39 #include "../../common/Translator.h"
40 #include "../../common/progress/TaskProgress.h"
41 #include "../../geometry/Coord2D.h"
42 #include "../../geometry/GeometryProperty.h"
43 #include "../../geometry/Point.h"
44 #include "../../raster/Grid.h"
45 #include "../../raster/Raster.h"
46 #include "../core/AbstractGraphFactory.h"
47 #include "../core/Edge.h"
48 #include "../core/GraphMetadata.h"
49 #include "../core/Vertex.h"
50 #include "../core/VertexProperty.h"
51 #include "../graphs/Graph.h"
52 #include "../Config.h"
53 #include "../Exception.h"
79 m_graph->addVertexProperty(gProp);
88 for(std::size_t r = 1; r < m_raster->getNumberOfRows(); r++)
90 for(std::size_t c = 1; c < m_raster->getNumberOfColumns(); c++)
94 m_raster->getValue(c, r, val);
96 int value = (int) val;
101 if(getVertexId(r, c, vId) ==
false)
117 if(value == 255 || value == 0)
129 if(getVertexId(r, c + 1, vTo))
131 int edgeId = getEdgeId();
133 Edge* e =
new Edge(edgeId, vFrom, vTo);
144 if(getVertexId(r + 1, c + 1, vTo))
146 int edgeId = getEdgeId();
148 Edge* e =
new Edge(edgeId, vFrom, vTo);
159 if(getVertexId(r + 1, c, vTo))
161 int edgeId = getEdgeId();
163 Edge* e =
new Edge(edgeId, vFrom, vTo);
174 if(getVertexId(r + 1, c - 1, vTo))
176 int edgeId = getEdgeId();
178 Edge* e =
new Edge(edgeId, vFrom, vTo);
189 if(getVertexId(r, c - 1, vTo))
191 int edgeId = getEdgeId();
193 Edge* e =
new Edge(edgeId, vFrom, vTo);
204 if(getVertexId(r - 1, c - 1, vTo))
206 int edgeId = getEdgeId();
208 Edge* e =
new Edge(edgeId, vFrom, vTo);
219 if(getVertexId(r - 1, c, vTo))
221 int edgeId = getEdgeId();
223 Edge* e =
new Edge(edgeId, vFrom, vTo);
234 if(getVertexId(r - 1, c + 1, vTo))
236 int edgeId = getEdgeId();
238 Edge* e =
new Edge(edgeId, vFrom, vTo);
253 if( row < 1 || row > (
int)m_raster->getNumberOfRows() - 1)
258 if( col < 1 || row > (
int)m_raster->getNumberOfColumns() - 1)
265 id = (row * m_raster->getNumberOfColumns()) + col;
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the vertex elements.
bool getVertexId(int row, int col, int &id)
Function used to generated the vertex id based on raster coordenate.
void setMessage(const std::string &message)
Set the task message.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
void useTimer(bool flag)
Used to define if task use progress timer information.
virtual ~LDDGraphBuilder()
Virtual destructor.
This class can be used to inform the progress of a task.
An utility struct for representing 2D coordinates.
#define TE_TR(message)
It marks a string in order to get translated.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
void setTotalSteps(int value)
Set the task total stepes.
void setId(unsigned int id)
It sets the property identifier.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
int getSRID() const
It returns the spatial reference system identifier associated to this property.
A point with x and y coordinate values.
An abstract class for raster data strucutures.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
int getSRID() const
Returns the raster spatial reference system identifier.
LDDGraphBuilder()
Default constructor.
bool build(te::rst::Raster *raster, const std::map< std::string, std::string > &dsInfo, const std::string &graphType, const std::map< std::string, std::string > &gInfo)
Function used to build the output graph based on input parameters.
This class defines the LDD strategy to build a graph.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
static AbstractGraph * make()
It creates and returns an empty graph with default graph type.
This abstract class provides the common functions for graph builder classes. Each builder strategy ha...
int getEdgeId()
Function used to generated the edge id.