19 namespace FaceIndicesUtils {
20 template<
typename IndexType >
24 std::set< IndexType > s(in_face_indices.begin(), in_face_indices.end());
25 return (in_face_indices.size() == s.size());
28 template<
typename IndexType >
31 std::vector< std::vector< IndexType > > &in_out_lines_indices)
33 size_t nb_poly_lines = in_out_lines_indices.size();
34 for(
size_t i = 0; i < nb_poly_lines; ++i)
36 size_t current_line_size = in_out_lines_indices[i].size();
37 if(current_line_size <= 2)
39 if(current_line_size <= 1)
40 throw std::invalid_argument(
41 "lines_indices_to_segments_indices -> input lines indices not "
42 "valid. Need at least 2 indices per line");
47 std::vector< IndexType > line_segment;
48 for(
size_t j = 1; j < current_line_size;
51 switch(line_segment.size())
54 line_segment.push_back(in_out_lines_indices[i][j]);
57 line_segment.erase(line_segment.begin());
60 line_segment.push_back(in_out_lines_indices[i][j]);
61 in_out_lines_indices.push_back(line_segment);
64 while(in_out_lines_indices[i].size() > 2)
65 in_out_lines_indices[i].pop_back();
69 template<
typename IndexType >
72 const std::vector< IndexType >
75 std::vector< IndexType >
78 std::vector< std::vector< IndexType > >
81 size_t nb_e = in_face_indices.size();
82 out_face_indices.clear();
83 out_lines_indices.clear();
85 std::vector< IndexType > new_line;
86 bool found_elm_i =
false,
89 only_first_is_cleared =
true;
90 IndexType where_found_i = -1;
91 for(IndexType i = 0; i < nb_e; ++i)
95 if(i == where_found_i)
98 preserve_next = !preserve_next;
100 if(new_line.size() > 1)
102 out_lines_indices.push_back(new_line);
111 if(std::find(new_line.begin(), new_line.end(), in_face_indices[i]) ==
113 new_line.push_back(in_face_indices[i]);
115 out_lines_indices.push_back(new_line);
119 for(IndexType j = i + 1; j < nb_e; ++j)
121 if(in_face_indices[i] == in_face_indices[j])
125 if(j - i <= nb_e / 2)
127 preserve_next =
false;
128 new_line.push_back(in_face_indices[i]);
132 if(only_first_is_cleared && (i > 0))
134 out_face_indices.clear();
135 only_first_is_cleared =
false;
136 if(out_lines_indices.size() > 0)
137 out_lines_indices[out_lines_indices.size() - 1].insert(
138 out_lines_indices[out_lines_indices.size() - 1].begin(),
142 new_line.push_back(in_face_indices[i]);
148 if(std::find(out_face_indices.begin(),
149 out_face_indices.end(),
150 in_face_indices[i]) == out_face_indices.end())
151 out_face_indices.push_back(in_face_indices[i]);