27 typedef bool return_type;
30 static return_type init() {
return true;}
32 template<
short_t d,
class Z>
35 if ( leafNode->
level != level )
43 typedef bool return_type;
46 static return_type init() {
return true;}
48 template<
short_t d,
class Z>
51 if ( leafNode->
level <= level )
59 typedef int return_type;
63 static return_type init() {
return 1000000;}
65 template<
short_t d,
class Z>
68 if ( leafNode->
level < res )
69 res = leafNode->
level;
76 typedef int return_type;
80 static return_type init() {
return -1;}
82 template<
short_t d,
class Z>
85 if ( leafNode->
level > res )
86 res = leafNode->
level;
95 template<
short_t d,
class Z>
102 template<
short_t d,
class Z>
105 return !( (box1.second.array() <= box1.first .array()).any() ||
106 (box2.first .array() >= box1.second.array()).any() );
109 template<
short_t d,
class Z>
112 return !( (box1.first .array() < box2.first .array()).any() ||
113 (box1.second.array() > box2.second.array()).any() ) ;
116 template<
short_t d,
class Z>
void
120 if ( _node->isLeaf() )
130 setLevel(_node->
left , lvl);
131 setLevel(_node->
right, lvl);
135 template<
short_t d,
class Z>
inline bool
138 return (someBox.first.array() >= someBox.second.array()).any() ;
142 template<
short_t d,
class Z>
void
144 node *_node,
int lvl)
146 GISMO_ENSURE( lvl <= static_cast<int>(m_indexLevel),
"Max index level reached..");
150 if( isDegenerate(iBox) )
156 local2globalIndex( iBox.first , static_cast<unsigned>(lvl), iBox.first );
157 local2globalIndex( iBox.second, static_cast<unsigned>(lvl), iBox.second);
160 if ( ( iBox.first.array() >= m_upperIndex.array() ).any() )
162 gsWarn<<
" Invalid box coordinate "<< k1.transpose() <<
" at level" <<lvl<<
".\n";
167 std::vector<node*> stack;
168 stack.reserve( 2 * (m_maxPath + d) );
169 stack.push_back(_node);
172 while ( ! stack.empty() )
174 curNode = stack.back();
177 if ( curNode->isLeaf() )
182 if ( lvl <= curNode->level )
194 if ( ++curNode->
level != lvl)
195 stack.push_back(curNode);
199 stack.push_back(newLeaf);
204 if ( iBox.second[curNode->
axis] <= curNode->
pos)
206 stack.push_back(curNode->
left);
207 else if ( iBox.first[curNode->
axis] >= curNode->
pos)
209 stack.push_back(curNode->
right);
213 stack.push_back(curNode->
left );
214 stack.push_back(curNode->
right);
220 if ( static_cast<unsigned>(lvl) > m_maxInsLevel)
224 template<
short_t d,
class Z>
void
228 GISMO_ENSURE( lvl <= static_cast<int>(m_indexLevel),
"Max index level reached..");
232 if( isDegenerate(iBox) )
238 local2globalIndex( iBox.first , static_cast<unsigned>(lvl), iBox.first );
239 local2globalIndex( iBox.second, static_cast<unsigned>(lvl), iBox.second);
242 if ( ( iBox.first.array() >= m_upperIndex.array() ).any() )
244 gsWarn<<
" Invalid box coordinate "<< k1.transpose() <<
" at level" <<lvl<<
".\n";
249 std::vector<node*> stack;
250 stack.reserve( 2 * (m_maxPath + d) );
251 stack.push_back(m_root);
254 while ( ! stack.empty() )
256 curNode = stack.back();
259 if ( curNode->isLeaf() )
264 if ( curNode->
level <= lvl )
275 if ( --curNode->
level != lvl)
276 stack.push_back(curNode);
280 stack.push_back(newLeaf);
285 if ( iBox.second[curNode->
axis] <= curNode->
pos)
287 stack.push_back(curNode->
left);
288 else if ( iBox.first[curNode->
axis] >= curNode->
pos)
290 stack.push_back(curNode->
right);
294 stack.push_back(curNode->
left );
295 stack.push_back(curNode->
right);
300 computeMaxInsLevel();
303 template<
short_t d,
class Z>
void
305 point const & k2,
int lvl)
308 "Max index level might be reached..");
312 if( isDegenerate(iBox) )
316 local2globalIndex( iBox.first , static_cast<unsigned>(lvl), iBox.first );
317 local2globalIndex( iBox.second, static_cast<unsigned>(lvl), iBox.second);
320 if ( ( iBox.first.array() >= m_upperIndex.array() ).any() )
327 std::stack<node*, std::vector<node*> > stack;
331 while ( ! stack.empty() )
333 curNode = stack.top();
336 if ( curNode->isLeaf() )
347 if ( ++curNode->
level > static_cast<int>(m_maxInsLevel) )
348 m_maxInsLevel = curNode->
level;
357 if ( iBox.second[curNode->
axis] <= curNode->
pos)
359 stack.push(curNode->
left);
360 else if ( iBox.first[curNode->
axis] >= curNode->
pos)
362 stack.push(curNode->
right);
366 stack.push(curNode->
left );
367 stack.push(curNode->
right);
373 template<
short_t d,
class Z>
376 std::stack<node*, std::vector<node*> > tstack;
380 std::stack<node*, std::vector<node*> > stack;
382 while ( ! stack.empty() )
384 curNode = stack.top();
387 if ( curNode->isTerminal() )
390 tstack.push(curNode);
392 else if ( ! curNode->isLeaf() )
394 stack.push(curNode->left );
395 stack.push(curNode->right);
400 while ( ! tstack.empty() )
402 curNode = tstack.top();
405 if (curNode->left->level == curNode->right->level)
409 if ( !curNode->isRoot() &&
410 curNode->parent->isTerminal() )
411 tstack.push(curNode->parent );
416 m_maxPath = minMaxPath().second;
419 template<
short_t d,
class Z>
421 int level,
node *_node)
const
423 return boxSearch< query1_visitor >(upper,lower,level,_node);
426 template<
short_t d,
class Z>
430 return boxSearch< query1_visitor >(upper,lower,level,m_root);
433 template<
short_t d,
class Z>
435 int level,
node *_node)
const
437 return boxSearch< query2_visitor >(lower,upper,level,_node);
440 template<
short_t d,
class Z>
444 return boxSearch< query2_visitor >(lower,upper,level,m_root);
447 template<
short_t d,
class Z>
449 int level,
node *_node)
const
451 return boxSearch< query3_visitor >(lower,upper,level,_node);
454 template<
short_t d,
class Z>
458 return boxSearch< query3_visitor >(lower,upper,level,m_root);
461 template<
short_t d,
class Z>
463 int level,
node *_node)
const
465 return boxSearch< query4_visitor >(lower,upper,level,_node);
468 template<
short_t d,
class Z>
472 return boxSearch< query4_visitor >(lower,upper,level,m_root);
475 template<
short_t d,
class Z>
480 std::pair<point,point> tmp = boxSearch< get_cell_visitor >(lower,upper,level,m_root);
481 global2localIndex(tmp.first,level,tmp.first);
482 global2localIndex(tmp.second,level,tmp.second);
486 template<
short_t d,
class Z>
487 std::pair<typename gsHDomain<d, Z>::point,
typename gsHDomain<d, Z>::point>
492 std::pair<point,point> result;
497 result.first[i] = ( k1[i] >= k3[i] ? k1[i] : k3[i] );
499 result.second[i] = ( k2[i] >= k4[i] ? k4[i] : k2[i] );
504 template<
short_t d,
class Z>
void
506 box & leftBox, box & rightBox )
508 GISMO_ASSERT( ! isDegenerate(original) ,
"Invalid box .");
509 GISMO_ASSERT( (k>=0) && (k< static_cast<int>(d)) ,
"Invalid axis "<< k <<
".");
510 leftBox = rightBox = original;
511 leftBox.second[k] = rightBox.first[k] = coord;
515 template<
short_t d,
class Z>
516 template<
typename visitor>
517 typename visitor::return_type
519 int level,
node *_node )
const
523 local2globalIndex( qBox.first , static_cast<unsigned>(level), qBox.first );
524 local2globalIndex( qBox.second, static_cast<unsigned>(level), qBox.second);
527 "boxSearch: Wrong order of points defining the box (or empty box): "
528 << qBox.first.transpose() <<
", "<< qBox.second.transpose() <<
".\n" );
530 typename visitor::return_type res = visitor::init();
532 std::vector<node*> stack;
533 stack.reserve( 2 * m_maxPath );
534 stack.push_back(_node);
537 while ( ! stack.empty() )
539 curNode = stack.back();
542 if ( curNode->isLeaf() )
545 GISMO_ASSERT( !isDegenerate(*curNode->
box),
"Encountered an empty leaf");
546 visitor::visitLeaf(curNode, level, res );
550 if ( qBox.second[curNode->
axis] <= curNode->
pos)
552 stack.push_back(curNode->
left);
553 else if ( qBox.first[curNode->
axis] >= curNode->
pos)
555 stack.push_back(curNode->
right);
559 stack.push_back(curNode->
left );
560 stack.push_back(curNode->
right);
570 template<
short_t d,
class Z>
575 local2globalIndex(p, static_cast<unsigned>(level), pp);
577 GISMO_ASSERT( ( pp.array() <= m_upperIndex.array() ).all(),
578 "pointSearch: Wrong input: "<< p.transpose()<<
", level "<<level<<
".\n" );
580 std::vector<node*> stack;
581 stack.reserve( 2 * m_maxPath );
582 stack.push_back(_node);
585 while ( ! stack.empty() )
587 curNode = stack.back();
590 if ( curNode->isLeaf() )
597 if ( pp[curNode->
axis] < curNode->
pos)
598 stack.push_back(curNode->
left);
600 stack.push_back(curNode->
right);
603 GISMO_ERROR(
"pointSearch: Error ("<< p.transpose()<<
").\n" );
607 template<
short_t d,
class Z>
608 template<
typename visitor>
609 typename visitor::return_type
612 typename visitor::return_type i = visitor::init();
614 node * curNode = m_root;
618 visitor::visitNode(curNode, i);
620 if ( !curNode->isLeaf() )
622 curNode = curNode->
left;
626 while (curNode->
parent != NULL &&
628 curNode = curNode->
parent;
630 if ( curNode->isRoot() )
639 template<
short_t d,
class Z>
640 template<
typename visitor>
641 typename visitor::return_type
644 typename visitor::return_type i = visitor::init();
646 node * curNode = m_root;
650 if ( !curNode->isLeaf() )
652 curNode = curNode->
left;
657 visitor::visitLeaf(curNode, i);
659 while (curNode->
parent != NULL &&
661 curNode = curNode->
parent;
663 if ( curNode->isRoot() )
673 template<
short_t d,
class Z>
677 node * curNode = m_root;
678 int min = 1000000000, max = -1, cur = 0;
682 if ( !curNode->isLeaf() )
684 curNode = curNode->
left;
690 min = math::min(min,cur);
691 max = math::max(max,cur);
693 while (curNode->
parent != NULL &&
696 curNode = curNode->
parent;
700 if ( curNode->isRoot() )
706 return std::make_pair(min,max);
709 template<
short_t d,
class Z>
712 std::vector<std::vector<Z> > boxes;
720 connect_Boxes(boxes);
723 b1.resize(boxes.size(),d);
724 b2.resize(boxes.size(),d);
725 level.resize(boxes.size());
726 for(
size_t i = 0; i < boxes.size(); i++)
730 b1(i,j) = boxes[i][j];
731 b2(i,j) = boxes[i][j+d];
733 level[i] = boxes[i][2*d];
738 template<
short_t d,
class Z>
742 getBoxes( b1, b2, level);
743 std::vector<Z> onSide;
745 unsigned remainder = (s-1) % 2;
749 unsigned quotient = ( (s-1) - remainder ) / 2;
758 for(
index_t i = 0; i < b1.rows(); i++)
759 if( b1(i, quotient ) == 0 )
764 for(
index_t i = 0; i < b1.rows(); i++)
767 Z B2( b2(i, quotient ) );
769 B2 = B2 << (m_indexLevel - m_maxInsLevel);
772 if( B2 == m_upperIndex[ quotient ] )
773 onSide.push_back( i );
778 for(
size_t i=0; i < onSide.size(); i++)
780 b1.row(i) = b1.row( onSide[i] );
781 b2.row(i) = b2.row( onSide[i] );
782 level[i] = level( onSide[i] );
784 b1.conservativeResize( onSide.size(), b1.cols() );
785 b2.conservativeResize( onSide.size(), b2.cols() );
786 level.conservativeResize( onSide.size() );
789 template<
short_t d,
class Z>
794 std::vector<std::vector<Z> > boxes;
796 GISMO_ASSERT(d==2 || d==3,
"Wrong dimension, should be 2 or 3.");
798 for(
size_t i = 0; i < boxes.size(); i++)
800 if ((boxes[i][0]==boxes[i][d+0]) || (boxes[i][1]==boxes[i][1+d]))
802 boxes.erase(boxes.begin()+i);
805 else if((d == 3) && (boxes[i][2]==boxes[i][d+2]))
807 boxes.erase(boxes.begin()+i);
813 connect_Boxes(boxes);
814 b1.resize(boxes.size(), d);
815 b2.resize(boxes.size(), d);
816 level.resize(boxes.size());
817 for(
size_t i = 0; i < boxes.size(); i++)
821 lowerCorner[j] = boxes[i][j];
822 upperCorner[j] = boxes[i][j+d];
824 level[i] = boxes[i][2*d];
825 computeLevelIndex(lowerCorner, level[i], lowerCorner);
826 computeLevelIndex(upperCorner, level[i], upperCorner);
827 b1.row(i) = lowerCorner;
828 b2.row(i) = upperCorner;
836 template<
short_t d,
class Z>
void
844 size_t s = boxes.size();
845 for(
size_t i = 0; i < s; i++)
847 for(
size_t j = i+1; j < s; j++)
850 if(boxes[i][4]==boxes[j][4])
852 if( (boxes[i][0]==boxes[j][0]) && (boxes[i][2]==boxes[j][2]))
854 if(boxes[i][1]==boxes[j][3])
856 boxes[i][1] = boxes[j][1];
857 boxes.erase(boxes.begin()+j);
862 if(boxes[i][3]==boxes[j][1])
864 boxes[i][3] = boxes[j][3];
865 boxes.erase(boxes.begin()+j);
871 if( (boxes[i][1]==boxes[j][1]) && (boxes[i][3]==boxes[j][3])
874 if(boxes[i][0]==boxes[j][2])
876 boxes[i][0] = boxes[j][0];
877 boxes.erase(boxes.begin()+j);
882 if(boxes[i][2]==boxes[j][0])
884 boxes[i][2] = boxes[j][2];
885 boxes.erase(boxes.begin()+j);
897 template<
short_t d,
class Z>
void
904 size_t s = boxes.size();
905 for(
size_t i = 0; i < s; i++)
907 for(
size_t j = i+1; j < s; j++)
909 if(boxes[i][2*d]==boxes[j][2*d])
911 unsigned nmCoordLo = 0;
912 unsigned nmCoordUp = 0;
913 unsigned nmCountUp = 0;
914 unsigned nmCountLo = 0;
921 if( boxes[i][k] != boxes[j][k] )
927 if( boxes[i][d+k] != boxes[j][d+k] )
939 && nmCoordLo == nmCoordUp )
942 if( boxes[i][nmCoordLo] == boxes[j][d+nmCoordUp] )
946 boxes[i][nmCoordLo] = boxes[j][nmCoordLo];
947 boxes.erase( boxes.begin()+j );
953 if( boxes[i][d+nmCoordUp] == boxes[i][nmCoordLo] )
957 boxes[i][d+nmCoordUp] = boxes[j][d+nmCoordUp];
958 boxes.erase( boxes.begin()+j );
971 template<
short_t d,
class Z>
978 size_t s = boxes.
size();
979 for(
size_t i = 0; i < s;i++)
981 for(
size_t j = i+1; j < s; j++)
983 if(boxes[i][4]==boxes[j][4])
985 if( (boxes[i][0]==boxes[j][0]) && (boxes[i][2]==boxes[j][2]))
987 if(boxes[i][1]==boxes[j][3])
989 boxes[i][1] = boxes[j][1];
990 boxes.erase(boxes.begin()+j);
995 if(boxes[i][3]==boxes[j][1])
997 boxes[i][3] = boxes[j][3];
998 boxes.erase(boxes.begin()+j);
1012 size_t s = boxes.size();
1013 for(
size_t i = 0; i < s;i++)
1015 for(
size_t j = i+1; j < s; j++)
1017 if( (boxes[i][1]==boxes[j][1]) && (boxes[i][3]==boxes[j][3]))
1019 if(boxes[i][0]==boxes[j][2])
1021 boxes[i][0] = boxes[j][0];
1022 boxes.erase(boxes.begin()+j);
1027 if(boxes[i][2]==boxes[j][0])
1029 boxes[i][2] = boxes[j][2];
1030 boxes.erase(boxes.begin()+j);
1043 template<
short_t d,
class Z>
void
1048 std::stack<node*, std::vector<node*> > stack;
1052 while ( ! stack.empty() )
1054 curNode = stack.top();
1057 if ( curNode->isLeaf() )
1061 const point & lowerGlob = curNode->lowCorner();
1062 const point & upperGlob = curNode->uppCorner();
1063 unsigned int level = this->m_maxInsLevel;
1067 global2localIndex(lowerGlob,level,lower);
1068 global2localIndex(upperGlob,level,upper);
1070 boxes.push_back(std::vector<Z>());
1071 for(
short_t i = 0; i < d; i++)
1073 boxes.back().push_back(lower[i]);
1075 for(
short_t i = 0; i < d; i++)
1077 boxes.back().push_back(upper[i]);
1079 boxes.back().push_back(curNode->
level);
1083 stack.push(curNode->
left) ;
1084 stack.push(curNode->
right);
1092 template<
short_t d,
class Z>
1093 std::vector<std::vector<std::vector< std::vector<Z> > > >
1104 std::vector<std::vector<Z> > boxes;
1105 getBoxes_vec(boxes);
1108 for(
auto it = boxes.begin(); it != boxes.end(); ++it)
1110 if( ( (*it)[0] == (*it)[2] ) || ( (*it)[0] == (*it)[2] ) )
1111 it = boxes.erase(it);
1114 std::vector<std::vector<gsVSegment<Z> > > seg;
1115 seg.resize(m_maxInsLevel+1);
1118 for(
size_t i = 0; i < boxes.size() ; i ++)
1120 seg[boxes[i][4]].push_back(
gsVSegment<Z>(boxes[i][0], boxes[i][1], boxes[i][3],
false));
1121 seg[boxes[i][4]].push_back(
gsVSegment<Z>(boxes[i][2], boxes[i][1], boxes[i][3],
false));
1125 std::vector< std::vector<std::vector< std::vector<Z> > > > result;
1126 for(
unsigned int i = 0; i < m_maxInsLevel+1; i++)
1128 result.push_back( getPolylinesSingleLevel( seg[i] ));
1135 template<
short_t d,
class Z>
1142 std::list< std::list< gsVSegment<Z> > > vert_seg_lists;
1145 std::vector< std::vector< std::vector<Z> > > result;
1148 std::sort( seg.begin(), seg.end() );
1151 std::list< gsVSegment<Z> > segs_x;
1152 for(
auto it_seg = seg.begin(); it_seg != seg.end(); ++it_seg )
1154 if( segs_x.empty() || (*it_seg).getX() == segs_x.front().getX() )
1155 segs_x.push_back( *it_seg );
1158 vert_seg_lists.push_back( segs_x );
1159 segs_x.erase( segs_x.begin(), segs_x.end() );
1160 segs_x.push_back( *it_seg );
1164 vert_seg_lists.push_back( segs_x );
1168 getRidOfOverlaps( vert_seg_lists );
1171 sweeplineConnectAndMerge( result, vert_seg_lists );
1175 template <
short_t d,
class Z>
1178 bool need_to_erase =
false;
1179 for(
auto it_x = vert_seg_lists.begin(); it_x != vert_seg_lists.end(); )
1182 for(
auto it_slow = (*it_x).begin(); it_slow != (*it_x).end(); ++it_slow)
1185 for(
auto it_quick = it_slow; it_quick != (*it_x).end(); ++it_quick)
1187 if( it_quick != it_slow )
1189 need_to_erase = it_slow->cannotDeleteOverlap( *it_quick) || need_to_erase;
1197 for(
auto it_slow = (*it_x).begin(); it_slow != (*it_x).end(); )
1199 if( (*it_slow).length() == 0 )
1201 (*it_x).erase( it_slow++ );
1208 if( (*it_x).empty() )
1209 vert_seg_lists.erase( it_x++ );
1215 template <
short_t d,
class Z>
1217 std::list< std::list<
gsVSegment<Z> > >& vert_seg_lists )
const
1235 std::list< gsAAPolyline<Z> > act_poly;
1236 std::queue< gsAAPolyline<Z> > poly_queue;
1238 for(
auto it_x = vert_seg_lists.begin(); it_x != vert_seg_lists.end(); ++it_x )
1243 for(
auto it = act_poly.begin(); it != act_poly.end(); ++it )
1244 poly_queue.push( *it );
1246 act_poly.erase( act_poly.begin(), act_poly.end() );
1248 gsAAPolyline<Z> curr_poly;
1249 while( !poly_queue.empty() )
1251 curr_poly = poly_queue.front();
1253 bool is_active =
true;
1254 for(
auto it_seg = (*it_x).begin(); it_seg != (*it_x).end(); )
1256 if( curr_poly.canBeExtended( *it_seg) )
1258 if( curr_poly.almostClosed() )
1259 result.push_back( curr_poly.writeParasolid () );
1261 poly_queue.push( curr_poly );
1264 (*it_x).erase( it_seg++ );
1273 act_poly.push_back( curr_poly );
1278 for(
auto it = (*it_x).begin(); it != (*it_x).end(); ++it )
1280 gsAAPolyline<Z> new_polyline( *it );
1281 act_poly.push_back( new_polyline );
1289 for(
auto it_slow = act_poly.begin(); it_slow != act_poly.end(); ++it_slow )
1291 for(
auto it_quick = it_slow; it_quick != act_poly.end(); ++it_quick)
1293 if(( it_slow != it_quick ) && ((*it_slow).mergeWith(*it_quick)))
1295 act_poly.erase( it_quick );
1296 act_poly.push_back( *it_slow );
1297 it_slow = act_poly.erase( it_slow );
1304 for(
auto it = act_poly.begin(); it != act_poly.end(); )
1306 if( (*it).almostClosed() )
1308 result.push_back( (*it).writeParasolid() );
1309 act_poly.erase( it++ );
1318 template<
short_t d,
class Z>
1324 result[i] = index[i] << (m_maxInsLevel-lvl) ;
1327 template<
short_t d,
class Z>
1328 inline void gsHDomain<d, Z>::computeLevelIndex(gsVector<Z, d>
const & index,
1330 gsVector<Z, d> & result)
const
1333 result[i] = index[i] >> (m_maxInsLevel-lvl) ;
1336 template<
short_t d,
class Z>
1337 inline void gsHDomain<d, Z>::local2globalIndex(gsVector<Z, d>
const & index,
1339 gsVector<Z, d> & result)
const
1342 result[i] = index[i] << (m_indexLevel-lvl) ;
1345 template<
short_t d,
class Z>
1346 inline void gsHDomain<d, Z>::global2localIndex(gsVector<Z, d>
const & index,
1348 gsVector<Z, d> & result)
const
1351 result[i] = index[i] >> (this->m_indexLevel-lvl) ;
1354 template<
short_t d,
class Z>
1360 "Problem with indices, increase number of levels (to do).");
1362 leafSearch< levelUp_visitor >();
1365 template<
short_t d,
class Z>
1369 nodeSearch< liftCoordsOneLevel_visitor >();
1372 template<
short_t d,
class Z>
1376 nodeSearch< reduceCoordsOneLevel_visitor >();
1379 template<
short_t d,
class Z>
1383 leafSearch< levelDown_visitor >();
1386 template<
short_t d,
class Z>
1389 return nodeSearch< numNodes_visitor >();
1392 template<
short_t d,
class Z>
1395 return leafSearch< numLeaves_visitor >();
1398 template<
short_t d,
class Z>
1401 leafSearch< printLeaves_visitor >();
1404 template<
short_t d,
class Z>
1407 m_maxInsLevel = leafSearch< maxLevel_visitor >();
void decrementLevel()
Decrement the level index globally.
Definition: gsHDomain.hpp:1380
static bool isDegenerate(box const &someBox)
Returns true if the box is degenerate (has zero volume)
Definition: gsHDomain.hpp:136
gsHDomain * clone() const
Clones the object.
Definition: gsHDomain.hpp:96
static std::pair< point, point > select_part(point const &k1, point const &k2, point const &k3, point const &k4)
Definition: gsHDomain.hpp:488
Class for representing a vertical line segment in 2D. Helper for the class gsAAPolyline.
Definition: gsHDomain.h:33
bool query2(point const &lower, point const &upper, int level, node *_node) const
Returns true if the box defined by lower and upper is contained in a domain with a higher level than ...
Definition: gsHDomain.hpp:434
static bool haveOverlap(box const &box1, box const &box2)
Definition: gsHDomain.hpp:103
visitor::return_type nodeSearch() const
Definition: gsHDomain.hpp:610
int leafSize() const
Returns the number of leaves in the tree.
Definition: gsHDomain.hpp:1393
bool query1(point const &lower, point const &upper, int level, node *_node) const
Returns true if the box defined by lower and upper is completely contained in level and does not over...
Definition: gsHDomain.hpp:420
Helper class for gsAAPolyline.
#define short_t
Definition: gsConfig.h:35
Provides structs and classes related to interfaces and boundaries.
static bool isContained(box const &box1, box const &box2)
Returns true if box1 is contained in box2.
Definition: gsHDomain.hpp:110
gsKdNode * adaptiveAlignedSplit(kdBox const &insBox, int index_level)
Definition: gsKdNode.h:285
side
Identifiers for topological sides.
Definition: gsBoundary.h:58
void multiplyByTwo()
Multiply all coordinates by two.
Definition: gsHDomain.hpp:1366
gsKdNode * left
Pointer to the left child of this split node (if it is one)
Definition: gsKdNode.h:60
Struct representing a kd-tree node.
Definition: gsKdNode.h:34
#define index_t
Definition: gsConfig.h:32
void incrementLevel()
Increment the level index globally.
Definition: gsHDomain.hpp:1355
void getBoxesInLevelIndex(gsMatrix< Z > &b1, gsMatrix< Z > &b2, gsVector< index_t > &level) const
Definition: gsHDomain.hpp:790
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
std::vector< std::vector< std::vector< std::vector< Z > > > > getPolylines() const
Definition: gsHDomain.hpp:1094
void sweeplineConnectAndMerge(std::vector< std::vector< std::vector< Z > > > &result, std::list< std::list< gsVSegment< Z > > > &vert_seg_lists) const
Sweepline algorithm.
Definition: gsHDomain.hpp:1216
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void clearBox(point const &lower, point const &upper, int lvl)
The clear function which clears box defined by points lower and upper to level lvl.
Definition: gsHDomain.hpp:225
#define gsWarn
Definition: gsDebug.h:50
int query3(point const &k1, point const &k2, int level, node *_node) const
Definition: gsHDomain.hpp:448
Z pos
Split coordinate (meaningfull only for split nodes)
Definition: gsKdNode.h:45
void getBoxes(gsMatrix< Z > &b1, gsMatrix< Z > &b2, gsVector< Z > &level) const
Returns the boxes which make up the hierarchical domain and the respective levels.
Definition: gsHDomain.hpp:710
void printLeaves() const
Prints out the leaves of the kd-tree.
Definition: gsHDomain.hpp:1399
void sinkBox(point const &lower, point const &upper, int lvl)
Sinks the box defined by points lower and upper to one level higher.
Definition: gsHDomain.hpp:304
std::pair< int, int > minMaxPath() const
Returns the minimim and maximum path length in the tree.
Definition: gsHDomain.hpp:675
node * pointSearch(const point &p, int level, node *_node) const
Definition: gsHDomain.hpp:572
void getRidOfOverlaps(std::list< std::list< gsVSegment< Z > > > &vert_seg_lists) const
Definition: gsHDomain.hpp:1176
int size() const
Returns the number of nodes in the tree.
Definition: gsHDomain.hpp:1387
Class with a hierarchical domain structure represented by a box k-d-tree.
Definition: gsHDomain.h:75
static void setLevel(node *_node, int lvl)
Definition: gsHDomain.hpp:117
int level
Definition: gsKdNode.h:49
void getBoxes_vec(std::vector< std::vector< Z >> &boxes) const
Represents boxes of the tree in a big vector.
Definition: gsHDomain.hpp:1044
void insertBox(point const &lower, point const &upper, node *_node, int lvl)
The insert function which insert box defined by points lower and upper to level lvl.
Definition: gsHDomain.hpp:143
Class for handling an axis-aligned polyline in 2D.
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
Struct of for an Axis-aligned bounding box.
Definition: gsAABB.h:30
This is the main header file that collects wrappers of Eigen for linear algebra.
kdBox * box
Definition: gsKdNode.h:54
visitor::return_type leafSearch() const
Definition: gsHDomain.hpp:642
gsKdNode * parent
Pointer to the parent node.
Definition: gsKdNode.h:57
visitor::return_type boxSearch(point const &k1, point const &k2, int level, node *_node) const
Definition: gsHDomain.hpp:518
int axis
Definition: gsKdNode.h:42
void divideByTwo()
Divide all coordinates by two.
Definition: gsHDomain.hpp:1373
Provides declaration of the tree node.
void getBoxesOnSide(boundary::side s, gsMatrix< Z > &b1, gsMatrix< Z > &b2, gsVector< Z > &level) const
Returns the boxes which make up the hierarchical domain and the respective levels touching side s...
Definition: gsHDomain.hpp:739
void connect_Boxes(std::vector< std::vector< Z > > &boxes) const
connect the boxes returned from quadtree getBoxes_vec()
Definition: gsHDomain.hpp:898
int query4(point const &lower, point const &upper, int level, node *_node) const
Definition: gsHDomain.hpp:462
gsKdNode * right
Pointer to the right child of this split node (if it is one)
Definition: gsKdNode.h:63