-
Notifications
You must be signed in to change notification settings - Fork 20
feat: tracking boolean operations #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smereu
wants to merge
18
commits into
main
Choose a base branch
from
feat/track_boolean_operations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
97eb31a
chore: update CHANGELOG for v0.9.0 (#1753)
pyansys-ci-bot 1547839
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 5a48878
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 4109456
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu e00316b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 1afa37a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 7c595bb
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 6a23076
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 62ca792
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 40c19c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 2952b14
finalize tracker changes for boolean and update from response
smereu aacd11a
chore: adding changelog file 2153.added.md [dependabot-skip]
pyansys-ci-bot b3b82b8
Merge branch 'main' into feat/track_boolean_operations
RobPasMue 8344d41
chore: adding changelog file 2153.added.md [dependabot-skip]
pyansys-ci-bot 12b13c0
Merge branch 'main' into feat/track_boolean_operations
jacobrkerstetter 15176d3
Merge branch 'main' into feat/track_boolean_operations
jacobrkerstetter e172e45
Delete doc/changelog.d/1753.maintenance.md
RobPasMue 1e711f6
fixing some comments
jacobrkerstetter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tracking boolean operations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1045,6 +1045,55 @@ def __repr__(self) -> str: | |
lines.append(f" N Design Points : {len(self.design_points)}") | ||
return "\n".join(lines) | ||
|
||
def _serialize_tracker_command_response(self, response) -> dict: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't go here IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should live inside the "_grpc" layer since it is purely related to the serialization of gRPC responses |
||
"""Serialize a TrackerCommandResponse object into a dictionary. | ||
|
||
Parameters | ||
---------- | ||
response : TrackerCommandResponse | ||
The gRPC TrackerCommandResponse object to serialize. | ||
|
||
Returns | ||
------- | ||
dict | ||
A dictionary representation of the TrackerCommandResponse object. | ||
""" | ||
|
||
def serialize_body(body): | ||
return { | ||
"id": body.id, | ||
"name": body.name, | ||
"can_suppress": body.can_suppress, | ||
"transform_to_master": { | ||
"m00": body.transform_to_master.m00, | ||
"m11": body.transform_to_master.m11, | ||
"m22": body.transform_to_master.m22, | ||
"m33": body.transform_to_master.m33, | ||
}, | ||
"master_id": body.master_id, | ||
"parent_id": body.parent_id, | ||
} | ||
|
||
def serialize_entity_identifier(entity): | ||
"""Serialize an EntityIdentifier object into a dictionary.""" | ||
return { | ||
"id": entity.id, | ||
} | ||
|
||
return { | ||
"success": response.success, | ||
"created_bodies": [ | ||
serialize_body(body) for body in getattr(response, "created_bodies", []) | ||
], | ||
"modified_bodies": [ | ||
serialize_body(body) for body in getattr(response, "modified_bodies", []) | ||
], | ||
"deleted_bodies": [ | ||
serialize_entity_identifier(entity) | ||
for entity in getattr(response, "deleted_bodies", []) | ||
], | ||
} | ||
|
||
def __read_existing_design(self) -> None: | ||
"""Read an existing ``Design`` located on the server.""" | ||
# | ||
|
@@ -1343,7 +1392,11 @@ def _handle_deleted_bodies(self, deleted_bodies): | |
for body in self.bodies: | ||
if body.id == body_id: | ||
body._is_alive = False | ||
self.bodies.remove(body) | ||
for bd in self._master_component.part.bodies: | ||
if bd.id == body_id: | ||
self._master_component.part.bodies.remove(bd) | ||
break | ||
self._clear_cached_bodies() | ||
removed = True | ||
self._grpc_client.log.info( | ||
f"Deleted body (ID: {body_id}) removed from root level." | ||
|
@@ -1370,10 +1423,11 @@ def _handle_created_bodies(self, created_bodies): | |
) | ||
continue | ||
|
||
added = any(self._find_and_add_body(body_info, self.components)) | ||
added = self._find_and_add_body(body_info, self.components) | ||
if not added: | ||
new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) | ||
self.bodies.append(new_body) | ||
self._master_component.part.bodies.append(new_body) | ||
self._clear_cached_bodies() | ||
self._grpc_client.log.debug( | ||
f"Added new body '{body_name}' (ID: {body_id}) to root level." | ||
) | ||
|
@@ -1388,14 +1442,17 @@ def _update_body(self, existing_body, body_info): | |
|
||
def _find_and_add_body(self, body_info, components): | ||
for component in components: | ||
if component.id == body_info["parent_id"]: | ||
parent_id_for_body = component._master_component.part.id | ||
if parent_id_for_body == body_info["parent_id"]: | ||
new_body = MasterBody( | ||
body_info["id"], | ||
body_info["name"], | ||
self._grpc_client, | ||
is_surface=body_info.get("is_surface", False), | ||
) | ||
component.bodies.append(new_body) | ||
# component.bodies.append(new_body) | ||
component._master_component.part.bodies.append(new_body) | ||
component._clear_cached_bodies() | ||
self._grpc_client.log.debug( | ||
f"Added new body '{new_body.name}' (ID: {new_body.id}) " | ||
f"to component '{component.name}' (ID: {component.id})" | ||
|
@@ -1425,11 +1482,17 @@ def _find_and_update_body(self, body_info, component): | |
|
||
def _find_and_remove_body(self, body_info, component): | ||
for body in component.bodies: | ||
if body.id == body_info["id"]: | ||
body_info_id = body_info["id"] | ||
if body.id == f"{component.id}/{body_info_id}": | ||
body._is_alive = False | ||
component.bodies.remove(body) | ||
# component.bodies.remove(body) | ||
for bd in component._master_component.part.bodies: | ||
if bd.id == body_info_id: | ||
component._master_component.part.bodies.remove(bd) | ||
break | ||
component._clear_cached_bodies() | ||
self._grpc_client.log.debug( | ||
f"Removed body '{body_info['name']}' (ID: {body_info['id']}) from component " | ||
f"Removed body (ID: {body_info['id']}) from component " | ||
f"'{component.name}' (ID: {component.id})" | ||
) | ||
return True | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should align the method used - there is one serialization method as part of this module too. If either one or the other is redundant, we should remove it.