347TEMP void THIS::DotWrite(
const std::string& rFileName)
const {
348 FD_DG(
"RabinAutomaton(" <<
this <<
")::DotWrite(" << rFileName <<
")");
350 if(BASE::ReindexOnWrite()) BASE::SetMinStateIndexMap();
352 StateSet::Iterator lit;
355 std::vector<std::string> ColorPalette;
356 ColorPalette.push_back(
"lightblue");
357 ColorPalette.push_back(
"darkblue");
358 ColorPalette.push_back(
"#ffcc80");
359 ColorPalette.push_back(
"#ff9900");
360 ColorPalette.push_back(
"#b0ffb0");
361 ColorPalette.push_back(
"#307030");
362 ColorPalette.push_back(
"#ff9090");
363 ColorPalette.push_back(
"#a00202");
364 ColorPalette.push_back(
"black");
365 if(2*THIS::RabinAcceptance().Size()>ColorPalette.size()-1) {
366 FD_DG(
"RabinAutomaton(" <<
this <<
")::DotWrite(...): to many Rabin pairs");
367 BASE::DotWrite(rFileName);
372 std::ofstream stream;
373 stream.exceptions(std::ios::badbit|std::ios::failbit);
376 stream.open(rFileName.c_str());
377 stream <<
"// dot output generated by libFAUDES RabinAutomaton" << std::endl;
378 stream <<
"digraph \"" << BASE::Name() <<
"\" {" << std::endl;
379 stream <<
" rankdir=LR" << std::endl;
381 stream <<
" node [shape=rectangle, style=rounded];" << std::endl;
385 stream <<
" // initial states" << std::endl;
387 for (lit = BASE::InitStatesBegin(); lit != BASE::InitStatesEnd(); ++lit) {
388 std::string xname= BASE::StateName(*lit);
389 if(xname==
"") xname=
ToStringInteger(
static_cast<long int>(BASE::MinStateIndex(*lit)));
390 stream <<
" dot_dummyinit_" << i <<
" [shape=none, label=\"\" ];" << std::endl;
391 stream <<
" dot_dummyinit_" << i <<
" -> \"" << xname <<
"\";" << std::endl;
398 RabinAcceptance::CIterator rit;
399 for(rit=THIS::RabinAcceptance().Begin();rit!=THIS::RabinAcceptance().End();++rit) {
400 marked = marked + rit->ISet();
401 marked = marked + rit->RSet();
406 stream <<
" // plain states" << std::endl;
407 for (lit = BASE::pStates->Begin(); lit != BASE::pStates->End(); ++lit) {
408 if(marked.
Exists(*lit))
continue;
409 std::string xname=BASE::StateName(*lit);
411 stream <<
" \"" << xname <<
"\";" << std::endl;
416 stream <<
" // colored states" << std::endl;
417 for (lit = marked.
Begin(); lit != marked.
End(); ++lit) {
418 std::string xname=BASE::StateName(*lit);
419 if(xname==
"") xname=
ToStringInteger(
static_cast<long int>(BASE::MinStateIndex(*lit)));
420 stream <<
" \"" << xname <<
"\"";
422 RabinAcceptance::CIterator rit;
423 std::vector<int> colvec;
425 for(rit=THIS::RabinAcceptance().Begin();rit!=THIS::RabinAcceptance().End();++rit) {
426 if(rit->ISet().Exists(*lit)) colvec.push_back(col);
427 if(rit->RSet().Exists(*lit)) colvec.push_back(col+1);
431 if(this->ExistsMarkedState(*lit))
432 colvec.push_back(ColorPalette.size()-1);
434 stream <<
" [label=<<TABLE BORDER=\"0\"><TR>";
436 stream <<
"<TD>" << xname <<
"</TD>";
438 stream <<
"<TD WIDTH=\"5\"></TD>";
441 for(i=0;i<colvec.size();++i) {
442 stream <<
"<TD BGCOLOR=\"" << ColorPalette.at(colvec.at(i)) <<
"\" BORDER=\"0\" WIDTH=\"10\"></TD>";
445 stream <<
"</TR></TABLE>>";
446 stream <<
"];" << std::endl;
450 stream <<
" // transition relation" << std::endl;
452 for(tit = trx1x2ev.
Begin(); tit != trx1x2ev.
End();) {
454 if(!elabel.empty()) elabel = elabel +
", ";
455 if(elabel.length()>9) elabel = elabel +
"\n";
456 elabel=elabel + BASE::EventName(tit->Ev);
462 if(tit==trx1x2ev.
End())
465 flush=((tit->X1 != x1) || (tit->X2 != x2));
468 std::string x1name= BASE::StateName(x1);
470 std::string x2name= BASE::StateName(x2);
472 stream <<
" \"" << x1name <<
"\" -> \"" << x2name
473 <<
"\" [label=\"" << elabel <<
"\"];" << std::endl;
479 stream <<
"}" << std::endl;
482 catch (std::ios::failure&) {
484 "Exception opening/writing dotfile \""+rFileName+
"\"", 3);
486 BASE::ClearMinStateIndexMap();