gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
Geo.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef GEO_H
7 #define GEO_H
8 
9 // Internal data structures and functions for the built-in CAD kernel. This is
10 // legacy code and should never be used directly: use GEO_Internals instead, or
11 // the public api.
12 
13 #include <cmath>
14 #include <vector>
15 #include <list>
16 #include "GmshDefines.h"
17 #include "GeoDefines.h"
18 #include "gmshSurface.h"
19 #include "ListUtils.h"
20 #include "TreeUtils.h"
21 #include "SPoint2.h"
22 #include "ExtrudeParams.h"
23 #include "findLinks.h"
24 
25 struct Coord {
26  double X, Y, Z;
27 };
28 
29 class Vertex {
30 public:
31  int Num;
32  int Typ;
33  double lc, u, w;
35  // a model vertex is usually defined in the euclidian coordinates
36  // (Pos). Yet, it can also be defined in the parametric coordinates
37  // of a surface: pntOnGeometry stores the local coodinates of the
38  // vertex in the gmshSurface it belongs to.
42  Vertex(double X = 0., double Y = 0., double Z = 0., double l = 1.,
43  double W = 1.)
44  : Num(0), lc(l), u(0.), w(W), geometry(nullptr), boundaryLayerIndex(0)
45  {
46  Typ = MSH_POINT;
47  Pos.X = X;
48  Pos.Y = Y;
49  Pos.Z = Z;
50  }
51  void norme()
52  {
53  double const d = std::sqrt(Pos.X * Pos.X + Pos.Y * Pos.Y + Pos.Z * Pos.Z);
54  if(d == 0.0) return;
55  Pos.X /= d;
56  Pos.Y /= d;
57  Pos.Z /= d;
58  }
59  Vertex operator%(Vertex &autre) // cross product
60  {
61  return Vertex(Pos.Y * autre.Pos.Z - Pos.Z * autre.Pos.Y,
62  -(Pos.X * autre.Pos.Z - Pos.Z * autre.Pos.X),
63  Pos.X * autre.Pos.Y - Pos.Y * autre.Pos.X, lc, w);
64  }
65 };
66 
67 class CircParam {
68 public:
69  double t1, t2, f1, f2, incl;
70  double invmat[3][3];
71  double n[3];
72 };
73 
74 class Curve {
75 public:
76  int Num;
77  int Typ;
79  int Method;
83  double l;
84  double mat[4][4];
87  double ubeg, uend;
90  float *k;
91  int degre;
95  int master;
96  std::list<double> affineTransformation;
97  bool degenerate() const
98  {
100  return true;
101  return degenerated;
102  }
103 };
104 
105 class EdgeLoop {
106 public:
107  int Num;
109 };
110 
111 class Surface {
112 public:
113  int Num;
114  int Typ;
115  int Method;
117  int Recombine_Dir; // -1 is left, +1 is right, -2/2 is alternated left/right
125  // A surface is defined topologically by its Generatrices i.e. curves that are
126  // the closure of it. The geometry of the surface is defined hereafter. Note
127  // that this representation should be the only one in gmsh, so parameter
128  // "Type" should disappear from the class Surface.
131  bool degenerate() const;
132 };
133 
134 class SurfaceLoop {
135 public:
136  int Num;
138 };
139 
140 class Volume {
141 public:
142  int Num;
143  int Typ;
144  int Method;
146  int QuadTri;
152 };
153 
155 public:
156  int Num;
157  int Typ;
159 };
160 
161 int CompareVertex(const void *a, const void *b);
162 int CompareSurfaceLoop(const void *a, const void *b);
163 int CompareEdgeLoop(const void *a, const void *b);
164 int CompareCurve(const void *a, const void *b);
165 int CompareSurface(const void *a, const void *b);
166 int CompareVolume(const void *a, const void *b);
167 int ComparePhysicalGroup(const void *a, const void *b);
168 
169 void FreeVertex(void *a, void *b);
170 void FreePhysicalGroup(void *a, void *b);
171 void FreeEdgeLoop(void *a, void *b);
172 void FreeSurfaceLoop(void *a, void *b);
173 void FreeCurve(void *a, void *b);
174 void FreeSurface(void *a, void *b);
175 void FreeVolume(void *a, void *b);
176 
177 inline void Projette(Vertex *v, double mat[3][3])
178 {
179  double X = v->Pos.X * mat[0][0] + v->Pos.Y * mat[0][1] + v->Pos.Z * mat[0][2];
180  double Y = v->Pos.X * mat[1][0] + v->Pos.Y * mat[1][1] + v->Pos.Z * mat[1][2];
181  double Z = v->Pos.X * mat[2][0] + v->Pos.Y * mat[2][1] + v->Pos.Z * mat[2][2];
182  v->Pos.X = X;
183  v->Pos.Y = Y;
184  v->Pos.Z = Z;
185 }
186 
187 Vertex *CreateVertex(int Num, double X, double Y, double Z, double lc,
188  double u);
189 Vertex *CreateVertex(int Num, double u, double v, gmshSurface *s, double lc);
190 Curve *CreateCurve(int Num, int Typ, int Order, List_T *Liste, List_T *Knots,
191  int p1, int p2, double u1, double u2, bool &ok);
193 Surface *CreateSurface(int Num, int Typ);
194 Volume *CreateVolume(int Num, int Typ);
195 EdgeLoop *CreateEdgeLoop(int Num, List_T *intlist);
196 SurfaceLoop *CreateSurfaceLoop(int Num, List_T *intlist);
197 PhysicalGroup *CreatePhysicalGroup(int Num, int typ, List_T *intlist);
198 
199 bool EndCurve(Curve *c);
200 void EndSurface(Surface *s);
201 
202 Vertex *FindPoint(int inum);
203 Curve *FindCurve(int inum);
204 EdgeLoop *FindEdgeLoop(int inum);
205 Surface *FindSurface(int inum);
206 SurfaceLoop *FindSurfaceLoop(int inum);
207 Volume *FindVolume(int inum);
208 PhysicalGroup *FindPhysicalGroup(int inum, int type);
209 
210 bool TranslateShapes(double X, double Y, double Z, List_T *shapes);
211 bool DilatShapes(double X, double Y, double Z, double A, double B, double C,
212  List_T *shapes);
213 bool RotateShapes(double Ax, double Ay, double Az, double Px, double Py,
214  double Pz, double alpha, List_T *shapes);
215 bool SymmetryShapes(double A, double B, double C, double D, List_T *shapes);
216 
221 
222 void DeletePoint(int Num, bool recursive = false);
223 void DeleteCurve(int Num, bool recursive = false);
224 void DeleteSurface(int Num, bool recursive = false);
225 void DeleteVolume(int Num, bool recursive = false);
226 void DeletePhysicalPoint(int Num);
227 void DeletePhysicalLine(int Num);
228 void DeletePhysicalSurface(int Num);
229 void DeletePhysicalVolume(int Num);
230 
231 void ExtrudeShapes(int extrude_type, List_T *in, double T0, double T1,
232  double T2, double A0, double A1, double A2, double X0,
233  double X1, double X2, double alpha, ExtrudeParams *e,
234  List_T *out);
235 void ProtudeXYZ(double &x, double &y, double &z, ExtrudeParams *e);
236 
237 void ReplaceAllDuplicates();
238 void ReplaceAllDuplicatesNew(double tol = -1.);
239 
240 bool ProjectPointOnSurface(Surface *s, Vertex &p, double uv[2]);
241 bool IntersectCurvesWithSurface(List_T *curve_ids, int surface_id,
242  List_T *shapes);
243 bool SplitCurve(int line_id, List_T *vertices_id, List_T *curves);
244 
245 int RecognizeLineLoop(List_T *liste, int *loop);
246 int RecognizeSurfaceLoop(List_T *liste, int *loop);
247 
248 bool SortEdgesInLoop(int num, List_T *edges, bool reorient = false);
249 bool SetSurfaceGeneratrices(Surface *s, List_T *loops);
250 bool SetVolumeSurfaces(Volume *v, List_T *loops);
251 
252 void SetTranslationMatrix(double matrix[4][4], double T[3]);
253 void SetSymmetryMatrix(double matrix[4][4], double A, double B, double C,
254  double D);
255 void SetDilatationMatrix(double matrix[4][4], double T[3], double A, double B,
256  double C);
257 void SetRotationMatrix(double matrix[4][4], double Axe[3], double alpha);
258 
259 int NEWPOINT();
260 int NEWCURVE();
261 int NEWCURVELOOP();
262 int NEWSURFACE();
263 int NEWSURFACELOOP();
264 int NEWVOLUME();
265 int NEWREG();
266 int NEWFIELD();
267 int NEWPHYSICAL();
268 
269 #endif
Volume
Definition: Geo.h:140
D
#define D
Definition: DefaultOptions.h:24
Surface::TrsfPoints
List_T * TrsfPoints
Definition: Geo.h:122
Surface::Num
int Num
Definition: Geo.h:113
CompareSurface
int CompareSurface(const void *a, const void *b)
Definition: Geo.cpp:81
Vertex::pntOnGeometry
SPoint2 pntOnGeometry
Definition: Geo.h:40
Volume::QuadTri
int QuadTri
Definition: Geo.h:146
PhysicalGroup::Num
int Num
Definition: Geo.h:156
NEWCURVELOOP
int NEWCURVELOOP()
Definition: Geo.cpp:3796
DeletePhysicalSurface
void DeletePhysicalSurface(int Num)
Definition: Geo.cpp:1125
DeletePhysicalVolume
void DeletePhysicalVolume(int Num)
Definition: Geo.cpp:1136
Curve::nbPointsTransfinite
int nbPointsTransfinite
Definition: Geo.h:80
DeletePhysicalLine
void DeletePhysicalLine(int Num)
Definition: Geo.cpp:1114
CompareSurfaceLoop
int CompareSurfaceLoop(const void *a, const void *b)
Definition: Geo.cpp:60
Curve
Definition: Geo.h:74
Curve::degenerate
bool degenerate() const
Definition: Geo.h:97
Surface::Typ
int Typ
Definition: Geo.h:114
EndCurve
bool EndCurve(Curve *c)
Definition: Geo.cpp:225
CircParam::f2
double f2
Definition: Geo.h:69
SPoint2
Definition: SPoint2.h:12
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
EdgeLoop::Num
int Num
Definition: Geo.h:107
Vertex::u
double u
Definition: Geo.h:33
Curve::end
Vertex * end
Definition: Geo.h:85
FreeCurve
void FreeCurve(void *a, void *b)
Definition: Geo.cpp:567
List_T
Definition: ListUtils.h:9
ListUtils.h
CircParam::invmat
double invmat[3][3]
Definition: Geo.h:70
FindSurface
Surface * FindSurface(int inum)
Definition: Geo.cpp:717
ReplaceAllDuplicates
void ReplaceAllDuplicates()
Definition: Geo.cpp:2527
List_Nbr
int List_Nbr(List_T *liste)
Definition: ListUtils.cpp:106
Vertex
Definition: Geo.h:29
PhysicalGroup::Entities
List_T * Entities
Definition: Geo.h:158
EndSurface
void EndSurface(Surface *s)
Definition: Geo.cpp:426
MSH_POINT
#define MSH_POINT
Definition: GeoDefines.h:16
Coord
Definition: Geo.h:25
CircParam
Definition: Geo.h:67
FreeSurface
void FreeSurface(void *a, void *b)
Definition: Geo.cpp:604
Surface::MeshSizeFromBoundary
int MeshSizeFromBoundary
Definition: Geo.h:130
DeletePoint
void DeletePoint(int Num, bool recursive=false)
Definition: Geo.cpp:956
RecognizeLineLoop
int RecognizeLineLoop(List_T *liste, int *loop)
Definition: Geo.cpp:1214
DuplicateCurve
Curve * DuplicateCurve(Curve *c)
Definition: Geo.cpp:830
NEWCURVE
int NEWCURVE()
Definition: Geo.cpp:3784
SetSymmetryMatrix
void SetSymmetryMatrix(double matrix[4][4], double A, double B, double C, double D)
Definition: Geo.cpp:1258
NEWPOINT
int NEWPOINT()
Definition: Geo.cpp:3776
gmshSurface.h
edges
static int edges[6][2]
Definition: meshGRegionLocalMeshMod.cpp:23
CreateReversedCurve
Curve * CreateReversedCurve(Curve *c)
Definition: Geo.cpp:1147
DeletePhysicalPoint
void DeletePhysicalPoint(int Num)
Definition: Geo.cpp:1103
NEWREG
int NEWREG()
Definition: Geo.cpp:3846
Vertex::boundaryLayerIndex
int boundaryLayerIndex
Definition: Geo.h:41
FindCurve
Curve * FindCurve(int inum)
Definition: Geo.cpp:703
Curve::endByTag
int endByTag
Definition: Geo.h:86
Volume::Surfaces
List_T * Surfaces
Definition: Geo.h:149
Vertex::Num
int Num
Definition: Geo.h:31
Volume::Extrude
ExtrudeParams * Extrude
Definition: Geo.h:147
Curve::Control_Points
List_T * Control_Points
Definition: Geo.h:88
FreePhysicalGroup
void FreePhysicalGroup(void *a, void *b)
Definition: Geo.cpp:158
Curve::begByTag
int begByTag
Definition: Geo.h:86
Curve::uend
double uend
Definition: Geo.h:87
Volume::Typ
int Typ
Definition: Geo.h:143
SetVolumeSurfaces
bool SetVolumeSurfaces(Volume *v, List_T *loops)
Definition: Geo.cpp:3734
Vertex::Vertex
Vertex(double X=0., double Y=0., double Z=0., double l=1., double W=1.)
Definition: Geo.h:42
NEWFIELD
int NEWFIELD()
Definition: Geo.cpp:3866
Volume::Method
int Method
Definition: Geo.h:144
gmshSurface
Definition: gmshSurface.h:22
Curve::ubeg
double ubeg
Definition: Geo.h:87
Surface::Extrude
ExtrudeParams * Extrude
Definition: Geo.h:124
Curve::Method
int Method
Definition: Geo.h:79
FindPoint
Vertex * FindPoint(int inum)
Definition: Geo.cpp:689
DuplicateVertex
Vertex * DuplicateVertex(Vertex *v)
Definition: Geo.cpp:778
FreeSurfaceLoop
void FreeSurfaceLoop(void *a, void *b)
Definition: Geo.cpp:208
TranslateShapes
bool TranslateShapes(double X, double Y, double Z, List_T *shapes)
Definition: Geo.cpp:1549
Curve::affineTransformation
std::list< double > affineTransformation
Definition: Geo.h:96
ProtudeXYZ
void ProtudeXYZ(double &x, double &y, double &z, ExtrudeParams *e)
Definition: Geo.cpp:2542
CreateSurface
Surface * CreateSurface(int Num, int Typ)
Definition: Geo.cpp:579
Curve::typeTransfinite
int typeTransfinite
Definition: Geo.h:81
RecognizeSurfaceLoop
int RecognizeSurfaceLoop(List_T *liste, int *loop)
Definition: Geo.cpp:1232
Vertex::norme
void norme()
Definition: Geo.h:51
Curve::k
float * k
Definition: Geo.h:90
CompareVertex
int CompareVertex(const void *a, const void *b)
Definition: Geo.cpp:30
Curve::beg
Vertex * beg
Definition: Geo.h:85
SetRotationMatrix
void SetRotationMatrix(double matrix[4][4], double Axe[3], double alpha)
Definition: Geo.cpp:1316
Vertex::Typ
int Typ
Definition: Geo.h:32
Projette
void Projette(Vertex *v, double mat[3][3])
Definition: Geo.h:177
CompareEdgeLoop
int CompareEdgeLoop(const void *a, const void *b)
Definition: Geo.cpp:67
ComparePhysicalGroup
int ComparePhysicalGroup(const void *a, const void *b)
Definition: Geo.cpp:95
ExtrudeParams.h
CreateSurfaceLoop
SurfaceLoop * CreateSurfaceLoop(int Num, List_T *intlist)
Definition: Geo.cpp:193
DuplicateVolume
Volume * DuplicateVolume(Volume *s)
Definition: Geo.cpp:942
CreateEdgeLoop
EdgeLoop * CreateEdgeLoop(int Num, List_T *intlist)
Definition: Geo.cpp:168
Surface
Definition: Geo.h:111
GmshDefines.h
NEWPHYSICAL
int NEWPHYSICAL()
Definition: Geo.cpp:3875
SortEdgesInLoop
bool SortEdgesInLoop(int num, List_T *edges, bool reorient=false)
Definition: Geo.cpp:3597
FindPhysicalGroup
PhysicalGroup * FindPhysicalGroup(int inum, int type)
Definition: Geo.cpp:755
DuplicateSurface
Surface * DuplicateSurface(Surface *s)
Definition: Geo.cpp:895
SymmetryShapes
bool SymmetryShapes(double A, double B, double C, double D, List_T *shapes)
Definition: Geo.cpp:1608
Vertex::lc
double lc
Definition: Geo.h:33
Volume::SurfacesOrientations
List_T * SurfacesOrientations
Definition: Geo.h:150
PhysicalGroup
Definition: Geo.h:154
ProjectPointOnSurface
bool ProjectPointOnSurface(Surface *s, Vertex &p, double uv[2])
Definition: Geo.cpp:3340
DilatShapes
bool DilatShapes(double X, double Y, double Z, double A, double B, double C, List_T *shapes)
Definition: Geo.cpp:1564
DeleteSurface
void DeleteSurface(int Num, bool recursive=false)
Definition: Geo.cpp:1018
Curve::mat
double mat[4][4]
Definition: Geo.h:84
Curve::master
int master
Definition: Geo.h:95
EdgeLoop
Definition: Geo.h:105
Curve::l
double l
Definition: Geo.h:83
SurfaceLoop::Num
int Num
Definition: Geo.h:136
GeoDefines.h
CompareCurve
int CompareCurve(const void *a, const void *b)
Definition: Geo.cpp:74
IntersectCurvesWithSurface
bool IntersectCurvesWithSurface(List_T *curve_ids, int surface_id, List_T *shapes)
Definition: Geo.cpp:3560
FreeVolume
void FreeVolume(void *a, void *b)
Definition: Geo.cpp:635
PhysicalGroup::Typ
int Typ
Definition: Geo.h:157
DeleteVolume
void DeleteVolume(int Num, bool recursive=false)
Definition: Geo.cpp:1064
Curve::degenerated
bool degenerated
Definition: Geo.h:78
Curve::geometry
gmshSurface * geometry
Definition: Geo.h:93
NEWSURFACE
int NEWSURFACE()
Definition: Geo.cpp:3809
Surface::GeneratricesByTag
List_T * GeneratricesByTag
Definition: Geo.h:121
Curve::Extrude
ExtrudeParams * Extrude
Definition: Geo.h:89
Surface::MeshAlgorithm
int MeshAlgorithm
Definition: Geo.h:130
SetTranslationMatrix
void SetTranslationMatrix(double matrix[4][4], double T[3])
Definition: Geo.cpp:1250
FindEdgeLoop
EdgeLoop * FindEdgeLoop(int inum)
Definition: Geo.cpp:733
Surface::TransfiniteSmoothing
int TransfiniteSmoothing
Definition: Geo.h:119
CreateVolume
Volume * CreateVolume(int Num, int Typ)
Definition: Geo.cpp:617
Coord::X
double X
Definition: Geo.h:26
EdgeLoop::Curves
List_T * Curves
Definition: Geo.h:108
Surface::RecombineAngle
double RecombineAngle
Definition: Geo.h:118
TreeUtils.h
Surface::Recombine
int Recombine
Definition: Geo.h:116
Volume::SurfacesByTag
List_T * SurfacesByTag
Definition: Geo.h:151
RotateShapes
bool RotateShapes(double Ax, double Ay, double Az, double Px, double Py, double Pz, double alpha, List_T *shapes)
Definition: Geo.cpp:1580
ExtrudeShapes
void ExtrudeShapes(int extrude_type, List_T *in, double T0, double T1, double T2, double A0, double A1, double A2, double X0, double X1, double X2, double alpha, ExtrudeParams *e, List_T *out)
Definition: Geo.cpp:3221
z
const double z
Definition: GaussQuadratureQuad.cpp:56
FreeVertex
void FreeVertex(void *a, void *b)
Definition: Geo.cpp:133
NEWVOLUME
int NEWVOLUME()
Definition: Geo.cpp:3834
Curve::Num
int Num
Definition: Geo.h:76
CircParam::t2
double t2
Definition: Geo.h:69
Vertex::geometry
gmshSurface * geometry
Definition: Geo.h:39
CompareVolume
int CompareVolume(const void *a, const void *b)
Definition: Geo.cpp:88
Coord::Z
double Z
Definition: Geo.h:26
CircParam::incl
double incl
Definition: Geo.h:69
Curve::ReverseMesh
int ReverseMesh
Definition: Geo.h:94
Vertex::operator%
Vertex operator%(Vertex &autre)
Definition: Geo.h:59
Coord::Y
double Y
Definition: Geo.h:26
DeleteCurve
void DeleteCurve(int Num, bool recursive=false)
Definition: Geo.cpp:981
Vertex::Pos
Coord Pos
Definition: Geo.h:34
SurfaceLoop
Definition: Geo.h:134
Volume::TrsfPoints
List_T * TrsfPoints
Definition: Geo.h:148
Surface::Generatrices
List_T * Generatrices
Definition: Geo.h:120
Volume::Recombine3D
int Recombine3D
Definition: Geo.h:145
Surface::geometry
gmshSurface * geometry
Definition: Geo.h:129
Surface::Recombine_Dir
int Recombine_Dir
Definition: Geo.h:117
CircParam::f1
double f1
Definition: Geo.h:69
Surface::ReverseMesh
int ReverseMesh
Definition: Geo.h:130
FindVolume
Volume * FindVolume(int inum)
Definition: Geo.cpp:722
CircParam::n
double n[3]
Definition: Geo.h:71
CreateVertex
Vertex * CreateVertex(int Num, double X, double Y, double Z, double lc, double u)
Definition: Geo.cpp:106
Curve::degre
int degre
Definition: Geo.h:91
Curve::Typ
int Typ
Definition: Geo.h:77
Surface::InSphereCenter
Vertex * InSphereCenter
Definition: Geo.h:123
Volume::Num
int Num
Definition: Geo.h:142
ExtrudeParams
Definition: ExtrudeParams.h:26
Curve::coeffTransfinite
double coeffTransfinite
Definition: Geo.h:82
ReplaceAllDuplicatesNew
void ReplaceAllDuplicatesNew(double tol=-1.)
Definition: Geo.cpp:2534
SetDilatationMatrix
void SetDilatationMatrix(double matrix[4][4], double T[3], double A, double B, double C)
Definition: Geo.cpp:1282
CreateCurve
Curve * CreateCurve(int Num, int Typ, int Order, List_T *Liste, List_T *Knots, int p1, int p2, double u1, double u2, bool &ok)
Definition: Geo.cpp:445
NEWSURFACELOOP
int NEWSURFACELOOP()
Definition: Geo.cpp:3821
CircParam::t1
double t1
Definition: Geo.h:69
FindSurfaceLoop
SurfaceLoop * FindSurfaceLoop(int inum)
Definition: Geo.cpp:744
SurfaceLoop::Surfaces
List_T * Surfaces
Definition: Geo.h:137
Vertex::w
double w
Definition: Geo.h:33
CreatePhysicalGroup
PhysicalGroup * CreatePhysicalGroup(int Num, int typ, List_T *intlist)
Definition: Geo.cpp:142
Surface::degenerate
bool degenerate() const
Definition: Geo.cpp:2358
MSH_SEGM_LINE
#define MSH_SEGM_LINE
Definition: GeoDefines.h:20
SetSurfaceGeneratrices
bool SetSurfaceGeneratrices(Surface *s, List_T *loops)
Definition: Geo.cpp:3674
FreeEdgeLoop
void FreeEdgeLoop(void *a, void *b)
Definition: Geo.cpp:183
SplitCurve
bool SplitCurve(int line_id, List_T *vertices_id, List_T *curves)
Definition: Geo.cpp:3433
Surface::Method
int Method
Definition: Geo.h:115
SPoint2.h
Curve::Circle
CircParam Circle
Definition: Geo.h:92