13 namespace datastructure {
33 setShapeType(
"polyline");
67 if ((x > -INFINITY) && (x < INFINITY) &&
68 (y > -INFINITY) && (y < INFINITY)) {
73 throw "Invalid points for polyline!";
87 setShapeType(
"polyline");
97 for (
int k = 0; k < points.size(); k += 2) {
113 float transl[] = {-center[0], -center[1]};
114 translate (transl[0], transl[1]);
116 for (
int k = 0; k < points.size(); k += 2) {
117 float tmp[] = { points[k], points[k + 1] };
118 rotatePoint (tmp, angle);
120 points[k + 1] = tmp[1];
123 transl[0] = center[0];
124 transl[1] = center[1];
125 translate (transl[0], transl[1]);
138 float transl[] = {-center[0], -center[1]};
139 translate (transl[0], transl[1]);
141 for (
int k = 0; k < points.size(); k += 2) {
146 transl[0] = center[0];
147 transl[1] = center[1];
148 translate(transl[0], transl[1]);
156 bbox[0] = bbox[1] = INFINITY;
157 bbox[2] = bbox[3] = -INFINITY;
158 for (
int k = 0; k < points.size(); k += 2) {
159 if (points[k] < bbox[0])
161 if (points[k] > bbox[2])
163 if (points[k + 1] < bbox[1])
164 bbox[1] = points[k + 1];
165 if (points[k + 1] > bbox[3])
166 bbox[3] = points[k + 1];
168 center[0] = bbox[0] + (bbox[2] - bbox[0]) / 2.;
169 center[1] = bbox[1] + (bbox[3] - bbox[1]) / 2.;
180 vector<float> dims(4);
181 dims[0] = dims[2] = INFINITY;
182 dims[1] = dims[3] = -INFINITY;
184 for (std::size_t i = 0, size = points.size();
187 y = points.at(i + 1);
207 string shape_json = getSymbolAttributeRepresentation();
208 string shape = getShapeType();
216 vector<float>::iterator it;
217 for (
int k = 0; k < points.size(); k++) {
218 shape_json += to_string(points[k]) +
COMMA;
223 shape_json.erase(shape_json.size() - 1);
void scale(float sx, float sy)
Scale the polyline about its center.
Definition: Polyline.h:133
const string getSymbolRepresentation() const
Definition: Polyline.h:205
Polyline(vector< float > pts)
Definition: Polyline.h:40
vector< float > getDimensions() const
Definition: Polyline.h:178
string getDataStructType()
Definition: Polyline.h:48
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 l *
Definition: Polyline.h:108
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:32
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)
Definition: Polyline.h:154
const string CLOSE_BOX
Definition: DataStructure.h:55
void setPolyline(vector< float > pts)
Definition: Polyline.h:85
void addPoint(float x, float y)
Definition: Polyline.h:66
vector< float > getPoints()
Definition: Polyline.h:81
Polyline()
Definition: Polyline.h:31
string getName() const
Definition: Polyline.h:57
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:95