CustusX  15.8
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 <vtkPainterPolyDataMapper.h>
51 #include <vtkLookupTable.h>
52 #include "cxLogger.h"
53 #include "cxImage.h"
54 #include "cxView.h"
55 #include "cxImageLUT2D.h"
56 #include "cxSliceProxy.h"
57 #include "cxTypeConversions.h"
58 #include "cxGPUImageBuffer.h"
59 #include "cxTexture3DSlicerProxy.h"
60 
61 
62 //---------------------------------------------------------
63 namespace cx
64 {
65 //---------------------------------------------------------
66 
68  RepImpl()
69 {
70 }
71 
73 {
74 }
75 
76 Slices3DRepPtr Slices3DRep::New(const QString& uid)
77 {
78  return wrap_new(new Slices3DRep(), uid);
79 }
80 
81 void Slices3DRep::setShaderPath(QString path)
82 {
83  for (unsigned i=0; i<mProxy.size(); ++i)
84  mProxy[i]->setShaderPath(path);
85 }
86 
87 void Slices3DRep::setImages(std::vector<ImagePtr> images)
88 {
89  if (images.empty())
90  {
91  reportWarning("Slices3DRep::setImages: No input images (in ViewGroup)");
92  return;
93  }
94  for (unsigned i=0; i<mProxy.size(); ++i)
95  {
96  mProxy[i]->setImages(images);
97  mProxy[i]->getSliceProxy()->setDefaultCenter(images[0]->get_rMd().coord(images[0]->boundingBox().center()));
98  }
99 }
100 
101 void Slices3DRep::addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
102 {
103  SliceProxyPtr sliceProxy = SliceProxy::create(dataManager);
104  sliceProxy->initializeFromPlane(plane, false, Vector3D(0,0,1), true, 150, 0.25);
105  sliceProxy->setAlwaysUseDefaultCenter(true);
106 
108  current->setSliceProxy(sliceProxy);
109  current->setTargetSpaceToR();
110 
111  mProxy.push_back(current);
112 }
113 
115 {
116  for (unsigned i=0; i<mProxy.size(); ++i)
117  mProxy[i]->getSliceProxy()->setTool(tool);
118 }
119 
121 {
122  for (unsigned i=0; i<mProxy.size(); ++i)
123  view->getRenderer()->AddActor(mProxy[i]->getActor());
124 }
125 
127 {
128  for (unsigned i=0; i<mProxy.size(); ++i)
129  view->getRenderer()->RemoveActor(mProxy[i]->getActor());
130 }
131 
132 //---------------------------------------------------------
133 }//end namespace
134 //---------------------------------------------------------
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