Exemplo n.º 1
0
 def get_bounds(self):
     first = 1
     for e in self._elements_from_aggregate():
         for n in e.cornernode_iterator():
             pos = n.position()
             if first:
                 xmin = pos[0]
                 xmax = pos[0]
                 ymin = pos[1]
                 ymax = pos[1]
                 first = None
             else:
                 xmin = min(pos[0], xmin)
                 xmax = max(pos[0], xmax)
                 ymin = min(pos[1], ymin)
                 ymax = max(pos[1], ymax)
     if not first:
         return primitives.Rectangle(primitives.Point(xmin, ymin),
                                     primitives.Point(xmax, ymax) )
Exemplo n.º 2
0
    def get_bounds(self):
        ms_size = self.ms.size()
        pixels = self._pixels_from_group()
        if pixels:
            maxx=0.0
            maxy=0.0
            minx=ms_size[0]
            miny=ms_size[1]
            pixel_size = self.ms.sizeOfPixels()

            if parallel_enable.enabled():
                boundsxmin=self.skeleton.localbounds.xmin()
                boundsxmax=self.skeleton.localbounds.xmax()
                boundsymin=self.skeleton.localbounds.ymin()
                boundsymax=self.skeleton.localbounds.ymax()
                for p in pixels:
                    low_x = p[0]*pixel_size[0]
                    hi_x = low_x + pixel_size[0]
                    low_y = p[1]*pixel_size[1]
                    hi_y = low_y + pixel_size[1]
                    if low_x >= boundsxmin:
                        minx = min(minx, low_x)
                    if low_y >= boundsymin:
                        miny = min(miny, low_y)
                    if hi_x <= boundsxmax:
                        maxx = max(maxx, hi_x)
                    if hi_y <= boundsymax:
                        maxy = max(maxy, hi_y)
            else:
                for p in pixels:
                    low_x = p[0]*pixel_size[0]
                    hi_x = low_x + pixel_size[0]
                    low_y = p[1]*pixel_size[1]
                    hi_y = low_y + pixel_size[1]
                    minx = min(minx, low_x)
                    miny = min(miny, low_y)
                    maxx = max(maxx, hi_x)
                    maxy = max(maxy, hi_y)

            return primitives.Rectangle(primitives.Point(minx, miny),
                                        primitives.Point(maxx, maxy))
Exemplo n.º 3
0
    def mark_dummy(self):
        global _size
        width  = self.dummy.MS.size()[0]*1.0
        height = self.dummy.MS.size()[1]*1.0

        # Portrait or Landscape?
        landscape = True
        if width < height:
            landscape = False

        # The easiest one 1xN or Nx1
        if landscape:
            if math.ceil(width/height) >= _size:
                ix = _size
                iy = 1
            else:
                ix = int(math.ceil(math.sqrt(_size)))
                iy = int(math.floor(math.sqrt(_size)))
                if ix*iy < _size:
                    iy += 1
        else:  # portrait
            if math.ceil(height/width) >= _size:
                ix = 1
                iy = _size
            else:
                ix = int(math.floor(math.sqrt(_size)))
                iy = int(math.ceil(math.sqrt(_size)))
                if ix*iy < _size:
                    ix += 1 
            
        hx = width/ix
        hy = height/iy

        # Bounding box
        class BBox:
            def __init__(self, ll, ur):  # ll = (x0, y0), ur = (x1, y1)
                self.lowerLeft = ll
                self.upperRight = ur
                self.index = None
            def set_index(self, id):
                self.index = id

        bboxes = []
        for j in range(iy):
            for i in range(ix):
                bboxes.append( BBox((i*hx,j*hy), ((i+1)*hx,(j+1)*hy)) )
        count = 0
        for id in range(_size-1,-1, -1):
            if id==_rank:
                #RCL:Store the bounds of the subdomain of this process
                self.localbounds=primitives.Rectangle(primitives.Point(bboxes[count].lowerLeft[0],bboxes[count].lowerLeft[1]),
                                                      primitives.Point(bboxes[count].upperRight[0],bboxes[count].upperRight[1]))
            bboxes[count].set_index(id)
            count += 1
        bboxes[count-1].upperRight = bboxes[-1].upperRight  # extension
        bboxes = bboxes[:count]  # removal of dummy bboxes

        # Now, iterate over the boxes and mark elements
        # Check to see if the center of an element is in the box or not.
        for e in self.dummy.element_iterator():
            for bbox in bboxes:
                if(e.belongTo(bbox)):
                    e.resetProcID(bbox.index)
Exemplo n.º 4
0
 def get_bounds(self):
     if parallel_enable.enabled():
         return self.skeleton.localbounds
     else:
         return primitives.Rectangle(primitives.Point(0.0,0.0),
                                     self.ms.size())