1 // Created on: 1991-07-25
2 // Created by: Christophe MARION
3 // Copyright (c) 1991-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
9 // under the terms of the GNU Lesser General Public 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.
17 #include <BRepPrim_Builder.ixx>
19 #include <Precision.hxx>
22 #include <Geom_Plane.hxx>
23 #include <Geom_Line.hxx>
24 #include <Geom_Circle.hxx>
26 #include <Geom2d_Line.hxx>
27 #include <Geom2d_Circle.hxx>
29 #include <BRepTools.hxx>
31 //=======================================================================
32 //function : BRepPrim_Builder
33 //purpose : constructor
34 //=======================================================================
36 BRepPrim_Builder::BRepPrim_Builder ()
40 //=======================================================================
41 //function : BRepPrim_Builder
42 //purpose : constructor
43 //=======================================================================
45 BRepPrim_Builder::BRepPrim_Builder (const BRep_Builder& B) :
50 //=======================================================================
51 //function : MakeShell
52 //purpose : Make a Shell
53 //=======================================================================
55 void BRepPrim_Builder::MakeShell (TopoDS_Shell& S) const
57 myBuilder.MakeShell(S);
58 S.Closed(Standard_True);
61 //=======================================================================
63 //purpose : Make a Planar Face
64 //=======================================================================
66 void BRepPrim_Builder::MakeFace (TopoDS_Face& F, const gp_Pln& P) const
68 myBuilder.MakeFace(F,new Geom_Plane(P),Precision::Confusion());
71 //=======================================================================
73 //purpose : Make an empty Wire
74 //=======================================================================
76 void BRepPrim_Builder::MakeWire (TopoDS_Wire& W) const
78 myBuilder.MakeWire(W);
81 //=======================================================================
82 //function : MakeDegeneratedEdge
84 //=======================================================================
86 void BRepPrim_Builder::MakeDegeneratedEdge (TopoDS_Edge& E) const
88 myBuilder.MakeEdge(E);
89 myBuilder.Degenerated(E,Standard_True);
92 //=======================================================================
94 //purpose : Make a linear Edge
95 //=======================================================================
97 void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Lin& L) const
99 myBuilder.MakeEdge(E,new Geom_Line(L),Precision::Confusion());
102 //=======================================================================
103 //function : MakeEdge
104 //purpose : Make a Circular Edge
105 //=======================================================================
107 void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Circ& C) const
109 myBuilder.MakeEdge(E,new Geom_Circle(C),Precision::Confusion());
112 //=======================================================================
113 //function : SetPCurve
115 //=======================================================================
117 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
118 const TopoDS_Face& F,
119 const gp_Lin2d& L) const
121 myBuilder.UpdateEdge(E,new Geom2d_Line(L),F,Precision::Confusion());
124 //=======================================================================
125 //function : SetPCurve
127 //=======================================================================
129 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
130 const TopoDS_Face& F,
132 const gp_Lin2d& L2) const
134 TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
135 myBuilder.UpdateEdge(TopoDS::Edge(aLocalShape),
138 F,Precision::Confusion());
139 // myBuilder.UpdateEdge(TopoDS::Edge(E.Oriented(TopAbs_FORWARD)),
140 // new Geom2d_Line(L1),
141 // new Geom2d_Line(L2),
142 // F,Precision::Confusion());
143 myBuilder.Continuity(E,F,F,GeomAbs_CN);
146 //=======================================================================
147 //function : SetPCurve
149 //=======================================================================
151 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
152 const TopoDS_Face& F,
153 const gp_Circ2d& C) const
155 myBuilder.UpdateEdge(E,new Geom2d_Circle(C),F,Precision::Confusion());
159 //=======================================================================
160 //function : MakeVertex
161 //purpose : Make a Vertex
162 //=======================================================================
164 void BRepPrim_Builder::MakeVertex (TopoDS_Vertex& V, const gp_Pnt& P) const
166 myBuilder.MakeVertex(V,P,Precision::Confusion());
169 //=======================================================================
170 //function : ReverseFace
171 //purpose : Reverse a Face
172 //=======================================================================
174 void BRepPrim_Builder::ReverseFace (TopoDS_Face& F) const
179 //=======================================================================
180 //function : AddEdgeVertex
181 //purpose : Add a Vertex to an Edge
182 //=======================================================================
184 void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
185 const TopoDS_Vertex& V,
186 const Standard_Real P,
187 const Standard_Boolean direct) const
189 TopoDS_Vertex VV = V;
193 myBuilder.UpdateVertex(VV,P,E,Precision::Confusion());
197 //=======================================================================
198 //function : AddEdgeVertex
199 //purpose : Add a Vertex to an Edge
200 //=======================================================================
202 void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
203 const TopoDS_Vertex& V,
204 const Standard_Real P1,
205 const Standard_Real P2) const
207 TopoDS_Vertex VV = V;
208 VV.Orientation(TopAbs_FORWARD);
210 VV.Orientation(TopAbs_REVERSED);
212 myBuilder.Range(E,P1,P2);
213 E.Closed(Standard_True);
216 //=======================================================================
217 //function : SetParameters
219 //=======================================================================
221 void BRepPrim_Builder::SetParameters (TopoDS_Edge& E,
222 const TopoDS_Vertex& ,
223 const Standard_Real P1,
224 const Standard_Real P2) const
226 myBuilder.Range(E,P1,P2);
229 //=======================================================================
230 //function : AddWireEdge
231 //purpose : Add an Edge to a Wire
232 //=======================================================================
234 void BRepPrim_Builder::AddWireEdge (TopoDS_Wire& W,
235 const TopoDS_Edge& E,
236 const Standard_Boolean direct) const
244 //=======================================================================
245 //function : AddFaceWire
246 //purpose : Add a Wire to a Face
247 //=======================================================================
249 void BRepPrim_Builder::AddFaceWire (TopoDS_Face& F,
250 const TopoDS_Wire& W) const
255 //=======================================================================
256 //function : AddShellFace
257 //purpose : Add a Face to a Shell
258 //=======================================================================
260 void BRepPrim_Builder::AddShellFace(TopoDS_Shell& S,
261 const TopoDS_Face& F) const
266 //=======================================================================
267 //function : Complete
269 //=======================================================================
271 void BRepPrim_Builder::CompleteEdge(TopoDS_Edge& E)const
273 BRepTools::Update(E);
276 //=======================================================================
277 //function : Complete
279 //=======================================================================
281 void BRepPrim_Builder::CompleteWire(TopoDS_Wire& W)const
283 BRepTools::Update(W);
287 //=======================================================================
288 //function : Complete
290 //=======================================================================
292 void BRepPrim_Builder::CompleteFace(TopoDS_Face& F)const
294 BRepTools::Update(F);
298 //=======================================================================
299 //function : Complete
301 //=======================================================================
303 void BRepPrim_Builder::CompleteShell(TopoDS_Shell& S)const
305 BRepTools::Update(S);