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 src/ansys/geometry/core/designer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Provides the PyGeometry ``designer`` subpackage."""

from ansys.geometry.core.designer.body import Body, MidSurfaceOffsetType, TemplateBody
from ansys.geometry.core.designer.body import Body, MasterBody, MidSurfaceOffsetType
from ansys.geometry.core.designer.component import Component, SharedTopologyType
from ansys.geometry.core.designer.design import Design, DesignFileFormat
from ansys.geometry.core.designer.designpoint import DesignPoint
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.part import MasterComponent, Part
from ansys.geometry.core.designer.selection import NamedSelection
34 changes: 17 additions & 17 deletions src/ansys/geometry/core/designer/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class IBody(ABC):
"""
Abstract Body interface.

Defines the common methods for a body. TemplateBody and Body both inherit from this.
Defines the common methods for a body. MasterBody and Body both inherit from this.
All child classes must implement all abstract methods.
"""

Expand Down Expand Up @@ -443,7 +443,7 @@ def unite(self, other: "Body") -> None:
return


class TemplateBody(IBody):
class MasterBody(IBody):
"""
Represents solids and surfaces organized within the design assembly.

Expand All @@ -460,7 +460,7 @@ class TemplateBody(IBody):
grpc_client : GrpcClient
An active supporting geometry service instance for design modeling.
is_surface : bool, default: False
Boolean indicating whether the ``TemplateBody`` is in fact a surface or an actual
Boolean indicating whether the ``MasterBody`` is in fact a surface or an actual
3D object (with volume).
"""

Expand All @@ -471,7 +471,7 @@ def __init__(
grpc_client: GrpcClient,
is_surface: bool = False,
):
"""Initialize ``TemplateBody`` class."""
"""Initialize ``MasterBody`` class."""
check_type(id, str)
check_type(name, str)
check_type(grpc_client, GrpcClient)
Expand All @@ -489,7 +489,7 @@ def __init__(
self._tessellation = None

def reset_tessellation_cache(func):
"""Decorate ``TemplateBody`` methods that require a tessellation cache update.
"""Decorate ``MasterBody`` methods that require a tessellation cache update.

Parameters
----------
Expand All @@ -503,7 +503,7 @@ def reset_tessellation_cache(func):
"""

@wraps(func)
def wrapper(self: "TemplateBody", *args, **kwargs):
def wrapper(self: "MasterBody", *args, **kwargs):
self._tessellation = None
return func(self, *args, **kwargs)

Expand Down Expand Up @@ -614,7 +614,7 @@ def imprint_curves(
) -> Tuple[List[Edge], List[Face]]: # noqa: D102
raise NotImplementedError(
"""
imprint_curves is not implemented at the TemplateBody level.
imprint_curves is not implemented at the MasterBody level.
Instead, call this method on a Body.
"""
)
Expand All @@ -630,7 +630,7 @@ def project_curves(
) -> List[Face]: # noqa: D102
raise NotImplementedError(
"""
project_curves is not implemented at the TemplateBody level.
project_curves is not implemented at the MasterBody level.
Instead, call this method on a Body.
"""
)
Expand Down Expand Up @@ -676,7 +676,7 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102
)

