NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxSlicePlaneClipper.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 /*
14  * sscSlicePlaneClipper.cpp
15  *
16  * Created on: Aug 20, 2010
17  * Author: christiana
18  */
19 
20 #include "cxSlicePlaneClipper.h"
21 
22 #include <vector>
23 #include <vtkPlane.h>
24 
25 #include "cxSliceProxy.h"
26 
27 namespace cx
28 {
29 
31 {
33 }
34 
35 SlicePlaneClipper::SlicePlaneClipper() :
36  mInvertPlane(false)
37 {
38 }
39 
41 {
42 }
43 
45 {
46  if (mSlicer==slicer)
47  return;
48  if (mSlicer)
49  {
50  disconnect(mSlicer.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(changedSlot()));
51  }
52  mSlicer = slicer;
53  if (mSlicer)
54  {
55  connect(mSlicer.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(changedSlot()));
56  }
57 
58  this->updateClipPlane();
59  this->changedSlot();
60 }
61 
63 {
64  return mSlicer;
65 }
66 
68 {
69  mInvertPlane = on;
70  changedSlot();
71 }
72 
74 {
75  return mInvertPlane;
76 }
77 
81 Vector3D SlicePlaneClipper::getUnitNormal() const
82 {
83  if (mInvertPlane)
84  return Vector3D(0,0,1);
85  else
86  return Vector3D(0,0,-1);
87 }
88 
92 {
93  vtkPlanePtr retval = vtkPlanePtr::New();
94  retval->SetNormal(mClipPlane->GetNormal());
95  retval->SetOrigin(mClipPlane->GetOrigin());
96  return retval;
97 }
98 
100 {
101  return mClipPlane;
102 }
103 
104 void SlicePlaneClipper::updateClipPlane()
105 {
106  if (!mSlicer)
107  return;
108  if (!mClipPlane)
109  mClipPlane = vtkPlanePtr::New();
110 
111  Transform3D rMs = mSlicer->get_sMr().inv();
112 
113  Vector3D n = rMs.vector(this->getUnitNormal());
114  Vector3D p = rMs.coord(Vector3D(0,0,0));
115  mClipPlane->SetNormal(n.begin());
116  mClipPlane->SetOrigin(p.begin());
117 }
118 
119 void SlicePlaneClipper::changedSlot()
120 {
121  if (!mSlicer)
122  return;
123 
124  this->updateClipPlane();
125  emit slicePlaneChanged();
126 }
127 
128 } // namespace cx
cx::SlicePlaneClipperPtr
boost::shared_ptr< class SlicePlaneClipper > SlicePlaneClipperPtr
Definition: cxForwardDeclarations.h:90
cx::SlicePlaneClipper::setSlicer
void setSlicer(SliceProxyPtr slicer)
Definition: cxSlicePlaneClipper.cpp:44
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::SlicePlaneClipper::slicePlaneChanged
void slicePlaneChanged()
cx::SlicePlaneClipper::New
static SlicePlaneClipperPtr New()
Definition: cxSlicePlaneClipper.cpp:30
cx::SlicePlaneClipper
Clip several 3D volumes using a SliceProxy.
Definition: cxSlicePlaneClipper.h:44
cx::SliceProxyPtr
boost::shared_ptr< class SliceProxy > SliceProxyPtr
Definition: cxForwardDeclarations.h:96
cx::SlicePlaneClipper::setInvertPlane
void setInvertPlane(bool on)
Definition: cxSlicePlaneClipper.cpp:67
cxSlicePlaneClipper.h
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::SlicePlaneClipper::~SlicePlaneClipper
~SlicePlaneClipper()
Definition: cxSlicePlaneClipper.cpp:40
vtkPlanePtr
vtkSmartPointer< class vtkPlane > vtkPlanePtr
Definition: cxProbeSector.cpp:33
cx::SlicePlaneClipper::getClipPlaneCopy
vtkPlanePtr getClipPlaneCopy()
Definition: cxSlicePlaneClipper.cpp:91
cx::SlicePlaneClipper::getClipPlane
vtkPlanePtr getClipPlane()
Definition: cxSlicePlaneClipper.cpp:99
cx::SlicePlaneClipper::getSlicer
SliceProxyPtr getSlicer()
Definition: cxSlicePlaneClipper.cpp:62
cxSliceProxy.h
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::SlicePlaneClipper::getInvertPlane
bool getInvertPlane() const
Definition: cxSlicePlaneClipper.cpp:73