~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/decimation/intern/LOD_MeshBounds.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * ***** BEGIN GPL LICENSE BLOCK *****
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation; either version 2
7
 
 * of the License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 
 *
18
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
 
 * All rights reserved.
20
 
 *
21
 
 * The Original Code is: all of this file.
22
 
 *
23
 
 * Contributor(s): none yet.
24
 
 *
25
 
 * ***** END GPL LICENSE BLOCK *****
26
 
 */
27
 
 
28
 
/** \file decimation/intern/LOD_MeshBounds.h
29
 
 *  \ingroup decimation
30
 
 */
31
 
 
32
 
 
33
 
#ifndef __LOD_MESHBOUNDS_H__
34
 
#define __LOD_MESHBOUNDS_H__
35
 
 
36
 
#include "MEM_SmartPtr.h"
37
 
#include "LOD_MeshPrimitives.h"
38
 
#include "LOD_ManMesh2.h"
39
 
#include "MT_assert.h"
40
 
 
41
 
// simple class to compute the mesh bounds of a manifold mesh,
42
 
 
43
 
class LOD_MeshBounds {
44
 
 
45
 
public :
46
 
        static
47
 
                LOD_MeshBounds *
48
 
        New(
49
 
        ){
50
 
 
51
 
                MEM_SmartPtr<LOD_MeshBounds> output(new LOD_MeshBounds());              
52
 
                return output.Release();
53
 
        }
54
 
 
55
 
                void
56
 
        ComputeBounds(
57
 
                const LOD_ManMesh2 * mesh
58
 
        ){
59
 
                MT_assert(mesh!=NULL);
60
 
                MT_assert(mesh->VertexSet().size() > 0);
61
 
 
62
 
                const std::vector<LOD_Vertex> &verts = mesh->VertexSet(); 
63
 
                
64
 
                m_min = verts[0].pos;
65
 
                m_max = verts[0].pos;
66
 
 
67
 
                // iterate through the verts
68
 
 
69
 
                int t;
70
 
                const int size = verts.size();
71
 
 
72
 
                for (t=1; t< size ; ++t) {
73
 
 
74
 
                        UpdateBounds(verts[t].pos,m_min,m_max);
75
 
                }
76
 
        }
77
 
                                
78
 
                MT_Vector3
79
 
        Min(
80
 
        ) const {
81
 
                return m_min;
82
 
        }
83
 
 
84
 
                MT_Vector3
85
 
        Max(
86
 
        ) const {
87
 
                return m_max;
88
 
        }
89
 
 
90
 
private :
91
 
 
92
 
                void
93
 
        UpdateBounds(
94
 
                MT_Vector3 vertex,
95
 
                MT_Vector3& min,
96
 
                MT_Vector3& max
97
 
        ) {
98
 
                if (vertex.x() < min.x()) {
99
 
                        min.x() = vertex.x();
100
 
                } else
101
 
                if (vertex.x() > max.x()) {
102
 
                        max.x()= vertex.x();
103
 
                }
104
 
 
105
 
                if (vertex.y() < min.y()) {
106
 
                        min.y() = vertex.y();
107
 
                } else
108
 
                if (vertex.y() > max.y()) {
109
 
                        max.y()= vertex.y();
110
 
                }
111
 
 
112
 
                if (vertex.z() < min.z()) {
113
 
                        min.z() = vertex.z();
114
 
                } else
115
 
                if (vertex.z() > max.z()) {
116
 
                        max.z()= vertex.z();
117
 
                }
118
 
        }
119
 
 
120
 
        LOD_MeshBounds(
121
 
        ) :
122
 
                m_min(0,0,0),
123
 
                m_max(0,0,0)
124
 
        {
125
 
        };
126
 
                        
127
 
        MT_Vector3 m_min;
128
 
        MT_Vector3 m_max;
129
 
 
130
 
};
131
 
 
132
 
#endif
133