6#if !defined(AFX_FACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_)
7#define AFX_FACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_
19BEGIN_MOOTOOLS_NAMESPACE
26 FACELIST_INTERNAL_FLAGS = 0xFFF00000,
27 FACELIST_ORDERED_FOR_RENDERING = 0x00100000,
28 FACELIST_MAT2FACE_INCLUDE_BACK = 0x00200000,
30 FACELIST_SERIALIZE_FLAGS = FACELIST_ORDERED_FOR_RENDERING,
54#define FACEPROPERTY_CHUNK MAKE_CUSTOM_ID('F', 'C', 'P', 'R')
55#define FACE_ORIGINAL_INDEX_CHUNK MAKE_CUSTOM_ID('F', 'A', 'O', 'I')
56#define FACE_SMOOTH_FLAG MAKE_CUSTOM_ID('F', 'A', 'S', 'F')
57#define FACE_SUB_MAT_FLAG MAKE_CUSTOM_ID('F', 'A', 'S', 'M')
58#define FACE_BACK_MATERIAL MAKE_CUSTOM_ID('B', 'K', 'M', 'T')
59#define FACETAG_DATA_CHUNK MAKE_CUSTOM_ID('F', 'C', 'T', 'G')
65 SIZET GetSizeof()
const;
66 ElementType GetType()
const;
67 ElementType GetBaseType()
const;
68 void ConstructElement(
void*
pNewData);
79 C3DEdge(
int point1,
int point2);
83 void SetMatchLessEdge(
int point1,
int point2);
84 void SetEdge(
int point1,
int point2);
101 void ReleaseArray(
const int *connections);
110 unsigned int connectionsSize;
112 int *GetArray(
unsigned int size);
164#define FACELIST_DEFAULT_INDEX_NBR 4
199 void ReleaseFace(
CFace *face)
const;
201 bool GetFace(
unsigned int index,
CFace& face)
const;
202 bool GetFace(
unsigned int index,
CFace& face);
203 int *GetIndexes(
unsigned int index,
int& size)
const;
206 unsigned int GetFaceFlags(
unsigned int index)
const;
208 bool CheckFaceFlags(
unsigned int index,
unsigned int flags,
bool allSetOrNoneSet)
const;
209 bool IsFaceOneFlagSet(
unsigned int index,
unsigned int flags)
const;
211 void SetFaceFlags(
unsigned int index,
unsigned int flags,
bool set);
239 void *GetDataChunk(DataChunkID
id,
unsigned int index)
const;
244 SIZET GetSizeOfData(DataChunkID
id)
const;
248 virtual void Dump()
const;
256 unsigned int GetOriginalIndex(
unsigned int index,
unsigned int dataChunkID = FACE_ORIGINAL_INDEX_CHUNK)
const;
289 unsigned int GetChangedStamp()
const;
299 int GetNumberOfFaces(
unsigned int property,
bool set)
const;
300 void SetFacesFlags(
unsigned int first,
unsigned int last,
unsigned int flags,
bool set);
301 void SetFacesFlags(
unsigned int flags,
bool set);
302 void SetFacesSize(
unsigned int facesize);
312 void SetBorderFacesStatus(
void);
314 int InitPointToFaceGraph(
const CGeomInfo *info);
321 const int *GetFacesConnectedToPoint(
int,
int& size)
const;
329 bool DoesEdgeExists(
const C3DEdge&
edge,
int face = -1)
const;
331 bool IsIsolatedFace(
int facenbr)
const;
335 int GraphMergePointConnectivity(
int,
int);
368 unsigned int changeStamp;
374 void CleanPointsIndex(
const CGeomInfo *info);
377 virtual bool UpdateList();
380 void CreatePointToFaceGraph(
const CGeomInfo *info);
383 void CreateEdgeToFaceGraph();
403inline SIZET CFacePropertyMethods::GetSizeof()
const
408inline ElementType CFacePropertyMethods::GetType()
const
410 return MAKE_CUSTOM_ID(
'F',
'A',
'C',
'E');
413inline ElementType CFacePropertyMethods::GetBaseType()
const
415 return MAKE_CUSTOM_ID(
'F',
'A',
'C',
'E');
418inline void CFacePropertyMethods::ConstructElement(
void*
pNewData)
439inline C3DEdge::C3DEdge()
447 XTRACE(
"SetEdge point1 == point2\n");
467inline int C3DEdge::Point1()
const
472inline int C3DEdge::Point2()
const
489 this->point1 =
edge.point1;
490 this->point2 =
edge.point2;
497 if (point1 <
edge.point1)
503inline bool C3DEdge::operator==(
const C3DEdge&
edge)
const
506 if (point1 ==
edge.point1 && point2 ==
edge.point2)
512inline bool C3DEdge::operator!=(
const C3DEdge&
edge)
const
515 if (point1 !=
edge.point1)
518 if (point2 !=
edge.point2)
528 static inline unsigned int HashValue(
const C3DEdge &
edge)
530 #ifdef OLD_HASH_FUNCTIONS
531 return ((
unsigned int)(
edge.Point1() << 8)) +
edge.Point2();
533 return HashMixValue(
edge.Point1()) +
edge.Point2();
559inline bool CFaceList::GetFace(
unsigned int index,
CFace& face)
const
561 if (index >= ptsIndex.GetEntriesSize())
565 ptsIndex.GetEntry(index, face);
571inline bool CFaceList::GetFace(
unsigned int index,
CFace& face)
573 if (index >= ptsIndex.GetEntriesSize())
577 ptsIndex.GetEntry(index, face);
585inline int *CFaceList::GetIndexes(
unsigned int index,
int&
refsize)
const
587 XASSERT(index < ptsIndex.GetEntriesSize());
588 return ptsIndex.GetEntry(index,
refsize);
593 if (
faceindex >= ptsIndex.GetEntriesSize())
594 return POINT_NOT_BELONG_TO_FACE;
598 for (
int i = 0;
i < size;
i++)
604 return POINT_NOT_BELONG_TO_FACE;
609 XASSERT(index < ptsIndex.GetEntriesSize());
611 return ptsIndex.SetEntrySize(index,
refsize);
614inline unsigned int CFaceList::GetFaceFlags(
unsigned int index)
const
616 if (index >= ptsIndex.GetEntriesSize())
624 if (index >= ptsIndex.GetEntriesSize())
628 return ((prop->flags &
flag) ==
flag);
633 if (index >= ptsIndex.GetEntriesSize())
648 if (index >= ptsIndex.GetEntriesSize())
655 prop->flags &=
~flag;
658inline void CFaceList::SetFaceFlags(
unsigned int index,
unsigned int refflags,
bool set)
660 if (index >= ptsIndex.GetEntriesSize())
670inline bool CFaceList::IsFaceOneFlagSet(
unsigned int index,
unsigned int refflags)
const
672 if (index >= ptsIndex.GetEntriesSize())
676 return ((prop->flags &
refflags) != 0);
755 return dataChunks.GetData(
id, index);
760 return dataChunks.GetSizeOfDataChunk(
id);
771inline bool CFace::Copy(
unsigned int srcindex)
779 faces->
CopyFace(GetEntryIndex(), face,
true);
782inline void *CFace::GetDataChunk(
unsigned int id)
const
787inline SIZET CFace::GetSizeOfData(
unsigned int id)
const
793END_MOOTOOLS_NAMESPACE
@ CHECKSUM_FACES_EXTRA
faces material & flags (geometry and channel if CHECKSUM_CHANNELS set)
Definition 3DType.h:431
@ CHECKSUM_FACES
faces position (geometry and channel if CHECKSUM_CHANNELS set)
Definition 3DType.h:430
An advanced array class containing data that needs to be construct / destruct.
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
ConnectionInfoType
This enum allows to get a set of face indexes given two point indexes It is used by different methods...
Definition FaceList.h:37
@ CONNECTION_BY_FACES
Get point indexes of any faces which contain point index (CFaceList::GetPointsNeighbourg only)
Definition FaceList.h:49
@ CONNECTION_BY_POINTS
Get neighbourg faces of face index (CFaceList::GetFacesNeighbourg)
Definition FaceList.h:47
@ CONNECTION_PT1_MINUS_PT2
Faces shared by pt1 but not by pt2.
Definition FaceList.h:41
@ CONNECTION_EDGE2
Used by CFaceList::GetFacesByOppositeEdges.
Definition FaceList.h:45
@ CONNECTION_PT1_OR_PT2
The following are used by CFaceList::GetFacesConnectedToPoints.
Definition FaceList.h:39
@ CONNECTION_PT1_AND_PT2
Intersection of faces shared by pt1 and pt2.
Definition FaceList.h:40
@ CONNECTION_EDGE1
Used by CFaceList::GetFacesByOppositeEdges.
Definition FaceList.h:44
@ CONNECTION_EXCLUDE_EDGE12
Used by CFaceList::GetFacesByOppositeEdges.
Definition FaceList.h:46
@ CONNECTION_PT2_MINUS_PT1
Faces shared by pt2 but not by pt1.
Definition FaceList.h:42
@ CONNECTION_BY_EDGES
Get point indexes of any edges which contain point index (link by and edge) or get faces connected by...
Definition FaceList.h:48
@ CONNECTION_PT1_XOR_PT2
All faces shared by pt1 xor pt2.
Definition FaceList.h:43
@ CONNECTION_BY_FACES_EXCLUDING_EDGE
Get point indexes of any faces which contain point index minus the edges which contain point index (C...
Definition FaceList.h:50
FACELIST_PROPERTIES
some face list properties
Definition FaceList.h:24
@ FACELIST_HAS_CHANGED
Should be set each time something important changed, in order to update internal graphs.
Definition FaceList.h:29
C3DEdge is a class containing 2 point indexes that represent the edge of a face.
Definition FaceList.h:72
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition Collection.h:30
Definition DataChunk.h:29
CElementMethods is provided to CElementArray and give some information on the data as well as the met...
Definition ElementArray.h:22
This class allows to increase performance on repetitive calls to specific CFaceList methods.
Definition FaceList.h:94
void ReleaseArray(const int *connections)
To be call once do not need any more indexes returned by the method using the CFaceGraphHelper.
Definition FaceList.h:425
A CFace contains the information related to a given face in a CFaceList.
Definition Face.h:97
void Inherit(const CFace &srcface)
Inherit srcface chunks (and so flags and others properties), but don't copy the srcface indexes.
Definition FaceList.h:777
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
void FlipFaces(FACE_PROPERTIES properties=FACE_NONE, bool musthave=true)
Reverse the indexes order. For a 3D face, a side effect is the normal inversion.
void ReleaseFace(CFace *face) const
Release a face created with CFaceList::CreateFace.
Definition FaceList.h:554
bool HasPointToFaceGraph() const
Return true if the point to face graph is computed.
CEdgeGraph & GetEdgeGraph(void)
Get the CEdgeGraph.
bool CopyFace(unsigned int dstindex, unsigned int srcindex, bool inheritPropertiesOnly=false)
Copy srcindex face to dstindex face. inheritPropertiesOnly = true means only flags and properties are...
Definition FaceList.h:684
void SetSize(int size, int defaultFaceSize=FACELIST_DEFAULT_INDEX_NBR, SetSizeMode sizeMode=DEFAULT, int growFaceMode=-1)
Resize the size of the number of face. If growOnly, memory is not reallocated if buffer's size decrea...
virtual unsigned int GetChecksum(unsigned int checksumFlags=CHECKSUM_FACES|CHECKSUM_FACES_EXTRA) const
Return a value that is a simple way to check if the geometry changed between two call to the method.
bool Clean(const CGeomInfo *info)
Clean faces with FACE_IS_INVALID status defined.
int CollectIndexes(unsigned int index, CHashTable< int > &hash, bool erase=false) const
Add the face indexes to the hash, and return the adedd count.
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
void DeleteEdgeToFaceGraph()
Release the edge graph when no longer needed. Any call to InitEdgeToFaceGraph must be followed by a c...
SIZET GetSizeOfData(DataChunkID id) const
Return the data size of one element of the given data chunk.
Definition FaceList.h:758
SetSizeMode
Definition FaceList.h:186
void ExpandSizeAndFlags(const CFaceList &faces, unsigned int flags)
Increase face size and set flags for the new faces.
void DeleteEdgeArray()
A call to DeleteEdgeArray must be balanced for each call to InitEdgeArray.
const CDataChunk & GetDataChunks() const
Return the class that handles the data chunks.
Definition FaceList.h:731
void DeletePointToFaceGraph()
Release the point to face graph. Any call to InitPointToFaceGraph must be followed by a call to Delet...
bool UpdateIndex(CXUIntArray *newpointindex, bool onlyValidFaces=true)
Same method with a CXUIntArray class.
void AppendDataChunks(CFaceList *srcFaces, bool copyEmpty=true)
Copy the data chunks that exists in the provided srcFaces list. If copyEmpty = true,...
void SetSize(int size, SetSizeMode sizeMode, int defaultFaceSize=FACELIST_DEFAULT_INDEX_NBR)
Resize the size of the number of face. If growOnly, memory is not reallocated if buffer's size decrea...
int InitEdgeToFaceGraph(const CGeomInfo *info)
Init Edge graph which is a map containing each different edge and their connections....
void SaveFacesIndex(unsigned int dataChunkID=FACE_ORIGINAL_INDEX_CHUNK)
Save face indexes in a specific FACE_ORIGINAL_INDEX_CHUNK data chunk. Face index can be retrieve afte...
bool RemoveDataChunk(DataChunkID id)
Remove the data chunk specified by its id.
void SetSizeAndFlags(const CFaceList &faces, unsigned int flags)
Set faces which size are the same than provided faces list and set flags for these faces.
int IsFaceIndex(unsigned int faceindex, int pointindex) const
Check if point index belong to face. Return the index position of this pointindex or POINT_NOT_BELONG...
Definition FaceList.h:591
unsigned int TagFaces(CGeomInfo *info, CFaceTagger &faceTagger, bool exploreByEdge)
Create group of faces which points/edges are delimited by a given property.
int * SetFaceSize(unsigned int index, int size, FACE_PROPERTIES invalidFlag=FACE_IS_INVALID)
Set the number of indexes for the given face index. If size < 3, then invalidFlag flag is set,...
Definition FaceList.h:607
void SetSize(int size, unsigned int *initialSize, int defaultFaceSize=FACELIST_DEFAULT_INDEX_NBR, int growFaceMode=-1)
This reset the face and initialize it again.
const int * GetFacesConnectedToEdge(const C3DEdge &, int &size)
Get faces connected to an edge. The returned array has size indexes.
bool Clean(const CGeomInfo *info, bool cleanFaces, CXUIntArray *newfacesindex=NULL)
Clean faces with FACE_IS_INVALID status defined and get an array contains the new to old index positi...
bool ReorderFaces(const unsigned int *neworder, unsigned int size, bool moveToDestinationIndexes)
Reorder faces given the order specified by neworder. If moveToDestinationIndexes is true : Face[0] go...
void ExpandSize(const CFaceList &srcfaces)
Expand the face list with srcfaces sizes. No data is copied, only size are preallocated....
const C3DEdgeArray * InitEdgeArray()
Always return an array (even if empty) containing all edge of the face list, without connection infor...
void PreAllocate(int estimatedFaceNbr, int estimatedIndexNbr, bool constructAllElementsOnce=false)
Preallocate the data with an estimated face nbr and total indexes count for the whole face set....
unsigned int AddDataChunk(DataChunkID id, CElementMethods *methods)
Add a data chunk defined by an id and methods which give the way to construct / destroy the data chun...
unsigned int GetOriginalIndex(unsigned int index, unsigned int dataChunkID=FACE_ORIGINAL_INDEX_CHUNK) const
Retrieve the original index of the face.
Definition FaceList.h:736
void SetSize(const CFaceList &srcfaces, int growFaceMode=-1)
Reset face list and get faces size from srcfaces face list. No data is copied, only size are prealloc...
virtual CFace * CreateFace() const =0
Get a face object the appropriate derived face type (ie it will return a C3DFace, with C3DFaceList,...
int GetSize() const
Return the number of faces of the list.
Definition FaceList.h:549
void SetSizeAndFlags(int newsize, unsigned int flags)
Set face size and flags.
void * GetDataChunk(DataChunkID id, unsigned int index) const
Return the data chunk for index face. The returned data can be cast accordingly giving the data chunk...
Definition FaceList.h:753
unsigned int GetDataChunkNbr() const
Return the number of data chunk in the face list.
CFacePropertyData is the main data chunk of CFaceList which consists of storing the flags.
Definition Face.h:70
CFaceTagger is the base class that allows to gather face together using C3DFaceList::TagFaces.
Definition FaceList.h:119
virtual void EndProcess(unsigned int createdGroup)
Default implementation does nothing.
virtual bool InitProcess(CGeomInfo *info)
Default implementation return true.
virtual void BeginNewGroup(unsigned int groupnbr, unsigned int firstface)
BeginNewGroup is called when a new group is to be created.
virtual bool BelongToGroup(unsigned int face, C3DEdge &edge, int *faces, unsigned int size)
Called when exploreByEdge= true in C3DFaceList::TagFaces. faces is an array of size face indexes con...
virtual bool BelongToGroup(unsigned int face, unsigned int point, int *faces, unsigned int size)
Called when exploreByEdge= false. faces is an array of size face indexes connected to faces points....
virtual void ProcessGroup(const int *faces, unsigned int size)=0
ProcessGroup validates a group of face that belong to the same group.
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
Definition InstanciatedObject.h:16
Class for storing the original face index in CFaceList::SaveFacesIndex or CPointList::SavePointsIndex...
Definition 3DExtraData.h:28
CPointList is the base class for different classes (C3DPointList, CUVWPointList......
Definition PointList.h:50
Definition FaceList.h:388
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition XTemplate.h:34