#JCP Ubuntu this file not found glibconfig.h, config of wxgtk goes wrong somewhere
-INCLUDE_DIRECTORIES(/usr/lib/x86_64-linux-gnu/glib-2.0/include/)
+INCLUDE_DIRECTORIES(/usr/lib/x86_64-linux-gnu/gtk-2.0/include/)
+LINK_DIRECTORIES(/usr/lib/x86_64-linux-gnu/)
#JCP Ubuntu this file not found glibconfig.h, config of wxgtk goes wrong somewhere
ADD_SUBDIRECTORY(install)
QtVTKViewerWidget *viewer = new QtVTKViewerWidget(mainwindow);
mainwindow-> setCentralWidget(viewer);
+ mainwindow->setMinimumSize(1024, 768);
-
- mainwindow->show();
+ mainwindow->showMaximized();
if(img)
viewer->setImage(img);
Program: wxMaracas
Module: $RCSfile: wxMaracasSurfaceRenderingManager.cxx,v $
Language: C++
- Date: $Date: 2011/10/05 16:26:55 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2012/05/11 11:46:37 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
+
#include "wxMaracasSurfaceRenderingManager.h"
#include "wxMaracasSurfaceRenderingManagerDataMhd.h"
-
-#include "vtkPLYReader.h"
-#include "vtkSmartPointer.h"
-
/**
** Start of the manager class
**/
_renderer = NULL;
_interactor = NULL;
_idCount=0;
+ image = 0;
}
wxMaracasSurfaceRenderingManager::~wxMaracasSurfaceRenderingManager(){
}
}
return -1;
}
+
+/**
+** Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+**/
+/**
+** Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+**/
+int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, std::string filename, std::string dataname){
+
+
+ wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerData(filename, _interactor);
+ if(dataname.compare("") != 0)
+ data->setDataname(dataname);
+
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ if(idTP == -1)
+ {
+ data->setId(_idCount);
+ _idCount++;
+ }
+ else
+ {
+ data->setId(idTP);
+ }
+ return data->getId();
+
+}
+
int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imagedata, std::string dataname) throw(char*){
checkInvariant();
if(imagedata != NULL){
/**
** adds or removes an actor depending of the bool value
**/
-void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove) throw(char*){
+bool wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove) throw(char*){
checkInvariant();
wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
_renderer->RemoveViewProp(data->getProp3D());
}
_renderer->Render();
+ return true;
}else {
if(addremove && propid == 0 && image){
addPropMHD(0, image, "id0");
+ return true;
}
- return;
}
+ return false;
}
/**
** adds or removes the surface box depending of the bool value
_renderer->Render();
}
-vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
+/*vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
if(filename.compare("")!= 0){
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
plyreader->SetFileName(filename.c_str());
plyreader->Update();
polydata->DeepCopy(plyreader->GetOutput());
+ }else if(ext.compare(VTK)==0){
+ vtkSmartPointer<vtkPolyDataReader> polyreader =vtkSmartPointer<vtkPolyDataReader>::New();
+ polyreader->SetFileName(filename.c_str());
+ polyreader->Update();
+ polydata->DeepCopy(polyreader->GetOutput());
}
vtkSmartPointer<vtkPolyDataMapper> dataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
return dataActor;
}
return NULL;
-}
+}*/
vtkImageData* wxMaracasSurfaceRenderingManager::getImageData(std::string filename){
if(filename.compare("")!= 0){
}
wxMaracasSurfaceRenderingManagerData* wxMaracasSurfaceRenderingManager::getViewData(int id) throw(char*){
- int i;
+ int i = 0;
for(i = 0; i < (int)(prop3Dvect.size());i++){
if(prop3Dvect[i]->getId() == id){
return prop3Dvect[i];
}
- }
- return 0;
+ }
#ifndef USE_QT
throw "id not found in the data";
#else
- return NULL;
+ return 0;
#endif
}
void wxMaracasSurfaceRenderingManager::loadProp3DSTL(const char* filename){
- this->addProp3D(-1, this->getProp3D(filename), filename);
+ this->addProp3D(-1, filename);
+}
+
+void wxMaracasSurfaceRenderingManager::exportImageStencil(int propid,const char* filename){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+ if(data && data->getProp3D()!=NULL){
+ data->exportImageStencil(filename);
+ }
}
Program: wxMaracas
Module: $RCSfile: wxMaracasSurfaceRenderingManager.h,v $
Language: C++
- Date: $Date: 2011/10/05 16:26:55 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2012/05/11 11:46:37 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
** Adds a prop3D to the manager and returns the identifier
**/
int addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname) throw (char*);
+
+ /**
+ ** Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+ **/
+ int addProp3D(int idTP, std::string filename, std::string dataname = "");
+
/**
** Adds a prop3D to the manager and returns the identifier
**/
/**
** loads a prop3D from a nSTL file
**/
- vtkProp3D* getProp3D(std::string filename);
+ //vtkProp3D* getProp3D(std::string filename);
/**
** loads a MHD file to convert it into an actor
/**
** adds or removes an actor depending of the bool value
**/
- void addRemoveActor(int propid, bool addremove)throw(char*);
+ bool addRemoveActor(int propid, bool addremove)throw(char*);
/**
**
**/
void loadProp3DSTL(const char* filename);
+ void exportImageStencil(int propid,const char* filename);
private:
std::vector<wxMaracasSurfaceRenderingManagerData*> prop3Dvect;
this->ui->tabWidgetSurface->removeTab(1);
this->ui->tabWidgetSurface->removeTab(0);
-
QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);
this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
Renderer = 0;
Interactor = 0;
}
+void QtSurfaceRenderer::SetRenderer(vtkRenderer* render){
+ Renderer = render;
+ this->ui->tabWidgetSurface->setCurrentIndex(0);
+ QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+ surfacepanel->setRenderer(Renderer);
+}
+
+void QtSurfaceRenderer::SetInteractor(vtkRenderWindowInteractor* interactor){
+ Interactor = interactor;
+ this->ui->tabWidgetSurface->setCurrentIndex(0);
+ QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+ surfacepanel->setInteractor(Interactor);
+}
QtSurfaceRenderer::~QtSurfaceRenderer()
{
void QtSurfaceRenderer::SetImageData(vtkImageData* img){
this->ui->tabWidgetSurface->setCurrentIndex(0);
- QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
- surfacepanel->setInteractor(Interactor);
- surfacepanel->setRenderer(Renderer);
+ QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
surfacepanel->setImageData(img);
}
~QtSurfaceRenderer();
- vtkSetMacro(Renderer, vtkRenderer*);
- vtkSetMacro(Interactor, vtkRenderWindowInteractor*);
+ void SetRenderer(vtkRenderer* render);
+ void SetInteractor(vtkRenderWindowInteractor* interactor);
void SetImageData(vtkImageData* img);
private slots:
this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
- this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
+ //this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
+
+ this->ui->comboBoxSave->addItem(QIcon(Save_xpm), QString(""));
+ this->ui->comboBoxSave->addItem(QString("Save surface"));
+ this->ui->comboBoxSave->addItem(QString("Export image stencil"));
+ _ImageSet = false;
}
QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
wxMaracasSurfaceRenderingManager::setImageData(img);
+ _ImageSet = true;
}
void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
{
- this->addRemoveActor(0, checked);
- if(!checked){
+ if(!this->addRemoveActor(0, checked)){
+ this->ui->checkBox->setChecked(false);
+ }else if(!checked){
this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
this->on_checkBoxBoundingBox_clicked(false);
}
}
void QtSurfaceRendererPanel::onIsoValueChanged(){
- this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
+ if(_ImageSet)
+ this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
}
-void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
+/*void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
{
QString filename = QFileDialog::getSaveFileName(this,
tr("Save Mesh File"),
QDir::currentPath(),
- tr("Mesh files (*.stl *.ply)") );
+ tr("Mesh files (*.stl *.ply *.vtk)") );
if( !filename.isNull() ){
//filename.append(".stl");
this->saveProp3DSTL(0, filename.toStdString().c_str());
}
-}
+}*/
void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
{
void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
{
- QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(), tr("Mesh files (*.stl *.ply)"));
+ QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(), tr("Mesh files (*.stl *.ply *.vtk)"));
if(!filename.isNull()){
this->loadProp3DSTL(filename.toStdString().c_str());
+ this->ui->checkBox->setCheckState(Qt::Checked);
+ }
+}
+
+void QtSurfaceRendererPanel::on_comboBoxSave_activated(int index)
+{
+ if(index == 1){
+ QString filename = QFileDialog::getSaveFileName(this,
+ tr("Save Mesh File"),
+ QDir::currentPath(),
+ tr("Mesh files (*.stl *.ply *.vtk)") );
+
+ if( !filename.isNull() ){
+ //filename.append(".stl");
+ this->saveProp3DSTL(0, filename.toStdString().c_str());
+ }
+ }else if(index == 2){
+
+ QString filename = QFileDialog::getSaveFileName(this,
+ tr("Save Image File"),
+ QDir::currentPath(),
+ tr("Meta Image file (*.mhd)") );
+
+ if( !filename.isNull() ){
+
+ this->exportImageStencil(0, filename.toStdString().c_str());
+ }
}
+ this->ui->comboBoxSave->setCurrentIndex(0);
}
void on_horizontalSliderMinIso_sliderReleased();
- void on_pushButtonSave_clicked();
+ //void on_pushButtonSave_clicked();
void on_checkBoxBoundingBox_clicked(bool checked);
void on_pushButtonOpen_clicked();
+ void on_comboBoxSave_activated(int index);
+
private:
Ui::QtSurfaceRendererPanel *ui;
void onIsoValueChanged();
+
+ bool _ImageSet;
};
#endif // QTSURFACERENDERERPANEL_H
<rect>
<x>0</x>
<y>0</y>
- <width>197</width>
- <height>299</height>
+ <width>252</width>
+ <height>362</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
+ <item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Show</string>
</widget>
</item>
<item row="1" column="1">
- <widget class="QPushButton" name="pushButtonSave">
+ <widget class="QComboBox" name="comboBoxSave">
<property name="enabled">
<bool>false</bool>
</property>
- <property name="text">
- <string/>
+ <property name="toolTip">
+ <string>Save current surface or export an image using stencil</string>
</property>
- <property name="icon">
- <iconset>
- <normaloff>../../../../data/Icons/Save.xpm</normaloff>../../../../data/Icons/Save.xpm</iconset>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="currentIndex">
+ <number>-1</number>
+ </property>
+ <property name="maxVisibleItems">
+ <number>2</number>
</property>
</widget>
</item>
<y>18</y>
</hint>
<hint type="destinationlabel">
- <x>136</x>
- <y>21</y>
+ <x>242</x>
+ <y>30</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>toggled(bool)</signal>
- <receiver>pushButtonSave</receiver>
+ <receiver>OpacitySlider</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>56</x>
- <y>20</y>
+ <x>43</x>
+ <y>19</y>
</hint>
<hint type="destinationlabel">
- <x>216</x>
- <y>50</y>
+ <x>83</x>
+ <y>170</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>toggled(bool)</signal>
- <receiver>OpacitySlider</receiver>
+ <receiver>horizontalSliderMinIso</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>43</x>
- <y>19</y>
+ <x>36</x>
+ <y>15</y>
</hint>
<hint type="destinationlabel">
- <x>73</x>
- <y>125</y>
+ <x>38</x>
+ <y>283</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>toggled(bool)</signal>
- <receiver>horizontalSliderMinIso</receiver>
+ <receiver>horizontalSliderMaxIso</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>36</x>
- <y>15</y>
+ <x>42</x>
+ <y>22</y>
</hint>
<hint type="destinationlabel">
- <x>28</x>
- <y>367</y>
+ <x>102</x>
+ <y>351</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>toggled(bool)</signal>
- <receiver>horizontalSliderMaxIso</receiver>
+ <receiver>comboBoxSave</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>42</x>
- <y>22</y>
+ <x>88</x>
+ <y>19</y>
</hint>
<hint type="destinationlabel">
- <x>92</x>
- <y>434</y>
+ <x>126</x>
+ <y>53</y>
</hint>
</hints>
</connection>
${QT_LIBRARIES}
QVTK
-#EED GUIQtVolumeRenderer
-#EED GUIQtSurfaceRenderer
-#EED KernelViewerWidgets
+ GUIQtVolumeRenderer
+ GUIQtSurfaceRenderer
+ KernelViewerWidgets
# If this library must link against other libraries
# USER! : Add here any extra Library you need
{
- this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
+ vtkRenderer* renderer = vtkRenderer::New();
+ this->GetRenderWindow()->AddRenderer(renderer);
this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
void QtVTKViewerWidget::setImage(vtkImageData* img){
+ ui->checkBoxShowPlanes->setChecked(true);
ui->_qtvtkviewer->setImage(img);
ui->m_VolumeRender->SetImageData(img);
ui->m_SurfaceRender->SetImageData(img);
<attribute name="label">
<string>Image Widget</string>
</attribute>
- <widget class="QWidget" name="">
+ <widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>201</width>
- <height>246</height>
+ <height>260</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<string>Show Planes</string>
</property>
<property name="checked">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="tristate">
<bool>false</bool>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <zorder>toolBox</zorder>
- <zorder>toolBox</zorder>
- <zorder>toolBox</zorder>
</widget>
</item>
</layout>
double* range = ImageData->GetScalarRange();
vector<double> greylevel;
- greylevel.push_back(0);
- greylevel.push_back(1);
+ greylevel.push_back(0); //first grey level
+ //greylevel.push_back(1);
+ greylevel.push_back(10);
+ greylevel.push_back(20);
greylevel.push_back(range[1]);
vector<double> vectvalue;
+ vectvalue.push_back(0); //first opacity value
+ //vectvalue.push_back(value/100.0);
vectvalue.push_back(0);
vectvalue.push_back(value/100.0);
vectvalue.push_back(value/100.0);
Program: wxMaracas
Module: $RCSfile: wxMaracasSurfaceRendering.cxx,v $
Language: C++
- Date: $Date: 2011/06/28 16:56:16 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2012/05/11 11:46:39 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
}
void wxMaracasSurfaceRendering::loadProp3D(wxString filename, wxString dataname){
- std::string s = std::string(filename.mb_str());
- vtkProp3D* prop3D = surrendmanager->getProp3D(s);
+ std::string fn = std::string(filename.mb_str());
+ std::string dn = std::string(dataname.mb_str());
+
+ int id = surrendmanager->addProp3D(-1, fn, dn);
+
+ if(id!=-1){
+ wxMaracasSurfaceRenderingPanel* controlpan = new wxMaracasSurfaceRenderingProp3D(this, id, false, -1);
+ addSurfaceRenderingPanel(controlpan, dn);
+ }
+ /*vtkProp3D* prop3D = surrendmanager->getProp3D(s);
if(prop3D != NULL){
s = std::string(dataname.mb_str() );
this->addProp3D(prop3D,s);
}else{
//TODO msj to the user indicating error in file
- }
+ }*/
}
void wxMaracasSurfaceRendering::addProp3D(vtkProp3D* prop3D, std::string dataname){
--- /dev/null
+#include "surfacerenderingimagestencilexport.h"
+
+#include "vtkObjectFactory.h"
+#include "vtkMetaImageWriter.h"
+
+#include "math.h"
+
+vtkStandardNewMacro(SurfaceRenderingImageStencilExport)
+
+SurfaceRenderingImageStencilExport::SurfaceRenderingImageStencilExport()
+{
+ ImageOutput = 0;
+}
+
+SurfaceRenderingImageStencilExport::~SurfaceRenderingImageStencilExport(){
+
+ if(ImageOutput){
+ ImageOutput->Delete();
+ }
+}
+
+void SurfaceRenderingImageStencilExport::Update(){
+ this->Execute(0);
+}
+
+void SurfaceRenderingImageStencilExport::Execute(vtkImageData *data){
+
+ vtkPolyData* polydata = (vtkPolyData*)this->GetInput();
+
+ vtkSmartPointer<vtkPolyDataToImageStencil> polytostencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
+ polytostencil->SetInput(polydata);
+ polytostencil->Update();
+
+ double *bounds = polydata->GetBounds();
+ vtkSmartPointer<vtkImageData> imagein = vtkSmartPointer<vtkImageData>::New();
+
+ imagein->SetExtent(bounds[0] - 1, bounds[1] + 1, bounds[2] - 1, bounds[3] + 1, bounds[4] - 1, bounds[5] + 1);
+ imagein->SetScalarTypeToUnsignedShort();
+ imagein->AllocateScalars();
+
+
+ int* extent = imagein->GetExtent();
+
+ for (int x = extent[0]; x <= extent[1]; x++){
+ for (int y = extent[2]; y <= extent[3]; y++){
+ for (int z =extent[4]; z <= extent[5]; z++){
+ unsigned short* pixel = static_cast<unsigned short*>(imagein->GetScalarPointer(x,y,z));
+ *pixel = 0;
+ }
+ }
+ }
+
+ vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
+ stencil->SetInput(imagein);
+ stencil->SetStencil(polytostencil->GetOutput());
+ stencil->ReverseStencilOn();
+ stencil->SetBackgroundValue(128);
+ stencil->Update();
+
+ if(ImageOutput){
+ ImageOutput->Delete();
+ }
+ ImageOutput = vtkImageData::New();
+ ImageOutput->DeepCopy(stencil->GetOutput());
+
+}
+
+vtkImageData* SurfaceRenderingImageStencilExport::GetOutput(){
+ return ImageOutput;
+}
--- /dev/null
+#ifndef SURFACERENDERINGIMAGESTENCILEXPORT_H
+#define SURFACERENDERINGIMAGESTENCILEXPORT_H
+
+#include <vtkDataSetToImageFilter.h>
+#include <vtkSmartPointer.h>
+#include <vtkPolyDataToImageStencil.h>
+#include <vtkImageStencil.h>
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+
+class SurfaceRenderingImageStencilExport : public vtkDataSetToImageFilter
+{
+public:
+ static SurfaceRenderingImageStencilExport *New();
+
+ vtkTypeMacro(SurfaceRenderingImageStencilExport,vtkDataSetToImageFilter)
+
+ virtual void Update();
+ vtkImageData* GetOutput();
+protected:
+
+ virtual void Execute(vtkImageData *data);
+
+private:
+
+ SurfaceRenderingImageStencilExport();
+ ~SurfaceRenderingImageStencilExport();
+
+ vtkImageData* ImageOutput;
+};
+
+#endif // SURFACERENDERINGIMAGESTENCILEXPORT_H
#include <vtkSmartPointer.h>
#include "vtkSTLWriter.h"
#include "vtkPLYWriter.h"
+#include "vtkPolyDataWriter.h"
+#include "surfacerenderingimagestencilexport.h"
+#include "vtkMetaImageWriter.h"
+#include "vtkPolyDataReader.h"
+#include "vtkPLYReader.h"
+#include "vtkSmartPointer.h"
/********************************************************************************************
** Start of data viewmanagerData
_boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );*/
}
+wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(string filename, vtkRenderWindowInteractor* interactor){
+
+ _prop3D = getProp3D(filename);
+ _dataname = filename;
+ _boxWidgetS1=NULL;
+
+ initializeBoxWidget(interactor);
+}
+
+vtkProp3D* wxMaracasSurfaceRenderingManagerData::getProp3D(std::string filename){
+
+ if(filename.compare("")!= 0){
+
+ vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
+ std::string ext = filename.substr(filename.find_last_of("."), 4);
+ if(ext.compare(STL)==0){
+ vtkSmartPointer<vtkSTLReader> STLReader=vtkSmartPointer<vtkSTLReader>::New();
+ STLReader->SetFileName(filename.c_str());
+ STLReader->Update();
+ polydata->DeepCopy(STLReader->GetOutput());
+
+ }else if(ext.compare(PLY)==0){
+ vtkSmartPointer<vtkPLYReader> plyreader =vtkSmartPointer<vtkPLYReader>::New();
+ plyreader->SetFileName(filename.c_str());
+ plyreader->Update();
+ polydata->DeepCopy(plyreader->GetOutput());
+ }else if(ext.compare(VTK)==0){
+ vtkSmartPointer<vtkPolyDataReader> polyreader =vtkSmartPointer<vtkPolyDataReader>::New();
+ polyreader->SetFileName(filename.c_str());
+ polyreader->Update();
+ polydata->DeepCopy(polyreader->GetOutput());
+ }
+
+ _dataMapper = vtkPolyDataMapper::New();
+ _dataMapper->SetInput(polydata);
+
+ vtkActor* dataActor = vtkActor::New();
+ dataActor->SetMapper(_dataMapper);
+ dataActor->GetProperty()->SetOpacity(1);
+ return dataActor;
+ }
+ return NULL;
+}
wxMaracasSurfaceRenderingManagerData::~wxMaracasSurfaceRenderingManagerData(){
plywriter->SetFileName(filename);
plywriter->SetInput(_dataMapper->GetInput());
plywriter->Write();
- }else if(ext.compare(PLY) == 0){
+ }else if(ext.compare(STL) == 0){
vtkSmartPointer<vtkSTLWriter> stlWriter =
vtkSmartPointer<vtkSTLWriter>::New();
stlWriter->SetFileName(filename);
stlWriter->SetInput(_dataMapper->GetInput());
stlWriter->SetFileTypeToBinary();
stlWriter->Write();
+ }else if(ext.compare(VTK) == 0){
+ vtkSmartPointer<vtkPolyDataWriter> polydataWriter =
+ vtkSmartPointer<vtkPolyDataWriter>::New();
+ polydataWriter->SetFileName(filename);
+ polydataWriter->SetInput(_dataMapper->GetInput());
+ polydataWriter->SetFileTypeToBinary();
+ polydataWriter->Write();
}else{
cout<<"unsupported format"<<endl;
}
}
+void wxMaracasSurfaceRenderingManagerData::exportImageStencil(const char* filename){
+ if(_dataMapper){
+ vtkSmartPointer< SurfaceRenderingImageStencilExport> stencilexport = vtkSmartPointer< SurfaceRenderingImageStencilExport >::New();
+ stencilexport->SetInput( _dataMapper->GetInput());
+ stencilexport->Update();
+ vtkImageData* imgstencil = stencilexport->GetOutput();
+
+ vtkSmartPointer<vtkMetaImageWriter> metawriter = vtkSmartPointer<vtkMetaImageWriter>::New();
+ metawriter->SetFileName(filename);
+ metawriter->SetInput(imgstencil);
+ metawriter->Write();
+ }else{
+ cout<<"No poly data set to data mapper."<<endl;
+ }
+
+}
+
#define PLY ".ply"
#define STL ".stl"
+#define VTK ".vtk"
+using namespace std;
class wxMaracasSurfaceRenderingManagerData {
public:
wxMaracasSurfaceRenderingManagerData(vtkProp3D* _prop3Dvect, std::string dataname="", vtkRenderWindowInteractor* interactor=NULL);
+ wxMaracasSurfaceRenderingManagerData(string filename, vtkRenderWindowInteractor* interactor);
~wxMaracasSurfaceRenderingManagerData();
/**
virtual void enableBoxWidget(bool enable);
+ void exportImageStencil(const char* filename);
+
+ vtkProp3D* getProp3D(std::string filename);
protected:
vtkPolyDataMapper* _dataMapper;
/**
_maxgreylevel = getMaxLevel(imagedata);
_prop3D=NULL;
+ _tresholdFilter = vtkImageThreshold::New();
+ _tresholdFilter->SetInput(this->_imagedata);
+ _tresholdFilter->SetInValue(255);
+ _tresholdFilter->SetOutValue(0);
+
+
_cubesFilter = vtkMarchingCubes::New();
- _cubesFilter->SetInput(this->_imagedata);
- _cubesFilter->ComputeGradientsOn ();
- _cubesFilter->ComputeScalarsOn ();
- _cubesFilter->SetNumberOfContours( 1 );
+ _cubesFilter->SetInput(_tresholdFilter->GetOutput());
+ //_cubesFilter->ComputeGradientsOn();
+ _cubesFilter->ComputeScalarsOn();
+ _cubesFilter->ComputeNormalsOn();
+ _cubesFilter->SetNumberOfContours( 1 );
_cleanFilter = vtkCleanPolyData::New();
_cleanFilter->SetInput ( _cubesFilter->GetOutput() );
+ _smooth = vtkSmoothPolyDataFilter::New();
+ _smooth->SetInput(_cleanFilter->GetOutput());
+ _smooth->SetNumberOfIterations(6);
+ _smooth->SetRelaxationFactor(0.3);
+ //_smooth->FeatureEdgeSmoothingOff();
+
_dataMapper = vtkPolyDataMapper::New( );
_dataMapper->ScalarVisibilityOff( );
_dataMapper->ImmediateModeRenderingOn();
boxSurfaceObserver* observer = boxSurfaceObserver::New();
vtkStripper* striper = vtkStripper::New();
- striper->SetInput( _cleanFilter->GetOutput() );
- //striper->SetInput( _cubesFilter->GetOutput() );
+ striper->SetInput( _smooth->GetOutput() );
+ //striper->SetInput( _cleanFilter->GetOutput() );
striper->Update();
_boxWidgetS1->SetInput(striper->GetOutput());
_boxWidgetS1->HandlesOn ();
_boxWidgetS1->EnabledOff();
}else{
- _dataMapper->SetInput(_cleanFilter->GetOutput());
+ //_dataMapper->SetInput(_cleanFilter->GetOutput());
+ _dataMapper->SetInput(_smooth->GetOutput());
}
dataActor->SetMapper(_dataMapper);
- this->_prop3D = dataActor;
+ float cr=1,cg=0.5,cb=0.5;
+ dataActor->GetProperty()->SetDiffuseColor(1,0.5,0.5 );
+ dataActor->GetProperty()->SetSpecular(.3);
+ dataActor->GetProperty()->SetSpecularPower(20);
-
+ this->_prop3D = dataActor;
this->changeIsoValue(this->_maxgreylevel);
void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){
- _cubesFilter->SetValue(0,value);
+ _tresholdFilter->ThresholdByLower(value);
+ _tresholdFilter->Update();
+
+ _cubesFilter->SetValue(0,255);
_cubesFilter->Update();
_cleanFilter->Update();
_dataMapper->Update();
**/
void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double min, double max){
-
- _cubesFilter->SetValue(min,max);
+ _tresholdFilter->ThresholdBetween(min, max);
+ _tresholdFilter->Update();
+ _cubesFilter->SetValue(0,255);
_cubesFilter->Update();
_cleanFilter->Update();
_dataMapper->Update();
#include "vtkImageData.h"
#include "vtkClipPolyData.h"
#include "vtkPlanes.h"
+#include "vtkImageThreshold.h"
+#include "vtkSmoothPolyDataFilter.h"
class wxMaracasSurfaceRenderingManagerDataMhd : public wxMaracasSurfaceRenderingManagerData {
vtkCleanPolyData* _cleanFilter;
vtkClipPolyData* _tissueClipper;
vtkPlanes* _tissuePlanes;
+ vtkImageThreshold * _tresholdFilter;
+ vtkSmoothPolyDataFilter* _smooth;
/**
** Get's the max grey level of the image
_volumeProperty = vtkVolumeProperty::New();
_volumeProperty->SetInterpolationTypeToLinear();
- //_volumeProperty->ShadeOn();
- _volumeProperty->DisableGradientOpacityOn();
- _tfun = vtkPiecewiseFunction::New();
+ _volumeProperty->ShadeOn();
+ _volumeProperty->SetAmbient(3);
+ _volumeProperty->SetDiffuse(0.2);
+ _volumeProperty->SetSpecular(0.5);
+ //_volumeProperty->DisableGradientOpacityOn();
+ _tfun = vtkPiecewiseFunction::New();
_volumeProperty->SetScalarOpacity(_tfun );
_ctfun = vtkColorTransferFunction::New();
}
void VolumeRendererManagerData::SetIndependentComponents(bool independent){
- if(!independent){
- _volumeProperty->IndependentComponentsOff();
- }else{
+ if(independent){
_volumeProperty->IndependentComponentsOn();
+ }else{
+ _volumeProperty->IndependentComponentsOff();
}
}
SET(${LIBRARY_NAME}_INSTALL_FOLDER ${LIBRARY_NAME})
SET(${LIBRARY_NAME}_LIBRARIES
- ${LIBRARY_NAME}
+
BaseVolumeRenderer
BaseSurfaceRenderer
KernelVolumeRenderer
KernelViewerWidgets
KernelSurfaceRenderer
+ ${LIBRARY_NAME}
)
# SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
#include "BrushFilter.h"
#include "FillFilter.h"
+
+//#include "regionStructUR.h"
+//#include "imageUndoRedo.h"
+
#include "imageModificationManager.h"
#include "imageUndoRedo.h"
+
class ManualPaintModel {
public:
ManualPaintModel();
#define _BASE_FILTER_MANUAL_PAINT_H_
#include <vtkImageData.h>
+
+//#include "regionStructUR.h"
+
#include "imageModificationManager.h"
+
class baseFilterManualPaint {
public: