1 |
commit: 7a67b46fa6e5dda158561b25b61129f4a282536a |
2 |
Author: Dennis Lamm <expeditioneer <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Nov 29 15:09:41 2020 +0000 |
4 |
Commit: Dennis Lamm <expeditioneer <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Nov 30 18:37:41 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7a67b46f |
7 |
|
8 |
dev-libs/libnest2d: added new ebuild |
9 |
|
10 |
Signed-off-by: Dennis Lamm <expeditoneer <AT> gentoo.org> |
11 |
Signed-off-by: Dennis Lamm <expeditioneer <AT> gentoo.org> |
12 |
|
13 |
dev-libs/libnest2d/Manifest | 1 + |
14 |
.../files/libnest2d-0.4-add-disallowed-areas.patch | 122 +++++++++++++++++++++ |
15 |
dev-libs/libnest2d/libnest2d-0.4.ebuild | 39 +++++++ |
16 |
dev-libs/libnest2d/metadata.xml | 23 ++++ |
17 |
4 files changed, 185 insertions(+) |
18 |
|
19 |
diff --git a/dev-libs/libnest2d/Manifest b/dev-libs/libnest2d/Manifest |
20 |
new file mode 100644 |
21 |
index 00000000000..c11b486d54e |
22 |
--- /dev/null |
23 |
+++ b/dev-libs/libnest2d/Manifest |
24 |
@@ -0,0 +1 @@ |
25 |
+DIST libnest2d-0.4.tar.gz 365065 BLAKE2B 74a4aef18be22d24e4e73288dd3e330b2f5baa3b2c705683c22767dfb0394a7b332bad957321f57ec7eaaf4740cff9ca1ed86f9d552be65df1b2af76ceba61e9 SHA512 fadce18986b844eed13a581f84055df909a17407a0980deb6c7c24248a969a537a8840650bcfc673e61973810ce9a008acb599e3b8e00c9bff6b566ca41cd62c |
26 |
|
27 |
diff --git a/dev-libs/libnest2d/files/libnest2d-0.4-add-disallowed-areas.patch b/dev-libs/libnest2d/files/libnest2d-0.4-add-disallowed-areas.patch |
28 |
new file mode 100644 |
29 |
index 00000000000..ed48cd3eeff |
30 |
--- /dev/null |
31 |
+++ b/dev-libs/libnest2d/files/libnest2d-0.4-add-disallowed-areas.patch |
32 |
@@ -0,0 +1,122 @@ |
33 |
+From 2e91be2679b5efa0773292d9d0a2ae72255bb271 Mon Sep 17 00:00:00 2001 |
34 |
+From: Ghostkeeper <rubend@××××××××.com> |
35 |
+Date: Tue, 6 Oct 2020 16:13:15 +0200 |
36 |
+Subject: [PATCH 1/3] Allow for an item to be a disallowed area |
37 |
+ |
38 |
+Disallowed areas have slightly different behaviour from fixed items: Other items won't get packed closely around them. Implementation of that pending. |
39 |
+ |
40 |
+Contributes to issue CURA-7754. |
41 |
+--- |
42 |
+ include/libnest2d/nester.hpp | 16 ++++++++++++++++ |
43 |
+ 1 file changed, 16 insertions(+) |
44 |
+ |
45 |
+diff --git a/include/libnest2d/nester.hpp b/include/libnest2d/nester.hpp |
46 |
+index 2f207d5..932a060 100644 |
47 |
+--- a/include/libnest2d/nester.hpp |
48 |
++++ b/include/libnest2d/nester.hpp |
49 |
+@@ -71,6 +71,15 @@ class _Item { |
50 |
+ int binid_{BIN_ID_UNSET}, priority_{0}; |
51 |
+ bool fixed_{false}; |
52 |
+ |
53 |
++ /** |
54 |
++ * \brief If this is a fixed area, indicates whether it is a disallowed area |
55 |
++ * or a previously placed item. |
56 |
++ * |
57 |
++ * If this is a disallowed area, other objects will not get packed close |
58 |
++ * together with this item. It only blocks other items in its area. |
59 |
++ */ |
60 |
++ bool disallowed_{false}; |
61 |
++ |
62 |
+ public: |
63 |
+ |
64 |
+ /// The type of the shape which was handed over as the template argument. |
65 |
+@@ -129,11 +138,18 @@ class _Item { |
66 |
+ sh_(sl::create<RawShape>(std::move(contour), std::move(holes))) {} |
67 |
+ |
68 |
+ inline bool isFixed() const noexcept { return fixed_; } |
69 |
++ inline bool isDisallowedArea() const noexcept { return disallowed_; } |
70 |
+ inline void markAsFixedInBin(int binid) |
71 |
+ { |
72 |
+ fixed_ = binid >= 0; |
73 |
+ binid_ = binid; |
74 |
+ } |
75 |
++ inline void markAsDisallowedAreaInBin(int binid) |
76 |
++ { |
77 |
++ fixed_ = binid >= 0; |
78 |
++ binid_ = binid; |
79 |
++ disallowed_ = true; |
80 |
++ } |
81 |
+ |
82 |
+ inline void binId(int idx) { binid_ = idx; } |
83 |
+ inline int binId() const noexcept { return binid_; } |
84 |
+ |
85 |
+From ff61049e59d3151462bca7ff2e2268c2b32731e7 Mon Sep 17 00:00:00 2001 |
86 |
+From: Ghostkeeper <rubend@××××××××.com> |
87 |
+Date: Tue, 6 Oct 2020 16:14:36 +0200 |
88 |
+Subject: [PATCH 2/3] Allow unsetting of being a disallowed area |
89 |
+ |
90 |
+If you set the bin to -1 or set the item to be a simple fixed item afterwards, it'll no longer be a disallowed area. |
91 |
+ |
92 |
+Contributes to issue CURA-7754. |
93 |
+--- |
94 |
+ include/libnest2d/nester.hpp | 3 ++- |
95 |
+ 1 file changed, 2 insertions(+), 1 deletion(-) |
96 |
+ |
97 |
+diff --git a/include/libnest2d/nester.hpp b/include/libnest2d/nester.hpp |
98 |
+index 932a060..54761a6 100644 |
99 |
+--- a/include/libnest2d/nester.hpp |
100 |
++++ b/include/libnest2d/nester.hpp |
101 |
+@@ -143,12 +143,13 @@ class _Item { |
102 |
+ { |
103 |
+ fixed_ = binid >= 0; |
104 |
+ binid_ = binid; |
105 |
++ disallowed_ = false; |
106 |
+ } |
107 |
+ inline void markAsDisallowedAreaInBin(int binid) |
108 |
+ { |
109 |
+ fixed_ = binid >= 0; |
110 |
+ binid_ = binid; |
111 |
+- disallowed_ = true; |
112 |
++ disallowed_ = fixed_; |
113 |
+ } |
114 |
+ |
115 |
+ inline void binId(int idx) { binid_ = idx; } |
116 |
+ |
117 |
+From 31391fd173249ad9b906390058e13b09238fadc8 Mon Sep 17 00:00:00 2001 |
118 |
+From: Ghostkeeper <rubend@××××××××.com> |
119 |
+Date: Thu, 8 Oct 2020 11:06:58 +0200 |
120 |
+Subject: [PATCH 3/3] Align items to their starting position if all placed |
121 |
+ items are disallowed |
122 |
+ |
123 |
+We shouldn't align items to disallowed areas. So place them in the starting position according to the alignment property. |
124 |
+ |
125 |
+Lot of work to investigate. But very little code changes! |
126 |
+ |
127 |
+Contributes to issue CURA-7754. |
128 |
+--- |
129 |
+ include/libnest2d/placers/nfpplacer.hpp | 5 +++-- |
130 |
+ 1 file changed, 3 insertions(+), 2 deletions(-) |
131 |
+ |
132 |
+diff --git a/include/libnest2d/placers/nfpplacer.hpp b/include/libnest2d/placers/nfpplacer.hpp |
133 |
+index 96a8cff..b0ebb15 100644 |
134 |
+--- a/include/libnest2d/placers/nfpplacer.hpp |
135 |
++++ b/include/libnest2d/placers/nfpplacer.hpp |
136 |
+@@ -101,7 +101,7 @@ struct NfpPConfig { |
137 |
+ * alignment with the candidate item or do anything else. |
138 |
+ * |
139 |
+ * \param remaining A container with the remaining items waiting to be |
140 |
+- * placed. You can use some features about the remaining items to alter to |
141 |
++ * placed. You can use some features about the remaining items to alter the |
142 |
+ * score of the current placement. If you know that you have to leave place |
143 |
+ * for other items as well, that might influence your decision about where |
144 |
+ * the current candidate should be placed. E.g. imagine three big circles |
145 |
+@@ -735,7 +735,8 @@ class _NofitPolyPlacer: public PlacerBoilerplate<_NofitPolyPlacer<RawShape, TBin |
146 |
+ remlist.insert(remlist.end(), remaining.from, remaining.to); |
147 |
+ } |
148 |
+ |
149 |
+- if(items_.empty()) { |
150 |
++ if(std::all_of(items_.begin(), items_.end(), |
151 |
++ [](const Item& item) { return item.isDisallowedArea(); })) { |
152 |
+ setInitialPosition(item); |
153 |
+ best_overfit = overfit(item.transformedShape(), bin_); |
154 |
+ can_pack = best_overfit <= 0; |
155 |
|
156 |
diff --git a/dev-libs/libnest2d/libnest2d-0.4.ebuild b/dev-libs/libnest2d/libnest2d-0.4.ebuild |
157 |
new file mode 100644 |
158 |
index 00000000000..6a9a278110f |
159 |
--- /dev/null |
160 |
+++ b/dev-libs/libnest2d/libnest2d-0.4.ebuild |
161 |
@@ -0,0 +1,39 @@ |
162 |
+# Copyright 1999-2020 Gentoo Authors |
163 |
+# Distributed under the terms of the GNU General Public License v2 |
164 |
+ |
165 |
+EAPI=7 |
166 |
+ |
167 |
+inherit cmake |
168 |
+ |
169 |
+DESCRIPTION="Library and framework for the 2D bin packaging problem" |
170 |
+HOMEPAGE="https://github.com/tamasmeszaros/libnest2d" |
171 |
+SRC_URI="https://github.com/tamasmeszaros/libnest2d/archive/${PV}.tar.gz -> ${P}.tar.gz" |
172 |
+ |
173 |
+LICENSE="LGPL-3" |
174 |
+SLOT="0" |
175 |
+KEYWORDS="~amd64 ~x86" |
176 |
+ |
177 |
+IUSE="examples static-libs test" |
178 |
+RESTRICT="!test? ( test )" |
179 |
+ |
180 |
+RDEPEND=" |
181 |
+ dev-cpp/eigen:3 |
182 |
+ dev-libs/boost |
183 |
+ dev-libs/clipper |
184 |
+ sci-libs/nlopt |
185 |
+ " |
186 |
+DEPEND="${RDEPEND} |
187 |
+ test? ( >=dev-cpp/catch-2.9.1 ) |
188 |
+ " |
189 |
+ |
190 |
+PATCHES=( "${FILESDIR}"/${P}-add-disallowed-areas.patch ) |
191 |
+ |
192 |
+src_configure() { |
193 |
+ local mycmakeargs=( |
194 |
+ -DBUILD_SHARED_LIBS=ON |
195 |
+ -DLIBNEST2D_BUILD_EXAMPLES=$(usex examples) |
196 |
+ -DLIBNEST2D_HEADER_ONLY=$(usex static-libs OFF ON) |
197 |
+ -DLIBNEST2D_BUILD_UNITTESTS=$(usex test) |
198 |
+ ) |
199 |
+ cmake_src_configure |
200 |
+} |
201 |
|
202 |
diff --git a/dev-libs/libnest2d/metadata.xml b/dev-libs/libnest2d/metadata.xml |
203 |
new file mode 100644 |
204 |
index 00000000000..a80bd99b8c2 |
205 |
--- /dev/null |
206 |
+++ b/dev-libs/libnest2d/metadata.xml |
207 |
@@ -0,0 +1,23 @@ |
208 |
+<?xml version="1.0" encoding="UTF-8"?> |
209 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
210 |
+<pkgmetadata> |
211 |
+ <maintainer type="project"> |
212 |
+ <email>3dprint@g.o</email> |
213 |
+ <name>Gentoo 3D Printer Project</name> |
214 |
+ </maintainer> |
215 |
+ <longdescription> |
216 |
+ Libnest2D is a library and framework for the 2D bin packaging problem. Inspired from the SVGNest Javascript |
217 |
+ library the project is built from scratch in C++11. The library is written with a policy that it should be |
218 |
+ usable out of the box with a very simple interface but has to be customizable to the very core as well. The |
219 |
+ algorithms are defined in a header only fashion with templated geometry types. These geometries can have custom |
220 |
+ or already existing implementation to avoid copying or having unnecessary dependencies. |
221 |
+ |
222 |
+ A default backend is provided if the user of the library just wants to use it out of the box without additional |
223 |
+ integration. This backend is reasonably fast and robust, being built on top of boost geometry and the |
224 |
+ polyclipping library. Usage of this default backend implies the dependency on these packages but its header only |
225 |
+ as well. |
226 |
+ </longdescription> |
227 |
+ <upstream> |
228 |
+ <remote-id type="github">tamasmeszaros/libnest2d</remote-id> |
229 |
+ </upstream> |
230 |
+</pkgmetadata> |