get/set the number of cells (ncells) within one cell_set of a Cell_Data or Cells Grid
int FLDset_ncells (
OMobj_id cell_set,
xp_long ncells);
int FLDget_ncells (
OMobj_id cell_set,
xp_long *ncells);
int FLDget_ncells_n (
OMobj_id cell_set,
int *ncells);
These routines get/set the number of cells (ncells) within one element of a cell_set array within either a Cell_Data and/or a Cells Grid cell_set.
Note that calling FLDget_ncells() on a Poly cell set (Polyline, Polytri, or Polyhedron (for polygons)) returns the number of primitive (triangular) cells in the cell set, while FLDget_npolys() returns the number of lines, triangles or polygons respectively.
xp_long *ncells
xp_long ncells
int *ncells
int ncells
This example, a fragment from modules/advect.c, shows advector getting its ncells from the input field, and setting the ncells in the output field.
int FUNCadvec (in, time, dir, out)
OMobj_id in, out;
double time;
int dir;
{
int i, cell, node, out_ncells, out_nnodes, rdir;
int data_type, size, conn_size, veclen, ncomp;
int *node_list, *out_node_list, nsets, cs, cell_nnodes, ncells;
int comp, null_flag, nspace;
char units[MAX_NAME_SIZE], label[MAX_NAME_SIZE], name[MAX_NAME_SIZE];
float vel[3], vel1[3], vel2[3], del[3], dt, t, mag, len, *coord,
*out_coord, *node_data, *out_data;
OMobj_id cell_set, out_cell_set;
...
if (FLDget_ncell_sets(in, &nsets)!= 1) {
ERR_RETURN("cannot get nsets");
}
for (out_nnodes=0,cs=0; cs<nsets; cs++) {
if (FLDget_cell_set(in, cs, &cell_set)!= 1) {
ERR_RETURN("cannot get cell set");
}
if (FLDget_ncells(cell_set, &ncells)!= 1) {
ERR_RETURN("cannot get ncells");
}
out_nnodes += ncells;
}
...
/*---------------*/
/* OUT CELLS */
/*---------------*/
if (FLDset_ncell_sets(out, 1)!= 1) {
ERR_RETURN("cannot set nsets");
}
if (FLDget_cell_set(out, 0, &cell_set)!= 1) {
ERR_RETURN("Error getting cell set");
}
if (FLDset_cell_set(cell_set, "Point")!= 1) {
ERR_RETURN("Error setting cell type");
}
if (FLDset_ncells(cell_set, out_nnodes)!= 1) {
ERR_RETURN("Error setting ncells");
}
...