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
5bf7b2f2
Commit
5bf7b2f2
authored
9 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
fix allocation errors in AttractorField::operator()
parent
4a684cc2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Mesh/Field.cpp
+51
-46
51 additions, 46 deletions
Mesh/Field.cpp
with
51 additions
and
46 deletions
Mesh/Field.cpp
+
51
−
46
View file @
5bf7b2f2
...
@@ -1746,6 +1746,7 @@ class AttractorField : public Field
...
@@ -1746,6 +1746,7 @@ class AttractorField : public Field
if
(
dim
==
0
)
nodes_id
.
push_back
(
tag
);
if
(
dim
==
0
)
nodes_id
.
push_back
(
tag
);
else
if
(
dim
==
1
)
edges_id
.
push_back
(
tag
);
else
if
(
dim
==
1
)
edges_id
.
push_back
(
tag
);
else
if
(
dim
==
2
)
faces_id
.
push_back
(
tag
);
else
if
(
dim
==
2
)
faces_id
.
push_back
(
tag
);
_xField
=
_yField
=
_zField
=
NULL
;
_xFieldId
=
_yFieldId
=
_zFieldId
=
-
1
;
_xFieldId
=
_yFieldId
=
_zFieldId
=
-
1
;
update_needed
=
true
;
update_needed
=
true
;
}
}
...
@@ -1792,7 +1793,8 @@ class AttractorField : public Field
...
@@ -1792,7 +1793,8 @@ class AttractorField : public Field
"nodes is computed."
;
"nodes is computed."
;
}
}
void
getCoord
(
double
x
,
double
y
,
double
z
,
double
&
cx
,
double
&
cy
,
double
&
cz
,
void
getCoord
(
double
x
,
double
y
,
double
z
,
double
&
cx
,
double
&
cy
,
double
&
cz
,
GEntity
*
ge
=
NULL
)
{
GEntity
*
ge
=
NULL
)
{
cx
=
_xField
?
(
*
_xField
)(
x
,
y
,
z
,
ge
)
:
x
;
cx
=
_xField
?
(
*
_xField
)(
x
,
y
,
z
,
ge
)
:
x
;
cy
=
_yField
?
(
*
_yField
)(
x
,
y
,
z
,
ge
)
:
y
;
cy
=
_yField
?
(
*
_yField
)(
x
,
y
,
z
,
ge
)
:
y
;
cz
=
_zField
?
(
*
_zField
)(
x
,
y
,
z
,
ge
)
:
z
;
cz
=
_zField
?
(
*
_zField
)(
x
,
y
,
z
,
ge
)
:
z
;
...
@@ -1843,27 +1845,18 @@ class AttractorField : public Field
...
@@ -1843,27 +1845,18 @@ class AttractorField : public Field
}
}
}
}
int
totpoints
=
double
x
,
y
,
z
;
nodes_id
.
size
()
+
std
::
vector
<
double
>
px
,
py
,
pz
;
(
n_nodes_by_edge
-
2
)
*
edges_id
.
size
()
+
((
points
.
size
())
?
points
.
size
()
:
n_nodes_by_edge
*
n_nodes_by_edge
*
faces_id
.
size
());
Msg
::
Info
(
"%d points found in point clouds (%d edges)"
,
totpoints
,
(
int
)
edges_id
.
size
());
if
(
totpoints
){
zeronodes
=
annAllocPts
(
totpoints
,
3
);
_infos
.
resize
(
totpoints
);
}
int
k
=
0
;
for
(
std
::
list
<
int
>::
iterator
it
=
nodes_id
.
begin
();
for
(
std
::
list
<
int
>::
iterator
it
=
nodes_id
.
begin
();
it
!=
nodes_id
.
end
();
++
it
)
{
it
!=
nodes_id
.
end
();
++
it
)
{
GVertex
*
gv
=
GModel
::
current
()
->
getVertexByTag
(
*
it
);
GVertex
*
gv
=
GModel
::
current
()
->
getVertexByTag
(
*
it
);
if
(
gv
)
{
if
(
gv
)
{
getCoord
(
gv
->
x
(),
gv
->
y
(),
gv
->
z
(),
zeronodes
[
k
][
0
],
getCoord
(
gv
->
x
(),
gv
->
y
(),
gv
->
z
(),
x
,
y
,
z
,
gv
);
zeronodes
[
k
][
1
],
zeronodes
[
k
][
2
],
gv
);
px
.
push_back
(
x
);
_infos
[
k
++
]
=
AttractorInfo
(
*
it
,
0
,
0
,
0
);
py
.
push_back
(
y
);
pz
.
push_back
(
z
);
_infos
.
push_back
(
AttractorInfo
(
*
it
,
0
,
0
,
0
));
}
}
}
}
for
(
std
::
list
<
int
>::
iterator
it
=
edges_id
.
begin
();
for
(
std
::
list
<
int
>::
iterator
it
=
edges_id
.
begin
();
...
@@ -1872,11 +1865,14 @@ class AttractorField : public Field
...
@@ -1872,11 +1865,14 @@ class AttractorField : public Field
if
(
e
)
{
if
(
e
)
{
if
(
e
->
mesh_vertices
.
size
()){
if
(
e
->
mesh_vertices
.
size
()){
for
(
unsigned
int
i
=
0
;
i
<
e
->
mesh_vertices
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
e
->
mesh_vertices
.
size
();
i
++
)
{
double
u
;
e
->
mesh_vertices
[
i
]
->
getParameter
(
0
,
u
);
double
u
;
e
->
mesh_vertices
[
i
]
->
getParameter
(
0
,
u
);
GPoint
gp
=
e
->
point
(
u
);
GPoint
gp
=
e
->
point
(
u
);
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
zeronodes
[
k
][
0
],
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
x
,
y
,
z
,
e
);
zeronodes
[
k
][
1
],
zeronodes
[
k
][
2
],
e
);
px
.
push_back
(
x
);
_infos
[
k
++
]
=
AttractorInfo
(
*
it
,
1
,
u
,
0
);
py
.
push_back
(
y
);
pz
.
push_back
(
z
);
_infos
.
push_back
(
AttractorInfo
(
*
it
,
1
,
u
,
0
));
}
}
}
}
int
NNN
=
n_nodes_by_edge
-
e
->
mesh_vertices
.
size
();
int
NNN
=
n_nodes_by_edge
-
e
->
mesh_vertices
.
size
();
...
@@ -1885,15 +1881,16 @@ class AttractorField : public Field
...
@@ -1885,15 +1881,16 @@ class AttractorField : public Field
Range
<
double
>
b
=
e
->
parBounds
(
0
);
Range
<
double
>
b
=
e
->
parBounds
(
0
);
double
t
=
b
.
low
()
+
u
*
(
b
.
high
()
-
b
.
low
());
double
t
=
b
.
low
()
+
u
*
(
b
.
high
()
-
b
.
low
());
GPoint
gp
=
e
->
point
(
t
);
GPoint
gp
=
e
->
point
(
t
);
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
zeronodes
[
k
][
0
],
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
x
,
y
,
z
,
e
);
zeronodes
[
k
][
1
],
zeronodes
[
k
][
2
],
e
);
px
.
push_back
(
x
);
_infos
[
k
++
]
=
AttractorInfo
(
*
it
,
1
,
t
,
0
);
py
.
push_back
(
y
);
pz
.
push_back
(
z
);
_infos
.
push_back
(
AttractorInfo
(
*
it
,
1
,
t
,
0
));
}
}
}
}
}
}
// This can lead to weird results as we generate attractors over
// This can lead to weird results as we generate attractors over the whole
// the whole parametric plane (we should really use a mesh,
// parametric plane (we should really use a mesh, e.g. a refined STL.)
// e.g. a refined STL.)
int
count
=
0
;
int
count
=
0
;
for
(
std
::
list
<
int
>::
iterator
it
=
faces_id
.
begin
();
for
(
std
::
list
<
int
>::
iterator
it
=
faces_id
.
begin
();
it
!=
faces_id
.
end
();
++
it
)
{
it
!=
faces_id
.
end
();
++
it
)
{
...
@@ -1901,10 +1898,10 @@ class AttractorField : public Field
...
@@ -1901,10 +1898,10 @@ class AttractorField : public Field
if
(
f
)
{
if
(
f
)
{
if
(
points
.
size
()){
if
(
points
.
size
()){
for
(
int
j
=
offset
[
count
];
j
<
offset
[
count
+
1
];
j
++
)
{
for
(
int
j
=
offset
[
count
];
j
<
offset
[
count
+
1
];
j
++
)
{
zeronodes
[
k
][
0
]
=
points
[
j
].
x
();
px
.
push_back
(
points
[
j
].
x
()
)
;
zeronodes
[
k
][
1
]
=
points
[
j
].
y
();
py
.
push_back
(
points
[
j
].
y
()
)
;
zeronodes
[
k
][
2
]
=
points
[
j
].
z
();
pz
.
push_back
(
points
[
j
].
z
()
)
;
_infos
[
k
++
]
=
AttractorInfo
(
*
it
,
2
,
uvpoints
[
j
].
x
(),
uvpoints
[
j
].
y
());
_infos
.
push_back
(
AttractorInfo
(
*
it
,
2
,
uvpoints
[
j
].
x
(),
uvpoints
[
j
].
y
())
)
;
}
}
count
++
;
count
++
;
}
}
...
@@ -1918,20 +1915,31 @@ class AttractorField : public Field
...
@@ -1918,20 +1915,31 @@ class AttractorField : public Field
double
t1
=
b1
.
low
()
+
u
*
(
b1
.
high
()
-
b1
.
low
());
double
t1
=
b1
.
low
()
+
u
*
(
b1
.
high
()
-
b1
.
low
());
double
t2
=
b2
.
low
()
+
v
*
(
b2
.
high
()
-
b2
.
low
());
double
t2
=
b2
.
low
()
+
v
*
(
b2
.
high
()
-
b2
.
low
());
GPoint
gp
=
f
->
point
(
t1
,
t2
);
GPoint
gp
=
f
->
point
(
t1
,
t2
);
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
zeronodes
[
k
][
0
],
getCoord
(
gp
.
x
(),
gp
.
y
(),
gp
.
z
(),
x
,
y
,
z
,
f
);
zeronodes
[
k
][
1
],
zeronodes
[
k
][
2
],
f
);
px
.
push_back
(
x
);
_infos
[
k
++
]
=
AttractorInfo
(
*
it
,
2
,
u
,
v
);
py
.
push_back
(
y
);
pz
.
push_back
(
z
);
_infos
.
push_back
(
AttractorInfo
(
*
it
,
2
,
u
,
v
));
}
}
}
}
}
}
}
}
else
{
else
{
printf
(
"
f
ace %d not yet created
\n
"
,
*
it
);
Msg
::
Error
(
"
F
ace %d not yet created"
,
*
it
);
}
}
}
}
int
totpoints
=
px
.
size
();
zeronodes
=
annAllocPts
(
totpoints
,
3
);
for
(
int
i
=
0
;
i
<
totpoints
;
i
++
){
zeronodes
[
i
][
0
]
=
px
[
i
];
zeronodes
[
i
][
1
]
=
py
[
i
];
zeronodes
[
i
][
2
]
=
pz
[
i
];
}
kdtree
=
new
ANNkd_tree
(
zeronodes
,
totpoints
,
3
);
kdtree
=
new
ANNkd_tree
(
zeronodes
,
totpoints
,
3
);
update_needed
=
false
;
update_needed
=
false
;
}
}
double
xyz
[
3
];
double
xyz
[
3
];
getCoord
(
X
,
Y
,
Z
,
xyz
[
0
],
xyz
[
1
],
xyz
[
2
],
ge
);
getCoord
(
X
,
Y
,
Z
,
xyz
[
0
],
xyz
[
1
],
xyz
[
2
],
ge
);
kdtree
->
annkSearch
(
xyz
,
1
,
index
,
dist
);
kdtree
->
annkSearch
(
xyz
,
1
,
index
,
dist
);
...
@@ -2432,6 +2440,3 @@ void GenericField::setCallbackWithData(ptrfunction fct, void *data){
...
@@ -2432,6 +2440,3 @@ void GenericField::setCallbackWithData(ptrfunction fct, void *data){
user_data
.
push_back
(
data
);
user_data
.
push_back
(
data
);
cbs
.
push_back
(
fct
);
cbs
.
push_back
(
fct
);
}
}
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