From 071e9a5cacffcc3eeb97996e805804cd4c710894 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 8 Nov 2018 17:42:19 +0100 Subject: [PATCH] moved draw_boundary and draw_model_elements from graph to hypgraph --- graph.cpp | 178 --------------------------------------------------- hyper.h | 2 + hypgraph.cpp | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+), 178 deletions(-) diff --git a/graph.cpp b/graph.cpp index c9ef6d92..fb7a9c9a 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5504,184 +5504,6 @@ function wrap_drawfullmap = drawfullmap; bool force_sphere_outline = false; -void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) { - if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye) && !(pmodel == mdDisk && hyperbolic && vid.alpha <= -1)) { - hyperpoint ret; - applymodel(xpush0(radius), ret); - ld r = hypot2(ret); - queuecircle(vid.xcenter, vid.ycenter, r * vid.radius, linecol, prio, fillcol); - return; - } - for(int i=0; i<360; i++) curvepoint(xspinpush0(i * 2 * M_PI / 360, 10)); - auto& c = queuecurve(linecol, fillcol, prio); - if(pmodel == mdDisk && hyperbolic && vid.alpha <= -1) - c.flags |= POLY_FORCE_INVERTED; - if(pmodel == mdJoukowsky) - c.flags |= POLY_FORCE_INVERTED; - } - -void draw_model_elements() { - - if(elliptic || (vid.grid && sphere)) - circle_around_center(M_PI/2, ringcolor, 0, PPR::CIRCLE); - - if(pmodel == mdTwoPoint) { - ld a = -conformal::model_orientation * M_PI / 180; - queuechr(xspinpush0(a, +vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); - queuechr(xspinpush0(a, -vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); - } - - if(pmodel == mdBall) { - queuecircle(vid.xcenter, vid.ycenter, vid.radius, ringcolor, PPR::OUTCIRCLE, fillmodel); - ballgeometry(); - } - - if(pmodel == mdHyperboloid && hyperbolic) { -#if CAP_QUEUE - curvepoint(hpxyz(0,0,1)); - curvepoint(hpxyz(0,0,-vid.alpha)); - queuecurve(ringcolor, 0, PPR::CIRCLE); - - ld& tz = conformal::top_z; - ld z = acosh(tz); - - hyperpoint a = xpush0(z); - ld cb = conformal::cos_ball; - ld sb = conformal::sin_ball; - - a[1] = sb * a[2] / -cb; - a[0] = sqrt(-1 + a[2] * a[2] - a[1] * a[1]); - - curvepoint(hpxyz(0,0,-vid.alpha)); - curvepoint(a); - curvepoint(hpxyz(0,0,0)); - a[0] = -a[0]; - curvepoint(a); - curvepoint(hpxyz(0,0,-vid.alpha)); - queuecurve(ringcolor, 0, PPR::CIRCLE); - - curvepoint(hpxyz(-1,0,0)); - curvepoint(hpxyz(1,0,0)); - queuecurve(ringcolor, 0, PPR::CIRCLE); - - a[1] = sb * tz / -cb; - a[0] = sqrt(tz * tz - a[1] * a[1]); - a[2] = tz - vid.alpha; - - curvepoint(a); - curvepoint(hpxyz(0,0,-vid.alpha)); - a[0] = -a[0]; - curvepoint(a); - queuecurve(ringcolor, 0, PPR::CIRCLE); -#endif - } - - } - -void draw_boundary(int w) { - - if(w == 1) return; - - color_t lc = ringcolor; - color_t fc = fillmodel; - PPR p = PPR::OUTCIRCLE; - - if(haveaura()) lc = 0; - if(lc == 0 && fc == 0) return; - - switch(pmodel) { - - case mdSinusoidal: { - if(stereo::active() || !sphere) return; - queuereset(vid.usingGL ? mdDisk : mdUnchanged, PPR::CIRCLE); - - for(ld a=-45; a<45+1e-6; a+=pow(.5, vid.linequality)) { - curvepoint(hpxyz(cos(a * M_PI / 90) * vid.radius, a * vid.radius / 90, 0)); - } - for(ld a=45; a>=-45-1e-6; a-=pow(.5, vid.linequality)) { - curvepoint(hpxyz(-cos(a * M_PI / 90) * vid.radius, a * vid.radius / 90, 0)); - } - queuecurve(lc, fc, p); - return; - } - - case mdTwoPoint: { - if(twopoint_do_flips || stereo::active() || !sphere) return; - queuereset(vid.usingGL ? mdDisk : mdUnchanged, p); - - for(int b=-1; b<=1; b+=2) - for(ld a=-90; a<=90+1e-6; a+=pow(.5, vid.linequality)) { - using namespace hyperpoint_vec; - ld x = sin(a * vid.twopoint_param * b / 90); - ld y = 0; - ld z = -sqrt(1 - x*x); - conformal::apply_orientation(y, x); - hyperpoint h1; - applymodel(hpxyz(x,y,z), h1); - - conformal::apply_orientation(h1[0], h1[1]); - h1[1] = abs(h1[1]) * b; - conformal::apply_orientation(h1[1], h1[0]); - curvepoint(h1); - } - - queuecurve(lc, fc, p); - queuereset(pmodel, p); - return; - } - - case mdBand: case mdBandEquidistant: case mdBandEquiarea: { - ld rad = 0; - if(pmodel == mdBand && hyperbolic) rad = vid.radius; - if(pmodel == mdBandEquidistant && sphere) rad = vid.radius / 2; - if(pmodel == mdBandEquiarea && sphere) rad = vid.radius / M_PI; - - if(rad) { - queuereset(vid.usingGL ? mdDisk : mdUnchanged, PPR::CIRCLE); - curvepoint(hpxyz(-vid.xcenter, -rad, 0)); - curvepoint(hpxyz(vid.xres-vid.xcenter, -rad, 0)); - queuecurve(ringcolor, 0, PPR::CIRCLE); - curvepoint(hpxyz(-vid.xcenter, rad, 0)); - curvepoint(hpxyz(vid.xres-vid.xcenter, rad, 0)); - queuecurve(ringcolor, 0, PPR::CIRCLE); - queuereset(pmodel, PPR::CIRCLE); - return; - } - } - - default: break; - } - - /* - if(!stereo::active() && !euclid && (pmodel == mdDisk || pmodel == mdBall || (sphere && mdAzimuthalEqui()))) { - double rad = vid.radius; - bool isbnd = true; - if(sphere) { - if(mdAzimuthalEqui()) - ; - else if(!vid.grid && !elliptic && !force_sphere_outline) - rad = 0; - else if(vid.alpha <= 0) - ; - else if(vid.grid || force_sphere_outline) // mark the edge - rad /= sqrt(vid.alpha*vid.alpha - 1); - } - if(rad) - queuecircle(vid.xcenter, vid.ycenter, rad, lc, p, fc); - return; - } - */ - - if(sphere) return; - circle_around_center(hyperbolic ? 20 : exp(10), lc, fc, p); - - /* - if(pmodel == mdPolygonal || pmodel == mdPolynomial) - polygonal::drawBoundary(darkena(0xFF, 0, 0xFF)); - */ - } - - void drawfullmap() { DEBB(DF_GRAPH, (debugfile,"draw full map\n")); diff --git a/hyper.h b/hyper.h index 953ee2bf..076db16e 100644 --- a/hyper.h +++ b/hyper.h @@ -4323,6 +4323,8 @@ bool in_smart_range(const transmatrix& T); void curvepoint(const hyperpoint& H1); dqi_poly& queuecurve(color_t linecol, color_t fillcol, PPR prio); +bool haveaura(); + string parser_help(); } diff --git a/hypgraph.cpp b/hypgraph.cpp index b794d0c9..4049b895 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1126,4 +1126,181 @@ transmatrix atscreenpos(ld x, ld y, ld size) { return V; } +void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) { + if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye) && !(pmodel == mdDisk && hyperbolic && vid.alpha <= -1)) { + hyperpoint ret; + applymodel(xpush0(radius), ret); + ld r = hypot2(ret); + queuecircle(vid.xcenter, vid.ycenter, r * vid.radius, linecol, prio, fillcol); + return; + } + for(int i=0; i<360; i++) curvepoint(xspinpush0(i * 2 * M_PI / 360, 10)); + auto& c = queuecurve(linecol, fillcol, prio); + if(pmodel == mdDisk && hyperbolic && vid.alpha <= -1) + c.flags |= POLY_FORCE_INVERTED; + if(pmodel == mdJoukowsky) + c.flags |= POLY_FORCE_INVERTED; + } + +void draw_model_elements() { + + if(elliptic || (vid.grid && sphere)) + circle_around_center(M_PI/2, ringcolor, 0, PPR::CIRCLE); + + if(pmodel == mdTwoPoint) { + ld a = -conformal::model_orientation * M_PI / 180; + queuechr(xspinpush0(a, +vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); + queuechr(xspinpush0(a, -vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); + } + + if(pmodel == mdBall) { + queuecircle(vid.xcenter, vid.ycenter, vid.radius, ringcolor, PPR::OUTCIRCLE, fillmodel); + ballgeometry(); + } + + if(pmodel == mdHyperboloid && hyperbolic) { +#if CAP_QUEUE + curvepoint(hpxyz(0,0,1)); + curvepoint(hpxyz(0,0,-vid.alpha)); + queuecurve(ringcolor, 0, PPR::CIRCLE); + + ld& tz = conformal::top_z; + ld z = acosh(tz); + + hyperpoint a = xpush0(z); + ld cb = conformal::cos_ball; + ld sb = conformal::sin_ball; + + a[1] = sb * a[2] / -cb; + a[0] = sqrt(-1 + a[2] * a[2] - a[1] * a[1]); + + curvepoint(hpxyz(0,0,-vid.alpha)); + curvepoint(a); + curvepoint(hpxyz(0,0,0)); + a[0] = -a[0]; + curvepoint(a); + curvepoint(hpxyz(0,0,-vid.alpha)); + queuecurve(ringcolor, 0, PPR::CIRCLE); + + curvepoint(hpxyz(-1,0,0)); + curvepoint(hpxyz(1,0,0)); + queuecurve(ringcolor, 0, PPR::CIRCLE); + + a[1] = sb * tz / -cb; + a[0] = sqrt(tz * tz - a[1] * a[1]); + a[2] = tz - vid.alpha; + + curvepoint(a); + curvepoint(hpxyz(0,0,-vid.alpha)); + a[0] = -a[0]; + curvepoint(a); + queuecurve(ringcolor, 0, PPR::CIRCLE); +#endif + } + + } + +void draw_boundary(int w) { + + if(w == 1) return; + + color_t lc = ringcolor; + color_t fc = fillmodel; + PPR p = PPR::OUTCIRCLE; + + if(haveaura()) lc = 0; + if(lc == 0 && fc == 0) return; + + switch(pmodel) { + + case mdSinusoidal: { + if(stereo::active() || !sphere) return; + queuereset(vid.usingGL ? mdDisk : mdUnchanged, PPR::CIRCLE); + + for(ld a=-45; a<45+1e-6; a+=pow(.5, vid.linequality)) { + curvepoint(hpxyz(cos(a * M_PI / 90) * vid.radius, a * vid.radius / 90, 0)); + } + for(ld a=45; a>=-45-1e-6; a-=pow(.5, vid.linequality)) { + curvepoint(hpxyz(-cos(a * M_PI / 90) * vid.radius, a * vid.radius / 90, 0)); + } + queuecurve(lc, fc, p); + return; + } + + case mdTwoPoint: { + if(twopoint_do_flips || stereo::active() || !sphere) return; + queuereset(vid.usingGL ? mdDisk : mdUnchanged, p); + + for(int b=-1; b<=1; b+=2) + for(ld a=-90; a<=90+1e-6; a+=pow(.5, vid.linequality)) { + using namespace hyperpoint_vec; + ld x = sin(a * vid.twopoint_param * b / 90); + ld y = 0; + ld z = -sqrt(1 - x*x); + conformal::apply_orientation(y, x); + hyperpoint h1; + applymodel(hpxyz(x,y,z), h1); + + conformal::apply_orientation(h1[0], h1[1]); + h1[1] = abs(h1[1]) * b; + conformal::apply_orientation(h1[1], h1[0]); + curvepoint(h1); + } + + queuecurve(lc, fc, p); + queuereset(pmodel, p); + return; + } + + case mdBand: case mdBandEquidistant: case mdBandEquiarea: { + ld rad = 0; + if(pmodel == mdBand && hyperbolic) rad = vid.radius; + if(pmodel == mdBandEquidistant && sphere) rad = vid.radius / 2; + if(pmodel == mdBandEquiarea && sphere) rad = vid.radius / M_PI; + + if(rad) { + queuereset(vid.usingGL ? mdDisk : mdUnchanged, PPR::CIRCLE); + curvepoint(hpxyz(-vid.xcenter, -rad, 0)); + curvepoint(hpxyz(vid.xres-vid.xcenter, -rad, 0)); + queuecurve(ringcolor, 0, PPR::CIRCLE); + curvepoint(hpxyz(-vid.xcenter, rad, 0)); + curvepoint(hpxyz(vid.xres-vid.xcenter, rad, 0)); + queuecurve(ringcolor, 0, PPR::CIRCLE); + queuereset(pmodel, PPR::CIRCLE); + return; + } + } + + default: break; + } + + /* + if(!stereo::active() && !euclid && (pmodel == mdDisk || pmodel == mdBall || (sphere && mdAzimuthalEqui()))) { + double rad = vid.radius; + bool isbnd = true; + if(sphere) { + if(mdAzimuthalEqui()) + ; + else if(!vid.grid && !elliptic && !force_sphere_outline) + rad = 0; + else if(vid.alpha <= 0) + ; + else if(vid.grid || force_sphere_outline) // mark the edge + rad /= sqrt(vid.alpha*vid.alpha - 1); + } + if(rad) + queuecircle(vid.xcenter, vid.ycenter, rad, lc, p, fc); + return; + } + */ + + if(sphere) return; + circle_around_center(hyperbolic ? 20 : exp(10), lc, fc, p); + + /* + if(pmodel == mdPolygonal || pmodel == mdPolynomial) + polygonal::drawBoundary(darkena(0xFF, 0, 0xFF)); + */ + } + }