1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2011 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC) //
// http://www.uq.edu.au/esscc //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
#include <boost/version.hpp>
#include <Geometry/SimpleParticle.h>
#include "Python/esys/lsm/geometry/SimpleSpherePy.h"
namespace esys
{
namespace lsm
{
SimpleSpherePy SimpleSpherePy::INVALID = SimpleSpherePy(Vec3Py(Vec3::ZERO), 0.0, -1, -1, -1.0);
SimpleSpherePy::SimpleSpherePy(
const Vec3Py ¢er,
double radius,
int id,
int tag,
double mass
) : SimpleParticle(center, radius, id, tag)
{
if (mass >= 0.0)
{
setMass(mass);
}
}
SimpleSpherePy::SimpleSpherePy(
int id,
const Vec3Py &posn,
double radius,
double mass
)
: SimpleParticle(posn, radius, id, 0)
{
if (mass >= 0.0)
{
setMass(mass);
}
}
SimpleSpherePy::SimpleSpherePy(const SimpleSpherePy &particle)
: SimpleParticle(particle)
{
}
void SimpleSpherePy::setPosnPy(const Vec3Py posn)
{
setPos(posn);
}
bool SimpleSpherePy::operator==(const SimpleSpherePy &p) const
{
return (getID() == p.getID());
}
Vec3Py SimpleSpherePy::getPosnPy() const
{
return Vec3Py(getPos());
}
void SimpleSpherePy::translateByPy(const Vec3Py &translation)
{
translateBy(translation);
}
void SimpleSpherePy::rigidRotatePy(const Vec3Py &axis, const Vec3Py &pt)
{
rotate(axis, pt);
}
class SimpleSpherePyPickleSuite : public boost::python::pickle_suite
{
public:
static
boost::python::tuple
getinitargs(SimpleSpherePy const& p)
{
return
boost::python::make_tuple(
p.getPosnPy(),
p.getRadius(),
p.getId(),
p.getTag(),
p.getMass()
);
}
};
using boost::python::arg;
void exportSimpleSphere()
{
// Check that Boost 1.34.0 or higher is being used.
// If so, disable auto-generation of C++ signatures for Epydoc
// (which stumbles over indentation in the auto-generated strings).
#if ((BOOST_VERSION / 100000 >= 1) \
&& (BOOST_VERSION / 100 % 1000 >= 34)) \
|| (BOOST_VERSION / 100000 >= 2)
boost::python::docstring_options no_autogen(true,false);
#endif
boost::python::class_<SimpleSpherePy>(
"SimpleSphere",
boost::python::init<
const Vec3Py &,
double,
int,
int,
double
>(
(
arg("centre")=Vec3Py(Vec3::ZERO),
arg("radius")=1.0,
arg("id")=0,
arg("tag")=0,
arg("mass")=-1.0
)
)
)
.def(
boost::python::init<
const SimpleSpherePy &
>(
(
arg("p")
)
)
)
.def(
boost::python::init<
int,
const Vec3Py &,
double,
double
>(
(
arg("id"),
arg("posn"),
arg("radius"),
arg("mass")
),
"Constructs a spherical particle.\n"
"@type centre: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg centre: Centre point of the spherical particle.\n"
"@type radius: float\n"
"@kwarg radius: Radius of the spherical particle.\n"
"@type id: int\n"
"@kwarg id: Unique identifier for the particle.\n"
"@type tag: int\n"
"@kwarg tag: Label for the particle.\n"
"@type mass: float\n"
"@kwarg mass: The mass of the spherical particle.\n"
)
)
.def(
"getRadius",
&SimpleSpherePy::getRad,
"Returns the radius of this sphere.\n"
"@rtype: float\n"
"@return: Radius of this sphere."
)
.def(
"getRad",
&SimpleSpherePy::getRad,
"Returns the radius of this sphere.\n"
"@rtype: float\n"
"@return: Radius of this sphere."
)
.def(
"getCenter",
&SimpleSpherePy::getPosnPy,
"Returns the centre point of this sphere.\n"
"@rtype: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy>}\n"
"@return: Returns the centre point of this sphere.\n"
)
.def(
"getCentre",
&SimpleSpherePy::getPosnPy,
"Returns the centre point of this sphere.\n"
"@rtype: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy>}\n"
"@return: Returns the centre point of this sphere.\n"
)
.def(
"getPosn",
&SimpleSpherePy::getPosnPy,
"Returns the centre point of this sphere.\n"
"@rtype: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy>}\n"
"@return: Returns the centre point of this sphere.\n"
)
.def(
"getPos",
&SimpleSpherePy::getPosnPy,
"Returns the centre point of this sphere.\n"
"@rtype: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy>}\n"
"@return: Returns the centre point of this sphere.\n"
)
.def(
"getId",
&SimpleSpherePy::getID,
"Returns the id associated with this particle.\n"
"@rtype: int\n"
"@return: Particle ID."
)
.def(
"getTag",
&SimpleSpherePy::getTag,
"Returns the tag assigned to this particle.\n"
"@rtype: int\n"
"@return: tag value assigned to this particle."
)
.def(
"getMass",
&SimpleSpherePy::getMass,
"Returns the mass of this particle.\n"
"@rtype: float\n"
"@return: mass"
)
/* .def(
"getVolume",
&SimpleSpherePy::getVolume,
"Returns the volume of this particle.\n"
"@rtype: float\n"
"@return: volume"
)
*/ .def(
"setRadius",
&SimpleSpherePy::setRad,
(arg("radius")),
"Sets the radius of this sphere.\n"
"@type radius: float\n"
"@kwarg radius: radius."
)
.def(
"setRad",
&SimpleSpherePy::setRad,
(arg("radius")),
"Sets the radius of this sphere.\n"
"@type radius: float\n"
"@kwarg radius: radius."
)
.def(
"setCenter",
&SimpleSpherePy::setPosnPy,
(arg("position")),
"Sets the centre-point of this sphere.\n"
"@type position: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg position: centre point."
)
.def(
"setCentre",
&SimpleSpherePy::setPosnPy,
(arg("position")),
"Sets the centre-point of this sphere.\n"
"@type position: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg position: centre point."
)
.def(
"setPosn",
&SimpleSpherePy::setPosnPy,
(arg("position")),
"Sets the centre-point of this sphere.\n"
"@type position: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg position: centre point."
)
.def(
"setPos",
&SimpleSpherePy::setPosnPy,
(arg("position")),
"Sets the centre-point of this sphere.\n"
"@type position: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg position: centre point."
)
.def(
"translate",
&SimpleSpherePy::translateByPy,
(arg("translation")),
"Moves the centre-point of this sphere by a specified translation.\n"
"@type translation: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg translation: Vector added to the current centre-point position."
)
.def(
"rotate",
&SimpleSpherePy::rigidRotatePy,
(
arg("axis"),
arg("pt")
),
"Performs rigid body rotation of the sphere about a specified axis.\n"
"@type axis: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg axis: The direction and magnitude of the axis of rotation.\n"
"@type pt: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg pt: Point through which the axis passes.\n"
)
.def(
"setId",
&SimpleSpherePy::setID,
(arg("id")),
"Sets the ID of this spherical particle.\n"
"@type id: int\n"
"@kwarg id: Identifier for this particle."
)
.def(
"setTag",
&SimpleSpherePy::setTag,
(arg("tag")),
"Sets the tag associated with this particle.\n"
"@type tag: int\n"
"@kwarg tag: Identifier for this particle."
)
.def(
"setMass",
&SimpleSpherePy::setMass,
(arg("mass")),
"Sets the mass of this particle.\n"
"@type mass: float\n"
"@kwarg mass: the new mass."
)
.def(
"__eq__",
&SimpleSpherePy::operator==,
(arg("p")),
"Equality operator for particles,"
" simply compares particle ID values.\n"
"@rtype: bool\n"
"@return: self.getId() == p.getId()"
)
.def(
"__hash__",
&SimpleSpherePy::getID,
"Returns a hash value for use in dictionaries and sets.\n"
"@rtype: int\n"
"@return: self.getId()"
)
.def_pickle(SimpleSpherePyPickleSuite())
;
}
}
}
|