Panda3D
 All Classes Functions Variables Enumerations
dxfToEgg.cxx
1 // Filename: dxfToEgg.cxx
2 // Created by: drose (04May04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "dxfToEgg.h"
16 
17 #include "dxfToEggConverter.h"
18 #include "pystub.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: DXFToEgg::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 DXFToEgg::
26 DXFToEgg() :
27  SomethingToEgg("DXF", ".dxf")
28 {
29  add_units_options();
30  add_normals_options();
31  add_transform_options();
32 
33  set_program_brief("convert AutoCAD .dxf files to .egg files");
34  set_program_description
35  ("This program converts DXF (AutoCAD interchange format) to egg. It "
36  "only converts polygon data, with no fancy tricks. DXF does not support "
37  "hierarchical databases, so dxf2egg creates a single group at the root "
38  "level for each layer in the DXF file.");
39 
40  redescribe_option
41  ("cs",
42  "Specify the coordinate system of the input " + _format_name +
43  " file. Normally, this is z-up.");
44 
45  _coordinate_system = CS_zup_right;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: DXFToEgg::run
50 // Access: Public
51 // Description:
52 ////////////////////////////////////////////////////////////////////
53 void DXFToEgg::
54 run() {
55  nout << "Reading " << _input_filename << "\n";
56 
57  _data->set_coordinate_system(_coordinate_system);
58 
59  DXFToEggConverter converter;
60  converter.set_egg_data(_data);
61  converter._allow_errors = _allow_errors;
62 
63  apply_parameters(converter);
64 
65  if (!converter.convert_file(_input_filename)) {
66  nout << "Errors in conversion.\n";
67  exit(1);
68  }
69 
71  nout << "\n";
72 }
73 
74 
75 int main(int argc, char *argv[]) {
76  // A call to pystub() to force libpystub.so to be linked in.
77  pystub();
78 
79  DXFToEgg prog;
80  prog.parse_command_line(argc, argv);
81  prog.run();
82  return 0;
83 }
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
A program to read a DXF file and generate an egg file.
Definition: dxfToEgg.h:28
void set_egg_data(EggData *egg_data)
Sets the egg data that will be filled in when convert_file() is called.
void write_egg_file()
Writes out the egg file as the normal result of the program.
Definition: eggWriter.cxx:193
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
This is the general base class for a file-converter program that reads some model file format and gen...
This class supervises the construction of an EggData structure from a DXF file.