Panda3D
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. More...
 
virtual void begin_section ()
 A hook for user code, if desired. More...
 
virtual void done_entity ()
 This is the primary hook for user code. More...
 
virtual void done_vertex ()
 A hook for user code, if desired. More...
 
virtual void end_file ()
 A hook for user code, if desired. More...
 
virtual void end_section ()
 A hook for user code, if desired. More...
 
virtual void error ()
 A hook for user code, if desired. More...
 
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()). More...
 
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. More...
 
void process (Filename filename)
 Opens the indicated filename and reads it as a DXF file. More...
 
void process (std::istream *in, bool owns_in)
 Reads the indicated stream as a DXF file. More...
 

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. More...
 

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 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 371 of file dxfFile.cxx.

◆ 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 380 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 406 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 391 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 424 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 415 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 433 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 444 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 467 of file dxfFile.cxx.

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

◆ 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 482 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 310 of file dxfFile.cxx.

References Filename::set_text().

◆ 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 328 of file dxfFile.cxx.


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