proj home

Files   Classes   Functions   Hierarchy  

d3meshpartition Class Reference

Brute force (quadratic) general mesh subtraction. More...

#include <d3meshpartition.h>

Inheritance diagram for d3meshpartition:
Collaboration diagram for d3meshpartition:

List of all members.

Public Member Functions

 d3meshpartition (d3tess &meshB_)
bool const isInside (pt3c &x) const
bool const intersection (pt3 &x, pt3c &w, pt3c &b) const
bool const isOnBoundary (pt3c &w, double const zero) const
 The boundary is interpreted as a simplex face having no neighbor.

Public Attributes

d3tessmeshB


Detailed Description

Brute force (quadratic) general mesh subtraction.

All the meshes simplexes are transversed for isInside and intersection. This becomes expensive as if there are m simplexes in mesh A and n simplexes in mesh B then A - B is O(m)O(n).

The method is robust and easy to implement.

Definition at line 22 of file d3meshpartition.h.


Constructor & Destructor Documentation

d3meshpartition::d3meshpartition ( d3tess meshB_  )  [inline]

Definition at line 28 of file d3meshpartition.h.

00029     : meshB(meshB_) {}


Member Function Documentation

bool const d3meshpartition::intersection ( pt3 x,
pt3c w,
pt3c b 
) const

Definition at line 34 of file d3meshpartition.cpp.

References lineintersection(), meshB, d3tess::pt, and d3tess::vi.

00035 {
00036 
00037   vector<d3tri> const & vi(meshB.vi);
00038   vector<pt3> const & pt(meshB.pt);
00039 
00040   static vector<pt3> solutions;
00041   solutions.clear();
00042 
00043   double t0,t1;
00044 
00045   uintc sz = vi.size();
00046   uint k;
00047   for (uint i=1; i<sz; ++i)
00048   {
00049     d3tri const & y(vi[i]);
00050 
00051     if (y.isonboundary()==false)
00052       continue;
00053 
00054     for (k=0; k<3; ++k)
00055     {
00056       if (y.ni[k]!=0)
00057         continue;
00058 
00059       pt3c & c(pt[ y.pi[(k+1)%3] ]);
00060       pt3c & d(pt[ y.pi[(k+2)%3] ]);
00061       if (lineintersection(t0,t1,w,b,c,d))
00062       {
00063         if ((t1>=0.0)&&(t1<=1.0))
00064           solutions.push_back(c+(d-c)*t1);
00065       }
00066     }
00067   }
00068 
00069   assert(solutions.empty()==false);
00070 
00071   uintc solsz = solutions.size();
00072   if (solsz==1)
00073   {
00074     x = solutions[0];
00075     return true;
00076   }
00077 
00078   uint di = 0;
00079   double dmin = (w-solutions[0]).dot();
00080   double d;
00081  
00082   for (uint i=1; i<solsz; ++i)
00083   {
00084     d = (w-solutions[i]).dot();
00085     if (d<dmin)
00086     {
00087       dmin = d;
00088       di = i;
00089     }
00090   }
00091 
00092   x = solutions[di];
00093   return true;
00094 }

bool const d3meshpartition::isInside ( pt3c x  )  const

Definition at line 9 of file d3meshpartition.cpp.

References trianglespace< T, D >::isInside(), meshB, d3tess::pt, and d3tess::vi.

00010 {
00011   vector<d3tri> const & vi(meshB.vi);
00012   vector<pt3> const & pt(meshB.pt);
00013   uintc sz = vi.size();
00014   for (uint i=1; i<sz; ++i)
00015   {
00016     d3tri const & y(vi[i]);
00017      
00018     trianglespace< pt3, double > t
00019     ( 
00020       pt[ y.pi[0] ],
00021       pt[ y.pi[1] ],
00022       pt[ y.pi[2] ]
00023     );
00024 
00025     if (!t.isInside(x))
00026       return true;
00027   }
00028 
00029   return false;
00030 }

bool const d3meshpartition::isOnBoundary ( pt3c w,
double const   zero 
) const

The boundary is interpreted as a simplex face having no neighbor.

Definition at line 96 of file d3meshpartition.cpp.

References trianglespace< T, D >::isOnBoundary(), meshB, d3tess::pt, and d3tess::vi.

00097 {
00098   // Find the simplex with the point w.
00099 
00100   vector<d3tri> const & vi(meshB.vi);
00101   vector<pt3> const & pt(meshB.pt);
00102   uintc sz = vi.size();
00103   for (uint i=1; i<sz; ++i)
00104   {
00105     d3tri const & y(vi[i]);
00106      
00107     // Inefficent code. Just get working, optimize later.
00108     trianglespace< pt3, double > t
00109     ( 
00110       pt[ y.pi[0] ],
00111       pt[ y.pi[1] ],
00112       pt[ y.pi[2] ]
00113     );
00114 
00115 //    if (!t.isInside(w))
00116     if (t.isOnBoundary(w,zero))
00117       return true;
00118   }
00119 
00120   return false;
00121 }


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:49:53 2011 for Chelton Evans Source by  doxygen 1.5.8