#include "onf_stepvectorizeconductivitymap.h" ONF_StepVectorizeConductivityMap::ONF_StepVectorizeConductivityMap() : SuperClass() { } QString ONF_StepVectorizeConductivityMap::description() const { return tr("Vectoriser une carte de conductivité"); } QString ONF_StepVectorizeConductivityMap::detailledDescription() const { return tr(""); } QString ONF_StepVectorizeConductivityMap::inputDescription() const { return SuperClass::inputDescription() + tr("

"); } QString ONF_StepVectorizeConductivityMap::outputDescription() const { return SuperClass::outputDescription() + tr("

"); } QString ONF_StepVectorizeConductivityMap::detailsDescription() const { return tr("https://github.com/Jean-Romain/vecnet"); } QString ONF_StepVectorizeConductivityMap::URL() const { //return tr("STEP URL HERE"); return SuperClass::URL(); //by default URL of the plugin } CT_VirtualAbstractStep* ONF_StepVectorizeConductivityMap::createNewInstance() const { return new ONF_StepVectorizeConductivityMap(); } //////////////////// PROTECTED METHODS ////////////////// void ONF_StepVectorizeConductivityMap::declareInputModels(CT_StepInModelStructureManager& manager) { manager.addResult(_inResult, tr("Carte de conductivité")); manager.setZeroOrMoreRootGroup(_inResult, _inZeroOrMoreRootGroup); manager.addGroup(_inZeroOrMoreRootGroup, _inGroup); manager.addItem(_inGroup, _inConductivityMap, tr("Carte de conductivité")); } void ONF_StepVectorizeConductivityMap::fillPostInputConfigurationDialog(CT_StepConfigurableDialog* postInputConfigDialog) { //postInputConfigDialog->addString(tr("Nom à donner au raster (pentes en pourcents)"), "", _namePourc); } void ONF_StepVectorizeConductivityMap::declareOutputModels(CT_StepOutModelStructureManager& manager) { manager.addResultCopy(_inResult); manager.addItem(_inGroup, _outRaster, tr("Raster")); } void ONF_StepVectorizeConductivityMap::compute() { for (CT_StandardItemGroup* grp : _inGroup.iterateOutputs(_inResult)) { for (const CT_Image2D* conductivity : grp->singularItems(_inConductivityMap)) { if (isStopped()) {return;} CT_Image2D* slope = new CT_Image2D(conductivity->minX(), conductivity->minY(), conductivity->xdim(), conductivity->ydim(), conductivity->resolution(), conductivity->level(), conductivity->NA(), conductivity->NA()); grp->addSingularItem(_outRaster, slope); slope->computeMinMax(); } } } //void ONF_StepVectorizeConductivityMap::track_line(const QList& seed, const CT_Image2D* map, const QList& network, float fov, float sightline, float min_conductivity, float th_conductivity) //{ // // Defensive programming // if (methods::is(seed, "sf")) seed = sf::st_geometry(seed); // if (!methods::is(seed, "sfc_LINESTRING")) stop("seed must be sfc_LINESTRING"); // if (length(seed) != 1L) stop("seed must be of length 1"); // if (!methods::is(map, "SpatRaster")) stop("map must be a SpatRaster"); // if (!is.null(network)) network = sf::st_geometry(network); // resolution <- terra::res(map); // if (resolution[1] != resolution[2]) stop("'map' raster must have the same resolution in both X and Y axis.", call. = false); // resolution <- resolution[1]; // t0 <- Sys.time(); // // We are working with large rasters not loaded in memory. We must load in memory some small parts // // iteratively wile driving. This object handle the logic of querying subsets in a larger map // mapper <- MapManager$new(map, th_conductivity = th_conductivity, smooth = true); // mapper$set_search_seed_mode(list(...)$seed_mode); // mapper$query_aoi(seed); // mapper$mask_network(network); // // This object handles the logic of least cost based driving // driver = DrivingAgent$new(sightline = sightline, fov = fov, resolution = resolution, min_conductivity = min_conductivity); // driver$set_seed(seed); // // Loop while the driver can move forward // while (!driver$reached_end()) // { // driver$print_speed(t0); // driver$query_sightview(mapper$aoi); // if (driver$is_on_edge()) // { // // If the driving agent is on the edge of the loaded aoi we must load a new aoi ahead // mapper$query_aoi(driver$get_seed()); // mapper$mask_network(network); // mapper$mask_trace(driver$get_trace()); // driver$query_sightview(mapper$aoi); // // If the driving agent is still on the edge of the loaded aoi it means that we are really on // // the edge of the full raster. Divide the sightline to reach the edge doing smaller steps // if (driver$is_on_edge()) // driver$divide_sightline(); // if (driver$is_on_edge()) // driver$divide_sightline(); // if (driver$is_on_edge()) // break; // } // // We are not on an edge we can compute the costs // driver$compute_cost(); // // If there is no path it means no point was reachable // if (!driver$has_path()) // { // break; // } // if (debug) // driver$plot(); // // We reached another road from the existing network // if (driver$has_reached_a_road()) // { // driver$network_connection(network); // break; // } // // Leave a trace of already seen roads and protect against infinite loops // mapper$mask_trace(driver$get_seed()); // if (driver$has_new_intersections()) // mapper$mask_trace(driver$get_intersections()); // driver$move(); // } // driver$print_speed(t0, done = true); // return driver$get_road(); //}