00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 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 FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef GEOM_POINT_CLOUD_H 00020 #define GEOM_POINT_CLOUD_H 00021 00022 #include <vector> 00023 #include <map> 00024 #include <string> 00025 00026 #include <boost/shared_ptr.hpp> 00027 00028 #include "vec3.hh" 00029 00030 namespace geom { 00031 00032 /* 00033 the pointcloud and its manager are meant to provide 00034 name-based lookup for the selection mechanism. They are 00035 defined here in abstract terms, and are then used in e.g. 00036 the gfx modules - a graphical object ISA point cloud, and 00037 the gfx object manager ISA point cloud manager. This way 00038 named graphical objects can be used in a selection statement, 00039 when the query is receiving a pointer to a point cloud manager. 00040 */ 00041 00042 class PointCloud 00043 { 00044 public: 00045 virtual ~PointCloud(); 00046 virtual std::vector<Vec3> GetPoints() const; 00047 virtual Vec3 GetCenter() const; 00048 virtual Real GetRadius() const; 00049 00050 protected: 00051 00052 void AddPoint(const Vec3& v); 00053 00054 00055 private: 00056 00057 std::vector<Vec3> point_list_; 00058 }; 00059 00060 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00061 00062 00063 class PointCloudManager 00064 { 00065 public: 00066 virtual ~PointCloudManager(); 00067 00068 PointCloudPtr GetPointCloud(const std::string& name); 00069 00070 protected: 00071 void AddPointCloud(const std::string& name, const PointCloudPtr& p); 00072 00073 private: 00074 std::map<std::string, PointCloudPtr> pmap_; 00075 }; 00076 00077 00078 } // ns 00079 00080 #endif