Skip to content

Commit

Permalink
CPlot: add cpu panorama
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Jun 29, 2024
1 parent cf9a4b0 commit 12a60e5
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 29 deletions.
13 changes: 1 addition & 12 deletions Cassiopee/CPlot/CPlot/Display/renderDLUIsoSolidZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,16 @@
//=============================================================================
void DataDL::renderUIsoSolidZone(UnstructZone* zonep, E_Int zonet, E_Int nofield)
{
E_Int i, n1, n2;
float offb;
double blend;
E_Int ret1, ret2;

E_Int ne = zonep->ne;

ZoneImplDL* zoneImpl = static_cast<ZoneImplDL*>(zonep->ptr_impl);

// Blending
blend = 1.;
#include "selection2.h"

double* x = zonep->x; double* y = zonep->y; double* z = zonep->z;
E_Int eltType0 = zonep->eltType[0];
E_Int* connect = zonep->connect[0];
double fmin, fmax;
fmax = maxf[nofield]; fmin = minf[nofield];
double deltai = MAX(fmax-fmin, ISOCUTOFF);
float r;
deltai = 1./deltai;
double* f = zonep->f[nofield];

#ifdef __SHADERS__
int curr = _shaders.currentShader();
Expand Down
56 changes: 41 additions & 15 deletions Cassiopee/CPlot/CPlot/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,8 @@ def display360(t, **kwargs):
# resolution for the 6 view images
locRez = exportRez.split('x')[1]
locRez = int(locRez)//2
locRez = max(locRez, 100)
locRez = max(locRez, 100) # minimum 100 pixels
locRez = min(locRez, 8192) # maximum 8192 pixels, generally the max texture size
locRez = "%dx%d"%(locRez, locRez)

# display 6 views
Expand All @@ -1159,12 +1160,13 @@ def display360(t, **kwargs):
# Create the 360 image from cube images
import Converter.Mpi as Cmpi
if Cmpi.rank == 0:
if offscreen == 7: foffscreen = 1
else: foffscreen = offscreen
a = C.newPyTree(['Base'])
display(a, panorama=1,
offscreen=foffscreen, export=export, exportResolution=exportRez)
finalizeExport(foffscreen)
#if offscreen == 7: foffscreen = 1
#else: foffscreen = offscreen
#a = C.newPyTree(['Base'])
#display(a, panorama=1,
# offscreen=foffscreen, export=export, exportResolution=exportRez)
#finalizeExport(foffscreen)
panorama(export, exportRez)
Cmpi.barrier() # wait for completion

if stereo == 1: # left eye
Expand All @@ -1182,20 +1184,20 @@ def display360(t, **kwargs):

display360__(t, posCam, posEye, dirCam, offscreen, locRez, kwargs)
if Cmpi.rank == 0:
if offscreen == 7: foffscreen = 1
else: foffscreen = offscreen
a = C.newPyTree(['Base'])
display(a, panorama=1,
offscreen=foffscreen, export=export2, exportResolution=exportRez)
finalizeExport(foffscreen)
#if offscreen == 7: foffscreen = 1
#else: foffscreen = offscreen
#a = C.newPyTree(['Base'])
#display(a, panorama=1,
# offscreen=foffscreen, export=export2, exportResolution=exportRez)
#finalizeExport(foffscreen)
panorama(export, exportRez)

# assemble images
a1 = C.convertFile2PyTree(export)
a2 = C.convertFile2PyTree(export2)
a1 = Internal.getZones(a1)[0]
a2 = Internal.getZones(a2)[0]
a1[0] = "right"
a2[0] = "left"
a1[0] = "right"; a2[0] = "left"
locRez = exportRez.split('x')
ni = int(locRez[0]); nj = int(locRez[1])
a = G.cart((0,0,0), (1,1,1), (ni,2*nj,1))
Expand All @@ -1209,3 +1211,27 @@ def display360(t, **kwargs):
C.convertPyTree2File(a, export) # finale
Cmpi.barrier() # wait for completion
return None

def panorama(export, exportResolution):
res = exportResolution.split('x')
resx = int(res[0]); resy = int(res[1])
import Generator.PyTree as G
import CPlot.cplot
a1 = C.convertFile2PyTree('cube_left.png')
a1 = C.getFields('nodes', a1, api=3)[0]
a2 = C.convertFile2PyTree('cube_right.png')
a2 = C.getFields('nodes', a2, api=3)[0]
a3 = C.convertFile2PyTree('cube_bottom.png')
a3 = C.getFields('nodes', a3, api=3)[0]
a4 = C.convertFile2PyTree('cube_top.png')
a4 = C.getFields('nodes', a4, api=3)[0]
a5 = C.convertFile2PyTree('cube_back.png')
a5 = C.getFields('nodes', a5, api=3)[0]
a6 = C.convertFile2PyTree('cube_front.png')
a6 = C.getFields('nodes', a6, api=3)[0]
a7 = G.cart((0,0,0), (1,1,1), (resx, resy,1))
C._addVars(a7, ['r','g','b','a'])
a7f = C.getFields('nodes', a7, api=3)[0]
CPlot.cplot.panorama(a1, a2, a3, a4, a5, a6, a7f)
C.convertPyTree2File(a7, export)
return a7
1 change: 1 addition & 0 deletions Cassiopee/CPlot/CPlot/cplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static PyMethodDef Pycplot [] =
{"show", K_CPLOT::show, METH_VARARGS},
{"display1D", K_CPLOT::display1D, METH_VARARGS},
{"configure", K_CPLOT::configure, METH_VARARGS},
{"panorama", K_CPLOT::panorama, METH_VARARGS},
{NULL, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Cassiopee/CPlot/CPlot/cplot.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ PyObject* hide(PyObject* self, PyObject* args);
PyObject* show(PyObject* self, PyObject* args);
PyObject* display1D(PyObject* self, PyObject* args);
PyObject* configure(PyObject* self, PyObject* args);
PyObject* panorama(PyObject* self, PyObject* args);
}

E_Int getMode(PyObject* modeObject);
Expand Down
Loading

0 comments on commit 12a60e5

Please sign in to comment.