Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::JPSTracer< CellPositionType, CellQueryFn > Class Template Reference
+ Collaboration diagram for Slic3r::JPSTracer< CellPositionType, CellQueryFn >:

Classes

struct  Node
 

Public Member Functions

 JPSTracer (CellPositionType target, CellQueryFn is_passable)
 
template<class Fn >
void foreach_reachable (const Node &from, Fn &&fn) const
 
float distance (Node a, Node b) const
 
float goal_heuristic (Node n) const
 
size_t unique_id (Node n) const
 

Public Attributes

const std::vector< CellPositionType > all_directions {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}
 

Private Member Functions

CellPositionType find_jump_point (CellPositionType start, CellPositionType forward_dir) const
 
bool is_jump_point (CellPositionType pos, CellPositionType forward_dir) const
 

Private Attributes

CellPositionType target
 
CellQueryFn is_passable
 

Detailed Description

template<typename CellPositionType, typename CellQueryFn>
class Slic3r::JPSTracer< CellPositionType, CellQueryFn >

Class Documentation

◆ Slic3r::JPSTracer::Node

struct Slic3r::JPSTracer::Node
template<typename CellPositionType, typename CellQueryFn>
struct Slic3r::JPSTracer< CellPositionType, CellQueryFn >::Node
Class Members
CellPositionType incoming_dir
CellPositionType position

Constructor & Destructor Documentation

◆ JPSTracer()

template<typename CellPositionType , typename CellQueryFn >
Slic3r::JPSTracer< CellPositionType, CellQueryFn >::JPSTracer ( CellPositionType  target,
CellQueryFn  is_passable 
)
inline
CellPositionType target
Definition JumpPointSearch.cpp:85
CellQueryFn is_passable
Definition JumpPointSearch.cpp:86

Member Function Documentation

◆ distance()

template<typename CellPositionType , typename CellQueryFn >
float Slic3r::JPSTracer< CellPositionType, CellQueryFn >::distance ( Node  a,
Node  b 
) const
inline
172{ return (a.position - b.position).template cast<double>().norm(); }

◆ find_jump_point()

template<typename CellPositionType , typename CellQueryFn >
CellPositionType Slic3r::JPSTracer< CellPositionType, CellQueryFn >::find_jump_point ( CellPositionType  start,
CellPositionType  forward_dir 
) const
inlineprivate
89 {
90 CellPositionType next = start + forward_dir;
91 while (next != target && is_passable(next) && !(is_jump_point(next, forward_dir))) { next = next + forward_dir; }
92
93 if (is_passable(next)) {
94 return next;
95 } else {
96 return start;
97 }
98 }
bool is_jump_point(CellPositionType pos, CellPositionType forward_dir) const
Definition JumpPointSearch.cpp:100

References Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_jump_point(), Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_passable, and Slic3r::JPSTracer< CellPositionType, CellQueryFn >::target.

Referenced by Slic3r::JPSTracer< CellPositionType, CellQueryFn >::foreach_reachable(), and Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_jump_point().

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

◆ foreach_reachable()

template<typename CellPositionType , typename CellQueryFn >
template<class Fn >
void Slic3r::JPSTracer< CellPositionType, CellQueryFn >::foreach_reachable ( const Node from,
Fn &&  fn 
) const
inline
129 {
130 const CellPositionType &pos = from.position;
131 const CellPositionType &forward_dir = from.incoming_dir;
132 std::vector<CellPositionType> dirs_to_check{};
133
134 if (abs(forward_dir.x()) + abs(forward_dir.y()) == 0) { // special case for starting point
135 dirs_to_check = all_directions;
136 } else if (abs(forward_dir.x()) + abs(forward_dir.y()) == 2) {
137 // diagonal
138 CellPositionType horizontal_check_dir = CellPositionType{forward_dir.x(), 0};
139 CellPositionType vertical_check_dir = CellPositionType{0, forward_dir.y()};
140
141 if (!is_passable(pos - horizontal_check_dir) && is_passable(pos + forward_dir - 2 * horizontal_check_dir)) {
142 dirs_to_check.push_back(forward_dir - 2 * horizontal_check_dir);
143 }
144
145 if (!is_passable(pos - vertical_check_dir) && is_passable(pos + forward_dir - 2 * vertical_check_dir)) {
146 dirs_to_check.push_back(forward_dir - 2 * vertical_check_dir);
147 }
148
149 dirs_to_check.push_back(horizontal_check_dir);
150 dirs_to_check.push_back(vertical_check_dir);
151 dirs_to_check.push_back(forward_dir);
152
153 } else { // horizontal or vertical
154 CellPositionType side_dir = CellPositionType(forward_dir.y(), forward_dir.x());
155
156 if (!is_passable(pos + side_dir) && is_passable(pos + forward_dir + side_dir)) {
157 dirs_to_check.push_back(forward_dir + side_dir);
158 }
159
160 if (!is_passable(pos - side_dir) && is_passable(pos + forward_dir - side_dir)) {
161 dirs_to_check.push_back(forward_dir - side_dir);
162 }
163 dirs_to_check.push_back(forward_dir);
164 }
165
166 for (const CellPositionType &dir : dirs_to_check) {
167 CellPositionType jp = find_jump_point(pos, dir);
168 if (jp != pos) fn(Node{jp, dir});
169 }
170 }
const std::vector< CellPositionType > all_directions
Definition JumpPointSearch.cpp:181
CellPositionType find_jump_point(CellPositionType start, CellPositionType forward_dir) const
Definition JumpPointSearch.cpp:88
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half abs(const half &a)
Definition Half.h:445
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14

