-
-
Notifications
You must be signed in to change notification settings - Fork 148
add polyhedron support. #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
17e2f78
add polyhedron support.
julialongtin 5dbedd3
first bug fixes.
julialongtin 6c5134c
avoid dividing 1 by a small number, divide v[a-c] instead.
julialongtin 4762150
cover more edge cases.
julialongtin ff39421
add a note for next time I am debugging.
julialongtin 904ea9c
rotated math is less spikey?
julialongtin 148cbb7
adjust EPS values and handling, remove clamping.
julialongtin 40be7ce
add example for Polyhedron.
julialongtin 656eec0
remove warning, and unnecessary import.
julialongtin c7a53dc
split ONModule into with and without suite variants, simplify Primiti…
julialongtin 60ff96b
reformat for clarity.
julialongtin c2109a9
much closer. some shadowing to deal with.
julialongtin 6088924
convex polyhedrons now work.
julialongtin b3c0c77
add utility file for containing triangle logic.
julialongtin 883092c
use triangle utility file.
julialongtin ea99224
cleanup warnings, build problems.
julialongtin 7878b30
fix the precision optimizing transforms in distancePointToTriangle.
julialongtin b8eedc1
remove warnings.
julialongtin 54622e3
remove warnings.
julialongtin fb2f678
tiny fixes.
julialongtin e53aef2
move items out of pointOnOutside, so they aren't recomputed during th…
julialongtin f840ed1
provide function for finding insideness based on winding numbers.
julialongtin 92612de
use pointOnOutsideByWinding.
julialongtin 90d8191
should work on concave or convex
julialongtin a93ac47
tiny changes.
julialongtin fb80e97
use the triangles from triangles, rather than tris.
julialongtin 30f2ccf
remove unnecessary import.
julialongtin 3e227a4
add a note, and make sure we can handle polygons with more than 4 bil…
julialongtin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| module pyramid(base, height) { | ||
| half = base / 2; | ||
|
|
||
| polyhedron( | ||
| points = [ | ||
| [-half, -half, 0], | ||
| [ half, -half, 0], | ||
| [ half, half, 0], | ||
| [-half, half, 0], | ||
| [0, 0, height] | ||
| ], | ||
| faces = [ | ||
| [0, 1, 2, 3], | ||
| [0, 1, 4], | ||
| [1, 2, 4], | ||
| [2, 3, 4], | ||
| [3, 0, 4] | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| pyramid_base = 12; | ||
| pyramid_height = 14; | ||
| pyramid(pyramid_base, pyramid_height); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import Graphics.Implicit.ExtOpenScad.Definitions ( | |
| Statement(Include, (:=), If, NewModule, ModuleCall, DoNothing), | ||
| Pattern(Name), | ||
| Expr(LitE), | ||
| OVal(OBool, OUModule, ONModule, OVargsModule), | ||
| OVal(OBool, OUModule, ONModule, ONModuleWithSuite, OVargsModule), | ||
| VarLookup(VarLookup), | ||
| StatementI(StatementI), | ||
| Symbol(Symbol), | ||
|
|
@@ -116,15 +116,23 @@ runStatementI (StatementI sourcePos (ModuleCall (Symbol name) argsExpr suite)) = | |
| fromMaybe (pure []) (fst argsMapped) | ||
| Just (ONModule _ implementation forms) -> do | ||
| possibleInstances <- selectInstances forms | ||
| let | ||
| suiteInfo = case possibleInstances of | ||
| [(_, suiteInfoFound)] -> suiteInfoFound | ||
| [] -> Nothing | ||
| ((_, suiteInfoFound):_) -> suiteInfoFound | ||
| when (null possibleInstances) (do | ||
| errorC sourcePos $ "no instance of " <> name <> " found to match given parameters.\nInstances available:\n" <> pack (show (ONModule (Symbol name) implementation forms)) | ||
| traverse_ ((`checkOptions` True) . Just . fst) forms | ||
| traverse_ ((`checkOptions` True) . Just) forms | ||
| ) | ||
| -- Evaluate all of the arguments. | ||
| evaluatedArgs <- evalArgs argsExpr | ||
| when (suite /= []) (errorC sourcePos $ "Suite provided, but module " <> name <> " does not accept one. Perhaps a missing semicolon?") | ||
| -- Run the module. | ||
| let | ||
| argsMapped = argMap evaluatedArgs $ implementation sourcePos | ||
| for_ (pack <$> snd argsMapped) $ errorC sourcePos | ||
| fromMaybe (pure []) $ fst argsMapped | ||
| Just (ONModuleWithSuite _ implementation forms) -> do | ||
| possibleInstances <- selectInstances forms | ||
| when (null possibleInstances) $ do | ||
| errorC sourcePos $ "no instance of " <> name <> " found to match given parameters.\nInstances available:\n" <> pack (show (ONModuleWithSuite (Symbol name) implementation forms)) | ||
| traverse_ ((`checkOptions` True) . Just) forms | ||
|
Comment on lines
+131
to
+135
|
||
| -- Ignore this for now, because all instances we define have the same suite requirements. | ||
| {- | ||
| when (length possibleInstances > 1) (do | ||
|
|
@@ -135,14 +143,9 @@ runStatementI (StatementI sourcePos (ModuleCall (Symbol name) argsExpr suite)) = | |
| evaluatedArgs <- evalArgs argsExpr | ||
| -- Evaluate the suite. | ||
| vals <- runSuiteCapture varlookup suite | ||
| suiteResults <- case suiteInfo of | ||
| Just True -> do | ||
| when (null vals) (errorC sourcePos "Suite required, but none provided.") | ||
| pure vals | ||
| Just False -> pure vals | ||
| _ -> do | ||
| when (suite /= []) (errorC sourcePos $ "Suite provided, but module " <> name <> " does not accept one. Perhaps a missing semicolon?") | ||
| pure [] | ||
| suiteResults <- do | ||
| when (null vals) (errorC sourcePos "Suite required, but none provided.") | ||
| pure vals | ||
| -- Run the module. | ||
| let | ||
| argsMapped = argMap evaluatedArgs $ implementation sourcePos suiteResults | ||
|
|
@@ -164,12 +167,12 @@ runStatementI (StatementI sourcePos (ModuleCall (Symbol name) argsExpr suite)) = | |
| pure [] | ||
| pushVals newVals | ||
| where | ||
| selectInstances :: [([(Symbol, Bool)], Maybe Bool)] -> StateC [([(Symbol, Bool)], Maybe Bool)] | ||
| selectInstances :: [[(Symbol, Bool)]] -> StateC [[(Symbol, Bool)]] | ||
| selectInstances instances = do | ||
| validInstances <- for instances | ||
| ( \(args, suiteInfo) -> do | ||
| ( \args -> do | ||
| res <- checkOptions (Just args) False | ||
| pure $ if res then Just (args, suiteInfo) else Nothing | ||
| pure $ if res then Just args else Nothing | ||
| ) | ||
| pure $ catMaybes validInstances | ||
| checkOptions :: Maybe [(Symbol, Bool)] -> Bool -> StateC Bool | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the
ONModulebranch, thesuiteargument from the AST is ignored. This changes behavior: providing a suite to a module that doesn't accept one (often a missing semicolon) will no longer error. Add an explicit check thatsuiteis empty and emit an error when it is not.