last implementations moved from meshlab

This commit is contained in:
alemuntoni 2020-05-29 15:18:33 +02:00
parent 074a89c588
commit 64e352374a
1 changed files with 89 additions and 16 deletions

View File

@ -511,11 +511,14 @@ public:
return true; return true;
} }
/* /*
* Una volta trovati <SampleNum> coppie di punti corrispondenti se ne sceglie This function is used to choose remove outliers after each ICP iteration.
* al piu' <PointNum> per calcolare la trasformazione che li fa coincidere. All the points with a distance over the given Percentile are discarded.
* La scelta viene fatta in base ai due parametri PassLo e PassHi; It uses two parameters
*/ MaxPointNum an (unused) hard limit on the number of points that are chosen
MinPointNum the minimum number of points that have to be chosen to be usable
*/
inline bool choosePoints( inline bool choosePoints(
std::vector<Point3d> &ps, // vertici corrispondenti su fix (rossi) std::vector<Point3d> &ps, // vertici corrispondenti su fix (rossi)
std::vector<Point3d> &ns, // normali corrispondenti su fix (rossi) std::vector<Point3d> &ns, // normali corrispondenti su fix (rossi)
@ -625,6 +628,18 @@ in
************************************************************************************/ ************************************************************************************/
/*
The Main ICP alignment Function:
It assumes that:
we have two meshes:
- Fix the mesh that does not move and stays in the spatial indexing structure.
- Mov the mesh we 'move' e.g. the one for which we search the transforamtion.
requires normalize normals for vertices AND faces
Allinea due mesh;
Assume che:
la uniform grid sia gia' inizializzata con la mesh fix
*/
inline bool align( inline bool align(
A2Grid &u, A2Grid &u,
A2GridVert &uv, A2GridVert &uv,
@ -666,7 +681,7 @@ in
do { do {
Stat::IterInfo ii; Stat::IterInfo ii;
Box3d movbox; Box3d movbox;
InitMov(movvert, movnorm, movbox, out); initMov(movvert, movnorm, movbox, out);
h.SetRange(0.0f, float(startMinDist), 512, 2.5f); h.SetRange(0.0f, float(startMinDist), 512, 2.5f);
pfix.clear(); pfix.clear();
nfix.clear(); nfix.clear();
@ -810,22 +825,80 @@ in
return true; return true;
} }
/*
bool InitMov( Funzione chiamata dalla Align ad ogni ciclo
Riempie i vettori <MovVert> e <MovNorm> con i coordinate e normali presi dal vettore di vertici mov
della mesh da muovere trasformata secondo la matrice <In>
Calcola anche il nuovo bounding box di tali vertici trasformati.
*/
inline bool initMov(
std::vector< Point3d > &movvert, std::vector< Point3d > &movvert,
std::vector< Point3d > &movnorm, std::vector< Point3d > &movnorm,
Box3d &movbox, Box3d &movbox,
const Matrix44d &in ); const Matrix44d &in )
{
Point3d pp, nn;
static bool InitFixVert(A2Mesh *fm, movvert.clear();
AlignPair::Param &pp, movnorm.clear();
A2GridVert &u, movbox.SetNull();
int PreferredGridSize=0);
static bool InitFix(A2Mesh *fm, A2Mesh::VertexIterator vi;
AlignPair::Param &pp, for (vi = mov->begin(); vi != mov->end(); vi++) {
A2Grid &u, pp = in*(*vi).P();
int PreferredGridSize=0); nn = in*Point3d((*vi).P() + (*vi).N()) - pp;
nn.Normalize();
movvert.push_back(pp);
movnorm.push_back(nn);
movbox.Add(pp);
}
return true;
}
static inline bool InitFixVert(
A2Mesh *fm,
AlignPair::Param &pp,
A2GridVert &u,
int preferredGridSize=0)
{
Box3d bb2 = fm->bbox;
double minDist = pp.MinDistAbs*1.1;
//the bbox of the grid should be enflated of the mindist used in the ICP search
bb2.Offset(Point3d(minDist, minDist, minDist));
u.SetBBox(bb2);
//Inserisco la src nella griglia
if (preferredGridSize == 0)
preferredGridSize = int(fm->vert.size())*pp.UGExpansionFactor;
u.Set(fm->vert.begin(), fm->vert.end());//, PreferredGridSize);
printf("UG %i %i %i\n", u.siz[0], u.siz[1], u.siz[2]);
return true;
}
static inline bool initFix(
A2Mesh *fm,
AlignPair::Param &pp,
A2Grid &u,
int preferredGridSize=0)
{
tri::InitFaceIMark(*fm);
Box3d bb2 = fm->bbox;
// double MinDist= fm->bbox.Diag()*pp.MinDistPerc;
double minDist = pp.MinDistAbs*1.1;
//gonfio della distanza utente il BBox della seconda mesh
bb2.Offset(Point3d(minDist, minDist, minDist));
u.SetBBox(bb2);
//Inserisco la src nella griglia
if (preferredGridSize == 0)
preferredGridSize = int(fm->face.size())*pp.UGExpansionFactor;
u.Set(fm->face.begin(), fm->face.end(), preferredGridSize);
printf("UG %i %i %i\n", u.siz[0], u.siz[1], u.siz[2]);
return true;
}
}; // end class }; // end class