1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/*=========================================================================
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/VolViewCopyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "XML/vtkXMLVVFileInstancePoolReader.h"
#include "vtkObjectFactory.h"
#include "vtkInstantiator.h"
#include "vtkVVFileInstancePool.h"
#include "vtkXMLDataElement.h"
#include "vtkKWApplication.h"
#include "vtkVVFileInstance.h"
#include "XML/vtkXMLVVFileInstancePoolWriter.h"
#include "KWVolViewInstantiator.h"
vtkStandardNewMacro(vtkXMLVVFileInstancePoolReader);
vtkCxxRevisionMacro(vtkXMLVVFileInstancePoolReader, "$Revision: 1.16 $");
//----------------------------------------------------------------------------
const char* vtkXMLVVFileInstancePoolReader::GetRootElementName()
{
return "VVFileInstancePool";
}
//----------------------------------------------------------------------------
int vtkXMLVVFileInstancePoolReader::Parse(vtkXMLDataElement *elem)
{
if (!this->Superclass::Parse(elem))
{
return 0;
}
vtkVVFileInstancePool *obj =
vtkVVFileInstancePool::SafeDownCast(this->Object);
if (!obj)
{
vtkWarningMacro(<< "The VVFileInstancePool is not set!");
return 0;
}
// Get Attributes
// File Instances
obj->RemoveAllFileInstances();
// Backward compat, we used to put them in "FileInstances"
vtkXMLDataElement *compat_nested_elem =
elem->FindNestedElementWithName("FileInstances");
if (compat_nested_elem)
{
elem = compat_nested_elem;
}
int idx, nb_nested_elems = elem->GetNumberOfNestedElements();
for (idx = 0; idx < nb_nested_elems; idx++)
{
vtkXMLDataElement *nested_elem = elem->GetNestedElement(idx);
const char *classname = nested_elem->GetAttribute("ClassName");
if (classname)
{
vtkVVFileInstance *file = vtkVVFileInstance::SafeDownCast(
vtkInstantiator::CreateInstance(classname));
if (file)
{
file->SetApplication(obj->GetApplication());
vtkXMLObjectReader *xmlr = file->GetNewXMLReader();
xmlr->Parse(nested_elem);
obj->AddFileInstance(file);
file->Delete();
xmlr->Delete();
}
}
}
return 1;
}
//----------------------------------------------------------------------------
void vtkXMLVVFileInstancePoolReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
|