1 // Created on: 1995-04-26
2 // Created by: Modelistation
3 // Copyright (c) 1995-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 _ChFi3d_ChBuilder_HeaderFile
18 #define _ChFi3d_ChBuilder_HeaderFile
19 
20 #include <BRepAdaptor_Curve2d.hxx>
21 #include <BRepAdaptor_Surface.hxx>
22 #include <ChFi3d_Builder.hxx>
23 #include <ChFiDS_ChamfMethod.hxx>
24 #include <ChFiDS_ChamfMode.hxx>
25 #include <ChFiDS_SecHArray1.hxx>
26 #include <ChFiDS_ListOfStripe.hxx>
27 #include <ChFiDS_SequenceOfSurfData.hxx>
28 #include <ChFiDS_ElSpine.hxx>
29 #include <math_Vector.hxx>
30 #include <TopAbs_Orientation.hxx>
31 #include <TopAbs_State.hxx>
32 
33 class TopoDS_Shape;
34 class TopoDS_Edge;
35 class TopoDS_Face;
36 class ChFiDS_SurfData;
37 class ChFiDS_Spine;
38 class Adaptor3d_TopolTool;
39 class TopoDS_Vertex;
40 class ChFiDS_Stripe;
41 
42 
43 //! construction tool for 3D chamfers on edges (on a solid).
44 class ChFi3d_ChBuilder  : public ChFi3d_Builder
45 {
46 public:
47 
48   DEFINE_STANDARD_ALLOC
49 
50 
51   //! initializes the Builder with the Shape <S> for the
52   //! computation of chamfers
53   Standard_EXPORT ChFi3d_ChBuilder(const TopoDS_Shape& S, const Standard_Real Ta = 1.0e-2);
54 
55   //! initializes a contour with the edge <E> as first
56   //! (the next are found by propagation ).
57   //! The two distances (parameters of the chamfer) must
58   //! be set after.
59   //! if the edge <E> has more than 2 adjacent faces
60   Standard_EXPORT void Add (const TopoDS_Edge& E);
61 
62   //! initializes a new contour with the edge <E> as first
63   //! (the next are found by propagation ), and  the
64   //! distance <Dis>
65   //! if the edge <E> has more than 2 adjacent faces
66   Standard_EXPORT void Add (const Standard_Real Dis, const TopoDS_Edge& E);
67 
68   //! set the distance <Dis> of the fillet
69   //! contour of index <IC> in the DS with <Dis> on <F>.
70   //! if the face <F> is not one of common faces
71   //! of an edge of the contour <IC>
72   Standard_EXPORT void SetDist (const Standard_Real Dis,
73                                 const Standard_Integer IC,
74                                 const TopoDS_Face& F);
75 
76   //! gives the distances <Dis> of the fillet
77   //! contour of index <IC> in the DS
78   Standard_EXPORT void GetDist (const Standard_Integer IC, Standard_Real& Dis) const;
79 
80   //! initializes a new contour with the edge <E> as first
81   //! (the next are found by propagation ), and  the
82   //! distance <Dis1> and <Dis2>
83   //! if the edge <E> has more than 2 adjacent faces
84   Standard_EXPORT void Add (const Standard_Real Dis1,
85                             const Standard_Real Dis2,
86                             const TopoDS_Edge& E,
87                             const TopoDS_Face& F);
88 
89   //! set the distances <Dis1> and <Dis2> of the fillet
90   //! contour of index <IC> in the DS with <Dis1> on <F>.
91   //! if the face <F> is not one of common faces
92   //! of an edge of the contour <IC>
93   Standard_EXPORT void SetDists (const Standard_Real Dis1,
94                                  const Standard_Real Dis2,
95                                  const Standard_Integer IC,
96                                  const TopoDS_Face& F);
97 
98   //! gives the distances <Dis1> and <Dis2> of the fillet
99   //! contour of index <IC> in the DS
100   Standard_EXPORT void Dists (const Standard_Integer IC,
101                               Standard_Real& Dis1,
102                               Standard_Real& Dis2) const;
103 
104   //! initializes a new contour with the edge <E> as first
105   //! (the next are found by propagation ), and  the
106   //! distance <Dis1> and <Angle>
107   //! if the edge <E> has more than 2 adjacent faces
108   Standard_EXPORT void AddDA (const Standard_Real Dis,
109                               const Standard_Real Angle,
110                               const TopoDS_Edge& E,
111                               const TopoDS_Face& F);
112 
113   //! set the distance <Dis> and <Angle> of the fillet
114   //! contour of index <IC> in the DS with <Dis> on <F>.
115   //! if the face <F> is not one of common faces
116   //! of an edge of the contour <IC>
117   Standard_EXPORT void SetDistAngle (const Standard_Real Dis,
118                                      const Standard_Real Angle,
119                                      const Standard_Integer IC,
120                                      const TopoDS_Face& F);
121 
122   //! gives the distances <Dis> and <Angle> of the fillet
123   //! contour of index <IC> in the DS
124   Standard_EXPORT void GetDistAngle (const Standard_Integer IC,
125                                      Standard_Real& Dis,
126                                      Standard_Real& Angle) const;
127 
128   //! set the mode of shamfer
129   Standard_EXPORT void SetMode (const ChFiDS_ChamfMode theMode);
130 
131   //! renvoi la methode des chanfreins utilisee
132   Standard_EXPORT ChFiDS_ChamfMethod IsChamfer (const Standard_Integer IC) const;
133 
134   //! returns the mode of chamfer used
135   Standard_EXPORT ChFiDS_ChamfMode Mode () const;
136 
137   //! Reset tous rayons du contour IC.
138   Standard_EXPORT void ResetContour (const Standard_Integer IC);
139 
140   Standard_EXPORT void Simulate (const Standard_Integer IC);
141 
142   Standard_EXPORT Standard_Integer NbSurf (const Standard_Integer IC) const;
143 
144   Standard_EXPORT Handle(ChFiDS_SecHArray1) Sect (const Standard_Integer IC,
145                                                   const Standard_Integer IS) const;
146 
147   Standard_EXPORT virtual void SimulSurf (Handle(ChFiDS_SurfData)& Data,
148                                           const Handle(ChFiDS_ElSpine)& Guide,
149                                           const Handle(ChFiDS_Spine)& Spine,
150                                           const Standard_Integer Choix,
151                                           const Handle(BRepAdaptor_Surface)& S1,
152                                           const Handle(Adaptor3d_TopolTool)& I1,
153                                           const Handle(BRepAdaptor_Curve2d)& PC1,
154                                           const Handle(BRepAdaptor_Surface)& Sref1,
155                                           const Handle(BRepAdaptor_Curve2d)& PCref1,
156                                           Standard_Boolean& Decroch1,
157                                           const Handle(BRepAdaptor_Surface)& S2,
158                                           const Handle(Adaptor3d_TopolTool)& I2,
159                                           const TopAbs_Orientation Or2,
160                                           const Standard_Real Fleche,
161                                           const Standard_Real TolGuide,
162                                           Standard_Real& First,
163                                           Standard_Real& Last,
164                                           const Standard_Boolean Inside,
165                                           const Standard_Boolean Appro,
166                                           const Standard_Boolean Forward,
167                                           const Standard_Boolean RecP,
168                                           const Standard_Boolean RecS,
169                                           const Standard_Boolean RecRst,
170                                           const math_Vector& Soldep) Standard_OVERRIDE;
171 
172   Standard_EXPORT virtual void SimulSurf (Handle(ChFiDS_SurfData)& Data,
173                                           const Handle(ChFiDS_ElSpine)& Guide,
174                                           const Handle(ChFiDS_Spine)& Spine,
175                                           const Standard_Integer Choix,
176                                           const Handle(BRepAdaptor_Surface)& S1,
177                                           const Handle(Adaptor3d_TopolTool)& I1,
178                                           const TopAbs_Orientation Or1,
179                                           const Handle(BRepAdaptor_Surface)& S2,
180                                           const Handle(Adaptor3d_TopolTool)& I2,
181                                           const Handle(BRepAdaptor_Curve2d)& PC2,
182                                           const Handle(BRepAdaptor_Surface)& Sref2,
183                                           const Handle(BRepAdaptor_Curve2d)& PCref2,
184                                           Standard_Boolean& Decroch2,
185                                           const Standard_Real Fleche,
186                                           const Standard_Real TolGuide,
187                                           Standard_Real& First,
188                                           Standard_Real& Last,
189                                           const Standard_Boolean Inside,
190                                           const Standard_Boolean Appro,
191                                           const Standard_Boolean Forward,
192                                           const Standard_Boolean RecP,
193                                           const Standard_Boolean RecS,
194                                           const Standard_Boolean RecRst,
195                                           const math_Vector& Soldep) Standard_OVERRIDE;
196 
197   Standard_EXPORT virtual void SimulSurf (Handle(ChFiDS_SurfData)& Data,
198                                           const Handle(ChFiDS_ElSpine)& Guide,
199                                           const Handle(ChFiDS_Spine)& Spine,
200                                           const Standard_Integer Choix,
201                                           const Handle(BRepAdaptor_Surface)& S1,
202                                           const Handle(Adaptor3d_TopolTool)& I1,
203                                           const Handle(BRepAdaptor_Curve2d)& PC1,
204                                           const Handle(BRepAdaptor_Surface)& Sref1,
205                                           const Handle(BRepAdaptor_Curve2d)& PCref1,
206                                           Standard_Boolean& Decroch1,
207                                           const TopAbs_Orientation Or1,
208                                           const Handle(BRepAdaptor_Surface)& S2,
209                                           const Handle(Adaptor3d_TopolTool)& I2,
210                                           const Handle(BRepAdaptor_Curve2d)& PC2,
211                                           const Handle(BRepAdaptor_Surface)& Sref2,
212                                           const Handle(BRepAdaptor_Curve2d)& PCref2,
213                                           Standard_Boolean& Decroch2,
214                                           const TopAbs_Orientation Or2,
215                                           const Standard_Real Fleche,
216                                           const Standard_Real TolGuide,
217                                           Standard_Real& First,
218                                           Standard_Real& Last,
219                                           const Standard_Boolean Inside,
220                                           const Standard_Boolean Appro,
221                                           const Standard_Boolean Forward,
222                                           const Standard_Boolean RecP1,
223                                           const Standard_Boolean RecRst1,
224                                           const Standard_Boolean RecP2,
225                                           const Standard_Boolean RecRst2,
226                                           const math_Vector& Soldep) Standard_OVERRIDE;
227 
228   //! Methode, implemented in inheritants, calculates
229   //! the elements of construction of  the surface (fillet
230   //! or chamfer).
231   Standard_EXPORT virtual Standard_Boolean PerformSurf (ChFiDS_SequenceOfSurfData& Data,
232                                                         const Handle(ChFiDS_ElSpine)& Guide,
233                                                         const Handle(ChFiDS_Spine)& Spine,
234                                                         const Standard_Integer Choix,
235                                                         const Handle(BRepAdaptor_Surface)& S1,
236                                                         const Handle(Adaptor3d_TopolTool)& I1,
237                                                         const Handle(BRepAdaptor_Surface)& S2,
238                                                         const Handle(Adaptor3d_TopolTool)& I2,
239                                                         const Standard_Real MaxStep,
240                                                         const Standard_Real Fleche,
241                                                         const Standard_Real TolGuide,
242                                                         Standard_Real& First,
243                                                         Standard_Real& Last,
244                                                         const Standard_Boolean Inside,
245                                                         const Standard_Boolean Appro,
246                                                         const Standard_Boolean Forward,
247                                                         const Standard_Boolean RecOnS1,
248                                                         const Standard_Boolean RecOnS2,
249                                                         const math_Vector& Soldep,
250                                                         Standard_Integer& Intf,
251                                                         Standard_Integer& Intl) Standard_OVERRIDE;
252 
253   //! Method, implemented in  the inheritants, calculates
254   //! the elements of construction of  the surface (fillet
255   //! or chamfer) contact edge/face.
256   Standard_EXPORT virtual void PerformSurf (ChFiDS_SequenceOfSurfData& Data,
257                                             const Handle(ChFiDS_ElSpine)& Guide,
258                                             const Handle(ChFiDS_Spine)& Spine,
259                                             const Standard_Integer Choix,
260                                             const Handle(BRepAdaptor_Surface)& S1,
261                                             const Handle(Adaptor3d_TopolTool)& I1,
262                                             const Handle(BRepAdaptor_Curve2d)& PC1,
263                                             const Handle(BRepAdaptor_Surface)& Sref1,
264                                             const Handle(BRepAdaptor_Curve2d)& PCref1,
265                                             Standard_Boolean& Decroch1,
266                                             const Handle(BRepAdaptor_Surface)& S2,
267                                             const Handle(Adaptor3d_TopolTool)& I2,
268                                             const TopAbs_Orientation Or2,
269                                             const Standard_Real MaxStep,
270                                             const Standard_Real Fleche,
271                                             const Standard_Real TolGuide,
272                                             Standard_Real& First,
273                                             Standard_Real& Last,
274                                             const Standard_Boolean Inside,
275                                             const Standard_Boolean Appro,
276                                             const Standard_Boolean Forward,
277                                             const Standard_Boolean RecP,
278                                             const Standard_Boolean RecS,
279                                             const Standard_Boolean RecRst,
280                                             const math_Vector& Soldep) Standard_OVERRIDE;
281 
282   //! Method, implemented in inheritants, calculates
283   //! the elements of construction of  the surface (fillet
284   //! or chamfer) contact edge/face.
285   Standard_EXPORT virtual void PerformSurf (ChFiDS_SequenceOfSurfData& Data,
286                                             const Handle(ChFiDS_ElSpine)& Guide,
287                                             const Handle(ChFiDS_Spine)& Spine,
288                                             const Standard_Integer Choix,
289                                             const Handle(BRepAdaptor_Surface)& S1,
290                                             const Handle(Adaptor3d_TopolTool)& I1,
291                                             const TopAbs_Orientation Or1,
292                                             const Handle(BRepAdaptor_Surface)& S2,
293                                             const Handle(Adaptor3d_TopolTool)& I2,
294                                             const Handle(BRepAdaptor_Curve2d)& PC2,
295                                             const Handle(BRepAdaptor_Surface)& Sref2,
296                                             const Handle(BRepAdaptor_Curve2d)& PCref2,
297                                             Standard_Boolean& Decroch2,
298                                             const Standard_Real MaxStep,
299                                             const Standard_Real Fleche,
300                                             const Standard_Real TolGuide,
301                                             Standard_Real& First,
302                                             Standard_Real& Last,
303                                             const Standard_Boolean Inside,
304                                             const Standard_Boolean Appro,
305                                             const Standard_Boolean Forward,
306                                             const Standard_Boolean RecP,
307                                             const Standard_Boolean RecS,
308                                             const Standard_Boolean RecRst,
309                                             const math_Vector& Soldep) Standard_OVERRIDE;
310 
311   //! Method, implemented in  inheritants, calculates
312   //! the elements of construction of  the surface (fillet
313   //! or chamfer) contact edge/edge.
314   Standard_EXPORT virtual void PerformSurf (ChFiDS_SequenceOfSurfData& Data,
315                                             const Handle(ChFiDS_ElSpine)& Guide,
316                                             const Handle(ChFiDS_Spine)& Spine,
317                                             const Standard_Integer Choix,
318                                             const Handle(BRepAdaptor_Surface)& S1,
319                                             const Handle(Adaptor3d_TopolTool)& I1,
320                                             const Handle(BRepAdaptor_Curve2d)& PC1,
321                                             const Handle(BRepAdaptor_Surface)& Sref1,
322                                             const Handle(BRepAdaptor_Curve2d)& PCref1,
323                                             Standard_Boolean& Decroch1,
324                                             const TopAbs_Orientation Or1,
325                                             const Handle(BRepAdaptor_Surface)& S2,
326                                             const Handle(Adaptor3d_TopolTool)& I2,
327                                             const Handle(BRepAdaptor_Curve2d)& PC2,
328                                             const Handle(BRepAdaptor_Surface)& Sref2,
329                                             const Handle(BRepAdaptor_Curve2d)& PCref2,
330                                             Standard_Boolean& Decroch2,
331                                             const TopAbs_Orientation Or2,
332                                             const Standard_Real MaxStep,
333                                             const Standard_Real Fleche,
334                                             const Standard_Real TolGuide,
335                                             Standard_Real& First,
336                                             Standard_Real& Last,
337                                             const Standard_Boolean Inside,
338                                             const Standard_Boolean Appro,
339                                             const Standard_Boolean Forward,
340                                             const Standard_Boolean RecP1,
341                                             const Standard_Boolean RecRst1,
342                                             const Standard_Boolean RecP2,
343                                             const Standard_Boolean RecRst2,
344                                             const math_Vector& Soldep) Standard_OVERRIDE;
345 
346 
347 
348 
349 protected:
350 
351 
352   Standard_EXPORT void SimulKPart (const Handle(ChFiDS_SurfData)& SD) const Standard_OVERRIDE;
353 
354   Standard_EXPORT Standard_Boolean SimulSurf (Handle(ChFiDS_SurfData)& Data,
355                                               const Handle(ChFiDS_ElSpine)& Guide,
356                                               const Handle(ChFiDS_Spine)& Spine,
357                                               const Standard_Integer Choix,
358                                               const Handle(BRepAdaptor_Surface)& S1,
359                                               const Handle(Adaptor3d_TopolTool)& I1,
360                                               const Handle(BRepAdaptor_Surface)& S2,
361                                               const Handle(Adaptor3d_TopolTool)& I2,
362                                               const Standard_Real TolGuide,
363                                               Standard_Real& First,
364                                               Standard_Real& Last,
365                                               const Standard_Boolean Inside,
366                                               const Standard_Boolean Appro,
367                                               const Standard_Boolean Forward,
368                                               const Standard_Boolean RecOnS1,
369                                               const Standard_Boolean RecOnS2,
370                                               const math_Vector& Soldep,
371                                               Standard_Integer& Intf,
372                                               Standard_Integer& Intl) Standard_OVERRIDE;
373 
374   Standard_EXPORT Standard_Boolean PerformFirstSection (const Handle(ChFiDS_Spine)& S,
375                                                         const Handle(ChFiDS_ElSpine)& HGuide,
376                                                         const Standard_Integer Choix,
377                                                         Handle(BRepAdaptor_Surface)& S1,
378                                                         Handle(BRepAdaptor_Surface)& S2,
379                                                         const Handle(Adaptor3d_TopolTool)& I1,
380                                                         const Handle(Adaptor3d_TopolTool)& I2,
381                                                         const Standard_Real Par,
382                                                         math_Vector& SolDep,
383                                                         TopAbs_State& Pos1,
384                                                         TopAbs_State& Pos2) const Standard_OVERRIDE;
385 
386   //! computes  the  intersection of two chamfers on
387   //! the vertex of index <Index> in myVDataMap.
388   Standard_EXPORT void PerformTwoCorner (const Standard_Integer Index) Standard_OVERRIDE;
389 
390   //! computes the intersection of three chamfers on
391   //! the vertex of index <Index> in myVDataMap.
392   Standard_EXPORT void PerformThreeCorner (const Standard_Integer Index) Standard_OVERRIDE;
393 
394   //! extends  the spine  of  the Stripe  <S> at  the
395   //! extremity of the vertex <V>.
396   Standard_EXPORT void ExtentOneCorner (const TopoDS_Vertex& V,
397                                         const Handle(ChFiDS_Stripe)& S) Standard_OVERRIDE;
398 
399   //! extends the spine of the 2 stripes of <LS> at the
400   //! extremity of the vertex <V>
401   Standard_EXPORT void ExtentTwoCorner (const TopoDS_Vertex& V,
402                                         const ChFiDS_ListOfStripe& LS) Standard_OVERRIDE;
403 
404   //! extends the spine of the 2 stripes of <LS> at the
405   //! extremity of the vertex <V>
406   Standard_EXPORT void ExtentThreeCorner (const TopoDS_Vertex& V,
407                                           const ChFiDS_ListOfStripe& LS) Standard_OVERRIDE;
408 
409   //! set the regularities
410   Standard_EXPORT void SetRegul() Standard_OVERRIDE;
411 
412 
413 
414 
415 private:
416 
417 
418   Standard_EXPORT void ConexFaces (const Handle(ChFiDS_Spine)& Sp,
419                                    const Standard_Integer IEdge,
420                                    TopoDS_Face& F1,
421                                    TopoDS_Face& F2) const;
422 
423   ChFiDS_ChamfMode   myMode;
424 
425 
426 };
427 
428 
429 
430 
431 
432 
433 
434 #endif // _ChFi3d_ChBuilder_HeaderFile
435