15 #include "eggToDXFLayer.h" 19 #include "eggGroupNode.h" 20 #include "eggPolygon.h" 30 _egg2dxf(egg2dxf), _group(group)
42 _egg2dxf(copy._egg2dxf),
44 _layer_color(copy._layer_color)
56 _egg2dxf = copy._egg2dxf;
58 _layer_color = copy._layer_color;
73 int autocad_color = get_autocad_color(color);
75 ColorCounts::iterator cci;
76 cci = _color_counts.find(autocad_color);
77 if (cci == _color_counts.end()) {
79 _color_counts[autocad_color] = 1;
98 ColorCounts::iterator cci;
99 for (cci = _color_counts.begin(); cci != _color_counts.end(); ++cci) {
100 int count = (*cci).second;
101 if (count > max_count) {
102 _layer_color = (*cci).first;
120 <<
"2\n" << _group->get_name() <<
"\n" 122 <<
"62\n" << _layer_color <<
"\n" 123 <<
"6\nCONTINUOUS\n";
133 out <<
"0\nPOLYLINE\n" 134 <<
"8\n" << _group->get_name() <<
"\n" 137 <<
"62\n" << get_autocad_color(poly->
get_color()) <<
"\n";
141 EggPolygon::reverse_iterator vi;
142 for (vi = poly->rbegin(); vi != poly->rend(); ++vi) {
146 <<
"10\n" << pos[0] <<
"\n" 147 <<
"20\n" << pos[1] <<
"\n" 148 <<
"30\n" << pos[2] <<
"\n";
150 out <<
"0\nSEQEND\n";
160 if (poly->size() > 4) {
166 EggGroupNode::iterator ci;
167 for (ci = group->begin(); ci != group->end(); ++ci) {
169 if (child->
is_of_type(EggPolygon::get_class_type())) {
174 }
else if (poly->size() > 2) {
177 <<
"8\n" << _group->get_name() <<
"\n";
182 EggPolygon::reverse_iterator vi;
183 for (i = 0, vi = poly->rbegin(); vi != poly->rend(); ++i, ++vi) {
186 out << 10 + i <<
"\n" << pos[0] <<
"\n" 187 << 20 + i <<
"\n" << pos[1] <<
"\n" 188 << 30 + i <<
"\n" << pos[2] <<
"\n";
189 if (i == 2 && poly->size() == 3) {
191 out << 11 + i <<
"\n" << pos[0] <<
"\n" 192 << 21 + i <<
"\n" << pos[1] <<
"\n" 193 << 31 + i <<
"\n" << pos[2] <<
"\n";
208 EggGroupNode::iterator ci;
209 for (ci = _group->begin(); ci != _group->end(); ++ci) {
211 if (child->
is_of_type(EggPolygon::get_class_type())) {
213 if (_egg2dxf->_use_polyline) {
229 get_autocad_color(
const LColor &color) {
231 static ColorMap _map;
233 ColorMap::iterator cmi;
234 cmi = _map.find(color);
235 if (cmi != _map.end()) {
236 return (*cmi).second;
240 _map[color] = result;
This is our own Panda specialization on the default STL map.
void write_3d_face(EggPolygon *poly, ostream &out)
Writes a polygon as a 3DFACE entity.
void write_polyline(EggPolygon *poly, ostream &out)
Writes a polygon as a POLYLINE entity.
const LMatrix4d & get_vertex_frame() const
Returns the coordinate frame of the vertices referenced by primitives at or under this node...
A base class for nodes in the hierarchy that are not leaf nodes.
LVertexd get_pos3() const
Valid if get_num_dimensions() returns 3 or 4.
LColor get_color() const
Returns the color set on this particular attribute.
void write_layer(ostream &out)
Writes the layer definition into the table at the beginning of the DXF file.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
void write_entities(ostream &out)
Writes out the "entities", e.g.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
bool triangulate_into(EggGroupNode *container, bool convex_also) const
Subdivides the polygon into triangles and adds each one to the indicated container.
This is the base class for all three-component vectors and points.
This is the base class for all three-component vectors and points.
A base class for things that may be directly added into the egg hierarchy.
void choose_overall_color()
After all polygons have been accounted for, chooses the polygon color that occurred most often as the...
A program to read an egg file and write a DXF file.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
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. ...
A single layer in the DXF file to be written by EggToDXF.
void add_color(const LColor &color)
Records that one polygon is defined using the indicated color.