コード例 #1
0
ファイル: bitmapdisplay.py プロジェクト: song2001/OOF2
 def draw(self, gfxwindow, device):
     bitmapobj = self.who().getObject(gfxwindow)
     if config.dimension() == 2:
         device.draw_image(bitmapobj, coord.Coord(0, 0), bitmapobj.size())
     if config.dimension() == 3:
         device.draw_image(bitmapobj, coord.Coord(0, 0, 0),
                           bitmapobj.size())
コード例 #2
0
ファイル: orientmapdisplay.py プロジェクト: pk-organics/OOF3D
 def draw(self, gfxwindow, device):
     msobj = self.who().getObject(gfxwindow)
     data = orientmapdata.getOrientationMap(msobj)
     if data is not None:
         orientimage = orientmapdata.OrientMapImage(data, self.colorscheme)
         if config.dimension() == 2:
             device.draw_image(orientimage, coord.Coord(0, 0), msobj.size())
         elif config.dimension() == 3:
             device.draw_image(orientimage, coord.Coord(0, 0, 0),
                               msobj.size())
コード例 #3
0
 def draw(self, gfxwindow, device):
     bitmap = self.who().resolve(gfxwindow).getBitmap()
     if bitmap is None or bitmap.empty():
         return
     bitmap.setColor(self.color)
     bitmap.setTintAlpha(self.tintOpacity)
     if device.has_alpha():
         if config.dimension() == 2:
             device.draw_alpha_image(bitmap, coord.Coord(0, 0),
                                     bitmap.size())
         elif config.dimension() == 3:
             bitmap.setVoxelAlpha(self.voxelOpacity)
             device.draw_alpha_image(bitmap, coord.Coord(0, 0, 0),
                                     bitmap.size())
コード例 #4
0
 def draw(self, gfxwindow, device):
     microstructure = self.who().getObject(gfxwindow)
     # The draw_image() routine requires an object with a
     # .fillstringimage() function.  We can't simply give
     # Microstructure such a function, since it can be displayed in
     # many ways, so we construct a temporary object,
     # MaterialImage, just to pass to draw_image().
     matlimage = material.MaterialImage(microstructure, self.no_material,
                                        self.no_color)
     if config.dimension() == 2:
         device.draw_image(matlimage, coord.Coord(0, 0),
                           microstructure.size())
     if config.dimension() == 3:
         device.draw_image(matlimage, coord.Coord(0, 0, 0),
                           microstructure.size())
コード例 #5
0
ファイル: displaymethods.py プロジェクト: santiama/OOF3D
 def _displaced(self, mesh, elem, realpos=None, masterpos=None):  # 2D only
     masterpos = masterpos or elem.to_master(realpos)
     realpos = realpos or elem.from_master(masterpos)
     disp = elem.outputField(mesh, field.getField("Displacement"),
                             masterpos)
     # 'disp' is an OutputValue wrapping a VectorOutputVal
     vdisp = disp.valuePtr()  # the underlying VectorOutputVal
     return realpos + self.where.factor() * coord.Coord(*vdisp)
コード例 #6
0
 def draw(self, gfxwindow, canvas):
     msobj = self.who().getObject(gfxwindow)
     img = orientationimage.OrientationImage(msobj, self.colorscheme,
                                             self.no_material,
                                             self.no_orientation)
     # Don't use OrientationImage.size() here, because
     # orientmapimage may be destroyed before drawing is
     # complete.  msobj.size() refers to an object that will be
     # persistent.
     canvas.draw_image(img, coord.Coord(0, 0), msobj.size())
