CustusX  22.04-rc5
An IGT application
cxMeshInView.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 #include "cxMeshInView.h"
12 
13 #include "cxMesh.h"
14 #include "cxGeometricRep.h"
15 #include "cxViewService.h"
16 #include "cxView.h"
17 #include "cxLogger.h"
18 
19 namespace cx
20 {
21 
22 MeshInView::MeshInView(ViewServicePtr viewService) : mViewService(viewService)
23 {
24 
25 }
27 {
28  this->hide();
29 }
30 
32 {
33  if (!mRep)
34  {
35  MeshPtr mesh(new Mesh("mesh", "mesh"));
36  mesh->setColor(QColor("cornflowerblue"));
37 
38  mRep = GeometricRep::New();
39  mRep->setMesh(mesh);
40 
41  ViewPtr view = mViewService->get3DView();
42  if (view)
43  view->addRep(mRep);
44  }
45 
46  mRep->getMesh()->setVtkPolyData(polyData);
47 }
48 
50 {
51  ViewPtr view = mViewService->get3DView();
52  if (view)
53  view->removeRep(mRep);
54  mRep.reset();
55 }
56 
57 } // namespace cx
A mesh data set.
Definition: cxMesh.h:45
MeshInView(ViewServicePtr viewService)
boost::shared_ptr< class ViewService > ViewServicePtr
boost::shared_ptr< class View > ViewPtr
static GeometricRepPtr New(const QString &uid="")
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
void show(vtkPolyDataPtr polyData)
boost::shared_ptr< class Mesh > MeshPtr
Namespace for all CustusX production code.