NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxSlices3DRep.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 /*
35  * sscSlices3DRep.cpp
36  *
37  * Created on: Oct 13, 2011
38  * Author: christiana
39  */
40 
41 #include "cxSlices3DRep.h"
42 
43 #include <vtkRenderer.h>
44 #include <vtkFloatArray.h>
45 #include <vtkPlaneSource.h>
46 #include <vtkPointData.h>
47 #include <vtkTriangleFilter.h>
48 #include <vtkStripper.h>
49 #include <vtkImageData.h>
50 #include <vtkLookupTable.h>
51 #include "cxLogger.h"
52 #include "cxImage.h"
53 #include "cxView.h"
54 #include "cxImageLUT2D.h"
55 #include "cxSliceProxy.h"
56 #include "cxTypeConversions.h"
57 #include "cxGPUImageBuffer.h"
58 #include "cxTexture3DSlicerProxy.h"
59 
60 #ifndef CX_VTK_OPENGL2
61 #include <vtkPainterPolyDataMapper.h>
62 #endif
63 
64 
65 
66 //---------------------------------------------------------
67 namespace cx
68 {
69 //---------------------------------------------------------
70 
72  RepImpl()
73 {
74 }
75 
77 {
78 }
79 
80 Slices3DRepPtr Slices3DRep::New(const QString& uid)
81 {
82  return wrap_new(new Slices3DRep(), uid);
83 }
84 
85 void Slices3DRep::setShaderPath(QString path)
86 {
87  for (unsigned i=0; i<mProxy.size(); ++i)
88  mProxy[i]->setShaderPath(path);
89 }
90 
91 void Slices3DRep::setImages(std::vector<ImagePtr> images)
92 {
93  if (images.empty())
94  {
95  reportWarning("Slices3DRep::setImages: No input images (in ViewGroup)");
96  return;
97  }
98  for (unsigned i=0; i<mProxy.size(); ++i)
99  {
100  mProxy[i]->setImages(images);
101  mProxy[i]->getSliceProxy()->setDefaultCenter(images[0]->get_rMd().coord(images[0]->boundingBox().center()));
102  }
103 }
104 
105 void Slices3DRep::addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
106 {
107  SliceProxyPtr sliceProxy = SliceProxy::create(dataManager);
108  sliceProxy->initializeFromPlane(plane, false, Vector3D(0,0,1), true, 150, 0.25);
109  sliceProxy->setAlwaysUseDefaultCenter(true);
110 
112  current->setSliceProxy(sliceProxy);
113  current->setTargetSpaceToR();
114 
115  mProxy.push_back(current);
116 }
117 
119 {
120  for (unsigned i=0; i<mProxy.size(); ++i)
121  mProxy[i]->getSliceProxy()->setTool(tool);
122 }
123 
125 {
126  for (unsigned i=0; i<mProxy.size(); ++i)
127  view->getRenderer()->AddActor(mProxy[i]->getActor());
128 }
129 
131 {
132  for (unsigned i=0; i<mProxy.size(); ++i)
133  view->getRenderer()->RemoveActor(mProxy[i]->getActor());
134 }
135 
136 //---------------------------------------------------------
137 }//end namespace
138 //---------------------------------------------------------
void setShaderPath(QString path)
static SliceProxyPtr create(PatientModelServicePtr dataManager)
boost::shared_ptr< class SliceProxy > SliceProxyPtr
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:83
static Texture3DSlicerProxyPtr New()
boost::shared_ptr< class View > ViewPtr
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
boost::shared_ptr< class Slices3DRep > Slices3DRepPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:91
virtual ~Slices3DRep()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Default implementation of Rep.
Definition: cxRepImpl.h:63
boost::shared_ptr< class Texture3DSlicerProxy > Texture3DSlicerProxyPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
void setImages(std::vector< ImagePtr > images)
virtual void addRepActorsToViewRenderer(ViewPtr view)
void setTool(ToolPtr tool)
void addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
static Slices3DRepPtr New(const QString &uid)
boost::shared_ptr< class Tool > ToolPtr