
#ifndef _MFnNurbsCurve
#define _MFnNurbsCurve
//
//-
// ==========================================================================
// Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors.  All 
// rights reserved.
// 
// The coded instructions, statements, computer programs, and/or related 
// material (collectively the "Data") in these files contain unpublished 
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its 
// licensors,  which is protected by U.S. and Canadian federal copyright law 
// and by international treaties.
// 
// The Data may not be disclosed or distributed to third parties or be 
// copied or duplicated, in whole or in part, without the prior written 
// consent of Autodesk.
// 
// The copyright notices in the Software and this entire statement, 
// including the above license grant, this restriction and the following 
// disclaimer, must be included in all copies of the Software, in whole 
// or in part, and all derivative works of the Software, unless such copies 
// or derivative works are solely in the form of machine-executable object 
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. 
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED 
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF 
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, 
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO 
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST 
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR 
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS 
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. 
// ==========================================================================
//+
//
// CLASS:    MFnNurbsCurve
//
// *****************************************************************************
//
// CLASS DESCRIPTION (MFnNurbsCurve)
//
// Function set for NURBS curves.
//
// *****************************************************************************

#if defined __cplusplus

// *****************************************************************************

// INCLUDED HEADER FILES


#include <maya/MFnDagNode.h>
#include <maya/MObject.h>

// *****************************************************************************

// DECLARATIONS

class MPointArray;
class MDoubleArray;
class MVector;
class MPoint;
class MDagPath;
class MPtrBase;
class TnurbsCurve;

#define kMFnNurbsEpsilon  1.0e-3

// *****************************************************************************

// CLASS DECLARATION (MFnNurbsCurve)

/// NURBS curve function set
/**
  Manipulate NURBS curve objects
*/
#ifdef _WIN32
#pragma warning(disable: 4522)
#endif // _WIN32

class OPENMAYA_EXPORT MFnNurbsCurve : public MFnDagNode 
{

	declareDagMFn(MFnNurbsCurve, MFnDagNode);

public: 
    ///
	enum Form {
        ///
		kInvalid=0,
        ///
		kOpen,
        ///
		kClosed, 
        ///
		kPeriodic,
        ///
		kLast
	};
    ///
	MObject  	create(	const MPointArray &controlVertices,
						const MDoubleArray &knotSequences,
						unsigned int degree,
						Form agForm,
						bool create2D,
						bool createRational,
						MObject & parentOrOwner = MObject::kNullObj,
						MStatus* ReturnStatus = NULL );
	///
	MObject		create( const MObjectArray& sources,
						MObject & parentOrOwner = MObject::kNullObj,
						MStatus* ReturnStatus = NULL );
	///
	MObject     copy (const MObject &source,
					  MObject &parentOrOwner = MObject::kNullObj,
					  MStatus* ReturnStatus = NULL);
	///
	MStatus		reverse(bool constructionHistory = false);

	///
	MStatus		makeMultipleEndKnots();

