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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 22083582..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) @@ -272,6 +275,9 @@ set(VCG_HEADERS vcg/connectors/halfedge_pos.h vcg/connectors/hedge.h vcg/connectors/hedge_component.h + + #wrap + wrap/callback.h ) set(SOURCES @@ -293,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/README.md b/README.md index 63209851..d98ee6ec 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) +![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) 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) . 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/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/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/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/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/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/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/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/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/allocate.h b/vcg/complex/allocate.h index fa56dd27..b4b337d6 100644 --- a/vcg/complex/allocate.h +++ b/vcg/complex/allocate.h @@ -23,9 +23,12 @@ #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 + +#include "used_types.h" namespace vcg { namespace tri { 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 { diff --git a/vcg/complex/base.h b/vcg/complex/base.h index adb0316e..88de7028 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_COMPLEX_BASE #define __VCG_COMPLEX_BASE +#include +#include + +#include + +#include "used_types.h" + namespace vcg { class PointerToAttribute @@ -596,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/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/complex/foreach.h b/vcg/complex/foreach.h index a062e41c..c2fa2cef 100644 --- a/vcg/complex/foreach.h +++ b/vcg/complex/foreach.h @@ -24,9 +24,7 @@ #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 { namespace tri { 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/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/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/simplex/edge/base.h b/vcg/simplex/edge/base.h index 472a635b..8f9a71b7 100644 --- a/vcg/simplex/edge/base.h +++ b/vcg/simplex/edge/base.h @@ -20,11 +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_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..4e922ae3 100644 --- a/vcg/simplex/edge/component.h +++ b/vcg/simplex/edge/component.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_EDGE_PLUS_COMPONENT #define __VCG_EDGE_PLUS_COMPONENT +#include +#include +#include + +#include + + namespace vcg { namespace edge { 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..b942c5a8 100644 --- a/vcg/simplex/edge/topology.h +++ b/vcg/simplex/edge/topology.h @@ -24,6 +24,12 @@ #ifndef _VCG_EDGE_TOPOLOGY #define _VCG_EDGE_TOPOLOGY +#include +#include + +#include "pos.h" +#include "component.h" + namespace vcg { namespace edge { /** \addtogroup edge */ diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index e96e541d..967c7dbc 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.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_FACE_PLUS #define __VCG_FACE_PLUS +#include +#include + +#include +#include + +#include "component.h" + namespace vcg { /*------------------------------------------------------------------*/ @@ -163,16 +169,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 { @@ -36,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; } @@ -196,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(); } @@ -208,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/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 3f676006..c0e0c0db 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -22,9 +22,12 @@ ****************************************************************************/ #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 + +#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/face/pos.h b/vcg/simplex/face/pos.h index bfc0103f..436226d1 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 { @@ -217,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); @@ -234,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/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index bd14e018..7caa961a 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -24,7 +24,9 @@ #ifndef _VCG_FACE_TOPOLOGY #define _VCG_FACE_TOPOLOGY -#include +#include "pos.h" + +#include namespace vcg { namespace face { diff --git a/vcg/simplex/tetrahedron/base.h b/vcg/simplex/tetrahedron/base.h index b5e9bc71..364cd857 100644 --- a/vcg/simplex/tetrahedron/base.h +++ b/vcg/simplex/tetrahedron/base.h @@ -30,16 +30,17 @@ 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 -//#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/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 */ diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 29ec6fb5..b12b0648 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -20,12 +20,15 @@ * 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 +#include +#include + +#include "component.h" + namespace vcg { diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index f4cab3c9..dab25640 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -20,12 +20,16 @@ * 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 +#include +#include + +#include +#include + namespace vcg { namespace vertex { /** \addtogroup VertexComponentGroup 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 35572cbc..c063308c 100644 --- a/vcg/simplex/vertex/component_ocf.h +++ b/vcg/simplex/vertex/component_ocf.h @@ -25,14 +25,16 @@ 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 -#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 { diff --git a/vcg/space/box.h b/vcg/space/box.h index ad4bdf97..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 @@ -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..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(); } - /** Traslate the bounding box by a vectore - @param p The transolation 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 emptry. - @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 2ef87d13..68314006 100644 --- a/vcg/space/line2.h +++ b/vcg/space/line2.h @@ -108,7 +108,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 line. inline PointType P( const ScalarType t ) const @@ -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; }; //@} diff --git a/vcg/space/line3.h b/vcg/space/line3.h index f16a411e..fc5cad6c 100644 --- a/vcg/space/line3.h +++ b/vcg/space/line3.h @@ -124,7 +124,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 line. inline PointType P( const ScalarType t ) const diff --git a/vcg/space/rasterized_outline2_packer.h b/vcg/space/rasterized_outline2_packer.h index ace38df7..29578e15 100644 --- a/vcg/space/rasterized_outline2_packer.h +++ b/vcg/space/rasterized_outline2_packer.h @@ -305,7 +305,7 @@ public: std::vector& 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/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()); } 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/import_stl.h b/wrap/io_trimesh/import_stl.h index 16517399..8225d13a 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; } 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 +};