Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
GeometricUtilities.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* GeometricUtilities.h (C) 2000-2025 */
9/* */
10/* Utility functions on geometry. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_GEOMETRICUTILITIES_H
13#define ARCANE_CORE_GEOMETRICUTILITIES_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real3.h"
18#include "arcane/utils/Real3x3.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
40class ARCANE_CORE_EXPORT QuadMapping
41{
42 public:
43
44 QuadMapping() = default;
45
46 public:
47
48 Real3 m_pos[4];
49 Real m_precision = 1.0e-14;
50
51 public:
52
55 {
56 Real u = iso.x;
57 Real v = iso.y;
58
59 Real x0 = (1.0 - u) * (1.0 - v);
60 Real x1 = (1.0 + u) * (1.0 - v);
61 Real x2 = (1.0 + u) * (1.0 + v);
62 Real x3 = (1.0 - u) * (1.0 + v);
63
64 return 0.25 * (m_pos[0] * x0 + m_pos[1] * x1 + m_pos[2] * x2 + m_pos[3] * x3);
65 }
66 Real3x3 evaluateGradient(Real3 iso) const
67 {
68 Real u = iso.x;
69 Real v = iso.y;
70
71 Real t1 = 0.25 * (v - 1.0);
72 Real t2 = 0.25 * (v + 1.0);
73 Real t3 = 0.25 * (u - 1.0);
74 Real t4 = 0.25 * (-u - 1.0);
75
76 return Real3x3(m_pos[0] * t1 - m_pos[1] * t1 + m_pos[2] * t2 - m_pos[3] * t2,
77 m_pos[0] * t3 + m_pos[1] * t4 - m_pos[2] * t4 - m_pos[3] * t3,
78 Real3::null());
79 }
80 Real computeInverseJacobian(Real3 uvw, Real3x3& matrix);
81 bool cartesianToIso(Real3 point, Real3& uvw, ITraceMng* tm);
82 bool cartesianToIso2(Real3 point, Real3& uvw, ITraceMng* tm);
83 Real3 normal();
84
85 private:
86
87 Real3 _normal();
88};
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
98class ARCANE_CORE_EXPORT ProjectionInfo
99{
100 public:
101
102 ProjectionInfo(Real distance, int region, Real alpha, Real beta, Real3 aprojection)
103 : m_distance(distance)
104 , m_region(region)
105 , m_alpha(alpha)
106 , m_beta(beta)
107 , m_projection(aprojection)
108 {}
109 ProjectionInfo() = default;
110
111 public:
112
116 int m_region = -1;
118 Real m_alpha = -1.0;
120 Real m_beta = -1.0;
123
124 public:
125
127 static ProjectionInfo projection(Real3 v1, Real3 v2, Real3 v3, Real3 point);
128
130 static ProjectionInfo projection(Real3 v1, Real3 v2, Real3 point);
131
135 static bool isInside(Real3 v1, Real3 v2, Real3 v3, Real3 point);
139 static bool isInside(Real3 v1, Real3 v2, Real3 point);
140};
141
142/*---------------------------------------------------------------------------*/
143/*---------------------------------------------------------------------------*/
144
145} // namespace Arcane::GeometricUtilities
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150#endif
Information about the floating-point type.
Definition Limits.h:49
Real3 m_projection
Position of the projection.
static ProjectionInfo projection(Real3 v1, Real3 v2, Real3 v3, Real3 point)
Projection of point point onto the triangle defined by v1, v2 and v3.
int m_region
Region where the projection is located (0 if inside the segment or triangle).
Real m_alpha
Barycentric x-coordinate of the projection.
static bool isInside(Real3 v1, Real3 v2, Real3 v3, Real3 point)
Indicates if the projection of point point is inside the triangle defined by v1, v2 and v3.
Real m_distance
Distance of the point to its projection.
Real m_beta
Barycentric y-coordinate of the projection.
Real3 evaluatePosition(Real3 iso) const
Calculates Cartesian coordinates from iso-barycentric coordinates.
Class managing a 3-dimensional real vector.
Definition Real3.h:132
Class managing a 3x3 real matrix.
Definition Real3x3.h:67
Utility functions on geometry.
double Real
Type representing a real number.
Real y
second component of the triplet
Definition Real3.h:36
Real x
first component of the triplet
Definition Real3.h:35