Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Direction.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef DIRECTION_H
28 #define DIRECTION_H
29 
30 #include <iostream>
31 #include "libxml/xmlIO.h"
39 class Direction {
40 
41 public:
45  Direction(const unsigned int toward) { setToward(toward); };
47  Direction(double x0, double y0, double z0) { setX(x0); setY(y0); setZ(z0); };
50 
52  void xmlPrint(std::ostream & o) const {
53  o << "\t<direction ";
54  if (isToward()) {
55  o << "toward=\"" << towardIndex << "\"";
56  }
57  else {
58  switch (xState) {
59  case NOT_SPECIFIED:
60  break;
61  case NULL_DIR:
62  o << "x=\"NULL\" ";
63  break;
64  case SPECIFIED:
65  o << "x=\"" << x << "\" ";
66  break;
67  default:
68  break;
69  }
70  switch (yState) {
71  case NOT_SPECIFIED:
72  break;
73  case NULL_DIR:
74  o << "y=\"NULL\" ";
75  break;
76  case SPECIFIED:
77  o << "y=\"" << y << "\" ";
78  break;
79  default:
80  break;
81  }
82  switch (zState) {
83  case NOT_SPECIFIED:
84  break;
85  case NULL_DIR:
86  o << "z=\"NULL\"";
87  break;
88  case SPECIFIED:
89  o << "z=\"" << z << "\"";
90  break;
91  default:
92  break;
93  }
94  }
95  o << "/>" << std::endl;
96  };
97 
99  void set(const double x, const double y, const double z) {
100  setX(x);setY(y);setZ(z);
101  };
102 
104  int getToward() const {
105  return towardIndex;
106  };
107 
109  void setToward(const unsigned int toward) {
110  towardIndex=toward;
111  xState = yState = zState = TOWARD;
112  };
113 
115  bool isToward() const {
116  return (towardIndex>=0 && xState==TOWARD && yState==TOWARD && zState==TOWARD);
117  };
118 
120 
121 
123  double getX() const { return x; };
124 
126  bool isXNull() const { return (xState==NULL_DIR); };
127 
129  bool isXSpecified() const { return (xState==SPECIFIED); };
130 
132  void setNullX() { x=0.0; xState = NULL_DIR; };
133 
135  void setX(const double x) { this->x = x; xState = SPECIFIED; };
137 
139 
140  double getY() const { return y; };
142 
144  bool isYNull() const { return (yState==NULL_DIR); };
145 
147  bool isYSpecified() const { return (yState==SPECIFIED); };
148 
150  void setNullY() { y=0.0; yState = NULL_DIR; };
151 
153  void setY(const double y) { this->y = y; yState = SPECIFIED; };
154 
156 
158 
159  double getZ() const { return z; };
161 
163  bool isZNull() const { return (zState==NULL_DIR); };
164 
166  bool isZSpecified() const { return (zState==SPECIFIED); };
167 
169  void setNullZ() { z=0.0; zState = NULL_DIR; };
170 
172  void setZ(const double z) { this->z = z; zState = SPECIFIED; };
173 
175 
176 private:
178  enum DirState {
183  };
184 
186  double x;
188  double y;
190  double z;
199 };
200 
201 #endif //DIRECTION_H
Direction(const Direction &d)
copy constructor
Definition: Direction.h:49
bool isYNull() const
is the y coordinate NULL ?
Definition: Direction.h:144
bool isZSpecified() const
is the z coordinate specified
Definition: Direction.h:166
void xmlPrint(std::ostream &o) const
print to an ostream
Definition: Direction.h:52
DirState yState
state for the y coordinates
Definition: Direction.h:194
double getY() const
get the y coordinate
Definition: Direction.h:141
void setX(const double x)
set the x coordinate
Definition: Direction.h:135
int towardIndex
toward atom index
Definition: Direction.h:198
void setNullZ()
set the z coordinate as NULL
Definition: Direction.h:169
double getZ() const
get the z coordinate
Definition: Direction.h:160
double y
y coordinates
Definition: Direction.h:188
void set(const double x, const double y, const double z)
set the direction
Definition: Direction.h:99
void setNullX()
set the x coordinate as NULL
Definition: Direction.h:132
bool isToward() const
true only if the direction is set by a toward atom
Definition: Direction.h:115
double z
z coordinates
Definition: Direction.h:190
Direction()
default constructor: nothing is specified
Definition: Direction.h:43
Direction(double x0, double y0, double z0)
constructor with initialization of the 3 directions
Definition: Direction.h:47
int getToward() const
get the toward index
Definition: Direction.h:104
Class that defines the direction of the Load with x, y and z.
Definition: Direction.h:39
the direction is set dynamically depending on the "toward" position
Definition: Direction.h:182
bool isXSpecified() const
is the x coordinate specified
Definition: Direction.h:129
DirState
state of the x,y and z
Definition: Direction.h:178
the direction has never been specified: it is absolutly free
Definition: Direction.h:179
void setToward(const unsigned int toward)
set the toward index
Definition: Direction.h:109
Direction(const unsigned int toward)
constructor with initialization of the toward
Definition: Direction.h:45
void setY(const double y)
set the y coordinate
Definition: Direction.h:153
double x
x coordinates
Definition: Direction.h:186
bool isYSpecified() const
is the y coordinate specified
Definition: Direction.h:147
the direction has been specified to be something imposed but not null (even 0.0 is possible!) ...
Definition: Direction.h:181
bool isZNull() const
is the z coordinate NULL ?
Definition: Direction.h:163
void setZ(const double z)
set the z coordinate
Definition: Direction.h:172
void setNullY()
set the y coordinate as NULL
Definition: Direction.h:150
DirState xState
state for the x coordinates
Definition: Direction.h:192
double getX() const
get the x coordinate
Definition: Direction.h:123
the direction has been specified to be always null
Definition: Direction.h:180
DirState zState
state for the z coordinates
Definition: Direction.h:196
bool isXNull() const
is the x coordinate NULL ?
Definition: Direction.h:126