amaazetools 0.1.4__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {amaazetools-0.1.4/amaazetools.egg-info → amaazetools-0.1.6}/PKG-INFO +1 -1
  2. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/trimesh.py +117 -0
  3. {amaazetools-0.1.4 → amaazetools-0.1.6/amaazetools.egg-info}/PKG-INFO +1 -1
  4. {amaazetools-0.1.4 → amaazetools-0.1.6}/pyproject.toml +1 -1
  5. {amaazetools-0.1.4 → amaazetools-0.1.6}/LICENSE +0 -0
  6. {amaazetools-0.1.4 → amaazetools-0.1.6}/MANIFEST.in +0 -0
  7. {amaazetools-0.1.4 → amaazetools-0.1.6}/README.md +0 -0
  8. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/__init__.py +0 -0
  9. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/dicom.py +0 -0
  10. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/edge_detection.py +0 -0
  11. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/mesh_segmentation.py +0 -0
  12. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools/svi.py +0 -0
  13. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools.egg-info/SOURCES.txt +0 -0
  14. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools.egg-info/dependency_links.txt +0 -0
  15. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools.egg-info/requires.txt +0 -0
  16. {amaazetools-0.1.4 → amaazetools-0.1.6}/amaazetools.egg-info/top_level.txt +0 -0
  17. {amaazetools-0.1.4 → amaazetools-0.1.6}/setup.cfg +0 -0
  18. {amaazetools-0.1.4 → amaazetools-0.1.6}/setup.py +0 -0
  19. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/cextensions.c +0 -0
  20. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/memory_allocation.c +0 -0
  21. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/memory_allocation.h +0 -0
  22. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/mesh_operations.c +0 -0
  23. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/mesh_operations.h +0 -0
  24. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/svi_computations.c +0 -0
  25. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/svi_computations.h +0 -0
  26. {amaazetools-0.1.4 → amaazetools-0.1.6}/src/vector_operations.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: amaazetools
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Python package for mesh processing tools developed by AMAAZE
5
5
  Author-email: Jeff Calder <jwcalder@umn.edu>
6
6
  License: MIT
@@ -9,6 +9,8 @@ from numpy import matlib
9
9
  from plyfile import PlyData, PlyElement
10
10
  import scipy.sparse as sparse
11
11
  import scipy.spatial as spatial
12
+ import scipy.sparse.csgraph as csgraph
13
+ from collections import Counter
12
14
  from skimage import measure
13
15
  from skimage.color import convert_colorspace
14
16
  from sklearn.neighbors import NearestNeighbors
@@ -17,6 +19,7 @@ from . import edge_detection
17
19
  import sys
18
20
  import urllib.request as url
19
21
 
22
+
20
23
  #Non-Class Specific Functions
21
24
 
22
25
 
@@ -466,6 +469,120 @@ class mesh:
466
469
  F = sparse.spdiags(1/num_adj_tri,0,self.num_verts(),self.num_verts())@F
467
470
 
468
471
  return F
