Skip to content

Commit

Permalink
Added warnings & constructor for directed_edge
Browse files Browse the repository at this point in the history
* Warnings concerning orientation and manifold meshes are now only
  printed once.
* Added constructor for directed_edge class.
  • Loading branch information
Pseudomanifold committed Sep 1, 2010
1 parent 51d92d0 commit efd51a3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
23 changes: 23 additions & 0 deletions directed_edge.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*!
* @file directed_edge.cpp
* @brief Functions for describign a directed edge.
*/

#include <cstddef>
#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"
2 changes: 2 additions & 0 deletions directed_edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* @brief Functions and implementations for edge class
*/

#include <iostream>
#include <cassert>

#include "edge.h"

namespace psalm
Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 15 additions & 1 deletion mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ void mesh::replace_with(mesh& M)

void mesh::add_face(std::vector<vertex*> vertices)
{
static bool warning_shown = false;

vertex* u = NULL;
vertex* v = NULL;

Expand Down Expand Up @@ -983,7 +985,12 @@ void mesh::add_face(std::vector<vertex*> 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);
}

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit efd51a3

Please sign in to comment.