BOOST_AUTO_TEST_CASE(test_load_dff, DATA_TEST_PREDICATE) { { auto d = Global::get().e->data->index.openFile("landstal.dff"); LoaderDFF loader; auto m = loader.loadFromMemory(d); BOOST_REQUIRE(m.get() != nullptr); BOOST_REQUIRE(m->getFrame()); BOOST_REQUIRE(!m->getAtomics().empty()); const auto& atomic = m->getAtomics()[0]; BOOST_REQUIRE(atomic->getGeometry()); BOOST_REQUIRE(atomic->getFrame()); } }
Clump* Clump::clone() const { // Clone frame hierarchy auto newroot = rootframe_->cloneHierarchy(); auto clump = new Clump; clump->setFrame(newroot); // This isn't the most optimal implementation, but this code is likely // to be replaced soon. auto find_new_frame = [&](const ModelFramePtr& old) -> ModelFramePtr { std::queue<ModelFramePtr> open; open.push(newroot); while (!open.empty()) { auto frame = open.front(); open.pop(); if (frame->getIndex() == old->getIndex()) { return frame; } for (const auto& child : frame->getChildren()) { open.push(child); } } return nullptr; }; // Generate new atomics for (const auto& atomic : getAtomics()) { auto newatomic = atomic->clone(); // Replace the original frame with the cloned frame if (atomic->getFrame()) { newatomic->setFrame(find_new_frame(atomic->getFrame())); } clump->addAtomic(newatomic); } return clump; }