472
+
473
+ def detect_holes(self):
474
+ """ finds vertices bordering on holes.
475
+
476
+ Returns
477
+ -------
478
+ holes : (num_verts) boolean array
479
+ holes[i] = 1 if vertex i borders on a hole, else 0
480
+ """
481
+ npts = self.num_verts()
482
+ ntri = self.num_tri()
483
+
484
+ T = self.triangles
485
+ #sparse matrices don't seem to be smart enough to remove 0's here in construction. I was going to add 1 and then remove it - no need
486
+
487
+ VT = self.tri_vert_adj()
488
+
489
+ ntri_per_vert = VT@np.ones(ntri) #need this later
490
+ max_tri = int(ntri_per_vert.max())
491
+
492
+ T1 = VT.multiply(T[:,0])
493
+ T2 = VT.multiply(T[:,1])
494
+ T3 = VT.multiply(T[:,2])
495
+
496
+ I = np.hstack((T1.row,T2.row,T3.row))
497
+ J = np.hstack((T1.data.astype(int), T2.data.astype(int),T3.data.astype(int)))
498
+
499
+ K = sparse.coo_matrix((np.ones(len(I)), (I,J)),shape=(npts,npts)).tocsr()
500
+ K.data = (K.data>0).astype(int) #the construction is additive - repeated index ~> counter
501
+
502
+ ntri_per_vert2 = (K@np.ones(npts)) -1
503
+ holes = ntri_per_vert2!=ntri_per_vert
504
+
505
+ return holes
506
+
507
+
508
+ def con_comp(self,Q=None,returncounts=False):
509
+ """ extracts connected components of mesh.
510
+
511
+ Parameters
512
+ ----------
513
+ Q : (num_verts) boolean array , default is None
514
+ optional array to prune edges with. If input, only edges from True to True will be considered for connectivity.
515
+ If not input (or None), all edges will be used for connectivity.
516
+ returncounts: boolean, default is False
517
+ if true, will return counts for labels.
518
+
519
+ Returns
520
+ -------
521
+ ncomp : number of connected components.
522
+ labels : (num_verts) integer array
523
+ labels of connected components for each point. values range from 0 to ncomp-1.
524
+ counts : (ncomp) integer array
525
+ (optional) returns number of points under each label. array sorted from 0 to ncomp-1.
526
+
527
+
528
+ """
529
+ T = self.triangles
530
+ npts = self.num_verts()
531
+ E = np.vstack( (T[:,[0,1]], T[:,[1,2]], T[:,[2,0]])) #edges of T
532
+
533
+ if Q is not None:
534
+ ll = Q[E]
535
+ E = E[ll[:,0]&ll[:,1],:]
536
+
537
+ E = np.vstack( (E,E[:,[1,0]]) )
538
+
539
+ W = sparse.coo_matrix((np.ones((np.shape(E)[0])), (E[:,0],E[:,1])),shape=(npts,npts))
540
+
541
+ ncomp,labels = csgraph.connected_components(W,directed=False)
542
+
543
+ if returncounts:
544
+ co = Counter(labels)
545
+ co = np.array(list(co.items()))
546
+ counts = co[np.argsort(co[:,0]),1]
547
+ return ncomp,labels,counts
548
+ else:
549
+ return ncomp,labels
550
+
551
+ def extract_subtri(self,L):
552
+ """ extracts sub-triangulation from specified vertices
553
+
554
+ Parameters
555
+ ----------
556
+ L : (num_verts) boolean or (n) integer array
557
+ boolean identifier or integer indices of vertices to extract.
558
+ Returns
559
+ -------
560
+ newpts : (n,3) float array
561
+ extracted points (i.e. pts[L,:])
562
+ newtri : (new_num_tri,3) integer array
563
+ triangles where only all 3 vertices are in the extract
564
+
565
+ """
566
+
567
+ n_pts = self.num_verts()
568
+ tri = self.triangles
569
+ pts = self.points
570
+
571
+ if L.dtype == np.dtype(bool):
572
+ pt_ind2keep = np.where(L)[0]
573
+ else:
574
+ pt_ind2keep = L
575
+
576
+ newind = np.arange(pt_ind2keep.shape[0])
577
+
578
+ old2new = -1*np.ones(n_pts)
579
+ old2new[pt_ind2keep] = newind
580
+
581
+ newtri = old2new[tri]
582
+ newtri = newtri[ np.sum(newtri<0,1) ==0, :]
583
+
584
+ newpts = pts[pt_ind2keep,:]
585
+ return newpts, newtri
469
586
 
470
587
  #Returns unit normal vectors to vertices (averaging adjacent faces and normalizing)
471
588
  def vertex_normals(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: amaazetools
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Python package for mesh processing tools developed by AMAAZE
5
5
  Author-email: Jeff Calder <jwcalder@umn.edu>
6
6
  License: MIT
@@ -9,7 +9,7 @@ packages = ['amaazetools']
9
9
 
10
10
  [project]
11
11
  name = "amaazetools"
12
- version = "0.1.4"
12
+ version = "0.1.6"
13
13
  authors = [
14
14
  { name="Jeff Calder", email="jwcalder@umn.edu" },
15
15
  ]
File without changes
File without changes
File without changes
File without changes
File without changes