Skip to content

Commit

Permalink
CPlot: render tag in style, npts in tkMapEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Sep 12, 2024
1 parent 003d842 commit acf451b
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 141 deletions.
4 changes: 0 additions & 4 deletions Cassiopee/CPlot/CPlot/Display/displaySSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ void Data::displaySSolidZone(StructZone* zonep, E_Int zone)
E_Float nz = 1./_numberOfStructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{color1[0] = zonep->colorR; color1[1] = zonep->colorG; color1[2] = zonep->colorB;}

#include "selection.h"

bool is1D = ((zonep->ni*zonep->nj == 1) | (zonep->ni*zonep->nk == 1) | (zonep->nj*zonep->nk == 1));
Expand Down
201 changes: 96 additions & 105 deletions Cassiopee/CPlot/CPlot/Display/displayUSolidHOZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,117 +25,108 @@
//=============================================================================
void Data::displayUSolidHOZone(UnstructZone *zonep, E_Int zone, E_Int zonet)
{
E_Int i, n1, n2, n3, n4, n5, n6, n7, n8;
E_Int ret1, ret2, ret3, ret4, f;

// Style
float color1[ 3 ];
float color2[ 3 ];

// Colormap
float r, g, b;
void ( *getrgb )( Data * data, double, float *, float *, float * );
getrgb = _plugins.zoneColorMap->f;

E_Float nz = 1. / _numberOfUnstructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{
color1[ 0 ] = zonep->colorR;
color1[ 1 ] = zonep->colorG;
color1[ 2 ] = zonep->colorB;
}

#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
bool is1D = ( (eltType0 == 1) | (eltType0 == 10 && zonep->nelts1D > 0) );
if (is1D == true && ptrState->mode == RENDER)
glLineWidth(1. + 5 * zonep->shaderParam1);
else if (is1D == true) glLineWidth(3.);
else glLineWidth(1.);

// scale
E_Float s = MAX(zonep->xmax - zonep->xmin, zonep->ymax - zonep->ymin);
s = MAX(s, zonep->zmax - zonep->zmin);
s = 100. / (s + 1.e-12);

// Only for textured rendering, we use vect display =======================
if (ptrState->mode == RENDER && zonep->material == 14 && zonep->texu != NULL) // Textured rendering
{
// Sans doute également à modifier pour le high order ?
triggerShader(*zonep, zonep->material, s, color1);

E_Int ff = 0;
double offb = 0.;
E_Int i, n1, n2, n3, n4, n5, n6, n7, n8;
E_Int ret1, ret2, ret3, ret4, f;

// Style
float color1[ 3 ];
float color2[ 3 ];

// Colormap
float r, g, b;
void ( *getrgb )( Data * data, double, float *, float *, float * );
getrgb = _plugins.zoneColorMap->f;

E_Float nz = 1. / _numberOfUnstructZones;
#include "solidStyles.h"

#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
bool is1D = ( (eltType0 == 1) | (eltType0 == 10 && zonep->nelts1D > 0) );
if (is1D == true && ptrState->mode == RENDER) glLineWidth(1. + 5 * zonep->shaderParam1);
else if (is1D == true) glLineWidth(3.);
else glLineWidth(1.);

// scale
E_Float s = MAX(zonep->xmax - zonep->xmin, zonep->ymax - zonep->ymin);
s = MAX(s, zonep->zmax - zonep->zmin);
s = 100. / (s + 1.e-12);

// Only for textured rendering, we use vect display =======================
if (ptrState->mode == RENDER && zonep->material == 14 && zonep->texu != NULL) // Textured rendering
{
// Sans doute également à modifier pour le high order ?
triggerShader(*zonep, zonep->material, s, color1);

E_Int ff = 0;
double offb = 0.;
#undef PLOT
double* f1 = zonep->texu;
double* f2 = zonep->texv;
double* f3 = zonep->texw;
double fmin1, fmax1, fmin2, fmax2, fmin3, fmax3;
fmax1 = 0.; fmin1 = 1.;
fmax2 = 0.; fmin2 = 1.;
fmax3 = 0.; fmin3 = 1.;
double* f1 = zonep->texu;
double* f2 = zonep->texv;
double* f3 = zonep->texw;
double fmin1, fmax1, fmin2, fmax2, fmin3, fmax3;
fmax1 = 0.; fmin1 = 1.;
fmax2 = 0.; fmin2 = 1.;
fmax3 = 0.; fmin3 = 1.;
#define GL_QUADS_ARE GL_QUADS
#define PLOTQUAD PLOTQUADQ
#define PLOTQUAD2 PLOTQUADQ2
#include "displayUVectSolidZone.h"
glLineWidth( 1. );
return;
}
// END Textured rendering ===========================================
// Activation du shader de tesselation :
int ishader = 0;
if (eltType0 == UnstructZone::TRI)
ishader = 1; // OK, element de type Tri_6, TRI_9, TRI_10, TRI_12 or TRI_15
if (eltType0 == UnstructZone::QUAD)
ishader = 2; // OK, element de type Quad_8 ou Quad_9, QUAD_12, QUAD_16, QUAD_25
this->_shaders.set_tesselation(ishader);
if (ptrState->mode == RENDER)
{
if (zonep->selected == 1 && zonep->active == 1)
triggerShader(*zonep, zonep->material, s, color2);
else
triggerShader(*zonep, zonep->material, s, color1);
}
else
{
if (zonep->selected == 1 && zonep->active == 1)
triggerShader(*zonep, 0, s, color2);
else
triggerShader(*zonep, 0, s, color1);
}
// Pour eviter de tracer le low order sans faire expres :-)
unsigned short idShader = this->_shaders.currentShader();
int t_inner = this->ptrState->inner_tesselation;
int t_outer = this->ptrState->outer_tesselation;
this->_shaders[ idShader ]->setUniform( "uInner", (float)t_inner );
this->_shaders[ idShader ]->setUniform( "uOuter", (float)t_outer );
this->_shaders[ idShader ]->setUniform( "patch_size", (int)zonep->eltSize[0] );

glPatchParameteri(GL_PATCH_VERTICES, zonep->eltSize[0]);
glBegin(GL_PATCHES);

E_Int ind_elt, ind;
E_Int ne = zonep->nec[0];
E_Int stride = ne;
E_Int* connect = zonep->connect[0];
double* x = zonep->x;
double* y = zonep->y;
double* z = zonep->z;
glLineWidth( 1. );
return;
}
// END Textured rendering ===========================================
// Activation du shader de tesselation :
int ishader = 0;
if (eltType0 == UnstructZone::TRI)
ishader = 1; // OK, element de type Tri_6, TRI_9, TRI_10, TRI_12 or TRI_15
if (eltType0 == UnstructZone::QUAD)
ishader = 2; // OK, element de type Quad_8 ou Quad_9, QUAD_12, QUAD_16, QUAD_25
this->_shaders.set_tesselation(ishader);
if (ptrState->mode == RENDER)
{
if (zonep->selected == 1 && zonep->active == 1)
triggerShader(*zonep, zonep->material, s, color2);
else
triggerShader(*zonep, zonep->material, s, color1);
}
else
{
if (zonep->selected == 1 && zonep->active == 1)
triggerShader(*zonep, 0, s, color2);
else
triggerShader(*zonep, 0, s, color1);
}
// Pour eviter de tracer le low order sans faire expres :-)
unsigned short idShader = this->_shaders.currentShader();
int t_inner = this->ptrState->inner_tesselation;
int t_outer = this->ptrState->outer_tesselation;
this->_shaders[ idShader ]->setUniform( "uInner", (float)t_inner );
this->_shaders[ idShader ]->setUniform( "uOuter", (float)t_outer );
this->_shaders[ idShader ]->setUniform( "patch_size", (int)zonep->eltSize[0] );

glPatchParameteri(GL_PATCH_VERTICES, zonep->eltSize[0]);
glBegin(GL_PATCHES);

E_Int ind_elt, ind;
E_Int ne = zonep->nec[0];
E_Int stride = ne;
E_Int* connect = zonep->connect[0];
double* x = zonep->x;
double* y = zonep->y;
double* z = zonep->z;

for (E_Int ielts = 0; ielts < ne; ++ielts)
for (E_Int ielts = 0; ielts < ne; ++ielts)
{
ind_elt = ielts;
for (E_Int inode = 0; inode < zonep->eltSize[0]; inode++)
{
ind_elt = ielts;
for (E_Int inode = 0; inode < zonep->eltSize[0]; inode++)
{
ind = connect[ind_elt + inode * stride]-1;
glVertex3f( (float)x[ind], (float)y[ind], (float)z[ind] );
}
ind = connect[ind_elt + inode * stride]-1;
glVertex3f( (float)x[ind], (float)y[ind], (float)z[ind] );
}
glEnd();
glLineWidth(1.);
return;
}
glEnd();
glLineWidth(1.);
return;
}
8 changes: 0 additions & 8 deletions Cassiopee/CPlot/CPlot/Display/displayUSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ void Data::displayUSolidZone(UnstructZone *zonep, E_Int zone, E_Int zonet)
E_Float nz = 1. / _numberOfUnstructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{
color1[ 0 ] = zonep->colorR;
color1[ 1 ] = zonep->colorG;
color1[ 2 ] = zonep->colorB;
}

#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
Expand Down
6 changes: 0 additions & 6 deletions Cassiopee/CPlot/CPlot/Display/renderDLSSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ void DataDL::renderGPUSSolidZone(StructZone* zonep, E_Int zone)
E_Float nz = 1./_numberOfStructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{color1[0] = zonep->colorR;
color1[1] = zonep->colorG;
color1[2] = zonep->colorB;}

#include "selection.h"

bool is1D = ((zonep->ni*zonep->nj == 1) | (zonep->ni*zonep->nk == 1) | (zonep->nj*zonep->nk == 1));
Expand Down
8 changes: 0 additions & 8 deletions Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ void DataDL::renderGPUUSolidHOZone(UnstructZone *zonep, E_Int zone, E_Int zonet)
E_Float nz = 1. / _numberOfUnstructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{
color1[ 0 ] = zonep->colorR;
color1[ 1 ] = zonep->colorG;
color1[ 2 ] = zonep->colorB;
}

#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
Expand Down
6 changes: 0 additions & 6 deletions Cassiopee/CPlot/CPlot/Display/renderDLUSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ void DataDL::renderGPUUSolidZone(UnstructZone* zonep, E_Int zone, E_Int zonet)
E_Float nz = 1./_numberOfUnstructZones;
#include "solidStyles.h"

// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{color1[0] = zonep->colorR;
color1[1] = zonep->colorG;
color1[2] = zonep->colorB;}

#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
Expand Down
4 changes: 4 additions & 0 deletions Cassiopee/CPlot/CPlot/Display/solidStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
color2[0] = 0.; color2[1] = 0.; color2[2] = 1;
break;
}
// Ecrasement si renderTag
if (zonep->colorR > -0.5)
{color1[0] = zonep->colorR; color1[1] = zonep->colorG; color1[2] = zonep->colorB;}

9 changes: 5 additions & 4 deletions Cassiopee/CPlot/apps/tkMapEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ def uniformize1D(density, h, npts, factor):
z = CTK.t[2][nob][2][noz]
zones.append(z)
try:
D._uniformize(zones, npts, h, factor, density)
if npts > 0:
for z in zones: D._uniformize(z, npts, h, factor, density)
else:
D._uniformize(zones, npts, h, factor, density)
for c, nz in enumerate(nzs):
nob = CTK.Nb[nz]+1
noz = CTK.Nz[nz]
Expand Down Expand Up @@ -373,8 +376,7 @@ def apply2D(density, h, npts, factor, ntype=0):
out.append(b)
# Garde les autres
out += u
#tp = C.newPyTree(['Base'])
#tp[2][1][2] += out
#tp = C.newPyTree(['Base', out])
#C.convertPyTree2File(tp, 'edges.cgns')

# Rebuild
Expand Down Expand Up @@ -734,7 +736,6 @@ def uniformize(event=None):
density = -1; npts = 2; factor = -1; h = -1
if rtype == 'Density':
density = CTK.varsFromWidget(VARS[0].get(), 1)
print('density', density)
if len(density) != 1:
CTK.TXT.insert('START', 'Invalid points density.\n')
CTK.TXT.insert('START', 'Error: ', 'Error')
Expand Down

0 comments on commit acf451b

Please sign in to comment.