first non-working align_pair sample
This commit is contained in:
parent
e5a15a2c48
commit
5b6d6ec767
|
@ -1,11 +1,21 @@
|
||||||
DEPENDPATH += . ../../..
|
DEPENDPATH += \
|
||||||
INCLUDEPATH += . ../../.. ../../../eigenlib
|
. \
|
||||||
|
../../..
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
. \
|
||||||
|
../../.. \
|
||||||
|
../../../eigenlib
|
||||||
|
|
||||||
|
|
||||||
CONFIG += console c++11
|
CONFIG += console c++11
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
# Mac specific Config required to avoid to make application bundles
|
# Mac specific Config required to avoid to make application bundles
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DEFINES *= NDEBUG
|
DEFINES *= NDEBUG
|
||||||
|
|
|
@ -1,6 +1,22 @@
|
||||||
|
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS = trimesh_allocate \
|
|
||||||
|
SUBDIRS = \
|
||||||
|
aabb_binary_tree \
|
||||||
|
colorspace \
|
||||||
|
#edgemesh_sampling \
|
||||||
|
polygonmesh_base \
|
||||||
|
polygonmesh_dual \
|
||||||
|
polygonmesh_optimize \
|
||||||
|
polygonmesh_polychord_collapse \
|
||||||
|
#polygonmesh_quadsimpl \
|
||||||
|
polygonmesh_smooth \
|
||||||
|
polygonmesh_zonohedra \
|
||||||
|
space_index_2d \
|
||||||
|
#space_minimal \
|
||||||
|
space_packer \
|
||||||
|
space_rasterized_packer \
|
||||||
|
trimesh_align_pair \
|
||||||
|
trimesh_allocate \
|
||||||
trimesh_attribute \
|
trimesh_attribute \
|
||||||
trimesh_attribute_saving \
|
trimesh_attribute_saving \
|
||||||
trimesh_ball_pivoting \
|
trimesh_ball_pivoting \
|
||||||
|
@ -45,4 +61,3 @@ SUBDIRS = trimesh_allocate \
|
||||||
trimesh_voronoiatlas \
|
trimesh_voronoiatlas \
|
||||||
trimesh_voronoiclustering \
|
trimesh_voronoiclustering \
|
||||||
trimesh_voronoisampling \
|
trimesh_voronoisampling \
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2016 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef MY_MESH_H
|
||||||
|
#define MY_MESH_H
|
||||||
|
|
||||||
|
#include <vcg/complex/complex.h>
|
||||||
|
|
||||||
|
typedef double Scalarm;
|
||||||
|
typedef vcg::Point2<Scalarm> Point2m;
|
||||||
|
typedef vcg::Point3<Scalarm> Point3m;
|
||||||
|
typedef vcg::Point4<Scalarm> Point4m;
|
||||||
|
typedef vcg::Plane3<Scalarm> Plane3m;
|
||||||
|
typedef vcg::Segment2<Scalarm> Segment2m;
|
||||||
|
typedef vcg::Segment3<Scalarm> Segment3m;
|
||||||
|
typedef vcg::Box3<Scalarm> Box3m;
|
||||||
|
typedef vcg::Matrix44<Scalarm> Matrix44m;
|
||||||
|
typedef vcg::Matrix33<Scalarm> Matrix33m;
|
||||||
|
typedef vcg::Shot<Scalarm> Shotm;
|
||||||
|
typedef vcg::Similarity<Scalarm> Similaritym;
|
||||||
|
|
||||||
|
namespace vcg
|
||||||
|
{
|
||||||
|
namespace vertex
|
||||||
|
{
|
||||||
|
template <class T> class Coord3m: public Coord<vcg::Point3<Scalarm>, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Coord3m"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> class Normal3m: public Normal<vcg::Point3<Scalarm>, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3m"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> class CurvatureDirmOcf: public CurvatureDirOcf<CurvatureDirTypeOcf<Scalarm>, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirmOcf"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> class RadiusmOcf: public RadiusOcf<Scalarm, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("RadiusmOcf"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
}//end namespace vertex
|
||||||
|
namespace face
|
||||||
|
{
|
||||||
|
template <class T> class Normal3m: public NormalAbs<vcg::Point3<Scalarm>, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3m"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> class CurvatureDirmOcf: public CurvatureDirOcf<CurvatureDirOcfBaseType<Scalarm>, T> {
|
||||||
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirdOcf"));T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
}//end namespace face
|
||||||
|
}//end namespace vcg
|
||||||
|
|
||||||
|
// Forward declarations needed for creating the used types
|
||||||
|
class CVertexO;
|
||||||
|
class CEdgeO;
|
||||||
|
class CFaceO;
|
||||||
|
|
||||||
|
// Declaration of the semantic of the used types
|
||||||
|
class CUsedTypesO: public vcg::UsedTypes < vcg::Use<CVertexO>::AsVertexType,
|
||||||
|
vcg::Use<CEdgeO >::AsEdgeType,
|
||||||
|
vcg::Use<CFaceO >::AsFaceType >{};
|
||||||
|
|
||||||
|
|
||||||
|
// The Main Vertex Class
|
||||||
|
// Most of the attributes are optional and must be enabled before use.
|
||||||
|
// Each vertex needs 40 byte, on 32bit arch. and 44 byte on 64bit arch.
|
||||||
|
|
||||||
|
class CVertexO : public vcg::Vertex< CUsedTypesO,
|
||||||
|
vcg::vertex::InfoOcf, /* 4b */
|
||||||
|
vcg::vertex::Coord3m, /* 12b */
|
||||||
|
vcg::vertex::BitFlags, /* 4b */
|
||||||
|
vcg::vertex::Normal3m, /* 12b */
|
||||||
|
vcg::vertex::Qualityf, /* 4b */
|
||||||
|
vcg::vertex::Color4b, /* 4b */
|
||||||
|
vcg::vertex::VFAdjOcf, /* 0b */
|
||||||
|
vcg::vertex::MarkOcf, /* 0b */
|
||||||
|
vcg::vertex::TexCoordfOcf, /* 0b */
|
||||||
|
vcg::vertex::CurvaturefOcf, /* 0b */
|
||||||
|
vcg::vertex::CurvatureDirmOcf, /* 0b */
|
||||||
|
vcg::vertex::RadiusmOcf /* 0b */
|
||||||
|
>{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The Main Edge Class
|
||||||
|
class CEdgeO : public vcg::Edge<CUsedTypesO,
|
||||||
|
vcg::edge::BitFlags, /* 4b */
|
||||||
|
vcg::edge::EVAdj,
|
||||||
|
vcg::edge::EEAdj
|
||||||
|
>{
|
||||||
|
};
|
||||||
|
|
||||||
|
// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch.
|
||||||
|
class CFaceO : public vcg::Face< CUsedTypesO,
|
||||||
|
vcg::face::InfoOcf, /* 4b */
|
||||||
|
vcg::face::VertexRef, /*12b */
|
||||||
|
vcg::face::BitFlags, /* 4b */
|
||||||
|
vcg::face::Normal3m, /*12b */
|
||||||
|
vcg::face::QualityfOcf, /* 0b */
|
||||||
|
vcg::face::MarkOcf, /* 0b */
|
||||||
|
vcg::face::Color4bOcf, /* 0b */
|
||||||
|
vcg::face::FFAdjOcf, /* 0b */
|
||||||
|
vcg::face::VFAdjOcf, /* 0b */
|
||||||
|
vcg::face::CurvatureDirmOcf, /* 0b */
|
||||||
|
vcg::face::WedgeTexCoordfOcf /* 0b */
|
||||||
|
> {};
|
||||||
|
|
||||||
|
|
||||||
|
class MyMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<CVertexO>, vcg::face::vector_ocf<CFaceO> >
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
int sfn; //The number of selected faces.
|
||||||
|
int svn; //The number of selected vertices.
|
||||||
|
|
||||||
|
int pvn; //the number of the polygonal vertices
|
||||||
|
int pfn; //the number of the polygonal faces
|
||||||
|
|
||||||
|
Matrix44m Tr; // Usually it is the identity. It is applied in rendering and filters can or cannot use it. (most of the filter will ignore this)
|
||||||
|
|
||||||
|
const Box3m &trBB()
|
||||||
|
{
|
||||||
|
static Box3m bb;
|
||||||
|
bb.SetNull();
|
||||||
|
bb.Add(Tr,bbox);
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MY_MESH_H
|
|
@ -0,0 +1,131 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2016 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/*! \file trimesh_align_pair.cpp
|
||||||
|
\ingroup code_sample
|
||||||
|
|
||||||
|
\brief the minimal example of using the lib
|
||||||
|
|
||||||
|
This file contain a minimal example of the library
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vcg/complex/complex.h>
|
||||||
|
|
||||||
|
#include <vcg/complex/algorithms/align_pair.h>
|
||||||
|
|
||||||
|
#include <wrap/io_trimesh/import.h>
|
||||||
|
#include <wrap/io_trimesh/export_ply.h>
|
||||||
|
|
||||||
|
#include "my_mesh.h"
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
std::vector<vcg::Point3d>* vcg::PointMatchingScale::fix;
|
||||||
|
std::vector<vcg::Point3d>* vcg::PointMatchingScale::mov;
|
||||||
|
vcg::Box3d vcg::PointMatchingScale::b;
|
||||||
|
|
||||||
|
int main(int argc,char ** argv)
|
||||||
|
{
|
||||||
|
if(argc<3) {
|
||||||
|
printf("Usage: trimesh_smooth <filename> <filename>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyMesh m1, m2;
|
||||||
|
|
||||||
|
//open first mesh
|
||||||
|
int err = tri::io::Importer<MyMesh>::Open(m1,argv[1]);
|
||||||
|
if(err) { // all the importers return 0 in case of success
|
||||||
|
printf("Error in reading %s: '%s'\n", argv[1], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//open second mesh
|
||||||
|
err = tri::io::Importer<MyMesh>::Open(m1,argv[2]);
|
||||||
|
if(err) { // all the importers return 0 in case of success
|
||||||
|
printf("Error in reading %s: '%s'\n", argv[2], tri::io::Importer<MyMesh>::ErrorMsg(err));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
////PARAMS
|
||||||
|
/////TODO
|
||||||
|
vcg::Matrix44d MovM;
|
||||||
|
vcg::AlignPair::Result result;
|
||||||
|
vcg::AlignPair::Param ap;
|
||||||
|
|
||||||
|
//MovM
|
||||||
|
vcg::Matrix44d FixM=vcg::Matrix44d::Construct(m1.Tr);
|
||||||
|
MovM=vcg::Matrix44d::Construct(m2.Tr);
|
||||||
|
MovM = Inverse(FixM) * MovM;
|
||||||
|
|
||||||
|
vcg::AlignPair::A2Mesh fix;
|
||||||
|
vcg::AlignPair aa;
|
||||||
|
|
||||||
|
// 1) Convert fixed mesh and put it into the grid.
|
||||||
|
m1.face.EnableMark();
|
||||||
|
aa.convertMesh<MyMesh>(m1,fix);
|
||||||
|
|
||||||
|
vcg::AlignPair::A2Grid UG;
|
||||||
|
vcg::AlignPair::A2GridVert VG;
|
||||||
|
|
||||||
|
if(m1.fn==0 || ap.UseVertexOnly) {
|
||||||
|
fix.initVert(vcg::Matrix44d::Identity());
|
||||||
|
vcg::AlignPair::InitFixVert(&fix,ap,VG);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fix.init(vcg::Matrix44d::Identity());
|
||||||
|
vcg::AlignPair::initFix(&fix, ap, UG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 2) Convert the second mesh and sample a <ap.SampleNum> points on it.
|
||||||
|
//MM(movId)->updateDataMask(MeshModel::MM_FACEMARK);
|
||||||
|
m2.face.EnableMark();
|
||||||
|
std::vector<vcg::AlignPair::A2Vertex> tmpmv;
|
||||||
|
aa.convertVertex(m2.vert,tmpmv);
|
||||||
|
aa.sampleMovVert(tmpmv, ap.SampleNum, ap.SampleMode);
|
||||||
|
|
||||||
|
aa.mov=&tmpmv;
|
||||||
|
aa.fix=&fix;
|
||||||
|
aa.ap = ap;
|
||||||
|
|
||||||
|
vcg::Matrix44d In=MovM;
|
||||||
|
// Perform the ICP algorithm
|
||||||
|
aa.align(In,UG,VG,result);
|
||||||
|
|
||||||
|
m2.Tr = result.Tr;
|
||||||
|
tri::UpdatePosition<MyMesh>::Matrix(m2, m2.Tr, true);
|
||||||
|
tri::UpdateBounding<MyMesh>::Box(m2);
|
||||||
|
m2.Tr.SetIdentity();
|
||||||
|
|
||||||
|
//result.FixName=fixId;
|
||||||
|
//result.MovName=movId;
|
||||||
|
//result.as.Dump(stdout);
|
||||||
|
|
||||||
|
//saves the rotated mesh
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(m2 ,"out.ply");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
include(../common.pri)
|
||||||
|
|
||||||
|
TARGET = trimesh_align_pair
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
my_mesh.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
trimesh_align_pair.cpp \
|
||||||
|
../../../wrap/ply/plylib.cpp
|
|
@ -192,7 +192,8 @@ public:
|
||||||
template <class Q>
|
template <class Q>
|
||||||
static inline Matrix44 Construct( const Matrix44<Q> & b )
|
static inline Matrix44 Construct( const Matrix44<Q> & b )
|
||||||
{
|
{
|
||||||
Matrix44<T> tmp; tmp.FromMatrix(b);
|
Matrix44<T> tmp;
|
||||||
|
tmp.FromMatrix(b);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue