Skip to content

Commit e9602ca

Browse files
author
Ben Wilson
committed
Add CLIs
1 parent 68db27c commit e9602ca

File tree

263 files changed

+6009
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+6009
-49
lines changed

AlignMesh/AlignMesh.cxx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include "AlignMeshCLP.h"
2+
3+
4+
// VTK Includes
5+
#include "vtkDecimatePro.h"
6+
#include "vtkXMLPolyDataWriter.h"
7+
#include "vtkXMLPolyDataReader.h"
8+
#include "vtkSmartPointer.h"
9+
#include "vtkPolyData.h"
10+
#include "vtkTriangleFilter.h"
11+
#include "vtkNew.h"
12+
#include "vtkCellLocator.h"
13+
14+
//ITK Includes
15+
#include "itkMesh.h"
16+
#include "itkMeshFileReader.h"
17+
#include "itkMeshFileWriter.h"
18+
#include "itkLineCell.h"
19+
#include "itkTriangleCell.h"
20+
#include "itkImageFileWriter.h"
21+
#include "itkResampleImageFilter.h"
22+
#include "itkConstrainedValueAdditionImageFilter.h"
23+
#include "itkBSplineInterpolateImageFunction.h"
24+
#include "itkPluginUtilities.h"
25+
#include <itkDefaultDynamicMeshTraits.h>
26+
#include <itkMetaMeshConverter.h>
27+
28+
29+
int main (int argc, char * argv[])
30+
{
31+
PARSE_ARGS;
32+
try{
33+
typedef itk::DefaultDynamicMeshTraits<float, 3, 3, float, float> MeshTraitsType;
34+
35+
36+
typedef MeshTraitsType::PointType PointType;
37+
38+
constexpr unsigned int Dimension = 3;
39+
using InputPixelType = float;
40+
41+
42+
using MeshType = itk::Mesh<InputPixelType, Dimension>;
43+
using MeshReaderType = itk::MeshFileReader<MeshType>;
44+
45+
using MeshWriterType = itk::MeshFileWriter<MeshType>;
46+
47+
MeshReaderType::Pointer meshReader = MeshReaderType::New();
48+
meshReader->SetFileName(inputVolume.c_str());
49+
// meshReader->Update();
50+
MeshType::Pointer mesh = meshReader->GetOutput();
51+
MeshType::PointsContainerPointer Points = mesh->GetPoints();
52+
int numberOfPoints = Points->Size();
53+
54+
MeshReaderType::Pointer meshReader2 = MeshReaderType::New();
55+
meshReader2->SetFileName(inputVolumeTwo.c_str());
56+
// meshReader->Update();
57+
MeshType::Pointer mesh2 = meshReader2->GetOutput();
58+
59+
60+
61+
62+
63+
MeshWriterType::Pointer writer = MeshWriterType::New();
64+
writer->SetInput(mesh);
65+
writer->SetFileName(outputVolume.c_str());
66+
//writer->Update();
67+
68+
69+
}
70+
catch (int e)
71+
{
72+
cout << "An exception occurred. Exception Nr. " << e << '\n';
73+
return EXIT_FAILURE;
74+
}
75+
return EXIT_SUCCESS;
76+
77+
}

AlignMesh/AlignMesh.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<executable>
3+
<category>Surface Models.Advanced</category>
4+
<title>AlignMesh</title>
5+
<description><![CDATA[This is a CLI module that can be bundled in an extension]]></description>
6+
<version>0.0.1</version>
7+
<documentation-url>http://www.example.com/Slicer/Modules/AlignMesh</documentation-url>
8+
<license>Slicer</license>
9+
<contributor>FirstName LastName (Institution), FirstName LastName (Institution)</contributor>
10+
<acknowledgements>This work was partially funded by NIH grant NXNNXXNNNNNN-NNXN</acknowledgements>
11+
<parameters>
12+
<label>IO</label>
13+
<description><![CDATA[Input/output parameters]]></description>
14+
<geometry>
15+
<name>inputVolume</name>
16+
<label>Input Volume</label>
17+
<channel>input</channel>
18+
<index>0</index>
19+
<description><![CDATA[Input volume]]></description>
20+
</geometry>
21+
<geometry>
22+
<name>inputVolumeTwo</name>
23+
<label>Input Volume Two </label>
24+
<channel>input</channel>
25+
<index>1</index>
26+
<description><![CDATA[Input volume two]]></description>
27+
</geometry>
28+
<geometry>
29+
<name>outputVolume</name>
30+
<label>Output Volume</label>
31+
<channel>output</channel>
32+
<index>2</index>
33+
<description><![CDATA[Output Volume]]></description>
34+
</geometry>
35+
</parameters>
36+
</executable>

