OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::AABBTreeLines Namespace Reference

Namespaces

namespace  detail

Classes

class  LinesDistancer

Functions

template<typename LineType>
AABBTreeIndirect::Tree< LineType::Dim, typename LineType::Scalar > build_aabb_tree_over_indexed_lines (const std::vector< LineType > &lines)
template<typename LineType, typename TreeType, typename VectorType>
VectorType::Scalar squared_distance_to_indexed_lines (const std::vector< LineType > &lines, const TreeType &tree, const VectorType &point, size_t &hit_idx_out, Eigen::PlainObjectBase< VectorType > &hit_point_out, typename VectorType::Scalar max_sqr_dist=std::numeric_limits< typename VectorType::Scalar >::infinity())
template<typename LineType, typename TreeType, typename VectorType>
std::vector< size_t > all_lines_in_radius (const std::vector< LineType > &lines, const TreeType &tree, const VectorType &point, typename VectorType::Scalar max_distance_squared)
template<typename LineType, typename TreeType, typename VectorType>
int point_outside_closed_contours (const std::vector< LineType > &lines, const TreeType &tree, const VectorType &point)
template<bool sorted, typename VectorType, typename LineType, typename TreeType>
std::vector< std::pair< VectorType, size_t > > get_intersections_with_line (const std::vector< LineType > &lines, const TreeType &tree, const LineType &line)

Function Documentation

◆ all_lines_in_radius()

template<typename LineType, typename TreeType, typename VectorType>
std::vector< size_t > Slic3r::AABBTreeLines::all_lines_in_radius ( const std::vector< LineType > & lines,
const TreeType & tree,
const VectorType & point,
typename VectorType::Scalar max_distance_squared )
inline
233 {
234 auto distancer = detail::IndexedLinesDistancer<LineType, TreeType, VectorType> { lines, tree, point };
235
236 if (tree.empty()) {
237 return {};
238 }
239
240 std::vector<size_t> found_lines {};
241 AABBTreeIndirect::detail::indexed_primitives_within_distance_squared_recurisve(distancer, size_t(0), max_distance_squared, found_lines);
242 return found_lines;
243 }
static void indexed_primitives_within_distance_squared_recurisve(const IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar squared_distance_limit, std::vector< size_t > &found_primitives_indices)
Definition AABBTreeIndirect.hpp:640

References Slic3r::AABBTreeIndirect::detail::indexed_primitives_within_distance_squared_recurisve().

Referenced by Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::all_lines_in_radius(), and Slic3r::Emboss::divide_segments_for_close_point().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_aabb_tree_over_indexed_lines()

template<typename LineType>
AABBTreeIndirect::Tree< LineType::Dim, typename LineType::Scalar > Slic3r::AABBTreeLines::build_aabb_tree_over_indexed_lines ( const std::vector< LineType > & lines)
inline
174 {
176 // using CoordType = typename TreeType::CoordType;
177 using VectorType = typename TreeType::VectorType;
178 using BoundingBox = typename TreeType::BoundingBox;
179
180 struct InputType {
181 size_t idx() const { return m_idx; }
182 const BoundingBox& bbox() const { return m_bbox; }
183 const VectorType& centroid() const { return m_centroid; }
184
185 size_t m_idx;
186 BoundingBox m_bbox;
187 VectorType m_centroid;
188 };
189
190 std::vector<InputType> input;
191 input.reserve(lines.size());
192 for (size_t i = 0; i < lines.size(); ++i) {
193 const LineType& line = lines[i];
194 InputType n;
195 n.m_idx = i;
196 n.m_centroid = (line.a + line.b) * 0.5;
197 n.m_bbox = BoundingBox(line.a, line.a);
198 n.m_bbox.extend(line.b);
199 input.emplace_back(n);
200 }
201
202 TreeType out;
203 out.build(std::move(input));
204 return out;
205 }
Definition AABBTreeIndirect.hpp:45
Definition BoundingBox.hpp:212

Referenced by Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::LinesDistancer(), Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::LinesDistancer(), anonymous_namespace{IntersectionPoints.cpp}::compute_intersections(), priv::create_search_data(), Slic3r::Emboss::divide_segments_for_close_point(), anonymous_namespace{GLGizmoSVG.cpp}::draw_filled(), Slic3r::SeamPlacerImpl::gather_enforcers_blockers(), Slic3r::TreeSupport3D::organic_smooth_branches_avoid_collisions(), and anonymous_namespace{TextLines.cpp}::select_closest_contour().

Here is the caller graph for this function:

◆ get_intersections_with_line()

