From b25a5c13e3a8cf61b540fd7eef5e1304a5e57974 Mon Sep 17 00:00:00 2001 From: evenp <Philippe.Even@loria.fr> Date: Sat, 28 Nov 2020 12:20:24 +0100 Subject: [PATCH] Code: directional scanners cleaned --- Code/FBSD/BSTools/bsdetectionwidget.cpp | 26 ++---- Code/FBSD/BlurredSegment/blurredsegment.cpp | 38 ++++++++ Code/FBSD/BlurredSegment/blurredsegment.h | 28 +++++- Code/FBSD/BlurredSegment/bsdetector.cpp | 38 ++++---- Code/FBSD/BlurredSegment/bsdetector.h | 22 ++--- Code/FBSD/BlurredSegment/bsproto.h | 1 + Code/FBSD/BlurredSegment/bstracker.cpp | 68 +++++++------- Code/FBSD/BlurredSegment/bstracker.h | 32 ++----- Code/FBSD/ConvexHull/chvertex.h | 1 - .../DirectionalScanner/adaptivescannero1.cpp | 10 +-- .../DirectionalScanner/adaptivescannero1.h | 13 ++- .../DirectionalScanner/adaptivescannero2.cpp | 10 +-- .../DirectionalScanner/adaptivescannero2.h | 13 ++- .../DirectionalScanner/adaptivescannero7.cpp | 10 +-- .../DirectionalScanner/adaptivescannero7.h | 13 ++- .../DirectionalScanner/adaptivescannero8.cpp | 10 +-- .../DirectionalScanner/adaptivescannero8.h | 13 ++- .../DirectionalScanner/directionalscanner.h | 24 ++--- .../directionalscannero1.cpp | 38 ++++---- .../DirectionalScanner/directionalscannero1.h | 25 +++--- .../directionalscannero2.cpp | 38 ++++---- .../DirectionalScanner/directionalscannero2.h | 25 +++--- .../directionalscannero7.cpp | 38 ++++---- .../DirectionalScanner/directionalscannero7.h | 25 +++--- .../directionalscannero8.cpp | 38 ++++---- .../DirectionalScanner/directionalscannero8.h | 25 +++--- .../DirectionalScanner/scannerprovider.cpp | 89 ++----------------- .../FBSD/DirectionalScanner/scannerprovider.h | 56 ++++-------- Code/FBSD/DirectionalScanner/vhscannero1.h | 12 +-- Code/FBSD/DirectionalScanner/vhscannero2.h | 12 +-- Code/FBSD/DirectionalScanner/vhscannero7.h | 12 +-- Code/FBSD/DirectionalScanner/vhscannero8.h | 12 +-- Code/FBSD/ImageTools/digitalstraightline.cpp | 19 +++- Code/FBSD/ImageTools/digitalstraightline.h | 32 ++++--- Code/FBSD/ImageTools/pt2i.h | 3 +- Code/FBSD/ImageTools/vr2i.h | 1 + Methode/ctrl.tex | 1 - 37 files changed, 399 insertions(+), 472 deletions(-) diff --git a/Code/FBSD/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp index e674d46..d9657e6 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.cpp +++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp @@ -792,26 +792,12 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_W : -// DEV IN - if (event->modifiers () & Qt::ControlModifier) - { - // Switches the scan centering on the detected segment - detector.switchScanRecentering (); - std::cout << "Fine tracking centered on " - << (detector.isScanRecentering () ? - "detected segment" : "initial scan") << std::endl; - extract (); - } - else -// DEV OUT - { - // Tunes the assigned thickness to detector - detector.setAssignedThickness (detector.assignedThickness () + - (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); - std::cout << "Assigned thickness = " - << detector.assignedThickness () << std::endl; - extract (); - } + // Tunes the assigned thickness to detector + detector.setAssignedThickness (detector.assignedThickness () + + (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); + std::cout << "Assigned thickness = " + << detector.assignedThickness () << std::endl; + extract (); break; case Qt::Key_X : diff --git a/Code/FBSD/BlurredSegment/blurredsegment.cpp b/Code/FBSD/BlurredSegment/blurredsegment.cpp index 54f999d..81e8e20 100755 --- a/Code/FBSD/BlurredSegment/blurredsegment.cpp +++ b/Code/FBSD/BlurredSegment/blurredsegment.cpp @@ -5,6 +5,7 @@ BlurredSegment::BlurredSegment () { plist = NULL; dss = NULL; + scan = NULL; } @@ -14,6 +15,7 @@ BlurredSegment::BlurredSegment (BiPtList *ptlist, DigitalStraightSegment *seg, { plist = ptlist; dss = seg; + scan = NULL; laps.set (aps); lape.set (ape); lapv.set (apv); @@ -24,6 +26,20 @@ BlurredSegment::~BlurredSegment () { if (plist != NULL) delete plist; if (dss != NULL) delete dss; + if (scan != NULL) delete scan; +} + + +void BlurredSegment::setScan (const Pt2i &pt1, const Pt2i &pt2) +{ + scan = new DigitalStraightLine (pt1, pt2, DigitalStraightLine::DSL_NAIVE); +} + + +void BlurredSegment::setScan (const Pt2i ¢er, const Vr2i &dir) +{ + Pt2i p2 (center.x () + dir.x (), center.y () + dir.y ()); + scan = new DigitalStraightLine (center, p2, DigitalStraightLine::DSL_NAIVE); } @@ -65,6 +81,28 @@ int BlurredSegment::size () const } +int BlurredSegment::extent () const +{ + int l = 0; + if (scan != NULL) + { + l = scan->pavingIndex (plist->backPoint ()) + + scan->pavingIndex (plist->frontPoint ()); + } + else + { + Pt2i pr = plist->backPoint (); + Pt2i pl = plist->frontPoint (); + Pt2i c ((pr.x () + pl.x ()) / 2, (pr.y () + pl.y ()) / 2); + Pt2i d (c.x () + pl.y () - pr.y (), c.y () + pr.x () - pl.x ()); + DigitalStraightLine line (c, d, DigitalStraightLine::DSL_NAIVE); + l = line.pavingIndex (plist->backPoint ()) + + line.pavingIndex (plist->frontPoint ()); + } + return (l < 0 ? 1 - l : 1 + l); +} + + std::vector<Pt2i> BlurredSegment::getStartPt () const { std::vector<Pt2i> res; diff --git a/Code/FBSD/BlurredSegment/blurredsegment.h b/Code/FBSD/BlurredSegment/blurredsegment.h index 828c29f..d7a7e07 100755 --- a/Code/FBSD/BlurredSegment/blurredsegment.h +++ b/Code/FBSD/BlurredSegment/blurredsegment.h @@ -15,7 +15,7 @@ class BlurredSegment public: /** - * \brief Creates a blurred segment from nothing. + * \brief Creates an empty blurred segment. */ BlurredSegment (); @@ -35,6 +35,20 @@ public: */ virtual ~BlurredSegment (); + /** + * \brief Sets the scan line used for detection. + * @param pt1 Scan start point. + * @param pt2 Scan end point. + */ + virtual void setScan (const Pt2i &pt1, const Pt2i &pt2); + + /** + * \brief Sets the scan line used for detection. + * @param center Scan center point. + * @param dir Scan line direction. + */ + virtual void setScan (const Pt2i ¢er, const Vr2i &dir); + /** * \brief Returns the minimal vertical or horizontal width. */ @@ -60,6 +74,11 @@ public: */ int size () const; + /** + * \brief Returns the scan distance between end points. + */ + int extent () const; + /** * \brief Returns the start point of the blurred segment. */ @@ -201,11 +220,12 @@ public: protected: + /** Bi-directional list of points: the effective blurred segment. */ + BiPtList *plist; /** Bounding straight segment. */ DigitalStraightSegment *dss; - - /** Bi-directional list of points. */ - BiPtList *plist; + /** Central scan line used for detection (if defined). */ + DigitalStraightLine *scan; /** Start point of the last known antipodal edge. */ Pt2i laps; diff --git a/Code/FBSD/BlurredSegment/bsdetector.cpp b/Code/FBSD/BlurredSegment/bsdetector.cpp index 5ba5093..7ca4e1c 100755 --- a/Code/FBSD/BlurredSegment/bsdetector.cpp +++ b/Code/FBSD/BlurredSegment/bsdetector.cpp @@ -26,6 +26,7 @@ const int BSDetector::RESULT_FINAL_TOO_MANY_OUTLIERS = 26; const int BSDetector::DEFAULT_FAST_TRACK_SCAN_WIDTH = 16; const int BSDetector::DEFAULT_ASSIGNED_THICKNESS = 3; +const int BSDetector::DEFAULT_ACCEPTED_LACKS = 5; const int BSDetector::FAST_TRACK_MARGIN = 2; const int BSDetector::BS_MIN_SIZE = 3; @@ -52,11 +53,11 @@ BSDetector::BSDetector () nfaf = NULL; nfaf = (nfaOn ? new NFAFilter () : NULL); + acceptedLacks = DEFAULT_ACCEPTED_LACKS; oppositeGradientDir = false; // main edge detection initialMinSize = DEFAULT_INITIAL_MIN_SIZE; finalFragmentationTestOn = false; fragmentMinSize = DEFAULT_FRAGMENT_MIN_SIZE; - recenteringOn = true; initialSparsityTestOn = true; finalSizeTestOn = true; finalMinSize = DEFAULT_FINAL_MIN_SIZE; @@ -292,7 +293,6 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, || ((! centralp) && p1.chessboard (p2) < BSTracker::MIN_SCAN)) return RESULT_VOID; - // Clearance //---------- if (prelimDetectionOn) bst0->clear (); @@ -314,8 +314,8 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, //--------------------------------------------------------------------- if (prelimDetectionOn) { - bspre = bst0->fastTrack (inThick + FAST_TRACK_MARGIN, - prep1, prep2, prewidth, prepc); + bspre = bst0->fastTrack (prep1, prep2, inThick + FAST_TRACK_MARGIN, + acceptedLacks, prewidth, prepc); if (bspre == NULL || bspre->size () < initialMinSize) return (bspre == NULL ? RESULT_PRELIM_NO_DETECTION : RESULT_PRELIM_TOO_FEW); @@ -344,8 +344,8 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, // Initial detection based on highest gradient without orientation constraint //--------------------------------------------------------------------------- - bsini = bst1->fastTrack (inThick + FAST_TRACK_MARGIN, - inip1, inip2, iniwidth, inipc); + bsini = bst1->fastTrack (inip1, inip2, inThick + FAST_TRACK_MARGIN, + acceptedLacks, iniwidth, inipc); if (bsini == NULL || bsini->size () < initialMinSize) return (bsini == NULL ? RESULT_INITIAL_NO_DETECTION : RESULT_INITIAL_TOO_FEW); @@ -354,12 +354,7 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, //------------- if (initialSparsityTestOn) { - DigitalStraightLine mydsl (inip1, inip2, DigitalStraightLine::DSL_NAIVE); - int mydrlf = mydsl.manhattan (bsini->getLastRight ()) - - mydsl.manhattan (bsini->getLastLeft ()); - if (mydrlf < 0) mydrlf = -mydrlf; // Case of horizontal P1P2 - int expansion = 1 + mydrlf; - if (bsini->size () < expansion / 2) + if (bsini->size () < bsini->extent () / 2) return RESULT_INITIAL_TOO_SPARSE; } @@ -378,12 +373,11 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, // Scan recentering and fitting //----------------------------- - if (recenteringOn) - pCenter.set (bsini->getSegment()->centerOfIntersection (inip1, inip2)); + pCenter.set (bsini->getSegment()->centerOfIntersection (inip1, inip2)); // Finer detection based on gradient maxima with orientation constraint //--------------------------------------------------------------------- - bsf = bst2->fineTrack (inThick, pCenter, bsinidir, 2 * inThick, gRef); + bsf = bst2->fineTrack (pCenter, bsinidir, inThick, acceptedLacks, gRef); if (bsf == NULL || bsf->size () < initialMinSize) return (bsf == NULL ? RESULT_FINAL_NO_DETECTION : RESULT_FINAL_TOO_FEW); @@ -400,13 +394,7 @@ int BSDetector::detect (const Pt2i &p1, const Pt2i &p2, //-------------- if (finalSparsityTestOn) { - Pt2i pOrtho (pCenter.x () + bsinidir.x (), pCenter.y () - bsinidir.y ()); - DigitalStraightLine mydsl (pCenter, pOrtho, DigitalStraightLine::DSL_NAIVE); - int mydrlf = mydsl.manhattan (bsf->getLastRight ()) - - mydsl.manhattan (bsf->getLastLeft ()); - if (mydrlf < 0) mydrlf = -mydrlf; // Case of horizontal P1P2 - int expansion = 1 + mydrlf; - if (expansion < 20 && (int) (bsf->size ()) < (expansion * 4) / 5) + if (bsf->size () < (bsf->extent () * 4) / 5) return RESULT_FINAL_TOO_SPARSE; } @@ -493,6 +481,12 @@ int BSDetector::copyDigitalStraightSegments ( } +void BSDetector::setPixelLackTolerence (int number) +{ + if (number >= 0) acceptedLacks = number; +} + + void BSDetector::incMaxDetections (bool dir) { maxtrials = maxtrials + (dir ? -1 : 1); diff --git a/Code/FBSD/BlurredSegment/bsdetector.h b/Code/FBSD/BlurredSegment/bsdetector.h index 3479279..5ee791d 100755 --- a/Code/FBSD/BlurredSegment/bsdetector.h +++ b/Code/FBSD/BlurredSegment/bsdetector.h @@ -238,15 +238,13 @@ public: /** * \brief Returns the pixel lack tolerence. */ - inline int getPixelLackTolerence () const { - return bst2->pixelLackTolerence (); } + inline int getPixelLackTolerence () const { return acceptedLacks; } /** * \brief Sets the pixel lack tolerence. * @param number New value for the pixel lack tolerance. */ - inline void setPixelLackTolerence (int number) { - bst2->setPixelLackTolerence (number); } + void setPixelLackTolerence (int number); /** * \brief Returns the preliminary detection modality status. @@ -293,16 +291,6 @@ public: inline void switchSingleOrDoubleMultiDetection () { singleMultiOn = ! singleMultiOn; } - /** - * \brief Returns true if the fine scan is recentred on the detected segment. - */ - inline bool isScanRecentering () const { return recenteringOn; } - - /** - * \brief Switches on or off the scan recentering modality. - */ - inline void switchScanRecentering () { recenteringOn = ! recenteringOn; } - /** * \brief Returns true if the multi-selection modality is set. */ @@ -527,6 +515,8 @@ private : static const int DEFAULT_FAST_TRACK_SCAN_WIDTH; /** Default value for the assigned thickess to detection method. */ static const int DEFAULT_ASSIGNED_THICKNESS; + /** Default value for the accepted number of successive lacks. */ + static const int DEFAULT_ACCEPTED_LACKS; /** Additional assigned thickness margin for fast tracks. */ static const int FAST_TRACK_MARGIN; /** Default minimal size of the initial blurred segment. */ @@ -547,6 +537,8 @@ private : VMap *gMap; /** Assigned maximal thickness for current detection. */ int inThick; + /** Accepted number of successive lacks (wrt restart points). */ + int acceptedLacks; /** Preliminary rough tracker. */ BSTracker *bst0; @@ -603,8 +595,6 @@ private : bool finalFragmentationTestOn; /** Minimal size of the segment fragments. */ int fragmentMinSize; - /** Automatic scan recentering (based on previous detection). */ - bool recenteringOn; /** Sparsity test modality after initial detection. */ bool initialSparsityTestOn; /** Sparsity test modality after final detection. */ diff --git a/Code/FBSD/BlurredSegment/bsproto.h b/Code/FBSD/BlurredSegment/bsproto.h index f9d0af6..b315d75 100755 --- a/Code/FBSD/BlurredSegment/bsproto.h +++ b/Code/FBSD/BlurredSegment/bsproto.h @@ -160,5 +160,6 @@ protected: * @param onleft Adding direction (true for LEFT, false for RIGHT). */ bool addPoint (Pt2i p, bool onleft); + }; #endif diff --git a/Code/FBSD/BlurredSegment/bstracker.cpp b/Code/FBSD/BlurredSegment/bstracker.cpp index 05fc160..ffbdecc 100755 --- a/Code/FBSD/BlurredSegment/bstracker.cpp +++ b/Code/FBSD/BlurredSegment/bstracker.cpp @@ -2,7 +2,6 @@ #include "bsproto.h" -const int BSTracker::DEFAULT_ACCEPTED_LACKS = 5; const int BSTracker::DEFAULT_PROX_THRESHOLD = 10; const int BSTracker::MIN_SCAN = 8; const int BSTracker::DEFAULT_MAX_SCAN = 32; @@ -21,7 +20,6 @@ BSTracker::BSTracker () { proxTestOff = true; proxThreshold = DEFAULT_PROX_THRESHOLD; - acceptedLacks = DEFAULT_ACCEPTED_LACKS; maxScan = DEFAULT_MAX_SCAN; fail_status = 0; @@ -57,8 +55,8 @@ void BSTracker::setGradientMap (VMap *data) } -BlurredSegment *BSTracker::fastTrack (int bsMaxWidth, - const Pt2i &p1, const Pt2i &p2, +BlurredSegment *BSTracker::fastTrack (const Pt2i &p1, const Pt2i &p2, + int bsMaxWidth, int acceptedLacks, int swidth, const Pt2i &pc) { // Creates a static directional scanner @@ -99,7 +97,7 @@ BlurredSegment *BSTracker::fastTrack (int bsMaxWidth, } pfirst.set (pix.at (candide)); } - BSProto bs (bsMaxWidth, pfirst); + BSProto bsp (bsMaxWidth, pfirst); Pt2i lastLeft (pfirst); Pt2i lastRight (pfirst); @@ -134,7 +132,7 @@ BlurredSegment *BSTracker::fastTrack (int bsMaxWidth, { if (proxTestOff || lastRight.manhattan (pix.at (candide)) <= proxThreshold) - added = bs.addRight (pix.at (candide)); + added = bsp.addRight (pix.at (candide)); } if (added) { @@ -166,7 +164,7 @@ BlurredSegment *BSTracker::fastTrack (int bsMaxWidth, { if (proxTestOff || lastLeft.manhattan (pix.at (candide)) <= proxThreshold) - added = bs.addLeft (pix.at (candide)); + added = bsp.addLeft (pix.at (candide)); } if (added) { @@ -180,16 +178,23 @@ BlurredSegment *BSTracker::fastTrack (int bsMaxWidth, delete ds; // Validates (regenerates) and returns the blurred segment - return (bs.endOfBirth ()); + BlurredSegment *bs = bsp.endOfBirth (); + if (bs != NULL) + { + if (swidth != 0) bs->setScan (pc, p1.vectorTo (p2)); + else bs->setScan (p1, p2); + } + return (bs); } -BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, - const Pt2i ¢er, const Vr2i &scandir, - int scanwidth, const Vr2i &gref) +BlurredSegment *BSTracker::fineTrack (const Pt2i ¢er, const Vr2i &scandir, + int bsMaxWidth, int acceptedLacks, + const Vr2i &gref) { // Checks scan width minimal size + int scanwidth = 2 * bsMaxWidth; if (scanwidth < MIN_SCAN) scanwidth = MIN_SCAN; // Gets detected segment normal vector @@ -231,7 +236,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, } // Initializes a blurred segment with the first candidate - BSProto bs (bsMaxWidth, pix[cand[0]]); + BSProto bsp (bsMaxWidth, pix[cand[0]]); // Handles assigned thickness control bool atcOn = true; @@ -250,23 +255,24 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, while (scanningRight || scanningLeft) { count ++; - EDist sw = bs.strictThickness (); + EDist sw = bsp.strictThickness (); // Handles assigned thickness control if (atcOn && stab_count >= assignedThicknessControlDelay) { - EDist finalWidth (bs.digitalThickness().sumWithOneHalf ()); - if (finalWidth.lessThan (bs.getMaxWidth ())) bs.setMaxWidth (finalWidth); + EDist finalWidth (bsp.digitalThickness().sumWithOneHalf ()); + if (finalWidth.lessThan (bsp.getMaxWidth ())) + bsp.setMaxWidth (finalWidth); atcOn = false; } // Resets the scan stripe - if (count > fittingDelay && bs.isExtending ()) + if (count > fittingDelay && bsp.isExtending ()) { // Stops the detection if the segment gets crosswise if (count == fittingDelay + 1) { - Vr2i dirn = bs.getSupportVector (); + Vr2i dirn = bsp.getSupportVector (); if (4 * dirn.squaredScalarProduct (scandir) < 3 * dirn.norm2 () * scandir.norm2 ()) // div. angle > 30 degrees { @@ -276,7 +282,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, } } int ppa, ppb, ppc; - bs.getLine()->getCentralLine (ppa, ppb, ppc); + bsp.getLine()->getCentralLine (ppa, ppb, ppc); ds->bindTo (ppa, ppb, ppc); } @@ -302,12 +308,12 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, added = false; nbc = gMap->localMax (cand, pix, normal); for (int i = 0; ! added && i < nbc; i++) - added = bs.addRight (pix[cand[i]]); + added = bsp.addRight (pix[cand[i]]); stab_count ++; if (added) { // Checks if the segment width is stable - if (atcOn && sw.lessThan (bs.strictThickness ())) stab_count = 0; + if (atcOn && sw.lessThan (bsp.strictThickness ())) stab_count = 0; // Handles detection interruptions if (rstop == 0) rstart = 0; @@ -325,7 +331,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, { if (++rstop - rstart > acceptedLacks) { - if (bs.size () <= 3) fail_status = FAILURE_NO_START; + if (bsp.size () <= 3) fail_status = FAILURE_NO_START; scanningRight = false; } } @@ -354,12 +360,12 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, added = false; nbc = gMap->localMax (cand, pix, normal); for (int i = 0; ! added && i < nbc; i++) - added = bs.addLeft (pix[cand[i]]); + added = bsp.addLeft (pix[cand[i]]); stab_count ++; if (added) { // Checks if the segment width is stable - if (atcOn && sw.lessThan (bs.strictThickness ())) stab_count = 0; + if (atcOn && sw.lessThan (bsp.strictThickness ())) stab_count = 0; // Handles detection interruptions if (lstop == 0) lstart = 0; @@ -377,25 +383,21 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, { if (++lstop - lstart > acceptedLacks) { - if (bs.size () <= 3) fail_status = FAILURE_NO_START; + if (bsp.size () <= 3) fail_status = FAILURE_NO_START; scanningLeft = false; } } } } } - if (rstart) bs.removeRight (rstart); - if (lstart) bs.removeLeft (lstart); + if (rstart) bsp.removeRight (rstart); + if (lstart) bsp.removeLeft (lstart); delete ds; // Validates (regenerates) and returns the blurred segment - return (bs.endOfBirth ()); -} - - -void BSTracker::setPixelLackTolerence (int number) -{ - if (number >= 0) acceptedLacks = number; + BlurredSegment *bs = bsp.endOfBirth (); + if (bs != NULL) bs->setScan (center, normal); + return (bs); } diff --git a/Code/FBSD/BlurredSegment/bstracker.h b/Code/FBSD/BlurredSegment/bstracker.h index bfd469b..b820f9b 100755 --- a/Code/FBSD/BlurredSegment/bstracker.h +++ b/Code/FBSD/BlurredSegment/bstracker.h @@ -41,39 +41,29 @@ public: /** * \brief Builds and returns a blurred segment from only gradient maximum. - * @param bsMaxWidth Blurred segment assigned maximal width. * @param p1 Initial stroke start point. * @param p2 Initial stroke end point. + * @param bsMaxWidth Blurred segment assigned maximal width. + * @param acceptedLacks Count of maximal successive detection fails. * @param swidth Set to 0 if no start point is provided. * @param pc Initial segment start point (if swidth is set). */ - BlurredSegment *fastTrack (int bsMaxWidth, - const Pt2i &p1, const Pt2i &p2, + BlurredSegment *fastTrack (const Pt2i &p1, const Pt2i &p2, + int bsMaxWidth, int acceptedLacks, int swidth = 0, const Pt2i &pc = Pt2i ()); /** * \brief Builds and returns a blurred segment from local gradient maxima. * Finer detection using gradient ridges and direction input. - * @param bsMaxWidth Initial assigned maximal width of the blurred segment. * @param center Central point of the scan. * @param scandir Scan stripe direction. - * @param scanwidth Width of the scan strip. + * @param bsMaxWidth Initial assigned maximal width of the blurred segment. + * @param acceptedLacks Count of maximal successive detection fails. * @param gref Gradient vector reference to select candidates. */ - BlurredSegment *fineTrack (int bsMaxWidth, - const Pt2i ¢er, const Vr2i &scandir, - int scanwidth, const Vr2i &gref); - - /** - * \brief Returns the pixel lack tolerence for exdending the blurred segment. - */ - inline int pixelLackTolerence () const { return acceptedLacks; } - - /** - * \brief Sets the pixel lack tolerence for extending the blurred segment. - * @param number New value for the pixel lack tolerence. - */ - void setPixelLackTolerence (int number); + BlurredSegment *fineTrack (const Pt2i ¢er, const Vr2i &scandir, + int bsMaxWidth, int acceptedLacks, + const Vr2i &gref); /** * \brief Returns the proximity test status. @@ -146,8 +136,6 @@ public: private : // Segment detection default parameters. - /** Default value for the accepted number of successive lacks. */ - static const int DEFAULT_ACCEPTED_LACKS; /** Default value for the proximity test used for fast tracking. */ static const int DEFAULT_PROX_THRESHOLD; /** Default value for the maximal number of scans processed on each side. */ @@ -196,8 +184,6 @@ private : /** Scan lines. */ std::vector <std::vector <Pt2i> > scanLine; - /** Accepted number of successive lacks (wrt restart points). */ - int acceptedLacks; /** Maximum number of scans to process at fast tracking stage. */ int maxScan; /** Minimal detection width before activating the dynamical scans. */ diff --git a/Code/FBSD/ConvexHull/chvertex.h b/Code/FBSD/ConvexHull/chvertex.h index 6c7ff72..82b7226 100755 --- a/Code/FBSD/ConvexHull/chvertex.h +++ b/Code/FBSD/ConvexHull/chvertex.h @@ -89,5 +89,4 @@ protected: CHVertex *rv; }; - #endif diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp index 2772d71..9e2bdf1 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp +++ b/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp @@ -57,11 +57,11 @@ AdaptiveScannerO1::AdaptiveScannerO1 ( lcy --; } while (dla * lcx + dlb * lcy < c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; fs = steps + nbs; } @@ -87,6 +87,8 @@ AdaptiveScannerO1::AdaptiveScannerO1 ( lcy --; } dlc1 = dla * lcx + dlb * lcy; + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -104,8 +106,6 @@ AdaptiveScannerO1::AdaptiveScannerO1 ( rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; } @@ -128,7 +128,7 @@ DirectionalScanner *AdaptiveScannerO1::getCopy () int AdaptiveScannerO1::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((x >= xmax || y < ymin) && dla * x + dlb * y >= dlc2) { diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero1.h b/Code/FBSD/DirectionalScanner/adaptivescannero1.h index 7397fd8..27d18cb 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero1.h +++ b/Code/FBSD/DirectionalScanner/adaptivescannero1.h @@ -14,7 +14,7 @@ public: /** * \brief Creates an adaptive DS from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -135,5 +135,4 @@ protected : AdaptiveScannerO1 (AdaptiveScannerO1 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp index c6f2e84..6417c10 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp +++ b/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp @@ -57,11 +57,11 @@ AdaptiveScannerO2::AdaptiveScannerO2 ( lcx ++; } while (dla * lcx + dlb * lcy < c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; fs = steps + nbs; } @@ -87,6 +87,8 @@ AdaptiveScannerO2::AdaptiveScannerO2 ( lcx ++; } dlc1 = dla * lcx + dlb * lcy; + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -104,8 +106,6 @@ AdaptiveScannerO2::AdaptiveScannerO2 ( rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; } @@ -128,7 +128,7 @@ DirectionalScanner *AdaptiveScannerO2::getCopy () int AdaptiveScannerO2::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((y < ymin || x >= xmax) && dla * x + dlb * y >= dlc2) { diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero2.h b/Code/FBSD/DirectionalScanner/adaptivescannero2.h index d97f90c..e3ab663 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero2.h +++ b/Code/FBSD/DirectionalScanner/adaptivescannero2.h @@ -16,7 +16,7 @@ public: /** * \brief Creates an adaptive DS from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -36,7 +36,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -57,7 +57,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -82,21 +82,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -137,5 +137,4 @@ protected : AdaptiveScannerO2 (AdaptiveScannerO2 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp index 8878b64..7c476ed 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp +++ b/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp @@ -57,11 +57,11 @@ AdaptiveScannerO7::AdaptiveScannerO7 ( lcx --; } while (dla * lcx + dlb * lcy > c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; fs = steps + nbs; } @@ -87,6 +87,8 @@ AdaptiveScannerO7::AdaptiveScannerO7 ( lcx --; } dlc1 = dla * lcx + dlb * lcy; + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -104,8 +106,6 @@ AdaptiveScannerO7::AdaptiveScannerO7 ( rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; } @@ -128,7 +128,7 @@ DirectionalScanner *AdaptiveScannerO7::getCopy () int AdaptiveScannerO7::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((y < ymin || x < xmin) && dla * x + dlb * y <= dlc2) { diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero7.h b/Code/FBSD/DirectionalScanner/adaptivescannero7.h index eafc1e9..e95d6ab 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero7.h +++ b/Code/FBSD/DirectionalScanner/adaptivescannero7.h @@ -15,7 +15,7 @@ public: /** * \brief Creates an adaptive DS from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -35,7 +35,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -56,7 +56,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -81,21 +81,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -136,5 +136,4 @@ protected : AdaptiveScannerO7 (AdaptiveScannerO7 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp index 868f886..1c838fe 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp +++ b/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp @@ -57,11 +57,11 @@ AdaptiveScannerO8::AdaptiveScannerO8 ( lcy --; } while (dla * lcx + dlb * lcy > c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; fs = steps + nbs; } @@ -87,6 +87,8 @@ AdaptiveScannerO8::AdaptiveScannerO8 ( lcy --; } dlc1 = dla * lcx + dlb * lcy; + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -104,8 +106,6 @@ AdaptiveScannerO8::AdaptiveScannerO8 ( rcx = lcx; rcy = lcy; - lst2 = steps; - rst2 = steps; } @@ -128,7 +128,7 @@ DirectionalScanner *AdaptiveScannerO8::getCopy () int AdaptiveScannerO8::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((x < xmin || y < ymin) && dla * x + dlb * y <= dlc2) { diff --git a/Code/FBSD/DirectionalScanner/adaptivescannero8.h b/Code/FBSD/DirectionalScanner/adaptivescannero8.h index 34ec977..e4a73f7 100755 --- a/Code/FBSD/DirectionalScanner/adaptivescannero8.h +++ b/Code/FBSD/DirectionalScanner/adaptivescannero8.h @@ -14,7 +14,7 @@ public: /** * \brief Creates an adaptive DS from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates an adaptive DS from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -135,5 +135,4 @@ protected : AdaptiveScannerO8 (AdaptiveScannerO8 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/directionalscanner.h b/Code/FBSD/DirectionalScanner/directionalscanner.h index 7bbd031..2c1de42 100755 --- a/Code/FBSD/DirectionalScanner/directionalscanner.h +++ b/Code/FBSD/DirectionalScanner/directionalscanner.h @@ -14,7 +14,7 @@ class DirectionalScanner public: /** - * \brief Deletes the scan strip. + * \brief Deletes the directional scanner. */ virtual ~DirectionalScanner (); @@ -24,21 +24,21 @@ public: virtual DirectionalScanner *getCopy () = 0; /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ virtual int first (std::vector<Pt2i> &scan) const = 0; /** - * \brief Returns next scan on the left. + * \brief Gets next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ virtual int nextOnLeft (std::vector<Pt2i> &scan) = 0; /** - * \brief Returns next scan on the right. + * \brief Gets next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -92,9 +92,9 @@ protected: /** Pointer to the end of discrete line pattern. */ bool *fs; - /** X-start position of central scan. */ + /** X-start position of central scan (still used in locate (Pt2i)). */ int ccx; - /** Y-start position of central scan. */ + /** Y-start position of central scan (still used in locate (Pt2i)). */ int ccy; /** X-start position of last scan to the left. */ int lcx; @@ -105,9 +105,9 @@ protected: /** Y-start position of last scan to the right. */ int rcy; - /** Current pattern step in left scan direction. */ + /** Current pattern step in scan line direction for left scans. */ bool *lst2; - /** Current pattern step in right scan direction. */ + /** Current pattern step in scan line direction for right scans. */ bool *rst2; /** Flag indicating if the output vector should be cleared before filling. @@ -130,9 +130,9 @@ protected: * @param xmaxi Right border of the scan area. * @param ymaxi Top border of the scan area. * @param nb Size of the support line pattern. - * @param st Support line pattern - * @param sx X-coordinate of the central scan start point - * @param sy Y-coordinate of the central scan start point + * @param st Support line pattern. + * @param sx X-coordinate of the central scan start point. + * @param sy Y-coordinate of the central scan start point. */ DirectionalScanner (int xmini, int ymini, int xmaxi, int ymaxi, int nb, bool* st, int sx, int sy) @@ -152,6 +152,6 @@ protected: ccx (ds->ccx), ccy (ds->ccy), lcx (ds->lcx), lcy (ds->lcy), rcx (ds->rcx), rcy (ds->rcy), lst2 (ds->lst2), rst2 (ds->rst2), clearance (ds->clearance) { } -}; +}; #endif diff --git a/Code/FBSD/DirectionalScanner/directionalscannero1.cpp b/Code/FBSD/DirectionalScanner/directionalscannero1.cpp index c046385..c4a634f 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero1.cpp +++ b/Code/FBSD/DirectionalScanner/directionalscannero1.cpp @@ -17,8 +17,8 @@ DirectionalScannerO1::DirectionalScannerO1 ( lst2 = steps; rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -47,6 +47,8 @@ DirectionalScannerO1::DirectionalScannerO1 ( lcy --; } while (dla * lcx + dlb * lcy < c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; @@ -56,11 +58,9 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -84,6 +84,8 @@ DirectionalScannerO1::DirectionalScannerO1 ( if (*st) lcx ++; lcy --; } + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -103,10 +105,8 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -115,8 +115,8 @@ DirectionalScannerO1::DirectionalScannerO1 (DirectionalScannerO1 *ds) { lst1 = ds->lst1; rst1 = ds->rst1; - ltransition = ds->ltransition; - rtransition = ds->rtransition; + lstop = ds->lstop; + rstop = ds->rstop; } @@ -129,7 +129,7 @@ DirectionalScanner *DirectionalScannerO1::getCopy () int DirectionalScannerO1::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((x >= xmax || y < ymin) && dla * x + dlb * y >= dlc2) { @@ -152,11 +152,11 @@ int DirectionalScannerO1::nextOnLeft (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (ltransition) + if (lstop) { lcy --; if (--lst2 < steps) lst2 = fs - 1; - ltransition = false; + lstop = false; } else { @@ -170,7 +170,7 @@ int DirectionalScannerO1::nextOnLeft (std::vector<Pt2i> &scan) { if (++lst2 >= fs) lst2 = steps; lcy ++; - ltransition = true; + lstop = true; } } } @@ -200,10 +200,10 @@ int DirectionalScannerO1::nextOnRight (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (rtransition) + if (rstop) { rcx ++; - rtransition = false; + rstop = false; } else { @@ -213,7 +213,7 @@ int DirectionalScannerO1::nextOnRight (std::vector<Pt2i> &scan) if (*rst2) { rcx --; - rtransition = true; + rstop = true; } rcy ++; if (++rst2 >= fs) rst2 = steps; diff --git a/Code/FBSD/DirectionalScanner/directionalscannero1.h b/Code/FBSD/DirectionalScanner/directionalscannero1.h index 023b5d1..38e4db4 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero1.h +++ b/Code/FBSD/DirectionalScanner/directionalscannero1.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a directional scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param xmax Right border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -110,15 +110,15 @@ public: private: - /** Current pattern step in strip direction on left side. */ + /** Current pattern step in stripe direction on left side. */ bool *lst1; - /** Current pattern step in strip direction on right side. */ + /** Current pattern step in stripe direction on right side. */ bool *rst1; - /** Status indicating start with a transition on last left scan. */ - bool ltransition; - /** Status indicating start with a transition on last right scan. */ - bool rtransition; + /** Status indicating no move in stripe direction on next left scan. */ + bool lstop; + /** Status indicating no move in stripe direction on next right scan. */ + bool rstop; /** @@ -128,5 +128,4 @@ private: DirectionalScannerO1 (DirectionalScannerO1 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/directionalscannero2.cpp b/Code/FBSD/DirectionalScanner/directionalscannero2.cpp index 8ea13b7..e4164b7 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero2.cpp +++ b/Code/FBSD/DirectionalScanner/directionalscannero2.cpp @@ -17,8 +17,8 @@ DirectionalScannerO2::DirectionalScannerO2 ( lst2 = steps; rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -47,6 +47,8 @@ DirectionalScannerO2::DirectionalScannerO2 ( lcx ++; } while (dla * lcx + dlb * lcy < c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; @@ -56,11 +58,9 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -84,6 +84,8 @@ DirectionalScannerO2::DirectionalScannerO2 ( if (*st) lcy --; lcx ++; } + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -103,10 +105,8 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -115,8 +115,8 @@ DirectionalScannerO2::DirectionalScannerO2 (DirectionalScannerO2 *ds) { lst1 = ds->lst1; rst1 = ds->rst1; - ltransition = ds->ltransition; - rtransition = ds->rtransition; + lstop = ds->lstop; + rstop = ds->rstop; } @@ -129,7 +129,7 @@ DirectionalScanner *DirectionalScannerO2::getCopy () int DirectionalScannerO2::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((y < ymin || x >= xmax) && dla * x + dlb * y >= dlc2) { @@ -152,10 +152,10 @@ int DirectionalScannerO2::nextOnLeft (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (ltransition) + if (lstop) { lcy --; - ltransition = false; + lstop = false; } else { @@ -167,7 +167,7 @@ int DirectionalScannerO2::nextOnLeft (std::vector<Pt2i> &scan) if (*lst2) { lcy ++; - ltransition = true; + lstop = true; } if (++lst2 >= fs) lst2 = steps; } @@ -198,11 +198,11 @@ int DirectionalScannerO2::nextOnRight (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (rtransition) + if (rstop) { rcx ++; if (--rst2 < steps) rst2 = fs - 1; - rtransition = false; + rstop = false; } else { @@ -213,7 +213,7 @@ int DirectionalScannerO2::nextOnRight (std::vector<Pt2i> &scan) if (*rst2) { if (++rst2 >= fs) rst2 = steps; - rtransition = true; + rstop = true; } else rcx ++; } diff --git a/Code/FBSD/DirectionalScanner/directionalscannero2.h b/Code/FBSD/DirectionalScanner/directionalscannero2.h index dfd53d1..79e39ff 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero2.h +++ b/Code/FBSD/DirectionalScanner/directionalscannero2.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a directional scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -110,15 +110,15 @@ public: private: - /** Current pattern step in strip direction on left side. */ + /** Current pattern step in stripe direction on left side. */ bool *lst1; - /** Current pattern step in strip direction on right side. */ + /** Current pattern step in stripe direction on right side. */ bool *rst1; - /** Status indicating start with a transition on last left scan. */ - bool ltransition; - /** Status indicating start with a transition on last right scan. */ - bool rtransition; + /** Status indicating no move in stripe direction on next left scan. */ + bool lstop; + /** Status indicating no move in stripe direction on next right scan. */ + bool rstop; /** @@ -128,5 +128,4 @@ private: DirectionalScannerO2 (DirectionalScannerO2 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/directionalscannero7.cpp b/Code/FBSD/DirectionalScanner/directionalscannero7.cpp index 62ae699..efa3d7d 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero7.cpp +++ b/Code/FBSD/DirectionalScanner/directionalscannero7.cpp @@ -17,8 +17,8 @@ DirectionalScannerO7::DirectionalScannerO7 ( lst2 = steps; rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -47,6 +47,8 @@ DirectionalScannerO7::DirectionalScannerO7 ( lcx --; } while (dla * lcx + dlb * lcy > c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; @@ -56,11 +58,9 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -84,6 +84,8 @@ DirectionalScannerO7::DirectionalScannerO7 ( if (*st) lcy --; lcx --; } + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -103,10 +105,8 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -115,8 +115,8 @@ DirectionalScannerO7::DirectionalScannerO7 (DirectionalScannerO7 *ds) { lst1 = ds->lst1; rst1 = ds->rst1; - ltransition = ds->ltransition; - rtransition = ds->rtransition; + lstop = ds->lstop; + rstop = ds->rstop; } @@ -129,7 +129,7 @@ DirectionalScanner *DirectionalScannerO7::getCopy () int DirectionalScannerO7::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((y < ymin || x < xmin) && dla * x + dlb * y <= dlc2) { @@ -152,11 +152,11 @@ int DirectionalScannerO7::nextOnLeft (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (ltransition) + if (lstop) { lcx --; if (--lst2 < steps) lst2 = fs - 1; - ltransition = false; + lstop = false; } else { @@ -168,7 +168,7 @@ int DirectionalScannerO7::nextOnLeft (std::vector<Pt2i> &scan) if (*lst2) { if (++lst2 >= fs) lst2 = steps; - ltransition = true; + lstop = true; } else lcx --; } @@ -199,10 +199,10 @@ int DirectionalScannerO7::nextOnRight (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (rtransition) + if (rstop) { rcy --; - rtransition = false; + rstop = false; } else { @@ -213,7 +213,7 @@ int DirectionalScannerO7::nextOnRight (std::vector<Pt2i> &scan) if (*rst2) { rcy ++; - rtransition = true; + rstop = true; } if (++rst2 >= fs) rst2 = steps; } diff --git a/Code/FBSD/DirectionalScanner/directionalscannero7.h b/Code/FBSD/DirectionalScanner/directionalscannero7.h index f2a33c8..e4141aa 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero7.h +++ b/Code/FBSD/DirectionalScanner/directionalscannero7.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a directional scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -110,15 +110,15 @@ public: private: - /** Current pattern step in strip direction on left side. */ + /** Current pattern step in stripe direction on left side. */ bool *lst1; - /** Current pattern step in strip direction on right side. */ + /** Current pattern step in stripe direction on right side. */ bool *rst1; - /** Status indicating start with a transition on last left scan. */ - bool ltransition; - /** Status indicating start with a transition on last right scan. */ - bool rtransition; + /** Status indicating no move in stripe direction on next left scan. */ + bool lstop; + /** Status indicating no move in stripe direction on next right scan. */ + bool rstop; /** @@ -128,5 +128,4 @@ private: DirectionalScannerO7 (DirectionalScannerO7 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/directionalscannero8.cpp b/Code/FBSD/DirectionalScanner/directionalscannero8.cpp index 8e110ca..1134235 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero8.cpp +++ b/Code/FBSD/DirectionalScanner/directionalscannero8.cpp @@ -17,8 +17,8 @@ DirectionalScannerO8::DirectionalScannerO8 ( lst2 = steps; rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -47,6 +47,8 @@ DirectionalScannerO8::DirectionalScannerO8 ( lcy --; } while (dla * lcx + dlb * lcy > c1); + lst2 = st; + rst2 = st; rcx = lcx; rcy = lcy; @@ -56,11 +58,9 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; fs = steps + nbs; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -84,6 +84,8 @@ DirectionalScannerO8::DirectionalScannerO8 ( if (*st) lcx --; lcy --; } + lst2 = st; + rst2 = st; // Looking for the upper leaning line st = steps; @@ -103,10 +105,8 @@ ccy = lcy; /** ZZZ */ lst1 = steps; rst1 = steps; - lst2 = steps; - rst2 = steps; - ltransition = false; - rtransition = false; + lstop = false; + rstop = false; } @@ -115,8 +115,8 @@ DirectionalScannerO8::DirectionalScannerO8 (DirectionalScannerO8 *ds) { lst1 = ds->lst1; rst1 = ds->rst1; - ltransition = ds->ltransition; - rtransition = ds->rtransition; + lstop = ds->lstop; + rstop = ds->rstop; } @@ -129,7 +129,7 @@ DirectionalScanner *DirectionalScannerO8::getCopy () int DirectionalScannerO8::first (std::vector<Pt2i> &scan) const { int x = lcx, y = lcy; // Current position coordinates - bool *nst = steps; // Current step in scan direction (jpts) + bool *nst = lst2; // Current step in scan direction (jpts) while ((x < xmin || y < ymin) && dla * x + dlb * y <= dlc2) { @@ -152,10 +152,10 @@ int DirectionalScannerO8::nextOnLeft (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (ltransition) + if (lstop) { lcx --; - ltransition = false; + lstop = false; } else { @@ -167,7 +167,7 @@ int DirectionalScannerO8::nextOnLeft (std::vector<Pt2i> &scan) if (*lst2) { lcx ++; - ltransition = true; + lstop = true; } if (++lst2 >= fs) lst2 = steps; } @@ -198,11 +198,11 @@ int DirectionalScannerO8::nextOnRight (std::vector<Pt2i> &scan) { // Prepares the next scan if (clearance) scan.clear (); - if (rtransition) + if (rstop) { rcy --; if (--rst2 < steps) rst2 = fs - 1; - rtransition = false; + rstop = false; } else { @@ -213,7 +213,7 @@ int DirectionalScannerO8::nextOnRight (std::vector<Pt2i> &scan) if (*rst2) { if (++rst2 >= fs) rst2 = steps; - rtransition = true; + rstop = true; } else rcy --; } diff --git a/Code/FBSD/DirectionalScanner/directionalscannero8.h b/Code/FBSD/DirectionalScanner/directionalscannero8.h index 3a6179c..0b28b9e 100755 --- a/Code/FBSD/DirectionalScanner/directionalscannero8.h +++ b/Code/FBSD/DirectionalScanner/directionalscannero8.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a directional scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a directional scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -80,21 +80,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ @@ -110,15 +110,15 @@ public: private: - /** Current pattern step in strip direction on left side. */ + /** Current pattern step in stripe direction on left side. */ bool *lst1; - /** Current pattern step in strip direction on right side. */ + /** Current pattern step in stripe direction on right side. */ bool *rst1; - /** Status indicating start with a transition on last left scan. */ - bool ltransition; - /** Status indicating start with a transition on last right scan. */ - bool rtransition; + /** Status indicating no move in stripe direction on next left scan. */ + bool lstop; + /** Status indicating no move in stripe direction on next right scan. */ + bool rstop; /** @@ -128,5 +128,4 @@ private: DirectionalScannerO8 (DirectionalScannerO8 *ds); }; - #endif diff --git a/Code/FBSD/DirectionalScanner/scannerprovider.cpp b/Code/FBSD/DirectionalScanner/scannerprovider.cpp index 0d23234..8d4d492 100755 --- a/Code/FBSD/DirectionalScanner/scannerprovider.cpp +++ b/Code/FBSD/DirectionalScanner/scannerprovider.cpp @@ -111,103 +111,24 @@ DirectionalScanner *ScannerProvider::getScanner (Pt2i p1, Pt2i p2, } -DirectionalScanner *ScannerProvider::getScanner (Pt2i p1, Pt2i p2, - Pt2i v1, Pt2i v2) -{ - // Get the scan strip center - int cx = (p1.x () + p2.x ()) / 2; - int cy = (p1.y () + p2.y ()) / 2; - - // Gets the steps position array - int nbs = 0; - bool *steps = v1.stepsTo (v2, &nbs); - - // Equation of the straight line passing through the center : ax - by = mu - int a = v2.y () - v1.y (); - int b = v1.x () - v2.x (); - if (a < 0 || (a == 0 && b < 0)) - { - a = -a; - b = -b; - } - - // Equation of the support lines of the scan strip - int c1 = a * p1.x () + b * p1.y (); - int c2 = a * p2.x () + b * p2.y (); - - // Builds and returns the appropriate scanner - if (b < 0) - if (-b > a) - return (new DirectionalScannerO1 (xmin, ymin, xmax, ymax, - a, b, c1, c2, nbs, steps, cx, cy)); - else - return (new DirectionalScannerO2 (xmin, ymin, xmax, ymax, - a, b, c1, c2, nbs, steps, cx, cy)); - else - if (b > a) - return (new DirectionalScannerO8 (xmin, ymin, xmax, ymax, - a, b, c1, c2, nbs, steps, cx, cy)); - else - return (new DirectionalScannerO7 (xmin, ymin, xmax, ymax, - a, b, c1, c2, nbs, steps, cx, cy)); -} - - -DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal, - int length) -{ - // Gets the steps position array - int nbs = 0; - bool *steps = normal.steps (&nbs); - - // Orients the direction rightwards - int a = normal.x (); - int b = normal.y (); // as equation is (ax - by) - if (a < 0 || (a == 0 && b < 0)) - { - a = -a; - b = -b; - } - - // Builds and returns the appropriate scanner - if (b < 0) - if (-b > a) - return (new DirectionalScannerO1 (xmin, ymin, xmax, ymax, - a, b, nbs, steps, - centre.x (), centre.y (), length)); - else - return (new DirectionalScannerO2 (xmin, ymin, xmax, ymax, - a, b, nbs, steps, - centre.x (), centre.y (), length)); - else - if (b > a) - return (new DirectionalScannerO8 (xmin, ymin, xmax, ymax, - a, b, nbs, steps, - centre.x (), centre.y (), length)); - else - return (new DirectionalScannerO7 (xmin, ymin, xmax, ymax, - a, b, nbs, steps, - centre.x (), centre.y (), length)); -} - - DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal, int length, bool controlable) { // Gets the steps position array int nbs = 0; - bool *steps = normal.steps (&nbs); + bool *steps = centre.stepsTo (Pt2i (centre.x () + normal.x (), + centre.y () + normal.y ()), &nbs); - // Orients the direction rightwards + // Orients rightwards int a = normal.x (); - int b = normal.y (); // as equation is (ax - by) + int b = normal.y (); // as equation is (ax + by = c) if (a < 0 || (a == 0 && b < 0)) { a = -a; b = -b; } - + // Builds and returns the appropriate scanner if (b < 0) if (-b > a) return (controlable ? diff --git a/Code/FBSD/DirectionalScanner/scannerprovider.h b/Code/FBSD/DirectionalScanner/scannerprovider.h index adac59b..d512635 100755 --- a/Code/FBSD/DirectionalScanner/scannerprovider.h +++ b/Code/FBSD/DirectionalScanner/scannerprovider.h @@ -8,7 +8,7 @@ * @class ScannerProvider scannerprovider.h * \brief Directional scanner provider. * Provides ad-hoc directional scanners in the relevant octant - * and according to static or dynamical needs. + * and according to static or dynamical control. */ class ScannerProvider { @@ -39,51 +39,27 @@ public: xmin = x0, ymin = y0, xmax = x0 + sizex; ymax = y0 + sizey; } /** - * \brief Returns an incremental directional scanner. + * \brief Returns a directional scanner from initial scan end points. * Returns a directional scanner from two control points. - * The scan strip is composed of parallel scan lines, the first one being - * defined by control points p1 and p2. - * @param p1 Start control point. - * @param p2 End control point. - * @param controlable Controlability request (true for an adaptive scanner). + * The scan stripe is composed of parallel scans (line segments), + * the initial one being defined by control points p1 and p2. + * @param p1 Initial scan start point. + * @param p2 Initial scan end point. + * @param controlable Control modality (true for an adaptive scanner). */ DirectionalScanner *getScanner (Pt2i p1, Pt2i p2, bool controlable = false); /** - * \brief Returns an incremental directional scanner. - * Returns a directional scanner from two points and direction v1 -> v2. - * The scan strip is composed of parallel scan lines, centered on the middle - * of (p1,p2) and aligned on (v1,v2). - * @param p1 Start control point - * @param p2 End control point - * @param v1 Direction start point - * @param v2 Direction end point - */ - DirectionalScanner *getScanner (Pt2i p1, Pt2i p2, Pt2i v1, Pt2i v2); - - /** - * \brief Returns an incremental directional scanner. - * Returns a directional scanner from two points and direction v1 -> v2. - * The scan strip is composed of parallel scan lines, centered on the middle - * of (p1,p2) and aligned on (v1,v2). - * @param centre Central point - * @param normal Scan strip normal vector - * @param length Length of a scan line - */ - DirectionalScanner *getScanner (Pt2i centre, Vr2i normal, int length); - - /** - * \brief Returns an incremental directional scanner. - * Returns a directional scanner from two points and direction v1 -> v2. - * The scan strip is composed of parallel scan lines, centered on the middle - * of (p1,p2) and aligned on (v1,v2). - * @param centre Central point - * @param normal Scan strip normal vector - * @param length Length of a scan line - * @param controlable Controlability request (true for an adaptive scanner) + * \brief Returns a directional scanner from scan center, vector and length. + * The scan stripe is composed of parallel scans (line segments), + * the first one defined by its center, its direct vector, and its length. + * @param centre Initial scan center. + * @param normal Initial scan direct vector. + * @param length Initial scan length. + * @param controlable Control modality (true for an adaptive scanner). */ DirectionalScanner *getScanner (Pt2i centre, Vr2i normal, - int length, bool controlable); + int length, bool controlable = false); /** * \brief Returns whether the currently used scan end points were permutated. @@ -112,6 +88,6 @@ private: int xmax; /** Scan area highest y coordinate. */ int ymax; -}; +}; #endif diff --git a/Code/FBSD/DirectionalScanner/vhscannero1.h b/Code/FBSD/DirectionalScanner/vhscannero1.h index da23e69..48d9bf7 100755 --- a/Code/FBSD/DirectionalScanner/vhscannero1.h +++ b/Code/FBSD/DirectionalScanner/vhscannero1.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a vh scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and length . - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -79,21 +79,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ diff --git a/Code/FBSD/DirectionalScanner/vhscannero2.h b/Code/FBSD/DirectionalScanner/vhscannero2.h index 8b4a8cb..f4286db 100755 --- a/Code/FBSD/DirectionalScanner/vhscannero2.h +++ b/Code/FBSD/DirectionalScanner/vhscannero2.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a vh scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -79,21 +79,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ diff --git a/Code/FBSD/DirectionalScanner/vhscannero7.h b/Code/FBSD/DirectionalScanner/vhscannero7.h index 84f50a9..d10d52e 100755 --- a/Code/FBSD/DirectionalScanner/vhscannero7.h +++ b/Code/FBSD/DirectionalScanner/vhscannero7.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a vh scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -79,21 +79,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ diff --git a/Code/FBSD/DirectionalScanner/vhscannero8.h b/Code/FBSD/DirectionalScanner/vhscannero8.h index ccdf4f7..b8ae4ab 100755 --- a/Code/FBSD/DirectionalScanner/vhscannero8.h +++ b/Code/FBSD/DirectionalScanner/vhscannero8.h @@ -14,7 +14,7 @@ public: /** * \brief Creates a vh scanner from pattern, start and upper bound. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a start point, a line pattern, and an upper bound. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -34,7 +34,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and bounds. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, upper and lower bounds. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -55,7 +55,7 @@ public: /** * \brief Creates a vh scanner from pattern, center and length. - * The scan strip is composed of parallel scan lines, the first one being + * The scan stripe is composed of parallel scan lines, the first one being * defined by a center, a line pattern, and a length value. * @param xmin Left border of the scan area. * @param ymin Bottom border of the scan area. @@ -79,21 +79,21 @@ public: DirectionalScanner *getCopy (); /** - * \brief Returns the central scan. + * \brief Gets the central scan in a vector. * Adds central scan points to given vector and returns its new size. * @param scan Vector of points to be completed. */ int first (std::vector<Pt2i> &scan) const; /** - * \brief Returns the next scan on the left. + * \brief Gets the next scan on the left in a vector. * Adds points of next left scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ int nextOnLeft (std::vector<Pt2i> &scan); /** - * \brief Returns the next scan on the right. + * \brief Gets the next scan on the right in a vector. * Adds points of next right scan to given vector and returns its new size. * @param scan Vector of points to be completed. */ diff --git a/Code/FBSD/ImageTools/digitalstraightline.cpp b/Code/FBSD/ImageTools/digitalstraightline.cpp index d2659df..c7dede7 100755 --- a/Code/FBSD/ImageTools/digitalstraightline.cpp +++ b/Code/FBSD/ImageTools/digitalstraightline.cpp @@ -65,10 +65,7 @@ DigitalStraightLine::DigitalStraightLine (Pt2i p1, Pt2i p2, int type) if (nu < 0) nu = -nu; if (nu < a) nu = a; // To match Pt2i::stepsTo method ... - if ((b > 0 && a > b) || (b < 0 && a < -b)) - c -= (nu - 1) / 2; - else - c -= nu / 2; + c -= nu / 2; } else if (type == DSL_STANDARD) @@ -436,6 +433,20 @@ bool DigitalStraightLine::crosses (const Pt2i &p1, const Pt2i &p2) const } +int DigitalStraightLine::pavingIndex (Pt2i pt) const +{ + int rmd = a * pt.x () + b * pt.y () - c; + if (a == 0) rmd = -rmd; + return (rmd < 0 ? (rmd + 1) / nu - 1 : rmd / nu); +} + + +int DigitalStraightLine::rmd (Pt2i pt) const +{ + return (a * pt.x () + b * pt.y () - c); +} + + int DigitalStraightLine::pgcd (int a, int b) { int r; diff --git a/Code/FBSD/ImageTools/digitalstraightline.h b/Code/FBSD/ImageTools/digitalstraightline.h index fb4114c..fb4da72 100755 --- a/Code/FBSD/ImageTools/digitalstraightline.h +++ b/Code/FBSD/ImageTools/digitalstraightline.h @@ -27,13 +27,13 @@ public: * \brief Creates a digital straightline from its equation parameters. * @param a X value slope parameter of equation : c <= ax + by < c + nu * @param b Y value slope parameter of equation : c <= ax + by < c + nu - * @param c Intercept parameter of equation : c <= ax + by < c + nu + * @param c Shift parameter of equation : c <= ax + by < c + nu * @param nu Width parameter of equation : c <= ax + by < c + nu */ DigitalStraightLine (int a, int b, int c, int nu); /** - * \brief Creates a digital straight line from two leaning points. + * \brief Creates a digital straight line centered on two points. * @param p1 First leaning point. * @param p2 Second leaning point. * @param type Digital line type : DSL_THIN, DSL_NAIVE or DSL_STANDARD. @@ -49,9 +49,9 @@ public: DigitalStraightLine (Pt2i p1, Pt2i p2, Pt2i p3); /** - * \brief Creates a digital straight line from two points and offest. - * It creates a parallel line to the line leaning on given points, - * with an orthogonal shift. + * \brief Creates a digital straight line from two points and side shift. + * It creates a parallel line to the line centered on given points, + * with side shift. * Unknown use, care the side correctness in case of. * @param p1 First point. * @param p2 Second point. @@ -75,7 +75,7 @@ public: * \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 c Shift parameter to provide. * @param nu Width parameter to provide. */ inline void equation (int &a, int &b, int &c, int &nu) const { @@ -85,7 +85,7 @@ public: * \brief Sets given values with the three central naive line parameters. * @param a X Slope parameter to provide. * @param b Y Slope parameter to provide. - * @param c0 Intercept parameter of the central naive line. + * @param c0 Shift parameter of the central naive line. */ inline void getCentralLine (int &a, int &b, int &c0) const { a = this->a; b = this->b; c0 = c + nu / 2; } @@ -179,7 +179,7 @@ public: bool crosses (const Pt2i &p1, const Pt2i &p2) const; /** - * \brief Returns the center of the intersection with an other digital line. + * \brief Returns the center of the intersection with another digital line. * @param l The other digital line. */ const Pt2i centerOfIntersection (DigitalStraightLine *l) const; @@ -187,8 +187,8 @@ public: /** * \brief Returns the center of the intersection with line P1-P2. * Care : returns (0,0) if p1 == p2 or if P1P2 is parallel to the line. - * @param p1 = start point of the crossed line. - * @param p2 = end point of the crossed line. + * @param p1 Start point of the crossed line. + * @param p2 End point of the crossed line. */ const Pt2i centerOfIntersection (Pt2i p1, Pt2i p2) const; @@ -198,6 +198,16 @@ public: const EDist squaredEuclideanThickness () const { return (EDist (nu * nu, a * a + b * b)); } + /** + * \brief Returns the plane paving index of given point. + * Plane paving index is the index of the line containing the point + * when paving the Euclidean plane by the digital straight line. + * @param pt Given point. + */ + int pavingIndex (Pt2i pt) const; + int rmd (Pt2i pt) const; + + protected: @@ -214,7 +224,7 @@ protected: int b; /** - * \brief Intercept parameter in equation : c <= ax + by < c + nu. + * \brief Shift parameter in equation : c <= ax + by < c + nu. */ int c; diff --git a/Code/FBSD/ImageTools/pt2i.h b/Code/FBSD/ImageTools/pt2i.h index 75c7fa9..57ac7ce 100755 --- a/Code/FBSD/ImageTools/pt2i.h +++ b/Code/FBSD/ImageTools/pt2i.h @@ -162,7 +162,8 @@ public: void draw (std::vector<Pt2i> &line, Pt2i p) const; /** - * \brief Returns the points of the straight segment to given point. + * \brief Returns the path of the straight segment to given point. + * The path is composed of relative position between adjacent points. * @param p Given point. * @param n Size of returned array. */ diff --git a/Code/FBSD/ImageTools/vr2i.h b/Code/FBSD/ImageTools/vr2i.h index 690713a..09f675e 100755 --- a/Code/FBSD/ImageTools/vr2i.h +++ b/Code/FBSD/ImageTools/vr2i.h @@ -139,6 +139,7 @@ public: /** * \brief Returns the location of the steps between the vector ends. + * DEPRECATED METHOD: DON'T USE ANY MORE. Use Pt2i::stepsTo (Pt2i) instead. * @param n Size of the returned array. */ bool *steps (int *n) const; diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index a5f31a2..5f311e3 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -59,7 +59,6 @@ Ctrl-p && Commute la d\'etection pr\'eliminaire \\ Ctrl-r && Commute la dilatation du masque d'occupation \\ Ctrl-s && Commute le test final de taille minimale des segments flous \\ Ctrl-v && Commute l'affichage du r\'esultat de la d\'etection en console (verbose) \\ -Ctrl-w && Commute le recentrage du scan sur le segment d\'etect\'e \\ Ctrl-y && Commute le test de densit\'e final \\ $<>$ && D\'ecale horizontalement l'affichage sur une grosse image \\ $\wedge\vee$ && D\'ecale verticalement l'affichage sur une grosse image \\ -- GitLab