diff --git a/Modules/Core/files.cmake b/Modules/Core/files.cmake index 1aa29e2075..e7919a0e4b 100644 --- a/Modules/Core/files.cmake +++ b/Modules/Core/files.cmake @@ -1,328 +1,329 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES mitkCoreActivator.cpp mitkCoreObjectFactoryBase.cpp mitkCoreObjectFactory.cpp mitkCoreServices.cpp mitkException.cpp + DataManagement/shape.cpp Algorithms/mitkBaseDataSource.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkCompositePixelValueToString.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkExtractSliceFilter2.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkPlaneGeometryDataToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkTemporalJoinImagesFilter.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkCrosshairManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSliceNavigationHelper.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkTimeNavigationController.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAnatomicalStructureColorPresets.cpp DataManagement/mitkArbitraryTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkApplyTransformMatrixOperation.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseGeometry.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkCrosshairData.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataStorage.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGeometryTransformHolder.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkGenericIDRelationRule.cpp DataManagement/mitkIdentifiable.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageReadAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageVtkReadAccessor.cpp DataManagement/mitkImageVtkWriteAccessor.cpp DataManagement/mitkImageWriteAccessor.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkIPersistenceService.cpp DataManagement/mitkIPropertyAliases.cpp DataManagement/mitkIPropertyDescriptions.cpp DataManagement/mitkIPropertyDeserialization.cpp DataManagement/mitkIPropertyExtensions.cpp DataManagement/mitkIPropertyFilters.cpp DataManagement/mitkIPropertyOwner.cpp DataManagement/mitkIPropertyPersistence.cpp DataManagement/mitkIPropertyProvider.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTableProperty.cpp DataManagement/mitkLookupTables.cpp DataManagement/mitkMaterial.cpp DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModifiedLock.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDataUID.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFunction.cpp DataManagement/mitkNodePredicateGeometry.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateDataProperty.cpp DataManagement/mitkNodePredicateSubGeometry.cpp DataManagement/mitkNumericConstants.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneGeometryData.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyDeserialization.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyFilters.cpp DataManagement/mitkPropertyKeyPath.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkPropertyListReplacedObserver.cpp DataManagement/mitkPropertyNameHelper.cpp DataManagement/mitkPropertyObserver.cpp DataManagement/mitkPropertyPersistence.cpp DataManagement/mitkPropertyPersistenceInfo.cpp DataManagement/mitkPropertyRelationRuleBase.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkScaleOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkSourceImageRelationRule.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTemporoSpatialStringProperty.cpp DataManagement/mitkUIDManipulator.cpp DataManagement/mitkVectorProperty.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkIPropertyRelations.cpp DataManagement/mitkPropertyRelations.cpp Interactions/mitkAction.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayActionEventBroadcast.cpp Interactions/mitkDisplayActionEventFunctions.cpp Interactions/mitkDisplayActionEventHandler.cpp Interactions/mitkDisplayActionEventHandlerDesynchronized.cpp Interactions/mitkDisplayActionEventHandlerStd.cpp Interactions/mitkDisplayActionEventHandlerSynchronized.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventFactory.cpp Interactions/mitkEventRecorder.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkInteractionEventObserver.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInteractionSchemeSwitcher.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkSinglePointDataInteractor.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkXML2EventParser.cpp IO/mitkAbstractFileIO.cpp IO/mitkAbstractFileReader.cpp IO/mitkAbstractFileWriter.cpp IO/mitkCustomMimeType.cpp IO/mitkFileReader.cpp IO/mitkFileReaderRegistry.cpp IO/mitkFileReaderSelector.cpp IO/mitkFileReaderWriterBase.cpp IO/mitkFileWriter.cpp IO/mitkFileWriterRegistry.cpp IO/mitkFileWriterSelector.cpp IO/mitkGeometry3DToXML.cpp IO/mitkIFileIO.cpp IO/mitkIFileReader.cpp IO/mitkIFileWriter.cpp IO/mitkGeometryDataReaderService.cpp IO/mitkGeometryDataWriterService.cpp IO/mitkImageVtkLegacyIO.cpp IO/mitkImageVtkXmlIO.cpp IO/mitkIMimeTypeProvider.cpp IO/mitkIOConstants.cpp IO/mitkIOMimeTypes.cpp IO/mitkIOUtil.cpp IO/mitkItkImageIO.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkLegacyFileReaderService.cpp IO/mitkLegacyFileWriterService.cpp IO/mitkLocaleSwitch.cpp IO/mitkLogBackend.cpp IO/mitkMimeType.cpp IO/mitkMimeTypeProvider.cpp IO/mitkOperation.cpp IO/mitkPixelType.cpp IO/mitkPointSetReaderService.cpp IO/mitkPointSetWriterService.cpp IO/mitkProportionalTimeGeometryToXML.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSurfaceStlIO.cpp IO/mitkSurfaceVtkIO.cpp IO/mitkSurfaceVtkLegacyIO.cpp IO/mitkSurfaceVtkXmlIO.cpp IO/mitkUtf8Util.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkPreferenceListReaderOptionsFunctor.cpp IO/mitkIOMetaInformationPropertyConstants.cpp IO/mitkIPreferences.cpp IO/mitkPreferences.cpp IO/mitkIPreferencesService.cpp IO/mitkPreferencesService.cpp IO/mitkIPreferencesStorage.cpp IO/mitkXMLPreferencesStorage.cpp Rendering/mitkAbstractAnnotationRenderer.cpp Rendering/mitkAnnotationUtils.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkBaseRendererHelper.cpp Rendering/mitkCrosshairVtkMapper2D.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/mitkMapper.cpp Rendering/mitkAnnotation.cpp Rendering/mitkPlaneGeometryDataMapper2D.cpp Rendering/mitkPlaneGeometryDataVtkMapper3D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkSurfaceVtkMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVideoRecorder.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp ) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfigMITKBase.xml Interactions/DisplayConfigPACSBase.xml Interactions/DisplayConfigCrosshair.xml Interactions/DisplayConfigRotation.xml Interactions/DisplayConfigActivateCoupling.xml Interactions/DisplayConfigSwivel.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigBlockLMB.xml Interactions/PointSet.xml Interactions/PointSetConfig.xml mitkLevelWindowPresets.xml mitkAnatomicalStructureColorPresets.xml ) diff --git a/Modules/Core/include/shape.h b/Modules/Core/include/shape.h new file mode 100644 index 0000000000..210bd29814 --- /dev/null +++ b/Modules/Core/include/shape.h @@ -0,0 +1,41 @@ +#ifndef SHAPE_H +#define SHAPE_H +#include +namespace mitk +{ + class MITKCORE_EXPORT Shape + { + public: + //static int nshapes; + Shape() = default;// { nshapes++; } + virtual ~Shape() = default; //{ nshapes--; } + double x, y; + void move(double dx, double dy); + virtual double area() = 0; + virtual double perimeter() = 0; + }; + + class MITKCORE_EXPORT Circle : public Shape + { + private: + double radius; + + public: + Circle(double r);// : radius(r) {} + double area() override; + double perimeter() override; + }; + + class MITKCORE_EXPORT Square : public Shape + { + private: + double width; + + public: + Square(double w);// : width(w) {} + double area() override; + double perimeter() override; + }; + +} +#endif diff --git a/Modules/Core/src/DataManagement/shape.cpp b/Modules/Core/src/DataManagement/shape.cpp new file mode 100644 index 0000000000..f6a4d1fad0 --- /dev/null +++ b/Modules/Core/src/DataManagement/shape.cpp @@ -0,0 +1,38 @@ +#include +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void mitk::Shape::move(double dx, double dy) +{ + x += dx; + y += dy; +} + +/* namespace mitk +{ + int Shape::nshapes = 0; +}*/ + +mitk::Circle::Circle(double r): radius(r) {} + +double mitk::Circle::area() +{ + return M_PI*radius*radius; +} + +double mitk::Circle::perimeter() +{ + return 2*M_PI*radius; +} + +mitk::Square::Square(double w) : width(w) {} + +double mitk::Square::area() +{ + return width*width; +} + +double mitk::Square::perimeter() +{ + return 4*width; +} diff --git a/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.cpp b/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.cpp index 38d24375cf..a681d74240 100644 --- a/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.cpp +++ b/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.cpp @@ -1,379 +1,379 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "DeepLearningSegmentationTool.h" -#include -#include -#include -#include -#include -#include - -mitk::DeepLearningSegmentationTool::DeepLearningSegmentationTool(std::string toolName, - std::string iconName, - std::string pythonFolder, - std::string inputImageVarName, - std::string pythonFileName, - std::string outputImageVarName, - ImageType imageType, - bool multilabel) -{ - m_ToolName = toolName; - m_IconName = iconName; - m_PythonProjectPath = "Modules/DeepLearningSegmentation/"+pythonFolder; - m_InputImageVarName = inputImageVarName; - m_PythonFileName = pythonFileName; - m_OutputImageVarName = outputImageVarName; - m_ImageType = imageType; - m_MultilabelSegmentation = multilabel; - m_SegmentationRunning = false; -} - -mitk::DeepLearningSegmentationTool::~DeepLearningSegmentationTool() { -} - -us::ModuleResource mitk::DeepLearningSegmentationTool::GetIconResource() const -{ - auto moduleContext = us::GetModuleContext(); - auto module = moduleContext->GetModule(); - auto resource = module->GetResource(m_IconName); - return resource; -} - -const char *mitk::DeepLearningSegmentationTool::GetName() const -{ - return m_ToolName.c_str(); -} - -const char **mitk::DeepLearningSegmentationTool::GetXPM() const -{ - return nullptr; -} - -void mitk::DeepLearningSegmentationTool::Activated() -{ - Superclass::Activated(); -} - -void mitk::DeepLearningSegmentationTool::Deactivated() -{ - Superclass::Deactivated(); -} - -mitk::LabelSetImage::Pointer mitk::DeepLearningSegmentationTool::DoSegmentation(std::string networkPath) -{ - m_SegmentationRunning = true; - //get the input Image - mitk::Image::Pointer input; - try - { - input = GetInputImage(); - } - catch(mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow(); - } - - //Get the python microservice - mitk::IPythonService::ForceLoadModule(); - us::ModuleContext *context = us::GetModuleContext(); - std::string filter = "(Name=PythonService)"; - auto m_PythonServiceRefs = context->GetServiceReferences(filter); - - if (!m_PythonServiceRefs.empty()) - { - mitk::IPythonService *m_PythonService = - dynamic_cast(context->GetService(m_PythonServiceRefs.front())); - // set path to the Python code which should be executed - try - { - std::vector pathVector; - pathVector.push_back(m_PythonProjectPath); - m_PythonService->AddRelativeSearchDirs(pathVector); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in setting the path to the Python code which should be executed"; - m_SegmentationRunning = false; - return nullptr; - } - // set the path to the trained network - try - { - std::string pathCommand = "network_path = '" + networkPath+"'"; - m_PythonService->Execute(pathCommand); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in setting the network path"; - m_SegmentationRunning = false; - return nullptr; - } - - //set the input image - try - { - if (m_ImageType==DeepLearningSegmentationTool::SimpleITKImage) - { - m_PythonService->CopyToPythonAsSimpleItkImage(input, m_InputImageVarName); - } - else if (m_ImageType==DeepLearningSegmentationTool::MITKImage) - { - m_PythonService->CopyMITKImageToPython(input, m_InputImageVarName); - } - else - { - mitkThrow() << "Unknown image type"; - } - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error setting the input image"; - m_SegmentationRunning = false; - return nullptr; - } - - // execute Segmentation - try - { - std::string fileName = mitk::StandardFileLocations::GetInstance()->FindFile( - m_PythonFileName.c_str(), m_PythonProjectPath.c_str()); - m_PythonService->ExecuteScript(fileName); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in executing python code"; - m_SegmentationRunning = false; - return nullptr; - } - - // get result - try - { - mitk::Image::Pointer outputImage; - if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) - { - outputImage = m_PythonService->CopySimpleItkImageFromPython(m_OutputImageVarName); - } - else if (m_ImageType == DeepLearningSegmentationTool::MITKImage) - { - outputImage = m_PythonService->CopyMITKImageFromPython(m_OutputImageVarName); - } - else - { - mitkThrow() << "Unknown image type"; - } - mitk::LabelSetImage::Pointer resultImage = mitk::LabelSetImage::New(); - resultImage->InitializeByLabeledImage(outputImage); - resultImage->SetGeometry(input->GetGeometry()); - m_SegmentationRunning = false; - outputImage->SetGeometry(input->GetGeometry()); - return resultImage; - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in getting the result"; - m_SegmentationRunning = false; - return nullptr; - } - } - else - { - mitkThrow() << "No service reference found"; - } - m_SegmentationRunning = false; - return nullptr; -} - -std::vector mitk::DeepLearningSegmentationTool::DoMultilabelSegmentation(std::string networkPath) -{ - - std::vector result; - m_SegmentationRunning = true; - // get the input Image - mitk::Image::Pointer input; - try - { - input = GetInputImage(); - } - catch (mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow(); - } - - // Get the python microservice - mitk::IPythonService::ForceLoadModule(); - us::ModuleContext *context = us::GetModuleContext(); - std::string filter = "(Name=PythonService)"; - auto m_PythonServiceRefs = context->GetServiceReferences(filter); - - if (!m_PythonServiceRefs.empty()) - { - mitk::IPythonService *m_PythonService = - dynamic_cast(context->GetService(m_PythonServiceRefs.front())); - // set path to the Python code which should be executed - try - { - std::vector pathVector; - pathVector.push_back(m_PythonProjectPath); - m_PythonService->AddRelativeSearchDirs(pathVector); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in setting the path to the Python code which should be executed"; - m_SegmentationRunning = false; - return result; - } - // set the path to the trained network - try - { - std::string pathCommand = "network_path = '" + networkPath + "'"; - m_PythonService->Execute(pathCommand); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in setting the network path"; - m_SegmentationRunning = false; - return result; - } - - // set the input image - try - { - if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) - { - m_PythonService->CopyToPythonAsSimpleItkImage(input, m_InputImageVarName); - } - else if (m_ImageType == DeepLearningSegmentationTool::MITKImage) - { - m_PythonService->CopyMITKImageToPython(input, m_InputImageVarName); - } - else - { - mitkThrow() << "Unknown image type"; - } - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error setting the input image"; - m_SegmentationRunning = false; - return result; - } - - // execute Segmentation - try - { - std::string fileName = - mitk::StandardFileLocations::GetInstance()->FindFile(m_PythonFileName.c_str(), m_PythonProjectPath.c_str()); - m_PythonService->ExecuteScript(fileName); - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in executing python code"; - m_SegmentationRunning = false; - return result; - } - - // get result - try - { - std::vector outputImages; - //if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) - //{ - // outputImage = m_PythonService->CopySimpleItkImageFromPython(m_OutputImageVarName); - //} - if (m_ImageType == DeepLearningSegmentationTool::MITKImage) - { - outputImages = m_PythonService->CopyListOfMITKImagesFromPython(m_OutputImageVarName); - } - else - { - mitkThrow() << "Unknown image type"; - } - - for (mitk::Image::Pointer image : outputImages) - { - mitk::LabelSetImage::Pointer resultImage = mitk::LabelSetImage::New(); - resultImage->InitializeByLabeledImage(image); - resultImage->SetGeometry(input->GetGeometry()); - m_SegmentationRunning = false; - resultImage->SetGeometry(input->GetGeometry()); - result.push_back(resultImage); - } - return result; - } - catch (const mitk::Exception &e) - { - MITK_ERROR << e.GetDescription(); - mitkThrow() << "Error in getting the result"; - m_SegmentationRunning = false; - return result; - } - } - else - { - mitkThrow() << "No service reference found"; - } - m_SegmentationRunning = false; - return result; -} - - -mitk::DataStorage *mitk::DeepLearningSegmentationTool::GetDataStorage() -{ - return GetToolManager()->GetDataStorage(); - GetToolManager()->GetReferenceData(0); -} - -mitk::DataNode *mitk::DeepLearningSegmentationTool::GetReferenceData() -{ - return GetToolManager()->GetReferenceData(0); -} - -mitk::Image::Pointer mitk::DeepLearningSegmentationTool::GetInputImage() - { - mitk::DataNode::Pointer referenceData = GetToolManager()->GetReferenceData(0); - mitk::Image::Pointer input = dynamic_cast(referenceData->GetData()); - if (input.IsNull()) - { - mitkThrow(); - } - //unsigned int timestep = mitk::RenderingManager::GetInstance()->GetTimeNavigationController()->GetTime()->GetPos(); - //mitk::Image::ConstPointer input = Get3DImage(input, timestep); - if (input.IsNull()) - { - mitkThrow(); - } - - return input; - } - -bool mitk::DeepLearningSegmentationTool::IsSegmentationRunning() -{ - return m_SegmentationRunning; -} - -bool mitk::DeepLearningSegmentationTool::IsMultilabelSegmentation() -{ - return m_MultilabelSegmentation; -} +//#include +//#include +//#include +//#include +//#include +//#include +// +//mitk::DeepLearningSegmentationTool::DeepLearningSegmentationTool(std::string toolName, +// std::string iconName, +// std::string pythonFolder, +// std::string inputImageVarName, +// std::string pythonFileName, +// std::string outputImageVarName, +// ImageType imageType, +// bool multilabel) +//{ +// m_ToolName = toolName; +// m_IconName = iconName; +// m_PythonProjectPath = "Modules/DeepLearningSegmentation/"+pythonFolder; +// m_InputImageVarName = inputImageVarName; +// m_PythonFileName = pythonFileName; +// m_OutputImageVarName = outputImageVarName; +// m_ImageType = imageType; +// m_MultilabelSegmentation = multilabel; +// m_SegmentationRunning = false; +//} +// +//mitk::DeepLearningSegmentationTool::~DeepLearningSegmentationTool() { +//} +// +//us::ModuleResource mitk::DeepLearningSegmentationTool::GetIconResource() const +//{ +// auto moduleContext = us::GetModuleContext(); +// auto module = moduleContext->GetModule(); +// auto resource = module->GetResource(m_IconName); +// return resource; +//} +// +//const char *mitk::DeepLearningSegmentationTool::GetName() const +//{ +// return m_ToolName.c_str(); +//} +// +//const char **mitk::DeepLearningSegmentationTool::GetXPM() const +//{ +// return nullptr; +//} +// +//void mitk::DeepLearningSegmentationTool::Activated() +//{ +// Superclass::Activated(); +//} +// +//void mitk::DeepLearningSegmentationTool::Deactivated() +//{ +// Superclass::Deactivated(); +//} +// +//mitk::LabelSetImage::Pointer mitk::DeepLearningSegmentationTool::DoSegmentation(std::string networkPath) +//{ +// m_SegmentationRunning = true; +// //get the input Image +// mitk::Image::Pointer input; +// try +// { +// input = GetInputImage(); +// } +// catch(mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow(); +// } +// +// //Get the python microservice +// mitk::IPythonService::ForceLoadModule(); +// us::ModuleContext *context = us::GetModuleContext(); +// std::string filter = "(Name=PythonService)"; +// auto m_PythonServiceRefs = context->GetServiceReferences(filter); +// +// if (!m_PythonServiceRefs.empty()) +// { +// mitk::IPythonService *m_PythonService = +// dynamic_cast(context->GetService(m_PythonServiceRefs.front())); +// // set path to the Python code which should be executed +// try +// { +// std::vector pathVector; +// pathVector.push_back(m_PythonProjectPath); +// m_PythonService->AddRelativeSearchDirs(pathVector); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in setting the path to the Python code which should be executed"; +// m_SegmentationRunning = false; +// return nullptr; +// } +// // set the path to the trained network +// try +// { +// std::string pathCommand = "network_path = '" + networkPath+"'"; +// m_PythonService->Execute(pathCommand); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in setting the network path"; +// m_SegmentationRunning = false; +// return nullptr; +// } +// +// //set the input image +// try +// { +// if (m_ImageType==DeepLearningSegmentationTool::SimpleITKImage) +// { +// m_PythonService->CopyToPythonAsSimpleItkImage(input, m_InputImageVarName); +// } +// else if (m_ImageType==DeepLearningSegmentationTool::MITKImage) +// { +// m_PythonService->CopyMITKImageToPython(input, m_InputImageVarName); +// } +// else +// { +// mitkThrow() << "Unknown image type"; +// } +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error setting the input image"; +// m_SegmentationRunning = false; +// return nullptr; +// } +// +// // execute Segmentation +// try +// { +// std::string fileName = mitk::StandardFileLocations::GetInstance()->FindFile( +// m_PythonFileName.c_str(), m_PythonProjectPath.c_str()); +// m_PythonService->ExecuteScript(fileName); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in executing python code"; +// m_SegmentationRunning = false; +// return nullptr; +// } +// +// // get result +// try +// { +// mitk::Image::Pointer outputImage; +// if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) +// { +// outputImage = m_PythonService->CopySimpleItkImageFromPython(m_OutputImageVarName); +// } +// else if (m_ImageType == DeepLearningSegmentationTool::MITKImage) +// { +// outputImage = m_PythonService->CopyMITKImageFromPython(m_OutputImageVarName); +// } +// else +// { +// mitkThrow() << "Unknown image type"; +// } +// mitk::LabelSetImage::Pointer resultImage = mitk::LabelSetImage::New(); +// resultImage->InitializeByLabeledImage(outputImage); +// resultImage->SetGeometry(input->GetGeometry()); +// m_SegmentationRunning = false; +// outputImage->SetGeometry(input->GetGeometry()); +// return resultImage; +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in getting the result"; +// m_SegmentationRunning = false; +// return nullptr; +// } +// } +// else +// { +// mitkThrow() << "No service reference found"; +// } +// m_SegmentationRunning = false; +// return nullptr; +//} +// +//std::vector mitk::DeepLearningSegmentationTool::DoMultilabelSegmentation(std::string networkPath) +//{ +// +// std::vector result; +// m_SegmentationRunning = true; +// // get the input Image +// mitk::Image::Pointer input; +// try +// { +// input = GetInputImage(); +// } +// catch (mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow(); +// } +// +// // Get the python microservice +// mitk::IPythonService::ForceLoadModule(); +// us::ModuleContext *context = us::GetModuleContext(); +// std::string filter = "(Name=PythonService)"; +// auto m_PythonServiceRefs = context->GetServiceReferences(filter); +// +// if (!m_PythonServiceRefs.empty()) +// { +// mitk::IPythonService *m_PythonService = +// dynamic_cast(context->GetService(m_PythonServiceRefs.front())); +// // set path to the Python code which should be executed +// try +// { +// std::vector pathVector; +// pathVector.push_back(m_PythonProjectPath); +// m_PythonService->AddRelativeSearchDirs(pathVector); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in setting the path to the Python code which should be executed"; +// m_SegmentationRunning = false; +// return result; +// } +// // set the path to the trained network +// try +// { +// std::string pathCommand = "network_path = '" + networkPath + "'"; +// m_PythonService->Execute(pathCommand); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in setting the network path"; +// m_SegmentationRunning = false; +// return result; +// } +// +// // set the input image +// try +// { +// if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) +// { +// m_PythonService->CopyToPythonAsSimpleItkImage(input, m_InputImageVarName); +// } +// else if (m_ImageType == DeepLearningSegmentationTool::MITKImage) +// { +// m_PythonService->CopyMITKImageToPython(input, m_InputImageVarName); +// } +// else +// { +// mitkThrow() << "Unknown image type"; +// } +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error setting the input image"; +// m_SegmentationRunning = false; +// return result; +// } +// +// // execute Segmentation +// try +// { +// std::string fileName = +// mitk::StandardFileLocations::GetInstance()->FindFile(m_PythonFileName.c_str(), m_PythonProjectPath.c_str()); +// m_PythonService->ExecuteScript(fileName); +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in executing python code"; +// m_SegmentationRunning = false; +// return result; +// } +// +// // get result +// try +// { +// std::vector outputImages; +// //if (m_ImageType == DeepLearningSegmentationTool::SimpleITKImage) +// //{ +// // outputImage = m_PythonService->CopySimpleItkImageFromPython(m_OutputImageVarName); +// //} +// if (m_ImageType == DeepLearningSegmentationTool::MITKImage) +// { +// outputImages = m_PythonService->CopyListOfMITKImagesFromPython(m_OutputImageVarName); +// } +// else +// { +// mitkThrow() << "Unknown image type"; +// } +// +// for (mitk::Image::Pointer image : outputImages) +// { +// mitk::LabelSetImage::Pointer resultImage = mitk::LabelSetImage::New(); +// resultImage->InitializeByLabeledImage(image); +// resultImage->SetGeometry(input->GetGeometry()); +// m_SegmentationRunning = false; +// resultImage->SetGeometry(input->GetGeometry()); +// result.push_back(resultImage); +// } +// return result; +// } +// catch (const mitk::Exception &e) +// { +// MITK_ERROR << e.GetDescription(); +// mitkThrow() << "Error in getting the result"; +// m_SegmentationRunning = false; +// return result; +// } +// } +// else +// { +// mitkThrow() << "No service reference found"; +// } +// m_SegmentationRunning = false; +// return result; +//} +// +// +//mitk::DataStorage *mitk::DeepLearningSegmentationTool::GetDataStorage() +//{ +// return GetToolManager()->GetDataStorage(); +// GetToolManager()->GetReferenceData(0); +//} +// +//mitk::DataNode *mitk::DeepLearningSegmentationTool::GetReferenceData() +//{ +// return GetToolManager()->GetReferenceData(0); +//} +// +//mitk::Image::Pointer mitk::DeepLearningSegmentationTool::GetInputImage() +// { +// mitk::DataNode::Pointer referenceData = GetToolManager()->GetReferenceData(0); +// mitk::Image::Pointer input = dynamic_cast(referenceData->GetData()); +// if (input.IsNull()) +// { +// mitkThrow(); +// } +// //unsigned int timestep = mitk::RenderingManager::GetInstance()->GetTimeNavigationController()->GetTime()->GetPos(); +// //mitk::Image::ConstPointer input = Get3DImage(input, timestep); +// if (input.IsNull()) +// { +// mitkThrow(); +// } +// +// return input; +// } +// +//bool mitk::DeepLearningSegmentationTool::IsSegmentationRunning() +//{ +// return m_SegmentationRunning; +//} +// +//bool mitk::DeepLearningSegmentationTool::IsMultilabelSegmentation() +//{ +// return m_MultilabelSegmentation; +//} diff --git a/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.h b/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.h index 13a4b7f648..16904f419f 100644 --- a/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.h +++ b/Modules/DeepLearningSegmentation/DeepLearningSegmentationTool.h @@ -1,131 +1,131 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef DeepLearningSegmentationTool_h #define DeepLearningSegmentationTool_h -#include -#include - -namespace us { -class ModuleResource; -} - -namespace mitk -{ - /** - * @class DeepLearningSegmentationTool - * @brief This is the base class for all Deep Learning Based Segmentations - */ - class MITKDEEPLEARNINGSEGMENTATION_EXPORT DeepLearningSegmentationTool : public mitk::AutoSegmentationTool - { - public: - enum ImageType - { - SimpleITKImage, - MITKImage - }; - /** - * @brief Getter for the icon of the module which is displayed in the Segmentation Plugin. - * @return icon of the segmentation method - */ - us::ModuleResource GetIconResource() const override; - - //bool CanHandle(mitk::BaseData *referenceData) const override; - - /** - * @brief Getter for the name of the module which is displayed in the Segmentation Plugin. - * @return name of the segmentation method - */ - const char *GetName() const override; - const char **GetXPM() const override; - - /** - * @brief Constructor - * - * @param pythonFolder the folder of the python code, should lie in "Modules/DeepLearningsegmentation" - * @param inputImageVarName the python variable name of the input image to segment - * @param pythonFileName the file name of the python script to execute. This is the entry point for the segmentation - * @param outputImageVarName the python variable name of the output image (segmentation) - */ - DeepLearningSegmentationTool(std::string toolName, - std::string iconName, - std::string pythonFolder, - std::string inputImageVarName, - std::string pythonFileName, - std::string outputImageVarName, - ImageType imageType, - bool multilabel = false); - ~DeepLearningSegmentationTool() override; - - void Activated() override; - void Deactivated() override; - - /** - * @brief Executes the segmentation by running python code - * - * @throw mitk::Exception if something went wrong during a python call, python service is not found, or no input image is found - * @param networkPath the path to the trained network for segmentation - * @return the segmentation result as label set image - */ - mitk::LabelSetImage::Pointer DoSegmentation(std::string networkPath); - /** - * @brief Executes the multilabel segmentation by running python code - * - * @throw mitk::Exception if something went wrong during a python call, python service is not found, or no input - * image is found - * @param networkPath the path to the trained network for segmentation - * @return the segmentation result as vector of label set image - */ - std::vector DoMultilabelSegmentation(std::string networkPath); - /** - * @brief Get the input image for the semgentation which is currently selected in the Segmentation Plugin - * - * @throw mitk::Exception if the input is null - * @return input image for segmentation - */ - mitk::Image::Pointer GetInputImage(); - /** - * @brief Getter for m_SegmentaionRunning, to determine, if a segmentation is currently executed - * @return m_SegmentaionRunning - */ - bool IsSegmentationRunning(); - - /** - * @brief Getter for the data storage from the tool manager - * @return data storage - */ - mitk::DataStorage* GetDataStorage(); - /** - * @brief Getter for the reference data from the tool manager - * @return reference data - */ - mitk::DataNode *GetReferenceData(); - - bool IsMultilabelSegmentation(); - - protected: - std::string m_PythonProjectPath; - std::string m_InputImageVarName; - std::string m_PythonFileName; - std::string m_OutputImageVarName; - - private: - std::string m_IconName; - std::string m_ToolName; - bool m_SegmentationRunning; - ImageType m_ImageType; - bool m_MultilabelSegmentation; - }; -} // namespace mitk +//#include +//#include +// +//namespace us { +//class ModuleResource; +//} +// +//namespace mitk +//{ +// /** +// * @class DeepLearningSegmentationTool +// * @brief This is the base class for all Deep Learning Based Segmentations +// */ +// class MITKDEEPLEARNINGSEGMENTATION_EXPORT DeepLearningSegmentationTool : public mitk::AutoSegmentationTool +// { +// public: +// enum ImageType +// { +// SimpleITKImage, +// MITKImage +// }; +// /** +// * @brief Getter for the icon of the module which is displayed in the Segmentation Plugin. +// * @return icon of the segmentation method +// */ +// us::ModuleResource GetIconResource() const override; +// +// //bool CanHandle(mitk::BaseData *referenceData) const override; +// +// /** +// * @brief Getter for the name of the module which is displayed in the Segmentation Plugin. +// * @return name of the segmentation method +// */ +// const char *GetName() const override; +// const char **GetXPM() const override; +// +// /** +// * @brief Constructor +// * +// * @param pythonFolder the folder of the python code, should lie in "Modules/DeepLearningsegmentation" +// * @param inputImageVarName the python variable name of the input image to segment +// * @param pythonFileName the file name of the python script to execute. This is the entry point for the segmentation +// * @param outputImageVarName the python variable name of the output image (segmentation) +// */ +// DeepLearningSegmentationTool(std::string toolName, +// std::string iconName, +// std::string pythonFolder, +// std::string inputImageVarName, +// std::string pythonFileName, +// std::string outputImageVarName, +// ImageType imageType, +// bool multilabel = false); +// ~DeepLearningSegmentationTool() override; +// +// void Activated() override; +// void Deactivated() override; +// +// /** +// * @brief Executes the segmentation by running python code +// * +// * @throw mitk::Exception if something went wrong during a python call, python service is not found, or no input image is found +// * @param networkPath the path to the trained network for segmentation +// * @return the segmentation result as label set image +// */ +// mitk::LabelSetImage::Pointer DoSegmentation(std::string networkPath); +// /** +// * @brief Executes the multilabel segmentation by running python code +// * +// * @throw mitk::Exception if something went wrong during a python call, python service is not found, or no input +// * image is found +// * @param networkPath the path to the trained network for segmentation +// * @return the segmentation result as vector of label set image +// */ +// std::vector DoMultilabelSegmentation(std::string networkPath); +// /** +// * @brief Get the input image for the semgentation which is currently selected in the Segmentation Plugin +// * +// * @throw mitk::Exception if the input is null +// * @return input image for segmentation +// */ +// mitk::Image::Pointer GetInputImage(); +// /** +// * @brief Getter for m_SegmentaionRunning, to determine, if a segmentation is currently executed +// * @return m_SegmentaionRunning +// */ +// bool IsSegmentationRunning(); +// +// /** +// * @brief Getter for the data storage from the tool manager +// * @return data storage +// */ +// mitk::DataStorage* GetDataStorage(); +// /** +// * @brief Getter for the reference data from the tool manager +// * @return reference data +// */ +// mitk::DataNode *GetReferenceData(); +// +// bool IsMultilabelSegmentation(); +// +// protected: +// std::string m_PythonProjectPath; +// std::string m_InputImageVarName; +// std::string m_PythonFileName; +// std::string m_OutputImageVarName; +// +// private: +// std::string m_IconName; +// std::string m_ToolName; +// bool m_SegmentationRunning; +// ImageType m_ImageType; +// bool m_MultilabelSegmentation; +// }; +//} // namespace mitk #endif diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index aec8c76d18..d10561022e 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -1,88 +1,88 @@ include(mitkTargetLinkLibrariesWithDynamicLookup) project(MITK_Python) set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "" FORCE) set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "" FORCE) mitk_check_dynamic_lookup(MODULE SHARED MITK_UNDEFINED_SYMBOLS_ALLOWED ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) option(MITK_PYTHON_THREADS "Enable threaded python usage by unlocking the GIL." ON ) option(MITK_PYTHON_EGG "Add building of python eggs to the dist target." OFF ) option(MITK_PYTHON_WHEEL "Add building of python wheels to the dist target." ON ) mark_as_advanced( MITK_PYTHON_THREADS MITK_PYTHON_EGG MITK_PYTHON_WHEEL ) set(libraries MitkCore - MitkCLCore - MitkCLUtilities - ITKCommon - MitkSegmentation - MitkMultilabel - MitkDICOM - MitkDICOMImageIO - MitkRT + #MitkCLCore + #MitkCLUtilities + #ITKCommon + #MitkSegmentation + #MitkMultilabel + #MitkDICOM + #MitkDICOMImageIO + #MitkRT ) if(MITK_USE_MatchPoint) list(APPEND libraries MitkMatchPointRegistration ) endif() -mitkSwigPrepareFiles(pyMITK MITK.i ${libraries}) +mitkSwigPrepareFiles(pyMITK MITKWRAP.i ${libraries}) set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS} -features autodoc=1 -keyword) if(MITK_PYTHON_THREADS) list(APPEND CMAKE_SWIG_FLAGS -threads) endif() set(CMAKE_SWIG_OUTDIR ${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}) set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) -swig_add_library(pyMITK LANGUAGE python SOURCES MITK.i) +swig_add_library(pyMITK LANGUAGE python SOURCES MITKWRAP.i) set_property(TARGET pyMITK PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Wrapping") target_link_libraries(pyMITK ${libraries}) mitk_target_link_libraries_with_dynamic_lookup(${SWIG_MODULE_pyMITK_REAL_NAME} ${Python3_LIBRARIES}) set_target_properties(pyMITK PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) execute_process(COMMAND ${SWIG_EXECUTABLE} -python -external-runtime) if(DEFINED SKBUILD) #message("SKBuild exists") install( FILES ${CMAKE_CURRENT_BINARY_DIR}/pyMITK.py ${CMAKE_CURRENT_SOURCE_DIR}/Packaging/__init__.py #${MITK_DOC_FILES} DESTINATION pyMITK COMPONENT Runtime ) install( TARGETS ${SWIG_MODULE_pyMITK_REAL_NAME} RUNTIME DESTINATION pyMITK LIBRARY DESTINATION pyMITK COMPONENT Runtime ) else() #message("SKBuild missing") include(LegacyPackaging.cmake) endif() diff --git a/Wrapping/Python/MITKWRAP.i b/Wrapping/Python/MITKWRAP.i new file mode 100644 index 0000000000..2831d93e28 --- /dev/null +++ b/Wrapping/Python/MITKWRAP.i @@ -0,0 +1,13 @@ +%begin %{ +#ifdef _MSC_VER +#define SWIG_PYTHON_INTERPRETER_NO_DEBUG +#endif +%} +%module pyMITK + +#define MITKCORE_EXPORT + +%{ +#include +%} +%include