00001
00002
00003
00004
00005
00006
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030 #ifndef PREDICATES1D_H
00031 # define PREDICATES1D_H
00032
00033 # include <string>
00034 # include "../system/TimeStamp.h"
00035 # include "../view_map/Interface1D.h"
00036 # include "../view_map/Functions1D.h"
00037 # include "AdvancedFunctions1D.h"
00038
00039
00040
00041
00043
00052 class UnaryPredicate1D
00053 {
00054 public:
00056 UnaryPredicate1D() {}
00058 virtual ~UnaryPredicate1D() {}
00062 virtual string getName() const {
00063 return "UnaryPredicate1D";
00064 }
00073 virtual bool operator()(Interface1D& inter) {
00074 cerr << "Warning: operator() not implemented" << endl;
00075 return false;
00076 }
00077 };
00078
00079
00080
00081
00082
00084
00091 class BinaryPredicate1D
00092 {
00093 public:
00095 BinaryPredicate1D() {}
00097 virtual ~BinaryPredicate1D() {}
00101 virtual string getName() const {
00102 return "BinaryPredicate1D";
00103 }
00112 virtual bool operator()(Interface1D& inter1, Interface1D& inter2) {
00113 cerr << "Warning: operator() not implemented" << endl;
00114 return false;
00115 }
00116 };
00117
00118
00119
00120
00121
00123
00124 namespace Predicates1D {
00125
00126
00128 class TrueUP1D : public UnaryPredicate1D
00129 {
00130 public:
00132 TrueUP1D() {}
00134 string getName() const {
00135 return "TrueUP1D";
00136 }
00138 bool operator()(Interface1D&) {
00139 return true;
00140 }
00141 };
00142
00143
00145 class FalseUP1D : public UnaryPredicate1D
00146 {
00147 public:
00149 FalseUP1D() {}
00151 string getName() const {
00152 return "FalseUP1D";
00153 }
00155 bool operator()(Interface1D&) {
00156 return false;
00157 }
00158 };
00159
00160
00165 class QuantitativeInvisibilityUP1D : public UnaryPredicate1D
00166 {
00167 public:
00173 QuantitativeInvisibilityUP1D(unsigned qi = 0) : _qi(qi) {}
00175 string getName() const {
00176 return "QuantitativeInvisibilityUP1D";
00177 }
00179 bool operator()(Interface1D& inter) {
00180 Functions1D::QuantitativeInvisibilityF1D func;
00181 return (func(inter) == _qi);
00182 }
00183 private:
00184 unsigned _qi;
00185 };
00186
00187
00192 class ContourUP1D : public UnaryPredicate1D
00193 {
00194 private:
00195 Functions1D::CurveNatureF1D _getNature;
00196 public:
00198 string getName() const {
00199 return "ContourUP1D";
00200 }
00202 bool operator()(Interface1D& inter) {
00203 if((_getNature(inter) & Nature::SILHOUETTE) || (_getNature(inter) & Nature::BORDER)){
00204 Interface0DIterator it=inter.verticesBegin();
00205 for(; !it.isEnd(); ++it){
00206 if(Functions0D::getOccludeeF0D(it) != Functions0D::getShapeF0D(it))
00207 return true;
00208 }
00209 }
00210 return false;
00211 }
00212 };
00213
00214
00219 class ExternalContourUP1D : public UnaryPredicate1D
00220 {
00221 private:
00222 Functions1D::CurveNatureF1D _getNature;
00223 public:
00225 string getName() const {
00226 return "ExternalContourUP1D";
00227 }
00229 bool operator()(Interface1D& inter) {
00230 if((_getNature(inter) & Nature::SILHOUETTE) || (_getNature(inter) & Nature::BORDER)){
00231 set<ViewShape*> occluded;
00232 Functions1D::getOccludeeF1D(inter, occluded);
00233 for(set<ViewShape*>::iterator os=occluded.begin(), osend=occluded.end();
00234 os!=osend;
00235 ++os){
00236 if((*os) == 0)
00237 return true;
00238 }
00239 }
00240 return false;
00241 }
00242 };
00243
00244
00248 class EqualToTimeStampUP1D : public UnaryPredicate1D
00249 {
00250 protected:
00251 unsigned _timeStamp;
00252 public:
00253 EqualToTimeStampUP1D(unsigned ts) : UnaryPredicate1D(){
00254 _timeStamp = ts;
00255 }
00257 string getName() const {
00258 return "EqualToTimeStampUP1D";
00259 }
00261 bool operator()(Interface1D& inter) {
00262 return (inter.getTimeStamp() == _timeStamp);
00263 }
00264 };
00265
00266
00270 class EqualToChainingTimeStampUP1D : public UnaryPredicate1D
00271 {
00272 protected:
00273 unsigned _timeStamp;
00274 public:
00275 EqualToChainingTimeStampUP1D(unsigned ts) : UnaryPredicate1D(){
00276 _timeStamp = ts;
00277 }
00279 string getName() const {
00280 return "EqualToChainingTimeStampUP1D";
00281 }
00283 bool operator()(Interface1D& inter) {
00284 ViewEdge* edge = dynamic_cast<ViewEdge*>(&inter);
00285 if (!edge)
00286 return false;
00287 return (edge->getChainingTimeStamp() >= _timeStamp);
00288 }
00289 };
00290
00291
00296 class ShapeUP1D: public UnaryPredicate1D
00297 {
00298 private:
00299 Id _id;
00300 public:
00307 ShapeUP1D(unsigned idFirst, unsigned idSecond=0)
00308 : UnaryPredicate1D(){
00309 _id = Id(idFirst, idSecond);
00310 }
00312 string getName() const {
00313 return "ShapeUP1D";
00314 }
00316 bool operator()(Interface1D& inter) {
00317 set<ViewShape*> shapes;
00318 Functions1D::getShapeF1D(inter, shapes);
00319 for(set<ViewShape*>::iterator s=shapes.begin(), send=shapes.end();
00320 s!=send;
00321 ++s){
00322 if((*s)->getId() == _id)
00323 return true;
00324 }
00325 return false;
00326 }
00327 };
00328
00329
00330
00331
00333
00334
00336 class TrueBP1D : public BinaryPredicate1D
00337 {
00338 public:
00340 string getName() const {
00341 return "TrueBP1D";
00342 }
00344 bool operator()(Interface1D& i1, Interface1D& i2) {
00345 return true;
00346 }
00347 };
00348
00349
00351 class FalseBP1D : public BinaryPredicate1D
00352 {
00353 public:
00355 string getName() const {
00356 return "FalseBP1D";
00357 }
00359 bool operator()(Interface1D& i1, Interface1D& i2) {
00360 return false;
00361 }
00362 };
00363
00364
00368 class Length2DBP1D : public BinaryPredicate1D
00369 {
00370 public:
00372 string getName() const {
00373 return "Length2DBP1D";
00374 }
00376 bool operator()(Interface1D& i1, Interface1D& i2) {
00377 return (i1.getLength2D() > i2.getLength2D());
00378 }
00379 };
00380
00381
00385 class SameShapeIdBP1D : public BinaryPredicate1D
00386 {
00387 public:
00389 string getName() const {
00390 return "SameShapeIdBP1D";
00391 }
00393 bool operator()(Interface1D& i1, Interface1D& i2) {
00394 set<ViewShape*> shapes1;
00395 Functions1D::getShapeF1D(i1, shapes1);
00396 set<ViewShape*> shapes2;
00397 Functions1D::getShapeF1D(i2, shapes2);
00398
00399 for(set<ViewShape*>::iterator s=shapes1.begin(), send=shapes1.end();
00400 s!=send;
00401 ++s){
00402 Id current = (*s)->getId();
00403 for(set<ViewShape*>::iterator s2=shapes2.begin(), s2end=shapes2.end();
00404 s2!=s2end;
00405 ++s2){
00406 if((*s2)->getId() == current)
00407 return true;
00408 }
00409 }
00410 return false;
00411 }
00412 };
00413
00414
00419 class ViewMapGradientNormBP1D : public BinaryPredicate1D
00420 {
00421 private:
00422 Functions1D::GetViewMapGradientNormF1D _func;
00423 public:
00424 ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0)
00425 : BinaryPredicate1D(), _func(level, iType, sampling) {
00426 }
00428 string getName() const {
00429 return "ViewMapGradientNormBP1D";
00430 }
00432 bool operator()(Interface1D& i1, Interface1D& i2) {
00433 return (_func(i1) > _func(i2));
00434 }
00435 };
00436 }
00437
00438 #endif // PREDICATES1D_H