Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ImLib3DFile.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00020 #include<ImLib3D/ImLib3DFile.hpp>
00021 
00022 bool 
00023 ImLib3DFile::IsImLib3DImage(const string &fname)
00024 {
00025     bool isImage=false;
00026     if(FileExists(fname))
00027     {
00028         // old format with top node==ImLib3DFileDescription
00029         try
00030         {
00031             ImLib3DFile file(fname,"r",true);
00032             file.GetChild(file.GetRoot("ImLib3DFileDescription"), "ImLib3DImage");
00033             isImage=true;
00034         }
00035         catch(std::exception& __fail){}
00036         // new format (no top node)
00037         try
00038         {
00039             ImLib3DFile file(fname,"r",true);
00040             file.GetRoot("ImLib3DImage");
00041             isImage=true;
00042         }
00043         catch(std::exception& __fail){}
00044     }
00045     return isImage;
00046 }
00047 
00048 xmlpp::Element *
00049 Streamable::CreateWriteNode(const string &topNodeName,ImLib3DFile *file,xmlpp::Element *parentNode,xmlpp::Element *node) const
00050 {
00051     if(!parentNode && !node){node=file->SetRoot(topNodeName);}
00052     if(!node){node=parentNode->add_child(topNodeName);}
00053     return node;
00054 }
00055 xmlpp::Element *
00056 Streamable::CreateReadNode(const string &topNodeName,ImLib3DFile *file,xmlpp::Element *parentNode,xmlpp::Element *node)
00057 {
00058     // this is for support of old file formats where there was a top node called "ImLib3DFileDescription"
00059     {
00060         if(!parentNode && !node)
00061         {
00062             xmlpp::Element *root=file->GetRoot();
00063             cout << "t1:" << root << endl;
00064             cout << "t2:" << root->get_name() << endl;
00065             if(root->get_name()=="ImLib3DFileDescription"){parentNode=root;}
00066         }
00067     }
00068     // get node
00069     if(!parentNode && !node){node=file->GetRoot(topNodeName);}
00070     if(!node){node=file->GetChild(parentNode,topNodeName);}
00071     return node;
00072 }

Generated on Fri Jun 17 13:36:05 2005 for ImLib3D by  doxygen 1.4.2