00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003, 2004 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: ObjectTransformer.cpp,v 1.5 2007/05/20 23:02:48 delpinux Exp $ 00019 00020 #include <ObjectTransformer.hpp> 00021 #include <Object.hpp> 00022 00023 #include <Sphere.hpp> 00024 #include <Cylinder.hpp> 00025 #include <Cone.hpp> 00026 #include <Cube.hpp> 00027 #include <Plane.hpp> 00028 #include <Torus.hpp> 00029 00030 #include <Union.hpp> 00031 #include <Difference.hpp> 00032 #include <Intersection.hpp> 00033 #include <Not.hpp> 00034 00035 #include <InfiniteCylinder.hpp> 00036 #include <InfiniteCone.hpp> 00037 00038 ReferenceCounting<Object> 00039 ObjectTransformer::operator()(const Object& o) const 00040 { 00041 const Shape& s = *o.shape(); 00042 ReferenceCounting<Shape> newShape = o.shape()->getCopy(); 00043 00044 Shape::TransformationsList transformations(__addedTransformations.size() 00045 + s.transformationsList().size()); 00046 00047 for (size_t i=0; i<s.transformationsList().size(); ++i) { 00048 transformations[i+__addedTransformations.size()] 00049 = s.transformationsList()[i]; 00050 } 00051 for (size_t i=0; i<__addedTransformations.size(); ++i) { 00052 transformations[i] = __addedTransformations[i]; 00053 } 00054 ASSERT(newShape != 0); 00055 00056 newShape->setTransformationsList(transformations); 00057 Object* newObject = new Object(newShape); 00058 00059 // Copies references if needed 00060 if (o.hasReference()) { 00061 newObject->setReference(o.reference()); 00062 } 00063 00064 return newObject; 00065 }
1.5.6