CustusX  22.04-rc5
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 }
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
static PlaneMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual DoubleBoundingBox3D boundingBox() const
Vector3D getRefNormal() const
virtual ~PlaneMetric()
void transformChanged()
emitted when transform is changed
Collection of Metric arguments that refer to another metric.
PatientModelServicePtr mDataManager
Definition: cxDataMetric.h:67
boost::shared_ptr< class PlaneMetric > PlaneMetricPtr
Definition: cxPlaneMetric.h:34
void parseXml(QDomNode &dataNode)
Use a XML node to load data.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual void parseXml(QDomNode &dataNode)
Use a XML node to load data.
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.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
virtual void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
virtual Vector3D getRefCoord() const
Base class for all Data Metrics.
Definition: cxDataMetric.h:43
PlaneMetric(const QString &uid, const QString &name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
Plane3D getRefPlane() const
Namespace for all CustusX production code.