17 QList<QVariant> rootData;
34 auto const& points = pointVec.
getVector();
36 QList<QVariant> geoData;
37 geoData << QVariant(geoName) <<
""
45 QList<QVariant> pointData;
53 geo->appendChild(pointList);
55 std::size_t nPoints = points.size();
57 for (std::size_t j = 0; j < nPoints; j++)
60 QList<QVariant> pnt_data;
62 pnt_data << static_cast<unsigned>(j) << QString::number(pnt[0],
'f')
63 << QString::number(pnt[1],
'f') << QString::number(pnt[2],
'f')
66 pnt_data, pointList,
static_cast<const GeoLib::Point*
>(&pnt)));
73 QVariant pnt_data(pointList->child(pnt->second)
74 ->setData(4, QString::fromStdString(pnt->first)));
77 INFO(
"Geometry '{:s}' built. {:d} points added.", geoName.toStdString(),
90 for (
int i = 0; i < nLists; i++)
92 if (
_rootItem->child(i)->data(0).toString().compare(geoName) == 0)
100 ERR(
"GeoTreeModel::addPolylineList(): No corresponding geometry for "
102 geoName.toStdString());
106 auto const& lines = polylineVec.
getVector();
108 QList<QVariant> plyData;
109 plyData <<
"Polylines"
126 if (name == list->data(0).toString().toStdString())
128 for (
int j = 0; j < list->childCount(); j++)
137 parent->vtkSource()->Modified();
148 std::size_t start_index,
149 std::size_t end_index)
151 auto const& lines = polyline_vec.
getVector();
153 for (std::size_t i = start_index; i < end_index; i++)
155 QList<QVariant> line_data;
156 line_data.reserve(4);
157 line_data <<
"Line " + QString::number(i) <<
""
162 auto* lineItem(
new GeoTreeItem(line_data, plyList, &line));
165 auto nPoints =
static_cast<int>(lines[i]->getNumberOfPoints());
166 for (
int j = 0; j < nPoints; j++)
169 QList<QVariant> pnt_data;
171 pnt_data << static_cast<int>(line.
getPointID(j))
172 << QString::number(pnt[0],
'f')
173 << QString::number(pnt[1],
'f')
174 << QString::number(pnt[2],
'f');
176 lineItem->appendChild(
new TreeItem(pnt_data, lineItem));
184 QVariant pnt_data(plyList->
child(pnt->second)
185 ->
setData(1, QString::fromStdString(pnt->first)));
188 INFO(
"{:d} polylines added.", end_index - start_index);
198 for (
int i = 0; i < nLists; i++)
200 if (
_rootItem->child(i)->data(0).toString().compare(geoName) == 0)
208 ERR(
"GeoTreeModel::addSurfaceList(): No corresponding geometry for "
210 geoName.toStdString());
214 auto const& surfaces = surfaceVec.
getVector();
216 QList<QVariant> sfcData;
217 sfcData <<
"Surfaces"
234 if (name == list->data(0).toString().toStdString())
236 int nChildren = list->childCount();
237 for (
int j = 0; j < nChildren; j++)
245 parent->vtkSource()->Modified();
257 std::size_t start_index,
258 std::size_t end_index)
260 auto const& surfaces = surface_vec.
getVector();
262 const std::vector<GeoLib::Point*>& nodesVec(
263 *(surfaces[start_index]->getPointVec()));
264 for (std::size_t i = start_index; i < end_index; i++)
266 QList<QVariant> surface;
268 surface <<
"Surface " + QString::number(i) <<
""
273 auto* surfaceItem(
new GeoTreeItem(surface, sfcList, &sfc));
276 auto nElems =
static_cast<int>(surfaces[i]->getNumberOfTriangles());
277 for (
int j = 0; j < nElems; j++)
279 QList<QVariant> elem;
282 elem << j << static_cast<int>(triangle[0])
283 <<
static_cast<int>(triangle[1])
284 <<
static_cast<int>(triangle[2]);
285 auto* child(
new TreeItem(elem, surfaceItem));
286 surfaceItem->appendChild(child);
288 for (
int k = 0; k < 3; k++)
290 QList<QVariant> node;
293 node << static_cast<int>(triangle[k])
294 << QString::number(pnt[0],
'f')
295 << QString::number(pnt[1],
'f')
296 << QString::number(pnt[2],
'f');
297 child->appendChild(
new TreeItem(node, child));
306 QVariant pnt_data(sfcList->
child(pnt->second)
307 ->
setData(1, QString::fromStdString(pnt->first)));
310 INFO(
"{:d} surfaces added.", end_index - start_index);
314 std::string
const& new_name)
316 for (
auto tree_item_entry :
_lists)
318 if (old_name == tree_item_entry->data(0).toString().toStdString())
320 QVariant new_entry(QString::fromStdString(new_name));
321 tree_item_entry->setData(0, new_entry);
325 for (
auto tree_item_entry :
_lists)
327 if (new_name == tree_item_entry->data(0).toString().toStdString())
329 INFO(
"Found tree_item_entry with name '{:s}'.", new_name);
339 for (std::size_t i = 0; i <
_lists.size(); i++)
341 if (name ==
_lists[i]->
data(0).toString().toStdString())
343 for (
int j = 0; j <
_lists[i]->childCount(); j++)
348 QModelIndex
index = createIndex(j, 0,
_lists[i]->child(j));
354 if (
_lists[i]->childCount() == 0)
366 std::size_t nLists =
_lists.size();
367 for (std::size_t i = 0; i < nLists; i++)
369 if (name ==
_lists[i]->
data(0).toString().toStdString())
371 for (
int j = 0; j <
_lists[i]->childCount(); j++)
375 if (item->getType() == type)
377 return item->vtkSource();
388 std::string item_name)
390 std::string geo_type_str;
396 geo_type_str =
"Points";
400 geo_type_str =
"Polylines";
403 geo_type_str =
"Surfaces";
412 { return (name == geo->data(0).toString().toStdString()); });
414 for (
int i = 0; i < (*it)->childCount(); i++)
416 if (geo_type_str == (*it)->child(i)->data(0).toString().toStdString())
419 item->
setData(col_idx, QString::fromStdString(item_name));
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::size_t getPointID(std::size_t const i) const
const Point * getPoint(std::size_t i) const
returns the i-th point contained in the polyline
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
NameIdMap::const_iterator getNameIDMapBegin() const
Returns the begin of the name id mapping structure.
std::vector< T * > const & getVector() const
NameIdMap::const_iterator getNameIDMapEnd() const
Returns the end of the name id mapping structure.
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
A TreeItem containing an additional GeoObject.
void appendPolylines(const std::string &name, GeoLib::PolylineVec const &polylineVec)
Appends polylines to the "Polyline"-subtree.
void addSurfaceList(QString geoName, GeoLib::SurfaceVec const &surfaceVec)
Adds a subtree "Surfaces" to an existing geometry with the given name.
void addPointList(QString geoName, GeoLib::PointVec const &pointVec)
vtkPolyDataAlgorithm * vtkSource(const std::string &name, GeoLib::GEOTYPE type) const
Returns the vtk-object indicated by type of the geometry indicated by name.
void renameGeometry(std::string const &old_name, std::string const &new_name)
void appendSurfaces(const std::string &name, GeoLib::SurfaceVec const &surfaceVec)
Appends surfaces to the "Surface"-subtree.
void setNameForItem(const std::string &name, GeoLib::GEOTYPE type, std::size_t id, std::string item_name)
void addPolylineList(QString geoName, GeoLib::PolylineVec const &polylineVec)
Adds a subtree "Polylines" to an existing geometry with the given name.
void addChildren(GeoObjectListItem *plyList, GeoLib::PolylineVec const &polyline_vec, std::size_t start_index, std::size_t end_index)
Adds children to the "Polylines" node.
void removeGeoList(const std::string &name, GeoLib::GEOTYPE type)
GeoTreeModel(QObject *parent=nullptr)
std::vector< GeoTreeItem * > _lists
static void box(const QString &e)
Objects nodes for the TreeModel.
void appendChild(TreeItem *item)
TreeItem * child(int row) const
virtual bool setData(int column, const QVariant &value)
bool removeRows(int position, int count, const QModelIndex &parent) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex parent(const QModelIndex &index) const override
TreeModel(QObject *parent=nullptr)
TemplateVec< GeoLib::Surface > SurfaceVec
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...