Developer documentation | Axl-2.5.1

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