// OiBSurfXYPlane.cpp #include "OiBSurfXYPlane.h" #include #include "trfxyp/BSurfXYPlane.h" #include "Inventor/nodes/SoSeparator.h" #include "Inventor/nodes/SoTranslation.h" #include "Inventor/nodes/SoRotationXYZ.h" #include "oiext/SoPolygon.hpp" const double PI2 = acos(-1.0)/2.0; //********************************************************************** // Class initialization. void OiBSurfXYPlane::init_class() const { SoPolygon::initClass(); } //********************************************************************** // Generate OI representation. SoNode* OiBSurfXYPlane:: generate_representation(const Surface& srf, const OiSurfaceTraits traits) const { assert( srf.get_type() == BSurfXYPlane::get_static_type() ); const BSurfXYPlane& rsrf = dynamic_cast(srf); double dist = rsrf.get_parameter(SurfXYPlane::DISTNORM); double phi = rsrf.get_parameter(SurfXYPlane::NORMPHI); double dx = dist*cos(phi); double dy = dist*sin(phi); double v1 = rsrf.get_vmin(); double v2 = rsrf.get_vmax(); double z1 = rsrf.get_zmin(); double z2 = rsrf.get_zmax(); SoPolygon::PointList points; points.push_back( CartesianTwoPoint(z1,v1) ); points.push_back( CartesianTwoPoint(z2,v1) ); points.push_back( CartesianTwoPoint(z2,v2) ); points.push_back( CartesianTwoPoint(z1,v2) ); int ispace = traits.ispace; // Create the separator to hold the transformation and object. SoSeparator* psep = new SoSeparator; // Finally rotate to the desired phi position. { SoRotationXYZ* prot = new SoRotationXYZ; prot->axis = SoRotationXYZ::Z; prot->angle = phi; psep->addChild(prot); } // Next translate out the required distance along x. { SoTranslation* ptrans = new SoTranslation; ptrans->translation.setValue(dist,0.0,0.0); psep->addChild(ptrans); } // First rotate about y so that z is correct. { SoRotationXYZ* prot = new SoRotationXYZ; prot->axis = SoRotationXYZ::Y; prot->angle = PI2; psep->addChild(prot); } // Add the plane. { SoPolygon* psobj = new SoPolygon(points,ispace); psep->addChild(psobj); } return psep; } //**********************************************************************