Structural deformable models
Public Member Functions | Public Attributes | Protected Attributes | List of all members
StructPath Class Reference

#include <StructTable.h>

Inheritance diagram for StructPath:
Inheritance graph
[legend]
Collaboration diagram for StructPath:
Collaboration graph
[legend]

Public Member Functions

 StructPath ()
 
 StructPath (const StructPath &rhs)
 
 ~StructPath ()
 
StructPathoperator= (const StructPath &rhs)
 
void clear ()
 
WinnergetWinner (MStructure &struc)
 
const WinnergetWinner (const MStructure &struc) const
 
float getGoodness () const
 
void protectWinners (StructTable &structs)
 
void unprotectWinners (StructTable &structs)
 
void blockOtherPaths (const std::set< std::string > &freepath, const StructTable &structs)
 
std::ostream & print (std::ostream &os, const StructTable &structs) const
 
float getRelGoodness () const
 
StructPath branch () const
 
void merge (const StructPath &mp)
 

Public Attributes

float m_Goodness
 goodness of path More...
 
float m_Maxness
 maximum goodness More...
 

Protected Attributes

bool m_WinnersProtected
 

Detailed Description

Definition at line 21 of file StructTable.h.

Constructor & Destructor Documentation

StructPath::StructPath ( )

Definition at line 523 of file StructTable.cpp.

523  : m_Goodness(0.f), m_Maxness(0.f),
524  m_WinnersProtected(false)
525 {}
float m_Goodness
goodness of path
Definition: StructTable.h:42
bool m_WinnersProtected
Definition: StructTable.h:45
float m_Maxness
maximum goodness
Definition: StructTable.h:43
StructPath::StructPath ( const StructPath rhs)

Definition at line 527 of file StructTable.cpp.

References operator=().

528 {
529  operator=(rhs);
530 }
StructPath & operator=(const StructPath &rhs)
StructPath::~StructPath ( )

Definition at line 532 of file StructTable.cpp.

533 {
534  //unprotectWinners();
535 }

Member Function Documentation

void StructPath::blockOtherPaths ( const std::set< std::string > &  freepath,
const StructTable structs 
)

Definition at line 611 of file StructTable.cpp.

References StructTable::getStructs(), m_WinnersProtected, and Winner::WID_BLOCKED.

Referenced by StructTable::findBestConnection(), and getGoodness().

613 {
614  for(map<string,MStructure>::const_iterator
615  st = structs.getStructs().begin();
616  st != structs.getStructs().end(); st++)
617  {
618  if(freepath.find(st->second.getName()) == freepath.end())
619  operator[](st->second.getName()) = Winner::WID_BLOCKED;
620  }
621  m_WinnersProtected = false;
622 }
std::map< std::string, MStructure > & getStructs()
Definition: StructTable.h:71
bool m_WinnersProtected
Definition: StructTable.h:45
StructPath StructPath::branch ( ) const

Definition at line 664 of file StructTable.cpp.

References m_Goodness, m_Maxness, Winner::WID_BLOCKED, and Winner::WID_EMPTY.

Referenced by StructTable::findBestConnection(), and getRelGoodness().

665 {
666  StructPath bp(*this);
667  for(iterator wi = bp.begin(); wi != bp.end(); wi++)
668  if(wi->second != Winner::WID_EMPTY) wi->second = Winner::WID_BLOCKED;
669  bp.m_Goodness = 0.f; bp.m_Maxness = 0.f;
670  return bp;
671 }
void StructPath::clear ( )

Definition at line 548 of file StructTable.cpp.

References m_Goodness, m_Maxness, and m_WinnersProtected.

549 {
550  map<string,dword>::clear();
551  m_Goodness = 0.0f;
552  m_Maxness = 0.f;
553  m_WinnersProtected = false;
554 }
float m_Goodness
goodness of path
Definition: StructTable.h:42
bool m_WinnersProtected
Definition: StructTable.h:45
float m_Maxness
maximum goodness
Definition: StructTable.h:43
float StructPath::getGoodness ( ) const
inline

Definition at line 31 of file StructTable.h.

References blockOtherPaths(), m_Goodness, print(), protectWinners(), and unprotectWinners().

31 { return m_Goodness; }
float m_Goodness
goodness of path
Definition: StructTable.h:42
float StructPath::getRelGoodness ( ) const
inline

Definition at line 37 of file StructTable.h.

References branch(), m_Goodness, m_Maxness, and merge().

