Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
anonymous_namespace{RaycastManager.cpp} Namespace Reference

Functions

void actualize (RaycastManager::Meshes &meshes, const ModelVolumePtrs &volumes, const RaycastManager::ISkip *skip, RaycastManager::Meshes *input=nullptr)
 
const AABBMeshget_mesh (const RaycastManager::Meshes &meshes, size_t volume_id)
 
RaycastManager::TrKey create_key (const ModelVolume &volume, const ModelInstance &instance)
 
RaycastManager::TrItems::iterator find (RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
 
RaycastManager::TrItems::const_iterator find (const RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
 
bool is_lower_key (const RaycastManager::TrKey &k1, const RaycastManager::TrKey &k2)
 
bool is_lower (const RaycastManager::TrItem &i1, const RaycastManager::TrItem &i2)
 
template<typename VecType >
void erase (std::vector< VecType > &vec, const std::vector< bool > &flags)
 

Function Documentation

◆ actualize()

void anonymous_namespace{RaycastManager.cpp}::actualize ( RaycastManager::Meshes meshes,
const ModelVolumePtrs volumes,
const RaycastManager::ISkip skip,
RaycastManager::Meshes input = nullptr 
)
231{
232 // check if volume was removed
233 std::vector<bool> removed_meshes(meshes.size(), {true});
234 bool need_sort = false;
235 // actualize MeshRaycaster
236 for (const ModelVolume *volume : volumes) {
237 size_t oid = volume->id().id;
238 if (skip != nullptr && skip->skip(oid))
239 continue;
240 auto is_oid = [oid](const RaycastManager::Mesh &it) { return oid == it.first; };
241 if (auto item = std::find_if(meshes.begin(), meshes.end(), is_oid);
242 item != meshes.end()) {
243 size_t index = item - meshes.begin();
244 removed_meshes[index] = false;
245 continue;
246 }
247
248 // exist AABB in inputs ?
249 if (inputs != nullptr) {
250 auto input = std::find_if(inputs->begin(), inputs->end(), is_oid);
251 if (input != inputs->end()) {
252 meshes.emplace_back(std::move(*input));
253 need_sort = true;
254 continue;
255 }
256 }
257
258 // add new raycaster
259 bool calculate_epsilon = true;
260 auto mesh = std::make_unique<AABBMesh>(volume->mesh(), calculate_epsilon);
261 meshes.emplace_back(std::make_pair(oid, std::move(mesh)));
262 need_sort = true;
263 }
264
265 // clean other raycasters
266 erase(meshes, removed_meshes);
267
268 // All the time meshes must be sorted by volume id - for faster search
269 if (need_sort) {
270 auto is_lower = [](const RaycastManager::Mesh &m1, const RaycastManager::Mesh &m2) { return m1.first < m2.first; };
271 std::sort(meshes.begin(), meshes.end(), is_lower);
272 }
273}
virtual bool skip(const size_t &model_volume_id) const
Condition to not process model volume.
Definition RaycastManager.hpp:44
std::pair< size_t, std::unique_ptr< AABBMesh > > Mesh
Definition RaycastManager.hpp:23
Definition Model.hpp:753
static int input(void)
bool is_lower(const RaycastManager::TrItem &i1, const RaycastManager::TrItem &i2)
Definition RaycastManager.cpp:20
void erase(std::vector< VecType > &vec, const std::vector< bool > &flags)
Definition RaycastManager.cpp:301
IGL_INLINE void volume(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedT > &T, Eigen::PlainObjectBase< Derivedvol > &vol)
Definition volume.cpp:15

References actualize(), erase(), input(), is_lower(), and Slic3r::GUI::RaycastManager::ISkip::skip().

Referenced by actualize().

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

◆ create_key()

RaycastManager::TrKey anonymous_namespace{RaycastManager.cpp}::create_key ( const ModelVolume volume,
const ModelInstance instance 
)
14 {
15 return std::make_pair(instance.id().id, volume.id().id); }
ObjectID id() const
Definition ObjectID.hpp:55
size_t id
Definition ObjectID.hpp:37

References Slic3r::ObjectID::id, and Slic3r::ObjectBase::id().

+ Here is the call graph for this function:

◆ erase()

template<typename VecType >
void anonymous_namespace{RaycastManager.cpp}::erase ( std::vector< VecType > &  vec,
const std::vector< bool > &  flags 
)
inline
302{
303 if (vec.size() < flags.size() || flags.empty())
304 return;
305
306 // reverse iteration over flags to erase indices from back to front.
307 for (int i = static_cast<int>(flags.size()) - 1; i >= 0; --i)
308 if (flags[i])
309 vec.erase(vec.begin() + i);
310}

References erase().

Referenced by actualize(), and erase().

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

◆ find() [1/2]

RaycastManager::TrItems::const_iterator anonymous_namespace{RaycastManager.cpp}::find ( const RaycastManager::TrItems items,
const RaycastManager::TrKey key 
)
293{
294 auto fnc = [](const RaycastManager::TrItem &it, const RaycastManager::TrKey &l_key) { return is_lower_key(it.first, l_key); };
295 auto it = std::lower_bound(items.begin(), items.end(), key, fnc);
296 if (it != items.end() && it->first != key)
297 return items.end();
298 return it;
299}
std::pair< TrKey, Transform3d > TrItem
Definition RaycastManager.hpp:29
std::pair< size_t, size_t > TrKey
Definition RaycastManager.hpp:28
bool is_lower_key(const RaycastManager::TrKey &k1, const RaycastManager::TrKey &k2)
Definition RaycastManager.cpp:18

References is_lower_key().

+ Here is the call graph for this function:

◆ find() [2/2]

RaycastManager::TrItems::iterator anonymous_namespace{RaycastManager.cpp}::find ( RaycastManager::TrItems items,
const RaycastManager::TrKey key 
)
284 {
285 auto fnc = [](const RaycastManager::TrItem &it, const RaycastManager::TrKey &l_key) { return is_lower_key(it.first, l_key); };
286 auto it = std::lower_bound(items.begin(), items.end(), key, fnc);
287 if (it != items.end() && it->first != key)
288 return items.end();
289 return it;
290}

References is_lower_key().

+ Here is the call graph for this function:

◆ get_mesh()

const Slic3r::AABBMesh * anonymous_namespace{RaycastManager.cpp}::get_mesh ( const RaycastManager::Meshes meshes,
size_t  volume_id 
)
276{
277 auto is_lower_index = [](const RaycastManager::Mesh &m, size_t i) { return m.first < i; };
278 auto it = std::lower_bound(meshes.begin(), meshes.end(), volume_id, is_lower_index);
279 if (it == meshes.end() || it->first != volume_id)
280 return nullptr;
281 return &(*(it->second));
282}

◆ is_lower()

bool anonymous_namespace{RaycastManager.cpp}::is_lower ( const RaycastManager::TrItem i1,
const RaycastManager::TrItem i2 
)
20 {
21 return is_lower_key(i1.first, i2.first); };

References is_lower_key().

Referenced by actualize().

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

◆ is_lower_key()

bool anonymous_namespace{RaycastManager.cpp}::is_lower_key ( const RaycastManager::TrKey k1,
const RaycastManager::TrKey k2 
)
18 {
19 return k1.first < k2.first || (k1.first == k2.first && k1.second < k2.second); }

Referenced by find(), find(), and is_lower().

+ Here is the caller graph for this function: