Class CAAMShape
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDVector
gov.nih.mipav.view.renderer.WildMagic.AAM.CDVector
gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMShape
This is the Java modified version of C++ active appearance model API
(AAM_API). It is modified with a subset of required functions for automatic
MRI prostate segmentation.
AAM-API LICENSE - file: license.txt
This software is freely available for non-commercial use such as
research and education. Please see the full disclaimer below.
All publications describing work using this software should cite
the reference given below.
Copyright (c) 2000-2003 Mikkel B. Stegmann, mbs@imm.dtu.dk
IMM, Informatics invalid input: '&' Mathematical Modelling
DTU, Technical University of Denmark
Richard Petersens Plads, Building 321
DK-2800 Lyngby, Denmark
http://www.imm.dtu.dk/~aam/
REFERENCES
Please use the reference below, when writing articles, reports etc. where
the AAM-API has been used. A draft version the article is available from
the homepage.
I will be happy to receive pre- or reprints of such articles.
/Mikkel
-------------
M. B. Stegmann, B. K. Ersboll, R. Larsen, "FAME -- A Flexible Appearance
Modelling Environment", IEEE Transactions on Medical Imaging, IEEE, 2003
(to appear)
-------------
3RD PART SOFTWARE
The software is partly based on the following libraries:
- The Microsoft(tm) Vision Software Developers Kit, VisSDK
- LAPACK
DISCLAIMER
This software is provided 'as-is', without any express or implied warranty.
In no event will the author be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any non-commercial
purpose, and to alter it, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
--
No guarantees of performance accompany this software, nor is any
responsibility assumed on the part of the author or IMM.
This software is provided by Mikkel B. Stegmann and IMM ``as is'' and any
express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall IMM or Mikkel B. Stegmann be liable for any
direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and
on any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of
this software, even if advised of the possibility of such damage.
$Revision: 1.4 $
$Date: 2003/04/23 14:49:15 $
Shape container. This class act as a container for a shape. Essentially it's
just a set of 2D points stored in a vector in the format xxxyyy.
- Author:
- Ruida Cheng
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIndicates if the point coordinates is in relative or absolute format.private intThe number of points.private double[]un-safe pointer to the first point data element.private StringCurrent ASF version number.private StringOptional 'host image' filename including full path.private Vector<CAAMPointInfo> Auxillary point data.User-defined field 1.User-defined field 2.User-defined field 3.private ModelImagehost image.Fields inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDVector
m_data, m_fExternalStorage, m_length -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAbs2Rel(int image_width, int image_height) Converts shape coordinates from absolute to relative.voidConverts shape coordinates from absolute to relative by using the hostimage.add(CVisDVector v) Plus operator.voidAddInterior(int interations) Add articifial interior points to the shape by making a Delaunay triangulation and adding the centroid of each triangle.voidAddPath(CAAMShape shape, CAAMPointInfo pointType) Adds a path to the shape.voidAddShapeExtends(int nPixels) Adds an extra outer path on each outer path in the distance of 'nPixels' along the point normal.doubleWrapper to align this to ref.doubleAligns this to 'ref' with respect to pose.voidAlignTransformation(CAAMShape ref, double[] scale, double[] theta, CAAMPoint t) Returns the transformation that aligns this to 'ref' with respect to pose.voidAllocates room for the three user defined fields.doubleArea()doubleArea(boolean use_covex_hull) Returns the total area of the shape (with holes excluded).assign(double value) Assignment operator (double).Assignment operator (CAAMShape).assign(CVisDVector vIn) Assignment operator (CAAMShape).Calculates the convex hull of each path in the shape.COG()Calculates the center of gravity of the shape (actually it's the center of the centroid).voidCOG(double[] x, double[] y) Calculates the center of gravity of the shape (actually it's the center of the centroid).booleanTests if any interior points has gone outside outer path of the shape.booleanConvert ASF shape from VOIprivate voidCopies all data from a shape to this.intDEC_TO_ZERO(int a) Convert deciam number to 0voidDisplaces the shape around it's center of gravity using a displacement vector.voiddispose()dispose memoryvoidExpand(int nPixels) Expands the shape by moving each model point 'nPixels' perperdicular to the shape contour (that is: along the model point normal).ExtractPath(int startPosition) Extracts one path from a shape into a new shape.voidReads a shape from a file.booleangenerateVOImesh(ModelImage targetImageSlice) From the current shape, generate the corresponding triagnle meshes view.booleangenerateVOIs(ModelImage targetImageSlice) ASF writer version 0.90.Get host image.GetHostImage(ModelImage src, int rfactor) Retrives the image connected to the shape.GetHostImage(ModelSimpleImage dest, String path, int rfactor) Retrives the image connected to the shape.GetPaths()Extracts the starting positions of each path in the shape by a simple linear search.GetPoint(int i) Returns the i'th point.intGetPoint(int i, double[] x, double[] y) Returns the i'th point.voidGetPointUS(int i, double[] x, double[] y) un-safe (and dirty) since it depends on assumptions regarding thedoubleGetRotation(CAAMShape ref) Returns the rotation between ref and this (in radians).doubleHeight()Shape heightfinal StringHost image (if any).doubleinitAlignTo(CAAMShape ref) Init ref to this.doubleinitAlignTo(CAAMShape ref, double[] pTheta) Aligns this to 'ref' with respect to pose.booleanIsAbs()Returns true if the shape is in absolute coordinates.booleanIsConvex()Tests if the shap is convex w.r.t. each path.booleanWrapper to check is point p is inside the shapebooleanTests if the point 'p' belongs to the shape.booleanIsInsidePath(CAAMPoint p, int path_start) Tests if the point 'p' is inside the path starting at position 'path_start'.voidMakeBorderShape(int size) Converts a one path shape into a border shape by adding two symmetric borders: an inside (a hole) and an outside border.doubleMaxX()Find the maximum x component of the shape.doubleMaxY()Find the maximum y component of the shape.doubleMinX()Find the maximum x component of the shape.doubleMinY()Find the minimum y component of the shape.voidFinds the normal to the i'th point on the shape.voidNormalDisplacement(int i, double dist) Displaces the i-th point along the normal.doubleNormalizes the shape by translating it's center of gravity to origo and scale by the reciprocal of the 2-norm.final intNPoints()The number of shape points.static voidParam2PoseVec(double scale, double theta, double tx, double ty, CDVector poseVec) Converts pose parameters: scale, theta, tx, ty to a pose vector.intPathLen(int startPosition) Returns the length of a path.PointAux()Returns the complete point aux vector of the shape.static voidPoseVec2Param(CDVector poseVec, double[] scale, double[] theta, double[] tx, double[] ty) Converts a pose vector to pose parameters: scale, theta, tx, ty.booleanReads an ver. 0.90 .asf into relative coordinates.booleanReadASF0_90(String filename) Reads an ver. 0.90 .asf into relative coordinates.booleanReadASFfromVOI(ModelImage image) Generate ASF shape from given VOIbooleanReadASFfromVOI_init(ModelImage image) voidRel2Abs(int image_width, int image_height) Converts shape coordinates from relative to absolute.voidvoidRemovePoint(int i) Removes the i-th point from the shape.voidResize(int length, double[] storage) Change number of shape points in the shape.voidReverses the point point ordering.voidRotate(double theta) rotate shape with given theta anglevoidRotate(double theta, boolean aroundCOG) Rotates the shape.voidScale(double s) Scale the shapevoidScale(double s, boolean aroundCOG) Scales the shape.voidSets all point to be connected in one closed path.voidSetHostImage(String hostImageFilename) Returns the host image (if any).intSetPoint(int i, double x, double y) Overwrites the i'th point.intOverwrites the i'th point.voidsetPointAux(int index, CAAMPointInfo value) Set specific point infovoidsetPointAux(Vector<CAAMPointInfo> value) set point info vectorvoidSetPointInfoFlagsInPath(int startPosition, int flags) Sets all flags in one path to the same value.doubleReturns the 2-norm of this shape centralized.sub(CVisDVector v) Minus operator.voidWrite the shape to a binary file.voidTranslate(double x, double y) Translates the shape.voidTranslates the shape.UserField(int field_nb) Returns the reference of the user defined field vector number 'field_nb'.doubleWidth()Shape width.booleanWrites the shape to a ASF file.booleanWriteASF0_90(String filename, int image_width, int image_height) ASF writer version 0.90.Methods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CDVector
__dbl_cmp_asc, __dbl_cmp_des, Abs, AlignTo, AlignTo, assign, assign, AutoCorrelation, Ceil, Clamp, CrossProduct, ElementDivide, ElementMultiply, Eq, Eq, Floor, FromFile, Ge, Ge, Gt, Gt, Le, Le, Linspace, Log, Lt, Lt, Max, Mean, Median, Min, Min, Ne, Ne, Norm1, Norm2, Normalize2, NormInf, Pow, quick_select, Rand, Rand, Range, Reverse, Round, Shuffle, Skewness, Sort, Sort, Sqr, Sqrt, Std, Sum, ToFile, ToMatlab, ToMatrix, ToString, Trim, TrimmedMean, TrimmedStd, TrimmedVar, Var, Var, VecCatMethods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDVector
add_into, div, div_into, EqDiff, EqProd, EqSum, equals, FreeBuffer, get, Length, less_than, mult, mult, mult_into, neg, not_equals, Resize, Resize, set, SetSize, SetSize, sub_into, VisCrossProduct, VisCrossProduct
-
Field Details
-
m_vPointAux
Auxillary point data. -
m_vUser1
User-defined field 1. -
m_vUser2
User-defined field 2. -
m_vUser3
User-defined field 3. -
m_szASFVer
Current ASF version number. -
m_iNbPoints
private int m_iNbPointsThe number of points. -
m_bAbsPointCoordinates
private boolean m_bAbsPointCoordinatesIndicates if the point coordinates is in relative or absolute format. -
m_szHostImage
Optional 'host image' filename including full path. -
myHostImage
host image. -
m_pData
private double[] m_pDataun-safe pointer to the first point data element.
-
-
Constructor Details
-
CAAMShape
public CAAMShape()Default constructor. Defaults to absolute shape coordinates and sets the number of points to zero. Notice that the user defined fields is *not* allocated by default. In order to preserved memory the user must to this explicitly by using AllocateUserFields(); -
CAAMShape
public CAAMShape(int nbPoints) Constructs a shape with 'nbPoints' points. Defaults to absolute point coordinates and single closed path connectivity.- Parameters:
nbPoints- The number of points the shape should contain.- See Also:
-
CAAMShape
Constructs a shape from a vector. Defaults to absolute point coordinates and single closed path connectivity.- Parameters:
v- The input vector.- See Also:
-
CAAMShape
Copy contructor.- Parameters:
s- The input shape.
-
-
Method Details
-
ToFile
Write the shape to a binary file. -
FromFile
Reads a shape from a file. -
SetClosedPathConnectivity
public void SetClosedPathConnectivity()Sets all point to be connected in one closed path. Manipulates the aux point info such that the shape points is interpreted as one closed outer path defined clock-wise with repect to it's normals. -
assign
Assignment operator (double). Sets all x and y compoments of a shape equal to a double. [Actually only used when calculating a mean shape -- since we want to accumulate in an empty shape]. -
assign
Assignment operator (CAAMShape). Set one shape equal another.- Parameters:
s- The shape to copy.
-
CopyData
Copies all data from a shape to this. Called from the assignment operator.- Parameters:
s- Shape to copy data from.
-
assign
Assignment operator (CAAMShape). Set the shape to be equal an xxx-yyy formatted vector. NOTE: this method does not manipulate any connectivity (i.e. point aux) info. So, if the shape beforehand was empty one should call SetClosedPathConnectivity() afterwards this call to obtain sensible point aux info. -
dispose
public void dispose()dispose memory- Overrides:
disposein classCVisDVector
-
Rotate
public void Rotate(double theta) rotate shape with given theta angle- Parameters:
theta-
-
Rotate
public void Rotate(double theta, boolean aroundCOG) Rotates the shape. Rotates the shape 'theta' radians.- Parameters:
theta- Rotation angle in radians.aroundCOG- If true the rotation is being done around the cog of the shape instead of around the global center.
-
Translate
Translates the shape.- Parameters:
p- The offset to translate.
-
Translate
public void Translate(double x, double y) Translates the shape.- Parameters:
x- X-translation.y- Y-translation.
-
ShapeSize
public double ShapeSize()Returns the 2-norm of this shape centralized.- Returns:
- The 2-norm.
-
MinX
public double MinX()Find the maximum x component of the shape.- Returns:
- The x-maximum.
-
MaxX
public double MaxX()Find the maximum x component of the shape.- Returns:
- The x-maximum.
-
MinY
public double MinY()Find the minimum y component of the shape.- Returns:
- The y-minimum.
-
MaxY
public double MaxY()Find the maximum y component of the shape.- Returns:
- The y-maximum.
-
Scale
public void Scale(double s) Scale the shape- Parameters:
s-
-
Scale
public void Scale(double s, boolean aroundCOG) Scales the shape.- Parameters:
s- Scale factor.aroundCOG- If true the scale is being done around the cog of the shape instead of around the global center.
-
COG
Calculates the center of gravity of the shape (actually it's the center of the centroid).- Parameters:
p- cog output.
-
COG
public void COG(double[] x, double[] y) Calculates the center of gravity of the shape (actually it's the center of the centroid).- Parameters:
x- X cog output.y- X cog output.
-
Normalize
public double Normalize()Normalizes the shape by translating it's center of gravity to origo and scale by the reciprocal of the 2-norm.- Returns:
- The 2-norm of the shape seen as a 2*nbPoint vector after the translation to orig.
-
SetPoint
public int SetPoint(int i, double x, double y) Overwrites the i'th point.- Returns:
- Zero.
-
SetPoint
Overwrites the i'th point. If the point doesn't exists, non-zero is returned.- Returns:
- Zero on success, non-zero if the point doesn't exists.
-
GetPoint
public int GetPoint(int i, double[] x, double[] y) Returns the i'th point.- Returns:
- Zero.
-
GetPoint
Returns the i'th point.- Returns:
- The i'th point.
-
Resize
public void Resize(int length, double[] storage) Change number of shape points in the shape. Note: Destroys *all* current point data and point info data.- Overrides:
Resizein classCVisDVector- Parameters:
length-storage-
-
AlignTransformation
Returns the transformation that aligns this to 'ref' with respect to pose.- Parameters:
ref- The reference shape.
-
initAlignTo
Init ref to this.- Parameters:
ref-- Returns:
- 2-norm of the shape
-
initAlignTo
Aligns this to 'ref' with respect to pose.- Parameters:
ref- The reference shape.pTheta- Optional pointer to return the rotation carried out on this.- Returns:
- The 2-norm of the this shape seen as a 2*nbPoint vector after the translation to orig but before the scale done to fit 'ref'.
-
AlignTo
Wrapper to align this to ref.- Parameters:
ref-- Returns:
-
AlignTo
Aligns this to 'ref' with respect to pose.- Parameters:
ref- The reference shape.pTheta- Optional pointer to return the rotation carried out on this.- Returns:
- The 2-norm of the this shape seen as a 2*nbPoint vector after the translation to origo but before the scale done to fit 'ref'.
-
GetRotation
Returns the rotation between ref and this (in radians). Get the rotation between two shapes by minimizing the sum of squared point distances, as described by Goodall (and Bookstein) using Singular Value Decomposition (SVD). Note that both shapes must be normalized with respect to scale and position beforehand. This could be done by using CAAMSAhape::Normalize().- Returns:
- The estimated angle, theta, between the two shapes.
-
Param2PoseVec
public static void Param2PoseVec(double scale, double theta, double tx, double ty, CDVector poseVec) Converts pose parameters: scale, theta, tx, ty to a pose vector. The pose vector will be in the format: [ s, theta, tx, ty ] where s = scale-1- Parameters:
scale- Scale input.theta- Rotational input.tx- X translation input.ty- Y translation input.poseVec- The output pose vector.
-
PoseVec2Param
public static void PoseVec2Param(CDVector poseVec, double[] scale, double[] theta, double[] tx, double[] ty) Converts a pose vector to pose parameters: scale, theta, tx, ty. The pose vector are expected to be in the format: [ s, theta, tx, ty ] where s = scale-1- Parameters:
poseVec- The input pose vector.scale- Scale output.theta- Rotational output.tx- X translation output.ty- Y translation output.
-
Displace
Displaces the shape around it's center of gravity using a displacement vector.- Parameters:
poseVec- The input pose vector.
-
IsInsidePath
Tests if the point 'p' is inside the path starting at position 'path_start'. Rarely used. Primary a helper function to IsInside.- Parameters:
p- The point to test for.path_start- The point index where a path starts- Returns:
- True if 'p' is inside
-
IsInside
Wrapper to check is point p is inside the shape- Parameters:
p- point- Returns:
- inside or not
-
IsInside
Tests if the point 'p' belongs to the shape. In the current version all shape points are assumes to be ordered points in a n-point polygon with no holes. For example used to clean up the meshes (removing unwanted triangles from the triangulisation).- Parameters:
bBoundTest- Flags wheather a bounding box test should be performed prior to the exact test.- Returns:
- True if 'p' is inside.
-
Expand
public void Expand(int nPixels) Expands the shape by moving each model point 'nPixels' perperdicular to the shape contour (that is: along the model point normal). This function will expand each outer (closed) path of the shape. No tests for crossing contours are being made as of now.- Parameters:
nPixels- The number of pixel to expand the shape with.
-
Normal
Finds the normal to the i'th point on the shape. If the point should be a single point the normal points is defined to be equal to the point it self.- Parameters:
i- Index of point.p1- Reference to the outside normal point.p2- Reference to the inside normal point.dist- The desired distance from p[1|2] to the i-th point.
-
NormalDisplacement
public void NormalDisplacement(int i, double dist) Displaces the i-th point along the normal.- Parameters:
i- Index of point.dist- The distance to move the point (>0 move point outwards, invalid input: '<'0 inwards).
-
WriteASF
Writes the shape to a ASF file. Remember asf's are always in relative coordinates. Se format description else where.- Parameters:
filename- Output filename.image_width- The image the coord. is relative to.image_height- The image the coord. is relative to.- Returns:
- true on success, false on errors
-
WriteASF0_90
ASF writer version 0.90. Writes the shape to a ver. 0.90 ASF file. Remember asf's are always in relative coordinates. Se format description else where.- Parameters:
filename- Output filename.image_width- The image the coord. is relative to.image_height- The image the coord. is relative to.- Returns:
- true on success, false on errors
-
generateVOIs
ASF writer version 0.90. Writes the shape to a ver. 0.90 ASF file. Remember asf's are always in relative coordinates. Se format description else where.- Parameters:
filename- Output filename.image_width- The image the coord. is relative to.image_height- The image the coord. is relative to.- Returns:
- true on success, false on errors
-
generateVOImesh
From the current shape, generate the corresponding triagnle meshes view. VOIs is used to display the mesh.- Parameters:
targetImageSlice-- Returns:
- true by default
-
ReadASF
Reads an ver. 0.90 .asf into relative coordinates. Se format description else where.- Parameters:
filename- Input filename.- Returns:
- true on success, false on errors
-
ReadASF0_90
Reads an ver. 0.90 .asf into relative coordinates. Se format description else where.- Parameters:
filename- Input filename.- Returns:
- true on success, false on errors
-
ReadASFfromVOI
Generate ASF shape from given VOI- Parameters:
image- image with VOI.- Returns:
- success or not
-
ConvertASFfromVOI
Convert ASF shape from VOI- Parameters:
v- VOI- Returns:
- success or not.
-
ReadASFfromVOI_init
-
Abs2Rel
Converts shape coordinates from absolute to relative by using the hostimage. -
IsAbs
public boolean IsAbs()Returns true if the shape is in absolute coordinates.- Returns:
- is abs coordinate or not
-
Rel2Abs
-
Abs2Rel
public void Abs2Rel(int image_width, int image_height) Converts shape coordinates from absolute to relative. Relative coordinates are specified as: x_relative = x_abs/image_width y_relative = y_abs/image_height- Parameters:
image_width- The image the coord. should be relative to.image_height- The image the coord. should be relative to.- See Also:
-
Rel2Abs
public void Rel2Abs(int image_width, int image_height) Converts shape coordinates from relative to absolute. Relative coordinates are specified as: x_relative = x_abs/image_width y_relative = y_abs/image_height- Parameters:
image_width- The image the coord. is relative to.image_height- The image the coord. is relative to.- See Also:
-
AddPath
Adds a path to the shape. All added point inherits the given pointtype.- Parameters:
shape- A shape containing one path.pointType- The pointtype of the added points.
-
ReversePointOrder
public void ReversePointOrder()Reverses the point point ordering. Used when a clock-wise outer path shall converted to a counter-clock wise hole. -
GetPaths
Extracts the starting positions of each path in the shape by a simple linear search. The starting position is identified by a change in path id (saved in the m_vPointAux member).- Returns:
- A vector of path starting positions.
-
PathLen
public int PathLen(int startPosition) Returns the length of a path.- Parameters:
startPosition- The starting position of the path.- Returns:
- The path length.
- See Also:
-
ExtractPath
Extracts one path from a shape into a new shape.- Parameters:
startPosition- The starting position of the path.- Returns:
- The path as a new shape.
-
AddShapeExtends
public void AddShapeExtends(int nPixels) Adds an extra outer path on each outer path in the distance of 'nPixels' along the point normal. This method is primary used in conjunction with the "do not use the convex hull" feature. In such a case one often still wants a certain neighborhood of the shape to be included in the model.- Parameters:
nPixels- The size of the extents.
-
SetPointInfoFlagsInPath
public void SetPointInfoFlagsInPath(int startPosition, int flags) Sets all flags in one path to the same value.- Parameters:
startPosition- Starting position of the path.flags- The flags.
-
AddInterior
public void AddInterior(int interations) Add articifial interior points to the shape by making a Delaunay triangulation and adding the centroid of each triangle. This is done iteratively. Default is one iteration- Parameters:
interations- Controls the number of artificial points. One iteration equals one triangulation.
-
ConsistencyCheck
public boolean ConsistencyCheck()Tests if any interior points has gone outside outer path of the shape.- Returns:
- True if the shape looks ok, false if not.
-
MakeBorderShape
public void MakeBorderShape(int size) Converts a one path shape into a border shape by adding two symmetric borders: an inside (a hole) and an outside border. No checks for folding paths are done as of now.- Parameters:
size- The size of the border in pixels.
-
add
Plus operator.- Overrides:
addin classCVisDVector- Parameters:
v- Vector to add.- Returns:
- The addition of this and 'v'.
-
sub
Minus operator.- Overrides:
subin classCVisDVector- Parameters:
v- Vector to add.- Returns:
- The subtraction of this and 'v'.
-
GetHostImage
Retrives the image connected to the shape. As of now it's loaded from disk using the HostImage() member in the shape.- Parameters:
dest- The destination image.path- The path to the .asf file.rfactor- Optional reduction factor. Performs a scaling of the the shape by 1/rfactor. Default 1 i.e. no scaling.- Returns:
- refactored image.
-
GetHostImage
Retrives the image connected to the shape. As of now it's loaded from disk using the HostImage() member in the shape.- Parameters:
src- source imagerfactor- reduction factor- Returns:
- refactored iamge.
-
Area
public double Area() -
Area
public double Area(boolean use_covex_hull) Returns the total area of the shape (with holes excluded).- Parameters:
use_covex_hull- Use the convex hull of the shape for area calculation (default false).- Returns:
- The area.
-
CalcConvexHull
Calculates the convex hull of each path in the shape. The calulation is built upon the geometrical fact that the homogenous point matrix: [ p1x p2x p3x ; p1y p2y p3y ; 1 1 1 ] is positive if p1, p2, p3 is a convex segment and negative if concave. Note: this holds for a clock-wise ordering of p1,p2,p3. Any open paths are considered cyclic in the concavity calulation. Remember that paths should be defined clock-wise in the asf format. BUG COMMENT: This does not seem to work with multiple paths.- Returns:
- A convex version of this shape w.r.t. each path.
-
IsConvex
public boolean IsConvex()Tests if the shap is convex w.r.t. each path. This call is rather expensive, since it spaws a call to CalcConvexHull().- Returns:
- True on convex, false on concave.
-
RemovePoint
public void RemovePoint(int i) Removes the i-th point from the shape. Since this require massive reordering of the preceeding point connectivity this is actually a very expensive call [a fairly ugly in it's implementation] :-(- Parameters:
i- The index of the point to remove.
-
DEC_TO_ZERO
public int DEC_TO_ZERO(int a) Convert deciam number to 0- Parameters:
a- int number- Returns:
-
UserField
Returns the reference of the user defined field vector number 'field_nb'.- Parameters:
field_nb- Field number [1-3].- Returns:
- A reference to the specified field vector.
-
AllocateUserFields
public void AllocateUserFields()Allocates room for the three user defined fields. Notice that the user defined fields is *not* allocated by default. In order to preserved memory the user must to this explicitly by using AllocateUserFields(); -
HostImage
Host image (if any).- Returns:
- host image
-
SetHostImage
Returns the host image (if any).- Parameters:
hostImageFilename-
-
Width
public double Width()Shape width.- Returns:
- shape width
-
Height
public double Height()Shape height- Returns:
- shape height
-
NPoints
public final int NPoints()The number of shape points.- Returns:
- number of points on shape
-
GetPointUS
public void GetPointUS(int i, double[] x, double[] y) un-safe (and dirty) since it depends on assumptions regarding the- Parameters:
i- indexx- x coordinate pointery- y conrdinate pointer
-
PointAux
Returns the complete point aux vector of the shape.- Returns:
- point info vector
-
setPointAux
set point info vector- Parameters:
value-
-
setPointAux
Set specific point info- Parameters:
index-value-
-
getHostImage
Get host image.- Returns:
- image
-