File: LineModel_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (94 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.h>
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/VIEW/PRIMITIVES/twoColoredLine.h>
#include <BALL/VIEW/PRIMITIVES/point.h>
#include <BALL/KERNEL/extractors.h>

///////////////////////////
#include <BALL/VIEW/MODELS/lineModel.h>
///////////////////////////

using namespace BALL;
using namespace BALL::VIEW;

START_TEST(AddLineModel)

CHECK(CSTR)
	AddLineModel();
RESULT

CHECK(AddLineModel::BALL_CREATE(AddLineModel))
  //BAUSTELLE
RESULT


PDBFile pdb(BALL_TEST_DATA_PATH(1BNA.pdb));
System system;
pdb >> system;

CHECK(AddLineModel::Processor::Result operator() (Composite& composite))
	AddLineModel bs;
	bool result = bs.operator() (system);
	TEST_EQUAL(result, true)
RESULT

Size nr_atoms = system.countAtoms();
Size nr_bonds = system.countBonds();
Size nr_double_bonds = 0;

AtomBondIterator abit;
AtomIterator ait;
BALL_FOREACH_INTRABOND(system, ait, abit)
{
	if (abit->getType() == Bond::TYPE__HYDROGEN)
	{
		nr_bonds--;
	}
	 
	if (abit->getOrder() == Bond::ORDER__DOUBLE)
	{
		nr_double_bonds++;
	}
}

CHECK(AddLineModel::createGeometricObjects() throw())
	AddLineModel bs;
	system.apply(bs);
	bs.createGeometricObjects();
	TEST_EQUAL(bs.getGeometricObjects().size(), nr_atoms + nr_bonds)
	Point* m = dynamic_cast<Point*>(*bs.getGeometricObjects().begin());
	TEST_NOT_EQUAL(m, 0)
	PRECISION(0.0001)
	Atom* atom = *atoms(system).begin();
	TEST_EQUAL(m->getVertex(), atom->getPosition())
	TEST_EQUAL(m->getComposite(), atom)
	list<GeometricObject*>::iterator it = bs.getGeometricObjects().begin();
	bool found = false;
	for (; it != bs.getGeometricObjects().end(); it++)
	{	
		TwoColoredLine* m = dynamic_cast<TwoColoredLine*>(*it);
		if (m != 0)
		{
			const Bond* bond = dynamic_cast<const Bond*>((*it)->getComposite());
			Bond* bond2 = (Bond*) bond;
			TEST_EQUAL(m->getVertex1(), bond2->getFirstAtom()->getPosition())
			TEST_EQUAL(m->getVertex2(), bond2->getSecondAtom()->getPosition())
			found = true;
			break;
		}
	}

	TEST_EQUAL(found, true)
RESULT


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST