21 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
26 class axlLineConverterPrivate {
51 return "Converter from axlLineConverter to axlMesh";
55 return "axlLineConverter";
59 return QStringList() <<
"axlLineConverter" <<
"axlLine";
67 return dtkAbstractDataFactory::instance()->registerDataConverterType(
"axlLineConverter", QStringList(),
"axlMesh",
createaxlLineConverter);
81 int nbEdges = d->nbsegments;
84 axlPoint direction(d->data->secondPoint()->operator -(d->data->firstPoint()));
89 int arcIndex = d->output->push_back_new_edge();
92 if (d->startIndex == -1 && d->endIndex == -1) {
94 for (
int k = 0; k <= nbEdges; k++) {
96 double step = (length*k)/nbEdges;
98 axlPoint currPoint(d->data->firstPoint()->operator + (direction*step));
100 d->output->push_back_vertex(currPoint);
104 int nbPointsInMesh = d->output->vertex_count();
107 d->output->edgePushBack(arcIndex, nbPointsInMesh-nbEdges-1);
110 for (
int k = 0; k < nbPointsInMesh-1; k++) {
111 d->output->edgePushBack(arcIndex, k+1);
115 d->output->edgePushBack(arcIndex, nbPointsInMesh-2);
117 }
else if (d->startIndex != -1 && d->endIndex != -1) {
119 d->output->edgePushBack(arcIndex, d->startIndex);
122 for (
int k = 1; k <= nbEdges-1; k++) {
124 double step = (length*k)/nbEdges;
126 axlPoint currPoint(d->data->firstPoint()->operator +(direction*step));
128 d->output->edgePushBack(arcIndex, d->output->vertex_count());
130 d->output->push_back_vertex(currPoint);
134 d->output->edgePushBack(arcIndex, d->endIndex);
136 dtkError() <<
"Error within axlLineConverter::toMesh: one point already exists and not the other one.";
140 d->output->vertex_show() =
false;
141 d->output->normal_used() =
false;
142 d->output->color_used() =
true;
143 d->output->edge_show() =
true;
144 d->output->face_show() =
false;
145 d->output->isPlanar() =
true;
147 d->output->setColor(d->data->color());
148 d->output->setOpacity(d->data->opacity());
149 d->output->setShader(d->data->shader());
155 if(
axlLine* line = dynamic_cast<axlLine*>(data))
161 d->startIndex = index;
162 else if (channel == 1)
165 dtkWarn() <<
"axlLineConverter::setParams usage: channel must be 0 or 1.";
169 d->output =
static_cast<axlMesh*
>(output);
void setData(dtkAbstractData *data)
QString toType(void) const
Class axlPoint defines 3D points.
Class axlLine defines 3D lines.
void setPrecision(double eps)
virtual ~axlLineConverter(void)
void setOutput(axlAbstractData *output)
QString identifier(void) const
QString description(void) const
dtkAbstractDataConverter * createaxlLineConverter(void)
QStringList fromTypes(void) const
static bool registered(void)
void setParams(int channel, int index)
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
Class axlAbstractData defines an API for all type of axel data.
Class axlMesh defines a piecewise-linear 3D object.