References Slic3r::JPSTracer< CellPositionType, CellQueryFn >::all_directions, Slic3r::JPSTracer< CellPositionType, CellQueryFn >::find_jump_point(), Slic3r::JPSTracer< CellPositionType, CellQueryFn >::Node::incoming_dir, Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_passable, and Slic3r::JPSTracer< CellPositionType, CellQueryFn >::Node::position.

+ Here is the call graph for this function:

◆ goal_heuristic()

template<typename CellPositionType , typename CellQueryFn >
float Slic3r::JPSTracer< CellPositionType, CellQueryFn >::goal_heuristic ( Node  n) const
inline
174{ return n.position == target ? -1.f : (target - n.position).template cast<double>().norm(); }

References Slic3r::JPSTracer< CellPositionType, CellQueryFn >::Node::position, and Slic3r::JPSTracer< CellPositionType, CellQueryFn >::target.

◆ is_jump_point()

template<typename CellPositionType , typename CellQueryFn >
bool Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_jump_point ( CellPositionType  pos,
CellPositionType  forward_dir 
) const
inlineprivate
101 {
102 if (abs(forward_dir.x()) + abs(forward_dir.y()) == 2) {
103 // diagonal
104 CellPositionType horizontal_check_dir = CellPositionType{forward_dir.x(), 0};
105 CellPositionType vertical_check_dir = CellPositionType{0, forward_dir.y()};
106
107 if (!is_passable(pos - horizontal_check_dir) && is_passable(pos + forward_dir - 2 * horizontal_check_dir)) { return true; }
108
109 if (!is_passable(pos - vertical_check_dir) && is_passable(pos + forward_dir - 2 * vertical_check_dir)) { return true; }
110
111 if (find_jump_point(pos, horizontal_check_dir) != pos) { return true; }
112
113 if (find_jump_point(pos, vertical_check_dir) != pos) { return true; }
114
115 return false;
116 } else { // horizontal or vertical
117 CellPositionType side_dir = CellPositionType(forward_dir.y(), forward_dir.x());
118
119 if (!is_passable(pos + side_dir) && is_passable(pos + forward_dir + side_dir)) { return true; }
120
121 if (!is_passable(pos - side_dir) && is_passable(pos + forward_dir - side_dir)) { return true; }
122
123 return false;
124 }
125 }

References Slic3r::JPSTracer< CellPositionType, CellQueryFn >::find_jump_point(), and Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_passable.

Referenced by Slic3r::JPSTracer< CellPositionType, CellQueryFn >::find_jump_point().

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

◆ unique_id()

template<typename CellPositionType , typename CellQueryFn >
size_t Slic3r::JPSTracer< CellPositionType, CellQueryFn >::unique_id ( Node  n) const
inline
177 {
178 return (static_cast<size_t>(uint16_t(n.position.x())) << 16) + static_cast<size_t>(uint16_t(n.position.y()));
179 }
unsigned __int16 uint16_t
Definition unistd.h:78

References Slic3r::JPSTracer< CellPositionType, CellQueryFn >::Node::position.

Member Data Documentation

◆ all_directions

template<typename CellPositionType , typename CellQueryFn >
const std::vector<CellPositionType> Slic3r::JPSTracer< CellPositionType, CellQueryFn >::all_directions {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}

◆ is_passable

template<typename CellPositionType , typename CellQueryFn >
CellQueryFn Slic3r::JPSTracer< CellPositionType, CellQueryFn >::is_passable
private

◆ target

template<typename CellPositionType , typename CellQueryFn >
CellPositionType Slic3r::JPSTracer< CellPositionType, CellQueryFn >::target
private

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