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
109e7023
Commit
109e7023
authored
11 years ago
by
Nicolas Marsic
Browse files
Options
Downloads
Patches
Plain Diff
PermutationTree::toLatex \o/
parent
56bbd11c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
FunctionSpace/PermutationTree.cpp
+109
-1
109 additions, 1 deletion
FunctionSpace/PermutationTree.cpp
FunctionSpace/PermutationTree.h
+9
-0
9 additions, 0 deletions
FunctionSpace/PermutationTree.h
with
118 additions
and
1 deletion
FunctionSpace/PermutationTree.cpp
+
109
−
1
View file @
109e7023
#include
<map>
#include
<map>
#include
<fstream>
#include
<fstream>
#include
<sstream>
#include
<cstring>
#include
<cstring>
#include
"Exception.h"
#include
"Exception.h"
...
@@ -368,6 +367,115 @@ string PermutationTree::toString(void) const{
...
@@ -368,6 +367,115 @@ string PermutationTree::toString(void) const{
return
stream
.
str
();
return
stream
.
str
();
}
}
string
PermutationTree
::
toLatex
(
void
)
const
{
stringstream
stream
;
// Small FEM //
stream
<<
"%%% Automaticaly generated by SmallFem"
<<
endl
;
// Header //
stream
<<
"
\\
documentclass[11pt]{article}"
<<
endl
<<
endl
<<
"
\\
usepackage{tikz}"
<<
endl
<<
endl
<<
"
\\
usetikzlibrary{arrows}"
<<
endl
<<
"
\\
tikzstyle{vertex} = [circle, fill = black!25, inner sep = 2pt]"
<<
endl
<<
"
\\
tikzstyle{line} = [thick, black]"
<<
endl
<<
"
\\
tikzstyle{arrow} = [-stealth']"
<<
endl
<<
endl
<<
"
\\
begin{document}"
<<
endl
<<
"
\\
begin{tikzpicture}"
;
// Options //
stream
<<
"["
<<
"grow = right,"
<<
"edge from parent/.style={draw, line},"
<<
"level 1/.style={sibling distance=12em},"
<<
"level 2/.style={sibling distance=4em},"
<<
"level 3/.style={sibling distance=2em},"
<<
"level 5/.style={level distance=5em},"
<<
"]"
<<
endl
;
// Tree //
// Root
stream
<<
"
\\
node[vertex]{
\\
phantom{$0$}}"
<<
endl
;
// Travel from root in deepFirst and add childs to stream
deepFirstStream
(
root
,
stream
);
// Final ;
stream
<<
";"
<<
endl
<<
endl
;
// Leaf Ids //
for
(
size_t
i
=
0
;
i
<
leaf
.
size
();
i
++
)
stream
<<
"
\\
node[xshift=8, yshift=10] "
<<
"at(l"
<<
leaf
[
i
]
->
leafId
<<
") "
<<
"{
\\
scriptsize $"
<<
leaf
[
i
]
->
leafId
<<
"$};"
<<
endl
;
// Footer //
stream
<<
"
\\
end{tikzpicture}"
<<
endl
<<
"
\\
end{document}"
<<
endl
;
return
stream
.
str
();
}
void
PermutationTree
::
deepFirstStream
(
node_t
*
node
,
stringstream
&
stream
)
const
{
vector
<
size_t
>
permutation
(
getSequenceSize
());
// If node is root, don't add to stream: just loop on its childs
if
(
node
->
myChoice
==
(
size_t
)(
-
1
))
for
(
size_t
i
=
0
;
i
<
node
->
son
.
size
();
i
++
)
deepFirstStream
(
node
->
son
[
i
],
stream
);
// Else, insert node in stream as child //
else
{
stream
<<
"child{node[vertex]"
;
// If node, name it
if
(
node
->
son
.
size
()
==
0
)
stream
<<
"(l"
<<
node
->
leafId
<<
")"
;
stream
<<
"{"
<<
node
->
myChoice
<<
"}"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
node
->
son
.
size
();
i
++
)
deepFirstStream
(
node
->
son
[
i
],
stream
);
// If leaf, child is tag and permutation //
if
(
node
->
son
.
size
()
==
0
){
// Permutation
fillWithPermutation
(
node
->
leafId
,
permutation
);
stream
<<
"child{node{$["
;
for
(
size_t
j
=
0
;
j
<
permutation
.
size
()
-
1
;
j
++
)
stream
<<
permutation
[
j
]
<<
", "
;
stream
<<
permutation
[
permutation
.
size
()
-
1
]
<<
"]$}"
<<
" edge from parent[arrow]"
<<
endl
;
// Tag
stream
<<
"child{node[anchor=west]{"
<<
node
->
tag
;
// Is true orientation ?
if
(
node
->
tag
==
node
->
leafId
)
stream
<<
" (
\\
emph{True Orientation})"
;
stream
<<
"} edge from parent[arrow]"
<<
endl
;
// Done
stream
<<
"}}"
;
}
stream
<<
"}"
<<
endl
;
}
// If leaf, return //
if
(
node
->
son
.
size
()
==
0
)
return
;
}
std
::
pair
<
size_t
,
char
*>
PermutationTree
::
serialize
(
void
)
const
{
std
::
pair
<
size_t
,
char
*>
PermutationTree
::
serialize
(
void
)
const
{
// Enumerate Nodes //
// Enumerate Nodes //
list
<
node_t
*>
node
;
list
<
node_t
*>
node
;
...
...
This diff is collapsed.
Click to expand it.
FunctionSpace/PermutationTree.h
+
9
−
0
View file @
109e7023
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
<vector>
#include
<vector>
#include
<list>
#include
<list>
#include
<string>
#include
<string>
#include
<sstream>
/**
/**
@class PermutationTree
@class PermutationTree
...
@@ -84,6 +85,8 @@ class PermutationTree{
...
@@ -84,6 +85,8 @@ class PermutationTree{
std
::
vector
<
std
::
pair
<
size_t
,
size_t
>
>
getAllTagsCount
(
void
)
const
;
std
::
vector
<
std
::
pair
<
size_t
,
size_t
>
>
getAllTagsCount
(
void
)
const
;
std
::
string
toString
(
void
)
const
;
std
::
string
toString
(
void
)
const
;
std
::
string
toLatex
(
void
)
const
;
std
::
pair
<
size_t
,
char
*>
serialize
(
void
)
const
;
std
::
pair
<
size_t
,
char
*>
serialize
(
void
)
const
;
void
serialize
(
const
std
::
string
&
path
)
const
;
void
serialize
(
const
std
::
string
&
path
)
const
;
...
@@ -100,6 +103,8 @@ class PermutationTree{
...
@@ -100,6 +103,8 @@ class PermutationTree{
const
std
::
vector
<
size_t
>&
sequence
,
const
std
::
vector
<
size_t
>&
sequence
,
size_t
offset
);
size_t
offset
);
void
deepFirstStream
(
node_t
*
node
,
std
::
stringstream
&
stream
)
const
;
static
void
enumerate
(
node_t
*
node
,
std
::
list
<
node_t
*>&
listOfNode
);
static
void
enumerate
(
node_t
*
node
,
std
::
list
<
node_t
*>&
listOfNode
);
static
void
unlink
(
node_t
*
node
,
unlink_t
*
unlink
,
size_t
maxSize
);
static
void
unlink
(
node_t
*
node
,
unlink_t
*
unlink
,
size_t
maxSize
);
void
serialize
(
char
*
stream
,
unlink_t
*
unlink
)
const
;
void
serialize
(
char
*
stream
,
unlink_t
*
unlink
)
const
;
...
@@ -194,6 +199,10 @@ class PermutationTree{
...
@@ -194,6 +199,10 @@ class PermutationTree{
@return Returns a string describing this PermutationTree
@return Returns a string describing this PermutationTree
**
**
@fn PermutationTree::toLatex
@return Returns a string (of a Latex file) describing this PermutationTree
**
@fn PermutationTree::serialize(void) const
@fn PermutationTree::serialize(void) const
Serialize this PermutationTree into a byte stream
Serialize this PermutationTree into a byte stream
...
...
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