SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
Edge.hpp
1 //
2 // Edge.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 Edge_hpp
29 #define Edge_hpp
30 
31 #include <stdio.h>
32 
33 #include <SketchUpAPI/model/edge.h>
34 
35 #include "SUAPI-CppWrapper/Geometry.hpp"
36 #include "SUAPI-CppWrapper/model/DrawingElement.hpp"
37 
38 namespace CW {
39 
40 // Forward Declarations
41 class Vertex;
42 class Face;
43 class Color;
44 
45 /**
46 *
47 */
48 class Edge :public DrawingElement {
49  private:
50  static SUEdgeRef create_edge(const Point3D& start, const Point3D& end);
51 
52  static SUEdgeRef copy_reference(const Edge& other);
53 
54  public:
55  /**
56  * Constructor for null Edge object.
57  */
58  Edge();
59 
60  /*
61  * Construct an Edge from a vector of two points.
62  * @param points - where points[0] is the start vertex and points[1] is the end vertex.
63  */
64  Edge(const std::vector<Point3D>& points);
65 
66  /*
67  * Construct an Edge from a vector of two points.
68  * @param start - the start vertex
69  * @param end - the end vertex.
70  */
71  Edge(const Point3D& start, const Point3D& end);
72 
73  /**
74  * Creates new edge using vertices position. Note that this will not join the new edge to existing vertices. Use GeometryInput for welding edges.
75  */
76  Edge(const Vertex& start, const Vertex& end);
77 
78  /*
79  * Edge constructor that essentially wraps around an already created SUFaceRef object.
80  * @param SUEdgeRef pointer to the edge.
81  * @param bool true if the edge should be released when this class object is destroyed. False, if the release of the face object is handled elsewhere (use with caution).
82  */
83  Edge(SUEdgeRef edge, bool attached = true);
84 
85  /** Copy Constructor */
86  Edge(const Edge& other);
87 
88  ~Edge();
89 
90  Edge& operator=(const Edge& other);
91 
92  /**
93  * Returns SUEdgeRef object for the Edge.
94  */
95  SUEdgeRef ref() const;
96 
97  /*
98  * The class object can be converted to a SUEdgeRef without loss of data.
99  */
100  operator SUEdgeRef() const;
101 
102  /*
103  * Returns whether the class is a valid object.
104  */
105  // operator bool() const;
106  /**
107  * NOT operator. Checks if the SUEdgeRef is valid.
108  * @return true if the edge is invalid
109  */
110  bool operator!() const;
111 
112  /*
113  * Returns the Color object assigned to the Edge
114  */
115  Color color() const;
116 
117  /*
118  * Sets the color of the Edge.
119  */
120  bool color(const Color& input_color);
121 
122  /*
123  * Return the vertex at the end of the Edge.
124  */
125  Vertex end() const;
126 
127  /*
128  * Return the faces connected to this edge.
129  */
130  std::vector<Face> faces() const;
131 
132  /*
133  * Gets the SUResult of the create edge operation.
134  * @return * SU_ERROR_NONE on success
135  * SU_ERROR_NULL_POINTER_INPUT if start or end is NULL
136  * SU_ERROR_NULL_POINTER_OUTPUT if edge is NULL
137  * SU_ERROR_GENERIC if start and end specify the same position.
138  */
139  // SUResult get_result() const;
140 
141  /*
142  * Determine if the Edge is smooth.
143  * @return true if the Edge is smooth.
144  */
145  bool smooth() const;
146 
147  /*
148  * Set the smooth status for an Edge.
149  * @param bool true to make the edge smooth, false to make the edge hard.
150  * @return true for successful, false for unsuccessful.
151  */
152  bool smooth(bool smooth);
153 
154  /*
155  * Determine if the Edge is soft.
156  * @return true if the Edge is soft.
157  */
158  bool soft() const;
159 
160  /*
161  * Set the soft status for an edge.
162  * @param bool true if you want soften the edge, false if you do not want to soften the edge.
163  * @return true for successful, false for unsuccessful.
164  */
165  bool soft(bool soft);
166 
167  /*
168  * Return the vertex at the start of the Edge.
169  */
170  Vertex start() const;
171 
172  /*
173  * Return Vector between the start and end points
174  */
175  Vector3D vector() const;
176 };
177 
178 } /* namespace CW */
179 #endif /* Edge_hpp */
bool operator!() const
Definition: Edge.cpp:144
bool attached() const
Returns true if the entity is attached to another object.
Definition: Entity.cpp:100
Edge()
Definition: Edge.cpp:71
SUEdgeRef ref() const
Definition: Edge.cpp:135
Definition: Color.hpp:34