本文整理汇总了Java中org.poly2tri.triangulation.delaunay.DelaunayTriangle.index方法的典型用法代码示例。如果您正苦于以下问题:Java DelaunayTriangle.index方法的具体用法?Java DelaunayTriangle.index怎么用?Java DelaunayTriangle.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.poly2tri.triangulation.delaunay.DelaunayTriangle
的用法示例。
在下文中一共展示了DelaunayTriangle.index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}