Panda3D
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
DXFFile Class Reference

A generic DXF-reading class. More...

#include "dxfFile.h"

Inheritance diagram for DXFFile:
MemoryBase DXFPoints DXFToEggConverter

Classes

struct  Color
 

Public Types

enum  Entity {
  EN_unknown , EN_3dface , EN_point , EN_insert ,
  EN_vertex , EN_polyline
}
 
enum  PolylineFlags {
  PF_closed = 0x01 , PF_curve_fit = 0x02 , PF_spline_fit = 0x04 , PF_3d = 0x08 ,
  PF_3d_mesh = 0x10 , PF_closed_n = 0x20 , PF_polyface = 0x40 , PF_continuous_linetype = 0x80
}
 
enum  Section {
  SE_unknown , SE_header , SE_tables , SE_blocks ,
  SE_entities , SE_objects
}
 
enum  State {
  ST_top , ST_section , ST_entity , ST_verts ,
  ST_error , ST_done
}
 

Public Member Functions

virtual void begin_file ()
 A hook for user code, if desired.
 
virtual void begin_section ()
 A hook for user code, if desired.
 
virtual void done_entity ()
 This is the primary hook for user code.
 
virtual void done_vertex ()
 A hook for user code, if desired.
 
virtual void end_file ()
 A hook for user code, if desired.
 
virtual void end_section ()
 A hook for user code, if desired.
 
virtual void error ()
 A hook for user code, if desired.
 
const Colorget_color () const
 This is a convenience function to return the r,g,b color of the current entity (at the time of done_entity()).
 
virtual DXFLayernew_layer (const std::string &name)
 
void ocs_2_wcs ()
 Assuming the current entity is a planar-based entity, for instance, a 2-d polygon (as opposed to a 3-d polygon), this converts the coordinates from the funny planar coordinate system to the world coordinates.
 
void process (Filename filename)
 Opens the indicated filename and reads it as a DXF file.
 
void process (std::istream *in, bool owns_in)
 Reads the indicated stream as a DXF file.
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 

Static Public Member Functions

static int find_color (double r, double g, double b)
 Returns the index of the closest matching AutoCAD color to the indicated r, g, b.
 

Public Attributes

int _color_index
 
Entity _entity
 
int _flags
 
DXFLayer_layer
 
DXFLayerMap _layers
 
LPoint3d _p
 
LPoint3d _q
 
LPoint3d _r
 
LPoint3d _s
 
Section _section
 
DXFVertices _verts
 
LVector3d _z
 

Static Public Attributes

static Color _colors [DXF_num_colors]
 

Detailed Description

A generic DXF-reading class.

This class can read a DXF file but doesn't actually do anything with the data; it's intended to be inherited from and the appropriate functions overridden (particularly DoneEntity()).

Definition at line 35 of file dxfFile.h.

Member Enumeration Documentation

◆ Entity

enum DXFFile::Entity

Definition at line 80 of file dxfFile.h.

◆ PolylineFlags

enum DXFFile::PolylineFlags

Definition at line 88 of file dxfFile.h.

◆ Section

enum DXFFile::Section

Definition at line 72 of file dxfFile.h.

◆ State

enum DXFFile::State

Definition at line 64 of file dxfFile.h.

Constructor & Destructor Documentation

◆ DXFFile()

DXFFile::DXFFile ( )

Definition at line 285 of file dxfFile.cxx.

◆ ~DXFFile()

DXFFile::~DXFFile ( )
virtual

Definition at line 297 of file dxfFile.cxx.

Member Function Documentation

◆ begin_file()

void DXFFile::begin_file ( )
virtual

A hook for user code, if desired.

This function is called whenever processing begins on the DXF file.

Definition at line 370 of file dxfFile.cxx.

Referenced by process().

◆ begin_section()

void DXFFile::begin_section ( )
virtual

A hook for user code, if desired.

This function is called whenever a new section in the DXF file is encountered.

Definition at line 379 of file dxfFile.cxx.

◆ done_entity()

void DXFFile::done_entity ( )
virtual

This is the primary hook for user code.

This function is called when an entity is read from the DXF file. This may be something like a polygon, point, or a polygon mesh: any geometry. It is up to the user code to override this function and do something interesting with each piece of geometry that is read.

