Improve readability
This commit is contained in:
parent
c4c397e12f
commit
fd931db7e0
@ -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,8 +141,8 @@ 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
|
||||
segIntersections (a@(_:_), b@(_:_)) =
|
||||
catMaybes
|
||||
. fmap (\[x, y] -> intersectSeg' x y)
|
||||
$ combinations a b
|
||||
segIntersections _ = []
|
||||
|
@ -13,28 +13,19 @@ import Parser.Meshparser
|
||||
diag :: DiagProp -> Object -> Diagram Cairo R2
|
||||
diag p obj@(Object _)
|
||||
| alg p == 0 =
|
||||
mkDiag
|
||||
(mconcat [coordPointsText,
|
||||
coordPoints, plotterBG])
|
||||
mkDiag (mconcat [coordPointsText, coordPoints, plotterBG])
|
||||
p obj
|
||||
| alg p == 1 =
|
||||
mkDiag
|
||||
(mconcat
|
||||
[convexHPText,
|
||||
convexHP, convexHLs,
|
||||
coordPoints, plotterBG])
|
||||
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
|
||||
p obj
|
||||
| otherwise = mempty
|
||||
diag p objs@(Objects _)
|
||||
| alg p == 2 =
|
||||
mkDiag (mconcat [polyLines, coordPointsText, coordPoints,
|
||||
plotterBG])
|
||||
mkDiag (mconcat [polyLines, coordPointsText, coordPoints, plotterBG])
|
||||
p objs
|
||||
| alg p == 3 =
|
||||
mkDiag (mconcat [polyIntersectionText,
|
||||
polyIntersection, coordPointsText,
|
||||
coordPoints, polyLines,
|
||||
plotterBG])
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user