Skip to content

Commit

Permalink
Merge pull request #142 from Haskell-Things/add_c0_insets_2
Browse files Browse the repository at this point in the history
support split events.
  • Loading branch information
julialongtin authored Sep 15, 2023
2 parents cca0225 + 790a6e1 commit c4fe7d2
Show file tree
Hide file tree
Showing 6 changed files with 796 additions and 100 deletions.
260 changes: 164 additions & 96 deletions Graphics/Slicer/Math/Skeleton/Line.hs

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions tests/GoldenSpec/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ goldenSpec = describe "golden tests" $ do
, toGanja $ onlyOne $ contoursFrom $ insetBy 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c0 []]
goldens "C0-Straight_Skeleton_And_Four_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c0 []] <>
(toGanja <$> (contoursFrom $ insetMany 0.1 4 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c0 [])))
-- goldens "C0-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c0 []] <>
-- (toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c0 [])))
goldens "C0-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c0 []] <>
(toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c0 [])))
golden "C0-NodeTree" $ addNodeTreesAlongDivide
(fst $ getRawNodeTreeOfCell (cellFrom $ findFirstCellOfContour c0 $ findDivisions c0 $ fromJust $ crashMotorcycles c0 []))
(fst $ getRawNodeTreeOfCell (cellFrom $ findNextCell $ onlyOne $ remainderFrom $ findFirstCellOfContour c0 $ findDivisions c0 $ fromJust $ crashMotorcycles c0 []))
Expand All @@ -80,6 +80,8 @@ goldenSpec = describe "golden tests" $ do
golden "C1-Straight_Skeleton" $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c1 []
goldens "C1-Straight_Skeleton_And_Inset" [ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c1 []
, toGanja $ onlyOne $ contoursFrom $ insetBy 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c1 []]
goldens "C1-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c1 []] <>
(toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c1 [])))
golden "C2-Cell1" $ cellFrom $ findFirstCellOfContour c2 $ findDivisions c2 $ fromMaybe (error "Got Nothing") $ crashMotorcycles c2 []
golden "C2-Cell1-NodeTree" $ fst $ getRawNodeTreeOfCell $ cellFrom $ findFirstCellOfContour c2 $ findDivisions c2 $ fromJust $ crashMotorcycles c2 []
golden "C2-Remainder1" $ onlyOne $ remainderFrom $ findFirstCellOfContour c2 $ findDivisions c2 $ fromJust $ crashMotorcycles c2 []
Expand All @@ -88,13 +90,15 @@ goldenSpec = describe "golden tests" $ do
golden "C3-Cell1" $ cellFrom $ findFirstCellOfContour c3 $ findDivisions c3 $ fromMaybe (error "Got Nothing") $ crashMotorcycles c3 []
golden "C3-Remainder1" $ onlyOne $ remainderFrom $ findFirstCellOfContour c3 $ findDivisions c3 $ fromJust $ crashMotorcycles c3 []
golden "C3-Straight_Skeleton" $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c3 []
-- goldens "C3-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c3 []] <>
-- (toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c3 [])))
goldens "C3-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c3 []] <>
(toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c3 [])))
golden "C4-Cell1" $ cellFrom $ findFirstCellOfContour c4 $ findDivisions c4 $ fromMaybe (error "Got Nothing") $ crashMotorcycles c4 []
golden "C4-Remainder1" $ onlyOne $ remainderFrom $ findFirstCellOfContour c4 $ findDivisions c4 $ fromJust $ crashMotorcycles c4 []
golden "C4-Cell2" $ cellFrom $ findNextCell $ onlyOne $ remainderFrom $ findFirstCellOfContour c4 $ findDivisions c4 $ fromJust $ crashMotorcycles c4 []
golden "C4-Straight_Skeleton" $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c4 []
golden "C4-Faces-Default" $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c4 []
goldens "C4-Straight_Skeleton_And_Insets" ([ toGanja $ fromMaybe (error "no skeleton?") $ findStraightSkeleton c4 []] <>
(toGanja <$> (infiniteInset 0.1 $ facesOf $ fromMaybe (error "got Nothing") $ findStraightSkeleton c4 [])))
golden "C5-Cell1" $ cellFrom $ findFirstCellOfContour c5 $ findDivisions c5 $ fromMaybe (error "Got Nothing") $ crashMotorcycles c5 []
golden "C5-Remainder1" $ onlyOne $ remainderFrom $ findFirstCellOfContour c5 $ findDivisions c5 $ fromJust $ crashMotorcycles c5 []
golden "C5-Cell2" $ cellFrom $ findNextCell $ onlyOne $ remainderFrom $ findFirstCellOfContour c5 $ findDivisions c5 $ fromJust $ crashMotorcycles c5 []
Expand Down
156 changes: 156 additions & 0 deletions tests/golden/C0-Straight_Skeleton_And_Insets.ganja.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
Algebra(2,0,1,()=>{
var line = (a,b,c)=>a*1e1 + b*1e2 + c*1e0;
var point = (x,y)=>!(1e0 + x*1e1 + y*1e2);
var aaa = point(1.0,1.0);
var aab = point(-1.0,1.0);
var aba = point(-1.0,1.0);
var abb = point(0.0,0.0);
var aca = point(0.0,0.0);
var acb = point(-1.0,-1.0);
var ada = point(-1.0,-1.0);
var adb = point(1.0,-1.0);
var aea = point(1.0,-1.0);
var aeb = point(1.0,1.0);
var afa = -0.7071067811865475e1+0.7071067811865475e2+0.0e0;
var afb = -0.3826834323650897e1-0.9238795325112867e2+0.541196100146197e0;
var afc = -0.9238795325112868e1-0.3826834323650897e2+0.5411961001461972e0;
var aga = 0.3826834323650897e1-0.9238795325112867e2-0.541196100146197e0;
var agb = 0.7071067811865475e1+0.7071067811865475e2+0.0e0;
var agc = 0.9238795325112868e1-0.3826834323650897e2-0.5411961001461972e0;
var aha = 0.9238795325112868e1-0.3826834323650897e2-0.5411961001461972e0;
var ahb = 0.0e1-1.0e2+0.0e0;
var ahc = -0.9238795325112868e1-0.3826834323650897e2+0.5411961001461972e0;
var ba = point(0.14142135623730953,0.0);
var bb = point(-0.7585786437626906,-0.9);
var bc = point(0.9,-0.9);
var bd = point(0.9,0.9);
var be = point(-0.7585786437626906,0.9);
var ca = point(0.28284271247461906,0.0);
var cb = point(-0.517157287525381,-0.8);
var cc = point(0.8,-0.8);
var cd = point(0.8,0.8);
var ce = point(-0.517157287525381,0.8);
var da = point(0.4242640687119286,0.0);
var db = point(-0.27573593128807133,-0.7);
var dc = point(0.7,-0.7);
var dd = point(0.7,0.7);
var de = point(-0.27573593128807133,0.7);
var ea = point(0.5656854249492381,0.0);
var eb = point(-0.03431457505076187,-0.6);
var ec = point(0.6,-0.6);
var ed = point(0.6,0.6);
var ee = point(-0.03431457505076187,0.6);
var fa = point(0.5,-0.20710678118654763);
var fb = point(0.20710678118654763,-0.5);
var fc = point(0.5,-0.5);
var ga = point(0.5,0.20710678118654763);
var gb = point(0.5,0.5);
var gc = point(0.20710678118654763,0.5);
document.body.appendChild(this.graph([
0x882288,
[aaa,aab],
0x00AA88,
aaa, "aaa",
aab, "aab",
0x882288,
[aba,abb],
0x00AA88,
aba, "aba",
abb, "abb",
0x882288,
[aca,acb],
0x00AA88,
aca, "aca",
acb, "acb",
0x882288,
[ada,adb],
0x00AA88,
ada, "ada",
adb, "adb",
0x882288,
[aea,aeb],
0x00AA88,
aea, "aea",
aeb, "aeb",
afa, "afa",
afb, "afb",
afc, "afc",
aga, "aga",
agb, "agb",
agc, "agc",
aha, "aha",
ahb, "ahb",
ahc, "ahc",
0x882288,
[ba,bb],
[bb,bc],
[bc,bd],
[bd,be],
[be,ba],
0x00AA88,
ba, "ba",
bb, "bb",
bc, "bc",
bd, "bd",
be, "be",
0x882288,
[ca,cb],
[cb,cc],
[cc,cd],
[cd,ce],
[ce,ca],
0x00AA88,
ca, "ca",
cb, "cb",
cc, "cc",
cd, "cd",
ce, "ce",
0x882288,
[da,db],
[db,dc],
[dc,dd],
[dd,de],
[de,da],
0x00AA88,
da, "da",
db, "db",
dc, "dc",
dd, "dd",
de, "de",
0x882288,
[ea,eb],
[eb,ec],
[ec,ed],
[ed,ee],
[ee,ea],
0x00AA88,
ea, "ea",
eb, "eb",
ec, "ec",
ed, "ed",
ee, "ee",
0x882288,
[fa,fb],
[fb,fc],
[fc,fa],
0x00AA88,
fa, "fa",
fb, "fb",
fc, "fc",
0x882288,
[ga,gb],
[gb,gc],
[gc,ga],
0x00AA88,
ga, "ga",
gb, "gb",
gc, "gc",
],{
grid: true,
labels: true,
lineWidth: 3,
pointRadius: 1,
fontSize: 1,
scale: 1,
}));
});
156 changes: 156 additions & 0 deletions tests/golden/C1-Straight_Skeleton_And_Insets.ganja.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
Algebra(2,0,1,()=>{
var line = (a,b,c)=>a*1e1 + b*1e2 + c*1e0;
var point = (x,y)=>!(1e0 + x*1e1 + y*1e2);
var aaa = point(-1.0,1.0);
var aab = point(-1.0,-1.0);
var aba = point(-1.0,-1.0);
var abb = point(0.0,0.0);
var aca = point(0.0,0.0);
var acb = point(1.0,-1.0);
var ada = point(1.0,-1.0);
var adb = point(1.0,1.0);
var aea = point(1.0,1.0);
var aeb = point(-1.0,1.0);
var afa = -0.7071067811865475e1-0.7071067811865475e2+0.0e0;
var afb = 0.9238795325112867e1-0.3826834323650897e2+0.541196100146197e0;
var afc = 0.3826834323650897e1-0.9238795325112868e2+0.5411961001461972e0;
var aga = 0.9238795325112867e1+0.3826834323650897e2-0.541196100146197e0;
var agb = -0.7071067811865475e1+0.7071067811865475e2+0.0e0;
var agc = 0.3826834323650897e1+0.9238795325112868e2-0.5411961001461972e0;
var aha = 0.3826834323650897e1+0.9238795325112868e2-0.5411961001461972e0;
var ahb = 1.0e1+0.0e2+0.0e0;
var ahc = 0.3826834323650897e1-0.9238795325112868e2+0.5411961001461972e0;
var ba = point(-0.0,0.14142135623730953);
var bb = point(0.9,-0.7585786437626906);
var bc = point(0.9,0.9);
var bd = point(-0.9,0.9);
var be = point(-0.9,-0.7585786437626906);
var ca = point(-0.0,0.28284271247461906);
var cb = point(0.8,-0.517157287525381);
var cc = point(0.8,0.8);
var cd = point(-0.8,0.8);
var ce = point(-0.8,-0.517157287525381);
var da = point(-0.0,0.4242640687119286);
var db = point(0.7,-0.27573593128807133);
var dc = point(0.7,0.7);
var dd = point(-0.7,0.7);
var de = point(-0.7,-0.27573593128807133);
var ea = point(-0.0,0.5656854249492381);
var eb = point(0.6,-0.03431457505076187);
var ec = point(0.6,0.6);
var ed = point(-0.6,0.6);
var ee = point(-0.6,-0.03431457505076187);
var fa = point(0.20710678118654763,0.5);
var fb = point(0.5,0.20710678118654763);
var fc = point(0.5,0.5);
var ga = point(-0.20710678118654763,0.5);
var gb = point(-0.5,0.5);
var gc = point(-0.5,0.20710678118654763);
document.body.appendChild(this.graph([
0x882288,
[aaa,aab],
0x00AA88,
aaa, "aaa",
aab, "aab",
0x882288,
[aba,abb],
0x00AA88,
aba, "aba",
abb, "abb",
0x882288,
[aca,acb],
0x00AA88,
aca, "aca",
acb, "acb",
0x882288,
[ada,adb],
0x00AA88,
ada, "ada",
adb, "adb",
0x882288,
[aea,aeb],
0x00AA88,
aea, "aea",
aeb, "aeb",
afa, "afa",
afb, "afb",
afc, "afc",
aga, "aga",
agb, "agb",
agc, "agc",
aha, "aha",
ahb, "ahb",
ahc, "ahc",
0x882288,
[ba,bb],
[bb,bc],
[bc,bd],
[bd,be],
[be,ba],
0x00AA88,
ba, "ba",
bb, "bb",
bc, "bc",
bd, "bd",
be, "be",
0x882288,
[ca,cb],
[cb,cc],
[cc,cd],
[cd,ce],
[ce,ca],
0x00AA88,
ca, "ca",
cb, "cb",
cc, "cc",
cd, "cd",
ce, "ce",
0x882288,
[da,db],
[db,dc],
[dc,dd],
[dd,de],
[de,da],
0x00AA88,
da, "da",
db, "db",
dc, "dc",
dd, "dd",
de, "de",
0x882288,
[ea,eb],
[eb,ec],
[ec,ed],
[ed,ee],
[ee,ea],
0x00AA88,
ea, "ea",
eb, "eb",
ec, "ec",
ed, "ed",
ee, "ee",
0x882288,
[fa,fb],
[fb,fc],
[fc,fa],
0x00AA88,
fa, "fa",
fb, "fb",
fc, "fc",
0x882288,
[ga,gb],
[gb,gc],
[gc,ga],
0x00AA88,
ga, "ga",
gb, "gb",
gc, "gc",
],{
grid: true,
labels: true,
lineWidth: 3,
pointRadius: 1,
fontSize: 1,
scale: 1,
}));
});
Loading

0 comments on commit c4fe7d2

Please sign in to comment.