public class MeshCurve extends RenderableCompositeBase
Modifier and Type | Class and Description |
---|---|
static class |
MeshCurve.Interpolation |
ModelComponent.FilePathSaveType, ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_CLOSED |
static MeshCurve.Interpolation |
DEFAULT_INTERPOLATION |
static double |
DEFAULT_NORMAL_LENGTH |
static boolean |
DEFAULT_PROJECT_TO_MESH |
static int |
DEFAULT_RESOLUTION |
static double |
INF |
static PropertyList |
myProps |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
MeshCurve() |
MeshCurve(MeshComponent mcomp) |
Modifier and Type | Method and Description |
---|---|
MeshMarker |
addMarker(Point3d pos) |
void |
clearMarkers() |
void |
componentChanged(ComponentChangeEvent e)
Notifies this composite component that a change has occured within one or
more of its descendants.
|
void |
connectToHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is added to the component hierarchy (i.e., added as
a child of another CompositeComponent).
|
MeshCurve |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap) |
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
void |
disconnectFromHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is removed from the component hierarchy (i.e., removed as a
child of its parent).
|
int |
findNearestMarkerInterval(Point3d p0)
Finds the index of the nearest marker interval on this curve to a
prescribed point
p0 . |
double |
findNearestPoint(Point3d pr,
Point3d p0,
double r0)
Finds the nearest point on this curve to a prescribed point
p0 .The method also returns the point's location. |
double |
findPointAtDistance(Point3d pr,
Point3d p0,
double dist,
double r0)
Finds the point on this curve that is a specified distance
dist
from a prescribed point p0 , within machine precision. |
void |
findPointAtLocation(Point3d pr,
double r)
Finds a point at a specific location on this curve, in world coordinates.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
double |
getArcLength(int idx)
Returns the arc-length at the
idx -th point on this curve, where
idx should be in the range [0, maxIdx] , where maxIdx is numPoints() -1 if the curve is open numPoints() if it is closed. |
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
MeshCurve.Interpolation |
getInterpolation() |
double |
getLength()
Returns the total length of this curve, as approximated by the sum of the
distances between all points.
|
java.util.List<Vector3d> |
getLocalNormals()
Returns a list of all the normals on this curve, in local mesh
coordinates.
|
java.util.List<Point3d> |
getLocalPoints()
Returns a list of all the points on this curve, in local mesh
coordinate.
|
PointList<MeshMarker> |
getMarkers() |
PolygonalMesh |
getMesh() |
MeshComponent |
getMeshComp() |
Vector3d |
getNormal(int idx)
Returns the
idx -th normal on this curve, in world coordinates,
where idx should be in the range 0 to numPoints() -1; |
double |
getNormalComputeRadius()
Queries the radius around the marker used to collect vertices for
estimating its surface normal.
|
PropertyMode |
getNormalComputeRadiusMode() |
double |
getNormalLength() |
java.util.List<Vector3d> |
getNormals()
Returns a list of all the normals on this curve, in world
coordinates.
|
Point3d |
getPoint(int idx)
Returns the
idx -th point on this curve, in world coordinates,
where idx should be in the range 0 to numPoints() -1; |
java.util.List<Point3d> |
getPoints()
Returns a list of all the points on this curve, in world coordinates.
|
boolean |
getProjectToMesh() |
double |
getResolution() |
Vector3d |
getTangent(int idx)
Returns the curve tangent for the
idx -th point on this curve,
where idx should be in the range 0 to numPoints() -1; The
tangent is computed by numerically differencing adjacent points. |
boolean |
isClosed() |
int |
numMarkers() |
int |
numPoints()
Returns the number of points (and normals) associated with this
MeshCurve.
|
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
boolean |
removeMarker(MeshMarker mkr) |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
void |
setClosed(boolean closed) |
void |
setInterpolation(MeshCurve.Interpolation interp) |
void |
setNormalComputeRadius(double rad)
Sets the radius around the marker used to collect vertices for estimating
its surface normal.
|
void |
setNormalComputeRadiusMode(PropertyMode mode) |
void |
setNormalLength(double len) |
void |
setProjectToMesh(boolean enable) |
void |
setResolution(double res) |
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
void |
updateCurveIfNecessary() |
void |
updateMarkerPositions() |
getRenderHints, getRenderProps, getSelection, isSelectable, numSelectionQueriesNeeded, setRenderProps
findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, hasChildren, hasState, hierarchyContainsReferences, indexOf, iterator, numComponents, postscan, scan, setDisplayMode, updateNameMap
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getGrandParent, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
recursivelyFind
public static final double INF
public static int DEFAULT_RESOLUTION
public static boolean DEFAULT_CLOSED
public static MeshCurve.Interpolation DEFAULT_INTERPOLATION
public static double DEFAULT_NORMAL_LENGTH
public static boolean DEFAULT_PROJECT_TO_MESH
public static PropertyList myProps
public MeshCurve()
public MeshCurve(MeshComponent mcomp)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ModelComponentBase
public double getResolution()
public void setResolution(double res)
public MeshCurve.Interpolation getInterpolation()
public boolean isClosed()
public void setClosed(boolean closed)
public void setInterpolation(MeshCurve.Interpolation interp)
public double getNormalLength()
public void setNormalLength(double len)
public void setNormalComputeRadius(double rad)
rad
- normal compute radiuspublic double getNormalComputeRadius()
setNormalComputeRadius(double)
for a
description of how this is done.public PropertyMode getNormalComputeRadiusMode()
public void setNormalComputeRadiusMode(PropertyMode mode)
public boolean getProjectToMesh()
public void setProjectToMesh(boolean enable)
public PolygonalMesh getMesh()
public MeshComponent getMeshComp()
public MeshMarker addMarker(Point3d pos)
public PointList<MeshMarker> getMarkers()
public int numMarkers()
public boolean removeMarker(MeshMarker mkr)
public void clearMarkers()
public void updateMarkerPositions()
public int numPoints()
n
is determined by the curve's resolution
property, and is computed so that in the case of linear
interpolation between the knot points, the distance between each point
will be <=
resolution.public java.util.List<Point3d> getLocalPoints()
numPoints
, and should not be
modified.public double getLength()
public java.util.List<Point3d> getPoints()
numPoints
.public Point3d getPoint(int idx)
idx
-th point on this curve, in world coordinates,
where idx
should be in the range 0 to numPoints()
-1;idx
- index of the desired pointidx
-th pointpublic double getArcLength(int idx)
idx
-th point on this curve, where
idx
should be in the range [0, maxIdx]
, where maxIdx
is numPoints()
-1 if the curve is open numPoints()
if it is closed.idx
- index of the point for which arc-length is desired.idx
-th pointpublic java.util.List<Vector3d> getLocalNormals()
numPoints
, and should not be
modified.public java.util.List<Vector3d> getNormals()
numPoints
.public Vector3d getNormal(int idx)
idx
-th normal on this curve, in world coordinates,
where idx
should be in the range 0 to numPoints()
-1;idx
- index of the desired normalidx
-th normalpublic Vector3d getTangent(int idx)
idx
-th point on this curve,
where idx
should be in the range 0 to numPoints()
-1; The
tangent is computed by numerically differencing adjacent points. If the
number of curve points is less than 1, the tangent is set to 0.idx
- index of the point for which the tangent is desiredidx
-th pointpublic double findPointAtDistance(Point3d pr, Point3d p0, double dist, double r0)
dist
from a prescribed point p0
, within machine precision. The method
also returns the location of the point. Point locations on the curve are
described by a non-negative parameter r
, which takes the form
r = k + swhere
k
is the index of a curve point (as returned by getPoints()
), and s
is a scalar parameter in the range [0,1]
that specifies the location along the interval between curve points
k
and k+1
. If the curve is open, the search for the
distance point begins at a location specified by r0
and locations
before r0
are ignored. If the curve is closed, r0
is
ignored.
If found, the method will return the point's location parameter r
, as well as the point's value in the optional parameter pr
if
it is not null
. If the point is not found, the method will return
-1.
pr
- if not null
, returns the distance point, if foundp0
- point with respect to which distance should be determineddist
- desired distance from p0
r0
- for open curves, a non-negative scalar giving the location on
the curve where the search should start. This should be a non-negative
scalar whose value is less than or equal to the number of curve points
(as returned by numPoints()
).public double findNearestPoint(Point3d pr, Point3d p0, double r0)
p0
.The method also returns the point's location. Locations on the curve
are described by a non-negative parameter r
, which takes the form
r = k + swhere
k
is the index of a curve point (as returned by getPoints()
), and s
is a scalar parameter in the range [0,1]
that specifies the location along the interval between curve points
k
and k+1
. If the curve is open, the search for the
nearest point begins at a location specified by r0
and locations
before r0
are ignored. If the polyline is closed, r0
is
ignored. The nearest point may not be unique.
The method will return the nearest point's location parameter r
, as well as the point's value in the optional parameter pr
if
it is not null
. If the curve is empty, both r
and
pr
at set to 0.
pr
- if not null
, returns the nearest pointp0
- point for which the nearest point should be determinedr0
- for open curves, a non-negative scalar giving the location
on the curve where the search should start. This should be a
non-negative scalar whose value is less than or equal to the number of
curve points (as returned by numPoints()
).public int findNearestMarkerInterval(Point3d p0)
p0
. This is defined as the interval containing
the nearest point to p0
.
If the curve is open, then there are numi = numMarkers()-1
intervals. If the nearest point is either the first point or last point,
then p0
is considered to lie before or after the
intervals and the method returns -1
or numi
,
respectively. Otherwise, the nearest interval index in the range 0
to numi-1
is returned.
If the curve is closed, then the number of intervals is numi =
numMarkers()
, and the method returns the nearest interval index in the
range 0
to numi-1
.
In all cases, the nearest interval may not be unique, in which case the interval with lowest index will be returned.
p0
- point for which the nearest point should be determinedpublic void findPointAtLocation(Point3d pr, double r)
r
, which
takes the form
r = k + swhere
k
is the index of a curve point (as returned by getPoints()
), and s
is a scalar parameter that specifies the
location along the interval between curve points k
and k+1
. If the curve is open, r
must lie in the range [0,
npnts-1]
, where numpts
is the number of curve points. If the
polyline is closed, then r
is reduced, using the modulo function,
to the range [0, numpts)
.pr
- returns the located point, in world coordinatesr
- specifies the location on the curvepublic void updateCurveIfNecessary()
public void componentChanged(ComponentChangeEvent e)
CompositeComponentBase
This method should propagate the notification up the component hierarchy
by calling notifyParentOfChange
.
componentChanged
in interface ComponentChangeListener
componentChanged
in interface CompositeComponent
componentChanged
in class CompositeComponentBase
e
- optional argument giving specific information about the changepublic RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
createRenderProps
in class RenderableCompositeBase
public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class RenderableCompositeBase
list
- list of objects to be renderedpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class RenderableCompositeBase
renderer
- provides the functionality used to perform the rendering.flags
- flags that may be used to control different
aspects of the rendering. Flags are defined in Renderer
and currently include
Renderer.HIGHLIGHT
and
Renderer.SORT_FACES
.public void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
updateBounds
in class RenderableCompositeBase
pmin
- minimum pointpmax
- maximum pointpublic void connectToHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will return the new
parent component; the system will have set this beforehand.
connectToHierarchy
in interface ModelComponent
connectToHierarchy
in class ModelComponentBase
hcomp
- hierarchy component to which this component,
or its ancestor, was attachedpublic void disconnectFromHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will still return this
original parent component; the system will set this to null
after.
disconnectFromHierarchy
in interface ModelComponent
disconnectFromHierarchy
in class ModelComponentBase
hcomp
- hierarchy component from which this component,
or its ancestor, was detachedpublic void getHardReferences(java.util.List<ModelComponent> refs)
getHardReferences
in interface ModelComponent
getHardReferences
in class ModelComponentBase
refs
- list to which hard references are appendedpublic MeshCurve copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
copy
in class RenderableCompositeBase