00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: Object.hpp,v 1.8 2007/05/20 23:02:48 delpinux Exp $ 00019 00020 // This class is defined to allow the use of Objects. Objects are 00021 // made of Shapes which have caracteristics like Boundary Conditions, ... 00022 00023 #ifndef OBJECT_HPP 00024 #define OBJECT_HPP 00025 00026 #include <Shape.hpp> 00027 #include <ReferenceCounting.hpp> 00028 00037 class Object 00038 { 00039 private: 00040 ConstReferenceCounting<Shape> 00041 __shape; 00043 bool __hasReference; 00045 TinyVector<3,real_t> 00046 __reference; 00048 public: 00057 friend std::ostream& operator << (std::ostream& os, 00058 const Object& o) 00059 { 00060 os << (*o.__shape) << '\n'; 00061 return os; 00062 } 00063 00069 const bool& hasReference() const 00070 { 00071 return __hasReference; 00072 } 00073 00079 const TinyVector<3>& reference() const 00080 { 00081 ASSERT(__hasReference); 00082 return __reference; 00083 } 00084 00090 ConstReferenceCounting<Shape> shape() const 00091 { 00092 ASSERT(__shape != 0); 00093 return __shape; 00094 } 00095 00103 bool inside(const TinyVector<3, real_t>& x) const 00104 { 00105 return __shape->inside(x); 00106 } 00107 00113 void setReference(const TinyVector<3, real_t>& aReference) 00114 { 00115 ASSERT(__hasReference == false); 00116 __hasReference = true; 00117 __reference = aReference; 00118 } 00119 00125 ReferenceCounting<Object> getCopy() const 00126 { 00127 return new Object(*this); 00128 } 00129 00135 Object(ConstReferenceCounting<Shape> s) 00136 : __shape(s), 00137 __hasReference(false), 00138 __reference(0) 00139 { 00140 ; 00141 } 00142 00148 Object(const Object& o) 00149 : __shape(o.__shape->getCopy()), 00150 __hasReference(o.__hasReference), 00151 __reference(o.__reference) 00152 { 00153 ; 00154 } 00155 00160 ~Object() 00161 { 00162 ; 00163 } 00164 }; 00165 00166 #endif // OBJECT_HPP
1.5.6