Skip to content

Commit

Permalink
WIP debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Sep 15, 2024
1 parent 3798504 commit 6e7278d
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ where
import Control.Arrow (left, (&&&))
import Control.Monad (when)
import Data.Coerce
import Debug.Trace
import Data.Either.Extra (maybeToEither)
import Data.Foldable (foldlM)
import Data.Map qualified as M
Expand Down Expand Up @@ -42,14 +43,23 @@ overlaySingleStructure ::
Either Text (MergedStructure (Maybe a))
overlaySingleStructure
inheritedStrucDefs
(Placed p@(Placement _ pose@(Pose loc orientation)) ns)
(Placed p@(Placement sName pose@(Pose loc orientation)) ns)
(MergedStructure inputArea inputPlacements inputWaypoints) = do
MergedStructure overlayArea overlayPlacements overlayWaypoints <-
mergeStructures inheritedStrucDefs (WithParent p) $ structure ns

let mergedWaypoints = inputWaypoints <> map (fmap $ placeOnArea overlayArea) overlayWaypoints
mergedPlacements = inputPlacements <> map (placeOnArea overlayArea) overlayPlacements
mergedArea = overlayGridExpanded (gridContent inputArea) pose overlayArea
inputGridContent = gridContent inputArea
mergedArea2 = overlayGridExpanded (show sName) inputGridContent pose overlayArea
mergedArea = trace (unwords [
"For placement of"
, show sName
, "at loc"
, show loc
, "where input has offset"
, show $ offset pose
]) mergedArea2

return $ MergedStructure mergedArea mergedPlacements mergedWaypoints
where
Expand Down Expand Up @@ -99,16 +109,19 @@ mergeStructures inheritedStrucDefs parentPlacement (Structure origArea subStruct
-- * Grid manipulation

overlayGridExpanded ::
String ->
Grid (Maybe a) ->
Pose ->
PositionedGrid (Maybe a) ->
PositionedGrid (Maybe a)
overlayGridExpanded
note
inputGrid
(Pose loc orientation)
(PositionedGrid _c overlayArea) =
PositionedGrid origin inputGrid <> positionedOverlay
(PositionedGrid c overlayArea) =
trace (unwords ["In overlayGridExpanded for", note, "where c = ", show c, "and loc = ", show loc]) output
where
output = PositionedGrid origin inputGrid <> positionedOverlay
reorientedOverlayCells = applyOrientationTransform orientation overlayArea
positionedOverlay = PositionedGrid loc reorientedOverlayCells

Expand Down

0 comments on commit 6e7278d

Please sign in to comment.