Commit f8eb2730 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'featureMeshConversion' into 'master'

Feature mesh conversion

implements a cast from polyMesh to Mesh and vice versa using  static_cast<Mesh>(polymeshInstance) or static_cast<PolyMesh>(trimeshInstance)
as mentioned in #23 .

Copy constructors for respective mesh types were added as well as a function to copy all properties from one mesh to another.
Unittest for mesh conversions were added checking the number of vertices / faces as well as custom double vertex properties and edge properties.

Note: The used triangulation only works for convex polygons, it should be replaced by the earclipping triangulation mentioned in #33

See merge request !110
parents 46c87795 104635d5
Pipeline #3981 passed with stage
in 40 minutes and 56 seconds
......@@ -10,6 +10,7 @@
<b>Core</b>
<ul>
<li>Implemented a cast from polyMesh to Mesh and vice versa using static_cast(polymeshInstance) or static_cast(trimeshInstance)</li>
<li>make all negative handles invalid, not just -1</li>
<li>Several warnings fixed (Including the checked iterators)</li>
</ul>
......
......@@ -583,6 +583,18 @@ public:
}
/**
* @brief copy_all_kernel_properties uses the = operator to copy all properties from a given other BaseKernel.
* @param _other Another BaseKernel, to copy the properties from.
*/
void copy_all_kernel_properties(const BaseKernel & _other)
{
this->vprops_ = _other.vprops_;
this->eprops_ = _other.eprops_;
this->hprops_ = _other.hprops_;
this->fprops_ = _other.fprops_;
}
protected: //------------------------------------------------- low-level access
public: // used by non-native kernel and MeshIO, should be protected
......
......@@ -186,6 +186,8 @@ public:
// --- constructor/destructor
PolyMeshT() {}
template<typename T>
explicit PolyMeshT(const T& t) : Kernel(t) {}
virtual ~PolyMeshT() {}
/** Uses default copy and assignment operator.
......
......@@ -74,7 +74,8 @@
namespace OpenMesh {
template<class Traits>
class TriMesh_ArrayKernelT;
//== CLASS DEFINITION =========================================================
/// Helper class to build a PolyMesh-type
......@@ -97,7 +98,18 @@ struct PolyMesh_ArrayKernel_GeneratorT
template <class Traits = DefaultTraits>
class PolyMesh_ArrayKernelT
: public PolyMesh_ArrayKernel_GeneratorT<Traits>::Mesh
{};
{
public:
PolyMesh_ArrayKernelT() {}
template<class OtherTraits>
PolyMesh_ArrayKernelT( const TriMesh_ArrayKernelT<OtherTraits> & t)
{
//assign the connectivity (add vertices)
this->assign(t);
//copy properties from triMesh
this->copy_all_kernel_properties(t);
}
};
//=============================================================================
......
......@@ -169,6 +169,10 @@ public:
/// Default constructor
TriMeshT() : PolyMesh() {}
explicit TriMeshT(PolyMesh rhs) : PolyMesh((rhs.triangulate(), rhs))
{
}
/// Destructor
virtual ~TriMeshT() {}
......
......@@ -74,7 +74,8 @@
namespace OpenMesh {
template<class Traits>
class PolyMesh_ArrayKernelT;
//== CLASS DEFINITION =========================================================
......@@ -97,7 +98,18 @@ struct TriMesh_ArrayKernel_GeneratorT
template <class Traits = DefaultTraits>
class TriMesh_ArrayKernelT
: public TriMesh_ArrayKernel_GeneratorT<Traits>::Mesh
{};
{
public:
TriMesh_ArrayKernelT() {}
template<class OtherTraits>
TriMesh_ArrayKernelT( const PolyMesh_ArrayKernelT<OtherTraits> & t)
{
//assign the connectivity (add vertices)
this->assign(t);
//copy properties from polyMesh
this->copy_all_kernel_properties(t);
}
};
//=============================================================================
......
This diff is collapsed.
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