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 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 <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>
29 #include <gp_Lin2d.hxx>
32 #include <Precision.hxx>
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>
40 //=======================================================================
41 //function : BRepPrim_Builder
42 //purpose : constructor
43 //=======================================================================
44 BRepPrim_Builder::BRepPrim_Builder ()
48 //=======================================================================
49 //function : BRepPrim_Builder
50 //purpose : constructor
51 //=======================================================================
53 BRepPrim_Builder::BRepPrim_Builder (const BRep_Builder& B) :
58 //=======================================================================
59 //function : MakeShell
60 //purpose : Make a Shell
61 //=======================================================================
63 void BRepPrim_Builder::MakeShell (TopoDS_Shell& S) const
65 myBuilder.MakeShell(S);
66 S.Closed(Standard_True);
69 //=======================================================================
71 //purpose : Make a Planar Face
72 //=======================================================================
74 void BRepPrim_Builder::MakeFace (TopoDS_Face& F, const gp_Pln& P) const
76 myBuilder.MakeFace(F,new Geom_Plane(P),Precision::Confusion());
79 //=======================================================================
81 //purpose : Make an empty Wire
82 //=======================================================================
84 void BRepPrim_Builder::MakeWire (TopoDS_Wire& W) const
86 myBuilder.MakeWire(W);
89 //=======================================================================
90 //function : MakeDegeneratedEdge
92 //=======================================================================
94 void BRepPrim_Builder::MakeDegeneratedEdge (TopoDS_Edge& E) const
96 myBuilder.MakeEdge(E);
97 myBuilder.Degenerated(E,Standard_True);
100 //=======================================================================
101 //function : MakeEdge
102 //purpose : Make a linear Edge
103 //=======================================================================
105 void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Lin& L) const
107 myBuilder.MakeEdge(E,new Geom_Line(L),Precision::Confusion());
110 //=======================================================================
111 //function : MakeEdge
112 //purpose : Make a Circular Edge
113 //=======================================================================
115 void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Circ& C) const
117 myBuilder.MakeEdge(E,new Geom_Circle(C),Precision::Confusion());
120 //=======================================================================
121 //function : SetPCurve
123 //=======================================================================
125 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
126 const TopoDS_Face& F,
127 const gp_Lin2d& L) const
129 myBuilder.UpdateEdge(E,new Geom2d_Line(L),F,Precision::Confusion());
132 //=======================================================================
133 //function : SetPCurve
135 //=======================================================================
137 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
138 const TopoDS_Face& F,
140 const gp_Lin2d& L2) const
142 TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
143 myBuilder.UpdateEdge(TopoDS::Edge(aLocalShape),
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);
154 //=======================================================================
155 //function : SetPCurve
157 //=======================================================================
159 void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E,
160 const TopoDS_Face& F,
161 const gp_Circ2d& C) const
163 myBuilder.UpdateEdge(E,new Geom2d_Circle(C),F,Precision::Confusion());
167 //=======================================================================
168 //function : MakeVertex
169 //purpose : Make a Vertex
170 //=======================================================================
172 void BRepPrim_Builder::MakeVertex (TopoDS_Vertex& V, const gp_Pnt& P) const
174 myBuilder.MakeVertex(V,P,Precision::Confusion());
177 //=======================================================================
178 //function : ReverseFace
179 //purpose : Reverse a Face
180 //=======================================================================
182 void BRepPrim_Builder::ReverseFace (TopoDS_Face& F) const
187 //=======================================================================
188 //function : AddEdgeVertex
189 //purpose : Add a Vertex to an Edge
190 //=======================================================================
192 void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
193 const TopoDS_Vertex& V,
194 const Standard_Real P,
195 const Standard_Boolean direct) const
197 TopoDS_Vertex VV = V;
201 myBuilder.UpdateVertex(VV,P,E,Precision::Confusion());
205 //=======================================================================
206 //function : AddEdgeVertex
207 //purpose : Add a Vertex to an Edge
208 //=======================================================================
210 void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E,
211 const TopoDS_Vertex& V,
212 const Standard_Real P1,
213 const Standard_Real P2) const
215 TopoDS_Vertex VV = V;
216 VV.Orientation(TopAbs_FORWARD);
218 VV.Orientation(TopAbs_REVERSED);
220 myBuilder.Range(E,P1,P2);
223 //=======================================================================
224 //function : SetParameters
226 //=======================================================================
228 void BRepPrim_Builder::SetParameters (TopoDS_Edge& E,
229 const TopoDS_Vertex& ,
230 const Standard_Real P1,
231 const Standard_Real P2) const
233 myBuilder.Range(E,P1,P2);
236 //=======================================================================
237 //function : AddWireEdge
238 //purpose : Add an Edge to a Wire
239 //=======================================================================
241 void BRepPrim_Builder::AddWireEdge (TopoDS_Wire& W,
242 const TopoDS_Edge& E,
243 const Standard_Boolean direct) const
251 //=======================================================================
252 //function : AddFaceWire
253 //purpose : Add a Wire to a Face
254 //=======================================================================
256 void BRepPrim_Builder::AddFaceWire (TopoDS_Face& F,
257 const TopoDS_Wire& W) const
262 //=======================================================================
263 //function : AddShellFace
264 //purpose : Add a Face to a Shell
265 //=======================================================================
267 void BRepPrim_Builder::AddShellFace(TopoDS_Shell& S,
268 const TopoDS_Face& F) const
273 //=======================================================================
274 //function : Complete
276 //=======================================================================
278 void BRepPrim_Builder::CompleteEdge(TopoDS_Edge& E)const
280 BRepTools::Update(E);
283 //=======================================================================
284 //function : Complete
286 //=======================================================================
288 void BRepPrim_Builder::CompleteWire(TopoDS_Wire& W)const
290 W.Closed(BRep_Tool::IsClosed(W));
291 BRepTools::Update(W);
295 //=======================================================================
296 //function : Complete
298 //=======================================================================
300 void BRepPrim_Builder::CompleteFace(TopoDS_Face& F)const
302 BRepTools::Update(F);
306 //=======================================================================
307 //function : Complete
309 //=======================================================================
311 void BRepPrim_Builder::CompleteShell(TopoDS_Shell& S)const
313 S.Closed(BRep_Tool::IsClosed(S));
314 BRepTools::Update(S);