Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7418644
preliminary impl of rayfire methods
jacobrkerstetter Jan 20, 2026
e62c005
test: added simple test case
jacobrkerstetter Jan 21, 2026
ec873a5
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Jan 27, 2026
64af449
moving rayfire to separate module
jacobrkerstetter Jan 27, 2026
697c856
commenting out rayfire options conversion until protos gets updated
jacobrkerstetter Jan 27, 2026
4a8ea71
rayfire test fixes
jacobrkerstetter Jan 28, 2026
baf3e9d
wip
jacobrkerstetter Jan 28, 2026
7c90567
test adjustments
jacobrkerstetter Jan 28, 2026
47f131d
implemented rayfire impacts class and working on tests
jacobrkerstetter Feb 2, 2026
23916a6
implementation working - needs 3 tests
jacobrkerstetter Feb 3, 2026
aa6bfda
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Feb 3, 2026
594ba36
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Feb 3, 2026
aa51e88
chore: adding changelog file 2552.added.md [dependabot-skip]
pyansys-ci-bot Feb 3, 2026
0cdfd92
bump protos
jacobrkerstetter Feb 3, 2026
12ce369
Merge branch 'feat/rayfire_support' of https://github.com/ansys/pyans…
jacobrkerstetter Feb 3, 2026
d30c2aa
remove unsupported
jacobrkerstetter Feb 3, 2026
3c16c31
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Feb 3, 2026
b7f6191
adding test coverage for rayfire options and making capitalization co…
jacobrkerstetter Feb 3, 2026
06acb03
Merge branch 'feat/rayfire_support' of https://github.com/ansys/pyans…
jacobrkerstetter Feb 3, 2026
2dddbe8
changing naming to fire from rayfire
jacobrkerstetter Feb 3, 2026
86cd2fc
fixing v1 tests
jacobrkerstetter Feb 3, 2026
b98d3b2
Merge branch 'main' into feat/rayfire_support
jacobrkerstetter Feb 3, 2026
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
1 change: 1 addition & 0 deletions doc/changelog.d/2552.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implement RayFire tools
26 changes: 26 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .base.patterns import GRPCPatternsService
from .base.points import GRPCPointsService
from .base.prepare_tools import GRPCPrepareToolsService
from .base.rayfire import GRPCRayfireService
from .base.repair_tools import GRPCRepairToolsService
from .base.unsupported import GRPCUnsupportedService

Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
self._patterns = None
self._points = None
self._prepare_tools = None
self._rayfire = None
self._repair_tools = None
self._unsupported = None

Expand Down Expand Up @@ -636,6 +638,30 @@ def prepare_tools(self) -> GRPCPrepareToolsService:

return self._prepare_tools

@property
def rayfire(self) -> GRPCRayfireService:
"""
Get the rayfire service for the specified version.

Returns
-------
RayfireServiceBase
The rayfire service for the specified version.
"""
if not self._rayfire:
from .v0.rayfire import GRPCRayfireServiceV0
from .v1.rayfire import GRPCRayfireServiceV1

if self.version == GeometryApiProtos.V0:
self._rayfire = GRPCRayfireServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1:
self._rayfire = GRPCRayfireServiceV1(self.channel)
else: # pragma: no cover
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._rayfire

@property
def repair_tools(self) -> GRPCRepairToolsService:
"""
Expand Down
60 changes: 60 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/rayfire.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the rayfire service implementation (abstraction layer)."""

from abc import ABC, abstractmethod

import grpc


class GRPCRayfireService(ABC): # pragma: no cover
"""Rayfire service for gRPC communication with the Geometry server.

Parameters
----------
channel : grpc.Channel
The gRPC channel to the server.
"""

def __init__(self, channel: grpc.Channel):
"""Initialize the GRPCRayfireService class."""
pass

@abstractmethod
def fire(self, **kwargs) -> dict:
"""Perform a rayfire operation to find impacted bodies."""
pass

