Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
3aac2be2
Commit
3aac2be2
authored
Apr 21, 2020
by
Dennis Gläser
Browse files
[python][vector] add repr field
parent
6963bcb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
frackit/python/geometry/vector.hh
View file @
3aac2be2
...
...
@@ -110,6 +110,20 @@ namespace Detail {
cls
.
def
(
"x"
,
&
Vector
::
x
,
"x-coordinate of the vector"
);
if
constexpr
(
worldDim
>
1
)
cls
.
def
(
"y"
,
&
Vector
::
y
,
"y-coordinate of the vector"
);
if
constexpr
(
worldDim
>
2
)
cls
.
def
(
"z"
,
&
Vector
::
z
,
"z-coordinate of the vector"
);
using
std
::
to_string
;
if
constexpr
(
worldDim
==
1
)
cls
.
def
(
"__repr__"
,
[
&
]
(
const
Vector
&
v
)
{
return
"Frackit::Vector<1> ("
+
to_string
(
v
.
x
())
+
")"
;
});
else
if
constexpr
(
worldDim
==
2
)
cls
.
def
(
"__repr__"
,
[
&
]
(
const
Vector
&
v
)
{
return
"Frackit::Vector<2> ("
+
to_string
(
v
.
x
())
+
", "
+
to_string
(
v
.
y
())
+
")"
;
});
else
cls
.
def
(
"__repr__"
,
[
&
]
(
const
Vector
&
v
)
{
return
"Frackit::Vector<3> ("
+
to_string
(
v
.
x
())
+
", "
+
to_string
(
v
.
y
())
+
", "
+
to_string
(
v
.
z
())
+
")"
;
});
}
}
// end namespace detail
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment