Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

exotkDX_Root.cxx

Go to the documentation of this file.
00001 
00002 //   exotkDX_Root.cxx
00004 //    Copyright (C) 2001  Stephane Routelous
00005 //
00006 //    This file is part of exoTK.
00007 //
00008 //    exoTK is free software; you can redistribute it and/or modify
00009 //    it under the terms of the GNU General Public License as published by
00010 //    the Free Software Foundation; either version 2 of the License, or
00011 //    (at your option) any later version.
00012 //
00013 //    exoTK is distributed in the hope that it will be useful,
00014 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //    GNU General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU General Public License
00019 //    along with exoTK; if not, write to the Free Software
00020 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00029 #include <exotkDX_Root.hxx>
00030 #ifndef  _TopoDS_Shape_HeaderFile
00031 #include <TopoDS_Shape.hxx>
00032 #endif
00033 #ifndef  _TopTools_HSequenceOfShape_HeaderFile
00034 #include <TopTools_HSequenceOfShape.hxx>
00035 #endif
00036 #ifndef  _exotkUtils_BRep_HeaderFile
00037 #include <exotkUtils_BRep.hxx>
00038 #endif
00039 #ifndef  _OSD_Path_HeaderFile
00040 #include <OSD_Path.hxx>
00041 #endif
00042 #ifndef  _TColStd_HSequenceOfAsciiString_HeaderFile
00043 #include <TColStd_HSequenceOfAsciiString.hxx>
00044 #endif
00045 #ifndef _Standard_DefineHandle_HeaderFile
00046 #include <Standard_DefineHandle.hxx>
00047 #endif
00048 
00049 //
00050 IMPLEMENT_STANDARD_HANDLE(exotkDX_Root, MMgt_TShared)
00051 IMPLEMENT_STANDARD_RTTI(exotkDX_Root, MMgt_TShared)
00052 //
00053 // Foreach ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and 
00054 // a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro.
00055 // We must respect the order: from the direct ancestor class
00056 // to the base class.
00057 //
00058 
00059 IMPLEMENT_STANDARD_TYPE(exotkDX_Root)
00060 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared) 
00061 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient)
00062 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
00063 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared)
00064 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient)
00065 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
00066 IMPLEMENT_STANDARD_TYPE_END(exotkDX_Root)
00067 
00068 exotkDX_Root::exotkDX_Root()
00069 {
00070         myAllowExport = Standard_False;
00071         myAllowImport = Standard_False;
00072 }
00073 
00074 exotkDX_Root::~exotkDX_Root()
00075 {
00076 
00077 }
00078 
00079 Standard_Boolean exotkDX_Root::AllowImport()
00080 {
00081         return myAllowImport;
00082 }
00083 Standard_Boolean exotkDX_Root::AllowExport()
00084 {
00085         return myAllowExport;
00086 }
00087 
00088 TCollection_AsciiString exotkDX_Root::Filename()
00089 {
00090         return myFileName;
00091 }
00092 void exotkDX_Root::SetFilename(const TCollection_AsciiString& aFilename)
00093 {
00094         myFileName = aFilename;
00095 }
00096 
00097 TopoDS_Shape exotkDX_Root::LoadShape()
00098 {
00099         TopoDS_Shape theComputedShape;
00100         
00101         Handle_TopTools_HSequenceOfShape theShapes = LoadShapes();
00102         if ( !theShapes.IsNull() && !theShapes->IsEmpty() )
00103         {
00104                 TopoDS_Shape theConvertedShape;
00105                 if ( exotkUtils_BRep::BuildShape(theConvertedShape,theShapes) )
00106                 {
00107                         theComputedShape = theConvertedShape;
00108                 }
00109         }
00110 
00111         return theComputedShape;
00112 }
00113 Standard_Boolean exotkDX_Root::SaveShapes(const Handle_TopTools_HSequenceOfShape& aSequenceOfShapes)
00114 {
00115         Standard_Boolean theSaveIsDone = Standard_False;
00116         if ( !aSequenceOfShapes.IsNull() && !aSequenceOfShapes->IsEmpty() )
00117         {
00118                 TopoDS_Shape theConvertedShape;
00119                 if ( exotkUtils_BRep::BuildShape(theConvertedShape,aSequenceOfShapes) )
00120                 {
00121                         theSaveIsDone = SaveShape(theConvertedShape);
00122                 }
00123         }
00124         return theSaveIsDone;
00125 
00126 }
00127 
00128 Standard_Boolean exotkDX_Root::Match(const TCollection_AsciiString& aFilename)
00129 {
00130         Standard_Boolean theFilenameIsKnown = Standard_False;
00131 
00132         if ( !aFilename.IsEmpty() )
00133         {
00134                 OSD_Path thePath(aFilename);
00135                 TCollection_AsciiString theExtension = thePath.Extension();
00136                 if ( !theExtension.IsEmpty() )
00137                 {
00138                         theExtension.LowerCase();
00139                         Handle_TColStd_HSequenceOfAsciiString theExtensions = FormatExtensions();
00140                         if ( !theExtensions.IsNull() && !theExtensions->IsEmpty())
00141                         {
00142                                 for ( int iter = 1 ; (iter <= theExtensions->Length()) && (!theFilenameIsKnown) ; iter++ )
00143                                 {
00144                                         TCollection_AsciiString theCurrentExtension = theExtensions->Value(iter);
00145                                         if ( !theCurrentExtension.IsEmpty() )
00146                                         {
00147                                                 theCurrentExtension.LowerCase();
00148                                                 if ( theCurrentExtension == theExtension )
00149                                                 {
00150                                                         theFilenameIsKnown = Standard_True;
00151                                                 }
00152                                         }
00153                                 }
00154                         }
00155                 }
00156         }
00157 
00158 
00159         return theFilenameIsKnown;
00160 }

Generated on Wed Jan 23 12:16:41 2002 for exotk by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001