void GeoTreeModel::addPointList(QString geoName, const GeoLib::PointVec* pointVec) { const std::vector<GeoLib::Point*>* points = pointVec->getVector(); QList<QVariant> geoData; geoData << QVariant(geoName) << "" << "" << "" << ""; GeoTreeItem* geo (new GeoTreeItem(geoData, _rootItem)); _lists.push_back(geo); _rootItem->appendChild(geo); QList<QVariant> pointData; pointData << "Points" << "" << "" << "" << ""; GeoObjectListItem* pointList = new GeoObjectListItem(pointData, geo, points, GeoLib::POINT); geo->appendChild(pointList); size_t nPoints = points->size(); for (size_t j = 0; j < nPoints; j++) { const GeoLib::Point &pnt(*(*points)[j]); std::string pnt_name(""); pointVec->getNameOfElementByID(j, pnt_name); QList<QVariant> pnt_data; pnt_data << static_cast<unsigned>(j) << QString::number(pnt[0], 'f') << QString::number(pnt[1], 'f') << QString::number(pnt[2], 'f') << QString::fromStdString(pnt_name); GeoTreeItem* point(new GeoTreeItem(pnt_data, pointList, static_cast<const GeoLib::Point*>(&pnt))); pointList->appendChild(point); } std::cout << "Geometry \"" << geoName.toStdString() << "\" built." << std::endl; std::cout << nPoints << " points added." << std::endl; reset(); }
void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects & geo_objs, std::string &name, GeoLib::Point const& shift) { std::vector<GeoLib::Point*> *pnts(new std::vector<GeoLib::Point*>); std::map<std::string, std::size_t>* pnt_name_map(new std::map< std::string, std::size_t>); const std::size_t pnts_per_edge(8); for (std::size_t k(0); k < pnts_per_edge; k++) { const std::size_t k_offset(k * pnts_per_edge * pnts_per_edge); for (std::size_t j(0); j < pnts_per_edge; j++) { const std::size_t offset(j * pnts_per_edge + k_offset); for (std::size_t i(0); i < pnts_per_edge; i++) { pnts->push_back(new GeoLib::Point(i+shift[0], j+shift[1], k+shift[2])); std::string pnt_name( name + "-" + BaseLib::number2str(i) + "-" + BaseLib::number2str(j) + "-" + BaseLib::number2str(k)); pnt_name_map->insert(std::pair< std::string, std::size_t>(pnt_name, i + offset)); } } } geo_objs.addPointVec(pnts, name, pnt_name_map); }