From 003d84278b2898f2e15c9d833c3af240aea57c16 Mon Sep 17 00:00:00 2001 From: benoit128 Date: Thu, 12 Sep 2024 14:41:15 +0200 Subject: [PATCH] OCC: blindage param, CPlot: simplify 1d --- .../CPlot/CPlot/Display/displaySMeshZone.cpp | 6 +- .../CPlot/CPlot/Display/displaySSolidZone.cpp | 8 +- .../CPlot/Display/displayUMeshHOZone.cpp | 13 +- .../CPlot/CPlot/Display/displayUMeshZone.cpp | 28 +-- .../CPlot/CPlot/Display/renderDLSMeshZone.cpp | 4 +- .../CPlot/CPlot/Display/renderDLUMeshZone.cpp | 149 ++++++++-------- .../CPlot/Display/renderDLUSolidHOZone.cpp | 163 +++++++++--------- Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp | 23 ++- Cassiopee/Post/Post/Mpi.py | 8 +- 9 files changed, 193 insertions(+), 209 deletions(-) diff --git a/Cassiopee/CPlot/CPlot/Display/displaySMeshZone.cpp b/Cassiopee/CPlot/CPlot/Display/displaySMeshZone.cpp index 27d9b9ce0..653ce7c4c 100644 --- a/Cassiopee/CPlot/CPlot/Display/displaySMeshZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/displaySMeshZone.cpp @@ -88,7 +88,7 @@ void Data::displaySMeshZone(StructZone* zonep, E_Int zone) double pt1[3]; double pt2[3]; double pt3[3]; double pt4[3]; E_Float nz = 1./_numberOfStructZones; -#include "meshStyles.h" + #include "meshStyles.h" // Grid dimensions E_Int ni = zonep->ni; @@ -102,7 +102,7 @@ void Data::displaySMeshZone(StructZone* zonep, E_Int zone) if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; } -#include "selection.h" + #include "selection.h" d = dist2BB(_view.xcam, _view.ycam, _view.zcam, zonep->xmin, zonep->ymin, zonep->zmin, @@ -111,7 +111,7 @@ void Data::displaySMeshZone(StructZone* zonep, E_Int zone) // steps computeSteps(zonep, stepi, stepj, stepk); -#include "displaySMeshZone.h" + #include "displaySMeshZone.h" // Zones 1D: on ajoute les noeuds if (is1D) diff --git a/Cassiopee/CPlot/CPlot/Display/displaySSolidZone.cpp b/Cassiopee/CPlot/CPlot/Display/displaySSolidZone.cpp index 314ceafec..615d5ac45 100644 --- a/Cassiopee/CPlot/CPlot/Display/displaySSolidZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/displaySSolidZone.cpp @@ -38,15 +38,13 @@ void Data::displaySSolidZone(StructZone* zonep, E_Int zone) getrgb = _plugins.zoneColorMap->f; E_Float nz = 1./_numberOfStructZones; -#include "solidStyles.h" + #include "solidStyles.h" // Ecrasement si renderTag if (zonep->colorR > -0.5) - {color1[0] = zonep->colorR; - color1[1] = zonep->colorG; - color1[2] = zonep->colorB;} + {color1[0] = zonep->colorR; color1[1] = zonep->colorG; color1[2] = zonep->colorB;} -#include "selection.h" + #include "selection.h" bool is1D = ((zonep->ni*zonep->nj == 1) | (zonep->ni*zonep->nk == 1) | (zonep->nj*zonep->nk == 1)); if (is1D == true && ptrState->mode == RENDER) glLineWidth(1.+5*zonep->shaderParam1); diff --git a/Cassiopee/CPlot/CPlot/Display/displayUMeshHOZone.cpp b/Cassiopee/CPlot/CPlot/Display/displayUMeshHOZone.cpp index 38cbb245d..67ce5b68e 100644 --- a/Cassiopee/CPlot/CPlot/Display/displayUMeshHOZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/displayUMeshHOZone.cpp @@ -95,9 +95,8 @@ void Data::displayUMeshZone_ho(UnstructZone* zonep, E_Int zone, E_Int zonet) double pt1[3]; double pt2[3]; double pt3[3]; double pt4[3]; E_Float nz = 1./_numberOfUnstructZones; -#include "meshStyles.h" - -#include "selection.h" + #include "meshStyles.h" + #include "selection.h" E_Int eltType0 = zonep->eltType[0]; bool is1D = false; @@ -116,20 +115,18 @@ void Data::displayUMeshZone_ho(UnstructZone* zonep, E_Int zone, E_Int zonet) // For BARS or NODES or 1D NGONS: display nodes if (is1D) - { + { glBegin(GL_QUADS); if (zonep->blank == 0) { - for (i = 0; i < zonep->np; i++) - { PLOTNODE; } + for (i = 0; i < zonep->np; i++) { PLOTNODE; } } else { for (i = 0; i < zonep->np; i++) { ret = _pref.blanking->f(this, i, zonep->blank, zone); - if (ret != 0) - { PLOTNODE; } + if (ret != 0) { PLOTNODE; } } } glEnd(); diff --git a/Cassiopee/CPlot/CPlot/Display/displayUMeshZone.cpp b/Cassiopee/CPlot/CPlot/Display/displayUMeshZone.cpp index 30cfe0c34..cfc7af40c 100644 --- a/Cassiopee/CPlot/CPlot/Display/displayUMeshZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/displayUMeshZone.cpp @@ -89,7 +89,7 @@ void Data::displayUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet) double pt1[3]; double pt2[3]; double pt3[3]; double pt4[3]; E_Float nz = 1./_numberOfUnstructZones; -#include "meshStyles.h" + #include "meshStyles.h" E_Int eltType0 = zonep->eltType[0]; bool is1D = false; @@ -97,33 +97,13 @@ void Data::displayUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet) if (is1D) { glLineWidth(3.); color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1.; } -#include "selection.h" + #include "selection.h" - /*if ( zonep->_is_high_order == true ) - { - int ishader = 0; - if ( eltType0 == UnstructZone::TRI ) - ishader = 1; // OK, element de type Tri_6 - if ( eltType0 == UnstructZone::QUAD ) - ishader = 2; // OK, element de type Quad_8 - if ( not this->_shaders.has_tesselation() ) { - this->_shaders.set_tesselation( ishader ); - } - - this->_shaders.activate( (short unsigned int)this->_shaders.shader_id(0) ); - std::cerr << "Shader id ::: " << this->_shaders.currentShader() << std::flush << std::endl; - int t_inner = this->ptrState->inner_tesselation; - int t_outer = this->ptrState->outer_tesselation; - this->_shaders[ this->_shaders.currentShader() ]->setUniform( "uInner", (float)t_inner ); - this->_shaders[ this->_shaders.currentShader() ]->setUniform( "uOuter", (float)t_outer ); - glPatchParameteri( GL_PATCH_VERTICES, zonep->eltSize ); - }*/ - -#include "displayUMeshZone.h" + #include "displayUMeshZone.h" // For BARS or NODES or 1D NGONS: display node if (is1D) - { + { glBegin(GL_QUADS); if (zonep->blank == 0) { diff --git a/Cassiopee/CPlot/CPlot/Display/renderDLSMeshZone.cpp b/Cassiopee/CPlot/CPlot/Display/renderDLSMeshZone.cpp index 544af2ec7..1ed8da6d5 100644 --- a/Cassiopee/CPlot/CPlot/Display/renderDLSMeshZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/renderDLSMeshZone.cpp @@ -88,7 +88,7 @@ void DataDL::renderGPUSMeshZone(StructZone* zonep, E_Int zone) double pt1[3]; double pt2[3]; double pt3[3]; double pt4[3]; E_Float nz = 1./_numberOfStructZones; -#include "meshStyles.h" + #include "meshStyles.h" double* x = zonep->x; double* y = zonep->y; @@ -102,7 +102,7 @@ void DataDL::renderGPUSMeshZone(StructZone* zonep, E_Int zone) 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" + #include "selection.h" d = dist2BB(_view.xcam, _view.ycam, _view.zcam, zonep->xmin, zonep->ymin, zonep->zmin, diff --git a/Cassiopee/CPlot/CPlot/Display/renderDLUMeshZone.cpp b/Cassiopee/CPlot/CPlot/Display/renderDLUMeshZone.cpp index 4d6393905..8805224bc 100644 --- a/Cassiopee/CPlot/CPlot/Display/renderDLUMeshZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/renderDLUMeshZone.cpp @@ -63,89 +63,88 @@ //============================================================================= void DataDL::renderGPUUMeshZone(UnstructZone* zonep, E_Int zone, E_Int zonet) { - ZoneImplDL* zImpl = static_cast(zonep->ptr_impl); - if (zImpl->_DLmesh == 0) - { - displayUMeshZone(zonep, zone, zonet); - return; - } - E_Int i, ret; + ZoneImplDL* zImpl = static_cast(zonep->ptr_impl); + if (zImpl->_DLmesh == 0) + { + displayUMeshZone(zonep, zone, zonet); + return; + } + E_Int i, ret; - // Style colors - float color1[3]; float color2[3]; + // Style colors + float color1[3]; float color2[3]; - // Colormap - float r, g, b; - void (*getrgb)(Data * data, double, float*, float*, float*); - getrgb = _plugins.zoneColorMap->f; + // Colormap + float r, g, b; + void (*getrgb)(Data * data, double, float*, float*, float*); + getrgb = _plugins.zoneColorMap->f; - // For node rendering (1D zones) - double dref = 0.004; - double xi, yi, zi; - double viewMatrix[16]; - glGetDoublev(GL_MODELVIEW_MATRIX, viewMatrix); - double right[3]; - right[0] = viewMatrix[0]; - right[1] = viewMatrix[4]; - right[2] = viewMatrix[8]; - double up[3]; - up[0] = viewMatrix[1]; - up[1] = viewMatrix[5]; - up[2] = viewMatrix[9]; - double xcam = _view.xcam; - double ycam = _view.ycam; - double zcam = _view.zcam; - double dx, dy, dz, dist, d; - double pru0, pru1, pru2, mru0, mru1, mru2; - double pt1[3]; - double pt2[3]; - double pt3[3]; - double pt4[3]; + // For node rendering (1D zones) + double dref = 0.004; + double xi, yi, zi; + double viewMatrix[16]; + glGetDoublev(GL_MODELVIEW_MATRIX, viewMatrix); + double right[3]; + right[0] = viewMatrix[0]; + right[1] = viewMatrix[4]; + right[2] = viewMatrix[8]; + double up[3]; + up[0] = viewMatrix[1]; + up[1] = viewMatrix[5]; + up[2] = viewMatrix[9]; + double xcam = _view.xcam; + double ycam = _view.ycam; + double zcam = _view.zcam; + double dx, dy, dz, dist, d; + double pru0, pru1, pru2, mru0, mru1, mru2; + double pt1[3]; + double pt2[3]; + double pt3[3]; + double pt4[3]; - E_Float nz = 1. / _numberOfUnstructZones; -#include "meshStyles.h" + E_Float nz = 1. / _numberOfUnstructZones; + #include "meshStyles.h" - double* x = zonep->x; - double* y = zonep->y; - double* z = zonep->z; - 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" + double* x = zonep->x; + double* y = zonep->y; + double* z = zonep->z; + 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" - // glCallList(zonep->_DLmesh); - if (zonep->_is_high_order == true) - { - int ishader = 3; - this->_shaders.set_tesselation(ishader); - this->_shaders.activate((short unsigned int)this->_shaders.shader_id(shader::None)); - int t_outer = this->ptrState->outer_tesselation; - this->_shaders[this->_shaders.currentShader()]->setUniform("uOuter", (float)t_outer); - this->_shaders[this->_shaders.currentShader()]->setUniform( "patch_size", 3 ); + if (zonep->_is_high_order == true) + { + int ishader = 3; + this->_shaders.set_tesselation(ishader); + this->_shaders.activate((short unsigned int)this->_shaders.shader_id(shader::None)); + int t_outer = this->ptrState->outer_tesselation; + this->_shaders[this->_shaders.currentShader()]->setUniform("uOuter", (float)t_outer); + this->_shaders[this->_shaders.currentShader()]->setUniform( "patch_size", 3 ); - glPatchParameteri( GL_PATCH_VERTICES, GLint(3) ); - } - glCallList(zImpl->_DLmesh); + glPatchParameteri( GL_PATCH_VERTICES, GLint(3) ); + } + glCallList(zImpl->_DLmesh); - // For BARS, NODE, 1D NGONS: display node - if (is1D) + // For BARS, NODE, 1D NGONS: display node + if (is1D) + { + glBegin(GL_QUADS); + if (zonep->blank == 0) + { + for (i = 0; i < zonep->np; i++) { PLOTNODE; } + } + else { - glBegin(GL_QUADS); - if (zonep->blank == 0) - { - for (i = 0; i < zonep->np; i++) { PLOTNODE; } - } - else - { - for (i = 0; i < zonep->np; i++) - { - ret = _pref.blanking->f(this, i, zonep->blank, zonet); - if (ret != 0) { PLOTNODE; } - } - } - glEnd(); + for (i = 0; i < zonep->np; i++) + { + ret = _pref.blanking->f(this, i, zonep->blank, zonet); + if (ret != 0) { PLOTNODE; } + } } - this->_shaders.activate((short unsigned int)0); - glLineWidth(1.); + glEnd(); + } + this->_shaders.activate((short unsigned int)0); + glLineWidth(1.); } diff --git a/Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp b/Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp index 3445e3ba9..fc76bb5ba 100644 --- a/Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp +++ b/Cassiopee/CPlot/CPlot/Display/renderDLUSolidHOZone.cpp @@ -27,100 +27,97 @@ //============================================================================= void DataDL::renderGPUUSolidHOZone(UnstructZone *zonep, E_Int zone, E_Int zonet) { - //std::cerr << "Call display " << std::flush << std::endl; - //this->displayUSolidHOZone(zonep, zone, zonet); - //return; - // Style - float color1[3]; float color2[3]; + // Style + float color1[3]; float color2[3]; - // Colormap - float r, g, b; - void ( *getrgb )( Data * data, double, float *, float *, float * ); - getrgb = _plugins.zoneColorMap->f; + // 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" + 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; - } + // Ecrasement si renderTag + if (zonep->colorR > -0.5) + { + color1[ 0 ] = zonep->colorR; + color1[ 1 ] = zonep->colorG; + color1[ 2 ] = zonep->colorB; + } -#include "selection.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.); + 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 ); + // 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 - { - triggerShader(*zonep, zonep->material, s, color1); - E_Int ff; - double offb = 0.; - E_Int ret1, ret2, ret3, ret4, i, n1, n2, n3, n4; + // Only for textured rendering, we use vect display ======================= + if (ptrState->mode == RENDER && zonep->material == 14 && zonep->texu != NULL) // Textured rendering + { + triggerShader(*zonep, zonep->material, s, color1); + E_Int ff; + double offb = 0.; + E_Int ret1, ret2, ret3, ret4, i, n1, n2, n3, n4; #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 et TRI_15 - if (eltType0 == UnstructZone::QUAD) - ishader = 2; // OK, element de type Quad_8 ou Quad_9, QUAD_12, QUAD_16 et QUAD_25 - // CONTINUER DE MEME POUR LES AUTRES TYPES DE HO - 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); - } - GLenum error = glGetError(); - if (error != GL_NO_ERROR) - { - std::cerr << __PRETTY_FUNCTION__ << ": get error n°0x" << std::hex << error << std::dec << std::flush << std::endl; - } - // 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] ); - ZoneImplDL *zImpl = static_cast(zonep->ptr_impl); - glPatchParameteri(GL_PATCH_VERTICES, GLint(zonep->eltSize[0])); - glCallList(zImpl->_DLsolid); 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 et TRI_15 + if (eltType0 == UnstructZone::QUAD) + ishader = 2; // OK, element de type Quad_8 ou Quad_9, QUAD_12, QUAD_16 et QUAD_25 + // CONTINUER DE MEME POUR LES AUTRES TYPES DE HO + 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); + } + GLenum error = glGetError(); + if (error != GL_NO_ERROR) + { + std::cerr << __PRETTY_FUNCTION__ << ": get error n°0x" << std::hex << error << std::dec << std::flush << std::endl; + } + // 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] ); + ZoneImplDL *zImpl = static_cast(zonep->ptr_impl); + glPatchParameteri(GL_PATCH_VERTICES, GLint(zonep->eltSize[0])); + glCallList(zImpl->_DLsolid); + glLineWidth(1.); } diff --git a/Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp b/Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp index ff15f2d45..620f21b87 100644 --- a/Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp +++ b/Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp @@ -39,7 +39,7 @@ // ultimate (best) functions // ============================================================================ -// Return uniform distribution of NbPoints on edge +// Return uniform (h constant) distribution of NbPoints on edge // ============================================================================ E_Int __getUniform(const TopoDS_Edge& E, E_Int nbPoints, E_Float*& ue) { @@ -47,6 +47,13 @@ E_Int __getUniform(const TopoDS_Edge& E, E_Int nbPoints, E_Float*& ue) GeomAdaptor_Curve geomAdap(C0.Curve()); // Geometric Interface <=> access to discretizations tool Standard_Real u0 = geomAdap.FirstParameter(); Standard_Real u1 = geomAdap.LastParameter(); + if (BRep_Tool::Degenerated(E)) + { + nbPoints = 2; + ue = new E_Float [nbPoints]; + for (E_Int i = 0; i < nbPoints; i++) ue[i] = u0; + return 1; + } GCPnts_UniformAbscissa param(geomAdap, int(nbPoints), u0, u1); ue = new E_Float [nbPoints]; for (E_Int i = 0; i < nbPoints; i++) ue[i] = param.Parameter(i+1); @@ -74,7 +81,15 @@ E_Int __getParamHmax(const TopoDS_Edge& E, E_Float hmax, E_Int& nbPoints, E_Floa nbPoints = std::max(nbPoints, E_Int(3)); GCPnts_UniformAbscissa param(geomAdap, int(nbPoints), u0, u1); ue = new E_Float [nbPoints]; - for (E_Int i = 0; i < nbPoints; i++) ue[i] = param.Parameter(i+1); + try // that fails some times + { + for (E_Int i = 0; i < nbPoints; i++) ue[i] = param.Parameter(i+1); + } + catch (const Standard_Failure& theErr) + { + for (E_Int i = 0; i < nbPoints; i++) ue[i] = i*(u1-u0)/(nbPoints-1)+u0; + printf("Warning: regular param used on edge.\n"); + } printf("L=%f hmax=%f nbPoints=" SF_D_ "\n", L, hmax, nbPoints); fflush(stdout); return 0; } @@ -90,7 +105,7 @@ E_Int __getParamHausd(const TopoDS_Edge& E, E_Float hausd, E_Int& nbPoints, E_Fl Standard_Real u1 = geomAdap.LastParameter(); if (BRep_Tool::Degenerated(E)) { - nbPoints=2; + nbPoints = 2; ue = new E_Float [nbPoints]; for (E_Int i = 0; i < nbPoints; i++) ue[i] = u0; return 1; @@ -107,7 +122,7 @@ E_Int __getParamHausd(const TopoDS_Edge& E, E_Float hausd, E_Int& nbPoints, E_Fl void geom1(E_Float u0, E_Float u1, E_Float h0, E_Float h1, E_Int& N, E_Float*& ue) { E_Float r = (u1-u0-h0)/(u1-u0-h1); - printf("r=%f\n", r); + //printf("r=%f\n", r); E_Float a = log(r); if (a > 1.e-12) // r!=1 { diff --git a/Cassiopee/Post/Post/Mpi.py b/Cassiopee/Post/Post/Mpi.py index 50d6e4e5a..5b1a21c08 100644 --- a/Cassiopee/Post/Post/Mpi.py +++ b/Cassiopee/Post/Post/Mpi.py @@ -15,10 +15,9 @@ def computeGradLSQ(t, fldNames): fcenters, fareas = G.getFaceCentersAndAreas(t) centers = G.getCellCenters(t, fcenters, fareas) zones = Internal.getZones(t) - for i in range(len(zones)): + for i, zone in enumerate(zones): cc = centers[i] if cc is None: continue - zone = zones[i] fsolc = Internal.getNodeFromName(zone, Internal.__FlowSolutionCenters__) Internal.createNode('CCx', 'DataArray_t', cc[0], None, fsolc) Internal.createNode('CCy', 'DataArray_t', cc[1], None, fsolc) @@ -33,9 +32,9 @@ def computeGradLSQ(t, fldNames): # get comm list zgc = Internal.getNodeFromType(zone, 'ZoneGridConnectivity_t') - if zgc == None: raise ValueError('ZoneGridConnectivity not found') + if zgc is None: raise ValueError('ZoneGridConnectivity not found.') comms = Internal.getNodesFromType(zgc, 'GridConnectivity1to1_t') - if comms == None: raise ValueError('GridConnectivity1to1 not found') + if comms is None: raise ValueError('GridConnectivity1to1 not found.') ptlists = [] for comm in comms: ptlist = Internal.getNodeFromName(comm, 'PointList')[1] @@ -44,7 +43,6 @@ def computeGradLSQ(t, fldNames): # compute lsq gradients parRun = 1 t = P.computeGradLSQ(t, fldNames, parRun, fcenters, ptlists, rfields) - # TODO(Imad): delete cell centers from tree return t