示例#1
0
    def __init__(self, id, display, steps_mesh, patch_id, color=None):
        """
        Constructor
        """
        self.id = id
        self.display = display
        self.steps_mesh = steps_mesh

        if not color:
            color = [random.random(), random.random(), random.random(), 0.3]

        tmpatch = sgeom.castToTmPatch(steps_mesh.getPatch(patch_id))
        self.bound_max = [v * display.scale for v in tmpatch.getBoundMax()]
        self.bound_min = [v * display.scale for v in tmpatch.getBoundMin()]

        patch_surface = tmpatch.getAllTriIndices()
        patch_surface = np.array(patch_surface, dtype=INDEX_DTYPE)
        v_set_size = steps_mesh.getTriVerticesSetSizeNP(patch_surface)
        tris_data = np.zeros(patch_surface.size * 3, dtype=INDEX_DTYPE)
        v_set = np.zeros(v_set_size, dtype=INDEX_DTYPE)
        verts_data = np.zeros(v_set_size * 3)
        steps_mesh.getTriVerticesMappingSetNP(patch_surface, tris_data, v_set)
        steps_mesh.getBatchVerticesNP(v_set, verts_data)
        verts_data *= display.scale
        tris_data.shape = -1, 3
        verts_data.shape = -1, 3
        mesh_data = gl.MeshData(vertexes=verts_data, faces=tris_data)
        gl.GLMeshItem.__init__(self,
                               meshdata=mesh_data,
                               smooth=False,
                               computeNormals=True,
                               shader='balloon',
                               glOptions='additive')
        self.setColor(color)
        display.addItem(self)
示例#2
0
def highlightPatch(mesh, patch_id, tri_proxy):
    """
    Highlight the STEPS compartment.
        
    Parameters:
        * mesh        Associated Tetmesh object created in STEPS
        * patch_id    Name of the patch
        * tri_proxy   Triangle element proxy generated by STEPS mesh importing function
        
    Return:
        None
    """
    patch = sgeom.castToTmPatch(mesh.getPatch(patch_id))
    data = patch.getAllTriIndices()
    highlightSTEPSTris(data, tri_proxy)
示例#3
0
 def __init__(self,
              plot,
              mesh,
              sim,
              patch_id,
              spec_id,
              axis="x",
              nbins=20,
              y_range=None,
              **kwargs):
     self.plot = plot
     self.mesh = mesh
     self.sim = sim
     self.patch_id = patch_id
     self.spec_id = spec_id
     self.nbins = nbins
     if y_range != None:
         self.plot.setYRange(y_range[0], y_range[1])
     tmpatch = sgeom.castToTmPatch(mesh.getPatch(patch_id))
     self.tris = tmpatch.getAllTriIndices()
     self.axis = 0
     if axis == "x":
         self.axis = 0
         plot.setLabel('bottom', 'X Coordinate', units='m')
     elif axis == "y":
         self.axis = 1
         plot.setLabel('bottom', 'Y Coordinate', units='m')
     elif axis == "z":
         self.axis = 2
         plot.setLabel('bottom', 'Z Coordinate', units='m')
     self.bound_max = tmpatch.getBoundMax()[self.axis]
     self.bound_min = tmpatch.getBoundMin()[self.axis]
     bins = np.linspace(self.bound_min, self.bound_max, nbins + 1)
     centers = [mesh.getTriBarycenter(t)[self.axis] for t in self.tris]
     self.belongs = np.digitize(centers, bins)
     self.bin_data = []
     for b in range(nbins):
         self.bin_data.append(bins[b])
         self.bin_data.append(bins[b + 1])
     data = np.zeros(nbins + 1)
     for t in range(len(self.tris)):
         data[self.belongs[t] - 1] += sim.getTriCount(
             self.tris[t], self.spec_id)
     y_data = []
     for b in range(nbins):
         y_data.append(data[b])
         y_data.append(data[b])
     self.curve = plot.plot(self.bin_data, y_data, fillLevel=-0.3, **kwargs)
示例#4
0
    def __init__(self,
                 id,
                 display,
                 mesh,
                 sim,
                 patch_id,
                 specs_colors,
                 spec_size=0.1):
        """
        Constructor.

        """
        self.patch_id = patch_id
        tris = sgeom.castToTmPatch(mesh.getPatch(patch_id)).getAllTriIndices()

        VisualTrisChannel.__init__(self, id, display, mesh, sim, tris,
                                   specs_colors, spec_size)
示例#5
0
    def __init__(self, id, display, steps_mesh, comp_id, color=None):
        """
        Constructor
        """
        self.id = id
        self.display = display
        self.steps_mesh = steps_mesh

        if not color:
            color = [random.random(), random.random(), random.random(), 0.3]
        tmcomp = sgeom.castToTmComp(steps_mesh.getComp(comp_id))
        self.bound_max = [v * display.scale for v in tmcomp.getBoundMax()]
        self.bound_min = [v * display.scale for v in tmcomp.getBoundMin()]

        ipatches = set(tmcomp.getIPatches())
        opatches = set(tmcomp.getOPatches())
        patches = ipatches.union(opatches)

        surface_tris = smeshctrl.findSurfTrisInComp(steps_mesh, tmcomp)
        for p in patches:
            surface_tris.extend(sgeom.castToTmPatch(p).getAllTriIndices())

        surface_tris = np.array(surface_tris, dtype=INDEX_DTYPE)

        v_set_size = steps_mesh.getTriVerticesSetSizeNP(surface_tris)
        tris_data = np.zeros(surface_tris.size * 3, dtype=INDEX_DTYPE)
        v_set = np.zeros(v_set_size, dtype=INDEX_DTYPE)
        verts_data = np.zeros(v_set_size * 3)
        steps_mesh.getTriVerticesMappingSetNP(surface_tris, tris_data, v_set)
        steps_mesh.getBatchVerticesNP(v_set, verts_data)
        verts_data *= display.scale
        tris_data.shape = -1, 3
        verts_data.shape = -1, 3
        mesh_data = gl.MeshData(vertexes=verts_data, faces=tris_data)
        gl.GLMeshItem.__init__(self,
                               meshdata=mesh_data,
                               smooth=False,
                               computeNormals=True,
                               shader='balloon',
                               glOptions='additive')
        self.setColor(color)
        display.addItem(self)
示例#6
0
    def __init__(self,
                 id,
                 display,
                 mesh,
                 sim,
                 patch_id,
                 spec_id,
                 spec_color=None,
                 spec_size=0.2,
                 max_nspec=100000,
                 max_density=1000e12,
                 auto_adjust=True):
        """
        Constructor.

        """
        self.patch_id = patch_id
        tris = sgeom.castToTmPatch(mesh.getPatch(patch_id)).getAllTriIndices()

        VisualTrisSpec.__init__(self, id, display, mesh, sim, tris, spec_id,
                                spec_color, spec_size, max_nspec, max_density,
                                auto_adjust)