Beispiel #1
0
static void CALLBACK combineCallback(GLdouble coords[3],
			      GLdouble *vertex_data[4],
			      GLfloat weight[4],
			      GLdouble **data)
{
  *data = new_vertex(coords[0],coords[1],coords[2]);
}
Beispiel #2
0
static void runTesselator(value contours)
{
  CAMLparam1(contours);

  gluTessBeginPolygon(tobj, NULL);
  while (contours != Val_int(0)) {
    value contour=Field(contours, 0);
    gluTessBeginContour(tobj);
    while (contour != Val_int(0)) {
      value v=Field(contour, 0);
      GLdouble *r =
        new_vertex(Double_val(Field(v, 0)),
                   Double_val(Field(v, 1)),
                   Double_val(Field(v, 2)));
      gluTessVertex(tobj, r, (void *)r);
      contour = Field(contour, 1);
    }
    contours = Field(contours, 1);
    gluTessEndContour(tobj);
  }
  gluTessEndPolygon(tobj);

  gluDeleteTess(tobj);
  tobj = NULL;
  free_chunks();
  CAMLreturn0;
}
Beispiel #3
0
// add a new vertex with label 'name' to a graph
void graph_add_vertex(Graph* graph, const char* name) {
	if (graph->n < graph->maxn) {
		graph->vertices[graph->n] = new_vertex(name);	
		graph->n++;
	} else {
		fprintf(stderr, "hey! adding new vertex to full graph\n");
	}
}
Beispiel #4
0
Surface_mesh::Vertex
Surface_mesh::
add_vertex(const Point& p)
{
    Vertex v = new_vertex();
    vpoint_[v] = p;
    return v;
}
Beispiel #5
0
void combine(const GLdouble newVertex[3],
             const void *neighborVertex_s[4],
             const GLfloat neighborWeight[4], void **outData, void *polyData)
{
    struct TessContext_s *ctx = (struct TessContext_s *)polyData;
    struct Vertex_s *result = new_vertex(ctx, newVertex[0], newVertex[1]);
    *outData = result;
}
Beispiel #6
0
Graph *add_vertex(Graph *gr, data pyld) {
    /* Reallocate the vertices array to contain one more Vertex */
    gr->vertices = (Vertex **) realloc(gr->vertices,
            (gr->size + 1) * sizeof(Vertex *));

    /* Create the new Vertex and bump the Graph's size */
    gr->vertices[gr->size] = new_vertex(pyld);
    gr->vertices[gr->size]->label = gr->size;
    gr->size = gr->size + 1;
    return gr;
}
Beispiel #7
0
void to_revolution()
{
  init_geometry();
  shape_t *s = new_shape();
  for(unsigned i = 0; i < numpoints; ++i) {
    add_vertex(s, new_vertex(pt[i].x, WINDOW_HEIGHT-pt[i].y, 0));
  }
  new_revolution(s, DIVISION_NUMBER);
  flushOBJ(file_out);
  finalize_geometry();
}
Beispiel #8
0
/* A Graph is an array of EdgeNodes */
Graph *new_graph(uint32_t sz) {
    int i;

    Graph *gr = (Graph *) malloc(sizeof(Graph));
    gr->size = sz;
    gr->vertices = (Vertex **) malloc(sz * sizeof(Vertex *));

    for (i = 0; i < sz; i++) {
        gr->vertices[i] = new_vertex(NULL);
        gr->vertices[i]->label = i;
    }

    return gr;
}
Beispiel #9
0
int main()
{
  init_geometry();
  shape_t *s = new_shape();
  add_vertex(s, new_vertex(0, 300, 0));
  add_vertex(s, new_vertex(20, 300, 0));
  add_vertex(s, new_vertex(20, 290, 0));
  add_vertex(s, new_vertex(300, 220, 0));
  add_vertex(s, new_vertex(295, 218, 0));
  add_vertex(s, new_vertex(60, 260, 0));
  add_vertex(s, new_vertex(5, 220, 0));
  add_vertex(s, new_vertex(5, 0, 0));
  add_vertex(s, new_vertex(0, 0, 0));
  shape_t *u = new_revolution(s, 60);
  flushOBJ(stdout);
  free_shape(s);
  free_shape(u);
  finalize_geometry();
  return 0;
}
Beispiel #10
0
Datei: gif_c.c Projekt: cran/gap
vertex *find_vertex(int i)
{
  vertex  **vv;

  for (vv = &(binary_tree); *vv && (*vv)->id != i; )
  {
    vv = (i < (*vv)->id ? &((*vv)->right) : &((*vv)->left) );
  }
  if (!(*vv))
  {
    *vv = new_vertex();
    (*vv)->id = i;
  }
  return(*vv);
}
Beispiel #11
0
Graph *new_graph(int V, Vertex *vertex_list[]) {
  int i = 0;
  Graph *G = (Graph *) malloc(sizeof(Graph));
  G->V = V;
  G->E = 0;
  G->adj_list = (Vertex **) calloc(V + 1, sizeof(Vertex *));
  G->edge_list = (int (*)[2]) calloc(1, sizeof *(G->edge_list));
  G->edge_pair = (int (*)[2]) calloc(1, sizeof *(G->edge_pair));
  for (i = 0; i < G->V; i++) {//Make the adjacency list sorted by the label
    G->adj_list[vertex_list[i]->label] = vertex_list[i];
  }
  G->adj_list[0] = new_vertex(0);
  memset(G->edge_list, 0, sizeof *(G->edge_list));
  memset(G->edge_pair, 0, sizeof *(G->edge_pair));
  return G;
}
Beispiel #12
0
Graph *read_graph(FILE *fp) {
  int number, count = 0;
  Vertex **vlist = NULL;
  while (fscanf(fp, " %d ->", &number) > 0) {
    int label;
    int weight;
    int direction;

    count += 1;
    vlist = realloc(vlist, count * sizeof *vlist);
    Vertex *curVertex = new_vertex(number);
    vlist[count - 1] = curVertex;
    while (fscanf(fp, " [%d %d %d]", &label, &weight, &direction) > 0) {
      add_adjacency_vertex_with_direction(curVertex, label,
                                          weight, direction);
    }
  }
  return new_graph(count, vlist);
}
Beispiel #13
0
Datei: modeling.c Projekt: foo/ii
void open_menu(int id)
{
  switch(id)
  {
    case 1:
      new_curve(mouse_x, mouse_y);
      break;
    case 2:
      new_vertex(mouse_x, mouse_y);
      break;
    case 3:
      erase_vertex(active_ncs, active_pt);
      break;
    case 4:
      new_cycloide(mouse_x, mouse_y);
      break;
    case 5:
      new_spiral(mouse_x, mouse_y);
      break;
  }
}
Beispiel #14
0
int simple_tent (struct face *given_face, int troid)
{
	double center[3];
	struct cycle *cyc;
	struct vertex *vtx0;
	struct surface *this_srf;

	this_srf = given_face -> srf;
	if (this_srf == NULL) return (0);

	cyc = given_face -> first_cycle;
	if (cyc == NULL)  {
		set_error1 ("(simple_tent): face has no boundary");
		return (0);
	}
	if (cyc -> next != NULL) {
		set_error1 ("(simple_tent): > 1 cycle");
		return (0);
	}
	if (!troid && given_face -> shape == CONVEX) {
		if (!face_center (given_face, center)) {
			if (!fac_centroid (given_face, center)) return (0);
		}
	}
	else {
		if (!fac_centroid (given_face, center)) return (0);
	}
	if (error()) return (0);


	vtx0 = new_vertex (center, NULL, NULL, (struct arc *) NULL, given_face);
	if (error()) return (0);
	link_vertex (this_srf, vtx0);

	if (!tent (given_face, vtx0)) return (0);
	if (error()) return (0);
	return (1);
}
Beispiel #15
0
void tessellate
    (double **verts,
     int *nverts,
     int **tris,
     int *ntris,
     const double **contoursbegin, 
     const double **contoursend)
{
    const double *contourbegin, *contourend;
    struct Vertex_s *current_vertex;
    GLUtesselator *tess;
    struct TessContext_s *ctx;

    tess = gluNewTess();
    ctx = new_tess_context();
    gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
    gluTessCallback(tess, GLU_TESS_VERTEX_DATA,  (GLvoid (*) ()) &vertex);
    gluTessCallback(tess, GLU_TESS_BEGIN_DATA,   (GLvoid (*) ()) &begin);
    gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (GLvoid (*) ()) &combine);

    gluTessBeginPolygon(tess, ctx);
    do {
        contourbegin = *contoursbegin++;
        contourend = *contoursbegin;
        gluTessBeginContour(tess);
        while (contourbegin != contourend) {
            current_vertex = new_vertex(ctx, contourbegin[0], contourbegin[1]);
            contourbegin += 2;
            gluTessVertex(tess, current_vertex->pt, current_vertex);
        }
        gluTessEndContour(tess);
    } while (contoursbegin != (contoursend - 1));
    gluTessEndPolygon(tess);

    write_output(ctx, verts, tris, nverts, ntris);
    destroy_tess_context(ctx);
    gluDeleteTess(tess);
}
bool LabelToolPlugin::visualizeImgWithSelectionCb(label_tool_msgs::ImagesWithSelection::Request &req,
                                                  label_tool_msgs::ImagesWithSelection::Response &res)
{
  reset();

  // copy data on class structure
  for(auto &img_with_poly : req.images)
  {
    // convert to opencv mat
    cv_bridge::CvImagePtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvCopy(img_with_poly.image, img_with_poly.image.encoding);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return false;
    }


    std::vector<cv::Point> polygon_edges;
    for(auto &point : img_with_poly.polygon_edges)
    {
      cv::Point new_vertex(point.x, point.y);
      polygon_edges.push_back(new_vertex);
    }

    ImgWithPolygon img_with_poly_class;
    img_with_poly_class.img_ = cv_ptr->image;
    img_with_poly_class.polygon_edges_ = polygon_edges;
    img_with_polygons_.push_back(img_with_poly_class);
  }

  emit dataAvailable();
  return true;
}
Beispiel #17
0
int multiple_tent (struct face *given_face)
{
	double center[3];
	struct cycle *cyc;
	struct vertex *vtx0;
	struct surface *this_srf;

	this_srf = given_face -> srf;
	if (this_srf == NULL) return (0);

	cyc = given_face -> first_cycle;
	if (cyc == NULL)  {
		set_error1 ("(multiple_tent): face has no boundary");
		return (0);
	}
	if (!fac_centroid (given_face, center)) return (0);
	if (error()) return (0);
	vtx0 = new_vertex (center, NULL, NULL, (struct arc *) NULL, given_face);
	if (error()) return (0);
	link_vertex (this_srf, vtx0);
	if (!tent (given_face, vtx0)) return (0);
	if (error()) return (0);
	return (1);
}
Beispiel #18
0
vertex_id copy_vertex(const vertex_id v)
{
  if(!is_valid_id(v)) return ERROR_VERTEX;
  return new_vertex(vertices[v].x, vertices[v].y, vertices[v].z);
}
Beispiel #19
0
/*
	D is the degree for every vertex
	V is the total number of vertices
	generate a random graph with V vertices, and every vertex has exact degree of D
*/
Graph *gen(int D, int V) {
  Vertex
      *(*sets)[V] = (Vertex *(*)[V]) calloc(3, sizeof *sets),
      *v1 = NULL, *v2 = NULL;
  int dgr[3] = {-1, 0, 1}, len[3] = {0, 0, 0}, min_index, new_index, i;
  if (D > V - 1) {
    perror("No such graph: total degree should be less than of equal to "
               "2 x maximal number of edge");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < V; i++) {
    sets[1][i] = new_vertex(i + 1);
  }
  len[1] = V;
  min_index = 1;
  while (len[0] < V - 1) {
    int v = rand() % (V - len[0]), l, pl;
    if (v / len[min_index] == 0) {
      v1 = sets[min_index][v];
      memmove(sets[min_index] + v, sets[min_index] + v + 1,
              (len[min_index] - v - 1) * sizeof(Vertex *));
      len[min_index] -= 1;//pop (v)
      if (len[min_index] == 0) {
        min_index = !(min_index - 1) + 1;
      }
    } else {
      new_index = !(min_index - 1) + 1;
      v -= len[min_index];
      v1 = sets[new_index][v];
      memmove(sets[new_index] + v, sets[new_index] + v + 1,
              (len[new_index] - v - 1) * sizeof(Vertex *));
      len[new_index] -= 1;//pop (v)
    }
    l = D - v1->degree;
    pl = 0;//Pop length
    while (l > 0 && dgr[min_index] < D) {
      int untouched_len = len[min_index] - pl, weight;
      new_index = !(min_index - 1) + 1;
      if (l < untouched_len) {
        for (i = 0; i < l; i++) {
          v = rand() % (len[min_index] - pl);
          v2 = sets[min_index][v];
          memmove(sets[min_index] + v, sets[min_index] + v + 1,
                  (len[min_index] - v - 1) * sizeof(Vertex *));
          len[min_index] -= 1;
          weight = getRandTo(MAX_EDGE_WEIGHT);
          int direction = rand() % 2;
          add_adjacency_vertex_with_direction(v2, v1->label, weight,
                                              direction);
          add_adjacency_vertex_with_direction(v1, v2->label, weight,
                                              !direction);
          if (v2->degree == D) {
            sets[0][len[0]] = v2;
            len[0] += 1;
          } else {
            sets[new_index][len[new_index]] = v2;
            len[new_index] += 1;
          }
        }
        dgr[new_index] = dgr[min_index] + 1;
        l = 0;
      } else {
        for (i = 0; i < untouched_len; i++) {
          v = rand() % (len[min_index] - pl);
          v2 = sets[min_index][v];
          memmove(sets[min_index] + v, sets[min_index] + v + 1,
                  (len[min_index] - v - 1) * sizeof(Vertex *));
          len[min_index] -= 1;//pop(v)
          weight = getRandTo(MAX_EDGE_WEIGHT);
          int direction = rand() % 2;
          add_adjacency_vertex_with_direction(v2, v1->label, weight,
                                              direction);
          add_adjacency_vertex_with_direction(v1, v2->label, weight,
                                              !direction);
          if (v2->degree == D) {
            sets[0][len[0]] = v2;
            len[0] += 1;
          } else {
            sets[new_index][len[new_index]] = v2;
            len[new_index] += 1;
          }
        }
        l -= untouched_len;
        pl = untouched_len;
        dgr[new_index] = dgr[min_index] + 1;
        min_index = new_index;
      }
    }
    sets[0][len[0]] = v1;
    len[0] += 1;
  }
  if (len[0] == V) {
    Graph *G = new_graph(V, sets[0]);
    free(sets);
    return G;
  } else {
    Graph *G;
    perror("No such graph: Returned graph has a vertex with degree "
               "less than min_index");
    sets[0][len[0]] = sets[min_index][0];
    G = new_graph(V, sets[0]);
    free(sets);
    return G;
  }
}
Beispiel #20
0
/* new concave face */
void new_concave_face (struct surface *this_srf, struct probe *prb)
{
    int k;
    double probe_center[3];
	double vertex1_coor[3], vertex2_coor[3], vertex3_coor[3], vertex4_coor[3];
	double circle1_axis[3], circle2_axis[3], circle3_axis[3], circle4_axis[3];
	struct circle *circle1, *circle2, *circle3, *circle4;
	struct vertex *vertex1, *vertex2, *vertex3, *vertex4;
	struct arc *arc1, *arc2, *arc3, *arc4;
    struct sphere *atom1, *atom2, *atom3, *atom4;
	struct face *concave_fac;
    struct pair *torus1, *torus2, *torus3, *torus4;
	double dot1, dot2, dot3, dot4;
	char message[MAX_STRING];
    struct cept *ex;

	if (prb -> natom > 3) {
		sprintf (message, "%8ld probe square concave face", prb -> number);
		informd (message);
	}
	else {
		sprintf (message, "%8ld probe triangular concave face", prb -> number);
		informd2 (message);
	}
    atom1 = prb -> atm[0];
    atom2 = prb -> atm[1];
    atom3 = prb -> atm[2];
    atom4 = prb -> atm[3];
    torus1 = prb -> pairs[0];
    torus2 = prb -> pairs[1];
    torus3 = prb -> pairs[2];
    torus4 = prb -> pairs[3];
    for (k = 0; k < 3; k++)
		probe_center[k] = prb -> center[k];

	/* compute vertex coordinates */
	for (k = 0; k < 3; k++) {
		vertex1_coor[k] = (atom1 -> radius * probe_center[k] +
			this_srf -> probe_radius * atom1 -> center[k]) /
			(atom1 -> radius + this_srf -> probe_radius);
		vertex2_coor[k] = (atom2 -> radius * probe_center[k] +
			this_srf -> probe_radius * atom2 -> center[k]) /
			(atom2 -> radius + this_srf -> probe_radius);
		vertex3_coor[k] = (atom3 -> radius * probe_center[k] +
			this_srf -> probe_radius * atom3 -> center[k]) /
				(atom3 -> radius + this_srf -> probe_radius);
		if (atom4 != NULL) {
			vertex4_coor[k] = (atom4 -> radius * probe_center[k] +
				this_srf -> probe_radius * atom4 -> center[k]) /
					(atom4 -> radius + this_srf -> probe_radius);
		}
	}

	/* set up vertices */
	vertex1 = new_vertex (vertex1_coor, (struct sphere *) atom1, prb, NULL, NULL);
	if (vertex1 == NULL) return;
	link_vertex (this_srf, vertex1);
	vertex2 = new_vertex (vertex2_coor, (struct sphere *) atom2, prb, NULL, NULL);
	if (vertex2 == NULL) return;
	link_vertex (this_srf, vertex2);
	vertex3 = new_vertex (vertex3_coor, (struct sphere *) atom3, prb, NULL, NULL);
	if (vertex3 == NULL) return;
	link_vertex (this_srf, vertex3);
	if (atom4 != NULL) {
		vertex4 = new_vertex (vertex4_coor, (struct sphere *) atom4, prb, NULL, NULL);
		if (vertex4 == NULL) return;
		link_vertex (this_srf, vertex4);
	}
	else vertex4 = NULL;

	/* calculate axes and set up circles */
	setup_axis (probe_center, prb -> atm[0] -> center,
		prb -> atm[1] -> center, circle1_axis);
	setup_axis (probe_center, prb -> atm[1] -> center,
		prb -> atm[2] -> center, circle2_axis);
	if (atom4 == NULL) {
		setup_axis (probe_center, prb -> atm[2] -> center,
			prb -> atm[0] -> center, circle3_axis);
	}
	else if (atom4 != NULL) {
		setup_axis (probe_center, prb -> atm[2] -> center,
			prb -> atm[3] -> center, circle3_axis);
		setup_axis (probe_center, prb -> atm[3] -> center,
			prb -> atm[0] -> center, circle4_axis);
	}

	circle1 = new_circle (probe_center, this_srf -> probe_radius, circle1_axis);
	if (circle1 == NULL) return;
	link_circle (this_srf, circle1);
	circle1 -> theta = 0.0;
	circle1 -> subtype = GREAT_SUBTYPE;
	circle2 = new_circle (probe_center, this_srf -> probe_radius, circle2_axis);
	if (circle2 == NULL) return;
	link_circle (this_srf, circle2);
	circle2 -> theta = 0.0;
	circle2 -> subtype = GREAT_SUBTYPE;
	circle3 = new_circle (probe_center, this_srf -> probe_radius, circle3_axis);
	if (circle3 == NULL) return;
	link_circle (this_srf, circle3);
	circle3 -> theta = 0.0;
	circle3 -> subtype = GREAT_SUBTYPE;
	if (atom4 != NULL) {
		circle4 = new_circle (probe_center, this_srf -> probe_radius, circle4_axis);
		if (circle4 == NULL) return;
		link_circle (this_srf, circle4);
		circle4 -> theta = 0.0;
		circle4 -> subtype = GREAT_SUBTYPE;
	}
	else circle4 = NULL;

	/* set up arcs */
	arc1 = new_arc (circle1, vertex1, vertex2, CONCAVE, 0, (double) 0.0, 0L, 0L, 0L);
	if (arc1 == NULL) return;
	this_srf -> n_arc++;
	arc2 = new_arc (circle2, vertex2, vertex3, CONCAVE, 0, (double) 0.0, 0L, 0L, 0L);
	if (arc2 == NULL) return;
	this_srf -> n_arc++;
	if (circle4 == NULL) {
		arc3 = new_arc (circle3, vertex3, vertex1, CONCAVE, 0, (double) 0.0, 0L, 0L, 0L);
		if (arc3 == NULL) return;
		this_srf -> n_arc++;
		arc4 = NULL;
	}
	else if (circle4 != NULL) {
		arc3 = new_arc (circle3, vertex3, vertex4, CONCAVE, 0, (double) 0.0, 0L, 0L, 0L);
		if (arc3 == NULL) return;
		this_srf -> n_arc++;
		arc4 = new_arc (circle4, vertex4, vertex1, CONCAVE, 0, (double) 0.0, 0L, 0L, 0L);
		if (arc4 == NULL) return;
		this_srf -> n_arc++;
	}

	/* add arcs to tori */
	arc1 -> next = torus1 -> first_arc;
	torus1 -> first_arc = arc1;
	sprintf (message, "%8ld %8ld torus: add arc", 
		torus1 -> sph[0] -> number, torus1 -> sph[1] -> number);
	informd2(message);
	arc2 -> next = torus2 -> first_arc;
	torus2 -> first_arc = arc2;
	sprintf (message, "%8ld %8ld torus: add arc", 
		torus2 -> sph[0] -> number, torus2 -> sph[1] -> number);
	informd2(message);
	arc3 -> next = torus3 -> first_arc;
	torus3 -> first_arc = arc3;
	sprintf (message, "%8ld %8ld torus: add arc", 
		torus3 -> sph[0] -> number, torus3 -> sph[1] -> number);
	informd2(message);
	if (torus4 != NULL) {
		arc4 -> next = torus4 -> first_arc;
		torus4 -> first_arc = arc4;
		sprintf (message, "%8ld %8ld torus: add arc", 
			torus4 -> sph[0] -> number, torus4 -> sph[1] -> number);
		informd(message);
	}

	/* new concave face */
	concave_fac = new_face (NULL, CONCAVE);
	if (concave_fac == NULL) return;
	concave_fac -> ptr.prb = prb;
	concave_fac -> chi = 1;
	link_face (this_srf, concave_fac);
	add2face (concave_fac, arc1, arc2, arc3, arc4);

	/* back pointer for cusp corrections */
	prb -> fac = concave_fac;
	arc1 -> fac = concave_fac;
	arc2 -> fac = concave_fac;
	arc3 -> fac = concave_fac;
	if (arc4 != NULL) {
		arc4 -> fac = concave_fac;
	}
}
Beispiel #21
0
inline vertex_t new_vertex(GLfloat x, GLfloat y, GLfloat z)
{
  return new_vertex(glm::vec4(x, y, z, 1.f));
}
Beispiel #22
0
inline vertex_t new_vertex(const glm::vec4 &pos)
{
  vertex_t v = new_vertex();
  v.position = pos;
  return v;
}
PointSet::Vertex* PointSet::new_vertex(const vec3& p) {
	Vertex* result = new_vertex() ;
	result->set_point(p) ;
	return result ;
}
Beispiel #24
0
inline vertex_t new_vertex(GLfloat x, GLfloat y, GLfloat z, const glm::mat4 &m)
{
  return new_vertex(m * glm::vec4(x, y, z, 1.f));
}
static void read_xyz (BINARYIO *bf)
{
    int i, k, n, nk, nz, np, nmax;
    int *indices, *iblank;
    void *xyz;
    VERTEX *verts;

    /* get number of grid blocks */

    if (mblock) {
        bf_getints (bf, 1, &nZones);
        if (nZones < 1 || nZones > 100000) {
            fprintf (stderr, "found %d blocks\n", nZones);
            fprintf (stderr, "file type and/or format is probably incorrect\n");
            bf_close (bf);
            exit (1);
        }
    }
    else
        nZones = 1;
    printf ("reading %d grid blocks\n", nZones);

    /* read indices for grids */

    indices = (int *) malloc (3 * nZones * sizeof(int));
    if (NULL == indices)
        FATAL ("read_xyz", "malloc failed for grid indices");
    bf_getints (bf, 3 * nZones, indices);

    /* create zone structures */

    Zones = new_zone (nZones);
    for (nmax = 0, nz = 0; nz < nZones; nz++) {
        Zones[nz].type = CGNS_ENUMV(Structured);
        for (np = 1, n = 0; n < 3; n++) {
            nk = indices[3 * nz + n];
            Zones[nz].dim[n] = nk;
            np *= nk;
        }
        Zones[nz].vertflags = 7;
        Zones[nz].datatype = is_double ? CGNS_ENUMV(RealDouble) : CGNS_ENUMV(RealSingle);
        Zones[nz].nverts = np;
        Zones[nz].verts = new_vertex (np);
        nk = whole ? (int)Zones[nz].nverts : (int)(Zones[nz].dim[0] * Zones[nz].dim[1]);
        if (nmax < nk) nmax = nk;
    }

    free (indices);

    if (is_double)
        xyz = (void *) malloc (3 * nmax * sizeof(double));
    else
        xyz = (void *) malloc (3 * nmax * sizeof(float));
    if (NULL == xyz)
        FATAL ("read_xyz", "malloc failed for coordinate working array");
    if (has_iblank) {
        iblank = (int *) malloc (nmax * sizeof(int));
        if (NULL == iblank)
            FATAL ("read_xyz", "malloc failed for iblank array");
    }
    else
        use_iblank = 0;

    /* read the grid blocks */

    for (nz = 0; nz < nZones; nz++) {
        printf ("reading block %d grid %dx%dx%d ...", nz+1,
            (int)Zones[nz].dim[0], (int)Zones[nz].dim[1],
            (int)Zones[nz].dim[2]);
        fflush (stdout);
        if (whole) {
            np = (int)Zones[nz].nverts;
            nk = 1;
        }
        else {
            np = (int)(Zones[nz].dim[0] * Zones[nz].dim[1]);
            nk = (int)Zones[nz].dim[2];
        }
        verts = Zones[nz].verts;
        for (k = 0; k < nk; k++) {
            if (is_double)
                bf_getdoubles (bf, 3 * np, xyz);
            else
                bf_getfloats (bf, 3 * np, xyz);
            if (has_iblank)
                bf_getints (bf, np, iblank);
            if (is_double) {
                for (i = 0, n = 0; n < np; n++, i++)
                    verts[n].x = ((double *)xyz)[i];
                for (n = 0; n < np; n++, i++)
                    verts[n].y = ((double *)xyz)[i];
                for (n = 0; n < np; n++, i++)
                    verts[n].z = ((double *)xyz)[i];
            }
            else {
                for (i = 0, n = 0; n < np; n++, i++)
                    verts[n].x = ((float *)xyz)[i];
                for (n = 0; n < np; n++, i++)
                    verts[n].y = ((float *)xyz)[i];
                for (n = 0; n < np; n++, i++)
                    verts[n].z = ((float *)xyz)[i];
            }
            for (n = 0; n < np; n++, verts++)
                verts->id = use_iblank ? iblank[n] : 1;
        }
        puts (" done");
    }

    free (xyz);
    if (has_iblank) free (iblank);
}