00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 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_GFX_IMPL_BACKBONE_TRACE_HH 00020 #define OST_GFX_IMPL_BACKBONE_TRACE_HH 00021 00022 /* 00023 Authors: Ansgar Philippsen, Marco Biasini 00024 */ 00025 00026 #include <ost/mol/mol.hh> 00027 00028 #include <ost/gfx/module_config.hh> 00029 #include <ost/gfx/impl/entity_detail.hh> 00030 00031 namespace ost { namespace gfx { namespace impl { 00032 00033 class BackboneTraceBuilder; 00034 00040 class DLLEXPORT_OST_GFX BackboneTrace { 00041 public: 00042 00043 BackboneTrace(const mol::EntityView& ent); 00044 BackboneTrace(); 00045 00046 int GetListCount() const; 00047 00048 const NodeEntryList& GetList(int index) const; 00049 NodeEntryList& GetList(int index); 00050 00051 void SetView(const mol::EntityView& ent); 00052 00053 // used internally 00054 void AddNodeList(const NodeEntryList& entries); 00055 00056 void Rebuild(); 00057 00058 private: 00059 mol::EntityView view_; 00060 NodeEntryListList node_list_list_; 00061 }; 00062 00065 class DLLEXPORT_OST_GFX NodeListSubset { 00066 public: 00067 friend class TraceSubset; 00068 00069 NodeListSubset(BackboneTrace& trace, int index); 00070 00071 int GetSize() const 00072 { 00073 return indices_.size(); 00074 } 00075 int AtStart() const 00076 { 00077 return at_start_; 00078 } 00079 00080 int AtEnd() const 00081 { 00082 return at_end_; 00083 } 00084 const NodeEntry& operator [](int index) const 00085 { 00086 assert(index>=0 && index<static_cast<int>(indices_.size())); 00087 return trace_.GetList(list_index_)[indices_[index]]; 00088 } 00089 NodeEntry& operator [](int index) 00090 { 00091 assert(index>=0 && index<static_cast<int>(indices_.size())); 00092 return trace_.GetList(list_index_)[indices_[index]]; 00093 } 00094 NodeListSubset& operator=(const NodeListSubset& rhs); 00095 private: 00096 BackboneTrace& trace_; 00097 int list_index_; 00098 protected: 00099 std::vector<int> indices_; 00100 int at_start_; 00101 int at_end_; 00102 }; 00103 00105 class DLLEXPORT_OST_GFX TraceSubset { 00106 public: 00107 TraceSubset(BackboneTrace& trace, const mol::EntityView& view, int n); 00108 TraceSubset(BackboneTrace& trace, int n); 00109 00110 const NodeListSubset& operator[](int index) const 00111 { 00112 return lists_[index]; 00113 } 00114 00115 NodeListSubset& operator[](int index) 00116 { 00117 return lists_[index]; 00118 } 00119 00120 int GetSize() const 00121 { 00122 return lists_.size(); 00123 } 00124 void SetOvershoot(int n) { overshoot_=n; } 00125 int GetOvershoot() const { return overshoot_; } 00126 TraceSubset& operator=(const TraceSubset& rhs); 00127 void Update(const mol::EntityView& view); 00128 private: 00129 void NodeListStart(NodeListSubset& nl, int c); 00130 void NodeListEnd(NodeListSubset& nl, int c, int s); 00131 BackboneTrace& trace_; 00132 std::vector<NodeListSubset> lists_; 00133 int overshoot_; 00134 }; 00135 00136 }}} 00137 00138 #endif
1.5.8