From 8148e2b52f9b2f5c2a0df053031374eeb23f7410 Mon Sep 17 00:00:00 2001 From: Julia Longtin Date: Wed, 31 Jan 2024 21:16:08 +0000 Subject: [PATCH] add more debugging messages in failure cases. --- Graphics/Slicer/Math/Skeleton/Definitions.hs | 2 +- Graphics/Slicer/Math/Skeleton/Face.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Graphics/Slicer/Math/Skeleton/Definitions.hs b/Graphics/Slicer/Math/Skeleton/Definitions.hs index 0ced757a..78f5291a 100644 --- a/Graphics/Slicer/Math/Skeleton/Definitions.hs +++ b/Graphics/Slicer/Math/Skeleton/Definitions.hs @@ -414,7 +414,7 @@ ancestorsOf :: INodeSet -> [INodeSet] ancestorsOf (INodeSet children _) | isEmpty children = [] | otherwise = case SL.last children of - [] -> error "encountered an empty generation." + [] -> [] -- error $ "encountered an empty generation: \n" <> show children <> "\n" [a] -> [INodeSet (SL.init children) a] newParents -> case SL.init children of (Slist [] 0) -> INodeSet mempty <$> newParents diff --git a/Graphics/Slicer/Math/Skeleton/Face.hs b/Graphics/Slicer/Math/Skeleton/Face.hs index 6c6dbd14..6dcb10dc 100644 --- a/Graphics/Slicer/Math/Skeleton/Face.hs +++ b/Graphics/Slicer/Math/Skeleton/Face.hs @@ -216,11 +216,11 @@ getFaces' origINodeSet eNodeSet iNodeSet iNode = findFacesRecurse iNode myPLines | isENode eNodeSet (fst pLine) = [] -- don't climb down an enode, you're done | hasArc myINode && isCollinear (outAndErrOf myINode) pLine = [] -- don't try to climb back up the tree | isNothing iNodeSet = error "we need INodes here." - | ancestorsOf (fromJust iNodeSet) /= [] = myGetFaces $ onlyOne $ filter (\a -> outAndErrOf (finalINodeOf a) == pLine) $ ancestorsOf (fromJust iNodeSet) + | not $ null (ancestorsOf $ fromJust iNodeSet) = myGetFaces $ onlyOne $ filter (\a -> outAndErrOf (finalINodeOf a) == pLine) $ ancestorsOf (fromJust iNodeSet) | otherwise = error "no between to plant?" where onlyOne :: (Show a) => [a] -> a - onlyOne [] = error "no item" + onlyOne [] = error $ "no item!\n" <> show pLine <> "\n" <> show iNodeSet <> "\n" onlyOne [a] = a onlyOne xs = error $ "too many items." <> show xs <> "\n" myGetFaces newINodeSet