From f6808728fcc74d2be974545c20ba1f65bed5818a Mon Sep 17 00:00:00 2001
From: even <philippe.even@loria.fr>
Date: Sun, 18 Nov 2018 20:35:53 +0100
Subject: [PATCH] Auxiliary views repaired

---
 Code/Seg/BSTools/bsaccumulatoritem.cpp    |  3 ++-
 Code/Seg/BSTools/bsaccumulatoritem.h      |  9 ++++++---
 Code/Seg/BSTools/bsdetectionwidget.cpp    | 14 ++++++++------
 Code/Seg/BSTools/bsstructureitem.cpp      |  6 ++++--
 Code/Seg/BlurredSegment/bsdetector.cpp    |  4 ++--
 Code/Seg/BlurredSegment/bsdetector.h      | 19 +++++++++++--------
 Code/Seg/ImageTools/digitalstraightline.h | 15 +++++++++++++++
 7 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/Code/Seg/BSTools/bsaccumulatoritem.cpp b/Code/Seg/BSTools/bsaccumulatoritem.cpp
index 9a1c178..31aba67 100755
--- a/Code/Seg/BSTools/bsaccumulatoritem.cpp
+++ b/Code/Seg/BSTools/bsaccumulatoritem.cpp
@@ -17,7 +17,8 @@ BSAccumulatorItem::BSAccumulatorItem (BSDetector *sd, int w, int h)
   detector = sd;
   width = w;
   height = h;
-  selaccu = 0;
+  selaccu = (sd->isFiltering (BSDetector::STEP_FINAL) ?
+             BSDetector::STEP_FINAL : BSDetector::STEP_INITIAL);
   map[0] = NULL;
   map[1] = NULL;
   solution[0] = -1;
diff --git a/Code/Seg/BSTools/bsaccumulatoritem.h b/Code/Seg/BSTools/bsaccumulatoritem.h
index 25368fb..80c923e 100755
--- a/Code/Seg/BSTools/bsaccumulatoritem.h
+++ b/Code/Seg/BSTools/bsaccumulatoritem.h
@@ -29,11 +29,14 @@ public:
 
   /** \brief Inquires if the pre-filter accumulator is displayed.
    */
-  inline bool isPrefilterDisplayed () const {return (selaccu == 0); }
+  inline bool isPrefilterDisplayed () const {
+    return (selaccu == BSDetector::STEP_INITIAL); }
 
   /** \brief Switches the displayed accumulator filter.
    */
-  inline void switchAccumulator () { selaccu = (selaccu != 0 ? 0 : 1); }
+  inline void switchAccumulator () {
+    selaccu = (selaccu != BSDetector::STEP_INITIAL ?
+               BSDetector::STEP_INITIAL : BSDetector::STEP_FINAL); }
 
   /** \brief Returns the size of the filter accumulator graphics item.
    */
@@ -82,7 +85,7 @@ private:
 
   /** Blurred segment detector. */
   BSDetector *detector;
-  /** Accumulator displayed (0 = prefilter, 1 = final filter). */
+  /** Accumulator displayed (1 = prefilter, 0 = final filter). */
   int selaccu;
 
   /** Accumulator width. */
diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp
index 98c8ebc..cfb29e2 100755
--- a/Code/Seg/BSTools/bsdetectionwidget.cpp
+++ b/Code/Seg/BSTools/bsdetectionwidget.cpp
@@ -377,9 +377,10 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       break;
 
     case Qt::Key_F :
-      detector.switchFiltering (1);
+      detector.switchFiltering (BSDetector::STEP_FINAL);
       cout << "Final filtering "
-           << (detector.isFiltering (1) ? "on" : "off") << endl;
+           << (detector.isFiltering (BSDetector::STEP_FINAL) ? "on" : "off")
+           << endl;
       extract ();
       break;
 
@@ -396,9 +397,10 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       }
       else
       {
-        detector.switchFiltering (0);
+        detector.switchFiltering (BSDetector::STEP_INITIAL);
         cout << "Pre-filtering "
-             << (detector.isFiltering (0) ? "on" : "off") << endl;
+             << (detector.isFiltering (BSDetector::STEP_INITIAL) ? "on" : "off")
+             << endl;
         extract ();
       }
       break;
@@ -826,8 +828,8 @@ void BSDetectionWidget::localTest ()
   p2 = Pt2i (232, 152);
 */
 
-  p1 = Pt2i (157, 125);
-  p2 = Pt2i (165, 88);
+  p1 = Pt2i (175, 40);
+  p2 = Pt2i (246, 79);
 
   extract ();
   cout << "Test run" << endl;
diff --git a/Code/Seg/BSTools/bsstructureitem.cpp b/Code/Seg/BSTools/bsstructureitem.cpp
index 8ea6913..ff025de 100755
--- a/Code/Seg/BSTools/bsstructureitem.cpp
+++ b/Code/Seg/BSTools/bsstructureitem.cpp
@@ -273,8 +273,10 @@ void BSStructureItem::toggleDisplay (bool next)
   displayItem += (next ? 1 : -1);
   if (displayItem > DISPLAY_MAX) displayItem = DISPLAY_MIN;
   else if (displayItem < DISPLAY_MIN) displayItem = DISPLAY_MAX;
-  det->setScanRecord (1, displayItem == DISPLAY_FINAL_SCANS_AND_FILTER);
-  det->setScanRecord (0, displayItem == DISPLAY_INITIAL_SCANS_AND_FILTER);
+  det->setScanRecord (BSDetector::STEP_FINAL,
+                      displayItem == DISPLAY_FINAL_SCANS_AND_FILTER);
+  det->setScanRecord (BSDetector::STEP_INITIAL,
+                      displayItem == DISPLAY_INITIAL_SCANS_AND_FILTER);
 }
 
 
diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/Seg/BlurredSegment/bsdetector.cpp
index f428a2a..5e94747 100755
--- a/Code/Seg/BlurredSegment/bsdetector.cpp
+++ b/Code/Seg/BlurredSegment/bsdetector.cpp
@@ -313,7 +313,7 @@ void BSDetector::switchOrthoScans ()
 vector<Pt2i> BSDetector::getRejected (int step) const
 {
   vector<Pt2i> res;
-  if (step != 0)
+  if (step == STEP_FINAL)
   {
     if (filteringOn) res = lsf2->getRejected ();
   }
@@ -324,7 +324,7 @@ vector<Pt2i> BSDetector::getRejected (int step) const
 
 void BSDetector::switchFiltering (int step)
 {
-  if (step != 0)
+  if (step == STEP_FINAL)
   {
     filteringOn = ! filteringOn;
     if (filteringOn && lsf2 == NULL) lsf2 = new LineSpaceFilter ();
diff --git a/Code/Seg/BlurredSegment/bsdetector.h b/Code/Seg/BlurredSegment/bsdetector.h
index 377771b..bbdc5e5 100755
--- a/Code/Seg/BlurredSegment/bsdetector.h
+++ b/Code/Seg/BlurredSegment/bsdetector.h
@@ -268,28 +268,31 @@ public:
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline vector<Pt2i> getScanBound1 (int step) const {
-    return (step != 0 ? bst2->getScanBound1 () : bst1->getScanBound1 ()); }
+    return (step == STEP_FINAL ?
+            bst2->getScanBound1 () : bst1->getScanBound1 ()); }
 
   /**
    * \brief Returns the lower bound of the final scan of the given step.
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline vector<Pt2i> getScanBound2 (int step) const {
-    return (step != 0 ? bst2->getScanBound2 () : bst1->getScanBound2 ()); }
+    return (step == STEP_FINAL ?
+            bst2->getScanBound2 () : bst1->getScanBound2 ()); }
 
   /**
    * \brief Returns the scan lines of the given step.
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline vector <vector <Pt2i> > getScans (int step) const {
-    return (step != 0 ? bst2->getScans () : bst1->getScans ()); }
+    return (step == STEP_FINAL ? bst2->getScans () : bst1->getScans ()); }
 
   /**
    * \brief Returns whether the scan record modality is set for the given step.
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline bool scanRecordOn (int step) {
-    return (step != 0 ? bst2->scanRecordOn () : bst1->scanRecordOn ()); }
+    return (step == STEP_FINAL ?
+      bst2->scanRecordOn () : bst1->scanRecordOn ()); }
 
   /**
    * \brief Sets the scan record modality of initial or final step.
@@ -297,7 +300,7 @@ public:
    * @param status Sets on if true, off otherwise.
    */
   inline void setScanRecord (int step, bool status) {
-    if (step != 0) bst2->setScanRecord (status);
+    if (step == STEP_FINAL) bst2->setScanRecord (status);
     else bst1->setScanRecord (status); }
 
   /**
@@ -355,14 +358,14 @@ public:
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline LineSpaceFilter *getFilter (int step) const {
-    return (step != 0 ? lsf2 : lsf1); }
+    return (step == STEP_FINAL ? lsf2 : lsf1); }
 
   /**
    * \brief Returns the accepted points by the line space based filter.
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline vector<Pt2i> getAccepted (int step) const {
-    return (step != 0 ?
+    return (step == STEP_FINAL ?
       (filteringOn ? lsf2->getAccepted () : bsf->getAllPoints ()) :
       (prefilteringOn ? lsf1->getAccepted () : bsini->getAllPoints ())); }
 
@@ -377,7 +380,7 @@ public:
    * @param step Initial step addressed if set to 0, final step otherwise.
    */
   inline bool isFiltering (int step) const {
-    return (step != 0 ? filteringOn : prefilteringOn); }
+    return (step == STEP_FINAL ? filteringOn : prefilteringOn); }
 
   /**
    * \brief Toggles the use of the given line space based filter.
diff --git a/Code/Seg/ImageTools/digitalstraightline.h b/Code/Seg/ImageTools/digitalstraightline.h
index 8a5c518..4b241be 100755
--- a/Code/Seg/ImageTools/digitalstraightline.h
+++ b/Code/Seg/ImageTools/digitalstraightline.h
@@ -73,6 +73,21 @@ public:
    */
   virtual ~DigitalStraightLine () { }
 
+  /**
+   * \brief Returns the parameters of the digital straight line equations.
+   * @param a X slope parameter to provide.
+   * @param b Y slope parameter to provide.
+   * @param c intercept parameter to provide.
+   * @param nu width parameter to provide.
+   */
+  inline void equation (int &a, int &b, int &c, int &nu) const
+  {
+    a = this->a;
+    b = this->b;
+    c = this->c;
+    nu = this->nu;
+  }
+
   /**
    * \brief Fills in the given array with the three medial axis parameters.
    * @param a X slope parameter to provide.
-- 
GitLab