2 Commits

Author SHA1 Message Date
Jonathon Broughton a06c9023fc better mock Mesh
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
2023-11-13 03:37:59 +00:00
Jonathon Broughton 4bcfe2cb2d mypymesh mock
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
2023-11-13 03:32:35 +00:00
5 changed files with 34 additions and 36 deletions
+8 -5
View File
@@ -1,7 +1,12 @@
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import List, Tuple, Any, Optional
import pymesh
try:
import pymesh
except ImportError:
from Geometry.mocks import mypymesh
pymesh = mypymesh
from speckle_automate import AutomationContext
@@ -41,7 +46,7 @@ def detect_clashes_old(
continue
intersection = pymesh.boolean(
ref_pymesh, latest_pymesh, operation="intersection"
latest_pymesh, operation="intersection"
)
if (
@@ -77,9 +82,7 @@ def check_for_clash(
if not ref_pymesh or not latest_pymesh:
continue
intersection = pymesh.boolean(
ref_pymesh, latest_pymesh, operation="intersection"
)
intersection = pymesh.boolean(latest_pymesh, operation="intersection")
if intersection and intersection.volume > 0:
severity = intersection.volume / min(
ref_pymesh.volume, latest_pymesh.volume
+7 -11
View File
@@ -1,19 +1,15 @@
from typing import Union, Type, TYPE_CHECKING
from typing import Union, Type
try:
import pymesh
except ImportError:
from Geometry.mocks import mypymesh
import pymesh
pymesh = mypymesh
import trimesh
class MockPyMesh:
def __init__(self, vertices, faces):
self.vertices = vertices or []
self.faces = faces or []
def boolean(self, other, operation):
return MockPyMesh([], [])
from Geometry.helpers import triangulate_face
def trimesh_to_pymesh(mesh: trimesh.Trimesh) -> pymesh.Mesh:
+13
View File
@@ -0,0 +1,13 @@
class mypymesh:
class Mesh:
def __init__(self, vertices, faces):
self.vertices = vertices
self.faces = faces
@property
def volume(self):
return 0
@staticmethod
def boolean(_other, _operation):
return mypymesh.Mesh([], [])
Generated
+1 -14
View File
@@ -774,19 +774,6 @@ files = [
[package.dependencies]
typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0"
[[package]]
name = "pymesh"
version = "1.0.2"
description = "Library for manipulating (Translate, Rotate and Scale) 3D data using numpy."
optional = false
python-versions = "*"
files = [
{file = "pymesh-1.0.2.tar.gz", hash = "sha256:7032cd5c53cd9d93b31b6033bfdf7a61ca482ce4dc10d70411a1f392df095deb"},
]
[package.dependencies]
numpy = "*"
[[package]]
name = "pytest"
version = "7.4.3"
@@ -1287,4 +1274,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "5e736eb0d2aeb78aaf6b2252f4f3e011b6bca230716f2d0e07c29d3b3dc796ce"
content-hash = "3abedc1c21df21ba5ab28f1ea6dc49c8a84c768e0f8f155e5c619ca3fd023765"
+5 -6
View File
@@ -9,7 +9,6 @@ readme = "README.md"
python = "^3.10"
specklepy = "2.17.11"
trimesh = "^4.0.4"
pymesh = "^1.0.2"
[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
@@ -23,11 +22,11 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
select = [
"E", # pycodestyle
"F", # pyflakes
"UP", # pyupgrade
"D", # pydocstyle
"I", # isort
"E", # pycodestyle
"F", # pyflakes
"UP", # pyupgrade
"D", # pydocstyle
"I", # isort
]
[tool.ruff.pydocstyle]