Skip to content

Commit

Permalink
CPlot: update selection roll
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Sep 14, 2024
1 parent 6ccda23 commit 4e4d421
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 24 deletions.
32 changes: 17 additions & 15 deletions Cassiopee/CPlot/CPlot/Plugins/mouseClick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ E_Int Data::findBlockContaining(double x, double y, double z,
E_Int& zone, E_Int& ind, E_Int& indE,
double& dist, E_Int& ncon)
{
E_Int nz, indl, inde;
E_Int nz, indl, inde, nconl;
double xmi, ymi, zmi, xma, yma, zma;
double d, dn, de;
E_Int nzmin = -1;
Expand Down Expand Up @@ -305,53 +305,55 @@ E_Int Data::findBlockContaining(double x, double y, double z,
else
{
findNearestPoint(x, y, z, (UnstructZone*)zonep, indl, dn);
inde = findElement(x, y, z, (UnstructZone*)zonep, de, ncon);
inde = findElement(x, y, z, (UnstructZone*)zonep, de, nconl);
}
d = MIN(dn, de);
if (zonep->active == 0) d = d + eps*0.01; // malus

if (d < dmin-1.e-10) // node ou centre plus proche
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelections.clear();
}
else if (d <= dmin+1.e-10) // meme point mini: compare dn ou de
{
if (ptrState->ambSelections.size() == 0) ptrState->ambSelections.push_back(nzmin);
ptrState->ambSelections.push_back(nz);
if (ptrState->ambSelections.size() == 0)
{ ptrState->ambSelections.insert(ptrState->ambSelections.end(), {nzmin,ind,indE,ncon}); }
ptrState->ambSelections.insert(ptrState->ambSelections.end(), {nz,indl,inde,nconl});
E_Int npos = ptrState->ambSelections.size()/4-1;
if (zonep->dim == 1 && _zones[nzmin]->dim == 1)
{
if (de < dminElt)
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelSet = ptrState->ambSelections.size()-1;
ptrState->ambSelSet = npos;
}
else if (dn < dminNode)
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelSet = ptrState->ambSelections.size()-1;
ptrState->ambSelSet = npos;
}
}
else if (zonep->dim == 1 && _zones[nzmin]->dim != 1)
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelSet = ptrState->ambSelections.size()-1;
ptrState->ambSelSet = npos;
}
else if (de < dminElt && _zones[nzmin]->dim != 1)
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelSet = ptrState->ambSelections.size()-1;
ptrState->ambSelSet = npos;
}
else if (dn < dminNode && _zones[nzmin]->dim != 1)
{
dmin = d; nzmin = nz; ind = indl; indE = inde;
dmin = d; nzmin = nz; ind = indl; indE = inde; ncon = nconl;
dminElt = de; dminNode = dn;
ptrState->ambSelSet = ptrState->ambSelections.size()-1;
ptrState->ambSelSet = npos;
}
}
}
Expand Down
68 changes: 62 additions & 6 deletions Cassiopee/CPlot/CPlot/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void Data::keyboard(unsigned char key, E_Int x, E_Int y)
}

