MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / NearestPointFromPoint

Method NearestPointFromPoint

src/Mod/Mesh/App/Core/Algorithm.cpp:1498–1525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496}
1497
1498bool MeshAlgorithm::NearestPointFromPoint(
1499 const Base::Vector3f& rclPt,
1500 FacetIndex& rclResFacetIndex,
1501 Base::Vector3f& rclResPoint
1502) const
1503{
1504 if (_rclMesh.CountFacets() == 0) {
1505 return false;
1506 }
1507
1508 // calc each facet
1509 float fMinDist = std::numeric_limits<float>::max();
1510 FacetIndex ulInd = FACET_INDEX_MAX;
1511 MeshFacetIterator pF(_rclMesh);
1512 for (pF.Init(); pF.More(); pF.Next()) {
1513 float fDist = pF->DistanceToPoint(rclPt);
1514 if (fDist < fMinDist) {
1515 fMinDist = fDist;
1516 ulInd = pF.Position();
1517 }
1518 }
1519
1520 MeshGeomFacet rclSFacet = _rclMesh.GetFacet(ulInd);
1521 rclSFacet.DistanceToPoint(rclPt, rclResPoint);
1522 rclResFacetIndex = ulInd;
1523
1524 return true;
1525}
1526
1527bool MeshAlgorithm::NearestPointFromPoint(
1528 const Base::Vector3f& rclPt,

Callers

nothing calls this directly

Calls 8

maxFunction · 0.85
DistanceToPointMethod · 0.80
InitMethod · 0.45
MoreMethod · 0.45
NextMethod · 0.45
PositionMethod · 0.45
GetFacetMethod · 0.45

Tested by

no test coverage detected