Migration guide to version 2.0
F2C v2 has some breaking changes, which requires a little modifications to our code using F2C v1. Fortunately, this guide shows those changes so we can start using v2 as soon as possible.
New classes and new functionalities
To be able to add new functionalities to the library, some classes are added:
f2c::types::Graphandf2c::types::Graph2Dimplement simple logic for graphsf2c::types::Routeon version 2 has a new logic.f2c::types::SwathsByCellsis a class now, instead of just an alias tostd::vector<Swaths>.f2c::rp::RoutePlannerBaseclass does the route planning without given known patterns.f2c::decomp::DecompositionBase,f2c::decomp::TrapezoidalDecompandf2c::decomp::BoustrophedonDecompprovides functions to do cell decomposition.f2c::pp::PathPlanningis able to connectf2c::types::Routesmoothly, providing proper coverage paths for any kind of fields.f2c::obj::NSwathModifiedis a new objective function. It’s an approximation tof2c::obj::NSwath, being able to compute faster the number of swaths.
Renaming functions
On v1, functions inherited from GDAL maintained the same name as in GDAL. Due to that, many functions didn’t have a name following camel case convention. Here it is a list with a few examples:
f2c::types::Geometry::Distance->f2c::types::Geometry::distancef2c::types::Geometry::Difference->f2c::types::Geometry::differencef2c::types::Geometry::Within->f2c::types::Geometry::withinf2c::types::Geometry::Union->f2c::types::Geometry::unionf2c::types::Swath::StartPoint->f2c::types::Swath::startPointf2c::types::Swath::EndPoint->f2c::types::Swath::endPoint
Other functions had names that could be improved:
f2c::types::Geometry::getArea()->f2c::types::Geometry::area()f2c::types::Geometry::getLength()->f2c::types::Geometry::length()f2c::types::Point::getSemiLongCurve()->f2c::types::Point::createSemiLongLine()f2c::pp::PathPlanning::searchBestPath->f2c::pp::PathPlanning::planPath
Warning
The input parameters in function f2c::Random::generateRandField(int n_sides, double area) has been reorder to f2c::Random::generateRandField(double area, int n_sides).
This change is made for keeping coherence with other similar functions, but can make our program crash if we are not careful.
Renaming files
This section is only refered to objective functions. Previously, they were mixed in the same folder, independently of the module they belong to.
Now, they are sorted by subfolders.
For example, file fields2cover/objectives/n_swath.h is moved to fields2cover/objectives/sg_obj/n_swath.h
Class attributes are private now
On v1, you can access any attribute of any class because everything was public. Following good practices, access to attributes is done by getters and setters now, and all the attributes are private:
f2c::types::Robotwidth->getWidth()/setWidth()op_width->getCovWidth()/setCovWidth()cruise_speed->getCruiseVel()/setCruiseVel()max_icc->getMaxCurv()/setMaxCurv()linear_curv_change->getMaxDiffCurv()/setMaxDiffCurv()
f2c::types::Swathid->getId()/setId()path->getPath()/setPath()width->getWidth()/setWidth()
f2c::types::Pathstates->getState()/setState(),getStates()/setStates()task_time->getTaskTime()
f2c::types::Fieldid->getId()/setId()coord_sys->getCRS()/setCRS()field->getField()/setField()ref_point->getRefPoint()/setRefPoint()
Visualizer
The library used for plotting has been changed from lava/matplotlib-cpp to alandefreitas/matplotplusplus. This means that the resulting plots will be different.
The main changes on the user side are:
f2c::Visualizer::figure()does not accept arguments.f2c::Visualizer::save(std::string)requires the extension of the file on the name i.e. .png.