![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2003 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: terrainDbFactory.h,v $ $Revision: 1.18 $ $State: Exp $ 00007 *******************************************************************************/ 00008 #ifndef terrainDbFactory_H_ 00009 #define terrainDbFactory_H_ 00010 00011 // \file terrainFactory.h 00012 // The file contains the terrain database factory, which is used to create 00013 // the appropriate terrain importers and exporters depending on the types of 00014 // terrain files to import and export. 00015 // 00016 00017 #include "terrainDbFactory/terrainDbFactoryDefines.h" 00018 #include <vlutil/vlHashlist.h> 00019 #include <vlutil/vlFilename.h> 00020 #include <vector> 00021 00022 class DtTerrainDatabase; 00023 class DtPaperMapDatabase; 00024 class DtPaperMap; 00025 class DtTerrainReader; 00026 class DtMetafileRecord; 00027 class DtVectorDataReader; 00028 class DtTerrainReaderFactory; 00029 class DtTdbMetafileFactory; 00030 class DtPaperMapFactory; 00031 class DtVectorDataFactory; 00032 class DtTerrainWriterFactory; 00033 class Coordinate_System; 00034 00035 // 00036 // DtTerrainDbFactory are two containers of DtTerrainFactoryEntries and 00037 // DtPaperMapFactoryEntries indexed by the DtString type that represents the 00038 // type of file able to load. 00039 class DT_DLL_terrainDbFactory DtTerrainDbFactory 00040 { 00041 public: 00042 // constructor 00043 DtTerrainDbFactory(); 00044 00045 // copy constructor 00046 DtTerrainDbFactory(const DtTerrainDbFactory& orig); 00047 00048 // assignment operator 00049 const DtTerrainDbFactory& operator=(const DtTerrainDbFactory& orig); 00050 00051 // Destructor: deletes factory and any entries on the factory. 00052 virtual ~DtTerrainDbFactory(); 00053 00054 00055 // creates the factories calling the functions for each one 00056 // and initialize them with default functions. 00057 // The functions are used in this order 00058 00059 // because the last three need a metafile factory. 00060 virtual void init(); 00061 00062 00063 // function to set/get the factories. 00064 // For metafile factory, it replace it into the other factories. 00065 virtual void setTerrainReaderFactory(DtTerrainReaderFactory* factory); 00066 virtual DtTerrainReaderFactory *terrainReaderFactory(); 00067 00068 virtual void setTerrainWriterFactory(DtTerrainWriterFactory* factory); 00069 virtual DtTerrainWriterFactory *terrainWriterFactory(); 00070 00071 virtual void setMetafileFactory(DtTdbMetafileFactory* factory); 00072 virtual DtTdbMetafileFactory *metafileFactory(); 00073 00074 virtual void setPaperMapFactory(DtPaperMapFactory* factory); 00075 virtual DtPaperMapFactory *paperMapFactory(); 00076 00077 virtual void setVectorDataFactory(DtVectorDataFactory* factory); 00078 virtual DtVectorDataFactory *vectorDataFactory(); 00079 00080 // creator functions callers 00081 00082 virtual DtTerrainReader* createTerrainReader(const DtString &type); 00083 00084 virtual DtPaperMap* createPaperMap(const DtString &type); 00085 00086 virtual DtVectorDataReader* createVectorDataReader(const DtString &type); 00087 00088 // Loads terrain database file fileName, returning data in terrain. 00089 // terrain must point to a newly created and initialized 00090 // DtTerrainDatabase object before it is passed into this function. 00091 // Creates and returns a DtPaperMapDatabase object in paperMapDatabase, 00092 // if paper maps are specified in the incoming terrain database file. 00093 // searchPaths is a list DtString*s, holding a list of locations in which 00094 // to search for the given fileName on the file system. 00095 // If there is not enough memory to load the database, it throws std::bad_alloc 00096 // \throws std::bad_alloc 00097 virtual bool loadDatabase(const DtFilename& fileName, 00098 DtTerrainDatabase* terrain, DtPaperMapDatabase*& paperMapDatabase, 00099 const DtList& searchPaths); 00100 00101 // Loads terrain database file fileName, returning data in terrain. 00102 // terrain must point to a newly created and initialized 00103 // DtTerrainDatabase object before it is passed into this function. 00104 // Creates and returns a DtPaperMapDatabase object in paperMapDatabase, 00105 // if paper maps are specified in the incoming terrain database file. 00106 // If there is not enough memory to load the database, it throws std::bad_alloc 00107 // \throws std::bad_alloc 00108 virtual bool loadDatabase(const DtFilename& fileName, 00109 DtTerrainDatabase* terrain, DtPaperMapDatabase * &paperMapDatabase,const DtFilename & path=DtFilename::nullFilename()); 00110 00111 // Given the specified filename, determines and returns the extension. 00112 // @return The extension of the specified filename, which is defined as the 00113 // string after, but not containing, the last '.' in the filename. 00114 // 00115 // @note If the filename is "geodetic" then the extension returned will be 00116 // "geodetic". 00117 virtual const DtString determineFileExtension(const DtFilename& filename); 00118 00119 // Loads the specified .map file into the specified terrain database. 00120 // @return A boolean indicating success or failure in loading the .map 00121 // terrain file. 00122 // If there is not enough memory to load the database, it throws std::bad_alloc 00123 // \throws std::bad_alloc 00124 virtual bool loadMapTerrainFile(DtTerrainDatabase& terrainDb, 00125 DtPaperMapDatabase*& paperMapDatabase, const DtFilename& filename, 00126 const std::vector<DtFilename>& paths, const DtString& extension); 00127 00128 // Loads the specified non-map (.gdb) file into the specified terrain database. 00129 // @return A boolean indicating success or failure in loading the terrain file. 00130 // If there is not enough memory to load the database, it throws std::bad_alloc 00131 // \throws std::bad_alloc 00132 virtual bool loadNonMapTerrainFile(DtTerrainDatabase& terrainDb, 00133 const DtFilename& filename, const DtString& extension); 00134 00135 // Apply simple processing to the database, such as reducing vertices 00136 // and creating a spatial subdivision is none exists. 00137 virtual bool processTerrainDatabase(DtTerrainDatabase& terrainDb); 00138 00139 virtual bool saveDatabase(const DtFilename& fileName, DtTerrainDatabase *terrain); 00140 00141 static DtTerrainDbFactory* create(); 00142 00143 // Calls down to appropriate terrain loader to return optional file flags. Will not load 00144 // terrain vectors or polygons 00145 virtual int optionalFileFlagsFromTerrainMapFile(const DtFilename& filename, 00146 const std::vector<DtFilename>& searchPaths, const DtString& extension); 00147 00148 // Calls down to appropriate terrain loader to return optional file flags. Will not load 00149 // terrain vectors or polygons 00150 // @return Optional file flags from file 00151 virtual int optionalFileFlagsFromTerrainFile(const DtFilename& filename, const DtString& extension); 00152 00153 // Returns a newly instantiated coordiate system for the specified terrain. This call should not load 00154 // any of the underlying vector or polygon information 00155 virtual Coordinate_System* coordinateSystemFor(const DtFilename& fileName, const DtFilename & path=DtFilename::nullFilename()); 00156 00157 // Figures out the terrain to load then calls coordinateSystemFromTerrainFile 00158 // @return Coordinate_System that needs to be deleted by caller 00159 virtual Coordinate_System* coordinateSystemFromTerrainMapFile(const DtFilename& filename, 00160 const std::vector<DtFilename>& searchPaths, const DtString& extension); 00161 00162 // Calls down to appropriate terrain loader to return a newly allocated coordinate system. Will not load 00163 // terrain vectors or polygons 00164 // @return Coordinate_System that needs to be deleted by caller 00165 virtual Coordinate_System* coordinateSystemFromTerrainFile(const DtFilename& filename, const DtString& extension); 00166 00167 // Returns true if any of the specified flags are set in the database 00168 // @return True/false depending on whether or not flags are set 00169 virtual bool hasOptionalFlags(int flags, const DtFilename& filename, const DtFilename & path=DtFilename::nullFilename()); 00170 00171 // Returns the path that contains the filename from the searchpaths 00172 virtual DtFilename pathFromFilename(const std::vector<DtFilename>& searchPaths, const DtFilename& filename); 00173 00174 protected: 00175 00176 DtTerrainReaderFactory *myTerrainReaderFactory; 00177 DtTerrainWriterFactory *myTerrainWriterFactory; 00178 DtTdbMetafileFactory *myMetafileFactory; 00179 DtPaperMapFactory *myPaperMapFactory; 00180 DtVectorDataFactory *myVectorDataFactory; 00181 }; 00182 00183 #endif 00184 00185