00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 //--------------------------------------------------------------------------- 00040 // Includes 00041 //--------------------------------------------------------------------------- 00042 00043 #include <stdlib.h> 00044 #include <stdio.h> 00045 00046 #include "OSGConfig.h" 00047 00048 #include "OSGOSGSceneFileType.h" 00049 #include "OSGOSGWriter.h" 00050 00051 OSG_USING_NAMESPACE 00052 00053 00059 /***************************************************************************\ 00060 * Types * 00061 \***************************************************************************/ 00062 00063 /***************************************************************************\ 00064 * Class variables * 00065 \***************************************************************************/ 00066 00067 const Char8 *OSGSceneFileType::_suffixA[] = { "osg" }; 00068 00069 OSGSceneFileType OSGSceneFileType::_the(_suffixA, 00070 sizeof(_suffixA), 00071 false, 00072 10, 00073 OSG_READ_SUPPORTED | 00074 OSG_WRITE_SUPPORTED); 00075 00076 OSGLoader *OSGSceneFileType::_pFile = NULL; 00077 00078 /***************************************************************************\ 00079 * Class methods * 00080 \***************************************************************************/ 00081 00082 /*-------------------------------------------------------------------------*\ 00083 - public - 00084 \*-------------------------------------------------------------------------*/ 00085 00086 OSGSceneFileType &OSGSceneFileType::the(void) 00087 { 00088 return _the; 00089 } 00090 00091 /*-------------------------------------------------------------------------*\ 00092 - protected - 00093 \*-------------------------------------------------------------------------*/ 00094 00095 /*-------------------------------------------------------------------------*\ 00096 - private - 00097 \*-------------------------------------------------------------------------*/ 00098 00099 /***************************************************************************\ 00100 * Instance methods * 00101 \***************************************************************************/ 00102 00103 /*-------------------------------------------------------------------------*\ 00104 - public - 00105 \*-------------------------------------------------------------------------*/ 00106 00107 /*------------------------------ access -----------------------------------*/ 00108 00109 const Char8 *OSGSceneFileType::getName(void) const 00110 { 00111 return "OSG GEOMETRY"; 00112 } 00113 00114 00115 NodePtr OSGSceneFileType::read(std::istream &is, const Char8 *) const 00116 { 00117 if(_pFile == NULL) 00118 _pFile = new OSGLoader; 00119 00120 _pFile->scanStream(is); 00121 00122 return _pFile->getRootNode(); 00123 } 00124 00125 bool OSGSceneFileType::write(const NodePtr &root, std::ostream &os, 00126 const Char8 *) const 00127 { 00128 if(!os) 00129 { 00130 FFATAL(("Can not open output stream!\n")); 00131 return false; 00132 } 00133 00134 OSGWriter writer(os, 4); 00135 writer.write(root); 00136 00137 return true; 00138 } 00139 00140 /*---------------------------- properties ---------------------------------*/ 00141 00142 /*-------------------------- your_category---------------------------------*/ 00143 00144 /*-------------------------- assignment -----------------------------------*/ 00145 00146 /*-------------------------- comparison -----------------------------------*/ 00147 00148 00149 /*-------------------------------------------------------------------------*\ 00150 - protected - 00151 \*-------------------------------------------------------------------------*/ 00152 00153 00157 OSGSceneFileType::OSGSceneFileType(const char *suffixArray[], 00158 UInt16 suffixByteCount, 00159 bool override, 00160 UInt32 overridePriority, 00161 UInt32 flags) : 00162 Inherited(suffixArray, 00163 suffixByteCount, 00164 override, 00165 overridePriority, 00166 flags) 00167 { 00168 return; 00169 } 00170 00171 00175 OSGSceneFileType::~OSGSceneFileType(void) 00176 { 00177 } 00178 00179 00180 /*-------------------------------------------------------------------------*/ 00181 /* cvs id's */ 00182 00183 #ifdef __sgi 00184 #pragma set woff 1174 00185 #endif 00186 00187 #ifdef OSG_LINUX_ICC 00188 #pragma warning( disable : 177 ) 00189 #endif 00190 00191 namespace 00192 { 00193 static Char8 cvsid_cpp[] = "@(#)$Id: $"; 00194 static Char8 cvsid_hpp[] = OSGOSGSCENEFILETYPE_HEADER_CVSID; 00195 }
1.4.3