コード例 #7
0
ファイル: skeletonelement.py プロジェクト: song2001/OOF2
    def realelement_shares(self, skeleton, mesh, index, fe_node,
                    curnodeindex, elemdict, materialfunc):        
        # Be safe with indices.
        if self.meshindex is None: # Zero is nontrivial index.
            self.meshindex = index
        else:
            if index != self.meshindex:
                raise ooferror2.ErrPyProgrammingError(
                    "Index mismatch in element construction.")
                
        nnewnodes = 0
        ncn = len(self.nodes) # Corner nodes.

        # elemdict is a dictionary of MasterElements, keyed by number
        # of sides.
        elementtype = elemdict[self.nnodes()]
        nodes = []                      # real nodes for this element

        for i in range(len(self.nodes)):  # i.e. for each edge...
            c0 = self.nodes[i]
            nodes.append(fe_node[c0])     # Corner nodes already exist.
            c1 = self.nodes[(i+1)%ncn]
            cset = skeletonnode.canonical_order(c0, c1)

            # Look up this edge in the dictionary.  If it's there,
            # then nodes have been created on the edge already, and we
            # should reuse them.

            try:
                xtranodes = mesh.getEdgeNodes(cset)
                # The nodes were created by the neighboring element.
                # Since elements traverse their edges counterclockwise
                # when creating nodes, the preexisting nodes are in
                # the wrong order for the current element.
                xtranodes.reverse()
            except KeyError:
                newindexinc=0
                newindex=0
                protocount=0
                protodiclength=len(elementtype.protodic[i])
                if c0.index<c1.index:
                    newindexinc=1
                    newindex=skeleton.maxnnodes+100*c0.index
                else:
                    # Do this to distinguish the protonode on either
                    # side of a corner node that has a smaller index
                    # than either corner nodes of the collinear
                    # segments extending from that corner node.
                    newindexinc=-1
                    newindex=skeleton.maxnnodes+100*c1.index+50+protodiclength-1

                # The edge wasn't in the dictionary.  It's a new edge.
                xtranodes  = []
                # Loop over all protonodes on the current
                # edge of the new element
                for newproto in elementtype.protodic[i]:
                    masterxy = primitives.Point(newproto.mastercoord()[0],
                                           newproto.mastercoord()[1])
                    realxy = self.frommaster(masterxy, 0)
                    newnode = _makenewnode_shares(
                        mesh, newproto,
                        coord.Coord(realxy.x, realxy.y),
                        c0,c1,newindex,protocount,
                        protodiclength,skeleton.maxnnodes)
                    newindex+=newindexinc
                    protocount+=1
                    nnewnodes = nnewnodes + 1
                    xtranodes.append(newnode)
                mesh.addEdgeNodes(cset, xtranodes)
            #Should this be 'join'ed instead, for speed?
            nodes = nodes + xtranodes

        # Interior nodes at the end.
        for newproto in elementtype.protodic['interior']:
            masterxy = primitives.Point(newproto.mastercoord()[0],
                                        newproto.mastercoord()[1])
            realxy = self.frommaster(masterxy, 0)
            newnode = _makenewnode(mesh, newproto,
                                   coord.Coord(realxy.x, realxy.y))
            nnewnodes = nnewnodes + 1
            nodes.append(newnode)
            mesh.addInternalNodes(self, newnode)

        # Having constructed the list of nodes, call the real
        # element's constructor.
        realel = elementtype.build(self, materialfunc(self, skeleton), nodes)
        # Long-lost cousin of Kal-El and Jor-El.
        
        mesh.addElement(realel)               # Add to mesh.
        # Tell the element about its exterior edges.
        for edge in self.exterior_edges:
            realel.set_exterior(fe_node[edge[0]], fe_node[edge[1]])

        return nnewnodes
