minor changes
This commit is contained in:
parent
71f78f7333
commit
5613d4c584
|
@ -32,6 +32,7 @@ public:
|
||||||
//control if two faces share an edge
|
//control if two faces share an edge
|
||||||
bool ShareEdge(SimplexType *f0,SimplexType *f1)
|
bool ShareEdge(SimplexType *f0,SimplexType *f1)
|
||||||
{
|
{
|
||||||
|
assert((!f0->IsD())&&(!f1->IsD()));
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
if (f0->FFp(i)==f1)
|
if (f0->FFp(i)==f1)
|
||||||
return (true);
|
return (true);
|
||||||
|
@ -49,6 +50,7 @@ public:
|
||||||
//control if two faces share a vertex
|
//control if two faces share a vertex
|
||||||
bool ShareVertex(SimplexType *f0,SimplexType *f1)
|
bool ShareVertex(SimplexType *f0,SimplexType *f1)
|
||||||
{
|
{
|
||||||
|
assert((!f0->IsD())&&(!f1->IsD()));
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
for (int j=0;j<3;j++)
|
for (int j=0;j<3;j++)
|
||||||
if (f0->V(i)==f1->V(j))
|
if (f0->V(i)==f1->V(j))
|
||||||
|
@ -61,7 +63,7 @@ public:
|
||||||
bool TestRealIntersection(SimplexType *f0,SimplexType *f1)
|
bool TestRealIntersection(SimplexType *f0,SimplexType *f1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (((!f0->IsActive())&&(!f1->IsActive()))||(f0->IsD())||(f1->IsD()))
|
if ((f0->IsD())||(f1->IsD())||((!f0->IsActive())&&(!f1->IsActive())))
|
||||||
return false;
|
return false;
|
||||||
//no adiacent faces
|
//no adiacent faces
|
||||||
if ((f0!=f1)&& (!ShareEdge(f0,f1))
|
if ((f0!=f1)&& (!ShareEdge(f0,f1))
|
||||||
|
@ -71,14 +73,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
///refresh all the elements of spatial hashing table
|
///refresh all the elements of spatial hashing table
|
||||||
///this function must called sometimes
|
|
||||||
void RefreshElements()
|
void RefreshElements()
|
||||||
{
|
{
|
||||||
HTable->Clear();
|
HTable->Clear();
|
||||||
vactive.clear();///new
|
vactive.clear();///new
|
||||||
for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||||
{
|
{
|
||||||
if ((!(*si).IsD())&&(!(*si).IsActive()))
|
if (!(*si).IsD())
|
||||||
|
{
|
||||||
|
if (!(*si).IsActive())
|
||||||
HTable->addSimplex(&*si);
|
HTable->addSimplex(&*si);
|
||||||
///new now
|
///new now
|
||||||
else
|
else
|
||||||
|
@ -92,6 +95,7 @@ public:
|
||||||
|
|
||||||
//UpdateStep(); commented now
|
//UpdateStep(); commented now
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////put active cells on apposite structure
|
/////put active cells on apposite structure
|
||||||
//void UpdateStep()
|
//void UpdateStep()
|
||||||
|
@ -116,7 +120,7 @@ public:
|
||||||
vactive.clear();
|
vactive.clear();
|
||||||
for (Container_Type::iterator si=simplex.begin();si<simplex.end();++si)
|
for (Container_Type::iterator si=simplex.begin();si<simplex.end();++si)
|
||||||
{
|
{
|
||||||
if ((((!(*si).IsD()))&&(*si).IsActive()))
|
if ((!(*si).IsD())&&((*si).IsActive()))
|
||||||
{
|
{
|
||||||
std::vector<Point3i> cells=HTable->addSimplex(&*si);
|
std::vector<Point3i> cells=HTable->addSimplex(&*si);
|
||||||
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||||
|
@ -126,6 +130,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///put active cells on apposite structure
|
||||||
|
void AddElements(typename ContSimplex::iterator newSimplex)
|
||||||
|
{
|
||||||
|
while (newSimplex!=_simplex.end())
|
||||||
|
{
|
||||||
|
if (!(*newSimplex).IsD())
|
||||||
|
{
|
||||||
|
if (!(*newSimplex).IsActive())
|
||||||
|
HTable->addSimplex(&*newSimplex);
|
||||||
|
///new now
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<Point3i> cells=HTable->addSimplex(&*newSimplex);
|
||||||
|
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||||
|
vactive.insert(*it);
|
||||||
|
}
|
||||||
|
///end new now
|
||||||
|
}
|
||||||
|
newSimplex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///control the real self intersection in the mesh and returns the elements that intersect with someone
|
///control the real self intersection in the mesh and returns the elements that intersect with someone
|
||||||
std::vector<SimplexType*> computeSelfIntersection()
|
std::vector<SimplexType*> computeSelfIntersection()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,202 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* VCGLib o o *
|
|
||||||
* Visual and Computer Graphics Library o o *
|
|
||||||
* _ O _ *
|
|
||||||
* Copyright(C) 2004 \/)\/ *
|
|
||||||
* 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. *
|
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
/****************************************************************************
|
|
||||||
History
|
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
|
||||||
Revision 1.6 2004/05/14 00:34:36 ganovelli
|
|
||||||
header added
|
|
||||||
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __VCG_MINDISTPOINT
|
|
||||||
#define __VCG_MINDISTPOINT
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <vcg/space/point3.h>
|
|
||||||
#include <vcg/space/box3.h>
|
|
||||||
#include <vcg/space/point4.h>
|
|
||||||
#include <vcg/math/base.h>
|
|
||||||
#include <vcg/space/index/grid_static_ptr.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace vcg;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
aka MetroCore
|
|
||||||
data una mesh m e una ug sulle sue facce trova il punto di m piu' vicino ad
|
|
||||||
un punto dato.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// input: mesh, punto, griglia, distanza limite
|
|
||||||
// output: normale alla faccia e punto piu' vicino su di essa
|
|
||||||
|
|
||||||
// Nota che il parametro template GRID non ci dovrebbe essere, visto che deve essere
|
|
||||||
// UGrid<MESH::FaceContainer >, ma non sono riuscito a definirlo implicitamente
|
|
||||||
|
|
||||||
template <class MESH, class GRID, class SCALAR>
|
|
||||||
void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & mdist,
|
|
||||||
Point3<SCALAR> & normf, Point3<SCALAR> & bestq, typename MESH::FaceType * &f, Point3<SCALAR> &ip)
|
|
||||||
{
|
|
||||||
typedef SCALAR scalar;
|
|
||||||
typedef Point3<scalar> Point3x;
|
|
||||||
typedef Box3<SCALAR> Box3x;
|
|
||||||
|
|
||||||
if(!gr.bbox.IsIn(p)) return;
|
|
||||||
typedef typename GridStaticPtr<typename MESH::FaceContainer>::Link A2UGridLink;
|
|
||||||
scalar ax = p[0] - gr.bbox.min[0]; // Real coodinate of point refer to
|
|
||||||
scalar ay = p[1] - gr.bbox.min[1];
|
|
||||||
scalar az = p[2] - gr.bbox.min[2];
|
|
||||||
|
|
||||||
int gx = int( ax/gr.voxel[0] ); // Integer coordinate of the point
|
|
||||||
int gy = int( ay/gr.voxel[1] ); // voxel
|
|
||||||
int gz = int( az/gr.voxel[2] );
|
|
||||||
|
|
||||||
scalar vx = gr.bbox.min[0]+gx*gr.voxel[0]; // Real world coordinate of the Voxel
|
|
||||||
scalar vy = gr.bbox.min[1]+gy*gr.voxel[1]; // origin
|
|
||||||
scalar vz = gr.bbox.min[2]+gz*gr.voxel[2];
|
|
||||||
|
|
||||||
scalar dx = math::Min(p[0] - vx, vx+gr.voxel[0]-p[0]); // Dist from the voxel
|
|
||||||
scalar dy = math::Min(p[1] - vy, vy+gr.voxel[1]-p[1]);
|
|
||||||
scalar dz = math::Min(p[2] - vz, vz+gr.voxel[2]-p[2]);
|
|
||||||
|
|
||||||
scalar vdist,vstep;
|
|
||||||
|
|
||||||
if(dx<dy && dx<dz)
|
|
||||||
{
|
|
||||||
vdist = dx;
|
|
||||||
vstep = gr.voxel[0];
|
|
||||||
}
|
|
||||||
else if(dy<dz)
|
|
||||||
{
|
|
||||||
vdist = dy;
|
|
||||||
vstep = gr.voxel[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vdist = dz;
|
|
||||||
vstep = gr.voxel[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
//scalar error = gr.bbox.SquaredDiag();
|
|
||||||
//scalar error = gr.bbox.Diag();
|
|
||||||
scalar error = mdist;
|
|
||||||
Point3x q;
|
|
||||||
typename MESH::FaceIterator bestf = (typename MESH::FaceIterator)0;
|
|
||||||
|
|
||||||
mesh.UnMarkAll();
|
|
||||||
|
|
||||||
int mxsd = gr.siz[0];
|
|
||||||
if(mxsd<gr.siz[1]) mxsd = gr.siz[1];
|
|
||||||
if(mxsd<gr.siz[2]) mxsd = gr.siz[2];
|
|
||||||
for(int s=0;s<mxsd;++s)
|
|
||||||
{
|
|
||||||
if(s==0)
|
|
||||||
{
|
|
||||||
|
|
||||||
A2UGridLink *first, *last, *l;
|
|
||||||
gr.Grid( gx, gy, gz, first, last );
|
|
||||||
for(l=first;l!=last;++l)
|
|
||||||
|
|
||||||
if( ! mesh.IsMarked( &*(l->Elem())) )
|
|
||||||
{
|
|
||||||
if( Dist((*(l->Elem())), p, error, q) )
|
|
||||||
{
|
|
||||||
bestq = q;
|
|
||||||
bestf = l->Elem();
|
|
||||||
typename MESH::ScalarType alfa=1, beta=1, gamma=1;
|
|
||||||
|
|
||||||
//bestf->InterpolationParameters(q, alfa, beta);
|
|
||||||
//calcolo normale con interpolazione trilineare
|
|
||||||
/*normf = (1-(alfa+beta))*(bestf->V(0)->Normal())+
|
|
||||||
(alfa*(bestf->V(1)->Normal()))+
|
|
||||||
(beta*(bestf->V(2)->Normal()));*/
|
|
||||||
bool ret=bestf->InterpolationParameters(q, alfa, beta, gamma);
|
|
||||||
//assert(ret);
|
|
||||||
normf = (bestf->V(0)->cN())*alfa+
|
|
||||||
(bestf->V(1)->cN())*beta+
|
|
||||||
(bestf->V(2)->cN())*gamma;
|
|
||||||
normf.Normalize();
|
|
||||||
ip[0]=alfa;ip[1]=beta;ip[2]=gamma;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh.Mark( &*(l->Elem()) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int ix=gx-s;ix<=gx+s;++ix)
|
|
||||||
if( ix>=0 && ix<gr.siz[0] )
|
|
||||||
{
|
|
||||||
for(int iy=gy-s;iy<=gy+s;++iy)
|
|
||||||
if( iy>=0 && iy<gr.siz[1] )
|
|
||||||
{
|
|
||||||
int sz = ( ix==gx-s || ix==gx+s ||
|
|
||||||
iy==gy-s || iy==gy+s )?1:2*s;
|
|
||||||
for(int iz=gz-s;iz<=gz+s;iz+=sz)
|
|
||||||
if( iz>=0 && iz<gr.siz[2] )
|
|
||||||
{
|
|
||||||
A2UGridLink *first, *last, *l;
|
|
||||||
gr.Grid( ix, iy, iz, first, last );
|
|
||||||
for(l=first;l!=last;++l)
|
|
||||||
if( ! mesh.IsMarked( &*(l->Elem())) )
|
|
||||||
{
|
|
||||||
if( Dist((*(l->Elem())), p, error, q) )
|
|
||||||
{
|
|
||||||
bestq = q;
|
|
||||||
bestf = l->Elem();
|
|
||||||
typename MESH::ScalarType alfa, beta, gamma;
|
|
||||||
//bestf->InterpolationParameters(q, alfa, beta);
|
|
||||||
//calcolo normale con interpolazione trilineare
|
|
||||||
bestf->InterpolationParameters(q, alfa, beta, gamma);
|
|
||||||
normf = (bestf->V(0)->cN())*alfa+
|
|
||||||
(bestf->V(1)->cN())*beta+
|
|
||||||
(bestf->V(2)->cN())*gamma ;
|
|
||||||
ip[0]=alfa;ip[1]=beta;ip[2]=gamma;
|
|
||||||
//normf.Normalize(); inutile si assume le normali ai vertici benfatte
|
|
||||||
}
|
|
||||||
mesh.Mark(&*l->Elem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( fabs(error)<vdist )
|
|
||||||
break;
|
|
||||||
vdist += vstep;
|
|
||||||
}
|
|
||||||
f=&*bestf;
|
|
||||||
mdist = scalar(fabs(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MESH, class GRID, class SCALAR>
|
|
||||||
void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & mdist,
|
|
||||||
Point3<SCALAR> & normf, Point3<SCALAR> & bestq, typename MESH::face_type * &f)
|
|
||||||
{
|
|
||||||
Point3<SCALAR> ip;
|
|
||||||
MinDistPoint(mesh,p,gr,mdist,normf,bestq,f,ip);
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -14,7 +14,61 @@ SOURCES += D:/sf/wrap/gui/trackmode.cpp \
|
||||||
D:/sf/wrap/ply/plylib.cpp \
|
D:/sf/wrap/ply/plylib.cpp \
|
||||||
simpleglwidget.cpp \
|
simpleglwidget.cpp \
|
||||||
main.cpp
|
main.cpp
|
||||||
FORMS = segmentform.ui
|
FORMS = segmentform.ui \
|
||||||
|
d:\sf\apps\test\segmentation3d\segmentform.ui
|
||||||
|
IMAGES = D:/sf/apps/test/segmentation3d/slider.jpg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,20 +26,8 @@
|
||||||
#include <vcg/complex/trimesh/create/platonic.h>
|
#include <vcg/complex/trimesh/create/platonic.h>
|
||||||
#include <volume_dataset.h>
|
#include <volume_dataset.h>
|
||||||
|
|
||||||
//#include <vcg/simplex/face/pos.h>
|
|
||||||
|
|
||||||
///marching cubes
|
|
||||||
|
|
||||||
//#include <segmentation_wolker.h>
|
|
||||||
#include <vcg/complex/trimesh/create/resampler.h>
|
#include <vcg/complex/trimesh/create/resampler.h>
|
||||||
|
|
||||||
//#ifdef _EXTENDED_MARCH
|
|
||||||
// #include <vcg/complex/trimesh/create/extended_marching_cubes.h>
|
|
||||||
//#else
|
|
||||||
// #include <vcg/complex/trimesh/create/marching_cubes.h>
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include <vcg/space/point3.h>
|
#include <vcg/space/point3.h>
|
||||||
#include <vcg/space/box3.h>
|
#include <vcg/space/box3.h>
|
||||||
|
|
||||||
|
@ -51,9 +39,6 @@
|
||||||
#include <collision_detection.h>
|
#include <collision_detection.h>
|
||||||
#include <vcg/complex/trimesh/smooth.h>
|
#include <vcg/complex/trimesh/smooth.h>
|
||||||
|
|
||||||
///debugghe
|
|
||||||
#include <wrap/io_trimesh/export_ply.h>
|
|
||||||
///debugghe
|
|
||||||
|
|
||||||
class Segmentator{
|
class Segmentator{
|
||||||
|
|
||||||
|
@ -86,7 +71,6 @@ public:
|
||||||
|
|
||||||
void UpdateAcceleration()
|
void UpdateAcceleration()
|
||||||
{
|
{
|
||||||
//if ((!IsBlocked(this))&&(!IsStopped(this)))
|
|
||||||
if ((!blocked)&&(!stopped))
|
if ((!blocked)&&(!stopped))
|
||||||
{
|
{
|
||||||
Acc()=(IntForce()+ExtForce())/Mass();
|
Acc()=(IntForce()+ExtForce())/Mass();
|
||||||
|
@ -127,9 +111,9 @@ public:
|
||||||
|
|
||||||
bool IsActive()
|
bool IsActive()
|
||||||
{
|
{
|
||||||
return(!(((V(0)->blocked)||(V(0)->stopped))&&
|
return((!(((V(0)->blocked)||(V(0)->stopped))&&
|
||||||
((V(1)->blocked)||(V(1)->stopped))&&
|
((V(1)->blocked)||(V(1)->stopped))&&
|
||||||
((V(2)->blocked)||(V(2)->stopped))));
|
((V(2)->blocked)||(V(2)->stopped))))&&(!intersected));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsBlocked()
|
bool IsBlocked()
|
||||||
|
@ -148,12 +132,17 @@ public:
|
||||||
|
|
||||||
///update of the internal forces using the dihedral angle
|
///update of the internal forces using the dihedral angle
|
||||||
bool Update ( void )
|
bool Update ( void )
|
||||||
|
{
|
||||||
|
if (!this->IsD())
|
||||||
{
|
{
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
MyFace *fopp=FFp(i);
|
MyFace *fopp=FFp(i);
|
||||||
|
MyFace *myAddr;
|
||||||
|
if (!fopp->IsD())
|
||||||
MyFace *myAddr=fopp->FFp(FFi(i));
|
MyFace *myAddr=fopp->FFp(FFi(i));
|
||||||
if ((fopp!=0)||(fopp<myAddr))//test do not duplicate updates per edge
|
|
||||||
|
if ((fopp->IsD())||(fopp!=0)||(fopp<myAddr))//test do not duplicate updates per edge
|
||||||
{
|
{
|
||||||
//normal and area based diadedral angle calcolus
|
//normal and area based diadedral angle calcolus
|
||||||
CoordType DirEdge=(V(i)->P()-V((i+1)%3)->P()).Normalize();
|
CoordType DirEdge=(V(i)->P()-V((i+1)%3)->P()).Normalize();
|
||||||
|
@ -177,6 +166,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return(__super::Update());
|
return(__super::Update());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -248,27 +238,6 @@ public:
|
||||||
{
|
{
|
||||||
m=new MyTriMesh();
|
m=new MyTriMesh();
|
||||||
CollDet=new Collision(m->face);
|
CollDet=new Collision(m->face);
|
||||||
//m=NULL;
|
|
||||||
|
|
||||||
//scale=Point3f(5.f,5.f,5.f);
|
|
||||||
//InitialBarycenter=Point3f(20.f,20.f,20.f);
|
|
||||||
//InitMesh(m);
|
|
||||||
//vcg::tri::UpdateNormals<MyTriMesh>::PerFaceNormalized(m);
|
|
||||||
//vcg::tri::UpdateBounding<MyTriMesh>::Box(m);
|
|
||||||
//vcg::tri::UpdateEdges<MyTriMesh>::Set(m);
|
|
||||||
///////debugghe
|
|
||||||
//edge_precision=4.f;
|
|
||||||
////edge_precision=1.f;
|
|
||||||
//float rx=this->m.bbox.DimX()/edge_precision;
|
|
||||||
//float ry=this->m.bbox.DimY()/edge_precision;
|
|
||||||
//float rz=this->m.bbox.DimZ()/edge_precision;
|
|
||||||
//Point3i res=Point3i((int)ceil(rx),(int)ceil(ry),(int)ceil(rz));
|
|
||||||
//// EXTENDED MARCHING CUBES
|
|
||||||
//MyWalk walker(m.bbox,res);
|
|
||||||
//MarchingCubes emc(new_m, walker);
|
|
||||||
//walker.BuildMesh<MarchingCubes>(m,new_m,emc);
|
|
||||||
|
|
||||||
//vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save(new_m,"D:/lillo.ply");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Segmentator()
|
~Segmentator()
|
||||||
|
@ -386,10 +355,8 @@ private:
|
||||||
bool OutOfLimits(MyTriMesh::CoordType p)
|
bool OutOfLimits(MyTriMesh::CoordType p)
|
||||||
{
|
{
|
||||||
Point3f test=p;
|
Point3f test=p;
|
||||||
/*Point3f max=UnScale(MapToSpace(V.Max()));
|
Point3f max=BBox().max-Point3f(1.f,1.f,1.f);//last change
|
||||||
Point3f min=UnScale(MapToSpace(V.Min()));*/
|
Point3f min=BBox().min;//+Point3f(1.f,1.f,1.f);//last change
|
||||||
Point3f max=BBox().max;//last change
|
|
||||||
Point3f min=BBox().min;//last change
|
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
if(((test.V(i)>=max.V(i))||(test.V(i)<=min.V(i))))
|
if(((test.V(i)>=max.V(i))||(test.V(i)<=min.V(i))))
|
||||||
|
@ -422,6 +389,24 @@ private:
|
||||||
void SetIntersectedFace(MyFace *f)
|
void SetIntersectedFace(MyFace *f)
|
||||||
{
|
{
|
||||||
f->intersected=true;
|
f->intersected=true;
|
||||||
|
///detaching from ff topology
|
||||||
|
/*MyFace *f0=f->FFp(0);
|
||||||
|
MyFace *f1=f->FFp(1);
|
||||||
|
MyFace *f2=f->FFp(2);
|
||||||
|
int i0=f->FFi(0);
|
||||||
|
int i1=f->FFi(1);
|
||||||
|
int i2=f->FFi(2);
|
||||||
|
|
||||||
|
f0->FFp(i0)=f0;
|
||||||
|
f1->FFp(i1)=f1;
|
||||||
|
f2->FFp(i2)=f2;
|
||||||
|
|
||||||
|
f0->FFi(i0)=0;
|
||||||
|
f1->FFi(i1)=1;
|
||||||
|
f2->FFi(i2)=2;
|
||||||
|
|
||||||
|
f->SetD();*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsStopped(MyVertex *v)
|
bool IsStopped(MyVertex *v)
|
||||||
|
@ -443,14 +428,15 @@ private:
|
||||||
v->stopped=false;
|
v->stopped=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///re-set physical pararmeters on the mesh
|
/////re-set physical pararmeters on the mesh
|
||||||
void InitPhysParam(float k_elanst,float mass,float k_dihedral)
|
//void InitPhysParam(float k_elanst,float mass,float k_dihedral)
|
||||||
{
|
//{
|
||||||
for (unsigned int i=0;i<m->face.size();i++)
|
// for (unsigned int i=0;i<m->face.size();i++)
|
||||||
{
|
// {
|
||||||
m->face[i].Init(k_elanst,mass,k_dihedral);
|
// if (!m->face[i].IsD())
|
||||||
}
|
// m->face[i].Init(k_elanst,mass,k_dihedral);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
///set the initial mesh of deformable object
|
///set the initial mesh of deformable object
|
||||||
void InitMesh(MyTriMesh *m)
|
void InitMesh(MyTriMesh *m)
|
||||||
|
@ -468,7 +454,7 @@ void InitMesh(MyTriMesh *m)
|
||||||
{
|
{
|
||||||
m->vert[i].P()=UnScale(m->vert[i].P());///last change
|
m->vert[i].P()=UnScale(m->vert[i].P());///last change
|
||||||
m->vert[i].P()+=InitialBarycenter;
|
m->vert[i].P()+=InitialBarycenter;
|
||||||
// m.vert[i].P()=UnScale(m.vert[i].P());
|
// m.vert[i].P()=UnScale(m.vert[i].P());
|
||||||
// P_Vertex.push_back(&m.vert[i]);
|
// P_Vertex.push_back(&m.vert[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +467,7 @@ void InitMesh(MyTriMesh *m)
|
||||||
///return true if the gray level of the vertex v differ from graylevel less than tolerance
|
///return true if the gray level of the vertex v differ from graylevel less than tolerance
|
||||||
bool InTolerance(MyTriMesh::VertexType *v)
|
bool InTolerance(MyTriMesh::VertexType *v)
|
||||||
{
|
{
|
||||||
return (abs(getColor(v->P())-gray_init)<tolerance);
|
return (fabs(getColor(v->P())-(float)gray_init)<(float)tolerance);
|
||||||
}
|
}
|
||||||
|
|
||||||
///add to the vertex v a containing force basing on diffence from tolerance
|
///add to the vertex v a containing force basing on diffence from tolerance
|
||||||
|
@ -511,7 +497,7 @@ MyTriMesh::CoordType GradientFactor(MyTriMesh::VertexType *v)
|
||||||
void AddExtForces()
|
void AddExtForces()
|
||||||
{
|
{
|
||||||
Part_VertexContainer::iterator vi;
|
Part_VertexContainer::iterator vi;
|
||||||
|
PartialUpdateNormals();
|
||||||
end_loop=true;
|
end_loop=true;
|
||||||
for (vi=P_Vertex.begin();vi<P_Vertex.end();++vi)
|
for (vi=P_Vertex.begin();vi<P_Vertex.end();++vi)
|
||||||
{
|
{
|
||||||
|
@ -519,8 +505,11 @@ void AddExtForces()
|
||||||
if (!(*vi).IsD())
|
if (!(*vi).IsD())
|
||||||
{
|
{
|
||||||
if (OutOfLimits((*vi).P()))
|
if (OutOfLimits((*vi).P()))
|
||||||
//vi->blocked=true;
|
{
|
||||||
SetBlocked(&*vi);
|
SetBlocked(&*vi);
|
||||||
|
(*vi).ExtForce()=MyTriMesh::CoordType(0,0,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
if ((!IsBlocked(&*vi))&&(!IsStopped(&*vi)))
|
if ((!IsBlocked(&*vi))&&(!IsStopped(&*vi)))
|
||||||
{
|
{
|
||||||
end_loop=false;
|
end_loop=false;
|
||||||
|
@ -565,7 +554,6 @@ void Reinit_PVectors()
|
||||||
MyTriMesh::FaceIterator fi;
|
MyTriMesh::FaceIterator fi;
|
||||||
for (fi=m->face.begin();fi<m->face.end();fi++)
|
for (fi=m->face.begin();fi<m->face.end();fi++)
|
||||||
{
|
{
|
||||||
//if ((!fi->IsBlocked()))
|
|
||||||
if ((!fi->IsD())&&(!fi->IsBlocked()))
|
if ((!fi->IsD())&&(!fi->IsBlocked()))
|
||||||
P_Faces.push_back(&(*fi));
|
P_Faces.push_back(&(*fi));
|
||||||
}
|
}
|
||||||
|
@ -582,13 +570,13 @@ void Refresh_PVectors()
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
for (i=0;i<P_Vertex.size();i++)
|
for (i=0;i<P_Vertex.size();i++)
|
||||||
{
|
{
|
||||||
if (!P_Vertex[i]->blocked)
|
if ((!P_Vertex[i]->IsD())&&(!P_Vertex[i]->blocked))
|
||||||
P_VertexAux.push_back(P_Vertex[i]);
|
P_VertexAux.push_back(P_Vertex[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<P_Faces.size();i++)
|
for (i=0;i<P_Faces.size();i++)
|
||||||
{
|
{
|
||||||
if (!P_Faces[i]->IsBlocked())
|
if ((!P_Faces[i]->IsD())&&(!P_Faces[i]->IsBlocked()))
|
||||||
P_FacesAux.push_back(P_Faces[i]);
|
P_FacesAux.push_back(P_Faces[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,13 +592,13 @@ void AddNewElements(MyTriMesh::VertexIterator vi,MyTriMesh::FaceIterator fi)
|
||||||
{
|
{
|
||||||
while (vi!=m->vert.end())
|
while (vi!=m->vert.end())
|
||||||
{
|
{
|
||||||
if (!(*vi).IsD())
|
if ((!(*vi).IsD())&&(!(*vi).blocked)&&(!(*vi).stopped))
|
||||||
P_Vertex.push_back(&(*vi));
|
P_Vertex.push_back(&(*vi));
|
||||||
vi++;
|
vi++;
|
||||||
}
|
}
|
||||||
while (fi!=m->face.end())
|
while (fi!=m->face.end())
|
||||||
{
|
{
|
||||||
if (!(*fi).IsD())
|
if ((!(*fi).IsD())&&((*fi).IsActive()))
|
||||||
P_Faces.push_back(&(*fi));
|
P_Faces.push_back(&(*fi));
|
||||||
fi++;
|
fi++;
|
||||||
}
|
}
|
||||||
|
@ -657,6 +645,35 @@ bool TimeSelfIntersection()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PartialUpdateNormals()
|
||||||
|
{
|
||||||
|
Part_FaceContainer::iterator fi;
|
||||||
|
for (fi=P_Faces.begin();fi<P_Faces.end();++fi)
|
||||||
|
if (!(*fi).IsD())
|
||||||
|
(*fi).ComputeNormalizedNormal();
|
||||||
|
|
||||||
|
Part_VertexContainer::iterator vi;
|
||||||
|
|
||||||
|
for (vi=P_Vertex.begin();vi<P_Vertex.end();++vi)
|
||||||
|
if( !(*vi).IsD() && (*vi).IsRW() )
|
||||||
|
(*vi).N() = MyVertex::NormalType(0.f,0.f,0.f);
|
||||||
|
|
||||||
|
for(fi=P_Faces.begin();fi!=P_Faces.end();++fi)
|
||||||
|
if( !(*fi).IsD() && (*fi).IsR() )
|
||||||
|
{
|
||||||
|
MyFace::NormalType t = (*fi).Normal();
|
||||||
|
for(int j=0; j<3; ++j)
|
||||||
|
if( !(*fi).V(j)->IsD() && (*fi).V(j)->IsRW() )
|
||||||
|
(*fi).V(j)->N() += t;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(vi=P_Vertex.begin();vi!=P_Vertex.end();++vi)
|
||||||
|
if( !(*vi).IsD() && (*vi).IsRW() )
|
||||||
|
(*vi).N().Normalize();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
///refine the mesh and re-update eventually
|
///refine the mesh and re-update eventually
|
||||||
void RefineStep(float _edge_size)
|
void RefineStep(float _edge_size)
|
||||||
{
|
{
|
||||||
|
@ -673,13 +690,20 @@ void RefineStep(float _edge_size)
|
||||||
MyTriMesh::FaceIterator finit2=m->face.begin();
|
MyTriMesh::FaceIterator finit2=m->face.begin();
|
||||||
|
|
||||||
if ((vinit2!=vinit)||(finit2!=finit))
|
if ((vinit2!=vinit)||(finit2!=finit))
|
||||||
|
{
|
||||||
Reinit_PVectors();
|
Reinit_PVectors();
|
||||||
else
|
|
||||||
AddNewElements(vend,fend);
|
|
||||||
|
|
||||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);
|
|
||||||
CollDet->RefreshElements();
|
CollDet->RefreshElements();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddNewElements(vend,fend);
|
||||||
|
CollDet->UpdateStep<Part_FaceContainer>(P_Faces);
|
||||||
|
}
|
||||||
|
|
||||||
|
//vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);
|
||||||
|
PartialUpdateNormals();
|
||||||
|
//CollDet->RefreshElements();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///reset vertex position and unblock them
|
///reset vertex position and unblock them
|
||||||
|
@ -688,6 +712,7 @@ void ReinitPhysicMesh()
|
||||||
Part_FaceContainer::iterator pfi;
|
Part_FaceContainer::iterator pfi;
|
||||||
|
|
||||||
for (pfi=P_Faces.begin();pfi<P_Faces.end();++pfi)
|
for (pfi=P_Faces.begin();pfi<P_Faces.end();++pfi)
|
||||||
|
if((!(*pfi).IsD())&&((!(*pfi).intersected)))
|
||||||
(*pfi).Init(k_elanst,mass,k_dihedral);
|
(*pfi).Init(k_elanst,mass,k_dihedral);
|
||||||
|
|
||||||
/*for (MyTriMesh::VertexIterator vi=m.vert.begin();vi<m.vert.end();vi++)
|
/*for (MyTriMesh::VertexIterator vi=m.vert.begin();vi<m.vert.end();vi++)
|
||||||
|
@ -711,14 +736,16 @@ void ClearStopped()
|
||||||
///do one step of controls for self collision detetction
|
///do one step of controls for self collision detetction
|
||||||
void CollisionDetection()
|
void CollisionDetection()
|
||||||
{
|
{
|
||||||
//CollDet->UpdateStep();
|
|
||||||
CollDet->UpdateStep<Part_FaceContainer>(P_Faces);
|
CollDet->UpdateStep<Part_FaceContainer>(P_Faces);
|
||||||
std::vector<MyFace*> coll=CollDet->computeSelfIntersection();
|
std::vector<MyFace*> coll=CollDet->computeSelfIntersection();
|
||||||
for (std::vector<MyFace*>::iterator it=coll.begin();it<coll.end();it++)
|
for (std::vector<MyFace*>::iterator it=coll.begin();it<coll.end();it++)
|
||||||
|
{
|
||||||
|
if (!(*it)->IsD())
|
||||||
{
|
{
|
||||||
SetBlockedFace(*it);
|
SetBlockedFace(*it);
|
||||||
SetIntersectedFace(*it);
|
SetIntersectedFace(*it);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -745,7 +772,7 @@ void LoadFromDir(char *in, char *out)
|
||||||
}
|
}
|
||||||
|
|
||||||
///set parameters for segmentation
|
///set parameters for segmentation
|
||||||
void SetSegmentParameters(int color,int tol,float Mass=0.5f,float K_elanst=0.2f,float Dihedral=0.2f,float Time_stamp=0.2f,
|
void SetSegmentParameters(int tol,float Mass=0.5f,float K_elanst=0.2f,float Dihedral=0.2f,float Time_stamp=0.2f,
|
||||||
float Edge_precision=4.f,Point3f ScaleFactor=Point3f(1.f,1.f,1.f),
|
float Edge_precision=4.f,Point3f ScaleFactor=Point3f(1.f,1.f,1.f),
|
||||||
clock_t _interval=1000,clock_t _interval2=250)
|
clock_t _interval=1000,clock_t _interval2=250)
|
||||||
{
|
{
|
||||||
|
@ -775,17 +802,11 @@ void InitSegmentation(MyTriMesh::CoordType b)
|
||||||
|
|
||||||
TrINT->SetPDESolver(PDESolvers::EULER_METHOD);
|
TrINT->SetPDESolver(PDESolvers::EULER_METHOD);
|
||||||
|
|
||||||
////caso optimized
|
|
||||||
///*V.Resample(inDir,outDir);
|
|
||||||
|
|
||||||
//V.Init(1000,outDir);*/
|
|
||||||
//V.Load(inDir);
|
|
||||||
//
|
|
||||||
/*bbox=vcg::Box3<float>(MapToSpace(V.Min()),MapToSpace(V.Max()));*/
|
|
||||||
|
|
||||||
InitMesh(m);
|
InitMesh(m);
|
||||||
|
|
||||||
//init the mesh with new
|
//init the mesh with new
|
||||||
Reinit_PVectors();
|
Reinit_PVectors();
|
||||||
|
|
||||||
ReinitPhysicMesh();
|
ReinitPhysicMesh();
|
||||||
|
|
||||||
CollDet->Init(bbox.min,bbox.max,5.f);
|
CollDet->Init(bbox.min,bbox.max,5.f);
|
||||||
|
@ -836,10 +857,22 @@ void AutoStep()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////set as deleted intersected vertices
|
||||||
|
//void ClearIntersectedFaces()
|
||||||
|
//{
|
||||||
|
// MyTriMesh::FaceIterator fi;
|
||||||
|
// for (fi=m->face.begin();fi<m->face.end();fi++)
|
||||||
|
// if ((*fi).intersected==true)
|
||||||
|
// (*fi).SetD();
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
///first version
|
///first version
|
||||||
void Resample()
|
void Resample()
|
||||||
{
|
{
|
||||||
|
//ClearIntersectedFaces();
|
||||||
new_m=new MyTriMesh();
|
new_m=new MyTriMesh();
|
||||||
|
vcg::tri::UpdateBounding<MyTriMesh>::Box(*m);
|
||||||
vcg::trimesh::Resampler<MyTriMesh,MyTriMesh>::Resample<vcg::trimesh::RES::MMarchingCubes>(*m,*new_m,
|
vcg::trimesh::Resampler<MyTriMesh,MyTriMesh>::Resample<vcg::trimesh::RES::MMarchingCubes>(*m,*new_m,
|
||||||
Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision));
|
Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision));
|
||||||
|
|
||||||
|
|
|
@ -8,24 +8,42 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1232</width>
|
<width>1100</width>
|
||||||
<height>981</height>
|
<height>974</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>211</width>
|
||||||
|
<height>839</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="caption">
|
<property name="caption">
|
||||||
<string>Segmentation</string>
|
<string>Segmentation</string>
|
||||||
</property>
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
<widget class="QButtonGroup">
|
<widget class="QButtonGroup">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>buttonGroup1</cstring>
|
<cstring>buttonGroup1</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="geometry">
|
<property name="sizePolicy">
|
||||||
<rect>
|
<sizepolicy>
|
||||||
<x>10</x>
|
<hsizetype>7</hsizetype>
|
||||||
<y>0</y>
|
<vsizetype>0</vsizetype>
|
||||||
<width>1030</width>
|
<horstretch>0</horstretch>
|
||||||
<height>50</height>
|
<verstretch>0</verstretch>
|
||||||
</rect>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string></string>
|
<string></string>
|
||||||
|
@ -78,30 +96,6 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>ExternalButton</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>420</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>120</width>
|
|
||||||
<height>31</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>ExternalForces</string>
|
|
||||||
</property>
|
|
||||||
<property name="toggleButton">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton">
|
<widget class="QPushButton">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>BlockedButton</cstring>
|
<cstring>BlockedButton</cstring>
|
||||||
|
@ -180,36 +174,54 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>ExternalButton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>420</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>120</width>
|
||||||
|
<height>31</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ExternalForces</string>
|
||||||
|
</property>
|
||||||
|
<property name="toggleButton">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="SimpleGLWidget">
|
<widget class="SimpleGLWidget">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>simpleGLWidget1</cstring>
|
<cstring>simpleGLWidget1</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="geometry">
|
<property name="sizePolicy">
|
||||||
<rect>
|
<sizepolicy>
|
||||||
<x>0</x>
|
<hsizetype>5</hsizetype>
|
||||||
<y>50</y>
|
<vsizetype>5</vsizetype>
|
||||||
<width>1030</width>
|
<horstretch>0</horstretch>
|
||||||
<height>880</height>
|
<verstretch>0</verstretch>
|
||||||
</rect>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
<widget class="QButtonGroup">
|
<widget class="QButtonGroup">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>buttonGroup2</cstring>
|
<cstring>buttonGroup2</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>1040</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>191</width>
|
|
||||||
<height>930</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy>
|
<sizepolicy>
|
||||||
<hsizetype>0</hsizetype>
|
<hsizetype>0</hsizetype>
|
||||||
<vsizetype>5</vsizetype>
|
<vsizetype>3</vsizetype>
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -478,60 +490,6 @@
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>textLabel1_2_2_2_2</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>30</x>
|
|
||||||
<y>440</y>
|
|
||||||
<width>116</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>Color</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>30</x>
|
|
||||||
<y>460</y>
|
|
||||||
<width>70</width>
|
|
||||||
<height>30</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>LineEditPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>Sunken</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string></string>
|
|
||||||
</property>
|
|
||||||
<property name="cursorPosition">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit">
|
<widget class="QLineEdit">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>E_size</cstring>
|
<cstring>E_size</cstring>
|
||||||
|
@ -742,7 +700,67 @@
|
||||||
<string>tolerance</string>
|
<string>tolerance</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel1_2_2_2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>440</y>
|
||||||
|
<width>116</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>color</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>slider1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>14</x>
|
||||||
|
<y>505</y>
|
||||||
|
<width>170</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>GrayScale</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>14</x>
|
||||||
|
<y>460</y>
|
||||||
|
<width>170</width>
|
||||||
|
<height>31</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>slider.jpg</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
</widget>
|
</widget>
|
||||||
<menubar>
|
<menubar>
|
||||||
<property name="name">
|
<property name="name">
|
||||||
|
@ -784,10 +802,11 @@
|
||||||
<slot access="public" specifier="">SavePly()</slot>
|
<slot access="public" specifier="">SavePly()</slot>
|
||||||
<slot access="public" specifier="">Extract()</slot>
|
<slot access="public" specifier="">Extract()</slot>
|
||||||
<slot access="public" specifier="">Apply()</slot>
|
<slot access="public" specifier="">Apply()</slot>
|
||||||
<slot access="public" specifier="">Clear()</slot>
|
|
||||||
<slot access="public" specifier="">slot()</slot>
|
|
||||||
<slot access="public" specifier="">Open()</slot>
|
<slot access="public" specifier="">Open()</slot>
|
||||||
<slot access="public" specifier="">CleanMesh()</slot>
|
<slot access="public" specifier="">CleanMesh()</slot>
|
||||||
|
<slot access="public" specifier="">Clear()</slot>
|
||||||
|
<slot access="public" specifier="">slot()</slot>
|
||||||
|
<slot access="public" specifier="">SetSegmentColor()</slot>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<actions>
|
<actions>
|
||||||
|
@ -870,7 +889,7 @@
|
||||||
</actions>
|
</actions>
|
||||||
<images>
|
<images>
|
||||||
<image name="image0">
|
<image name="image0">
|
||||||
<data format="XBM.GZ" length="79">789c534e494dcbcc4b554829cdcdad8c2fcf4c29c95030e0524611cd48cd4ccf28010a1797249664262b2467241641a592324b8aa363156c15aab914146aadb90067111b1f</data>
|
<data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154789cad94514c5b5518c77fe7dc4b7b4b6150bb96324418ca32358bee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d6a78d0b027b3cd07d9e68c81c625a6c139408a4384f416100aed6d4b7bdb7b8e0fc0921a70c6ed7b3ae7e43bbff3fffedfc927e2f138bbd1dbdbab7902118fc785d8058f8d8de9aeae2e72b91cb66de338ce7f82e47239666767492412b8aefbf0dcdc553a323242f4501d918e2d3a8f15a9784584100809a609526eafd1a0f54e6142e029c5c21f3ef41583bb77a805efbe1ce9d86279e32619678eaab7853fa0f02a16abb64166ad0cdac75307eb3874b84cb0a14aa5a24108cc0688c48c9a4a1e826ddbe6f0b12219678e8ace610502ccdfafe3f68d3c33bf6c01c59dcc209d472c4e0d35d2f3ba81d205d06005e4de60c77170bd2255af80150870f70e8c0eaf009260a349577714e913a4175d16925b5cbe50607931cc3b677c68ca28a5f7066f5b26f00760febec9e8f032a0e81b68a17fc0201415989647a9d8c4c498cbe8f05f5cff3a4d4bac8bfe210b290b35e01afd428257b1b875cd01aaf4bd1de5dd0fea688e1530ad1c1bab16b7af17393558cf997311c0e49bafd670d6258621f6576c9ab09a3248fe5ae6c08103f49f36517213d33070369bf8e2529ee9c90ceb2b2eef7f14617c2c48722a4b7226845143fa87622905ebeb6514253a9eb5084504a66950c88618bee0303d99217cb09e9ed71a09369538fa523d00e9a50a42eed3bc6d8f41281fa0903e8561796cac86f8f2b33c33930ea0f0fb4d5adbeb30ad22866ffbbad226d2a805d7ee0484220208925aaa50deaa67e27b97e9c90ccdcdf5c462cdd8a94d2e7e62f3603244ea410989a4ed191f52a8fd156b056d9d553a9e0bf0e7ef45c6bf7339fd5e90ec7a88575e6d20d6e6e7e2a755ec854dce7fb8885b2cd014f6f3c2714d3a550bae55ac35c1068fb7061b00b87a7995899b25ce9e0b73e24d8fae97b37c7cbe9370b499fce6066eb54adf6098f6ee2a9a7ff9c70841a5023d270deca510d746537c7e29cdf8ad20475fb4307c82d4fc324ec6859d66fdfc6381e44014b36e9fe6e572393ca54068aa22cfd0598b686b3737aeae90bc9725796f0350802414b6e81b7c9a9f7e70708a2e6e5991cfeee3f1ecec2c0b0b3e8c068142a2a8d23728397132c6dc6f2e2b8b0a8da4b5ddc7f3c735ed47146f0cb4502983693a4c25ca7b83138904fa8a412466e00f48b4271086c2901263676c4a6990b615b6ade15b85694af239984a94585bf6f606bbae5b334f1f37e4a3531e031c8fc7c5a312ff17f849c3e3f1b8f81b8be6900aca9b61c90000000049454e44ae426082</data>
|
||||||
</image>
|
</image>
|
||||||
</images>
|
</images>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -958,9 +977,15 @@
|
||||||
<receiver>simpleGLWidget1</receiver>
|
<receiver>simpleGLWidget1</receiver>
|
||||||
<slot>Clear()</slot>
|
<slot>Clear()</slot>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>slider1</sender>
|
||||||
|
<signal>sliderMoved(int)</signal>
|
||||||
|
<receiver>simpleGLWidget1</receiver>
|
||||||
|
<slot>SetSegmentColor()</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<pixmapinproject/>
|
<pixmapinproject/>
|
||||||
<layoutdefaults spacing="6" margin="11"/>
|
<layoutdefaults spacing="2" margin="4"/>
|
||||||
<includehints>
|
<includehints>
|
||||||
<includehint>simpleglwidget.h</includehint>
|
<includehint>simpleglwidget.h</includehint>
|
||||||
</includehints>
|
</includehints>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <qimage.h>
|
#include <qimage.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox.h>
|
||||||
|
#include <qslider.h>
|
||||||
|
|
||||||
extern Segmentator *s;
|
extern Segmentator *s;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ void SimpleGLWidget::LoadTexture(QString p,int level)
|
||||||
QString PathFile=Path;
|
QString PathFile=Path;
|
||||||
PathFile.append(Qd[level]);
|
PathFile.append(Qd[level]);
|
||||||
|
|
||||||
bool b=qI.load(PathFile,qformat);
|
qI.load(PathFile,qformat);
|
||||||
QImage tx = QGLWidget::convertToGLFormat (qI);
|
QImage tx = QGLWidget::convertToGLFormat (qI);
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ void drawForces(Segmentator::Part_VertexContainer *pv,int typeForce)
|
||||||
{
|
{
|
||||||
Segmentator::Part_VertexContainer::iterator vi;
|
Segmentator::Part_VertexContainer::iterator vi;
|
||||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
glLineWidth(0.3);
|
glLineWidth(0.3f);
|
||||||
glDisable(GL_NORMALIZE);
|
glDisable(GL_NORMALIZE);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
||||||
|
@ -169,7 +170,7 @@ else
|
||||||
if (typeForce==2)
|
if (typeForce==2)
|
||||||
glColor3d(0,1,0);
|
glColor3d(0,1,0);
|
||||||
|
|
||||||
for (vi=pv->begin();vi<pv->end();vi++)
|
for (vi=pv->begin();vi<pv->end();++vi)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
vcg::glVertex((*vi).P());
|
vcg::glVertex((*vi).P());
|
||||||
|
@ -262,8 +263,7 @@ void SimpleGLWidget::SmoothMesh()
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleGLWidget::glDraw(){
|
void SimpleGLWidget::glDraw(){
|
||||||
|
glClearColor(0.2f,0.2f,0.2f,1.f);
|
||||||
glClearColor(0.2,0.2,0.2,1);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -336,11 +336,12 @@ void SimpleGLWidget::glDraw(){
|
||||||
else
|
else
|
||||||
glPolygonMode(GL_FRONT,GL_FILL);
|
glPolygonMode(GL_FRONT,GL_FILL);
|
||||||
|
|
||||||
int i=0;
|
|
||||||
if (s->m!=NULL)
|
if (s->m!=NULL)
|
||||||
{
|
{
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
for (fi=s->m->face.begin();fi<s->m->face.end();fi++)
|
for (fi=s->m->face.begin();fi<s->m->face.end();fi++)
|
||||||
|
{
|
||||||
|
if(!(*fi).IsD())
|
||||||
{
|
{
|
||||||
glColor3d(0.4,0.8,0.8);
|
glColor3d(0.4,0.8,0.8);
|
||||||
if (fi->intersected)
|
if (fi->intersected)
|
||||||
|
@ -348,17 +349,27 @@ void SimpleGLWidget::glDraw(){
|
||||||
|
|
||||||
if (((blocked)&&(!fi->IsBlocked()))||(!blocked))
|
if (((blocked)&&(!fi->IsBlocked()))||(!blocked))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!wire)
|
if (!wire)
|
||||||
vcg::glNormal(fi->Normal());
|
{
|
||||||
|
vcg::glNormal(fi->V(0)->N());
|
||||||
|
vcg::glVertex(fi->V(0)->P());
|
||||||
|
vcg::glNormal(fi->V(1)->N());
|
||||||
|
vcg::glVertex(fi->V(1)->P());
|
||||||
|
vcg::glNormal(fi->V(2)->N());
|
||||||
|
vcg::glVertex(fi->V(2)->P());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vcg::glVertex(fi->V(0)->P());
|
vcg::glVertex(fi->V(0)->P());
|
||||||
vcg::glVertex(fi->V(1)->P());
|
vcg::glVertex(fi->V(1)->P());
|
||||||
vcg::glVertex(fi->V(2)->P());
|
vcg::glVertex(fi->V(2)->P());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
//WriteInfo();
|
//WriteInfo();
|
||||||
|
|
||||||
|
@ -442,13 +453,11 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e )
|
||||||
//LoadMatrix();
|
//LoadMatrix();
|
||||||
glReadPixels(e->x(),_H-e->y(),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&winz);
|
glReadPixels(e->x(),_H-e->y(),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&winz);
|
||||||
gluUnProject(e->x(),_H-e->y(),winz,modelMatrix,projection,viewport,&x,&y,&z);
|
gluUnProject(e->x(),_H-e->y(),winz,modelMatrix,projection,viewport,&x,&y,&z);
|
||||||
QString color="";
|
|
||||||
color.sprintf("%i",s->gray_init);
|
|
||||||
//w->Color->text()=color;
|
|
||||||
SetExtractionParameters();
|
SetExtractionParameters();
|
||||||
//s->SetInitialBarycenter(Point3f(x,y,_numslide));
|
|
||||||
//s->InitSegmentation(Point3f(x,y,_numslide));
|
|
||||||
s->InitSegmentation(Point3f(x,y,z));
|
s->InitSegmentation(Point3f(x,y,z));
|
||||||
|
w->slider1->setValue(s->gray_init);
|
||||||
|
|
||||||
UpdateBBMesh();
|
UpdateBBMesh();
|
||||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
||||||
repaint();
|
repaint();
|
||||||
|
@ -456,6 +465,11 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e )
|
||||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(s->m);
|
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(s->m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleGLWidget::setColor()
|
||||||
|
{
|
||||||
|
s->gray_init=w->slider1->value();
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
if (!_showslides)
|
if (!_showslides)
|
||||||
|
@ -520,7 +534,7 @@ void SimpleGLWidget::SetExtractionParameters()
|
||||||
//int color =atoi(w->Color->text());
|
//int color =atoi(w->Color->text());
|
||||||
///to modify
|
///to modify
|
||||||
|
|
||||||
s->SetSegmentParameters(s->gray_init,tolerance,mass,k_elanst,dihedral,timestep,edge,Point3f(1.f,1.f,dinstance));
|
s->SetSegmentParameters(tolerance,mass,k_elanst,dihedral,timestep,edge,Point3f(1.f,1.f,dinstance));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e )
|
void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e )
|
||||||
|
@ -536,7 +550,7 @@ void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e )
|
||||||
|
|
||||||
void SimpleGLWidget::initializeGL(){
|
void SimpleGLWidget::initializeGL(){
|
||||||
|
|
||||||
GLfloat f[4]={0.2,0.2,0.2,1.f};
|
GLfloat f[4]={0.2f,0.2f,0.2f,1.f};
|
||||||
GLfloat p[4]={3,3,5,0};
|
GLfloat p[4]={3,3,5,0};
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT,f);
|
glLightfv(GL_LIGHT0, GL_AMBIENT,f);
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION,p);
|
glLightfv(GL_LIGHT1, GL_POSITION,p);
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
void OpenDirectory();
|
void OpenDirectory();
|
||||||
void MarchingCube();
|
void MarchingCube();
|
||||||
void UpdateBBMesh();
|
void UpdateBBMesh();
|
||||||
|
void setColor();
|
||||||
|
|
||||||
//virtual void keyPressEvent(QKeyEvent *qk);
|
//virtual void keyPressEvent(QKeyEvent *qk);
|
||||||
|
|
||||||
|
@ -164,4 +165,8 @@ public:
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetSegmentColor()
|
||||||
|
{
|
||||||
|
setColor();
|
||||||
|
}
|
||||||
};
|
};
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef _SEG3D_VOLUMEDATASET
|
||||||
|
#define _SEG3D_VOLUMEDATASET
|
||||||
|
|
||||||
#include <qimage.h>
|
#include <qimage.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
@ -481,3 +483,4 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
#endif
|
Loading…
Reference in New Issue