~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to intern/csg/intern/blender/CSG_PropArray.h

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef CSG_IndexProp_H
2
 
#define CSG_IndexProp_H
3
 
 
4
 
#include <vector>
5
 
#include <memory.h>
6
 
// Face and vertex props that are contained in a seperate array
7
 
// (PropArray) and indexed through a VProp compliant thing.
8
 
 
9
 
typedef int (*CSG_InterpFunc)(const void *d1, const void * d2, void *dnew, float epsilon);
10
 
 
11
 
class IndexProp
12
 
{
13
 
private :
14
 
 
15
 
        int m_vIndex;
16
 
        int m_size;
17
 
        unsigned char *m_data;
18
 
        mutable CSG_InterpFunc m_interpFunc;
19
 
 
20
 
public :
21
 
 
22
 
        IndexProp(const int& vIndex)
23
 
                : m_vIndex(vIndex), 
24
 
                  m_size(0),
25
 
                  m_data(0)
26
 
        {};
27
 
        
28
 
        IndexProp(
29
 
                const int& vIndex, 
30
 
                const IndexProp& p1, 
31
 
                const IndexProp& p2, 
32
 
                const MT_Scalar& epsilon
33
 
        ): 
34
 
                m_vIndex(vIndex),
35
 
                m_data(0)
36
 
        {
37
 
                SetInterpFunc(p1.m_interpFunc);
38
 
                SetSize(p1.m_size);
39
 
                m_interpFunc(p1.m_data,p2.m_data,m_data,(float)epsilon);
40
 
        }
41
 
 
42
 
        IndexProp(const IndexProp& other)
43
 
        :       m_vIndex(other.m_vIndex),
44
 
                m_data(0),
45
 
                m_interpFunc(other.m_interpFunc)
46
 
        {
47
 
                SetInterpFunc(other.m_interpFunc);
48
 
                SetSize(other.m_size);
49
 
                memcpy(m_data,other.m_data,m_size);
50
 
        }
51
 
 
52
 
        IndexProp(
53
 
        ):  m_vIndex(-1),
54
 
                m_size(0),
55
 
                m_data(0)
56
 
        {};
57
 
 
58
 
        // Support conversion to an integer
59
 
        ///////////////////////////////////
60
 
        operator int(
61
 
        ) const { 
62
 
                return m_vIndex;
63
 
        }
64
 
 
65
 
        // and assignment from an integer.
66
 
        //////////////////////////////////
67
 
                IndexProp& 
68
 
        operator = (
69
 
                int i
70
 
        ) { 
71
 
                m_vIndex = i; 
72
 
                return *this;
73
 
        }
74
 
 
75
 
                IndexProp&
76
 
        operator = (
77
 
                const IndexProp& other
78
 
        ) {
79
 
                m_vIndex = other.m_vIndex;
80
 
                m_data = 0;
81
 
                SetSize(other.m_size);
82
 
                SetInterpFunc(other.m_interpFunc);
83
 
                memcpy(m_data,other.m_data,m_size);
84
 
                return *this;
85
 
        }
86
 
 
87
 
        // Our local functions
88
 
        //////////////////////
89
 
 
90
 
        void SetInterpFunc(CSG_InterpFunc interpFunc)
91
 
        {
92
 
                m_interpFunc = interpFunc;
93
 
        }
94
 
        
95
 
        void SetSize(int size)
96
 
        {
97
 
                delete[] m_data;
98
 
                m_data = new unsigned char[size];
99
 
                m_size = size;
100
 
        }
101
 
 
102
 
        int Size() const {
103
 
                return m_size;
104
 
        }
105
 
 
106
 
        void CopyData(const void * userData)
107
 
        {
108
 
                memcpy(m_data,userData,m_size);
109
 
        }
110
 
 
111
 
        void Create(int size, const void * userData, CSG_InterpFunc interpFunc)
112
 
        {
113
 
                SetInterpFunc(interpFunc);
114
 
                SetSize(size);
115
 
                CopyData(userData);
116
 
        }
117
 
 
118
 
        const unsigned char * GetData() const { return m_data;}
119
 
 
120
 
        ~IndexProp() {
121
 
                delete[] m_data;
122
 
        };
123
 
};
124
 
        
125
 
 
126
 
#endif
 
 
b'\\ No newline at end of file'