Logo Search packages:      
Sourcecode: v-sim version File versions  Download package

int visuDataSet_population ( VisuData data,
int  nbOfTypes,
int *  nbOfNodesPerVisuElement,
VisuElement **  visuElementUsed 
)

visuDataSet_population: : a VisuData object ; : number of VisuElement ; : number of VisuNode per VisuElement ; : pointers to VisuElement in the same order that .

This method allocates the storing part of the given VisuData structure and store all the VisuNodes.

Returns: 1 if everything goes right.

Definition at line 892 of file visu_data.c.

{
  int i;
  int *pos;
  int nb;

  DBG_fprintf(stderr, "Visu Data : populating VisuData %p", (gpointer)data);

  data->fromIntToVisuElement = malloc(sizeof(VisuElement*) * nbOfTypes);
  if (!data->fromIntToVisuElement)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate fromIntToVisuElement failed.\n");
      return 0;
    }

  data->ntype = nbOfTypes;
  if (data->ntype <= 0)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : ntype <= 0 failed.\n");
      return 0;
    }
  data->nodes = malloc(sizeof(VisuNode*) * data->ntype);
  if (!data->nodes)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate nodes failed.\n");
      return 0;
    }
  data->numberOfNodes = malloc(sizeof(int) * data->ntype);
  if (!data->numberOfNodes)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate numberOfNodes failed.\n");
      return 0;
    }
  data->numberOfStoredNodes = malloc(sizeof(int) * data->ntype);
  if (!data->numberOfStoredNodes)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate numberOfStoredNodes failed.\n");
      return 0;
    }

  nb = 0;
  for(i = 0; i < data->ntype; i++)
    {
      if (nbOfNodesPerVisuElement[i] <= 0)
      {
        DBG_fprintf(stderr, " ... Error!\nVisu Data : nb nodes for '%s' <= 0.\n",
                  data->fromIntToVisuElement[i]->name);
        return 0;
      }
      data->nodes[i] = malloc(sizeof(VisuNode) * nbOfNodesPerVisuElement[i]);
      if (!data->nodes[i])
      {
        DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate nodes[%d] failed.\n", i);
        return 0;
      }
      nb += nbOfNodesPerVisuElement[i];
      data->numberOfNodes[i] = nbOfNodesPerVisuElement[i];
      data->numberOfStoredNodes[i] = 0;
      pos = malloc(sizeof(int));
      if (!pos)
      {
        DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate pos (%d) failed.\n", i);
        return 0;
      }
      *pos = i;
      g_hash_table_insert(data->fromVisuElementToInt, (gpointer)visuElementUsed[i], (gpointer)pos);
      data->fromIntToVisuElement[i] = visuElementUsed[i];
    }
  data->nbOfAllStoredNodes = 0;
  data->fromNumberToVisuNode = malloc(sizeof(VisuNode*) * nb);
  if (!data->fromNumberToVisuNode)
    {
      DBG_fprintf(stderr, " ... Error!\nVisu Data : allocate fromNumberToVisuNode failed.\n");
      return 0;
    }

  DBG_fprintf(stderr, " ... OK\n");
  return 1;
}


Generated by  Doxygen 1.6.0   Back to index