Class SoCSGShape
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
public class SoCSGShape extends SoShape
Shape defined by a binary boolean operation on two sub scene graphs. This shape represents the result of a Constructive Solid Geometry (CSG) operation applied on the two scene graphsleftOperandandrightOperand. Constructive solid geometry allows the application to create a (potentially) complex object by using Boolean operators to combine (relatively) simple objects.The left and right operands can be any scene graph, including other
SoCSGShapenodes. You can define a complex CSG geometry by creating a tree using multipleSoCSGShapenodes. The specified scene graph's shapes must be closed (no holes) and CCW-orientated (all triangles composing shapes must be counter-clockwise).Each time an operand is modified, a CSG Operation is performed. Keep this in mind if you create a CSGTree (
SoCSGShapewhich contains other SoCSGShapes), especially if you use associative and commutative operations (only additions or only intersections) because the result of such operations does not depend on the tree ( (A + B) + C = A + (B + C) ). In this case, try to build your tree by putting the most often modified nodes at the top of the tree.For example, a tree optimized for modification on first node ( N1 ) will look like this:
S __|__S | __|__S N1 | __|__S N2 | __|__ N3 | | N4 N5 Where S are
SoCSGShapeand N1, N2, ... are ordinary nodes. In this case, a modification on N1 will need only 1 csgOperation, whereas a modificaion on N5 will need 4 csgOperations to regenerate the resulting shape.A tree optimized for random modification will try to minimize its depth:
S ________|_________ | | ____S____ ____S____ | | | | __S__ N3 N4 N5 | | N1 N2 In this case, any modification will require at most 3 CSG Operations.
- Since:
- Open Inventor 8.6
File format/default:
CSGShape {
leftOperand NULL rightOperand NULL csgOperation ADD NOTES - CSG means Constructive Solid Geometry.
- Some operations are not commutative (A - B) != (B - A).
LIMITATIONS Only vertices are handled in the generated shape. None of the normal, color, or texCoord properties of the left or right operands are taken into account. Shaders are also not taken in account, even vertex shaders. But note that you can use a shader above
SoCSGShape. The shader will be applied to the result of the CSG operation. - See Also:
SoShape
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSoCSGShape.CsgOperationTypesCSG operation to be used.static classSoCSGShape.CsgStatusStatus of CSG operation.-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoShape
SoShape.ShapeTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description SoSFEnum<SoCSGShape.CsgOperationTypes>csgOperationCSG boolean operation to apply.SoSFNodeleftOperandGeometry scene graph to be used as left operand for the Boolean operation.SoSFNoderightOperandGeometry scene graph to be used as right operand for the Boolean operation.-
Fields inherited from class com.openinventor.inventor.nodes.SoShape
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoCSGShape()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SoCSGShape.CsgStatusgetStatus()Returns status of csg operation.voidsetMaxAttempt(int maxAttempt)If the CSG Operation failed for any reason, it will be retried by applying a small random transformation to the operand vertices.static voidsetRescueOperation(SoCSGShape.CsgOperationTypes op)Set operation to use if the CSG operation fails or CSGLib is not available.-
Methods inherited from class com.openinventor.inventor.nodes.SoShape
getShapeType, isPrimitiveRestartAvailable, isPrimitiveRestartAvailable
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
leftOperand
public final SoSFNode leftOperand
Geometry scene graph to be used as left operand for the Boolean operation.
-
rightOperand
public final SoSFNode rightOperand
Geometry scene graph to be used as right operand for the Boolean operation.
-
csgOperation
public final SoSFEnum<SoCSGShape.CsgOperationTypes> csgOperation
CSG boolean operation to apply. . Default is ADD.
-
-
Method Detail
-
setMaxAttempt
public void setMaxAttempt(int maxAttempt)
If the CSG Operation failed for any reason, it will be retried by applying a small random transformation to the operand vertices. This can solve the problem if the geometries are well formed, but for example 2 faces are coplanar. This method sets the max number of timesSoCSGShapewill retry before giving up and using the rescueOperation (seesetRescueOperation). A max attempt of 5 is enough. If CSG Operation fails after 5 attempts, it will probably fail all the time.Default is 5.
Warning A value > 0 may change the coordinates of geometries as they will be transformed a little bit to apply the CSG operation. This transformation is normally not visible to the naked eye (it's about 0.01%), but may cause issues if you need precise values.
-
getStatus
public SoCSGShape.CsgStatus getStatus()
Returns status of csg operation.Note Status is updated only when the node is traversed. Initially returns CSG_NO_ERROR. .
-
setRescueOperation
public static void setRescueOperation(SoCSGShape.CsgOperationTypes op)
Set operation to use if the CSG operation fails or CSGLib is not available. Default is NOTHING. Must be one of LEFT_ONLY, RIGHT_ONLY, NOTHING or ALL. .
-
-