70 void recursFillPrimitiveArray(vector<PtrPrimitive>&)
const;
84 unsigned int N = primitive_tab.size()/200 +1;
87 vector<PtrPrimitive> segments_and_points;
89 for(
unsigned int i=0;i<primitive_tab.size();++i,++nbinserted)
91 if((P = dynamic_cast<Polygone *>(primitive_tab[i])) != NULL)
94 segments_and_points.push_back(primitive_tab[i]);
97 vparams.
progress(nbinserted/(
float)primitive_tab.size(), QGLViewer::tr(
"BSP Construction"));
105 for(
unsigned int j=0;j<segments_and_points.size();++j,++nbinserted)
107 if((S = dynamic_cast<Segment *>(segments_and_points[j])) != NULL)
109 else if((p = dynamic_cast<Point *>(segments_and_points[j])) != NULL)
113 vparams.
progress(nbinserted/(
float)primitive_tab.size(), QGLViewer::tr(
"BSP Construction"));
118 primitive_tab.resize(0);
130 void recursFillPrimitiveArray(vector<PtrPrimitive>&)
const;
134 void insert(
Point *);
152 int Classify(
Point *);
154 void initEquation(
const Polygone *P,
double & a,
double & b,
double & c,
double & d);
173 if(_root != NULL) _root->recursFillPrimitiveArray(tab);
175 for(
unsigned int i=0;i<_points.size();++i) tab.push_back(_points[i]);
176 for(
unsigned int j=0;j<_segments.size();++j) tab.push_back(_segments[j]);
228 double t = fabs(Z1/(Z2 - Z1));
230 if((t < 0.0)||(t > 1.0))
232 if(t > 1.0) t = 0.999;
233 if(t < 0.0) t = 0.001;
304 static int Signs[100];
305 static double Zvals[100];
336 if(Smin > Signs[i]) Smin = Signs[i];
337 if(Smax < Signs[i]) Smax = Signs[i];
342 if((Smin == 0)&&(Smax == 0))
367 if((Smin == -1)&&(Smax == 0))
374 if((Smin == 0)&&(Smax == 1))
383 vector<Feedback3DColor> Ps;
384 vector<Feedback3DColor> Ms;
397 if(Signs[(j+1)%n] == 0)
402 if((nZero > 2)||(nconsZero > 0))
413 while(Signs[dep] == 0) dep++;
415 int prev_sign = Signs[dep];
417 for(
int k=1;k<=n;k++)
419 int sign = Signs[(k+dep)%n];
421 if(sign == prev_sign)
429 else if(sign == -prev_sign)
434 double Z1 = Zvals[(k+dep-1)%n];
435 double Z2 = Zvals[(k+dep)%n];
437 double t = fabs(Z1/(Z2 - Z1));
439 if((t < 0.0)||(t > 1.0))
441 if(t > 1.0) t = 0.999;
442 if(t < 0.0) t = 0.001;
447 Ps.push_back(newVertex);
448 Ms.push_back(newVertex);
462 Ps.push_back(newVertex);
463 Ms.push_back(newVertex);
465 prev_sign = -prev_sign;
491 Polygone *side_plus = NULL, *side_moins = NULL;
495 Classify(P,side_moins,side_plus);
499 if(side_plus != NULL) {
500 if(fils_plus == NULL)
501 fils_plus =
new BSPNode(side_plus);
503 fils_plus->insert(side_plus);
506 if(side_moins != NULL) {
507 if(fils_moins == NULL)
508 fils_moins =
new BSPNode(side_moins);
510 fils_moins->insert(side_moins);
516 if(fils_plus != NULL)
517 fils_plus->recursFillPrimitiveArray(primitive_tab);
519 for(
unsigned int i=0;i<seg_plus.size();++i)
520 primitive_tab.push_back(seg_plus[i]);
521 for(
unsigned int j=0;j<pts_plus.size();++j)
522 primitive_tab.push_back(pts_plus[j]);
525 primitive_tab.push_back(polygone);
527 if(fils_moins != NULL)
528 fils_moins->recursFillPrimitiveArray(primitive_tab);
530 for(
unsigned int i2=0;i2<seg_moins.size();++i2)
531 primitive_tab.push_back(seg_moins[i2]);
532 for(
unsigned int j2=0;j2<pts_moins.size();++j2)
533 primitive_tab.push_back(pts_moins[j2]);
538 int res = Classify(P);
541 if(fils_moins == NULL)
542 pts_moins.push_back(P);
544 fils_moins->insert(P);
548 if(fils_plus == NULL)
549 pts_plus.push_back(P);
551 fils_plus->insert(P);
557 Segment *side_plus = NULL, *side_moins = NULL;
559 Classify(S,side_moins,side_plus);
561 if(side_plus != NULL) {
562 if(fils_plus == NULL)
563 seg_plus.push_back(side_plus);
565 fils_plus->insert(side_plus);
568 if(side_moins != NULL) {
569 if(fils_moins == NULL)
570 seg_moins.push_back(side_moins);
572 fils_moins->insert(side_moins);
580 initEquation(P,a,b,c,d);
591 while((j < P->nbVertices())&& n.
infNorm() <= 0.00001)
608 if(ind < P->nbVertices())
virtual void sortPrimitives(std::vector< PtrPrimitive > &, VRenderParams &)
virtual unsigned int nbVertices() const
void Classify(Polygone *, Polygone *&, Polygone *&)
vector< Point * > pts_moins
void recursFillPrimitiveArray(vector< PtrPrimitive > &) const
void initEquation(const Polygone *P, double &a, double &b, double &c, double &d)
vector< Segment * > seg_moins
virtual const Feedback3DColor & sommet3DColor(int) const
void recursFillPrimitiveArray(vector< PtrPrimitive > &) const
void progress(float, const QString &)
virtual const Vector3 & vertex(int) const
vector< Segment * > _segments
vector< Point * > pts_plus
double infNorm() const
Infinite norm.
virtual const Feedback3DColor & sommet3DColor(int) const
vector< Point * > _points
vector< Segment * > seg_plus
static unsigned int ind(unsigned int i, unsigned int j)
virtual const Feedback3DColor & sommet3DColor(int i) const
double norm() const
Norm.