View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0033365 | Community | OCCT:Data Exchange | public | 2023-04-13 11:16 | 2023-04-14 13:23 |
Reporter | Lyndon Alcock | Assigned To | Lyndon Alcock | ||
Priority | normal | Severity | just a question | ||
Status | feedback | Resolution | open | ||
Platform | Windows | OS | VC++ 2022 | ||
Product Version | 7.6.3 | ||||
Summary | 0033365: Data Exchange - How do I iterate over a mesh without doubling model edge vertices in open cascade? | ||||
Description | Currently I am working on exporting from open cascade to off format however i cannot find within the API a way of iterating over all the indices in the model, my current work around is to use ```BRep_Tool::Triangulation(face, location)``` for each of the faces in the BRep however this is creating duplicate vertices for every vertex on the edge of the face, ideally i would like something that iterates over all of the vertices and faces in the model? this is the current working code std::vector<double> vertices; std::vector<int> indices; int index_count = 0; int triangle_count = 0; for (TopExp_Explorer explorer(shape, TopAbs_FACE); explorer.More(); explorer.Next()) { TopoDS_Face face = TopoDS::Face(explorer.Current()); TopAbs_Orientation face_orientation = face.Orientation(); TopLoc_Location location; Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(face, location); if (!triangulation.IsNull()) { int nb_nodes = triangulation->NbNodes(); for (int node_index = 1; node_index <= nb_nodes; node_index++) { gp_Pnt node = triangulation->Node(node_index); vertices.push_back(node.X()); vertices.push_back(node.Y()); vertices.push_back(node.Z()); } int nb_triangles = triangulation->NbTriangles(); for (int triangle_index = 1; triangle_index <= nb_triangles; triangle_index++) { int i0, i1, i2; Poly_Triangle triangle = triangulation->Triangle(triangle_index); triangle.Get(i0, i1, i2); indices.push_back(i0 - 1 + index_count); indices.push_back(i1 - 1 + index_count); indices.push_back(i2 - 1 + index_count); } index_count += nb_nodes; triangle_count += nb_triangles; } } ideally I would like get the triangulation of the whole model which I imagine would look something like this ```BRep_Tool::Triangulation(shape, location);```, however this does not exist? | ||||
Tags | No tags attached. | ||||
Test case number | |||||
|
Dear @Lyndon Alcock We do not have functionality to get whole triangulation of the model. But You can use code samples about writing mesh into some other formats, please make a look into: occt\src\RWObj\RWObj_CafWriter.cxx occt\src\RWGltf\RWGltf_CafWriter.cxx occt\src\RWPly\RWPly_CafWriter.cxx We use RWMesh_FaceIterator and some additional tools for this. |
|
Dear @Lyndon Alcock Please use the forum for technical questions: https://dev.opencascade.org/forums |
|
I've managed to get it to work by storing double vertices as a map and converting the indices when exporting the code :) |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-04-13 11:16 | Lyndon Alcock | New Issue | |
2023-04-13 11:16 | Lyndon Alcock | Assigned To | => ika |
2023-04-13 13:18 | dpasukhi | Category | OCCT:Application Framework => OCCT:Data Exchange |
2023-04-13 13:18 | dpasukhi | Summary | How do I iterate over a mesh without doubling model edge vertices in open cascade? => Data Exchange - How do I iterate over a mesh without doubling model edge vertices in open cascade? |
2023-04-13 13:18 | dpasukhi | Description Updated | |
2023-04-13 13:18 | dpasukhi | Description Updated | |
2023-04-13 13:21 | dpasukhi | Note Added: 0113380 | |
2023-04-13 13:21 | dpasukhi | Assigned To | ika => Lyndon Alcock |
2023-04-13 13:21 | dpasukhi | Status | new => feedback |
2023-04-13 13:22 | dpasukhi | Note Added: 0113381 | |
2023-04-14 13:23 | Lyndon Alcock | Note Added: 0113382 |