CMS 3D CMS Logo

Public Member Functions | Public Attributes

DDCompareCPV Struct Reference

#include <DDCompareTools.h>

Inheritance diagram for DDCompareCPV:
binary_function

List of all members.

Public Member Functions

 DDCompareCPV ()
 DDCompareCPV (const DDCompOptions &ddco)
bool operator() (const DDCompactView &lhs, const DDCompactView &rhs) const

Public Attributes

DDCompOptions ddco_

Detailed Description

Definition at line 34 of file DDCompareTools.h.


Constructor & Destructor Documentation

DDCompareCPV::DDCompareCPV ( )

Definition at line 104 of file DDCompareTools.cc.

: ddco_() { }
DDCompareCPV::DDCompareCPV ( const DDCompOptions ddco)

Definition at line 106 of file DDCompareTools.cc.

: ddco_(ddco) { }

Member Function Documentation

bool DDCompareCPV::operator() ( const DDCompactView lhs,
const DDCompactView rhs 
) const

Definition at line 108 of file DDCompareTools.cc.

References graph< N, E >::begin(), DDPosData::copyno_, gather_cfg::cout, ddco_, graph< N, E >::edgeData(), graph< N, E >::end(), DDName::fullname(), diffTwoXMLs::g1, diffTwoXMLs::g2, DDCompactView::graph(), i, DDBase< N, C >::name(), graph< N, E >::nodeData(), p1, p2, and runTheMatrix::ret.

                                                                                      {
  bool ret(true);

  const DDCompactView::graph_type & g1 = lhs.graph();
  const DDCompactView::graph_type & g2 = rhs.graph();

  typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
  adjl_iterator git1 = g1.begin();
  adjl_iterator gend1 = g1.end();
  adjl_iterator git2 = g2.begin();
  adjl_iterator gend2 = g2.end();
  /*     std::cout << "uniqueness test: " << &(*git1) << " != " << &(*git2)  */
  /*          << " and " << &(*gend1) << " != " << &(*gend2) << std::endl; */
  //    DDCompactView::graph_type::const_iterator bit = g1.begin_iter();
  DDCompactView::graph_type::index_type i=0;
  //    for (; git1 != gend1; ++git1) {
  while ( git1 != gend1 && git2 != gend2 && ret ) {
    const DDLogicalPart & ddLP1 = g1.nodeData(git1);
    const DDLogicalPart & ddLP2 = g2.nodeData(git2);
    std::cout << ++i << " P " << ddLP1.name() << " " << ddLP2.name() << std::endl;
    if ( ! DDCompareLP(ddco_)(ddLP1, ddLP2) ) {
      ret = false;
      break;
    } else if (git1->size() && git2->size() ) { 
      DDCompactView::graph_type::edge_list::const_iterator cit1  = git1->begin();
      DDCompactView::graph_type::edge_list::const_iterator cend1 = git1->end();
      DDCompactView::graph_type::edge_list::const_iterator cit2  = git2->begin();
      DDCompactView::graph_type::edge_list::const_iterator cend2 = git2->end();
      //for (; cit != cend; ++cit) {
      while ( cit1 != cend1 && cit2 != cend2 ) {
        const DDLogicalPart & ddcurLP1 = g1.nodeData(cit1->first);
        const DDLogicalPart & ddcurLP2 = g2.nodeData(cit2->first);
        std::cout << ++i << " c1--> " << g1.edgeData(cit1->second)->copyno_ << " " << ddcurLP1.name().fullname() << std::endl;
        std::cout << ++i << " c2--> " << g2.edgeData(cit2->second)->copyno_ << " " << ddcurLP2.name().fullname() << std::endl;
        const DDPosData* p1(g1.edgeData(cit1->second));
        const DDPosData* p2(g2.edgeData(cit2->second));
        //        if ( g1.edgeData(cit1->second)->copyno_ != g2.edgeData(cit2->second)->copyno_
//      if ( p1->copyno_ != p2->copyno_
//           || ddcurLP1.name().fullname() != ddcurLP2.name().fullname() ) {
//        std::cout << "Failed to match node (fullname:copy_no): 1: " 
//                  << ddcurLP1.name().fullname() << ":" << p1->copyno_ << " 2: " 
//                  << ddcurLP2.name().fullname() << ":" << p2->copyno_ << std::endl;
//        ret = false;
//        break;
        if ( p1->copyno_ != p2->copyno_ || 
             ! DDCompareLP(ddco_)(ddcurLP1,ddcurLP2) ) {
          std::cout << "Failed to match node (fullname:copy_no): 1: " 
                    << ddcurLP1.name().fullname() << ":" << p1->copyno_ << " 2: " 
                    << ddcurLP2.name().fullname() << ":" << p2->copyno_ << std::endl;
          ret = false;
          break;
        } else if ( ! DDCompareDDTrans()(p1->trans_, p2->trans_) ) {
          std::cout << "Failed to match translation " << std::endl;
//        std::cout << "1: " << std::setw(12) << std::fixed << std::setprecision(4) << p1->trans_.x();
//        std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << p1->trans_.y();
//        std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << p1->trans_.z() << std::endl;
//        std::cout << "2: " << std::setw(12) << std::fixed << std::setprecision(4) << p2->trans_.x();
//        std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << p2->trans_.y();
//        std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << p2->trans_.z() << std::endl;
          ret = false;
          break;
        } else if ( ! DDCompareDDRot(ddco_)(p1->rot_, p2->rot_) ) {
          std::cout << "Failed to match rotation " << std::endl;
          ret = false;
          break;
        }
        ++cit1;
        ++cit2;
      }
    } else if ( git1->size() != git2->size() ) {
      ret = false;
      std::cout << "DDCompactViews are different because number of children do not match" << std::endl;
      std::cout << "graph1 size of edge_list: " << git1->size() << " and graph2 size of edge_list: " << git2->size() << std::endl;
      break;
    }
    ++git1;
    ++git2;
  }
  return ret;
}

Member Data Documentation

Definition at line 38 of file DDCompareTools.h.

Referenced by operator()().