Commit 8cf188d7 by Christophe Geuzaine

Merge branch 'visuForDev' into 'master'

Visu for dev

See merge request !56
parents 10bedee6 267151e7
Pipeline #774 failed with stage
in 76 minutes 52 seconds
......@@ -88,6 +88,7 @@ opt(SOLVER "Enable built-in finite element solvers (required for compounds)" ${D
opt(TAUCS "Enable Taucs linear solver" ${DEFAULT})
opt(TCMALLOC "Enable libtcmalloc, a fast malloc implementation but that does not release memory" OFF)
opt(TETGEN "Enable Tetgen 3D initial mesh generator" ${DEFAULT})
opt(VISUDEV "Enable additional visualization capabilities for development purpose" OFF)
opt(VORO3D "Enable Voro3D (for hex meshing, experimental)" ${DEFAULT})
opt(WRAP_JAVA "Enable generation of Java wrappers" OFF)
opt(WRAP_PYTHON "Enable generation of Python wrappers" OFF)
......@@ -488,6 +489,10 @@ if(ENABLE_PARSER)
set_config_option(HAVE_PARSER "Parser")
endif(ENABLE_PARSER)
if(ENABLE_VISUDEV)
set_config_option(HAVE_VISUDEV "VisuDev")
endif(ENABLE_VISUDEV)
if(ENABLE_FLTK)
# first, try to use fltk-config for fltk >= 1.3 (FindFLTK is buggy on Unix,
# where e.g. xft and xinerama options are not dealt with)
......
......@@ -236,6 +236,8 @@ class CTX {
int mouseSelection, mouseHoverMeshes, pickElements;
// disable some warnings for expert users?
int expertMode;
// Enable heavy visualization capabilities (for development purpose)
int heavyVisu;
// dynamic: equal to 1 while gmsh is printing
int printing;
// hide all unselected entities?
......
......@@ -67,6 +67,7 @@
#cmakedefine HAVE_SOLVER
#cmakedefine HAVE_TAUCS
#cmakedefine HAVE_TETGEN
#cmakedefine HAVE_VISUDEV
#cmakedefine HAVE_VORO3D
#cmakedefine HAVE_ZIPPER
......
......@@ -3627,6 +3627,23 @@ double opt_general_expert_mode(OPT_ARGS_NUM)
return CTX::instance()->expertMode;
}
#if defined(HAVE_VISUDEV)
double opt_general_heavy_visualization(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
if(CTX::instance()->heavyVisu != val)
CTX::instance()->mesh.changed |= (ENT_LINE | ENT_SURFACE | ENT_VOLUME);
CTX::instance()->heavyVisu = (int)val;
}
#if defined(HAVE_FLTK)
if(FlGui::available() && (action & GMSH_GUI))
FlGui::instance()->options->general.butt[22]->value
(CTX::instance()->heavyVisu);
#endif
return CTX::instance()->heavyVisu;
}
#endif
double opt_general_stereo_mode(OPT_ARGS_NUM)
{
if(action & GMSH_SET)
......
......@@ -285,6 +285,7 @@ double opt_general_zoom_factor(OPT_ARGS_NUM);
double opt_general_expert_mode(OPT_ARGS_NUM);
double opt_general_stereo_mode(OPT_ARGS_NUM);
double opt_general_camera_mode(OPT_ARGS_NUM);
double opt_general_heavy_visualization(OPT_ARGS_NUM);
double opt_general_eye_sep_ratio(OPT_ARGS_NUM);
double opt_general_focallength_ratio(OPT_ARGS_NUM);
double opt_general_camera_aperture(OPT_ARGS_NUM);
......
......@@ -31,6 +31,11 @@ void VertexArray::_addVertex(float x, float y, float z)
void VertexArray::_addNormal(float nx, float ny, float nz)
{
#if defined(HAVE_VISUDEV)
_normals.push_back(nx);
_normals.push_back(ny);
_normals.push_back(nz);
#else
// storing the normals as bytes hurts rendering performance, but it
// significantly reduces the memory footprint
char cx = float2char(nx);
......@@ -39,6 +44,7 @@ void VertexArray::_addNormal(float nx, float ny, float nz)
_normals.push_back(cx);
_normals.push_back(cy);
_normals.push_back(cz);
#endif
}
void VertexArray::_addColor(unsigned char r, unsigned char g, unsigned char b,
......@@ -131,9 +137,9 @@ void VertexArray::finalize()
class AlphaElement {
public:
AlphaElement(float *vp, char *np, unsigned char *cp) : v(vp), n(np), c(cp) {}
AlphaElement(float *vp, normal_type *np, unsigned char *cp) : v(vp), n(np), c(cp) {}
float *v;
char *n;
normal_type *n;
unsigned char *c;
};
......@@ -182,14 +188,14 @@ void VertexArray::sort(double x, double y, double z)
elements.reserve(n);
for(int i = 0; i < n; i++){
float *vp = &_vertices[3 * npe * i];
char *np = _normals.empty() ? 0 : &_normals[3 * npe * i];
normal_type *np = _normals.empty() ? 0 : &_normals[3 * npe * i];
unsigned char *cp = _colors.empty() ? 0 : &_colors[4 * npe * i];
elements.push_back(AlphaElement(vp, np, cp));
}
std::sort(elements.begin(), elements.end(), AlphaElementLessThan());
std::vector<float> sortedVertices;
std::vector<char> sortedNormals;
std::vector<normal_type> sortedNormals;
std::vector<unsigned char> sortedColors;
sortedVertices.reserve(_vertices.size());
sortedNormals.reserve(_normals.size());
......@@ -215,8 +221,9 @@ void VertexArray::sort(double x, double y, double z)
double VertexArray::getMemoryInMb()
{
int bytes = _vertices.size() * sizeof(float) + _normals.size() * sizeof(char) +
_colors.size() * sizeof(unsigned char);
int bytes = _vertices.size() * sizeof(float) +
_normals.size() * sizeof(normal_type) +
_colors.size() * sizeof(unsigned char);
return (double)bytes / 1024. / 1024.;
}
......@@ -224,7 +231,9 @@ char *VertexArray::toChar(int num, std::string name, int type, double min, doubl
int numsteps, double time, SBoundingBox3d bbox, int &len)
{
int vn = _vertices.size(), nn = _normals.size(), cn = _colors.size();
int vs = vn * sizeof(float), ns = nn * sizeof(char), cs = cn * sizeof(unsigned char);
int vs = vn * sizeof(float),
ns = nn * sizeof(normal_type),
cs = cn * sizeof(unsigned char);
int is = sizeof(int), ds = sizeof(double);
int ss = name.size();
double xmin = bbox.min().x(), ymin = bbox.min().y(), zmin = bbox.min().z();
......@@ -314,7 +323,8 @@ void VertexArray::fromChar(int length, const char *bytes, int swap)
int nn; memcpy(&nn, &bytes[index], is); index += is;
if(nn){
_normals.resize(nn); int ns = nn * sizeof(char);
_normals.resize(nn);
int ns = nn * sizeof(normal_type);
memcpy(&_normals[0], &bytes[index], ns); index += ns;
}
......
......@@ -11,6 +11,12 @@
#include "SVector3.h"
#include "SBoundingBox3d.h"
#if defined(HAVE_VISUDEV)
typedef float normal_type;
#else
typedef char normal_type;
#endif
class MElement;
template<int N>
......@@ -138,7 +144,7 @@ class VertexArray{
private:
int _numVerticesPerElement;
std::vector<float> _vertices;
std::vector<char> _normals;
std::vector<normal_type> _normals;
std::vector<unsigned char> _colors;
std::vector<MElement*> _elements;
std::set<ElementData<3>, ElementDataLessThan<3> > _data3;
......@@ -168,9 +174,9 @@ class VertexArray{
std::vector<float>::iterator lastVertex(){return _vertices.end();}
// return a pointer to the raw normal array
char *getNormalArray(int i=0){ return &_normals[i]; }
std::vector<char>::iterator firstNormal(){return _normals.begin();}
std::vector<char>::iterator lastNormal(){return _normals.end();}
normal_type *getNormalArray(int i=0){ return &_normals[i]; }
std::vector<normal_type>::iterator firstNormal(){return _normals.begin();}
std::vector<normal_type>::iterator lastNormal(){return _normals.end();}
// return a pointer to the raw color array
unsigned char *getColorArray(int i=0){ return &_colors[i]; }
......
......@@ -82,7 +82,7 @@ static void draw_stl(std::vector<SPoint3> &vertices, std::vector<SVector3> &norm
glVertexPointer(3, GL_FLOAT, 0, va.getVertexArray());
glEnableClientState(GL_VERTEX_ARRAY);
glNormalPointer(GL_BYTE, 0, va.getNormalArray());
glNormalPointer(NORMAL_GLTYPE, 0, va.getNormalArray());
glEnableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, va.getNumVertices());
......
......@@ -296,6 +296,9 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
(CTX::instance()->homeDir + CTX::instance()->sessionFileName).c_str());
opt_general_options_save(0, GMSH_SET, o->general.butt[9]->value());
opt_general_expert_mode(0, GMSH_SET, o->general.butt[10]->value());
#if defined(HAVE_VISUDEV)
opt_general_heavy_visualization(0, GMSH_SET, o->general.butt[22]->value());
#endif
if(opt_general_gui_color_scheme(0, GMSH_GET, 0) != o->general.butt[21]->value()){
opt_general_gui_color_scheme(0, GMSH_SET, o->general.butt[21]->value());
......@@ -1475,12 +1478,19 @@ optionWindow::optionWindow(int deltaFontSize)
general.butt[9]->type(FL_TOGGLE_BUTTON);
general.butt[9]->callback(general_options_ok_cb);
#if defined(HAVE_VISUDEV)
general.butt[22] = new Fl_Check_Button
(L + 2 * WB, 2 * WB + 8 * BH, BW/2-WB, BH, "Enable heavy visualization capabilities");
general.butt[22]->type(FL_TOGGLE_BUTTON);
general.butt[22]->callback(general_options_ok_cb);
#endif
Fl_Button *b1 = new Fl_Button
(L + width - 2 * WB - BW/3, 2 * WB + 7 * BH, BW/3, BH, "Show file path");
b1->callback(options_show_file_cb, (void*)"option");
Fl_Button *b2 = new Fl_Button
(L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Restore all options to default settings");
(L + 2 * WB, 2 * WB + 10 * BH, BW, BH, "Restore all options to default settings");
b2->callback(options_restore_defaults_cb);
if(CTX::instance()->guiColorScheme)
b2->color(FL_DARK_RED);
......
......@@ -33,7 +33,11 @@ class optionWindow{
struct{
Fl_Group *group;
#if defined(HAVE_VISUDEV)
Fl_Check_Button *butt[23];
#else
Fl_Check_Button *butt[22];
#endif
Fl_Button *push[20];
Fl_Value_Input *value[50];
Fl_Button *color[50];
......
......@@ -77,6 +77,21 @@ void MElement::_getEdgeRep(MVertex *v0, MVertex *v1,
}
}
#if defined(HAVE_VISUDEV)
void MElement::_getFaceRepQuad(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3,
double *x, double *y, double *z, SVector3 *n)
{
x[0] = v0->x(); x[1] = v1->x(); x[2] = (x[0]+x[1]+v2->x()+v3->x())/4;
y[0] = v0->y(); y[1] = v1->y(); y[2] = (y[0]+y[1]+v2->y()+v3->y())/4;
z[0] = v0->z(); z[1] = v1->z(); z[2] = (z[0]+z[1]+v2->z()+v3->z())/4;;
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
for(int i = 0; i < 3; i++) n[i] = normal;
}
#endif
void MElement::_getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2,
double *x, double *y, double *z, SVector3 *n)
{
......
......@@ -43,6 +43,10 @@ class MElement
int faceIndex=-1);
void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2,
double *x, double *y, double *z, SVector3 *n);
#if defined(HAVE_VISUDEV)
void _getFaceRepQuad(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3,
double *x, double *y, double *z, SVector3 *n);
#endif
public :
MElement(int num=0, int part=0);
virtual ~MElement(){}
......
......@@ -370,6 +370,39 @@ void _myGetFaceRep(MHexahedron *hex, int num, double *x, double *y, double *z,
n[2] = n[0];
}
void MHexahedron::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
#if defined(HAVE_VISUDEV)
static const int fquad[24][4] = {
{0, 3, 2, 1}, {3, 2, 1, 0}, {2, 1, 0, 3}, {1, 0, 3, 2},
{0, 1, 5, 4}, {1, 5, 4, 0}, {5, 4, 0, 1}, {4, 0, 1, 5},
{0, 4, 7, 3}, {4, 7, 3, 0}, {7, 3, 0, 4}, {3, 0, 4, 7},
{1, 2, 6, 5}, {2, 6, 5, 1}, {6, 5, 1, 2}, {5, 1, 2, 6},
{2, 3, 7, 6}, {3, 7, 6, 2}, {7, 6, 2, 3}, {6, 2, 3, 7},
{4, 5, 6, 7}, {5, 6, 7, 4}, {6, 7, 4, 5}, {7, 4, 5, 6}
};
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges > 1) {
_myGetFaceRep(this, num, x, y, z, n, CTX::instance()->mesh.numSubEdges);
return;
}
_getFaceRepQuad(getVertex(fquad[num][0]), getVertex(fquad[num][1]),
getVertex(fquad[num][2]), getVertex(fquad[num][3]),
x, y, z, n);
return;
}
#endif
static const int f[12][3] = {
{0, 3, 2}, {0, 2, 1},
{0, 1, 5}, {0, 5, 4},
{0, 4, 7}, {0, 7, 3},
{1, 2, 6}, {1, 6, 5},
{2, 3, 7}, {2, 7, 6},
{4, 5, 6}, {4, 6, 7}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
void MHexahedron20::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
......@@ -392,13 +425,23 @@ void MHexahedronN::getFaceRep(bool curved, int num,
else MHexahedron::getFaceRep(false, num, x, y, z, n);
}
int MHexahedron::getNumFacesRep(bool curved)
{
#if defined(HAVE_VISUDEV)
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges == 1) return 24;
return 12 * gmsh_SQU(CTX::instance()->mesh.numSubEdges);
}
#endif
return 12;
}
int MHexahedron20::getNumFacesRep(bool curved)
{
return curved ? 6 * (CTX::instance()->mesh.numSubEdges *
CTX::instance()->mesh.numSubEdges * 2) : 12;
}
int MHexahedron27::getNumFacesRep(bool curved)
{
return curved ? 6 * (CTX::instance()->mesh.numSubEdges *
......
......@@ -87,19 +87,8 @@ class MHexahedron : public MElement {
virtual double getInnerRadius();
virtual double angleShapeMeasure();
virtual void getFaceInfo(const MFace & face, int &ithFace, int &sign, int &rot) const;
virtual int getNumFacesRep(bool curved){ return 12; }
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
{
static const int f[12][3] = {
{0, 3, 2}, {0, 2, 1},
{0, 1, 5}, {0, 5, 4},
{0, 4, 7}, {0, 7, 3},
{1, 2, 6}, {1, 6, 5},
{2, 3, 7}, {2, 7, 6},
{4, 5, 6}, {4, 6, 7}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
virtual int getNumFacesRep(bool curved);
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{
v.resize(4);
......
......@@ -428,6 +428,39 @@ static void _myGetFaceRep(MPrism *pri, int num, double *x, double *y, double *z,
n[2] = n[0];
}
void MPrism::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
#if defined(HAVE_VISUDEV)
static const int fquad[12][4] = {
{0, 1, 4, 3}, {1, 4, 3, 0}, {4, 3, 0, 1}, {3, 0, 1, 4},
{1, 2, 5, 4}, {2, 5, 4, 1}, {5, 4, 1, 2}, {4, 1, 2, 5},
{2, 0, 3, 5}, {0, 3, 5, 2}, {3, 5, 2, 0}, {5, 2, 0, 3}
};
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges > 1) {
_myGetFaceRep(this, num, x, y, z, n, CTX::instance()->mesh.numSubEdges);
return;
}
if (num > 1) {
int i = num - 2;
_getFaceRepQuad(getVertex(fquad[i][0]), getVertex(fquad[i][1]),
getVertex(fquad[i][2]), getVertex(fquad[i][3]),
x, y, z, n);
return;
}
}
#endif
static const int f[8][3] = {
{0, 2, 1},
{3, 4, 5},
{0, 1, 4}, {0, 4, 3},
{0, 3, 5}, {0, 5, 2},
{1, 2, 5}, {1, 5, 4}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
void MPrism15::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
......@@ -449,6 +482,18 @@ void MPrismN::getFaceRep(bool curved, int num,
else MPrism::getFaceRep(false, num, x, y, z, n);
}
int MPrism::getNumFacesRep(bool curved)
{
#if defined(HAVE_VISUDEV)
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges == 1) return 14;
return 8 * gmsh_SQU(CTX::instance()->mesh.numSubEdges);
}
if (CTX::instance()->heavyVisu) return 14;
#endif
return 8;
}
int MPrism15::getNumFacesRep(bool curved)
{
return curved ? 4 * (CTX::instance()->mesh.numSubEdges *
......
......@@ -92,18 +92,8 @@ class MPrism : public MElement {
_v[faces_prism(num, 2)],
_v[faces_prism(num, 3)]);
}
virtual int getNumFacesRep(bool curved){ return 8; }
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
{
static const int f[8][3] = {
{0, 2, 1},
{3, 4, 5},
{0, 1, 4}, {0, 4, 3},
{0, 3, 5}, {0, 5, 2},
{1, 2, 5}, {1, 5, 4}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
virtual int getNumFacesRep(bool curved);
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{
v.resize((num < 2) ? 3 : 4);
......
......@@ -82,6 +82,16 @@ void MPyramidN::getEdgeRep(bool curved, int num,
else MPyramid::getEdgeRep(false, num, x, y, z, n);
}
int MPyramid::getNumFacesRep(bool curved)
{
#if defined(HAVE_VISUDEV)
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges == 1) return 8;
return 6 * gmsh_SQU(CTX::instance()->mesh.numSubEdges);
}
#endif
return 6;
}
int MPyramidN::getNumFacesRep(bool curved)
{
......@@ -121,6 +131,8 @@ static void _myGetFaceRep(MPyramid *pyr, int num, double *x, double *y, double *
iVertex4 = 3;
}
SPoint3 pnt1, pnt2, pnt3;
if (iFace < 4) {
int ix = 0, iy = 0;
......@@ -137,7 +149,6 @@ static void _myGetFaceRep(MPyramid *pyr, int num, double *x, double *y, double *
const double d = 1. / numSubEdges;
SPoint3 pnt1, pnt2, pnt3;
double u1, v1, u2, v2, u3, v3;
if (ix % 2 == 0){
u1 = ix / 2 * d; v1= iy*d;
......@@ -165,21 +176,8 @@ static void _myGetFaceRep(MPyramid *pyr, int num, double *x, double *y, double *
pyr->pnt(U1, V1, W1, pnt1);
pyr->pnt(U2, V2, W2, pnt2);
pyr->pnt(U3, V3, W3, pnt3);
x[0] = pnt1.x(); x[1] = pnt2.x(); x[2] = pnt3.x();
y[0] = pnt1.y(); y[1] = pnt2.y(); y[2] = pnt3.y();
z[0] = pnt1.z(); z[1] = pnt2.z(); z[2] = pnt3.z();
SVector3 d1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 d2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
n[0] = crossprod(d1, d2);
n[0].normalize();
n[1] = n[0];
n[2] = n[0];
}
else {
SPoint3 pnt1, pnt2, pnt3;
/*
0
......@@ -316,14 +314,50 @@ static void _myGetFaceRep(MPyramid *pyr, int num, double *x, double *y, double *
pyr->pnt(U2,V2,W2, pnt2);
pyr->pnt(U3,V3,W3, pnt3);
}
}
n[0] = 1;
n[1] = 1;
n[2] = 1;
x[0] = pnt1.x(); x[1] = pnt2.x(); x[2] = pnt3.x();
y[0] = pnt1.y(); y[1] = pnt2.y(); y[2] = pnt3.y();
z[0] = pnt1.z(); z[1] = pnt2.z(); z[2] = pnt3.z();
x[0] = pnt1.x(); x[1] = pnt2.x(); x[2] = pnt3.x();
y[0] = pnt1.y(); y[1] = pnt2.y(); y[2] = pnt3.y();
z[0] = pnt1.z(); z[1] = pnt2.z(); z[2] = pnt3.z();
SVector3 d1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 d2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
n[0] = crossprod(d1, d2);
n[0].normalize();
n[1] = n[0];
n[2] = n[0];
}
void MPyramid::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
#if defined(HAVE_VISUDEV)
static const int fquad[4][4] = {
{0, 3, 2, 1}, {3, 2, 1, 0}, {2, 1, 0, 3}, {1, 0, 3, 2}
};
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges > 1) {
_myGetFaceRep(this, num, x, y, z, n, CTX::instance()->mesh.numSubEdges);
return;
}
if (num > 3) {
int i = num - 4;
_getFaceRepQuad(getVertex(fquad[i][0]), getVertex(fquad[i][1]),
getVertex(fquad[i][2]), getVertex(fquad[i][3]),
x, y, z, n);
return;
}
}
#endif
static const int f[6][3] = {
{0, 1, 4},
{3, 0, 4},
{1, 2, 4},
{2, 3, 4},
{0, 3, 2}, {0, 2, 1}
};
_getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]),
x, y, z, n);
}
void MPyramidN::getFaceRep(bool curved, int num,
......
......@@ -97,20 +97,9 @@ class MPyramid : public MElement {
else
return MFace(_v[0], _v[3], _v[2], _v[1]);
}
virtual int getNumFacesRep(bool curved){ return 6; }
virtual int getNumFacesRep(bool curved);
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n)
{
static const int f[6][3] = {
{0, 1, 4},
{3, 0, 4},
{1, 2, 4},
{2, 3, 4},
{0, 3, 2}, {0, 2, 1}
};
_getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]),
x, y, z, n);
}
SVector3 *n);
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{
v.resize((num < 4) ? 3 : 4);
......
......@@ -124,6 +124,17 @@ void MQuadrangle9::getEdgeRep(bool curved, int num,
else MQuadrangle::getEdgeRep(false, num, x, y, z, n);
}
int MQuadrangle::getNumFacesRep(bool curved)
{
#if defined(HAVE_VISUDEV)
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges == 1) return 4;
return 2 * gmsh_SQU(CTX::instance()->mesh.numSubEdges);
}
#endif
return 2;
}
int MQuadrangleN::getNumFacesRep(bool curved)
{
return curved ? 2*SQU(CTX::instance()->mesh.numSubEdges) : 2;
......@@ -191,6 +202,30 @@ static void _myGetFaceRep(MQuadrangle *t, int num, double *x, double *y, double
z[0] = pnt1.z(); z[1] = pnt2.z(); z[2] = pnt3.z();
}
void MQuadrangle::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
#if defined(HAVE_VISUDEV)
static const int fquad[4][4] = {
{0, 1, 2, 3}, {1, 2, 3, 0}, {2, 3, 0, 1}, {3, 0, 1, 2}
};
if (CTX::instance()->heavyVisu) {
if (CTX::instance()->mesh.numSubEdges > 1) {
_myGetFaceRep(this, num, x, y, z, n, CTX::instance()->mesh.numSubEdges);
return;
}
_getFaceRepQuad(getVertex(fquad[num][0]), getVertex(fquad[num][1]),
getVertex(fquad[num][2]), getVertex(fquad[num][3]),
x, y, z, n);
return;
}
#endif
static const int f[2][3] = {
{0, 1, 2}, {0, 2, 3}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
void MQuadrangleN::getFaceRep(bool curved, int num,
double *x, double *y, double *z, SVector3 *n)
{
......
......@@ -91,14 +91,8 @@ class MQuadrangle : public MElement {
}
virtual int getNumFaces(){ return 1; }
virtual MFace getFace(int num){ return MFace(_v[0], _v[1], _v[2], _v[3]); }
virtual int getNumFacesRep(bool curved){ return 2; }
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
{
static const int f[2][3] = {
{0, 1, 2}, {0, 2, 3}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
virtual int getNumFacesRep(bool curved);
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{
v.resize(4);
......
......@@ -27,6 +27,12 @@
#include <GL/glu.h>
#endif
#if defined(HAVE_VISUDEV)
#define NORMAL_GLTYPE GL_FLOAT
#else
#define NORMAL_GLTYPE GL_BYTE
#endif
class PView;
class GModel;
class GVertex;
......
......@@ -230,7 +230,7 @@ class drawGFace {
glEnableClientState(GL_VERTEX_ARRAY);
if(useNormalArray){
glEnable(GL_LIGHTING);
glNormalPointer(GL_BYTE, 0, va->getNormalArray());
glNormalPointer(NORMAL_GLTYPE, 0, va->getNormalArray());
glEnableClientState(GL_NORMAL_ARRAY);
}
else{
......
......@@ -359,7 +359,7 @@ static void drawArrays(drawContext *ctx, GEntity *e, VertexArray *va, GLint type
if(useNormalArray){
glEnable(GL_LIGHTING);
glNormalPointer(GL_BYTE, 0, va->getNormalArray());
glNormalPointer(NORMAL_GLTYPE, 0, va->getNormalArray());
glEnableClientState(GL_NORMAL_ARRAY);
}
else
......
......@@ -39,8 +39,12 @@ static void drawArrays(drawContext *ctx, PView *p, VertexArray *va, GLint type,
glColor4ubv((GLubyte *)va->getColorArray(4 * i));
double f = 1.;
if(opt->pointType > 1){
#if defined(HAVE_VISUDEV)
f = *va->getNormalArray(3 * i);
#else
char *n = va->getNormalArray(3 * i);
f = char2float(*n);
#endif