Developer documentation | Axl-2.5.1

axlPointConverter.cpp
Go to the documentation of this file.
1 /* axlPointConverter.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5  * Created: Tue Jan 24 11:03:18 2012 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Jan 24 11:27:25 2012 (+0100)
8  * By: Julien Wintz
9  * Update #: 50
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlMesh.h"
21 #include "axlPoint.h"
22 #include "axlPointConverter.h"
23 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
24 
25 class axlPointConverterPrivate
26 {
27 public:
28  axlPoint *data;
29 };
30 
31 axlPointConverter::axlPointConverter(void) : axlAbstractDataConverter(), d(new axlPointConverterPrivate)
32 {
33  d->data = NULL;
34 }
35 
37 {
38  delete d;
39 
40  d = NULL;
41 }
42 
43 QString axlPointConverter::description(void) const
44 {
45  return "Converter from axlPointConverter to axlMesh";
46 }
47 
48 QStringList axlPointConverter::fromTypes(void) const
49 {
50  return QStringList() << "axlPointConverter" << "axlPoint";
51 }
52 
53 QString axlPointConverter::toType (void) const
54 {
55  return "axlMesh";
56 }
57 
59 {
60  return dtkAbstractDataFactory::instance()->registerDataConverterType("axlPointConverter", QStringList(), "axlMesh", createaxlPointConverter);
61 }
62 
64 {
65  if(!d->data)
66  return NULL;
67 
68  axlMesh *mesh = new axlMesh;
69 
70  mesh->push_back_vertex(d->data);
71 
72  return mesh;
73 }
74 
75 void axlPointConverter::setData(dtkAbstractData *data)
76 {
77  if(axlPoint *point = dynamic_cast<axlPoint *>(data))
78  d->data = point;
79 }
80 
81 dtkAbstractDataConverter *createaxlPointConverter(void)
82 {
83  return new axlPointConverter;
84 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
QStringList fromTypes(void) const
dtkAbstractDataConverter * createaxlPointConverter(void)
void setData(dtkAbstractData *data)
QString toType(void) const
QString description(void) const
static bool registered(void)
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41
axlMesh * toMesh(void)
void push_back_vertex(const double &x, const double &y, const double &z)
Add a new vertex to the mesh.
Definition: axlMesh.cpp:333