MacroSituation* Drainer::SolveMicro(MicroSituation& micro, MacroSituation* macroOld, Block blk) { if (micro[blk] == BlockStatus::Mine) return m_FailMacro; auto macro = new MacroSituation(*macroOld); OpenBlock(micro, macro, blk); if (macro->m_ToOpen == 0) { delete macro; return m_SucceedMacro; } while (true) { ASSERT((macro->m_Solver->GetSolvingState() & SolvingState::CanOpenForSure) == SolvingState::Stale); macro->m_Solver->Solve(SolvingState::Reduce | SolvingState::Overlap | SolvingState::Probability, true); if ((macro->m_Solver->GetSolvingState() & SolvingState::CanOpenForSure) == SolvingState::Stale) #ifdef _DEBUG { for (auto i = 0; i < macro->m_Degrees.size(); ++i) if (macro->m_Degrees[i] < 0 && macro->m_Solver->m_Manager[i] == BlockStatus::Blank) throw; return macro; } #else return macro; #endif #ifdef _DEBUG auto flag = false; #endif for (auto i = 0; i < macro->m_Degrees.size(); ++i) { if (macro->m_Degrees[i] >= 0 || macro->m_Solver->m_Manager[i] != BlockStatus::Blank) continue; OpenBlock(micro, macro, i); #ifdef _DEBUG flag = true; #endif if (macro->m_ToOpen == 0) { delete macro; return m_SucceedMacro; } } ASSERT(flag); } }
/* ======================== idRenderLog::StartFrame ======================== */ void idRenderLog::StartFrame() { if ( r_logFile.GetInteger() == 0 ) { return; } // open a new logfile indentLevel = 0; indentString[0] = '\0'; activeLevel = r_logLevel.GetInteger(); struct tm *newtime; time_t aclock; char ospath[ MAX_OSPATH ]; char qpath[128]; sprintf( qpath, "renderlogPC_%04i.txt", r_logFile.GetInteger() ); idStr finalPath = fileSystem->RelativePathToOSPath( qpath ); sprintf( ospath, "%s", finalPath.c_str() ); /* for ( int i = 0; i < 9999 ; i++ ) { char qpath[128]; sprintf( qpath, "renderlog_%04i.txt", r_logFile.GetInteger() ); idStr finalPath = fileSystem->RelativePathToOSPath( qpath ); fileSystem->RelativePathToOSPath( qpath, ospath, MAX_OSPATH ,FSPATH_BASE ); if ( !fileSystem->FileExists( finalPath.c_str() ) ) { break; // use this name } } */ common->SetRefreshOnPrint( false ); // problems are caused if this print causes a refresh... if ( logFile != NULL ) { fileSystem->CloseFile( logFile ); logFile = NULL; } logFile = fileSystem->OpenFileWrite( ospath ); if ( logFile == NULL ) { idLib::Warning( "Failed to open logfile %s", ospath ); return; } idLib::Printf( "Opened logfile %s\n", ospath ); // write the time out to the top of the file time( &aclock ); newtime = localtime( &aclock ); const char *str = asctime( newtime ); logFile->Printf( "// %s", str ); logFile->Printf( "// %s\n\n", com_version.GetString() ); frameStartTime = Sys_Microseconds(); closeBlockTime = frameStartTime; OpenBlock( "Frame" ); }
TInt CIniData::OpenAddBlock(const TDesC &aSection) /** Locates and opens a section for 'adds' @param aSection Section to work with @return ETrue if successful or EFalse */ { BlockState = E_ADD; return OpenBlock(aSection); }
TInt CIniData::OpenTemplateBlock(const TDesC &aSection) /** Locates and opens a section for 'template' @param aSection Section to work with @return ETrue if successful or EFalse */ { BlockState = E_TEMPLATE; return OpenBlock(aSection); }
void Drainer::OpenBlock(MicroSituation& micro, MacroSituation* macro, Block blk) { if (macro->m_Degrees[blk] >= 0) return; ASSERT(micro[blk] == BlockStatus::Blank); macro->m_Solver->AddRestrain(blk, false); auto degree = 0; for (auto b : m_BlocksR[blk]) if (micro[b] == BlockStatus::Mine) ++degree; macro->m_Degrees[blk] = degree; if (degree == 0) for (auto b : m_BlocksR[blk]) OpenBlock(micro, macro, b); else macro->m_Solver->AddRestrain(m_BlocksR[blk], degree); --macro->m_ToOpen; macro->Hash(); }
bool COntologyOBOImpl::OpenOntology( SParserOBO& sParser ) { size_t i, j, iParent; vector<vector<size_t> > vecveciChildren; g_CatSleipnir( ).info( "COntologyOBOImpl::OpenOntology( ) %s", sParser.m_szTarget ); Reset( ); sParser.m_vecvecstrParents.clear( ); sParser.m_vecNodes.clear( ); if( !( sParser.GetLine( ) && OpenHeader( sParser ) ) ) return false; while( sParser.m_istm.peek( ) != EOF ) if( !OpenBlock( sParser ) ) return false; m_aNodes = new SNode[ m_iNodes = sParser.m_vecNodes.size( ) ]; vecveciChildren.resize( m_iNodes ); for( i = 0; i < m_iNodes; ++i ) { m_aNodes[ i ] = sParser.m_vecNodes[ i ]; if( m_aNodes[ i ].m_iParents = sParser.m_vecvecstrParents[ i ].size( ) ) { m_aNodes[ i ].m_aiParents = new size_t[ m_aNodes[ i ].m_iParents ]; for( j = 0; j < m_aNodes[ i ].m_iParents; ++j ) { if( ( iParent = m_mapNodes[ sParser.m_vecvecstrParents[ i ][ j ] ] ) == i ) { g_CatSleipnir( ).error( "COntologyOBOImpl::OpenOntology( ) found a loop for node %d: %s has parent %s", i, m_aNodes[ i ].m_strID.c_str( ), sParser.m_vecvecstrParents[ i ][ j ].c_str( ) ); return false; } m_aNodes[ i ].m_aiParents[ j ] = iParent; vecveciChildren[ m_aNodes[ i ].m_aiParents[ j ] ].push_back( i ); } } } for( i = 0; i < m_iNodes; ++i ) { if( !vecveciChildren[ i ].size( ) ) continue; m_aNodes[ i ].m_aiChildren = new size_t[ m_aNodes[ i ].m_iChildren = vecveciChildren[ i ].size( ) ]; for( j = 0; j < m_aNodes[ i ].m_iChildren; ++j ) m_aNodes[ i ].m_aiChildren[ j ] = vecveciChildren[ i ][ j ]; } return true; }