131{
133 using namespace Eigen;
134
136
137
138
139
140
141 if(
142 this->
getF().
rows() <= (WindingNumberAABB_MIN_F>0?WindingNumberAABB_MIN_F:0) ||
144 {
145
146 return;
147 }
148
149
150 int max_d = -1;
151 typename DerivedV::Scalar max_len =
152 -numeric_limits<typename DerivedV::Scalar>::infinity();
154 {
156 {
159 }
160 }
161
164
165
166
167
168 typename DerivedV::Scalar split_value;
169
171 {
173
174 median(BC.col(max_d),split_value);
175 break;
176 default:
177 assert(false);
180 break;
181 }
182
183
184
185 vector<int> id( this->
getF().
rows());
186 for(
int i = 0;i<this->
getF().
rows();i++)
187 {
188 if(BC(i,max_d) <= split_value)
189 {
190 id[i] = 0;
191 }else
192 {
193 id[i] = 1;
194 }
195 }
196
197 const int lefts = (int)
count(
id.
begin(),
id.end(),0);
198 const int rights = (int)
count(
id.
begin(),
id.end(),1);
199 if(lefts == 0 || rights == 0)
200 {
201
202 return;
203 }
204 assert(lefts+rights == this->
getF().
rows());
205 DerivedF leftF(lefts, this->
getF().
cols());
206 DerivedF rightF(rights,this->
getF().
cols());
207 int left_i = 0;
208 int right_i = 0;
209 for(
int i = 0;i<this->
getF().
rows();i++)
210 {
211 if(id[i] == 0)
212 {
213 leftF.row(left_i++) = this->
getF().row(i);
214 }else if(id[i] == 1)
215 {
216 rightF.row(right_i++) = this->
getF().row(i);
217 }else
218 {
219 assert(false);
220 }
221 }
222 assert(right_i == rightF.rows());
223 assert(left_i == leftF.rows());
224
225 WindingNumberAABB<Point,DerivedV,DerivedF> * leftWindingNumberAABB =
226 new WindingNumberAABB<Point,DerivedV,DerivedF>(*this,leftF);
227 leftWindingNumberAABB->grow();
228 this->
children.push_back(leftWindingNumberAABB);
229 WindingNumberAABB<Point,DerivedV,DerivedF> * rightWindingNumberAABB =
230 new WindingNumberAABB<Point,DerivedV,DerivedF>(*this,rightF);
231 rightWindingNumberAABB->grow();
232 this->
children.push_back(rightWindingNumberAABB);
233}
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
const MatrixXF & getcap() const
Definition WindingNumberTree.h:265
void delete_children()
Definition WindingNumberTree.h:226
IGL_INLINE void count(const Eigen::SparseMatrix< XType > &X, const int dim, Eigen::SparseVector< SType > &S)
Definition count.cpp:12
IGL_INLINE bool median(const Eigen::MatrixBase< DerivedV > &V, mType &m)
Definition median.cpp:15
IGL_INLINE void barycenter(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedBC > &BC)
Definition barycenter.cpp:14
S::iterator begin(S &sh, const PathTag &)
Definition geometry_traits.hpp:614
size_t cols(const T &raster)
Definition MarchingSquares.hpp:60
size_t rows(const T &raster)
Definition MarchingSquares.hpp:55