00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2003 Pascal Havé 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: Domain.cpp,v 1.5 2006/11/02 15:41:25 delpinux Exp $ 00019 00020 #include <Domain.hpp> 00021 00022 #include <Scene.hpp> 00023 00024 #include <Union.hpp> 00025 #include <Intersection.hpp> 00026 #include <Difference.hpp> 00027 #include <Not.hpp> 00028 00029 Domain:: 00030 Domain(ConstReferenceCounting<Scene> scene) 00031 : __isR3(true), 00032 __objects(0), 00033 __scene(scene) 00034 { 00035 ; 00036 } 00037 00038 Domain:: 00039 Domain(const Domain& D) 00040 : __isR3(D.__isR3), 00041 __objects(D.__objects), 00042 __scene(D.__scene) 00043 { 00044 ; 00045 } 00046 00047 Domain:: 00048 ~Domain() 00049 { 00050 ; 00051 } 00052 00053 ConstReferenceCounting<Scene> Domain:: 00054 scene() const 00055 { 00056 return __scene; 00057 } 00058 00059 void Domain::__buildReferenceAssociation(const Object& o) 00060 { 00061 if (o.hasReference()) { 00062 const TinyVector<3, real_t>& ref = o.reference(); 00063 if (__povToReference.find(ref) == __povToReference.end()) { 00064 const size_t n = __povToReference.size() + 1; 00065 __povToReference[ref] = n; 00066 ffout(2) << "\t\t" << ref << " -> " << n << '\n'; 00067 } 00068 } 00069 00070 const Shape& shape = (*o.shape()); 00071 00072 switch(shape.type()) { 00073 case Shape::union_: { 00074 const Union& U = static_cast<const Union&>(shape); 00075 00076 for (Union::const_iterator i = U.begin(); 00077 i != U.end(); ++i) { 00078 __buildReferenceAssociation(*(*i)); 00079 } 00080 break; 00081 } 00082 case Shape::difference: { 00083 const Difference& D = static_cast<const Difference&>(shape); 00084 00085 for (Difference::const_iterator i = D.begin(); 00086 i != D.end(); ++i) { 00087 __buildReferenceAssociation(*(*i)); 00088 } 00089 break; 00090 } 00091 case Shape::intersection: { 00092 const Intersection& I = static_cast<const Intersection&>(shape); 00093 00094 for (Intersection::const_iterator i = I.begin(); 00095 i != I.end(); ++i) { 00096 __buildReferenceAssociation(*(*i)); 00097 } 00098 break; 00099 } 00100 case Shape::not_: { 00101 const Object& notObject = *(static_cast<const Not&>(shape).object()); 00102 __buildReferenceAssociation(notObject); 00103 break; 00104 } 00105 default: { 00106 ; 00107 } 00108 } 00109 }
1.5.6