コード例 #1
0
ファイル: agrid2.c プロジェクト: 1014511134/src
void agrid2_size (agrid2 pnt, float* size)
/*< determine grid size >*/
{
    int i2;

    for (i2 = 0; i2 < pnt->n2; i2++) {
	size[i2] = (float) grid_size (pnt->ent[i2]);
    }
}
コード例 #2
0
ファイル: deep_matching.cpp プロジェクト: BoAdBo/AlphaPose
/* compute the grid of parent cell position, and their connection to children cells
   cells can be half-overlapping if <overlap>=1
   <dense_step> forces the grid spacing if >0
*/
void prepare_big_cells( const int imshape[2], int cell_size, int overlap, int child_overlap, 
                        int_cube* child_grid, float_image* child_norms, int dense_step,
                        int_cube* grid, int_cube* children, float_image* norms )
{
    int offset, step, gtx, gty;
    if( dense_step ) {
      step = dense_step;
      offset = 0;
      // we do not care if the patches are overlapping outside the image
      #define grid_size(imsize) (1+imsize/step)
      gtx = grid_size(imshape[0]);
      gty = grid_size(imshape[1]);
      #undef grid_size
    } else {
      // we want patches fully included in the image
      offset = cell_size/2;
      step = cell_size/(overlap+1);
      #define grid_size(imsize) (1+MAX(0,imsize-2*offset)/step)
      gtx = grid_size(imshape[0]);
      gty = grid_size(imshape[1]);
      #undef grid_size
    }
    
    assert(!grid->pixels);
    *grid = empty_cube(int,gtx,gty,2);
    
    assert(0<=overlap && overlap<=1);
    int nc = pow2(2+child_overlap);  // number of children per cell
    if(child_grid) {
      assert(!norms->pixels);
      *norms = image_like(float,grid);
      assert(!children->pixels);
      *children = empty_cube(int,gtx,gty,nc);
    }
    
    _prepare_big_cells( cell_size, offset, step, child_grid, child_norms, grid, children, norms );
}
コード例 #3
0
  void goalCB()
  {
    ROS_INFO("%s: Received new goal", action_name_.c_str());

    typedef boost::shared_ptr<const turtlebot_actions::FindFiducialGoal> GoalPtr;
    GoalPtr goal = as_.acceptNewGoal();

    cv::Size grid_size(goal->pattern_width,goal->pattern_height);
    detector_.setPattern(grid_size, goal->pattern_size, Pattern(goal->pattern_type));

    ros::Duration(1.0).sleep();
    //subscribe to the image topic of interest
    std::string image_topic = goal->camera_name + "/image_rect";
    sub_ = it_.subscribeCamera(image_topic, 1, &FindFiducialAction::detectCB, this);

    pub_timer_ = nh_.createTimer(tf_listener_.getCacheLength() - ros::Duration(1.0), boost::bind(&FindFiducialAction::timeoutCB, this, _1),true);
  }
コード例 #4
0
ファイル: grid.c プロジェクト: Sproglet/oversight
/*
 * Calculate or check all grid offsets.
 * Return : NULL=ok else error message (must be freed)
 */
char *grid_calculate_offsets(GridInfo *gi)
{
    char *error_text = NULL;

    if (gi->segments) {

        GridSegment *gs = gi->segments->array[0];

        if (gs->offset == -1) {
            error_text = grid_set_offsets(gi);
        } else {
            error_text = grid_check_offsets(gi);
        }
        gi->page_size = grid_size(gi);
    }
    return error_text;
}
コード例 #5
0
ファイル: UmlCanvas.cpp プロジェクト: kralf/bouml
void UmlCanvas::drawBackground(QPainter& painter, const QRect& clip) {
  if (show_grid()) {
    int s = grid_size();
    
    qreal left = int(clip.left())-(int(clip.left()) % s);
    qreal top = int(clip.top())-(int(clip.top()) % s);
    
    QVarLengthArray<QLineF, 100> lines;
    
    for (qreal x = left; x < clip.right(); x += s)
      lines.append(QLineF(x, clip.top(), x, clip.bottom()));
    for (qreal y = top; y < clip.bottom(); y += s)
      lines.append(QLineF(clip.left(), y, clip.right(), y));
    
    painter.save();
    painter.setPen(Qt::lightGray);
    painter.drawLines(lines.data(), lines.size());
    painter.restore();
  }
}
コード例 #6
0
// The evolve method filters the "current" image passed in by the INVT
// simulation framework and computes this image's gist vector. To compute
// this vector, it first applies Gabor filters to the input image at
// different orientations and scales. Then, it subdivides each of the
// filteration results into smaller "chunks" and populates the gist
// vector with the average pixel values in these coarse chunks.
void GistEstimatorContextBased::
onSimEventVisualCortexOutput(SimEventQueue& q, rutz::shared_ptr<SimEventVisualCortexOutput>& e)
{
  ///////////// VisualCortex* vc = dynamic_cast<VisualCortex*>(e->source()) ;

  const double G = GRID_SIZE ;
  const int N = GRID_SIZE * GRID_SIZE ;
  Image<double>::iterator gist_vector = itsGistVector.beginw() ;

  clock_t start_time = clock() ;
  for (uint orientation = 0; orientation < NUM_ORIENTATIONS; ++orientation)
    for (uint scale = 0; scale < NUM_SCALES; ++scale, gist_vector += N)
      {

        LFATAL("Please talk to Laurent to fix this");

        ImageType I; /////// = apply_gabor_filter(vc, orientation, scale) ;
        //LINFO("Gabor filter [O:%u, S:%u] returned %dx%d image",
        //orientation, scale, I.getWidth(), I.getHeight()) ;

        Dims grid_size(static_cast<int>(std::ceil(I.getWidth()/G)),
                       static_cast<int>(std::ceil(I.getHeight()/G))) ;
        //LINFO("computing averages for %dx%d subimages of filtered image",
        //grid_size.w(), grid_size.h()) ;
        std::vector<double> averages = grid_averages(I, grid_size) ;

        //LINFO("copying %d averages to gist vector at offset %d",
        //int(averages.size()),
        //int(gist_vector - itsGistVector.beginw())) ;
        std::copy(averages.begin(), averages.end(), gist_vector) ;
      }
  LINFO("%g seconds to compute %dx%d gist vector",
        static_cast<double>(clock() - start_time)/CLOCKS_PER_SEC,
        itsGistVector.getHeight(), itsGistVector.getWidth()) ;

  rutz::shared_ptr<SimEventGistOutput>
    gist_event(new SimEventGistOutput(this, itsGistVector)) ;
  q.post(gist_event) ;
}
コード例 #7
0
ThemeManager::ThemeManager(QSettings& settings, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_settings(settings)
{
	setWindowTitle(tr("Themes"));

	m_tabs = new QTabWidget(this);

	// Find view sizes
	int focush = style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
	int focusv = style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
	int frame = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
	int scrollbar = style()->pixelMetric(QStyle::PM_SliderThickness);
	QSize grid_size(259 + focush, 154 + focusv + (fontMetrics().height() * 2));
	QSize view_size((grid_size.width() + frame + focush) * 2 + scrollbar, (grid_size.height() + frame + focusv) * 2);

	// Add default themes tab
	QWidget* tab = new QWidget(this);
	m_tabs->addTab(tab, tr("Default"));

	// Add default themes list
	m_default_themes = new QListWidget(tab);
	m_default_themes->setSortingEnabled(true);
	m_default_themes->setViewMode(QListView::IconMode);
	m_default_themes->setIconSize(QSize(258, 153));
	m_default_themes->setGridSize(grid_size);
	m_default_themes->setMovement(QListView::Static);
	m_default_themes->setResizeMode(QListView::Adjust);
	m_default_themes->setSelectionMode(QAbstractItemView::SingleSelection);
	m_default_themes->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_default_themes->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
	m_default_themes->setMinimumSize(view_size);
	m_default_themes->setWordWrap(true);
	addItem("gentleblues", true, tr("Gentle Blues"));
	addItem("oldschool", true, tr("Old School"));
	addItem("spacedreams", true, tr("Space Dreams"));
	addItem("writingdesk", true, tr("Writing Desk"));

	// Add default control buttons
	QPushButton* new_default_button = new QPushButton(tr("New"), tab);
	new_default_button->setAutoDefault(false);
	connect(new_default_button, SIGNAL(clicked()), this, SLOT(newTheme()));

	m_clone_default_button = new QPushButton(tr("Duplicate"), tab);
	m_clone_default_button->setAutoDefault(false);
	connect(m_clone_default_button, SIGNAL(clicked()), this, SLOT(cloneTheme()));

	// Lay out default themes tab
	QGridLayout* default_layout = new QGridLayout(tab);
	default_layout->setColumnStretch(0, 1);
	default_layout->setRowStretch(2, 1);
	default_layout->addWidget(m_default_themes, 0, 0, 3, 1);
	default_layout->addWidget(new_default_button, 0, 1);
	default_layout->addWidget(m_clone_default_button, 1, 1);

	// Add themes tab
	tab = new QWidget(this);
	m_tabs->addTab(tab, tr("Custom"));

	// Add themes list
	m_themes = new QListWidget(tab);
	m_themes->setSortingEnabled(true);
	m_themes->setViewMode(QListView::IconMode);
	m_themes->setIconSize(QSize(258, 153));
	m_themes->setGridSize(grid_size);
	m_themes->setMovement(QListView::Static);
	m_themes->setResizeMode(QListView::Adjust);
	m_themes->setSelectionMode(QAbstractItemView::SingleSelection);
	m_themes->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_themes->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
	m_themes->setMinimumSize(view_size);
	m_themes->setWordWrap(true);
	QDir dir(Theme::path(), "*.theme");
	QStringList themes = dir.entryList(QDir::Files, QDir::Name | QDir::IgnoreCase);
	for (const QString& theme : themes) {
		QString name = QSettings(dir.filePath(theme), QSettings::IniFormat).value("Name").toString();
		if (!name.isEmpty()) {
			addItem(QFileInfo(theme).completeBaseName(), false, name);
		} else {
			name = QUrl::fromPercentEncoding(QFileInfo(theme).completeBaseName().toUtf8());
			QSettings(dir.filePath(theme), QSettings::IniFormat).setValue("Name", name);

			QString id = Theme::createId();
			dir.rename(theme, id + ".theme");
			dir.remove(QFileInfo(theme).completeBaseName() + ".png");

			QStringList sessions = QDir(Session::path(), "*.session").entryList(QDir::Files);
			sessions.prepend("");
			for (const QString& file : sessions) {
				Session session(file);
				if ((session.theme() == name) && (session.themeDefault() == false)) {
					session.setTheme(id, false);
				}
			}

			addItem(id, false, name);
		}
	}

	// Add control buttons
	QPushButton* new_button = new QPushButton(tr("New"), tab);
	new_button->setAutoDefault(false);
	connect(new_button, SIGNAL(clicked()), this, SLOT(newTheme()));

	m_clone_button = new QPushButton(tr("Duplicate"), tab);
	m_clone_button->setAutoDefault(false);
	m_clone_button->setEnabled(false);
	connect(m_clone_button, SIGNAL(clicked()), this, SLOT(cloneTheme()));

	m_edit_button = new QPushButton(tr("Edit"), tab);
	m_edit_button->setAutoDefault(false);
	m_edit_button->setEnabled(false);
	connect(m_edit_button, SIGNAL(clicked()), this, SLOT(editTheme()));

	m_remove_button = new QPushButton(tr("Delete"), tab);
	m_remove_button->setAutoDefault(false);
	m_remove_button->setEnabled(false);
	connect(m_remove_button, SIGNAL(clicked()), this, SLOT(deleteTheme()));

	QPushButton* import_button = new QPushButton(tr("Import"), tab);
	import_button->setAutoDefault(false);
	connect(import_button, SIGNAL(clicked()), this, SLOT(importTheme()));

	m_export_button = new QPushButton(tr("Export"), tab);
	m_export_button->setAutoDefault(false);
	m_export_button->setEnabled(false);
	connect(m_export_button, SIGNAL(clicked()), this, SLOT(exportTheme()));

	// Lay out custom themes tab
	QGridLayout* custom_layout = new QGridLayout(tab);
	custom_layout->setColumnStretch(0, 1);
	custom_layout->setRowMinimumHeight(4, import_button->sizeHint().height());
	custom_layout->setRowStretch(7, 1);
	custom_layout->addWidget(m_themes, 0, 0, 8, 1);
	custom_layout->addWidget(new_button, 0, 1);
	custom_layout->addWidget(m_clone_button, 1, 1);
	custom_layout->addWidget(m_edit_button, 2, 1);
	custom_layout->addWidget(m_remove_button, 3, 1);
	custom_layout->addWidget(import_button, 5, 1);
	custom_layout->addWidget(m_export_button, 6, 1);

	// Lay out dialog
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
	connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));

	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(m_tabs, 1);
	layout->addSpacing(layout->margin());
	layout->addWidget(buttons);

	// Select theme
	QString theme = m_settings.value("ThemeManager/Theme").toString();
	bool is_default = m_settings.value("ThemeManager/ThemeDefault", false).toBool();
	if (!selectItem(theme, is_default)) {
		selectItem(Theme::defaultId(), true);
	}
	selectionChanged(is_default);
	connect(m_default_themes, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(currentThemeChanged(QListWidgetItem*)));
	connect(m_themes, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(currentThemeChanged(QListWidgetItem*)));
	connect(m_themes, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(editTheme()));

	// Restore size
	resize(m_settings.value("ThemeManager/Size", sizeHint()).toSize());
}
コード例 #8
0
ファイル: config.cpp プロジェクト: powderluv/rpg_svo
Config::Config() :
#ifdef SVO_USE_ROS
    trace_name(vk::getParam<string>("svo/trace_name", "svo")),
    trace_dir(vk::getParam<string>("svo/trace_dir", "/tmp")),
    n_pyr_levels(vk::getParam<int>("svo/n_pyr_levels", 3)),
    use_imu(vk::getParam<bool>("svo/use_imu", false)),
    core_n_kfs(vk::getParam<int>("svo/core_n_kfs", 3)),
    map_scale(vk::getParam<double>("svo/map_scale", 1.0)),
    grid_size(vk::getParam<int>("svo/grid_size", 30)),
    init_min_disparity(vk::getParam<double>("svo/init_min_disparity", 50.0)),
    init_min_tracked(vk::getParam<int>("svo/init_min_tracked", 50)),
    init_min_inliers(vk::getParam<int>("svo/init_min_inliers", 40)),
    klt_max_level(vk::getParam<int>("svo/klt_max_level", 4)),
    klt_min_level(vk::getParam<int>("svo/klt_min_level", 2)),
    reproj_thresh(vk::getParam<double>("svo/reproj_thresh", 2.0)),
    poseoptim_thresh(vk::getParam<double>("svo/poseoptim_thresh", 2.0)),
    poseoptim_num_iter(vk::getParam<int>("svo/poseoptim_num_iter", 10)),
    structureoptim_max_pts(vk::getParam<int>("svo/structureoptim_max_pts", 20)),
    structureoptim_num_iter(vk::getParam<int>("svo/structureoptim_num_iter", 5)),
    loba_thresh(vk::getParam<double>("svo/loba_thresh", 2.0)),
    loba_robust_huber_width(vk::getParam<double>("svo/loba_robust_huber_width", 1.0)),
    loba_num_iter(vk::getParam<int>("svo/loba_num_iter", 0)),
    kfselect_mindist(vk::getParam<double>("svo/kfselect_mindist", 0.12)),
    triang_min_corner_score(vk::getParam<double>("svo/triang_min_corner_score", 20.0)),
    triang_half_patch_size(vk::getParam<int>("svo/triang_half_patch_size", 4)),
    subpix_n_iter(vk::getParam<int>("svo/subpix_n_iter", 10)),
    max_n_kfs(vk::getParam<int>("svo/max_n_kfs", 10)),
    img_imu_delay(vk::getParam<double>("svo/img_imu_delay", 0.0)),
    max_fts(vk::getParam<int>("svo/max_fts", 120)),
    quality_min_fts(vk::getParam<int>("svo/quality_min_fts", 50)),
    quality_max_drop_fts(vk::getParam<int>("svo/quality_max_drop_fts", 40))
