Skip to content

Conversation

PascalGilbraith
Copy link
Contributor

Add support for binary and ASCII STL files

@PascalGilbraith
Copy link
Contributor Author

I was hesitant to submit as I see this will conflict with #9 once it's merged
I'm happy to wait for that PR to be closed and fix the conflicts myself

@autopawn autopawn self-assigned this Jun 15, 2023
Copy link
Owner

@autopawn autopawn left a comment

Choose a reason for hiding this comment

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

Nice PR! I am ready to merge it after my comments are addressed.

src/model.c Outdated

// Read facet definitions, 50 bytes each, facet normal, 3 vertices, and a 2 byte spacer
char buffer[50];
while(fread(buffer, sizeof(char), 50, fp))
Copy link
Owner

Choose a reason for hiding this comment

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

Should we make sure that this call to fread returns 50?

Copy link
Owner

Choose a reason for hiding this comment

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

Same for the previous

fread(facetCount, sizeof(int), 1, fp);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we successfully read some facet data but at some point fread fails to read the 50 bytes, should we output the error but display what we have processed, or just output the error and return null?

Copy link
Owner

Choose a reason for hiding this comment

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

I think we should just display an error, indicating the premature end of the file. Since it is unlikely that fread fails.

WARNING to WARN for consistent output

Use type rather then expression sizeof as it will never change

Output error if fread fails to read the facet count check fread reads all 50 bytes of facet data before processing Add note assuming little-endian hardware
Add warning that color is not supported if --color argument passed to stl import
@PascalGilbraith PascalGilbraith force-pushed the feature/add_stl_support branch from 95640b5 to bf605ac Compare June 18, 2023 09:46
@autopawn autopawn merged commit 1c55ea9 into autopawn:master Jun 18, 2023
@PascalGilbraith PascalGilbraith deleted the feature/add_stl_support branch June 19, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants