00001 //# LCDifference.h: Make the difference of 2 regions 00002 //# Copyright (C) 1998 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef LATTICES_LCDIFFERENCE_H 00029 #define LATTICES_LCDIFFERENCE_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/lattices/LRegions/LCRegionMulti.h> 00034 00035 00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00037 00038 // <summary> 00039 // Make the difference of 2 regions. 00040 // </summary> 00041 00042 // <use visibility=export> 00043 00044 // <reviewed reviewer="" date="" tests=""> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 // <li> <linkto class=LCRegion>LCRegion</linkto> 00049 // </prerequisite> 00050 00051 // <synopsis> 00052 // The LCDifference class is a specialization of class 00053 // <linkto class=LCRegion>LCRegion</linkto>. 00054 // It makes it possible to "subtract" one region from 00055 // another. For example, imagine an overlapping box 00056 // and circle. The box - circle is the box with the 00057 // chunk taken out of it where the circle overlaps. 00058 // The circle - box is the circle with the chunk 00059 // taken out of it where the box overlaps. 00060 // <p> 00061 // The center of the difference must be inside the lattice 00062 // </synopsis> 00063 00064 // <example> 00065 // <srcblock> 00066 // </srcblock> 00067 // </example> 00068 00069 // <todo asof="1997/11/11"> 00070 // </todo> 00071 00072 class LCDifference: public LCRegionMulti 00073 { 00074 public: 00075 LCDifference(); 00076 00077 // Construct the difference region1 - region2. 00078 LCDifference (const LCRegion& region1, const LCRegion& region2); 00079 00080 // Construct from multiple regions given as a Block. 00081 // When <src>takeOver</src> is True, the destructor will delete the 00082 // given regions. Otherwise a copy of the regions is made. 00083 LCDifference (Bool takeOver, const PtrBlock<const LCRegion*>& regions); 00084 00085 // Copy constructor (copy semantics). 00086 LCDifference (const LCDifference& other); 00087 00088 virtual ~LCDifference(); 00089 00090 // Assignment (copy semantics). 00091 LCDifference& operator= (const LCDifference& other); 00092 00093 // Comparison 00094 virtual Bool operator== (const LCRegion& other) const; 00095 00096 // Make a copy of the derived object. 00097 virtual LCRegion* cloneRegion() const; 00098 00099 // Get the class name (to store in the record). 00100 static String className(); 00101 00102 // Get the region type. Returns className() 00103 virtual String type() const; 00104 00105 // Convert the (derived) object to a record. 00106 virtual TableRecord toRecord (const String& tableName) const; 00107 00108 // Convert correct object from a record. 00109 static LCDifference* fromRecord (const TableRecord&, 00110 const String& tableName); 00111 00112 protected: 00113 // Construct another LCRegion (for e.g. another lattice) by moving 00114 // this one. It recalculates the bounding box and mask. 00115 // A positive translation value indicates "to right". 00116 virtual LCRegion* doTranslate (const Vector<Float>& translateVector, 00117 const IPosition& newLatticeShape) const; 00118 00119 // Do the actual getting of the mask. 00120 virtual void multiGetSlice (Array<Bool>& buffer, const Slicer& section); 00121 00122 private: 00123 // Make the bounding box and determine the offsets. 00124 void defineBox(); 00125 }; 00126 00127 00128 00129 } //# NAMESPACE CASACORE - END 00130 00131 #endif