concavity.cpp
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <assert.h>
5 
62 #include <vector>
63 
64 #include "concavity.h"
65 #include "raytri.h"
66 #include "bestfit.h"
67 #include "cd_hull.h"
68 #include "meshvolume.h"
69 #include "cd_vector.h"
70 #include "splitplane.h"
71 #include "ConvexDecomposition.h"
72 
73 
74 #define WSCALE 4
75 #define CONCAVE_THRESH 0.05f
76 
77 namespace ConvexDecomposition
78 {
79 
80 unsigned int getDebugColor(void)
81 {
82  static unsigned int colors[8] =
83  {
84  0xFF0000,
85  0x00FF00,
86  0x0000FF,
87  0xFFFF00,
88  0x00FFFF,
89  0xFF00FF,
90  0xFFFFFF,
91  0xFF8040
92  };
93 
94  static int count = 0;
95 
96  count++;
97 
98  if ( count == 8 ) count = 0;
99 
100  assert( count >= 0 && count < 8 );
101 
102  unsigned int color = colors[count];
103 
104  return color;
105 
106 }
107 
108 class Wpoint
109 {
110 public:
111  Wpoint(const Vector3d<double> &p,double w)
112  {
113  mPoint = p;
114  mWeight = w;
115  }
116 
118  double mWeight;
119 };
120 
121 typedef std::vector< Wpoint > WpointVector;
122 
123 
124 static inline double DistToPt(const double *p,const double *plane)
125 {
126  double x = p[0];
127  double y = p[1];
128  double z = p[2];
129  double d = x*plane[0] + y*plane[1] + z*plane[2] + plane[3];
130  return d;
131 }
132 
133 
134 static void intersect(const double *p1,const double *p2,double *split,const double *plane)
135 {
136 
137  double dp1 = DistToPt(p1,plane);
138  double dp2 = DistToPt(p2,plane);
139 
140  double dir[3];
141 
142  dir[0] = p2[0] - p1[0];
143  dir[1] = p2[1] - p1[1];
144  dir[2] = p2[2] - p1[2];
145 
146  double dot1 = dir[0]*plane[0] + dir[1]*plane[1] + dir[2]*plane[2];
147  double dot2 = dp1 - plane[3];
148 
149  double t = -(plane[3] + dot2 ) / dot1;
150 
151  split[0] = (dir[0]*t)+p1[0];
152  split[1] = (dir[1]*t)+p1[1];
153  split[2] = (dir[2]*t)+p1[2];
154 
155 }
156 
157 
158 class CTri
159 {
160 public:
161  CTri(void) { };
162 
163  CTri(const double *p1,const double *p2,const double *p3,unsigned int i1,unsigned int i2,unsigned int i3)
164  {
165  mProcessed = 0;
166  mI1 = i1;
167  mI2 = i2;
168  mI3 = i3;
169 
170  mP1.Set(p1);
171  mP2.Set(p2);
172  mP3.Set(p3);
173 
175  }
176 
177  double Facing(const CTri &t)
178  {
179  double d = mNormal.Dot(t.mNormal);
180  return d;
181  }
182 
183  // clip this line segment against this triangle.
184  bool clip(const Vector3d<double> &start,Vector3d<double> &end) const
185  {
186  Vector3d<double> sect;
187 
188  bool hit = lineIntersectsTriangle(start.Ptr(), end.Ptr(), mP1.Ptr(), mP2.Ptr(), mP3.Ptr(), sect.Ptr() );
189 
190  if ( hit )
191  {
192  end = sect;
193  }
194  return hit;
195  }
196 
197  bool Concave(const Vector3d<double> &p,double &distance,Vector3d<double> &n) const
198  {
200  distance = p.Distance(n);
201  return true;
202  }
203 
204  void addTri(unsigned int *indices,unsigned int i1,unsigned int i2,unsigned int i3,unsigned int &tcount) const
205  {
206  indices[tcount*3+0] = i1;
207  indices[tcount*3+1] = i2;
208  indices[tcount*3+2] = i3;
209  tcount++;
210  }
211 
212  double getVolume(ConvexDecompInterface *callback) const
213  {
214  unsigned int indices[8*3];
215 
216 
217  unsigned int tcount = 0;
218 
219  addTri(indices,0,1,2,tcount);
220  addTri(indices,3,4,5,tcount);
221 
222  addTri(indices,0,3,4,tcount);
223  addTri(indices,0,4,1,tcount);
224 
225  addTri(indices,1,4,5,tcount);
226  addTri(indices,1,5,2,tcount);
227 
228  addTri(indices,0,3,5,tcount);
229  addTri(indices,0,5,2,tcount);
230 
231  const double *vertices = mP1.Ptr();
232 
233  if ( callback )
234  {
235  unsigned int color = getDebugColor();
236 
237 #if 0
241 
242  callback->ConvexDebugPoint(mP1.Ptr(),0.01f,0x00FF00);
243  callback->ConvexDebugPoint(mP2.Ptr(),0.01f,0x00FF00);
244  callback->ConvexDebugPoint(mP3.Ptr(),0.01f,0x00FF00);
245  callback->ConvexDebugPoint(d1.Ptr(),0.01f,0xFF0000);
246  callback->ConvexDebugPoint(d2.Ptr(),0.01f,0xFF0000);
247  callback->ConvexDebugPoint(d3.Ptr(),0.01f,0xFF0000);
248 
249  callback->ConvexDebugTri(mP1.Ptr(), d1.Ptr(), d1.Ptr(),0x00FF00);
250  callback->ConvexDebugTri(mP2.Ptr(), d2.Ptr(), d2.Ptr(),0x00FF00);
251  callback->ConvexDebugTri(mP3.Ptr(), d3.Ptr(), d3.Ptr(),0x00FF00);
252 
253 #else
254  for (unsigned int i=0; i<tcount; i++)
255  {
256  unsigned int i1 = indices[i*3+0];
257  unsigned int i2 = indices[i*3+1];
258  unsigned int i3 = indices[i*3+2];
259 
260  const double *p1 = &vertices[ i1*3 ];
261  const double *p2 = &vertices[ i2*3 ];
262  const double *p3 = &vertices[ i3*3 ];
263 
264  callback->ConvexDebugTri(p1,p2,p3,color);
265 
266  }
267 #endif
268  }
269 
270  double v = computeMeshVolume(mP1.Ptr(), tcount, indices );
271 
272  return v;
273 
274  }
275 
276  double raySect(const Vector3d<double> &p,const Vector3d<double> &dir,Vector3d<double> &sect) const
277  {
278  double plane[4];
279 
280  plane[0] = mNormal.x;
281  plane[1] = mNormal.y;
282  plane[2] = mNormal.z;
283  plane[3] = mPlaneD;
284 
285  Vector3d<double> dest = p+dir*100000;
286 
287  intersect( p.Ptr(), dest.Ptr(), sect.Ptr(), plane );
288 
289  return sect.Distance(p); // return the intersection distance.
290 
291  }
292 
293  double planeDistance(const Vector3d<double> &p) const
294  {
295  double plane[4];
296 
297  plane[0] = mNormal.x;
298  plane[1] = mNormal.y;
299  plane[2] = mNormal.z;
300  plane[3] = mPlaneD;
301 
302  return DistToPt( p.Ptr(), plane );
303 
304  }
305 
306  bool samePlane(const CTri &t) const
307  {
308  const double THRESH = 0.001f;
309  double dd = fabs( t.mPlaneD - mPlaneD );
310  if ( dd > THRESH ) return false;
311  dd = fabs( t.mNormal.x - mNormal.x );
312  if ( dd > THRESH ) return false;
313  dd = fabs( t.mNormal.y - mNormal.y );
314  if ( dd > THRESH ) return false;
315  dd = fabs( t.mNormal.z - mNormal.z );
316  if ( dd > THRESH ) return false;
317  return true;
318  }
319 
320  bool hasIndex(unsigned int i) const
321  {
322  if ( i == mI1 || i == mI2 || i == mI3 ) return true;
323  return false;
324  }
325 
326  bool sharesEdge(const CTri &t) const
327  {
328  bool ret = false;
329  unsigned int count = 0;
330 
331  if ( t.hasIndex(mI1) ) count++;
332  if ( t.hasIndex(mI2) ) count++;
333  if ( t.hasIndex(mI3) ) count++;
334 
335  if ( count >= 2 ) ret = true;
336 
337  return ret;
338  }
339 
340  void debug(unsigned int color,ConvexDecompInterface *callback)
341  {
342  callback->ConvexDebugTri( mP1.Ptr(), mP2.Ptr(), mP3.Ptr(), color );
343  callback->ConvexDebugTri( mP1.Ptr(), mP1.Ptr(), mNear1.Ptr(), 0xFF0000 );
344  callback->ConvexDebugTri( mP2.Ptr(), mP2.Ptr(), mNear2.Ptr(), 0xFF0000 );
345  callback->ConvexDebugTri( mP2.Ptr(), mP3.Ptr(), mNear3.Ptr(), 0xFF0000 );
346  callback->ConvexDebugPoint( mNear1.Ptr(), 0.01f, 0xFF0000 );
347  callback->ConvexDebugPoint( mNear2.Ptr(), 0.01f, 0xFF0000 );
348  callback->ConvexDebugPoint( mNear3.Ptr(), 0.01f, 0xFF0000 );
349  }
350 
351  double area(void)
352  {
353  double a = mConcavity*mP1.Area(mP2,mP3);
354  return a;
355  }
356 
358  {
359 
360  Wpoint p1(mP1,mC1);
361  Wpoint p2(mP2,mC2);
362  Wpoint p3(mP3,mC3);
363 
364  Vector3d<double> d1 = mNear1 - mP1;
365  Vector3d<double> d2 = mNear2 - mP2;
366  Vector3d<double> d3 = mNear3 - mP3;
367 
368  d1*=WSCALE;
369  d2*=WSCALE;
370  d3*=WSCALE;
371 
372  d1 = d1 + mP1;
373  d2 = d2 + mP2;
374  d3 = d3 + mP3;
375 
376  Wpoint p4(d1,mC1);
377  Wpoint p5(d2,mC2);
378  Wpoint p6(d3,mC3);
379 
380  list.push_back(p1);
381  list.push_back(p2);
382  list.push_back(p3);
383 
384  list.push_back(p4);
385  list.push_back(p5);
386  list.push_back(p6);
387 
388 #if 0
389  callback->ConvexDebugPoint(mP1.Ptr(),0.01f,0x00FF00);
390  callback->ConvexDebugPoint(mP2.Ptr(),0.01f,0x00FF00);
391  callback->ConvexDebugPoint(mP3.Ptr(),0.01f,0x00FF00);
392  callback->ConvexDebugPoint(d1.Ptr(),0.01f,0xFF0000);
393  callback->ConvexDebugPoint(d2.Ptr(),0.01f,0xFF0000);
394  callback->ConvexDebugPoint(d3.Ptr(),0.01f,0xFF0000);
395 
396  callback->ConvexDebugTri(mP1.Ptr(), d1.Ptr(), d1.Ptr(),0x00FF00);
397  callback->ConvexDebugTri(mP2.Ptr(), d2.Ptr(), d2.Ptr(),0x00FF00);
398  callback->ConvexDebugTri(mP3.Ptr(), d3.Ptr(), d3.Ptr(),0x00FF00);
399 
400  Vector3d<double> np1 = mP1 + mNormal*0.05f;
401  Vector3d<double> np2 = mP2 + mNormal*0.05f;
402  Vector3d<double> np3 = mP3 + mNormal*0.05f;
403 
404  callback->ConvexDebugTri(mP1.Ptr(), np1.Ptr(), np1.Ptr(), 0xFF00FF );
405  callback->ConvexDebugTri(mP2.Ptr(), np2.Ptr(), np2.Ptr(), 0xFF00FF );
406  callback->ConvexDebugTri(mP3.Ptr(), np3.Ptr(), np3.Ptr(), 0xFF00FF );
407 
408  callback->ConvexDebugPoint( np1.Ptr(), 0.01F, 0XFF00FF );
409  callback->ConvexDebugPoint( np2.Ptr(), 0.01F, 0XFF00FF );
410  callback->ConvexDebugPoint( np3.Ptr(), 0.01F, 0XFF00FF );
411 
412 #endif
413 
414 
415 
416  }
417 
425  double mPlaneD;
426  double mConcavity;
427  double mC1;
428  double mC2;
429  double mC3;
430  unsigned int mI1;
431  unsigned int mI2;
432  unsigned int mI3;
433  int mProcessed; // already been added...
434 };
435 
436 typedef std::vector< CTri > CTriVector;
437 
438 bool featureMatch(CTri &m,const CTriVector &tris,ConvexDecompInterface *callback,const CTriVector &input_mesh)
439 {
440 
441  bool ret = false;
442 
443  double neardot = 0.707f;
444 
445  m.mConcavity = 0;
446 
447  //gLog->Display("*********** FEATURE MATCH *************\r\n");
448  //gLog->Display("Plane: %0.4f,%0.4f,%0.4f %0.4f\r\n", m.mNormal.x, m.mNormal.y, m.mNormal.z, m.mPlaneD );
449  //gLog->Display("*********************************************\r\n");
450 
451  CTriVector::const_iterator i;
452 
453  CTri nearest;
454 
455  double near[3] = { 1e9, 1e9, 1e9 };
456 
457  for (i=tris.begin(); i!=tris.end(); ++i)
458  {
459  const CTri &t = (*i);
460 
461 
462  //gLog->Display(" HullPlane: %0.4f,%0.4f,%0.4f %0.4f\r\n", t.mNormal.x, t.mNormal.y, t.mNormal.z, t.mPlaneD );
463 
464  if ( t.samePlane(m) )
465  {
466  //gLog->Display("*** PLANE MATCH!!!\r\n");
467  ret = false;
468  break;
469  }
470 
471  double dot = t.mNormal.Dot(m.mNormal);
472 
473  if ( dot > neardot )
474  {
475 
476  double d1 = t.planeDistance( m.mP1 );
477  double d2 = t.planeDistance( m.mP2 );
478  double d3 = t.planeDistance( m.mP3 );
479 
480  if ( d1 > 0.001f || d2 > 0.001f || d3 > 0.001f ) // can't be near coplaner!
481  {
482 
483  neardot = dot;
484 
485  Vector3d<double> n1,n2,n3;
486 
487  t.raySect( m.mP1, m.mNormal, m.mNear1 );
488  t.raySect( m.mP2, m.mNormal, m.mNear2 );
489  t.raySect( m.mP3, m.mNormal, m.mNear3 );
490 
491  nearest = t;
492 
493  ret = true;
494  }
495 
496  }
497  }
498 
499  if ( ret )
500  {
501  if ( 0 )
502  {
503  CTriVector::const_iterator i;
504  for (i=input_mesh.begin(); i!=input_mesh.end(); ++i)
505  {
506  const CTri &c = (*i);
507  if ( c.mI1 != m.mI1 && c.mI2 != m.mI2 && c.mI3 != m.mI3 )
508  {
509  c.clip( m.mP1, m.mNear1 );
510  c.clip( m.mP2, m.mNear2 );
511  c.clip( m.mP3, m.mNear3 );
512  }
513  }
514  }
515 
516  //gLog->Display("*********************************************\r\n");
517  //gLog->Display(" HullPlaneNearest: %0.4f,%0.4f,%0.4f %0.4f\r\n", nearest.mNormal.x, nearest.mNormal.y, nearest.mNormal.z, nearest.mPlaneD );
518 
519  m.mC1 = m.mP1.Distance( m.mNear1 );
520  m.mC2 = m.mP2.Distance( m.mNear2 );
521  m.mC3 = m.mP3.Distance( m.mNear3 );
522 
523  m.mConcavity = m.mC1;
524 
525  if ( m.mC2 > m.mConcavity ) m.mConcavity = m.mC2;
526  if ( m.mC3 > m.mConcavity ) m.mConcavity = m.mC3;
527 
528  #if 0
529  callback->ConvexDebugTri( m.mP1.Ptr(), m.mP2.Ptr(), m.mP3.Ptr(), 0x00FF00 );
530  callback->ConvexDebugTri( m.mNear1.Ptr(), m.mNear2.Ptr(), m.mNear3.Ptr(), 0xFF0000 );
531 
532  callback->ConvexDebugTri( m.mP1.Ptr(), m.mP1.Ptr(), m.mNear1.Ptr(), 0xFFFF00 );
533  callback->ConvexDebugTri( m.mP2.Ptr(), m.mP2.Ptr(), m.mNear2.Ptr(), 0xFFFF00 );
534  callback->ConvexDebugTri( m.mP3.Ptr(), m.mP3.Ptr(), m.mNear3.Ptr(), 0xFFFF00 );
535  #endif
536 
537  }
538  else
539  {
540  //gLog->Display("No match\r\n");
541  }
542 
543  //gLog->Display("*********************************************\r\n");
544  return ret;
545 }
546 
547 bool isFeatureTri(CTri &t,CTriVector &flist,double fc,ConvexDecompInterface *callback,unsigned int color)
548 {
549  bool ret = false;
550 
551  if ( t.mProcessed == 0 ) // if not already processed
552  {
553 
554  double c = t.mConcavity / fc; // must be within 80% of the concavity of the parent.
555 
556  if ( c > 0.85f )
557  {
558  // see if this triangle is a 'feature' triangle. Meaning it shares an
559  // edge with any existing feature triangle and is within roughly the same
560  // concavity of the parent.
561  if ( flist.size() )
562  {
563  CTriVector::iterator i;
564  for (i=flist.begin(); i!=flist.end(); ++i)
565  {
566  CTri &ftri = (*i);
567  if ( ftri.sharesEdge(t) )
568  {
569  t.mProcessed = 2; // it is now part of a feature.
570  flist.push_back(t); // add it to the feature list.
571 // callback->ConvexDebugTri( t.mP1.Ptr(), t.mP2.Ptr(),t.mP3.Ptr(), color );
572  ret = true;
573  break;
574  }
575  }
576  }
577  else
578  {
579  t.mProcessed = 2;
580  flist.push_back(t); // add it to the feature list.
581 // callback->ConvexDebugTri( t.mP1.Ptr(), t.mP2.Ptr(),t.mP3.Ptr(), color );
582  ret = true;
583  }
584  }
585  else
586  {
587  t.mProcessed = 1; // eliminated for this feature, but might be valid for the next one..
588  }
589 
590  }
591  return ret;
592 }
593 
594 double computeConcavity(unsigned int vcount,
595  const double *vertices,
596  unsigned int tcount,
597  const unsigned int *indices,
598  ConvexDecompInterface *callback,
599  double *plane, // plane equation to split on
600  double &volume)
601 {
602 
603 
604  double cret = 0;
605  volume = 1;
606 
607  HullResult result;
608  HullLibrary hl;
609  HullDesc desc;
610 
611  desc.mMaxVertices = 256;
613 
614 
615  desc.mVcount = vcount;
616  desc.mVertices = vertices;
617  desc.mVertexStride = sizeof(double)*3;
618 
619  HullError ret = hl.CreateConvexHull(desc,result);
620 
621  if ( ret == QE_OK )
622  {
623 
624  double bmin[3];
625  double bmax[3];
626 
627  double diagonal = getBoundingRegion( result.mNumOutputVertices, result.mOutputVertices, sizeof(double)*3, bmin, bmax );
628 
629  double dx = bmax[0] - bmin[0];
630  double dy = bmax[1] - bmin[1];
631  double dz = bmax[2] - bmin[2];
632 
633  Vector3d<double> center;
634 
635  center.x = bmin[0] + dx*0.5f;
636  center.y = bmin[1] + dy*0.5f;
637  center.z = bmin[2] + dz*0.5f;
638 
639  double boundVolume = dx*dy*dz;
640 
641  volume = computeMeshVolume2( result.mOutputVertices, result.mNumFaces, result.mIndices );
642 
643 #if 1
644  // ok..now..for each triangle on the original mesh..
645  // we extrude the points to the nearest point on the hull.
646  const unsigned int *source = result.mIndices;
647 
649 
650  for (unsigned int i=0; i<result.mNumFaces; i++)
651  {
652  unsigned int i1 = *source++;
653  unsigned int i2 = *source++;
654  unsigned int i3 = *source++;
655 
656  const double *p1 = &result.mOutputVertices[i1*3];
657  const double *p2 = &result.mOutputVertices[i2*3];
658  const double *p3 = &result.mOutputVertices[i3*3];
659 
660 // callback->ConvexDebugTri(p1,p2,p3,0xFFFFFF);
661 
662  CTri t(p1,p2,p3,i1,i2,i3); //
663  tris.push_back(t);
664  }
665 
666  // we have not pre-computed the plane equation for each triangle in the convex hull..
667 
668  double totalVolume = 0;
669 
670  CTriVector ftris; // 'feature' triangles.
671 
672  const unsigned int *src = indices;
673 
674 
675  double maxc=0;
676 
677 
678  if ( 1 )
679  {
680  CTriVector input_mesh;
681  if ( 1 )
682  {
683  const unsigned int *src = indices;
684  for (unsigned int i=0; i<tcount; i++)
685  {
686 
687  unsigned int i1 = *src++;
688  unsigned int i2 = *src++;
689  unsigned int i3 = *src++;
690 
691  const double *p1 = &vertices[i1*3];
692  const double *p2 = &vertices[i2*3];
693  const double *p3 = &vertices[i3*3];
694 
695  CTri t(p1,p2,p3,i1,i2,i3);
696  input_mesh.push_back(t);
697  }
698  }
699 
700  CTri maxctri;
701 
702  for (unsigned int i=0; i<tcount; i++)
703  {
704 
705  unsigned int i1 = *src++;
706  unsigned int i2 = *src++;
707  unsigned int i3 = *src++;
708 
709  const double *p1 = &vertices[i1*3];
710  const double *p2 = &vertices[i2*3];
711  const double *p3 = &vertices[i3*3];
712 
713  CTri t(p1,p2,p3,i1,i2,i3);
714 
715  featureMatch(t, tris, callback, input_mesh );
716 
717  if ( t.mConcavity > CONCAVE_THRESH )
718  {
719 
720  if ( t.mConcavity > maxc )
721  {
722  maxc = t.mConcavity;
723  maxctri = t;
724  }
725 
726  double v = t.getVolume(0);
727  totalVolume+=v;
728  ftris.push_back(t);
729  }
730 
731  }
732  }
733 
734  if ( ftris.size() && 0 )
735  {
736 
737  // ok..now we extract the triangles which form the maximum concavity.
738  CTriVector major_feature;
739  double maxarea = 0;
740 
741  while ( maxc > CONCAVE_THRESH )
742  {
743 
744  unsigned int color = getDebugColor(); //
745 
746  CTriVector flist;
747 
748  bool found;
749 
750  double totalarea = 0;
751 
752  do
753  {
754  found = false;
755  CTriVector::iterator i;
756  for (i=ftris.begin(); i!=ftris.end(); ++i)
757  {
758  CTri &t = (*i);
759  if ( isFeatureTri(t,flist,maxc,callback,color) )
760  {
761  found = true;
762  totalarea+=t.area();
763  }
764  }
765  } while ( found );
766 
767 
768  if ( totalarea > maxarea )
769  {
770  major_feature = flist;
771  maxarea = totalarea;
772  }
773 
774  maxc = 0;
775 
776  for (unsigned int i=0; i<ftris.size(); i++)
777  {
778  CTri &t = ftris[i];
779  if ( t.mProcessed != 2 )
780  {
781  t.mProcessed = 0;
782  if ( t.mConcavity > maxc )
783  {
784  maxc = t.mConcavity;
785  }
786  }
787  }
788  }
789 
790  unsigned int color = getDebugColor();
791 
792  WpointVector list;
793  for (unsigned int i=0; i<major_feature.size(); ++i)
794  {
795  major_feature[i].addWeighted(list,callback);
796  major_feature[i].debug(color,callback);
797  }
798 
799  getBestFitPlane( list.size(), &list[0].mPoint.x, sizeof(Wpoint), &list[0].mWeight, sizeof(Wpoint), plane );
800 
801  computeSplitPlane( vcount, vertices, tcount, indices, callback, plane );
802 
803 
804  }
805  else
806  {
807  computeSplitPlane( vcount, vertices, tcount, indices, callback, plane );
808  }
809 #endif
810 
811  cret = totalVolume;
812 
813  hl.ReleaseResult(result);
814  }
815 
816 
817  return cret;
818 }
819 
820 
821 };
ConvexDecomposition::Vector3d< double >
ConvexDecomposition::QF_TRIANGLES
@ QF_TRIANGLES
Definition: cd_hull.h:137
ConvexDecomposition::CTri::Concave
bool Concave(const Vector3d< double > &p, double &distance, Vector3d< double > &n) const
Definition: concavity.cpp:197
ConvexDecomposition::Vector3d::Distance
Type Distance(const Vector3d< Type > &a) const
Definition: cd_vector.h:454
ConvexDecomposition::featureMatch
bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callback, const CTriVector &input_mesh)
Definition: concavity.cpp:438
ConvexDecomposition::Vector3d::y
Type y
Definition: cd_vector.h:897
ConvexDecomposition::HullResult::mOutputVertices
double * mOutputVertices
Definition: cd_hull.h:79
ConvexDecomposition::HullDesc::mVcount
unsigned int mVcount
Definition: cd_hull.h:189
ConvexDecomposition::CTri
Definition: concavity.cpp:158
ConvexDecomposition::CTri::mConcavity
double mConcavity
Definition: concavity.cpp:426
ConvexDecomposition::CTri::planeDistance
double planeDistance(const Vector3d< double > &p) const
Definition: concavity.cpp:293
ConvexDecomposition::CTri::mNear1
Vector3d< double > mNear1
Definition: concavity.cpp:421
ConvexDecomposition::CTri::mC1
double mC1
Definition: concavity.cpp:427
ConvexDecomposition::CTri::debug
void debug(unsigned int color, ConvexDecompInterface *callback)
Definition: concavity.cpp:340
ConvexDecomposition::HullDesc
Definition: cd_hull.h:144
ConvexDecomposition::HullResult::mNumOutputVertices
unsigned int mNumOutputVertices
Definition: cd_hull.h:78
ConvexDecomposition::Wpoint
Definition: concavity.cpp:108
ConvexDecomposition::CTri::mNormal
Vector3d< double > mNormal
Definition: concavity.cpp:424
ConvexDecomposition::Vector3d::z
Type z
Definition: cd_vector.h:898
cd_vector.h
CONCAVE_THRESH
#define CONCAVE_THRESH
Definition: concavity.cpp:75
ConvexDecomposition::CTri::CTri
CTri(void)
Definition: concavity.cpp:161
ConvexDecomposition::computeSplitPlane
bool computeSplitPlane(unsigned int vcount, const double *vertices, unsigned int tcount, const unsigned int *indices, ConvexDecompInterface *callback, double *plane)
Definition: splitplane.cpp:204
ConvexDecomposition::HullLibrary::CreateConvexHull
HullError CreateConvexHull(const HullDesc &desc, HullResult &result)
Definition: cd_hull.cpp:2948
ConvexDecomposition::dot
double dot(const double3 &a, const double3 &b)
Definition: cd_hull.cpp:661
ConvexDecomposition::CTri::mNear2
Vector3d< double > mNear2
Definition: concavity.cpp:422
ConvexDecomposition::CTri::addWeighted
void addWeighted(WpointVector &list, ConvexDecompInterface *callback)
Definition: concavity.cpp:357
ConvexDecomposition::computeMeshVolume
double computeMeshVolume(const double *vertices, unsigned int tcount, const unsigned int *indices)
Definition: meshvolume.cpp:67
raytri.h
ConvexDecomposition::CTri::mNear3
Vector3d< double > mNear3
Definition: concavity.cpp:423
ConvexDecomposition::HullLibrary::ReleaseResult
HullError ReleaseResult(HullResult &result)
Definition: cd_hull.cpp:3149
ConvexDecomposition::Vector3d::NearestPointInTriangle
void NearestPointInTriangle(const Vector3d< Type > &point, const Vector3d< Type > &triangle0, const Vector3d< Type > &triangle1, const Vector3d< Type > &triangle2)
Definition: cd_vector.h:803
ConvexDecomposition::CTri::hasIndex
bool hasIndex(unsigned int i) const
Definition: concavity.cpp:320
ConvexDecomposition::CTri::mI1
unsigned int mI1
Definition: concavity.cpp:430
ConvexDecomposition::computeConcavity
double computeConcavity(unsigned int vcount, const double *vertices, unsigned int tcount, const unsigned int *indices, ConvexDecompInterface *callback, double *plane, double &volume)
Definition: concavity.cpp:594
ConvexDecomposition::CTri::mProcessed
int mProcessed
Definition: concavity.cpp:433
ConvexDecomposition::HullResult
Definition: cd_hull.h:65
ConvexDecomposition::Vector3d::Dot
Type Dot(const Vector3d< Type > &a) const
Definition: cd_vector.h:556
ConvexDecomposition::CTri::sharesEdge
bool sharesEdge(const CTri &t) const
Definition: concavity.cpp:326
WSCALE
#define WSCALE
Definition: concavity.cpp:74
ConvexDecomposition
Definition: bestfit.cpp:75
ConvexDecomposition::ConvexDecompInterface::ConvexDebugPoint
virtual void ConvexDebugPoint(const double *p, double dist, unsigned int color)
Definition: ConvexDecomposition.h:196
ConvexDecomposition::lineIntersectsTriangle
bool lineIntersectsTriangle(const double *rayStart, const double *rayEnd, const double *p1, const double *p2, const double *p3, double *sect)
Definition: raytri.cpp:123
ConvexDecomposition::HullLibrary
Definition: cd_hull.h:221
ConvexDecomposition::CTri::mC3
double mC3
Definition: concavity.cpp:429
ConvexDecomposition::CTriVector
std::vector< CTri > CTriVector
Definition: concavity.cpp:436
ConvexDecomposition::getBoundingRegion
double getBoundingRegion(unsigned int vcount, const double *points, unsigned int pstride, double *bmin, double *bmax)
Definition: bestfit.cpp:431
ConvexDecomposition::Wpoint::mWeight
double mWeight
Definition: concavity.cpp:118
ConvexDecomposition::computeMeshVolume2
double computeMeshVolume2(const double *vertices, unsigned int tcount, const unsigned int *indices)
Definition: meshvolume.cpp:136
ConvexDecomposition::intersect
static void intersect(const double *p1, const double *p2, double *split, const double *plane)
Definition: concavity.cpp:134
ConvexDecomposition::Wpoint::mPoint
Vector3d< double > mPoint
Definition: concavity.cpp:117
ConvexDecomposition::Vector3d::ComputePlane
double ComputePlane(const Vector3d< double > &A, const Vector3d< double > &B, const Vector3d< double > &C)
Definition: cd_vector.h:397
ConvexDecomposition::Vector3d::x
Type x
Definition: cd_vector.h:896
ConvexDecomposition::HullDesc::mMaxVertices
unsigned int mMaxVertices
Definition: cd_hull.h:194
ConvexDecomposition::HullError
HullError
Definition: cd_hull.h:197
ConvexDecomposition::HullDesc::mVertexStride
unsigned int mVertexStride
Definition: cd_hull.h:191
meshvolume.h
ConvexDecomposition::CTri::mP3
Vector3d< double > mP3
Definition: concavity.cpp:420
ConvexDecomposition::HullDesc::SetHullFlag
void SetHullFlag(HullFlag flag)
Definition: cd_hull.h:178
ConvexDecomposition::tris
static Array< Tri * > tris
Definition: cd_hull.cpp:2390
ConvexDecomposition::Wpoint::Wpoint
Wpoint(const Vector3d< double > &p, double w)
Definition: concavity.cpp:111
ConvexDecomposition::HullResult::mIndices
unsigned int * mIndices
Definition: cd_hull.h:82
ConvexDecomposition::Vector3d::Area
Type Area(const Vector3d< Type > &p1, const Vector3d< Type > &p2) const
Definition: cd_vector.h:494
ConvexDecomposition::ConvexDecompInterface
Definition: ConvexDecomposition.h:191
ConvexDecomposition::CTri::mPlaneD
double mPlaneD
Definition: concavity.cpp:425
ConvexDecomposition::ConvexDecompInterface::ConvexDebugTri
virtual void ConvexDebugTri(const double *p1, const double *p2, const double *p3, unsigned int color)
Definition: ConvexDecomposition.h:195
ConvexDecomposition::CTri::mP2
Vector3d< double > mP2
Definition: concavity.cpp:419
bestfit.h
ConvexDecomposition::WpointVector
std::vector< Wpoint > WpointVector
Definition: concavity.cpp:121
ConvexDecomposition::CTri::samePlane
bool samePlane(const CTri &t) const
Definition: concavity.cpp:306
concavity.h
ConvexDecomposition::HullResult::mNumFaces
unsigned int mNumFaces
Definition: cd_hull.h:80
ConvexDecomposition::CTri::clip
bool clip(const Vector3d< double > &start, Vector3d< double > &end) const
Definition: concavity.cpp:184
ConvexDecomposition::CTri::mP1
Vector3d< double > mP1
Definition: concavity.cpp:418
ConvexDecomposition::CTri::mC2
double mC2
Definition: concavity.cpp:428
ConvexDecomposition::isFeatureTri
bool isFeatureTri(CTri &t, CTriVector &flist, double fc, ConvexDecompInterface *callback, unsigned int color)
Definition: concavity.cpp:547
ConvexDecomposition::Vector3d::Ptr
const Type * Ptr() const
Definition: cd_vector.h:291
cd_hull.h
ConvexDecomposition::CTri::mI2
unsigned int mI2
Definition: concavity.cpp:431
ConvexDecomposition::getDebugColor
unsigned int getDebugColor(void)
Definition: concavity.cpp:80
ConvexDecomposition::CTri::mI3
unsigned int mI3
Definition: concavity.cpp:432
ConvexDecomposition::QE_OK
@ QE_OK
Definition: cd_hull.h:199
ConvexDecomposition::HullDesc::mVertices
const double * mVertices
Definition: cd_hull.h:190
ConvexDecomposition::CTri::Facing
double Facing(const CTri &t)
Definition: concavity.cpp:177
splitplane.h
ConvexDecomposition::plane
Definition: planetri.cpp:182
ConvexDecomposition::CTri::area
double area(void)
Definition: concavity.cpp:351
ConvexDecomposition::Vector3d::Set
void Set(const int *p)
Definition: cd_vector.h:264
ConvexDecomposition.h
ConvexDecomposition::CTri::getVolume
double getVolume(ConvexDecompInterface *callback) const
Definition: concavity.cpp:212
ConvexDecomposition::DistToPt
static double DistToPt(const double *p, const double *plane)
Definition: concavity.cpp:124
ConvexDecomposition::CTri::addTri
void addTri(unsigned int *indices, unsigned int i1, unsigned int i2, unsigned int i3, unsigned int &tcount) const
Definition: concavity.cpp:204
ConvexDecomposition::CTri::CTri
CTri(const double *p1, const double *p2, const double *p3, unsigned int i1, unsigned int i2, unsigned int i3)
Definition: concavity.cpp:163
ConvexDecomposition::getBestFitPlane
bool getBestFitPlane(unsigned int vcount, const double *points, unsigned int vstride, const double *weights, unsigned int wstride, double *plane)
Definition: bestfit.cpp:292
ConvexDecomposition::CTri::raySect
double raySect(const Vector3d< double > &p, const Vector3d< double > &dir, Vector3d< double > &sect) const
Definition: concavity.cpp:276


convex_decomposition
Author(s): John W. Ratcliff
autogenerated on Wed Mar 2 2022 00:04:59