10 #if !defined(KRATOS_BREP_TRIMMING_UTILITIES_H_INCLUDED)
11 #define KRATOS_BREP_TRIMMING_UTILITIES_H_INCLUDED
20 #include "clipper/include/clipper2/clipper.h"
53 typedef signed long long cInt;
56 static void CreateBrepSurfaceTrimmingIntegrationPoints(
60 const std::vector<double>& rSpansU,
61 const std::vector<double>& rSpansV,
76 static void Triangulate_OPT(
const Clipper2Lib::Path64& polygon, std::vector<Matrix>& triangles,
const double factor)
78 if (polygon.size() == 4)
87 triangles.push_back(triangle);
98 std::list<Diagonal> diagonals;
101 std::vector< Clipper2Lib::Point64 >
const& points = polygon;
102 matrix<DPState> dpstates(
n,
n);
108 dpstates(
j,
i).visible =
true;
109 dpstates(
j,
i).weight = 0;
110 dpstates(
j,
i).bestvertex = -1;
120 dpstates(
j,
i).visible =
false;
129 dpstates(
j,
i).visible =
false;
138 dpstates(
j,
i).visible =
false;
146 dpstates(
n - 1, 0).visible =
true;
147 dpstates(
n - 1, 0).weight = 0;
148 dpstates(
n - 1, 0).bestvertex = -1;
153 if (!dpstates(
j,
i).visible)
continue;
156 if (!dpstates(
k,
i).visible)
continue;
157 if (!dpstates(
j,
k).visible)
continue;
159 if (
k <= (
i + 1))
d1 = 0;
161 if (
j <= (
k + 1)) d2 = 0;
164 weight = dpstates(
k,
i).weight + dpstates(
j,
k).weight +
d1 + d2;
166 if ((bestvertex == -1) || (weight < minweight)) {
171 if (bestvertex == -1) {
175 dpstates(
j,
i).bestvertex = bestvertex;
176 dpstates(
j,
i).weight = minweight;
182 diagonals.push_back(newdiagonal);
184 while (!diagonals.empty()) {
185 diagonal = *(diagonals.begin());
186 diagonals.pop_front();
188 bestvertex = dpstates(diagonal.
index2, diagonal.
index1).bestvertex;
189 if (bestvertex == -1) {
201 triangles.push_back(triangle);
206 if (bestvertex > (diagonal.
index1 + 1)) {
208 newdiagonal.
index2 = bestvertex;
209 diagonals.push_back(newdiagonal);
211 if (diagonal.
index2 > (bestvertex + 1)) {
212 newdiagonal.
index1 = bestvertex;
214 diagonals.push_back(newdiagonal);
240 tmp = (p3[1] - p1[1]) * (p2[0] - p1[0]) - (p3[0] - p1[0]) * (p2[1] - p1[1]);
241 if (
tmp > 0)
return true;
247 return sqrt(point_1[0] * point_2[0] + point_1[1] * point_2[1]);
252 double area = (triangle(0, 0) * (triangle(1, 1) - triangle(2, 1))
253 + triangle(1, 0) * (triangle(2, 1) - triangle(0, 1))
254 + triangle(2, 0) * (triangle(0, 1) - triangle(1, 1))) / 2;
263 if ((p11[0] == p21[0]) && (p11[1] == p21[1]))
return false;
264 if ((p11[0] == p22[0]) && (p11[1] == p22[1]))
return false;
265 if ((p12[0] == p21[0]) && (p12[1] == p21[1]))
return false;
266 if ((p12[0] == p22[0]) && (p12[1] == p22[1]))
return false;
269 double dot11, dot12, dot21, dot22;
271 v1ort[0] = p12[1] - p11[1];
272 v1ort[1] = p11[0] - p12[0];
274 v2ort[0] = p22[1] - p21[1];
275 v2ort[1] = p21[0] - p22[0];
277 v[0] = p21[0] - p11[0];
278 v[1] = p21[1] - p11[1];
279 dot21 =
v[0] * v1ort[0] +
v[1] * v1ort[1];
280 v[0] = p22[0] - p11[0];
281 v[1] = p22[1] - p11[1];
282 dot22 =
v[0] * v1ort[0] +
v[1] * v1ort[1];
284 v[0] = p11[0] - p21[0];
285 v[1] = p11[1] - p21[1];
286 dot11 =
v[0] * v2ort[0] +
v[1] * v2ort[1];
287 v[0] = p12[0] - p21[0];
288 v[1] = p12[1] - p21[1];
289 dot12 =
v[0] * v2ort[0] +
v[1] * v2ort[1];
291 if (dot11 * dot12 > 0)
return false;
292 if (dot21 * dot22 > 0)
return false;
302 Clipper2Lib::Point64 int_point;
311 const Clipper2Lib::Point64& int_point,
316 point[0] = int_point.x *
factor;
317 point[1] = int_point.y *
factor;
The BrepCurveOnSurface acts as topology for curves on surfaces.
Definition: brep_curve_on_surface.h:44
Definition: brep_trimming_utilities.h:37
signed long long cInt
Definition: brep_trimming_utilities.h:53
static bool IsConvex(const array_1d< double, 2 > &p1, const array_1d< double, 2 > &p2, const array_1d< double, 2 > &p3)
Definition: brep_trimming_utilities.h:234
static bool InCone(array_1d< double, 2 > &p1, array_1d< double, 2 > &p2, array_1d< double, 2 > &p3, array_1d< double, 2 > &p)
Definition: brep_trimming_utilities.h:219
static double Distance(array_1d< double, 2 > point_1, array_1d< double, 2 > point_2)
Definition: brep_trimming_utilities.h:245
array_1d< double, 3 > CoordinatesArrayType
Definition: brep_trimming_utilities.h:48
std::vector< std::pair< double, CoordinatesArrayType > > TessellationType
Definition: brep_trimming_utilities.h:51
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: brep_trimming_utilities.h:46
std::size_t SizeType
Definition: brep_trimming_utilities.h:43
static bool Intersects(array_1d< double, 2 > &p11, array_1d< double, 2 > &p12, array_1d< double, 2 > &p21, array_1d< double, 2 > &p22)
Definition: brep_trimming_utilities.h:260
static Clipper2Lib::Point64 ToIntPoint(const double x, const double y, const double factor)
Definition: brep_trimming_utilities.h:297
std::size_t IndexType
Definition: brep_trimming_utilities.h:42
IntegrationPoint< 3 > IntegrationPointType
Definition: brep_trimming_utilities.h:45
static array_1d< double, 2 > IntPointToDoublePoint(const Clipper2Lib::Point64 &int_point, const double factor)
Definition: brep_trimming_utilities.h:310
static void Triangulate_OPT(const Clipper2Lib::Path64 &polygon, std::vector< Matrix > &triangles, const double factor)
Definition: brep_trimming_utilities.h:76
static double GetAreaOfTriangle(const Matrix &triangle)
Definition: brep_trimming_utilities.h:250
Integration information for the creation of integration points.
Definition: integration_info.h:35
Short class definition.
Definition: integration_point.h:52
Definition: amatrix_interface.h:41
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
v
Definition: generate_convection_diffusion_explicit_element.py:114
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
p
Definition: sensitivityMatrix.py:52
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
subroutine d1(DSTRAN, D, dtime, NDI, NSHR, NTENS)
Definition: TensorModule.f:594
e
Definition: run_cpp_mpi_tests.py:31
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254
Definition: brep_trimming_utilities.h:64
long bestvertex
Definition: brep_trimming_utilities.h:67
double weight
Definition: brep_trimming_utilities.h:66
bool visible
Definition: brep_trimming_utilities.h:65
Definition: brep_trimming_utilities.h:70
long index1
Definition: brep_trimming_utilities.h:71
long index2
Definition: brep_trimming_utilities.h:72