Strip extra spaces from code.
[voro++.git] / branches / 2d / src / cell_nc_2d.hh
blob1f2d2ad6a9c3e5a709636d47386c21e919b3314f
1 // Voro++, a cell-based Voronoi library
2 //
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
14 #include "cell_2d.hh"
16 namespace voro {
18 class voronoicell_nonconvex_base_2d : public voronoicell_base_2d {
19 public:
20 using voronoicell_base_2d::nplane;
21 bool exclude;
22 bool nonconvex;
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);
33 private:
34 double reg[6];
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 {
39 public:
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) {
44 double rs=x*x+y*y;
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) {
51 double rs=x*x+y*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);
61 private:
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 {
69 public:
70 int *ne;
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) {
77 double rs=x*x+y*y;
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) {
84 double rs=x*x+y*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);
90 private:
91 inline void n_add_memory_vertices() {
92 int *nne=new int[current_vertices],
93 *nee=ne+(current_vertices>>1),
94 *nep=ne,*nnep=nne;
95 while(nep<nee) *(nnep++)=*(nep++);
96 delete [] ne;ne=nne;
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;
104 #endif