Developer documentation | Axl-2.5.1

axlPlaneCreator.cpp
Go to the documentation of this file.
1 /* axlPlaneCreator.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 "axlPlaneCreator.h"
14 #include <axlCore/axlPoint.h>
15 #include <axlCore/axlPlane.h>
17 
18 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
19 
23 
24 class axlPlaneCreatorPrivate{
25 
26 public :
27  QPair <axlPoint *, axlPoint *> inputs;
28  axlPlane *output;
29 
30 
31 };
32 
36 axlPlaneCreator::axlPlaneCreator(QObject *parent) : axlAbstractCreatorProcess(), d(new axlPlaneCreatorPrivate){
37  d->output = NULL;
38 
39  dtkAbstractProcessFactory::instance()->registerProcessType("axlPlaneCreator", createaxlPlaneCreator);
40 
41 }
42 
44  delete d;
45  d = NULL;
46 }
47 
48 
50  if(channel == 0){
51  return d->inputs.first;
52  }else{
53  return d->inputs.second;
54  }
55 }
56 
57 
59  if(process->output()){
60  d->output = dynamic_cast<axlPlane *>(process->output());
61  }
62 }
63 
65  return false;
66 }
67 
68 
69 dtkAbstractData *axlPlaneCreator::output(void){
70  return d->output;
71 }
72 
73 
74 void axlPlaneCreator::setInput(dtkAbstractData *newData, int channel){
75  if(dynamic_cast<axlPoint *>(newData)){
76  axlPoint *point = dynamic_cast<axlPoint *>(newData);
77  if(channel == 0){
78  d->inputs.first = point;
79  }else{
80  d->inputs.second = point;
81  }
82  }
83 }
84 
85 
87 
88  if(d->output == NULL){
89  if(d->inputs.first && d->inputs.second){
90  d->output = new axlPlane(d->inputs.first, d->inputs.second);
91  return 1;
92  }else{
93  return 0;
94  }
95  }else{
96  if(d->inputs.first && d->inputs.second){
97  d->output->setValues(d->inputs.first, d->inputs.second);
98  return 1;
99  }else{
100  return 0;
101  }
102 
103  }
104 
105 }
106 
107 QString axlPlaneCreator::description(void) const{
108  return "create a plane with two points : \n one on the plane and the other one to determine its normal";
109 }
110 
111 
112 QString axlPlaneCreator::identifier(void) const{
113  return "axlPlaneCreator";
114 }
115 
116 
118  return dtkAbstractProcessFactory::instance()->registerProcessType("axlPlaneCreator", createaxlPlaneCreator);
119 }
120 
121 dtkAbstractProcess *createaxlPlaneCreator(void){
122 
123  return new axlPlaneCreator;
124 }
125 
126 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void copyProcess(axlAbstractProcess *process)
axlPlaneCreator(QObject *parent=0)
Class axlPlane defines 3D planes.
Definition: axlPlane.h:34
virtual dtkAbstractData * output(void)
virtual QString identifier(void) const
bool hasParameters(void)
virtual int update(void)
virtual axlAbstractData * getInput(int channel) const
virtual QString description(void) const
virtual ~axlPlaneCreator(void)
virtual void setInput(dtkAbstractData *newData, int channel)
dtkAbstractProcess * createaxlPlaneCreator(void)
Class axlAbstractData defines an API for all type of axel data.
static bool registered(void)