Panda3D
 All Classes Functions Variables Enumerations
dxfToEgg.cxx
00001 // Filename: dxfToEgg.cxx
00002 // Created by:  drose (04May04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "dxfToEgg.h"
00016 
00017 #include "dxfToEggConverter.h"
00018 #include "pystub.h"
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: DXFToEgg::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 DXFToEgg::
00026 DXFToEgg() :
00027   SomethingToEgg("DXF", ".dxf")
00028 {
00029   add_units_options();
00030   add_normals_options();
00031   add_transform_options();
00032 
00033   set_program_description
00034     ("This program converts DXF (AutoCAD interchange format) to egg.  It "
00035      "only converts polygon data, with no fancy tricks.  DXF does not support "
00036      "hierarchical databases, so dxf2egg creates a single group at the root "
00037      "level for each layer in the DXF file.");
00038 
00039   redescribe_option
00040     ("cs",
00041      "Specify the coordinate system of the input " + _format_name +
00042      " file.  Normally, this is z-up.");
00043 
00044   _coordinate_system = CS_zup_right;
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: DXFToEgg::run
00049 //       Access: Public
00050 //  Description:
00051 ////////////////////////////////////////////////////////////////////
00052 void DXFToEgg::
00053 run() {
00054   nout << "Reading " << _input_filename << "\n";
00055 
00056   _data->set_coordinate_system(_coordinate_system);
00057 
00058   DXFToEggConverter converter;
00059   converter.set_egg_data(_data);
00060   converter._allow_errors = _allow_errors;
00061 
00062   apply_parameters(converter);
00063 
00064   if (!converter.convert_file(_input_filename)) {
00065     nout << "Errors in conversion.\n";
00066     exit(1);
00067   }
00068 
00069   write_egg_file();
00070   nout << "\n";
00071 }
00072 
00073 
00074 int main(int argc, char *argv[]) {
00075   // A call to pystub() to force libpystub.so to be linked in.
00076   pystub();
00077 
00078   DXFToEgg prog;
00079   prog.parse_command_line(argc, argv);
00080   prog.run();
00081   return 0;
00082 }
 All Classes Functions Variables Enumerations