STIR 6.4.0
CombinedShape3D.inl
Go to the documentation of this file.
1//
2//
12/*
13 Copyright (C) 2000- 2009, Hammersmith Imanet Ltd
14 This file is part of STIR.
15
16 SPDX-License-Identifier: Apache-2.0
17
18 See STIR/LICENSE.txt for details
19*/
20START_NAMESPACE_STIR
21
22template <class operation>
23CombinedShape3D<operation>::CombinedShape3D(shared_ptr<Shape3D> object1_v, shared_ptr<Shape3D> object2_v)
24 : object1_ptr(object1_v),
25 object2_ptr(object2_v)
26{}
27
28template <class operation>
29bool
31{
32 return operation()(object1_ptr->is_inside_shape(index), object2_ptr->is_inside_shape(index));
33}
34
35template <class operation>
38{
39 // TODO alright ?
40#if 0
41 Shape3D* tmp = static_cast<Shape3D *>(new CombinedShape3D<operation>(*this));
42 cerr << "Cloning " << this <<
43 ", new " << tmp << endl;
44 return tmp;
45#else
46 return static_cast<Shape3D*>(new CombinedShape3D<operation>(*this));
47#endif
48}
49
50template <class operation>
51void
53{
54 // TODO alright ?
55 shared_ptr<Shape3D> new_object1_ptr = object1_ptr->clone();
56 shared_ptr<Shape3D> new_object2_ptr = object2_ptr->clone();
57 object1_ptr = new_object1_ptr;
58 object2_ptr = new_object2_ptr;
59 object1_ptr->translate(direction);
60 object2_ptr->translate(direction);
61}
62
63template <class operation>
64void
66{
67 // TODO alright ?
68#if 0
69 cerr << "scale: " << object1_ptr.ptr->data
70 << ", " << object2_ptr.ptr->data << endl;
71#endif
72 shared_ptr<Shape3D> new_object1_ptr = object1_ptr->clone();
73 shared_ptr<Shape3D> new_object2_ptr = object2_ptr->clone();
74 object1_ptr = new_object1_ptr;
75 object2_ptr = new_object2_ptr;
76 object1_ptr->scale(scale3D);
77 object2_ptr->scale(scale3D);
78}
79
80END_NAMESPACE_STIR
a templated class for 3-dimensional coordinates.
Definition CartesianCoordinate3D.h:53
void translate(const CartesianCoordinate3D< float > &direction)
translate the whole shape by shifting its origin
Definition CombinedShape3D.inl:52
bool is_inside_shape(const CartesianCoordinate3D< float > &coord) const
determine if a point is inside the shape or not (up to floating point errors)
Definition CombinedShape3D.inl:30
Shape3D * clone() const
Allocate a new Shape3D object which is a copy of the current one.
Definition CombinedShape3D.inl:37
void scale(const CartesianCoordinate3D< float > &scale3D)
scale the whole shape
Definition CombinedShape3D.inl:65
The base class for all 3 dimensional shapes.
Definition Shape3D.h:66