Commit 8e6c042d authored by Heng Liu's avatar Heng Liu
Browse files

Merge branch 'v2.1rc2' into clean_edge_collapse

parents 930b1446 0cf80cd0
......@@ -21,8 +21,6 @@ set(OVM_ENABLE_UNITTESTS ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMes
set(OVM_ENABLE_EXAMPLES ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh examples")
set(OVM_BUILD_DOCUMENTATION ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh documentation")
set(OVM_CXX_STANDARD 11 CACHE STRING "C++ standard version to use")
set_property(CACHE OVM_CXX_STANDARD PROPERTY STRINGS 11 14 17 20)
if (OVM_STANDALONE_BUILD)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Build/bin")
......@@ -41,6 +39,11 @@ if (OVM_STANDALONE_BUILD)
add_definitions(-D_GLIBCXX_DEBUG=1)
add_definitions(-D_GLIBCXX_DEBUG_PEDANTIC=1)
endif()
set(OVM_CXX_STANDARD 11 CACHE STRING "C++ standard version to use")
set_property(CACHE OVM_CXX_STANDARD PROPERTY STRINGS 11 14 17 20)
set(CMAKE_CXX_STANDARD ${OVM_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
# OVM_TARGET_PREFIX is prepended to targets with generic names,
# i.e., "doc", "unittests"
......
......@@ -21,7 +21,7 @@ SET(SOURCE_FILES
OpenVolumeMesh/Mesh/HexahedralMeshTopologyKernel.cc
)
set(OVM_ENABLE_DEPRECATED_APIS ON CACHE BOOL "Support deprecated OpenVolumeMesh APIs")
set(OVM_ENABLE_DEPRECATED_APIS OFF CACHE BOOL "Support deprecated OpenVolumeMesh APIs")
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/OpenVolumeMesh/Config/DeprecationConfig.hh.in"
......@@ -69,12 +69,9 @@ generate_export_header(OpenVolumeMesh
set_target_properties (OpenVolumeMesh PROPERTIES
VERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
SOVERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
CXX_STANDARD ${OVM_CXX_STANDARD}
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
POSITION_INDEPENDENT_CODE ON
# TODO: turn this on once we have OVM_EXPORT macros in all required places:
#CXX_VISIBILITY_PRESET hidden
#CXX_VISIBILITY_PRESET hidden
)
......
......@@ -2,11 +2,6 @@ find_package(Boost 1.43.0)
if(Boost_FOUND)
add_executable(file_converter ovm_converter.cc)
set_target_properties (file_converter PROPERTIES
CXX_STANDARD ${OVM_CXX_STANDARD}
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
target_link_libraries(file_converter OpenVolumeMesh::OpenVolumeMesh Boost::boost)
else()
......
......@@ -113,8 +113,6 @@ private:
void compute_vertex_normal(const VertexHandle& _vh);
void compute_face_normal(const FaceHandle& _fh);
GeomKernelT& kernel_;
VertexPropertyT<typename GeomKernelT::PointT> v_normals_;
......
......@@ -67,8 +67,9 @@ void NormalAttrib<GeomKernelT>::update_vertex_normals() {
// Compute face normals
update_face_normals();
for(VertexIter v_it = kernel_.v_iter(); v_it.valid(); ++v_it) {
compute_vertex_normal(*v_it);
for(const auto &_vh: kernel_.vertices())
{
compute_vertex_normal(_vh);
}
}
......@@ -80,10 +81,8 @@ void NormalAttrib<GeomKernelT>::update_face_normals() {
return;
}
for(FaceIter f_it = kernel_.f_iter(); f_it.valid(); ++f_it) {
// Assume the face is planar, so just take the
// first two edges
compute_face_normal(*f_it);
for (const auto &_fh: kernel_.faces()) {
f_normals_[_fh] = kernel_.normal(kernel_.halfface_handle(_fh, 0));
}
}
......@@ -109,29 +108,6 @@ void NormalAttrib<GeomKernelT>::compute_vertex_normal(const VertexHandle& _vh) {
normal.normalize();
v_normals_[_vh] = normal;
}
template <class GeomKernelT>
void NormalAttrib<GeomKernelT>::compute_face_normal(const FaceHandle& _fh) {
if(kernel_.face(_fh).halfedges().size() < 3) {
std::cerr << "Warning: Degenerate face detected!" << std::endl;
return;
}
const std::vector<HalfEdgeHandle>& halfedges = kernel_.face(_fh).halfedges();
std::vector<HalfEdgeHandle>::const_iterator he_it = halfedges.begin();
typename GeomKernelT::PointT p1 = kernel_.vertex(kernel_.halfedge(*he_it).from_vertex());
typename GeomKernelT::PointT p2 = kernel_.vertex(kernel_.halfedge(*he_it).to_vertex());
++he_it;
typename GeomKernelT::PointT p3 = kernel_.vertex(kernel_.halfedge(*he_it).to_vertex());
typename GeomKernelT::PointT n = (p2 - p1) % (p3 - p2);
n.normalize();
f_normals_[_fh] = n;
}
} // Namespace OpenVolumeMesh
......@@ -5,5 +5,3 @@
#define OPENVOLUMEMESH_VERSION_MINOR @OpenVolumeMesh_VERSION_MINOR@
#define OPENVOLUMEMESH_VERSION_PATCH @OpenVolumeMesh_VERSION_PATCH@
#define OPENVOLUMEMESH_CXX_VERSION @OVM_CXX_STANDARD@
......@@ -37,6 +37,7 @@
#include <cassert>
#include <iostream>
#include <type_traits>
#include "../Geometry/VectorT.hh"
#include "TopologyKernel.hh"
......@@ -217,6 +218,28 @@ public:
return p;
}
/// Compute halfface normal assuming planarity (just uses first 2 edges)
/// Note: NormalAttrib provides fast access to precomputed normals.
PointT normal(const HalfFaceHandle& _hfh) const
{
if(TopologyKernelT::halfface(_hfh).halfedges().size() < 3) {
std::cerr << "Warning: Degenerate face: "
<< TopologyKernelT::face_handle(_hfh) << std::endl;
return PointT {0.0, 0.0, 0.0};
}
const std::vector<HalfEdgeHandle>& halfedges = TopologyKernelT::halfface(_hfh).halfedges();
std::vector<HalfEdgeHandle>::const_iterator he_it = halfedges.begin();
const PointT &p1 = vertex(TopologyKernelT::halfedge(*he_it).from_vertex());
const PointT &p2 = vertex(TopologyKernelT::halfedge(*he_it).to_vertex());
++he_it;
const PointT &p3 = vertex(TopologyKernelT::halfedge(*he_it).to_vertex());
const PointT n = (p2 - p1).cross(p3 - p2);
return n.normalized();
}
void clone_vertices(std::vector<VecT>& _copy) const {
_copy.clear();
_copy.reserve(vertices_.size());
......
......@@ -79,7 +79,11 @@ public:
// STL compliance (needs to have default constructor)
BaseIterator() : valid_(false), mesh_(nullptr) {}
BaseIterator(const BaseIterator& _c) = default;
virtual ~BaseIterator() = default;
BaseIterator& operator=(const BaseIterator& _c) = default;
bool operator== (const BaseIterator& _c) const {
return (this->cur_handle_ == _c.cur_handle() &&
this->valid_ == _c.valid() &&
......@@ -101,13 +105,6 @@ public:
return cur_handle_.idx() < _c.cur_handle_.idx();
}
BaseIterator& operator=(const BaseIterator& _c) {
this->valid_ = _c.valid();
this->cur_handle_ = _c.cur_handle();
this->mesh_ = _c.mesh();
return *this;
}
operator bool() const {
return valid_;
}
......@@ -189,6 +186,7 @@ public:
lap_(0),
max_laps_(1)
{}
BaseCirculator(const BaseCirculator& _c) = default;
virtual ~BaseCirculator() = default;
......@@ -208,13 +206,7 @@ public:
return lap_ < _c.lap_;
}
BaseCirculator& operator=(const BaseCirculator& _c) {
BaseIter::operator=(_c);
this->ref_handle_ = _c.ref_handle();
this->lap_ = _c.lap_;
this->max_laps_ = _c.max_laps_;
return *this;
}
BaseCirculator& operator=(const BaseCirculator& _c) = default;
const IH& ref_handle() const {
return ref_handle_;
......
......@@ -377,8 +377,17 @@ class VectorT {
};
}
/// cross product: only defined for Vec3* as specialization
/// \see OpenVolumeMesh::cross and .cross()
template<typename OtherScalar>
auto cross (const VectorT<OtherScalar, DIM> &_rhs) const ->
decltype(*this % _rhs)
{
return *this % _rhs;
}
/// compute scalar product
/// \see OpenVolumeMesh::dot
/// \see OpenVolumeMesh::dot and .dot()
template<typename OtherScalar>
auto operator|(const VectorT<OtherScalar, DIM>& _rhs) const ->
decltype(*this->data() * *_rhs.data()) {
......@@ -387,6 +396,15 @@ class VectorT {
*data() * *_rhs.data());
}
/// compute scalar product
/// \see OpenVolumeMesh::dot and .operator|
template<typename OtherScalar>
auto dot(const VectorT<OtherScalar, DIM>& _rhs) const ->
decltype(*this | _rhs)
{
return *this | _rhs;
}
//------------------------------------------------------------ euclidean norm
/// \name Euclidean norm calculations
......
#include "OpenVolumeMesh/Config/Version.hh"
// C++ version at OVM build time,
// to be used for things that change ABI
#if OPENVOLUMEMESH_CXX_VERSION >= 17
#define OVM_BUILD_CXX_17 1
#else
#define OVM_BUILD_CXX_17 0
#endif
// C++ version when compiling (e.g. client code),
// be careful not to change ABI depending on these defines.
......
......@@ -37,9 +37,6 @@ if(GTEST_FOUND)
set_target_properties(${TARGET_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests
CXX_STANDARD ${OVM_CXX_STANDARD}
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
#[[=
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment