public class BVFeatureQuery
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BVFeatureQuery.InsideQuery |
static class |
BVFeatureQuery.NearestKCollector<T>
Collects the nearest K boundables, as in a k-nearest-neighbor search
|
static interface |
BVFeatureQuery.ObjectDistanceCalculator |
static interface |
BVFeatureQuery.ObjectDistanceCollector
Utility class for collecting objects when performing
a nearest-distance search until a condition is met
(e.g.
|
static class |
BVFeatureQuery.ObjectDistanceEntry<T>
Pair of { Object, Distance}, used by nearest object queries
|
Modifier and Type | Field and Description |
---|---|
boolean |
debug |
java.lang.String |
lastCase |
maspack.geometry.BVFeatureQuery.PointFaceDistanceCalculator |
myPointFaceCalc |
Constructor and Description |
---|
BVFeatureQuery() |
Modifier and Type | Method and Description |
---|---|
static double |
distanceToMesh(Point3d nearPnt,
PolygonalMesh mesh,
Point3d pnt)
Returns the nearest distance from a point to a mesh.
|
Face |
getFaceForInsideOrientedTest(Point3d nearLoc,
Vector2d uv)
If called immediately after either
isInsideOrientedMesh(PolygonalMesh,Point3d,double) or
isInsideOrientedMesh(BVTree,Point3d,double) ,
returns the nearest face
that was used to resolve whether or not the query point is actually
inside the mesh. |
int |
getMaxRayCasts()
Returns the maximum number of ray casts that will be attempted by
isInsideMesh(maspack.geometry.PolygonalMesh, maspack.matrix.Point3d) . |
static Face |
getNearestFaceToPoint(Point3d nearPnt,
Vector2d uv,
PolygonalMesh mesh,
Point3d pnt)
Returns the nearest triangular mesh face to a point.
|
BVFeatureQuery.InsideQuery |
isInsideMesh(PolygonalMesh mesh,
BVTree bvh,
Point3d pnt,
double tol)
Determines if a point is on or inside a closed triangular mesh, the faces
of which are contained within a specified bounding volume hierarchy.
|
static BVFeatureQuery.InsideQuery |
isInsideMesh(PolygonalMesh mesh,
Point3d pnt)
Determines if a point is on or inside a closed triangular mesh.
|
BVFeatureQuery.InsideQuery |
isInsideMesh(PolygonalMesh mesh,
Point3d pnt,
double tol)
Determines if a point is on or inside a closed triangular mesh.
|
boolean |
isInsideOrientedMesh(BVTree bvh,
Point3d pnt,
double tol)
Returns true if a point is on or inside an oriented triangular mesh, the
faces of which are contained within a specified bounding volume
hierarchy.
|
static boolean |
isInsideOrientedMesh(PolygonalMesh mesh,
Point3d pnt)
Returns true if a point is on or inside an oriented triangular
mesh.
|
boolean |
isInsideOrientedMesh(PolygonalMesh mesh,
Point3d pnt,
double tol)
Returns true if a point is on or inside an oriented triangular
mesh.
|
BVFeatureQuery.InsideQuery |
isInsideOrOnMesh(PolygonalMesh mesh,
BVTree bvh,
Point3d pnt,
double tol) |
Boundable |
nearestEdgeToPoint(Point3d nearPnt,
DoubleHolder sval,
BVTree bvh,
Point3d pnt)
Returns the nearest edge to a point, using a specified bounding volume
hierarchy.
|
Boundable |
nearestEdgeToPoint(Point3d nearPnt,
DoubleHolder sval,
MeshBase mesh,
Point3d pnt)
Returns the nearest mesh edge to a point.
|
Face |
nearestFaceAlongLine(Point3d nearPnt,
Vector3d duv,
BVTree bvh,
Point3d origin,
Vector3d dir,
double min,
double max)
Returns the nearest triangular face to a point along a line, using a
specified bounding volume hierarchy.
|
Face |
nearestFaceAlongLine(Point3d nearPnt,
Vector3d duv,
PolygonalMesh mesh,
Point3d origin,
Vector3d dir,
double min,
double max)
Returns the nearest triangular mesh face to a point along a line.
|
Face |
nearestFaceAlongRay(Point3d nearPnt,
Vector3d duv,
BVTree bvh,
Point3d origin,
Vector3d dir)
Returns the nearest triangular face along a directed ray, using a
specified bounding volume hierarchy.
|
Face |
nearestFaceAlongRay(Point3d nearPnt,
Vector3d duv,
PolygonalMesh mesh,
Point3d origin,
Vector3d dir)
Returns the nearest triangular mesh face along a directed ray.
|
Face |
nearestFaceToPoint(Point3d nearPnt,
Vector2d uv,
BVTree bvh,
Point3d pnt)
Returns the nearest triangular face to a point, using a specified
bounding volume hierarchy.
|
Face |
nearestFaceToPoint(Point3d nearPnt,
Vector2d uv,
PolygonalMesh mesh,
Point3d pnt)
Returns the nearest triangular mesh face to a point.
|
Feature |
nearestFeatureToPoint(Point3d nearPnt,
BVTree featureTree,
Point3d pnt)
Find the nearest feature to a point
|
java.util.TreeSet<BVFeatureQuery.ObjectDistanceEntry<Feature>> |
nearestKFeaturesToPoint(BVTree bvh,
int k,
Point3d pnt)
Finds the K nearest features in the bounding-volume hierarchy to a point in world coordinates
The resulting tree is ordered by distance (nearest to furthest).
|
BVNode |
nearestLeafToPoint(BVTree bvh,
Point3d pnt) |
Boundable |
nearestObject(BVTree bvh,
BVFeatureQuery.ObjectDistanceCalculator dcalc) |
void |
nearestObjects(BVTree bvh,
BVFeatureQuery.ObjectDistanceCalculator dcalc,
BVFeatureQuery.ObjectDistanceCollector coll)
Find and collect objects starting at the nearest and working outwards
until a given criteria is met
|
Boundable |
nearestObjectToPoint(Point3d nearPnt,
BVTree bvh,
BVFeatureQuery.ObjectDistanceCalculator calc)
Returns the nearest Object to a point, using a specified
bounding volume hierarchy.
|
static Point3d |
nearestPointAlongRay(PolygonalMesh mesh,
Point3d origin,
Vector3d dir)
Returns the nearest point on a polygonal mesh that intersects
a given ray, or null if the ray does not intersect the mesh.
|
Vertex3d |
nearestVertexToPoint(BVTree bvh,
Point3d pnt)
Returns the nearest mesh vertex to a point, using a specified bounding
volume hierarchy.
|
Vertex3d |
nearestVertexToPoint(MeshBase mesh,
Point3d pnt)
Returns the nearest mesh vertex to a point.
|
void |
setMaxRayCasts(int maxrc)
Sets the maximum number of ray casts that will be attempted by
isInsideMesh(maspack.geometry.PolygonalMesh, maspack.matrix.Point3d) . |
public maspack.geometry.BVFeatureQuery.PointFaceDistanceCalculator myPointFaceCalc
public boolean debug
public java.lang.String lastCase
public Face nearestFaceToPoint(Point3d nearPnt, Vector2d uv, PolygonalMesh mesh, Point3d pnt)
nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.uv
- if not null
, returns the UV coordinates
of the nearest face point. These are the barycentric coordinates
with respect to the second and third vertices.mesh
- mesh containing the faces.pnt
- point for which the nearest face should be found.null
if the mesh contains no faces.public Feature nearestFeatureToPoint(Point3d nearPnt, BVTree featureTree, Point3d pnt)
nearPnt
- populates with location of nearest point on set of featuresfeatureTree
- bounding-volume tree containing desired featurespnt
- point from which to find the nearest featurepublic Face nearestFaceToPoint(Point3d nearPnt, Vector2d uv, BVTree bvh, Point3d pnt)
nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.uv
- if not null
, returns the UV coordinates
of the nearest face point. These are the barycentric coordinates
with respect to the second and third vertices.bvh
- bounding volume hierarchy containing the faces.pnt
- point for which the nearest face should be found.null
if bvh
contains no faces.public static Face getNearestFaceToPoint(Point3d nearPnt, Vector2d uv, PolygonalMesh mesh, Point3d pnt)
nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.uv
- if not null
, returns the UV coordinates
of the nearest face point. These are the barycentric coordinates
with respect to the second and third vertices.mesh
- mesh containing the faces.pnt
- point for which the nearest face should be found.null
if the mesh contains no faces.public static double distanceToMesh(Point3d nearPnt, PolygonalMesh mesh, Point3d pnt)
nearPnt
- if not null
, returns the nearest
point on the mesh in world coordinates.mesh
- mesh to which distance should be computed.pnt
- point for which distance should be computed (world coords)public Face nearestFaceAlongRay(Point3d nearPnt, Vector3d duv, PolygonalMesh mesh, Point3d origin, Vector3d dir)
nearPnt
and duv
are undefined.nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.duv
- if not null
, returns the distance of the point to
the face (in x
) and the UV coordinates of the nearest face
point (in y
and z
). The UV coordinates are the
barycentric coordinates with respect to the second and third vertices.mesh
- mesh containing the faces.origin
- originating point of the ray.dir
- direction of the ray. If not normalized, the distance
returned in duv
will be scaled by the inverse of
the length of dir
.null
is no
face is found.public Face nearestFaceAlongRay(Point3d nearPnt, Vector3d duv, BVTree bvh, Point3d origin, Vector3d dir)
nearPnt
and duv
are undefined.nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.duv
- if not null
, returns the distance of the point to
the face (in x
) and the UV coordinates of the nearest face
point (in y
and z
). The UV coordinates are the
barycentric coordinates with respect to the second and third vertices.bvh
- bounding volume hierarchy containing the faces.origin
- origininating point of the ray.dir
- direction of the ray. If not normalized, the distance
returned in duv
will be scaled by the inverse of
the length of dir
.null
is no
face is found.public static Point3d nearestPointAlongRay(PolygonalMesh mesh, Point3d origin, Vector3d dir)
mesh
- to intersect with the rayorigin
- origininating point of the ray.dir
- direction of the ray.public Face nearestFaceAlongLine(Point3d nearPnt, Vector3d duv, PolygonalMesh mesh, Point3d origin, Vector3d dir, double min, double max)
nearPnt
and
duv
are undefined. The search can be restricted to a line
segment by restricting min
and max
to finite
values. Setting them to negative and positive infinity causes the entire
line to be searched.nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.duv
- if not null
, returns the distance of the point to
the face (in x
) and the UV coordinates of the nearest face
point (in y
and z
). The UV coordinates are the
barycentric coordinates with respect to the second and third vertices.mesh
- mesh containing the facesorigin
- originating point of the linedir
- direction of the line. If not normalized, the distance
returned in duv
will be scaled by the inverse of
the length of dir
.min
- minimum allowed distance along the line from
origin
.max
- maximum allowed distance along the line from
origin
.null
is no
face is found.public Face nearestFaceAlongLine(Point3d nearPnt, Vector3d duv, BVTree bvh, Point3d origin, Vector3d dir, double min, double max)
nearPnt
and duv
are
undefined. The search can be restricted to a line segment by restricting
min
and max
to finite values. Setting them to
negative and positive infinity causes the entire line to be searched.nearPnt
- if not null
, returns the nearest
point on the face in world coordinates.duv
- if not null
, returns the distance of the point to
the face (in x
) and the UV coordinates of the nearest face
point (in y
and z
). The UV coordinates are the
barycentric coordinates with respect to the second and third vertices.bvh
- bounding volume hierarchy containing the faces.origin
- originating point of the linedir
- direction of the line. If not normalized, the distance
returned in duv
will be scaled by the inverse of
the length of dir
.min
- minimum allowed distance along the line from
origin
.max
- maximum allowed distance along the line from
origin
.null
is no
face is found.public static boolean isInsideOrientedMesh(PolygonalMesh mesh, Point3d pnt)
The method works by inspecting the nearest face, edge or vertex to
the point. Hence the mesh does not need to be closed, and the method is
faster, though possibly less numerically robust, than isInsideMesh(PolygonalMesh,Point3d)
, which uses ray casting.
mesh
- mesh which point may be inside.pnt
- point to check.pnt
is on or inside the mesh.public boolean isInsideOrientedMesh(PolygonalMesh mesh, Point3d pnt, double tol)
The method works by inspecting the nearest face, edge or vertex to
the point. Hence the mesh does not need to be closed, and the method is
faster, though possibly less numerically robust, than isInsideMesh(PolygonalMesh,Point3d,double)
, which uses ray casting.
mesh
- mesh which point may be inside.pnt
- point to check (in world coordinates)tol
- tolerance within which the point is considered to be on the
mesh surfaces. A value of -1 will cause the tolerance to be computed
automatically.pnt
is on or inside the mesh.public boolean isInsideOrientedMesh(BVTree bvh, Point3d pnt, double tol)
The method works by inspecting the nearest face, edge or vertex to
the point. Hence the mesh does not need to be closed, and the method is
faster, though possibly less numerically robust, than isInsideMesh(PolygonalMesh,BVTree,Point3d,double)
, which uses ray casting.
bvh
- bounding volume hierarchy containing the faces.pnt
- point to check (in world coordinates)tol
- tolerance within which the point is considered to be on the
mesh surface. A value of -1 will cause the tolerance to be computed
automatically.pnt
is on or inside the mesh.public Face getFaceForInsideOrientedTest(Point3d nearLoc, Vector2d uv)
isInsideOrientedMesh(PolygonalMesh,Point3d,double)
or
isInsideOrientedMesh(BVTree,Point3d,double)
,
returns the nearest face
that was used to resolve whether or not the query point is actually
inside the mesh. If the point is outside the mesh's bounding tree, then
no nearest face will have been computed and this method will return
null
.nearLoc
- if not null
, and if the returned face is not
null
, returns the nearest point (to the query point) on the
face in mesh local coordinates.uv
- if not null
, and if the returned face is not
null
, returns the UV coordinates of the nearest point on the
face. These are the barycentric coordinates with respect to the second
and third vertices.public int getMaxRayCasts()
isInsideMesh(maspack.geometry.PolygonalMesh, maspack.matrix.Point3d)
.public void setMaxRayCasts(int maxrc)
isInsideMesh(maspack.geometry.PolygonalMesh, maspack.matrix.Point3d)
.maxrc
- maximum number of ray castspublic static BVFeatureQuery.InsideQuery isInsideMesh(PolygonalMesh mesh, Point3d pnt)
The maximum number of ray casts can be controlled by the methods getMaxRayCasts()
and setMaxRayCasts(int)
. If the number of ray casts
exceeds this total the method returns InsideQuery.UNSURE.
mesh
- mesh which point may be inside.pnt
- point to check.pnt
is inside, InsideQuery.ON if on,
InsideQuery.OUTSIDE if it is outside, and InsideQuery.UNSURE if the method did not converge.public BVFeatureQuery.InsideQuery isInsideMesh(PolygonalMesh mesh, Point3d pnt, double tol)
The maximum number of ray casts can be controlled by the methods getMaxRayCasts()
and setMaxRayCasts(int)
. If the number of ray casts
exceeds this total the method returns InsideQuery.UNSURE.
mesh
- mesh which point may be inside.pnt
- point to check.tol
- tolerance within which the point is considered to be on the
mesh surface. A value of -1 will cause the tolerance to be computed
automatically.pnt
is inside, InsideQuery.ON if on,
InsideQuery.OUTSIDE if it is outside, and InsideQuery.UNSURE if the method did not converge.public BVFeatureQuery.InsideQuery isInsideMesh(PolygonalMesh mesh, BVTree bvh, Point3d pnt, double tol)
The maximum number of ray casts can be
controlled by the methods getMaxRayCasts()
and setMaxRayCasts(int)
. If the number of ray casts exceeds this total the
method returns InsideQuery.UNSURE.
mesh
- mesh which point may be inside.bvh
- bounding volume hierarchy containing the mesh.pnt
- point to check.tol
- tolerance within which the point is considered to be on the
mesh surface. A value of -1 will cause the tolerance to be computed
automatically.pnt
is inside or on,
InsideQuery.OUTSIDE if it is outside, and InsideQuery.UNSURE if the method did not converge.public BVFeatureQuery.InsideQuery isInsideOrOnMesh(PolygonalMesh mesh, BVTree bvh, Point3d pnt, double tol)
public Vertex3d nearestVertexToPoint(MeshBase mesh, Point3d pnt)
mesh
- mesh containing the vertices.pnt
- point for which the nearest vertex should be found.null
if the mesh
contains no vertices.public Vertex3d nearestVertexToPoint(BVTree bvh, Point3d pnt)
bvh
- bounding volume hierarchy containing the vertices.pnt
- point for which the nearest vertex should be found.null
if
bvh
contains no vertices.public Boundable nearestEdgeToPoint(Point3d nearPnt, DoubleHolder sval, MeshBase mesh, Point3d pnt)
nearPnt
- if not null
, returns the nearest point on
the edge.sval
- if not null
, returns a coordinate in the
range [0,1] giving the location of the nearest point along the edge.mesh
- mesh containing the edges.pnt
- point for which the nearest edge should be found.null
if the mesh
contains no edges.public Boundable nearestEdgeToPoint(Point3d nearPnt, DoubleHolder sval, BVTree bvh, Point3d pnt)
nearPnt
- if not null
, returns the nearest point on
the edge.sval
- if not null
, returns a coordinate in the
range [0,1] giving the location of the nearest point along the edge.bvh
- bounding volume hierarchy containing the faces.pnt
- point for which the nearest edge should be found.null
if
bvh
contains no edges.public Boundable nearestObjectToPoint(Point3d nearPnt, BVTree bvh, BVFeatureQuery.ObjectDistanceCalculator calc)
nearPnt
- if not null
, returns the nearest
point in the boundablebvh
- bounding volume hierarchy containing the faces.calc
- distance calculator for which nearest object should be found.null
if bvh
contains no objects.public Boundable nearestObject(BVTree bvh, BVFeatureQuery.ObjectDistanceCalculator dcalc)
public void nearestObjects(BVTree bvh, BVFeatureQuery.ObjectDistanceCalculator dcalc, BVFeatureQuery.ObjectDistanceCollector coll)
bvh
- bounding object hierarchydcalc
- distance calculatorcoll
- distance conditionpublic java.util.TreeSet<BVFeatureQuery.ObjectDistanceEntry<Feature>> nearestKFeaturesToPoint(BVTree bvh, int k, Point3d pnt)
bvh
- bounding volume hierarchyk
- number of elements to returnpnt
- point (world-coordinates)