当前位置: 首页>>代码示例>>Java>>正文


Java DelaunayTriangle类代码示例

本文整理汇总了Java中org.poly2tri.triangulation.delaunay.DelaunayTriangle的典型用法代码示例。如果您正苦于以下问题:Java DelaunayTriangle类的具体用法?Java DelaunayTriangle怎么用?Java DelaunayTriangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DelaunayTriangle类属于org.poly2tri.triangulation.delaunay包,在下文中一共展示了DelaunayTriangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEdgeSideOfTriangle

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
private static boolean isEdgeSideOfTriangle( DelaunayTriangle triangle,
                                             TriangulationPoint ep,
                                             TriangulationPoint eq )
{
    int index;
    index = triangle.edgeIndex( ep, eq );
    if( index != -1 )
    {
        triangle.markConstrainedEdge( index );
        triangle = triangle.neighbors[ index ];
        if( triangle != null )
        {
            triangle.markConstrainedEdge( ep, eq );
        }
        return true;
    }        
    return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:DTSweep.java

示例2: nextFlipPoint

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * When we need to traverse from one triangle to the next we need 
 * the point in current triangle that is the opposite point to the next
 * triangle. 
 * 
 * @param ep
 * @param eq
 * @param ot
 * @param op
 * @return
 */
private static TriangulationPoint nextFlipPoint( TriangulationPoint ep,
                                                 TriangulationPoint eq,
                                                 DelaunayTriangle ot, 
                                                 TriangulationPoint op )
{
    Orientation o2d = orient2d( eq, op, ep );
    if( o2d == Orientation.CW )
    {
        // Right
        return ot.pointCCW( op );
    }
    else if( o2d == Orientation.CCW )
    {
        // Left                
        return ot.pointCW( op );
    }
    else
    {
        // TODO: implement support for point on constraint edge
        throw new PointOnEdgeException("Point on constrained edge not supported yet");
    }                    
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:34,代码来源:DTSweep.java

示例3: nextFlipTriangle

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * After a flip we have two triangles and know that only one will still be
 * intersecting the edge. So decide which to contiune with and legalize the other
 * 
 * @param tcx
 * @param o - should be the result of an orient2d( eq, op, ep )
 * @param t - triangle 1
 * @param ot - triangle 2
 * @param p - a point shared by both triangles 
 * @param op - another point shared by both triangles
 * @return returns the triangle still intersecting the edge
 */
private static DelaunayTriangle nextFlipTriangle( DTSweepContext tcx, 
                                           Orientation o,
                                           DelaunayTriangle  t, 
                                           DelaunayTriangle ot, 
                                           TriangulationPoint p, 
                                           TriangulationPoint op)
{
    int edgeIndex;
    if( o == Orientation.CCW )
    {
        // ot is not crossing edge after flip
        edgeIndex = ot.edgeIndex( p, op );
        ot.dEdge[edgeIndex] = true;
        legalize( tcx, ot );
        ot.clearDelunayEdges();
        return t;
    }
    // t is not crossing edge after flip
    edgeIndex = t.edgeIndex( p, op );
    t.dEdge[edgeIndex] = true;
    legalize( tcx, t );
    t.clearDelunayEdges();            
    return ot;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:DTSweep.java

示例4: fill

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * Adds a triangle to the advancing front to fill a hole.
 * @param tcx
 * @param node - middle node, that is the bottom of the hole
 */
private static void fill( DTSweepContext tcx, AdvancingFrontNode node )
{
    DelaunayTriangle triangle = new DelaunayTriangle( node.prev.point, 
                                                      node.point, 
                                                      node.next.point );
    // TODO: should copy the cEdge value from neighbor triangles
    //       for now cEdge values are copied during the legalize 
    triangle.markNeighbor( node.prev.triangle );
    triangle.markNeighbor( node.triangle );
    tcx.addToList( triangle );

    // Update the advancing front
    node.prev.next = node.next;
    node.next.prev = node.prev;
    tcx.removeNode( node );
    
    // If it was legalized the triangle has already been mapped
    if( !legalize( tcx, triangle ) )
    {
        tcx.mapTriangleToNodes( triangle );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:DTSweep.java

示例5: createAdvancingFront

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
public void createAdvancingFront()
{
    AdvancingFrontNode head,tail,middle;
    // Initial triangle
    DelaunayTriangle iTriangle = new DelaunayTriangle( _points.get(0), 
                                                       getTail(), 
                                                       getHead() );
    addToList( iTriangle );
    
    head = new AdvancingFrontNode( iTriangle.points[1] );
    head.triangle = iTriangle;
    middle = new AdvancingFrontNode( iTriangle.points[0] );
    middle.triangle = iTriangle;
    tail = new AdvancingFrontNode( iTriangle.points[2] );

    aFront = new AdvancingFront( head, tail ); 
    aFront.addNode( middle );
    
    // TODO: I think it would be more intuitive if head is middles next and not previous
    //       so swap head and tail
    aFront.head.next = middle;
    middle.next = aFront.tail;
    middle.prev = aFront.head;
    aFront.tail.prev = middle;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:DTSweepContext.java

示例6: mapTriangleToNodes

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * Try to map a node to all sides of this triangle that don't have 
 * a neighbor.
 * 
 * @param t
 */
public void mapTriangleToNodes( DelaunayTriangle t )
{
    AdvancingFrontNode n;
    for( int i=0; i<3; i++ )
    {
        if( t.neighbors[i] == null )
        {
            n = aFront.locatePoint( t.pointCW( t.points[i] ) );
            if( n != null )
            {
                n.triangle = t;
            }
        }            
    }        
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:DTSweepContext.java

示例7: test3dPoints

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
@Test
public void test3dPoints() {
    List<TriangulationPoint> p = get3DPointsList();
    PointSet pt = get3DPoints(p);
    Set<DelaunayTriangle> expectedTriangles = new HashSet<DelaunayTriangle>();
    expectedTriangles.addAll(Arrays.asList(
            new DelaunayTriangle(p.get(9),p.get(5),p.get(2)),
            new DelaunayTriangle(p.get(2),p.get(5),p.get(6)),
            new DelaunayTriangle(p.get(2),p.get(6),p.get(4)),
            new DelaunayTriangle(p.get(8),p.get(2),p.get(4)),
            new DelaunayTriangle(p.get(8),p.get(4),p.get(3)),
            new DelaunayTriangle(p.get(6),p.get(3),p.get(4)),
            new DelaunayTriangle(p.get(1),p.get(3),p.get(6)),
            new DelaunayTriangle(p.get(1),p.get(7),p.get(3)),
            new DelaunayTriangle(p.get(1),p.get(0),p.get(10)),
            new DelaunayTriangle(p.get(9),p.get(10),p.get(0)),
            new DelaunayTriangle(p.get(5),p.get(9),p.get(0)),
            new DelaunayTriangle(p.get(5),p.get(0),p.get(6)),
            new DelaunayTriangle(p.get(6),p.get(0),p.get(1))
            ));
    Poly2Tri.triangulate(pt);
    assertEquals(expectedTriangles.size(), pt.getTriangles().size());
    for(DelaunayTriangle tri : pt.getTriangles()) {
        assertTrue("Could not find "+tri, expectedTriangles.contains(tri));
    }
}
 
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:27,代码来源:TestDelaunay.java

示例8: toWKT

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * Convert triangles list into wkt form for debugging purpose
 * @param triangles Triangle array
 * @return String WKT
 */
public static String toWKT(List<DelaunayTriangle> triangles) {
    StringBuilder stringBuilder = new StringBuilder("MULTIPOLYGON(");
    AtomicBoolean first = new AtomicBoolean(true);
    for(DelaunayTriangle triangle : triangles) {
        if(!first.getAndSet(false)) {
            stringBuilder.append(",");
        }
        stringBuilder.append("((");
        TriangulationPoint[] pts = triangle.points;
        addPts(stringBuilder, pts);
        // Close linestring
        stringBuilder.append(", ");
        addPts(stringBuilder, pts[0]);
        stringBuilder.append("))");
    }
    stringBuilder.append(")");
    return stringBuilder.toString();
}
 
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:24,代码来源:TestConstrainedDelaunay.java

示例9: updateFaceNormals

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
public static void updateFaceNormals( Mesh mesh,
                                      List<DelaunayTriangle> triangles,
                                      CoordinateTransform pc )
{
    FloatBuffer nBuf;
    Vector3 fNormal;
    HashMap<DelaunayTriangle,Vector3> fnMap;
    int size = 3*3*triangles.size();

    fnMap = calculateFaceNormals( triangles, pc );
    
    prepareNormalBuffer( mesh, size );
    nBuf = mesh.getMeshData().getNormalBuffer();
    nBuf.rewind();        
    for( DelaunayTriangle t : triangles )
    {
        fNormal = fnMap.get( t );
        for( int i=0; i<3; i++ )
        {
            nBuf.put(fNormal.getXf());
            nBuf.put(fNormal.getYf());
            nBuf.put(fNormal.getZf());
        }
    }        
}
 
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:26,代码来源:ArdorMeshMapper.java

示例10: isEdgeSideOfTriangle

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
private static boolean isEdgeSideOfTriangle( DelaunayTriangle triangle,
                                             TriangulationPoint ep,
                                             TriangulationPoint eq )
{
    int index;
    index = triangle.edgeIndex( ep, eq );
    if( index != -1 )
    {
        triangle.markConstrainedEdge( index );
        triangle = triangle.neighbors[ index ];
        if( triangle != null )
        {
            triangle.markConstrainedEdge( ep, eq );
        }
        return true;
    }
    return false;
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:19,代码来源:DTSweep.java

示例11: nextFlipPoint

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * When we need to traverse from one triangle to the next we need
 * the point in current triangle that is the opposite point to the next
 * triangle.
 *
 * @param ep
 * @param eq
 * @param ot
 * @param op
 * @return
 */
private static TriangulationPoint nextFlipPoint( TriangulationPoint ep,
                                                 TriangulationPoint eq,
                                                 DelaunayTriangle ot,
                                                 TriangulationPoint op )
{
    Orientation o2d = orient2d( eq, op, ep );
    if( o2d == Orientation.CW )
    {
        // Right
        return ot.pointCCW( op );
    }
    else if( o2d == Orientation.CCW )
    {
        // Left
        return ot.pointCW( op );
    }
    else
    {
        // TODO: implement support for point on constraint edge
        throw new PointOnEdgeException("Point on constrained edge not supported yet");
    }
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:34,代码来源:DTSweep.java

示例12: nextFlipTriangle

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * After a flip we have two triangles and know that only one will still be
 * intersecting the edge. So decide which to contiune with and legalize the other
 *
 * @param tcx
 * @param o - should be the result of an orient2d( eq, op, ep )
 * @param t - triangle 1
 * @param ot - triangle 2
 * @param p - a point shared by both triangles
 * @param op - another point shared by both triangles
 * @return returns the triangle still intersecting the edge
 */
private static DelaunayTriangle nextFlipTriangle( DTSweepContext tcx,
                                           Orientation o,
                                           DelaunayTriangle  t,
                                           DelaunayTriangle ot,
                                           TriangulationPoint p,
                                           TriangulationPoint op)
{
    int edgeIndex;
    if( o == Orientation.CCW )
    {
        // ot is not crossing edge after flip
        edgeIndex = ot.edgeIndex( p, op );
        ot.dEdge[edgeIndex] = true;
        legalize( tcx, ot );
        ot.clearDelunayEdges();
        return t;
    }
    // t is not crossing edge after flip
    edgeIndex = t.edgeIndex( p, op );
    t.dEdge[edgeIndex] = true;
    legalize( tcx, t );
    t.clearDelunayEdges();
    return ot;
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:37,代码来源:DTSweep.java

示例13: fill

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * Adds a triangle to the advancing front to fill a hole.
 * @param tcx
 * @param node - middle node, that is the bottom of the hole
 */
private static void fill( DTSweepContext tcx, AdvancingFrontNode node )
{
    DelaunayTriangle triangle = new DelaunayTriangle( node.prev.point,
                                                      node.point,
                                                      node.next.point );
    // TODO: should copy the cEdge value from neighbor triangles
    //       for now cEdge values are copied during the legalize
    triangle.markNeighbor( node.prev.triangle );
    triangle.markNeighbor( node.triangle );
    tcx.addToList( triangle );

    // Update the advancing front
    node.prev.next = node.next;
    node.next.prev = node.prev;
    tcx.removeNode( node );

    // If it was legalized the triangle has already been mapped
    if( !legalize( tcx, triangle ) )
    {
        tcx.mapTriangleToNodes( triangle );
    }
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:28,代码来源:DTSweep.java

示例14: createAdvancingFront

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
public void createAdvancingFront()
{
    AdvancingFrontNode head,tail,middle;
    // Initial triangle
    DelaunayTriangle iTriangle = new DelaunayTriangle( _points.get(0),
                                                       getTail(),
                                                       getHead() );
    addToList( iTriangle );

    head = new AdvancingFrontNode( iTriangle.points[1] );
    head.triangle = iTriangle;
    middle = new AdvancingFrontNode( iTriangle.points[0] );
    middle.triangle = iTriangle;
    tail = new AdvancingFrontNode( iTriangle.points[2] );

    aFront = new AdvancingFront( head, tail );
    aFront.addNode( middle );

    // TODO: I think it would be more intuitive if head is middles next and not previous
    //       so swap head and tail
    aFront.head.next = middle;
    middle.next = aFront.tail;
    middle.prev = aFront.head;
    aFront.tail.prev = middle;
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:26,代码来源:DTSweepContext.java

示例15: mapTriangleToNodes

import org.poly2tri.triangulation.delaunay.DelaunayTriangle; //导入依赖的package包/类
/**
 * Try to map a node to all sides of this triangle that don't have
 * a neighbor.
 *
 * @param t
 */
public void mapTriangleToNodes( DelaunayTriangle t )
{
    AdvancingFrontNode n;
    for( int i=0; i<3; i++ )
    {
        if( t.neighbors[i] == null )
        {
            n = aFront.locatePoint( t.pointCW( t.points[i] ) );
            if( n != null )
            {
                n.triangle = t;
            }
        }
    }
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:22,代码来源:DTSweepContext.java


注:本文中的org.poly2tri.triangulation.delaunay.DelaunayTriangle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。