customOperators.cpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23  \ *---------------------------------------------------------------------------*/
24 
25 #include "customOperators.hpp"
26 
34 std::array<double, 3> operator-(const bitpit::Vertex &v1, const bitpit::Vertex &v2){
35  std::array<double, 3> coords2 = v1.getCoords() - v2.getCoords();
36  return ( coords2 );
37 }
38 
45 int
46 countSubstring(const std::string& str, const std::string& sub)
47 {
48  if (sub.length() == 0) return 0;
49  int count = 0;
50  for (size_t offset = str.find(sub); offset != std::string::npos;
51  offset = str.find(sub, offset + sub.length()))
52  {
53  ++count;
54  }
55  return count;
56 }
std::array< double, 3 > operator-(const bitpit::Vertex &v1, const bitpit::Vertex &v2)
int countSubstring(const std::string &str, const std::string &sub)