~ubuntu-branches/debian/squeeze/gmsh/squeeze

« back to all changes in this revision

Viewing changes to Post/PViewOptions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme
  • Date: 2009-09-02 18:12:15 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090902181215-yla8zvcas2ucvkm9
[Christophe Prud'homme]
* New upstream release
  + fixed surface mesh orientation bug introduced in 2.4.0;
  + mesh and graphics code refactoring;
  + small usability enhancements and bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include <string.h>
7
7
#include "GmshConfig.h"
8
8
#include "GmshMessage.h"
 
9
#include "GmshDefines.h"
9
10
#include "PViewOptions.h"
10
 
 
11
 
#if defined(HAVE_MATH_EVAL)
12
 
#include "matheval.h"
13
 
#endif
 
11
#include "mathEvaluator.h"
14
12
 
15
13
PViewOptions PViewOptions::reference;
16
14
 
17
 
PViewOptions::PViewOptions()
 
15
PViewOptions::PViewOptions() : genRaiseEvaluator(0)
18
16
{
19
 
  for(int i = 0; i < 3; i++) genRaiseFunction[i] = 0;
20
17
  ColorTable_InitParam(2, &colorTable);
21
18
  ColorTable_Recompute(&colorTable);
22
19
}
23
20
 
24
21
PViewOptions::~PViewOptions()
25
22
{
26
 
  destroyGeneralRaise();
 
23
  if(genRaiseEvaluator) delete genRaiseEvaluator;
27
24
}
28
25
 
29
26
double PViewOptions::getScaleValue(int iso, int numIso, double min, double max)
96
93
  return colorTable.table[index];
97
94
}
98
95
 
99
 
void PViewOptions::destroyGeneralRaise()
100
 
{
101
 
  for(int i = 0; i < 3; i++){
102
 
#if defined(HAVE_MATH_EVAL)
103
 
    if(genRaiseFunction[i])
104
 
      evaluator_destroy(genRaiseFunction[i]);
105
 
    genRaiseFunction[i] = 0;
106
 
#else
107
 
    genRaiseFunction[i] = (void*)-1;
108
 
#endif
109
 
  }
110
 
}
111
 
 
112
96
void PViewOptions::createGeneralRaise()
113
97
{
114
 
  destroyGeneralRaise();
 
98
  const char *names[] = 
 
99
    { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8"};
 
100
  unsigned int numVariables = sizeof(names) / sizeof(names[0]);
 
101
  std::vector<std::string> expressions(3), variables(numVariables);
 
102
  expressions[0] = genRaiseX;
 
103
  expressions[1] = genRaiseY;
 
104
  expressions[2] = genRaiseZ;
 
105
  for(unsigned int i = 0; i < numVariables; i++) variables[i] = names[i];
115
106
 
116
 
  const char *expr[3] = {genRaiseX.c_str(), genRaiseY.c_str(), genRaiseZ.c_str()};
117
 
#if defined(HAVE_MATH_EVAL)
118
 
  for(int i = 0; i < 3; i++) {
119
 
    if(strlen(expr[i])) {
120
 
      if(!(genRaiseFunction[i] = evaluator_create((char*)expr[i])))
121
 
        Msg::Error("Invalid expression '%s'", expr[i]);
122
 
    }
123
 
  }
124
 
#else
125
 
  for(int i = 0; i < 3; i++) {
126
 
    if(!strcmp(expr[i], "v0")) genRaiseFunction[i] = (void*)0;
127
 
    else if(!strcmp(expr[i], "v1")) genRaiseFunction[i] = (void*)1;
128
 
    else if(!strcmp(expr[i], "v2")) genRaiseFunction[i] = (void*)2;
129
 
    else if(!strcmp(expr[i], "v3")) genRaiseFunction[i] = (void*)3;
130
 
    else if(!strcmp(expr[i], "v4")) genRaiseFunction[i] = (void*)4;
131
 
    else if(!strcmp(expr[i], "v5")) genRaiseFunction[i] = (void*)5;
132
 
    else if(!strcmp(expr[i], "v6")) genRaiseFunction[i] = (void*)6;
133
 
    else if(!strcmp(expr[i], "v7")) genRaiseFunction[i] = (void*)7;
134
 
    else if(!strcmp(expr[i], "v8")) genRaiseFunction[i] = (void*)8;
135
 
    else if(strlen(expr[i])) {
136
 
      Msg::Error("Invalid expression '%s'", expr[i]);
137
 
      return;
138
 
    }
139
 
  }
140
 
#endif
 
107
  if(genRaiseEvaluator) delete genRaiseEvaluator;
 
108
  genRaiseEvaluator = new mathEvaluator(expressions, variables);
 
109
  if(expressions.empty()){
 
110
    delete genRaiseEvaluator;
 
111
    genRaiseEvaluator = 0;
 
112
  }
141
113
}
142
114
 
143
 
bool PViewOptions::skipElement(int numEdges)
 
115
bool PViewOptions::skipElement(int type)
144
116
{
145
 
  switch(numEdges){
146
 
  case 0: return !drawPoints;
147
 
  case 1: return !drawLines;
148
 
  case 3: return !drawTriangles;
149
 
  case 4: return !drawQuadrangles;
150
 
  case 6: return !drawTetrahedra;
151
 
  case 12: return !drawHexahedra;
152
 
  case 9: return !drawPrisms;
153
 
  case 8: return !drawPyramids;
 
117
  switch(type){
 
118
  case TYPE_PNT: return !drawPoints;
 
119
  case TYPE_LIN: return !drawLines;
 
120
  case TYPE_TRI: return !drawTriangles;
 
121
  case TYPE_QUA: return !drawQuadrangles;
 
122
  case TYPE_TET: return !drawTetrahedra;
 
123
  case TYPE_HEX: return !drawHexahedra;
 
124
  case TYPE_PRI: return !drawPrisms;
 
125
  case TYPE_PYR: return !drawPyramids;
154
126
  default: return true;
155
127
  }
156
128
}