Skip to content

Commit

Permalink
OCC: corr. remesh edge, CPlot: update visu edge
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Sep 10, 2024
1 parent 7cab9bf commit fd5569f
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 69 deletions.
8 changes: 5 additions & 3 deletions Cassiopee/CPlot/CPlot/Display/displaySMeshZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ void Data::displaySMeshZone(StructZone* zonep, E_Int zone)
if (ptrState->dim == 2) nk = 1;
E_Int nij = ni*nj;

if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1)
{ glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
bool is1D = false;
if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1) is1D = true;

if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }

#include "selection.h"

Expand All @@ -112,7 +114,7 @@ void Data::displaySMeshZone(StructZone* zonep, E_Int zone)
#include "displaySMeshZone.h"

// Zones 1D: on ajoute les noeuds
if (nj*nk == 1 || ni*nk == 1 || ni*nj == 1)
if (is1D)
{
glBegin(GL_QUADS);
if (zonep->blank == 0)
Expand Down
6 changes: 4 additions & 2 deletions Cassiopee/CPlot/CPlot/Display/displayUMeshHOZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ void Data::displayUMeshZone_ho(UnstructZone* zonep, E_Int zone, E_Int zonet)
#include "selection.h"

E_Int eltType0 = zonep->eltType[0];
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0)) glLineWidth(3.);
bool is1D = false;
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0)) is1D = true;
if (is1D) glLineWidth(3.);
int ishader = 3;
this->_shaders.set_tesselation(ishader);
this->_shaders.activate((short unsigned int)this->_shaders.shader_id(shader::None));
Expand All @@ -113,7 +115,7 @@ void Data::displayUMeshZone_ho(UnstructZone* zonep, E_Int zone, E_Int zonet)
this->_shaders.set_tesselation(0);

// For BARS or NODES or 1D NGONS: display nodes
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0))
if (is1D)
{
glBegin(GL_QUADS);
if (zonep->blank == 0)
Expand Down
10 changes: 6 additions & 4 deletions Cassiopee/CPlot/CPlot/Display/displayUMeshZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ void Data::displayUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet)
E_Float nz = 1./_numberOfUnstructZones;
#include "meshStyles.h"

E_Int eltType0 = zonep->eltType[0];
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0))
{ glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
E_Int eltType0 = zonep->eltType[0];
bool is1D = false;
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0)) is1D = true;

if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }

#include "selection.h"

Expand All @@ -120,7 +122,7 @@ void Data::displayUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet)
#include "displayUMeshZone.h"

// For BARS or NODES or 1D NGONS: display node
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0))
if (is1D)
{
glBegin(GL_QUADS);
if (zonep->blank == 0)
Expand Down
9 changes: 1 addition & 8 deletions Cassiopee/CPlot/CPlot/Display/meshStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@
break;

case 4:
// Wires noirs
//getrgb(this, zone*1./_numberOfZones, &g, &r, &b);
//complementColor(g,r,b, color1[0],color1[1],color1[2]);
//if (color1[2] > 0.8 && color1[0] < 0.2 && color1[1] < 0.2)
//{ r = color1[0]; g = color1[1]; b = color1[2];
// color1[0] = b; color1[1] = r; color1[2] = g;}
//color2[0] = 0.7; color2[1] = 0.88; color2[2] = 1.;

// Wires noirs fins
color1[0] = 0.; color1[1] = 0.; color1[2] = 0.;
color2[0] = 0.7; color2[1] = 0.88; color2[2] = 1.;
// Ecrasement si render tag
Expand Down
11 changes: 8 additions & 3 deletions Cassiopee/CPlot/CPlot/Display/renderDLSIsoSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ void DataDL::renderSIsoSolidZone(StructZone* zonep, E_Int zone, E_Int nofield)
// Blending
blend = 1.;
#include "selection2.h"
bool is1D = false;
if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1) is1D = true;


#ifdef __SHADERS__
int curr = _shaders.currentShader();
if (curr != 0) _shaders[curr]->setUniform("blend", (float)blend);
glColor4f(0.,0.,0., blend); // pour imposer blend

if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1)
if (is1D)
{
if (curr != 0) _shaders[curr]->setUniform("lightOn", (int)0); // impose isoLight off on 1D meshes
}
Expand All @@ -58,7 +61,7 @@ void DataDL::renderSIsoSolidZone(StructZone* zonep, E_Int zone, E_Int nofield)
glCallList(zoneImpl->_DLiso);

