Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 564b4a8012 | |||
| a06c9023fc |
@@ -6,7 +6,7 @@
|
||||
"dockerFile": "../Dockerfile",
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "poetry install --no-root",
|
||||
"postCreateCommand": "poetry install --no-root",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
|
||||
@@ -4,8 +4,6 @@ dist/
|
||||
*.egg-info/
|
||||
.cache/
|
||||
*.log
|
||||
.ruff_cache/
|
||||
.venv/
|
||||
.env/
|
||||
.git/
|
||||
Dockerfile copy*
|
||||
Regular → Executable
+3
-1
@@ -246,4 +246,6 @@ COPY . /home/speckle
|
||||
|
||||
# Using poetry, we generate a list of requirements, save them to requirements.txt, and then use pip to install them
|
||||
RUN poetry export --format requirements.txt --output /home/speckle/requirements.txt --without-hashes && \
|
||||
pip install --requirement /home/speckle/requirements.txt
|
||||
pip install --requirement /home/speckle/requirements.txt
|
||||
|
||||
RUN poetry install --no-root
|
||||
+2
-4
@@ -46,7 +46,7 @@ def detect_clashes_old(
|
||||
continue
|
||||
|
||||
intersection = pymesh.boolean(
|
||||
latest_pymesh, operation="intersection"
|
||||
latest_pymesh, ref_pymesh, operation="intersection"
|
||||
)
|
||||
|
||||
if (
|
||||
@@ -82,9 +82,7 @@ def check_for_clash(
|
||||
if not ref_pymesh or not latest_pymesh:
|
||||
continue
|
||||
|
||||
intersection = pymesh.boolean(
|
||||
latest_pymesh, operation="intersection"
|
||||
)
|
||||
intersection = pymesh.boolean(latest_pymesh, ref_pymesh, operation="intersection")
|
||||
if intersection and intersection.volume > 0:
|
||||
severity = intersection.volume / min(
|
||||
ref_pymesh.volume, latest_pymesh.volume
|
||||
|
||||
+2
-11
@@ -12,15 +12,6 @@ import trimesh
|
||||
from Geometry.helpers import triangulate_face
|
||||
|
||||
|
||||
class MockPyMesh:
|
||||
def __init__(self, vertices, faces):
|
||||
self.vertices = vertices or []
|
||||
self.faces = faces or []
|
||||
|
||||
def boolean(self, other, operation):
|
||||
return MockPyMesh([], [])
|
||||
|
||||
|
||||
def trimesh_to_pymesh(mesh: trimesh.Trimesh) -> pymesh.Mesh:
|
||||
"""
|
||||
Convert a Trimesh object to a Pymesh object.
|
||||
@@ -44,7 +35,7 @@ def pymesh_to_trimesh(mesh: pymesh.Mesh) -> trimesh.Trimesh:
|
||||
|
||||
|
||||
def cast(
|
||||
mesh: Union[trimesh.Trimesh, pymesh.Mesh], target_type: Type
|
||||
mesh: Union[trimesh.Trimesh, pymesh.Mesh], target_type: Type
|
||||
) -> Union[trimesh.Trimesh, pymesh.Mesh]:
|
||||
"""
|
||||
Casts a mesh object to a specified type.
|
||||
@@ -79,7 +70,7 @@ def speckle_mesh_to_trimesh(input_mesh: SpeckleMesh) -> trimesh.Trimesh:
|
||||
face_vertex_count = input_mesh.faces[i]
|
||||
i += 1 # Skip the vertex count
|
||||
|
||||
face_vertex_indices = input_mesh.faces[i: i + face_vertex_count]
|
||||
face_vertex_indices = input_mesh.faces[i : i + face_vertex_count]
|
||||
|
||||
face_vertices = [
|
||||
Vector.from_list(vertices[idx].tolist()) for idx in face_vertex_indices
|
||||
|
||||
+9
-8
@@ -1,12 +1,13 @@
|
||||
class mypymesh:
|
||||
def __init__(self, vertices, faces):
|
||||
self.vertices = vertices
|
||||
self.faces = faces
|
||||
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([], [])
|
||||
|
||||
@property
|
||||
def volume(self):
|
||||
return 0
|
||||
return mypymesh.Mesh([], [])
|
||||
|
||||
@@ -36,27 +36,25 @@ class FunctionInputs(AutomateBase):
|
||||
title="Static Model Name",
|
||||
description="Name of the static structural model.",
|
||||
)
|
||||
|
||||
|
||||
tolerance: float = Field(
|
||||
default=25.0,
|
||||
title="Tolerance",
|
||||
description="Specify the tolerance value for the analysis. \
|
||||
Negative values relaxes the test, positive values make it more strict.",
|
||||
readonly=True,
|
||||
)
|
||||
tolerance_unit: str = Field( # Using the SpecklePy Units enum here
|
||||
default=Units.mm,
|
||||
json_schema_extra={"examples": ["mm", "cm", "m"]},
|
||||
title="Tolerance Unit",
|
||||
description="Unit of the tolerance value.",
|
||||
readonly=True,
|
||||
)
|
||||
tolerance: float = Field(
|
||||
default=25.0,
|
||||
title="Tolerance",
|
||||
description="Specify the tolerance value for the analysis. \
|
||||
Negative values relaxes the test, positive values make it more strict.",
|
||||
readonly=True,
|
||||
)
|
||||
tolerance_unit: str = Field( # Using the SpecklePy Units enum here
|
||||
default=Units.mm,
|
||||
json_schema_extra={"examples": ["mm", "cm", "m"]},
|
||||
title="Tolerance Unit",
|
||||
description="Unit of the tolerance value.",
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
|
||||
def automate_function(
|
||||
automate_context: AutomationContext,
|
||||
function_inputs: FunctionInputs,
|
||||
automate_context: AutomationContext,
|
||||
function_inputs: FunctionInputs,
|
||||
) -> None:
|
||||
"""This is an example Speckle Automate function.
|
||||
|
||||
@@ -129,26 +127,21 @@ def automate_function(
|
||||
speckle_to_element(obj) for obj in latest_displayable_objects
|
||||
]
|
||||
|
||||
# using trimesh library process all these meshes in the form of A vs B
|
||||
# and get the clashes
|
||||
tolerance = function_inputs.tolerance
|
||||
|
||||
clashes = detect_and_report_clashes(
|
||||
reference_mesh_elements, latest_mesh_elements, tolerance, automate_context
|
||||
)
|
||||
|
||||
# all object count
|
||||
# all reference objects count
|
||||
# all latest objects count
|
||||
|
||||
percentage_reference_objects_clashing = (
|
||||
len(set([ref_id for ref_id, latest_id, severity in clashes]))
|
||||
/ len(reference_mesh_elements)
|
||||
* 100
|
||||
len(set([ref_id for ref_id, latest_id, severity in clashes]))
|
||||
/ len(reference_mesh_elements)
|
||||
* 100
|
||||
)
|
||||
percentage_latest_objects_clashing = (
|
||||
len(set([latest_id for ref_id, latest_id, severity in clashes]))
|
||||
/ len(latest_mesh_elements)
|
||||
* 100
|
||||
len(set([latest_id for ref_id, latest_id, severity in clashes]))
|
||||
/ len(latest_mesh_elements)
|
||||
* 100
|
||||
)
|
||||
|
||||
# all clashes count
|
||||
@@ -170,7 +163,7 @@ def automate_function(
|
||||
|
||||
|
||||
def get_reference_model(
|
||||
automate_context: AutomationContext, static_model_name: str
|
||||
automate_context: AutomationContext, static_model_name: str
|
||||
) -> Base:
|
||||
# the static reference model will be retrieved from the project using model name stored in the inputs
|
||||
speckle_client = automate_context.speckle_client
|
||||
|
||||
Generated
+15
-1
@@ -796,6 +796,20 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
|
||||
[package.extras]
|
||||
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "python-dotenv"
|
||||
version = "1.0.0"
|
||||
description = "Read key-value pairs from a .env file and set them as environment variables"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"},
|
||||
{file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
cli = ["click (>=5.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "requests"
|
||||
version = "2.31.0"
|
||||
@@ -1274,4 +1288,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "3abedc1c21df21ba5ab28f1ea6dc49c8a84c768e0f8f155e5c619ca3fd023765"
|
||||
content-hash = "e4e56818583a9f0fad2adbfbc4dcb2ebaa1fc8f917004477f0e1574237b7850a"
|
||||
|
||||
@@ -15,6 +15,7 @@ black = "^23.3.0"
|
||||
mypy = "^1.3.0"
|
||||
ruff = "^0.0.271"
|
||||
pytest = "^7.4.2"
|
||||
python-dotenv = "^1.0.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
||||
Reference in New Issue
Block a user