Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
23d1c577
Commit
23d1c577
authored
12 years ago
by
Niklaus Johner
Browse files
Options
Downloads
Patches
Plain Diff
Added operators for geom::Vec3List
parent
6fd32068
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/geom/pymod/export_vec3.cc
+13
-0
13 additions, 0 deletions
modules/geom/pymod/export_vec3.cc
modules/geom/src/vec3.hh
+68
-2
68 additions, 2 deletions
modules/geom/src/vec3.hh
with
81 additions
and
2 deletions
modules/geom/pymod/export_vec3.cc
+
13
−
0
View file @
23d1c577
...
@@ -95,6 +95,19 @@ void export_Vec3()
...
@@ -95,6 +95,19 @@ void export_Vec3()
class_
<
Vec3List
>
(
"Vec3List"
,
init
<>
())
class_
<
Vec3List
>
(
"Vec3List"
,
init
<>
())
.
def
(
vector_indexing_suite
<
Vec3List
>
())
.
def
(
vector_indexing_suite
<
Vec3List
>
())
.
def
(
geom
::
VectorAdditions
<
Vec3List
>
())
.
def
(
geom
::
VectorAdditions
<
Vec3List
>
())
.
def
(
self
*=
Real
())
.
def
(
self
/=
Real
())
.
def
(
self
+=
Real
())
.
def
(
self
+=
self
)
.
def
(
self
-=
self
)
//.def(-self)
.
def
(
self
*
Real
())
.
def
(
Real
()
*
self
)
.
def
(
self
/
Real
())
.
def
(
self
+
self
)
.
def
(
self
+
Real
())
.
def
(
Real
()
+
self
)
.
def
(
self
-
self
)
.
add_property
(
"center"
,
&
Vec3List
::
GetCenter
)
.
add_property
(
"center"
,
&
Vec3List
::
GetCenter
)
.
add_property
(
"inertia"
,
&
Vec3List
::
GetInertia
)
.
add_property
(
"inertia"
,
&
Vec3List
::
GetInertia
)
.
add_property
(
"principal_axes"
,
&
Vec3List
::
GetPrincipalAxes
)
.
add_property
(
"principal_axes"
,
&
Vec3List
::
GetPrincipalAxes
)
...
...
This diff is collapsed.
Click to expand it.
modules/geom/src/vec3.hh
+
68
−
2
View file @
23d1c577
...
@@ -207,7 +207,13 @@ namespace geom {
...
@@ -207,7 +207,13 @@ namespace geom {
// TODO: move to separate file
// TODO: move to separate file
class
Mat3
;
class
Mat3
;
class
DLLEXPORT_OST_GEOM
Vec3List
:
public
std
::
vector
<
Vec3
>
{
class
DLLEXPORT_OST_GEOM
Vec3List
:
public
std
::
vector
<
Vec3
>
,
private
boost
::
equality_comparable
<
Vec3List
>
,
private
boost
::
additive
<
Vec3List
>
,
private
boost
::
additive
<
Vec3List
,
Real
>
,
private
boost
::
multiplicative
<
Vec3List
,
Real
>
{
public:
public:
typedef
std
::
vector
<
Vec3
>
base_type
;
typedef
std
::
vector
<
Vec3
>
base_type
;
Vec3List
()
:
base_type
()
{}
Vec3List
()
:
base_type
()
{}
...
@@ -222,7 +228,67 @@ public:
...
@@ -222,7 +228,67 @@ public:
base_type
::
operator
=
(
rhs
);
base_type
::
operator
=
(
rhs
);
return
*
this
;
return
*
this
;
}
}
//! addable op
Vec3List
&
operator
+=
(
const
Vec3List
&
rhs
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
+=
(
rhs
)[
i
];
}
return
*
this
;
}
Vec3List
&
operator
+=
(
Real
d
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
+=
d
;
}
return
*
this
;
}
//! subtractable op
Vec3List
&
operator
-=
(
const
Vec3List
&
rhs
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
-=
(
rhs
)[
i
];
}
return
*
this
;
}
Vec3List
&
operator
-=
(
Real
d
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
-=
d
;
}
return
*
this
;
}
//! negateable
//Vec3List3 operator-() const
//{
// geom::Vec3List vl;
// for (unsigned int i=0;i!=this->size();++i) {
// geom::Vec3 v=(*this)[i];
// vl.push_back(-v);
// }
// return vl;
//}
//! multipliable
Vec3List
&
operator
*=
(
Real
d
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
*=
d
;
}
return
*
this
;
}
//! dividable
Vec3List
&
operator
/=
(
Real
d
)
{
for
(
unsigned
int
i
=
0
;
i
!=
this
->
size
();
++
i
)
{
(
*
this
)[
i
]
/=
d
;
}
return
*
this
;
}
// TODO: move some or all of these to stand-alone functions
// TODO: move some or all of these to stand-alone functions
Mat3
GetInertia
()
const
;
Mat3
GetInertia
()
const
;
Vec3
GetCenter
()
const
;
Vec3
GetCenter
()
const
;
...
...
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