Skip to content

Export volumes to STEP files#1589

Closed
ilguido wants to merge 4 commits intosolvespace:masterfrom
ilguido:master
Closed

Export volumes to STEP files#1589
ilguido wants to merge 4 commits intosolvespace:masterfrom
ilguido:master

Conversation

@ilguido
Copy link
Contributor

@ilguido ilguido commented May 14, 2025

A simple workaround to export valid volumes in STEP format. Quick description:

  • all code is contained in exportstep.cpp;
  • duplicated entities are treated as aliases, so that only one copy for each entity is used in all the file;
  • if two points are within the same distance accuracy, they are treated as duplicated.

I tested this with a good number of drawings already and it works.

Screenshot_20250514_204207

@iscgar
Copy link
Contributor

iscgar commented May 14, 2025

I don't know the first thing about STEP files, so I have no comments about the logic, but please don't use List<T>. It's just a bespoke implementation of std::vector<T> which doesn't offer any benefits other than implicit shallow copy for code that needs it (at the cost of requiring users to manually free the memory). The STEP code isn't such a case, so please switch to std::vector<int> and use ranged for loops.

Also, while SolveSpace is single threaded in that code path, please make the lists and the functions that operate on them members of StepFileWriter. There's no reason to add more global state.

Copy link
Member

@ruevs ruevs left a comment

Choose a reason for hiding this comment

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

I'm starting to think that this approach (discovering matching/duplicate points/lines/curves numerically at this level instead of trying to deduce it from the structure) may not be so bad... I need to try the other way ("logically") myself to see how hard it would be.

@ruevs
Copy link
Member

ruevs commented May 15, 2025

For cross reference:
#206 (comment)
#1580

The "correct" STEP export is neither this nor #1580 but some "nonlinear combination" of both may be :-)

@ruevs ruevs mentioned this pull request May 15, 2025
@rcarmo
Copy link

rcarmo commented May 15, 2025

@ilguido would you mind sharing the file that you're using so I can use it as a reference?

@phkahler
Copy link
Member

I'm starting to think that this approach (discovering matching/duplicate points/lines/curves numerically at this level instead of trying to deduce it from the structure) may not be so bad...

@ruevs I'm also in favor of doing it "the right way", but this would be the 3rd attempt by non-core developers to resolve the issue (of step file quality). When there is that much interest I think it's time to do something, and if you or I don't have the time to work through a "more correct" solution I think it's time to accept one or more of these others. It may be worth pointing out that these "fixes" to the existing exporter do not impact the rest of the application - they are limited to the step file exporter.

Based on the image at the top of this PR it looks like this one handles the PWL curves as well, and to me that's important. I kind of like the snapping of #1580 but that's secondary and I'm not sure if that one handles PWL curves yet.

@ilguido I agree with @iscgar comments (above) on this PR and using standard data structures instead of the solvespace Lists where possible and not introducing globals.

ruevs
ruevs previously requested changes May 16, 2025
@ruevs
Copy link
Member

ruevs commented May 16, 2025

You solution does "the right thing" when exporting the two samples I tried:
#206 (comment)
1mmCube.zip

image

unlike #1580

@ruevs
Copy link
Member

ruevs commented May 16, 2025

Exported STEPS files:
1mmCube_master_vs_ilguido_vs_rcarmo.zip

@ilguido
Copy link
Contributor Author

ilguido commented May 16, 2025

The refactored code should be OK now. I further tested it, but I invite you to do your checks anyway.

@ilguido ilguido mentioned this pull request May 18, 2025
@phkahler phkahler added the STEP Issues relating to STEP file read/write label May 19, 2025
@phkahler
Copy link
Member

@ilguido you imported into gmsh. Do you do FEA work? If so you might have something to say under issue #866

@ruevs ruevs dismissed their stale review May 21, 2025 17:03

Done

@phkahler
Copy link
Member

I've merged the other version of this PR.

@phkahler phkahler closed this May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

STEP Issues relating to STEP file read/write

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad STEP generation Feature Request: Exporting (better) solid STEP

5 participants