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
3ada8d22
Commit
3ada8d22
authored
15 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
encapsulate serialized varray header parsing in VertexArraay::decodeHeader
parent
21acb6c8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Common/GmshRemote.cpp
+10
-30
10 additions, 30 deletions
Common/GmshRemote.cpp
Common/VertexArray.cpp
+53
-31
53 additions, 31 deletions
Common/VertexArray.cpp
Common/VertexArray.h
+7
-2
7 additions, 2 deletions
Common/VertexArray.h
Post/PViewVertexArrays.cpp
+10
-37
10 additions, 37 deletions
Post/PViewVertexArrays.cpp
with
80 additions
and
100 deletions
Common/GmshRemote.cpp
+
10
−
30
View file @
3ada8d22
...
...
@@ -100,22 +100,13 @@ static void computeAndSendVertexArrays()
}
// Merge the vertex arrays
void
addToVertexArrays
(
const
char
*
bytes
,
int
len
)
static
void
addToVertexArrays
(
int
length
,
const
char
*
bytes
,
int
swap
)
{
int
is
=
sizeof
(
int
),
ds
=
sizeof
(
double
);
std
::
string
name
;
int
index
=
0
;
int
num
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
ss
;
memcpy
(
&
ss
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
ss
){
std
::
vector
<
char
>
n
(
ss
);
memcpy
(
&
n
[
0
],
&
bytes
[
index
],
ss
);
index
+=
ss
;
for
(
unsigned
int
i
=
0
;
i
<
n
.
size
();
i
++
)
name
+=
n
[
i
];
}
int
type
;
memcpy
(
&
type
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
num
,
type
,
numSteps
;
double
min
,
max
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
;
int
index
=
VertexArray
::
decodeHeader
(
length
,
bytes
,
swap
,
name
,
num
,
type
,
min
,
max
,
numSteps
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
);
PView
*
p
=
PView
::
list
[
num
-
1
];
PViewData
*
data
=
p
->
getData
();
...
...
@@ -126,17 +117,6 @@ void addToVertexArrays(const char* bytes, int len)
VertexArray
*
va
=
varrays
[
type
-
1
];
double
min
;
memcpy
(
&
min
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
max
;
memcpy
(
&
max
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
numsteps
;
memcpy
(
&
numsteps
,
&
bytes
[
index
],
is
);
index
+=
is
;
double
time
;
memcpy
(
&
time
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmin
;
memcpy
(
&
xmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymin
;
memcpy
(
&
ymin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmin
;
memcpy
(
&
zmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmax
;
memcpy
(
&
xmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymax
;
memcpy
(
&
ymax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmax
;
memcpy
(
&
zmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
if
(
data
->
getMin
()
>
min
)
data
->
setMin
(
min
);
if
(
data
->
getMax
()
<
max
)
data
->
setMax
(
max
);
...
...
@@ -148,7 +128,7 @@ void addToVertexArrays(const char* bytes, int len)
if
(
type
==
4
)
type
=
2
;
VertexArray
*
toAdd
=
new
VertexArray
(
type
,
100
);
toAdd
->
fromChar
(
bytes
,
0
);
toAdd
->
fromChar
(
length
,
bytes
,
swap
);
va
->
merge
(
toAdd
);
delete
toAdd
;
}
...
...
@@ -226,7 +206,7 @@ int GmshRemote()
char
str
[
len
];
MPI_Recv
(
str
,
len
,
MPI_CHAR
,
status
.
MPI_SOURCE
,
MPI_GMSH_VARRAY
,
MPI_COMM_WORLD
,
&
status2
);
addToVertexArrays
(
str
,
len
);
addToVertexArrays
(
len
,
str
,
swap
);
}
}
computeAndSendVertexArrays
(
client
,
false
);
...
...
This diff is collapsed.
Click to expand it.
Common/VertexArray.cpp
+
53
−
31
View file @
3ada8d22
...
...
@@ -252,32 +252,56 @@ char *VertexArray::toChar(int num, std::string name, int type, double min, doubl
return
bytes
;
}
void
VertexArray
::
fromChar
(
const
char
*
bytes
,
int
swap
)
int
VertexArray
::
decodeHeader
(
int
length
,
const
char
*
bytes
,
int
swap
,
std
::
string
&
name
,
int
&
num
,
int
&
type
,
double
&
min
,
double
&
max
,
int
&
numSteps
,
double
&
time
,
double
&
xmin
,
double
&
ymin
,
double
&
zmin
,
double
&
xmax
,
double
&
ymax
,
double
&
zmax
)
{
// FIXME deal with swap
int
is
=
sizeof
(
int
),
ds
=
sizeof
(
double
);
int
is
=
sizeof
(
int
),
ds
=
sizeof
(
double
),
index
=
0
;
if
(
length
<
4
*
is
+
9
*
ds
){
Msg
::
Error
(
"Too few bytes to create vertex array: %d"
,
length
);
return
0
;
}
int
num
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
swap
){
Msg
::
Error
(
"Should swap bytes in vertex array--not implemented yet"
);
return
0
;
}
int
index
=
0
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
ss
;
memcpy
(
&
ss
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
ss
){
std
::
vector
<
char
>
name
(
ss
);
memcpy
(
&
name
[
0
],
&
bytes
[
index
],
ss
);
index
+=
ss
;
}
int
type
;
memcpy
(
&
type
,
&
bytes
[
index
],
is
);
index
+=
is
;
double
min
;
memcpy
(
&
min
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
max
;
memcpy
(
&
max
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
numsteps
;
memcpy
(
&
numsteps
,
&
bytes
[
index
],
is
);
index
+=
is
;
double
time
;
memcpy
(
&
time
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmin
;
memcpy
(
&
xmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymin
;
memcpy
(
&
ymin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmin
;
memcpy
(
&
zmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmax
;
memcpy
(
&
xmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymax
;
memcpy
(
&
ymax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmax
;
memcpy
(
&
zmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
std
::
vector
<
char
>
n
(
ss
);
memcpy
(
&
n
[
0
],
&
bytes
[
index
],
ss
);
index
+=
ss
;
for
(
unsigned
int
i
=
0
;
i
<
n
.
size
();
i
++
)
name
+=
n
[
i
];
}
memcpy
(
&
type
,
&
bytes
[
index
],
is
);
index
+=
is
;
memcpy
(
&
min
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
max
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
numSteps
,
&
bytes
[
index
],
is
);
index
+=
is
;
memcpy
(
&
time
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
xmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
ymin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
zmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
xmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
ymax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
memcpy
(
&
zmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
return
index
;
}
void
VertexArray
::
fromChar
(
int
length
,
const
char
*
bytes
,
int
swap
)
{
std
::
string
name
;
int
num
,
type
,
numSteps
;
double
min
,
max
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
;
int
index
=
decodeHeader
(
length
,
bytes
,
swap
,
name
,
num
,
type
,
min
,
max
,
numSteps
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
);
if
(
!
index
)
return
;
int
is
=
sizeof
(
int
);
int
vn
;
memcpy
(
&
vn
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
vn
){
_vertices
.
resize
(
vn
);
int
vs
=
vn
*
sizeof
(
float
);
...
...
@@ -297,15 +321,13 @@ void VertexArray::fromChar(const char *bytes, int swap)
}
}
void
VertexArray
::
merge
(
VertexArray
*
arr
)
{
if
(
arr
->
getNumVertices
()
!=
0
)
{
_vertices
.
insert
(
_vertices
.
end
(),
arr
->
firstVertex
(),
arr
->
lastVertex
());
_normals
.
insert
(
_normals
.
end
(),
arr
->
firstNormal
(),
arr
->
lastNormal
());
_colors
.
insert
(
_colors
.
end
(),
arr
->
firstColor
(),
arr
->
lastColor
());
_elements
.
insert
(
_elements
.
end
(),
arr
->
firstElementPointer
(),
arr
->
lastElementPointer
());
void
VertexArray
::
merge
(
VertexArray
*
va
)
{
if
(
va
->
getNumVertices
()
!=
0
)
{
_vertices
.
insert
(
_vertices
.
end
(),
va
->
firstVertex
(),
va
->
lastVertex
());
_normals
.
insert
(
_normals
.
end
(),
va
->
firstNormal
(),
va
->
lastNormal
());
_colors
.
insert
(
_colors
.
end
(),
va
->
firstColor
(),
va
->
lastColor
());
_elements
.
insert
(
_elements
.
end
(),
va
->
firstElementPointer
(),
va
->
lastElementPointer
());
}
}
This diff is collapsed.
Click to expand it.
Common/VertexArray.h
+
7
−
2
View file @
3ada8d22
...
...
@@ -178,9 +178,14 @@ class VertexArray{
// network)
char
*
toChar
(
int
num
,
std
::
string
name
,
int
type
,
double
min
,
double
max
,
int
numsteps
,
double
time
,
SBoundingBox3d
bbox
,
int
&
len
);
void
fromChar
(
const
char
*
bytes
,
int
swap
);
void
fromChar
(
int
length
,
const
char
*
bytes
,
int
swap
);
static
int
decodeHeader
(
int
length
,
const
char
*
bytes
,
int
swap
,
std
::
string
&
name
,
int
&
num
,
int
&
type
,
double
&
min
,
double
&
max
,
int
&
numSteps
,
double
&
time
,
double
&
xmin
,
double
&
ymin
,
double
&
zmin
,
double
&
xmax
,
double
&
ymax
,
double
&
zmax
);
// merge another vertex array into this one
void
merge
(
VertexArray
*
arr
);
void
merge
(
VertexArray
*
va
);
};
#endif
This diff is collapsed.
Click to expand it.
Post/PViewVertexArrays.cpp
+
10
−
37
View file @
3ada8d22
...
...
@@ -1145,39 +1145,12 @@ void PView::fillVertexArrays()
void
PView
::
fillVertexArray
(
ConnectionManager
*
remote
,
int
length
,
const
char
*
bytes
,
int
swap
)
{
int
is
=
sizeof
(
int
),
ds
=
sizeof
(
double
);
if
(
length
<
4
*
is
+
9
*
ds
){
Msg
::
Error
(
"Too few bytes to create vertex array: %d"
,
length
);
return
;
}
if
(
swap
){
Msg
::
Error
(
"Should swap bytes in vertex array--not implemented yet"
);
return
;
}
std
::
string
name
;
int
index
=
0
;
int
num
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
ss
;
memcpy
(
&
ss
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
ss
){
std
::
vector
<
char
>
n
(
ss
);
memcpy
(
&
n
[
0
],
&
bytes
[
index
],
ss
);
index
+=
ss
;
for
(
unsigned
int
i
=
0
;
i
<
n
.
size
();
i
++
)
name
+=
n
[
i
];
}
int
type
;
memcpy
(
&
type
,
&
bytes
[
index
],
is
);
index
+=
is
;
double
min
;
memcpy
(
&
min
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
max
;
memcpy
(
&
max
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
numsteps
;
memcpy
(
&
numsteps
,
&
bytes
[
index
],
is
);
index
+=
is
;
double
time
;
memcpy
(
&
time
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmin
;
memcpy
(
&
xmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymin
;
memcpy
(
&
ymin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmin
;
memcpy
(
&
zmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
xmax
;
memcpy
(
&
xmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymax
;
memcpy
(
&
ymax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
zmax
;
memcpy
(
&
zmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
num
,
type
,
numSteps
;
double
min
,
max
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
;
if
(
!
VertexArray
::
decodeHeader
(
length
,
bytes
,
swap
,
name
,
num
,
type
,
min
,
max
,
numSteps
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
))
return
;
Msg
::
Debug
(
"Filling vertex array (type %d) in view num %d"
,
type
,
num
);
...
...
@@ -1186,7 +1159,7 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
PView
*
p
=
PView
::
getViewByNum
(
num
);
if
(
!
p
){
Msg
::
Info
(
"View num %d does not exist: creating new view"
,
num
);
PViewData
*
data
=
new
PViewDataRemote
(
remote
,
min
,
max
,
num
s
teps
,
time
,
bbox
);
PViewData
*
data
=
new
PViewDataRemote
(
remote
,
min
,
max
,
num
S
teps
,
time
,
bbox
);
data
->
setName
(
name
+
" (remote)"
);
p
=
new
PView
(
data
,
num
);
SetBoundingBox
();
...
...
@@ -1207,22 +1180,22 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
case
1
:
if
(
p
->
va_points
)
delete
p
->
va_points
;
p
->
va_points
=
new
VertexArray
(
1
,
100
);
p
->
va_points
->
fromChar
(
bytes
,
swap
);
p
->
va_points
->
fromChar
(
length
,
bytes
,
swap
);
break
;
case
2
:
if
(
p
->
va_lines
)
delete
p
->
va_lines
;
p
->
va_lines
=
new
VertexArray
(
2
,
100
);
p
->
va_lines
->
fromChar
(
bytes
,
swap
);
p
->
va_lines
->
fromChar
(
length
,
bytes
,
swap
);
break
;
case
3
:
if
(
p
->
va_triangles
)
delete
p
->
va_triangles
;
p
->
va_triangles
=
new
VertexArray
(
3
,
100
);
p
->
va_triangles
->
fromChar
(
bytes
,
swap
);
p
->
va_triangles
->
fromChar
(
length
,
bytes
,
swap
);
break
;
case
4
:
if
(
p
->
va_vectors
)
delete
p
->
va_vectors
;
p
->
va_vectors
=
new
VertexArray
(
2
,
100
);
p
->
va_vectors
->
fromChar
(
bytes
,
swap
);
p
->
va_vectors
->
fromChar
(
length
,
bytes
,
swap
);
break
;
default:
Msg
::
Error
(
"Cannot fill vertex array of type %d"
,
type
);
...
...
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