v0.2.1
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
stl_occ_mesh.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** gmio
3 ** Copyright Fougue (24 Jun. 2016)
4 ** contact@fougue.pro
5 **
6 ** This software is a reusable library whose purpose is to provide complete
7 ** I/O support for various CAD file formats (eg. STL)
8 **
9 ** This software is governed by the CeCILL-B license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-B
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
14 ****************************************************************************/
15 
32 #ifndef __cplusplus
33 # error C++ compiler required
34 #endif
35 
36 #ifndef GMIO_SUPPORT_STL_OCC_MESH_H
37 #define GMIO_SUPPORT_STL_OCC_MESH_H
38 
39 #include "support_global.h"
40 #include "../gmio_stl/stl_mesh.h"
41 #include "../gmio_stl/stl_mesh_creator.h"
42 
43 #include <vector>
44 
45 #include <BRepBuilderAPI_CellFilter.hxx>
46 #include <BRepBuilderAPI_VertexInspector.hxx>
47 #include <StlMesh_Mesh.hxx>
48 #include <StlMesh_MeshTriangle.hxx>
49 #include <TColgp_SequenceOfXYZ.hxx>
50 
64 {
66  explicit gmio_stl_mesh_occmesh(const StlMesh_Mesh* mesh);
67  explicit gmio_stl_mesh_occmesh(const Handle_StlMesh_Mesh& hnd);
68 
69  inline const StlMesh_Mesh* mesh() const { return m_mesh; }
70 
71 private:
72  static void get_triangle(
73  const void* cookie, uint32_t tri_id, gmio_stl_triangle* tri);
74 
75  void init_C_members();
76  void init_cache();
77 
78  struct domain_data {
79  std::vector<const gp_XYZ*> vec_coords;
80  };
81 
82  struct triangle_data {
83  const StlMesh_MeshTriangle* ptr_triangle;
84  const domain_data* ptr_domain;
85  };
86 
87  const StlMesh_Mesh* m_mesh;
88  std::vector<domain_data> m_vec_domain_data;
89  std::vector<triangle_data> m_vec_triangle_data;
90 };
91 
110 {
112  explicit gmio_stl_mesh_creator_occmesh(StlMesh_Mesh* mesh);
113  explicit gmio_stl_mesh_creator_occmesh(const Handle_StlMesh_Mesh& hnd);
114 
115  inline StlMesh_Mesh* mesh() const { return m_mesh; }
116 
117 private:
118  static void begin_solid(
119  void* cookie, const struct gmio_stl_mesh_creator_infos* infos);
120  static void add_triangle(
121  void* cookie, uint32_t tri_id, const gmio_stl_triangle* tri);
122 
123  void init_C_members();
124  int add_unique_vertex(const gmio_vec3f& v);
125 
126  StlMesh_Mesh* m_mesh;
127  BRepBuilderAPI_CellFilter m_filter;
128  BRepBuilderAPI_VertexInspector m_inspector;
129 };
130 
131 #endif /* GMIO_SUPPORT_STL_OCC_MESH_H */
132 
Provides creation of a new domain within an StlMesh_Mesh object.
Definition: stl_occ_mesh.h:109
const StlMesh_Mesh * mesh() const
Definition: stl_occ_mesh.h:69
Vector of three float coords.
Definition: vecgeom.h:27
Provides an interface for accessing the underlying(hidden) user mesh.
Definition: stl_mesh.h:30
const void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh.h:34
void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh_creator.h:75
STL mesh triangle.
Definition: stl_triangle.h:30
Provides access to all the triangles of OpenCascade's StlMesh_Mesh.
Definition: stl_occ_mesh.h:63
Provides an interface for the creation of the underlying(hidden) user mesh.
Definition: stl_mesh_creator.h:71
Global declarations for the support module.
StlMesh_Mesh * mesh() const
Definition: stl_occ_mesh.h:115
Informations about the STL stream, used in gmio_stl_mesh_creator::func_begin_solid() ...
Definition: stl_mesh_creator.h:36
Fougue © 2016