template<bool sorted, typename VectorType, typename LineType, typename TreeType>
std::vector< std::pair< VectorType, size_t > > Slic3r::AABBTreeLines::get_intersections_with_line ( const std::vector< LineType > & lines,
const TreeType & tree,
const LineType & line )
inline
279 {
280 if (tree.empty()) {
281 return {};
282 }
283 auto line_bb = typename TreeType::BoundingBox(line.a, line.a);
284 line_bb.extend(line.b);
285
286 auto intersections = detail::get_intersections_with_line<LineType, TreeType, VectorType>(0, tree, lines, line, line_bb);
287 if (sorted) {
288 using Floating =
289 typename std::conditional<std::is_floating_point<typename LineType::Scalar>::value, typename LineType::Scalar, double>::type;
290
291 std::vector<std::pair<Floating, std::pair<VectorType, size_t>>> points_with_sq_distance {};
292 for (const auto& p : intersections) {
293 points_with_sq_distance.emplace_back((p.first - line.a).template cast<Floating>().squaredNorm(), p);
294 }
295 std::sort(points_with_sq_distance.begin(), points_with_sq_distance.end(),
296 [](const std::pair<Floating, std::pair<VectorType, size_t>>& left,
297 std::pair<Floating, std::pair<VectorType, size_t>>& right) { return left.first < right.first; });
298 for (size_t i = 0; i < points_with_sq_distance.size(); i++) {
299 intersections[i] = points_with_sq_distance[i].second;
300 }
301 }
302
303 return intersections;
304 }
std::vector< std::pair< VectorType, size_t > > get_intersections_with_line(size_t node_idx, const TreeType &tree, const std::vector< LineType > &lines, const LineType &line, const typename TreeType::BoundingBox &line_bb)
Definition AABBTreeLines.hpp:126
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::cast(), and Slic3r::AABBTreeLines::detail::get_intersections_with_line().

Referenced by anonymous_namespace{IntersectionPoints.cpp}::compute_intersections(), anonymous_namespace{GLGizmoSVG.cpp}::draw_filled(), and Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::intersections_with_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ point_outside_closed_contours()

template<typename LineType, typename TreeType, typename VectorType>
int Slic3r::AABBTreeLines::point_outside_closed_contours ( const std::vector< LineType > & lines,
const TreeType & tree,
const VectorType & point )
inline
249 {
250 if (tree.empty()) {
251 return 1;
252 }
253
254 auto [hits_above, hits_below] = detail::coordinate_aligned_ray_hit_count<LineType, TreeType, VectorType, 0>(0, tree, lines, point);
255 if (hits_above < 0 || hits_below < 0) {
256 return 0;
257 } else if (hits_above % 2 == 1 && hits_below % 2 == 1) {
258 return -1;
259 } else if (hits_above % 2 == 0 && hits_below % 2 == 0) {
260 return 1;
261 } else { // this should not happen with closed contours. lets check it in Y direction
262 auto [hits_above, hits_below] = detail::coordinate_aligned_ray_hit_count<LineType, TreeType, VectorType, 1>(0, tree, lines, point);
263 if (hits_above < 0 || hits_below < 0) {
264 return 0;
265 } else if (hits_above % 2 == 1 && hits_below % 2 == 1) {
266 return -1;
267 } else if (hits_above % 2 == 0 && hits_below % 2 == 0) {
268 return 1;
269 } else { // both results were unclear
270 return 0;
271 }
272 }
273 }
std::tuple< int, int > coordinate_aligned_ray_hit_count(size_t node_idx, const TreeType &tree, const std::vector< LineType > &lines, const VectorType &ray_origin)
Definition AABBTreeLines.hpp:51

References Slic3r::AABBTreeLines::detail::coordinate_aligned_ray_hit_count().

Referenced by Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::outside().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ squared_distance_to_indexed_lines()

template<typename LineType, typename TreeType, typename VectorType>
VectorType::Scalar Slic3r::AABBTreeLines::squared_distance_to_indexed_lines ( const std::vector< LineType > & lines,
const TreeType & tree,
const VectorType & point,
size_t & hit_idx_out,
Eigen::PlainObjectBase< VectorType > & hit_point_out,
typename VectorType::Scalar max_sqr_dist = std::numeric_limits<typename VectorType::Scalar>::infinity() )
inline
218 {
219 using Scalar = typename VectorType::Scalar;
220 if (tree.empty())
221 return Scalar(-1);
222 auto distancer = detail::IndexedLinesDistancer<LineType, TreeType, VectorType> { lines, tree, point };
223 return AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive(distancer, size_t(0), Scalar(0), max_sqr_dist,
224 hit_idx_out, hit_point_out);
225 }
static Scalar squared_distance_to_indexed_primitives_recursive(IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar low_sqr_d, Scalar up_sqr_d, size_t &i, Eigen::PlainObjectBase< typename IndexedPrimitivesDistancerType::VectorType > &c)
Definition AABBTreeIndirect.hpp:557

References Slic3r::AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive().

Referenced by Slic3r::AABBTreeLines::LinesDistancer< Linef3 >::distance_from_lines_extra(), priv::find_closest_point_index(), priv::find_closest_point_pair(), and anonymous_namespace{TextLines.cpp}::select_closest_contour().

Here is the call graph for this function:
Here is the caller graph for this function: