minor changes
This commit is contained in:
parent
8722c1dbc2
commit
28da494fe3
|
@ -61,7 +61,7 @@ public:
|
|||
bool TestRealIntersection(SimplexType *f0,SimplexType *f1)
|
||||
{
|
||||
|
||||
if ((!f0->IsActive())&&(!f1->IsActive()))
|
||||
if (((!f0->IsActive())&&(!f1->IsActive()))||(f0->IsD())||(f1->IsD()))
|
||||
return false;
|
||||
//no adiacent faces
|
||||
if ((f0!=f1)&& (!ShareEdge(f0,f1))
|
||||
|
@ -70,25 +70,51 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
///refresh the elemnt of spatial hashing table
|
||||
///refresh all the elements of spatial hashing table
|
||||
///this function must called sometimes
|
||||
void RefreshElements()
|
||||
{
|
||||
HTable->Clear();
|
||||
|
||||
vactive.clear();///new
|
||||
for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||
{
|
||||
if ((!(*si).IsD())&&(!(*si).IsActive()))
|
||||
HTable->addSimplex(&*si);
|
||||
///new now
|
||||
else
|
||||
{
|
||||
std::vector<Point3i> cells=HTable->addSimplex(&*si);
|
||||
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
vactive.insert(*it);
|
||||
}
|
||||
///end new now
|
||||
}
|
||||
|
||||
UpdateStep();
|
||||
//UpdateStep(); commented now
|
||||
}
|
||||
|
||||
/////put active cells on apposite structure
|
||||
//void UpdateStep()
|
||||
//{
|
||||
// vactive.clear();
|
||||
// for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||
// {
|
||||
// if ((((!(*si).IsD()))&&(*si).IsActive()))
|
||||
// {
|
||||
// std::vector<Point3i> cells=HTable->addSimplex(&*si);
|
||||
// for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
// vactive.insert(*it);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
///put active cells on apposite structure
|
||||
void UpdateStep()
|
||||
template <class Container_Type>
|
||||
void UpdateStep(Container_Type &simplex)
|
||||
{
|
||||
vactive.clear();
|
||||
for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||
for (Container_Type::iterator si=simplex.begin();si<simplex.end();++si)
|
||||
{
|
||||
if ((((!(*si).IsD()))&&(*si).IsActive()))
|
||||
{
|
||||
|
@ -99,6 +125,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
///control the real self intersection in the mesh and returns the elements that intersect with someone
|
||||
std::vector<SimplexType*> computeSelfIntersection()
|
||||
{
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
#include <qapplication.h>
|
||||
#include <qimage.h>
|
||||
#include <segmentform.h>
|
||||
#include <segmentator.h>
|
||||
//#include <segmentator.h>
|
||||
#include <qdir.h>
|
||||
#include <qcolor.h>
|
||||
#include <SimpleGLWidget.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
|
||||
Segmentator *s;
|
||||
QTimer *timer;
|
||||
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
s=new Segmentator();
|
||||
|
@ -26,6 +28,7 @@ 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);
|
||||
|
@ -33,6 +36,7 @@ int main( int argc, char ** argv )
|
|||
s->InitSegmentation(Point3f(0.f,100.f,0.f));
|
||||
#endif
|
||||
|
||||
|
||||
/*s=new Segmentator();*/
|
||||
|
||||
//s->LoadFromDir("./venacava/","prova.txt");//to chANGE
|
||||
|
|
|
@ -3,7 +3,16 @@ LANGUAGE = C++
|
|||
|
||||
CONFIG += qt warn_on release
|
||||
|
||||
win32:LIBS += qt-mt332.lib qtmain.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib imm32.lib winmm.lib wsock32.lib winspool.lib delayimp.lib opengl32.lib glu32.lib glew32.lib
|
||||
DEFINES += QT_NO_DEBUG _WINDOWS UNICODE WIN32 QT_DLL QT_THREAD_SUPPORT _TORUS01 _EXTENDED_MARCH1
|
||||
win32:DEFINES += QT_NO_DEBUG _WINDOWS UNICODE WIN32 QT_DLL QT_THREAD_SUPPORT _TORUS01 _EXTENDED_MARCH1
|
||||
win32:INCLUDEPATH += "$(QTDIR)\include" . "C:\Qt\3.3.2\mkspecs\win32-msvc.net" D:\sf\apps\test\segmentation3d D:\sf
|
||||
|
||||
SOURCES += D:/sf/wrap/gui/trackmode.cpp \
|
||||
D:/sf/wrap/gui/trackball.cpp \
|
||||
D:/sf/wrap/ply/plylib.cpp \
|
||||
simpleglwidget.cpp \
|
||||
main.cpp
|
||||
FORMS = segmentform.ui
|
||||
|
||||
|
||||
|
@ -20,6 +29,154 @@ FORMS = segmentform.ui
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unix {
|
||||
UI_DIR = .ui
|
||||
MOC_DIR = .moc
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
#ifndef SEGMENTATOR
|
||||
#define SEGMENTATOR
|
||||
#ifndef __SEGMENTATOR
|
||||
#define __SEGMENTATOR
|
||||
|
||||
//#include <vcg/simplex/vertex/with/afvn.h>
|
||||
//#include <vcg/simplex/face/with/afav.h>
|
||||
|
||||
///need vertex-face topology in case of extended marching cubes
|
||||
#ifdef _EXTENDED_MARCH
|
||||
#include <vcg/simplex/vertex/with/afvn.h>
|
||||
#include <vcg/simplex/face/with/afavfnfmrt.h>
|
||||
#else
|
||||
#include <vcg/simplex/vertex/with/vn.h>
|
||||
#include <vcg/simplex/face/with/af.h>
|
||||
#include <vcg/simplex/face/with/afavfnfmrt.h>
|
||||
#endif
|
||||
|
||||
#include <sim/particle/with/basic_physics.h>
|
||||
#include <sim/methods/mass_spring/triangle.h>
|
||||
|
@ -15,13 +19,26 @@
|
|||
#include <vcg/complex/trimesh/allocate.h>
|
||||
#include <vcg/complex/trimesh/update/topology.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/update/edges.h>
|
||||
|
||||
#include <vcg/complex/trimesh/refine.h>
|
||||
#include <vcg/complex/trimesh/platonic.h>
|
||||
#include <vcg/complex/trimesh/create/platonic.h>
|
||||
#include <volume_dataset.h>
|
||||
|
||||
//#include <vcg/simplex/face/pos.h>
|
||||
|
||||
///marching cubes
|
||||
|
||||
//#include <segmentation_wolker.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/box3.h>
|
||||
|
@ -34,6 +51,10 @@
|
|||
#include <collision_detection.h>
|
||||
#include <vcg/complex/trimesh/smooth.h>
|
||||
|
||||
///debugghe
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
///debugghe
|
||||
|
||||
class Segmentator{
|
||||
|
||||
public:
|
||||
|
@ -42,7 +63,11 @@ struct DummyEdge;
|
|||
struct DummyTetra;
|
||||
struct MyFace;
|
||||
|
||||
#ifdef _EXTENDED_MARCH
|
||||
struct MyVertex: public ParticleBasic<vcg::VertexAFVNf<DummyEdge,MyFace,DummyTetra> >
|
||||
#else
|
||||
struct MyVertex: public ParticleBasic<vcg::VertexVNf<DummyEdge,MyFace,DummyTetra> >
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -55,6 +80,7 @@ public:
|
|||
stopped=false;
|
||||
Acc()=Point3f(0,0,0);
|
||||
Vel()=Point3f(0,0,0);
|
||||
ClearFlags();
|
||||
//neeed call of the super class
|
||||
}
|
||||
|
||||
|
@ -82,7 +108,7 @@ public:
|
|||
};
|
||||
|
||||
///this class implements the deformable triangle in a mass spring system
|
||||
struct MyFace : public TriangleMassSpring< vcg::FaceAF<MyVertex,DummyEdge,MyFace> >
|
||||
struct MyFace : public TriangleMassSpring< vcg::FaceAFAVFNFMRT<MyVertex,DummyEdge,MyFace> >
|
||||
{
|
||||
public:
|
||||
bool intersected;
|
||||
|
@ -163,11 +189,25 @@ typedef PDEIntegrator<Part_FaceContainer,Part_VertexContainer,float> myIntegrat
|
|||
typedef Collision_Detector<std::vector<MyFace> > Collision;
|
||||
|
||||
|
||||
////typedef Walker<MyTriMesh,MyTriMesh> MyWalk;
|
||||
//
|
||||
//#ifdef _EXTENDED_MARCH
|
||||
// typedef vcg::tri::ExtendedMarchingCubes<MyTriMesh, MyWalk> MarchingCubes;
|
||||
//#else
|
||||
// typedef vcg::tri::MarchingCubes<MyTriMesh, MyWalk> MarchingCubes;
|
||||
//#endif
|
||||
|
||||
|
||||
public:
|
||||
Point3f scale;
|
||||
|
||||
//VolumetricDataset<int> d;
|
||||
MyTriMesh m;
|
||||
/*MyTriMesh m;
|
||||
MyTriMesh new_m;*/
|
||||
|
||||
MyTriMesh *m;
|
||||
MyTriMesh *new_m;
|
||||
|
||||
Part_FaceContainer P_Faces;
|
||||
Part_VertexContainer P_Vertex;
|
||||
Part_VertexContainer V_Stopped;
|
||||
|
@ -206,7 +246,29 @@ public:
|
|||
|
||||
Segmentator()
|
||||
{
|
||||
CollDet=new Collision(m.face);
|
||||
m=new MyTriMesh();
|
||||
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()
|
||||
|
@ -384,33 +446,34 @@ private:
|
|||
///re-set physical pararmeters on the mesh
|
||||
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);
|
||||
m->face[i].Init(k_elanst,mass,k_dihedral);
|
||||
}
|
||||
}
|
||||
|
||||
///set the initial mesh of deformable object
|
||||
void InitMesh(MyTriMesh &m)
|
||||
void InitMesh(MyTriMesh *m)
|
||||
{
|
||||
m.Clear();
|
||||
m->Clear();
|
||||
|
||||
vcg::tri::Icosahedron<MyTriMesh>(m);
|
||||
vcg::tri::Icosahedron<MyTriMesh>(*m);
|
||||
|
||||
vcg::tri::UpdateTopology<MyTriMesh>::FaceFace(m);
|
||||
vcg::tri::UpdateTopology<MyTriMesh>::FaceFace(*m);
|
||||
|
||||
/* P_Vertex.clear();
|
||||
P_Faces.clear();*/
|
||||
|
||||
for (unsigned int i=0;i<m.vert.size();i++)
|
||||
for (unsigned int i=0;i<m->vert.size();i++)
|
||||
{
|
||||
m.vert[i].P()+=InitialBarycenter;
|
||||
m.vert[i].P()=UnScale(m.vert[i].P());
|
||||
m->vert[i].P()=UnScale(m->vert[i].P());///last change
|
||||
m->vert[i].P()+=InitialBarycenter;
|
||||
// m.vert[i].P()=UnScale(m.vert[i].P());
|
||||
// P_Vertex.push_back(&m.vert[i]);
|
||||
}
|
||||
|
||||
|
||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(m);
|
||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);
|
||||
|
||||
}
|
||||
|
||||
|
@ -490,7 +553,7 @@ void Reinit_PVectors()
|
|||
P_Vertex.clear();
|
||||
MyTriMesh::VertexIterator vi;
|
||||
|
||||
for (vi=m.vert.begin();vi<m.vert.end();vi++)
|
||||
for (vi=m->vert.begin();vi<m->vert.end();vi++)
|
||||
{
|
||||
if ((!vi->IsD())&&(!vi->blocked))
|
||||
P_Vertex.push_back(&(*vi));
|
||||
|
@ -500,7 +563,7 @@ void Reinit_PVectors()
|
|||
|
||||
P_Faces.clear();
|
||||
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()))
|
||||
|
@ -516,7 +579,7 @@ void Refresh_PVectors()
|
|||
P_FacesAux.clear();
|
||||
P_VertexAux.clear();
|
||||
|
||||
int i=0;
|
||||
unsigned int i=0;
|
||||
for (i=0;i<P_Vertex.size();i++)
|
||||
{
|
||||
if (!P_Vertex[i]->blocked)
|
||||
|
@ -539,13 +602,13 @@ void Refresh_PVectors()
|
|||
///add the new elements on partial vectors when allocate space for new vertices
|
||||
void AddNewElements(MyTriMesh::VertexIterator vi,MyTriMesh::FaceIterator fi)
|
||||
{
|
||||
while (vi!=m.vert.end())
|
||||
while (vi!=m->vert.end())
|
||||
{
|
||||
if (!(*vi).IsD())
|
||||
P_Vertex.push_back(&(*vi));
|
||||
vi++;
|
||||
}
|
||||
while (fi!=m.face.end())
|
||||
while (fi!=m->face.end())
|
||||
{
|
||||
if (!(*fi).IsD())
|
||||
P_Faces.push_back(&(*fi));
|
||||
|
@ -597,24 +660,24 @@ bool TimeSelfIntersection()
|
|||
///refine the mesh and re-update eventually
|
||||
void RefineStep(float _edge_size)
|
||||
{
|
||||
MyTriMesh::VertexIterator vinit=m.vert.begin();
|
||||
MyTriMesh::FaceIterator finit=m.face.begin();
|
||||
MyTriMesh::VertexIterator vend=m.vert.end();
|
||||
MyTriMesh::FaceIterator fend=m.face.end();
|
||||
MyTriMesh::VertexIterator vinit=m->vert.begin();
|
||||
MyTriMesh::FaceIterator finit=m->face.begin();
|
||||
MyTriMesh::VertexIterator vend=m->vert.end();
|
||||
MyTriMesh::FaceIterator fend=m->face.end();
|
||||
|
||||
refined=vcg::Refine(m,MidPoint<MyTriMesh>(),_edge_size);
|
||||
refined=vcg::Refine(*m,MidPoint<MyTriMesh>(),_edge_size);
|
||||
|
||||
if (refined)
|
||||
{
|
||||
MyTriMesh::VertexIterator vinit2=m.vert.begin();
|
||||
MyTriMesh::FaceIterator finit2=m.face.begin();
|
||||
MyTriMesh::VertexIterator vinit2=m->vert.begin();
|
||||
MyTriMesh::FaceIterator finit2=m->face.begin();
|
||||
|
||||
if ((vinit2!=vinit)||(finit2!=finit))
|
||||
Reinit_PVectors();
|
||||
else
|
||||
AddNewElements(vend,fend);
|
||||
|
||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(m);
|
||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);
|
||||
CollDet->RefreshElements();
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +711,8 @@ void ClearStopped()
|
|||
///do one step of controls for self collision detetction
|
||||
void CollisionDetection()
|
||||
{
|
||||
CollDet->UpdateStep();
|
||||
//CollDet->UpdateStep();
|
||||
CollDet->UpdateStep<Part_FaceContainer>(P_Faces);
|
||||
std::vector<MyFace*> coll=CollDet->computeSelfIntersection();
|
||||
for (std::vector<MyFace*>::iterator it=coll.begin();it<coll.end();it++)
|
||||
{
|
||||
|
@ -736,7 +800,7 @@ vcg::Box3<float> BBox()
|
|||
///one step of moving for the deformable object
|
||||
void Step(float t,float _edge_size)
|
||||
{
|
||||
if (m.face.size()!=0)
|
||||
if (m->face.size()!=0)
|
||||
{
|
||||
AddExtForces();
|
||||
TrINT->Step(t);
|
||||
|
@ -755,7 +819,7 @@ void Step(float t,float _edge_size)
|
|||
|
||||
void Smooth()
|
||||
{
|
||||
ScaleLaplacianSmooth<MyTriMesh>(m,1,0.5);
|
||||
ScaleLaplacianSmooth<MyTriMesh>(*m,1,0.5);
|
||||
}
|
||||
|
||||
void AutoStep()
|
||||
|
@ -763,7 +827,7 @@ void AutoStep()
|
|||
refined=false;
|
||||
Step(time_stamp,edge_size);
|
||||
//test on 80% of the vertex blocked
|
||||
if ((((float)P_Vertex.size()/(float)m.vn)<0.2)&&(end_loop)&&(!refined)&&(edge_size>edge_precision))
|
||||
if ((((float)P_Vertex.size()/(float)m->vn)<0.2)&&(end_loop)&&(!refined)&&(edge_size>edge_precision))
|
||||
{
|
||||
edge_size/=2.f;
|
||||
if (edge_size<edge_precision)
|
||||
|
@ -772,5 +836,21 @@ void AutoStep()
|
|||
}
|
||||
}
|
||||
|
||||
///first version
|
||||
void Resample()
|
||||
{
|
||||
new_m=new MyTriMesh();
|
||||
vcg::trimesh::Resampler<MyTriMesh,MyTriMesh>::Resample<vcg::trimesh::RES::MMarchingCubes>(*m,*new_m,
|
||||
Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision));
|
||||
|
||||
delete(m);
|
||||
|
||||
m=new_m;
|
||||
Reinit_PVectors();
|
||||
ReinitPhysicMesh();
|
||||
|
||||
CollDet->Init(bbox.min,bbox.max,5.f);
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
|
@ -234,6 +234,12 @@
|
|||
<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>
|
||||
|
@ -361,117 +367,6 @@
|
|||
<string>mass of particles</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>ClearButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>700</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<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>
|
||||
|
@ -691,6 +586,141 @@
|
|||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SmoothButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>660</y>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursor>0</cursor>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smooth</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>SaveButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>700</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>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>ClearButton</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>740</y>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursor>0</cursor>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ClearMesh</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>Marching_Cubes</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>619</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Marching Cube</string>
|
||||
</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>
|
||||
<widget class="SimpleGLWidget">
|
||||
<property name="name">
|
||||
|
@ -746,9 +776,9 @@
|
|||
<slot access="public" specifier="">SavePly()</slot>
|
||||
<slot access="public" specifier="">Extract()</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="">CleanMesh()</slot>
|
||||
<slot access="public" specifier="">Clear()</slot>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<actions>
|
||||
|
@ -895,12 +925,6 @@
|
|||
<receiver>simpleGLWidget1</receiver>
|
||||
<slot>Apply()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>ClearButton</sender>
|
||||
<signal>pressed()</signal>
|
||||
<receiver>simpleGLWidget1</receiver>
|
||||
<slot>Clear()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>fileOpenAction</sender>
|
||||
<signal>activated()</signal>
|
||||
|
@ -913,7 +937,22 @@
|
|||
<receiver>simpleGLWidget1</receiver>
|
||||
<slot>SavePly()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>Marching_Cubes</sender>
|
||||
<signal>pressed()</signal>
|
||||
<receiver>simpleGLWidget1</receiver>
|
||||
<slot>CleanMesh()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>ClearButton</sender>
|
||||
<signal>pressed()</signal>
|
||||
<receiver>simpleGLWidget1</receiver>
|
||||
<slot>Clear()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in declaration">simpleglwidget.h</include>
|
||||
</includes>
|
||||
<pixmapinproject/>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
|
|
|
@ -20,11 +20,22 @@ QGLWidget(parent, name)
|
|||
resultForces=false;
|
||||
continue_int=false;
|
||||
_numslide=0;
|
||||
Track.center=Point3f(0,0,0);
|
||||
Track.Reset();
|
||||
Track.radius= 100;
|
||||
|
||||
TrackM.center=Point3f(0,0,0);
|
||||
TrackM.Reset();
|
||||
TrackM.radius= 100.f;
|
||||
|
||||
TrackS.center=Point3f(0,0,0);
|
||||
TrackS.Reset();
|
||||
TrackS.radius= 100.f;
|
||||
|
||||
zoom=1;
|
||||
path="";
|
||||
/*s=new Segmentator();*/
|
||||
//timer = new QTimer(this );
|
||||
//QTimer::connect( timer, SIGNAL(timeout()), this, SLOT(Update()) );
|
||||
// timer->start(0); // 2 seconds single-shot timer
|
||||
|
||||
}
|
||||
|
||||
void SimpleGLWidget::SaveMatrix()
|
||||
|
@ -185,7 +196,7 @@ void SimpleGLWidget::Save()
|
|||
if (filename!=NULL)
|
||||
{
|
||||
const char *path_save=filename.ascii();
|
||||
vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save(s->m,path_save);
|
||||
vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save((*s->m),path_save);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -267,27 +278,29 @@ void SimpleGLWidget::glDraw(){
|
|||
if (_showslides)
|
||||
{
|
||||
vcg::Point3f p=Point3f((float)s->BBox().Center().V(0),(float)s->BBox().Center().V(1),(float)s->BBox().Center().V(2));
|
||||
Track.radius=s->BBox().Diag();
|
||||
Track.GetView();
|
||||
Track.Apply();
|
||||
Track.Draw();
|
||||
TrackS.radius=s->BBox().Diag();
|
||||
TrackS.GetView();
|
||||
TrackS.Apply();
|
||||
TrackS.Draw();
|
||||
glScalef(1.f/s->BBox().Diag(),1.f/s->BBox().Diag(),1.f/s->BBox().Diag());
|
||||
glScalef(GLfloat(zoom),GLfloat(zoom),GLfloat(zoom));
|
||||
//glScalef(GLfloat(zoom),GLfloat(zoom),GLfloat(zoom));
|
||||
glTranslate(-p);
|
||||
//save transformation matrixes
|
||||
SaveMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(s->m);
|
||||
vcg::Point3f p=s->m.bbox.Center();
|
||||
Track.radius=s->m.bbox.Diag();
|
||||
Track.GetView();
|
||||
Track.Apply();
|
||||
Track.Draw();
|
||||
glScalef(1/s->m.bbox.Diag(),1/s->m.bbox.Diag(),1/s->m.bbox.Diag());
|
||||
glScalef(GLfloat(zoom),GLfloat(zoom),GLfloat(zoom));
|
||||
if (s->m!=NULL)
|
||||
{
|
||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
||||
vcg::Point3f p=s->m->bbox.Center();
|
||||
TrackM.GetView();
|
||||
TrackM.Apply();
|
||||
TrackM.Draw();
|
||||
glScalef(1.f/s->m->bbox.Diag(),1.f/s->m->bbox.Diag(),1.f/s->m->bbox.Diag());
|
||||
glTranslate(-p);
|
||||
//glScalef(1.f/s->m->bbox.Diag(),1.f/s->m->bbox.Diag(),1.f/s->m->bbox.Diag());
|
||||
}
|
||||
}
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
@ -324,8 +337,10 @@ void SimpleGLWidget::glDraw(){
|
|||
glPolygonMode(GL_FRONT,GL_FILL);
|
||||
|
||||
int i=0;
|
||||
if (s->m!=NULL)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
glColor3d(0.4,0.8,0.8);
|
||||
if (fi->intersected)
|
||||
|
@ -343,7 +358,7 @@ void SimpleGLWidget::glDraw(){
|
|||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
}
|
||||
glPopMatrix();
|
||||
//WriteInfo();
|
||||
|
||||
|
@ -390,15 +405,32 @@ void SimpleGLWidget::resizeGL( int w, int h )
|
|||
|
||||
void SimpleGLWidget::ClearMesh()
|
||||
{
|
||||
s->m.Clear();
|
||||
s->m->Clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void SimpleGLWidget::UpdateBBMesh()
|
||||
{
|
||||
vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
||||
}
|
||||
|
||||
void SimpleGLWidget::mousePressEvent ( QMouseEvent * e )
|
||||
{
|
||||
if (e->button()==Qt::LeftButton )
|
||||
Track.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
{
|
||||
|
||||
if ((!_showslides)&&(s->m!=NULL))
|
||||
{
|
||||
/*vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
||||
TrackM.radius=s->m->bbox.Diag();
|
||||
TrackM.center=s->m->bbox.Center();
|
||||
*/
|
||||
UpdateBBMesh();
|
||||
TrackM.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
}
|
||||
else if (_showslides)
|
||||
TrackS.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
}
|
||||
else
|
||||
//test mass spring model
|
||||
if ((e->button()==Qt::RightButton)&&(_showslides))
|
||||
|
@ -417,6 +449,8 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e )
|
|||
//s->SetInitialBarycenter(Point3f(x,y,_numslide));
|
||||
//s->InitSegmentation(Point3f(x,y,_numslide));
|
||||
s->InitSegmentation(Point3f(x,y,z));
|
||||
UpdateBBMesh();
|
||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(*(s->m));
|
||||
repaint();
|
||||
}
|
||||
//vcg::tri::UpdateBounding<Segmentator::MyTriMesh>::Box(s->m);
|
||||
|
@ -426,7 +460,9 @@ void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
|||
{
|
||||
if (!_showslides)
|
||||
{
|
||||
zoom+=e->delta()/120.f;
|
||||
/* zoom+=e->delta()/120.f;
|
||||
repaint();*/
|
||||
TrackM.MouseWheel(e->delta()/120.f);
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
|
@ -446,7 +482,11 @@ void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
|||
|
||||
void SimpleGLWidget::mouseReleaseEvent(QMouseEvent * e )
|
||||
{
|
||||
Track.MouseUp(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
if (!_showslides)
|
||||
TrackM.MouseUp(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
else
|
||||
TrackS.MouseUp(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT);
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@ -459,6 +499,15 @@ void SimpleGLWidget::Step()
|
|||
}
|
||||
}
|
||||
|
||||
void SimpleGLWidget::MarchingCube()
|
||||
{
|
||||
if (s->m->fn>0)
|
||||
s->Resample();
|
||||
|
||||
//vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save((*s->new_m),"d:/march.ply");
|
||||
//vcg::tri::io::ExporterPLY<Segmentator::MyTriMesh>::Save((*s->m),"d:/march.ply");
|
||||
}
|
||||
|
||||
void SimpleGLWidget::SetExtractionParameters()
|
||||
{
|
||||
float mass=atof(w->M_particles->text());
|
||||
|
@ -476,7 +525,11 @@ void SimpleGLWidget::SetExtractionParameters()
|
|||
|
||||
void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e )
|
||||
{
|
||||
Track.MouseMove(e->x(),_H-e->y());
|
||||
if (_showslides)
|
||||
TrackS.MouseMove(e->x(),_H-e->y());
|
||||
else
|
||||
TrackM.MouseMove(e->x(),_H-e->y());
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include <GL\glew.h>
|
||||
#include <GL/glew.h>
|
||||
#include <qgl.h>
|
||||
#include <wrap\gl\trimesh.h>
|
||||
#include <wrap\gui\trackball.h>
|
||||
#include <wrap/gl/trimesh.h>
|
||||
#include <wrap/gui/trackball.h>
|
||||
#include <segmentator.h>
|
||||
#include <sim/tri_pde_integrator.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
#include <segmentform.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
class SimpleGLWidget: public QGLWidget{
|
||||
|
||||
|
@ -17,7 +17,8 @@ Q_OBJECT
|
|||
private :
|
||||
int _H;
|
||||
int _W;
|
||||
vcg::Trackball Track;
|
||||
vcg::Trackball TrackM;
|
||||
vcg::Trackball TrackS;
|
||||
double zoom;
|
||||
GLdouble projection[16];
|
||||
GLdouble modelMatrix[16];
|
||||
|
@ -31,7 +32,8 @@ private :
|
|||
bool resultForces;
|
||||
bool continue_int;
|
||||
GLuint texName;
|
||||
|
||||
//Segmentator *s;
|
||||
//QTimer *timer;
|
||||
//vcg::GlTrimesh<Segmentator::MyTriMesh> *Wrap;
|
||||
|
||||
public:
|
||||
|
@ -59,7 +61,8 @@ public:
|
|||
void WriteInfo();
|
||||
void ClearMesh();
|
||||
void OpenDirectory();
|
||||
|
||||
void MarchingCube();
|
||||
void UpdateBBMesh();
|
||||
|
||||
//virtual void keyPressEvent(QKeyEvent *qk);
|
||||
|
||||
|
@ -73,6 +76,7 @@ public:
|
|||
void ShowSlides()
|
||||
{
|
||||
_showslides=!_showslides;
|
||||
UpdateBBMesh();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@ -124,17 +128,21 @@ public:
|
|||
|
||||
void Extract()
|
||||
{
|
||||
UpdateBBMesh();
|
||||
continue_int=!continue_int;
|
||||
if (continue_int)
|
||||
{
|
||||
_showslides=false;
|
||||
w->SlidesButton->setOn(false);
|
||||
//((SegmentForm *)this->parent())->SlidesButton->setOn(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_showslides=true;
|
||||
w->SlidesButton->setOn(true);
|
||||
//((SegmentForm *)this->parent())->SlidesButton->setOn(true);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -142,8 +150,18 @@ public:
|
|||
Step();
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
ClearMesh();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void CleanMesh()
|
||||
{
|
||||
MarchingCube();
|
||||
UpdateBBMesh();
|
||||
repaint();
|
||||
}
|
||||
|
||||
};
|
Loading…
Reference in New Issue