22 #ifndef __dgPolyhedra__ 23 #define __dgPolyhedra__ 41 typedef dgInt64 dgEdgeKey;
60 DG_MSC_VECTOR_ALIGMENT
64 dgEdge(dgInt32 vertex, dgInt32 face, dgUnsigned64 userdata = 0);
66 dgInt32 m_incidentVertex;
67 dgInt32 m_incidentFace;
68 dgUnsigned64 m_userData;
73 } DG_GCC_VECTOR_ALIGMENT;
83 dgInt64 GetVal()
const;
84 dgInt32 GetLowKey()
const;
85 dgInt32 GetHighKey()
const;
96 dgEdge *AddFace(dgInt32 v0, dgInt32 v1, dgInt32 v2);
97 dgEdge *AddFace(dgInt32 count,
const dgInt32 *
const index);
98 dgEdge *AddFace(dgInt32 count,
const dgInt32 *
const index,
const dgInt64 *
const userdata);
100 void DeleteFace(
dgEdge *
const edge);
102 dgInt32 GetFaceCount()
const;
103 dgInt32 GetEdgeCount()
const;
104 dgInt32 GetLastVertexIndex()
const;
106 dgInt32 IncLRU()
const;
107 void SetLRU(dgInt32 lru)
const;
109 dgEdge *FindEdge(dgInt32 v0, dgInt32 v1)
const;
110 dgTreeNode *FindEdgeNode(dgInt32 v0, dgInt32 v1)
const;
112 dgEdge *AddHalfEdge(dgInt32 v0, dgInt32 v1);
113 void DeleteEdge(
dgEdge *
const edge);
114 void DeleteEdge(dgInt32 v0, dgInt32 v1);
116 bool FlipEdge(
dgEdge *
const edge);
117 dgEdge *SpliteEdge(dgInt32 newIndex,
dgEdge *
const edge);
118 dgBigVector FaceNormal(
dgEdge *
const face,
const dgFloat64 *
const vertex, dgInt32 strideInBytes)
const;
120 void BeginConectedSurface()
const;
121 bool GetConectedSurface(
dgPolyhedra &polyhedra)
const;
122 void EndConectedSurface()
const;
124 dgSphere CalculateSphere(
const dgFloat64 *
const vertex, dgInt32 strideInBytes,
const dgMatrix *
const basis = NULL)
const;
125 void ChangeEdgeIncidentVertex(
dgEdge *
const edge, dgInt32 newIndex);
126 void DeleteDegenerateFaces(
const dgFloat64 *
const pool, dgInt32 dstStrideInBytes, dgFloat64 minArea);
128 void Optimize(
const dgFloat64 *
const pool, dgInt32 strideInBytes, dgFloat64 tol);
129 void Triangulate(
const dgFloat64 *
const vertex, dgInt32 strideInBytes,
dgPolyhedra *
const leftOversOut);
130 void ConvexPartition(
const dgFloat64 *
const vertex, dgInt32 strideInBytes,
dgPolyhedra *
const leftOversOut);
204 void RefineTriangulation(
const dgFloat64 *
const vertex, dgInt32 stride);
205 void RefineTriangulation(
const dgFloat64 *
const vertex, dgInt32 stride,
dgBigVector *
const normal, dgInt32 perimeterCount,
dgEdge **
const perimeter);
206 void OptimizeTriangulation(
const dgFloat64 *
const vertex, dgInt32 strideInBytes);
207 void MarkAdjacentCoplanarFaces(
dgPolyhedra &polyhedraOut,
dgEdge *
const face,
const dgFloat64 *
const pool, dgInt32 strideInBytes);
213 mutable dgInt32 m_baseMark;
214 mutable dgInt32 m_edgeMark;
215 mutable dgInt32 m_faceSecuence;
217 friend class dgPolyhedraDescriptor;
223 inline dgEdge::dgEdge() {
226 inline dgEdge::dgEdge(dgInt32 vertex, dgInt32 face, dgUnsigned64 userdata)
227 : m_incidentVertex(vertex)
228 , m_incidentFace(face)
229 , m_userData(userdata)
237 inline dgPolyhedra::dgPairKey::dgPairKey() {
240 inline dgPolyhedra::dgPairKey::dgPairKey(dgInt64 val)
241 : m_key(dgUnsigned64(val)) {
244 inline dgPolyhedra::dgPairKey::dgPairKey(dgInt32 v0, dgInt32 v1)
245 : m_key(dgUnsigned64((dgInt64(v0) << 32) | v1)) {
248 inline dgInt64 dgPolyhedra::dgPairKey::GetVal()
const {
249 return dgInt64(m_key);
252 inline dgInt32 dgPolyhedra::dgPairKey::GetLowKey()
const {
253 return dgInt32(m_key >> 32);
256 inline dgInt32 dgPolyhedra::dgPairKey::GetHighKey()
const {
257 return dgInt32(m_key & 0xffffffff);
260 inline void dgPolyhedra::BeginFace() {
263 inline dgEdge *dgPolyhedra::AddFace(dgInt32 count,
const dgInt32 *
const index) {
264 return AddFace(count, index, NULL);
267 inline dgEdge *dgPolyhedra::AddFace(dgInt32 v0, dgInt32 v1, dgInt32 v2) {
273 return AddFace(3, vertex, NULL);
276 inline dgInt32 dgPolyhedra::GetEdgeCount()
const {
278 dgInt32 edgeCount = 0;
279 Iterator iter(*
this);
280 for (iter.Begin(); iter; iter ++) {
283 NEWTON_ASSERT(edgeCount == GetCount());;
288 inline dgInt32 dgPolyhedra::GetLastVertexIndex()
const {
289 dgInt32 maxVertexIndex = -1;
290 Iterator iter(*
this);
291 for (iter.Begin(); iter; iter ++) {
292 const dgEdge *
const edge = &(*iter);
293 if (edge->m_incidentVertex > maxVertexIndex) {
294 maxVertexIndex = edge->m_incidentVertex;
297 return maxVertexIndex + 1;
301 inline dgInt32 dgPolyhedra::IncLRU()
const {
303 NEWTON_ASSERT(m_edgeMark < 0x7fffffff);
307 inline void dgPolyhedra::SetLRU(dgInt32 lru)
const {
308 if (lru > m_edgeMark) {
313 inline void dgPolyhedra::BeginConectedSurface()
const {
314 m_baseMark = IncLRU();
317 inline void dgPolyhedra::EndConectedSurface()
const {
321 inline dgPolyhedra::dgTreeNode *dgPolyhedra::FindEdgeNode(dgInt32 i0, dgInt32 i1)
const {
323 return Find(key.GetVal());
327 inline dgEdge *dgPolyhedra::FindEdge(dgInt32 i0, dgInt32 i1)
const {
332 dgTreeNode *
const node = FindEdgeNode(i0, i1);
333 return node ? &node->GetInfo() : NULL;
336 inline void dgPolyhedra::DeleteEdge(dgInt32 v0, dgInt32 v1) {
338 dgTreeNode *
const node = Find(pairKey.GetVal());
339 dgEdge *
const edge = node ? &node->GetInfo() : NULL;
Definition: dgPolyhedra.h:61
Definition: dgSphere.h:37
Definition: dgPolyhedra.h:76
Definition: dgPolyhedra.h:79
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgVector.h:104