1 #ifndef JUGIMAP_VECTOR_SHAPES_H
2 #define JUGIMAP_VECTOR_SHAPES_H
6 #include "jmCommonFunctions.h"
14 class JugiMapBinaryLoader;
19 struct TShapePoint :
public Vec2f
23 bool smoothCorner =
false;
25 TShapePoint():
Vec2f(){}
27 TShapePoint(
Vec2f _p,
float _distance) :
Vec2f(_p), distance(_distance) {}
28 TShapePoint(
Vec2f _p,
float _distance,
bool _smoothCorner) :
Vec2f(_p), distance(_distance), smoothCorner(_smoothCorner){}
79 std::vector<TShapePoint>&
GetPath(){
return path; }
114 std::vector<TShapePoint>path;
115 float pathLength = 0.0f;
127 std::vector<Vec2f>vertices;
129 bool rectangle =
false;
130 Vec2f boundingBoxMin;
131 Vec2f boundingBoxMax;
135 bool IsValid()
override {
return !vertices.empty(); }
138 void UpdateBoundingBox();
148 BezierVertex(
Vec2f _P,
Vec2f _BPprevious,
Vec2f _BPnext) :
P(_P),CPprevious(_BPprevious),CPnext(_BPnext){}
156 std::vector<BezierVertex>vertices;
157 float toPolyThreshold = 1.0f;
160 bool IsValid()
override {
return !vertices.empty(); }
165 void _GetShapePointsFromBezierSegment(std::vector<TShapePoint> &path,
Vec2f BP1,
Vec2f BP2,
Vec2f BP3,
Vec2f BP4,
int i);
219 VectorShape(
bool _extra,
int _dataFlags,
const std::vector<jugimap::Parameter> &_parameters) : extra(_extra), dataFlags(_dataFlags), parameters(_parameters){}
234 std::string GetName(){
return name; }
276 std::vector<TShapePoint>& GetPath(){
return shape->
GetPath(); }
293 std::vector<jugimap::Parameter> parameters;
294 float pathLength = 0.0;
302 #endif // VECTORSHAPE_H
~VectorShape()
Destructor.
Definition: jmVectorShapes.h:231
VectorShape()
Base constructor.
Definition: jmVectorShapes.h:213
ShapeKind GetKind()
Returns the kind of this shape.
Definition: jmVectorShapes.h:246
Bezier polycurve - BezierShape object.
The single point shape.
Definition: jmVectorShapes.h:187
void RebuildPath() override
Rebuild the path from the current shape geometry.
Definition: jmVectorShapes.cpp:288
bool IsValid() override
Returns true if this shape is a valid geometric object; otherwise returns false.
Definition: jmVectorShapes.h:192
GeometricShape * GetGeometricShape()
Returns the geometric shape of this vector shape.
Definition: jmVectorShapes.h:238
std::vector< TShapePoint > & GetPath()
Returns a reference to the path vector of this geometric shape.
Definition: jmVectorShapes.h:79
The ellipse shape.
Definition: jmVectorShapes.h:172
bool IsValid() override
Returns true if this shape is a valid geometric object; otherwise returns false.
Definition: jmVectorShapes.h:180
Polyline - PolyLineShape object.
The polyline shape. Defines also a rectangle shape.
Definition: jmVectorShapes.h:124
void SetGeometricShape(GeometricShape *_geomShape)
Set the geometric shape of this vector shape to *_geomShape*.
Definition: jmVectorShapes.h:242
ShapeKind GetKind()
Returns the kind of this shape.
Definition: jmVectorShapes.h:57
Vec2f GetPathPoint(float r)
Returns a point along the path at the given parametric position r.
Definition: jmVectorShapes.h:269
Ellipse - EllipseShape object.
static GeometricShape * Copy(GeometricShape *_geomShape)
Create a new geometric object which is a copy of the given *_geomShape*.
Definition: jmVectorShapes.cpp:43
virtual void RebuildPath()=0
Rebuild the path from the current shape geometry.
bool IsValid() override
Returns true if this shape is a valid geometric object; otherwise returns false.
Definition: jmVectorShapes.h:135
The shape kind not defined.
VectorShape(GeometricShape *_geomShape)
Create a vector shape with the given *_geomShape*.
Definition: jmVectorShapes.h:223
bool IsValid()
Returns true if this vector shape has a geometric object which is valid; otherwise returns false.
Definition: jmVectorShapes.h:280
bool IsValid() override
Returns true if this shape is a valid geometric object; otherwise returns false.
Definition: jmVectorShapes.h:160
The GeometricShape is the base class for geometric shapes.
Definition: jmVectorShapes.h:38
std::vector< jugimap::Parameter > & GetParameters()
Returns a reference to the vector of data parameters in this vector shape.
Definition: jmVectorShapes.h:258
void RebuildPath() override
Rebuild the path from the current shape geometry.
Definition: jmVectorShapes.cpp:593
void RebuildPath() override
Rebuild the path from the current shape geometry.
Definition: jmVectorShapes.cpp:415
Vec2f GetPathPoint(float p, float &directionAngle) override
Returns a point along the path at the given parametric position p.
Definition: jmVectorShapes.h:197
int GetDataFlags()
Returns the data flags of this vector shape.
Definition: jmVectorShapes.h:254
void RebuildPath() override
Rebuild the path from the current shape geometry.
Definition: jmVectorShapes.cpp:537
Vec2f GetPathPoint(float r, float &directionAngle)
Returns a point along the path at the given parametric position r.
Definition: jmVectorShapes.h:273
Vec2< float > Vec2f
Vec2 struct in float precision.
Definition: jmCommon.h:167
ShapeKind
The kinds of geometric shape. Used as identifier for GeometricShape and VectorShape objects.
Definition: jmGlobal.h:133
virtual Vec2f GetPathPoint(float p)
Returns a point along the path at the given parametric position p.
Definition: jmVectorShapes.cpp:105
void _SetClosed(bool _closed)
Set the closed parameter when you create a geometric shape by hand. Do not change it for existing sha...
Definition: jmVectorShapes.h:73
bool IsClosed()
Returns true if this vector shape has a geometric object which is closed; otherwise returns false.
Definition: jmVectorShapes.h:284
float GetPathLength()
Returns the length of the path.
Definition: jmVectorShapes.h:91
float GetPathLength()
Returns the length of this vector shape.
Definition: jmVectorShapes.h:265
Single point - SinglePointShape object.
2d vector.
Definition: jmCommon.h:23
virtual bool IsValid()=0
Returns true if this shape is a valid geometric object; otherwise returns false.
The bezier shape.
Definition: jmVectorShapes.h:154
The VectorShape class defines the vector shape from JugiMap Editor.
Definition: jmVectorShapes.h:206
VectorShape(bool _extra, int _dataFlags, const std::vector< jugimap::Parameter > &_parameters)
Create a vector shape with the given data parameters *_probe*, *_dataFlags* and *_parameters*.
Definition: jmVectorShapes.h:219
The JugiMapBinaryLoader class loads data from jugimap binary files (.jmb).
Definition: jmMapBinaryLoader.h:37
bool IsClosed()
Returns true if this shape is a closed geometric object; otherwise returns false.
Definition: jmVectorShapes.h:69
Vec2f GetPathPoint(float p) override
Returns a point along the path at the given parametric position p.
Definition: jmVectorShapes.h:196
static void Assign(GeometricShape *sSrc, GeometricShape *sDst)
Assign the content of the given sSrc to the sDst.
Definition: jmVectorShapes.cpp:74