1 // Voro++, a cell-based Voronoi library
3 // Authors : Chris H. Rycroft (LBL / UC Berkeley)
4 // Cody Robert Dance (UC Berkeley)
5 // Email : chr@alum.mit.edu
6 // Date : August 30th 2011
8 /** \file cell_nc_2d.hh
9 * \brief Header file for the non-convex 2D Voronoi classes. */
11 #ifndef VORO_CELL_NC_2D_HH
12 #define VORO_CELL_NC_2D_HH
18 class voronoicell_nonconvex_base_2d
: public voronoicell_base_2d
{
20 using voronoicell_base_2d::nplane
;
23 template<class vc_class
>
24 inline bool nplane_base(vc_class
&vc
,double x
,double y
,double rs
,int p_id
) {
25 return exclude
?(nonconvex
?
26 (-x
*reg
[3]+y
*reg
[2]<-tolerance
&&x
*reg
[5]-y
*reg
[4]<-tolerance
)||nplane_nonconvex(vc
,x
,y
,rs
,p_id
):
27 -x
*reg
[3]+y
*reg
[2]<-tolerance
||x
*reg
[5]-y
*reg
[4]<-tolerance
||nplane(vc
,x
,y
,rs
,p_id
)):
28 nplane(vc
,x
,y
,rs
,p_id
);
30 template<class vc_class
>
31 bool nplane_nonconvex(vc_class
&vc
,double x
,double y
,double rs
,int p_id
);
32 void init_nonconvex_base(double xmin
,double xmax
,double ymin
,double ymax
,double wx0
,double wy0
,double wx1
,double wy1
);
35 inline int face(double xmin
,double xmax
,double ymin
,double ymax
,double &wx
,double &wy
);
38 class voronoicell_nonconvex_2d
: public voronoicell_nonconvex_base_2d
{
40 inline bool nplane(double x
,double y
,double rs
,int p_id
) {
41 return nplane_base(*this,x
,y
,rs
,0);
43 inline bool nplane(double x
,double y
,int p_id
) {
45 return nplane(x
,y
,rs
,0);
47 inline bool plane(double x
,double y
,double rs
) {
48 return nplane(x
,y
,rs
,0);
50 inline bool plane(double x
,double y
) {
52 return nplane(x
,y
,rs
,0);
54 inline void init(double xmin
,double xmax
,double ymin
,double ymax
) {
55 nonconvex
=exclude
=false;
56 init_base(xmin
,xmax
,ymin
,ymax
);
58 inline void init_nonconvex(double xmin
,double xmax
,double ymin
,double ymax
,double wx0
,double wy0
,double wx1
,double wy1
) {
59 init_nonconvex_base(xmin
,xmax
,ymin
,ymax
,wx0
,wy0
,wx1
,wy1
);
62 inline void n_add_memory_vertices() {}
63 inline void n_copy(int a
,int b
) {}
64 inline void n_set(int a
,int id
) {}
65 friend class voronoicell_base_2d
;
68 class voronoicell_nonconvex_neighbor_2d
: public voronoicell_nonconvex_base_2d
{
71 voronoicell_nonconvex_neighbor_2d() : ne(new int[init_vertices
]) {}
72 ~voronoicell_nonconvex_neighbor_2d() {delete [] ne
;}
73 inline bool nplane(double x
,double y
,double rs
,int p_id
) {
74 return nplane_base(*this,x
,y
,rs
,p_id
);
76 inline bool nplane(double x
,double y
,int p_id
) {
78 return nplane(x
,y
,rs
,p_id
);
80 inline bool plane(double x
,double y
,double rs
) {
81 return nplane(x
,y
,rs
,0);
83 inline bool plane(double x
,double y
) {
85 return nplane(x
,y
,rs
,0);
87 void init(double xmin
,double xmax
,double ymin
,double ymax
);
88 void init_nonconvex(double xmin
,double xmax
,double ymin
,double ymax
,double wx0
,double wy0
,double wx1
,double wy1
);
89 virtual void neighbors(vector
<int> &v
);
91 inline void n_add_memory_vertices() {
92 int *nne
=new int[current_vertices
],
93 *nee
=ne
+(current_vertices
>>1),
95 while(nep
<nee
) *(nnep
++)=*(nep
++);
98 inline void n_copy(int a
,int b
) {ne
[a
]=ne
[b
];}
99 inline void n_set(int a
,int id
) {ne
[a
]=id
;}
100 friend class voronoicell_base_2d
;