From efd51a3353d9bb9838204fcac11036066205e466 Mon Sep 17 00:00:00 2001 From: Bastian Rieck Date: Wed, 1 Sep 2010 13:39:27 +0200 Subject: [PATCH] Added warnings & constructor for directed_edge * Warnings concerning orientation and manifold meshes are now only printed once. * Added constructor for directed_edge class. --- Makefile | 4 ++-- directed_edge.cpp | 23 +++++++++++++++++++++++ directed_edge.h | 2 ++ edge.cpp | 14 +++++++++++++- mesh.cpp | 16 +++++++++++++++- 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 directed_edge.cpp diff --git a/Makefile b/Makefile index 7fbb79c..1840e3a 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ CC = g++ -CCFLAGS = -g -Wall -c -pedantic +CCFLAGS = -g -Wall -c -pedantic -O11 LIBS = -L /usr/X11/lib -L /usr/local/lib INCLUDES = -I /usr/local/include LDFLAGS = -MYOBJECTS = psalm.o v3ctor.o mesh.o face.o vertex.o edge.o +MYOBJECTS = psalm.o v3ctor.o mesh.o face.o vertex.o edge.o directed_edge.o BIN = psalm # Path to "meshlabserver" binary, which is used for creating test data. diff --git a/directed_edge.cpp b/directed_edge.cpp new file mode 100644 index 0000000..d62a626 --- /dev/null +++ b/directed_edge.cpp @@ -0,0 +1,23 @@ +/*! +* @file directed_edge.cpp +* @brief Functions for describign a directed edge. +*/ + +#include +#include "directed_edge.h" + +namespace psalm +{ + +/*! +* Default constructor. Sets all attributes to "false" or "NULL". +*/ + +directed_edge::directed_edge() +{ + e = NULL; + inverted = false; + new_edge = false; +} + +} // end of namespace "psalm" diff --git a/directed_edge.h b/directed_edge.h index e7d0040..0f6b70c 100644 --- a/directed_edge.h +++ b/directed_edge.h @@ -26,6 +26,8 @@ class edge; // forward declaration to break up circular dependency with face cla class directed_edge { public: + directed_edge(); + edge* e; ///< Pointer to edge bool inverted; ///< Flag signalling direction diff --git a/edge.cpp b/edge.cpp index 973b2fb..e1fbd3c 100644 --- a/edge.cpp +++ b/edge.cpp @@ -3,7 +3,9 @@ * @brief Functions and implementations for edge class */ +#include #include + #include "edge.h" namespace psalm @@ -96,7 +98,17 @@ void edge::set_f(face* f) void edge::set_g(face* g) { - assert(f != NULL && this->g == NULL); + static bool warning_shown = false; + if(f != NULL && this->g != NULL) + { + if(!warning_shown) + { + std::cerr << "psalm: Warning: Mesh might be non-manifold.\n"; + warning_shown = true; + } + return; + } + this->g = g; } diff --git a/mesh.cpp b/mesh.cpp index ab51231..8ebc7b9 100644 --- a/mesh.cpp +++ b/mesh.cpp @@ -925,6 +925,8 @@ void mesh::replace_with(mesh& M) void mesh::add_face(std::vector vertices) { + static bool warning_shown = false; + vertex* u = NULL; vertex* v = NULL; @@ -983,7 +985,12 @@ void mesh::add_face(std::vector vertices) } else { - std::cerr << "psalm: Detected wrong orientation in mesh. Expect inconsistent results.\n"; + if(!warning_shown) + { + std::cerr << "psalm: Warning: Wrong orientation in mesh--results may be inconsistent.\n"; + warning_shown = true; + } + edge.e->set_g(f); } @@ -1998,6 +2005,13 @@ void mesh::subdivide_catmull_clark() } } + // For non-manifold meshes, we may not be able to find + // adjacent faces for every combination of vertices and + // edges + if( e1 == NULL || + e2 == NULL) + continue; + // If crease handling is not enabled, we may not have // edge points everywhere. These faces need to be // skipped, of course.