Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noinia committed Jul 23, 2024
1 parent 0264af2 commit ddbf527
Showing 1 changed file with 28 additions and 54 deletions.
82 changes: 28 additions & 54 deletions hgeometry/test-with-ipe/test/Plane/LowerEnvelopeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ spec = describe "lower envelope tests" $ do
testIpe [osp|degenerate1.ipe|]
[osp|degenerate1_out|]

-- testIpeGraph [osp|foo.ipe|]
-- [osp|foo_graph_out|]



-- | Computes the vertex form of the upper envelope. The z-coordinates are still flipped.

Expand Down Expand Up @@ -134,7 +138,7 @@ voronoiVertices = foldMap (\case
Unbounded _ pts _ -> Set.fromList (NonEmpty.toList pts)
) . voronoiDiagram'


-- | Build voronoi diagrams on the input points
testIpe :: OsPath -> OsPath -> Spec
testIpe inFp outFp = do
(points :: NonEmpty (Point 2 R :+ _)) <- runIO $ do
Expand All @@ -148,11 +152,31 @@ testIpe inFp outFp = do
goldenWith [osp|data/test-with-ipe/Plane/LowerEnvelope/|]
(ipeFileGolden { name = outFp })
(addStyleSheet opacitiesStyle $ singlePageFromContent out)
-- FIXME: use data/test-with-ipe/VoronoiDiagram/ as input and data/test-with-ipe/Plane/LowerEnvelope
-- as output dir

{-
-- build a triangulated graph from the points in the input file
testIpeGraph :: OsPath -> OsPath -> Spec
testIpeGraph inFp outFp = do
(points :: NonEmpty (Point 2 R :+ _)) <- runIO $ do
inFp' <- getDataFileName ([osp|test-with-ipe/VoronoiDiagram/|] <> inFp)
NonEmpty.fromList <$> readAllFrom inFp'
let vd = voronoiDiagram' $ view core <$> points
vv = voronoiVertices $ view core <$> points
out = [ iO' points
, iO' vd
] <> [ iO'' v $ attr SStroke red | v <- Set.toAscList vv ]
goldenWith [osp|data/test-with-ipe/Plane/LowerEnvelope/|]
(ipeFileGolden { name = outFp })
(addStyleSheet opacitiesStyle $ singlePageFromContent out)
-}







-- outputFile' <- addStyleSheetFrom "../hgeometry-ipe/resources/opacities.isy" outputFile

{-
Expand All @@ -176,21 +200,6 @@ testIpe inFp outFp = do
, iO' trivialVD
]
testIpe [osp|trivial.ipe|]
[osp|trivial_out|]
testIpe [osp|simplest.ipe|]
[osp|simplest_out|]
testIpe [osp|simpler.ipe|]
[osp|simpler_out|]
testIpe [osp|simple.ipe|]
[osp|simple_out|]
testIpe [osp|simple1.ipe|]
[osp|simple1_out|]
testIpe [osp|foo.ipe|]
[osp|foo_out|]
degenerateTests :: Spec
degenerateTests = describe "degnereate inputs" $ do
Expand Down Expand Up @@ -269,39 +278,4 @@ trivialVD = VoronoiDiagram $ LowerEnvelope vInfty (Seq.fromList [bv])
_ -> error "absurd"
-- order of the planes is incorrect, as is the z-coord.
-- testIpe :: OsPath -> IO [IpeObject R]
-- testIpe inFp = do inFp' <- getDataFileName inFp
-- (points :: [Point 2 R :+ _]) <- readAllFrom inFp'
-- print $ (Point3 183.02716 93.61106 8869.99979 :: Point 3 R)
-- `onSideTest`
-- (NonVerticalHyperPlane (Vector3 282 426 (-65250)))
-- -- mapM_ print points
-- -- mapM_ (print . liftPointToPlane . view core) points
-- -- let hs = liftPointToPlane . view core <$> points
-- -- mapM_ (print . asVertex hs) $ uniqueTriplets hs
-- let vv = voronoiVertices $ (view core) <$> points
-- let vd = voronoiDiagram $ (view core) <$> points
-- print $ vd
-- -- print "vertices"
-- -- mapM_ print vs
-- pure $ [ iO' points
-- , iO' vd
-- ] <> [ iO'' v $ attr SStroke red | v <- vv ]
-- -- $ (map iO' points)
-- -- -- <> [iO' vd]
-- -- <>
-}

0 comments on commit ddbf527

Please sign in to comment.