X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMAlgo%2FGEOMAlgo_FinderShapeOn2.cxx;h=34509300b603865b87b9ecfdb93be0e51a797463;hb=HEAD;hp=e2e34de0fefe009075e38d742c2ee8e4c4bd879e;hpb=5e3080a50e2ddb3beb564c81d4b8b5aa62fe86e3;p=modules%2Fgeom.git diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx index e2e34de0f..34509300b 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -33,6 +33,8 @@ #include #include +#include + #include #include #include @@ -68,12 +70,7 @@ #include #include #include - -#if OCC_VERSION_LARGE > 0x06070100 #include -#else -#include -#endif //======================================================================= //function : @@ -349,7 +346,7 @@ void GEOMAlgo_FinderShapeOn2::ProcessEdges() // Standard_Boolean bIsConformState, bIsToBreak; Standard_Integer i, aNb, iCnt, iErr; - TopAbs_State aSt; + TopAbs_State aSt = TopAbs_UNKNOWN; // todo: aSt must be explicitly initilized to avoid warning (see below) TopTools_IndexedMapOfShape aM; TopExp_Explorer aExp; GEOMAlgo_ListIteratorOfListOfPnt aIt; @@ -383,7 +380,7 @@ void GEOMAlgo_FinderShapeOn2::ProcessEdges() } // if (BRep_Tool::Degenerated(aE)) { - myMSS.Add(aE, aSt); + myMSS.Add(aE, aSt); // todo: aSt must be explicitly initilized to avoid warning (see above) continue; } // @@ -599,7 +596,7 @@ void GEOMAlgo_FinderShapeOn2::ProcessSolids() void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, GEOMAlgo_ListOfPnt& aLP) { - Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds; + Standard_Integer j, j1, j2, k, n[4], aNx, aNb, iCnt;//, aNbLinks, aNbMax, *pIds; TopLoc_Location aLoc; Handle(Poly_Triangulation) aTRF; TColStd_MapOfInteger aMBN; @@ -611,24 +608,21 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, // aLP.Clear(); // - aTRF=BRep_Tool::Triangulation(aF, aLoc); - if (aTRF.IsNull()) { - if (!BuildTriangulation(aF)) { - myWarningStatus=20; // no triangulation found - return; - } - aTRF=BRep_Tool::Triangulation(aF, aLoc); + if (!GEOMUtils::MeshShape(aF, /*deflection*/0.001, /*forced*/false, + /*angle deflection*/0.349066, /*isRelative*/true, + /*doPostCheck*/true)) { + myWarningStatus=20; // no triangulation found + return; } + aTRF=BRep_Tool::Triangulation(aF, aLoc); // const gp_Trsf& aTrsf=aLoc.Transformation(); - const Poly_Array1OfTriangle& aTrs=aTRF->Triangles(); - const TColgp_Array1OfPnt& aNodes=aTRF->Nodes(); // // map link/nbtriangles - j1=aTrs.Lower(); - j2=aTrs.Upper(); + j1 = 1; + j2 = aTRF->NbTriangles(); for (j=j1; j<=j2; ++j) { - const Poly_Triangle& aTr=aTrs(j); + const Poly_Triangle& aTr = aTRF->Triangle(j); aTr.Get(n[0], n[1], n[2]); n[3]=n[0]; for (k=0; k<3; ++k) { @@ -646,7 +640,6 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, } // // boundary nodes aMBN - aNbLinks=aMPKI.Extent(); aIt.Initialize(aMPKI); for (; aIt.More(); aIt.Next()) { iCnt=aIt.Value(); @@ -661,11 +654,11 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, } // // inner nodes=all_nodes - boundary_nodes - j1=aNodes.Lower(); - j2=aNodes.Upper(); + j1=1; + j2=aTRF->NbNodes(); for (j=j1; j<=j2; ++j) { if (!aMBN.Contains(j)) { - aP=aNodes(j).Transformed(aTrsf); + aP=aTRF->Node(j).Transformed(aTrsf); aLP.Append(aP); } } @@ -753,16 +746,15 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, gp_Pnt aP; // aLP.Clear(); + if (!GEOMUtils::MeshShape(aE, /*deflection*/0.001, /*forced*/false, + /*angle deflection*/0.349066, /*isRelative*/true, + /*doPostCheck*/true)) { + myErrorStatus=20; // no triangulation found + return; + } BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc); if (aTRE.IsNull() || aPTE.IsNull()) { Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc); - if (aPE.IsNull()) { - if (!BuildTriangulation(aE)) { - myErrorStatus=20; // no triangulation found - return; - } - aPE = BRep_Tool::Polygon3D(aE, aLoc); - } const gp_Trsf& aTrsf=aLoc.Transformation(); const TColgp_Array1OfPnt& aNodes=aPE->Nodes(); // @@ -775,13 +767,12 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, } else { const gp_Trsf& aTrsf=aLoc.Transformation(); - const TColgp_Array1OfPnt& aNodes=aTRE->Nodes(); // aNbNodes=aPTE->NbNodes(); const TColStd_Array1OfInteger& aInds=aPTE->Nodes(); for (j=2; jNode(aIndex).Transformed(aTrsf); aLP.Append(aP); } } @@ -828,59 +819,6 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, } } -//======================================================================= -//function : BuildTriangulation -//purpose : -//======================================================================= -Standard_Boolean - GEOMAlgo_FinderShapeOn2::BuildTriangulation (const TopoDS_Shape& theShape) -{ - // calculate deflection - Standard_Real aDeviationCoefficient = 0.001; - - Bnd_Box B; - BRepBndLib::Add(theShape, B); - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - - Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin; - Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4; - Standard_Real aHLRAngle = 0.349066; - - // build triangulation - BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle); - - // check triangulation - bool isTriangulation = true; - - TopExp_Explorer exp (theShape, TopAbs_FACE); - if (exp.More()) - { - TopLoc_Location aTopLoc; - Handle(Poly_Triangulation) aTRF; - aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc); - if (aTRF.IsNull()) { - isTriangulation = false; - } - } - else // no faces, try edges - { - TopExp_Explorer expe (theShape, TopAbs_EDGE); - if (!expe.More()) { - isTriangulation = false; - } - else { - TopLoc_Location aLoc; - Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc); - if (aPE.IsNull()) { - isTriangulation = false; - } - } - } - - return isTriangulation; -} - // // myErrorStatus : //