Referenced by StructTable::findBestConnection(), and print().

38  { return m_Maxness != 0.f ? m_Goodness/m_Maxness : 0.f; }
float m_Goodness
goodness of path
Definition: StructTable.h:42
float m_Maxness
maximum goodness
Definition: StructTable.h:43
Winner * StructPath::getWinner ( MStructure struc)

Definition at line 556 of file StructTable.cpp.

References MStructure::getName(), MStructure::getWinner(), and NULL.

557 {
558  iterator wi = find(struc.getName());
559  if(wi != end() && wi->second) {
560  Winner* winner = (Winner*)struc.getWinner(wi->second);
561  if(!winner) wi->second = 0;
562  return winner;
563  } else return NULL;
564 }
#define NULL
Definition: simpletypes.h:9
const Winner * getWinner(dword wid) const
Definition: MStruct.cpp:80
Definition: ExpMap.h:10
const std::string & getName() const
Definition: MStruct.h:63
const Winner * StructPath::getWinner ( const MStructure struc) const

Definition at line 566 of file StructTable.cpp.

References MStructure::getName(), MStructure::getWinner(), and NULL.

567 {
568  const_iterator wi = find(struc.getName());
569  if(wi != end() && wi->second)
570  {
571  const Winner* winner = struc.getWinner(wi->second);
572  if(!winner) (dword&)(wi->second) = 0;
573  return winner;
574  } else return NULL;
575 }
#define NULL
Definition: simpletypes.h:9
const Winner * getWinner(dword wid) const
Definition: MStruct.cpp:80
Definition: ExpMap.h:10
unsigned long dword
Definition: simpletypes.h:6
const std::string & getName() const
Definition: MStruct.h:63
void StructPath::merge ( const StructPath mp)

Definition at line 673 of file StructTable.cpp.

References m_Goodness, m_Maxness, Winner::WID_BLOCKED, and Winner::WID_EMPTY.

Referenced by StructTable::findBestConnection(), and getRelGoodness().

674 {
675  for(const_iterator wi = mp.begin(); wi != mp.end(); wi++)
676  if(wi->second != Winner::WID_EMPTY &&
677  wi->second != Winner::WID_BLOCKED)
678  operator[](wi->first) = wi->second;
680 }
float m_Goodness
goodness of path
Definition: StructTable.h:42
float m_Maxness
maximum goodness
Definition: StructTable.h:43
StructPath & StructPath::operator= ( const StructPath rhs)

Definition at line 537 of file StructTable.cpp.

References m_Goodness, m_Maxness, and m_WinnersProtected.

Referenced by StructPath().

538 {
539  if(this != &rhs) {
540  map<string,dword>::operator=(rhs);
541  m_Goodness = rhs.m_Goodness;
543  m_Maxness = rhs.m_Maxness;
544  }
545  return *this;
546 }
float m_Goodness
goodness of path
Definition: StructTable.h:42
bool m_WinnersProtected
Definition: StructTable.h:45
float m_Maxness
maximum goodness
Definition: StructTable.h:43
ostream & StructPath::print ( std::ostream &  os,
const StructTable structs 
) const

Definition at line 624 of file StructTable.cpp.

References Winner::getConnection(), Model::getQualityOfFit(), getRelGoodness(), StructTable::getStructure(), MStructure::getSupStruct(), MStructure::getWeight(), MStructure::getWinner(), MStructure::hasSupStruct(), Winner::m_BestRating, m_Goodness, Winner::m_Model, SubStructure::m_RateWeight, Winner::WID_BLOCKED, and Winner::WID_EMPTY.

Referenced by getGoodness().

