Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Feb 23, 2022
2 parents 38c3a41 + e6546b3 commit e4950d1
Show file tree
Hide file tree
Showing 246 changed files with 55,181 additions and 1,555 deletions.
84 changes: 81 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Please do not add here all kind of intermediate files just by extension.
# Try whenever possible to match folder and to try to use
# building rules that put all the generated files into separate folders
# Rules to ignore all files without extension (binaries on unix)
# these rules must be above all the other rules
*
!/**/
!*.*

# QTCreator user prefs
*.user
Expand All @@ -15,6 +17,9 @@ release/
# Intermediate Files
*.bc

# osx rubbish
.DS_Store

# Visual Studio Project files
*.vcxproj
*.vcxproj.filters
Expand All @@ -25,3 +30,76 @@ wrap/nanoply/nanoply_vcg/nanoply_vcg.sln
wrap/nanoply/nanoply_vcg/nanoply_vcg.VC.VC.opendb
wrap/nanoply/nanoply_vcg/.vs/nanoply_vcg/v15/ipch/AutoPCH/NANOPLY_VCG-1b6b1a83/MAIN-5f62d91f/MAIN.ipch
*.sln

##Standard cmake gitignore##
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps

##standard Qt and C++ gitignore##
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
*.lib
*.exe
*.obj
*.res

# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
mocs_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl

# Qt unit tests
target_wrapper.*

# QtCreator
*.autosave

# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*

# QtCreator CMake
CMakeLists.txt.user*

# QtCreator 4.8< compilation database
compile_commands.json

# QtCreator local machine specific files for imported projects
*creator.user*
15 changes: 15 additions & 0 deletions apps/minimal_project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.13)
project(trimesh_base)
add_subdirectory(vcglib)
set(CMAKE_CXX_STANDARD 14)
set(SOURCES
simple_main.cpp)

add_executable(simple_main
${SOURCES})

target_link_libraries(
simple_main
PUBLIC
vcglib
)
74 changes: 74 additions & 0 deletions apps/minimal_project/simple_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2016 \/)\/ *
* 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. *
* *
****************************************************************************/
/*! \file trimesh_base.cpp
\ingroup code_sample
\brief the minimal example of using the lib
This file contain a minimal example of the library, showing how to load a mesh and how to compute per vertex normals on it.
*/

#include<vcg/complex/complex.h>
#include<wrap/io_trimesh/import_off.h>

class MyVertex; class MyEdge; class MyFace;
struct MyUsedTypes : public vcg::UsedTypes<vcg::Use<MyVertex> ::AsVertexType,
vcg::Use<MyEdge> ::AsEdgeType,
vcg::Use<MyFace> ::AsFaceType>{};

class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VertexRef, vcg::face::BitFlags > {};
class MyEdge : public vcg::Edge< MyUsedTypes> {};

class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};

class MyVertex0 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::BitFlags >{};
class MyVertex1 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
class MyVertex2 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Color4b, vcg::vertex::CurvatureDirf,
vcg::vertex::Qualityf, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};


