Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Bezier Class Reference

#include <bezier.h>

Inheritance diagram for Bezier:

Primitive List of all members.

Public Member Functions

 Bezier ()
 Bezier (const vector< Point3D * > &pointsList)
 Bezier (const Bezier &bez)
 ~Bezier ()
virtual void display (QPainter &paint)
virtual void setPrimitive (QPoint &refPoint, QPoint &modifPoint)
virtual void toXML (QDomElement &elem)
vector< Point3D * > getCtrlPoints () const
void addPoint (Point3D *point)
void addPointPosI (Point3D *point, const unsigned int pos)
int nbPoints ()
double getNbSamples ()
void setNbSamples (double sample)

Public Attributes

vector< Point3D * > pointsList
vector< Point3D * > samplesPointsList
double nbSamples
int type

Detailed Description

La classe Bezier dessine des béziers cubiques.

Author:
Guitteny Fabrice

Idiart Baptiste

Le Goff Erwan


Constructor & Destructor Documentation

Bezier::Bezier  ) 
 

constructeur par défaut

00006 { 00007 type = BEZIER; 00008 nbSamples = NORMAL_SAMPLE; 00009 }

Bezier::Bezier const vector< Point3D * > &  pointsList  ) 
 

constructeur

Parameters:
pointsList liste de points de contrôle

00012 { 00013 for (unsigned int i = 0; i < ptsList.size(); i++) 00014 pointsList.push_back(ptsList[i]); 00015 type = BEZIER; 00016 nbSamples = NORMAL_SAMPLE; 00017 }

Bezier::Bezier const Bezier bez  ) 
 

constructeur par copie

Parameters:
bez bezier

00019 : Primitive(bez) 00020 { 00021 vector<Point3D *> vect = bez.pointsList; 00022 for (unsigned int i = 0; i < vect.size(); i++) 00023 pointsList.push_back(vect[i]); 00024 type = BEZIER; 00025 nbSamples = NORMAL_SAMPLE; 00026 }

Bezier::~Bezier  )  [inline]
 

00058 {};


Member Function Documentation

void Bezier::addPoint Point3D point  ) 
 

ajoute un point de contrôle à la liste de points de contrôle

Parameters:
point point à ajouter

00039 { 00040 pointsList.push_back(point); 00041 }

void Bezier::addPointPosI Point3D point,
const unsigned int  pos
 

ajoute un point de contrôle à une position définié de la liste de points de contrôle

Parameters:
point point à ajouter
pos position dans la liste

00045 { 00046 if (pos < pointsList.size()) // on peut insérer 00047 { 00048 vector<Point3D *> temp; 00049 for (unsigned int i = 0; i < pos; i++) 00050 temp.push_back(pointsList[i]); 00051 temp.push_back(point); 00052 for (unsigned int i = pos + 1; i <= pointsList.size(); i++) 00053 temp.push_back(pointsList[i-1]); 00054 pointsList = temp; 00055 } 00056 }

void Bezier::display QPainter &  paint  )  [virtual]
 

méthode d'affichage d'une courbe de Bézier

Parameters:
paint affichage dans un QPainter

Implements Primitive.

00063 { 00064 00065 Point3D p0 = *pointsList[0]; 00066 Point3D p1 = *pointsList[1]; 00067 Point3D p2 = *pointsList[2]; 00068 Point3D p3 = *pointsList[3]; 00069 00070 int temp = 0; 00071 samplesPointsList.clear(); 00072 00073 // évalue la position au temps t 00074 for (float t = 0.0f; t <= 1.0f; t += 0.001) 00075 { 00076 // bases de Bernstein 00077 float B0 = (1-t)*(1-t)*(1-t); 00078 float B1 = 3*t*(1-t)*(1-t); 00079 float B2 = 3*t*t*(1-t); 00080 float B3 = t*t*t; 00081 00082 // pondération 00083 Point3D pos = p0*B0 + p1*B1 + p2*B2 + p3*B3; 00084 00085 if (temp >= nbSamples) 00086 { 00087 samplesPointsList.push_back(new Point3D(pos)); 00088 temp = 0; 00089 } 00090 temp++; 00091 paint.drawPoint((int)pos.getCoordinate(0),(int)pos.getCoordinate(1)); 00092 } 00093 }

vector< Point3D * > Bezier::getCtrlPoints  )  const
 

accesseur

Returns:
liste de points de contrôle

00032 { 00033 return pointsList; 00034 }

double Primitive::getNbSamples  )  [inline, inherited]
 

accesseur : valeur de l'échantillonage

Returns:
nombre d'échantillons

00081 {return nbSamples;}

int Primitive::nbPoints  )  [inline, inherited]
 

nombre de points définissant la primitive

00073 {return pointsList.size();}

void Primitive::setNbSamples double  sample  )  [inline, inherited]
 

modificateur : valeur de l'échantillonage

Parameters:
sample nouvelle valeur de l'échantillonage

00087 { 00088 if (type == CIRCLE) 00089 nbSamples = sample / 3; 00090 else 00091 nbSamples = sample; 00092 }

void Bezier::setPrimitive QPoint &  refPoint,
QPoint &  modifPoint
[virtual]
 

changement des points de contrôle de la courbe de Bézier

Parameters:
refPoint point à modifier
modifPoint nouvelle valeur du point

Implements Primitive.

00100 { 00101 Point3D * p = qPointToPoint3D(refPoint); 00102 if (*p == *pointsList[0]) 00103 pointsList[0] = qPointToPoint3D(modifPoint); 00104 if (*p == *pointsList[1]) 00105 pointsList[1] = qPointToPoint3D(modifPoint); 00106 if (*p == *pointsList[2]) 00107 pointsList[2] = qPointToPoint3D(modifPoint); 00108 if (*p == *pointsList[3]) 00109 pointsList[3] = qPointToPoint3D(modifPoint); 00110 }

void Bezier::toXML QDomElement &  elem  )  [virtual]
 

ecrit la primitive dans un fichier xml

Parameters:
elem balise courante dans le fichier XML

Implements Primitive.

00116 { 00117 string nomAttr; 00118 for(int i = 0 ;i<nbPoints() ; i++) 00119 { 00120 char snumpt[256]=""; 00121 sprintf(snumpt,"%d",i); 00122 string temp = (string)snumpt; 00123 nomAttr = "P"+temp+"x"; 00124 elem.setAttribute( nomAttr, (*pointsList[i])[0]); 00125 char snumpt2[256]=""; 00126 sprintf(snumpt2,"%d",i); 00127 string temp2 = (string)snumpt2; 00128 nomAttr = "P"+temp2+"y"; 00129 elem.setAttribute( nomAttr, (*pointsList[i])[1]); 00130 } 00131 }


Member Data Documentation

double Primitive::nbSamples [inherited]
 

nombre d'échantillons

vector<Point3D*> Primitive::pointsList [inherited]
 

liste des points définissant la primitive

vector<Point3D*> Primitive::samplesPointsList [inherited]
 

liste des points pour l'échantillonage

int Primitive::type [inherited]
 

type de la primitive SEGMENT, CERCLE, BEZIER ou BSPLINE


The documentation for this class was generated from the following files:
Generated on Tue Nov 29 21:58:58 2005 for CylinderGenerator by doxygen 1.3.7