/*=============================================================================
Project: SharpImage
Module: siSpatialObject.cs
Language: C#
Author: Dan Mueller
Date: $Date: 2007-07-06 10:57:00 +1000 (Fri, 06 Jul 2007) $
Revision: $Revision: 2 $
Copyright (c) Queensland University of Technology (QUT) 2007.
All rights reserved.
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.
=============================================================================*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using SharpImage.Rendering;
namespace SharpImage.SpatialObject
{
public abstract class siSpatialObject : itk.itkDataObject
{
#region Constants
//=====================================================================
protected const uint Dimension = 3;
protected const string MET_OBJECT_TYPE = "ObjectType = ";
protected const string MET_NUM_DIMS = "NDims = ";
//=====================================================================
#endregion
#region Instance Variables
//=====================================================================
//=====================================================================
#endregion
#region Construction and Disposal
//=====================================================================
///
/// Default constructor.
///
protected siSpatialObject()
{
}
//=====================================================================
#endregion
#region Properties
//=====================================================================
#region MTime
//=====================================================================
public override uint MTime
{
get { return 0; }
}
//=====================================================================
#endregion
#region SmartPointer
//=====================================================================
unsafe public override void* NativePointer
{
get { return (void*)0; }
set{ /* Nothing to do: siSpatialObjects are fully managed. */ }
}
//=====================================================================
#endregion
#region MangledTypeString
//=====================================================================
public override string MangledTypeString
{
get { return "ManagedSO3"; }
}
//=====================================================================
#endregion
#region Children
//=====================================================================
private List m_Children = new List();
///
/// Gets the collection of child SpatialObjects.
///
virtual public List Children
{
get { return this.m_Children; }
}
//=====================================================================
#endregion
#region Size
//=====================================================================
private itk.itkSize m_Size = new itk.itkSize(128, 128, 128);
///
/// Gets/sets the size of the SpatialObject.
/// The default size = [128, 128, 128].
///
virtual public itk.itkSize Size
{
get { return this.m_Size; }
set
{
// Set for this
this.m_Size = value;
// Set for all children
foreach (siSpatialObject child in this.Children)
child.Size = value;
}
}
//=====================================================================
#endregion
#region Spacing
//=====================================================================
private itk.itkSpacing m_Spacing = new itk.itkSpacing(1.0, 1.0, 1.0);
///
/// Gets/sets the spacing of the SpatialObject.
/// The default spacing = [1.0, 1.0, 1.0].
///
virtual public itk.itkSpacing Spacing
{
get { return this.m_Spacing; }
set
{
// Set for this
this.m_Spacing = value;
// Set for all children
foreach (siSpatialObject child in this.Children)
child.Spacing = value;
}
}
//=====================================================================
#endregion
#region Origin
//=====================================================================
private itk.itkPoint m_Origin = new itk.itkPoint(0, 0, 0);
///
/// Gets/sets the origin of the SpatialObject.
/// The default Origin = [0, 0, 0].
///
virtual public itk.itkPoint Origin
{
get { return this.m_Origin; }
set
{
// Set for this
this.m_Origin = value;
// Set for all children
foreach (siSpatialObject child in this.Children)
child.Origin = value;
}
}
//=====================================================================
#endregion
//=====================================================================
#endregion
#region Public Methods
//=====================================================================
///
/// Read the spatial object from a meta file (*.mhd).
///
///
public override void Read(string filename)
{
throw new NotSupportedException("The Read() method is not supported by this siSpatialObject.");
}
///
/// Write the spatial object to a meta file (*.mhd).
///
///
public override void Write(string filename)
{
throw new NotSupportedException("The Write() method is not supported by this siSpatialObject.");
}
///
/// Not valid for siSpatialObjects because they are fully managed.
///
public override void DisconnectPipeline()
{
// Nothing to do: siSpatialObjects are fully managed.
}
///
/// Renders the spatial object using OpenGL.
///
/// The renderer this spatial object is being renderered to.
public virtual void Render(siRenderer renderer)
{
// Suclasses must override this method.
// If they do not, then nothing is rendererd to the screen.
}
///
/// Initialises the spatial object for rendering.
///
public virtual void Initialise(siRenderer renderer)
{
// Subclasses must override this method.
}
public override void RemoveAllObservers()
{
throw new NotSupportedException("The RemoveAllObservers or operation is not supported.");
}
public override void AddAnyEventObserver()
{
throw new NotSupportedException("The AddAnyEventObserver or operation is not supported.");
}
//=====================================================================
#endregion
#region Private Methods
//=====================================================================
//=====================================================================
#endregion
}
}