NorMIT-nav  22.09
An IGT application
cxSimpleSyntheticVolume.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 
14 #include "cxTypeConversions.h"
15 
16 namespace cx {
17 
19  : cxSyntheticVolume(bounds)
20 {
21 }
22 
24 {
25  std::cout << QString("Volume: Simple, bounds=[%1]")
26  .arg(qstring_cast(mBounds))
27  << std::endl;
28 }
29 
31  float y,
32  float thickness,
33  int n_lines,
34  int axis) const
35 {
36  float linespacing = mBounds(axis)/n_lines;
37 
38  for(int i = 0; i < n_lines; i++)
39  {
40  if(x > i*linespacing + linespacing/2 && x < i*linespacing + thickness + linespacing/2)
41  {
42  if(y > 0.0f && y < thickness)
43  {
44  return true;
45  }
46  }
47  }
48  return false;
49 }
50 
51 unsigned char cxSimpleSyntheticVolume::evaluate(const cx::Vector3D &p) const
52 {
53  float x = p[0];
54  float y = p[1];
55  float z = p[2];
56 
57  // Let's make a block in the middle of the volume
58  if(x > mBounds(0)/3 && x < 2*mBounds(0)/3
59  && y > mBounds(1)/3 && y < 2*mBounds(1)/3
60  && z > mBounds(2)/3 && z < 2*mBounds(2)/3)
61  {
62  return 255;
63  }
64 
65  // A set of thin lines with traversing in each of the directions
66 
67  // Z direction
68  if(isOnLine(x, y-2.0f, 0.5f, 5, 2))
69  {
70  return 255;
71  }
72 
73  if(isOnLine(x, y-3.0f, 0.25f, 5, 2))
74  {
75  return 255;
76  }
77 
78  if(isOnLine(x, y-4.0f, 0.125f, 5, 2))
79  {
80  return 255;
81  }
82  if(isOnLine(x, y-5.0f, 0.0625f, 5, 2))
83  {
84  return 255;
85  }
86 
87  // Y direction
88  if(isOnLine(x, z-2.0f, 0.5f, 5, 1))
89  {
90  return 255;
91  }
92 
93  if(isOnLine(x, z-3.0f, 0.25f, 5, 1))
94  {
95  return 255;
96  }
97 
98  if(isOnLine(x, z-4.0f, 0.125f, 5, 1))
99  {
100  return 255;
101  }
102  if(isOnLine(x, z-5.0f, 0.0625f, 5, 1))
103  {
104  return 255;
105  }
106 
107  // X direction
108  if(isOnLine(z, y-2.0f, 0.5f, 5, 0))
109  {
110  return 255;
111  }
112 
113  if(isOnLine(z, y-3.0f, 0.25f, 5, 0))
114  {
115  return 255;
116  }
117 
118  if(isOnLine(z, y-4.0f, 0.125f, 5, 0))
119  {
120  return 255;
121  }
122  if(isOnLine(z, y-5.0f, 0.0625f, 5, 0))
123  {
124  return 255;
125  }
126 
127 
128  // Return nonzero if value is inside region
129  else if(x > 0 && x < mBounds(0)
130  && y > 0 && y < mBounds(1)
131  && z > 0 && z < mBounds(2))
132  {
133  return 10;
134  }
135  return 0;
136 }
137 } //namespace cx
cx::cxSimpleSyntheticVolume::evaluate
virtual unsigned char evaluate(const cx::Vector3D &p) const
Definition: cxSimpleSyntheticVolume.cpp:51
qstring_cast
QString qstring_cast(const T &val)
Definition: cxTypeConversions.h:46
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::cxSyntheticVolume
Definition: cxSyntheticVolume.h:36
cx::cxSimpleSyntheticVolume::isOnLine
virtual bool isOnLine(float x, float y, float thickness, int n_lines, int axis) const
Definition: cxSimpleSyntheticVolume.cpp:30
cx::cxSimpleSyntheticVolume::cxSimpleSyntheticVolume
cxSimpleSyntheticVolume(Vector3D bounds)
Definition: cxSimpleSyntheticVolume.cpp:18
cxTypeConversions.h
cxSimpleSyntheticVolume.h
cx::cxSyntheticVolume::mBounds
Vector3D mBounds
Definition: cxSyntheticVolume.h:114
cx::cxSimpleSyntheticVolume::printInfo
virtual void printInfo() const
Definition: cxSimpleSyntheticVolume.cpp:23
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42