v0.3.0
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 ** Copyright (c) 2016, Fougue Ltd. <http://www.fougue.pro>
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 **
9 ** 1. Redistributions of source code must retain the above copyright
10 ** notice, this list of conditions and the following disclaimer.
11 **
12 ** 2. Redistributions in binary form must reproduce the above
13 ** copyright notice, this list of conditions and the following
14 ** disclaimer in the documentation and/or other materials provided
15 ** with the distribution.
16 **
17 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ****************************************************************************/
29 
46 #ifndef __cplusplus
47 # error C++ compiler required
48 #endif
49 
50 #ifndef GMIO_SUPPORT_STL_OCC_MESH_H
51 #define GMIO_SUPPORT_STL_OCC_MESH_H
52 
53 #include "support_global.h"
54 #include "../gmio_stl/stl_mesh.h"
55 #include "../gmio_stl/stl_mesh_creator.h"
56 
57 #include <vector>
58 
59 #include <BRepBuilderAPI_CellFilter.hxx>
60 #include <BRepBuilderAPI_VertexInspector.hxx>
61 #include <StlMesh_Mesh.hxx>
62 #include <StlMesh_MeshTriangle.hxx>
63 #include <TColgp_SequenceOfXYZ.hxx>
64 
78 {
80  explicit gmio_stl_mesh_occmesh(const StlMesh_Mesh* mesh);
81  explicit gmio_stl_mesh_occmesh(const Handle_StlMesh_Mesh& hnd);
82 
83  inline const StlMesh_Mesh* mesh() const { return m_mesh; }
84 
85 private:
86  static void get_triangle(
87  const void* cookie, uint32_t tri_id, gmio_stl_triangle* tri);
88 
89  void init_C_members();
90  void init_cache();
91 
92  struct domain_data {
93  std::vector<const gp_XYZ*> vec_coords;
94  };
95 
96  struct triangle_data {
97  const StlMesh_MeshTriangle* ptr_triangle;
98  const domain_data* ptr_domain;
99  };
100 
101  const StlMesh_Mesh* m_mesh;
102  std::vector<domain_data> m_vec_domain_data;
103  std::vector<triangle_data> m_vec_triangle_data;
104 };
105 
124 {
126  explicit gmio_stl_mesh_creator_occmesh(StlMesh_Mesh* mesh);
127  explicit gmio_stl_mesh_creator_occmesh(const Handle_StlMesh_Mesh& hnd);
128 
129  inline StlMesh_Mesh* mesh() const { return m_mesh; }
130 
131 private:
132  static void begin_solid(
133  void* cookie, const struct gmio_stl_mesh_creator_infos* infos);
134  static void add_triangle(
135  void* cookie, uint32_t tri_id, const gmio_stl_triangle* tri);
136 
137  void init_C_members();
138  int add_unique_vertex(const gmio_vec3f& v);
139 
140  StlMesh_Mesh* m_mesh;
141  BRepBuilderAPI_CellFilter m_filter;
142  BRepBuilderAPI_VertexInspector m_inspector;
143 };
144 
145 #endif /* GMIO_SUPPORT_STL_OCC_MESH_H */
146 
Provides creation of a new domain within an StlMesh_Mesh object.
Definition: stl_occ_mesh.h:123
const StlMesh_Mesh * mesh() const
Definition: stl_occ_mesh.h:83
Vector of three float coords.
Definition: vecgeom.h:41
Provides an interface for accessing the underlying(hidden) user mesh.
Definition: stl_mesh.h:44
const void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh.h:48
void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh_creator.h:89
STL mesh triangle.
Definition: stl_triangle.h:44
Provides access to all the triangles of OpenCascade's StlMesh_Mesh.
Definition: stl_occ_mesh.h:77
Provides an interface for the creation of the underlying(hidden) user mesh.
Definition: stl_mesh_creator.h:85
Global declarations for the support module.
StlMesh_Mesh * mesh() const
Definition: stl_occ_mesh.h:129
Informations about the STL stream, used in gmio_stl_mesh_creator::func_begin_solid() ...
Definition: stl_mesh_creator.h:50
Fougue © 2016