Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
Face.h
Go to the documentation of this file.
1//! @file Face.h
2//! CFace class definition which is the base class for any kind of face
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_FACE_H__CA6BC29D_FAC2_11D1_A0DE_000000000000__INCLUDED_)
7#define AFX_FACE_H__CA6BC29D_FAC2_11D1_A0DE_000000000000__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "Collection.h"
14#include "Point.h"
15
16BEGIN_MOOTOOLS_NAMESPACE
17
18#define POINT_NOT_BELONG_TO_FACE -1
19#define EDGE_NOT_BELONG_TO_FACE -1
20
21typedef enum XEnumType(unsigned int)
22{
23 FACE_UNCHANGE = 0x00,
24 FACE_CHANGE = 0x01,
25 FACE_INVALID = 0x02,
26 FACE_DUPLICATED_INDEX = 0x04,
27} FACERESULT;
28
29typedef enum XEnumType(unsigned int)
30{
31 CONDITION_BELONG_TO_NONE = 0x00,
32 CONDITION_BELONG_TO_SOME = 0x01,
33 CONDITION_BELONG_TO_ALL = 0x02,
34} FLAGRESULT;
35
36//! @enum FACE_PROPERTIES
37//! @brief Face flags used by any classes that inherit from CFace (C3DFace, CUVWFace...)
38typedef enum FACE_PROPERTIES XEnumType(unsigned int)
39{
40 FACE_NONE = 0x00,
41
42 //!< These flags can be used whatever the face class
43 FACE_IS_INVALID = 0x01, //!< This flag is used when a face a less than 3 indexes or when it is tagged invalid. Geometric faces that have this flag are removed during cleaning operation. Channel face are kept, but the flag is converted to FACE_IS_UNUSED during cleaning operation.
44 FACE_IS_UNUSED = 0x02, //!< This flag is to be used in a dependent channel, meaning that the face should be ignored and does not contain data.
45 FACE_IS_HIDDEN = 0x04,
46 FACE_IS_HOLE = 0x08,
47 FACE_IS_SINGLE_SIDED = 0x10, //!< Force single side display (cannot be used with FACE_IS_DOUBLE_SIDED)
48 FACE_IS_DOUBLE_SIDED = 0x20, //!< Force double side display
49 FACE_IS_SELECTED = 0x40,
50
51 //!< Face computed properties
52 FACE_IS_BORDER = 0x1000,
53 FACE_HAS_COPLANAR_NEIGHBOURG = 0x2000,
54 FACE_HAS_CONFUSED_POINTS = 0x4000,
55 FACE_IS_TEMP_SELECTED = 0x8000, //!< used by some algorithm to tag some faces. It must be reset to FALSE each time you need to use it.
56
57 FACE_USER_SELECTED = 0x10000, //!< Flag used for interacting with point list. This is a helper to keep FACE_IS_SELECTED flags is interaction canceled.
58
59 FACE_USER_PROPERTIES1 = 0x01000000,
60 FACE_USER_PROPERTIES2 = 0x02000000,
61 FACE_USER_PROPERTIES3 = 0x04000000,
62 FACE_USER_PROPERTIES4 = 0x08000000,
64
66//! @class CFacePropertyData
67//! @brief CFacePropertyData is the main data chunk of CFaceList which consists of storing the flags.
68//! @details It is overriden by C3DFacePropertyData in C3DFaceList
70{
72 friend CFaceList;
73 friend CFace;
74
75protected:
76 unsigned int flags;
77
79};
80
81inline CFacePropertyData::CFacePropertyData()
82{
83 flags = FACE_NONE;
84}
85
86//! @class CFace
87//! @brief A CFace contains the information related to a given face in a CFaceList.
88//! @details CFace is most of the time built from CFaceList::GetFace method. It represents a single face of this list at the specified index.
89//! CFace is the base class for more specific classes C3DFace, CUVWFace...\n
90//! It contains an array of indexes that refers to CPointList.
91//! @note
92//! CFaces indexes can be modified or resized but do not forget that they are part of the whole CFaceList, which is in a single memory block.\n
93//! Resizing faces (especially if indexes are added) can lead to numerous memory reallocations and loss of performance.\n
94//! The CFaceList class contains a number of methods for pre-allocating memory, so that a call to SetSize does not lead to inappropriate memory reallocations.
95class CDataChunk;
96class DLL_3DFUNCTION CFace : protected CCollectionElement<int, unsigned short>
97{
98 friend CFaceList;
99
100protected:
101 CFaceList *faces;
102 CFacePropertyData *prop;
103
104public:
105 using CCollectionElement<int, unsigned short>::Reset;
106 using CCollectionElement<int, unsigned short>::IsEmpty;
107 using CCollectionElement<int, unsigned short>::GetSize;
108 using CCollectionElement<int, unsigned short>::GetData;
109 using CCollectionElement<int, unsigned short>::operator [];
110 using CCollectionElement<int, unsigned short>::GetAt;
111 using CCollectionElement<int, unsigned short>::SetAt;
112
113 CFace();
114
115 // Face info
116 unsigned int GetFaceIndex() const;
117 unsigned int GetFlags() const;
118 void SetFlags(unsigned int flags);
119 bool IsFlagSet(FACE_PROPERTIES) const;
120 bool IsOneFlagSet(int flag) const;
121 void SetFlag(FACE_PROPERTIES, bool set);
122 void SetFlags(unsigned int flags, bool set);
123 void Inherit(const CFace& srcface); //!< Inherit srcface chunks (and so flags and others properties), but don't copy the srcface indexes
124 bool Copy(const CFace& srcface);
125 bool Copy(unsigned int srcindex);
126
127 // Points index functions
128 int *SetSize(int size, FACE_PROPERTIES invalidFlag = FACE_IS_INVALID); //!< Set the number of indexes for the face. If size < 3, then invalidFlag flag is set, if size >= 3 the flag is removed.. For channel flags, FACE_IS_UNUSED should be used to keep the same number of faces between 3d faces and channel faces, if the matching 3d face is not set to invalid on a clean operation
129 int ReplaceIndex(int oldindex, int newindex);
130 bool CompareIndexes(const CFace& refface, bool allowIndexShift) const;
131 int AddIndex(int);
132 bool RemoveIndex(int);
133 void SetTriangle(int pointindex1, int pointindex2, int pointindex3);
134 void SetQuadrangle(int pointindex1, int pointindex2, int pointindex3, int pointindex4);
135 void Flip();
136
137 // Face ! who are you ?
138 bool IsOnePointFlagSet(const CGeomInfo *info, unsigned int pointPropertiesFlags, bool set); //!< check if one point has one of the pointPropertiesFlags set or unset (call IsPointFlagSet internally)
139 FLAGRESULT IsPointFlagSet(const CGeomInfo *info, unsigned int pointPropertiesFlags, bool set); //!< check how many points have one of the pointPropertiesFlags set or unset (call IsPointFlagSet internally)
140 void SetPointFlag(const CGeomInfo *info, unsigned int pointPropertiesFlags, bool set);
141 int IsFacePoint(int pointindex); //!< Check if point index belong to face. Return the index position of this pointindex or POINT_NOT_BELONG_TO_FACE
142 int GetPrevIndex(int offset) const;
143 int GetNextIndex(int offset) const;
144 int IsFaceEdge(int pt1, int pt2, bool sameOrder);
145 bool IsTriangular();
146
147 // Others
148 void GetCenter(const CGeomInfo *info, C4DPoint& center) const;
149 void *GetDataChunk(unsigned int id) const;
150 SIZET GetSizeOfData(unsigned int id) const;
151};
152
153///////////////////////////////////////////////////////////////////////////////////
154// Inline implementation
155
156inline CFace::CFace()
157{
158 faces = NULL;
159 prop = NULL;
160}
161
162inline unsigned int CFace::GetFaceIndex() const
163{
164 return GetEntryIndex();
165}
166
167inline unsigned int CFace::GetFlags() const
168{
169 return prop->flags;
170};
171
172inline void CFace::SetFlags(unsigned int flags)
173{
174 prop->flags = flags;
175};
176
177inline void CFace::SetFlag(FACE_PROPERTIES flag, bool set)
178{
179 if (set)
180 prop->flags |= flag;
181 else
182 prop->flags &= ~flag;
183}
184
185inline void CFace::SetFlags(unsigned int newflags, bool set)
186{
187 if (set)
188 prop->flags |= newflags;
189 else
190 prop->flags &= ~newflags;
191}
192
193inline bool CFace::IsFlagSet(FACE_PROPERTIES flag) const
194{
195 return ((prop->flags & flag) == flag);
196}
197
198inline bool CFace::IsOneFlagSet(int flag) const
199{
200 XASSERT(flag != FACE_NONE); // This does not allow to test this case
201 return ((prop->flags & flag) != 0);
202}
203
204// Return the next point index, giving a face offset
205inline int CFace::GetNextIndex(int offset) const
206{
207 int size;
208 const int *pts_data = GetData(size);
209 XASSERT(offset >=0 && offset < size);
210 return pts_data[(offset+1) % size];
211}
212
213// Return the prev point index, giving a face offset
214inline int CFace::GetPrevIndex(int offset) const
215{
216 int size;
217 const int *pts_data = GetData(size);
218 XASSERT(offset >=0 && offset < size);
219 return pts_data[(size+offset-1) % size];
220}
221
223{
224 SetFlag(invalidFlag, size < 3);
226}
227
228END_MOOTOOLS_NAMESPACE
229
230#endif // !defined(AFX_FACE_H__CA6BC29D_FAC2_11D1_A0DE_000000000000__INCLUDED_)
FACE_PROPERTIES
Face flags used by any classes that inherit from CFace (C3DFace, CUVWFace...)
Definition Face.h:39
@ FACE_USER_SELECTED
Flag used for interacting with point list. This is a helper to keep FACE_IS_SELECTED flags is interac...
Definition Face.h:57
@ FACE_IS_DOUBLE_SIDED
Force double side display.
Definition Face.h:48
@ FACE_IS_SELECTED
Face computed properties.
Definition Face.h:49
@ 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
@ FACE_IS_TEMP_SELECTED
used by some algorithm to tag some faces. It must be reset to FALSE each time you need to use it.
Definition Face.h:55
@ FACE_IS_SINGLE_SIDED
Force single side display (cannot be used with FACE_IS_DOUBLE_SIDED)
Definition Face.h:47
CPt class is the base class for different class of points (C3DPoint, CUVWPoint...)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition 4DPoint.h:17
Definition Collection.h:30
Definition DataChunk.h:29
A CFace contains the information related to a given face in a CFaceList.
Definition Face.h:97
FLAGRESULT IsPointFlagSet(const CGeomInfo *info, unsigned int pointPropertiesFlags, bool set)
check how many points have one of the pointPropertiesFlags set or unset (call IsPointFlagSet internal...
bool IsOnePointFlagSet(const CGeomInfo *info, unsigned int pointPropertiesFlags, bool set)
check if one point has one of the pointPropertiesFlags set or unset (call IsPointFlagSet internally)
int IsFacePoint(int pointindex)
Check if point index belong to face. Return the index position of this pointindex or POINT_NOT_BELONG...
int * SetSize(int size, FACE_PROPERTIES invalidFlag=FACE_IS_INVALID)
Set the number of indexes for the face. If size < 3, then invalidFlag flag is set,...
Definition Face.h:222
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
CFacePropertyData is the main data chunk of CFaceList which consists of storing the flags.
Definition Face.h:70
Definition FaceList.h:62
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71