AlignMesh/CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
#-----------------------------------------------------------------------------
3+
set(MODULE_NAME AlignMesh)
4+
5+
#-----------------------------------------------------------------------------
6+
7+
#
8+
# SlicerExecutionModel
9+
#
10+
find_package(SlicerExecutionModel REQUIRED)
11+
include(${SlicerExecutionModel_USE_FILE})
12+
13+
14+
#
15+
# ITK
16+
#
17+
set(${PROJECT_NAME}_ITK_COMPONENTS
18+
ITKIOImageBase
19+
ITKIOMeshBase
20+
ITKSmoothing
21+
ITKLabelMap
22+
)
23+
find_package(ITK 5 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
24+
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
25+
include(${ITK_USE_FILE})
26+
27+
#-----------------------------------------------------------------------------
28+
set(MODULE_INCLUDE_DIRECTORIES
29+
${MRMLCore_INCLUDE_DIRS}
30+
${CMAKE_CURRENT_SOURCE_DIR}
31+
32+
)
33+
34+
set(MODULE_SRCS
35+
)
36+
37+
set(MODULE_TARGET_LIBRARIES
38+
${ITK_LIBRARIES}
39+
${VTK_LIBRARIES}
40+
)
41+
42+
#-----------------------------------------------------------------------------
43+
SEMMacroBuildCLI(
44+
NAME ${MODULE_NAME}
45+
TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
46+
INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
47+
ADDITIONAL_SRCS ${MODULE_SRCS}
48+
)
49+
50+
#-----------------------------------------------------------------------------
51+
if(BUILD_TESTING)
52+
add_subdirectory(Testing)
53+
endif()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fc6170ceeff3d8217a9dd6a1add2ec8c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0749d4d3f07a217030f9ae33d94c4559
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6e5c289c73e14ba7a1b0f8aaf6ed249a
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3ebd710c9cf9d75750f4569b8caf6d07

AlignMesh/Testing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(Cxx)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#if defined(_MSC_VER)
2+
#pragma warning ( disable : 4786 )
3+
#endif
4+
5+
#ifdef __BORLANDC__
6+
#define ITK_LEAN_AND_MEAN
7+
#endif
8+
9+
#include "itkTestMain.h"
10+
11+
// STD includes
12+
#include <iostream>
13+
14+
#ifdef WIN32
15+
# define MODULE_IMPORT __declspec(dllimport)
16+
#else
17+
# define MODULE_IMPORT
18+
#endif
19+
20+
extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char* []);
21+
22+
void RegisterTests()
23+
{
24+
StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint;
25+
}

AlignMesh/Testing/Cxx/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
#-----------------------------------------------------------------------------
3+
set(BASELINE ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Baseline)
4+
set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../Data/Input)
5+
set(TEMP "${CMAKE_BINARY_DIR}/Testing/Temporary")
6+
7+
set(CLP ${MODULE_NAME})
8+
9+
#-----------------------------------------------------------------------------
10+
add_executable(${CLP}Test ${CLP}Test.cxx)
11+
target_link_libraries(${CLP}Test ${CLP}Lib ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES})
12+
set_target_properties(${CLP}Test PROPERTIES LABELS ${CLP})
13+
14+
#-----------------------------------------------------------------------------
15+
set(testname ${CLP}Test)
16+
ExternalData_add_test(${CLP}Data NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $<TARGET_FILE:${CLP}Test>
17+
--compare DATA{${BASELINE}/${CLP}Test.nhdr,${CLP}Test.raw}
18+
${TEMP}/${CLP}Test.nhdr
19+
ModuleEntryPoint
20+
--sigma 2.5 DATA{${INPUT}/CTHeadAxial.nhdr,CTHeadAxial.raw.gz} ${TEMP}/${CLP}Test.nhdr
21+
)
22+
set_property(TEST ${testname} PROPERTY LABELS ${CLP})
23+
24+
#-----------------------------------------------------------------------------
25+
ExternalData_add_target(${CLP}Data)

0 commit comments

Comments
 (0)