#else
    trace_name("svo"),
#ifdef ANDROID
    trace_dir("/data/local/tmp"),
#else
    trace_dir("/tmp"),
#endif
    n_pyr_levels(3),
    use_imu(false),
    core_n_kfs(3),
    map_scale(1.0),
    grid_size(25),
    init_min_disparity(50.0),
    init_min_tracked(50),
    init_min_inliers(40),
    klt_max_level(4),
    klt_min_level(2),
    reproj_thresh(2.0),
    poseoptim_thresh(2.0),
    poseoptim_num_iter(10),
    structureoptim_max_pts(20),
    structureoptim_num_iter(5),
    loba_thresh(2.0),
    loba_robust_huber_width(1.0),
    loba_num_iter(0),
    kfselect_mindist(0.12),
    triang_min_corner_score(20.0),
    triang_half_patch_size(4),
    subpix_n_iter(10),
    max_n_kfs(0),
    img_imu_delay(0.0),
    max_fts(120),
    quality_min_fts(50),
    quality_max_drop_fts(40)
#endif
{}

Config& Config::getInstance()
{
  static Config instance; // Instantiated on first use and guaranteed to be destroyed
  return instance;
}

} // namespace svo
コード例 #9
0
ファイル: Mtrace2.c プロジェクト: 1014511134/src
int main(int argc, char* argv[])
{
    int nx, na, na2, ia, nz, order, maxsplit, ix, iz, *siz;
    float **place, *slow, **out, dx,dz, x0,z0, x[2];
    float max1, min1, max2, min2;
    bool isvel, lsint;
    agrid grd;
    sf_file vel, outp, size, grid;
        
    sf_init (argc,argv);

    /* get 2-D grid parameters */
    vel = sf_input("in");
    if (!sf_histint(vel,"n1",&nz)) sf_error("No n1= in input");
    if (!sf_histint(vel,"n2",&nx)) sf_error("No n2= in input");
    if (!sf_histfloat(vel,"d1",&dz)) sf_error("No d1= in input");
    if (!sf_histfloat(vel,"d2",&dx)) sf_error("No d2= in input");
    if (!sf_histfloat(vel,"o1",&z0)) z0=0.;
    if (!sf_histfloat(vel,"o2",&x0)) x0=0.;

    outp = sf_output("out");
    
    sf_putint(outp,"n4",nz);
    sf_putfloat(outp,"d4",dz);
    sf_putfloat(outp,"o4",z0);

    sf_putint(outp,"n3",nx);
    sf_putfloat(outp,"d3",dx);
    sf_putfloat(outp,"o3",x0);

    if (!sf_getint("na",&na)) na=60;
    /* number of angles */
    if (!sf_getfloat("da",&da)) da=3.1;
    /* angle increment (in degrees) */
    if (!sf_getfloat("a0",&a0)) a0=-90.;
    /* initial angle (in degrees) */

    if (!sf_getint("maxsplit",&maxsplit)) maxsplit=10;
    /* maximum splitting for adaptive grid */

    if (!sf_getfloat("minx",&min1)) min1=0.5*dx;
    /* parameters for adaptive grid */
    if (!sf_getfloat("maxx",&max1)) max1=2.*dx;
    if (!sf_getfloat("mina",&min2)) min2=0.5*da;
    if (!sf_getfloat("maxa",&max2)) max2=2.*da;

    sf_putint(outp,"n2",na);
    sf_putfloat(outp,"d2",da);
    sf_putfloat(outp,"o2",a0);

    da *= (SF_PI/180.);
    a0 *= (SF_PI/180.);

    sf_putint(outp,"n1",5);

    size = sf_output("size");
    sf_putint(size,"n1",nx);
    sf_putint(size,"n2",nz);
    sf_settype(size,SF_INT);

    grid = sf_output("grid");

    /* additional parameters */
    if(!sf_getbool("vel",&isvel)) isvel=true;
    /* y: velocity, n: slowness */
    if(!sf_getint("order",&order)) order=3;
    /* velocity interpolation order */
    if (!sf_getbool("lsint",&lsint)) lsint=false;
    /* if use least-squares interpolation */

    slow  = sf_floatalloc(nz*nx);
    place = sf_floatalloc2(5,na);
    siz  = sf_intalloc(nx);

    sf_floatread(slow,nx*nz,vel);

    if (isvel) {
      for(ix = 0; ix < nx*nz; ix++){
	slow[ix] = 1./slow[ix];
      }
    }

    ct = sf_celltrace_init (lsint, order, nz*nx, nz, nx, dz, dx, z0, x0, slow);
    free (slow);

    grd = agrid_init (na, 5, maxsplit);
    agrid_set (grd,place);

    for (iz = 0; iz < nz; iz++) {
	x[0] = z0+iz*dz;

	sf_warning("depth %d of %d;",iz+1, nz);
	for (ix = 0; ix < nx; ix++) {
	    x[1] = x0+ix*dx;

	    fill_grid(grd,min1,max1,min2,max2,(void*) x, raytrace);
	
	    na2 = grid_size (grd);
	    out = write_grid (grd);

	    siz[ix] = na2;
	
	    for (ia=0; ia < na2; ia++) {
	      if (ia < na)
		  sf_floatwrite (place[ia], 5, outp);

	      sf_floatwrite(out[ia], 5, grid);
	    }
	    free (out);
	}
	
	sf_intwrite (siz,nx,size);
    }
    sf_warning(".");

    exit (0);
}
コード例 #10
0
ファイル: grid.hpp プロジェクト: rasmith/RayTracerX
 void AssignToAll(const ValueType& v) {
   for (int n = 0; n < grid_size(); ++n)
     values_[n] = v;
 }
