Improve readability

This commit is contained in:
hasufell 2014-10-25 20:39:34 +02:00
parent c4c397e12f
commit fd931db7e0
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 17 additions and 38 deletions

View File

@ -53,7 +53,7 @@ sortLexPoly ps = maybe [] (`shiftM` ps) (elemIndex (yMax ps) ps)
-- while saving the origin of that point. This is done in O(n).
sortLexPolys :: ([PT], [PT]) -> [PolyPT]
sortLexPolys (pA'@(_:_), pB'@(_:_)) =
queueToList . go (Q.fromList . sortLexPoly $ pA') $
queueToList $ go (Q.fromList . sortLexPoly $ pA')
(Q.fromList . sortLexPoly $ pB')
where
-- Start recursive algorithm, each polygon is represented by a Queue.
@ -130,10 +130,7 @@ intersectionPoints xs' =
-- Get the scan line or in other words the
-- Segment pairs we are going to check for intersection.
scanLine :: [PolyPT] -> ([Segment], [Segment])
scanLine sp@(_:_) =
(,)
(getSegment isPolyA)
(getSegment isPolyB)
scanLine sp@(_:_) = (,) (getSegment isPolyA) (getSegment isPolyB)
where
getSegment f = fromMaybe []
((\x -> [(id' x, suc x), (id' x, pre x)])
@ -144,10 +141,10 @@ intersectionPoints xs' =
-- both polygons we currently examine. This is done in O(1)
-- since we have max 4 segments.
segIntersections :: ([Segment], [Segment]) -> [PT]
segIntersections (a@(_:_), b@(_:_))
= catMaybes
. fmap (\[x, y] -> intersectSeg' x y)
$ combinations a b
segIntersections (a@(_:_), b@(_:_)) =
catMaybes
. fmap (\[x, y] -> intersectSeg' x y)
$ combinations a b
segIntersections _ = []
-- Gets all unique(!) combinations of two arrays. Both arrays

View File

@ -13,29 +13,20 @@ import Parser.Meshparser
diag :: DiagProp -> Object -> Diagram Cairo R2
diag p obj@(Object _)
| alg p == 0 =
mkDiag
(mconcat [coordPointsText,
coordPoints, plotterBG])
p obj
mkDiag (mconcat [coordPointsText, coordPoints, plotterBG])
p obj
| alg p == 1 =
mkDiag
(mconcat
[convexHPText,
convexHP, convexHLs,
coordPoints, plotterBG])
p obj
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
p obj
| otherwise = mempty
diag p objs@(Objects _)
| alg p == 2 =
mkDiag (mconcat [polyLines, coordPointsText, coordPoints,
plotterBG])
p objs
mkDiag (mconcat [polyLines, coordPointsText, coordPoints, plotterBG])
p objs
| alg p == 3 =
mkDiag (mconcat [polyIntersectionText,
polyIntersection, coordPointsText,
coordPoints, polyLines,
plotterBG])
p objs
mkDiag (mconcat [polyIntersectionText, polyIntersection, coordPointsText,
coordPoints, polyLines, plotterBG])
p objs
| otherwise = mempty
@ -43,14 +34,5 @@ diag p objs@(Objects _)
-- of an obj file.
diagS :: DiagProp -> MeshString -> Diagram Cairo R2
diagS p mesh
| alg p == 2 || alg p == 3 =
diag p.
Objects .
facesToArr $
mesh
| otherwise =
(diag p .
Object .
meshToArr $
mesh) #
bg white
| alg p == 2 || alg p == 3 = diag p. Objects . facesToArr $ mesh
| otherwise = (diag p . Object . meshToArr $ mesh) # bg white