SoCSGShape Class Reference
[Shapes]

VSG extension Shape defined by a binary boolean operation on two sub scene graphs. More...

#include <Inventor/nodes/SoCSGShape.h>

Inheritance diagram for SoCSGShape:
SoShape SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Types

enum  CsgOperationType {
  ADD,
  SUB,
  INTERSECTION,
  LEFT_ONLY,
  RIGHT_ONLY,
  NOTHING,
  ALL
}
enum  CsgStatus {
  CSG_NO_ERROR,
  CSG_LIB_NOT_AVAILABLE,
  CSG_ERROR
}

Public Member Functions

virtual SoType getTypeId () const
 SoCSGShape ()
void setMaxAttempt (int maxAttempt)
CsgStatus getStatus ()

Static Public Member Functions

static SoType getClassTypeId ()
static void setRescueOperation (CsgOperationType op)

Public Attributes

SoSFNode leftOperand
SoSFNode rightOperand
SoSFEnum csgOperation

Detailed Description

VSG extension 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 graphs leftOperand and rightOperand. 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 SoCSGShape nodes. You can define a complex CSG geometry by creating a tree using multiple SoCSGShape nodes. 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 (SoCSGShape which 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 SoCSGShape and 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.

NOTE: node available since Open Inventor 8.6

FILE FORMAT/DEFAULT

NOTES

SEE ALSO

SoShape

See related examples:

MedicalFreeHandCutting, CSGClippingGroup


Member Enumeration Documentation

CSG operation to be used.

Enumerator:
ADD 

leftOperand union rightOperand.

Remove useless faces and create edges if necessary.

SUB 

LeftOperand - rightOperand.

Remove useless faces and create edges if necessary.

INTERSECTION 

LeftOperand intersect rightOperand.

Remove useless faces and create edges if necessary.

LEFT_ONLY 

Keep only leftOperand.

RIGHT_ONLY 

Keep only rightOperand.

NOTHING 

Keep nothing (result will be empty).

May be useful for debugging.

ALL 

Keep left and right primitives (concatenate all resulting faces).

May be useful for debugging.

Status of CSG operation.

Status can be queried using the getStatus() method.

Enumerator:
CSG_NO_ERROR 

No error.

CSG_LIB_NOT_AVAILABLE 

CSGLib is not available.

CSG_ERROR 

an error occurred


Constructor & Destructor Documentation

SoCSGShape::SoCSGShape (  ) 

Constructor.


Member Function Documentation

static SoType SoCSGShape::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoShape.

CsgStatus SoCSGShape::getStatus (  ) 

Returns status of csg operation.

Note:
Status is updated only when the node is traversed. Initially returns CSG_NO_ERROR. Use enum CsgStatus.
virtual SoType SoCSGShape::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoShape.

void SoCSGShape::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 times SoCSGShape will retry before giving up and using the rescueOperation (see setRescueOperation). 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.
static void SoCSGShape::setRescueOperation ( CsgOperationType  op  )  [static]

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. Use enum CsgOperationType.


Member Data Documentation

CSG boolean operation to apply.

Use enum CsgOperationType. Default is ADD.

Geometry scene graph to be used as left operand for the Boolean operation.

Geometry scene graph to be used as right operand for the Boolean operation.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/