ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
AssimpIfc.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "AssimpIfc.h"
9 
10 #include <QCoreApplication>
11 #include <QString>
12 
15  QStringList{"ifc", "stp", "step"}, "ifc",
16  QStringList{"qMeshIO - IFC file (*.ifc *.stp *.step)"},
17  QStringList(), Import}),
18  mNameMatcher("^(?<type>Ifc[^_]+)_(?<name>.*)_(?<guid>.{22})$") {
19  mNameMatcher.optimize();
20 }
21 
22 void AssimpIfc::_postProcess(ccHObject &ioContainer) {
23  _recursiveRename(&ioContainer);
24 }
25 
26 void AssimpIfc::_recursiveRename(ccHObject *ioContainer) {
27  const auto cChildCount = ioContainer->getChildrenNumber();
28 
29  for (unsigned int i = 0; i < cChildCount; ++i) {
30  _recursiveRename(ioContainer->getChild(i));
31  }
32 
33  if (ioContainer->getName() == QLatin1String("$RelAggregates")) {
34  ioContainer->setName(
35  QCoreApplication::translate("qMeshIO", "Unnamed Group"));
36  } else {
37  auto match = mNameMatcher.match(ioContainer->getName());
38 
39  if (match.hasMatch()) {
40  // Split names of the form:
41  // IfcBeam_Holzbalken-4_1X4dAmiW97Nurao$8fngpg
42  // into type, name, and GUID:
43  // IfcBeam, Holzbalken-4, 1X4dAmiW97Nurao$8fngpg
44  // Then rename our node with "name" put "type" and "GUID" into our
45  // meta data
46 
47  const QString cType = match.captured("type");
48  const QString cName = match.captured("name");
49  const QString cGUID = match.captured("guid");
50 
51  ioContainer->setMetaData("IFC Type", cType);
52  ioContainer->setMetaData("IFC GUID", cGUID);
53 
54  ioContainer->setName(cName);
55  }
56  }
57 }
static constexpr float DEFAULT_PRIORITY
Definition: FileIOFilter.h:313
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
unsigned getChildrenNumber() const
Returns the number of children.
Definition: ecvHObject.h:312
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Definition: ecvHObject.h:325
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
void setMetaData(const QString &key, const QVariant &data)
Sets a meta-data element.
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75