OrcaSlicer latest
OrcaSlicer
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 AABBMesh * get_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 )
245{
246 // check if volume was removed
247 std::vector<bool> removed_meshes(meshes.size(), {true});
248 bool need_sort = false;
249 // actualize MeshRaycaster
250 for (const ModelVolume *volume : volumes) {
251 size_t oid = volume->id().id;
252 if (skip != nullptr && skip->skip(oid))
253 continue;
254 auto is_oid = [oid](const RaycastManager::Mesh &it) { return oid == it.first; };
255 if (auto item = std::find_if(meshes.begin(), meshes.end(), is_oid);
256 item != meshes.end()) {
257 size_t index = item - meshes.begin();
258 removed_meshes[index] = false;
259 continue;
260 }
261
262 // exist AABB in inputs ?
263 if (inputs != nullptr) {
264 auto input = std::find_if(inputs->begin(), inputs->end(), is_oid);
265 if (input != inputs->end()) {
266 meshes.emplace_back(std::move(*input));
267 need_sort = true;
268 continue;
269 }
270 }
271
272 // add new raycaster
273 bool calculate_epsilon = true;
274 auto mesh = std::make_unique<AABBMesh>(volume->mesh(), calculate_epsilon);
275 meshes.emplace_back(std::make_pair(oid, std::move(mesh)));
276 need_sort = true;
277 }
278
279 // clean other raycasters
280 erase(meshes, removed_meshes);
281
282 // All the time meshes must be sorted by volume id - for faster search
283 if (need_sort) {
284 auto is_lower = [](const RaycastManager::Mesh &m1, const RaycastManager::Mesh &m2) { return m1.first < m2.first; };
285 std::sort(meshes.begin(), meshes.end(), is_lower);
286 }
287}
virtual bool skip(const size_t &model_volume_id) const
Condition to not process model volume.
Definition RaycastManager.hpp:49
std::pair< size_t, std::unique_ptr< AABBMesh > > Mesh
Definition RaycastManager.hpp:28
Definition Model.hpp:832
bool is_lower(const RaycastManager::TrItem &i1, const RaycastManager::TrItem &i2)
Definition RaycastManager.cpp:33
void erase(std::vector< VecType > &vec, const std::vector< bool > &flags)
Definition RaycastManager.cpp:315

References actualize(), erase(), 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 )
27 {
28 return std::make_pair(instance.id().id, volume.id().id); }
ObjectID id() const
Definition ObjectID.hpp:69
size_t id
Definition ObjectID.hpp:39

References Slic3r::ObjectBase::id(), and Slic3r::ObjectID::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
316{
317 if (vec.size() < flags.size() || flags.empty())
318 return;
319
320 // reverse iteration over flags to erase indices from back to front.
321 for (int i = static_cast<int>(flags.size()) - 1; i >= 0; --i)
322 if (flags[i])
323 vec.erase(vec.begin() + i);
324}

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 )
307{
308 auto fnc = [](const RaycastManager::TrItem &it, const RaycastManager::TrKey &l_key) { return is_lower_key(it.first, l_key); };
309 auto it = std::lower_bound(items.begin(), items.end(), key, fnc);
310 if (it != items.end() && it->first != key)
311 return items.end();
312 return it;
313}
std::pair< TrKey, Transform3d > TrItem
Definition RaycastManager.hpp:34
std::pair< size_t, size_t > TrKey
Definition RaycastManager.hpp:33
bool is_lower_key(const RaycastManager::TrKey &k1, const RaycastManager::TrKey &k2)
Definition RaycastManager.cpp:31

References find(), and 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 )
298 {
299 auto fnc = [](const RaycastManager::TrItem &it, const RaycastManager::TrKey &l_key) { return is_lower_key(it.first, l_key); };
300 auto it = std::lower_bound(items.begin(), items.end(), key, fnc);
301 if (it != items.end() && it->first != key)
302 return items.end();
303 return it;
304}

References find(), and is_lower_key().

Referenced by find(), and find().

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

◆ get_mesh()

const Slic3r::AABBMesh * anonymous_namespace{RaycastManager.cpp}::get_mesh ( const RaycastManager::Meshes & meshes,
size_t volume_id )
290{
291 auto is_lower_index = [](const RaycastManager::Mesh &m, size_t i) { return m.first < i; };
292 auto it = std::lower_bound(meshes.begin(), meshes.end(), volume_id, is_lower_index);
293 if (it == meshes.end() || it->first != volume_id)
294 return nullptr;
295 return &(*(it->second));
296}

References get_mesh().

Referenced by get_mesh().

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

◆ is_lower()

bool anonymous_namespace{RaycastManager.cpp}::is_lower ( const RaycastManager::TrItem & i1,
const RaycastManager::TrItem & i2 )
33 {
34 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 )
31 {
32 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: