File: geometricObject.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (103 lines) | stat: -rw-r--r-- 2,146 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
95
96
97
98
99
100
101
102
103
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/VIEW/KERNEL/geometricObject.h>
#include <BALL/VIEW/DATATYPE/colorExtensions.h>

using std::endl;
using std::ostream;
using std::istream;

namespace BALL
{
	namespace VIEW
	{

		GeometricObject::GeometricObject()
			: color_(),
				composite_(0)
		{
		}

		GeometricObject::GeometricObject(const GeometricObject& geometric_object)
			: color_(geometric_object.color_),
				composite_(geometric_object.composite_)
		{
		}

		GeometricObject::~GeometricObject()
		{
			#ifdef BALL_VIEW_DEBUG
				Log.info() << "Destructing object " << this << " of class " << RTTI::getName<GeometricObject>() << endl;
			#endif 
		}

		void GeometricObject::clear()
		{
			color_ = ColorRGBA();
			composite_ = 0;
		}

		void GeometricObject::set(const GeometricObject& geometric_object)
		{
			color_ = geometric_object.color_;
			composite_ = geometric_object.composite_;
		}

		GeometricObject& GeometricObject::operator = (const GeometricObject& geometric_object)
		{
			set(geometric_object);
			return *this;
		}

		void GeometricObject::swap(GeometricObject& geometric_object)
		{
			const Composite* composite = geometric_object.composite_;
			geometric_object.composite_ = composite_;
			composite_ = composite;
		}

		void GeometricObject::dump(ostream& s, Size depth) const
		{
			BALL_DUMP_STREAM_PREFIX(s);
			
			BALL_DUMP_DEPTH(s, depth);
			BALL_DUMP_HEADER(s, this, this);

			BALL_DUMP_DEPTH(s,depth);
			s << "composite 		 : " << composite_ << endl;

			BALL_DUMP_STREAM_SUFFIX(s);
		}

		void GeometricObject::getColors(HashSet<String>& color_set)
		{
			String c;

			MultiColorExtension* mce = dynamic_cast<MultiColorExtension*>(this);
			if (mce != 0)
			{
				const vector<ColorRGBA>& cs = mce->getColors();
				for (Position p = 0; p < cs.size(); p++)
				{
					cs[p].get(c);
					color_set.insert(c);
				}

				return;
			}

			ColorExtension2* ce2 = dynamic_cast<ColorExtension2*>(this);
			if (ce2 != 0)
			{
				ce2->getColor2().get(c);
				color_set.insert(c);
			}

			getColor().get(c);
			color_set.insert(c);
		}
			
	} // namespace VIEW
} // namespace BALL