void LabelPainter::removeLabel(glm::mat4 MVP, Label l) { for (int i = 0; i < _labels.size(); i++) { if (_labels[i].id == l.id) { _labels.erase(_labels.begin() + i); break; } } changeLabels(MVP); }
void MultiDLA::generate(const Sizes& sizes, const RunParams& params) { double r = 0.5385; MCoord::setDefDims(3); MCoord sz; double scale = params.cellSize;// * std::sqrt(1 - 0.4 * 0.4); sz.setCoord(0, Coordinate(sizes.x * 2.0 * r / scale)); sz.setCoord(1, Coordinate(sizes.y * 2.0 * r / scale)); sz.setCoord(2, Coordinate(sizes.z * 2.0 * r / scale)); std::vector<double> composition; double porosity = 0.0; composition.push_back(params.porosity); porosity += params.porosity; if (porosity <= 0 || porosity >= 1) { std::cout << "Wrong porosity!" << std::endl; return; } m_finished = false; // clean up if (m_fld) { delete m_fld; } #ifndef _WIN32 uint32_t t0 = uint32_t(clock()); #endif m_fld = new CellsField(sz, MCoord(), params.cellSize); std::cout << "DLA" << std::endl; cMultiDLA(m_fld, params.porosity, params.init, params.step, params.hit); std::cout << "Aggregation" << std::endl; clusterAggregation(m_fld, params.cluster); for (FieldElement i = 1; i < composition.size(); ++i) { std::cout << "Change labels " << composition[i] << std::endl; changeLabels(m_fld, composition[i], i); } #ifndef _WIN32 std::cout << "Прошло: " << double(clock() - t0) / CLOCKS_PER_SEC << " сек." << std::endl; #endif if (m_cancel) { QMetaObject::invokeMethod(m_mainwindow, "setProgress", Qt::QueuedConnection, Q_ARG(int, 0)); std::cout << "Canceled!" << std::endl; m_cancel = false; return; } //PrintField(fld); // save field to file //fld->tofile(fileName.c_str()); m_finished = true; QMetaObject::invokeMethod(m_mainwindow, "restructGL", Qt::QueuedConnection); std::cout << "Done" << std::endl; }
void LabelPainter::addLabel(glm::mat4 MVP, Label l) { bool notIn = true; for (int i = 0; i < _labels.size(); i++) { if (_labels[i].id == l.id) { notIn = false; } } if (notIn) { _labels.push_back(l); changeLabels(MVP); } }
void LabelPainter::updateMVP(glm::mat4 MVP) { changeLabels(MVP); }