1 // Created on: 1991-07-01
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _BRep_Builder_HeaderFile
18 #define _BRep_Builder_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <TopoDS_Builder.hxx>
25 #include <Geom2d_Curve.hxx>
26 #include <Geom_Curve.hxx>
27 #include <Geom_Surface.hxx>
28 #include <GeomAbs_Shape.hxx>
29 #include <Poly_Polygon3D.hxx>
30 #include <Poly_PolygonOnTriangulation.hxx>
31 #include <Poly_ListOfTriangulation.hxx>
32 
33 class TopoDS_Face;
34 class Geom_Surface;
35 class TopLoc_Location;
36 class Poly_Triangulation;
37 class TopoDS_Edge;
38 class Geom_Curve;
39 class Poly_Polygon3D;
40 class Poly_PolygonOnTriangulation;
41 class Geom2d_Curve;
42 class gp_Pnt2d;
43 class Poly_Polygon2D;
44 class TopoDS_Vertex;
45 class gp_Pnt;
46 
47 
48 //! A framework providing advanced tolerance control.
49 //! It is used to build Shapes.
50 //! If tolerance control is required, you are advised to:
51 //! 1. build a default precision for topology, using the
52 //! classes provided in the BRepAPI package
53 //! 2. update the tolerance of the resulting shape.
54 //! Note that only vertices, edges and faces have
55 //! meaningful tolerance control. The tolerance value
56 //! must always comply with the condition that face
57 //! tolerances are more restrictive than edge tolerances
58 //! which are more restrictive than vertex tolerances. In
59 //! other words: Tol(Vertex) >= Tol(Edge) >= Tol(Face).
60 //! Other rules in setting tolerance include:
61 //! - you can open up tolerance but should never restrict it
62 //! - an edge cannot be included within the fusion of the
63 //! tolerance spheres of two vertices
64 class BRep_Builder  : public TopoDS_Builder
65 {
66 public:
67 
68   DEFINE_STANDARD_ALLOC
69 
70 
71   //! Makes an undefined Face.
72     void MakeFace (TopoDS_Face& F) const;
73 
74   //! Makes a Face with a surface.
75   Standard_EXPORT void MakeFace (TopoDS_Face& F, const Handle(Geom_Surface)& S, const Standard_Real Tol) const;
76 
77   //! Makes a Face with a surface and a location.
78   Standard_EXPORT void MakeFace (TopoDS_Face& F, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
79 
80   //! Makes a theFace with a single triangulation. The triangulation
81   //! is in the same reference system than the TFace.
82   Standard_EXPORT void MakeFace (TopoDS_Face& theFace, const Handle(Poly_Triangulation)& theTriangulation) const;
83 
84   //! Makes a Face with a list of triangulations and active one.
85   //! Use NULL active triangulation to set the first triangulation in list as active.
86   //! The triangulations is in the same reference system than the TFace.
87   Standard_EXPORT void MakeFace (TopoDS_Face& theFace, const Poly_ListOfTriangulation& theTriangulations, const Handle(Poly_Triangulation)& theActiveTriangulation = Handle(Poly_Triangulation)()) const;
88 
89   //! Updates the face F using the tolerance value Tol,
90   //! surface S and location Location.
91   Standard_EXPORT void UpdateFace (const TopoDS_Face& F, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
92 
93   //! Changes a face triangulation.
94   //! A NULL theTriangulation removes face triangulations.
95   //! If theToReset is TRUE face triangulations will be reset to new list with only one input triangulation that will be active.
96   //! Else if theTriangulation is contained in internal triangulations list it will be made active,
97   //!      else the active triangulation will be replaced to theTriangulation one.
98   Standard_EXPORT void UpdateFace (const TopoDS_Face& theFace, const Handle(Poly_Triangulation)& theTriangulation, const Standard_Boolean theToReset = true) const;
99 
100   //! Updates the face Tolerance.
101   Standard_EXPORT void UpdateFace (const TopoDS_Face& F, const Standard_Real Tol) const;
102 
103   //! Sets the  NaturalRestriction flag of  the face.
104   Standard_EXPORT void NaturalRestriction (const TopoDS_Face& F, const Standard_Boolean N) const;
105 
106   //! Makes an undefined Edge (no geometry).
107   Standard_EXPORT void MakeEdge (TopoDS_Edge& E) const;
108 
109   //! Makes an Edge with a curve.
110     void MakeEdge (TopoDS_Edge& E, const Handle(Geom_Curve)& C, const Standard_Real Tol) const;
111 
112   //! Makes an Edge with a curve and a location.
113     void MakeEdge (TopoDS_Edge& E, const Handle(Geom_Curve)& C, const TopLoc_Location& L, const Standard_Real Tol) const;
114 
115   //! Makes an Edge with a polygon 3d.
116     void MakeEdge (TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const;
117 
118   //! makes an Edge polygon on Triangulation.
119     void MakeEdge (TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N, const Handle(Poly_Triangulation)& T) const;
120 
121   //! makes an Edge polygon on Triangulation.
122     void MakeEdge (TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L) const;
123 
124   //! Sets a 3D curve for the edge.
125   //! If <C> is a null handle, remove any existing 3d curve.
126     void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom_Curve)& C, const Standard_Real Tol) const;
127 
128   //! Sets a 3D curve for the edge.
129   //! If <C> is a null handle, remove any existing 3d curve.
130   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom_Curve)& C, const TopLoc_Location& L, const Standard_Real Tol) const;
131 
132   //! Sets a pcurve for the edge on the face.
133   //! If <C> is a null handle, remove any existing pcurve.
134     void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C, const TopoDS_Face& F, const Standard_Real Tol) const;
135 
136   //! Sets pcurves for the edge on the  closed face.  If
137   //! <C1> or <C2> is a null handle, remove any existing
138   //! pcurve.
139     void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const TopoDS_Face& F, const Standard_Real Tol) const;
140 
141   //! Sets a pcurve for the edge on the face.
142   //! If <C> is a null handle, remove any existing pcurve.
143   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
144 
145   //! Sets a pcurve for the edge on the face.
146   //! If <C> is a null handle, remove any existing pcurve.
147   //! Sets UV bounds for curve repsentation
148   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol, const gp_Pnt2d& Pf, const gp_Pnt2d& Pl) const;
149 
150   //! Sets pcurves for the edge on the closed surface.
151   //! <C1> or <C2> is a null handle, remove any existing
152   //! pcurve.
153   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
154 
155   //! Sets pcurves for the edge on the closed surface.
156   //! <C1> or <C2> is a null handle, remove any existing
157   //! pcurve.
158   //! Sets UV bounds for curve repsentation
159   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol, const gp_Pnt2d& Pf, const gp_Pnt2d& Pl) const;
160 
161   //! Changes an Edge 3D polygon.
162   //! A null Polygon removes the 3d Polygon.
163     void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const;
164 
165   //! Changes an Edge 3D polygon.
166   //! A null Polygon removes the 3d Polygon.
167   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P, const TopLoc_Location& L) const;
168 
169   //! Changes an Edge polygon on Triangulation.
170     void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N, const Handle(Poly_Triangulation)& T) const;
171 
172   //! Changes an Edge polygon on Triangulation.
173   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L) const;
174 
175   //! Changes an Edge polygon on Triangulation.
176     void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N1, const Handle(Poly_PolygonOnTriangulation)& N2, const Handle(Poly_Triangulation)& T) const;
177 
178   //! Changes an Edge polygon on Triangulation.
179   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_PolygonOnTriangulation)& N1, const Handle(Poly_PolygonOnTriangulation)& N2, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L) const;
180 
181   //! Changes Edge polygon on a face.
182   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon2D)& P, const TopoDS_Face& S) const;
183 
184   //! Changes Edge polygon on a face.
185   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon2D)& P, const Handle(Geom_Surface)& S, const TopLoc_Location& T) const;
186 
187   //! Changes Edge polygons on a face.
188   //!
189   //! A null Polygon removes the 2d Polygon.
190   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon2D)& P1, const Handle(Poly_Polygon2D)& P2, const TopoDS_Face& S) const;
191 
192   //! Changes Edge polygons on a face.
193   //!
194   //! A null Polygon removes the 2d Polygon.
195   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Handle(Poly_Polygon2D)& P1, const Handle(Poly_Polygon2D)& P2, const Handle(Geom_Surface)& S, const TopLoc_Location& L) const;
196 
197   //! Updates the edge tolerance.
198   Standard_EXPORT void UpdateEdge (const TopoDS_Edge& E, const Standard_Real Tol) const;
199 
200   //! Sets the geometric continuity on the edge.
201   Standard_EXPORT void Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const GeomAbs_Shape C) const;
202 
203   //! Sets the geometric continuity on the edge.
204   Standard_EXPORT void Continuity (const TopoDS_Edge& E, const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const TopLoc_Location& L1, const TopLoc_Location& L2, const GeomAbs_Shape C) const;
205 
206   //! Sets the same parameter flag for the edge <E>.
207   Standard_EXPORT void SameParameter (const TopoDS_Edge& E, const Standard_Boolean S) const;
208 
209   //! Sets the same range flag for the edge <E>.
210   Standard_EXPORT void SameRange (const TopoDS_Edge& E, const Standard_Boolean S) const;
211 
212   //! Sets the degenerated flag for the edge <E>.
213   Standard_EXPORT void Degenerated (const TopoDS_Edge& E, const Standard_Boolean D) const;
214 
215   //! Sets the range of the 3d curve if Only3d=TRUE,
216   //! otherwise sets the range to all the representations
217   Standard_EXPORT void Range (const TopoDS_Edge& E, const Standard_Real First, const Standard_Real Last, const Standard_Boolean Only3d = Standard_False) const;
218 
219   //! Sets the range  of the edge  on the pcurve on  the
220   //! surface.
221   Standard_EXPORT void Range (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real First, const Standard_Real Last) const;
222 
223   //! Sets the range of the edge on the pcurve on the face.
224     void Range (const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Real First, const Standard_Real Last) const;
225 
226   //! Add  to <Eout>  the  geometric representations  of
227   //! <Ein>.
228   Standard_EXPORT void Transfert (const TopoDS_Edge& Ein, const TopoDS_Edge& Eout) const;
229 
230   //! Makes an udefined vertex without geometry.
231     void MakeVertex (TopoDS_Vertex& V) const;
232 
233   //! Makes a vertex from a 3D point.
234     void MakeVertex (TopoDS_Vertex& V, const gp_Pnt& P, const Standard_Real Tol) const;
235 
236   //! Sets a 3D point on the vertex.
237   Standard_EXPORT void UpdateVertex (const TopoDS_Vertex& V, const gp_Pnt& P, const Standard_Real Tol) const;
238 
239   //! Sets  the parameter  for the   vertex on the  edge
240   //! curves.
241   Standard_EXPORT void UpdateVertex (const TopoDS_Vertex& V, const Standard_Real P, const TopoDS_Edge& E, const Standard_Real Tol) const;
242 
243   //! Sets  the parameter  for the  vertex  on the  edge
244   //! pcurve  on the face.
245     void UpdateVertex (const TopoDS_Vertex& V, const Standard_Real P, const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Real Tol) const;
246 
247   //! Sets  the parameter  for the  vertex  on the  edge
248   //! pcurve  on the surface.
249   Standard_EXPORT void UpdateVertex (const TopoDS_Vertex& V, const Standard_Real P, const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const Standard_Real Tol) const;
250 
251   //! Sets the parameters for the vertex on the face.
252   Standard_EXPORT void UpdateVertex (const TopoDS_Vertex& Ve, const Standard_Real U, const Standard_Real V, const TopoDS_Face& F, const Standard_Real Tol) const;
253 
254   //! Updates the vertex tolerance.
255   Standard_EXPORT void UpdateVertex (const TopoDS_Vertex& V, const Standard_Real Tol) const;
256 
257   //! Transfert the parameters  of   Vin on  Ein as  the
258   //! parameter of Vout on Eout.
259   Standard_EXPORT void Transfert (const TopoDS_Edge& Ein, const TopoDS_Edge& Eout, const TopoDS_Vertex& Vin, const TopoDS_Vertex& Vout) const;
260 
261 
262 
263 
264 protected:
265 
266 
267 
268 
269 
270 private:
271 
272 
273 
274 
275 
276 };
277 
278 
279 #include <BRep_Builder.lxx>
280 
281 
282 
283 
284 
285 #endif // _BRep_Builder_HeaderFile
286