Fraxinus  22.09
An IGT application
cxCreateProbeDefinitionFromConfiguration.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 #include "cxTypeConversions.h"
14 #include <iostream>
15 
16 namespace cx
17 {
18 
20 {
22 
23  QSize storedSize(basis.mImageWidth, basis.mImageHeight);
24  if (storedSize!=data.getSize())
25  {
26  // wrong size: resample
27  data.resample(storedSize);
28  }
29 
30  config.mLeftEdge = data.getClipRect_p()[0];
31  config.mRightEdge = data.getClipRect_p()[1];
32  config.mTopEdge = data.getClipRect_p()[2];
33  config.mBottomEdge = data.getClipRect_p()[3];
34 
35  config.mOriginCol = data.getOrigin_p()[0];
36  config.mOriginRow = data.getOrigin_p()[1];
37 
38  config.mPixelWidth = data.getSpacing()[0];
39  config.mPixelHeight = data.getSpacing()[1];
40 
41  config.mImageWidth = data.getSize().width();
42  config.mImageHeight = data.getSize().height();
43 
45  {
46  config.mWidthDeg = data.getWidth() / M_PI*180.0;
47  config.mOffset = data.getDepthStart() / data.getSpacing()[1];
48  config.mDepth = (data.getDepthEnd() - data.getDepthStart()) / data.getSpacing()[1];
49  }
50  else
51  {
52  // derived values
53  config.mWidthDeg = 0.0;
54  config.mOffset = 0;
55  config.mDepth = 0;
56  }
57 
59 
60  return config;
61 }
62 
64 {
65  if(config.isEmpty())
66  return ProbeDefinition();
67 
68  ProbeDefinition probeDefinition;
69 
70  if (config.mWidthDeg > 0.1) // Sector probe
71  {
72  double depthStart = config.mOffset * config.mPixelHeight;
73  double depthEnd = config.mDepth * config.mPixelHeight + depthStart;
74 
75  double width = config.mWidthDeg * M_PI / 180.0;//width in radians
76  probeDefinition = ProbeDefinition(ProbeDefinition::tSECTOR);
77  probeDefinition.setSector(depthStart, depthEnd, width);
78  }
79  else //Linear probe
80  {
81  int widtInPixels = config.mRightEdge - config.mLeftEdge;
82  double width = config.mPixelWidth * double(widtInPixels); //width in mm
83  // correct for top/bottom edges if applicable
84  double depthStart = double(config.mTopEdge-config.mOriginRow) * config.mPixelHeight;
85  double depthEnd = double(config.mBottomEdge-config.mOriginRow) * config.mPixelHeight;
86 
87  probeDefinition = ProbeDefinition(ProbeDefinition::tLINEAR);
88  probeDefinition.setSector(depthStart, depthEnd, width);
89  }
90 
91  probeDefinition.setSpacing(Vector3D(config.mPixelWidth, config.mPixelHeight, 1));
92  probeDefinition.setSize(QSize(config.mImageWidth, config.mImageHeight));
93  probeDefinition.setOrigin_p(Vector3D(config.mOriginCol, config.mOriginRow, 0));
94  probeDefinition.setClipRect_p(DoubleBoundingBox3D(config.mLeftEdge,config.mRightEdge,config.mTopEdge,config.mBottomEdge,0,0));
95  probeDefinition.setTemporalCalibration(config.mTemporalCalibration);
96 
97  return probeDefinition;
98 }
99 
100 } // namespace cx
double getWidth() const
< a easy-to-work-with struct for a specific xml configuration
void setSpacing(Vector3D spacing)
US beam is emitted straight forward.
void resample(QSize mSize)
Set a new image size. Resample all other parameters to match this new image size, keeping sizes in mi...
void setSector(double depthStart, double depthEnd, double width, double centerOffset=0)
double getDepthStart() const
double getDepthEnd() const
Vector3D getOrigin_p() const
void setOrigin_p(Vector3D origin_p)
US beam is emitted radially in a flat cone.
void setTemporalCalibration(double value)
void setClipRect_p(DoubleBoundingBox3D clipRect_p)
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
int mImageWidth
Width of the used image format (x dim)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
Definition of characteristics for an Ultrasound Probe Sector.
Vector3D getSpacing() const
int mImageHeight
Height of the used image format (y dim)
double mTemporalCalibration
delay in timestamping in grabber source relative to master clock.
double getTemporalCalibration() const
DoubleBoundingBox3D getClipRect_p() const
void setSize(QSize size)
ProbeDefinition createProbeDefinitionFromConfiguration(ProbeXmlConfigParser::Configuration config)
ProbeXmlConfigParser::Configuration createConfigurationFromProbeDefinition(ProbeXmlConfigParser::Configuration basis, ProbeDefinition data)
#define M_PI
Namespace for all CustusX production code.