Skip to content

Commit

Permalink
Merge pull request #184 from vincentcasseau/main
Browse files Browse the repository at this point in the history
Connector: fix seg fault in 2D in gatherMatching
  • Loading branch information
vincentcasseau authored Sep 17, 2024
2 parents deab78f + c613d9a commit 1b37113
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Cassiopee/CPlot/apps/validCassiopee.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,8 +1539,12 @@ def setupLocal(**kwargs):
print('Info: comparing to local database.')
BASE4COMPARE = 'LOCAL'
os.environ['VALIDLOCAL'] = '.'
casFolder = os.path.join(os.getenv('CASSIOPEE'), "Cassiopee", "Valid{}".format(DATA))
if not os.access(casFolder, os.W_OK):
casFolder = os.path.join(os.getenv('CASSIOPEE'), "Cassiopee")
casValidFolder = os.path.join(casFolder, "Valid{}".format(DATA))
# Create ValidData folder if not present and permissions are OK
if os.access(casFolder, os.W_OK):
os.makedirs(casValidFolder, exist_ok=True)
else:
os.environ['VALIDLOCAL'] = os.path.join(os.getcwd(), "Valid{}".format(DATA))

if INTERACTIVE: WIDGETS['UpdateButton'].configure(state=TK.NORMAL)
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Connector/Connector/connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ namespace K_CONNECTOR

/* Functions used for gatherMatching functions */
void compIncrement(E_Int indwA1, E_Int imw1, E_Float* oppositeWins, E_Float* oppositePts,
E_Int& inci, E_Int& incj, E_Int& inciopp, E_Int& incjopp);
E_Int dimPb, E_Int& inci, E_Int& incj, E_Int& inciopp, E_Int& incjopp);

void compTrirac(E_Int im1, E_Int jm1, E_Int im2, E_Int jm2,
E_Int typewin1, E_Int inc1, E_Int inc2,
Expand Down
11 changes: 7 additions & 4 deletions Cassiopee/Connector/Connector/gatherMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ PyObject* K_CONNECTOR::gatherMatching(PyObject* self, PyObject* args)
inciopp = 1; incjopp = imw2;
}
// Build subwindows
compIncrement(inds1, imcw1, oppositeWins, oppositePts, incci, inccj, incciopp, inccjopp);
compIncrement(inds1, imcw1, oppositeWins, oppositePts, dimPb,
incci, inccj, incciopp, inccjopp);

jsw1 = inds1/imcw1; isw1 = inds1-jsw1*imcw1; iew1 = imcw1; jew1 = jsw1;
deltaw2 = 0; iwmax1 = imcw1;
Expand Down Expand Up @@ -847,13 +848,14 @@ E_Int K_CONNECTOR::signature(E_Int r1, E_Int r2, E_Int r3, E_Int var)
//=============================================================================
/* IN: indA1: index of first matching point of win now1
IN: imw1: size of win now1
IN: oppositeWins, oppositePts: infos for opposite matching pts: win number and index
IN: oppositeWins, oppositePts: infos for opposite matching pts: win number and index
IN: dimPb: problem dimension
OUT: inci, incj: valid increments for matching points in now1
OUT: inciopp, incjopp: valid increments for matching opposite points in now2
If no valid increment in one direction, set to 0 */
//==============================================================================
void K_CONNECTOR::compIncrement(
E_Int indA1, E_Int imw1, E_Float* oppositeWins, E_Float* oppositePts,
E_Int indA1, E_Int imw1, E_Float* oppositeWins, E_Float* oppositePts, E_Int dimPb,
E_Int& inci, E_Int& incj, E_Int& inciopp, E_Int& incjopp)
{
E_Int indB1 = indA1+1;
Expand All @@ -865,7 +867,8 @@ void K_CONNECTOR::compIncrement(
inci = 1;
inciopp = E_Int(oppositePts[indB1])-E_Int(oppositePts[indA1]);
}
if (oppositeWins[indD1] == oppositeWins[indA1])

if (dimPb == 3 && oppositeWins[indD1] == oppositeWins[indA1])
{
incj = imw1;
incjopp = E_Int(oppositePts[indD1])-E_Int(oppositePts[indA1]);
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Connector/Connector/gatherMatchingNM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ PyObject* K_CONNECTOR::gatherMatchingNM(PyObject* self, PyObject* args)
if ( nmatch==4)
{incjopp = indTab2[noOpp[2]]-indTab2[noOpp[0]];}
// Build subwindows
compIncrement(inds1, imcw1, oppositeWins, oppositePts, incci, inccj, incciopp, inccjopp);
compIncrement(inds1, imcw1, oppositeWins, oppositePts, dimPb, incci, inccj, incciopp, inccjopp);

jsw1 = inds1/imcw1; isw1 = inds1-jsw1*imcw1; iew1 = imcw1; jew1 = jsw1;
deltaw2=0; iwmax1 = imcw1;
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/KCore/KCore/Nuga/include/mesh_t.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ struct mesh_t
mesh_t(const mesh_t<eGEODIM(GEODIM+1), USTRIDE>& parent_mesh):
crd(crd), localiz(nullptr), neighbors(nullptr), oriented(parent_mesh.oriented)
{
parent_mesh.get_boundary<FIXSTRIDE>(*this);
parent_mesh.template get_boundary<FIXSTRIDE>(*this);
}

mesh_t(const construct_elt_t& e):localiz(nullptr), neighbors(nullptr), oriented(0), metric_type(eMetricType::ISO_MIN)
Expand Down

0 comments on commit 1b37113

Please sign in to comment.