Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
3DFaceList.h
Go to the documentation of this file.
1//! @file 3DFaceList.h
2//!
3//! @brief C3DFaceList class definition which is a list of C3DFace
4//!
5//////////////////////////////////////////////////////////////////////
6
7#if !defined(AFX_3DFACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_)
8#define AFX_3DFACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_
9
10#ifdef _MSC_VER
11#pragma once
12#endif // _MSC_VER
13
14#include "BitArray.h"
15#include "3DBBox.h"
16#include "FaceList.h"
17#include "3DPointList.h"
18#include "3DFace.h"
19#include "DependentChannels.h"
20#include "MaterialMap.h"
21
22BEGIN_MOOTOOLS_NAMESPACE
23
24//! @class FBMaterialID
25//! @brief This class handles two MaterialID that simplifies operation on faces which have front and back materials.
26//! For example Sketchup format use intensively that kind of faces, and FBMaterial is a simple way to know if a face IsSingleMaterial, or if it has different front and back materials.
28{
29public:
30 MaterialID frontID;
31 MaterialID backID;
32
34 {
35 frontID = backID = MATERIAL_UNDEFINED;
36 }
37
38 FBMaterialID(MaterialID front, MaterialID back = MATERIAL_UNDEFINED)
39 {
40 frontID = front;
41 backID = back;
42 }
43
44 inline bool operator==(FBMaterialID mat) const
45 {
46 if (frontID == mat.frontID && backID == mat.backID)
47 return true;
48
49 return false;
50 }
51
52 inline bool operator!=(FBMaterialID mat) const
53 {
54 if (frontID != mat.frontID || backID != mat.backID)
55 return true;
56
57 return false;
58 }
59
60 inline bool IsUndefined() const
61 {
62 if (frontID == MATERIAL_UNDEFINED && backID == MATERIAL_UNDEFINED)
63 return true;
64
65 return false;
66 }
67
68 inline bool IsFrontDefined() const
69 {
70 return (frontID != MATERIAL_UNDEFINED);
71 }
72
73 inline bool IsBackDefined() const
74 {
75 return (backID != MATERIAL_UNDEFINED);
76 }
77
78 inline bool IsSingleMaterial() const // Return true if front material is the same than back material or if there is no back material. Note: this does not take into account the fact that this single material might have different front and back UV
79 {
80 return (frontID == backID) || (!IsBackDefined());
81 }
82};
83
84template <> class CHashMethods<FBMaterialID>
85{
86public:
87 static inline bool HashCompare(const FBMaterialID& mat1, const FBMaterialID& mat2)
88 {
89 if (mat1.frontID != mat2.frontID)
90 return false;
91
92 if (mat1.backID != mat2.backID)
93 return false;
94
95 return true;
96 }
97
98 static inline unsigned int HashValue(const FBMaterialID& hash)
99 {
101 }
102};
103
104//! @class CFBMaterialHashMap
105//! @brief This class gets an object material hash. It returns front and back material pair.
106//! @Note if we have a face #1 [Mat #1, Mat #2] and a face #2 [Mat #1, Mat #3] we will get 2 entries with (#1-#2, 1), (#1-#3, 1)
107class DLL_3DFUNCTION CFBMaterialHashMap : public CHashMap<FBMaterialID, FBMaterialID, unsigned int>
108{
109 friend C3DFaceList;
110
111protected:
112 mutable bool hasBackMaterial;
113
114public:
116
117 unsigned int GetFrontHash(CMaterialHashMap& map, bool reset = true, bool removeUndefinedMaterial = true) const; // Get the front material hash map and return the number of front material faces
118 unsigned int GetBackHash(CMaterialHashMap& map, bool reset = true, bool removeUndefinedMaterial = true) const; // Get the back material hash map and return the number of back material faces
119 unsigned int GetFrontBackHash(CMaterialHashMap& map, bool reset = true, bool removeUndefinedMaterial = true) const; // Get the front and back material hash map and return the number of material that belong to front or back faces. Note: if we have a face #1 [Mat #1, Mat #2] and a face #2 [Mat #1, Mat #3] we will get 3 entries with (#1, 2), (#2, 1) (#3, 1)
120
121 unsigned int ReplaceFrontMaterial(MaterialID matid, MaterialID newmatid); // Replace all materials that have front matid by front newmatid material. Return the number of front materials changed
122 unsigned int ReplaceBackMaterial(MaterialID matid, MaterialID newmatid); // Replace all materials that have back matid by back newmatid material. Return the number of back materials changed
123
124#ifdef _DEBUG
125 unsigned int GetFaceCount(MaterialID frontid, MaterialID backid) const; // Return the number of face thta have frontid or backid
126 static unsigned int GetFaceCount(const CMaterialHashMap& map); // Return the number of face concerned by the material hash
127#endif
128};
129
130class C3DFacePropertyMethods : public CFacePropertyMethods
131{
132 DECLARE_SERIAL_XOBJECT(C3DFacePropertyMethods);
133
134 SIZET GetSizeof() const;
135 ElementType GetType() const;
136 void ConstructElement(void* pNewData);
137
138#ifdef _DEBUG
139 void Dump(const void* data) const
140 {
141 XTRACE(_T("Flags: %d - MaterialID : %d\n"), ((C3DFacePropertyData*)data)->flags, ((C3DFacePropertyData *)data)->materialid);
142 };
143#endif
144};
145
146inline SIZET C3DFacePropertyMethods::GetSizeof() const
147{
148 return sizeof(C3DFacePropertyData);
149}
150
151inline ElementType C3DFacePropertyMethods::GetType() const
152{
153 return MAKE_CUSTOM_ID('3', 'D', 'F', 'A');
154}
155
156inline void C3DFacePropertyMethods::ConstructElement(void* pNewData)
157{
158 xConstruct(C3DFacePropertyData, pNewData);
159}
160
161typedef enum FaceGridFlags XEnumType(unsigned int)
162{
163 FACEGRID_NONE = 0x00,
164
165 // Method that will be called
166 FACEGRID_CACHE_FOR = 0x0FF,
167 FACEGRID_CACHE_FOR_RAYCAST = 0, // Default method
168 FACEGRID_CACHE_FOR_GETCLOSESTFACE,
169
170 // Parameters
171 FACEGRID_MULTITHREADED = 0x100, // the grid will be called in concurrently in different thread
172 FACEGRID_REMOVE_DUPLICATED_FACES = 0x200, // Fast removal of duplicated faces in the graph (face that have same indexes. As a consequence, only one of those duplicated faces are added to the grid)
173 FACEGRID_FILL_FULL_BBOX = 0x400, // This is the and original standard filling method (all face bbox cells are filled). Otherwise only cells belonging to the face plane are filled.
174 FACEGRID_IGNORE_NODE_TRANSFORM = 0x800, // If a node is provided, does not take care of the node transform
175
176#ifdef _DEBUG
177 FACEGRID_DEBUG = 0x10000,
178#endif
179} FaceGridFlags;
180
181//! @enum RayCastFlags
182//! This enum gives a control on the faces handled by C3DFaceList::GetRayCastFace and information returned.
183typedef enum RayCastFlags XEnumType(unsigned int)
184{
185 RAYCAST_DEFAULT = 0x00,
186 RAYCAST_CHECK_BOTHDIR = 0x01, //!< Test ray cast in both direction
187 RAYCAST_TUV_COORDINATE = 0x02, //!< hitPoint(x, y, z) contains the (t, u, v) coordinates of the found intersection. We can compute the hitPoint in 2 way : hitPoint = eye + t * normal or hitPoint = (1-u-v) * p0 + u * p1 + v * p2 where p0, p1, p2 are the triangle point. Note that if RAYCAST_CHECK_BOTHDIR and that the normal have been flipped to intersect the face, then t will be negative to correctly compute the hitPoint
188 RAYCAST_SAME_DIRECTION = 0x04, //!< The provided direction and the normal of the face must have the same direction
189 RAYCAST_OPPOSITE_DIRECTION = 0x08, //!< The provided direction and the normal of the face must have the opposite direction
190#ifdef _DEBUG
191 RAYCAST_DEBUG = 0x1000, //!< internal: Debug ray cast
192#endif
194
195//! @class C3DFaceGridMap
196//! @brief C3DFaceGridMap is initialized by C3DFaceList::GetFaceGridMap.
197//! @details It allows to perform fast ray casting or retrieve the closest face giving a point.
198//! Giving a point, it return a face index list of the faces which are in the voxel where is located the point.
200{
201 friend C3DFaceList;
202
203protected:
204 mutable CXCriticalSection threadLock;
205 unsigned int flags;
206 unsigned int facesize; // The face list number of faces, needed to initializing ThreadInfo through BeginThread
207 C4x4Matrix mat; // A transformation matrix
208 C3DBBox bbox; // The bounding box containing the datas (eventually transformed)
209 C3DPointI cells; // cells number in x, y, z dimensions
210
211#ifdef _DEBUG
212 unsigned int beginThreadCount;
213#endif
214
215 typedef struct ThreadInfo
216 {
217 CBitArray checkedFaces; // Speedup GetClosestFace by avoiding multiple allocation
218 CXArray<int> checkedIndexes;
219 } ThreadInfo;
220
222
223 unsigned int ThreadCount() const;
224 bool ThreadIsInitialized() const;
225
226public:
227 C3DFaceGridMap(CGeomInfo* info, unsigned int faceGridFlags); //!< Init grid. info contains points and faces list. voxelCountMultiplicationFactor multiply the default number of grid voxel.
228 virtual ~C3DFaceGridMap();
229
230 ThreadInfo *BeginThread(bool forceSingleThread = false); //!< Parallel support for GetClosestFace, GetRayCastFace, GetRayCastFace2
231 void EndThread();
232
233 unsigned int GetFlags() const; //!< return flags used for creating the C3DPointGridMap
234 C3DBBox GetBBox() const; //!< Return the bounding box of the face list using for creating the grid map
235 const C4x4Matrix& GetTransform() const; //!< Return the matrix used to transform the point of the face grid map
236 unsigned int GetCellNbr() const; //!< Return the total number of cells that have been defined automatically depending on the input face list
237
238#ifdef _DEBUG
239 void Dump() const;
240 unsigned int ThreadInitializationCount() const { return beginThreadCount; }
241#endif
242};
243
244//! @class C3DFaceList
245//! @brief C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored in C3DPointList class.
246//! Look at CFaceList base class to get more information.
247//!
248class DLL_3DFUNCTION C3DFaceList : public CFaceList
249{
250public:
251 // using CFaceList::operator=;
252 DECLARE_SERIAL_XOBJECT(C3DFaceList);
253
254 //! @brief Create a new face list. When srcFaces is provided, the data structure (datachunks) is inherited but the face list is created empty
256 virtual ~C3DFaceList(); //!< Use CFace::Delete should be used because there can be several references to the face list. This does not occurs if C3DFaceList is created on the stack.
257
258 static C3DFaceList *Create(C3DFaceList *srcFaces = NULL); //!< Allocates and creates an empty set of 3d faces. Use C3DFaceList::Delete to delete it
259
260 virtual CFace *CreateFace() const //!< @brief use ReleaseFace(CFace *) to delete created face
261 {
262 return xNew(C3DFace);
263 };
264
265 //! @name Face information
266 //! Various information about the face
267 //!
268 //! @{
269 // void FlipFaces(const CGeomInfo *info, bool invertSpecNormal = true); // Reverse the index order for all faces and all the corresponding channel faces. Optionally set spec normal channels vectors to opposite dir
270 bool GetBoundingBox(const CGeomInfo *info, C3DPoint& min, C3DPoint& max, unsigned int faceFlags = FACE_NONE, bool set = true, C4x4Matrix *matrix = NULL); //!< points are transformed by matrix if any provided
271 bool GetBoundingBox(const CGeomInfo *info, C3DBBox& bbox, unsigned int faceFlags = FACE_NONE, bool set = true, C4x4Matrix *matrix = NULL); //!< points are transformed by matrix if any provided
272 bool UnifyNormals(CGeomInfo *info, CBitArray& flippedFaces);
273 double GetDistanceToFace(CGeomInfo *info, unsigned int index, const C3DPoint& pt); //!< Get the distance from face index to the given pt. Calculate the projection on the face or on the closest edge. The face can be both triangular or quadrangular
274 double GetDistanceToFacePlane(CGeomInfo *info, unsigned int index, const C3DPoint& pt, bool absoluteValue = true); //!< Get the distance from face index to the face plane. The face can be N-Gon but in this case, we check before that this NGon is planar, which can be slow.
275
276 //! @}
277
278 //! @name Operations on face
279 //! Modify the faces
280 //!
281 //! @{
282 int MergeCoplanarFaces(const CGeomInfo *info, double radianMaxAngle);
283 int Triangulate(CGeomInfo *, unsigned int uvwChannel = ALL_CHANNELS_TYPE, FACE_PROPERTIES properties = FACE_NONE, bool musthave = true);
284
285 //! @}
286
287 //! @name Retrieve quickly a face
288 //! Create a C3DFaceGridMap which is a way to quickly find a face
289 //!
290 //! @{
291 unsigned int GetFaceGridMapFlags() const; //!< Return an already computed face grid or null
292 C3DFaceGridMap* GetFaceGridMap(bool addReferenceCount = true); //!< Return an already computed map that contains each faces sampled in an integer grid. Pending DeleteFaceGridMap must be called, unless addReferenceCount = false
293 C3DFaceGridMap *GetFaceGridMap(CGeomInfo *info, unsigned int faceGridFlags = FACEGRID_NONE); //!< Return or (re-)compute a map that contains each faces sampled in an integer grid, with the given flags. The face list must be triangular, otherwise, returns NULL. Pending DeleteFaceGridMap must be called.
294 unsigned int GetClosestFace(CGeomInfo * info, C3DFaceGridMap * faceGridMap, const C3DPointD& pt, double& distance, double maxdistance = HUGE_VAL); //!< Return the closest face index to the point pt. If a face is found distance contains the distance of pt to the face. Otherwise distance = HUGE_VALUE and index INVALID_FACE_INDEX is returned. maxDistance can be used to define a max distance and limite the search, increasing speed.
295 unsigned int GetRayCastFace(CGeomInfo* info, C3DFaceGridMap* faceGridMap, const C3DPointD& eye, const C3DVectorD& dir, C3DPointD& hitPoint, unsigned int rayCastFlags = RAYCAST_DEFAULT, bool *oppositeDir = NULL); //!< Return the ray cast face index to the point pt, or INVALID_FACE_INDEX if none.
296 void DeleteFaceGridMap();
297
298 //! @}
299
300 //! @name Sort faces
301 //!
302 //! @{
303 int *Sort(unsigned int sortmode, unsigned int& arraySize, bool& orderChanged); //!< sortmode contains FACE_SORT_MODE flags. arraySize is the size of the returned index array. orderChanged is false if the faces are already sorted (index of the array match index of the faces). orderChanged means nothing if SORT_FRONT_AND_BACK_MATERIAL is set. The method returns a sorted by material array (this does not change the face order itself). arraySize contains the size of the returned array. It is equal to GetSize() or 2*GetSize() depending on the sort mode
304 bool Sort(const CGeomInfo *info, unsigned int mode); //!< Sort the face by changing their order; depenging on the front or back face material (SORT_FRONT_AND_BACK_MATERIAL cannot be used)
305
306 //! @name Get or modify material used by faces
307 //!
308 //! @{
309 bool ReplaceMaterial(MaterialID matid, MaterialID newmatid); //!< Replace face matid by newmatid and update the material hash map if possible
310 unsigned int GetMaterialsHashMap(const CGeomInfo *info, CMaterialHashMap& hashMaterialMap, bool includeBackFace = true, bool reset = true); //!< Get (MaterialID, facecount) hash. If includeBackFace, the back face material are added to the hash. Return the number of material
311 const CFBMaterialHashMap *GetFBMaterialsHashMap(const CGeomInfo *info); //!< Return a ((front MaterialID, back MaterialID), facecount) material id hash
312 void DeleteFBMaterialsHashMap(); //!< Free the hash material when no longer needed
313
314 // double side material information
315 bool HasDifferentFrontAndBackUVChannel(const CGeomInfo* info, MapType type) const; //!< Return true if the object has different front and back UV channels (looking materials front & back UV). The method return false, if back UV is undefined or if front and back channel are the same. A CGeomInfo with object and scene is needed.
316 bool HasBackFaceMaterials() const;
317 bool RemoveBackFaceMaterials(); //!< Return true if object had back face materials
318 void SetBackFaceMaterial(unsigned int index, MaterialID id);
319 void SetFaceMaterial(unsigned int index, MaterialID id);
320 MaterialID GetFaceMaterial(unsigned int index) const;
321 MaterialID GetBackFaceMaterial(unsigned int index, bool getFrontIfNeeded = false) const; //!< getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true, then this value is overriden by front face material
322 FBMaterialID GetFBFaceMaterial(unsigned int index, bool getFrontIfNeeded = false) const; //!< getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true, then this value is overriden by front face material
323 bool CompareBackAndFrontMaterials(bool deleteBackIfSame, bool checkFrontBackMaterialChannel = false, CGeomInfo *info = NULL); //!< return true if back & front materials are the sames, or if no back materials. deleteBackIfSame = true will delete the extra back face information. checkFrontBackMaterialChannel = true the delete occurs only if channelID is the same for front and back channelID (we might have the same material applied to both side of a face, with different channels) or if 2 differents channels are exactly the same
324
325 //! @}
326
327 // Update informations
328 virtual bool UpdateList();
329
330 virtual void RemoveAll();
331 C3DFaceList& operator=(const C3DFaceList& reffaces);
332 virtual CFaceList& operator=(const CFaceList& reffaces);
333
334#ifdef _DEBUG
335 unsigned int GetRayCastFaceDebug(CGeomInfo* info, C3DFaceGridMap* faceGridMap, const C3DPointD& eye, const C3DVectorD& dir, C3DPointD& hitPoint, unsigned int rayCastFlags = RAYCAST_DEFAULT, bool* oppositeDir = NULL); // Return the ray cast face index to the point pt, or INVALID_FACE_INDEX if none.
336 CXString GetFaceListType() const { return _T("3D"); };
337#endif
338
339protected:
340 CFBMaterialHashMap *fbMaterialHash;
341 C3DFaceGridMap *faceGridMap;
342
343 void CreateFBMaterialsHashMap(); // use GetMaterialsHash
344
345 int DoTriangulation(const CGeomInfo *info, unsigned int newsize, int internalFlags, FACE_PROPERTIES properties = FACE_NONE, bool musthave = true);
346};
347
348inline void C3DFaceList::SetFaceMaterial(unsigned int index, MaterialID id)
349{
350 C3DFacePropertyData *prop = static_cast<C3DFacePropertyData *>(GetMainDataChunk(index));
351 prop->materialid = id;
352}
353
354inline MaterialID C3DFaceList::GetFaceMaterial(unsigned int index) const
355{
356 C3DFacePropertyData *prop = static_cast<C3DFacePropertyData *>(GetMainDataChunk(index));
357 if (prop && !(prop->flags & (FACE_IS_INVALID|FACE_IS_UNUSED)))
358 return prop->materialid;
359
360 return MATERIAL_UNDEFINED;
361}
362
363inline MaterialID C3DFaceList::GetBackFaceMaterial(unsigned int index, bool getFrontIfNeeded) const
364{
365 const CBackFaceMaterialData *data = (const CBackFaceMaterialData *)GetDataChunks().GetData(FACE_BACK_MATERIAL, index);
366 if (data)
367 {
368 if (getFrontIfNeeded && data->matid == MATERIAL_UNDEFINED)
369 return GetFaceMaterial(index);
370
371 return data->matid;
372 }
373
374 return getFrontIfNeeded ? GetFaceMaterial(index) : MATERIAL_UNDEFINED; // Invalid material. Use the front face material
375}
376
378{
379 return FBMaterialID(GetFaceMaterial(index), GetBackFaceMaterial(index, getFrontIfNeeded));
380}
381
382END_MOOTOOLS_NAMESPACE
383
384#endif // !defined(AFX_3DFACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_)
C3DBBoxT template class for handling bounding box.
C3DFace class definition for a 3D face, which is a list of indexes that refers to a 3D point list.
RayCastFlags
Definition 3DFaceList.h:184
@ RAYCAST_CHECK_BOTHDIR
Test ray cast in both direction.
Definition 3DFaceList.h:186
@ RAYCAST_TUV_COORDINATE
hitPoint(x, y, z) contains the (t, u, v) coordinates of the found intersection. We can compute the hi...
Definition 3DFaceList.h:187
@ RAYCAST_OPPOSITE_DIRECTION
The provided direction and the normal of the face must have the opposite direction.
Definition 3DFaceList.h:189
@ RAYCAST_SAME_DIRECTION
The provided direction and the normal of the face must have the same direction.
Definition 3DFaceList.h:188
C3DPointList class definition for handling a list of C3DPoint.
CDependentChannels class definition which handles a CChannel array.
FACE_PROPERTIES
Face flags used by any classes that inherit from CFace (C3DFace, CUVWFace...)
Definition Face.h:39
@ FACE_NONE
These flags can be used whatever the face class.
Definition Face.h:40
@ FACE_IS_INVALID
This flag is used when a face a less than 3 indexes or when it is tagged invalid. Geometric faces tha...
Definition Face.h:43
@ FACE_IS_UNUSED
This flag is to be used in a dependent channel, meaning that the face should be ignored and does not ...
Definition Face.h:44
CFaceList class is the base class for different kind of face list.
MapType
This enum allows to know the kind of texture map.
Definition MaterialMap.h:26
C3DFaceGridMap is initialized by C3DFaceList::GetFaceGridMap.
Definition 3DFaceList.h:200
unsigned int GetCellNbr() const
Return the total number of cells that have been defined automatically depending on the input face lis...
C3DBBox GetBBox() const
Return the bounding box of the face list using for creating the grid map.
unsigned int GetFlags() const
return flags used for creating the C3DPointGridMap
ThreadInfo * BeginThread(bool forceSingleThread=false)
Parallel support for GetClosestFace, GetRayCastFace, GetRayCastFace2.
C3DFaceGridMap(CGeomInfo *info, unsigned int faceGridFlags)
Init grid. info contains points and faces list. voxelCountMultiplicationFactor multiply the default n...
const C4x4Matrix & GetTransform() const
Return the matrix used to transform the point of the face grid map.
A 3D face is a list of indexes of C3DPointList object point list.
Definition 3DFace.h:43
C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored i...
Definition 3DFaceList.h:249
bool ReplaceMaterial(MaterialID matid, MaterialID newmatid)
Replace face matid by newmatid and update the material hash map if possible.
unsigned int GetMaterialsHashMap(const CGeomInfo *info, CMaterialHashMap &hashMaterialMap, bool includeBackFace=true, bool reset=true)
Get (MaterialID, facecount) hash. If includeBackFace, the back face material are added to the hash....
virtual CFace * CreateFace() const
<
Definition 3DFaceList.h:260
C3DFaceGridMap * GetFaceGridMap(CGeomInfo *info, unsigned int faceGridFlags=FACEGRID_NONE)
Return or (re-)compute a map that contains each faces sampled in an integer grid, with the given flag...
bool GetBoundingBox(const CGeomInfo *info, C3DPoint &min, C3DPoint &max, unsigned int faceFlags=FACE_NONE, bool set=true, C4x4Matrix *matrix=NULL)
points are transformed by matrix if any provided
C3DFaceList(C3DFaceList *srcFaces=NULL)
Create a new face list. When srcFaces is provided, the data structure (datachunks) is inherited but t...
const CFBMaterialHashMap * GetFBMaterialsHashMap(const CGeomInfo *info)
Return a ((front MaterialID, back MaterialID), facecount) material id hash.
int * Sort(unsigned int sortmode, unsigned int &arraySize, bool &orderChanged)
sortmode contains FACE_SORT_MODE flags. arraySize is the size of the returned index array....
double GetDistanceToFacePlane(CGeomInfo *info, unsigned int index, const C3DPoint &pt, bool absoluteValue=true)
Get the distance from face index to the face plane. The face can be N-Gon but in this case,...
bool Sort(const CGeomInfo *info, unsigned int mode)
Sort the face by changing their order; depenging on the front or back face material (SORT_FRONT_AND_B...
void DeleteFBMaterialsHashMap()
Free the hash material when no longer needed.
unsigned int GetClosestFace(CGeomInfo *info, C3DFaceGridMap *faceGridMap, const C3DPointD &pt, double &distance, double maxdistance=HUGE_VAL)
Return the closest face index to the point pt. If a face is found distance contains the distance of p...
double GetDistanceToFace(CGeomInfo *info, unsigned int index, const C3DPoint &pt)
Get the distance from face index to the given pt. Calculate the projection on the face or on the clos...
FBMaterialID GetFBFaceMaterial(unsigned int index, bool getFrontIfNeeded=false) const
getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true,...
Definition 3DFaceList.h:377
unsigned int GetRayCastFace(CGeomInfo *info, C3DFaceGridMap *faceGridMap, const C3DPointD &eye, const C3DVectorD &dir, C3DPointD &hitPoint, unsigned int rayCastFlags=RAYCAST_DEFAULT, bool *oppositeDir=NULL)
Return the ray cast face index to the point pt, or INVALID_FACE_INDEX if none.
virtual ~C3DFaceList()
Use CFace::Delete should be used because there can be several references to the face list....
unsigned int GetFaceGridMapFlags() const
Return an already computed face grid or null.
static C3DFaceList * Create(C3DFaceList *srcFaces=NULL)
Allocates and creates an empty set of 3d faces. Use C3DFaceList::Delete to delete it.
bool RemoveBackFaceMaterials()
Return true if object had back face materials.
bool HasDifferentFrontAndBackUVChannel(const CGeomInfo *info, MapType type) const
Return true if the object has different front and back UV channels (looking materials front & back UV...
bool CompareBackAndFrontMaterials(bool deleteBackIfSame, bool checkFrontBackMaterialChannel=false, CGeomInfo *info=NULL)
return true if back & front materials are the sames, or if no back materials. deleteBackIfSame = true...
MaterialID GetBackFaceMaterial(unsigned int index, bool getFrontIfNeeded=false) const
getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true,...
Definition 3DFaceList.h:363
bool GetBoundingBox(const CGeomInfo *info, C3DBBox &bbox, unsigned int faceFlags=FACE_NONE, bool set=true, C4x4Matrix *matrix=NULL)
points are transformed by matrix if any provided
C3DFaceGridMap * GetFaceGridMap(bool addReferenceCount=true)
Return an already computed map that contains each faces sampled in an integer grid....
C3DPointGridMap is a compact class for retrieving quickly points which are in the same voxel of a pro...
Definition 3DPointList.h:77
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Class for storing the back face material using FACE_BACK_MATERIAL id in C3DFaceList::AddDataChunk.
Definition 3DExtraData.h:78
CBitArray class for handling array of bits.
Definition BitArray.h:18
This class gets an object material hash. It returns front and back material pair. @Note if we have a ...
Definition 3DFaceList.h:108
A CFace contains the information related to a given face in a CFaceList.
Definition Face.h:97
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
CFacePropertyData * GetMainDataChunk(unsigned int index) const
return the main data chunk for index. The main data chunk is a chunk like another one,...
Definition FaceList.h:748
const CDataChunk & GetDataChunks() const
Return the class that handles the data chunks.
Definition FaceList.h:731
Definition FaceList.h:62
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
CHashMap is a template class that associates key to a single value through an hash table.
Definition HashMap.h:42
Definition Hash.h:146
Definition InstanciatedObject.h:16
Definition XThreadSync.h:20
This class handles two MaterialID that simplifies operation on faces which have front and back materi...
Definition 3DFaceList.h:28