23 template<
typename T,
unsigned d>
74 template<
short_t d,
class Z = index_t>
94 struct levelUp_visitor;
103 # define Eigen gsEigen
104 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
137 m_maxPath(o.m_maxPath)
153 m_maxPath = o.m_maxPath;
158 #if EIGEN_HAS_RVALUE_REFERENCES
164 m_maxPath(o.m_maxPath)
175 m_maxPath = o.m_maxPath;
205 Z numMax = std::numeric_limits<Z>::max();
207 std::vector<Z> logUpps(d);
216 logUpps[i] = math::floor( (math::log(numMax) - math::log(upp[i])) / math::log(2) );
221 init(upp, std::min( *std::min_element(logUpps.begin(), logUpps.end()), oldMax) );
278 void insertBox (point
const & lower, point
const & upper,
279 node * _node,
int lvl);
303 void clearBox (point
const & lower, point
const & upper,
315 void sinkBox (point
const & lower, point
const & upper,
int lvl);
320 for (
short_t i = 0; i!=d; ++i )
344 bool query1 (point
const & lower, point
const & upper,
345 int level, node * _node )
const;
388 bool query1 (point
const & lower, point
const & upper,
403 bool query2 (point
const & lower, point
const & upper,
404 int level, node *_node )
const;
416 bool query2 (point
const & lower, point
const & upper,
427 int query3(point
const & k1, point
const & k2,
428 int level, node *_node )
const;
442 int query3(point
const & lower, point
const & upper,
447 int query4(point
const & lower, point
const & upper,
448 int level, node *_node)
const;
459 int query4(point
const & lower, point
const & upper,
462 std::pair<point,point> queryLevelCell(point
const & lower,
482 literator beginLeafIterator()
487 const_literator beginLeafIterator()
const
492 void makeCompressed();
572 std::vector<std::vector<std::vector<std::vector<Z>>>>
getPolylines()
const;
574 std::vector<std::vector<std::vector<Z>>> getPolylinesSingleLevel(std::vector<
gsVSegment<Z>>& seg)
const;
577 inline unsigned getIndexLevel()
const
582 inline unsigned getMaxInsLevel()
const
587 void computeMaxInsLevel();
595 static bool haveOverlap(box
const & box1, box
const & box2);
598 static bool isContained(box
const & box1, box
const & box2);
606 static std::pair<point,point>
select_part(point
const & k1, point
const & k2,
607 point
const & k3, point
const & k4);
609 static void bisectBox(box
const & original,
619 static void setLevel(node *_node,
int lvl);
642 void getBoxes_vec(std::vector<std::vector<Z>>& boxes)
const;
654 void connect_Boxes(std::vector<std::vector<Z> > &boxes)
const;
655 void connect_Boxes2d(std::vector<std::vector<Z> > &boxes)
const;
657 void connect_Boxes_2(std::vector<std::vector<Z> > &boxes)
const;
666 std::list< std::list<
gsVSegment<Z> > >& vert_seg_lists )
const;
674 template<
typename visitor>
675 typename visitor::return_type
676 boxSearch(point
const & k1, point
const & k2,
677 int level, node *_node)
const;
681 template<
typename visitor>
682 typename visitor::return_type
687 template<
typename visitor>
688 typename visitor::return_type
695 node *
pointSearch(
const point & p,
int level, node *_node)
const;
700 typedef int return_type;
701 static return_type init() {
return 0;}
712 typedef int return_type;
713 static return_type init() {
return 0;}
724 typedef int return_type;
725 static return_type init() {
return 0;}
736 typedef int return_type;
737 static return_type init() {
return 0;}
748 typedef int return_type;
749 static return_type init() {
return 0;}
760 typedef int return_type;
761 static return_type init() {
return 0;}
765 leafNode->multiplyByTwo();
772 typedef int return_type;
773 static return_type init() {
return 0;}
777 leafNode->divideByTwo();
784 typedef int return_type;
785 static return_type init() {
return 0;}
797 typedef std::pair<point,point> return_type;
800 static return_type init()
802 return std::make_pair(point::Zero(),point::Zero());
808 if ( leafNode->
level == level )
810 res.first = leafNode->lowCorner();
811 res.second = leafNode->uppCorner();
822 #ifndef GISMO_BUILD_LIB
823 #include GISMO_HPP_HEADER(gsHDomain.hpp)
Re-implements gsDomainIterator for iteration over all boundary elements of a hierarchical parameter d...
Definition: gsHDomain.h:24
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(const gsHDomain &o)
Copy constructor (makes a deep copy)
Definition: gsHDomain.h:133
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
Decreases the level by 1 for all leaves.
Definition: gsHDomain.h:722
static bool haveOverlap(box const &box1, box const &box2)
Definition: gsHDomain.hpp:103
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
visitor::return_type nodeSearch() const
Definition: gsHDomain.hpp:610
Iterates over the leaves of an gsHDomain (tree).
Definition: gsHDomainLeafIter.h:29
int leafSize() const
Returns the number of leaves in the tree.
Definition: gsHDomain.hpp:1393
void setIndexLevel(int) const
Adds nlevels new index levels in the tree.
Definition: gsHDomain.h:625
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
#define short_t
Definition: gsConfig.h:35
unsigned m_maxInsLevel
Maximum level present in the tree.
Definition: gsHDomain.h:111
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
void init(point const &upp, unsigned index_level)
Initialize the tree.
Definition: gsHDomain.h:181
void insertBox(point const &lower, point const &upper, int lvl)
The insert function which insert box defined by points lower and upper to level lvl.
Definition: gsHDomain.h:290
side
Identifiers for topological sides.
Definition: gsBoundary.h:58
void multiplyByTwo()
Multiply all coordinates by two.
Definition: gsHDomain.hpp:1366
Struct representing a kd-tree node.
Definition: gsKdNode.h:34
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
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
Decreases the level by 1 for all leaves.
Definition: gsHDomain.h:698
void init(point const &upp)
Initialize the tree with computing the index_level.
Definition: gsHDomain.h:197
int levelOf(point const &p, int level) const
Returns the level of the point p.
Definition: gsHDomain.h:467
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
Counts number of nodes in the tree.
Definition: gsHDomain.h:782
Increases the level by 1 for all leaves.
Definition: gsHDomain.h:710
int query3(point const &k1, point const &k2, int level, node *_node) const
Definition: gsHDomain.hpp:448
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 internalIndex(point const &point_idx, int lvl, point &internal_idx)
Returns the internal coordinates of point point_idx of level lvl.
Definition: gsHDomain.h:318
Provides declaration of HDomainLeafIter class.
Multiplies everything by 2.
Definition: gsHDomain.h:770
#define gsInfo
Definition: gsDebug.h:43
Counts number of nodes in the tree.
Definition: gsHDomain.h:734
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
~gsHDomain()
Destructor deletes the whole tree.
Definition: gsHDomain.h:225
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
Counts number of nodes in the tree.
Definition: gsHDomain.h:746
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
Returns an cell/element box of a requested level.
Definition: gsHDomain.h:795
const point & upperCorner() const
Accessor for gsHDomain::m_upperIndex.
Definition: gsHDomain.h:249
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
gsHDomain & operator=(const gsHDomain &o)
Assignment operator (makes a deep copy)
Definition: gsHDomain.h:143
const point upperCornerIndex() const
Return the upper corner of the tree in level 0.
Definition: gsHDomain.h:255
Struct of for an Axis-aligned bounding box.
Definition: gsAABB.h:30
int numBreaks(int lvl, int k) const
Returns the number of distinct knots in direction k of level lvl.
Definition: gsHDomain.h:498
This is the main header file that collects wrappers of Eigen for linear algebra.
visitor::return_type leafSearch() const
Definition: gsHDomain.hpp:642
visitor::return_type boxSearch(point const &k1, point const &k2, int level, node *_node) const
Definition: gsHDomain.hpp:518
node * m_root
Pointer to the root node of the tree.
Definition: gsHDomain.h:94
EIGEN_MAKE_ALIGNED_OPERATOR_NEW unsigned m_indexLevel
The level of the box representation (global indices)
Definition: gsHDomain.h:108
Multiplies everything by 2.
Definition: gsHDomain.h:758
void divideByTwo()
Divide all coordinates by two.
Definition: gsHDomain.hpp:1373
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
point m_upperIndex
Keeps the highest upper indices (at level gsHDomain::m_indexLevel)
Definition: gsHDomain.h:102