MNurbsIntersector Class Reference

#include <MNurbsIntersector.h>

Class Description

Nurbs intersector.

The MNurbsIntersector class contains methods for efficiently finding the closest point to a NURBS surface. A tree-based algorithm is used to find the closest point.

The create() method builds the internal data required for the algorithm. As a result, calls to it should be minimized as it is a heavy operation. If the NURBS surface or matrix changes, you will need to recreate the tree based data to correspond, again using the create() method.

This class is not threadsafe.

+ Examples:

Public Member Functions

 MNurbsIntersector (void)
 Constructor.
 
virtual ~MNurbsIntersector (void)
 Destructor.
 
MStatus create (MObject &nurbsObject, const MMatrix &matrix=MMatrix::identity)
 This method creates the data required by the intersector. More...
 
bool isCreated (void) const
 This method returns true if the intersector is created. More...
 
MStatus getClosestPoint (const MPoint &point, MPointOnNurbs &nurbsPoint, double maxDistance=DBL_MAX) const
 This method finds the closest point. More...
 
MStatus getIntersects (const MPoint &rayStartingPoint, const MVector &alongThisDirection, MDoubleArray &uArray, MDoubleArray &vArray, MPointArray &points, double tolerance) const
 This method finds all the points of intersection of the NURBS surface with a ray (a vector at a point). More...
 
MStatus getIntersect (const MPoint &rayStartingPoint, const MVector &alongThisDirection, double &u, double &v, MPoint &pntOfIntersection, double tolerance) const
 This method finds the first point of intersection of the NURBS surface with a ray (a vector at a point). More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Member Function Documentation

MStatus create ( MObject nurbsObject,
const MMatrix matrix = MMatrix::identity 
)

This method creates the data required by the intersector.

It is a heavy operation that should be called only when necessary, such as when the underlying NURBS surface or the matrix changes.

Parameters
[in]nurbsObjecta NURBS surface object .
[in]matrixspecify the mapping to apply for transforming points that are specified in the getClosestPoint method into the object space of the NURBS surface.
Returns
Status code
Status Codes:
  • MS::kSuccess The NURBS intersector was created .
  • MS::kInvalidParameter Object is not a kNurbsSurface, a kNurbsSurfaceData or a kNurbsSurfaceGeom.
  • MS::kFailure Other internal failure .
+ Examples:
bool isCreated ( void  ) const

This method returns true if the intersector is created.

False is returned otherwise.

MStatus getClosestPoint ( const MPoint point,
MPointOnNurbs &  nurbsPoint,
double  maxDistance = DBL_MAX 
) const

This method finds the closest point.

Information is returned in the nurbsPoint object.

Parameters
[in]pointSpecifies the location for which to evaluate the closest point on the NURBS surface. `point' is transformed using the matrix parameter passed to the create() method, so for example if your matrix maps world to object space, then `point' should be specified in world space.
[out]nurbsPointResulting closest point in object space.
[in]maxDistanceMaximum distance to consider in object space.
Returns
Status code
Status Codes:
  • MS::kSuccess The NURBS point was found.
  • MS::kFailure object error, or create hasn't been called beforehand.
+ Examples:
MStatus getIntersects ( const MPoint rayStartingPoint,
const MVector alongThisDirection,
MDoubleArray uArray,
MDoubleArray vArray,
MPointArray points,
double  tolerance 
) const

This method finds all the points of intersection of the NURBS surface with a ray (a vector at a point).

The points are returned in the points object, and the U and V parameters of the points are returned in the uArray and vArray objects respectively.

Parameters
[in]rayStartingPointStarting location of ray to test
[in]alongThisDirectionDirection of ray to test
[in]uArrayU parameters of intersection (if any)
[in]vArrayV parameters of intersection (if any)
[out]pointsStorage for points of intersection (if any)
[in]toleranceThe epsilon value in the calculation
Returns
Status code
Status Codes:
  • MS::kSuccess An intersection point has been found
  • MS::kFailure No intersection points found
MStatus getIntersect ( const MPoint rayStartingPoint,
const MVector alongThisDirection,
double &  u,
double &  v,
MPoint pntOfIntersection,
double  tolerance 
) const

This method finds the first point of intersection of the NURBS surface with a ray (a vector at a point).

The point is returned in the pntOfIntersection object, and the U and V parameters of the point are returned in the u and v variables respectively.

Parameters
[in]rayStartingPointStarting location of ray to test
[in]alongThisDirectionDirection of ray to test
[in]uU parameter of intersection (if any)
[in]vV parameter of intersection (if any)
[out]pntOfIntersectionStorage for closest point of intersection (if any)
[in]toleranceThe epsilon value in the calculation
Returns
Status code
Status Codes:
  • MS::kSuccess An intersection point has been found
  • MS::kFailure No intersection points found
+ Examples:
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

The documentation for this class was generated from the following files:
  • MNurbsIntersector.h
  • MNurbsIntersector.cpp