v0.4.1
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
stl_occ_polytri.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 <Poly_Triangulation.hxx>
59 #include <gp_XYZ.hxx>
60 #include <vector>
61 
72 {
74  explicit gmio_stl_mesh_occpolytri(const Handle_Poly_Triangulation& hnd);
75 
76  const Handle_Poly_Triangulation& polytri() const { return m_polytri; }
77 
78 private:
79  static void get_triangle(
80  const void* cookie, uint32_t tri_id, gmio_stl_triangle* tri);
81  void init();
82 
83  Handle_Poly_Triangulation m_polytri;
84  const TColgp_Array1OfPnt* m_polytri_vec_node;
85  const Poly_Array1OfTriangle* m_polytri_vec_triangle;
86  bool m_polytri_has_normals;
87  const TShort_Array1OfShortReal* m_polytri_vec_normal;
88 };
89 
100 {
101 public:
103  const Handle_Poly_Triangulation& polytri() const { return m_polytri; }
104 
105 private:
106  static void begin_solid(
107  void* cookie, const struct gmio_stl_mesh_creator_infos* infos);
108  static void add_triangle(
109  void* cookie, uint32_t tri_id, const gmio_stl_triangle* tri);
110  static void end_solid(void* cookie);
111 
112  int add_unique_vertex(const gmio_vec3f& v, const gmio_vec3f& n);
113 
114  Handle_Poly_Triangulation m_polytri;
115  BRepBuilderAPI_CellFilter m_filter;
116  BRepBuilderAPI_VertexInspector m_inspector;
117  std::vector<gp_XYZ> m_vec_node;
118  std::vector<gmio_vec3f> m_vec_normal;
119  std::vector<Poly_Triangle> m_vec_triangle;
120 };
121 
Provides access to the triangles of an OpenCascade Poly_Triangulation.
Definition: stl_occ_polytri.h:71
Vector of three float coords.
Definition: vecgeom.h:40
const Handle_Poly_Triangulation & polytri() const
Definition: stl_occ_polytri.h:103
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
Provides an interface for the creation of the underlying(hidden) user mesh.
Definition: stl_mesh_creator.h:78
const Handle_Poly_Triangulation & polytri() const
Definition: stl_occ_polytri.h:76
Provides creation of an OpenCascade Poly_Triangulation.
Definition: stl_occ_polytri.h:99
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