int
simv2_UnstructuredMesh_setGhostNodes(visit_handle h, visit_handle gn)
{
    int retval = VISIT_ERROR;
    VisIt_UnstructuredMesh *obj = GetObject(h, "simv2_UnstructuredMesh_setGhostNodes");
    if(obj != NULL)
    {
        // Get the ghost node information
        int owner, dataType, nComps, nTuples;
        void *data = 0;
        if(simv2_VariableData_getData(gn, owner, dataType, nComps, nTuples, data) == VISIT_ERROR)
        {
            VisItError("Could not obtain ghost node information.");
            return VISIT_ERROR;
        }

        if(nComps != 1)
        {
            VisItError("Ghost node arrays must have 1 component.");
            return VISIT_ERROR;
        }

        if(dataType != VISIT_DATATYPE_CHAR && dataType != VISIT_DATATYPE_INT)
        {
            VisItError("Ghost node arrays must contain either char or int elements.");
            return VISIT_ERROR;
        }

        obj->FreeGhostNodes();
        obj->ghostNodes = gn;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_UnstructuredMesh_setGlobalNodeIds(visit_handle h, visit_handle gln)
{
    int retval = VISIT_ERROR;
    VisIt_UnstructuredMesh *obj = GetObject(h, "simv2_UnstructuredMesh_setGlobalNodeIds");
    if(obj != NULL)
    {
        // Get the global node id information
        int owner, dataType, nComps, nTuples;
        void *data = 0;
        if(simv2_VariableData_getData(gln, owner, dataType, nComps, nTuples, data) == VISIT_ERROR)
        {
            VisItError("Could not obtain global node id information.");
            return VISIT_ERROR;
        }

        if(nComps != 1)
        {
            VisItError("Global node id arrays must have 1 component.");
            return VISIT_ERROR;
        }

        if(dataType != VISIT_DATATYPE_LONG && dataType != VISIT_DATATYPE_INT)
        {
            VisItError("Global node id arrays must contain either int or long elements.");
            return VISIT_ERROR;
        }

        obj->FreeGlobalNodeIds();
        obj->globalNodeIds = gln;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_CSGMesh_setRegions(visit_handle h, visit_handle typeflags, 
    visit_handle leftids, visit_handle rightids)
{
    int retval = VISIT_ERROR;
    visit_handle cHandles[3];
    cHandles[0] = typeflags;
    cHandles[1] = leftids;
    cHandles[2] = rightids;

    // Get the coordinates
    int owner[3], dataType[3], nComps[3], nTuples[3];
    void *data[3] = {0,0,0};
    for(int i = 0; i < 3; ++i)
    {
        if(simv2_VariableData_getData(cHandles[i], owner[i], dataType[i], nComps[i], 
            nTuples[i], data[i]) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }

        // Error checking.
        if(nComps[i] != 1)
        {
            VisItError("Region arrays must have 1 component");
            return VISIT_ERROR;
        }
        if(nTuples[i] <= 0)
        {
            VisItError("Region arrays must not be empty");
            return VISIT_ERROR;
        }
        if(dataType[i] != VISIT_DATATYPE_INT)
        {
            VisItError("Region arrays must contain integer data");
            return VISIT_ERROR;
        }
    }

    for(int i = 1; i < 3; ++i)
    {
        if(nTuples[0] != nTuples[i])
        {
            VisItError("Region arrays must contain the same number of tuples.");
            return VISIT_ERROR;
        }
    }

    VisIt_CSGMesh *obj = GetObject(h);
    if(obj != NULL)
    {
        obj->FreeRegions();
        obj->typeflags = typeflags;
        obj->leftids = leftids;
        obj->rightids = rightids;

        retval = VISIT_OKAY;
    }
    return retval;
}
static int
simv2_UnstructuredMesh_setCoords_helper(const char *fname,
    visit_handle h, visit_handle *cHandles, int ndims)
{
    int retval = VISIT_ERROR;

    // Get the coordinates
    int owner[3], dataType[3], nComps[3], nTuples[3];
    void *data[3] = {0,0,0};
    for(int i = 0; i < ndims; ++i)
    {
        if(simv2_VariableData_getData(cHandles[i], owner[i], dataType[i], nComps[i], 
            nTuples[i], data[i]) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }

        // Error checking.
        if(nComps[i] != 1)
        {
            VisItError("Coordinates must have 1 component");
            return VISIT_ERROR;
        }
        if(dataType[i] != VISIT_DATATYPE_FLOAT &&
           dataType[i] != VISIT_DATATYPE_DOUBLE)
        {
            VisItError("Coordinates must contain float or double data");
            return VISIT_ERROR;
        }
    }

    for(int i = 1; i < ndims; ++i)
    {
        if(nTuples[0] != nTuples[i])
        {
            VisItError("Coordinates must contain the same number of tuples.");
            return VISIT_ERROR;
        }
        if(dataType[0] != dataType[i])
        {
            VisItError("Coordinates must be the same data type.");
            return VISIT_ERROR;
        }
    }

    VisIt_UnstructuredMesh *obj = GetObject(h, fname);
    if(obj != NULL)
    {
        obj->ndims = ndims;
        obj->coordMode = VISIT_COORD_MODE_SEPARATE;
        obj->FreeCoordinates();
        obj->xcoords = cHandles[0];
        obj->ycoords = cHandles[1];
        obj->zcoords = (ndims == 3) ?  cHandles[2] : VISIT_INVALID_HANDLE;
        obj->coords = VISIT_INVALID_HANDLE;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_DomainList_check(visit_handle h)
{
    int retval = VISIT_ERROR;
    VisIt_DomainList *obj = GetObject(h, "simv2_DomainList_check");
    if(obj != NULL)
    {
        if(obj->mydoms != VISIT_INVALID_HANDLE)
        {
            int owner, dataType, nComps = 0, nTuples = 0;
            void *data = NULL;
            if(simv2_VariableData_getData(obj->mydoms, owner, dataType, nComps,
                nTuples, data) == VISIT_OKAY)
            {
                int *doms = (int*)data;
                for(int i = 0; i < nTuples; ++i)
                {
                    if(doms[i] < 0 || doms[i] >= obj->alldoms)
                    {
                        VisItError("The domain list contained out of range domain numbers");
                        return VISIT_ERROR;
                    }
                }
            }

            if(nTuples <= 0)
            {
                VisItError("No domains were supplied for the DomainList");
                return VISIT_ERROR;
            }
        }
        retval = VISIT_OKAY;
    }
    return retval;
}
static int
simv2_CurveData_setCoords_helper(visit_handle h, visit_handle *cHandles, 
    int ndims, const char *fname)
{
    int retval = VISIT_ERROR;
    VisIt_CurveData *obj = GetObject(h, fname);

    // Get the coordinates
    int owner[3], dataType[3], nComps[3], nTuples[3];
    void *data[3] = {0,0,0};
    for(int i = 0; i < ndims; ++i)
    {
        if(simv2_VariableData_getData(cHandles[i], owner[i], dataType[i], nComps[i], 
            nTuples[i], data[i]) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }

        // Error checking.
        if(nComps[i] != 1)
        {
            VisItError("Coordinates must have 1 component");
            return VISIT_ERROR;
        }
        if(!((i == 0 && dataType[i] == VISIT_DATATYPE_INT) ||
              dataType[i] == VISIT_DATATYPE_FLOAT ||
              dataType[i] == VISIT_DATATYPE_DOUBLE))
        {
            VisItError("Coordinates must contain int, float, or double data");
            return VISIT_ERROR;
        }
    }

    for(int i = 1; i < ndims; ++i)
    {
        if(nTuples[0] != nTuples[i])
        {
            VisItError("Coordinates must contain the same number of tuples.");
            return VISIT_ERROR;
        }
    }

    if(obj != NULL)
    {
        obj->FreeCoordinates();
        obj->xcoords = cHandles[0];
        obj->ycoords = cHandles[1];

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_UnstructuredMesh_setConnectivity(visit_handle h, int nzones, visit_handle conn)
{
    // Get the connectivity
    int owner, dataType, nComps, nTuples;
    void *data = 0;
    if(simv2_VariableData_getData(conn, owner, dataType, nComps, nTuples, 
        data) == VISIT_ERROR)
    {
        return VISIT_ERROR;
    }

    if(nComps != 1)
    {
        VisItError("The connectivity array must have 1 component.");
        return VISIT_ERROR;
    }
    if(nTuples <= 0)
    {
        VisItError("The connectivity array is empty.");
        return VISIT_ERROR;
    }
    if(dataType != VISIT_DATATYPE_INT)
    {
        VisItError("The connectivity array must contain integers.");
        return VISIT_ERROR;
    }
    if(nzones <= 0)
    {
        VisItError("The number of zones must be greater than zero.");
        return VISIT_ERROR;
    }

    VisIt_UnstructuredMesh *obj = GetObject(h, "simv2_UnstructuredMesh_setConnectivity");
    int retval = VISIT_ERROR;
    if(obj != NULL)
    {
        obj->nzones = nzones;
        if(obj->lastRealZone == -1)
            obj->lastRealZone = nzones - 1;
        obj->FreeConnectivity();
        obj->connectivity = conn;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_DomainList_setDomains(visit_handle h, int alldoms, visit_handle mydoms)
{
    int retval = VISIT_ERROR;
    VisIt_DomainList *obj = GetObject(h, "simv2_DomainList_setDomains");

    if(alldoms < 1)
    {
        VisItError("There must be at least 1 domain.");
        return VISIT_ERROR;
    }
 
    if(mydoms != VISIT_INVALID_HANDLE)
    {
        // Get the domains
        int owner, dataType, nComps, nTuples;
        void *data = 0;
        if(simv2_VariableData_getData(mydoms, owner, dataType, nComps, 
           nTuples, data) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }

        // Error checking.
        if(nComps != 1)
        {
            VisItError("DomainList must have 1 component");
            return VISIT_ERROR;
        }
        if(dataType != VISIT_DATATYPE_INT)
        {
            VisItError("DomainList must contain int data");
            return VISIT_ERROR;
        }
    }

    if(obj != NULL)
    {
        obj->FreeDomains();
        obj->mydoms = mydoms;
        obj->alldoms = alldoms;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_UnstructuredMesh_setCoords(visit_handle h, visit_handle coords)
{
    int retval = VISIT_ERROR;

    // Get the coordinates
    int owner, dataType, nComps, nTuples;
    void *data = 0;
    if(simv2_VariableData_getData(coords, owner, dataType, nComps, nTuples, 
        data) == VISIT_ERROR)
    {
        return VISIT_ERROR;
    }

    // Error checking.
    if(nComps != 2 && nComps != 3)
    {
        VisItError("Interleaved coordinates must have 2 or 3 components");
        return VISIT_ERROR;
    }
    if(dataType != VISIT_DATATYPE_FLOAT &&
       dataType != VISIT_DATATYPE_DOUBLE)
    {
        VisItError("Coordinates must contain float or double data");
        return VISIT_ERROR;
    }

    VisIt_UnstructuredMesh *obj = GetObject(h, "simv2_UnstructuredMesh_setCoords");
    if(obj != NULL)
    {
        obj->ndims = nComps;
        obj->coordMode = VISIT_COORD_MODE_INTERLEAVED;
        obj->FreeCoordinates();
        obj->xcoords = VISIT_INVALID_HANDLE;
        obj->ycoords = VISIT_INVALID_HANDLE;
        obj->zcoords = VISIT_INVALID_HANDLE;
        obj->coords = coords;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_CSGMesh_setBoundaryCoeffs(visit_handle h, visit_handle boundaryCoeffs)
{
    int retval = VISIT_ERROR;
    VisIt_CSGMesh *obj = GetObject(h);
    if(obj != NULL)
    {
        int owner, dataType, nComps, nTuples;
        void *data = NULL;
        if(simv2_VariableData_getData(boundaryCoeffs, owner, dataType, nComps, 
            nTuples, data) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }
        // Error checking.
        if(nComps != 1)
        {
            VisItError("CSGMesh's boundary Coeffs array must have 1 component");
            return VISIT_ERROR;
        }
        if(nTuples <= 0)
        {
            VisItError("CSGMesh's boundary Coeffs array must not be empty");
            return VISIT_ERROR;
        }
        if(dataType != VISIT_DATATYPE_DOUBLE &&
           dataType != VISIT_DATATYPE_FLOAT)
        {
            VisItError("CSGMesh's boundary Coeffs array must contain float or double data");
            return VISIT_ERROR;
        }

        obj->FreeBoundaryCoeffs();
        obj->boundaryCoeffs = boundaryCoeffs;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_CSGMesh_setZonelist(visit_handle h, visit_handle zonelist)
{
    int retval = VISIT_ERROR;
    VisIt_CSGMesh *obj = GetObject(h);
    if(obj != NULL)
    {
        int owner, dataType, nComps, nTuples;
        void *data = NULL;
        if(simv2_VariableData_getData(zonelist, owner, dataType, nComps, 
            nTuples, data) == VISIT_ERROR)
        {
            return VISIT_ERROR;
        }
        // Error checking.
        if(nComps != 1)
        {
            VisItError("Zonelist array must have 1 component");
            return VISIT_ERROR;
        }
        if(nTuples <= 0)
        {
            VisItError("Zonelist array must not be empty");
            return VISIT_ERROR;
        }
        if(dataType != VISIT_DATATYPE_INT)
        {
            VisItError("Zonelist array must contain integer data");
            return VISIT_ERROR;
        }

        obj->FreeZonelist();
        obj->zonelist = zonelist;

        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_SpeciesData_setSpeciesMF(visit_handle h, visit_handle val)
{
    // How many arrays make up the variable.
    int nArr = 1;
    if(simv2_VariableData_getNumArrays(val, &nArr) == VISIT_ERROR)
    {
        return VISIT_ERROR;
    }
    if(nArr != 1)
    {
        VisItError("speciesMF must have 1 component.");
        return VISIT_ERROR;
    }

    int owner, dataType, nComps, nTuples;
    void *data = NULL;
    if(simv2_VariableData_getData(val, owner, dataType, nComps, nTuples, data) ==
            VISIT_ERROR)
    {
        return VISIT_ERROR;
    }
    if(dataType != VISIT_DATATYPE_FLOAT &&
            dataType != VISIT_DATATYPE_DOUBLE)
    {
        VisItError("simv2_SpeciesData_setSpeciesMF: speciesMF requires float or double data");
        return VISIT_ERROR;
    }

    int retval = VISIT_ERROR;
    VisIt_SpeciesData *obj = GetObject(h, "simv2_SpeciesData_setSpeciesMF");
    if(obj != NULL)
    {
        obj->speciesMF = val;
        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_SpeciesData_setMixedSpecies(visit_handle h, visit_handle val)
{
    // How many arrays make up the variable.
    int nArr = 1;
    if(simv2_VariableData_getNumArrays(val, &nArr) == VISIT_ERROR)
    {
        return VISIT_ERROR;
    }
    if(nArr != 1)
    {
        VisItError("mixedSpecies must have 1 component.");
        return VISIT_ERROR;
    }

    int owner, dataType, nComps, nTuples;
    void *data = NULL;
    if(simv2_VariableData_getData(val, owner, dataType, nComps, nTuples, data) ==
            VISIT_ERROR)
    {
        return VISIT_ERROR;
    }
    if(dataType != VISIT_DATATYPE_INT)
    {
        VisItError("simv2_SpeciesData_setMixedSpecies: mixedSpecies requires int data");
        return VISIT_ERROR;
    }

    int retval = VISIT_ERROR;
    VisIt_SpeciesData *obj = GetObject(h, "simv2_SpeciesData_setMixedSpecies");
    if(obj != NULL)
    {
        obj->mixedSpecies = val;
        retval = VISIT_OKAY;
    }
    return retval;
}
int
simv2_UnstructuredMesh_check(visit_handle h)
{
    VisIt_UnstructuredMesh *obj = GetObject(h, "simv2_UnstructuredMesh_check");
    int retval = VISIT_ERROR;
    if(obj != NULL)
    {
        if(obj->nzones <= 0 || obj->connectivity == VISIT_INVALID_HANDLE)
        {
            VisItError("The UnstructuredMesh object does not have connectivity.");
            return VISIT_ERROR;
        }

        if(obj->coordMode == VISIT_COORD_MODE_SEPARATE &&
           obj->xcoords == VISIT_INVALID_HANDLE)
        {
            VisItError("The UnstructuredMesh's coordinates were not provided.");
            return VISIT_ERROR;
        }

        if(obj->ghostCells != VISIT_INVALID_HANDLE)
        {
            // Get the ghost cell information
            int owner, dataType, nComps, nTuples = 0;
            void *data = 0;
            simv2_VariableData_getData(obj->ghostCells, owner, dataType, nComps, nTuples, data);

            if(nTuples != obj->nzones)
            {
                 VisItError("The number of elements in the ghost cell array does "
                            "not match the number of cells in the mesh.");
                 return VISIT_ERROR;
            }
        }

        if(obj->globalCellIds != VISIT_INVALID_HANDLE)
        {
            // Get the ghost cell information
            int owner, dataType, nComps, nTuples = 0;
            void *data = 0;
            simv2_VariableData_getData(obj->globalCellIds, owner, dataType, nComps, nTuples, data);

            if(nTuples != obj->nzones)
            {
                VisItError("The number of elements in the global cell id array does "
                           "not match the number of cells in the mesh.");
                return VISIT_ERROR;
            }
        }

        if(obj->ghostNodes != VISIT_INVALID_HANDLE ||
           obj->globalNodeIds != VISIT_INVALID_HANDLE)
        {
            // Get the ghost node information
            int owner, dataType, nComps, nTuples = 0, nNodes = 0;
            void *data = 0;
            if(obj->coordMode == VISIT_COORD_MODE_SEPARATE)
            {
                simv2_VariableData_getData(obj->xcoords, owner, dataType, nComps, nNodes, data);
            }
            else
            {
                simv2_VariableData_getData(obj->coords, owner, dataType, nComps, nNodes, data);
            }

            if(obj->ghostNodes != VISIT_INVALID_HANDLE)
            {
                simv2_VariableData_getData(obj->ghostNodes, owner, dataType, nComps, nTuples, data);
                if(nTuples != nNodes)
                {
                    VisItError("The number of elements in the ghost node array does "
                               "not match the number of nodes in the mesh.");
                    return VISIT_ERROR;
                }
            }

            if(obj->globalNodeIds != VISIT_INVALID_HANDLE)
            {
                simv2_VariableData_getData(obj->globalNodeIds, owner, dataType, nComps, nTuples, data);
                if(nTuples != nNodes)
                {
                    VisItError("The number of elements in the global node ids array does "
                               "not match the number of nodes in the mesh.");
                    return VISIT_ERROR;
                }
            }
        }

        retval = VISIT_OKAY;
    }

    return retval;
}