Skip to content

Commit

Permalink
Fixes for analysis functions to include jumpDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
drlukeparry committed Feb 1, 2022
1 parent de7f20a commit 3bce788
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions pyslm/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,37 @@ def getLayerGeometryPathLength(layerGeom: LayerGeometry) -> float:
totalPathDist = np.sum(lineDist)

if isinstance(layerGeom, PointsGeometry):
raise Exception('Cannot pass a PointsGeometry to calculate the total path length'
)
raise Exception('Cannot pass a PointsGeometry to calculate the total path length')

return float(totalPathDist)


def getLayerGeomTotalJumps(layerGeom: LayerGeometry) -> int:
"""
Returns the number of jumps across a :class:`LayerGeometry`.
.. note::
It is assumed that there is a single jump for each ContourGeometry and PointsGeometry
:param layerGeom: The :class:`LayerGeometry` to measure
:return: Returns the total number of jumps
"""
coords = layerGeom.coords

numJumps = 0

if isinstance(layerGeom, ContourGeometry):
numJumps = 1

if isinstance(layerGeom, HatchGeometry):
numJumps = coords.shape[0] / 2

if isinstance(layerGeom, PointsGeometry):
numJumps = 1

return numJumps


def getIntraLayerGeometryJumpLength(layer: Layer) -> float:
"""
Returns the intra-layer geometry jump length across the :class:`Layer`
Expand All @@ -78,6 +105,7 @@ def getIntraLayerGeometryJumpLength(layer: Layer) -> float:

return intraJumpDistance


def getLayerJumpLength(layer: Layer) -> float:
"""
Returns the total jump length across the :class:`Layer`
Expand Down Expand Up @@ -147,21 +175,22 @@ def getEffectiveLaserSpeed(bstyle: BuildStyle) -> float:
pointJumpTime = float(bstyle.pointDistance) * 1e-3 / bstyle.jumpSpeed

# Point distance [microns), point exposure time (mu s)
return float(bstyle.pointDistance) * 1e-3 / (float(bstyle.pointExposureTime)*1e-6 + pointJumpTime + bstyle.jumpDelay * 1e-6)
return float(bstyle.pointDistance) * 1e-3 / (float(bstyle.pointExposureTime)*1e-6 + pointJumpTime + float(bstyle.pointDelay) * 1e-6)

else:
# Return the laser speed
return bstyle.laserSpeed


def getLayerGeometryTime(layerGeom: LayerGeometry, models: List[Model],
includeJumpTime: Optional[bool] = False) -> float:
includeJumpTime: Optional[bool] = False,
jumpDelay: Optional[float] = 0.0) -> float:
"""
Returns the total time taken to scan across a :class:`~pyslm.geometry.LayerGeometry`.
:param layerGeom: The :class:`~pyslm.geometry.LayerGeometry` to process
:param models: A list of :class:`~pyslm.geometry.Model` which is used by the :class:`geometry.LayerGeometry`
:param includeJumpTime: Include the jump time between scan vectors in the calculation (default = False)
:param includeJumpTime: Include the jump time between scan vectors in the calculation (default = `False`)
:return: The time taken to scan across the :class:`~pyslm.geometry.LayerGeometry`
"""

Expand All @@ -174,13 +203,18 @@ def getLayerGeometryTime(layerGeom: LayerGeometry, models: List[Model],
if isinstance(layerGeom, HatchGeometry) or isinstance(layerGeom, ContourGeometry):
scanTime = getLayerGeometryPathLength(layerGeom) / getEffectiveLaserSpeed(bstyle)
elif isinstance(layerGeom, PointsGeometry):
scanTime = layerGeom.coords * bstyle.pointExposureTime * 1e-6
scanTime = layerGeom.coords * float(bstyle.pointExposureTime) * 1e-6
else:
raise Exception('Invalid LayerGeometry object passed as an argument')

if includeJumpTime:

# Add distance to transverse across each scan vector (if applicable)
totalJumpTime = getLayerGeometryJumpDistance(layerGeom) / bstyle.jumpSpeed

# Add a jump delay (optional) between scan vectors (if applicable)
totalJumpTime += getLayerGeomTotalJumps(layerGeom) * float(bstyle.jumpDelay) * 1e-6

return scanTime + totalJumpTime

def getLayerTime(layer: Layer, models: List[Model],
Expand All @@ -207,4 +241,14 @@ def getLayerTime(layer: Layer, models: List[Model],
if includeJumpTime:
layerTime += getIntraLayerGeometryJumpLength(layer) / laserJumpSpeed

# Include jump times between layer geometry groups
intraGeomJumpDelayTime = 0.0

# Include the jump time between layer geometry groups
for layerGeom in layer.geometry:
bstyle = utils.getBuildStyleById(models, layerGeom.mid, layerGeom.bid)
intraGeomJumpDelayTime += bstyle.jumpDelay

layerTime += intraGeomJumpDelayTime

return layerTime

0 comments on commit 3bce788

Please sign in to comment.