summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/eraser.cc
diff options
context:
space:
mode:
authorgaillaro2005-05-06 14:43:00 +0000
committergaillaro2005-05-06 14:43:00 +0000
commit9aab8a34ad597c2b46cdde3d7cdc1e44c66c9596 (patch)
tree33dcd7b5fddb67380ad517bccfe76a9cd54b1f4a /2005/i/robert/src/ovision/see/eraser.cc
parent1d6fa32f84b92e6dab641beb918cbb809ce1265b (diff)
modifs avant match vendredi
Diffstat (limited to '2005/i/robert/src/ovision/see/eraser.cc')
-rw-r--r--2005/i/robert/src/ovision/see/eraser.cc108
1 files changed, 98 insertions, 10 deletions
diff --git a/2005/i/robert/src/ovision/see/eraser.cc b/2005/i/robert/src/ovision/see/eraser.cc
index a2393ed..9ca2dc3 100644
--- a/2005/i/robert/src/ovision/see/eraser.cc
+++ b/2005/i/robert/src/ovision/see/eraser.cc
@@ -5,15 +5,16 @@
/// @file eraser.cc Filtre les objets par leurs tailles
#include <iostream>
+#include <fstream>
#include "eraser.hh"
+#include "group.hh"
/// Constructeur
-Eraser::Eraser (const std::string &filename, const int resolution)
- : res_ (resolution)
+Eraser::Eraser (const int maxHeight, const int resolution)
+ : res_ (resolution), maxHeight_ (maxHeight)
{
oconfig_ = OConfig::getInstance ();
- init ();
}
/// Destructeur
@@ -22,31 +23,118 @@ Eraser::~Eraser (void)
}
/// Ouvre le fichier de données
-Eraser::init (std::string &filename)
+void
+Eraser::init (const std::string &filename)
{
// Ouverture du fichier de distance
- std::ifstream file (filename);
- if (!file) {
- throw "<Eraser::init> Error during file opening";
+ std::ifstream file (filename.c_str ());
+ if (!file)
+ {
+ throw "<Eraser::init> Error during file opening\n";
return;
}
+ // Enlève les commentaires
+ char trash[50];
+ file.getline (trash, 50);
+ char c;
+ int y, min, max;
+ while (!file.eof ())
+ {
+ file >> c >> y >> min >> max;
+ add (c, y, min, max);
+ }
// Parcours des lignes et analyse
+ file.close ();
+ // Remplissage du reste
+ add ('V', maxHeight_, tabVMin_[tabVMax_.size () - 1], tabVMax_[tabVMax_.size () -1]);
+ add ('O', maxHeight_, min, max);
+}
+
+/// Remplissage de la table
+void
+Eraser::add (const char c, const int y, const int min, const int max)
+{
+ static int lastO = 0;
+ static int lastV = 0;
+ if (c == 'V')
+ {
+ for (int i = lastV; i <= y/res_; ++i)
+ {
+ tabVMin_.push_back (min);
+ tabVMax_.push_back (max);
+ }
+ lastV = y/res_;
+ }
+ else if (c == 'O')
+ {
+ for (int i = lastO; i <= y/res_; ++i)
+ {
+ tabOMin_.push_back (min);
+ tabOMax_.push_back (max);
+ std::cout << i << " " << min << " " << max << "\n";
+ }
+ lastO = (y+res_)/res_;
+ }
+ else
+ {
+ throw "<Eraser::init> Bad syntax in file\n";
+ return;
+ }
}
/// Objet à la bonne taille ?
bool
Eraser::killOrNot (const Zone &zone)
{
- int y = zone.ymax % res_;
+ int y = zone.ymax / res_;
+ if (zone.vertical)
+ {
+ if ((zone.area > tabVMin_[y]) || (zone.area < tabVMax_[y]))
+ return true;
+ }
+ else
+ {
+ if ((zone.area > tabOMin_[y]) || (zone.area < tabOMax_[y]))
+ return true;
+ }
+ return false;
+}
+
+
+/// Zone trop petite
+bool
+Eraser::isTooSmall (const Zone &zone)
+{
+ int y = zone.ymax / res_;
+ if (zone.vertical)
+ {
+ if (zone.area < tabVMin_[y])
+ return true;
+ }
+ else
+ {
+ if (zone.area < tabOMin_[y])
+ return true;
+ }
+ return false;
+}
+
+/// Zone trop grande
+bool
+Eraser::isTooBig (const Zone &zone)
+{
+ int y = zone.ymax / res_;
if (zone.vertical)
{
- if ((zone.area > tabVMin[y]) || (zone.area < tabVMax[y]))
+ if (zone.area > tabVMax_[y])
return true;
}
else
{
- if ((zone.area > tabOMin[y]) || (zone.area < tabOMax[y]))
+ if (zone.area > tabOMax_[y])
+ {
return true;
+ }
}
return false;
}