Changeset 859

Show
Ignore:
Timestamp:
01/25/08 20:19:39
Author:
robert
Message:

Added support for --output-task-directories (also can use --otd) when generating vpbmaster builds.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/vpb/BuildOptions

    r857 r859  
    5252        void setDirectory(const std::string& directory); 
    5353        const std::string& getDirectory() const { return _directory; } 
     54 
     55        void setOutputTaskDirectories(bool flag) { _outputTaskDirectories = flag; } 
     56        bool getOutputTaskDirectories() const { return _outputTaskDirectories; } 
    5457 
    5558        void setDestinationTileBaseName(const std::string& basename) { _tileBasename = basename; } 
     
    278281        std::string                                 _destinationCoordinateSystemString; 
    279282        std::string                                 _directory; 
     283        bool                                        _outputTaskDirectories; 
    280284        std::string                                 _imageExtension; 
    281285        std::string                                 _intermediateBuildName; 
  • trunk/include/vpb/DataSet

    r854 r859  
    191191        void setShapeFilePlacer(ObjectPlacer* placer) { _shapeFilePlacer = placer; } 
    192192        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; 
    193197 
    194198    protected: 
     
    205209        void _writeRow(Row& row); 
    206210        void _buildDestination(bool writeToDisk); 
     211        int _run(); 
    207212         
    208213        void init(); 
     
    246251        bool                                        _newDestinationGraph; 
    247252         
     253        std::string                                 _taskOutputDirectory; 
     254         
    248255}; 
    249256 
  • trunk/include/vpb/Destination

    r844 r859  
    276276    bool areSubTilesComplete(); 
    277277    std::string getSubTileName(); 
     278    std::string getExternalSubTileName(); 
    278279    osg::Node* createPagedLODScene(); 
    279280    osg::Node* createSubTileScene(); 
  • trunk/src/vpb/BuildOptions.cpp

    r857 r859  
    3737    _destinationCoordinateSystem->setEllipsoidModel(new osg::EllipsoidModel); 
    3838    _directory = ""; 
     39    _outputTaskDirectories = false; 
    3940    _geometryType = POLYGONAL; 
    4041    _imageExtension = ".dds"; 
     
    106107    _destinationCoordinateSystem = rhs._destinationCoordinateSystem; 
    107108    _directory = rhs._directory; 
     109    _outputTaskDirectories = rhs._outputTaskDirectories; 
    108110    _extents = rhs._extents; 
    109111    _geometryType = rhs._geometryType; 
  • trunk/src/vpb/BuildOptionsIO.cpp

    r857 r859  
    151151 
    152152        ADD_STRING_PROPERTY(Directory); 
     153        ADD_BOOL_PROPERTY(OutputTaskDirectories); 
    153154        ADD_STRING_PROPERTY(DestinationTileBaseName); 
    154155        ADD_STRING_PROPERTY(DestinationTileExtension); 
  • trunk/src/vpb/Commandline.cpp

    r857 r859  
    656656    while (arguments.read("-l",numLevels)) { buildOptions->setMaximumNumOfLevels(numLevels); } 
    657657 
     658    while (arguments.read("--otd") ||  
     659           arguments.read("--output-task-directories") || 
     660           arguments.read("--subtile-directories")) 
     661    { 
     662        buildOptions->setOutputTaskDirectories(true); 
     663    } 
     664 
     665 
    658666    float verticalScale; 
    659667    while (arguments.read("-v",verticalScale)) 
  • trunk/src/vpb/DataSet.cpp

    r855 r859  
    147147    double destination_yRange = _destinationExtents.yMax()-_destinationExtents.yMin(); 
    148148 
    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) ) ); 
    154154 
    155155    // note i_max and j_max are one beyond the extents required so that the below for loop can use < 
    156156    // 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) ) ); 
    159159 
    160160    // clamp j range to 0 to Ck range 
     
    203203    double tileSize = source->getType()==Source::IMAGE ? _maximumTileImageSize-2 : _maximumTileTerrainSize-1; 
    204204 
    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) ) ); 
    207207    level = std::max(k_cols, k_rows); 
    208208    level = std::min(level, int(source->getMaxLevel())); 
     
    301301        double destination_yRange = _destinationExtents.yMax()-_destinationExtents.yMin(); 
    302302 
    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; 
    305305         
    306306        extents.xMin() = _destinationExtents.xMin() + (double(currentX)/double(Ck)) * destination_xRange; 
     
    16651665                { 
    16661666                    osg::ref_ptr<osg::Node> node = parent->createSubTileScene(); 
    1667                     std::string filename = _directory+parent->getSubTileName(); 
     1667                    std::string filename = _taskOutputDirectory+parent->getSubTileName(); 
    16681668                    if (node.valid()) 
    16691669                    { 
     
    16921692            osg::ref_ptr<osg::Node> node = cd->createPagedLODScene(); 
    16931693             
     1694            std::string filename; 
    16941695            if (cd->_level==0) 
    16951696            { 
     1697                filename = getDirectory() + _tileBasename + _tileExtension;     
     1698 
    16961699                if (_decorateWithCoordinateSystemNode) 
    16971700                { 
     
    17091712                } 
    17101713            } 
    1711  
    1712             std::string filename = _directory+_tileBasename+_tileExtension; 
     1714            else 
     1715            { 
     1716                filename = _taskOutputDirectory + _tileBasename + _tileExtension;     
     1717            } 
    17131718 
    17141719            if (node.valid()) 
     
    24182423} 
    24192424 
     2425std::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 
     2441std::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} 
    24202447 
    24212448bool DataSet::generateTasks_new(TaskManager* taskManager) 
     
    24272454    if (!prepareForDestinationGraphCreation()) return false; 
    24282455 
    2429     log(osg::NOTICE,"OK, OK I now need something to do..."); 
    2430      
    24312456    selectAppropriateSplitLevels(); 
    24322457     
     
    26832708        pushOperationLog(getBuildLog()); 
    26842709    } 
     2710 
     2711    int result = _run(); 
     2712     
     2713    if (getBuildLog()) 
     2714    { 
     2715        popOperationLog(); 
     2716    } 
     2717 
     2718     
     2719    return result; 
     2720} 
     2721 
     2722int DataSet::_run() 
     2723{ 
    26852724     
    26862725    bool requiresGraphicsContextInMainThread = true; 
     
    27512790            } 
    27522791        } 
     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()); 
    27532835 
    27542836        writeDestination(); 
    27552837    } 
    27562838 
    2757     if (getBuildLog()) 
    2758     { 
    2759         popOperationLog(); 
    2760     } 
    2761  
    2762     return true; 
    2763 
     2839    return 0; 
     2840
  • trunk/src/vpb/Destination.cpp

    r848 r859  
    27092709std::string CompositeDestination::getSubTileName() 
    27102710{ 
    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 
     2717std::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
    27142743 
    27152744osg::Node* CompositeDestination::createPagedLODScene() 
     
    28222851    pagedLOD->setRange(0,cutOffDistance,farDistance); 
    28232852     
    2824     pagedLOD->setFileName(1,getSubTileName()); 
     2853    pagedLOD->setFileName(1,getExternalSubTileName()); 
    28252854    pagedLOD->setRange(1,0,cutOffDistance); 
    28262855