/src/OpenFOAM/primitives/septernion/septernion.C

https://github.com/xyuan/OpenFOAM-1.7.x · C · 83 lines · 31 code · 20 blank · 32 comment · 0 complexity · 948566a8334e0af2ab07bd8e20e7092e MD5 · raw file

  1. /*---------------------------------------------------------------------------*\
  2. ========= |
  3. \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
  4. \\ / O peration |
  5. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
  6. \\/ M anipulation |
  7. -------------------------------------------------------------------------------
  8. License
  9. This file is part of OpenFOAM.
  10. OpenFOAM is free software: you can redistribute it and/or modify it
  11. under the terms of the GNU General Public License as published by
  12. the Free Software Foundation, either version 3 of the License, or
  13. (at your option) any later version.
  14. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
  15. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
  20. \*---------------------------------------------------------------------------*/
  21. #include "septernion.H"
  22. #include "IOstreams.H"
  23. #include "OStringStream.H"
  24. // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
  25. const char* const Foam::septernion::typeName = "septernion";
  26. const Foam::septernion Foam::septernion::zero(vector::zero, quaternion::zero);
  27. const Foam::septernion Foam::septernion::I(vector::zero, quaternion::I);
  28. // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
  29. Foam::septernion::septernion(Istream& is)
  30. {
  31. is >> *this;
  32. }
  33. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  34. Foam::word Foam::name(const septernion& s)
  35. {
  36. OStringStream buf;
  37. buf << '(' << s.t() << ',' << s.r() << ')';
  38. return buf.str();
  39. }
  40. // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
  41. Foam::Istream& Foam::operator>>(Istream& is, septernion& s)
  42. {
  43. // Read beginning of septernion
  44. is.readBegin("septernion");
  45. is >> s.t() >> s.r();
  46. // Read end of septernion
  47. is.readEnd("septernion");
  48. // Check state of Istream
  49. is.check("operator>>(Istream&, septernion&)");
  50. return is;
  51. }
  52. Foam::Ostream& Foam::operator<<(Ostream& os, const septernion& s)
  53. {
  54. os << token::BEGIN_LIST
  55. << s.t() << token::SPACE << s.r()
  56. << token::END_LIST;
  57. return os;
  58. }
  59. // ************************************************************************* //