Commit 749ae1d0 authored by Mike Kremer's avatar Mike Kremer

Removed a lot of unnecessary include directives and also keep the use of...

Removed a lot of unnecessary include directives and also keep the use of asserts consistent throughout the entire code. Fixed a bug when deleting ranges of cells. 

This patch was entirely written by Vladimir Chalupecky. Thanks Vladimir. I really appreciate your help.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@257 66977474-1d4b-4f09-8fe9-267525286df2
parent b02d35a7
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <istream>
#include <ostream>
#include "OpenVolumeMeshStatus.hh" #include "OpenVolumeMeshStatus.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#ifndef STATUS_HH_ #ifndef STATUS_HH_
#define STATUS_HH_ #define STATUS_HH_
#include <iostream> #include <iosfwd>
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#ifndef NDEBUG
#include <iostream>
#endif
#include "StatusAttrib.hh" #include "StatusAttrib.hh"
#include "../Core/TopologyKernel.hh" #include "../Core/TopologyKernel.hh"
...@@ -462,8 +466,10 @@ void StatusAttrib::garbage_collection(std_API_Container_VHandlePointer &vh_to_up ...@@ -462,8 +466,10 @@ void StatusAttrib::garbage_collection(std_API_Container_VHandlePointer &vh_to_up
garbage_collection(vh_to_update, hh_to_update, hfh_to_update, ch_to_update, false); garbage_collection(vh_to_update, hh_to_update, hfh_to_update, ch_to_update, false);
} else { } else {
#ifndef NDEBUG
std::cerr << "Preservation of three-manifoldness in garbage_collection() " std::cerr << "Preservation of three-manifoldness in garbage_collection() "
<< "requires bottom-up incidences!" << std::endl; << "requires bottom-up incidences!" << std::endl;
#endif
return; return;
} }
} }
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <iostream> #include <istream>
#include <ostream>
#include "BaseEntities.hh" #include "BaseEntities.hh"
......
...@@ -40,9 +40,11 @@ ...@@ -40,9 +40,11 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <algorithm>
#ifndef NDEBUG
#include <iostream> #include <iostream>
#endif
#include <set> #include <set>
#include <algorithm>
#include "Iterators.hh" #include "Iterators.hh"
#include "TopologyKernel.hh" #include "TopologyKernel.hh"
...@@ -61,7 +63,9 @@ BaseIter(_mesh, _ref_h), ...@@ -61,7 +63,9 @@ BaseIter(_mesh, _ref_h),
cur_index_(0) { cur_index_(0) {
if(!_mesh->has_vertex_bottom_up_incidences()) { if(!_mesh->has_vertex_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -123,7 +127,9 @@ BaseIter(_mesh, _ref_h), ...@@ -123,7 +127,9 @@ BaseIter(_mesh, _ref_h),
cur_index_(0) { cur_index_(0) {
if(!_mesh->has_edge_bottom_up_incidences()) { if(!_mesh->has_edge_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -184,7 +190,9 @@ VertexCellIter::VertexCellIter(const VertexHandle& _ref_h, ...@@ -184,7 +190,9 @@ VertexCellIter::VertexCellIter(const VertexHandle& _ref_h,
BaseIter(_mesh, _ref_h) { BaseIter(_mesh, _ref_h) {
if(!_mesh->has_full_bottom_up_incidences()) { if(!_mesh->has_full_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -252,7 +260,9 @@ BaseIter(_mesh, _ref_h), ...@@ -252,7 +260,9 @@ BaseIter(_mesh, _ref_h),
cur_index_(0) { cur_index_(0) {
if(!_mesh->has_edge_bottom_up_incidences() || !_mesh->has_face_bottom_up_incidences()) { if(!_mesh->has_edge_bottom_up_incidences() || !_mesh->has_face_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -373,7 +383,9 @@ CellCellIter::CellCellIter(const CellHandle& _ref_h, ...@@ -373,7 +383,9 @@ CellCellIter::CellCellIter(const CellHandle& _ref_h,
BaseIter(_mesh, _ref_h) { BaseIter(_mesh, _ref_h) {
if(!_mesh->has_face_bottom_up_incidences()) { if(!_mesh->has_face_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -477,7 +489,9 @@ BoundaryHalfFaceHalfFaceIter::BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle& ...@@ -477,7 +489,9 @@ BoundaryHalfFaceHalfFaceIter::BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle&
BaseIter(_mesh, _ref_h) { BaseIter(_mesh, _ref_h) {
if(!_mesh->has_face_bottom_up_incidences()) { if(!_mesh->has_face_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
...@@ -540,7 +554,9 @@ BaseIter(_mesh, TopologyKernel::InvalidFaceHandle), ...@@ -540,7 +554,9 @@ BaseIter(_mesh, TopologyKernel::InvalidFaceHandle),
bf_it_(_mesh->faces_begin()) { bf_it_(_mesh->faces_begin()) {
if(!_mesh->has_face_bottom_up_incidences()) { if(!_mesh->has_face_bottom_up_incidences()) {
#ifndef NDEBUG
std::cerr << "This iterator needs bottom-up incidences!" << std::endl; std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
#endif
BaseIter::valid(false); BaseIter::valid(false);
return; return;
} }
......
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#ifndef ITERATORS_HH_ #ifndef ITERATORS_HH_
#define ITERATORS_HH_ #define ITERATORS_HH_
#include <iterator>
#include <set> #include <set>
#include <vector> #include <vector>
#include <iterator>
#include "OpenVolumeMeshHandle.hh" #include "OpenVolumeMeshHandle.hh"
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <limits>
#include "OpenVolumeMeshBaseProperty.hh" #include "OpenVolumeMeshBaseProperty.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -44,9 +44,8 @@ ...@@ -44,9 +44,8 @@
#ifndef OPENVOLUMEMESHBASEPROPERTY_HH #ifndef OPENVOLUMEMESHBASEPROPERTY_HH
#define OPENVOLUMEMESHBASEPROPERTY_HH #define OPENVOLUMEMESHBASEPROPERTY_HH
#include <limits> #include <iosfwd>
#include <string> #include <string>
#include <iostream>
#include <vector> #include <vector>
#include "OpenVolumeMeshHandle.hh" #include "OpenVolumeMeshHandle.hh"
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <istream>
#include <ostream>
#include "OpenVolumeMeshHandle.hh" #include "OpenVolumeMeshHandle.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
#ifndef OPENVOLUMEMESHHANDLE_HH_ #ifndef OPENVOLUMEMESHHANDLE_HH_
#define OPENVOLUMEMESHHANDLE_HH_ #define OPENVOLUMEMESHHANDLE_HH_
#include <iostream>
#include <vector>
#include <OpenVolumeMesh/System/FunctionalInclude.hh>
#include <algorithm> #include <algorithm>
#include <iosfwd>
#include <vector>
#include "../System/FunctionalInclude.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -45,15 +45,14 @@ ...@@ -45,15 +45,14 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cassert> #include <cassert>
#include <istream>
#include <ostream>
#include <numeric>
#include <string>
#include <vector>
#include "OpenVolumeMeshBaseProperty.hh" #include "OpenVolumeMeshBaseProperty.hh"
#include "OpenVolumeMeshHandle.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -42,8 +42,6 @@ ...@@ -42,8 +42,6 @@
#include "PropertyDefines.hh" #include "PropertyDefines.hh"
#include "../Geometry/VectorT.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
template <> const std::string typeName<int>() { return "int"; } template <> const std::string typeName<int>() { return "int"; }
......
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
#ifndef PROPERTYDEFINES_HH_ #ifndef PROPERTYDEFINES_HH_
#define PROPERTYDEFINES_HH_ #define PROPERTYDEFINES_HH_
#include <iostream> #include <iosfwd>
#include <typeinfo>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <typeinfo>
#include "BaseProperty.hh"
#include "PropertyHandles.hh" #include "PropertyHandles.hh"
#include "PropertyPtr.hh" #include "PropertyPtr.hh"
...@@ -55,8 +55,6 @@ namespace OpenVolumeMesh { ...@@ -55,8 +55,6 @@ namespace OpenVolumeMesh {
template <class T> template <class T>
class OpenVolumeMeshPropertyT; class OpenVolumeMeshPropertyT;
template <class PropT, class HandleT>
class PropertyPtr;
class ResourceManager; class ResourceManager;
......
...@@ -42,8 +42,10 @@ ...@@ -42,8 +42,10 @@
#define PROPERTYDEFINEST_CC #define PROPERTYDEFINEST_CC
#include <istream>
#include <ostream>
#include "PropertyDefines.hh" #include "PropertyDefines.hh"
#include "PropertyPtr.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -43,13 +43,10 @@ ...@@ -43,13 +43,10 @@
#ifndef PROPERTYPTR_HH_ #ifndef PROPERTYPTR_HH_
#define PROPERTYPTR_HH_ #define PROPERTYPTR_HH_
#include <iostream>
#include <string> #include <string>
#include <cassert>
#include "BaseProperty.hh" #include "BaseProperty.hh"
#include "PropertyHandles.hh" #include "OpenVolumeMeshHandle.hh"
#include "../System/MemoryInclude.hh" #include "../System/MemoryInclude.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
......
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
#ifndef RESOURCEMANAGER_HH_ #ifndef RESOURCEMANAGER_HH_
#define RESOURCEMANAGER_HH_ #define RESOURCEMANAGER_HH_
#ifndef NDEBUG
#include <iostream>
#endif
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -223,8 +226,11 @@ private: ...@@ -223,8 +226,11 @@ private:
template <class FullPropT, class PropIterT> template <class FullPropT, class PropIterT>
bool property_exists(const PropIterT& _begin, const PropIterT& _end, const std::string& _name) const { bool property_exists(const PropIterT& _begin, const PropIterT& _end, const std::string& _name) const {
if(_name.length() == 0) { if(_name.empty()) {
std::cerr << "Checking for the existence of anonymous properties is ambiguous!" << std::endl; #ifndef NDEBUG
std::cerr << "property_exists(): Checking for the existence of anonymous properties is" << std::endl;
std::cerr << "ambiguous!" << std::endl;
#endif
return false; return false;
} }
......
...@@ -43,11 +43,8 @@ ...@@ -43,11 +43,8 @@
#define RESOURCEMANAGERT_CC #define RESOURCEMANAGERT_CC
#include "ResourceManager.hh" #include "ResourceManager.hh"
#include "PropertyDefines.hh" #include "PropertyDefines.hh"
#include "PropertyPtr.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
template<class T> template<class T>
......
...@@ -40,10 +40,14 @@ ...@@ -40,10 +40,14 @@
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include <OpenVolumeMesh/System/FunctionalInclude.hh> #ifndef NDEBUG
#include <iostream>
#endif
#include <queue> #include <queue>
#include "TopologyKernel.hh" #include "TopologyKernel.hh"
#include "../System/FunctionalInclude.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
...@@ -91,18 +95,16 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex, ...@@ -91,18 +95,16 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex,
const VertexHandle& _toVertex, const VertexHandle& _toVertex,
bool _allowDuplicates) { bool _allowDuplicates) {
#ifndef NDEBUG // If the conditions are not fulfilled, assert will fail (instead
if((size_t)_fromVertex.idx() >= n_vertices() || (size_t)_toVertex.idx() >= n_vertices()) { // of returning an invalid handle)
std::cerr << "Vertex handle is out of bounds!" << std::endl; assert(_fromVertex.is_valid() && (size_t)_fromVertex.idx() < n_vertices());
return InvalidEdgeHandle; assert(_toVertex.is_valid() && (size_t)_toVertex.idx() < n_vertices());
}
#endif
// Test if edge does not exist, yet // Test if edge does not exist, yet
if(!_allowDuplicates) { if(!_allowDuplicates) {
if(v_bottom_up_) { if(v_bottom_up_) {
assert(outgoing_hes_per_vertex_.size() > (size_t)_fromVertex.idx()); assert((size_t)_fromVertex.idx() < outgoing_hes_per_vertex_.size());
std::vector<HalfEdgeHandle>& ohes = outgoing_hes_per_vertex_[_fromVertex.idx()]; std::vector<HalfEdgeHandle>& ohes = outgoing_hes_per_vertex_[_fromVertex.idx()];
for(std::vector<HalfEdgeHandle>::const_iterator he_it = ohes.begin(), for(std::vector<HalfEdgeHandle>::const_iterator he_it = ohes.begin(),
he_end = ohes.end(); he_it != he_end; ++he_it) { he_end = ohes.end(); he_it != he_end; ++he_it) {
...@@ -134,8 +136,9 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex, ...@@ -134,8 +136,9 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex,
// Update vertex bottom-up incidences // Update vertex bottom-up incidences
if(v_bottom_up_) { if(v_bottom_up_) {
assert(outgoing_hes_per_vertex_.size() > (size_t)_fromVertex.idx()); assert((size_t)_fromVertex.idx() < outgoing_hes_per_vertex_.size());
assert(outgoing_hes_per_vertex_.size() > (size_t)_toVertex.idx()); assert((size_t)_toVertex.idx() < outgoing_hes_per_vertex_.size());
outgoing_hes_per_vertex_[_fromVertex.idx()].push_back(halfedge_handle(eh, 0)); outgoing_hes_per_vertex_[_fromVertex.idx()].push_back(halfedge_handle(eh, 0));
outgoing_hes_per_vertex_[_toVertex.idx()].push_back(halfedge_handle(eh, 1)); outgoing_hes_per_vertex_[_toVertex.idx()].push_back(halfedge_handle(eh, 1));
} }
...@@ -155,14 +158,10 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex, ...@@ -155,14 +158,10 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex,
FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck) { FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedges, bool _topologyCheck) {
#ifndef NDEBUG #ifndef NDEBUG
// Test if all edges are valid // Assert that halfedges are valid
for(std::vector<HalfEdgeHandle>::const_iterator it = _halfedges.begin(), for(std::vector<HalfEdgeHandle>::const_iterator it = _halfedges.begin(),
end = _halfedges.end(); it != end; ++it) { end = _halfedges.end(); it != end; ++it)
if((size_t)it->idx() >= edges_.size() * 2u) { assert(it->is_valid() && (size_t)it->idx() < edges_.size() * 2u);
std::cerr << "Halfedge handle out of bounds!" << std::endl;
return InvalidFaceHandle;
}
}
#endif #endif
// Perform topology check // Perform topology check
...@@ -193,7 +192,12 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge ...@@ -193,7 +192,12 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge
for(std::set<VertexHandle>::const_iterator v_it = fromVertices.begin(), for(std::set<VertexHandle>::const_iterator v_it = fromVertices.begin(),
v_end = fromVertices.end(); v_it != v_end; ++v_it) { v_end = fromVertices.end(); v_it != v_end; ++v_it) {
if(toVertices.count(*v_it) != 1) { if(toVertices.count(*v_it) != 1) {
std::cerr << "The specified halfedges are not connected!" << std::endl; // The situation here is different, the caller has requested a
// topology check and expects an invalid handle if the half-edges
// are not connected. Give him a message in debug mode.
#ifndef NDEBUG
std::cerr << "add_face(): The specified halfedges are not connected!" << std::endl;
#endif
return InvalidFaceHandle; return InvalidFaceHandle;
} }
} }
...@@ -217,8 +221,10 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge ...@@ -217,8 +221,10 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge
for(std::vector<HalfEdgeHandle>::const_iterator it = _halfedges.begin(), for(std::vector<HalfEdgeHandle>::const_iterator it = _halfedges.begin(),
end = _halfedges.end(); it != end; ++it) { end = _halfedges.end(); it != end; ++it) {
assert(incident_hfs_per_he_.size() > (size_t)it->idx());
assert(incident_hfs_per_he_.size() > (size_t)opposite_halfedge_handle(*it).idx()); assert((size_t)it->idx() < incident_hfs_per_he_.size());
assert((size_t)opposite_halfedge_handle(*it).idx() < incident_hfs_per_he_.size());
incident_hfs_per_he_[it->idx()].push_back(halfface_handle(fh, 0)); incident_hfs_per_he_[it->idx()].push_back(halfface_handle(fh, 0));
incident_hfs_per_he_[opposite_halfedge_handle(*it).idx()].push_back(halfface_handle(fh, 1)); incident_hfs_per_he_[opposite_halfedge_handle(*it).idx()].push_back(halfface_handle(fh, 1));
} }
...@@ -240,14 +246,10 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge ...@@ -240,14 +246,10 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge
FaceHandle TopologyKernel::add_face(const std::vector<VertexHandle>& _vertices) { FaceHandle TopologyKernel::add_face(const std::vector<VertexHandle>& _vertices) {
#ifndef NDEBUG #ifndef NDEBUG
// Test if all vertices exist // Assert that all vertices have valid indices
for(std::vector<VertexHandle>::const_iterator it = _vertices.begin(), for(std::vector<VertexHandle>::const_iterator it = _vertices.begin(),
end = _vertices.end(); it != end; ++it) { end = _vertices.end(); it != end; ++it)
if((size_t)it->idx() >= n_vertices()) { assert(it->is_valid() && (size_t)it->idx() < n_vertices());
std::cerr << "Vertex handle out of bounds!" << std::endl;
return InvalidFaceHandle;
}
}
#endif #endif
// Add edge for each pair of vertices // Add edge for each pair of vertices
...@@ -305,9 +307,8 @@ void TopologyKernel::reorder_incident_halffaces(const EdgeHandle& _eh) { ...@@ -305,9 +307,8 @@ void TopologyKernel::reorder_incident_halffaces(const EdgeHandle& _eh) {
HalfFaceHandle start_hf = InvalidHalfFaceHandle; HalfFaceHandle start_hf = InvalidHalfFaceHandle;
HalfFaceHandle cur_hf = InvalidHalfFaceHandle; HalfFaceHandle cur_hf = InvalidHalfFaceHandle;
// Start with one incident halfface and go // Start with one incident halfface and go into the first direction
// into the first direction assert((size_t)cur_he.idx() < incident_hfs_per_he_.size());
assert(incident_hfs_per_he_.size() > (size_t)cur_he.idx());
if(incident_hfs_per_he_[cur_he.idx()].size() != 0) { if(incident_hfs_per_he_[cur_he.idx()].size() != 0) {