/** * Get the volume that corresponds to the given dimensions. * * @param volume the volume to get * @return the corresponding volume */ public final Viewer3DNodeVolume getVolume(final Viewer3DNodeAxes.Volume volume) { Viewer3DNodeVolume vol; final String key = volume.getCacheString(); if (m_caching && m_cache.containsKey(key)) { vol = m_cache.get(key); } else { // create the new volume final vtkImageData vtkImg = m_converter.getVTKImageData(volume); // copy the current settings if possible if (m_current != null) { final TransferFunctionBundle gray = new TransferFunctionBundle(m_current.getBundleGray()); final TransferFunctionBundle rgb = new TransferFunctionBundle(m_current.getBundleRGB()); vol = new Viewer3DNodeVolume(vtkImg, volume, gray, rgb); } else { vol = new Viewer3DNodeVolume(vtkImg, volume); } if (m_caching) { m_cache.put(key, vol); } } m_current = vol; vol.setMapper(m_mapper); return vol; }
/** * If this method is called, all images cached by this instance will be deleted by a call to the * vtkImageData.Delete() method.<br> * This means that the memory of all images will be freed, regardless if one of the images is * currently being rendered! */ public final void delete() { if (m_cache != null) { for (final Viewer3DNodeVolume v : m_cache.values()) { v.delete(false); } m_cache.clear(); } m_converter = null; m_current = null; m_cache = null; m_mapper = null; m_axes = null; }