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