Skip to content

Commit 2c261ae

Browse files
author
deseilligny
committed
In adding self sym in coded target generate
1 parent 3ed0312 commit 2c261ae

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

MMVII/include/MMVII_nums.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ class cCompEquiCodes : public cMemCheck
969969
static std::string NameCERNLookUpTable(size_t aNbBits); ///< name of file where are stored CERN'S LUT
970970
static std::string NameCERNPannel(size_t aNbBits); ///< name of file where are stored CERN'S 3D target
971971
/// allocate & compute code , return the same adress if param eq
972-
static cCompEquiCodes * Alloc(size_t aNbBits,size_t aPerAmbig=1,bool WithMirror=false);
972+
static cCompEquiCodes * Alloc(size_t aNbBits,size_t aPerAmbig=1,bool WithMirror=false,bool OkSelfSym=true);
973973

974974
/// For a set code (p.y()) return the cell containing them (or not contatining them)
975975
std::vector<cCelCC*> VecOfUsedCode(const std::vector<cPt2di> &,bool Used);
@@ -986,7 +986,7 @@ class cCompEquiCodes : public cMemCheck
986986
private :
987987
static std::string NameCERStuff(const std::string & aPrefix,size_t aNbBits); ///< name of file where are stored CERN'S 3D target
988988

989-
cCompEquiCodes(size_t aNbBits,size_t aPerdAmbig,bool WithMirror);
989+
cCompEquiCodes(size_t aNbBits,size_t aPerdAmbig,bool WithMirror,bool OkSelfSym);
990990
/// put all the code identic, up to a circular permutation, in the same cellu
991991
void AddCodeWithPermCirc(size_t aCode,cCelCC *);
992992

MMVII/src/CodedTarget/cGenerateEncoding.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class cAppliGenerateEncoding : public cMMVII_Appli
226226
int mP2;
227227
size_t mPerCircPerm;
228228
bool mMiror;
229+
bool mOkSelfSym;
229230
bool mUseAiconCode;
230231
cCompEquiCodes * mCEC;
231232
std::vector<cCelCC*> mVOC;
@@ -248,6 +249,7 @@ cAppliGenerateEncoding::cAppliGenerateEncoding
248249
cMMVII_Appli (aVArgs,aSpec),
249250
mPhProj (*this),
250251
mMiror (false),
252+
mOkSelfSym (true),
251253
mCEC (nullptr)
252254
{
253255
}
@@ -276,6 +278,7 @@ cCollecSpecArg2007 & cAppliGenerateEncoding::ArgOpt(cCollecSpecArg2007 & anArgOp
276278
<< AOpt2007(mSpec.mUseHammingCode,"UHC","Use Hamming code")
277279
<< AOpt2007(mSpec.mPrefix,"Prefix","Prefix for output files")
278280
<< AOpt2007(mMiror,"Mir","Unify mirro codes")
281+
<< AOpt2007(mOkSelfSym,"OkSelfSym","Accept code with self symetry on period")
279282
<< AOpt2007(mNameOut,"Out","Name for output file")
280283
<< AOpt2007(mPostfixOut,"Postfix","Postfix for output file (def->default tagged extension")
281284
<< mPhProj.DPGndPt3D().ArgDirInOpt("GCPNames","Dir GCP for code selection on names")
@@ -406,14 +409,19 @@ int cAppliGenerateEncoding::Exe()
406409
mP2 = (1<<mSpec.mNbBits);
407410

408411
// [1] ============= read initial value of cells
409-
mCEC = cCompEquiCodes::Alloc(mSpec.mNbBits,mPerCircPerm,mMiror);
412+
mCEC = cCompEquiCodes::Alloc(mSpec.mNbBits,mPerCircPerm,mMiror,mOkSelfSym);
413+
410414
/*
411415
if (1)
412416
{
413417
for (const auto & aCEC : *mCEC)
414-
if (aCEC-)
418+
if (aCEC)
419+
{
420+
421+
}
415422
}
416423
*/
424+
417425
mVOC = mCEC->VecOfCells();
418426
StdOut() << "Size Cells init " << mVOC.size() << std::endl;
419427

MMVII/src/UtiMaths/bitcoding.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ size_t N_LeftBitsCircPerm(size_t aSetFlag,size_t aPow2,size_t N)
127127
}
128128

