/*============================================================================= NOTE: THIS FILE IS A HANDMADE WRAPPER FOR THE ManagedITK PROJECT. Project: ManagedITK Program: Insight Segmentation & Registration Toolkit Module: itkManagedContinuousIndex.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 __itkManagedContinuousIndex_cxx #define __itkManagedContinuousIndex_cxx // Use some managed namespaces #using #using using namespace System; using namespace System::IO; using namespace System::Reflection; using namespace System::ComponentModel; using namespace System::Diagnostics; // Include Array #include "itkManagedArray.cxx" #include "itkManagedIndex.cxx" namespace itk { #define itkContinuousIndexValueType System::Double /// ///This class is a managed replacement for itk::ContinuousIndex. /// /// ///A ContinuousIndex represents an n-Dimensional real-valued point in pixel space. /// public ref class itkContinuousIndex : itkArray { public: ///Constructor taking the data values as a params array. ///The variable length data array. The dimension will be initialised as data.Length. itkContinuousIndex ( ... array^ data ) : itkArray( data ) { } ///Constructor taking the number of dimensions for the array. ///The data values are initialised as zero. ///The dimensionality of the array to initialise. itkContinuousIndex( unsigned int dimension ) : itkArray( dimension ) { } ///Constructor taking another array. ///Another array to clone the data from. itkContinuousIndex ( itkContinuousIndex^ other) : itkArray( other->Data ) { } ///Constructor which copies member data from an existing itkIndex object. ///The existing itkIndex object to copy from. itkContinuousIndex( itkIndex^ index ) : itkArray( index->Dimension ) { for (unsigned int i=0; iDimension; i++) this->Data[i] = (itkContinuousIndexValueType)index[i]; } ///Converts this to a discrete itkIndex by rounding 'away from zero'. ///Uses MidpointRounding::AwayFromZero to perform rounding. virtual itkIndex^ ToIndex() { itkIndex^ index = gcnew itkIndex(this->Dimension); for (unsigned int i=0; iDimension; i++) index[i] += (int)Math::Round(this[i], MidpointRounding::AwayFromZero); return index; } /// ///Compares the given Object to this. ///They are equal if they have the same dimensionality AND data. /// ///The object to test. ///true AND the objects are equal OR false AND the objects are not equal. virtual bool Equals(Object^ obj) override { // Check if input object is null if ( obj == nullptr ) return false; // Cast itkContinuousIndex^ right = safe_cast< itkContinuousIndex^ >(obj); if ( right != nullptr ) { // Check number of dimensions are the same if (this->Dimension != right->Dimension) return false; // Check data at each location is the the same bool result = true; for (unsigned int i = 0; i < this->Dimension; i++) result &= (this[i] == right[i]); return result; } return false; } /// ///Compares two itkContinuousIndex objects. ///They are equal if they have the same dimensionality AND data. /// /// /// ///true AND the objects are equal OR false AND the objects are not equal. static bool operator ==(itkContinuousIndex^ lhs, itkContinuousIndex^ rhs) { if ( Object::ReferenceEquals(lhs, rhs) ) return true; else if ( Object::ReferenceEquals(lhs, nullptr) ) return false; else if ( Object::ReferenceEquals(rhs, nullptr) ) return false; else return lhs->Equals(rhs); } /// ///Compares two itkContinuousIndex objects. ///They are not equal if they do not have the same dimensionality OR ///do not have the same data. /// /// ///true AND the objects are not equal OR false AND the objects are equal. virtual bool operator !=(itkContinuousIndex^ rhs) { return !(this == rhs); } }; // end ref class } // end namespace itk #endif