From a9202ed7db4020ba7cbc7603ac1232d7f82acdff Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 26 Aug 2014 01:40:46 +0000 Subject: [PATCH] Added method BuildFromNonFaux to build an edgemesh composed by the "non faux edges". --- vcg/complex/algorithms/create/platonic.h | 49 +++++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/vcg/complex/algorithms/create/platonic.h b/vcg/complex/algorithms/create/platonic.h index dd6079aa..ae53a2c3 100644 --- a/vcg/complex/algorithms/create/platonic.h +++ b/vcg/complex/algorithms/create/platonic.h @@ -655,6 +655,35 @@ void Build( MeshType & in, const V & v) Build(in,v,dummyfaceVec); } + +template +void BuildFromNonFaux(TriMeshType &in, EdgeMeshType &out) +{ + tri::RequireCompactness(in); + std::vector::PEdge> edgevec; + tri::UpdateTopology::FillUniqueEdgeVector(in, edgevec, false); + out.Clear(); + for(size_t i=0;i::AddVertex(out, in.vert[i].P()); + tri::UpdateFlags::VertexClearV(out); + + for(size_t i=0;i::AddEdge(out,&out.vert[i0],&out.vert[i1]); + if(in.vert[i0].IsS()) out.vert[i0].SetS(); + if(in.vert[i1].IsS()) out.vert[i1].SetS(); + } + + for(size_t i=0;i::DeleteVertex(out,out.vert[i]); + + tri::Allocator::CompactEveryVector(out); +} + // Build a regular grid mesh as a typical height field mesh // x y are the position on the grid scaled by wl and hl (at the end x is in the range 0..wl and y is in 0..hl) // z is taken from the array @@ -869,18 +898,18 @@ void Disk(MeshType & m, int slices) template void OrientedDisk(MeshType &m, int slices, typename MeshType::CoordType center, typename MeshType::CoordType norm, float radius) { - typedef typename MeshType::ScalarType ScalarType; - typedef typename MeshType::CoordType CoordType; + typedef typename MeshType::ScalarType ScalarType; + typedef typename MeshType::CoordType CoordType; - Disk(m,slices); - tri::UpdatePosition::Scale(m,radius); - ScalarType angleRad = Angle(CoordType(0,0,1),norm); - CoordType axis = CoordType(0,0,1)^norm; + Disk(m,slices); + tri::UpdatePosition::Scale(m,radius); + ScalarType angleRad = Angle(CoordType(0,0,1),norm); + CoordType axis = CoordType(0,0,1)^norm; - Matrix44 rotM; - rotM.SetRotateRad(angleRad,axis); - tri::UpdatePosition::Matrix(m,rotM); - tri::UpdatePosition::Translate(m,center); + Matrix44 rotM; + rotM.SetRotateRad(angleRad,axis); + tri::UpdatePosition::Matrix(m,rotM); + tri::UpdatePosition::Translate(m,center); } template