summaryrefslogtreecommitdiff
path: root/inc/Blend_CSWalking_3.gxx
blob: e70cb8e9342ee7f202eb6ab2138e556419d3c0d6 (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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
Standard_Boolean Blend_CSWalking::Recadre(Blend_FuncInv& FuncInv,
					  const Standard_Boolean OnFirst,
					  const math_Vector& sol,
					  math_Vector& solrst,
					  Standard_Integer& Indexsol,
					  Standard_Boolean& IsVtx,
					  TheVertex& Vtx)
     
{
  Standard_Integer nbarc;
  Standard_Boolean ok,yamin;
  Standard_Real dist,distmin,prm,pmin;
  gp_Pnt2d pt2d;
  math_Vector toler(1,4),infb(1,4),supb(1,4),valsol(1,4);

  Handle(TheTopolTool) Iter;
  TopAbs_State situ;

  yamin = Standard_False;
  nbarc = 0;
  distmin = RealLast();
  if (OnFirst) {
    pt2d.SetCoord(sol(1),sol(2));
    Iter = domain1;
  }
  else {
    pt2d.SetCoord(sol(3),sol(4));
    Iter = domain2;
  }
  Iter->Init();
  while (Iter->More()) {
    nbarc++;
    if (OnFirst) {
      ok = TheBlendTool::Project(pt2d,surf1,Iter->Value(),prm,dist);
    }
    else {
      ok = TheBlendTool::Project(pt2d,surf2,Iter->Value(),prm,dist);
    }
    if (ok) {
      if (dist<distmin) {
	yamin = Standard_True;
	distmin = dist;
	pmin = prm;
	Indexsol = nbarc;
      }
    }
    Iter->Next();
  }

  IsVtx = Standard_False;
  if (!yamin) {
    return Standard_False;
  }

  Iter->Init();
  nbarc = 1;
  while (nbarc < Indexsol) {
    nbarc++;
    Iter->Next();
  }

  TheArc thearc = Iter->Value();
  Handle(Adaptor2d_HCurve2d) thecur;
  if (OnFirst) {
    thecur = TheBlendTool::CurveOnSurf(thearc,surf1);
  }
  else {
    thecur = TheBlendTool::CurveOnSurf(thearc,surf2);
  }

  FuncInv.Set(OnFirst,thecur);
  
  FuncInv.GetTolerance(toler,tolesp);
  FuncInv.GetBounds(infb,supb);
  solrst(1) = pmin;
  solrst(2) = param;
  
  if (OnFirst) {
    solrst(3) = sol(3);
    solrst(4) = sol(4);
  }
  else {
    solrst(3) = sol(1);
    solrst(4) = sol(2);
  }
  
  math_FunctionSetRoot rsnld(FuncInv,toler,30);
  rsnld.Perform(FuncInv,solrst,infb,supb);
  


  if (!rsnld.IsDone()) {
    cout << "RSNLD not done "<< endl << endl;
    return Standard_False;
  }
      
  // On doit verifier la valeur de la fonction
  rsnld.Root(solrst);

  if (FuncInv.IsSolution(solrst,tolesp)) {

//    if (OnFirst) {
//      situ = TheTopolTool::Classify(surf2,gp_Pnt2d(solrst(3),solrst(4)),
//				    Max(toler(3),toler(4)));
//				    
//    }
//    else {
//      situ = TheTopolTool::Classify(surf1,gp_Pnt2d(solrst(3),solrst(4)),
//				    Max(toler(3),toler(4)));
//    }

    if (OnFirst) {
      situ = domain2->Classify(gp_Pnt2d(solrst(3),solrst(4)),
			       Min(toler(3),toler(4)));
				    
    }
    else {
      situ = domain1->Classify(gp_Pnt2d(solrst(3),solrst(4)),
			       Min(toler(3),toler(4)));
    }


    if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
      return Standard_False;
    }

    Iter->Initialize(thearc);
    Iter->InitVertexIterator();
    IsVtx = !Iter->MoreVertex();
    while (!IsVtx) {
      Vtx = Iter->Vertex();
      if (Abs(TheBlendTool::Parameter(Vtx,thearc)-solrst(1)) <=
	  TheBlendTool::Tolerance(Vtx,thearc)) {
	IsVtx = Standard_True;
      }
      else {
	Iter->NextVertex();
	IsVtx = !Iter->MoreVertex();
      }
    }
    if (!Iter->MoreVertex()) {
      IsVtx = Standard_False;
    }

    return Standard_True;
  } 

  return Standard_False;
}

*/


void Blend_CSWalking::Transition(const TheArc& A,
				 const Standard_Real Param,
				 IntSurf_Transition& TLine,
				 IntSurf_Transition& TArc)
{

  gp_Pnt2d p2d;
  gp_Vec2d dp2d;

  gp_Pnt pbid;
  gp_Vec d1u,d1v,normale,tgrst;

  TheArcTool::D1(A,Param,p2d,dp2d);
  TheSurfaceTool::D1(surf,p2d.X(),p2d.Y(),pbid,d1u,d1v);

  tgrst.SetLinearForm(dp2d.X(),d1u,dp2d.Y(),d1v);
  normale = d1u.Crossed(d1v);

  IntSurf::MakeTransition(previousP.TangentOnS(),tgrst,normale,TLine,TArc);

}


void Blend_CSWalking::MakeExtremity(TheExtremity& Extrem,
				    const Standard_Integer Index,
				    const Standard_Real Param,
				    const Standard_Boolean IsVtx,
				    const TheVertex& Vtx)
{

  IntSurf_Transition Tline,Tarc;
  Standard_Real prm,U,V;
  Standard_Integer nbarc;
  Handle(TheTopolTool) Iter;

//  Extrem.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
  previousP.ParametersOnS(U,V);
  Extrem.SetValue(previousP.PointOnS(),U,V,previousP.Parameter(),tolesp);
  Iter = domain;


  Iter->Init();
  nbarc = 1;

  if (!IsVtx) {
    while (nbarc < Index) {
      nbarc++;
      Iter->Next();
    }
    Transition(Iter->Value(),Param,Tline,Tarc);
    Extrem.AddArc(Iter->Value(),Param,Tline,Tarc);
  }

  else {

    Extrem.SetVertex(Vtx);
    while (Iter->More()) {
      TheArc arc = Iter->Value();
      if (nbarc != Index) {
	Iter->Initialize(arc);
	Iter->InitVertexIterator();
	while (Iter->MoreVertex()) {
//	  if (TheTopolTool::Identical(Vtx,Iter.Vertex())) {
	  if (Iter->Identical(Vtx,Iter->Vertex())) {
	    prm = TheBlendTool::Parameter(Vtx,arc);
	    Transition(arc,prm,Tline,Tarc);
	    Extrem.AddArc(arc,prm,Tline,Tarc);
	  }
	  Iter->NextVertex();
	}
      }
      else {
	Transition(arc,Param,Tline,Tarc);
	Extrem.AddArc(arc,Param,Tline,Tarc);
      }
      nbarc++;
      Iter->Next();
    }
  }
}