#ifdef __SHADERS__
if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1)
if (is1D)
{
if (ptrState->isoLight == 1 && ptrState->dim == 3)
{
Expand Down Expand Up @@ -96,6 +99,8 @@ void DataDL::renderSIsoSolidZone(StructZone* zonep, E_Int zone, E_Int nofield1,
// Blending
blend = 1.;
#include "selection2.h"
bool is1D = false;
if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1) is1D = true;

#ifdef __SHADERS__
int curr = _shaders.currentShader();
Expand All @@ -108,7 +113,7 @@ void DataDL::renderSIsoSolidZone(StructZone* zonep, E_Int zone, E_Int nofield1,
glCallList(zoneImpl->_DLiso);

// Pour les lignes
if (nij == 1 || ni*nk == 1 || nj*nk == 1)
if (is1D)
{
glBegin(GL_LINES);
E_Int nie, nje, nke;
Expand Down
8 changes: 4 additions & 4 deletions Cassiopee/CPlot/CPlot/Display/renderDLSMeshZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ void DataDL::renderGPUSMeshZone(StructZone* zonep, E_Int zone)
E_Int nj = zonep->nj;
E_Int nk = zonep->nk;
if (ptrState->dim == 2) nk = 1;

if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1)
{ glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
bool is1D = false;
if (ni*nj == 1 || ni*nk == 1 || nj*nk == 1) is1D = true;
if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
#include "selection.h"

d = dist2BB(_view.xcam, _view.ycam, _view.zcam,
Expand All @@ -120,7 +120,7 @@ void DataDL::renderGPUSMeshZone(StructZone* zonep, E_Int zone)
glLineWidth(1.);

// Zones 1D: on ajoute les noeuds
if (nj*nk == 1 || ni*nk == 1 || ni*nj == 1)
if (is1D)
{
glBegin(GL_QUADS);
if (zonep->blank == 0)
Expand Down
6 changes: 4 additions & 2 deletions Cassiopee/CPlot/CPlot/Display/renderDLUIsoSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ void DataDL::renderUIsoSolidZone(UnstructZone* zonep, E_Int zonet, E_Int nofield
#include "selection2.h"

E_Int eltType0 = zonep->eltType[0];
bool is1D = false;
if ((eltType0 == 1) || (eltType0 == 10 && zonep->nelts1D > 0)) is1D = true;

#ifdef __SHADERS__
int curr = _shaders.currentShader();
if (curr != 0) _shaders[curr]->setUniform("blend", (float)blend);
glColor4f(0.,0.,0., blend); // pour imposer blend

if ((eltType0 == 1) || (eltType0 == 10 && zonep->nelts1D > 0))
if (is1D)
{
if (curr != 0) _shaders[curr]->setUniform("lightOn", (int)0); // impose isoLight off on 1D meshes
}
Expand All @@ -53,7 +55,7 @@ void DataDL::renderUIsoSolidZone(UnstructZone* zonep, E_Int zonet, E_Int nofield
glCallList(zoneImpl->_DLiso);

#ifdef __SHADERS__
if ((eltType0 == 1) || (eltType0 == 10 && zonep->nelts1D > 0))
if (is1D)
{
if (ptrState->isoLight == 1 && ptrState->dim == 3)
{
Expand Down
8 changes: 4 additions & 4 deletions Cassiopee/CPlot/CPlot/Display/renderDLUMeshZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ void DataDL::renderGPUUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet)
double* y = zonep->y;
double* z = zonep->z;
E_Int eltType0 = zonep->eltType[0];

if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0))
{ glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
bool is1D = false;
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0)) is1D = true;
if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; }
#include "selection.h"

// glCallList(zonep->_DLmesh);
Expand All @@ -129,7 +129,7 @@ void DataDL::renderGPUUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet)
glCallList(zImpl->_DLmesh);

// For BARS, NODE, 1D NGONS: display node
if (eltType0 == 1 || eltType0 == 0 || (eltType0 == 10 && zonep->nelts1D > 0))
if (is1D)
{
glBegin(GL_QUADS);
if (zonep->blank == 0)
Expand Down
3 changes: 1 addition & 2 deletions Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void DataDL::renderGPUUSolidHOZone(UnstructZone *zonep, E_Int zone, E_Int zonet)

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);
if (is1D == true && ptrState->mode == RENDER) glLineWidth( 1. + 5 * zonep->shaderParam1);
else if (is1D == true) glLineWidth(3.);
else glLineWidth(1.);

Expand Down
49 changes: 30 additions & 19 deletions Cassiopee/CPlot/apps/tkMapEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def refine1D(density, npts, factor):
#==============================================================================
# Uniformize pour les zones edges
#==============================================================================
def uniformize1D(density, npts, factor):
def uniformize1D(density, h, npts, factor):
fail = False
nzs = CPlot.getSelectedZones()
zones = []
Expand All @@ -263,7 +263,7 @@ def uniformize1D(density, npts, factor):
z = CTK.t[2][nob][2][noz]
zones.append(z)
try:
D._uniformize(zones, npts, -1, factor, density)
D._uniformize(zones, npts, h, factor, density)
for c, nz in enumerate(nzs):
nob = CTK.Nb[nz]+1
noz = CTK.Nz[nz]
Expand All @@ -282,7 +282,7 @@ def uniformize1D(density, npts, factor):
# ntype=4: smooth
# Retourne True (failed), False (success)
#==============================================================================
def apply2D(density, npts, factor, ntype=0):
def apply2D(density, h, npts, factor, ntype=0):
nzs = CPlot.getSelectedZones()
nz = nzs[0]
nob = CTK.Nb[nz]+1
Expand All @@ -299,6 +299,7 @@ def apply2D(density, npts, factor, ntype=0):
if ntype == 0: # uniformize
if density > 0: npts = D.getLength(i)*density
if factor > 0: npts = np*factor
if h > 0: npts = D.getLength(i)/h+1
npts = int(max(npts, 2))
distrib = G.cart((0,0,0), (1./(npts-1.),1,1), (npts,1,1))
b = G.map(i, distrib)
Expand Down Expand Up @@ -404,7 +405,7 @@ def apply2D(density, npts, factor, ntype=0):
# ntype=4: smooth
# Retourne True (failed), False (success)
#==============================================================================
def apply3D(density, npts, factor, ntype):
def apply3D(density, h, npts, factor, ntype):
nzs = CPlot.getSelectedZones()
nz = nzs[0]
nob = CTK.Nb[nz]+1
Expand All @@ -421,6 +422,7 @@ def apply3D(density, npts, factor, ntype):
if ntype == 0: # uniformize
if density > 0: npts = D.getLength(i)*density
if factor > 0: npts = np*factor
if h > 0: npts = D.getLength(i)/h+1
npts = int(max(npts, 2))
distrib = G.cart((0,0,0), (1./(npts-1.),1,1), (npts,1,1))
b = G.map(i, distrib)
Expand Down Expand Up @@ -729,9 +731,10 @@ def uniformize(event=None):
CTK.TXT.insert('START', 'Error: ', 'Error'); return

rtype = VARS[2].get()
density = -1; npts = 2; factor = -1
if type == 'Density':
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 All @@ -748,6 +751,14 @@ def uniformize(event=None):
CTK.TXT.insert('START', 'Invalid number factor.\n')
CTK.TXT.insert('START', 'Error: ', 'Error')
factor = factor[0]
elif rtype == 'H':
h = CTK.varsFromWidget(VARS[0].get(), 1)
print('h', h)
if len(h) != 1:
CTK.TXT.insert('START', 'Invalid h step.\n')
CTK.TXT.insert('START', 'Error: ', 'Error')
h = h[0]

CTK.saveTree()
CTK.setCursor(2, WIDGETS['frame'])

Expand All @@ -759,11 +770,11 @@ def uniformize(event=None):
dim = Internal.getZoneDim(zone)
if dim[0] == 'Structured':
if dim[2] != 1 and dim[3] != 1:
fail = apply3D(density, npts, factor, ntype=0)
fail = apply3D(density, h, npts, factor, ntype=0)
elif dim[2] != 1 and dim[3] == 1:
fail = apply2D(density, npts, factor, ntype=0)
else: fail = uniformize1D(density, npts, factor)
else: fail = uniformize1D(density, npts, factor) # all zones
fail = apply2D(density, h, npts, factor, ntype=0)
else: fail = uniformize1D(density, h, npts, factor)
else: fail = uniformize1D(density, h, npts, factor) # all zones

if not fail:
CTK.TXT.insert('START', 'Uniformize successfull.\n')
Expand Down Expand Up @@ -808,9 +819,9 @@ def enforce(event=None):
dim = Internal.getZoneDim(zone)
if dim[0] == 'Structured':
if dim[2] != 1 and dim[3] != 1:
fail = apply3D(1., 1, h, ntype=2)
fail = apply3D(1., -1, 1, h, ntype=2)
elif dim[2] != 1 and dim[3] == 1:
fail = apply2D(1., 1, h, ntype=2)
fail = apply2D(1., -1, 1, h, ntype=2)
else: fail = stretch1D(h)
else: fail = stretch1D(h)

Expand Down Expand Up @@ -862,9 +873,9 @@ def refine(event=None):
dim = Internal.getZoneDim(zone)
if dim[0] == 'Structured':
if dim[2] != 1 and dim[3] != 1:
fail = apply3D(1., npts, factor, ntype=1)
fail = apply3D(1., -1, npts, factor, ntype=1)
elif dim[2] != 1 and dim[3] == 1:
fail = apply2D(1., npts, factor, ntype=1)
fail = apply2D(1., -1, npts, factor, ntype=1)
else: fail = refine1D(1., npts, factor) # all zones
else: fail = refine1D(1., npts, factor) # all zones

Expand Down Expand Up @@ -916,9 +927,9 @@ def smooth(event=None):
dim = Internal.getZoneDim(zone)
if dim[0] == 'Structured':
if dim[2] != 1 and dim[3] != 1:
fail = apply3D(1., niter, eps, ntype=4)
fail = apply3D(1., -1, niter, eps, ntype=4)
elif dim[2] != 1 and dim[3] == 1:
fail = apply2D(1., niter, eps, ntype=4)
fail = apply2D(1., -1, niter, eps, ntype=4)
else: fail = smooth1D(niter, eps)
else: fail = smooth1D(niter, eps) # all zones

Expand Down Expand Up @@ -1039,9 +1050,9 @@ def copyDistrib():
# Traitement
if dim[0] == 'Structured':
if dim[2] != 1 and dim[3] != 1:
fail = apply3D(1., 1, source, ntype=3)
fail = apply3D(1., -1, 1, source, ntype=3)
elif dim[2] != 1 and dim[3] == 1:
fail = apply2D(1., 1, source, ntype=3)
fail = apply2D(1., -1, 1, source, ntype=3)
else: fail = copyDistrib1D(source)
else: fail = copyDistrib1D(source) # all zones

Expand Down Expand Up @@ -1275,7 +1286,7 @@ def createApp(win):
B = TTK.Button(Frame, text="Uniformize", command=uniformize)
B.grid(row=0, column=0, sticky=TK.EW)
BB = CTK.infoBulle(parent=B, text='Uniformize an edge with regular spacing.')
B = TTK.OptionMenu(Frame, VARS[2], 'NFactor', 'Density', 'Npts')
B = TTK.OptionMenu(Frame, VARS[2], 'NFactor', 'Density', 'Npts', 'H')
B.grid(row=0, column=1, sticky=TK.EW)
B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=7)
B.grid(row=0, column=2, columnspan=2, sticky=TK.EW)
Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/CPlot/apps/tkView.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ def setStyle(event=None):
elif v == 'Multicolor wireframes': style = 1
elif v == 'Multicolor wires+solid': style = 2
elif v == 'Black wires+solid': style = 3
elif v == 'Multicolor wires+solid2': style = 4
elif v == 'Black wires+solid2': style = 4
CPlot.setState(meshStyle=style)
style = 0; v = VARS[17].get()
if v == 'Monocolor/1-side': style = 0
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def createApp(win):
B = TTK.Label(Mesh, text="Style:")
B.grid(row=0, column=0, sticky=TK.EW)
BB = CTK.infoBulle(parent=B, text='Mesh style.')
B = TTK.OptionMenu(Mesh, VARS[16], 'Red wires+solid', 'Black wires+solid', 'Multicolor wireframes', 'Multicolor wires+solid', 'Multicolor wires+solid2', command=setStyle)
B = TTK.OptionMenu(Mesh, VARS[16], 'Red wires+solid', 'Black wires+solid', 'Multicolor wireframes', 'Multicolor wires+solid', 'Black wires+solid2', command=setStyle)
B.grid(row=0, column=1, sticky=TK.EW)

# - Solid frame -
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/CPlot/doc/source/CPlot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Actions
:type displayInfo: int
:param displayIsoLegend: 0 means no iso legend display (default: 0)
:type displayIsoLegend: int
:param meshStyle: 0: white solid and red wireframe, 1: colored wireframe, 2: colored solid and wireframe, 3: cyan solid and black wireframe (default: 2)
:param meshStyle: 0: white solid and red wireframe, 1: colored wireframe, 2: colored solid and wireframe, 3: cyan solid and black wireframe, 4: colored solid and black wireframe (default: 2)
:type meshStyle: int
:param solidStyle: 0: blue, 1: colored by zone, 3: white, 4: colored by zone outlined (default: 0)
:type solidStyle: int
Expand Down
Loading

0 comments on commit fd5569f

Please sign in to comment.