1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxnurbs.h
13#ifndef _FBXSDK_SCENE_GEOMETRY_NURBS_H_
14#define _FBXSDK_SCENE_GEOMETRY_NURBS_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/geometry/fbxgeometry.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22/** A NURBS surface is a type of parametric geometry. A NURBS surface is defined by the
23 order, form, knot vector and control points in the U and V coordinates.
24
25 For more information on the meaning of form, knot vectors and control points,
26 see the FbxNurbsCurve documentation. The same rules apply for the NURBS curves
27 and NURBS surfaces, but NURBS surfaces have two dimensions (U and V).
28
29 * \nosubgrouping
30 */
31class FBXSDK_DLL FbxNurbs : public FbxGeometry
32{
33 FBXSDK_OBJECT_DECLARE(FbxNurbs, FbxGeometry);
34
35public:
36 //! Returns the FbxNodeAttribute::EType::eNurbs node attribute type.
37 virtual FbxNodeAttribute::EType GetAttributeType() const;
38
39 //! Resets the NURBS surface its default values.
40 void Reset();
41
42 /**
43 * \name NURBS surface properties
44 */
45 //@{
46
47 /** Sets the surface mode.
48 * \param pMode Surface mode identifier (see class FbxGeometry)
49 */
50 void SetSurfaceMode(FbxGeometry::ESurfaceMode pMode);
51
52 /** Returns the surface mode.
53 * \return The surface mode identifier that is currently set.
54 */
55 inline ESurfaceMode GetSurfaceMode() const {return mSurfaceMode;}
56
57 /** NURBS types.
58 */
59 enum EType
60 {
61 ePeriodic, //!< Periodic.
62 eClosed, //!< Closed.
63 eOpen //!< Open.
64 };
65
66 /** Allocates memory space for an array of control points as well as knot
67 * and multiplicity vectors.
68 * \param pUCount Number of U-dimension control points.
69 * \param pUType U-dimension NURBS type.
70 * \param pVCount Number of V-dimension control points.
71 * \param pVType V-dimension NURBS type.
72 * \remarks Always call this function after FbxNurbs::SetOrder().
73 */
74 void InitControlPoints(int pUCount, EType pUType, int pVCount, EType pVType);
75
76 /** Returns the number of U-dimension control points.
77 * \return Number of U-dimension control points.
78 */
79 inline int GetUCount() const {return mUCount;}
80
81 /** Returns the number of V-dimension control points.
82 * \return Number of V-dimension control points.
83 */
84 inline int GetVCount() const {return mVCount;}
85
86 /** Returns the U-dimension NURBS type.
87 * \return NURBS type identifier.
88 */
89 inline EType GetNurbsUType() const {return mUType;}
90
91 /** Returns the V-dimension NURBS type.
92 * \return NURBS type identifier.
93 */
94 inline EType GetNurbsVType() const {return mVType;}
95
96 /** Returns the number of elements in the U-dimension knot vector. See FbxNurbsCurve for more information.
97 * \return The number of elements in the U-dimension knot vector.
98 */
99 int GetUKnotCount() const;
100
101 /** Returns the U-dimension knot vector.
102 * \return Pointer to the U-dimension knot vector.
103 */
104 double* GetUKnotVector() const;
105
106 /** Returns the number of elements in the V-dimension knot vector. See FbxNurbsCurve for more information.
107 * \return The number of elements in the V-dimension knot vector.
108 */
109 int GetVKnotCount() const;
110
111 /** Returns the V-dimension knot vector.
112 * \return Pointer to the V-dimension knot vector.
113 */
114 double* GetVKnotVector() const;
115
116 /** Returns multiplicity of U-dimension control points.
117 * \return Pointer to the array of multiplicity values.
118 * \remarks The length of this vector is equal to the U count.
119 * Its elements are set to 1 by default.
120 */
121 int* GetUMultiplicityVector() const;
122
123 /** Returns multiplicity of V-dimension control points.
124 * \return Pointer to the array of multiplicity values.
125 * \remarks The length of this vector is equal to the V count.
126 * Its elements are set to 1 by default.
127 */
128 int* GetVMultiplicityVector() const;
129
130 /** Sets the order of the NURBS surface.
131 * \param pUOrder NURBS order in U dimension.
132 * \param pVOrder NURBS order in V dimension.
133 */
134 void SetOrder(FbxUInt pUOrder, FbxUInt pVOrder);
135
136 /** Returns the NURBS order in U dimension.
137 * \return NURBS order in U dimension.
138 */
139 inline int GetUOrder() const {return mUOrder;}
140
141 /** Returns the NURBS order in V dimension.
142 * \return NURBS order in V dimension.
143 */
144 inline int GetVOrder() const {return mVOrder;}
145
146 /** Sets the NURBS step.
147 * The step value is the number of divisions between adjacent control points.
148 * \param pUStep Steps in U dimension.
149 * \param pVStep Steps in V dimension.
150 */
151 void SetStep(int pUStep, int pVStep);
152
153 /** Returns the number of divisions between adjacent control points in U dimension.
154 * \return Steps in U dimension.
155 */
156 inline int GetUStep() const {return mUStep;}
157
158 /** Returns the number of divisions between adjacent control points in V dimension.
159 * \return Steps in V dimension.
160 */
161 inline int GetVStep() const {return mVStep;}
162
163 /** Calculates the number of surface spans in the U dimension.
164 * See FbxNurbsCurve::GetSpanCount() for more information.
165 * \return The number of spans in the U dimension if the surface has been initialized.
166 * If the spans have not been initialized, returns -1.
167 */
168 int GetUSpanCount() const;
169
170 /** Calculates the number of surface spans in the V dimension.
171 * See FbxNurbsCurve::GetSpanCount() for more information.
172 * \return The number of spans in the V dimension if the surface has been initialized.
173 * If the spans have not been initialized, returns -1.
174 */
175 int GetVSpanCount() const;
176
177 //@}
178
179 /**
180 * \name NURBS export flags
181 */
182 //@{
183
184 /** Sets the flag that induces UV flipping at export.
185 * \param pFlag If \c true, UV flipping occurs.
186 */
187 void SetApplyFlipUV(bool pFlag);
188
189 /** Returns the flag that induces UV flipping at export.
190 * \return The current state of the UV flip flag.
191 */
192 bool GetApplyFlipUV() const;
193
194 /** Sets the flag that induces link flipping at export.
195 * \param pFlag If \c true, the links control points indices are flipped.
196 */
197 void SetApplyFlipLinks(bool pFlag);
198
199 /** Returns the flag that induces link flipping at export.
200 * \return The current state of the link flip flag.
201 */
202 bool GetApplyFlipLinks() const;
203
204 /** Returns flip flags state.
205 * \return \c True if we need to flip either the UV or the links.
206 */
207 bool GetApplyFlip() const { return GetApplyFlipUV() || GetApplyFlipLinks(); }
208
209 //@}
210
211/*****************************************************************************************************************************
212** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
213*****************************************************************************************************************************/
214#ifndef DOXYGEN_SHOULD_SKIP_THIS
215 // Error identifiers, these are only used internally.
216 enum EErrorCode
217 {
218 eNurbsTypeUnknown,
219 eWrongNumberOfControlPoint,
220 eWeightTooSmall,
221 eUMultiplicityVectorError,
222 eVMultiplicityVectorError,
223 eUKnotVectorError,
224 eVKnotVectorError,
225 eErrorCount
226 };
227
228 virtual FbxObject& Copy(const FbxObject& pObject);
229 virtual void SetControlPointAt(const FbxVector4 &pCtrlPoint , int pIndex) { ParentClass::SetControlPointAt(pCtrlPoint, pIndex); }
230 virtual void InitControlPoints(int pCount) { ParentClass::InitControlPoints(pCount); }
231
232protected:
233 virtual void Construct(const FbxObject* pFrom);
234 virtual void Destruct(bool pRecursive);
235
236 FbxUInt mUOrder, mVOrder;
237 int mUCount, mVCount;
238 int mUStep, mVStep;
239 EType mUType, mVType;
240
241 double* mUKnotVector;
242 double* mVKnotVector;
243
244 int* mUMultiplicityVector;
245 int* mVMultiplicityVector;
246
247 ESurfaceMode mSurfaceMode;
248
249 // Export flags.
250 bool mApplyFlipUV;
251 bool mApplyFlipLinks;
252
253 friend class FbxGeometryConverter;
254#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
255};
256
257#include <fbxsdk/fbxsdk_nsend.h>
258
259#endif /* _FBXSDK_SCENE_GEOMETRY_NURBS_H_ */
260