Reference documentation for deal.II version 8.4.2
utilities.h
1 // ---------------------------------------------------------------------
2 // @f$Id@f$
3 //
4 // Copyright (C) 2014 - 2015 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 
18 #ifndef dealii__occ_utilities_h
19 #define dealii__occ_utilities_h
20 
21 #include <deal.II/base/config.h>
22 
23 #ifdef DEAL_II_WITH_OPENCASCADE
24 
25 #include <deal.II/grid/tria.h>
26 #include <deal.II/base/point.h>
27 
28 #include <string>
29 
30 // opencascade needs "HAVE_CONFIG_H" to be exported...
31 #define HAVE_CONFIG_H
32 #include <TopoDS_Shape.hxx>
33 #include <TopoDS_Face.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Vertex.hxx>
36 #include <TopoDS_Compound.hxx>
37 #include <TopoDS_CompSolid.hxx>
38 #include <TopoDS_Solid.hxx>
39 #include <TopoDS_Shell.hxx>
40 #include <TopoDS_Wire.hxx>
41 #include <IFSelect_ReturnStatus.hxx>
42 #include <gp_Pnt.hxx>
43 #undef HAVE_CONFIG_H
44 
45 
46 
47 DEAL_II_NAMESPACE_OPEN
48 
95 namespace OpenCASCADE
96 {
104  std_cxx11::tuple<unsigned int, unsigned int, unsigned int>
105  count_elements(const TopoDS_Shape &shape);
106 
114  TopoDS_Shape read_IGES(const std::string &filename,
115  const double scale_factor=1e-3);
116 
120  void write_IGES(const TopoDS_Shape &shape,
121  const std::string &filename);
122 
130  TopoDS_Shape read_STEP(const std::string &filename,
131  const double scale_factor=1e-3);
132 
133 
137  void write_STEP(const TopoDS_Shape &shape,
138  const std::string &filename);
139 
152  double get_shape_tolerance(const TopoDS_Shape &shape);
153 
160  TopoDS_Shape intersect_plane(const TopoDS_Shape &in_shape,
161  const double c_x,
162  const double c_y,
163  const double c_z,
164  const double c,
165  const double tolerance=1e-7);
166 
174  TopoDS_Edge join_edges(const TopoDS_Shape &in_shape,
175  const double tolerance=1e-7);
176 
194  TopoDS_Edge interpolation_curve(std::vector<Point<3> > &curve_points,
195  const Tensor<1,3> &direction=Tensor<1,3>(),
196  const bool closed=false,
197  const double tolerance=1e-7);
198 
204  void extract_geometrical_shapes(const TopoDS_Shape &shape,
205  std::vector<TopoDS_Face> &faces,
206  std::vector<TopoDS_Edge> &edges,
207  std::vector<TopoDS_Vertex> &vertices);
208 
218  void create_triangulation(const TopoDS_Face &face,
219  Triangulation<2,3> &tria);
220 
226  void extract_compound_shapes(const TopoDS_Shape &shape,
227  std::vector<TopoDS_Compound> &compounds,
228  std::vector<TopoDS_CompSolid> &compsolids,
229  std::vector<TopoDS_Solid> &solids,
230  std::vector<TopoDS_Shell> &shells,
231  std::vector<TopoDS_Wire> &wires);
232 
247  std_cxx11::tuple<Point<3>, TopoDS_Shape, double, double>
248  project_point_and_pull_back(const TopoDS_Shape &in_shape,
249  const Point<3> &origin,
250  const double tolerance=1e-7);
251 
258  Point<3> closest_point(const TopoDS_Shape &in_shape,
259  const Point<3> &origin,
260  const double tolerance=1e-7);
261 
270  Point<3> push_forward(const TopoDS_Shape &in_shape,
271  const double u,
272  const double v);
273 
274 
280  std_cxx11::tuple<Point<3>, Point<3>, double >
281  push_forward_and_differential_forms(const TopoDS_Face &face,
282  const double u,
283  const double v,
284  const double tolerance=1e-7);
285 
286 
294  std_cxx11::tuple<Point<3>, Point<3>, double>
295  closest_point_and_differential_forms(const TopoDS_Shape &in_shape,
296  const Point<3> &origin,
297  const double tolerance=1e-7);
298 
299 
307  Point<3> line_intersection(const TopoDS_Shape &in_shape,
308  const Point<3> &origin,
309  const Tensor<1,3> &direction,
310  const double tolerance=1e-7);
311 
312 
316  Point<3> point(const gp_Pnt &p);
317 
318 
322  gp_Pnt point(const Point<3> &p);
323 
324 
331  bool point_compare(const Point<3> &p1, const Point<3> &p2,
332  const Tensor<1,3> &direction=Tensor<1,3>(),
333  const double tolerance=1e-10);
334 
335 
340  DeclException1 (ExcPointNotOnManifold,
341  Point<3>,
342  <<"The point [ "<<arg1<<" ] is not on the manifold.");
343 
348  DeclException1 (ExcProjectionFailed,
349  Point<3>,
350  <<"Projection of point [ "<< arg1
351  << " ] failed.");
352 
356  DeclException1 (ExcOCCError,
357  IFSelect_ReturnStatus,
358  <<"An OpenCASCADE routine failed with return status "
359  <<arg1);
360 
364  DeclException0(ExcEdgeIsDegenerate);
365 
369  DeclException0(ExcUnsupportedShape);
370 }
371 
372 
373 DEAL_II_NAMESPACE_CLOSE
374 
375 #endif // DEAL_II_WITH_OPENCASCADE
376 
377 /*------------------------------ occ_utilities.h ------------------------------*/
378 #endif
379 /*------------------------------ occ_utilities.h ------------------------------*/
std_cxx11::tuple< Point< 3 >, Point< 3 >, double > closest_point_and_differential_forms(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
Definition: utilities.cc:535
TopoDS_Shape read_IGES(const std::string &filename, const double scale_factor=1e-3)
Definition: utilities.cc:181
Point< 3 > line_intersection(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const Tensor< 1, 3 > &direction, const double tolerance=1e-7)
Definition: utilities.cc:372
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:295
TopoDS_Shape read_STEP(const std::string &filename, const double scale_factor=1e-3)
Definition: utilities.cc:224
Point< 3 > push_forward(const TopoDS_Shape &in_shape, const double u, const double v)
Definition: utilities.cc:567
void write_IGES(const TopoDS_Shape &shape, const std::string &filename)
Definition: utilities.cc:212
TopoDS_Edge interpolation_curve(std::vector< Point< 3 > > &curve_points, const Tensor< 1, 3 > &direction=Tensor< 1, 3 >(), const bool closed=false, const double tolerance=1e-7)
Definition: utilities.cc:413
std_cxx11::tuple< unsigned int, unsigned int, unsigned int > count_elements(const TopoDS_Shape &shape)
Definition: utilities.cc:73
std_cxx11::tuple< Point< 3 >, Point< 3 >, double > push_forward_and_differential_forms(const TopoDS_Face &face, const double u, const double v, const double tolerance=1e-7)
Definition: utilities.cc:590
void write_STEP(const TopoDS_Shape &shape, const std::string &filename)
Definition: utilities.cc:255
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:114
DeclException1(ExcPointNotOnManifold, Point< 3 >,<<"The point [ "<< arg1<<" ] is not on the manifold.")
std_cxx11::tuple< Point< 3 >, TopoDS_Shape, double, double > project_point_and_pull_back(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
Definition: utilities.cc:445
Point< 3 > closest_point(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
Definition: utilities.cc:525
double get_shape_tolerance(const TopoDS_Shape &shape)
Definition: utilities.cc:269
TopoDS_Edge join_edges(const TopoDS_Shape &in_shape, const double tolerance=1e-7)
Definition: utilities.cc:308
Definition: mpi.h:48
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:89
DeclException0(ExcEdgeIsDegenerate)
Point< 3 > point(const gp_Pnt &p)
Definition: utilities.cc:156
bool point_compare(const Point< 3 > &p1, const Point< 3 > &p2, const Tensor< 1, 3 > &direction=Tensor< 1, 3 >(), const double tolerance=1e-10)
Definition: utilities.cc:161
void create_triangulation(const TopoDS_Face &face, Triangulation< 2, 3 > &tria)
Definition: utilities.cc:608