diff --git a/Cassiopee/CPlot/CPlot/Plugins/screenDump.cpp b/Cassiopee/CPlot/CPlot/Plugins/screenDump.cpp index 6fc11215f..b2a87c759 100644 --- a/Cassiopee/CPlot/CPlot/Plugins/screenDump.cpp +++ b/Cassiopee/CPlot/CPlot/Plugins/screenDump.cpp @@ -409,12 +409,12 @@ char* Data::export2Image(E_Int exportWidth, E_Int exportHeight) offscreenD[ind] = depth[ind]; } } - } } - // export dans buffer - char* offscreen = (char*)ptrState->offscreenBuffer[ptrState->frameBuffer+1]; - for (E_Int i = 0; i < screenSize*3; i++) buffer[i] = offscreen[i]; - free(depth); + } + // export dans buffer + char* offscreen = (char*)ptrState->offscreenBuffer[ptrState->frameBuffer+1]; + for (E_Int i = 0; i < screenSize*3; i++) buffer[i] = offscreen[i]; + free(depth); #else printf("Error: CPlot: mesa offscreen unavailable.\n"); #endif @@ -429,6 +429,9 @@ char* Data::export2Image(E_Int exportWidth, E_Int exportHeight) glDeleteFramebuffersEXT(1, &fb); #endif + // software postprocessing on final buffer (just before screen dump) + + return buffer; } diff --git a/Cassiopee/CPlot/CPlot/PyTree.py b/Cassiopee/CPlot/CPlot/PyTree.py index eb9878ea4..9493eaf7b 100644 --- a/Cassiopee/CPlot/CPlot/PyTree.py +++ b/Cassiopee/CPlot/CPlot/PyTree.py @@ -1436,7 +1436,7 @@ def display360ODS__(t, posCam, posEye, dirCam, offscreen, exportRez, stereoShift return None # subfunction of display 360. Display the n views with rotating posCam -# tentative only for osmesa +# only for osmesa def display360ODS2__(t, posCam, posEye, dirCam, offscreen, exportRez, stereoShift, kwargs): import KCore.Vector as Vector @@ -1730,8 +1730,6 @@ def panoramaStereo(export, export1, export2, exportRez, type360=0): pr2 = Internal.getNodeFromName2(a2, v) if pr1 is not None and pr2 is not None: pr1 = pr1[1]; pr2 = pr2[1] - pr1 = pr1[:,::-1] - pr2 = pr2[:,::-1] pr[0:ni,0:nj] = pr1[0:ni, 0:nj] pr[0:ni,nj:2*nj] = pr2[0:ni, 0:nj] else: diff --git a/Cassiopee/CPlot/CPlot/blur.cpp b/Cassiopee/CPlot/CPlot/blur.cpp index 383eeee88..c1ff67933 100644 --- a/Cassiopee/CPlot/CPlot/blur.cpp +++ b/Cassiopee/CPlot/CPlot/blur.cpp @@ -33,6 +33,8 @@ void createGaussFilter(E_Float sigma, E_Int n, E_Float* c) { c[i] = exp( -(i*i) / (2.*sigma2)) / (sigma*sqrt(2.*M_PI)); } + + /* printf("gaussian coefficients: "); for (E_Int i = 0; i <= n; i++) printf("%g ", c[i]); printf("\n"); @@ -44,9 +46,10 @@ void createGaussFilter(E_Float sigma, E_Int n, E_Float* c) sum += c[i]; } printf("sum=%g\n", sum); + */ } -// Apply gaussian blur to in +// Apply gaussian blur to in (single scalar) // IN: in: color array // IN: ni,nj: image size // IN: c: kernel coef @@ -54,34 +57,108 @@ void createGaussFilter(E_Float sigma, E_Int n, E_Float* c) // OUT: out: color array (already allocated) void gaussianBlur2(E_Float* in, E_Int ni, E_Int nj, E_Float* c, E_Int n, E_Float* out) { + E_Int ind; + + // filter + for (E_Int j = 0; j < nj; j++) + for (E_Int i = 0; i < ni; i++) + { + ind = i+j*ni; + out[ind] = in[ind]*c[0]; + } + // filter en i for (E_Int j = 0; j < nj; j++) for (E_Int i = n; i < ni-n; i++) { - out[i+j*ni] = in[i+j*ni]*c[0]; - + ind = i+j*ni; for (E_Int k = 1; k <= n; k++) { - out[i+j*ni] += in[i-k+j*ni]*c[k]; // right - out[i+j*ni] += in[i+k+j*ni]*c[k]; // left + out[ind] += in[ind-k]*c[k]; // right + out[ind] += in[ind+k]*c[k]; // left } } // filter en j for (E_Int j = n; j < nj-n; j++) for (E_Int i = 0; i < ni; i++) + { + ind = i+j*ni; + in[ind] = out[ind]*c[0]; + + for (E_Int k = 1; k <= n; k++) + { + out[ind] += in[ind-k*ni]*c[k]; + out[ind] += in[ind+k*ni]*c[k]; + } + } +} + +// identical but applied to interlaced color buffer (3), return out +void gaussianBlur3(char* in, E_Int ni, E_Int nj, E_Float* c, E_Int n, float* depth, char* out) +{ + float dmin, dmax; + // compute min/max of depth + dmin = 1.e30; dmax = -1.e30; + for (E_Int i = 0; i < ni*nj; i++) + { + dmin = std::min(dmin, depth[i]); + dmax = std::max(dmax, depth[i]); + } + // normalize depth + for (E_Int i = 0; i < ni*nj; i++) + { + depth[i] = (depth[i]-dmin)/(dmax-dmin); + } + + // assombrit les pixels lointains + double percentage = 0.8; + for (E_Int i = 0; i < ni*nj; i++) + { + if (depth[i] > 0.5) + { + out[3*i] = in[3*i]*percentage; + out[3*i+1] = in[3*i+1]*percentage; + out[3*i+2] = in[3*i+2]*percentage; + } + } + + // dof + /* + // blur en i + for (E_Int j = 0; j < nj; j++) + for (E_Int i = n; i < ni-n; i++) + { + ind = i+j*ni; + out[3*ind] = in[3*ind]*c[0]; + out[3*ind+1] = in[3*ind+1]*c[0]; + out[3*ind+2] = in[3*ind+2]*c[0]; + + for (E_Int k = 1; k <= n; k++) + { + out[ind] += in[i-k+j*ni]*c[k]; // right + out[ind] += in[i+k+j*ni]*c[k]; // left + } + } + + // blur en j + for (E_Int j = n; j < nj-n; j++) + for (E_Int i = 0; i < ni; i++) { in[i+j*ni] = out[i+j*ni]*c[0]; for (E_Int k = 1; k <= n; k++) { - in[i+j*ni] += out[i+(j-k)*ni]*c[k]; - in[i+j*ni] += out[i+(j+k)*ni]*c[k]; + out[i+j*ni] += in[i+(j-k)*ni]*c[k]; + out[i+j*ni] += in[i+(j+k)*ni]*c[k]; } } + */ + // antialiasing + } -// bllur array +// blur array PyObject* K_CPLOT::blur(PyObject* self, PyObject* args) { // Get the 4 arrays of cube images (left, right, bottom, top, back, front) diff --git a/Cassiopee/CPlot/CPlot/panorama.cpp b/Cassiopee/CPlot/CPlot/panorama.cpp index 5069d70d4..ec0d0c691 100644 --- a/Cassiopee/CPlot/CPlot/panorama.cpp +++ b/Cassiopee/CPlot/CPlot/panorama.cpp @@ -266,7 +266,7 @@ PyObject* K_CPLOT::panorama(PyObject* self, PyObject* args) ty = (1.*jj) / njl1; theta = tinf + tx * tsup; // between -pi and pi - phi = M_PI/2. - ty * M_PI; // between pi/2 and -pi/2 + phi = -M_PI/2. + ty * M_PI; // between pi/2 and -pi/2 x = cos(phi) * sin(theta); y = sin(phi); @@ -499,7 +499,7 @@ PyObject* K_CPLOT::panoramaODS(PyObject* self, PyObject* args) for (E_Int j = 0; j < njl; j++) { ty = (1.*j)/nj1; - phi = M_PI/2. - ty * M_PI; // between pi/2 and -pi/2 + phi = - M_PI/2. + ty * M_PI; // between pi/2 and -pi/2 ind = i + j*nil; diff --git a/Cassiopee/Envs/sh_Cassiopee_local b/Cassiopee/Envs/sh_Cassiopee_local index eba5e9e5a..6a3e6275d 100644 --- a/Cassiopee/Envs/sh_Cassiopee_local +++ b/Cassiopee/Envs/sh_Cassiopee_local @@ -33,7 +33,6 @@ if echo "$KC" | grep -q 'celeste'; then export MAC="visio"; fi if echo "$KC" | grep -q 'visung'; then export MAC="visung"; fi if echo "$KC" | grep -q 'giulia'; then export MAC="giulia"; fi if echo "$KC" | grep -q 'sator'; then export MAC="sator_cas"; fi -if echo "$KC" | grep -q 'jean-zay'; then export MAC="jean-zay"; fi if echo "$KC" | grep -q 'spiro'; then export MAC="spiro_el8"; fi if echo "$KC" | grep -q 'cobalt'; then export MAC="cobalt"; fi if echo "$KC" | grep -q 'irene'; then export MAC="irene"; fi @@ -742,21 +741,6 @@ elif [ "$MAC" = "sator_sph" ]; then export PRODMODE=1 export PIP_DISABLE_PIP_VERSION_CHECK=1 -elif [ "$MAC" = "jean-zay" ]; then -#-----------------------------jean-zay IDRIS --------------------------------------- - export ELSAPROD=jz_r8 - export ELSAPROD=$ELSAPROD$EXT - # Nbre de threads - export OMP_NUM_THREADS=40 - export KMP_AFFINITY="compact,1,0,granularity=fine,verbose" - # modules - #. /etc/profile.d/module.sh - module load intel-compilers/19.1.3 - module load intel-mpi/2019.9 - module load python/3.7.10 - module load hdf5/1.12.0 - export PYTHONEXE=python3 - elif [ "$MAC" = "adastra_cpu" ]; then #----------------------------- adastra cpu --------------------------------------- export ELSAPROD=adastra_cpu diff --git a/Cassiopee/Initiator/Initiator/MeshSize.py b/Cassiopee/Initiator/Initiator/MeshSize.py index 04a7fce71..de29a5285 100644 --- a/Cassiopee/Initiator/Initiator/MeshSize.py +++ b/Cassiopee/Initiator/Initiator/MeshSize.py @@ -51,6 +51,12 @@ def meshSize(UInf, RoInf, ReInf, LInf, esurc=0.012, yplus=1., algo='Turbulent'): else: raise ValueError('meshSize: unknown algo.') +def boundaryLayerHeight(ReInf, algo='Turbulent'): + if algo == 'Laminar': + delta = 0.75*5*ReInf**(-0.5) + elif algo == 'Turbulent': + delta = 0.75*0.37*ReInf**(-1./5.) + return delta if __name__ == '__main__': print(meshSize1(1., 1.225, 0.000017894, 1.0)) diff --git a/Cassiopee/OCC/OCC/Atomic/addLabel.cpp b/Cassiopee/OCC/OCC/Atomic/addLabel.cpp index 3ace1080b..2bb39b684 100644 --- a/Cassiopee/OCC/OCC/Atomic/addLabel.cpp +++ b/Cassiopee/OCC/OCC/Atomic/addLabel.cpp @@ -25,17 +25,38 @@ #include #include -// Assuming you have a document and a shape -Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); -TopoDS_Shape myShape = ...; // Your shape - -// Iterate over faces -for (TopExp_Explorer exp(myShape, TopAbs_FACE); exp.More(); exp.Next()) +//===================================================================== +// Add label to shape +//===================================================================== +PyObject* K_OCC::addLabel(PyObject* self, PyObject* args) { - TopoDS_Shape face = exp.Current(); - TDF_Label label; - if (shapeTool->FindShape(face, label)) + PyObject* hook; + if (!PYPARSETUPLE_(args, O, &hook)) return NULL; + + void** packet = NULL; +#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 1) + packet = (void**) PyCObject_AsVoidPtr(hook); +#else + packet = (void**) PyCapsule_GetPointer(hook, NULL); +#endif + + //TopTools_IndexedMapOfShape& edges = *(TopTools_IndexedMapOfShape*)packet[2]; + TopTools_IndexedMapOfShape& surfaces = *(TopTools_IndexedMapOfShape*)packet[1]; + + TopoDS_Shape* shp = (TopoDS_Shape*)packet[0]; + + // Assuming you have a document and a shape + Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); + TopoDS_Shape myShape = ...; // Your shape + + // Iterate over faces + for (TopExp_Explorer exp(myShape, TopAbs_FACE); exp.More(); exp.Next()) { - // Do something with the label + TopoDS_Shape face = exp.Current(); + TDF_Label label; + if (shapeTool->FindShape(face, label)) + { + // Do something with the label + } } }