MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / GetInsertedKnotElements

Method GetInsertedKnotElements

src/LNLib/Algorithm/KnotVectorUtils.cpp:205–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205std::vector<std::vector<double>> LNLib::KnotVectorUtils::GetInsertedKnotElements(const std::vector<std::vector<double>>& knotVectors)
206{
207 std::map<double, int> finalMap;
208 for (int i = 0; i < knotVectors.size(); i++)
209 {
210 auto kv = knotVectors[i];
211 std::map<double, int> map = GetKnotMultiplicityMap(kv);
212 for (auto it = map.begin(); it != map.end(); ++it)
213 {
214 double key = it->first;
215 int count = it->second;
216 auto got = finalMap.find(key);
217 if (got == finalMap.end())
218 {
219 finalMap.insert({ key, count });
220 }
221 else
222 {
223 int currentCount = got->second;
224 if (currentCount < count)
225 {
226 finalMap[key] = count;
227 }
228 }
229 }
230 }
231
232 std::vector<std::vector<double>> result;
233 for (int i = 0; i < knotVectors.size(); i++)
234 {
235 auto kv = knotVectors[i];
236 std::map<double, int> map = GetKnotMultiplicityMap(kv);
237
238 std::vector<double> insertElements;
239 for (auto it = finalMap.begin(); it != finalMap.end(); ++it)
240 {
241 double key = it->first;
242 int count = it->second;
243
244 auto got = map.find(key);
245 if (got == map.end())
246 {
247 for (int j = 0; j < count; j++)
248 {
249 insertElements.emplace_back(key);
250 }
251 }
252 else
253 {
254 int currentCount = got->second;
255 int times = count - currentCount;
256 for (int j = 0; j < times; j++)
257 {
258 insertElements.emplace_back(key);
259 }
260 }
261 }
262 result.emplace_back(insertElements);

Callers

nothing calls this directly

Calls 1

InsertMidKnotCoreFunction · 0.85

Tested by

no test coverage detected