-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_vcrop.java
More file actions
90 lines (68 loc) · 2.5 KB
/
Copy pathtest_vcrop.java
File metadata and controls
90 lines (68 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import CGAL.Kernel.Point_2;
import CGAL.Kernel.Iso_rectangle_2;
import CGAL.Voronoi_cropping_2.HalfedgeDS;
import CGAL.Voronoi_cropping_2.HDS_Face_handle;
import CGAL.Voronoi_cropping_2.HDS_Halfedge_handle;
import CGAL.Voronoi_cropping_2.CGAL_Voronoi_cropping_2;
import CGAL.Voronoi_cropping_2.Voronoi_cropping_2;
import java.util.Vector;
public class test_vcrop {
public static void print_info(HalfedgeDS hds)
{
System.out.println("HDS-info "+hds.size_of_vertices()+", "+hds.size_of_halfedges()+", "+hds.size_of_faces());
}
public static void main(String arg[]){
Vector<Point_2> points = new Vector<Point_2>(7);
points.add( new Point_2(0,0) );
points.add( new Point_2(0,1) );
points.add( new Point_2(1,1) );
int[] colors = new int[] {1,1,2};
Iso_rectangle_2 isorect =
new Iso_rectangle_2( new Point_2(-2,-2), new Point_2(2,2) );
HalfedgeDS hds = new HalfedgeDS();
Voronoi_cropping_2 vcrop=new Voronoi_cropping_2();
vcrop.insert(points.iterator(), colors);
vcrop.voronoi_diagram(hds, isorect);
print_info(hds);
CGAL_Voronoi_cropping_2.join_faces(hds);
print_info(hds);
vcrop.voronoi_diagram(hds);
print_info(hds);
CGAL_Voronoi_cropping_2.join_faces(hds);
print_info(hds);
for (HDS_Face_handle fh : hds.faces() )
{
if (fh.color() == 2) fh.set_color(1); //update the color
}
vcrop.insert( new Point_2(1,0), 1);
vcrop.insert( new Point_2(0.5,0.5), 2);
vcrop.voronoi_diagram(hds, isorect);//clear the hds and replace it with a new
CGAL_Voronoi_cropping_2.join_faces(hds);
print_info(hds);
for ( HDS_Face_handle fh : hds.faces() )
{
if ( fh.has_holes() ) System.out.println("Start a new face with holes");
else System.out.println("Start a new face");
System.out.println("Corresponding input point: "+vcrop.get_point(fh.point_index())+"\n");
HDS_Halfedge_handle hedge = fh.halfedge();
HDS_Halfedge_handle first = hedge.clone();
do{
System.out.println("2 "+ hedge.vertex().point() + " 0 " + hedge.opposite().vertex().point() + " 0");
hedge=hedge.next();
}
while(!hedge.equals(first) );
if ( fh.has_holes() )
{
for (HDS_Halfedge_handle hh : fh.holes() )
{
first = hh.clone();
do{
System.out.println("2 "+ hh.vertex().point() + " 0 " + hh.opposite().vertex().point() + " 0");
hh=hh.next();
}
while(!hh.equals(first) );
}
}
}
}
}