mirror of
https://github.com/apache/lucene.git
synced 2025-02-10 12:05:36 +00:00
Separate the above and below planes everywhere so we can compute intersections and bounds.
This commit is contained in:
parent
6bb6b4e82a
commit
f48623de72
@ -43,8 +43,14 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
private final GeoPoint testPoint;
|
private final GeoPoint testPoint;
|
||||||
|
|
||||||
private final Plane testPointXZPlane;
|
private final Plane testPointXZPlane;
|
||||||
|
private final Plane testPointXZAbovePlane;
|
||||||
|
private final Plane testPointXZBelowPlane;
|
||||||
private final Plane testPointYZPlane;
|
private final Plane testPointYZPlane;
|
||||||
|
private final Plane testPointYZAbovePlane;
|
||||||
|
private final Plane testPointYZBelowPlane;
|
||||||
private final Plane testPointXYPlane;
|
private final Plane testPointXYPlane;
|
||||||
|
private final Plane testPointXYAbovePlane;
|
||||||
|
private final Plane testPointXYBelowPlane;
|
||||||
|
|
||||||
private final GeoPoint[] edgePoints;
|
private final GeoPoint[] edgePoints;
|
||||||
private final Edge[] shapeStartEdges;
|
private final Edge[] shapeStartEdges;
|
||||||
@ -69,6 +75,13 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
this.testPointYZPlane = new Plane(1.0, 0.0, 0.0, -testPoint.x);
|
this.testPointYZPlane = new Plane(1.0, 0.0, 0.0, -testPoint.x);
|
||||||
this.testPointXYPlane = new Plane(0.0, 0.0, 1.0, -testPoint.z);
|
this.testPointXYPlane = new Plane(0.0, 0.0, 1.0, -testPoint.z);
|
||||||
|
|
||||||
|
this.testPointXZAbovePlane = new Plane(testPointXZPlane, true);
|
||||||
|
this.testPointXZBelowPlane = new Plane(testPointXZPlane, false);
|
||||||
|
this.testPointYZAbovePlane = new Plane(testPointYZPlane, true);
|
||||||
|
this.testPointYZBelowPlane = new Plane(testPointYZPlane, false);
|
||||||
|
this.testPointXYAbovePlane = new Plane(testPointXYPlane, true);
|
||||||
|
this.testPointXYBelowPlane = new Plane(testPointXYPlane, false);
|
||||||
|
|
||||||
this.edgePoints = new GeoPoint[pointsList.size()];
|
this.edgePoints = new GeoPoint[pointsList.size()];
|
||||||
this.shapeStartEdges = new Edge[pointsList.size()];
|
this.shapeStartEdges = new Edge[pointsList.size()];
|
||||||
int edgePointIndex = 0;
|
int edgePointIndex = 0;
|
||||||
@ -122,7 +135,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Use the XZ plane exclusively.
|
// Use the XZ plane exclusively.
|
||||||
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointXZPlane, testPoint);
|
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointXZPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointXZPlane, thePoint);
|
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointXZPlane, thePoint);
|
||||||
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointXZPlane, testPointCutoff, checkPointCutoff, thePoint);
|
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointXZPlane, testPointXZAbovePlane, testPointXZBelowPlane, testPointCutoff, checkPointCutoff, thePoint);
|
||||||
// Traverse our way from the test point to the check point. Use the y tree because that's fixed.
|
// Traverse our way from the test point to the check point. Use the y tree because that's fixed.
|
||||||
if (!yTree.traverse(crossingEdgeIterator, testPoint.y, testPoint.y)) {
|
if (!yTree.traverse(crossingEdgeIterator, testPoint.y, testPoint.y)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
@ -133,7 +146,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Use the YZ plane exclusively.
|
// Use the YZ plane exclusively.
|
||||||
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointYZPlane, testPoint);
|
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointYZPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointYZPlane, thePoint);
|
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointYZPlane, thePoint);
|
||||||
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointYZPlane, testPointCutoff, checkPointCutoff, thePoint);
|
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointYZPlane, testPointYZAbovePlane, testPointYZBelowPlane, testPointCutoff, checkPointCutoff, thePoint);
|
||||||
// Traverse our way from the test point to the check point. Use the x tree because that's fixed.
|
// Traverse our way from the test point to the check point. Use the x tree because that's fixed.
|
||||||
if (!xTree.traverse(crossingEdgeIterator, testPoint.x, testPoint.x)) {
|
if (!xTree.traverse(crossingEdgeIterator, testPoint.x, testPoint.x)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
@ -144,7 +157,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Use the XY plane exclusively.
|
// Use the XY plane exclusively.
|
||||||
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointXYPlane, testPoint);
|
final SidedPlane testPointCutoff = new SidedPlane(thePoint, testPointXYPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointXYPlane, thePoint);
|
final SidedPlane checkPointCutoff = new SidedPlane(testPoint, testPointXYPlane, thePoint);
|
||||||
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointXYPlane, testPointCutoff, checkPointCutoff, thePoint);
|
final CrossingEdgeIterator crossingEdgeIterator = new CrossingEdgeIterator(testPointXYPlane, testPointXYAbovePlane, testPointXYBelowPlane, testPointCutoff, checkPointCutoff, thePoint);
|
||||||
// Traverse our way from the test point to the check point. Use the z tree because that's fixed.
|
// Traverse our way from the test point to the check point. Use the z tree because that's fixed.
|
||||||
if (!zTree.traverse(crossingEdgeIterator, testPoint.z, testPoint.z)) {
|
if (!zTree.traverse(crossingEdgeIterator, testPoint.z, testPoint.z)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
@ -159,6 +172,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Travel in X and Y
|
// Travel in X and Y
|
||||||
// We'll do this using the testPointYZPlane, and create a travel plane for the right XZ plane.
|
// We'll do this using the testPointYZPlane, and create a travel plane for the right XZ plane.
|
||||||
final Plane travelPlane = new Plane(0.0, 1.0, 0.0, -thePoint.y);
|
final Plane travelPlane = new Plane(0.0, 1.0, 0.0, -thePoint.y);
|
||||||
|
final Plane travelAbovePlane = new Plane(travelPlane, true);
|
||||||
|
final Plane travelBelowPlane = new Plane(travelPlane, false);
|
||||||
// We need cutoff planes for both legs.
|
// We need cutoff planes for both legs.
|
||||||
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointYZPlane, testPoint);
|
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointYZPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
||||||
@ -170,9 +185,9 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
||||||
// Note: we need to handle the cases where end point of the leg sits on an edge!
|
// Note: we need to handle the cases where end point of the leg sits on an edge!
|
||||||
// MHL
|
// MHL
|
||||||
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointYZPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointYZPlane, testPointYZAbovePlane, testPointYZBelowPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
||||||
xTree.traverse(testPointEdgeIterator, testPoint.x, testPoint.x);
|
xTree.traverse(testPointEdgeIterator, testPoint.x, testPoint.x);
|
||||||
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, travelAbovePlane, travelBelowPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
||||||
if (!yTree.traverse(checkPointEdgeIterator, thePoint.y, thePoint.y)) {
|
if (!yTree.traverse(checkPointEdgeIterator, thePoint.y, thePoint.y)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
return true;
|
return true;
|
||||||
@ -182,6 +197,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Travel in X and Z
|
// Travel in X and Z
|
||||||
// We'll do this using the testPointXYPlane, and create a travel plane for the right YZ plane.
|
// We'll do this using the testPointXYPlane, and create a travel plane for the right YZ plane.
|
||||||
final Plane travelPlane = new Plane(1.0, 0.0, 0.0, -thePoint.x);
|
final Plane travelPlane = new Plane(1.0, 0.0, 0.0, -thePoint.x);
|
||||||
|
final Plane travelAbovePlane = new Plane(travelPlane, true);
|
||||||
|
final Plane travelBelowPlane = new Plane(travelPlane, false);
|
||||||
// We need cutoff planes for both legs.
|
// We need cutoff planes for both legs.
|
||||||
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointXYPlane, testPoint);
|
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointXYPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
||||||
@ -193,9 +210,9 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
||||||
// Note: we need to handle the cases where end point of the leg sits on an edge!
|
// Note: we need to handle the cases where end point of the leg sits on an edge!
|
||||||
// MHL
|
// MHL
|
||||||
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointXYPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointXYPlane, testPointXYAbovePlane, testPointXYBelowPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
||||||
zTree.traverse(testPointEdgeIterator, testPoint.z, testPoint.z);
|
zTree.traverse(testPointEdgeIterator, testPoint.z, testPoint.z);
|
||||||
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, travelAbovePlane, travelBelowPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
||||||
if (!xTree.traverse(checkPointEdgeIterator, thePoint.x, thePoint.x)) {
|
if (!xTree.traverse(checkPointEdgeIterator, thePoint.x, thePoint.x)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
return true;
|
return true;
|
||||||
@ -205,6 +222,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
// Travel in Y and Z
|
// Travel in Y and Z
|
||||||
// We'll do this using the testPointXZPlane, and create a travel plane for the right XY plane.
|
// We'll do this using the testPointXZPlane, and create a travel plane for the right XY plane.
|
||||||
final Plane travelPlane = new Plane(0.0, 0.0, 1.0, -thePoint.z);
|
final Plane travelPlane = new Plane(0.0, 0.0, 1.0, -thePoint.z);
|
||||||
|
final Plane travelAbovePlane = new Plane(travelPlane, true);
|
||||||
|
final Plane travelBelowPlane = new Plane(travelPlane, false);
|
||||||
// We need cutoff planes for both legs.
|
// We need cutoff planes for both legs.
|
||||||
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointXZPlane, testPoint);
|
final SidedPlane testPointCutoffPlane = new SidedPlane(thePoint, testPointXZPlane, testPoint);
|
||||||
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
final SidedPlane checkPointCutoffPlane = new SidedPlane(testPoint, travelPlane, thePoint);
|
||||||
@ -216,9 +235,9 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
final SidedPlane checkPointOtherCutoffPlane = new SidedPlane(thePoint, travelPlane, intersectionPoints[0]);
|
||||||
// Note: we need to handle the cases where end point of the first leg sits on an edge!
|
// Note: we need to handle the cases where end point of the first leg sits on an edge!
|
||||||
// MHL
|
// MHL
|
||||||
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointXZPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
final CrossingEdgeIterator testPointEdgeIterator = new CrossingEdgeIterator(testPointXZPlane, testPointXZAbovePlane, testPointXZBelowPlane, testPointCutoffPlane, testPointOtherCutoffPlane, null);
|
||||||
yTree.traverse(testPointEdgeIterator, testPoint.y, testPoint.y);
|
yTree.traverse(testPointEdgeIterator, testPoint.y, testPoint.y);
|
||||||
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
final CrossingEdgeIterator checkPointEdgeIterator = new CrossingEdgeIterator(travelPlane, travelAbovePlane, travelBelowPlane, checkPointCutoffPlane, checkPointOtherCutoffPlane, thePoint);
|
||||||
if (!zTree.traverse(checkPointEdgeIterator, thePoint.z, thePoint.z)) {
|
if (!zTree.traverse(checkPointEdgeIterator, thePoint.z, thePoint.z)) {
|
||||||
// Endpoint is on edge
|
// Endpoint is on edge
|
||||||
return true;
|
return true;
|
||||||
@ -589,10 +608,10 @@ class GeoComplexPolygon extends GeoBasePolygon {
|
|||||||
|
|
||||||
public int crossingCount = 0;
|
public int crossingCount = 0;
|
||||||
|
|
||||||
public CrossingEdgeIterator(final Plane plane, final Membership bound1, final Membership bound2, final Vector thePoint) {
|
public CrossingEdgeIterator(final Plane plane, final Plane abovePlane, final Plane belowPlane, final Membership bound1, final Membership bound2, final Vector thePoint) {
|
||||||
this.plane = plane;
|
this.plane = plane;
|
||||||
this.abovePlane = new Plane(plane, true);
|
this.abovePlane = abovePlane;
|
||||||
this.belowPlane = new Plane(plane, false);
|
this.belowPlane = belowPlane;
|
||||||
this.bound1 = bound1;
|
this.bound1 = bound1;
|
||||||
this.bound2 = bound2;
|
this.bound2 = bound2;
|
||||||
this.thePoint = thePoint;
|
this.thePoint = thePoint;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user