MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / box_project_uvs

Method box_project_uvs

src/ifcgeom/IfcGeomRepresentation.cpp:157–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155/// @todo Very simple impl. Assumes that input vertices and normals match 1:1.
156
157std::vector<double> IfcGeom::Representation::Triangulation::box_project_uvs(const std::vector<double>& vertices, const std::vector<double>& normals)
158{
159 std::vector<double> uvs;
160 uvs.resize(vertices.size() / 3 * 2);
161 for (size_t uv_idx = 0, v_idx = 0;
162 uv_idx < uvs.size() && v_idx < vertices.size() && v_idx < normals.size();
163 uv_idx += 2, v_idx += 3) {
164
165 double n_x = normals[v_idx], n_y = normals[v_idx + 1], n_z = normals[v_idx + 2];
166 double v_x = vertices[v_idx], v_y = vertices[v_idx + 1], v_z = vertices[v_idx + 2];
167
168 if (std::abs(n_x) > std::abs(n_y) && std::abs(n_x) > std::abs(n_z)) {
169 uvs[uv_idx] = v_z;
170 uvs[uv_idx + 1] = v_y;
171 }
172 if (std::abs(n_y) > std::abs(n_x) && std::abs(n_y) > std::abs(n_z)) {
173 uvs[uv_idx] = v_x;
174 uvs[uv_idx + 1] = v_z;
175 }
176 if (std::abs(n_z) > std::abs(n_x) && std::abs(n_z) > std::abs(n_y)) {
177 uvs[uv_idx] = v_x;
178 uvs[uv_idx + 1] = v_y;
179 }
180 }
181
182 return uvs;
183}
184
185int IfcGeom::Representation::Triangulation::addVertex(int item_id, int material_index, double pX, double pY, double pZ) {
186 const bool convert = settings().get<ifcopenshell::geometry::settings::ConvertBackUnits>().get();

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected