[Debian-astro-commits] [gyoto] 119/221: Convert FixedStar to Object/Property
Thibaut Jean-Claude Paumard
thibaut at moszumanska.debian.org
Fri May 22 20:52:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
thibaut pushed a commit to branch master
in repository gyoto.
commit e843260a99b0863c828064383bb451a1836cb057
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date: Thu Nov 27 19:50:28 2014 +0100
Convert FixedStar to Object/Property
---
include/GyotoFixedStar.h | 13 ++++---------
lib/FixedStar.C | 34 ++++++++++++++++------------------
2 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/include/GyotoFixedStar.h b/include/GyotoFixedStar.h
index 0a60dc6..f363521 100644
--- a/include/GyotoFixedStar.h
+++ b/include/GyotoFixedStar.h
@@ -59,6 +59,7 @@ class Gyoto::Astrobj::FixedStar : public Astrobj::UniformSphere {
// Constructors - Destructor
// -------------------------
public:
+ GYOTO_OBJECT;
/**
* Everything is undefined, call setCoordSys(), setPos() and
@@ -81,6 +82,9 @@ class Gyoto::Astrobj::FixedStar : public Astrobj::UniformSphere {
double const * getPos() const; ///< Get const pointer to pos_
void getPos(double* dst) const; ///< Get a copy of the pos_ array
+ std::vector<double> position() const; ///< Get vector copy of #pos_
+ void position(std::vector<double> const&); ///< Set #pos_ from vector
+
double rMax();
bool rotating() const ;
@@ -93,15 +97,6 @@ class Gyoto::Astrobj::FixedStar : public Astrobj::UniformSphere {
void setPos(const double[3]); ///< Set pos_ array
// void setCoordSys(int); ///< set coordinate system
- virtual int setParameter(std::string name,
- std::string content,
- std::string unit);
-
- public:
-#ifdef GYOTO_USE_XERCES
- virtual void fillElement(FactoryMessenger *fmp) const ;
-#endif
-
// Outputs
// -------
protected:
diff --git a/lib/FixedStar.C b/lib/FixedStar.C
index 2370cf8..7464ed8 100644
--- a/lib/FixedStar.C
+++ b/lib/FixedStar.C
@@ -20,6 +20,7 @@
#include "GyotoUtils.h"
#include "GyotoPhoton.h"
#include "GyotoFixedStar.h"
+#include "GyotoProperty.h"
#include "GyotoFactoryMessenger.h"
#include <iostream>
@@ -37,6 +38,12 @@ using namespace std;
using namespace Gyoto;
using namespace Gyoto::Astrobj;
+GYOTO_PROPERTY_BOOL(FixedStar,
+ Rotating, NonRotating, rotating,
+ UniformSphere::properties);
+GYOTO_PROPERTY_VECTOR_DOUBLE(FixedStar, Position, position, &Rotating);
+GYOTO_PROPERTY_FINALIZE(FixedStar, &Position);
+
FixedStar::FixedStar() : UniformSphere("FixedStar"), rotating_(false)
{
# if GYOTO_DEBUG_ENABLED
@@ -167,24 +174,15 @@ double FixedStar::rMax() {
void FixedStar::setPos(const double p[3])
{ for (int i=0; i<3; ++i) pos_[i]=p[i]; radius(radius_);}
-int FixedStar::setParameter(string name, string content, string unit) {
- if (name=="Position") {
- double pos[3];
- if (FactoryMessenger::parseArray(content, pos, 3) != 3)
- throwError("FixedStar \"Position\" element requires exactly 3 tokens");
- setPos(pos);
- } else if (name=="Rotating") {
- rotating(true);
- } else if (name=="NonRotating") {
- rotating(false);
- } else return UniformSphere::setParameter(name, content, unit);
- return 0;
+void FixedStar::position(std::vector<double> const &v) {
+ if (v.size() !=3)
+ throwError("FixedStar position needs exactly 3 tokens");
+ for (int i=0; i<3; ++i) pos_[i]=v[i];
+ radius(radius_);
}
-#ifdef GYOTO_USE_XERCES
-void FixedStar::fillElement(FactoryMessenger *fmp) const {
- fmp -> setParameter ("Position", const_cast<double*>(pos_), 3);
- fmp -> setParameter (rotating_?"Rotating":"NonRotating");
- UniformSphere::fillElement(fmp);
+std::vector<double> FixedStar::position() const {
+ std::vector<double> res(3, 0.);
+ for (int i=0; i<3; ++i) res[i]=pos_[i];
+ return res;
}
-#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git
More information about the Debian-astro-commits
mailing list