コード例 #8
0
ファイル: skeletonelement.py プロジェクト: song2001/OOF2
    def realelement(self, skeletoncontext, mesh, index,
                    fe_node, seg_dict,
                    elemdict, materialfunc):
        # Create a real element corresponding to this skeleton
        # element. The elemdict argument is a dictionary (keyed by the
        # number of sides of the element) of MasterElement objects,
        # which contain the information needed to construct the real
        # elements.  "index" is the SkeletonElement's position in the
        # Skeleton's list, and "fe_node" is a dictionary of real nodes
        # in the FEMesh, indexed by their corresponding SkeletonNode
        # objects.  The lists give the nodes in the order in which
        # they were added to the element.
        
        # Be safe with indices.
        if self.meshindex is None: # Zero is nontrivial index.
            self.meshindex = index
        else:
            if index != self.meshindex:
                raise ooferror2.ErrPyProgrammingError(
                    "Index mismatch in element construction.")
                
        nnewnodes = 0
        ncn = len(self.nodes) # Corner nodes.

        # elemdict is a dictionary of MasterElements, keyed by number
        # of sides.
        elementtype = elemdict[self.nnodes()]
        nodes = []                      # real nodes for this element

        for i in range(len(self.nodes)):  # i.e. for each edge...
            c0 = self.nodes[i]
            nodes.append(fe_node[c0])     # Corner nodes already exist.
            c1 = self.nodes[(i+1)%ncn]
            cset = skeletonnode.canonical_order(c0, c1)


            # Look up this edge in the dictionary.  If it's there,
            # then nodes have been created on the edge already, and we
            # should reuse them.

            try:
                xtranodes = mesh.getEdgeNodes(cset)
                # The nodes were created by the neighboring element.
                # Since elements traverse their edges counterclockwise
                # when creating nodes, the preexisting nodes are in
                # the wrong order for the current element.
                xtranodes.reverse()
            except KeyError:
                # The edge wasn't in the dictionary.  It's a new edge.
                xtranodes  = []
                # Loop over all protonodes on the current
                # edge of the new element
                for newproto in elementtype.protodic[i]:
                    masterxy = primitives.Point(newproto.mastercoord()[0],
                                           newproto.mastercoord()[1])
                    realxy = self.frommaster(masterxy, 0)
                    newnode = _makenewnode(mesh, newproto,
                                           coord.Coord(realxy.x, realxy.y))
                    nnewnodes = nnewnodes + 1
                    xtranodes.append(newnode)
                #Interface branch
                try:
                    #If the segment represented by cset is a member of an
                    #interface, then new edge nodes (xtranodes) will
                    #not be shared by another element.
                    test=seg_dict[cset]
                except KeyError:
                    mesh.addEdgeNodes(cset, xtranodes)
            nodes = nodes + xtranodes

        # Interior nodes at the end.
        for newproto in elementtype.protodic['interior']:
            masterxy = primitives.Point(newproto.mastercoord()[0],
                                        newproto.mastercoord()[1])
            realxy = self.frommaster(masterxy, 0)
            newnode = _makenewnode(mesh, newproto,
                                   coord.Coord(realxy.x, realxy.y))
            nnewnodes = nnewnodes + 1
            nodes.append(newnode)
            mesh.addInternalNodes(self, newnode)

        # Having constructed the list of nodes, call the real
        # element's constructor.  materialfunc returns the element's
        # material.  In normal operation, materialfunc is
        # SkeletonElement.realmaterial.
        realel = elementtype.build(self, materialfunc(self, skeletoncontext),
                                   nodes)
        
        mesh.addElement(realel)               # Add to mesh.
        # Tell the element about its exterior edges.
        for edge in self.exterior_edges:
            realel.set_exterior(fe_node[edge[0]], fe_node[edge[1]])

        return nnewnodes
コード例 #9
0
ファイル: fakecanvas.py プロジェクト: song2001/OOF2
 def window_coord(self, *args):
     return coord.Coord(1, 1)
コード例 #10
0
ファイル: fakecanvas.py プロジェクト: song2001/OOF2
 def world_coord(self, *args):
     return coord.Coord(1, 1)
コード例 #11
0
ファイル: fakecanvas.py プロジェクト: song2001/OOF2
 def get_bounds(self):
     return geometry.CRectangle(coord.Coord(0, 0), coord.Coord(1, 1))
コード例 #12
0
ファイル: fakecanvas.py プロジェクト: song2001/OOF2
 def get_scrollregion(self):
     return geometry.CRectangle(coord.Coord(0, 0), coord.Coord(1, 1))
コード例 #13
0
ファイル: canvasoutput.py プロジェクト: creuzige/OOF2
def point2Coord(point):
    "Convert a Point (pure Python) to Coord (swigged C++)"
    return coord.Coord(point[0], point[1])