<commit_before>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: cartoonModel.C,v 1.29 2004/09/04 01:50:37 amoll Exp $

#include <BALL/VIEW/MODELS/cartoonModel.h>
#include <BALL/VIEW/PRIMITIVES/tube.h>
#include <BALL/VIEW/PRIMITIVES/disc.h>
#include <BALL/VIEW/PRIMITIVES/mesh.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/chain.h>
#include <BALL/KERNEL/residue.h>
#include <BALL/KERNEL/secondaryStructure.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/MATHS/matrix44.h>

using namespace std;

namespace BALL
{
	namespace VIEW
	{

		AddCartoonModel::AddCartoonModel()
			throw()
			: AddBackboneModel(),
				last_chain_(0),
				spline_vector_position_(-1),
				helix_radius_(2.4),
				arrow_width_(2),
				arrow_height_(0.4)
		{
		}

		AddCartoonModel::AddCartoonModel(const AddCartoonModel& cartoon)
			throw()
			:	AddBackboneModel(cartoon),
				last_chain_(0),
				spline_vector_position_(-1),
				helix_radius_(cartoon.helix_radius_),
				arrow_width_(cartoon.arrow_width_),
				arrow_height_(cartoon.arrow_height_)
		{
		}

		AddCartoonModel::~AddCartoonModel()
			throw()
		{
			#ifdef BALL_VIEW_DEBUG
				Log.error() << "Destructing object " << (void *)this 
										<< " of class " << RTTI::getName<AddCartoonModel>() << endl;
			#endif 
		}

		bool AddCartoonModel::finish()
		{
			return true;
		}


		void AddCartoonModel::clear_()
			throw()
		{
			spline_vector_.clear();
			last_parent_ = 0;
			have_start_point_ = false;

			spline_.clear();
			last_chain_ = 0;
			spline_vector_position_ = -1;
		}

