Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IRayMeshIntersection.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/* IRayMeshIntersection.h (C) 2000-2025 */
9/* */
10/* Calculation of the intersection between segments and the surface of a */
11/* mesh. */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_CORE_IRAYMESHINTERSECTION_H
14#define ARCANE_CORE_IRAYMESHINTERSECTION_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \brief Generic interface for calculating the intersection of a ray with a face.
31 */
33{
34 public:
35
36 virtual ~IRayFaceIntersector() {}
37
38 public:
39
40 /*!
41 * \brief Calculates the intersection between a ray and a face.
42 *
43 * \param origin ray origin position.
44 * \param direction direction of the ray.
45 * \param orig_face_local_id local ID of the ray's origin face
46 * \param face_nodes positions of the face nodes.
47 * \param face_local_id local ID of the face. If it is not
48 * a sub-domain face, it equals ITEM_NULL_LOCAL_ID.
49 * \param user_value user value to be filled by the caller if necessary.
50 * \param distance returned, intersection distance if one exists.
51 * \param intersection_position returned, position of the intersection point.
52 * \return true if an intersection is found, false otherwise.
53 */
54 virtual bool computeIntersection(Real3 origin, Real3 direction,
55 Int32 orig_face_local_id,
56 Int32 face_local_id,
57 Real3ConstArrayView face_nodes,
58 Int32* user_value,
59 Real* distance, Real3* intersection_position) = 0;
60};
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65/*!
66 * \brief Calculation of the intersection between a set of segments and the surface
67 * of a mesh.
68 */
70{
71 public:
72
73 //! Frees resources.
74 virtual ~IRayMeshIntersection() = default;
75
76 public:
77
78 //! Builds the instance.
79 virtual void build() = 0;
80
81 public:
82
83 /*!
84 * \brief Calculates the intersection.
85 *
86 * In return, the array \a faces_local_id contains the local ID
87 * of the intersected face for each segment. If a segment
88 * does not intersect any face, the corresponding local_id is NULL_ITEM_LOCAL_ID.
89 */
90 virtual void compute(Real3ConstArrayView segments_position,
91 Real3ConstArrayView segments_direction,
92 Int32ConstArrayView orig_faces_local_id,
93 Int32ArrayView user_values,
94 Real3ArrayView intersections,
95 RealArrayView distances,
96 Int32ArrayView faces_local_id) = 0;
97
98 /*!
99 * \brief Calculates the intersection of rays.
100 *
101 * Calculates the intersection of rays in the family \a ray_family
102 * with the surface of the mesh. The position and direction
103 * of the rays are given by the variables \a rays_position
104 * and \a rays_direction. The array \a rays_orig_face contains
105 * the local ID of the face from which the ray originates. This array
106 * is used in the IRayFaceIntersector.
107 *
108 * In return, \a rays_face will contain for each ray the localId()
109 * of the intersected face
110 * or NULL_ITEM_LOCAL_ID if a ray does not intersect any face.
111 * The array \a rays_intersection returns the position
112 * of the intersection point and \a rays_distance the distance
113 * of the intersection point relative to the ray origin.
114 * The array \a user_values is filled in return by
115 * the IRayFaceIntersector.
116 *
117 * In parallel, the rays in the family are exchanged
118 * between sub-domains so that a ray is in the
119 * same sub-domain as the owner of the intersected face.
120 * If a ray does not intersect any face, it remains in
121 * this sub-domain.
122 */
123 virtual void compute(IItemFamily* ray_family,
124 VariableParticleReal3& rays_position,
125 VariableParticleReal3& rays_direction,
126 VariableParticleInt32& rays_orig_face,
127 VariableParticleInt32& user_values,
128 VariableParticleReal3& intersections,
129 VariableParticleReal& distances,
130 VariableParticleInt32& rays_face) = 0;
131
132 /*!
133 * \brief Sets the intersection callback.
134 *
135 * This allows the caller to specify its method for calculating
136 * the intersection of a ray with a face. If this method is not
137 * called, a default intersector is used.
138 */
139 virtual void setFaceIntersector(IRayFaceIntersector* intersector) = 0;
140
141 //! Intersector used (0 if none specified)
143};
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148} // namespace Arcane
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153#endif
Declarations of Arcane's general types.
Interface of an entity family.
Definition IItemFamily.h:83
Generic interface for calculating the intersection of a ray with a face.
virtual bool computeIntersection(Real3 origin, Real3 direction, Int32 orig_face_local_id, Int32 face_local_id, Real3ConstArrayView face_nodes, Int32 *user_value, Real *distance, Real3 *intersection_position)=0
Calculates the intersection between a ray and a face.
Calculation of the intersection between a set of segments and the surface of a mesh.
virtual ~IRayMeshIntersection()=default
Frees resources.
virtual void build()=0
Builds the instance.
virtual void compute(IItemFamily *ray_family, VariableParticleReal3 &rays_position, VariableParticleReal3 &rays_direction, VariableParticleInt32 &rays_orig_face, VariableParticleInt32 &user_values, VariableParticleReal3 &intersections, VariableParticleReal &distances, VariableParticleInt32 &rays_face)=0
Calculates the intersection of rays.
virtual IRayFaceIntersector * faceIntersector()=0
Intersector used (0 if none specified).
virtual void setFaceIntersector(IRayFaceIntersector *intersector)=0
Sets the intersection callback.
virtual void compute(Real3ConstArrayView segments_position, Real3ConstArrayView segments_direction, Int32ConstArrayView orig_faces_local_id, Int32ArrayView user_values, Real3ArrayView intersections, RealArrayView distances, Int32ArrayView faces_local_id)=0
Calculates the intersection.
Class managing a 3-dimensional real vector.
Definition Real3.h:132
MeshVariableScalarRefT< Particle, Real3 > VariableParticleReal3
Coordinate type particle quantity.
MeshVariableScalarRefT< Particle, Int32 > VariableParticleInt32
Particle quantity of 32-bit integer type.
MeshVariableScalarRefT< Particle, Real > VariableParticleReal
Real type particle quantity.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< Real3 > Real3ConstArrayView
C equivalent of a 1D array of Real3.
Definition UtilsTypes.h:496
ArrayView< Real3 > Real3ArrayView
C equivalent of a 1D array of Real3.
Definition UtilsTypes.h:467
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:453
double Real
Type representing a real number.
ArrayView< Real > RealArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:459
std::int32_t Int32
Signed integer type of 32 bits.