Geotools三角剖分,用到了图的数据结构,蛮强大的,坑爹的是源码里面居然有System.out.println()代码,不过总体功能是有的。
/**
* delary三角网
*/
static public void delaury(){
List<DelaunayNode> nodes = new ArrayList<DelaunayNode>();
for(int i=0;i<200;i++){
Coordinate coord = new Coordinate(Math.random()*100,Math.random()*100);
DelaunayNode xyNode = new DelaunayNode();
xyNode.setCoordinate(coord);
nodes.add(xyNode);
}
List<Edge> edges = new ArrayList<Edge>();
DelaunayEdge edge = new DelaunayEdge(nodes.get(0),nodes.get(1));
edges.add(edge);
BasicGraph basicGraph = new BasicGraph();
basicGraph.setNodes(nodes);
basicGraph.setEdges(edges);
DelaunayTriangulator delaunayTriangulator = new DelaunayTriangulator();
DelaunayNode[] delaunayNodes = new DelaunayNode[nodes.size()];
System.out.println(nodes.toArray(delaunayNodes));
delaunayTriangulator.setNodeArray(nodes.toArray(delaunayNodes));
//构建三角网
//delaunayTriangulator.getTriangulation();
GraphViewer gpViewer = new GraphViewer();
gpViewer.setGraph(delaunayTriangulator.getTriangulation());
gpViewer.setSize(500,500);
gpViewer.setVisible(true);
JFrame jFrame = new JFrame();
jFrame.add(gpViewer);
//jFrame.add(new JButton("dd"));
//jFrame.setSize(500,500);
jFrame.setVisible(true);
}