10 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
13 class axlSurfaceRevolutionParametricConverterPrivate
33 return "Converter from axlSurfaceRevolutionParametric to axlMesh";
38 return "axlSurfaceRevolutionParametricConverter";
43 return QStringList() <<
"axlSurfaceRevolutionParametricConverter" <<
"axlSurfaceRevolutionParametric";
55 axlPoint *axlSurfaceRevolutionParametricConverter::rotatePoint(
double a,
double b,
double c,
double x,
double y,
double z,
double u,
double v,
double w,
double alpha)
58 qreal a1 = (a*(qPow(v,2)+qPow(w,2))-u*(b*v+c*w-u*x-v*y-w*z))*(1-qCos(alpha))+x*qCos(alpha)+(-c*v+b*w-w*y+v*z)*qSin(alpha);
59 qreal a2 = (b*(qPow(u,2)+qPow(w,2))-v*(a*u+c*w-u*x-v*y-w*z))*(1-qCos(alpha))+y*qCos(alpha)+(c*u-a*w+w*x-u*z)*qSin(alpha);
60 qreal a3 = (c*(qPow(u,2)+qPow(v,2))-w*(a*u+b*v-u*x-v*y-w*z))*(1-qCos(alpha))+z*qCos(alpha)+(-b*u+a*v-v*x+u*y)*qSin(alpha);
67 return rotatePoint(a.
x(),a.
y(),a.
z(),x.
x(),x.
y(),x.
z(),u.
x(),u.
y(),u.
z(),alpha);
74 return RotatePoint(*(line->
firstPoint()),*x,dir,alpha);
83 double axlSurfaceRevolutionParametricConverter::angleOfArc(
const axlCircleArc *arc)
120 QList<axlPoint *> axlSurfaceRevolutionParametricConverter::Sampling(
axlAbstractCurve *curve)
122 QList<axlPoint *> result;
124 if(
axlLine *line = dynamic_cast<axlLine *>(curve))
129 else if(
axlCircleArc *ca = dynamic_cast<axlCircleArc *>(curve))
131 double step = angleOfArc(ca)/40;
140 for(
int i = 0; i<=40;i++)
143 result.append(RotatePoint(
new axlLine(ca->center(),ca->center()+normalCCWArc(*ca)),inter,i*step));
148 double step = (curvepara->endParam()-curvepara->startParam())/40;
149 for(
int i = 0;i<41;i++)
151 result.append(
new axlPoint(curvepara->eval(curvepara->startParam()+i*step)));
165 double step = (d->data->getEndAngle()-d->data->getStartAngle())/NoS;
166 qDebug()<<d->data->getCurve()->description();
167 QList<axlPoint *> samples = Sampling(d->data->getCurve());
169 for(
int i = 0;i<samples.size();i++)
171 for(
int j = 0;j<NoS+1;j++)
173 output->
push_back_vertex(RotatePoint(d->data->getAxe(),samples.value(i),d->data->getStartAngle()+j*step));
177 for(
int i = 0; i < samples.size()-1; i++)
179 for(
int j= 0; j <NoS; j++)
181 i1 = i * (NoS+1) + j;
184 QVector<int> firstTriangle;
185 QVector<int> secondTriamgle;
187 firstTriangle.push_back(i1);
188 firstTriangle.push_back(i1 + 1);
189 firstTriangle.push_back(i2);
191 secondTriamgle.push_back(i2);
192 secondTriamgle.push_back(i1 + 1);
193 secondTriamgle.push_back(i2 + 1);
203 for(
int i = 0; i < NoS+1 ; i++)
209 for(
int j = 0; j < samples.size() ; j++)
211 ed1<<(NoS+j*(NoS+1));
216 for(
int i = 0; i < NoS+1 ; i++)
218 ed2<<(samples.size()-2)*(NoS+1) + (NoS-i);
222 for(
int j = 0; j < samples.size() ; j++)
224 ed3<<(samples.size()-1-j)*(NoS+1);
bool isDirect(void) const
Class axlPoint defines 3D points.
virtual QString description(void) const
Class axlLine defines 3D lines.
QStringList fromTypes(void) const
bool vertex_show(void) const
axlPoint point1(void) const
void push_back_edge(int, int)
void setData(dtkAbstractData *data)
axlPoint * secondPoint(void) const
Returns second point of the line.
QVector< int > Edge
An edge is represented by a sequence of vertices.
axlPoint center(void) const
QString toType(void) const
axlPoint * firstPoint(void) const
Returns first point of the line.
dtkAbstractDataConverter * createaxlSurfaceRevolutionParametricConverter(void)
~axlSurfaceRevolutionParametricConverter(void)
QString description(void) const
axlPoint point2(void) const
static double dotProduct(const axlPoint &lhs, const axlPoint &rhs)
bool face_show(void) const
axlPoint calculateNormal(void) const
static bool registered(void)
void push_back_face(const Face &face)
axlPoint normal(void) const
static axlPoint crossProduct(const axlPoint &lhs, const axlPoint &rhs)
Returns the cross product between lhs (coords) and rhs (coords).
QString identifier(void) const
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
Class axlMesh defines a piecewise-linear 3D object.
void push_back_vertex(const double &x, const double &y, const double &z)
Add a new vertex to the mesh.
axlSurfaceRevolutionParametricConverter(void)