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
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
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide 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,42 +100,22 @@ static void computeAndSendVertexArrays()
...
@@ -100,42 +100,22 @@ static void computeAndSendVertexArrays()
}
}
// Merge the vertex arrays
// 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
;
std
::
string
name
;
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
);
int
index
=
0
;
PView
*
p
=
PView
::
list
[
num
-
1
];
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
;
PView
*
p
=
PView
::
list
[
num
-
1
];
PViewData
*
data
=
p
->
getData
();
PViewData
*
data
=
p
->
getData
();
PViewOptions
*
opt
=
p
->
getOptions
();
PViewOptions
*
opt
=
p
->
getOptions
();
VertexArray
*
varrays
[
4
]
=
VertexArray
*
varrays
[
4
]
=
{
p
->
va_points
,
p
->
va_lines
,
p
->
va_triangles
,
p
->
va_vectors
};
{
p
->
va_points
,
p
->
va_lines
,
p
->
va_triangles
,
p
->
va_vectors
};
VertexArray
*
va
=
varrays
[
type
-
1
];
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
->
getMin
()
>
min
)
data
->
setMin
(
min
);
if
(
data
->
getMax
()
<
max
)
data
->
setMax
(
max
);
if
(
data
->
getMax
()
<
max
)
data
->
setMax
(
max
);
...
@@ -147,8 +127,8 @@ void addToVertexArrays(const char* bytes, int len)
...
@@ -147,8 +127,8 @@ void addToVertexArrays(const char* bytes, int len)
data
->
setBoundingBox
(
bb
);
data
->
setBoundingBox
(
bb
);
if
(
type
==
4
)
type
=
2
;
if
(
type
==
4
)
type
=
2
;
VertexArray
*
toAdd
=
new
VertexArray
(
type
,
100
);
VertexArray
*
toAdd
=
new
VertexArray
(
type
,
100
);
toAdd
->
fromChar
(
bytes
,
0
);
toAdd
->
fromChar
(
length
,
bytes
,
swap
);
va
->
merge
(
toAdd
);
va
->
merge
(
toAdd
);
delete
toAdd
;
delete
toAdd
;
}
}
...
@@ -226,7 +206,7 @@ int GmshRemote()
...
@@ -226,7 +206,7 @@ int GmshRemote()
char
str
[
len
];
char
str
[
len
];
MPI_Recv
(
str
,
len
,
MPI_CHAR
,
status
.
MPI_SOURCE
,
MPI_Recv
(
str
,
len
,
MPI_CHAR
,
status
.
MPI_SOURCE
,
MPI_GMSH_VARRAY
,
MPI_COMM_WORLD
,
&
status2
);
MPI_GMSH_VARRAY
,
MPI_COMM_WORLD
,
&
status2
);
addToVertexArrays
(
str
,
len
);
addToVertexArrays
(
len
,
str
,
swap
);
}
}
}
}
computeAndSendVertexArrays
(
client
,
false
);
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
...
@@ -252,32 +252,56 @@ char *VertexArray::toChar(int num, std::string name, int type, double min, doubl
return
bytes
;
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
);
int
num
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
return
0
;
}
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
;
int
ss
;
memcpy
(
&
ss
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
ss
){
if
(
ss
){
std
::
vector
<
char
>
name
(
ss
);
std
::
vector
<
char
>
n
(
ss
);
memcpy
(
&
name
[
0
],
&
bytes
[
index
],
ss
);
index
+=
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
;
}
int
type
;
memcpy
(
&
type
,
&
bytes
[
index
],
is
);
index
+=
is
;
void
VertexArray
::
fromChar
(
int
length
,
const
char
*
bytes
,
int
swap
)
double
min
;
memcpy
(
&
min
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
{
double
max
;
memcpy
(
&
max
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
std
::
string
name
;
int
numsteps
;
memcpy
(
&
numsteps
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
num
,
type
,
numSteps
;
double
time
;
memcpy
(
&
time
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
min
,
max
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
;
double
xmin
;
memcpy
(
&
xmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
index
=
decodeHeader
(
length
,
bytes
,
swap
,
name
,
num
,
type
,
min
,
max
,
double
ymin
;
memcpy
(
&
ymin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
numSteps
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
);
double
zmin
;
memcpy
(
&
zmin
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
if
(
!
index
)
return
;
double
xmax
;
memcpy
(
&
xmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
double
ymax
;
memcpy
(
&
ymax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
is
=
sizeof
(
int
);
double
zmax
;
memcpy
(
&
zmax
,
&
bytes
[
index
],
ds
);
index
+=
ds
;
int
vn
;
memcpy
(
&
vn
,
&
bytes
[
index
],
is
);
index
+=
is
;
int
vn
;
memcpy
(
&
vn
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
vn
){
if
(
vn
){
_vertices
.
resize
(
vn
);
int
vs
=
vn
*
sizeof
(
float
);
_vertices
.
resize
(
vn
);
int
vs
=
vn
*
sizeof
(
float
);
...
@@ -297,15 +321,13 @@ void VertexArray::fromChar(const char *bytes, int swap)
...
@@ -297,15 +321,13 @@ void VertexArray::fromChar(const char *bytes, int swap)
}
}
}
}
void
VertexArray
::
merge
(
VertexArray
*
arr
)
{
void
VertexArray
::
merge
(
VertexArray
*
va
)
if
(
arr
->
getNumVertices
()
!=
0
)
{
{
_vertices
.
insert
(
_vertices
.
end
(),
arr
->
firstVertex
(),
if
(
va
->
getNumVertices
()
!=
0
)
{
arr
->
lastVertex
());
_vertices
.
insert
(
_vertices
.
end
(),
va
->
firstVertex
(),
va
->
lastVertex
());
_normals
.
insert
(
_normals
.
end
(),
arr
->
firstNormal
(),
_normals
.
insert
(
_normals
.
end
(),
va
->
firstNormal
(),
va
->
lastNormal
());
arr
->
lastNormal
());
_colors
.
insert
(
_colors
.
end
(),
va
->
firstColor
(),
va
->
lastColor
());
_colors
.
insert
(
_colors
.
end
(),
arr
->
firstColor
(),
_elements
.
insert
(
_elements
.
end
(),
va
->
firstElementPointer
(),
arr
->
lastColor
());
va
->
lastElementPointer
());
_elements
.
insert
(
_elements
.
end
(),
arr
->
firstElementPointer
(),
arr
->
lastElementPointer
());
}
}
}
}
This diff is collapsed.
Click to expand it.
Common/VertexArray.h
+
7
−
2
View file @
3ada8d22
...
@@ -178,9 +178,14 @@ class VertexArray{
...
@@ -178,9 +178,14 @@ class VertexArray{
// network)
// network)
char
*
toChar
(
int
num
,
std
::
string
name
,
int
type
,
double
min
,
double
max
,
char
*
toChar
(
int
num
,
std
::
string
name
,
int
type
,
double
min
,
double
max
,
int
numsteps
,
double
time
,
SBoundingBox3d
bbox
,
int
&
len
);
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
// merge another vertex array into this one
void
merge
(
VertexArray
*
arr
);
void
merge
(
VertexArray
*
va
);
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
Post/PViewVertexArrays.cpp
+
10
−
37
View file @
3ada8d22
...
@@ -1145,39 +1145,12 @@ void PView::fillVertexArrays()
...
@@ -1145,39 +1145,12 @@ void PView::fillVertexArrays()
void
PView
::
fillVertexArray
(
ConnectionManager
*
remote
,
int
length
,
void
PView
::
fillVertexArray
(
ConnectionManager
*
remote
,
int
length
,
const
char
*
bytes
,
int
swap
)
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
;
std
::
string
name
;
int
num
,
type
,
numSteps
;
int
index
=
0
;
double
min
,
max
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
;
int
num
;
memcpy
(
&
num
,
&
bytes
[
index
],
is
);
index
+=
is
;
if
(
!
VertexArray
::
decodeHeader
(
length
,
bytes
,
swap
,
name
,
num
,
type
,
min
,
max
,
int
ss
;
memcpy
(
&
ss
,
&
bytes
[
index
],
is
);
index
+=
is
;
numSteps
,
time
,
xmin
,
ymin
,
zmin
,
xmax
,
ymax
,
zmax
))
if
(
ss
){
return
;
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
;
Msg
::
Debug
(
"Filling vertex array (type %d) in view num %d"
,
type
,
num
);
Msg
::
Debug
(
"Filling vertex array (type %d) in view num %d"
,
type
,
num
);
...
@@ -1186,7 +1159,7 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
...
@@ -1186,7 +1159,7 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
PView
*
p
=
PView
::
getViewByNum
(
num
);
PView
*
p
=
PView
::
getViewByNum
(
num
);
if
(
!
p
){
if
(
!
p
){
Msg
::
Info
(
"View num %d does not exist: creating new view"
,
num
);
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)"
);
data
->
setName
(
name
+
" (remote)"
);
p
=
new
PView
(
data
,
num
);
p
=
new
PView
(
data
,
num
);
SetBoundingBox
();
SetBoundingBox
();
...
@@ -1207,22 +1180,22 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
...
@@ -1207,22 +1180,22 @@ void PView::fillVertexArray(ConnectionManager *remote, int length,
case
1
:
case
1
:
if
(
p
->
va_points
)
delete
p
->
va_points
;
if
(
p
->
va_points
)
delete
p
->
va_points
;
p
->
va_points
=
new
VertexArray
(
1
,
100
);
p
->
va_points
=
new
VertexArray
(
1
,
100
);
p
->
va_points
->
fromChar
(
bytes
,
swap
);
p
->
va_points
->
fromChar
(
length
,
bytes
,
swap
);
break
;
break
;
case
2
:
case
2
:
if
(
p
->
va_lines
)
delete
p
->
va_lines
;
if
(
p
->
va_lines
)
delete
p
->
va_lines
;
p
->
va_lines
=
new
VertexArray
(
2
,
100
);
p
->
va_lines
=
new
VertexArray
(
2
,
100
);
p
->
va_lines
->
fromChar
(
bytes
,
swap
);
p
->
va_lines
->
fromChar
(
length
,
bytes
,
swap
);
break
;
break
;
case
3
:
case
3
:
if
(
p
->
va_triangles
)
delete
p
->
va_triangles
;
if
(
p
->
va_triangles
)
delete
p
->
va_triangles
;
p
->
va_triangles
=
new
VertexArray
(
3
,
100
);
p
->
va_triangles
=
new
VertexArray
(
3
,
100
);
p
->
va_triangles
->
fromChar
(
bytes
,
swap
);
p
->
va_triangles
->
fromChar
(
length
,
bytes
,
swap
);
break
;
break
;
case
4
:
case
4
:
if
(
p
->
va_vectors
)
delete
p
->
va_vectors
;
if
(
p
->
va_vectors
)
delete
p
->
va_vectors
;
p
->
va_vectors
=
new
VertexArray
(
2
,
100
);
p
->
va_vectors
=
new
VertexArray
(
2
,
100
);
p
->
va_vectors
->
fromChar
(
bytes
,
swap
);
p
->
va_vectors
->
fromChar
(
length
,
bytes
,
swap
);
break
;
break
;
default:
default:
Msg
::
Error
(
"Cannot fill vertex array of type %d"
,
type
);
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