From 884faa97c1460ba1fd9c57f3af7d44f30accec37 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Sat, 5 May 2018 00:36:43 +0200 Subject: [PATCH] Added FillSelectedFaceEdgeVector FaceEdgeSelCrease and BuildFromFaceEdgeSel function It is much more meaningful to create a poly mesh from selected edges instead abusing of the faux edges bit Similarly it much butter to select crease edges for subsuequent uses --- vcg/complex/algorithms/create/platonic.h | 4 +-- vcg/complex/algorithms/update/flag.h | 40 +++++++++++------------- vcg/complex/algorithms/update/topology.h | 15 ++++++++- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/vcg/complex/algorithms/create/platonic.h b/vcg/complex/algorithms/create/platonic.h index 24f9333e..8b4d906e 100644 --- a/vcg/complex/algorithms/create/platonic.h +++ b/vcg/complex/algorithms/create/platonic.h @@ -768,11 +768,11 @@ void BuildMeshFromCoordVector( MeshType & in, const V & v) template -void BuildFromNonFaux(TriMeshType &in, EdgeMeshType &out) +void BuildFromFaceEdgeSel(TriMeshType &in, EdgeMeshType &out) { tri::RequireCompactness(in); std::vector::PEdge> edgevec; - tri::UpdateTopology::FillUniqueEdgeVector(in, edgevec, false); + tri::UpdateTopology::FillSelectedFaceEdgeVector(in, edgevec); out.Clear(); for(size_t i=0;i::AddVertex(out, in.vert[i].P()); diff --git a/vcg/complex/algorithms/update/flag.h b/vcg/complex/algorithms/update/flag.h index 359d3256..8963342a 100644 --- a/vcg/complex/algorithms/update/flag.h +++ b/vcg/complex/algorithms/update/flag.h @@ -122,10 +122,7 @@ public: static void FaceClearB(MeshType &m) { FaceClear(m,FaceType::BORDER012);} static void FaceClearS(MeshType &m) {FaceClear(m,FaceType::SELECTED);} static void FaceClearF(MeshType &m) { FaceClear(m,FaceType::FAUX012);} - static void FaceClearCreases(MeshType &m) { FaceClear(m,FaceType::CREASE0); - FaceClear(m,FaceType::CREASE1); - FaceClear(m,FaceType::CREASE2); - } + static void FaceClearFaceEdgeS(MeshType &m) { FaceClear(m,FaceType::FACEEDGESEL012 ); } static void EdgeSetV(MeshType &m) { EdgeSet(m,EdgeType::VISITED);} static void VertexSetV(MeshType &m) { VertexSet(m,VertexType::VISITED);} @@ -380,20 +377,20 @@ public: /// \brief Marks feature edges according to two signed dihedral angles. - /// Actually it marks as fauxedges all the non feature edges, - /// e.g. the edges where the signed dihedral angle between the normal of two incident faces , - /// is between the two given thresholds. - /// In this way all the edges that are almost planar are marked as Faux Edges (e.g. edges to be ignored) + /// Actually it uses the face_edge selection bit on faces, + /// we select the edges where the signed dihedral angle between the normal of two incident faces , + /// is outside the two given thresholds. + /// In this way all the edges that are almost planar are marked as non selected (e.g. edges to be ignored) /// Note that it uses the signed dihedral angle convention (negative for concave edges and positive for convex ones); /// /// Optionally it can also mark as feature edges also the boundary edges. /// - static void FaceFauxSignedCrease(MeshType &m, float AngleRadNeg, float AngleRadPos, bool MarkBorderFlag = false ) + static void FaceEdgeSelSignedCrease(MeshType &m, float AngleRadNeg, float AngleRadPos, bool MarkBorderFlag = false ) { RequirePerFaceFlags(m); RequireFFAdjacency(m); //initially Nothing is faux (e.g all crease) - FaceClearF(m); + FaceClearFaceEdgeS(m); // Then mark faux only if the signed angle is the range. for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) { @@ -402,12 +399,12 @@ public: if(!face::IsBorder(*fi,z) ) { ScalarType angle = DihedralAngleRad(*fi,z); - if(angle>AngleRadNeg && angleAngleRadPos) + (*fi).SetFaceEdgeS(z); } else { - if(MarkBorderFlag) (*fi).SetF(z); + if(MarkBorderFlag) (*fi).SetFaceEdgeS(z); } } } @@ -416,29 +413,30 @@ public: /// \brief Marks feature edges according to border flag. /// Actually it marks as fauxedges all the non border edges, /// - static void FaceFauxBorder(MeshType &m) + static void FaceEdgeSelBorder(MeshType &m) { RequirePerFaceFlags(m); RequireFFAdjacency(m); //initially Nothing is faux (e.g all crease) - FaceClearF(m); + FaceClearFaceEdgeS(m); // Then mark faux only if the signed angle is the range. for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) { for(int z=0;z<(*fi).VN();++z) { - if(!face::IsBorder(*fi,z) ) (*fi).SetF(z); + if(!face::IsBorder(*fi,z) ) (*fi).SetFaceEdgeS(z); } } } /// \brief Marks feature edges according to a given angle - /// Actually it marks as fauxedges all the non feature edges, - /// e.g. the edge such that the angle between the normal of two faces sharing it is less than the given threshold. - /// In this way all the near planar edges are marked as Faux Edges (e.g. edges to be ignored) - static void FaceFauxCrease(MeshType &m,float AngleRad) + /// Actually it uses the face_edge selection bit on faces, + /// we select the edges where the dihedral angle between the normal of two incident faces is larger than , + /// the given thresholds. + /// In this way all the near planar edges are marked remains not selected (e.g. edges to be ignored) + static void FaceEdgeSelCrease(MeshType &m,float AngleRad) { - FaceFauxSignedCrease(m,-AngleRad,AngleRad); + FaceEdgeSelSignedCrease(m,-AngleRad,AngleRad); } diff --git a/vcg/complex/algorithms/update/topology.h b/vcg/complex/algorithms/update/topology.h index d37ddab5..3afd7168 100644 --- a/vcg/complex/algorithms/update/topology.h +++ b/vcg/complex/algorithms/update/topology.h @@ -138,6 +138,20 @@ static void FillUniqueEdgeVector(MeshType &m, std::vector &edgeVec, bool edgeVec.resize(newEnd-edgeVec.begin()); // redundant! remove? } +static void FillSelectedFaceEdgeVector(MeshType &m, std::vector &edgeVec) +{ + edgeVec.reserve(m.fn*3); + ForEachFace(m, [&](FaceType &f){ + for(int j=0;j vei(&*vi);!vei.End();++vei) cnt++; - EdgeType *vep = vi->VEp(); assert((numVertex[tri::Index(m,*vi)] == 0) == (vi->VEp()==0) ); assert(cnt==numVertex[tri::Index(m,*vi)]); }