Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y libgl1-mesa-dev libeigen3-dev libcgal-dev
- if: matrix.os == 'macos-latest' || matrix.os == 'macos-14'
run: |
- if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install cgal
# Cache vcpkg on Windows
- name: Restore vcpkg cache
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ add_library(_loop_cgal MODULE

target_link_libraries(_loop_cgal PRIVATE pybind11::module CGAL::CGAL)
target_include_directories(_loop_cgal PRIVATE ${CMAKE_SOURCE_DIR}/src)
set_target_properties(_loop_cgal PROPERTIES PREFIX "" SUFFIX ".so")

if(WIN32)
set_target_properties(_loop_cgal PROPERTIES PREFIX "" SUFFIX ".pyd")
else()
set_target_properties(_loop_cgal PROPERTIES PREFIX "" SUFFIX ".so")
endif()

# Windows: copy required DLLs from VCPKG_ROOT
Expand Down
1 change: 0 additions & 1 deletion examples/cut_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import pyvista as pv
from loop_cgal import TriMesh, set_verbose
from LoopStructural.datatypes import BoundingBox
set_verbose(True)
Expand Down
4 changes: 2 additions & 2 deletions loop_cgal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, surface: pv.PolyData):
# Extract vertices and triangles
verts = np.array(surface.points, dtype=np.float64).copy()
faces = surface.faces.reshape(-1, 4)[:, 1:].copy().astype(np.int32)
if (not validate_vertices_and_faces(verts, faces)):
if not validate_vertices_and_faces(verts, faces):
raise ValueError("Invalid surface geometry")

super().__init__(verts, faces)
Expand All @@ -54,7 +54,7 @@ def from_vertices_and_triangles(
The created TriMesh object.
"""
# Create a temporary PyVista PolyData object for validation
if (not validate_vertices_and_faces(vertices, triangles)):
if not validate_vertices_and_faces(vertices, triangles):
raise ValueError("Invalid vertices or triangles")
surface = pv.PolyData(vertices, np.hstack((np.full((triangles.shape[0], 1), 3), triangles)).flatten())
return cls(surface)
Expand Down
6 changes: 1 addition & 5 deletions loop_cgal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def validate_pyvista_polydata(
raise ValueError(f"{surface_name} points contain NaN or infinite values")


def validate_vertices_and_faces(verts, faces) -> bool:
def validate_vertices_and_faces(verts, faces):
"""Validate vertices and faces arrays.
Parameters
----------
Expand All @@ -42,10 +42,6 @@ def validate_vertices_and_faces(verts, faces) -> bool:
faces : np.ndarray

An array of shape (n_faces, 3) containing the triangle vertex indices.
Returns
-------
bool
True if valid, False otherwise.
Raises
------
ValueError
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ classifiers = [
]

dependencies = ['pyvista','vtk','scipy','numpy']
optional-dependencies = { test = ['pytest'] }

[project.optional-dependencies]
test = ['pytest']

[tool.scikit-build]
wheel.expand-macos-universal-tags = true
Expand Down
4 changes: 2 additions & 2 deletions src/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void TriMesh::cutWithSurface(TriMesh &clipper,
bool preserve_intersection_clipper,
bool use_exact_kernel)
{

if (LoopCGAL::verbose)
{
std::cout << "Cutting mesh with surface." << std::endl;
Expand Down Expand Up @@ -692,7 +692,7 @@ void TriMesh::cut_with_implicit_function(const std::vector<double> &property, do
double v0 = newvals[tri[0]];
double v1 = newvals[tri[1]];
double v2 = newvals[tri[2]];
if (v0 <= value && v1 <= value && v2 <= value)
if (v0 < value && v1 < value && v2 < value)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/meshutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ double calculate_triangle_area(const std::array<double, 3> &v1,
const std::array<double, 3> &v3);
Exact_Mesh convert_to_exact(const TriMesh& input);
TriangleMesh convert_to_double_mesh(const Exact_Mesh& input);

#endif // MESHUTILS_H
1 change: 0 additions & 1 deletion tests/test_mesh_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def square_surface():
# Unit square made of two triangles
return pv.Plane(center=(0,0,0),direction=(0,0,1),i_size=1.0,j_size=1.0)



@pytest.fixture
Expand Down