openModeller  Version 1.4.0
Occurrence.cpp
Go to the documentation of this file.
00001 
00028 #include <openmodeller/Log.hh>
00029 
00030 #include <openmodeller/Occurrence.hh>
00031 
00032 #include <string.h>
00033 
00034 /****************************************************************/
00035 /************************** Occurrence **************************/
00036 
00037 /******************/
00038 /*** destructor ***/
00039 
00040 OccurrenceImpl::~OccurrenceImpl()
00041 {
00042 }
00043 
00044 OccurrenceImpl&
00045 OccurrenceImpl::operator=( const OccurrenceImpl & rhs )
00046 {
00047   if ( this == &rhs ) {
00048 
00049     return *this;
00050   }
00051 
00052   x_ = rhs.x_;
00053   y_ = rhs.y_;
00054   error_ = rhs.error_;
00055   abundance_ = rhs.abundance_;
00056 
00057   attr_ = rhs.attr_;
00058   unnormEnv_ = rhs.unnormEnv_;
00059   normEnv_ = rhs.normEnv_;
00060 
00061   return *this;
00062 }
00063 
00064 Sample const & OccurrenceImpl::environment() const
00065 {
00066   if ( normEnv_.size() != 0 ) {
00067 
00068     return normEnv_;
00069   }
00070   else {
00071 
00072     return unnormEnv_;
00073   }
00074 }
00075 
00076 Sample const & OccurrenceImpl::originalEnvironment() const
00077 {
00078   return unnormEnv_;
00079 }
00080 
00081 void
00082 OccurrenceImpl::normalize( Normalizer * normalizerPtr, size_t categoricalThreshold )
00083 {
00084   unnormEnv_.setCategoricalThreshold( categoricalThreshold );
00085 
00086   normEnv_ = unnormEnv_;
00087 
00088   if ( normalizerPtr ) {
00089 
00090     normalizerPtr->normalize( &normEnv_ );
00091   }
00092 }
00093 
00094 void
00095 OccurrenceImpl::setNormalizedEnvironment( const Sample& s )
00096 {
00097   normEnv_ = s;
00098 }
00099 
00100 void
00101 OccurrenceImpl::setUnnormalizedEnvironment( const Sample& s )
00102 {
00103   unnormEnv_ = s;
00104 }
00105 
00106 bool
00107 OccurrenceImpl::hasEnvironment() const
00108 {
00109   return unnormEnv_.size() != 0;
00110 }
00111 
00112 void
00113 OccurrenceImpl::setId( const std::string& id )
00114 {
00115   id_ = id;
00116 }
00117 
00118 void
00119 OccurrenceImpl::setAbundance( Scalar value )
00120 {
00121   abundance_ = value;
00122 }
00123 
00124 void
00125 OccurrenceImpl::dump() const
00126 {
00127   Log::instance()->info( "Occurrence %s\n", id_.c_str() );
00128   Log::instance()->info( "Unnormalized environment:\n" );
00129   unnormEnv_.dump();
00130   Log::instance()->info( "Normalized environment:\n" );
00131   normEnv_.dump();
00132 }