Skip to content

Commit

Permalink
remove superfluous rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
j-zimmermann committed Aug 28, 2024
1 parent 7830f1f commit 93cb806
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
24 changes: 15 additions & 9 deletions ossdbs/electrodes/abbott_stjude.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def _construct_geometry(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:

def __body(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
radius = self._parameters.lead_diameter * 0.5
point = tuple(np.array(self._direction) * radius)
center = tuple(np.array(self._direction) * radius)
height = self._parameters.total_length - self._parameters.tip_length
body = occ.Cylinder(p=point, d=self._direction, r=radius, h=height)
body = occ.Cylinder(p=center, d=self._direction, r=radius, h=height)
body.bc(self._boundaries["Body"])
return body

Expand Down Expand Up @@ -168,6 +168,17 @@ class AbbottStJudeDirectedModel(ElectrodeModel):
def _construct_encapsulation_geometry(
self, thickness: float
) -> netgen.libngpy._NgOCC.TopoDS_Shape:
"""Generate geometry of encapsulation layer around electrode.
Parameters
----------
thickness : float
Thickness of encapsulation layer.
Returns
-------
geometry : netgen.libngpy._NgOCC.TopoDS_Shape
"""
center = tuple(np.array(self._direction) * self._parameters.lead_diameter * 0.5)
radius = self._parameters.lead_diameter * 0.5 + thickness
height = self._parameters.total_length - self._parameters.tip_length
Expand Down Expand Up @@ -265,15 +276,12 @@ def _contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
height = self._parameters.contact_length
body = occ.Cylinder(p=point, d=direction, r=radius, h=height)
# tilted y-vector marker is in YZ-plane and orthogonal to _direction
new_direction = (0, direction[2], -direction[1])
new_direction = (0, 1, 0)
eraser = occ.HalfSpace(p=point, n=new_direction)
delta = 15
angle = 30 + delta
angle = 45
axis = occ.Axis(p=point, d=direction)

contact = body - eraser.Rotate(axis, angle) - eraser.Rotate(axis, -angle)
# Centering contact to label edges
contact = contact.Rotate(axis, angle)

# Label all outer edges
for edge in contact.edges:
Expand All @@ -289,6 +297,4 @@ def _contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
if not np.isclose(np.linalg.norm(edge_center - new_center), radius / 2):
edge.name = "Rename"

contact = contact.Rotate(axis, -angle)

return contact
2 changes: 0 additions & 2 deletions ossdbs/electrodes/boston_scientific_cartesia.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ def _contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:

# TODO check that the starting axis of the contacts
# are correct according to the documentation
# contact = contact.Rotate(axis, -angle)

return contact


Expand Down
1 change: 1 addition & 0 deletions ossdbs/electrodes/boston_scientific_vercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _contacts(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
contact_tip = occ.Sphere(c=center, r=radius) * half_space
h_pt2 = self._parameters.tip_length - radius
contact_pt2 = occ.Cylinder(p=center, d=direction, r=radius, h=h_pt2)
# defining first contact
contact_1 = contact_tip + contact_pt2

vectors = []
Expand Down
10 changes: 2 additions & 8 deletions ossdbs/electrodes/medtronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,12 @@ def _contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
height = self._parameters.contact_length
body = occ.Cylinder(p=point, d=direction, r=radius, h=height)
# tilted y-vector marker is in YZ-plane and orthogonal to _direction
new_direction = (0, direction[2], -direction[1])
new_direction = (0, 1, 0)
eraser = occ.HalfSpace(p=point, n=new_direction)
delta = 15
angle = 30 + delta
angle = 45
axis = occ.Axis(p=point, d=direction)

contact = body - eraser.Rotate(axis, angle) - eraser.Rotate(axis, -angle)
# Centering contact to label edges
contact = contact.Rotate(axis, angle)

# Label all outer edges
for edge in contact.edges:
Expand All @@ -273,7 +270,4 @@ def _contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
if not np.isclose(np.linalg.norm(edge_center - new_center), radius / 2):
edge.name = "Rename"

# Reseting position so that 0 deg lies in the middle of contact
contact = contact.Rotate(axis, -angle)

return contact

0 comments on commit 93cb806

Please sign in to comment.