Skip to content

Commit 8c99c88

Browse files
Add ToolPath and ToolPathSegment class
1 parent 235ecf8 commit 8c99c88

File tree

5 files changed

+821
-2
lines changed

5 files changed

+821
-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: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
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+
virtual ~ToolPath() = default;
41+
42+
/** @brief Get the uuid */
43+
boost::uuids::uuid getUUID() const;
44+
45+
/** @brief Regenerate uuid */
46+
void regenerateUUID();
47+
48+
/**
49+
* @brief Get the parent uuid
50+
* @details This can be null
51+
*/
52+
const boost::uuids::uuid& getParentUUID() const;
53+
54+
/**
55+
* @brief Set the parent uuid
56+
* @details This can be used in cases were a segment is split during a filter process and want tracability.
57+
* @param uuid
58+
*/
59+
void setParentUUID(const boost::uuids::uuid& uuid);
60+
61+
/** @brief Set the tool path description */
62+
void setDescription(const std::string& desc);
63+
64+
/** @brief Get the tool path description */
65+
const std::string& getDescription() const;
66+
67+
/**
68+
* @brief Set a namespace for the tool path
69+
* @details This can be multiple namespace by separating by '::' for example 'main::left::place'
70+
* which will have it show up in the widget as a teared item in the tree view.
71+
* @param ns A namespace the tool path is associated with
72+
*/
73+
void setNamespace(std::string ns);
74+
75+
/**
76+
* @brief Get the namespace for the tool path
77+
* @return The namespace
78+
*/
79+
const std::string& getNamespace() const;
80+
81+
bool operator==(const ToolPath& rhs) const;
82+
bool operator!=(const ToolPath& rhs) const;
83+
84+
///////////////////////////
85+
// C++ container support //
86+
///////////////////////////
87+
/** pointer */
88+
using pointer = typename AlignedVector<ToolPathSegment>::pointer;
89+
/** const_pointer */
90+
using const_pointer = typename AlignedVector<ToolPathSegment>::const_pointer;
91+
/** reference */
92+
using reference = typename AlignedVector<ToolPathSegment>::reference;
93+
/** const_reference */
94+
using const_reference = typename AlignedVector<ToolPathSegment>::const_reference;
95+
/** size_type */
96+
using size_type = typename AlignedVector<ToolPathSegment>::size_type;
97+
/** difference_type */
98+
using difference_type = typename AlignedVector<ToolPathSegment>::difference_type;
99+
/** iterator */
100+
using iterator = typename AlignedVector<ToolPathSegment>::iterator;
101+
/** const_iterator */
102+
using const_iterator = typename AlignedVector<ToolPathSegment>::const_iterator;
103+
/** reverse_iterator */
104+
using reverse_iterator = typename AlignedVector<ToolPathSegment>::reverse_iterator;
105+
/** const_reverse_iterator */
106+
using const_reverse_iterator = typename AlignedVector<ToolPathSegment>::const_reverse_iterator;
107+
108+
///////////////
109+
// Iterators //
110+
///////////////
111+
/** @brief returns an iterator to the beginning */
112+
iterator begin();
113+
/** @brief returns an iterator to the beginning */
114+
const_iterator begin() const;
115+
/** @brief returns an iterator to the end */
116+
iterator end();
117+
/** @brief returns an iterator to the end */
118+
const_iterator end() const;
119+
/** @brief returns a reverse iterator to the beginning */
120+
reverse_iterator rbegin();
121+
/** @brief returns a reverse iterator to the beginning */
122+
const_reverse_iterator rbegin() const;
123+
/** @brief returns a reverse iterator to the end */
124+
reverse_iterator rend();
125+
/** @brief returns a reverse iterator to the end */
126+
const_reverse_iterator rend() const;
127+
/** @brief returns an iterator to the beginning */
128+
const_iterator cbegin() const;
129+
/** @brief returns an iterator to the end */
130+
const_iterator cend() const;
131+
/** @brief returns a reverse iterator to the beginning */
132+
const_reverse_iterator crbegin() const;
133+
/** @brief returns a reverse iterator to the end */
134+
const_reverse_iterator crend() const;
135+
136+
//////////////
137+
// Capacity //
138+
//////////////
139+
/** @brief checks whether the container is empty */
140+
bool empty() const;
141+
/** @brief returns the number of elements */
142+
size_type size() const;
143+
/** @brief returns the maximum possible number of elements */
144+
size_type max_size() const;
145+
/** @brief reserve number of elements */
146+
void reserve(size_type n);
147+
/** @brief returns the number of elements that can be held in currently allocated storage */
148+
size_type capacity() const;
149+
/** @brief reduces memory usage by freeing unused memory */
150+
void shrink_to_fit();
151+
152+
////////////////////
153+
// Element Access //
154+
////////////////////
155+
/** @brief access the first element */
156+
reference front();
157+
/** @brief access the first element */
158+
const_reference front() const;
159+
/** @brief access the last element */
160+
reference back();
161+
/** @brief access the last element */
162+
const_reference back() const;
163+
/** @brief access specified element with bounds checking */
164+
reference at(size_type n);
165+
/** @brief access specified element with bounds checking */
166+
const_reference at(size_type n) const;
167+
/** @brief direct access to the underlying array */
168+
pointer data();
169+
/** @brief direct access to the underlying array */
170+
const_pointer data() const;
171+
/** @brief access specified element */
172+
reference operator[](size_type pos);
173+
/** @brief access specified element */
174+
const_reference operator[](size_type pos) const;
175+
176+
///////////////
177+
// Modifiers //
178+
///////////////
179+
/** @brief clears the contents */
180+
void clear();
181+
182+
/** @brief inserts element */
183+
iterator insert(const_iterator p, const ToolPathSegment& x);
184+
iterator insert(const_iterator p, ToolPathSegment&& x);
185+
iterator insert(const_iterator p, std::initializer_list<ToolPathSegment> l);
186+
template <class InputIt>
187+
void insert(const_iterator pos, InputIt first, InputIt last)
188+
{
189+
container_.insert(pos, first, last);
190+
}
191+
192+
/** @brief constructs element in-place */
193+
template <class... Args>
194+
iterator emplace(const_iterator pos, Args&&... args);
195+
196+
/** @brief erases element */
197+
iterator erase(const_iterator p);
198+
iterator erase(const_iterator first, const_iterator last);
199+
200+
/** Append element to container */
201+
void push_back(const ToolPathSegment& x);
202+
void push_back(const ToolPathSegment&& x);
203+
204+
/** @brief constructs an element in-place at the end */
205+
template <typename... Args>
206+
#if __cplusplus > 201402L
207+
reference emplace_back(Args&&... args);
208+
#else
209+
void emplace_back(Args&&... args);
210+
#endif
211+
212+
/** @brief removes the last element */
213+
void pop_back();
214+
215+
/** @brief swaps the contents */
216+
void swap(AlignedVector<ToolPathSegment>& other);
217+
218+
protected:
219+
/** @brief The uuid */
220+
boost::uuids::uuid uuid_;
221+
222+
/** @brief The parent uuid */
223+
boost::uuids::uuid parent_uuid_;
224+
225+
/** @brief The description */
226+
std::string description_;
227+
228+
/** @brief The container */
229+
AlignedVector<ToolPathSegment> container_;
230+
231+
/** @brief The namespace associated with the tool path */
232+
std::string ns_{ "general" };
233+
234+
friend class boost::serialization::access;
235+
template <class Archive>
236+
void serialize(Archive& ar, const unsigned int version); // NOLINT
237+
};
238+
239+
} // namespace tesseract_common
240+
241+
#endif // TESSERACT_COMMON_TOOL_PATH_H

0 commit comments

Comments
 (0)