Skip to content

Commit b77ba22

Browse files
author
Ben Wilson
committed
Add Mesh CLIs
1 parent 291f047 commit b77ba22

File tree

93 files changed

+2138
-39
lines changed

Some content is hidden

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

93 files changed

+2138
-39
lines changed

BordersOut/BordersOut.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ int main (int argc, char * argv[])
3434
vtkNew<vtkFeatureEdges> boundaryEdges;
3535
boundaryEdges->SetInputData(meshinC->GetOutput());
3636
boundaryEdges->BoundaryEdgesOn();
37-
boundaryEdges->FeatureEdgesOff();
37+
//boundaryEdges->FeatureEdgesOff();
3838
boundaryEdges->NonManifoldEdgesOff();
3939
boundaryEdges->ManifoldEdgesOff();
4040
boundaryEdges->Update();
4141

4242
NBorders = (boundaryEdges->GetOutput()->GetNumberOfLines());
4343
TOTALBorders = NBorders;
4444

45+
//std::cout << "Number of Border Edges... " << TOTALBorders << std::endl;
46+
4547
//Write to file
4648
vtkNew<vtkXMLPolyDataWriter> writer;
4749
writer->SetFileName(outputVolume.c_str());

BordersOut/BordersOut.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<executable>
3-
<category>Examples</category>
3+
<category>Surface Models.Advanced</category>
44
<title>BordersOut</title>
55
<description><![CDATA[This is a CLI module that can be bundled in an extension]]></description>
66
<version>0.0.1</version>
77
<documentation-url>http://www.example.com/Slicer/Modules/BordersOut</documentation-url>
88
<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>
9+
<contributor>Ben Wilson (Kitware)</contributor>
10+
<acknowledgements></acknowledgements>
1111
<parameters>
1212
<label>IO</label>
1313
<description><![CDATA[Input/output parameters]]></description>

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ include(${Slicer_USE_FILE})
1010

1111
#-----------------------------------------------------------------------------
1212
# Extension modules
13+
add_subdirectory(applyVec)
14+
add_subdirectory(avgMesh)
1315
add_subdirectory(BordersOut)
14-
add_subdirectory(Decimation)
1516
add_subdirectory(Cleaner)
1617
add_subdirectory(Connectivity)
18+
add_subdirectory(Decimation)
19+
add_subdirectory(extractVertices)
1720
add_subdirectory(FillHoles)
21+
add_subdirectory(GetCurvatures)
22+
add_subdirectory(GetDirectionFeatures)
23+
add_subdirectory(ImportFromFile)
24+
add_subdirectory(KWMToPolyData)
1825
add_subdirectory(lookupPointData)
1926
add_subdirectory(MC2Origin)
2027
add_subdirectory(meshValues)
2128
add_subdirectory(Mirror)
2229
add_subdirectory(Normals)
30+
add_subdirectory(pointDataOP)
2331
add_subdirectory(relaxPolygons)
2432
add_subdirectory(Smoothing)
2533
add_subdirectory(SurfaceToolbox)

GetCurvatures/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 GetCurvatures)
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

