File: rfx_specialuniform.cpp

package info (click to toggle)
meshlab 1.3.2+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 21,096 kB
  • ctags: 33,630
  • sloc: cpp: 224,813; ansic: 8,170; xml: 119; makefile: 80
file content (105 lines) | stat: -rw-r--r-- 3,901 bytes parent folder | download | duplicates (5)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/****************************************************************************
* MeshLab                                                           o o     *
* A versatile mesh processing toolbox                             o     o   *
*                                                                _   O  _   *
* Copyright(C) 2005-2008                                           \/)\/    *
* Visual Computing Lab                                            /\/|      *
* ISTI - Italian National Research Council                           |      *
*                                                                    \      *
* All rights reserved.                                                      *
*                                                                           *
* This program is free software; you can redistribute it and/or modify      *
* it under the terms of the GNU General Public License as published by      *
* the Free Software Foundation; either version 2 of the License, or         *
* (at your option) any later version.                                       *
*                                                                           *
* This program is distributed in the hope that it will be useful,           *
* but WITHOUT ANY WARRANTY; without even the implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
* for more details.                                                         *
*                                                                           *
****************************************************************************/

#include "rfx_specialuniform.h"

// static member initialization
const char *RfxSpecialUniform::SpecialUniformTypeString[] = {
	"MSHLB_BBOX_MIN","MSHLB_BBOX_MAX","MSHLB_QUALITY_MIN", "MSHLB_QUALITY_MAX"
};

RfxSpecialUniform::RfxSpecialUniform(const QString &_name, const QString &_type, MeshDocument* mDoc) : RfxUniform(_name, _type)
{
     this->_mDoc = mDoc;
     this->_specialType = getSpecialType(_name);
}

RfxSpecialUniform::~RfxSpecialUniform()
{
	
}

/*
	Initializes the value of the uniform according to its special type.
*/
void RfxSpecialUniform::initialize(){
     float val[16];

	vcg::Box3f bb;
	 std::pair<float, float> qMinMax;

     switch(this->_specialType){
          case MSHLB_BBOX_MIN:
               bb = this->_mDoc->mm()->cm.bbox;
               val[0] = bb.min[0];
               val[1] = bb.min[1];
               val[2] = bb.min[2];
               val[3] = 1.0;

               this->SetValue(val);
               break;
          

          case MSHLB_BBOX_MAX:
               bb = this->_mDoc->mm()->cm.bbox;
               val[0] = bb.max[0];
               val[1] = bb.max[1];
               val[2] = bb.max[2];
               val[3] = 1.0;


               this->SetValue(val);
               break;

		case MSHLB_QUALITY_MIN:
			qMinMax = vcg::tri::Stat<CMeshO>::ComputePerVertexQualityMinMax(this->_mDoc->mm()->cm);
			val[0] = qMinMax.first;
			this->SetValue(val);
			break;

		case MSHLB_QUALITY_MAX:
			qMinMax = vcg::tri::Stat<CMeshO>::ComputePerVertexQualityMinMax(this->_mDoc->mm()->cm);
			val[0] = qMinMax.second;
			this->SetValue(val);
			break;

          default:
	          break;
          }
}

/*
	Verifies if the uniform is a special one or not.
	If the name of the uniform is one of the uniform special name it returns the special type of the uniform.
	Otherwise returns "NONE".
	@param name the name of the uniform
	@return the special uniform type.
*/
RfxSpecialUniform::SpecialUniformType RfxSpecialUniform::getSpecialType(const QString& name)
{
	for(int i = 0; i < RfxSpecialUniform::TOTAL_SPECIAL_TYPES; ++i) {
		if (name == SpecialUniformTypeString[i])
               return (SpecialUniformType)i;
	}
     return NONE;
}