Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
bezier.c
Go to the documentation of this file.
1/* =============================================================================
2** This file is part of the mmg software package for the tetrahedral
3** mesh modification.
4** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004-
5**
6** mmg is free software: you can redistribute it and/or modify it
7** under the terms of the GNU Lesser General Public License as published
8** by the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** mmg is distributed in the hope that it will be useful, but WITHOUT
12** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14** License for more details.
15**
16** You should have received a copy of the GNU Lesser General Public
17** License and of the GNU General Public License along with mmg (in
18** files COPYING.LESSER and COPYING). If not, see
19** <http://www.gnu.org/licenses/>. Please read their terms carefully and
20** use this copy of the mmg distribution only if you accept them.
21** =============================================================================
22*/
23
36#include "mmgcommon_private.h"
37
51inline void MMG5_bezierEdge(MMG5_pMesh mesh,MMG5_int i0,MMG5_int i1,
52 double b0[3],double b1[3], int8_t isrid,double v[3])
53{
54 MMG5_pPoint p0,p1;
55 double ux,uy,uz,*n1,*n2,*t,ps1,ps2;
56
57 p0 = &mesh->point[i0];
58 p1 = &mesh->point[i1];
59
60 ux = p1->c[0] - p0->c[0];
61 uy = p1->c[1] - p0->c[1];
62 uz = p1->c[2] - p0->c[2];
63
64 if ( isrid ) {
65 if ( MG_SIN(p0->tag) || (p0->tag & MG_NOM) ) {
66 b0[0] = p0->c[0] + MMG5_ATHIRD*ux;
67 b0[1] = p0->c[1] + MMG5_ATHIRD*uy;
68 b0[2] = p0->c[2] + MMG5_ATHIRD*uz;
69 }
70 else {
71 t = &p0->n[0];
72 ps1 = t[0]*ux + t[1]*uy + t[2]*uz;
73 b0[0] = p0->c[0] + MMG5_ATHIRD*ps1*t[0];
74 b0[1] = p0->c[1] + MMG5_ATHIRD*ps1*t[1];
75 b0[2] = p0->c[2] + MMG5_ATHIRD*ps1*t[2];
76 }
77
78 if (MG_SIN(p1->tag) || (p1->tag & MG_NOM) ) {
79 b1[0] = p1->c[0] - MMG5_ATHIRD*ux;
80 b1[1] = p1->c[1] - MMG5_ATHIRD*uy;
81 b1[2] = p1->c[2] - MMG5_ATHIRD*uz;
82 }
83 else {
84 t = &p1->n[0];
85 ps1 = -(t[0]*ux + t[1]*uy + t[2]*uz);
86 b1[0] = p1->c[0] + MMG5_ATHIRD*ps1*t[0];
87 b1[1] = p1->c[1] + MMG5_ATHIRD*ps1*t[1];
88 b1[2] = p1->c[2] + MMG5_ATHIRD*ps1*t[2];
89 }
90 }
91
92 /* regular edge */
93 else {
94 if ( MG_SIN(p0->tag) || (p0->tag & MG_NOM) ) {
95 b0[0] = p0->c[0] + MMG5_ATHIRD*ux;
96 b0[1] = p0->c[1] + MMG5_ATHIRD*uy;
97 b0[2] = p0->c[2] + MMG5_ATHIRD*uz;
98 }
99 else {
100 if ( MG_GEO & p0->tag ) {
101 n1 = &mesh->xpoint[p0->xp].n1[0];
102 n2 = &mesh->xpoint[p0->xp].n2[0];
103 ps1 = v[0]*n1[0] + v[1]*n1[1] + v[2]*n1[2];
104 ps2 = v[0]*n2[0] + v[1]*n2[1] + v[2]*n2[2];
105 if ( ps1 < ps2 ) {
106 n1 = &mesh->xpoint[p0->xp].n2[0];
107 ps1 = ps2;
108 }
109 }
110 else if ( (MG_REF & p0->tag) || (MG_BDY & p0->tag) ) {
111 // if MG_BDY, we are in mmg3d: the normal is stored in the xPoint
112 n1 = &mesh->xpoint[p0->xp].n1[0];
113 ps1 = ux*n1[0] + uy*n1[1] + uz*n1[2];
114 }
115 else {
116 n1 = &p0->n[0];
117 ps1 = ux*n1[0] + uy*n1[1] + uz*n1[2];
118 }
119 b0[0] = MMG5_ATHIRD*(2.0*p0->c[0] + p1->c[0] - ps1*n1[0]);
120 b0[1] = MMG5_ATHIRD*(2.0*p0->c[1] + p1->c[1] - ps1*n1[1]);
121 b0[2] = MMG5_ATHIRD*(2.0*p0->c[2] + p1->c[2] - ps1*n1[2]);
122 }
123
124 if ( MG_SIN(p1->tag) || (p1->tag & MG_NOM) ) {
125 b1[0] = p1->c[0] - MMG5_ATHIRD*ux;
126 b1[1] = p1->c[1] - MMG5_ATHIRD*uy;
127 b1[2] = p1->c[2] - MMG5_ATHIRD*uz;
128 }
129 else {
130 if ( MG_GEO & p1->tag ) {
131 n1 = &mesh->xpoint[p1->xp].n1[0];
132 n2 = &mesh->xpoint[p1->xp].n2[0];
133 ps1 = -(v[0]*n1[0] + v[1]*n1[1] + v[2]*n1[2]);
134 ps2 = -(v[0]*n2[0] + v[1]*n2[1] + v[2]*n2[2]);
135 if ( fabs(ps2) < fabs(ps1) ) {
136 n1 = &mesh->xpoint[p1->xp].n2[0];
137 ps1 = ps2;
138 }
139 }
140 else if ( (MG_REF & p1->tag ) || (MG_BDY & p1->tag) ) {
141 // if MG_BDY, we are in mmg3d: the normal is stored in the xPoint
142 n1 = &mesh->xpoint[p1->xp].n1[0];
143 ps1 = -(ux*n1[0] + uy*n1[1] + uz*n1[2]);
144 }
145 else {
146 n1 = &p1->n[0];
147 ps1 = -(ux*n1[0] + uy*n1[1] + uz*n1[2]);
148 }
149 b1[0] = MMG5_ATHIRD*(2.0*p1->c[0] + p0->c[0] - ps1*n1[0]);
150 b1[1] = MMG5_ATHIRD*(2.0*p1->c[1] + p0->c[1] - ps1*n1[1]);
151 b1[2] = MMG5_ATHIRD*(2.0*p1->c[2] + p0->c[2] - ps1*n1[2]);
152 }
153 }
154}
MMG5_pMesh * mesh
void MMG5_bezierEdge(MMG5_pMesh mesh, MMG5_int i0, MMG5_int i1, double b0[3], double b1[3], int8_t isrid, double v[3])
Definition: bezier.c:51
#define MG_GEO
#define MMG5_ATHIRD
#define MG_SIN(tag)
#define MG_BDY
#define MG_NOM
#define MG_REF
MMG mesh structure.
Definition: libmmgtypes.h:605
MMG5_pPoint point
Definition: libmmgtypes.h:641
MMG5_pxPoint xpoint
Definition: libmmgtypes.h:642
Structure to store points of a MMG mesh.
Definition: libmmgtypes.h:270
double n[3]
Definition: libmmgtypes.h:272
int16_t tag
Definition: libmmgtypes.h:284
double c[3]
Definition: libmmgtypes.h:271
MMG5_int xp
Definition: libmmgtypes.h:279
double n2[3]
Definition: libmmgtypes.h:295
double n1[3]
Definition: libmmgtypes.h:295