Developer documentation | Axl-2.5.1

axlSphereCreator.cpp
Go to the documentation of this file.
1 /* axlSphereCreator.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013, Anais Ducoffe, INRIA.
5  */
6 
7 /* Commentary:
8  */
9 
10 /* Change log:
11  *
12  */
13 #include "axlSphereCreator.h"
14 #include <axlCore/axlDouble.h>
15 #include <axlCore/axlPoint.h>
16 #include <axlCore/axlSphere.h>
18 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
19 
23 
24 class axlSphereCreatorPrivate{
25 
26 public :
27  axlPoint *center;
28  double radius;
29  axlSphere *output;
30 
31 
32 };
33 
37 axlSphereCreator::axlSphereCreator(QObject *parent) : axlAbstractCreatorProcess(), d(new axlSphereCreatorPrivate){
38  d->center = NULL;
39  d->radius = 1;
40  d->output = NULL;
41 
42 }
43 
45  delete d;
46  d = NULL;
47 }
48 
49 
51  return d->center;
52 }
53 
55  if(process->output()){
56  d->output = dynamic_cast<axlSphere *>(process->output());
57  }
58 }
59 
61  return true;
62 }
63 
64 
65 dtkAbstractData *axlSphereCreator::output(void){
66  return d->output;
67 }
68 
69 
70 void axlSphereCreator::setInput(dtkAbstractData *newData, int channel){
71  if(dynamic_cast<axlPoint *>(newData)){
72  axlPoint *value = dynamic_cast<axlPoint *>(newData);
73  if(channel == 0){
74  d->center = value;
75  }
76 
77  }
78 }
79 
81  d->radius = data;
82 }
83 
84 
86 
87  if(d->output == NULL){
88  if(d->center &&(d->radius > 0.0) ){
89  axlSphere *newSphere = new axlSphere(d->center->x(), d->center->y(), d->center->z(), d->radius);
90  d->output = newSphere;
91  return 1;
92  }else{
93  return 0;
94  }
95  }else{
96  if(d->center && (d->radius > 0.0) ){
97  d->output->setValues(d->center->x(), d->center->y(), d->center->z(), d->radius);
98  return 1;
99  }else{
100  return 0;
101  }
102 
103  }
104 
105 }
106 
107 QString axlSphereCreator::description(void) const{
108  return "create a sphere with one center point \n and the radius value";
109 }
110 
111 
112 QString axlSphereCreator::identifier(void) const{
113  return "axlSphereCreator";
114 }
115 
116 dtkAbstractProcess *createaxlSphereCreator(void){
117 
118  return new axlSphereCreator;
119 }
120 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual QString identifier(void) const
virtual void setInput(dtkAbstractData *newData, int channel)
virtual QString description(void) const
dtkAbstractProcess * createaxlSphereCreator(void)
virtual void setParameter(double data)
virtual int update(void)
void copyProcess(axlAbstractProcess *process)
virtual ~axlSphereCreator(void)
virtual dtkAbstractData * output(void)
virtual axlAbstractData * getInput(int channel) const
Class axlSphere defines 3D spheres.
Definition: axlSphere.h:33
axlSphereCreator(QObject *parent=0)
bool hasParameters(void)
Class axlAbstractData defines an API for all type of axel data.