forked from blowekamp/itkExternalTemplate
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a hint to foster writing examples for the contributed classes.
- Loading branch information
1 parent
de17054
commit d233c14
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ else() | |
set(ITK_DIR ${CMAKE_BINARY_DIR}) | ||
itk_module_impl() | ||
endif() | ||
|
||
itk_module_examples() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.16.3) | ||
project({{ cookiecutter.module_name }}Examples) | ||
|
||
set(ExampleSpecificComponents | ||
{{ cookiecutter.module_name }} | ||
) | ||
|
||
if(NOT ITK_SOURCE_DIR) | ||
find_package(ITK REQUIRED COMPONENTS ITKImageIO ITKTransformIO ${ExampleSpecificComponents}) | ||
else() | ||
# When being built as part of ITK, ITKImageIO and ITKTransformIO | ||
# lists of modules are not yet ready, causing a configure error | ||
find_package(ITK REQUIRED COMPONENTS ${ExampleSpecificComponents}) | ||
endif() | ||
include(${ITK_USE_FILE}) | ||
|
||
add_executable({{ cookiecutter.example_name }} {{ cookiecutter.example_name }}.cxx ) | ||
target_link_libraries({{ cookiecutter.example_name }} ${ITK_LIBRARIES}) |
45 changes: 45 additions & 0 deletions
45
{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*========================================================================= | ||
* | ||
* Copyright Insight Software Consortium | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
|
||
#include "itk{{cookiecutter.filter_name}}.h" | ||
|
||
#include "itkCommand.h" | ||
#include "itkImageFileReader.h" | ||
#include "itkImageFileWriter.h" | ||
|
||
|
||
int main( int argc, char * argv[] ) | ||
{ | ||
if( argc < 4 ) | ||
{ | ||
std::cerr << "Missing parameters." << std::endl; | ||
std::cerr << "Usage: " << argv[0] | ||
<< " inputImage" | ||
<< " outputImage" | ||
<< " parameters" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
|
||
// Please, write a complete, self-containted and useful example that | ||
// demonstrate a class when being used along with other ITK classes or in | ||
// the context of a wider or specific application. | ||
|
||
|
||
return EXIT_SUCCESS; | ||
} |
42 changes: 42 additions & 0 deletions
42
{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright Insight Software Consortium | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0.txt | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Run with: | ||
# ./{{ cookiecutter.example_name }}.py <InputImageFile> <OutputImageFile> | ||
# <Parameters> | ||
# e.g. | ||
# ./{{ cookiecutter.example_name }}.py MyImage.mha Output.mha 2 0.2 | ||
# (A rule of thumb is to set the Threshold to be about 1 / 100 of the Level.) | ||
# | ||
# parameter_1: absolute minimum... | ||
# The assumption is that... | ||
# parameter_2: controls the.. | ||
# A tradeoff between... | ||
|
||
import sys | ||
import itk | ||
|
||
import numpy as np | ||
|
||
|
||
if len(sys.argv) != 4: | ||
print('Usage: ' + sys.argv[0] + | ||
' <InputFileName> <OutputFileName> <Parameters>') | ||
sys.exit(1) | ||
|
||
# Please, write a complete, self-containted and useful example that | ||
# demonstrate a class when being used along with other ITK classes or in | ||
# the context of a wider or specific application. |