Close

Relief for ODA Team in Ukraine

Learn more
ODA Facet Modeler
Perform Boolean Operations

This chapter provides information on how to perform Boolean operations on bodies and 2D profiles.

Facet Modeler enables you to perform various Boolean operations on bodies and its components.

Perform Boolean Operations on Bodies

To perform a Boolean operation on 3D objects, use the following boolOper() method:

static Body boolOper(BooleanOperation eOperation, Body& rOperandA, Body& rOperandB, bool bOptimization = false);

Please note that this function destroys both operands.

Facet Modeler allows you to perform three Boolean operations: union, intersection and difference. For a better view of the resulting bodies, tags are used. It’s important to note that Boolean operations take tags into account when forming the resulting body. Tag information remains on those resulting edges that were produced from one operand’s original edges that didn’t coincide with other operand’s edges. There is no tag information on the resulting edge that was produced from coinciding edges, as in this case its value is undefined.
There are two operands: a blue box and a red one. A smaller box touches the bigger box, within which it is located, with three faces, as the boxes have one common vertex. The bOptimization flag enables using 3d boxes in order to decrease the number of face slicing operations and improves the performance.

Each edge of the red box is tagged with one tag value (“tag A”) and each edge of the blue box is tagged with another tag value (“tag B”). Now that the tag information is placed on each edge, it is possible to find out what tag information appears on the resulting edges after each Boolean operation. Here is the color legend for the images below:

  • Red — Edge has a "tag A" on it.
  • Blue — Edge has a "tag B" on it.
  • Black — Edge has an empty tag on it.

In the pictures below you can see the results of Boolean operations:

As you can see, after the union operation three edges have become black. They have empty tags on them because in these positions the edges of red and blue boxes were coinciding, and this is the case when it can’t be defined whether to put a “tag A” or a “tag B” on them.

After the intersection operation there are three resulting edges with an empty tag because the original edges were coinciding at some point.

After the difference operation there are no black edges as the edges that coincided were removed due to the operation’s definition.

Perform Boolean Operations on Profiles

To perform a Boolean operation on 2D profiles, use the PerformOperation() method:

static bool PerformOperation(BooleanOperation eOperation, const Profile2D& rArg1, const Profile2D& rArg2, Profile2D& rResult, const OdGeTol& tol = FMGeGbl::gTol);

Below is a code snippet that creates a ring profile with a major radius dRadius1 and minor radius dRadius2:


Profile2D createRing(double dMinorRadius, double dMajorRadius)
{
  Profile2D result;
   Profile2D minorCircle = Profile2D(Contour2D::createCircle(OdGePoint2d::kOrigin, dMinorRadius));
  Profile2D majorCircle = Profile2D(Contour2D::createCircle(OdGePoint2d::kOrigin, dMajorRadius));
   Profile2D::PerformOperation(FacetModeler::BooleanOperation::eDifference, majorCircle, minorCircle, result);
   return result;
}

In the left picture below the darker circle has a radius dRadius1 and the lighter circle has a radius dRadius2. The right part of the picture shows the result of the difference operation; coinciding parts were eliminated.

See Also

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