63 #ifndef OPENMESH_MESH_DUAL_H
64 #define OPENMESH_MESH_DUAL_H
70 #if defined(OM_CC_MIPS)
76 #include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
77 #include <OpenMesh/Core/Utils/Property.hh>
94 template <
typename MeshTraits>
95 PolyMesh_ArrayKernelT<MeshTraits>* MeshDual (PolyMesh_ArrayKernelT<MeshTraits> &primal)
97 PolyMesh_ArrayKernelT<MeshTraits>* dual =
new PolyMesh_ArrayKernelT<MeshTraits>();
102 FPropHandleT< typename PolyMesh_ArrayKernelT<MeshTraits>::VertexHandle > primalToDual;
103 primal.add_property(primalToDual);
106 for(
typename PolyMesh_ArrayKernelT<MeshTraits>::ConstFaceIter fit=primal.faces_begin(); fit!=primal.faces_end(); ++fit)
108 typename PolyMesh_ArrayKernelT<MeshTraits>::Point centerPoint(0,0,0);
109 typename PolyMesh_ArrayKernelT<MeshTraits>::Scalar degree= 0.0;
110 for(
typename PolyMesh_ArrayKernelT<MeshTraits>::ConstFaceVertexIter vit=primal.cfv_iter(*fit); vit.is_valid(); ++vit, ++degree)
111 centerPoint += primal.point(*vit);
113 centerPoint /= degree;
114 primal.property(primalToDual, *fit) = dual->add_vertex(centerPoint);
118 std::vector< typename PolyMesh_ArrayKernelT<MeshTraits>::VertexHandle > face_vhandles;
119 for(
typename PolyMesh_ArrayKernelT<MeshTraits>::ConstVertexIter vit=primal.vertices_begin(); vit!=primal.vertices_end(); ++vit)
121 if(!primal.is_boundary(*vit))
123 face_vhandles.clear();
124 for(
typename PolyMesh_ArrayKernelT<MeshTraits>::ConstVertexFaceIter fit=primal.cvf_iter(*vit); fit.is_valid(); ++fit)
125 face_vhandles.push_back(primal.property(primalToDual, *fit));
126 dual->add_face(face_vhandles);
130 primal.remove_property(primalToDual);
142 #endif // OPENMESH_MESH_DUAL_H defined