Warnings on vc14 were eliminated
[occt.git] / src / BRepAlgo / BRepAlgo_EdgeConnector.cxx
CommitLineData
b311480e 1// Created on: 1997-08-22
2// Created by: Prestataire Mary FABIEN
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 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>
7fd59977 23#include <TopoDS_Shape.hxx>
7fd59977 24#include <TopoDS_Wire.hxx>
7fd59977 25#include <TopOpeBRepBuild_BlockBuilder.hxx>
42cf5bc1 26#include <TopOpeBRepBuild_BlockIterator.hxx>
27#include <TopOpeBRepBuild_ShapeSet.hxx>
28#include <TopTools_ListIteratorOfListOfShape.hxx>
29#include <TopTools_ListOfShape.hxx>
7fd59977 30
92efcf78 31IMPLEMENT_STANDARD_RTTIEXT(BRepAlgo_EdgeConnector,MMgt_TShared)
32
7fd59977 33//=======================================================================
34//function : Create
35//purpose :
36//=======================================================================
7fd59977 37BRepAlgo_EdgeConnector::BRepAlgo_EdgeConnector()
38:myIsDone(Standard_False)
39{
40 myListeOfEdge.Clear();
41}
42
43//=======================================================================
44//function : Add
45//purpose :
46//=======================================================================
47
48void BRepAlgo_EdgeConnector::Add(const TopoDS_Edge& e)
49{
50 if(e.IsNull()) return;
51 myListeOfEdge.Append(e);
52}
53
54//=======================================================================
55//function : Add
56//purpose :
57//=======================================================================
58
59void BRepAlgo_EdgeConnector::Add(TopTools_ListOfShape& LOEdge)
60{
61 if(LOEdge.IsEmpty()) return;
62 myListeOfEdge.Append(LOEdge);
63}
64
65//=======================================================================
66//function : AddStart
67//purpose :
68//=======================================================================
69
70void BRepAlgo_EdgeConnector::AddStart(const TopoDS_Shape& e)
71{
72 if(e.IsNull()) return;
73 myListeOfStartEdge.Append(e);
74}
75
76//=======================================================================
77//function : AddStart
78//purpose :
79//=======================================================================
80
81void BRepAlgo_EdgeConnector::AddStart(TopTools_ListOfShape& LOEdge)
82{
83 if(LOEdge.IsEmpty()) return;
84 myListeOfStartEdge.Append(LOEdge);
85}
86
87//=======================================================================
88//function : ClearStartElement
89//purpose :
90//=======================================================================
91
92void BRepAlgo_EdgeConnector::ClearStartElement()
93{
94 myListeOfStartEdge.Clear();
95}
96
97//=======================================================================
98//function : MakeBlock
99//purpose :
100//=======================================================================
101
102TopTools_ListOfShape& BRepAlgo_EdgeConnector::MakeBlock()
103{
104 Standard_Boolean b;
105 if(myListeOfStartEdge.IsEmpty()) return myListeOfStartEdge;
106 TopOpeBRepBuild_ShapeSet SS(TopAbs_VERTEX);
107 myResultMap.Clear();
108 myResultList.Clear();
109 TopTools_ListIteratorOfListOfShape it(myListeOfEdge);
110 for(;it.More();it.Next()) {
111 const TopoDS_Shape& edge = it.Value();
112 SS.AddElement(edge);
113 }
114 it.Initialize(myListeOfStartEdge);
115 for(;it.More();it.Next()) {
116 const TopoDS_Shape& edge = it.Value();
117 SS.AddStartElement(edge);
118 }
119 myBlockB.MakeBlock(SS);
120 BRep_Builder WireB;
121 for(myBlockB.InitBlock();myBlockB.MoreBlock();myBlockB.NextBlock()) {
0797d9d3 122//#ifndef OCCT_DEBUG
7fd59977 123 TopOpeBRepBuild_BlockIterator BI = myBlockB.BlockIterator();
124//#else
125// TopOpeBRepBuild_BlockIterator& BI = myBlockB.BlockIterator();
126//#endif
127 TopoDS_Wire W;
128 WireB.MakeWire(W);
129 for(BI.Initialize();BI.More();BI.Next()) {
130 const TopoDS_Shape& CurrentE = myBlockB.Element(BI);
131 WireB.Add(W, CurrentE);
132 }
133 b = myBlockB.CurrentBlockIsRegular();
134 myResultMap.Bind(W, b);
135 myResultList.Append(W);
136 }
137 Done();
138 return myResultList;
139}
140
141//=======================================================================
142//function : IsWire
143//purpose :
144//=======================================================================
145
146Standard_Boolean BRepAlgo_EdgeConnector::IsWire(const TopoDS_Shape& S)
147{
148 if(!myResultMap.IsBound(S)) {
149 return Standard_False;
150 }
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();
157 break;
158 }
159 }
160 return b;
161}
162
163//=======================================================================
164//function : IsDone
165//purpose :
166//=======================================================================
167
168
169Standard_Boolean BRepAlgo_EdgeConnector::IsDone() const
170{
171 return myIsDone;
172}
173
174//=======================================================================
175//function : Done
176//purpose :
177//=======================================================================
178
179
180void BRepAlgo_EdgeConnector::Done()
181{
182 myIsDone = Standard_True;
183}
184