@abstractmethod
def fire_ordered(self, **kwargs) -> dict:
"""Perform a rayfire ordered operation."""
pass

@abstractmethod
def fire_faces(self, **kwargs) -> dict:
"""Perform a rayfire operation to find impacted faces."""
pass

@abstractmethod
def fire_ordered_uv(self, **kwargs) -> dict:
"""Perform a rayfire ordered UV operation."""
pass
31 changes: 30 additions & 1 deletion src/ansys/geometry/core/_grpc/_services/v0/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
PartExportFormat as GRPCPartExportFormat,
)
from ansys.api.dbu.v0.drivingdimensions_pb2 import UpdateStatus as GRPCUpdateStatus
from ansys.api.geometry.v0.commands_pb2 import RayFireAddtionalOptions as GRPCRayFireOptions
from ansys.api.geometry.v0.models_pb2 import (
Arc as GRPCArc,
Circle as GRPCCircle,
Expand Down Expand Up @@ -77,7 +78,7 @@
from ansys.geometry.core.math.plane import Plane
from ansys.geometry.core.math.point import Point2D, Point3D
from ansys.geometry.core.math.vector import UnitVector3D
from ansys.geometry.core.misc.options import TessellationOptions
from ansys.geometry.core.misc.options import RayfireOptions, TessellationOptions
from ansys.geometry.core.parameters.parameter import (
Parameter,
ParameterUpdateStatus,
Expand Down Expand Up @@ -1410,6 +1411,34 @@ def from_grpc_matrix_to_matrix(matrix: GRPCMatrix) -> "Matrix44":
)


def from_rayfire_options_to_grpc_rayfire_options(options: "RayfireOptions") -> GRPCRayFireOptions:
"""Convert a ``RayFireOptions`` class to a gRPC RayFireOptions message.

Parameters
----------
options : RayFireOptions
Source ray fire options.

Returns
-------
GRPCRayFireOptions
Geometry service gRPC RayFireOptions message.
"""
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS

return GRPCRayFireOptions(
radius=options.radius.m_as(DEFAULT_UNITS.SERVER_LENGTH),
direction=from_unit_vector_to_grpc_direction(options.direction),
max_distance=options.max_distance.m_as(DEFAULT_UNITS.SERVER_LENGTH),
min_distance=options.min_distance.m_as(DEFAULT_UNITS.SERVER_LENGTH),
tight_tolerance=options.tight_tolerance,
pick_back_faces=options.pick_back_faces,
max_hits=options.max_hits,
request_params=options.request_params,
request_secondary=options.request_secondary,
)


def _nurbs_curves_compatibility(backend_version: "semver.Version", grpc_geometries: GRPCGeometries):
"""Check if the backend version is compatible with NURBS curves in sketches.

Expand Down
205 changes: 205 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/rayfire.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the rayfire service implementation for v0."""

import grpc

from ansys.geometry.core.errors import protect_grpc

from ..base.conversions import from_measurement_to_server_length
from ..base.rayfire import GRPCRayfireService
from .conversions import (
build_grpc_id,
from_grpc_point_to_point3d,
from_point3d_to_grpc_point,
from_unit_vector_to_grpc_direction,
)


class GRPCRayfireServiceV0(GRPCRayfireService):
"""Rayfire service for gRPC communication with the Geometry server.

This class provides methods to interact with the Geometry server's
rayfire service. It is specifically designed for the v0 version of the
Geometry API.

Parameters
----------
channel : grpc.Channel
The gRPC channel to the server.
"""

@protect_grpc
def __init__(self, channel: grpc.Channel): # noqa: D102
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub

self.stub = CommandsStub(channel)

@protect_grpc
def fire(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.commands_pb2 import RayFireRequest, RayFireRequestData

# Create the request - assumes all inputs are valid and of the proper type
request = RayFireRequest(
request_data=[
RayFireRequestData(
body=build_grpc_id(kwargs["body_id"]),
faces=[build_grpc_id(face_id) for face_id in kwargs["face_ids"]],
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
points=[from_point3d_to_grpc_point(point) for point in kwargs["points"]],
max_distance=from_measurement_to_server_length(kwargs["max_distance"]),
)
]
)

# Call the gRPC service
response = self.stub.RayFire(request).response_data[0]

# Return the response - formatted as a dictionary
return {
"impacts": [
{"body_id": impact.body, "point": from_grpc_point_to_point3d(impact.point)}
for impact in response.single_ray_fire_impacts.impacts
]
}

@protect_grpc
def fire_ordered(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.commands_pb2 import (
RayFireOrderedRequest,
RayFireOrderedRequestData,
)

# Create the request - assumes all inputs are valid and of the proper type
request = RayFireOrderedRequest(
request_data=[
RayFireOrderedRequestData(
body=build_grpc_id(kwargs["body_id"]),
faces=[build_grpc_id(face_id) for face_id in kwargs["face_ids"]],
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
ray_radius=from_measurement_to_server_length(kwargs["ray_radius"]),
points=[from_point3d_to_grpc_point(point) for point in kwargs["points"]],
max_distance=from_measurement_to_server_length(kwargs["max_distance"]),
tight_tolerance=kwargs["tight_tolerance"],
)
]
)

# Call the gRPC service
response = self.stub.RayFireOrdered(request).response_data[0]

# Return the response - formatted as a dictionary
return {
"ordered_impacts": [
{
"impacts": [
{"body_id": impact.body, "point": from_grpc_point_to_point3d(impact.point)}
for impact in ordered_impacts.impacts
]
}
for ordered_impacts in response.ordered_ray_fire_impacts
]
}

@protect_grpc
def fire_faces(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.commands_pb2 import RayFireFacesRequest, RayFireFacesRequestData

from .conversions import from_rayfire_options_to_grpc_rayfire_options

# Create options
options = (
from_rayfire_options_to_grpc_rayfire_options(kwargs["options"])
if kwargs["options"]
else None
)

# Create the request - assumes all inputs are valid and of the proper type
request = RayFireFacesRequest(
request_data=[
RayFireFacesRequestData(
body=build_grpc_id(kwargs["body_id"]),
faces=[build_grpc_id(face_id) for face_id in kwargs["face_ids"]],
points=[from_point3d_to_grpc_point(point) for point in kwargs["points"]],
options=options,
)
]
)

# Call the gRPC service
response = self.stub.RayFireFaces(request).response_data[0]

# Return the response - formatted as a dictionary
return {
"face_impacts": [
{
"impacts": [
{"face_id": impact.face, "point": from_grpc_point_to_point3d(impact.point)}
for impact in face_impact.impacts
]
}
for face_impact in response.faces_ray_fire_impacts
]
}

@protect_grpc
def fire_ordered_uv(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.commands_pb2 import (
RayFireOrderedUVRequest,
RayFireOrderedUVRequestData,
)

# Create the request - assumes all inputs are valid and of the proper type
request = RayFireOrderedUVRequest(
request_data=[
RayFireOrderedUVRequestData(
body=build_grpc_id(kwargs["body_id"]),
faces=[build_grpc_id(face_id) for face_id in kwargs["face_ids"]],
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
ray_radius=from_measurement_to_server_length(kwargs["ray_radius"]),
points=[from_point3d_to_grpc_point(point) for point in kwargs["points"]],
max_distance=from_measurement_to_server_length(kwargs["max_distance"]),
tight_tolerance=kwargs["tight_tolerance"],
)
]
)

# Call the gRPC service
response = self.stub.RayFireOrderedUV(request).response_data[0]

# Return the response - formatted as a dictionary
return {
"ordered_impacts": [
{
"impacts": [
{
"body_id": impact.body,
"point": from_grpc_point_to_point3d(impact.point),
"u": impact.u,
"v": impact.v,
}
for impact in ordered_impact.impacts
]
}
for ordered_impact in response.ordered_ray_fire_impacts
]
}
Loading
Loading