/* * top-level compilation; break the document into * style, html, and source blocks with footnote links * weeded out. */ static Paragraph * compile_document(Line *ptr, MMIOT *f) { ParagraphRoot d = { 0, 0 }; ANCHOR(Line) source = { 0, 0 }; Paragraph *p = 0; struct kw *tag; int eaten, unclosed; while ( ptr ) { if ( !(f->flags & MKD_NOHTML) && (tag = isopentag(ptr)) ) { int blocktype; /* If we encounter a html/style block, compile and save all * of the cached source BEFORE processing the html/style. */ if ( T(source) ) { E(source)->next = 0; p = Pp(&d, 0, SOURCE); p->down = compile(T(source), 1, f); T(source) = E(source) = 0; } if ( f->flags & MKD_NOSTYLE ) blocktype = HTML; else blocktype = strcmp(tag->id, "STYLE") == 0 ? STYLE : HTML; p = Pp(&d, ptr, blocktype); ptr = htmlblock(p, tag, &unclosed); if ( unclosed ) { p->typ = SOURCE; p->down = compile(p->text, 1, f); p->text = 0; } } else if ( isfootnote(ptr) ) { /* footnotes, like cats, sleep anywhere; pull them * out of the input stream and file them away for * later processing */ ptr = consume(addfootnote(ptr, f), &eaten); } else { /* source; cache it up to wait for eof or the * next html/style block */ ATTACH(source,ptr); ptr = ptr->next; } } if ( T(source) ) { /* if there's any cached source at EOF, compile * it now. */ E(source)->next = 0; p = Pp(&d, 0, SOURCE); p->down = compile(T(source), 1, f); } return T(d); }
static Line * enumerated_block(Paragraph *top, int clip, MMIOT *f, int list_class) { ParagraphRoot d = { 0, 0 }; Paragraph *p; Line *q = top->text, *text; int para = 0, z; while (( text = q )) { p = Pp(&d, text, LISTITEM); text = listitem(p, clip, f->flags, 0); p->down = compile(p->text, 0, f); p->text = 0; if ( para && p->down ) p->down->align = PARA; if ( (q = skipempty(text)) == 0 || islist(q, &clip, f->flags, &z) != list_class ) break; if ( para = (q != text) ) { Line anchor; anchor.next = text; ___mkd_freeLineRange(&anchor, q); if ( p->down ) p->down->align = PARA; } } top->text = 0; top->down = T(d); return text; }
static Paragraph * fencedcodeblock(ParagraphRoot *d, Line **ptr) { Line *first, *r; Paragraph *ret; first = (*ptr); /* don't allow zero-length code fences */ if ( (first->next == 0) || iscodefence(first->next, first->count, 0) ) return 0; /* find the closing fence, discard the fences, * return a Paragraph with the contents */ for ( r = first; r && r->next; r = r->next ) if ( iscodefence(r->next, first->count, first->kind) ) { (*ptr) = r->next->next; ret = Pp(d, first->next, CODE); if (S(first->text) - first->count > 0) { char *lang_attr = T(first->text) + first->count; while ( *lang_attr != 0 && *lang_attr == ' ' ) lang_attr++; ret->lang = strdup(lang_attr); } else { ret->lang = 0; } ___mkd_freeLine(first); ___mkd_freeLine(r->next); r->next = 0; return ret; } return 0; }
static Paragraph * fencedcodeblock(ParagraphRoot *d, Line **ptr) { Line *first, *r; Paragraph *ret; first = (*ptr); /* don't allow zero-length code fences */ if ( (first->next == 0) || iscodefence(first->next, first->count) ) return 0; /* find the closing fence, discard the fences, * return a Paragraph with the contents */ for ( r = first; r && r->next; r = r->next ) if ( iscodefence(r->next, first->count) ) { (*ptr) = r->next->next; ret = Pp(d, first->next, CODE); ___mkd_freeLine(first); ___mkd_freeLine(r->next); r->next = 0; return ret; } return 0; }
void Triangulator::triangulateFromUpVp(cv::Mat &up, cv::Mat &vp, cv::Mat &xyz){ std::cerr << "WARNING! NOT FULLY IMPLEMENTED!" << std::endl; int N = up.rows * up.cols; cv::Mat projPointsCam(2, N, CV_32F); uc.reshape(0,1).copyTo(projPointsCam.row(0)); vc.reshape(0,1).copyTo(projPointsCam.row(1)); cv::Mat projPointsProj(2, N, CV_32F); up.reshape(0,1).copyTo(projPointsProj.row(0)); vp.reshape(0,1).copyTo(projPointsProj.row(1)); cv::Mat Pc(3,4,CV_32F,cv::Scalar(0.0)); cv::Mat(calibration.Kc).copyTo(Pc(cv::Range(0,3), cv::Range(0,3))); cv::Mat Pp(3,4,CV_32F), temp(3,4,CV_32F); cv::Mat(calibration.Rp).copyTo(temp(cv::Range(0,3), cv::Range(0,3))); cv::Mat(calibration.Tp).copyTo(temp(cv::Range(0,3), cv::Range(3,4))); Pp = cv::Mat(calibration.Kp) * temp; cv::Mat xyzw; cv::triangulatePoints(Pc, Pp, projPointsCam, projPointsProj, xyzw); xyz.create(3, N, CV_32F); for(int i=0; i<N; i++){ xyz.at<float>(0,i) = xyzw.at<float>(0,i)/xyzw.at<float>(3,i); xyz.at<float>(1,i) = xyzw.at<float>(1,i)/xyzw.at<float>(3,i); xyz.at<float>(2,i) = xyzw.at<float>(2,i)/xyzw.at<float>(3,i); } xyz = xyz.t(); xyz = xyz.reshape(3, up.rows); }
/// Legendre polynomials. double legendre_p(unsigned int l, double x) { std::vector<double> P(l), Pp(l); ::legendre_poly(l, x, P.data(), Pp.data()); return P[l]; }
static Line * definition_block(Paragraph *top, int clip, MMIOT *f, int kind) { ParagraphRoot d = { 0, 0 }; Paragraph *p; Line *q = top->text, *text = 0, *labels; int z, para; while (( labels = q )) { if ( (q = isdefinition(labels, &z, &kind)) == 0 ) break; if ( (text = skipempty(q->next)) == 0 ) break; if (( para = (text != q->next) )) ___mkd_freeLineRange(q, text); q->next = 0; if ( kind == 1 /* discount dl */ ) for ( q = labels; q; q = q->next ) { CLIP(q->text, 0, 1); UNCHECK(q); S(q->text)--; } dd_block: p = Pp(&d, text, LISTITEM); text = listitem(p, clip, f->flags, (kind==2) ? is_extra_dd : 0); p->down = compile(p->text, 0, f); p->text = labels; labels = 0; if ( para && p->down ) p->down->align = PARA; if ( (q = skipempty(text)) == 0 ) break; if (( para = (q != text) )) { Line anchor; anchor.next = text; ___mkd_freeLineRange(&anchor,q); text = q; } if ( kind == 2 && is_extra_dd(q) ) goto dd_block; } top->text = 0; top->down = T(d); return text; }
Triangulator::Triangulator(CalibrationData _calibration) : calibration(_calibration){ // Precompute uc, vc maps uc.create(calibration.frameHeight, calibration.frameWidth, CV_32F); vc.create(calibration.frameHeight, calibration.frameWidth, CV_32F); for(unsigned int row=0; row<calibration.frameHeight; row++){ for(unsigned int col=0; col<calibration.frameWidth; col++){ uc.at<float>(row, col) = col; vc.at<float>(row, col) = row; } } // Precompute determinant tensor cv::Mat Pc(3,4,CV_32F,cv::Scalar(0.0)); cv::Mat(calibration.Kc).copyTo(Pc(cv::Range(0,3), cv::Range(0,3))); cv::Mat Pp(3,4,CV_32F), temp(3,4,CV_32F); cv::Mat(calibration.Rp).copyTo(temp(cv::Range(0,3), cv::Range(0,3))); cv::Mat(calibration.Tp).copyTo(temp(cv::Range(0,3), cv::Range(3,4))); Pp = cv::Mat(calibration.Kp) * temp; cv::Mat e = cv::Mat::eye(4, 4, CV_32F); int sz[] = {4, 3, 3, 3}; cv::Mat C(4, sz, CV_32F, cv::Scalar::all(0)); for(int k=0; k<4; k++){ for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ for(int l=0; l<3; l++){ cv::Mat op(4, 4, CV_32F); Pc.row(i).copyTo(op.row(0)); Pc.row(j).copyTo(op.row(1)); Pp.row(l).copyTo(op.row(2)); e.row(k).copyTo(op.row(3)); C.at<float>(cv::Vec4i(k,i,j,l)) = cv::determinant(op.t()); } } } } determinantTensor = C; // Precompute lens correction maps cv::Mat eye = cv::Mat::eye(3, 3, CV_32F); cv::initUndistortRectifyMap(calibration.Kc, calibration.kc, eye, calibration.Kc, cv::Size(calibration.frameWidth, calibration.frameHeight), CV_32FC1, lensMap1, lensMap2); //cv::Mat map1, map2; //cv::normalize(lensMap1, map1, 0, 255, cv::NORM_MINMAX, CV_8U); //cv::normalize(lensMap2, map2, 0, 255, cv::NORM_MINMAX, CV_8U); //cv::imwrite("map1.png", map1); //cv::imwrite("map2.png", map2); }
void Node::drawSimple(QPainter &P, MapView *theView) { // if (!M_PREFS->getWireframeView() && !TEST_RFLAGS(RendererOptions::Interacting)) // return; if (! ((isReadonly() || !isSelectable(theView->pixelPerM(), theView->renderOptions())) && (!isPOI() && !isWaypoint()))) // if (!Pt->isReadonly() && Pt->isSelectable(r)) { if (!layer()) { qDebug() << "Node without layer: " << id().numId << xmlId(); return; } qreal WW = theView->nodeWidth(); if (WW >= 1) { QColor theColor = QColor(0,0,0,128); if (M_PREFS->getUseStyledWireframe() && hasPainter()) { const FeaturePainter* thePainter = getCurrentPainter(); if (thePainter->DrawForeground) theColor = thePainter->ForegroundColor; else if (thePainter->DrawBackground) theColor = thePainter->BackgroundColor; } QPointF Pp(theView->toView(this)); if (layer()->classGroups() & Layer::Special) { QRect R2(Pp.x()-(WW+4)/2, Pp.y()-(WW+4)/2, WW+4, WW+4); P.fillRect(R2,QColor(255,0,255,192)); } else if (isWaypoint()) { QRect R2(Pp.x()-(WW+4)/2, Pp.y()-(WW+4)/2, WW+4, WW+4); P.fillRect(R2,QColor(255,0,0,192)); } QRect R(Pp.x()-WW/2, Pp.y()-WW/2, WW, WW); P.fillRect(R,theColor); } } }
/* * break a collection of markdown input into * blocks of lists, code, html, and text to * be marked up. */ static Paragraph * compile(Line *ptr, int toplevel, MMIOT *f) { ParagraphRoot d = { 0, 0 }; Paragraph *p = 0; Line *r; int para = toplevel; int blocks = 0; int hdr_type, list_type, list_class, indent; ptr = consume(ptr, ¶); while ( ptr ) { if ( iscode(ptr) ) { p = Pp(&d, ptr, CODE); if ( f->flags & MKD_1_COMPAT) { /* HORRIBLE STANDARDS KLUDGE: the first line of every block * has trailing whitespace trimmed off. */ ___mkd_tidy(&p->text->text); } ptr = codeblock(p); } #if WITH_FENCED_CODE else if ( iscodefence(ptr,3,0) && (p=fencedcodeblock(&d, &ptr)) ) /* yay, it's already done */ ; #endif else if ( ishr(ptr) ) { p = Pp(&d, 0, HR); r = ptr; ptr = ptr->next; ___mkd_freeLine(r); } else if ( list_class = islist(ptr, &indent, f->flags, &list_type) ) { if ( list_class == DL ) { p = Pp(&d, ptr, DL); ptr = definition_block(p, indent, f, list_type); } else { p = Pp(&d, ptr, list_type); ptr = enumerated_block(p, indent, f, list_class); } } else if ( isquote(ptr) ) { p = Pp(&d, ptr, QUOTE); ptr = quoteblock(p, f->flags); p->down = compile(p->text, 1, f); p->text = 0; } else if ( ishdr(ptr, &hdr_type) ) { p = Pp(&d, ptr, HDR); ptr = headerblock(p, hdr_type); } else { p = Pp(&d, ptr, MARKUP); ptr = textblock(p, toplevel, f->flags); /* tables are a special kind of paragraph */ if ( actually_a_table(f, p->text) ) p->typ = TABLE; } if ( (para||toplevel) && !p->align ) p->align = PARA; blocks++; para = toplevel || (blocks > 1); ptr = consume(ptr, ¶); if ( para && !p->align ) p->align = PARA; } return T(d); }
/* * break a collection of markdown input into * blocks of lists, code, html, and text to * be marked up. */ static Paragraph * compile(Line *ptr, int toplevel, MMIOT *f) { ParagraphRoot d = { 0, 0 }; Paragraph *p = 0; Line *r; int para = toplevel; int blocks = 0; int hdr_type, list_type, list_class, indent; ptr = consume(ptr, ¶); while ( ptr ) { if ( iscode(ptr) ) { p = Pp(&d, ptr, CODE); if ( f->flags & MKD_1_COMPAT) { /* HORRIBLE STANDARDS KLUDGE: the first line of every block * has trailing whitespace trimmed off. */ ___mkd_tidy(&p->text->text); } ptr = codeblock(p); } else if ( ishr(ptr) ) { p = Pp(&d, 0, HR); r = ptr; ptr = ptr->next; ___mkd_freeLine(r); } else if (( list_class = islist(ptr, &indent, f->flags, &list_type) )) { if ( list_class == DL ) { p = Pp(&d, ptr, DL); ptr = definition_block(p, indent, f, list_type); } else { p = Pp(&d, ptr, list_type); ptr = enumerated_block(p, indent, f, list_class); } } else if ( isquote(ptr) ) { p = Pp(&d, ptr, QUOTE); ptr = quoteblock(p, f->flags); p->down = compile(p->text, 1, f); p->text = 0; } else if ( ishdr(ptr, &hdr_type) ) { p = Pp(&d, ptr, HDR); ptr = headerblock(p, hdr_type); } else if ( istable(ptr) && !(f->flags & (MKD_STRICT|MKD_NOTABLES)) ) { p = Pp(&d, ptr, TABLE); ptr = tableblock(p); } else { p = Pp(&d, ptr, MARKUP); ptr = textblock(p, toplevel, f->flags); } if ( (para||toplevel) && !p->align ) p->align = PARA; blocks++; para = toplevel || (blocks > 1); ptr = consume(ptr, ¶); if ( para && !p->align ) p->align = PARA; } return T(d); }
int main(int argc, char *argv[]) { timeSelector::addOptions(); # include "addRegionOption.H" argList::addBoolOption ( "noWrite", "suppress writing results" ); #include "addDictOption.H" #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createNamedMesh.H" #include "createFields.H" // Create particle cloud cfdemCloud particleCloud(mesh); // Post-processing dictionary #include "postProcessingDict.H" // Create conditional averaging class conditionalAve condAve(postProcessingDict,conditionalAveragingDict, mesh,nVariable,nAveragingVariable,nTotalCase,conditionalAveraging); // Create multiple variable conditional averaging class multipleVarsConditionalAve multipleVarsCondAve(postProcessingDict,multConditionalAveragingDict, mesh,multNVariable,multNAveragingVariable,multNTotalCase,multConditionalAveraging); forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Pout << " " << endl; Pout << "\nTime = " << runTime.timeName() << endl; mesh.readUpdate(); // Read gas volume fraction IOobject voidfractionheader ( "voidfraction", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading voidfraction" << endl; volScalarField voidfraction(voidfractionheader,mesh); // Read Eulerian particle velocity IOobject Usheader ( "Us", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading Us" << endl; volVectorField Us(Usheader,mesh); // Read particle kinetic stresses IOobject sigmaKinHeader ( "sigmaKin", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading sigmaKin" << endl; volSymmTensorField sigmaKin(sigmaKinHeader,mesh); // Read particle collisional stresses IOobject sigmaCollHeader ( "sigmaColl", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading sigmaColl" << endl; volSymmTensorField sigmaColl(sigmaCollHeader,mesh); // Particle pressure volScalarField Pp ( IOobject ( "Pp", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar( "zero", dimensionSet(1,-1,-2,0,0), scalar(0) ) ); Pp = 1./3. * tr( sigmaKin + sigmaColl ) ; // Write into the results folder Pp.write(); // Calculate the particulate pressure gradient volVectorField gradPp(fvc::grad(Pp)); // Particle shear stress volTensorField sigmap ( IOobject ( "sigmap", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedTensor( "zero", dimensionSet(1,-1,-2,0,0), tensor(0,0,0,0,0,0,0,0,0) ) ); sigmap = ( sigmaKin + sigmaColl ) - tensor(I) * Pp; // Write into the results folder sigmap.write(); // Particle viscosity volScalarField mup ( IOobject ( "mup", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar( "zero", dimensionSet(1,-1,-1,0,0), scalar(0) ) ); // Particle shear stresses volTensorField S("S",fvc::grad(Us) + fvc::grad(Us)().T()); dimensionedScalar SSsmall("zero", dimensionSet(0,0,-2,0,0,0,0), SMALL); mup = ( sigmap && S ) / ( max ( S && S, SSsmall ) ); // Limit by zero mup.max(0.); // Write into the results folder mup.write(); // Particle viscosity/sqrt(p) dimensionedScalar PpSmall("zero", dimensionSet(1,-1,-2,0,0,0,0), 1.e-06); volScalarField mupSqrtPp ( IOobject ( "mupSqrtPp", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mup/sqrt((mag(Pp)+PpSmall)*rhop)/dp ); //- Dummy word word varName(""); //- Conditional averaging condAve.calc(); condAve.write(varName); //- Multi-variable conditional averaging multipleVarsCondAve.calc(); multipleVarsCondAve.write(varName); }