Reimplemented in DXFPoints.

Definition at line 405 of file dxfFile.cxx.

◆ done_vertex()

void DXFFile::done_vertex ( )
virtual

A hook for user code, if desired.

This function is called whenever a vertex is read from the DXF file. This function has the default behavior of adding the vertex to the _verts list, so that when done_entity() is called later, it will have the complete list of vertices available to it.

Definition at line 390 of file dxfFile.cxx.

◆ end_file()

void DXFFile::end_file ( )
virtual

A hook for user code, if desired.

This function is called when the DXF processing is complete.

Definition at line 423 of file dxfFile.cxx.

◆ end_section()

void DXFFile::end_section ( )
virtual

A hook for user code, if desired.

This function is called as each section in the DXF file is finished.

Definition at line 414 of file dxfFile.cxx.

◆ error()

void DXFFile::error ( )
virtual

A hook for user code, if desired.

This function is called when some unexpected error occurs while reading the DXF file.

Definition at line 432 of file dxfFile.cxx.

◆ find_color()

int DXFFile::find_color ( double r,
double g,
double b )
static

Returns the index of the closest matching AutoCAD color to the indicated r, g, b.

Definition at line 443 of file dxfFile.cxx.

◆ get_color()

const DXFFile::Color & DXFFile::get_color ( ) const

This is a convenience function to return the r,g,b color of the current entity (at the time of done_entity()).

It's based on the _color_index value that was read from the DXF file.

Definition at line 466 of file dxfFile.cxx.

Referenced by DXFToEggLayer::add_line(), and DXFToEggLayer::add_polygon().

◆ new_layer()

virtual DXFLayer * DXFFile::new_layer ( const std::string & name)
inlinevirtual

Definition at line 60 of file dxfFile.h.

◆ ocs_2_wcs()

void DXFFile::ocs_2_wcs ( )

Assuming the current entity is a planar-based entity, for instance, a 2-d polygon (as opposed to a 3-d polygon), this converts the coordinates from the funny planar coordinate system to the world coordinates.

It converts the _p value of the entity, as well as all vertices in the _verts list.

Definition at line 481 of file dxfFile.cxx.

Referenced by DXFPoints::done_entity().

◆ process() [1/2]

void DXFFile::process ( Filename filename)

Opens the indicated filename and reads it as a DXF file.

Definition at line 309 of file dxfFile.cxx.

References VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), process(), and Filename::set_text().

Referenced by DXFToEggConverter::convert_file(), and process().

◆ process() [2/2]

void DXFFile::process ( std::istream * in,
bool owns_in )

Reads the indicated stream as a DXF file.

If owns_in is true, then the istream will be deleted via vfs->close_read_file() when the DXFFile object destructs.

Definition at line 327 of file dxfFile.cxx.

References begin_file(), VirtualFileSystem::close_read_file(), and VirtualFileSystem::get_global_ptr().

Member Data Documentation

◆ _color_index

int DXFFile::_color_index

Definition at line 128 of file dxfFile.h.

◆ _colors

DXFFile::Color DXFFile::_colors
static

Definition at line 22 of file dxfFile.h.

◆ _entity

Entity DXFFile::_entity

Definition at line 125 of file dxfFile.h.

◆ _flags

int DXFFile::_flags

Definition at line 123 of file dxfFile.h.

◆ _layer

DXFLayer* DXFFile::_layer

Definition at line 129 of file dxfFile.h.

◆ _layers

DXFLayerMap DXFFile::_layers

Definition at line 136 of file dxfFile.h.

◆ _p

LPoint3d DXFFile::_p

Definition at line 126 of file dxfFile.h.

◆ _q

LPoint3d DXFFile::_q

Definition at line 126 of file dxfFile.h.

◆ _r

LPoint3d DXFFile::_r

Definition at line 126 of file dxfFile.h.

◆ _s

LPoint3d DXFFile::_s

Definition at line 126 of file dxfFile.h.

◆ _section

Section DXFFile::_section

Definition at line 124 of file dxfFile.h.

◆ _verts

DXFVertices DXFFile::_verts

Definition at line 133 of file dxfFile.h.

◆ _z

LVector3d DXFFile::_z

Definition at line 127 of file dxfFile.h.


The documentation for this class was generated from the following files: