00137 {
00138
Primitive *p = NULL;
00139
if( !attr.isNull() )
00140 {
00141
if(attr.tagName() ==
"segment" )
00142 {
00143
Point3D *a =
new Point3D( atof(attr.attribute(
"Ax",
"" )),atof(attr.attribute(
"Ay",
"" )));
00144 Point3D *b =
new Point3D( atof(attr.attribute(
"Bx",
"" )),atof(attr.attribute(
"By",
"" )));
00145 p=
new Segment(a,b);
00146 }
00147
00148
if(attr.tagName() ==
"cercle" )
00149 {
00150 Point3D *a =
new Point3D( atof(attr.attribute(
"Ax",
"" )),atof(attr.attribute(
"Ay",
"" )));
00151
00152 Point3D *b =
new Point3D( atof(attr.attribute(
"Bx",
"" )),atof(attr.attribute(
"By",
"" )));
00153 p =
new Circle(a,b);
00154 }
00155
00156
if(attr.tagName() ==
"bezier" )
00157 {
00158
Bezier *courbeB =
new Bezier();
00159 string attrName=
"P0x";
00160
double Px;
00161
double Py;
00162 Point3D *ctrlPoint;
00163
int numPoint = 0;
00164
while(attr.hasAttribute(attrName))
00165 {
00166 Px = atof(attr.attribute( attrName,
"" ));
00167
char snumPoint[256]=
"";
00168 sprintf(snumPoint,
"%d",numPoint);
00169 string temp = (string)snumPoint;
00170 attrName=
"P"+temp+
"y";
00171 Py = atof(attr.attribute( attrName,
"" ));
00172 ctrlPoint =
new Point3D(Px, Py, 0.0);
00173 courbeB->
addPoint(ctrlPoint);
00174 numPoint++;
00175
char snumPoint2[256]=
"";
00176 sprintf(snumPoint2,
"%d",numPoint);
00177 string temp2 = (string)snumPoint2;
00178 attrName=
"P"+temp2+
"x";
00179 }
00180
00181 p=courbeB;
00182 }
00183
00184
if(attr.tagName() ==
"bspline" )
00185 {
00186
Bspline *courbeB =
new Bspline();
00187 string attrName=
"P0x";
00188
double Px;
00189
double Py;
00190 Point3D *ctrlPoint;
00191
int numPoint = 0;
00192
while(attr.hasAttribute(attrName))
00193 {
00194 Px = atof(attr.attribute( attrName,
"" ));
00195
char snumPoint[256]=
"";
00196 sprintf(snumPoint,
"%d",numPoint);
00197 string temp = (string)snumPoint;
00198 attrName=
"P"+temp+
"y";
00199 Py = atof(attr.attribute( attrName,
"" ));
00200 ctrlPoint =
new Point3D(Px, Py, 0.0);
00201 courbeB->
addPoint(ctrlPoint);
00202 numPoint++;
00203
char snumPoint2[256]=
"";
00204 sprintf(snumPoint2,
"%d",numPoint);
00205 string temp2 = (string)snumPoint2;
00206 attrName=
"P"+temp2+
"x";
00207 }
00208
00209 p=courbeB;
00210 }
00211
00212 }
00213
return p;
00214 }