| 137 | } |
| 138 | |
| 139 | IfcComposedMesh IfcGeometryProcessor::GetMesh(uint32_t expressID) |
| 140 | { |
| 141 | spdlog::debug("[GetMesh({})]", expressID); |
| 142 | auto lineType = _loader.GetLineType(expressID); |
| 143 | auto &relVoids = _cache.GetRelVoids(); |
| 144 | |
| 145 | IfcComposedMesh mesh; |
| 146 | mesh.expressID = expressID; |
| 147 | std::optional<glm::dvec4> generatedColor = GetStyleItemFromExpressId(expressID); |
| 148 | if (!generatedColor) |
| 149 | { |
| 150 | mesh.color = glm::dvec4(1.0); |
| 151 | mesh.hasColor = false; |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | mesh.color = generatedColor.value(); |
| 156 | mesh.hasColor = true; |
| 157 | } |
| 158 | |
| 159 | mesh.transformation = glm::dmat4(1); |
| 160 | |
| 161 | if (_schemaManager.IsIfcElement(lineType)) |
| 162 | { |
| 163 | _loader.MoveToArgumentOffset(expressID, 5); |
| 164 | uint32_t localPlacement = 0; |
| 165 | if (_loader.GetTokenType() == parsing::IfcTokenType::REF) |
| 166 | { |
| 167 | _loader.StepBack(); |
| 168 | localPlacement = _loader.GetRefArgument(); |
| 169 | } |
| 170 | uint32_t ifcPresentation = 0; |
| 171 | if (_loader.GetTokenType() == parsing::IfcTokenType::REF) |
| 172 | { |
| 173 | _loader.StepBack(); |
| 174 | ifcPresentation = _loader.GetRefArgument(); |
| 175 | } |
| 176 | |
| 177 | if (localPlacement != 0 && _loader.IsValidExpressID(localPlacement)) |
| 178 | { |
| 179 | mesh.transformation = _geometryLoader.GetLocalPlacement(localPlacement); |
| 180 | } |
| 181 | |
| 182 | if (ifcPresentation != 0 && _loader.IsValidExpressID(ifcPresentation)) |
| 183 | { |
| 184 | mesh.children.push_back(GetMesh(ifcPresentation)); |
| 185 | } |
| 186 | |
| 187 | auto relVoidsIt = relVoids.find(expressID); |
| 188 | if (relVoidsIt != relVoids.end() && !relVoidsIt->second.empty()) |
| 189 | { |
| 190 | auto origin = GetOrigin(mesh, _expressIDToGeometry); |
| 191 | auto normalizeMat = glm::translate(-origin); |
| 192 | |
| 193 | std::vector<IfcGeometry> voidGeoms; |
| 194 | |
| 195 | for (auto relVoidExpressID : relVoidsIt->second) |
| 196 | { |