I don't know if this is the right place to give this input, but here goes
anyway:
I have an application based on OSG. A DXF file was read in using the
readNodeFile function. I noticed that the CIRCLEs in the DXF file had a
thickness associated with them that was not being shown in the imported
node. I reviewed the dxfCircle class and added a _thickness member variable.
Here is the modified class, below. There are probably other DXF ENTITIES
that have the optional thickness parameter, including at least ARC and LINE.
They will need the same thing done to them. I also noticed that, in our
system, the desired default for the inverted parameter passed to
scene::addTriangles and ::addQuads is true. I don't know if anyone else has
experienced it. I saw cylinders that are dark when viewed from the outside
and show the color when viewed from the inside.
class dxfCircle : public dxfBasicEntity
{
public:
dxfCircle() : _radius(0), _ocs(0,0,1), _thickness(0) {}
virtual ~dxfCircle() {}
virtual dxfBasicEntity* create() { return new dxfCircle; }
virtual const char* name() { return CIRCLE; }
virtual void assign(dxfFile* dxf, codeValue cv);
virtual void drawScene(scene* sc);
protected:
osg::Vec3d_center;
double_radius;
osg::Vec3d_ocs;
double_thickness;
};
dxfCircle::assign(dxfFile* dxf, codeValue cv)
{
double d = cv._double;
//unsigned short s = cv._short;
switch (cv._groupCode) {
case 10:
_center.x() = d;
break;
case 20:
_center.y() = d;
break;
case 30:
_center.z() = d;
break;
case 39:
_thickness = d;
break;
case 40:
_radius = d;
break;
case 210:
_ocs.x() = d;
break;
case 220:
_ocs.y() = d;
break;
case 230:
_ocs.z() = d;
break;
default:
dxfBasicEntity::assign(dxf, cv);
break;
}
}
void
dxfCircle::drawScene(scene* sc)
{
Matrixd m;
getOCSMatrix(_ocs, m);
sc-ocs(m);
std::vectorVec3d vlist;
std::vectorVec3d qlist;
int numsteps = 360/5; // baaarghf.
double angle_step = osg::DegreesToRadians((double)360.0 / (double)
numsteps);
double angle1 = 0.0f;
double angle2 = 0.0f;
Vec3d a = _center;
Vec3d b,c,d,e;
for (int r = 0; r numsteps; r++)
{
angle1 = angle2;
if (r == numsteps - 1)
angle2 = 0.0f;
else
angle2 += angle_step;
b = a + Vec3d(_radius * (double) sin(angle1), _radius * (double)
cos(angle1), 0);
c = a + Vec3d(_radius * (double) sin(angle2), _radius * (double)
cos(angle2), 0);
d = a + Vec3d(_radius * (double) sin(angle1), _radius * (double)
cos(angle1), _thickness);
e = a + Vec3d(_radius * (double) sin(angle2), _radius * (double)
cos(angle2), _thickness);
if(_thickness == 0)
{
//vlist.push_back(a);
vlist.push_back(b);
vlist.push_back(c);
}
else
{
qlist.push_back(b);
qlist.push_back(c);
qlist.push_back(e);
qlist.push_back(d);
}
}
if(_thickness == 0)
{
sc-addLineStrip(getLayer(), _color, vlist);
//sc-addTriangles(getLayer(), _color, vlist);
}
else
{
sc-addQuads(getLayer(), _color, qlist);
}
sc-ocs_clear();
}
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org