/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2014 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ #ifndef __MIQ_PARAMETRIZATION_H #define __MIQ_PARAMETRIZATION_H //igl stuff #include #include #include #include #include #include #include #include #include namespace vcg { namespace tri { template < class MeshType> // Classe templatata su Tipo Mesh class MiQParametrizer { typedef typename MeshType::CoordType CoordType; typedef typename MeshType::VertexType VertexType; typedef typename MeshType::FaceType FaceType; typedef typename MeshType::ScalarType ScalarType; typedef typename MeshType::VertexType PolyVertexType; public: struct MIQParameters { //the gradient of the parametrization 1 is the bb diagonal, as big is the gradient as small are the quads double gradient; //do the rounding or not across cuts... set to true to get a quadrangulation bool doRound; //do the round at once for each stiffness iteration or do it gradually.. gradually is more stable but much mor slow bool directRound; //the stiffness increment for ach iteration double stiffness; //the maximum number ofstiffness iteration to avoid folds int stiffness_iter; //local iteration to round integer variables ofr each stiffness round int local_iter; //this bool multiply the gradiens U or V separately times a constant to make hexagons bool hexaLine; //the threshold of normal dot product to consider a crease double crease_thr; //number of 90° rotation independence (4 for quad meshing, 2 to obtain a quad meshing for hexagonalization) int Ndir; //round or not the singularities bool round_singularities; //use the crease edges as feature or not bool crease_as_feature; //true if roound selected vert bool round_selected; //the anisotropy in MIQ sense (see paper) double miqAnisotropy; MIQParameters() { gradient=80; doRound=true; directRound=true; round_singularities=true; crease_as_feature=false; round_selected=true; stiffness=5; stiffness_iter=10; local_iter=5; Ndir=4; crease_thr=0.2; hexaLine=false; miqAnisotropy=1; } }; static void GetFeatureLines(MeshType &trimesh, std::vector > &feature_lines) { feature_lines.clear(); for (size_t i=0;i()); feature_lines.back().push_back(i); feature_lines.back().push_back(j); } } } private: static void CrossFieldParam(MeshType &trimesh, MIQParameters &MiqP) { Eigen::MatrixXi F; Eigen::MatrixXd V; vcg::tri::MeshToMatrix::GetTriMeshData(trimesh,F,V); //then get the principal directions Eigen::MatrixXd X1,X2; X1=Eigen::MatrixXd(trimesh.FN(), 3); for (size_t i=0;i > hard_features; if (MiqP.crease_as_feature) GetFeatureLines(trimesh,hard_features); std::vector extra_round; if (MiqP.round_selected) { for (int i=0;i::GetTriMeshData(trimesh,F,V); //then get the principal directions Eigen::MatrixXd X1,X2; X1=Eigen::MatrixXd(trimesh.FN(), 3); for (size_t i=0;i > hard_features; std::vector extra_round; //collect extra vertex selected that need to be rounded if (MiqP.round_selected) { for (int i=0;iClearCrease(j); f0->ClearFaceEdgeS(j); } for (size_t i=0;iFFp(j); //if (f0==f1){f0->SetCrease(j);continue;} if (f0==f1){f0->SetFaceEdgeS(j);continue;} CoordType N0=f0->N(); CoordType N1=f1->N(); if ((N0*N1)>thr)continue; //f0->SetCrease(j); f0->SetFaceEdgeS(j); } } static void MIQParametrize(MeshType &trimesh, MIQParameters &MiqP) { // if (MiqP.crease_as_feature) // SetCreases(trimesh,MiqP.crease_thr); if (MiqP.Ndir==4) CrossFieldParam(trimesh,MiqP); else LineFieldParam(trimesh,MiqP); } }; } // end namespace tri } // end namespace vcg #endif // VORO_CLUSTER_H