Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __FEATURE_H_30112004_1121__
00011 #define __FEATURE_H_30112004_1121__
00012
00013 #include <vector>
00014 #include <Geometry/point.h>
00015
00016 namespace RDFeatures {
00017 template <typename FAMILYMARKER, typename TYPEMARKER=FAMILYMARKER, typename LOCTYPE=RDGeom::Point3D>
00018 class ExplicitFeature {
00019 public:
00020 ExplicitFeature() {};
00021 explicit ExplicitFeature(const FAMILYMARKER &f,const TYPEMARKER &t) :
00022 d_family(f), d_type(t) {};
00023 ExplicitFeature(const FAMILYMARKER &f,const TYPEMARKER &t,const LOCTYPE &loc) :
00024 d_family(f), d_type(t), d_loc(loc){};
00025
00026 const FAMILYMARKER &getFamily() const { return d_family; };
00027 void setFamily(const FAMILYMARKER &f) { d_family=f; };
00028
00029 const TYPEMARKER &getType() const { return d_type; };
00030 void setType(const TYPEMARKER &t) { d_type=t; };
00031
00032 const LOCTYPE &getLoc() const { return d_loc; };
00033 void setLoc(const LOCTYPE &loc) { d_loc=loc; };
00034
00035 const std::vector<LOCTYPE> &getDirs() const { return d_dirs; };
00036 std::vector<LOCTYPE> &getDirs() { return d_dirs; };
00037
00038 private:
00039 FAMILYMARKER d_family;
00040 TYPEMARKER d_type;
00041 LOCTYPE d_loc;
00042 std::vector<LOCTYPE> d_dirs;
00043 };
00044
00045
00046 template <typename FAMILYMARKER, typename TYPEMARKER=FAMILYMARKER, typename LOCTYPE=RDGeom::Point3D>
00047 class ImplicitFeature {
00048 public:
00049 ImplicitFeature() : d_weightSum(0.0) {};
00050 explicit ImplicitFeature(const FAMILYMARKER &f,const TYPEMARKER &t) :
00051 d_weightSum(0.0), d_family(f), d_type(t) {};
00052
00053 const FAMILYMARKER &getFamily() const { return d_family; };
00054 void setFamily(const FAMILYMARKER &f) { d_family=f; };
00055
00056 const TYPEMARKER &getType() const { return d_type; };
00057 void setType(const TYPEMARKER &t) { d_type=t; };
00058
00059 LOCTYPE getLoc() const {
00060 PRECONDITION(d_weights.size()==d_locs.size(),"weight/locs mismatch");
00061 LOCTYPE accum;
00062 for(unsigned int i=0;i<d_weights.size();i++){
00063 LOCTYPE tmp=*d_locs[i];
00064 tmp *= d_weights[i]/d_weightSum;
00065 accum += tmp;
00066 }
00067 return accum;
00068 };
00069 void addPoint(const LOCTYPE *p,double weight=1.0){
00070 d_locs.push_back(p);
00071 d_weights.push_back(weight);
00072 d_weightSum += weight;
00073 }
00074 void reset() {
00075 d_locs.clear();
00076 d_weights.clear();
00077 d_weightSum=0.0;
00078 }
00079
00080 const std::vector<LOCTYPE> &getDirs() const { return d_dirs; };
00081 std::vector<LOCTYPE> &getDirs() { return d_dirs; };
00082
00083
00084 private:
00085 double d_weightSum;
00086 FAMILYMARKER d_family;
00087 TYPEMARKER d_type;
00088 std::vector<double> d_weights;
00089 std::vector<const LOCTYPE *> d_locs;
00090
00091 std::vector<LOCTYPE> d_dirs;
00092 };
00093 }
00094 #endif