/*============================================================================= NOTE: THIS FILE WAS AUTOMATICALLY GENERATED BY THE ManagedITK PROJECT. Project: ManagedITK Program: Insight Segmentation & Registration Toolkit Module: itkManaged@MANAGED_BASE_NAME@.cxx Language: C++/CLI Author: Dan Mueller $Date: 2007-04-11 16:26:16 +1000 (Wed, 11 Apr 2007) $ $Revision: 128 $ Copyright (c) Queensland University of Technology (QUT) 2007. All rights reserved. Portions of this code are covered under the ITK and VTK copyright. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =============================================================================*/ #pragma once #pragma warning( disable : 4635 ) // Disable warnings about XML doc comments #ifndef __itkManaged@MANAGED_BASE_NAME@_cxx #define __itkManaged@MANAGED_BASE_NAME@_cxx // Use some managed namespaces #using #using #using using namespace System; using namespace System::IO; using namespace System::Reflection; using namespace System::ComponentModel; using namespace System::Diagnostics; namespace itk { /// ///This class is a managed wrapper for itk::@MANAGED_BASE_NAME@. /// /// ///The actual type instance can be specified by calling the New() ///method with the desired output image type. /// public ref class itk@MANAGED_BASE_NAME@ : itkImageFunction { private: itkImageFunction^ m_Instance; protected: ///Protected constructor. itk@MANAGED_BASE_NAME@ ( ) : itkImageFunction( ) { } public: ///Dispose of the managed object. ~itk@MANAGED_BASE_NAME@ ( ) { if (!this->m_IsDisposed) { try { delete m_Instance; } catch ( ... ) { } finally { this->m_IsDisposed = true; } } } ///Finalize the managed object. !itk@MANAGED_BASE_NAME@ ( ) { } /// ///Get/set the pointer to the native ITK object associated with ///this wrapper instance. /// ///The pointer to the native ITK object. property void* NativePointer { virtual void* get() override { return this->m_Instance->NativePointer; } virtual void set ( void* value ) override { this->m_Instance->NativePointer = value; } } ///Get the last modified time. property unsigned long MTime { virtual unsigned long get() override { return this->m_Instance->MTime; } } ///Create a specific type instance using the given types. ///An array of types specifying which instance to create. static itk@MANAGED_BASE_NAME@^ New ( ... array^ types ) { // Check that types is valid if ( types == nullptr || types->Length == 0 ) throw gcnew itkInvalidWrappedTypeException("The given types array is invalid. A non-empty, valid types array must be specified to create an instance of a wrapped itk::@MANAGED_BASE_NAME@."); // Create the MangledTypeString for the specified explicit instance String^ mangledType = String::Empty; for each ( INativePointer^ type in types ) mangledType += type->MangledTypeString; return itk@MANAGED_BASE_NAME@::New( mangledType ); } ///Create a specific type instance using the given types. ///A string specifying which instance type to create. Eg. "IUC2D", "IF3D", etc. static itk@MANAGED_BASE_NAME@^ New ( String^ mangledType ) { // Create a new managed object itk@MANAGED_BASE_NAME@^ newManagedObject = gcnew itk@MANAGED_BASE_NAME@(); newManagedObject->m_MangledTypeString = mangledType; // Get the name of the instance type to create String^ nameInstanceType = "itk.itk@MANAGED_BASE_NAME@_" + newManagedObject->MangledTypeString; try { // Create the correct instance class Type^ typeInstance = Assembly::GetExecutingAssembly()->GetType(nameInstanceType); if (typeInstance == nullptr) throw gcnew NullReferenceException("The type '" + nameInstanceType + "' could not be found in " + Assembly::GetExecutingAssembly()->GetName() ); Object^ objInstance = typeInstance->InvokeMember("New", BindingFlags::InvokeMethod, Type::DefaultBinder, nullptr, nullptr); if (objInstance == nullptr) throw gcnew NullReferenceException("Could not invoke the New() method for '" + nameInstanceType + "'."); newManagedObject->m_Instance = safe_cast(objInstance); // Pass events from type to wrapper newManagedObject->PassEventsFromTypeToWrapper( ); // Return return newManagedObject; } catch (Exception^ ex) { throw gcnew itkInvalidWrappedTypeException("Could not create an instance of '" + nameInstanceType + "'. The given type may not be supported or may be invalid.", ex); } } /// ///Remove all observers watching this object. /// /// ///By default, observers are created for all events. Calling this ///method removes all native observers, and therefore prevents ///the firing of managed events. Call AddAnyEventObserver() to ///reset the default observers which enable the managed events. /// virtual void RemoveAllObservers ( ) override { this->m_Instance->RemoveAllObservers(); } /// ///Adds a native observer watching for any event. /// /// ///By default, observers are created for all events. Calling this ///method adds a single native observer for any event. This ///observer invokes the managed events. Therefore, calling this ///method more than once, or calling it without first calling ///RemoveAllObservers(), may cause the managed events to be ///invoked more than once. /// virtual void AddAnyEventObserver ( ) override { this->m_Instance->AddAnyEventObserver( ); this->PassEventsFromTypeToWrapper( ); } ///Set the input image to the function object. ///The input image as an itkImage. virtual void SetInputImage( itkImageBase^ inputImage ) override { m_Instance->SetInputImage( inputImage ); } ///Set the input image to the function object. ///The input image as an IntPtr. virtual void SetInputImage( IntPtr itkInputImagePtr ) override { m_Instance->SetInputImage( itkInputImagePtr ); } ///Evaluate the function at specified physical location. ///The geometric location in physical space. ///The pixel value at the given physical location. virtual itkPixel^ Evaluate( itkPoint^ point ) override { return m_Instance->Evaluate( point ); } ///Evaluate the function at specified discrete location. ///The discrete location in image space. ///The pixel value at the given discrete location. virtual itkPixel^ EvaluateAtIndex( itkIndex^ index ) override { return m_Instance->EvaluateAtIndex( index ); } ///Evaluate the function at specified continuous location. ///The continuous location in image space. ///The pixel value at the given continuous location. virtual itkPixel^ EvaluateAtContinuousIndex( itkContinuousIndex^ cindex ) override { return m_Instance->EvaluateAtContinuousIndex( cindex ); } @MANAGED_PROPERTIES_WRAPPER@ @MANAGED_METHODS_WRAPPER@ private: ///Pass managed events from the type instance to this wrapper instance. void PassEventsFromTypeToWrapper() { this->m_Instance->Started += gcnew itkTimedEventHandler(this, &itk@MANAGED_BASE_NAME@::Instance_StartedHandler); this->m_Instance->Ended += gcnew itkTimedEventHandler(this, &itk@MANAGED_BASE_NAME@::Instance_EndedHandler); this->m_Instance->Aborted += gcnew itkTimedEventHandler(this, &itk@MANAGED_BASE_NAME@::Instance_AbortedHandler); this->m_Instance->Iteration += gcnew itkObjectHandler(this, &itk@MANAGED_BASE_NAME@::Instance_IterationHandler); this->m_Instance->Modified += gcnew itkObjectHandler(this, &itk@MANAGED_BASE_NAME@::Instance_ModifiedHandler); } ///Handle the Started event. void Instance_StartedHandler(itkObject^ sender, System::DateTime time) { this->InvokeStartedEvent(time); } ///Handle the Ended event. void Instance_EndedHandler(itkObject^ sender, System::DateTime time) { this->InvokeEndedEvent(time); } ///Handle the Aborted event. void Instance_AbortedHandler(itkObject^ sender, System::DateTime time) { this->InvokeAbortedEvent(time); } ///Handle the Iteration event. void Instance_IterationHandler(itkObject^ sender) { this->InvokeIterationEvent(); } ///Handle the Modified event. void Instance_ModifiedHandler(itkObject^ sender) { this->InvokeModifiedEvent(); } }; // end ref class } // end namespace itk #endif