Skip to content

Comments

Improvement: Move CAD management to t8_cad_handle with cmesh ownership#2093

Open
LenaRadmer wants to merge 7 commits intomainfrom
improvement-cad_handler
Open

Improvement: Move CAD management to t8_cad_handle with cmesh ownership#2093
LenaRadmer wants to merge 7 commits intomainfrom
improvement-cad_handler

Conversation

@LenaRadmer
Copy link
Collaborator

@LenaRadmer LenaRadmer commented Jan 14, 2026

Describe your changes here:

Changing t8_cad to t8_cad_handle for a more explicit CAD shape management. The cmesh now owns the CAD handle and uses a reference counter to manage it.
Also, the t8_geom prefix was removed for everything related to CAD shape management for cleanup. The mesh reader and geometry implementations were updated to support this new handle system.

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

All these boxes must be checked by the REVIEWERS before merging the pull request:

As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.

General

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation. Make sure to add a file documentation for each file!
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.
  • The code coverage of the project (reported in the CI) should not decrease. If coverage is decreased, make sure that this is reasonable and acceptable.
  • Valgrind doesn't find any bugs in the new code. This script can be used to check for errors; see also this wiki article.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the script/find_all_source_files.scp to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

License

  • The author added a BSD statement to doc/ (or already has one).

@LenaRadmer LenaRadmer marked this pull request as ready for review January 19, 2026 08:11
@LenaRadmer LenaRadmer marked this pull request as draft January 19, 2026 09:12
@LenaRadmer LenaRadmer changed the title Improvement: Rename t8_cad to t8_cad_handle Improvement: Move CAD management to t8_cad_handle with cmesh ownership Jan 19, 2026
@LenaRadmer LenaRadmer marked this pull request as ready for review January 19, 2026 12:19
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.25%. Comparing base (322342b) to head (94451b2).
⚠️ Report is 45 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2093      +/-   ##
==========================================
+ Coverage   77.97%   78.25%   +0.27%     
==========================================
  Files         113      114       +1     
  Lines       19106    19050      -56     
==========================================
+ Hits        14898    14907       +9     
+ Misses       4208     4143      -65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


t8_cad::t8_cad (const TopoDS_Shape cad_shape)
void
t8_cad_handle::load_cad_from_shape (const TopoDS_Shape &cad_shape)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t8_cad_handle::load_cad_from_shape (const TopoDS_Shape &cad_shape)
t8_cad_handle::load (const TopoDS_Shape &cad_shape)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok


t8_cad::t8_cad (std::string fileprefix)
void
t8_cad_handle::load_cad_from_file (const std::string fileprefix)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t8_cad_handle::load_cad_from_file (const std::string fileprefix)
t8_cad_handle::load (const std::string fileprefix)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okidoki

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okidoki


t8_cad::t8_cad (std::string fileprefix)
void
t8_cad_handle::load (const std::string fileprefix)
Copy link
Member

Choose a reason for hiding this comment

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

String view will accept anything, while a std::string only std::strings

Suggested change
t8_cad_handle::load (const std::string fileprefix)
t8_cad_handle::load (const std::string_view fileprefix)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok


t8_cad::t8_cad (const TopoDS_Shape cad_shape)
void
t8_cad_handle::load (const TopoDS_Shape &cad_shape)
Copy link
Member

Choose a reason for hiding this comment

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

Since we have to save the cad shape anyway, we have to own it at some point. So we either make a copy of it or the user gives it to us. But by taking a reference, the user cannot give it to us directly via std::move or as an rvalue. And if we do not use a reference, we do not need const.

Suggested change
t8_cad_handle::load (const TopoDS_Shape &cad_shape)
t8_cad_handle::load (TopoDS_Shape cad_shape)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

TopExp::MapShapesAndUniqueAncestors (cad_shape, TopAbs_VERTEX, TopAbs_EDGE, cad_shape_vertex2edge_map);
TopExp::MapShapesAndUniqueAncestors (cad_shape, TopAbs_EDGE, TopAbs_FACE, cad_shape_edge2face_map);
TopExp::MapShapesAndUniqueAncestors (cad_shape, TopAbs_VERTEX, TopAbs_FACE, cad_shape_vertex2face_map);
map (cad_shape);
Copy link
Member

Choose a reason for hiding this comment

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

we do not need this anymore and the next function can take it without making a copy.

Suggested change
map (cad_shape);
map (std::move(cad_shape));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay

if (cad_shape.IsNull ()) {
SC_ABORTF ("Shape is null. \n");
}
map (cad_shape);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
map (cad_shape);
map (std::move(cad_shape));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

}

void
t8_cad_handle::map (const TopoDS_Shape &cad_shape_in)
Copy link
Member

Choose a reason for hiding this comment

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

same as above

Suggested change
t8_cad_handle::map (const TopoDS_Shape &cad_shape_in)
t8_cad_handle::map (TopoDS_Shape cad_shape_in)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup

}

t8_cad::t8_cad ()
t8_cad_handle::t8_cad_handle (std::string fileprefix)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t8_cad_handle::t8_cad_handle (std::string fileprefix)
t8_cad_handle::t8_cad_handle (const std::string_view fileprefix)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okidoki

t8_cad_handle::load (fileprefix);
}

t8_cad_handle::t8_cad_handle (const TopoDS_Shape cad_shape_in)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t8_cad_handle::t8_cad_handle (const TopoDS_Shape cad_shape_in)
t8_cad_handle::t8_cad_handle (TopoDS_Shape cad_shape_in)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

t8_refcount_init (&rc);
t8_debugf ("Constructed the cad_handle from shape.\n");

t8_cad_handle::load (cad_shape_in);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t8_cad_handle::load (cad_shape_in);
load (std::move(cad_shape_in));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

cad_shape_vertex2edge_map.Clear ();
cad_shape_edge2face_map.Clear ();

cad_shape = cad_shape_in;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cad_shape = cad_shape_in;
cad_shape = std::move(cad_shape_in);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

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