Panda3D
 All Classes Functions Variables Enumerations
dxfPoints.cxx
00001 // Filename: dxfPoints.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 "dxfPoints.h"
00016 #include "pystub.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: DXFPoints::Constructor
00020 //       Access: Public
00021 //  Description:
00022 ////////////////////////////////////////////////////////////////////
00023 DXFPoints::
00024 DXFPoints() :
00025   WithOutputFile(true, true, false)
00026 {
00027   // Indicate the extension name we expect the user to supply for
00028   // output files.
00029   _preferred_extension = ".txt";
00030 
00031   set_program_description
00032     ("This program reads an AutoCAD .dxf file and generates a simple "
00033      "list of all the points contained within it, one per line, to a "
00034      "text file, or to standard output.");
00035 
00036   clear_runlines();
00037   add_runline("[opts] input.dxf > output.txt");
00038   add_runline("[opts] -o output.txt input.dxf");
00039   add_runline("[opts] input.dxf output.txt");
00040 }
00041 
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: DXFPoints::run
00045 //       Access: Public
00046 //  Description:
00047 ////////////////////////////////////////////////////////////////////
00048 void DXFPoints::
00049 run() {
00050   // Invoke the DXFFile base class to process the input file.
00051   process(_input_filename);
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: DXFPoints::done_entity
00056 //       Access: Public, Virtual
00057 //  Description: This is inherited from DXFFile, and gets called as
00058 //               each entity (face, line, whatever) has finished
00059 //               processing.
00060 ////////////////////////////////////////////////////////////////////
00061 void DXFPoints::
00062 done_entity() {
00063   if (_entity == EN_point) {
00064     get_output() << _p << "\n";
00065 
00066   } else if (_entity == EN_insert) {
00067     ocs_2_wcs();
00068     get_output() << _p << "\n";
00069   }
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: DXFPoints::handle_args
00074 //       Access: Protected, Virtual
00075 //  Description:
00076 ////////////////////////////////////////////////////////////////////
00077 bool DXFPoints::
00078 handle_args(ProgramBase::Args &args) {
00079   if (args.empty()) {
00080     nout << "You must specify the .dxf file to read on the command line.\n";
00081     return false;
00082 
00083   } else if (args.size() != 1) {
00084     nout << "You must specify only one .dxf file to read on the command line.\n";
00085     return false;
00086   }
00087 
00088   _input_filename = args[0];
00089 
00090   return true;
00091 }
00092 
00093 
00094 int main(int argc, char *argv[]) {
00095   // A call to pystub() to force libpystub.so to be linked in.
00096   pystub();
00097 
00098   DXFPoints prog;
00099   prog.parse_command_line(argc, argv);
00100   prog.run();
00101   return 0;
00102 }
 All Classes Functions Variables Enumerations