Skip to content

Commit

Permalink
Add autotest on issue 5501 (#3980)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chernobrovkin-AD authored Jan 16, 2025
1 parent f1bf925 commit 09b543e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test_regression/helpers/meshlib_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def compare_meshes_similarity(mesh1: mrmeshpy.Mesh, mesh2: mrmeshpy.Mesh,
:param verts_thresh: vertices difference threshold
:param skip_volume: skip volume check - for open meshes
"""
if isinstance(mesh1, str) or isinstance(mesh1, Path):
mesh1 = mrmeshpy.loadMesh(str(mesh1))
if isinstance(mesh2, str) or isinstance(mesh2, Path):
mesh2 = mrmeshpy.loadMesh(str(mesh2))

with check:
# check on meshes relative Hausdorff distance
rhsdr = relative_hausdorff(mesh1, mesh2)
Expand Down
32 changes: 32 additions & 0 deletions test_regression/test_issues/test_issue_5501.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import io
from pathlib import Path

import meshlib.mrmeshpy as mm
import pytest
from constants import test_files_path
from helpers.meshlib_helpers import compare_meshes_similarity


@pytest.mark.smoke
@pytest.mark.bindingsV3
def test_issue_5501_read(tmp_path):
input_folder = Path(test_files_path) / "issues" / "5501"
in_file = input_folder / "input.ctm"
with open(in_file, "rb") as file_handler:
buf = io.BytesIO(file_handler.read())
mrmesh = mm.loadMesh(buf, "*.ctm")
mm.saveMesh(mrmesh, tmp_path / "out_read.ctm")
compare_meshes_similarity(in_file, tmp_path / "out_read.ctm")

@pytest.mark.smoke
@pytest.mark.bindingsV3
def test_issue_2899_write(tmp_path):
input_folder = Path(test_files_path) / "issues" / "5501"
in_file = input_folder / "input.ctm"
mrmesh = mm.loadMesh(in_file)
with io.BytesIO() as byte_stream:
mm.saveMesh(mrmesh, out=byte_stream, extension="*.ctm")
with open(tmp_path / "out_write.ctm", "wb") as f:
f.write(byte_stream.getbuffer())

compare_meshes_similarity(in_file, tmp_path / "out_write.ctm")

0 comments on commit 09b543e

Please sign in to comment.