DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
IntersectionConstruction.h
1// Copyright (C) 2014-2016 Anders Logg, August Johansson and Benjamin Kehlet
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17//
18// First added: 2014-02-03
19// Last changed: 2017-09-29
20
21#ifndef __INTERSECTION_CONSTRUCTION_H
22#define __INTERSECTION_CONSTRUCTION_H
23
24#include <vector>
25#include <dolfin/log/log.h>
26#include "Point.h"
27
28namespace dolfin
29{
30 // Forward declarations
31 class MeshEntity;
32
37
39 {
40 public:
41
54 static std::vector<Point>
55 intersection(const MeshEntity& entity_0,
56 const MeshEntity& entity_1);
57
73 static std::vector<Point>
74 intersection(const std::vector<Point>& points_0,
75 const std::vector<Point>& points_1,
76 std::size_t gdim);
77
78 //--- Low-level intersection construction functions ---
79
80 // There are 19 different intersections to consider. Initially, we have
81 // 4 different entities: point, segment, triangle, tetrahedron, and thus
82 // 16 combinations. Because of symmetry, these are reduced to 10. However,
83 // some of the combination are relevant in both 1D, 2D and 3D, and thus
84 // the total number of intersections lands at 19. The table indicates the
85 // number of versions (1D, 2D, 3D) for each relevant combination.
86 //
87 // | 0 1 2 3
88 // --------------
89 // 0 | 3 x x x point-foo (1D, 2D, 3D)
90 // 1 | 3 3 x x segment-foo (1D, 2D, 3D)
91 // 2 | 2 2 2 x triangle-foo (--, 2D, 3D)
92 // 3 | 1 1 1 1 tetrahedron-foo (--, --, 3D)
93 //
94 // The intersection construction functions can be grouped into
95 // three classes:
96 //
97 // [P] Use point collision predicates (9)
98 // [C] Compute collision by solving for intersection points (3)
99 // [D] Delegate computation to [P] or [C] for subsimplices (7)
100 //
101 // [P] intersection_point_point_1d
102 // [P] intersection_point_point_2d
103 // [P] intersection_point_point_3d
104 // [P] intersection_segment_point_1d
105 // [P] intersection_segment_point_2d
106 // [P] intersection_segment_point_3d
107 // [P] intersection_triangle_point_2d
108 // [P] intersection_triangle_point_3d
109 // [P] intersection_tetrahedron_point_3d
110 // [D] intersection_segment_segment_1d
111 // [C] intersection_segment_segment_2d
112 // [C] intersection_segment_segment_3d <-- not used/implemented
113 // [D] intersection_triangle_segment_2d
114 // [C] intersection_triangle_segment_3d <-- needs review
115 // [D] intersection_tetrahedron_segment_3d
116 // [D] intersection_triangle_triangle_2d
117 // [D] intersection_triangle_triangle_3d
118 // [D] intersection_tetrahedron_triangle_3d
119 // [D] intersection_tetrahedron_tetrahedron_3d
120 //
121 // Note that intersection_segment_segment_3d is not used/implemented.
122 // In summary, this means that there are only two functions that require
123 // computation, other than simple checks for point collisions or delegation
124 // to lower-level intersection functions. These two functions are:
125 //
126 // [C] intersection_segment_segment_2d
127 // [C] intersection_triangle_segment_3d
128
130 static std::vector<double>
132 double q0);
133
135 static std::vector<Point>
137 const Point& q0);
138
140 static std::vector<Point>
142 const Point& q0);
143
145 static std::vector<double>
147 double p1,
148 double q0);
149
151 static std::vector<Point>
153 const Point& p1,
154 const Point& q0);
155
157 static std::vector<Point>
159 const Point& p1,
160 const Point& q0);
161
163 static std::vector<Point>
165 const Point& p1,
166 const Point& p2,
167 const Point& q0);
168
170 static std::vector<Point>
172 const Point& p1,
173 const Point& p2,
174 const Point& q0);
175
177 static std::vector<Point>
179 const Point& p1,
180 const Point& p2,
181 const Point& p3,
182 const Point& q0);
183
185 static std::vector<double>
187 double p1,
188 double q0,
189 double q1);
190
192 static std::vector<Point>
194 const Point& p1,
195 const Point& q0,
196 const Point& q1);
197
199 static std::vector<Point>
201 const Point& p1,
202 const Point& q0,
203 const Point& q1);
204
206 static std::vector<Point>
208 const Point& p1,
209 const Point& p2,
210 const Point& q0,
211 const Point& q1);
212
214 static std::vector<Point>
216 const Point& p1,
217 const Point& p2,
218 const Point& q0,
219 const Point& q1);
220
222 static std::vector<Point>
224 const Point& p1,
225 const Point& p2,
226 const Point& p3,
227 const Point& q0,
228 const Point& q1);
229
231 static std::vector<Point>
233 const Point& p1,
234 const Point& p2,
235 const Point& q0,
236 const Point& q1,
237 const Point& q2);
238
240 static std::vector<Point>
242 const Point& p1,
243 const Point& p2,
244 const Point& q0,
245 const Point& q1,
246 const Point& q2);
247
249 static std::vector<Point>
251 const Point& p1,
252 const Point& p2,
253 const Point& p3,
254 const Point& q0,
255 const Point& q1,
256 const Point& q2);
257
259 static std::vector<Point>
261 const Point& p1,
262 const Point& p2,
263 const Point& p3,
264 const Point& q0,
265 const Point& q1,
266 const Point& q2,
267 const Point& q3);
268
269 private :
271 static std::vector<Point>
272 _intersection_triangle_segment_3d(const Point& p0,
273 const Point& p1,
274 const Point& p2,
275 const Point& q0,
276 const Point& q1);
277
278 static std::vector<Point>
279 _intersection_tetrahedron_tetrahedron_3d(const Point& p0,
280 const Point& p1,
281 const Point& p2,
282 const Point& p3,
283 const Point& q0,
284 const Point& q1,
285 const Point& q2,
286 const Point& q3);
287
288 };
289
290}
291
292#endif
Definition IntersectionConstruction.h:39
static std::vector< Point > intersection_tetrahedron_tetrahedron_3d(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &q0, const Point &q1, const Point &q2, const Point &q3)
Compute intersection of tetrahedron p0-p1-p2-p3 with tetrahedron q0-q1-q2-q3 (3D)
Definition IntersectionConstruction.cpp:856
static std::vector< Point > intersection_triangle_triangle_2d(const Point &p0, const Point &p1, const Point &p2, const Point &q0, const Point &q1, const Point &q2)
Compute intersection of triangle p0-p1-p2 with triangle q0-q1-q2 (2D)
Definition IntersectionConstruction.cpp:656
static std::vector< Point > intersection_segment_segment_2d(const Point &p0, const Point &p1, const Point &q0, const Point &q1)
Compute intersection of segment p0-p1 with segment q0-q1 (2D)
Definition IntersectionConstruction.cpp:330
static std::vector< double > intersection_segment_point_1d(double p0, double p1, double q0)
Compute intersection of segment p0-p1 with point q0 (1D)
Definition IntersectionConstruction.cpp:241
static std::vector< Point > intersection(const MeshEntity &entity_0, const MeshEntity &entity_1)
Definition IntersectionConstruction.cpp:83
static std::vector< double > intersection_point_point_1d(double p0, double q0)
Compute intersection of points p0 and q0 (1D)
Definition IntersectionConstruction.cpp:212
static std::vector< Point > intersection_tetrahedron_triangle_3d(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &q0, const Point &q1, const Point &q2)
Compute intersection of tetrahedron p0-p1-p2-p3 with triangle q0-q1-q2 (3D)
Definition IntersectionConstruction.cpp:721
static std::vector< Point > intersection_triangle_point_2d(const Point &p0, const Point &p1, const Point &p2, const Point &q0)
Compute intersection of triangle p0-p1-p2 with point q0 (2D)
Definition IntersectionConstruction.cpp:274
static std::vector< Point > intersection_triangle_segment_3d(const Point &p0, const Point &p1, const Point &p2, const Point &q0, const Point &q1)
Compute intersection of triangle p0-p1-p2 with segment q0-q1 (3D)
Definition IntersectionConstruction.cpp:845
static std::vector< Point > intersection_segment_point_3d(const Point &p0, const Point &p1, const Point &q0)
Compute intersection of segment p0-p1 with point q0 (3D)
Definition IntersectionConstruction.cpp:263
static std::vector< Point > intersection_point_point_2d(const Point &p0, const Point &q0)
Compute intersection of points p0 and q0 (2D)
Definition IntersectionConstruction.cpp:221
static std::vector< Point > intersection_segment_point_2d(const Point &p0, const Point &p1, const Point &q0)
Compute intersection of segment p0-p1 with point q0 (2D)
Definition IntersectionConstruction.cpp:252
static std::vector< Point > intersection_triangle_segment_2d(const Point &p0, const Point &p1, const Point &p2, const Point &q0, const Point &q1)
Compute intersection of triangle p0-p1-p2 with segment q0-q1 (2D)
Definition IntersectionConstruction.cpp:487
static std::vector< double > intersection_segment_segment_1d(double p0, double p1, double q0, double q1)
Compute intersection of segment p0-p1 with segment q0-q1 (1D)
Definition IntersectionConstruction.cpp:311
static std::vector< Point > intersection_tetrahedron_segment_3d(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &q0, const Point &q1)
Compute intersection of tetrahedron p0-p1-p2-p3 with segment q0-q1 (3D)
Definition IntersectionConstruction.cpp:629
static std::vector< Point > intersection_point_point_3d(const Point &p0, const Point &q0)
Compute intersection of points p0 and q0 (3D)
Definition IntersectionConstruction.cpp:231
static std::vector< Point > intersection_tetrahedron_point_3d(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &q0)
Compute intersection of tetrahedron p0-p1-p2-p3 with point q0 (3D)
Definition IntersectionConstruction.cpp:298
static std::vector< Point > intersection_segment_segment_3d(const Point &p0, const Point &p1, const Point &q0, const Point &q1)
Compute intersection of segment p0-p1 with segment q0-q1 (3D)
Definition IntersectionConstruction.cpp:476
static std::vector< Point > intersection_triangle_triangle_3d(const Point &p0, const Point &p1, const Point &p2, const Point &q0, const Point &q1, const Point &q2)
Compute intersection of triangle p0-p1-p2 with triangle q0-q1-q2 (3D)
Definition IntersectionConstruction.cpp:690
static std::vector< Point > intersection_triangle_point_3d(const Point &p0, const Point &p1, const Point &p2, const Point &q0)
Compute intersection of triangle p0-p1-p2 with point q0 (3D)
Definition IntersectionConstruction.cpp:286
Definition MeshEntity.h:43
Definition Point.h:41
Definition adapt.h:30