// Set libplot's filling-and-edging style. May set the line width to zero // to turn off edging. In libplot, a 0-width line is as narrow a line as // can be drawn. void drvplot::set_filling_and_edging_style() { switch (currentShowType()) { case drvbase::stroke: (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->filltype(0); // no filling break; case drvbase::fill: if (pathWasMerged()) { (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(edgeR()), plotcolor(edgeG()), plotcolor(edgeB())); (void)plotter->fillcolor(plotcolor(fillR()), plotcolor(fillG()), plotcolor(fillB())); } else { (void)plotter->flinewidth(0.0); // little or no edging (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->fillcolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); } (void)plotter->filltype(1); (void)plotter->fillmod("winding"); break; case drvbase::eofill: if (pathWasMerged()) { (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(edgeR()), plotcolor(edgeG()), plotcolor(edgeB())); (void)plotter->fillcolor(plotcolor(fillR()), plotcolor(fillG()), plotcolor(fillB())); } else { (void)plotter->flinewidth(0.0); // little or no edging (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->fillcolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); } (void)plotter->filltype(1); (void)plotter->fillmod("even-odd"); break; default: // cannot happen errf << "unexpected ShowType " << (int) currentShowType(); break; } }
// Version with multi-segment lines void drvVTK::print_coords() { int bp = 0; colorStream << fillR() << " " << fillG() << " " << fillB() << " 0.5" << endl; polyStream << numberOfElementsInPath() << " " ; linepoints += numberOfElementsInPath(); lineCount++; for (unsigned int n = 0; n < numberOfElementsInPath(); n++) { const basedrawingelement & elem = pathElement(n); switch (elem.getType()) { case moveto:{ const Point & p = elem.getPoint(0); const int m = add_point(p); polyStream << m-1 << " "; bp = m; } break; case lineto:{ const Point & p = elem.getPoint(0); const int l = add_point(p); polyStream << l-1 << " "; } break; case closepath: polyStream << bp-1 << " "; break; case curveto:{ errf << "\t\tFatal: unexpected case in drvVTK - curveto " << endl; } break; default: errf << "\t\tFatal: unexpected case in drvVTK : default" << endl; abort(); break; } } polyStream << endl; }
void drvSAMPL::show_path() { outf << "Path # " << currentNr(); if (isPolygon()) outf << " (polygon): " << endl; else outf << " (polyline): " << endl; outf << "\tcurrentShowType: "; switch (currentShowType()) { case drvbase::stroke: outf << "stroked"; break; case drvbase::fill: outf << "filled"; break; case drvbase::eofill: outf << "eofilled"; break; default: // cannot happen outf << "unexpected ShowType " << (int) currentShowType(); break; } outf << endl; outf << "\tcurrentLineWidth: " << currentLineWidth() << endl; outf << "\tcurrentR: " << currentR() << endl; outf << "\tcurrentG: " << currentG() << endl; outf << "\tcurrentB: " << currentB() << endl; outf << "\tedgeR: " << edgeR() << endl; outf << "\tedgeG: " << edgeG() << endl; outf << "\tedgeB: " << edgeB() << endl; outf << "\tfillR: " << fillR() << endl; outf << "\tfillG: " << fillG() << endl; outf << "\tfillB: " << fillB() << endl; outf << "\tcurrentLineCap: " << currentLineCap() << endl; outf << "\tdashPattern: " << dashPattern() << endl; outf << "\tPath Elements 0 to " << numberOfElementsInPath() - 1 << endl; print_coords(); }
void drvCAIRO::show_path() { DashPattern dp(dashPattern()); outf << endl; outf << " /*" << endl; outf << " * Path # " << currentNr() ; if (isPolygon()) outf << " (polygon):" << endl; else outf << " (polyline):" << endl; outf << " */" << endl; outf << endl; outf << " cairo_save (cr);" << endl; outf << " cairo_set_line_width (cr, " << currentLineWidth() << ");" << endl; // CAIRO_LINE_CAP_BUTT - start(stop) the line exactly at the start(end) point // CAIRO_LINE_CAP_ROUND - use a round ending, the center of the circle is the end point // CAIRO_LINE_CAP_SQUARE - use squared ending, the center of the square is the end point outf << " cairo_set_line_cap (cr, "; switch( currentLineCap() ) { case 0: outf << "CAIRO_LINE_CAP_BUTT);" << endl; break; case 1: outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; case 2: outf << "CAIRO_LINE_CAP_SQUARE);" << endl; break; default: errf << "Unexpected currentLineCap() in cairo driver: " << currentLineCap() << endl; outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; } // cairo_set_dash (cairo_t *cr, const double *dashes, int num_dashes, double offset); // dashes : // an array specifying alternate lengths of on and off stroke portions // // num_dashes : // the length of the dashes array // // offset : // an offset into the dash pattern at which the stroke should start // // dashPattern: has nrOfEntries, float *numbers, float offset if (dp.nrOfEntries > 0) { outf << " {" << endl; outf << " double pat[" << dp.nrOfEntries << "] = {" << endl; for (int i = 0; i < dp.nrOfEntries; i++) { outf << " " << dp.numbers[i] << ", " << endl; } outf << " };" << endl; outf << endl; outf << " cairo_set_dash (cr, pat, " << dp.nrOfEntries << ", " << dp.offset << ");" << endl; outf << " }" << endl; } else { outf << " cairo_set_dash (cr, NULL, 0, 0.0);" << endl; } // cairo_move_to (cr, 0.25, 0.25); // cairo_line_to (cr, 0.5, 0.375); outf << " /* Path Elements 0 to " << numberOfElementsInPath() - 1 << " */" << endl; print_coords(); switch (currentShowType()) { case drvbase::stroke: outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; case drvbase::eofill: outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);" << endl; evenoddmode = true; case drvbase::fill: outf << " cairo_set_source_rgb (cr, " << fillR() << "," << fillG() << "," << fillB() << ");" << endl; outf << " cairo_fill_preserve (cr);" << endl; if (evenoddmode) { outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);" << endl; evenoddmode = false; } outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; default: // cannot happen outf << " // unexpected ShowType " << (int) currentShowType(); break; } outf << " cairo_restore (cr);" << endl; }
void RKWidget::step ( const size_t nStep ) { DNformat *Bstore; DNformat *Xstore; double temp; if(unstable) return; samset = false; if( dirty ) { if(aexist) { Destroy_CompCol_Matrix(&A); if ( lwork == 0 ) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&Up); } else if ( lwork > 0 ) { SUPERLU_FREE(work); } // these may be freed in dgssvx or Destroy_CompCol_Matrix I think aexist = false; } a = new double[nvar*N_]; xa = new int[N_+1]; asub = new int[nvar*N_]; updateCoef(method); if(nblock == 1) { // load with coef[] ??? fillA(); } else if (nup+ndn == 0) { // solve seperate independent blocks??? } else { // load block system blockFillA(); } dCreate_CompCol_Matrix(&A, N_, N_, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE); aexist = true; /* Initialize the statistics variables. */ StatInit(&stat); dPrint_CompCol_Matrix("A matrix", &A); options.Fact = DOFACT; //options.ColPerm=NATURAL; options.ColPerm=COLAMD; options.PivotGrowth = NO; options.ConditionNumber = NO; /* ONLY PERFORM THE LU DECOMPOSITION */ B.ncol = 0; /* Indicate not to solve the system */ dgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &Up, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); //dPrint_CompCol_Matrix("A matrix", &A); printf("LU factorization: dgssvx() returns info %d\n", info); if ( info == 0 || info == N_+1 ) { if ( options.PivotGrowth ) printf("Recip. pivot growth = %e\n", rpg); if ( options.ConditionNumber ) printf("Recip. condition number = %e\n", rcond); printf("L\\U_ MB %.3f\ttotal MB needed %.3f\n", mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); fflush(stdout); options.Fact = FACTORED; /* Indicate the factored form of A is supplied. */ B.ncol = 1; dirty = false; } else if ( info > 0 && lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); } if ( options.PrintStat ) StatPrint(&stat); StatFree(&stat); } for ( size_t n = 0; n < nStep; n++ ) { for( int ns = 0; ns < nStage; ns++ ) { ///set B matrix Bstore= (DNformat *)B.Store; rhsb=(double*)Bstore->nzval; if (nup+ndn == 0) { // solve seperate independent blocks??? std::cout << "Discontinuous Galerkin Not Implimented\n"; return; } else { fillB(ns); } ///solve factored system StatInit(&stat); options.Fact = FACTORED; dgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &Up, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); //if( n == 1 ) printf("Triangular solve: dgssvx() returns info %d\n", info); ///update U_ if ( info == 0 || info == N_+1 ) { /* This is how you could access the solution matrix. */ Xstore = (DNformat *)X.Store; rhsx = (double*)(Xstore->nzval); for ( size_t i = 0; i < N_ ; i++ ) { if(rhsx[i]> 1e16) unstable = true; b_k[i+N_*ns]=rhsx[i]; } } else { std::cout << "ERROR: Matrix Solution Failed info = " << info << std::endl; } StatFree(&stat); } for(int j=0 ; j<nStage; j++) { temp=b_b[j]; if( temp != 0 ) { for(size_t i = 0; i < N_ ; i++ ) { U_[i] += temp*b_k[i+j*N_]; } } } cStep++; totCFL += CFL; } }