def addPlate2Mod(xc,zc,dx,dz,rotAng,modd,sigPlate):
# use matplotlib paths to find CC inside of polygon
plateCorners = getPlateCorners(xc,zc,dx,dz,rotAng)
mod = copy.copy(modd)
verts = [
(plateCorners[0,:]), # left, top
(plateCorners[1,:]), # right, top
(plateCorners[3,:]), # right, bottom
(plateCorners[2,:]), # left, bottom
(plateCorners[0,:]), # left, top (closes polygon)
]
codes = [Path.MOVETO,
Path.LINETO,
Path.LINETO,
Path.LINETO,
Path.CLOSEPOLY,
]
path = Path(verts, codes)
CCLocs = mesh.gridCC
insideInd = np.where(path.contains_points(CCLocs))
#Check selected cell centers by plotting
# print insideInd
# fig = plt.figure()
# ax = fig.add_subplot(111)
# patch = patches.PathPatch(path, facecolor='none', lw=2)
# ax.add_patch(patch)
# plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
# ax.set_xlim(-10,10)
# ax.set_ylim(-20,0)
# plt.axes().set_aspect('equal')
# plt.show()
mod[insideInd] = sigPlate
return mod
评论列表
文章目录