contrib/gel/gevd/gevd_region_edge.cxx
Go to the documentation of this file.
00001 // This is gel/gevd/gevd_region_edge.cxx
00002 #include "gevd_region_edge.h"
00003 //:
00004 // \file
00005 #include <vtol/vtol_edge_2d.h>
00006 
00007 gevd_region_edge::gevd_region_edge(vtol_edge_2d_sptr e)
00008 : edge_(e)
00009 {
00010 }
00011 
00012 gevd_region_edge::~gevd_region_edge()
00013 {
00014 }
00015 
00016 bool gevd_region_edge::is_vertex() const
00017 {
00018   return !edge_; // returns true if edge_ is a null (smart) pointer
00019 }
00020 
00021 bool gevd_region_edge::SetNewLabel(unsigned int label)
00022 {
00023   if (label == 0) return false;
00024   labels_.push_back(label);
00025   return true;
00026 }
00027 
00028 //--------------------------------------------------------
00029 //: Conditionally propagate the labels of a gevd_region_edge.
00030 //  In this approach we don't differentiate between Right
00031 //  and Left.  Here we allow an unlimited number of labels
00032 //  to be assigned to an edge, which is necessary due to
00033 //  small regions which don't have proper closure but
00034 //  whose edges are on the boundary of larger legitimate
00035 //  regions.
00036 void gevd_region_edge::Prop(gevd_region_edge const* re, unsigned int label)
00037 {
00038   //First try to propagate the labels
00039   //Do not allow propagation to occur
00040   //between different edges
00041   vtol_edge_2d_sptr source = re->get_edge();
00042   vtol_edge_2d_sptr target = this->get_edge();
00043   if (source&&target&&*source==*target)
00044     for (unsigned int i = 0; i<re->NumLabels(); ++i)
00045       this->SetNewLabel(re->GetLabel(i));
00046   this->SetNewLabel(label);
00047 }
00048