Changeset 31079
- Timestamp:
- Apr 22, 2008, 4:00:37 PM (16 years ago)
- Location:
- grass/trunk/vector/v.voronoi
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/vector/v.voronoi/dt_main.c
r25234 r31079 75 75 G_fatal_error(_("Vector map <%s> not found"), in_opt->answer); 76 76 } 77 77 78 78 Vect_set_open_level (2); 79 79 Vect_open_old (&In, in_opt->answer, mapset); 80 80 81 if (0 > Vect_open_new (&Out, out_opt->answer, 0)) { 82 G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer); 81 /* check if we have a 3D input points map */ 82 mode3d = 0; 83 if ( Vect_is_3d ( &In ) ) { 84 mode3d = 1; 85 } 86 87 88 if ( mode3d ) { 89 if (0 > Vect_open_new (&Out, out_opt->answer, 1)) { 90 G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer); 91 } 92 } else { 93 if (0 > Vect_open_new (&Out, out_opt->answer, 0)) { 94 G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer); 95 } 96 83 97 } 84 98 … … 111 125 G_debug ( 3, "nareas = %d", nareas ); 112 126 for ( area = 1; area <= nareas; area++ ) { 113 double x, y ;127 double x, y, z, angle, slope; 114 128 int ret; 115 129 … … 118 132 119 133 ret = Vect_get_point_in_area ( &Out, area, &x, &y ); 120 121 134 if ( ret < 0 ) { 122 135 G_warning ( _("Cannot calculate area centroid") ); 123 136 continue; 124 137 } 138 139 ret = Vect_tin_get_z (&Out, x, y, &z, &angle, &slope); 140 G_debug(3, "area centroid z: %f",z); 141 if ( ret < 0 ) { 142 G_warning ( _("Cannot calculate area centroid z coordinate") ); 143 continue; 144 } 125 145 126 Vect_append_point ( Points, x, y, 0.0);146 Vect_append_point ( Points, x, y, z ); 127 147 Vect_cat_set ( Cats, 1, area ); 128 148 -
grass/trunk/vector/v.voronoi/dt_write.c
r18934 r31079 47 47 int j, nlines; 48 48 int found = 0; 49 double x, y ;49 double x, y, z; 50 50 51 51 nlines = Vect_get_node_n_lines ( &Out, node ); … … 61 61 Vect_get_line_nodes ( &Out, abs(line), &node2, NULL ); 62 62 63 Vect_get_node_coor ( &Out, node2, &x, &y, NULL);63 Vect_get_node_coor ( &Out, node2, &x, &y, &z ); 64 64 65 65 if ( x == sb->coord.x && y == sb->coord.y ) { … … 74 74 /* Not found, write it */ 75 75 Vect_reset_line ( Points ); 76 Vect_append_point ( Points, sa->coord.x, sa->coord.y, 0.0 ); 77 Vect_append_point ( Points, sb->coord.x, sb->coord.y, 0.0 ); 76 if ( mode3d ) { 77 G_debug(3, "sa->coord.z: %f", sa->coord.z ); 78 Vect_append_point ( Points, sa->coord.x, sa->coord.y, sa->coord.z ); 79 Vect_append_point ( Points, sb->coord.x, sb->coord.y, sb->coord.z ); 80 } else { 81 Vect_append_point ( Points, sa->coord.x, sa->coord.y, 0.0 ); 82 Vect_append_point ( Points, sb->coord.x, sb->coord.y, 0.0 ); 83 } 78 84 Vect_write_line ( &Out, Type, Points, Cats ); 79 85 } … … 82 88 return 0; 83 89 } 90 -
grass/trunk/vector/v.voronoi/sw_defs.h
r13251 r31079 14 14 15 15 struct Point { 16 double x,y ;16 double x,y,z; 17 17 }; 18 18 … … 42 42 43 43 #ifdef MAIN 44 int triangulate, sorted, plot, debug ;44 int triangulate, sorted, plot, debug, mode3d; 45 45 struct Site *sites; 46 46 int nsites; … … 62 62 int PQmin; 63 63 #else 64 extern int triangulate, sorted, plot, debug ;64 extern int triangulate, sorted, plot, debug, mode3d; 65 65 extern struct Site *sites; 66 66 extern int nsites; -
grass/trunk/vector/v.voronoi/sw_main.c
r25234 r31079 43 43 foundDupe = 0; 44 44 while(i < nsites) 45 if(sites[i].coord.x == sites[i-1].coord.x && sites[i].coord.y == sites[i-1].coord.y) 46 i++; 47 else 48 { 49 if(i != j) sites[j] = sites[i]; 50 i++; j++;; 45 if ( mode3d ) { 46 if(sites[i].coord.x == sites[i-1].coord.x && sites[i].coord.y == sites[i-1].coord.y 47 && sites[i].coord.z == sites[i-1].coord.z) 48 i++; 49 else 50 { 51 if(i != j) sites[j] = sites[i]; 52 i++; j++;; 53 } 54 } else { 55 if(sites[i].coord.x == sites[i-1].coord.x && sites[i].coord.y == sites[i-1].coord.y) 56 i++; 57 else 58 { 59 if(i != j) sites[j] = sites[i]; 60 i++; j++;; 61 } 51 62 } 52 63 … … 68 79 Points = Vect_new_line_struct (); 69 80 81 nlines = Vect_get_num_lines ( &In ); 82 70 83 nsites = 0; 71 sites = (struct Site *) myalloc(4000*sizeof(*sites)); 72 73 nlines = Vect_get_num_lines ( &In ); 84 sites = (struct Site *) myalloc(nlines * sizeof(*sites)); 74 85 75 86 for ( line = 1; line <= nlines; line++ ) { … … 85 96 sites[nsites].coord.x = Points->x[0]; 86 97 sites[nsites].coord.y = Points->y[0]; 98 if ( mode3d ) { 99 G_debug(3, "Points->z[0]: %f", Points->z[0]); 100 sites[nsites].coord.z = Points->z[0]; 101 } 87 102 88 103 sites[nsites].sitenbr = nsites; -
grass/trunk/vector/v.voronoi/vo_main.c
r25234 r31079 322 322 IFi->key, OFi->database, OFi->driver); 323 323 } 324 G_done_msg(" ");324 G_done_msg(" "); 325 325 } 326 326 }
Note:
See TracChangeset
for help on using the changeset viewer.
