Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
PointList.h
Go to the documentation of this file.
1//! @file PointList.h
2//! CPointList class is the base class for different point array (C3DPointList, CUVWPointList...)
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_POINTLIST_H__E9597160_87C0_11D3_A029_C00DB92E437A__INCLUDED_)
7#define AFX_POINTLIST_H__E9597160_87C0_11D3_A029_C00DB92E437A__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "DataChunk.h"
14#include "3DExtraData.h"
15#include "ElementArray.h"
16#include "Point.h"
17
18BEGIN_MOOTOOLS_NAMESPACE
19
20//! @def POINT_ORIGINAL_INDEX_CHUNK
21//! @brief Point data chunk custom ids
22#define POINT_ORIGINAL_INDEX_CHUNK MAKE_CUSTOM_ID('P', 'O', 'O', 'I')
23
24//! @enum POINTLIST_PROPERTIES
25//! @brief Flags used by CPointList
26typedef enum POINTLIST_PROPERTIES XEnumType(unsigned int)
27{
28 POINTLIST_NONE = 0x00,
29 POINTLIST_HAS_CHANGED = 0x01, //!< Should be set each time something important changed, in order to update internal graphs
31
32class CPointMethods : public CElementMethods
33{
34 virtual SIZET GetSizeof() const = 0;
35 virtual ElementType GetType() const = 0;
36 virtual void ConstructElement(void* pNewData) = 0;
37
38 virtual bool IsObject() const;
39 ElementType GetBaseType() const;
40 void CopyElement(void* pDest, const void* pSrc);
41 void SerializeElement(CXArchive& ar, void* pSrc);
42};
43
44//! @class CPointList
45//! @brief CPointList is the base class for different classes (C3DPointList, CUVWPointList...) that contains data such points, uvw, vectors...
46//! @details CPointList offers all methods to get/set the points, to modify them and associates any kind of data to points.
47//! CPointList includes different relationship graph to find easily who is connected with who.\n
48//! @note As CPointList inherits from CInstanciatedObject, it can be referenced multiple time. Use CPointList::Delete instead of delete to delete the list.
49class DLL_3DFUNCTION CPointList : protected CElementArray, public CInstanciatedObject
50{
51 DECLARE_DYNAMIC_XOBJECT(CPointList);
52
53public:
54 using CElementArray::GetThisRuntimeClassDescriptor;
55 using CElementArray::GetRuntimeClassDescriptor;
56 using CElementArray::GetSizeOfElement;
57 using CElementArray::IsKindOf;
58 using CElementArray::GetSize;
59 using CElementArray::SetAt;
60 using CElementArray::SetAtGrow;
61 using CElementArray::Add;
62
63 //! Creates a new point array. When srcPoints is provided, the data structure (datachunks) is inherited but the point list is created empty
65
66 int SetGrowFactor(int nGrowBy);
67 //! constructAllElements means that size elements are constructed (even if they are not used)\n
68 //! this can be used when maintaining a point list that have (0 to size) elements avoiding a repeated construction/destruction\n
69 void PreAllocate(int size, bool constructAllElementsOnce = false);
70 virtual void SetSize(int size, bool growOnly = false, int growSize = CElementArray::GROW_KEEP_MODE); //!< growOnly = false means that memory block is shrink down if specified size is below existing size. growSize defines the way memory size increases when resizing the point array.
71 virtual void RemoveAll();
72 void FreeExtra();
73
74 bool RemoveDataChunk(DataChunkID channel); //!< Remove the data chunk specified by its id
75 unsigned int AddDataChunk(DataChunkID dataid, CElementMethods *methods); //!< Add a data chunk defined by an id and methods which give the way to construct / destroy the data chunk data.
76 void *GetDataChunk(DataChunkID id, unsigned int index) const; //!< Return the data chunk for index point. The returned data can be cast accordingly giving the data chunk id.
77 void AppendDataChunks(CPointList *srcPoints, bool copyEmpty = true); //!< Copy the data chunks that exists in the provided srcPoints list. If copyEmpty = true, the data chunk are created empty. Otherwise they are copied from the source point list.
78 const CDataChunk& GetDataChunks() const; //!< Return the number of data chunk in the face list
79 unsigned int GetDataChunkNbr() const; //!< Return the class that handles the data chunks.
80 SIZET GetSizeOfData(DataChunkID id) const; //!< Return the data size of one element of the given data chunk.
81
82 // CPointAccess
83 const CPt *GetFirst() const;
84 const CPt *GetNext(const CPt *point) const;
85 CPt *GetFirst();
86 CPt *GetNext(CPt *pointList);
87 CPt *ElementAt(int i);
88 const CPt *ElementAt(int i) const;
89 CPt *operator[](int i);
90 const CPt *operator[](int i) const;
91
92 // operator CXObject*() { return (CXObject *)this; };
93
94 bool CopyPoint(int dstindex, int srcindex);
95 bool CopyPoint(int dstindex, int srcindex, const CPointList& srcpointlist);
96
97 // Clean functions
98 bool Clean(CFaceList *faces, CXUIntArray *newpointindex = NULL);
99 bool Reorder(const unsigned int *reforder, unsigned int size, bool moveToDestinationIndexes);
100
101 // Flags init functions
102 void SetFlag(POINTLIST_PROPERTIES flag, bool set);
103 bool IsFlagSet(POINTLIST_PROPERTIES flag) const;
104 unsigned int GetChangedStamp() const; //!< Return a value that can be used to know if the list changed (value changed each time POINTLIST_HAS_CHANGED set)
105
106 unsigned int GetPointFlags(unsigned int index) const;
107 bool IsPointFlagSet(unsigned int index, POINT_PROPERTIES flag) const;
108 bool CheckPointFlags(unsigned int index, unsigned int checkflags, bool allSetOrNoneSet) const;
109 void SetPointFlag(unsigned int index, POINT_PROPERTIES flag, bool set);
110 void SetPointFlags(unsigned int index, unsigned int refflags, bool set);
111 bool IsPointOneFlagSet(unsigned int index, unsigned int refflags) const;
112
113 void SetPointsFlags(unsigned int flags, bool set);
114 void SetBorderPointsStatus(CEdgeGraph& edgeGraph, bool initPC2BP = false); // set initPC2BP to true to init POINT_CONNECTED_TO_POINT_AT_BORDER (requires a little overtime)
115 void Set3DCornerPointsStatus(CFaceList *faces, double radianAngle);
116 void SetInvalidPoints(CFaceList& facelist, bool keepExistingInvalidPoints);
117 void SavePointsIndex();
118 unsigned int GetOriginalIndex(unsigned int index) const;
119
120 // List informations functions
121 int GetNumberOfPoints(POINT_PROPERTIES, bool set);
122 int GetNumberOfPoints(unsigned int properties, bool set);
123
124 virtual unsigned int GetChecksum(unsigned int checksumFlags = CHECKSUM_POINTS | CHECKSUM_POINTS_EXTRA) const; //!< Return a value that is a simple way to check if the geometry changed between two call to the method
125
126 // virtual function
127 virtual void Inherit(const CPointList& refpoints);
128 virtual void Serialize(CXArchive& ar);
129
130 // pure virtual function
131 virtual CPointList& operator=(const CPointList& refpoints);
132
133#ifdef _DEBUG
134 void Dump() const;
135 unsigned int MemoryStats() const;
136 virtual CXString GetPointListType() const = 0;
137#endif
138
139private:
140 CDataChunk dataChunks;
141
142protected:
143 unsigned int changeStamp;
144 unsigned int flags;
145
146 virtual ~CPointList(); //!< Use Delete instead
147 virtual bool UpdateList();
148
149};
150
151///////////////////////////////////////////////////////////////////////////////////
152// CPointMethods
153// Inline implementation
154inline bool CPointMethods::IsObject() const
155{
156 return true;
157}
158
159inline ElementType CPointMethods::GetBaseType() const
160{
161 return MAKE_CUSTOM_ID('P', 'N', 'T', 'S');
162}
163
164inline void CPointMethods::CopyElement(void* pDest, const void* pSrc)
165{
166 *((CPt *)pDest) = *((const CPt *)pSrc);
167}
168
169inline void CPointMethods::SerializeElement(CXArchive& ar, void* pSrc)
170{
171 ((CPt *)pSrc)->Serialize(ar);
172}
173
174///////////////////////////////////////////////////////////////////////////////////
175// CPointList
176// Inline implementation
177inline const CPt *CPointList::GetFirst() const
178{
179 return (const CPt *)CElementArray::GetFirst();
180}
181
182inline const CPt *CPointList::GetNext(const CPt *pointList) const
183{
184 return (const CPt *)CElementArray::GetNext(pointList);
185}
186
187inline CPt *CPointList::GetFirst()
188{
189 return (CPt *)CElementArray::GetFirst();
190}
191
192inline CPt *CPointList::GetNext(CPt *pointList)
193{
194 return (CPt *)CElementArray::GetNext(pointList);
195}
196
197inline CPt *CPointList::ElementAt(int i)
198{
199 return ((CPt *)CElementArray::ElementAt(i));
200}
201
202inline const CPt *CPointList::ElementAt(int i) const
203{
204 return ((const CPt *)CElementArray::ElementAt(i));
205}
206
207inline CPt *CPointList::operator[](int i)
208{
209 return ((CPt *)CElementArray::operator[](i));
210}
211
212inline const CPt *CPointList::operator[](int i) const
213{
214 return ((const CPt *)CElementArray::ElementAt(i));
215}
216
217inline unsigned int CPointList::GetOriginalIndex(unsigned int index) const
218{
219 COriginalIndexData *data = (COriginalIndexData *)dataChunks.GetData(POINT_ORIGINAL_INDEX_CHUNK, index);
220 if (data)
221 return data->index;
222
223 return -1;
224}
225
226inline void *CPointList::GetDataChunk(unsigned id, unsigned int index) const
227{
228 return dataChunks.GetData(id, index);
229}
230
231inline SIZET CPointList::GetSizeOfData(unsigned id) const
232{
233 return dataChunks.GetSizeOfDataChunk(id);
234}
235
236END_MOOTOOLS_NAMESPACE
237
238#endif // !defined(AFX_POINTLIST_H__E9597160_87C0_11D3_A029_C00DB92E437A__INCLUDED_)
This file contains implementation of different extra data information that can be attached through CP...
@ CHECKSUM_POINTS
Point position is taken into account (geometry and channel if CHECKSUM_CHANNELS set)
Definition 3DType.h:428
@ CHECKSUM_POINTS_EXTRA
Point flags (geometry and channel if CHECKSUM_CHANNELS set)
Definition 3DType.h:429
An advanced array class containing data that needs to be construct / destruct.
CPt class is the base class for different class of points (C3DPoint, CUVWPoint...)
POINT_PROPERTIES
Point flags used by any classes that inherit from CPt (C3DPoint, C3DVector...)
Definition Point.h:19
POINTLIST_PROPERTIES
Flags used by CPointList.
Definition PointList.h:27
@ POINTLIST_HAS_CHANGED
Should be set each time something important changed, in order to update internal graphs.
Definition PointList.h:29
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition DataChunk.h:29
An advanced array class containing data that needs to be construct / destruct.
Definition ElementArray.h:69
@ GROW_KEEP_MODE
Keep the default grow size (SetAtGrow, SetSize)
Definition ElementArray.h:76
CElementMethods is provided to CElementArray and give some information on the data as well as the met...
Definition ElementArray.h:22
virtual bool IsObject() const
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
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
unsigned int GetDataChunkNbr() const
Return the class that handles the data chunks.
void * GetDataChunk(DataChunkID id, unsigned int index) const
Return the data chunk for index point. The returned data can be cast accordingly giving the data chun...
Definition PointList.h:226
SIZET GetSizeOfData(DataChunkID id) const
Return the data size of one element of the given data chunk.
Definition PointList.h:231
virtual unsigned int GetChecksum(unsigned int checksumFlags=CHECKSUM_POINTS|CHECKSUM_POINTS_EXTRA) const
Return a value that is a simple way to check if the geometry changed between two call to the method.
virtual void SetSize(int size, bool growOnly=false, int growSize=CElementArray::GROW_KEEP_MODE)
growOnly = false means that memory block is shrink down if specified size is below existing size....
void PreAllocate(int size, bool constructAllElementsOnce=false)
bool RemoveDataChunk(DataChunkID channel)
Remove the data chunk specified by its id.
CPointList(CPointList *srcPoints)
Creates a new point array. When srcPoints is provided, the data structure (datachunks) is inherited b...
unsigned int GetChangedStamp() const
Return a value that can be used to know if the list changed (value changed each time POINTLIST_HAS_CH...
unsigned int AddDataChunk(DataChunkID dataid, CElementMethods *methods)
Add a data chunk defined by an id and methods which give the way to construct / destroy the data chun...
void AppendDataChunks(CPointList *srcPoints, bool copyEmpty=true)
Copy the data chunks that exists in the provided srcPoints list. If copyEmpty = true,...
const CDataChunk & GetDataChunks() const
Return the number of data chunk in the face list.
CPt base only contains some flags that are used by the derived class.
Definition Point.h:60
Definition XArchive.h:17
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition XTemplate.h:34