Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
gentools_s.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
35#include "libmmgs_private.h"
36
37
38/* Delete all triangle references in mesh */
40 MMG5_pTria pt;
41 MMG5_int k;
42
43 for(k=1; k<=mesh->nt; k++) {
44 pt = &mesh->tria[k];
45 pt->ref = 0;
46 }
47
48 return 1;
49}
50
64int setref(MMG5_pMesh mesh,MMG5_int start,MMG5_int ref,int putreq) {
65 MMG5_pTria pt,pt1;
66 MMG5_int base,*list,*adja,cur,k,iel,jel;
67 int ilist;
68 int8_t j,voy;
69
70 ilist = cur = 0;
71 MMG5_SAFE_CALLOC(list,mesh->nt+1,MMG5_int,return 0);
72 base = ++mesh->base;
73
74 /* Pile up triangles from start, till a GEO boundary is met */
75 pt = &mesh->tria[start];
76 list[ilist] = start;
77 ilist++;
78 assert( ilist <= mesh->nt );
79 pt->flag = base;
80
81 do {
82 iel = list[cur];
83 pt = &mesh->tria[iel];
84 adja = &mesh->adja[3*(iel-1)+1];
85
86 for(j=0; j<3; j++) {
87 if( MG_EDG(pt->tag[j]) ) {
88 if( putreq ) {
89 pt->tag[j] |= MG_REQ;
90 jel = adja[j] / 3;
91 voy = adja[j] % 3;
92 if( !jel ) continue;
93 pt1 = &mesh->tria[jel];
94 pt1->tag[voy] |= MG_REQ;
95 }
96 continue;
97 }
98 jel = adja[j] / 3;
99 assert(jel);
100 pt1 = &mesh->tria[jel];
101 if ( pt1->flag == base ) continue;
102
103 list[ilist] = jel;
104 ilist++;
105 assert( ilist <= mesh->nt );
106 pt1->flag = base;
107 }
108 cur++;
109 }
110 while( cur < ilist );
111
112 /* Set all references of triangles of list to ref */
113 for (k=0; k<ilist; k++) {
114 iel = list[k];
115 pt = &mesh->tria[iel];
116 pt->ref = ref;
117 }
118 MMG5_SAFE_FREE(list);
119 return 1;
120}
121
123MMG5_int MMGS_indElt(MMG5_pMesh mesh, MMG5_int kel) {
124 MMG5_pTria pt;
125 MMG5_int ne, k;
126
127 ne = 0;
128 for (k=1; k<=mesh->nt; k++) {
129 pt = &mesh->tria[k];
130 if ( MG_EOK(pt) ) {
131 ne++;
132 if ( k == kel ) return ne;
133 }
134 }
135 return 0;
136}
137
139MMG5_int MMGS_indPt(MMG5_pMesh mesh, MMG5_int kp) {
140 MMG5_pPoint ppt;
141 MMG5_int np, k;
142
143 np = 0;
144 for (k=1; k<=mesh->np; k++) {
145 ppt = &mesh->point[k];
146 if ( MG_VOK(ppt) ) {
147 np++;
148 if ( k == kp ) return np;
149 }
150 }
151 return 0;
152}
153
162
163 if ( !nsd ) {
164 return;
165 }
166
167 if ( mesh->info.imprim > 4 || mesh->info.ddebug ) {
168 fprintf(stdout,"\n -- ONLY KEEP DOMAIN OF REF %"MMG5_PRId"\n",nsd );
169 }
170
172
174
176
177 return;
178}
MMG5_pMesh * mesh
MMG5_int MMGS_indPt(MMG5_pMesh mesh, MMG5_int kp)
Definition: gentools_s.c:139
int delref(MMG5_pMesh mesh)
Definition: gentools_s.c:39
void MMGS_keep_only1Subdomain(MMG5_pMesh mesh, MMG5_int nsd)
Definition: gentools_s.c:161
MMG5_int MMGS_indElt(MMG5_pMesh mesh, MMG5_int kel)
Definition: gentools_s.c:123
int setref(MMG5_pMesh mesh, MMG5_int start, MMG5_int ref, int putreq)
Definition: gentools_s.c:64
int MMGS_delElt(MMG5_pMesh mesh, MMG5_int iel)
Definition: zaldy_s.c:93
void MMGS_delPt(MMG5_pMesh mesh, MMG5_int ip)
Definition: zaldy_s.c:58
#define MG_REQ
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MG_EOK(pt)
void MMG5_keep_subdomainElts(MMG5_pMesh, int, int(*delElt)(MMG5_pMesh, MMG5_int))
Definition: tools.c:1072
#define MG_EDG(tag)
void MMG5_mark_usedVertices(MMG5_pMesh mesh, void(*delPt)(MMG5_pMesh, MMG5_int))
Definition: tools.c:1018
void MMG5_mark_verticesAsUnused(MMG5_pMesh mesh)
Definition: tools.c:994
#define MG_VOK(ppt)
#define MMG5_SAFE_FREE(ptr)
int8_t ddebug
Definition: libmmgtypes.h:532
MMG mesh structure.
Definition: libmmgtypes.h:605
MMG5_Info info
Definition: libmmgtypes.h:651
MMG5_pPoint point
Definition: libmmgtypes.h:641
MMG5_int * adja
Definition: libmmgtypes.h:624
MMG5_int base
Definition: libmmgtypes.h:616
MMG5_int nt
Definition: libmmgtypes.h:612
MMG5_pTria tria
Definition: libmmgtypes.h:647
MMG5_int np
Definition: libmmgtypes.h:612
Structure to store points of a MMG mesh.
Definition: libmmgtypes.h:270
int16_t tag[3]
Definition: libmmgtypes.h:342
MMG5_int ref
Definition: libmmgtypes.h:335
MMG5_int flag
Definition: libmmgtypes.h:341