Developer documentation | Axl-2.5.1

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