/usr/include/polymake/topaz/connected_sum.tcc is in libpolymake-dev-common 3.2r2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /* Copyright (c) 1997-2018
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
   http://www.polymake.org
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
--------------------------------------------------------------------------------
*/
#include "polymake/topaz/connected_sum.h"
#include "polymake/topaz/complex_tools.h"
#include <sstream>
namespace polymake { namespace topaz {
        
typedef hash_map<int,int> map;
template <typename Complex_1, typename Complex_2>
std::list< Set<int> > connected_sum(const Complex_1& C1,
                                    const Complex_2& C2,
                                    const int f1, const int f2,
                                    Array<std::string>& L1,
                                    const Array<std::string>& L2,
                                    map& P)
{
   typedef typename Complex_2::value_type Facet2;
   std::list< Set<int> > CS;
      
   // add facets of C1, omitting f1, and compute the vertex set of C1
   Set<int> V1, V2, facet1, facet2;
   int i=0;
   for (auto c_it=entire(C1);  !c_it.at_end();  ++c_it, ++i) {
      if (i==f1)
         facet1=*c_it;
      else
         CS.push_back(*c_it);
      V1 += *c_it;
   }
      
   if (facet1.empty())
      throw std::runtime_error("connected_sum - f1 is not a facet index");
      
   // find facet f2 and compute the vertex set of C2
   i=0;
   for (typename Entire<Complex_2>::const_iterator c_it=entire(C2); !c_it.at_end(); ++c_it, ++i) {
      if (i==f2)
         facet2=*c_it;
      V2 += *c_it;
   }
   if (facet2.empty())
      throw std::runtime_error("connected_sum - f2 is not a facet index");
      
   if (facet1.size()!=facet2.size())
      throw std::runtime_error("connected_sum - facets dimension mismatch");
      
   // compute new vertex indices for V2, identyfing facet1 and facet2
   int index_diff= V1.back()-V2.front()+1;
   map vertex_map(V2.size());
   typename Set<int>::iterator f1_it=facet1.begin();
   for (typename Entire< Set<int> >::iterator it=entire(V2); !it.at_end(); ++it) {
      const int v=*it;
      if (facet2.contains(v)) {
         vertex_map[*it]= P.empty() ? *f1_it : P[*f1_it];
         ++f1_it;
         --index_diff;
      } else
         vertex_map[*it]=*it+index_diff;
   }
      
   // add facets of C2, omitting f2, and adjust the vertex indices
   i=0;
   for (auto c_it=entire(C2);  !c_it.at_end();  ++c_it, ++i)
      if (i!=f2) {
         Set<int> f;
         for (typename Entire<Facet2>::const_iterator f_it=entire(*c_it);
              !f_it.at_end(); ++f_it)
            f+=vertex_map[*f_it];
         CS.push_back(f);
      }
      
   // adjust labels
   if (L1.size() != 0) {         // if L1.size()==0 => no L1 and L2 specified.
      int count = L1.size();
      L1.resize(count + L2.size() - facet1.size());
         
      for (int v=0; v<count; ++v) {
         if (!facet1.contains(v))
            L1[v].append("_1");
      }
         
      for (int v=0; v<L2.size(); ++v) {
         if (!facet2.contains(v)) {
            L1[count] = L2[v] + "_2";
            ++count;
         }
      }
   }
      
   const Set<int> V = accumulate(CS, operations::add());
   if (adj_numbering(CS,V) && L1.size()!=0) {
      // adjust labels
      Array<std::string> L_tmp(V.size());
      Array<std::string>::iterator l = L_tmp.begin();
      for (Entire< Set<int> >::const_iterator v=entire(V);
           !v.at_end(); ++v, ++l)
         *l = L1[*v];
         
      L1 = L_tmp;
   }
      
   return CS;
}
   
} }
// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
 |