From 981c0534ea7fd1bfe4806ef05b4d64c6e1ecd2ed Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 15 Jan 2024 13:37:48 +0000 Subject: [PATCH] Porting to OCCT 7.8.0 --- src/BlockFix/BlockFix_SphereSpaceModifier.cxx | 10 + src/GEOMAlgo/CMakeLists.txt | 3 - src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx | 52 -- src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx | 3 - src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx | 6 + .../GEOMAlgo_DataMapOfPassKeyInteger.hxx | 14 + src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx | 611 -------------- src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx | 125 --- src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx | 787 ------------------ src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.hxx | 145 ---- src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx | 81 +- src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx | 3 - src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx | 144 ---- src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx | 61 -- .../GEOMAlgo_IndexedDataMapOfIntegerShape.hxx | 12 + src/GEOMAlgo/GEOMAlgo_PassKey.cxx | 2 + src/GEOMAlgo/GEOMAlgo_PassKey.hxx | 25 + src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx | 17 + src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx | 11 + src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx | 12 + src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx | 13 + .../GEOMAlgo_PassKeyShapeMapHasher.cxx | 17 + .../GEOMAlgo_PassKeyShapeMapHasher.hxx | 11 + src/GEOMGUI/GeometryGUI.cxx | 5 +- src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx | 9 +- src/GEOMImpl/GEOMImpl_ITestOperations.cxx | 24 +- .../GEOMImpl_ShapeProximityDriver.cxx | 28 +- src/GEOMUtils/GEOMUtils.cxx | 188 +++-- src/GEOMUtils/GEOMUtils.hxx | 45 +- src/OCC2VTK/OCC2VTK_Tools.cxx | 1 - src/STEPPlugin/STEPPlugin_ExportDriver.cxx | 14 +- src/STLPlugin/STLPlugin_ExportDriver.cxx | 1 + 32 files changed, 331 insertions(+), 2149 deletions(-) delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.hxx delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx delete mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx diff --git a/src/BlockFix/BlockFix_SphereSpaceModifier.cxx b/src/BlockFix/BlockFix_SphereSpaceModifier.cxx index 50c67b212..c52d2a92f 100644 --- a/src/BlockFix/BlockFix_SphereSpaceModifier.cxx +++ b/src/BlockFix/BlockFix_SphereSpaceModifier.cxx @@ -138,6 +138,9 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& theFace, gp_Ax3 ax3 = sp.Position(); if (Abs(Vmax-Vmin) < PI2) { gp_Ax3 axnew3 (ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(), ax3.XDirection()); + if (!ax3.Direct()) { + axnew3.YReverse(); + } sp.SetPosition(axnew3); Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); theNewSurface = aNewSphere; @@ -157,6 +160,9 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& theFace, gp_Dir newNorm(gp_Vec(PC,PN)); gp_Dir newDirX(gp_Vec(PC,PX)); gp_Ax3 axnew3(ax3.Axis().Location(), newNorm, newDirX); + if (!ax3.Direct()) { + axnew3.YReverse(); + } sp.SetPosition(axnew3); // check if both new poles are outside theFace @@ -276,6 +282,10 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& theFace, } gp_Ax3 anAxisOfNewSphere (aCentre, anUp, XDirOfCircle); + gp_Ax3 ax3 = sp.Position(); + if (!ax3.Direct()) { + anAxisOfNewSphere.YReverse(); + } theNewSurface = new Geom_SphericalSurface (anAxisOfNewSphere, Radius); break; } //for (; itw.More(); itw.Next()) (iteration on outer wire) diff --git a/src/GEOMAlgo/CMakeLists.txt b/src/GEOMAlgo/CMakeLists.txt index 8a75aa730..39585b771 100644 --- a/src/GEOMAlgo/CMakeLists.txt +++ b/src/GEOMAlgo/CMakeLists.txt @@ -60,10 +60,7 @@ SET(GEOMAlgo_HEADERS GEOMAlgo_DataMapOfShapeMapOfShape.hxx GEOMAlgo_DataMapOfShapePnt.hxx GEOMAlgo_Extractor.hxx - GEOMAlgo_FinderShapeOn.hxx - GEOMAlgo_FinderShapeOn1.hxx GEOMAlgo_FinderShapeOn2.hxx - GEOMAlgo_FinderShapeOnQuad.hxx GEOMAlgo_GetInPlace.hxx GEOMAlgo_GetInPlaceAPI.hxx GEOMAlgo_GlueAnalyser.hxx diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx index 82401d0c9..7e9cc0b1b 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx @@ -80,7 +80,6 @@ #include #include #include -#include #include #include @@ -834,57 +833,6 @@ Standard_Integer GEOMAlgo_AlgoTools::RefineSDShapes // return 0; } -//======================================================================= -//function : BuildTriangulation -//purpose : -//======================================================================= -Standard_Boolean - GEOMAlgo_AlgoTools::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; -} //======================================================================= //function : IsCompositeShape diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx index 793373fc0..2d318a1dc 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx @@ -87,9 +87,6 @@ class GEOMAlgo_AlgoTools { static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ; - Standard_EXPORT - static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ; - Standard_EXPORT static Standard_Integer RefineSDShapes (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD, diff --git a/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx b/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx index 20a6e6033..039486cbe 100644 --- a/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx +++ b/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx @@ -25,10 +25,16 @@ #ifndef _GEOMAlgo_ClsfSolid_HeaderFile #define _GEOMAlgo_ClsfSolid_HeaderFile +#include + #include #include #include +#if OCC_VERSION_LARGE < 0x07080000 #include +#else +#include +#endif #include DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf) diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx index 2dbddd353..973834342 100644 --- a/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx @@ -25,14 +25,28 @@ #ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile #define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile +#include + #include #include + +#if OCC_VERSION_LARGE < 0x07080000 #include #define _NCollection_MapHasher #include typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyInteger; + +#else + +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyInteger; + +#endif // OCC_VERSION_LARGE < 0x07080000 + + typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger; #undef _NCollection_MapHasher diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx deleted file mode 100644 index bf84c454c..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx +++ /dev/null @@ -1,611 +0,0 @@ -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File: GEOMAlgo_FinderShapeOn.cxx -// Created: Tue Jan 11 14:44:31 2005 -// Author: Peter KURNEV - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -//======================================================================= -//function : GEOMAlgo_FinderShapeOn -//purpose : -//======================================================================= -GEOMAlgo_FinderShapeOn::GEOMAlgo_FinderShapeOn() -: - GEOMAlgo_ShapeAlgo() -{ - myTolerance=0.0001; - myShapeType=TopAbs_VERTEX; - myState=GEOMAlgo_ST_UNKNOWN; - myIsAnalytic=Standard_True; -} -//======================================================================= -//function : ~ -//purpose : -//======================================================================= -GEOMAlgo_FinderShapeOn::~GEOMAlgo_FinderShapeOn() -{ -} -//======================================================================= -//function : SetSurface -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::SetSurface(const Handle(Geom_Surface)& aS) -{ - mySurface=aS; -} -//======================================================================= -//function : Surface -//purpose : -//======================================================================= -const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn::Surface() const -{ - return mySurface; -} -//======================================================================= -//function : SetShapeType -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::SetShapeType(const TopAbs_ShapeEnum aType) -{ - myShapeType=aType; -} -//======================================================================= -//function : ShapeType -//purpose : -//======================================================================= -TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::ShapeType()const -{ - return myShapeType; -} -//======================================================================= -//function : SetState -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::SetState(const GEOMAlgo_State aState) -{ - myState=aState; -} -//======================================================================= -//function : State -//purpose : -//======================================================================= -GEOMAlgo_State GEOMAlgo_FinderShapeOn::State() const -{ - return myState; -} -//======================================================================= -// function: Shapes -// purpose: -//======================================================================= -const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn::Shapes() const -{ - Standard_Boolean bIsConformState; - Standard_Integer i, aNb; - TopAbs_State aSt; - TopTools_ListOfShape* pL; - // - pL=(TopTools_ListOfShape*) &myLS; - pL->Clear(); - // - aNb=myMSS.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=myMSS.FindKey(i); - aSt=myMSS.FindFromIndex(i); - // - bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); - if (bIsConformState) { - pL->Append(aS); - } - } - return myLS; -} -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::Perform() -{ - myErrorStatus=0; - myWarningStatus=0; - myLS.Clear(); - myMSS.Clear(); - // - if (!myResult.IsNull()){ - myResult.Nullify(); - } - // - CheckData(); - if(myErrorStatus) { - return; - } - // - // Initialize the context - GEOMAlgo_ShapeAlgo::Perform(); - // - myIsAnalytic=GEOMAlgo_SurfaceTools::IsAnalytic(mySurface); - // - MakeArgument1(); - if(myErrorStatus) { - return; - } - // - if (myIsAnalytic && myShapeType==TopAbs_VERTEX) { - FindVertices(); - return; - } - // - MakeArgument2(); - if(myErrorStatus) { - return; - } - // - Find(); - if(myErrorStatus || myWarningStatus) { - return; - } - // -} -//======================================================================= -//function : FindVertices -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::FindVertices() -{ - Standard_Integer i, aNb, iErr; - TopAbs_State aSt; - TopAbs_Orientation aOr; - gp_Pnt aP; - TopTools_IndexedMapOfShape aM; - // - TopExp::MapShapes(myArg1, TopAbs_FACE, aM); - const TopoDS_Face& aF=TopoDS::Face(aM(1)); - aOr=aF.Orientation(); - // - aM.Clear(); - TopExp::MapShapes(myShape, myShapeType, aM); - aNb=aM.Extent(); - if (!aNb) { - myWarningStatus=10; // No found sub-shapes of type myShapeType - return; - } - // - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=aM(i); - const TopoDS_Vertex& aV=TopoDS::Vertex(aS); - aP=BRep_Tool::Pnt(aV); - iErr=GEOMAlgo_SurfaceTools::GetState(aP, mySurface, myTolerance, aSt); - if (aOr==TopAbs_REVERSED) { - aSt=GEOMAlgo_SurfaceTools::ReverseState(aSt); - } - myMSS.Add(aS, aSt); - } -} -//======================================================================= -//function : Find -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::Find() -{ - Standard_Integer i, aNb; - Standard_Boolean bICS; - TopTools_IndexedMapOfShape aM; - // - TopExp::MapShapes(myArg2, myShapeType, aM); - // - aNb=aM.Extent(); - if (!aNb) { - myWarningStatus=10; // No found sub-shapes of type myShapeType - return; - } - // - bICS=GEOMAlgo_AlgoTools::IsCompositeShape(myArg2); - if (!bICS || myIsAnalytic) { - TopoDS_Compound aCmp; - BRep_Builder aBB; - // - aBB.MakeCompound(aCmp); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aSi=aM(i); - aBB.Add(aCmp, aSi); - } - // - aM.Clear(); - aM.Add(aCmp); - aNb=1; - } - // - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=aM(i); - Find(aS); - if (myErrorStatus) { - return; - } - } -} -//======================================================================= -//function : Find -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::Find(const TopoDS_Shape& aS) -{ - myErrorStatus=0; - // - Standard_Integer i, iErr; - TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON}; - TopTools_ListIteratorOfListOfShape aIt; - BOPCol_ListOfShape aLS; - BOPAlgo_PaveFiller aPF; - // - // 1. Prepare DSFiller - aLS.Append(myArg1); - aLS.Append(aS); - aPF.SetArguments(aLS); - // - aPF.Perform(); - iErr=aPF.ErrorStatus(); - if (iErr) { - myErrorStatus=31; // PaveFiller is failed - return; - } - // - // 2. Find shapes - GEOMAlgo_ShapeSolid* pSS; - GEOMAlgo_VertexSolid aVXS; - GEOMAlgo_WireSolid aWRS; - GEOMAlgo_ShellSolid aSHS; - GEOMAlgo_SolidSolid aSLS; - // - pSS=NULL; - // - switch (myShapeType) { - case TopAbs_VERTEX: - pSS=&aVXS; - break; - case TopAbs_EDGE: - pSS=&aWRS; - break; - case TopAbs_FACE: - pSS=&aSHS; - break; - case TopAbs_SOLID: - aSLS.SetShape2(myArg2); - pSS=&aSLS; - break; - default: - myErrorStatus=12; // unallowed sub-shape type - return; - } - // - pSS->SetFiller(aPF); - pSS->Perform(); - iErr=pSS->ErrorStatus(); - if (iErr) { - myErrorStatus=32; // builder ShapeSolid failed - return; - } - // - for (i=0; i<3; ++i) { - const TopTools_ListOfShape& aLS=pSS->Shapes(aSts[i]); - aIt.Initialize(aLS); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSImage=aIt.Value(); - if (myImages.IsBound(aSImage)) { - const TopoDS_Shape& aSx=myImages.Find(aSImage); - myMSS.Add(aSx, aSts[i]); - } - else { - myErrorStatus=33;// can not find original shape - return; - } - } - } -} -//======================================================================= -//function : MakeArgument1 -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::MakeArgument1() -{ - myErrorStatus=0; - // - Standard_Integer i, aNb; - TopAbs_ShapeEnum aType; - BRepLib_FaceError aFErr; - BRepLib_MakeFace aMF; - TopTools_IndexedMapOfShape aM; - BRep_Builder aBB; - TopoDS_Face aFace; - TopoDS_Shell aSh; - TopoDS_Solid aSd; - // - // Argument 1 - if (!myIsAnalytic) { - aMF.Init(mySurface, Standard_True, Precision::Confusion()); - - aFErr=aMF.Error(); - if (aFErr!=BRepLib_FaceDone) { - myErrorStatus=20; // can not build the face - return; - } - // - const TopoDS_Shape& aF=aMF.Shape(); - aFace=TopoDS::Face(aF); - // - // update tolerances - aM.Add(aF); - TopExp::MapShapes(aF, TopAbs_VERTEX, aM); - TopExp::MapShapes(aF, TopAbs_EDGE, aM); - - aNb=aM.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=aM(i); - aType=aS.ShapeType(); - switch (aType) { - case TopAbs_VERTEX: { - const TopoDS_Vertex& aVx=TopoDS::Vertex(aS); - aBB.UpdateVertex(aVx, myTolerance); - } - break; - case TopAbs_EDGE: { - const TopoDS_Edge& aEx=TopoDS::Edge(aS); - aBB.UpdateEdge(aEx, myTolerance); - } - break; - case TopAbs_FACE: { - const TopoDS_Face& aFx=TopoDS::Face(aS); - aBB.UpdateFace(aFx, myTolerance); - } - break; - default: - break; - } - } - } // - else { - aBB.MakeFace(aFace, mySurface, myTolerance); - } - // - // make solid - aBB.MakeShell(aSh); - aBB.Add(aSh, aFace); - aBB.MakeSolid(aSd); - aBB.Add(aSd, aSh); - myArg1=aSd; -} -//======================================================================= -//function : MakeArgument2 -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::MakeArgument2() -{ - myErrorStatus=0; - // - TopoDS_Shape aSC; - TopTools_DataMapOfShapeShape aOriginals; - // - myImages.Clear(); - // - GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC); - // - myArg2=aSC; -} -//======================================================================= -//function : CheckData -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::CheckData() -{ - myErrorStatus=0; - // - if(mySurface.IsNull()) { - myErrorStatus=10; // mySurface=NULL - return; - } - // - if (myShape.IsNull()) { - myErrorStatus=11; // myShape=NULL - return; - } - // - if (!(myShapeType==TopAbs_VERTEX || - myShapeType==TopAbs_EDGE || - myShapeType==TopAbs_FACE || - myShapeType==TopAbs_SOLID)) { - myErrorStatus=12; // unallowed sub-shape type - return; - } - // - if (myState==GEOMAlgo_ST_UNKNOWN || - myState==GEOMAlgo_ST_INOUT) { - myErrorStatus=13; // unallowed state type - return; - } -} -// -//======================================================================= -//function : CopySource -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn::CopySource(const TopoDS_Shape& aE, - TopTools_DataMapOfShapeShape& aImages, - TopTools_DataMapOfShapeShape& aOriginals, - TopoDS_Shape& aEx) -{ - Standard_Boolean bFree; - TopAbs_ShapeEnum aType; - Standard_Integer aR; - BRep_Builder BB; - TopoDS_Iterator aIt; - // - aType=aE.ShapeType(); - // - if (aOriginals.IsBound(aE)) { - aEx=aOriginals.ChangeFind(aE); - return; - } - else { - aEx=aE.EmptyCopied(); - aOriginals.Bind(aE, aEx); - aImages.Bind(aEx, aE); - } - // - aR=(Standard_Integer)aType+1; - if (aR>TopAbs_VERTEX) { - return; - } - // - bFree=aEx.Free(); - aEx.Free(Standard_True); - // - aType=(TopAbs_ShapeEnum) aR; - // - aIt.Initialize(aE);//, Standard_False); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aV=aIt.Value(); - TopoDS_Shape aVx; - // - CopySource (aV, aImages, aOriginals, aVx); - // - aVx.Orientation(aV.Orientation()); - BB.Add(aEx, aVx); - } - // - aEx.Free(bFree); -} -// -//======================================================================= -//function : BuildTriangulation -//purpose : -//======================================================================= -Standard_Boolean - GEOMAlgo_FinderShapeOn::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 : -// -// 10 -mySurface=NULL -// 11 -myShape=NULL -// 12 -unallowed type of sub-shapes -// 13 -unallowed state -// 20 -can not build the face -// 30 -wrong args are used for DSFiller -// 31 -DSFiller failed -// 32 -builder ShapeSolid failed -// 33 -can not find original shape -// -// myWarningStatus -// -// 10 - sub-shapes of type myShapeType can not be fond in myShape diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx deleted file mode 100644 index cde1a3de5..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx +++ /dev/null @@ -1,125 +0,0 @@ - -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File: GEOMAlgo_FinderShapeOn.hxx -// Created: Tue Jan 11 14:44:31 2005 -// Author: Peter KURNEV - -#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile -#define _GEOMAlgo_FinderShapeOn_HeaderFile - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - - -#include -#include -#include - -//======================================================================= -//function : GEOMAlgo_FinderShapeOn -//purpose : -//======================================================================= -class GEOMAlgo_FinderShapeOn : public GEOMAlgo_ShapeAlgo -{ - public: - Standard_EXPORT - GEOMAlgo_FinderShapeOn(); - - Standard_EXPORT - virtual ~GEOMAlgo_FinderShapeOn(); - - Standard_EXPORT - virtual void Perform() ; - - Standard_EXPORT - void SetSurface(const Handle(Geom_Surface)& aS) ; - - Standard_EXPORT - void SetShapeType(const TopAbs_ShapeEnum aST) ; - - Standard_EXPORT - void SetState(const GEOMAlgo_State aSF) ; - - Standard_EXPORT - const Handle(Geom_Surface)& Surface() const; - - Standard_EXPORT - TopAbs_ShapeEnum ShapeType() const; - - Standard_EXPORT - GEOMAlgo_State State() const; - - Standard_EXPORT - const TopTools_ListOfShape& Shapes() const; - - Standard_EXPORT - static void CopySource(const TopoDS_Shape& aS, - TopTools_DataMapOfShapeShape& aImages, - TopTools_DataMapOfShapeShape& aOriginals, - TopoDS_Shape& aSC) ; - - Standard_EXPORT - static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ; - -protected: - Standard_EXPORT - virtual void CheckData() ; - - Standard_EXPORT - void MakeArgument1() ; - - Standard_EXPORT - void MakeArgument2() ; - - Standard_EXPORT - void Find() ; - - Standard_EXPORT - void Find(const TopoDS_Shape& aS) ; - - Standard_EXPORT - void FindVertices() ; - - - Handle(Geom_Surface) mySurface; - TopAbs_ShapeEnum myShapeType; - GEOMAlgo_State myState; - TopoDS_Shape myArg1; - TopoDS_Shape myArg2; - TopTools_ListOfShape myLS; - TopTools_DataMapOfShapeShape myImages; - GEOMAlgo_IndexedDataMapOfShapeState myMSS; - Standard_Boolean myIsAnalytic; -}; -#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx deleted file mode 100644 index 64d50241e..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx +++ /dev/null @@ -1,787 +0,0 @@ -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File: GEOMAlgo_FinderShapeOn1.cxx -// Created: Fri Mar 4 10:31:06 2005 -// Author: Peter KURNEV - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : GEOMAlgo_FinderShapeOn1 -//purpose : -//======================================================================= -GEOMAlgo_FinderShapeOn1::GEOMAlgo_FinderShapeOn1() -: - GEOMAlgo_ShapeAlgo() -{ - myTolerance=0.0001; - myShapeType=TopAbs_VERTEX; - myState=GEOMAlgo_ST_UNKNOWN; - myNbPntsMin=3; - myNbPntsMax=0; -} -//======================================================================= -//function : ~ -//purpose : -//======================================================================= -GEOMAlgo_FinderShapeOn1::~GEOMAlgo_FinderShapeOn1() -{ -} -//======================================================================= -//function : SetSurface -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::SetSurface(const Handle(Geom_Surface)& aS) -{ - mySurface=aS; -} -//======================================================================= -//function : Surface -//purpose : -//======================================================================= -const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn1::Surface() const -{ - return mySurface; -} -//======================================================================= -//function : SetShapeType -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::SetShapeType(const TopAbs_ShapeEnum aType) -{ - myShapeType=aType; -} -//======================================================================= -//function : ShapeType -//purpose : -//======================================================================= -TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn1::ShapeType()const -{ - return myShapeType; -} -//======================================================================= -//function : SetState -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::SetState(const GEOMAlgo_State aState) -{ - myState=aState; -} -//======================================================================= -//function : State -//purpose : -//======================================================================= -GEOMAlgo_State GEOMAlgo_FinderShapeOn1::State() const -{ - return myState; -} -//======================================================================= -//function : SetNbPntsMin -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::SetNbPntsMin(const Standard_Integer aNb) -{ - myNbPntsMin=aNb; -} -//======================================================================= -//function : NbPntsMin -//purpose : -//======================================================================= -Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMin()const -{ - return myNbPntsMin; -} -//======================================================================= -//function : SetNbPntsMax -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::SetNbPntsMax(const Standard_Integer aNb) -{ - myNbPntsMax=aNb; -} -//======================================================================= -//function : NbPntsMax -//purpose : -//======================================================================= -Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMax()const -{ - return myNbPntsMax; -} -//======================================================================= -// function: MSS -// purpose: -//======================================================================= -const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn1::MSS() const -{ - return myMSS; -} -//======================================================================= -// function: Shapes -// purpose: -//======================================================================= -const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn1::Shapes() const -{ - Standard_Integer i, aNb; - TopTools_ListOfShape* pL; - // - pL=(TopTools_ListOfShape*) &myLS; - pL->Clear(); - // - aNb=myMSS.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=myMSS.FindKey(i); - if (aS.ShapeType()==myShapeType) { - pL->Append(aS); - } - } - return myLS; -} -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::Perform() -{ - myErrorStatus=0; - myWarningStatus=0; - myLS.Clear(); - myMSS.Clear(); - // - CheckData(); - if(myErrorStatus) { - return; - } - // - // Initialize the context - GEOMAlgo_ShapeAlgo::Perform(); - // - // 1 - ProcessVertices(); - if(myErrorStatus) { - return; - } - if (myShapeType==TopAbs_VERTEX) { - return; - } - // - // 2 - ProcessEdges(); - if(myErrorStatus) { - return; - } - if (myShapeType==TopAbs_EDGE) { - return; - } - // - // 3 - ProcessFaces(); - if(myErrorStatus) { - return; - } - if (myShapeType==TopAbs_FACE) { - return; - } - // - // 4 - ProcessSolids(); - // -} -//======================================================================= -//function : ProcessVertices -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::ProcessVertices() -{ - myErrorStatus=0; - // - Standard_Boolean bIsConformState; - Standard_Integer i, aNb; - gp_Pnt aP; - TopTools_IndexedMapOfShape aM; - TopAbs_State aSt; - // - TopExp::MapShapes(myShape, TopAbs_VERTEX, aM); - aNb=aM.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i)); - aP=BRep_Tool::Pnt(aV); - // - aSt = GetPointState( aP ); - bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); - // - if (myShapeType==TopAbs_VERTEX){ - if (bIsConformState) { - myMSS.Add(aV, aSt); - } - } - else if (bIsConformState || aSt==TopAbs_ON) { - myMSS.Add(aV, aSt); - } - } -} -//======================================================================= -//function : ProcessEdges -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::ProcessEdges() -{ - myErrorStatus=0; - // - Standard_Boolean bIsConformState, bIsToBreak; - Standard_Integer i, aNb, iCnt; - TopAbs_State aSt; - TopTools_IndexedMapOfShape aM; - TopExp_Explorer aExp; - GEOMAlgo_ListIteratorOfListOfPnt aIt; - GeomAbs_SurfaceType aType1; - // - aType1=myGAS.GetType(); - // - TopExp::MapShapes(myShape, TopAbs_EDGE, aM); - // - bIsConformState=Standard_False; - // - aNb=aM.Extent(); - for (i=1; i<=aNb; ++i) { - GEOMAlgo_ListOfPnt aLP; - GEOMAlgo_StateCollector aSC; - // - const TopoDS_Edge& aE=TopoDS::Edge(aM(i)); - // - aExp.Init(aE, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Shape& aV=aExp.Current(); - // - bIsConformState=myMSS.Contains(aV); - if (!bIsConformState) { - break;// vertex has non-conformed state - } - else { - aSt=myMSS.FindFromKey(aV); - aSC.AppendState(aSt); - } - } - // - if (!bIsConformState) { - continue; // vertex has non-conformed state,skip edge - } - // - if (BRep_Tool::Degenerated(aE)) { - myMSS.Add(aE, aSt); - continue; - } - // - if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) { - Standard_Real aT1, aT2; - Handle(Geom_Curve) aC; - GeomAdaptor_Curve aGAC; - GeomAbs_CurveType aType2; - // - aC=BRep_Tool::Curve(aE, aT1, aT2); - aGAC.Load(aC); - // - aType2=aGAC.GetType(); - if (aType2==GeomAbs_Line) { - continue; - } - } - // - InnerPoints(aE, aLP); - if (myErrorStatus) { - return; - } - // - bIsConformState=Standard_True; - aIt.Initialize(aLP); - for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { - if (myNbPntsMax) { - if (iCnt > myNbPntsMax) { - break; - } - } - // - const gp_Pnt& aP=aIt.Value(); - aSt = GetPointState( aP ); - bIsToBreak=aSC.AppendState(aSt); - if (bIsToBreak) { - break; - } - } - // - aSt=aSC.State(); - // - bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); - if (myShapeType==TopAbs_EDGE) { - if (bIsConformState) { - myMSS.Add(aE, aSt); - } - } - else if (bIsConformState || aSt==TopAbs_ON) { - myMSS.Add(aE, aSt); - } - } // for (i=1; i<=aNb; ++i) next edge -} -//======================================================================= -//function : ProcessFaces -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::ProcessFaces() -{ - myErrorStatus=0; - // - Standard_Boolean bIsConformState, bIsToBreak; - Standard_Integer i, aNbF, iCnt; - TopAbs_State aSt; - TopTools_IndexedMapOfShape aM; - TopExp_Explorer aExp; - GEOMAlgo_ListIteratorOfListOfPnt aIt; - GeomAbs_SurfaceType aType1, aType2; - // - aType1=myGAS.GetType(); - // - TopExp::MapShapes(myShape, TopAbs_FACE, aM); - aNbF=aM.Extent(); - for (i=1; i<=aNbF; ++i) { - GEOMAlgo_StateCollector aSC; - GEOMAlgo_ListOfPnt aLP; - // - const TopoDS_Face& aF=TopoDS::Face(aM(i)); - // - if (myState==GEOMAlgo_ST_ON) { - Handle(Geom_Surface) aS; - GeomAdaptor_Surface aGAS; - // - aS=BRep_Tool::Surface(aF); - aGAS.Load(aS); - aType2=aGAS.GetType(); - if (aType2!=aType1) { - continue; - } - } - // - bIsConformState=Standard_False; - // - aExp.Init(aF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Shape& aE=aExp.Current(); - bIsConformState=myMSS.Contains(aE); - if (!bIsConformState) { - break;// edge has non-conformed state - } - else { - aSt=myMSS.FindFromKey(aE); - aSC.AppendState(aSt); - } - } - // - if (!bIsConformState) { - continue; // edge has non-conformed state,skip face - } - // - InnerPoints(aF, aLP); - if (myErrorStatus) { - return; - } - // - bIsConformState=Standard_True; - aIt.Initialize(aLP); - for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { - if (myNbPntsMax) { - if (iCnt > myNbPntsMax) { - break; - } - } - // - const gp_Pnt& aP=aIt.Value(); - aSt = GetPointState( aP ); - bIsToBreak=aSC.AppendState(aSt); - if (bIsToBreak) { - break; - } - } - // - aSt=aSC.State(); - // - bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); - if (myShapeType==TopAbs_FACE) { - if (bIsConformState) { - myMSS.Add(aF, aSt); - } - } - else if (bIsConformState || aSt==TopAbs_ON) { - myMSS.Add(aF, aSt); - } - }// for (i=1; i<=aNb; ++i) next face -} -//======================================================================= -//function : ProcessSolids -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::ProcessSolids() -{ - myErrorStatus=0; - // - Standard_Boolean bIsConformState; - Standard_Integer i, aNbS, j, aNbF; - TopTools_IndexedMapOfShape aM, aMF; - TopAbs_State aSt; - // - TopExp::MapShapes(myShape, TopAbs_SOLID, aM); - aNbS=aM.Extent(); - for (i=1; i<=aNbS; ++i) { - GEOMAlgo_StateCollector aSC; - // - const TopoDS_Shape& aSd=aM(i); - aMF.Clear(); - TopExp::MapShapes(aSd, TopAbs_FACE, aMF); - // - bIsConformState=Standard_False; - // - aNbF=aMF.Extent(); - for (j=1; j<=aNbF; ++j) { - const TopoDS_Shape& aF=aMF(j); - bIsConformState=myMSS.Contains(aF); - if (!bIsConformState) { - break;// face has non-conformed state - } - else { - aSt=myMSS.FindFromKey(aF); - aSC.AppendState(aSt); - } - } - // - if (!bIsConformState) { - continue; // face has non-conformed state,skip solid - } - // - aSt=aSC.State(); - // - bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); - if (bIsConformState) { - myMSS.Add(aSd, aSt); - } - } -} -// -//======================================================================= -//function : InnerPoints -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF, - GEOMAlgo_ListOfPnt& aLP) -{ - myErrorStatus=0; - // - Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds; - TopLoc_Location aLoc; - Handle(Poly_Triangulation) aTRF; - TColStd_MapOfInteger aMBN; - GEOMAlgo_DataMapOfPassKeyInteger aMPKI; - GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt; - gp_Pnt aP, aP1, aP2; - // - aLP.Clear(); - // - aTRF=BRep_Tool::Triangulation(aF, aLoc); - if (aTRF.IsNull()) { - if (!GEOMAlgo_AlgoTools::BuildTriangulation(aF)) { - 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(); - for (j=j1; j<=j2; ++j) { - const Poly_Triangle& aTr=aTrs(j); - aTr.Get(n[0], n[1], n[2]); - n[3]=n[0]; - for (k=0; k<3; ++k) { - GEOMAlgo_PassKey aPK; - // - aPK.SetIds(n[k], n[k+1]); - if (aMPKI.IsBound(aPK)) { - Standard_Integer& iCntX=aMPKI.ChangeFind(aPK); - ++iCntX; - } - else { - aMPKI.Bind(aPK, 1); - } - } - } - // - // boundary nodes aMBN - aNbLinks=aMPKI.Extent(); - aIt.Initialize(aMPKI); - for (; aIt.More(); aIt.Next()) { - iCnt=aIt.Value(); - if (iCnt==1) { - const GEOMAlgo_PassKey& aPK=aIt.Key(); - // - aNx=(Standard_Integer)aPK.Id(1); - aMBN.Add(aNx); - aNx=(Standard_Integer)aPK.Id(2); - aMBN.Add(aNx); - } - } - // - // inner nodes=all_nodes - boundary_nodes - j1=aNodes.Lower(); - j2=aNodes.Upper(); - for (j=j1; j<=j2; ++j) { - if (!aMBN.Contains(j)) { - aP=aNodes(j).Transformed(aTrsf); - aLP.Append(aP); - } - } - // - aNb=aLP.Extent(); - // - if (!aNb && myNbPntsMin) { - // try to fill it yourself - Standard_Boolean bIsDone; - Standard_Integer aN1, aN2; - Handle(Geom_Surface) aS; - GeomAdaptor_Surface aGAS; - GeomAbs_SurfaceType aType; - // - aS=BRep_Tool::Surface(aF); - aGAS.Load(aS); - aType=aGAS.GetType(); - if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) { - // inner links - aNbLinks=aMPKI.Extent(); - aIt.Initialize(aMPKI); - for (; aIt.More(); aIt.Next()) { - iCnt=aIt.Value(); - if (iCnt>1) { - // take the first having occurred inner link - // and discretize it - const GEOMAlgo_PassKey& aPK=aIt.Key(); - // - aN1=(Standard_Integer)aPK.Id(1); - aN2=(Standard_Integer)aPK.Id(2); - // - aP1=aNodes(aN1).Transformed(aTrsf); - aP2=aNodes(aN2).Transformed(aTrsf); - // - if (aType==GeomAbs_Cylinder) { - gp_Cylinder aCyl; - // - aCyl=aGAS.Cylinder(); - if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) { - continue; - } - } - // - BRepLib_MakeEdge aBME(aP1, aP2); - bIsDone=aBME.IsDone(); - if (!bIsDone) { - myErrorStatus=30; //can not obtain the line from the link - return; - } - // - const TopoDS_Shape& aSx=aBME.Shape(); - const TopoDS_Edge& aE=TopoDS::Edge(aSx); - // - InnerPoints(aE, myNbPntsMin, aLP); - break; - }// if (iCnt>1) - }// for (; aIt.More(); aIt.Next()) - }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) - }// if (!aNb && myNbPntsMin) { -} -//======================================================================= -//function : InnerPoints -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE, - GEOMAlgo_ListOfPnt& aLP) -{ - Standard_Integer aNbPntsMin; - // - myErrorStatus=0; - aNbPntsMin=21; - // - aLP.Clear(); - InnerPoints(aE, aNbPntsMin, aLP); -} -//======================================================================= -//function : InnerPoints -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE, - const Standard_Integer aNbPntsMin, - GEOMAlgo_ListOfPnt& aLP) -{ - Standard_Boolean bInf1, bInf2; - Standard_Integer j, aNbT; - Standard_Real dT, aT, aT1, aT2; - gp_Pnt aP; - Handle(Geom_Curve) aC3D; - // - aC3D=BRep_Tool::Curve(aE, aT1, aT2); - if (aC3D.IsNull()) { - return; - } - // - bInf1=Precision::IsNegativeInfinite(aT1); - bInf2=Precision::IsPositiveInfinite(aT2); - if (bInf1 || bInf2) { - return; - } - // - aNbT=aNbPntsMin+1; - dT=(aT2-aT1)/aNbT; - for (j=1; jD0(aT, aP); - aLP.Append(aP); - } -} - -//======================================================================= -//function : CheckData -//purpose : -//======================================================================= -void GEOMAlgo_FinderShapeOn1::CheckData() -{ - myErrorStatus=0; - // - if(mySurface.IsNull()) { - myErrorStatus=10; // mySurface=NULL - return; - } - // - if (myShape.IsNull()) { - myErrorStatus=11; // myShape=NULL - return; - } - // - if (!(myShapeType==TopAbs_VERTEX || - myShapeType==TopAbs_EDGE || - myShapeType==TopAbs_FACE || - myShapeType==TopAbs_SOLID)) { - myErrorStatus=12; // unallowed subshape type - return; - } - // - if (myState==GEOMAlgo_ST_UNKNOWN || - myState==GEOMAlgo_ST_INOUT) { - myErrorStatus=13; // unallowed state type - return; - } - // - GeomAbs_SurfaceType aType; - // - myGAS.Load(mySurface); - aType=myGAS.GetType(); - if (!(aType==GeomAbs_Plane || - aType==GeomAbs_Cylinder || - aType==GeomAbs_Sphere)) { - myErrorStatus=14; // unallowed surface type - } -} - -//======================================================================= -//function : GetPointState -//purpose : -//======================================================================= - -TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP) -{ - TopAbs_State aSt; - GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt); - return aSt; -} - - -// -// myErrorStatus : -// -// 10 -mySurface=NULL -// 11 -myShape=NULL -// 12 -unallowed type of subshapes -// 13 -unallowed state -// 14 -unallowed surface type -// 15 -unallowed surface type -// 20- no triangulation found -// 30- can not obtain the line from the link - diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.hxx deleted file mode 100644 index 5f67b1090..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.hxx +++ /dev/null @@ -1,145 +0,0 @@ -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File: GEOMAlgo_FinderShapeOn1.hxx -// Created: Fri Mar 4 10:31:06 2005 -// Author: Peter KURNEV - -#ifndef _GEOMAlgo_FinderShapeOn1_HeaderFile -#define _GEOMAlgo_FinderShapeOn1_HeaderFile - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -//======================================================================= -//function : GEOMAlgo_FinderShapeOn1 -//purpose : -//======================================================================= -class GEOMAlgo_FinderShapeOn1 : public GEOMAlgo_ShapeAlgo -{ - public: - Standard_EXPORT - GEOMAlgo_FinderShapeOn1(); - - Standard_EXPORT - virtual ~GEOMAlgo_FinderShapeOn1(); - - Standard_EXPORT - void SetSurface(const Handle(Geom_Surface)& aS) ; - - Standard_EXPORT - void SetShapeType(const TopAbs_ShapeEnum aST) ; - - Standard_EXPORT - void SetState(const GEOMAlgo_State aSF) ; - - Standard_EXPORT - void SetNbPntsMin(const Standard_Integer aNb) ; - - Standard_EXPORT - Standard_Integer NbPntsMin() const; - - Standard_EXPORT - void SetNbPntsMax(const Standard_Integer aNb) ; - - Standard_EXPORT - Standard_Integer NbPntsMax() const; - - Standard_EXPORT - const Handle(Geom_Surface)& Surface() const; - - Standard_EXPORT - TopAbs_ShapeEnum ShapeType() const; - - Standard_EXPORT - GEOMAlgo_State State() const; - - Standard_EXPORT - virtual void Perform() ; - - Standard_EXPORT - const TopTools_ListOfShape& Shapes() const; - - Standard_EXPORT - const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const; - - protected: - Standard_EXPORT - virtual void CheckData() ; - - Standard_EXPORT - void ProcessVertices() ; - - Standard_EXPORT - void ProcessEdges() ; - - Standard_EXPORT - void ProcessFaces() ; - - Standard_EXPORT - void ProcessSolids() ; - - Standard_EXPORT - void InnerPoints(const TopoDS_Face& aF, - GEOMAlgo_ListOfPnt& aLP) ; - - Standard_EXPORT - void InnerPoints(const TopoDS_Edge& aE, - GEOMAlgo_ListOfPnt& aLP) ; - - Standard_EXPORT - void InnerPoints(const TopoDS_Edge& aE, - const Standard_Integer aNbPnts, - GEOMAlgo_ListOfPnt& aLP) ; - - Standard_EXPORT - virtual TopAbs_State GetPointState(const gp_Pnt& aP) ; - - - Handle(Geom_Surface) mySurface; - TopAbs_ShapeEnum myShapeType; - GEOMAlgo_State myState; - Standard_Integer myNbPntsMin; - Standard_Integer myNbPntsMax; - GeomAdaptor_Surface myGAS; - TopTools_ListOfShape myLS; - GEOMAlgo_IndexedDataMapOfShapeState myMSS; -}; - -#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx index 5fd59d517..34509300b 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx @@ -33,6 +33,8 @@ #include #include +#include + #include #include #include @@ -606,14 +608,13 @@ 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(); // @@ -745,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(); // @@ -819,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 : // diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx index 8f999f393..6824e3c59 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx @@ -126,9 +126,6 @@ protected: const Standard_Integer aNbPnts, GEOMAlgo_ListOfPnt& aLP) ; - Standard_EXPORT - Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ; - TopAbs_ShapeEnum myShapeType; GEOMAlgo_State myState; diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx deleted file mode 100644 index 908cb4762..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOMAlgo_FinderShapeOnQuad.cxx -// Created : Mon Oct 17 17:31:45 2005 -// Author : Edward AGAPOV (eap) -// -#include "GEOMAlgo_FinderShapeOnQuad.hxx" -#include "GEOMAlgo_SurfaceTools.hxx" - -#include -#include -#include - - -GEOMAlgo_FinderShapeOnQuad::GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint, - const gp_Pnt & theTopRightPoint, - const gp_Pnt & theBottomLeftPoint, - const gp_Pnt & theBottomRightPoint) -{ - myPoints.resize(6); - myPoints[0] = theTopLeftPoint ; - myPoints[1] = theTopRightPoint ; - myPoints[2] = theBottomRightPoint; - myPoints[3] = theBottomLeftPoint ; - myPoints[4] = myPoints[0]; - myPoints[5] = myPoints[1]; - - // Find plane normal defined by corner points, it will be used to define a plane - // for each quadrangle side. - myQuadNormal.SetCoord (0,0,0); - for ( int i = 1; i <= 4; ++i ) - myQuadNormal += gp_Vec( myPoints[i], myPoints[i+1] ) ^ gp_Vec( myPoints[i], myPoints[i-1] ); - //std::cout< point2 vector - gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]); - //std::cout<<" Y Vec : "<Axis().Direction(); - gp_Vec aSideVec = myQuadNormal ^ aSideNorm; - gp_Vec c1p ( myPoints[i], aP ); - gp_Vec pc2 ( aP, myPoints[i+1] ); - if ( aSideVec * c1p >= 0. && aSideVec * pc2 >= 0. ) - return TopAbs_ON; - // consider to be IN (???????????) - //nbIn += myConcaveSide[i] ? 0.5 : 1.0; - } - } - Standard_Real inThreshold = myPlanes.size(); // usually 4.0 - if ( myConcaveQuad ) - inThreshold = 2.5; // 1.0 + 1.0 + 0.5 - - if ( nbIn >= inThreshold ) - return TopAbs_IN; - - return TopAbs_OUT; -} - diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx deleted file mode 100644 index 84b6fc0fe..000000000 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx +++ /dev/null @@ -1,61 +0,0 @@ -// 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOMAlgo_FinderShapeOnQuad.hxx -// Created : Mon Oct 17 17:15:59 2005 -// Author : Edward AGAPOV (eap) -// -#ifndef GEOMAlgo_FinderShapeOnQuad_HeaderFile -#define GEOMAlgo_FinderShapeOnQuad_HeaderFile - -#include "GEOMAlgo_FinderShapeOn1.hxx" - -#include - -#include - - -class GEOMAlgo_FinderShapeOnQuad: public GEOMAlgo_FinderShapeOn1 -{ -public: - - Standard_EXPORT - GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint, - const gp_Pnt & theTopRightPoint, - const gp_Pnt & theBottomLeftPoint, - const gp_Pnt & theBottomRightPoint); - -protected: - - virtual void CheckData() ; - - virtual TopAbs_State GetPointState(const gp_Pnt& aP) ; - -private: - - bool myConcaveQuad; - std::vector myConcaveSide; - std::vector myPoints; - std::vector myPlanes; - gp_Vec myQuadNormal; -}; -#endif diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx index c848ff86c..68ad864de 100644 --- a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx @@ -29,6 +29,11 @@ #include #include + +#include + +#if OCC_VERSION_LARGE < 0x07080000 + #include #define _NCollection_MapHasher @@ -39,6 +44,13 @@ typedef NCollection_IndexedDataMap + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfIntegerShape; + +#endif // OCC_VERSION_LARGE < 0x07080000 #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKey.cxx b/src/GEOMAlgo/GEOMAlgo_PassKey.cxx index 9f052c40f..2a031c2b0 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKey.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKey.cxx @@ -206,6 +206,7 @@ static } return !bRet; } +#if OCC_VERSION_LARGE < 0x07080000 //======================================================================= //function : HashCode //purpose : @@ -214,6 +215,7 @@ static { return ::HashCode(mySum, aUpper); } +#endif //======================================================================= //function : Dump //purpose : diff --git a/src/GEOMAlgo/GEOMAlgo_PassKey.hxx b/src/GEOMAlgo/GEOMAlgo_PassKey.hxx index 77a74f073..bb5185689 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKey.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKey.hxx @@ -28,6 +28,8 @@ #ifndef _GEOMAlgo_PassKey_HeaderFile #define _GEOMAlgo_PassKey_HeaderFile +#include + #include #include #include @@ -88,8 +90,19 @@ class GEOMAlgo_PassKey { Standard_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aOther) const; +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const; +#endif + + Standard_EXPORT + bool operator==(const GEOMAlgo_PassKey& theOther) const + { + return IsEqual(theOther); + } + + Standard_EXPORT + size_t GetSum() const { return (size_t)mySum; } Standard_EXPORT Standard_Integer Id(const Standard_Integer aIndex) const; @@ -102,4 +115,16 @@ class GEOMAlgo_PassKey { Standard_Integer mySum; TColStd_IndexedMapOfInteger myMap; }; + +namespace std +{ + template <> + struct hash + { + size_t operator()(const GEOMAlgo_PassKey& thePK) const noexcept + { + return thePK.GetSum(); + } + }; +} #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx index 79d55846e..9918596b4 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx @@ -27,6 +27,8 @@ // #include +#if OCC_VERSION_LARGE < 0x07080000 + //======================================================================= //function : HashCode //purpose : @@ -45,3 +47,18 @@ { return aPK1.IsEqual(aPK2); } + +#else + +size_t GEOMAlgo_PassKeyMapHasher::operator()(const GEOMAlgo_PassKey& aPKey) const +{ + return aPKey.GetSum(); +} + +bool GEOMAlgo_PassKeyMapHasher::operator()(const GEOMAlgo_PassKey& aPKey1, + const GEOMAlgo_PassKey& aPKey2) const +{ + return aPKey1.IsEqual(aPKey2); +} + +#endif // OCC_VERSION_LARGE < 0x07080000 diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx index a6ce772af..144d5d14c 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx @@ -34,12 +34,15 @@ #include #include +#include + //======================================================================= //class : GEOMAlgo_PassKeyMapHasher //purpose : //======================================================================= class GEOMAlgo_PassKeyMapHasher { public: +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT static Standard_Integer HashCode(const GEOMAlgo_PassKey& aPKey, const Standard_Integer Upper) ; @@ -47,5 +50,13 @@ class GEOMAlgo_PassKeyMapHasher { Standard_EXPORT static Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aPKey1, const GEOMAlgo_PassKey& aPKey2) ; +#else + Standard_EXPORT + size_t operator()(const GEOMAlgo_PassKey& aPKey) const; + + Standard_EXPORT + bool operator()(const GEOMAlgo_PassKey& aPKey1, + const GEOMAlgo_PassKey& aPKey2) const; +#endif // OCC_VERSION_LARGE < 0x07080000 }; #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx index fa0c73ee7..e4ceeb154 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx @@ -27,6 +27,8 @@ // #include +#include + #include #include @@ -94,7 +96,11 @@ static Clear(); myNbIds=1; myMap.Add(aS1); +#if OCC_VERSION_LARGE < 0x07080000 aHC=aS1.HashCode(myUpper); +#else + aHC = std::hash{}(aS1); +#endif mySum=NormalizedId(aHC, myNbIds); } //======================================================================= @@ -160,7 +166,11 @@ static myNbIds=myMap.Extent(); for(i=1; i<=myNbIds; ++i) { const TopoDS_Shape& aS=myMap(i); +#if OCC_VERSION_LARGE < 0x07080000 aId=aS.HashCode(myUpper); +#else + aId = std::hash{}(aS); +#endif aIdN=NormalizedId(aId, myNbIds); mySum+=aIdN; } @@ -195,6 +205,7 @@ static } return !bRet; } +#if OCC_VERSION_LARGE < 0x07080000 //======================================================================= //function : HashCode //purpose : @@ -203,6 +214,7 @@ static { return ::HashCode(mySum, aUpper); } +#endif //======================================================================= //function : Dump //purpose : diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx index f846bfbf7..4ea580317 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx @@ -29,6 +29,8 @@ #ifndef _GEOMAlgo_PassKeyShape_HeaderFile #define _GEOMAlgo_PassKeyShape_HeaderFile +#include + #include #include #include @@ -90,8 +92,19 @@ class GEOMAlgo_PassKeyShape { Standard_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aOther) const; +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const; +#endif + + Standard_EXPORT + bool operator==(const GEOMAlgo_PassKeyShape& theOther) const + { + return IsEqual(theOther); + } + + Standard_EXPORT + size_t GetSum() const { return (size_t)mySum; } Standard_EXPORT void Dump(const Standard_Integer aHex = 0) const; diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx index 7e1dccbc1..e926870f9 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx @@ -27,6 +27,8 @@ // #include +#if OCC_VERSION_LARGE < 0x07080000 + //======================================================================= //function : HashCode //purpose : @@ -45,3 +47,18 @@ { return aPK1.IsEqual(aPK2); } + +#else + +size_t GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey) const +{ + return aPKey.GetSum(); +} + +bool GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const +{ + return aPKey1.IsEqual(aPKey2); +} + +#endif // OCC_VERSION_LARGE < 0x07080000 diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx index 921d53db2..c656c45a4 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx @@ -34,6 +34,8 @@ #include #include +#include + //======================================================================= //class : GEOMAlgo_PassKeyShapeMapHasher //purpose : @@ -41,6 +43,7 @@ class GEOMAlgo_PassKeyShapeMapHasher { public: +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT static Standard_Integer HashCode(const GEOMAlgo_PassKeyShape& aPKey, const Standard_Integer Upper) ; @@ -48,5 +51,13 @@ class GEOMAlgo_PassKeyShapeMapHasher Standard_EXPORT static Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aPKey1, const GEOMAlgo_PassKeyShape& aPKey2) ; +#else + Standard_EXPORT + size_t operator()(const GEOMAlgo_PassKeyShape& aPKey) const; + + Standard_EXPORT + bool operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const; +#endif // OCC_VERSION_LARGE < 0x07080000 }; #endif diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 0c4eebd1a..0b0cfe95f 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -22,7 +22,10 @@ // File : GeometryGUI.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -#include // E.A. must be included before Python.h to fix compilation on windows +#include + +#include // E.A. must be included before Python.h to fix compilation on windows + #ifdef HAVE_FINITE #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined #endif diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index e20f8eac2..eff9b9233 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -24,13 +24,12 @@ // E.A. : On windows with python 2.6, there is a conflict // E.A. : between pymath.h and Standard_math.h which define // E.A. : some same symbols : acosh, asinh, ... - #include - #include - #include -#else - #include +#include +#include +#include #endif +#include #include #ifdef HAVE_FINITE diff --git a/src/GEOMImpl/GEOMImpl_ITestOperations.cxx b/src/GEOMImpl/GEOMImpl_ITestOperations.cxx index db1ac798f..629233356 100644 --- a/src/GEOMImpl/GEOMImpl_ITestOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITestOperations.cxx @@ -22,11 +22,10 @@ #include -#include +#include + #include -#include -#include -#include + #include #ifndef MAX2 @@ -83,25 +82,22 @@ bool GEOMImpl_ITestOperations::Tesselate(Handle(GEOM_Object) theShape, // reset error code SetErrorCode(KO); + // create a copy of the source shape TopoDS_Shape aShape = BRepBuilderAPI_Copy(theShape->GetValue()).Shape(); + // use default deflection if necessary if (theLinearDeflection <= 0) theLinearDeflection = 0.001; - // compute absolute deflection if necessary: 0.001 - if (theIsRelative) { - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - Bnd_Box bndBox; - BRepBndLib::Add(aShape, bndBox); - bndBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - theLinearDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theLinearDeflection * 4; - } + // use default deviation angle if necessary: 20 degrees if (theAngularDeflection <= 0) theAngularDeflection = 20. * M_PI / 180.; + // compute triangulation - BRepTools::Clean(aShape); - BRepMesh_IncrementalMesh aMesh(aShape, theLinearDeflection, Standard_False, theAngularDeflection); + GEOMUtils::MeshShape(aShape, theLinearDeflection, /*theForced*/ true, + theAngularDeflection, theIsRelative); + // set OK status and return SetErrorCode(OK); return true; diff --git a/src/GEOMImpl/GEOMImpl_ShapeProximityDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeProximityDriver.cxx index 23404069b..df823e314 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeProximityDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeProximityDriver.cxx @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -37,28 +39,6 @@ #include namespace { - static void tessellateShape(const TopoDS_Shape& theShape) - { - Standard_Boolean isTessellate = Standard_False; - TopLoc_Location aLoc; - for (TopExp_Explorer anExp(theShape, TopAbs_FACE); anExp.More() && !isTessellate; anExp.Next()) - { - Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(TopoDS::Face(anExp.Value()), aLoc); - isTessellate = aTria.IsNull(); - } - for (TopExp_Explorer anExp(theShape, TopAbs_EDGE); anExp.More() && !isTessellate; anExp.Next()) - { - Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(TopoDS::Edge(anExp.Value()), aLoc); - isTessellate = aPoly.IsNull(); - } - - if (isTessellate) - { - BRepMesh_IncrementalMesh aMesher(theShape, 0.1); - Standard_ProgramError_Raise_if(!aMesher.IsDone(), "Meshing failed"); - } - } - static Standard_Real paramOnCurve(const BRepAdaptor_Curve& theCurve, const gp_Pnt& thePoint, const Standard_Real theTol) { Extrema_ExtPC aParamSearch(thePoint, theCurve, theCurve.FirstParameter(), theCurve.LastParameter()); @@ -293,8 +273,8 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook if (aFunction->GetType() == PROXIMITY_COARSE) { // tessellate shapes if there is no mesh exists - tessellateShape(aShape1); - tessellateShape(aShape2); + GEOMUtils::MeshShape(aShape1, 0.1, /*theForced*/false, 0.5, /*isRelative*/false); + GEOMUtils::MeshShape(aShape2, 0.1, /*theForced*/false, 0.5, /*isRelative*/false); // compute proximity basing on the tessellation BRepExtrema_ShapeProximity aCalcProx; diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index f61f871e7..cb36716e4 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -93,6 +93,8 @@ #include #include +#include + #include #include #include @@ -677,56 +679,6 @@ void GEOMUtils::AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfSh } } -//======================================================================= -//function : CheckTriangulation -//purpose : -//======================================================================= -bool GEOMUtils::CheckTriangulation (const TopoDS_Shape& aShape) -{ - bool isTriangulation = true; - - TopExp_Explorer exp (aShape, 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 (aShape, TopAbs_EDGE); - if (!expe.More()) { - return false; - } - TopLoc_Location aLoc; - Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc); - if (aPE.IsNull()) { - isTriangulation = false; - } - } - - if (!isTriangulation) { - // calculate deflection - Standard_Real aDeviationCoefficient = 0.001; - - Bnd_Box B; - BRepBndLib::Add(aShape, 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; - - BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle); - } - - return true; -} - //======================================================================= //function : GetTypeOfSimplePart //purpose : @@ -1286,46 +1238,112 @@ TopoDS_Shape GEOMUtils::ReduceCompound( const TopoDS_Shape& shape ) return result; } -void GEOMUtils::MeshShape( const TopoDS_Shape shape, - double deflection, bool theForced ) -{ - Standard_Real aDeflection = ( deflection <= 0 ) ? DefaultDeflection() : deflection; - - // Is shape triangulated? - Standard_Boolean alreadyMeshed = true; - TopExp_Explorer ex; - TopLoc_Location aLoc; - for ( ex.Init( shape, TopAbs_FACE ); ex.More() && alreadyMeshed; ex.Next() ) { - const TopoDS_Face& aFace = TopoDS::Face( ex.Current() ); - Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation( aFace, aLoc ); - alreadyMeshed = !aPoly.IsNull(); - } - - if ( !alreadyMeshed || theForced ) { - // Compute bounding box - Bnd_Box B; - BRepBndLib::Add( shape, B ); - if ( B.IsVoid() ) - return; // NPAL15983 (Bug when displaying empty groups) - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - B.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); - - // This magic line comes from Prs3d_ShadedShape.gxx in OCCT - aDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * aDeflection * 4; - - // Clean triangulation before compute incremental mesh - BRepTools::Clean( shape ); - - // Compute triangulation - BRepMesh_IncrementalMesh mesh( shape, aDeflection ); - } -} - +//======================================================================= +//function : DefaultDeflection +//purpose : +//======================================================================= double GEOMUtils::DefaultDeflection() { return 0.001; } +//======================================================================= +//function : CanBeMeshed +//purpose : +//======================================================================= +static bool GEOMUtils_CanBeMeshed (const TopoDS_Shape& theShape, + const bool theCheckMesh, + bool& theHasMesh) +{ + // Is shape triangulated? + theHasMesh = true; + + TopExp_Explorer ex (theShape, TopAbs_FACE); + TopLoc_Location aLoc; + if (ex.More()) { + if (theCheckMesh) { + for ( ; ex.More() && theHasMesh; ex.Next() ) { + const TopoDS_Face& aFace = TopoDS::Face( ex.Current() ); + Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation( aFace, aLoc ); + theHasMesh = !aPoly.IsNull(); + } + } + } + else { // no faces, try edges + ex.Init(theShape, TopAbs_EDGE); + if (!ex.More()) { + return false; // nothing to mesh + } + if (theCheckMesh) { + for ( ; ex.More() && theHasMesh; ex.Next() ) { + Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(ex.Current()), aLoc); + theHasMesh = !aPE.IsNull(); + } + } + } + + return true; +} + +//======================================================================= +//function : MeshShape +//purpose : +//======================================================================= +bool GEOMUtils::MeshShape( const TopoDS_Shape theShape, + const double theDeflection, + const bool theForced, + const double theAngleDeflection, + const bool isRelative, + const bool doPostCheck) +{ + Standard_Real aDeflection = (theDeflection <= 0) ? DefaultDeflection() : theDeflection; + + // Is shape triangulated? + bool alreadyMeshed = true; + if (!GEOMUtils_CanBeMeshed (theShape, /*theCheckMesh*/true, alreadyMeshed)) + return false; + + if (alreadyMeshed && !theForced) + return true; + + if (isRelative) { + // Compute bounding box + Bnd_Box B; + BRepBndLib::Add(theShape, B); + if (B.IsVoid()) + return false; // NPAL15983 (Bug when displaying empty groups) + + Standard_Real aDeviationCoeff = aDeflection; + Standard_Real aMaxChordialDeviation = aDeflection; + aDeflection = Prs3d::GetDeflection(B, aDeviationCoeff, aMaxChordialDeviation); + } + + // Clean triangulation before compute incremental mesh + BRepTools::Clean(theShape); + + // Compute triangulation + BRepMesh_IncrementalMesh mesh (theShape, aDeflection, Standard_False, theAngleDeflection); + + if (!doPostCheck) + return true; + + if (!mesh.IsDone()) + return false; + + GEOMUtils_CanBeMeshed(theShape, /*theCheckMesh*/true, alreadyMeshed); + return alreadyMeshed; +} + +//======================================================================= +//function : CheckTriangulation +//purpose : +//======================================================================= +bool GEOMUtils::CheckTriangulation (const TopoDS_Shape& theShape) +{ + Standard_Real aHLRAngle = 0.349066; + return MeshShape(theShape, DefaultDeflection(), false, aHLRAngle); +} + //======================================================================= //function : IsOpenPath //purpose : diff --git a/src/GEOMUtils/GEOMUtils.hxx b/src/GEOMUtils/GEOMUtils.hxx index fe36edd65..ba6b7d045 100644 --- a/src/GEOMUtils/GEOMUtils.hxx +++ b/src/GEOMUtils/GEOMUtils.hxx @@ -155,13 +155,6 @@ namespace GEOMUtils Standard_EXPORT void AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfShape& theList); - /*! - * \brief Build a triangulation on \a theShape if it is absent. - * \param theShape The shape to check/build triangulation on. - * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. - */ - Standard_EXPORT bool CheckTriangulation (const TopoDS_Shape& theShape); - /*! * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. * \param theShape The shape to get type of. @@ -347,22 +340,40 @@ namespace GEOMUtils */ Standard_EXPORT TopoDS_Shape ReduceCompound( const TopoDS_Shape& shape ); - /*! - * \brief Generate triangulation for the shape. - * - * \param shape shape being meshed - * \param deflection deflection coefficient to be used - * \param forced if \c true, causes generation of mesh regardless it is already present in the shape - */ - Standard_EXPORT void MeshShape( const TopoDS_Shape shape, - double deflection, bool forced = true ); - /*! * \brief Get default deflection coefficient used for triangulation * \return default deflection value */ Standard_EXPORT double DefaultDeflection(); + /*! + * \brief Generate triangulation for \a theShape. + * + * \param theShape shape to be meshed. + * \param theDeflection deflection coefficient to be used. + * \param theForced if \c true, causes generation of mesh regardless it is already present in the shape. + * \param theAngleDeflection angular deflection coefficient to be used. + * \param isRelative if true, \a theDeflection is considered relative to \a theShape maximum axial dimension. + * \param doPostCheck if true, check mesh generation result and return corresponding boolean value. + * \retval bool Returns false in the following cases: + * 1. The shape has neither faces nor edges, i.e. impossible to build triangulation or polygon. + * 2. \a theForced is false and \a theShape has no mesh or has incomplete mesh. + * 3. \a doPostCheck is true and mesh generation failed or produced an incomplete mesh. + */ + Standard_EXPORT bool MeshShape( const TopoDS_Shape theShape, + const double theDeflection = DefaultDeflection(), + const bool theForced = true, + const double theAngleDeflection = 0.5, + const bool isRelative = true, + const bool doPostCheck = false); + + /*! + * \brief Build a triangulation on \a theShape if it is absent. + * \param theShape The shape to check/build triangulation on. + * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. + */ + Standard_EXPORT bool CheckTriangulation (const TopoDS_Shape& theShape); + /** * \brief Check if the shape is not a closed wire or edge. * diff --git a/src/OCC2VTK/OCC2VTK_Tools.cxx b/src/OCC2VTK/OCC2VTK_Tools.cxx index 377d4c3c0..e125b6806 100644 --- a/src/OCC2VTK/OCC2VTK_Tools.cxx +++ b/src/OCC2VTK/OCC2VTK_Tools.cxx @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx index 1ed99c516..fa7492ea1 100644 --- a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx @@ -33,6 +33,8 @@ // OOCT includes #include #include +#include +#include #include #include #include @@ -126,12 +128,22 @@ Standard_Integer STEPPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& /*l Interface_Static::SetCVal("xstep.cascade.unit","M"); Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); -#else +#elif OCC_VERSION_LARGE < 0x07080000 STEPControl_Writer aWriterTmp; Interface_Static::SetCVal("xstep.cascade.unit","M"); Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); STEPControl_Writer aWriter; +#else + STEPControl_Writer aWriter; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); + Interface_Static::SetIVal("write.step.nonmanifold", 1); + Handle(StepData_StepModel) aModel = aWriter.Model(); + aModel->InternalParameters.InitFromStatic(); + Standard_Integer aWriteUnitInt = Interface_Static::IVal("write.step.unit"); + Standard_Real aWriteUnitReal = UnitsMethods::GetLengthFactorValue(aWriteUnitInt); + aModel->SetWriteLengthUnit(aWriteUnitReal); #endif IFSelect_ReturnStatus status = aWriter.Transfer( aShape, STEPControl_AsIs ); diff --git a/src/STLPlugin/STLPlugin_ExportDriver.cxx b/src/STLPlugin/STLPlugin_ExportDriver.cxx index b98686a94..0bb1352ca 100644 --- a/src/STLPlugin/STLPlugin_ExportDriver.cxx +++ b/src/STLPlugin/STLPlugin_ExportDriver.cxx @@ -102,6 +102,7 @@ Standard_Integer STLPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& log) BRepBndLib::Add( aShape, bndBox ); bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); aDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * aDeflection; + aDeflection = MAX2( aDeflection, Precision::Confusion() ); } //Compute triangulation BRepTools::Clean( aCopyShape );