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