[brlcad-commits] SF.net SVN: brlcad:[36454] brlcad/trunk/src/conv/step
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <ind...@us...> - 2009-11-10 12:32:13
|
Revision: 36454 http://brlcad.svn.sourceforge.net/brlcad/?rev=36454&view=rev Author: indianlarry Date: 2009-11-10 12:32:00 +0000 (Tue, 10 Nov 2009) Log Message: ----------- Added openNURBS brep generation code for Toroidal and Spherical surfacs. Modified Paths: -------------- brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp brlcad/trunk/src/conv/step/SphericalSurface.cpp brlcad/trunk/src/conv/step/SphericalSurface.h brlcad/trunk/src/conv/step/ToroidalSurface.cpp brlcad/trunk/src/conv/step/ToroidalSurface.h Modified: brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp =================================================================== --- brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp 2009-11-10 12:02:55 UTC (rev 36453) +++ brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp 2009-11-10 12:32:00 UTC (rev 36454) @@ -88,6 +88,8 @@ #include "RationalBSplineSurfaceWithKnots.h" #include "RationalQuasiUniformSurface.h" #include "RationalUniformSurface.h" +#include "SphericalSurface.h" +#include "ToroidalSurface.h" #include "UniformSurface.h" #include "AdvancedBrepShapeRepresentation.h" @@ -2587,6 +2589,62 @@ return true; } +bool SphericalSurface::LoadONBrep(ON_Brep *brep) +{ + // get sphere center + ON_3dPoint center = GetOrigin(); + center = center * LocalUnits::length; + + // Creates a sphere with given center and radius. + ON_Sphere sphere(center, radius * LocalUnits::length); + + ON_RevSurface* s = sphere.RevSurfaceForm(); + if (s) { + double r = fabs(sphere.radius); + if ( r <= ON_SQRT_EPSILON ) + r = 1.0; + r *= ON_PI; + s->SetDomain(0,0.0,2.0*r); + s->SetDomain(1,-r,r); + } + ON_id = brep->AddSurface(s); + + return true; +} + +bool ToroidalSurface::LoadONBrep(ON_Brep *brep) +{ + ON_3dPoint origin = GetOrigin(); + ON_3dVector norm = GetNormal(); + ON_3dVector xaxis = GetXAxis(); + ON_3dVector yaxis = GetYAxis(); + + origin = origin * LocalUnits::length; + + ON_Plane p(origin, xaxis, yaxis); + + // Creates a torus parallel to the plane + // with given major and minor radius. + ON_Torus torus(p, major_radius * LocalUnits::length, minor_radius * LocalUnits::length); + + ON_RevSurface* s = torus.RevSurfaceForm(); + if (s) { + double r = fabs(torus.major_radius); + if (r <= ON_SQRT_EPSILON) + r = 1.0; + r *= ON_PI; + s->SetDomain(0, 0.0, 2.0 * r); + r = fabs(torus.minor_radius); + if (r <= ON_SQRT_EPSILON) + r = 1.0; + r *= ON_PI; + s->SetDomain(1, 0.0, 2.0 * r); + } + ON_id = brep->AddSurface(s); + + return true; +} + bool VertexLoop::LoadONBrep(ON_Brep *brep) { Modified: brlcad/trunk/src/conv/step/SphericalSurface.cpp =================================================================== --- brlcad/trunk/src/conv/step/SphericalSurface.cpp 2009-11-10 12:02:55 UTC (rev 36453) +++ brlcad/trunk/src/conv/step/SphericalSurface.cpp 2009-11-10 12:32:00 UTC (rev 36454) @@ -25,6 +25,8 @@ #include "STEPWrapper.h" #include "Factory.h" +#include "Axis2Placement3D.h" + #include "SphericalSurface.h" #define CLASSNAME "SphericalSurface" @@ -44,6 +46,27 @@ SphericalSurface::~SphericalSurface() { } +const double * +SphericalSurface::GetOrigin() { + return position->GetOrigin(); +} + +const double * +SphericalSurface::GetNormal() { + return position->GetAxis(2); +} + +const double * +SphericalSurface::GetXAxis() { + return position->GetXAxis(); +} + +const double * +SphericalSurface::GetYAxis() { + return position->GetYAxis(); +} + + bool SphericalSurface::Load(STEPWrapper *sw, SCLP23(Application_instance) *sse) { step=sw; @@ -91,15 +114,6 @@ return (*i).second; } } - -bool -SphericalSurface::LoadONBrep(ON_Brep *brep) -{ - cerr << "Error: ::LoadONBrep(ON_Brep *brep) not implemented for " << entityname << endl; - return false; -} - - // Local Variables: // tab-width: 8 // mode: C++ Modified: brlcad/trunk/src/conv/step/SphericalSurface.h =================================================================== --- brlcad/trunk/src/conv/step/SphericalSurface.h 2009-11-10 12:02:55 UTC (rev 36453) +++ brlcad/trunk/src/conv/step/SphericalSurface.h 2009-11-10 12:32:00 UTC (rev 36454) @@ -40,6 +40,10 @@ SphericalSurface(); virtual ~SphericalSurface(); SphericalSurface(STEPWrapper *sw,int STEPid); + const double *GetOrigin(); + const double *GetNormal(); + const double *GetXAxis(); + const double *GetYAxis(); bool Load(STEPWrapper *sw,SCLP23(Application_instance) *sse); virtual bool LoadONBrep(ON_Brep *brep); virtual void Print(int level); Modified: brlcad/trunk/src/conv/step/ToroidalSurface.cpp =================================================================== --- brlcad/trunk/src/conv/step/ToroidalSurface.cpp 2009-11-10 12:02:55 UTC (rev 36453) +++ brlcad/trunk/src/conv/step/ToroidalSurface.cpp 2009-11-10 12:32:00 UTC (rev 36454) @@ -25,6 +25,8 @@ #include "STEPWrapper.h" #include "Factory.h" +#include "Axis2Placement3D.h" + #include "ToroidalSurface.h" #define CLASSNAME "ToroidalSurface" @@ -44,6 +46,26 @@ ToroidalSurface::~ToroidalSurface() { } +const double * +ToroidalSurface::GetOrigin() { + return position->GetOrigin(); +} + +const double * +ToroidalSurface::GetNormal() { + return position->GetAxis(2); +} + +const double * +ToroidalSurface::GetXAxis() { + return position->GetXAxis(); +} + +const double * +ToroidalSurface::GetYAxis() { + return position->GetYAxis(); +} + bool ToroidalSurface::Load(STEPWrapper *sw, SCLP23(Application_instance) *sse) { step=sw; @@ -94,14 +116,6 @@ } } -bool -ToroidalSurface::LoadONBrep(ON_Brep *brep) -{ - cerr << "Error: ::LoadONBrep(ON_Brep *brep) not implemented for " << entityname << endl; - return false; -} - - // Local Variables: // tab-width: 8 // mode: C++ Modified: brlcad/trunk/src/conv/step/ToroidalSurface.h =================================================================== --- brlcad/trunk/src/conv/step/ToroidalSurface.h 2009-11-10 12:02:55 UTC (rev 36453) +++ brlcad/trunk/src/conv/step/ToroidalSurface.h 2009-11-10 12:32:00 UTC (rev 36454) @@ -41,6 +41,10 @@ ToroidalSurface(); virtual ~ToroidalSurface(); ToroidalSurface(STEPWrapper *sw,int STEPid); + const double *GetOrigin(); + const double *GetNormal(); + const double *GetXAxis(); + const double *GetYAxis(); bool Load(STEPWrapper *sw,SCLP23(Application_instance) *sse); virtual bool LoadONBrep(ON_Brep *brep); virtual void Print(int level); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |