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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
8bc430bb
Commit
8bc430bb
authored
19 years ago
by
Jean-François Remacle
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
1703e2bd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Mesh/BDS.cpp
+43
-77
43 additions, 77 deletions
Mesh/BDS.cpp
benchmarks/stl/demo1.stl
+2158
-0
2158 additions, 0 deletions
benchmarks/stl/demo1.stl
with
2201 additions
and
77 deletions
Mesh/BDS.cpp
+
43
−
77
View file @
8bc430bb
// $Id: BDS.cpp,v 1.4
5
2005-12-
08 15:35:20
remacle Exp $
// $Id: BDS.cpp,v 1.4
6
2005-12-
11 14:27:46
remacle Exp $
//
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -1990,7 +1990,7 @@ bool BDS_Mesh::swap_edge(BDS_Edge * e)
...
@@ -1990,7 +1990,7 @@ bool BDS_Mesh::swap_edge(BDS_Edge * e)
}
}
}
}
// See if the swap revert one triangle
// See if the swap revert
s
one triangle
double
cb1
[
3
],
cb2
[
3
];
double
cb1
[
3
],
cb2
[
3
];
if
(
orientation
==
1
)
if
(
orientation
==
1
)
{
{
...
@@ -2117,6 +2117,9 @@ bool BDS_Mesh::collapse_edge(BDS_Edge * e, BDS_Point * p, const double eps)
...
@@ -2117,6 +2117,9 @@ bool BDS_Mesh::collapse_edge(BDS_Edge * e, BDS_Point * p, const double eps)
p
->
Y
=
Y
;
p
->
Y
=
Y
;
p
->
Z
=
Z
;
p
->
Z
=
Z
;
n2
=
t
->
N
();
n2
=
t
->
N
();
if
(
n1
*
n2
<
0
)
return
false
;
double
s_before
=
surface_triangle
(
pts
[
0
],
pts
[
1
],
pts
[
2
]);
double
s_before
=
surface_triangle
(
pts
[
0
],
pts
[
1
],
pts
[
2
]);
// normals should not be opposed or change too dramatically
// normals should not be opposed or change too dramatically
// this does not concern the triangles with the small edge that
// this does not concern the triangles with the small edge that
...
@@ -2258,6 +2261,9 @@ bool BDS_Mesh::move_point(BDS_Point * p, double X, double Y, double Z)
...
@@ -2258,6 +2261,9 @@ bool BDS_Mesh::move_point(BDS_Point * p, double X, double Y, double Z)
p
->
X
=
oldx
;
p
->
X
=
oldx
;
p
->
Y
=
oldy
;
p
->
Y
=
oldy
;
p
->
Z
=
oldz
;
p
->
Z
=
oldz
;
if
(
n1
*
n2
<
0
)
return
false
;
double
angle
=
n1
.
angle
(
n2
);
double
angle
=
n1
.
angle
(
n2
);
if
(
fabs
(
angle
)
>
M_PI
/
3
)
if
(
fabs
(
angle
)
>
M_PI
/
3
)
return
false
;
return
false
;
...
@@ -2324,6 +2330,9 @@ bool BDS_Mesh::smooth_point(BDS_Point * p, BDS_Mesh * geom_mesh)
...
@@ -2324,6 +2330,9 @@ bool BDS_Mesh::smooth_point(BDS_Point * p, BDS_Mesh * geom_mesh)
if
(
p
->
g
&&
p
->
g
->
classif_degree
<=
1
)
if
(
p
->
g
&&
p
->
g
->
classif_degree
<=
1
)
return
false
;
return
false
;
// if(!p->g->surf)
// return false;
double
X
=
0
;
double
X
=
0
;
double
Y
=
0
;
double
Y
=
0
;
...
@@ -2352,6 +2361,7 @@ bool BDS_Mesh::smooth_point(BDS_Point * p, BDS_Mesh * geom_mesh)
...
@@ -2352,6 +2361,7 @@ bool BDS_Mesh::smooth_point(BDS_Point * p, BDS_Mesh * geom_mesh)
void
BDS_Mesh
::
compute_metric_edge_lengths
(
const
BDS_Metric
&
metric
)
void
BDS_Mesh
::
compute_metric_edge_lengths
(
const
BDS_Metric
&
metric
)
{
{
// printf("computation of metric lengths\n");
// printf("computation of metric lengths\n");
{
{
std
::
list
<
BDS_Edge
*
>::
iterator
it
=
edges
.
begin
();
std
::
list
<
BDS_Edge
*
>::
iterator
it
=
edges
.
begin
();
...
@@ -2362,6 +2372,14 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
...
@@ -2362,6 +2372,14 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
metric
.
target_length
(
0.5
*
((
*
it
)
->
p2
->
X
+
(
*
it
)
->
p1
->
X
),
metric
.
target_length
(
0.5
*
((
*
it
)
->
p2
->
X
+
(
*
it
)
->
p1
->
X
),
0.5
*
((
*
it
)
->
p2
->
Y
+
(
*
it
)
->
p1
->
Y
),
0.5
*
((
*
it
)
->
p2
->
Y
+
(
*
it
)
->
p1
->
Y
),
0.5
*
((
*
it
)
->
p2
->
Z
+
(
*
it
)
->
p1
->
Z
));
0.5
*
((
*
it
)
->
p2
->
Z
+
(
*
it
)
->
p1
->
Z
));
BDS_Edge
*
e
=
(
*
it
);
BDS_GeomEntity
*
g
=
e
->
g
;
if
(
g
&&
g
->
classif_degree
==
1
)
{
double
l
=
(
*
it
)
->
length
()
*
4
;
if
(
l
<
(
*
it
)
->
target_length
)
(
*
it
)
->
target_length
=
l
;
}
}
}
++
it
;
++
it
;
}
}
...
@@ -2374,6 +2392,9 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
...
@@ -2374,6 +2392,9 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
BDS_Edge
*
e
=
(
*
it
);
BDS_Edge
*
e
=
(
*
it
);
BDS_GeomEntity
*
g
=
e
->
g
;
BDS_GeomEntity
*
g
=
e
->
g
;
// do not unrefined curves
// minimal length is the actual length
if
(
g
&&
g
->
surf
)
{
if
(
g
&&
g
->
surf
)
{
double
curvature
=
g
->
surf
->
normalCurv
(
0.5
*
(
e
->
p1
->
X
+
e
->
p2
->
X
),
double
curvature
=
g
->
surf
->
normalCurv
(
0.5
*
(
e
->
p1
->
X
+
e
->
p2
->
X
),
0.5
*
(
e
->
p1
->
Y
+
e
->
p2
->
Y
),
0.5
*
(
e
->
p1
->
Y
+
e
->
p2
->
Y
),
...
@@ -2392,7 +2413,6 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
...
@@ -2392,7 +2413,6 @@ void BDS_Mesh::compute_metric_edge_lengths(const BDS_Metric & metric)
3.14159
*
radius
/
metric
.
nb_elements_per_radius_of_curvature
;
3.14159
*
radius
/
metric
.
nb_elements_per_radius_of_curvature
;
e
->
target_length
=
e
->
target_length
=
metric
.
update_target_length
(
target
,
e
->
target_length
);
metric
.
update_target_length
(
target
,
e
->
target_length
);
}
}
++
it
;
++
it
;
}
}
...
@@ -2454,14 +2474,10 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
...
@@ -2454,14 +2474,10 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
SNAP_SUCCESS
=
0
;
SNAP_SUCCESS
=
0
;
SNAP_FAILURE
=
0
;
SNAP_FAILURE
=
0
;
// printf("METRIC %g %g %g\n",LC,metric._min,metric._max);
// add initial set of edges in a list
std
::
list
<
BDS_Edge
*
>
small_to_long
(
edges
);
std
::
list
<
BDS_Edge
*
>
small_to_long
(
edges
);
// split edges
// split edges
{
for
(
int
ii
=
0
;
ii
<
2
;
ii
++
)
{
std
::
list
<
BDS_Edge
*
>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*
>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*
>::
iterator
ite
=
small_to_long
.
end
();
std
::
list
<
BDS_Edge
*
>::
iterator
ite
=
small_to_long
.
end
();
compute_metric_edge_lengths
(
metric
);
compute_metric_edge_lengths
(
metric
);
...
@@ -2471,45 +2487,17 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
...
@@ -2471,45 +2487,17 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
double
length
=
(
*
it
)
->
length
();
double
length
=
(
*
it
)
->
length
();
if
(
!
(
*
it
)
->
deleted
&&
length
>
(
*
it
)
->
target_length
/
0.7
)
{
if
(
!
(
*
it
)
->
deleted
&&
length
>
(
*
it
)
->
target_length
/
0.7
)
{
split_edge
(
*
it
,
0.5
,
geom_mesh
);
split_edge
(
*
it
,
0.5
,
geom_mesh
);
//split_edge (*it, 0.5, 0 );
nb_modif
++
;
nb_modif
++
;
}
}
}
}
++
it
;
++
it
;
}
}
}
// re-create small_to_long
cleanup
();
cleanup
();
small_to_long
=
edges
;
small_to_long
=
edges
;
// split edges
{
std
::
list
<
BDS_Edge
*>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*>::
iterator
ite
=
small_to_long
.
end
();
compute_metric_edge_lengths
(
metric
);
while
(
it
!=
ite
)
{
if
((
*
it
)
->
numfaces
()
==
2
)
{
double
length
=
(
*
it
)
->
length
();
if
(
!
(
*
it
)
->
deleted
&&
length
>
(
*
it
)
->
target_length
/
0.7
){
split_edge
(
*
it
,
0.5
,
geom_mesh
);
//split_edge (*it, 0.5, 0 );
nb_modif
++
;
}
}
}
++
it
;
}
}
// re-create small_to_long
cleanup
();
small_to_long
=
edges
;
// collapse
// collapse
{
for
(
int
ii
=
0
;
ii
<
1
;
ii
++
)
{
std
::
list
<
BDS_Edge
*>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*>::
iterator
ite
=
small_to_long
.
end
();
std
::
list
<
BDS_Edge
*>::
iterator
ite
=
small_to_long
.
end
();
// compute_metric_edge_lengths (metric);
// compute_metric_edge_lengths (metric);
...
@@ -2531,9 +2519,9 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
...
@@ -2531,9 +2519,9 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
}
}
++
it
;
++
it
;
}
}
}
cleanup
();
cleanup
();
small_to_long
=
edges
;
small_to_long
=
edges
;
}
{
{
std
::
list
<
BDS_Edge
*>::
iterator
it
=
small_to_long
.
begin
();
std
::
list
<
BDS_Edge
*>::
iterator
it
=
small_to_long
.
begin
();
...
@@ -2545,46 +2533,24 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
...
@@ -2545,46 +2533,24 @@ int BDS_Mesh::adapt_mesh(const BDS_Metric & metric, bool smooth,
BDS_Point
*
op
[
2
];
BDS_Point
*
op
[
2
];
(
*
it
)
->
oppositeof
(
op
);
(
*
it
)
->
oppositeof
(
op
);
double
a1
=
surface_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
0
]
);
double
a2
=
surface_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
1
]
);
double
b1
=
surface_triangle
(
(
*
it
)
->
p1
,
op
[
0
]
,
op
[
1
]
);
double
b2
=
surface_triangle
(
(
*
it
)
->
p2
,
op
[
0
]
,
op
[
1
]
);
double
cb1
[
3
],
cb2
[
3
];
normal_triangle
(
(
*
it
)
->
p1
,
op
[
0
]
,
op
[
1
],
cb1
);
normal_triangle
(
(
*
it
)
->
p2
,
op
[
0
]
,
op
[
1
],
cb2
);
double
prosc
=
cb1
[
0
]
*
cb2
[
0
]
+
cb1
[
1
]
*
cb2
[
1
]
+
cb1
[
2
]
*
cb2
[
2
];
if
(
fabs
(
a1
+
a2
-
b1
-
b2
)
<
0.2
*
(
a1
+
a2
+
b1
+
b2
))
{
double
qa1
=
quality_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
0
]
);
double
qa1
=
quality_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
0
]
);
double
qa2
=
quality_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
1
]
);
double
qa2
=
quality_triangle
(
(
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
1
]
);
double
qb1
=
quality_triangle
(
(
*
it
)
->
p1
,
op
[
0
]
,
op
[
1
]
);
double
qb1
=
quality_triangle
(
(
*
it
)
->
p1
,
op
[
0
]
,
op
[
1
]
);
double
qb2
=
quality_triangle
(
(
*
it
)
->
p2
,
op
[
0
]
,
op
[
1
]
);
double
qb2
=
quality_triangle
(
(
*
it
)
->
p2
,
op
[
0
]
,
op
[
1
]
);
double
d
=
dist_droites_gauches
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
op
[
0
],
op
[
1
]);
BDS_Vector
v1
(
*
((
*
it
)
->
p1
),
*
((
*
it
)
->
p2
));
BDS_Vector
v2
(
*
(
op
[
0
]),
*
(
op
[
1
]));
double
dd
=
sqrt
(
v1
*
v1
+
v2
*
v2
);
double
qa
=
(
qa1
<
qa2
)
?
qa1
:
qa2
;
double
qa
=
(
qa1
<
qa2
)
?
qa1
:
qa2
;
double
qb
=
(
qb1
<
qb2
)
?
qb1
:
qb2
;
double
qb
=
(
qb1
<
qb2
)
?
qb1
:
qb2
;
// printf("qa %g qb %g ..\n",qa,qb);
if
(
qb
>
qa
)
if
(
qb
>
qa
&&
d
<
0.1
*
dd
)
{
{
nb_modif
++
;
nb_modif
++
;
swap_edge
(
*
it
);
swap_edge
(
*
it
);
}
}
}
}
}
++
it
;
++
it
;
}
}
}
}
cleanup
();
cleanup
();
if
(
smooth
&&
0
){
if
(
smooth
){
Msg
(
INFO
,
"smoothing %d points
\n
"
,
points
.
size
());
Msg
(
INFO
,
"smoothing %d points
\n
"
,
points
.
size
());
std
::
set
<
BDS_Point
*
,
PointLessThan
>::
iterator
it
=
points
.
begin
();
std
::
set
<
BDS_Point
*
,
PointLessThan
>::
iterator
it
=
points
.
begin
();
std
::
set
<
BDS_Point
*
,
PointLessThan
>::
iterator
ite
=
points
.
end
();
std
::
set
<
BDS_Point
*
,
PointLessThan
>::
iterator
ite
=
points
.
end
();
...
...
This diff is collapsed.
Click to expand it.
benchmarks/stl/demo1.stl
0 → 100644
+
2158
−
0
View file @
8bc430bb
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