8#ifndef IGL_WINDINGNUMBERTREE_H
9#define IGL_WINDINGNUMBERTREE_H
30 std::pair<const WindingNumberTree*,const WindingNumberTree*>,
31 typename DerivedV::Scalar>
41 Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,Eigen::Dynamic>
44 Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,Eigen::Dynamic>
64 const Eigen::MatrixBase<DerivedV> &
V,
65 const Eigen::MatrixBase<DerivedF> &
F);
69 const Eigen::MatrixBase<DerivedF> &
F);
73 const Eigen::MatrixBase<DerivedV> &
V,
74 const Eigen::MatrixBase<DerivedF> &
F);
78 inline const DerivedV &
getV()
const;
82 inline virtual void grow();
88 inline virtual bool inside(
const Point & p)
const;
95 inline typename DerivedV::Scalar
winding_number(
const Point & p)
const;
117 inline void print(
const char * tab=
"");
155template <
typename Po
int,
typename DerivedV,
typename DerivedF>
159template <
typename Po
int,
typename DerivedV,
typename DerivedF>
167 radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
172template <
typename Po
int,
typename DerivedV,
typename DerivedF>
174 const Eigen::MatrixBase<DerivedV> & _V,
175 const Eigen::MatrixBase<DerivedF> & _F):
182 radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
188template <
typename Po
int,
typename DerivedV,
typename DerivedF>
190 const Eigen::MatrixBase<DerivedV> & _V,
191 const Eigen::MatrixBase<DerivedF> & _F)
197 Eigen::Matrix<typename MatrixXF::Scalar,Eigen::Dynamic,1> SVI,SVJ;
203template <
typename Po
int,
typename DerivedV,
typename DerivedF>
206 const Eigen::MatrixBase<DerivedF> & _F):
207 method(parent.method),
216template <
typename Po
int,
typename DerivedV,
typename DerivedF>
222template <
typename Po
int,
typename DerivedV,
typename DerivedF>
227 typename list<WindingNumberTree<Point,DerivedV,DerivedF>* >::iterator cit = children.begin();
228 while(cit != children.end())
233 cit = children.erase(cit);
237template <
typename Po
int,
typename DerivedV,
typename DerivedF>
241 for(
auto child : children)
243 child->set_method(m);
247template <
typename Po
int,
typename DerivedV,
typename DerivedF>
253template <
typename Po
int,
typename DerivedV,
typename DerivedF>
260template <
typename Po
int,
typename DerivedV,
typename DerivedF>
267template <
typename Po
int,
typename DerivedV,
typename DerivedF>
274template <
typename Po
int,
typename DerivedV,
typename DerivedF>
280template <
typename Po
int,
typename DerivedV,
typename DerivedF>
281inline typename DerivedV::Scalar
290 if(children.size()>0)
293 typename DerivedV::Scalar
sum = 0;
296 cit != children.end();
302 sum += (*cit)->winding_number(p);
308 sum += (*cit)->winding_number(p);
319 return winding_number_all(p);
325 if((cap.rows() - 2) < F.rows())
330 return winding_number_boundary(p);
333 typename DerivedV::Scalar dist = (p-center).norm();
340 return winding_number_boundary(p);
345 return parent->cached_winding_number(*
this,p);
347 default: assert(
false);
break;
352 return winding_number_all(p);
358template <
typename Po
int,
typename DerivedV,
typename DerivedF>
359inline typename DerivedV::Scalar
365template <
typename Po
int,
typename DerivedV,
typename DerivedF>
366inline typename DerivedV::Scalar
369 using namespace Eigen;
390template <
typename Po
int,
typename DerivedV,
typename DerivedF>
395 cout<<tab<<
"["<<endl<<F<<endl<<
"]";
399 cit != children.end();
403 (*cit)->print((
string(tab)+
"").c_str());
407template <
typename Po
int,
typename DerivedV,
typename DerivedF>
408inline typename DerivedV::Scalar
411 return std::numeric_limits<typename DerivedV::Scalar>::infinity();
414template <
typename Po
int,
typename DerivedV,
typename DerivedF>
415inline typename DerivedV::Scalar
417 const Point & )
const
420 return numeric_limits<typename DerivedV::Scalar>::infinity();
423template <
typename Po
int,
typename DerivedV,
typename DerivedF>
424inline typename DerivedV::Scalar
427 const Point & p)
const
447 bool is_far = this->radius<that.
radius;
450 typename DerivedV::Scalar a = atan2(
451 that.
radius - this->radius,
452 (that.
center - this->center).norm());
460 pair<const WindingNumberTree*,const WindingNumberTree*> this_that(
this,&that);
462 if(cached.count(this_that)==0)
467 return cached[this_that];
468 }
else if(children.size() == 0)
476 cit != children.end();
479 if((*cit)->inside(p))
481 return (*cit)->cached_winding_number(that,p);
Space partitioning tree for computing winding number hierarchically.
Definition WindingNumberTree.h:25
virtual bool inside(const Point &p) const
Definition WindingNumberTree.h:275
Eigen::Matrix< typename DerivedF::Scalar, Eigen::Dynamic, Eigen::Dynamic > MatrixXF
Definition WindingNumberTree.h:45
virtual DerivedV::Scalar max_simple_abs_winding_number(const Point &p) const
Definition WindingNumberTree.h:416
const WindingNumberTree * parent
Definition WindingNumberTree.h:38
DerivedV & V
Definition WindingNumberTree.h:49
std::list< WindingNumberTree * > children
Definition WindingNumberTree.h:39
WindingNumberTree()
Definition WindingNumberTree.h:160
virtual void set_mesh(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F)
Definition WindingNumberTree.h:189
const MatrixXF & getcap() const
Definition WindingNumberTree.h:262
WindingNumberMethod method
Definition WindingNumberTree.h:37
virtual DerivedV::Scalar max_abs_winding_number(const Point &p) const
Definition WindingNumberTree.h:409
void print(const char *tab="")
Definition WindingNumberTree.h:391
const MatrixXF & getF() const
Definition WindingNumberTree.h:255
virtual DerivedV::Scalar cached_winding_number(const WindingNumberTree &that, const Point &p) const
Definition WindingNumberTree.h:425
void set_method(const WindingNumberMethod &m)
Definition WindingNumberTree.h:238
MatrixXF cap
Definition WindingNumberTree.h:55
const DerivedV & getV() const
Definition WindingNumberTree.h:248
DerivedV::Scalar winding_number_all(const Point &p) const
Definition WindingNumberTree.h:360
virtual void grow()
Definition WindingNumberTree.h:268
DerivedV::Scalar radius
Definition WindingNumberTree.h:57
Eigen::Matrix< typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic > MatrixXS
Definition WindingNumberTree.h:42
static std::map< std::pair< const WindingNumberTree *, const WindingNumberTree * >, typename DerivedV::Scalar > cached
Definition WindingNumberTree.h:32
void delete_children()
Definition WindingNumberTree.h:223
Point center
Definition WindingNumberTree.h:59
virtual ~WindingNumberTree()
Definition WindingNumberTree.h:217
MatrixXF F
Definition WindingNumberTree.h:53
DerivedV::Scalar winding_number(const Point &p) const
Definition WindingNumberTree.h:282
DerivedV::Scalar winding_number_boundary(const Point &p) const
Definition WindingNumberTree.h:367
MatrixXS SV
Definition WindingNumberTree.h:51
static DerivedV dummyV
Definition WindingNumberTree.h:35
void exterior_edges(const Eigen::MatrixXi &F, Eigen::MatrixXi &E)
Determines boundary "edges" and also edges with an odd number of occurrences where seeing edge (i,...
void remove_duplicate_vertices(const Eigen::MatrixBase< DerivedV > &V, const double epsilon, Eigen::PlainObjectBase< DerivedSV > &SV, Eigen::PlainObjectBase< DerivedSVI > &SVI, Eigen::PlainObjectBase< DerivedSVJ > &SVJ)
Remove duplicate vertices upto a uniqueness tolerance (epsilon)
void winding_number(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, const Eigen::MatrixBase< DerivedO > &O, Eigen::PlainObjectBase< DerivedW > &W)
Computes the generalized winding number at each dim-dimensional query point in O with respect to the ...
WindingNumberMethod
Definition WindingNumberMethod.h:13
@ APPROX_SIMPLE_WINDING_NUMBER_METHOD
Definition WindingNumberMethod.h:17
@ APPROX_CACHE_WINDING_NUMBER_METHOD
Definition WindingNumberMethod.h:19
@ EXACT_WINDING_NUMBER_METHOD
Definition WindingNumberMethod.h:15
void triangle_fan(const Eigen::MatrixBase< DerivedE > &E, Eigen::PlainObjectBase< Derivedcap > &cap)
Given a list of faces tessellate all of the "exterior" edges forming another list of.
void sum(const Eigen::SparseMatrix< T > &X, const int dim, Eigen::SparseVector< T > &S)
Sum the columns or rows of a sparse matrix.
constexpr double PI
π
Definition PI.h:18