summaryrefslogtreecommitdiff
path: root/inc/Contap_ArcFunction.gxx
blob: c3e275045a00d389b02d76dd0326ae666b21d4f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>



Contap_ArcFunction::Contap_ArcFunction ():
       myMean(1.),
       myType(Contap_ContourStd),
       myDir(0.,0.,1.)
{}


void Contap_ArcFunction::Set(const TheSurface& S)
{
  mySurf = S;
  Standard_Integer i;
  Standard_Integer nbs = TheContTool::NbSamplePoints(S);
  Standard_Real U,V;
//  gp_Vec d1u,d1v;
  gp_Vec norm;
  if (nbs > 0) {
    myMean = 0.;
    for (i = 1; i <= nbs; i++) {
      TheContTool::SamplePoint(S,i,U,V);
//      TheSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
//      myMean = myMean + d1u.Crossed(d1v).Magnitude();
      TheSurfProps::Normale(S,U,V,solpt,norm);
      myMean = myMean + norm.Magnitude();
    }
    myMean = myMean / ((Standard_Real)nbs);
  }
}


Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
					    Standard_Real& F)
{
  //gp_Vec d1u,d1v;
  gp_Pnt2d pt2d(TheArcTool::Value(myArc,U));
//  TheSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
//  gp_Vec norm(d1u.Crossed(d1v));
  gp_Vec norm;
  TheSurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);

  switch (myType) {
  case Contap_ContourStd:
    {
      F = (norm.Dot(myDir))/myMean;
    }
    break;
  case Contap_ContourPrs:
    {
      F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
    }
    break;
  case Contap_DraftStd:
    {
      F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
    }
    break;
  case Contap_DraftPrs:
  default:
    {
    }
  }
  return Standard_True;
}


Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
						 Standard_Real& D)
{
  gp_Pnt2d pt2d;
  gp_Vec2d d2d;
#ifndef DEB
  Standard_Real dfu =0.,dfv =0.;
#else
  Standard_Real dfu,dfv;
#endif
//  gp_Vec d1u,d1v,d2u,d2v,d2uv;
  TheArcTool::D1(myArc,U,pt2d,d2d);
//  TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
  gp_Vec norm,dnu,dnv;
  TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);

  switch (myType) {
  case Contap_ContourStd:
    {
//      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
//      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
      dfu = (dnu.Dot(myDir))/myMean;
      dfv = (dnv.Dot(myDir))/myMean;
    }
    break;
  case Contap_ContourPrs:
    {
      gp_Vec Ep(myEye,solpt);
//      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
//      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
      dfu = (dnu.Dot(Ep))/myMean;
      dfv = (dnv.Dot(Ep))/myMean;
    }
    break;
  case Contap_DraftStd:
    {
/*
      gp_Vec norm(d1u.Crossed(d1v).Normalized());
      gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
      dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
      dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
      dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
      norm.Normalized();
      dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
      dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
    }
    break;
  case Contap_DraftPrs:
  default:
    {
    }
  }
  D = d2d.X()*dfu + d2d.Y()*dfv;
  return Standard_True;
}

Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
					     Standard_Real& F,
					     Standard_Real& D)
{
  gp_Pnt2d pt2d;
  gp_Vec2d d2d;
#ifndef DEB
  Standard_Real dfu =0.,dfv =0.;
#else
  Standard_Real dfu,dfv;
#endif
// gp_Vec d1u,d1v,d2u,d2v,d2uv;
  TheArcTool::D1(myArc,U,pt2d,d2d);
//  TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
//  gp_Vec norm(d1u.Crossed(d1v));
  gp_Vec norm,dnu,dnv;
  TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);

  switch (myType) {
  case Contap_ContourStd:
    {
      F   = (norm.Dot(myDir))/myMean;
//      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
//      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
      dfu = (dnu.Dot(myDir))/myMean;
      dfv = (dnv.Dot(myDir))/myMean;
    }
    break;
  case Contap_ContourPrs:
    {
      gp_Vec Ep(myEye,solpt);
      F   = (norm.Dot(Ep))/myMean;
//      dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
//      dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
      dfu = (dnu.Dot(Ep))/myMean;
      dfv = (dnv.Dot(Ep))/myMean;
    }
    break;
  case Contap_DraftStd:
    {
      F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
      norm.Normalize();
/*
      gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
      dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
      dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
      dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
      dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
      dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
    }
    break;
  case Contap_DraftPrs:
  default:
    {
    }
  }

  D = d2d.X()*dfu + d2d.Y()*dfv;
  return Standard_True;
}

Standard_Integer Contap_ArcFunction::GetStateNumber ()
{
  seqpt.Append(solpt);
  return seqpt.Length();
}

Standard_Integer Contap_ArcFunction::NbSamples () const
{
  return Max(Max(TheContTool::NbSamplesU(mySurf,0.,0.),
		 TheContTool::NbSamplesV(mySurf,0.,0.)),
	     TheContTool::NbSamplesOnArc(myArc));
}

//modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
//=======================================================================
//function : Quadric
//purpose  : returns empty Quadric
//=======================================================================
  const IntSurf_Quadric& Contap_ArcFunction::Quadric() const 
{ 
  return(myQuad);
}
//modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t