source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/plyclean/undo.h @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.3 KB
Line 
1//
2// undo.h:
3// Save every variable that changes, so that we can exactly "undo"
4// an operation by putting everything back the way it was.  This
5// allows us to try mesh simplification changes, and abort the
6// changes if we detect something bad happening (like a topology
7// change...)
8
9#ifndef UNDO_H
10#define UNDO_H
11
12
13#define MAXUNDOBUFSIZE 40000
14
15// Variables for storing the undo operation list
16extern bool saveUndo;
17extern char  undoBuf[sizeof(void *)*MAXUNDOBUFSIZE];
18extern char *undoPtr;
19extern void *undoLoc[MAXUNDOBUFSIZE];
20extern int  undoSize[MAXUNDOBUFSIZE];
21extern int undoN;
22
23// Functions
24template<class T> void save(T &data)
25{
26  if (!saveUndo) return;
27  void *ptr = &data;
28  if (sizeof(T) + undoPtr > MAXUNDOBUFSIZE + undoBuf) {
29    // Error checking:
30    // Shit.  We don't have enough buffer to push this on undo stack
31    // Really should make it dynamically allocated. @!#$!#!@#
32    fprintf(stderr, "Error.  Out of memory, can't push object of size");
33    fprintf(stderr, "        %d on the undo stack.\n", sizeof(T));
34    fprintf(stderr, "        Recommend increasing MAXUNDOBUFSIZE. :-( \n");
35    exit(-1);
36  }
37  bcopy((char *) ptr, undoPtr, sizeof(T));
38  undoPtr += sizeof(T);
39  undoLoc[undoN] = &data;
40  undoSize[undoN] = sizeof(T);
41  undoN++;
42}
43
44void SaveCheckpoint(void);
45void undo(void);
46void SaveOff(void);
47
48#endif  // UNDO_H
Note: See TracBrowser for help on using the repository browser.