source: tags/release-1.1.5/src/PixelMap/Voxel.cc @ 1441

Last change on this file since 1441 was 418, checked in by MatthewWhiting, 16 years ago

A range of changes from CONRAD development:

  • Improved output for Object3D & Scan, and ordering for Object3D
  • == and match function for Voxel, implemented in Detection functions
  • Additional WCS & flux calculations for Cube using vectors of Voxels
  • Fixed setupColumns, removing the extra call to calcObjWCSparams.
  • New function prepareLogFile to wrap up the code to start a log file. Implemented in mainDuchamp.
File size: 3.8 KB
Line 
1// -----------------------------------------------------------------------
2// Voxel.cc: Member functions for the Voxel class.
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#include <iostream>
29#include <iomanip>
30#include <duchamp/PixelMap/Voxel.hh>
31
32namespace PixelInfo
33{
34
35  Voxel::Voxel(long x, long y, long z, float f)
36  {
37    this->itsX=x;
38    this->itsY=y;
39    this->itsZ=z;
40    this->itsF=f;
41  }
42  //--------------------------------------------------------------------
43
44  Voxel::Voxel(const Voxel& v)
45  {
46    operator=(v);
47  }
48  //--------------------------------------------------------------------
49
50  Voxel& Voxel::operator= (const Voxel& v)
51  {
52    if(this == &v) return *this;
53    this->itsX=v.itsX;
54    this->itsY=v.itsY;
55    this->itsZ=v.itsZ;
56    this->itsF=v.itsF;
57    return *this;
58  }
59  //--------------------------------------------------------------------
60
61  std::ostream& operator<< ( std::ostream& theStream, Voxel& vox)
62  {
63    /**
64     * A convenient way of printing the coordinate and flux values of
65     * a voxel.  They are all printed to a single line (with no
66     * carriage-return), with the flux to precision of 4.
67     */ 
68
69    theStream << std::setw(4) << vox.itsX ;
70    theStream << " " << std::setw(4) << vox.itsY;
71    theStream << " " << std::setw(4) << vox.itsZ;
72    theStream << std::setprecision(4);
73    theStream << "  " << vox.itsF;
74    return theStream;
75
76  }
77  //------------------------------------------------------
78
79  bool operator== (Voxel lhs, Voxel rhs)
80  {
81    /**
82     * For two voxels to be equal, all four parameters must be equal.
83     */
84    return (lhs.itsX == rhs.itsX) &&
85      (lhs.itsY == rhs.itsY) &&
86      (lhs.itsZ == rhs.itsZ) &&
87      (lhs.itsF == rhs.itsF);
88  }
89  //------------------------------------------------------
90
91  bool Voxel::match(Voxel other)
92  {
93    /**
94     * This function just tests for equality of position. The flux is ignored.
95     */
96    return (this->itsX == other.itsX) &&
97      (this->itsY == other.itsY) &&
98      (this->itsZ == other.itsZ);
99  }
100  //--------------------------------------------------------------------
101  //--------------------------------------------------------------------
102
103  Pixel::Pixel(long x, long y, float f)
104  {
105    this->itsX=x;
106    this->itsY=y;
107    this->itsF=f;
108  }
109  //--------------------------------------------------------------------
110
111  Pixel::Pixel(const Pixel& p)
112  {
113    operator=(p);
114  }
115  //--------------------------------------------------------------------
116
117  Pixel& Pixel::operator= (const Pixel& p)
118  {
119    if(this == &p) return *this;
120    this->itsX=p.itsX;
121    this->itsY=p.itsY;
122    this->itsF=p.itsF;
123    return *this;
124  }
125  //--------------------------------------------------------------------
126
127}
Note: See TracBrowser for help on using the repository browser.