#include #include #include #include #include #include #include #include #include #include #include #include #define BOOST_FILESYSTEM_VERSION 3 #define BOOST_FILESYSTEM_NO_DEPRECATED #include "boost/filesystem.hpp" namespace fs = ::boost::filesystem; // return the filenames of all files that have the specified extension // in the specified directory and all subdirectories void get_all(const fs::path& root, const string& ext, vector& ret) { if(!fs::exists(root) || !fs::is_directory(root)) return; fs::recursive_directory_iterator it(root); fs::recursive_directory_iterator endit; while(it != endit) { if(fs::is_regular_file(*it) && it->path().extension() == ext) ret.push_back(it->path().filename()); ++it; } } int main(int argc, char *argv[]) { vtkSmartPointer volume = vtkSmartPointer::New(); double isoValue; vtkSmartPointer reader = vtkSmartPointer::New(); fs::path r{"/Users/paulsmith/Documents/MarchingCubes2/axmaxilla"}; string e = ".png"; vector pp; get_all(&r, &e, &pp); vtkStringArray fn; fn.SetNumberOfValues(pp.size()); for (int i = 0; i < pp.size(); i++) fn.SetValue(i, pp[i].string()); reader->SetFileNames(fn); // hoping to eventually adapt x and y sizes to those of the pngs reader->SetDataExtent(0, 269, 0, 146, 0, pp.size()-1); reader->SetDataScalarTypeToUnsignedChar(); reader->Update(); volume->DeepCopy(reader->GetOutput()); isoValue = 1; vtkSmartPointer surface = vtkSmartPointer::New(); #if VTK_MAJOR_VERSION <= 5 surface->SetInput(volume); #else surface->SetInputData(volume); #endif surface->ComputeNormalsOn(); surface->SetValue(0, isoValue); vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->SetBackground(.1, .2, .3); vtkSmartPointer renderWindow = vtkSmartPointer::New(); renderWindow->AddRenderer(renderer); vtkSmartPointer interactor = vtkSmartPointer::New(); interactor->SetRenderWindow(renderWindow); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInputConnection(surface->GetOutputPort()); mapper->ScalarVisibilityOff(); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); renderer->AddActor(actor); renderWindow->Render(); interactor->Start(); return EXIT_SUCCESS; }