Group node for Constructive Solid Geometry rendering. More...
#include <SolidViz/nodes/SoCSGGroup.h>
Classes | |
struct | SoCSGProduct |
Public Member Functions | |
virtual SoType | getTypeId () const |
SoCSGGroup () | |
SoCSGGroup (int nChildren) | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Public Attributes | |
SoSFString | expression |
SoSFBool | isShapesBefore |
SoSFBool | isActive |
SoSFBool | boundingBoxPruningEnabled |
This group node performs a Constructive Solid Geometry (CSG) rendering. The children of this group define the solids that are involved in the CSG rendering. It is important to know that all children of this group are assumed to be solid (i.e., having a closed surface). Otherwise the results may be incorrect.
An expression defines the operations between these solids. Possible operations are: intersection (indicated as "." in the expression), union ("+"), and subtraction ("-"). A solid is identified by a letter (or a group of letters) in the expression and corresponds to the child number as follows: 'A' corresponds to child 0, 'B' corresponds to child 1, "AA" corresponds to child 26, "AZ" corresponds to child 51, and so forth. The expression is not case sensitive. If you decide for example to use "AA", you must have previously created children 0-25 (A through Z).
A letter can be followed by a number to indicate the convexity of the solid. The convexity of a solid is defined as the maximum numbers of pairs of front and back surfaces. For instance, the convexity of a cube is 1 whereas the convexity of a torus is 2. The convexity of a solid is assumed to be 1 if no digit follows the corresponding letter in the expression. The maximum allowable convexity value is 128.
The more complex the expression, the slower the performance. The same holds true for the convexity of an object - greater convexity implies slower performance.
For best performance, the graphics accelerator should perform stencil buffer operations in hardware.
Example of CSG Tree:
In this example, "myShape1" is 'A', "Separator1" is B, and "Separator2" is C. A CSG expression could be: "A . B - C + A" and corresponds to the following CSG tree:
The CSG tree defined by expression is assumed to be in normal form (normalized). A CSG tree is in normal form when all intersection and subtraction operators have a left subtree that contains no union operator and a right subtree that is simply a shape. For example, the tree shown above is in normal form.
A CSG tree can be converted to normal form by repeatedly applying the following set of production rules to the tree and then its subtrees:
A - ( B + C ) | => | ( A - B ) - C |
A . ( B + C ) | => | ( A . B ) + ( A . C ) |
A - ( B . C ) | => | ( A - B ) + ( A - C ) |
A . ( B . C ) | => | ( A . B ) . C |
A - ( B - C ) | => | ( A - B ) + ( A . C ) |
A . ( B - C ) | => | ( A . B ) - C |
( A - B ) . C | => | ( A . C ) - B |
( A + B ) - C | => | ( A - C ) + ( B - C ) |
( A + B ) . C | => | ( A . C ) + ( B . C ) |
If the CSG expression exceeds a certain length, a save/restore of the Z-Buffer is needed. This operation is time consuming. An environment variable, OIV_CSG_BUFFER_REGION [Win 32 only], allows the algorithm to use the OpenGL Buffer Region extension to speed up save/restore of Z-buffer task. Standard save and restore of the Z-buffer (glDrawPixels/glReadPixels) is used if this variable is not defined or the extension is not available.
Because there are two Buffer Region extensions, the value of this environment variable can be:
KTX_BUFFER_REGION: Uses the GL_KTX_buffer_region extension.
ARB_BUFFER_REGION: Uses the WGL_ARB_buffer_region extension.
expression | "" |
isShapesBefore | FALSE |
isActive | TRUE |
boundingBoxPruningEnabled | FALSE |
SoCSGGroup::SoCSGGroup | ( | ) |
Constructor.
SoCSGGroup::SoCSGGroup | ( | int | nChildren | ) |
Constructor.
static SoType SoCSGGroup::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoGroup.
virtual SoType SoCSGGroup::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoGroup.
Indicates if the CSG tree is pruned by the following rules:.
These rules can potentially speed up the rendering in case of a complex CSG expression by simplifying the CSG tree.
Expression which defines the CSG tree.
Indicates if CSG rendering should be done.
If this flag is set to FALSE, this group works as an SoGroup.
This flag indicates if there are any shapes before the CSGGroup in the scene graph.
For better performance, this group should not be preceded by any shapes, otherwise it is necessary to save a backup of the Z-Buffer (which is done when this flag is set to TRUE). If there are shapes preceding the group and the value is set to FALSE, the resulting image may be incorrect.