CSGOperationd 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 CSGOperationd class provides constructive solid geometry (CSG) operations for triangle meshes using double 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.
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" inside the shape volume in order for the CSGOperation class methods to correctly calculate CSG operation on the input shapes.
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 it 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 CSGOperationd csgOperation; // define CSGOperation object sphere.CreateSphere( 1.0f, 20 ); // create sphere torus.CreateTorus( 1.0f, 0.25f ); // create torus csgOperation.SetShapesPositionHint( CSGOperation::IntersectsOrOutside ); // gives hint to the CSG operation // object about sphere and torus relative-to-each-other position csgOperation.Create( sphere, torus ); // create/prepare the CSG operation between the sphere and the torus csgOperation.AMinusB( result ); // get the AMinusB result of the CSG operation into the result object
See Also
