deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
utilities.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2014 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_occ_utilities_h
15#define dealii_occ_utilities_h
16
17#include <deal.II/base/config.h>
18
19#ifdef DEAL_II_WITH_OPENCASCADE
20
21# include <deal.II/base/point.h>
22
24
25# include <deal.II/grid/tria.h>
26
27# include <string>
28
29// opencascade needs "HAVE_CONFIG_H" to be exported...
30# define HAVE_CONFIG_H
31# include <IFSelect_ReturnStatus.hxx>
32# include <TopoDS_CompSolid.hxx>
33# include <TopoDS_Compound.hxx>
34# include <TopoDS_Edge.hxx>
35# include <TopoDS_Face.hxx>
36# include <TopoDS_Shape.hxx>
37# include <TopoDS_Shell.hxx>
38# include <TopoDS_Solid.hxx>
39# include <TopoDS_Vertex.hxx>
40# include <TopoDS_Wire.hxx>
41# include <gp_Pnt.hxx>
42# undef HAVE_CONFIG_H
43
44#endif // DEAL_II_WITH_OPENCASCADE
45
47
48#ifdef DEAL_II_WITH_OPENCASCADE
99namespace OpenCASCADE
100{
108 std::tuple<unsigned int, unsigned int, unsigned int>
109 count_elements(const TopoDS_Shape &shape);
110
118 TopoDS_Shape
119 read_IGES(const std::string &filename, const double scale_factor = 1e-3);
120
124 void
125 write_IGES(const TopoDS_Shape &shape, const std::string &filename);
126
127
133 TopoDS_Shape
134 read_STL(const std::string &filename);
135
151 void
152 write_STL(const TopoDS_Shape &shape,
153 const std::string &filename,
154 const double deflection,
155 const bool sew_different_faces = false,
156 const double sewer_tolerance = 1e-6,
157 const bool is_relative = false,
158 const double angular_deflection = 0.5,
159 const bool in_parallel = false);
160
161
169 TopoDS_Shape
170 read_STEP(const std::string &filename, const double scale_factor = 1e-3);
171
172
176 void
177 write_STEP(const TopoDS_Shape &shape, const std::string &filename);
178
191 double
192 get_shape_tolerance(const TopoDS_Shape &shape);
193
200 TopoDS_Shape
201 intersect_plane(const TopoDS_Shape &in_shape,
202 const double c_x,
203 const double c_y,
204 const double c_z,
205 const double c,
206 const double tolerance = 1e-7);
207
215 TopoDS_Edge
216 join_edges(const TopoDS_Shape &in_shape, const double tolerance = 1e-7);
217
235 template <int dim>
236 TopoDS_Edge
237 interpolation_curve(std::vector<Point<dim>> &curve_points,
238 const Tensor<1, dim> &direction = Tensor<1, dim>(),
239 const bool closed = false,
240 const double tolerance = 1e-7);
241
247 void
248 extract_geometrical_shapes(const TopoDS_Shape &shape,
249 std::vector<TopoDS_Face> &faces,
250 std::vector<TopoDS_Edge> &edges,
251 std::vector<TopoDS_Vertex> &vertices);
252
265 template <int spacedim>
266 void
267 create_triangulation(const TopoDS_Face &face,
269
270
289 template <int spacedim>
290 std::vector<TopoDS_Edge>
292 const Triangulation<2, spacedim> &triangulation,
293 const Mapping<2, spacedim> &mapping =
295
301 void
302 extract_compound_shapes(const TopoDS_Shape &shape,
303 std::vector<TopoDS_Compound> &compounds,
304 std::vector<TopoDS_CompSolid> &compsolids,
305 std::vector<TopoDS_Solid> &solids,
306 std::vector<TopoDS_Shell> &shells,
307 std::vector<TopoDS_Wire> &wires);
308
323 template <int dim>
324 std::tuple<Point<dim>, TopoDS_Shape, double, double>
325 project_point_and_pull_back(const TopoDS_Shape &in_shape,
326 const Point<dim> &origin,
327 const double tolerance = 1e-7);
328
335 template <int dim>
337 closest_point(const TopoDS_Shape &in_shape,
338 const Point<dim> &origin,
339 const double tolerance = 1e-7);
340
349 template <int dim>
351 push_forward(const TopoDS_Shape &in_shape, const double u, const double v);
352
353
359 std::tuple<Point<3>, Tensor<1, 3>, double, double>
360 push_forward_and_differential_forms(const TopoDS_Face &face,
361 const double u,
362 const double v,
363 const double tolerance = 1e-7);
364
365
373 std::tuple<Point<3>, Tensor<1, 3>, double, double>
374 closest_point_and_differential_forms(const TopoDS_Shape &in_shape,
375 const Point<3> &origin,
376 const double tolerance = 1e-7);
377
378
386 template <int dim>
388 line_intersection(const TopoDS_Shape &in_shape,
389 const Point<dim> &origin,
390 const Tensor<1, dim> &direction,
391 const double tolerance = 1e-7);
392
393
401 template <int spacedim>
403 point(const gp_Pnt &p, const double tolerance = 1e-10);
404
405
409 template <int spacedim>
410 gp_Pnt
411 point(const Point<spacedim> &p);
412
413
420 template <int dim>
421 bool
422 point_compare(const Point<dim> &p1,
423 const Point<dim> &p2,
424 const Tensor<1, dim> &direction = Tensor<1, dim>(),
425 const double tolerance = 1e-10);
426
427
432 template <int dim>
435 << "The point [ " << arg1 << " ] is not on the manifold.");
436
441 template <int dim>
444 << "Projection of point [ " << arg1 << " ] failed.");
445
450 IFSelect_ReturnStatus,
451 << "An OpenCASCADE routine failed with return status "
452 << arg1);
453
458
463} // namespace OpenCASCADE
464
465#endif // DEAL_II_WITH_OPENCASCADE
466
468
469#endif
Abstract base class for mapping classes.
Definition mapping.h:318
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DeclException0(Exception0)
static ::ExceptionBase & ExcPointNotOnManifold(Point< dim > arg1)
static ::ExceptionBase & ExcEdgeIsDegenerate()
static ::ExceptionBase & ExcProjectionFailed(Point< dim > arg1)
static ::ExceptionBase & ExcOCCError(IFSelect_ReturnStatus arg1)
static ::ExceptionBase & ExcUnsupportedShape()
#define DeclException1(Exception1, type1, outsequence)
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:578
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:874
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:155
Point< dim > push_forward(const TopoDS_Shape &in_shape, const double u, const double v)
Definition utilities.cc:853
std::tuple< unsigned int, unsigned int, unsigned int > count_elements(const TopoDS_Shape &shape)
Definition utilities.cc:110
void write_STEP(const TopoDS_Shape &shape, const std::string &filename)
Definition utilities.cc:406
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:817
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:129
TopoDS_Edge join_edges(const TopoDS_Shape &in_shape, const double tolerance=1e-7)
Definition utilities.cc:464
TopoDS_Shape read_STEP(const std::string &filename, const double scale_factor=1e-3)
Definition utilities.cc:377
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:237
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Definition utilities.cc:210
Point< dim > closest_point(const TopoDS_Shape &in_shape, const Point< dim > &origin, const double tolerance=1e-7)
Definition utilities.cc:807
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:724
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:532
void write_STL(const TopoDS_Shape &shape, const std::string &filename, const double deflection, const bool sew_different_faces=false, const double sewer_tolerance=1e-6, const bool is_relative=false, const double angular_deflection=0.5, const bool in_parallel=false)
Definition utilities.cc:312
void create_triangulation(const TopoDS_Face &face, Triangulation< 2, spacedim > &tria)
Definition utilities.cc:911
TopoDS_Shape read_STL(const std::string &filename)
Definition utilities.cc:302
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:446
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:621
double get_shape_tolerance(const TopoDS_Shape &shape)
Definition utilities.cc:422
void write_IGES(const TopoDS_Shape &shape, const std::string &filename)
Definition utilities.cc:289
TopoDS_Shape read_IGES(const std::string &filename, const double scale_factor=1e-3)
Definition utilities.cc:260