Developer documentation | Axl-2.5.1

axlToMesh.cpp
Go to the documentation of this file.
1 /* axlToMesh.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2012, Anais Ducoffe, INRIA.
5  */
6 
7 /* Comment:
8  */
9 
10 /* Change log:
11  *
12  */
13 #include "axlToMesh.h"
16 #include <axlCore/axlMesh.h>
17 
18 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
19 
23 
24 class axlToMeshPrivate{
25 
26 public :
27  //inputs
28  QVector<axlAbstractData *> input;
29  //output
30  QVector<axlAbstractData *> output;
31 };
32 
36 axlToMesh::axlToMesh(QObject *parent) : axlAbstractProcess(), d(new axlToMeshPrivate){
37 
38 }
39 
41  delete d;
42  d= NULL;
43 }
44 
45 
46 axlAbstractData * axlToMesh::getInput(int channel) const{
47  if(channel < d->input.size())
48  return d->input.at(channel);
49  else {
50  qDebug()<< "You are trying to acces an input that is not exit";
51  return nullptr;
52  }
53 }
54 
55 dtkAbstractData *axlToMesh::output(int channel){
56  if(channel < d->output.size()){
57  return d->output.at(channel);
58  }
59  else
60  qDebug()<< "You are trying to acces an output that is not exit";
61  return NULL;
62 }
63 
64 dtkAbstractData *axlToMesh::output(void){
65 
66  return d->output.at(0);
67 }
68 
69 
70 void axlToMesh::setInput(dtkAbstractData *newData, int channel)
71 {
72 // qDebug()<<"-- set input"<<channel;
73 
74  // TO DO : Be careful we don't have choice their for the resize ... we need more method on dtkAbstractProcess
75 // if(channel >= d->input.size())
76 // d->input.resize(channel + 1);
77 
78 
79  if(axlAbstractData *axlData = dynamic_cast<axlAbstractData *>(newData)){
80 // if(channel < d->input.size()) {
81 // d->input[channel] = axlData;
82 // } else {
83  d->input.push_back(axlData);
84 // }
85  }
86 }
87 
88 //void axlToMesh::setInput(dtkAbstractData *newData)
89 //{
90 // if(axlAbstractData *axlData = dynamic_cast<axlAbstractData *>(newData)){
91 // d->input.push_back(axlData);
92 // }
93 // else
94 // qDebug()<< "You are trying to set an input that is not exit";
95 
96 //}
97 
98 
100 
101  return d->output.size();
102 }
103 
104 
106 {
107  //TO DO: Because setInput method is not perfect, We cannot assert that all inputs are correctly set.
108 // qDebug() << "-- axlToMesh::update" <<d->input.size();
109  for(int i = 0 ; i < d->input.size() ; i++)
110  {
111  axlAbstractData *data = d->input.at(i);
112 // qDebug() << Q_FUNC_INFO << "data input type "<< i << data->identifier()+"Converter";
113  axlAbstractDataConverter *converter = dynamic_cast<axlAbstractDataConverter *>(dtkAbstractDataFactory::instance()->converter(data->identifier()+"Converter"));
114 
115  if(converter)
116  {
117 // qDebug() << Q_FUNC_INFO << "converter type "<< converter->identifier();
118  converter->setData(data);
119  axlMesh *currentMesh = converter->toMesh();
120  d->output.push_back(currentMesh);
121  dtkWarn()<<"Mesh"<< currentMesh->vertex_count() << currentMesh->edge_count() << currentMesh->face_count();
122  }
123  else{
124  qDebug()<< "Cannot find converter for : "<< d->input[i]->identifier();
125  return 0;
126  }
127  }
128 
129  dtkWarn()<<"axlConvertToMesh::update :" <<d->output.size() << "data has been converted sucessfully";
130 
131  foreach(axlAbstractData *data, d->output) {
132  emit dataInserted(data);
133  }
134 
135 
136  return 1;
137 }
138 
139 QString axlToMesh::description(void) const{
140  return "Convert all Input selected Data to axlMesh. Only data with converter will be converted";
141 }
142 
143 
144 QString axlToMesh::identifier(void) const{
145  return "axlToMesh";
146 }
147 
148 dtkAbstractProcess *createaxlToMeshProcess(void){
149  return new axlToMesh;
150 }
151 
152 // /////////////////////////////////////////////////////////////////
153 // axlToMesh documentation
154 // /////////////////////////////////////////////////////////////////
155 
axlToMesh(QObject *parent=0)
Definition: axlToMesh.cpp:36
int face_count(void) const
Definition: axlMesh.cpp:138
QString description(void) const
Definition: axlToMesh.cpp:139
int channelCount(void)
Definition: axlToMesh.cpp:99
~axlToMesh(void)
Definition: axlToMesh.cpp:40
void dataInserted(axlAbstractData *data)
int edge_count(void) const
Definition: axlMesh.cpp:143
axlAbstractData * getInput(int channel) const
Definition: axlToMesh.cpp:46
virtual int update(void)
Definition: axlToMesh.cpp:105
axlToMesh is a process that allow you to convert data to mesh.
Definition: axlToMesh.h:27
void setInput(dtkAbstractData *newData, int channel=0)
Definition: axlToMesh.cpp:70
QString identifier(void) const
Definition: axlToMesh.cpp:144
dtkAbstractData * output(void)
Definition: axlToMesh.cpp:64
virtual axlMesh * toMesh(void)
Mesh conversion.
int vertex_count(void) const
Definition: axlMesh.cpp:122
Class axlAbstractData defines an API for all type of axel data.
dtkAbstractProcess * createaxlToMeshProcess(void)
Definition: axlToMesh.cpp:148
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41