Skip to content

Commit

Permalink
Refactor our data model to support masters/instances (#456)
Browse files Browse the repository at this point in the history
Co-authored-by: Roberto Pastor Muela <[email protected]>
  • Loading branch information
jonahrb and RobPasMue authored Apr 5, 2023
1 parent f6b74fb commit 06dd45d
Show file tree
Hide file tree
Showing 12 changed files with 982 additions and 328 deletions.
1 change: 1 addition & 0 deletions src/ansys/geometry/core/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ansys.geometry.core.connection.client import GrpcClient
from ansys.geometry.core.connection.conversions import (
frame_to_grpc_frame,
grpc_matrix_to_matrix,
plane_to_grpc_plane,
point3d_to_grpc_point,
sketch_shapes_to_grpc_geometries,
Expand Down
23 changes: 22 additions & 1 deletion src/ansys/geometry/core/connection/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from ansys.api.geometry.v0.models_pb2 import Frame as GRPCFrame
from ansys.api.geometry.v0.models_pb2 import Geometries
from ansys.api.geometry.v0.models_pb2 import Line as GRPCLine
from ansys.api.geometry.v0.models_pb2 import Matrix as GRPCMatrix
from ansys.api.geometry.v0.models_pb2 import Plane as GRPCPlane
from ansys.api.geometry.v0.models_pb2 import Point as GRPCPoint
from ansys.api.geometry.v0.models_pb2 import Polygon as GRPCPolygon
from ansys.api.geometry.v0.models_pb2 import Tessellation
from beartype.typing import TYPE_CHECKING, List, Optional, Tuple

from ansys.geometry.core.math import Frame, Plane, Point2D, Point3D, UnitVector3D
from ansys.geometry.core.math import Frame, Matrix44, Plane, Point2D, Point3D, UnitVector3D
from ansys.geometry.core.misc import DEFAULT_UNITS
from ansys.geometry.core.sketch import (
Arc,
Expand Down Expand Up @@ -344,3 +345,23 @@ def tess_to_pd(tess: Tessellation) -> "PolyData":
import pyvista as pv

return pv.PolyData(np.array(tess.vertices).reshape(-1, 3), tess.faces)


def grpc_matrix_to_matrix(m: GRPCMatrix) -> Matrix44:
"""
Convert an ``ansys.api.geometry.Matrix`` class to a
:class:`ansys.geometry.core.math.Matrix44` class.
"""
import numpy as np

return Matrix44(
np.round(
[
[m.m00, m.m01, m.m02, m.m03],
[m.m10, m.m11, m.m12, m.m13],
[m.m20, m.m21, m.m22, m.m23],
[m.m30, m.m31, m.m32, m.m33],
],
8,
)
)
3 changes: 2 additions & 1 deletion src/ansys/geometry/core/designer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Provides the PyGeometry ``designer`` subpackage."""

from ansys.geometry.core.designer.body import Body, MidSurfaceOffsetType
from ansys.geometry.core.designer.body import Body, MidSurfaceOffsetType, TemplateBody
from ansys.geometry.core.designer.component import Component, SharedTopologyType
from ansys.geometry.core.designer.design import Design, DesignFileFormat
from ansys.geometry.core.designer.edge import CurveType, Edge
from ansys.geometry.core.designer.face import Face, SurfaceType
from ansys.geometry.core.designer.part import Part, TransformedPart
from ansys.geometry.core.designer.selection import NamedSelection
Loading

0 comments on commit 06dd45d

Please sign in to comment.