		// -----------------------------------------------------------------
		void AddCartoonModel::drawDNA_(SecondaryStructure& ss)
			throw()
		{
			AtomIterator it;
			BALL_FOREACH_ATOM(ss, it)
			{
				if (it->getName() == "P")
				{
					SplinePoint spline_point((*it).getPosition(), &*it);
					spline_vector_.push_back(spline_point);
				}
			}

			createBackbone_();

			/*
			A: N6
			C: N4
		 	G: N1
			T: O4
			*/

			Position nr_of_residues = ss.countResidues();
			for (Position pos = 0; pos < nr_of_residues; pos++)
			{
				Atom* atom = 0;
				Residue* r = ss.getResidue(pos);
				if (r->getName() == "A")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if (it->getName() == "N6") 
						{
							atom = &*it;
							break;
						}
					}
				}
				else if (r->getName() == "C")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if (it->getName() == "N4") 
						{
							atom = &*it;
							break;
						}
					}
				}
				else if (r->getName() == "G")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if (it->getName() == "N1") 
						{
							atom = &*it;
							break;
						}
					}
				}
				else if (r->getName() == "T")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if (it->getName() == "O4") 
						{
							atom = &*it;
							break;
						}
					}
				}

				// did we find an atom to create the connection?
				if (atom== 0) continue;


				float distance = 999;
				Vector3 nearest_position;
				for (Position j = 0; j < 9; j++)
				{
					Vector3 splinep = spline_[pos*9 + j];
					float d = (splinep - atom->getPosition()).getSquareLength();
					if (d < distance)
					{
						nearest_position = splinep;
						distance = d;
					}
				}

				// draw the connection
				Tube* tube = new Tube;
				if (!tube) throw Exception::OutOfMemory (__FILE__, __LINE__, sizeof(Tube));
				
				tube->setRadius(tube_radius_);
				tube->setVertex1(atom->getPosition());
				tube->setVertex2(nearest_position);
				tube->setComposite(atom);
				geometric_objects_.push_back(tube);
			}

			have_start_point_ = false;

		}
		
		void AddCartoonModel::drawStrand_(SecondaryStructure& ss)
			throw()
		{
			vector<Vector3> peptide_normals;<commit_msg>no message<commit_after>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: cartoonModel.C,v 1.30 2004/09/04 11:54:48 amoll Exp $

#include <BALL/VIEW/MODELS/cartoonModel.h>
#include <BALL/VIEW/PRIMITIVES/tube.h>
#include <BALL/VIEW/PRIMITIVES/disc.h>
#include <BALL/VIEW/PRIMITIVES/mesh.h>
#include <BALL/VIEW/PRIMITIVES/box.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/chain.h>
#include <BALL/KERNEL/residue.h>
#include <BALL/KERNEL/secondaryStructure.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/MATHS/matrix44.h>

using namespace std;

namespace BALL
{
	namespace VIEW
	{

		AddCartoonModel::AddCartoonModel()
			throw()
			: AddBackboneModel(),
				last_chain_(0),
				spline_vector_position_(-1),
				helix_radius_(2.4),
				arrow_width_(2),
				arrow_height_(0.4)
		{
		}

		AddCartoonModel::AddCartoonModel(const AddCartoonModel& cartoon)
			throw()
			:	AddBackboneModel(cartoon),
				last_chain_(0),
				spline_vector_position_(-1),
				helix_radius_(cartoon.helix_radius_),
				arrow_width_(cartoon.arrow_width_),
				arrow_height_(cartoon.arrow_height_)
		{
		}

		AddCartoonModel::~AddCartoonModel()
			throw()
		{
			#ifdef BALL_VIEW_DEBUG
				Log.error() << "Destructing object " << (void *)this 
										<< " of class " << RTTI::getName<AddCartoonModel>() << endl;
			#endif 
		}

		bool AddCartoonModel::finish()
		{
			return true;
		}


		void AddCartoonModel::clear_()
			throw()
		{
			spline_vector_.clear();
			last_parent_ = 0;
			have_start_point_ = false;

			spline_.clear();
			last_chain_ = 0;
			spline_vector_position_ = -1;
		}

		// -----------------------------------------------------------------
		void AddCartoonModel::drawDNA_(SecondaryStructure& ss)
			throw()
		{
			AtomIterator it;
			BALL_FOREACH_ATOM(ss, it)
			{
				if (it->getName() == "P")
				{
					SplinePoint spline_point((*it).getPosition(), &*it);
					spline_vector_.push_back(spline_point);
				}
			}

			createBackbone_();

			Position nr_of_residues = ss.countResidues();
			for (Position pos = 0; pos < nr_of_residues; pos++)
			{
				Atom* base_atom = 0;
				Atom* atom2 = 0;
				Atom* atom3 = 0;
				Residue* r = ss.getResidue(pos);
				if (r->getName() == "A")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if 			(it->getName() == "P") 	base_atom = &*it;
						else if (it->getName() == "C2") atom2 = &*it;
						else if (it->getName() == "N6") atom3 = &*it;
					}
				}
				else if (r->getName() == "C")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if 			(it->getName() == "P") 	base_atom = &*it;
						else if (it->getName() == "N4") atom2 = &*it;
						else if (it->getName() == "O2") atom3 = &*it;
					}
				}
				else if (r->getName() == "G")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if 			(it->getName() == "P") 	base_atom = &*it;
						else if (it->getName() == "O6") atom2 = &*it;
						else if (it->getName() == "N2") atom3 = &*it;
					}
				}
				else if (r->getName() == "T")
				{
					BALL_FOREACH_ATOM(*r, it)
					{
						if 			(it->getName() == "P") 	base_atom = &*it;
						else if (it->getName() == "C5M") atom2 = &*it;
						else if (it->getName() == "O2") atom3 = &*it;
					}
				}

				// did we find all needed atoms?
				if (base_atom == 0 ||
						atom2   	== 0 ||
						atom3   	== 0)
				{
					continue;
				}

				Box* box = new Box(
							atom2->getPosition(),
							base_atom->getPosition() - atom2->getPosition(),
							atom3->getPosition() - atom2->getPosition(),
							0.3);
				box->setComposite(r);

				geometric_objects_.push_back(box);

			}

			have_start_point_ = false;

		}
		
		void AddCartoonModel::drawStrand_(SecondaryStructure& ss)
			throw()
		{
			vector<Vector3> peptide_normals;
{'fraction_non_alphanumeric': 0.17855719410123555, 'fraction_numerical': 0.01620831672645144, 'mean_word_length': 2.4643350207086976, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '908353', 'n_tokens_mistral': 3758, 'n_tokens_neox': 2862, 'n_words': 509}