contrib/oxl/mvl/TripleMatchSetLineSeg.cxx
Go to the documentation of this file.
00001 // This is oxl/mvl/TripleMatchSetLineSeg.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 
00006 #include "TripleMatchSetLineSeg.h"
00007 
00008 #include <vcl_cassert.h>
00009 
00010 #include <vcl_vector.h>
00011 #include <mvl/HomgLineSeg2D.h>
00012 
00013 #include <mvl/LineSegSet.h>
00014 #include <mvl/PairMatchSetLineSeg.h>
00015 
00016 
00017 TripleMatchSetLineSeg::TripleMatchSetLineSeg():
00018   TripleMatchSet(new PairMatchSetLineSeg, new PairMatchSetLineSeg)
00019 {
00020 }
00021 
00022 TripleMatchSetLineSeg::TripleMatchSetLineSeg(LineSegSet& lines1,
00023                                              LineSegSet& lines2,
00024                                              LineSegSet& lines3):
00025   TripleMatchSet(new PairMatchSetLineSeg(lines1, lines2),
00026                  new PairMatchSetLineSeg(lines2, lines3))
00027 {
00028 }
00029 
00030 TripleMatchSetLineSeg::TripleMatchSetLineSeg(const PairMatchSetLineSeg& match12,
00031                                              const PairMatchSetLineSeg& match23):
00032   TripleMatchSet(new PairMatchSetLineSeg(*match12.get_linesegs1(), *match12.get_linesegs2()),
00033                  new PairMatchSetLineSeg(*match23.get_linesegs1(), *match23.get_linesegs2()))
00034 {
00035   assert(match23.get_linesegs1() == match12.get_linesegs2());
00036   set_from_pairwise_matches(match12, match23);
00037 }
00038 
00039 void TripleMatchSetLineSeg::set(LineSegSet& lines1, LineSegSet& lines2, LineSegSet& lines3)
00040 {
00041   TripleMatchSet::set(new PairMatchSetLineSeg(lines1, lines2), new PairMatchSetLineSeg(lines2, lines3));
00042 }
00043 
00044 void TripleMatchSetLineSeg::extract_matches(vcl_vector<HomgLineSeg2D> &linesegs1, vcl_vector<int> &indices1,
00045                                             vcl_vector<HomgLineSeg2D> &linesegs2, vcl_vector<int> &indices2,
00046                                             vcl_vector<HomgLineSeg2D> &linesegs3, vcl_vector<int> &indices3) const
00047 {
00048   const LineSegSet* linesegs1_ = get_linesegs1();
00049   const LineSegSet* linesegs2_ = get_linesegs2();
00050   const LineSegSet* linesegs3_ = get_linesegs3();
00051 
00052   int n = count();
00053   linesegs1.resize(n);
00054   linesegs2.resize(n);
00055   linesegs3.resize(n);
00056 
00057   indices1.resize(n);
00058   indices2.resize(n);
00059   indices3.resize(n);
00060 
00061   int i = 0;
00062   for (iterator p = begin(); p; ++p, ++i) {
00063     indices1[i] = p.get_i1();
00064     indices2[i] = p.get_i2();
00065     indices3[i] = p.get_i3();
00066     linesegs1[i] = linesegs1_->get_homg(indices1[i]);
00067     linesegs2[i] = linesegs2_->get_homg(indices2[i]);
00068     linesegs3[i] = linesegs3_->get_homg(indices3[i]);
00069   }
00070 }