1 #ifndef ZEOPP_V_NETWORK_HH
2 #define ZEOPP_V_NETWORK_HH
9 const int init_network_edge_memory
=4;
10 const int init_network_vertex_memory
=64;
11 const int max_network_vertex_memory
=65536;
16 inline void first(double v
,double d
) {e
=v
>0?v
:0;dis
=d
;}
17 inline void add(double v
,double d
) {
19 else if(v
<e
) {e
=v
;dis
=d
;}
21 inline void print(FILE *fp
) {fprintf(fp
," %g %g",e
,dis
);}
24 class voronoi_network
{
36 const double xsp
,ysp
,zsp
;
54 template<class c_class
>
55 voronoi_network(c_class
&c
,double net_tol_
=tolerance
);
57 void print_network(FILE *fp
=stdout
,bool reverse_remove
=false);
58 inline void print_network(const char* filename
,bool reverse_remove
=false) {
59 FILE *fp(safe_fopen(filename
,"w"));
63 void draw_network(FILE *fp
=stdout
);
64 inline void draw_network(const char* filename
) {
65 FILE *fp(safe_fopen(filename
,"w"));
69 template<class v_cell
>
70 inline void add_to_network(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
,int *&cmap
) {
72 add_to_network_internal(c
,idn
,x
,y
,z
,rad
,cmap
);
74 template<class v_cell
>
75 inline void add_to_network_rectangular(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
,int *&cmap
) {
77 add_to_network_rectangular_internal(c
,idn
,x
,y
,z
,rad
,cmap
);
79 template<class v_cell
>
80 inline void add_to_network(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
) {
81 if(c
.p
>map_mem
) add_mapping_memory(c
.p
);
82 add_to_network_internal(c
,idn
,x
,y
,z
,rad
,vmap
);
84 template<class v_cell
>
85 inline void add_to_network_rectangular(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
) {
86 if(c
.p
>map_mem
) add_mapping_memory(c
.p
);
87 add_to_network_rectangular_internal(c
,idn
,x
,y
,z
,rad
,vmap
);
92 inline int step_div(int a
,int b
);
93 inline int step_int(double a
);
94 inline void add_neighbor(int k
,int idn
);
95 void add_particular_vertex_memory(int l
);
96 void add_edge_network_memory();
97 void add_network_memory(int l
);
98 void add_mapping_memory(int pmem
);
99 inline unsigned int pack_periodicity(int i
,int j
,int k
);
100 inline void unpack_periodicity(unsigned int pa
,int &i
,int &j
,int &k
);
101 template<class v_cell
>
102 void add_edges_to_network(v_cell
&c
,double x
,double y
,double z
,double rad
,int *cmap
);
103 int not_already_there(int k
,int j
,unsigned int cper
);
104 bool search_previous(double gx
,double gy
,double x
,double y
,double z
,int &ijk
,int &q
,int &ci
,int &cj
,int &ck
);
105 bool safe_search_previous_rect(double x
,double y
,double z
,int &ijk
,int &q
,int &ci
,int &cj
,int &ck
);
106 bool search_previous_rect(double x
,double y
,double z
,int &ijk
,int &q
,int &ci
,int &cj
,int &ck
);
107 template<class v_cell
>
108 void add_to_network_internal(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
,int *cmap
);
109 template<class v_cell
>
110 void add_to_network_rectangular_internal(v_cell
&c
,int idn
,double x
,double y
,double z
,double rad
,int *cmap
);