Merge pull request #140 from joemarshall/fix_ocl_resample

fixes to opencamlib resampling for numpy
pull/258/head
Alain Pelletier 2024-02-22 10:34:52 -04:00 zatwierdzone przez GitHub
commit a8d87938d2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 13 dodań i 6 usunięć

Wyświetl plik

@ -90,7 +90,11 @@ class camPathChunk:
# progressIndex=-1# for e.g. parallel strategy, when trying to save time..
def __init__(self, inpoints, startpoints=None, endpoints=None, rotations=None):
# name this as _points so nothing external accesses it directly
self._points = np.array(inpoints) # for 3 axes, this is only storage of points. For N axes, here go the sampled points
# for 3 axes, this is only storage of points. For N axes, here go the sampled points
if len(inpoints)==0:
self._points = np.empty(shape=(0,3))
else:
self._points = np.array(inpoints)
self.poly = None # get polygon just in time
self.simppoly = None
if startpoints:

Wyświetl plik

@ -109,16 +109,19 @@ async def oclResampleChunks(operation, chunks_to_resample,use_cached_mesh):
tmp_chunks = list()
tmp_chunks.append(camPathChunk(inpoints=[]))
for chunk, i_start, i_length in chunks_to_resample:
for p_index in range(i_start, i_start + i_length):
tmp_chunks[0].append(chunk.points[p_index])
tmp_chunks[0].extend(chunk.get_points_np()[i_start:i_start+i_length])
print(i_start,i_length,len(tmp_chunks[0]._points))
samples = await ocl_sample(operation, tmp_chunks,use_cached_mesh=use_cached_mesh)
sample_index = 0
for chunk, i_start, i_length in chunks_to_resample:
z = np.array(p.z for p in samples[sample_index:sample_index+i_length]) / OCL_SCALE
chunk.setZ(z,if_bigger=True)
# sample_index += i_length
z = np.array([p.z for p in samples[sample_index:sample_index+i_length]]) / OCL_SCALE
pts = chunk.get_points_np()
pt_z = pts[i_start:i_start+i_length,2]
pt_z = np.where(z>pt_z,z,pt_z)
sample_index += i_length
# for p_index in range(i_start, i_start + i_length):
# z = samples[sample_index].z / OCL_SCALE
# sample_index += 1