00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_ENTITY_DETAIL_HH
00020 #define OST_GFX_ENTITY_DETAIL_HH
00021
00022 #include <map>
00023 #include <vector>
00024
00025 #include <boost/shared_ptr.hpp>
00026
00027 #include <ost/geom/geom.hh>
00028
00029 #include <ost/mol/mol.hh>
00030 #include <ost/mol/entity_view.hh>
00031 #include <ost/mol/query.hh>
00032
00033 #include <ost/gfx/module_config.hh>
00034 #include <ost/gfx/color.hh>
00035 #include <ost/gfx/gfx.hh>
00036 #include <ost/gfx/gfx_prim.hh>
00037 #include <ost/gfx/entity_fw.hh>
00038
00039
00040 namespace ost { namespace gfx { namespace impl {
00041
00042 struct DLLEXPORT_OST_GFX AtomEntry
00043 {
00044 AtomEntry() {}
00045 AtomEntry(const mol::AtomHandle& a, float r, float v, const Color& c):
00046 atom(a),color(c),radius(r), vdwr(v) {}
00047 mol::AtomHandle atom;
00048 Color color;
00049 float radius;
00050 float vdwr;
00051 };
00052
00053
00054 typedef std::map<long, AtomEntry> AtomEntryMap;
00055 typedef std::vector<AtomEntry> AtomEntryList;
00056
00057 struct DLLEXPORT_OST_GFX BondEntry
00058 {
00059 BondEntry(const mol::BondHandle& b, float r,AtomEntry* ae1, AtomEntry* ae2):
00060 bond(b),atom1(ae1),atom2(ae2),radius(r),
00061 pp1(ae1 ? ae1->atom.GetPos() : geom::Vec3()),
00062 pp2(ae2 ? ae2->atom.GetPos() : geom::Vec3())
00063 {}
00064 mol::BondHandle bond;
00065 AtomEntry* atom1;
00066 AtomEntry* atom2;
00067 float radius;
00068 geom::Vec3 pp1,pp2;
00069 };
00070
00071 typedef std::vector<BondEntry> BondEntryList;
00072
00073 class DLLEXPORT_OST_GFX GfxView {
00074 public:
00075 void Clear();
00076 void AddAtom(const mol::AtomView& av);
00077 void AddBond(const mol::BondHandle& bv);
00078
00079 AtomEntryMap atom_map;
00080 BondEntryList bond_list;
00081 std::vector<long> orphan_atom_list;
00082 };
00083
00084 typedef boost::shared_ptr<GfxView> GfxViewPtr;
00085
00086 struct DLLEXPORT_OST_GFX NodeEntry {
00087 mol::AtomHandle atom;
00088 Color color1, color2;
00089 geom::Vec3 direction,normal;
00090 float rad;
00091 geom::Vec3 v0,v1,v2;
00092 bool nflip;
00093 };
00094
00095 typedef std::vector<NodeEntry> NodeEntryList;
00096 typedef std::vector<NodeEntryList> NodeEntryListList;
00097 typedef boost::shared_ptr<NodeEntryListList> NodeEntryListListPtr;
00098
00099 struct DLLEXPORT_OST_GFX TraceProfileEntry {
00100 TraceProfileEntry(): v(), n(), id(0) {}
00101 TraceProfileEntry(const geom::Vec3& v_,
00102 const geom::Vec3& n_): v(v_),n(n_),id(0) {}
00103 geom::Vec3 v;
00104 geom::Vec3 n;
00105 VertexID id;
00106 };
00107
00108 typedef std::vector<TraceProfileEntry> TraceProfile;
00109
00110 struct DLLEXPORT_OST_GFX SplineEntry {
00111 SplineEntry():
00112 position(0.0,0.0,0.0),
00113 direction(0.0,0.0,1.0),
00114 normal(0.0,1.0,0.0),
00115 color1(1.0,1.0,1.0,1.0),
00116 color2(1.0,1.0,1.0,1.0),
00117 rad(1.0),
00118 type(0)
00119 {
00120 }
00121 SplineEntry(const geom::Vec3& p,
00122 const geom::Vec3& d,
00123 const geom::Vec3& n,
00124 float r,
00125 const Color& c1, const Color& c2,
00126 int t):
00127 position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
00128 type1(t),type2(t),frac(0.0),v0(),v1(),v2(),nflip(false)
00129 {
00130 }
00131
00132 void ToQuat();
00133
00134 void FromQuat();
00135
00136 geom::Vec3 position,direction,normal;
00137 Color color1, color2;
00138 float quat_value[4];
00139 float rad;
00140 int type;
00141 int type1, type2;
00142 float frac;
00143 geom::Vec3 v0,v1,v2;
00144 bool nflip;
00145 };
00146
00147 typedef std::vector<SplineEntry> SplineEntryList;
00148 typedef std::vector<SplineEntryList> SplineEntryListList;
00149
00150 class DLLEXPORT_OST_GFX Spline {
00151 public:
00152
00153 public:
00154
00155 Spline();
00156
00157
00158 SplineEntry& AddEntry(const geom::Vec3& pos, const geom::Vec3& dir,
00159 const geom::Vec3& normal, float r, const Color& col1,
00160 const Color& col2, int type);
00161
00162 SplineEntryList Generate(int nsub) const;
00163
00164 private:
00165 SplineEntryList entry_list_;
00166 };
00167
00168 }}}
00169
00170
00171 #endif