Developer documentation | Axl-2.5.1

axlVolumeDiscreteProcessCreator.cpp
Go to the documentation of this file.
1 /* axlVolumeDiscreteProcessCreator.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
16 #include "axlVolumeDiscrete.h"
17 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
18 
20 
21 #include <vtkImageData.h>
22 #include "axlVtkViewPlugin.h"
23 
24 // ///////////////////////////////////////////////////////////////////
25 // axlVolumeDiscreteProcessCreatorPrivate
26 // ///////////////////////////////////////////////////////////////////
27 
28 class axlVolumeDiscreteProcessCreatorPrivate
29 {
30 public:
31 
32  unsigned int x, y,z; // } grid dimension parameters
34  axlVolumeDiscrete *output;
35 
36 };
37 // ///////////////////////////////////////////////////////////////////
38 // axlVolumeDiscreteProcessCreator implementation
39 // ///////////////////////////////////////////////////////////////////
40 
42 {
43  d->input = NULL;
44  d->output = NULL;
45 }
46 
48 {
49  delete d;
50  d= NULL;
51 
52 }
53 
54 //axlAbstractData *axlVolumeDiscreteProcessCreator::getInput(int channel) const{
55 // return d->input;
56 //}
57 
58 
59 
60 //not finished yet
62  if(process->output()){
63  d->output = dynamic_cast<axlVolumeDiscrete *>(process->output());
64  }
65 
66 }
67 
69  return true;
70 }
71 
72 
74 //double axlVolumeDiscreteProcessCreator::equationToValue(int i, int j, int k){
75 // return 0;
76 //}
77 
78 
79 
81  return d->output;
82 }
83 
84 
85 
86 void axlVolumeDiscreteProcessCreator::setInput(dtkAbstractData *newData, int channel){
87  if(dynamic_cast<axlAbstractSurfaceImplicit *>(newData)){
88  d->input = dynamic_cast<axlAbstractSurfaceImplicit *>(newData);
89  }
90 }
91 
92 
93 void axlVolumeDiscreteProcessCreator::setParameter(int value, int channel){
94  if(channel == 0){
95  d->x = value;
96  }else if(channel == 1){
97  d->y = value;
98  }else if(channel == 2){
99  d->z = value;
100  }else{
101 
102  }
103 
104 }
105 
107 
108  if(!d->input)
109  return 0;
110 
111  d->output = new axlVolumeDiscrete();
112  d->output->setDimensions(d->x, d->y, d->z);
113 
114  vtkImageData *grid = static_cast<vtkImageData *>(d->output->data());
115 
116  int nx = d->output->xDimension();
117  int ny = d->output->yDimension();
118  int nz = d->output->zDimension();
119  int value = 0;
120  int indice = 0;
121  double *coordinates = new double[3];
122 
123 
124  for(int i = 0; i < nx ;i++){
125  for(int j = 0; j < ny ;j++){
126  for(int k = 0; k < nz ;k++){
127  //get the point of the volume at indices i,j,k
128  indice = k*nx*ny+j*nx+i;
129  grid->GetPoint(indice, coordinates);
130  //compute the value obtained with the implicit surface.
131  value = d->input->eval(coordinates);
132  //set value
133  d->output->setValue(value, i, j,k);
134  }
135  }
136  }
137 
138  return 1;
139 
140 }
141 
143  return "creates an axlVolume";
144 }
145 
146 
148  return "axlVolumeDiscreteProcessCreator";
149 }
150 
152  return axlVtkViewPlugin::processFactSingleton->registerProcessType("axlVolumeDiscreteProcessCreator", createaxlVolumeDiscreteProcessCreator,"axlAbstractCreator");
153 }
154 
155 // /////////////////////////////////////////////////////////////////
156 // Type instanciation
157 // /////////////////////////////////////////////////////////////////
158 
159 dtkAbstractProcess *createaxlVolumeDiscreteProcessCreator(void)
160 {
162 }
virtual void setParameter(int value, int channel)
virtual void setInput(dtkAbstractData *newData, int channel)
void copyProcess(axlAbstractProcess *process)
dtkAbstractProcess * createaxlVolumeDiscreteProcessCreator(void)
static dtkAbstractProcessFactory * processFactSingleton