de.unihalle.informatik.MiToBo.core.datatypes
Class MTBRegion3D

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBRegion3D

public class MTBRegion3D
extends de.unihalle.informatik.Alida.operator.ALDData

Class to create a 3D region object. The center of mass and the volume of the 3D region can be calculated as well as other 3D region properties.

Author:
glass

Field Summary
private  MTBPoint3D centroid
          The centroid of the region (not normalised by volume!)
private  int id
          ID of the region (uniqueness is not guaranteed nor checked!)
private  java.util.Vector<MTBPoint3D> points
          Points belonging to the region
private  int volume
          The volume of the region (number of points included).
 
Constructor Summary
MTBRegion3D()
          Construct a new MTBRegion3D object.
MTBRegion3D(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion3DType xmlregion3D)
          Construct a new MTBRegion3D from a 3D-region in xml-representation.
MTBRegion3D(java.util.Vector<MTBPoint3D> p)
          Construct a new MTBRegion3D object from the given points.
 
Method Summary
 void addPoint(double px, double py, double pz)
          Append a point to the region from the given coordinates.
 void addPoint(MTBPoint3D p)
          Append a 3D point to the region.
 MTBPoint3D calcCentre(java.util.Vector<MTBPoint3D> p)
          Calculate the centroid (not yet normalized by volume) of a given vector of points.
 double[] getBoundingBox()
          Calculates the axes-parallel bounding box of the region.
 MTBPoint3D getCentre()
          Return the center of the region as 3D point.
 double getCentreX()
          Return the x-coordinate of the center of the region.
 double getCentreY()
          Return the y-coordinate of the center of the region.
 double getCentreZ()
          Return the z-coordinate of the center of the region.
 int getID()
          Return the ID of the region.
 java.util.Vector<MTBPoint3D> getPoints()
          Return the points which are included in the 3D region.
 int getSizeX()
          Calculate the expansion in x-direction of the region.
 int getSizeY()
          Calculate the expansion in y-direction of the region.
 int getSizeZ()
          Calculate the expansion in z-direction of the region.
 double getVolume()
          Return the volume of the 3D region (number of points within the region).
 void regionToFile(java.lang.String fileName)
          Write the coordinates of the included 3D points into a text file.
 void setID(int id)
          Set the ID of the region.
 de.unihalle.informatik.MiToBo_xml.MTBXMLRegion3DType toXMLType()
           
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

centroid

private MTBPoint3D centroid
The centroid of the region (not normalised by volume!)


id

private int id
ID of the region (uniqueness is not guaranteed nor checked!)


points

private java.util.Vector<MTBPoint3D> points
Points belonging to the region


volume

private int volume
The volume of the region (number of points included).

Constructor Detail

MTBRegion3D

public MTBRegion3D()
Construct a new MTBRegion3D object.


MTBRegion3D

public MTBRegion3D(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion3DType xmlregion3D)
Construct a new MTBRegion3D from a 3D-region in xml-representation.

Parameters:
xmlregion3D - 3D-region in xml-representation

MTBRegion3D

public MTBRegion3D(java.util.Vector<MTBPoint3D> p)
Construct a new MTBRegion3D object from the given points.

Parameters:
p - vector of region points
Method Detail

addPoint

public void addPoint(double px,
                     double py,
                     double pz)
Append a point to the region from the given coordinates. The point is added at the end of the point list.

Parameters:
px - coordinate in x-dimension
py - coordinate in y-dimension
pz - coordinate in z-dimension

addPoint

public void addPoint(MTBPoint3D p)
Append a 3D point to the region. The point is added at the end of the point list.

Parameters:
p - point to add

calcCentre

public MTBPoint3D calcCentre(java.util.Vector<MTBPoint3D> p)
Calculate the centroid (not yet normalized by volume) of a given vector of points.

Parameters:
p - vector of Point3D
Returns:
The centroid (not yet normalised by volume).

getBoundingBox

public double[] getBoundingBox()
Calculates the axes-parallel bounding box of the region.

The function extracts the coordinates of the back upper left and front lower right corner of the bounding box of the region. Note that the there is at least one point of the region lying on each side of the bounding box, i.e. the region not just touches the box, but lies on it.

The result array contains the corner coordinates in the following order: [xmin, ymin, zmin, xmax, ymax, zmax]

Returns:
Coordinates of back upper left and front lower right corners.

getCentre

public MTBPoint3D getCentre()
Return the center of the region as 3D point.

Returns:
Center of region.

getCentreX

public double getCentreX()
Return the x-coordinate of the center of the region.

Returns:
Coordinate of the center in x-dimension.

getCentreY

public double getCentreY()
Return the y-coordinate of the center of the region.

Returns:
Coordinate of the center in y-dimension.

getCentreZ

public double getCentreZ()
Return the z-coordinate of the center of the region.

Returns:
Coordinate of the center in z-dimension.

getID

public int getID()
Return the ID of the region. Uniqueness is publicnot guaranteed nor checked!

Returns:
Region ID

getPoints

public java.util.Vector<MTBPoint3D> getPoints()
Return the points which are included in the 3D region.

Returns:
Region points.

getSizeX

public int getSizeX()
Calculate the expansion in x-direction of the region.

Returns:
Expansion of the region in x-direction.

getSizeY

public int getSizeY()
Calculate the expansion in y-direction of the region.

Returns:
Expansion of the region in y-direction.

getSizeZ

public int getSizeZ()
Calculate the expansion in z-direction of the region.

Returns:
Expansion of the region in z-direction.

getVolume

public double getVolume()
Return the volume of the 3D region (number of points within the region).

Returns:
Region volume.

regionToFile

public void regionToFile(java.lang.String fileName)
Write the coordinates of the included 3D points into a text file.

Parameters:
fileName - File name to store the region on disk.

setID

public void setID(int id)
Set the ID of the region. Uniqueness is not guaranteed nor checked!

Parameters:
id - region ID

toXMLType

public de.unihalle.informatik.MiToBo_xml.MTBXMLRegion3DType toXMLType()