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