X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FShHealOper%2FShHealOper_Sewing.cxx;h=3991dff35f15f94f384e1031048264aae4a98c3b;hb=914938a458b9d78a1b7719a3c9f6b74d3c5f20a7;hp=b0f8e4206a43a007eca91c3fdc28a1af03341fcb;hpb=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git diff --git a/src/ShHealOper/ShHealOper_Sewing.cxx b/src/ShHealOper/ShHealOper_Sewing.cxx index b0f8e4206..3991dff35 100644 --- a/src/ShHealOper/ShHealOper_Sewing.cxx +++ b/src/ShHealOper/ShHealOper_Sewing.cxx @@ -1,26 +1,29 @@ -// File: ShHealOper_Sewing.cxx -// Created: 29.04.04 15:07:10 -// Author: Galina KULIKOVA -// < MODULE = KERNEL> : -// Copyright (C) 2003 CEA +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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. +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // - -// 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. +// 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. // -// 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 +// 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: ShHealOper_Sewing.cxx +// Created: 29.04.04 15:07:10 +// Author: Galina KULIKOVA +// #include #include #include @@ -34,12 +37,26 @@ #include #include #include + +namespace +{ + bool cmpNbSubShapes( const TopoDS_Shape& s1, const TopoDS_Shape& s2, TopAbs_ShapeEnum t) + { + int nbNew = 0, nbOld = 0; + TopExp_Explorer exp; + TopTools_MapOfShape shMap; + for ( exp.Init( s1, t ); exp.More(); exp.Next() ) if ( shMap.Add( exp.Current() ) ) ++nbNew; + shMap.Clear(); + for ( exp.Init( s2, t ); exp.More(); exp.Next() ) if ( shMap.Add( exp.Current() ) ) ++nbOld; + return nbNew != nbOld; + } +} + //======================================================================= //function : ShHealOper_Sewing() //purpose : Constructor //======================================================================= - ShHealOper_Sewing::ShHealOper_Sewing (const TopoDS_Shape& theShape, const Standard_Real theTolerance) { @@ -94,7 +111,7 @@ Standard_Boolean ShHealOper_Sewing::sewing(const TopTools_SequenceOfShape& theSe return myDone; } //sewing shape - Handle(BRepAlgo_Sewing) aSewing = new BRepAlgo_Sewing; + Handle(BRepBuilderAPI_Sewing) aSewing = new BRepBuilderAPI_Sewing; aSewing->Load(myInitShape); aSewing->SetTolerance(myTolerance); aSewing->SetFaceMode(myFacesMode); @@ -116,7 +133,7 @@ Standard_Boolean ShHealOper_Sewing::sewing(const TopTools_SequenceOfShape& theSe //analysis either sewing was made by changing number of shells myDone = isSewed(aSewShape); - //keep modification of the subshapes in the Context. + //keep modification of the sub-shapes in the Context. TopExp_Explorer aExp(myInitShape,TopAbs_FACE); for( ; aExp.More(); aExp.Next()) myDone = (getModifications( aExp.Current(),aSewing) || myDone); @@ -221,7 +238,7 @@ Standard_Boolean ShHealOper_Sewing::getWires(const TopoDS_Shape& theSewShape) co //======================================================================= Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShape, - const Handle(BRepAlgo_Sewing)& theSewing) const + const Handle(BRepBuilderAPI_Sewing)& theSewing) const { if((Standard_Integer)theShape.ShapeType() > (Standard_Integer)myHistoryLevel) return Standard_False; @@ -245,15 +262,11 @@ Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShap Standard_Boolean ShHealOper_Sewing::isSewed(const TopoDS_Shape& theShape) const { - Standard_Integer nbNewShells =0; - Standard_Integer nbOldShells =0; - TopExp_Explorer aExpShells(theShape,TopAbs_SHELL); - for( ; aExpShells.More(); aExpShells.Next()) - nbNewShells++; - for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next()) - nbOldShells++; - return (nbNewShells != nbOldShells); + return cmpNbSubShapes( theShape, myInitShape, TopAbs_SHELL ) || + cmpNbSubShapes( theShape, myInitShape, TopAbs_EDGE ) || + cmpNbSubShapes( theShape, myInitShape, TopAbs_VERTEX ); } + //======================================================================= //function : deleteFreeEdges //purpose :