1 // Created on: 1997-08-22
2 // Created by: Prestataire Mary FABIEN
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRep_Builder.hxx>
19 #include <BRepAlgo_DataMapOfShapeBoolean.hxx>
20 #include <BRepAlgo_EdgeConnector.hxx>
21 #include <Standard_Type.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <TopoDS_Wire.hxx>
25 #include <TopOpeBRepBuild_BlockBuilder.hxx>
26 #include <TopOpeBRepBuild_BlockIterator.hxx>
27 #include <TopOpeBRepBuild_ShapeSet.hxx>
28 #include <TopTools_ListIteratorOfListOfShape.hxx>
29 #include <TopTools_ListOfShape.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(BRepAlgo_EdgeConnector,Standard_Transient)
33 //=======================================================================
36 //=======================================================================
37 BRepAlgo_EdgeConnector::BRepAlgo_EdgeConnector()
38 :myIsDone(Standard_False)
40 myListeOfEdge.Clear();
43 //=======================================================================
46 //=======================================================================
48 void BRepAlgo_EdgeConnector::Add(const TopoDS_Edge& e)
50 if(e.IsNull()) return;
51 myListeOfEdge.Append(e);
54 //=======================================================================
57 //=======================================================================
59 void BRepAlgo_EdgeConnector::Add(TopTools_ListOfShape& LOEdge)
61 if(LOEdge.IsEmpty()) return;
62 myListeOfEdge.Append(LOEdge);
65 //=======================================================================
68 //=======================================================================
70 void BRepAlgo_EdgeConnector::AddStart(const TopoDS_Shape& e)
72 if(e.IsNull()) return;
73 myListeOfStartEdge.Append(e);
76 //=======================================================================
79 //=======================================================================
81 void BRepAlgo_EdgeConnector::AddStart(TopTools_ListOfShape& LOEdge)
83 if(LOEdge.IsEmpty()) return;
84 myListeOfStartEdge.Append(LOEdge);
87 //=======================================================================
88 //function : ClearStartElement
90 //=======================================================================
92 void BRepAlgo_EdgeConnector::ClearStartElement()
94 myListeOfStartEdge.Clear();
97 //=======================================================================
98 //function : MakeBlock
100 //=======================================================================
102 TopTools_ListOfShape& BRepAlgo_EdgeConnector::MakeBlock()
105 if(myListeOfStartEdge.IsEmpty()) return myListeOfStartEdge;
106 TopOpeBRepBuild_ShapeSet SS(TopAbs_VERTEX);
108 myResultList.Clear();
109 TopTools_ListIteratorOfListOfShape it(myListeOfEdge);
110 for(;it.More();it.Next()) {
111 const TopoDS_Shape& edge = it.Value();
114 it.Initialize(myListeOfStartEdge);
115 for(;it.More();it.Next()) {
116 const TopoDS_Shape& edge = it.Value();
117 SS.AddStartElement(edge);
119 myBlockB.MakeBlock(SS);
121 for(myBlockB.InitBlock();myBlockB.MoreBlock();myBlockB.NextBlock()) {
123 TopOpeBRepBuild_BlockIterator BI = myBlockB.BlockIterator();
125 // TopOpeBRepBuild_BlockIterator& BI = myBlockB.BlockIterator();
129 for(BI.Initialize();BI.More();BI.Next()) {
130 const TopoDS_Shape& CurrentE = myBlockB.Element(BI);
131 WireB.Add(W, CurrentE);
133 b = myBlockB.CurrentBlockIsRegular();
134 myResultMap.Bind(W, b);
135 myResultList.Append(W);
141 //=======================================================================
144 //=======================================================================
146 Standard_Boolean BRepAlgo_EdgeConnector::IsWire(const TopoDS_Shape& S)
148 if(!myResultMap.IsBound(S)) {
149 return Standard_False;
151 Standard_Boolean b = Standard_False;
152 myBlockB.InitBlock();
153 TopTools_ListIteratorOfListOfShape LI(myResultList);
154 for(;myBlockB.MoreBlock();myBlockB.NextBlock(),LI.Next()) {
155 if(S == LI.Value()) {
156 b = myBlockB.CurrentBlockIsRegular();
163 //=======================================================================
166 //=======================================================================
169 Standard_Boolean BRepAlgo_EdgeConnector::IsDone() const
174 //=======================================================================
177 //=======================================================================
180 void BRepAlgo_EdgeConnector::Done()
182 myIsDone = Standard_True;