Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
8a32747b
Commit
8a32747b
authored
10 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
make old algo available again
parent
8557e3f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Plugin/Triangulate.cpp
+104
-95
104 additions, 95 deletions
Plugin/Triangulate.cpp
with
104 additions
and
95 deletions
Plugin/Triangulate.cpp
+
104
−
95
View file @
8a32747b
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#endif
#endif
StringXNumber
TriangulateOptions_Number
[]
=
{
StringXNumber
TriangulateOptions_Number
[]
=
{
{
GMSH_FULLRC
,
"Algorithm"
,
NULL
,
0.
},
{
GMSH_FULLRC
,
"View"
,
NULL
,
-
1.
}
{
GMSH_FULLRC
,
"View"
,
NULL
,
-
1.
}
};
};
...
@@ -35,7 +36,8 @@ std::string GMSH_TriangulatePlugin::getHelp() const
...
@@ -35,7 +36,8 @@ std::string GMSH_TriangulatePlugin::getHelp() const
return
"Plugin(Triangulate) triangulates the points in the "
return
"Plugin(Triangulate) triangulates the points in the "
"view `View', assuming that all the points belong "
"view `View', assuming that all the points belong "
"to a surface that can be projected one-to-one "
"to a surface that can be projected one-to-one "
"onto a plane.
\n\n
"
"onto a plane. Algorithm selects the old (0) or new (1) "
"meshing algorithm.
\n\n
"
"If `View' < 0, the plugin is run on the current view.
\n\n
"
"If `View' < 0, the plugin is run on the current view.
\n\n
"
"Plugin(Triangulate) creates one new view."
;
"Plugin(Triangulate) creates one new view."
;
}
}
...
@@ -67,7 +69,8 @@ class PointData : public MVertex {
...
@@ -67,7 +69,8 @@ class PointData : public MVertex {
PView
*
GMSH_TriangulatePlugin
::
execute
(
PView
*
v
)
PView
*
GMSH_TriangulatePlugin
::
execute
(
PView
*
v
)
{
{
int
iView
=
(
int
)
TriangulateOptions_Number
[
0
].
def
;
int
algo
=
(
int
)
TriangulateOptions_Number
[
0
].
def
;
int
iView
=
(
int
)
TriangulateOptions_Number
[
1
].
def
;
PView
*
v1
=
getView
(
iView
,
v
);
PView
*
v1
=
getView
(
iView
,
v
);
if
(
!
v1
)
return
v
;
if
(
!
v1
)
return
v
;
...
@@ -123,110 +126,116 @@ PView *GMSH_TriangulatePlugin::execute(PView *v)
...
@@ -123,110 +126,116 @@ PView *GMSH_TriangulatePlugin::execute(PView *v)
}
}
delete
s
;
delete
s
;
#if 0 // old code
PView
*
v2
;
PViewDataList
*
data2
;
// build a point record structure for the divide and conquer algorithm
DocRecord doc(points.size());
for(unsigned int i = 0; i < points.size(); i++){
double XX = CTX::instance()->mesh.randFactor * lc * (double)rand() / (double)RAND_MAX;
double YY = CTX::instance()->mesh.randFactor * lc * (double)rand() / (double)RAND_MAX;
doc.points[i].where.h = points[i]->x() + XX;
doc.points[i].where.v = points[i]->y() + YY;
doc.points[i].adjacent = NULL;
doc.points[i].data = (void*)points[i];
}
// triangulate
if
(
algo
==
0
)
{
// using old code
try{
doc.MakeMeshWithPoints();
}
catch(const char *err){
Msg::Error("%s", err);
}
// create output (using unperturbed data)
// build a point record structure for the divide and conquer algorithm
PView *v2 = new PView();
DocRecord
doc
(
points
.
size
());
PViewDataList *data2 = getDataList(v2);
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
();
i
++
){
for(int i = 0; i < doc.numTriangles; i++){
double
XX
=
CTX
::
instance
()
->
mesh
.
randFactor
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
int a = doc.triangles[i].a;
double
YY
=
CTX
::
instance
()
->
mesh
.
randFactor
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
int b = doc.triangles[i].b;
doc
.
points
[
i
].
where
.
h
=
points
[
i
]
->
x
()
+
XX
;
int c = doc.triangles[i].c;
doc
.
points
[
i
].
where
.
v
=
points
[
i
]
->
y
()
+
YY
;
int n = doc.numPoints;
doc
.
points
[
i
].
adjacent
=
NULL
;
if(a < 0 || a >= n || b < 0 || b >= n || c < 0 || c >= n){
doc
.
points
[
i
].
data
=
(
void
*
)
points
[
i
];
Msg::Warning("Skipping bad triangle %d", i);
continue;
}
}
PointData *p[3];
p[0] = (PointData*)doc.points[doc.triangles[i].a].data;
// triangulate
p[1] = (PointData*)doc.points[doc.triangles[i].b].data;
try
{
p[2] = (PointData*)doc.points[doc.triangles[i].c].data;
doc
.
MakeMeshWithPoints
();
int numComp = 0;
std::vector<double> *vec = 0;
if((int)p[0]->v.size() == 3 + 9 * numSteps &&
(int)p[1]->v.size() == 3 + 9 * numSteps &&
(int)p[2]->v.size() == 3 + 9 * numSteps){
numComp = 9; data2->NbTT++; vec = &data2->TT;
}
}
else if((int)p[0]->v.size() == 3 + 3 * numSteps &&
catch
(
const
char
*
err
){
(int)p[1]->v.size() == 3 + 3 * numSteps &&
Msg
::
Error
(
"%s"
,
err
);
(int)p[2]->v.size() == 3 + 3 * numSteps){
numComp = 3; data2->NbVT++; vec = &data2->VT;
}
}
else{
numComp = 1; data2->NbST++; vec = &data2->ST;
// create output (using unperturbed data)
v2
=
new
PView
();
data2
=
getDataList
(
v2
);
for
(
int
i
=
0
;
i
<
doc
.
numTriangles
;
i
++
){
int
a
=
doc
.
triangles
[
i
].
a
;
int
b
=
doc
.
triangles
[
i
].
b
;
int
c
=
doc
.
triangles
[
i
].
c
;
int
n
=
doc
.
numPoints
;
if
(
a
<
0
||
a
>=
n
||
b
<
0
||
b
>=
n
||
c
<
0
||
c
>=
n
){
Msg
::
Warning
(
"Skipping bad triangle %d"
,
i
);
continue
;
}
PointData
*
p
[
3
];
p
[
0
]
=
(
PointData
*
)
doc
.
points
[
doc
.
triangles
[
i
].
a
].
data
;
p
[
1
]
=
(
PointData
*
)
doc
.
points
[
doc
.
triangles
[
i
].
b
].
data
;
p
[
2
]
=
(
PointData
*
)
doc
.
points
[
doc
.
triangles
[
i
].
c
].
data
;
int
numComp
=
0
;
std
::
vector
<
double
>
*
vec
=
0
;
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
9
*
numSteps
){
numComp
=
9
;
data2
->
NbTT
++
;
vec
=
&
data2
->
TT
;
}
else
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
3
*
numSteps
){
numComp
=
3
;
data2
->
NbVT
++
;
vec
=
&
data2
->
VT
;
}
else
{
numComp
=
1
;
data2
->
NbST
++
;
vec
=
&
data2
->
ST
;
}
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
0
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
1
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
2
]);
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
)
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
3
+
numComp
*
step
+
comp
]);
}
}
for(int nod = 0; nod < 3; nod++) vec->push_back(p[nod]->v[0]);
for(int nod = 0; nod < 3; nod++) vec->push_back(p[nod]->v[1]);
for(int nod = 0; nod < 3; nod++) vec->push_back(p[nod]->v[2]);
for(int step = 0; step < numSteps; step++)
for(int nod = 0; nod < 3; nod++)
for(int comp = 0; comp < numComp; comp++)
vec->push_back(p[nod]->v[3 + numComp * step + comp]);
}
#else
// new code
Msg
::
Info
(
"Using new triangulation code"
);
std
::
vector
<
MTriangle
*>
tris
;
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
();
i
++
)
{
double
XX
=
1.e-12
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
double
YY
=
1.e-12
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
points
[
i
]
->
x
()
+=
XX
;
points
[
i
]
->
y
()
+=
YY
;
}
}
delaunayMeshIn2D
(
points
,
tris
);
else
{
// new code
PView
*
v2
=
new
PView
();
Msg
::
Info
(
"Using new triangulation code"
);
PViewDataList
*
data2
=
getDataList
(
v2
);
std
::
vector
<
MTriangle
*>
tris
;
for
(
unsigned
int
i
=
0
;
i
<
tris
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
();
i
++
)
{
PointData
*
p
[
3
];
double
XX
=
1.e-12
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
p
[
0
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
0
);
double
YY
=
1.e-12
*
lc
*
(
double
)
rand
()
/
(
double
)
RAND_MAX
;
p
[
1
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
1
);
points
[
i
]
->
x
()
+=
XX
;
p
[
2
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
2
);
points
[
i
]
->
y
()
+=
YY
;
int
numComp
=
0
;
std
::
vector
<
double
>
*
vec
=
0
;
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
9
*
numSteps
){
numComp
=
9
;
data2
->
NbTT
++
;
vec
=
&
data2
->
TT
;
}
else
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
3
*
numSteps
){
numComp
=
3
;
data2
->
NbVT
++
;
vec
=
&
data2
->
VT
;
}
}
else
{
delaunayMeshIn2D
(
points
,
tris
);
numComp
=
1
;
data2
->
NbST
++
;
vec
=
&
data2
->
ST
;
v2
=
new
PView
();
data2
=
getDataList
(
v2
);
for
(
unsigned
int
i
=
0
;
i
<
tris
.
size
();
i
++
){
PointData
*
p
[
3
];
p
[
0
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
0
);
p
[
1
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
1
);
p
[
2
]
=
(
PointData
*
)
tris
[
i
]
->
getVertex
(
2
);
int
numComp
=
0
;
std
::
vector
<
double
>
*
vec
=
0
;
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
9
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
9
*
numSteps
){
numComp
=
9
;
data2
->
NbTT
++
;
vec
=
&
data2
->
TT
;
}
else
if
((
int
)
p
[
0
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
1
]
->
v
.
size
()
==
3
+
3
*
numSteps
&&
(
int
)
p
[
2
]
->
v
.
size
()
==
3
+
3
*
numSteps
){
numComp
=
3
;
data2
->
NbVT
++
;
vec
=
&
data2
->
VT
;
}
else
{
numComp
=
1
;
data2
->
NbST
++
;
vec
=
&
data2
->
ST
;
}
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
0
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
1
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
2
]);
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
)
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
3
+
numComp
*
step
+
comp
]);
delete
tris
[
i
];
}
}
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
0
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
1
]);
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
2
]);
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
)
for
(
int
nod
=
0
;
nod
<
3
;
nod
++
)
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
)
vec
->
push_back
(
p
[
nod
]
->
v
[
3
+
numComp
*
step
+
comp
]);
delete
tris
[
i
];
}
}
#endif
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
();
i
++
)
delete
points
[
i
];
delete
points
[
i
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment