Index: trunk/ArchTOIPipe/ProcWSophya/genwproc.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/genwproc.cc	(revision 1498)
+++ trunk/ArchTOIPipe/ProcWSophya/genwproc.cc	(revision 1502)
@@ -6,7 +6,4 @@
 #include "ctimer.h"
 
-
-// #define DEBUGGENW 1 
-
 // -------------------------------------------------------------
 //   Class GenWindowTOIProcessor : generic processor with window
@@ -14,13 +11,15 @@
 
 ////////////////////////////////////////////////////////////////
-GenWindowTOIProcessor::GenWindowTOIProcessor(int nbinput,int nboutput
-                                   ,int wsz, int wstep, int wsztot)
+GenWindowTOIProcessor::GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput
+                                   ,int_4 wsz, int_4 wstep, int_4 wsztot)
 {
   if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !");
   if(nboutput<0) nboutput=0;
   if(wsz<2) throw ParmError("GenWindowTOIProcessor::Creator wsz<2 !");
-  if(wsz%2==0) wsz++;
+  if(wsz%2==0) {if(wsztot==wsz) wsztot++; wsz++;}
   if(wstep<1) wstep=1;
-  if(wsztot<wsz) wsztot = 2*wsz;  // CMV prise de decision wsztot / wstep
+  if(wsztot<wsz) wsztot = 2*wsz;
+  // cas sans intersection entre 2 samples successifs
+  if(wstep>=wsz) wsztot = wsz;
 
   NbInput = nbinput;
@@ -30,7 +29,10 @@
   WSizeTot = wsztot;
 
-  SNdeb = SNend = StartSample = CurWtIndex = -1;
-  TotNsCount = 0;
-
+  CurWtIndex = -1;
+  SNbegin = SNend = StartSample = LastFilledSn = -1;
+  TotNsCount = TotDecalCount = 0;
+
+  SetDbgLevel();
+  SetWSizeLCR();
   SetDefaultValue();
 
@@ -38,5 +40,5 @@
   TVector<int_8> vi8(1);   // constructeur copie de TArray (taille nulle)
   
-  int k;
+  int_4 k;
   for(k=0;k<NbInput;k++) {
     WDataIn.push_back(vr8);
@@ -44,12 +46,13 @@
     WInFlg.push_back(false);
   }
-  if(NbOutput) for(k=0;k<NbOutput;k++) {
-    WDataOut.push_back(vr8);
-    WFlagOut.push_back(vi8);
-    WOutFlg.push_back(false);
-    WPutOutFlg.push_back(false);
-    WPutOutOwnVector.push_back(false);
-    OutSample.push_back(0);
-  }
+  if(NbOutput)
+    for(k=0;k<NbOutput;k++) {
+      WDataOut.push_back(vr8);
+      WFlagOut.push_back(vi8);
+      WOutFlg.push_back(false);
+      WPutOutFlg.push_back(false);
+      WPutOutOwnVector.push_back(false);
+      OutSample.push_back(0);
+    }
 }
 
@@ -59,18 +62,23 @@
 
 ////////////////////////////////////////////////////////////////
-void GenWindowTOIProcessor::PrintStatus(ostream & os)
-{
-  os<<"\n ------------------------------------------------------ \n" 
-    <<" GenWindowTOIProcessor::PrintStatus() - ["
-    <<NbInput<<","<<NbOutput<<"] (wtot="<<WSizeTot
-    <<" WindowSize="<<GetWSize()
-    <<" WStep= "<<GetWStep()<<endl;
-  TOIProcessor::PrintStatus(os);
-  os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<endl;
-  os<<"------------------------------------------------------ "<<endl;
-}
-
-////////////////////////////////////////////////////////////////
-TVector<r_8> GenWindowTOIProcessor::GetWData(int numtoi)
+void GenWindowTOIProcessor::PrintStatus(ostream & os,int lp)
+{
+os<<"\n ------------------------------------------------------ \n" 
+  <<" GenWindowTOIProcessor::PrintStatus() - ["<<NbInput<<","<<NbOutput<<"]"<<endl
+  <<" WSizeTot="<<WSizeTot<<" WSize="<<GetWSize()<<" WStep= "<<GetWStep()<<endl;
+if(lp>0) {
+  os<<" WindowLCR: "
+    <<" L=("<<W0Left<<","<<GetWSize('l')<<")"
+    <<" C=("<<W0Center<<","<<GetWSize('c')<<")"
+    <<" R=("<<W0Right<<","<<GetWSize('r')<<")"
+    <<endl;
+}
+TOIProcessor::PrintStatus(os);
+os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<" NbDecal="<<TotDecalCount<<endl;
+os<<"------------------------------------------------------ "<<endl;
+}
+
+////////////////////////////////////////////////////////////////
+TVector<r_8> GenWindowTOIProcessor::GetWData(int_4 numtoi)
 {
   if(numtoi<0 || numtoi>=NbInput)
@@ -81,5 +89,5 @@
 }
 
