Skip to content

Commit

Permalink
streamlining the ugly code. it's still not exactly beautiful, though. (
Browse files Browse the repository at this point in the history
  • Loading branch information
lene committed Mar 27, 2014
1 parent 3417d58 commit 61cf5bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Displayable/Object/FacePolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ template <unsigned D, unsigned N_vertex> class FacePolygon {
/// a version of std::find() that returns an index instead of an iterator
static unsigned index_of(const vertex_type &x,
const VecMath::MultiDimensionalVector< vertex_type, 1 > &original_container);
unsigned getAssociatedIndex(unsigned i, const FacePolygon<D, N_vertex> &other) const;

/// Array of vertices the Surface consists of
vertex_ptr_type _vertices[N_vertex];
Expand Down
27 changes: 14 additions & 13 deletions src/Displayable/Object/FacePolygon.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,25 @@ FacePolygon<D, N_vertex>::operator==(const FacePolygon<D, N_vertex> &other) cons
ArrayList<N_vertex, unsigned>(other._indices))) {
return false;
}
print(); std::cerr << " == "; other.print(); std::cerr << "?\n";
unsigned associated_index[N_vertex];

for (unsigned i = 0; i < N_vertex; ++i) {
for (unsigned j = 0; j < N_vertex; ++j) {
if (other._indices[j] == _indices[i]) {
associated_index[i] = j;
break;
}
}
}
for (unsigned i = 0; i < N_vertex; ++i) {
std::cerr << i << ": " << *_vertices[i] << " == "
<< associated_index[i] << ": " << *other._vertices[associated_index[i]] << "?\n";
if (*_vertices[i] != *other._vertices[associated_index[i]]) return false;
if (*_vertices[i] != *other._vertices[getAssociatedIndex(i, other)]) return false;
}

return true;
}

template <unsigned D, unsigned N_vertex>
unsigned
FacePolygon<D, N_vertex>::getAssociatedIndex(unsigned i, const FacePolygon<D, N_vertex> &other) const {
for (unsigned j = 0; j < N_vertex; ++j) {
if (other._indices[j] == _indices[i]) {
return j;
}
}
return 0;
}

template <unsigned D, unsigned N_vertex>
void
FacePolygon<D, N_vertex>::print() const {
Expand Down

0 comments on commit 61cf5bf

Please sign in to comment.