openEmbroider  0.1
an open source embroidery software
OE_stitchs.h
1 /*
2  * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  *
20  */
21 
22 #ifndef OE_STITCHS_H
23 #define OE_STITCHS_H
24 
25 #include "OE_base.h"
26 #include "OE_utils.h"
27 #include "OE_thread.h"
28 #include <stdint.h>
29 #include <vector>
30 
31 class OE_stitchs : public OE_base
32 {
33  public:
35  OE_stitchs();
37  virtual ~OE_stitchs();
38 
39  //virtual bool getNeedRefresh();
40  //virtual bool setNeedRefresh(bool value);
41 
43  bool getPoint(uint16_t nb, float* x, float* y);
44  bool getPoint(uint16_t nb, vector_2d* pt);
45 
47  std::vector<vector_2d> getPoints();
48 
50  int getNpts();
51 
53  OE_thread * getThread();
54 
56  bool setPoint(uint16_t nb, float x, float y);
57 
59  bool setThread(OE_thread * thread);
60 
62  bool addPoint( float x, float y);
63  bool addPoint( vector_2d pt);
64 
66  bool setMaxLen(float maxLen);
67 
69  std::vector<vector_2d> stitchMaxLen(std::vector<vector_2d> ptsArray, float maxlen);
70 
74  virtual void getBound(float* xMin, float* yMin, float* xMax, float* yMax);
75 
77  virtual bool check();
78 
79 
80  virtual void refresh();
81 
82  static float defaultMaxlen;
83 
84  protected:
85 
87  //float bounds[4];
88 
90  OE_thread * thread = nullptr;
91 
93  std::vector<vector_2d> pts;
94 
95  float maxLen = 0;
96 
102  //static bool ptInBounds( vector_2d pt, float* bounds);
103  private:
104 
105 };
106 
107 #endif // OE_STITCHS_H
std::vector< vector_2d > getPoints()
return a copy of the array of points
Definition: OE_stitchs.cpp:65
int getNpts()
return the number of points in the stitch (control points, without handles)
Definition: OE_stitchs.cpp:72
bool setThread(OE_thread *thread)
to set the thread.
Definition: OE_stitchs.cpp:87
OE_stitchs()
Definition: OE_stitchs.cpp:32
Definition: OE_thread.h:26
OE_thread * thread
Tight bounding box of the shape [minx,miny,maxx,maxy].
Definition: OE_stitchs.h:90
Definition: OE_base.h:30
bool setMaxLen(float maxLen)
set the max len of a segment
Definition: OE_stitchs.cpp:106
Definition: OE_stitchs.h:31
std::vector< vector_2d > pts
the array of stitch points
Definition: OE_stitchs.h:93
OE_thread * getThread()
to get the thread.
Definition: OE_stitchs.cpp:74
std::vector< vector_2d > stitchMaxLen(std::vector< vector_2d > ptsArray, float maxlen)
return an array of point splited to respect the maxLen distance
Definition: OE_stitchs.cpp:143
virtual void getBound(float *xMin, float *yMin, float *xMax, float *yMax)
calculate the curve bounding box
Definition: OE_stitchs.cpp:116
bool addPoint(float x, float y)
to add a point at the end of the stitch.
Definition: OE_stitchs.cpp:94
bool getPoint(uint16_t nb, float *x, float *y)
to get a point in the stitch.
Definition: OE_stitchs.cpp:44
Definition: OE_utils.h:28
virtual bool check()
check if the stitch is valid.
Definition: OE_stitchs.cpp:139
virtual ~OE_stitchs()
Definition: OE_stitchs.cpp:36
bool setPoint(uint16_t nb, float x, float y)
to set a point in the stitch.
Definition: OE_stitchs.cpp:76