コード例 #11
0
ファイル: manager.cpp プロジェクト: prohor33/physics-projects
void Manager::InitializeSolver() {

  if (!PARAMETERS->GetGridFromInputFile()) {

    SOLVER->SetGridNeighbors(
              GridNeighbor(-1, -1),
              GridNeighbor(-1, -1),
              GridNeighbor(-1, -1)
              );

    SOLVER->grid_ = new Grid();

    return;
  }

  GRID_FILE_READER->ReadFile(PARAMETERS->GetInputGridFilename());

  int n, m, p;

  n = GRID_FILE_READER->grid_config()->size[sep::X];
  m = GRID_FILE_READER->grid_config()->size[sep::Y];
  p = GRID_FILE_READER->grid_config()->size[sep::Z];

  // TODO: here should be size of process grid, not whole grid
  SOLVER->SetWholeCellsQuantity(n * m * p);

  vector<int> grid_size(3);
  vector<int> grid_start(3);

  if (!PARAMETERS->GetUseParallelComputing()) {
    // Singletone case

    SOLVER->SetGridNeighbors(
              GridNeighbor(-1, -1),
              GridNeighbor(-1, -1),
              GridNeighbor(-1, -1)
              );

    grid_start[sep::X] = 0;
    grid_start[sep::Y] = 0;
    grid_start[sep::Z] = 0;

    grid_size[sep::X] = n;
    grid_size[sep::Y] = m;
    grid_size[sep::Z] = p;

    SOLVER->grid_ = new Grid(grid_start, grid_size);

    return;
  }

  // Parallel computing case

  int rank = PARAMETERS->GetProcessID();
  int size = PARAMETERS->GetProcessesQ();

  int norm_size = n/size + 1;

  if (rank == size-1) {
    // last process

    grid_size[sep::X] = n - norm_size*(size-1);
  } else {

    grid_size[sep::X] = norm_size;
  }

  grid_size[sep::Y] = m;
  grid_size[sep::Z] = p;

  grid_start[sep::X] = rank * norm_size;
  grid_start[sep::Y] = 0;
  grid_start[sep::Z] = 0;

  cout << "rank " << rank << ": start = " << grid_start[sep::X] <<
    " size = " << grid_size[sep::X] << endl;

  SOLVER->SetGridNeighbors(
            GridNeighbor(rank < size-1 ? rank+1 : -1, rank > 0 ? rank-1 : -1),
            GridNeighbor(-1, -1),
            GridNeighbor(-1, -1)
            );

  SOLVER->grid_ = new Grid(grid_start, grid_size);
}
コード例 #12
0
void ossimHdfGridModel::setGridNodes(ossimDblGrid& grid, int32 sds_id, const ossimIpt& spacing)
{
   int x=0, y=0;
   ossim_uint32 index = 0;
   if (m_isHdf4)
   {
      int32 dim_sizes[MAX_VAR_DIMS];
      int32 rank, data_type, n_attrs;
      char  name[MAX_NC_NAME];

      int32 status = SDgetinfo(sds_id, name, &rank, dim_sizes, &data_type, &n_attrs);
      if (status == -1)
         return;

      int32 origin[2] = {0, 0}; 
      int32 num_rows = dim_sizes[0]; 
      int32 num_cols = dim_sizes[1]; 

      ossimDpt grid_origin(0,0); // The grid as used in base class, has UV-space always at 0,0 origin
      ossimIpt grid_size (num_cols, num_rows);
      ossimDpt dspacing (spacing);
      grid.initialize(grid_size, grid_origin, dspacing);

      float32* values = new float32 [num_rows * num_cols]; 
      intn statusN = SDreaddata(sds_id, origin, NULL, dim_sizes, (VOIDP)values);
      if (statusN > -1)
      {
         for (y = 0; y < num_rows; y++)
         {
            for (x = 0; x < num_cols; x++)
            {
               grid.setNode(x, y, values[index++]);
            }
         }
      }
      delete values;
   }
   else
   {
      hsize_t dims_out[2]; //dataset dimensions
      hid_t datatype = H5Dget_type(sds_id);
      hid_t dataspace = H5Dget_space(sds_id);    //dataspace handle
      int rank = H5Sget_simple_extent_ndims(dataspace);
      if (rank == 2)
      {
         herr_t status_n  = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);

         ossim_int32 latGridRows = dims_out[0];
         ossim_int32 lonGridCols = dims_out[1];

         ossim_int32 cols = spacing.x;
         ossim_int32 rows = spacing.y;

         ossim_int32 spacingX = 0;
         ossim_int32 spacingY = 0;

         if (rows % latGridRows == 0 && cols % lonGridCols == 0)
         {
            spacingY = rows/latGridRows; //line increment step
            spacingX = cols/lonGridCols; //pixel increment step
         }
         
         ossimIpt gridSpacing(spacingX, spacingY);

         ossimDpt grid_origin(0,0); // The grid as used in base class, has UV-space always at 0,0 origin
         ossimIpt grid_size (cols, rows);
         ossimDpt dspacing (gridSpacing);
         grid.initialize(grid_size, grid_origin, dspacing);

         if( H5Tequal(H5T_NATIVE_FLOAT,  datatype))
         {
            ossim_float32* data_out = new ossim_float32[dims_out[0] * dims_out[1]];
            herr_t status = H5Dread(sds_id, datatype, dataspace, dataspace,
               H5P_DEFAULT, data_out);

            index = 0;
            for (y = 0; y < rows; y++)
            {
               for (x = 0; x < cols; x++)
               {
                  index = x + y * cols;
                  grid.setNode(x, y, data_out[index]);
               }
            }
            delete[] data_out;
         }
         else if( H5Tequal(H5T_NATIVE_DOUBLE,  datatype))
         {
            ossim_float64* data_out = new ossim_float64[dims_out[0] * dims_out[1]];
            herr_t status = H5Dread(sds_id, datatype, dataspace, dataspace,
               H5P_DEFAULT, data_out);

            index = 0;
            for (y = 0; y < rows; y++)
            {
               for (x = 0; x < cols; x++)
               {
                  index = x + y * cols;
                  grid.setNode(x, y, data_out[index]);
               }
            }
            delete[] data_out;
         }
      }
      H5Tclose(datatype);
      H5Sclose(dataspace);
   }
}