Merge branch 'devel'
This commit is contained in:
commit
001a01b386
|
@ -0,0 +1,59 @@
|
|||
branches:
|
||||
only:
|
||||
- devel
|
||||
|
||||
# Build worker image (VM template)
|
||||
image: Visual Studio 2015
|
||||
|
||||
# clone directory
|
||||
clone_folder: c:\projects\vcglib
|
||||
# Build Configuration, i.e. Debug, Release, etc.
|
||||
configuration:
|
||||
- release
|
||||
# - debug
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
# MinGW 32bit
|
||||
- QTDIR: C:\Qt\5.6\mingw49_32
|
||||
SPEC: win32-g++
|
||||
COMPILER: mingw32-make
|
||||
#ARTIFACT: $(APPVEYOR_PROJECT_NAME)-%APPVEYOR_REPO_TAG_NAME%.%APPVEYOR_BUILD_NUMBER%-win32.zip
|
||||
#ARTIFACT: $(APPVEYOR_PROJECT_NAME)-%APPVEYOR_REPO_TAG_NAME%-win32.zip
|
||||
# Microsoft Visual Studio 64bit
|
||||
- QTDIR: C:\Qt\5.6\msvc2015_64
|
||||
VSVER: 14.0
|
||||
SPEC: win32-msvc2015
|
||||
COMPILER: nmake
|
||||
#ARTIFACT: $(APPVEYOR_PROJECT_NAME)-%APPVEYOR_REPO_TAG_NAME%.%APPVEYOR_BUILD_NUMBER%-win64.zip
|
||||
#ARTIFACT: $(APPVEYOR_PROJECT_NAME)-%APPVEYOR_REPO_TAG_NAME%-win64.zip
|
||||
|
||||
|
||||
|
||||
# Set paths, etc.
|
||||
before_build:
|
||||
# Set paths
|
||||
#- '%QTDIR%\bin\qtenv2.bat'
|
||||
- call "%QTDIR%\bin\qtenv2.bat"
|
||||
# Show qmake and make version
|
||||
- qmake -v
|
||||
- if %COMPILER%==mingw32-make call %COMPILER% -v
|
||||
# Detect architecture (32bit or 64bit)
|
||||
- if %QTDIR:_64=%==%QTDIR% (set ARCH=x86) else (set ARCH=x64)
|
||||
# Set more... if Microsoft Visual Studio
|
||||
- if %COMPILER%==nmake call "%ProgramFiles(x86)%\Microsoft Visual Studio %VSVER%\VC\vcvarsall.bat" %ARCH%
|
||||
# Show build folder
|
||||
#- echo %APPVEYOR_BUILD_FOLDER%
|
||||
#- echo %CONFIGURATION%
|
||||
|
||||
# To run your custom scripts instead of automatic MSBuild
|
||||
build_script:
|
||||
# Go to clone directory
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
- cd apps
|
||||
- cd sample
|
||||
# Run qmake
|
||||
- qmake sample.pro -r -spec %SPEC% "CONFIG+=%CONFIGURATION%"
|
||||
# Run compiler
|
||||
#- '%COMPILER%'
|
||||
- call %COMPILER%
|
|
@ -0,0 +1,14 @@
|
|||
## Thank you for sending a Pull Request to the VCGLib!
|
||||
|
||||
VCGLib is fully owned by CNR, and all the VCGLib contributors that do not work at the VCLab of CNR must first sign the contributor license agreement that you can find at the following link: https://github.com/cnr-isti-vclab/vcglib/blob/devel/docs/ContributorLicenseAgreement.pdf
|
||||
|
||||
If you will sign the CLA, then we will be able to merge your pull request after reviewing it.
|
||||
Please send the signed document to muntoni.alessandro@gmail.com and paolo.cignoni@isti.cnr.it .
|
||||
If you will not sign the CLA, we will review and then apply your changes as soon as possible.
|
||||
|
||||
Before opening the PR, please leave the follwing form with a check for your particluar case:
|
||||
|
||||
##### Check with `[x]` what is your case:
|
||||
- [ ] I already signed and sent via email the CLA;
|
||||
- [ ] I wil sign and send the CLA via email as soon as possible;
|
||||
- [ ] I don't want to sign the CLA.
|
|
@ -0,0 +1,18 @@
|
|||
name: BuildSamplesMacOS
|
||||
|
||||
on:
|
||||
[push, pull_request]
|
||||
|
||||
jobs:
|
||||
macos_build_tests:
|
||||
name: Build Samples (MacOS)
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
- name: Build Samples
|
||||
run: |
|
||||
qmake apps/sample/sample.pro
|
||||
make -j4
|
|
@ -0,0 +1,18 @@
|
|||
name: BuildSamplesUbuntu
|
||||
|
||||
on:
|
||||
[push, pull_request]
|
||||
|
||||
jobs:
|
||||
ubuntu_build_tests:
|
||||
name: Build Samples (Ubuntu)
|
||||
runs-on: ubuntu-latest #in order to deploy, need to use oldest supported version
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
- name: Build Samples
|
||||
run: |
|
||||
qmake apps/sample/sample.pro
|
||||
make -j4
|
|
@ -0,0 +1,29 @@
|
|||
name: BuildSamplesWindows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
windows_build_tests:
|
||||
name: Build Samples (Windows)
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Downlaod Jom
|
||||
run: |
|
||||
Invoke-WebRequest -Uri "http://download.qt.io/official_releases/jom/jom_1_1_3.zip" -OutFile "jom_1_1_3.zip"
|
||||
New-Item -Name "jom" -ItemType "directory"
|
||||
Expand-Archive -Path jom_1_1_3.zip -DestinationPath .\jom
|
||||
echo "::add-path::$(Get-Location)\jom"
|
||||
- name: Setup env variables
|
||||
id: envs
|
||||
run: |
|
||||
echo '::set-env name=VCINSTALLDIR::C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC'
|
||||
- name: Setup MSVC
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
- name: Build Samples
|
||||
run: |
|
||||
qmake apps/sample/sample.pro
|
||||
jom -j4
|
|
@ -1,3 +1,7 @@
|
|||
# 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
|
||||
|
||||
# QTCreator user prefs
|
||||
*.user
|
||||
|
||||
|
@ -10,3 +14,14 @@ release/
|
|||
|
||||
# Intermediate Files
|
||||
*.bc
|
||||
|
||||
# Visual Studio Project files
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
*.suo
|
||||
*.ply
|
||||
wrap/nanoply/nanoply_vcg/nanoply_vcg.sln
|
||||
*.db
|
||||
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
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
# Enable C++ support
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
|
||||
# Compiler selection
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- clang
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
|
||||
|
||||
install:
|
||||
# Linux Setup
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget --no-check-certificate http://cmake.org/files/v3.1/cmake-3.1.3-Linux-x86_64.tar.gz ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar -xzf cmake-3.1.3-Linux-x86_64.tar.gz ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8" ;fi ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=$PWD/cmake-3.1.3-Linux-x86_64/bin:$PATH ;fi
|
||||
# OSX Setup
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget --no-check-certificate http://cmake.org/files/v3.7/cmake-3.7.2-Darwin-x86_64.tar.gz ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar -xzf cmake-3.7.2-Darwin-x86_64.tar.gz ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PWD/cmake-3.1.3-Darwin-x86_64/CMake.app/Contents/bin:$PATH ;fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake ;fi
|
||||
|
||||
# Build steps
|
||||
script:
|
||||
- cd apps
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ..
|
||||
- make
|
|
@ -1,6 +1,10 @@
|
|||
The **_Visualization and Computer Graphics Library_** (VCGlib for short) is a open source, portable, C++, templated, no dependency, library for manipulation, processing, cleaning, simplifying triangle meshes.
|
||||
|
||||
The library, composed by more than 100k lines of code, is released under the GPL license, and it is the base of most of the software tools of the [Visual Computing Lab](http://vcg.isti.cnr.it) of the Italian National Research Council Institute ISTI , like MeshLab, metro and many others.
|
||||

|
||||

|
||||

|
||||
|
||||
The library, composed by more than 100k lines of code, is released under the GPL license, and it is the base of most of the software tools of the [Visual Computing Lab](http://vcg.isti.cnr.it) of the Italian National Research Council Institute ISTI, like MeshLab, metro and many others.
|
||||
|
||||
The VCG library is tailored to mostly manage triangular meshes: The library is fairly large and offers many state of the art functionalities for processing meshes, like:
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
|
||||
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
|
||||
include_directories(../)
|
||||
include_directories(../eigenlib)
|
||||
add_subdirectory(metro)
|
||||
add_subdirectory(tridecimator)
|
|
@ -17,6 +17,7 @@ OBJECTS_DIR = build/obj
|
|||
# Lib headers
|
||||
INCLUDEPATH += .
|
||||
INCLUDEPATH += ../../..
|
||||
INCLUDEPATH += ../../../eigenlib
|
||||
|
||||
# Lib sources
|
||||
SOURCES += ../../../wrap/ply/plylib.cpp
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,2 @@
|
|||
project (metro)
|
||||
add_executable(metro metro.cpp ../../wrap/ply/plylib.cpp)
|
|
@ -20,91 +20,14 @@
|
|||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.23 2007/05/04 16:50:23 ganovelli
|
||||
added plus types version (#ifdef _PLUS_TYPES_ to use it ).
|
||||
|
||||
Revision 1.22 2006/10/25 12:40:19 fiorin
|
||||
Added possibility to use Octree as search structure:
|
||||
|
||||
Revision 1.21 2006/05/03 21:22:39 cignoni
|
||||
added missing Include
|
||||
|
||||
Revision 1.20 2006/04/20 08:30:24 cignoni
|
||||
small GCC compiling issues
|
||||
|
||||
Revision 1.19 2006/03/27 04:17:07 cignoni
|
||||
moved to generic export.h
|
||||
|
||||
Revision 1.18 2006/01/10 13:20:40 cignoni
|
||||
Changed ply::PlyMask to io::Mask
|
||||
|
||||
Revision 1.17 2005/10/02 23:11:00 cignoni
|
||||
Version 4.06, Added possibility of using three different search structures UG Hash and AABB
|
||||
|
||||
Revision 1.16 2005/09/16 11:52:14 cignoni
|
||||
removed wrong %v in vertex number printing
|
||||
|
||||
Revision 1.15 2005/04/04 10:36:36 cignoni
|
||||
Release 4.05
|
||||
Added saving of Error Histogram
|
||||
|
||||
Revision 1.14 2005/01/26 22:45:34 cignoni
|
||||
Release 4.04
|
||||
final updates for gcc compiling issues
|
||||
|
||||
Revision 1.13 2005/01/24 15:46:48 cignoni
|
||||
Release 4.04
|
||||
Moved to the library core the code for computing min distance froma a point to a mesh using a uniform grid.
|
||||
Slightly faster.
|
||||
|
||||
Revision 1.12 2005/01/03 11:28:52 cignoni
|
||||
Release 4.03
|
||||
Better ply compatibility, and improved error reporting
|
||||
|
||||
Revision 1.11 2004/11/29 09:07:04 cignoni
|
||||
Release 4.02
|
||||
removed bug in printing Hausdorf distance,
|
||||
removed bug in command line parsing,
|
||||
upgraded import mesh library to support off format
|
||||
|
||||
Revision 1.10 2004/09/21 23:52:50 cignoni
|
||||
Release 4.01
|
||||
|
||||
Revision 1.9 2004/09/20 16:29:08 ponchio
|
||||
Minimal changes.
|
||||
|
||||
Revision 1.8 2004/09/20 15:17:28 cignoni
|
||||
Removed bug in displays msec and better usage messages
|
||||
|
||||
Revision 1.7 2004/09/09 22:59:15 cignoni
|
||||
Removed many small warnings
|
||||
|
||||
Revision 1.6 2004/07/15 00:15:16 cignoni
|
||||
inflate -> offset
|
||||
|
||||
Revision 1.5 2004/06/24 09:08:31 cignoni
|
||||
Official Release of Metro 4.00
|
||||
|
||||
Revision 1.4 2004/05/14 13:53:12 ganovelli
|
||||
GPL added
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
// standard libraries
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include <vcg/math/histogram.h>
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <vcg/simplex/face/component_ep.h>
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <vcg/simplex/face/component_ep.h>
|
||||
#include <vcg/complex/algorithms/update/component_ep.h>
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include "sampling.h"
|
||||
|
@ -218,7 +141,7 @@ int main(int argc, char**argv)
|
|||
printf("-------------------------------\n"
|
||||
" Metro V.4.07 \n"
|
||||
" http://vcg.isti.cnr.it\n"
|
||||
" release date: "__DATE__"\n"
|
||||
" release date: " __DATE__ "\n"
|
||||
"-------------------------------\n\n");
|
||||
|
||||
if(argc <= 2) Usage();
|
||||
|
@ -373,15 +296,14 @@ int main(int argc, char**argv)
|
|||
// save error files.
|
||||
if(flags & SamplingFlags::SAVE_ERROR)
|
||||
{
|
||||
vcg::tri::io::PlyInfo p;
|
||||
p.mask|=vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTQUALITY /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ;
|
||||
int saveMask = vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTQUALITY /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ;
|
||||
//p.mask|=vcg::ply::PLYMask::PM_VERTCOLOR|vcg::ply::PLYMask::PM_VERTQUALITY;
|
||||
if(ColorMax!=0 || ColorMin != 0){
|
||||
vcg::tri::UpdateColor<CMesh>::PerVertexQualityRamp(S1,ColorMin,ColorMax);
|
||||
vcg::tri::UpdateColor<CMesh>::PerVertexQualityRamp(S2,ColorMin,ColorMax);
|
||||
}
|
||||
tri::io::ExporterPLY<CMesh>::Save( S1,S1NewName.c_str(),true,p);
|
||||
tri::io::ExporterPLY<CMesh>::Save( S2,S2NewName.c_str(),true,p);
|
||||
tri::io::ExporterPLY<CMesh>::Save( S1,S1NewName.c_str(),saveMask);
|
||||
tri::io::ExporterPLY<CMesh>::Save( S2,S2NewName.c_str(),saveMask);
|
||||
}
|
||||
|
||||
// save error files.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
TARGET = metro
|
||||
INCLUDEPATH += . ../..
|
||||
CONFIG += console stl
|
||||
DEPENDPATH += ../..
|
||||
INCLUDEPATH += . ../.. ../../eigenlib
|
||||
CONFIG += console stl c++11 debug_and_release
|
||||
TEMPLATE = app
|
||||
HEADERS += sampling.h
|
||||
SOURCES += metro.cpp ../../wrap/ply/plylib.cpp
|
||||
|
||||
# Mac specific Config required to avoid to make application bundles
|
||||
|
|
|
@ -548,7 +548,6 @@ void Sampling<MetroMesh>::Hausdorff()
|
|||
{
|
||||
Box3< ScalarType> bbox;
|
||||
|
||||
typedef typename std::vector<FaceType>::iterator FaceVecIterator;
|
||||
// set grid meshes.
|
||||
if(Flags & SamplingFlags::USE_HASH_GRID) hS2.Set(S2.face.begin(),S2.face.end());
|
||||
if(Flags & SamplingFlags::USE_AABB_TREE) tS2.Set(S2.face.begin(),S2.face.end());
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
|
||||
// mesh definition
|
||||
#include <vcg/simplex/vertex/with/afvn.h>
|
||||
#include <vcg/simplex/face/with/af.h>
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/refine.h>
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/import_ply.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
// std
|
||||
#include <vector>
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
struct MyFace;
|
||||
struct MyTetra;
|
||||
struct MyEdge;
|
||||
struct MyVertex: public VertexAFVNf<MyEdge,MyFace,MyTetra>{};
|
||||
struct MyFace: public FaceAF<MyVertex,MyEdge,MyFace>{};
|
||||
struct MyMesh: public tri::TriMesh< vector<MyVertex>, vector<MyFace> >{};
|
||||
|
||||
|
||||
|
||||
|
||||
#define FLAT 0
|
||||
#define ARC 1
|
||||
#define BUTTERFLY 2
|
||||
//#define BUTTERFLY2 3
|
||||
|
||||
//#define PLANE 4
|
||||
//#define SPHERE 5
|
||||
|
||||
#define LENGTH 6
|
||||
#define ONLY_SEL 7
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
if(argc<4)
|
||||
{
|
||||
printf(
|
||||
"\n PlyRefine ("__DATE__")\n"
|
||||
" Visual Computing Group I.S.T.I. C.N.R.\n"
|
||||
"Usage: PlyRefine filein.ply fileout.ply [command list]\n"
|
||||
"Commands: \n"
|
||||
" Refinement rules:\n"
|
||||
" -m# midpoint flat \n"
|
||||
" -a# midpoint arc\n"
|
||||
" -b# butterfly\n"
|
||||
//" -p# clip with plane \n"
|
||||
//" -s# clip with sphere \n"
|
||||
" Selective Refinement\n"
|
||||
" -L# refine only if the the edge is longer than #(default 0.0)\n"
|
||||
" -S(0|1) refine only selected faces\n"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
typedef pair<int,float> OP_TYPE;
|
||||
vector<OP_TYPE > operations;
|
||||
bool only_selected=false;
|
||||
int i=3; int n_steps;float length=0;
|
||||
while(i<argc)
|
||||
{
|
||||
if(argv[i][0]!='-')
|
||||
{printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
||||
operations.push_back(OP_TYPE()); OP_TYPE & op = operations.back();
|
||||
switch(argv[i][1])
|
||||
{
|
||||
|
||||
case 'm' :
|
||||
n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
op.first = FLAT;op.second = n_steps; break;
|
||||
case 'a' :
|
||||
n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
op.first = ARC;op.second = n_steps; break;
|
||||
case 'b' :
|
||||
n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
op.first = BUTTERFLY;op.second = n_steps; break;
|
||||
//case 'v' :
|
||||
// n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
// op.first = BUTTERFLY2;op.second = n_steps; break;
|
||||
//case 'p' :
|
||||
// n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
// op.first = PLANE;op.second = n_steps; break;
|
||||
//case 's' :
|
||||
// n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
// op.first = SPHERE;op.second = n_steps; break;
|
||||
case 'L' :
|
||||
n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
op.first = LENGTH;op.second = n_steps; break;
|
||||
case 'S' :
|
||||
n_steps = atof(argv[i]+2); n_steps=max(1,n_steps);
|
||||
op.first = ONLY_SEL;op.second = n_steps; break;
|
||||
default : {printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
|
||||
MyMesh m;
|
||||
if(vcg::tri::io::ImporterPLY<MyMesh>::Open(m,argv[1])!=0)
|
||||
{
|
||||
printf("Error reading file %s\n",argv[1]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
vcg::tri::UpdateTopology<MyMesh>::FaceBorderFlags(m);
|
||||
vcg::tri::UpdateNormals<MyMesh>::PerVertexNormalized(m);
|
||||
|
||||
int h;
|
||||
for(i=0;i < operations.size();++i){
|
||||
|
||||
switch(operations[i].first){
|
||||
case FLAT:
|
||||
for(h=0;h<operations[i].second;++h){
|
||||
Refine(m,MidPoint<MyMesh>(),length,only_selected);
|
||||
}
|
||||
break;
|
||||
case ARC:
|
||||
for(h=0;h<operations[i].second;++h){
|
||||
Refine(m,MidPointArc<MyMesh>(),length,only_selected);}
|
||||
break;
|
||||
case BUTTERFLY:
|
||||
for(h=0;h<operations[i].second;++h){
|
||||
Refine(m,MidPointButterfly<MyMesh>(),length,only_selected); }
|
||||
break;
|
||||
//case BUTTERFLY2:
|
||||
// for(h=0;h<operations[i].second;++h){
|
||||
// m.ComputeNormalizedVertexNormal();
|
||||
// Refine(m,MidPointButterfly2<MyMesh>(),length,only_selected);
|
||||
// }
|
||||
// break;
|
||||
/* case PLANE:
|
||||
for(h=0;h<operations[i].second;++h){
|
||||
m.ComputeNormalizedVertexNormal();
|
||||
Refine(m,MidPointPlane<MyMesh>(),length,only_selected);
|
||||
}
|
||||
break;
|
||||
case SPHERE:
|
||||
for(h=0;h<operations[i].second;++h){
|
||||
m.ComputeNormalizedVertexNormal();
|
||||
Refine(m,MidPointSphere<MyMesh>(),length,only_selected);
|
||||
}
|
||||
break;
|
||||
*/ case LENGTH:
|
||||
length = operations[i].second; break;
|
||||
case ONLY_SEL:
|
||||
only_selected = (bool)operations[i].second; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//m.ComputeNormalizedVertexNormal();
|
||||
//Refine(m,MidPointArc<MyMesh>(),0);
|
||||
vcg::tri::io::PlyInfo pi;
|
||||
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,argv[2],pi.mask);
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +1,25 @@
|
|||
/****************************************************************************
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
// Standard headers
|
||||
#include <iostream>
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = colorspace
|
||||
LIBPATH +=
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += . ../../..
|
||||
CONFIG += console stl
|
||||
TEMPLATE = app
|
||||
SOURCES += colorspace.cpp
|
|
@ -1,8 +1,23 @@
|
|||
DEPENDPATH += . ../../..
|
||||
INCLUDEPATH += . ../../..
|
||||
CONFIG += console c++11
|
||||
DEPENDPATH += \
|
||||
. \
|
||||
../../..
|
||||
|
||||
INCLUDEPATH += \
|
||||
. \
|
||||
../../.. \
|
||||
../../../eigenlib
|
||||
|
||||
|
||||
CONFIG += c++11
|
||||
TEMPLATE = app
|
||||
|
||||
# Mac specific Config required to avoid to make application bundles
|
||||
CONFIG -= app_bundle
|
||||
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
unix {
|
||||
CONFIG(release, debug|release) {
|
||||
DEFINES *= NDEBUG
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,11 +74,11 @@ int main( int argc, char **argv )
|
|||
|
||||
tri::UpdateTopology<MyMesh>::VertexEdge(e);
|
||||
tri::Clean<MyMesh>::SelectNonManifoldVertexOnEdgeMesh(e);
|
||||
printf("Selected vertices %i\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
|
||||
printf("Selected vertices %lu\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
|
||||
tri::Clean<MyMesh>::SplitSelectedVertexOnEdgeMesh(e);
|
||||
printf("Out mesh has %i vert %i edges\n",e.vn,e.en);
|
||||
tri::Clean<MyMesh>::SelectCreaseVertexOnEdgeMesh(e,math::ToRad(30.f));
|
||||
printf("Selected vertices %i\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
|
||||
printf("Selected vertices %lu\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
|
||||
tri::Clean<MyMesh>::SplitSelectedVertexOnEdgeMesh(e);
|
||||
printf("Out mesh has %i vert %i edges\n",e.vn,e.en);
|
||||
|
||||
|
|
|
@ -23,20 +23,12 @@
|
|||
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
/*include the algorithms for updating: */
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
/* include the support for polygon meshes (function to convert from/to trimesh)*/
|
||||
//#include <vcg/complex/algorithms/polygon_support.h>
|
||||
|
||||
/* include the support for half edges */
|
||||
#include <vcg/complex/algorithms/update/halfedge_indexed.h>
|
||||
|
||||
|
@ -44,16 +36,11 @@
|
|||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
// forward declarations
|
||||
class TFace;
|
||||
class TVertex;
|
||||
|
||||
struct TUsedTypes: public vcg::UsedTypes< vcg::Use<TVertex>::AsVertexType, vcg::Use<TFace>::AsFaceType >{};
|
||||
|
||||
|
||||
|
||||
/* Definition of a mesh of triangles
|
||||
*/
|
||||
class TVertex : public Vertex< TUsedTypes,
|
||||
vertex::BitFlags,
|
||||
vertex::Coord3f,
|
||||
|
@ -126,7 +113,7 @@ class PMesh: public
|
|||
PMesh pm;
|
||||
TMesh tm0;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int /*argc*/, char *argv[]) {
|
||||
|
||||
int loadmask;
|
||||
|
||||
|
@ -209,9 +196,8 @@ else
|
|||
TMesh tm1;
|
||||
vcg::tri::PolygonSupport<TMesh,PMesh>::ImportFromPolyMesh(tm1,pm);
|
||||
|
||||
vcg::tri::io::PlyInfo pi;
|
||||
vcg::tri::io::ExporterPLY<TMesh>::Save(tm1,"converted_tri.ply",false,pi);
|
||||
vcg::tri::io::ExporterPLY<PMesh>::Save(pm,"converted_poly.ply",false,pi);
|
||||
vcg::tri::io::ExporterPLY<TMesh>::Save(tm1,"converted_tri.ply",false);
|
||||
vcg::tri::io::ExporterPLY<PMesh>::Save(pm,"converted_poly.ply",false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
/****************************************************************************
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
/*include the algorithms for updating: */
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
#include <wrap/io_trimesh/export_obj.h>
|
||||
#include <wrap/io_trimesh/import_obj.h>
|
||||
|
||||
#include <vcg/complex/algorithms/dual_meshing.h>
|
||||
|
||||
#include <vcg/complex/algorithms/polygon_support.h>
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
// forward declarations
|
||||
class TFace;
|
||||
class TVertex;
|
||||
|
||||
struct TUsedTypes: public vcg::UsedTypes< vcg::Use<TVertex>::AsVertexType, vcg::Use<TFace>::AsFaceType >{};
|
||||
|
||||
/* Definition of a mesh of triangles
|
||||
*/
|
||||
class TVertex : public Vertex< TUsedTypes,
|
||||
vertex::BitFlags,
|
||||
vertex::Coord3f,
|
||||
vertex::Normal3f,
|
||||
vertex::Mark >{};
|
||||
|
||||
class TFace : public Face< TUsedTypes,
|
||||
face::VertexRef, // three pointers to vertices
|
||||
face::Normal3f, // normal
|
||||
face::BitFlags, // flags
|
||||
face::FFAdj // three pointers to adjacent faces
|
||||
> {};
|
||||
|
||||
/* the mesh is a container of vertices and a container of faces */
|
||||
class TMesh : public vcg::tri::TriMesh< vector<TVertex>, vector<TFace> > {};
|
||||
|
||||
|
||||
/* Definition of a mesh of polygons that also supports half-edges
|
||||
*/
|
||||
class PFace;
|
||||
class PVertex;
|
||||
|
||||
struct PUsedTypes: public vcg::UsedTypes<vcg::Use<PVertex> ::AsVertexType,
|
||||
vcg::Use<PFace> ::AsFaceType>{};
|
||||
|
||||
class PVertex:public vcg::Vertex< PUsedTypes,
|
||||
vcg::vertex::Coord3f,
|
||||
vcg::vertex::Normal3f,
|
||||
vcg::vertex::Mark,
|
||||
vcg::vertex::Qualityf,
|
||||
vcg::vertex::BitFlags>{} ;
|
||||
|
||||
class PFace:public vcg::Face<
|
||||
PUsedTypes
|
||||
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
|
||||
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
||||
// will be allocated dynamically")
|
||||
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
||||
,vcg::face::PFVAdj
|
||||
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
||||
,vcg::face::BitFlags // bit flags
|
||||
,vcg::face::Qualityf // quality
|
||||
,vcg::face::Normal3f // normal
|
||||
> {};
|
||||
|
||||
class PMesh: public
|
||||
vcg::tri::TriMesh<
|
||||
std::vector<PVertex>, // the vector of vertices
|
||||
std::vector<PFace > // the vector of faces
|
||||
>{};
|
||||
|
||||
TMesh primalT;
|
||||
PMesh primal,dual;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
vcg::tri::Sphere<TMesh>(primalT,2);
|
||||
vcg::tri::PolygonSupport<TMesh,PMesh>::ImportFromTriMesh(primal,primalT);
|
||||
|
||||
vcg::tri::DualMeshing<PMesh>::MakeDual(primal,dual);
|
||||
vcg::tri::io::ExporterOBJ<PMesh>::Save(dual,"./dual.obj",vcg::tri::io::Mask::IOM_BITPOLYGONAL);
|
||||
|
||||
vcg::tri::DualMeshing<PMesh>::MakeDual(dual,primal);
|
||||
vcg::tri::io::ExporterOBJ<PMesh>::Save(primal,"./dual_dual.obj",vcg::tri::io::Mask::IOM_BITPOLYGONAL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = polygonmesh_base
|
||||
SOURCES += polygonmesh_dual.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -0,0 +1,180 @@
|
|||
/****************************************************************************
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
/*include the algorithms for updating: */
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
#include <wrap/io_trimesh/export_obj.h>
|
||||
#include <wrap/io_trimesh/import_ply.h>
|
||||
|
||||
#include <vcg/complex/algorithms/dual_meshing.h>
|
||||
|
||||
#include <vcg/complex/algorithms/polygon_support.h>
|
||||
|
||||
#include <vcg/complex/algorithms/polygonal_algorithms.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/quality.h>
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
// forward declarations
|
||||
class TFace;
|
||||
class TVertex;
|
||||
|
||||
struct TUsedTypes: public vcg::UsedTypes< vcg::Use<TVertex>::AsVertexType, vcg::Use<TFace>::AsFaceType >{};
|
||||
|
||||
/* Definition of a mesh of triangles
|
||||
*/
|
||||
class TVertex : public Vertex< TUsedTypes,
|
||||
vertex::BitFlags,
|
||||
vertex::Coord3f,
|
||||
vertex::Normal3f,
|
||||
vertex::Mark >{};
|
||||
|
||||
class TFace : public Face< TUsedTypes,
|
||||
face::VertexRef, // three pointers to vertices
|
||||
face::Normal3f, // normal
|
||||
face::BitFlags, // flags
|
||||
face::FFAdj // three pointers to adjacent faces
|
||||
> {};
|
||||
|
||||
/* the mesh is a container of vertices and a container of faces */
|
||||
class TMesh : public vcg::tri::TriMesh< vector<TVertex>, vector<TFace> > {};
|
||||
|
||||
|
||||
/* Definition of a mesh of polygons that also supports half-edges
|
||||
*/
|
||||
class PFace;
|
||||
class PVertex;
|
||||
|
||||
struct PUsedTypes: public vcg::UsedTypes<vcg::Use<PVertex> ::AsVertexType,
|
||||
vcg::Use<PFace> ::AsFaceType>{};
|
||||
|
||||
class PVertex:public vcg::Vertex< PUsedTypes,
|
||||
vcg::vertex::Coord3f,
|
||||
vcg::vertex::Normal3f,
|
||||
vcg::vertex::Mark,
|
||||
vcg::vertex::BitFlags>{} ;
|
||||
|
||||
class PFace:public vcg::Face<
|
||||
PUsedTypes
|
||||
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
|
||||
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
||||
// will be allocated dynamically")
|
||||
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
||||
,vcg::face::PFVAdj
|
||||
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
||||
,vcg::face::BitFlags // bit flags
|
||||
,vcg::face::Normal3f // normal
|
||||
,face::Qualityd // face quality
|
||||
> {};
|
||||
|
||||
class PMesh: public
|
||||
vcg::tri::TriMesh<
|
||||
std::vector<PVertex>, // the vector of vertices
|
||||
std::vector<PFace > // the vector of faces
|
||||
>{};
|
||||
|
||||
TMesh primalT;
|
||||
PMesh primal,dual,dual_opt,dual_flat;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
assert(argc>1);
|
||||
|
||||
std::cout<<"Opening file " << argv[0] << std::endl;
|
||||
|
||||
int res=vcg::tri::io::ImporterPLY<TMesh>::Open(primalT,argv[1]);
|
||||
assert(res==vcg::ply::E_NOERROR);
|
||||
vcg::tri::PolygonSupport<TMesh,PMesh>::ImportFromTriMesh(primal,primalT);
|
||||
|
||||
vcg::tri::DualMeshing<PMesh>::MakeDual(primal,dual);
|
||||
vcg::tri::io::ExporterOBJ<PMesh>::Save(dual,"./dual_no_optimized.obj",vcg::tri::io::Mask::IOM_BITPOLYGONAL);
|
||||
|
||||
//copy the mesh
|
||||
vcg::tri::Append<PMesh,PMesh>::Mesh(dual_opt,dual);
|
||||
vcg::tri::Append<PMesh,PMesh>::Mesh(dual_flat,dual);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::SmoothReprojectPCA(dual_opt);
|
||||
|
||||
vcg::tri::io::ExporterOBJ<PMesh>::Save(dual_opt,"./dual_optimized.obj",vcg::tri::io::Mask::IOM_BITPOLYGONAL);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::FlattenFaces(dual_flat);
|
||||
vcg::tri::io::ExporterOBJ<PMesh>::Save(dual_flat,"./dual_flattened.obj",vcg::tri::io::Mask::IOM_BITPOLYGONAL);
|
||||
|
||||
//update the quality as template
|
||||
std::pair<typename PMesh::ScalarType,typename PMesh::ScalarType> minmax_dual,minmax_dual_opt,minmax_dual_flat;
|
||||
typename PMesh::ScalarType Avg_dual,Avg_dual_opt,Avg_dual_flat;
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual,PolygonalAlgorithm<PMesh>::QTemplate);
|
||||
minmax_dual=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual);
|
||||
Avg_dual=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual_opt,PolygonalAlgorithm<PMesh>::QTemplate);
|
||||
minmax_dual_opt=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual_opt);
|
||||
Avg_dual_opt=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual_opt);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual_flat,PolygonalAlgorithm<PMesh>::QTemplate);
|
||||
minmax_dual_flat=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual_flat);
|
||||
Avg_dual_flat=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual_flat);
|
||||
|
||||
std::cout<<std::endl<<std::endl<<"Template Quality No Optimized min / max " <<minmax_dual.first<<" / "<<minmax_dual.second<<std::endl;
|
||||
std::cout<<"Template Quality Optimized min / max " <<minmax_dual_opt.first<<" / "<<minmax_dual_opt.second<<std::endl;
|
||||
std::cout<<"Template Quality Flattened min / max " <<minmax_dual_flat.first<<" / "<<minmax_dual_flat.second<<std::endl<<std::endl;
|
||||
|
||||
std::cout<<"Template Quality No Optimized Average " <<Avg_dual<<std::endl;
|
||||
std::cout<<"Template Quality Optimized Average " <<Avg_dual_opt<<std::endl;
|
||||
std::cout<<"Template Quality Flattened Average " <<Avg_dual_flat<<std::endl<<std::endl<<std::endl<<std::endl;
|
||||
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual,PolygonalAlgorithm<PMesh>::QPlanar);
|
||||
minmax_dual=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual);
|
||||
Avg_dual=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual_opt,PolygonalAlgorithm<PMesh>::QPlanar);
|
||||
minmax_dual_opt=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual_opt);
|
||||
Avg_dual_opt=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual_opt);
|
||||
|
||||
vcg::PolygonalAlgorithm<PMesh>::UpdateQuality(dual_flat,PolygonalAlgorithm<PMesh>::QPlanar);
|
||||
minmax_dual_flat=tri::Stat<PMesh>::ComputePerFaceQualityMinMax(dual_flat);
|
||||
Avg_dual_flat=tri::Stat<PMesh>::ComputePerFaceQualityAvg(dual_flat);
|
||||
|
||||
std::cout<<"Flatness Quality No Optimized min / max " <<minmax_dual.first<<" / "<<minmax_dual.second<<std::endl;
|
||||
std::cout<<"Flatness Quality Optimized min / max " <<minmax_dual_opt.first<<" / "<<minmax_dual_opt.second<<std::endl;
|
||||
std::cout<<"Flatness Quality Flattened min / max " <<minmax_dual_flat.first<<" / "<<minmax_dual_flat.second<<std::endl<<std::endl;
|
||||
|
||||
std::cout<<"Flatness Quality No Optimized Average " <<Avg_dual<<std::endl;
|
||||
std::cout<<"Flatness Quality Optimized Average " <<Avg_dual_opt<<std::endl;
|
||||
std::cout<<"Flatness Quality Flattened Average " <<Avg_dual_flat<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = polygonmesh_base
|
||||
SOURCES += polygonmesh_optimize.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -0,0 +1,132 @@
|
|||
/****************************************************************************
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/polygonal_algorithms.h>
|
||||
|
||||
#include <wrap/io_trimesh/export_obj.h>
|
||||
#include <wrap/io_trimesh/import_ply.h>
|
||||
#include <wrap/io_trimesh/export_off.h>
|
||||
#include <wrap/io_trimesh/import_off.h>
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
// forward declarations
|
||||
class TFace;
|
||||
class TVertex;
|
||||
|
||||
struct TUsedTypes: public vcg::UsedTypes< vcg::Use<TVertex>::AsVertexType, vcg::Use<TFace>::AsFaceType >{};
|
||||
|
||||
/* Definition of a mesh of triangles
|
||||
*/
|
||||
class TVertex : public Vertex< TUsedTypes,
|
||||
vertex::BitFlags,
|
||||
vertex::Coord3f,
|
||||
vertex::Normal3f,
|
||||
vertex::Mark >{};
|
||||
|
||||
class TFace : public Face< TUsedTypes,
|
||||
face::VertexRef, // three pointers to vertices
|
||||
face::Normal3f, // normal
|
||||
face::BitFlags, // flags
|
||||
face::Mark, // incremental mark
|
||||
face::FFAdj // three pointers to adjacent faces
|
||||
> {};
|
||||
|
||||
/* the mesh is a container of vertices and a container of faces */
|
||||
class TMesh : public vcg::tri::TriMesh< vector<TVertex>, vector<TFace> > {};
|
||||
|
||||
|
||||
/* Definition of a mesh of polygons that also supports half-edges
|
||||
*/
|
||||
class PFace;
|
||||
class PVertex;
|
||||
|
||||
struct PUsedTypes: public vcg::UsedTypes<vcg::Use<PVertex> ::AsVertexType,
|
||||
vcg::Use<PFace> ::AsFaceType>{};
|
||||
|
||||
class PVertex:public vcg::Vertex< PUsedTypes,
|
||||
vcg::vertex::Coord3f,
|
||||
vcg::vertex::Normal3f,
|
||||
vcg::vertex::Mark,
|
||||
vcg::vertex::Qualityf,
|
||||
vcg::vertex::Mark,
|
||||
vcg::vertex::BitFlags>{} ;
|
||||
|
||||
class PFace:public vcg::Face<
|
||||
PUsedTypes
|
||||
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
|
||||
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
||||
// will be allocated dynamically")
|
||||
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
||||
,vcg::face::PFVAdj
|
||||
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
||||
,vcg::face::BitFlags // bit flags
|
||||
,vcg::face::Qualityf // quality
|
||||
,vcg::face::Mark // incremental mark
|
||||
,vcg::face::Normal3f // normal
|
||||
> {};
|
||||
|
||||
class PMesh: public
|
||||
vcg::tri::TriMesh<
|
||||
std::vector<PVertex>, // the vector of vertices
|
||||
std::vector<PFace > // the vector of faces
|
||||
>{};
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
TMesh tm;
|
||||
PMesh pm;
|
||||
math::MarsenneTwisterRNG RndGen;
|
||||
tri::io::ImporterOFF<PMesh>::Open(pm,"../../meshes/fertility_quad.off");
|
||||
tri::UpdateBounding<PMesh>::Box(pm);
|
||||
tri::UpdateSelection<PMesh>::VertexClear(pm);
|
||||
// randomly displace half of the vertices
|
||||
float randScale = pm.bbox.Diag()/200.0f;
|
||||
ForEachVertex(pm,[&](PVertex &v){
|
||||
if(v.P()[0] < pm.bbox.Center()[0])
|
||||
v.P() += math::GeneratePointInUnitBallUniform<float,math::MarsenneTwisterRNG>(RndGen)*randScale;
|
||||
});
|
||||
|
||||
// Select half of the vertices
|
||||
ForEachVertex(pm,[&](PVertex &v){
|
||||
if(v.P()[2] < pm.bbox.Center()[2])
|
||||
v.SetS();
|
||||
});
|
||||
printf("Input quad mesh has %i %i (sel %i)\n",pm.VN(), pm.FN(), tri::UpdateSelection<PMesh>::VertexCount(pm) );
|
||||
|
||||
tri::io::ImporterPLY<TMesh>::Open(tm,"../../meshes/fertility_tri.ply");
|
||||
tri::UpdateNormal<TMesh>::PerVertexNormalizedPerFaceNormalized(tm);
|
||||
printf("Input tri mesh has %i %i\n",tm.VN(), tm.FN());
|
||||
tri::io::ExporterOFF<PMesh>::Save(pm,"./smooth.off");
|
||||
PolygonalAlgorithm<PMesh>::LaplacianReproject(pm,tm,100,0.6,0.3,true);
|
||||
tri::io::ExporterOFF<PMesh>::Save(pm,"./smooth2.off");
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = polygonmesh_smooth
|
||||
SOURCES += polygonmesh_smooth.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -89,7 +89,7 @@ void example2(){
|
|||
z.addVector(a,b,c);
|
||||
}
|
||||
|
||||
printf("Building %s from %d vectors...\n",fullMeshFilename, z.vectors().size() );
|
||||
printf("Building %s from %lu vectors...\n",fullMeshFilename, z.vectors().size() );
|
||||
|
||||
MyMesh m;
|
||||
z.createMesh(m);
|
||||
|
@ -106,7 +106,7 @@ void example2(){
|
|||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int main(int , char **){
|
||||
example1();
|
||||
example2();
|
||||
return 0;
|
||||
|
|
|
@ -1,42 +1,63 @@
|
|||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = trimesh_base \
|
||||
|
||||
SUBDIRS = \
|
||||
aabb_binary_tree \
|
||||
colorspace \
|
||||
#edgemesh_sampling \
|
||||
polygonmesh_base \
|
||||
polygonmesh_dual \
|
||||
polygonmesh_optimize \
|
||||
polygonmesh_polychord_collapse \
|
||||
#polygonmesh_quadsimpl \
|
||||
polygonmesh_smooth \
|
||||
#polygonmesh_zonohedra \
|
||||
space_index_2d \
|
||||
#space_minimal \
|
||||
space_packer \
|
||||
space_rasterized_packer \
|
||||
trimesh_align_pair \
|
||||
trimesh_allocate \
|
||||
trimesh_attribute \
|
||||
trimesh_attribute_saving \
|
||||
trimesh_ball_pivoting \
|
||||
trimesh_base \
|
||||
trimesh_closest \
|
||||
trimesh_copy \
|
||||
trimesh_color \
|
||||
trimesh_curvature \
|
||||
trimesh_clustering \
|
||||
trimesh_edge \
|
||||
trimesh_color \
|
||||
trimesh_copy \
|
||||
trimesh_create \
|
||||
trimesh_curvature \
|
||||
trimesh_cylinder_clipping \
|
||||
trimesh_disk_parametrization \
|
||||
trimesh_fitting \
|
||||
trimesh_geodesic \
|
||||
# trimesh_ext_mc \
|
||||
trimesh_harmonic \
|
||||
trimesh_hole \
|
||||
trimesh_implicit_smooth \
|
||||
trimesh_indexing \
|
||||
trimesh_inertia \
|
||||
trimesh_intersection \
|
||||
trimesh_intersection_plane \
|
||||
trimesh_intersection_mesh \
|
||||
trimesh_isosurface \
|
||||
trimesh_join \
|
||||
trimesh_kdtree \
|
||||
trimesh_montecarlo_sampling \
|
||||
trimesh_normal \
|
||||
trimesh_optional \
|
||||
trimesh_pointmatching \
|
||||
trimesh_pointcloud_sampling \
|
||||
trimesh_ray \
|
||||
trimesh_refine \
|
||||
trimesh_remeshing \
|
||||
trimesh_sampling \
|
||||
trimesh_select \
|
||||
trimesh_smooth \
|
||||
trimesh_split_vertex \
|
||||
trimesh_texture \
|
||||
trimesh_texture_clean \
|
||||
trimesh_topology \
|
||||
trimesh_topological_cut \
|
||||
trimesh_voronoi \
|
||||
trimesh_voronoiatlas \
|
||||
trimesh_voronoiclustering \
|
||||
trimesh_voronoisampling \
|
||||
edgemesh_sampling \
|
||||
polygonmesh_base \
|
||||
colorspace \
|
||||
space_index_2d \
|
||||
space_packer
|
||||
# aabb_binary_tree
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <vcg/space/distance2.h>
|
||||
#include<vcg/space/segment2.h>
|
||||
#include<vcg/space/index/grid_static_ptr2d.h>
|
||||
#include<vcg/space/index/grid_closest2d.h>
|
||||
#include<vcg/space/intersection2.h>
|
||||
#include <vcg/space/segment2.h>
|
||||
#include <vcg/space/index/grid_static_ptr2d.h>
|
||||
#include <vcg/space/index/grid_closest2d.h>
|
||||
#include <vcg/space/intersection2.h>
|
||||
|
||||
typedef double MyScalarType;
|
||||
typedef vcg::Point2<MyScalarType> MyCoordType;
|
||||
|
|
|
@ -57,7 +57,7 @@ static void buildRandRectSet(int rectNum, vector<Box2f> &rectVec)
|
|||
}
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
int main( int /*argc*/, char **/*argv*/ )
|
||||
{
|
||||
vector<Similarity2f> trVec;
|
||||
vector<Similarity2f> trPolyVec;
|
||||
|
@ -115,7 +115,6 @@ int main( int argc, char **argv )
|
|||
|
||||
packingParam.costFunction = RasterizedOutline2Packer<float, QtOutline2Rasterizer>::Parameters::LowestHorizon;
|
||||
packingParam.doubleHorizon = true;
|
||||
packingParam.cellSize = 4;
|
||||
packingParam.rotationNum = 16; //number of rasterizations in 90°
|
||||
|
||||
RasterizedOutline2Packer<float, QtOutline2Rasterizer>::Pack(outline2Vec,containerSize,trVec,packingParam);
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/****************************************************************************
|
||||
* VCGLib o o *
|
||||
* Visual and Computer Graphics Library o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2004-2019 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include <vcg/space/point2.h>
|
||||
#include <vcg/space/point3.h>
|
||||
#include <vcg/complex/algorithms/outline_support.h>
|
||||
#include <wrap/qt/outline2_rasterizer.h>
|
||||
#include <vcg/space/rasterized_outline2_packer.h>
|
||||
|
||||
#include <wrap/qt/Outline2ToQImage.h>
|
||||
|
||||
// This sample shows how to pack a sequence of outlines at the given scale into
|
||||
// a number of containers not known in advance using the PackBestEffort()
|
||||
// function
|
||||
|
||||
typedef std::vector<vcg::Point2f> Outline2f;
|
||||
typedef vcg::RasterizedOutline2Packer<float,QtOutline2Rasterizer> RasterizedPacker;
|
||||
typedef RasterizedPacker::Parameters PackingParams;
|
||||
|
||||
|
||||
void FillOutlineVec(std::vector<Outline2f>& outlines)
|
||||
{
|
||||
vcg::tri::OutlineUtil<float>::BuildRandomOutlineVec(30, outlines);
|
||||
for (auto& outline : outlines)
|
||||
for (auto& p : outline)
|
||||
p *= 200.0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// the vector of outlines to pack
|
||||
std::vector<Outline2f> outlines;
|
||||
FillOutlineVec(outlines);
|
||||
|
||||
// containerIndices maps each outline index to the container in which is packed
|
||||
std::vector<int> containerIndices(outlines.size(), -1); // -1 means not packed to any container
|
||||
|
||||
// packingTransforms maps each outline index to its transform */
|
||||
std::vector<vcg::Similarity2f> packingTransforms(outlines.size(), vcg::Similarity2f{});
|
||||
|
||||
/* size of the packing area */
|
||||
const vcg::Point2i grid_size(400, 600);
|
||||
|
||||
PackingParams params;
|
||||
params.costFunction = PackingParams::LowestHorizon;
|
||||
params.doubleHorizon = true;
|
||||
params.innerHorizon = true; /* use inner horizons to pack charts in between gaps */
|
||||
params.permutations = false; /* do not use permutations (they are ignored by PackBestEffort() */
|
||||
params.rotationNum = 16; /* 16 rotations per chart */
|
||||
params.gutterWidth = 2; /* 2 pixels gutter */
|
||||
params.minmax = false; /* do not combine costs of the two horizons when evaluating placements */
|
||||
|
||||
int totPacked = 0;
|
||||
int nc = 0; /* current container index */
|
||||
while (true) {
|
||||
|
||||
std::cout << "Packing into container " << nc << std::endl;
|
||||
|
||||
// build a vector with the outlines not yet packed, and a corresponding vector
|
||||
// of indices into the 'outlines' vector
|
||||
std::vector<int> outlineIndex_iter;
|
||||
std::vector<Outline2f> outlines_iter;
|
||||
for (unsigned i = 0; i < containerIndices.size(); ++i) {
|
||||
if (containerIndices[i] == -1) {
|
||||
outlineIndex_iter.push_back(i);
|
||||
outlines_iter.push_back(outlines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<vcg::Similarity2f> transforms;
|
||||
std::vector<int> polyToContainer;
|
||||
int numPacked = RasterizedPacker::PackBestEffort(outlines_iter, {grid_size}, transforms, polyToContainer, params);
|
||||
|
||||
totPacked += numPacked;
|
||||
|
||||
if (numPacked == 0) {
|
||||
std::cerr << "Failed to pack any outline at the current iteration. Stopping." << std::endl;
|
||||
std::exit(-1);
|
||||
} else {
|
||||
for (unsigned i = 0; i < outlines_iter.size(); ++i) {
|
||||
if (polyToContainer[i] != -1) {
|
||||
assert(polyToContainer[i] == 0); // We only use a single container in this example
|
||||
int outline_i = outlineIndex_iter[i];
|
||||
assert(containerIndices[outline_i] == -1);
|
||||
containerIndices[outline_i] = nc;
|
||||
packingTransforms[outline_i] = transforms[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totPacked == outlines.size())
|
||||
break;
|
||||
else
|
||||
nc++;
|
||||
|
||||
if (nc > 10)
|
||||
std::cerr << "Warning: packing into more than 10 containers! (nc = " << nc << ")" << std::endl;
|
||||
}
|
||||
|
||||
/* for each container, generate an image */
|
||||
for (int i = 0; i < nc + 1; ++i) {
|
||||
std::vector<Outline2f> outlines_iter;
|
||||
std::vector<vcg::Similarity2f> transforms_iter;
|
||||
for (unsigned k = 0; k < containerIndices.size(); ++k) {
|
||||
assert(containerIndices[k] != -1 && "Some outlines were not packed");
|
||||
if (containerIndices[k] == i) {
|
||||
outlines_iter.push_back(outlines[k]);
|
||||
transforms_iter.push_back(packingTransforms[k]);
|
||||
}
|
||||
}
|
||||
std::string filename = std::string("container_") + std::to_string(i) + std::string(".png");
|
||||
Outline2Dumper::Param pp;
|
||||
pp.width = grid_size.X();
|
||||
pp.height = grid_size.Y();
|
||||
pp.fill = true;
|
||||
pp.randomColor = true;
|
||||
|
||||
Outline2Dumper::dumpOutline2VecPNG(filename.c_str(), outlines_iter, transforms_iter, pp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
include(../common.pri)
|
||||
QT += opengl svg
|
||||
TARGET = space_rasterized_packer
|
||||
SOURCES += space_rasterized_packer.cpp \
|
||||
../../../../vcglib/wrap/qt/Outline2ToQImage.cpp \
|
||||
../../../../vcglib/wrap/qt/outline2_rasterizer.cpp
|
|
@ -0,0 +1,149 @@
|
|||
/****************************************************************************
|
||||
* 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_align_pair.cpp
|
||||
\ingroup code_sample
|
||||
|
||||
\brief the minimal example for aligning two meshes
|
||||
|
||||
This file contain a minimal example for aligning two meshs.
|
||||
|
||||
Example call:
|
||||
./trimesh_align_pair mesh1.ply mesh2.ply output.ply
|
||||
|
||||
output.ply will contain mesh2.ply rotated in order to be aligned to mesh1.ply
|
||||
|
||||
*/
|
||||
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/align_pair.h>
|
||||
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
class MyFace;
|
||||
class MyVertex;
|
||||
|
||||
struct MyUsedTypes :
|
||||
public vcg::UsedTypes< vcg::Use<MyVertex>::AsVertexType,
|
||||
vcg::Use<MyFace>::AsFaceType>
|
||||
{};
|
||||
|
||||
class MyVertex :
|
||||
public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3d, vcg::vertex::Normal3d, vcg::vertex::Color4b, vcg::vertex::BitFlags>
|
||||
{};
|
||||
|
||||
class MyFace :
|
||||
public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3d, vcg::face::FFAdj, vcg::face::Mark, vcg::face::BitFlags >
|
||||
{};
|
||||
|
||||
class MyMesh :
|
||||
public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> >
|
||||
{};
|
||||
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
std::vector<vcg::Point3d>* vcg::PointMatchingScale::fix;
|
||||
std::vector<vcg::Point3d>* vcg::PointMatchingScale::mov;
|
||||
vcg::Box3d vcg::PointMatchingScale::b;
|
||||
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
if(argc<3) {
|
||||
printf("Usage: trimesh_smooth <filename> <filename>\n");
|
||||
return 0;
|
||||
}
|
||||
std::string outputname = "output.ply";
|
||||
if (argc == 4){
|
||||
outputname = std::string(argv[3]);
|
||||
}
|
||||
|
||||
MyMesh m1, m2;
|
||||
|
||||
//open first mesh
|
||||
int err = tri::io::Importer<MyMesh>::Open(m1,argv[1]);
|
||||
if(err) { // all the importers return 0 in case of success
|
||||
printf("Error in reading %s: '%s'\n", argv[1], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//open second mesh
|
||||
err = tri::io::Importer<MyMesh>::Open(m2,argv[2]);
|
||||
if(err) { // all the importers return 0 in case of success
|
||||
printf("Error in reading %s: '%s'\n", argv[2], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//update normals
|
||||
vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFace(m1);
|
||||
vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFace(m2);
|
||||
|
||||
////PARAMS
|
||||
vcg::AlignPair::Result result;
|
||||
vcg::AlignPair::Param ap;
|
||||
vcg::AlignPair::A2Mesh fix;
|
||||
vcg::AlignPair aa;
|
||||
|
||||
// 1) Convert fixed mesh and put it into the grid.
|
||||
aa.convertMesh<MyMesh>(m1,fix);
|
||||
|
||||
vcg::AlignPair::A2Grid UG;
|
||||
vcg::AlignPair::A2GridVert VG;
|
||||
|
||||
if(m1.fn==0 || ap.UseVertexOnly) {
|
||||
fix.initVert(vcg::Matrix44d::Identity());
|
||||
vcg::AlignPair::InitFixVert(&fix,ap,VG);
|
||||
}
|
||||
else {
|
||||
fix.init(vcg::Matrix44d::Identity());
|
||||
vcg::AlignPair::initFix(&fix, ap, UG);
|
||||
}
|
||||
|
||||
|
||||
// 2) Convert the second mesh and sample a <ap.SampleNum> points on it.
|
||||
std::vector<vcg::AlignPair::A2Vertex> tmpmv;
|
||||
aa.convertVertex(m2.vert,tmpmv);
|
||||
aa.sampleMovVert(tmpmv, ap.SampleNum, ap.SampleMode);
|
||||
|
||||
aa.mov=&tmpmv;
|
||||
aa.fix=&fix;
|
||||
aa.ap = ap;
|
||||
|
||||
//use identity as first matrix
|
||||
vcg::Matrix44d In;
|
||||
In.SetIdentity();
|
||||
|
||||
// Perform the ICP algorithm
|
||||
aa.align(In,UG,VG,result);
|
||||
|
||||
//rotate m2 using the resulting transformation
|
||||
tri::UpdatePosition<MyMesh>::Matrix(m2, result.Tr, true);
|
||||
tri::UpdateBounding<MyMesh>::Box(m2);
|
||||
|
||||
//saves the rotated mesh
|
||||
tri::io::ExporterPLY<MyMesh>::Save(m2 ,outputname.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
include(../common.pri)
|
||||
|
||||
TARGET = trimesh_align_pair
|
||||
|
||||
SOURCES += \
|
||||
trimesh_align_pair.cpp \
|
||||
../../../wrap/ply/plylib.cpp
|
|
@ -81,11 +81,12 @@ int main()
|
|||
vcg::tri::Allocator<MyMesh>::DeleteFace(m,m.face[3]);
|
||||
|
||||
// If you loop in a mesh with deleted elements you have to skip them!
|
||||
MyMesh::CoordType b(0,0,0);
|
||||
for(fi = m.face.begin(); fi!=m.face.end(); ++fi )
|
||||
{
|
||||
if(!fi->IsD()) // <---- Check added
|
||||
{
|
||||
MyMesh::CoordType b = vcg::Barycenter(*fi);
|
||||
b += vcg::Barycenter(*fi);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +95,7 @@ int main()
|
|||
{
|
||||
if(!fi->IsD())
|
||||
{
|
||||
MyMesh::CoordType b = vcg::Barycenter(*fi);
|
||||
b += vcg::Barycenter(*fi);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = trimesh_attribute
|
||||
SOURCES += trimesh_attribute.cpp ../../../wrap/ply/plylib.cpp
|
||||
SOURCES += trimesh_attribute.cpp
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/****************************************************************************
|
||||
* 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_attribute.cpp
|
||||
\ingroup code_sample
|
||||
|
||||
\brief the minimal example of using the attributes
|
||||
|
||||
Attributes are a simple mechanism to associate user-defined 'attributes' to the simplicies and to the mesh.
|
||||
See the page '\ref attributes' for more details.
|
||||
*/
|
||||
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/create/platonic.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<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::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags> {};
|
||||
|
||||
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
|
||||
int main()
|
||||
{
|
||||
MyMesh m;
|
||||
Torus<MyMesh>(m, 3.0f, 1.0f);
|
||||
//! [Adding a few attributes]
|
||||
// add a per-vertex attribute with type float named "GaussianCurvature"
|
||||
MyMesh::PerVertexAttributeHandle<float>
|
||||
hvf = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<float> (m,std::string("GaussianCurvature"));
|
||||
|
||||
MyMesh::PerVertexAttributeHandle<vcg::Point3f>
|
||||
hv3f = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<vcg::Point3f> (m,std::string("InvertedNormal"));
|
||||
|
||||
// add a per-face attribute with type float named "FaceArea"
|
||||
MyMesh::PerFaceAttributeHandle<float>
|
||||
hff = vcg::tri::Allocator<MyMesh>:: GetPerFaceAttribute<float> (m,std::string("FaceArea"));
|
||||
//! [filling the attribute]
|
||||
vcg::tri::Allocator<MyMesh>::ClearPerVertexAttribute<float>(m,hvf, float(M_PI*2));
|
||||
vcg::tri::Allocator<MyMesh>::ClearPerVertexAttribute<vcg::Point3f>(m,hv3f, vcg::Point3f(0,0,0));
|
||||
|
||||
ForEachFace(m, [&](MyFace &f){
|
||||
hff[&f]=vcg::DoubleArea(f)*0.5f;
|
||||
for(int i=0;i<3;++i){
|
||||
hvf[f.V(i)] -= vcg::Angle(f.P1(i)-f.P0(i),f.P2(i)-f.P0(i));
|
||||
hv3f[f.V(i)] -= vcg::NormalizedTriangleNormal(f);
|
||||
}
|
||||
});
|
||||
|
||||
//! [Saving 3 attributes in ply, one of the 3 disguised as quality]
|
||||
vcg::tri::io::PlyInfo pi;
|
||||
pi.AddPerVertexFloatAttribute("GaussianCurvature","quality");
|
||||
pi.AddPerFaceFloatAttribute("FaceArea");
|
||||
pi.AddPerVertexPoint3fAttribute(m,"InvertedNormal");
|
||||
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,"MeshWithCurvature.ply",false,pi);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = trimesh_attribute_saving
|
||||
SOURCES += trimesh_attribute_saving.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -21,11 +21,6 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#include<vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/create/ball_pivoting.h>
|
||||
|
||||
// input output
|
||||
|
@ -107,8 +102,7 @@ int main(int argc, char **argv)
|
|||
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
||||
printf("Created in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1);
|
||||
|
||||
vcg::tri::io::PlyInfo pi;
|
||||
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,argv[2],pi.mask);
|
||||
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,argv[2]);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
|
||||
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
|
||||
project (trimesh_base)
|
||||
add_executable(trimesh_base trimesh_base.cpp)
|
||||
include_directories(../../..)
|
||||
include_directories(../../../eigenlib)
|
|
@ -31,8 +31,6 @@ This file contain a minimal example of the library, showing how to load a mesh a
|
|||
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<wrap/io_trimesh/import_off.h>
|
||||
#include<vcg/complex/algorithms/update/topology.h>
|
||||
#include<vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
class MyVertex; class MyEdge; class MyFace;
|
||||
struct MyUsedTypes : public vcg::UsedTypes<vcg::Use<MyVertex> ::AsVertexType,
|
||||
|
|
|
@ -1,21 +1,35 @@
|
|||
/****************************************************************************
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
// stuff to define the mesh
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <vcg/simplex/face/component_ep.h>
|
||||
#include <vcg/complex/algorithms/point_sampling.h>
|
||||
#include <vcg/complex/algorithms/update/component_ep.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/point_sampling.h>
|
||||
|
||||
// io
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <sys/timeb.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
class BaseVertex;
|
||||
class BaseEdge;
|
||||
|
|
|
@ -28,13 +28,8 @@
|
|||
*/
|
||||
#include<vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/clustering.h>
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
|
||||
|
|
|
@ -28,11 +28,7 @@
|
|||
*/
|
||||
#include<vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/update/bounding.h>
|
||||
#include <vcg/complex/algorithms/update/color.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/clustering.h>
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
|
|
|
@ -1,27 +1,15 @@
|
|||
|
||||
// stuff to define the mesh
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <vcg/complex/append.h>
|
||||
// io
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <sys/timeb.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
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::VFAdj,vcg::vertex::Coord3f,vcg::vertex::Normal3f,vcg::vertex::Mark,vcg::vertex::BitFlags >
|
||||
{
|
||||
};
|
||||
class MyVertex : public vcg::Vertex< MyUsedTypes,vcg::vertex::VFAdj,vcg::vertex::Coord3f,vcg::vertex::Normal3f,vcg::vertex::Mark,vcg::vertex::BitFlags > {};
|
||||
|
||||
class MyEdge : public vcg::Edge< MyUsedTypes> {};
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/****************************************************************************
|
||||
* 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_create.cpp
|
||||
\ingroup code_sample
|
||||
|
||||
\brief Some examples of building meshes out of nothing
|
||||
|
||||
*/
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/export_off.h>
|
||||
|
||||
class MyFace;
|
||||
class MyVertex;
|
||||
|
||||
struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex>::AsVertexType, vcg::Use<MyFace>::AsFaceType>{};
|
||||
|
||||
class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Color4b, vcg::vertex::BitFlags >{};
|
||||
class MyFace : public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::FFAdj, vcg::face::BitFlags > {};
|
||||
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
|
||||
int main()
|
||||
{
|
||||
MyMesh diskMesh;
|
||||
|
||||
// Create a simple triangle mesh using just a vector of coords and a vector of indexes
|
||||
vector<Point3f> coordVec;
|
||||
vector<Point3i> indexVec;
|
||||
coordVec.push_back(Point3f(0,0,0));
|
||||
for(int i=0;i<36;++i) {
|
||||
float angleRad = float(i)*M_PI/18.0;
|
||||
coordVec.push_back(Point3f(sin(angleRad),cos(angleRad),0));
|
||||
indexVec.push_back(Point3i(0,i+1,1+(i+1)%36));
|
||||
}
|
||||
|
||||
tri::BuildMeshFromCoordVectorIndexVector(diskMesh,coordVec,indexVec);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(diskMesh,"disc.off");
|
||||
|
||||
// Create the platonic solids
|
||||
MyMesh platonicMesh;
|
||||
tri::Tetrahedron(platonicMesh);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(platonicMesh,"tetrahedron.off");
|
||||
tri::Octahedron(platonicMesh);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(platonicMesh,"octahedron.off");
|
||||
tri::Hexahedron(platonicMesh);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(platonicMesh,"hexahedron.off");
|
||||
tri::Dodecahedron(platonicMesh);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(platonicMesh,"dodecahedron.off");
|
||||
tri::Icosahedron(platonicMesh);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(platonicMesh,"icosahedron.off");
|
||||
|
||||
// Procedurally transform a mesh into a solid collection of triangular prisms
|
||||
MyMesh facePrismMesh;
|
||||
tri::BuildPrismFaceShell(platonicMesh, facePrismMesh, 0.1f, 0.1f);
|
||||
tri::io::ExporterOFF<MyMesh>::Save(facePrismMesh,"facePrism.off");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = trimesh_create
|
||||
SOURCES += trimesh_create.cpp
|
|
@ -25,16 +25,13 @@
|
|||
|
||||
\brief an example showing the various techniques for computing curvatures
|
||||
|
||||
This file contain a minimal example of the library
|
||||
|
||||
*/
|
||||
#include<vcg/complex/complex.h>
|
||||
#include <vcg/complex/complex.h>
|
||||
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/update/curvature.h>
|
||||
|
||||
#include<wrap/io_trimesh/export_off.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
|
||||
#include<vcg/complex/algorithms/update/curvature.h>
|
||||
#include<vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
class MyEdge;
|
||||
class MyFace;
|
||||
|
@ -43,8 +40,8 @@ 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 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> > {};
|
||||
|
||||
|
@ -52,18 +49,20 @@ int main( int /*argc*/, char **/*argv*/ )
|
|||
{
|
||||
MyMesh m;
|
||||
vcg::tri::Torus(m,30,10);
|
||||
vcg::tri::io::ExporterOFF<MyMesh>::Save(m,"torus.off");
|
||||
|
||||
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||
// vcg::tri::UpdateCurvature<MyMesh>::VertexCurvature(m);
|
||||
vcg::tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
|
||||
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
|
||||
//vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycles(m);
|
||||
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsPCA(m,m.bbox.Diag()/100);
|
||||
vcg::tri::UpdateTopology<MyMesh>::VertexFace(m);
|
||||
|
||||
vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
|
||||
// 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);
|
||||
vcg::tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
|
||||
|
||||
// Two different techniques for computing Principal Curvature Directions
|
||||
// they require the presence of the vertex::CurvatureDir component
|
||||
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
|
||||
vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycle(m);
|
||||
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
||||
printf( "Mesh has %i vert and %i faces\n", m.VN(), m.FN() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
include(../common.pri)
|
||||
SOURCES += trimesh_cylclip.cpp ../../../wrap/ply/plylib.cpp
|
||||
|
||||
HEADERS += \
|
||||
cylinder_clip.h
|
|
@ -0,0 +1,2 @@
|
|||
include(../common.pri)
|
||||
SOURCES += trimesh_cylinder_clipping.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -21,13 +21,6 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include<vcg/simplex/vertex/base.h>
|
||||
#include<vcg/simplex/vertex/component.h>
|
||||
|
||||
#include <vcg/complex/used_types.h>
|
||||
|
||||
#include<vcg/simplex/face/base.h>
|
||||
#include<vcg/simplex/face/component.h>
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/create/platonic.h>
|
||||
#include<vcg/complex/algorithms/parametrization/poisson_solver.h>
|
||||
|
@ -67,7 +60,7 @@ int main( int argc, char **argv )
|
|||
printf("Mesh has %i vn %i fn\n",m.VN(),m.FN());
|
||||
tri::PoissonSolver<MyMesh> PS(m);
|
||||
|
||||
if(!PS.IsFeaseable())
|
||||
if(!PS.IsFeasible())
|
||||
{
|
||||
printf("mesh is not homeomorphic to a disk\n");
|
||||
return -1;
|
|
@ -0,0 +1,3 @@
|
|||
include(../common.pri)
|
||||
TARGET = trimesh_disk_parametrization
|
||||
SOURCES += trimesh_disk_parametrization.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -1,13 +0,0 @@
|
|||
#DEFINES += VCG_USE_EIGEN
|
||||
|
||||
TARGET = trimesh_diskparam
|
||||
DEPENDPATH += . ../../..
|
||||
|
||||
INCLUDEPATH += . ../../..
|
||||
|
||||
CONFIG += console stl
|
||||
TEMPLATE = app
|
||||
SOURCES += trimesh_diskparam.cpp ../../../wrap/ply/plylib.cpp
|
||||
|
||||
# Mac specific Config required to avoid to make application bundles
|
||||
CONFIG -= app_bundle
|
|
@ -21,12 +21,13 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
|
||||
// This sample require gl.
|
||||
// This sample requires gl.
|
||||
#ifndef GLU_VERSIONS
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
|
@ -34,16 +35,12 @@
|
|||
#endif
|
||||
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/append.h>
|
||||
|
||||
// input output
|
||||
#include<wrap/io_trimesh/import.h>
|
||||
#include<wrap/io_trimesh/export.h>
|
||||
|
||||
// topology computation
|
||||
#include<vcg/complex/algorithms/update/topology.h>
|
||||
#include<vcg/complex/algorithms/update/bounding.h>
|
||||
#include<vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/complex/algorithms/update/position.h>
|
||||
#include <vcg/complex/algorithms/update/quality.h>
|
||||
#include <vcg/complex/algorithms/stat.h>
|
||||
|
|
|
@ -32,8 +32,6 @@ Given a mesh (an icosahedron) for each face we get a few random samples over it,
|
|||
*/
|
||||
|
||||
#include<vcg/complex/complex.h>
|
||||
#include<vcg/complex/algorithms/update/topology.h>
|
||||
#include<vcg/complex/algorithms/update/normal.h>
|
||||
#include<vcg/complex/algorithms/create/platonic.h>
|
||||
#include<vcg/complex/algorithms/point_sampling.h>
|
||||
#include<wrap/io_trimesh/import_off.h>
|
||||
|
|
|
@ -84,7 +84,7 @@ int main( int argc, char **argv )
|
|||
printf("min %f max %f\n",minmax.first,minmax.second);
|
||||
tri::io::ExporterPLY<MyMesh>::Save(m,"base.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY);
|
||||
int t0=clock();
|
||||
tri::Geodesic<MyMesh>::PerVertexDijsktraCompute(m,seedVec,ed);
|
||||
tri::Geodesic<MyMesh>::PerVertexDijkstraCompute(m,seedVec,ed);
|
||||
int t1=clock();
|
||||
printf("Geodesic dijkstra %6.3f\n",float(t1-t0)/CLOCKS_PER_SEC);
|
||||
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m);
|
||||
|
|
|
@ -29,16 +29,6 @@
|
|||
#include<vcg/complex/algorithms/smooth.h>
|
||||
#include<vcg/complex/algorithms/refine.h>
|
||||
|
||||
#include<vcg/complex/algorithms/update/selection.h>
|
||||
|
||||
// topology computation
|
||||
#include<vcg/complex/algorithms/update/topology.h>
|
||||
#include <vcg/complex/algorithms/update/flag.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
|
||||
// half edge iterators
|
||||
#include<vcg/simplex/face/pos.h>
|
||||
|
||||
// input output
|
||||
#include <wrap/io_trimesh/import_ply.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/****************************************************************************
|
||||
* 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_create.cpp
|
||||
\ingroup code_sample
|
||||
|
||||
\brief A very simple example that open a fbx file and save it as an obj.
|
||||
Just as an example of what you should add to your project to compile it:
|
||||
../../../wrap/openfbx/src/ofbx.cpp
|
||||
../../../wrap/openfbx/src/miniz.c
|
||||
|
||||
|
||||
*/
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <wrap/io_trimesh/import_fbx.h>
|
||||
#include <wrap/io_trimesh/export_obj.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
class MyFace;
|
||||
class MyEdge;
|
||||
class MyVertex;
|
||||
|
||||
struct MyUsedTypes : public UsedTypes<Use<MyVertex>::AsVertexType, Use<MyFace>::AsFaceType>{};
|
||||
|
||||
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::Qualityf, vertex::Color4b,vertex::BitFlags >{};
|
||||
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::Qualityf, face::WedgeTexCoord2f, face::Color4b, face::BitFlags > {};
|
||||
class MyMesh : public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> >{};
|
||||
|
||||
int main()
|
||||
{
|
||||
MyMesh openMesh;
|
||||
|
||||
// tri::io::ImporterFBX<MyMesh>::Open(openMesh,"Arabic_Censer/Arabic_Censer.FBX");
|
||||
// tri::io::ImporterFBX<MyMesh>::Open(openMesh,"elephant/ELEPHANT_M.fbx");
|
||||
tri::io::ImporterFBX<MyMesh>::Open(openMesh,"liontemple/sketchfabTemp.obj.fbx");
|
||||
|
||||
tri::io::ExporterOBJ<MyMesh>::Save(openMesh,"sphere.obj",tri::io::Mask::IOM_WEDGTEXCOORD);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
include(../common.pri)
|
||||
TARGET = trimesh_import_fbx
|
||||
SOURCES += trimesh_import_fbx.cpp \
|
||||
../../../wrap/openfbx/src/ofbx.cpp \
|
||||
../../../wrap/openfbx/src/miniz.c
|
||||
|
||||
CONFIG += c++11
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
#include <iostream>
|
||||
#include <QTime>
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
@ -21,7 +20,7 @@
|
|||
int num_test = 1000;
|
||||
int kNearest = 256;
|
||||
float queryDist = 0.0037;
|
||||
float ratio = 1000.0f;
|
||||
float bboxratio = 1000.0f;
|
||||
|
||||
|
||||
class CVertex;
|
||||
|
@ -34,6 +33,10 @@ class CFace : public vcg::Face < CUsedTypes, vcg::face::VertexRef>{};
|
|||
|
||||
class CMesh : public vcg::tri::TriMesh < std::vector< CVertex >, std::vector< CFace > > {};
|
||||
|
||||
int elapsed(int t)
|
||||
{
|
||||
return ((clock()-t)*1000.0)/CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct PointCloud
|
||||
|
@ -72,21 +75,19 @@ void testKDTree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
{
|
||||
std::cout << "==================================================="<< std::endl;
|
||||
std::cout << "KDTree" << std::endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
|
||||
int t0=clock();
|
||||
// Construction of the kdTree
|
||||
vcg::ConstDataWrapper<CMesh::VertexType::CoordType> wrapperVcg(&mesh.vert[0].P(), mesh.vert.size(), size_t(mesh.vert[1].P().V()) - size_t(mesh.vert[0].P().V()));
|
||||
vcg::KdTree<CMesh::ScalarType> kdTreeVcg(wrapperVcg);
|
||||
std::cout << "Build: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build: " << elapsed(t0) << " ms" << std::endl;
|
||||
int nn=1;
|
||||
// Computation of the point radius
|
||||
float mAveragePointSpacing = 0;
|
||||
time.restart();
|
||||
t0=clock();
|
||||
#pragma omp parallel for reduction(+: mAveragePointSpacing) schedule(dynamic, 10)
|
||||
for (int i = 0; i < mesh.vert.size(); i++)
|
||||
{
|
||||
#ifdef #ifdef _OPENMP
|
||||
#ifdef _OPENMP
|
||||
nn =omp_get_num_threads();
|
||||
#endif
|
||||
vcg::KdTree<CMesh::ScalarType>::PriorityQueue queue;
|
||||
|
@ -98,7 +99,7 @@ void testKDTree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
std::cout << "Num trhread " << nn << std::endl;
|
||||
mAveragePointSpacing /= mesh.vert.size();
|
||||
std::cout << "Average point radius (OpenMP with" << nn << " threads) " << mAveragePointSpacing << std::endl;
|
||||
std::cout << "Time (OpenMP): " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Time (OpenMP): " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
queryDist = mAveragePointSpacing * 150;
|
||||
|
||||
|
@ -107,11 +108,11 @@ void testKDTree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
float avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
int t0=clock();
|
||||
std::vector<unsigned int> indeces;
|
||||
std::vector<float> dists;
|
||||
kdTreeVcg.doQueryDist(mesh.vert[test_indeces[ii]].cP(), queryDist, indeces, dists);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl;
|
||||
|
||||
|
@ -120,10 +121,10 @@ void testKDTree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
int t0=clock();
|
||||
vcg::KdTree<CMesh::ScalarType>::PriorityQueue queue;
|
||||
kdTreeVcg.doQueryK(mesh.vert[test_indeces[ii]].cP(), kNearest, queue);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl;
|
||||
|
||||
|
@ -132,11 +133,11 @@ void testKDTree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
int t0=clock();
|
||||
unsigned int index;
|
||||
float minDist;
|
||||
kdTreeVcg.doQueryClosest(randomSamples[ii], index, minDist);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -163,11 +164,10 @@ void testNanoFLANN(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::ve
|
|||
> my_kd_tree_t;
|
||||
|
||||
// Construction of the nanoFLANN KDtree
|
||||
QTime time;
|
||||
time.start();
|
||||
int t0=clock();
|
||||
my_kd_tree_t index(3, cloud, nanoflann::KDTreeSingleIndexAdaptorParams(16) );
|
||||
index.buildIndex();
|
||||
std::cout << "Build nanoFlann: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build nanoFlann: " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
// Test with the radius search
|
||||
std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
|
||||
|
@ -176,9 +176,9 @@ void testNanoFLANN(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::ve
|
|||
nanoflann::SearchParams params;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
const size_t nMatches = index.radiusSearch(mesh.vert[test_indeces[ii]].P().V(), queryDist, ret_matches, params);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl;
|
||||
|
||||
|
@ -189,9 +189,9 @@ void testNanoFLANN(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::ve
|
|||
std::vector<float> out_dist_sqr(kNearest);
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
index.knnSearch(mesh.vert[test_indeces[ii]].P().V(), kNearest, &ret_index[0], &out_dist_sqr[0]);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl;
|
||||
|
||||
|
@ -202,9 +202,9 @@ void testNanoFLANN(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::ve
|
|||
std::vector<float> out_dist_sqr_clos(1);
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
index.knnSearch(randomSamples[ii].V(), 1, &ret_index_clos[0], &out_dist_sqr_clos[0]);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -214,26 +214,25 @@ void testUniformGrid(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::
|
|||
{
|
||||
std::cout << "==================================================="<< std::endl;
|
||||
std::cout << "Uniform Grid" << std::endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
int t0=clock();
|
||||
|
||||
// Construction of the uniform grid
|
||||
typedef vcg::GridStaticPtr<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
|
||||
MeshGrid uniformGrid;
|
||||
uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
|
||||
std::cout << "Build: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build: " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
// Test with the radius search
|
||||
std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
|
||||
float avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl;
|
||||
|
||||
|
@ -242,12 +241,12 @@ void testUniformGrid(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetKClosestVertex(mesh, uniformGrid, kNearest, mesh.vert[test_indeces[ii]].cP(), mesh.bbox.Diag(), vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl;
|
||||
|
||||
|
@ -256,10 +255,10 @@ void testUniformGrid(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
float minDist;
|
||||
vcg::tri::GetClosestVertex(mesh, uniformGrid, randomSamples[ii], mesh.bbox.Diag(), minDist);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -270,26 +269,25 @@ void testSpatialHashing(CMesh& mesh, std::vector<unsigned int>& test_indeces, st
|
|||
{
|
||||
std::cout << "==================================================="<< std::endl;
|
||||
std::cout << "Spatial Hashing" << std::endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
int t0=clock();
|
||||
|
||||
// Construction of the uniform grid
|
||||
typedef vcg::SpatialHashTable<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
|
||||
MeshGrid uniformGrid;
|
||||
uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
|
||||
std::cout << "Build: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build: " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
// Test with the radius search
|
||||
std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
|
||||
float avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl;
|
||||
|
||||
|
@ -298,12 +296,12 @@ void testSpatialHashing(CMesh& mesh, std::vector<unsigned int>& test_indeces, st
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetKClosestVertex(mesh, uniformGrid, kNearest, mesh.vert[test_indeces[ii]].cP(), mesh.bbox.Diag(), vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl;
|
||||
|
||||
|
@ -312,10 +310,10 @@ void testSpatialHashing(CMesh& mesh, std::vector<unsigned int>& test_indeces, st
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
float minDist;
|
||||
vcg::tri::GetClosestVertex(mesh, uniformGrid, randomSamples[ii], mesh.bbox.Diag(), minDist);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -326,26 +324,25 @@ void testPerfectSpatialHashing(CMesh& mesh, std::vector<unsigned int>& test_inde
|
|||
{
|
||||
std::cout << "==================================================="<< std::endl;
|
||||
std::cout << "Perfect Spatial Hashing" << std::endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
int t0=clock();
|
||||
|
||||
// Construction of the uniform grid
|
||||
typedef vcg::SpatialHashTable<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
|
||||
MeshGrid uniformGrid;
|
||||
uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
|
||||
std::cout << "Build: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build: " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
// Test with the radius search
|
||||
std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
|
||||
float avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -355,26 +352,25 @@ void testOctree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
{
|
||||
std::cout << "==================================================="<< std::endl;
|
||||
std::cout << "Octree" << std::endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
int t0=clock();
|
||||
|
||||
// Construction of the uniform grid
|
||||
typedef vcg::Octree<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
|
||||
MeshGrid uniformGrid;
|
||||
uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
|
||||
std::cout << "Build: " << time.elapsed() << " ms" << std::endl;
|
||||
std::cout << "Build: " << elapsed(t0) << " ms" << std::endl;
|
||||
|
||||
// Test with the radius search
|
||||
std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
|
||||
float avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)" << std::endl;
|
||||
|
||||
|
@ -383,12 +379,12 @@ void testOctree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
std::vector<CMesh::VertexPointer> vertexPtr;
|
||||
std::vector<CMesh::VertexType::CoordType> points;
|
||||
std::vector<float> dists;
|
||||
vcg::tri::GetKClosestVertex(mesh, uniformGrid, kNearest, mesh.vert[test_indeces[ii]].cP(), mesh.bbox.Diag(), vertexPtr, dists, points);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl;
|
||||
|
||||
|
@ -397,10 +393,10 @@ void testOctree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vecto
|
|||
avgTime = 0.0f;
|
||||
for (int ii = 0; ii < num_test * 10; ii++)
|
||||
{
|
||||
time.restart();
|
||||
t0=clock();
|
||||
float minDist;
|
||||
vcg::tri::GetClosestVertex(mesh, uniformGrid, randomSamples[ii], mesh.bbox.Diag(), minDist);
|
||||
avgTime += time.elapsed();
|
||||
avgTime += elapsed(t0);
|
||||
}
|
||||
std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)" << std::endl << std::endl;
|
||||
}
|
||||
|
@ -424,7 +420,7 @@ int main( int argc, char * argv[] )
|
|||
randGen.initialize(0);
|
||||
std::vector<vcg::Point3f> randomSamples;
|
||||
for (int i = 0; i < num_test * 10; i++)
|
||||
randomSamples.push_back(vcg::math::GeneratePointOnUnitSphereUniform<float>(randGen) * randGen.generate01() * mesh.bbox.Diag() / ratio);
|
||||
randomSamples.push_back(vcg::math::GeneratePointOnUnitSphereUniform<float>(randGen) * randGen.generate01() * mesh.bbox.Diag() / bboxratio);
|
||||
|
||||
std::vector<unsigned int> test_indeces;
|
||||
for (int i = 0; i < num_test * 10; i++)
|
||||
|
|
|
@ -1,22 +1,4 @@
|
|||
include(../common.pri)
|
||||
TARGET = kdTree_test
|
||||
|
||||
HEADERS = nanoflann.hpp
|
||||
|
||||
SOURCES = trimesh_indexing.cpp \
|
||||
../../../wrap/ply/plylib.cpp
|
||||
|
||||
win32-msvc2010:QMAKE_CXXFLAGS += /openmp
|
||||
win32-msvc2012:QMAKE_CXXFLAGS += /openmp
|
||||
|
||||
win32-g++:QMAKE_CXXFLAGS += -fopenmp
|
||||
win32-g++:QMAKE_LIB += -lgomp
|
||||
|
||||
mac-g++:QMAKE_CXXFLAGS += -fopenmp
|
||||
mac-g++:QMAKE_LIB += -lgomp
|
||||
|
||||
|
||||
|
||||
win32{
|
||||
DEFINES += NOMINMAX
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue