Skip to content

Commit 11cd2e6

Browse files
Add ToolPath and ToolPathSegment class
1 parent 235ecf8 commit 11cd2e6

File tree

7 files changed

+977
-2
lines changed

7 files changed

+977
-2
lines changed

tesseract_common/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ add_library(
6060
src/shader_param.cpp
6161
src/shader_params.cpp
6262
src/shader_type.cpp
63+
src/tool_path.cpp
64+
src/tool_path_segment.cpp
6365
src/types.cpp)
6466
target_link_libraries(
6567
${PROJECT_NAME}
@@ -85,8 +87,7 @@ target_code_coverage(
8587
ENABLE ${TESSERACT_ENABLE_CODE_COVERAGE})
8688
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
8789
"$<INSTALL_INTERFACE:include>")
88-
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
89-
${FreeImage_INCLUDE_DIRS})
90+
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${FreeImage_INCLUDE_DIRS})
9091

9192
configure_package(NAMESPACE tesseract TARGETS ${PROJECT_NAME})
9293

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
/**
2+
* @file tool_path.h
3+
* @brief Common Tesseract Tool Path
4+
*
5+
* @author Levi Armstrong
6+
* @date Nov 16, 2022
7+
* @version TODO
8+
* @bug No known bugs
9+
*
10+
* @copyright Copyright (c) 2022, Levi Armstrong
11+
*
12+
* @par License
13+
* Software License Agreement (Apache License)
14+
* @par
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* @par
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
#ifndef TESSERACT_COMMON_TOOL_PATH_H
27+
#define TESSERACT_COMMON_TOOL_PATH_H
28+
29+
#include <string>
30+
#include <tesseract_common/tool_path_segment.h>
31+
32+
namespace tesseract_common
33+
{
34+
class ToolPath
35+
{
36+
public:
37+
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38+
39+
ToolPath(std::string description = "");
40+
ToolPath(boost::uuids::uuid uuid, std::string description = "");
41+
virtual ~ToolPath() = default;
42+
43+
/** @brief Get the uuid */
44+
boost::uuids::uuid getUUID() const;
45+
46+
/** @brief Regenerate uuid */
47+
void regenerateUUID();
48+
49+
/**
50+
* @brief Get the parent uuid
51+
* @details This can be null
52+
*/
53+
const boost::uuids::uuid& getParentUUID() const;
54+
55+
/**
56+
* @brief Set the parent uuid
57+
* @details This can be used in cases were a segment is split during a filter process and want tracability.
58+
* @param uuid
59+
*/
60+
void setParentUUID(const boost::uuids::uuid& uuid);
61+
62+
/** @brief Set the tool path description */
63+
void setDescription(const std::string& desc);
64+
65+
/** @brief Get the tool path description */
66+
const std::string& getDescription() const;
67+
68+
/**
69+
* @brief Set a namespace for the tool path
70+
* @details This can be multiple namespace by separating by '::' for example 'main::left::place'
71+
* which will have it show up in the widget as a teared item in the tree view.
72+
* @param ns A namespace the tool path is associated with
73+
*/
74+
void setNamespace(std::string ns);
75+
76+
/**
77+
* @brief Get the namespace for the tool path
78+
* @return The namespace
79+
*/
80+
const std::string& getNamespace() const;
81+
82+
bool operator==(const ToolPath& rhs) const;
83+
bool operator!=(const ToolPath& rhs) const;
84+
85+
// LCOV_EXCL_START
86+
87+
///////////////////////////
88+
// C++ container support //
89+
///////////////////////////
90+
/** pointer */
91+
using pointer = typename AlignedVector<ToolPathSegment>::pointer;
92+
/** const_pointer */
93+
using const_pointer = typename AlignedVector<ToolPathSegment>::const_pointer;
94+
/** reference */
95+
using reference = typename AlignedVector<ToolPathSegment>::reference;
96+
/** const_reference */
97+
using const_reference = typename AlignedVector<ToolPathSegment>::const_reference;
98+
/** size_type */
99+
using size_type = typename AlignedVector<ToolPathSegment>::size_type;
100+
/** difference_type */
101+
using difference_type = typename AlignedVector<ToolPathSegment>::difference_type;
102+
/** iterator */
103+
using iterator = typename AlignedVector<ToolPathSegment>::iterator;
104+
/** const_iterator */
105+
using const_iterator = typename AlignedVector<ToolPathSegment>::const_iterator;
106+
/** reverse_iterator */
107+
using reverse_iterator = typename AlignedVector<ToolPathSegment>::reverse_iterator;
108+
/** const_reverse_iterator */
109+
using const_reverse_iterator = typename AlignedVector<ToolPathSegment>::const_reverse_iterator;
110+
111+
///////////////
112+
// Iterators //
113+
///////////////
114+
/** @brief returns an iterator to the beginning */
115+
iterator begin();
116+
/** @brief returns an iterator to the beginning */
117+
const_iterator begin() const;
118+
/** @brief returns an iterator to the end */
119+
iterator end();
120+
/** @brief returns an iterator to the end */
121+
const_iterator end() const;
122+
/** @brief returns a reverse iterator to the beginning */
123+
reverse_iterator rbegin();
124+
/** @brief returns a reverse iterator to the beginning */
125+
const_reverse_iterator rbegin() const;
126+
/** @brief returns a reverse iterator to the end */
127+
reverse_iterator rend();
128+
/** @brief returns a reverse iterator to the end */
129+
const_reverse_iterator rend() const;
130+
/** @brief returns an iterator to the beginning */
131+
const_iterator cbegin() const;
132+
/** @brief returns an iterator to the end */
133+
const_iterator cend() const;
134+
/** @brief returns a reverse iterator to the beginning */
135+
const_reverse_iterator crbegin() const;
136+
/** @brief returns a reverse iterator to the end */
137+
const_reverse_iterator crend() const;
138+
139+
//////////////
140+
// Capacity //
141+
//////////////
142+
/** @brief checks whether the container is empty */
143+
bool empty() const;
144+
/** @brief returns the number of elements */
145+
size_type size() const;
146+
/** @brief returns the maximum possible number of elements */
147+
size_type max_size() const;
148+
/** @brief reserve number of elements */
149+
void reserve(size_type n);
150+
/** @brief returns the number of elements that can be held in currently allocated storage */
151+
size_type capacity() const;
152+
/** @brief reduces memory usage by freeing unused memory */
153+
void shrink_to_fit();
154+
155+
////////////////////
156+
// Element Access //
157+
////////////////////
158+
/** @brief access the first element */
159+
reference front();
160+
/** @brief access the first element */
161+
const_reference front() const;
162+
/** @brief access the last element */
163+
reference back();
164+
/** @brief access the last element */
165+
const_reference back() const;
166+
/** @brief access specified element with bounds checking */
167+
reference at(size_type n);
168+
/** @brief access specified element with bounds checking */
169+
const_reference at(size_type n) const;
170+
/** @brief direct access to the underlying array */
171+
pointer data();
172+
/** @brief direct access to the underlying array */
173+
const_pointer data() const;
174+
/** @brief access specified element */
175+
reference operator[](size_type pos);
176+
/** @brief access specified element */
177+
const_reference operator[](size_type pos) const;
178+
179+
///////////////
180+
// Modifiers //
181+
///////////////
182+
/** @brief clears the contents */
183+
void clear();
184+
185+
/** @brief inserts element */
186+
iterator insert(const_iterator p, const ToolPathSegment& x);
187+
iterator insert(const_iterator p, ToolPathSegment&& x);
188+
iterator insert(const_iterator p, std::initializer_list<ToolPathSegment> l);
189+
template <class InputIt>
190+
void insert(const_iterator pos, InputIt first, InputIt last)
191+
{
192+
container_.insert(pos, first, last);
193+
}
194+
195+
/** @brief constructs element in-place */
196+
template <class... Args>
197+
iterator emplace(const_iterator pos, Args&&... args);
198+
199+
/** @brief erases element */
200+
iterator erase(const_iterator p);
201+
iterator erase(const_iterator first, const_iterator last);
202+
203+
/** Append element to container */
204+
void push_back(const ToolPathSegment& x);
205+
void push_back(const ToolPathSegment&& x);
206+
207+
/** @brief constructs an element in-place at the end */
208+
template <typename... Args>
209+
#if __cplusplus > 201402L
210+
reference emplace_back(Args&&... args);
211+
#else
212+
void emplace_back(Args&&... args);
213+
#endif
214+
215+
/** @brief removes the last element */
216+
void pop_back();
217+
218+
/** @brief swaps the contents */
219+
void swap(AlignedVector<ToolPathSegment>& other);
220+
// LCOV_EXCL_STOP
221+
222+
protected:
223+
/** @brief The uuid */
224+
boost::uuids::uuid uuid_{};
225+
226+
/** @brief The parent uuid */
227+
boost::uuids::uuid parent_uuid_{};
228+
229+
/** @brief The description */
230+
std::string description_;
231+
232+
/** @brief The container */
233+
AlignedVector<ToolPathSegment> container_;
234+
235+
/** @brief The namespace associated with the tool path */
236+
std::string ns_{ "general" };
237+
238+
friend class boost::serialization::access;
239+
template <class Archive>
240+
void serialize(Archive& ar, const unsigned int version); // NOLINT
241+
};
242+
243+
} // namespace tesseract_common
244+
245+
#endif // TESSERACT_COMMON_TOOL_PATH_H

0 commit comments

Comments
 (0)