Close

Relief for ODA Team in Ukraine

Learn more
ODA Facet Modeler
Create Objects via Extrusion

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

A solid of extrusion is a body with a fixed cross-sectional profile. In Facet Modeler there are two ways to create an extrusion body; each way is represented by a static method. These methods have a common DeviationParams deviation parameter which represents the accuracy of approximation and has its default value set to 0.5.

The ways to create an extrusion body are:

  • Using a base profile, extrusion vector and deviation parameters.
    static Body extrusion(const Profile2D& rBase, const OdGeVector3d& vDir, const DeviationParams& deviation = FMGeGbl::gDefDev);
  • Using a base profile, extrusion vector, initial 3D plane of the profile and deviation parameters. The profile is placed into the 3D plane defined by a matrix and then extruded along the path of the extrusion. The direction vector must be non-perpendicular to the z-axis of the initial 3D plane.
    static Body extrusion(const Profile2D& rBase, const OdGeMatrix3d& mBasePlane, const OdGeVector3d& vDir, const DeviationParams& deviation = FMGeGbl::gDefDev);



The only difference between these two constructors is that in the second case the transformation matrix is applied during the extrusion, whereas in the first case you would need to apply the matrix after the extrusion operation.
The usage of the first static method is shown below in the cylinder creation example.

Create a Cylinder via Extrusion

To create a cylinder, you can create a base profile and then call the extrusion() method with your profile:

static Body extrusion(const Profile2D& rBase, const OdGeVector3d& vDir, const DeviationParams& deviation = FMGeGbl::gDefDev);


The following code snippet creates a cylinder with a radius dRadius and height dHeight:


Body createCylinder(const DeviationParams& devDeviation, double dRadius, double dHeight)
{
  // Create base profile
  Profile2D cBase;
   // With one contour
  cBase.resize(1);
   cBase.front().appendVertex(OdGePoint2d::kOrigin - OdGeVector2d::kXAxis * dRadius, 1);
  cBase.front().appendVertex(OdGePoint2d::kOrigin + OdGeVector2d::kXAxis * dRadius, 1);
   cBase.front().setOrientationAt(0, efoFront);
  cBase.front().setOrientationAt(1, efoFront);
   // Close profile
  cBase.front().setClosed();
   // Make contour outer
  cBase.front().makeCCW();
   return Body::extrusion(cBase, OdGeVector3d::kZAxis * dHeight, devDeviation);
}

Create a Pipe via Extrusion

To create a pipe, you can create a ring profile and then use the extrusion() method with the ring as the base profile to extrude:

static Body extrusion(const Profile2D& rBase, const OdGeVector3d& vDir, const DeviationParams& deviation = FMGeGbl::gDefDev);


The following code snippet creates a pipe with a major radius dRadius1, minor radius dRadius2 and height dHeight:


Body createPipe1(const DeviationParams& devDeviation, double dRadius1, double dRadius2, double dHeight)
{
  Profile2D circle1;
  Profile2D circle2;
  Profile2D res;
   circle1 = Profile2D(Contour2D::createCircle(OdGePoint2d::kOrigin, dRadius1));
  circle2 = Profile2D(Contour2D::createCircle(OdGePoint2d::kOrigin, dRadius2));
   Profile2D::PerformOperation(eDifference, circle1, circle2, res);
   return Body::extrusion(res, OdGeVector3d::kZAxis * dHeight, devDeviation);
}

A pipe can also be created from two cylinders of different radii via a difference operation:


Body createPipe2(const DeviationParams& devDeviation, double dRadius1, double dRadius2, double dHeight)
{
  Body cyl1 = createCylinder(devDeviation, dRadius1, dHeight);
  Body cyl2 = createCylinder(devDeviation, dRadius2, dHeight);
   return Body::boolOper(eDifference, cyl1, cyl2);
}

To read more about Boolean operations see Perform Boolean Operations.

See Also

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