    ///
	MObject  	cv( unsigned int index, MStatus * ReturnStatus = NULL ) const;
    ///
	MStatus		getCV( unsigned int index, MPoint &pt,
						MSpace::Space space = MSpace::kObject ) const;
    ///
	MStatus		setCV( unsigned int index, const MPoint &pt,
						MSpace::Space space = MSpace::kObject );
    ///
	Form		form( MStatus * ReturnStatus = NULL ) const;
    ///
	int			degree( MStatus * ReturnStatus = NULL ) const;
    ///
	int			numCVs( MStatus * ReturnStatus = NULL ) const;
    ///
	int			numSpans( MStatus * ReturnStatus = NULL ) const;
    ///
	int			numKnots( MStatus * ReturnStatus = NULL ) const;
	///
	MStatus		getKnotDomain( double &start, double &end ) const;
    ///
	MStatus		getKnots( MDoubleArray &array ) const;
    ///
    MStatus     setKnots( const MDoubleArray &array, unsigned int startIndex,
                          unsigned int endIndex );
    ///
	MStatus		setKnot( unsigned int index, double param );
    ///
	MObject  	cvs( unsigned int startIndex, unsigned int endIndex,
						MStatus * ReturnStatus = NULL ) const;
	///
	MStatus		getCVs( MPointArray &array,
						MSpace::Space space = MSpace::kObject ) const;
    ///
	MStatus		setCVs( const MPointArray &array,
						MSpace::Space space = MSpace::kObject );
    ///
	double		knot( unsigned int index, MStatus * ReturnStatus = NULL ) const;
    ///
	MStatus		removeKnot( double atThisParam, bool removeAll = false );
    ///
	bool		isPointOnCurve( const MPoint &point,
								double tolerance = kMFnNurbsEpsilon,
								MSpace::Space space = MSpace::kObject,
								MStatus * ReturnStatus = NULL ) const;
    ///
	MStatus		getPointAtParam( double param, MPoint &point,
								MSpace::Space space = MSpace::kObject
								) const;
    ///
	MStatus		getParamAtPoint( const MPoint & atThisPoint, double &param,
								 MSpace::Space space = MSpace::kObject )
								 const;
    ///
	MStatus		getParamAtPoint( const MPoint & atThisPoint, double &param,
								 double tolerance = kMFnNurbsEpsilon,
								 MSpace::Space space = MSpace::kObject )
								 const;
    ///
	bool		isParamOnCurve( double param,
								MStatus * ReturnStatus = NULL ) const;
    ///
	MVector		normal( double param,
						MSpace::Space space = MSpace::kObject,
						MStatus * ReturnStatus = NULL ) const;
    ///
	MVector		tangent( double param,
						 MSpace::Space space = MSpace::kObject,
						 MStatus * ReturnStatus = NULL ) const;
    ///
    MStatus		getDerivativesAtParm( double param, MPoint &pos, 
									  MVector &dU, MSpace::Space space,
									  MVector * dUU = NULL) const; 
    ///
	bool		isPlanar( MVector * planeNormal = NULL,
							MStatus * ReturnStatus = NULL ) const;
    ///
	MPoint		closestPoint( const MPoint &toThisPoint, 
								double * param = NULL,
								double tolerance = kMFnNurbsEpsilon,
								MSpace::Space space = MSpace::kObject,
								MStatus * ReturnStatus = NULL ) const;
    ///
	MPoint		closestPoint( const MPoint &toThisPoint, 
							    bool paramAsStart = true,
								double * param = NULL,
								double tolerance = kMFnNurbsEpsilon,
								MSpace::Space space = MSpace::kObject,
								MStatus * ReturnStatus = NULL ) const;
    ///
	double		distanceToPoint( const MPoint &pt,
								MSpace::Space space = MSpace::kObject,
								MStatus * ReturnStatus = NULL ) const;
    ///
	double		area( double tolerance = kMFnNurbsEpsilon,
							MStatus * ReturnStatus = NULL ) const;
    ///
	double		length( double tolerance = kMFnNurbsEpsilon,
							MStatus * ReturnStatus = NULL ) const;
    ///
	double		findParamFromLength( double partLength,
							MStatus * ReturnStatus = NULL ) const;
    ///
	bool        hasHistoryOnCreate( MStatus * ReturnStatus = NULL );
    ///
	MStatus     updateCurve();
protected:  
	MObject		createMObject(MObject & parentOrOwner,
    						  TnurbsCurve * newCurve,
    						  MStatus * ReturnStatus);

	virtual bool objectChanged( MFn::Type, MStatus * );
private:
	inline void * updateGeomPtr() const;
	inline void * updateConstGeomPtr() const;

};

#ifdef _WIN32
#pragma warning(default: 4522)
#endif // _WIN32

// *****************************************************************************
#endif /* __cplusplus */
#endif /* _MFnNurbsCurve */
