X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxSTLWidget_03.cxx;h=5d376a3d95a304eb92d3b9ffaa62330274eff087;hb=c85eb0d2045092682d9ec729097ba1a06084732c;hp=77154c39d26ff36edd722dc4ff60969c2a4fcd85;hpb=985e1ac15f538897e8252ce1eb9c175b3100d1b8;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx index 77154c3..5d376a3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + #include "vtkObjectFactory.h" @@ -526,17 +551,34 @@ void wxSTLWidget_03::ConfigureProcessing(vtkImageData *img, int x, int y, int z) //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]); //SIL// _cast = vtkImageCast::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _cast->SetInput(_thresh->GetOutput()); +#else + _cast->SetInputData(_thresh->GetOutput()); +#endif + _cast->SetOutputScalarTypeToUnsignedChar(); _connect = vtkImageSeedConnectivity::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _connect->SetInput(_cast->GetOutput()); +#else + _connect->SetInputData(_cast->GetOutput()); +#endif _connect->SetInputConnectValue(255); _connect->SetOutputConnectedValue(255); _connect->SetOutputUnconnectedValue(0); cast3 = vtkImageCast::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cast3->SetInput(_connect->GetOutput()); +#else + cast3->SetInputData(_connect->GetOutput()); +#endif cast3->SetOutputScalarTypeToUnsignedShort(); _thresh2 = vtkImageThreshold::New(); @@ -547,20 +589,40 @@ void wxSTLWidget_03::ConfigureProcessing(vtkImageData *img, int x, int y, int z) //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue()); cast2 = vtkImageCast::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cast2->SetInput(_thresh2->GetOutput()); +#else + cast2->SetInputData(_thresh2->GetOutput()); +#endif cast2->SetOutputScalarTypeToUnsignedChar(); _connect2 = vtkImageSeedConnectivity::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _connect2->SetInput(cast2->GetOutput()); +#else + _connect2->SetInputData(cast2->GetOutput()); +#endif _connect2->SetInputConnectValue(255); _connect2->SetOutputConnectedValue(255); _connect2->SetOutputUnconnectedValue(0); cast4 = vtkImageCast::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cast4->SetInput(_connect2->GetOutput()); +#else + cast4->SetInputData(_connect2->GetOutput()); +#endif cast4->SetOutputScalarTypeToUnsignedShort(); } _thresh->RemoveAllInputs(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _thresh->SetInput(_imagedata); +#else + _thresh->SetInputData(_imagedata); +#endif _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd()); _thresh->Update(); @@ -573,7 +635,14 @@ void wxSTLWidget_03::ConfigureProcessing(vtkImageData *img, int x, int y, int z) //cast3->Update(); //SIL// _thresh2->RemoveAllInputs(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _thresh2->SetInput(_imagedata); +#else + _thresh2->SetInputData(_imagedata); +#endif + _thresh2->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd()); _thresh2->Update(); cast2->Update(); @@ -662,9 +731,14 @@ void wxSTLWidget_03::ExtractSurface(int x, int y, int z) puntoactualprov[1] = y; puntoactualprov[2] = z; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _imagedata->UpdateInformation(); _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent()); _imagedata->Update(); +#else + // .. +#endif _imagedata->GetSpacing(espprin); _imagedata->GetExtent(extprin); @@ -702,13 +776,26 @@ void wxSTLWidget_03::ExtractSurface(int x, int y, int z) // Visualisation - result volume _2_isoMC6 = vtkMarchingCubes::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _2_isoMC6->SetInput(cast4->GetOutput()); +#else + _2_isoMC6->SetInputData(cast4->GetOutput()); +#endif _2_isoMC6->SetValue(0, 128); _2_isoMC6->Update(); _2_isoMapperMC6 = vtkPolyDataMapper::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _2_isoMapperMC6->SetInput(_2_isoMC6->GetOutput()); +#else + _2_isoMapperMC6->SetInputData(_2_isoMC6->GetOutput()); +#endif + + _2_isoMapperMC6->ScalarVisibilityOff(); _2_isoMapperMC6->ImmediateModeRenderingOn(); @@ -786,7 +873,7 @@ void wxSTLWidget_03::OnRangeSpin ( wxScrollEvent & event ) wxSlider *sl_B=_sl_RangeSizeSpin; int value = lastResizeRef_Value; - int delta = (int)pow( 4 , sl_B->GetValue() ); + int delta = (int)pow((double) 4 , (double)sl_B->GetValue() ); int startResized = value - delta/2; int endResized = value + delta/2; @@ -829,7 +916,12 @@ void wxSTLWidget_03::OnBtnSaveBinaryFile(wxCommandEvent& event) { vtkMetaImageWriter *writer= vtkMetaImageWriter::New(); writer->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 writer->SetInput(cast4->GetOutput()); +#else + writer->SetInputData(cast4->GetOutput()); +#endif writer->Write(); writer->Delete(); } @@ -917,7 +1009,12 @@ void wxSTLWidget_03::OnBtnSTLFileLoad(wxCommandEvent& event) vtkSTLReader *imgReader= vtkSTLReader::New(); imgReader->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) ); _loadSTLMapper = vtkPolyDataMapper::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _loadSTLMapper->SetInput(imgReader->GetOutput()); +#else + _loadSTLMapper->SetInputData(imgReader->GetOutput()); +#endif _loadActorSTL = vtkActor::New(); _loadActorSTL->SetMapper(_loadSTLMapper); _loadActorSTL->GetProperty()->SetColor( 1, 0, 0); @@ -949,7 +1046,12 @@ void wxSTLWidget_03::ConfigureSTL() stlInterna = vtkPolyData::New(); dsm1 = vtkPolyDataMapper ::New(); - dsm1->SetInput (stlInterna); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + dsm1->SetInput(stlInterna); +#else + dsm1->SetInputData(stlInterna); +#endif dsm1->ScalarVisibilityOff(); actorInternal = vtkActor::New(); @@ -957,7 +1059,14 @@ void wxSTLWidget_03::ConfigureSTL() actorInternal->GetProperty()->SetColor (0,1,0); dsm2 = vtkPolyDataMapper ::New(); - dsm2->SetInput (stlExterna); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + dsm2->SetInput(stlExterna); +#else + dsm2->SetInputData(stlExterna); +#endif + dsm2->ScalarVisibilityOff(); actorExternal= vtkActor::New(); @@ -1013,7 +1122,14 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event) // wxDirDialog dialog( this, "Choose a directory...", ( !dirSTL.IsEmpty( ) )?dirSTL: wxGetHomeDir( ) ); + + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE ); +#else + wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxFD_SAVE ); +#endif if( dialog.ShowModal( ) == wxID_OK ) @@ -1029,17 +1145,29 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event) // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares. - vtkTriangleFilter *filtro = vtkTriangleFilter::New(); + vtkClosePolyData *cpd = vtkClosePolyData::New(); + vtkTriangleFilter *filtro = vtkTriangleFilter::New(); + vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New(); + + // 1.2 se escribe a disco el archivo stl de la superficie interna +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 filtro->SetInput(stlInterna); - vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New(); pdcf->SetInput( filtro->GetOutput() ); - vtkClosePolyData *cpd = vtkClosePolyData::New(); cpd->SetInput( pdcf->GetOutput() ); - - // 1.2 se escribe a disco el archivo stl de la superficie interna cpd->Update(); +#else + filtro->SetInputData(stlInterna); + pdcf->SetInputData( filtro->GetOutput() ); + cpd->SetInputData( pdcf->GetOutput() ); +#endif vtkSTLWriter *writerI = vtkSTLWriter::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 writerI->SetInput( cpd->GetOutput() ); +#else + writerI->SetInputData( cpd->GetOutput() ); +#endif // prefix = fileprefix; filename=prefix+"_internal.stl"; writerI->SetFileName(filename.c_str()); @@ -1048,10 +1176,20 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event) writerI->Delete(); // 1.3 se escribe a disco el archivo stl de la superficie externa +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 filtro->SetInput(stlExterna); +#else + filtro->SetInputData(stlExterna); +#endif cpd->Update(); vtkSTLWriter *writerE = vtkSTLWriter::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 writerE->SetInput( cpd->GetOutput() ); +#else + writerE->SetInputData( cpd->GetOutput() ); +#endif // prefix = fileprefix; filename=prefix+"_external.stl"; writerE->SetFileName( filename.c_str() );