Пример #1
0
 def voxel_matches_polygon(self, coordinate_list):
     for voxel_coords in coordinate_list:
         voxel_coords = np.asarray(voxel_coords)
         rmax = voxel_coords[:, 0].max()
         rmin = voxel_coords[:, 0].min()
         zmax = voxel_coords[:, 1].max()
         zmin = voxel_coords[:, 1].min()
         router = 1.5 * rmax
         rinner = 0.5 * rmin
         zupper = 1.5 * zmax if zmax > 0 else 0.5 * zmax
         zlower = 0.5 * zmin if zmin > 0 else 1.5 * zmin
         test_rs = np.linspace(rinner, router, int(100 * (router - rinner)))
         test_zs = np.linspace(zlower, zupper, int(100 * (zupper - zlower)))
         voxel = AxisymmetricVoxel(voxel_coords, primitive_type='csg')
         polygon = Polygon(voxel_coords, closed=True)
         test_verts = list(itertools.product(test_rs, test_zs))
         try:
             inside_poly = polygon.contains_points(test_verts)
         except AttributeError:
             # Polygon.contains_points was only introduced in Matplotlib 2.2.
             # Before that we need to convert to Path
             inside_poly = Path(polygon.get_verts()).contains_points(test_verts)
         inside_csg = [any(child.contains(Point3D(r, 0, z)) for child in voxel.children)
                       for (r, z) in test_verts]
         self.assertSequenceEqual(inside_csg, inside_poly.tolist())
Пример #2
0
 def update_plots(self):
     """ Update Plots """
     polymask = Path(self.poly.xy).contains_points(self.pntxy)
     self.polyi_changed.emit(polymask.tolist())
Пример #3
0
 def update_plots(self):
     """ Update Plots """
     polymask = Path(self.poly.xy).contains_points(self.pntxy)
     self.polyi_changed.emit(polymask.tolist())