diff options
Diffstat (limited to 'src/Wavefront/Lex.hs')
-rw-r--r-- | src/Wavefront/Lex.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Wavefront/Lex.hs b/src/Wavefront/Lex.hs index f4cb54a..811553a 100644 --- a/src/Wavefront/Lex.hs +++ b/src/Wavefront/Lex.hs | |||
@@ -38,7 +38,7 @@ data ObjBuilder m = ObjBuilder | |||
38 | , trim :: [CurveSpec] -> m () | 38 | , trim :: [CurveSpec] -> m () |
39 | , hole :: [CurveSpec] -> m () | 39 | , hole :: [CurveSpec] -> m () |
40 | , specialCurves :: [CurveSpec] -> m () | 40 | , specialCurves :: [CurveSpec] -> m () |
41 | , equivalentCurves :: [EmbeddedCurve] -> m () | 41 | , equivalentCurves :: [EmbeddedCurveRef] -> m () |
42 | , groups :: [S.ByteString] -> m () | 42 | , groups :: [S.ByteString] -> m () |
43 | , smoothingGroup :: Int -> m () | 43 | , smoothingGroup :: Int -> m () |
44 | , mergingGroup :: Int -> Double -> m () | 44 | , mergingGroup :: Int -> Double -> m () |
@@ -188,7 +188,7 @@ echoBuilder = ObjBuilder | |||
188 | , trim = \ss -> echo $ unwords ("trim":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) | 188 | , trim = \ss -> echo $ unwords ("trim":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) |
189 | , hole = \ss -> echo $ unwords ("hole":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) | 189 | , hole = \ss -> echo $ unwords ("hole":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) |
190 | , specialCurves = \ss -> echo $ unwords ("scrv":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) | 190 | , specialCurves = \ss -> echo $ unwords ("scrv":concatMap (\(CurveSpec s e r) -> [show s,show e,show r]) ss) |
191 | , equivalentCurves = \ccs -> echo $ unwords ("con":map showEmbeddedCurve ccs) | 191 | , equivalentCurves = \ccs -> echo $ unwords ("con":map showEmbeddedCurveRef ccs) |
192 | , groups = \gs -> echo $ unwords $ "g":map unpackUtf8 gs | 192 | , groups = \gs -> echo $ unwords $ "g":map unpackUtf8 gs |
193 | , smoothingGroup = \sg -> echo ("s " ++ show sg) | 193 | , smoothingGroup = \sg -> echo ("s " ++ show sg) |
194 | , mergingGroup = \mg δ -> echo $ unwords ["mg",show mg,show δ] | 194 | , mergingGroup = \mg δ -> echo $ unwords ["mg",show mg,show δ] |
@@ -264,6 +264,8 @@ newtype ObjConfig = ObjConfig | |||
264 | { cfgSubst :: IntMap L.ByteString | 264 | { cfgSubst :: IntMap L.ByteString |
265 | } | 265 | } |
266 | 266 | ||
267 | defaultConfig = ObjConfig IntMap.empty | ||
268 | |||
267 | -- consChunk :: S.ByteString -> L.ByteString -> L.ByteString | 269 | -- consChunk :: S.ByteString -> L.ByteString -> L.ByteString |
268 | -- consChunk c bs = L.fromChunks (c : L.toChunks bs) | 270 | -- consChunk c bs = L.fromChunks (c : L.toChunks bs) |
269 | 271 | ||
@@ -430,11 +432,11 @@ parseCurveSpecsN n tok bs cont = parseFloatsN 2 tok bs $ \fs bs' -> case fs of | |||
430 | 432 | ||
431 | _ -> cont [] bs' | 433 | _ -> cont [] bs' |
432 | 434 | ||
433 | parseEmbeddedCurves :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([EmbeddedCurve] -> L.ByteString -> b) -> b | 435 | parseEmbeddedCurveRefs :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([EmbeddedCurveRef] -> L.ByteString -> b) -> b |
434 | parseEmbeddedCurves tok bs cont = parseIntsN 1 tok bs $ \is bs' -> case is of | 436 | parseEmbeddedCurveRefs tok bs cont = parseIntsN 1 tok bs $ \is bs' -> case is of |
435 | (sref:_) -> do | 437 | (sref:_) -> do |
436 | parseCurveSpecsN 1 tok bs' $ \cs bs'' -> case cs of | 438 | parseCurveSpecsN 1 tok bs' $ \cs bs'' -> case cs of |
437 | (c:_) -> parseEmbeddedCurves tok bs'' $ cont . (EmbeddedCurve sref c :) | 439 | (c:_) -> parseEmbeddedCurveRefs tok bs'' $ cont . (EmbeddedCurveRef sref c :) |
438 | _ -> cont [] bs'' | 440 | _ -> cont [] bs'' |
439 | 441 | ||
440 | _ -> cont [] bs' | 442 | _ -> cont [] bs' |
@@ -472,14 +474,14 @@ data CurveSpec = CurveSpec | |||
472 | } | 474 | } |
473 | deriving (Eq,Ord,Show) | 475 | deriving (Eq,Ord,Show) |
474 | 476 | ||
475 | data EmbeddedCurve = EmbeddedCurve | 477 | data EmbeddedCurveRef = EmbeddedCurveRef |
476 | { curveSurfaceRef :: Int | 478 | { curveSurfaceRef :: Int |
477 | , embeddedCurve :: CurveSpec | 479 | , embeddedCurve :: CurveSpec |
478 | } | 480 | } |
479 | deriving (Eq,Ord,Show) | 481 | deriving (Eq,Ord,Show) |
480 | 482 | ||
481 | showEmbeddedCurve :: EmbeddedCurve -> String | 483 | showEmbeddedCurveRef :: EmbeddedCurveRef -> String |
482 | showEmbeddedCurve (EmbeddedCurve s c) = unwords | 484 | showEmbeddedCurveRef (EmbeddedCurveRef s c) = unwords |
483 | [ show s | 485 | [ show s |
484 | , show (curveStart c) | 486 | , show (curveStart c) |
485 | , show (curveEnd c) | 487 | , show (curveEnd c) |
@@ -560,7 +562,7 @@ parseOBJ builder args bs0 | |||
560 | then parseI deprecated_cdc 4 -- cdc | 562 | then parseI deprecated_cdc 4 -- cdc |
561 | else parseI deprecated_cdp 4 -- cdp | 563 | else parseI deprecated_cdp 4 -- cdp |
562 | "co" -> -- con | 564 | "co" -> -- con |
563 | parseEmbeddedCurves (findToken args) (next 2 bs) $ \ss bs' -> do | 565 | parseEmbeddedCurveRefs (findToken args) (next 2 bs) $ \ss bs' -> do |
564 | equivalentCurves builder ss | 566 | equivalentCurves builder ss |
565 | parseOBJ builder args bs' | 567 | parseOBJ builder args bs' |
566 | "cs" -> if lengthLessThan 3 bs | 568 | "cs" -> if lengthLessThan 3 bs |