Skip to content

Commit

Permalink
Revert "Fix issue#86"
Browse files Browse the repository at this point in the history
This reverts commit 4477641.

Use of GeomAPI_ProjectPointOnSurf in OCCGeomRepresentation::projectPointOn proved to be controversial
  • Loading branch information
nicolaslg committed Dec 8, 2024
1 parent 5643780 commit 11165d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
51 changes: 15 additions & 36 deletions src/Core/Geom/OCCGeomRepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,7 @@ void OCCGeomRepresentation::project(const Utils::Math::Point& P1, Utils::Math::P
/*----------------------------------------------------------------------------*/
void OCCGeomRepresentation::projectPointOn( Utils::Math::Point& P)
{

if(!m_shape.IsNull() && m_shape.ShapeType()==TopAbs_VERTEX)
{
gp_Pnt pnt = BRep_Tool::Pnt(TopoDS::Vertex(m_shape));
Expand All @@ -1790,42 +1791,20 @@ void OCCGeomRepresentation::projectPointOn( Utils::Math::Point& P)
else
{
gp_Pnt pnt(P.getX(),P.getY(),P.getZ());

// issue#86 : dans le cas des surfaces, si la surface est toute petite,
// il faut projeter avec GeomAPI_ProjectPointOnSurf au lieu de
// BRepExtrema_DistShapeShape pour éviter les imprécisions numériques.
bool is_done = false;
if (m_shape.ShapeType()==TopAbs_FACE && computeSurfaceArea()<getPrecision()) {
// Initialisation du projecteur
TopoDS_Face face = TopoDS::Face(m_shape);
Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
GeomAPI_ProjectPointOnSurf projector;
projector.Init(pnt, surface);

// Si la projection est réussie
if (projector.NbPoints() > 0) {
gp_Pnt pnt2 = projector.NearestPoint(); // Point projeté le plus proche
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
is_done = true;
}
}

if (!is_done) {
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(pnt);
BRepExtrema_DistShapeShape extrema(V, m_shape);
bool isDone = extrema.IsDone();
if(!isDone) {
isDone = extrema.Perform();
}

if(!isDone){
std::cerr<<"OCCGeomRepresentation::projectPointOn("<<P<<")\n";
throw TkUtil::Exception("Echec d'une projection d'un point sur une courbe ou surface!!");

}
gp_Pnt pnt2 = extrema.PointOnShape2(1);
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
}
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(pnt);
BRepExtrema_DistShapeShape extrema(V, m_shape);
bool isDone = extrema.IsDone();
if(!isDone) {
isDone = extrema.Perform();
}

if(!isDone){
std::cerr<<"OCCGeomRepresentation::projectPointOn("<<P<<")\n";
throw TkUtil::Exception("Echec d'une projection d'un point sur une courbe ou surface!!");

}
gp_Pnt pnt2 = extrema.PointOnShape2(1);
P.setXYZ(pnt2.X(), pnt2.Y(), pnt2.Z());
// std::cout<<"OCCGeomRepresentation::projectPointOn("<<pnt.X()<<", "<<pnt.Y()<<", "<<pnt.Z()
// <<") => "<<pnt2.X()<<", "<<pnt2.Y()<<", "<<pnt2.Z()<<" distance : "<<pnt.Distance(pnt2)<<std::endl;
}
Expand Down
1 change: 1 addition & 0 deletions test_link/test_issue35.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import pyMagix3D as Mgx3D

# Test que le découpage en o-grid n'est PAS fait quand la contrainte d'Euler n'est pas vérifiée
Expand Down

0 comments on commit 11165d8

Please sign in to comment.