some modifications
This commit is contained in:
parent
c618354a24
commit
dcfa1f4bad
|
@ -17,7 +17,7 @@ int main( int argc, char ** argv )
|
|||
//s->LoadFromDir("./venacava/","prova.txt");//to chANGE
|
||||
|
||||
//s->InitSegmentation(0.5,0.2,20,10.f);
|
||||
//
|
||||
|
||||
QApplication a( argc, argv );
|
||||
|
||||
SegmentForm w;
|
||||
|
@ -26,12 +26,19 @@ int main( int argc, char ** argv )
|
|||
//assign pointer to pricipal form
|
||||
w.simpleGLWidget1->w=&w;
|
||||
|
||||
#ifdef _TORUS
|
||||
w.simpleGLWidget1->SetExtractionParameters();
|
||||
s->BBox().min=Point3f(0.f,0.f,0.f);
|
||||
s->BBox().max=Point3f(300.f,300.f,300.f);
|
||||
s->InitSegmentation(Point3f(0.f,100.f,0.f));
|
||||
#endif
|
||||
|
||||
/*s=new Segmentator();*/
|
||||
|
||||
//s->LoadFromDir("./venacava/","prova.txt");//to chANGE
|
||||
|
||||
//s->InitSegmentation(0.5,0.2,20,10.f);
|
||||
|
||||
////s->InitSegmentation(0.5,0.2,20,10.f);
|
||||
//w.simpleGLWidget1->path="./venacava/";
|
||||
|
||||
timer = new QTimer(w.simpleGLWidget1 );
|
||||
QTimer::connect( timer, SIGNAL(timeout()), w.simpleGLWidget1, SLOT(Update()) );
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
/****************************************************************************
|
||||
* 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
|
|
@ -0,0 +1,29 @@
|
|||
TEMPLATE = app
|
||||
LANGUAGE = C++
|
||||
|
||||
CONFIG += qt warn_on release
|
||||
|
||||
|
||||
FORMS = segmentform.ui
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unix {
|
||||
UI_DIR = .ui
|
||||
MOC_DIR = .moc
|
||||
OBJECTS_DIR = .obj
|
||||
}
|
||||
|
||||
|
|
@ -234,6 +234,21 @@ private:
|
|||
return (MyTriMesh::CoordType(x,y,z));
|
||||
}
|
||||
|
||||
#ifdef _TORUS
|
||||
///torus version
|
||||
float getColor(MyTriMesh::CoordType p)
|
||||
{
|
||||
static float ray=100.f;
|
||||
static float diameter=20.f;
|
||||
Point3f center=BBox().Center();
|
||||
float dist=(p-center).Norm();
|
||||
float difference=abs(ray-dist);
|
||||
if(difference<diameter)
|
||||
return 100.f;
|
||||
else
|
||||
return (100.f+difference*5.f);
|
||||
}
|
||||
#else
|
||||
///return integer coordinete in volumetric dataset
|
||||
float getColor(MyTriMesh::CoordType p)
|
||||
{
|
||||
|
@ -262,6 +277,7 @@ private:
|
|||
|
||||
return color;
|
||||
}
|
||||
#endif
|
||||
|
||||
///maximixe the gradient of the movement
|
||||
MyTriMesh::CoordType Gradient(MyTriMesh::CoordType p,float h=0.01f)
|
||||
|
@ -307,13 +323,11 @@ private:
|
|||
///return true if a coordinate is out of limits
|
||||
bool OutOfLimits(MyTriMesh::CoordType p)
|
||||
{
|
||||
/*Point3f max=Scale(MapToSpace(V.Max()));
|
||||
Point3f min=Scale(MapToSpace(V.Min()));
|
||||
Point3f test=(Scale(p));*/
|
||||
Point3f test=p;
|
||||
Point3f max=UnScale(MapToSpace(V.Max()));
|
||||
Point3f min=UnScale(MapToSpace(V.Min()));
|
||||
|
||||
/*Point3f max=UnScale(MapToSpace(V.Max()));
|
||||
Point3f min=UnScale(MapToSpace(V.Min()));*/
|
||||
Point3f max=BBox().max;//last change
|
||||
Point3f min=BBox().min;//last change
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
if(((test.V(i)>=max.V(i))||(test.V(i)<=min.V(i))))
|
||||
|
@ -430,6 +444,7 @@ MyTriMesh::CoordType GradientFactor(MyTriMesh::VertexType *v)
|
|||
}
|
||||
|
||||
///add the external forces to the deformable mesh
|
||||
|
||||
void AddExtForces()
|
||||
{
|
||||
Part_VertexContainer::iterator vi;
|
||||
|
@ -682,8 +697,10 @@ void SetSegmentParameters(int color,int tol,float Mass=0.5f,float K_elanst=0.2f,
|
|||
time_stamp=Time_stamp;
|
||||
k_dihedral=Dihedral;
|
||||
scale=ScaleFactor;
|
||||
bbox=vcg::Box3<float>(UnScale(MapToSpace(V.Min())),(UnScale(MapToSpace(V.Max()))));//last change!
|
||||
}
|
||||
|
||||
|
||||
///init the segmentation of the mesh
|
||||
void InitSegmentation(MyTriMesh::CoordType b)
|
||||
{
|
||||
|
@ -708,8 +725,6 @@ void InitSegmentation(MyTriMesh::CoordType b)
|
|||
ReinitPhysicMesh();
|
||||
|
||||
CollDet->Init(bbox.min,bbox.max,5.f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
///return the bounding box of the mesh
|
||||
|
@ -740,7 +755,7 @@ void Step(float t,float _edge_size)
|
|||
|
||||
void Smooth()
|
||||
{
|
||||
ScaleLaplacianSmooth<MyTriMesh>(m,2,0.5);
|
||||
ScaleLaplacianSmooth<MyTriMesh>(m,1,0.5);
|
||||
}
|
||||
|
||||
void AutoStep()
|
||||
|
|
|
@ -30,30 +30,6 @@
|
|||
<property name="title">
|
||||
<string></string>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SlidesButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Slides</string>
|
||||
</property>
|
||||
<property name="toggleButton">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>ResultButton</cstring>
|
||||
|
@ -150,6 +126,30 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SlidesButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Slides</string>
|
||||
</property>
|
||||
<property name="toggleButton">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>WireButton</cstring>
|
||||
|
@ -196,243 +196,6 @@
|
|||
<property name="title">
|
||||
<string></string>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SaveButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>560</y>
|
||||
<width>140</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SavePly</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SmoothButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>520</y>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursor>1</cursor>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smooth</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SegmentButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>480</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extract</string>
|
||||
</property>
|
||||
<property name="toggleButton">
|
||||
<bool>true</bool>
|
||||
</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>390</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="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>370</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>Tolerance</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>330</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>310</y>
|
||||
<width>116</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>tolerance</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>E_size</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>270</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>250</y>
|
||||
<width>116</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>minimum edge size</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>T_step</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>210</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.2</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
|
@ -598,27 +361,6 @@
|
|||
<string>mass of particles</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>ApplyButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>440</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>ClearButton</cstring>
|
||||
|
@ -626,7 +368,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>600</y>
|
||||
<y>700</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
|
@ -640,6 +382,315 @@
|
|||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SaveButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>660</y>
|
||||
<width>140</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SavePly</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SmoothButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>620</y>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursor>1</cursor>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smooth</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SegmentButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>580</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extract</string>
|
||||
</property>
|
||||
<property name="toggleButton">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>ApplyButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>540</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2_3</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>300</y>
|
||||
<width>140</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Slide dinstance (pixel)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>250</y>
|
||||
<width>116</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>minimum edge size</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>S_dist</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>340</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>380</y>
|
||||
<width>116</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>tolerance</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>Tolerance</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>400</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</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">
|
||||
<property name="name">
|
||||
<cstring>E_size</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>270</y>
|
||||
<width>70</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>T_step</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>210</y>
|
||||
<width>70</width>
|
||||
<height>31</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>0.2</string>
|
||||
</property>
|
||||
<property name="cursorPosition">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="SimpleGLWidget">
|
||||
<property name="name">
|
||||
|
@ -648,7 +699,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<y>50</y>
|
||||
<width>1030</width>
|
||||
<height>880</height>
|
||||
</rect>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <SimpleGLWidget.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qimage.h>
|
||||
#include <qdir.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
|
@ -23,6 +24,7 @@ QGLWidget(parent, name)
|
|||
Track.Reset();
|
||||
Track.radius= 100;
|
||||
zoom=1;
|
||||
path="";
|
||||
}
|
||||
|
||||
void SimpleGLWidget::SaveMatrix()
|
||||
|
@ -40,35 +42,102 @@ void SimpleGLWidget::LoadMatrix()
|
|||
glLoadMatrixd(modelMatrix);
|
||||
}
|
||||
|
||||
//load as texture the i jpg of the directory
|
||||
void SimpleGLWidget::LoadTexture(QString p,int level)
|
||||
{
|
||||
QImage qI=QImage();
|
||||
QDir Qd=QDir(p);
|
||||
QString qformat;
|
||||
QString Path=QString(p);
|
||||
Qd.setNameFilter("*.jpg");
|
||||
|
||||
Qd.setSorting(QDir::Name);
|
||||
QString PathFile=Path;
|
||||
PathFile.append(Qd[level]);
|
||||
|
||||
bool b=qI.load(PathFile,qformat);
|
||||
QImage tx = QGLWidget::convertToGLFormat (qI);
|
||||
|
||||
|
||||
glGenTextures(1, &texName);
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, 3, tx.width(), tx.height(), 0,GL_RGBA, GL_UNSIGNED_BYTE, tx.bits() );
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||
|
||||
}
|
||||
|
||||
void SimpleGLWidget::drawSlide()
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
for (int x=0;x<((s->V.dimX())-1);x++)
|
||||
for (int y=0;y<((s->V.dimY())-1);y++)
|
||||
{
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPolygonMode(GL_FRONT,GL_FILL);
|
||||
glMatrixMode (GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
float dx=s->BBox().DimX();
|
||||
float dy=s->BBox().DimY();
|
||||
|
||||
//to change take scale from segmentator.. better!
|
||||
float n=atof(w->S_dist->text());
|
||||
float level=((float)_numslide)*n;
|
||||
|
||||
Point3f p0=s->BBox().min;
|
||||
p0+=Point3f(0.f,0.f,level);
|
||||
|
||||
Point3f p1=p0+Point3f(dx,0.f,0.f);
|
||||
Point3f p2=p0+Point3f(dx,dy,0.f);
|
||||
Point3f p3=p0+Point3f(0.f,dy,0.f);
|
||||
|
||||
glColor3d(1,1,1);
|
||||
|
||||
///texture
|
||||
//_numslide
|
||||
glBegin(GL_QUADS);
|
||||
glNormal(Point3d(0,0,1));
|
||||
Point3<int> p0=Point3<int>(x,y,_numslide);
|
||||
double color=((double)s->V.getAt(p0))/256.f;
|
||||
glColor3d(color,color,color);
|
||||
glTexCoord(Point3f(0,1,0));
|
||||
glVertex(p0);
|
||||
|
||||
Point3<int> p1=Point3<int>(x+1,y,_numslide);
|
||||
color=((double)s->V.getAt(p1))/256.f;
|
||||
glColor3d(color,color,color);
|
||||
glTexCoord(Point3f(1,1,0));
|
||||
glVertex(p1);
|
||||
|
||||
Point3<int> p2=Point3<int>(x+1,y+1,_numslide);
|
||||
color=((double)s->V.getAt(p2))/256.f;
|
||||
glColor3d(color,color,color);
|
||||
glTexCoord(Point3f(1,0,0));
|
||||
glVertex(p2);
|
||||
|
||||
Point3<int> p3=Point3<int>(x,y+1,_numslide);
|
||||
color=((double)s->V.getAt(p3))/256.f;
|
||||
glColor3d(color,color,color);
|
||||
glTexCoord(Point3f(0,0,0));
|
||||
glVertex(p3);
|
||||
}
|
||||
glEnd();
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
|
||||
//glBegin(GL_QUADS);
|
||||
//for (int x=0;x<((s->V.dimX())-1);x++)
|
||||
// for (int y=0;y<((s->V.dimY())-1);y++)
|
||||
// {
|
||||
// glNormal(Point3d(0,0,1));
|
||||
// Point3<int> p0=Point3<int>(x,y,_numslide);
|
||||
// double color=((double)s->V.getAt(p0))/256.f;
|
||||
// glColor3d(color,color,color);
|
||||
// glVertex(p0);
|
||||
//
|
||||
// Point3<int> p1=Point3<int>(x+1,y,_numslide);
|
||||
// color=((double)s->V.getAt(p1))/256.f;
|
||||
// glColor3d(color,color,color);
|
||||
// glVertex(p1);
|
||||
//
|
||||
// Point3<int> p2=Point3<int>(x+1,y+1,_numslide);
|
||||
// color=((double)s->V.getAt(p2))/256.f;
|
||||
// glColor3d(color,color,color);
|
||||
// glVertex(p2);
|
||||
//
|
||||
// Point3<int> p3=Point3<int>(x,y+1,_numslide);
|
||||
// color=((double)s->V.getAt(p3))/256.f;
|
||||
// glColor3d(color,color,color);
|
||||
// glVertex(p3);
|
||||
// }
|
||||
//glEnd();
|
||||
}
|
||||
|
||||
void drawForces(Segmentator::Part_VertexContainer *pv,int typeForce)
|
||||
|
@ -115,8 +184,8 @@ void SimpleGLWidget::Save()
|
|||
"Choose a filename to save under" );
|
||||
if (filename!=NULL)
|
||||
{
|
||||
const char *path=filename.ascii();
|
||||
vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save(s->m,path);
|
||||
const char *path_save=filename.ascii();
|
||||
vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save(s->m,path_save);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -202,7 +271,7 @@ void SimpleGLWidget::glDraw(){
|
|||
Track.GetView();
|
||||
Track.Apply();
|
||||
Track.Draw();
|
||||
glScalef(1/s->BBox().Diag(),1/s->BBox().Diag(),1/s->BBox().Diag());
|
||||
glScalef(1.f/s->BBox().Diag(),1.f/s->BBox().Diag(),1.f/s->BBox().Diag());
|
||||
glScalef(GLfloat(zoom),GLfloat(zoom),GLfloat(zoom));
|
||||
glTranslate(-p);
|
||||
//save transformation matrixes
|
||||
|
@ -240,6 +309,7 @@ void SimpleGLWidget::glDraw(){
|
|||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
Segmentator::MyTriMesh::FaceIterator fi;
|
||||
|
||||
|
@ -292,9 +362,14 @@ void SimpleGLWidget::OpenDirectory()
|
|||
if (filename!=NULL)
|
||||
{
|
||||
filename+="/";
|
||||
const char *path=filename.ascii();
|
||||
char *p=(char*)path;
|
||||
path=filename;
|
||||
const char *pa=filename.ascii();
|
||||
char *p=(char*)pa;
|
||||
s->LoadFromDir(p,"prova.txt");
|
||||
LoadTexture(p,0);
|
||||
_showslides=true;
|
||||
w->SlidesButton->setOn(true);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,7 +415,8 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e )
|
|||
//w->Color->text()=color;
|
||||
SetExtractionParameters();
|
||||
//s->SetInitialBarycenter(Point3f(x,y,_numslide));
|
||||
s->InitSegmentation(Point3f(x,y,_numslide));
|
||||
//s->InitSegmentation(Point3f(x,y,_numslide));
|
||||
s->InitSegmentation(Point3f(x,y,z));
|
||||
repaint();
|
||||
}
|
||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(s->m);
|
||||
|
@ -359,6 +435,10 @@ void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
|||
_numslide+=e->delta()/120.f;
|
||||
if ((_numslide<0)||(_numslide>=s->V.dimZ()))
|
||||
_numslide=oldnum;
|
||||
if (s!=0)
|
||||
{
|
||||
LoadTexture(path,_numslide);
|
||||
}
|
||||
}
|
||||
|
||||
repaint();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
#include <segmentform.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
class SimpleGLWidget: public QGLWidget{
|
||||
|
||||
|
@ -29,10 +30,12 @@ private :
|
|||
bool intForces;
|
||||
bool resultForces;
|
||||
bool continue_int;
|
||||
GLuint texName;
|
||||
|
||||
//vcg::GlTrimesh<Segmentator::MyTriMesh> *Wrap;
|
||||
|
||||
public:
|
||||
QString path;
|
||||
SegmentForm *w;
|
||||
SimpleGLWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 );
|
||||
|
||||
|
@ -48,6 +51,7 @@ public:
|
|||
virtual void SaveMatrix();
|
||||
virtual void Save();
|
||||
void LoadMatrix();
|
||||
void LoadTexture(QString path,int level);
|
||||
void drawSlide();
|
||||
void SmoothMesh();
|
||||
void Step();
|
||||
|
@ -121,6 +125,16 @@ public:
|
|||
void Extract()
|
||||
{
|
||||
continue_int=!continue_int;
|
||||
if (continue_int)
|
||||
{
|
||||
_showslides=false;
|
||||
w->SlidesButton->setOn(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_showslides=true;
|
||||
w->SlidesButton->setOn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
|
Loading…
Reference in New Issue