From 83f1ac84b56a3ef6bb804108e0d0a55554886c97 Mon Sep 17 00:00:00 2001 From: jean-pierre roux Date: Thu, 15 Oct 2009 15:32:58 +0000 Subject: [PATCH] Linux vs Windoze --- appli/creaNewProject/creaNewProject.cpp | 28 +++++-------------------- src/creaVtk.h | 12 +++++------ src/creaVtk.txx | 20 +++++++++++------- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/appli/creaNewProject/creaNewProject.cpp b/appli/creaNewProject/creaNewProject.cpp index 9fb5c39..f529587 100644 --- a/appli/creaNewProject/creaNewProject.cpp +++ b/appli/creaNewProject/creaNewProject.cpp @@ -29,8 +29,8 @@ bool myApp::OnInit( ) if (name.IsEmpty()) return false; #if(_WIN32) - std::string command("creaNewProject.bat "); - std::string command1("creaSed.exe "); + std::string command("creaNewProject.bat "); + std::string command1("creaSed.exe "); std::string command2("del "); command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\""; @@ -38,11 +38,10 @@ bool myApp::OnInit( ) command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\""; if ( ! system ( command.c_str() ) ) { - system ( command1.c_str() ); system ( command2.c_str() ); wxMessageBox(_T("Done !"),_T("creaNewProject"), - wxOK | wxICON_INFORMATION); + wxOK | wxICON_INFORMATION); } else { @@ -51,12 +50,12 @@ bool myApp::OnInit( ) wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR); } #else - std::string command("creaNewProject.sh "); + std::string command("creaNewProject.sh "); command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name); if ( ! system ( command.c_str() ) ) { wxMessageBox(_T("Done !"),_T("creaNewProject"), - wxOK | wxICON_INFORMATION); + wxOK | wxICON_INFORMATION); } else { @@ -66,23 +65,6 @@ bool myApp::OnInit( ) } #endif - command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\""; - command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "PROJECT_NAME " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\""; - command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\""; - if ( ! system ( command.c_str() ) ) - { - - system ( command1.c_str() ); - system ( command2.c_str() ); - wxMessageBox(_T("Done !"),_T("creaNewProject"), - wxOK | wxICON_INFORMATION); - } - else - { - wxString err(_T("An error occured while running '")); - err += crea::std2wx(command) + _T("'"); - wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR); - } return false; } diff --git a/src/creaVtk.h b/src/creaVtk.h index 84510c7..b340382 100644 --- a/src/creaVtk.h +++ b/src/creaVtk.h @@ -8,15 +8,13 @@ namespace crea { - template - CREA_EXPORT vtkImageData* NewVtkImageDataFromRaw( T* data, - int nx, - int ny, - int nz, - bool do_not_desalloc = true); - + vtkImageData* CREA_EXPORT NewVtkImageDataFromRaw( T* data, + int nx, + int ny, + int nz, + bool do_not_desalloc = true); /* // Already provided by vtkTypeTraits::VTKTypeID() template diff --git a/src/creaVtk.txx b/src/creaVtk.txx index b0fe8b0..c4e7167 100644 --- a/src/creaVtk.txx +++ b/src/creaVtk.txx @@ -16,8 +16,7 @@ #include #include namespace crea -{ - +{ template /*CREA_EXPORT*/ vtkImageData* NewVtkImageDataFromRaw( T* data, int nx, @@ -27,12 +26,16 @@ namespace crea { // std::cout << "NV "<::SizedName() << std::endl; - vtkImageData *image = vtkImageData::New(); + vtkImageData *image = vtkImageData::New(); + + // Shouldn't we pass NumberOfScalarComponents to deal with RGB, RGBA images as well? // JPR + image->SetNumberOfScalarComponents(1); + int vtktype = vtkTypeTraits::VTKTypeID(); image->SetScalarType(vtktype); - image->SetDimensions(nx,ny,nz); - image->SetSpacing(1,1,1); + image->SetDimensions(nx, ny ,nz); + image->SetSpacing(1, 1, 1); image->AllocateScalars(); vtkDataArray* array = 0; switch (vtktype) @@ -65,13 +68,14 @@ namespace crea <<" non implemented"); } vtkDataArrayTemplate* tarray - = dynamic_cast*>(array); + = dynamic_cast*>(array); array->SetNumberOfComponents( 1 ); size_t size = (long)nx*(long)ny*(long)nz; // The last param of SetArray is set to 1 to keep the class from deleting the array // when it cleans up or reallocates memory. - int dndesa = 0; - if (do_not_desalloc) dndesa = 1; + int dndesa = 0; + if (do_not_desalloc) + dndesa = 1; tarray->SetArray( data, size, dndesa ); image->GetPointData( )->SetScalars( tarray ); array->Delete( ); -- 2.45.1