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
Analyze
Contributor 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
Gmsh
Gmsh
Commits
30cc1751
Commit
30cc1751
authored
Dec 4, 2018
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
limit vertex array prealloc to reasonable values
parent
2798ed59
No related branches found
No related tags found
No related merge requests found
Pipeline
#3027
passed
Dec 4, 2018
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/VertexArray.cpp
+17
-8
17 additions, 8 deletions
Common/VertexArray.cpp
Geo/GModelVertexArrays.cpp
+11
-4
11 additions, 4 deletions
Geo/GModelVertexArrays.cpp
with
28 additions
and
12 deletions
Common/VertexArray.cpp
+
17
−
8
View file @
30cc1751
...
...
@@ -9,6 +9,7 @@
#include
"VertexArray.h"
#include
"Context.h"
#include
"Numeric.h"
#include
"OS.h"
template
<
int
N
>
float
ElementDataLessThan
<
N
>::
tolerance
=
0.0F
;
float
BarycenterLessThan
::
tolerance
=
0.0F
;
...
...
@@ -17,11 +18,27 @@ VertexArray::VertexArray(int numVerticesPerElement, int numElements)
:
_numVerticesPerElement
(
numVerticesPerElement
)
{
int
nb
=
(
numElements
?
numElements
:
1
)
*
_numVerticesPerElement
;
double
memv
=
(
nb
*
3.
*
sizeof
(
float
))
/
1024.
/
1024.
;
double
memmax
=
TotalRam
()
/
3.
;
if
(
memv
>
memmax
){
int
old
=
nb
;
nb
=
memmax
/
(
3.
*
sizeof
(
float
))
*
1024
*
1024
;
Msg
::
Debug
(
"Reduce preallocation of vertex array (%d -> %d)"
,
old
,
nb
);
}
_vertices
.
reserve
(
nb
*
3
);
_normals
.
reserve
(
nb
*
3
);
_colors
.
reserve
(
nb
*
4
);
}
double
VertexArray
::
getMemoryInMb
()
{
int
bytes
=
_vertices
.
size
()
*
sizeof
(
float
)
+
_normals
.
size
()
*
sizeof
(
normal_type
)
+
_colors
.
size
()
*
sizeof
(
unsigned
char
);
return
(
double
)
bytes
/
1024.
/
1024.
;
}
void
VertexArray
::
_addVertex
(
float
x
,
float
y
,
float
z
)
{
_vertices
.
push_back
(
x
);
...
...
@@ -214,14 +231,6 @@ void VertexArray::sort(double x, double y, double z)
_colors
=
sortedColors
;
}
double
VertexArray
::
getMemoryInMb
()
{
int
bytes
=
_vertices
.
size
()
*
sizeof
(
float
)
+
_normals
.
size
()
*
sizeof
(
normal_type
)
+
_colors
.
size
()
*
sizeof
(
unsigned
char
);
return
(
double
)
bytes
/
1024.
/
1024.
;
}
char
*
VertexArray
::
toChar
(
int
num
,
const
std
::
string
&
name
,
int
type
,
double
min
,
double
max
,
int
numsteps
,
double
time
,
const
SBoundingBox3d
&
bbox
,
int
&
len
)
...
...
This diff is collapsed.
Click to expand it.
Geo/GModelVertexArrays.cpp
+
11
−
4
View file @
30cc1751
...
...
@@ -360,12 +360,19 @@ private:
bool
_curved
;
int
_estimateIfClipped
(
int
num
)
{
if
(
CTX
::
instance
()
->
clipWholeElements
&&
CTX
::
instance
()
->
clipOnlyDrawIntersectingVolume
)
{
if
(
CTX
::
instance
()
->
clipWholeElements
)
{
for
(
int
clip
=
0
;
clip
<
6
;
clip
++
)
{
if
(
CTX
::
instance
()
->
mesh
.
clip
&
(
1
<<
clip
))
if
(
CTX
::
instance
()
->
mesh
.
clip
&
(
1
<<
clip
)){
if
(
CTX
::
instance
()
->
clipOnlyDrawIntersectingVolume
){
// let be more aggressive than num^{2/3}
return
(
int
)
sqrt
((
double
)
num
);
}
else
{
// why not :-)
return
num
/
4
;
}
}
}
}
return
num
;
}
...
...
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