Skip to content
Snippets Groups Projects
Commit b65664e6 authored by Tom Fischer's avatar Tom Fischer
Browse files

[GL] Impl. of PointVec::resetInternalDataStructures.

If the coordinates of a point managed by PointVec are modified from outside the internal data structures must be updated. I.e., the AABB needs maybe an update. But more important if the point is moved
in general it has to be moved also in the OctTree.
parent 7016c443
No related branches found
No related tags found
No related merge requests found
......@@ -249,4 +249,25 @@ void PointVec::setNameForElement(std::size_t id, std::string const& name)
_id_to_name_map[id] = name;
}
void PointVec::resetInternalDataStructures()
{
MathLib::Point3d const& min(_aabb.getMinPoint());
MathLib::Point3d const& max(_aabb.getMaxPoint());
double const rel_eps(_rel_eps / std::sqrt(MathLib::sqrDist(min, max)));
_aabb = GeoLib::AABB(_data_vec->begin(), _data_vec->end());
_rel_eps = rel_eps * std::sqrt(MathLib::sqrDist(_aabb.getMinPoint(),
_aabb.getMaxPoint()));
_oct_tree.reset(OctTree<GeoLib::Point, 16>::createOctTree(
_aabb.getMinPoint(), _aabb.getMaxPoint(), _rel_eps));
GeoLib::Point* ret_pnt(nullptr);
for (auto const p : *_data_vec)
{
_oct_tree->addPoint(p, ret_pnt);
}
}
} // end namespace
......@@ -103,6 +103,12 @@ public:
void setNameForElement(std::size_t id, std::string const& name) override;
/// Resets the internal data structures, i.e., the axis aligned bounding
/// box, the relative epsilon for the equality tests and the oct tree data
/// structure.
/// \note This method have to be called if the coordinates of a point stored
/// by the PointVec is modified from outside.
void resetInternalDataStructures();
private:
/**
* After the point set is modified (for example by makePntsUnique()) the mapping has to be corrected.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment