From: skv Date: Mon, 17 Jun 2013 07:20:09 +0000 (+0000) Subject: 0021835: EDF 2070 GEOM : Problem with detecting Self-intersections X-Git-Tag: BR_hydro_v_0_3_1~202 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ddc7178e65bbe4a7a11a07e0eb5fd223bf73dc2;p=modules%2Fgeom.git 0021835: EDF 2070 GEOM : Problem with detecting Self-intersections --- diff --git a/src/NMTTools/NMTTools_PaveFiller_2.cxx b/src/NMTTools/NMTTools_PaveFiller_2.cxx index 19792f45b..98c045691 100644 --- a/src/NMTTools/NMTTools_PaveFiller_2.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_2.cxx @@ -27,6 +27,7 @@ #include #include +#include #include @@ -117,7 +118,7 @@ void NMTTools_PaveFiller::PerformVE() } // Edge aE2=TopoDS::Edge(myDS->Shape(aWith)); - if (BRep_Tool::Degenerated(aE2)){ + if (NMTTools_Tools::IsDegenerated(aE2)){ continue; } // Vertex @@ -221,7 +222,7 @@ void NMTTools_PaveFiller::PrepareEdges() if (myDS->GetShapeType(i)==TopAbs_EDGE) { aE=TopoDS::Edge(myDS->Shape(i)); // - if (BRep_Tool::Degenerated(aE)){ + if (NMTTools_Tools::IsDegenerated(aE)){ continue; } // diff --git a/src/NMTTools/NMTTools_PaveFiller_4.cxx b/src/NMTTools/NMTTools_PaveFiller_4.cxx index 397481e95..ef774277e 100644 --- a/src/NMTTools/NMTTools_PaveFiller_4.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_4.cxx @@ -24,6 +24,7 @@ // Author: Peter KURNEV #include +#include #include #include @@ -184,7 +185,8 @@ void NMTTools_PaveFiller::PerformEE() const TopoDS_Edge aE1=TopoDS::Edge(myDS->Shape(nE1));//mpv const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv // - if (BRep_Tool::Degenerated(aE1) || BRep_Tool::Degenerated(aE2)){ + if (NMTTools_Tools::IsDegenerated(aE1) || + NMTTools_Tools::IsDegenerated(aE2)){ continue; } // @@ -955,7 +957,7 @@ void NMTTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE) BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); // Edge aE=TopoDS::Edge(myDS->Shape(nE)); - if (BRep_Tool::Degenerated(aE)) { + if (NMTTools_Tools::IsDegenerated(aE)) { myIsDone=Standard_True; return; } diff --git a/src/NMTTools/NMTTools_PaveFiller_5.cxx b/src/NMTTools/NMTTools_PaveFiller_5.cxx index 4ee66534c..f97bf9601 100644 --- a/src/NMTTools/NMTTools_PaveFiller_5.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_5.cxx @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,7 @@ #include #include #include +#include static @@ -146,7 +148,7 @@ static // // Edge const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE)); - if (BRep_Tool::Degenerated(aE)){ + if (NMTTools_Tools::IsDegenerated(aE)){ continue; } // @@ -199,6 +201,8 @@ static BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); aEF.SetRange (anewSR); // + BRepTools::Write(aE, "/dn20/salome/skv/SALOME/scripts/Dumps/edge"); + BRepTools::Write(aF, "/dn20/salome/skv/SALOME/scripts/Dumps/face"); aEF.Perform(); // if (aEF.IsDone()) { diff --git a/src/NMTTools/NMTTools_PaveFiller_6.cxx b/src/NMTTools/NMTTools_PaveFiller_6.cxx index 3d7270c90..81df58ce8 100644 --- a/src/NMTTools/NMTTools_PaveFiller_6.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_6.cxx @@ -782,7 +782,7 @@ void NMTTools_PaveFiller::MakePCurves() } const TopoDS_Edge& aE=TopoDS::Edge(aS); // - if (BRep_Tool::Degenerated(aE)) { + if (NMTTools_Tools::IsDegenerated(aE)) { continue; } // diff --git a/src/NMTTools/NMTTools_PaveFiller_7.cxx b/src/NMTTools/NMTTools_PaveFiller_7.cxx index e8c228237..2ffafd19f 100644 --- a/src/NMTTools/NMTTools_PaveFiller_7.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_7.cxx @@ -24,6 +24,7 @@ // Author: Peter KURNEV #include +#include #include #include @@ -108,7 +109,7 @@ void NMTTools_PaveFiller::MakeSplitEdges() // // Original Edge aE=TopoDS::Edge(myDS->Shape(i)); - if (BRep_Tool::Degenerated(aE)){ + if (NMTTools_Tools::IsDegenerated(aE)){ continue; } // @@ -198,7 +199,7 @@ void NMTTools_PaveFiller::UpdateCommonBlocks(const Standard_Integer) } // const TopoDS_Edge& aE=*((TopoDS_Edge*)&myDS->Shape(nE)); - if (BRep_Tool::Degenerated(aE)){ + if (NMTTools_Tools::IsDegenerated(aE)){ continue; } // @@ -371,7 +372,7 @@ void NMTTools_PaveFiller::UpdateCommonBlocks() if (myDS->GetShapeType(nE)!=TopAbs_EDGE){ continue; } - if (BRep_Tool::Degenerated(TopoDS::Edge(myDS->Shape(nE)))){ + if (NMTTools_Tools::IsDegenerated(TopoDS::Edge(myDS->Shape(nE)))){ continue; } // @@ -489,7 +490,7 @@ void NMTTools_PaveFiller::UpdatePaveBlocks() for(; aExp.More(); aExp.Next()) { aE=TopoDS::Edge(aExp.Current()); // - if (BRep_Tool::Degenerated(aE)) { + if (NMTTools_Tools::IsDegenerated(aE)) { continue; } // diff --git a/src/NMTTools/NMTTools_Tools.cxx b/src/NMTTools/NMTTools_Tools.cxx index 8f6588d5c..9ae202c8a 100644 --- a/src/NMTTools/NMTTools_Tools.cxx +++ b/src/NMTTools/NMTTools_Tools.cxx @@ -73,6 +73,7 @@ #include #include #include +#include static void ProcessBlock(const Standard_Integer iV, @@ -612,3 +613,39 @@ void ProcessBlock(const TopoDS_Shape& aF, ProcessBlock(aFx, aMCV, aProcessed, aChain); } } + +//======================================================================= +// function: IsDegenerated +// purpose : +//======================================================================= +Standard_Boolean NMTTools_Tools::IsDegenerated(const TopoDS_Edge &theEdge) +{ + Standard_Boolean aResult = BRep_Tool::Degenerated(theEdge); + + if (!aResult) { + // Check if there is a null-length 3d curve. + Standard_Real aF; + Standard_Real aL; + Handle(Geom_Curve) aCrv = BRep_Tool::Curve(theEdge, aF, aL); + + aResult = aCrv.IsNull(); + + if (!aResult) { + const Standard_Real aTolConf2 = + Precision::Confusion()*Precision::Confusion(); + gp_Pnt aPnt[2] = { aCrv->Value(aF), aCrv->Value(aL) }; + + if (aPnt[0].SquareDistance(aPnt[1]) <= aTolConf2) { + // Check the middle point. + const gp_Pnt aPMid = aCrv->Value(0.5*(aF + aL)); + + if (aPnt[0].SquareDistance(aPMid) <= aTolConf2) { + // 3D curve is degenerated. + aResult = Standard_True; + } + } + } + } + + return aResult; +} diff --git a/src/NMTTools/NMTTools_Tools.hxx b/src/NMTTools/NMTTools_Tools.hxx index 5924d02a9..7bb2f87cb 100644 --- a/src/NMTTools/NMTTools_Tools.hxx +++ b/src/NMTTools/NMTTools_Tools.hxx @@ -95,5 +95,8 @@ class NMTTools_Tools { static void UpdateEdge(const TopoDS_Edge& aE, const Standard_Real aTol) ; + Standard_EXPORT + static Standard_Boolean IsDegenerated(const TopoDS_Edge &theEdge); + }; #endif