0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / BRepPrim / BRepPrim_Builder.cxx
CommitLineData
b311480e 1// Created on: 1991-07-25
2// Created by: Christophe MARION
3// Copyright (c) 1991-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 <BRepPrim_Builder.hxx>
20#include <BRepTools.hxx>
21#include <Geom2d_Circle.hxx>
22#include <Geom2d_Line.hxx>
23#include <Geom_Circle.hxx>
24#include <Geom_Line.hxx>
25#include <Geom_Plane.hxx>
26#include <gp_Circ.hxx>
27#include <gp_Circ2d.hxx>
28#include <gp_Lin.hxx>
29#include <gp_Lin2d.hxx>
30#include <gp_Pln.hxx>
31#include <gp_Pnt.hxx>
7fd59977 32#include <Precision.hxx>
33#include <TopoDS.hxx>
42cf5bc1 34#include <TopoDS_Edge.hxx>
35#include <TopoDS_Face.hxx>
36#include <TopoDS_Shell.hxx>
37#include <TopoDS_Vertex.hxx>
38#include <TopoDS_Wire.hxx>
7fd59977 39
40//=======================================================================
41//function : BRepPrim_Builder
42//purpose : constructor
43//=======================================================================
7fd59977 44BRepPrim_Builder::BRepPrim_Builder ()
45{
46}
47
48//=======================================================================
49//function : BRepPrim_Builder
50//purpose : constructor
51//=======================================================================
52
53BRepPrim_Builder::BRepPrim_Builder (const BRep_Builder& B) :
54 myBuilder(B)
55{
56}
57
58//=======================================================================
59//function : MakeShell
60//purpose : Make a Shell
61//=======================================================================
62
63void BRepPrim_Builder::MakeShell (TopoDS_Shell& S) const
64{
65 myBuilder.MakeShell(S);
66 S.Closed(Standard_True);
67}
68
69//=======================================================================
70//function : MakeFace
71//purpose : Make a Planar Face
72//=======================================================================
73
74void BRepPrim_Builder::MakeFace (TopoDS_Face& F, const gp_Pln& P) const
75{
76 myBuilder.MakeFace(F,new Geom_Plane(P),Precision::Confusion());
77}
78
79//=======================================================================
80//function : MakeWire
81//purpose : Make an empty Wire
82//=======================================================================
83
84void BRepPrim_Builder::MakeWire (TopoDS_Wire& W) const
85{
86 myBuilder.MakeWire(W);
87}
88
89//=======================================================================
90//function : MakeDegeneratedEdge
91//purpose :
92//=======================================================================
93
94void BRepPrim_Builder::MakeDegeneratedEdge (TopoDS_Edge& E) const
95{
96 myBuilder.MakeEdge(E);
97 myBuilder.Degenerated(E,Standard_True);
98}
99
100//=======================================================================
101//function : MakeEdge
102//purpose : Make a linear Edge
103//=======================================================================
104
105void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Lin& L) const
106{
107 myBuilder.MakeEdge(E,new Geom_Line(L),Precision::Confusion());
108}
109
110//=======================================================================
111//function : MakeEdge
112//purpose : Make a Circular Edge
113//=======================================================================
114
115void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Circ& C) const
116{
117 myBuilder.MakeEdge(E,new Geom_Circle(C),Precision::Confusion());
118}
119
120//=======================================================================
121//function : SetPCurve
122//purpose :
123//=======================================================================
124
125void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
126 const TopoDS_Face& F,
127 const gp_Lin2d& L) const
128{
129 myBuilder.UpdateEdge(E,new Geom2d_Line(L),F,Precision::Confusion());
130}
131
132//=======================================================================
133//function : SetPCurve
134//purpose :
135//=======================================================================
136
137void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
138 const TopoDS_Face& F,
139 const gp_Lin2d& L1,
140 const gp_Lin2d& L2) const
141{
142 TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
143 myBuilder.UpdateEdge(TopoDS::Edge(aLocalShape),
144 new Geom2d_Line(L1),
145 new Geom2d_Line(L2),
146 F,Precision::Confusion());
147// myBuilder.UpdateEdge(TopoDS::Edge(E.Oriented(TopAbs_FORWARD)),
148// new Geom2d_Line(L1),
149// new Geom2d_Line(L2),
150// F,Precision::Confusion());
151 myBuilder.Continuity(E,F,F,GeomAbs_CN);
152}
153
154//=======================================================================
155//function : SetPCurve
156//purpose :
157//=======================================================================
158
159void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
160 const TopoDS_Face& F,
161 const gp_Circ2d& C) const
162{
163 myBuilder.UpdateEdge(E,new Geom2d_Circle(C),F,Precision::Confusion());
164}
165
166
167//=======================================================================
168//function : MakeVertex
169//purpose : Make a Vertex
170//=======================================================================
171
172void BRepPrim_Builder::MakeVertex (TopoDS_Vertex& V, const gp_Pnt& P) const
173{
174 myBuilder.MakeVertex(V,P,Precision::Confusion());
175}
176
177//=======================================================================
178//function : ReverseFace
179//purpose : Reverse a Face
180//=======================================================================
181
182void BRepPrim_Builder::ReverseFace (TopoDS_Face& F) const
183{
184 F.Reverse();
185}
186
187//=======================================================================
188//function : AddEdgeVertex
189//purpose : Add a Vertex to an Edge
190//=======================================================================
191
192void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
193 const TopoDS_Vertex& V,
194 const Standard_Real P,
195 const Standard_Boolean direct) const
196{
197 TopoDS_Vertex VV = V;
198 if (!direct)
199 VV.Reverse();
200 myBuilder.Add(E,VV);
201 myBuilder.UpdateVertex(VV,P,E,Precision::Confusion());
202}
203
204
205//=======================================================================
206//function : AddEdgeVertex
207//purpose : Add a Vertex to an Edge
208//=======================================================================
209
210void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
211 const TopoDS_Vertex& V,
212 const Standard_Real P1,
213 const Standard_Real P2) const
214{
215 TopoDS_Vertex VV = V;
216 VV.Orientation(TopAbs_FORWARD);
217 myBuilder.Add(E,VV);
218 VV.Orientation(TopAbs_REVERSED);
219 myBuilder.Add(E,VV);
220 myBuilder.Range(E,P1,P2);
7fd59977 221}
222
223//=======================================================================
224//function : SetParameters
225//purpose :
226//=======================================================================
227
228void BRepPrim_Builder::SetParameters (TopoDS_Edge& E,
229 const TopoDS_Vertex& ,
230 const Standard_Real P1,
231 const Standard_Real P2) const
232{
233 myBuilder.Range(E,P1,P2);
234}
235
236//=======================================================================
237//function : AddWireEdge
238//purpose : Add an Edge to a Wire
239//=======================================================================
240
241void BRepPrim_Builder::AddWireEdge (TopoDS_Wire& W,
242 const TopoDS_Edge& E,
243 const Standard_Boolean direct) const
244{
245 TopoDS_Edge EE = E;
246 if (!direct)
247 EE.Reverse();
248 myBuilder.Add(W,EE);
249}
250
251//=======================================================================
252//function : AddFaceWire
253//purpose : Add a Wire to a Face
254//=======================================================================
255
256void BRepPrim_Builder::AddFaceWire (TopoDS_Face& F,
257 const TopoDS_Wire& W) const
258{
259 myBuilder.Add(F,W);
260}
261
262//=======================================================================
263//function : AddShellFace
264//purpose : Add a Face to a Shell
265//=======================================================================
266
267void BRepPrim_Builder::AddShellFace(TopoDS_Shell& S,
268 const TopoDS_Face& F) const
269{
270 myBuilder.Add(S,F);
271}
272
273//=======================================================================
274//function : Complete
275//purpose :
276//=======================================================================
277
278void BRepPrim_Builder::CompleteEdge(TopoDS_Edge& E)const
279{
280 BRepTools::Update(E);
281}
282
283//=======================================================================
284//function : Complete
285//purpose :
286//=======================================================================
287
288void BRepPrim_Builder::CompleteWire(TopoDS_Wire& W)const
289{
da72a17c 290 W.Closed(BRep_Tool::IsClosed(W));
7fd59977 291 BRepTools::Update(W);
292}
293
294
295//=======================================================================
296//function : Complete
297//purpose :
298//=======================================================================
299
300void BRepPrim_Builder::CompleteFace(TopoDS_Face& F)const
301{
302 BRepTools::Update(F);
303}
304
305
306//=======================================================================
307//function : Complete
308//purpose :
309//=======================================================================
310
311void BRepPrim_Builder::CompleteShell(TopoDS_Shell& S)const
312{
da72a17c 313 S.Closed(BRep_Tool::IsClosed(S));
7fd59977 314 BRepTools::Update(S);
315}