diff --git a/AlignMesh/AlignMesh.cxx b/AlignMesh/AlignMesh.cxx new file mode 100644 index 0000000..cb4d643 --- /dev/null +++ b/AlignMesh/AlignMesh.cxx @@ -0,0 +1,77 @@ +#include "AlignMeshCLP.h" + + +// VTK Includes +#include "vtkDecimatePro.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" +#include "vtkNew.h" +#include "vtkCellLocator.h" + +//ITK Includes +#include "itkMesh.h" +#include "itkMeshFileReader.h" +#include "itkMeshFileWriter.h" +#include "itkLineCell.h" +#include "itkTriangleCell.h" +#include "itkImageFileWriter.h" +#include "itkResampleImageFilter.h" +#include "itkConstrainedValueAdditionImageFilter.h" +#include "itkBSplineInterpolateImageFunction.h" +#include "itkPluginUtilities.h" +#include +#include + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + try{ + typedef itk::DefaultDynamicMeshTraits MeshTraitsType; + + + typedef MeshTraitsType::PointType PointType; + + constexpr unsigned int Dimension = 3; + using InputPixelType = float; + + + using MeshType = itk::Mesh; + using MeshReaderType = itk::MeshFileReader; + + using MeshWriterType = itk::MeshFileWriter; + + MeshReaderType::Pointer meshReader = MeshReaderType::New(); + meshReader->SetFileName(inputVolume.c_str()); + // meshReader->Update(); + MeshType::Pointer mesh = meshReader->GetOutput(); + MeshType::PointsContainerPointer Points = mesh->GetPoints(); + int numberOfPoints = Points->Size(); + + MeshReaderType::Pointer meshReader2 = MeshReaderType::New(); + meshReader2->SetFileName(inputVolumeTwo.c_str()); + // meshReader->Update(); + MeshType::Pointer mesh2 = meshReader2->GetOutput(); + + + + + + MeshWriterType::Pointer writer = MeshWriterType::New(); + writer->SetInput(mesh); + writer->SetFileName(outputVolume.c_str()); + //writer->Update(); + + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + +} diff --git a/AlignMesh/AlignMesh.xml b/AlignMesh/AlignMesh.xml new file mode 100644 index 0000000..fe7de38 --- /dev/null +++ b/AlignMesh/AlignMesh.xml @@ -0,0 +1,36 @@ + + + Surface Models.Advanced + AlignMesh + + 0.0.1 + http://www.example.com/Slicer/Modules/AlignMesh + Slicer + FirstName LastName (Institution), FirstName LastName (Institution) + This work was partially funded by NIH grant NXNNXXNNNNNN-NNXN + + + + + inputVolume + + input + 0 + + + + inputVolumeTwo + + input + 1 + + + + outputVolume + + output + 2 + + + + diff --git a/AlignMesh/CMakeLists.txt b/AlignMesh/CMakeLists.txt new file mode 100644 index 0000000..be5ef55 --- /dev/null +++ b/AlignMesh/CMakeLists.txt @@ -0,0 +1,53 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME AlignMesh) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKIOMeshBase + ITKSmoothing + ITKLabelMap + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ${MRMLCore_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/AlignMesh/Data/Baseline/AlignMeshTest.nhdr.md5 b/AlignMesh/Data/Baseline/AlignMeshTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/AlignMesh/Data/Baseline/AlignMeshTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/AlignMesh/Data/Baseline/AlignMeshTest.raw.md5 b/AlignMesh/Data/Baseline/AlignMeshTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/AlignMesh/Data/Baseline/AlignMeshTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/AlignMesh/Data/Input/CTHeadAxial.nhdr.md5 b/AlignMesh/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/AlignMesh/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/AlignMesh/Data/Input/CTHeadAxial.raw.gz.md5 b/AlignMesh/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/AlignMesh/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/AlignMesh/Testing/CMakeLists.txt b/AlignMesh/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/AlignMesh/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/AlignMesh/Testing/Cxx/AlignMeshTest.cxx b/AlignMesh/Testing/Cxx/AlignMeshTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/AlignMesh/Testing/Cxx/AlignMeshTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/AlignMesh/Testing/Cxx/CMakeLists.txt b/AlignMesh/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/AlignMesh/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/AlignMeshICP/AlignMeshICP.cxx b/AlignMeshICP/AlignMeshICP.cxx new file mode 100644 index 0000000..4beabcb --- /dev/null +++ b/AlignMeshICP/AlignMeshICP.cxx @@ -0,0 +1,66 @@ +#include "AlignMeshICPCLP.h" + +// VTK Includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" +#include "vtkNew.h" +#include "vtkIterativeClosestPointTransform.h" +#include "vtkLandmarkTransform.h" +#include "vtkTransformPolyDataFilter.h" +#include "vtkAppendPolyData.h" + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + vtkSmartPointer source; + vtkSmartPointer target; + + // Read the file + vtkNew targetReader; + targetReader->SetFileName(inputVolume.c_str()); + targetReader->Update(); + target = targetReader->GetOutput(); + + vtkNew sourceReader; + sourceReader->SetFileName(inputVolumeTwo.c_str()); + sourceReader->Update(); + source = sourceReader->GetOutput(); + + + vtkNew icp; + icp->SetSource(source); + icp->SetTarget(target); + vtkSmartPointer transform = + icp->GetLandmarkTransform(); + transform->SetModeToRigidBody(); + icp->SetMaximumNumberOfIterations(20); + icp->StartByMatchingCentroidsOn(); + icp->Modified(); + icp->Update(); + + vtkNew icpTransformFilter; + icpTransformFilter->SetInputData(source); + icpTransformFilter->SetTransform(icp); + icpTransformFilter->Update(); + + //Write to file + vtkNew writer; + writer->SetFileName(outputVolume.c_str()); + writer->SetInputData(icpTransformFilter->GetOutput()); + writer->Update(); + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/AlignMeshICP/AlignMeshICP.xml b/AlignMeshICP/AlignMeshICP.xml new file mode 100644 index 0000000..6df6d07 --- /dev/null +++ b/AlignMeshICP/AlignMeshICP.xml @@ -0,0 +1,36 @@ + + + Surface Models.Advanced + AlignMeshICP + + 0.0.1 + http://www.example.com/Slicer/Modules/avgMesh + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + inputVolumeTwo + + input + 1 + + + + outputVolume + + output + 2 + + + + diff --git a/AlignMeshICP/CMakeLists.txt b/AlignMeshICP/CMakeLists.txt new file mode 100644 index 0000000..248cc83 --- /dev/null +++ b/AlignMeshICP/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME AlignMeshICP) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/AlignMeshICP/Data/Baseline/AlignMeshICPTest.nhdr.md5 b/AlignMeshICP/Data/Baseline/AlignMeshICPTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/AlignMeshICP/Data/Baseline/AlignMeshICPTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/AlignMeshICP/Data/Baseline/AlignMeshICPTest.raw.md5 b/AlignMeshICP/Data/Baseline/AlignMeshICPTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/AlignMeshICP/Data/Baseline/AlignMeshICPTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/AlignMeshICP/Data/Input/CTHeadAxial.nhdr.md5 b/AlignMeshICP/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/AlignMeshICP/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/AlignMeshICP/Data/Input/CTHeadAxial.raw.gz.md5 b/AlignMeshICP/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/AlignMeshICP/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/AlignMeshICP/Testing/CMakeLists.txt b/AlignMeshICP/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/AlignMeshICP/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/AlignMeshICP/Testing/Cxx/AlignMeshICPTest.cxx b/AlignMeshICP/Testing/Cxx/AlignMeshICPTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/AlignMeshICP/Testing/Cxx/AlignMeshICPTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/AlignMeshICP/Testing/Cxx/CMakeLists.txt b/AlignMeshICP/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/AlignMeshICP/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/GetCurvatures/CMakeLists.txt b/GetCurvatures/CMakeLists.txt new file mode 100644 index 0000000..1f760fb --- /dev/null +++ b/GetCurvatures/CMakeLists.txt @@ -0,0 +1,53 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME GetCurvatures) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKIOMeshBase + ITKSmoothing + ITKLabelMap + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ${MRMLCore_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/GetCurvatures/Data/Baseline/GetCurvaturesTest.nhdr.md5 b/GetCurvatures/Data/Baseline/GetCurvaturesTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/GetCurvatures/Data/Baseline/GetCurvaturesTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/GetCurvatures/Data/Baseline/GetCurvaturesTest.raw.md5 b/GetCurvatures/Data/Baseline/GetCurvaturesTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/GetCurvatures/Data/Baseline/GetCurvaturesTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/GetCurvatures/Data/Input/CTHeadAxial.nhdr.md5 b/GetCurvatures/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/GetCurvatures/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/GetCurvatures/Data/Input/CTHeadAxial.raw.gz.md5 b/GetCurvatures/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/GetCurvatures/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/GetCurvatures/GetCurvatures.cxx b/GetCurvatures/GetCurvatures.cxx new file mode 100644 index 0000000..25e5f19 --- /dev/null +++ b/GetCurvatures/GetCurvatures.cxx @@ -0,0 +1,126 @@ +#include "GetCurvaturesCLP.h" + +// VTK Includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkNew.h" +#include "vtkTransformFilter.h" +#include "vtkTransform.h" +#include "vtkPoints.h" +#include "vtkCurvatures.h" +#include "vtkPointData.h" +#include "vtkDoubleArray.h" + + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + + vtkSmartPointer polyData; + + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + vtkNew curveMax; + curveMax->SetInputData(polyData); + curveMax->SetCurvatureTypeToMaximum(); + curveMax->Update(); + + vtkSmartPointer polyDataCurveMax = curveMax->GetOutput(); + + vtkNew curveMin; + curveMin->SetInputData(polyData); + curveMin->SetCurvatureTypeToMinimum(); + curveMin->Update(); + vtkSmartPointer polyDataCurveMin = curveMin->GetOutput(); + + unsigned int nPoints = polyDataCurveMax->GetNumberOfPoints(); + vtkSmartPointer ArrayCurveMax = vtkDoubleArray::SafeDownCast( + polyDataCurveMax->GetPointData()->GetScalars() + ); + vtkSmartPointer ArrayCurveMin = vtkDoubleArray::SafeDownCast( + polyDataCurveMin->GetPointData()->GetScalars() + ); + + std::ofstream curvedness(outputCurve); + std::ofstream shapeIndex(outputShape); + std::ofstream gauss(outputGauss); + std::ofstream mean(outputMean); + + curvedness << "NUMBER_OF_POINTS=" << nPoints << std::endl; + curvedness << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl; + + shapeIndex << "NUMBER_OF_POINTS=" << nPoints << std::endl; + shapeIndex << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl; + + gauss << "NUMBER_OF_POINTS=" << nPoints << std::endl; + gauss << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl; + + mean << "NUMBER_OF_POINTS=" << nPoints << std::endl; + mean << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl; + + if( ArrayCurveMax && ArrayCurveMin ) + { + + for( unsigned int i = 0; i < nPoints; i++ ) + { + + float curvmax, curvmin; + curvmax = ArrayCurveMax->GetValue(i); + curvmin = ArrayCurveMin->GetValue(i); + + float aux = sqrt( (pow(curvmax, 2) + pow(curvmin, 2) ) / 2); + curvedness << aux << std::endl; + + aux = (2 / M_PI) * (atan( (curvmax + curvmin) / (curvmax - curvmin) ) ); + if( aux != aux ) + { + aux = 0; + } + shapeIndex << aux << std::endl; + + aux = curvmax * curvmin; + gauss << aux << std::endl; + + aux = (curvmax + curvmin) / 2; + mean << aux << std::endl; + // std::cout << "Curvature: " << curv << std::endl; + } + } + else + { + // std::cout << "Got no array?" << std::endl; + + curvedness.close(); + } + + curvedness.close(); + shapeIndex.close(); + gauss.close(); + mean.close(); + + //Write to file + //vtkNew writer; + //writer->SetFileName(outputVolume.c_str()); + //writer->SetInputData(polyData); + //writer->Update(); + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/GetCurvatures/GetCurvatures.xml b/GetCurvatures/GetCurvatures.xml new file mode 100644 index 0000000..c3c1188 --- /dev/null +++ b/GetCurvatures/GetCurvatures.xml @@ -0,0 +1,50 @@ + + + Surface Models.Advanced + GetCurvatures + + 0.0.1 + http://www.example.com/Slicer/Modules/GetCurvatures + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputCurve + + output + Curve Output File Name + + + + outputShape + + output + Shape Output File Name + + + + outputGauss + + output + Gauss Output File Name + + + + outputMean + + output + Mean Output File Name + + + + diff --git a/GetCurvatures/Testing/CMakeLists.txt b/GetCurvatures/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/GetCurvatures/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/GetCurvatures/Testing/Cxx/CMakeLists.txt b/GetCurvatures/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/GetCurvatures/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/GetCurvatures/Testing/Cxx/GetCurvaturesTest.cxx b/GetCurvatures/Testing/Cxx/GetCurvaturesTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/GetCurvatures/Testing/Cxx/GetCurvaturesTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/GetDirectionFeatures/CMakeLists.txt b/GetDirectionFeatures/CMakeLists.txt new file mode 100644 index 0000000..913239a --- /dev/null +++ b/GetDirectionFeatures/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME GetDirectionFeatures) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.nhdr.md5 b/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.raw.md5 b/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/GetDirectionFeatures/Data/Baseline/GetDirectionFeaturesTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/GetDirectionFeatures/Data/Input/CTHeadAxial.nhdr.md5 b/GetDirectionFeatures/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/GetDirectionFeatures/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/GetDirectionFeatures/Data/Input/CTHeadAxial.raw.gz.md5 b/GetDirectionFeatures/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/GetDirectionFeatures/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/GetDirectionFeatures/GetDirectionFeatures.cxx b/GetDirectionFeatures/GetDirectionFeatures.cxx new file mode 100644 index 0000000..89bea09 --- /dev/null +++ b/GetDirectionFeatures/GetDirectionFeatures.cxx @@ -0,0 +1,99 @@ +#include "GetDirectionFeaturesCLP.h" + +// VTK Includes +#include "vtkDecimatePro.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" +#include "vtkNew.h" +#include "vtkPoints.h" +#include "vtkPolyDataNormals.h" +#include "vtkDataArray.h" +#include "vtkPointData.h" + + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + vtkSmartPointer polyData; + + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + vtkIdType numPoints = polyData->GetNumberOfPoints(); + + double point[3], vectorx[3], vectory[3], vectorz[3]; + vectorx[0] = 1; vectorx[1] = 0; vectorx[2] = 0; + vectory[0] = 0; vectory[1] = 1; vectory[2] = 0; + vectorz[0] = 0; vectorz[1] = 0; vectorz[2] = 1; + + vtkNew meshNormals; + meshNormals->SetComputePointNormals(1); + meshNormals->SetComputeCellNormals(0); + meshNormals->SetSplitting(0); + meshNormals->SetInputData(polyData); + meshNormals->Update(); + + vtkSmartPointer vtkMeshNormals = meshNormals->GetOutput(); + + vtkSmartPointer Array = vtkDataArray::SafeDownCast(vtkMeshNormals->GetPointData()->GetNormals()); + + std::ofstream outfileVecX; + std::ofstream outfileVecY; + std::ofstream outfileVecZ; + + outfileVecX.open(vecXFile.c_str()); + outfileVecY.open(vecYFile.c_str()); + outfileVecZ.open(vecZFile.c_str()); + outfileVecX << "NUMBER_OF_POINTS = " << numPoints << std::endl; + outfileVecX << "DIMENSION = " << 1 << std::endl; + outfileVecX << "TYPE = Scalar" << std::endl; + + outfileVecY << "NUMBER_OF_POINTS = " << numPoints << std::endl; + outfileVecY << "DIMENSION = " << 1 << std::endl; + outfileVecY << "TYPE = Scalar" << std::endl; + + outfileVecZ << "NUMBER_OF_POINTS = " << numPoints << std::endl; + outfileVecZ << "DIMENSION = " << 1 << std::endl; + outfileVecZ << "TYPE = Scalar" << std::endl; + + + + for(vtkIdType i = 0; i GetTuple(i, point); + + double dotprodX = point[0] * vectorx[0] + point[1] * vectorx[1] + point[2] * vectorx[2]; + double dotprodY = point[0] * vectory[0] + point[1] * vectory[1] + point[2] * vectory[2]; + double dotprodZ = point[0] * vectorz[0] + point[1] * vectorz[1] + point[2] * vectorz[2]; + + outfileVecX << dotprodX << std::endl; + outfileVecY << dotprodY << std::endl; + outfileVecZ << dotprodZ << std::endl; + + } + + outfileVecX.close(); + outfileVecY.close(); + outfileVecZ.close(); + + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/GetDirectionFeatures/GetDirectionFeatures.xml b/GetDirectionFeatures/GetDirectionFeatures.xml new file mode 100644 index 0000000..dcd13b1 --- /dev/null +++ b/GetDirectionFeatures/GetDirectionFeatures.xml @@ -0,0 +1,47 @@ + + + Surface Models.Advanced + GetDirectionFeatures + + 0.0.1 + http://www.example.com/Slicer/Modules/GetDirectionFeatures + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + vecXFile + + output + Output File Name + + + vecYFile + + output + Output File Name + + + vecZFile + + output + Output File Name + + + diff --git a/GetDirectionFeatures/Testing/CMakeLists.txt b/GetDirectionFeatures/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/GetDirectionFeatures/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/GetDirectionFeatures/Testing/Cxx/CMakeLists.txt b/GetDirectionFeatures/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/GetDirectionFeatures/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/GetDirectionFeatures/Testing/Cxx/GetDirectionFeaturesTest.cxx b/GetDirectionFeatures/Testing/Cxx/GetDirectionFeaturesTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/GetDirectionFeatures/Testing/Cxx/GetDirectionFeaturesTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/ImportFromFile/CMakeLists.txt b/ImportFromFile/CMakeLists.txt new file mode 100644 index 0000000..d8e9b2d --- /dev/null +++ b/ImportFromFile/CMakeLists.txt @@ -0,0 +1,53 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME ImportFromFile) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKIOMeshBase + ITKSmoothing + ITKLabelMap + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ${MRMLCore_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/ImportFromFile/Data/Baseline/ImportFromFileTest.nhdr.md5 b/ImportFromFile/Data/Baseline/ImportFromFileTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/ImportFromFile/Data/Baseline/ImportFromFileTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/ImportFromFile/Data/Baseline/ImportFromFileTest.raw.md5 b/ImportFromFile/Data/Baseline/ImportFromFileTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/ImportFromFile/Data/Baseline/ImportFromFileTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/ImportFromFile/Data/Input/CTHeadAxial.nhdr.md5 b/ImportFromFile/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/ImportFromFile/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/ImportFromFile/Data/Input/CTHeadAxial.raw.gz.md5 b/ImportFromFile/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/ImportFromFile/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/ImportFromFile/ImportFromFile.cxx b/ImportFromFile/ImportFromFile.cxx new file mode 100644 index 0000000..ca31b33 --- /dev/null +++ b/ImportFromFile/ImportFromFile.cxx @@ -0,0 +1,68 @@ +#include "ImportFromFileCLP.h" + +// VTK Includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkNew.h" +#include "vtkTransformFilter.h" +#include "vtkTransform.h" +#include "vtkPoints.h" + + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + std::string line; + + // open inputFile + std::ifstream input, input2; + input2.open( inputFile ); + input2.seekg(0, std::ios::beg); + // calculate number of lines of the inputFilename + int numberOfLines = 0; + + while(std::getline(input, line)) + { + numberOfLines++; + } + input2.close(); + + numberOfLines = numberOfLines - 3; + + input.open(inputFile); + input.seekg(0, std::ios::beg); + + std::ofstream output; + output.open(outputFile); + output << "NUMBER_OF_POINTS= " << numberOfLines << std::endl; + output << "DIMENSION=1" << std::endl; + output << "TYPE=Scalar" << std::endl; + + // extract column 5 and write the values + while( std::getline(input, line) ) + { + float dummy, extractValue, point; + std::sscanf(line.c_str(), " %f %f %f %f %f ", &point, &dummy, &dummy, &dummy, &extractValue); + + } + + // close input&output + input.close(); + output.close(); + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/ImportFromFile/ImportFromFile.xml b/ImportFromFile/ImportFromFile.xml new file mode 100644 index 0000000..fd30e46 --- /dev/null +++ b/ImportFromFile/ImportFromFile.xml @@ -0,0 +1,29 @@ + + + Surface Models.Advanced + ImportFromFile + + 0.0.1 + http://www.example.com/Slicer/Modules/ImportFromFile + Slicer + Ben Wilson (Kitware) + + + + + + inputFile + + input + Input File Name + + + + outputFile + + output + Output File Name + + + + diff --git a/ImportFromFile/Testing/CMakeLists.txt b/ImportFromFile/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/ImportFromFile/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/ImportFromFile/Testing/Cxx/CMakeLists.txt b/ImportFromFile/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/ImportFromFile/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/ImportFromFile/Testing/Cxx/ImportFromFileTest.cxx b/ImportFromFile/Testing/Cxx/ImportFromFileTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/ImportFromFile/Testing/Cxx/ImportFromFileTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/InvVect/CMakeLists.txt b/InvVect/CMakeLists.txt new file mode 100644 index 0000000..8b7ca0f --- /dev/null +++ b/InvVect/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME InvVect) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/InvVect/Data/Baseline/InvVectTest.nhdr.md5 b/InvVect/Data/Baseline/InvVectTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/InvVect/Data/Baseline/InvVectTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/InvVect/Data/Baseline/InvVectTest.raw.md5 b/InvVect/Data/Baseline/InvVectTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/InvVect/Data/Baseline/InvVectTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/InvVect/Data/Input/CTHeadAxial.nhdr.md5 b/InvVect/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/InvVect/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/InvVect/Data/Input/CTHeadAxial.raw.gz.md5 b/InvVect/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/InvVect/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/InvVect/InvVect.cxx b/InvVect/InvVect.cxx new file mode 100644 index 0000000..94a18e2 --- /dev/null +++ b/InvVect/InvVect.cxx @@ -0,0 +1,61 @@ +#include "InvVectCLP.h" + +// VTK Includes +#include "vtkStdString.h" + + +static int GetIntFromString(const char *inputLine) +{ + std::string Line = inputLine; + int loc = Line.find("=", 1); + std::string NbPoint = Line.erase(0, loc + 1); + int Val = atoi(NbPoint.c_str() ); + return Val; +} + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + //Needs Testing + + std::ifstream vectorFile; + vectorFile.open(vectFile.c_str()); + std::ofstream outfileVec; + outfileVec.open(outFile.c_str()); + // Get the number of points in the file + char output[64]; + vectorFile.getline(output, 32); + outfileVec << output << std::endl; + int Val = GetIntFromString(output); + vectorFile.getline(output, 32); + outfileVec << output << std::endl; + vectorFile.getline(output, 32); + outfileVec << output << std::endl; + + // Write to file in format + float X, Y, Z; + for(int Line = 0; Line < Val; Line++) + { + vectorFile.getline(output, 64); + sscanf(output, "%f %f %f", &X, &Y, &Z); + X = -1 * X; + Y = -1 * Y; + Z = -1 * Z; + outfileVec << X << " " << Y << " " << Z << std::endl; + } + outfileVec.close(); + + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/InvVect/InvVect.xml b/InvVect/InvVect.xml new file mode 100644 index 0000000..375d457 --- /dev/null +++ b/InvVect/InvVect.xml @@ -0,0 +1,27 @@ + + + Surface Models.Advanced + InvVect + + 0.0.1 + http://www.example.com/Slicer/Modules/InvVect + Slicer + FirstName LastName (Institution), FirstName LastName (Institution) + This work was partially funded by NIH grant NXNNXXNNNNNN-NNXN + + + + + vectFile + + + input + + + outFile + + + output + + + diff --git a/InvVect/Testing/CMakeLists.txt b/InvVect/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/InvVect/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/InvVect/Testing/Cxx/CMakeLists.txt b/InvVect/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/InvVect/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/InvVect/Testing/Cxx/InvVectTest.cxx b/InvVect/Testing/Cxx/InvVectTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/InvVect/Testing/Cxx/InvVectTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/KWMToPolyData/CMakeLists.txt b/KWMToPolyData/CMakeLists.txt new file mode 100644 index 0000000..7c8be3c --- /dev/null +++ b/KWMToPolyData/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME KWMToPolyData) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.nhdr.md5 b/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.raw.md5 b/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/KWMToPolyData/Data/Baseline/KWMToPolyDataTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/KWMToPolyData/Data/Input/CTHeadAxial.nhdr.md5 b/KWMToPolyData/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/KWMToPolyData/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/KWMToPolyData/Data/Input/CTHeadAxial.raw.gz.md5 b/KWMToPolyData/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/KWMToPolyData/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/KWMToPolyData/KWMToPolyData.cxx b/KWMToPolyData/KWMToPolyData.cxx new file mode 100644 index 0000000..b258186 --- /dev/null +++ b/KWMToPolyData/KWMToPolyData.cxx @@ -0,0 +1,106 @@ +#include "KWMToPolyDataCLP.h" + +//VTK includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkCleanPolyData.h" +#include "vtkNew.h" +#include "vtkPolyData.h" +#include "vtkFloatArray.h" +#include "vtkPointData.h" + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + vtkSmartPointer polyData; + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + char line[70]; + ifstream input; + int NPoints, NDimension; + char * aux; + input.open(inFile.c_str(), ios::in); + + // get values from file format of KWM + input.getline(line, 500, '\n'); + aux = strtok(line, " = "); + aux = strtok(NULL, " = "); + // TODO: Change from atof + NPoints = atof(aux); + + input.getline(line, 500, '\n'); + aux = strtok(line, " = "); + aux = strtok(NULL, " = "); + // TODO: Change from atof + NDimension = atof(aux); + + input.getline(line, 500, '\n'); + + vtkNew scalars; + scalars->SetNumberOfComponents(NDimension); + scalars->SetName(scalarFile.c_str()); + + for(int i = 0; i < NPoints; i++) + { + input.getline(line, 500, '\n'); + float value = 0; + std::string proc_string = line; + std::istringstream iss(proc_string); + float *tuple = new float[NDimension]; + int count = 0; + do { + std::string sub; + iss >> sub; + if(sub != "") + { + if(count >= NDimension ) + { + std::cerr << "Error" << std::endl; + return 1; + } + value = atof(sub.c_str()); + tuple[ count ] = value; + count++; + } + } while(iss); + if ( count != NDimension ) + { + // improper reading in file + std::cerr << "Error in Line: "<< line << std::endl; + return 1; + } + scalars->InsertNextTuple(tuple); + + } + // close file + input.close(); + + // apply transformation + polyData->GetPointData()->AddArray(scalars); + + vtkNew SurfaceWriter; + SurfaceWriter->SetInputData(polyData); + SurfaceWriter->SetFileName(outputVolume.c_str()); + SurfaceWriter->Update(); + + + } +catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/KWMToPolyData/KWMToPolyData.xml b/KWMToPolyData/KWMToPolyData.xml new file mode 100644 index 0000000..3c1ecb3 --- /dev/null +++ b/KWMToPolyData/KWMToPolyData.xml @@ -0,0 +1,43 @@ + + + Examples + KWMToPolyData + + 0.0.1 + http://www.example.com/Slicer/Modules/KWMToPolyData + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + inFile + + output + KWM File Name + + + + scalarFile + + output + Scalar File Name + + + + diff --git a/KWMToPolyData/Testing/CMakeLists.txt b/KWMToPolyData/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/KWMToPolyData/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/KWMToPolyData/Testing/Cxx/CMakeLists.txt b/KWMToPolyData/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/KWMToPolyData/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/KWMToPolyData/Testing/Cxx/KWMToPolyDataTest.cxx b/KWMToPolyData/Testing/Cxx/KWMToPolyDataTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/KWMToPolyData/Testing/Cxx/KWMToPolyDataTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/applyVec/CMakeLists.txt b/applyVec/CMakeLists.txt new file mode 100644 index 0000000..ed1c5f0 --- /dev/null +++ b/applyVec/CMakeLists.txt @@ -0,0 +1,53 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME applyVec) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKIOMeshBase + ITKSmoothing + ITKLabelMap + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ${MRMLCore_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/applyVec/Data/Baseline/applyVecTest.nhdr.md5 b/applyVec/Data/Baseline/applyVecTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/applyVec/Data/Baseline/applyVecTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/applyVec/Data/Baseline/applyVecTest.raw.md5 b/applyVec/Data/Baseline/applyVecTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/applyVec/Data/Baseline/applyVecTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/applyVec/Data/Input/CTHeadAxial.nhdr.md5 b/applyVec/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/applyVec/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/applyVec/Data/Input/CTHeadAxial.raw.gz.md5 b/applyVec/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/applyVec/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/applyVec/Testing/CMakeLists.txt b/applyVec/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/applyVec/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/applyVec/Testing/Cxx/CMakeLists.txt b/applyVec/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/applyVec/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/applyVec/Testing/Cxx/applyVecTest.cxx b/applyVec/Testing/Cxx/applyVecTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/applyVec/Testing/Cxx/applyVecTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/applyVec/applyVec.cxx b/applyVec/applyVec.cxx new file mode 100644 index 0000000..b83391f --- /dev/null +++ b/applyVec/applyVec.cxx @@ -0,0 +1,130 @@ +#include "applyVecCLP.h" + +// VTK Includes +#include "vtkDecimatePro.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" +#include "vtkNew.h" + + +//ITK Includes +#include "itkMesh.h" +#include "itkMeshFileReader.h" +#include "itkMeshFileWriter.h" +#include "itkLineCell.h" +#include "itkTriangleCell.h" +#include "itkImageFileWriter.h" +#include "itkResampleImageFilter.h" +#include "itkConstrainedValueAdditionImageFilter.h" +#include "itkBSplineInterpolateImageFunction.h" +#include "itkPluginUtilities.h" +#include +#include + +static int GetIntFromString(const char *inputLine) +{ + std::string Line = inputLine; + int loc = Line.find("=", 1); + std::string NbPoint = Line.erase(0, loc + 1); + int Val = atoi(NbPoint.c_str() ); + return Val; +} + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + typedef itk::DefaultDynamicMeshTraits MeshTraitsType; + + typedef itk::DefaultDynamicMeshTraits TriangleMeshTraits; + //typedef itk::Mesh TriangleMeshType; + typedef TriangleMeshTraits::PointType PointTriangleType; + + + typedef MeshTraitsType::PointType PointType; + + constexpr unsigned int Dimension = 3; + using InputPixelType = float; + + + using MeshType = itk::Mesh; + using MeshReaderType = itk::MeshFileReader; + + using MeshWriterType = itk::MeshFileWriter; + + MeshReaderType::Pointer meshReader = MeshReaderType::New(); + meshReader->SetFileName(inputVolume.c_str()); + MeshType::Pointer mesh = meshReader->GetOutput(); + MeshType::PointsContainerPointer Points = mesh->GetPoints(); + + + char output[64]; + std::ifstream vectorFile; + vectorFile.open(vectFile); + + vectorFile.getline(output, 64); + unsigned int Val = GetIntFromString(output); + + if( mesh->GetNumberOfPoints() != Val ) + { + std::cout << "Mesh and vector field must have the same number of points" << std::endl; + std::cout << "The mesh has " << mesh->GetNumberOfPoints() << " points and the vector field has " << Val + << " points." << std::endl; + exit(-1); + } + // Skipping the second and third lines of the file + vectorFile.getline(output, 32); + vectorFile.getline(output, 32); + + float X, Y, Z; + std::vector Xval; + std::vector Yval; + std::vector Zval; + for( unsigned int Line = 0; Line < Val; Line++ ) + { + vectorFile.getline(output, 64); + sscanf(output, "%f %f %f", &X, &Y, &Z); + Xval.push_back(X); + Yval.push_back(Y); + Zval.push_back(Z); + } + + PointType * point1 = new PointType; + PointTriangleType *Tripoint = new PointTriangleType; + for( unsigned int i = 0; i < mesh->GetNumberOfPoints(); i++ ) + { + if( mesh->GetPoint( i, point1 ) && &Xval[i] != NULL ) + { + + Tripoint->SetElement(0, point1->GetElement(0) + Xval[i]); + Tripoint->SetElement(1, point1->GetElement(1) + Yval[i]); + Tripoint->SetElement(2, point1->GetElement(2) + Zval[i]); + + mesh->SetPoint(i, *Tripoint); + } + else + { + return -1; + } + } + MeshWriterType::Pointer writer = MeshWriterType::New(); + + writer->SetInput(mesh); + writer->SetFileName(outputVolume.c_str() ); + writer->Update(); + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/applyVec/applyVec.xml b/applyVec/applyVec.xml new file mode 100644 index 0000000..80e8007 --- /dev/null +++ b/applyVec/applyVec.xml @@ -0,0 +1,37 @@ + + + Surface Models.Advanced + applyVec + + 0.0.1 + http://www.example.com/Slicer/Modules/applyVec + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + vectFile + + input + Vector File Name + + + + + diff --git a/avgMesh/CMakeLists.txt b/avgMesh/CMakeLists.txt new file mode 100644 index 0000000..c146ca3 --- /dev/null +++ b/avgMesh/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME avgMesh) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/avgMesh/Data/Baseline/avgMeshTest.nhdr.md5 b/avgMesh/Data/Baseline/avgMeshTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/avgMesh/Data/Baseline/avgMeshTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/avgMesh/Data/Baseline/avgMeshTest.raw.md5 b/avgMesh/Data/Baseline/avgMeshTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/avgMesh/Data/Baseline/avgMeshTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/avgMesh/Data/Input/CTHeadAxial.nhdr.md5 b/avgMesh/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/avgMesh/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/avgMesh/Data/Input/CTHeadAxial.raw.gz.md5 b/avgMesh/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/avgMesh/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/avgMesh/Testing/CMakeLists.txt b/avgMesh/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/avgMesh/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/avgMesh/Testing/Cxx/CMakeLists.txt b/avgMesh/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/avgMesh/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/avgMesh/Testing/Cxx/avgMeshTest.cxx b/avgMesh/Testing/Cxx/avgMeshTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/avgMesh/Testing/Cxx/avgMeshTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/avgMesh/avgMesh.cxx b/avgMesh/avgMesh.cxx new file mode 100644 index 0000000..528518d --- /dev/null +++ b/avgMesh/avgMesh.cxx @@ -0,0 +1,61 @@ +#include "avgMeshCLP.h" + +//VTK Includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkNew.h" + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + vtkSmartPointer polyData; + vtkSmartPointer polyData2; + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + vtkNew reader2; + reader2->SetFileName(inputVolumeTwo.c_str()); + reader2->Update(); + reader2->Update(); + polyData2 = reader2->GetOutput(); + + vtkSmartPointer tmpPoints = vtkSmartPointer::New(); + for( unsigned int pointID = 0; pointID < polyData2->GetNumberOfPoints(); pointID++ ) + { + double curPoint[3]; + double avgPoint[3]; + double tmpPoint[3]; + polyData2->GetPoint(pointID, curPoint); + polyData->GetPoint(pointID, avgPoint); + for( unsigned int dim = 0; dim < 3; dim++ ) + { + tmpPoint[dim] = curPoint[dim] + avgPoint[dim]; + } + tmpPoints->InsertPoint(pointID, tmpPoint); + } + + polyData->SetPoints(tmpPoints); + vtkNew writer; + writer->SetFileName(outputVolume.c_str()); + writer->SetInputData(polyData); + writer->Update(); + + } +catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/avgMesh/avgMesh.xml b/avgMesh/avgMesh.xml new file mode 100644 index 0000000..2d05e16 --- /dev/null +++ b/avgMesh/avgMesh.xml @@ -0,0 +1,36 @@ + + + Surface Models.Advanced + avgMesh + + 0.0.1 + http://www.example.com/Slicer/Modules/avgMesh + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + inputVolumeTwo + + input + 1 + + + + outputVolume + + output + 2 + + + + diff --git a/closestPoint/CMakeLists.txt b/closestPoint/CMakeLists.txt new file mode 100644 index 0000000..f9deb7a --- /dev/null +++ b/closestPoint/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME closestPoint) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/closestPoint/Data/Baseline/closestPointTest.nhdr.md5 b/closestPoint/Data/Baseline/closestPointTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/closestPoint/Data/Baseline/closestPointTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/closestPoint/Data/Baseline/closestPointTest.raw.md5 b/closestPoint/Data/Baseline/closestPointTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/closestPoint/Data/Baseline/closestPointTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/closestPoint/Data/Input/CTHeadAxial.nhdr.md5 b/closestPoint/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/closestPoint/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/closestPoint/Data/Input/CTHeadAxial.raw.gz.md5 b/closestPoint/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/closestPoint/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/closestPoint/Testing/CMakeLists.txt b/closestPoint/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/closestPoint/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/closestPoint/Testing/Cxx/CMakeLists.txt b/closestPoint/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/closestPoint/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/closestPoint/Testing/Cxx/closestPointTest.cxx b/closestPoint/Testing/Cxx/closestPointTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/closestPoint/Testing/Cxx/closestPointTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/closestPoint/closestPoint.cxx b/closestPoint/closestPoint.cxx new file mode 100644 index 0000000..5cb198f --- /dev/null +++ b/closestPoint/closestPoint.cxx @@ -0,0 +1,95 @@ +#include "closestPointCLP.h" + +// VTK Includes +#include "vtkDecimatePro.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" +#include "vtkNew.h" + + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + vtkSmartPointer mesh1; + vtkSmartPointer mesh2; + + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + mesh1 = reader->GetOutput(); + + vtkNew reader2; + reader2->SetFileName(inputVolumeTwo.c_str()); + reader2->Update(); + mesh2 = reader2->GetOutput(); + + std::ifstream inFile; + char Line[40]; + float CurrentAttribute; + std::vector v_AttributeIn, v_AttributeOut; + // open closest point file + inFile.open(valFile.c_str()); + + while( std::strncmp(Line, "NUMBER_OF_POINTS =", 18) && strncmp(Line, "NUMBER_OF_POINTS", 17) ) + { + inFile.getline(Line, 40); + } + + unsigned int NbVertices = atoi(strrchr(Line, '=') + 1); + inFile.getline(Line, 40); + inFile.getline(Line, 40); + for(unsigned int i = 0; i < NbVertices; i++) + { + inFile >> CurrentAttribute; + v_AttributeIn.push_back(CurrentAttribute); + } + inFile.close(); + + double x[3]; + vtkIdType closestVertId; + for(int PointId = 0; PointId < mesh2->GetNumberOfPoints(); PointId++) + { + mesh2->GetPoint(PointId, x); + closestVertId = mesh1->FindPoint(x); + if(closestVertId >= 0) + { + v_AttributeOut.push_back(v_AttributeIn[(int)closestVertId]); + } + else + { + return EXIT_FAILURE; + } + } + // Write out to file + + std::ofstream outputfile; + outputfile.open(outFile); + outputfile << "NUMBER_OF_POINTS=" << v_AttributeOut.size() << std::endl; + outputfile << "DIMENSION=" << 1 << std::endl; + outputfile << "TYPE=Scalar" << std::endl; + for(unsigned int i = 0; i < v_AttributeOut.size(); i++) + { + outputfile << v_AttributeOut[i] << std::endl; + } + outputfile.close(); + + + } + catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/closestPoint/closestPoint.xml b/closestPoint/closestPoint.xml new file mode 100644 index 0000000..630f3b8 --- /dev/null +++ b/closestPoint/closestPoint.xml @@ -0,0 +1,41 @@ + + + Surface Models.Advanced + closestPoint + + 0.0.1 + http://www.example.com/Slicer/Modules/avgMesh + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + inputVolumeTwo + + input + 1 + + + + valFile + + + input + + + outFile + + + output + + + diff --git a/extractVertices/CMakeLists.txt b/extractVertices/CMakeLists.txt new file mode 100644 index 0000000..48b4a73 --- /dev/null +++ b/extractVertices/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME extractVertices) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/extractVertices/Data/Baseline/extractVerticesTest.nhdr.md5 b/extractVertices/Data/Baseline/extractVerticesTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/extractVertices/Data/Baseline/extractVerticesTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/extractVertices/Data/Baseline/extractVerticesTest.raw.md5 b/extractVertices/Data/Baseline/extractVerticesTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/extractVertices/Data/Baseline/extractVerticesTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/extractVertices/Data/Input/CTHeadAxial.nhdr.md5 b/extractVertices/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/extractVertices/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/extractVertices/Data/Input/CTHeadAxial.raw.gz.md5 b/extractVertices/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/extractVertices/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/extractVertices/Testing/CMakeLists.txt b/extractVertices/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/extractVertices/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/extractVertices/Testing/Cxx/CMakeLists.txt b/extractVertices/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/extractVertices/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/extractVertices/Testing/Cxx/extractVerticesTest.cxx b/extractVertices/Testing/Cxx/extractVerticesTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/extractVertices/Testing/Cxx/extractVerticesTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/extractVertices/extractVertices.cxx b/extractVertices/extractVertices.cxx new file mode 100644 index 0000000..c3082a8 --- /dev/null +++ b/extractVertices/extractVertices.cxx @@ -0,0 +1,63 @@ +#include "extractVerticesCLP.h" + +//VTK includes +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkCleanPolyData.h" +#include "vtkNew.h" +#include "vtkPolyData.h" + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + vtkSmartPointer polyData; + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + std::ofstream outfile0, outfile1, outfile2; + + outfile0.open(outFile0); + outfile1.open(outFile1); + outfile2.open(outFile2); + + int NbPoints = polyData->GetNumberOfPoints(); + outfile0 << "NUMBER_OF_POINTS=" << NbPoints << std::endl << "DIMENSION=1" << std::endl << "TYPE=Scalar" + << std::endl; + outfile1 << "NUMBER_OF_POINTS=" << NbPoints << std::endl << "DIMENSION=1" << std::endl << "TYPE=Scalar" + << std::endl; + outfile2 << "NUMBER_OF_POINTS=" << NbPoints << std::endl << "DIMENSION=1" << std::endl << "TYPE=Scalar" + << std::endl; + + double x[3]; + for(int PointId = 0; PointId < NbPoints; PointId++) + { + polyData->GetPoint(PointId, x); + outfile0 << x[0] << std::endl; + outfile1 << x[1] << std::endl; + outfile2 << x[2] << std::endl; + } + outfile0.close(); + outfile1.close(); + outfile2.close(); + + + + } +catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/extractVertices/extractVertices.xml b/extractVertices/extractVertices.xml new file mode 100644 index 0000000..8cb6d91 --- /dev/null +++ b/extractVertices/extractVertices.xml @@ -0,0 +1,50 @@ + + + Surface Models.Advanced + extractVertices + + 0.0.1 + http://www.example.com/Slicer/Modules/extractVertices + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + outFile0 + + output + Output File Name + + + + outFile1 + + output + Output File Name + + + + outFile2 + + output + Output File Name + + + + diff --git a/lookupPointData/CMakeLists.txt b/lookupPointData/CMakeLists.txt new file mode 100644 index 0000000..50b239d --- /dev/null +++ b/lookupPointData/CMakeLists.txt @@ -0,0 +1,57 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME lookupPointData) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) +find_package(VTK COMPONENTS + vtkCommonColor + vtkCommonCore + vtkCommonDataModel + vtkFiltersGeneral + vtkIOInfovis + vtkInteractionStyle + vtkRenderingCore + vtkRenderingFreeType + vtkRenderingOpenGL2 QUIET) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/lookupPointData/Data/Baseline/lookupPointDataTest.nhdr.md5 b/lookupPointData/Data/Baseline/lookupPointDataTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/lookupPointData/Data/Baseline/lookupPointDataTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/lookupPointData/Data/Baseline/lookupPointDataTest.raw.md5 b/lookupPointData/Data/Baseline/lookupPointDataTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/lookupPointData/Data/Baseline/lookupPointDataTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/lookupPointData/Data/Input/CTHeadAxial.nhdr.md5 b/lookupPointData/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/lookupPointData/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/lookupPointData/Data/Input/CTHeadAxial.raw.gz.md5 b/lookupPointData/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/lookupPointData/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/lookupPointData/Testing/CMakeLists.txt b/lookupPointData/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/lookupPointData/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/lookupPointData/Testing/Cxx/CMakeLists.txt b/lookupPointData/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/lookupPointData/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/lookupPointData/Testing/Cxx/lookupPointDataTest.cxx b/lookupPointData/Testing/Cxx/lookupPointDataTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/lookupPointData/Testing/Cxx/lookupPointDataTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/lookupPointData/lookupPointData.cxx b/lookupPointData/lookupPointData.cxx new file mode 100644 index 0000000..55e9979 --- /dev/null +++ b/lookupPointData/lookupPointData.cxx @@ -0,0 +1,71 @@ +#include "lookupPointDataCLP.h" + + +//VTK Includes +#include "vtkFillHolesFilter.h" +#include "vtkPolyDataNormals.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkDelimitedTextReader.h" +#include "vtkTable.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkNew.h" +#include "vtkDoubleArray.h" +#include "vtkPointData.h" + +#include +#include + + +// Needs testing + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + vtkSmartPointer polyData; + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + //std::ifstream csvfile(csvFile); + vtkNew CSVDelimiter; + CSVDelimiter->SetFieldDelimiterCharacters(","); + CSVDelimiter->SetFileName(csvFile.c_str()); + CSVDelimiter->SetHaveHeaders(true); + CSVDelimiter->Update(); + vtkSmartPointer table = CSVDelimiter->GetOutput(); + + vtkDoubleArray* outputScalars = (vtkDoubleArray*) polyData->GetPointData()->GetArray(scalarVal.c_str()); + + for (unsigned int idx=0; idx < table->GetNumberOfRows() ; idx++) + { + for (unsigned int idxs = 0 ; idxs < polyData->GetNumberOfPoints() ; idxs++) + { + if (outputScalars->GetVariantValue(idxs) == table->GetValue(idx,0)) + { + outputScalars->SetVariantValue(idxs,table->GetValue(idx,1)); + } + } + } + + vtkNew writer; + writer->SetFileName(outputVolume.c_str()); + writer->SetInputData(polyData); + writer->Update(); + } +catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + + return EXIT_SUCCESS; +} diff --git a/lookupPointData/lookupPointData.xml b/lookupPointData/lookupPointData.xml new file mode 100644 index 0000000..59cdcc2 --- /dev/null +++ b/lookupPointData/lookupPointData.xml @@ -0,0 +1,44 @@ + + + Surface Models.Advanced + lookupPointData + + 0.0.1 + http://www.example.com/Slicer/Modules/lookupPointData + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + csvFile + + input + CSV File Name + + + + scalarVal + + input + Scalar Value File + + + + + diff --git a/pointDataOP/CMakeLists.txt b/pointDataOP/CMakeLists.txt new file mode 100644 index 0000000..e678ee6 --- /dev/null +++ b/pointDataOP/CMakeLists.txt @@ -0,0 +1,47 @@ + +#----------------------------------------------------------------------------- +set(MODULE_NAME pointDataOP) + +#----------------------------------------------------------------------------- + +# +# SlicerExecutionModel +# +find_package(SlicerExecutionModel REQUIRED) +include(${SlicerExecutionModel_USE_FILE}) + +# +# ITK +# +set(${PROJECT_NAME}_ITK_COMPONENTS + ITKIOImageBase + ITKSmoothing + ) +find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED) +set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt +include(${ITK_USE_FILE}) + +#----------------------------------------------------------------------------- +set(MODULE_INCLUDE_DIRECTORIES + ) + +set(MODULE_SRCS + ) + +set(MODULE_TARGET_LIBRARIES + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +SEMMacroBuildCLI( + NAME ${MODULE_NAME} + TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES} + INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES} + ADDITIONAL_SRCS ${MODULE_SRCS} + ) + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(Testing) +endif() diff --git a/pointDataOP/Data/Baseline/pointDataOPTest.nhdr.md5 b/pointDataOP/Data/Baseline/pointDataOPTest.nhdr.md5 new file mode 100644 index 0000000..e3f7f40 --- /dev/null +++ b/pointDataOP/Data/Baseline/pointDataOPTest.nhdr.md5 @@ -0,0 +1 @@ +fc6170ceeff3d8217a9dd6a1add2ec8c diff --git a/pointDataOP/Data/Baseline/pointDataOPTest.raw.md5 b/pointDataOP/Data/Baseline/pointDataOPTest.raw.md5 new file mode 100644 index 0000000..6e640c3 --- /dev/null +++ b/pointDataOP/Data/Baseline/pointDataOPTest.raw.md5 @@ -0,0 +1 @@ +0749d4d3f07a217030f9ae33d94c4559 \ No newline at end of file diff --git a/pointDataOP/Data/Input/CTHeadAxial.nhdr.md5 b/pointDataOP/Data/Input/CTHeadAxial.nhdr.md5 new file mode 100644 index 0000000..734a046 --- /dev/null +++ b/pointDataOP/Data/Input/CTHeadAxial.nhdr.md5 @@ -0,0 +1 @@ +6e5c289c73e14ba7a1b0f8aaf6ed249a \ No newline at end of file diff --git a/pointDataOP/Data/Input/CTHeadAxial.raw.gz.md5 b/pointDataOP/Data/Input/CTHeadAxial.raw.gz.md5 new file mode 100644 index 0000000..f555cb4 --- /dev/null +++ b/pointDataOP/Data/Input/CTHeadAxial.raw.gz.md5 @@ -0,0 +1 @@ +3ebd710c9cf9d75750f4569b8caf6d07 \ No newline at end of file diff --git a/pointDataOP/Testing/CMakeLists.txt b/pointDataOP/Testing/CMakeLists.txt new file mode 100644 index 0000000..35f9732 --- /dev/null +++ b/pointDataOP/Testing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Cxx) diff --git a/pointDataOP/Testing/Cxx/CMakeLists.txt b/pointDataOP/Testing/Cxx/CMakeLists.txt new file mode 100644 index 0000000..41219b0 --- /dev/null +++ b/pointDataOP/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,25 @@ + +#----------------------------------------------------------------------------- +set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline) +set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input) +set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary") + +set(CLP ${MODULE_NAME}) + +#----------------------------------------------------------------------------- +add_executable(${CLP}Test ${CLP}Test.cxx) +target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}) +set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP}) + +#----------------------------------------------------------------------------- +set(testname ${CLP}Test) +ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw} + ${TEMP}/${CLP}Test.nhdr + ModuleEntryPoint + --sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr + ) +set_property(TEST ${testname} PROPERTY LABELS ${CLP}) + +#----------------------------------------------------------------------------- +ExternalData_add_target(${CLP}Data) diff --git a/pointDataOP/Testing/Cxx/pointDataOPTest.cxx b/pointDataOP/Testing/Cxx/pointDataOPTest.cxx new file mode 100644 index 0000000..35540fb --- /dev/null +++ b/pointDataOP/Testing/Cxx/pointDataOPTest.cxx @@ -0,0 +1,25 @@ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +#include "itkTestMain.h" + +// STD includes +#include + +#ifdef WIN32 +# define MODULE_IMPORT __declspec(dllimport) +#else +# define MODULE_IMPORT +#endif + +extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []); + +void RegisterTests() +{ + StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint; +} diff --git a/pointDataOP/pointDataOP.cxx b/pointDataOP/pointDataOP.cxx new file mode 100644 index 0000000..1987e77 --- /dev/null +++ b/pointDataOP/pointDataOP.cxx @@ -0,0 +1,80 @@ +#include "pointDataOPCLP.h" + +//VTK Includes +#include "vtkFillHolesFilter.h" +#include "vtkPolyDataNormals.h" +#include "vtkXMLPolyDataWriter.h" +#include "vtkXMLPolyDataReader.h" +#include "vtkSmartPointer.h" +#include "vtkPolyData.h" +#include "vtkNew.h" +#include "vtkPointData.h" +#include "vtkDoubleArray.h" + + + +int main (int argc, char * argv[]) + { + PARSE_ARGS; + + try{ + + //TODO: Testing + + vtkSmartPointer polyData; + + // Read the file + vtkNew reader; + reader->SetFileName(inputVolume.c_str()); + reader->Update(); + polyData = reader->GetOutput(); + + unsigned int nPoints = polyData->GetNumberOfPoints(); + + //unsigned int numberOfArrays = polyData->GetPointData()->GetNumberOfArrays(); + + const char * name = names.c_str(); + polyData->GetPointData()->SetActiveScalars(name); + vtkDoubleArray *scalarData = (vtkDoubleArray*) polyData->GetPointData()->GetArray(name); + + if (scalarData) + { + double opValue = opVal; + + + if (! operation.compare("threshBelow")) + { + for (unsigned int i = 0 ; i < nPoints; i++) + { + if (scalarData->GetComponent(i,0) < opValue) scalarData->SetComponent(i,0, 0); + } + + } else if (! operation.compare("sub")) + { + for (unsigned int i = 0 ; i < nPoints; i++) + { + double curValue = scalarData->GetComponent(i,0); + scalarData->SetComponent(i,0, curValue - opValue); + } + } else + { + std::cout << "No (known) point operation detected -> exiting" << std::endl; + } + } + + + + vtkNew writer; + writer->SetFileName(outputVolume.c_str()); + writer->SetInputData(polyData); + writer->Update(); + } +catch (int e) + { + cout << "An exception occurred. Exception Nr. " << e << '\n'; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + + } diff --git a/pointDataOP/pointDataOP.xml b/pointDataOP/pointDataOP.xml new file mode 100644 index 0000000..3ce79b2 --- /dev/null +++ b/pointDataOP/pointDataOP.xml @@ -0,0 +1,56 @@ + + + Surface Models.Advanced + pointDataOP + + 0.0.1 + http://www.example.com/Slicer/Modules/pointDataOP + Slicer + Ben Wilson (Kitware) + + + + + + inputVolume + + input + 0 + + + + outputVolume + + output + 1 + + + + names + + input + Name: + + + + operation + + --operaton + : [threshBelow | sub] threshBelow: set to 0 all data below , sub: subtract value.]]> + threshBelow + threshBelow + sub + + + opVal + + output + Op Value + 0 + + -10.0 + 10.0 + + + +