opennurbs_model_component.h
1 /*
2 //
3 // Copyright (c) 1993-2012 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_COMPONENT_INC_)
17 #define ON_MODEL_COMPONENT_INC_
18 
19 /*
20 Description:
21  The ON_ModelComponent class is a base class for all components in a
22  model and manages the index, id and other information common to all
23  components in a model.
24 */
25 class ON_CLASS ON_ModelComponent : public ON_Object
26 {
27  ON_OBJECT_DECLARE(ON_ModelComponent);
28 
29 public:
30  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
31 
32  void Dump(
33  ON_TextLog&
34  ) const override;
35 
36  unsigned int SizeOf() const override;
37 
38 
39  ON__UINT32 DataCRC(
40  ON__UINT32 current_remainder
41  ) const override;
42 
43  ON_UUID ModelObjectId() const override;
44 
45 public:
46 
47 #pragma region RH_C_SHARED_ENUM [ON_ModelComponent::Type] [Rhino.DocObjects.ModelComponentType] [public:byte]
48  ///<summary>
49  ///The ON_ModelComponent::Type enum has a value for each explicit component type
50  ///and two special values, Unset and Mixed. Use an ON_ModelComponentTypeIterator
51  ///instance to iterate over the ON_ModelComponent::Type values.
52  ///</summary>
53  enum class Type : unsigned char
54  {
55  ///<summary>No value set.</summary>
56  Unset = 0,
57  ///<summary>Embedded image (bitmap) components.</summary>
58  Image = 1,
59  ///<summary>Texture mapping.</summary>
60  TextureMapping = 2,
61  ///<summary>Render material.</summary>
62  RenderMaterial = 3,
63  ///<summary>Line pattern (linetype).</summary>
64  LinePattern = 4,
65  ///<summary>Layer.</summary>
66  Layer = 5,
67  ///<summary>Group.</summary>
68  Group = 6,
69  ///<summary>Text style.</summary>
70  TextStyle = 7,
71  ///<summary>AnnotationDimension style.</summary>
72  DimStyle = 8,
73  ///<summary>Render light.</summary>
74  RenderLight = 9,
75  ///<summary>Hatch pattern.</summary>
76  HatchPattern = 10,
77  ///<summary>Instance definition.</summary>
78  InstanceDefinition = 11,
79  ///<summary>Model objects (points, curves, surfaces, ..., annotation, page details, ...), including objects referenced by instance definitions.</summary>
80  ModelGeometry = 12,
81  ///<summary>History record.</summary>
82  HistoryRecord = 13,
83  ///<summary>Multiple component types.
84  /// Used when a component type filter must include all explicit component types.
85  ///</summary>
86  Mixed = 0xFE
87  };
88 #pragma endregion
89 
90  static ON_ModelComponent::Type ComponentTypeFromUnsigned(
91  unsigned int component_type_as_unsigned
92  );
93 
94  static const ON_wString ComponentTypeToString(
96  );
97 
98  /*
99  Parameters:
100  component_type - [in]
101  Returns:
102  True if component_type is a valid enum value,
103  and not equal to ON_ModelComponent::Type::Unset.
104  */
105  static bool ComponentTypeIsValid(
106  ON_ModelComponent::Type component_type
107  );
108 
109  /*
110  Parameters:
111  component_type - [in]
112  Returns:
113  True if component_type is a valid enum value,
114  and not equal to ON_ModelComponent::Type::Unset,
115  and not equal to ON_ModelComponent::Type::Mixed.
116  */
117  static bool ComponentTypeIsValidAndNotMixed(
118  ON_ModelComponent::Type component_type
119  );
120 
121  /*
122  Parameters:
123  component_type - [in]
124  Returns:
125  True if component's of the specified type require uniquen names.
126  Remarks:
127  In general, component names ignore case and parent when testing for
128  equality.
129  However, there are exceptions. Use
130  ON_ModelComponent::UniqueNameIncludesParent() and
131  ON_ModelComponent::UniqueNameIgnoresCase()
132  to test for exceptions.
133  */
134  static bool UniqueNameRequired(
135  ON_ModelComponent::Type component_type
136  );
137 
138  /*
139  Parameters:
140  component_type - [in]
141  Returns:
142  True if objects with the same name and different parents are considered
143  to have a unique name. This typically means the user interface for the
144  object names is some type of tree.
145  Remarks:
146  Currently, layers are the only object type where this property is true.
147  */
148  static bool UniqueNameIncludesParent(
149  ON_ModelComponent::Type component_type
150  );
151 
152  /*
153  Parameters:
154  component_type - [in]
155  Returns:
156  True if component names ignore case when testing for equality.
157  Remarks:
158  Currently all other component types except for groups ignore
159  case when testing for equality.
160  */
161  static bool UniqueNameIgnoresCase(
162  ON_ModelComponent::Type component_type
163  );
164 
165  static bool IndexRequired(
166  ON_ModelComponent::Type component_type
167  );
168 
169  /*
170  Returns:
171  True if a componenent name can begin with the first code point.
172  Remarks:
173  Component names cannot begin with a (, ), [, ], {, }, or space.
174  These brackets can be the second or later code points.
175  A space can be an interior code point.
176  */
177  static bool IsValidComponentNameFirstCodePoint(
178  ON__UINT32 unicode_code_point
179  );
180 
181  /*
182  Parameters:
183  length - [in]
184  number of wchar_t elements in candidate_component_name[] or -1
185  if it is a null terminated string.
186  candidate_component_name - [in]
187  The first code point is decoded from this string
188  and passed to ON_ModelComponent::IsValidComponentNameFirstCodePoint().
189  Returns:
190  True if a componenent name can begin with the first code point.
191  Remarks:
192  Component names cannot begin with a (, ), [, ], {, }, or space.
193  These brackets can be the second or later code points.
194  A space can be an interior code point.
195  */
196  static bool IsValidComponentNameFirstCodePoint(
197  int length,
198  const wchar_t* candidate_component_name
199  );
200 
201  static bool IsValidComponentName(
202  const wchar_t* candidate_component_name
203  );
204 
205  static bool IsValidComponentName(
206  const ON_wString& candidate_component_name
207  );
208 
209  static bool IsValidComponentName(
210  size_t length,
211  const wchar_t* candidate_component_name
212  );
213 
214  /*
215  Parameters:
216  model_component - [in]
217  model_manfest - [in]
218  current model contents
219  valid_name - [in]
220  Valid name for this component in a model with the specified manifest.
221  Returns:
222  true: model_component.Name() is valid
223  false: model_component.Name() is not valid
224  */
225  static bool IsValidComponentName(
226  const class ON_ComponentManifest& model_manfest,
227  const ON_ModelComponent& model_component,
228  bool bPermitReferencePrefix,
229  ON_wString& valid_name
230  );
231 
232 public:
233  static const ON_ModelComponent Unset;
234 
235  ON_ModelComponent() ON_NOEXCEPT;
236 
237  ~ON_ModelComponent() = default;
238 
239  // Locked status of source attributes is not copied to permit copy and modify operations.
240  // Runtime serial number and content version number are not copied.
242  const ON_ModelComponent& source
243  );
244 
245  /*
246  Description:
247  Sets and locks the component type attribute.
248  Parameters:
249  component_type - [in]
250  */
252  ON_ModelComponent::Type component_type
253  ) ON_NOEXCEPT;
254 
255  // Locked status of source attributes is not copied to permit copy and modify operations.
257  ON_ModelComponent::Type component_type,
258  const ON_ModelComponent& source
259  ) ON_NOEXCEPT;
260 
261  /*
262  Remarks:
263  operator= will not change locked destination attributes.
264  Locked status of source attributes is not copied to permit copy and modify operations.
265  */
266  ON_ModelComponent& operator=(const ON_ModelComponent& source);
268  /*
269  The ON_ModelComponent::Attributes enum is used to set bits that identify
270  model component attributes.
271  */
272  enum Attributes : unsigned int
273  {
274  NoAttributes = 0U,
276  ComponentSerialNumberAttribute = 0x0001U,
277  TypeAttribute = 0x0002U,
278  ModelSerialNumberAttribute = 0x0004U,
279  IdAttribute = 0x0008U,
280  IndexAttribute = 0x0010U,
281  NameAttribute = 0x0020U,
282  ParentIdAttribute = 0x0040U,
283  DeletedNameAttribute = 0x0080U,
284  ComponentStatusAttribute = 0x0100U,
285 
286  // Default model attributes saved in binary archives.
287  // Id, ParentId, Name, Index
288  // Do not include SystemComponentAttribute in BinaryArchiveAttributes
289  BinaryArchiveAttributes = 0x78U,
290 
291  // Do not include SystemComponentAttribute in AllAttributes
292  AllAttributes = 0x1FFU,
293 
294  SystemComponentAttribute = 0x8000U
295  };
296 
297  unsigned int CopyFrom(
298  const ON_ModelComponent& src,
299  unsigned int attributes_filter
300  );
301 
302  bool WriteModelComponentAttributes(
303  class ON_BinaryArchive& archive,
304  unsigned int attributes_filter
305  ) const;
306 
307  bool ReadModelComponentAttributes(
308  class ON_BinaryArchive& archive
309  );
310 
311  ///////////////////////////////////////////////////////////////////////////////
312  //
313  // Model Serial Number interface
314  //
315  // The ModelSerialNumber() identifies the model that manages the component.
316  // If the component is from some type of reference model, then one or both of
317  // the reference model serial number and InstanceDefinitionModelSerialNumber()
318  // identify the source model.
319  //
320 
321  /*
322  Description:
323  Specify the model that is managing this component.
324  Parameters:
325  model_serial_number - [in]
326  In Rhino, this is the document runtime serial number.
327  Returns:
328  true if the model_serial_number value was changed to component_model_serial_number or is already equal to component_model_serial_number.
329  false if the model_serial_number value is locked and component_model_serial_number != locked value.
330  */
331  bool SetModelSerialNumber(
332  unsigned int model_serial_number
333  );
334 
335  /*
336  Description:
337  Specify the model that is managing this component.
338  Parameters:
339  model_serial_number - [in]
340  In Rhino, this is the document runtime serial number.
341  reference_model_serial_number - [in]
342  In Rhino, this is the worksession reference model serial number.
343  instance_definition_model_serial_number - [in]
344  In Rhino, this is the linked instance definition model serial number.
345  Returns:
346  true if the model_serial_number value was changed to component_model_serial_number or is already equal to component_model_serial_number.
347  false if the model_serial_number value is locked and component_model_serial_number != locked value.
348  */
349  bool SetModelSerialNumber(
350  unsigned int model_serial_number,
351  unsigned int reference_model_serial_number,
352  unsigned int instance_definition_model_serial_number
353  );
354 
355  /*
356  Returns:
357  A value identifing the model that manages this component.
358  Remarks:
359  If the component is being managed by a model, this value identifies the model.
360  In Rhino, this value is the document runtime serial number.
361  Typically this value is set and locked by the code that adds
362  a component to a model.
363  This value is copied by the copy constructor and operator=.
364  This value is not saved in .3dm archives.
365  */
366  unsigned int ModelSerialNumber() const;
367 
368  /*
369  Returns:
370  When a compoent is in a model for reference, this value identifies the
371  reference model.
372  Remarks:
373  Reference components are not saved in .3dm archives.
374  Typically this value is set and locked by the code that adds
375  a component to a model.
376  This value is copied by the copy constructor and operator=.
377  This value is not saved in .3dm archives.
378 
379  In Rhino, this value is a worksession model runtime serial number and
380  these values are used.
381  0: not from a worksession reference model
382  1: from an unidentified reference model
383  2-1000: reserved for future use
384  >1000: worksession reference model serial number
385  */
386  unsigned int ReferenceModelSerialNumber() const;
387 
388  /*
389  Returns:
390  When a component is in a model as part of the information required
391  for a linked instance definition, this value identifies the the linked
392  instance definition reference model.
393  Remarks:
394  Reference components are not saved in .3dm archives.
395  Typically this value is set and locked by the code that adds
396  a component to a model.
397  This value is copied by the copy constructor and operator=.
398  This value is not saved in .3dm archives.
399 
400  In Rhino, this value is a linked instance definition runtime serial number
401  and these values are used..
402  0: Active model component.
403  1-1000: reserved for future use
404  >1000: linked instance defintion serial number
405  */
406  unsigned int InstanceDefinitionModelSerialNumber() const;
407 
408  /*
409  Description:
410  Sets the model serial number, reference model serial number and instance
411  definition model serial number values to 0 and flags these values
412  as unset.
413  */
414  bool ClearModelSerialNumber();
415 
416  /*
417  Description:
418  Calling LockModelSerialNumber() will prohibit future changes to the
419  ModelSerialNumber(), ReferenceModelSerialNumber(), and
420  InstanceDefinitionModelSerialNumber() attributes.
421  */
422  void LockModelSerialNumber();
423 
424  /*
425  Returns:
426  True if the ModelSerialNumber(), ReferenceModelSerialNumber(), and
427  InstanceDefinitionModelSerialNumber() attributes are locked.
428  */
429  bool ModelSerialNumberIsLocked() const;
430 
431  /*
432  Returns:
433  True if the ModelSerialNumber(), ReferenceModelSerialNumber(), and
434  InstanceDefinitionModelSerialNumber() attributes are set.
435  */
436  bool ModelSerialNumberIsSet() const;
437 
438  /*
439  Returns
440  True if ReferenceModelSerialNumber() or InstanceDefinitionModelSerialNumber() are not zero.
441  */
442  bool IsReferenceComponent() const;
443 
444  ///////////////////////////////////////////////////////////////////////////////
445  //
446  // Type interface
447  //
448 
449  /*
450  Returns:
451  Value of the Type attribute.
452  Remarks:
453  If the component is in a model, then the component_type is unique for all components
454  of identical type in the model and is locked.
455  */
456  ON_ModelComponent::Type ComponentType() const;
457 
458  /*
459  Parameters:
460  component_component_type - [in]
461  Returns:
462  true if the component_type value was changed to component_component_type or is already equal to component_component_type.
463  false if the component_type value is locked and component_component_type != locked value.
464  */
465  bool SetComponentType(
466  ON_ModelComponent::Type component_component_type
467  );
468 
469  /*
470  Description:
471  Set the model serial number value to the ON_ModelComponent::Unset.Type()
472  and change the state so TypeIsSet() returns false.
473  */
474  bool ClearComponentType();
475 
476  /*
477  Description:
478  Calling LockType() will prhibit future changes to the Type attribute.
479  */
480  void LockComponentType();
481 
482  /*
483  Returns:
484  True if the Type attribute is locked.
485  */
486  bool ComponentTypeIsLocked() const;
487 
488  /*
489  Returns:
490  True if the Type attribute is set.
491  */
492  bool ComponentTypeIsSet() const;
493 
494  ///////////////////////////////////////////////////////////////////////////////
495  //
496  // Id interface
497  //
498  // The component id is intended to be unique in the context of a model.
499  //
500 
501  /*
502  Returns:
503  Value of the Id attribute.
504  Remarks:
505  If the component is in a model, then the id is unique for all components in
506  the model and is locked.
507  */
508  const ON_UUID& Id() const;
509 
510  bool IdIsNil() const;
511  bool IdIsNotNil() const;
512 
513  /*
514  Parameters:
515  component_id - [in]
516  Returns:
517  true if the id value was changed to component_id or is already equal to component_id.
518  false if the id value is locked and component_id != locked value.
519  */
520  bool SetId(
521  const ON_UUID& component_id
522  );
523 
524  /*
525  Description:
526  Sets the id to a new value created by ON_CreateUuid().
527  Returns:
528  ON_nil_uuid: Id is locked.
529  Otherwise the value of the new id.
530  */
531  const ON_UUID& SetId();
532 
533  /*
534  Description:
535  If the it is nil, call SetId().
536  */
537  const ON_UUID& IfIdIsNilSetId();
538 
539  /*
540  Description:
541  Sets the id to a new value created by ON_CreateUuid() and locks the
542  id attribute so it cannot be changed.
543  Returns:
544  ON_nil_uuid: Id is locked.
545  Otherwise the value of the new id.
546  */
547  const ON_UUID& SetAndLockId();
548 
549 
550  /*
551  Description:
552  Set the component id value to the ON_ModelComponent::Unset.ModelComponentId()
553  and change the state so ModelComponentIdIsSet() returns false.
554  */
555  bool ClearId();
556 
557  /*
558  Description:
559  Calling LockModelComponentId() will prhibit future changes to the ModelComponentId attribute.
560  */
561  void LockId();
562 
563  /*
564  Returns:
565  True if the ModelComponentId attribute is locked.
566  */
567  bool IdIsLocked() const;
568 
569  /*
570  Returns:
571  True if the ModelComponentId attribute is set.
572  */
573  bool IdIsSet() const;
574 
575 
576  ///////////////////////////////////////////////////////////////////////////////
577  //
578  // Index interface
579  //
580  // When a component is managed by a model, the component index is identifies
581  // the component within the context of that model.
582  //
583 
584  /*
585  Returns:
586  Value of the runtime model component index attribute.
587  Remarks:
588  If the component is in a model, then the index is unique for all components
589  of identical type in the model and is locked.
590  If the index has not been set, ON_UNSET_INT_INDEX is returned.
591  The Index() value can change when saved in an archive (.3dm file).
592  Use the Id() when you need to reference model compoenents in an archive.
593  */
594  int Index() const;
595 
596  /*
597  Returns:
598  Value of the model component index attribute.
599  Parameters:
600  unset_index_value - [in]
601  Value to return if the index has not been set.
602  ON_UNSET_INT_INDEX or indices of default components are often
603  used for this parameter.
604  Returns:
605  IndexIsSet() ? Index() : unset_index_value;
606  Remarks:
607  If the component is in a model, then the index is unique for all components
608  of identical type in the model and is locked.
609  */
610  int Index(
611  int unset_index_value
612  ) const;
613 
614  /*
615  Parameters:
616  component_index - [in]
617  Returns:
618  true if the index value was changed to component_index or is already equal to component_index.
619  false if the index value is locked and component_index != locked value.
620  */
621  bool SetIndex(
622  int component_index
623  );
624 
625  /*
626  Description:
627  Set the component index value to the ON_ModelComponent::Unset.ModelComponentIndex()
628  and change the state so ModelComponentIndexIsSet() returns false.
629  */
630  bool ClearIndex();
631 
632  /*
633  Description:
634  Calling LockModelComponentIndex() will prhibit future changes to the ModelComponentIndex attribute.
635  */
636  void LockIndex();
637 
638  /*
639  Returns:
640  True if the ModelComponentIndex attribute is locked.
641  */
642  bool IndexIsLocked() const;
643 
644  /*
645  Returns:
646  True if the ModelComponentIndex attribute is set.
647  */
648  bool IndexIsSet() const;
649 
650  ///////////////////////////////////////////////////////////////////////////////
651  //
652  // Parent object interface
653  //
654  //
655  const ON_UUID& ParentId() const;
656 
657  bool ParentIdIsNil() const;
658  bool ParentIdIsNotNil() const;
659 
660  bool SetParentId(
661  const ON_UUID& parent_id
662  );
663  bool ClearParentId();
664  void LockParentId();
665  bool ParentIdIsLocked() const;
666  bool ParentIdIsSet() const;
667 
668  ///////////////////////////////////////////////////////////////////////////////
669  //
670  // Model component locked, hidden, deleted, selected, highlights, damaged, ... status interface
671  //
672  //
673  ON_ComponentStatus ModelComponentStatus() const;
674 
675  bool SetModelComponentStatus(
676  ON_ComponentStatus component_status
677  );
678 
679  bool ClearModelComponentStatus();
680 
681  void LockModelComponentStatus();
682 
683  bool ModelComponentStatusIsLocked() const;
684 
685  bool ModelComponentStatusIsSet() const;
686 
687  /*
688  Returns:
689  The component's deleted state.
690  Remarks:
691  Deleted components can be undeleted.
692  */
693  bool IsDeleted() const;
694 
695  /*
696  Parameters:
697  bDeleted - [in]
698  manifest - [in/out]
699  optional manifest to update
700  Returns:
701  True if the component's deleted state was changed from
702  !bDeleted to bDeleted and all other name and manifest information
703  was updated as expected.
704  */
705  bool SetDeletedModelComponentState(
706  bool bDeleted,
707  class ON_ComponentManifest* manifest
708  );
709 
710  /*
711  Returns:
712  The component's user interface locked state.
713  Remarks:
714  This is a user interface locked state and does not effect
715  changing the component values.
716  */
717  bool IsLocked() const;
718 
719  void SetLockedModelComponentState(
720  bool bLocked
721  );
722 
723  /*
724  Returns:
725  The component's user interface hidden state.
726  Remarks:
727  This is a user interface hidden state and does not effect
728  changing the component values.
729  */
730  bool IsHidden() const;
731 
732  void SetHiddenModelComponentState(
733  bool bHidden
734  );
735 
736 
737  ///////////////////////////////////////////////////////////////////////////////
738  //
739  // Name interface
740  //
741  //
742 
743  /*
744  Returns:
745  Value of the Name attribute.
746  Remarks:
747  If the component is in a model, then the name is unique among all components in
748  the model. Names are formatted as reference : parent::leaf.
749  For example in "A.3dm : Z", "A.3dm" is the reference and "Z" is the leaf.
750  For a layer full path "X::Y::Z", "X::Y" is the parent and "Z" is the leaf.
751  For most models, only the leaf is present in the name.
752  The reference portion appears when a model component originates in a reference file
753  (a linked instance definition with reference component names or a worksession reference).
754  Components with a tree hierarchy, like layers, can have a parent and leaf.
755  */
756  const ON_wString Name() const;
757 
758  const ON_wString DeletedName() const;
759 
760  /*
761  Parameters:
762  component_name - [out]
763  Returns:
764  A pointer to the string in component_name.
765  */
766  const wchar_t* GetName(
767  ON_wString& component_name
768  ) const;
769 
770  /*
771  Description:
772  Get a platform independent hash of the name suitable for equality testing
773  and binary searching.
774  When testing for equality or doing binary searches, using ON_NameHash values
775  is faster than using the CompareName or ON_wString::CompareAttributeName.
776  */
777  const ON_NameHash& NameHash() const;
778  const ON_NameHash& DeletedNameHash() const;
779 
780  /*
781  Parameters:
782  new_name - [in]
783  Returns:
784  If new_name is empty or a valid component name, then name hash this component would have if SetName(new_name) were called.
785  If new_name is not valid, then ON_NameHash::UnsetNameHash is returned.
786  Remarks:
787  This function trims leading and trailing white space, includes the parent id when
788  ON_ModelComponent::UniqueNameIncludesParent(ComponentType()) is true,
789  and uses ON_ModelComponent::IsValidComponentName() to determine if a
790  non-empty name is valid.
791  */
792  const ON_NameHash NewNameHash(
793  const wchar_t* new_name
794  ) const;
796  /*
797  Description:
798  Returns the string " : ". This is the string Rhino uses
799  to separate the reference file names from and model component names
800  read from those files.
801 
802  Example:
803  File A.3dm contains a layer "alpha", dimstyle "a1", an embedded block "A_blk",
804  and a linked block "X" referencing B.3dm with reference component names.
805  File B.3dm contains a layer "beta", dimstyle "b1", an embedded block "B_blk",
806  and linked block "Y" referencing C.3dm.
807  File C.3dm contains a layer gamma, dimstyle "c1", an embedded block "C_blk",
808  and linked block "Z" referencing D.3dm.
809  File D.3dm contains a layer "delta", dimstyle "d1", and an embedded block "D_blk".
810 
811  Reading file A.3dm will craete the following components:
812  Layers:
813  alpha
814  X>B.3dm
815  beta (full layer path "X>B.3dm::beta")
816  Y>C.3dm
817  gamma (full layer path "Y>C.3dm::gamma")
818  Z>D.3dm
819  delta (full layer path "Z>D.3dm::delta")
820  Blocks:
821  X
822  A_blk
823  Y
824  B.3dm : B_blk
825  Z
826  C.3dm : C_blk
827  D.3dm : D_blk
828  Annotation styles
829  a1
830  B.3dm : b1
831  C.3dm : c1
832  D.3dm : d1
833 
834  See Also:
835  ON_ModelComponent::ReferencePrefixDelimiter = " : "
836  ON_ModelComponent::ReferencePrefixSeparator = ">"
837  ON_ModelComponent::NamePathSeparator = "::"
838  */
839  static const ON_wString ReferencePrefixDelimiter;
840 
841  /*
842  Description:
843  Returns the string ">". This is the string Rhino uses
844  to separate the block definition name and linked file name
845  in grandparent layers.
846 
847  Example:
848  File A.3dm contains a layer "alpha", dimstyle "a1", an embedded block "A_blk",
849  and a linked block "X" referencing B.3dm with reference component names.
850  File B.3dm contains a layer "beta", dimstyle "b1", an embedded block "B_blk",
851  and linked block "Y" referencing C.3dm.
852  File C.3dm contains a layer gamma, dimstyle "c1", an embedded block "C_blk",
853  and linked block "Z" referencing D.3dm.
854  File D.3dm contains a layer "delta", dimstyle "d1", and an embedded block "D_blk".
855 
856  Reading file A.3dm will craete the following components:
857  Layers:
858  alpha
859  X>B.3dm
860  beta (full layer path "X>B.3dm::beta")
861  Y>C.3dm
862  gamma (full layer path "Y>C.3dm::gamma")
863  Z>D.3dm
864  delta (full layer path "Z>D.3dm::delta")
865  Blocks:
866  X
867  A_blk
868  Y
869  B.3dm : B_blk
870  Z
871  C.3dm : C_blk
872  D.3dm : D_blk
873  Annotation styles
874  a1
875  B.3dm : b1
876  C.3dm : c1
877  D.3dm : d1
878 
879  See Also:
880  ON_ModelComponent::ReferencePrefixDelimiter = " : "
881  ON_ModelComponent::ReferencePrefixSeparator = ">"
882  ON_ModelComponent::NamePathSeparator = "::"
883  */
884  static const ON_wString ReferencePrefixSeparator;
885 
886 
887  /*
888  Description:
889  Returns the string "::". This is the string Rhino uses in layer
890  full path names to separate the names of individual layers.
891 
892  Example:
893  If a model has layers
894  A
895  B
896  C
897  then the full path names are
898  "A", "A::B", "A::B::C".
899 
900  See Also:
901  ON_ModelComponent::ReferencePrefixDelimiter = " : "
902  ON_ModelComponent::ReferencePrefixSeparator = ">"
903  ON_ModelComponent::NamePathSeparator = "::"
904  */
905  static const ON_wString NamePathSeparator;
906 
907  ///*
908  //Description:
909  //Parameters:
910  // reference_prefix - [in]
911  //Returns:
912  // The worksession component name reference prefix.
913  //Example:
914  // "[ A.3dm ]" = ON_ModelComponent::WorksessionReferencePrefix("A.3dm")
915  //*/
916  //static const ON_wString WorksessionReferencePrefix(
917  // const wchar_t* reference_prefix,
918  // bool bAppendReferencePrefixDelimiter
919  //);
920 
921 
922  /*
923  Description:
924  Test a string to see if its beginning matches the
925  string returned by ON_ModelComponent::NameReferenceDelimiter.
926  Parameters:
927  s - [in];
928  string to test.
929  Returns:
930  null:
931  The beginning of the string does not match ON_ModelComponent::NameReferenceDelimiter.
932  non-null:
933  The beginning of the string matches ON_ModelComponent::NameReferenceDelimiter.
934  The returned pointer is the first character in s after the last character
935  of the delimiter. Put another way, if the beginning of s matches
936  the string ON_ModelComponent::NameReferenceDelimiter, then the returned pointer is
937  s + ON_ModelComponent::NameReferenceDelimiter.Length().
938  */
939  static const wchar_t* IsReferencePrefixDelimiter(
940  const wchar_t* s
941  );
942 
943  /*
944  Description:
945  Test a string to see if its beginning matches the
946  string returned by ON_ModelComponent::NameReferenceSeparator.
947  Parameters:
948  s - [in];
949  string to test.
950  Returns:
951  null:
952  The beginning of the string does not match ON_ModelComponent::NameReferenceSeparator.
953  non-null:
954  The beginning of the string matches ON_ModelComponent::NameReferenceSeparator.
955  The returned pointer is the first character in s after the last character
956  of the delimiter. Put another way, if the beginning of s matches
957  the string ON_ModelComponent::NameReferenceSeparator, then the returned pointer is
958  s + ON_ModelComponent::NameReferenceSeparator.Length().
959  */
960  static const wchar_t* IsReferencePrefixSeparator(
961  const wchar_t* s
962  );
963 
964  /*
965  Description:
966  Test a string to see if its beginning matches the
967  string returned by ON_ModelComponent::NamePathSeparator.
968  Parameters:
969  s - [in];
970  string to test.
971  Returns:
972  null:
973  The beginning of the string does not match ON_ModelComponent::NamePathSeparator.
974  non-null:
975  The beginning of the string matches ON_ModelComponent::NamePathSeparator.
976  The returned pointer is the first character in s after the last character
977  of the delimiter. Put another way, if the beginning of s matches
978  the string ON_ModelComponent::NamePathSeparator, then the returned pointer is
979  s + ON_ModelComponent::NamePathSeparator.Length().
980  */
981  static const wchar_t* IsNamePathSeparator(
982  const wchar_t* s
983  );
984 
985  /*
986  Example:
987  If a full layer name is "A.3dm : X::Y::Z", then
988  reference_prefix = "A.3dm"
989  name_parent = "X::Y"
990  name_leaf = "Z"
991  */
992  static void SplitName(
993  const wchar_t* name,
994  ON_wString& reference_prefix,
995  ON_wString& name_parent,
996  ON_wString& name_leaf
997  );
998 
999  /*
1000  Parameters:
1001  name - [in]
1002  Example:
1003  If the name is "A.3dm : X", then "A.3dm" is returned.
1004  */
1005  static const ON_wString NameReferencePrefix(
1006  const wchar_t* name
1007  );
1008 
1009  /*
1010  Parameters:
1011  name - [in]
1012  bIncludeReference - [in]
1013  Example:
1014  If the name is "A.3dm>B.3dm : X::Y::Z" and bIncludeReference is true,
1015  then "A.3dm>B.3dm : X::Y" is returned.
1016  If the name is "A.3dm>B.3dm : X::Y::Z" and bIncludeReference is false,
1017  then "X::Y" is returned.
1018  */
1019  static const ON_wString NameParent(
1020  const wchar_t* name,
1021  bool bIncludeReference
1022  );
1023 
1024  /*
1025  Example:
1026  If the name is "A.3dm>B.3dm : X::Y::Z",
1027  then name_leaf = "Z" is returned.
1028  */
1029  static const ON_wString NameLeaf(
1030  const wchar_t* name
1031  );
1032 
1033  /*
1034  Parameters:
1035  name - [in]
1036  Example:
1037  If the name is "A.3dm : X", then "X" is returned.
1038  */
1039  static const ON_wString RemoveReferencePrefix(
1040  const wchar_t* name
1041  );
1042 
1043  /*
1044  Description:
1045  Remove all occurances of ON::NameReferenceDelimiter() from name.
1046  */
1047  static const ON_wString RemoveAllReferencePrefixDelimiters(
1048  const wchar_t* name
1049  );
1050 
1051  /*
1052  Description:
1053  Remove any trailing occurance of ON_ModelComponent::NameReferenceDelimiter from name.
1054  Example:
1055  "A.3dm" = ON_ModelComponent::RemoveTrailingRemoveReferencePrefixDelimiter("A.3dm : ");
1056  */
1057  static const ON_wString RemoveTrailingReferencePrefixDelimiter(
1058  const wchar_t* name
1059  );
1060 
1061  /*
1062  Description:
1063  Remove any trailing occurance of ON_ModelComponent::NameReferenceSeparator from name.
1064  */
1065  static const ON_wString RemoveTrailingReferencePrefixSeparator(
1066  const wchar_t* name
1067  );
1068 
1069  /*
1070  Description:
1071  Remove any trailing occurance of ON_ModelComponent::NamePathSeparator from name.
1072  */
1073  static const ON_wString RemoveTrailingNamePathSeparator(
1074  const wchar_t* name
1075  );
1076 
1077 
1078 
1079 private:
1080  const ON_NameHash& Internal_NameHash() const;
1081 
1082 public:
1083  /*
1084  Description:
1085  Expert user function that gets a pointer to the name.
1086  Returns:
1087  A pointer to the string that contains the name. This pointer
1088  must be used immediately and then discarded before any code
1089  can possibly call SetName() or the ON_ModelComponent destructor
1090  could be called.
1091  Remarks:
1092  About the only good use for this function is when a model compoenent is
1093  peristent and the name is needed for a formatted string. For any
1094  other use, call the Name() function and store the result in an
1095  ON_wString. This function is dangerous because the returned pointer
1096  will be invalid if SetName() is called.
1097  */
1098  const wchar_t* NameAsPointer() const;
1099 
1100  /*
1101  Returns:
1102  true if the name is unset or is set to the empty string.
1103  */
1104  bool NameIsEmpty() const;
1105 
1106  /*
1107  Returns:
1108  true if the name is set and the value is not the empty string.
1109  */
1110  bool NameIsNotEmpty() const;
1111 
1112  /*
1113  Parameters:
1114  component_name - [in]
1115  Leading and trailing nonzero unicode code points with values <= ON_wString::Space are ignored.
1116  Returns:
1117  true
1118  if the name attribute was changed to component_name or is already equal to component_name.
1119  false
1120  False is returned and no changes are made if
1121  the name attribute is locked and component_name != locked value
1122  or
1123  component_name is not empty and ON_ModelComponent::IsValidComponentName(component_name) is false.
1124  Remarks:
1125  If component_name is nullptr or the emtpy string, the NameIsSet() state will still be true.
1126  */
1127  bool SetName(
1128  const wchar_t* component_name
1129  );
1130 
1131  /*
1132  Description:
1133  Change the name of a component and optionally update a manifest.
1134  Parameters:
1135  new_name - [in]
1136  New name for the component.
1137  manifest - [in]
1138  nullptr or a manifest with an item for the component.
1139  */
1140  bool ChangeName(
1141  const wchar_t* new_name,
1142  class ON_ComponentManifest* manifest
1143  );
1144 
1145  /*
1146  Description:
1147  Set the component name value to the ON_ModelComponent::Unset.Name()
1148  and change the state so NameIsSet() and DeletedNameIsSet() both return false.
1149  */
1150  bool ClearName();
1151 
1152  /*
1153  Description:
1154  Calling LockName() will prohibit future changes to the Name attribute.
1155  */
1156  void LockName();
1157 
1158  /*
1159  Returns:
1160  True if the Name attribute is locked.
1161  */
1162  bool NameIsLocked() const;
1163 
1164  /*
1165  Returns:
1166  True if the name attribute is set.
1167  Remarks:
1168  At most one of NameIsSet() and DeletedNameIsSet() is true.
1169  A name can be set to the empty string.
1170  */
1171  bool NameIsSet() const;
1172 
1173  /*
1174  Returns:
1175  True if the deleted name attribute is set.
1176  Remarks:
1177  At most one of NameIsSet() and DeletedNameIsSet() is true.
1178  */
1179  bool DeletedNameIsSet() const;
1180 
1181  /*
1182  Description:
1183  If NameIsSet() is true, then the name is deleted in a waty that can be undone by calling UndeleteName() and
1184  the DeletedNameIsSet() property is changed to true.
1185 
1186  If NameIsSet() is false or NameIsLocked() is true, then nothing is changed.
1187 
1188  Note that a name can be set to the empty string and there is a difference between
1189  a name being set to the empty string and a name being unset.
1190  If you want to make the name attribute unset, call ClearName().
1191  */
1192  bool DeleteName();
1193 
1194  bool UndeleteName();
1195 
1196  void LockAllSettingsExceptName();
1197  bool SetLocalizedSystemComponentName(
1198  const wchar_t* system_component_localized_name
1199  );
1200 
1201  /*
1202  Parameters:
1203  other_name -[in]
1204  Returns:
1205  ON_wString::CompareAttributeName(this->Name(), other_name)
1206  Remarks:
1207  CompareName() is the correct tool to use when looking up objects by name.
1208  */
1209  int CompareName(
1210  const ON_UUID& other_parent_id,
1211  const wchar_t* other_name
1212  ) const;
1213  int CompareName(
1214  const wchar_t* other_name
1215  ) const;
1216 
1217  /*
1218  Parameters:
1219  other_name -[in]
1220  Returns:
1221  int rc = ON_wString::CompareAttributeName(this->Name(), other_name);
1222  return (0 != rc) ? rc : ON_wString::CompareOrdinal(this->Name(), other_name, false);
1223  Remarks:
1224  CompareNameExact() is the correct tool to use when detecting changes in
1225  case are important. Use CompareName() when searching for components by name.
1226  */
1227  int CompareNameExact(
1228  const ON_UUID& other_parent_id,
1229  const wchar_t* other_name
1230  ) const;
1231  int CompareNameExact(
1232  const wchar_t* other_name
1233  ) const;
1234 
1235 
1236  /*
1237  Parameters:
1238  a -[in]
1239  b -[in]
1240  Returns:
1241  ON_wString::CompareAttributeName(a.Name(), b.Name() )
1242  Remarks:
1243  CompareName() is the correct tool to use when looking up objects by name.
1244  */
1245  static int CompareName(
1246  const ON_ModelComponent& a,
1247  const ON_ModelComponent& b
1248  );
1249 
1250  /*
1251  Parameters:
1252  a -[in]
1253  b -[in]
1254  Returns:
1255  int rc = ON_wString::CompareAttributeName(a.Name(), b.Name());
1256  return (0 != rc) ? rc : ON_wString::CompareOrdinal(a.Name(), b.Name(), false);
1257  Remarks:
1258  CompareNameExact() is the correct tool to use when detecting changes in
1259  case are important. Use CompareName() when searching for components by name.
1260  */
1261  static int CompareNameExact(
1262  const ON_ModelComponent& a,
1263  const ON_ModelComponent& b
1264  );
1265 
1266  static int CompareId(
1267  const ON_ModelComponent& a,
1268  const ON_ModelComponent& b
1269  );
1270 
1271  /*
1272  Description
1273  Call ON_ModelComponent::CompareName() and then ON_ModelComponent::CompareId().
1274  When used for sorting, will be sorted by name and then by id.
1275  */
1276  static int CompareNameAndId(
1277  const ON_ModelComponent& a,
1278  const ON_ModelComponent& b
1279  );
1280 
1281  /*
1282  Description
1283  Call ON_ModelComponent::Id()and then ON_ModelComponent::CompareName().
1284  When used for sorting, will be sorted by id and then by name.
1285  */
1286  static int CompareIdAndName(
1287  const ON_ModelComponent& a,
1288  const ON_ModelComponent& b
1289  );
1290 
1291  /*
1292  Description:
1293  Set a component's id, name and index to the manifest_item values.
1294  Parameters:
1295  manifest_item - [in]
1296  manifest_name - [in]
1297  bSetId - [in]
1298  Set the component id to manifest_item.m_manifest_id.
1299  bSetParentId - [in]
1300  Use manifest_item.NameHash().ParentId()
1301  bSetName - [in]
1302  Set the component name to manifest_name.
1303  bSetIndex - [in]
1304  Set the component index to manifest_item.m_manifest_index.
1305  */
1306  bool SetIdentification(
1307  const class ON_ComponentManifestItem& manifest_item,
1308  const wchar_t* manifest_name,
1309  bool bSetId,
1310  bool bParentId,
1311  bool bSetName,
1312  bool bSetIndex
1313  );
1314 
1315 
1316  ///////////////////////////////////////////////////////////////////////////////
1317  //
1318  // General attributes interface
1319  //
1320  //
1321 
1322  /*
1323  Description:
1324  Writes the attributes identified by the component_filter parameter.
1325  Parameters:
1326  attributes_filter - [in]
1327  A bitfield that determines which attributes will be cleared.
1328  Returns:
1329  a bitfield indicating which attributes were cleared.
1330  (Locked attributes cannot be cleared.)
1331  */
1332  unsigned int ClearModelComponentAttributes(
1333  unsigned int attributes_filter
1334  );
1335 
1336  /*
1337  Returns:
1338  The runtime serial number.
1339  This value is unique for every instance of an ON_ModelComponent class.
1340  This value is never saved in .3dm archives.
1341  */
1342  ON__UINT64 RuntimeSerialNumber() const;
1343 
1344  /*
1345  Description:
1346  Whenever an attribute is changed, the content version number is incremented.
1347  The ContentVersionNumber() is commonly used by consumers of the model
1348  component attributes to trigger updates when needed.
1349  Remarks:
1350  The ContentVersionNumber value is copied by the copy constructor and operator=.
1351  The value is not saved in .3dm archives.
1352  */
1353  ON__UINT64 ContentVersionNumber() const;
1354 
1355  /*
1356  Returns:
1357  True if this model component is a system constant.
1358  Remarks:
1359  An incomplete list of system constant model compoenents is below:
1360 
1361  ON_ModelComponent::Unset
1362 
1363  ON_InstanceDefinition::Empty
1364 
1365  ON_Linetype::Unset
1366  ON_Linetype::Continuous
1367  ON_Linetype::ByLayer
1368  ON_Linetype::ByParent
1369 
1370  ON_Layer::Unset
1371  ON_Layer::Default
1372 
1373  ON_TextStyle::Unset
1374  ON_TextStyle::Default
1375  ON_TextStyle::ByLayer
1376  ON_TextStyle::ByParent
1377 
1378  ON_DimStyle::Unset
1379  ON_DimStyle::Default
1380  ON_DimStyle::DefaultInchDecimal
1381  ON_DimStyle::DefaultInchFractional
1382  ON_DimStyle::DefaultFootInchArchitecture
1383  ON_DimStyle::DefaultMillimeterSmall
1384  ON_DimStyle::DefaultMillimeterLarge
1385  ON_DimStyle::DefaultMillimeterArchitecture
1386  */
1387  bool IsSystemComponent() const;
1388 
1389  bool EraseIdentification(
1390  bool bIgnoreLocks
1391  );
1392 
1393  bool SetAsSystemComponent();
1394  bool SetAsUnsetSystemComponent();
1395 
1396 private:
1397  bool Internal_SetAsSystemComponent(
1398  bool bUnsetSystemComponent
1399  );
1400 
1401 protected:
1402  /*
1403  Classes derived from ON_ModelComponent should have private data members and
1404  call IncrementContentVersionNumber() when the data member value changes.
1405  */
1406  void IncrementContentVersionNumber() const;
1407 
1408 private:
1409  const ON__UINT64 m_runtime_serial_number;
1410  mutable ON__UINT64 m_content_version_number = 0;
1411  ON__UINT32 m_model_serial_number = 0;
1412  ON__UINT32 m_reference_model_serial_number = 0;
1413  ON__UINT32 m_linked_idef_serial_number = 0;
1415 
1416  ON__UINT16 m_locked_status = 0;
1417  ON__UINT16 m_set_status = 0;
1418  ON_ComponentStatus m_component_status = ON_ComponentStatus::NoneSet;
1419  ON__UINT8 m_reserved1 = 0;
1420  ON__UINT16 m_reserved2 = 0;
1421 
1422  // m_component_index is the index of the component in the model identified
1423  // by m_model_serial_number.
1424  //
1425  // Some components use small negative indices (-1,-2,-3,...) to identify
1426  // default or constant components. An incomplete list includes these:
1427  // ON_TextStyle::Default, (index = -1)
1428  // ON_TextStyle::ByLayer, (index = -2)
1429  // ON_TextStyle::ByParent, (index = -3)
1430  // ON_Linetype::Continuous, (index = -1)
1431  // ON_Linetype::ByLayer, (index = -2)
1432  // ON_Linetype::ByParent, (index = -3)
1433  //
1434  // ON_UNSET_INT_INDEX is a large negative number.
1435  ON__INT32 m_component_index = ON_UNSET_INT_INDEX;
1436  ON__UINT32 m_reserved3 = 0;
1437 
1438  ON_UUID m_component_id = ON_nil_uuid;
1439  ON_UUID m_component_parent_id = ON_nil_uuid;
1440  // lazy evaluation is used top initialize m_component_name_hash
1441  mutable ON_NameHash m_component_name_hash;
1442 
1443  ON_wString m_component_name;
1444 
1445 public:
1446  // For internal use. Never call this function.
1447  static unsigned int Internal_SystemComponentHelper();
1448 };
1449 
1450 
1451 class ON_CLASS ON_ModelComponentContentMark
1452 {
1453 public:
1454  static const ON_ModelComponentContentMark Unset;
1455 public:
1456  ON_ModelComponentContentMark() = default;
1457  ~ON_ModelComponentContentMark() = default;
1459  ON_ModelComponentContentMark& operator=(const ON_ModelComponentContentMark&) = default;
1460 
1461  /*
1462  Description:
1463  Save the current content state of model_component.
1464  Parameters:
1465  model_component - [in]
1466  */
1468  const class ON_ModelComponent& model_component
1469  );
1470 
1471  /*
1472  Description:
1473  Save the current content state of model_component.
1474  Parameters:
1475  model_component - [in]
1476  */
1478  const class ON_ModelComponent* model_component
1479  );
1480 
1481  /*
1482  Description:
1483  Save the current content state of model_component.
1484  Parameters:
1485  model_component - [in]
1486  */
1487  void Set(
1488  const class ON_ModelComponent& model_component
1489  );
1490 
1491  /*
1492  Description:
1493  Save the current content state of model_component.
1494  Parameters:
1495  model_component - [in]
1496  */
1497  void Set(
1498  const class ON_ModelComponent* model_component
1499  );
1500 
1501  /*
1502  Parameters:
1503  model_component - [in]
1504  Returns:
1505  true if the content of model_component is identical
1506  to the content state saved in this ON_ModelComponentContentMark.
1507  false otherwise.
1508  */
1509  bool EqualContent(
1510  const class ON_ModelComponent& model_component
1511  ) const;
1512 
1513  /*
1514  Parameters:
1515  model_component - [in]
1516  Returns:
1517  true if the content of model_component is identical
1518  to the content state saved in this ON_ModelComponentContentMark.
1519  false otherwise.
1520  */
1521  bool EqualContent(
1522  const class ON_ModelComponent* model_component
1523  ) const;
1524 
1525  /*
1526  Parameters:
1527  lhs - [in]
1528  rhs - [in]
1529  Returns:
1530  true if lhs and rhs are identical.
1531  false otherwise.
1532  */
1533  static bool EqualContent(
1535  const ON_ModelComponentContentMark& rhs
1536  );
1537 
1538  /*
1539  Returns:
1540  Saved model component id.
1541  */
1542  ON_UUID ComponentId() const;
1543 
1544  /*
1545  Returns:
1546  Saved model component runtime serial number.
1547  */
1548  ON__UINT64 ComponentRuntimeSerialNumber() const;
1549 
1550  /*
1551  Returns:
1552  Saved model component content version number.
1553  */
1554  ON__UINT64 ComponentContentVersionNumber() const;
1555 
1556  /*
1557  Returns:
1558  Saved model component type.
1559  */
1560  ON_ModelComponent::Type ComponentType() const;
1561 
1562  /*
1563  Returns:
1564  True if a model component content state is saved in this ON_ModelComponentContentMark.
1565  False otherwise.
1566  */
1567  bool IsSet() const;
1568 
1569  /*
1570  Returns:
1571  True if a model component content state is saved in this ON_ModelComponentContentMark.
1572  False otherwise.
1573  */
1574  bool IsUnset() const;
1575 
1576 private:
1577  ON_UUID m_component_id = ON_nil_uuid;
1578  ON__UINT64 m_component_serial_number = 0;
1579  ON__UINT64 m_component_content_version_number = 0;
1581 
1582 private:
1583  unsigned char m_reserved1 = 0;
1584  unsigned char m_reserved2 = 0;
1585  unsigned char m_reserved3 = 0;
1586  unsigned int m_reserved4 = 0;
1587 };
1588 
1589 bool operator==(
1590  const ON_ModelComponentContentMark& lhs,
1591  const ON_ModelComponentContentMark& rhs
1592  );
1593 
1594 bool operator!=(
1595  const ON_ModelComponentContentMark& lhs,
1596  const ON_ModelComponentContentMark& rhs
1597  );
1598 
1599 class ON_CLASS ON_ModelComponentTypeIterator
1600 {
1601 public:
1602  // Default constructor creates ON_ModelComponentTypeIterator::Empty
1603  ON_ModelComponentTypeIterator() ON_NOEXCEPT;
1604 
1605  ~ON_ModelComponentTypeIterator() = default;
1607  ON_ModelComponentTypeIterator& operator=(const ON_ModelComponentTypeIterator&) = default;
1608 
1609  /*
1610  Paramters:
1611  type_count - [in] number of types
1612  types - [in]
1613  list of types to iterate over
1614  */
1616  size_t type_count,
1617  const ON_ModelComponent::Type* types
1618  ) ON_NOEXCEPT;
1619 
1620  // Contains no types
1621  static const ON_ModelComponentTypeIterator Empty;
1623  // Contains all explicit component types (excludes Unset and Mixed).
1624  static const ON_ModelComponentTypeIterator ExplicitComponentTypes;
1626  // Every type in ON_ModelComponentTypeIterator::ExplicitComponents
1627  // except Image, RenderLight, ModelGeometry, and HistoryRecord
1628  // The types in ON_ModelComponentTypeIterator::Tables
1629  // identify the most commonly used "table" component types.
1630  static const ON_ModelComponentTypeIterator TableComponentTypes;
1631 
1632  // Number of types in the iterator
1633  unsigned int TypeCount() const;
1634 
1635  /*
1636  Description:
1637  Sets the iterator to point to the first available type.
1638  Returns:
1639  The first available type.
1640  */
1641  ON_ModelComponent::Type FirstType();
1642 
1643  /*
1644  Description:
1645  Sets the iterator to point to the last available type.
1646  Returns:
1647  The last available type.
1648  */
1649  ON_ModelComponent::Type LastType();
1650 
1651  /*
1652  Description:
1653  Increments the iterator and returns the new type.
1654  Returns:
1655  The new type.
1656  ON_ModelComponent::Type::Unset if the iterator is incremented the last type.
1657  */
1658  ON_ModelComponent::Type NextType();
1659 
1660  /*
1661  Description:
1662  Decrements the iterator and returns the new type.
1663  Returns:
1664  The new type
1665  ON_ModelComponent::Type::Unset if the iterator is decrented the first type.
1666  */
1667  ON_ModelComponent::Type PreviousType();
1668 
1669  /*
1670  Description:
1671  Decrements the iterator and returns the new type.
1672  Returns:
1673  The current type.
1674  */
1675  ON_ModelComponent::Type CurrentType() const;
1676 
1677 private:
1678  ON__INT32 m_type_count = 0;
1679 
1680  // -1 iterated before first, m_type_count = iteratated past last
1681  ON__INT32 m_current_index = ON_UNSET_UINT_INDEX;
1682 
1683  ON_ModelComponent::Type m_types[32];
1684 };
1685 
1686 class ON_CLASS ON_ModelComponentReference
1687 {
1688 public:
1689  static const ON_ModelComponentReference Empty;
1690 
1691  // No = default to insure m_sp is completely managed in the openurbs DLL.
1692  ON_ModelComponentReference() ON_NOEXCEPT; // No = default to insure m_sp is completely managed in the openurbs DLL.
1693  ~ON_ModelComponentReference(); // No = default to insure m_sp is completely managed in the openurbs DLL.
1694  ON_ModelComponentReference(const ON_ModelComponentReference&) ON_NOEXCEPT; // No = default to insure m_sp is completely managed in the openurbs DLL.
1695  ON_ModelComponentReference& operator=(const ON_ModelComponentReference&); // No = default to insure m_sp is completely managed in the openurbs DLL.
1696 
1697 #if defined(ON_HAS_RVALUEREF)
1698  ON_ModelComponentReference( ON_ModelComponentReference&& ) ON_NOEXCEPT;
1699  ON_ModelComponentReference& operator=( ON_ModelComponentReference&& );
1700 #endif
1701 
1702  ON_ModelComponentReference(
1703  std::shared_ptr<ON_ModelComponent>& sp
1704  ) ON_NOEXCEPT;
1705 
1706  ON_ModelComponentReference& operator=(
1707  std::shared_ptr<ON_ModelComponent>& sp
1708  );
1709 
1710  /*
1711  Parameters:
1712  constant_system_component - [in]
1713  A constant system component that exists for the duration of
1714  the application.
1715  Remarks:
1716  See ON_ModelComponent::CreateConstantSystemComponentReference()
1717  for more information about constant system components.
1718 
1719  */
1720  static ON_ModelComponentReference CreateConstantSystemComponentReference(
1721  const class ON_ModelComponent& constant_system_component
1722  ) ON_NOEXCEPT;
1723 
1724  /*
1725  Parameters:
1726  model_component - [in]
1727  bManagedComponentReference - [in]
1728  true
1729  model_component will be deleted by the last ON_ModelComponentReference
1730  and must have been created by call to operator new() with heap allocation.
1731  false
1732  model_component must remain in scope until the last ON_ModelComponentReference
1733  is destroyed.
1734  Remarks:
1735  The input pointer will be managed and deleted by the returned
1736  by ON_ModelComponentReference.
1737  */
1738  static ON_ModelComponentReference CreateForExperts(
1739  class ON_ModelComponent* model_component,
1740  bool bManagedComponentReference
1741  ) ON_NOEXCEPT;
1742 
1743  /*
1744  Return:
1745  A pointer to the managed model component or nullptr.
1746  */
1747  const class ON_ModelComponent* ModelComponent() const ON_NOEXCEPT;
1748 
1749  ON__UINT64 ModelComponentRuntimeSerialNumber() const ON_NOEXCEPT;
1750  const ON_UUID ModelComponentId() const ON_NOEXCEPT;
1751  const ON_NameHash ModelComponentNameHash() const ON_NOEXCEPT;
1752  int ModelComponentIndex() const ON_NOEXCEPT;
1753 
1754  unsigned int ReferenceCount() const ON_NOEXCEPT;
1755 
1756  bool IsEmpty() const ON_NOEXCEPT;
1757 
1758  void Dump(
1759  ON_TextLog& text_log
1760  ) const;
1761 
1762 private:
1763 #pragma ON_PRAGMA_WARNING_PUSH
1764 #pragma ON_PRAGMA_WARNING_DISABLE_MSC( 4251 )
1765  // C4251: ... needs to have dll-interface to be used by clients of class ...
1766  // m_sp is private and all code that manages m_sp is explicitly implemented in the DLL.
1767  std::shared_ptr<ON_ModelComponent> m_sp;
1768 #pragma ON_PRAGMA_WARNING_POP
1769 };
1770 
1771 #if defined(ON_DLL_TEMPLATE)
1772 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_ModelComponentReference>;
1773 #endif
1774 
1775 #endif
Definition: opennurbs_model_component.h:1534
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
void Dump(ON_TextLog &) const override
Creates a text dump of the object.
Definition: opennurbs_string.h:2020
virtual unsigned int SizeOf() const
Definition: opennurbs_archive.h:1044
Type
The ON_ModelComponent::Type enum has a value for each explicit component type and two special values...
Definition: opennurbs_model_component.h:52
Definition: opennurbs_model_component.h:1406
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
Attributes
Definition: opennurbs_model_component.h:258
Definition: opennurbs_archive.h:478
Definition: opennurbs_compstat.h:88
virtual bool IsValid(class ON_TextLog *text_log=nullptr) const
Tests an object to see if its data members are correctly initialized.
Pure virtual base class for all classes that must provide runtime class id or support object level 3D...
Definition: opennurbs_object.h:460
An ON_NameHash is designed to help search for and compare attribute names like the ON_ModelComponent...
Definition: opennurbs_string.h:3434
Definition: opennurbs_array.h:409
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
static const ON_ComponentStatus NoneSet
Definition: opennurbs_compstat.h:92
Definition: opennurbs_model_component.h:1622
virtual ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
Returns a CRC calculated from the information that defines the object. This CRC can be used as a quic...
virtual ON_UUID ModelObjectId() const
All objects in an opennurbs model have an id ( ON_Layer.m_layer_id, ON_Font.m_font_id, ON_Material.m_material_id, ON_3dmObjectAttributes.m_uuid ).