CSGOperation class
From Solid Graphics Wiki
This class is part of the SolidKit Library Pro package only! It's demo version is available in the SolidKit Library Demo package. 

The CSGOperation class provides constructive solid geometry (CSG) operations for triangle meshes using float precision.
Please read the Support of Constructive Solid Geometry in the SolidKit Library article to learn about limitations of the SolidKit Library regarding the constructive solid geometry.
For example of using the CSGOperation class please see the Console_Template_Pro project source code. The Console_Template_Pro project is part of the SolidKit Library sample projects.
Each triangle of the mesh must have it's vertexes oriented in counterclockwise order when looked at the triangle from outside of the mesh shape's volume. The shape's volume must be completely enclosed by the mesh triangles, there cannot be "holes" on the shape's surface in order for the CSGOperation class methods to correctly calculate CSG operation on the input shapes. All input shapes for CSG operations must be non self intersecting and must use righthand coordinate system (or must be converted from lefthand to righthand coordinate system before a CSG Operation is performed).
Fields
The class does not have any public fields.
Methods
Method name  Description 
SetShapesPositionHint  Hints to the CSGOperation object position of the input shape objects. This can speed up the processing time if the position of the objects relative to each other is already known. 
Create  Creates/prepares CSG operation between two Shape class objects. Once CSG operation is created  it's result can be retrieved by it's AMinusB, BMinusA, Union, Intersection or GetResult methods. 
Union  Retrieves result shape of the CSG operation which is union of the two input shapes. 
Intersection  Retrieves result shape of CSG operation which is intersection of the two input shapes. 
AMinusB  Retrieves result shape of CSG operation which is subtraction of second input shape object from the first shape object. 
BMinusA  Retrieves result shape of CSG operation which is subtraction of first input shape object from the second shape object. 
GetResult  Retrieves specified groups of triangles of the CSG operation result. 
Operators
The class does not have any public operators.
Example
Following is example of the difference (AMinusB) CSG operation between a sphere and a torus.
The variation of the code below which also renders the result image to a file is available in the Console_Tamplate_Pro SolidKit Library example project.
using SKL3D; Shape sphere, torus, result; // Define shapes to be used. CSGOperation csgOperation; // Define CSGOperation object. sphere.CreateSphere( 1.0f, 20 ); // Create sphere torus.CreateTorus( 1.0f, 0.25f ); // Create torus csgOperation.SetShapesPositionHint( CSGOperation::IntersectsOrOutside ); // Optional instruction which gives hint to // the CSG operation about sphere and torus relativetoeachother position csgOperation.Create( sphere, torus ); // Create/prepare the CSG operation between the sphere and the torus // specifying the sphere as the "shape A" and the torus as the "shape B" csgOperation.AMinusB( result ); // Get the "sphere  torus" result of the CSG operation into the result object
See Also