Skip to content

Silence logs and light refactoring #9

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

robinthibaut
Copy link
Contributor

I opened this PR to silence all the logs we're getting that were not silenced by the verbose argument.

Also added some light reformatting on the Python and C++ code for better readability.

clang-format -i /loop-cgal/src/*  

More details (Copilot summary):

Python Code Improvements:

  • Reorganized Imports: Updated loop_cgal/__init__.py to use future annotations, reordered imports for clarity, and grouped related imports together.
  • Simplified Return Statement: Refactored clip_pyvista_polydata to directly return the result of pv.PolyData.from_regular_faces without assigning it to an intermediate variable.

C++ Code Improvements:

  • Header File Reordering: Adjusted the order of header file imports in src/clip.cpp for better organization.
  • Whitespace Cleanup: Removed unnecessary blank lines in src/clip.cpp to improve code compactness. [1] [2]
  • Simplified Function Calls: Reformatted function calls in clip_plane, clip_surface, and corefine_mesh to remove redundant line breaks and improve readability. [1] [2] [3] [4] [5]

Logging and Verbosity Adjustments:

  • Verbose Logging Behavior: Updated verbose logging in various functions to improve clarity and ensure it is only triggered when the verbose flag is set. Examples include clip_plane, clip_surface, and corefine_mesh. [1] [2] [3]
  • Default Verbose Parameter: Changed the default verbose parameter to false in the TriMesh constructor in src/mesh.cpp, reducing unnecessary logging during object initialization.

Formatting and Consistency:

  • Improved Code Formatting: Reformatted loops, conditional blocks, and function definitions in src/mesh.cpp for consistency and readability. [1] [2] [3]
  • Error Handling Messages: Standardized error and warning messages, including replacing std::cout with std::cerr for error logs where appropriate. [1] [2]

These changes collectively enhance the readability, maintainability, and reliability of the codebase while ensuring consistent behavior across the library.

@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 20:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR focuses on reducing verbose logging output and applying formatting improvements to the codebase. The main goal is to silence logs that weren't controlled by the verbose argument and improve code readability through consistent formatting.

  • Silenced unwanted log output by making verbose logging conditional and changing default verbose behavior
  • Applied clang-format styling to C++ code for consistent formatting and readability
  • Reorganized Python imports and simplified return statements

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/meshutils.cpp Applied clang-format styling with consistent brace placement and whitespace
src/mesh.h Reordered header includes and applied formatting to class and function declarations
src/mesh.cpp Changed default verbose to false, removed unconditional logging, and applied formatting
src/clip.cpp Reordered headers, applied formatting, and made verbose logging conditional
loop_cgal/init.py Added future annotations, reorganized imports, and simplified return statement

Comment on lines 216 to +219
void TriMesh::reverseFaceOrientation() {
// Reverse the face orientation of the mesh
PMP::reverse_face_orientations(_mesh);
if (!CGAL::is_valid_polygon_mesh(_mesh, true))
{
std::cerr << "Error: Mesh is not valid after reversing face orientations." << std::endl;
}
// Reverse the face orientation of the mesh
PMP::reverse_face_orientations(_mesh);
if (!CGAL::is_valid_polygon_mesh(_mesh, false)) {
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The verbose parameter was changed from true to false, but this appears to be inconsistent with the function's verbose parameter. If the function receives verbose=true, the validation should also use the verbose flag for consistency.

Copilot uses AI. Check for mistakes.

#endif
if (!beautify_flag) {
std::cout << "Removing degenerate faces failed." << std::endl;
std::cerr << "Removing degenerate faces failed." << std::endl;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

Changed from std::cout to std::cerr for error messages, which is correct, but this should be applied consistently to line 380 as well where the same error message still uses std::cerr.

Copilot uses AI. Check for mistakes.

Comment on lines +264 to +265
if (verbose)
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

[nitpick] The verbose check is missing braces around the single statement. For consistency with the rest of the codebase and to prevent potential bugs when adding more statements, consider using braces: if (verbose) {

Suggested change
if (verbose)
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
if (verbose) {
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
}

Copilot uses AI. Check for mistakes.

Comment on lines +301 to +302
if (verbose)
CGAL::is_valid_polygon_mesh(_tm, true);
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Same issue as line 264 - missing braces around the single statement after the verbose check.

Suggested change
if (verbose)
CGAL::is_valid_polygon_mesh(_tm, true);
if (verbose) {
CGAL::is_valid_polygon_mesh(_tm, true);
}

Copilot uses AI. Check for mistakes.

Comment on lines +388 to +389
if (verbose)
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Same issue as previous verbose checks - missing braces around the single statement.

Suggested change
if (verbose)
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
if (verbose) {
std::cout << "Meshes do not intersect. Returning tm." << std::endl;
}

Copilot uses AI. Check for mistakes.

Comment on lines +439 to +442
if (verbose)
std::cout << "Found " << tm_1_shared_edges.size()
<< " shared edges in tm1 and " << tm_2_shared_edges.size()
<< " shared edges in tm2." << std::endl;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Same issue as previous verbose checks - missing braces around the single statement.

Suggested change
if (verbose)
std::cout << "Found " << tm_1_shared_edges.size()
<< " shared edges in tm1 and " << tm_2_shared_edges.size()
<< " shared edges in tm2." << std::endl;
if (verbose) {
std::cout << "Found " << tm_1_shared_edges.size()
<< " shared edges in tm1 and " << tm_2_shared_edges.size()
<< " shared edges in tm2." << std::endl;
}

Copilot uses AI. Check for mistakes.

Comment on lines +472 to +473
if (verbose)
std::cout << "Corefinement done." << std::endl;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Same issue as previous verbose checks - missing braces around the single statement.

Suggested change
if (verbose)
std::cout << "Corefinement done." << std::endl;
if (verbose) {
std::cout << "Corefinement done." << std::endl;
}

Copilot uses AI. Check for mistakes.

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.

1 participant