Skip to content

Commit 789622d

Browse files
author
deseilligny
committed
Self Sym Option in gen encoding
1 parent 1a8294d commit 789622d

File tree

2 files changed

+47
-33
lines changed

2 files changed

+47
-33
lines changed

MMVII/src/CodedTarget/cGenerateEncoding.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class cAppliGenerateEncoding : public cMMVII_Appli
227227
size_t mPerCircPerm;
228228
bool mMiror;
229229
bool mOkSelfSym;
230+
bool mShowSelfSym;
230231
bool mUseAiconCode;
231232
cCompEquiCodes * mCEC;
232233
std::vector<cCelCC*> mVOC;
@@ -250,6 +251,7 @@ cAppliGenerateEncoding::cAppliGenerateEncoding
250251
mPhProj (*this),
251252
mMiror (false),
252253
mOkSelfSym (true),
254+
mShowSelfSym (false),
253255
mCEC (nullptr)
254256
{
255257
}
@@ -278,7 +280,7 @@ cCollecSpecArg2007 & cAppliGenerateEncoding::ArgOpt(cCollecSpecArg2007 & anArgOp
278280
<< AOpt2007(mSpec.mUseHammingCode,"UHC","Use Hamming code")
279281
<< AOpt2007(mSpec.mPrefix,"Prefix","Prefix for output files")
280282
<< AOpt2007(mMiror,"Mir","Unify mirro codes")
281-
<< AOpt2007(mOkSelfSym,"OkSelfSym","Accept code with self symetry on period")
283+
<< AOpt2007(mOkSelfSym,"OkSelfSym","Accept code with self symetry on period",{eTA2007::HDV})
282284
<< AOpt2007(mNameOut,"Out","Name for output file")
283285
<< AOpt2007(mPostfixOut,"Postfix","Postfix for output file (def->default tagged extension")
284286
<< mPhProj.DPGndPt3D().ArgDirInOpt("GCPNames","Dir GCP for code selection on names")
@@ -411,16 +413,16 @@ int cAppliGenerateEncoding::Exe()
411413
// [1] ============= read initial value of cells
412414
mCEC = cCompEquiCodes::Alloc(mSpec.mNbBits,mPerCircPerm,mMiror,mOkSelfSym);
413415

414-
/*
415-
if (1)
416+
417+
if (mShowSelfSym)
416418
{
417-
for (const auto & aCEC : *mCEC)
418-
if (aCEC)
419+
for (const auto & aCEC : mCEC->VecOfCells() )
420+
if (aCEC && aCEC->mSelfSym)
419421
{
420-
422+
StdOut() << " SSC " << StrOfBitFlag(aCEC->mLowCode,1<<mSpec.mNbBits) << "\n";
421423
}
422424
}
423-
*/
425+
424426

425427
mVOC = mCEC->VecOfCells();
426428
StdOut() << "Size Cells init " << mVOC.size() << std::endl;
@@ -454,13 +456,16 @@ int cAppliGenerateEncoding::Exe()
454456
MMVII_INTERNAL_ASSERT_bench(aVCode[aK-1].y() < aVCode[aK].y(),"Not growing order for bitflag in 3D-AICON");
455457
}
456458

457-
for (size_t aK=0 ; aK<aVCode.size(); aK++)
458-
{
459-
cCelCC * aCel = mCEC->CellOfCode(aVCode[aK].y());
460-
aCel->mNum = aVCode[aK].x();
461-
MMVII_INTERNAL_ASSERT_bench(aCel!=0,"CellOfCode in3D AICON");
462-
MMVII_INTERNAL_ASSERT_bench(aVCode[aK].y()==(int)aCel->mLowCode,"CellOfCode in3D AICON");
463-
}
459+
for (size_t aK=0 ; aK<aVCode.size(); aK++)
460+
{
461+
cCelCC * aCel = mCEC->CellOfCode(aVCode[aK].y());
462+
if (aCel)
463+
{
464+
aCel->mNum = aVCode[aK].x();
465+
MMVII_INTERNAL_ASSERT_bench(aCel!=0,"CellOfCode in3D AICON");
466+
MMVII_INTERNAL_ASSERT_bench(aVCode[aK].y()==(int)aCel->mLowCode,"CellOfCode in3D AICON");
467+
}
468+
}
464469

465470

466471
}

MMVII/src/UtiMaths/bitcoding.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,18 @@ cCompEquiCodes::cCompEquiCodes(size_t aNbBits,size_t aPer,bool WithMirror,bool O
299299
{
300300
if (mVCodes2Cell[aCode] == nullptr)
301301
{
302-
cCelCC * aNewCel = new cCelCC(aCode);
303-
aNewCel->mNum = mVecOfCells.size();
304-
mVecOfCells.push_back(aNewCel);
305-
306-
AddCodeWithPermCirc(aCode,aNewCel);
307-
if (WithMirror)
308-
AddCodeWithPermCirc(BitMirror(aCode,mNbCodeUC),aNewCel);
309-
310-
AddAndResizeUp(mHistoNbBit,NbBits(aCode),1);
302+
if (OkSelfSym || (! CodeIsSelfmSym(aCode,mNbBits,mPeriod)))
303+
{
304+
cCelCC * aNewCel = new cCelCC(aCode);
305+
aNewCel->mNum = mVecOfCells.size();
306+
mVecOfCells.push_back(aNewCel);
307+
308+
AddCodeWithPermCirc(aCode,aNewCel);
309+
if (WithMirror)
310+
AddCodeWithPermCirc(BitMirror(aCode,mNbCodeUC),aNewCel);
311+
312+
AddAndResizeUp(mHistoNbBit,NbBits(aCode),1);
313+
}
311314
}
312315
else
313316
{
@@ -374,20 +377,25 @@ void cCompEquiCodes::AddCodeWithPermCirc(size_t aCode,cCelCC * aNewCel)
374377
}
375378
aNewCel->mSelfSym = CodeIsSelfmSym(aCode,mNbBits,mPeriod);
376379

377-
if ( aNewCel->mSelfSym )
378-
StdOut() << " SelfSym " << StrOfBitFlag(aCode,1<<mNbBits) << "\n";
379380
}
380381

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

383384

384385
std::vector<cCelCC*> cCompEquiCodes::VecOfUsedCode(const std::vector<cPt2di> & aVXY,bool Used)
385386
{
387+
// StdOut() << " LllLL=" << __LINE__ << "\n";
388+
386389
for (auto aPCel : mVecOfCells)
390+
{
387391
aPCel->mTmp = false;
392+
}
388393

389394
for (auto aXY : aVXY)
390-
mVCodes2Cell[aXY.y()]->mTmp = true;
395+
{
396+
if (mVCodes2Cell[aXY.y()])
397+
mVCodes2Cell[aXY.y()]->mTmp = true;
398+
}
391399

392400
std::vector<cCelCC*> aRes;
393401
for (auto aPCel : mVecOfCells)
@@ -448,15 +456,16 @@ void TestComputeCoding(size_t aNBBCoding,int aParity,size_t)
448456
std::unique_ptr<cCompEquiCodes> aCEC (cCompEquiCodes::Alloc(aNBBCoding));
449457
for (const auto & aPCel : aCEC->VecOfCells())
450458
{
451-
size_t aCode = aPCel->mLowCode;
452-
int aNbB = NbBits(aCode);
453-
bool takeIt = (aNbB%2==0) ? ((aParity & 2)!=0) : ((aParity & 1) !=0);
459+
// StdOut() << "LLL=" << __LINE__ << "Ptr=" << aPCel << "\n";
460+
size_t aCode = aPCel->mLowCode;
461+
int aNbB = NbBits(aCode);
462+
bool takeIt = (aNbB%2==0) ? ((aParity & 2)!=0) : ((aParity & 1) !=0);
454463

455-
if (takeIt)
456-
{
464+
if (takeIt)
465+
{
457466
size_t aLenRun = MaxRun2Length(aCode,size_t(1)<<aNBBCoding);
458-
aVCodeByRun.at(aLenRun).push_back(aPCel);
459-
}
467+
aVCodeByRun.at(aLenRun).push_back(aPCel);
468+
}
460469
}
461470

462471
int aCumul=0;

0 commit comments

Comments
 (0)