本文整理汇总了Java中org.poly2tri.triangulation.delaunay.DelaunayTriangle.oppositePoint方法的典型用法代码示例。如果您正苦于以下问题:Java DelaunayTriangle.oppositePoint方法的具体用法?Java DelaunayTriangle.oppositePoint怎么用?Java DelaunayTriangle.oppositePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.poly2tri.triangulation.delaunay.DelaunayTriangle
的用法示例。
在下文中一共展示了DelaunayTriangle.oppositePoint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flipEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
private static void flipEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle t,
TriangulationPoint p )
{
TriangulationPoint op, newP;
DelaunayTriangle ot;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
} // TODO: remove
inScanArea = inScanArea( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inScanArea )
{
// Lets rotate shared edge one vertex CW
rotateTrianglePair( t, p, ot, op );
tcx.mapTriangleToNodes( t );
tcx.mapTriangleToNodes( ot );
if( p == eq && op == ep )
{
if( eq == tcx.edgeEvent.constrainedEdge.q
&& ep == tcx.edgeEvent.constrainedEdge.p)
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - constrained edge done" ); } // TODO: remove
t.markConstrainedEdge( ep, eq );
ot.markConstrainedEdge( ep, eq );
legalize( tcx, t );
legalize( tcx, ot );
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - subedge done" ); } // TODO: remove
// XXX: I think one of the triangles should be legalized here?
}
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - flipping and continuing with triangle still crossing edge" ); } // TODO: remove
Orientation o = orient2d( eq, op, ep );
t = nextFlipTriangle( tcx, o, t, ot, p, op );
flipEdgeEvent( tcx, ep, eq, t, p );
}
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, t, ot, newP );
edgeEvent( tcx, ep, eq, t, p );
}
}
示例2: flipScanEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
/**
* Scan part of the FlipScan algorithm<br>
* When a triangle pair isn't flippable we will scan for the next
* point that is inside the flip triangle scan area. When found
* we generate a new flipEdgeEvent
*
* @param tcx
* @param ep - last point on the edge we are traversing
* @param eq - first point on the edge we are traversing
* @param flipTriangle - the current triangle sharing the point eq with edge
* @param t
* @param p
*/
private static void flipScanEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle flipTriangle,
DelaunayTriangle t,
TriangulationPoint p )
{
DelaunayTriangle ot;
TriangulationPoint op,newP;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( tcx.isDebugEnabled() )
{
System.out.println("[FLIP:SCAN] - scan next point" ); // TODO: remove
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
}
inScanArea = inScanArea( eq,
flipTriangle.pointCCW( eq ),
flipTriangle.pointCW( eq ),
op );
if( inScanArea )
{
// flip with new edge op->eq
flipEdgeEvent( tcx, eq, op, ot, op );
// TODO: Actually I just figured out that it should be possible to
// improve this by getting the next ot and op before the the above
// flip and continue the flipScanEdgeEvent here
// set new ot and op here and loop back to inScanArea test
// also need to set a new flipTriangle first
// Turns out at first glance that this is somewhat complicated
// so it will have to wait.
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, flipTriangle, ot, newP );
}
}
示例3: legalize
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
/**
* Returns true if triangle was legalized
*/
private static boolean legalize( DTSweepContext tcx,
DelaunayTriangle t )
{
int oi;
boolean inside;
TriangulationPoint p,op;
DelaunayTriangle ot;
// To legalize a triangle we start by finding if any of the three edges
// violate the Delaunay condition
for( int i=0; i<3; i++ )
{
// TODO: fix so that cEdge is always valid when creating new triangles then we can check it here
// instead of below with ot
if( t.dEdge[i] )
{
continue;
}
ot = t.neighbors[i];
if( ot != null )
{
p = t.points[i];
op = ot.oppositePoint( t, p );
oi = ot.index( op );
// If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)
// then we should not try to legalize
if( ot.cEdge[oi] || ot.dEdge[oi] )
{
t.cEdge[i] = ot.cEdge[oi]; // XXX: have no good way of setting this property when creating new triangles so lets set it here
continue;
}
inside = smartIncircle( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inside )
{
boolean notLegalized;
// Lets mark this shared edge as Delaunay
t.dEdge[i] = true;
ot.dEdge[oi] = true;
// Lets rotate shared edge one vertex CW to legalize it
rotateTrianglePair( t, p, ot, op );
// We now got one valid Delaunay Edge shared by two triangles
// This gives us 4 new edges to check for Delaunay
// Make sure that triangle to node mapping is done only one time for a specific triangle
notLegalized = !legalize( tcx, t );
if( notLegalized )
{
tcx.mapTriangleToNodes( t );
}
notLegalized = !legalize( tcx, ot );
if( notLegalized )
{
tcx.mapTriangleToNodes( ot );
}
// Reset the Delaunay edges, since they only are valid Delaunay edges
// until we add a new triangle or point.
// XXX: need to think about this. Can these edges be tried after we
// return to previous recursive level?
t.dEdge[i] = false;
ot.dEdge[oi] = false;
// If triangle have been legalized no need to check the other edges since
// the recursive legalization will handles those so we can end here.
return true;
}
}
}
return false;
}
示例4: flipEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
private static void flipEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle t,
TriangulationPoint p )
{
TriangulationPoint op, newP;
DelaunayTriangle ot;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( t.getConstrainedEdgeAcross(p) )
{
throw new RuntimeException( "Intersecting Constraints" );
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
} // TODO: remove
inScanArea = inScanArea( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inScanArea )
{
// Lets rotate shared edge one vertex CW
rotateTrianglePair( t, p, ot, op );
tcx.mapTriangleToNodes( t );
tcx.mapTriangleToNodes( ot );
if( p == eq && op == ep )
{
if( eq == tcx.edgeEvent.constrainedEdge.q
&& ep == tcx.edgeEvent.constrainedEdge.p)
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - constrained edge done" ); } // TODO: remove
t.markConstrainedEdge( ep, eq );
ot.markConstrainedEdge( ep, eq );
legalize( tcx, t );
legalize( tcx, ot );
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - subedge done" ); } // TODO: remove
// XXX: I think one of the triangles should be legalized here?
}
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - flipping and continuing with triangle still crossing edge" ); } // TODO: remove
Orientation o = orient2d( eq, op, ep );
t = nextFlipTriangle( tcx, o, t, ot, p, op );
flipEdgeEvent( tcx, ep, eq, t, p );
}
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, t, ot, newP );
edgeEvent( tcx, ep, eq, t, p );
}
}
示例5: flipEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
private static void flipEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle t,
TriangulationPoint p )
{
TriangulationPoint op, newP;
DelaunayTriangle ot;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( t.getConstrainedEdgeAcross(p) )
{
throw new RuntimeException( "Intersecting Constraints" );
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
} // TODO: remove
inScanArea = inScanArea( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inScanArea )
{
// Lets rotate shared edge one vertex CW
rotateTrianglePair( t, p, ot, op );
tcx.mapTriangleToNodes( t );
tcx.mapTriangleToNodes( ot );
if( p == eq && op == ep )
{
if( eq == tcx.edgeEvent.constrainedEdge.q
&& ep == tcx.edgeEvent.constrainedEdge.p)
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - constrained edge done" ); } // TODO: remove
t.markConstrainedEdge( ep, eq );
ot.markConstrainedEdge( ep, eq );
legalize( tcx, t );
legalize( tcx, ot );
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - subedge done" ); } // TODO: remove
// XXX: I think one of the triangles should be legalized here?
}
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - flipping and continuing with triangle still crossing edge" ); } // TODO: remove
Orientation o = orient2d( eq, op, ep );
t = nextFlipTriangle( tcx, o, t, ot, p, op );
flipEdgeEvent( tcx, ep, eq, t, p );
}
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, t, ot, newP );
edgeEvent( tcx, ep, eq, t, p );
}
}
示例6: flipScanEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
/**
* Scan part of the FlipScan algorithm<br>
* When a triangle pair isn't flippable we will scan for the next
* point that is inside the flip triangle scan area. When found
* we generate a new flipEdgeEvent
*
* @param tcx
* @param ep - last point on the edge we are traversing
* @param eq - first point on the edge we are traversing
* @param flipTriangle - the current triangle sharing the point eq with edge
* @param t
* @param p
*/
private static void flipScanEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle flipTriangle,
DelaunayTriangle t,
TriangulationPoint p )
{
DelaunayTriangle ot;
TriangulationPoint op,newP;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( tcx.isDebugEnabled() )
{
System.out.println("[FLIP:SCAN] - scan next point" ); // TODO: remove
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
}
inScanArea = inScanArea( eq,
flipTriangle.pointCCW( eq ),
flipTriangle.pointCW( eq ),
op );
if( inScanArea )
{
// flip with new edge op->eq
flipEdgeEvent( tcx, eq, op, ot, op );
// TODO: Actually I just figured out that it should be possible to
// improve this by getting the next ot and op before the the above
// flip and continue the flipScanEdgeEvent here
// set new ot and op here and loop back to inScanArea test
// also need to set a new flipTriangle first
// Turns out at first glance that this is somewhat complicated
// so it will have to wait.
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, flipTriangle, ot, newP );
}
}
示例7: legalize
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
/**
* Returns true if triangle was legalized
*/
private static boolean legalize( DTSweepContext tcx,
DelaunayTriangle t )
{
int oi;
boolean inside;
TriangulationPoint p,op;
DelaunayTriangle ot;
// To legalize a triangle we start by finding if any of the three edges
// violate the Delaunay condition
for( int i=0; i<3; i++ )
{
// TODO: fix so that cEdge is always valid when creating new triangles then we can check it here
// instead of below with ot
if( t.dEdge[i] )
{
continue;
}
ot = t.neighbors[i];
if( ot != null )
{
p = t.points[i];
op = ot.oppositePoint( t, p );
oi = ot.index( op );
// If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)
// then we should not try to legalize
if( ot.cEdge[oi] || ot.dEdge[oi] )
{
t.cEdge[i] = ot.cEdge[oi]; // XXX: have no good way of setting this property when creating new triangles so lets set it here
continue;
}
inside = smartIncircle( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inside )
{
boolean notLegalized;
// Lets mark this shared edge as Delaunay
t.dEdge[i] = true;
ot.dEdge[oi] = true;
// Lets rotate shared edge one vertex CW to legalize it
rotateTrianglePair( t, p, ot, op );
// We now got one valid Delaunay Edge shared by two triangles
// This gives us 4 new edges to check for Delaunay
// Make sure that triangle to node mapping is done only one time for a specific triangle
notLegalized = !legalize( tcx, t );
if( notLegalized )
{
tcx.mapTriangleToNodes( t );
}
notLegalized = !legalize( tcx, ot );
if( notLegalized )
{
tcx.mapTriangleToNodes( ot );
}
// Reset the Delaunay edges, since they only are valid Delaunay edges
// until we add a new triangle or point.
// XXX: need to think about this. Can these edges be tried after we
// return to previous recursive level?
t.dEdge[i] = false;
ot.dEdge[oi] = false;
// If triangle have been legalized no need to check the other edges since
// the recursive legalization will handles those so we can end here.
return true;
}
}
}
return false;
}
示例8: flipEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
private static void flipEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle t,
TriangulationPoint p )
{
TriangulationPoint op, newP;
DelaunayTriangle ot;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( t.getConstrainedEdgeAcross(p) )
{
throw new RuntimeException( "Intersecting Constraints" );
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
} // TODO: remove
inScanArea = inScanArea( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inScanArea )
{
// Lets rotate shared edge one vertex CW
rotateTrianglePair( t, p, ot, op );
tcx.mapTriangleToNodes( t );
tcx.mapTriangleToNodes( ot );
if( p == eq && op == ep )
{
if( eq == tcx.edgeEvent.constrainedEdge.q
&& ep == tcx.edgeEvent.constrainedEdge.p)
{
t.markConstrainedEdge( ep, eq );
ot.markConstrainedEdge( ep, eq );
legalize( tcx, t );
legalize( tcx, ot );
}
}
else
{
Orientation o = orient2d( eq, op, ep );
t = nextFlipTriangle( tcx, o, t, ot, p, op );
flipEdgeEvent( tcx, ep, eq, t, p );
}
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, t, ot, newP );
edgeEvent( tcx, ep, eq, t, p );
}
}
示例9: flipScanEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
/**
* Scan part of the FlipScan algorithm<br>
* When a triangle pair isn't flippable we will scan for the next
* point that is inside the flip triangle scan area. When found
* we generate a new flipEdgeEvent
*
* @param tcx
* @param ep - last point on the edge we are traversing
* @param eq - first point on the edge we are traversing
* @param flipTriangle - the current triangle sharing the point eq with edge
* @param t
* @param p
*/
private static void flipScanEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle flipTriangle,
DelaunayTriangle t,
TriangulationPoint p )
{
DelaunayTriangle ot;
TriangulationPoint op,newP;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
}
inScanArea = inScanArea( eq,
flipTriangle.pointCCW( eq ),
flipTriangle.pointCW( eq ),
op );
if( inScanArea )
{
// flip with new edge op->eq
flipEdgeEvent( tcx, eq, op, ot, op );
// TODO: Actually I just figured out that it should be possible to
// improve this by getting the next ot and op before the the above
// flip and continue the flipScanEdgeEvent here
// set new ot and op here and loop back to inScanArea test
// also need to set a new flipTriangle first
// Turns out at first glance that this is somewhat complicated
// so it will have to wait.
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, flipTriangle, ot, newP );
}
}
示例10: flipEdgeEvent
import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入方法依赖的package包/类
private static void flipEdgeEvent( DTSweepContext tcx,
TriangulationPoint ep,
TriangulationPoint eq,
DelaunayTriangle t,
TriangulationPoint p )
{
TriangulationPoint op, newP;
DelaunayTriangle ot;
boolean inScanArea;
ot = t.neighborAcross( p );
op = ot.oppositePoint( t, p );
if( ot == null )
{
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
}
if( t.getConstrainedEdgeAcross(p) )
{
throw new RuntimeException( "JAMES IS THE BEST" );
//System.out.println("Intersecting Constraints, if this happens often, tell James");
}
if( tcx.isDebugEnabled() )
{
tcx.getDebugContext().setPrimaryTriangle( t );
tcx.getDebugContext().setSecondaryTriangle( ot );
} // TODO: remove
inScanArea = inScanArea( p,
t.pointCCW( p ),
t.pointCW( p ),
op );
if( inScanArea )
{
// Lets rotate shared edge one vertex CW
rotateTrianglePair( t, p, ot, op );
tcx.mapTriangleToNodes( t );
tcx.mapTriangleToNodes( ot );
if( p == eq && op == ep )
{
if( eq == tcx.edgeEvent.constrainedEdge.q
&& ep == tcx.edgeEvent.constrainedEdge.p)
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - constrained edge done" ); } // TODO: remove
t.markConstrainedEdge( ep, eq );
ot.markConstrainedEdge( ep, eq );
legalize( tcx, t );
legalize( tcx, ot );
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - subedge done" ); } // TODO: remove
// XXX: I think one of the triangles should be legalized here?
}
}
else
{
if( tcx.isDebugEnabled() ) { System.out.println("[FLIP] - flipping and continuing with triangle still crossing edge" ); } // TODO: remove
Orientation o = orient2d( eq, op, ep );
t = nextFlipTriangle( tcx, o, t, ot, p, op );
flipEdgeEvent( tcx, ep, eq, t, p );
}
}
else
{
newP = nextFlipPoint( ep, eq, ot, op );
flipScanEdgeEvent( tcx, ep, eq, t, ot, newP );
edgeEvent( tcx, ep, eq, t, p );
}
}