codespell - see #92

This commit is contained in:
alemuntoni 2021-03-25 15:19:14 +01:00
parent c275c8fa87
commit ad75e35593
25 changed files with 221 additions and 221 deletions

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -64,10 +64,10 @@ class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFac
class GLArea:public QGLWidget class GLArea:public QGLWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GLArea (QWidget * parent = 0); GLArea (QWidget * parent = 0);
/// we choosed a subset of the avaible drawing modes /// we chose a subset of the available drawing modes
enum DrawMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,HIDDEN,FLAT}; enum DrawMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,HIDDEN,FLAT};
public slots: public slots:
/// widget-based user interaction slots /// widget-based user interaction slots
@ -89,7 +89,7 @@ protected:
void mousePressEvent(QMouseEvent*e); void mousePressEvent(QMouseEvent*e);
void mouseMoveEvent(QMouseEvent*e); void mouseMoveEvent(QMouseEvent*e);
void mouseReleaseEvent(QMouseEvent*e); void mouseReleaseEvent(QMouseEvent*e);
void wheelEvent(QWheelEvent*e); void wheelEvent(QWheelEvent*e);
private: private:
/// the active mesh instance /// the active mesh instance
CMesh mesh; CMesh mesh;

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -65,13 +65,13 @@ public:
class GLArea:public QGLWidget class GLArea:public QGLWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GLArea (SharedDataOpenGLContext* sharedcontext,MainWindow* parent); GLArea (SharedDataOpenGLContext* sharedcontext,MainWindow* parent);
~GLArea(); ~GLArea();
void resetTrackBall(); void resetTrackBall();
//unsigned int getId() const {return areaid;} //unsigned int getId() const {return areaid;}
/// we choosed a subset of the avaible drawing modes /// we chose a subset of the available drawing modes
signals: signals:
/// signal for setting the statusbar message /// signal for setting the statusbar message
@ -88,7 +88,7 @@ protected:
void mousePressEvent(QMouseEvent*e); void mousePressEvent(QMouseEvent*e);
void mouseMoveEvent(QMouseEvent*e); void mouseMoveEvent(QMouseEvent*e);
void mouseReleaseEvent(QMouseEvent*e); void mouseReleaseEvent(QMouseEvent*e);
void wheelEvent(QWheelEvent*e); void wheelEvent(QWheelEvent*e);
private: private:
MainWindow* parwin; MainWindow* parwin;

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -24,7 +24,7 @@
/** /**
* Minimal trimesh viewer made with AntTweakBar and freglut * Minimal trimesh viewer made with AntTweakBar and freglut
* *
* This sample shows how to use togheter: * This sample shows how to use togheter:
* - the trimesh loading and initialization * - the trimesh loading and initialization
* - basic usage of the default manipulators (the "Trackball") * - basic usage of the default manipulators (the "Trackball")
*/ */
@ -75,7 +75,7 @@ vcg::Trackball track;
/// window size /// window size
int width,height; int width,height;
/// we choosed a subset of the avaible drawing modes /// we chose a subset of the available drawing modes
enum DrawMode{SMOOTH=0,PERPOINTS,WIRE,FLATWIRE,HIDDEN,FLAT}; enum DrawMode{SMOOTH=0,PERPOINTS,WIRE,FLATWIRE,HIDDEN,FLAT};
/// the current drawmode /// the current drawmode
@ -101,7 +101,7 @@ static vcg::Trackball::Button GLUT2VCG (int glut_button, int )
return vcg::Trackball::Button (vcgbt); return vcg::Trackball::Button (vcgbt);
} }
@ -124,29 +124,29 @@ void Display(){
glPushMatrix(); glPushMatrix();
float d=1.0f/mesh.bbox.Diag(); float d=1.0f/mesh.bbox.Diag();
vcg::glScale(d); vcg::glScale(d);
glTranslate(-glWrap.m->bbox.Center()); glTranslate(-glWrap.m->bbox.Center());
// the trimesh drawing calls // the trimesh drawing calls
switch(drawmode) switch(drawmode)
{ {
case SMOOTH: case SMOOTH:
glWrap.Draw<vcg::GLW::DMSmooth, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMSmooth, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
case PERPOINTS: case PERPOINTS:
glWrap.Draw<vcg::GLW::DMPoints, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMPoints, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
case WIRE: case WIRE:
glWrap.Draw<vcg::GLW::DMWire, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
case FLATWIRE: case FLATWIRE:
glWrap.Draw<vcg::GLW::DMFlatWire, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMFlatWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
case HIDDEN: case HIDDEN:
glWrap.Draw<vcg::GLW::DMHidden, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMHidden, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
case FLAT: case FLAT:
glWrap.Draw<vcg::GLW::DMFlat, vcg::GLW::CMNone,vcg::GLW::TMNone> (); glWrap.Draw<vcg::GLW::DMFlat, vcg::GLW::CMNone,vcg::GLW::TMNone> ();
break; break;
default: default:
break; break;
} }
@ -185,7 +185,7 @@ void initMesh()
} }
void TW_CALL loadMesh(void *) void TW_CALL loadMesh(void *)
{ {
if(filename==0) return; if(filename==0) return;
int err=vcg::tri::io::ImporterPLY<CMesh>::Open(mesh,(char*)filename); int err=vcg::tri::io::ImporterPLY<CMesh>::Open(mesh,(char*)filename);
if(err!=0){ if(err!=0){
@ -276,7 +276,7 @@ int main(int argc, char *argv[])
// (note that AntTweakBar could also be intialized after GLUT, no matter) // (note that AntTweakBar could also be intialized after GLUT, no matter)
if( !TwInit(TW_OPENGL, NULL) ) if( !TwInit(TW_OPENGL, NULL) )
{ {
// A fatal error occured // A fatal error occured
fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError()); fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
return 1; return 1;
} }
@ -311,12 +311,12 @@ int main(int argc, char *argv[])
glutKeyboardFunc(keyPressEvent); glutKeyboardFunc(keyPressEvent);
glutKeyboardUpFunc(keyReleaseEvent); glutKeyboardUpFunc(keyReleaseEvent);
glutMouseWheelFunc(wheelEvent); glutMouseWheelFunc(wheelEvent);
bar = TwNewBar("TweakBar"); bar = TwNewBar("TweakBar");
TwCopyCDStringToClientFunc (CopyCDStringToClient); TwCopyCDStringToClientFunc (CopyCDStringToClient);
TwAddVarRW(bar,"Input",TW_TYPE_CDSTRING,&filename," label='Filepath' group=SetMesh help=` Name of the file to load` "); 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,"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.` "); TwAddButton(bar,"Use tetrahedron",loadTetrahedron,0, " label='Make Tetrahedron' group=SetMesh help=`use tetrahedron.` ");

View File

@ -112,7 +112,7 @@ template<class TriMeshType>
// ALNParser::ParseALN(rmaps, alnName); // ALNParser::ParseALN(rmaps, alnName);
// for(size_t i=0; i<rmaps.size(); i++) // for(size_t i=0; i<rmaps.size(); i++)
// AddSingleMesh(rmaps[i].filename.c_str(), rmaps[i].trasformation, rmaps[i].quality); // AddSingleMesh(rmaps[i].filename.c_str(), rmaps[i].transformation, rmaps[i].quality);
return true; return true;
} }

