Exemplo n.º 1
0
void VolumeTexture::setGridData(const VolumetricData *voldata) {
  if (v == voldata) return;
  v = voldata;
  if (texmap) {
    vmd_dealloc(texmap);
    texmap = NULL;
  }
  size[0] = size[1] = size[2] = 0;
  texid = 0;
}
Exemplo n.º 2
0
// add the given Displayable as a child (assuming it is one)
void Displayable::add_child(Displayable *d) {
    
  // append child to list of children
  children[num_children++] = d;
  if (num_children == max_children) {
    void *tmp = vmd_alloc(max_children*2*sizeof(Displayable*));
    memcpy(tmp,children,max_children*sizeof(Displayable*));
    vmd_dealloc(children);
    children = (Displayable **)tmp;
    max_children *= 2;
  } 
}
Exemplo n.º 3
0
int VolumeTexture::allocateTextureMap(int npixels) {
  texid = 0;
  if (texmap) {
    vmd_dealloc(texmap);
    texmap = NULL;
  }
  texmap = (unsigned char *) vmd_alloc(npixels*3*sizeof(unsigned char));
  if (texmap == NULL) {
    msgErr << "Texture map allocation failed, out of memory?" << sendmsg;
    return FALSE;
  }
  memset(texmap, 0, npixels*3*sizeof(unsigned char));
  texid = VMDApp::get_texserialnum();
  return TRUE;
}
Exemplo n.º 4
0
// destructor; free up allocated space
Displayable::~Displayable(void) {
  // delete all children still around; also unregistered them
  while(num_children > 0)
    // delete first child object, the child destructor then removes the
    // child from this parent's list, until there are no more
    delete child(0);

  cmdList->reset_and_free(0); // free space allocated for disp storage
  delete cmdList;             // free the cmdList itself back to scene memory

  // if this is a child, remove it from it's parent's list of children
  if (parent)
    parent->remove_child(this);

  vmd_dealloc(children);
}
Exemplo n.º 5
0
Arquivo: vmd.C Projeto: quolc/VMDLeap
// function to resize allocations depending on whether or not the allocator
// provides a realloc() function or not.
void * vmd_resize_alloc(void *ptr, size_t oldsize, size_t newsize) {
  void *newptr=NULL;

  if (ptr == NULL) { 
    newptr = vmd_alloc(newsize);
    return newptr; 
  }

  if (vmd_realloc != NULL) {
    newptr = vmd_realloc(ptr, newsize);
  }

  if (newptr == NULL) {
    newptr = vmd_alloc(newsize);
    if (newptr != NULL) {
      memcpy(newptr, ptr, oldsize);
      vmd_dealloc(ptr);
    }
  }

  return newptr;
}
Exemplo n.º 6
0
VolumeTexture::~VolumeTexture() {
  if (texmap) vmd_dealloc(texmap);
}
Exemplo n.º 7
0
void Displayable::operator delete(void *p, size_t) {
  vmd_dealloc(p);
}