MNurbsIntersector Class Reference
[OpenMaya - API module for common classes]

#include <MNurbsIntersector.h>

Collaboration diagram for MNurbsIntersector:

Collaboration graph
[legend]

List of all members.


Detailed 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:

closestPointOnNurbsSurfaceCmd.cpp, and intersectOnNurbsSurfaceCmd.cpp.


Public Member Functions

 MNurbsIntersector (void)
virtual ~MNurbsIntersector (void)
MStatus create (MObject &nurbsObject, const MMatrix &matrix=MMatrix::identity)
bool isCreated (void)
MStatus getClosestPoint (MPoint &point, MPointOnNurbs &nurbsPoint, double maxDistance=DBL_MAX)
MStatus getIntersects (const MPoint &rayStartingPoint, const MVector &alongThisDirection, MDoubleArray &uArray, MDoubleArray &vArray, MPointArray &points, double tolerance)
MStatus getIntersect (const MPoint &rayStartingPoint, const MVector &alongThisDirection, double &u, double &v, MPoint &pntOfIntersection, double tolerance)

Constructor & Destructor Documentation

MNurbsIntersector::MNurbsIntersector ( void   ) 

Constructor

MNurbsIntersector::~MNurbsIntersector ( void   )  [virtual]

Destructor.


Member Function Documentation

MStatus MNurbsIntersector::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] nurbsObject a NURBS surface object .
[in] matrix specify 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:
Examples:

bool MNurbsIntersector::isCreated ( void   ) 

This method returns true if the intersector is created. False is returned otherwise.

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

This method finds the closest point. Information is returned in the nurbsPoint object.

Parameters:
[in] point Specifies 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] nurbsPoint Resulting closest point in object space.
[in] maxDistance Maximum distance to consider in object space.
Returns:
Status code
Status Codes:
Examples:

MStatus MNurbsIntersector::getIntersects ( const MPoint rayStartingPoint,
const MVector alongThisDirection,
MDoubleArray uArray,
MDoubleArray vArray,
MPointArray points,
double  tolerance 
)

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] rayStartingPoint Starting location of ray to test
[in] alongThisDirection Direction of ray to test
[in] uArray U parameters of intersection (if any)
[in] vArray V parameters of intersection (if any)
[out] points Storage for points of intersection (if any)
[in] tolerance The epsilon value in the calculation
Returns:
Status code
Status Codes:

MStatus MNurbsIntersector::getIntersect ( const MPoint rayStartingPoint,
const MVector alongThisDirection,
double &  u,
double &  v,
MPoint pntOfIntersection,
double  tolerance 
)

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] rayStartingPoint Starting location of ray to test
[in] alongThisDirection Direction of ray to test
[in] u U parameter of intersection (if any)
[in] v V parameter of intersection (if any)
[out] pntOfIntersection Storage for closest point of intersection (if any)
[in] tolerance The epsilon value in the calculation
Returns:
Status code
Status Codes:
Examples:


Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6