Skip to content

Commit 16d728a

Browse files
committed
Revert "Fix issue#86"
This reverts commit 4477641. We keep the modification to the removal of "import sys in "test_issue_35.py, which is unrelated. Use of GeomAPI_ProjectPointOnSurf in OCCGeomRepresentation::projectPointOn proved to be controversial
1 parent 5643780 commit 16d728a

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

src/Core/Geom/OCCGeomRepresentation.cpp

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ void OCCGeomRepresentation::project(const Utils::Math::Point& P1, Utils::Math::P
17821782
/*----------------------------------------------------------------------------*/
17831783
void OCCGeomRepresentation::projectPointOn( Utils::Math::Point& P)
17841784
{
1785+
17851786
if(!m_shape.IsNull() && m_shape.ShapeType()==TopAbs_VERTEX)
17861787
{
17871788
gp_Pnt pnt = BRep_Tool::Pnt(TopoDS::Vertex(m_shape));
@@ -1790,42 +1791,20 @@ void OCCGeomRepresentation::projectPointOn( Utils::Math::Point& P)
17901791
else
17911792
{
17921793
gp_Pnt pnt(P.getX(),P.getY(),P.getZ());
1793-
1794-
// issue#86 : dans le cas des surfaces, si la surface est toute petite,
1795-
// il faut projeter avec GeomAPI_ProjectPointOnSurf au lieu de
1796-
// BRepExtrema_DistShapeShape pour éviter les imprécisions numériques.
1797-
bool is_done = false;
1798-
if (m_shape.ShapeType()==TopAbs_FACE && computeSurfaceArea()<getPrecision()) {
1799-
// Initialisation du projecteur
1800-
TopoDS_Face face = TopoDS::Face(m_shape);
1801-
Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
1802-
GeomAPI_ProjectPointOnSurf projector;
1803-
projector.Init(pnt, surface);
1804-
1805-
// Si la projection est réussie
1806-
if (projector.NbPoints() > 0) {
1807-
gp_Pnt pnt2 = projector.NearestPoint(); // Point projeté le plus proche
1808-
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
1809-
is_done = true;
1810-
}
1811-
}
1812-
1813-
if (!is_done) {
1814-
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(pnt);
1815-
BRepExtrema_DistShapeShape extrema(V, m_shape);
1816-
bool isDone = extrema.IsDone();
1817-
if(!isDone) {
1818-
isDone = extrema.Perform();
1819-
}
1820-
1821-
if(!isDone){
1822-
std::cerr<<"OCCGeomRepresentation::projectPointOn("<<P<<")\n";
1823-
throw TkUtil::Exception("Echec d'une projection d'un point sur une courbe ou surface!!");
1824-
1825-
}
1826-
gp_Pnt pnt2 = extrema.PointOnShape2(1);
1827-
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
1828-
}
1794+
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(pnt);
1795+
BRepExtrema_DistShapeShape extrema(V, m_shape);
1796+
bool isDone = extrema.IsDone();
1797+
if(!isDone) {
1798+
isDone = extrema.Perform();
1799+
}
1800+
1801+
if(!isDone){
1802+
std::cerr<<"OCCGeomRepresentation::projectPointOn("<<P<<")\n";
1803+
throw TkUtil::Exception("Echec d'une projection d'un point sur une courbe ou surface!!");
1804+
1805+
}
1806+
gp_Pnt pnt2 = extrema.PointOnShape2(1);
1807+
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
18291808
// std::cout<<"OCCGeomRepresentation::projectPointOn("<<pnt.X()<<", "<<pnt.Y()<<", "<<pnt.Z()
18301809
// <<") => "<<pnt2.X()<<", "<<pnt2.Y()<<", "<<pnt2.Z()<<" distance : "<<pnt.Distance(pnt2)<<std::endl;
18311810
}

0 commit comments

Comments
 (0)