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
8af1d2c8
Commit
8af1d2c8
authored
24 years ago
by
Jean-François Remacle
Browse files
Options
Downloads
Patches
Plain Diff
Nice isosurfaces
parent
22a79efe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Graphics/IsoSimplex.cpp
+186
-0
186 additions, 0 deletions
Graphics/IsoSimplex.cpp
Graphics/IsoSimplex.h
+10
-0
10 additions, 0 deletions
Graphics/IsoSimplex.h
with
196 additions
and
0 deletions
Graphics/IsoSimplex.cpp
0 → 100644
+
186
−
0
View file @
8af1d2c8
#include
"Gmsh.h"
#include
"GmshUI.h"
#include
"Geo.h"
#include
"Mesh.h"
#include
"Draw.h"
#include
"Iso.h"
#include
"Context.h"
#include
"Numeric.h"
#include
"Views.h"
extern
Context_T
CTX
;
/* ------------------------------------------------------------------------ */
/* S i m p l e x */
/* ------------------------------------------------------------------------ */
/*
compute the gradient of a linear interpolation in a tetrahedron
*/
void
gradSimplex
(
double
*
x
,
double
*
y
,
double
*
z
,
double
*
v
,
double
*
grad
)
{
/*
p = p1 * (1-u-v-w) + p2 u + p3 v + p4 w
*/
double
mat
[
3
][
3
];
double
det
,
b
[
3
];
mat
[
0
][
0
]
=
x
[
1
]
-
x
[
0
];
mat
[
1
][
0
]
=
x
[
2
]
-
x
[
0
];
mat
[
2
][
0
]
=
x
[
3
]
-
x
[
0
];
mat
[
0
][
1
]
=
y
[
1
]
-
y
[
0
];
mat
[
1
][
1
]
=
y
[
2
]
-
y
[
0
];
mat
[
2
][
1
]
=
y
[
3
]
-
y
[
0
];
mat
[
0
][
2
]
=
z
[
1
]
-
z
[
0
];
mat
[
1
][
2
]
=
z
[
2
]
-
z
[
0
];
mat
[
2
][
2
]
=
z
[
3
]
-
z
[
0
];
b
[
0
]
=
v
[
1
]
-
v
[
0
];
b
[
1
]
=
v
[
2
]
-
v
[
0
];
b
[
2
]
=
v
[
3
]
-
v
[
0
];
sys3x3
(
mat
,
b
,
grad
,
&
det
);
}
void
IsoSimplex
(
Post_View
*
View
,
int
preproNormals
,
double
*
X
,
double
*
Y
,
double
*
Z
,
double
*
Val
,
double
V
,
double
Vmin
,
double
Vmax
,
double
*
Offset
,
double
Raise
[
3
][
5
],
int
shade
){
int
nb
,
i
;
double
Xp
[
6
],
Yp
[
6
],
Zp
[
6
];
double
Xpi
[
6
],
Ypi
[
6
],
Zpi
[
6
];
double
norms
[
12
];
if
(
V
!=
Vmax
){
nb
=
0
;
if
((
Val
[
0
]
>
V
&&
Val
[
1
]
<=
V
)
||
(
Val
[
1
]
>
V
&&
Val
[
0
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V
,
0
,
1
,
&
Xp
[
nb
],
&
Yp
[
nb
],
&
Zp
[
nb
]);
nb
++
;
}
if
((
Val
[
0
]
>
V
&&
Val
[
2
]
<=
V
)
||
(
Val
[
2
]
>
V
&&
Val
[
0
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V
,
0
,
2
,
&
Xp
[
nb
],
&
Yp
[
nb
],
&
Zp
[
nb
]);
nb
++
;
}
if
((
Val
[
0
]
>
V
&&
Val
[
3
]
<=
V
)
||
(
Val
[
3
]
>
V
&&
Val
[
0
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V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
nb
],
&
Zp
[
nb
]);
nb
++
;
}
if
((
Val
[
1
]
<
V
&&
Val
[
2
]
<=
V
)
||
(
Val
[
2
]
<
V
&&
Val
[
1
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V
,
1
,
2
,
&
Xp
[
nb
],
&
Yp
[
nb
],
&
Zp
[
nb
]);
nb
++
;
}
if
((
Val
[
1
]
<
V
&&
Val
[
3
]
<=
V
)
||
(
Val
[
3
]
<
V
&&
Val
[
1
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V
,
1
,
3
,
&
Xp
[
nb
],
&
Yp
[
nb
],
&
Zp
[
nb
]);
nb
++
;
}
if
((
Val
[
2
]
<
V
&&
Val
[
3
]
<=
V
)
||
(
Val
[
3
]
<
V
&&
Val
[
2
]
<=
V
)){
InterpolateIso
(
X
,
Y
,
Z
,
Val
,
V
,
2
,
3
,
&
Xp
[
nb
],
&
Yp
[
nb
],
&
Zp
[
nb
]);
nb
++
;
}
}
/*
3 possibilities for quads
-) 0,2,5,3
-) 0,1,5,4
-) 1,2,4,3
in all cases, simply invert the 2 last ones
for having the quads ordered
*/
if
(
nb
==
4
)
{
double
xx
=
Xp
[
3
];
double
yy
=
Yp
[
3
];
double
zz
=
Zp
[
3
];
Xp
[
3
]
=
Xp
[
2
];
Yp
[
3
]
=
Yp
[
2
];
Zp
[
3
]
=
Zp
[
2
];
Xp
[
2
]
=
xx
;
Yp
[
2
]
=
yy
;
Zp
[
2
]
=
zz
;
}
/*
for having a nice isosurface, we should have n . grad v > 0
n = normal to the polygon
v = unknown field we wanna draw
*/
if
(
nb
>
2
)
{
double
v1
[
3
]
=
{
Xp
[
2
]
-
Xp
[
0
],
Yp
[
2
]
-
Yp
[
0
],
Zp
[
2
]
-
Zp
[
0
]};
double
v2
[
3
]
=
{
Xp
[
1
]
-
Xp
[
0
],
Yp
[
1
]
-
Yp
[
0
],
Zp
[
1
]
-
Zp
[
0
]};
double
gr
[
3
];
double
n
[
3
],
xx
;
prodve
(
v1
,
v2
,
n
);
norme
(
n
);
gradSimplex
(
X
,
Y
,
Z
,
Val
,
gr
);
prosca
(
gr
,
n
,
&
xx
);
if
(
xx
>
0
)
{
for
(
i
=
0
;
i
<
nb
;
i
++
)
{
Xpi
[
i
]
=
Xp
[
i
];
Ypi
[
i
]
=
Yp
[
i
];
Zpi
[
i
]
=
Zp
[
i
];
}
for
(
i
=
0
;
i
<
nb
;
i
++
)
{
Xp
[
i
]
=
Xpi
[
nb
-
i
-
1
];
Yp
[
i
]
=
Ypi
[
nb
-
i
-
1
];
Zp
[
i
]
=
Zpi
[
nb
-
i
-
1
];
}
}
else
{
n
[
0
]
=
-
n
[
0
];
n
[
1
]
=
-
n
[
1
];
n
[
2
]
=
-
n
[
2
];
}
if
(
preproNormals
)
{
for
(
i
=
0
;
i
<
nb
;
i
++
)
{
View
->
add_normal
(
Xp
[
i
],
Yp
[
i
],
Zp
[
i
],
n
[
0
],
n
[
1
],
n
[
2
]);
}
return
;
}
else
{
for
(
i
=
0
;
i
<
nb
;
i
++
)
{
if
(
!
View
->
get_normal
(
Xp
[
i
],
Yp
[
i
],
Zp
[
i
],
norms
[
3
*
i
],
norms
[
3
*
i
+
1
],
norms
[
3
*
i
+
2
]))
{
//printf("coucou\n");
norms
[
3
*
i
]
=
n
[
0
];
norms
[
3
*
i
+
1
]
=
n
[
1
];
norms
[
3
*
i
+
2
]
=
n
[
2
];
}
}
}
}
if
(
nb
==
3
)
Draw_Triangle
(
Xp
,
Yp
,
Zp
,
norms
,
Offset
,
Raise
,
shade
);
else
if
(
nb
==
4
)
Draw_Quadrangle
(
Xp
,
Yp
,
Zp
,
norms
,
Offset
,
Raise
,
shade
);
}
This diff is collapsed.
Click to expand it.
Graphics/IsoSimplex.h
0 → 100644
+
10
−
0
View file @
8af1d2c8
#ifndef _ISOSIMPLEX_H_
#define _ISOSIMPLEX_H_
struct
Post_View
;
void
IsoSimplex
(
Post_View
*
View
,
int
preproNormals
,
double
*
X
,
double
*
Y
,
double
*
Z
,
double
*
Val
,
double
V
,
double
Vmin
,
double
Vmax
,
double
*
Offset
,
double
Raise
[
3
][
5
],
int
shade
);
#endif
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