int main( int argc, char **argv )
{
if(argc<2)
{
printf("Usage trimesh_base <meshfilename.off>\n");
return -1;
}
/*!
*/
MyMesh m;

if(vcg::tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=vcg::tri::io::ImporterOFF<MyMesh>::NoError)
{
printf("Error reading file %s\n",argv[1]);
exit(0);
}

vcg::tri::RequirePerVertexNormal(m);
vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFa
int main()
{
MyMesh m;
Torus<MyMesh>(m, 3.0f, 1.0f);
vcg::tri::Torus<MyMesh>(m, 3.0f, 1.0f);
//! [Adding a few attributes]
// add a per-vertex attribute with type float named "GaussianCurvature"
MyMesh::PerVertexAttributeHandle<float>
Expand Down
3 changes: 2 additions & 1 deletion apps/sample/trimesh_curvature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ project(trimesh_curvature)

if (VCG_HEADER_ONLY)
set(SOURCES
trimesh_curvature.cpp)
trimesh_curvature.cpp
${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp)
endif()

add_executable(trimesh_curvature
Expand Down
72 changes: 56 additions & 16 deletions apps/sample/trimesh_curvature/trimesh_curvature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,86 @@
/*! \file trimesh_curvature.cpp
\ingroup code_sample
\brief an example showing the various techniques for computing curvatures
\brief an example showing various techniques for computing curvatures
*/
#include <vcg/complex/complex.h>

#include <vcg/complex/algorithms/create/platonic.h>
#include <vcg/complex/algorithms/update/curvature.h>
#include <vcg/complex/algorithms/update/curvature_fitting.h>

#include<wrap/io_trimesh/export_off.h>
#include<wrap/io_trimesh/export_ply.h>

class MyEdge;
class MyFace;
class MyVertex;
struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
vcg::Use<MyEdge> ::AsEdgeType,
vcg::Use<MyFace> ::AsFaceType>{};

class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::VFAdj, vcg::vertex::CurvatureDirf, vcg::vertex::Curvaturef, vcg::vertex::BitFlags >{};
class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VFAdj, vcg::face::VertexRef, vcg::face::BitFlags > {};
class MyEdge : public vcg::Edge<MyUsedTypes>{};
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::VFAdj, vcg::vertex::Qualityf, vcg::vertex::CurvatureDirf, vcg::vertex::BitFlags >{};
class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VFAdj, vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::BitFlags > {};
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};

int main( int /*argc*/, char **/*argv*/ )
{
MyMesh m;
vcg::tri::Torus(m,30,10);
// in a torus with radii 1 and 4
// on the outside the principal curvature should be 1 and 1/5
// and internally the principal curvature should be 1 and -1/3
// Gaussian range -0.333 .. 0.200
// mean range 0.333 .. 0.600
//vcg::tri::Torus(m,4,1,32,16);


// in a sphere of radius 2 the curvature is everywhere 0.5
// Gaussian 0.25
// Mean 0.5
vcg::tri::Sphere(m,5);
vcg::tri::UpdatePosition<MyMesh>::Scale(m, 2.0);

vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
vcg::tri::UpdateTopology<MyMesh>::VertexFace(m);
vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(m);
vcg::Distribution<float> distr;
printf("Starting mesh vn:%i fn:%i\n",m.VN(),m.FN());

// Two different techniques for computing Discrete Gaussian and Mean Curvature
// they require the presence of the vertex::Curvature component
vcg::tri::UpdateCurvature<MyMesh>::PerVertex(m);
// Method 1 (discrete - Optimizing 3d triangulations using discrete curvature analysis 2003)
vcg::tri::UpdateCurvature<MyMesh>::PerVertexAbsoluteMeanAndGaussian(m);
vcg::tri::UpdateQuality<MyMesh>::VertexFromAttributeName(m,"KG");
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Gaussian Curvature method 1 Min %f Max %f\n",distr.Min(),distr.Max());
vcg::tri::UpdateQuality<MyMesh>::VertexFromAttributeName(m,"KH");
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Mean Curvature method 1 Min %f Max %f\n",distr.Min(),distr.Max());

// Method 2 (discrete - Discrete Differential-Geometry Operators for Triangulated 2-Manifolds 2002)
vcg::tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
vcg::tri::UpdateQuality<MyMesh>::VertexFromAttributeName(m,"KG");
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Gaussian Curvature method 2 Min %f Max %f\n",distr.Min(),distr.Max());
vcg::tri::UpdateQuality<MyMesh>::VertexFromAttributeName(m,"KH");
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Mean Curvature method 2 Min %f Max %f\n",distr.Min(),distr.Max());
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,"Torus_Discrete_Mean2.ply",vcg::tri::io::Mask::IOM_VERTQUALITY);

// Two different techniques for computing Principal Curvature Directions
// they require the presence of the vertex::CurvatureDir component
// Method 3 (directions - Estimating the Tensor of Curvature of a Surface from a Polyhedral Approximation - 1995)
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
vcg::tri::UpdateQuality<MyMesh>::VertexGaussianFromCurvatureDir(m);
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Gaussian Curvature method 3 Min %f Max %f\n",distr.Min(),distr.Max());
vcg::tri::UpdateQuality<MyMesh>::VertexMeanFromCurvatureDir(m);
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Mean Curvature method 3 Min %f Max %f\n",distr.Min(),distr.Max());

// Method 4 (directions - Restricted delaunay triangulations and normal cycle )
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycle(m);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());

vcg::tri::UpdateQuality<MyMesh>::VertexGaussianFromCurvatureDir(m);
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Gaussian Curvature method 4 Min %f Max %f\n",distr.Min(),distr.Max());
vcg::tri::UpdateQuality<MyMesh>::VertexMeanFromCurvatureDir(m);
vcg::tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m,distr);
printf("Mean Curvature method 4 Min %f Max %f\n",distr.Min(),distr.Max());


return 0;
}
2 changes: 1 addition & 1 deletion apps/sample/trimesh_curvature/trimesh_curvature.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include(../common.pri)
TARGET = trimesh_curvature
SOURCES += trimesh_curvature.cpp
SOURCES += trimesh_curvature.cpp ../../../wrap/ply/plylib.cpp
2 changes: 1 addition & 1 deletion apps/sample/trimesh_hole/trimesh_hole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int main(int argc,char ** argv){
{
f1=f2;
f2++;
TriSplit<MyMesh,CenterPointBarycenter<MyMesh> >::Apply(vf[i],&(*f1),&(*f2),&(*vertp),CenterPointBarycenter<MyMesh>() );
vcg::tri::TriSplit<MyMesh,vcg::tri::CenterPointBarycenter<MyMesh> >::Apply(vf[i],&(*f1),&(*f2),&(*vertp),vcg::tri::CenterPointBarycenter<MyMesh>() );
f1->SetS();
f2->SetS();
for(int itr=0;itr<3;itr++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ int main(int ,char **)
tri::UpdateSelection<MyMesh>::FaceDilate(m1);
tri::Clean<MyMesh>::SelectIntersectingFaces(m2,m1);
tri::UpdateSelection<MyMesh>::FaceDilate(m2);
IsotropicRemeshing<MyMesh>::Params params;
vcg::tri::IsotropicRemeshing<MyMesh>::Params params;

float len = (tri::Stat<MyMesh>::ComputeFaceEdgeLengthAverage(m1,true) + tri::Stat<MyMesh>::ComputeFaceEdgeLengthAverage(m1,true));
params.SetTargetLen(len*0.8f);
params.SetFeatureAngleDeg(10);
params.iter=1; // just one iteration to avoid overtessellating.
params.selectedOnly=true;
printf(" Input mesh %8i v %8i f\n",m1.VN(),m1.FN());
IsotropicRemeshing<MyMesh>::Do(m1, params);
IsotropicRemeshing<MyMesh>::Do(m2, params);
vcg::tri::IsotropicRemeshing<MyMesh>::Do(m1, params);
vcg::tri::IsotropicRemeshing<MyMesh>::Do(m2, params);
printf(" Input mesh %8i v %8i f\n",m1.VN(),m1.FN());
}
tri::Clean<MyMesh>::SelectIntersectingFaces(m1,m2);
Expand Down
6 changes: 3 additions & 3 deletions apps/sample/trimesh_remeshing/trimesh_remeshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main( int argc, char **argv )

// Mesh cleaning
tri::Clean<MyMesh>::RemoveUnreferencedVertex(original);
Allocator<MyMesh>::CompactEveryVector(original);
vcg::tri::Allocator<MyMesh>::CompactEveryVector(original);


tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(original);
Expand All @@ -90,7 +90,7 @@ int main( int argc, char **argv )
float maxSurfDist = maxSurfDistPerc*(original.bbox.Diag()/100.f);
printf("Length Thr: %8.3f ~ %4.2f %% on %5.3f\n",lengthThr,targetLenPerc,original.bbox.Diag());

IsotropicRemeshing<MyMesh>::Params params;
vcg::tri::IsotropicRemeshing<MyMesh>::Params params;
params.SetTargetLen(lengthThr);
params.SetFeatureAngleDeg(creaseAngle);
params.iter=iterNum;
Expand All @@ -111,7 +111,7 @@ int main( int argc, char **argv )


printf(" Input mesh %8i v %8i f\n",toremesh.VN(),toremesh.FN());
IsotropicRemeshing<MyMesh>::Do(toremesh, original, params);
vcg::tri::IsotropicRemeshing<MyMesh>::Do(toremesh, original, params);
vcg::tri::io::ExporterPLY<MyMesh>::Save(toremesh, "remesh.ply");
printf("Output mesh %8i v %8i f\n",toremesh.VN(),toremesh.FN());

Expand Down
4 changes: 2 additions & 2 deletions apps/sample/trimesh_texture_clean/trimesh_texture_clean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ int main(int ,char ** )

// generate a simple 2D grid
Grid(m,20,20,1,1);
// assign it a simple planar parametrization
tri:UpdateTexture<MyMesh>::WedgeTexFromPlane(m,Point3f(1.0f,0,0),Point3f(0,1.0f,0),true);
// assign it a simple planar parametrization
tri::UpdateTexture<MyMesh>::WedgeTexFromPlane(m,Point3f(1.0f,0,0),Point3f(0,1.0f,0),true);
tri::io::ExporterOBJ<MyMesh>::Save(m,"grid_0.obj",mask);

// randomly perturb a few coord textures introducing fake seams
Expand Down
4 changes: 2 additions & 2 deletions eigenlib/howto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Current Eigen Version 3.3.9 (04.12.2020) updated on 15/06/2021
To update the lib:
- download Eigen
- unzip it somewhere
- delete (in the filesystem) the content of the folder eigenlib/Eigen - copy the folders 'Eigen' there
- execute the two following shell commands in the folder Eigen
- delete (in the filesystem) the content of the folder eigenlib/Eigen - copy the folders 'Eigen' and 'unsupported' there
- execute the two following shell commands in the folder 'Eigen' and 'unsupported'

grep -RiIl 'http://mozilla.org/MPL/2.0/.' * | xargs sed -i 's/http:\/\/mozilla.org\/MPL\/2.0\/./the mozilla.org home page/g'
grep -RiIl 'http' * | xargs sed -i 's/http/xxxp/g'
Expand Down
Loading

0 comments on commit e4950d1

Please sign in to comment.