v0.4.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 ** Copyright (c) 2017, 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 #pragma once
51 
52 #include "support_global.h"
53 #include "../gmio_stl/stl_mesh.h"
54 #include "../gmio_stl/stl_mesh_creator.h"
55 
56 #include <BRepBuilderAPI_CellFilter.hxx>
57 #include <BRepBuilderAPI_VertexInspector.hxx>
58 #include <StlMesh_Mesh.hxx>
59 #include <StlMesh_MeshTriangle.hxx>
60 #include <TColgp_SequenceOfXYZ.hxx>
61 #include <vector>
62 
76 {
78  explicit gmio_stl_mesh_occmesh(const Handle_StlMesh_Mesh& hnd);
79 
80  const Handle_StlMesh_Mesh& mesh() const { return m_mesh; }
81 
82 private:
83  static void get_triangle(
84  const void* cookie, uint32_t tri_id, gmio_stl_triangle* tri);
85 
86  void init();
87 
88  struct domain_data {
89  std::vector<const gp_XYZ*> vec_coords;
90  };
91 
92  struct triangle_data {
93  const StlMesh_MeshTriangle* ptr_triangle;
94  const domain_data* ptr_domain;
95  };
96 
97  Handle_StlMesh_Mesh m_mesh;
98  std::vector<domain_data> m_vec_domain_data;
99  std::vector<triangle_data> m_vec_triangle_data;
100 };
101 
120 {
122  explicit gmio_stl_mesh_creator_occmesh(const Handle_StlMesh_Mesh& hnd);
123 
124  const Handle_StlMesh_Mesh& mesh() const { return m_mesh; }
125 
126 private:
127  static void begin_solid(
128  void* cookie, const struct gmio_stl_mesh_creator_infos* infos);
129  static void add_triangle(
130  void* cookie, uint32_t tri_id, const gmio_stl_triangle* tri);
131 
132  void init();
133  int add_unique_vertex(const gmio_vec3f& v);
134 
135  Handle_StlMesh_Mesh m_mesh;
136  BRepBuilderAPI_CellFilter m_filter;
137  BRepBuilderAPI_VertexInspector m_inspector;
138 };
139 
Provides creation of a new domain within an OpenCascade StlMesh_Mesh.
Definition: stl_occ_mesh.h:119
const Handle_StlMesh_Mesh & mesh() const
Definition: stl_occ_mesh.h:80
Vector of three float coords.
Definition: vecgeom.h:40
Provides an interface for accessing the underlying(hidden) user mesh.
Definition: stl_mesh.h:43
const void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh.h:47
void * cookie
Opaque pointer on the user mesh, passed as first argument to hook functions.
Definition: stl_mesh_creator.h:82
STL mesh triangle.
Definition: stl_triangle.h:43
const Handle_StlMesh_Mesh & mesh() const
Definition: stl_occ_mesh.h:124
Provides access to all the triangles of an OpenCascade StlMesh_Mesh.
Definition: stl_occ_mesh.h:75
Provides an interface for the creation of the underlying(hidden) user mesh.
Definition: stl_mesh_creator.h:78
Global declarations for the support module.
Informations about the STL stream, used in gmio_stl_mesh_creator::func_begin_solid() ...
Definition: stl_mesh_creator.h:49
Fougue © 2017