1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
19 /** \file
20  * \ingroup freestyle
21  */
22 
23 #include "IndexedFaceSet.h"
24 #include "NodeCamera.h"
25 #include "NodeViewLayer.h"
26 #include "SceneVisitor.h"
27 
28 #include "BLI_sys_types.h"
29 
30 #ifdef WITH_CXX_GUARDEDALLOC
31 #  include "MEM_guardedalloc.h"
32 #endif
33 
34 namespace Freestyle {
35 
36 class SceneHash : public SceneVisitor {
37  public:
SceneHash()38   inline SceneHash() : SceneVisitor()
39   {
40     _sum = 1;
41   }
42 
~SceneHash()43   virtual ~SceneHash()
44   {
45   }
46 
47   VISIT_DECL(NodeCamera);
48   VISIT_DECL(NodeViewLayer);
49   VISIT_DECL(IndexedFaceSet);
50 
51   string toString();
52 
match()53   inline bool match()
54   {
55     return _sum == _prevSum;
56   }
57 
store()58   inline void store()
59   {
60     _prevSum = _sum;
61   }
62 
reset()63   inline void reset()
64   {
65     _sum = 1;
66   }
67 
68  private:
69   void adler32(const unsigned char *data, int size);
70 
71   uint32_t _sum;
72   uint32_t _prevSum;
73 
74 #ifdef WITH_CXX_GUARDEDALLOC
75   MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:SceneHash")
76 #endif
77 };
78 
79 } /* namespace Freestyle */
80