-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add examples to the template. #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.10.2) | ||
project({{ cookiecutter.module_name }}Examples) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, do we need to enable and add tests for the examples? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the example does something, we can use it to write a test, see this. Having test data in there is harder to properly support, that's why I removed it. |
||
|
||
find_package(ITK REQUIRED | ||
COMPONENTS | ||
ITKImageIO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is problematic if the example is built as part of ITK. See this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fbudin69500 do you think we should add this to the module template? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems difficult to address cleanly for now as the template would have to explicitly instantiate certain IOs and it is not possible to know ahead of time which IOs should be instantiated. There could be hints in the CMakeLists.txt with commented out lines of code with the IO names that the developer could either uncomment or remove, but that doesn't seem ideal. @dzenanz : Was an issue created in the issue tracker for that Meta module IO issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just created an issue: InsightSoftwareConsortium/ITK#359 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could apply solution from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR #163. |
||
{{ cookiecutter.module_name }} | ||
) | ||
include(${ITK_USE_FILE}) | ||
|
||
add_executable({{ cookiecutter.example_name }} {{ cookiecutter.example_name }}.cxx ) | ||
target_link_libraries({{ cookiecutter.example_name }} ${ITK_LIBRARIES}) |
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; | ||
} |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add
CXX
or does this help CMake somehow exclude any Python example file that is added along?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python examples don't need to be built -- the default include
CXX
-> this is good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 So do we need to use
explicitly then?