NorMIT-nav  22.09
An IGT application
cxPlaneMetric.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 
12 
13 #include "cxPlaneMetric.h"
14 
15 #include "cxBoundingBox3D.h"
16 #include "cxTool.h"
17 #include "cxTypeConversions.h"
18 #include "cxSpaceListener.h"
19 #include "cxSpaceProvider.h"
20 #include "cxPatientModelService.h"
21 
22 namespace cx
23 {
24 
25 PlaneMetric::PlaneMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider) :
26  DataMetric(uid, name, dataManager, spaceProvider)
27 {
28  mArguments.reset(new MetricReferenceArgumentList(QStringList() << "position" << "direction"));
29  connect(mArguments.get(), SIGNAL(argumentsChanged()), this, SIGNAL(transformChanged()));
30 }
31 
32 PlaneMetricPtr PlaneMetric::create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
33 {
34  return PlaneMetricPtr(new PlaneMetric(uid, name, dataManager, spaceProvider));
35 }
36 
38 {
39 }
40 
42 {
43  return Eigen::Hyperplane<double, 3>(this->getRefNormal(), this->getRefCoord());
44 }
45 
47 {
48  std::vector<Vector3D> coords = mArguments->getRefCoords();
49  if (coords.size()<2)
50  return Vector3D::Zero();
51  return coords[0];
52 }
53 
55 {
56  std::vector<Vector3D> coords = mArguments->getRefCoords();
57  if (coords.size()<2)
58  return Vector3D::UnitZ();
59  return (coords[1]-coords[0]).normal();
60 }
61 
62 
63 void PlaneMetric::addXml(QDomNode& dataNode)
64 {
65  DataMetric::addXml(dataNode);
66  mArguments->addXml(dataNode);
67 }
68 
69 void PlaneMetric::parseXml(QDomNode& dataNode)
70 {
71  DataMetric::parseXml(dataNode);
72  mArguments->parseXml(dataNode, mDataManager->getDatas());
73 }
74 
76 {
77  Vector3D p0_r = this->getRefCoord();
78  return DoubleBoundingBox3D(p0_r, p0_r);
79 }
80 
81 
82 }
cx::PlaneMetric::getRefPlane
Plane3D getRefPlane() const
Definition: cxPlaneMetric.cpp:41
cx::DoubleBoundingBox3D
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,...
Definition: cxBoundingBox3D.h:63
cxSpaceListener.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::DataMetric::mDataManager
PatientModelServicePtr mDataManager
Definition: cxDataMetric.h:67
cx::PlaneMetric::addXml
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
Definition: cxPlaneMetric.cpp:63
cx::DataMetric::addXml
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
Definition: cxDataMetric.cpp:55
cxBoundingBox3D.h
cx::MetricReferenceArgumentList
Collection of Metric arguments that refer to another metric.
Definition: cxMetricReferenceArgumentList.h:36
cx::Data::transformChanged
void transformChanged()
emitted when transform is changed
cxPlaneMetric.h
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cxTool.h
cxTypeConversions.h
cxPatientModelService.h
cx::PlaneMetric::getRefNormal
Vector3D getRefNormal() const
Definition: cxPlaneMetric.cpp:54
cx::PlaneMetric::parseXml
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
Definition: cxPlaneMetric.cpp:69
cx::DataMetric
Base class for all Data Metrics.
Definition: cxDataMetric.h:43
cx::PlaneMetricPtr
boost::shared_ptr< class PlaneMetric > PlaneMetricPtr
Definition: cxPlaneMetric.h:34
cx::PlaneMetric::getRefCoord
virtual Vector3D getRefCoord() const
Definition: cxPlaneMetric.cpp:46
cx::PlaneMetric::create
static PlaneMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
Definition: cxPlaneMetric.cpp:32
cx::PlaneMetric::~PlaneMetric
virtual ~PlaneMetric()
Definition: cxPlaneMetric.cpp:37
cx::PlaneMetric::PlaneMetric
PlaneMetric(const QString &uid, const QString &name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
Definition: cxPlaneMetric.cpp:25
cx::PlaneMetric::boundingBox
virtual DoubleBoundingBox3D boundingBox() const
Definition: cxPlaneMetric.cpp:75
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::DataMetric::parseXml
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
Definition: cxDataMetric.cpp:65
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23
cxSpaceProvider.h
cx::Plane3D
Eigen::Hyperplane< double, 3 > Plane3D
Definition: cxPlaneMetric.h:26