View File

@ -1529,7 +1529,7 @@ public:
std::vector< VertexPointer > minVertVec; std::vector< VertexPointer > minVertVec;
std::vector< VertexPointer > maxVertVec; std::vector< VertexPointer > maxVertVec;
// The set of directions to be choosen // The set of directions to be chosen
std::vector< CoordType > dirVec; std::vector< CoordType > dirVec;
dirVec.push_back(CoordType(1,0,0)); dirVec.push_back(CoordType(1,0,0));
dirVec.push_back(CoordType(0,1,0)); dirVec.push_back(CoordType(0,1,0));

View File

@ -1005,7 +1005,7 @@ static void AllEdge(MeshType & m, VertexSampler &ps)
// Regular Uniform Edge sampling // Regular Uniform Edge sampling
// Each edge is subdivided in a number of pieces proprtional to its length // 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) static void EdgeUniform(MeshType & m, VertexSampler &ps,int sampleNum, bool sampleFauxEdge=true)
{ {

View File

@ -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 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. If RefineSelected is true only selected faces are taken into account for being splitted.

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -45,13 +45,13 @@ namespace tri
/* Base class for all Texture Optimizers*/ /* Base class for all Texture Optimizers*/
template<class MESH_TYPE> template<class MESH_TYPE>
class TextureOptimizer{ class TextureOptimizer{
protected: protected:
MESH_TYPE &m; MESH_TYPE &m;
SimpleTempData<typename MESH_TYPE::VertContainer, int > isFixed; SimpleTempData<typename MESH_TYPE::VertContainer, int > isFixed;
public: public:
/* Tpyes */ /* Tpyes */
typedef MESH_TYPE MeshType; typedef MESH_TYPE MeshType;
typedef typename MESH_TYPE::VertexIterator VertexIterator; typedef typename MESH_TYPE::VertexIterator VertexIterator;
@ -59,26 +59,26 @@ public:
typedef typename MESH_TYPE::VertexType VertexType; typedef typename MESH_TYPE::VertexType VertexType;
typedef typename MESH_TYPE::FaceType FaceType; typedef typename MESH_TYPE::FaceType FaceType;
typedef typename MESH_TYPE::ScalarType ScalarType; typedef typename MESH_TYPE::ScalarType ScalarType;
/* Access functions */ /* Access functions */
const MeshType & Mesh() const {return m;} const MeshType & Mesh() const {return m;}
MeshType & Mesh() {return m;} MeshType & Mesh() {return m;}
/* Constructior */ /* Constructior */
TextureOptimizer(MeshType &_m):m(_m),isFixed(_m.vert){ TextureOptimizer(MeshType &_m):m(_m),isFixed(_m.vert){
assert(m.HasPerVertexTexture()); assert(m.HasPerVertexTexture());
} }
// initializes on current geometry // initializes on current geometry
virtual void TargetCurrentGeometry()=0; virtual void TargetCurrentGeometry()=0;
// performs an interation. Returns largest movement. // performs an iteration. Returns largest movement.
virtual ScalarType Iterate()=0; virtual ScalarType Iterate()=0;
// performs an iteration (faster, but it does not tell how close it is to stopping) // performs an iteration (faster, but it does not tell how close it is to stopping)
virtual void IterateBlind()=0; virtual void IterateBlind()=0;
// performs <steps> iteration // performs <steps> iteration
virtual ScalarType IterateN(int step){ virtual ScalarType IterateN(int step){
for (int i=0; i<step-1; i++) { for (int i=0; i<step-1; i++) {
@ -86,7 +86,7 @@ public:
} }
if (step>1) return this->Iterate(); else return 0; if (step>1) return this->Iterate(); else return 0;
} }
// performs iterations until convergence. // performs iterations until convergence.
bool IterateUntilConvergence(ScalarType threshold=0.0001, int maxite=5000){ bool IterateUntilConvergence(ScalarType threshold=0.0001, int maxite=5000){
int i; int i;
@ -95,34 +95,34 @@ public:
} }
return true; return true;
} }
// desctuctor: free temporary field // desctuctor: free temporary field
~TextureOptimizer(){ ~TextureOptimizer(){
isFixed.Stop(); isFixed.Stop();
}; };
// set the current border as fixed (forced to stay in position during text optimization) // set the current border as fixed (forced to stay in position during text optimization)
void SetBorderAsFixed(){ void SetBorderAsFixed(){
isFixed.Start(); isFixed.Start();
for (VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { 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) // everything moves, no vertex must fixed during texture optimization)
void SetNothingAsFixed(){ void SetNothingAsFixed(){
isFixed.Start(); isFixed.Start();
for (VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { for (VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) {
isFixed[v]=0; isFixed[v]=0;
} }
} }
// fix a given vertex // fix a given vertex
void FixVertex(const VertexType *v, bool fix=true){ void FixVertex(const VertexType *v, bool fix=true){
isFixed[v]=(fix)?1:0; isFixed[v]=(fix)?1:0;
} }
}; };
@ -130,12 +130,12 @@ public:
/* /*
AREA PRESERVING TEXTURE OPTIMIZATION 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." "An adaptable surface parameterization method."
Proc. of the 12th International Meshing oundtable, 201213 [2003]. Proc. of the 12th International Meshing oundtable, 201-213 [2003].
Features: Features:
:) - Balances angle and area distortions (best results!). :) - Balances angle and area distortions (best results!).
:) - Can choose how to balance area and angle preservation (see SetTheta) :) - Can choose how to balance area and angle preservation (see SetTheta)
theta=0 -> pure conformal (use MIPS instead!) theta=0 -> pure conformal (use MIPS instead!)
@ -144,12 +144,12 @@ Features:
:( - Slowest method. :( - Slowest method.
:( - Requires a fixed boundary, else expands forever in texture space (unless theta=0). :( - Requires a fixed boundary, else expands forever in texture space (unless theta=0).
:( - Diverges in presence of flipped faces (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. Speed too large => when close, bounces back and forth around minimum, w/o getting any closer.
Lower speed => longer convercence times Lower speed => longer convercence times
*/ */
template<class MESH_TYPE> template<class MESH_TYPE>
class AreaPreservingTextureOptimizer:public TextureOptimizer<MESH_TYPE>{ class AreaPreservingTextureOptimizer:public TextureOptimizer<MESH_TYPE>{
public: public:
/* Types */ /* Types */
@ -159,34 +159,34 @@ public:
typedef typename MESH_TYPE::VertexType VertexType; typedef typename MESH_TYPE::VertexType VertexType;
typedef typename MESH_TYPE::FaceType FaceType; typedef typename MESH_TYPE::FaceType FaceType;
typedef typename MESH_TYPE::ScalarType ScalarType; typedef typename MESH_TYPE::ScalarType ScalarType;
private: private:
typedef TextureOptimizer<MESH_TYPE> Super; // superclass (commodity) typedef TextureOptimizer<MESH_TYPE> Super; // superclass (commodity)
// extra data per face: [0..3] -> cotangents. [4] -> area*2 // extra data per face: [0..3] -> cotangents. [4] -> area*2
SimpleTempData<typename MESH_TYPE::FaceContainer, Point4<ScalarType> > data; SimpleTempData<typename MESH_TYPE::FaceContainer, Point4<ScalarType> > data;
SimpleTempData<typename MESH_TYPE::VertContainer, Point2<ScalarType> > sum; SimpleTempData<typename MESH_TYPE::VertContainer, Point2<ScalarType> > sum;
ScalarType totArea; ScalarType totArea;
ScalarType speed; ScalarType speed;
int theta; int theta;
public: public:
// constructor and destructor // constructor and destructor
AreaPreservingTextureOptimizer(MeshType &_m):Super(_m),data(_m.face),sum(_m.vert){ AreaPreservingTextureOptimizer(MeshType &_m):Super(_m),data(_m.face),sum(_m.vert){
speed=0.001; speed=0.001;
theta=3; theta=3;
} }
~AreaPreservingTextureOptimizer(){ ~AreaPreservingTextureOptimizer(){
data.Stop(); data.Stop();
sum.Stop(); sum.Stop();
Super::isFixed.Stop(); Super::isFixed.Stop();
} }
void SetSpeed(ScalarType _speed){ void SetSpeed(ScalarType _speed){
speed=_speed; speed=_speed;
} }
@ -194,7 +194,7 @@ public:
ScalarType GetSpeed(){ ScalarType GetSpeed(){
return speed; return speed;
} }
// sets the parameter theta: // sets the parameter theta:
// good parameters are in 1..3 // good parameters are in 1..3
// 0 = converge to pure conformal, ignore area preservation // 0 = converge to pure conformal, ignore area preservation
@ -207,16 +207,16 @@ public:
int GetTheta(){ int GetTheta(){
return theta; return theta;
} }
void IterateBlind(){ void IterateBlind(){
/* todo: do as iterate, but without */ /* todo: do as iterate, but without */
Iterate(); Iterate();
} }
ScalarType Iterate(){ ScalarType Iterate(){
ScalarType max; // max displacement ScalarType max; // max displacement
#define v0 (f->V0(i)->T().P()) #define v0 (f->V0(i)->T().P())
#define v1 (f->V1(i)->T().P()) #define v1 (f->V1(i)->T().P())
#define v2 (f->V2(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++) { for (FaceIterator f=Super::m.face.begin(); f!=Super::m.face.end(); f++) {
int i=0; ScalarType area2 = ((v1-v0) ^ (v2-v0)); int i=0; ScalarType area2 = ((v1-v0) ^ (v2-v0));
for (i=0; i<3; i++){ for (i=0; i<3; i++){
ScalarType ScalarType
a = (v1-v0).Norm(), a = (v1-v0).Norm(),
b = ((v1-v0) * (v2-v0))/a, b = ((v1-v0) * (v2-v0))/a,
c = area2 / a, c = area2 / a,
m0= data[f][i] / area2, m0= data[f][i] / area2,
m1= data[f][(i+1)%3] / area2, m1= data[f][(i+1)%3] / area2,
m2= data[f][(i+2)%3] / area2, m2= data[f][(i+2)%3] / area2,
mx= (b-a)/area2, mx= (b-a)/area2,
my= c/area2, // 1.0/a my= c/area2, // 1.0/a
mA= data[f][3]/area2 * scale, mA= data[f][3]/area2 * scale,
@ -258,35 +258,35 @@ public:
/* linear weightings /* linear weightings
dx= (OMEGA) * (my * M2) + dx= (OMEGA) * (my * M2) +
(1-OMEGA) * ( px - 2.0*qx), (1-OMEGA) * ( px - 2.0*qx),
dy= (OMEGA) * (-mx * M2) + dy= (OMEGA) * (-mx * M2) +
(1-OMEGA) * ( py - 2.0*qy),*/ (1-OMEGA) * ( py - 2.0*qy),*/
// exponential weighting // exponential weighting
// 2d gradient // 2d gradient
dx=// M1 dx=// M1
//*M1 // ^ theta-1 //*M1 // ^ theta-1
pow(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 dy=// M1
//*M1 // ^ theta-1 //*M1 // ^ theta-1
pow(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, gy= dy/c,
gx= (dx - gy*b) / a; gx= (dx - gy*b) / a;
// 3d gradient // 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; speed=0.001;
for (VertexIterator v=Super::m.vert.begin(); v!=Super::m.vert.end(); v++) for (VertexIterator v=Super::m.vert.begin(); v!=Super::m.vert.end(); v++)
if ( !Super::isFixed[v] ) //if (!v->IsB()) if ( !Super::isFixed[v] ) //if (!v->IsB())
{ {
ScalarType n=sum[v].Norm(); ScalarType n=sum[v].Norm();
if ( n > 1 ) { sum[v]/=n; n=1.0;} if ( n > 1 ) { sum[v]/=n; n=1.0;}
@ -298,17 +298,17 @@ public:
} }
return max; return max;
#undef v0 #undef v0
#undef v1 #undef v1
#undef v2 #undef v2
//printf("rejected %d\n",rejected); //printf("rejected %d\n",rejected);
} }
void TargetCurrentGeometry(){ void TargetCurrentGeometry(){
Super::isFixed.Start(); Super::isFixed.Start();
data.Start(); data.Start();
sum.Start(); sum.Start();
totArea=0; totArea=0;
for (FaceIterator f=Super::m.face.begin(); f!=Super::m.face.end(); f++) { 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(); 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) // returns false if any fold is present (faster than MarkFolds)
template<class MESH_TYPE> template<class MESH_TYPE>
bool IsFoldFree(MESH_TYPE &m){ bool IsFoldFree(MESH_TYPE &m){
assert(m.HasPerVertexTexture()); assert(m.HasPerVertexTexture());
typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType;
typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType;
ScalarType lastsign=0; ScalarType lastsign=0;
for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ 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())); 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 // returns number of folded faces
template<class MESH_TYPE> template<class MESH_TYPE>
int MarkFolds(MESH_TYPE &m){ int MarkFolds(MESH_TYPE &m){
assert(m.HasPerVertexTexture()); assert(m.HasPerVertexTexture());
assert(m.HasPerFaceQuality()); assert(m.HasPerFaceQuality());
typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType;
typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType;
SimpleTempData<typename MESH_TYPE::FaceContainer, short> sign(m.face); SimpleTempData<typename MESH_TYPE::FaceContainer, short> sign(m.face);
sign.Start(0); sign.Start(0);
// first pass, determine predominant sign // first pass, determine predominant sign
int npos=0, nneg=0; int npos=0, nneg=0;
ScalarType lastsign=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; nneg++; }
if (fsign>0) { sign[f]=+1; npos++; } if (fsign>0) { sign[f]=+1; npos++; }
} }
// second pass, detect folded faces // second pass, detect folded faces
int res=0; int res=0;
short gsign= (nneg>npos)?-1:+1; short gsign= (nneg>npos)?-1:+1;
@ -382,28 +382,28 @@ int MarkFolds(MESH_TYPE &m){
f->Q()=0; f->Q()=0;
} else f->Q()=1; } else f->Q()=1;
} }
sign.Stop(); sign.Stop();
return res; return res;
} }
// Smooths texture coords. // 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) // e.g. these created when obtaining tecture coordinates after projections)
template<class MESH_TYPE> template<class MESH_TYPE>
void SmoothTextureCoords(MESH_TYPE &m){ void SmoothTextureCoords(MESH_TYPE &m){
assert(m.HasPerVertexTexture()); assert(m.HasPerVertexTexture());
typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType;
SimpleTempData<typename MESH_TYPE::VertContainer, int> div(m.vert); SimpleTempData<typename MESH_TYPE::VertContainer, int> div(m.vert);
SimpleTempData<typename MESH_TYPE::VertContainer, PointType > sum(m.vert); SimpleTempData<typename MESH_TYPE::VertContainer, PointType > sum(m.vert);
div.Start(); div.Start();
sum.Start(); sum.Start();
for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) {
sum[v].SetZero(); sum[v].SetZero();
div[v]=0; 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(); 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) { if (v->div>0) {
v->T().P() = sum[v]/div[v]; v->T().P() = sum[v]/div[v];
} }
} }
div.Stop(); div.Stop();
sum.Stop(); sum.Stop();

View File

@ -566,7 +566,7 @@ bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &
return false; return false;
if(math::Abs(M.Determinant())<1e-10) return false; // matrix should be at least invertible... 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); TranV=M.GetColumn3(3);
// Second Step Recover Scale and Shearing interleaved // Second Step Recover Scale and Shearing interleaved

View File

@ -207,7 +207,7 @@ public:
} }
/* multiply the current reference frame for the matrix passed /* 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<S> m44) void MultMatrix( vcg::Matrix44<S> m44)
{ {
@ -218,7 +218,7 @@ public:
} }
/* multiply the current reference frame for the similarity passed /* 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> & s){ MultMatrix(s.Matrix());} void MultSimilarity( const Similarity<S> & s){ MultMatrix(s.Matrix());}

View File

@ -107,7 +107,7 @@ public:
{ {
return _min!=p._min || _max!=p._max; 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 @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.5 box doubles (+50% in every direction)
if S < 0 box shrinks if S < 0 box shrinks
@ -133,12 +133,12 @@ public:
_min -= delta; _min -= delta;
_max += delta; _max += delta;
} }
/// Initializing the box /// Initializing the box
void Set( const PointType & p ) void Set( const PointType & p )
{ {
_min = _max = p; _min = _max = p;
} }
/// Set the box to a null value /// Set the box to a null value
void SetNull() void SetNull()
{ {
_min.X()= 1; _max.X()= -1; _min.X()= 1; _max.X()= -1;
@ -147,7 +147,7 @@ public:
} }
/** Add two boxex: /** Add two boxex:
Returns minimal box that contains both operands. Returns minimal box that contains both operands.
@param b The box to add @param b The box to add
*/ */
void Add( Box const & b ) 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 @param b The other operand
*/ */
void Intersect( const Box & b ) void Intersect( const Box & b )
@ -190,7 +190,7 @@ public:
if(_min.X()>_max.X() || _min.Y()>_max.Y() ) SetNull(); if(_min.X()>_max.X() || _min.Y()>_max.Y() ) SetNull();
else if (N>2) if (_min.Z()>_max.Z()) SetNull(); else if (N>2) if (_min.Z()>_max.Z()) SetNull();
} }
/** Traslalate the box. /** Translalate the box.
@param p: the translation vector @param p: the translation vector
*/ */
void Translate( const PointType & p ) void Translate( const PointType & p )
@ -198,7 +198,7 @@ public:
_min += p; _min += p;
_max += p; _max += p;
} }
/** Check wheter a point is inside box. /** Check whether a point is inside box.
@param p The point @param p The point
@returns True if inside, false otherwise @returns True if inside, false otherwise
*/ */
@ -214,7 +214,7 @@ public:
_min.Z() <= p.Z() && p.Z() <= _max.Z() _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 @param p The point 3D
@returns True if inside, false otherwise @returns True if inside, false otherwise
*/ */
@ -283,7 +283,7 @@ public:
(p[2]-_min[2])/(_max[2]-_min[2]) (p[2]-_min[2])/(_max[2]-_min[2])
); );
} }
/// Computes the Volume for the box. /// Computes the Volume for the box.
inline S Volume() const inline S Volume() const
{ {
if (N==2) return (_max.X()-_min.X())*(_max.Y()-_min.Y()); 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 /// imports the box

View File

@ -164,8 +164,8 @@ public:
if(min.X()>max.X() || min.Y()>max.Y()) SetNull(); if(min.X()>max.X() || min.Y()>max.Y()) SetNull();
} }
/** Traslate the bounding box by a vectore /** Translate the bounding box by a vector
@param p The transolation vector @param p The translation vector
*/ */
void Translate( const PointType & p ) void Translate( const PointType & p )
{ {
@ -205,7 +205,7 @@ public:
bb.Intersect(b); bb.Intersect(b);
return bb.IsValid(); return bb.IsValid();
} }
/** Check if emptry. /** Check if empty.
@return True iff empty @return True iff empty
*/ */
inline bool IsNull() const { return min.X()>max.X() || min.Y()>max.Y(); } 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()<max.X() && min.Y()<max.Y(); } inline bool IsValid() const { return min.X()<max.X() && min.Y()<max.Y(); }
/** Check if emptry. /** Check if empty.
@return True iff empty @return True iff empty
*/ */
inline bool IsEmpty() const { return min==max; } inline bool IsEmpty() const { return min==max; }

