-
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e91503
commit d036c0b
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2024 Ultimaker B.V. | ||
// CuraEngine is released under the terms of the AGPLv3 or higher. | ||
|
||
#ifndef PATH_ADAPTER_H | ||
#define PATH_ADAPTER_H | ||
|
||
#include <stddef.h> | ||
|
||
#include "geometry/Point2LL.h" | ||
#include "utils/Coord_t.h" | ||
|
||
namespace cura | ||
{ | ||
|
||
/* Adapter class to allow extrusion-related functions to work with either an ExtrusionLine or a Polygon */ | ||
template<typename PathType> | ||
class PathAdapter | ||
{ | ||
public: | ||
/*! | ||
* \brief Base constructor | ||
* \param path The actual stored path | ||
* \param fixed_line_width The fixed line width in case the stored path doesn't handle information about a variable | ||
* line width. Can be omitted otherwise. | ||
*/ | ||
PathAdapter(const PathType& path, coord_t fixed_line_width = 0) | ||
: path_(path) | ||
, fixed_line_width_(fixed_line_width) | ||
{ | ||
} | ||
|
||
bool empty() const | ||
{ | ||
return path_.empty(); | ||
} | ||
|
||
size_t size() const | ||
{ | ||
return path_.size(); | ||
} | ||
|
||
coord_t length() const | ||
{ | ||
return path_.length(); | ||
} | ||
|
||
const Point2LL& pointAt(size_t index) const; | ||
|
||
coord_t lineWidthAt(size_t index) const; | ||
|
||
const PathType& getPath() const | ||
{ | ||
return path_; | ||
} | ||
|
||
private: | ||
const PathType& path_; | ||
const coord_t fixed_line_width_; | ||
}; | ||
|
||
} // namespace cura | ||
|
||
#endif // PATH_ADAPTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 Ultimaker B.V. | ||
// CuraEngine is released under the terms of the AGPLv3 or higher. | ||
|
||
#include "PathAdapter.h" | ||
|
||
#include "utils/ExtrusionLine.h" | ||
|
||
namespace cura | ||
{ | ||
|
||
template<> | ||
const Point2LL& PathAdapter<ExtrusionLine>::pointAt(size_t index) const | ||
{ | ||
return path_.junctions_.at(index).p_; | ||
} | ||
|
||
template<> | ||
coord_t PathAdapter<ExtrusionLine>::lineWidthAt(size_t index) const | ||
{ | ||
return path_.junctions_.at(index).w_; | ||
} | ||
|
||
template<> | ||
const Point2LL& PathAdapter<Polygon>::pointAt(size_t index) const | ||
{ | ||
return path_.at(index); | ||
} | ||
|
||
template<> | ||
coord_t PathAdapter<Polygon>::lineWidthAt(size_t /*index*/) const | ||
{ | ||
return fixed_line_width_; | ||
} | ||
|
||
} // namespace cura |