Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions programs/extcuraengine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-- For matching our OpenScad variable types.
{-# LANGUAGE ViewPatterns #-}

import Prelude ((*), (/), (+), (-), odd, mod, round, floor, foldMap, (<>), FilePath, fromInteger, error, div, reverse, fst, filter, (<=))
import Prelude ((*), (/), (+), (-), odd, mod, round, floor, (<>), FilePath, fromInteger, error, div, reverse, fst, filter, (<=))

import Control.Applicative (pure, (<*>), (<$>))

Expand Down Expand Up @@ -121,13 +121,16 @@ centeredTrisFromSTL (RectArea (bedX,bedY,_)) stl = shiftedTris
where
centerPoint = Point3 (dx,dy,dz)
shiftedTris = [shiftTri centerPoint tri | tri <- tris] `using` parListChunk (div (length tris) (fromFastℕ threads)) rseq
xs = [ xOf.fst <$> triPoints | triPoints <- sidesOf <$> tris ] `using` parListChunk (div (length tris) (fromFastℕ threads)) rseq
ys = [ yOf.fst <$> triPoints | triPoints <- sidesOf <$> tris ] `using` parListChunk (div (length tris) (fromFastℕ threads)) rseq
zs = [ zOf.fst <$> triPoints | triPoints <- sidesOf <$> tris ] `using` parListChunk (div (length tris) (fromFastℕ threads)) rseq
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of repetition here, maybe refactor common parListChunk (div (length tris) (fromFastℕ threads)) rseq.

tris = trianglesFromSTL threads stl
(dx,dy,dz) = (bedX/2-x0, bedY/2-y0, -zMin)
xMin = minimum $ xOf.fst <$> foldMap sidesOf tris
yMin = minimum $ yOf.fst <$> foldMap sidesOf tris
zMin = minimum $ zOf.fst <$> foldMap sidesOf tris
xMax = maximum $ xOf.fst <$> foldMap sidesOf tris
yMax = maximum $ yOf.fst <$> foldMap sidesOf tris
xMin = minimum $ concat xs
xMax = maximum $ concat xs
yMin = minimum $ concat ys
yMax = maximum $ concat ys
zMin = minimum $ concat zs
(x0,y0) = ((xMax+xMin)/2-xMin, (yMax+yMin)/2-yMin)

-----------------------------------------------------------------------
Expand Down