Changeset 859
- Timestamp:
- 01/25/08 20:19:39
- Files:
-
- trunk/include/vpb/BuildOptions (modified) (2 diffs)
- trunk/include/vpb/DataSet (modified) (3 diffs)
- trunk/include/vpb/Destination (modified) (1 diff)
- trunk/src/vpb/BuildOptions.cpp (modified) (2 diffs)
- trunk/src/vpb/BuildOptionsIO.cpp (modified) (1 diff)
- trunk/src/vpb/Commandline.cpp (modified) (1 diff)
- trunk/src/vpb/DataSet.cpp (modified) (10 diffs)
- trunk/src/vpb/Destination.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/vpb/BuildOptions
r857 r859 52 52 void setDirectory(const std::string& directory); 53 53 const std::string& getDirectory() const { return _directory; } 54 55 void setOutputTaskDirectories(bool flag) { _outputTaskDirectories = flag; } 56 bool getOutputTaskDirectories() const { return _outputTaskDirectories; } 54 57 55 58 void setDestinationTileBaseName(const std::string& basename) { _tileBasename = basename; } … … 278 281 std::string _destinationCoordinateSystemString; 279 282 std::string _directory; 283 bool _outputTaskDirectories; 280 284 std::string _imageExtension; 281 285 std::string _intermediateBuildName; trunk/include/vpb/DataSet
r854 r859 191 191 void setShapeFilePlacer(ObjectPlacer* placer) { _shapeFilePlacer = placer; } 192 192 ObjectPlacer* getShapeFilePlacer() { return _shapeFilePlacer.get(); } 193 194 195 std::string getTaskName(unsigned int level, unsigned int X, unsigned int Y) const; 196 std::string getSubtileName(unsigned int level, unsigned int X, unsigned int Y) const; 193 197 194 198 protected: … … 205 209 void _writeRow(Row& row); 206 210 void _buildDestination(bool writeToDisk); 211 int _run(); 207 212 208 213 void init(); … … 246 251 bool _newDestinationGraph; 247 252 253 std::string _taskOutputDirectory; 254 248 255 }; 249 256 trunk/include/vpb/Destination
r844 r859 276 276 bool areSubTilesComplete(); 277 277 std::string getSubTileName(); 278 std::string getExternalSubTileName(); 278 279 osg::Node* createPagedLODScene(); 279 280 osg::Node* createSubTileScene(); trunk/src/vpb/BuildOptions.cpp
r857 r859 37 37 _destinationCoordinateSystem->setEllipsoidModel(new osg::EllipsoidModel); 38 38 _directory = ""; 39 _outputTaskDirectories = false; 39 40 _geometryType = POLYGONAL; 40 41 _imageExtension = ".dds"; … … 106 107 _destinationCoordinateSystem = rhs._destinationCoordinateSystem; 107 108 _directory = rhs._directory; 109 _outputTaskDirectories = rhs._outputTaskDirectories; 108 110 _extents = rhs._extents; 109 111 _geometryType = rhs._geometryType; trunk/src/vpb/BuildOptionsIO.cpp
r857 r859 151 151 152 152 ADD_STRING_PROPERTY(Directory); 153 ADD_BOOL_PROPERTY(OutputTaskDirectories); 153 154 ADD_STRING_PROPERTY(DestinationTileBaseName); 154 155 ADD_STRING_PROPERTY(DestinationTileExtension); trunk/src/vpb/Commandline.cpp
r857 r859 656 656 while (arguments.read("-l",numLevels)) { buildOptions->setMaximumNumOfLevels(numLevels); } 657 657 658 while (arguments.read("--otd") || 659 arguments.read("--output-task-directories") || 660 arguments.read("--subtile-directories")) 661 { 662 buildOptions->setOutputTaskDirectories(true); 663 } 664 665 658 666 float verticalScale; 659 667 while (arguments.read("-v",verticalScale)) trunk/src/vpb/DataSet.cpp
r855 r859 147 147 double destination_yRange = _destinationExtents.yMax()-_destinationExtents.yMin(); 148 148 149 int Ck = pow(2.0, double(level-1)) * _C1;150 int Rk = pow(2.0, double(level-1)) * _R1;151 152 int i_min ( floor( ((extents.xMin() - _destinationExtents.xMin()) / destination_xRange) * double(Ck) ) );153 int j_min ( floor( ((extents.yMin() - _destinationExtents.yMin()) / destination_yRange) * double(Rk) ) );149 int Ck = int(pow(2.0, double(level-1))) * _C1; 150 int Rk = int(pow(2.0, double(level-1))) * _R1; 151 152 int i_min = int( floor( ((extents.xMin() - _destinationExtents.xMin()) / destination_xRange) * double(Ck) ) ); 153 int j_min = int( floor( ((extents.yMin() - _destinationExtents.yMin()) / destination_yRange) * double(Rk) ) ); 154 154 155 155 // note i_max and j_max are one beyond the extents required so that the below for loop can use < 156 156 // and the clamping to the 0..Ck-1 and 0..Rk-1 extents will work fine. 157 int i_max ( ceil( ((extents.xMax() - _destinationExtents.xMin()) / destination_xRange) * double(Ck) ) );158 int j_max ( ceil( ((extents.yMax() - _destinationExtents.yMin()) / destination_yRange) * double(Rk) ) );157 int i_max = int( ceil( ((extents.xMax() - _destinationExtents.xMin()) / destination_xRange) * double(Ck) ) ); 158 int j_max = int( ceil( ((extents.yMax() - _destinationExtents.yMin()) / destination_yRange) * double(Rk) ) ); 159 159 160 160 // clamp j range to 0 to Ck range … … 203 203 double tileSize = source->getType()==Source::IMAGE ? _maximumTileImageSize-2 : _maximumTileTerrainSize-1; 204 204 205 int k_cols ( ceil( 1.0 + ::log( destination_xRange / (_C1 * sourceResolutionX * tileSize ) ) / ::log(2.0) ) );206 int k_rows ( ceil( 1.0 + ::log( destination_yRange / (_R1 * sourceResolutionY * tileSize ) ) / ::log(2.0) ) );205 int k_cols = int( ceil( 1.0 + ::log( destination_xRange / (_C1 * sourceResolutionX * tileSize ) ) / ::log(2.0) ) ); 206 int k_rows = int( ceil( 1.0 + ::log( destination_yRange / (_R1 * sourceResolutionY * tileSize ) ) / ::log(2.0) ) ); 207 207 level = std::max(k_cols, k_rows); 208 208 level = std::min(level, int(source->getMaxLevel())); … … 301 301 double destination_yRange = _destinationExtents.yMax()-_destinationExtents.yMin(); 302 302 303 int Ck = pow(2.0, double(currentLevel-1)) * _C1;304 int Rk = pow(2.0, double(currentLevel-1)) * _R1;303 int Ck = int(pow(2.0, double(currentLevel-1))) * _C1; 304 int Rk = int(pow(2.0, double(currentLevel-1))) * _R1; 305 305 306 306 extents.xMin() = _destinationExtents.xMin() + (double(currentX)/double(Ck)) * destination_xRange; … … 1665 1665 { 1666 1666 osg::ref_ptr<osg::Node> node = parent->createSubTileScene(); 1667 std::string filename = _ directory+parent->getSubTileName();1667 std::string filename = _taskOutputDirectory+parent->getSubTileName(); 1668 1668 if (node.valid()) 1669 1669 { … … 1692 1692 osg::ref_ptr<osg::Node> node = cd->createPagedLODScene(); 1693 1693 1694 std::string filename; 1694 1695 if (cd->_level==0) 1695 1696 { 1697 filename = getDirectory() + _tileBasename + _tileExtension; 1698 1696 1699 if (_decorateWithCoordinateSystemNode) 1697 1700 { … … 1709 1712 } 1710 1713 } 1711 1712 std::string filename = _directory+_tileBasename+_tileExtension; 1714 else 1715 { 1716 filename = _taskOutputDirectory + _tileBasename + _tileExtension; 1717 } 1713 1718 1714 1719 if (node.valid()) … … 2418 2423 } 2419 2424 2425 std::string DataSet::getTaskName(unsigned int level, unsigned int X, unsigned int Y) const 2426 { 2427 if (level==0 && X==0 && Y==0) 2428 { 2429 std::ostringstream taskfile; 2430 taskfile<<_tileBasename<<"_root_L0_X0_Y0"; 2431 return taskfile.str(); 2432 } 2433 else 2434 { 2435 std::ostringstream taskfile; 2436 taskfile<<_tileBasename<<"_subtile_L"<<level<<"_X"<<X<<"_Y"<<Y; 2437 return taskfile.str(); 2438 } 2439 } 2440 2441 std::string DataSet::getSubtileName(unsigned int level, unsigned int X, unsigned int Y) const 2442 { 2443 std::ostringstream os; 2444 os << _tileBasename << "_L"<<level<<"_X"<<X<<"_Y"<<Y<<"_subtile"<<getDestinationTileExtension(); 2445 return os.str(); 2446 } 2420 2447 2421 2448 bool DataSet::generateTasks_new(TaskManager* taskManager) … … 2427 2454 if (!prepareForDestinationGraphCreation()) return false; 2428 2455 2429 log(osg::NOTICE,"OK, OK I now need something to do...");2430 2431 2456 selectAppropriateSplitLevels(); 2432 2457 … … 2683 2708 pushOperationLog(getBuildLog()); 2684 2709 } 2710 2711 int result = _run(); 2712 2713 if (getBuildLog()) 2714 { 2715 popOperationLog(); 2716 } 2717 2718 2719 return result; 2720 } 2721 2722 int DataSet::_run() 2723 { 2685 2724 2686 2725 bool requiresGraphicsContextInMainThread = true; … … 2751 2790 } 2752 2791 } 2792 2793 if (getOutputTaskDirectories()) 2794 { 2795 _taskOutputDirectory = getDirectory() + getTaskName(getSubtileLevel(), getSubtileX(), getSubtileY()); 2796 log(osg::NOTICE,"Need to create output task directory = %s", _taskOutputDirectory.c_str()); 2797 int result = 0; 2798 osgDB::FileType type = osgDB::fileType(_taskOutputDirectory); 2799 if (type==osgDB::DIRECTORY) 2800 { 2801 log(osg::NOTICE," Directory already created"); 2802 } 2803 else if (type==osgDB::REGULAR_FILE) 2804 { 2805 log(osg::NOTICE," Error cannot create directory as a conventional file already exists with that name"); 2806 result = 1; 2807 } 2808 else // FILE_NOT_FOUND 2809 { 2810 // need to create directory. 2811 result = mkdir(_taskOutputDirectory.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); 2812 } 2813 2814 if (result) 2815 { 2816 log(osg::NOTICE,"Error: could not create directory %i",errno); 2817 return 1; 2818 } 2819 2820 #ifdef WIN32 2821 _taskOutputDirectory.push_back('\\'); 2822 #else 2823 _taskOutputDirectory.push_back('/'); 2824 #endif 2825 2826 if (getGenerateSubtile()) log(osg::NOTICE,"We are a subtile"); 2827 if (getRecordSubtileFileNamesOnLeafTile()) log(osg::NOTICE,"We have to record ../task/name"); 2828 } 2829 else 2830 { 2831 _taskOutputDirectory = getDirectory(); 2832 } 2833 2834 log(osg::NOTICE,"Task output directory = %s", _taskOutputDirectory.c_str()); 2753 2835 2754 2836 writeDestination(); 2755 2837 } 2756 2838 2757 if (getBuildLog()) 2758 { 2759 popOperationLog(); 2760 } 2761 2762 return true; 2763 } 2839 return 0; 2840 } trunk/src/vpb/Destination.cpp
r848 r859 2709 2709 std::string CompositeDestination::getSubTileName() 2710 2710 { 2711 return _name+"_subtile"+_dataSet->getDestinationTileExtension(); 2712 } 2713 2711 std::string filename = _name+"_subtile"+_dataSet->getDestinationTileExtension(); 2712 log(osg::NOTICE,"CompositeDestination::getSubTileName()=%s",filename.c_str()); 2713 return filename; 2714 } 2715 2716 2717 std::string CompositeDestination::getExternalSubTileName() 2718 { 2719 std::string filename; 2720 2721 bool externalFile = _dataSet->getOutputTaskDirectories() && _dataSet->getRecordSubtileFileNamesOnLeafTile(); 2722 bool isLeaf = (_level == (_dataSet->getMaximumNumOfLevels()-1)); 2723 bool isRoot = (_level == 0); 2724 2725 if (externalFile && isRoot) 2726 { 2727 filename = _dataSet->getTaskName(_level,_tileX,_tileY) + std::string("/") + _name+"_subtile"+_dataSet->getDestinationTileExtension(); 2728 log(osg::NOTICE,"CompositeDestination::getExternalSubTileName()=%s ROOT!!",filename.c_str()); 2729 } 2730 else if (externalFile && isLeaf) 2731 { 2732 filename = std::string("../") + _dataSet->getTaskName(_level,_tileX,_tileY) + std::string("/") + _name+"_subtile"+_dataSet->getDestinationTileExtension(); 2733 log(osg::NOTICE,"CompositeDestination::getExternalSubTileName()=%s LEAF!!",filename.c_str()); 2734 } 2735 else 2736 { 2737 filename = _name+"_subtile"+_dataSet->getDestinationTileExtension(); 2738 log(osg::NOTICE,"CompositeDestination::getExternalSubTileName()=%s",filename.c_str()); 2739 } 2740 2741 return filename; 2742 } 2714 2743 2715 2744 osg::Node* CompositeDestination::createPagedLODScene() … … 2822 2851 pagedLOD->setRange(0,cutOffDistance,farDistance); 2823 2852 2824 pagedLOD->setFileName(1,get SubTileName());2853 pagedLOD->setFileName(1,getExternalSubTileName()); 2825 2854 pagedLOD->setRange(1,0,cutOffDistance); 2826 2855
