1 // Created on: 1993-11-09
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1993-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 _ChFiDS_Spine_HeaderFile
18 #define _ChFiDS_Spine_HeaderFile
19 
20 #include <BRepAdaptor_Curve.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Vec.hxx>
23 #include <GeomAbs_CurveType.hxx>
24 #include <ChFiDS_ChamfMode.hxx>
25 #include <ChFiDS_ErrorStatus.hxx>
26 #include <ChFiDS_ListOfHElSpine.hxx>
27 #include <ChFiDS_State.hxx>
28 #include <ChFiDS_TypeOfConcavity.hxx>
29 #include <ChFiDS_ElSpine.hxx>
30 #include <TColStd_HArray1OfReal.hxx>
31 #include <TopTools_SequenceOfShape.hxx>
32 
33 class TopoDS_Edge;
34 class gp_Lin;
35 class gp_Circ;
36 class TopoDS_Vertex;
37 
38 // resolve name collisions with X11 headers
39 #ifdef Status
40   #undef Status
41 #endif
42 
43 class ChFiDS_Spine;
44 DEFINE_STANDARD_HANDLE(ChFiDS_Spine, Standard_Transient)
45 
46 //! Contains information necessary for construction of
47 //! a 3D fillet or chamfer:
48 //!
49 //! - guideline composed of edges of the solid, tangents
50 //! between them, and borders by faces tangents
51 //! between them.
52 //!
53 //! Tools for construction of the Sp
54 //! by propagation from an edge of solid
55 //! are provided in the Builder of Fil3d.
56 //!
57 //! The Spine contains among others the
58 //! information about the nature of extremities
59 //! of the fillet ( on free border , on section or closed ).
60 //!
61 //! IMPORTANT NOTE  :    the guideline
62 //! represented in this way is not C2, although the path
63 //! claims it. Several palliative workarounds
64 //! (see the methods at the end) are planned,
65 //! but they are not enough. It is necessary to change
66 //! the approach and double the Spine of line C2 with
67 //! the known consequences for management of
68 //! interactions between KPart Blend in Fil3d.
69 class ChFiDS_Spine : public Standard_Transient
70 {
71 
72 public:
73 
74 
75   Standard_EXPORT ChFiDS_Spine();
76 
77   Standard_EXPORT ChFiDS_Spine(const Standard_Real Tol);
78 
79   //! store edges composing the guideline
80     void SetEdges (const TopoDS_Edge& E);
81 
82   //! store offset edges composing the offset guideline
83     void SetOffsetEdges (const TopoDS_Edge& E);
84 
85   //! store the edge at the first position before all others
86     void PutInFirst (const TopoDS_Edge& E);
87 
88   //! store the offset edge at the first position before all others
89     void PutInFirstOffset (const TopoDS_Edge& E);
90 
91     Standard_Integer NbEdges() const;
92 
93     const TopoDS_Edge& Edges (const Standard_Integer I) const;
94 
95     const TopoDS_Edge& OffsetEdges (const Standard_Integer I) const;
96 
97   //! stores if the start of a set of edges starts on a
98   //! section of free border or forms  a closed contour
99     void SetFirstStatus (const ChFiDS_State S);
100 
101   //! stores if the end of a set of edges starts on a
102   //! section of free border or forms  a closed contour
103     void SetLastStatus (const ChFiDS_State S);
104 
105   Standard_EXPORT virtual void AppendElSpine (const Handle(ChFiDS_ElSpine)& Els);
106 
107   Standard_EXPORT virtual void AppendOffsetElSpine (const Handle(ChFiDS_ElSpine)& Els);
108 
109   Standard_EXPORT Handle(ChFiDS_ElSpine) ElSpine (const Standard_Integer IE) const;
110 
111   Standard_EXPORT Handle(ChFiDS_ElSpine) ElSpine (const TopoDS_Edge& E) const;
112 
113   Standard_EXPORT Handle(ChFiDS_ElSpine) ElSpine (const Standard_Real W) const;
114 
115   Standard_EXPORT ChFiDS_ListOfHElSpine& ChangeElSpines();
116 
117   Standard_EXPORT ChFiDS_ListOfHElSpine& ChangeOffsetElSpines();
118 
119   Standard_EXPORT virtual void Reset (const Standard_Boolean AllData = Standard_False);
120 
121   Standard_EXPORT Standard_Boolean SplitDone() const;
122 
123   Standard_EXPORT void SplitDone (const Standard_Boolean B);
124 
125   //! prepare the guideline depending on the edges that
126   //! are elementary arks (take parameters from
127   //! a single curvilinear abscissa); to be able to call
128   //! methods on the geometry (first,last,value,d1,d2)
129   //! it is necessary to start with preparation otherwise an
130   //! exception will be raised
131   Standard_EXPORT void Load();
132 
133   Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const;
134 
135   Standard_EXPORT Standard_Boolean IsClosed() const;
136 
137   Standard_EXPORT Standard_Real FirstParameter() const;
138 
139   Standard_EXPORT Standard_Real LastParameter() const;
140 
141   Standard_EXPORT void SetFirstParameter (const Standard_Real Par);
142 
143   Standard_EXPORT void SetLastParameter (const Standard_Real Par);
144 
145   //! gives the total length of all arcs before the
146   //! number IndexSp
147   Standard_EXPORT Standard_Real FirstParameter (const Standard_Integer IndexSpine) const;
148 
149   //! gives the total length till the ark with number
150   //! IndexSpine (inclus)
151   Standard_EXPORT Standard_Real LastParameter (const Standard_Integer IndexSpine) const;
152 
153   //! gives the length of ark with number IndexSp
154   Standard_EXPORT Standard_Real Length (const Standard_Integer IndexSpine) const;
155 
156   Standard_EXPORT Standard_Boolean IsPeriodic() const;
157 
158   Standard_EXPORT Standard_Real Period() const;
159 
160   Standard_EXPORT Standard_Real Absc (const Standard_Real U);
161 
162   Standard_EXPORT Standard_Real Absc (const Standard_Real U, const Standard_Integer I);
163 
164   Standard_EXPORT void Parameter (const Standard_Real AbsC, Standard_Real& U, const Standard_Boolean Oriented = Standard_True);
165 
166   Standard_EXPORT void Parameter (const Standard_Integer Index, const Standard_Real AbsC, Standard_Real& U, const Standard_Boolean Oriented = Standard_True);
167 
168   Standard_EXPORT gp_Pnt Value (const Standard_Real AbsC);
169 
170   Standard_EXPORT void D0 (const Standard_Real AbsC, gp_Pnt& P);
171 
172   Standard_EXPORT void D1 (const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1);
173 
174   Standard_EXPORT void D2 (const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2);
175 
176   Standard_EXPORT void SetCurrent (const Standard_Integer Index);
177 
178   //! sets the current curve and returns it
179   Standard_EXPORT const BRepAdaptor_Curve& CurrentElementarySpine (const Standard_Integer Index);
180 
181     Standard_Integer CurrentIndexOfElementarySpine() const;
182 
183   Standard_EXPORT GeomAbs_CurveType GetType() const;
184 
185   Standard_EXPORT gp_Lin Line() const;
186 
187   Standard_EXPORT gp_Circ Circle() const;
188 
189   //! returns if the set of edges starts on a free boundary
190   //! or if the first vertex is a breakpoint or if the set is
191   //! closed
192     ChFiDS_State FirstStatus() const;
193 
194   //! returns the state at the end of the set
195     ChFiDS_State LastStatus() const;
196 
197     ChFiDS_State Status (const Standard_Boolean IsFirst) const;
198 
199   //! returns the type of concavity in the connection
200     ChFiDS_TypeOfConcavity GetTypeOfConcavity() const;
201 
202     void SetStatus (const ChFiDS_State S, const Standard_Boolean IsFirst);
203 
204   //! sets the type of concavity in the connection
205     void SetTypeOfConcavity (const ChFiDS_TypeOfConcavity theType);
206 
207   //! returns   if the  set  of  edges starts (or   end) on
208   //! Tangency point.
209     Standard_Boolean IsTangencyExtremity (const Standard_Boolean IsFirst) const;
210 
211     void SetTangencyExtremity (const Standard_Boolean IsTangency, const Standard_Boolean IsFirst);
212 
213   Standard_EXPORT Standard_Real Absc (const TopoDS_Vertex& V) const;
214 
215   Standard_EXPORT TopoDS_Vertex FirstVertex() const;
216 
217   Standard_EXPORT TopoDS_Vertex LastVertex() const;
218 
219   Standard_EXPORT void SetFirstTgt (const Standard_Real W);
220 
221   Standard_EXPORT void SetLastTgt (const Standard_Real W);
222 
223   Standard_EXPORT Standard_Boolean HasFirstTgt() const;
224 
225   Standard_EXPORT Standard_Boolean HasLastTgt() const;
226 
227   //! set a parameter reference for the approx.
228   Standard_EXPORT void SetReference (const Standard_Real W);
229 
230   //! set  a  parameter  reference  for  the approx,  at the
231   //! middle  of edge I.
232   Standard_EXPORT void SetReference (const Standard_Integer I);
233 
234   Standard_EXPORT Standard_Integer Index (const Standard_Real W, const Standard_Boolean Forward = Standard_True) const;
235 
236   Standard_EXPORT Standard_Integer Index (const TopoDS_Edge& E) const;
237 
238   Standard_EXPORT void UnsetReference();
239 
240   Standard_EXPORT void SetErrorStatus (const ChFiDS_ErrorStatus state);
241 
242   Standard_EXPORT ChFiDS_ErrorStatus ErrorStatus() const;
243 
244   //! Return the mode of chamfers used
245   Standard_EXPORT ChFiDS_ChamfMode Mode() const;
246 
247 
248 
249   DEFINE_STANDARD_RTTIEXT(ChFiDS_Spine,Standard_Transient)
250 
251 protected:
252 
253 
254   Standard_Boolean splitdone;
255   ChFiDS_ListOfHElSpine elspines;
256   ChFiDS_ListOfHElSpine offset_elspines;
257   ChFiDS_ChamfMode   myMode;
258 
259 
260 private:
261 
262 
263   Standard_EXPORT void Prepare (Standard_Real& L, Standard_Integer& Index) const;
264 
265   BRepAdaptor_Curve myCurve;
266   BRepAdaptor_Curve myOffsetCurve;
267   Standard_Integer indexofcurve;
268   ChFiDS_TypeOfConcavity myTypeOfConcavity;
269   ChFiDS_State firstState;
270   ChFiDS_State lastState;
271   TopTools_SequenceOfShape spine;
272   TopTools_SequenceOfShape offsetspine;
273   Handle(TColStd_HArray1OfReal) abscissa;
274   Handle(TColStd_HArray1OfReal) offset_abscissa;
275   Standard_Real tolesp;
276   Standard_Real firstparam;
277   Standard_Real lastparam;
278   Standard_Boolean firstprolon;
279   Standard_Boolean lastprolon;
280   Standard_Boolean firstistgt;
281   Standard_Boolean lastistgt;
282   Standard_Real firsttgtpar;
283   Standard_Real lasttgtpar;
284   Standard_Boolean hasfirsttgt;
285   Standard_Boolean haslasttgt;
286   gp_Pnt firstori;
287   gp_Pnt lastori;
288   gp_Vec firsttgt;
289   gp_Vec lasttgt;
290   Standard_Real valref;
291   Standard_Boolean hasref;
292   ChFiDS_ErrorStatus errorstate;
293 
294 
295 };
296 
297 
298 #include <ChFiDS_Spine.lxx>
299 
300 
301 
302 
303 
304 #endif // _ChFiDS_Spine_HeaderFile
305