Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DT_VertexBase.h « convex « src « solid « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37646fdd935402a58fa44d317a6b2601a82097aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * SOLID - Software Library for Interference Detection
 * 
 * Copyright (C) 2001-2003  Dtecta.  All rights reserved.
 *
 * This library may be distributed under the terms of the Q Public License
 * (QPL) as defined by Trolltech AS of Norway and appearing in the file
 * LICENSE.QPL included in the packaging of this file.
 *
 * This library may be distributed and/or modified under the terms of the
 * GNU General Public License (GPL) version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Commercial use or any other use of this library not covered by either 
 * the QPL or the GPL requires an additional license from Dtecta. 
 * Please contact info@dtecta.com for enquiries about the terms of commercial
 * use of this library.
 */

#ifndef DT_VERTEXBASE_H
#define DT_VERTEXBASE_H

#include "MT_Point3.h"

#include <vector>

class DT_Complex;

typedef std::vector<DT_Complex *>DT_ComplexList;

class DT_VertexBase {
public:
    explicit DT_VertexBase(const void *base = 0, DT_Size stride = 0, bool owner = false) : 
        m_base((char *)base),
		m_stride(stride ? stride : 3 * sizeof(DT_Scalar)),
		m_owner(owner)
	{}
	
	~DT_VertexBase()
	{
		if (m_owner)
		{
			delete [] m_base;
		}
	}
    
    MT_Point3 operator[](DT_Index i) const 
	{ 
        return MT_Point3(reinterpret_cast<DT_Scalar *>(m_base + i * m_stride));
    }
    
    void setPointer(const void *base, bool owner = false)
	{
		m_base = (char *)base; 
		m_owner = owner;
	} 
	
    const void *getPointer() const { return m_base; }	
	bool        isOwner() const { return m_owner; }
    
	void addComplex(DT_Complex *complex) const { m_complexList.push_back(complex); }
	void removeComplex(DT_Complex *complex) const
	{
		DT_ComplexList::iterator it = std::find(m_complexList.begin(), m_complexList.end(), complex); 
		if (it != m_complexList.end())
		{
			m_complexList.erase(it);
		}
	}
	
	const DT_ComplexList& getComplexList() const { return m_complexList; }
	
private:    
    char                  *m_base;
    DT_Size                m_stride;
	bool                   m_owner;
	mutable DT_ComplexList m_complexList;
};

#endif