Browse Source

add dxf2egg

David Rose 21 years ago
parent
commit
877a7b9cea

+ 4 - 3
pandatool/src/dxf/Sources.pp

@@ -8,10 +8,11 @@
   #define UNIX_SYS_LIBS m
   
   #define SOURCES \
-    dxfFile.cxx dxfFile.h dxfLayer.h dxfLayerMap.cxx dxfLayerMap.h \
-    dxfVertex.cxx dxfVertex.h dxfVertexMap.cxx dxfVertexMap.h
+    dxfFile.cxx dxfFile.h dxfLayer.h dxfLayer.cxx \
+    dxfLayerMap.cxx dxfLayerMap.h \
+    dxfVertex.cxx dxfVertex.h
 
   #define INSTALL_HEADERS \
-    dxfFile.h dxfLayer.h dxfLayerMap.h dxfVertex.h dxfVertexMap.h
+    dxfFile.h dxfLayer.h dxfLayerMap.h dxfVertex.h
 
 #end ss_lib_target

+ 1 - 1
pandatool/src/dxf/dxfFile.cxx

@@ -656,7 +656,7 @@ change_section(Section new_section) {
 ////////////////////////////////////////////////////////////////////
 void DXFFile::
 change_layer(const string &layer_name) {
-  if (_layer == NULL || _layer->_name != layer_name) {
+  if (_layer == NULL || _layer->get_name() != layer_name) {
     _layer = _layers.get_layer(layer_name, this);
   }
 }

+ 16 - 17
pandatool/src/dxf/dxfVertexMap.h → pandatool/src/dxf/dxfLayer.cxx

@@ -1,4 +1,4 @@
-// Filename: dxfVertexMap.h
+// Filename: dxfLayer.cxx
 // Created by:  drose (04May04)
 //
 ////////////////////////////////////////////////////////////////////
@@ -16,24 +16,23 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifndef DXFVERTEXMAP_H
-#define DXFVERTEXMAP_H
+#include "dxfLayer.h"
 
-#include "pandatoolbase.h"
-
-#include "dxfVertex.h"
-#include "pmap.h"
 
 ////////////////////////////////////////////////////////////////////
-// 	 Class : DXFVertexMap
-// Description : This is a map of DXFVertex to an integer index
-//               number.  It is intended to be used to collapse
-//               together identical vertices, since the DXF file has
-//               no inherent notion of shared vertices.
+//     Function: DXFLayer::Constructor
+//       Access: Public
+//  Description:
 ////////////////////////////////////////////////////////////////////
-class DXFVertexMap : public pmap<DXFVertex, int> {
-public:
-  int get_vertex_index(const DXFVertex &vert);
-};
+DXFLayer::
+DXFLayer(const string &name) : Namable(name) {
+}
 
-#endif
+////////////////////////////////////////////////////////////////////
+//     Function: DXFLayer::Destructor
+//       Access: Public, Virtual
+//  Description:
+////////////////////////////////////////////////////////////////////
+DXFLayer::
+~DXFLayer() {
+}

+ 4 - 12
pandatool/src/dxf/dxfLayer.h

@@ -20,7 +20,7 @@
 #define DXFLAYER_H
 
 #include "pandatoolbase.h"
-#include "dxfVertexMap.h"
+#include "namable.h"
 
 ////////////////////////////////////////////////////////////////////
 // 	 Class : DXFLayer
@@ -29,21 +29,13 @@
 //               the file, or it may be implicitly defined by an
 //               entity's having referenced it.
 //
-//               The DXFLayer class provides a facility for collapsing
-//               identical vertices, via the _vmap member; however,
-//               this is not automatic and must be done explicitly by
-//               user code.
-//
 //               User code may derive from DXFLayer to associate
 //               private data with each layer, if desired.
 ////////////////////////////////////////////////////////////////////
-class DXFLayer {
+class DXFLayer : public Namable {
 public:
-  DXFLayer(const string &name) : _name(name) { }
-  virtual ~DXFLayer() { }
-  
-  string _name;
-  DXFVertexMap _vmap;
+  DXFLayer(const string &name);
+  virtual ~DXFLayer();
 };
 
 #endif

+ 0 - 48
pandatool/src/dxf/dxfVertexMap.cxx

@@ -1,48 +0,0 @@
-// Filename: dxfVertexMap.cxx
-// Created by:  drose (04May04)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#include "dxfVertexMap.h"
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXFVertexMap::get_vertex_index
-//       Access: Public
-//  Description: Looks up the vertex in the map, and returns an index
-//               unique to that vertex.  If the vertex has been used
-//               before, returns the index used previously; otherwise,
-//               assigns a new, unique index to the vertex and returns
-//               that.
-////////////////////////////////////////////////////////////////////
-int DXFVertexMap::
-get_vertex_index(const DXFVertex &vert) {
-  iterator vmi;
-  vmi = find(vert);
-  if (vmi != end()) {
-    // The vertex was already here.
-    return (*vmi).second;
-  }
-
-  // Nope, need a new vertex.
-  int index = size();
-  (*this)[vert] = index;
-
-  // That should have added one to the map.
-  nassertr((int)size() == index+1, index);
-
-  return index;
-}
-

+ 15 - 0
pandatool/src/dxfprogs/Sources.pp

@@ -13,3 +13,18 @@
     dxfPoints.cxx dxfPoints.h
 
 #end bin_target
+
+#begin bin_target
+  #define TARGET dxf2egg
+  #define LOCAL_LIBS dxf dxfegg eggbase progbase
+
+  #define OTHER_LIBS \
+    egg:c pandaegg:m \
+    linmath:c pnmimagetypes:c pnmimage:c putil:c mathutil:c event:c panda:m \
+    express:c pandaexpress:m \
+    dtoolutil:c dtoolbase:c dconfig:c dtoolconfig:m dtool:m pystub
+
+  #define SOURCES \
+    dxfToEgg.cxx dxfToEgg.h
+
+#end bin_target

+ 1 - 1
pandatool/src/ptloader/Sources.pp

@@ -2,7 +2,7 @@
   #define TARGET ptloader
   #define BUILDING_DLL BUILDING_PTLOADER
   #define LOCAL_LIBS \
-    fltegg flt lwoegg lwo converter pandatoolbase
+    fltegg flt lwoegg lwo dxfegg dxf converter pandatoolbase
   #define OTHER_LIBS \
     egg2pg:c builder:c egg:c pandaegg:m \
     mathutil:c linmath:c putil:c \

+ 6 - 2
pandatool/src/ptloader/config_ptloader.cxx

@@ -19,10 +19,11 @@
 #include "config_ptloader.h"
 #include "loaderFileTypePandatool.h"
 
-#include "config_lwo.h"
-#include "fltToEggConverter.h"
 #include "config_flt.h"
+#include "fltToEggConverter.h"
+#include "config_lwo.h"
 #include "lwoToEggConverter.h"
+#include "dxfToEggConverter.h"
 
 /*
 #ifdef HAVE_DX
@@ -81,6 +82,9 @@ init_libptloader() {
   LwoToEggConverter *lwo = new LwoToEggConverter;
   reg->register_type(new LoaderFileTypePandatool(lwo));
 
+  DXFToEggConverter *dxf = new DXFToEggConverter;
+  reg->register_type(new LoaderFileTypePandatool(dxf));
+
   /*
 #ifdef HAVE_DX
   init_libxfile();