From eaee8de41c9bd33fd94f397af06e9df47aa258c5 Mon Sep 17 00:00:00 2001 From: skv Date: Fri, 27 Feb 2015 10:22:05 +0300 Subject: [PATCH] Fix of searching for shapes on surface (NGO letter from 20.02.2015) --- .../AdvancedEngine_IOperations.cxx | 13 +- .../AdvancedEngine_PipeTShapeDriver.cxx | 16 +- src/GEOMAlgo/CMakeLists.txt | 8 +- src/GEOMAlgo/FILES | 8 +- src/GEOMAlgo/GEOMAlgo_ClsfQuad.cxx | 219 ++++++++++++++++++ src/GEOMAlgo/GEOMAlgo_ClsfQuad.hxx | 92 ++++++++ src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx | 197 +++++++--------- src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx | 3 + src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 36 +-- 9 files changed, 441 insertions(+), 151 deletions(-) create mode 100644 src/GEOMAlgo/GEOMAlgo_ClsfQuad.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_ClsfQuad.hxx diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations.cxx b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx index 2e8db2e20..d311338c9 100644 --- a/src/AdvancedEngine/AdvancedEngine_IOperations.cxx +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx @@ -36,8 +36,9 @@ #include "GEOM_Function.hxx" #include "GEOM_PythonDump.hxx" #include "GEOMUtils.hxx" +#include "GEOMAlgo_ClsfSurf.hxx" +#include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_Splitter.hxx" -#include "GEOMAlgo_FinderShapeOn1.hxx" #include "GEOMImpl_Gen.hxx" #include "GEOMImpl_Types.hxx" @@ -815,11 +816,13 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf const Standard_Real theTolerance, TopTools_ListOfShape &theFaces) { - GEOMAlgo_FinderShapeOn1 aFinder; + GEOMAlgo_FinderShapeOn2 aFinder; + Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf; + aClsfSurf->SetSurface(theSurface); aFinder.SetShape(theShape); aFinder.SetTolerance(theTolerance); - aFinder.SetSurface(theSurface); + aFinder.SetClsf(aClsfSurf); aFinder.SetShapeType(TopAbs_FACE); aFinder.SetState(GEOMAlgo_ST_ON); @@ -836,7 +839,7 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { MESSAGE(" iErr : " << iErr); TCollection_AsciiString aMsg (" iErr : "); @@ -845,7 +848,7 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf return false; } Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx if (iWrn) { MESSAGE(" *** iWrn : " << iWrn); } diff --git a/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx index 30c497df5..5bdf76723 100644 --- a/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx +++ b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx @@ -26,9 +26,9 @@ #include "GEOM_Function.hxx" #include "GEOM_IOperations.hxx" #include "GEOMUtils.hxx" -#include "GEOMAlgo_FinderShapeOn1.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_ClsfBox.hxx" +#include "GEOMAlgo_ClsfSurf.hxx" #include "GEOMAlgo_Splitter.hxx" #include "Geom_CylindricalSurface.hxx" @@ -127,7 +127,7 @@ AdvancedEngine_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { TCollection_AsciiString aMsg (" iErr : "); aMsg += TCollection_AsciiString(iErr); @@ -185,12 +185,14 @@ Handle(TColStd_HSequenceOfInteger) } // Call algo - GEOMAlgo_FinderShapeOn1 aFinder; - Standard_Real aTol = 1e-6; + GEOMAlgo_FinderShapeOn2 aFinder; + Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf; + Standard_Real aTol = 1e-6; + aClsfSurf->SetSurface(theSurface); aFinder.SetShape(theShape); aFinder.SetTolerance(aTol); - aFinder.SetSurface(theSurface); + aFinder.SetClsf(aClsfSurf); aFinder.SetShapeType(theShapeType); aFinder.SetState(theState); @@ -208,7 +210,7 @@ Handle(TColStd_HSequenceOfInteger) // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { // MESSAGE(" iErr : " << iErr); TCollection_AsciiString aMsg (" iErr : "); @@ -217,7 +219,7 @@ Handle(TColStd_HSequenceOfInteger) return aSeqOfIDs; } // Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx // if (iWrn) { // MESSAGE(" *** iWrn : " << iWrn); // } diff --git a/src/GEOMAlgo/CMakeLists.txt b/src/GEOMAlgo/CMakeLists.txt index 8a61e31ca..f44663a10 100755 --- a/src/GEOMAlgo/CMakeLists.txt +++ b/src/GEOMAlgo/CMakeLists.txt @@ -51,6 +51,7 @@ SET(GEOMAlgo_HEADERS GEOMAlgo_BuilderShape.hxx GEOMAlgo_Clsf.hxx GEOMAlgo_ClsfBox.hxx + GEOMAlgo_ClsfQuad.hxx GEOMAlgo_ClsfSolid.hxx GEOMAlgo_ClsfSurf.hxx GEOMAlgo_CoupleOfShapes.hxx @@ -58,10 +59,7 @@ SET(GEOMAlgo_HEADERS GEOMAlgo_DataMapOfPassKeyInteger.hxx GEOMAlgo_DataMapOfShapeMapOfShape.hxx GEOMAlgo_DataMapOfShapePnt.hxx - GEOMAlgo_FinderShapeOn.hxx - GEOMAlgo_FinderShapeOn1.hxx GEOMAlgo_FinderShapeOn2.hxx - GEOMAlgo_FinderShapeOnQuad.hxx GEOMAlgo_GetInPlace.hxx GEOMAlgo_GetInPlaceAPI.hxx GEOMAlgo_GlueAnalyser.hxx @@ -116,13 +114,11 @@ SET(GEOMAlgo_SOURCES GEOMAlgo_BuilderShape.cxx GEOMAlgo_Clsf.cxx GEOMAlgo_ClsfBox.cxx + GEOMAlgo_ClsfQuad.cxx GEOMAlgo_ClsfSolid.cxx GEOMAlgo_ClsfSurf.cxx GEOMAlgo_CoupleOfShapes.cxx - GEOMAlgo_FinderShapeOn.cxx - GEOMAlgo_FinderShapeOn1.cxx GEOMAlgo_FinderShapeOn2.cxx - GEOMAlgo_FinderShapeOnQuad.cxx GEOMAlgo_GetInPlace.cxx GEOMAlgo_GetInPlace_1.cxx GEOMAlgo_GetInPlace_2.cxx diff --git a/src/GEOMAlgo/FILES b/src/GEOMAlgo/FILES index aa1e05e72..85d55bcfc 100644 --- a/src/GEOMAlgo/FILES +++ b/src/GEOMAlgo/FILES @@ -16,24 +16,20 @@ GEOMAlgo_SolidSolid.hxx GEOMAlgo_SolidSolid.cxx GEOMAlgo_ShapeAlgo.hxx GEOMAlgo_ShapeAlgo.cxx -GEOMAlgo_FinderShapeOn.hxx -GEOMAlgo_FinderShapeOn.cxx -GEOMAlgo_FinderShapeOn1.hxx -GEOMAlgo_FinderShapeOn1.cxx GEOMAlgo_HAlgo.hxx GEOMAlgo_HAlgo.cxx GEOMAlgo_Clsf.hxx GEOMAlgo_Clsf.cxx GEOMAlgo_ClsfBox.hxx GEOMAlgo_ClsfBox.cxx +GEOMAlgo_ClsfQuad.hxx +GEOMAlgo_ClsfQuad.cxx GEOMAlgo_ClsfSolid.hxx GEOMAlgo_ClsfSolid.cxx GEOMAlgo_ClsfSurf.hxx GEOMAlgo_ClsfSurf.cxx GEOMAlgo_FinderShapeOn2.hxx GEOMAlgo_FinderShapeOn2.cxx -GEOMAlgo_FinderShapeOnQuad.hxx -GEOMAlgo_FinderShapeOnQuad.cxx GEOMAlgo_Gluer.hxx GEOMAlgo_Gluer.cxx GEOMAlgo_GlueAnalyser.hxx diff --git a/src/GEOMAlgo/GEOMAlgo_ClsfQuad.cxx b/src/GEOMAlgo/GEOMAlgo_ClsfQuad.cxx new file mode 100644 index 000000000..7a2736d35 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ClsfQuad.cxx @@ -0,0 +1,219 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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_ClsfQuad.cxx +// Created: Fri Feb 13 16:03:19 2015 +// Author: Sergey KHROMOV +// + + +#include +#include + +#include + + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf); +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf); + +//======================================================================= +//function : +//purpose : +//======================================================================= +GEOMAlgo_ClsfQuad::GEOMAlgo_ClsfQuad() +: GEOMAlgo_Clsf(), + myQuadNormal(0., 0., 0.) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ClsfQuad::~GEOMAlgo_ClsfQuad() +{ +} +//======================================================================= +//function : SetCorners +//purpose : +//======================================================================= +void GEOMAlgo_ClsfQuad::SetCorners(const gp_Pnt &theTopLeftPoint, + const gp_Pnt &theTopRigthPoint, + const gp_Pnt &theBottomLeftPoint, + const gp_Pnt &theBottomRigthPoint) +{ + myPoints.resize(6); + myPoints[0] = theTopLeftPoint; + myPoints[1] = theTopRigthPoint; + myPoints[2] = theBottomRigthPoint; + 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]); + } + + if (myQuadNormal.SquareMagnitude() <= DBL_MIN) { + return; + } + + // detect concave quadrangle sides + myConcaveQuad = false; + myConcaveSide.resize (4, false); + + for ( int i = 1; i <= 4; ++i ) { + gp_Vec localQN = + gp_Vec(myPoints[i], myPoints[i+1]) ^ gp_Vec(myPoints[i], myPoints[i-1]); + + if (myQuadNormal * localQN < 0) { + myConcaveSide[i-1] = myConcaveSide[i] = myConcaveQuad = true; + } + } + + // loop on quadrangle sides + myPlanes.reserve( 4 ); + + for ( int i = 0; i < 4; ++i ) { + // point1 -> point2 vector + gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]); + + // plane normal + gp_Vec aSideNorm = aSideVec ^ myQuadNormal; + if (aSideNorm.SquareMagnitude() <= DBL_MIN) { + continue; + } + + // make plane + Handle(Geom_Plane) aPlane = new Geom_Plane(myPoints[i], aSideNorm); + + myPlanes.push_back(GeomAdaptor_Surface()); + myPlanes.back().Load( aPlane ); + } +} + + //======================================================================= +//function : GetCorners +//purpose : +//======================================================================= +void GEOMAlgo_ClsfQuad::GetCorners(gp_Pnt &theTopLeftPoint, + gp_Pnt &theTopRigthPoint, + gp_Pnt &theBottomLeftPoint, + gp_Pnt &theBottomRigthPoint) const +{ + if (myPoints.size() == 6) { + theTopLeftPoint = myPoints[0]; + theTopRigthPoint = myPoints[1]; + theBottomLeftPoint = myPoints[3]; + theBottomRigthPoint = myPoints[2]; + } +} + +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_ClsfQuad::CheckData() +{ + + if (myQuadNormal.SquareMagnitude() <= DBL_MIN) { + myErrorStatus = 10; // undefined quadrangle normal. + return; + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_ClsfQuad::Perform() +{ + myErrorStatus=0; + // + // Return IN if aP has TopAbs_IN with all sides. + // In the case of concave quadrangle, return IN if + // aP is OUT of only one concave side + double nbIn = 0.; + + for (size_t i = 0; i < myPlanes.size(); ++i) { + TopAbs_State aSt; + + GEOMAlgo_SurfaceTools::GetState(myPnt, myPlanes[i], myTolerance, aSt); + + if (aSt == TopAbs_IN) { + nbIn += myConcaveSide[i] ? 0.5 : 1.0; + } else if (aSt == TopAbs_ON) { + // check that aP is between quadrangle corners + Handle(Geom_Plane) aSidePlane = + Handle(Geom_Plane)::DownCast(myPlanes[i].Surface()); + gp_Vec aSideNorm = aSidePlane->Axis().Direction(); + gp_Vec aSideVec = myQuadNormal ^ aSideNorm; + gp_Vec c1p (myPoints[i], myPnt); + gp_Vec pc2 (myPnt, myPoints[i+1]); + + if (aSideVec * c1p >= 0. && aSideVec * pc2 >= 0.) { + myState = TopAbs_ON; + return; + } + // 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) { + myState = TopAbs_IN; + } else { + myState = TopAbs_OUT; + } +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ClsfQuad::CanBeON(const Handle(Geom_Curve)& aC) const +{ + return GEOMAlgo_Clsf::CanBeON(aC); +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ClsfQuad::CanBeON(const Handle(Geom_Surface)& aS1) const +{ + GeomAdaptor_Surface aGAS1; + + aGAS1.Load(aS1); + + GeomAbs_SurfaceType aST1 = aGAS1.GetType(); + Standard_Boolean bRet = (aST1 == GeomAbs_Plane); + + return bRet; +} diff --git a/src/GEOMAlgo/GEOMAlgo_ClsfQuad.hxx b/src/GEOMAlgo/GEOMAlgo_ClsfQuad.hxx new file mode 100644 index 000000000..cab2c169c --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ClsfQuad.hxx @@ -0,0 +1,92 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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_ClsfQuad.hxx +// Created: Fri Feb 13 16:03:19 2015 +// Author: Sergey KHROMOV +// +// +#ifndef _GEOMAlgo_ClsfQuad_HeaderFile +#define _GEOMAlgo_ClsfQuad_HeaderFile + + +#include + +#include +#include + +#include + + +DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf) + +//======================================================================= +// class : GEOMAlgo_ClsfQuad +//purpose : +//======================================================================= +class GEOMAlgo_ClsfQuad : public GEOMAlgo_Clsf +{ + +public: + + Standard_EXPORT + GEOMAlgo_ClsfQuad(); + + Standard_EXPORT + virtual ~GEOMAlgo_ClsfQuad(); + + Standard_EXPORT + void SetCorners(const gp_Pnt &theTopLeftPoint, + const gp_Pnt &theTopRigthPoint, + const gp_Pnt &theBottomLeftPoint, + const gp_Pnt &theBottomRigthPoint); + + Standard_EXPORT + void GetCorners(gp_Pnt &theTopLeftPoint, + gp_Pnt &theTopRigthPoint, + gp_Pnt &theBottomLeftPoint, + gp_Pnt &theBottomRigthPoint) const; + + Standard_EXPORT + virtual void Perform(); + + Standard_EXPORT + virtual void CheckData(); + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const; + + DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfQuad); + +protected: + + bool myConcaveQuad; + std::vector myConcaveSide; + std::vector myPoints; + std::vector myPlanes; + gp_Vec myQuadNormal; + +}; +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx index b90cf1b76..439caec37 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx @@ -26,75 +26,54 @@ // // #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 -#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 -#include -#include #if OCC_VERSION_LARGE > 0x06070100 #include #else #include #endif -#include -#include //======================================================================= //function : @@ -626,7 +605,7 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, // aTRF=BRep_Tool::Triangulation(aF, aLoc); if (aTRF.IsNull()) { - if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) { + if (!BuildTriangulation(aF)) { myWarningStatus=20; // no triangulation found return; } @@ -770,7 +749,7 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, if (aTRE.IsNull() || aPTE.IsNull()) { Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc); if (aPE.IsNull()) { - if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) { + if (!BuildTriangulation(aE)) { myErrorStatus=20; // no triangulation found return; } @@ -841,6 +820,59 @@ 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 : // @@ -854,60 +886,3 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, // 40- point can not be classified // 41- invalid data for classifier // 42- can not compute hatching - -/* -// A -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 occured 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 fron 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) { -*/ diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx index cab4f69a1..d4fea6af9 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.hxx @@ -126,6 +126,9 @@ 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/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index ecae62607..450de941e 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -54,9 +54,9 @@ #include "GEOMUtils.hxx" #include "GEOMAlgo_ClsfBox.hxx" +#include "GEOMAlgo_ClsfQuad.hxx" #include "GEOMAlgo_ClsfSolid.hxx" -#include "GEOMAlgo_FinderShapeOn1.hxx" -#include "GEOMAlgo_FinderShapeOnQuad.hxx" +#include "GEOMAlgo_ClsfSurf.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_GetInPlace.hxx" #include "GEOMAlgo_GetInPlaceAPI.hxx" @@ -2636,7 +2636,7 @@ Handle(TColStd_HSequenceOfInteger) // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { MESSAGE(" iErr : " << iErr); TCollection_AsciiString aMsg (" iErr : "); @@ -2645,7 +2645,7 @@ Handle(TColStd_HSequenceOfInteger) return aSeqOfIDs; } Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx if (iWrn) { MESSAGE(" *** iWrn : " << iWrn); } @@ -2803,7 +2803,7 @@ Handle(TColStd_HSequenceOfInteger) // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { if (iErr == 41) { SetErrorCode("theCheckShape must be a solid"); @@ -2817,7 +2817,7 @@ Handle(TColStd_HSequenceOfInteger) return aSeqOfIDs; } Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx if (iWrn) { MESSAGE(" *** iWrn : " << iWrn); } @@ -3074,13 +3074,14 @@ Handle(TColStd_HSequenceOfInteger) // END: Mantis issue 0020961 // Call algo - GEOMAlgo_FinderShapeOn1 aFinder; - //Standard_Real aTol = 0.0001; // default value - Standard_Real aTol = VertMax; // Mantis issue 0020961 + GEOMAlgo_FinderShapeOn2 aFinder; + Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf; + Standard_Real aTol = VertMax; // Mantis issue 0020961 + aClsfSurf->SetSurface(theSurface); aFinder.SetShape(theShape); aFinder.SetTolerance(aTol); - aFinder.SetSurface(theSurface); + aFinder.SetClsf(aClsfSurf); aFinder.SetShapeType(theShapeType); aFinder.SetState(theState); @@ -3098,7 +3099,7 @@ Handle(TColStd_HSequenceOfInteger) // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { MESSAGE(" iErr : " << iErr); TCollection_AsciiString aMsg (" iErr : "); @@ -3107,7 +3108,7 @@ Handle(TColStd_HSequenceOfInteger) return aSeqOfIDs; } Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx if (iWrn) { MESSAGE(" *** iWrn : " << iWrn); } @@ -3985,12 +3986,15 @@ Handle(TColStd_HSequenceOfInteger) gp_Pnt aPntBL = BRep_Tool::Pnt(TopoDS::Vertex(aBL)); gp_Pnt aPntBR = BRep_Tool::Pnt(TopoDS::Vertex(aBR)); - GEOMAlgo_FinderShapeOnQuad aFinder( aPntTL, aPntTR, aPntBL, aPntBR ); + GEOMAlgo_FinderShapeOn2 aFinder; + Handle(GEOMAlgo_ClsfQuad) aClsfQuad = new GEOMAlgo_ClsfQuad; + Standard_Real aTol = 0.0001; // default value + aClsfQuad->SetCorners(aPntTL, aPntTR, aPntBL, aPntBR); aFinder.SetShape(aShape); aFinder.SetTolerance(aTol); - //aFinder.SetSurface(theSurface); + aFinder.SetClsf(aClsfQuad); aFinder.SetShapeType(aShapeType); aFinder.SetState(theState); @@ -4008,7 +4012,7 @@ Handle(TColStd_HSequenceOfInteger) // Interprete results Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx if (iErr) { MESSAGE(" iErr : " << iErr); TCollection_AsciiString aMsg (" iErr : "); @@ -4017,7 +4021,7 @@ Handle(TColStd_HSequenceOfInteger) return aSeqOfIDs; } Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx if (iWrn) { MESSAGE(" *** iWrn : " << iWrn); } -- 2.39.2