void CMeter2DGraphView::UpdateValueAxisTitle() { TRACE_FUN( Frequently, "CMeter2DGraphView::UpdateValueAxisTitle" ); QString valueAxisTitle( QString::fromUtf8( model()->valueAxisTitle().c_str() ) ); QRect valueAxisTitleRect( QFontMetrics( _boldFont ).boundingRect( 0, 0, _meshArea.height(), 0, Qt::AlignCenter | Qt::TextWordWrap, valueAxisTitle ) ); _meshArea.setLeft( 0 ); _meshArea.adjust( valueAxisTitleRect.height(), 0, 0, 0 ); SRaster& raster( _rasterContainer[ CMeter2DGraphView::rtValueAxisTitle ] ); raster._x = _meshArea.x() - valueAxisTitleRect.height(); raster._y = _meshArea.y() + _meshArea.height() / 2 + valueAxisTitleRect.width() / 2; raster._image = QImage( valueAxisTitleRect.height(), valueAxisTitleRect.width(), QImage::Format_ARGB32 ); QPainter painter; InitializeRasterRenderer( painter, raster._image ); painter.setFont( _boldFont ); painter.rotate( -90 ); painter.drawText( -valueAxisTitleRect.width(), 0, valueAxisTitleRect.width(), valueAxisTitleRect.height(), Qt::AlignCenter | Qt::TextWordWrap, valueAxisTitle ); }
RASTER_MAP_TYPE QgsGrassGisLib::G_raster_map_type( const char *name, const char *mapset ) { Q_UNUSED( mapset ); Raster rast = raster( name ); return grassRasterType( rast.provider->dataType( rast.band ) ); }
aRTcomponent* aRTdb::ImportRaster(SEXP options) { string filename = GET_STRING_ELEMENT(options, "file"); string layername = GET_STRING_ELEMENT(options, "lname"); double dummy = GET_REAL_ELEMENT (options, "dummy"); TeRaster raster(filename.c_str()); bool ok; aRTlayer* child = new aRTlayer(Database, layername); AddChild(child); PrintSilent("Importing raster \'%s\' to layer \'%s\' ... ", filename.c_str(), layername.c_str()); ok = TeImportRaster (child->Layer(), &raster, raster.params().ncols_, raster.params().nlines_, TeRasterParams::TeNoCompression, "", // object id dummy, true); // usedummy if(!ok) { PrintSilentNo; error("Could not import the raster"); } PrintSilentYes; return child; }
void fbPolySegment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) { void (*raster)(DrawablePtr drawable, GCPtr gc, int n, xSegment * seg); DBG(("%s x %d, width=%d, fill=%d, line=%d\n", __FUNCTION__, n, gc->lineWidth, gc->fillStyle, gc->lineStyle)); if (gc->lineWidth == 0) { raster = fbZeroSegment; if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid) { switch (drawable->bitsPerPixel) { case 8: raster = fbPolySegment8; break; case 16: raster = fbPolySegment16; break; case 32: raster = fbPolySegment32; break; } } } else raster = miPolySegment; raster(drawable, gc, n, seg); }
double terrama2::core::RiscoDeFogo::XYLinhaCol(double x, double y, const std::string& path, const std::string& filename) const { //const auto& prec = *(precipitacao.rbegin()+i); std::shared_ptr<te::da::DataSource> datasource(te::da::DataSourceFactory::make("GDAL", "file://"+path+filename)); //RAII for open/closing the datasource terrama2::core::OpenClose<std::shared_ptr<te::da::DataSource> > openClose(datasource); std::shared_ptr<te::da::DataSourceTransactor> transactor(datasource->getTransactor()); std::shared_ptr<te::da::DataSet> dataset(transactor->getDataSet(filename)); std::shared_ptr<te::rst::Raster> raster(dataset->getRaster(0)); te::rst::Grid* grid = raster->getGrid(); te::rst::Band* band = raster->getBand(0); double colD, rowD; grid->geoToGrid(x, y, colD, rowD); int col = std::round(colD); int row = std::round(rowD); double value; band->getValue(col, row, value); return value; }
void DrawTargetSkia::MaskSurface(const Pattern &aSource, SourceSurface *aMask, Point aOffset, const DrawOptions &aOptions) { MarkChanged(); AutoPaintSetup paint(mCanvas.get(), aOptions, aSource); TempBitmap bitmap = GetBitmapForSurface(aMask); if (bitmap.mBitmap.colorType() == kAlpha_8_SkColorType) { mCanvas->drawBitmap(bitmap.mBitmap, aOffset.x, aOffset.y, &paint.mPaint); } else { SkPaint maskPaint; TempBitmap tmpBitmap; SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP), tmpBitmap); SkMatrix transform = maskPaint.getShader()->getLocalMatrix(); transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y)); maskPaint.getShader()->setLocalMatrix(transform); SkLayerRasterizer::Builder builder; builder.addLayer(maskPaint); SkAutoTUnref<SkRasterizer> raster(builder.detachRasterizer()); paint.mPaint.setRasterizer(raster.get()); IntSize size = aMask->GetSize(); Rect rect = Rect(aOffset.x, aOffset.y, size.width, size.height); mCanvas->drawRect(RectToSkRect(rect), paint.mPaint); } }
int QgsGrassGisLib::G_open_cell_old( const char *name, const char *mapset ) { Q_UNUSED( mapset ); Raster rast = raster( name ); return rast.fd; }
Raster* Raster::getRasterFromASCFile(std::string const& fname) { std::ifstream in(fname.c_str()); if (!in.is_open()) { WARN("Raster::getRasterFromASCFile(): Could not open file %s.", fname.c_str()); return NULL; } // header information std::size_t n_cols(0), n_rows(0); double xllcorner(0.0), yllcorner(0.0), cell_size(0.0), no_data_val(-9999); if (readASCHeader(in, n_cols, n_rows, xllcorner, yllcorner, cell_size, no_data_val)) { double* values = new double[n_cols*n_rows]; std::string s; // read the data into the double-array for (size_t j(0); j < n_rows; ++j) { const size_t idx ((n_rows - j - 1) * n_cols); for (size_t i(0); i < n_cols; ++i) { in >> s; values[idx+i] = strtod(BaseLib::replaceString(",", ".", s).c_str(),0); } } in.close(); Raster *raster(new Raster(n_cols, n_rows, xllcorner, yllcorner, cell_size, values, values+n_cols*n_rows, no_data_val)); delete [] values; return raster; } else {
void fbPolyLine(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt) { void (*raster)(DrawablePtr, GCPtr, int mode, int n, DDXPointPtr pt); DBG(("%s x %d, width=%d, fill=%d, line=%d\n", __FUNCTION__, n, gc->lineWidth, gc->fillStyle, gc->lineStyle)); if (gc->lineWidth == 0) { raster = fbZeroLine; if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid) { switch (drawable->bitsPerPixel) { case 8: raster = fbPolyline8; break; case 16: raster = fbPolyline16; break; case 32: raster = fbPolyline32; break; } } } else { if (gc->lineStyle != LineSolid) raster = miWideDash; else raster = miWideLine; } raster(drawable, gc, mode, n, pt); }
CurveRasterizer<int, Polynomial2> EnhancedSGM::getCurveRasteriser2(int idx) const { Vector2i _pinfPx = _pinfPxVec[idx]; CurveRasterizer<int, Polynomial2> raster(_pinfPx, epipoles().getSecondPx(), _epipolarCurves.getSecond(_reconstVec[idx])); if (epipoles().secondIsInverted()) raster.setStep(-1); return raster; }
CurveRasterizer<int, Polynomial2> EnhancedSGM::getCurveRasteriser1(int idx) const { Vector2i pt = _pointPxVec1[idx]; CurveRasterizer<int, Polynomial2> raster(pt, epipoles().getFirstPx(), _epipolarCurves.getFirst(_reconstVec[idx])); if (epipoles().firstIsInverted()) raster.setStep(-1); return raster; }
void CMeter2DGraphView::UpdateValueTitle() { TRACE_FUN( Frequently, "CMeter2DGraphView::UpdateValueTitle" ); typedef std::list< int > THeightContainer; THeightContainer heightContainer; int maxValueTitleWidth( 0 ); const CMeter2DGraphModel::TValueTitleContainer& valueTitleContainer( model()->valueTitleContainer() ); for( CMeter2DGraphModel::TValueTitleContainer::const_iterator I_value( valueTitleContainer.begin() ); I_value != valueTitleContainer.end(); ++I_value ) { QSize valueTitleSize( QFontMetrics( _normalFont ).size( Qt::AlignCenter, I_value->c_str() ) ); valueTitleSize.setWidth( valueTitleSize.width() + 2 ); heightContainer.push_back( valueTitleSize.height() ); if( maxValueTitleWidth < valueTitleSize.width() ) { maxValueTitleWidth = valueTitleSize.width(); } } _meshArea.setRight( width() ); _meshArea.adjust( 0, 0, -maxValueTitleWidth - 1, 0 ); SRaster& raster( _rasterContainer[ CMeter2DGraphView::rtValueTitles ] ); raster._x = _meshArea.x() + _meshArea.width(); raster._y = _meshArea.y() + _meshArea.height(); raster._image = QImage( maxValueTitleWidth, _meshArea.height(), QImage::Format_ARGB32 ); QPainter painter; InitializeRasterRenderer( painter, raster._image ); painter.setFont( _normalFont ); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const CMeter2DGraphModel::TValueTitleContainer& titleContainer( model()->valueTitleContainer() ); THeightContainer::iterator I_height( heightContainer.begin() ); CMeter2DGraphModel::TValueTitleContainer::const_iterator I_title( titleContainer.begin() ); float resolution( float( raster._image.height() ) / model()->valueResolution() ); for( float I_y( resolution ); I_y < raster._image.height() - resolution / 2 && I_height != heightContainer.end() && I_title != titleContainer.end(); I_y += resolution, ++I_height, ++I_title ) { painter.drawText( 1, int( I_y ) - *I_height / 2, maxValueTitleWidth, *I_height, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, I_title->c_str() ); } }
void terrama2::core::DataStoragerTiff::store(DataSetSeries series, DataSetPtr outputDataSet) const { if(!outputDataSet.get() || !series.syncDataSet.get()) { QString errMsg = QObject::tr("Mandatory parameters not provided."); TERRAMA2_LOG_ERROR() << errMsg; throw DataStoragerException() << ErrorDescription(errMsg); } QUrl uri(QString::fromStdString(dataProvider_->uri)); auto path = uri.path().toStdString(); try { std::string mask = getMask(outputDataSet); auto dataset = series.syncDataSet->dataset(); size_t rasterColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE); if(!isValidColumn(rasterColumn)) { QString errMsg = QObject::tr("No raster attribute."); TERRAMA2_LOG_ERROR() << errMsg; throw DataStoragerException() << ErrorDescription(errMsg); } size_t timestampColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::DATETIME_TYPE); dataset->moveBeforeFirst(); while(dataset->moveNext()) { std::shared_ptr<te::rst::Raster> raster(dataset->isNull(rasterColumn) ? nullptr : dataset->getRaster(rasterColumn).release()); std::shared_ptr<te::dt::DateTime> timestamp; if(!isValidColumn(timestampColumn) || dataset->isNull(timestampColumn)) timestamp = nullptr; else timestamp.reset(dataset->getDateTime(timestampColumn).release()); if(!raster.get()) { QString errMsg = QObject::tr("Null raster found."); TERRAMA2_LOG_ERROR() << errMsg; continue; } std::string filename = replaceMask(mask, timestamp, outputDataSet); std::string output = path + "/" + filename; te::rp::Copy2DiskRaster(*raster, output); } } catch(const DataStoragerException&) { throw; } catch(...) { //TODO: fix DataStoragerTiff catch } }
static void put_contig_and_raster(TIFFRGBAImage * img, uint32 * rast, uint32 x, uint32 y, uint32 w, uint32 h, int32 fromskew, int32 toskew, unsigned char *cp) { (*(((TIFFRGBAImage_Extra *) img)->put_contig)) (img, rast, x, y, w, h, fromskew, toskew, cp); raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h); }
static void put_separate_and_raster(TIFFRGBAImage * img, uint32 * rast, uint32 x, uint32 y, uint32 w, uint32 h, int32 fromskew, int32 toskew, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) { (*(((TIFFRGBAImage_Extra *) img)->put_separate)) (img, rast, x, y, w, h, fromskew, toskew, r, g, b, a); raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h); }
TEST(MeshValidation, DetectHolesTri) { std::array<double, 12> pix = {{0,0.1,0.2,0.1,0,0,0.1,0,0,0,-0.1,0}}; GeoLib::Raster raster(4,3,0,0,1,pix.begin(), pix.end()); MeshLib::ConvertRasterToMesh conv(raster, MeshLib::MeshElemType::TRIANGLE, MeshLib::UseIntensityAs::ELEVATION); auto mesh = std::unique_ptr<MeshLib::Mesh>{conv.execute()}; ASSERT_EQ(0, MeshLib::MeshValidation::detectHoles(*mesh)); detectHoles(*mesh, {12}, 1); detectHoles(*mesh, {11, 11}, 1); detectHoles(*mesh, {10, 12}, 2); }
void Paintbox::refreshBrushPreview() { if (item != NULL) brush_viewer->scene()->removeItem(item); item = brush_viewer->scene()->addPixmap(QPixmap::fromImage( raster(getBrush(), (int) ((brush_viewer->width()-2) * size_slider->value() / 100.0), (int)((brush_viewer->height()-2) * size_slider->value() / 100.0), getHardness()) ) ); brush_viewer->setSceneRect(item->boundingRect()); }
void display() { glClear(GL_COLOR_BUFFER_BIT); raster(); glColor3f(0,1,0); glxPrintf(4,24,"%d",count); count++; glFlush(); glutSwapBuffers(); }
const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling) { if (!_direct_values.empty()) { ERR( "Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- Data vector contains outdated values..."); return _direct_values; } std::unique_ptr<GeoLib::Raster> raster( GeoLib::IO::AsciiRasterInterface::readRaster(filename)); if (!raster) { ERR( "Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- could not load raster file."); return _direct_values; } MathLib::Vector3 const dir(0.0, 0.0, -1.0); double const angle(90); std::string const prop_name("OriginalSubsurfaceNodeIDs"); std::unique_ptr<MeshLib::Mesh> surface_mesh( MeshLib::MeshSurfaceExtraction::getMeshSurface( mesh, dir, angle, prop_name)); std::vector<double> node_area_vec = MeshLib::MeshSurfaceExtraction::getSurfaceAreaForNodes(*surface_mesh); const std::vector<MeshLib::Node*> &surface_nodes(surface_mesh->getNodes()); const std::size_t nNodes(surface_mesh->getNNodes()); const double no_data(raster->getHeader().no_data); boost::optional<MeshLib::PropertyVector<int> const&> opt_node_id_pv( surface_mesh->getProperties().getPropertyVector<int>(prop_name)); if (!opt_node_id_pv) { ERR( "Need subsurface node ids, but the property \"%s\" is not " "available.", prop_name.c_str()); return _direct_values; } MeshLib::PropertyVector<int> const& node_id_pv(*opt_node_id_pv); _direct_values.reserve(nNodes); for (std::size_t i=0; i<nNodes; ++i) { double val(raster->getValueAtPoint(*surface_nodes[i])); val = (val == no_data) ? 0 : ((val*node_area_vec[i])/scaling); _direct_values.push_back(std::pair<std::size_t, double>(node_id_pv[i], val)); } return _direct_values; }
const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling) { if (!_direct_values.empty()) { ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- Data vector contains outdated values..."); return _direct_values; } std::unique_ptr<GeoLib::Raster> raster( FileIO::AsciiRasterInterface::readRaster(filename)); if (!raster) { ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- could not load raster file."); return _direct_values; } MathLib::Vector3 const dir(0.0, 0.0, -1.0); double const angle(90); std::string const prop_name("bulk_node_ids"); std::unique_ptr<MeshLib::Mesh> surface_mesh( MeshLib::MeshSurfaceExtraction::getMeshSurface( mesh, dir, angle, prop_name)); std::vector<double> node_area_vec = MeshLib::MeshSurfaceExtraction::getSurfaceAreaForNodes(*surface_mesh); const std::vector<MeshLib::Node*> &surface_nodes(surface_mesh->getNodes()); const std::size_t nNodes(surface_mesh->getNumberOfNodes()); const double no_data(raster->getHeader().no_data); MeshLib::PropertyVector<int> const* node_id_pv = nullptr; try { node_id_pv = surface_mesh->getProperties().getPropertyVector<int>( prop_name, MeshLib::MeshItemType::Node, 1); } catch (std::runtime_error const& e) { WARN("%s", e.what()); return _direct_values; } _direct_values.reserve(nNodes); for (std::size_t i = 0; i < nNodes; ++i) { double val(raster->getValueAtPoint(*surface_nodes[i])); val = (val == no_data) ? 0 : ((val * node_area_vec[i]) / scaling); _direct_values.emplace_back((*node_id_pv)[i], val); } return _direct_values; }
const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh &mesh, const std::string &filename) { if (_direct_values.empty()) { GeoLib::Raster* raster(GeoLib::Raster::getRasterFromASCFile(filename)); if (! raster) { ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration() - could not load vtk raster."); return _direct_values; } double origin_x(raster->getOrigin()[0]); double origin_y(raster->getOrigin()[1]); double delta(raster->getRasterPixelDistance()); double no_data(raster->getNoDataValue()); unsigned imgwidth(raster->getNCols()), imgheight(raster->getNRows()); double const*const img(raster->begin()); const double dir[3] = {0,0,1}; const std::vector<GeoLib::PointWithID*> surface_nodes(MeshLib::MeshSurfaceExtraction::getSurfaceNodes(mesh, dir) ); //std::vector<MeshLib::CNode*> nodes = mesh.nod_vector; const size_t nNodes(surface_nodes.size()); _direct_values.reserve(nNodes); for (size_t i=0; i<nNodes; i++) { const double* coords (surface_nodes[i]->getCoords()); if (coords[0]>=origin_x && coords[0]<(origin_x+(delta*imgwidth)) && coords[1]>=origin_y && coords[1]<(origin_y+(delta*imgheight))) { int cell_x = static_cast<int>(floor((coords[0] - origin_x)/delta)); int cell_y = static_cast<int>(floor((coords[1] - origin_y)/delta)); // if node outside of raster use raster boundary values cell_x = (cell_x < 0) ? 0 : ((cell_x > static_cast<int>(imgwidth )) ? (imgwidth-1) : cell_x); cell_y = (cell_y < 0) ? 0 : ((cell_y > static_cast<int>(imgheight)) ? (imgheight-1) : cell_y); size_t index = cell_y*imgwidth+cell_x; if (fabs(img[index] + no_data) > std::numeric_limits<float>::min()) _direct_values.push_back( std::pair<size_t, double>(surface_nodes[i]->getID(),img[index]) ); } } delete raster; } else ERR("Error in DirectConditionGenerator::directToSurfaceNodes() - Data vector contains outdated values."); return _direct_values; }
char GRASS_LIB_EXPORT *QgsGrassGisLib::G_find_cell2( const char * name, const char * mapset ) { Q_UNUSED( name ); Q_UNUSED( mapset ); QgsDebugMsg( "name = " + QString( name ) ); // G_find_cell2 is used by some modules to test if output exists (r.basins.fill) // and exits with fatal error if exists -> we must test existence here Raster rast = raster( name ); if ( !rast.provider || !rast.provider->isValid() ) { return 0; } QString ms = "qgis"; return qstrdup( ms.toAscii() ); // memory lost }
void RasterOperations::testMirrorRotate() { try { QString expr = QString("aamirvert=mirrorrotateraster(small.mpr,rotate180)"); Ilwis::ExecutionContext ctx; DOTEST(Ilwis::commandhandler()->execute(expr,&ctx), "mirror rotate mirrvert done."); Ilwis::IRasterCoverage raster("ilwis://internalcatalog/aamirvert"); raster->connectTo(QString("file:///%1/aamirvert.mpr").arg(_baseDataPath.absolutePath()), "map","ilwis3",Ilwis::IlwisObject::cmOUTPUT); raster->createTime(Ilwis::Time::now()); raster->store(); } catch(Ilwis::ErrorObject& err) { qDebug() << err.message(); QVERIFY(false); } }
void RasterOperations::testResample() { Ilwis::IGeoReference grf("code=georef:type=corners,csy=epsg:21037,envelope=-3.02456e+06 -4.55547e+06 6.47259e+06 4.39692e+06,gridsize=1188 1120,name=grf1"); QString expr = QString("aa5resbic=resample(n000302.mpr,grf1,bicubic)"); DOTEST(grf.isValid(),"making georef by code"); QString expr = QString("aa5resbic=resample(average_monthly_temperature_january_5.mpr,plate102.grf,bicubic)"); //QString expr = QString("aa5resbic=resample(small3.mpr,aeqsmall.grf,bicubic)"); Ilwis::ExecutionContext ctx; Ilwis::SymbolTable syms; DOTEST(Ilwis::commandhandler()->execute(expr,&ctx,syms), "resample done."); Ilwis::IRasterCoverage raster("ilwis://internalcatalog/aa5resbic"); raster->connectTo(QString("file:///%1/aa5ss.mpr").arg(_baseDataPath.absolutePath()), "map","ilwis3",Ilwis::IlwisObject::cmOUTPUT); raster->createTime(Ilwis::Time::now()); raster->store(); }
int QgsGrassGisLib::G_get_cellhd( const char *name, const char *mapset, struct Cell_head *cellhd ) { Q_UNUSED( mapset ); initCellHead( cellhd ); Raster rast = raster( name ); QgsRasterDataProvider *provider = rast.provider; cellhd->rows = provider->ySize(); cellhd->cols = provider->xSize(); cellhd->ew_res = provider->extent().width() / provider->xSize(); cellhd->ns_res = provider->extent().height() / provider->ySize(); cellhd->north = provider->extent().yMaximum(); cellhd->south = provider->extent().yMinimum(); cellhd->east = provider->extent().yMaximum(); cellhd->west = provider->extent().xMinimum(); return 0; }
void DrawTargetSkia::Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions) { MarkChanged(); AutoPaintSetup paint(mCanvas.get(), aOptions, aSource); SkPaint maskPaint; TempBitmap tmpBitmap; SetPaintPattern(maskPaint, aMask, tmpBitmap); SkLayerRasterizer::Builder builder; builder.addLayer(maskPaint); SkAutoTUnref<SkRasterizer> raster(builder.detachRasterizer()); paint.mPaint.setRasterizer(raster.get()); mCanvas->drawRect(SkRectCoveringWholeSurface(), paint.mPaint); }
int main () { std::string line; while (std::getline(std::cin, line)) { std::stringstream ss(line); int digit_size; ss >> digit_size; if (digit_size == 0) { return 0; } std::string digits; ss >> digits; raster(digits, digit_size); } }
void GdalDataAccess::accessingRasterData() { try { qDebug() << "Gridcoverage: access value through GDAL"; // Ilwis::IRasterCoverage raster2(makeInputPath("g250_06.tif")); // DOCOMPARE(raster2->pix2value(Ilwis::Pixel(10549,9483)), 25.0,"accessing numerical value raster map"); Ilwis::IRasterCoverage raster(makeInputPath("f41078a1.tif")); DOCOMPARE(raster->pix2value(Ilwis::Pixel(3278,2669)), 4.0,"accessing numerical value raster map"); raster.prepare(makeInputPath("GCL_INT.tif")); DOCOMPARE(raster->pix2value(Ilwis::Pixel(239,297,23)), 48.0, "accessing numerical value in stack of raster (layer 24)"); }catch (const Ilwis::ErrorObject& err) { QString error = "Test threw exception : " + err.message(); QFAIL(error.toLatin1()); } }
const std::vector<std::pair<std::size_t, double>>& DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh& mesh, const std::string& filename) { if (_direct_values.empty()) { GeoLib::Raster* raster( FileIO::AsciiRasterInterface::readRaster(filename)); if (!raster) { ERR("Error in DirectConditionGenerator::directToSurfaceNodes() - " "could not load raster file."); return _direct_values; } const MathLib::Vector3 dir(0, 0, -1); const std::vector<MeshLib::Node*> surface_nodes( MeshLib::MeshSurfaceExtraction::getSurfaceNodes(mesh, dir, 90)); const double no_data(raster->getHeader().no_data); _direct_values.reserve(surface_nodes.size()); for (auto const* surface_node : surface_nodes) { double val(raster->getValueAtPoint(*surface_node)); val = (val == no_data) ? 0 : val; _direct_values.push_back( std::make_pair(surface_node->getID(), val)); } delete raster; std::for_each(surface_nodes.begin(), surface_nodes.end(), std::default_delete<MeshLib::Node>()); } else ERR("Error in DirectConditionGenerator::directToSurfaceNodes() - Data " "vector contains outdated values."); return _direct_values; }
static void printCurrentFrame() { QPrinter printer; QPrintDialog dialog(&printer, 0); if (!dialog.exec()) return; ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); int frame = TApp::instance()->getCurrentFrame()->getFrame(); int lx = TApp::instance() ->getCurrentScene() ->getScene() ->getCurrentCamera() ->getRes() .lx; int ly = TApp::instance() ->getCurrentScene() ->getScene() ->getCurrentCamera() ->getRes() .ly; TRaster32P raster(lx, ly); if (scene->getFrameCount() <= 0) { // Ricordarsi di usare DvMsgBox !! (se si decommenta questo codice :) ) // QMessageBox::warning(0,"Print",tr("It is not possible to generate an // animation\nbecause the scene is empty.", "WARNING")); return; } raster->fill(scene->getProperties()->getBgColor()); scene->renderFrame(raster, frame, TApp::instance()->getCurrentXsheet()->getXsheet()); QImage img = rasterToQImage(raster); QPainter painter(&printer); QRect rect = painter.viewport(); QSize size = img.size(); size.scale(rect.size(), Qt::KeepAspectRatio); painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); painter.setWindow(img.rect()); painter.drawImage(0, 0, img); }