コード例 #1
0
ファイル: GeoTreeModel.cpp プロジェクト: envinf/ogs
void GeoTreeModel::addChildren(GeoObjectListItem* sfcList,
                               GeoLib::SurfaceVec const& surface_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Surface*>* surfaces = surface_vec.getVector();

	const std::vector<GeoLib::Point*> &nodesVec(*((*surfaces)[start_index]->getPointVec()));
	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> surface;
		surface.reserve(4);
		surface << "Surface " + QString::number(i) << "" <<
		"" << "";

		const GeoLib::Surface &sfc(*(*surfaces)[i]);
		GeoTreeItem* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc));
		sfcList->appendChild(surfaceItem);

		int nElems = static_cast<int>((*surfaces)[i]->getNTriangles());
		for (int j = 0; j < nElems; j++)
		{
			QList<QVariant> elem;
			elem.reserve(4);
			const GeoLib::Triangle &triangle(*sfc[j]);
			elem << j << static_cast<int>(triangle[0])
			     << static_cast<int>(triangle[1])
			     << static_cast<int>(triangle[2]);
			TreeItem* child(new TreeItem(elem, surfaceItem));
			surfaceItem->appendChild(child);

			for (int k = 0; k < 3; k++)
			{
				QList<QVariant> node;
				node.reserve(4);
				const GeoLib::Point &pnt(*(nodesVec[triangle[k]]));
				node << static_cast<int>(triangle[k])
				     << QString::number(pnt[0], 'f')
				     << QString::number(pnt[1], 'f')
				     << QString::number(pnt[2], 'f');
				child->appendChild(new TreeItem(node, child));
			}
		}
	}

	for (auto pnt = surface_vec.getNameIDMapBegin(); pnt != surface_vec.getNameIDMapEnd(); ++pnt)
		QVariant pnt_data (sfcList->child(pnt->second)->setData(1, QString::fromStdString(pnt->first)));

	INFO("%d surfaces added.", end_index - start_index);
}
コード例 #2
0
ファイル: GeoTreeModel.cpp プロジェクト: Stefan6/ogs
void GeoTreeModel::addChildren(GeoObjectListItem* sfcList,
                               const GeoLib::SurfaceVec* surface_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Surface*>* surfaces = surface_vec->getVector();

	const std::vector<GeoLib::Point*> &nodesVec(*((*surfaces)[start_index]->getPointVec()));
	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> surface;
		std::string sfc_name("");
		surface_vec->getNameOfElementByID(i, sfc_name);
		surface << "Surface " + QString::number(i) << QString::fromStdString(sfc_name) <<
		"" << "";

		const GeoLib::Surface &sfc(*(*surfaces)[i]);
		GeoTreeItem* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc));
		sfcList->appendChild(surfaceItem);

		int nElems = static_cast<int>((*surfaces)[i]->getNTriangles());
		for (int j = 0; j < nElems; j++)
		{
			QList<QVariant> elem;
			const GeoLib::Triangle &triangle(*sfc[j]);
			elem << j << static_cast<int>(triangle[0])
			     << static_cast<int>(triangle[1])
			     << static_cast<int>(triangle[2]);
			TreeItem* child(new TreeItem(elem, surfaceItem));
			surfaceItem->appendChild(child);

			for (int k = 0; k < 3; k++)
			{
				QList<QVariant> node;
				const GeoLib::Point &pnt(*(nodesVec[triangle[k]]));
				node << static_cast<int>(triangle[k])
				     << QString::number(pnt[0], 'f')
				     << QString::number(pnt[1], 'f')
				     << QString::number(pnt[2], 'f');
				TreeItem* nchild(new TreeItem(node, child));
				child->appendChild(nchild);
			}
		}
	}
	std::cout << end_index - start_index << " surfaces added." << std::endl;
}