Part.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Geometry
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2013, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeGeometry/Base.h"
16 #include "CeeCore/RefCountedObject.h"
17 #include "CeeCore/Mat4d.h"
18 #include "CeeCore/BoundingBox.h"
19 
20 namespace cee {
21 namespace geo {
22 
23 class PartSettings;
24 class Data;
25 class TextureCoordinates;
26 
27 //==================================================================================================
28 //
29 //
30 //
31 //==================================================================================================
32 class CEE_GEO_EXPORT Part : public RefCountedObject
33 {
34 public:
35  Part();
36  Part(Data* data);
37  virtual ~Part();
38 
39  Data* data();
40  const Data* data() const;
41  void setData(Data* data);
42 
43  int id() const;
44  void setId(int id);
45 
46  template<typename T>
47  const T* dataOfType() const;
48  template<typename T>
49  T* dataOfType();
50 
51  TextureCoordinates* textureCoordinates();
52  void setTextureCoordinates(TextureCoordinates* coordinates);
53 
54  PartSettings& settings();
55  const PartSettings& settings() const;
56 
57  const Mat4d& transformation() const;
58  void setTransformation(const Mat4d& matrix);
59 
60  BoundingBox boundingBox();
61 
62 private:
63  CEE_PRIVATE_IMPL(Part);
64  CEE_PRIVATE_F(GeometryModel);
65  CEE_DISALLOW_COPY_AND_ASSIGN(Part);
66 };
67 
68 
69 //--------------------------------------------------------------------------------------------------
72 //--------------------------------------------------------------------------------------------------
73 template<typename T>
74 const T* Part::dataOfType() const
75 {
76  if (dynamic_cast<const T*>(data()))
77  {
78  return static_cast<const T*>(data());
79  }
80 
81  return NULL;
82 }
83 
84 
85 //--------------------------------------------------------------------------------------------------
88 //--------------------------------------------------------------------------------------------------
89 template<typename T>
91 {
92  // Use the const version to avoid code duplication
93  return const_cast<T*>(static_cast<const Part&>(*this).dataOfType<T>());
94 }
95 
96 } // namespace geo
97 } // namespace cee
98 
Part settings represents how to draw a part and it&#39;s associated part data.
Definition: PartSettings.h:29
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
Texture coordinates.
Definition: TextureCoordinates.h:30
Base class for all geometry part data classes.
Definition: Data.h:28
Base class for all reference counted objects with built-in support for intrusive reference counting...
Definition: RefCountedObject.h:34
Axis-aligned bounding box.
Definition: BoundingBox.h:27
GeometryModel is a subclass of Model that can handle a large number of parts efficiently.
Definition: GeometryModel.h:36
const T * dataOfType() const
Returns the active (last inserted/top of stack) effect of the given type T, or NULL if no effect of t...
Definition: Part.h:74
Geometry part and how it is to be drawn.
Definition: Part.h:32
4 dimensional matrix.
Definition: Mat4d.h:26