625 {
626  os << setw(10);
627  os << "path goodness: " << m_Goodness << " ("
628  << getRelGoodness() << ")" << endl;
629  for(const_iterator wi = begin(); wi != end(); wi++)
630  {
631  if(wi->second != Winner::WID_EMPTY &&
632  wi->second != Winner::WID_BLOCKED)
633  {
634  os << " " << wi->first;
635  const MStructure& st = structs.getStructure(wi->first);
636  const Winner* winner = st.getWinner(wi->second);
637  if(winner) {
638  if(winner->m_Model)
639  os << "\t ("<< st.getWeight() <<") * "
640  << winner->m_Model->getQualityOfFit() << endl;
641  else os << "\t (no model)"<<endl;
642  for(const_iterator ri = begin(); ri != end(); ri++)
643  {
644  float rating = winner->getConnection(ri->first,
645  ri->second);
646  if(rating>=0.f) {
647  if(st.hasSupStruct(ri->first)) {
648  const SubStructure& subs =
649  st.getSupStruct(ri->first);
650  os << " <--[" << ri->first
651  << "\t] = ("<<subs.m_RateWeight<<") * "
652  << rating << endl;
653  }
654  }
655  }
656  os << " (best: " << winner->m_BestRating << ")" << endl;
657  } else os << " (deleted)"<< endl;
658  }
659  }
660  os << setw(0) << flush;
661  return os;
662 }
float getQualityOfFit() const
Definition: Model.cpp:1204
const Winner * getWinner(dword wid) const
Definition: MStruct.cpp:80
float m_Goodness
goodness of path
Definition: StructTable.h:42
float getRelGoodness() const
Definition: StructTable.h:37
float m_RateWeight
Definition: MStruct.h:47
Model * m_Model
Definition: ExpMap.h:36
float m_BestRating
Definition: ExpMap.h:39
float getWeight() const
Definition: MStruct.h:70
float getConnection(const std::string &sname, dword wid) const
Definition: ExpMap.cpp:313
Definition: ExpMap.h:10
const MStructure & getStructure(const std::string &sname) const
bool hasSupStruct(const std::string sname) const
Definition: MStruct.h:85
const SubStructure & getSupStruct(const std::string sname) const
Definition: MStruct.h:83
void StructPath::protectWinners ( StructTable structs)

Definition at line 577 of file StructTable.cpp.

References StructTable::getStructs(), Winner::m_Model, m_WinnersProtected, Model::setFlags(), Model::ST_NODEL, Winner::WID_FIRST, and Winner::WID_LAST.

Referenced by getGoodness().

578 {
579  if(m_WinnersProtected) return;
580  for(iterator wi = begin(); wi != end(); wi++)
581  {
582  if(wi->second>=Winner::WID_FIRST &&
583  wi->second<=Winner::WID_LAST) {
584  Winner* winner = (Winner*)structs.getStructs()[wi->first]
585  .getWinner(wi->second);
586  if(winner && winner->m_Model) {
587  winner->m_Model->setFlags(Model::ST_NODEL);
588  } else wi->second = 0;
589  }
590  }
591  m_WinnersProtected = true;
592 }
std::map< std::string, MStructure > & getStructs()
Definition: StructTable.h:71
bool m_WinnersProtected
Definition: StructTable.h:45
Model * m_Model
Definition: ExpMap.h:36
Definition: ExpMap.h:10
dword & setFlags(dword flags)
Definition: Model.h:198
void StructPath::unprotectWinners ( StructTable structs)

Definition at line 594 of file StructTable.cpp.

References StructTable::getStructs(), Winner::m_Model, m_WinnersProtected, Model::ST_NODEL, Model::unsetFlags(), Winner::WID_FIRST, and Winner::WID_LAST.

Referenced by getGoodness().

595 {
596  if(!m_WinnersProtected) return;
597  for(iterator wi = begin(); wi != end(); wi++)
598  {
599  if(wi->second>=Winner::WID_FIRST &&
600  wi->second<=Winner::WID_LAST) {
601  Winner* winner = (Winner*)structs.getStructs()[wi->first]
602  .getWinner(wi->second);
603  if(winner && winner->m_Model) {
605  } else wi->second = 0;
606  }
607  }
608  m_WinnersProtected = false;
609 }
std::map< std::string, MStructure > & getStructs()
Definition: StructTable.h:71
bool m_WinnersProtected
Definition: StructTable.h:45
Model * m_Model
Definition: ExpMap.h:36
dword & unsetFlags(dword flags)
Definition: Model.h:199
Definition: ExpMap.h:10

Member Data Documentation

float StructPath::m_Goodness

goodness of path

Definition at line 42 of file StructTable.h.

Referenced by branch(), clear(), StructTable::findBestConnection(), getGoodness(), getRelGoodness(), merge(), operator=(), and print().

float StructPath::m_Maxness

maximum goodness

Definition at line 43 of file StructTable.h.

Referenced by branch(), clear(), StructTable::findBestConnection(), getRelGoodness(), merge(), and operator=().

bool StructPath::m_WinnersProtected
protected

Definition at line 45 of file StructTable.h.

Referenced by blockOtherPaths(), clear(), operator=(), protectWinners(), and unprotectWinners().


The documentation for this class was generated from the following files: