backboneModel.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: backboneModel.h,v 1.20.18.1 2007/03/25 21:26:05 oliver Exp $
00005 //
00006 
00007 #ifndef BALL_VIEW_MODELS_BACKBONEMODEL_H
00008 #define BALL_VIEW_MODELS_BACKBONEMODEL_H
00009 
00010 #ifndef BALL_VIEW_MODELS_MODELPROCESSOR_H
00011 # include <BALL/VIEW/MODELS/modelProcessor.h>
00012 #endif
00013 
00014 #ifndef BALL_MATHS_VECTOR3_H
00015 # include <BALL/MATHS/vector3.h>
00016 #endif 
00017 
00018 #ifndef BALL_KERNEL_SECONDARYSTRUCTURE_H
00019  #include <BALL/KERNEL/secondaryStructure.h>
00020 #endif
00021 
00022 #ifndef BALL_KERNEL_PROTEIN_H
00023  #include <BALL/KERNEL/protein.h>
00024 #endif
00025 
00026 #ifndef BALL_MATHS_MATRIX44_H
00027  #include <BALL/MATHS/matrix44.h>
00028 #endif
00029 
00030 namespace BALL
00031 {
00032   namespace VIEW
00033   {
00041     class BALL_VIEW_EXPORT AddBackboneModel: public ModelProcessor
00042     {
00043       //_
00044       protected:
00045 
00046       struct ModelPart
00047       {
00048         ModelPart();
00049         ModelPart(const ModelPart& m);
00050         const ModelPart& operator = (const ModelPart& p);
00051 
00052         // residues for this ModelPart
00053         vector<Residue*> residues;
00054         // Model Type, e.g. Strand, Helix, Ribbon
00055         Index type;
00056         // start and end index in guide_points_
00057         Position first_guide_point;
00058         Position last_guide_point;
00059         // start and end index in interpolated_points_
00060         Position first_point;
00061         Position last_point;
00062       };
00063         
00064       enum ModelTypes
00065       {
00066         TUBE,
00067         RIBBON,
00068         NUCLEIC_ACID
00069       };
00070 
00071       public:
00072 
00073       BALL_CREATE(AddBackboneModel)
00074 
00075       
00076       AddBackboneModel();
00077 
00079       AddBackboneModel(const AddBackboneModel& add_Backbone_model);
00080 
00082       virtual ~AddBackboneModel();
00083 
00087       virtual void clear();
00088 
00090       virtual bool start();
00091 
00099       virtual Processor::Result operator() (Composite& composite);
00100 
00108       virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00109 
00111       void setTubeRadius(float radius)
00112         { tube_radius_ = radius;}
00113 
00115       float getTubeRadius() const
00116         { return tube_radius_;}
00117 
00119       virtual bool createGeometricObjects();
00120 
00122       void setRibbonMode(bool state)
00123         {ribbon_mode_ = state;}
00124 
00126       bool ribbonModeEnabled() const
00127         {return ribbon_mode_;}
00128 
00129       protected:
00130 
00131       virtual void calculateModelParts(Protein& protein);
00132       virtual bool collectPositions(vector<Residue*> residues);
00133       virtual void calculateGuidePoints_();
00134 
00135       virtual void assignModelType(ModelPart& part);
00136 
00137       virtual void createModel_(Position set_pos, Position model_pos);
00138       // build a tube model
00139       virtual void createTube_(Position set_pos, Position model_pos);
00140       // build a ribbon / helix
00141       virtual void createRibbon_(Position set_pos, Position model_pos);
00142 
00143 
00144       virtual void refineGuidePoints_() {};
00145       virtual void interpolate_();
00146       virtual void refineModelParts_();
00147 
00148       virtual void clear_();
00149       
00150       inline void evaluateBSpline(const Vector3& v1, const Vector3& v2, 
00151                                   const Vector3& v3, float x, Vector3& result);
00152 
00153       inline bool residuesAreConnected_(Residue& residue1, Residue& residue2);
00154 
00155       inline void calculateTubePoints_(Vector3 right, Vector3 dir, vector<Vector3>& points);
00156       inline void calculateRibbonPoints_(Vector3 xn, Vector3 dir, vector<Vector3>& points);
00157       inline void calculateRibbonEllipse_(float ribbon_width, float ribbon_height);
00158 
00159       //_
00160       float tube_radius_;
00161 
00162       //_
00163       Size  interpolation_steps_;
00164       // must be alwas uneven:
00165       Size number_of_ribbons_;
00166       float ribbon_width_;
00167       float ribbon_height_;
00168       bool care_for_SS_;
00169       bool ribbon_mode_;
00170 
00171       vector<vector<vector<Vector3> > > guide_points_;
00172       vector<vector<vector<Vector3> > > interpolated_points_;
00173       vector<vector<Vector3> > backbone_;
00174       vector<vector<Vector3> > offsets_;
00175       vector<vector<ModelPart> > model_parts_;
00176 
00177       Protein dummy_protein_;
00178       Chain dummy_chain_;
00179       SecondaryStructure dummy_ss_;
00180       HashSet<Residue*> residues_to_be_rendered_;
00181       Protein* last_protein_;
00182       vector<vector<Index> > ss_;
00183       // temp variables for speedup:
00184       Size        slides_;
00185       Position    middle_slide_;
00186       Position    middle_ribbon_;
00187       Angle       slides_angle_;
00188       Matrix4x4   temp_matrix_;
00189       vector<float> xs_, ys_;
00190     };
00191 
00192   } // namespace VIEW
00193 } // namespace BALL
00194 
00195 #endif // BALL_VIEW_MODELS_BACKBONEMODEL_H