129129

130+
bool CodeIsSelfmSym(size_t aCode,size_t aNbBits,size_t aPeriod)
131+
{
132+
size_t aCodeInit = aCode; // used to compute selfSimFound
133+
134+
for (size_t aBit=0 ; aBit<aNbBits ; aBit+=aPeriod)
135+
{
136+
if ((aBit!=0) && (aCode==aCodeInit))
137+
return true;
138+
139+
aCode = N_LeftBitsCircPerm(aCode,1<<aNbBits,aPeriod);
140+
141+
}
142+
return false;
143+
}
144+
130145
/// make a symetry bits, assuming a size NbIt, with aPow2= NbBit^2
131146

132147
size_t BitMirror(size_t aSetFlag,size_t aPow2)
@@ -273,7 +288,7 @@ size_t cCelCC::HammingDist(const cCelCC & aC2) const
273288

274289
//std::map<std::string,cCompEquiCodes*> cCompEquiCodes::TheMapCodes;
275290

276-
cCompEquiCodes::cCompEquiCodes(size_t aNbBits,size_t aPer,bool WithMirror) :
291+
cCompEquiCodes::cCompEquiCodes(size_t aNbBits,size_t aPer,bool WithMirror,bool OkSelfSym) :
277292
mNbBits (aNbBits),
278293
mPeriod (aPer),
279294
mNbCodeUC (size_t(1)<<mNbBits),
@@ -309,9 +324,9 @@ cCompEquiCodes::~cCompEquiCodes()
309324
DeleteAllAndClear(mVecOfCells);
310325
}
311326

312-
cCompEquiCodes * cCompEquiCodes::Alloc(size_t aNbBits,size_t aPer,bool WithMirror)
327+
cCompEquiCodes * cCompEquiCodes::Alloc(size_t aNbBits,size_t aPer,bool WithMirror,bool OkSelfSym)
313328
{
314-
return new cCompEquiCodes(aNbBits,aPer,WithMirror);
329+
return new cCompEquiCodes(aNbBits,aPer,WithMirror,OkSelfSym);
315330
/*
316331
std::string aInd = ToStr(aNbBits)+"_"+ ToStr(aPer) + "_" +ToStr(WithMirror);
317332
cCompEquiCodes* & aRef = TheMapCodes[aInd];
@@ -346,8 +361,6 @@ cCelCC * cCompEquiCodes::CellOfCode(size_t aCode)
346361

347362
void cCompEquiCodes::AddCodeWithPermCirc(size_t aCode,cCelCC * aNewCel)
348363
{
349-
size_t aCodeInit = aCode; // used to compute selfSimFound
350-
351364
for (size_t aBit=0 ; aBit<mNbBits ; aBit+=mPeriod)
352365
{
353366
// Test because code may have already been processed i
@@ -357,10 +370,12 @@ void cCompEquiCodes::AddCodeWithPermCirc(size_t aCode,cCelCC * aNewCel)
357370
mVCodes2Cell[aCode] = aNewCel;
358371
aNewCel->mEquivCode.push_back(aCode);
359372
}
360-
if ((aBit!=0) && (aCode==aCodeInit))
361-
aNewCel->mSelfSym = true;
362373
aCode = N_LeftBitsCircPerm(aCode,mNbCodeUC,mPeriod);
363374
}
375+
aNewCel->mSelfSym = CodeIsSelfmSym(aCode,mNbBits,mPeriod);
376+
377+
if ( aNewCel->mSelfSym )
378+
StdOut() << " SelfSym " << StrOfBitFlag(aCode,1<<mNbBits) << "\n";
364379
}
365380

366381
const std::vector<cCelCC*> & cCompEquiCodes::VecOfCells() const {return mVecOfCells;}

0 commit comments

Comments
 (0)