SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
LoopInput.hpp
1 //
2 // LoopInput.hpp
3 //
4 // Sketchup C++ Wrapper for C API
5 // MIT License
6 //
7 // Copyright (c) 2017 Tom Kaneko
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 
16 // The above copyright notice and this permission notice shall be included in all
17 // copies or substantial portions of the Software.
18 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 // SOFTWARE.
26 //
27 
28 #ifndef LoopInput_hpp
29 #define LoopInput_hpp
30 
31 #include <stdio.h>
32 #include <vector>
33 
34 #include <SketchUpAPI/model/geometry_input.h>
35 
36 #include "SUAPI-CppWrapper/model/Material.hpp"
37 #include "SUAPI-CppWrapper/model/Layer.hpp"
38 
39 namespace CW {
40 // Forward declarations
41 class GeometryInput;
42 class Edge;
43 class Curve;
44 class Material;
45 class Layer;
46 class Vertex;
47 
48 /**
49 * Struct holds information for an edge that was added to a vertex.
50 */
52  bool hidden = false;
53  bool soft = false;
54  bool smooth = false;
55  Material material = Material();
56  Layer layer = Layer();
57 };
58 
59 class LoopInput {
60  friend class Face;
61  friend class GeometryInput;
62 
63  private:
64  SULoopInputRef m_loop_input;
65  size_t m_edge_num = 0;
66  bool m_attached;
67 
68  /** Array holds information about the added edges of the vertex. This is to allow the copying of this object.
69  std::vector<std::pair<size_t, InputEdgeProperties>> m_edge_properties;
70  */
71 
72  //std::vector<Edge> m_edges;
73  //std::vector<Curve> m_curves;
74 
75  static SULoopInputRef create_loop_input_ref();
76 
77  public:
78  /**
79  * Create empty LoopInput object
80  */
81  LoopInput();
82 
83  /**
84  * Create LoopInput object from preexisting SULoopInputRef object
85  */
86  LoopInput(SULoopInputRef loop_input, bool attached = false);
87 
88  /**
89  * Create LoopInput object from vector of edges that can form a loop.
90  * @param loop_edges - vector of edges from which properties will be copied into the new loop input.
91  * @param vertex_index - 0 by default. This is the first index of the vertex to be added to the loop. Only when using SUGeometryInputRef object would you use an index higher than 0.
92  */
93  //LoopInput(std::vector<Edge> loop_edges, size_t vertex_index = 0);
94 
95  /**
96  * Create LoopInput object from vector of edge properties that can form a loop.
97  * @param loop_edge_properties - vector of InputEdgeProperties from which edge properties will be copied to the new loop input.
98  * @param vertex_index - 0 by default. This is the first index of the vertex to be added to the loop. Only when using SUGeometryInputRef object would you use an index higher than 0.
99  */
100  LoopInput(const std::vector<InputEdgeProperties>& loop_edge_properties, size_t vertex_index = 0);
101 
102  /** Copy constructor */
103  LoopInput(const LoopInput& other);
104 
105  ~LoopInput();
106 
107  /** Copy assignment operator **/
108  LoopInput& operator=(const LoopInput& other);
109 
110  /*
111  * Returns the stored SULoopInputRef object.
112  */
113  SULoopInputRef ref() const;
114 
115  /*
116  * The class object can be converted to a SULoopInputRef without loss of data.
117  */
118  operator SULoopInputRef() const;
119  operator SULoopInputRef*();
120 
121  /**
122  * Indicates whether a LoopInput is valid, or empty.
123  * @return true if valid and has three or more vertices (the minimum for a loop). Returns false if invalid or has two or less vertices.
124  */
125  operator bool() const;
126 
127  /**
128  * Adds a vertex index to the loop. LoopInput does not hold the point locations of vertices. It holds information on the edges that form the loop.
129  * @param index - the vertex index of the loop. When used with SUCreateFace(), it would be a zero-based index. When used with SUGeometryInputAddFace(), the vertex index would need to correspond to specific indices of the vertices that have been added to SUGeometryInputRef object.
130  */
131  LoopInput& add_vertex_index(const size_t index);
132 
133  LoopInput& set_edge_hidden(const size_t edge_index, const bool hidden);
134  LoopInput& set_edge_soft(const size_t edge_index, const bool soft);
135  LoopInput& set_edge_smooth(const size_t edge_index, const bool smooth);
136  LoopInput& set_edge_material(const size_t edge_index, const Material& material);
137  LoopInput& set_edge_layer(const size_t edge_index, const Layer& layer);
138 
139 
140 
141  /**
142  * Creates a LoopInput object, which will store the properties of the sequence of Edge objects.
143  */
144  //LoopInput(std::vector<Edge> edges);
145 
146  /*
147  * Creates a Loop object which is used as a LoopInputRef object (i.e. it is not attached to a Face yet)
148  * @param vector of SUPoint3D objects, tracing the outline of the loop.
149  */
150  /*
151  * Returns the stored m_edges array.
152  */
153  //std::vector<Edge> get_edges();
154 
155  /*
156  * Returns an array of vertices that represent the loop.
157  */
158  //std::vector<Point3D> get_vertices();
159 
160  /*
161  * Adds the loop to the given
162  */
163  // TODO: det
164  //SUResult add_to_geometry_input(GeometryInput &geom_input);
165 
166  /*
167  * Adds a series of vertices that represent the loop.
168  */
169  //LoopInput& add_vertices(std::vector<Point3D> points);
170 
171  /*
172  * Adds an edge on the end of the Loop
173  */
174  /*
175  LoopInput& add_edge(Edge edge);
176  LoopInput& add_edges(std::vector<Edge> edges);
177  */
178  //LoopInput& add_curve(Curve curve);
179  //LoopInput& add_curves(std::vector<Curve> curves);
180 
181 };
182 
183 } /* namespace CW */
184 
185 #endif /* LoopInput_hpp */
Definition: Color.hpp:34