Skip to content
Snippets Groups Projects
Commit ec670ac1 authored by ansgar's avatar ansgar
Browse files

removed rsurf from trunk

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2201 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 40eeab9c
No related branches found
No related tags found
No related merge requests found
Showing
with 11 additions and 1553 deletions
scene.SetFog(False)
eh = io.LoadEntity("sdh.pdb")
ev = eh.Select("cname=A")
ec=gfx.Entity("p",ev)
ec.SetRenderMode(gfx.CPK)
scene.Add(ec)
scene.SetCenter(ec.GetCenter())
ec.Hide()
s = mol.BuildSurface(ev,1.5,15.0/57.3)
gs=gfx.Surface("s",s)
scene.Add(gs)
# for debug reasons
rs=mol.RSurf(1.5)
for a in ev.GetAtomList():
rs.AddSphere(a.GetPos(),a.GetRadius(),str(a))
rs.Build()
rs.Triangulate(60.0*3.1415/180.0)
gr=gfx.RSurface("r",rs)
scene.Add(gr)
gr.Hide()
......@@ -122,8 +122,4 @@ void export_Surface()
.def("CleanColorOps", &Surface::CleanColorOps)
.def("ReapplyColorOps", &Surface::ReapplyColorOps)
;
class_<RSurface, bases<GfxObj>, RSurfaceP, boost::noncopyable>("RSurface", init<const String&, const mol::rsurf::RSurfP&>())
;
}
......@@ -360,169 +360,4 @@ void Surface::ReapplyColorOps(){
GfxObj::ReapplyColorOps();
}
// rsurf stuff
using namespace mol::rsurf;
RSurface::RSurface(const String& name, const RSurfP& rs):
GfxObj(name),
rs_(rs)
{
ArcList alist = rs->GetArcList();
TetList tlist = rs->GetTetList();
SphereList slist = rs->GetSphereList();
#if 0
for(TetList::const_iterator it=tlist.begin();it!=tlist.end();++it) {
VertexID id1 = va_.Add((*it)->A->pos,Vec3(),Color(1,1,1));
VertexID id2 = va_.Add((*it)->B->pos,Vec3(),Color(1,1,1));
VertexID id3 = va_.Add((*it)->C->pos,Vec3(),Color(1,1,1));
VertexID id4 = va_.Add((*it)->cA,Vec3(),Color(0,1,0));
VertexID id5 = va_.Add((*it)->cB,Vec3(),Color(0,1,0));
VertexID id6 = va_.Add((*it)->cC,Vec3(),Color(0,1,0));
va_.AddLine(id1,id4);
va_.AddLine(id2,id5);
va_.AddLine(id3,id6);
va_.AddLine(id4,id5);
va_.AddLine(id5,id6);
va_.AddLine(id6,id4);
}
#endif
#if 0
for(ArcList::const_iterator it=alist.begin();it!=alist.end();++it) {
Arc& arc= *(*it);
if(arc.S && arc.T) {
VertexID id0 = va_.Add(arc.S->pos,Vec3(),Color(1,0,0));
VertexID id1 = va_.Add(arc.mid,Vec3(),Color(1,1,1));
VertexID id2 = va_.Add(arc.T->pos,Vec3(),Color(1,0,1));
VertexID id3 = va_.Add(arc.H->pos,Vec3(),Color(1,1,1));
VertexID id4 = va_.Add(arc.K->pos,Vec3(),Color(1,1,1));
va_.AddLine(id0,id1);
va_.AddLine(id1,id2);
va_.AddLine(id1,id3);
va_.AddLine(id1,id4);
}
}
#endif
for(SphereList::const_iterator it=slist.begin();it!=slist.end();++it) {
for(uint l=0;l<(*it)->arc_list_list.size();++l) {
const Sphere& sp = *(*it);
const ArcDirDeque& alist=sp.arc_list_list[l];
if(alist.empty()) continue;
if(alist.size()<4) continue;
Vec3 a0 = alist[0].inv_arc ? -alist[0].arc->axis : alist[0].arc->axis;
Vec3 a1 = alist[1].inv_arc ? -alist[1].arc->axis : alist[1].arc->axis;
Vec3 s0 = alist[0].inv_arc ? alist[0].arc->T->pos : alist[0].arc->S->pos;
Vec3 s1 = alist[1].inv_arc ? alist[1].arc->T->pos : alist[1].arc->S->pos;
Vec3 p0 = sp.pos+sp.rad*(s0-sp.pos)/((sp.rad+alist[0].arc->S->rad));
Vec3 p1 = sp.pos+sp.rad*(s1-sp.pos)/((sp.rad+alist[1].arc->S->rad));
VertexID id00 = va_.Add(p0,Vec3(),Color(1,1,1));
VertexID id10 = va_.Add(p1,Vec3(),Color(1,1,1));
VertexID id20 = id00;
for(float c=0.0;c<=1.0;c+=0.1) {
Mat3 r0 = AxisRotation(a0,c*alist[0].arc->phi);
Mat3 r1 = AxisRotation(a1,c*alist[1].arc->phi);
Vec3 v0 = r0*(p0-alist[0].arc->fixpoint)+alist[0].arc->fixpoint;
Vec3 v1 = r1*(p1-alist[1].arc->fixpoint)+alist[1].arc->fixpoint;
Vec3 v2 = r1*(v0-alist[1].arc->fixpoint)+alist[1].arc->fixpoint;
VertexID id01 = va_.Add(v0,Vec3(),Color(1,1,1));
VertexID id11 = va_.Add(v1,Vec3(),Color(1,1,1));
VertexID id21 = va_.Add(v2,Vec3(),Color(1,c,0));
va_.AddLine(id00,id01);
va_.AddLine(id10,id11);
va_.AddLine(id20,id21);
id00=id01;
id10=id11;
id20=id21;
}
#if 0
Vec3 sum1;
Vec3 sum2;
Vec3 sum3;
Vec3 prev;
float plan=0.0;
for(uint i=0;i<alist.size();++i) {
uint j = (i-1+alist.size())%alist.size();
uint k = (i+1)%alist.size();
sum1+=(alist[i].arc->mid-sp.pos)*alist[i].arc->phi;
Vec3 d0 = alist[i].arc->S->pos-sp.pos;
Vec3 d1 = alist[i].arc->mid-sp.pos;
Vec3 d2 = alist[i].arc->T->pos-sp.pos;
Vec3 p0 = sp.pos+sp.rad*(d0)/(sp.rad+alist[i].arc->S->rad);
Vec3 p1 = sp.pos+sp.rad*(d1)/(sp.rad+alist[i].arc->S->rad);
Vec3 p2 = sp.pos+sp.rad*(d2)/(sp.rad+alist[i].arc->S->rad);
Vec3 c0 = Normalize(Cross(Normalize(alist[i].w.pos-alist[i].v.pos),
Normalize(alist[k].w.pos-alist[k].v.pos))+
Cross(Normalize(alist[j].w.pos-alist[j].v.pos),
Normalize(alist[i].w.pos-alist[i].v.pos)));
Vec3 c1 = Normalize(Cross(Normalize(p0-p1),Normalize(p2-p1)));
if(i>0) {
plan+=Dot(prev,Normalize(d1));
}
prev=Normalize(d1);
sum2+=c0*alist[i].arc->phi;
VertexID id0 = va_.Add(p0,Vec3(),Color(1,1,0));
VertexID id1 = va_.Add(p1,Vec3(),Color(1,1,1));
VertexID id2 = va_.Add(p2,Vec3(),Color(1,1,0));
VertexID id3 = va_.Add(sp.pos,Vec3(),Color(1,1,1));
va_.AddLine(id0,id1);
va_.AddLine(id1,id2);
//va_.AddLine(id1,id3);
}
float f = plan/static_cast<float>(alist.size());
VertexID id8 = va_.Add(sp.pos,Vec3(),Color(1,1,1));
VertexID id9 = va_.Add(sp.pos+1.1*sp.rad*Normalize(sum1),Vec3(),Color(0,0,1));
VertexID idA = va_.Add(sp.pos+1.1*sp.rad*Normalize(sum2),Vec3(),Color(1,0,0));
VertexID idB = va_.Add(sp.pos+1.1*sp.rad*Normalize(f*sum1+(1.0-f)*sum2),Vec3(),Color(0,1,0));
va_.AddLine(id8,id9);
va_.AddLine(id8,idA);
va_.AddLine(id8,idB);
#endif
#if 0
VertexID id0 = va_.Add(sp.pos,Vec3(),Color(1,1,1));
VertexID id1 = va_.Add(sp.top_list[l],Vec3(),Color(1,1,0));
va_.AddLine(id0,id1);
#endif
}
}
va_.SetMode(0x2);
va_.SetLighting(false);
va_.SetCullFace(false);
va_.SetColorMaterial(true);
}
Vec3 RSurface::GetCenter() const
{
return Vec3(0,0,0);
}
void RSurface::CustomRenderGL(RenderPass pass)
{
if (!(pass==STANDARD_RENDER_PASS || pass==OPAQUE_RENDER_PASS))
return;
va_.RenderGL();
}
geom::AlignedCuboid RSurface::GetBoundingBox() const
{
return geom::AlignedCuboid(Vec3(-1,-1,-1), Vec3(1,1,1));
}
void RSurface::ProcessLimits(Vec3& minc, Vec3& maxc, const mol::Transform& tf) const
{
// nop
}
}} // ns
......@@ -123,24 +123,6 @@ private:
boost::ptr_vector<gfx::ColorOp> c_ops_;
};
// temporary debug
class RSurface;
typedef boost::shared_ptr<RSurface> RSurfaceP;
class DLLEXPORT_OST_GFX RSurface: public GfxObj {
public:
RSurface(const String& name, const mol::rsurf::RSurfP& rs);
virtual geom::Vec3 GetCenter() const;
virtual void CustomRenderGL(RenderPass pass);
virtual geom::AlignedCuboid GetBoundingBox() const;
virtual void ProcessLimits(geom::Vec3& minc, geom::Vec3& maxc, const mol::Transform& tf) const;
private:
mol::rsurf::RSurfP rs_;
};
}} // ns
#endif
......@@ -24,7 +24,6 @@ using namespace boost::python;
#include <ost/mol/surface_handle.hh>
#include <ost/mol/surface_builder.hh>
#include <ost/mol/entity_handle.hh>
#include <ost/mol/impl/rsurf_impl.hh>
#include <ost/mol/impl/surface_impl.hh>
using namespace ost;
......@@ -37,12 +36,6 @@ SurfaceHandle create1()
return CreateSurface();
}
void rsurf_tri_dummy(rsurf::RSurf& rs, float patch_size)
{
impl::SurfaceImplP impl(new impl::SurfaceImpl());
rs.Triangulate(impl,patch_size);
}
void (SurfaceHandle::*attach1)(const EntityHandle&,Real)=&SurfaceHandle::Attach;
void (SurfaceHandle::*attach2)(const EntityView&,Real)=&SurfaceHandle::Attach;
......@@ -74,10 +67,4 @@ void export_Surface()
def("CreateSurface",create1);
def("BuildSurface",BuildSurface);
class_<rsurf::RSurf,rsurf::RSurfP>("RSurf", init<Real>())
.def("AddSphere",&rsurf::RSurf::AddSphere)
.def("Build",&rsurf::RSurf::Build)
.def("Triangulate",rsurf_tri_dummy)
;
}
......@@ -9,7 +9,6 @@ query_ast.cc
query_impl.cc
residue_impl.cc
surface_impl.cc
rsurf_impl.cc
torsion_impl.cc
PARENT_SCOPE
)
......@@ -34,7 +33,6 @@ residue_impl.hh
residue_impl_fw.hh
surface_impl.hh
surface_impl_fw.hh
rsurf_impl.hh
torsion_impl.hh
torsion_impl_fw.hh
PARENT_SCOPE
......
This diff is collapsed.
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2010 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#ifndef OST_SURFACE_IMPL_RSURF_HH
#define OST_SURFACE_IMPL_RSURF_HH
/*
A fast reduced surface implementation to generate molecular surfaces
The concept of a reduced surface was introduced by M Sanner et al, 1984
Author: Ansgar Philippsen
*/
#include <vector>
#include <deque>
#include <boost/shared_ptr.hpp>
#include <ost/geom/geom.hh>
#include <ost/mol/spatial_organizer.hh>
#include "surface_impl_fw.hh"
#include <ost/mol/surface_prop.hh>
namespace ost { namespace mol { namespace rsurf {
// helper types for triangulation
// \internal
struct EdgePoint
{
EdgePoint(): id(0),pos() {}
EdgePoint(SurfaceVertexID i, const geom::Vec3& p, const geom::Vec3& n):
id(i), pos(p), norm(n) {}
SurfaceVertexID id;
geom::Vec3 pos,norm;
};
/// \internal
typedef std::vector<EdgePoint> EdgePointList;
// required before sphere
/// \internal
struct Arc;
/// \internal
typedef boost::shared_ptr<Arc> ArcP;
/// \internal
typedef std::vector<ArcP> ArcList;
/// \internal
struct ArcDirEntry {
EdgePointList epl;
EdgePoint v,w;
ArcP arc;
bool inv_arc;
};
/// \internal
typedef std::deque<ArcDirEntry> ArcDirDeque;
// basic sphere
struct Sphere {
Sphere(const geom::Vec3& p, Real r): pos(p), rad(r) {}
geom::Vec3 pos;
Real rad;
String name;
ArcDirDeque arc_list;
std::vector<geom::Vec3> top_list;
std::vector<ArcDirDeque> arc_list_list;
};
typedef boost::shared_ptr<Sphere> SphereP;
typedef std::vector<SphereP> SphereList;
struct Tet;
typedef boost::shared_ptr<Tet> TetP;
// arc that bridges two tets
/*
the orientation of H,K,S,T is such that the rotation of S
around the HK axis towards T is positive right handed:
S T (S is in front, T in back)
\/
K----H
i.e. for HK=Vec3(0,0,1) and S=Vec3(1,0,0), a 90deg
positive rotation results in Vec3(0,1,0)
*/
struct Arc {
Arc();
Arc(const SphereP& h, const SphereP& k, const SphereP& s);
void SetT(const SphereP& t);
SphereP H,K; // the two sphere that form the axis
SphereP S,T; // the start and end solvent sphere
geom::Vec3 axis; // normalized axis from H to K
geom::Vec3 fixpoint; // point on axis where sdir and tdir start
geom::Vec3 sdir; // direction normal from axis to S
geom::Vec3 tdir; // direction normal from axis to T
Real phi; // angle from S to T
geom::Mat3 xmat; // transformation matrix needed during traversal
geom::Vec3 mid;
EdgePointList eplS, eplT; // book-keeping for the triangulation
TetP A,B;
uint step; // sync edge stepsize for triangulation
};
// the constellation of three spheres with a locked solvent sphere
/*
when viewed with the solvent sphere in front of the abc triplet,
[ABC] are arranged clockwise
*/
struct Tet {
// use already determined sphere
Tet(const SphereP& a, const SphereP& b, const SphereP& c, const Sphere& s);
// use existing S
Tet(const SphereP& a, const SphereP& b, const SphereP& c, const SphereP& s);
ArcP GetArc(const SphereP& h, const SphereP& k);
SphereP A,B,C,S;
ArcP U,V,W;
geom::Vec3 cA,cB,cC; // contact points of S with A,B and C
bool parity_swap;
void init();
};
typedef std::vector<TetP> TetList;
// spatial organizer for optimized search
typedef SpatialOrganizer<SphereP> SpatOrg;
class DLLEXPORT_OST_MOL RSurf
{
public:
// ctor
RSurf(Real probe_radius);
void AddSphere(const geom::Vec3& pos, Real rad, const String& name);
// construct reduced surface from spheres
void Build();
// triangulate rsurf and thereby build full molecular surface
void Triangulate(impl::SurfaceImplP& surface, Real patch_size);
// return probe radius
Real GetProbeRadius() const {return probe_radius_;}
// internal use
ArcList GetArcList() const {return arc_list_;}
// internal use
TetList GetTetList() const {return tet_list_;}
// internal use
SphereList GetSphereList() const {return sphere_list_;}
private:
// main recursive routine
void traverse_arc(TetP tet, ArcP& arc, SphereP c);
// get tet from list, optionally creating it if necessary
// the solvent s is either used as a parity check, or as the new sphere
std::pair<TetP,bool> get_tet(SphereP a, SphereP b, SphereP c, const Sphere& s, bool create);
// find best tet for an arc traversal
std::pair<TetP,bool> find_best_tet(ArcP arc, SphereP c);
SphereList get_nearest_spheres(const geom::Vec3& pos, SphereP a, SphereP b);
Real calc_phi(ArcP arc, SphereP x, bool prune_zero);
SphereList sphere_list_;
ArcList arc_list_;
TetList tet_list_;
Real probe_radius_;
Real max_rad_;
SpatOrg spat_org_;
};
}}} // ns
#endif
......@@ -37,8 +37,6 @@ class DLLEXPORT_OST_MOL SurfaceImpl {
typedef std::vector<SurfaceVertex> VertexList;
typedef std::vector<SurfaceTri> FaceList;
friend class ::ost::mol::rsurf::RSurf;
public:
SurfaceImpl();
......
......@@ -28,14 +28,4 @@ typedef boost::shared_ptr<SurfaceImpl> SurfaceImplP;
}}} // ns
namespace ost { namespace mol { namespace rsurf {
/// \internal
class RSurf;
/// \internal
typedef boost::shared_ptr<RSurf> RSurfP;
}}} // ns
#endif
......@@ -21,6 +21,5 @@
#include <ost/mol/surface_handle.hh>
#include <ost/mol/impl/surface_impl.hh>
#include <ost/mol/impl/rsurf_impl.hh>
#endif
......@@ -18,10 +18,9 @@
//------------------------------------------------------------------------------
#include "surface_builder.hh"
#include "surface_handle.hh"
#include <ost/mol/impl/surface_impl.hh>
#include <ost/mol/impl/rsurf_impl.hh>
#include <ost/log.hh>
#include "surface_handle.hh"
#include "entity_view.hh"
#include "iterator.hh"
......@@ -29,18 +28,8 @@ namespace ost { namespace mol {
SurfaceHandle BuildSurface(const EntityView& ev, Real probe_radius, Real patch_size)
{
rsurf::RSurf rsurf(probe_radius);
for(AtomViewIter it=ev.AtomsBegin();it!=ev.AtomsEnd();++it) {
rsurf.AddSphere((*it).GetPos(),(*it).GetAtomProps().radius,(*it).GetQualifiedName());
}
rsurf.Build();
impl::SurfaceImplP impl(new impl::SurfaceImpl());
rsurf.Triangulate(impl,patch_size);
return SurfaceHandle(impl);
LOGN_ERROR("not yet implemented");
return SurfaceHandle();
}
}}
......
......@@ -28,6 +28,10 @@ SurfaceHandle CreateSurface()
}
SurfaceHandle::SurfaceHandle():
impl_()
{}
SurfaceHandle::SurfaceHandle(const impl::SurfaceImplP& p):
impl_(p)
{}
......
......@@ -38,6 +38,9 @@ typedef std::vector<SurfaceVertexID> SurfaceVertexIDList;
// molecular surface
class DLLEXPORT_OST_MOL SurfaceHandle {
public:
// creates invalid handle
SurfaceHandle();
// internally used ctor
SurfaceHandle(const impl::SurfaceImplP& p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment