SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
Curve.hpp
1 //
2 // Curve.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 Curve_hpp
29 #define Curve_hpp
30 
31 #include <stdio.h>
32 #include <vector>
33 
34 #include <SketchUpAPI/model/curve.h>
35 
36 #include "SUAPI-CppWrapper/model/Edge.hpp"
37 
38 namespace CW {
39 
40 class Curve :public Entity {
41  private:
42  SUCurveType m_curve_type;
43  SUResult m_create_result;
44 
45  static SUCurveRef create_curve(std::vector<Edge>& edges, SUResult &result);
46 
47  public:
48  /**
49  * A curve is created from an array of Edge objects.
50  * @param edges - a vector array of Edge objects.
51  * @param curve_type (optional) the type of curve
52  */
53  Curve(std::vector<Edge> edges, SUCurveType curve_type = SUCurveType_Simple);
54  Curve(SUCurveRef curve, SUCurveType curve_type);
55 
56  ~Curve();
57 
58  /**
59  * Returns SUCurveRef object of this curve.
60  */
61  SUCurveRef ref() const;
62 
63  /**
64  * Returns the series of Edge objects in the Curve.
65  */
66  std::vector<Edge> get_edges() const;
67 
68  /**
69  * Returns the type of Curve.
70  */
71  SUCurveType get_type();
72 
73  /*
74  * Returns the SUResult object form when the Curve was created.
75  * @return * SU_ERROR_NONE on success
76  * SU_ERROR_NULL_POINTER_INPUT if edges is NULL
77  * SU_ERROR_OUT_OF_RANGE if len is 0
78  * SU_ERROR_NULL_POINTER_OUTPUT if curve is NULL
79  * SU_ERROR_OVERWRITE_VALID if curve already references a valid object
80  * SU_ERROR_GENERIC if edge array contains an invalid edge, if the edges in the array are not connected, if any of the edges are associated with a face object, or the edges describe a loop
81  */
82  SUResult get_result() const;
83 
84  /*
85  * Returns whether the class is a valid object.
86  */
87  operator bool() const;
88 
89  /**
90  * NOT operator. Checks if the CurveRef is valid.
91  * @return true if the curve is invalid
92  */
93  bool operator!() const;
94 
95 };
96 
97 } /* namespace CW */
98 
99 #endif /* Curve_hpp */
SUCurveType get_type()
Definition: Curve.cpp:87
bool operator!() const
Definition: Curve.cpp:109
Definition: Color.hpp:34
SUCurveRef ref() const
Definition: Curve.cpp:63
std::vector< Edge > get_edges() const
Definition: Curve.cpp:68
Curve(std::vector< Edge > edges, SUCurveType curve_type=SUCurveType_Simple)
Definition: Curve.cpp:40