t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_geometry_cad.hxx
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
29 #ifndef T8_GEOMETRY_CAD_HXX
30 #define T8_GEOMETRY_CAD_HXX
31 
32 #include <t8.h>
36 
37 #if T8_WITH_OCC
38 
39 #include <TopoDS_Shape.hxx>
40 #include <TopExp.hxx>
41 #include <gp_Pnt.hxx>
42 #include <Geom_Curve.hxx>
43 #include <Geom_Surface.hxx>
44 
50 {
51  public:
64  t8_geometry_cad (int dim, std::string fileprefix, std::string name = "t8_geom_cad");
65 
79  t8_geometry_cad (int dim, const TopoDS_Shape cad_shape, std::string name = "t8_geom_cad");
80 
85  t8_geometry_cad (int dim);
86 
88  virtual ~t8_geometry_cad ()
89  {
90  /* Nothing to do. */
91  }
92 
97  inline t8_geometry_type_t
99  {
100  return T8_GEOMETRY_TYPE_CAD;
101  };
102 
111  virtual void
112  t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
113  double *out_coords) const;
114 
124  virtual void
125  t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
126  double *jacobian) const;
127 
135  virtual void
137 
142  int
143  t8_geom_is_line (const int curve_index) const;
144 
149  int
150  t8_geom_is_plane (const int surface_index) const;
151 
156  const gp_Pnt
157  t8_geom_get_cad_point (const int index) const;
158 
163  const Handle_Geom_Curve
164  t8_geom_get_cad_curve (const int index) const;
165 
170  const Handle_Geom_Surface
171  t8_geom_get_cad_surface (const int index) const;
172 
176  const TopTools_IndexedMapOfShape
178 
182  const TopTools_IndexedMapOfShape
184 
188  const TopTools_IndexedMapOfShape
190 
196  int
197  t8_geom_get_common_edge (const int vertex1_index, const int vertex2_index) const;
198 
204  int
205  t8_geom_get_common_face (const int edge1_index, const int edge2_index) const;
206 
212  int
213  t8_geom_is_vertex_on_edge (const int vertex_index, const int edge_index) const;
214 
220  int
221  t8_geom_is_edge_on_face (const int edge_index, const int face_index) const;
222 
228  int
229  t8_geom_is_vertex_on_face (const int vertex_index, const int face_index) const;
230 
237  void
238  t8_geom_get_parameter_of_vertex_on_edge (const int vertex_index, const int edge_index, double *edge_param) const;
239 
246  void
247  t8_geom_get_parameters_of_vertex_on_face (const int vertex_index, const int face_index, double *face_params) const;
248 
263  void
264  t8_geom_edge_parameter_to_face_parameters (const int edge_index, const int face_index, const int num_face_nodes,
265  const double edge_param, const double *surface_params,
266  double *face_params) const;
267 
272  void
273  t8_geom_get_face_parametric_bounds (const int surface_index, double *bounds) const;
274 
279  void
280  t8_geom_get_edge_parametric_bounds (const int edge_index, double *bounds) const;
281 
286  int
287  t8_geom_is_edge_closed (int edge_index) const;
288 
295  int
296  t8_geom_is_surface_closed (int geometry_index, int parameter) const;
297 
298  private:
307  void
308  t8_geom_evaluate_cad_tri (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
309  double *out_coords) const;
310 
319  void
320  t8_geom_evaluate_cad_quad (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
321  double *out_coords) const;
322 
331  void
332  t8_geom_evaluate_cad_tet (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
333  double *out_coords) const;
334 
343  void
344  t8_geom_evaluate_cad_hex (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
345  double *out_coords) const;
346 
347  const int *edges;
348  const int *faces;
349  TopoDS_Shape cad_shape;
350  TopTools_IndexedMapOfShape cad_shape_vertex_map;
351  TopTools_IndexedMapOfShape cad_shape_edge_map;
352  TopTools_IndexedMapOfShape cad_shape_face_map;
353  TopTools_IndexedDataMapOfShapeListOfShape
354  cad_shape_vertex2edge_map;
355  TopTools_IndexedDataMapOfShapeListOfShape
356  cad_shape_edge2face_map;
357 };
358 
359 #endif /* T8_WITH_OCC */
360 
361 #endif /* !T8_GEOMETRY_CAD_HXX */
This structure holds the connectivity data of the coarse mesh.
Definition: t8_cmesh_types.h:88
This geometry uses OpenCASCADE CAD geometries to curve the trees to the actual shape of the underlyin...
Definition: t8_geometry_cad.hxx:50
const TopTools_IndexedMapOfShape t8_geom_get_cad_shape_vertex_map() const
Get the cad_shape_vertex2edge_map.
Definition: t8_geometry_cad.cxx:1121
int t8_geom_is_vertex_on_face(const int vertex_index, const int face_index) const
Check if a cad vertex lies on an cad face.
Definition: t8_geometry_cad.cxx:1185
const Handle_Geom_Curve t8_geom_get_cad_curve(const int index) const
Get an cad curve from the cad_shape.
Definition: t8_geometry_cad.cxx:1106
int t8_geom_is_vertex_on_edge(const int vertex_index, const int edge_index) const
Check if a cad vertex lies on an cad edge.
Definition: t8_geometry_cad.cxx:1171
const Handle_Geom_Surface t8_geom_get_cad_surface(const int index) const
Get an cad surface from the cad_shape.
Definition: t8_geometry_cad.cxx:1114
int t8_geom_is_edge_on_face(const int edge_index, const int face_index) const
Check if a cad vertex lies on an cad edge.
Definition: t8_geometry_cad.cxx:1178
void t8_geom_get_face_parametric_bounds(const int surface_index, double *bounds) const
Finds the parametric bounds of an cad face.
Definition: t8_geometry_cad.cxx:1274
const TopTools_IndexedMapOfShape t8_geom_get_cad_shape_edge_map() const
Get the cad_shape_edge2face_map.
Definition: t8_geometry_cad.cxx:1127
int t8_geom_is_surface_closed(int geometry_index, int parameter) const
Checks if a surface is closed in its U parameter or V parameter.
Definition: t8_geometry_cad.cxx:1296
int t8_geom_is_plane(const int surface_index) const
Check if a cad_surface is a plane.
Definition: t8_geometry_cad.cxx:1091
void t8_geom_get_edge_parametric_bounds(const int edge_index, double *bounds) const
Finds the parametric bounds of an cad edge.
Definition: t8_geometry_cad.cxx:1281
int t8_geom_is_edge_closed(int edge_index) const
Checks if an edge is closed in its U parameter.
Definition: t8_geometry_cad.cxx:1289
virtual void t8_geom_load_tree_data(t8_cmesh_t cmesh, t8_gloidx_t gtreeid)
Update a possible internal data buffer for per tree data.
Definition: t8_geometry_cad.cxx:151
virtual ~t8_geometry_cad()
The destructor.
Definition: t8_geometry_cad.hxx:88
int t8_geom_get_common_face(const int edge1_index, const int edge2_index) const
Check if two cad edges share a common cad face.
Definition: t8_geometry_cad.cxx:1155
virtual void t8_geom_evaluate_jacobian(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian) const
Compute the jacobian of the t8_geom_evaluate map at a point in the reference space .
Definition: t8_geometry_cad.cxx:120
void t8_geom_edge_parameter_to_face_parameters(const int edge_index, const int face_index, const int num_face_nodes, const double edge_param, const double *surface_params, double *face_params) const
Converts the parameters of an cad edge to the corresponding parameters on an cad face.
Definition: t8_geometry_cad.cxx:1221
t8_geometry_cad(int dim, std::string fileprefix, std::string name="t8_geom_cad")
Constructor of the cad geometry with a given dimension.
Definition: t8_geometry_cad.cxx:52
const gp_Pnt t8_geom_get_cad_point(const int index) const
Get an cad point from the cad_shape.
Definition: t8_geometry_cad.cxx:1099
int t8_geom_is_line(const int curve_index) const
Check if a cad_curve is a line.
Definition: t8_geometry_cad.cxx:1083
t8_geometry_type_t t8_geom_get_type() const
Get the type of this geometry.
Definition: t8_geometry_cad.hxx:98
int t8_geom_get_common_edge(const int vertex1_index, const int vertex2_index) const
Check if two cad points share a common cad edge.
Definition: t8_geometry_cad.cxx:1139
const TopTools_IndexedMapOfShape t8_geom_get_cad_shape_face_map() const
Get the cad_shape_face_map.
Definition: t8_geometry_cad.cxx:1133
void t8_geom_get_parameter_of_vertex_on_edge(const int vertex_index, const int edge_index, double *edge_param) const
Retrieves the parameter of an cad vertex on an cad edge.
Definition: t8_geometry_cad.cxx:1198
void t8_geom_get_parameters_of_vertex_on_face(const int vertex_index, const int face_index, double *face_params) const
Retrieves the parameters of an cad vertex on a cad face.
Definition: t8_geometry_cad.cxx:1208
virtual void t8_geom_evaluate(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const
Maps points in the reference space .
Definition: t8_geometry_cad.cxx:95
Definition: t8_geometry_with_vertices.hxx:40
std::string name
The name of this geometry.
Definition: t8_geometry_base.hxx:183
This is the administrative header file for t8code.
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:100
We define here the datatypes needed for internal cmesh routines.
@ T8_GEOMETRY_TYPE_CAD
The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model.
Definition: t8_geometry.h:47
enum t8_geometry_type t8_geometry_type_t
This enumeration contains all possible geometries.
This header provides the C interface to create a cad geometry.
Implements the inherited struct t8_geometry_with_vertices, which can be used for geometries that use ...