-
-
Save ochafik/67416f534552dba87d4e32102f69154d to your computer and use it in GitHub Desktop.
OpenSCAD Manifold rejects / deleted code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::shared_ptr<manifold::Mesh> meshFromPolySet(const PolySet& ps) { | |
| IndexedMesh im; | |
| { | |
| PolySet triangulated(3); | |
| PolySetUtils::tessellate_faces(ps, triangulated); | |
| im.append_geometry(triangulated); | |
| } | |
| auto numfaces = im.numfaces; | |
| const auto &vertices = im.vertices.getArray(); | |
| const auto &indices = im.indices; | |
| auto mesh = make_shared<manifold::Mesh>(); | |
| mesh->vertPos.resize(vertices.size()); | |
| mesh->triVerts.resize(numfaces); | |
| for (size_t i = 0, n = vertices.size(); i < n; i++) { | |
| const auto &v = vertices[i]; | |
| mesh->vertPos[i] = glm::vec3((float) v.x(), (float) v.y(), (float) v.z()); | |
| } | |
| const auto vertexCount = mesh->vertPos.size(); | |
| assert(indices.size() == numfaces * 4); | |
| for (size_t i = 0; i < numfaces; i++) { | |
| auto offset = i * 4; // 3 indices of triangle then -1. | |
| auto i0 = indices[offset]; | |
| auto i1 = indices[offset + 1]; | |
| auto i2 = indices[offset + 2]; | |
| assert(indices[offset + 3] == -1); | |
| assert(i0 >= 0 && i0 < vertexCount && | |
| i1 >= 0 && i1 < vertexCount && | |
| i2 >= 0 && i2 < vertexCount); | |
| assert(i0 != i1 && i0 != i2 && i1 != i2); | |
| mesh->triVerts[i] = {i0, i1, i2}; | |
| } | |
| return mesh; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment