Reference documentation for deal.II version 9.1.0-pre
utilities.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2014 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_occ_utilities_h
18 # define dealii_occ_utilities_h
19 
20 # include <deal.II/base/config.h>
21 
22 # ifdef DEAL_II_WITH_OPENCASCADE
23 
24 # include <deal.II/base/point.h>
25 
26 # include <deal.II/fe/mapping_q1.h>
27 
28 # include <deal.II/grid/tria.h>
29 
30 # include <string>
31 
32 // opencascade needs "HAVE_CONFIG_H" to be exported...
33 # define HAVE_CONFIG_H
34 # include <IFSelect_ReturnStatus.hxx>
35 # include <TopoDS_CompSolid.hxx>
36 # include <TopoDS_Compound.hxx>
37 # include <TopoDS_Edge.hxx>
38 # include <TopoDS_Face.hxx>
39 # include <TopoDS_Shape.hxx>
40 # include <TopoDS_Shell.hxx>
41 # include <TopoDS_Solid.hxx>
42 # include <TopoDS_Vertex.hxx>
43 # include <TopoDS_Wire.hxx>
44 # include <gp_Pnt.hxx>
45 # undef HAVE_CONFIG_H
46 
47 
48 
49 DEAL_II_NAMESPACE_OPEN
50 
103 namespace OpenCASCADE
104 {
112  std::tuple<unsigned int, unsigned int, unsigned int>
113  count_elements(const TopoDS_Shape &shape);
114 
122  TopoDS_Shape
123  read_IGES(const std::string &filename, const double scale_factor = 1e-3);
124 
128  void
129  write_IGES(const TopoDS_Shape &shape, const std::string &filename);
130 
138  TopoDS_Shape
139  read_STEP(const std::string &filename, const double scale_factor = 1e-3);
140 
141 
145  void
146  write_STEP(const TopoDS_Shape &shape, const std::string &filename);
147 
160  double
161  get_shape_tolerance(const TopoDS_Shape &shape);
162 
169  TopoDS_Shape
170  intersect_plane(const TopoDS_Shape &in_shape,
171  const double c_x,
172  const double c_y,
173  const double c_z,
174  const double c,
175  const double tolerance = 1e-7);
176 
184  TopoDS_Edge
185  join_edges(const TopoDS_Shape &in_shape, const double tolerance = 1e-7);
186 
204  template <int dim>
205  TopoDS_Edge
206  interpolation_curve(std::vector<Point<dim>> &curve_points,
207  const Tensor<1, dim> & direction = Tensor<1, dim>(),
208  const bool closed = false,
209  const double tolerance = 1e-7);
210 
216  void
217  extract_geometrical_shapes(const TopoDS_Shape & shape,
218  std::vector<TopoDS_Face> & faces,
219  std::vector<TopoDS_Edge> & edges,
220  std::vector<TopoDS_Vertex> &vertices);
221 
234  template <int spacedim>
235  void
236  create_triangulation(const TopoDS_Face & face,
238 
239 
260  template <int spacedim>
261  std::vector<TopoDS_Edge>
263  const Triangulation<2, spacedim> &triangulation,
264  const Mapping<2, spacedim> & mapping =
266 
272  void
273  extract_compound_shapes(const TopoDS_Shape & shape,
274  std::vector<TopoDS_Compound> & compounds,
275  std::vector<TopoDS_CompSolid> &compsolids,
276  std::vector<TopoDS_Solid> & solids,
277  std::vector<TopoDS_Shell> & shells,
278  std::vector<TopoDS_Wire> & wires);
279 
294  template <int dim>
295  std::tuple<Point<dim>, TopoDS_Shape, double, double>
296  project_point_and_pull_back(const TopoDS_Shape &in_shape,
297  const Point<dim> & origin,
298  const double tolerance = 1e-7);
299 
306  template <int dim>
307  Point<dim>
308  closest_point(const TopoDS_Shape &in_shape,
309  const Point<dim> & origin,
310  const double tolerance = 1e-7);
311 
320  template <int dim>
321  Point<dim>
322  push_forward(const TopoDS_Shape &in_shape, const double u, const double v);
323 
324 
330  std::tuple<Point<3>, Tensor<1, 3>, double, double>
331  push_forward_and_differential_forms(const TopoDS_Face &face,
332  const double u,
333  const double v,
334  const double tolerance = 1e-7);
335 
336 
344  std::tuple<Point<3>, Tensor<1, 3>, double, double>
345  closest_point_and_differential_forms(const TopoDS_Shape &in_shape,
346  const Point<3> & origin,
347  const double tolerance = 1e-7);
348 
349 
357  template <int dim>
358  Point<dim>
359  line_intersection(const TopoDS_Shape & in_shape,
360  const Point<dim> & origin,
361  const Tensor<1, dim> &direction,
362  const double tolerance = 1e-7);
363 
364 
372  template <int spacedim>
374  point(const gp_Pnt &p, const double &tolerance = 1e-10);
375 
376 
380  template <int spacedim>
381  gp_Pnt
382  point(const Point<spacedim> &p);
383 
384 
391  template <int dim>
392  bool
393  point_compare(const Point<dim> & p1,
394  const Point<dim> & p2,
395  const Tensor<1, dim> &direction = Tensor<1, dim>(),
396  const double tolerance = 1e-10);
397 
398 
403  template <int dim>
405  Point<dim>,
406  << "The point [ " << arg1 << " ] is not on the manifold.");
407 
412  template <int dim>
414  Point<dim>,
415  << "Projection of point [ " << arg1 << " ] failed.");
416 
421  IFSelect_ReturnStatus,
422  << "An OpenCASCADE routine failed with return status "
423  << arg1);
424 
429 
434 } // namespace OpenCASCADE
435 
436 
437 DEAL_II_NAMESPACE_CLOSE
438 
439 # endif // DEAL_II_WITH_OPENCASCADE
440 
441 #endif // dealii_occ_utilities_h
442 /*----------------------------- occ_utilities.h -----------------------------*/
std::tuple< unsigned int, unsigned int, unsigned int > count_elements(const TopoDS_Shape &shape)
Definition: utilities.cc:80
TopoDS_Shape read_IGES(const std::string &filename, const double scale_factor=1e-3)
Definition: utilities.cc:230
Point< dim > push_forward(const TopoDS_Shape &in_shape, const double u, const double v)
Definition: utilities.cc:743
TopoDS_Shape intersect_plane(const TopoDS_Shape &in_shape, const double c_x, const double c_y, const double c_z, const double c, const double tolerance=1e-7)
Definition: utilities.cc:340
Point< spacedim > point(const gp_Pnt &p, const double &tolerance=1e-10)
Definition: utilities.cc:180
TopoDS_Shape read_STEP(const std::string &filename, const double scale_factor=1e-3)
Definition: utilities.cc:271
Point< dim > line_intersection(const TopoDS_Shape &in_shape, const Point< dim > &origin, const Tensor< 1, dim > &direction, const double tolerance=1e-7)
Definition: utilities.cc:422
static::ExceptionBase & ExcOCCError(IFSelect_ReturnStatus arg1)
bool point_compare(const Point< dim > &p1, const Point< dim > &p2, const Tensor< 1, dim > &direction=Tensor< 1, dim >(), const double tolerance=1e-10)
Definition: utilities.cc:207
std::tuple< Point< 3 >, Tensor< 1, 3 >, double, double > push_forward_and_differential_forms(const TopoDS_Face &face, const double u, const double v, const double tolerance=1e-7)
Definition: utilities.cc:764
TopoDS_Edge interpolation_curve(std::vector< Point< dim >> &curve_points, const Tensor< 1, dim > &direction=Tensor< 1, dim >(), const bool closed=false, const double tolerance=1e-7)
Definition: utilities.cc:468
static::ExceptionBase & ExcEdgeIsDegenerate()
void write_IGES(const TopoDS_Shape &shape, const std::string &filename)
Definition: utilities.cc:259
void create_triangulation(const TopoDS_Face &face, Triangulation< 2, spacedim > &tria)
Definition: utilities.cc:801
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
void write_STEP(const TopoDS_Shape &shape, const std::string &filename)
Definition: utilities.cc:300
Abstract base class for mapping classes.
Definition: dof_tools.h:57
#define DeclException0(Exception0)
Definition: exceptions.h:385
Point< dim > closest_point(const TopoDS_Shape &in_shape, const Point< dim > &origin, const double tolerance=1e-7)
Definition: utilities.cc:697
void extract_compound_shapes(const TopoDS_Shape &shape, std::vector< TopoDS_Compound > &compounds, std::vector< TopoDS_CompSolid > &compsolids, std::vector< TopoDS_Solid > &solids, std::vector< TopoDS_Shell > &shells, std::vector< TopoDS_Wire > &wires)
Definition: utilities.cc:125
std::tuple< Point< dim >, TopoDS_Shape, double, double > project_point_and_pull_back(const TopoDS_Shape &in_shape, const Point< dim > &origin, const double tolerance=1e-7)
Definition: utilities.cc:614
double get_shape_tolerance(const TopoDS_Shape &shape)
Definition: utilities.cc:316
TopoDS_Edge join_edges(const TopoDS_Shape &in_shape, const double tolerance=1e-7)
Definition: utilities.cc:354
void extract_geometrical_shapes(const TopoDS_Shape &shape, std::vector< TopoDS_Face > &faces, std::vector< TopoDS_Edge > &edges, std::vector< TopoDS_Vertex > &vertices)
Definition: utilities.cc:99
std::vector< TopoDS_Edge > create_curves_from_triangulation_boundary(const Triangulation< 2, spacedim > &triangulation, const Mapping< 2, spacedim > &mapping=StaticMappingQ1< 2, spacedim >::mapping)
Definition: utilities.cc:510
static::ExceptionBase & ExcPointNotOnManifold(Point< dim > arg1)
static::ExceptionBase & ExcProjectionFailed(Point< dim > arg1)
static::ExceptionBase & ExcUnsupportedShape()
std::tuple< Point< 3 >, Tensor< 1, 3 >, double, double > closest_point_and_differential_forms(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
Definition: utilities.cc:707