0026595: Lost some comments in OCCT-code after cdl elimination
[occt.git] / src / Contap / Contap_ArcFunction.cxx
CommitLineData
b311480e 1// Created on: 1993-06-03
2// Created by: Jacques GOUSSARD
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
733a0e55 16
e2065c2f 17
42cf5bc1 18#include <Adaptor2d_HCurve2d.hxx>
19#include <Adaptor3d_HSurface.hxx>
20#include <Contap_ArcFunction.hxx>
e2065c2f 21#include <Contap_HContTool.hxx>
e2065c2f 22#include <Contap_HCurve2dTool.hxx>
42cf5bc1 23#include <Contap_SurfProps.hxx>
24#include <gp_Dir.hxx>
25#include <gp_Pnt.hxx>
26#include <IntSurf_Quadric.hxx>
7fd59977 27
7fd59977 28Contap_ArcFunction::Contap_ArcFunction ():
e2065c2f 29myMean(1.),
30myType(Contap_ContourStd),
31myDir(0.,0.,1.)
7fd59977 32{}
33
34
e2065c2f 35void Contap_ArcFunction::Set(const Handle(Adaptor3d_HSurface)& S)
7fd59977 36{
37 mySurf = S;
38 Standard_Integer i;
e2065c2f 39 Standard_Integer nbs = Contap_HContTool::NbSamplePoints(S);
7fd59977 40 Standard_Real U,V;
e2065c2f 41 // gp_Vec d1u,d1v;
7fd59977 42 gp_Vec norm;
43 if (nbs > 0) {
44 myMean = 0.;
45 for (i = 1; i <= nbs; i++) {
e2065c2f 46 Contap_HContTool::SamplePoint(S,i,U,V);
47 // Adaptor3d_HSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
48 // myMean = myMean + d1u.Crossed(d1v).Magnitude();
49 Contap_SurfProps::Normale(S,U,V,solpt,norm);
7fd59977 50 myMean = myMean + norm.Magnitude();
51 }
52 myMean = myMean / ((Standard_Real)nbs);
53 }
54}
55
56
57Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
e2065c2f 58 Standard_Real& F)
7fd59977 59{
60 //gp_Vec d1u,d1v;
e2065c2f 61 gp_Pnt2d pt2d(Contap_HCurve2dTool::Value(myArc,U));
62 // Adaptor3d_HSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
63 // gp_Vec norm(d1u.Crossed(d1v));
7fd59977 64 gp_Vec norm;
e2065c2f 65 Contap_SurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
7fd59977 66
67 switch (myType) {
68 case Contap_ContourStd:
69 {
70 F = (norm.Dot(myDir))/myMean;
71 }
72 break;
73 case Contap_ContourPrs:
74 {
75 F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
76 }
77 break;
78 case Contap_DraftStd:
79 {
80 F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
81 }
82 break;
83 case Contap_DraftPrs:
84 default:
85 {
86 }
87 }
88 return Standard_True;
89}
90
91
92Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
e2065c2f 93 Standard_Real& D)
7fd59977 94{
95 gp_Pnt2d pt2d;
96 gp_Vec2d d2d;
7fd59977 97 Standard_Real dfu =0.,dfv =0.;
e2065c2f 98 // gp_Vec d1u,d1v,d2u,d2v,d2uv;
99 Contap_HCurve2dTool::D1(myArc,U,pt2d,d2d);
100 // Adaptor3d_HSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
7fd59977 101 gp_Vec norm,dnu,dnv;
e2065c2f 102 Contap_SurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
7fd59977 103
104 switch (myType) {
105 case Contap_ContourStd:
106 {
e2065c2f 107 // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
108 // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
7fd59977 109 dfu = (dnu.Dot(myDir))/myMean;
110 dfv = (dnv.Dot(myDir))/myMean;
111 }
112 break;
113 case Contap_ContourPrs:
114 {
115 gp_Vec Ep(myEye,solpt);
e2065c2f 116 // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
117 // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
7fd59977 118 dfu = (dnu.Dot(Ep))/myMean;
119 dfv = (dnv.Dot(Ep))/myMean;
120 }
121 break;
122 case Contap_DraftStd:
123 {
e2065c2f 124 /*
7fd59977 125 gp_Vec norm(d1u.Crossed(d1v).Normalized());
126 gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
127 dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
128 dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
129 dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
e2065c2f 130 */
7fd59977 131 norm.Normalized();
132 dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
133 dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
134 }
135 break;
136 case Contap_DraftPrs:
137 default:
138 {
139 }
140 }
141 D = d2d.X()*dfu + d2d.Y()*dfv;
142 return Standard_True;
143}
144
145Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
e2065c2f 146 Standard_Real& F,
147 Standard_Real& D)
7fd59977 148{
149 gp_Pnt2d pt2d;
150 gp_Vec2d d2d;
7fd59977 151 Standard_Real dfu =0.,dfv =0.;
e2065c2f 152 // gp_Vec d1u,d1v,d2u,d2v,d2uv;
153 Contap_HCurve2dTool::D1(myArc,U,pt2d,d2d);
154 // Adaptor3d_HSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
155 // gp_Vec norm(d1u.Crossed(d1v));
7fd59977 156 gp_Vec norm,dnu,dnv;
e2065c2f 157 Contap_SurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
7fd59977 158
159 switch (myType) {
160 case Contap_ContourStd:
161 {
162 F = (norm.Dot(myDir))/myMean;
e2065c2f 163 // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
164 // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
7fd59977 165 dfu = (dnu.Dot(myDir))/myMean;
166 dfv = (dnv.Dot(myDir))/myMean;
167 }
168 break;
169 case Contap_ContourPrs:
170 {
171 gp_Vec Ep(myEye,solpt);
172 F = (norm.Dot(Ep))/myMean;
e2065c2f 173 // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
174 // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
7fd59977 175 dfu = (dnu.Dot(Ep))/myMean;
176 dfv = (dnv.Dot(Ep))/myMean;
177 }
178 break;
179 case Contap_DraftStd:
180 {
181 F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
182 norm.Normalize();
e2065c2f 183 /*
7fd59977 184 gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
185 dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
186 dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
187 dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
e2065c2f 188 */
7fd59977 189 dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
190 dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
191 }
192 break;
193 case Contap_DraftPrs:
194 default:
195 {
196 }
197 }
198
199 D = d2d.X()*dfu + d2d.Y()*dfv;
200 return Standard_True;
201}
202
203Standard_Integer Contap_ArcFunction::GetStateNumber ()
204{
205 seqpt.Append(solpt);
206 return seqpt.Length();
207}
208
209Standard_Integer Contap_ArcFunction::NbSamples () const
210{
e2065c2f 211 return Max(Max(Contap_HContTool::NbSamplesU(mySurf,0.,0.),
212 Contap_HContTool::NbSamplesV(mySurf,0.,0.)),
213 Contap_HContTool::NbSamplesOnArc(myArc));
7fd59977 214}
215
216//modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
217//=======================================================================
218//function : Quadric
219//purpose : returns empty Quadric
220//=======================================================================
e2065c2f 221const IntSurf_Quadric& Contap_ArcFunction::Quadric() const
7fd59977 222{
223 return(myQuad);
224}
225//modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t