+// Copyright (C) 2005 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.
+//
+// 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_Gluer.cxx
// Created: Sat Dec 04 12:45:53 2004
// Author: Peter KURNEV
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
+#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
#include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
-#include <GEOMAlgo_IndexedDataMapOfPassKeyListOfShape.hxx>
-#include <GEOMAlgo_PassKey.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+#include <GEOMAlgo_PassKeyShape.hxx>
#include <GEOMAlgo_Tools.hxx>
+//
+
+static
+ void GetSubShapes(const TopoDS_Shape& aS,
+ TopTools_IndexedMapOfShape& aMSS);
//=======================================================================
//function : GEOMAlgo_Gluer
{
myErrorStatus=0;
//
+ Standard_Boolean bHasNewSubShape;
Standard_Integer i, aNbF, aNbSDF, iErr;
TopoDS_Shape aNewShape;
TopTools_IndexedMapOfShape aMF;
TopTools_ListIteratorOfListOfShape aItS;
- GEOMAlgo_PassKey aPKF;
- GEOMAlgo_IndexedDataMapOfPassKeyListOfShape aMPKLF;
+ GEOMAlgo_PassKeyShape aPKF;
+ GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF;
//
TopExp::MapShapes(myShape, aType, aMF);
//
}
//
// Images/Origins
+ //
aNbF=aMPKLF.Extent();
for (i=1; i<=aNbF; ++i) {
const TopTools_ListOfShape& aLSDF=aMPKLF(i);
}
//
const TopoDS_Shape& aS1=aLSDF.First();
- if (aType==TopAbs_FACE) {
- TopoDS_Face aNewFace;
- //
- const TopoDS_Face& aF1=TopoDS::Face(aS1);
- MakeFace(aF1, aNewFace);
- aNewShape=aNewFace;
+ //
+ bHasNewSubShape=Standard_True;
+ // prevent creation of a new shape if there are not
+ // new subshapes of aSS among the originals
+ if (aNbSDF==1) {
+ bHasNewSubShape=HasNewSubShape(aS1);
+ if (!bHasNewSubShape) {
+ aNewShape=aS1;
+ aNewShape.Orientation(TopAbs_FORWARD);
+ }
}
- else if (aType==TopAbs_EDGE) {
- TopoDS_Edge aNewEdge;
- //
- const TopoDS_Edge& aE1=TopoDS::Edge(aS1);
- MakeEdge(aE1, aNewEdge);
- aNewShape=aNewEdge;
+ //
+ if (bHasNewSubShape) {
+ if (aType==TopAbs_FACE) {
+ TopoDS_Face aNewFace;
+ //
+ const TopoDS_Face& aF1=TopoDS::Face(aS1);
+ MakeFace(aF1, aNewFace);
+ aNewShape=aNewFace;
+ }
+ else if (aType==TopAbs_EDGE) {
+ TopoDS_Edge aNewEdge;
+ //
+ const TopoDS_Edge& aE1=TopoDS::Edge(aS1);
+ MakeEdge(aE1, aNewEdge);
+ aNewShape=aNewEdge;
+ }
}
//
myImages.Bind(aNewShape, aLSDF);
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::FacePassKey(const TopoDS_Face& aF,
- GEOMAlgo_PassKey& aPK)
+ GEOMAlgo_PassKeyShape& aPK)
{
Standard_Integer i, aNbE, aNbMax;
TopTools_ListOfShape aLE;
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::EdgePassKey(const TopoDS_Edge& aE,
- GEOMAlgo_PassKey& aPK)
+ GEOMAlgo_PassKeyShape& aPK)
{
TopoDS_Vertex aV1, aV2;
//
void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE,
TopoDS_Edge& aNewEdge)
{
- //modified by NIZNHY-PKV Thu Dec 30 11:15:23 2004 f
myErrorStatus=0;
//
Standard_Boolean bIsDE;
else {
BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge);
}
- //modified by NIZNHY-PKV Thu Dec 30 11:15:28 2004 t
}
//
//=======================================================================
aER=TopoDS::Edge(myOrigins.Find(aE));
//
aER.Orientation(TopAbs_FORWARD);
- if (!BRep_Tool::Degenerated(aER)) {//modified by NIZNHY-PKV Thu Dec 30 11:31:37 2004 ft
+ if (!BRep_Tool::Degenerated(aER)) {
// build p-curve
if (bIsUPeriodic) {
GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax);
//
aBB.Add(newWire, aER);
}
+ //modified by NIZNHY-PKV Mon Jan 31 17:26:36 2005f
+ //
+ TopTools_ListOfShape aLW;
+ //
+ aLW.Append(aW);
+ myImages.Bind(newWire, aLW);
+ myOrigins.Bind(aW, newWire);
+ //
+ //modified by NIZNHY-PKV Mon Jan 31 17:26:41 2005 t
aBB.Add(newFace, newWire);
}
aNewFace=newFace;
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current());
- //modified by NIZNHY-PKV Thu Dec 30 11:38:05 2004 f
+ //
if (BRep_Tool::Degenerated(aE)) {
continue;
}
- //modified by NIZNHY-PKV Thu Dec 30 11:38:08 2004 t
+ //
const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE));
//
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
}
return bRet;
}
-//
-
+//=======================================================================
+//function : HasNewSubShape
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_Gluer::HasNewSubShape(const TopoDS_Shape& aS)const
+{
+ Standard_Boolean bRet;
+ Standard_Integer i, aNbSS;
+ TopTools_IndexedMapOfShape aMSS;
+ //
+ GetSubShapes(aS, aMSS);
+ //
+ bRet=Standard_False;
+ aNbSS=aMSS.Extent();
+ for (i=1; i<=aNbSS; ++i) {
+ const TopoDS_Shape& aSS=aMSS(i);
+ if (aSS.ShapeType()==TopAbs_WIRE) {
+ continue;
+ }
+ //
+ bRet=!myOrigins.IsBound(aSS);
+ if (bRet) {
+ return bRet;
+ }
+ //
+ const TopoDS_Shape& aSSIm=myOrigins.Find(aSS);
+ bRet=!aSSIm.IsSame(aSS);
+ if (bRet) {
+ return bRet;
+ }
+ }
+ return bRet;
+}
+//=======================================================================
+//function : GetSubShapes
+//purpose :
+//=======================================================================
+void GetSubShapes(const TopoDS_Shape& aS,
+ TopTools_IndexedMapOfShape& aMSS)
+{
+ Standard_Integer aR;
+ TopAbs_ShapeEnum aType;
+ TopoDS_Iterator aIt;
+ //
+ aType=aS.ShapeType();
+ aR=(Standard_Integer)aType+1;
+ if (aR>TopAbs_VERTEX) {
+ return;
+ }
+ //
+ aIt.Initialize(aS);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aSS=aIt.Value();
+ aMSS.Add(aSS);
+ GetSubShapes(aSS, aMSS);
+ }
+}
+//=======================================================================
+//function : Modified
+//purpose :
+//=======================================================================
+const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS)
+{
+ TopAbs_ShapeEnum aType;
+ //
+ myGenerated.Clear();
+ //
+ aType=aS.ShapeType();
+ if (aType==TopAbs_VERTEX ||
+ aType==TopAbs_EDGE ||
+ aType==TopAbs_WIRE || //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
+ aType==TopAbs_FACE ||
+ aType==TopAbs_SHELL || //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
+ aType==TopAbs_SOLID) { //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
+ if(myOrigins.IsBound(aS)) {
+ const TopoDS_Shape& aSnew=myOrigins.Find(aS);
+ if (!aSnew.IsSame(aS)) {
+ myGenerated.Append(aSnew);
+ }
+ }
+ }
+ //
+ return myGenerated;
+}
+//=======================================================================
+//function : Generated
+//purpose :
+//=======================================================================
+const TopTools_ListOfShape& GEOMAlgo_Gluer::Generated(const TopoDS_Shape& )
+{
+ myGenerated.Clear();
+ return myGenerated;
+}
+//=======================================================================
+//function : IsDeleted
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_Gluer::IsDeleted (const TopoDS_Shape& aS)
+{
+ Standard_Boolean bRet=Standard_False;
+ //
+ const TopTools_ListOfShape& aL=Modified(aS);
+ bRet=!aL.IsEmpty();
+ //
+ return bRet;
+}
//
// ErrorStatus
//
//
// 1 - some shapes can not be glued by faces
//
-/*
-//=======================================================================
-//function : BuildResult
-//purpose :
-//=======================================================================
-void GEOMAlgo_Gluer::BuildResult()
-{
- Standard_Boolean bAdded;
- TopoDS_Compound aCmp;
- BRep_Builder aBB;
- TopAbs_ShapeEnum aType;
- TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
- //
- aBB.MakeCompound(aCmp);
- //
- bAdded=Standard_False;
- aItIm.Initialize(myImages);
- for (; aItIm.More(); aItIm.Next()) {
- const TopoDS_Shape& aIm=aItIm.Key();
- aType=aIm.ShapeType();
- if(aType==TopAbs_SOLID) {
- bAdded=Standard_True;
- aBB.Add(aCmp, aIm);
- }
- }
- myResult=aCmp;
- //
- if (bAdded) {
- Standard_Real aTol=1.e-7;
- BOP_CorrectTolerances::CorrectCurveOnSurface(myResult);
- //BRepLib::SameParameter(myResult, aTol, bAdded);
- }
-}
-*/