opennurbs_instance.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_INSTANCE_INC_)
18 #define OPENNURBS_INSTANCE_INC_
19 
21 {
22 public:
27 
28  bool Read(
29  ON_BinaryArchive& archive
30  );
31 
32  bool Write(
33  ON_BinaryArchive& archive
34  ) const;
35 
36  bool IsEmpty() const;
37  bool IsNotEmpty() const;
38 
39  bool HasLayerInformation() const;
40  bool HasLayerTableInformation() const;
41  bool HasParentLayerInformation() const;
42 
43  /*
44  Description:
45  Update runtime layer color visibility, locked, ... settings in the
46  layer table read from a refence file to the values to use in the
47  runtime model.
48  This is typically done right after the reference file layer table is
49  read and before the layers are added to the runtime model.
50  Parameters:
51  source_archive_manifest - [in]
52  manifest of archive being read (may partially read)
53  model_manifest - [in]
54  manifest of runtime model (may partially created)
55  layer_count - [in]
56  length of layers[] array;
57  layers - [in/out]
58  The input values should be the layer table read from the referenced file.
59  The output values have color, visibility, locked, ... settings updated
60  to the state they had the last time the model file (not the referenced file)
61  was saved.
62  linked_definition_parent_layer - [in/out]
63  If linked_definition_parent_layer is not nullptr, its color, visibility, ...
64  settings are updated to the state they had the last time the model file
65  (not the referenced file) was saved.
66  Remarks:
67  The layer idenitification information (name, index, id) are not changed by
68  this function.
69  */
70  void AfterReferenceLayerTableRead(
71  const class ON_ComponentManifest& source_archive_manifest,
72  const class ON_ComponentManifest& model_manifest,
73  const class ON_ManifestMap& archive_to_model_map,
74  ON_Layer* linked_definition_parent_layer,
75  unsigned int layer_count,
76  ON_Layer** layers
77  );
78 
79  /*
80  Description:
81  Update the mapping from from reference file layer id to runtime model layer id.
82  Typically this is done immediately after the reference file layers are added
83  to the runtime model.
84  Parameters:
85  source_archive_manifest - [in]
86  manifest of archive being read (may partially read)
87  model_manifest - [in]
88  manifest of runtime model (may partially created)
89  archive_to_model_map - [in]
90  Manifest map from reference file settings to runtime model settings.
91  This map typically exists while the archive is being read and is
92  destroyed after reading is complete. That's why the mapping has
93  to be saved.
94  */
95  void AfterLayerTableAddedToModel(
96  const class ON_ComponentManifest& source_archive_manifest,
97  const class ON_ComponentManifest& model_manifest,
98  const class ON_ManifestMap& archive_to_model_map
99  );
100 
101  /*
102  Description:
103  Save the current runtime layer color, visibility, ... states.
104  Typically this is done immediately before a linked instance definition
105  or worksession reference information is written. Calling the Write()
106  function destroys the information created by BeforeWrite() because
107  it is generally out-of-date if modeling resumes after writing.
108  Parameters:
109  model_manifest - [in]
110  manifest of runtime model
111  destination_archive_manifest - [in]
112  manifest of archive being written (may partially written)
113  model_to_archive_map - [in]
114  Manifest map from model to destination_archive_manifest.
115  linked_definition_parent_layer - [in]
116  nullptr or the parent layer
117  context - [in]
118  first parameter passed to ModelLayerFromIdFunc
119  ModelLayerFromIdFunc - [in]
120  Function to get model layers from id
121  */
122  void BeforeLinkedDefinitionWrite(
123  const class ON_ComponentManifest& model_manifest,
124  const class ON_ComponentManifest& destination_archive_manifest,
125  const class ON_ManifestMap& model_to_archive_map,
126  const ON_Layer* linked_definition_parent_layer,
127  void* context,
128  const ON_Layer*(*ModelLayerFromIdFunc)(void* context, const ON_UUID&)
129  );
130 
131 private:
132  class ON_ReferencedComponentSettingsImpl* Impl(
133  bool bCreateIfNull
134  );
135 
136  class ON_ReferencedComponentSettingsImpl* m_impl = nullptr;
137 };
138 
139 /*
140 Description:
141  An ON_InstanceDefinition defines the geometry used by
142  instance references.
143 See Also:
144  ON_InstanceRef
145 */
146 class ON_CLASS ON_InstanceDefinition : public ON_ModelComponent
147 {
148  ON_OBJECT_DECLARE(ON_InstanceDefinition);
149 
150 public:
151 
152  // IDEF_UPDATE_TYPE lists the possible relationships between
153  // the instance definition geometry and the archive
154  // (m_source_archive) containing the original defition.
155  enum class IDEF_UPDATE_TYPE : unsigned int
156  {
157  Unset = 0,
158  Static = 1,
159  LinkedAndEmbedded = 2,
160  Linked = 3
161 
162 
163  //static_def = 0,
164  //embedded_def = 1,
165  // // As of 7 February, "static_def" and "embedded_def"
166  // // and shall be treated the same. Using "static_def"
167  // // is prefered and "embedded_def" is obsolete.
168  // // The geometry for the instance definition
169  // // is saved in archives, is fixed and has no
170  // // connection to a source archive.
171  // // All source archive information should be
172  // // empty strings and m_source_archive_checksum
173  // // shoule be "zero".
174  //linked_and_embedded_def = 2,
175  // // The geometry for the instance definition
176  // // is saved in archives. Complete source
177  // // archive and checksum information will be
178  // // present. The document setting
179  // // ON_3dmIOSettings.m_idef_link_update
180  // // determines if, when and how the instance
181  // // definition geometry is updated by reading the
182  // // source archive.
183  //linked_def = 3,
184  // // The geometry for this instance definition
185  // // is not saved in the archive that contains
186  // // this instance definition. This instance
187  // // definition geometry is imported from a
188  // // "source archive" The "source archive" file
189  // // name and checksum information are saved
190  // // in m_source_archive and m_source_archive_checksum.
191  // // If file named in m_source_archive is not available,
192  // // then this instance definition is not valid and any
193  // // references to it are not valid.
194  };
195 
196  // Converts and integer into an IDEF_UPDATE_TYPE enum.
197  static ON_InstanceDefinition::IDEF_UPDATE_TYPE InstanceDefinitionTypeFromUnsigned(
198  unsigned int idef_type_as_unsigned
199  );
201  // Bits that identify subsets of the instance defintion
202  // fields. These bits are used to determine which fields to
203  // set when an ON_InstanceDefinition class is used to
204  // modify an existing instance definition.
205  enum
206  {
207  no_idef_settings = 0,
208  idef_name_setting = 1, // m_name
209  idef_description_setting = 2, // m_description
210  idef_url_setting = 4, // all m_url_* fields
211  idef_units_setting = 8, // m_us and m_unit_scale
212  idef_source_archive_setting = 0x10, // all m_source_*, layer style, update depth fields
213  idef_userdata_setting = 0x20,
214  all_idef_settings = 0xFFFFFFFF
215  };
216 
217 public:
218  ON_InstanceDefinition() ON_NOEXCEPT;
221  ON_InstanceDefinition& operator=(const ON_InstanceDefinition&);
223 private:
224  void Internal_Destroy();
225  void Internal_Copy(const ON_InstanceDefinition& src);
226 
227 public:
228 
229  static const ON_InstanceDefinition Unset;
230 
231  /*
232  Parameters:
233  model_component_reference - [in]
234  none_return_value - [in]
235  value to return if ON_InstanceDefinition::Cast(model_component_ref.ModelComponent())
236  is nullptr
237  Returns:
238  If ON_InstanceDefinition::Cast(model_component_ref.ModelComponent()) is not nullptr,
239  that pointer is returned. Otherwise, none_return_value is returned.
240  */
241  static const ON_InstanceDefinition* FromModelComponentRef(
242  const class ON_ModelComponentReference& model_component_reference,
243  const ON_InstanceDefinition* none_return_value
244  );
245 
246 
247  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
248 
249  // virtual ON_Object::Dump override
250  void Dump(
251  ON_TextLog& text_log
252  ) const override;
253 
254 public:
255  bool Write(
256  ON_BinaryArchive& archive
257  ) const override;
258 
259 private:
260  bool Internal_WriteV5(
261  ON_BinaryArchive& archive
262  ) const;
263  bool Internal_WriteV6(
264  ON_BinaryArchive& archive
265  ) const;
266 
267 public:
268  bool Read(
269  ON_BinaryArchive& archive
270  ) override;
271 
272 private:
273  bool Internal_ReadV5(
274  ON_BinaryArchive& archive
275  );
276  bool Internal_ReadV6(
277  ON_BinaryArchive& archive
278  );
279 
280 public:
281  ON::object_type ObjectType() const override;
282 
283  // virtual ON_Object:: override
284  unsigned int SizeOf() const override;
285 
286  const ON_BoundingBox BoundingBox() const;
287 
288  void SetBoundingBox( ON_BoundingBox bbox );
289 
290  void ClearBoundingBox();
291 
292  const ON_wString Description() const;
293  void SetDescription( const wchar_t* description );
294 
295  const ON_wString URL() const;
296  void SetURL( const wchar_t* url );
297 
298  const ON_wString URL_Tag() const;
299  void SetURL_Tag( const wchar_t* url_tag );
300 
301  /*
302  Returns:
303  A list of object ids in the instance geometry table sorted by id.
304  */
305  const ON_SimpleArray<ON_UUID>& InstanceGeometryIdList() const;
306 
307  /*
308  Parameters:
309  instance_geometry_id_list - [in]
310  A list of object ids in the instance geometry table.
311  */
312  void SetInstanceGeometryIdList(
313  const ON_SimpleArray<ON_UUID>& instance_geometry_id_list
314  );
315 
316  /*
317  Description:
318  Remove all ids from the InstanceGeometryIdList().
319  */
320  void ClearInstanceGeometryIdList();
321 
322  /*
323  Description:
324  Remove id from the InstanceGeometryIdList().
325  */
326  bool RemoveInstanceGeometryId(
327  ON_UUID id
328  );
329 
330  /*
331  Description:
332  Remove InstanceGeometryIdList()[id_index] from the InstanceGeometryIdList() array.
333  */
334  bool RemoveInstanceGeometryId(
335  int id_index
336  );
337 
338  /*
339  Description:
340  Add id to the InstanceGeometryIdList().
341  Parameters:
342  id - [in]
343  non-nil id to add.
344  Returns:
345  True if id is not nil and was added to the InstanceGeometryIdList().
346  */
347  bool AddInstanceGeometryId(
348  ON_UUID id
349  );
350 
351  /*
352  Returns:
353  True if id is in the InstanceGeometryIdList().
354  */
355  bool IsInstanceGeometryId(
356  ON_UUID id
357  ) const;
358 
359 private:
360  int Internal_InstanceGeometryIdIndex(
361  ON_UUID id
362  ) const;
363 
364 public:
365  /*
366  Parameters:
367  instance_definition_type - [in]
368  ON_InstanceDefinition::IDEF_UPDATE_TYPE::Unset - change the type to Unset
369  and remove all linked file information.
370  ON_InstanceDefinition::IDEF_UPDATE_TYPE::Static - change the type to Static
371  and remove all linked file information.
372  ON_InstanceDefinition::IDEF_UPDATE_TYPE::LinkedAndEmbedded - change
373  the type to from Linked to LinkedAndEmbedded. If the current type
374  is not Linked, then no changes are made.
375  ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked - change
376  the type to from LinkedAndEmbedded to Linked. If the current type
377  is not LinkedAndEmbedded, then no changes are made.
378  */
379  bool SetInstanceDefinitionType(
380  const ON_InstanceDefinition::IDEF_UPDATE_TYPE instance_definition_type
381  );
382 
383  /*
384  Parameters:
385  linked_definition_type - [in]
386  Either ON_InstanceDefinition::IDEF_UPDATE_TYPE::LinkedAndEmbedded
387  or ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked.
388  linked_file_reference - [in]
389  */
390  bool SetLinkedFileReference(
391  ON_InstanceDefinition::IDEF_UPDATE_TYPE linked_definition_type,
392  ON_FileReference linked_file_reference
393  );
394 
395  bool SetLinkedFileReference(
396  ON_InstanceDefinition::IDEF_UPDATE_TYPE linked_definition_type,
397  const wchar_t* linked_file_full_path
398  );
399 
400  const ON_FileReference LinkedFileReference() const;
401 
402  /*
403  Destroy all linked file path information and convert the type to Static.
404  */
405  void ClearLinkedFileReference();
406 
407  void ClearLinkedFileContentHash();
408 
409  void ClearLinkedFileRelativePath();
410 
411  const ON_wString& LinkedFilePath() const;
412 
413  const ON_UnitSystem& UnitSystem() const;
414 
415 public:
416  /*
417  Description:
418  Sets m_us and m_unit_scale.
419  */
420  void SetUnitSystem( ON::LengthUnitSystem us );
421  void SetUnitSystem( const ON_UnitSystem& us );
422 
423  /*
424  Returns:
425  True if this is a linked instance definition with
426  layer settings information.
427  */
428  bool HasLinkedIdefReferenceComponentSettings() const;
429 
430  void ClearLinkedIdefReferenceComponentSettings();
431 
432  /*
433  Parameters:
434  bCreateIfNonePresent - [in]
435  When bCreateIfNonePresent is true and the idef type is ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked,
436  then ON_ReferencedComponentSettings will be created if none are present.
437  Return:
438  ON_ReferencedComponentSettings pointer or nullptr.
439  */
440  const ON_ReferencedComponentSettings* LinkedIdefReferenceComponentSettings() const;
441 
442  /*
443  Parameters:
444  bCreateIfNonePresent - [in]
445  When bCreateIfNonePresent is true and the idef type is ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked,
446  then ON_ReferencedComponentSettings will be created if none are present.
447  Return:
448  ON_ReferencedComponentSettings pointer or nullptr.
449  */
450  ON_ReferencedComponentSettings* LinkedIdefReferenceComponentSettings(
451  bool bCreateIfNonePresent
452  );
453 
454 public:
455 
456  // OBSOLETE - change IdefUpdateType() to InstanceDefinitionType()
457  ON_InstanceDefinition::IDEF_UPDATE_TYPE IdefUpdateType() const;
458 
459  ON_InstanceDefinition::IDEF_UPDATE_TYPE InstanceDefinitionType() const;
460 
461  /*
462  Returns:
463  true if InstanceDefinitionType() = ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked or ON_InstanceDefinition::IDEF_UPDATE_TYPE::LinkedAndEmbedded.
464  */
465  bool IsLinkedType() const;
466 
467  /*
468  Description:
469  This property applies when an instance definiton is linked.
470  Returns:
471  true:
472  When reading the file that defines the content of the linked instance definition,
473  skip any linked instance definitions found in that file.
474  false:
475  When reading the file that defines the content of the linked instance definition,
476  recursively load linked instance definitions found in that file.
477  */
478  bool SkipNestedLinkedDefinitions() const;
479 
480  void SetSkipNestedLinkedDefinitions(
481  bool bSkipNestedLinkedDefinitions
482  );
483 
484 private:
485  // list of object ids in the instance geometry table.
486  ON_SimpleArray<ON_UUID> m_object_uuid;
487 
488 private:
489  ON_wString m_description;
490  ON_wString m_url;
491  ON_wString m_url_tag; // UI link text for m_url
492 
493 private:
494  ON_BoundingBox m_bbox = ON_BoundingBox::EmptyBoundingBox;
495 
496 private:
497  ON_UnitSystem m_us = ON_UnitSystem::None;
498 
499 private:
500  // Note: the embedded_def type is obsolete.
501  // To avoid having to deal with this obsolete type in
502  // your code, using ON_InstanceDefintion::IdefUpdateType()
503  // to get this value. The IdefUpdateType() function
504  // with convert the obsolte value to the correct
505  // value.
506  ON_InstanceDefinition::IDEF_UPDATE_TYPE m_idef_update_type = ON_InstanceDefinition::IDEF_UPDATE_TYPE::Static;
507 
508 private:
509  bool m_bSkipNestedLinkedDefinitions = false;
511 private:
512  /////////////////////////////////////////////////////////////
513  //
514  // linked instance definition internals
515  //
516 private:
517  ON_FileReference m_linked_file_reference;
518 
519  // For V5 3dm archive compatibility.
520  // Set as needed by the Write() function for new idefs and saved if the idef is read from a V5 file.
521 private:
522  mutable ON_CheckSum m_linked_file_V5_checksum = ON_CheckSum::UnsetCheckSum;
523 private:
524  bool Internal_SetLinkedFileReference(
525  ON_InstanceDefinition::IDEF_UPDATE_TYPE linked_definition_type,
526  const ON_FileReference& linked_file_reference,
527  ON_CheckSum V5_checksum
528  );
529 
530  // See comment for Internal_ReferencedComponentSettings() function.
531 private:
532  mutable class ON_ReferencedComponentSettings* m_linked_idef_component_settings = nullptr;
533 
534 public:
535 
536  /// <summary>
537  /// ON_InstanceDefinition::LinkedComponentStates specifies how model components
538  /// (layers, materials, dimension styles, ...) from linked instance defintion files
539  /// are appear in the active model.
540  /// </summary>
541  enum class eLinkedComponentAppearance : unsigned char
542  {
543  ///<summary>
544  /// This is the only valid layer style when the instance definition type is
545  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::Static or
546  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::LinkedAndEmbedded.
547  /// This style is not valid when the instance definition type
548  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked.
549  ///</summary>
550  Unset = 0,
551 
552  ///<summary>
553  /// Model components (layers, materials, dimension styles, ...) from
554  /// linked instance definition files are embedded as ordinary components
555  /// in the active model.
556  /// This layer style may be used when the instance definition type is
557  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked.
558  ///</summary>
559  Active = 1,
560 
561  ///<summary>
562  /// Layers from the linked instance definition are reference components in the model.
563  /// This is the default layer style when the instance definition type is
564  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked.
565  /// This layer style may be used when the instance definition type is
566  /// ON_InstanceDefinition::IDEF_UPDATE_TYPE::Linked.
567  ///</summary>
568  Reference = 2
569  };
570 
571  static ON_InstanceDefinition::eLinkedComponentAppearance LinkedComponentAppearanceFromUnsigned(
572  unsigned int linked_component_appearance_as_unsigned
573  );
574 
575  ON_InstanceDefinition::eLinkedComponentAppearance LinkedComponentAppearance() const;
576 
577  bool SetLinkedComponentAppearance(
578  ON_InstanceDefinition::eLinkedComponentAppearance linked_component_appearance
579  );
580 
581 private:
583 
584 public:
585 
586  /*
587  Returns:
588  A SHA-1 hash of these instance defintions properties:
589 
590  InstanceGeometryIdList()
591  BoundingBox()
592  UnitSystem()
593  InstanceDefinitionType()
594  LinkedFileReference()
595  LinkedComponentAppearance()
596  */
597  const ON_SHA1_Hash GeometryContentHash() const;
598 
599  /*
600  Returns:
601  A SHA-1 hash of these instance defintions properties
602  Description()
603  URL()
604  URL_Tag()
605  and all the properties that contribute to the GeometryContentHash().
606  */
607  const ON_SHA1_Hash ContentHash() const;
608 
609 private:
610  void Internal_AccumulateHash() const;
611 
612 private:
613  // Internal_AccumulateHash() uses lazy evaluation to set m_geometry_content_hash when needed.
614  mutable ON_SHA1_Hash m_geometry_content_hash = ON_SHA1_Hash::ZeroDigest;
615 
616  // Internal_AccumulateHash() uses lazy evaluation to set m_content_hash when needed.
617  mutable ON_SHA1_Hash m_content_hash = ON_SHA1_Hash::ZeroDigest;
618 
619 private:
620  // Increments content version number and sets hashes to ON_SHA1_Hash::ZeroDigest.
621  void Internal_ContentChanged();
622 
623 private:
624  unsigned char m_reserved2A = 0;
625  unsigned char m_reserved2B = 0;
626  unsigned char m_reserved2C = 0;
627 
628 private:
629  unsigned int m_reserved1 = 0;
630 
631 private:
632  ON__UINT_PTR m_reserved_ptr = 0;
633 };
634 
635 #if defined(ON_DLL_TEMPLATE)
636 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_InstanceDefinition*>;
637 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_InstanceDefinition>;
638 #endif
639 
640 /*
641 Description:
642  An ON_InstanceRef is a reference to an instance definition
643  along with transformation to apply to the definition.
644 See Also:
645  ON_InstanceRef
646 */
647 class ON_CLASS ON_InstanceRef : public ON_Geometry
648 {
649  ON_OBJECT_DECLARE(ON_InstanceRef);
650 
651 public:
652  ON_InstanceRef() = default;
653  ~ON_InstanceRef() = default;
654  ON_InstanceRef(const ON_InstanceRef&) = default;
655  ON_InstanceRef& operator=(const ON_InstanceRef&) = default;
656 
657 public:
658  /////////////////////////////////////////////////////////////
659  //
660  // virtual ON_Object overrides
661  //
662  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
663  bool Write(
664  ON_BinaryArchive& binary_archive
665  ) const override;
666  bool Read(
667  ON_BinaryArchive& binary_archive
668  ) override;
669  ON::object_type ObjectType() const override;
670 
671  /////////////////////////////////////////////////////////////
672  //
673  // virtual ON_Geometry overrides
674  //
675  int Dimension() const override;
676 
677  // virtual ON_Geometry GetBBox override
678  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
679 
680  bool Transform(
681  const ON_Xform& xform
682  ) override;
683 
684  // virtual ON_Geometry::IsDeformable() override
685  bool IsDeformable() const override;
686 
687  // virtual ON_Geometry::MakeDeformable() override
688  bool MakeDeformable() override;
689 
690  /////////////////////////////////////////////////////////////
691  //
692 
693  // Unique id of the instance definition (ON_InstanceDefinition)
694  // in the instance definition table that defines the geometry
695  // used by this reference.
696  ON_UUID m_instance_definition_uuid = ON_nil_uuid;
697 
698  // Transformation for this reference.
700 
701  // Bounding box for this reference.
702  ON_BoundingBox m_bbox;
703 
704 #if 0
705 public:
706  /*
707  Remove all reference to the nested linked idef information.
708  */
709  void ClearReferenceToNestedLinkedIdef();
710 
711  /*
712  Returns:
713  true
714  if input was valid and the reference to the nested linked idef was set.
715  false
716  if reference to the nested linked idef was not set.
717  */
718  bool SetReferenceToNestedLinkedIdef(
719  const ON_UUID& parent_idef_uuid,
720  const ON_FileReference& parent_reference_file,
721  const ON_FileReference& nested_reference_file
722  );
723 
724  /*
725  Parameters:
726  parent_idef_uuid - [in]
727  The peristent id of the parent idef that contains the (possibly deeply nested)
728  instance definion this reference refers to.
729  parent_reference_file - [in]
730  the file for the parent idef.
731  nested_reference_file - [in]
732  if the referenced idef is itself linked, nested_reference_file identifies
733  the file.
734 
735  Returns:
736  True if this is a reference to a nested linked idef.
737  */
738  bool GetReferenceToNestedLinkedIdef(
739  ON_UUID& parent_idef_uuid,
740  ON_FileReference& parent_reference_file,
741  ON_FileReference& nested_reference_file
742  ) const;
743 
744  /*
745  Returns:
746  True if this is a reference to a nested linked idef.
747  */
748  bool ContainsReferenceToNestedLinkedIdef() const;
749 
750 private:
751  /////////////////////////////////////////////////////////////
752  //
753  // Additional information used when this reference is to
754  // an instance definition that is nested inside an ordinary
755  // linked instance definition.
756  //
757  // For example, if
758  // idefA = linked instance defintion referencing file A.
759  // idefX = any type of instance definition found in idefA.
760  //
761  // iref = model geometry reference to idefX.
762  //
763  // When A is not a 3dm file or the 3dm id of idefX is
764  // in use in the current model, the id of idefX will change
765  // every time A is read. This means saving the value of
766  // iref.m_instance_definition_uuid is not sufficient to identify
767  // idefX. In this case, the additional information
768  //
769  // iref.m_bReferenceToNestedLinkedIdef = true
770  // iref.m_parent_idef_uuid = idefA.Id()
771  // iref.m_parent_reference_file = idefA.FileReference().
772  // iref.m_nested_reference_file = idefX.FileReference().
773  //
774  // is used to identify idefX in a peristent way.
775  //
776  bool m_bReferenceToNestedLinkedIdef = false;
777  ON_UUID m_parent_idef_uuid = ON_nil_uuid; // persistent id
778  ON_FileReference m_parent_reference_file = ON_FileReference::Unset;
779  ON_FileReference m_nested_reference_file = ON_FileReference::Unset;
780 #endif
781 
782 public:
783  // Tolerance to use for flagging instance xforms
784  // as singular.
785  // A valid ON_InstanceRef.m_xform satisfies:
786  // true == (m_xform.Inverse()*m_xform).IsIdentity(ON_InstanceRef::SingularTransformationTolerance)
787  static const double SingularTransformationTolerance;
788 };
789 
790 #endif
ON_UUID is a 16 byte universally unique identifier.
Definition: opennurbs_uuid.h:32
The ON_ModelComponent class is a base class for all components in a model and manages the index...
Definition: opennurbs_model_component.h:24
This is the only valid layer style when the instance definition type is ON_InstanceDefinition::IDEF_U...
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
Definition: opennurbs_instance.h:20
Definition: opennurbs_sha1.h:19
An ON_InstanceDefinition defines the geometry used by instance references.
Definition: opennurbs_instance.h:139
ON_Object array is used to store lists of classes that are derived from ON_Object. It differs from ON_ClassArray in that the virtual ON_Object::MemoryRelocate function is called when growing the dynamic array requires changing the location of the memory buffer used to store the elements in the array.
Definition: opennurbs_array.h:725
Definition: opennurbs_string.h:2020
Base class for all geometry classes that must provide runtime class id. Provides interface for common...
Definition: opennurbs_geometry.h:37
Definition: opennurbs_layer.h:20
static const ON_Xform IdentityTransformation
ON_Xform IdentityTransformation diagonal = (1,1,1,1)
Definition: opennurbs_xform.h:32
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
An ON_InstanceRef is a reference to an instance definition along with transformation to apply to the ...
Definition: opennurbs_instance.h:613
Definition: opennurbs_archive.h:478
Definition: opennurbs_string.h:3739
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
IDEF_UPDATE_TYPE
Definition: opennurbs_instance.h:148
Definition: opennurbs_model_component.h:1622
Definition: opennurbs_string.h:341
eLinkedComponentAppearance
ON_InstanceDefinition::LinkedComponentStates specifies how model components (layers, materials, dimension styles, ...) from linked instance defintion files are appear in the active model.
Definition: opennurbs_instance.h:510
static const ON_FileReference Unset
Definition: opennurbs_file_utilities.h:1128
static const ON_SHA1_Hash ZeroDigest
Definition: opennurbs_sha1.h:22
Definition: opennurbs_file_utilities.h:1125