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"
80 m_graph->addVertexProperty(gProp);
89 for(std::size_t r = 1; r < m_raster->getNumberOfRows(); r++)
91 for(std::size_t c = 1; c < m_raster->getNumberOfColumns(); c++)
95 m_raster->getValue(c, r, val);
97 int value = (int) val;
102 if(getVertexId(r, c, vId) ==
false)
118 if(value == 255 || value == 0)
130 if(getVertexId(r, c + 1, vTo))
132 int edgeId = getEdgeId();
134 Edge* e =
new Edge(edgeId, vFrom, vTo);
145 if(getVertexId(r + 1, c + 1, vTo))
147 int edgeId = getEdgeId();
149 Edge* e =
new Edge(edgeId, vFrom, vTo);
160 if(getVertexId(r + 1, c, vTo))
162 int edgeId = getEdgeId();
164 Edge* e =
new Edge(edgeId, vFrom, vTo);
175 if(getVertexId(r + 1, c - 1, vTo))
177 int edgeId = getEdgeId();
179 Edge* e =
new Edge(edgeId, vFrom, vTo);
190 if(getVertexId(r, c - 1, vTo))
192 int edgeId = getEdgeId();
194 Edge* e =
new Edge(edgeId, vFrom, vTo);
205 if(getVertexId(r - 1, c - 1, vTo))
207 int edgeId = getEdgeId();
209 Edge* e =
new Edge(edgeId, vFrom, vTo);
220 if(getVertexId(r - 1, c, vTo))
222 int edgeId = getEdgeId();
224 Edge* e =
new Edge(edgeId, vFrom, vTo);
235 if(getVertexId(r - 1, c + 1, vTo))
237 int edgeId = getEdgeId();
239 Edge* e =
new Edge(edgeId, vFrom, vTo);
254 if( row < 1 || row > (
int)m_raster->getNumberOfRows() - 1)
259 if( col < 1 || row > (
int)m_raster->getNumberOfColumns() - 1)
266 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 m_edgeId
Attribute used as a index counter for edge objects.
int getEdgeId()
Function used to generated the edge id.