39 using namespace YACS::ENGINE;
40 using namespace YACS::HMI;
46 return sqrt(
double(dx*dx +dy*dy));
78 for(std::set<double>::iterator it =
_sxm.begin(); it !=
_sxm.end(); ++it)
89 for(std::set<double>::iterator it =
_sym.begin(); it !=
_sym.end(); ++it)
97 for (
int ij=0; ij <
_im*
_jm; ij++)
101 for (
int j=0; j<
_jm; j++)
103 char*
m =
new char[
_im+1];
104 for (
int i=0; i<
_im; i++)
119 QRectF bb = (item->mapToScene(item->
boundingRect())).boundingRect();
120 qreal xp = bb.right();
121 qreal yp = (bb.top() + bb.bottom())*0.5;
124 for (
int i=0;
i<
_im-1;
i++)
131 for (
int j=0; j<
_jm-1; j++)
132 if (
_ym[j+1] >= yp && yp >
_ym[j])
138 if(ifrom < 0 || jfrom < 0)
return pair<int,int>(ifrom,jfrom);
139 while (ifrom < _im && !
cost(ifrom,jfrom)) ifrom++;
141 return pair<int,int>(ifrom,jfrom);
153 QRectF bb = (item->mapToScene(item->
boundingRect())).boundingRect();
154 qreal xp = bb.right();
155 qreal yp = (bb.top() + bb.bottom())*0.5;
158 for (
int i=0;
i<
_im-1;
i++)
165 for (
int j=0; j<
_jm-1; j++)
166 if (
_ym[j+1] >= yp && yp >
_ym[j])
172 if(ifrom < 0 || jfrom < 0)
return pair<int,int>(ifrom,jfrom);
173 while (ifrom < _im && !
cost(ifrom,jfrom)) ifrom++;
175 return pair<int,int>(ifrom,jfrom);
182 QRectF bb = (item->mapToScene(item->
boundingRect())).boundingRect();
183 qreal xp = bb.left();
184 qreal yp = (bb.top() + bb.bottom())*0.5;
187 for (
int i=0;
i<
_im-1;
i++)
194 for (
int j=0; j<
_jm-1; j++)
195 if (
_ym[j+1] >= yp && yp >
_ym[j])
201 if(ito < 0 || jto < 0)
return pair<int,int>(ito,jto);
202 while (ito >0 && !
cost(ito,jto)) ito--;
204 return pair<int,int>(ito,jto);
216 QRectF bb = (item->mapToScene(item->
boundingRect())).boundingRect();
217 qreal xp = bb.left();
218 qreal yp = (bb.top() + bb.bottom())*0.5;
221 for (
int i=0;
i<
_im-1;
i++)
228 for (
int j=0; j<
_jm-1; j++)
229 if (
_ym[j+1] >= yp && yp >
_ym[j])
235 if(ito < 0 || jto < 0)
return pair<int,int>(ito,jto);
236 while (ito > 0 && !
cost(ito,jto)) ito--;
238 return pair<int,int>(ito,jto);
249 pair<Node*, Node*> outin = it->first;
252 ali.
to =
cellTo(outin.second->getInGate());
254 alist.push_back(ali);
256 <<
") to ("<<ali.
to.first<<
","<<ali.
to.second
265 map<pair<OutPort*, InPort*>,
SubjectLink*>::const_iterator it;
270 pair<OutPort*, InPort*> outin = it->first;
275 alist.push_back(ali);
277 <<
") to ("<<ali.
to.first<<
","<<ali.
to.second
285 DEBTRACE(
"LinkMatrix::getPath " << lnp.size());
288 int dim = lnp.size();
290 double coef=-0.25+rand()%101*0.005;
292 LNodePath::const_iterator it = lnp.begin();
293 for (
int k=0; k<dim; k++)
297 DEBTRACE(
"i, j: " << i <<
" " << j <<
" Xmax, Ymax: " <<
_im <<
" " <<
_jm);
303 a.
x = coef*
_xm[
i] + (1.-coef)*
_xm[i+1];
309 a.
y = coef*
_ym[j] + (1.-coef)*
_ym[j+1];
321 int dim = lnp.size();
322 LNodePath::const_iterator it = lnp.begin();
323 for (; it != lnp.end(); ++it)
347 list<AbstractSceneItem*> children = cnItem->
getChildren();
348 for (list<AbstractSceneItem*>::const_iterator it = children.begin(); it != children.end(); ++it)
366 QRectF bb = (obstacle->mapToScene(obstacle->
boundingRect())).boundingRect();
369 int imin =
_x2i[bb.left() + margin];
370 int imax =
_x2i[bb.right() - margin];
371 int jmin =
_y2j[bb.top() + margin];
372 int jmax =
_y2j[bb.bottom() - margin];
373 DEBTRACE(bb.left() <<
" " << bb.right() <<
" " << bb.top() <<
" " << bb.bottom() );
374 DEBTRACE(imin <<
" " << imax <<
" " << jmin <<
" " << jmax);
375 for (
int j=jmin; j<
jmax; j++)
384 _sxm.insert(bb.left() + margin);
385 _sxm.insert(bb.right() - margin);
386 _sym.insert(bb.top() + margin);
387 _sym.insert(bb.bottom() - margin);
394 set<double> sxmCpy =
_sxm;
395 if (sxmCpy.empty())
return;
396 set<double>::iterator itx = sxmCpy.begin();
400 for (; itx != sxmCpy.end(); ++itx)
403 int nbpas = floor((xmax -xmin)/
_pas);
407 double xpas = (xmax -xmin)/nbpas;
408 for (
int i=1;
i<nbpas;
i++)
409 _sxm.insert(xmin +
i*xpas);
415 set<double> symCpy =
_sym;
416 if (symCpy.empty())
return;
417 set<double>::iterator ity = symCpy.begin();
421 for (; ity != symCpy.end(); ++ity)
424 int nbpas = floor((ymax -ymin)/
_pas);
428 double ypas = (ymax -ymin)/nbpas;
429 for (
int i=1;
i<nbpas;
i++)
430 _sym.insert(ymin +
i*ypas);