1 #ifndef SEGMENT_TREES_H_
2 #define SEGMENT_TREES_H_
7 #include <CGAL/Cartesian.h>
8 #include <CGAL/Segment_tree_k.h>
9 #include <CGAL/Range_segment_tree_traits.h>
24 template<
typename PropertyType=
size_t>
29 typedef CGAL::Cartesian<double>
CK;
30 typedef CGAL::Segment_tree_map_traits_2<CK, size_t>
Traits2;
32 typedef CGAL::Segment_tree_map_traits_3<CK, size_t>
Traits3;
54 m_boundaries.push_back(_b);
60 void AddBoundary(
const Boundary* _b, PropertyType _p);
63 void BuildSegmentTrees();
69 size_t FindEnclosingBoundaries(
const Point3d& _p,
70 double _e=0.5*numeric_limits<float>::epsilon());
78 return m_output.size();
90 return m_propertyMap[m_output[_i]];
96 return m_boundaries[m_output[_i]];
110 vector<const Boundary*> m_boundaries;
111 vector<PropertyType> m_propertyMap;
112 vector<size_t> m_output;
113 size_t m_dimension{3};
115 Segment_tree_2_type* m_tree2{
nullptr};
116 Segment_tree_3_type* m_tree3{
nullptr};
122 template<
typename PropertyType>
127 template<
typename PropertyType>
130 m_boundaries.clear();
139 template<
typename PropertyType>
143 m_propertyMap.emplace_back(_p);
147 template<
typename PropertyType>
152 if(m_dimension == 2) {
153 vector<Interval2> in;
154 for(
size_t i = 0; i < m_boundaries.size(); i++) {
155 auto b = m_boundaries[i];
156 auto x = b->GetRange(0);
157 auto y = b->GetRange(1);
159 Key2(x.max,y.max)),i));
164 vector<Interval3> in;
165 for(
size_t i = 0; i < m_boundaries.size(); i++) {
166 auto b = m_boundaries[i];
167 auto x = b->GetRange(0);
168 auto y = b->GetRange(1);
169 auto z = b->GetRange(2);
171 Key3(x.max,y.max,z.max)),i));
178 template<
typename PropertyType>
188 if(m_dimension == 2) {
189 vector<Interval2> out;
191 Key2(_p[0]+_e,_p[1]+_e)),m_boundaries.size());
192 m_tree2->window_query(p,std::back_inserter(out));
193 for(
auto i = out.begin(); i != out.end(); i++)
194 m_output.push_back(i->second);
197 vector<Interval3> out;
199 Key3(_p[0]+_e,_p[1]+_e,_p[2]+_e)),m_boundaries.size());
200 m_tree3->window_query(p,std::back_inserter(out));
201 for(
auto i = out.begin(); i != out.end(); i++)
202 m_output.push_back(i->second);
205 return GetNumberEnclosingBoundaries();
Definition: Boundary.h:30
Definition: SegmentTrees.h:25
Traits3::Key Key3
Definition: SegmentTrees.h:39
CGAL::Cartesian< double > CK
Definition: SegmentTrees.h:29
size_t GetDimension()
Definition: SegmentTrees.h:100
const Boundary * GetOutputBoundary(size_t _i)
Definition: SegmentTrees.h:95
void AddBoundary(const Boundary *_b)
Definition: SegmentTrees.h:53
CGAL::Segment_tree_map_traits_3< CK, size_t > Traits3
Definition: SegmentTrees.h:32
PropertyType GetOutputBoundaryProperty(size_t _i)
Definition: SegmentTrees.h:89
size_t GetOutputBoundaryIndex(size_t _i)
Definition: SegmentTrees.h:83
SegmentTrees(size_t _d=3)
Definition: SegmentTrees.h:124
Traits2::Interval Interval2
Definition: SegmentTrees.h:34
void BuildSegmentTrees()
Build the Segment Trees.
Definition: SegmentTrees.h:148
CGAL::Segment_tree_3< Traits3 > Segment_tree_3_type
Definition: SegmentTrees.h:33
Traits3::Interval Interval3
Definition: SegmentTrees.h:35
Traits3::Pure_interval Pure_interval3
Definition: SegmentTrees.h:37
CGAL::Segment_tree_map_traits_2< CK, size_t > Traits2
Definition: SegmentTrees.h:30
size_t FindEnclosingBoundaries(const Point3d &_p, double _e=0.5 *numeric_limits< float >::epsilon())
Definition: SegmentTrees.h:181
size_t GetNumberEnclosingBoundaries()
Definition: SegmentTrees.h:77
CGAL::Segment_tree_2< Traits2 > Segment_tree_2_type
Definition: SegmentTrees.h:31
void SetDimension(size_t _d=3)
Definition: SegmentTrees.h:101
Traits2::Pure_interval Pure_interval2
Definition: SegmentTrees.h:36
Traits2::Key Key2
Definition: SegmentTrees.h:38
~SegmentTrees()
Definition: SegmentTrees.h:129