NorMIT-nav  22.09
An IGT application
cxRouteToTarget.h
Go to the documentation of this file.
1 #ifndef CXROUTETOTARGET_H
2 #define CXROUTETOTARGET_H
3 
4 #include "org_custusx_filter_routetotarget_Export.h"
5 
6 #include "cxMesh.h"
7 #include <QDomElement>
8 
9 
10 namespace cx
11 {
12 
13 typedef std::vector< Eigen::Matrix4d > M4Vector;
14 typedef boost::shared_ptr<class RouteToTarget> RouteToTargetPtr;
15 typedef boost::shared_ptr<class BranchList> BranchListPtr;
16 typedef boost::shared_ptr<class Branch> BranchPtr;
17 
18 
19 class org_custusx_filter_routetotarget_EXPORT RouteToTarget
20 {
21 public:
22  RouteToTarget();
23  virtual ~RouteToTarget();
24  void setBloodVesselVolume(ImagePtr bloodVesselVolume);
25  //void setCenterline(vtkPolyDataPtr centerline);
26  Eigen::MatrixXd getCenterlinePositions(vtkPolyDataPtr centerline_r);
27  void setSmoothing(bool smoothing);
28  void processCenterline(MeshPtr mesh);
29  void setBranchList(BranchListPtr branchList);
30  void processBloodVesselCenterline(Eigen::MatrixXd positions);
31  void findClosestPointInBranches(Vector3D targetCoordinate_r);
32  void findClosestPointInBloodVesselBranches(Vector3D targetCoordinate_r);
33  void findRoutePositions();
34  void findRoutePositionsInBloodVessels();
35  void searchBranchUp(BranchPtr searchBranchPtr, int startIndex);
36  void searchBloodVesselBranchUp(BranchPtr searchBranchPtr, int startIndex);
37  vtkPolyDataPtr findRouteToTarget(PointMetricPtr targetPoint);
38  vtkPolyDataPtr findExtendedRoute(PointMetricPtr targetPoint);
39  vtkPolyDataPtr findRouteToTargetAlongBloodVesselCenterlines(MeshPtr bloodVesselCenterlineMesh, PointMetricPtr targetPoint);
40  vtkPolyDataPtr generateAirwaysFromBloodVesselCenterlines();
41  bool makeConnectedAirwayAndBloodVesselRoute();
42  vtkPolyDataPtr getConnectedAirwayAndBloodVesselRoute();
43  vtkPolyDataPtr addVTKPoints(std::vector< Eigen::Vector3d > positions);
44  void addRouteInformationToFile(VisServicesPtr services);
45  static double calculateRouteLength(std::vector< Eigen::Vector3d > route);
46  void setBloodVesselRadius();
47  double calculateBloodVesselRadius(Eigen::Vector3d position, Eigen::Vector3d orientation);
48  double findDistanceToSegmentationEdge(vtkImageDataPtr bloodVesselImage, Eigen::Vector3i indexVector, Eigen::Vector3d perpendicularVector, int* dim, double* spacing, int direction);
49  void makeMarianaCenterlineFile(QString filename);
50  QJsonArray makeMarianaCenterlineJSON();
51  std::vector< Eigen::Vector3d > getRoutePositions();
52  std::vector< double > getCameraRotation();
53 
54  double getTracheaLength();
55  static std::vector<Eigen::Vector3d> getRoutePositions(MeshPtr route);
56 
57 
58 private:
59  Eigen::MatrixXd mCLpoints;
60  bool mSmoothing = true;
61  BranchListPtr mBranchListPtr;
62  BranchListPtr mBloodVesselBranchListPtr;
63  BranchPtr mProjectedBranchPtr;
64  BranchPtr mProjectedBloodVesselBranchPtr;
65  int mProjectedIndex;
66  int mProjectedBloodVesselIndex;
67  ImagePtr mBloodVesselVolume;
68  Vector3D mTargetPosition;
69  std::vector< Eigen::Vector3d > mRoutePositions;
70  std::vector< Eigen::Vector3d > mExtendedRoutePositions;
71  std::vector< double > mCameraRotation;
72  std::vector< double > mExtendedCameraRotation;
73  std::vector< Eigen::Vector3d > mBloodVesselRoutePositions;
74  std::vector< Eigen::Vector3d > mMergedAirwayAndBloodVesselRoutePositions;
75  std::vector< int > mBranchingIndex;
76  std::vector<BranchPtr> mSearchBranchPtrVector;
77  std::vector<int> mSearchIndexVector;
78  Eigen::MatrixXd mConnectedPointsInBVCL;
79  bool checkIfRouteToTargetEndsAtEndOfLastBranch();
80  bool mPathToBloodVesselsFound = false;
81 };
82 
83 Eigen::MatrixXd findClosestBloodVesselSegments(Eigen::MatrixXd bloodVesselPositions , Eigen::MatrixXd airwayPositions, Vector3D targetPosition);
84 std::pair< Eigen::MatrixXd, Eigen::MatrixXd > findLocalPointsInCT(int closestCLIndex , Eigen::MatrixXd CLpoints);
85 std::pair<int, double> findDistanceFromPointToLine(Eigen::MatrixXd point, std::vector< Eigen::Vector3d > line);
86 std::vector< Eigen::Vector3d > getBranchPositions(BranchPtr branchPtr, int startIndex);
87 double findDistance(Eigen::MatrixXd p1, Eigen::MatrixXd p2);
88 Eigen::MatrixXd convertToEigenMatrix(std::vector< Eigen::Vector3d > positionsVector);
89 double variance(Eigen::VectorXd X);
90 
91 org_custusx_filter_routetotarget_EXPORT QJsonArray makeMarianaCenterlineOfFullBranchTreeJSON(BranchListPtr branchList);
92 
93 } /* namespace cx */
94 
95 #endif // CXROUTETOTARGET_H
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::findDistance
double findDistance(Eigen::MatrixXd p1, Eigen::MatrixXd p2)
Definition: cxBronchoscopePositionProjection.cpp:372
cx::VisServicesPtr
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cx::RouteToTargetPtr
boost::shared_ptr< class RouteToTarget > RouteToTargetPtr
Definition: cxAccusurf.h:12
cx::variance
double variance(Eigen::VectorXd X)
Definition: cxRouteToTarget.cpp:832
cx::RouteToTarget
Definition: cxRouteToTarget.h:19
cx::MeshPtr
boost::shared_ptr< class Mesh > MeshPtr
Definition: cxForwardDeclarations.h:48
cx::M4Vector
std::vector< Eigen::Matrix4d > M4Vector
Definition: cxBronchoscopePositionProjection.h:12
cx::findLocalPointsInCT
std::pair< Eigen::MatrixXd, Eigen::MatrixXd > findLocalPointsInCT(int closestCLIndex, Eigen::MatrixXd CLpositions)
Definition: cxRouteToTarget.cpp:759
cx::convertToEigenMatrix
Eigen::MatrixXd convertToEigenMatrix(std::vector< Eigen::Vector3d > positionsVector)
Definition: cxRouteToTarget.cpp:820
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::findDistanceFromPointToLine
std::pair< int, double > findDistanceFromPointToLine(Eigen::MatrixXd point, std::vector< Eigen::Vector3d > line)
Definition: cxRouteToTarget.cpp:795
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::BranchListPtr
boost::shared_ptr< class BranchList > BranchListPtr
Definition: cxBronchoscopePositionProjection.h:14
cx::findClosestBloodVesselSegments
Eigen::MatrixXd findClosestBloodVesselSegments(Eigen::MatrixXd bloodVesselPositions, Eigen::MatrixXd airwayPositions, Vector3D targetPosition)
Definition: cxRouteToTarget.cpp:735
cx::makeMarianaCenterlineOfFullBranchTreeJSON
QJsonArray makeMarianaCenterlineOfFullBranchTreeJSON(BranchListPtr branchList)
Definition: cxRouteToTarget.cpp:697
cx::BranchPtr
boost::shared_ptr< class Branch > BranchPtr
Definition: cxBronchoscopePositionProjection.h:15
cx::PointMetricPtr
boost::shared_ptr< class PointMetric > PointMetricPtr
Definition: cxForwardDeclarations.h:84
cxMesh.h
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::getBranchPositions
std::vector< Eigen::Vector3d > getBranchPositions(BranchPtr branchPtr, int startIndex)
Definition: cxRouteToTarget.cpp:722