OpenStructure
surface_handle.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_SURFACE_HANDLE_HL
20 #define OST_SURFACE_HANDLE_HL
21 
22 #include <vector>
23 
24 #include <ost/mol/surface_prop.hh>
26 
27 namespace ost { namespace mol {
28 
29 class SurfaceHandle;
30 class EntityView;
31 
32 // Create a non-managed surface
33 DLLEXPORT_OST_MOL SurfaceHandle CreateSurface();
34 
35 typedef std::vector<SurfaceTriID> SurfaceTriIDList;
36 typedef std::vector<SurfaceVertexID> SurfaceVertexIDList;
37 
38 // molecular surface
40 public:
41  // creates invalid handle
42  SurfaceHandle();
43 
44  // internally used ctor
46 
47  // associate each vertex with the closest atom from the given entity,
48  // but only if an atom is actually within 'cutoff' distance
49  void Attach(const EntityHandle& eh, Real cutoff);
50 
51  // dito for view
52  void Attach(const EntityView& ev, Real cutoff);
53 
54  SurfaceVertexList FindWithin(const geom::Vec3&, Real dist) const;
55 
56  // returns unique id
57  SurfaceVertexID AddVertex(const SurfaceVertex& v);
58 
59  // retrieve vertex based on id
60  SurfaceVertex GetVertex(SurfaceVertexID id) const;
61 
62  // assigns face based on id
64 
65  SurfaceTri GetTri(SurfaceTriID id) const;
66 
67  SurfaceVertexIDList GetVertexIDList() const;
68  SurfaceTriIDList GetTriIDList() const;
69 
70  // flip normals
71  void Invert();
72 
73  bool IsValid() const {return impl_;}
74 
75  bool operator==(const SurfaceHandle& ref) const { return impl_==ref.impl_; }
76 
77  bool operator!=(const SurfaceHandle& ref) const { return !this->operator==(ref); }
78 
79 private:
80  impl::SurfaceImplP impl_;
81 
82 };
83 
84 DLLEXPORT_OST_MOL std::ostream& operator<<(std::ostream& os,
85  const SurfaceHandle& surf);
86 
87 typedef std::vector<SurfaceHandle> SurfaceHandleList;
88 
89 }} // ns
90 
91 #endif