13 namespace datastructure {
35 setShapeType(
"polyline");
69 if ((x > -INFINITY) && (x < INFINITY) &&
70 (y > -INFINITY) && (y < INFINITY)) {
75 throw "Invalid points for polyline!";
93 setShapeType(
"polyline");
103 for (
int k = 0; k < points.size(); k += 2) {
119 float transl[] = {-center[0], -center[1]};
120 translate (transl[0], transl[1]);
122 for (
int k = 0; k < points.size(); k += 2) {
123 float tmp[] = { points[k], points[k + 1] };
124 rotatePoint (tmp, angle);
126 points[k + 1] = tmp[1];
129 transl[0] = center[0];
130 transl[1] = center[1];
131 translate (transl[0], transl[1]);
144 float transl[] = {-center[0], -center[1]};
145 translate (transl[0], transl[1]);
147 for (
int k = 0; k < points.size(); k += 2) {
152 transl[0] = center[0];
153 transl[1] = center[1];
154 translate(transl[0], transl[1]);
163 bbox[0] = bbox[1] = INFINITY;
164 bbox[2] = bbox[3] = -INFINITY;
165 for (
int k = 0; k < points.size(); k += 2) {
166 if (points[k] < bbox[0])
168 if (points[k] > bbox[2])
170 if (points[k + 1] < bbox[1])
171 bbox[1] = points[k + 1];
172 if (points[k + 1] > bbox[3])
173 bbox[3] = points[k + 1];
175 center[0] = bbox[0] + (bbox[2] - bbox[0]) / 2.;
176 center[1] = bbox[1] + (bbox[3] - bbox[1]) / 2.;
187 vector<float> dims(4);
188 dims[0] = dims[2] = INFINITY;
189 dims[1] = dims[3] = -INFINITY;
191 for (std::size_t i = 0, size = points.size();
194 y = points.at(i + 1);
214 string shape_json = getSymbolAttributeRepresentation();
215 string shape = getShapeType();
223 vector<float>::iterator it;
224 for (
int k = 0; k < points.size(); k++) {
225 shape_json += to_string(points[k]) +
COMMA;
230 shape_json.erase(shape_json.size() - 1);
void scale(float sx, float sy)
Scale the polyline about its center.
Definition: Polyline.h:139
const string getSymbolRepresentation() const
This method returns the JSON representation of the shape.
Definition: Polyline.h:212
Polyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:42
vector< float > getDimensions() const
This method returns the dimensions of the shape: min and max values in X and Y.
Definition: Polyline.h:185
string getDataStructType()
Get the name of the data type.
Definition: Polyline.h:50
const string COLON
Definition: DataStructure.h:51
const string OPEN_BOX
Definition: DataStructure.h:54
const string CLOSE_CURLY
Definition: DataStructure.h:53
This class defines a polyline and is part of the symbol collection. A polyline has a set of vertices ...
Definition: Polyline.h:24
void rotate(float angle)
rotate the polyline about its center
Definition: Polyline.h:114
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:33
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
void getCenter(float *center)
Get center of polyline - use its bounding box.
Definition: Polyline.h:161
const string CLOSE_BOX
Definition: DataStructure.h:55
void setPolyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:91
void addPoint(float x, float y)
This method adds a point to the polyline.
Definition: Polyline.h:68
vector< float > getPoints()
This method returns the point list of the polyline.
Definition: Polyline.h:83
Polyline()
default constructor
Definition: Polyline.h:33
string getName() const
This method gets the name of the shape.
Definition: Polyline.h:59
vector< float > points
Definition: Polyline.h:27
const string COMMA
Definition: DataStructure.h:50
const string QUOTE
Definition: DataStructure.h:49
void translate(float tx, float ty)
Translate the polyline.
Definition: Polyline.h:101