# Assign the new body to its specified parent (and return the new body)
tb = TemplateBody(
tb = MasterBody(
response.master_id, copy_name, self._grpc_client, is_surface=self.is_surface
)
parent._transformed_part.part.bodies.append(tb)
Expand Down Expand Up @@ -726,23 +726,23 @@ def plot(

def intersect(self, other: "Body") -> None: # noqa: D102
raise NotImplementedError(
"TemplateBody does not implement boolean methods. Call this method on a Body instead."
"MasterBody does not implement boolean methods. Call this method on a Body instead."
)

def subtract(self, other: "Body") -> None: # noqa: D102
raise NotImplementedError(
"TemplateBody does not implement boolean methods. Call this method on a Body instead."
"MasterBody does not implement boolean methods. Call this method on a Body instead."
)

def unite(self, other: "Body") -> None:
# noqa: D102
raise NotImplementedError(
"TemplateBody does not implement boolean methods. Call this method on a Body instead."
"MasterBody does not implement boolean methods. Call this method on a Body instead."
)

def __repr__(self) -> str:
"""Represent the ``TemplateBody`` as a string."""
lines = [f"ansys.geometry.core.designer.TemplateBody {hex(id(self))}"]
"""Represent the ``MasterBody`` as a string."""
lines = [f"ansys.geometry.core.designer.MasterBody {hex(id(self))}"]
lines.append(f" Name : {self.name}")
lines.append(f" Exists : {self.is_alive}")
lines.append(f" Surface body : {self.is_surface}")
Expand All @@ -767,11 +767,11 @@ class Body(IBody):
User-defined label for the body.
parent : Component
Parent component to nest the new component under within the design assembly.
template : TemplateBody
template : MasterBody
The master body that this body is an occurrence of.
"""

def __init__(self, id, name, parent: "Component", template: TemplateBody) -> None:
def __init__(self, id, name, parent: "Component", template: MasterBody) -> None:
"""Initialize ``Body`` class."""
self._id = id
self._name = name
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def __repr__(self) -> str:
lines.append(f" Name : {self.name}")
lines.append(f" Exists : {self.is_alive}")
lines.append(f" Parent component : {self._parent.name}")
lines.append(f" TemplateBody : {self._template.id}")
lines.append(f" MasterBody : {self._template.id}")
lines.append(f" Surface body : {self.is_surface}")
if self.is_surface:
lines.append(f" Surface thickness : {self.surface_thickness}")
Expand Down
24 changes: 12 additions & 12 deletions src/ansys/geometry/core/designer/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
)
from ansys.geometry.core.connection.conversions import point3d_to_grpc_point
from ansys.geometry.core.designer.beam import Beam, BeamProfile
from ansys.geometry.core.designer.body import Body, TemplateBody
from ansys.geometry.core.designer.body import Body, MasterBody
from ansys.geometry.core.designer.coordinate_system import CoordinateSystem
from ansys.geometry.core.designer.designpoint import DesignPoint
from ansys.geometry.core.designer.face import Face
from ansys.geometry.core.designer.part import Part, TransformedPart
from ansys.geometry.core.designer.part import MasterComponent, Part
from ansys.geometry.core.errors import protect_grpc
from ansys.geometry.core.math import (
IDENTITY_MATRIX44,
Expand Down Expand Up @@ -87,7 +87,7 @@ class Component:
If a component already exists on the server, you can pass in its ID to create it on the
client-side data model. If this is argument is present, a new Component will not be created
on the server.
transformed_part : TransformedPart, optional
transformed_part : MasterComponent, optional
This argument should be present when creating a nested instance component. It will use the
given transformed_part instead of creating a new one.
read_existing_comp : bool, optional
Expand All @@ -112,7 +112,7 @@ def __init__(
grpc_client: GrpcClient,
template: Optional["Component"] = None,
preexisting_id: Optional[str] = None,
transformed_part: Optional[TransformedPart] = None,
transformed_part: Optional[MasterComponent] = None,
read_existing_comp: bool = False,
):
"""Initialize ``Component`` class."""
Expand Down Expand Up @@ -152,8 +152,8 @@ def __init__(
if template:
# If this is not a nested instance
if not transformed_part:
# Create new TransformedPart, but use template's Part
tp = TransformedPart(
# Create new MasterComponent, but use template's Part
tp = MasterComponent(
uuid.uuid4(),
f"tp_{name}",
template._transformed_part.part,
Expand All @@ -167,9 +167,9 @@ def __init__(
return

elif not read_existing_comp:
# This is an independent Component - Create new Part and TransformedPart
# This is an independent Component - Create new Part and MasterComponent
p = Part(uuid.uuid4(), f"p_{name}", [], [])
tp = TransformedPart(uuid.uuid4(), f"tp_{name}", p)
tp = MasterComponent(uuid.uuid4(), f"tp_{name}", p)
p.parts.append(tp)
self._transformed_part = tp

Expand Down Expand Up @@ -401,7 +401,7 @@ def extrude_sketch(

self._grpc_client.log.debug(f"Extruding sketch provided on {self.id}. Creating body...")
response = self._bodies_stub.CreateExtrudedBody(request)
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=False)
tb = MasterBody(response.master_id, name, self._grpc_client, is_surface=False)
self._transformed_part.part.bodies.append(tb)
return Body(response.id, response.name, self, tb)

Expand Down Expand Up @@ -448,7 +448,7 @@ def extrude_face(self, name: str, face: Face, distance: Union[Quantity, Distance
self._grpc_client.log.debug(f"Extruding from face provided on {self.id}. Creating body...")
response = self._bodies_stub.CreateExtrudedBodyFromFaceProfile(request)

tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=False)
tb = MasterBody(response.master_id, name, self._grpc_client, is_surface=False)
self._transformed_part.part.bodies.append(tb)
return Body(response.id, response.name, self, tb)

Expand Down Expand Up @@ -485,7 +485,7 @@ def create_surface(self, name: str, sketch: Sketch) -> Body:
)
response = self._bodies_stub.CreatePlanarBody(request)

tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=True)
tb = MasterBody(response.master_id, name, self._grpc_client, is_surface=True)
self._transformed_part.part.bodies.append(tb)
return Body(response.id, response.name, self, tb)

Expand Down Expand Up @@ -525,7 +525,7 @@ def create_surface_from_face(self, name: str, face: Face) -> Body:
)
response = self._bodies_stub.CreateBodyFromFace(request)

tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=True)
tb = MasterBody(response.master_id, name, self._grpc_client, is_surface=True)
self._transformed_part.part.bodies.append(tb)
return Body(response.id, response.name, self, tb)

Expand Down
14 changes: 7 additions & 7 deletions src/ansys/geometry/core/designer/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
point3d_to_grpc_point,
)
from ansys.geometry.core.designer.beam import Beam, BeamCircularProfile, BeamProfile
from ansys.geometry.core.designer.body import Body, MidSurfaceOffsetType, TemplateBody
from ansys.geometry.core.designer.body import Body, MasterBody, MidSurfaceOffsetType
from ansys.geometry.core.designer.component import Component, SharedTopologyType
from ansys.geometry.core.designer.coordinate_system import CoordinateSystem
from ansys.geometry.core.designer.designpoint import DesignPoint
from ansys.geometry.core.designer.edge import Edge
from ansys.geometry.core.designer.face import Face
from ansys.geometry.core.designer.part import Part, TransformedPart
from ansys.geometry.core.designer.part import MasterComponent, Part
from ansys.geometry.core.designer.selection import NamedSelection
from ansys.geometry.core.errors import protect_grpc
from ansys.geometry.core.materials import Material, MaterialProperty, MaterialPropertyType
Expand Down Expand Up @@ -571,12 +571,12 @@ def __read_existing_design(self) -> None:
created_bodies = {}

# Make dummy TP for design since server doesn't have one
self._transformed_part = TransformedPart("1", "tp_design", created_parts[self.id])
self._transformed_part = MasterComponent("1", "tp_design", created_parts[self.id])

# Create TransformedParts
# Create MasterComponents
for tp in response.transformed_parts:
part = created_parts.get(tp.part_master.id)
new_tp = TransformedPart(tp.id, tp.name, part, grpc_matrix_to_matrix(tp.placement))
new_tp = MasterComponent(tp.id, tp.name, part, grpc_matrix_to_matrix(tp.placement))
created_tps[tp.id] = new_tp

# Create Components
Expand All @@ -598,7 +598,7 @@ def __read_existing_design(self) -> None:
# TODO: is_surface?
for body in response.bodies:
part = created_parts.get(body.parent_id)
tb = TemplateBody(body.id, body.name, self._grpc_client)
tb = MasterBody(body.id, body.name, self._grpc_client)
part.bodies.append(tb)
created_bodies[body.id] = tb

Expand Down Expand Up @@ -647,7 +647,7 @@ def __read_existing_design(self) -> None:
num_created_shared_topologies += 1

self._grpc_client.log.debug(f"Parts created: {len(created_parts)}")
self._grpc_client.log.debug(f"TransformedParts created: {len(created_tps) + 1}")
self._grpc_client.log.debug(f"MasterComponents created: {len(created_tps) + 1}")
self._grpc_client.log.debug(f"Components created: {len(created_components)}")
self._grpc_client.log.debug(f"Bodies created: {len(created_bodies)}")
self._grpc_client.log.debug(f"Materials created: {len(self.materials)}")
Expand Down
38 changes: 19 additions & 19 deletions src/ansys/geometry/core/designer/part.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Provides the ``Part`` class module."""
from beartype.typing import List

from ansys.geometry.core.designer.body import TemplateBody
from ansys.geometry.core.designer.body import MasterBody
from ansys.geometry.core.math import IDENTITY_MATRIX44, Matrix44


Expand All @@ -17,20 +17,20 @@ class Part:
Unique identifier for this part.
name : str
Name of this part.
parts : List[TransformedPart]
List of TransformedPart children that this Part contains.
bodies : List[TemplateBody]
List of TemplateBody children that this Part contains. These are master bodies.
parts : List[MasterComponent]
List of MasterComponent children that this Part contains.
bodies : List[MasterBody]
List of MasterBody children that this Part contains. These are master bodies.
"""

def __init__(
self, id: str, name: str, parts: List["TransformedPart"], bodies: List[TemplateBody]
self, id: str, name: str, parts: List["MasterComponent"], bodies: List[MasterBody]
) -> None:
"""Initialize the ``Part`` class."""
self._id: str = id
self._name: str = name
self._parts: List["TransformedPart"] = parts
self._bodies: List[TemplateBody] = bodies
self._parts: List["MasterComponent"] = parts
self._bodies: List[MasterBody] = bodies

@property
def id(self) -> str:
Expand All @@ -43,25 +43,25 @@ def name(self) -> str:
return self._name

@property
def parts(self) -> List["TransformedPart"]:
"""``TransformedPart`` children that this ``Part`` contains."""
def parts(self) -> List["MasterComponent"]:
"""``MasterComponent`` children that this ``Part`` contains."""
return self._parts

@parts.setter
def parts(self, parts: List["TransformedPart"]) -> None:
def parts(self, parts: List["MasterComponent"]) -> None:
self._parts = parts

@property
def bodies(self) -> List[TemplateBody]:
def bodies(self) -> List[MasterBody]:
"""
``TemplateBody`` children that this ``Part`` contains.
``MasterBody`` children that this ``Part`` contains.

These are master bodies.
"""
return self._bodies

@bodies.setter
def bodies(self, bodies: List["TemplateBody"]) -> None:
def bodies(self, bodies: List["MasterBody"]) -> None:
self._bodies = bodies

def __repr__(self) -> str:
Expand All @@ -74,14 +74,14 @@ def __repr__(self) -> str:
)


class TransformedPart:
class MasterComponent:
"""
Represents a Part Occurrence.

Notes
-----
This class should not be accessed by users.
TransformedParts hold fundamental data of an assembly. TransformedParts wrap Parts
MasterComponents hold fundamental data of an assembly. MasterComponents wrap Parts
by adding a transform matrix.

Parameters
Expand All @@ -99,7 +99,7 @@ class TransformedPart:
def __init__(
self, id: str, name: str, part: Part, transform: Matrix44 = IDENTITY_MATRIX44
) -> None:
"""Initialize ``TransformedPart`` class."""
"""Initialize ``MasterComponent`` class."""
self._id: str = id
self._name: str = name
self._part: Part = part
Expand Down Expand Up @@ -130,9 +130,9 @@ def transform(self, matrix: Matrix44) -> None:
self._transform = matrix

def __repr__(self) -> str:
"""Represent the ``TransformedPart`` as a string."""
"""Represent the ``MasterComponent`` as a string."""
return (
f"TransformedPart(id={self.id}, "
f"MasterComponent(id={self.id}, "
f"name={self.name}, "
f"template={self.part}, "
f"transform={self.transform})"
Expand Down
Loading