diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 6d893fbeee..b4bd2b0df2 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1596,6 +1596,11 @@ Since OCCT 7.4.0 exception is thrown on the attempt of taking points in case of * The method *ImagesResult* of the class *BOPAlgo_BuilderShape* has been removed as unused. The functionality of this method can be completely replaced by the history methods *Modified* and *IsDeleted*. * The method *TrackHistory* of the classes *BOPAlgo_RemoveFeatures* and *BRepAlgoAPI_Defeaturing* has been renamed to *SetToFillHistory*. * The method *GetHistory* of the class *BRepAlgoAPI_Defeaturing* has been renamed to *History*. +* The classes *BRepAlgo_BooleanOperations* and *BRepAlgo_DSAccess* have been removed as obsolete. Please use the BRepAlgoAPI_* classes to perform Boolean operations. +* *BRepAlgo_DataMapOfShapeBoolean* has been removed as unused. +* *BRepAlgo_DataMapOfShapeInterference* has been removed as unused. +* *BRepAlgo_EdgeConnector* has been removed as unused. +* *BRepAlgo_SequenceOfSequenceOfInteger* has been removed as unused. @subsection upgrade_740_localcontext Local Context removal diff --git a/src/BRepAlgo/BRepAlgo.hxx b/src/BRepAlgo/BRepAlgo.hxx index fcb7f7136b..37c8a7d94d 100644 --- a/src/BRepAlgo/BRepAlgo.hxx +++ b/src/BRepAlgo/BRepAlgo.hxx @@ -38,9 +38,6 @@ class BRepAlgo_Tool; class BRepAlgo_Image; class BRepAlgo_AsDes; class BRepAlgo_FaceRestrictor; -class BRepAlgo_BooleanOperations; -class BRepAlgo_DSAccess; -class BRepAlgo_EdgeConnector; class BRepAlgo_NormalProjection; @@ -114,9 +111,6 @@ friend class BRepAlgo_Tool; friend class BRepAlgo_Image; friend class BRepAlgo_AsDes; friend class BRepAlgo_FaceRestrictor; -friend class BRepAlgo_BooleanOperations; -friend class BRepAlgo_DSAccess; -friend class BRepAlgo_EdgeConnector; friend class BRepAlgo_NormalProjection; }; diff --git a/src/BRepAlgo/BRepAlgo_BooleanOperations.cxx b/src/BRepAlgo/BRepAlgo_BooleanOperations.cxx deleted file mode 100644 index d0c9f6e037..0000000000 --- a/src/BRepAlgo/BRepAlgo_BooleanOperations.cxx +++ /dev/null @@ -1,395 +0,0 @@ -// Created on: 1997-11-20 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : Create -//purpose : -//======================================================================= -BRepAlgo_BooleanOperations::BRepAlgo_BooleanOperations() : -myApproxNbPntMax (30) , -myApproxTol3D (1.e-7) , -myApproxTol2D (1.e-7) -{ -} - -//======================================================================= -//function : Shapes2d -//purpose : -//======================================================================= - void BRepAlgo_BooleanOperations::Shapes2d (const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - // S1 doit etre une face ou un ensemble de faces - // S2 doit etre une edge. - - if (S2.ShapeType() != TopAbs_EDGE) return; - - BRep_Builder Builder ; - TopoDS_Wire Wire ; - Builder.MakeWire (Wire); - Builder.Add (Wire, S2); - - TopExp_Explorer Exp (S1, TopAbs_FACE) ; - if (!Exp.More()) return ; - const TopoDS_Face& FirstFace = TopoDS::Face (Exp.Current()) ; - - TopLoc_Location Loc; - const Handle(Geom_Surface)& Surf = BRep_Tool::Surface (FirstFace, Loc) ; - - TopoDS_Face Face ; - Builder.MakeFace (Face, Surf, Loc, BRep_Tool::Tolerance (FirstFace)) ; - Builder.Add (Face, Wire) ; - Face.Orientation (FirstFace.Orientation()) ; - - myS1 = S1 ; - myS2 = Face ; - - myDSA.Init() ; - myDSA.Load (myS1, myS2) ; - Handle (TopOpeBRepDS_HDataStructure)& HDS = myDSA.ChangeDS() ; - myDSA.myDSFiller.Insert2d (myS1, myS2, HDS) ; -} - -//======================================================================= -//function : Shapes -//purpose : Defines the arguments. -//======================================================================= - void BRepAlgo_BooleanOperations::Shapes (const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - myS1 = S1; - myS2 = S2; - myDSA.Init(); - myDSA.Load(myS1, myS2); - Handle(TopOpeBRepDS_HDataStructure)& HDS = myDSA.ChangeDS(); - myDSA.myDSFiller.Insert(myS1,myS2,HDS); - // const Standard_Boolean CheckShapes = Standard_True; - // Standard_Boolean esp = HDS->EdgesSameParameter(); - // Standard_Boolean localcheck = CheckShapes; -} - -//======================================================================= -//function : SetApproxParameters -//purpose : Sets the parameters for the approximations. -//======================================================================= - void BRepAlgo_BooleanOperations::SetApproxParameters (const Standard_Integer NbPntMax, - const Standard_Real Tol3D, - const Standard_Real Tol2D) -{ - myApproxNbPntMax = NbPntMax ; - myApproxTol3D = Tol3D ; - myApproxTol2D = Tol2D ; -} - -//======================================================================= -//function : Define -//purpose : -//======================================================================= - void BRepAlgo_BooleanOperations::Define (const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - Handle(TopOpeBRepDS_HDataStructure)& HDS) -{ - ChangeDataStructure() = HDS; - myS1 = S1; - myS2 = S2; -} - -//======================================================================= -//function : Perform -//purpose : Performs the global boolean operation. -//======================================================================= - void BRepAlgo_BooleanOperations::Perform () -{ - TopOpeBRepDS_BuildTool& BTofBuilder = myDSA.myHB->ChangeBuildTool(); - TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool(); - GTofBTofBuilder.SetNbPntMax(myApproxNbPntMax); - GTofBTofBuilder.SetTolerances (myApproxTol3D, myApproxTol2D) ; - Handle(TopOpeBRepBuild_HBuilder)& HB = myDSA.myHB; - Handle(TopOpeBRepDS_HDataStructure)& HDS = myDSA.ChangeDS(); - HB->Perform(HDS,myS1,myS2); -} - -//======================================================================= -//function : Perform -//purpose : Performs the global boolean operation in regards of the -// given states. -//======================================================================= - void BRepAlgo_BooleanOperations::Perform (const TopAbs_State State1, - const TopAbs_State State2) -{ - Perform() ; - - myShape.Nullify() ; - myResult.Nullify() ; - myMapShape.Clear() ; - - Handle(TopOpeBRepBuild_HBuilder)& HBuilder = ChangeBuilder() ; - HBuilder->MergeShapes (myS1, State1, myS2, State2) ; - - const TopTools_ListOfShape& ListResults = HBuilder->Merged (myS1, State1) ; - Standard_Integer NbResults = ListResults.Extent() ; - if (NbResults > 0) { - if (NbResults == 1) { - myShape = ListResults.First() ; - } else { - BRep_Builder Builder ; - Builder.MakeCompound (TopoDS::Compound (myShape)) ; - TopTools_ListIteratorOfListOfShape Iter ; - for (Iter.Initialize (ListResults) ; Iter.More() ; Iter.Next()) - Builder.Add (myShape, Iter.Value()) ; - } - TopExp_Explorer Explorer ; - for (Explorer.Init (myShape, TopAbs_FACE) ; Explorer.More() ; Explorer.Next()) { - myMapShape.Add (Explorer.Current()) ; - } - for (Explorer.Init (myShape, TopAbs_EDGE) ; Explorer.More() ; Explorer.Next()) { - myMapShape.Add (Explorer.Current()) ; - } - } -} - -//======================================================================= -//function : Common -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::Common() -{ - Perform (TopAbs_IN, TopAbs_IN) ; - return myShape ; -} - -//======================================================================= -//function : fus -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::Fus() -{ - Perform (TopAbs_OUT, TopAbs_OUT) ; - return myShape ; -} - -//======================================================================= -//function : cut -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::Cut() -{ - Perform (TopAbs_OUT, TopAbs_IN) ; - return myShape ; -} - -//======================================================================= -//function : Section -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::Section() -{ -// Standard_Boolean bcw = BuilderCanWork(); -// if ( ! bcw || myshapeisnull) return; - - Perform () ; - - myShape.Nullify() ; - myResult.Nullify() ; - myMapShape.Clear() ; - - Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ; - - const TopTools_ListOfShape& ListResults = HBuilder->Section() ; - Standard_Integer NbResults = ListResults.Extent() ; - if (NbResults > 0) { - if (NbResults == 1) { - myShape = ListResults.First() ; - } else { - BRep_Builder Builder ; - Builder.MakeCompound (TopoDS::Compound (myShape)) ; - TopTools_ListIteratorOfListOfShape Iter ; - for (Iter.Initialize (ListResults) ; Iter.More() ; Iter.Next()) - Builder.Add (myShape, Iter.Value()) ; - } - TopExp_Explorer Explorer ; - for (Explorer.Init (myShape, TopAbs_EDGE) ; Explorer.More() ; Explorer.Next()) { - myMapShape.Add (Explorer.Current()) ; - } - } - - return myShape ; -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::Shape() -{ - return myShape; -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - const TopoDS_Shape& BRepAlgo_BooleanOperations::ShapeFrom (const TopoDS_Shape& Shape) -{ - myResult.Nullify() ; - - if (!myShape.IsNull()) { - - TopoDS_Shape ShapeToDel ; - if (Shape.IsSame (myS1)) { - ShapeToDel = myS2 ; - } else { - ShapeToDel = myS1 ; - } - - BRepTools_Substitution Substitute ; - - TopTools_ListOfShape NullFaces ; - NullFaces.Clear() ; - - TopExp_Explorer ExpFac ; - for (ExpFac.Init (ShapeToDel, TopAbs_FACE) ; ExpFac.More() ; ExpFac.Next()) { - const TopoDS_Face& Face = TopoDS::Face (ExpFac.Current()) ; - const TopTools_ListOfShape& ListResults = Modified (Face) ; - if (ListResults.Extent() == 0) { - if (myMapShape.Contains (Face)) Substitute.Substitute (Face, NullFaces) ; - } else { - TopTools_ListIteratorOfListOfShape ItrFace ; - for (ItrFace.Initialize (ListResults) ; ItrFace.More() ; ItrFace.Next()) { - Substitute.Substitute (TopoDS::Face (ItrFace.Value()), NullFaces) ; - } - } - } - - Substitute.Build (myShape) ; - if (Substitute.IsCopied (myShape)) { - const TopTools_ListOfShape& ListResults = Substitute.Copy (myShape) ; - Standard_Integer NbResults = ListResults.Extent() ; - if (NbResults == 1) { - myResult = ListResults.First() ; - } else if (NbResults > 1) { - BRep_Builder Builder ; - Builder.MakeCompound (TopoDS::Compound (myResult)) ; - TopTools_ListIteratorOfListOfShape ItrResult ; - for (ItrResult.Initialize (ListResults) ; ItrResult.More() ; ItrResult.Next()) { - Builder.Add (myResult, ItrResult.Value()) ; - } - } - } else { - myResult = myShape ; - } - - } - return myResult ; -} - -//======================================================================= -//function : Modified -//purpose : -//======================================================================= - const TopTools_ListOfShape& BRepAlgo_BooleanOperations::Modified (const TopoDS_Shape& Shape) -{ - return myDSA.Modified(Shape); -} - -//======================================================================= -//function : IsDeleted -//purpose : -//======================================================================= - Standard_Boolean BRepAlgo_BooleanOperations::IsDeleted (const TopoDS_Shape& Shape) -{ - Standard_Boolean Deleted = Standard_True ; - - Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ; - - if ( myMapShape.Contains (Shape) - || HBuilder->IsMerged (Shape, TopAbs_OUT) - || HBuilder->IsMerged (Shape, TopAbs_IN) - || HBuilder->IsMerged (Shape, TopAbs_ON) - || HBuilder->IsSplit (Shape, TopAbs_OUT) - || HBuilder->IsSplit (Shape, TopAbs_IN) - || HBuilder->IsSplit (Shape, TopAbs_ON)) - Deleted = Standard_False ; - - return Deleted ; -} - -//======================================================================= -//function : DataStructure -//purpose : -//======================================================================= - const Handle(TopOpeBRepDS_HDataStructure)& BRepAlgo_BooleanOperations::DataStructure() const -{ - return myDSA.DS(); -} - -//======================================================================= -//function : DataStructure -//purpose : -//======================================================================= - Handle(TopOpeBRepDS_HDataStructure)& BRepAlgo_BooleanOperations::ChangeDataStructure() -{ - return myDSA.ChangeDS(); -} - -//======================================================================= -//function : Builder -//purpose : -//======================================================================= - const Handle(TopOpeBRepBuild_HBuilder)& BRepAlgo_BooleanOperations::Builder() const -{ - return myDSA.Builder(); -} - -//======================================================================= -//function : Builder -//purpose : -//======================================================================= - Handle(TopOpeBRepBuild_HBuilder)& BRepAlgo_BooleanOperations::ChangeBuilder() -{ - return myDSA.ChangeBuilder(); -} - -//======================================================================= -//function : DataStructureAccess -//purpose : returns the member myDSA. -//======================================================================= - BRepAlgo_DSAccess& BRepAlgo_BooleanOperations::DataStructureAccess() -{ - return myDSA; -} - diff --git a/src/BRepAlgo/BRepAlgo_BooleanOperations.hxx b/src/BRepAlgo/BRepAlgo_BooleanOperations.hxx deleted file mode 100644 index 6975d3ffe2..0000000000 --- a/src/BRepAlgo/BRepAlgo_BooleanOperations.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// Created on: 1993-10-14 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _BRepAlgo_BooleanOperations_HeaderFile -#define _BRepAlgo_BooleanOperations_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -class TopoDS_Shape; -class TopOpeBRepDS_HDataStructure; -class TopOpeBRepBuild_HBuilder; -class BRepAlgo_DSAccess; - - - -class BRepAlgo_BooleanOperations -{ -public: - - DEFINE_STANDARD_ALLOC - - - Standard_EXPORT BRepAlgo_BooleanOperations(); - - //! S1 is a Shell with ALL faces supported by the SAME S2 is - //! an Edge INCLUDED in that surface with pcurve. - //! this avoids a time-consuming 3D operation, compared to Shapes. - Standard_EXPORT void Shapes2d (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! Defines the arguments. - Standard_EXPORT void Shapes (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! Sets different parameters for the curve approximations : - //! NbPntMax : Maximum number of points to be approximated at - //! the same time in one curve. - //! Tol3D, Tol2D : Tolerances to be reached by the approximation. - //! RelativeTol : The given tolerances are relative. - Standard_EXPORT void SetApproxParameters (const Standard_Integer NbPntMax, const Standard_Real Tol3D, const Standard_Real Tol2D); - - Standard_EXPORT void Define (const TopoDS_Shape& S1, const TopoDS_Shape& S2, Handle(TopOpeBRepDS_HDataStructure)& HDS); - - //! returns the common part of the shapes. - Standard_EXPORT const TopoDS_Shape& Common(); - - //! returns the fuse part of the shapes. - Standard_EXPORT const TopoDS_Shape& Fus(); - - //! returns the cut part of the shapes. - Standard_EXPORT const TopoDS_Shape& Cut(); - - //! returns the intersection of the shapes. - Standard_EXPORT const TopoDS_Shape& Section(); - - //! returns the result of the boolean operation. - Standard_EXPORT const TopoDS_Shape& Shape(); - - //! Returns the shape(s) resulting of the boolean operation - //! issued from the shape . - Standard_EXPORT const TopoDS_Shape& ShapeFrom (const TopoDS_Shape& S); - - //! Returns the list of the descendant shapes of the shape . - Standard_EXPORT const TopTools_ListOfShape& Modified (const TopoDS_Shape& S); - - //! Returns the fact that the shape has been deleted or not - //! by the boolean operation. - Standard_EXPORT Standard_Boolean IsDeleted (const TopoDS_Shape& S); - - Standard_EXPORT const Handle(TopOpeBRepDS_HDataStructure)& DataStructure() const; - - Standard_EXPORT Handle(TopOpeBRepDS_HDataStructure)& ChangeDataStructure(); - - Standard_EXPORT const Handle(TopOpeBRepBuild_HBuilder)& Builder() const; - - Standard_EXPORT Handle(TopOpeBRepBuild_HBuilder)& ChangeBuilder(); - - //! returns the member myDSA. It is useful to then access - //! the method GetSectionEdgeSet (wich is a member of DSAccess) - Standard_EXPORT BRepAlgo_DSAccess& DataStructureAccess(); - - - - -protected: - - - - - -private: - - - //! Performs the global boolean operation. - Standard_EXPORT void Perform(); - - //! Performs the global boolean operation and build the - //! result in regards of the given states. - Standard_EXPORT void Perform (const TopAbs_State State1, const TopAbs_State State2); - - - BRepAlgo_DSAccess myDSA; - TopoDS_Shape myS1; - TopoDS_Shape myS2; - TopoDS_Shape myShape; - TopTools_MapOfShape myMapShape; - TopoDS_Shape myResult; - Standard_Integer myApproxNbPntMax; - Standard_Real myApproxTol3D; - Standard_Real myApproxTol2D; -}; - - - - - - - -#endif // _BRepAlgo_BooleanOperations_HeaderFile diff --git a/src/BRepAlgo/BRepAlgo_DSAccess.cxx b/src/BRepAlgo/BRepAlgo_DSAccess.cxx deleted file mode 100644 index f659555a93..0000000000 --- a/src/BRepAlgo/BRepAlgo_DSAccess.cxx +++ /dev/null @@ -1,1767 +0,0 @@ -// Created on: 1997-08-13 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#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 : Create -//purpose : -//======================================================================= - -BRepAlgo_DSAccess::BRepAlgo_DSAccess() { - Init(); -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Init() -{ - if(myHDS.IsNull()) - myHDS = new TopOpeBRepDS_HDataStructure(); - else - myHDS->ChangeDS().Init(); - myRecomputeBuilderIsDone = Standard_False; - myGetSectionIsDone = Standard_False; - myListOfCompoundOfEdgeConnected.Clear(); - myEC = new BRepAlgo_EdgeConnector(); - myHB.Nullify(); - - // init of the builder - Standard_Real tol3dAPPROX = 1e-7; - Standard_Real tol2dAPPROX = 1e-7; - // set tolerance values used by the APPROX process - TopOpeBRepTool_GeomTool GT; - GT.Define(TopOpeBRepTool_APPROX); - GT.SetTolerances(tol3dAPPROX,tol2dAPPROX); - TopOpeBRepDS_BuildTool BT(GT); - myHB = new TopOpeBRepBuild_HBuilder(BT); - myHB->ChangeBuilder().ChangeClassify(Standard_False); - - myState1 = TopAbs_UNKNOWN; - myState2 = TopAbs_UNKNOWN; - -} - - -// Filling of the DS - -//======================================================================= -//function : Load -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Load(const TopoDS_Shape& S) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - myS1 = S; - DS.AddShape(S, 1); -} - -//======================================================================= -//function : Load -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Load(TopoDS_Shape& S1, - TopoDS_Shape& S2) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - - if ( S1.Orientation() == TopAbs_REVERSED ) { - S1.Orientation(TopAbs_FORWARD); - } - if ( S2.Orientation() == TopAbs_REVERSED ) { - S2.Orientation(TopAbs_FORWARD); - } - - DS.AddShape(S1,1); - DS.AddShape(S2,2); - - TopOpeBRepTool_ShapeExplorer ex1,ex2; - for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) { - const TopoDS_Shape& so1 = ex1.Current(); - for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) { - const TopoDS_Shape& so2 = ex2.Current(); - DS.FillShapesSameDomain(so1,so2); - } - } - - myS1 = S1; - myS2 = S2; - -} - -//======================================================================= -//function : Intersect -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Intersect() -{ - myRecomputeBuilderIsDone = Standard_False; - - if(!myS1.IsNull() && !myS2.IsNull()) - myDSFiller.Insert(myS1, myS2, myHDS); -} - -//======================================================================= -//function : Intersect -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Intersect -(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - myRecomputeBuilderIsDone = Standard_False; - - if(S1.IsNull() || S2.IsNull()) { - return; - } - - Standard_Boolean orientFORWARD = Standard_False; - TopExp_Explorer exp; - if(S1.ShapeType() != TopAbs_FACE) { - exp.Init(S1, TopAbs_FACE); - if(!exp.More()) - return; - } - if(S2.ShapeType() != TopAbs_FACE) { - exp.Init(S2, TopAbs_FACE); - if(!exp.More()) - return; - } - myDSFiller.Insert(S1, S2, myHDS, orientFORWARD); -} - -//======================================================================= -//function : SameDomain -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::SameDomain -(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - myRecomputeBuilderIsDone = Standard_False; - - if(S1.IsNull() || S2.IsNull()) - return; - - TopExp_Explorer exp1, exp2; - exp1.Init(S1, TopAbs_FACE); - if(!exp1.More()) - return; - exp2.Init(S2, TopAbs_FACE); - if(!exp2.More()) - return; - - myDSFiller.Insert2d(S1, S2, myHDS); -} - - -// Construction of Sections - -#define FindKeep Standard_False - -//======================================================================= -//function : GetSectionEdgeSet -//purpose : -//======================================================================= - -const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet -(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - GetSectionEdgeSet(); - - // Check if S1 and S2 contain faces - TopExp_Explorer exp1, exp2; - exp1.Init(S1, TopAbs_FACE); - if(!exp1.More()) - return myEmptyListOfShape; - exp2.Init(S2, TopAbs_FACE); - if(!exp2.More()) - return myEmptyListOfShape; - - for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) { - if(!myHDS->HasShape(exp1.Current(), FindKeep)) - return myEmptyListOfShape; - } - for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) - if(!myHDS->HasShape(exp2.Current(), FindKeep)) - return myEmptyListOfShape; - - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder(); - - // The purpose is to find interferences associated with faces, - // edges that come from their Geometry (= Edge || Curve) - TopTools_ListOfShape LE; - LE.Clear(); - TopExp_Explorer exp; - for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) { - const TopoDS_Shape& F1 = exp1.Current(); - - TopOpeBRepDS_ListOfInterference& lof = DS.ChangeShapeInterferences(F1); - TopOpeBRepDS_InterferenceIterator li(lof); - li.SupportKind(TopOpeBRepDS_FACE); - for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) { - const TopoDS_Shape& F2 = exp2.Current(); - Standard_Integer si = DS.Shape(F2, FindKeep); - li.Support(si); - - for(; li.More(); li.Next()) { - const TopOpeBRepDS_Interference& CurrInt = li.Value(); - TopOpeBRepDS_Kind gk = CurrInt.GeometryType(); - Standard_Integer gi = CurrInt.Geometry(); - const TopoDS_Shape& geosha = DS.Shape(gi, FindKeep); - if(gk == TopOpeBRepDS_CURVE) { - const TopTools_ListOfShape& lEdge = myHB->NewEdges(gi); - LE.Append(lEdge.First()); - } else { - const TopTools_ListOfShape& lEdge = Builder.Splits(geosha, TopAbs_ON); - TopTools_ListIteratorOfListOfShape it(lEdge); - for(; it.More(); it.Next()) { - const TopoDS_Shape& CurrEdge = it.Value(); - Standard_Integer ipv1, ipv2; - TopOpeBRepDS_Kind pvk1, pvk2; - PntVtxOnSectEdge(CurrEdge, ipv1, pvk1, ipv2, pvk2); - if(pvk1 != TopOpeBRepDS_VERTEX) { - ipv1 = 0; - if(pvk2 != TopOpeBRepDS_VERTEX) continue; - } else { - if(pvk2 != TopOpeBRepDS_VERTEX) - ipv2 = 0; - } - for(exp.Init(F1, TopAbs_VERTEX); exp.More(); exp.Next()) { - Standard_Integer iVert = DS.Shape(exp.Current()); - if(iVert) { - if((iVert == ipv1) || (iVert == ipv2)) { - LE.Append(CurrEdge); - break; - } - } - } - } - } - } - } - } - - // find all groups of connected Edges associated to LE - TopTools_ListIteratorOfListOfShape ILE; - myCurrentList.Clear(); - TopTools_MapOfShape ME; - ME.Clear(); - TopTools_ListIteratorOfListOfShape ILC; - TopExp_Explorer ECE; - ILE.Initialize(LE); - for(;ILE.More();ILE.Next()) { - const TopoDS_Shape& E = ILE.Value(); - ILC.Initialize(myListOfCompoundOfEdgeConnected); - for(;ILC.More();ILC.Next()) { - const TopoDS_Shape& Com = ILC.Value(); - ECE.Init(Com, TopAbs_EDGE); - for(;ECE.More();ECE.Next()) { - if(ECE.Current().IsSame(E)) { - if(!ME.Contains(Com)) { - myCurrentList.Append(Com); - ME.Add(Com); - break; - } - } - } - } - } - - return myCurrentList; -} - -//======================================================================= -//function : GetSectionEdgeSet -//purpose : -//======================================================================= - -const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet() -{ - if(!myRecomputeBuilderIsDone) { - // it is possible to call the method many times consecutively - myHDS->AddAncestors(myS1); - // start of lpa modification - if (!myS1.IsSame(myS2) && !myS2.IsNull()) { - myHDS->AddAncestors(myS2); - myHB->Perform(myHDS,myS1,myS2); - } - else { - myHB->Perform(myHDS); - } - // end of modif lpa - myRecomputeBuilderIsDone = Standard_True; - myGetSectionIsDone = Standard_False; - } - if(myGetSectionIsDone) - return myListOfCompoundOfEdgeConnected; - myGetSectionIsDone = Standard_True; - - myListOfCompoundOfEdgeConnected.Clear(); - - // EdgeConnector - Handle(BRepAlgo_EdgeConnector) EC = myEC; - EC->ClearStartElement(); - TopTools_MapOfShape ME; - ME.Clear(); - myHB->InitSection(); - for(; myHB->MoreSection(); myHB->NextSection()) { - const TopoDS_Edge& ES = TopoDS::Edge(myHB->CurrentSection()); - if(ME.Contains(ES)) continue; - ME.Add(ES); - EC->AddStart(ES); - } - TopTools_ListOfShape& LW = EC->MakeBlock(); - - // the wires are tranformed into compounds. - myCompoundWireMap.Clear(); - BRep_Builder BB; - TopTools_ListIteratorOfListOfShape ILW(LW); - TopExp_Explorer Explor; - for(;ILW.More();ILW.Next()) { - TopoDS_Compound Compound; -//POP - BB.MakeCompound(Compound); -// BB.MakeCompound(TopoDS::Compound(Compound)); - Explor.Init(ILW.Value(), TopAbs_EDGE); - for(;Explor.More(); Explor.Next()) { - BB.Add(Compound, Explor.Current()); - } - myListOfCompoundOfEdgeConnected.Append(Compound); - myCompoundWireMap.Bind(Compound,ILW.Value()); - } - return myListOfCompoundOfEdgeConnected; -} - -//======================================================================= -//function : IsWire -//purpose : -//======================================================================= - -Standard_Boolean BRepAlgo_DSAccess::IsWire(const TopoDS_Shape& S) -{ - Standard_Boolean b = Standard_False; - if(myEC->IsDone()) { - if (myCompoundWireMap.IsBound(S)) - b = myEC->IsWire(myCompoundWireMap(S)); - } - return b; -} - -//======================================================================= -//function : Wire -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_DSAccess::Wire(const TopoDS_Shape& S) -{ - if(!IsWire(S)) { - myWire.Nullify(); - } - else { - BRep_Builder BB; - BB.MakeWire(myWire); - TopExp_Explorer Explor(S, TopAbs_EDGE); - for(;Explor.More(); Explor.Next()) BB.Add(myWire, Explor.Current()); - } - return myWire; -} - -//======================================================================= -//function : SectionVertex -//purpose : -//======================================================================= - -const TopTools_ListOfShape& BRepAlgo_DSAccess::SectionVertex -(const TopoDS_Shape& F, - const TopoDS_Shape& E) -{ - myListOfVertex.Clear(); - if(F.ShapeType() != TopAbs_FACE || E.ShapeType() != TopAbs_EDGE) - return myListOfVertex; - Standard_Integer iF = myHDS->Shape(F), iE = myHDS->Shape(E); - if((iF == 0) || (iE == 0)) - return myListOfVertex; - - const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); - const TopOpeBRepDS_ListOfInterference& LI = - DS.ShapeInterferences(E, Standard_False); - TopOpeBRepDS_InterferenceIterator II(LI); - Standard_Integer goodIndex = 0; - TopOpeBRepDS_Kind goodKind; - for(;II.More();II.Next()) { - const Handle(TopOpeBRepDS_Interference)& I = II.Value(); - const TopOpeBRepDS_Transition& T = I->Transition(); - if((T.ONAfter() == TopAbs_FACE) && - (T.IndexAfter() == iF)) { - goodKind = I->GeometryType(); - goodIndex = I->Geometry(); - if(goodKind == TopOpeBRepDS_VERTEX) - myListOfVertex.Append(myHDS->Shape(goodIndex)); - else - if (goodKind == TopOpeBRepDS_POINT) - myListOfVertex.Append(myHB->NewVertex(goodIndex)); - } - } - return myListOfVertex; -} - - -// Editing of the DS - -//======================================================================= -//function : SuppressEdgeSet -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::SuppressEdgeSet -(const TopoDS_Shape& C) -{ - // It is checked if C really is a Coumpound of connected Edges - - myHB->InitExtendedSectionDS(); -// myGetSectionIsDone = Standard_False; - - TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected); - for(;LLS.More(); LLS.Next()) - if(C == LLS.Value()) - break; - if(!LLS.More()) - return; - - // Cleaning - TopoDS_Shape Empty; - Empty.Nullify(); - Suppress(C, Empty); - myListOfCompoundOfEdgeConnected.Remove(LLS); -} - -//======================================================================= -//function : ChangeEdgeSet -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::ChangeEdgeSet -(const TopoDS_Shape& Old, const TopoDS_Shape& New) -{ - // It is checked if Old is a Coumpound of connected Edges - - myHB->InitExtendedSectionDS(); - - TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected); - for(;LLS.More(); LLS.Next()) - if(Old == LLS.Value()) - break; - if(!LLS.More()) - return; - - // The compound of Edges to be rotated is constructed - BRep_Builder B; - Standard_Boolean Trouve; - Standard_Integer iC; - TopoDS_Compound C; - TopoDS_Edge E; - B.MakeCompound(C); - TColStd_PackedMapOfInteger RPoint; //The points to be controlled - - TopOpeBRepDS_ListIteratorOfListOfInterference iter; - TopExp_Explorer exp(Old, TopAbs_EDGE); - TopExp_Explorer exp2; - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& Edge = exp.Current(); - for(exp2.Init(New, TopAbs_EDGE), Trouve=Standard_False; - exp2.More() && (!Trouve); exp2.Next()) { - E = TopoDS::Edge(exp2.Current()); - Trouve = E.IsSame(Edge); - } - - if (!Trouve) B.Add(C, Edge); // Edge to be removed - else if (!E.IsEqual(Edge)) { - // It is necessary to change Interferences => take the complement - iC = myHB->GetDSCurveFromSectEdge(Edge); - if (!iC) { -#ifdef OCCT_DEBUG - cout << "Warning DSAccess: Modifications of Edge are not implemented" << endl; -#endif - } - else { - // Complete the interferences Curve/Face - Standard_Integer iF; - Handle(TopOpeBRepDS_Interference) interf; - - iF = myHB->GetDSFaceFromDSCurve(iC, 1); - TopOpeBRepDS_ListOfInterference& list1 = - myHDS->ChangeDS().ChangeShapeInterferences(iF); - for(iter.Initialize(list1); iter.More(); iter.Next()) { - interf = iter.Value(); - if (interf->Geometry() == iC) - interf->Transition(interf->Transition().Complement()); - } - iF = myHB->GetDSFaceFromDSCurve(iC, 2); - TopOpeBRepDS_ListOfInterference& list2 = - myHDS->ChangeDS().ChangeShapeInterferences(iF); - for(iter.Initialize(list2); iter.More(); iter.Next()) { - interf = iter.Value(); - if (interf->Geometry() == iC) - interf->Transition(interf->Transition().Complement()); - } - // The associated points are recorded - Standard_Integer ipv1, ipv2; - //Standard_Boolean bid; // skl - TopOpeBRepDS_Kind k1, k2; - PntVtxOnCurve(iC, ipv1, k1, ipv2, k2); - if (ipv1 != 0) /*bid = */RPoint.Add(ipv1); // skl - if (ipv2 != 0) /*bid = */RPoint.Add(ipv2); // skl - } - } - } - - - // Cleaning - Suppress(C, New); - - // Is it necessary to invert the Interferences "Edge on Fa" - if (!RPoint.IsEmpty()) { - const TopOpeBRepDS_DataStructure & DS = myHDS->DS(); - Standard_Integer iP,iE, nbShape = DS.NbShapes(); - Handle(TopOpeBRepDS_Interference) interf; - for (iE=1; iE<=nbShape; iE++) { - if (DS.Shape(iE,0).ShapeType() == TopAbs_EDGE) { - const TopOpeBRepDS_ListOfInterference& List = - myHDS->DS().ShapeInterferences(iE); - for(iter.Initialize(List); iter.More(); iter.Next()) { - interf = iter.Value(); - if (interf->GeometryType() == TopOpeBRepDS_POINT) { - iP = interf->Geometry(); - if (RPoint.Contains(iP)) - interf->Transition(interf->Transition().Complement()); - } - } - } - } - } - - // The old is replaced by new - LLS.Value() = New; -} - - -//======================================================================= -//function : Remove -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::Suppress(const TopoDS_Shape& C, - const TopoDS_Shape& Keep) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder(); - Standard_Integer i, iC = 0, iF1, iF2,iE1, iE2; -// TopOpeBRepDS_ListIteratorOfListOfInterference; - TColStd_ListIteratorOfListOfInteger it1, it2; - - //A group of points to be kept is constructed - mySetOfKeepPoint.Clear(); - if (!Keep.IsNull()) { - //Standard_Boolean B; // skl - Standard_Integer ipv1, ipv2; - TopOpeBRepDS_Kind k1, k2; - TopExp_Explorer exp(Keep, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& SectEdge = exp.Current(); - iC = myHB->GetDSCurveFromSectEdge(SectEdge); - if(!iC) - PntVtxOnSectEdge(SectEdge, ipv1, k1, ipv2, k2); - else - PntVtxOnCurve(iC, ipv1, k1, ipv2, k2); - if (ipv1 != 0) /*B = */mySetOfKeepPoint.Add(ipv1); // skl - if (ipv2 != 0) /*B = */mySetOfKeepPoint.Add(ipv2); // skl - } - } - - // The curves, which generated the the Edges, are found - // during the parsing the Edges which come from Edge are found - // (= MapOfInteger : ESE) - - // First, the interferences of support 1d. - TopExp_Explorer exp(C, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& SectEdge = exp.Current(); - iC = myHB->GetDSCurveFromSectEdge(SectEdge); - if(!iC) { - // the Edges that come from Edge are processed - // the interferences connected with Edges are processed : - iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); - iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); - - RemoveEdgeInterferences(iE1,iE2,SectEdge); - - TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1); - TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2); - for(it1.Initialize(loi11); it1.More(); it1.Next()) { - iF1 = it1.Value(); - for(it2.Initialize(loi12); it2.More(); it2.Next()) { - iF2 = it2.Value(); - // similar to the case of SectEdges coming from curve. - RemoveEdgeInterferences(iF1,iF2,SectEdge); - } - } - TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1); - TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2); - for(it1.Initialize(loi21); it1.More(); it1.Next()) { - iF1 = it1.Value(); - for(it2.Initialize(loi22); it2.More(); it2.Next()) { - iF2 = it2.Value(); - // similar to the case of SectEdges coming from curve. - RemoveEdgeInterferences(iF1,iF2,SectEdge); - } - } - continue; - } - // The Edges that come from Curve are processed - iF1 = myHB->GetDSFaceFromDSCurve(iC, 1); - iF2 = myHB->GetDSFaceFromDSCurve(iC, 2); - - RemoveEdgeInterferences(iF1, iF2, iC); - DS.ChangeKeepCurve(iC, FindKeep); - } - - // Secondly, the interferences of 2D support. - exp.Init(C, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& SectEdge = exp.Current(); - iC = myHB->GetDSCurveFromSectEdge(SectEdge); - if(!iC) { - iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); - iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); - TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1); - TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2); - for(it1.Initialize(loi11); it1.More(); it1.Next()) { - iF1 = it1.Value(); - for(it2.Initialize(loi12); it2.More(); it2.Next()) { - iF2 = it2.Value(); - if(iF1 == iF2) - continue; - RemoveFaceInterferences(iF1, iF2, iE1, iE2); - } - } - TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1); - TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2); - for(it1.Initialize(loi21); it1.More(); it1.Next()) { - iF1 = it1.Value(); - for(it2.Initialize(loi22); it2.More(); it2.Next()) { - iF2 = it2.Value(); - if(iF1 == iF2) - continue; - RemoveFaceInterferences(iF1, iF2, iE1, iE2); - } - } - } - else { - iF1 = myHB->GetDSFaceFromDSCurve(iC, 1); - iF2 = myHB->GetDSFaceFromDSCurve(iC, 2); - - RemoveFaceInterferences(iF1, iF2, iC); - } - } - - // Thirdly, RemoveSameDomain is done for the faces that contain all Edges of C, - // and are SameDomain and without Geometry. - - RemoveFaceSameDomain(C); - - // Fourthly, the faces, that were not concerned, are removed - Standard_Integer NbSh = DS.NbShapes(); - for(i = 1; i <= NbSh; i++) { - const TopoDS_Shape& Face = DS.Shape(i); - if(Face.IsNull()) - continue; - if((Face.ShapeType() != TopAbs_FACE) || DS.HasGeometry(Face) || - (myHDS->HasSameDomain(Face))) - continue; - for(exp.Init(Face, TopAbs_EDGE); exp.More(); exp.Next()){ - const TopoDS_Shape& Edge = exp.Current(); - if(DS.HasShape(Edge)) - break; - } - if(exp.More()) - continue; - DS.ChangeKeepShape(Face, Standard_False); - } - - // Builder.myKPMAPf1f2 is reconstructed - Builder.FindIsKPart(); - - // The Edges of section are removed from Builder.mySplitON - exp.Init(C, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& SectE= exp.Current(); - TopTools_ListOfShape& losob = Builder.ChangeSplit(SectE, TopAbs_ON); - losob.Clear(); - } -} - -//======================================================================= -//function : SuppressSectionVertex -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::SuppressSectionVertex -(const TopoDS_Vertex& /*V*/) -{ - if(!myRecomputeBuilderIsDone) - return; -} - - -// Reconstruction of Shapes - -//======================================================================= -//function : Merge -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_DSAccess::Merge -(const TopAbs_State state1, - const TopAbs_State state2) -{ - if((state1 != TopAbs_IN) && - (state1 != TopAbs_OUT)) - return myEmptyShape; - if((state2 != TopAbs_IN) && - (state2 != TopAbs_OUT)) - return myEmptyShape; - // if GetSectionEdgeSet has already been called, nothing is done - // in GetSectionEdgeSet. - if(myState1 != TopAbs_UNKNOWN) - if(myState1 != state1 || myState2 != state2) - myGetSectionIsDone = Standard_False; - myState1 = state1; - myState2 = state2; - GetSectionEdgeSet(); - - myHB->Clear(); - myHB->MergeShapes(myS1,state1,myS2,state2); - const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1); - - BRep_Builder BB; - myResultShape.Nullify(); - BB.MakeCompound(TopoDS::Compound(myResultShape)); - TopTools_ListIteratorOfListOfShape it(L1); - for(;it.More(); it.Next()) { - BB.Add(myResultShape, it.Value()); - } - return myResultShape; -} - -//======================================================================= -//function : Merge -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_DSAccess::Merge -(const TopAbs_State state1) -{ - if((state1 != TopAbs_IN) && - (state1 != TopAbs_OUT)) - return myEmptyShape; - GetSectionEdgeSet(); - - myHB->Clear(); - myHB->MergeSolid(myS1,state1); - const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1); - - BRep_Builder BB; - myResultShape.Nullify(); - BB.MakeCompound(TopoDS::Compound(myResultShape)); - TopTools_ListIteratorOfListOfShape it(L1); - for(;it.More(); it.Next()) { - BB.Add(myResultShape, it.Value()); - } - return myResultShape; -} - -//======================================================================= -//function : Propagate -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_DSAccess::Propagate -(const TopAbs_State what, - const TopoDS_Shape& /*fromShape*/, - const TopoDS_Shape& /*LoadShape*/) -{ - if((what != TopAbs_IN) && - (what != TopAbs_OUT)) - return myEmptyShape; - if(!myRecomputeBuilderIsDone) - return myEmptyShape; - -// myHB->MergeShapes(myS1,t1,myS2,t2); - - //POP for NT; - static TopoDS_Shape bid; - return bid; -} - -//======================================================================= -//function : PropagateFromSection -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_DSAccess::PropagateFromSection -(const TopoDS_Shape& SectionShape) -{ - GetSectionEdgeSet(); - TopTools_ListIteratorOfListOfShape ils(myListOfCompoundOfEdgeConnected); - TopExp_Explorer exp; - for(; ils.More(); ils.Next()) { - const TopoDS_Shape& SetEdgSet = ils.Value(); - exp.Init(SetEdgSet, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - if(SectionShape.IsSame(exp.Current())) - return SetEdgSet; - } - } - return myEmptyShape; -} - -//======================================================================= -//function : Modified -//purpose : -//======================================================================= - -const TopTools_ListOfShape& BRepAlgo_DSAccess::Modified (const TopoDS_Shape& Shape) -{ - myModified.Clear() ; - -// Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ; - TopTools_ListIteratorOfListOfShape Iterator ; - - if (myHB->IsSplit (Shape, TopAbs_OUT)) { - for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_OUT)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - if (myHB->IsSplit (Shape, TopAbs_IN)) { - for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_IN)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - if (myHB->IsSplit (Shape, TopAbs_ON)) { - for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_ON)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - - if (myHB->IsMerged (Shape, TopAbs_OUT)) { - for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_OUT)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - if (myHB->IsMerged(Shape, TopAbs_IN)) { - for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_IN)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - if (myHB->IsMerged(Shape, TopAbs_ON)) { - for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_ON)) ; - Iterator.More() ; - Iterator.Next()) { - myModified.Append (Iterator.Value()) ; - } - } - - return myModified ; -} - - - -//======================================================================= -//function : Check -//purpose : -//======================================================================= - -BRepAlgo_CheckStatus BRepAlgo_DSAccess::Check() -{ -// TopOpeBRepDS_Check Ck(HDS); -// to be precised : in Ck, there is a possibility to know -// exactly the n*n of shapes/points/curves/surfaces, -// which are not correct in the DS. -// Standard_Boolean IsOK = Ck.ChkIntgSamDom() ; -// IsOK = IsOK && Ck.OneVertexOnPnt(); -// IsOK = IsOK && Ck.ChkIntg(); -// if(IsOK) -// return TopOpeBRepDS_OK; - return BRepAlgo_NOK; -} - -//======================================================================= -//function : RemoveEdgeInterferences -//purpose : case of SectEdge coming from Edge(s) -// -// if iE1 and iE2 are Edges : -// Remove interferences of DSEdge(= iE1 or iE2) of -// geometry a vertex of SectEdge, and if there is nothing else, -// make unkeep on DSEdge -// if iE1 or iE2 == 0, no interference on Edges in the DS -// NYI : management of SameDomain -// -// if iE1 and iE2 are Faces : -// for each of faces F1 and F2, explode into Edges -// for each Edge : -// remove the interferences of a SectEdge vertex -// on geometry. If there is no other interferences attached to -// these Edges, and if these Edges are not SameDomain, -// make unKeepShape. -//======================================================================= - -void BRepAlgo_DSAccess::RemoveEdgeInterferences -(const Standard_Integer iE1, - const Standard_Integer iE2, - const TopoDS_Shape& SectEdge) -{ - if(!iE1 || !iE2) - return; - - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepDS_Kind kind1, kind2; - TopExp_Explorer exp(SectEdge, TopAbs_VERTEX); - Standard_Integer i = 1, ipv1, ipv2; - - // the Vertex/Points of SectEdge are retrieved - PntVtxOnSectEdge(SectEdge, ipv1, kind1, ipv2, kind2); - - const TopoDS_Shape& Shape = DS.Shape(iE1, FindKeep); - if(Shape.IsNull()) - return; - if(Shape.ShapeType() == TopAbs_FACE) { - Standard_Integer iF1 = iE1, iF2 = iE2; - RemoveEdgeInterferencesFromFace(iF1, iF2, ipv1, kind1, ipv2, kind2); - return; - } - else if(Shape.ShapeType() != TopAbs_EDGE) - return; - - // the interferences are taken from the DS - TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; - TopOpeBRepDS_Kind gk; - Standard_Integer iCurrE1, iCurrE2, gi; -// Standard_Boolean RemInterf; - - for(i = 1; i <= 2; i++) { - iCurrE1 = ((i == 1) ? iE1 : iE2); - iCurrE2 = ((i == 1) ? iE2 : iE1); - const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep); - if(DSEdge.IsNull()) - continue; - TopOpeBRepDS_ListOfInterference& loi = - DS.ChangeShapeInterferences(DSEdge); - // RemInterf = Standard_True; - for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { - Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); - if (I.IsNull()) continue; - if((I->SupportType() != TopOpeBRepDS_EDGE) || - (I->Support() != iCurrE2)) { - // RemInterf = Standard_False;//debug ... - continue; - } - gk = I->GeometryType(); - gi = I->Geometry(); - if(gk == kind1) { - if(gi == ipv1) { - DS.RemoveShapeInterference(DSEdge, I); - if(!DS.HasGeometry(DSEdge)) { - // if(RemInterf || (!lioloi.More())) { - RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain - DS.ChangeKeepShape(iCurrE1, FindKeep); - // } - } - } - } - else if(gk == kind2) { - if(gi == ipv2) { - DS.RemoveShapeInterference(DSEdge, I); - if(!DS.HasGeometry(DSEdge)) { - // if(RemInterf || (!lioloi.More())) {//debug - RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain - DS.ChangeKeepShape(iCurrE1, FindKeep); - // } - } - } - } - } - } -} - -//======================================================================= -//function : RemoveEdgeInterferences -//purpose : case of SectEdge coming from Curve -// for each of faces F1 and F2, explode into Edges -// for each Edge : -// remove the interferences that have a vertex of SectEdge -// as a geometry. If no other interferences are attached to -// these Edges, and if the Edges are not SameDomain, -// make unKeepShape. -//======================================================================= - -void BRepAlgo_DSAccess::RemoveEdgeInterferences -(const Standard_Integer iF1, - const Standard_Integer iF2, - const Standard_Integer iCurve) -{ - TopOpeBRepDS_Kind gk1, gk2; - Standard_Integer gi1, gi2; - - PntVtxOnCurve(iCurve, gi1, gk1, gi2, gk2); - - if (!mySetOfKeepPoint.IsEmpty()) { - if (mySetOfKeepPoint.Contains(gi1)) gi1 = 0; - if (mySetOfKeepPoint.Contains(gi2)) gi2 = 0; - } - - if (gi1 || gi2) - RemoveEdgeInterferencesFromFace(iF1, iF2, gi1, gk1, gi2, gk2); -} - -//======================================================================= -//function : RemoveFaceInterferences -//purpose : case of SectEdge coming from Edge(s) -// Remove interferences between F1 and F2 concerning -// DSEdge (= E1 or E2) : -// a) if DSEdge is not SameDomain -> the edge is Removed -// b) if among other interferences of DSEdge of -// GeomtryType == VERTEX, there is none -// with Edge of DSFace(= F1 or F2) -// if DSFace has no more interferences and is not SameDomain, -// make unkeep DSFace. -//======================================================================= - -void BRepAlgo_DSAccess::RemoveFaceInterferences -(const Standard_Integer iF1, - const Standard_Integer iF2, - const Standard_Integer iE1, - const Standard_Integer iE2) -{ - if(!iF1 || !iF2) - return; - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;//, lioloei, liolofi; - TopTools_ListIteratorOfListOfShape liolos; - TopOpeBRepDS_Kind gk; - TopExp_Explorer exp; - Standard_Integer i, iCurrF1, iCurrF2, j, iCurrE1, /*iCurrE2,*/ gi; // skl - Standard_Boolean RemInterf; - - for(i = 1; i <= 2; i++) { - iCurrF1 = ((i == 1) ? iF1 : iF2); - iCurrF2 = ((i == 1) ? iF2 : iF1); - const TopoDS_Shape& DSFace = DS.Shape(iCurrF1); - if(DSFace.IsNull()) - continue; - const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace); - for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { - Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); - if (I.IsNull()) continue; - if((I->SupportType() != TopOpeBRepDS_FACE) || - (I->Support() != iCurrF2)) { - continue; - } - gk = I->GeometryType(); - gi = I->Geometry(); - if(gk != TopOpeBRepDS_EDGE) continue; - for(j = 1; j <= 2; j++) { - iCurrE1 = ((j == 1) ? iE1 : iE2); - //iCurrE2 = ((j == 1) ? iE2 : iE1); // skl - if(gi != iCurrE1) continue; - // a) if DSEdge is not SameDomain -> the interference is Removed - // et DSEdge - const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep); - if(DSEdge.IsNull()) - continue; - if(!myHDS->HasSameDomain(DSEdge)) { - if(!DS.HasGeometry(DSEdge)) { - DS.RemoveShapeInterference(DSFace, I); - DS.ChangeKeepShape(DSEdge, FindKeep); - } else { - // NYI : manage the case when the geometry of DSEdge - // NYI : is not connected anyhow with two faces - } - if(!DS.HasGeometry(DSFace)) { - DS.ChangeKeepShape(DSFace, FindKeep); - } - continue; - } - // b) if no Edges of SameDomain(DSEdge), - // belong to DSFace(= F1 or F2) - // -> the interference is removed - const TopoDS_Shape& Edge = DS.Shape(iCurrE1, FindKeep); - if(Edge.IsNull()) - continue; - const TopTools_ListOfShape& loe = DS.ShapeSameDomain(Edge); - RemInterf = Standard_True; - for(liolos.Initialize(loe); liolos.More(); liolos.Next()) { - const TopoDS_Shape& ESD = liolos.Value(); - for(exp.Init(DSFace, TopAbs_EDGE); exp.More(); exp.Next()) { - if(ESD.IsSame(exp.Current())) { - RemInterf = Standard_False; - break; - } - } - if(!RemInterf) break; - } - if(RemInterf) { - // RemoveSameDomain(iCurrF1, iCurrF2); - - if(!DS.HasGeometry(DSFace)) { - if(!myHDS->HasSameDomain(DSFace)) - DS.ChangeKeepShape(DSFace, FindKeep); - } - } - if(!DS.HasGeometry(DSFace) && !myHDS->HasSameDomain(DSFace)) - DS.ChangeKeepShape(DSFace, FindKeep); - } - } - } -} - -//======================================================================= -//function : RemoveFaceInterferences -//purpose : case of SectEdge from Curve -// remove interferences of Geometry iCurve between F1 and F2. -// if Face(= F1 or F2) has noother interference, and if Face -// is not SameDomain, make unKeepShape Face. -//======================================================================= - -void BRepAlgo_DSAccess::RemoveFaceInterferences -(const Standard_Integer iF1, - const Standard_Integer iF2, - const Standard_Integer iCurve) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; - TopOpeBRepDS_Kind gk; - Standard_Integer i, iCurrF1, iCurrF2, gi; - - for(i = 1; i <= 2; i++) { - iCurrF1 = ((i == 1) ? iF1 : iF2); - iCurrF2 = ((i == 1) ? iF2 : iF1); - const TopoDS_Shape& DSFace = DS.Shape(iCurrF1); - const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace); - for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { - Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); - if (I.IsNull()) continue; - if((I->SupportType() != TopOpeBRepDS_FACE) || - (I->Support() != iCurrF2)) { - break;; - } - } - for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { - Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); - if (I.IsNull()) continue; - if((I->SupportType() != TopOpeBRepDS_FACE) || - (I->Support() != iCurrF2)) { - continue; - } - gk = I->GeometryType(); - gi = I->Geometry(); - if(gk != TopOpeBRepDS_CURVE) continue; - if(gi != iCurve) continue; - DS.RemoveShapeInterference(DSFace, I); -// const TopoDS_Shape& interferenceface = DS.Shape(iCurrF2); -// DS.RemoveShapeInterference(interferenceface, I); - if(!DS.HasGeometry(DSFace)) { - const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSFace); - if(los.IsEmpty()) - DS.ChangeKeepShape(DSFace, FindKeep); - } -// if(!DS.HasGeometry(interferenceface)) { -// const TopTools_ListOfShape& los = DS.ShapeSameDomain(interferenceface); -// if(los.IsEmpty()) -// DS.ChangeKeepShape(interferenceface, FindKeep); -// } - } - } -} - -//======================================================================= -//function : RemoveEdgeInterferencesFromFace -//purpose : Remove interferences of Edges from iF1 or iF2 -// that have GeometryType kind1/kind2 and -// Geometry ipv1/ipv2. -// if kind1/kind2 == TopAbs_VERTEX -> RemoveEdgeFromFace -//======================================================================= - -void BRepAlgo_DSAccess::RemoveEdgeInterferencesFromFace -(const Standard_Integer iF1, - const Standard_Integer iF2, - const Standard_Integer ipv1, - const TopOpeBRepDS_Kind kind1, - const Standard_Integer ipv2, - const TopOpeBRepDS_Kind kind2) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; - TopExp_Explorer exp, exp2; - TopOpeBRepDS_Kind sk, gk; - Standard_Integer i, iCurrF1, iCurrF2, iE = 0, si, gi; - - for(i = 1; i <= 2; i++) { - iCurrF1 = ((i == 1) ? iF1 : iF2); - iCurrF2 = ((i == 1) ? iF2 : iF1); - const TopoDS_Shape& DSFace = DS.Shape(iCurrF1, FindKeep); - if(DSFace.IsNull()) - continue; - exp.Init(DSFace, TopAbs_EDGE); - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& DSEdge = exp.Current(); - iE = DS.Shape(DSEdge, FindKeep); - if(!iE) continue; - const TopOpeBRepDS_ListOfInterference& loi = - DS.ShapeInterferences(DSEdge); - for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { - Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); - if (I.IsNull()) continue; - sk = I->SupportType(); - si = I->Support(); - if((sk != TopOpeBRepDS_FACE) || (si != iCurrF2)) { - if(sk != TopOpeBRepDS_EDGE) - continue; - const TopoDS_Shape& DSFace2 = DS.Shape(iCurrF2, FindKeep); - exp2.Init(DSFace2, TopAbs_EDGE); - for(; exp2.More(); exp2.Next()) { - if(si == DS.Shape(exp2.Current(), FindKeep)) - break; - } - if(!exp2.More()) - continue; - } - gk = I->GeometryType(); - gi = I->Geometry(); - if(gk == kind1) { - if(gi == ipv1) { - DS.RemoveShapeInterference(DSEdge, I); -// if(!DS.HasGeometry(DSEdge)) { -// const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge); -// if(los.IsEmpty()) { -// DS.ChangeKeepShape(iE, FindKeep); -// } -// } - } - else if(gk == kind2) { - if(gi == ipv2) { - DS.RemoveShapeInterference(DSEdge, I); -// if(!DS.HasGeometry(DSEdge)) { -// const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge); -// if(los.IsEmpty()) { -// DS.ChangeKeepShape(iE, FindKeep); -// } -// } - } - } - else continue; - } - } - } - if(kind1 == TopOpeBRepDS_VERTEX) - RemoveEdgeFromFace(iCurrF1,ipv1); - if(kind2 == TopOpeBRepDS_VERTEX) - RemoveEdgeFromFace(iCurrF1,ipv2); - } -} - -//======================================================================= -//function : RemoveEdgeFromFace -//purpose : Remove from DS the Edges, which belong to iF -// and have iV as vertex if they do not have Geometry and -// are not SameDomain. -//======================================================================= - -void BRepAlgo_DSAccess::RemoveEdgeFromFace -(const Standard_Integer iF, - const Standard_Integer iV) -{ - if(!iF || !iV) - return; - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - const TopoDS_Shape& DSFace = DS.Shape(iF, FindKeep); - const TopoDS_Shape& Vertex = DS.Shape(iV, FindKeep); - if(DSFace.IsNull() || Vertex.IsNull()) - return; - TopExp_Explorer exp(DSFace, TopAbs_EDGE), exp2; - for(; exp.More(); exp.Next()) { - const TopoDS_Shape& Edge = exp.Current(); -#ifdef OCCT_DEBUG -// Standard_Integer iEdge2 = DS.Shape(Edge, FindKeep); -// Standard_Integer iEdge3 = DS.Shape(Edge); -#endif - - if(!DS.HasShape(Edge)) - continue; - exp2.Init(Edge, TopAbs_VERTEX); - for(; exp2.More(); exp2.Next()) { -#ifdef OCCT_DEBUG -// Standard_Integer iEdge5 = DS.Shape(Vertex, FindKeep); -// Standard_Integer iEdge4 = DS.Shape(Vertex); -// Standard_Integer iEdge6 = DS.Shape(exp2.Current(), FindKeep); -// Standard_Integer iEdge7 = DS.Shape(exp2.Current()); -#endif - - if(Vertex.IsSame(exp2.Current())) { - if(!DS.HasGeometry(Edge)) { - const TopTools_ListOfShape& los = DS.ShapeSameDomain(Edge); - if(los.IsEmpty()) { -#ifdef OCCT_DEBUG -// Standard_Integer iEdge = DS.Shape(Edge); -#endif - DS.ChangeKeepShape(Edge, FindKeep); - } - } - } - } - } -} - -//======================================================================= -//function : PntVtxOnCurve -//purpose : To find the points/vertices on curves -//======================================================================= - -void BRepAlgo_DSAccess::PntVtxOnCurve -(const Standard_Integer iCurve, - Standard_Integer& ipv1, - TopOpeBRepDS_Kind& pvk1, - Standard_Integer& ipv2, - TopOpeBRepDS_Kind& pvk2) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - - const TopOpeBRepDS_Curve& C = DS.Curve(iCurve); - TopOpeBRepDS_Kind pvk; - Standard_Integer ipv, iMother = C.Mother(), igoodC = iCurve, comp = 0; - if(iMother) igoodC = iMother; -//#ifndef OCCT_DEBUG - TopOpeBRepDS_PointIterator PII = myHDS->CurvePoints(igoodC); - TopOpeBRepDS_PointIterator& PIt = PII; // skl : I change "M_PI" to "PIt" -//#else -// TopOpeBRepDS_PointIterator& PIt = myHDS->CurvePoints(igoodC); -//#endif - for(;PIt.More(); PIt.Next()) { - comp++; - if(comp > 2) - // Standard_Error ... - return; - ipv = PIt.Current(); - // a point or a vertex is removed from the DS - if(PIt.IsPoint()) { - pvk = TopOpeBRepDS_POINT; - DS.ChangeKeepPoint(ipv, FindKeep); - } - else if(PIt.IsVertex()) { - pvk = TopOpeBRepDS_VERTEX; - DS.ChangeKeepShape(ipv, FindKeep); - } - else continue; - ((comp == 1) ? ipv1 : ipv2) = ipv; - ((comp == 1) ? pvk1 : pvk2) = pvk; - } -} - -//======================================================================= -//function : PntVtxOnSectEdge -//purpose : Points/Vertexes on SectEdge are found -//======================================================================= - -void BRepAlgo_DSAccess::PntVtxOnSectEdge -(const TopoDS_Shape& SectEdge, - Standard_Integer& ipv1, - TopOpeBRepDS_Kind& pvk1, - Standard_Integer& ipv2, - TopOpeBRepDS_Kind& pvk2) -{ - ipv1 = ipv2 = 0; - pvk1 = pvk2 = TopOpeBRepDS_UNKNOWN; - -// myHB->ChangeBuilder(); - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - TopOpeBRepDS_Kind kind = TopOpeBRepDS_POINT; - TopExp_Explorer exp(SectEdge, TopAbs_VERTEX); - Standard_Integer i = 1, ipv; - - for(; exp.More(); exp.Next(), i++) { - const TopoDS_Shape& DSVertex = exp.Current(); - ipv = myHB->GetDSPointFromNewVertex(DSVertex); - if(!ipv) { - ipv = DS.Shape(DSVertex, FindKeep); - kind = TopOpeBRepDS_VERTEX; - if(!ipv) - // Standard_Error ... - return; - } - - if(i == 1) { - ipv1 = ipv; - pvk1 = kind; - } - else if(i == 2) { - ipv2 = ipv; - pvk2 = kind; - } - else - // Standard_Error ... - return; - } -} - -//======================================================================= -//function : RemoveEdgeSameDomain -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::RemoveEdgeSameDomain -(const Standard_Integer /*iE1*/, - const Standard_Integer /*iE2*/) -{ - return; -/* TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - const TopoDS_Shape& E1 = DS.Shape(iE1); - const TopoDS_Shape& E2 = DS.Shape(iE2); - TopAbs_ShapeEnum ts1, ts2; - ts1 = E1.ShapeType(); - ts2 = E2.ShapeType(); - if((ts1 != TopAbs_EDGE) || - (ts2 != TopAbs_EDGE)) - return; - TopTools_ListOfShape& lossd = DS.ChangeShapeSameDomain(E1); - if(lossd.IsEmpty()) - return; - Standard_Integer exte = lossd.Extent(); - if(exte == 1) { - if(lossd.First().IsSame(E2)) - DS.UnfillShapesSameDomain(E1,E2); - return; - }*/ -} - -//======================================================================= -//function : RemoveFaceSameDomain -//purpose : remove SameDomain information of glued faces -//======================================================================= - -void BRepAlgo_DSAccess::RemoveFaceSameDomain -(const TopoDS_Shape& C) -{ -// myHB->ChangeBuilder(); - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - -//TColStd_ListIteratorOfListOfInteger it; - TopExp_Explorer exp(C, TopAbs_EDGE); - Standard_Integer iE1, iE2, iE, /*NbF,*/ iF1, iF2, iCurrF1, iCurrF2, iC =0; // skl - iF1 = iF2 = iCurrF1 = iCurrF2 = 0; - Standard_Boolean b; - const TopoDS_Shape& SectEdge = exp.Current(); - - for(; exp.More(); exp.Next()) { - iC = myHB->GetDSCurveFromSectEdge(SectEdge); - if(!iC && !SectEdge.IsNull()) - break; -// const TopoDS_Shape& SectEdge = exp.Current(); - } - if(!iC && !SectEdge.IsNull()) { - iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); - iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); - if(iE1 && iE2) return; - iE = (iE1 ? iE1 : iE2); - if(!iE) return; - - TColStd_ListOfInteger& loi = FindGoodFace(iE, iF1, b); - if(!b) return; - if(exp.More()) - exp.Next(); - //NbF = loi.Extent(); // skl - for(; exp.More(); exp.Next()) { - // skl : I change "SectEdge" to "SectEdg" - const TopoDS_Shape& SectEdg = exp.Current(); - iC = myHB->GetDSCurveFromSectEdge(SectEdg); - if(!iC) { - iE1 = myHB->GetDSEdgeFromSectEdge(SectEdg, 1); - iE2 = myHB->GetDSEdgeFromSectEdge(SectEdg, 2); - if(iE1 && iE2) return; - iE = (iE1 ? iE1 : iE2); - if(!iE) return; - - TColStd_ListOfInteger& loi2 = FindGoodFace(iE, iCurrF1, b); - if(!b) return; - if(!iCurrF1 || !iF1) return; - if(iCurrF1 != iF1) { - if(loi2.Extent() == 1) iCurrF2 = loi2.First(); - if(iCurrF2 == iF1) continue; - if(loi.Extent() == 1) iF2 = loi.First(); - - if(!iCurrF2 || !iF2) return; - if((iCurrF1 == iF2) || - (iCurrF2 == iF2)) { - iF1 = iF2; - continue; - } - return; - } - } - } - - const TopoDS_Shape& FSD = DS.Shape(iF1); - if(FSD.IsNull()) - return; - TopTools_ListOfShape& ssd = DS.ChangeShapeSameDomain(FSD); - TopTools_ListIteratorOfListOfShape itssd(ssd); - TopExp_Explorer exp2; - for(; itssd.More(); itssd.Next()) { - exp2.Init(itssd.Value(), TopAbs_VERTEX); - for(; exp2.More(); exp2.Next()) { - const TopoDS_Shape& exp2Curr = exp2.Current(); - exp.Init(C, TopAbs_VERTEX); - for(; exp.More(); exp.Next()) { - if(exp2Curr.IsSame(exp.Current())) - break; - } - if(exp.More()) - break; - } - if(exp2.More()) - break; - } - - if(exp2.More()) { - const TopoDS_Shape& FSD2 = itssd.Value(); - Standard_Integer iFSD = DS.Shape(FSD), iFSD2 = DS.Shape(FSD2); - RemoveFaceSameDomain(iFSD, iFSD2); -// DS.UnfillShapesSameDomain(FSD, FSD2); - } - } -} - -//======================================================================= -//function : FindGoodFace -//purpose : -//======================================================================= - -TColStd_ListOfInteger& BRepAlgo_DSAccess::FindGoodFace -(const Standard_Integer iE, - Standard_Integer& iF1, - Standard_Boolean& b) -{ -// myHB->ChangeBuilder(); - b = Standard_False; - TColStd_ListOfInteger& loi = myHB->GetDSFaceFromDSEdge(iE, 1); - if(loi.Extent() == 1) { - iF1 = loi.First(); - b = Standard_True; - TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2); - return loi2; - } - else { - TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2); - if(loi2.Extent() == 1) { - b = Standard_True; - iF1 = loi2.First(); - return loi; - } - } - b = Standard_False; - return myEmptyListOfInteger; -} - -//======================================================================= -//function : RemoveFaceSameDomain -//purpose : -//======================================================================= - -void BRepAlgo_DSAccess::RemoveFaceSameDomain -(const Standard_Integer iF1, - const Standard_Integer iF2) -{ - TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); - const TopoDS_Shape& F1 = DS.Shape(iF1, FindKeep); - const TopoDS_Shape& F2 = DS.Shape(iF2, FindKeep); - if(F1.IsNull() || F2.IsNull()) - return; - - - Standard_Integer iref1 = DS.SameDomainRef(F1), - iref2 = DS.SameDomainRef(F2), istart, iend; - if(iref1 == iF1) - DS.SameDomainRef(F2,iF2); - if(iref2 == iF1) - DS.SameDomainRef(F1,iF1); - DS.UnfillShapesSameDomain(F1,F2); - - if(iref1 != iref2) - return; - Standard_Boolean iF1iF2IsConnected = Standard_False; - TColStd_IndexedMapOfInteger moi; - moi.Clear(); - if(iref2 == iF2) { - istart = iF2; - iend = iF1; - } - else { - istart = iF1; - iend = iF2; - } - moi.Add(istart); - Standard_Integer NbConnect = 0, icurr; - while(moi.Extent() > NbConnect) { - NbConnect++; - icurr = moi.FindKey(NbConnect); - DS.SameDomainRef(icurr, istart); - const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr); - if(los.IsEmpty()) { - const TopoDS_Shape& SNSD = DS.Shape(icurr); - DS.SameDomainRef(SNSD, 0); - } - TopTools_ListIteratorOfListOfShape li(los); - for(; li.More(); li.Next()) { - Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep); - if(!iCurrShap) - return; - if(iCurrShap == iend) - iF1iF2IsConnected = Standard_True; - moi.Add(iCurrShap); - } - } - if(!iF1iF2IsConnected) { - moi.Clear(); - moi.Add(iend); - NbConnect = 0; - while(moi.Extent() > NbConnect) { - NbConnect++; - icurr = moi.FindKey(NbConnect); - DS.SameDomainRef(icurr, iend); - const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr); - if(los.IsEmpty()) { - const TopoDS_Shape& SNSD = DS.Shape(icurr); - DS.SameDomainRef(SNSD, 0); - } - TopTools_ListIteratorOfListOfShape li(los); - for(; li.More(); li.Next()) { - Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep); - if(!iCurrShap) - return; - moi.Add(iCurrShap); - } - } - } -} - -//======================================================================= -//function : DS -//purpose : -//======================================================================= - -const Handle(TopOpeBRepDS_HDataStructure)& -BRepAlgo_DSAccess::DS() const -{ - return myHDS; -} - -//======================================================================= -//function : changeDS -//purpose : -//======================================================================= -Handle(TopOpeBRepDS_HDataStructure)& -BRepAlgo_DSAccess::ChangeDS() -{ - return myHDS; -} - -//======================================================================= -//function : Builder -//purpose : -//======================================================================= - -const Handle(TopOpeBRepBuild_HBuilder)& -BRepAlgo_DSAccess::Builder() const -{ - return myHB; -} - -//======================================================================= -//function : ChangeBuilder -//purpose : -//======================================================================= - -Handle(TopOpeBRepBuild_HBuilder)& -BRepAlgo_DSAccess::ChangeBuilder() -{ - return myHB; -} diff --git a/src/BRepAlgo/BRepAlgo_DSAccess.hxx b/src/BRepAlgo/BRepAlgo_DSAccess.hxx deleted file mode 100644 index aefaeab2e3..0000000000 --- a/src/BRepAlgo/BRepAlgo_DSAccess.hxx +++ /dev/null @@ -1,237 +0,0 @@ -// Created on: 1997-08-13 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _BRepAlgo_DSAccess_HeaderFile -#define _BRepAlgo_DSAccess_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class TopOpeBRepDS_HDataStructure; -class TopOpeBRepBuild_HBuilder; -class BRepAlgo_EdgeConnector; -class BRepAlgo_BooleanOperations; -class TopoDS_Shape; -class TopoDS_Vertex; - - - -class BRepAlgo_DSAccess -{ -public: - - DEFINE_STANDARD_ALLOC - - - Standard_EXPORT BRepAlgo_DSAccess(); - - //! Clears the internal data structure, including the - Standard_EXPORT void Init(); - - //! Loads the shape in DS. - Standard_EXPORT void Load (const TopoDS_Shape& S); - - //! Loads two shapes in the DS without intersecting them. - Standard_EXPORT void Load (TopoDS_Shape& S1, TopoDS_Shape& S2); - - //! Intersects two shapes at input and loads the DS with - //! their intersection. Clears the TopOpeBRepBuild_HBuilder if - //! necessary - Standard_EXPORT void Intersect(); - - //! Intersects the faces contained in two given shapes - //! and loads them in the DS. Clears the TopOpeBRepBuild_HBuilder - //! if necessary - Standard_EXPORT void Intersect (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! This method does the same thing as the previous, - //! but faster. There is no intersection face/face 3D. - //! The faces have the same support(surface). No test of - //! tangency (that is why it is faster). Intersects in 2d - //! the faces tangent F1 anf F2. - Standard_EXPORT void SameDomain (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! returns compounds of Edge connected with section, which - //! contains sections between faces contained in S1 and S2. - //! returns an empty list of Shape if S1 or S2 do not contain - //! face. - //! calls GetSectionEdgeSet() if it has not already been done - Standard_EXPORT const TopTools_ListOfShape& GetSectionEdgeSet (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! returns all compounds of edges connected with section - //! contained in the DS - Standard_EXPORT const TopTools_ListOfShape& GetSectionEdgeSet(); - - //! NYI - Standard_EXPORT Standard_Boolean IsWire (const TopoDS_Shape& Compound); - - //! NYI - Standard_EXPORT const TopoDS_Shape& Wire (const TopoDS_Shape& Compound); - - //! NYI - //! returns the vertex of section, which contains the section - //! between face S1 and edge S2 (returns an empty Shape - //! if S1 is not a face or if S2 is not an edge) - Standard_EXPORT const TopTools_ListOfShape& SectionVertex (const TopoDS_Shape& S1, const TopoDS_Shape& S2); - - //! Invalidates a complete line of section. All - //! Edges connected by Vertex or a Wire. Can be - //! a group of connected Edges, which do not form a - //! standard Wire. - Standard_EXPORT void SuppressEdgeSet (const TopoDS_Shape& Compound); - - //! Modifies a line of section. -- should be a - //! Group of Edges connected by Vertex. -- Can be a - //! Wire. Can be a group of connected Edges that do not - //! form a standard Wire. should be sub-groupn of - Standard_EXPORT void ChangeEdgeSet (const TopoDS_Shape& Old, const TopoDS_Shape& New); - - //! NYI - //! Make invalid a Vertex of section. The Vertex shoud be - //! reconstructed from a point. - Standard_EXPORT void SuppressSectionVertex (const TopoDS_Vertex& V); - - Standard_EXPORT const TopoDS_Shape& Merge (const TopAbs_State state1, const TopAbs_State state2); - - Standard_EXPORT const TopoDS_Shape& Merge (const TopAbs_State state1); - - //! NYI Propagation of a state starting from the shape - //! FromShape = edge or vertex of section, face or - //! Coumpound de section. LoadShape is either S1, - //! or S2 (see the method Load). Propagation from - //! FromShape, on the states of LoadShape. - //! Return a Wire in 2d, a Shell in 3d. - //! Specifications are incomplete, to be redefined for the typologies - //! correpsonding to and the result : - //! exemple : FromShape resultat - //! vertex wire (or edge) - //! edge of section face (or shell) - //! compound of section shell - //! ... ... - Standard_EXPORT const TopoDS_Shape& Propagate (const TopAbs_State what, const TopoDS_Shape& FromShape, const TopoDS_Shape& LoadShape); - - //! SectionShape est soit un Vertex de section(NYI), soit - //! une Edge de section. Propagation des shapes - //! de section en partant de SectionShape. - //! return un Compound de section. - Standard_EXPORT const TopoDS_Shape& PropagateFromSection (const TopoDS_Shape& SectionShape); - - //! Returns the list of the descendant shapes of the shape . - Standard_EXPORT const TopTools_ListOfShape& Modified (const TopoDS_Shape& S); - - //! Returns the fact that the shape has been deleted or not - //! by the boolean operation. - Standard_EXPORT Standard_Boolean IsDeleted (const TopoDS_Shape& S); - - //! NYI - //! coherence of the internal Data Structure. - Standard_EXPORT BRepAlgo_CheckStatus Check(); - - Standard_EXPORT const Handle(TopOpeBRepDS_HDataStructure)& DS() const; - - Standard_EXPORT Handle(TopOpeBRepDS_HDataStructure)& ChangeDS(); - - Standard_EXPORT const Handle(TopOpeBRepBuild_HBuilder)& Builder() const; - - Standard_EXPORT Handle(TopOpeBRepBuild_HBuilder)& ChangeBuilder(); - - -friend class BRepAlgo_BooleanOperations; - - -protected: - - - - - -private: - - - Standard_EXPORT void Suppress (const TopoDS_Shape& Compound, const TopoDS_Shape& KeepComp); - - Standard_EXPORT void RemoveEdgeInterferences (const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iCurve); - - Standard_EXPORT void RemoveEdgeInterferences (const Standard_Integer iE1, const Standard_Integer iE2, const TopoDS_Shape& SectEdge); - - Standard_EXPORT void RemoveFaceInterferences (const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iE1, const Standard_Integer iE2); - - Standard_EXPORT void RemoveFaceInterferences (const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iCurve); - - Standard_EXPORT void RemoveEdgeInterferencesFromFace (const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer ipv1, const TopOpeBRepDS_Kind kind1, const Standard_Integer ipv2, const TopOpeBRepDS_Kind kind2); - - Standard_EXPORT void RemoveEdgeFromFace (const Standard_Integer iF, const Standard_Integer iV); - - Standard_EXPORT void PntVtxOnCurve (const Standard_Integer iCurve, Standard_Integer& ipv1, TopOpeBRepDS_Kind& ik1, Standard_Integer& ipv2, TopOpeBRepDS_Kind& ik2); - - Standard_EXPORT void PntVtxOnSectEdge (const TopoDS_Shape& SectEdge, Standard_Integer& ipv1, TopOpeBRepDS_Kind& ik1, Standard_Integer& ipv2, TopOpeBRepDS_Kind& ik2); - - Standard_EXPORT void RemoveEdgeSameDomain (const Standard_Integer iE1, const Standard_Integer iE2); - - Standard_EXPORT void RemoveFaceSameDomain (const TopoDS_Shape& C); - - Standard_EXPORT TColStd_ListOfInteger& FindGoodFace (const Standard_Integer iE, Standard_Integer& iF1, Standard_Boolean& b); - - Standard_EXPORT void RemoveFaceSameDomain (const Standard_Integer iF1, const Standard_Integer iF2); - - Standard_EXPORT Standard_Boolean GoodInterf (const TopoDS_Shape& SectEdge, const TopOpeBRepDS_Kind kind, const Standard_Integer iPointVertex); - - - Handle(TopOpeBRepDS_HDataStructure) myHDS; - TopOpeBRep_DSFiller myDSFiller; - Handle(TopOpeBRepBuild_HBuilder) myHB; - Handle(BRepAlgo_EdgeConnector) myEC; - TopoDS_Shape myS1; - TopoDS_Shape myS2; - TopAbs_State myState1; - TopAbs_State myState2; - TopTools_ListOfShape myListOfCompoundOfEdgeConnected; - TopTools_ListOfShape myCurrentList; - Standard_Boolean myRecomputeBuilderIsDone; - Standard_Boolean myGetSectionIsDone; - TopoDS_Shape myResultShape; - TopoDS_Wire myWire; - TopTools_ListOfShape myListOfVertex; - TopTools_ListOfShape myModified; - TopoDS_Shape myEmptyShape; - TopTools_ListOfShape myEmptyListOfShape; - TColStd_ListOfInteger myEmptyListOfInteger; - TopTools_DataMapOfShapeShape myCompoundWireMap; - TColStd_PackedMapOfInteger mySetOfKeepPoint; - - -}; - - - - - - - -#endif // _BRepAlgo_DSAccess_HeaderFile diff --git a/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean.hxx b/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean.hxx deleted file mode 100644 index 8d59ec3792..0000000000 --- a/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2015 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#ifndef BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean_HeaderFile -#define BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean_HeaderFile - -#include - -#endif diff --git a/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference.hxx b/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference.hxx deleted file mode 100644 index 7b67016548..0000000000 --- a/src/BRepAlgo/BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2015 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#ifndef BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference_HeaderFile -#define BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference_HeaderFile - -#include - -#endif diff --git a/src/BRepAlgo/BRepAlgo_DataMapOfShapeBoolean.hxx b/src/BRepAlgo/BRepAlgo_DataMapOfShapeBoolean.hxx deleted file mode 100644 index c76e8b0dc8..0000000000 --- a/src/BRepAlgo/BRepAlgo_DataMapOfShapeBoolean.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// Created on: 1997-01-17 -// Created by: Didier PIFFAULT -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef BRepAlgo_DataMapOfShapeBoolean_HeaderFile -#define BRepAlgo_DataMapOfShapeBoolean_HeaderFile - -#include -#include -#include -#include - -typedef NCollection_DataMap BRepAlgo_DataMapOfShapeBoolean; -typedef NCollection_DataMap::Iterator BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean; - - -#endif diff --git a/src/BRepAlgo/BRepAlgo_DataMapOfShapeInterference.hxx b/src/BRepAlgo/BRepAlgo_DataMapOfShapeInterference.hxx deleted file mode 100644 index 9b0eefee55..0000000000 --- a/src/BRepAlgo/BRepAlgo_DataMapOfShapeInterference.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// Created on: 1997-01-17 -// Created by: Didier PIFFAULT -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef BRepAlgo_DataMapOfShapeInterference_HeaderFile -#define BRepAlgo_DataMapOfShapeInterference_HeaderFile - -#include -#include -#include -#include - -typedef NCollection_DataMap BRepAlgo_DataMapOfShapeInterference; -typedef NCollection_DataMap::Iterator BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference; - - -#endif diff --git a/src/BRepAlgo/BRepAlgo_EdgeConnector.cxx b/src/BRepAlgo/BRepAlgo_EdgeConnector.cxx deleted file mode 100644 index 44c6204a09..0000000000 --- a/src/BRepAlgo/BRepAlgo_EdgeConnector.cxx +++ /dev/null @@ -1,184 +0,0 @@ -// Created on: 1997-08-22 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(BRepAlgo_EdgeConnector,Standard_Transient) - -//======================================================================= -//function : Create -//purpose : -//======================================================================= -BRepAlgo_EdgeConnector::BRepAlgo_EdgeConnector() -:myIsDone(Standard_False) -{ - myListeOfEdge.Clear(); -} - -//======================================================================= -//function : Add -//purpose : -//======================================================================= - -void BRepAlgo_EdgeConnector::Add(const TopoDS_Edge& e) -{ - if(e.IsNull()) return; - myListeOfEdge.Append(e); -} - -//======================================================================= -//function : Add -//purpose : -//======================================================================= - -void BRepAlgo_EdgeConnector::Add(TopTools_ListOfShape& LOEdge) -{ - if(LOEdge.IsEmpty()) return; - myListeOfEdge.Append(LOEdge); -} - -//======================================================================= -//function : AddStart -//purpose : -//======================================================================= - -void BRepAlgo_EdgeConnector::AddStart(const TopoDS_Shape& e) -{ - if(e.IsNull()) return; - myListeOfStartEdge.Append(e); -} - -//======================================================================= -//function : AddStart -//purpose : -//======================================================================= - -void BRepAlgo_EdgeConnector::AddStart(TopTools_ListOfShape& LOEdge) -{ - if(LOEdge.IsEmpty()) return; - myListeOfStartEdge.Append(LOEdge); -} - -//======================================================================= -//function : ClearStartElement -//purpose : -//======================================================================= - -void BRepAlgo_EdgeConnector::ClearStartElement() -{ - myListeOfStartEdge.Clear(); -} - -//======================================================================= -//function : MakeBlock -//purpose : -//======================================================================= - -TopTools_ListOfShape& BRepAlgo_EdgeConnector::MakeBlock() -{ - Standard_Boolean b; - if(myListeOfStartEdge.IsEmpty()) return myListeOfStartEdge; - TopOpeBRepBuild_ShapeSet SS(TopAbs_VERTEX); - myResultMap.Clear(); - myResultList.Clear(); - TopTools_ListIteratorOfListOfShape it(myListeOfEdge); - for(;it.More();it.Next()) { - const TopoDS_Shape& edge = it.Value(); - SS.AddElement(edge); - } - it.Initialize(myListeOfStartEdge); - for(;it.More();it.Next()) { - const TopoDS_Shape& edge = it.Value(); - SS.AddStartElement(edge); - } - myBlockB.MakeBlock(SS); - BRep_Builder WireB; - for(myBlockB.InitBlock();myBlockB.MoreBlock();myBlockB.NextBlock()) { -//#ifndef OCCT_DEBUG - TopOpeBRepBuild_BlockIterator BI = myBlockB.BlockIterator(); -//#else -// TopOpeBRepBuild_BlockIterator& BI = myBlockB.BlockIterator(); -//#endif - TopoDS_Wire W; - WireB.MakeWire(W); - for(BI.Initialize();BI.More();BI.Next()) { - const TopoDS_Shape& CurrentE = myBlockB.Element(BI); - WireB.Add(W, CurrentE); - } - b = myBlockB.CurrentBlockIsRegular(); - myResultMap.Bind(W, b); - myResultList.Append(W); - } - Done(); - return myResultList; -} - -//======================================================================= -//function : IsWire -//purpose : -//======================================================================= - -Standard_Boolean BRepAlgo_EdgeConnector::IsWire(const TopoDS_Shape& S) -{ - if(!myResultMap.IsBound(S)) { - return Standard_False; - } - Standard_Boolean b = Standard_False; - myBlockB.InitBlock(); - TopTools_ListIteratorOfListOfShape LI(myResultList); - for(;myBlockB.MoreBlock();myBlockB.NextBlock(),LI.Next()) { - if(S == LI.Value()) { - b = myBlockB.CurrentBlockIsRegular(); - break; - } - } - return b; -} - -//======================================================================= -//function : IsDone -//purpose : -//======================================================================= - - -Standard_Boolean BRepAlgo_EdgeConnector::IsDone() const -{ - return myIsDone; -} - -//======================================================================= -//function : Done -//purpose : -//======================================================================= - - -void BRepAlgo_EdgeConnector::Done() -{ - myIsDone = Standard_True; -} - diff --git a/src/BRepAlgo/BRepAlgo_EdgeConnector.hxx b/src/BRepAlgo/BRepAlgo_EdgeConnector.hxx deleted file mode 100644 index 0a450008dc..0000000000 --- a/src/BRepAlgo/BRepAlgo_EdgeConnector.hxx +++ /dev/null @@ -1,101 +0,0 @@ -// Created on: 1997-08-22 -// Created by: Prestataire Mary FABIEN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _BRepAlgo_EdgeConnector_HeaderFile -#define _BRepAlgo_EdgeConnector_HeaderFile - -#include -#include - -#include -#include -#include -#include -#include -class TopoDS_Edge; -class TopoDS_Shape; - - -class BRepAlgo_EdgeConnector; -DEFINE_STANDARD_HANDLE(BRepAlgo_EdgeConnector, Standard_Transient) - -//! Used by DSAccess to reconstruct an EdgeSet of connected edges. The result produced by -//! MakeBlock is a list of non-standard TopoDS_wire, -//! which can present connexions of edge of order > 2 -//! in certain vertex. The method IsWire -//! indicates standard/non-standard character of all wire produced. -class BRepAlgo_EdgeConnector : public Standard_Transient -{ - -public: - - - Standard_EXPORT BRepAlgo_EdgeConnector(); - - Standard_EXPORT void Add (const TopoDS_Edge& e); - - Standard_EXPORT void Add (TopTools_ListOfShape& LOEdge); - - Standard_EXPORT void AddStart (const TopoDS_Shape& e); - - Standard_EXPORT void AddStart (TopTools_ListOfShape& LOEdge); - - Standard_EXPORT void ClearStartElement(); - - //! returns a list of wire non standard - Standard_EXPORT TopTools_ListOfShape& MakeBlock(); - - Standard_EXPORT void Done(); - - //! NYI - //! returns true if proceeded to MakeBlock() - Standard_EXPORT Standard_Boolean IsDone() const; - - //! NYI - //! returns true if W is a Wire standard. - //! W must belong to the list returned by MakeBlock. - Standard_EXPORT Standard_Boolean IsWire (const TopoDS_Shape& W); - - - - - DEFINE_STANDARD_RTTIEXT(BRepAlgo_EdgeConnector,Standard_Transient) - -protected: - - - - -private: - - - TopTools_ListOfShape myListeOfEdge; - TopTools_ListOfShape myListeOfStartEdge; - BRepAlgo_DataMapOfShapeBoolean myResultMap; - TopTools_ListOfShape myResultList; - TopOpeBRepBuild_BlockBuilder myBlockB; - Standard_Boolean myIsDone; - - -}; - - - - - - - -#endif // _BRepAlgo_EdgeConnector_HeaderFile diff --git a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx index 319f0da32c..5910205061 100644 --- a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx +++ b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/BRepAlgo/BRepAlgo_SequenceOfSequenceOfInteger.hxx b/src/BRepAlgo/BRepAlgo_SequenceOfSequenceOfInteger.hxx deleted file mode 100644 index 9f42c139a0..0000000000 --- a/src/BRepAlgo/BRepAlgo_SequenceOfSequenceOfInteger.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 1997-01-17 -// Created by: Didier PIFFAULT -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef BRepAlgo_SequenceOfSequenceOfInteger_HeaderFile -#define BRepAlgo_SequenceOfSequenceOfInteger_HeaderFile - -#include -#include - -typedef NCollection_Sequence BRepAlgo_SequenceOfSequenceOfInteger; - - -#endif diff --git a/src/BRepAlgo/FILES b/src/BRepAlgo/FILES index dba5d3dced..4cf963e8d4 100755 --- a/src/BRepAlgo/FILES +++ b/src/BRepAlgo/FILES @@ -5,21 +5,11 @@ BRepAlgo_AsDes.cxx BRepAlgo_AsDes.hxx BRepAlgo_BooleanOperation.cxx BRepAlgo_BooleanOperation.hxx -BRepAlgo_BooleanOperations.cxx -BRepAlgo_BooleanOperations.hxx BRepAlgo_CheckStatus.hxx BRepAlgo_Common.cxx BRepAlgo_Common.hxx BRepAlgo_Cut.cxx BRepAlgo_Cut.hxx -BRepAlgo_DataMapIteratorOfDataMapOfShapeBoolean.hxx -BRepAlgo_DataMapIteratorOfDataMapOfShapeInterference.hxx -BRepAlgo_DataMapOfShapeBoolean.hxx -BRepAlgo_DataMapOfShapeInterference.hxx -BRepAlgo_DSAccess.cxx -BRepAlgo_DSAccess.hxx -BRepAlgo_EdgeConnector.cxx -BRepAlgo_EdgeConnector.hxx BRepAlgo_FaceRestrictor.cxx BRepAlgo_FaceRestrictor.hxx BRepAlgo_Fuse.cxx @@ -32,6 +22,5 @@ BRepAlgo_NormalProjection.cxx BRepAlgo_NormalProjection.hxx BRepAlgo_Section.cxx BRepAlgo_Section.hxx -BRepAlgo_SequenceOfSequenceOfInteger.hxx BRepAlgo_Tool.cxx BRepAlgo_Tool.hxx diff --git a/src/BRepFill/BRepFill_Draft.cxx b/src/BRepFill/BRepFill_Draft.cxx index 583ed0c170..5e274f09a7 100644 --- a/src/BRepFill/BRepFill_Draft.cxx +++ b/src/BRepFill/BRepFill_Draft.cxx @@ -20,11 +20,13 @@ #include #include #include +#include +#include #include #include #include #include -#include +#include #include #include #include @@ -618,99 +620,84 @@ static Standard_Boolean GoodOrientation(const Bnd_Box& B, return Standard_False; // Impossible to do } } - - BRepAlgo_DSAccess DSA; - DSA.Load(Sol1, Sol2); - DSA.Intersect(Sol1, Sol2); // intersection of 2 solids - -// removal of edges corresponding to "unused" intersections - Standard_Integer NbPaquet; -// gp_Pnt P1,P2; - TopoDS_Vertex V,V1; - TopTools_ListOfShape List; - List = DSA.GetSectionEdgeSet();// list of edges - - NbPaquet = List.Extent(); - if (NbPaquet == 0) { -#if DRAW - cout << "No fusion" << endl; - DBRep::Set("DepPart", Sol1); - DBRep::Set("StopPart", Sol2); -#endif + // Perform intersection of solids + BOPAlgo_PaveFiller aPF; + TopTools_ListOfShape anArgs; + anArgs.Append(Sol1); + anArgs.Append(Sol2); + aPF.SetArguments(anArgs); + aPF.Perform(); + if (aPF.HasErrors()) return Standard_False; - } - if (NbPaquet > 1) { - // It is required to select packs. - TColStd_Array1OfReal Dist(1, NbPaquet); - TopTools_ListIteratorOfListOfShape it(List); - Standard_Real D, Dmin = 1.e10; - Standard_Integer ii; - - //Classify the packs by distance. - BRepExtrema_DistShapeShape Dist2; - Dist2.LoadS1( myWire ); - for (ii=1; it.More();it.Next(),ii++){ - Dist2.LoadS2( it.Value() ); - Dist2.Perform(); - if (Dist2.IsDone()) { - D = Dist2.Value(); - Dist(ii) = D; - if (D < Dmin) Dmin = D; - } - else - Dist(ii) = 1.e10; - } + BRepAlgoAPI_Section aSec(Sol1, Sol2, aPF); + const TopoDS_Shape& aSection = aSec.Shape(); - // remove edges "farther" than Dmin - for (ii=1, it.Initialize(List); it.More();it.Next(), ii++){ - if (Dist(ii) > Dmin) { - DSA.SuppressEdgeSet(it.Value()); - } -#if DRAW - else if (Affich) { - DBRep::Set("KeepEdges", it.Value()); - } -#endif - } - } + TopExp_Explorer exp(aSection, TopAbs_EDGE); + if (!exp.More()) + // No section edges produced + return Standard_False; - if (StopShape.ShapeType() != TopAbs_SOLID) { + if (StopShape.ShapeType() != TopAbs_SOLID) + { // It is required to choose the state by the geometry - //(1) Return an edge of section - List = DSA.GetSectionEdgeSet();// list of edges - TopTools_ListIteratorOfListOfShape it(List); - TopoDS_Iterator iter(it.Value()); - TopoDS_Edge E = TopoDS::Edge(iter.Value()); + // We need to find the section edge, closest to myWire + TopoDS_Edge aSEMin; + Standard_Real Dmin = Precision::Infinite(); + BRepExtrema_DistShapeShape DistTool; + DistTool.LoadS1(myWire); - //(2) Return geometry on StopShape -// Class BRep_Tool without fields and without Constructor : -// BRep_Tool BT; - Handle(Geom_Surface) S; - Handle(Geom2d_Curve) C2d; - gp_Pnt2d P2d; - Standard_Real f,l; - TopLoc_Location L; -// BT.CurveOnSurface(E, C2d, S, L, f, l, 2); - BRep_Tool::CurveOnSurface(E, C2d, S, L, f, l, 2); - - // Find a normal. - C2d->D0((f+l)/2,P2d); - GeomLProp_SLProps SP(S, P2d.X(), P2d.Y(), 1, 1.e-12); - if (! SP.IsNormalDefined()) { - C2d->D0((3*f+l)/4,P2d); - SP.SetParameters(P2d.X(), P2d.Y()); - if ( !SP.IsNormalDefined()) { - C2d->D0((f+3*l)/4,P2d); - SP.SetParameters(P2d.X(), P2d.Y()); + for (; exp.More(); exp.Next()) + { + const TopoDS_Shape& aSE = exp.Current(); + DistTool.LoadS2(aSE); + DistTool.Perform(); + if (DistTool.IsDone()) + { + Standard_Real D = DistTool.Value(); + if (D < Dmin) + { + Dmin = D; + aSEMin = TopoDS::Edge(aSE); + if (Dmin < Precision::Confusion()) + break; + } } } - // Subtract State1 - if (myDir.Angle(SP.Normal()) < M_PI/2) State1 = TopAbs_IN; - else State1 = TopAbs_OUT; + if (!aSEMin.IsNull()) + { + // Get geometry of StopShape + Handle(Geom_Surface) S; + Handle(Geom2d_Curve) C2d; + gp_Pnt2d P2d; + Standard_Real f, l; + TopLoc_Location L; + BRep_Tool::CurveOnSurface(aSEMin, C2d, S, L, f, l, 2); + + // Find a normal. + C2d->D0((f + l) / 2, P2d); + GeomLProp_SLProps SP(S, P2d.X(), P2d.Y(), 1, 1.e-12); + if (!SP.IsNormalDefined()) + { + C2d->D0((3 * f + l) / 4, P2d); + SP.SetParameters(P2d.X(), P2d.Y()); + if (!SP.IsNormalDefined()) + { + C2d->D0((f + 3 * l) / 4, P2d); + SP.SetParameters(P2d.X(), P2d.Y()); + } + } + + if (SP.IsNormalDefined()) + { + // Subtract State1 + if (myDir.Angle(SP.Normal()) < M_PI / 2) State1 = TopAbs_IN; + else State1 = TopAbs_OUT; + } + } } if (! KeepOutSide) { // Invert State2; @@ -718,8 +705,100 @@ static Standard_Boolean GoodOrientation(const Bnd_Box& B, else State2 = TopAbs_IN; } -//recalculate the final shape - TopoDS_Shape result = DSA.Merge(State1, State2); + // Perform Boolean operation + BOPAlgo_Builder aBuilder; + aBuilder.AddArgument(Sol1); + aBuilder.AddArgument(Sol2); + aBuilder.PerformWithFiller(aPF); + if (aBuilder.HasErrors()) + return Standard_False; + + TopoDS_Shape result; + Handle(BRepTools_History) aHistory = new BRepTools_History; + + Standard_Boolean isSingleOpNeeded = Standard_True; + // To get rid of the unnecessary parts of first solid make the cutting first + if (State1 == TopAbs_OUT) + { + TopTools_ListOfShape aLO, aLT; + aLO.Append(Sol1); + aLT.Append(Sol2); + aBuilder.BuildBOP(aLO, aLT, BOPAlgo_CUT); + if (!aBuilder.HasErrors()) + { + TopoDS_Solid aCutMin; + TopExp_Explorer anExpS(aBuilder.Shape(), TopAbs_SOLID); + if (anExpS.More()) + { + aCutMin = TopoDS::Solid(anExpS.Current()); + anExpS.Next(); + if (anExpS.More()) + { + Standard_Real aDMin = Precision::Infinite(); + BRepExtrema_DistShapeShape DistTool; + DistTool.LoadS1(myWire); + + for (anExpS.ReInit(); anExpS.More(); anExpS.Next()) + { + const TopoDS_Shape& aCut = anExpS.Current(); + DistTool.LoadS2(aCut); + DistTool.Perform(); + if (DistTool.IsDone()) + { + Standard_Real D = DistTool.Value(); + if (D < aDMin) + { + aDMin = D; + aCutMin = TopoDS::Solid(aCut); + } + } + } + } + } + + if (!aCutMin.IsNull()) + { + // Save history for first argument only + aHistory->Merge(aLO, aBuilder); + + // Perform needed operation with result of Cut + BOPAlgo_Builder aGluer; + aGluer.AddArgument(aCutMin); + aGluer.AddArgument(Sol2); + aGluer.SetGlue(BOPAlgo_GlueShift); + aGluer.Perform(); + + aLO.Clear(); + aLO.Append(aCutMin); + aGluer.BuildBOP(aLO, State1, aLT, State2); + + if (!aGluer.HasErrors()) + { + aHistory->Merge(aGluer.History()); + + result = aGluer.Shape(); + anExpS.Init(result, TopAbs_SOLID); + isSingleOpNeeded = !anExpS.More(); + } + } + } + } + + if (isSingleOpNeeded) + { + aHistory->Clear(); + + TopTools_ListOfShape aLO, aLT; + aLO.Append(Sol1); + aLT.Append(Sol2); + + aBuilder.BuildBOP(aLO, State1, aLT, State2); + if (aBuilder.HasErrors()) + return Standard_False; + + aHistory->Merge(aBuilder.History()); + result = aBuilder.Shape(); + } if (issolid) myShape = result; else { @@ -728,15 +807,15 @@ static Standard_Boolean GoodOrientation(const Bnd_Box& B, if (Exp.More()) myShape = Exp.Current(); } -// Update the History + // Update the History Standard_Integer ii; for (ii=1; ii<=myLoc->NbLaw(); ii++) { - const TopTools_ListOfShape& L = DSA.Modified(myFaces->Value(1,ii)); + const TopTools_ListOfShape& L = aHistory->Modified(myFaces->Value(1,ii)); if (L.Extent()>0) myFaces->SetValue(1, ii, L.First()); } for (ii=1; ii<=myLoc->NbLaw()+1; ii++) { - const TopTools_ListOfShape& L = DSA.Modified(mySections->Value(1,ii)); + const TopTools_ListOfShape& L = aHistory->Modified(mySections->Value(1,ii)); if (L.Extent()>0) mySections->SetValue(1, ii, L.First()); } diff --git a/src/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx b/src/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx index 16754abda3..94cdb4e6ad 100644 --- a/src/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx +++ b/src/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx @@ -481,11 +481,6 @@ void TopOpeBRepBuild_HBuilder::MakeCurveAncestorMap() itloe.Initialize(LOS); for(;itloe.More();itloe.Next()) { TopoDS_Shape& E = *((TopoDS_Shape*)(&itloe.Value())); - if(mySectEdgeDSCurve.IsBound(E)) { -#ifdef OCCT_DEBUG - cout<<"BRepAlgo_DSAccess::MakeEdgeAncestorFromCurve : program error"<