1 //Copyright (c) 2018 Ultimaker B.V.
2 //CuraEngine is released under the terms of the AGPLv3 or higher.
3 
4 #ifndef WEAVE_DATA_STORAGE_H
5 #define WEAVE_DATA_STORAGE_H
6 
7 #include "utils/NoCopy.h"
8 #include "utils/IntPoint.h"
9 #include "utils/polygon.h"
10 #include "mesh.h"
11 #include "LayerPlan.h"
12 #include "MeshGroup.h"
13 
14 
15 namespace cura {
16 
17 
18 enum class WeaveSegmentType
19 {
20     UP,
21     DOWN,
22     FLAT,
23     MOVE,
24     DOWN_AND_FLAT // DOWN_AND_FLAT is for parts of the roof which can either be viewed as flat or as down, since their [to] location is an up move with zero length
25 };
26 
27 
28 struct WeaveConnectionSegment
29 {
30     Point3 to;
31     WeaveSegmentType segmentType;
WeaveConnectionSegmentWeaveConnectionSegment32     WeaveConnectionSegment(Point3 to, WeaveSegmentType dir) : to(to), segmentType(dir) {};
33 };
34 
35 struct PolyLine3
36 {
37     Point3 from;
38     std::vector<WeaveConnectionSegment> segments;
39 };
40 
41 struct WeaveConnectionPart
42 {
43     PolyLine3 connection;
44     int supported_index;//!< index of corresponding supported polygon in WeaveConnection.supported (! last point in polygon is first point to start printing it!)
WeaveConnectionPartWeaveConnectionPart45     WeaveConnectionPart(int top_idx) : supported_index(top_idx) {};
46 };
47 
48 struct WeaveConnection
49 {
50     int z0;//!< height of the supporting polygons (of the prev layer, roof inset, etc.)
51     int z1;//!< height of the \p supported polygons
52     std::vector<WeaveConnectionPart> connections; //!< for each polygon in \p supported the connection.
53     Polygons supported; //!< polygons to be supported by connections (from other polygons)
54 };
55 
56 // Horizontal Fills:
57 
58 typedef std::vector<WeaveConnectionSegment> WeaveInsetPart; //!< Polygon with extra information on each point
59 struct WeaveRoofPart : WeaveConnection
60 {
61     // [supported] is an insets of the roof polygons (or of previous insets of it)
62     // [connections] are the connections between two consecutive roof polygon insets
63     std::vector<WeaveInsetPart> supported_withMoves; //!< optimized inset polygons, with some parts of the polygons replaced by moves
64 };
65 
66 struct WeaveRoof
67 {
68     std::vector<WeaveRoofPart> roof_insets; //!< connections between consecutive insets of the roof polygons
69     Polygons roof_outlines; //!< the area within which the horitonal connections are generated
70 };
71 
72 // Layers
73 
74 struct WeaveLayer : WeaveConnection
75 {
76     // [supported] are the outline polygons on the next layer which are (to be) connected,
77     //             as well as the polygons supported by roofs (holes and boundaries of roofs)
78     // [connections] are the vertical connections
79     WeaveRoof roofs; //!< parts which are filled horizontally (both roofs and floors...)
80 };
81 struct WireFrame : public NoCopy
82 {
83     MeshGroup* meshgroup;
84     WeaveRoof bottom_infill;
85     Polygons bottom_outline;
86     int z_bottom;
87     std::vector<WeaveLayer> layers;
88 };
89 
90 
91 }//namespace cura
92 
93 #endif//WEAVE_DATA_STORAGE_H
94