GetCurvatures/GetCurvatures.cxx

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#include "GetCurvaturesCLP.h"
2+
3+
// VTK Includes
4+
#include "vtkXMLPolyDataWriter.h"
5+
#include "vtkXMLPolyDataReader.h"
6+
#include "vtkSmartPointer.h"
7+
#include "vtkPolyData.h"
8+
#include "vtkNew.h"
9+
#include "vtkTransformFilter.h"
10+
#include "vtkTransform.h"
11+
#include "vtkPoints.h"
12+
#include "vtkCurvatures.h"
13+
#include "vtkPointData.h"
14+
#include "vtkDoubleArray.h"
15+
16+
17+
18+
int main (int argc, char * argv[])
19+
{
20+
PARSE_ARGS;
21+
22+
try{
23+
24+
25+
vtkSmartPointer<vtkPolyData> polyData;
26+
27+
28+
// Read the file
29+
vtkNew<vtkXMLPolyDataReader> reader;
30+
reader->SetFileName(inputVolume.c_str());
31+
reader->Update();
32+
polyData = reader->GetOutput();
33+
34+
vtkNew<vtkCurvatures> curveMax;
35+
curveMax->SetInputData(polyData);
36+
curveMax->SetCurvatureTypeToMaximum();
37+
curveMax->Update();
38+
39+
vtkSmartPointer<vtkPolyData> polyDataCurveMax = curveMax->GetOutput();
40+
41+
vtkNew<vtkCurvatures> curveMin;
42+
curveMin->SetInputData(polyData);
43+
curveMin->SetCurvatureTypeToMinimum();
44+
curveMin->Update();
45+
vtkSmartPointer<vtkPolyData> polyDataCurveMin = curveMin->GetOutput();
46+
47+
unsigned int nPoints = polyDataCurveMax->GetNumberOfPoints();
48+
vtkSmartPointer<vtkDoubleArray> ArrayCurveMax = vtkDoubleArray::SafeDownCast(
49+
polyDataCurveMax->GetPointData()->GetScalars()
50+
);
51+
vtkSmartPointer<vtkDoubleArray> ArrayCurveMin = vtkDoubleArray::SafeDownCast(
52+
polyDataCurveMin->GetPointData()->GetScalars()
53+
);
54+
55+
std::ofstream curvedness(outputCurve);
56+
std::ofstream shapeIndex(outputShape);
57+
std::ofstream gauss(outputGauss);
58+
std::ofstream mean(outputMean);
59+
60+
curvedness << "NUMBER_OF_POINTS=" << nPoints << std::endl;
61+
curvedness << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl;
62+
63+
shapeIndex << "NUMBER_OF_POINTS=" << nPoints << std::endl;
64+
shapeIndex << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl;
65+
66+
gauss << "NUMBER_OF_POINTS=" << nPoints << std::endl;
67+
gauss << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl;
68+
69+
mean << "NUMBER_OF_POINTS=" << nPoints << std::endl;
70+
mean << "DIMENSION=1" << std::endl << "TYPE=Scalar" << std::endl;
71+
72+
if( ArrayCurveMax && ArrayCurveMin )
73+
{
74+
75+
for( unsigned int i = 0; i < nPoints; i++ )
76+
{
77+
78+
float curvmax, curvmin;
79+
curvmax = ArrayCurveMax->GetValue(i);
80+
curvmin = ArrayCurveMin->GetValue(i);
81+
82+
float aux = sqrt( (pow(curvmax, 2) + pow(curvmin, 2) ) / 2);
83+
curvedness << aux << std::endl;
84+
85+
aux = (2 / M_PI) * (atan( (curvmax + curvmin) / (curvmax - curvmin) ) );
86+
if( aux != aux )
87+
{
88+
aux = 0;
89+
}
90+
shapeIndex << aux << std::endl;
91+
92+
aux = curvmax * curvmin;
93+
gauss << aux << std::endl;
94+
95+
aux = (curvmax + curvmin) / 2;
96+
mean << aux << std::endl;
97+
// std::cout << "Curvature: " << curv << std::endl;
98+
}
99+
}
100+
else
101+
{
102+
// std::cout << "Got no array?" << std::endl;
103+
104+
curvedness.close();
105+
}
106+
107+
curvedness.close();
108+
shapeIndex.close();
109+
gauss.close();
110+
mean.close();
111+
112+
//Write to file
113+
//vtkNew<vtkXMLPolyDataWriter> writer;
114+
//writer->SetFileName(outputVolume.c_str());
115+
//writer->SetInputData(polyData);
116+
//writer->Update();
117+
}
118+
catch (int e)
119+
{
120+
cout << "An exception occurred. Exception Nr. " << e << '\n';
121+
return EXIT_FAILURE;
122+
}
123+
124+
return EXIT_SUCCESS;
125+
126+
}

GetCurvatures/GetCurvatures.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<executable>
3+
<category>Surface Models.Advanced</category>
4+
<title>GetCurvatures</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/GetCurvatures</documentation-url>
8+
<license>Slicer</license>
9+
<contributor>Ben Wilson (Kitware)</contributor>
10+
<acknowledgements></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+
<file>
22+
<name>outputCurve</name>
23+
<label>Curve Output File Name</label>
24+
<channel>output</channel>
25+
<description>Curve Output File Name</description>
26+
<default></default>
27+
</file>
28+
<file>
29+
<name>outputShape</name>
30+
<label>Shape Output File Name</label>
31+
<channel>output</channel>
32+
<description>Shape Output File Name</description>
33+
<default></default>
34+
</file>
35+
<file>
36+
<name>outputGauss</name>
37+
<label>Gauss Output File Name</label>
38+
<channel>output</channel>
39+
<description>Gauss Output File Name</description>
40+
<default></default>
41+
</file>
42+
<file>
43+
<name>outputMean</name>
44+
<label>Mean Output File Name</label>
45+
<channel>output</channel>
46+
<description>Mean Output File Name</description>
47+
<default></default>
48+
</file>
49+
</parameters>
50+
</executable>

0 commit comments

Comments
 (0)