Point Cloud Library (PCL)  1.14.1-dev
opennurbs_object_history.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(ON_OBJECT_HISTORY_INC_)
18 #define ON_OBJECT_HISTORY_INC_
19 
20 #if defined(ON_DLL_TEMPLATE)
21 // This stuff is here because of a limitation in the way Microsoft
22 // handles templates and DLLs. See Microsoft's knowledge base
23 // article ID Q168958 for details.
24 #pragma warning( push )
25 #pragma warning( disable : 4231 )
26 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray< class ON_Value* >;
27 #pragma warning( pop )
28 #endif
29 
30 class ON_CLASS ON_CurveProxyHistory
31 {
32 public:
33  // Used to save information needed to create an ON_CurveProxy
34  // reference in history records.
37 
38  ON_ObjRef m_curve_ref; // from ON_CurveProxy.m_real_curve
39  bool m_bReversed; // from ON_CurveProxy.m_bReversed
40  ON_Interval m_full_real_curve_domain; // from ON_CurveProxy.m_real_curve.Domain()
41  ON_Interval m_sub_real_curve_domain; // from ON_CurveProxy.m_real_curve_domain
42  ON_Interval m_proxy_curve_domain; // from ON_CurveProxy.m_this_domain
43 
44  void Destroy();
45  bool Write( ON_BinaryArchive& ) const;
47  void Dump( ON_TextLog& ) const;
48 
49 private:
50  ON__UINT8 m_reserved[64];
51 };
52 
53 #if defined(ON_DLL_TEMPLATE)
54 // This stuff is here because of a limitation in the way Microsoft
55 // handles templates and DLLs. See Microsoft's knowledge base
56 // article ID Q168958 for details.
57 #pragma warning( push )
58 #pragma warning( disable : 4231 )
59 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_CurveProxyHistory>;
60 #pragma warning( pop )
61 #endif
62 
63 class ON_CLASS ON_PolyEdgeHistory
64 {
65 public:
66  // Used to save information needed to create an CRhinoPolyEdge
67  // reference in history records.
70 
71  void Destroy();
72  bool Write( ON_BinaryArchive& ) const;
74  void Dump( ON_TextLog& ) const;
75 
79 private:
80  ON__UINT8 m_reserved[64];
81 };
82 
83 class ON_CLASS ON_HistoryRecord : public ON_Object
84 {
85  ON_OBJECT_DECLARE(ON_HistoryRecord);
86 public:
89 
90  // The copy constructor and operator= create duplicates
91  // of the linked list of ON_Value classes.
94 
95  // virtual ON_Object::IsValid override
96  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
97  // virtual ON_Object::Dump override
98  void Dump( ON_TextLog& ) const;
99  // virtual ON_Object::Write override
100  ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const;
101  // virtual ON_Object::Read override
102  ON_BOOL32 Read(ON_BinaryArchive& binary_archive);
103  // virtual
105 
106  //////////
107  // If history becomes invalid, call Destroy()
108  void Destroy();
109 
110  void DestroyValue( int value_id );
111 
112  /*
113  Description:
114  For setting values.
115  Parameters:
116  value_id - [in]
117  If there a value with the same input
118  id exists, the old value is replaced.
119  count - [in]
120  Number of values
121  b - [in]
122  array of count bools
123  i - [in]
124  array of count ints
125  x - [in]
126  array of count doubles
127  p - [in]
128  array of count 3d points
129  v - [in]
130  array of count 3d vectors
131  xform - [in]
132  array of count xforms
133  c - [in]
134  array of count colors
135  or - [in]
136  array of count object references
137  g - [in]
138  array of count geometry pointers
139  u - [in]
140  array of uuids
141  s - [in]
142  string
143  */
144  bool SetBoolValue( int value_id, bool b);
145  bool SetIntValue( int value_id, int i);
146  bool SetDoubleValue( int value_id, double x);
147  bool SetPointValue( int value_id, ON_3dPoint p);
148  bool SetVectorValue( int value_id, ON_3dVector v);
149  bool SetXformValue( int value_id, ON_Xform xform);
150  bool SetColorValue( int value_id, ON_Color c);
151  bool SetObjRefValue( int value_id, const ON_ObjRef& oref);
152  bool SetPointOnObjectValue( int value_id, const ON_ObjRef& oref, ON_3dPoint point );
153  bool SetUuidValue( int value_id, ON_UUID uuid );
154  bool SetStringValue( int value_id, const wchar_t* s );
155  bool SetGeometryValue( int value_id, ON_Geometry* g);
156  bool SetPolyEdgeValue( int value_id, const ON_PolyEdgeHistory& polyedge );
157 
158  /*
159  Description:
160  For setting values.
161  Parameters:
162  value_id - [in]
163  If there a value with the same input
164  id exists, the old value is replaced.
165  count - [in]
166  Number of values
167  b - [in]
168  array of count bools
169  i - [in]
170  array of count ints
171  x - [in]
172  array of count doubles
173  P - [in]
174  array of count 3d points
175  V - [in]
176  array of count 3d vectors
177  xform - [in]
178  array of count xforms
179  c - [in]
180  array of count colors
181  or - [in]
182  array of count object references
183  g - [in]
184  array of count geometry pointers
185  u - [in]
186  array of uuids
187  s - [in]
188  array of strings
189  */
190  bool SetBoolValues( int value_id, int count, const bool* b);
191  bool SetIntValues( int value_id, int count, const int* i);
192  bool SetDoubleValues( int value_id, int count, const double* x);
193  bool SetPointValues( int value_id, int count, const ON_3dPoint* P);
194  bool SetVectorValues( int value_id, int count, const ON_3dVector* V);
195  bool SetXformValues( int value_id, int count, const ON_Xform* xform);
196  bool SetColorValues( int value_id, int count, const ON_Color* c);
197  bool SetObjRefValues( int value_id, int count, const ON_ObjRef* oref);
198  bool SetUuidValues( int value_id, int count, const ON_UUID* u );
199  bool SetStringValues( int value_id, int count, const wchar_t* const* s );
200  bool SetStringValues( int value_id, const ON_ClassArray<ON_wString>& s );
201  bool SetGeometryValues( int value_id, const ON_SimpleArray<ON_Geometry*> a);
202  bool SetPolyEdgeValues( int value_id, int count, const ON_PolyEdgeHistory* a );
203 
204  /*
205  Description:
206  For retrieving values.
207  */
208  bool GetStringValue( int value_id, ON_wString& str ) const;
209  bool GetBoolValue( int value_id, bool* b ) const;
210  bool GetIntValue( int value_id, int* i ) const;
211  bool GetDoubleValue( int value_id, double* number ) const;
212  bool GetPointValue( int value_id, ON_3dPoint& point ) const;
213  bool GetVectorValue( int value_id, ON_3dVector& point ) const;
214  bool GetXformValue( int value_id, ON_Xform& point ) const;
215  bool GetColorValue( int value_id, ON_Color* color ) const;
216  bool GetObjRefValue( int value_id, ON_ObjRef& oref ) const;
217  bool GetPointOnObjectValue( int value_id, ON_ObjRef& oref ) const;
218  bool GetCurveValue( int value_id, const ON_Curve*& ) const;
219  bool GetSurfaceValue( int value_id, const ON_Surface*& ) const;
220  bool GetBrepValue( int value_id, const ON_Brep*& ) const;
221  bool GetMeshValue( int value_id, const ON_Mesh*& ) const;
222  bool GetGeometryValue( int value_id, const ON_Geometry*& ) const;
223  bool GetUuidValue( int value_id, ON_UUID* uuid ) const;
224  bool GetPolyEdgeValue( int value_id, const ON_PolyEdgeHistory*& polyedge ) const;
225 
226  int GetStringValues( int value_id, ON_ClassArray<ON_wString>& string ) const;
227  int GetBoolValues( int value_id, ON_SimpleArray<bool>& ) const;
228  int GetIntValues( int value_id, ON_SimpleArray<int>& ) const;
229  int GetDoubleValues( int value_id, ON_SimpleArray<double>& ) const;
230  int GetPointValues( int value_id, ON_SimpleArray<ON_3dPoint>& ) const;
231  int GetVectorValues( int value_id, ON_SimpleArray<ON_3dVector>& ) const;
232  int GetXformValues( int value_id, ON_SimpleArray<ON_Xform>& ) const;
233  int GetColorValues( int value_id, ON_SimpleArray<ON_Color>& ) const;
234  int GetObjRefValues( int value_id, ON_ClassArray<ON_ObjRef>& objects ) const;
236  int GetUuidValues( int value_id, ON_SimpleArray<ON_UUID>& ) const;
238 
239  /*
240  Desccription:
241  Determine if object is an antecedent (input) in this
242  history record.
243  Parameters:
244  object_uuid - [in]
245  Returns:
246  Returns true if object_uuid is the id of an input
247  object.
248  */
249  bool IsAntecedent( ON_UUID object_uuid ) const;
250 
251 
252  /*
253  Description:
254  Print a list of the values in text_log.
255  Parameters:
256  text_log - [in]
257  Returns:
258  Number of values listed.
259  */
260  int ValueReport( ON_TextLog& text_log ) const;
261 
262  // CRhinoCommand::CommandId() value of the command that
263  // created this history record. Each time the command
264  // is run, it can create a history record.
266 
267  // A YYYYMMDDn version number that gets updated when
268  // a command changes. This version is checked so that
269  // new versions of a command's ReplayHistory don't
270  // attempt to use information saved in old files.
272 
274  {
275  history_parameters = 0, // parameters for UpdateHistory
276  feature_parameters = 1, // parameters for a feature
277  force_32bit_record_type = 0xFFFFFFFF
278  };
279 
281 
282  /*
283  Description:
284  Convert integer into an ON_HistoryRecord::RECORD_TYPE.
285  Parameters:
286  i - [in]
287  Returns:
288  ON_HistoryRecord::RECORD_TYPE enum with same value as i.
289  */
290  static
292 
293  // Each history record has a unique id that is assigned
294  // when the record is added to Rhino's history record table.
296 
297  // List of object id values of antecedent objects that
298  // are referenced in the list of input events in m_value[].
299  // These were the command's "input" objects.
301 
302  // List of object id values of descendant objects that
303  // were created. These were the command's "output" objects
305 
306  // Information needed to update the descendant objects
307  // when an antecedent object is modified.
309 
310  /*
311  Description:
312  This tool is used in rare situations when the object ids
313  stored in the uuid list need to be remapped.
314  Parameters:
315  uuid_remap - [in]
316  Is it critical that uuid_remap[] be sorted with respect
317  to ON_UuidPair::CompareFirstUuid.
318  */
319  void RemapObjectIds( const ON_SimpleArray<ON_UuidPair>& uuid_remap );
320 
321 private:
322  bool m_bValuesSorted;
323  ON_Value* FindValueHelper( int, int, bool ) const;
324  void CopyHelper( const ON_HistoryRecord&);
325 };
326 
327 
328 #endif
bool Read(ON_BinaryArchive &)
bool Write(ON_BinaryArchive &) const
void Dump(ON_TextLog &) const
bool SetPolyEdgeValues(int value_id, int count, const ON_PolyEdgeHistory *a)
bool GetBoolValue(int value_id, bool *b) const
bool IsAntecedent(ON_UUID object_uuid) const
bool GetDoubleValue(int value_id, double *number) const
int GetPolyEdgeValues(int value_id, ON_SimpleArray< const ON_PolyEdgeHistory * > &) const
bool SetXformValue(int value_id, ON_Xform xform)
bool SetObjRefValue(int value_id, const ON_ObjRef &oref)
bool SetStringValues(int value_id, int count, const wchar_t *const *s)
bool SetPointOnObjectValue(int value_id, const ON_ObjRef &oref, ON_3dPoint point)
bool SetPointValue(int value_id, ON_3dPoint p)
bool SetVectorValue(int value_id, ON_3dVector v)
int GetXformValues(int value_id, ON_SimpleArray< ON_Xform > &) const
ON_HistoryRecord(const ON_HistoryRecord &src)
bool GetIntValue(int value_id, int *i) const
bool GetMeshValue(int value_id, const ON_Mesh *&) const
bool GetObjRefValue(int value_id, ON_ObjRef &oref) const
int GetColorValues(int value_id, ON_SimpleArray< ON_Color > &) const
static RECORD_TYPE RecordType(int i)
int GetGeometryValues(int value_id, ON_SimpleArray< const ON_Geometry * > &) const
int GetObjRefValues(int value_id, ON_ClassArray< ON_ObjRef > &objects) const
bool GetStringValue(int value_id, ON_wString &str) const
bool SetPolyEdgeValue(int value_id, const ON_PolyEdgeHistory &polyedge)
int GetUuidValues(int value_id, ON_SimpleArray< ON_UUID > &) const
bool SetDoubleValues(int value_id, int count, const double *x)
bool SetGeometryValue(int value_id, ON_Geometry *g)
bool SetXformValues(int value_id, int count, const ON_Xform *xform)
bool SetGeometryValues(int value_id, const ON_SimpleArray< ON_Geometry * > a)
void DestroyValue(int value_id)
ON_UUID ModelObjectId() const
bool SetDoubleValue(int value_id, double x)
bool SetVectorValues(int value_id, int count, const ON_3dVector *V)
bool GetUuidValue(int value_id, ON_UUID *uuid) const
void RemapObjectIds(const ON_SimpleArray< ON_UuidPair > &uuid_remap)
int GetVectorValues(int value_id, ON_SimpleArray< ON_3dVector > &) const
bool SetStringValues(int value_id, const ON_ClassArray< ON_wString > &s)
bool GetBrepValue(int value_id, const ON_Brep *&) const
bool SetObjRefValues(int value_id, int count, const ON_ObjRef *oref)
bool GetColorValue(int value_id, ON_Color *color) const
bool SetBoolValue(int value_id, bool b)
bool GetXformValue(int value_id, ON_Xform &point) const
int GetPointValues(int value_id, ON_SimpleArray< ON_3dPoint > &) const
bool SetColorValues(int value_id, int count, const ON_Color *c)
bool SetColorValue(int value_id, ON_Color c)
bool SetPointValues(int value_id, int count, const ON_3dPoint *P)
int GetIntValues(int value_id, ON_SimpleArray< int > &) const
bool GetGeometryValue(int value_id, const ON_Geometry *&) const
bool SetUuidValue(int value_id, ON_UUID uuid)
bool GetCurveValue(int value_id, const ON_Curve *&) const
bool SetBoolValues(int value_id, int count, const bool *b)
ON_HistoryRecord & operator=(const ON_HistoryRecord &src)
bool GetPointValue(int value_id, ON_3dPoint &point) const
ON_SimpleArray< class ON_Value * > m_value
bool SetIntValue(int value_id, int i)
ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
bool GetPolyEdgeValue(int value_id, const ON_PolyEdgeHistory *&polyedge) const
void Dump(ON_TextLog &) const
bool GetPointOnObjectValue(int value_id, ON_ObjRef &oref) const
int GetBoolValues(int value_id, ON_SimpleArray< bool > &) const
int GetDoubleValues(int value_id, ON_SimpleArray< double > &) const
int GetStringValues(int value_id, ON_ClassArray< ON_wString > &string) const
ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
bool GetVectorValue(int value_id, ON_3dVector &point) const
int ValueReport(ON_TextLog &text_log) const
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
bool GetSurfaceValue(int value_id, const ON_Surface *&) const
bool SetIntValues(int value_id, int count, const int *i)
bool SetStringValue(int value_id, const wchar_t *s)
bool SetUuidValues(int value_id, int count, const ON_UUID *u)
bool Write(ON_BinaryArchive &) const
void Dump(ON_TextLog &) const
bool Read(ON_BinaryArchive &)
ON_SimpleArray< double > m_t
ON_ClassArray< ON_CurveProxyHistory > m_segment