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 OST_SURFACE_HANDLE_HL 00020 #define OST_SURFACE_HANDLE_HL 00021 00022 #include <vector> 00023 00024 #include <ost/mol/surface_prop.hh> 00025 #include <ost/mol/impl/surface_impl_fw.hh> 00026 00027 namespace ost { namespace mol { 00028 00029 class SurfaceHandle; 00030 class EntityView; 00031 00032 // Create a non-managed surface 00033 DLLEXPORT_OST_MOL SurfaceHandle CreateSurface(); 00034 00035 typedef std::vector<SurfaceTriID> SurfaceTriIDList; 00036 typedef std::vector<SurfaceVertexID> SurfaceVertexIDList; 00037 00038 // molecular surface 00039 class DLLEXPORT_OST_MOL SurfaceHandle { 00040 public: 00041 // creates invalid handle 00042 SurfaceHandle(); 00043 00044 // internally used ctor 00045 SurfaceHandle(const impl::SurfaceImplP& p); 00046 00047 // associate each vertex with the closest atom from the given entity, 00048 // but only if an atom is actually within 'cutoff' distance 00049 void Attach(const EntityHandle& eh, Real cutoff); 00050 00051 // dito for view 00052 void Attach(const EntityView& ev, Real cutoff); 00053 00054 SurfaceVertexList FindWithin(const geom::Vec3&, Real dist) const; 00055 00056 // returns unique id 00057 SurfaceVertexID AddVertex(const SurfaceVertex& v); 00058 00059 // retrieve vertex based on id 00060 SurfaceVertex GetVertex(SurfaceVertexID id) const; 00061 00062 // assigns face based on id 00063 SurfaceTriID AddTri(SurfaceVertexID v0, SurfaceVertexID v1, SurfaceVertexID v2); 00064 00065 SurfaceTri GetTri(SurfaceTriID id) const; 00066 00067 SurfaceVertexIDList GetVertexIDList() const; 00068 SurfaceTriIDList GetTriIDList() const; 00069 00070 // flip normals 00071 void Invert(); 00072 00073 bool IsValid() const {return impl_;} 00074 00075 bool operator==(const SurfaceHandle& ref) const { return impl_==ref.impl_; } 00076 00077 bool operator!=(const SurfaceHandle& ref) const { return !this->operator==(ref); } 00078 00079 private: 00080 impl::SurfaceImplP impl_; 00081 00082 }; 00083 00084 DLLEXPORT_OST_MOL std::ostream& operator<<(std::ostream& os, 00085 const SurfaceHandle& surf); 00086 00087 typedef std::vector<SurfaceHandle> SurfaceHandleList; 00088 00089 }} // ns 00090 00091 #endif