[PREVIEW] [Medical] Class for computing the intersection of geometry with a plane. More...
#include <Medical/nodes/PlaneGeometryIntersection.h>
Public Member Functions | |
virtual SoType | getTypeId () const |
const SoShape * | getShape () const |
int | recompute () |
PlaneGeometryIntersection () | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
static void | initClass () |
static void | exitClass () |
Public Attributes | |
SoSFNode | scene |
SoSFPlane | plane |
SoSFBool | polygon |
SoSFBool | automatic |
SoSFFloat | tolerance |
This class computes and (optionally) renders the intersection of the geometry in the specified scene graph with the specified plane. In curve mode it computes a set of line segments corresponding to the intersection. In polygon mode it computes a set of polygon boundaries that can be used as a "cap" for clipped geometry. The intent is that the specified scene graph is one shape. In fact it can be any scene graph, but the result is always a single polygon with multiple boundaries (if necessary). The computed vertices (and indices in polygon mode) can be accessed using the getShape() method. The curve or polygon may be exported to a file like any other Open Inventor geometry using SoWriteAction, SoSTLWriteAction, etc.
Curve mode:
By default we compute and render the curve(s) defined by the intersection of the scene geometry and the plane. This is fast and works reliably for any Open Inventor geometry that produces triangles when an SoCallbackAction is applied (almost all Open Inventor geometry nodes). The appearance of the intersection curve can be controlled like any Open Inventor geometry using SoMaterial, SoDrawStyle, etc. nodes. The application may need to use an SoPolygonOffset node to "push" the scene geometry behind the intersection curve (polygon offset does not affect the intersection curve because it is a line set). Curve mode is useful to see where a clip plane intersects the geometry. Because it is much faster than polygon mode it is useful as a preview of where the polygons will be generated (if possible).
Polygon mode:
When the polygon field is set to true, the node converts the intersection curves to polygon boundaries. All the boundaries are stored in an SoIndexedFaceSet node and an SoShapeHints node is created with the 'windingType' field set to ODD_TYPE. All boundaries have counterclockwise vertex ordering and the face normal vector is the opposite of the current plane normal vector (because for a clip plane the plane normal points toward the unclipped half space which is effectively toward the interior of the shape). The appearance of the polygon can be controlled like any Open Inventor geometry using SoMaterial, etc. nodes. There are cases where polygons cannot be constructed, for example if the geometry is self-intersecting.
The coordinates of the intersection boundaries can be accessed using the getShape() method. This is an SoLineSet in curve mode and an SoIndexedFaceSet in polygon mode. In either case the coordinates are in the shape's attached SoVertexProperty node. Note that in curve mode the line segments are in random order and do not form a connected polyline. This allows the intersection geometry to be computed in minimum time and does not (visually) effect rendering. If you need the boundary(s) as a connected polyline for some purpose, use the polygon mode. Note that in polygon mode there are redundant vertices in the vertex list because it still contains all the line segments. To follow the boundaries in connection order use the coordinate indices in the SoIndexedFaceSet node.
Notes:
Limitations:
scene | NONE |
plane | 1 0 0 0 |
polygon | FALSE |
automatic | TRUE |
tolerance | 1e-6 |
InventorMedical, SoClipPlane, SoClipPlaneManip, SoSTLWriteAction
PlaneGeometryIntersection::PlaneGeometryIntersection | ( | ) |
Constructor.
static void PlaneGeometryIntersection::exitClass | ( | ) | [static] |
Finish using class (called automatically by InventorMedical::finish()).
Reimplemented from SoSeparator.
static SoType PlaneGeometryIntersection::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoSeparator.
const SoShape* PlaneGeometryIntersection::getShape | ( | ) | const |
Get the shape node that contains the computed vertices and indices.
Returns null if no shape has been computed yet. In curve mode this is an SoLineSet. In polygon mode this is an SoIndexedFaceSet. In both cases the vertices are in the shape node's attached SoVertexProperty node's 'vertex' field.
The application must not modify these nodes.
virtual SoType PlaneGeometryIntersection::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoSeparator.
static void PlaneGeometryIntersection::initClass | ( | ) | [static] |
Initialize class (called automatically by InventorMedical::init()).
Reimplemented from SoSeparator.
int PlaneGeometryIntersection::recompute | ( | ) |
Recompute the intersection.
Recomputes the intersection boundary(s) based on the current scene and plane. Normally used when the automatic field is set to false. Useful when the goal is simply to compute the intersection. Also useful if recomputation is too slow. For example, to defer recomputation until the user has finished moving the clip plane.
Returns 0 if successful. Any other value means that an error occured during the computation and the geometry may not be valid.
Specifies whether to recompute the intersection automatically or not (default true).
If true, the intersection (curve or polygon depending on the polygon field) will be re-computed automatically when the scene or the plane changes. If false, the intersection will only be re-computed when the recompute method is called.
Plane to intersect with.
Default is (1,0,0) at 0 (same as SoClipPlane). Typically this field is connected from the clipping node's 'plane' field.
Specifies whether to compute a capping polygon (default false).
If true, compute a capping polygon. If false, compute only the intersection curve.
Scene to intersect with plane.
Default is none.
Tolerance for testing if vertices are equal.
Default is 1e-6. This tolerance is used for calculation of triangle intersections with the plane.