OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType > Class Template Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/AABBTreeIndirect.hpp>

Inheritance diagram for Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >:
Collaboration diagram for Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >:

Classes

struct  Node

Public Types

enum  : size_t { npos = size_t(-1) , inner = size_t(-2) }
using CoordType = ACoordType
using VectorType = Eigen::Matrix<CoordType, NumDimensions, 1, Eigen::DontAlign>
using BoundingBox = Eigen::AlignedBox<CoordType, NumDimensions>

Public Member Functions

void clear ()
template<typename SourceNode>
void build (std::vector< SourceNode > &&input)
template<typename SourceNode>
void build_modify_input (std::vector< SourceNode > &input)
const std::vector< Node > & nodes () const
const Node & node (size_t idx) const
bool empty () const
const Node & left_child (size_t idx) const
const Node & right_child (size_t idx) const
template<typename SourceNode>
void build (const std::vector< SourceNode > &input)

Static Public Member Functions

static size_t left_child_idx (size_t idx)
static size_t right_child_idx (size_t idx)

Static Public Attributes

static constexpr int NumDimensions = ANumDimensions

Private Member Functions

template<typename SourceNode>
void build_recursive (std::vector< SourceNode > &input, size_t node, const size_t left, const size_t right)
template<typename SourceNode>
void partition_input (std::vector< SourceNode > &input, const size_t dimension, size_t left, size_t right, const size_t k) const

Private Attributes

std::vector< Node > m_nodes

Detailed Description

template<int ANumDimensions, typename ACoordType>
class Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >

Member Typedef Documentation

◆ BoundingBox

template<int ANumDimensions, typename ACoordType>
using Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::BoundingBox = Eigen::AlignedBox<CoordType, NumDimensions>

◆ CoordType

template<int ANumDimensions, typename ACoordType>
using Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::CoordType = ACoordType

◆ VectorType

template<int ANumDimensions, typename ACoordType>
using Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::VectorType = Eigen::Matrix<CoordType, NumDimensions, 1, Eigen::DontAlign>

Member Enumeration Documentation

◆ anonymous enum

template<int ANumDimensions, typename ACoordType>
anonymous enum : size_t
Enumerator
npos 
inner 
52 : size_t {
53 // Node is not used.
54 npos = size_t(-1),
55 // Inner node (not leaf).
56 inner = size_t(-2)
57 };
Definition AABBTreeIndirect.hpp:45
@ npos
Definition AABBTreeIndirect.hpp:54
@ inner
Definition AABBTreeIndirect.hpp:56

Member Function Documentation

◆ build() [1/2]

template<int ANumDimensions, typename ACoordType>
template<typename SourceNode>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::build ( const std::vector< SourceNode > & input)
inline
121 {
123 this->build(std::move(copy));
124 }
void build(std::vector< SourceNode > &&input)
Definition AABBTreeIndirect.hpp:91

◆ build() [2/2]

template<int ANumDimensions, typename ACoordType>
template<typename SourceNode>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::build ( std::vector< SourceNode > && input)
inline
92 {
94 input.clear();
95 }
void clear()
Definition AABBTreeIndirect.hpp:79
void build_modify_input(std::vector< SourceNode > &input)
Definition AABBTreeIndirect.hpp:98

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::build().

Here is the caller graph for this function:

◆ build_modify_input()

template<int ANumDimensions, typename ACoordType>
template<typename SourceNode>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::build_modify_input ( std::vector< SourceNode > & input)
inline
99 {
100 if (input.empty())
101 clear();
102 else {
103 // Allocate enough memory for a full binary tree.
104 m_nodes.assign(next_highest_power_of_2(input.size()) * 2 - 1, Node());
105 build_recursive(input, 0, 0, input.size() - 1);
106 }
107 }
bool empty() const
Definition AABBTreeIndirect.hpp:111
void build_recursive(std::vector< SourceNode > &input, size_t node, const size_t left, const size_t right)
Definition AABBTreeIndirect.hpp:129
std::vector< Node > m_nodes
Definition AABBTreeIndirect.hpp:218
uint16_t next_highest_power_of_2(uint16_t v)
Definition Utils.hpp:376
Definition AABBTreeIndirect.hpp:61

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::build(), Slic3r::Algorithm::build_aabb_tree_over_expolygons(), and Slic3r::TreeSupport3D::merge_influence_areas().

Here is the caller graph for this function:

◆ build_recursive()

template<int ANumDimensions, typename ACoordType>
template<typename SourceNode>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::build_recursive ( std::vector< SourceNode > & input,
size_t node,
const size_t left,
const size_t right )
inlineprivate
130 {
131 assert(node < m_nodes.size());
132 assert(left <= right);
133
134 if (left == right) {
135 // Insert a node into the balanced tree.
136 m_nodes[node].set(input[left]);
137 return;
138 }
139
140 // Calculate bounding box of the input.
142 for (size_t i = left + 1; i <= right; ++ i)
143 bbox.extend(input[i].bbox());
144 int dimension = -1;
145 bbox.diagonal().maxCoeff(&dimension);
146
147 // Partition the input to left / right pieces of the same length to produce a balanced tree.
148 size_t center = (left + right) / 2;
150 // Insert an inner node into the tree. Inner node does not reference any input entity (triangle, line segment etc).
151 m_nodes[node].idx = inner;
152 m_nodes[node].bbox = bbox;
154 build_recursive(input, node * 2 + 2, center + 1, right);
155 }
void partition_input(std::vector< SourceNode > &input, const size_t dimension, size_t left, size_t right, const size_t k) const
Definition AABBTreeIndirect.hpp:162
const Node & node(size_t idx) const
Definition AABBTreeIndirect.hpp:110
Eigen::AlignedBox< CoordType, NumDimensions > BoundingBox
Definition AABBTreeIndirect.hpp:50

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::build_modify_input(), and Slic3r::AABBTreeIndirect::Tree< 2, float >::build_recursive().

