Developer documentation | Axl-2.5.1

axlBarycenterProcess.cpp
Go to the documentation of this file.
1 /* axlBarycenterProcess.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2012, Anais Ducoffe, INRIA.
5  */
6 
7 /* Commentary:
8  */
9 
10 /* Change log:
11  *
12  */
13 #include "axlBarycenterProcess.h"
14 #include <axlCore/axlPoint.h>
15 #include <axlCore/axlLine.h>
16 #include <axlCore/axlDouble.h>
18 
22 
23 class axlBarycenterProcessPrivate{
24 
25 public :
26  //inputs
27  axlLine *input;
28  axlDouble *lambda;
29  //output
30  axlPoint *output;
31 
32 };
33 
37 axlBarycenterProcess::axlBarycenterProcess(QObject *parent) : axlAbstractProcess(), d(new axlBarycenterProcessPrivate){
38  d->input = NULL;
39  d->output = NULL;
40  d->lambda = NULL;
41 
42 }
43 
44 
46  delete d;
47  d= NULL;
48 }
49 
50 
52  return d->input;
53 }
54 
56  return d->lambda->value();
57 }
58 
59 
60 
61 dtkAbstractData *axlBarycenterProcess::output(void){
62  return d->output;
63 }
64 
65 
66 void axlBarycenterProcess::setInput(dtkAbstractData *newData, int channel){
67  if(dynamic_cast<axlLine *>(newData)){
68  axlLine *axlData = dynamic_cast<axlLine *>(newData);
69  d->input = axlData;
70 
71  }
72 }
73 
74 void axlBarycenterProcess::setParameter(double data, int channel){
75  axlDouble *axlData = new axlDouble(data);
76  d->lambda = axlData;
77 }
78 
80 
84  if (d->output==NULL) {
85  if (d->input){
86  if(d->lambda){
87  d->output = d->input->getBarycenterPoint(d->lambda->value());
88  return 1;
89  } else {
90  d->lambda = new axlDouble(0.5);
91  d->output = d->input->getBarycenterPoint(d->lambda->value());
92  return 1;
93  }
94  } else {
95  return 0;
96  }
97  } else {
98  if (d->input) {
99  if(d->lambda) {
100  axlPoint* tmp= d->input->getBarycenterPoint(d->lambda->value());
101  d->output->setCoordinates( tmp->x(), tmp->y(), tmp->z()) ;
102  delete tmp;
103  return 1;
104  } else {
105  return 0;
106  }
107  } else {
108  return 0;
109  }
110 
111  } // return 0;
112 }
113 
115  return 1;
116 }
117 
119  return "give the barycenter point of the points defining the line";
120 }
121 
122 
124  return "axlBarycenterProcess";
125 }
126 
127 dtkAbstractProcess *createaxlBarycenterProcess(void){
128  return new axlBarycenterProcess;
129 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
Class axlLine defines 3D lines.
Definition: axlLine.h:35
Class axlDouble defines a double.
Definition: axlDouble.h:29
axlAbstractData * getInput(int channel) const
void setParameter(double data, int channel=0)
QString description(void) const
void setInput(dtkAbstractData *newData, int channel=0)
dtkAbstractData * output(void)
double getCoeffValue(void) const
dtkAbstractProcess * createaxlBarycenterProcess(void)
double y
Definition: axlPoint.h:37
double z
Definition: axlPoint.h:38
QString identifier(void) const
double x
Definition: axlPoint.h:37
Class axlAbstractData defines an API for all type of axel data.
axlBarycenterProcess(QObject *parent=0)
virtual int update(void)
Returns the barycenter point of the line.