/*============================================================================= 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: $Date: 2007-09-01 06:17:25 +1000 (Sat, 01 Sep 2007) $ Revision: $Revision: 2 $ 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 // Some managed includes @MANAGED_INCLUDE_WRAPPER@ // 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 interface for itk::@MANAGED_BASE_NAME@. /// /// ///Both the wrapper and type classes derive from this interface. /// public interface class I@MANAGED_BASE_NAME@ { @MANAGED_PROPERTIES_INTERFACE@ @MANAGED_METHODS_INTERFACE@ }; /// ///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@ : itkSpatialObjectBase, I@MANAGED_BASE_NAME@ { private: itkSpatialObjectBase^ m_Instance; protected: ///Protected constructor. itk@MANAGED_BASE_NAME@ ( ) : itkSpatialObjectBase( ) { this->m_IsDisposed = false; } public: ///Dispose of the managed object. ~itk@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed) { this->m_IsDisposed = true; delete m_Instance; } } ///Finalize the managed object. !itk@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed && this->DisposeNativeObjectOnFinalize) delete this; } /// ///Gets/sets if the underlying native object should be disposed when the managed object is finalized. ///The default is true. /// property bool DisposeNativeObjectOnFinalize { virtual bool get() override { return this->m_Instance->DisposeNativeObjectOnFinalize; } virtual void set( bool value ) override { this->m_Instance->DisposeNativeObjectOnFinalize = value; } } /// ///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; } } ///Get the object dimensions. property unsigned int ObjectDimension { virtual unsigned int get() override { return this->m_Instance->ObjectDimension; } } ///Get the SpatialObject type string. property String^ TypeName { virtual String^ get() override { return this->m_Instance->TypeName; } } ///Get the SpatialObject type string. property String^ SpatialObjectTypeAsString { virtual String^ get() override { return this->m_Instance->SpatialObjectTypeAsString; } } ///Get/set the ObjectToWorldTransform (a ScalableAffineTransform). property itkTransform^ ObjectToWorldTransform { virtual itkTransform^ get() override { return this->m_Instance->ObjectToWorldTransform; } virtual void set(itkTransform^ transform) override { this->m_Instance->ObjectToWorldTransform = transform; } } ///Get/set the ObjectToParentTransform (a ScalableAffineTransform). property itkTransform^ ObjectToParentTransform { virtual itkTransform^ get() override { return this->m_Instance->ObjectToParentTransform; } virtual void set(itkTransform^ transform) override { this->m_Instance->ObjectToParentTransform = transform; } } /// ///Get/set the region object that defines the size and starting index ///for the largest possible region this SpatialObject could represent. /// property itkImageRegion^ LargestPossibleRegion { virtual itkImageRegion^ get() override { return this->m_Instance->LargestPossibleRegion; } virtual void set ( itkImageRegion^ region ) override { this->m_Instance->LargestPossibleRegion = region; } } /// ///Get/set the region object that defines the size and starting index ///for the region of the SpatialObject requested (i.e., the region of the ///image to be operated on by a filter). Setting the RequestedRegion ///does not cause the object to be modified. /// property itkImageRegion^ RequestedRegion { virtual itkImageRegion^ get() override { return this->m_Instance->RequestedRegion; } virtual void set ( itkImageRegion^ region ) override { this->m_Instance->RequestedRegion = region; } } /// ///Get/set the region object that defines the size and starting index ///of the region of the SpatialObject currently loaded in memory. /// property itkImageRegion^ BufferedRegion { virtual itkImageRegion^ get() override { return this->m_Instance->BufferedRegion; } virtual void set ( itkImageRegion^ region ) override { this->m_Instance->BufferedRegion = region; } } ///Get/set the spacing. property itkSpacing^ Spacing { virtual itkSpacing^ get() override { return this->m_Instance->Spacing; } virtual void set( itkSpacing^ spacing ) override { this->m_Instance->Spacing = spacing; } } ///Create a specific type instance using the given types. ///The dimension of the spatial object. static itk@MANAGED_BASE_NAME@^ New ( unsigned int dim ) { return itk@MANAGED_BASE_NAME@::New( dim.ToString() ); } ///Create a specific type instance using the given types. ///A string specifying which instance type to create. Eg. "IUC2", "IF3", 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); } } ///Return itk::LightObject::Print( ostream ) as a string. virtual String^ ToString ( ) override { return m_Instance->ToString( ); } /// ///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( ); } ///Separate this object from the pipeline. /// ///This method disconnects the object from the upstream pipeline. ///Hence an Update() from downstream will not propagate back past this object. ///To completely isolate this object from the pipeline, the application must ///remove this object from any filters which it is connected as the input. /// virtual void DisconnectPipeline ( ) override { this->m_Instance->DisconnectPipeline(); } /// ///Compute the World transform when the local transform is set ///This function should be called each time the local transform ///has been modified. /// virtual void ComputeObjectToWorldTransform ( ) override { this->m_Instance->ComputeObjectToWorldTransform(); } /// ///Compute the Local transform when the global transform is set. /// virtual void ComputeObjectToParentTransform ( ) override { this->m_Instance->ComputeObjectToParentTransform(); } /// ///Returns the value at a point. /// virtual bool ValueAt ( itkPoint^ point, double & value ) override { return this->m_Instance->ValueAt( point, value ); } /// ///Returns true if the object can provide a "meaningful" value at ///a point. Often defaults to returning same answer as IsInside, but ///certain objects influence space beyond their spatial extent. /// virtual bool IsEvaluableAt ( itkPoint^ point ) override { return this->m_Instance->IsEvaluableAt( point ); } /// ///Returns true if a point is inside the object. /// virtual bool IsInside ( itkPoint^ point ) override { return this->m_Instance->IsInside( point ); } /// ///Add an object to the list of children. /// virtual void AddSpatialObject ( itkSpatialObjectBase^ object ) override { return this->m_Instance->AddSpatialObject( object ); } /// ///Remove the object passed as arguments from the list of children. /// virtual void RemoveSpatialObject ( itkSpatialObjectBase^ object ) override { return this->m_Instance->RemoveSpatialObject( object ); } /// ///Set the native pointer of the given object to the parent object in the hierarchy tree. /// virtual void GetParent ( itkSpatialObjectBase^ parent ) override { return this->m_Instance->GetParent( parent ); } /// ///Clear the spatial object by deleting all lists of children and subchildren. /// virtual void Clear ( ) override { this->m_Instance->Clear( ); } /// ///Return the number of children directly under this SpatialObject. /// virtual unsigned int GetNumberOfChildren ( ) override { return this->m_Instance->GetNumberOfChildren( ); } /// ///Return the number of children under this SpatialObject to the given depth. /// virtual unsigned int GetNumberOfChildren ( unsigned int depth ) override { return this->m_Instance->GetNumberOfChildren( depth ); } /// ///Returns a list of pointer to the children affiliated to this object. ///A depth of 0 returns the immediate children. A depth of 1 returns the ///children and those children's children. /// /// ///This method steps through the unmanaged list of children and creates a ///managed wrapper for each child using the typeid. Currently the supported ///types are: Group, Ellipse, Tube, Box. ///All unsupported types are wrapped as an itkSpatialObject. /// virtual array^ GetChildren ( unsigned int depth ) override { return this->m_Instance->GetChildren( depth ); } @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