Mesh: consider placement in MeshPy::nearestFacetOnRay

This commit is contained in:
wmayer
2022-08-04 20:47:33 +02:00
parent d7efe8358f
commit 0b4fcb8f20
4 changed files with 51 additions and 43 deletions

View File

@@ -815,6 +815,32 @@ std::vector<PointIndex> MeshObject::getPointsFromFacets(const std::vector<FacetI
return _kernel.GetFacetPoints(facets);
}
bool MeshObject::nearestFacetOnRay(const MeshObject::TRay& ray, double maxAngle, MeshObject::TFaceSection& output) const
{
Base::Vector3f pnt = Base::toVector<float>(ray.first);
Base::Vector3f dir = Base::toVector<float>(ray.second);
Base::Placement plm = getPlacement();
Base::Placement inv = plm.inverse();
// transform the ray relative to the mesh kernel
inv.multVec(pnt, pnt);
inv.getRotation().multVec(dir, dir);
FacetIndex index = 0;
Base::Vector3f res;
MeshCore::MeshAlgorithm alg(getKernel());
if (alg.NearestFacetOnRay(pnt, dir, static_cast<float>(maxAngle), res, index)) {
plm.multVec(res, res);
output.first = index;
output.second = Base::toVector<double>(res);
return true;
}
return false;
}
void MeshObject::updateMesh(const std::vector<FacetIndex>& facets) const
{
std::vector<PointIndex> points;