-TVector<int_8> GenWindowTOIProcessor::GetWFlag(int numtoi)
+TVector<int_8> GenWindowTOIProcessor::GetWFlag(int_4 numtoi)
 {
   if(numtoi<0 || numtoi>=NbInput)
@@ -90,5 +98,5 @@
 }
 
-r_8 * GenWindowTOIProcessor::GetWDataPointer(int numtoi)
+r_8 * GenWindowTOIProcessor::GetWDataPointer(int_4 numtoi)
 {
   if(numtoi<0 || numtoi>=NbInput)
@@ -100,5 +108,5 @@
 }
  
-int_8 * GenWindowTOIProcessor::GetWFlagPointer(int numtoi)
+int_8 * GenWindowTOIProcessor::GetWFlagPointer(int_4 numtoi)
 {
   if(numtoi<0 || numtoi>=NbInput)
@@ -109,5 +117,5 @@
 }
 
-void GenWindowTOIProcessor::GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag)
+void GenWindowTOIProcessor::GetData(int_4 numtoi, int_8 numsample, r_8 & data, int_8 & flag)
 {
   if(numtoi<0 || numtoi>=NbInput)
@@ -115,5 +123,5 @@
   if(!WInFlg[numtoi])
     throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!");
-  int_8 k = numsample-GetStartSample();
+  int_8 k = numsample-GetWStartSample();
   if ((k<0) || (k >= GetWSize()))
     throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!");
@@ -127,5 +135,5 @@
                                     ,TVector<r_8>& data,TVector<int_8>& flag)
 {
-  if(numtoi<0 || numtoi>=NbOutput)
+  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
     throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
   if(!WOutFlg[numtoi])
@@ -145,5 +153,5 @@
                                     ,r_8 data,int_8 flag)
 {
-  if(numtoi<0 || numtoi>=NbOutput)
+  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
     throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
   if(!WOutFlg[numtoi])
@@ -160,4 +168,122 @@
 }
 
+/******* cmv routines
+void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
+                                    ,TVector<r_8>& data,TVector<int_8>& flag)
+{
+  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
+    throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
+  if(!WOutFlg[numtoi])
+    throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
+  if(data.Size()!=flag.Size())
+    throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()!=flag.Size()!");
+  if(data.Size() == 0)
+    throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()==0 !");
+
+  for(int_4 k=0;k<data.Size(); k++)
+     putData(numtoi,numsample+k,data(k),flag(k));
+}
+
+void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
+                                    ,r_8 data,int_8 flag)
+{
+  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
+    throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
+  if(!WOutFlg[numtoi])
+    throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
+
+  putData(numtoi,numsample,data,flag);
+}
+*********/
+
+////////////////////////////////////////////////////////////////
+void GenWindowTOIProcessor::SetWSizeLCR(int_4 wszl,int_4 wszc,int_4 wszr)
+// Fenetre a gauche, au centre et a droite du pixel central
+// Selon la logique:
+//-----------------------------------------------
+//                     | pixel central
+//                     |
+//                     |
+//          | wszl | wszc | wszr |
+//                     |
+//       |           WSize           |
+//-----------------------------------------------
+// wszc toujours impair SVP.
+// Default: 0,0,0 : WSize/2,1,WSize/2
+{
+ int_4 wsz2 = WSize/2;
+ // Default
+ if(wszl<=0 && wszc<=0 && wszr<=0) {
+   WSizeLeft = WSizeRight = wsz2; WSizeCenter = 1;
+   W0Left = 0; W0Center = wsz2;   W0Right = wsz2+1;
+   return;
+ }
+
+ // Fenetre centrale
+ if(wszc<=0)    wszc = 1;
+ if(wszc%2==0)  wszc++;
+ if(wszc>WSize) wszc = WSize;
+ WSizeCenter = wszc;
+ W0Center = wsz2 - WSizeCenter/2;
+
+ // Fenetre de gauche
+ if(wszl<=0) wszl = WSize;
+ W0Left = W0Center - wszl;
+ if(W0Left<0) W0Left = 0;
+ WSizeLeft = W0Center - W0Left;
+ if(WSizeLeft<=0) WSizeLeft = 1;
+
+ // Fenetre de droite
+ if(wszr<=0) wszr = WSize;
+ W0Right = W0Center + WSizeCenter;
+ if(W0Right>=WSize) W0Right = WSize - 1;
+ int_4 dum = W0Right + wszr; if(dum>WSize) dum = WSize;
+ WSizeRight = dum - W0Right;
+ if(WSizeRight<=0) WSizeRight = 1;
+}
+
+TVector<r_8> GenWindowTOIProcessor::GetWData(char cw,int_4 numtoi)
+// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
+{
+ if(numtoi<0 || numtoi>=NbInput)
+    throw RangeCheckError("GenWindowTOIProcessor::GetWData(lcr) : toi out of range !");
+ if(!WInFlg[numtoi])
+   throw ParmError("GenWindowTOIProcessor::GetWData(lcr) : toi not connected!");
+ return (WDataIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
+}
+
+TVector<int_8> GenWindowTOIProcessor::GetWFlag(char cw,int_4 numtoi)
+// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
+{
+ if(numtoi<0 || numtoi>=NbInput)
+   throw RangeCheckError("GenWindowTOIProcessor::GetWFlag(lcr) : toi out of range !");
+ if(!WInFlg[numtoi])
+   throw ParmError("GenWindowTOIProcessor::GetWFlag(lcr) : toi not connected!");
+ return (WFlagIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
+}
+
+r_8 * GenWindowTOIProcessor::GetWDataPointer(char cw,int_4 numtoi,int_4& n)
+// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
+{
+ if(numtoi<0 || numtoi>=NbInput)
+   throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointe(lcr)r : toi out of range !");
+ if(!WInFlg[numtoi])
+   throw ParmError("GenWindowTOIProcessor::GetWDataPointer(lcr) : toi not connected!");
+ n = GetWSize(cw);
+ return (WDataIn[numtoi].Data()+StartWtIndex(cw));
+
+}
+ 
+int_8 * GenWindowTOIProcessor::GetWFlagPointer(char cw,int_4 numtoi,int_4& n)
+// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
+{
+ if(numtoi<0 || numtoi>=NbInput)
+   throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi out of range !");
+ if(!WInFlg[numtoi])
+   throw ParmError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi not connected!");
+ n = GetWSize(cw);
+ return (WFlagIn[numtoi].Data()+StartWtIndex(cw));
+}
+
 ////////////////////////////////////////////////////////////////
 void GenWindowTOIProcessor::UserInit(int_8 kstart)
@@ -181,13 +307,14 @@
   cout << "GenWindowTOIProcessor::init" << endl;
   char buff[64];
-  int k;
+  int_4 k;
   for(k=0; k<NbInput; k++) {
     sprintf(buff,"in%d", k);
     declareInput(buff);
   }
-  for(k=0; k<NbOutput; k++) {
-    sprintf(buff,"out%d",k);
-    declareOutput(buff);
-  }
+  if(NbOutput)
+    for(k=0; k<NbOutput; k++) {
+      sprintf(buff,"out%d",k);
+      declareOutput(buff);
+    }
   name = "GenWindowTOIProcessor";
   // upExtra = 1; $CHECK a quoi ca sert EA?
@@ -197,11 +324,12 @@
 {
   //  TOIManager* mgr = TOIManager::getManager();
-  SNdeb = getMinIn();
-  SNend = getMaxIn();
-  if(SNend-SNdeb<WSize)
+  SNbegin = getMinIn();
+  SNend   = getMaxIn();
+
+  if(SNend-SNbegin<WSize)
     throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !");
 
   // Allocation des tailles pour les vecteurs
-  int kc, nc=0;
+  int_4 kc, nc=0;
   for(kc=0;kc<NbInput;kc++) {
     if( !(WInFlg[kc]=checkInputTOIIndex(kc)) ) continue;
@@ -214,25 +342,27 @@
     throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!");
   }
-  for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
+  if(NbOutput)
+    for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
 
   // Lecture des samples et remplissage des vecteurs
-  cout<<"GenWindowTOIProcessor::run() SNRange="<<SNdeb<<" - "<<SNend<<endl; 
+  cout<<"GenWindowTOIProcessor::run() SNRange="<<SNbegin<<" - "<<SNend<<endl; 
   try {
     Timer tm("GenWindowTOIProcessor::run()");
-    for(int_8 ks=SNdeb;ks<=SNend;ks++) {  // CMV gerer le += step
+    int_4 wsz2=WSize/2;
+    int_8 ksend = SNbegin;
+    for(int_8 ks=SNbegin; ks<=SNend; ks+=WStep) {
+
       Remplissage(ks);
-      if (ks == SNdeb) {
-	UserInit(ks);
-	Ecriture();
-      }
-      if ((ks-SNdeb)%WStep == 0) {
-	UserProc(ks);
-	// Il faut traiter les ecritures en sortie 
-	Ecriture();
-      }
+      if(DbgLevel) test_avec_print(ks);
+
+      if(ks == SNbegin) {UserInit(ks); Ecriture();}
+
+      UserProc(ks);
+      Ecriture();
+
+      ksend = ks;
       TotNsCount++;
     }
-    UserEnd(SNend);
-    Ecriture();
+    UserEnd(ksend); Ecriture();
     cout << " GenWindowTOIProcessor::run() - End of processing " << endl;
 
@@ -249,70 +379,95 @@
 //      samples :   sn-ws/2        sn          sn+ws/2
 //      fenetre :   0              ws/2+1      ws-1
-{
-#ifdef DEBUGGENW
- cout << "GenWindowTOIProcessor::Remplissage(" << ks << ") CurWtIndex=" << CurWtIndex << endl;
-#endif 
-
-if(ks<SNdeb || ks>SNend) {
-  cerr << "GenWindowTOIProcessor::remplissage/Erreur : ks(=" << ks << ") <" 
-       << SNdeb << " || ks>" << SNend << endl; 
-  throw RangeCheckError("GenWindowTOIProcessor::remplissage : ks<SNdeb || ks>SNend !");
- }
-int_8 wsz2=WSize/2;
-
-StartSample = ks - wsz2; // peut etre < snb au debut
-
-// Premier remplissage ???? Gestion de la borne inferieure
+// Cette routine doit etre utilisee dans une boucle:
+//      for(int k=???; k<???; k+=WStep) .....
+// Dans le grand buffer WSizeTot il doit y avoir WSize samples
+//      entre ks1=ks-wsz2 et ks2=ks-wsz2  (ks1<=k<=ks2)
+// En ENTREE de cette routine :
+// - CurWtIndex = c'est l'index du tableau WSizeTot qui doit etre rempli
+//                (le dernier index qui a ete rempli par l'appel precedent
+//                 est donc CurWtIndex-1)
+// - LastFilledSn = c'est le dernier numero de sample qui a ete rempli
+//                  dans le tableau WSizeTot par l'appel precedent
+{
+int_4 wsz2=WSize/2;
+
+// Numero de sample du premier element du tableau WSize
+//   (peut etre < SNbegin au debut)
+StartSample = ks - wsz2;
+
+// on doit avoir les samples [ks1,ks2] dans le buffer
+// (mais selon le step, certain peuvent etre deja remplis)
+int_8 ks1 = ks-wsz2, ks2 = ks+wsz2;
+
+if(DbgLevel>1)
+  cout<<"DBG-GenWindowTOIProcessor::Remplissage("<<ks
+      <<") ["<<ks1<<","<<ks2<<"]"
+      <<" CurWtIndex="<<CurWtIndex<<" LastFilledSn="<<LastFilledSn<<endl;
+
+//--------------------------------------------------------
+// Premier remplissage ????
+// Gestion de la borne inferieure pour le permier sample
+//--------------------------------------------------------
 if(CurWtIndex<0) {
-#ifdef DEBUGGENW
-  cout << "GenWindowTOIProcessor::Remplissage 1ere fois" << endl; 
-#endif 
+  if(DbgLevel>1)
+    cout<<"DBG-GenWindowTOIProcessor::Remplissage 1ere fois"<<endl; 
+  for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
+    if(!WInFlg[ntoi]) continue;
+    for(int_8 k=ks1, j=0; k<=ks2; k++, j++) {
+      if(k>=SNbegin && k<=SNend) {
+        getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
+      } else {
+        (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
+      }
+    }
+  }
+  CurWtIndex = ks2 - ks1 + 1;
+  LastFilledSn = ks2;
+  return;
+}
+
+//--------------------------------------------------------
+// Faut-il decaler ????
+//--------------------------------------------------------
+if(WStep>=WSize) {
+  // On ne decale pas puisque entre 2 appels a la routine
+  // il faut TOUT recharger (aucun sample deja charge n'est utile)
   CurWtIndex = 0;
-  for(int_8 k=ks-wsz2; k<=ks+wsz2; k++) { // Lecture TOI
-    for(int kc=0; kc<NbInput; kc++) {
-      if(!WInFlg[kc]) continue;
-      if(k>=SNdeb && k<=SNend) {
-        getData(kc,k,(WDataIn[kc])(CurWtIndex), (WFlagIn[kc])(CurWtIndex));
-      } else {
-        (WDataIn[kc])(CurWtIndex) = R8DefVal;
-        (WFlagIn[kc])(CurWtIndex) = I8DefVal;
+} else {
+  // Certains samples deja charges sont utiles
+  int_8 ifin = ks2 - LastFilledSn + CurWtIndex-1;
+  if(ifin >= WSizeTot) { // On decale
+    int_8 ideb = CurWtIndex-1 - LastFilledSn + ks1;
+    if(DbgLevel>1)
+      cout<<"DBG-GenWindowTOIProcessor::Remplissage ... Decalage ideb="<<ideb
+          <<" ifin="<<ifin<< endl; 
+    for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
+      if(!WInFlg[ntoi]) continue;
+      for(int_4 i=ideb, j=0; i<CurWtIndex; i++, j++) {
+        (WDataIn[ntoi])(j) = (WDataIn[ntoi])(i);
+        (WFlagIn[ntoi])(j) = (WFlagIn[ntoi])(i);
       }
     }
-    CurWtIndex++;
-  }
-  return;
-}
-
-// CMV gere decalage seulement si step < wsize sinon copie.
-// Faut-il decaler ????
-if(CurWtIndex == WSizeTot) { // On decale
-#ifdef DEBUGGENW
-  cout << "GenWindowTOIProcessor::Remplissage Decalage " << endl; 
-#endif 
-  for(int kc=0; kc<NbInput; kc++) {
-    if(!WInFlg[kc]) continue;
-      for(int_8 k=1;k<WSize;k++) { // un en moins car on va remplir apres
-        (WDataIn[kc])(k-1) = (WDataIn[kc])(WSizeTot-WSize+k);
-        (WFlagIn[kc])(k-1) = (WFlagIn[kc])(WSizeTot-WSize+k);
-      }
-  }
-  CurWtIndex = WSize-1;
-}
-
-// Remplissage de ks+wsz2 (dernier element de la fenetre pour ks central)
-int_8 kse = ks+wsz2;
-#ifdef DEBUGGENW
-  cout << "GenWindowTOIProcessor::Normal fill " << endl; 
-#endif 
-for(int kc=0; kc<NbInput; kc++) {
-  if(!WInFlg[kc]) continue;
-  if(kse>=SNdeb && kse<=SNend) {
-    getData(kc,kse,(WDataIn[kc])(CurWtIndex),(WFlagIn[kc])(CurWtIndex));
-  } else {
-    (WDataIn[kc])(CurWtIndex) = R8DefVal;
-    (WFlagIn[kc])(CurWtIndex) = I8DefVal;
-  }
-}
-CurWtIndex++;
+    CurWtIndex = CurWtIndex-ideb;
+    TotDecalCount++;
+  }
+}
+
+// Remplissage des samples utiles pour ks
+if(ks1<=LastFilledSn) ks1 = LastFilledSn+1;
+if(DbgLevel>1)
+  cout<<"DBG-GenWindowTOIProcessor::Normal fill de ["<<ks1<<","<<ks2<<"]"<<endl;
+for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
+  if(!WInFlg[ntoi]) continue;
+  for(int_4 k=ks1, j=CurWtIndex; k<=ks2; k++, j++) {
+    if(k>=SNbegin && k<=SNend) {
+      getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
+    } else {
+      (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
+    }
+  }
+}
+CurWtIndex += ks2 - ks1 + 1;
+LastFilledSn = ks2;
 
 return;
@@ -337,2 +492,60 @@
   for(kc=0; kc<NbOutput; kc++)  WPutOutFlg[kc] = false;
 }
+
+////////////////////////////////////////////////////////////////
+void  GenWindowTOIProcessor::test_avec_print(int_8 ks)
+{
+if(DbgLevel<=0) return;
+
+int i,ii=0;
+r_8   * datatot = WDataIn[0].Data();
+int_8 * flagtot = WFlagIn[0].Data();
+r_8   * data = GetWDataPointer();
+int_8 * flag = GetWFlagPointer();
+int_4 nl,nc,nr;
+r_8   * datal = GetWDataPointer('l',nl);
+int_8 * flagl = GetWFlagPointer('l',nl);
+r_8   * datac = GetWDataPointer('c',nc);
+int_8 * flagc = GetWFlagPointer('c',nc);
+r_8   * datar = GetWDataPointer('r',nr);
+int_8 * flagr = GetWFlagPointer('r',nr);
+
+cout<<"-------- ks = "<<ks<<endl;
+
+if(DbgLevel>2) {
+  cout<<"datatot = ";
+  for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<datatot[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"flagtot = ";
+  for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<flagtot[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+}
+
+cout<<"data = ";
+for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<data[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+cout<<"flag = ";
+for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<flag[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+
+if(DbgLevel>2) {
+  cout<<"datal = ";
+  for(i=0;i<nl;i++) {ii=0; cout<<" "<<datal[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"flagl = ";
+  for(i=0;i<nl;i++) {ii=0; cout<<" "<<flagl[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"datac = ";
+  for(i=0;i<nc;i++) {ii=0; cout<<" "<<datac[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"flagc = ";
+  for(i=0;i<nc;i++) {ii=0; cout<<" "<<flagc[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"datar = ";
+  for(i=0;i<nr;i++) {ii=0; cout<<" "<<datar[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+  cout<<"flagr = ";
+  for(i=0;i<nr;i++) {ii=0; cout<<" "<<flagr[i]; if(i%10==9) {cout<<endl; ii=1;}}
+        if(ii==0) cout<<endl;
+}
+}
Index: trunk/ArchTOIPipe/ProcWSophya/genwproc.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/genwproc.h	(revision 1498)
+++ trunk/ArchTOIPipe/ProcWSophya/genwproc.h	(revision 1502)
@@ -12,29 +12,52 @@
 class GenWindowTOIProcessor : public TOIProcessor {
 public:
-  GenWindowTOIProcessor(int nbinput,int nboutput,int wsz, int wstep=1, int wsztot=-1);
+  GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput,int_4 wsz, int_4 wstep=1, int_4 wsztot=-1);
   virtual ~GenWindowTOIProcessor();
 
-  inline int_8 GetWSize() const { return WSize; }
-  inline int_8 GetWStep() const { return WStep; }
-  inline int_8 ProcessedSampleCount() const { return TotNsCount; }
+  inline int_4 GetWSize() const { return WSize; }
+  inline int_4 GetWStep() const { return WStep; }
+  inline int_4 ProcessedSampleCount() const { return TotNsCount; }
 
-  inline int_8 GetStartSample()  {return StartSample;}
-  inline int_8 GetCenterSample() {return StartSample + WSize/2;}
-  inline int_8 StartSampleNum() { return SNdeb; }
-  inline int_8 EndSampleNum() { return SNend; }
+  // DbgLevel = 0 : No debug
+  // DbgLevel = 1 : Print fenetre WSize
+  // DbgLevel = 2 : 1 + Print logique remplissage/decalage
+  // DbgLevel = 3 : 2 + Print fenetre WSizeTot et WSizeL,C,R
+  inline void SetDbgLevel(int_2 lp=0) {DbgLevel = (lp>0) ? lp : 0;}
+
+  void SetWSizeLCR(int_4 wszl=0,int_4 wszc=0,int_4 wszr=0);
+  inline int_4 GetWSize(char cw)
+               {if     (cw=='l') return WSizeLeft;
+                else if(cw=='c') return WSizeCenter;
+                else if(cw=='r') return WSizeRight;
+                                 return WSize;}
+
+  inline int_8 GetWStartSample()  {return StartSample;}
+  inline int_8 GetWCenterSample() {return StartSample + WSize/2;}
+  inline int_8 GetWCenterIndex()  {return WSize/2;}
+  inline int_8 StartSampleNum()   {return SNbegin;}
+  inline int_8 EndSampleNum()     {return SNend;}
 
   inline void SetDefaultValue(r_8 r8dval=0., int_8 i8dval=0)
                       {R8DefVal = r8dval; I8DefVal = i8dval;}
 
-  TVector<r_8> GetWData(int numtoi=0);
-  TVector<int_8> GetWFlag(int numtoi=0);
-  r_8 * GetWDataPointer(int numtoi=0);
-  int_8 * GetWFlagPointer(int numtoi=0);
-  void GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag);
+  TVector<r_8> GetWData(int_4 numtoi=0);
+  TVector<int_8> GetWFlag(int_4 numtoi=0);
+  r_8 * GetWDataPointer(int_4 numtoi=0);
+  int_8 * GetWFlagPointer(int_4 numtoi=0);
+  void GetData(int_4 numtoi, int_8 numsample, r_8 & data, int_8 & flag);
   inline void GetData(int_8 numsample, r_8 & data, int_8 & flag)
                       { GetData(0, numsample, data, flag); }
 
-  void PutWData(int numtoi,int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag);
-  void PutWData(int numtoi,int_8 numsample,r_8 data,int_8 flag);
+  TVector<r_8> GetWData(char cw,int_4 numtoi=0);
+  TVector<int_8> GetWFlag(char cw,int_4 numtoi=0);
+  r_8   * GetWDataPointer(char cw,int_4 numtoi,int_4& n);
+  int_8 * GetWFlagPointer(char cw,int_4 numtoi,int_4& n);
+  inline   r_8 * GetWDataPointer(char cw,int_4& n)
+                 {return GetWDataPointer(cw,0,n);}
+  inline int_8 * GetWFlagPointer(char cw,int_4& n)
+                 {return GetWFlagPointer(cw,0,n);}
+
+  void PutWData(int_4 numtoi,int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag);
+  void PutWData(int_4 numtoi,int_8 numsample,r_8 data,int_8 flag);
   inline void PutWData(int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag)
                       {PutWData(0,numsample,data,flag);}
@@ -42,5 +65,5 @@
                       {PutWData(0,numsample,data,flag);}
 
-  virtual void PrintStatus(ostream & os);
+  virtual void PrintStatus(ostream & os,int lp=0);
 
   virtual void UserInit(int_8 kstart);
@@ -54,21 +77,31 @@
   void Remplissage(int_8 ks);
   void Ecriture();
-  inline int_8 StartWtIndex()
-         {if(CurWtIndex<0) return -1; else return CurWtIndex-WSize;}
-  inline int_8 CenterWtIndex()
-         {if(CurWtIndex<0) return -1; else return CurWtIndex-(WSize+1)/2;}
+  void test_avec_print(int_8 ks);
+  inline int_4 StartWtIndex()  {return CurWtIndex-WSize;}
+  inline int_4 CenterWtIndex() {return CurWtIndex-(WSize+1)/2;}
+  inline int_4 StartWtIndex(char cw)
+         {if     (cw=='l') return StartWtIndex()+W0Left;
+          else if(cw=='c') return StartWtIndex()+W0Center;
+          else if(cw=='r') return StartWtIndex()+W0Right;
+                           return StartWtIndex();}
 
-  int NbInput,NbOutput;
-  int_8 WSizeTot,WSize,WStep;
-  int_8 SNdeb,SNend;
-  int_8 StartSample,CurWtIndex;
-  int_8 TotNsCount;
-  r_8 R8DefVal;
+  int_2 DbgLevel;
+  int_4 NbInput,NbOutput;
+  int_4 WSizeTot,WSize,WStep;
+  int_4 WSizeLeft,WSizeCenter,WSizeRight, W0Left,W0Center,W0Right;
+  int_8 SNbegin,SNend;
+  int_8 TotNsCount,TotDecalCount;
+  r_8   R8DefVal;
   int_8 I8DefVal;
+
+  int_4 CurWtIndex;   // Prochain index a remplir dans le buffer WSizeTot
+  int_8 LastFilledSn; // Numero du dernier sample remplie
+  int_8 StartSample;  // Numero de sample du 1er element du buffer WSize
+
   vector< TVector<r_8>   > WDataIn;
   vector< TVector<int_8> > WFlagIn;
+  vector< bool > WInFlg;
   vector< TVector<r_8>   > WDataOut;
   vector< TVector<int_8> > WFlagOut;
-  vector< bool > WInFlg;
   vector< bool > WOutFlg;
   vector< bool > WPutOutFlg;
