Merge branch 'master' into lyonm/custom-property-writing

This commit is contained in:
Max Lyon
2023-02-06 16:50:37 +01:00
46 changed files with 617 additions and 675 deletions

View File

@@ -23,19 +23,12 @@ if ( BUILD_APPS )
add_subdirectory (VDProgMesh/Analyzer)
# Add non ui apps as dependency before fixbundle
if ( WIN32 )
if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" )
# let bundle generation depend on all targets
if ( APPLE OR (WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" ) )
# let bundle generation depend on all targets
add_dependencies (fixbundle commandlineDecimater Dualizer mconvert Smoothing commandlineAdaptiveSubdivider commandlineSubdivider mkbalancedpm Analyzer )
endif()
endif()
# Add non ui apps as dependency before fixbundle
if ( APPLE)
# let bundle generation depend on all targets
add_dependencies (fixbundle commandlineDecimater Dualizer mconvert Smoothing commandlineAdaptiveSubdivider commandlineSubdivider mkbalancedpm Analyzer )
endif()
set( OpenGL_GL_PREFERENCE GLVND)
# find needed packages for gui applications
find_package (OpenGL)
@@ -70,17 +63,12 @@ if ( BUILD_APPS )
# Add ui apps as dependency before fixbundle
if ( WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles")
# Required on Windows (NOTMINGW) and APPLE
if ( APPLE OR (WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles") )
# let bundle generation depend on all targets
add_dependencies (fixbundle DecimaterGui ProgViewer QtViewer SubdividerGui Synthesizer)
endif()
# Add ui apps as dependency before fixbundle
if ( APPLE)
# let bundle generation depend on all targets
add_dependencies (fixbundle DecimaterGui ProgViewer QtViewer SubdividerGui Synthesizer)
endif()
if ( WIN32 )
FILE(GLOB files_install_app_dlls "${CMAKE_BINARY_DIR}/Build/*.dll" )
INSTALL(FILES ${files_install_app_dlls} DESTINATION . )

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (headers
../DecimaterViewerWidget.hh
../../QtViewer/QGLViewerWidget.hh

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (commandlineDecimater ../decimater.cc)
target_link_libraries (commandlineDecimater

View File

@@ -1,9 +1,5 @@
include (VCICommon)
include_directories (
../../..
)
vci_add_executable (Dualizer dualizer.cc)
target_link_libraries (Dualizer

View File

@@ -1,11 +1,5 @@
include (VCICommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set( headers
ProgViewerWidget.hh
../QtViewer/QGLViewerWidget.hh

View File

@@ -1,15 +1,5 @@
include (VCICommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
# source code directories
set (directories
.
)
set (sources
MeshViewerWidget.cc
QGLViewerWidget.cc

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (Smoothing smooth.cc)
target_link_libraries (Smoothing

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (headers
../MeshViewerWidget.hh
../SubdivideWidget.hh

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (commandlineAdaptiveSubdivider ../adaptive_subdivider.cc)
target_link_libraries (commandlineAdaptiveSubdivider

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (commandlineSubdivider ../subdivider.cc)
target_link_libraries (commandlineSubdivider

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (Analyzer vdpmanalyzer.cc)
target_link_libraries (Analyzer

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (headers
VDPMSynthesizerViewerWidget.hh
)

View File

@@ -1,10 +1,5 @@
include (VCICommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
vci_add_executable (mkbalancedpm mkbalancedpm.cc)
target_link_libraries (mkbalancedpm

View File

@@ -1,9 +1,5 @@
include (VCICommon)
include_directories (
../../..
)
vci_add_executable (mconvert mconvert.cc)
target_link_libraries (mconvert

View File

@@ -1,29 +1,135 @@
include (VCICommon)
include_directories (
../..
${CMAKE_CURRENT_SOURCE_DIR}
set ( headers
Geometry/Config.hh
Geometry/EigenVectorT.hh
Geometry/LoopSchemeMaskT.hh
Geometry/MathDefs.hh
Geometry/NormalConeT.hh
Geometry/NormalConeT_impl.hh
Geometry/Plane3d.hh
Geometry/QuadricT.hh
Geometry/Vector11T.hh
Geometry/VectorT.hh
Geometry/VectorT_inc.hh
IO/BinaryHelper.hh
IO/IOInstances.hh
IO/IOManager.hh
IO/MeshIO.hh
IO/OFFFormat.hh
IO/OMFormat.hh
IO/OMFormatT_impl.hh
IO/Options.hh
IO/SR_binary.hh
IO/SR_binary_spec.hh
IO/SR_binary_vector_of_bool.hh
IO/SR_rbo.hh
IO/SR_store.hh
IO/SR_types.hh
IO/StoreRestore.hh
IO/exporter/BaseExporter.hh
IO/exporter/ExporterT.hh
IO/importer/BaseImporter.hh
IO/importer/ImporterT.hh
IO/reader/BaseReader.hh
IO/reader/OBJReader.hh
IO/reader/OFFReader.hh
IO/reader/OMReader.hh
IO/reader/PLYReader.hh
IO/reader/STLReader.hh
IO/writer/BaseWriter.hh
IO/writer/OBJWriter.hh
IO/writer/OFFWriter.hh
IO/writer/OMWriter.hh
IO/writer/PLYWriter.hh
IO/writer/STLWriter.hh
IO/writer/VTKWriter.hh
Mesh/ArrayItems.hh
Mesh/ArrayKernel.hh
Mesh/ArrayKernelT_impl.hh
Mesh/AttribKernelT.hh
Mesh/Attributes.hh
Mesh/BaseKernel.hh
Mesh/BaseMesh.hh
Mesh/Casts.hh
Mesh/CirculatorsT.hh
Mesh/DefaultPolyMesh.hh
Mesh/DefaultTriMesh.hh
Mesh/FinalMeshItemsT.hh
Mesh/Handles.hh
Mesh/IteratorsT.hh
Mesh/PolyConnectivity.hh
Mesh/PolyConnectivity_inline_impl.hh
Mesh/PolyMeshT.hh
Mesh/PolyMeshT_impl.hh
Mesh/PolyMesh_ArrayKernelT.hh
Mesh/SmartHandles.hh
Mesh/SmartRange.hh
Mesh/Status.hh
Mesh/Tags.hh
Mesh/Traits.hh
Mesh/TriConnectivity.hh
Mesh/TriMeshT.hh
Mesh/TriMeshT_impl.hh
Mesh/TriMesh_ArrayKernelT.hh
Mesh/gen/circulators_header.hh
Mesh/gen/circulators_template.hh
Mesh/gen/footer.hh
Mesh/gen/iterators_header.hh
Mesh/gen/iterators_template.hh
System/OpenMeshDLLMacros.hh
System/compiler.hh
System/config.hh
System/mostream.hh
System/omstream.hh
Utils/AutoPropertyHandleT.hh
Utils/BaseProperty.hh
Utils/Endian.hh
Utils/GenProg.hh
Utils/HandleToPropHandle.hh
Utils/Noncopyable.hh
Utils/Predicates.hh
Utils/Property.hh
Utils/PropertyContainer.hh
Utils/PropertyCreator.hh
Utils/PropertyManager.hh
Utils/RandomNumberGenerator.hh
Utils/SingletonT.hh
Utils/SingletonT_impl.hh
Utils/color_cast.hh
Utils/typename.hh
Utils/vector_cast.hh
Utils/vector_traits.hh
)
# source code directories
set (directories
.
Geometry
IO
IO/exporter
IO/importer
IO/reader
IO/writer
Mesh
Mesh/gen
System
Utils
set ( sources
IO/BinaryHelper.cc
IO/IOManager.cc
IO/OMFormat.cc
IO/reader/BaseReader.cc
IO/reader/OBJReader.cc
IO/reader/OFFReader.cc
IO/reader/OMReader.cc
IO/reader/PLYReader.cc
IO/reader/STLReader.cc
IO/writer/BaseWriter.cc
IO/writer/OBJWriter.cc
IO/writer/OFFWriter.cc
IO/writer/OMWriter.cc
IO/writer/PLYWriter.cc
IO/writer/STLWriter.cc
IO/writer/VTKWriter.cc
Mesh/ArrayKernel.cc
Mesh/BaseKernel.cc
Mesh/PolyConnectivity.cc
Mesh/TriConnectivity.cc
System/omstream.cc
Utils/BaseProperty.cc
Utils/Endian.cc
Utils/PropertyCreator.cc
Utils/RandomNumberGenerator.cc
)
# collect all header and source files
vci_append_files (headers "*.hh" ${directories})
vci_append_files (sources "*.cc" ${directories})
# Disable Library installation when not building OpenMesh on its own but as part of another project!
if ( NOT ${CMAKE_PROJECT_NAME} MATCHES "OpenMesh")
set(VCI_NO_LIBRARY_INSTALL true)
@@ -36,12 +142,25 @@ if (WIN32)
add_definitions( -DOPENMESHDLL -DBUILDOPENMESHDLL)
vci_add_library (OpenMeshCore SHARED ${sources} ${headers})
else()
# OpenMesh has no dll exports so we have to build a static library on windows
vci_add_library (OpenMeshCore STATIC ${sources} ${headers})
endif()
target_include_directories(OpenMeshCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
else ()
vci_add_library (OpenMeshCore SHAREDANDSTATIC ${sources} ${headers})
target_include_directories(OpenMeshCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
target_include_directories(OpenMeshCoreStatic PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
set_target_properties (OpenMeshCore PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} )
endif ()
@@ -53,18 +172,10 @@ endif ()
# Add core as dependency before fixbundle
if ( (${CMAKE_PROJECT_NAME} MATCHES "OpenMesh") AND BUILD_APPS )
if ( WIN32 )
if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" )
if ( APPLE OR (WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" ) )
add_dependencies (fixbundle OpenMeshCore)
endif()
endif()
# Add core as dependency before fixbundle
if ( APPLE )
# let bundle generation depend on targets
add_dependencies (fixbundle OpenMeshCore)
endif ()
endif()
# if we build debug and release in the same dir, we want to install both!
@@ -126,25 +237,8 @@ install(DIRECTORY .
#install the config file
install(FILES System/config.h DESTINATION include/OpenMesh/Core/System)
#install inlined Files from IO
install(DIRECTORY IO/
DESTINATION include/OpenMesh/Core/IO
FILES_MATCHING
PATTERN "*.inl"
PATTERN "CVS" EXCLUDE
PATTERN ".svn" EXCLUDE
PATTERN "reader" EXCLUDE
PATTERN "writer" EXCLUDE
PATTERN "importer" EXCLUDE
PATTERN "exporter" EXCLUDE
PATTERN "tmp" EXCLUDE
PATTERN "Debian*" EXCLUDE )
endif ()
target_include_directories(OpenMeshCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
install(TARGETS OpenMeshCore EXPORT OpenMeshConfig
ARCHIVE DESTINATION ${VCI_PROJECT_LIBDIR}
LIBRARY DESTINATION ${VCI_PROJECT_LIBDIR}

View File

@@ -51,6 +51,7 @@
// OpenMesh
#include <OpenMesh/Core/System/config.h>
#include <string>
//== NAMESPACES ==============================================================
@@ -115,31 +116,24 @@ public:
TexCoordST = 0x8000 ///< Write texture coordinates as ST instead of UV
};
/// Texture filename. This will be written as
/// map_Kd in the OBJ writer into the material file.
std::string texture_file ;
/// Filename extension for material files when writing OBJs
/// default is currently .mat
std::string material_file_extension;
public:
/// Default constructor
Options() : flags_( Default )
Options() : texture_file(""), material_file_extension(".mat"), flags_( Default )
{ }
/// Copy constructor
Options(const Options& _opt) : flags_(_opt.flags_)
{ }
/// Initializing constructor setting a single option
Options(Flag _flg) : flags_( _flg)
{ }
/// Initializing constructor setting multiple options
/// Initializing constructor setting multiple options
Options(const value_type _flgs) : flags_( _flgs)
{ }
~Options()
{ }
/// Restore state after default constructor.
void cleanup(void)
{ flags_ = Default; }
@@ -154,17 +148,9 @@ public:
public:
//@{
/// Copy options defined in _rhs.
Options& operator = ( const Options& _rhs )
{ flags_ = _rhs.flags_; return *this; }
Options& operator = ( const value_type _rhs )
{ flags_ = _rhs; return *this; }
//@}
//@{
/// Unset options defined in _rhs.

View File

@@ -330,7 +330,7 @@ struct binary< std::vector< T >, typename std::enable_if<std::is_default_constru
typedef typename value_type::value_type elem_type;
static const bool is_streamable = binary<T>::is_streamable;
static size_t size_of(bool _store_size = true)
static size_t size_of(bool /*_store_size*/ = true)
{ return IO::UnknownSize; }
static size_t size_of(const value_type& _v, bool _store_size = true)
@@ -424,7 +424,7 @@ struct binary< std::vector< T >, typename std::enable_if<std::is_default_constru
}
};
#include <OpenMesh/Core/IO/SR_binary_vector_of_bool.inl>
#include <OpenMesh/Core/IO/SR_binary_vector_of_bool.hh>
// ----------------------------------------------------------------------------

View File

@@ -6,7 +6,7 @@ template <> struct binary< std::vector<bool> >
static const bool is_streamable = true;
static size_t size_of(bool _store_size = true) { return UnknownSize; }
static size_t size_of(bool /*_store_size*/ = true) { return UnknownSize; }
static size_t size_of(const value_type& _v, bool _store_size = true)
{
size_t size = _v.size() / 8 + ((_v.size() % 8)!=0);

View File

@@ -130,26 +130,31 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
size_t _OBJWriter_::getMaterial(OpenMesh::Vec3f _color) const
{
for (size_t i=0; i < material_.size(); i++)
if(material_[i] == _color)
return i;
auto idx_it = material_idx_.find(_color);
if (idx_it != material_idx_.end()) {
return idx_it->second;
} else {
size_t idx = material_.size();
material_.push_back(_color);
material_idx_[_color] = idx;
//not found add new material
material_.push_back( _color );
return material_.size()-1;
return idx;
}
}
//-----------------------------------------------------------------------------
size_t _OBJWriter_::getMaterial(OpenMesh::Vec4f _color) const
{
for (size_t i=0; i < materialA_.size(); i++)
if(materialA_[i] == _color)
return i;
//not found add new material
materialA_.push_back( _color );
return materialA_.size()-1;
auto idx_it = materialA_idx_.find(_color);
if (idx_it != materialA_idx_.end()) {
return idx_it->second;
} else {
size_t idx = materialA_.size();
materialA_.push_back(_color);
materialA_idx_[_color] = idx;
return idx;
}
}
//-----------------------------------------------------------------------------
@@ -162,7 +167,9 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
OpenMesh::Vec4f cA;
material_.clear();
material_idx_.clear();
materialA_.clear();
materialA_idx_.clear();
//iterate over faces
for (size_t i=0, nF=_be.n_faces(); i<nF; ++i)
@@ -195,6 +202,9 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << "illum 1" << '\n';
}
if (_opt.texture_file != "") {
_out << "map_Kd " << _opt.texture_file << std::endl;
}
return true;
}
@@ -219,8 +229,10 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
_out.precision(_precision);
// check exporter features
if (!check( _be, _opt))
return false;
if (!check( _be, _opt)) {
return false;
}
// No binary mode for OBJ
if ( _opt.check(Options::Binary) ) {
@@ -240,9 +252,9 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
}
//create material file if needed
if ( _opt.check(Options::FaceColor) ){
if ( _opt.check(Options::FaceColor) || _opt.texture_file != ""){
std::string matFile = path_ + objName_ + ".mat";
std::string matFile = path_ + objName_ + _opt.material_file_extension;
std::fstream matStream(matFile.c_str(), std::ios_base::out );
@@ -262,8 +274,8 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
_out << _be.n_faces() << " faces" << '\n';
// material file
if (useMatrial && _opt.check(Options::FaceColor) )
_out << "mtllib " << objName_ << ".mat" << '\n';
if ( (useMatrial && _opt.check(Options::FaceColor)) || _opt.texture_file != "")
_out << "mtllib " << objName_ << _opt.material_file_extension << '\n';
std::map<Vec2f,int> texMap;
//collect Texturevertices from halfedges
@@ -387,7 +399,9 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
}
material_.clear();
material_idx_.clear();
materialA_.clear();
materialA_idx_.clear();
return true;
}

View File

@@ -103,7 +103,9 @@ private:
mutable std::string objName_;
mutable std::vector< OpenMesh::Vec3f > material_;
mutable std::map< OpenMesh::Vec3f, size_t> material_idx_;
mutable std::vector< OpenMesh::Vec4f > materialA_;
mutable std::map< OpenMesh::Vec4f, size_t> materialA_idx_;
size_t getMaterial(OpenMesh::Vec3f _color) const;

View File

@@ -135,7 +135,7 @@ private:
writeValue(_type, _out, _value);
}
template<typename T>
void writeProxy(ValueType _type, std::ostream& _out, T _value, OpenMesh::GenProg::FalseType /*_binary*/) const
void writeProxy(ValueType /*_type*/, std::ostream& _out, T _value, OpenMesh::GenProg::FalseType /*_binary*/) const
{
_out << " " << _value;
}

View File

@@ -456,13 +456,7 @@ public:
}
/// calculated and returns the average of the two vertex normals
Normal calc_normal(EdgeHandle _eh) const
{
HalfedgeHandle _heh = this->halfedge_handle(_eh, 0);
VertexHandle vh0 = this->from_vertex_handle(_heh);
VertexHandle vh1 = this->to_vertex_handle(_heh);
return 0.5 * (this->calc_normal(vh0) + this->calc_normal(vh1));
}
Normal calc_normal(EdgeHandle _eh) const;
/** defines a consistent representation of a sector geometry:
the halfedge _in_heh defines the sector orientation

View File

@@ -109,7 +109,7 @@ PolyMeshT<Kernel>::calc_face_normal_impl(FaceHandle _fh, PointIs3DTag) const
{
assert(this->halfedge_handle(_fh).is_valid());
ConstFaceVertexIter fv_it(this->cfv_iter(_fh));
// Safeguard for 1-gons
if (!(++fv_it).is_valid()) return Normal(0, 0, 0);
@@ -140,7 +140,7 @@ PolyMeshT<Kernel>::calc_face_normal_impl(FaceHandle _fh, PointIs3DTag) const
}
const typename vector_traits<Normal>::value_type length = norm(n);
// The expression ((n *= (1.0/norm)),n) is used because the OpenSG
// vector class does not return self after component-wise
// self-multiplication with a scalar!!!
@@ -401,8 +401,8 @@ calc_halfedge_normal(HalfedgeHandle _heh, const double _feature_angle) const
}
Normal n(0,0,0);
for(unsigned int i=0; i<fhs.size(); ++i)
n += Kernel::normal(fhs[i]);
for (unsigned int i = 0; i < fhs.size(); ++i)
n += Kernel::has_face_normals() ? Kernel::normal(fhs[i]) : calc_face_normal(fhs[i]);
return normalize(n);
}
@@ -424,6 +424,28 @@ calc_normal(HalfedgeHandle _heh, const double _feature_angle) const
//-----------------------------------------------------------------------------
template <class Kernel>
typename PolyMeshT<Kernel>::Normal
PolyMeshT<Kernel>::
calc_normal(EdgeHandle _eh) const
{
Normal n(0);
for (int i = 0; i < 2; ++i)
{
const auto heh = this->halfedge_handle(_eh, i);
const auto fh = this->face_handle(heh);
if (fh.is_valid())
n += calc_normal(fh);
}
const auto length = norm(n);
if (length != 0)
n /= length;
return n;
}
//-----------------------------------------------------------------------------
template <class Kernel>
bool
PolyMeshT<Kernel>::
@@ -444,8 +466,8 @@ is_estimated_feature_edge(HalfedgeHandle _heh, const double _feature_angle) cons
FaceHandle fh0 = Kernel::face_handle(_heh);
FaceHandle fh1 = Kernel::face_handle(Kernel::opposite_halfedge_handle(_heh));
Normal fn0 = Kernel::normal(fh0);
Normal fn1 = Kernel::normal(fh1);
Normal fn0 = Kernel::has_face_normals() ? Kernel::normal(fh0) : calc_face_normal(fh0);
Normal fn1 = Kernel::has_face_normals() ? Kernel::normal(fh1) : calc_face_normal(fh1);
// dihedral angle above angle threshold
return ( dot(fn0,fn1) < cos(_feature_angle) );

View File

@@ -1,29 +1,98 @@
include (VCICommon)
include_directories (
../..
${CMAKE_CURRENT_SOURCE_DIR}
set ( headers
Decimater/BaseDecimaterT.hh
Decimater/BaseDecimaterT_impl.hh
Decimater/CollapseInfoT.hh
Decimater/DecimaterT.hh
Decimater/DecimaterT_impl.hh
Decimater/McDecimaterT.hh
Decimater/McDecimaterT_impl.hh
Decimater/MixedDecimaterT.hh
Decimater/MixedDecimaterT_impl.hh
Decimater/ModAspectRatioT.hh
Decimater/ModAspectRatioT_impl.hh
Decimater/ModBaseT.hh
Decimater/ModEdgeLengthT.hh
Decimater/ModEdgeLengthT_impl.hh
Decimater/ModHausdorffT.hh
Decimater/ModHausdorffT_impl.hh
Decimater/ModIndependentSetsT.hh
Decimater/ModNormalDeviationT.hh
Decimater/ModNormalFlippingT.hh
Decimater/ModProgMeshT.hh
Decimater/ModProgMeshT_impl.hh
Decimater/ModQuadricT.hh
Decimater/ModQuadricT_impl.hh
Decimater/ModRoundnessT.hh
Decimater/Observer.hh
Dualizer/meshDualT.hh
Smoother/JacobiLaplaceSmootherT.hh
Smoother/JacobiLaplaceSmootherT_impl.hh
Smoother/LaplaceSmootherT.hh
Smoother/LaplaceSmootherT_impl.hh
Smoother/SmootherT.hh
Smoother/SmootherT_impl.hh
Smoother/smooth_mesh.hh
Subdivider/Adaptive/Composite/CompositeT.hh
Subdivider/Adaptive/Composite/CompositeT_impl.hh
Subdivider/Adaptive/Composite/CompositeTraits.hh
Subdivider/Adaptive/Composite/RuleInterfaceT.hh
Subdivider/Adaptive/Composite/RulesT.hh
Subdivider/Adaptive/Composite/RulesT_impl.hh
Subdivider/Adaptive/Composite/Traits.hh
Subdivider/Uniform/Composite/CompositeT.hh
Subdivider/Uniform/Composite/CompositeT_impl.hh
Subdivider/Uniform/Composite/CompositeTraits.hh
Subdivider/Uniform/CatmullClarkT.hh
Subdivider/Uniform/CatmullClarkT_impl.hh
Subdivider/Uniform/CompositeLoopT.hh
Subdivider/Uniform/CompositeSqrt3T.hh
Subdivider/Uniform/LongestEdgeT.hh
Subdivider/Uniform/LoopT.hh
Subdivider/Uniform/MidpointT.hh
Subdivider/Uniform/ModifiedButterFlyT.hh
Subdivider/Uniform/Sqrt3InterpolatingSubdividerLabsikGreinerT.hh
Subdivider/Uniform/Sqrt3T.hh
Subdivider/Uniform/SubdividerT.hh
Utils/Config.hh
Utils/GLConstAsString.hh
Utils/Gnuplot.hh
Utils/HeapT.hh
Utils/MeshCheckerT.hh
Utils/MeshCheckerT_impl.hh
Utils/NumLimitsT.hh
Utils/StripifierT.hh
Utils/StripifierT_impl.hh
Utils/TestingFramework.hh
Utils/Timer.hh
Utils/conio.hh
VDPM/MeshTraits.hh
VDPM/StreamingDef.hh
VDPM/VFront.hh
VDPM/VHierarchy.hh
VDPM/VHierarchyNode.hh
VDPM/VHierarchyNodeIndex.hh
VDPM/VHierarchyWindow.hh
VDPM/ViewingParameters.hh
)
# source code directories
set (directories
.
Decimater
Dualizer
Smoother
Subdivider/Adaptive/Composite
Subdivider/Uniform/Composite
Subdivider/Uniform
Utils
VDPM
set ( sources
Decimater/Observer.cc
Utils/Gnuplot.cc
Utils/Timer.cc
Utils/conio.cc
VDPM/VFront.cc
VDPM/VHierarchy.cc
VDPM/VHierarchyNodeIndex.cc
VDPM/VHierarchyWindow.cc
VDPM/ViewingParameters.cc
)
# collect all header and source files
vci_append_files (headers "*.hh" ${directories})
vci_append_files (sources "*.cc" ${directories})
IF(WIN32 AND NOT MINGW)
vci_append_files (sources "*.c" ${directories})
list(APPEND sources "Utils/getopt.c")
ENDIF(WIN32 AND NOT MINGW)
# Disable Library installation when not building OpenMesh on its own but as part of another project!
@@ -42,8 +111,21 @@ if (WIN32)
vci_add_library (OpenMeshTools STATIC ${sources} ${headers})
endif()
target_include_directories(OpenMeshTools PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
else ()
vci_add_library (OpenMeshTools SHAREDANDSTATIC ${sources} ${headers})
target_include_directories(OpenMeshTools PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
target_include_directories(OpenMeshToolsStatic PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
set_target_properties (OpenMeshTools PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} )
endif ()
@@ -104,9 +186,8 @@ else()
endif()
if (NOT APPLE AND NOT ${OPENMESH_NO_INSTALL_HEADERS})
# Install Header Files
install(DIRECTORY .
# Install Header Files
install(DIRECTORY .
DESTINATION include/OpenMesh/Tools
FILES_MATCHING
PATTERN "*.hh"
@@ -116,15 +197,10 @@ install(DIRECTORY .
PATTERN "Templates" EXCLUDE
PATTERN "Debian*" EXCLUDE)
#install the config file
install(FILES Utils/getopt.h DESTINATION include/OpenMesh/Tools/Utils)
#install the config file
install(FILES Utils/getopt.h DESTINATION include/OpenMesh/Tools/Utils)
endif ()
target_include_directories(OpenMeshTools PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
$<INSTALL_INTERFACE:include>)
install(TARGETS OpenMeshTools EXPORT OpenMeshConfig
ARCHIVE DESTINATION ${VCI_PROJECT_LIBDIR}
LIBRARY DESTINATION ${VCI_PROJECT_LIBDIR}

View File

@@ -68,16 +68,16 @@ typename ModAspectRatioT<MeshT>::Scalar ModAspectRatioT<MeshT>::aspectRatio(
Point d1 = _v1 - _v2;
// finds the max squared edge length
Scalar l2, maxl2 = d0.sqrnorm();
if ((l2 = d1.sqrnorm()) > maxl2)
Scalar l2, maxl2 = sqrnorm(d0);
if ((l2 = sqrnorm(d1)) > maxl2)
maxl2 = l2;
// keep searching for the max squared edge length
d1 = _v2 - _v0;
if ((l2 = d1.sqrnorm()) > maxl2)
if ((l2 = sqrnorm(d1)) > maxl2)
maxl2 = l2;
// squared area of the parallelogram spanned by d0 and d1
Scalar a2 = (d0 % d1).sqrnorm();
Scalar a2 = sqrnorm(d0 % d1);
// the area of the triangle would be
// sqrt(a2)/2 or length * height / 2

View File

@@ -72,7 +72,7 @@ ModEdgeLengthT<MeshT>::ModEdgeLengthT(MeshT &_mesh, float _edge_length,
template<class MeshT>
float ModEdgeLengthT<MeshT>::collapse_priority(const CollapseInfo& _ci) {
typename Mesh::Scalar sqr_length = (_ci.p0 - _ci.p1).sqrnorm();
typename Mesh::Scalar sqr_length = sqrnorm(_ci.p0 - _ci.p1);
return ( (sqr_length <= sqr_edge_length_) ? sqr_length : float(Base::ILLEGAL_COLLAPSE));
}

View File

@@ -76,7 +76,7 @@ distPointTriangleSquared( const Point& _p,
const Point v0v1 = _v1 - _v0;
const Point v0v2 = _v2 - _v0;
const Point n = v0v1 % v0v2; // not normalized !
const Scalar d = n.sqrnorm();
const Scalar d = sqrnorm(n);
// Check if the triangle is degenerated
@@ -88,9 +88,9 @@ distPointTriangleSquared( const Point& _p,
// these are not needed for every point, should still perform
// better with many points against one triangle
const Point v1v2 = _v2 - _v1;
const Scalar inv_v0v2_2 = static_cast<Scalar>(1.0) / v0v2.sqrnorm();
const Scalar inv_v0v1_2 = static_cast<Scalar>(1.0) / v0v1.sqrnorm();
const Scalar inv_v1v2_2 = static_cast<Scalar>(1.0) / v1v2.sqrnorm();
const Scalar inv_v0v2_2 = static_cast<Scalar>(1.0) / sqrnorm(v0v2);
const Scalar inv_v0v1_2 = static_cast<Scalar>(1.0) / sqrnorm(v0v1);
const Scalar inv_v1v2_2 = static_cast<Scalar>(1.0) / sqrnorm(v1v2);
Point v0p = _p - _v0;
@@ -177,10 +177,10 @@ distPointTriangleSquared( const Point& _p,
}
} else {
// Calculate the distance to an interior point of the triangle
return ( (_p - n*((n|v0p) * invD)) - _p).sqrnorm();
return sqrnorm( (_p - n*((n|v0p) * invD)) - _p);
}
return (v0p - _p).sqrnorm();
return sqrnorm(v0p - _p);
}

View File

@@ -287,10 +287,10 @@ public: // specific methods
Vec3f vecAB = B-A;
// compute squared values to avoid sqrt-computations
value_type aa = (B-C).sqrnorm();
value_type bb = vecAC.sqrnorm();
value_type cc = vecAB.sqrnorm();
value_type AA = cross(vecAC,vecAB).sqrnorm(); // without factor 1/4 **)
value_type aa = sqrnorm(B-C);
value_type bb = sqrnorm(vecAC);
value_type cc = sqrnorm(vecAB);
value_type AA = sqrnorm(cross(vecAC,vecAB)); // without factor 1/4 **)
if ( AA < epsilon )
return 0.0;

View File

@@ -160,7 +160,7 @@ protected:
const typename MeshType::Point to = _m.point(_m.to_vertex_handle(_m.halfedge_handle(*eit,0)));
const typename MeshType::Point from = _m.point(_m.from_vertex_handle(_m.halfedge_handle(*eit,0)));
real_t length = (to - from).sqrnorm();
real_t length = sqrnorm(to - from);
// Only push the edges that need to be split
if ( length > max_edge_length_squared_ )
@@ -187,7 +187,7 @@ protected:
typename MeshType::EdgeHandle eh = _m.edge_handle(*voh_it);
const typename MeshType::Point to = _m.point(_m.to_vertex_handle(*voh_it));
const typename MeshType::Point from = _m.point(_m.from_vertex_handle(*voh_it));
real_t length = (to - from).sqrnorm();
real_t length = sqrnorm(to - from);
// Only push the edges that need to be split
if ( length > max_edge_length_squared_ )

View File

@@ -1,10 +1,68 @@
include (VCICommon)
include_directories (
..
${CMAKE_CURRENT_SOURCE_DIR}
set( UNITTEST_SRC
unittests.cc
unittests_add_face.cc
unittests_boundary.cc
unittests_centroid_calculations.cc
unittests_convert_meshes.cc
unittests_cpp_11_features.cc
unittests_decimater.cc
unittests_delete_face.cc
unittests_eigen3_type.cc
unittests_faceless_mesh.cc
unittests_mc_decimater.cc
unittests_mesh_cast.cc
unittests_mesh_dual.cc
unittests_mesh_type.cc
unittests_mixed_decimater.cc
unittests_normal_calculations.cc
unittests_polymesh_collapse.cc
unittests_polymesh_vec2i.cc
unittests_property.cc
unittests_propertymanager.cc
unittests_randomNumberGenerator.cc
unittests_read_write_OBJ.cc
unittests_read_write_OFF.cc
unittests_read_write_OM.cc
unittests_read_write_PLY.cc
unittests_read_write_STL.cc
unittests_set_positions_directly.cc
unittests_smart_handles.cc
unittests_smart_ranges.cc
unittests_smarttagger.cc
unittests_smoother.cc
unittests_split_copy.cc
unittests_split_edge_copy.cc
unittests_sr_binary.cc
unittests_stripifier.cc
unittests_subdivider_adaptive.cc
unittests_subdivider_uniform.cc
unittests_trimesh_circulator_current_halfedge_handle_replacement.cc
unittests_trimesh_circulator_face_edge.cc
unittests_trimesh_circulator_face_face.cc
unittests_trimesh_circulator_face_halfedge.cc
unittests_trimesh_circulator_face_vertex.cc
unittests_trimesh_circulator_halfedge_loop.cc
unittests_trimesh_circulator_vertex_edge.cc
unittests_trimesh_circulator_vertex_face.cc
unittests_trimesh_circulator_vertex_ihalfedge.cc
unittests_trimesh_circulator_vertex_ohalfedge.cc
unittests_trimesh_circulator_vertex_vertex.cc
unittests_trimesh_collapse.cc
unittests_trimesh_garbage_collection.cc
unittests_trimesh_iterators.cc
unittests_trimesh_others.cc
unittests_trimesh_ranges.cc
unittests_trimesh_split.cc
unittests_trimesh_vec2i.cc
unittests_tutorials.cc
unittests_vdpm.cc
unittests_vector_type.cc
)
if ( NOT DEFINED OPENMESH_BUILD_UNIT_TESTS)
set( OPENMESH_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit test builds in OpenMesh." )
endif()
@@ -35,7 +93,6 @@ if ( OPENMESH_BUILD_UNIT_TESTS )
endif()
# Create new target named unittests_hexmeshing
FILE(GLOB UNITTEST_SRC *.cc)
# Create unittest executable
vci_add_executable(unittests ${UNITTEST_SRC})
vci_add_executable(unittests_customvec ${UNITTEST_SRC})

View File

@@ -9,10 +9,13 @@
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
#include <OpenMesh/Tools/Decimater/ModEdgeLengthT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
#include <OpenMesh/Core/Geometry/EigenVectorT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3T.hh>
struct EigenTraits : OpenMesh::DefaultTraits {
using Point = Eigen::Vector3d;
using Normal = Eigen::Vector3d;
@@ -266,6 +269,141 @@ TEST_F(OpenMeshEigenTest, Decimater) {
EXPECT_EQ(1052u, mesh_.n_faces()) << "The number of faces after decimation is not correct!";
}
// Test decimation with Eigen as vector type
TEST_F(OpenMeshEigenTest, DecimaterWithEdgeLength) {
mesh_.clear();
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
EXPECT_TRUE(ok);
EXPECT_EQ(7526u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(22572u, mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(15048u, mesh_.n_faces()) << "The number of loaded faces is not correct!";
mesh_.update_normals();
OpenMesh::Decimater::DecimaterT<EigenTriMesh> decimater(mesh_);
OpenMesh::Decimater::ModEdgeLengthT<EigenTriMesh>::Handle hModEdgeLength; // use a the edge length module
OpenMesh::Decimater::ModNormalDeviationT<EigenTriMesh>::Handle hModNormalDeviation; // also use normal deviation module as binary check
decimater.add(hModEdgeLength);
decimater.module(hModEdgeLength).set_edge_length(30.0);
decimater.add(hModNormalDeviation);
decimater.module(hModNormalDeviation).set_normal_deviation(50);
decimater.initialize();
size_t removedVertices = decimater.decimate_to(2);
mesh_.garbage_collection();
EXPECT_EQ(0u, removedVertices) << "The number of remove vertices is not correct!";
EXPECT_EQ( 7526u, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!";
EXPECT_EQ(22572u, mesh_.n_edges()) << "The number of edges after decimation is not correct!";
EXPECT_EQ(15048u, mesh_.n_faces()) << "The number of faces after decimation is not correct!";
}
TEST_F(OpenMeshEigenTest, Subdivider_Sqrt3) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[9];
vhandle[0] = mesh_.add_vertex(EigenTriMesh::Point(0, 0, 0));
vhandle[1] = mesh_.add_vertex(EigenTriMesh::Point(0, 1, 0));
vhandle[2] = mesh_.add_vertex(EigenTriMesh::Point(0, 2, 0));
vhandle[3] = mesh_.add_vertex(EigenTriMesh::Point(1, 0, 0));
vhandle[4] = mesh_.add_vertex(EigenTriMesh::Point(1, 1, 0));
vhandle[5] = mesh_.add_vertex(EigenTriMesh::Point(1, 2, 0));
vhandle[6] = mesh_.add_vertex(EigenTriMesh::Point(2, 0, 0));
vhandle[7] = mesh_.add_vertex(EigenTriMesh::Point(2, 1, 0));
vhandle[8] = mesh_.add_vertex(EigenTriMesh::Point(2, 2, 0));
// Add eight faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[4]);
face_vhandles.push_back(vhandle[3]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[5]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[7]);
face_vhandles.push_back(vhandle[6]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
face_vhandles.push_back(vhandle[7]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[4]);
face_vhandles.push_back(vhandle[8]);
face_vhandles.push_back(vhandle[7]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[4]);
face_vhandles.push_back(vhandle[5]);
face_vhandles.push_back(vhandle[8]);
mesh_.add_face(face_vhandles);
// Test setup:
// 6 === 7 === 8
// | / | / |
// | / | / |
// | / | / |
// 3 === 4 === 5
// | / | \ |
// | / | \ |
// | / | \ |
// 0 === 1 === 2
// Initialize subdivider
OpenMesh::Subdivider::Uniform::Sqrt3T<EigenTriMesh> sqrt3;
// Check setup
EXPECT_EQ(9u, mesh_.n_vertices() ) << "Wrong number of vertices";
EXPECT_EQ(8u, mesh_.n_faces() ) << "Wrong number of faces";
// Execute 3 subdivision steps
sqrt3.attach(mesh_);
sqrt3( 3 );
sqrt3.detach();
// Check setup
EXPECT_EQ(121u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with sqrt3";
EXPECT_EQ(216u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with sqrt3";
}
}
#endif

View File

@@ -93,6 +93,7 @@ void compare_ranges(RangeT1&& range1, RangeT2&& range2, int offset, bool reverse
size_t n = vec1.size();
/*
std::cout << "Vec1 elements: ";
for (auto el : vec1)
std::cout << el.idx() << " ";
@@ -102,6 +103,7 @@ void compare_ranges(RangeT1&& range1, RangeT2&& range2, int offset, bool reverse
for (auto el : vec2)
std::cout << el.idx() << " ";
std::cout << std::endl;
*/
for (size_t i = 0; i < n; ++i)
{