opennurbs_model_geometry.h
1 /*
2 //
3 // Copyright (c) 1993-2016 Robert McNeel & Associates. All rights reserved.
4 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
5 // McNeel & Associates.
6 //
7 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
10 //
11 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
12 //
13 ////////////////////////////////////////////////////////////////
14 */
15 
16 #if !defined(ON_MODEL_GEOMETRY_INC_)
17 #define ON_MODEL_GEOMETRY_INC_
18 
19 /*
20 Description:
21  Used to store geometry table object definition and attributes in an ONX_Model.
22 */
23 class ON_CLASS ON_ModelGeometryComponent : public ON_ModelComponent
24 {
25  ON_OBJECT_DECLARE(ON_ModelGeometryComponent);
26 
27 public:
28  static const ON_ModelGeometryComponent Unset;
29 
30  static const ON_ModelGeometryComponent* FromModelComponentRef(
31  const class ON_ModelComponentReference& model_component_reference,
32  const ON_ModelGeometryComponent* none_return_value
33  );
34 
36  const class ON_ComponentManifest& source_manifest,
37  const class ON_ComponentManifest& destination_manifest,
38  const class ON_ManifestMap& manifest_map
39  ) override;
40 
41  bool IsEmpty() const;
42 
43  bool IsInstanceDefinitionGeometry() const;
44 
45 private:
46 
47 public:
48  ON_ModelGeometryComponent() ON_NOEXCEPT;
49 
52  ) ON_NOEXCEPT;
53 
56  ON_ModelGeometryComponent& operator=(const ON_ModelGeometryComponent&);
57 
58 #if defined(ON_HAS_RVALUEREF)
59  // rvalue copy constructor
60  ON_ModelGeometryComponent( ON_ModelGeometryComponent&& ) ON_NOEXCEPT;
61  // rvalue assignment operator
62  ON_ModelGeometryComponent& operator=( ON_ModelGeometryComponent&& );
63 #endif
64 
65  void Dump(
66  ON_TextLog& text_log
67  ) const override;
68 
69  /*
70  Parameters:
71  geometry - [in]
72  ON_Curve, ON_Surface, ON_Brep, ON_Mesh, ON_Light, annotation, detail, ...
73  A new copy of the geometry is managed by the ON_ModelGeometryComponent class.
74  attributes - [in]
75  nullptr if not available.
76  A new copy of the attributes is managed by the ON_ModelGeometryComponent class.
77  model_geometry_component - [in]
78  If not nullptr, this class is set. Otherwise operator new allocates
79  an ON_ModelGeometryComponent class.
80  Remarks:
81  The returned ON_ModelGeometryComponent manages geometry and attributes and will
82  eventually delete them.
83  */
84  static ON_ModelGeometryComponent* Create(
85  const class ON_Object& model_geometry,
86  const class ON_3dmObjectAttributes* attributes,
87  ON_ModelGeometryComponent* model_geometry_component
88  );
89 
90  /*
91  Parameters:
92  geometry_object - [in]
93  ON_Curve, ON_Surface, ON_Brep, ON_Mesh, ON_Light, annotation, detail, ...
94  geometry_object was created on the heap using operator new and
95  the ON_ModelGeometryComponent destructor will delete geometry_object.
96  attributes - [in]
97  attributes is nullptr or was created on the heap using operator new
98  and the ON_ModelGeometryComponent destructor will delete attributes.
99  model_geometry - [in]
100  If not nullptr, this class is set. Otherwise operator new allocates
101  an ON_ModelGeometryComponent class.
102  Remarks:
103  The returned ON_ModelGeometryComponent manages geometry_object and attributes and will
104  eventually delete them.
105  */
106  static ON_ModelGeometryComponent* CreateManaged(
107  class ON_Object* geometry_object,
108  class ON_3dmObjectAttributes* attributes,
109  ON_ModelGeometryComponent* model_geometry_component
110  );
111 
112  /*
113  Parameters:
114  bManageGeometry - [in]
115  If true, geometry_object was created on the heap using operator new and
116  the ON_ModelGeometryComponent destructor will delete geometry_object. Othewise
117  the expert caller is carefully managing the geometry_object instance and memory.
118  geometry_object - [in]
119  ON_Curve, ON_Surface, ON_Brep, ON_Mesh, ON_Light, annotation, detail, ...
120  bManageAttributes - [in]
121  If true, attributes is nullptr or was created on the heap using operator new
122  and the ON_ModelGeometryComponent destructor will delete attributes. Othewise
123  the expert caller is carefully managing the attributes instance and memory.
124  attributes - [in]
125  nullptr if not available
126  model_geometry_component - [in]
127  If not nullptr, this class is set. Otherwise operator new allocates
128  an ON_ModelGeometryComponent class.
129  */
130  static ON_ModelGeometryComponent* CreateForExperts(
131  bool bManageGeometry,
132  class ON_Object* geometry_object,
133  bool bManageAttributes,
134  class ON_3dmObjectAttributes* attributes,
135  ON_ModelGeometryComponent* model_geometry_component
136  );
137 
138  /*
139  Parameters:
140  no_geometry_return_value - [in]
141  This value is returned if no geometric object has been set.
142  A good choices for this parameter's value depends on the context.
143  Common options are nullptr.
144  Returns:
145  The curve, surface, annotation, detail, light, ... geometry,
146  or no_geometry_return_value if the geometry has not been set.
147  If the geometry is a light, then ComponentType() will return ON_ModelComponent::Type::RenderLight.
148  If the geometry is set and something besides light, then ComponentType()
149  will return ON_ModelComponent::Type::ModelGeometry.
150  Otherwise, ComponentType() will return ON_ModelComponent::Type::ModelGeometry::Unset.
151  */
152  const class ON_Geometry* Geometry(
153  const class ON_Geometry* no_geometry_return_value
154  ) const;
155 
156  /*
157  Parameters:
158  no_attributes_return_value - [in]
159  This value is returned if no attributes have been set.
160  A good choices for this parameter's value depends on the context.
161  Common options are nullptr, &ON_3dmObjectAttributes::Unset,
162  &ON_3dmObjectAttributes::Default, or the model's current default attributes.
163  Returns:
164  The layer, rendering and other attributes for this element,
165  or no_attributes_return_value if the attributes have not been set.
166  */
168  const ON_3dmObjectAttributes* no_attributes_return_value
169  ) const;
170 
171 private:
172 
173 #pragma ON_PRAGMA_WARNING_PUSH
174 #pragma ON_PRAGMA_WARNING_DISABLE_MSC( 4251 )
175  // C4251: ... needs to have dll-interface to be used by clients of class ...
176  // m_geometry_sp is private and all code that manages m_sp is explicitly implemented in the DLL.
177  // m_attributes_sp is private and all code that manages m_sp is explicitly implemented in the DLL.
178 private:
179  std::shared_ptr<ON_Geometry> m_geometry_sp;
180 private:
181  std::shared_ptr<ON_3dmObjectAttributes> m_attributes_sp;
182 #pragma ON_PRAGMA_WARNING_POP
183 };
184 
185 #if defined(ON_DLL_TEMPLATE)
186 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_ModelGeometryComponent*>;
187 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<const ON_ModelGeometryComponent*>;
188 #endif
189 
190 #endif
The ON_ModelComponent class is a base class for all components in a model and manages the index...
Definition: opennurbs_model_component.h:24
virtual bool UpdateReferencedComponents(const class ON_ComponentManifest &source_manifest, const class ON_ComponentManifest &destination_manifest, const class ON_ManifestMap &manifest_map)
Uses the destination_manifest to update references to other components. This is typically done when a...
void Dump(ON_TextLog &) const override
Creates a text dump of the object.
ON_ManifestIdentificationMap is used to record a map from a source manifest to a destination manifest...
Definition: opennurbs_archive.h:1464
Definition: opennurbs_array.h:36
Base class for all geometry classes that must provide runtime class id. Provides interface for common...
Definition: opennurbs_geometry.h:37
Type
The ON_ModelComponent::Type enum has a value for each explicit component type and two special values...
Definition: opennurbs_model_component.h:52
Attributes
Definition: opennurbs_model_component.h:258
Definition: opennurbs_archive.h:478
static const ON_ModelComponent Unset
Definition: opennurbs_model_component.h:222
Top level OpenNURBS objects have geometry and attributes. The geometry is stored in some class derive...
Definition: opennurbs_3dm_attributes.h:41
Used to store geometry table object definition and attributes in an ONX_Model.
Definition: opennurbs_model_geometry.h:22
Pure virtual base class for all classes that must provide runtime class id or support object level 3D...
Definition: opennurbs_object.h:460
Definition: opennurbs_textlog.h:20
Definition: opennurbs_model_component.h:1622