this function takes mesh_method and kwargs that came from the generic Body.intialize_mesh and returns
        the grid... intialize mesh then takes care of filling columns and rescaling to the correct units, etc
336374
def _build_mesh(self, mesh_method, **kwargs):
        

        # if we don't provide instantaneous masses or smas, then assume they are
        # not time dependent - in which case they were already stored in the init
        sma = kwargs.get('sma', self.sma)  # Rsol (same units as coordinates)

        mesh_args = self.instantaneous_mesh_args

        if mesh_method == 'marching':
            ntriangles = kwargs.get('ntriangles', self.ntriangles)

            av = libphoebe.sphere_area_volume(*mesh_args,
                                              larea=True,
                                              lvolume=True)

            delta = _estimate_delta(ntriangles, av['larea'])

            new_mesh = libphoebe.sphere_marching_mesh(*mesh_args,
                                                      delta=delta,
                                                      full=True,
                                                      max_triangles=ntriangles*2,
                                                      vertices=True,
                                                      triangles=True,
                                                      centers=True,
                                                      vnormals=True,
                                                      tnormals=True,
                                                      cnormals=False,
                                                      vnormgrads=True,
                                                      cnormgrads=False,
                                                      areas=True,
                                                      volume=True,
                                                      init_phi=self.mesh_init_phi)

            # In addition to the values exposed by the mesh itself, let's report
            # the volume and surface area of the lobe.  The lobe area is used
            # if mesh_offseting is required, and the volume is optionally exposed
            # to the user.
            new_mesh['volume'] = av['lvolume']
            new_mesh['area'] = av['larea']

            scale = sma

        else:
            raise NotImplementedError("mesh_method '{}' is not supported".format(mesh_method))

        return new_mesh, scale
404764
def Grid(
    pos=(0, 0, 0),
    normal=(0, 0, 1),
    sx=1,
    sy=1,
    c="g",
    bc="darkgreen",
    lw=1,
    alpha=1,
    resx=10,
    resy=10,
):
    
    ps = vtk.vtkPlaneSource()
    ps.SetResolution(resx, resy)
    ps.Update()
    poly0 = ps.GetOutput()
    t0 = vtk.vtkTransform()
    t0.Scale(sx, sy, 1)
    tf0 = vtk.vtkTransformPolyDataFilter()
    tf0.SetInputData(poly0)
    tf0.SetTransform(t0)
    tf0.Update()
    poly = tf0.GetOutput()
    axis = np.array(normal) / np.linalg.norm(normal)
    theta = np.arccos(axis[2])
    phi = np.arctan2(axis[1], axis[0])
    t = vtk.vtkTransform()
    t.PostMultiply()
    t.RotateY(theta * 57.3)
    t.RotateZ(phi * 57.3)
    tf = vtk.vtkTransformPolyDataFilter()
    tf.SetInputData(poly)
    tf.SetTransform(t)
    tf.Update()
    pd = tf.GetOutput()
    actor = Actor(pd, c=c, bc=bc, alpha=alpha)
    actor.GetProperty().SetRepresentationToWireframe()
    actor.GetProperty().SetLineWidth(lw)
    actor.SetPosition(pos)
    settings.collectable_actors.append(actor)
    return actor
814516
def show_grid(self, **kwargs):
        
        kwargs.setdefault('grid', 'back')
        kwargs.setdefault('location', 'outer')
        kwargs.setdefault('ticks', 'both')
        return self.show_bounds(**kwargs)
915155
def add_column(self, width):
        
        tblGrid = self._tbl.tblGrid
        gridCol = tblGrid.add_gridCol()
        gridCol.w = width
        for tr in self._tbl.tr_lst:
            tc = tr.add_tc()
            tc.width = width
        return _Column(gridCol, self)
538976
def define_simple_grid_template(self, template_id, nrows, ncols):
        """"""
        template = GridTemplate(template_id, nrows, ncols)
        [template.define_frame('%s,%s' % (i, j), template[i, j]) for i in range(nrows) for j in range(ncols)]
        template.register(self)
        return self
989772
def mesh_to_BVH(mesh):
    
    bvh = fcl.BVHModel()
    bvh.beginModel(num_tris_=len(mesh.faces),
                   num_vertices_=len(mesh.vertices))
    bvh.addSubModel(verts=mesh.vertices,
                    triangles=mesh.faces)
    bvh.endModel()
    return bvh
520236
def vectorize(*args, **kwargs):
    
    if args and callable(args[0]):
        # Guessing the argument is the method.
        return _vectorize(args[0])
    else:
        # Wait for the second call.
        return lambda m: _vectorize(m, *args, **kwargs)
