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 fbxtrimnurbssurface.h
13#ifndef _FBXSDK_SCENE_GEOMETRY_TRIM_NURBS_SURFACE_H_
14#define _FBXSDK_SCENE_GEOMETRY_TRIM_NURBS_SURFACE_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/geometry/fbxgeometry.h>
19#include <fbxsdk/scene/geometry/fbxnurbscurve.h>
20#include <fbxsdk/scene/geometry/fbxnurbssurface.h>
21
22#include <fbxsdk/fbxsdk_nsbegin.h>
23
24/** FbxBoundary describes a trimming boundary for a trimmed NURBS object.
25 * Note:Outer boundaries run counter-clockwise in UV space and inner
26 * boundaries run clockwise. An outer boundary represents the outer edges
27 * of the trimmed surface whereas the inner boundaries define "holes" in
28 * the surface.
29 */
30class FBXSDK_DLL FbxBoundary : public FbxGeometry
31{
32 FBXSDK_OBJECT_DECLARE(FbxBoundary, FbxGeometry);
33
34public:
35
36 //! Properties
37 static const char* sOuterFlag;
38
39 /** This property handles outer flag.
40 *
41 * Default value is false.
42 */
43 FbxPropertyT<FbxBool> OuterFlag;
44
45 /** Adds an edge to this boundary.
46 * \param pCurve The curve to be appended to the end of this boundary
47 */
48 void AddCurve( FbxNurbsCurve* pCurve );
49
50 /** Returns the number of edges within this boundary.
51 * \return The number of edges within this boundary
52 */
53 int GetCurveCount() const;
54
55 /** Returns the edge at the specified index.
56 * \param pIndex The specified index, no bound checking is done.
57 * \return The edge at the specified index if
58 * pIndex is in the range [0, GetEdgeCount() ),
59 * otherwise the return value is undefined.
60 */
61 FbxNurbsCurve* GetCurve( int pIndex );
62
63 /** Returns the edge at the specified index.
64 * \param pIndex The specified index, no bound checking is done.
65 * \return The edge at the specified index if
66 * pIndex is in the range [0, GetEdgeCount() ),
67 * otherwise, the return value is undefined.
68 */
69 const FbxNurbsCurve* GetCurve( int pIndex ) const;
70
71
72 //! Returns the type of node attribute.
73 virtual FbxNodeAttribute::EType GetAttributeType() const;
74
75 /** Detects if the point is in the boundary's control hull.
76 * \param pPoint The point to be detected.
77 * \return \c True if the point is in the boundary's control hull, returns \c false if it is not in the control hull.
78 */
79 bool IsPointInControlHull(const FbxVector4& pPoint );
80
81 /** Computes the origin point in the boundary
82 * \return The origin point.
83 */
84 FbxVector4 ComputePointInBoundary();
85
86/*****************************************************************************************************************************
87** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
88*****************************************************************************************************************************/
89#ifndef DOXYGEN_SHOULD_SKIP_THIS
90 virtual FbxObject& Copy(const FbxObject& pObject);
91
92 void ClearCurves();
93 void CopyCurves( FbxBoundary const& pOther );
94 bool IsValid(bool mustClosed = true);
95 bool IsCounterClockwise();
96
97protected:
98 virtual void ConstructProperties(bool pForceSet);
99
100 void Reset();
101 bool LineSegmentIntersect(const FbxVector4 & pStart1, const FbxVector4 & pEnd1, const FbxVector4 & pStart2, const FbxVector4 & pEnd2 ) const;
102#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
103};
104
105
106/** FbxTrimNurbsSurface describes a NURBS surface with regions
107 trimmed or cut away with trimming boundaries.
108 */
109class FBXSDK_DLL FbxTrimNurbsSurface : public FbxGeometry
110{
111 FBXSDK_OBJECT_DECLARE(FbxTrimNurbsSurface,FbxGeometry);
112public:
113 //! Returns the type of node attribute.
114 virtual FbxNodeAttribute::EType GetAttributeType() const;
115
116
117 /** Returns the number of regions on this trimmed NURBS surface.
118 * Note: There is always at least one region.
119 * \return The number of regions
120 */
121 int GetTrimRegionCount() const;
122
123 /** Calls this function before adding boundaries to a new trim region.
124 * The number of regions is incremented on this call.
125 */
126 void BeginTrimRegion();
127
128 /** Calls this function after the last boundary for a given region is added.
129 * If no boundaries are added between the calls to BeginTrimRegion
130 * and EndTrimRegion, the last region is removed.
131 */
132 void EndTrimRegion();
133
134 /** Appends a trimming boundary to the set of trimming boundaries.
135 * The first boundary specified for a given trim region should be
136 * the outer boundary. All other boundaries are inner boundaries.
137 * This must be called after a call to BeginTrimRegion(). Boundaries
138 * cannot be shared among regions. Duplicate the boundary if necessary.
139 * \param pBoundary The boundary to add.
140 * \return \c True if the boundary is added successfully.
141 * If the boundary is not added successfully, returns \c false.
142 */
143 bool AddBoundary( FbxBoundary* pBoundary );
144
145 /** Returns the boundary at a given index for the specified region
146 * \param pIndex The index of the boundary to retrieve, no bound checking is done.
147 * \param pRegionIndex The index of the region which is bordered by the boundary.
148 * \return The trimming boundary at index pIndex,
149 * if pIndex is in the range [0, GetBoundaryCount() ),
150 * otherwise the result is undefined.
151 */
152 FbxBoundary* GetBoundary( int pIndex, int pRegionIndex = 0 );
153
154 /** Returns the boundary at a given index for the specified region
155 * \param pIndex The index of the boundary to retrieve, no bound checking is done.
156 * \param pRegionIndex The index of the region which is bordered by the boundary.
157 * \return The trimming boundary at index pIndex,
158 * if pIndex is in the range [0, GetBoundaryCount() ),
159 * otherwise the result is undefined.
160 */
161 const FbxBoundary* GetBoundary( int pIndex, int pRegionIndex = 0 ) const;
162
163 /** Returns the number of boundaries for a given region.
164 * \param pRegionIndex The index of the region.
165 * \return The number of trim boundaries for the given region.
166 */
167 int GetBoundaryCount(int pRegionIndex = 0) const;
168
169 /** Sets the NURBS surface that is trimmed by the trimming boundaries.
170 * \param pNurbs The NURBS surface to be trimmed.
171 */
172 void SetNurbsSurface( const FbxNurbsSurface* pNurbs );
173
174 /** Returns the NURBS surface that is trimmed by the trim boundaries.
175 * \return A pointer to the (untrimmed) NURBS surface.
176 */
177 FbxNurbsSurface* GetNurbsSurface();
178
179 /** Returns the NURBS surface that is trimmed by the trim boundaries.
180 * \return A pointer to the (untrimmed) NURBS surface.
181 */
182 const FbxNurbsSurface* GetNurbsSurface() const;
183
184 /** Sets the flag which indicates whether the surface normals are flipped.
185 * You can flip the normals of the surface to reverse the surface.
186 * \param pFlip If \c true, the surface is reversed. If it is false, the surface is not reversed.
187 */
188 inline void SetFlipNormals( bool pFlip ) { mFlipNormals = pFlip; }
189
190 /** Checks if the normals are flipped.
191 * \return \c True if normals are flipped, returns \c false if they are not flipped.
192 */
193 inline bool GetFlipNormals() const { return mFlipNormals; }
194
195 virtual int GetControlPointsCount() const;
196
197 /** Sets the control point and the normal values for a specified index.
198 * \param pCtrlPoint The value of the control point.
199 * \param pNormal The value of the normal.
200 * \param pIndex The specified index.
201 * \param pI2DSearch Unused in this implementation.
202 */
203 virtual void SetControlPointAt(const FbxVector4 &pCtrlPoint, const FbxVector4 &pNormal , int pIndex, bool pI2DSearch = false);
204
205 /** Sets the control point for a specified index.
206 * \param pCtrlPoint The value of the control point.
207 * \param pIndex The specified index.
208 */
209 virtual void SetControlPointAt(const FbxVector4 &pCtrlPoint, int pIndex) { ParentClass::SetControlPointAt(pCtrlPoint, pIndex); }
210
211 /** Returns the NURBS surface's control points.
212 * \param pStatus The FbxStatus object to hold error codes.
213 */
214 virtual FbxVector4* GetControlPoints(FbxStatus* pStatus = NULL) const;
215
216/*****************************************************************************************************************************
217** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
218*****************************************************************************************************************************/
219#ifndef DOXYGEN_SHOULD_SKIP_THIS
220 virtual FbxObject& Copy(const FbxObject& pObject);
221
222 bool IsValid(bool mustClosed = true);
223 void ClearBoundaries();
224 void CopyBoundaries( FbxTrimNurbsSurface const& pOther );
225 bool IsValid(int pRegion, bool mustClosed = true);
226 void RebuildRegions();
227
228protected:
229 virtual void Construct(const FbxObject* pFrom);
230
231private:
232 bool mFlipNormals;
233 FbxArray<int> mRegionIndices;
234 bool mNewRegion;
235#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
236};
237
238#include <fbxsdk/fbxsdk_nsend.h>
239
240#endif /* _FBXSDK_SCENE_GEOMETRY_TRIM_NURBS_SURFACE_H_ */
241