0024236: Eliminate GCC compiler warning (uninitialized variables)
[occt.git] / src / Contap / Contap_ArcFunction.gxx
1 // Created on: 1993-06-03
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <gp_Pnt2d.hxx>
23 #include <gp_Vec2d.hxx>
24
25 Contap_ArcFunction::Contap_ArcFunction ():
26        myMean(1.),
27        myType(Contap_ContourStd),
28        myDir(0.,0.,1.)
29 {}
30
31
32 void Contap_ArcFunction::Set(const TheSurface& S)
33 {
34   mySurf = S;
35   Standard_Integer i;
36   Standard_Integer nbs = TheContTool::NbSamplePoints(S);
37   Standard_Real U,V;
38 //  gp_Vec d1u,d1v;
39   gp_Vec norm;
40   if (nbs > 0) {
41     myMean = 0.;
42     for (i = 1; i <= nbs; i++) {
43       TheContTool::SamplePoint(S,i,U,V);
44 //      TheSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
45 //      myMean = myMean + d1u.Crossed(d1v).Magnitude();
46       TheSurfProps::Normale(S,U,V,solpt,norm);
47       myMean = myMean + norm.Magnitude();
48     }
49     myMean = myMean / ((Standard_Real)nbs);
50   }
51 }
52
53
54 Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
55                                             Standard_Real& F)
56 {
57   //gp_Vec d1u,d1v;
58   gp_Pnt2d pt2d(TheArcTool::Value(myArc,U));
59 //  TheSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
60 //  gp_Vec norm(d1u.Crossed(d1v));
61   gp_Vec norm;
62   TheSurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
63
64   switch (myType) {
65   case Contap_ContourStd:
66     {
67       F = (norm.Dot(myDir))/myMean;
68     }
69     break;
70   case Contap_ContourPrs:
71     {
72       F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
73     }
74     break;
75   case Contap_DraftStd:
76     {
77       F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
78     }
79     break;
80   case Contap_DraftPrs:
81   default:
82     {
83     }
84   }
85   return Standard_True;
86 }
87
88
89 Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
90                                                  Standard_Real& D)
91 {
92   gp_Pnt2d pt2d;
93   gp_Vec2d d2d;
94   Standard_Real dfu =0.,dfv =0.;
95 //  gp_Vec d1u,d1v,d2u,d2v,d2uv;
96   TheArcTool::D1(myArc,U,pt2d,d2d);
97 //  TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
98   gp_Vec norm,dnu,dnv;
99   TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
100
101   switch (myType) {
102   case Contap_ContourStd:
103     {
104 //      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
105 //      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
106       dfu = (dnu.Dot(myDir))/myMean;
107       dfv = (dnv.Dot(myDir))/myMean;
108     }
109     break;
110   case Contap_ContourPrs:
111     {
112       gp_Vec Ep(myEye,solpt);
113 //      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
114 //      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
115       dfu = (dnu.Dot(Ep))/myMean;
116       dfv = (dnv.Dot(Ep))/myMean;
117     }
118     break;
119   case Contap_DraftStd:
120     {
121 /*
122       gp_Vec norm(d1u.Crossed(d1v).Normalized());
123       gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
124       dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
125       dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
126       dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
127 */
128       norm.Normalized();
129       dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
130       dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
131     }
132     break;
133   case Contap_DraftPrs:
134   default:
135     {
136     }
137   }
138   D = d2d.X()*dfu + d2d.Y()*dfv;
139   return Standard_True;
140 }
141
142 Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
143                                              Standard_Real& F,
144                                              Standard_Real& D)
145 {
146   gp_Pnt2d pt2d;
147   gp_Vec2d d2d;
148   Standard_Real dfu =0.,dfv =0.;
149 // gp_Vec d1u,d1v,d2u,d2v,d2uv;
150   TheArcTool::D1(myArc,U,pt2d,d2d);
151 //  TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
152 //  gp_Vec norm(d1u.Crossed(d1v));
153   gp_Vec norm,dnu,dnv;
154   TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
155
156   switch (myType) {
157   case Contap_ContourStd:
158     {
159       F   = (norm.Dot(myDir))/myMean;
160 //      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
161 //      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
162       dfu = (dnu.Dot(myDir))/myMean;
163       dfv = (dnv.Dot(myDir))/myMean;
164     }
165     break;
166   case Contap_ContourPrs:
167     {
168       gp_Vec Ep(myEye,solpt);
169       F   = (norm.Dot(Ep))/myMean;
170 //      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
171 //      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
172       dfu = (dnu.Dot(Ep))/myMean;
173       dfv = (dnv.Dot(Ep))/myMean;
174     }
175     break;
176   case Contap_DraftStd:
177     {
178       F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
179       norm.Normalize();
180 /*
181       gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
182       dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
183       dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
184       dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
185 */
186       dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
187       dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
188     }
189     break;
190   case Contap_DraftPrs:
191   default:
192     {
193     }
194   }
195
196   D = d2d.X()*dfu + d2d.Y()*dfv;
197   return Standard_True;
198 }
199
200 Standard_Integer Contap_ArcFunction::GetStateNumber ()
201 {
202   seqpt.Append(solpt);
203   return seqpt.Length();
204 }
205
206 Standard_Integer Contap_ArcFunction::NbSamples () const
207 {
208   return Max(Max(TheContTool::NbSamplesU(mySurf,0.,0.),
209                  TheContTool::NbSamplesV(mySurf,0.,0.)),
210              TheContTool::NbSamplesOnArc(myArc));
211 }
212
213 //modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
214 //=======================================================================
215 //function : Quadric
216 //purpose  : returns empty Quadric
217 //=======================================================================
218   const IntSurf_Quadric& Contap_ArcFunction::Quadric() const 
219
220   return(myQuad);
221 }
222 //modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t