From abb29e730026783b72869be6330826da5f6c8376 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 8 Feb 2021 23:03:37 +0100 Subject: [PATCH 01/47] Close opened files when reading an STL file. --- wrap/io_trimesh/import_stl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wrap/io_trimesh/import_stl.h b/wrap/io_trimesh/import_stl.h index 90510e9d..31c9739f 100644 --- a/wrap/io_trimesh/import_stl.h +++ b/wrap/io_trimesh/import_stl.h @@ -140,6 +140,7 @@ static bool IsSTLColored(const char * filename, bool &coloredFlag, bool &magicsM } } + fclose(fp); return true; } @@ -163,6 +164,7 @@ static bool IsSTLBinary(const char * filename, bool &binaryFlag) if(file_size == expected_file_size) { binaryFlag = true; + fclose(fp); return true; } From 4ae9537e75c4535d98a61175e38a2f8667c2a65b Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Wed, 10 Feb 2021 12:33:03 +0100 Subject: [PATCH 02/47] added check for file path length when opening a mesh with the generic importer --- wrap/io_trimesh/import.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wrap/io_trimesh/import.h b/wrap/io_trimesh/import.h index 96d161bb..0961f3d8 100644 --- a/wrap/io_trimesh/import.h +++ b/wrap/io_trimesh/import.h @@ -115,7 +115,12 @@ static int Open(OpenMeshType &m, const char *filename, CallBackPos *cb=0) static int Open(OpenMeshType &m, const char *filename, int &loadmask, CallBackPos *cb=0) { int err; - if(FileExtension(filename,"ply")) + if (strlen(filename) < 3) + { + err = -1; + LastType()=KT_UNKNOWN; + } + else if(FileExtension(filename,"ply")) { err = ImporterPLY::Open(m, filename, loadmask, cb); LastType()=KT_PLY; @@ -140,7 +145,7 @@ static int Open(OpenMeshType &m, const char *filename, int &loadmask, CallBackPo err = ImporterVMI::Open(m, filename, loadmask, cb); LastType()=KT_VMI; } - else { + else { err=1; LastType()=KT_UNKNOWN; } @@ -152,7 +157,7 @@ static bool ErrorCritical(int error) { switch(LastType()) { - case KT_PLY : return (error>0); break; + case KT_PLY : return ImporterPLY::ErrorCritical(error); break; case KT_STL : return (error>0); break; case KT_OFF : return (error>0); break; case KT_OBJ : return ImporterOBJ::ErrorCritical(error); break; From e292f0cc9ba2c6516f958f88bccd6437c2d92320 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 12 Feb 2021 17:48:34 +0100 Subject: [PATCH 03/47] fix malformed file on some stl files (see https://github.com/cnr-isti-vclab/meshlab/issues/732) --- wrap/io_trimesh/import_stl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrap/io_trimesh/import_stl.h b/wrap/io_trimesh/import_stl.h index 11eb57c3..2a202098 100644 --- a/wrap/io_trimesh/import_stl.h +++ b/wrap/io_trimesh/import_stl.h @@ -150,7 +150,7 @@ static bool IsSTLColored(const char * filename, bool &coloredFlag, bool &magicsM static bool IsSTLBinary(const char * filename, bool &binaryFlag) { binaryFlag=false; - FILE *fp = fopen(filename, "r"); + FILE *fp = fopen(filename, "rb"); /* Find size of file */ fseek(fp, 0, SEEK_END); long file_size = ftell(fp); From fed787ebb9ffc6cc35eb53af1d06980618eecca6 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 2 Mar 2021 14:25:30 +0100 Subject: [PATCH 04/47] fix stl filesize computation for >2gb files (see https://github.com/cnr-isti-vclab/meshlab/issues/924) --- wrap/io_trimesh/import_stl.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wrap/io_trimesh/import_stl.h b/wrap/io_trimesh/import_stl.h index 2a202098..106067ee 100644 --- a/wrap/io_trimesh/import_stl.h +++ b/wrap/io_trimesh/import_stl.h @@ -24,7 +24,7 @@ #ifndef __VCGLIB_IMPORT_STL #define __VCGLIB_IMPORT_STL #include -#include +#include #include namespace vcg { @@ -153,13 +153,13 @@ static bool IsSTLBinary(const char * filename, bool &binaryFlag) FILE *fp = fopen(filename, "rb"); /* Find size of file */ fseek(fp, 0, SEEK_END); - long file_size = ftell(fp); + unsigned long file_size = ftell(fp); unsigned int facenum; /* Check for binary or ASCII file */ fseek(fp, STL_LABEL_SIZE, SEEK_SET); fread(&facenum, sizeof(unsigned int), 1, fp); - long expected_file_size=STL_LABEL_SIZE + 4 + (sizeof(short)+sizeof(STLFacet) )*facenum ; + unsigned long expected_file_size=STL_LABEL_SIZE + 4 + (sizeof(short)+sizeof(STLFacet) )*facenum ; if(file_size == expected_file_size) { binaryFlag = true; @@ -169,15 +169,16 @@ static bool IsSTLBinary(const char * filename, bool &binaryFlag) // second check, sometimes the size is a bit wrong, // lets'make a test to check that we find only ascii stuff before assuming it is ascii unsigned char tmpbuf[1000]; - int byte_to_read = std::min(int(sizeof(tmpbuf)), int(file_size - 80)); + unsigned long byte_to_read = std::min(sizeof(tmpbuf), file_size - 80); fread(tmpbuf, byte_to_read,1,fp); fclose(fp); - for(int i = 0; i < byte_to_read; i++) + for(unsigned long i = 0; i < byte_to_read; i++) { if(tmpbuf[i] > 127) { binaryFlag=true; - if(abs(file_size-expected_file_size) > file_size/20 ) + unsigned long diff = (file_size > expected_file_size) ? file_size-expected_file_size : expected_file_size-file_size; + if(diff > file_size/20 ) return false; // break; } From a7c1893b8d646116f19ce3c9fcbf2c4a294cfe9d Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 2 Mar 2021 15:16:02 +0100 Subject: [PATCH 05/47] fix export collada also with double precision scalars --- wrap/dae/colladaformat.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrap/dae/colladaformat.h b/wrap/dae/colladaformat.h index 29b6dfe7..3b6c6f8e 100644 --- a/wrap/dae/colladaformat.h +++ b/wrap/dae/colladaformat.h @@ -38,9 +38,9 @@ template struct CoordNumber{public: static unsigned int coord() { return 0; }}; -template<> struct CoordNumber { public: static unsigned int coord() { return 2; } }; -template<> struct CoordNumber { public: static unsigned int coord() { return 3; } }; -template<> struct CoordNumber { public: static unsigned int coord() { return 4; } }; +template struct CoordNumber> { public: static unsigned int coord() { return 2; } }; +template struct CoordNumber> { public: static unsigned int coord() { return 3; } }; +template struct CoordNumber> { public: static unsigned int coord() { return 4; } }; template<> struct CoordNumber { public: static unsigned int coord() { return 4; } }; From b54ca75043c5ddb06f7eda756b9299137b89f080 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 2 Mar 2021 15:32:35 +0100 Subject: [PATCH 06/47] fix import_stl for windows build --- wrap/io_trimesh/import_stl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wrap/io_trimesh/import_stl.h b/wrap/io_trimesh/import_stl.h index 106067ee..16517399 100644 --- a/wrap/io_trimesh/import_stl.h +++ b/wrap/io_trimesh/import_stl.h @@ -153,13 +153,13 @@ static bool IsSTLBinary(const char * filename, bool &binaryFlag) FILE *fp = fopen(filename, "rb"); /* Find size of file */ fseek(fp, 0, SEEK_END); - unsigned long file_size = ftell(fp); + std::size_t file_size = ftell(fp); unsigned int facenum; /* Check for binary or ASCII file */ fseek(fp, STL_LABEL_SIZE, SEEK_SET); fread(&facenum, sizeof(unsigned int), 1, fp); - unsigned long expected_file_size=STL_LABEL_SIZE + 4 + (sizeof(short)+sizeof(STLFacet) )*facenum ; + std::size_t expected_file_size=STL_LABEL_SIZE + 4 + (sizeof(short)+sizeof(STLFacet) )*facenum ; if(file_size == expected_file_size) { binaryFlag = true; @@ -169,15 +169,15 @@ static bool IsSTLBinary(const char * filename, bool &binaryFlag) // second check, sometimes the size is a bit wrong, // lets'make a test to check that we find only ascii stuff before assuming it is ascii unsigned char tmpbuf[1000]; - unsigned long byte_to_read = std::min(sizeof(tmpbuf), file_size - 80); + std::size_t byte_to_read = std::min(sizeof(tmpbuf), (size_t)file_size - 80); fread(tmpbuf, byte_to_read,1,fp); fclose(fp); - for(unsigned long i = 0; i < byte_to_read; i++) + for(std::size_t i = 0; i < byte_to_read; i++) { if(tmpbuf[i] > 127) { binaryFlag=true; - unsigned long diff = (file_size > expected_file_size) ? file_size-expected_file_size : expected_file_size-file_size; + std::size_t diff = (file_size > expected_file_size) ? file_size-expected_file_size : expected_file_size-file_size; if(diff > file_size/20 ) return false; // break; From 7a62fd2c7a15046e10927eee7d1825ba6a71f6c8 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Fri, 5 Mar 2021 12:30:23 +0100 Subject: [PATCH 07/47] fixed return type nonsense --- vcg/simplex/face/component_polygon.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/vcg/simplex/face/component_polygon.h b/vcg/simplex/face/component_polygon.h index 8ac67f47..b17c2f85 100644 --- a/vcg/simplex/face/component_polygon.h +++ b/vcg/simplex/face/component_polygon.h @@ -67,23 +67,23 @@ public: */ // ~PFVAdj(){ __Dealloc(); } - inline typename T::VertexType * & V( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]; } - inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } - inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } + inline typename T::VertexType * & V( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]; } + inline typename T::VertexType * V( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } + inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } /** Return the pointer to the ((j+1)%3)-th vertex of the face. @param j Index of the face vertex. */ - inline VertexType * & V0( const int j ) { return V(j);} - inline VertexType * & V1( const int j ) { return V((j+1)%this->VN());} - inline VertexType * & V2( const int j ) { return V((j+2)%this->VN());} - inline const VertexType * const & V0( const int j ) const { return V(j);} - inline const VertexType * const & V1( const int j ) const { return V((j+1)%this->VN());} - inline const VertexType * const & V2( const int j ) const { return V((j+2)%this->VN());} - inline const VertexType * const & cV0( const int j ) const { return cV(j);} - inline const VertexType * const & cV1( const int j ) const { return cV((j+1)%this->VN());} - inline const VertexType * const & cV2( const int j ) const { return cV((j+2)%this->VN());} + inline VertexType * & V0( const int j ) { return V(j);} + inline VertexType * & V1( const int j ) { return V((j+1)%this->VN());} + inline VertexType * & V2( const int j ) { return V((j+2)%this->VN());} + inline const VertexType * V0( const int j ) const { return V(j);} + inline const VertexType * V1( const int j ) const { return V((j+1)%this->VN());} + inline const VertexType * V2( const int j ) const { return V((j+2)%this->VN());} + inline const VertexType * cV0( const int j ) const { return cV(j);} + inline const VertexType * cV1( const int j ) const { return cV((j+1)%this->VN());} + inline const VertexType * cV2( const int j ) const { return cV((j+2)%this->VN());} inline CoordType &P( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]->P(); } inline CoordType cP( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]->cP(); } From 3ef68d60091d0c845f51110773662c97e0cd9116 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Fri, 5 Mar 2021 12:54:13 +0100 Subject: [PATCH 08/47] missing include --- wrap/nanoply/include/nanoply.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wrap/nanoply/include/nanoply.hpp b/wrap/nanoply/include/nanoply.hpp index d35473a6..5a213560 100644 --- a/wrap/nanoply/include/nanoply.hpp +++ b/wrap/nanoply/include/nanoply.hpp @@ -30,6 +30,7 @@ #include #include #include +#include // Avoid conflicting declaration of min/max macros in windows headers From 399ebd99ca2fdecb05bfbe0f14bfa29ddb6c3af6 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Tue, 9 Mar 2021 22:51:32 +0100 Subject: [PATCH 09/47] const --- vcg/complex/algorithms/parametrization/uv_utils.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vcg/complex/algorithms/parametrization/uv_utils.h b/vcg/complex/algorithms/parametrization/uv_utils.h index 6318310e..e93bcedf 100644 --- a/vcg/complex/algorithms/parametrization/uv_utils.h +++ b/vcg/complex/algorithms/parametrization/uv_utils.h @@ -96,11 +96,10 @@ public: } ///calculate the BBox in UV space - static vcg::Box2 PerVertUVBox(MeshType &m) + static vcg::Box2 PerVertUVBox(const MeshType &m) { vcg::Box2 UVBox; - VertexIterator vi; - for (vi=m.vert.begin();vi!=m.vert.end();vi++) + for (auto vi=m.vert.begin();vi!=m.vert.end();vi++) { if ((*vi).IsD()) continue; UVBox.Add((*vi).T().P()); From bff978189b6eeb0f22efdcfa479048e7403efbfb Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 11 Mar 2021 16:04:35 +0100 Subject: [PATCH 10/47] switch to std::shuffle in point_sampling (std::random_shuffle deprecated) --- vcg/complex/algorithms/point_sampling.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index 10047237..0afbb3ba 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -713,7 +713,7 @@ static void FillAndShuffleFacePointerVector(MeshType & m, std::vector &vertVec) { @@ -723,7 +723,7 @@ static void FillAndShuffleVertexPointerVector(MeshType & m, std::vector Date: Thu, 11 Mar 2021 18:57:18 +0100 Subject: [PATCH 11/47] using urbg generator for std::shuffle --- vcg/complex/algorithms/point_sampling.h | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index 0afbb3ba..1d61bbfd 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -494,6 +494,18 @@ static math::MarsenneTwisterRNG &SamplingRandomGenerator() return rnd; } +class MarsenneTwisterURBG +{ +public: + MarsenneTwisterURBG(unsigned int max) : _max(max) {} + typedef unsigned int result_type; + unsigned int min() const {return 0;} + unsigned int max() const {return _max;} + unsigned int operator()() {return RandomInt(_max);} +private: + unsigned int _max; +}; + // Returns an integer random number in the [0,i-1] interval using the improve Marsenne-Twister method. // this functor is needed for passing it to the std functions. static unsigned int RandomInt(unsigned int i) @@ -712,8 +724,8 @@ static void FillAndShuffleFacePointerVector(MeshType & m, std::vector &vertVec) { @@ -722,8 +734,8 @@ static void FillAndShuffleVertexPointerVector(MeshType & m, std::vector Date: Thu, 11 Mar 2021 19:21:56 +0100 Subject: [PATCH 12/47] fixes due to min/max... --- .../trimesh_sampling/trimesh_sampling.pro | 5 +++ vcg/complex/algorithms/point_sampling.h | 32 +++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/sample/trimesh_sampling/trimesh_sampling.pro b/apps/sample/trimesh_sampling/trimesh_sampling.pro index e112f066..1f9039f4 100644 --- a/apps/sample/trimesh_sampling/trimesh_sampling.pro +++ b/apps/sample/trimesh_sampling/trimesh_sampling.pro @@ -1,3 +1,8 @@ include(../common.pri) TARGET = trimesh_sampling SOURCES += trimesh_sampling.cpp + +# Awful.. +win32{ + DEFINES += NOMINMAX +} diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index 1d61bbfd..8e2418ed 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -494,18 +494,6 @@ static math::MarsenneTwisterRNG &SamplingRandomGenerator() return rnd; } -class MarsenneTwisterURBG -{ -public: - MarsenneTwisterURBG(unsigned int max) : _max(max) {} - typedef unsigned int result_type; - unsigned int min() const {return 0;} - unsigned int max() const {return _max;} - unsigned int operator()() {return RandomInt(_max);} -private: - unsigned int _max; -}; - // Returns an integer random number in the [0,i-1] interval using the improve Marsenne-Twister method. // this functor is needed for passing it to the std functions. static unsigned int RandomInt(unsigned int i) @@ -513,6 +501,18 @@ static unsigned int RandomInt(unsigned int i) return (SamplingRandomGenerator().generate(i)); } +class MarsenneTwisterURBG +{ +public: + typedef unsigned int result_type; + MarsenneTwisterURBG(result_type max) : _max(max) {} + result_type min() const {return 0;} + result_type max() const {return _max;} + result_type operator()() {return SamplingRandomGenerator().generate(_max);} +private: + result_type _max; +}; + // Returns a random number in the [0,1) real interval using the improved Marsenne-Twister method. static double RandomDouble01() { @@ -725,7 +725,7 @@ static void FillAndShuffleFacePointerVector(MeshType & m, std::vector &vertVec) { @@ -735,7 +735,7 @@ static void FillAndShuffleVertexPointerVector(MeshType & m, std::vector Date: Thu, 11 Mar 2021 19:42:30 +0100 Subject: [PATCH 13/47] using std::mt19937 --- vcg/complex/algorithms/point_sampling.h | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index 8e2418ed..702dbdef 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -35,6 +35,7 @@ sampling strategies (montecarlo, stratified etc). #ifndef __VCGLIB_POINT_SAMPLING #define __VCGLIB_POINT_SAMPLING +#include #include #include @@ -501,18 +502,6 @@ static unsigned int RandomInt(unsigned int i) return (SamplingRandomGenerator().generate(i)); } -class MarsenneTwisterURBG -{ -public: - typedef unsigned int result_type; - MarsenneTwisterURBG(result_type max) : _max(max) {} - result_type min() const {return 0;} - result_type max() const {return _max;} - result_type operator()() {return SamplingRandomGenerator().generate(_max);} -private: - result_type _max; -}; - // Returns a random number in the [0,1) real interval using the improved Marsenne-Twister method. static double RandomDouble01() { @@ -725,7 +714,9 @@ static void FillAndShuffleFacePointerVector(MeshType & m, std::vector &vertVec) { @@ -735,7 +726,9 @@ static void FillAndShuffleVertexPointerVector(MeshType & m, std::vector Date: Thu, 18 Mar 2021 17:17:09 +0100 Subject: [PATCH 14/47] face const correctness --- vcg/simplex/face/component.h | 89 ++++++++++++++++++++++++-------- vcg/simplex/face/component_ocf.h | 66 +++++++++++++++++++---- 2 files changed, 123 insertions(+), 32 deletions(-) diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index 8134eac6..2fda0b9d 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -37,10 +37,13 @@ namespace face { template class EmptyCore: public T { public: inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } inline typename T::VertexType * &FVp( const int i ) { return this->V(i); } + inline typename T::VertexType * FVp( const int i ) const { return this->cV(i); } inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } static bool HasVertexRef() { return false; } @@ -49,23 +52,28 @@ public: typedef typename T::VertexType::NormalType NormalType; typedef NormalType WedgeNormalType; NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - NormalType cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + const NormalType& N() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + const NormalType& cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } WedgeNormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - WedgeNormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + const WedgeNormalType& WN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + const WedgeNormalType& cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } typedef int WedgeTexCoordType; typedef vcg::TexCoord2 TexCoordType; TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;} - TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} + const TexCoordType & WT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} + const TexCoordType &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} typedef int FlagType; int &Flags() { static int dummyflags(0); assert(0); return dummyflags; } + int Flags() const { return 0; } int cFlags() const { return 0; } static bool HasFlags() { return false; } inline void InitIMark() { } inline int &IMark() { assert(0); static int tmp=-1; return tmp;} + inline int IMark() const { return 0;} inline int cIMark() const { return 0;} typedef int MarkType; @@ -74,13 +82,17 @@ public: typedef vcg::Color4b ColorType; typedef ColorType WedgeColorType; ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const ColorType& C() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const ColorType& cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } WedgeColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - WedgeColorType cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const WedgeColorType& WC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const WedgeColorType& cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; } - QualityType cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } + const QualityType& Q() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } + const QualityType& cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } - Quality3Type cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } + const Quality3Type& Q3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } + const Quality3Type& cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } static bool HasColor() { return false; } static bool HasQuality() { return false; } @@ -106,17 +118,22 @@ public: typedef int VFAdjType; typename T::FacePointer &VFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; } + typename T::FacePointer VFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; } typename T::FacePointer cVFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; } typename T::FacePointer &FFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; } + typename T::FacePointer FFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; } typename T::FacePointer cFFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; } typename T::EdgePointer &FEp(int) { static typename T::EdgePointer fp=0; assert(0); return fp; } + typename T::EdgePointer FEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; } typename T::EdgePointer cFEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; } typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; } + typename T::HEdgePointer FHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; } typename T::HEdgePointer cFHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; } char &VFi(int) { static char z=0; assert(0); return z;} char VFi(int) const { static char z=0; assert(0); return z;} - char &FFi(int) { static char z=0; assert(0); return z;} char cVFi(int) const { static char z=0; assert(0); return z;} + char &FFi(int) { static char z=0; assert(0); return z;} + char FFi(int) const { static char z=0; assert(0); return z;} char cFFi(int) const { static char z=0; assert(0); return z;} bool IsVFInitialized(const int j) const {return static_cast(this)->cVFi(j)!=-1;} void VFClear(int j) { @@ -135,13 +152,17 @@ public: typedef typename T::ScalarType CurScalarType; CurVecType &PD1() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } CurVecType &PD2() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } - CurVecType cPD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } - CurVecType cPD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } + const CurVecType& PD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } + const CurVecType& PD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } + const CurVecType& cPD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } + const CurVecType& cPD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; } CurScalarType &K1() { static typename T::ScalarType dummy(0); assert(0); return dummy; } CurScalarType &K2() { static typename T::ScalarType dummy(0); assert(0); return dummy; } - CurScalarType cK1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } - CurScalarType cK2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } + const CurScalarType& K1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } + const CurScalarType& K2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } + const CurScalarType& cK1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } + const CurScalarType& cK2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; } static bool HasCurvatureDir() { return false; } @@ -177,8 +198,9 @@ public: inline const typename T::VertexType * V (const int j) const { assert(j>=0 && j<3); return v[j]; } inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } - inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } /// \brief Shortcut: the position of the i-th vertex (equivalent to \c V(i)->P() ) - inline CoordType cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } + inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } /// \brief Shortcut: the position of the i-th vertex (equivalent to \c V(i)->P() ) + inline const CoordType &P( const int j ) const { assert(j>=0 && j<3); return v[j]->P(); } + inline CoordType cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } inline typename T::VertexType * & V0( const int j ) { return V(j);} /** \brief Return the pointer to the j-th vertex of the face. */ inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);} /** \brief Return the pointer to the ((j+1)%3)-th vertex of the face. */ @@ -193,6 +215,9 @@ public: inline CoordType & P0( const int j ) { return V(j)->P();} inline CoordType & P1( const int j ) { return V((j+1)%3)->P();} inline CoordType & P2( const int j ) { return V((j+2)%3)->P();} + inline const CoordType & P0( const int j ) const { return V(j)->P();} + inline const CoordType & P1( const int j ) const { return V((j+1)%3)->P();} + inline const CoordType & P2( const int j ) const { return V((j+2)%3)->P();} inline const CoordType & cP0( const int j ) const { return cV(j)->P();} inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();} inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();} @@ -240,7 +265,8 @@ template class WedgeNormal: public T { public: typedef typename T::VertexType::NormalType WedgeNormalType; inline WedgeNormalType &WN(int j) { return _wnorm[j]; } - inline WedgeNormalType cWN(int j) const { return _wnorm[j]; } + inline const WedgeNormalType& WN(int j) const { return _wnorm[j]; } + inline const WedgeNormalType& cWN(int j) const { return _wnorm[j]; } template void ImportData(const RightValueType & rightF){ if(rightF.IsWedgeNormalEnabled()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);} inline void Alloc(const int & ns){T::Alloc(ns);} @@ -256,7 +282,8 @@ template class WedgeRealNormal: public T { public: typedef A WedgeNormalType; inline WedgeNormalType &WN(int i) { return _wn[i]; } - inline WedgeNormalType cWN(int i) const { return _wn[i]; } + inline const WedgeNormalType& WN(int i) const { return _wn[i]; } + inline const WedgeNormalType& cWN(int i) const { return _wn[i]; } template void ImportData(const RightValueType & rightF){ if(RightValueType::HasWedgeNormal()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);} inline void Alloc(const int & ns){T::Alloc(ns);} @@ -293,7 +320,8 @@ public: typedef int WedgeTexCoordType; typedef A TexCoordType; TexCoordType &WT(const int i) { return _wt[i]; } - TexCoordType cWT(const int i) const { return _wt[i]; } + const TexCoordType& WT(const int i) const { return _wt[i]; } + const TexCoordType& cWT(const int i) const { return _wt[i]; } template void ImportData(const RightValueType & rightF){ if(rightF.IsWedgeTexCoordEnabled()) @@ -329,6 +357,7 @@ public: BitFlags():_flags(0) {} typedef int FlagType; int &Flags() {return _flags; } + int Flags() const {return _flags; } int cFlags() const {return _flags; } template void ImportData(const RightValueType & rightF){ @@ -351,7 +380,8 @@ public: typedef A ColorType; Color():_color(vcg::Color4b::White) {} ColorType &C() { return _color; } - ColorType cC() const { return _color; } + const ColorType& C() const { return _color; } + const ColorType& cC() const { return _color; } template void ImportData(const RightValueType & rightF){ if(rightF.IsColorEnabled()) C() = rightF.cC(); @@ -370,7 +400,8 @@ template class WedgeColor: public T { public: typedef A WedgeColorType; WedgeColorType &WC(int i) { return _color[i]; } - WedgeColorType cWC(int i) const { return _color[i]; } + const WedgeColorType& WC(int i) const { return _color[i]; } + const WedgeColorType& cWC(int i) const { return _color[i]; } template void ImportData(const RightValueType & rightF){ @@ -404,7 +435,8 @@ public: typedef A QualityType; Quality():_quality(0) {} QualityType &Q() { return _quality; } - QualityType cQ() const { return _quality; } + const QualityType& Q() const { return _quality; } + const QualityType& cQ() const { return _quality; } template void ImportData(const RightValueType & rightF){ if(rightF.IsQualityEnabled()) @@ -434,7 +466,8 @@ template class Quality3: public T { public: typedef vcg::Point3 Quality3Type; Quality3Type &Q3() { return _quality; } - Quality3Type cQ3() const { return _quality; } + const Quality3Type& Q3() const { return _quality; } + const Quality3Type& cQ3() const { return _quality; } template void ImportData(const RightValueType & rightF){ if(rightF.IsQuality3Enabled()) Q3() = rightF.cQ3(); @@ -468,6 +501,7 @@ template class Mark: public T { public: Mark():_imark(0){} inline int &IMark() { return _imark;} + inline int IMark() const { return _imark;} inline int cIMark() const { return _imark;} inline void InitIMark() { _imark = 0; } static bool HasMark() { return true; } @@ -501,11 +535,15 @@ public: CurVecType &PD1() { return _curv.max_dir;} CurVecType &PD2() { return _curv.min_dir;} + const CurVecType &PD1() const { return _curv.max_dir;} + const CurVecType &PD2() const { return _curv.min_dir;} CurVecType cPD1() const { return _curv.max_dir;} CurVecType cPD2() const { return _curv.min_dir;} CurScalarType &K1() { return _curv.k1;} CurScalarType &K2() { return _curv.k2;} + const CurScalarType &K1() const { return _curv.k1;} + const CurScalarType &K2() const { return _curv.k2;} CurScalarType cK1() const {return _curv.k1;} CurScalarType cK2() const {return _curv.k2;} template < class RightValueType> @@ -560,8 +598,10 @@ public: _vfi[2]=-1; } typename T::FacePointer &VFp(const int j) { assert(j>=0 && j<3); return _vfp[j]; } + typename T::FacePointer VFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } typename T::FacePointer cVFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; } char &VFi(const int j) {return _vfi[j]; } + char VFi(const int j)const {return _vfi[j]; } char cVFi(const int j)const {return _vfi[j]; } template void ImportData(const RightValueType & rightF){T::ImportData(rightF);} @@ -589,6 +629,7 @@ public: typename T::FacePointer &EFp(const int j) { assert(j>=0 && j<3); return _efp[j]; } typename T::FacePointer cEFp(const int j) const { assert(j>=0 && j<3); return _efp[j]; } char &VFi(const int j) {return _efi[j]; } + char VFi(const int j) const {return _efi[j]; } template void ImportData(const RightValueType & rightF){T::ImportData(rightF);} inline void Alloc(const int & ns){T::Alloc(ns);} @@ -624,12 +665,16 @@ public: _ffp[2]=nullptr; } typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<3); return _ffp[j]; } + typename T::FacePointer FFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } typename T::FacePointer cFFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; } char &FFi(const int j) { return _ffi[j]; } + char FFi(const int j) const { return _ffi[j]; } char cFFi(const int j) const { return _ffi[j]; } typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);} typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);} + typename T::FacePointer FFp1( const int j ) const { return FFp((j+1)%3);} + typename T::FacePointer FFp2( const int j ) const { return FFp((j+2)%3);} typename T::FacePointer cFFp1( const int j ) const { return FFp((j+1)%3);} typename T::FacePointer cFFp2( const int j ) const { return FFp((j+2)%3);} @@ -657,6 +702,7 @@ public: } typename T::EdgePointer &FEp( int j) { assert(j>=0 && j<3); return _fep[j]; } + typename T::EdgePointer FEp( int j) const { assert(j>=0 && j<3); return _fep[j]; } typename T::EdgePointer cFEp( int j) const { assert(j>=0 && j<3); return _fep[j]; } typename T::EdgePointer &FEp1( int j ) { return FEp((j+1)%3);} @@ -682,6 +728,7 @@ template class FHAdj: public T { public: FHAdj(){_fh=0;} typename T::HEdgePointer &FHp( ) { return _fh; } + typename T::HEdgePointer FHp( ) const { return _fh; } typename T::HEdgePointer cFHp( ) const { return _fh; } template diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index 2707dc22..3f676006 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -398,6 +398,11 @@ public: return (*this).Base().AV[(*this).Index()]._fp[j]; } + typename T::FacePointer VFp(const int j) const { + if(! (*this).Base().VFAdjacencyEnabled ) return 0; + else return (*this).Base().AV[(*this).Index()]._fp[j]; + } + typename T::FacePointer cVFp(const int j) const { if(! (*this).Base().VFAdjacencyEnabled ) return 0; else return (*this).Base().AV[(*this).Index()]._fp[j]; @@ -436,6 +441,11 @@ public: return (*this).Base().AF[(*this).Index()]._fp[j]; } + typename T::FacePointer FFp(const int j) const { + if(! (*this).Base().FFAdjacencyEnabled ) return 0; + else return (*this).Base().AF[(*this).Index()]._fp[j]; + } + typename T::FacePointer cFFp(const int j) const { if(! (*this).Base().FFAdjacencyEnabled ) return 0; else return (*this).Base().AF[(*this).Index()]._fp[j]; @@ -445,6 +455,12 @@ public: assert((*this).Base().FFAdjacencyEnabled); return (*this).Base().AF[(*this).Index()]._zp[j]; } + + char FFi(const int j) const { + assert((*this).Base().FFAdjacencyEnabled); + return (*this).Base().AF[(*this).Index()]._zp[j]; + } + char cFFi(const int j) const { assert((*this).Base().FFAdjacencyEnabled); return (*this).Base().AF[(*this).Index()]._zp[j]; @@ -452,11 +468,14 @@ public: typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);} typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);} + typename T::FacePointer FFp1( const int j ) const { return FFp((j+1)%3);} + typename T::FacePointer FFp2( const int j ) const { return FFp((j+2)%3);} typename T::FacePointer cFFp1( const int j ) const { return FFp((j+1)%3);} typename T::FacePointer cFFp2( const int j ) const { return FFp((j+2)%3);} typename T::FacePointer &Neigh( const int j ) { return FFp(j);} - typename T::FacePointer cNeigh( const int j ) const { return cFFp(j);} + typename T::FacePointer Neigh( const int j ) const { return FFp(j);} + typename T::FacePointer cNeigh( const int j ) const { return FFp(j);} unsigned int SizeNeigh(){return 3;} template @@ -479,7 +498,13 @@ public: // you cannot use Normals before enabling them with: yourmesh.face.EnableNormal() assert((*this).Base().NormalEnabled); return (*this).Base().NV[(*this).Index()]; } - NormalType cN() const { + + const NormalType& N() const { + // you cannot use Normals before enabling them with: yourmesh.face.EnableNormal() + assert((*this).Base().NormalEnabled); + return (*this).Base().NV[(*this).Index()]; } + + const NormalType& cN() const { // you cannot use Normals before enabling them with: yourmesh.face.EnableNormal() assert((*this).Base().NormalEnabled); return (*this).Base().NV[(*this).Index()]; } @@ -518,13 +543,17 @@ public: CurVecType &PD1() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; } CurVecType &PD2() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; } - CurVecType cPD1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; } - CurVecType cPD2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; } + const CurVecType& PD1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; } + const CurVecType& PD2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; } + const CurVecType& cPD1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; } + const CurVecType& cPD2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; } CurScalarType &K1() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k1; } CurScalarType &K2() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k2; } - CurScalarType cK1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k1; } - CurScalarType cK2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k2; } + const CurScalarType& K1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k1; } + const CurScalarType& K2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k2; } + const CurScalarType& cK1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k1; } + const CurScalarType& cK2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].k2; } template void ImportData(const RightFaceType & rightF){ @@ -554,7 +583,11 @@ public: assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; } - QualityType cQ() const { + const QualityType& Q() const { + assert((*this).Base().QualityEnabled); + return (*this).Base().QV[(*this).Index()]; + } + const QualityType& cQ() const { assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; } @@ -580,7 +613,11 @@ public: assert((*this).Base()._ColorEnabled); return (*this).Base().CV[(*this).Index()]; } - ColorType cC() const { + const ColorType& C() const { + assert((*this).Base()._ColorEnabled); + return (*this).Base().CV[(*this).Index()]; + } + const ColorType& cC() const { assert((*this).Base()._ColorEnabled); return (*this).Base().CV[(*this).Index()]; } @@ -605,6 +642,10 @@ public: assert((*this).Base().MarkEnabled); return (*this).Base().MV[(*this).Index()]; } + inline int IMark() const { + assert((*this).Base().MarkEnabled); + return (*this).Base().MV[(*this).Index()]; + } inline int cIMark() const { assert((*this).Base().MarkEnabled); return (*this).Base().MV[(*this).Index()]; @@ -628,7 +669,8 @@ public: WedgeTexCoordOcf(){ } typedef A TexCoordType; TexCoordType &WT(const int i) { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } - TexCoordType cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } + const TexCoordType& WT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } + const TexCoordType& cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } template void ImportData(const RightFaceType & rightF){ if(this->IsWedgeTexCoordEnabled() && rightF.IsWedgeTexCoordEnabled()) @@ -648,7 +690,8 @@ public: WedgeColorOcf(){ } typedef A WedgeColorType; WedgeColorType &WC(const int i) { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; } - const WedgeColorType cWC(const int i) const { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; } + const WedgeColorType& WC(const int i) const { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; } + const WedgeColorType& cWC(const int i) const { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; } template void ImportData(const RightFaceType & rightF){ if(this->IsWedgeColorEnabled() && rightF.IsWedgeColorEnabled()) @@ -668,7 +711,8 @@ public: WedgeNormalOcf(){ } typedef A WedgeNormalType; WedgeNormalType &WN(const int i) { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; } - WedgeNormalType const &cWN(const int i) const { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; } + const WedgeNormalType & WN(const int i) const { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; } + const WedgeNormalType &cWN(const int i) const { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; } template void ImportData(const RightFaceType & rightF){ if(this->IsWedgeNormalEnabled() && rightF.IsWedgeNormalEnabled()) From a1e1ba882f47249b3445e2ac6b31f7e288dff885 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 18 Mar 2021 17:23:27 +0100 Subject: [PATCH 15/47] 3ds const correctness --- wrap/io_trimesh/export_3ds.h | 273 +++++++++++++++++----------------- wrap/io_trimesh/export_obj.h | 2 +- wrap/io_trimesh/io_material.h | 21 +-- 3 files changed, 151 insertions(+), 145 deletions(-) diff --git a/wrap/io_trimesh/export_3ds.h b/wrap/io_trimesh/export_3ds.h index 69e4bd15..927cae0f 100644 --- a/wrap/io_trimesh/export_3ds.h +++ b/wrap/io_trimesh/export_3ds.h @@ -149,7 +149,7 @@ namespace io { /* function which saves in 3DS file format */ - static int SaveBinary(SaveMeshType &m, const char * filename, const int &mask, CallBackPos *cb=0) + static int SaveBinary(const SaveMeshType &m, const char * filename, const int &mask, CallBackPos *cb=0) { if(m.vn > MAX_POLYGONS)//check max polygons return E_NOTNUMBERVERTVALID; @@ -222,28 +222,29 @@ namespace io { int nface = 0; if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD) ) { - FaceIterator fi; - for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() ) - { - for(unsigned int k=0;k<3;k++) + for(const auto& f : m.face) { + if( !f.IsD() ) { - int i = GetIndexVertex(m, (*fi).V(k)); - vcg::TexCoord2 t = (*fi).WT(k); - if(!m.vert[i].IsD()) + for(unsigned int k=0;k<3;k++) { - if(AddDuplexVertexCoord(ListOfDuplexVert,Key(i,t))) + int i = GetIndexVertex(m, f.cV(k)); + vcg::TexCoord2 t = f.cWT(k); + if(!m.vert[i].IsD()) { - VectorOfVertexType.push_back((*(*fi).V(k))); - ListOfDuplexVert[Key(i,t)] = int(VectorOfVertexType.size()-1); - count++; + if(AddDuplexVertexCoord(ListOfDuplexVert,Key(i,t))) + { + VectorOfVertexType.push_back((*f.V(k))); + ListOfDuplexVert[Key(i,t)] = int(VectorOfVertexType.size()-1); + count++; + } } } - } - if (cb !=NULL) - (*cb)(100.0 * (float)++nface/(float)m.face.size(), "calc duplex vertex ..."); - else - return E_ABORTED; + if (cb !=NULL) + (*cb)(100.0 * (float)++nface/(float)m.face.size(), "calc duplex vertex ..."); + else + return E_ABORTED; + } } } @@ -267,7 +268,6 @@ namespace io { lib3ds_mesh_new_texel_list(mesh,m.vn + number_vertex_to_duplicate); //set number of textures int v_index = 0; - VertexIterator vi; //saves vert if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD )) { @@ -288,134 +288,139 @@ namespace io { } else { - VertRemap.resize(m.vert.size(),-1); - for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if( !(*vi).IsD() ) - { - Lib3dsPoint point; - point.pos[0] = (*vi).P()[0]; - point.pos[1] = (*vi).P()[1]; - point.pos[2] = (*vi).P()[2]; + VertRemap.resize(m.vert.size(),-1); + unsigned int vi = 0; + for(const auto& v : m.vert) { + if( !v.IsD() ) + { + Lib3dsPoint point; + point.pos[0] = v.P()[0]; + point.pos[1] = v.P()[1]; + point.pos[2] = v.P()[2]; - mesh->pointL[v_index] = point; - VertRemap[vi-m.vert.begin()]=v_index; - if (cb !=NULL) - (*cb)(100.0 * (float)++current/(float)max, "writing vertices "); - else - return E_ABORTED; - v_index++; + mesh->pointL[v_index] = point; + VertRemap[vi]=v_index; + if (cb !=NULL) + (*cb)(100.0 * (float)++current/(float)max, "writing vertices "); + else + return E_ABORTED; + v_index++; + } + vi++; } } lib3ds_mesh_new_face_list (mesh, m.face.size());//set number of faces int f_index = 0;//face index //int t_index = 0;//texture index - FaceIterator fi; - for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() ) - { - vcg::TexCoord2 t0(0,0),t1(0,0),t2(0,0); - int i0 = GetIndexVertex(m, (*fi).V(0)); - int i1 = GetIndexVertex(m, (*fi).V(1)); - int i2 = GetIndexVertex(m, (*fi).V(2)); - if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) + for(const auto& f : m.face) { + if( !f.IsD() ) { - t0 = (*fi).WT(0); - t1 = (*fi).WT(1); - t2 = (*fi).WT(2); - } - - Lib3dsFace face; - if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD )) - { - face.points[0] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i0,t0)); - face.points[1] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i1,t1)); - face.points[2] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i2,t2)); - } - else - { - face.points[0] = VertRemap[i0]; - face.points[1] = VertRemap[i1]; - face.points[2] = VertRemap[i2]; - } - - //saves coord textures - if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) - { - mesh->texelL[face.points[0]][0] = t0.u(); - mesh->texelL[face.points[0]][1] = t0.v(); - mesh->texelL[face.points[1]][0] = t1.u(); - mesh->texelL[face.points[1]][1] = t1.v(); - mesh->texelL[face.points[2]][0] = t2.u(); - mesh->texelL[face.points[2]][1] = t2.v(); - } - - if(mask & vcg::tri::io::Mask::IOM_FACEFLAGS) - face.flags = 0; - - face.smoothing = 10; - - if((mask & vcg::tri::io::Mask::IOM_FACENORMAL) | (mask & vcg::tri::io::Mask::IOM_WEDGNORMAL) ) - { - face.normal[0] = (*fi).N()[0]; - face.normal[1] = (*fi).N()[1]; - face.normal[2] = (*fi).N()[2]; - } - - if((mask & vcg::tri::io::Mask::IOM_FACECOLOR) | (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)) - { - int material_index = vcg::tri::io::Materials::CreateNewMaterial(m, materials, fi); - if(material_index == (int)materials.size()) + vcg::TexCoord2 t0(0,0),t1(0,0),t2(0,0); + int i0 = GetIndexVertex(m, f.cV(0)); + int i1 = GetIndexVertex(m, f.cV(1)); + int i2 = GetIndexVertex(m, f.cV(2)); + if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) { - Lib3dsMaterial *material = lib3ds_material_new();//creates a new material - - std::string name = qnamematerial.arg(material_index-1).toStdString(); - strcpy(material->name,name.c_str());//copy new name of material + t0 = f.cWT(0); + t1 = f.cWT(1); + t2 = f.cWT(2); + } - if(mask & vcg::tri::io::Mask::IOM_FACECOLOR) - { - //ambient - material->ambient[0] = materials[materials.size()-1].Ka[0]; - material->ambient[1] = materials[materials.size()-1].Ka[1]; - material->ambient[2] = materials[materials.size()-1].Ka[2]; - material->ambient[3] = materials[materials.size()-1].Tr; - - //diffuse - material->diffuse[0] = materials[materials.size()-1].Kd[0]; - material->diffuse[1] = materials[materials.size()-1].Kd[1]; - material->diffuse[2] = materials[materials.size()-1].Kd[2]; - material->diffuse[3] = materials[materials.size()-1].Tr; - - //specular - material->specular[0] = materials[materials.size()-1].Ks[0]; - material->specular[1] = materials[materials.size()-1].Ks[1]; - material->specular[2] = materials[materials.size()-1].Ks[2]; - material->specular[3] = materials[materials.size()-1].Tr; - - //shininess - material->shininess = materials[materials.size()-1].Ns; - } - - //texture - if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) - strcpy(material->texture1_map.name,materials[materials.size()-1].map_Kd.c_str()); - - lib3ds_file_insert_material(file,material);//inserts the material inside the file - strcpy(face.material,name.c_str()); + Lib3dsFace face; + if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD )) + { + face.points[0] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i0,t0)); + face.points[1] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i1,t1)); + face.points[2] = GetIndexDuplexVertex(ListOfDuplexVert,Key(i2,t2)); } else - { - std::string name = qnamematerial.arg(material_index).toStdString(); - strcpy(face.material,name.c_str());//set name of material + { + face.points[0] = VertRemap[i0]; + face.points[1] = VertRemap[i1]; + face.points[2] = VertRemap[i2]; } + + //saves coord textures + if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) + { + mesh->texelL[face.points[0]][0] = t0.u(); + mesh->texelL[face.points[0]][1] = t0.v(); + mesh->texelL[face.points[1]][0] = t1.u(); + mesh->texelL[face.points[1]][1] = t1.v(); + mesh->texelL[face.points[2]][0] = t2.u(); + mesh->texelL[face.points[2]][1] = t2.v(); + } + + if(mask & vcg::tri::io::Mask::IOM_FACEFLAGS) + face.flags = 0; + + face.smoothing = 10; + + if((mask & vcg::tri::io::Mask::IOM_FACENORMAL) | (mask & vcg::tri::io::Mask::IOM_WEDGNORMAL) ) + { + face.normal[0] = f.cN()[0]; + face.normal[1] = f.cN()[1]; + face.normal[2] = f.cN()[2]; + } + + if((mask & vcg::tri::io::Mask::IOM_FACECOLOR) | (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)) + { + int material_index = vcg::tri::io::Materials::CreateNewMaterial(m, materials, f); + if(material_index == (int)materials.size()) + { + Lib3dsMaterial *material = lib3ds_material_new();//creates a new material + + std::string name = qnamematerial.arg(material_index-1).toStdString(); + strcpy(material->name,name.c_str());//copy new name of material + + if(mask & vcg::tri::io::Mask::IOM_FACECOLOR) + { + //ambient + material->ambient[0] = materials[materials.size()-1].Ka[0]; + material->ambient[1] = materials[materials.size()-1].Ka[1]; + material->ambient[2] = materials[materials.size()-1].Ka[2]; + material->ambient[3] = materials[materials.size()-1].Tr; + + //diffuse + material->diffuse[0] = materials[materials.size()-1].Kd[0]; + material->diffuse[1] = materials[materials.size()-1].Kd[1]; + material->diffuse[2] = materials[materials.size()-1].Kd[2]; + material->diffuse[3] = materials[materials.size()-1].Tr; + + //specular + material->specular[0] = materials[materials.size()-1].Ks[0]; + material->specular[1] = materials[materials.size()-1].Ks[1]; + material->specular[2] = materials[materials.size()-1].Ks[2]; + material->specular[3] = materials[materials.size()-1].Tr; + + //shininess + material->shininess = materials[materials.size()-1].Ns; + } + + //texture + if(HasPerWedgeTexCoord(m) && (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD ) ) + strcpy(material->texture1_map.name,materials[materials.size()-1].map_Kd.c_str()); + + lib3ds_file_insert_material(file,material);//inserts the material inside the file + strcpy(face.material,name.c_str()); + } + else + { + std::string name = qnamematerial.arg(material_index).toStdString(); + strcpy(face.material,name.c_str());//set name of material + } + } + + mesh->faceL[f_index]=face; + + if (cb !=NULL) + (*cb)(100.0 * (float)++current/(float)max, "writing faces "); + else + return E_ABORTED; + f_index++; + } - - mesh->faceL[f_index]=face; - - if (cb !=NULL) - (*cb)(100.0 * (float)++current/(float)max, "writing faces "); - else - return E_ABORTED; - f_index++; - } lib3ds_file_insert_mesh(file, mesh);//inserts the Mesh into file @@ -435,7 +440,7 @@ namespace io { /* function which saves in 3DS format */ - static int Save(SaveMeshType &m, const char * filename, const int &mask, CallBackPos *cb=0) + static int Save(const SaveMeshType &m, const char * filename, const int &mask, CallBackPos *cb=0) { return SaveBinary(m,filename,mask,cb); } @@ -443,7 +448,7 @@ namespace io { /* returns index of the vertex */ - inline static int GetIndexVertex(SaveMeshType &m, VertexType *p) + inline static int GetIndexVertex(const SaveMeshType &m, VertexType *p) { return p-&*(m.vert.begin()); } diff --git a/wrap/io_trimesh/export_obj.h b/wrap/io_trimesh/export_obj.h index c34d4b80..47597ee0 100644 --- a/wrap/io_trimesh/export_obj.h +++ b/wrap/io_trimesh/export_obj.h @@ -218,7 +218,7 @@ public: { int index=-1; if(useMaterialAttribute) index = materialIndexHandle[fi]; - else index = Materials::CreateNewMaterial(m,materialVec,fi); + else index = Materials::CreateNewMaterial(m,materialVec,*fi); if(index != curMatIndex) { fprintf(fp,"\nusemtl material_%d\n", index); diff --git a/wrap/io_trimesh/io_material.h b/wrap/io_trimesh/io_material.h index 993be356..9471a5bd 100644 --- a/wrap/io_trimesh/io_material.h +++ b/wrap/io_trimesh/io_material.h @@ -85,7 +85,8 @@ struct Material template class Materials { -public: +public: + typedef typename SaveMeshType::FaceType FaceType; typedef typename SaveMeshType::FaceIterator FaceIterator; typedef typename SaveMeshType::VertexIterator VertexIterator; typedef typename SaveMeshType::VertexType VertexType; @@ -93,20 +94,20 @@ public: /* creates a new meterial */ - inline static int CreateNewMaterial(SaveMeshType &m, std::vector &materials, FaceIterator &fi) - { + inline static int CreateNewMaterial(const SaveMeshType &m, std::vector &materials, const FaceType& f) + { Material mtl; - + if(HasPerFaceColor(m)){ - mtl.Kd = Point3f((float)((*fi).C()[0])/255.0f,(float)((*fi).C()[1])/255.0f,(float)((*fi).C()[2])/255.0f);//diffuse - mtl.Tr = (float)((*fi).C()[3])/255.0f;//alpha + mtl.Kd = Point3f((float)(f.C()[0])/255.0f,(float)(f.C()[1])/255.0f,(float)(f.C()[2])/255.0f);//diffuse + mtl.Tr = (float)(f.C()[3])/255.0f;//alpha } - - if(m.textures.size() && (*fi).WT(0).n() >=0 ) - mtl.map_Kd = m.textures[(*fi).WT(0).n()]; + + if(m.textures.size() && f.WT(0).n() >=0 ) + mtl.map_Kd = m.textures[f.WT(0).n()]; else mtl.map_Kd = ""; - + int matInd = MaterialsCompare(materials,mtl); if(matInd == -1) { From 0a2ed11ac24f9f53564b8792ed9ce278126e68ff Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 18 Mar 2021 18:21:59 +0100 Subject: [PATCH 16/47] (partial) ply const correctness --- vcg/container/simple_temporary_data.h | 8 +++-- vcg/simplex/vertex/component.h | 14 +++++++++ wrap/io_trimesh/export_ply.h | 42 ++++++++++++++++----------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index 979e4357..c1f26fa5 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -114,16 +114,16 @@ public: typedef SimpleTempData SimpTempDataType; typedef ATTR_TYPE AttrType; - STL_CONT &c; + const STL_CONT &c; VectorNBW data; int padding; - SimpleTempData(STL_CONT &_c) : c(_c), padding(0) + SimpleTempData(const STL_CONT &_c) : c(_c), padding(0) { data.reserve(c.capacity()); data.resize(c.size()); }; - SimpleTempData(STL_CONT &_c, const ATTR_TYPE &val) : c(_c) + SimpleTempData(const STL_CONT &_c, const ATTR_TYPE &val) : c(_c) { data.reserve(c.capacity()); data.resize(c.size()); @@ -142,11 +142,13 @@ public: // access to data ATTR_TYPE &operator[](const typename STL_CONT::value_type &v) { return data[&v - &*c.begin()]; } ATTR_TYPE &operator[](const typename STL_CONT::value_type *v) { return data[v - &*c.begin()]; } + ATTR_TYPE &operator[](const typename STL_CONT::const_iterator &cont) { return data[&(*cont) - &*c.begin()]; } ATTR_TYPE &operator[](const typename STL_CONT::iterator &cont) { return data[&(*cont) - &*c.begin()]; } ATTR_TYPE &operator[](size_t i) { return data[i]; } const ATTR_TYPE &operator[](const typename STL_CONT::value_type &v) const { return data[&v - &*c.begin()]; } const ATTR_TYPE &operator[](const typename STL_CONT::value_type *v) const { return data[v - &*c.begin()]; } + const ATTR_TYPE &operator[](const typename STL_CONT::const_iterator &cont) const { return data[&(*cont) - &*c.begin()]; } const ATTR_TYPE &operator[](const typename STL_CONT::iterator &cont) const { return data[&(*cont) - &*c.begin()]; } const ATTR_TYPE &operator[](size_t i) const { return data[i]; } diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index 1914dbbd..f4cab3c9 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -49,30 +49,35 @@ template class EmptyCore: public TT { public: typedef int FlagType; int &Flags() { assert(0); static int dummyflags(0); return dummyflags; } + int Flags() const { return 0; } int cFlags() const { return 0; } static bool HasFlags() { return false; } typedef vcg::Point3f CoordType; typedef CoordType::ScalarType ScalarType; CoordType &P() { assert(0); static CoordType coord(0, 0, 0); return coord; } + CoordType P() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; } CoordType cP() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; } static bool HasCoord() { return false; } inline bool IsCoordEnabled() const { return TT::VertexType::HasCoord();} typedef vcg::Point3s NormalType; NormalType &N() { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + NormalType N() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } NormalType cN() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } static bool HasNormal() { return false; } inline bool IsNormalEnabled() const { return TT::VertexType::HasNormal();} typedef float QualityType; QualityType &Q() { assert(0); static QualityType dummyQuality(0); return dummyQuality; } + QualityType Q() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; } QualityType cQ() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; } static bool HasQuality() { return false; } inline bool IsQualityEnabled() const { return TT::VertexType::HasQuality();} typedef vcg::Color4b ColorType; ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + ColorType C() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } static bool HasColor() { return false; } inline bool IsColorEnabled() const { return TT::VertexType::HasColor();} @@ -80,18 +85,21 @@ public: typedef int MarkType; void InitIMark() { } int cIMark() const { assert(0); static int tmp=-1; return tmp;} + int IMark() const { assert(0); static int tmp=-1; return tmp;} int &IMark() { assert(0); static int tmp=-1; return tmp;} static bool HasMark() { return false; } inline bool IsMarkEnabled() const { return TT::VertexType::HasMark();} typedef ScalarType RadiusType; RadiusType &R() { static ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } + RadiusType R() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } RadiusType cR() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } static bool HasRadius() { return false; } inline bool IsRadiusEnabled() const { return TT::VertexType::HasRadius();} typedef vcg::TexCoord2 TexCoordType; TexCoordType &T() { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } + TexCoordType T() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } TexCoordType cT() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } static bool HasTexCoord() { return false; } inline bool IsTexCoordEnabled() const { return TT::VertexType::HasTexCoord();} @@ -151,17 +159,23 @@ public: typedef Point2f CurvatureType; float &Kh() { static float dummy = 0.f; assert(0);return dummy;} float &Kg() { static float dummy = 0.f; assert(0);return dummy;} + float Kh() const { static float dummy = 0.f; assert(0); return dummy;} + float Kg() const { static float dummy = 0.f; assert(0); return dummy;} float cKh() const { static float dummy = 0.f; assert(0); return dummy;} float cKg() const { static float dummy = 0.f; assert(0); return dummy;} typedef CurvatureDirBaseType CurvatureDirType; CurVecType &PD1() {static CurVecType v(0,0,0); assert(0);return v;} CurVecType &PD2() {static CurVecType v(0,0,0); assert(0);return v;} + CurVecType PD1() const {static CurVecType v(0,0,0); assert(0);return v;} + CurVecType PD2() const {static CurVecType v(0,0,0); assert(0);return v;} CurVecType cPD1() const {static CurVecType v(0,0,0); assert(0);return v;} CurVecType cPD2() const {static CurVecType v(0,0,0); assert(0);return v;} CurScalarType &K1() { static ScalarType v = 0.0;assert(0);return v;} CurScalarType &K2() { static ScalarType v = 0.0;assert(0);return v;} + CurScalarType K1() const {static ScalarType v = 0.0;assert(0);return v;} + CurScalarType K2() const {static ScalarType v = 0.0;assert(0);return v;} CurScalarType cK1() const {static ScalarType v = 0.0;assert(0);return v;} CurScalarType cK2() const {static ScalarType v = 0.0;assert(0);return v;} diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index c1f45e01..05364d73 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -70,30 +70,30 @@ namespace vcg { public: typedef ::vcg::ply::PropDescriptor PropDescriptor ; - typedef typename SaveMeshType::VertexPointer VertexPointer; + typedef typename SaveMeshType::ConstVertexPointer VertexPointer; typedef typename SaveMeshType::ScalarType ScalarType; typedef typename SaveMeshType::VertexType VertexType; typedef typename SaveMeshType::FaceType FaceType; - typedef typename SaveMeshType::FacePointer FacePointer; - typedef typename SaveMeshType::VertexIterator VertexIterator; - typedef typename SaveMeshType::FaceIterator FaceIterator; - typedef typename SaveMeshType::EdgeIterator EdgeIterator; + typedef typename SaveMeshType::ConstFacePointer FacePointer; + typedef typename SaveMeshType::ConstVertexIterator VertexIterator; + typedef typename SaveMeshType::ConstFaceIterator FaceIterator; + typedef typename SaveMeshType::ConstEdgeIterator EdgeIterator; typedef typename vcg::Shot::ScalarType ShotScalarType; - static int Save(SaveMeshType &m, const char * filename, bool binary=true) + static int Save(const SaveMeshType &m, const char * filename, bool binary=true) { PlyInfo pi; return Save(m,filename,binary,pi); } - static int Save(SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 ) + static int Save(const SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 ) { PlyInfo pi; pi.mask=savemask; return Save(m,filename,binary,pi,cb); } - static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0 + static int Save(const SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0 { FILE * fpout; const char * hbin = "binary_little_endian"; @@ -437,14 +437,20 @@ namespace vcg { if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) ) fwrite(&(vp->Flags()),sizeof(int),1,fpout); - if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) ) - fwrite(&( vp->C() ),sizeof(char),4,fpout); + if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) ){ + auto c = vp->C(); + fwrite(&c,sizeof(char),4,fpout); + } - if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) ) - fwrite(&( vp->Q() ),sizeof(typename VertexType::QualityType),1,fpout); + if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) ){ + auto q = vp->Q(); + fwrite(&q, sizeof(typename VertexType::QualityType),1,fpout); + } - if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) ) - fwrite(&( vp->R() ),sizeof(typename VertexType::RadiusType),1,fpout); + if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) ){ + auto r = vp->R(); + fwrite(&r,sizeof(typename VertexType::RadiusType),1,fpout); + } if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) ) { @@ -489,7 +495,7 @@ namespace vcg { fprintf(fpout,"%.*g %.*g %.*g " ,DGT,vp->P()[0],DGT,vp->P()[1],DGT,vp->P()[2]); if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) ) - fprintf(fpout,"%.*g %.*g %.*g " ,DGT,ScalarType(vp->N()[0]),DGT,ScalarType(vp->N()[1]),DGT,ScalarType(vp->N()[2])); + fprintf(fpout,"%.*g %.*g %.*g " ,DGT,ScalarType(vp->N()[0]),DGT,ScalarType(vp->N()[1]),DGT,ScalarType(vp->N()[2])); if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS)) fprintf(fpout,"%d ",vp->Flags()); @@ -571,8 +577,10 @@ namespace vcg { fwrite(&b3char,sizeof(char),1,fpout); fwrite(vv,sizeof(int),3,fpout); - if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) ) - fwrite(&(fp->Flags()),sizeof(int),1,fpout); + if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) ){ + auto fl = fp->Flags(); + fwrite(&fl,sizeof(int),1,fpout); + } if( HasPerVertexTexCoord(m) && (!HasPerWedgeTexCoord(m)) && (pi.mask & Mask::IOM_WEDGTEXCOORD) ) // Note that you can save VT as WT if you really want it... { From 3d0e74e4721e2762da9ae768976ed0c70c30c4d2 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 18 Mar 2021 18:30:54 +0100 Subject: [PATCH 17/47] stl const correctness --- vcg/space/color4.h | 8 ++++---- wrap/io_trimesh/export_stl.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vcg/space/color4.h b/vcg/space/color4.h index f9d2b9d0..d97e7480 100644 --- a/vcg/space/color4.h +++ b/vcg/space/color4.h @@ -259,8 +259,8 @@ inline static Color4 ColorRamp(const float &minf,const float &maxf ,float v ) return rc; } -inline static unsigned short ToUnsignedB5G5R5(Color4 &) { return 0;} -inline static unsigned short ToUnsignedR5G5B5(Color4 &) { return 0;} +inline static unsigned short ToUnsignedB5G5R5(const Color4 &) { return 0;} +inline static unsigned short ToUnsignedR5G5B5(const Color4 &) { return 0;} inline static Color4 FromUnsignedB5G5R5(unsigned short) { @@ -420,7 +420,7 @@ typedef Color4 Color4d; template<> -inline unsigned short Color4::ToUnsignedB5G5R5(Color4 &cc) +inline unsigned short Color4::ToUnsignedB5G5R5(const Color4 &cc) { unsigned short r = cc[0]/8; unsigned short g = cc[1]/8; @@ -430,7 +430,7 @@ inline unsigned short Color4::ToUnsignedB5G5R5(Color4 -inline unsigned short Color4::ToUnsignedR5G5B5(Color4 &cc) +inline unsigned short Color4::ToUnsignedR5G5B5(const Color4 &cc) { unsigned short r = cc[0]/8; unsigned short g = cc[1]/8; diff --git a/wrap/io_trimesh/export_stl.h b/wrap/io_trimesh/export_stl.h index 50859273..0ed6d9c9 100644 --- a/wrap/io_trimesh/export_stl.h +++ b/wrap/io_trimesh/export_stl.h @@ -75,14 +75,14 @@ public: typedef typename SaveMeshType::FaceType FaceType; typedef unsigned short CallBackSTLFaceAttribute(const SaveMeshType &m, const FaceType &f); -static int Save(SaveMeshType &m, const char * filename, const int &mask, CallBackPos *) +static int Save(const SaveMeshType &m, const char * filename, const int &mask, CallBackPos *) { return Save(m,filename,true,mask); } -static int Save(SaveMeshType &m, const char * filename , bool binary =true, int mask=0, const char *objectname=0, bool magicsMode=0) +static int Save(const SaveMeshType &m, const char * filename , bool binary =true, int mask=0, const char *objectname=0, bool magicsMode=0) { - typedef typename SaveMeshType::FaceIterator FaceIterator; + typedef typename SaveMeshType::ConstFaceIterator FaceIterator; FILE *fp; fp = fopen(filename,"wb"); From abcde4bbed4945d9c29424cd45cfba0196fd169f Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 18 Mar 2021 18:54:15 +0100 Subject: [PATCH 18/47] vrml const correctness --- wrap/io_trimesh/export_vrml.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wrap/io_trimesh/export_vrml.h b/wrap/io_trimesh/export_vrml.h index 4348ef86..117fbd4a 100644 --- a/wrap/io_trimesh/export_vrml.h +++ b/wrap/io_trimesh/export_vrml.h @@ -57,15 +57,15 @@ namespace vcg { class ExporterWRL { public: - typedef typename SaveMeshType::VertexPointer VertexPointer; + typedef typename SaveMeshType::ConstVertexPointer VertexPointer; typedef typename SaveMeshType::ScalarType ScalarType; typedef typename SaveMeshType::VertexType VertexType; typedef typename SaveMeshType::FaceType FaceType; - typedef typename SaveMeshType::VertexIterator VertexIterator; - typedef typename SaveMeshType::FaceIterator FaceIterator; + typedef typename SaveMeshType::ConstVertexIterator VertexIterator; + typedef typename SaveMeshType::ConstFaceIterator FaceIterator; ///Standard call for saving a mesh - static int Save(SaveMeshType &m, const char * filename, const int &mask, CallBackPos * /*cb=0*/) + static int Save(const SaveMeshType &m, const char * filename, const int &mask, CallBackPos * /*cb=0*/) { FILE *fp; fp = fopen(filename,"wb"); @@ -321,4 +321,4 @@ namespace vcg { } // end Namespace tri } // end Namespace vcg -#endif \ No newline at end of file +#endif From 8f953efd0477bf0893d4c6045fafb121bd0065a2 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 19 Mar 2021 12:16:01 +0100 Subject: [PATCH 19/47] CountBitLargePolygons const correctness --- vcg/complex/algorithms/clean.h | 49 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/vcg/complex/algorithms/clean.h b/vcg/complex/algorithms/clean.h index a52c8d75..b38b01d9 100644 --- a/vcg/complex/algorithms/clean.h +++ b/vcg/complex/algorithms/clean.h @@ -168,6 +168,7 @@ public: typedef CleanMeshType MeshType; typedef typename MeshType::VertexType VertexType; typedef typename MeshType::VertexPointer VertexPointer; + typedef typename MeshType::ConstVertexPointer ConstVertexPointer; typedef typename MeshType::VertexIterator VertexIterator; typedef typename MeshType::ConstVertexIterator ConstVertexIterator; typedef typename MeshType::EdgeIterator EdgeIterator; @@ -931,30 +932,38 @@ public: } /** - * The number of polygonal faces is - * FN - EN_f (each faux edge hides exactly one triangular face or in other words a polygon of n edges has n-3 faux edges.) - * In the general case where a The number of polygonal faces is - * FN - EN_f + VN_f - * where: - * EN_f is the number of faux edges. - * VN_f is the number of faux vertices (e.g vertices completely surrounded by faux edges) - * as a intuitive proof think to a internal vertex that is collapsed onto a border of a polygon: - * it deletes 2 faces, 1 faux edges and 1 vertex so to keep the balance you have to add back the removed vertex. - */ - static int CountBitLargePolygons(MeshType &m) + * The number of polygonal faces is + * FN - EN_f (each faux edge hides exactly one triangular face or in other words a polygon of n edges has n-3 faux edges.) + * In the general case where a The number of polygonal faces is + * FN - EN_f + VN_f + * where: + * EN_f is the number of faux edges. + * VN_f is the number of faux vertices (e.g vertices completely surrounded by faux edges) + * as a intuitive proof think to a internal vertex that is collapsed onto a border of a polygon: + * it deletes 2 faces, 1 faux edges and 1 vertex so to keep the balance you have to add back the removed vertex. + */ + static int CountBitLargePolygons(const MeshType &m) { - tri::RequirePerFaceFlags(m); - UpdateFlags::VertexSetV(m); + //note - using unordered_map to set visited vertices because + //the mesh is const (before, the function used vertex flags...). + //could be used std::vector if the vertex has the Index() + //member function... + std::unordered_map vertVisited; + for (ConstVertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) + if (!vi->IsD()) vertVisited[&(*vi)] = true; + // First loop Clear all referenced vertices - for (FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) + for (ConstFaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) if (!fi->IsD()) - for(int i=0;i<3;++i) fi->V(i)->ClearV(); + for(int i=0;i<3;++i){ + vertVisited[fi->V(i)] = false; + } // Second Loop, count (twice) faux edges and mark all vertices touched by non faux edges // (e.g vertexes on the boundary of a polygon) int countE = 0; - for (FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) + for (ConstFaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) if (!fi->IsD()) { for(int i=0;i<3;++i) { @@ -962,16 +971,16 @@ public: countE++; else { - fi->V0(i)->SetV(); - fi->V1(i)->SetV(); + vertVisited[fi->V0(i)] = true; + vertVisited[fi->V1(i)] = true; } } } // Third Loop, count the number of referenced vertexes that are completely surrounded by faux edges. int countV = 0; - for (VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) - if (!vi->IsD() && !vi->IsV()) countV++; + for (ConstVertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) + if (!vi->IsD() && !(vertVisited[&(*vi)])) countV++; return m.fn - countE/2 + countV ; } From 8b369752486b3b62c752564461910b41db761adb Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 19 Mar 2021 12:58:38 +0100 Subject: [PATCH 20/47] dxf, gts and partial obj const correctness --- wrap/io_trimesh/export_dxf.h | 10 +++++----- wrap/io_trimesh/export_gts.h | 35 +++++++++++++++++++---------------- wrap/io_trimesh/export_obj.h | 10 ++++++---- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/wrap/io_trimesh/export_dxf.h b/wrap/io_trimesh/export_dxf.h index 7f4e8557..08d21bb0 100644 --- a/wrap/io_trimesh/export_dxf.h +++ b/wrap/io_trimesh/export_dxf.h @@ -41,7 +41,7 @@ class ExporterDXF typedef typename SaveMeshType::CoordType CoordType; public: ///Standard call for saving a mesh - static int Save(SaveMeshType &m, const char * filename) + static int Save(const SaveMeshType &m, const char * filename) { if(m.fn==0 && m.en != 0) return SaveEdge(m,filename); @@ -55,7 +55,7 @@ public: fprintf(o,"2\n"); fprintf(o,"ENTITIES\n"); - typename SaveMeshType::FaceIterator fi; + typename SaveMeshType::ConstFaceIterator fi; for(fi=m.face.begin(); fi!=m.face.end(); ++fi) { if (!fi->IsD()) @@ -109,7 +109,7 @@ public: } - static bool SaveEdge(SaveMeshType &m, const char * filename) + static bool SaveEdge(const SaveMeshType &m, const char * filename) { FILE * o = fopen(filename,"w"); if(o==NULL) return 1; @@ -121,7 +121,7 @@ public: fprintf(o,"2\n"); fprintf(o,"ENTITIES\n"); - typename SaveMeshType::EdgeIterator ei; + typename SaveMeshType::ConstEdgeIterator ei; for(ei=m.edge.begin(); ei!=m.edge.end();++ei) { CoordType p1 = (*ei).V(0)->P(); @@ -155,7 +155,7 @@ public: return true; } - static bool writeHeader(FILE* o, SaveMeshType &mp) + static bool writeHeader(FILE* o, const SaveMeshType &mp) { // standard DXF header // most of data is meaningless, but required by a lot of importers diff --git a/wrap/io_trimesh/export_gts.h b/wrap/io_trimesh/export_gts.h index 4af571cb..f08719f0 100644 --- a/wrap/io_trimesh/export_gts.h +++ b/wrap/io_trimesh/export_gts.h @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -45,15 +46,15 @@ namespace vcg { { public: - typedef typename SaveMeshType::VertexPointer VertexPointer; + typedef typename SaveMeshType::ConstVertexPointer VertexPointer; typedef typename SaveMeshType::ScalarType ScalarType; typedef typename SaveMeshType::VertexType VertexType; typedef typename SaveMeshType::FaceType FaceType; - typedef typename SaveMeshType::FacePointer FacePointer; - typedef typename SaveMeshType::VertexIterator VertexIterator; - typedef typename SaveMeshType::FaceIterator FaceIterator; + typedef typename SaveMeshType::ConstFacePointer FacePointer; + typedef typename SaveMeshType::ConstVertexIterator VertexIterator; + typedef typename SaveMeshType::ConstFaceIterator FaceIterator; - static int Save(SaveMeshType &m, const char * filename, int /*mask*/ ) + static int Save(const SaveMeshType &m, const char * filename, int /*mask*/ ) { QFile device(filename); if (!device.open(QFile::WriteOnly)) @@ -62,17 +63,19 @@ namespace vcg { QTextStream stream(&device); // update vertex indices - std::vector FlagV; + //std::vector FlagV; + std::unordered_map vertFlags; VertexPointer vp; VertexIterator vi; int j; for(j=0,vi=m.vert.begin(); vi!=m.vert.end(); ++vi) { vp = &(*vi); - FlagV.push_back(vp->Flags()); + //FlagV.push_back(vp->Flags()); if (!vp->IsD()) { - vp->Flags() = j; + vertFlags[vp] = j; + //vp->Flags() = j; j++; } } @@ -94,8 +97,8 @@ namespace vcg { { for (int k=0; k<3; ++k) { - int a = fp->cV(k)->Flags(); - int b = fp->cV((k+1)%3)->Flags(); + int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags(); + int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags(); if (a>b) std::swap(a,b); Edge e(a,b); @@ -132,8 +135,8 @@ namespace vcg { { for (int k=0; k<3; ++k) { - int a = fp->cV(k)->Flags(); - int b = fp->cV((k+1)%3)->Flags(); + int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags(); + int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags(); if (a>b) std::swap(a,b); Edge e(a,b); @@ -154,8 +157,8 @@ namespace vcg { { for (int k=0; k<3; ++k) { - int a = fp->cV(k)->Flags(); - int b = fp->cV((k+1)%3)->Flags(); + int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags(); + int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags(); if (a>b) std::swap(a,b); Edge e(a,b); @@ -170,8 +173,8 @@ namespace vcg { } // Recupera i flag originali - for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi) - (*vi).Flags()=FlagV[j++]; + //for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi) + // (*vi).Flags()=FlagV[j++]; int result = 0; diff --git a/wrap/io_trimesh/export_obj.h b/wrap/io_trimesh/export_obj.h index 47597ee0..ce0626fe 100644 --- a/wrap/io_trimesh/export_obj.h +++ b/wrap/io_trimesh/export_obj.h @@ -42,7 +42,9 @@ class ExporterOBJ { public: typedef typename SaveMeshType::FaceIterator FaceIterator; + typedef typename SaveMeshType::ConstFaceIterator ConstFaceIterator; typedef typename SaveMeshType::EdgeIterator EdgeIterator; + typedef typename SaveMeshType::ConstEdgeIterator ConstEdgeIterator; typedef typename SaveMeshType::VertexIterator VertexIterator; typedef typename SaveMeshType::VertexType VertexType; typedef typename SaveMeshType::ScalarType ScalarType; @@ -212,7 +214,7 @@ public: int curMatIndex = -1; std::vector materialVec; //used if we do not have material attributes - for(FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() ) + for(ConstFaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() ) { if((mask & Mask::IOM_FACECOLOR) || (mask & Mask::IOM_WEDGTEXCOORD) || (mask & Mask::IOM_VERTTEXCOORD)) { @@ -269,7 +271,7 @@ public: } // end for faces - for(EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei) if( !(*ei).IsD() ) + for(ConstEdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei) if( !(*ei).IsD() ) { fprintf(fp,"l %i %i\n", VertexId[tri::Index(m, (*ei).V(0))] + 1, @@ -312,7 +314,7 @@ public: /* returns index of the vertex normal */ - inline static int GetIndexVertexNormal(SaveMeshType &/*m*/, std::map &mapNormToInt, const CoordType &norm ) + inline static int GetIndexVertexNormal(const SaveMeshType &/*m*/, std::map &mapNormToInt, const CoordType &norm ) { typename std::map::iterator iter= mapNormToInt.find(norm); if(iter != mapNormToInt.end()) return (*iter).second; @@ -358,7 +360,7 @@ public: adds a new index to the normal per vertex if it is the first time which is otherwise met does not execute anything */ - inline static bool AddNewNormalVertex(typename std::map &m, CoordType &n ,int value) + inline static bool AddNewNormalVertex(typename std::map &m, const CoordType &n ,int value) { int index = m[n]; if(index==0){m[n]=value;return true;} From 82ce871150b1aaa9a63eb670fa782d0a989c9868 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 19 Mar 2021 13:16:48 +0100 Subject: [PATCH 21/47] const GetAllAttributeHandle --- vcg/complex/allocate.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 5ada3e88..fb088206 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1550,7 +1550,7 @@ public: \returns the name of all attributes with a non-empy name. */ template - static void GetAllPerVertexAttribute(MeshType & m, std::vector &all){ + static void GetAllPerVertexAttribute(const MeshType & m, std::vector &all){ all.clear(); typename std::set ::const_iterator i; for(i = m.vert_attr.begin(); i != m.vert_attr.end(); ++i ) @@ -1847,7 +1847,7 @@ public: } template - static void GetAllPerFaceAttribute(MeshType & m, std::vector &all){ + static void GetAllPerFaceAttribute(const MeshType & m, std::vector &all){ all.clear(); typename std::set :: const_iterator i; for(i = m.face_attr.begin(); i != m.face_attr.end(); ++i ) From f83bdf081554c3b6ac77a7a1cfd9d31040b3d8b6 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Tue, 23 Mar 2021 01:06:28 +0100 Subject: [PATCH 22/47] quick and dirty fix for polygon import from trimesh --- vcg/complex/algorithms/polygon_support.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcg/complex/algorithms/polygon_support.h b/vcg/complex/algorithms/polygon_support.h index c6df0d8e..bce0d219 100644 --- a/vcg/complex/algorithms/polygon_support.h +++ b/vcg/complex/algorithms/polygon_support.h @@ -141,7 +141,8 @@ namespace tri { { std::vector vs;// vertices of the polygon ExtractPolygon(&*tfi,vs); - std::reverse(vs.begin(),vs.end()); + if (vs.size() > 3) + std::reverse(vs.begin(), vs.end()); //now vs contains all the vertices of the polygon (still in the trimesh) if (vs.size()==0)continue; typename PolyMeshType::FaceIterator pfi = tri::Allocator::AddFaces(pm,1); From bf6c48f9bead3ef3d030ccd6f9846180e6e235df Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 12:59:45 +0100 Subject: [PATCH 23/47] fix VectorNBW bool specialization with const --- vcg/container/simple_temporary_data.h | 35 +++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index c1f26fa5..059d65c7 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -24,6 +24,11 @@ #ifndef __VCGLIB_SIMPLE__ #define __VCGLIB_SIMPLE__ +#include +#include +#include +#include + namespace vcg { @@ -42,16 +47,16 @@ public: virtual void CopyValue(const size_t to, const size_t from, const SimpleTempDataBase *other) = 0; }; -template -class VectorNBW : public std::vector +template +class VectorNBW : public std::vector { }; -template <> -class VectorNBW +template +class VectorNBW { public: - VectorNBW() : data(0), datasize(0), datareserve(0) {} + VectorNBW() : data(nullptr), datasize(0), datareserve(0) {} ~VectorNBW() { @@ -59,22 +64,20 @@ public: delete[] data; } - bool *data; - - void reserve(const int &sz) + void reserve(size_t sz) { if (sz <= datareserve) return; bool *newdataLoc = new bool[sz]; if (datasize != 0) - memcpy(newdataLoc, data, sizeof(datasize)); + memcpy(newdataLoc, data, sizeof(bool) * sizeof(datasize)); std::swap(data, newdataLoc); if (newdataLoc != 0) delete[] newdataLoc; datareserve = sz; } - void resize(const int &sz) + void resize(size_t sz) { int oldDatasize = datasize; if (sz <= oldDatasize) @@ -96,14 +99,16 @@ public: bool empty() const { return datasize == 0; } - bool *begin() const { return data; } + bool* begin() {return data;} + const bool *begin() const { return data; } - bool &operator[](const int &i) { return data[i]; } - const bool &operator[](const int &i) const { return data[i]; } + bool &operator[](size_t i) { return data[i]; } + const bool &operator[](size_t i) const { return data[i]; } private: - int datasize; - int datareserve; + bool *data; + size_t datasize; + size_t datareserve; }; template From 3bfe5793f6145aa5ec6efcb583641247b7d81c57 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 13:15:24 +0100 Subject: [PATCH 24/47] SimpleTempData DataBegin and const DataBegin --- vcg/complex/allocate.h | 4 ++-- vcg/complex/base.h | 2 +- vcg/container/simple_temporary_data.h | 34 +++++++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index fb088206..c81368ba 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -2207,7 +2207,7 @@ public: pa._padding = 0; } - template + template static void FixPaddedPerTetraAttribute(MeshType &m, PointerToAttribute &pa) { @@ -2245,7 +2245,7 @@ public: // copy the padded container in the new one char * ptr = (char*)( ((Attribute *)pa._handle)->DataBegin()); - memcpy((void*)_handle->attribute ,(void*) &(ptr[0]) ,sizeof(ATTR_TYPE)); + memcpy((void*)_handle->DataBegin() ,(void*) &(ptr[0]) ,sizeof(ATTR_TYPE)); // remove the padded container delete ( (Attribute *) pa._handle); diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 828bdcae..599cc975 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -340,7 +340,7 @@ public: Attribute * _handle; int n_attr; - ATTR_TYPE & operator ()(){ return *((Attribute *)_handle)->attribute;} + ATTR_TYPE & operator ()(){ return *((ATTR_TYPE*)((Attribute *)_handle)->DataBegin());} }; // Some common Handle typedefs to simplify use diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index 059d65c7..ac00c378 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -41,6 +41,7 @@ public: virtual void Reorder(std::vector &newVertIndex) = 0; virtual size_t SizeOf() const = 0; virtual void *DataBegin() = 0; + virtual const void* DataBegin() const = 0; virtual void *At(size_t i) = 0; virtual const void *At(size_t i) const = 0; @@ -56,12 +57,12 @@ template class VectorNBW { public: - VectorNBW() : data(nullptr), datasize(0), datareserve(0) {} + VectorNBW() : booldata(nullptr), datasize(0), datareserve(0) {} ~VectorNBW() { - if (data) - delete[] data; + if (booldata) + delete[] booldata; } void reserve(size_t sz) @@ -70,8 +71,8 @@ public: return; bool *newdataLoc = new bool[sz]; if (datasize != 0) - memcpy(newdataLoc, data, sizeof(bool) * sizeof(datasize)); - std::swap(data, newdataLoc); + memcpy(newdataLoc, booldata, sizeof(bool) * sizeof(datasize)); + std::swap(booldata, newdataLoc); if (newdataLoc != 0) delete[] newdataLoc; datareserve = sz; @@ -85,12 +86,12 @@ public: if (sz > datareserve) reserve(sz); datasize = sz; - memset(&data[oldDatasize], 0, datasize - oldDatasize); + memset(&booldata[oldDatasize], 0, datasize - oldDatasize); } void push_back(const bool &v) { resize(datasize + 1); - data[datasize] = v; + booldata[datasize] = v; } void clear() { datasize = 0; } @@ -99,14 +100,14 @@ public: bool empty() const { return datasize == 0; } - bool* begin() {return data;} - const bool *begin() const { return data; } + bool* data() {return booldata;} + const bool *data() const { return booldata; } - bool &operator[](size_t i) { return data[i]; } - const bool &operator[](size_t i) const { return data[i]; } + bool &operator[](size_t i) { return booldata[i]; } + const bool &operator[](size_t i) const { return booldata[i]; } private: - bool *data; + bool *booldata; size_t datasize; size_t datareserve; }; @@ -184,7 +185,7 @@ public: void Reorder(std::vector &newVertIndex) { - for (unsigned int i = 0; i < data.size(); ++i) + for (size_t i = 0; i < data.size(); ++i) { if (newVertIndex[i] != (std::numeric_limits::max)()) data[newVertIndex[i]] = data[i]; @@ -192,7 +193,8 @@ public: } size_t SizeOf() const { return sizeof(ATTR_TYPE); } - void *DataBegin() { return data.empty() ? NULL : &(*data.begin()); } + void *DataBegin() { return data.empty() ? nullptr : data.data(); } + const void *DataBegin() const { return data.empty() ? nullptr : data.data(); } }; template @@ -200,11 +202,11 @@ class Attribute : public SimpleTempDataBase { public: typedef ATTR_TYPE AttrType; - AttrType *attribute; Attribute() { attribute = new ATTR_TYPE(); } ~Attribute() { delete attribute; } size_t SizeOf() const { return sizeof(ATTR_TYPE); } void *DataBegin() { return attribute; } + const void* DataBegin() const {return attribute;} void Resize(size_t) { assert(0); } void Reorder(std::vector &) { assert(0); } @@ -220,6 +222,8 @@ public: return (void *)0; } void CopyValue(const size_t, const size_t, const SimpleTempDataBase *) { assert(0); } +private: + AttrType *attribute; }; } // end namespace vcg From 7c601cc83757963a11010345d4e2a538040777f3 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 15:27:13 +0100 Subject: [PATCH 25/47] ConstPerVertexAttributeHandle --- vcg/complex/allocate.h | 39 +++++++++++++++++++++++------------- vcg/complex/base.h | 26 ++++++++++++++++++++++++ wrap/io_trimesh/export_ply.h | 28 +++++++++++++------------- 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index c81368ba..3a6a6b85 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1434,6 +1434,17 @@ public: return false; } + /*! \brief Check if a const handle to a Per-Vertex Attribute is valid + */ + template + static + bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerVertexAttributeHandle & a){ + if(a._handle == nullptr) return false; + for(AttrIterator i = m.vert_attr.begin(); i!=m.vert_attr.end();++i) + if ( (*i).n_attr == a.n_attr ) return true; + return false; + } + /*! \brief Add a Per-Vertex Attribute of the given ATTR_TYPE with the given name. No attribute with that name must exists (even of different type) @@ -1482,20 +1493,20 @@ public: } return AddPerVertexAttribute(m,name); } - - /*! \brief gives a handle to a per-vertex attribute with a given name and ATTR_TYPE + + /*! \brief gives a const handle to a per-vertex attribute with a given name and ATTR_TYPE \returns a valid handle. If the name is not empty and an attribute with that name and type exists returns a handle to it. Otherwise, returns an invalid handle (check it using IsValidHandle). */ template static - typename MeshType::template PerVertexAttributeHandle - GetPerVertexAttribute( const MeshType & m, std::string name = std::string("")){ - typename MeshType::template PerVertexAttributeHandle h; + typename MeshType::template ConstPerVertexAttributeHandle + GetConstPerVertexAttribute( const MeshType & m, std::string name = std::string("")){ + typename MeshType::template ConstPerVertexAttributeHandle h; if(!name.empty()){ - return FindPerVertexAttribute(m,name); + return FindConstPerVertexAttribute(m,name); } - return typename MeshType:: template PerVertexAttributeHandle(nullptr,0); + return typename MeshType:: template ConstPerVertexAttributeHandle(nullptr,0); } /*! \brief Try to retrieve an handle to an attribute with a given name and ATTR_TYPE @@ -1524,15 +1535,15 @@ public: } return typename MeshType:: template PerVertexAttributeHandle(nullptr,0); } - + /** * Same as the one above, but without modifying the attribute if it is found. * (A "find" function should never modify the container in which is looking for..) * Input mesh is const. */ template - static typename MeshType::template PerVertexAttributeHandle - FindPerVertexAttribute( const MeshType & m, const std::string & name) + static typename MeshType::template ConstPerVertexAttributeHandle + FindConstPerVertexAttribute( const MeshType & m, const std::string & name) { assert(!name.empty()); PointerToAttribute h1; h1._name = name; @@ -1541,9 +1552,9 @@ public: i =m.vert_attr.find(h1); if(i!=m.vert_attr.end()) if((*i)._sizeof == sizeof(ATTR_TYPE) ){ - return typename MeshType::template PerVertexAttributeHandle((*i)._handle,(*i).n_attr); + return typename MeshType::template ConstPerVertexAttributeHandle((*i)._handle,(*i).n_attr); } - return typename MeshType:: template PerVertexAttributeHandle(nullptr,0); + return typename MeshType:: template ConstPerVertexAttributeHandle(nullptr,0); } /*! \brief query the mesh for all the attributes per vertex @@ -1556,8 +1567,8 @@ public: for(i = m.vert_attr.begin(); i != m.vert_attr.end(); ++i ) if(!(*i)._name.empty()) { - typename MeshType:: template PerVertexAttributeHandle hh; - hh = Allocator:: template FindPerVertexAttribute (m,(*i)._name); + typename MeshType:: template ConstPerVertexAttributeHandle hh; + hh = Allocator:: template FindConstPerVertexAttribute (m,(*i)._name); if(IsValidHandle(m,hh)) all.push_back((*i)._name); } diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 599cc975..678d715e 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -297,6 +297,25 @@ public: void resize(size_t /*size*/) { }; }; + template + class ConstAttributeHandle{ + public: + ConstAttributeHandle(){_handle=(SimpleTempData *)nullptr;} + ConstAttributeHandle( const void *ah,const int & n):_handle ( (const SimpleTempData *)ah ),n_attr(n){} + + + //pointer to the SimpleTempData that stores the attribute + const SimpleTempData * _handle; + + // its attribute number + int n_attr; + + // access function + template + const ATTR_TYPE & operator [](const RefType & i) const {return (*_handle)[i];} + void resize(size_t /*size*/) { }; + }; + template class PerVertexAttributeHandle: public AttributeHandle{ public: @@ -304,6 +323,13 @@ public: PerVertexAttributeHandle( void *ah,const int & n):AttributeHandle(ah,n){} }; + template + class ConstPerVertexAttributeHandle: public ConstAttributeHandle{ + public: + ConstPerVertexAttributeHandle():ConstAttributeHandle(){} + ConstPerVertexAttributeHandle( const void *ah,const int & n):ConstAttributeHandle(ah,n){} + }; + template class PerFaceAttributeHandle: public AttributeHandle{ diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index 05364d73..c871d8d2 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -93,7 +93,7 @@ namespace vcg { return Save(m,filename,binary,pi,cb); } - static int Save(const SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0 + static int Save(const SaveMeshType &m, const char * filename, bool binary, const PlyInfo &pi, CallBackPos *cb=0) // V1.0 { FILE * fpout; const char * hbin = "binary_little_endian"; @@ -112,7 +112,7 @@ namespace vcg { fpout = fopen(filename,"wb"); if(fpout==NULL) { - pi.status=::vcg::ply::E_CANTOPEN; + //pi.status=::vcg::ply::E_CANTOPEN; return ::vcg::ply::E_CANTOPEN; } fprintf(fpout, @@ -360,12 +360,12 @@ namespace vcg { VertexIterator vi; SimpleTempData indices(m.vert); - std::vector > thfv(pi.VertDescriptorVec.size()); - std::vector > thdv(pi.VertDescriptorVec.size()); - std::vector > thiv(pi.VertDescriptorVec.size()); - std::vector > thsv(pi.VertDescriptorVec.size()); - std::vector > thcv(pi.VertDescriptorVec.size()); - std::vector > thuv(pi.VertDescriptorVec.size()); + std::vector > thfv(pi.VertDescriptorVec.size()); + std::vector > thdv(pi.VertDescriptorVec.size()); + std::vector > thiv(pi.VertDescriptorVec.size()); + std::vector > thsv(pi.VertDescriptorVec.size()); + std::vector > thcv(pi.VertDescriptorVec.size()); + std::vector > thuv(pi.VertDescriptorVec.size()); for(size_t i=0;i::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_INT : thiv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_SHORT : thsv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_CHAR : thcv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_FLOAT : thfv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_INT : thiv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_SHORT : thsv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_CHAR : thcv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; default : assert(0); } } From e0ccec2fc8667658bb31dc6892844fc47cf0a5f1 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 16:12:04 +0100 Subject: [PATCH 26/47] ConstPerFaceAttributeHandle --- vcg/complex/allocate.h | 99 +++++++++++++++++++++--------------- vcg/complex/base.h | 23 ++++++++- wrap/io_trimesh/export_ply.h | 24 ++++----- 3 files changed, 91 insertions(+), 55 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 3a6a6b85..b1bed546 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1423,8 +1423,9 @@ public: public: - /*! \brief Check if an handle to a Per-Vertex Attribute is valid - */ + /** + * @brief Checks if a handle to a Per-Vertex Attribute is valid + */ template static bool IsValidHandle( const MeshType & m, const typename MeshType::template PerVertexAttributeHandle & a){ @@ -1434,8 +1435,9 @@ public: return false; } - /*! \brief Check if a const handle to a Per-Vertex Attribute is valid - */ + /** + * @brief Checks if a const handle to a Per-Vertex Attribute is valid + */ template static bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerVertexAttributeHandle & a){ @@ -1501,12 +1503,8 @@ public: template static typename MeshType::template ConstPerVertexAttributeHandle - GetConstPerVertexAttribute( const MeshType & m, std::string name = std::string("")){ - typename MeshType::template ConstPerVertexAttributeHandle h; - if(!name.empty()){ - return FindConstPerVertexAttribute(m,name); - } - return typename MeshType:: template ConstPerVertexAttributeHandle(nullptr,0); + GetPerVertexAttribute( const MeshType & m, std::string name = std::string("")){ + return FindPerVertexAttribute(m,name); } /*! \brief Try to retrieve an handle to an attribute with a given name and ATTR_TYPE @@ -1537,23 +1535,26 @@ public: } /** - * Same as the one above, but without modifying the attribute if it is found. - * (A "find" function should never modify the container in which is looking for..) - * Input mesh is const. + * @brief Try to retrieve a const handle to an attribute with a given name + * and ATTR_TYPE, from the given const mesh. + * If not found, an invalid handle will be returned. + * Check it with the function IsValidHandle */ template static typename MeshType::template ConstPerVertexAttributeHandle - FindConstPerVertexAttribute( const MeshType & m, const std::string & name) + FindPerVertexAttribute( const MeshType & m, const std::string & name) { - assert(!name.empty()); - PointerToAttribute h1; h1._name = name; - typename std::set :: iterator i; + if(!name.empty()){ + PointerToAttribute h1; h1._name = name; + typename std::set :: iterator i; - i =m.vert_attr.find(h1); - if(i!=m.vert_attr.end()) - if((*i)._sizeof == sizeof(ATTR_TYPE) ){ - return typename MeshType::template ConstPerVertexAttributeHandle((*i)._handle,(*i).n_attr); + i =m.vert_attr.find(h1); + if(i!=m.vert_attr.end()){ + if((*i)._sizeof == sizeof(ATTR_TYPE) ){ + return typename MeshType::template ConstPerVertexAttributeHandle((*i)._handle,(*i).n_attr); + } } + } return typename MeshType:: template ConstPerVertexAttributeHandle(nullptr,0); } @@ -1568,7 +1569,7 @@ public: if(!(*i)._name.empty()) { typename MeshType:: template ConstPerVertexAttributeHandle hh; - hh = Allocator:: template FindConstPerVertexAttribute (m,(*i)._name); + hh = Allocator:: template FindPerVertexAttribute (m,(*i)._name); if(IsValidHandle(m,hh)) all.push_back((*i)._name); } @@ -1742,6 +1743,9 @@ public: } /// Per Face Attributes + /** + * @brief Checks if a handle to a Per-Face attribute is valid + */ template static bool IsValidHandle( const MeshType & m, const typename MeshType::template PerFaceAttributeHandle & a){ @@ -1751,6 +1755,18 @@ public: return false; } + /** + * @brief Checks if a const handle to a Per-Face attribute is valid + */ + template + static + bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerFaceAttributeHandle & a){ + if(a._handle == nullptr) return false; + for(AttrIterator i = m.face_attr.begin(); i!=m.face_attr.end();++i) + if ( (*i).n_attr == a.n_attr ) return true; + return false; + } + template static typename MeshType::template PerFaceAttributeHandle @@ -1803,13 +1819,9 @@ public: */ template static - typename MeshType::template PerFaceAttributeHandle + typename MeshType::template ConstPerFaceAttributeHandle GetPerFaceAttribute( const MeshType & m, std::string name = std::string("")){ - typename MeshType::template PerFaceAttributeHandle h; - if(!name.empty()){ - return FindPerFaceAttribute(m,name); - } - return typename MeshType:: template PerFaceAttributeHandle(nullptr,0); + return FindPerFaceAttribute(m,name); } template @@ -1823,7 +1835,7 @@ public: i =m.face_attr.find(h1); if(i!=m.face_attr.end()) if((*i)._sizeof == sizeof(ATTR_TYPE) ){ - if( (*i)._padding != 0 ){ + if( (*i)._padding != 0 ){ PointerToAttribute attr = (*i); // copy the PointerToAttribute m.face_attr.erase(i); // remove it from the set FixPaddedPerFaceAttribute(m,attr); @@ -1837,24 +1849,27 @@ public: } /** - * Same as the one above, but without modifying the attribute if it is found. - * (A "find" function should never modify the container in which is looking for..) - * Input mesh is const. + * @brief Try to retrieve a const handle to an attribute with a given name + * and ATTR_TYPE, from the given const mesh. + * If not found, an invalid handle will be returned. + * Check it with the function IsValidHandle */ template static - typename MeshType::template PerFaceAttributeHandle + typename MeshType::template ConstPerFaceAttributeHandle FindPerFaceAttribute( const MeshType & m, const std::string & name){ - assert(!name.empty()); - PointerToAttribute h1; h1._name = name; - typename std::set ::iterator i; + if(!name.empty()){ + PointerToAttribute h1; h1._name = name; + typename std::set ::iterator i; - i =m.face_attr.find(h1); - if(i!=m.face_attr.end()) - if((*i)._sizeof == sizeof(ATTR_TYPE) ){ - return typename MeshType::template PerFaceAttributeHandle((*i)._handle,(*i).n_attr); + i =m.face_attr.find(h1); + if(i!=m.face_attr.end()){ + if((*i)._sizeof == sizeof(ATTR_TYPE) ){ + return typename MeshType::template ConstPerFaceAttributeHandle((*i)._handle,(*i).n_attr); + } } - return typename MeshType:: template PerFaceAttributeHandle(nullptr,0); + } + return typename MeshType:: template ConstPerFaceAttributeHandle(nullptr,0); } template @@ -1864,7 +1879,7 @@ public: for(i = m.face_attr.begin(); i != m.face_attr.end(); ++i ) if(!(*i)._name.empty()) { - typename MeshType:: template PerFaceAttributeHandle hh; + typename MeshType:: template ConstPerFaceAttributeHandle hh; hh = Allocator:: template FindPerFaceAttribute (m,(*i)._name); if(IsValidHandle(m,hh)) all.push_back((*i)._name); diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 678d715e..2afd27a1 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -330,7 +330,6 @@ public: ConstPerVertexAttributeHandle( const void *ah,const int & n):ConstAttributeHandle(ah,n){} }; - template class PerFaceAttributeHandle: public AttributeHandle{ public: @@ -338,6 +337,13 @@ public: PerFaceAttributeHandle( void *ah,const int & n):AttributeHandle(ah,n){} }; + template + class ConstPerFaceAttributeHandle: public ConstAttributeHandle{ + public: + ConstPerFaceAttributeHandle():ConstAttributeHandle(){} + ConstPerFaceAttributeHandle( void *ah,const int & n):ConstAttributeHandle(ah,n){} + }; + template class PerEdgeAttributeHandle: public AttributeHandle{ public: @@ -345,6 +351,13 @@ public: PerEdgeAttributeHandle( void *ah,const int & n):AttributeHandle(ah,n){} }; + template + class ConstPerEdgeAttributeHandle: public ConstAttributeHandle{ + public: + ConstPerEdgeAttributeHandle():ConstAttributeHandle(){} + ConstPerEdgeAttributeHandle( void *ah,const int & n):ConstAttributeHandle(ah,n){} + }; + template class PerTetraAttributeHandle : public AttributeHandle { @@ -353,6 +366,14 @@ public: PerTetraAttributeHandle(void *ah, const int &n) : AttributeHandle(ah, n) {} }; + template + class ConstPerTetraAttributeHandle : public ConstAttributeHandle + { + public: + ConstPerTetraAttributeHandle() : ConstAttributeHandle() {} + ConstPerTetraAttributeHandle(void *ah, const int &n) : ConstAttributeHandle(ah, n) {} + }; + template class PerMeshAttributeHandle{ public: diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index c871d8d2..d2c9d3cf 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -374,22 +374,22 @@ namespace vcg { assert(vcg::tri::HasPerVertexAttribute(m,pi.VertAttrNameVec[i])); switch (pi.VertDescriptorVec[i].stotype1) { - case ply::T_FLOAT : thfv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_INT : thiv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_SHORT : thsv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_CHAR : thcv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; - case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator::template FindConstPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_FLOAT : thfv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_INT : thiv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_SHORT : thsv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_CHAR : thcv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; + case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator::template FindPerVertexAttribute(m,pi.VertAttrNameVec[i]); break; default : assert(0); } } } - std::vector > thff(pi.FaceDescriptorVec.size()); - std::vector > thdf(pi.FaceDescriptorVec.size()); - std::vector > thif(pi.FaceDescriptorVec.size()); - std::vector > thsf(pi.FaceDescriptorVec.size()); - std::vector > thcf(pi.FaceDescriptorVec.size()); - std::vector > thuf(pi.FaceDescriptorVec.size()); + std::vector > thff(pi.FaceDescriptorVec.size()); + std::vector > thdf(pi.FaceDescriptorVec.size()); + std::vector > thif(pi.FaceDescriptorVec.size()); + std::vector > thsf(pi.FaceDescriptorVec.size()); + std::vector > thcf(pi.FaceDescriptorVec.size()); + std::vector > thuf(pi.FaceDescriptorVec.size()); for(size_t i=0;i Date: Tue, 23 Mar 2021 16:20:31 +0100 Subject: [PATCH 27/47] ConstPerEdgeAttributeHandle --- vcg/complex/allocate.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index b1bed546..f185d83f 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1628,6 +1628,15 @@ public: return false; } + template + static + bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerEdgeAttributeHandle & a){ + if(a._handle == nullptr) return false; + for(AttrIterator i = m.edge_attr.begin(); i!=m.edge_attr.end();++i) + if ( (*i).n_attr == a.n_attr ) return true; + return false; + } + template static typename MeshType::template PerEdgeAttributeHandle @@ -1674,6 +1683,12 @@ public: return AddPerEdgeAttribute(m,name); } + template + static + typename MeshType::template ConstPerEdgeAttributeHandle + GetPerEdgeAttribute( const MeshType & m, std::string name = std::string("")){ + return FindPerEdgeAttribute(m,name); + } template static @@ -1700,6 +1715,24 @@ public: return typename MeshType:: template PerEdgeAttributeHandle(nullptr,0); } + template + static + typename MeshType::template ConstPerEdgeAttributeHandle + FindPerEdgeAttribute( const MeshType & m, const std::string & name){ + if(!name.empty()){ + PointerToAttribute h1; h1._name = name; + typename std::set ::const_iterator i; + + i =m.edge_attr.find(h1); + if(i!=m.edge_attr.end()){ + if((*i)._sizeof == sizeof(ATTR_TYPE) ){ + return typename MeshType::template ConstPerEdgeAttributeHandle((*i)._handle,(*i).n_attr); + } + } + } + return typename MeshType:: template ConstPerEdgeAttributeHandle(nullptr,0); + } + template static void GetAllPerEdgeAttribute(const MeshType & m, std::vector &all){ all.clear(); @@ -1707,7 +1740,7 @@ public: for(i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i ) if(!(*i)._name.empty()) { - typename MeshType:: template PerEdgeAttributeHandle hh; + typename MeshType:: template ConstPerEdgeAttributeHandle hh; hh = Allocator:: template FindPerEdgeAttribute (m,(*i)._name); if(IsValidHandle(m,hh)) all.push_back((*i)._name); From 94dc161edb8471026ac11f156db566501cc0ad8f Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 16:30:36 +0100 Subject: [PATCH 28/47] ConstPerTetraAttributeHandle --- vcg/complex/allocate.h | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index f185d83f..170ac390 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -1957,6 +1957,17 @@ public: return false; } + template + static bool IsValidHandle(const MeshType & m, const typename MeshType::template ConstPerTetraAttributeHandle & a) + { + if (a._handle == nullptr) + return false; + for (AttrIterator i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i) + if ((*i).n_attr == a.n_attr) + return true; + return false; + } + template static typename MeshType::template PerTetraAttributeHandle AddPerTetraAttribute(MeshType & m, std::string name) { @@ -2002,6 +2013,12 @@ public: return AddPerTetraAttribute(m, name); } + template + static typename MeshType::template ConstPerTetraAttributeHandle GetPerTetraAttribute(const MeshType &m, std::string name = std::string("")) + { + return FindPerTetraAttribute(m, name); + } + template static typename MeshType::template PerTetraAttributeHandle FindPerTetraAttribute(MeshType &m, const std::string &name) { @@ -2029,14 +2046,33 @@ public: } template - static void GetAllPerTetraAttribute(MeshType &m, std::vector &all) + static typename MeshType::template ConstPerTetraAttributeHandle FindPerTetraAttribute(MeshType &m, const std::string &name) + { + if(!name.empty()){ + PointerToAttribute h1; + h1._name = name; + typename std::set::iterator i; + + i = m.tetra_attr.find(h1); + if (i != m.tetra_attr.end()){ + if ((*i)._sizeof == sizeof(ATTR_TYPE)) + { + return typename MeshType::template ConstPerTetraAttributeHandle((*i)._handle, (*i).n_attr); + } + } + } + return typename MeshType::template ConstPerTetraAttributeHandle(nullptr, 0); + } + + template + static void GetAllPerTetraAttribute(const MeshType &m, std::vector &all) { all.clear(); typename std::set::const_iterator i; for (i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i) if (!(*i)._name.empty()) { - typename MeshType::template PerTetraAttributeHandle hh; + typename MeshType::template ConstPerTetraAttributeHandle hh; hh = Allocator::template FindPerTetraAttribute(m, (*i)._name); if (IsValidHandle(m, hh)) all.push_back((*i)._name); From 34af1c91bd76d8b81a3db6dc500b9b297a113f83 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 16:52:56 +0100 Subject: [PATCH 29/47] ConstPerMeshAttributeHandle --- vcg/complex/allocate.h | 34 ++++++++++++++++++++++++++++++++++ vcg/complex/base.h | 13 ++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 170ac390..fa56dd27 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -2121,6 +2121,15 @@ public: return false; } + template + static + bool IsValidHandle(const MeshType & m, const typename MeshType::template ConstPerMeshAttributeHandle & a){ + if(a._handle == nullptr) return false; + for(AttrIterator i = m.mesh_attr.begin(); i!=m.mesh_attr.end();++i) + if ( (*i).n_attr == a.n_attr ) return true; + return false; + } + template static typename MeshType::template PerMeshAttributeHandle @@ -2159,6 +2168,13 @@ public: return AddPerMeshAttribute(m,name); } + template + static + typename MeshType::template ConstPerMeshAttributeHandle + GetPerMeshAttribute(const MeshType & m, std::string name = std::string("")){ + return FindPerMeshAttribute(m,name); + } + template static typename MeshType::template PerMeshAttributeHandle @@ -2185,6 +2201,24 @@ public: return typename MeshType:: template PerMeshAttributeHandle(nullptr,0); } + template + static + typename MeshType::template ConstPerMeshAttributeHandle + FindPerMeshAttribute( const MeshType & m, const std::string & name){ + if (!name.empty()){ + PointerToAttribute h1; h1._name = name; + typename std::set ::iterator i; + i =m.mesh_attr.find(h1); + if(i!=m.mesh_attr.end()){ + if((*i)._sizeof == sizeof(ATTR_TYPE) ){ + return typename MeshType::template ConstPerMeshAttributeHandle((*i)._handle,(*i).n_attr); + } + } + } + + return typename MeshType:: template ConstPerMeshAttributeHandle(nullptr,0); + } + template static void GetAllPerMeshAttribute(const MeshType & m, std::vector &all){ typename std::set :: iterator i; diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 2afd27a1..adb0316e 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -387,7 +387,18 @@ public: Attribute * _handle; int n_attr; - ATTR_TYPE & operator ()(){ return *((ATTR_TYPE*)((Attribute *)_handle)->DataBegin());} + ATTR_TYPE & operator ()(){ return *((ATTR_TYPE*) (_handle->DataBegin()));} + }; + + template + class ConstPerMeshAttributeHandle{ + public: + ConstPerMeshAttributeHandle(){_handle=nullptr;} + ConstPerMeshAttributeHandle(const void *ah,const int & n):_handle ( (const Attribute *)ah ),n_attr(n){} + + const Attribute * _handle; + int n_attr; + const ATTR_TYPE & operator ()(){ return *((const ATTR_TYPE*)(_handle->DataBegin()));} }; // Some common Handle typedefs to simplify use From ea276afef7233f4ae32af2cc0b30074853c98b23 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 23 Mar 2021 20:27:06 +0100 Subject: [PATCH 30/47] fix wrong static usage on PerElement PlyInfo --- wrap/io_trimesh/io_mask.h | 2 +- wrap/io_trimesh/io_ply.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wrap/io_trimesh/io_mask.h b/wrap/io_trimesh/io_mask.h index 8fa7d251..aafff054 100644 --- a/wrap/io_trimesh/io_mask.h +++ b/wrap/io_trimesh/io_mask.h @@ -66,7 +66,7 @@ public: enum { IOM_NONE = 0x00000, - IOM_VERTCOORD = 0x00001, + IOM_VERTCOORD = 0x00001, IOM_VERTFLAGS = 0x00002, IOM_VERTCOLOR = 0x00004, IOM_VERTQUALITY = 0x00008, diff --git a/wrap/io_trimesh/io_ply.h b/wrap/io_trimesh/io_ply.h index d0cfc042..5a504784 100644 --- a/wrap/io_trimesh/io_ply.h +++ b/wrap/io_trimesh/io_ply.h @@ -69,8 +69,8 @@ public: void AddPerElemFloatAttribute(int elemType, const char *attrName, const char * propName=0) { static const char *elemStr[2]={"vertex","face"}; - static std::vector *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)}; - static std::vector *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)}; + std::vector *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)}; + std::vector *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)}; if(propName==0) propName=attrName; elemDescVec[elemType]->push_back(PropDescriptor()); From 7efd90dc06e29b4a6066f29b4d3f168ae6c68e12 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 12:21:59 +0100 Subject: [PATCH 31/47] cmake configuration for vcglib --- CMakeLists.txt | 296 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..22083582 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,296 @@ +# Copyright 2019, 2020, Collabora, Ltd. +# Copyright 2019, 2021, Visual Computing Lab, ISTI - Italian National Research Council +# SPDX-License-Identifier: BSL-1.0 + +cmake_minimum_required(VERSION 3.13) +project(VCGLib) + +# Eigen options +option(ALLOW_BUNDLED_EIGEN "Allow use of bundled Eigen source" ON) +option(ALLOW_SYSTEM_EIGEN "Allow use of system-provided Eigen" ON) + +# VCG options +option(VCG_HEADER_ONLY "Use VCG library in header only mode" ON) +option(VCG_BUILD_EXAMPLES "Build a set of examples of the library" OFF) + +# Prefer GLVND +if(POLICY CMP0072) + cmake_policy(SET CMP0072 NEW) +endif() + +### Build settings +set(CMAKE_CXX_STANDARD 11) + +### Eigen +set(VCG_EIGEN_DIR ${CMAKE_CURRENT_LIST_DIR}/eigenlib) + +if(ALLOW_SYSTEM_EIGEN AND EIGEN3_INCLUDE_DIR) + message(STATUS "- Eigen - using system-provided library") + set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR}) +elseif(ALLOW_BUNDLED_EIGEN AND EXISTS "${VCG_EIGEN_DIR}/Eigen/Eigen") + message(STATUS "- Eigen - using bundled source") + set(EIGEN_INCLUDE_DIRS ${VCG_EIGEN_DIR}) +else() + message( + FATAL_ERROR + "Eigen is required - at least one of ALLOW_SYSTEM_EIGEN or ALLOW_BUNDLED_EIGEN must be enabled and found.") +endif() + +### VCGLib headers and sources + +set(VCG_HEADERS + vcg/complex/append.h + vcg/complex/all_types.h + vcg/complex/complex.h + vcg/complex/allocate.h + vcg/complex/exception.h + vcg/complex/algorithms/overlap_estimation.h + vcg/complex/algorithms/dual_meshing.h + vcg/complex/algorithms/intersection.h + vcg/complex/algorithms/clip.h + vcg/complex/algorithms/geodesic.h + vcg/complex/algorithms/parametrization/poisson_solver.h + vcg/complex/algorithms/parametrization/uv_utils.h + vcg/complex/algorithms/parametrization/distortion.h + vcg/complex/algorithms/parametrization/tangent_field_operators.h + vcg/complex/algorithms/parametrization/voronoi_atlas.h + vcg/complex/algorithms/edge_collapse.h + vcg/complex/algorithms/hole.h + vcg/complex/algorithms/align_pair.h + vcg/complex/algorithms/closest.h + vcg/complex/algorithms/tetra_implicit_smooth.h + vcg/complex/algorithms/bitquad_support.h + vcg/complex/algorithms/skeleton.h + vcg/complex/algorithms/symmetry.h + vcg/complex/algorithms/voronoi_volume_sampling.h + vcg/complex/algorithms/polygon_polychord_collapse.h + vcg/complex/algorithms/inside.h + vcg/complex/algorithms/local_optimization/tri_edge_flip.h + vcg/complex/algorithms/local_optimization/quad_diag_collapse.h + vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h + vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric_tex.h + vcg/complex/algorithms/local_optimization/tri_edge_collapse.h + vcg/complex/algorithms/local_optimization/tetra_edge_collapse.h + vcg/complex/algorithms/polygonal_algorithms.h + vcg/complex/algorithms/inertia.h + vcg/complex/algorithms/mesh_assert.h + vcg/complex/algorithms/cut_tree.h + vcg/complex/algorithms/nring.h + vcg/complex/algorithms/tetra/tetfuse_collapse.h + vcg/complex/algorithms/stat.h + vcg/complex/algorithms/ransac_matching.h + vcg/complex/algorithms/refine.h + vcg/complex/algorithms/outline_support.h + vcg/complex/algorithms/convex_hull.h + vcg/complex/algorithms/clean.h + vcg/complex/algorithms/mesh_to_matrix.h + vcg/complex/algorithms/quadrangulator.h + vcg/complex/algorithms/isotropic_remeshing.h + vcg/complex/algorithms/smooth.h + vcg/complex/algorithms/autoalign_4pcs.h + vcg/complex/algorithms/local_optimization.h + vcg/complex/algorithms/curve_on_manifold.h + vcg/complex/algorithms/clustering.h + vcg/complex/algorithms/refine_loop.h + vcg/complex/algorithms/cylinder_clipping.h + vcg/complex/algorithms/pointcloud_normal.h + vcg/complex/algorithms/bitquad_creation.h + vcg/complex/algorithms/crease_cut.h + vcg/complex/algorithms/implicit_smooth.h + vcg/complex/algorithms/voronoi_remesher.h + vcg/complex/algorithms/polygon_support.h + vcg/complex/algorithms/point_sampling.h + vcg/complex/algorithms/create/mc_lookup_table.h + vcg/complex/algorithms/create/mc_trivial_walker.h + vcg/complex/algorithms/create/extrude.h + vcg/complex/algorithms/create/resampler.h + vcg/complex/algorithms/create/ball_pivoting.h + vcg/complex/algorithms/create/readme.txt + vcg/complex/algorithms/create/zonohedron.h + vcg/complex/algorithms/create/platonic.h + vcg/complex/algorithms/create/marching_cubes.h + vcg/complex/algorithms/create/plymc/voxel.h + vcg/complex/algorithms/create/plymc/simplemeshprovider.h + vcg/complex/algorithms/create/plymc/tri_edge_collapse_mc.h + vcg/complex/algorithms/create/plymc/volume.h + vcg/complex/algorithms/create/plymc/plymc.h + vcg/complex/algorithms/create/plymc/svoxel.h + vcg/complex/algorithms/create/tetramesh_support.h + vcg/complex/algorithms/create/advancing_front.h + vcg/complex/algorithms/textcoord_optimization.h + vcg/complex/algorithms/bitquad_optimization.h + vcg/complex/algorithms/halfedge_quad_clean.h + vcg/complex/algorithms/voronoi_processing.h + vcg/complex/algorithms/update/quality.h + vcg/complex/algorithms/update/selection.h + vcg/complex/algorithms/update/fitmaps.h + vcg/complex/algorithms/update/component_ep.h + vcg/complex/algorithms/update/texture.h + vcg/complex/algorithms/update/curvature_fitting.h + vcg/complex/algorithms/update/normal.h + vcg/complex/algorithms/update/position.h + vcg/complex/algorithms/update/halfedge_topology.h + vcg/complex/algorithms/update/topology.h + vcg/complex/algorithms/update/flag.h + vcg/complex/algorithms/update/bounding.h + vcg/complex/algorithms/update/halfedge_indexed.h + vcg/complex/algorithms/update/color.h + vcg/complex/algorithms/update/curvature.h + vcg/complex/algorithms/point_outlier.h + vcg/complex/algorithms/harmonic.h + vcg/complex/algorithms/point_matching_scale.h + vcg/complex/algorithms/attribute_seam.h + vcg/complex/foreach.h + vcg/complex/base.h + vcg/complex/used_types.h + vcg/container/entries_allocation_table.h + vcg/container/container_allocation_table.h + vcg/container/derivation_chain.h + vcg/container/vector_occ.h + vcg/container/simple_temporary_data.h + vcg/space/segment2.h + vcg/space/fitting3.h + vcg/space/tetra3.h + vcg/space/triangle2.h + vcg/space/ray2.h + vcg/space/deprecated_point2.h + vcg/space/point4.h + vcg/space/box2.h + vcg/space/ray3.h + vcg/space/planar_polygon_tessellation.h + vcg/space/texcoord2.h + vcg/space/deprecated_point3.h + vcg/space/intersection/triangle_triangle3.h + vcg/space/distance2.h + vcg/space/point3.h + vcg/space/deprecated_point.h + vcg/space/space.h + vcg/space/point.h + vcg/space/colorspace.h + vcg/space/rect_packer.h + vcg/space/triangle3.h + vcg/space/obox3.h + vcg/space/point2.h + vcg/space/smallest_enclosing.h + vcg/space/color4.h + vcg/space/polygon3.h + vcg/space/line3.h + vcg/space/index/octree.h + vcg/space/index/grid_util2d.h + vcg/space/index/grid_closest.h + vcg/space/index/grid_static_ptr.h + vcg/space/index/grid_util.h + vcg/space/index/spatial_hashing.h + vcg/space/index/closest2d.h + vcg/space/index/grid_static_obj.h + vcg/space/index/kdtree/kdtree.h + vcg/space/index/kdtree/priorityqueue.h + vcg/space/index/kdtree/kdtree_face.h + vcg/space/index/kdtree/mlsutils.h + vcg/space/index/octree_template.h + vcg/space/index/aabb_binary_tree/kclosest.h + vcg/space/index/aabb_binary_tree/closest.h + vcg/space/index/aabb_binary_tree/ray.h + vcg/space/index/aabb_binary_tree/frustum_cull.h + vcg/space/index/aabb_binary_tree/aabb_binary_tree.h + vcg/space/index/aabb_binary_tree/base.h + vcg/space/index/grid_closest2d.h + vcg/space/index/spatial_hashing2d.h + vcg/space/index/space_iterators.h + vcg/space/index/grid_static_ptr2d.h + vcg/space/index/base2d.h + vcg/space/index/base.h + vcg/space/index/perfect_spatial_hashing.h + vcg/space/index/space_iterators2d.h + vcg/space/line2.h + vcg/space/point_matching.h + vcg/space/intersection3.h + vcg/space/deprecated_point4.h + vcg/space/rasterized_outline2_packer.h + vcg/space/box.h + vcg/space/plane3.h + vcg/space/outline2_packer.h + vcg/space/segment3.h + vcg/space/intersection2.h + vcg/space/sphere3.h + vcg/space/box3.h + vcg/space/distance3.h + vcg/math/quadric5.h + vcg/math/factorial.h + vcg/math/eigen_matrix_addons.h + vcg/math/quadric.h + vcg/math/perlin_noise.h + vcg/math/shot.h + vcg/math/spherical_harmonics.h + vcg/math/eigen_matrixbase_addons.h + vcg/math/quaternion.h + vcg/math/similarity.h + vcg/math/disjoint_set.h + vcg/math/random_generator.h + vcg/math/camera.h + vcg/math/linear.h + vcg/math/matrix44.h + vcg/math/eigen.h + vcg/math/old_lin_algebra.h + vcg/math/similarity2.h + vcg/math/gen_normal.h + vcg/math/old_matrix44.h + vcg/math/old_deprecated_matrix.h + vcg/math/old_matrix33.h + vcg/math/polar_decomposition.h + vcg/math/base.h + vcg/math/histogram.h + vcg/math/legendre.h + vcg/math/matrix33.h + vcg/math/old_matrix.h + vcg/simplex/edge/distance.h + vcg/simplex/edge/topology.h + vcg/simplex/edge/pos.h + vcg/simplex/edge/component.h + vcg/simplex/edge/base.h + vcg/simplex/tetrahedron/tetrahedron.h + vcg/simplex/tetrahedron/topology.h + vcg/simplex/tetrahedron/pos.h + vcg/simplex/tetrahedron/component.h + vcg/simplex/tetrahedron/base.h + vcg/simplex/face/component_occ.h + vcg/simplex/face/component_ep.h + vcg/simplex/face/jumping_pos.h + vcg/simplex/face/distance.h + vcg/simplex/face/component_polygon.h + vcg/simplex/face/topology.h + vcg/simplex/face/pos.h + vcg/simplex/face/component.h + vcg/simplex/face/component_ocf.h + vcg/simplex/face/base.h + vcg/simplex/vertex/component_occ.h + vcg/simplex/vertex/component_sph.h + vcg/simplex/vertex/distance.h + vcg/simplex/vertex/component.h + vcg/simplex/vertex/component_ocf.h + vcg/simplex/vertex/base.h + vcg/connectors/halfedge_pos.h + vcg/connectors/hedge.h + vcg/connectors/hedge_component.h +) + +set(SOURCES +) + +if (VCG_HEADER_ONLY) + add_library(vcglib INTERFACE) + target_include_directories( + vcglib INTERFACE + ${CMAKE_CURRENT_LIST_DIR} + ${EIGEN_INCLUDE_DIRS}) + + #just to show headers in ide + add_custom_target(vcglib_ide SOURCES ${VCG_HEADERS}) +else() + #TODO make vcglib that includes all the wrap sources, checking everytime + # if the the required targets (e.g. qt, gl, glew...) exists +endif() + +if(VCG_BUILD_EXAMPLES) + #TODO make the list of samples to build +endif() From 2e635647c4b203229c35bd9888718bd52c5c53f8 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 14:52:06 +0100 Subject: [PATCH 32/47] add wrap/callback to cmake headers --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22083582..d4790194 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,6 +272,9 @@ set(VCG_HEADERS vcg/connectors/halfedge_pos.h vcg/connectors/hedge.h vcg/connectors/hedge_component.h + + #wrap + wrap/callback.h ) set(SOURCES From 0b99eaa7b2625ee36226548dfa6b9c1dd45475d3 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 14:53:00 +0100 Subject: [PATCH 33/47] first complex.h files made self-sufficient --- vcg/complex/allocate.h | 11 ++++++++--- vcg/complex/base.h | 11 ++++++++--- vcg/complex/exception.h | 3 +++ vcg/container/simple_temporary_data.h | 5 +++-- vcg/simplex/edge/pos.h | 2 ++ vcg/simplex/edge/topology.h | 3 +++ vcg/simplex/face/pos.h | 2 ++ vcg/simplex/face/topology.h | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index fa56dd27..461684a9 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -23,9 +23,14 @@ #ifndef __VCGLIB_TRIALLOCATOR #define __VCGLIB_TRIALLOCATOR -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +#include +#include + +#include "used_types.h" + +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif namespace vcg { namespace tri { diff --git a/vcg/complex/base.h b/vcg/complex/base.h index adb0316e..60cdb8cc 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -20,12 +20,17 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_COMPLEX_BASE #define __VCG_COMPLEX_BASE +#include +#include + +#include "used_types.h" + namespace vcg { class PointerToAttribute diff --git a/vcg/complex/exception.h b/vcg/complex/exception.h index b42c4c37..36d5ef6d 100644 --- a/vcg/complex/exception.h +++ b/vcg/complex/exception.h @@ -23,6 +23,9 @@ #ifndef __VCG_EXCEPTION_H #define __VCG_EXCEPTION_H +#include +#include + namespace vcg { class MissingComponentException : public std::runtime_error diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index ac00c378..4e91c195 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -24,10 +24,11 @@ #ifndef __VCGLIB_SIMPLE__ #define __VCGLIB_SIMPLE__ -#include +#include +#include #include #include -#include +#include namespace vcg { diff --git a/vcg/simplex/edge/pos.h b/vcg/simplex/edge/pos.h index 2b278f53..cc455bc9 100644 --- a/vcg/simplex/edge/pos.h +++ b/vcg/simplex/edge/pos.h @@ -24,6 +24,8 @@ #ifndef __VCG_EDGE_POS #define __VCG_EDGE_POS +#include + namespace vcg { namespace edge { diff --git a/vcg/simplex/edge/topology.h b/vcg/simplex/edge/topology.h index 6156a96d..13904c05 100644 --- a/vcg/simplex/edge/topology.h +++ b/vcg/simplex/edge/topology.h @@ -24,6 +24,9 @@ #ifndef _VCG_EDGE_TOPOLOGY #define _VCG_EDGE_TOPOLOGY +#include +#include + namespace vcg { namespace edge { /** \addtogroup edge */ diff --git a/vcg/simplex/face/pos.h b/vcg/simplex/face/pos.h index bfc0103f..a20d4ac3 100644 --- a/vcg/simplex/face/pos.h +++ b/vcg/simplex/face/pos.h @@ -29,6 +29,8 @@ #ifndef __VCG_FACE_POS #define __VCG_FACE_POS +#include + namespace vcg { namespace face { diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index bd14e018..bb07cec7 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -24,7 +24,7 @@ #ifndef _VCG_FACE_TOPOLOGY #define _VCG_FACE_TOPOLOGY -#include +#include namespace vcg { namespace face { From 4f3162ece5110d1668e07efff739a26b7cfcd369 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 15:48:57 +0100 Subject: [PATCH 34/47] all included from used_types.h have been made self sufficient --- vcg/complex/used_types.h | 1 - vcg/connectors/hedge.h | 9 ++++++++- vcg/connectors/hedge_component.h | 5 ++++- vcg/simplex/edge/base.h | 16 +++++++++++++--- vcg/simplex/edge/component.h | 13 ++++++++++--- vcg/simplex/face/base.h | 20 ++++++++++++++------ vcg/simplex/face/component.h | 12 +++++++++--- vcg/simplex/face/component_ocf.h | 12 +++++++++--- vcg/simplex/face/component_polygon.h | 6 +++++- vcg/simplex/tetrahedron/base.h | 11 +++++++---- vcg/simplex/tetrahedron/component.h | 2 ++ vcg/simplex/vertex/base.h | 11 ++++++++--- vcg/simplex/vertex/component.h | 12 +++++++++--- vcg/simplex/vertex/component_ocf.h | 16 ++++++++++------ 14 files changed, 108 insertions(+), 38 deletions(-) diff --git a/vcg/complex/used_types.h b/vcg/complex/used_types.h index 04daf9bb..570dd1ce 100755 --- a/vcg/complex/used_types.h +++ b/vcg/complex/used_types.h @@ -23,7 +23,6 @@ #ifndef VCG_USED_TYPES_H #define VCG_USED_TYPES_H -#include #include #include #include diff --git a/vcg/connectors/hedge.h b/vcg/connectors/hedge.h index e0785681..48f72a33 100644 --- a/vcg/connectors/hedge.h +++ b/vcg/connectors/hedge.h @@ -20,11 +20,18 @@ * for more details. * * * ****************************************************************************/ -#include #ifndef __VCG_HEDGE_ #define __VCG_HEDGE_ +#include +#include + +#include +#include + +#include "hedge_component.h" + namespace vcg { /*------------------------------------------------------------------*/ diff --git a/vcg/connectors/hedge_component.h b/vcg/connectors/hedge_component.h index 8c48a8d9..12c441a8 100644 --- a/vcg/connectors/hedge_component.h +++ b/vcg/connectors/hedge_component.h @@ -20,11 +20,14 @@ * for more details. * * * ****************************************************************************/ -#include #ifndef __VCG_HEDGE_COMPONENT #define __VCG_HEDGE_COMPONENT +#include +#include +#include + namespace vcg { namespace hedge { /* diff --git a/vcg/simplex/edge/base.h b/vcg/simplex/edge/base.h index 472a635b..42309db1 100644 --- a/vcg/simplex/edge/base.h +++ b/vcg/simplex/edge/base.h @@ -20,11 +20,21 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_EDGE_PLUS #define __VCG_EDGE_PLUS + +#include +#include +#include + +#include +#include + +#include "component.h" + namespace vcg { /*------------------------------------------------------------------*/ /* diff --git a/vcg/simplex/edge/component.h b/vcg/simplex/edge/component.h index 69d32765..9c44c073 100644 --- a/vcg/simplex/edge/component.h +++ b/vcg/simplex/edge/component.h @@ -20,12 +20,19 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_EDGE_PLUS_COMPONENT #define __VCG_EDGE_PLUS_COMPONENT +#include +#include +#include + +#include + + namespace vcg { namespace edge { diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index e96e541d..8f208cbd 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -20,12 +20,20 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_FACE_PLUS #define __VCG_FACE_PLUS +#include +#include + +#include +#include + +#include "component.h" + namespace vcg { /*------------------------------------------------------------------*/ @@ -163,16 +171,16 @@ public: /// select the Face void SetS() {this->Flags() |=SELECTED;} /// Un-select a Face - void ClearS() {this->Flags() &= ~SELECTED;} + void ClearS() {this->Flags() &= ~SELECTED;} /// select the Face void SetV() {this->Flags() |=VISITED;} /// Un-select a Face - void ClearV() {this->Flags() &= ~VISITED;} + void ClearV() {this->Flags() &= ~VISITED;} /// This function checks if the face is selected bool IsB(int i) const {return (this->cFlags() & (BORDER0<Flags() |=(BORDER0<Flags() |=(BORDER0<Flags() &= (~(BORDER0< +#include +#include + +#include +#include namespace vcg { namespace face { diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index 3f676006..919b1a55 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -22,9 +22,15 @@ ****************************************************************************/ #ifndef __VCG_FACE_PLUS_COMPONENT_OCF #define __VCG_FACE_PLUS_COMPONENT_OCF -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif + +#include +#include + +#include +#include namespace vcg { namespace face { diff --git a/vcg/simplex/face/component_polygon.h b/vcg/simplex/face/component_polygon.h index b17c2f85..0a7cdd04 100644 --- a/vcg/simplex/face/component_polygon.h +++ b/vcg/simplex/face/component_polygon.h @@ -24,6 +24,10 @@ #ifndef __VCG_POLYGON_COMPONENT #define __VCG_POLYGON_COMPONENT +#include +#include +#include + namespace vcg { namespace face { @@ -60,7 +64,7 @@ public: typedef typename T::VertexType::ScalarType ScalarType; typedef typename T::VertexType VertexType; - PFVAdj(){ _vpoly = NULL; } + PFVAdj(){ _vpoly = nullptr; } /* Note: the destructor will not be called in general because there are no virtual destructors. * Instead, the job of deallocating the memory will be done by the face allocator. * This destructor is only done for those who istance a face alone (outside a mesh) diff --git a/vcg/simplex/tetrahedron/base.h b/vcg/simplex/tetrahedron/base.h index b5e9bc71..d541503c 100644 --- a/vcg/simplex/tetrahedron/base.h +++ b/vcg/simplex/tetrahedron/base.h @@ -36,10 +36,13 @@ added #ifndef __VCG_TETRA_PLUS #define __VCG_TETRA_PLUS -//#include -//#include -//#include -//#include +#include +#include + +#include +#include + +#include "component.h" namespace vcg { diff --git a/vcg/simplex/tetrahedron/component.h b/vcg/simplex/tetrahedron/component.h index 7cd9781d..cb1a6e87 100644 --- a/vcg/simplex/tetrahedron/component.h +++ b/vcg/simplex/tetrahedron/component.h @@ -34,6 +34,8 @@ added #define __VCG_TETRAHEDRON_PLUS_COMPONENT #include + +#include #include namespace vcg { diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 29ec6fb5..649546f1 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -20,12 +20,17 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_VERTEX_PLUS #define __VCG_VERTEX_PLUS +#include +#include + +#include "component.h" + namespace vcg { diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index f4cab3c9..4a1396d8 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -20,12 +20,18 @@ * for more details. * * * ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_VERTEX_PLUS_COMPONENT #define __VCG_VERTEX_PLUS_COMPONENT +#include +#include + +#include +#include + namespace vcg { namespace vertex { /** \addtogroup VertexComponentGroup diff --git a/vcg/simplex/vertex/component_ocf.h b/vcg/simplex/vertex/component_ocf.h index 35572cbc..919a3090 100644 --- a/vcg/simplex/vertex/component_ocf.h +++ b/vcg/simplex/vertex/component_ocf.h @@ -25,14 +25,18 @@ OCF = Optional Component Fast (hopefully) compare with OCC(Optional Component Compact) */ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif #ifndef __VCG_VERTEX_PLUS_COMPONENT_OCF #define __VCG_VERTEX_PLUS_COMPONENT_OCF -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif + +#include +#include + +#include +#include + namespace vcg { namespace vertex { From e36aa76fbdca6a8d30be8020f8a8483f8037a8fb Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 16:08:53 +0100 Subject: [PATCH 35/47] complex and simplex self-sufficient headers --- vcg/complex/algorithms/update/flag.h | 4 ++++ vcg/complex/allocate.h | 2 ++ vcg/complex/foreach.h | 8 +++++--- vcg/simplex/edge/topology.h | 3 +++ vcg/simplex/face/topology.h | 2 ++ vcg/simplex/tetrahedron/pos.h | 9 +++++++-- vcg/simplex/tetrahedron/topology.h | 2 ++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/vcg/complex/algorithms/update/flag.h b/vcg/complex/algorithms/update/flag.h index 2a7957c2..75c6860c 100644 --- a/vcg/complex/algorithms/update/flag.h +++ b/vcg/complex/algorithms/update/flag.h @@ -23,6 +23,10 @@ #ifndef __VCG_TRI_UPDATE_FLAGS #define __VCG_TRI_UPDATE_FLAGS +#include +#include +#include + namespace vcg { namespace tri { /// \ingroup trimesh diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 461684a9..60c370dc 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -26,6 +26,8 @@ #include #include +#include + #include "used_types.h" //#ifndef __VCG_MESH diff --git a/vcg/complex/foreach.h b/vcg/complex/foreach.h index a062e41c..58dc3d99 100644 --- a/vcg/complex/foreach.h +++ b/vcg/complex/foreach.h @@ -24,9 +24,11 @@ #ifndef VCG__FOREACH_H #define VCG__FOREACH_H -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +//#ifndef __VCG_MESH +//#error "This file should not be included alone. It is automatically included by complex.h" +//#endif + +#include namespace vcg { namespace tri { diff --git a/vcg/simplex/edge/topology.h b/vcg/simplex/edge/topology.h index 13904c05..b942c5a8 100644 --- a/vcg/simplex/edge/topology.h +++ b/vcg/simplex/edge/topology.h @@ -27,6 +27,9 @@ #include #include +#include "pos.h" +#include "component.h" + namespace vcg { namespace edge { /** \addtogroup edge */ diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index bb07cec7..7caa961a 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -24,6 +24,8 @@ #ifndef _VCG_FACE_TOPOLOGY #define _VCG_FACE_TOPOLOGY +#include "pos.h" + #include namespace vcg { diff --git a/vcg/simplex/tetrahedron/pos.h b/vcg/simplex/tetrahedron/pos.h index c9ed4629..d47348ce 100644 --- a/vcg/simplex/tetrahedron/pos.h +++ b/vcg/simplex/tetrahedron/pos.h @@ -30,6 +30,11 @@ #ifndef __VCG_TETRA_POS #define __VCG_TETRA_POS +#include +#include + +#include "component.h" + namespace vcg { namespace tetra { @@ -87,7 +92,7 @@ public: return _vi; } - inline bool End(){return (Vt()==NULL);} + inline bool End(){return (Vt()==nullptr);} /// move on the next tetrahedron that share the vertex void operator++() @@ -97,7 +102,7 @@ public: Vt() = tw->VTp(vi); Vi() = tw->VTi(vi); - assert((Vt()==NULL)||((tw->V(vi))==(Vt()->V(Vi())))); + assert((Vt()==nullptr)||((tw->V(vi))==(Vt()->V(Vi())))); } }; diff --git a/vcg/simplex/tetrahedron/topology.h b/vcg/simplex/tetrahedron/topology.h index 5203af47..a72b8883 100644 --- a/vcg/simplex/tetrahedron/topology.h +++ b/vcg/simplex/tetrahedron/topology.h @@ -24,6 +24,8 @@ #ifndef _VCG_TETRA_TOPOLOGY #define _VCG_TETRA_TOPOLOGY +#include + namespace vcg { namespace tetrahedron { /** \addtogroup tetrahedron */ From 8408a1a1d1a98a4e6f004530fb9ecf16d84c4c72 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 17:47:49 +0100 Subject: [PATCH 36/47] all complex.h files are self-sufficient --- vcg/complex/algorithms/mesh_assert.h | 4 ++++ vcg/complex/algorithms/update/normal.h | 5 +++++ vcg/complex/algorithms/update/selection.h | 7 +++++++ vcg/complex/algorithms/update/topology.h | 6 ++++++ vcg/complex/append.h | 5 ++--- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/vcg/complex/algorithms/mesh_assert.h b/vcg/complex/algorithms/mesh_assert.h index 5f8a174a..ec821a39 100644 --- a/vcg/complex/algorithms/mesh_assert.h +++ b/vcg/complex/algorithms/mesh_assert.h @@ -23,6 +23,10 @@ #ifndef __VCGLIB_MESH_ASSERT #define __VCGLIB_MESH_ASSERT +#include +#include +#include + namespace vcg { namespace tri { /** diff --git a/vcg/complex/algorithms/update/normal.h b/vcg/complex/algorithms/update/normal.h index cedd0434..e649e284 100644 --- a/vcg/complex/algorithms/update/normal.h +++ b/vcg/complex/algorithms/update/normal.h @@ -24,8 +24,13 @@ #ifndef __VCG_TRI_UPDATE_NORMALS #define __VCG_TRI_UPDATE_NORMALS +#include +#include + #include +#include "flag.h" + namespace vcg { namespace tri { diff --git a/vcg/complex/algorithms/update/selection.h b/vcg/complex/algorithms/update/selection.h index 221db704..48b90d22 100644 --- a/vcg/complex/algorithms/update/selection.h +++ b/vcg/complex/algorithms/update/selection.h @@ -23,6 +23,13 @@ #ifndef __VCG_TRI_UPDATE_SELECTION #define __VCG_TRI_UPDATE_SELECTION +#include + +#include +#include + +#include "flag.h" + namespace vcg { namespace tri { /// \ingroup trimesh diff --git a/vcg/complex/algorithms/update/topology.h b/vcg/complex/algorithms/update/topology.h index 3dcab7d6..a71f63e9 100644 --- a/vcg/complex/algorithms/update/topology.h +++ b/vcg/complex/algorithms/update/topology.h @@ -24,6 +24,12 @@ #ifndef __VCG_TRI_UPDATE_TOPOLOGY #define __VCG_TRI_UPDATE_TOPOLOGY +#include + +#include +#include +#include + namespace vcg { namespace tri { /// \ingroup trimesh diff --git a/vcg/complex/append.h b/vcg/complex/append.h index 02580a4b..6be6826e 100644 --- a/vcg/complex/append.h +++ b/vcg/complex/append.h @@ -23,9 +23,8 @@ #ifndef __VCGLIB_APPEND #define __VCGLIB_APPEND -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif +#include +#include namespace vcg { namespace tri { From d69e3e67cc14970906a33efdd92894e24abb140e Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 17:59:53 +0100 Subject: [PATCH 37/47] cleanups --- vcg/complex/allocate.h | 4 ---- vcg/complex/base.h | 4 +--- vcg/complex/foreach.h | 4 ---- vcg/simplex/edge/base.h | 4 +--- vcg/simplex/edge/component.h | 4 +--- vcg/simplex/face/base.h | 4 +--- vcg/simplex/face/component.h | 4 +--- vcg/simplex/face/component_occ.h | 3 --- vcg/simplex/face/component_ocf.h | 3 --- vcg/simplex/tetrahedron/base.h | 4 +--- vcg/simplex/vertex/base.h | 4 +--- vcg/simplex/vertex/component.h | 4 +--- vcg/simplex/vertex/component_occ.h | 9 ++++++--- vcg/simplex/vertex/component_ocf.h | 4 +--- 14 files changed, 15 insertions(+), 44 deletions(-) diff --git a/vcg/complex/allocate.h b/vcg/complex/allocate.h index 60c370dc..b4b337d6 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -30,10 +30,6 @@ #include "used_types.h" -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif - namespace vcg { namespace tri { /** \addtogroup trimesh diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 60cdb8cc..4a1e01f9 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_COMPLEX_BASE #define __VCG_COMPLEX_BASE diff --git a/vcg/complex/foreach.h b/vcg/complex/foreach.h index 58dc3d99..c2fa2cef 100644 --- a/vcg/complex/foreach.h +++ b/vcg/complex/foreach.h @@ -24,10 +24,6 @@ #ifndef VCG__FOREACH_H #define VCG__FOREACH_H -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif - #include namespace vcg { diff --git a/vcg/simplex/edge/base.h b/vcg/simplex/edge/base.h index 42309db1..8f9a71b7 100644 --- a/vcg/simplex/edge/base.h +++ b/vcg/simplex/edge/base.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_EDGE_PLUS #define __VCG_EDGE_PLUS diff --git a/vcg/simplex/edge/component.h b/vcg/simplex/edge/component.h index 9c44c073..4e922ae3 100644 --- a/vcg/simplex/edge/component.h +++ b/vcg/simplex/edge/component.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_EDGE_PLUS_COMPONENT #define __VCG_EDGE_PLUS_COMPONENT diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index 8f208cbd..967c7dbc 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_FACE_PLUS #define __VCG_FACE_PLUS diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index 5337d687..5ac8b3d6 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_FACE_PLUS_COMPONENT #define __VCG_FACE_PLUS_COMPONENT diff --git a/vcg/simplex/face/component_occ.h b/vcg/simplex/face/component_occ.h index 318e5852..a9eb739a 100644 --- a/vcg/simplex/face/component_occ.h +++ b/vcg/simplex/face/component_occ.h @@ -26,9 +26,6 @@ OCC = Optional Component Compact compare with OCF(Optional Component Fast) */ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif #ifndef __VCG_FACE_PLUS_COMPONENT_OCC #define __VCG_FACE_PLUS_COMPONENT_OCC diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index 919b1a55..c0e0c0db 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -22,9 +22,6 @@ ****************************************************************************/ #ifndef __VCG_FACE_PLUS_COMPONENT_OCF #define __VCG_FACE_PLUS_COMPONENT_OCF -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif #include #include diff --git a/vcg/simplex/tetrahedron/base.h b/vcg/simplex/tetrahedron/base.h index d541503c..364cd857 100644 --- a/vcg/simplex/tetrahedron/base.h +++ b/vcg/simplex/tetrahedron/base.h @@ -30,9 +30,7 @@ added ****************************************************************************/ -// #ifndef __VCG_TETRA_MESH -// #error "This file should not be included alone. It is automatically included by complex.h" -// #endif + #ifndef __VCG_TETRA_PLUS #define __VCG_TETRA_PLUS diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 649546f1..b12b0648 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_VERTEX_PLUS #define __VCG_VERTEX_PLUS diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index 4a1396d8..dab25640 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -20,9 +20,7 @@ * for more details. * * * ****************************************************************************/ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_VERTEX_PLUS_COMPONENT #define __VCG_VERTEX_PLUS_COMPONENT diff --git a/vcg/simplex/vertex/component_occ.h b/vcg/simplex/vertex/component_occ.h index 80e0e124..e15f5e68 100644 --- a/vcg/simplex/vertex/component_occ.h +++ b/vcg/simplex/vertex/component_occ.h @@ -33,12 +33,15 @@ Working release (compilata solo su MSVC), component_occ � migrato da component ****************************************************************************/ -#ifndef __VCG_MESH -#error "This file should not be included alone. It is automatically included by complex.h" -#endif + #ifndef __VCG_VERTEX_PLUS_COMPONENT_OCC #define __VCG_VERTEX_PLUS_COMPONENT_OCC +#include + +#include +#include + namespace vcg { namespace vertex { /* diff --git a/vcg/simplex/vertex/component_ocf.h b/vcg/simplex/vertex/component_ocf.h index 919a3090..c063308c 100644 --- a/vcg/simplex/vertex/component_ocf.h +++ b/vcg/simplex/vertex/component_ocf.h @@ -25,9 +25,7 @@ OCF = Optional Component Fast (hopefully) compare with OCC(Optional Component Compact) */ -//#ifndef __VCG_MESH -//#error "This file should not be included alone. It is automatically included by complex.h" -//#endif + #ifndef __VCG_VERTEX_PLUS_COMPONENT_OCF #define __VCG_VERTEX_PLUS_COMPONENT_OCF From adb799a0a2f6c51e407752add09eb8beddc18d58 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 19:15:10 +0100 Subject: [PATCH 38/47] fix const correctnes of face/component.h --- vcg/complex/algorithms/harmonic.h | 8 +++--- vcg/complex/algorithms/isotropic_remeshing.h | 4 +-- vcg/simplex/face/component.h | 26 ++++++++++---------- vcg/simplex/face/pos.h | 26 ++++++++++++++++---- wrap/io_trimesh/export_3ds.h | 2 +- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/vcg/complex/algorithms/harmonic.h b/vcg/complex/algorithms/harmonic.h index ec9a67cd..2c83d103 100644 --- a/vcg/complex/algorithms/harmonic.h +++ b/vcg/complex/algorithms/harmonic.h @@ -235,19 +235,19 @@ public: ScalarT cotB = 0; // Get the edge (a pair of vertices) - VertexType * v0 = f.cV(edge); - VertexType * v1 = f.cV((edge+1)%f.VN()); + const VertexType * v0 = f.cV(edge); + const VertexType * v1 = f.cV((edge+1)%f.VN()); if (fp != NULL && fp != &f) { // not a border edge - VertexType * vb = fp->cV((f.cFFi(edge)+2)%fp->VN()); + const VertexType * vb = fp->cV((f.cFFi(edge)+2)%fp->VN()); ScalarT angleB = ComputeAngle(v0, vb, v1); cotB = vcg::math::Cos(angleB) / vcg::math::Sin(angleB); } - VertexType * va = f.cV((edge+2)%f.VN()); + const VertexType * va = f.cV((edge+2)%f.VN()); ScalarT angleA = ComputeAngle(v0, va, v1); cotA = vcg::math::Cos(angleA) / vcg::math::Sin(angleA); diff --git a/vcg/complex/algorithms/isotropic_remeshing.h b/vcg/complex/algorithms/isotropic_remeshing.h index 264e7c08..5b7ac9ec 100644 --- a/vcg/complex/algorithms/isotropic_remeshing.h +++ b/vcg/complex/algorithms/isotropic_remeshing.h @@ -813,7 +813,7 @@ private: { if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+1)%3)) && !vcg::tri::IsMarked(*params.m, faces[i]->cV1(vIdxes[i]))) { - vcg::tri::Mark(*params.m,faces[i]->cV1(vIdxes[i])); + vcg::tri::Mark(*params.m,faces[i]->V1(vIdxes[i])); incidentFeatures++; CoordType movingEdgeVector0 = (faces[i]->cP1(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize(); if (std::fabs(movingEdgeVector0 * dEdgeVector) < .9f || !p.IsEdgeS()) @@ -821,7 +821,7 @@ private: } if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+2)%3)) && !vcg::tri::IsMarked(*params.m, faces[i]->cV2(vIdxes[i]))) { - vcg::tri::Mark(*params.m,faces[i]->cV2(vIdxes[i])); + vcg::tri::Mark(*params.m,faces[i]->V2(vIdxes[i])); incidentFeatures++; CoordType movingEdgeVector1 = (faces[i]->cP2(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize(); if (std::fabs(movingEdgeVector1 * dEdgeVector) < .9f || !p.IsEdgeS()) diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index 5ac8b3d6..0ab89fb6 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -40,15 +40,15 @@ namespace face { template class EmptyCore: public T { public: - inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * &FVp( const int i ) { return this->V(i); } - inline typename T::VertexType * FVp( const int i ) const { return this->cV(i); } - inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } - inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } + inline const typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline const typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::VertexType * &FVp( const int i ) { return this->V(i); } + inline const typename T::VertexType * FVp( const int i ) const { return this->cV(i); } + inline const typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } + inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } static bool HasVertexRef() { return false; } static bool HasFVAdjacency() { return false; } @@ -200,7 +200,7 @@ public: inline typename T::VertexType * &V( const int j ) { assert(j>=0 && j<3); return v[j]; } /// \brief The pointer to the i-th vertex inline const typename T::VertexType * V (const int j) const { assert(j>=0 && j<3); return v[j]; } - inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } + inline const typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } /// \brief Shortcut: the position of the i-th vertex (equivalent to \c V(i)->P() ) inline const CoordType &P( const int j ) const { assert(j>=0 && j<3); return v[j]->P(); } @@ -212,9 +212,9 @@ public: inline const typename T::VertexType * V0( const int j ) const { return V(j);} /** \brief Return the pointer to the j-th vertex of the face. */ inline const typename T::VertexType * V1( const int j ) const { return V((j+1)%3);} /** \brief Return the pointer to the ((j+1)%3)-th vertex of the face. */ inline const typename T::VertexType * V2( const int j ) const { return V((j+2)%3);} /** \brief Return the pointer to the ((j+2)%3)-th vertex of the face. */ - inline typename T::VertexType * cV0( const int j ) const { return cV(j);} - inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);} - inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);} + inline const typename T::VertexType * cV0( const int j ) const { return cV(j);} + inline const typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);} + inline const typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);} inline CoordType & P0( const int j ) { return V(j)->P();} inline CoordType & P1( const int j ) { return V((j+1)%3)->P();} diff --git a/vcg/simplex/face/pos.h b/vcg/simplex/face/pos.h index a20d4ac3..436226d1 100644 --- a/vcg/simplex/face/pos.h +++ b/vcg/simplex/face/pos.h @@ -219,15 +219,22 @@ public: } /// return the vertex that it should have if we make FlipV; - VertexType *VFlip() const + VertexType *VFlip() { - assert(f->cV(f->Prev(z))!=v && (f->cV(f->Next(z))==v || f->cV(z)==v)); - if(f->cV(f->Next(z))==v) return f->cV(z); - else return f->cV(f->Next(z)); + assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v)); + if(f->V(f->Next(z))==v) return f->V(z); + else return f->V(f->Next(z)); } + const VertexType *VFlip() const + { + assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v)); + if(f->V(f->Next(z))==v) return f->V(z); + else return f->V(f->Next(z)); + } + /// return the face that it should have if we make FlipF; - FaceType *FFlip() const + FaceType *FFlip() { // assert( f->FFp(z)->FFp(f->FFi(z))==f ); // assert(f->V(f->Prev(z))!=v); @@ -236,6 +243,15 @@ public: return nf; } + const FaceType *FFlip() const + { + // assert( f->FFp(z)->FFp(f->FFi(z))==f ); + // assert(f->V(f->Prev(z))!=v); + // assert(f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v); + const FaceType *nf=f->FFp(z); + return nf; + } + // Trova il prossimo half-edge di bordo (nhe) // tale che diff --git a/wrap/io_trimesh/export_3ds.h b/wrap/io_trimesh/export_3ds.h index 927cae0f..82424005 100644 --- a/wrap/io_trimesh/export_3ds.h +++ b/wrap/io_trimesh/export_3ds.h @@ -448,7 +448,7 @@ namespace io { /* returns index of the vertex */ - inline static int GetIndexVertex(const SaveMeshType &m, VertexType *p) + inline static int GetIndexVertex(const SaveMeshType &m, const VertexType *p) { return p-&*(m.vert.begin()); } From fa55a9901c3302b97921200cd27f84cfa687924e Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 25 Mar 2021 12:43:08 +0100 Subject: [PATCH 39/47] cmake configuration to build examples --- CMakeLists.txt | 4 ++ apps/CMakeLists.txt | 12 ++-- apps/metro/CMakeLists.txt | 17 ++++- apps/sample/CMakeLists.txt | 64 +++++++++++++++++++ apps/sample/aabb_binary_tree/CMakeLists.txt | 14 ++++ apps/sample/colorspace/CMakeLists.txt | 14 ++++ apps/sample/polygonmesh_base/CMakeLists.txt | 17 +++++ apps/sample/polygonmesh_dual/CMakeLists.txt | 17 +++++ .../polygonmesh_optimize/CMakeLists.txt | 17 +++++ .../CMakeLists.txt | 17 +++++ apps/sample/polygonmesh_smooth/CMakeLists.txt | 17 +++++ apps/sample/sample.pro | 2 +- apps/sample/space_index_2d/CMakeLists.txt | 16 +++++ apps/sample/space_packer/CMakeLists.txt | 30 +++++++++ .../space_rasterized_packer/CMakeLists.txt | 29 +++++++++ apps/sample/trimesh_align_pair/CMakeLists.txt | 17 +++++ apps/sample/trimesh_allocate/CMakeLists.txt | 17 +++++ apps/sample/trimesh_attribute/CMakeLists.txt | 16 +++++ .../trimesh_attribute_saving/CMakeLists.txt | 17 +++++ .../trimesh_ball_pivoting/CMakeLists.txt | 17 +++++ apps/sample/trimesh_base/CMakeLists.txt | 24 ++++--- apps/sample/trimesh_closest/CMakeLists.txt | 17 +++++ apps/sample/trimesh_clustering/CMakeLists.txt | 16 +++++ apps/sample/trimesh_color/CMakeLists.txt | 17 +++++ apps/sample/trimesh_copy/CMakeLists.txt | 17 +++++ apps/sample/trimesh_create/CMakeLists.txt | 16 +++++ apps/sample/trimesh_curvature/CMakeLists.txt | 16 +++++ .../trimesh_cylinder_clipping/CMakeLists.txt | 17 +++++ .../CMakeLists.txt | 17 +++++ apps/sample/trimesh_fitting/CMakeLists.txt | 16 +++++ apps/sample/trimesh_geodesic/CMakeLists.txt | 17 +++++ apps/sample/trimesh_harmonic/CMakeLists.txt | 17 +++++ apps/sample/trimesh_hole/CMakeLists.txt | 17 +++++ .../trimesh_implicit_smooth/CMakeLists.txt | 17 +++++ apps/sample/trimesh_indexing/CMakeLists.txt | 17 +++++ apps/sample/trimesh_inertia/CMakeLists.txt | 16 +++++ .../trimesh_intersection_mesh/CMakeLists.txt | 16 +++++ .../trimesh_intersection_plane/CMakeLists.txt | 16 +++++ apps/sample/trimesh_isosurface/CMakeLists.txt | 17 +++++ apps/sample/trimesh_join/CMakeLists.txt | 17 +++++ apps/sample/trimesh_kdtree/CMakeLists.txt | 17 +++++ .../CMakeLists.txt | 16 +++++ apps/sample/trimesh_normal/CMakeLists.txt | 16 +++++ apps/sample/trimesh_optional/CMakeLists.txt | 17 +++++ .../CMakeLists.txt | 17 +++++ .../trimesh_pointmatching/CMakeLists.txt | 16 +++++ apps/sample/trimesh_ray/CMakeLists.txt | 17 +++++ apps/sample/trimesh_refine/CMakeLists.txt | 17 +++++ apps/sample/trimesh_remeshing/CMakeLists.txt | 17 +++++ apps/sample/trimesh_sampling/CMakeLists.txt | 16 +++++ apps/sample/trimesh_select/CMakeLists.txt | 16 +++++ apps/sample/trimesh_smooth/CMakeLists.txt | 17 +++++ .../trimesh_split_vertex/CMakeLists.txt | 17 +++++ apps/sample/trimesh_texture/CMakeLists.txt | 31 +++++++++ .../trimesh_texture_clean/CMakeLists.txt | 16 +++++ .../trimesh_topological_cut/CMakeLists.txt | 17 +++++ apps/sample/trimesh_topology/CMakeLists.txt | 16 +++++ apps/sample/trimesh_voronoi/CMakeLists.txt | 17 +++++ .../trimesh_voronoiatlas/CMakeLists.txt | 17 +++++ .../trimesh_voronoiclustering/CMakeLists.txt | 17 +++++ .../trimesh_voronoisampling/CMakeLists.txt | 17 +++++ apps/tridecimator/CMakeLists.txt | 17 ++++- 62 files changed, 1074 insertions(+), 18 deletions(-) create mode 100644 apps/sample/CMakeLists.txt create mode 100644 apps/sample/aabb_binary_tree/CMakeLists.txt create mode 100644 apps/sample/colorspace/CMakeLists.txt create mode 100644 apps/sample/polygonmesh_base/CMakeLists.txt create mode 100644 apps/sample/polygonmesh_dual/CMakeLists.txt create mode 100644 apps/sample/polygonmesh_optimize/CMakeLists.txt create mode 100644 apps/sample/polygonmesh_polychord_collapse/CMakeLists.txt create mode 100644 apps/sample/polygonmesh_smooth/CMakeLists.txt create mode 100644 apps/sample/space_index_2d/CMakeLists.txt create mode 100644 apps/sample/space_packer/CMakeLists.txt create mode 100644 apps/sample/space_rasterized_packer/CMakeLists.txt create mode 100644 apps/sample/trimesh_align_pair/CMakeLists.txt create mode 100644 apps/sample/trimesh_allocate/CMakeLists.txt create mode 100644 apps/sample/trimesh_attribute/CMakeLists.txt create mode 100644 apps/sample/trimesh_attribute_saving/CMakeLists.txt create mode 100644 apps/sample/trimesh_ball_pivoting/CMakeLists.txt create mode 100644 apps/sample/trimesh_closest/CMakeLists.txt create mode 100644 apps/sample/trimesh_clustering/CMakeLists.txt create mode 100644 apps/sample/trimesh_color/CMakeLists.txt create mode 100644 apps/sample/trimesh_copy/CMakeLists.txt create mode 100644 apps/sample/trimesh_create/CMakeLists.txt create mode 100644 apps/sample/trimesh_curvature/CMakeLists.txt create mode 100644 apps/sample/trimesh_cylinder_clipping/CMakeLists.txt create mode 100644 apps/sample/trimesh_disk_parametrization/CMakeLists.txt create mode 100644 apps/sample/trimesh_fitting/CMakeLists.txt create mode 100644 apps/sample/trimesh_geodesic/CMakeLists.txt create mode 100644 apps/sample/trimesh_harmonic/CMakeLists.txt create mode 100644 apps/sample/trimesh_hole/CMakeLists.txt create mode 100644 apps/sample/trimesh_implicit_smooth/CMakeLists.txt create mode 100644 apps/sample/trimesh_indexing/CMakeLists.txt create mode 100644 apps/sample/trimesh_inertia/CMakeLists.txt create mode 100644 apps/sample/trimesh_intersection_mesh/CMakeLists.txt create mode 100644 apps/sample/trimesh_intersection_plane/CMakeLists.txt create mode 100644 apps/sample/trimesh_isosurface/CMakeLists.txt create mode 100644 apps/sample/trimesh_join/CMakeLists.txt create mode 100644 apps/sample/trimesh_kdtree/CMakeLists.txt create mode 100644 apps/sample/trimesh_montecarlo_sampling/CMakeLists.txt create mode 100644 apps/sample/trimesh_normal/CMakeLists.txt create mode 100644 apps/sample/trimesh_optional/CMakeLists.txt create mode 100644 apps/sample/trimesh_pointcloud_sampling/CMakeLists.txt create mode 100644 apps/sample/trimesh_pointmatching/CMakeLists.txt create mode 100644 apps/sample/trimesh_ray/CMakeLists.txt create mode 100644 apps/sample/trimesh_refine/CMakeLists.txt create mode 100644 apps/sample/trimesh_remeshing/CMakeLists.txt create mode 100644 apps/sample/trimesh_sampling/CMakeLists.txt create mode 100644 apps/sample/trimesh_select/CMakeLists.txt create mode 100644 apps/sample/trimesh_smooth/CMakeLists.txt create mode 100644 apps/sample/trimesh_split_vertex/CMakeLists.txt create mode 100644 apps/sample/trimesh_texture/CMakeLists.txt create mode 100644 apps/sample/trimesh_texture_clean/CMakeLists.txt create mode 100644 apps/sample/trimesh_topological_cut/CMakeLists.txt create mode 100644 apps/sample/trimesh_topology/CMakeLists.txt create mode 100644 apps/sample/trimesh_voronoi/CMakeLists.txt create mode 100644 apps/sample/trimesh_voronoiatlas/CMakeLists.txt create mode 100644 apps/sample/trimesh_voronoiclustering/CMakeLists.txt create mode 100644 apps/sample/trimesh_voronoisampling/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d4790194..fc28d096 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ option(ALLOW_SYSTEM_EIGEN "Allow use of system-provided Eigen" ON) option(VCG_HEADER_ONLY "Use VCG library in header only mode" ON) option(VCG_BUILD_EXAMPLES "Build a set of examples of the library" OFF) +set (VCG_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}) +set (VCG_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR} PARENT_SCOPE) + # Prefer GLVND if(POLICY CMP0072) cmake_policy(SET CMP0072 NEW) @@ -296,4 +299,5 @@ endif() if(VCG_BUILD_EXAMPLES) #TODO make the list of samples to build + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/apps) endif() diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index dc516ffe..7af54e3a 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,9 +1,7 @@ -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) +cmake_minimum_required(VERSION 3.13) + +project(VCGApps) + +add_subdirectory(sample) add_subdirectory(metro) add_subdirectory(tridecimator) diff --git a/apps/metro/CMakeLists.txt b/apps/metro/CMakeLists.txt index f628ace7..aa5ec471 100644 --- a/apps/metro/CMakeLists.txt +++ b/apps/metro/CMakeLists.txt @@ -1,2 +1,17 @@ +cmake_minimum_required(VERSION 3.13) project (metro) -add_executable(metro metro.cpp ../../wrap/ply/plylib.cpp) + +if (VCG_HEADER_ONLY) + set(SOURCES + metro.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(metro + ${SOURCES}) + +target_link_libraries( + metro + PUBLIC + vcglib + ) diff --git a/apps/sample/CMakeLists.txt b/apps/sample/CMakeLists.txt new file mode 100644 index 00000000..a1846e1b --- /dev/null +++ b/apps/sample/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required(VERSION 3.13) +project(VCGExamples) + +set(VCG_EXAMPLE_PROJECTS + aabb_binary_tree + colorspace + polygonmesh_base + polygonmesh_dual + polygonmesh_optimize + polygonmesh_polychord_collapse + polygonmesh_smooth + space_index_2d + space_packer + space_rasterized_packer + trimesh_align_pair + trimesh_allocate + trimesh_attribute + trimesh_attribute_saving + trimesh_ball_pivoting + trimesh_base + trimesh_closest + trimesh_clustering + trimesh_color + trimesh_copy + trimesh_create + trimesh_curvature + trimesh_cylinder_clipping + trimesh_disk_parametrization + trimesh_fitting + trimesh_geodesic + trimesh_harmonic + trimesh_hole + trimesh_implicit_smooth + trimesh_indexing + trimesh_inertia + 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) + +foreach(VCG_EXAMPLE ${VCG_EXAMPLE_PROJECTS}) + add_subdirectory(${VCG_EXAMPLE}) +endforeach() diff --git a/apps/sample/aabb_binary_tree/CMakeLists.txt b/apps/sample/aabb_binary_tree/CMakeLists.txt new file mode 100644 index 00000000..bccc0ec7 --- /dev/null +++ b/apps/sample/aabb_binary_tree/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.13) +project(aabb_binary_tree) + +set(SOURCES + aabb_binary_tree.cpp) + +add_executable(aabb_binary_tree + ${SOURCES}) + +target_link_libraries( + aabb_binary_tree + PUBLIC + vcglib + ) diff --git a/apps/sample/colorspace/CMakeLists.txt b/apps/sample/colorspace/CMakeLists.txt new file mode 100644 index 00000000..c6b2d5a0 --- /dev/null +++ b/apps/sample/colorspace/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.13) +project(colorspace) + +set(SOURCES + colorspace.cpp) + +add_executable(colorspace + ${SOURCES}) + +target_link_libraries( + colorspace + PUBLIC + vcglib + ) diff --git a/apps/sample/polygonmesh_base/CMakeLists.txt b/apps/sample/polygonmesh_base/CMakeLists.txt new file mode 100644 index 00000000..567a8a85 --- /dev/null +++ b/apps/sample/polygonmesh_base/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(polygonmesh_base) + +if (VCG_HEADER_ONLY) + set(SOURCES + polygonmesh.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(polygonmesh_base + ${SOURCES}) + +target_link_libraries( + polygonmesh_base + PUBLIC + vcglib + ) diff --git a/apps/sample/polygonmesh_dual/CMakeLists.txt b/apps/sample/polygonmesh_dual/CMakeLists.txt new file mode 100644 index 00000000..40018f75 --- /dev/null +++ b/apps/sample/polygonmesh_dual/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(polygonmesh_dual) + +if (VCG_HEADER_ONLY) + set(SOURCES + polygonmesh_dual.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(polygonmesh_dual + ${SOURCES}) + +target_link_libraries( + polygonmesh_dual + PUBLIC + vcglib + ) diff --git a/apps/sample/polygonmesh_optimize/CMakeLists.txt b/apps/sample/polygonmesh_optimize/CMakeLists.txt new file mode 100644 index 00000000..07f572db --- /dev/null +++ b/apps/sample/polygonmesh_optimize/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(polygonmesh_optimize) + +if (VCG_HEADER_ONLY) + set(SOURCES + polygonmesh_optimize.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(polygonmesh_optimize + ${SOURCES}) + +target_link_libraries( + polygonmesh_optimize + PUBLIC + vcglib + ) diff --git a/apps/sample/polygonmesh_polychord_collapse/CMakeLists.txt b/apps/sample/polygonmesh_polychord_collapse/CMakeLists.txt new file mode 100644 index 00000000..0ac97fc7 --- /dev/null +++ b/apps/sample/polygonmesh_polychord_collapse/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(polygonmesh_polychord_collapse) + +if (VCG_HEADER_ONLY) + set(SOURCES + polygonmesh_polychord_collapse.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(polygonmesh_polychord_collapse + ${SOURCES}) + +target_link_libraries( + polygonmesh_polychord_collapse + PUBLIC + vcglib + ) diff --git a/apps/sample/polygonmesh_smooth/CMakeLists.txt b/apps/sample/polygonmesh_smooth/CMakeLists.txt new file mode 100644 index 00000000..002bb6db --- /dev/null +++ b/apps/sample/polygonmesh_smooth/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(polygonmesh_smooth) + +if (VCG_HEADER_ONLY) + set(SOURCES + polygonmesh_smooth.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(polygonmesh_smooth + ${SOURCES}) + +target_link_libraries( + polygonmesh_smooth + PUBLIC + vcglib + ) diff --git a/apps/sample/sample.pro b/apps/sample/sample.pro index 1036b4d2..0a99190e 100644 --- a/apps/sample/sample.pro +++ b/apps/sample/sample.pro @@ -60,4 +60,4 @@ SUBDIRS = \ trimesh_voronoi \ trimesh_voronoiatlas \ trimesh_voronoiclustering \ - trimesh_voronoisampling \ + trimesh_voronoisampling diff --git a/apps/sample/space_index_2d/CMakeLists.txt b/apps/sample/space_index_2d/CMakeLists.txt new file mode 100644 index 00000000..b5c07abd --- /dev/null +++ b/apps/sample/space_index_2d/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(space_index_2d) + +if (VCG_HEADER_ONLY) + set(SOURCES + space_index_2d.cpp) +endif() + +add_executable(space_index_2d + ${SOURCES}) + +target_link_libraries( + space_index_2d + PUBLIC + vcglib + ) diff --git a/apps/sample/space_packer/CMakeLists.txt b/apps/sample/space_packer/CMakeLists.txt new file mode 100644 index 00000000..69d3e0fd --- /dev/null +++ b/apps/sample/space_packer/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.13) +project(space_packer) + +find_package( + Qt5 + COMPONENTS OpenGL Svg) + +if (TARGET Qt5::OpenGL AND TARGET Qt5::Svg) + + if (VCG_HEADER_ONLY) + set(SOURCES + space_packer.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/Outline2ToQImage.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/outline2_rasterizer.cpp) + endif() + + add_executable(space_packer + ${SOURCES}) + + target_link_libraries( + space_packer + PUBLIC + vcglib + Qt5::OpenGL + Qt5::Svg + ) +else() + message( + STATUS "VCG examples - Skipping space_packer example") +endif() diff --git a/apps/sample/space_rasterized_packer/CMakeLists.txt b/apps/sample/space_rasterized_packer/CMakeLists.txt new file mode 100644 index 00000000..bbe86336 --- /dev/null +++ b/apps/sample/space_rasterized_packer/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.13) +project(space_rasterized_packer) + +find_package( + Qt5 + COMPONENTS OpenGL Svg) + +if (TARGET Qt5::OpenGL AND TARGET Qt5::Svg) + if (VCG_HEADER_ONLY) + set(SOURCES + space_rasterized_packer.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/Outline2ToQImage.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/outline2_rasterizer.cpp) + endif() + + add_executable(space_rasterized_packer + ${SOURCES}) + + target_link_libraries( + space_rasterized_packer + PUBLIC + vcglib + Qt5::OpenGL + Qt5::Svg + ) +else() + message( + STATUS "VCG examples - Skipping space_rasterized_packer example") +endif() diff --git a/apps/sample/trimesh_align_pair/CMakeLists.txt b/apps/sample/trimesh_align_pair/CMakeLists.txt new file mode 100644 index 00000000..34ebd62c --- /dev/null +++ b/apps/sample/trimesh_align_pair/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_align_pair) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_align_pair.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_align_pair + ${SOURCES}) + +target_link_libraries( + trimesh_align_pair + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_allocate/CMakeLists.txt b/apps/sample/trimesh_allocate/CMakeLists.txt new file mode 100644 index 00000000..00e5dafd --- /dev/null +++ b/apps/sample/trimesh_allocate/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_allocate) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_allocate.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_allocate + ${SOURCES}) + +target_link_libraries( + trimesh_allocate + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_attribute/CMakeLists.txt b/apps/sample/trimesh_attribute/CMakeLists.txt new file mode 100644 index 00000000..54a08850 --- /dev/null +++ b/apps/sample/trimesh_attribute/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_attribute) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_attribute.cpp) +endif() + +add_executable(trimesh_attribute + ${SOURCES}) + +target_link_libraries( + trimesh_attribute + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_attribute_saving/CMakeLists.txt b/apps/sample/trimesh_attribute_saving/CMakeLists.txt new file mode 100644 index 00000000..56572ba8 --- /dev/null +++ b/apps/sample/trimesh_attribute_saving/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_attribute_saving) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_attribute_saving.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_attribute_saving + ${SOURCES}) + +target_link_libraries( + trimesh_attribute_saving + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_ball_pivoting/CMakeLists.txt b/apps/sample/trimesh_ball_pivoting/CMakeLists.txt new file mode 100644 index 00000000..df6f55eb --- /dev/null +++ b/apps/sample/trimesh_ball_pivoting/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_ball_pivoting) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_ball_pivoting.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_ball_pivoting + ${SOURCES}) + +target_link_libraries( + trimesh_ball_pivoting + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_base/CMakeLists.txt b/apps/sample/trimesh_base/CMakeLists.txt index 8939a675..b87de841 100644 --- a/apps/sample/trimesh_base/CMakeLists.txt +++ b/apps/sample/trimesh_base/CMakeLists.txt @@ -1,8 +1,16 @@ -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) +cmake_minimum_required(VERSION 3.13) +project(trimesh_base) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_base.cpp) +endif() + +add_executable(trimesh_base + ${SOURCES}) + +target_link_libraries( + trimesh_base + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_closest/CMakeLists.txt b/apps/sample/trimesh_closest/CMakeLists.txt new file mode 100644 index 00000000..4e61aa77 --- /dev/null +++ b/apps/sample/trimesh_closest/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_closest) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_closest.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_closest + ${SOURCES}) + +target_link_libraries( + trimesh_closest + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_clustering/CMakeLists.txt b/apps/sample/trimesh_clustering/CMakeLists.txt new file mode 100644 index 00000000..ec0a1361 --- /dev/null +++ b/apps/sample/trimesh_clustering/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_clustering) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_clustering.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_clustering + ${SOURCES}) + +target_link_libraries( + trimesh_clustering + PUBLIC vcglib + ) diff --git a/apps/sample/trimesh_color/CMakeLists.txt b/apps/sample/trimesh_color/CMakeLists.txt new file mode 100644 index 00000000..ecf09f09 --- /dev/null +++ b/apps/sample/trimesh_color/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_color) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_color.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_color + ${SOURCES}) + +target_link_libraries( + trimesh_color + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_copy/CMakeLists.txt b/apps/sample/trimesh_copy/CMakeLists.txt new file mode 100644 index 00000000..431fb603 --- /dev/null +++ b/apps/sample/trimesh_copy/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_copy) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_copy.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_copy + ${SOURCES}) + +target_link_libraries( + trimesh_copy + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_create/CMakeLists.txt b/apps/sample/trimesh_create/CMakeLists.txt new file mode 100644 index 00000000..a9ba842b --- /dev/null +++ b/apps/sample/trimesh_create/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_create) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_create.cpp) +endif() + +add_executable(trimesh_create + ${SOURCES}) + +target_link_libraries( + trimesh_create + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_curvature/CMakeLists.txt b/apps/sample/trimesh_curvature/CMakeLists.txt new file mode 100644 index 00000000..a09fe6e1 --- /dev/null +++ b/apps/sample/trimesh_curvature/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_curvature) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_curvature.cpp) +endif() + +add_executable(trimesh_curvature + ${SOURCES}) + +target_link_libraries( + trimesh_curvature + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_cylinder_clipping/CMakeLists.txt b/apps/sample/trimesh_cylinder_clipping/CMakeLists.txt new file mode 100644 index 00000000..96ceb24c --- /dev/null +++ b/apps/sample/trimesh_cylinder_clipping/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_cylinder_clipping) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_cylinder_clipping.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_cylinder_clipping + ${SOURCES}) + +target_link_libraries( + trimesh_cylinder_clipping + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_disk_parametrization/CMakeLists.txt b/apps/sample/trimesh_disk_parametrization/CMakeLists.txt new file mode 100644 index 00000000..02edee20 --- /dev/null +++ b/apps/sample/trimesh_disk_parametrization/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_disk_parametrization) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_disk_parametrization.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_disk_parametrization + ${SOURCES}) + +target_link_libraries( + trimesh_disk_parametrization + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_fitting/CMakeLists.txt b/apps/sample/trimesh_fitting/CMakeLists.txt new file mode 100644 index 00000000..c93263b9 --- /dev/null +++ b/apps/sample/trimesh_fitting/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_fitting) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_fitting.cpp) +endif() + +add_executable(trimesh_fitting + ${SOURCES}) + +target_link_libraries( + trimesh_fitting + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_geodesic/CMakeLists.txt b/apps/sample/trimesh_geodesic/CMakeLists.txt new file mode 100644 index 00000000..f410e7c2 --- /dev/null +++ b/apps/sample/trimesh_geodesic/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_geodesic) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_geodesic.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_geodesic + ${SOURCES}) + +target_link_libraries( + trimesh_geodesic + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_harmonic/CMakeLists.txt b/apps/sample/trimesh_harmonic/CMakeLists.txt new file mode 100644 index 00000000..b525fced --- /dev/null +++ b/apps/sample/trimesh_harmonic/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_harmonic) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_harmonic.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_harmonic + ${SOURCES}) + +target_link_libraries( + trimesh_harmonic + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_hole/CMakeLists.txt b/apps/sample/trimesh_hole/CMakeLists.txt new file mode 100644 index 00000000..da677588 --- /dev/null +++ b/apps/sample/trimesh_hole/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_hole) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_hole.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_hole + ${SOURCES}) + +target_link_libraries( + trimesh_hole + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_implicit_smooth/CMakeLists.txt b/apps/sample/trimesh_implicit_smooth/CMakeLists.txt new file mode 100644 index 00000000..a9c3f74d --- /dev/null +++ b/apps/sample/trimesh_implicit_smooth/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_implicit_smooth) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_implicit_smooth.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_implicit_smooth + ${SOURCES}) + +target_link_libraries( + trimesh_implicit_smooth + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_indexing/CMakeLists.txt b/apps/sample/trimesh_indexing/CMakeLists.txt new file mode 100644 index 00000000..80df98e5 --- /dev/null +++ b/apps/sample/trimesh_indexing/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_indexing) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_indexing.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_indexing + ${SOURCES}) + +target_link_libraries( + trimesh_indexing + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_inertia/CMakeLists.txt b/apps/sample/trimesh_inertia/CMakeLists.txt new file mode 100644 index 00000000..49dc45ed --- /dev/null +++ b/apps/sample/trimesh_inertia/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_inertia) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_inertia.cpp) +endif() + +add_executable(trimesh_inertia + ${SOURCES}) + +target_link_libraries( + trimesh_inertia + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_intersection_mesh/CMakeLists.txt b/apps/sample/trimesh_intersection_mesh/CMakeLists.txt new file mode 100644 index 00000000..d76bb7ad --- /dev/null +++ b/apps/sample/trimesh_intersection_mesh/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_intersection_mesh) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_intersection_mesh.cpp) +endif() + +add_executable(trimesh_intersection_mesh + ${SOURCES}) + +target_link_libraries( + trimesh_intersection_mesh + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_intersection_plane/CMakeLists.txt b/apps/sample/trimesh_intersection_plane/CMakeLists.txt new file mode 100644 index 00000000..0a317f06 --- /dev/null +++ b/apps/sample/trimesh_intersection_plane/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_intersection_plane) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_intersection_plane.cpp) +endif() + +add_executable(trimesh_intersection_plane + ${SOURCES}) + +target_link_libraries( + trimesh_intersection_plane + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_isosurface/CMakeLists.txt b/apps/sample/trimesh_isosurface/CMakeLists.txt new file mode 100644 index 00000000..d1d07423 --- /dev/null +++ b/apps/sample/trimesh_isosurface/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_isosurface) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_isosurface.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_isosurface + ${SOURCES}) + +target_link_libraries( + trimesh_isosurface + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_join/CMakeLists.txt b/apps/sample/trimesh_join/CMakeLists.txt new file mode 100644 index 00000000..e783f456 --- /dev/null +++ b/apps/sample/trimesh_join/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_join) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_join.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_join + ${SOURCES}) + +target_link_libraries( + trimesh_join + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_kdtree/CMakeLists.txt b/apps/sample/trimesh_kdtree/CMakeLists.txt new file mode 100644 index 00000000..79587c32 --- /dev/null +++ b/apps/sample/trimesh_kdtree/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_kdtree) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_kdtree.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_kdtree + ${SOURCES}) + +target_link_libraries( + trimesh_kdtree + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_montecarlo_sampling/CMakeLists.txt b/apps/sample/trimesh_montecarlo_sampling/CMakeLists.txt new file mode 100644 index 00000000..6ae8946e --- /dev/null +++ b/apps/sample/trimesh_montecarlo_sampling/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_montecarlo_sampling) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_montecarlo_sampling.cpp) +endif() + +add_executable(trimesh_montecarlo_sampling + ${SOURCES}) + +target_link_libraries( + trimesh_montecarlo_sampling + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_normal/CMakeLists.txt b/apps/sample/trimesh_normal/CMakeLists.txt new file mode 100644 index 00000000..06f24aca --- /dev/null +++ b/apps/sample/trimesh_normal/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_normal) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_normal.cpp) +endif() + +add_executable(trimesh_normal + ${SOURCES}) + +target_link_libraries( + trimesh_normal + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_optional/CMakeLists.txt b/apps/sample/trimesh_optional/CMakeLists.txt new file mode 100644 index 00000000..f6195fc2 --- /dev/null +++ b/apps/sample/trimesh_optional/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_optional) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_optional.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_optional + ${SOURCES}) + +target_link_libraries( + trimesh_optional + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_pointcloud_sampling/CMakeLists.txt b/apps/sample/trimesh_pointcloud_sampling/CMakeLists.txt new file mode 100644 index 00000000..1e8cfa07 --- /dev/null +++ b/apps/sample/trimesh_pointcloud_sampling/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_pointcloud_sampling) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_pointcloud_sampling.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_pointcloud_sampling + ${SOURCES}) + +target_link_libraries( + trimesh_pointcloud_sampling + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_pointmatching/CMakeLists.txt b/apps/sample/trimesh_pointmatching/CMakeLists.txt new file mode 100644 index 00000000..f7ba0aae --- /dev/null +++ b/apps/sample/trimesh_pointmatching/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_pointmatching) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_pointmatching.cpp) +endif() + +add_executable(trimesh_pointmatching + ${SOURCES}) + +target_link_libraries( + trimesh_pointmatching + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_ray/CMakeLists.txt b/apps/sample/trimesh_ray/CMakeLists.txt new file mode 100644 index 00000000..e9b07b96 --- /dev/null +++ b/apps/sample/trimesh_ray/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_ray) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_ray.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_ray + ${SOURCES}) + +target_link_libraries( + trimesh_ray + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_refine/CMakeLists.txt b/apps/sample/trimesh_refine/CMakeLists.txt new file mode 100644 index 00000000..88bbe644 --- /dev/null +++ b/apps/sample/trimesh_refine/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_refine) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_refine.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_refine + ${SOURCES}) + +target_link_libraries( + trimesh_refine + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_remeshing/CMakeLists.txt b/apps/sample/trimesh_remeshing/CMakeLists.txt new file mode 100644 index 00000000..72377e8a --- /dev/null +++ b/apps/sample/trimesh_remeshing/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_remeshing) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_remeshing.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_remeshing + ${SOURCES}) + +target_link_libraries( + trimesh_remeshing + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_sampling/CMakeLists.txt b/apps/sample/trimesh_sampling/CMakeLists.txt new file mode 100644 index 00000000..a720ceeb --- /dev/null +++ b/apps/sample/trimesh_sampling/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_sampling) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_sampling.cpp) +endif() + +add_executable(trimesh_sampling + ${SOURCES}) + +target_link_libraries( + trimesh_sampling + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_select/CMakeLists.txt b/apps/sample/trimesh_select/CMakeLists.txt new file mode 100644 index 00000000..3fa8e8c3 --- /dev/null +++ b/apps/sample/trimesh_select/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_select) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_select.cpp) +endif() + +add_executable(trimesh_select + ${SOURCES}) + +target_link_libraries( + trimesh_select + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_smooth/CMakeLists.txt b/apps/sample/trimesh_smooth/CMakeLists.txt new file mode 100644 index 00000000..a3bbddcd --- /dev/null +++ b/apps/sample/trimesh_smooth/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_smooth) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_smooth.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_smooth + ${SOURCES}) + +target_link_libraries( + trimesh_smooth + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_split_vertex/CMakeLists.txt b/apps/sample/trimesh_split_vertex/CMakeLists.txt new file mode 100644 index 00000000..09a75511 --- /dev/null +++ b/apps/sample/trimesh_split_vertex/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_split_vertex) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_split_vertex.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_split_vertex + ${SOURCES}) + +target_link_libraries( + trimesh_split_vertex + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_texture/CMakeLists.txt b/apps/sample/trimesh_texture/CMakeLists.txt new file mode 100644 index 00000000..b4328dd7 --- /dev/null +++ b/apps/sample/trimesh_texture/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_texture) + +find_package( + Qt5 + COMPONENTS OpenGL Svg) + +if (TARGET Qt5::OpenGL AND TARGET Qt5::Svg) + + if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_texture.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/Outline2ToQImage.cpp + ${VCG_INCLUDE_DIRS}/wrap/qt/outline2_rasterizer.cpp) + endif() + + add_executable(trimesh_texture + ${SOURCES}) + + target_link_libraries( + trimesh_texture + PUBLIC + vcglib + Qt5::OpenGL + Qt5::Svg + ) +else() + message( + STATUS "VCG examples - Skipping trimesh_texture example") +endif() diff --git a/apps/sample/trimesh_texture_clean/CMakeLists.txt b/apps/sample/trimesh_texture_clean/CMakeLists.txt new file mode 100644 index 00000000..5d325ee8 --- /dev/null +++ b/apps/sample/trimesh_texture_clean/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_texture_clean) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_texture_clean.cpp) +endif() + +add_executable(trimesh_texture_clean + ${SOURCES}) + +target_link_libraries( + trimesh_texture_clean + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_topological_cut/CMakeLists.txt b/apps/sample/trimesh_topological_cut/CMakeLists.txt new file mode 100644 index 00000000..871b1236 --- /dev/null +++ b/apps/sample/trimesh_topological_cut/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_topological_cut) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_topological_cut.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_topological_cut + ${SOURCES}) + +target_link_libraries( + trimesh_topological_cut + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_topology/CMakeLists.txt b/apps/sample/trimesh_topology/CMakeLists.txt new file mode 100644 index 00000000..bb0b5471 --- /dev/null +++ b/apps/sample/trimesh_topology/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_topology) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_topology.cpp) +endif() + +add_executable(trimesh_topology + ${SOURCES}) + +target_link_libraries( + trimesh_topology + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_voronoi/CMakeLists.txt b/apps/sample/trimesh_voronoi/CMakeLists.txt new file mode 100644 index 00000000..9ce633cb --- /dev/null +++ b/apps/sample/trimesh_voronoi/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_voronoi) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_voronoi.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_voronoi + ${SOURCES}) + +target_link_libraries( + trimesh_voronoi + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_voronoiatlas/CMakeLists.txt b/apps/sample/trimesh_voronoiatlas/CMakeLists.txt new file mode 100644 index 00000000..3f639e58 --- /dev/null +++ b/apps/sample/trimesh_voronoiatlas/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_voronoiatlas) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_voronoiatlas.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_voronoiatlas + ${SOURCES}) + +target_link_libraries( + trimesh_voronoiatlas + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_voronoiclustering/CMakeLists.txt b/apps/sample/trimesh_voronoiclustering/CMakeLists.txt new file mode 100644 index 00000000..2e0bfc26 --- /dev/null +++ b/apps/sample/trimesh_voronoiclustering/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_voronoiclustering) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_voronoiclustering.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_voronoiclustering + ${SOURCES}) + +target_link_libraries( + trimesh_voronoiclustering + PUBLIC + vcglib + ) diff --git a/apps/sample/trimesh_voronoisampling/CMakeLists.txt b/apps/sample/trimesh_voronoisampling/CMakeLists.txt new file mode 100644 index 00000000..df908eb5 --- /dev/null +++ b/apps/sample/trimesh_voronoisampling/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) +project(trimesh_voronoisampling) + +if (VCG_HEADER_ONLY) + set(SOURCES + trimesh_voronoisampling.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(trimesh_voronoisampling + ${SOURCES}) + +target_link_libraries( + trimesh_voronoisampling + PUBLIC + vcglib + ) diff --git a/apps/tridecimator/CMakeLists.txt b/apps/tridecimator/CMakeLists.txt index 7f337fcb..0cf6e0fe 100644 --- a/apps/tridecimator/CMakeLists.txt +++ b/apps/tridecimator/CMakeLists.txt @@ -1,2 +1,17 @@ +cmake_minimum_required(VERSION 3.13) project (tridecimator) -add_executable(tridecimator tridecimator.cpp ../../wrap/ply/plylib.cpp) + +if (VCG_HEADER_ONLY) + set(SOURCES + tridecimator.cpp + ${VCG_INCLUDE_DIRS}/wrap/ply/plylib.cpp) +endif() + +add_executable(tridecimator + ${SOURCES}) + +target_link_libraries( + tridecimator + PUBLIC + vcglib + ) From ad75e3559363627e655a2f013e0dd99e1e6de300 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 25 Mar 2021 15:19:14 +0100 Subject: [PATCH 40/47] codespell - see #92 --- apps/QT/trimesh_QT/glarea.h | 8 +- apps/QT/trimesh_QT_shared/glarea.h | 8 +- apps/QT/trimesh_ant_freeglut/main.cpp | 32 ++-- apps/plymc/simplemeshprovider.h | 2 +- vcg/complex/algorithms/clean.h | 2 +- vcg/complex/algorithms/point_sampling.h | 2 +- vcg/complex/algorithms/refine.h | 2 +- .../algorithms/textcoord_optimization.h | 162 +++++++++--------- vcg/math/matrix44.h | 2 +- vcg/math/shot.h | 4 +- vcg/space/box.h | 20 +-- vcg/space/box2.h | 8 +- vcg/space/line2.h | 2 +- vcg/space/line3.h | 2 +- vcg/space/rasterized_outline2_packer.h | 4 +- vcg/space/ray2.h | 2 +- vcg/space/ray3.h | 2 +- wrap/gui/activecoordinateframe.cpp | 32 ++-- wrap/gui/activecoordinateframe.h | 18 +- wrap/gui/coordinateframe.h | 4 +- wrap/gui/trackball.h | 26 +-- wrap/io_tetramesh/io_ply.h | 14 +- wrap/io_trimesh/import_ptx.h | 8 +- wrap/io_trimesh/io_ply.h | 62 +++---- wrap/math/sparse_matrix.h | 14 +- 25 files changed, 221 insertions(+), 221 deletions(-) diff --git a/apps/QT/trimesh_QT/glarea.h b/apps/QT/trimesh_QT/glarea.h index 75b17dfa..aaf5c1c1 100644 --- a/apps/QT/trimesh_QT/glarea.h +++ b/apps/QT/trimesh_QT/glarea.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * - * This program is free software; you can redistribute it and/or modify * + * 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. * @@ -64,10 +64,10 @@ class CMesh : public vcg::tri::TriMesh< std::vector, std::vectorbbox.Center()); + glTranslate(-glWrap.m->bbox.Center()); // the trimesh drawing calls switch(drawmode) { - case SMOOTH: + case SMOOTH: glWrap.Draw (); break; - case PERPOINTS: + case PERPOINTS: glWrap.Draw (); break; - case WIRE: + case WIRE: glWrap.Draw (); break; - case FLATWIRE: + case FLATWIRE: glWrap.Draw (); break; - case HIDDEN: + case HIDDEN: glWrap.Draw (); break; - case FLAT: + case FLAT: glWrap.Draw (); break; - default: + default: break; } @@ -185,7 +185,7 @@ void initMesh() } void TW_CALL loadMesh(void *) -{ +{ if(filename==0) return; int err=vcg::tri::io::ImporterPLY::Open(mesh,(char*)filename); if(err!=0){ @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) // (note that AntTweakBar could also be intialized after GLUT, no matter) if( !TwInit(TW_OPENGL, NULL) ) { - // A fatal error occured + // A fatal error occured fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError()); return 1; } @@ -311,12 +311,12 @@ int main(int argc, char *argv[]) glutKeyboardFunc(keyPressEvent); glutKeyboardUpFunc(keyReleaseEvent); - + glutMouseWheelFunc(wheelEvent); bar = TwNewBar("TweakBar"); TwCopyCDStringToClientFunc (CopyCDStringToClient); - + TwAddVarRW(bar,"Input",TW_TYPE_CDSTRING,&filename," label='Filepath' group=SetMesh help=` Name of the file to load` "); TwAddButton(bar,"Load from file",loadMesh,0, " label='Load Mesh' group=SetMesh help=`load the mesh` "); TwAddButton(bar,"Use tetrahedron",loadTetrahedron,0, " label='Make Tetrahedron' group=SetMesh help=`use tetrahedron.` "); diff --git a/apps/plymc/simplemeshprovider.h b/apps/plymc/simplemeshprovider.h index 9505d33b..e6c38402 100644 --- a/apps/plymc/simplemeshprovider.h +++ b/apps/plymc/simplemeshprovider.h @@ -112,7 +112,7 @@ template // ALNParser::ParseALN(rmaps, alnName); // for(size_t i=0; i minVertVec; std::vector< VertexPointer > maxVertVec; - // The set of directions to be choosen + // The set of directions to be chosen std::vector< CoordType > dirVec; dirVec.push_back(CoordType(1,0,0)); dirVec.push_back(CoordType(0,1,0)); diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index 702dbdef..d5e711f8 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -1005,7 +1005,7 @@ static void AllEdge(MeshType & m, VertexSampler &ps) // Regular Uniform Edge sampling // Each edge is subdivided in a number of pieces proprtional to its length -// Sample are choosen without touching the vertices. +// Samples are chosen without touching the vertices. static void EdgeUniform(MeshType & m, VertexSampler &ps,int sampleNum, bool sampleFauxEdge=true) { diff --git a/vcg/complex/algorithms/refine.h b/vcg/complex/algorithms/refine.h index cd3c75a6..082a0228 100644 --- a/vcg/complex/algorithms/refine.h +++ b/vcg/complex/algorithms/refine.h @@ -303,7 +303,7 @@ Given a mesh the following function refines it according to two functor objects: - a predicate that tells if a given edge must be splitted -- a functor that gives you the new poistion of the created vertices (starting from an edge) +- a functor that gives you the new position of the created vertices (starting from an edge) If RefineSelected is true only selected faces are taken into account for being splitted. diff --git a/vcg/complex/algorithms/textcoord_optimization.h b/vcg/complex/algorithms/textcoord_optimization.h index 831e92cd..3c822ace 100644 --- a/vcg/complex/algorithms/textcoord_optimization.h +++ b/vcg/complex/algorithms/textcoord_optimization.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* 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. * @@ -45,13 +45,13 @@ namespace tri /* Base class for all Texture Optimizers*/ -template +template class TextureOptimizer{ protected: MESH_TYPE &m; SimpleTempData isFixed; public: - + /* Tpyes */ typedef MESH_TYPE MeshType; typedef typename MESH_TYPE::VertexIterator VertexIterator; @@ -59,26 +59,26 @@ public: typedef typename MESH_TYPE::VertexType VertexType; typedef typename MESH_TYPE::FaceType FaceType; typedef typename MESH_TYPE::ScalarType ScalarType; - - + + /* Access functions */ const MeshType & Mesh() const {return m;} MeshType & Mesh() {return m;} - + /* Constructior */ TextureOptimizer(MeshType &_m):m(_m),isFixed(_m.vert){ assert(m.HasPerVertexTexture()); } - - // initializes on current geometry + + // initializes on current geometry virtual void TargetCurrentGeometry()=0; - - // performs an interation. Returns largest movement. + + // performs an iteration. Returns largest movement. virtual ScalarType Iterate()=0; - + // performs an iteration (faster, but it does not tell how close it is to stopping) virtual void IterateBlind()=0; - + // performs iteration virtual ScalarType IterateN(int step){ for (int i=0; i1) return this->Iterate(); else return 0; } - + // performs iterations until convergence. bool IterateUntilConvergence(ScalarType threshold=0.0001, int maxite=5000){ int i; @@ -95,34 +95,34 @@ public: } return true; } - + // desctuctor: free temporary field ~TextureOptimizer(){ isFixed.Stop(); }; - + // set the current border as fixed (forced to stay in position during text optimization) void SetBorderAsFixed(){ isFixed.Start(); for (VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { - isFixed[v]=(v->IsB())?1:0; - } + isFixed[v]=(v->IsB())?1:0; + } } - + // everything moves, no vertex must fixed during texture optimization) void SetNothingAsFixed(){ isFixed.Start(); for (VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { - isFixed[v]=0; - } + isFixed[v]=0; + } } - + // fix a given vertex void FixVertex(const VertexType *v, bool fix=true){ isFixed[v]=(fix)?1:0; } - - + + }; @@ -130,12 +130,12 @@ public: /* AREA PRESERVING TEXTURE OPTIMIZATION -as in: Degener, P., Meseth, J., Klein, R. +as in: Degener, P., Meseth, J., Klein, R. "An adaptable surface parameterization method." - Proc. of the 12th International Meshing oundtable, 201–213 [2003]. + Proc. of the 12th International Meshing oundtable, 201-213 [2003]. Features: - + :) - Balances angle and area distortions (best results!). :) - Can choose how to balance area and angle preservation (see SetTheta) theta=0 -> pure conformal (use MIPS instead!) @@ -144,12 +144,12 @@ Features: :( - Slowest method. :( - Requires a fixed boundary, else expands forever in texture space (unless theta=0). :( - Diverges in presence of flipped faces (unless theta=0). -:( - Requires a speed parameter to be set. +:( - Requires a speed parameter to be set. Speed too large => when close, bounces back and forth around minimum, w/o getting any closer. Lower speed => longer convercence times */ -template +template class AreaPreservingTextureOptimizer:public TextureOptimizer{ public: /* Types */ @@ -159,34 +159,34 @@ public: typedef typename MESH_TYPE::VertexType VertexType; typedef typename MESH_TYPE::FaceType FaceType; typedef typename MESH_TYPE::ScalarType ScalarType; - + private: typedef TextureOptimizer Super; // superclass (commodity) - + // extra data per face: [0..3] -> cotangents. [4] -> area*2 SimpleTempData > data; SimpleTempData > sum; - + ScalarType totArea; ScalarType speed; - + int theta; - + public: - + // constructor and destructor AreaPreservingTextureOptimizer(MeshType &_m):Super(_m),data(_m.face),sum(_m.vert){ speed=0.001; theta=3; } - + ~AreaPreservingTextureOptimizer(){ data.Stop(); sum.Stop(); Super::isFixed.Stop(); } - + void SetSpeed(ScalarType _speed){ speed=_speed; } @@ -194,7 +194,7 @@ public: ScalarType GetSpeed(){ return speed; } - + // sets the parameter theta: // good parameters are in 1..3 // 0 = converge to pure conformal, ignore area preservation @@ -207,16 +207,16 @@ public: int GetTheta(){ return theta; } - + void IterateBlind(){ - /* todo: do as iterate, but without */ + /* todo: do as iterate, but without */ Iterate(); } - + ScalarType Iterate(){ - + ScalarType max; // max displacement - + #define v0 (f->V0(i)->T().P()) #define v1 (f->V1(i)->T().P()) #define v2 (f->V2(i)->T().P()) @@ -236,15 +236,15 @@ public: for (FaceIterator f=Super::m.face.begin(); f!=Super::m.face.end(); f++) { int i=0; ScalarType area2 = ((v1-v0) ^ (v2-v0)); for (i=0; i<3; i++){ - ScalarType + ScalarType a = (v1-v0).Norm(), b = ((v1-v0) * (v2-v0))/a, c = area2 / a, - + m0= data[f][i] / area2, m1= data[f][(i+1)%3] / area2, m2= data[f][(i+2)%3] / area2, - + mx= (b-a)/area2, my= c/area2, // 1.0/a mA= data[f][3]/area2 * scale, @@ -258,35 +258,35 @@ public: /* linear weightings - dx= (OMEGA) * (my * M2) + + dx= (OMEGA) * (my * M2) + (1-OMEGA) * ( px - 2.0*qx), - dy= (OMEGA) * (-mx * M2) + + dy= (OMEGA) * (-mx * M2) + (1-OMEGA) * ( py - 2.0*qy),*/ - + // exponential weighting // 2d gradient - + dx=// M1 - //*M1 // ^ theta-1 + //*M1 // ^ theta-1 pow(M1,theta-1) - *(px*(M1+ theta*M2) - 2.0*qx*M1), + *(px*(M1+ theta*M2) - 2.0*qx*M1), dy=// M1 - //*M1 // ^ theta-1 + //*M1 // ^ theta-1 pow(M1,theta-1) - *(py*(M1+ theta*M2) - 2.0*qy*M1), + *(py*(M1+ theta*M2) - 2.0*qy*M1), gy= dy/c, gx= (dx - gy*b) / a; // 3d gradient - sum[f->V(i)]+= ( (v1-v0) * gx + (v2-v0) * gy ) * data[f][3]; + sum[f->V(i)]+= ( (v1-v0) * gx + (v2-v0) * gy ) * data[f][3]; } } - max=0; // max displacement + max=0; // max displacement speed=0.001; - for (VertexIterator v=Super::m.vert.begin(); v!=Super::m.vert.end(); v++) - if ( !Super::isFixed[v] ) //if (!v->IsB()) + for (VertexIterator v=Super::m.vert.begin(); v!=Super::m.vert.end(); v++) + if ( !Super::isFixed[v] ) //if (!v->IsB()) { ScalarType n=sum[v].Norm(); if ( n > 1 ) { sum[v]/=n; n=1.0;} @@ -298,17 +298,17 @@ public: } return max; #undef v0 - #undef v1 - #undef v2 + #undef v1 + #undef v2 //printf("rejected %d\n",rejected); } - + void TargetCurrentGeometry(){ - + Super::isFixed.Start(); data.Start(); sum.Start(); - + totArea=0; for (FaceIterator f=Super::m.face.begin(); f!=Super::m.face.end(); f++) { double area2 = ((f->V(1)->P() - f->V(0)->P() )^(f->V(2)->P() - f->V(0)->P() )).Norm(); @@ -322,7 +322,7 @@ public: } } } - + }; @@ -333,12 +333,12 @@ public: // returns false if any fold is present (faster than MarkFolds) template bool IsFoldFree(MESH_TYPE &m){ - + assert(m.HasPerVertexTexture()); - + typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; - + ScalarType lastsign=0; for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ ScalarType sign=((f->V(1)->T().P()-f->V(0)->T().P()) ^ (f->V(2)->T().P()-f->V(0)->T().P())); @@ -354,16 +354,16 @@ bool IsFoldFree(MESH_TYPE &m){ // returns number of folded faces template int MarkFolds(MESH_TYPE &m){ - + assert(m.HasPerVertexTexture()); assert(m.HasPerFaceQuality()); - + typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; - + SimpleTempData sign(m.face); sign.Start(0); - + // first pass, determine predominant sign int npos=0, nneg=0; ScalarType lastsign=0; @@ -372,7 +372,7 @@ int MarkFolds(MESH_TYPE &m){ if (fsign<0) { sign[f]=-1; nneg++; } if (fsign>0) { sign[f]=+1; npos++; } } - + // second pass, detect folded faces int res=0; short gsign= (nneg>npos)?-1:+1; @@ -382,28 +382,28 @@ int MarkFolds(MESH_TYPE &m){ f->Q()=0; } else f->Q()=1; } - + sign.Stop(); - + return res; } // Smooths texture coords. -// (can be useful to remove folds, +// (can be useful to remove folds, // e.g. these created when obtaining tecture coordinates after projections) template void SmoothTextureCoords(MESH_TYPE &m){ - + assert(m.HasPerVertexTexture()); - + typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; - + SimpleTempData div(m.vert); SimpleTempData sum(m.vert); - + div.Start(); sum.Start(); - + for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { sum[v].SetZero(); div[v]=0; @@ -415,13 +415,13 @@ void SmoothTextureCoords(MESH_TYPE &m){ div[f->V(2)] +=2; sum[f->V(2)] += f->V(1)->T().P(); sum[f->V(2)] += f->V(0)->T().P(); } - for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) // if (!v->IsB()) + for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) // if (!v->IsB()) { if (v->div>0) { v->T().P() = sum[v]/div[v]; } } - + div.Stop(); sum.Stop(); diff --git a/vcg/math/matrix44.h b/vcg/math/matrix44.h index cb2f8c7c..11d228d9 100644 --- a/vcg/math/matrix44.h +++ b/vcg/math/matrix44.h @@ -566,7 +566,7 @@ bool Decompose(Matrix44 &M, Point3 &ScaleV, Point3 &ShearV, Point3 & return false; if(math::Abs(M.Determinant())<1e-10) return false; // matrix should be at least invertible... - // First Step recover the traslation + // First Step recover the translation TranV=M.GetColumn3(3); // Second Step Recover Scale and Shearing interleaved diff --git a/vcg/math/shot.h b/vcg/math/shot.h index 978100b2..0eeda9cf 100644 --- a/vcg/math/shot.h +++ b/vcg/math/shot.h @@ -207,7 +207,7 @@ public: } /* multiply the current reference frame for the matrix passed - note: it is up to the caller to check the the matrix passed is a pure rototraslation + note: it is up to the caller to check the the matrix passed is a pure rototranslation */ void MultMatrix( vcg::Matrix44 m44) { @@ -218,7 +218,7 @@ public: } /* multiply the current reference frame for the similarity passed - note: it is up to the caller to check the the matrix passed is a pure rototraslation + note: it is up to the caller to check the the matrix passed is a pure rototranslation */ void MultSimilarity( const Similarity & s){ MultMatrix(s.Matrix());} diff --git a/vcg/space/box.h b/vcg/space/box.h index ad4bdf97..8cc66abb 100644 --- a/vcg/space/box.h +++ b/vcg/space/box.h @@ -107,7 +107,7 @@ public: { return _min!=p._min || _max!=p._max; } - /** Infaltes the box of a percentage.. + /** Infltes the box of a percentage.. @param s Scalar value. E.g if s=0.1 the box enlarges of 10% in every direction if S==0.5 box doubles (+50% in every direction) if S < 0 box shrinks @@ -133,12 +133,12 @@ public: _min -= delta; _max += delta; } - /// Initializing the box + /// Initializing the box void Set( const PointType & p ) { _min = _max = p; } - /// Set the box to a null value + /// Set the box to a null value void SetNull() { _min.X()= 1; _max.X()= -1; @@ -147,7 +147,7 @@ public: } /** Add two boxex: Returns minimal box that contains both operands. - @param b The box to add + @param b The box to add */ void Add( Box const & b ) { @@ -174,7 +174,7 @@ public: }; } } - /** Coputes intersection of Boxes: the minimal box containing both operands. + /** Computes intersection of Boxes: the minimal box containing both operands. @param b The other operand */ void Intersect( const Box & b ) @@ -190,7 +190,7 @@ public: if(_min.X()>_max.X() || _min.Y()>_max.Y() ) SetNull(); else if (N>2) if (_min.Z()>_max.Z()) SetNull(); } - /** Traslalate the box. + /** Translalate the box. @param p: the translation vector */ void Translate( const PointType & p ) @@ -198,7 +198,7 @@ public: _min += p; _max += p; } - /** Check wheter a point is inside box. + /** Check whether a point is inside box. @param p The point @returns True if inside, false otherwise */ @@ -214,7 +214,7 @@ public: _min.Z() <= p.Z() && p.Z() <= _max.Z() ); } - /** Check wheter a point is inside box, open at left and closed at right [min..max) + /** Check whether a point is inside box, open at left and closed at right [min..max) @param p The point 3D @returns True if inside, false otherwise */ @@ -283,7 +283,7 @@ public: (p[2]-_min[2])/(_max[2]-_min[2]) ); } - /// Computes the Volume for the box. + /// Computes the Volume for the box. inline S Volume() const { if (N==2) return (_max.X()-_min.X())*(_max.Y()-_min.Y()); @@ -356,7 +356,7 @@ public: //@} //@{ - /** @name Iporters (for boxes in different spaces and with different scalar types) + /** @name Importers (for boxes in different spaces and with different scalar types) **/ /// imports the box diff --git a/vcg/space/box2.h b/vcg/space/box2.h index 651c903c..9f50e625 100644 --- a/vcg/space/box2.h +++ b/vcg/space/box2.h @@ -164,8 +164,8 @@ public: if(min.X()>max.X() || min.Y()>max.Y()) SetNull(); } - /** Traslate the bounding box by a vectore - @param p The transolation vector + /** Translate the bounding box by a vector + @param p The translation vector */ void Translate( const PointType & p ) { @@ -205,7 +205,7 @@ public: bb.Intersect(b); return bb.IsValid(); } - /** Check if emptry. + /** Check if empty. @return True iff empty */ inline bool IsNull() const { return min.X()>max.X() || min.Y()>max.Y(); } @@ -215,7 +215,7 @@ public: */ inline bool IsValid() const { return min.X()& leftHorizon() { return mLeftHorizon; } vcg::Point2i& size() { return mSize; } - //returns the score relative to the left horizon of that poly in that particular position, taking into account the choosen algo + //returns the score relative to the left horizon of that poly in that particular position, taking into account the chosen algo int getCostX(RasterizedOutline2& poly, Point2i pos, int rast_i) { switch (params.costFunction) { case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndLeftHorizon(poly, pos, rast_i); @@ -315,7 +315,7 @@ public: return 0; } - //returns the score relative to the bottom horizon of that poly in that particular position, taking into account the choosen algo + //returns the score relative to the bottom horizon of that poly in that particular position, taking into account the chosen algo int getCostY(RasterizedOutline2& poly, Point2i pos, int rast_i) { switch (params.costFunction) { case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndBottomHorizon(poly, pos, rast_i); diff --git a/vcg/space/ray2.h b/vcg/space/ray2.h index fb8defe8..fe38ea93 100644 --- a/vcg/space/ray2.h +++ b/vcg/space/ray2.h @@ -109,7 +109,7 @@ public: { if (NORM) return ScalarType((p-_ori)*_dir); else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm()); } - /// returns wheter this type is normalized or not + /// returns whether this type is normalized or not static bool IsNormalized() {return NORM;}; /// calculates the point of parameter t on the ray. inline PointType P( const ScalarType t ) const diff --git a/vcg/space/ray3.h b/vcg/space/ray3.h index dc76fc2b..b3b7c047 100644 --- a/vcg/space/ray3.h +++ b/vcg/space/ray3.h @@ -115,7 +115,7 @@ public: { if (NORM) return ScalarType((p-_ori).dot(_dir)); else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm()); } - /// returns wheter this type is normalized or not + /// returns whether this type is normalized or not static bool IsNormalized() {return NORM;}; /// calculates the point of parameter t on the ray. inline PointType P( const ScalarType t ) const diff --git a/wrap/gui/activecoordinateframe.cpp b/wrap/gui/activecoordinateframe.cpp index 9891d18e..a3f65db7 100644 --- a/wrap/gui/activecoordinateframe.cpp +++ b/wrap/gui/activecoordinateframe.cpp @@ -68,16 +68,16 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw) manipulator->center=position; manipulator->GetView(); manipulator->Apply(); - + MovableCoordinateFrame::Render(glw); - + // got nothing to draw if(!drawmoves && !drawrotations){ glPopMatrix(); - return; + return; } - int current_mode=manipulator->current_button; + int current_mode=manipulator->current_button; bool rotating=(current_mode==rotx)||(current_mode==roty)||(current_mode==rotz); bool moving=(current_mode==movx)||(current_mode==movy)||(current_mode==movz); @@ -89,18 +89,18 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); - + QString message("this should never be seen"); char axis_name; float verse; - + if(current_mode==x_modifier){ glColor(xcolor); message = QString("move or rotate on X axis"); } else if(current_mode==y_modifier){ glColor(ycolor); message = QString("move or rotate on Y axis"); } else if(current_mode==z_modifier){ glColor(zcolor); message = QString("move or rotate on Z axis"); - } else + } else if(rotating && drawrotations){ // draw a rotation Point3f axis, arc_point; float angle; @@ -126,15 +126,15 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw) .arg(axis_name); Quaternionf arc_rot; arc_rot.FromAxis(angle/18.0,axis); - glBegin(GL_POLYGON); + glBegin(GL_POLYGON); glVertex(position); glVertex(position+arc_point); for(int i=0;i<18;i++){ arc_point = arc_rot.Rotate(arc_point); glVertex(position+arc_point); } - glEnd(); - } else if(moving && drawmoves){ // draw a traslation + glEnd(); + } else if(moving && drawmoves){ // draw a translation Point3f ntra=manipulator->track.tra; ntra.Normalize(); if(current_mode==movx){ @@ -159,11 +159,11 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw) glEnd(); glBegin(GL_POINTS); glVertex(old_pos); - glEnd(); + glEnd(); } else { // got nothing to draw glPopAttrib(); glPopMatrix(); - return; + return; } // draw message below cursor font.setBold(true); @@ -179,7 +179,7 @@ void ActiveCoordinateFrame::Reset(bool reset_position,bool reset_alignment) { MovableCoordinateFrame::Reset(reset_position, reset_alignment); Update(); - manipulator->Reset(); + manipulator->Reset(); } void ActiveCoordinateFrame::SetPosition(const Point3f newpos) @@ -215,7 +215,7 @@ void ActiveCoordinateFrame::MouseMove(int x, int y) manipulator->MouseMove(x,y); } -void ActiveCoordinateFrame::MouseUp(int x, int y, /*Button */ int button) +void ActiveCoordinateFrame::MouseUp(int x, int y, /*Button */ int button) { Move(manipulator->track); manipulator->Reset(); @@ -263,9 +263,9 @@ void ActiveCoordinateFrame::Update() x_axis=r.Rotate(Point3f(1,0,0)); y_axis=r.Rotate(Point3f(0,1,0)); z_axis=r.Rotate(Point3f(0,0,1)); - + manipulator->ClearModes(); - manipulator->modes[0] = NULL; + manipulator->modes[0] = NULL; manipulator->modes[movx] = new AxisMode(p,x_axis); manipulator->modes[movy] = new AxisMode(p,y_axis); manipulator->modes[movz] = new AxisMode(p,z_axis); diff --git a/wrap/gui/activecoordinateframe.h b/wrap/gui/activecoordinateframe.h index d5a1dc8b..715fa3c2 100644 --- a/wrap/gui/activecoordinateframe.h +++ b/wrap/gui/activecoordinateframe.h @@ -87,7 +87,7 @@ public: @param new_rotation the new rotation of the coordinate frame. */ virtual void SetRotation(const Quaternionf rotation); - + /*! @brief Align the coordinate frame to one or two directions. @@ -99,8 +99,8 @@ public: @param primary the primary direction of alignment. @param secondary the secondary direction of alignment. - @param axis_1 the name of the axis to align to the primary direction, must be a char choosen from 'X', 'Y' and 'Z' - @param axis_2 the name of the axis to align to the secondary direction, must be different from axis_1 and must be a char choosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is choosen automatically. + @param axis_1 the name of the axis to align to the primary direction, must be a char chosen from 'X', 'Y' and 'Z' + @param axis_2 the name of the axis to align to the secondary direction, must be different from axis_1 and must be a char chosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is chosen automatically. */ virtual void AlignWith(const Point3f primary, const Point3f secondary, const char axis_1, const char axis_2); @@ -119,7 +119,7 @@ public: @param x the x coordinate of the cursor. @param y the y coordinate of the cursor. */ - void MouseMove(int x, int y); + void MouseMove(int x, int y); /*! @brief Interface function relative to mouse up event in QT. @@ -143,20 +143,20 @@ public: @param button the keyboard modifiers state. */ void ButtonDown(int button); - + /*! @brief Set rotational snap value. - + @param value the new rotational snap value, in degrees. */ void SetSnap(float value); /// The eulerian trackball. Trackball *manipulator; - + /// The flag that enables moves feedback rendering bool drawmoves; - + /// The flag that enables rotations feedback rendering bool drawrotations; protected: @@ -165,7 +165,7 @@ protected: const int x_modifier,y_modifier,z_modifier; Point3f x_axis,y_axis,z_axis; float rot_snap_rad,mov_snap; - // functions: + // functions: virtual void Move(const Similarityf); void Update(); private: diff --git a/wrap/gui/coordinateframe.h b/wrap/gui/coordinateframe.h index fb2098aa..56aa4256 100644 --- a/wrap/gui/coordinateframe.h +++ b/wrap/gui/coordinateframe.h @@ -212,8 +212,8 @@ public: @param primary the primary direction of alignment. @param secondary the secondary direction of alignment. - @param axis_1 the name of the axis to align to the primary direction, must be a char choosen from 'X', 'Y' and 'Z' - @param axis_2 the name of the axis to align to the secondary direction, must be different from axis_1 and must be a char choosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is choosen automatically. + @param axis_1 the name of the axis to align to the primary direction, must be a char chosen from 'X', 'Y' and 'Z' + @param axis_2 the name of the axis to align to the secondary direction, must be different from axis_1 and must be a char chosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is chosen automatically. */ virtual void AlignWith(const Point3f primary, const Point3f secondary, const char axis_1, const char axis_2); diff --git a/wrap/gui/trackball.h b/wrap/gui/trackball.h index 9d3a87f2..9b43e175 100644 --- a/wrap/gui/trackball.h +++ b/wrap/gui/trackball.h @@ -110,9 +110,9 @@ public: /// A trackball stores a transformation called 'track' that effectively rototranslate the object. Similarityf track; /// track position in model space. - Point3f center; + Point3f center; /// size of the widget in model space. - float radius; + float radius; }; /*! @@ -160,7 +160,7 @@ mesh->Render(); Note on the typical use: - - Perspective and glulookat are choosed to frame the origin centered 1-radius trackball. + - Perspective and glulookat are chosen to frame the origin centered 1-radius trackball. - The final scale and translate are just to fit a generic mesh to the 1sized origin centered where the trackball stays box. - The trackball works also on Orthographic projections \b but that are not centered around origin (just move it back along the Z) */ @@ -199,7 +199,7 @@ public: @warning The destructor does not deallocate the memory allocated by setDefaultMapping(), because the application can change the modes map. This can lead to small memory leaks, so please explicitally delete any manipulator in the modes map if you are going to repeatly allocate and deallocate Trackball instances. */ ~Trackball(); - + private: // Trackball must not be copied. Use Append (see vcg/complex/trimesh/append.h) Trackball operator =(const Trackball & /*m*/) = delete; @@ -273,7 +273,7 @@ public: void ApplyInverse(); // DrawIcon() has been moved to trackutils.h //void DrawIcon(); - + // T(c) S R T(t) T(-c) => S R T(S^(-1) R^(-1)(c) + t - c) Matrix44f Matrix() const; Matrix44f InverseMatrix() const; @@ -315,7 +315,7 @@ public: @param x The horizontal coordinate of the mouse pointer. @param y The vertical coordinate of the mouse pointer. */ - void MouseMove(int x, int y); + void MouseMove(int x, int y); /*! @brief Interface function relative to mouse down event in QT/SDL. @@ -323,7 +323,7 @@ public: @param y The vertical coordinate of the mouse pointer. @param button The new state. */ - void MouseUp(int x, int y, /*Button */ int button); + void MouseUp(int x, int y, /*Button */ int button); /*! @brief Old interface function relative to mouse down event in QT/SDL. @@ -367,9 +367,9 @@ public: void SetSpinnable(bool on); - + // returns if it is animating or not - // + // bool IsAnimating(unsigned int msec=0); // Animate: either takes an absolute time (if default not specified, then it is automeasured) @@ -424,7 +424,7 @@ public: /* //internals // commented out no more used this stuff! enum Action { NONE = 0, VIEW_ROTATE = 1, - // Axis Constrained Rotation + // Axis Constrained Rotation TRACK_ROTATE_X = 3, TRACK_ROTATE_Y = 4, TRACK_ROTATE_Z = 5, // Drag constrained to an axis (trackball axis) DRAG_X = 6, DRAG_Y = 7, DRAG_Z = 8, @@ -469,9 +469,9 @@ public: /// The inactive manipulator. It is drawn when Trackball is inactive. TrackMode *inactive_mode; - + // The manipulator to deal with timer events and key events - TrackMode *idle_and_keys_mode; + TrackMode *idle_and_keys_mode; /*! @brief Reset modes to default mapping. @@ -493,7 +493,7 @@ public: /// Transformation before current user action. Similarityf last_track; /// track after an Undo() call. - Similarityf undo_track; + Similarityf undo_track; /// Currently not in use. Similarityf last_view; /// Mouse cursor coordinates before current action. diff --git a/wrap/io_tetramesh/io_ply.h b/wrap/io_tetramesh/io_ply.h index c2e9d472..848e4e49 100644 --- a/wrap/io_tetramesh/io_ply.h +++ b/wrap/io_tetramesh/io_ply.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* 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. * @@ -52,9 +52,9 @@ namespace vcg { namespace tetra { namespace io { - + /** Additional data needed or useful for parsing a ply mesh. -This class can be passed to the ImporterPLY::Open() function for +This class can be passed to the ImporterPLY::Open() function for - retrieving additional per-vertex per-tetra data - specifying a callback for long ply parsing - knowing what data is contained in a ply file @@ -74,10 +74,10 @@ public: } /// Store the error codes enconutered when parsing a ply int status; - /// It returns a bit mask describing the field preesnt in the ply file - int mask; + /// It returns a bit mask describing the field present in the ply file + int mask; - /// a Simple callback that can be used for long ply parsing. + /// a Simple callback that can be used for long ply parsing. // it returns the current position, and formats a string with a description of what th efunction is doing (loading vertexes, faces...) CallBackPos *cb; @@ -87,7 +87,7 @@ public: PropDescriptor *VertexData; /// the number of per-face descriptor (usually 0) int fdn; - + /// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply PropDescriptor *TetraData; diff --git a/wrap/io_trimesh/import_ptx.h b/wrap/io_trimesh/import_ptx.h index f049d398..79a43960 100644 --- a/wrap/io_trimesh/import_ptx.h +++ b/wrap/io_trimesh/import_ptx.h @@ -67,7 +67,7 @@ public: flipfaces = false; } - /// a bit mask describing the field preesnt in the ply file + /// a bit mask describing the field present in the ply file int mask; /// index of mesh to be imported @@ -189,8 +189,8 @@ public: if ( ( colnum <=0 ) || ( rownum <=0 ) ) return false; // initial 4 lines - if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered position - if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'X' + if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered position + if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'X' if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'Y' if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'Z' // now the transformation matrix @@ -434,7 +434,7 @@ public: tri::Clean::RemoveUnreferencedVertex(m); } } - Matrix44x tr; + Matrix44x tr; tr.Import(currtrasf); tri::UpdatePosition::Matrix(m,tr,true); tri::Allocator::CompactVertexVector(m); diff --git a/wrap/io_trimesh/io_ply.h b/wrap/io_trimesh/io_ply.h index 5a504784..f52547e8 100644 --- a/wrap/io_trimesh/io_ply.h +++ b/wrap/io_trimesh/io_ply.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* 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. * @@ -54,9 +54,9 @@ namespace io { - + /** Additional data needed or useful for parsing a ply mesh. -This class can be passed to the ImporterPLY::Open() function for +This class can be passed to the ImporterPLY::Open() function for - retrieving additional per-vertex per-face data - specifying a callback for long ply parsing - knowing what data is contained in a ply file @@ -65,13 +65,13 @@ class PlyInfo { public: typedef ::vcg::ply::PropDescriptor PropDescriptor ; - + void AddPerElemFloatAttribute(int elemType, const char *attrName, const char * propName=0) { static const char *elemStr[2]={"vertex","face"}; std::vector *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)}; std::vector *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)}; - + if(propName==0) propName=attrName; elemDescVec[elemType]->push_back(PropDescriptor()); elemNameVec[elemType]->push_back(attrName); @@ -80,71 +80,71 @@ public: elemDescVec[elemType]->back().stotype1 = vcg::ply::T_FLOAT; elemDescVec[elemType]->back().memtype1 = vcg::ply::T_FLOAT; } - - void AddPerVertexFloatAttribute(const char *attrName, const char *propName=0) { - AddPerElemFloatAttribute(0,attrName,propName); + + void AddPerVertexFloatAttribute(const char *attrName, const char *propName=0) { + AddPerElemFloatAttribute(0,attrName,propName); } - void AddPerFaceFloatAttribute(const char *attrName, const char *propName=0) { - AddPerElemFloatAttribute(1,attrName,propName); + void AddPerFaceFloatAttribute(const char *attrName, const char *propName=0) { + AddPerElemFloatAttribute(1,attrName,propName); } - - - /* Note that saving a per vertex point3 attribute is a mess. + + + /* Note that saving a per vertex point3 attribute is a mess. * Actually require to allocate 3 float attribute and save them. And they are never deallocated... */ template void AddPerVertexPoint3fAttribute(MeshType &m, const char *attrName, const char *propName="") { if(propName==0) propName=attrName; - + const char *attrxyz[3] = { strdup((std::string(attrName)+std::string("_x")).c_str()), strdup((std::string(attrName)+std::string("_y")).c_str()), strdup((std::string(attrName)+std::string("_z")).c_str()), }; - typename MeshType::template PerVertexAttributeHandle + typename MeshType::template PerVertexAttributeHandle ht = vcg::tri::Allocator:: template GetPerVertexAttribute (m,attrName); - + typename MeshType::template PerVertexAttributeHandle htt[3]; - + for(int i=0;i<3;++i) - { + { htt[i] = vcg::tri::Allocator:: template GetPerVertexAttribute (m,std::string(attrxyz[i])); // ForEachVertex (m, [&](typename MeshType::VertexType &v) { // htt[i][v] = ht[v][i]; -// }); +// }); for(auto vi=m.vert.begin();vi!=m.vert.end();++vi) - if(!vi->IsD()) + if(!vi->IsD()) htt[i][vi] = ht[vi][i]; - AddPerVertexFloatAttribute(attrxyz[i]); + AddPerVertexFloatAttribute(attrxyz[i]); } } - - + + PlyInfo() { status=0; mask=0; - cb=0; + cb=0; } /// Store the error codes enconutered when parsing a ply int status; - /// It returns a bit mask describing the field preesnt in the ply file - int mask; + /// It returns a bit mask describing the field present in the ply file + int mask; - /// a Simple callback that can be used for long ply parsing. + /// a Simple callback that can be used for long ply parsing. // it returns the current position, and formats a string with a description of what th efunction is doing (loading vertexes, faces...) CallBackPos *cb; /// The additional vertex descriptor that a user can specify to load additional per-vertex non-standard data stored in a ply std::vector VertDescriptorVec; - /// AttributeName is an array, externally allocated, containing the names of the attributes to be saved (loaded). + /// AttributeName is an array, externally allocated, containing the names of the attributes to be saved (loaded). /// We assume that AttributeName[], if not empty, is exactly of the same size of VertexdData[] /// If AttributeName[i] is not empty we use it to retrieve/store the info instead of the offsetted space in the current vertex - std::vector VertAttrNameVec; - + std::vector VertAttrNameVec; + /// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply std::vector FaceDescriptorVec; - std::vector FaceAttrNameVec; + std::vector FaceAttrNameVec; /// a string containing the current ply header. Useful for showing it to the user. std::string header; diff --git a/wrap/math/sparse_matrix.h b/wrap/math/sparse_matrix.h index cef43843..802c6ad9 100644 --- a/wrap/math/sparse_matrix.h +++ b/wrap/math/sparse_matrix.h @@ -15,10 +15,10 @@ public: std::vector _Ap; std::vector _Ai; std::vector _Ax; - + typedef typename std::pair IndexType; - - int _dimension; + + int _dimension; public: @@ -26,16 +26,16 @@ public: virtual void Initalize(int dimension) {_dimension=dimension;} -///create a sparse matrix given a set of entries as vector +///create a sparse matrix given a set of entries as vector ///of pair of int virtual void CreateSparse(std::vector Entries) {} -///return the value of the matrix +///return the value of the matrix virtual ScalarType &A(int row,int col) {return (_Ax[0]);} -///return true if the rapresention of sparse matriz is symmetric +///return true if the represention of sparse matriz is symmetric virtual bool IsSymmetric() {return false;} @@ -45,4 +45,4 @@ virtual void Zero() ///return the dimension of the matrix virtual int Size(){return _dimension;} -}; \ No newline at end of file +}; From 045d13add4d981e596e6546c020941517ddc5c33 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 25 Mar 2021 15:29:38 +0100 Subject: [PATCH 41/47] ghactions builds examples from cmake --- .../{BuildSamplesUbuntu.yml => BuildExamplesLinux.yml} | 10 ++++++---- .../{BuildSamplesMacOS.yml => BuildExamplesMacOS.yml} | 8 +++++--- ...uildSamplesWindows.yml => BuildExamplesWindows.yml} | 8 +++++--- 3 files changed, 16 insertions(+), 10 deletions(-) rename .github/workflows/{BuildSamplesUbuntu.yml => BuildExamplesLinux.yml} (55%) rename .github/workflows/{BuildSamplesMacOS.yml => BuildExamplesMacOS.yml} (64%) rename .github/workflows/{BuildSamplesWindows.yml => BuildExamplesWindows.yml} (84%) diff --git a/.github/workflows/BuildSamplesUbuntu.yml b/.github/workflows/BuildExamplesLinux.yml similarity index 55% rename from .github/workflows/BuildSamplesUbuntu.yml rename to .github/workflows/BuildExamplesLinux.yml index 9601bba4..e2fa3b37 100644 --- a/.github/workflows/BuildSamplesUbuntu.yml +++ b/.github/workflows/BuildExamplesLinux.yml @@ -1,12 +1,12 @@ -name: BuildSamplesUbuntu +name: BuildExamplesLinux 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 + name: Build Examples (Linux) + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -14,5 +14,7 @@ jobs: uses: jurplel/install-qt-action@v2 - name: Build Samples run: | - qmake apps/sample/sample.pro + mkdir build + cd build + cmake -DVCG_BUILD_EXAMPLES=ON .. make -j4 diff --git a/.github/workflows/BuildSamplesMacOS.yml b/.github/workflows/BuildExamplesMacOS.yml similarity index 64% rename from .github/workflows/BuildSamplesMacOS.yml rename to .github/workflows/BuildExamplesMacOS.yml index 7640a8ea..1c86276f 100644 --- a/.github/workflows/BuildSamplesMacOS.yml +++ b/.github/workflows/BuildExamplesMacOS.yml @@ -1,11 +1,11 @@ -name: BuildSamplesMacOS +name: BuildExamplesMacOS on: [push, pull_request] jobs: macos_build_tests: - name: Build Samples (MacOS) + name: Build Examples (MacOS) runs-on: macos-latest steps: @@ -14,5 +14,7 @@ jobs: uses: jurplel/install-qt-action@v2 - name: Build Samples run: | - qmake apps/sample/sample.pro + mkdir build + cd build + cmake -DVCG_BUILD_EXAMPLES=ON .. make -j4 diff --git a/.github/workflows/BuildSamplesWindows.yml b/.github/workflows/BuildExamplesWindows.yml similarity index 84% rename from .github/workflows/BuildSamplesWindows.yml rename to .github/workflows/BuildExamplesWindows.yml index a9a069b0..f92285cc 100644 --- a/.github/workflows/BuildSamplesWindows.yml +++ b/.github/workflows/BuildExamplesWindows.yml @@ -1,10 +1,10 @@ -name: BuildSamplesWindows +name: BuildExamplesWindows on: [push, pull_request] jobs: windows_build_tests: - name: Build Samples (Windows) + name: Build Examples (Windows) runs-on: windows-latest steps: @@ -25,5 +25,7 @@ jobs: uses: jurplel/install-qt-action@v2 - name: Build Samples run: | - qmake apps/sample/sample.pro + mkdir build + cd build + cmake -G "NMake Makefiles" -DVCG_BUILD_EXAMPLES=ON .. jom -j4 From eed785fdd35cc3cd9438022d52681606b4e4457c Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 25 Mar 2021 15:39:09 +0100 Subject: [PATCH 42/47] update readme --- README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 63209851..e65a1b39 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ 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. -![BuildSamplesUbuntu](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildSamplesUbuntu/badge.svg) -![BuildSamplesMacOS](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildSamplesMacOS/badge.svg) -![BuildSamplesWindows](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildSamplesWindows/badge.svg) +![BuilExamplesLinux](https://github.com/cnr-isti-vclab/vcglib/workflows/BuilExamplesLinux/badge.svg) +![BuildExamplesMacOS](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildExamplesMacOS/badge.svg) +![BuildExamplesWindows](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildExamplesWindows/badge.svg) 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. @@ -28,17 +28,10 @@ A number of applications have been developed using the vcglib: - Metro, the tool for measuring differences between meshes - The first high quality out-of-core mesh simplifier that was used by the Stanford Digital Michelangelo project to process their huge 3D scanned models. -## Contributing -In case of bugs please report them [here](https://github.com/cnr-isti-vclab/vcglib/issues). - -Copyright of the library is fully owned by CNR. Contributing means signing an appropriate [license agreement](https://github.com/cnr-isti-vclab/vcglib/blob/master/docs/ContributorLicenseAgreement.pdf) . - -Pull requests about trivial, small, questionable updates (e.g. small stylistic changes like int -> uint8_t) will be rejected without discussion. - - ## Contacts For any info about licensing (portion of) the library please contact us: Paolo Cignoni (p.cignoni@isti.cnr.it) Visual Computing Lab of the Italian National Research Council - ISTI +In case of bugs please report them [here](https://github.com/cnr-isti-vclab/vcglib/issues) . From c8149ca991d7f10f936631b52004bbeb8abdb6bd Mon Sep 17 00:00:00 2001 From: Alessandro Muntoni Date: Thu, 25 Mar 2021 15:39:59 +0100 Subject: [PATCH 43/47] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e65a1b39..d98ee6ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ 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. -![BuilExamplesLinux](https://github.com/cnr-isti-vclab/vcglib/workflows/BuilExamplesLinux/badge.svg) +![BuildExamplesLinux](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildExamplesLinux/badge.svg) ![BuildExamplesMacOS](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildExamplesMacOS/badge.svg) ![BuildExamplesWindows](https://github.com/cnr-isti-vclab/vcglib/workflows/BuildExamplesWindows/badge.svg) From ade2c49443beee39ddc3cd70f1d2172d550f7f03 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 25 Mar 2021 18:13:41 +0100 Subject: [PATCH 44/47] some cleanups --- vcg/complex/base.h | 4 +- vcg/space/box.h | 2 +- vcg/space/box2.h | 285 +++++++++++++++++----------------- vcg/space/box3.h | 52 +++---- vcg/space/deprecated_point3.h | 2 +- vcg/space/deprecated_point4.h | 6 +- vcg/space/line2.h | 2 +- 7 files changed, 178 insertions(+), 175 deletions(-) diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 4a1e01f9..88de7028 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -25,6 +25,8 @@ #define __VCG_COMPLEX_BASE #include +#include + #include #include "used_types.h" @@ -599,7 +601,7 @@ template inline bool IsMarked(const MeshType & m,typename MeshT @param m the mesh containing the element @param t tetra pointer */ template -inline bool IsMarked(MeshType &m, typename MeshType::ConstTetraPointer t) { return t->cIMark() == m.imark; } +inline bool IsMarked(const MeshType &m, typename MeshType::ConstTetraPointer t) { return t->cIMark() == m.imark; } /** \brief Set the vertex incremental mark of the vertex to the one of the mesh. @param m the mesh containing the element diff --git a/vcg/space/box.h b/vcg/space/box.h index 8cc66abb..2cb77ab1 100644 --- a/vcg/space/box.h +++ b/vcg/space/box.h @@ -49,7 +49,7 @@ First working release. #ifndef __VCGLIB_BOX #define __VCGLIB_BOX -#include +#include #include #include diff --git a/vcg/space/box2.h b/vcg/space/box2.h index 9f50e625..ad0a5854 100644 --- a/vcg/space/box2.h +++ b/vcg/space/box2.h @@ -2,7 +2,7 @@ * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * -* Copyright(C) 2004-2016 \/)\/ * +* Copyright(C) 2004-2021 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * @@ -36,54 +36,51 @@ template class Segment2; /** \addtogroup space */ /*@{*/ /** - Templated class for a 2D bounding box. It is stored just as two Point2 + Templated class for a 2D bounding box. It is stored just as two Point2 @param BoxScalarType (Template Parameter) Specifies the scalar field. */ template class Box2 { public: - /// The scalar type + /// The scalar type typedef BoxScalarType ScalarType; - typedef Point2 PointType ; + typedef Point2 PointType; - /// min coordinate point - PointType min; - /// max coordinate point - PointType max; - /// Standard constructor + /// min coordinate point + PointType min; + /// max coordinate point + PointType max; + /// Standard constructor inline Box2() { min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1; } - /// Copy constructor - inline Box2( const Box2 & b ) { min=b.min; max=b.max; } - /// Min Max constructor - inline Box2( const Point2 & mi, const Point2 & ma ) { min = mi; max = ma; } + /// Min Max constructor + inline Box2(const Point2 & mi, const Point2 & ma ) { min = mi; max = ma; } - inline Box2(const Point2 & center, const BoxScalarType & radius) { - min = center-Point2(radius,radius); - max = center+Point2(radius,radius); - } + inline Box2(const Point2 & center, const BoxScalarType & radius) + { + min = center-Point2(radius,radius); + max = center+Point2(radius,radius); + } - /// Distructor - inline ~Box2() { } - /// Operator to compare two bounding box + /// Operator to compare two bounding box inline bool operator == ( Box2 const & p ) const { return min==p.min && max==p.max; } - /// Initializing the bounding box with a point + /// Initializing the bounding box with a point void Set( const PointType & p ) { min = max = p; } - Point2 P(const int & i) const + Point2 P(int i) const { - return Point2( - min[0]+ (i%2) * DimX(), + return Point2( + min[0]+ (i%2) * DimX(), min[1]+ ((i / 2)%2) * DimY()); } - // Initializing with the values + // Initializing with the values inline void Set( ScalarType minx, ScalarType miny, ScalarType maxx, ScalarType maxy ) { min[0] = minx; @@ -91,15 +88,15 @@ public: max[0] = maxx; max[1] = maxy; } - /// Set the bounding box to a null value + /// Set the bounding box to a null value void SetNull() { - min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1; + min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1; } - /** Function to add two bounding box - the bounding box expand to include the other bounding box (if necessary) - @param b The bounding box to be added - */ + /** @brief Function to add two bounding box + * the bounding box expand to include the other bounding box (if necessary) + * @param b The bounding box to be added + */ void Add( Box2 const & b ) { if(IsNull()) @@ -116,14 +113,15 @@ public: if(max.Y() < b.max.Y()) max.Y() = b.max.Y(); } } - /** Adds a point to the bouning box. - the bounding box expand to include the new point (if necessary) - @param p The point 2D - */ + /** + * @brief Adds a point to the bouning box. + * the bounding box expand to include the new point (if necessary) + * @param p The point 2D + */ void Add( const PointType & p ) { if(IsNull()) Set(p); - else + else { if(min.X() > p.X()) min.X() = p.X(); if(min.Y() > p.Y()) min.Y() = p.Y(); @@ -133,26 +131,29 @@ public: } } - /** Varies the dimension of the bounding box. - @param delta The size delta (if positive, box is enlarged) - */ - void Offset(const ScalarType s) + /** + * @brief Varies the dimension of the bounding box. + * @param delta The size delta (if positive, box is enlarged) + */ + void Offset(ScalarType s) { Offset(PointType(s, s)); } - /** Varies the dimension of the bounding box. - @param delta The size delta per dimension (if positive, box is enlarged) - */ + /** + * @brief Varies the dimension of the bounding box. + * @param delta The size delta per dimension (if positive, box is enlarged) + */ void Offset(const PointType & delta) { min -= delta; max += delta; } - /** Computes intersection between this and another bounding box - @param b The other bounding box - */ + /** + * @brief Computes intersection between this and another bounding box + * @param b The other bounding box + */ void Intersect( const Box2 & b ) { if(min.X() < b.min.X()) min.X() = b.min.X(); @@ -164,114 +165,118 @@ public: if(min.X()>max.X() || min.Y()>max.Y()) SetNull(); } - /** Translate the bounding box by a vector - @param p The translation vector - */ + /** + * @brief Translate the bounding box by a vector + * @param p The translation vector + */ void Translate( const PointType & p ) { min += p; max += p; } - /** Checks whether a 2D point p is inside the box - @param p The point 2D - @return True iff p inside - */ - bool IsIn( PointType const & p ) const + /** + * @brief Checks whether a 2D point p is inside the box + * @param p The point 2D + * @return True iff p inside + */ + bool IsIn( const PointType & p ) const { return ( min.X() <= p.X() && p.X() <= max.X() && - min.Y() <= p.Y() && p.Y() <= max.Y() - ); + min.Y() <= p.Y() && p.Y() <= max.Y()); } - /** Checks whether a 2D point p is inside the box, closed at min but open at max - @param p The point in 2D - @return True iff p inside - */ - bool IsInEx( PointType const & p ) const + /** + * @brief Checks whether a 2D point p is inside the box, closed at min but open at max + * @param p The point in 2D + * @return True iff p inside + */ + bool IsInEx( const PointType & p ) const { - return ( + return ( min.X() <= p.X() && p.X() < max.X() && - min.Y() <= p.Y() && p.Y() < max.Y() - ); + min.Y() <= p.Y() && p.Y() < max.Y()); } - /** Check bbox collision. - Note: just adjiacent bbox won't collide - @param b A bounding box - @return True iff collision - */ - bool Collide( Box2 const &b ) + /** + * @brief Check bbox collision. + * Note: just adjiacent bbox won't collide + * @param b A bounding box + * @return True iff collision + */ + bool Collide( const Box2 &b ) const { Box2 bb=*this; bb.Intersect(b); return bb.IsValid(); } - /** Check if empty. - @return True iff empty - */ + /** + * Check if empty. + * @return True iff empty + */ inline bool IsNull() const { return min.X()>max.X() || min.Y()>max.Y(); } - /** Check consistency. - @return True iff consistent - */ + /** + * Check consistency. + * @return True iff consistent + */ inline bool IsValid() const { return min.X() @@ -300,36 +305,36 @@ ScalarType DistancePoint2Box2(const Point2 &test, if ((test.X()<=bbox.min.X())&&(test.Y()<=bbox.min.Y())) return ((test-bbox.min).Norm()); else - if ((test.X()>=bbox.min.X())&& - (test.X()<=bbox.max.X())&& - (test.Y()<=bbox.min.Y())) - return (bbox.min.Y()-test.Y()); - else - if ((test.X()>=bbox.max.X())&& - (test.Y()<=bbox.min.Y())) - return ((test-vcg::Point2(bbox.max.X(),bbox.min.Y())).Norm()); - else - if ((test.Y()>=bbox.min.Y())&& - (test.Y()<=bbox.max.Y())&& - (test.X()>=bbox.max.X())) - return (test.X()-bbox.max.X()); - else - if ((test.X()>=bbox.max.X())&&(test.Y()>=bbox.max.Y())) - return ((test-bbox.max).Norm()); - else - if ((test.X()>=bbox.min.X())&& - (test.X()<=bbox.max.X())&& - (test.Y()>=bbox.max.Y())) - return (test.Y()-bbox.max.Y()); - else - if ((test.X()<=bbox.min.X())&& - (test.Y()>=bbox.max.Y())) - return ((test-vcg::Point2(bbox.min.X(),bbox.max.Y())).Norm()); - else - if ((test.X()<=bbox.min.X())&& - (test.Y()<=bbox.max.Y())&& - (test.Y()>=bbox.min.Y())) - return (bbox.min.X()-test.X()); + if ((test.X()>=bbox.min.X())&& + (test.X()<=bbox.max.X())&& + (test.Y()<=bbox.min.Y())) + return (bbox.min.Y()-test.Y()); + else + if ((test.X()>=bbox.max.X())&& + (test.Y()<=bbox.min.Y())) + return ((test-vcg::Point2(bbox.max.X(),bbox.min.Y())).Norm()); + else + if ((test.Y()>=bbox.min.Y())&& + (test.Y()<=bbox.max.Y())&& + (test.X()>=bbox.max.X())) + return (test.X()-bbox.max.X()); + else + if ((test.X()>=bbox.max.X())&&(test.Y()>=bbox.max.Y())) + return ((test-bbox.max).Norm()); + else + if ((test.X()>=bbox.min.X())&& + (test.X()<=bbox.max.X())&& + (test.Y()>=bbox.max.Y())) + return (test.Y()-bbox.max.Y()); + else + if ((test.X()<=bbox.min.X())&& + (test.Y()>=bbox.max.Y())) + return ((test-vcg::Point2(bbox.min.X(),bbox.max.Y())).Norm()); + else + if ((test.X()<=bbox.min.X())&& + (test.Y()<=bbox.max.Y())&& + (test.Y()>=bbox.min.Y())) + return (bbox.min.X()-test.X()); } else { @@ -372,13 +377,13 @@ Point2 ClosestPoint2Box2(const Point2 &test, return closest; } - /// Specificazione di box of short +/// Specificazione di box of short typedef Box2 Box2s; - /// Specificazione di box of int +/// Specificazione di box of int typedef Box2 Box2i; - /// Specificazione di box of float +/// Specificazione di box of float typedef Box2 Box2f; - /// Specificazione di box of double +/// Specificazione di box of double typedef Box2 Box2d; /*@}*/ diff --git a/vcg/space/box3.h b/vcg/space/box3.h index 4fd6de3a..862767db 100644 --- a/vcg/space/box3.h +++ b/vcg/space/box3.h @@ -46,29 +46,27 @@ public: typedef BoxScalarType ScalarType; /// min coordinate point - Point3 min; + Point3 min; /// max coordinate point Point3 max; /// The bounding box constructor inline Box3() { this->SetNull(); } - /// Copy constructor - //inline Box3( const Box3 & b ) { min=b.min; max=b.max; } /// Min Max constructor inline Box3( const Point3 & mi, const Point3 & ma ) { min = mi; max = ma; } /// Point Radius Constructor - inline Box3(const Point3 & center, const BoxScalarType & radius) { - min = center-Point3(radius,radius,radius); - max = center+Point3(radius,radius,radius); - } + inline Box3(const Point3 & center, const BoxScalarType & radius) { + min = center-Point3(radius,radius,radius); + max = center+Point3(radius,radius,radius); + } /// The bounding box distructor inline ~Box3() { } /// Operator to compare two bounding box - inline bool operator == ( Box3 const & p ) const + inline bool operator == ( const Box3 & p ) const { return min==p.min && max==p.max; } /// Operator to dispare two bounding box - inline bool operator != ( Box3 const & p ) const + inline bool operator != ( const Box3 & p ) const { return min!=p.min || max!=p.max; } @@ -103,7 +101,7 @@ public: /** Modify the current bbox to contain also the passed box. * Adding a null bounding box does nothing */ - void Add( Box3 const & b ) + void Add( const Box3 & b ) { if(b.IsNull()) return; // Adding a null bbox should do nothing if(IsNull()) *this=b; @@ -137,20 +135,20 @@ public: /** Modify the current bbox to contain also the passed sphere */ -void Add( const Point3 & p, const BoxScalarType radius ) -{ - if(IsNull()) Set(p); - else + void Add( const Point3 & p, const BoxScalarType radius ) { - min.X() = std::min(min.X(),p.X()-radius); - min.Y() = std::min(min.Y(),p.Y()-radius); - min.Z() = std::min(min.Z(),p.Z()-radius); + if(IsNull()) Set(p); + else + { + min.X() = std::min(min.X(),p.X()-radius); + min.Y() = std::min(min.Y(),p.Y()-radius); + min.Z() = std::min(min.Z(),p.Z()-radius); - max.X() = std::max(max.X(),p.X()+radius); - max.Y() = std::max(max.Y(),p.Y()+radius); - max.Z() = std::max(max.Z(),p.Z()+radius); + max.X() = std::max(max.X(),p.X()+radius); + max.Y() = std::max(max.Y(),p.Y()+radius); + max.Z() = std::max(max.Z(),p.Z()+radius); + } } -} /** Modify the current bbox to contain also the box b transformed according to the matrix m */ void Add( const Matrix44 &m, const Box3 & b ) @@ -193,7 +191,7 @@ void Add( const Point3 & p, const BoxScalarType radius ) } /** true if the point belong to the closed box */ - bool IsIn( Point3 const & p ) const + bool IsIn( const Point3 & p ) const { return ( min.X() <= p.X() && p.X() <= max.X() && @@ -204,7 +202,7 @@ void Add( const Point3 & p, const BoxScalarType radius ) /** true if the point belong to the open box (open on the max side) * e.g. if p in [min,max) */ - bool IsInEx( Point3 const & p ) const + bool IsInEx( const Point3 & p ) const { return ( min.X() <= p.X() && p.X() < max.X() && @@ -225,7 +223,7 @@ void Add( const Point3 & p, const BoxScalarType radius ) return bb.IsValid(); } */ - bool Collide(Box3 const &b) const + bool Collide( const Box3 &b) const { return b.min.X()min.X() && b.min.Y()min.Y() && @@ -259,14 +257,14 @@ void Add( const Point3 & p, const BoxScalarType radius ) return (max-min); } /// Returns global coords of a local point expressed in [0..1]^3 - Point3 LocalToGlobal(Point3 const & p) const{ + Point3 LocalToGlobal(const Point3 & p) const{ return Point3( min[0] + p[0]*(max[0]-min[0]), min[1] + p[1]*(max[1]-min[1]), min[2] + p[2]*(max[2]-min[2])); } /// Returns local coords expressed in [0..1]^3 of a point in 3D - Point3 GlobalToLocal(Point3 const & p) const{ + Point3 GlobalToLocal(const Point3 & p) const{ return Point3( (p[0]-min[0])/(max[0]-min[0]), (p[1]-min[1])/(max[1]-min[1]), @@ -313,7 +311,7 @@ void Add( const Point3 & p, const BoxScalarType radius ) } /// gives the ith box vertex in order: (x,y,z),(X,y,z),(x,Y,z),(X,Y,z),(x,y,Z),(X,y,Z),(x,Y,Z),(X,Y,Z) - Point3 P(const int & i) const { + Point3 P(int i) const { return Point3( min[0]+ (i%2) * DimX(), min[1]+ ((i / 2)%2) * DimY(), diff --git a/vcg/space/deprecated_point3.h b/vcg/space/deprecated_point3.h index dd32ebfd..a5e75494 100644 --- a/vcg/space/deprecated_point3.h +++ b/vcg/space/deprecated_point3.h @@ -253,7 +253,7 @@ public: assert(i>=0 && i<3); return _v[i]; } - inline const P3ScalarType &X() const { return _v[0]; } + inline const P3ScalarType &X() const { return _v[0]; } inline const P3ScalarType &Y() const { return _v[1]; } inline const P3ScalarType &Z() const { return _v[2]; } inline P3ScalarType &X() { return _v[0]; } diff --git a/vcg/space/deprecated_point4.h b/vcg/space/deprecated_point4.h index a932f43d..39b5d135 100644 --- a/vcg/space/deprecated_point4.h +++ b/vcg/space/deprecated_point4.h @@ -97,10 +97,8 @@ public: { _v[0] = p[0]; _v[1]= p[1]; _v[2] = p[2]; _v[3]= p[3]; } - inline Point4 ( const Point4 & p ) - { - _v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2]; _v[3]= p._v[3]; - } + inline Point4 ( const Point4 & p ) = default; + inline void SetZero() { _v[0] = _v[1] = _v[2] = _v[3]= 0; diff --git a/vcg/space/line2.h b/vcg/space/line2.h index 2abeb18d..68314006 100644 --- a/vcg/space/line2.h +++ b/vcg/space/line2.h @@ -167,7 +167,7 @@ public: Line2 (const Line2 &r) { Import(r); }; /// assignment - inline LineType & operator = ( Line2 const &r) + inline LineType & operator = ( const Line2 &r) { Import(r); return *this; }; //@} From 608e15562b9f3716cb238741562ac623bc75a529 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Mon, 29 Mar 2021 10:08:41 +0200 Subject: [PATCH 45/47] =?UTF-8?q?improved=20=CF=80=20precision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcg/math/base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcg/math/base.h b/vcg/math/base.h index a2ca912a..e721194c 100644 --- a/vcg/math/base.h +++ b/vcg/math/base.h @@ -165,7 +165,7 @@ namespace math { /* Some files do not define M_PI... */ #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846264338327950288 #endif #ifndef SQRT_TWO From 7973ee6b48a7e59a7de6334d87cdcbfb98d71273 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Mon, 29 Mar 2021 11:55:47 +0200 Subject: [PATCH 46/47] fixed weird constness --- vcg/simplex/face/pos.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcg/simplex/face/pos.h b/vcg/simplex/face/pos.h index 436226d1..b745e95f 100644 --- a/vcg/simplex/face/pos.h +++ b/vcg/simplex/face/pos.h @@ -68,19 +68,19 @@ public: /// Index of the edge int z; /// Pointer to the vertex - VertexType *v; + VertexType * v; /// Default constructor Pos() : f(0), z(-1), v(0) {} /// Constructor which associates the half-edge element with a face, its edge and its vertex /// \note that the input must be consistent, e.g. it should hold that \c vp==fp->V0(zp) or \c vp==fp->V1(zp) - Pos(FaceType * const fp, int const zp, VertexType * const vp) + Pos(FaceType * fp, int zp, VertexType * vp) { f=fp; z=zp; v=vp; assert((vp==fp->V0(zp))||(vp==fp->V1(zp))); } - Pos(FaceType * const fp, int const zp){f=fp; z=zp; v=f->V(zp);} - Pos(FaceType * const fp, VertexType * const vp) + Pos(FaceType * fp, int zp){f=fp; z=zp; v=f->V(zp);} + Pos(FaceType * fp, VertexType * vp) { f = fp; v = vp; From 895f8b0d03c6b964b33734ac20952353f6c78232 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Mon, 29 Mar 2021 17:29:44 +0200 Subject: [PATCH 47/47] fixed bug in const copy of mesh attributes --- vcg/complex/append.h | 120 ++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/vcg/complex/append.h b/vcg/complex/append.h index 6be6826e..63c44684 100644 --- a/vcg/complex/append.h +++ b/vcg/complex/append.h @@ -669,64 +669,76 @@ static void MeshAppendConst( // If the left mesh has attributes that are not in the right mesh, their values for the elements // of the right mesh will be uninitialized - unsigned int id_r; - typename std::set< PointerToAttribute >::iterator al, ar; + unsigned int id_r; + typename std::set< PointerToAttribute >::iterator al, ar; - // per vertex attributes - for(al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al) - if(!(*al)._name.empty()){ - ar = mr.vert_attr.find(*al); - if(ar!= mr.vert_attr.end()){ - id_r = 0; - for (auto v: mr.vert){ - if( !v.IsD() && (!selected || v.IsS())) - (*al)._handle->CopyValue(remap.vert[Index(mr,v)], id_r, (*ar)._handle); - ++id_r; - } - } - } + // per vertex attributes + for (al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al) + if(!(*al)._name.empty()) + { + ar = mr.vert_attr.find(*al); + if (ar != mr.vert_attr.end()) + { + id_r = 0; + for (const auto & v : mr.vert) + { + if( !v.IsD() && (!selected || v.IsS())) + (*al)._handle->CopyValue(remap.vert[Index(mr,v)], id_r, (*ar)._handle); + ++id_r; + } + } + } - // per edge attributes - for(al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al) - if(!(*al)._name.empty()){ - ar = mr.edge_attr.find(*al); - if(ar!= mr.edge_attr.end()){ - id_r = 0; - for (auto e: mr.edge){ - if( !e.IsD() && (!selected || e.IsS())) - (*al)._handle->CopyValue(remap.edge[Index(mr,e)], id_r, (*ar)._handle); - ++id_r; - } - } - } + // per edge attributes + for (al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al) + if (!(*al)._name.empty()) + { + ar = mr.edge_attr.find(*al); + if (ar!= mr.edge_attr.end()) + { + id_r = 0; + for (const auto & e : mr.edge) + { + if( !e.IsD() && (!selected || e.IsS())) + (*al)._handle->CopyValue(remap.edge[Index(mr,e)], id_r, (*ar)._handle); + ++id_r; + } + } + } - // per face attributes - for(al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al) - if(!(*al)._name.empty()){ - ar = mr.face_attr.find(*al); - if(ar!= mr.face_attr.end()){ - id_r = 0; - for (auto f: mr.face) { - if( !f.IsD() && (!selected || f.IsS())) - (*al)._handle->CopyValue(remap.face[Index(mr,f)], id_r, (*ar)._handle); - ++id_r; - } - } - } + // per face attributes + for (al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al) + if (!(*al)._name.empty()) + { + ar = mr.face_attr.find(*al); + if (ar!= mr.face_attr.end()) + { + id_r = 0; + for (const auto & f : mr.face) + { + if( !f.IsD() && (!selected || f.IsS())) + (*al)._handle->CopyValue(remap.face[Index(mr,f)], id_r, (*ar)._handle); + ++id_r; + } + } + } - // per tetra attributes - for(al = ml.tetra_attr.begin(); al != ml.tetra_attr.end(); ++al) - if(!(*al)._name.empty()){ - ar = mr.tetra_attr.find(*al); - if(ar!= mr.tetra_attr.end()){ - id_r = 0; - for (auto t: mr.tetra) { - if( !t.IsD() && (!selected || t.IsS())) - (*al)._handle->CopyValue(remap.tetra[Index(mr, t)], id_r, (*ar)._handle); - ++id_r; - } - } - } + // per tetra attributes + for (al = ml.tetra_attr.begin(); al != ml.tetra_attr.end(); ++al) + if (!(*al)._name.empty()) + { + ar = mr.tetra_attr.find(*al); + if (ar!= mr.tetra_attr.end()) + { + id_r = 0; + for (const auto & t: mr.tetra) + { + if( !t.IsD() && (!selected || t.IsS())) + (*al)._handle->CopyValue(remap.tetra[Index(mr, t)], id_r, (*ar)._handle); + ++id_r; + } + } + } // per mesh attributes // if both ml and mr have an attribute with the same name, no action is done