Skip to content

Commit

Permalink
unfinished CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Wilson committed Aug 19, 2019
1 parent e9602ca commit 41db383
Show file tree
Hide file tree
Showing 13 changed files with 481 additions and 106 deletions.
2 changes: 1 addition & 1 deletion AlignMesh/AlignMesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main (int argc, char * argv[])
meshReader2->SetFileName(inputVolumeTwo.c_str());
// meshReader->Update();
MeshType::Pointer mesh2 = meshReader2->GetOutput();




Expand Down
61 changes: 61 additions & 0 deletions BordersOut/BordersOut.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "BordersOutCLP.h"

//VTK Includes
#include "vtkXMLPolyDataWriter.h"
#include "vtkXMLPolyDataReader.h"
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include "vtkTriangleFilter.h"
#include "vtkNew.h"
#include "vtkFeatureEdges.h"
#include "vtkCleanPolyData.h"


int main (int argc, char * argv[])
{
PARSE_ARGS;

try{
int NBorders;
int TOTALBorders;

vtkSmartPointer<vtkPolyData> polyData;

// Read the file
vtkNew<vtkXMLPolyDataReader> reader;
reader->SetFileName(inputVolume.c_str());
reader->Update();
polyData = reader->GetOutput();

vtkNew<vtkCleanPolyData> meshinC;
meshinC->SetInputData(polyData);
meshinC->Update();

vtkNew<vtkFeatureEdges> boundaryEdges;
boundaryEdges->SetInputData(meshinC->GetOutput());
boundaryEdges->BoundaryEdgesOn();
//boundaryEdges->FeatureEdgesOff();
boundaryEdges->NonManifoldEdgesOff();
boundaryEdges->ManifoldEdgesOff();
boundaryEdges->Update();

NBorders = (boundaryEdges->GetOutput()->GetNumberOfLines());
TOTALBorders = NBorders;

//std::cout << "Number of Border Edges... " << TOTALBorders << std::endl;

//Write to file
vtkNew<vtkXMLPolyDataWriter> writer;
writer->SetFileName(outputVolume.c_str());
writer->SetInputData(boundaryEdges->GetOutput());
writer->Update();
}
catch (int e)
{
cout << "An exception occurred. Exception Nr. " << e << '\n';
return EXIT_FAILURE;
}

return EXIT_SUCCESS;

}
29 changes: 29 additions & 0 deletions BordersOut/BordersOut.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<executable>
<category>Surface Models.Advanced</category>
<title>BordersOut</title>
<description><![CDATA[This is a CLI module that can be bundled in an extension]]></description>
<version>0.0.1</version>
<documentation-url>http://www.example.com/Slicer/Modules/BordersOut</documentation-url>
<license>Slicer</license>
<contributor>Ben Wilson (Kitware)</contributor>
<acknowledgements></acknowledgements>
<parameters>
<label>IO</label>
<description><![CDATA[Input/output parameters]]></description>
<geometry>
<name>inputVolume</name>
<label>Input Volume</label>
<channel>input</channel>
<index>0</index>
<description><![CDATA[Input volume]]></description>
</geometry>
<geometry>
<name>outputVolume</name>
<label>Output Volume</label>
<channel>output</channel>
<index>1</index>
<description><![CDATA[Output Volume]]></description>
</geometry>
</parameters>
</executable>
47 changes: 47 additions & 0 deletions BordersOut/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

#-----------------------------------------------------------------------------
set(MODULE_NAME BordersOut)

#-----------------------------------------------------------------------------

#
# 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()
1 change: 1 addition & 0 deletions BordersOut/Data/Baseline/BordersOutTest.nhdr.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fc6170ceeff3d8217a9dd6a1add2ec8c
1 change: 1 addition & 0 deletions BordersOut/Data/Baseline/BordersOutTest.raw.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0749d4d3f07a217030f9ae33d94c4559
1 change: 1 addition & 0 deletions BordersOut/Data/Input/CTHeadAxial.nhdr.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6e5c289c73e14ba7a1b0f8aaf6ed249a
1 change: 1 addition & 0 deletions BordersOut/Data/Input/CTHeadAxial.raw.gz.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3ebd710c9cf9d75750f4569b8caf6d07
1 change: 1 addition & 0 deletions BordersOut/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(Cxx)
25 changes: 25 additions & 0 deletions BordersOut/Testing/Cxx/BordersOutTest.cxx
Original file line number Diff line number Diff line change
@@ -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 <iostream>

#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;
}
25 changes: 25 additions & 0 deletions BordersOut/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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} $<TARGET_FILE:${CLP}Test>
--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)
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_subdirectory(AlignMesh)
add_subdirectory(AlignMeshICP)
add_subdirectory(applyVec)
add_subdirectory(avgMesh)
add_subdirectory(BordersOut)
add_subdirectory(Cleaner)
add_subdirectory(closestPoint)
add_subdirectory(Connectivity)
Expand Down
Loading

0 comments on commit 41db383

Please sign in to comment.