QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_instance.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
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//
14*/
15
16#if !defined(OPENNURBS_INSTANCE_INC_)
17#define OPENNURBS_INSTANCE_INC_
18
19/*
20Description:
21 An ON_InstanceDefinition defines the geometry used by
22 instance references.
23See Also:
24 ON_InstanceRef
25*/
27{
29
30public:
31
32 // IDEF_UPDATE_TYPE lists the possible relationships between
33 // the instance definition geometry and the archive
34 // (m_source_archive) containing the original defition.
36 {
37 static_def = 0, // This instance definition is never updated.
38 // If m_source_archive is set, it records the
39 // origin of the instance definition geometry
40 // and, but m_source_archive is never used
41 // to update the instance definition
42 embedded_def = 1, // This instance definition geometry was
43 // imported from another archive (m_source_archive)
44 // and is embedded. If m_source_archive changes,
45 // the user is asked if they want to update
46 // the instance definition.
47 linked_and_embedded_def = 2,
48 // This instance definition geometry was
49 // imported from another archive (m_source_archive)
50 // and is embedded. If m_source_archive changes,
51 // the instance definition is automatically updated.
52 // If m_source_archive is not available, the
53 // instance definition is still valid.
54 linked_def = 3, // This instance definition geometry was
55 // imported from another archive (m_source_archive)
56 // and is not embedded. If m_source_archive changes,
57 // the instance definition is automatically updated.
58 // If m_source_archive is not available, the
59 // instance definition is not valid.
60 // This does not save runtime memory. It may
61 // save a little disk space, but it is a
62 // foolish option requested by people who do not
63 // understand all the issues.
64 force_32bit_idef_update_type = 0xFFFFFFFF
65 };
66
67 static IDEF_UPDATE_TYPE IdefUpdateType(int i);
68
69 // Bits that identify subsets of the instance defintion
70 // fields. These bits are used to determine which fields to
71 // set when an ON_InstanceDefinition class is used to
72 // modify an existing instance definition.
73 enum
74 {
75 no_idef_settings = 0,
76 idef_name_setting = 1, // m_name
77 idef_description_setting = 2, // m_description
78 idef_url_setting = 4, // all m_url_* fields
79 idef_units_setting = 8, // m_us and m_unit_scale
80 idef_source_archive_setting = 0x10, // all m_source_* fields
81 idef_userdata_setting = 0x20, // all m_source_* fields
82 all_idef_settings = 0xFFFFFFFF
83 };
84
85public:
88
89 // virtual ON_Object overrides
90 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
92 ON_BinaryArchive& binary_archive
93 ) const;
95 ON_BinaryArchive& binary_archive
96 );
97 ON::object_type ObjectType() const;
98 unsigned int SizeOf() const;
99
100 // virtual ON_Geometry overrides
101 int Dimension() const;
103 double* boxmin,
104 double* boxmax,
105 int bGrowBox = false
106 ) const;
108 const ON_Xform& xform
109 );
110
111 // virtual
112 ON_UUID ModelObjectId() const;
113
114 // Interface
115 const wchar_t* Name() const;
116 void SetName( const wchar_t* name );
117
118 const wchar_t* Description() const;
119 void SetDescription( const wchar_t* description );
120
121 const wchar_t* URL() const;
122 void SetURL( const wchar_t* url );
123
124 const wchar_t* URL_Tag() const;
125 void SetURL_Tag( const wchar_t* url_tag );
126
127 ON_UUID Uuid() const;
128 void SetUuid( ON_UUID uuid );
129
130 void SetBoundingBox( ON_BoundingBox bbox );
131
132 // list of object ids in the instance geometry table.
134
135 /*
136 Description:
137 If the instance definition is linked or embedded, use
138 SetSource to specify the source archive.
139 Parameters:
140 source_archive - [in] name of source archive
141 checksum - [in] check sum used to detect changed
142 source_type - [in] See comments for ON_InstanceDefinition::IDEF_UPDATE_TYPE
143 Remarks:
144 In all cases, the complete instance definition geometry
145 is stored in the 3dm archive. When an instance definition
146 is linked or embedded, applications can examine the source
147 archive settings and update the definition when appropriate.
148 The checksum can be used to detect changed files.
149 */
150 void SetSourceArchive(
151 const wchar_t* source_archive,
152 ON_CheckSum checksum,
153 IDEF_UPDATE_TYPE update_type
154 );
155
156 /*
157 Returns:
158 Name of source archive.
159 */
160 const wchar_t* SourceArchive() const;
161
162 /*
163 Returns:
164 Check sum of source archive.
165 */
166 ON_CheckSum SourceArchiveCheckSum() const;
167
168 const ON_UnitSystem& UnitSystem() const;
169
170 /*
171 Description:
172 Sets m_us and m_unit_scale.
173 */
174 void SetUnitSystem( ON::unit_system us );
175 void SetUnitSystem( const ON_UnitSystem& us );
176
177public:
178
179 ON_UUID m_uuid; // unique id for this instance definition
180 ON_wString m_name; // The "name" is for human comfort.
181 // It can be empty and duplicates
182 // may exist. Instance reference use
183 // m_uuid to find instance definitions.
185
187 ON_wString m_url_tag; // UI link text for m_url
188
190
192
194
195 int m_idef_update_depth; // Controls how much geometry is read when
196 // a linked idef is updated.
197 // 0: read everything, included nested linked idefs
198 // 1: skip nested linked idefs.
199
200 ON_wString m_source_archive; // filename used to update idef
201 // (it can be empty or relative)
202 bool m_source_bRelativePath; // True if the filename in m_source_archive is
203 // a relative the location of the 3dm file
204 // containing this instance definition.
205
206 ON_CheckSum m_source_archive_checksum; // used to detect when idef is out of
207 // synch with source archive.
208};
209
210
211/*
212Description:
213 An ON_InstanceRef is a reference to an instance definition
214 along with transformation to apply to the definition.
215See Also:
216 ON_InstanceRef
217*/
219{
221
222public:
224
226 //
227 // virtual ON_Object overrides
228 //
229 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
231 ON_BinaryArchive& binary_archive
232 ) const;
234 ON_BinaryArchive& binary_archive
235 );
236 ON::object_type ObjectType() const;
237
239 //
240 // virtual ON_Geometry overrides
241 //
242 int Dimension() const;
244 double* boxmin,
245 double* boxmax,
246 int bGrowBox = false
247 ) const;
249 const ON_Xform& xform
250 );
251
252 // virtual ON_Geometry::IsDeformable() override
253 bool IsDeformable() const;
254
255 // virtual ON_Geometry::MakeDeformable() override
256 bool MakeDeformable();
257
259 //
260
261 // Unique id of the instance definition (ON_InstanceDefinition)
262 // in the instance definition table that defines the geometry
263 // used by this reference.
265
266 // Transformation for this reference.
268
269 // Bounding box for this reference.
271
272 // Tolerance to use for flagging instance xforms
273 // as singular.
274 static const double m_singular_xform_tol;
275};
276
277#endif
@ Uuid
Definition RSMetaType.h:69
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_string.h:24
Definition opennurbs_geometry.h:36
virtual bool IsDeformable() const
Definition opennurbs_geometry.cpp:205
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
virtual bool MakeDeformable()
Definition opennurbs_geometry.cpp:210
virtual int Dimension() const =0
Definition opennurbs_instance.h:27
ON_UUID m_uuid
Definition opennurbs_instance.h:179
ON_wString m_source_archive
Definition opennurbs_instance.h:200
ON_OBJECT_DECLARE(ON_InstanceDefinition)
ON_wString m_url_tag
Definition opennurbs_instance.h:187
ON_wString m_description
Definition opennurbs_instance.h:184
ON_CheckSum m_source_archive_checksum
Definition opennurbs_instance.h:206
ON_wString m_url
Definition opennurbs_instance.h:186
ON_BoundingBox m_bbox
Definition opennurbs_instance.h:189
ON_SimpleArray< ON_UUID > m_object_uuid
Definition opennurbs_instance.h:133
bool m_source_bRelativePath
Definition opennurbs_instance.h:202
ON_wString m_name
Definition opennurbs_instance.h:180
ON_UnitSystem m_us
Definition opennurbs_instance.h:191
IDEF_UPDATE_TYPE
Definition opennurbs_instance.h:36
int m_idef_update_depth
Definition opennurbs_instance.h:195
IDEF_UPDATE_TYPE m_idef_update_type
Definition opennurbs_instance.h:193
Definition opennurbs_instance.h:219
ON_UUID m_instance_definition_uuid
Definition opennurbs_instance.h:264
ON_OBJECT_DECLARE(ON_InstanceRef)
static const double m_singular_xform_tol
Definition opennurbs_instance.h:274
ON_Xform m_xform
Definition opennurbs_instance.h:267
ON_BoundingBox m_bbox
Definition opennurbs_instance.h:270
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_object.cpp:1734
virtual ON_UUID ModelObjectId() const
Definition opennurbs_object.cpp:1622
virtual unsigned int SizeOf() const
Definition opennurbs_object.cpp:1677
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
virtual ON::object_type ObjectType() const
Definition opennurbs_object.cpp:1616
Definition opennurbs_array.h:46
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_string.h:688
Definition opennurbs_xform.h:28
Definition opennurbs_string.h:392
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362