0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IntPatch / IntPatch_ALine.hxx
1 // Created on: 1992-04-06
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-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 _IntPatch_ALine_HeaderFile
18 #define _IntPatch_ALine_HeaderFile
19
20 #include <Standard_Handle.hxx>
21
22 #include <IntAna_Curve.hxx>
23 #include <IntPatch_Line.hxx>
24 #include <IntPatch_SequenceOfPoint.hxx>
25 #include <TColStd_ListOfReal.hxx>
26
27 class IntAna_Curve;
28 class IntPatch_Point;
29 class IntPatch_ALine;
30
31 DEFINE_STANDARD_HANDLE(IntPatch_ALine, IntPatch_Line)
32
33 //! Implementation of an intersection line described by a
34 //! parametrized curve.
35 class IntPatch_ALine : public IntPatch_Line
36 {
37
38 public:
39
40   
41   //! Creates an analytic intersection line
42   //! when the transitions are In or Out.
43   Standard_EXPORT IntPatch_ALine(const IntAna_Curve& C, const Standard_Boolean Tang, const IntSurf_TypeTrans Trans1, const IntSurf_TypeTrans Trans2);
44   
45   //! Creates an analytic intersection line
46   //! when the transitions are Touch.
47   Standard_EXPORT IntPatch_ALine(const IntAna_Curve& C, const Standard_Boolean Tang, const IntSurf_Situation Situ1, const IntSurf_Situation Situ2);
48   
49   //! Creates an analytic intersection line
50   //! when the transitions are Undecided.
51   Standard_EXPORT IntPatch_ALine(const IntAna_Curve& C, const Standard_Boolean Tang);
52   
53   //! To add a vertex in the list.
54   Standard_EXPORT void AddVertex (const IntPatch_Point& Pnt);
55   
56   //! Replaces the element of range Index in the list
57   //! of points.
58     void Replace (const Standard_Integer Index, const IntPatch_Point& Pnt);
59   
60     void SetFirstPoint (const Standard_Integer IndFirst);
61   
62     void SetLastPoint (const Standard_Integer IndLast);
63   
64   //! Returns the first parameter on the intersection line.
65   //! If IsIncluded returns True, Value and D1 methods can
66   //! be call with a parameter equal to FirstParamater.
67   //! Otherwise, the parameter must be greater than
68   //! FirstParameter.
69     Standard_Real FirstParameter (Standard_Boolean& IsIncluded) const;
70   
71   //! Returns the last parameter on the intersection line.
72   //! If IsIncluded returns True, Value and D1 methods can
73   //! be call with a parameter equal to LastParamater.
74   //! Otherwise, the parameter must be less than LastParameter.
75     Standard_Real LastParameter (Standard_Boolean& IsIncluded) const;
76   
77   //! Returns the point of parameter U on the analytic
78   //! intersection line.
79     gp_Pnt Value (const Standard_Real U);
80   
81   //! Returns Standard_True when the derivative at parameter U
82   //! is defined on the analytic intersection line.
83   //! In that case, Du is the derivative.
84   //! Returns Standard_False when it is not possible to
85   //! evaluate the derivative.
86   //! In both cases, P is the point at parameter U on the
87   //! intersection.
88     Standard_Boolean D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& Du);
89   
90   //! Tries to find the parameters of the point P on the curve.
91   //! If the method returns False, the "projection" is
92   //! impossible.
93   //! If the method returns True at least one parameter has been found.
94   //! theParams is always sorted in ascending order.
95   void FindParameter(const gp_Pnt& P,
96                      TColStd_ListOfReal& theParams) const;
97   
98   //! Returns True if the line has a known First point.
99   //! This point is given by the method FirstPoint().
100     Standard_Boolean HasFirstPoint() const;
101   
102   //! Returns True if the line has a known Last point.
103   //! This point is given by the method LastPoint().
104     Standard_Boolean HasLastPoint() const;
105   
106   //! Returns the IntPoint corresponding to the FirstPoint.
107   //! An exception is raised when HasFirstPoint returns False.
108     const IntPatch_Point& FirstPoint() const;
109   
110   //! Returns the IntPoint corresponding to the LastPoint.
111   //! An exception is raised when HasLastPoint returns False.
112     const IntPatch_Point& LastPoint() const;
113   
114     Standard_Integer NbVertex() const;
115   
116   //! Returns the vertex of range Index on the line.
117     const IntPatch_Point& Vertex (const Standard_Integer Index) const;
118   
119   //! Allows modifying the vertex with index theIndex on the line.
120   IntPatch_Point& ChangeVertex(const Standard_Integer theIndex)
121   {
122     return svtx.ChangeValue(theIndex);
123   }
124
125   //! Set the parameters of all the vertex on the line.
126   //! if a vertex is already in the line,
127   //! its parameter is modified
128   //! else a new point in the line is inserted.
129   Standard_EXPORT void ComputeVertexParameters (const Standard_Real Tol);
130   
131   Standard_EXPORT const IntAna_Curve& Curve() const;
132
133
134
135
136   DEFINE_STANDARD_RTTIEXT(IntPatch_ALine,IntPatch_Line)
137
138 protected:
139
140
141
142
143 private:
144
145
146   IntAna_Curve curv;
147   Standard_Boolean fipt;
148   Standard_Boolean lapt;
149   Standard_Integer indf;
150   Standard_Integer indl;
151   IntPatch_SequenceOfPoint svtx;
152
153
154 };
155
156
157 #include <IntPatch_ALine.lxx>
158
159
160
161
162
163 #endif // _IntPatch_ALine_HeaderFile