View File

@ -108,7 +108,7 @@ public:
{ if (NORM) return ScalarType((p-_ori).dot(_dir)); { if (NORM) return ScalarType((p-_ori).dot(_dir));
else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm()); 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;}; static bool IsNormalized() {return NORM;};
/// calculates the point of parameter t on the line. /// calculates the point of parameter t on the line.
inline PointType P( const ScalarType t ) const inline PointType P( const ScalarType t ) const

View File

@ -124,7 +124,7 @@ public:
{ if (NORM) return ScalarType((p-_ori).dot(_dir)); { if (NORM) return ScalarType((p-_ori).dot(_dir));
else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm()); 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;}; static bool IsNormalized() {return NORM;};
/// calculates the point of parameter t on the line. /// calculates the point of parameter t on the line.
inline PointType P( const ScalarType t ) const inline PointType P( const ScalarType t ) const

View File

@ -305,7 +305,7 @@ public:
std::vector<int>& leftHorizon() { return mLeftHorizon; } std::vector<int>& leftHorizon() { return mLeftHorizon; }
vcg::Point2i& size() { return mSize; } 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) { int getCostX(RasterizedOutline2& poly, Point2i pos, int rast_i) {
switch (params.costFunction) { switch (params.costFunction) {
case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndLeftHorizon(poly, pos, rast_i); case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndLeftHorizon(poly, pos, rast_i);
@ -315,7 +315,7 @@ public:
return 0; 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) { int getCostY(RasterizedOutline2& poly, Point2i pos, int rast_i) {
switch (params.costFunction) { switch (params.costFunction) {
case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndBottomHorizon(poly, pos, rast_i); case CostFuncEnum::MinWastedSpace: return emptyCellBetweenPolyAndBottomHorizon(poly, pos, rast_i);

View File

@ -109,7 +109,7 @@ public:
{ if (NORM) return ScalarType((p-_ori)*_dir); { if (NORM) return ScalarType((p-_ori)*_dir);
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm()); 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;}; static bool IsNormalized() {return NORM;};
/// calculates the point of parameter t on the ray. /// calculates the point of parameter t on the ray.
inline PointType P( const ScalarType t ) const inline PointType P( const ScalarType t ) const

View File

@ -115,7 +115,7 @@ public:
{ if (NORM) return ScalarType((p-_ori).dot(_dir)); { if (NORM) return ScalarType((p-_ori).dot(_dir));
else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm()); 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;}; static bool IsNormalized() {return NORM;};
/// calculates the point of parameter t on the ray. /// calculates the point of parameter t on the ray.
inline PointType P( const ScalarType t ) const inline PointType P( const ScalarType t ) const

View File

@ -68,16 +68,16 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw)
manipulator->center=position; manipulator->center=position;
manipulator->GetView(); manipulator->GetView();
manipulator->Apply(); manipulator->Apply();
MovableCoordinateFrame::Render(glw); MovableCoordinateFrame::Render(glw);
// got nothing to draw // got nothing to draw
if(!drawmoves && !drawrotations){ if(!drawmoves && !drawrotations){
glPopMatrix(); 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 rotating=(current_mode==rotx)||(current_mode==roty)||(current_mode==rotz);
bool moving=(current_mode==movx)||(current_mode==movy)||(current_mode==movz); 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); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH); glEnable(GL_POINT_SMOOTH);
QString message("this should never be seen"); QString message("this should never be seen");
char axis_name; char axis_name;
float verse; float verse;
if(current_mode==x_modifier){ if(current_mode==x_modifier){
glColor(xcolor); message = QString("move or rotate on X axis"); glColor(xcolor); message = QString("move or rotate on X axis");
} else if(current_mode==y_modifier){ } else if(current_mode==y_modifier){
glColor(ycolor); message = QString("move or rotate on Y axis"); glColor(ycolor); message = QString("move or rotate on Y axis");
} else if(current_mode==z_modifier){ } else if(current_mode==z_modifier){
glColor(zcolor); message = QString("move or rotate on Z axis"); glColor(zcolor); message = QString("move or rotate on Z axis");
} else } else
if(rotating && drawrotations){ // draw a rotation if(rotating && drawrotations){ // draw a rotation
Point3f axis, arc_point; Point3f axis, arc_point;
float angle; float angle;
@ -126,15 +126,15 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw)
.arg(axis_name); .arg(axis_name);
Quaternionf arc_rot; Quaternionf arc_rot;
arc_rot.FromAxis(angle/18.0,axis); arc_rot.FromAxis(angle/18.0,axis);
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glVertex(position); glVertex(position);
glVertex(position+arc_point); glVertex(position+arc_point);
for(int i=0;i<18;i++){ for(int i=0;i<18;i++){
arc_point = arc_rot.Rotate(arc_point); arc_point = arc_rot.Rotate(arc_point);
glVertex(position+arc_point); glVertex(position+arc_point);
} }
glEnd(); glEnd();
} else if(moving && drawmoves){ // draw a traslation } else if(moving && drawmoves){ // draw a translation
Point3f ntra=manipulator->track.tra; Point3f ntra=manipulator->track.tra;
ntra.Normalize(); ntra.Normalize();
if(current_mode==movx){ if(current_mode==movx){
@ -159,11 +159,11 @@ void ActiveCoordinateFrame::Render(QGLWidget* glw)
glEnd(); glEnd();
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(old_pos); glVertex(old_pos);
glEnd(); glEnd();
} else { // got nothing to draw } else { // got nothing to draw
glPopAttrib(); glPopAttrib();
glPopMatrix(); glPopMatrix();
return; return;
} }
// draw message below cursor // draw message below cursor
font.setBold(true); font.setBold(true);
@ -179,7 +179,7 @@ void ActiveCoordinateFrame::Reset(bool reset_position,bool reset_alignment)
{ {
MovableCoordinateFrame::Reset(reset_position, reset_alignment); MovableCoordinateFrame::Reset(reset_position, reset_alignment);
Update(); Update();
manipulator->Reset(); manipulator->Reset();
} }
void ActiveCoordinateFrame::SetPosition(const Point3f newpos) void ActiveCoordinateFrame::SetPosition(const Point3f newpos)
@ -215,7 +215,7 @@ void ActiveCoordinateFrame::MouseMove(int x, int y)
manipulator->MouseMove(x,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); Move(manipulator->track);
manipulator->Reset(); manipulator->Reset();
@ -263,9 +263,9 @@ void ActiveCoordinateFrame::Update()
x_axis=r.Rotate(Point3f(1,0,0)); x_axis=r.Rotate(Point3f(1,0,0));
y_axis=r.Rotate(Point3f(0,1,0)); y_axis=r.Rotate(Point3f(0,1,0));
z_axis=r.Rotate(Point3f(0,0,1)); z_axis=r.Rotate(Point3f(0,0,1));
manipulator->ClearModes(); manipulator->ClearModes();
manipulator->modes[0] = NULL; manipulator->modes[0] = NULL;
manipulator->modes[movx] = new AxisMode(p,x_axis); manipulator->modes[movx] = new AxisMode(p,x_axis);
manipulator->modes[movy] = new AxisMode(p,y_axis); manipulator->modes[movy] = new AxisMode(p,y_axis);
manipulator->modes[movz] = new AxisMode(p,z_axis); manipulator->modes[movz] = new AxisMode(p,z_axis);

View File

@ -87,7 +87,7 @@ public:
@param new_rotation the new rotation of the coordinate frame. @param new_rotation the new rotation of the coordinate frame.
*/ */
virtual void SetRotation(const Quaternionf rotation); virtual void SetRotation(const Quaternionf rotation);
/*! /*!
@brief Align the coordinate frame to one or two directions. @brief Align the coordinate frame to one or two directions.
@ -99,8 +99,8 @@ public:
@param primary the primary direction of alignment. @param primary the primary direction of alignment.
@param secondary the secondary 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_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 choosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is choosen automatically. @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); 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 x the x coordinate of the cursor.
@param y the y 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. @brief Interface function relative to mouse up event in QT.
@ -143,20 +143,20 @@ public:
@param button the keyboard modifiers state. @param button the keyboard modifiers state.
*/ */
void ButtonDown(int button); void ButtonDown(int button);
/*! /*!
@brief Set rotational snap value. @brief Set rotational snap value.
@param value the new rotational snap value, in degrees. @param value the new rotational snap value, in degrees.
*/ */
void SetSnap(float value); void SetSnap(float value);
/// The eulerian trackball. /// The eulerian trackball.
Trackball *manipulator; Trackball *manipulator;
/// The flag that enables moves feedback rendering /// The flag that enables moves feedback rendering
bool drawmoves; bool drawmoves;
/// The flag that enables rotations feedback rendering /// The flag that enables rotations feedback rendering
bool drawrotations; bool drawrotations;
protected: protected:
@ -165,7 +165,7 @@ protected:
const int x_modifier,y_modifier,z_modifier; const int x_modifier,y_modifier,z_modifier;
Point3f x_axis,y_axis,z_axis; Point3f x_axis,y_axis,z_axis;
float rot_snap_rad,mov_snap; float rot_snap_rad,mov_snap;
// functions: // functions:
virtual void Move(const Similarityf); virtual void Move(const Similarityf);
void Update(); void Update();
private: private:

View File

@ -212,8 +212,8 @@ public:
@param primary the primary direction of alignment. @param primary the primary direction of alignment.
@param secondary the secondary 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_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 choosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is choosen automatically. @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); virtual void AlignWith(const Point3f primary, const Point3f secondary, const char axis_1, const char axis_2);

View File

@ -110,9 +110,9 @@ public:
/// A trackball stores a transformation called 'track' that effectively rototranslate the object. /// A trackball stores a transformation called 'track' that effectively rototranslate the object.
Similarityf track; Similarityf track;
/// track position in model space. /// track position in model space.
Point3f center; Point3f center;
/// size of the widget in model space. /// size of the widget in model space.
float radius; float radius;
}; };
/*! /*!
@ -160,7 +160,7 @@ mesh->Render();
</pre> </pre>
Note on the typical use: 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 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) - 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 <b>does not</b> 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. @warning The destructor <b>does not</b> 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(); ~Trackball();
private: private:
// Trackball must not be copied. Use Append (see vcg/complex/trimesh/append.h) // Trackball must not be copied. Use Append (see vcg/complex/trimesh/append.h)
Trackball operator =(const Trackball & /*m*/) = delete; Trackball operator =(const Trackball & /*m*/) = delete;
@ -273,7 +273,7 @@ public:
void ApplyInverse(); void ApplyInverse();
// DrawIcon() has been moved to trackutils.h // DrawIcon() has been moved to trackutils.h
//void DrawIcon(); //void DrawIcon();
// T(c) S R T(t) T(-c) => S R T(S^(-1) R^(-1)(c) + t - c) // T(c) S R T(t) T(-c) => S R T(S^(-1) R^(-1)(c) + t - c)
Matrix44f Matrix() const; Matrix44f Matrix() const;
Matrix44f InverseMatrix() const; Matrix44f InverseMatrix() const;
@ -315,7 +315,7 @@ public:
@param x The horizontal coordinate of the mouse pointer. @param x The horizontal coordinate of the mouse pointer.
@param y The vertical 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. @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 y The vertical coordinate of the mouse pointer.
@param button The new state. @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. @brief Old interface function relative to mouse down event in QT/SDL.
@ -367,9 +367,9 @@ public:
void SetSpinnable(bool on); void SetSpinnable(bool on);
// returns if it is animating or not // returns if it is animating or not
// //
bool IsAnimating(unsigned int msec=0); bool IsAnimating(unsigned int msec=0);
// Animate: either takes an absolute time (if default not specified, then it is automeasured) // 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! /* //internals // commented out no more used this stuff!
enum Action { NONE = 0, enum Action { NONE = 0,
VIEW_ROTATE = 1, VIEW_ROTATE = 1,
// Axis Constrained Rotation // Axis Constrained Rotation
TRACK_ROTATE_X = 3, TRACK_ROTATE_Y = 4, TRACK_ROTATE_Z = 5, TRACK_ROTATE_X = 3, TRACK_ROTATE_Y = 4, TRACK_ROTATE_Z = 5,
// Drag constrained to an axis (trackball axis) // Drag constrained to an axis (trackball axis)
DRAG_X = 6, DRAG_Y = 7, DRAG_Z = 8, DRAG_X = 6, DRAG_Y = 7, DRAG_Z = 8,
@ -469,9 +469,9 @@ public:
/// The inactive manipulator. It is drawn when Trackball is inactive. /// The inactive manipulator. It is drawn when Trackball is inactive.
TrackMode *inactive_mode; TrackMode *inactive_mode;
// The manipulator to deal with timer events and key events // 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. @brief Reset modes to default mapping.
@ -493,7 +493,7 @@ public:
/// Transformation before current user action. /// Transformation before current user action.
Similarityf last_track; Similarityf last_track;
/// track after an Undo() call. /// track after an Undo() call.
Similarityf undo_track; Similarityf undo_track;
/// Currently not in use. /// Currently not in use.
Similarityf last_view; Similarityf last_view;
/// Mouse cursor coordinates before current action. /// Mouse cursor coordinates before current action.

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -52,9 +52,9 @@ namespace vcg {
namespace tetra { namespace tetra {
namespace io { namespace io {
/** Additional data needed or useful for parsing a ply mesh. /** 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 - retrieving additional per-vertex per-tetra data
- specifying a callback for long ply parsing - specifying a callback for long ply parsing
- knowing what data is contained in a ply file - knowing what data is contained in a ply file
@ -74,10 +74,10 @@ public:
} }
/// Store the error codes enconutered when parsing a ply /// Store the error codes enconutered when parsing a ply
int status; int status;
/// It returns a bit mask describing the field preesnt in the ply file /// It returns a bit mask describing the field present in the ply file
int mask; 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...) // it returns the current position, and formats a string with a description of what th efunction is doing (loading vertexes, faces...)
CallBackPos *cb; CallBackPos *cb;
@ -87,7 +87,7 @@ public:
PropDescriptor *VertexData; PropDescriptor *VertexData;
/// the number of per-face descriptor (usually 0) /// the number of per-face descriptor (usually 0)
int fdn; int fdn;
/// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply /// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply
PropDescriptor *TetraData; PropDescriptor *TetraData;

View File

@ -67,7 +67,7 @@ public:
flipfaces = false; 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; int mask;
/// index of mesh to be imported /// index of mesh to be imported
@ -189,8 +189,8 @@ public:
if ( ( colnum <=0 ) || ( rownum <=0 ) ) return false; if ( ( colnum <=0 ) || ( rownum <=0 ) ) return false;
// initial 4 lines // 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 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 '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 'Y'
if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'Z' if (!fscanf(fp, "%lf %lf %lf\n", &xx, &yy, &zz)) return false; // scanner registered axis 'Z'
// now the transformation matrix // now the transformation matrix
@ -434,7 +434,7 @@ public:
tri::Clean<OpenMeshType>::RemoveUnreferencedVertex(m); tri::Clean<OpenMeshType>::RemoveUnreferencedVertex(m);
} }
} }
Matrix44x tr; Matrix44x tr;
tr.Import(currtrasf); tr.Import(currtrasf);
tri::UpdatePosition<OpenMeshType>::Matrix(m,tr,true); tri::UpdatePosition<OpenMeshType>::Matrix(m,tr,true);
tri::Allocator<OpenMeshType>::CompactVertexVector(m); tri::Allocator<OpenMeshType>::CompactVertexVector(m);

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -54,9 +54,9 @@ namespace io {
/** Additional data needed or useful for parsing a ply mesh. /** 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 - retrieving additional per-vertex per-face data
- specifying a callback for long ply parsing - specifying a callback for long ply parsing
- knowing what data is contained in a ply file - knowing what data is contained in a ply file
@ -65,13 +65,13 @@ class PlyInfo
{ {
public: public:
typedef ::vcg::ply::PropDescriptor PropDescriptor ; typedef ::vcg::ply::PropDescriptor PropDescriptor ;
void AddPerElemFloatAttribute(int elemType, const char *attrName, const char * propName=0) void AddPerElemFloatAttribute(int elemType, const char *attrName, const char * propName=0)
{ {
static const char *elemStr[2]={"vertex","face"}; static const char *elemStr[2]={"vertex","face"};
std::vector<PropDescriptor> *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)}; std::vector<PropDescriptor> *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)};
std::vector<std::string > *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)}; std::vector<std::string > *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)};
if(propName==0) propName=attrName; if(propName==0) propName=attrName;
elemDescVec[elemType]->push_back(PropDescriptor()); elemDescVec[elemType]->push_back(PropDescriptor());
elemNameVec[elemType]->push_back(attrName); elemNameVec[elemType]->push_back(attrName);
@ -80,71 +80,71 @@ public:
elemDescVec[elemType]->back().stotype1 = vcg::ply::T_FLOAT; elemDescVec[elemType]->back().stotype1 = vcg::ply::T_FLOAT;
elemDescVec[elemType]->back().memtype1 = vcg::ply::T_FLOAT; elemDescVec[elemType]->back().memtype1 = vcg::ply::T_FLOAT;
} }
void AddPerVertexFloatAttribute(const char *attrName, const char *propName=0) { void AddPerVertexFloatAttribute(const char *attrName, const char *propName=0) {
AddPerElemFloatAttribute(0,attrName,propName); AddPerElemFloatAttribute(0,attrName,propName);
} }
void AddPerFaceFloatAttribute(const char *attrName, const char *propName=0) { void AddPerFaceFloatAttribute(const char *attrName, const char *propName=0) {
AddPerElemFloatAttribute(1,attrName,propName); 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... */ * Actually require to allocate 3 float attribute and save them. And they are never deallocated... */
template<class MeshType> template<class MeshType>
void AddPerVertexPoint3fAttribute(MeshType &m, const char *attrName, const char *propName="") void AddPerVertexPoint3fAttribute(MeshType &m, const char *attrName, const char *propName="")
{ {
if(propName==0) propName=attrName; if(propName==0) propName=attrName;
const char *attrxyz[3] = { const char *attrxyz[3] = {
strdup((std::string(attrName)+std::string("_x")).c_str()), strdup((std::string(attrName)+std::string("_x")).c_str()),
strdup((std::string(attrName)+std::string("_y")).c_str()), strdup((std::string(attrName)+std::string("_y")).c_str()),
strdup((std::string(attrName)+std::string("_z")).c_str()), strdup((std::string(attrName)+std::string("_z")).c_str()),
}; };
typename MeshType::template PerVertexAttributeHandle <vcg::Point3f> typename MeshType::template PerVertexAttributeHandle <vcg::Point3f>
ht = vcg::tri::Allocator<MeshType>:: template GetPerVertexAttribute <vcg::Point3f> (m,attrName); ht = vcg::tri::Allocator<MeshType>:: template GetPerVertexAttribute <vcg::Point3f> (m,attrName);
typename MeshType::template PerVertexAttributeHandle <float> htt[3]; typename MeshType::template PerVertexAttributeHandle <float> htt[3];
for(int i=0;i<3;++i) for(int i=0;i<3;++i)
{ {
htt[i] = vcg::tri::Allocator<MeshType>:: template GetPerVertexAttribute<float> (m,std::string(attrxyz[i])); htt[i] = vcg::tri::Allocator<MeshType>:: template GetPerVertexAttribute<float> (m,std::string(attrxyz[i]));
// ForEachVertex (m, [&](typename MeshType::VertexType &v) { // ForEachVertex (m, [&](typename MeshType::VertexType &v) {
// htt[i][v] = ht[v][i]; // htt[i][v] = ht[v][i];
// }); // });
for(auto vi=m.vert.begin();vi!=m.vert.end();++vi) for(auto vi=m.vert.begin();vi!=m.vert.end();++vi)
if(!vi->IsD()) if(!vi->IsD())
htt[i][vi] = ht[vi][i]; htt[i][vi] = ht[vi][i];
AddPerVertexFloatAttribute(attrxyz[i]); AddPerVertexFloatAttribute(attrxyz[i]);
} }
} }
PlyInfo() PlyInfo()
{ {
status=0; status=0;
mask=0; mask=0;
cb=0; cb=0;
} }
/// Store the error codes enconutered when parsing a ply /// Store the error codes enconutered when parsing a ply
int status; int status;
/// It returns a bit mask describing the field preesnt in the ply file /// It returns a bit mask describing the field present in the ply file
int mask; 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...) // it returns the current position, and formats a string with a description of what th efunction is doing (loading vertexes, faces...)
CallBackPos *cb; CallBackPos *cb;
/// The additional vertex descriptor that a user can specify to load additional per-vertex non-standard data stored in a ply /// The additional vertex descriptor that a user can specify to load additional per-vertex non-standard data stored in a ply
std::vector<PropDescriptor> VertDescriptorVec; std::vector<PropDescriptor> 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[] /// 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 /// 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<std::string> VertAttrNameVec; std::vector<std::string> VertAttrNameVec;
/// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply /// The additional vertex descriptor that a user can specify to load additional per-face non-standard data stored in a ply
std::vector<PropDescriptor> FaceDescriptorVec; std::vector<PropDescriptor> FaceDescriptorVec;
std::vector<std::string> FaceAttrNameVec; std::vector<std::string> FaceAttrNameVec;
/// a string containing the current ply header. Useful for showing it to the user. /// a string containing the current ply header. Useful for showing it to the user.
std::string header; std::string header;

View File

@ -15,10 +15,10 @@ public:
std::vector<int> _Ap; std::vector<int> _Ap;
std::vector<int> _Ai; std::vector<int> _Ai;
std::vector<double> _Ax; std::vector<double> _Ax;
typedef typename std::pair<int,int> IndexType; typedef typename std::pair<int,int> IndexType;
int _dimension; int _dimension;
public: public:
@ -26,16 +26,16 @@ public:
virtual void Initalize(int dimension) virtual void Initalize(int dimension)
{_dimension=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 ///of pair of int
virtual void CreateSparse(std::vector<IndexType> Entries) virtual void CreateSparse(std::vector<IndexType> Entries)
{} {}
///return the value of the matrix ///return the value of the matrix
virtual ScalarType &A(int row,int col) virtual ScalarType &A(int row,int col)
{return (_Ax[0]);} {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() virtual bool IsSymmetric()
{return false;} {return false;}
@ -45,4 +45,4 @@ virtual void Zero()
///return the dimension of the matrix ///return the dimension of the matrix
virtual int Size(){return _dimension;} virtual int Size(){return _dimension;}
}; };