Skip to content

Commit

Permalink
Merge pull request #72 from abel-research/aopReadWrite
Browse files Browse the repository at this point in the history
Aop read write
  • Loading branch information
JoshuaSteer committed Feb 21, 2022
2 parents 31026c5 + 870121e commit 8bc62e6
Show file tree
Hide file tree
Showing 12 changed files with 15,275 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9"]

steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ tests/obj.obj
tests/stl_file_2_hc.stl
tests/stl_file_2_lp.stl
tests/stl_file_trim.stl
tests/reg_test*
tests/Example_write.aop
tests/aop_test.stl
tests/aop_write.aop
tests/aop_write_2.aop

tests/reg_test*

dev.py
2 changes: 1 addition & 1 deletion ampscan/analyse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .analyse import (calc_volume_closed, create_slices, calc_perimeter, calc_widths, calc_csa, est_volume,
visualise_slices, plot_slices, MeasurementsOut, CMapOut)
visualise_slices, plot_slices, MeasurementsOut, CMapOut, logEuPath)
from .output import getPDF, generateRegBinsCsv, generateRegCsv, generate_spec

del analyse, output
29 changes: 3 additions & 26 deletions ampscan/analyse/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import numpy as np
from ampscan.core import AmpObject
import matplotlib.pyplot as plt
import matplotlib.colors as clr
import matplotlib.colorbar as clb
Expand Down Expand Up @@ -40,29 +39,7 @@ def calc_volume_closed(amp_in, return_closed=False):
amp: AmpObject
If return_closed is True, then the closed shape is returned
"""
amp = AmpObject({
'vert': amp_in.vert.copy(),
'faces': amp_in.faces.copy(),
'values': amp_in.values.copy(),
})
amp.calcStruct()
# Fill in the holes
while (amp.faceEdges == -99999).sum() != 0:
# Find the edges which are only conected to one face
edges = (amp.faceEdges == -99999).sum(axis=1).astype(bool)
edges = amp.edges[edges, :]
# Return the vert indicies for the loop
vInd = logEuPath(edges)
# Calculate the mmidpoint
midpoint = amp.vert[vInd, :].mean(axis=0)
# Add in the new vertex
amp.vert = np.r_[amp.vert, midpoint[None, :]]
f0 = amp.vert.shape[0] - 1
# Add in each face using adjacent vertices in loop
for f1, f2 in zip(vInd, np.roll(vInd, 1)):
amp.faces = np.r_[amp.faces, [[f1, f0, f2]]]
# Update structure and check if any more holes (algorithm keeps going until all holes filled)
amp.calcStruct()
amp = amp_in.close()
# Calculate the area of each face in the array using vector cross product
v01 = amp.vert[amp.faces[:, 1], :] - amp.vert[amp.faces[:, 0], :]
v02 = amp.vert[amp.faces[:, 2], :] - amp.vert[amp.faces[:, 0], :]
Expand All @@ -77,7 +54,7 @@ def calc_volume_closed(amp_in, return_closed=False):



def create_slices(amp, *args, typ='slices', axis = 2):
def create_slices(amp, *args, typ='slices', axis = 2, order=True):
r"""
Generate polygons from planar slices through the AmpObject. The slices are either defined as a
list of positions in some axis
Expand Down Expand Up @@ -142,7 +119,7 @@ def create_slices(amp, *args, typ='slices', axis = 2):
polys = []
for plane in slices:
try:
ind = vE < plane
ind = vE <= plane
# Select edges with one vertex above and one below the slice plane
validEdgeInd = np.where(np.logical_xor(ind[:,0], ind[:,1]))[0]
validfE = amp.faceEdges[validEdgeInd, :].astype(int)
Expand Down

0 comments on commit 8bc62e6

Please sign in to comment.