// Surface.cpp #include "Surface.h" #include "CrossStat.h" #include "TrackVector.h" using std::ostream; using trf::TrfObject; using trf::CrossStat; using trf::Surface; //********************************************************************** // Free functions. //********************************************************************** namespace { // Surface creator. ObjPtr create(const ObjData& data) { return ObjPtr(0); } } //********************************************************************** // Methods not to be overridden. //********************************************************************** // constructor Surface::Surface() { } //********************************************************************** // destructor Surface::~Surface() { } //********************************************************************** // Check if two surfaces are exactly the same including boundaries. bool Surface::bound_equal(const Surface& srf) const { if ( this->get_type() == srf.get_type() ) return safe_bound_equal(srf); return false; } //********************************************************************** // Check if two surfaces have the same pure surface. bool Surface::pure_equal(const Surface& srf) const { if ( this->get_pure_type() == srf.get_pure_type() ) return safe_pure_equal(srf); return false; } //********************************************************************** // Check if two surfaces are in order. bool Surface::pure_less_than(const Surface& srf) const { if ( this->get_pure_type() == srf.get_pure_type() ) return safe_pure_less_than(srf); return this->get_pure_type() < srf.get_pure_type(); } //********************************************************************** // Methods which may need to be overridden in pure surfaces. //********************************************************************** // Return q/p. double Surface::qoverp(const TrackVector& vec) const { return vec(4); } //********************************************************************** // Return the default direction. TrackSurfaceDirection Surface::get_direction(const TrackVector& vec) const { return TSD_UNDEFINED; } //********************************************************************** // Methods to be overridden in bound surfaces. //********************************************************************** // Return the creator. ObjCreator Surface::get_creator() { return create; } //********************************************************************** // Default for safe_bound_equal is to call safe_pure_equal. bool Surface::safe_bound_equal(const Surface& srf) const { assert( is_pure() ); return safe_pure_equal(srf); } //********************************************************************** // Return the full type. // Must be overridden in subclasses. TrfObject::Type Surface::get_type() const { return get_pure_type(); } //********************************************************************** // Return the generic type. TrfObject::Type Surface::get_generic_type() const { return get_static_type(); } //********************************************************************** // Default for new surface is new pure surface. Surface* Surface::new_surface() const { assert( is_pure() ); return new_pure_surface(); } //********************************************************************** // Default for status is pure status. CrossStat Surface::status(const VTrack& trv) const { assert( is_pure() ); return pure_status(trv); } //********************************************************************** // Default for status is pure status. CrossStat Surface::status(const ETrack& trv) const { assert( is_pure() ); return pure_status( (VTrack&) trv ); } //********************************************************************** // Free functions. //********************************************************************** // Output stream operator. ostream& trf::operator<<(ostream& stream, const Surface& srf) { srf.ostr( stream ); return stream; } //********************************************************************** // Equality operator. bool operator==( const Surface& srf1, const Surface& srf2 ) { return srf1.bound_equal(srf2); } //********************************************************************** // Inequality operator. // bool operator!=( const Surface& srf1, const Surface& srf2 ) { return ( ! ( srf1 == srf2 ) ); } //**********************************************************************