Skip to content

Commit

Permalink
Added nii image "squircle.nii" +
Browse files Browse the repository at this point in the history
Updated example to work with a default dataset.
  • Loading branch information
ange-clement committed Apr 12, 2024
1 parent 0e9905c commit 3cb583a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Binary file added Data/data/images/squircle.nii
Binary file not shown.
2 changes: 1 addition & 1 deletion Mesh_3/examples/Mesh_3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support)
if(TARGET CGAL::CGAL_ImageIO)
if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION
VERSION_GREATER 5))
add_executable(mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp)
create_single_source_cgal_program("mesh_3D_gray_vtk_image.cpp")
target_link_libraries(
mesh_3D_gray_vtk_image
PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO
Expand Down
14 changes: 7 additions & 7 deletions Mesh_3/examples/Mesh_3/mesh_3D_gray_vtk_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ namespace fs = std::filesystem;
int main(int argc, char* argv[])
{
// Loads image
if(argc == 1){
std::cerr << "Usage: " << argv[0] << " <nii file or dicom directory> iso_level=1 facet_size=1 facet_distance=0.1 cell_size=1\n";
return 0;
}

// Usage: mesh_3D_gray_vtk_image <nii file or dicom directory> iso_level=1 facet_size=1 facet_distance=0.1 cell_size=1

const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/squircle.nii");

vtkImageData* vtk_image = nullptr;
Image_word_type iso = (argc>2)? boost::lexical_cast<Image_word_type>(argv[2]): 1;
double fs = (argc>3)? boost::lexical_cast<double>(argv[3]): 1;
double fd = (argc>4)? boost::lexical_cast<double>(argv[4]): 0.1;
double cs = (argc>5)? boost::lexical_cast<double>(argv[5]): 1;

fs::path path(argv[1]);
fs::path path(fname);

if(fs::is_regular_file(path)){
std::cout << "regular file" << std::endl;
if (path.has_extension()){
fs::path stem = path.stem();
if ((path.extension() == ".nii") || (stem.has_extension() && (stem.extension() == ".nii") && (path.extension() == ".gz"))) {
vtkNIFTIImageReader* reader = vtkNIFTIImageReader::New();
reader->SetFileName(argv[1]);
reader->SetFileName(fname.c_str());
reader->Update();
vtk_image = reader->GetOutput();
vtk_image->Print(std::cerr);
Expand Down Expand Up @@ -111,7 +111,7 @@ int main(int argc, char* argv[])
Mesh_domain domain = Mesh_domain::create_gray_image_mesh_domain
(image,
params::image_values_to_subdomain_indices(Less(iso)).
value_outside(0));
value_outside(iso+1));
/// [Domain creation]

// Mesh criteria
Expand Down

0 comments on commit 3cb583a

Please sign in to comment.