// -- Change selected zone in case of ambiguous selection --
case 'n':
case 'w':
{
changeAmbSelection();
break;
Expand Down Expand Up @@ -1386,18 +1386,74 @@ void Data::changeAppearance()
void Data::changeAmbSelection()
{
std::vector<E_Int>& v = ptrState->ambSelections;
E_Int vsize = v.size();
E_Int zone, ind, inde, ncon;
Zone* z = NULL;
E_Int vsize = v.size()/4;
if (vsize <= 1) return;
ptrState->ambSelSet += 1;
if (ptrState->ambSelSet >= vsize) ptrState->ambSelSet = 0;
E_Int zone = v[ptrState->ambSelSet];

bool active = false;
E_Int roll = 0;
while (roll < vsize)
{
ptrState->ambSelSet += 1;
if (ptrState->ambSelSet >= vsize) ptrState->ambSelSet = 0;
zone = v[ptrState->ambSelSet*4];
z = _zones[zone];
if (z->active == 1) break;
roll++;
}
if (z->active == 0) return; // no available active zone

ind = v[ptrState->ambSelSet*4+1];
inde = v[ptrState->ambSelSet*4+2];
ncon = v[ptrState->ambSelSet*4+3];

for (E_Int i = 0; i < _numberOfZones; i++)
_zones[i]->previouslySelected = _zones[i]->selected;

ptrState->selectedZone = zone+1;

Zone* z = _zones[zone];
for (E_Int i = 0; i < _numberOfZones; i++) _zones[i]->selected = 0;
z->selected = 1;

if (zone < _numberOfStructZones)
{
StructZone* zz = (StructZone*)z;
E_Int ni = zz->ni;
E_Int nj = zz->nj;
E_Int k = ind / (ni*nj);
E_Int j = (ind - k*ni*nj)/ni;
E_Int i = ind - k*ni*nj - j*ni;
ptrState->activePointI = i+1;
ptrState->activePointJ = j+1;
ptrState->activePointK = k+1;
}
else
{
ptrState->activePointI = ind; // indice du noeud le plus proche
ptrState->activePointJ = inde; // indice de l'element contenant P
ptrState->activePointL = ncon; // connectivite contenant l'element
UnstructZone* zz = (UnstructZone*)z;
if (zz->eltType[0] != 10) // autre que NGON
{
E_Int* c = zz->connect[ncon];
E_Int size = zz->eltSize[ncon];
E_Int ne = zz->nec[ncon];
E_Int v = 0;
E_Int prev = 0;
for (E_Int nc = 0; nc < ncon; nc++) prev += zz->nec[nc];
for (E_Int nv = 0; nv < size; nv++)
{
if (c[inde-prev+nv*ne] == ind+1) break;
}
ptrState->activePointK = -v-1;
}
//else ptrState->activePointK = findFace(posX, posY, posZ, indE, zz, dist);
}
for (E_Int n = 0; n < z->nfield; n++)
{
double* f = z->f[n];
ptrState->activePointF[n] = f[ind];
}

}
8 changes: 7 additions & 1 deletion Cassiopee/CPlot/apps/tkMapEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,15 +1153,21 @@ def enforceLocal(event=None):

CAD = Internal.getNodeFromName1(z, 'CAD')

#print("imin=",imin,"imax",imax,"ind",ind,"npts",npts)
if imin > 1: z0 = T.subzone(z, (1,1,1), (imin,-1,-1))
else: z0 = None
if ind > 2: zp1 = T.subzone(z, (max(imin,1),1,1), (ind+1,-1,-1))
if ind > 1: zp1 = T.subzone(z, (max(imin,1),1,1), (ind+1,-1,-1))
else: zp1 = None
if ind < npts-1: zp2 = T.subzone(z, (ind+1,1,1), (min(imax, npts),-1,-1))
else: zp2 = None
if imax < npts: z1 = T.subzone(z, (imax,1,1), (npts,-1,-1))
else: z1 = None

if zp1 is None and zp2 is None:
if z0 is not None: zp1 = z0; z0 = None
elif z1 is not None: zp2 = z1; z1 = None
else: print("Error: can not remesh edge.")

if zp1 is not None:
P0 = C.getValue(zp1, 'GridCoordinates', 0)
P1 = C.getValue(zp1, 'GridCoordinates', 1)
Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/Converter/install
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ then
INSTALLPATH="$1"
else
echo 'install: install in $CASSIOPEE/Dist/bin/$ELSAPROD'
echo ' -or- '
echo ' -or-'
echo 'install <dir>: install in directory <dir>.'
exit 1
fi
Expand Down Expand Up @@ -52,7 +52,7 @@ if [ $PRODMODE -le 1 ]; then
fi
else
python $sconsf install prefix="$INSTALLPATH" "$SCONSOPT"
fi
fi
[ $? != 0 ] && exit 1;
#touch Converter/converter.cpp
rm -f build/lib.*/Converter/converter.*
Expand Down

0 comments on commit 4e4d421

Please sign in to comment.