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
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.
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.
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.
22 #include <gp_Pnt2d.hxx>
23 #include <gp_Vec2d.hxx>
25 Contap_ArcFunction::Contap_ArcFunction ():
27 myType(Contap_ContourStd),
32 void Contap_ArcFunction::Set(const TheSurface& S)
36 Standard_Integer nbs = TheContTool::NbSamplePoints(S);
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();
49 myMean = myMean / ((Standard_Real)nbs);
54 Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
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));
62 TheSurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
65 case Contap_ContourStd:
67 F = (norm.Dot(myDir))/myMean;
70 case Contap_ContourPrs:
72 F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
77 F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
89 Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
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);
99 TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
102 case Contap_ContourStd:
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;
110 case Contap_ContourPrs:
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;
119 case Contap_DraftStd:
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;
129 dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
130 dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
133 case Contap_DraftPrs:
138 D = d2d.X()*dfu + d2d.Y()*dfv;
139 return Standard_True;
142 Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
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));
154 TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
157 case Contap_ContourStd:
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;
166 case Contap_ContourPrs:
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;
176 case Contap_DraftStd:
178 F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
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;
186 dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
187 dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
190 case Contap_DraftPrs:
196 D = d2d.X()*dfu + d2d.Y()*dfv;
197 return Standard_True;
200 Standard_Integer Contap_ArcFunction::GetStateNumber ()
203 return seqpt.Length();
206 Standard_Integer Contap_ArcFunction::NbSamples () const
208 return Max(Max(TheContTool::NbSamplesU(mySurf,0.,0.),
209 TheContTool::NbSamplesV(mySurf,0.,0.)),
210 TheContTool::NbSamplesOnArc(myArc));
213 //modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
214 //=======================================================================
216 //purpose : returns empty Quadric
217 //=======================================================================
218 const IntSurf_Quadric& Contap_ArcFunction::Quadric() const
222 //modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t