25210
def baseOn(self, *args):
        
        if isinstance(args[0], dict):
            self.baseOn(*args[0].items())
        else:
            for (param, value) in args:
                self.addGrid(param, [value])

        return self
858236
def _set_rho_grids(self):
        
        rho_grids = np.arange(self.rho_bins) * 2 / self.rho_bins - 1 \
            + 1 / self.rho_bins
        rho_weights = np.ones(self.rho_bins) / self.rho_bins
        return rho_grids, rho_weights
751962
def write(filename, mesh, file_format=None, **kwargs):
    
    if not file_format:
        # deduce file format from extension
        file_format = _filetype_from_filename(filename)

    # check cells for sanity
    for key, value in mesh.cells.items():
        if key[:7] == "polygon":
            assert value.shape[1] == int(key[7:])
        else:
            assert value.shape[1] == num_nodes_per_cell[key]

    try:
        interface, args, default_kwargs = _writer_map[file_format]
    except KeyError:
        raise KeyError(
            "Unknown format '{}'. Pick one of {}".format(
                file_format, sorted(list(_writer_map.keys()))
            )
        )

    # Build kwargs
    _kwargs = default_kwargs.copy()
    _kwargs.update(kwargs)

    # Write
    return interface.write(filename, mesh, *args, **_kwargs)
1251516
def make_grid(rect, cells={}, num_rows=0, num_cols=0, padding=None,
        inner_padding=None, outer_padding=None, row_heights={}, col_widths={}, 
        default_row_height='expand', default_col_width='expand'):
    
    grid = Grid(
            bounding_rect=rect,
            min_cell_rects=cells,
            num_rows=num_rows,
            num_cols=num_cols,
            padding=padding,
            inner_padding=inner_padding,
            outer_padding=outer_padding,
            row_heights=row_heights,
            col_widths=col_widths,
            default_row_height=default_row_height,
            default_col_width=default_col_width,
    )
    return grid.make_cells()
703126
private void initGrid() {
        // Setting up images grid
        final int cols = getResources().getInteger(R.integer.images_grid_columns);

        views.grid.setLayoutManager(new GridLayoutManager(this, cols));

        gridAdapter = new PhotoListAdapter(this);
        gridAdapter.setLoadingOffset(PAGE_SIZE / 2);
        gridAdapter.setCallbacks(new EndlessRecyclerAdapter.LoaderCallbacks() {
            @Override
            public boolean canLoadNextItems() {
                return gridAdapter.canLoadNext();
            }

            @Override
            public void loadNextItems() {
                // We should either load all items that were loaded before state save / restore,
                // or next page if we already loaded all previously shown items
                int count = Math.max(savedPhotoCount, gridAdapter.getCount() + PAGE_SIZE);
                Events.create(FlickrApi.LOAD_IMAGES_EVENT).param(count).post();
            }
        });
        views.grid.setAdapter(gridAdapter);
    }
1250120
def isSnappedToGrid( self ):
        
        shift = QtCore.QCoreApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier
        return (self._xSnapToGrid and self._ySnapToGrid) or shift
396549
def normalize_mesh(mesh):
  ''''''
  mesh = dict(mesh)
  pos = mesh['position'][:,:3].copy()
  pos -= (pos.max(0)+pos.min(0)) / 2.0
  pos /= np.abs(pos).max()
  mesh['position'] = pos
  return mesh
55277
public static void resize(GVRMesh mesh, float size) {
        float dim[] = getBoundingSize(mesh);
        float maxsize = 0.0f;

        if (dim[0] > maxsize) maxsize = dim[0];
        if (dim[1] > maxsize) maxsize = dim[1];
        if (dim[2] > maxsize) maxsize = dim[2];

        scale(mesh, size / maxsize);
    }
778062
def build(self):
        
        keys = self._param_grid.keys()
        grid_values = self._param_grid.values()

        def to_key_value_pairs(keys, values):
            return [(key, key.typeConverter(value)) for key, value in zip(keys, values)]

        return [dict(to_key_value_pairs(keys, prod)) for prod in itertools.product(*grid_values)]
1180486
def meshgrid(x_min, x_max, x_step, y_min=None, y_max=None, y_step=None):
    """"""
    if y_min is None:
        y_min = x_min
    if y_max is None:
        y_max = x_max
    if y_step is None:
        y_step = x_step
    xx, yy = np.meshgrid(
        np.arange(x_min, x_max, x_step), np.arange(y_min, y_max, y_step)
    )
    return xx, yy