Close

Relief for ODA Team in Ukraine

Learn more
ODA Facet Modeler
Create Objects via Revolution

This chapter contains information on how to create objects via revolution.

A body of revolution is a solid body that is the result of rotating a 2D profile about an axis. In Facet Modeler there are three static methods that create a revolution body; each has its own parameters but they all share DeviationParams. The deviation represents the accuracy of approximation and has its default value set to 0.5.

The ways to create a revolution body are:

  • Using a base profile, radius, height and deviation parameters. In this case the revolution axis is kZAxis and there is also scaling along kXAxis with a coefficient that depends on dHeight and along kYAxis with a coefficient that depends on dRadius.
    static Body revolution(const Profile2D& rBase, double dRadius, double dHeight, const DeviationParams& deviation = FMGeGbl::gDefDev);
  • Using a base profile, circle arc with revolution axis and angles, deviation parameters and an optional transformation matrix.
    static Body revolution(const Profile2D& base, const OdGeCircArc3d& revAxisAndAngles, const DeviationParams& deviation = FMGeGbl::gDefDev, const OdGeMatrix2d* pBaseTransform = NULL);
  • Using a base profile, revolution axis, position of the revolution axis, start and end angles of revolution, and deviation parameters.
    static Body revolution(const Profile2D& base, const OdGeVector3d& revAxis, const OdGePoint3d& axisPosition, double startAng, double endAng, const DeviationParams& deviation = FMGeGbl::gDefDev);

Below is an illustration of the third method's parameters:



For example, the first static method can be used to create a sphere out of a circle profile.
The second static method can be used to create a torus out of a circle profile and an arc it will rotate about.
The second method accepts parameters in the form of OdGeCircArc3d, which makes it more compact than the third method, plus a transformation matrix.
Examples for the first and the second constructors are demonstrated below.

Create a Sphere via Revolution

To create a sphere, you can create a semicircle profile and then use the following revolution() method with your semicircle as the base profile:

static Body revolution(const Profile2D& rBase, double dRadius, double dHeight, const DeviationParams& deviation = FMGeGbl::gDefDev);


The following code snippet creates a sphere with a radius of dRadius:

Body createSphere(const DeviationParams& devDeviation, double dRadius)
{
  // Create a sphere profile
  Profile2D cSphereProfile; 

  // With one contour
  cSphereProfile.resize(1);   
  
  // Add vertices with bulge == 1 (Arc)
  cSphereProfile.front().appendVertex(OdGePoint2d::kOrigin); // Add first point
  cSphereProfile.front().appendVertex(OdGePoint2d::kOrigin + OdGeVector2d::kXAxis * dRradius * 2, 1); 

  // Will be reversed in revolution method.
  cSphereProfile.front().setOrientationAt(0, efoBack);
  cSphereProfile.front().setOrientationAt(1, efoBack);
  
  // Close profile
  cSphereProfile.front().setClosed();  

  // Make contour outer
  cSphereProfile.front().makeCCW();         

  // Create revolution body
  return Body::revolution(cSphereProfile, dRadius, dRadius * 2, devDeviation);
}

Create a Torus via Revolution

To create a torus, you can create a circle and then use the following revolution() method with your circle as the base profile:

static Body revolution(const Profile2D& base, const OdGeCircArc3d& revAxisAndAngles, const DeviationParams& deviation = FMGeGbl::gDefDev, const OdGeMatrix2d* pBaseTransform = NULL);


The following code snippet creates a torus with a minor radius of dRadius1 and major radius of dRadius2. It also uses a matrix to move the circle profile from the kOrigin point so that it would revolve around an arc and form a torus:

Body createTorus(const DeviationParams& devDeviation, double dRadius1, double dRadius2)
{
  Profile2D cTorusProfile;
  cTorusProfile.resize(1);

  OdGeMatrix2d move;
  OdGeCircArc3d arc (OdGePoint3d::kOrigin, OdGeVector3d::kXAxis, dRadius2);

  cTorusProfile.front().appendVertex(OdGePoint2d::kOrigin + OdGeVector2d::kXAxis * dRadius1, 1);
  cTorusProfile.front().appendVertex(OdGePoint2d::kOrigin - OdGeVector2d::kXAxis * dRadius1, 1);

  move.setToTranslation(OdGeVector2d(dRadius2, 0.0));

  cTorusProfile.transformBy(move);

  cTorusProfile.front().setOrientationAt(0, efoFront);
  cTorusProfile.front().setOrientationAt(1, efoFront);
  cTorusProfile.front().setClosed();
  cTorusProfile.front().makeCCW();

  return Body::revolution(cTorusProfile, arc, devDeviation);
}

See Also

Work With B-Rep Data in Facet Modeler
Create Basic Objects
Create Objects via Extrusion
Iterate through Entities
Perform Boolean Operations
Perform Slicing Operations
Calculate Area and Volume
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.