SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
Loop.hpp
1 //
2 // Loop.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 Loop_hpp
29 #define Loop_hpp
30 
31 #include <stdio.h>
32 #include <vector>
33 
34 #include "SUAPI-CppWrapper/model/Entity.hpp"
35 
36 //#include <SketchUpAPI/geometry.h>
37 //#include <SketchUpAPI/model/geometry_input.h>
38 #include <SketchUpAPI/model/loop.h>
39 
40 namespace CW {
41 
42 // Forward Declarations
43 class LoopInput;
44 class Edge;
45 class Vertex;
46 class Point3D;
47 
48 /**
49 * PointLoopClassify is used to describe where a point sits on a loop object.
50 */
51 enum class PointLoopClassify {
52  PointOutside,
53  PointInside,
54  PointOnVertex,
55  PointOnEdge,
56  PointNotOnPlane,
57  PointUnknown // indicates an error
58 };
59 
60 /**
61 * A face is made up of an outer loop and inner loops.
62 */
63 class Loop :public Entity {
64  public:
65  /**
66  * Creates an invalid Loop object.
67  */
68  Loop();
69 
70  /*
71  * Creates a Loop object from the SULoopRef.
72  * @param SULoopRef object that is already attached to a SUFaceRef
73  */
74  Loop(SULoopRef loop);
75 
76  /*
77  * Copy Constructor.
78  */
79  Loop(const Loop& other);
80 
81  /** Copy assignment operator */
82  Loop& operator=(const Loop& other);
83 
84  /**
85  * Returns the SULoopRef object stored in this loop.
86  */
87  SULoopRef ref() const;
88 
89  /*
90  * Returns the LoopInput object for this loop. A SULoopInputRef will be created using the values of the original SULoopRef object.
91  */
92  LoopInput loop_input() const;
93 
94  /**
95  * Returns the Edges in the Loop
96  */
97  std::vector<Edge> edges() const;
98 
99  /**
100  * Returns the Vertices in the Loop
101  */
102  std::vector<Vertex> vertices() const;
103 
104  /**
105  * Returns the points representing the vertices in the Loop
106  */
107  std::vector<Point3D> points() const;
108 
109  /**
110  * Determine where on the loop a point lies. @see PointLoopClassify.
111  * @param point - the Point3D object ot check.
112  */
113  PointLoopClassify classify_point(const Point3D& point) const;
114 
115  /**
116  * Returns the number of edges/vertices in the loop.
117  */
118  size_t size() const;
119 
120  /**
121  * Returns whether a point is within a loop, given by the vector of points.
122  * @param loop_points - a vector of points representing the vertices of a loop.
123  * @param test_point - the point to test within the loop.
124  * @return PointLoopClassify object describing the location of the point relative to the loop.
125  */
126  static PointLoopClassify classify_point(const std::vector<Point3D>& loop_points, const Point3D& test_point);
127 
128  /**
129  * Retrieves a flag indicating the whether the loop is the outer loop on its associated face.
130  */
131  bool is_outer_loop() const;
132 
133 };
134 
135 } /* namespace CW */
136 #endif /* Loop_hpp */
Definition: Color.hpp:34