Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cm3Libraries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
cm3
cm3Libraries
Commits
cd5e6bde
Commit
cd5e6bde
authored
4 years ago
by
Van Dung NGUYEN
Browse files
Options
Downloads
Patches
Plain Diff
correct tree removing
parent
aa13d163
No related branches found
No related tags found
1 merge request
!309
Master
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
NonLinearSolver/modelReduction/Tree.cpp
+100
-60
100 additions, 60 deletions
NonLinearSolver/modelReduction/Tree.cpp
NonLinearSolver/modelReduction/Tree.h
+1
-0
1 addition, 0 deletions
NonLinearSolver/modelReduction/Tree.h
with
101 additions
and
60 deletions
NonLinearSolver/modelReduction/Tree.cpp
+
100
−
60
View file @
cd5e6bde
...
...
@@ -64,6 +64,7 @@ void TreeNode::saveToFile(FILE* f) const
fprintf
(
f
,
" %f"
,
direction
[
i
]);
}
fprintf
(
f
,
" %s
\n
"
,
af
->
getName
().
c_str
());
fflush
(
f
);
};
void
TreeNode
::
getNormal
(
std
::
vector
<
SVector3
>&
allVec
,
bool
stiff
,
std
::
vector
<
std
::
vector
<
SVector3
>
>*
allDnormalDunknown
)
const
...
...
@@ -917,7 +918,13 @@ void Tree::loadDataFromFile(std::string filename)
node
->
depth
=
depth
;
node
->
location
=
location
;
node
->
childOrder
=
childOrder
;
node
->
parent
=
nodeMap
[
std
::
pair
<
int
,
int
>
(
depth
-
1
,
parentIdLoc
)];
std
::
pair
<
int
,
int
>
twoNum
(
depth
-
1
,
parentIdLoc
);
if
(
nodeMap
.
find
(
twoNum
)
==
nodeMap
.
end
())
{
Msg
::
Error
(
"node %d %d is not found !!!"
,
depth
-
1
,
parentIdLoc
);
Msg
::
Exit
(
0
);
}
node
->
parent
=
nodeMap
[
twoNum
];
node
->
parent
->
childs
[
childOrder
]
=
node
;
node
->
matIndex
=
matIndex
;
if
(
numChild
>
0
)
...
...
@@ -1195,10 +1202,8 @@ bool Tree::treeMerging()
for
(
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
TreeNode
*
,
int
>
>
>::
iterator
it
=
mapIndexes
.
begin
();
it
!=
mapIndexes
.
end
();
it
++
)
{
int
mIndex
=
it
->
first
;
if
(
mIndex
>=
0
)
{
std
::
vector
<
std
::
pair
<
TreeNode
*
,
int
>
>&
sameMat
=
it
->
second
;
if
(
sameMat
.
size
()
>
1
)
if
((
mIndex
>=
0
)
&&
(
sameMat
.
size
()
>
1
)
)
{
std
::
vector
<
TreeNode
*>
nodes
;
std
::
set
<
int
>
position
;
...
...
@@ -1263,8 +1268,6 @@ bool Tree::treeMerging()
//
break
;
}
}
}
};
}
...
...
@@ -1359,6 +1362,14 @@ bool Tree::removeZeroBranches(double tol)
child
->
parent
=
node
->
parent
;
child
->
childOrder
=
node
->
childOrder
;
grandParent
->
childs
[
node
->
childOrder
]
=
child
;
// decrease all associated nodes by 1
std
::
vector
<
TreeNode
*>
allAssociatedNodesToChild
;
getRefToAssociatedNodes
(
child
,
allAssociatedNodesToChild
);
for
(
int
j
=
0
;
j
<
allAssociatedNodesToChild
.
size
();
j
++
)
{
allAssociatedNodesToChild
[
j
]
->
depth
--
;
};
Msg
::
Info
(
"------------------"
);
Msg
::
Info
(
"node is replaced by child"
);
}
...
...
@@ -1463,7 +1474,7 @@ void Tree::printTree() const
{
printf
(
"Tree print
\n
"
);
if
(
_root
==
NULL
)
return
;
std
::
vector
<
TreeNode
*>
listPrev
,
listCur
;
std
::
vector
<
TreeNode
*>
listPrev
(
0
)
,
listCur
(
0
)
;
listPrev
.
push_back
(
_root
);
int
depth
=
0
;
while
(
true
)
...
...
@@ -1994,6 +2005,35 @@ void Tree::getAllNodes(nodeContainer& allNodes) const
};
};
void
Tree
::
getRefToAssociatedNodes
(
TreeNode
*
node
,
std
::
vector
<
TreeNode
*>&
allNodes
)
{
allNodes
.
clear
();
std
::
vector
<
TreeNode
*>
listPrev
,
listCur
;
listPrev
.
push_back
(
node
);
//
while
(
true
)
{
listCur
.
clear
();
for
(
int
i
=
0
;
i
<
listPrev
.
size
();
i
++
)
{
TreeNode
*
np
=
listPrev
[
i
];
for
(
int
j
=
0
;
j
<
np
->
childs
.
size
();
j
++
)
{
listCur
.
push_back
(
np
->
childs
[
j
]);
}
}
listPrev
=
listCur
;
if
(
listCur
.
size
()
==
0
)
{
break
;
}
else
{
allNodes
.
insert
(
allNodes
.
end
(),
listCur
.
begin
(),
listCur
.
end
());
}
};
}
void
Tree
::
getRefToAllNodes
(
std
::
vector
<
TreeNode
*>&
allNodes
)
{
allNodes
.
clear
();
...
...
This diff is collapsed.
Click to expand it.
NonLinearSolver/modelReduction/Tree.h
+
1
−
0
View file @
cd5e6bde
...
...
@@ -93,6 +93,7 @@ class Tree
double
getNonNegativeWeight
(
const
TreeNode
*
node
)
const
;
void
getRefToAllLeaves
(
std
::
vector
<
TreeNode
*>&
allLeaves
);
void
getRefToAllNodes
(
std
::
vector
<
TreeNode
*>&
allNodes
);
void
getRefToAssociatedNodes
(
TreeNode
*
node
,
std
::
vector
<
TreeNode
*>&
allNodes
);
#endif //SWIG
protected
:
...
...
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