Developer documentation | Axl-2.5.1

axlConeCreator.cpp
Go to the documentation of this file.
1 /* axlConeCreator.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 "axlConeCreator.h"
14 #include <axlCore/axlPoint.h>
15 #include <axlCore/axlCone.h>
16 #include <axlCore/axlDouble.h>
18 
19 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
20 
24 
25 class axlConeCreatorPrivate{
26 
27 public :
28  axlPoint *point1;
29  axlPoint *point2;
30  double radius;
31  axlCone *output;
32 
33 
34 };
35 
39 axlConeCreator::axlConeCreator(QObject *parent) : axlAbstractCreatorProcess(), d(new axlConeCreatorPrivate){
40  d->point1 = NULL;
41  d->point2 = NULL;
42  d->radius = 1;
43  d->output = NULL;
44 
45 
46 }
47 
49 
50  delete d;
51  d = NULL;
52 }
53 
54 
56  if(channel == 0){
57  return d->point1;
58  }else {
59  return d->point2;
60  }
61 }
62 
63 
65  if(process->output()){
66  d->output = dynamic_cast<axlCone *>(process->output());
67  }
68 
69 }
70 
72  return true;
73 }
74 
75 
76 
77 dtkAbstractData *axlConeCreator::output(void){
78  return d->output;
79 }
80 
81 void axlConeCreator::setInput(dtkAbstractData *newData, int channel){
82  if(dynamic_cast<axlPoint *>(newData)){
83  axlPoint *point = dynamic_cast<axlPoint *>(newData);
84  if(channel == 0){
85  d->point1 = point;
86  }else if(channel ==1){
87  d->point2 = point;
88  }
89  }
90 }
91 
92 
93 void axlConeCreator::setParameter(double value){
94  d->radius = value;
95 
96 }
97 
99  if(d->output == NULL){
100  if(d->point1 && d->point2 && (d->radius >=0.0)){
101  axlCone *newCone = new axlCone(d->point1, d->point2, d->radius);
102  d->output = newCone;
103  return 1;
104  }else{
105  return 0;
106  }
107  }else{
108 
109  if(d->point1 && d->point2 && (d->radius >=0.0)){
110  d->output->setValues(d->point1, d->point2, d->radius);
111  return 1;
112  }else{
113  return 0;
114  }
115 
116  }
117 
118 }
119 
120 QString axlConeCreator::description(void) const{
121  return "create a cone with two points : \n its base point and its apex point \n and its radius value";
122 }
123 
124 
125 QString axlConeCreator::identifier(void) const{
126  return "axlConeCreator";
127 }
128 
130  return dtkAbstractProcessFactory::instance()->registerProcessType("axlConeCreator", createaxlConeCreator);
131 }
132 
133 // /////////////////////////////////////////////////////////////////
134 // Type instanciation
135 // /////////////////////////////////////////////////////////////////
136 
137 dtkAbstractProcess *createaxlConeCreator(void)
138 {
139  return new axlConeCreator;
140 }
141 
142 
143 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual int update(void)
virtual void setParameter(double value)
virtual void setInput(dtkAbstractData *newData, int channel)
dtkAbstractProcess * createaxlConeCreator(void)
virtual axlAbstractData * getInput(int channel) const
virtual QString description(void) const
virtual dtkAbstractData * output(void)
void copyProcess(axlAbstractProcess *process)
virtual ~axlConeCreator(void)
Class axlCone defines 3D cones.
Definition: axlCone.h:34
bool hasParameters(void)
axlConeCreator(QObject *parent=0)
virtual QString identifier(void) const
Class axlAbstractData defines an API for all type of axel data.
static bool registered(void)