Here is the caller graph for this function:

◆ clear()

template<int ANumDimensions, typename ACoordType>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::clear ( )
inline
79{ m_nodes.clear(); }

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::build_modify_input().

Here is the caller graph for this function:

◆ empty()

template<int ANumDimensions, typename ACoordType>
bool Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::empty ( ) const
inline
111{ return m_nodes.empty(); }

Referenced by Slic3r::AABBTreeIndirect::detail::intersect_triangle_epsilon(), Slic3r::GUI::anonymous_namespace{GLGizmoTextureDisplacement.cpp}::remap_texture_paint_spatial(), Slic3r::AABBTreeIndirect::traverse(), and Slic3r::Algorithm::wave_seeds().

Here is the caller graph for this function:

◆ left_child()

template<int ANumDimensions, typename ACoordType>
const Node & Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::left_child ( size_t idx) const
inline
116{ return m_nodes[left_child_idx(idx)]; }
static size_t left_child_idx(size_t idx)
Definition AABBTreeIndirect.hpp:114

◆ left_child_idx()

template<int ANumDimensions, typename ACoordType>
size_t Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::left_child_idx ( size_t idx)
inlinestatic
114{ return idx * 2 + 1; }

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::left_child(), Slic3r::AABBTreeIndirect::Tree< 2, float >::right_child_idx(), and Slic3r::AABBTreeIndirect::detail::traverse_recurse().

Here is the caller graph for this function:

◆ node()

template<int ANumDimensions, typename ACoordType>
const Node & Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::node ( size_t idx) const
inline
110{ return m_nodes[idx]; }

Referenced by Slic3r::AABBTreeIndirect::detail::traverse_recurse().

Here is the caller graph for this function:

◆ nodes()

template<int ANumDimensions, typename ACoordType>
const std::vector< Node > & Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::nodes ( ) const
inline
109{ return m_nodes; }

Referenced by priv::find_closest_point_index(), and Slic3r::AABBTreeIndirect::detail::intersect_triangle_epsilon().

Here is the caller graph for this function:

◆ partition_input()

template<int ANumDimensions, typename ACoordType>
template<typename SourceNode>
void Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::partition_input ( std::vector< SourceNode > & input,
const size_t dimension,
size_t left,
size_t right,
const size_t k ) const
inlineprivate
163 {
164 while (left < right) {
165 size_t center = (left + right) / 2;
167 {
168 // Bubble sort the input[left], input[center], input[right], so that a median of the three values
169 // will end up in input[center].
170 CoordType left_value = input[left ].centroid()(dimension);
172 CoordType right_value = input[right ].centroid()(dimension);
173 if (left_value > center_value) {
176 }
177 if (left_value > right_value) {
180 }
184 }
186 }
187 if (right <= left + 2)
188 // The <left, right> interval is already sorted.
189 break;
190 size_t i = left;
191 size_t j = right - 1;
193 // Partition the set based on the pivot.
194 for (;;) {
195 // Skip left points that are already at correct positions.
196 // Search will certainly stop at position (right - 1), which stores the pivot.
197 while (input[++ i].centroid()(dimension) < pivot) ;
198 // Skip right points that are already at correct positions.
199 while (input[-- j].centroid()(dimension) > pivot && i < j) ;
200 if (i >= j)
201 break;
202 std::swap(input[i], input[j]);
203 }
204 // Restore pivot to the center of the sequence.
205 std::swap(input[i], input[right - 1]);
206 // Which side the kth element is in?
207 if (k < i)
208 right = i - 1;
209 else if (k == i)
210 // Sequence is partitioned, kth element is at its place.
211 break;
212 else
213 left = i + 1;
214 }
215 }
ACoordType CoordType
Definition AABBTreeIndirect.hpp:48

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::build_recursive().

Here is the caller graph for this function:

◆ right_child()

template<int ANumDimensions, typename ACoordType>
const Node & Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::right_child ( size_t idx) const
inline
117{ return m_nodes[right_child_idx(idx)]; }
static size_t right_child_idx(size_t idx)
Definition AABBTreeIndirect.hpp:115

◆ right_child_idx()

template<int ANumDimensions, typename ACoordType>
size_t Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::right_child_idx ( size_t idx)
inlinestatic
115{ return left_child_idx(idx) + 1; }

Referenced by Slic3r::AABBTreeIndirect::Tree< 2, float >::right_child(), and Slic3r::AABBTreeIndirect::detail::traverse_recurse().

Here is the caller graph for this function:

Member Data Documentation

◆ m_nodes

template<int ANumDimensions, typename ACoordType>
std::vector<Node> Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::m_nodes
private

◆ NumDimensions

template<int ANumDimensions, typename ACoordType>
int Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::NumDimensions = ANumDimensions
staticconstexpr

The documentation for this class was generated from the following file: