minor changes
This commit is contained in:
parent
d34f797d3f
commit
a506fdf8c7
|
@ -82,6 +82,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!(*si).IsD())
|
if (!(*si).IsD())
|
||||||
{
|
{
|
||||||
|
(*si).Mark()=0;
|
||||||
if (!(*si).IsActive())
|
if (!(*si).IsActive())
|
||||||
|
|
||||||
HTable->AddElem(&*si);
|
HTable->AddElem(&*si);
|
||||||
|
|
|
@ -31,8 +31,8 @@ int main( int argc, char ** argv )
|
||||||
|
|
||||||
#ifdef _TORUS
|
#ifdef _TORUS
|
||||||
//w.simpleGLWidget1->SetExtractionParameters();
|
//w.simpleGLWidget1->SetExtractionParameters();
|
||||||
//s->SetSegmentParameters(10,0.5f,0.2f,0.8f,0.4f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15);
|
//s->SetSegmentParameters(10,0.5f,0.2f,0.8f,0.4f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,30);
|
||||||
s->SetSegmentParameters(10,0.5f,0.8f,0.8f,0.2f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15);
|
s->SetSegmentParameters(10,0.5f,0.6f,0.25f,0.2f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15);
|
||||||
s->BBox().min=Point3f(-40.f,-40.f,-40.f);
|
s->BBox().min=Point3f(-40.f,-40.f,-40.f);
|
||||||
s->BBox().max=Point3f(40.f,40.f,40.f);
|
s->BBox().max=Point3f(40.f,40.f,40.f);
|
||||||
s->InitSegmentation(Point3f(-25.f,0.f,0.f));
|
s->InitSegmentation(Point3f(-25.f,0.f,0.f));
|
||||||
|
@ -50,7 +50,7 @@ int main( int argc, char ** argv )
|
||||||
|
|
||||||
timer = new QTimer(w.simpleGLWidget1 );
|
timer = new QTimer(w.simpleGLWidget1 );
|
||||||
QTimer::connect( timer, SIGNAL(timeout()), w.simpleGLWidget1, SLOT(Update()) );
|
QTimer::connect( timer, SIGNAL(timeout()), w.simpleGLWidget1, SLOT(Update()) );
|
||||||
timer->start(0); // 2 seconds single-shot timer
|
timer->start(0); //
|
||||||
|
|
||||||
|
|
||||||
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
|
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
|
||||||
|
|
|
@ -242,6 +242,26 @@ FORMS = segmentform.ui \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
// #include <vcg/simplex/face/with/afavfnfmrt.h>
|
// #include <vcg/simplex/face/with/afavfnfmrt.h>
|
||||||
//#else
|
//#else
|
||||||
|
|
||||||
#include <vcg/simplex/vertex/with/vn.h>
|
#include <vcg/simplex/vertex/with/afvn.h>
|
||||||
#include <vcg/simplex/face/with/affnfmrt.h>
|
#include <vcg/simplex/face/with/afavfnfmrt.h>
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include <vcg/simplex/face/topology.h>
|
#include <vcg/simplex/face/topology.h>
|
||||||
#include <vcg/complex/trimesh/update/topology.h>
|
#include <vcg/complex/trimesh/update/topology.h>
|
||||||
|
//#include <mymarchingCubes.h>
|
||||||
|
|
||||||
class Segmentator{
|
class Segmentator{
|
||||||
|
|
||||||
|
@ -52,11 +53,11 @@ struct DummyEdge;
|
||||||
struct DummyTetra;
|
struct DummyTetra;
|
||||||
struct MyFace;
|
struct MyFace;
|
||||||
|
|
||||||
#ifdef _EXTENDED_MARCH
|
//#ifdef _EXTENDED_MARCH
|
||||||
|
// struct MyVertex: public ParticleBasic<vcg::VertexAFVNf<DummyEdge,MyFace,DummyTetra> >
|
||||||
|
//#else
|
||||||
struct MyVertex: public ParticleBasic<vcg::VertexAFVNf<DummyEdge,MyFace,DummyTetra> >
|
struct MyVertex: public ParticleBasic<vcg::VertexAFVNf<DummyEdge,MyFace,DummyTetra> >
|
||||||
#else
|
//#endif
|
||||||
struct MyVertex: public ParticleBasic<vcg::VertexVNf<DummyEdge,MyFace,DummyTetra> >
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
///this class implements the deformable triangle in a mass spring system
|
///this class implements the deformable triangle in a mass spring system
|
||||||
struct MyFace : public TriangleMassSpring< vcg::FaceAFFNFMRT<MyVertex,DummyEdge,MyFace> >
|
struct MyFace : public TriangleMassSpring< vcg::FaceAFAVFNFMRT<MyVertex,DummyEdge,MyFace> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool intersected;
|
bool intersected;
|
||||||
|
@ -108,18 +109,28 @@ public:
|
||||||
ScalarType AreaRep;
|
ScalarType AreaRep;
|
||||||
int _Mark;
|
int _Mark;
|
||||||
|
|
||||||
|
CoordType old_N;
|
||||||
|
|
||||||
MyFace()
|
MyFace()
|
||||||
{
|
{
|
||||||
intersected=false;
|
intersected=false;
|
||||||
ClearFlags();
|
ClearFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NormInversion()
|
||||||
|
{
|
||||||
|
return (((old_N*NormalizedNormal())<0)||(Normal().Norm()<0.01));
|
||||||
|
}
|
||||||
|
|
||||||
void Init ( double k, double mass,float k_dihedral )
|
void Init ( double k, double mass,float k_dihedral )
|
||||||
{
|
{
|
||||||
__super::Init(k,mass);
|
__super::Init(k,mass);
|
||||||
kdihedral=k_dihedral;
|
kdihedral=k_dihedral;
|
||||||
AreaRep=((V(1)->RPos() - V(0)->RPos()) ^ (V(2)->RPos() - V(0)->RPos())).Norm();
|
AreaRep=((V(1)->RPos() - V(0)->RPos()) ^ (V(2)->RPos() - V(0)->RPos())).Norm();
|
||||||
SetS();
|
SetS();
|
||||||
|
ComputeNormal();
|
||||||
|
old_N=Normal();
|
||||||
|
old_N.Normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsActive()
|
bool IsActive()
|
||||||
|
@ -171,7 +182,7 @@ 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 (!IsD()&&(!intersected))//if this face is not deleted
|
if (!IsD())//&&(!intersected))//if this face is not deleted
|
||||||
{
|
{
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +196,15 @@ public:
|
||||||
|
|
||||||
if ((fopp<myAddr)&&(!fopp->intersected))//test do not duplicate updates per edge
|
if ((fopp<myAddr)&&(!fopp->intersected))//test do not duplicate updates per edge
|
||||||
{
|
{
|
||||||
|
/////updateing spring force
|
||||||
|
//ScalarType stretch;
|
||||||
|
//CoordType direction;
|
||||||
|
//stretch=ForceValue(L(i),(V(i)->P()-V((i+1)%3)->P()).Norm());
|
||||||
|
//direction=(V(i)->P()-V((i+1)%3)->P());
|
||||||
|
//direction.Normalize();
|
||||||
|
//V(i)-> IntForce()+=direction*(stretch)/2.f-DampFactor(i);
|
||||||
|
//V((i+1)%3)-> IntForce()+=direction*(-stretch)/2.f-DampFactor(i);
|
||||||
|
|
||||||
//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();
|
||||||
fopp=FFp(i);
|
fopp=FFp(i);
|
||||||
|
@ -210,33 +230,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////area changing constrain penalize area goes to zero
|
|
||||||
//CoordType m0=(V(0)->P()+V(1)->P())/2.f;
|
|
||||||
//CoordType m1=(V(1)->P()+V(2)->P())/2.f;
|
|
||||||
//CoordType m2=(V(2)->P()+V(0)->P())/2.f;
|
|
||||||
//m0=(V(2)->P()-m0).Normalize();//directions
|
|
||||||
//m1=(V(0)->P()-m1).Normalize();
|
|
||||||
//m2=(V(1)->P()-m2).Normalize();
|
|
||||||
//ScalarType FArea=((ScalarType)1/AreaRep-Area())*_k;
|
|
||||||
//V(0)->IntForce()+=m0*FArea/3.f;
|
|
||||||
//V(1)->IntForce()+=m1*FArea/3.f;
|
|
||||||
//V(2)->IntForce()+=m2*FArea/3.f;
|
|
||||||
////end area constrain
|
|
||||||
|
|
||||||
return(__super::Update());
|
return(__super::Update());
|
||||||
///new
|
|
||||||
//double stretch;
|
|
||||||
//CoordType direction;
|
|
||||||
/////for each vertex
|
|
||||||
//for (int i=0;i<3;i++)
|
|
||||||
//{
|
|
||||||
// //spring on the face
|
|
||||||
// direction=(V(i)->RPos()-V(i)->P());
|
|
||||||
// stretch=direction.Norm();
|
|
||||||
// direction.Normalize();
|
|
||||||
// V(i)-> IntForce()+=direction*(stretch * _k)/2.f;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
///new
|
///new
|
||||||
|
@ -371,7 +365,7 @@ private:
|
||||||
MyTriMesh::CoordType p1=MyTriMesh::CoordType(p.X(),p.Z(),p.Y());
|
MyTriMesh::CoordType p1=MyTriMesh::CoordType(p.X(),p.Z(),p.Y());
|
||||||
MyTriMesh::CoordType p2=MyTriMesh::CoordType(p.Z(),p.Y(),p.X());
|
MyTriMesh::CoordType p2=MyTriMesh::CoordType(p.Z(),p.Y(),p.X());
|
||||||
|
|
||||||
if (InTorus(p)||InTorus(p1)||InTorus(p2))
|
if (InTorus(p))//||InTorus(p1)||InTorus(p2))
|
||||||
return (100.f);
|
return (100.f);
|
||||||
else
|
else
|
||||||
return (0.f);
|
return (0.f);
|
||||||
|
@ -489,6 +483,8 @@ private:
|
||||||
{
|
{
|
||||||
f->intersected=true;
|
f->intersected=true;
|
||||||
f->ClearS();
|
f->ClearS();
|
||||||
|
SetBlockedFace(f);
|
||||||
|
|
||||||
//if ((!f->intersected)&&(!f->IsD()))
|
//if ((!f->intersected)&&(!f->IsD()))
|
||||||
//{
|
//{
|
||||||
// f->intersected=true;
|
// f->intersected=true;
|
||||||
|
@ -589,11 +585,10 @@ MyTriMesh::CoordType GradientFactor(MyTriMesh::VertexType *v)
|
||||||
void AddExtForces()
|
void AddExtForces()
|
||||||
{
|
{
|
||||||
Part_VertexContainer::iterator vi;
|
Part_VertexContainer::iterator vi;
|
||||||
//PartialUpdateNormals();
|
/*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)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!(*vi).IsD())
|
if (!(*vi).IsD())
|
||||||
{
|
{
|
||||||
if (OutOfLimits((*vi).P()))
|
if (OutOfLimits((*vi).P()))
|
||||||
|
@ -637,7 +632,7 @@ void Reinit_PVectors()
|
||||||
{
|
{
|
||||||
if ((!vi->IsD())&&(!vi->blocked))
|
if ((!vi->IsD())&&(!vi->blocked))
|
||||||
P_Vertex.push_back(&(*vi));
|
P_Vertex.push_back(&(*vi));
|
||||||
if ((!vi->IsD())&&((*vi).stopped)&&(!vi->blocked))
|
if ((!vi->IsD())&&((*vi).stopped)&&(!vi->blocked))///to see
|
||||||
V_Stopped.push_back(&(*vi));
|
V_Stopped.push_back(&(*vi));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +640,7 @@ 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->IsD())&&(!fi->IsBlocked()))
|
if ((!fi->IsD())&&(!fi->IsBlocked())&&(!fi->intersected))
|
||||||
P_Faces.push_back(&(*fi));
|
P_Faces.push_back(&(*fi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,17 +654,20 @@ void Refresh_PVectors()
|
||||||
P_VertexAux.clear();
|
P_VertexAux.clear();
|
||||||
|
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
|
///as first control normal inversion
|
||||||
|
for (i=0;i<P_Faces.size();i++)
|
||||||
|
if (P_Faces[i]->NormInversion())//if one step inversion the block vertices
|
||||||
|
SetIntersectedFace(P_Faces[i]);
|
||||||
|
else
|
||||||
|
P_Faces[i]->old_N=NormalizedNormal<MyFace>(*P_Faces[i]);
|
||||||
|
|
||||||
for (i=0;i<P_Vertex.size();i++)
|
for (i=0;i<P_Vertex.size();i++)
|
||||||
{
|
if ((!P_Vertex[i]->IsD())&&(!P_Vertex[i]->blocked))//&&(!P_Vertex[i]->stopped))
|
||||||
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]->IsD())&&(!P_Faces[i]->intersected)&&(!P_Faces[i]->IsBlocked()))//&&(!P_Faces[i]->IsActive()))//&&(!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]);
|
||||||
}
|
|
||||||
|
|
||||||
P_Faces.clear();
|
P_Faces.clear();
|
||||||
P_Vertex.clear();
|
P_Vertex.clear();
|
||||||
|
@ -739,8 +737,8 @@ bool TimeSelfIntersection()
|
||||||
|
|
||||||
void PartialUpdateNormals()
|
void PartialUpdateNormals()
|
||||||
{
|
{
|
||||||
//vcg::tri::UpdateNormals<MyTriMesh>::PerFaceNormalized(*m);
|
/*vcg::tri::UpdateNormals<MyTriMesh>::PerFaceNormalized(*m);
|
||||||
//vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);
|
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);*/
|
||||||
Part_FaceContainer::iterator fi;
|
Part_FaceContainer::iterator fi;
|
||||||
for (fi=P_Faces.begin();fi<P_Faces.end();++fi)
|
for (fi=P_Faces.begin();fi<P_Faces.end();++fi)
|
||||||
if (!(*fi).IsD())
|
if (!(*fi).IsD())
|
||||||
|
@ -755,7 +753,7 @@ void PartialUpdateNormals()
|
||||||
for(fi=P_Faces.begin();fi!=P_Faces.end();++fi)
|
for(fi=P_Faces.begin();fi!=P_Faces.end();++fi)
|
||||||
if( !(*fi).IsD() && (*fi).IsR() )
|
if( !(*fi).IsD() && (*fi).IsR() )
|
||||||
{
|
{
|
||||||
MyFace::NormalType t = (*fi).Normal();
|
MyFace::NormalType t = (*fi).N();
|
||||||
for(int j=0; j<3; ++j)
|
for(int j=0; j<3; ++j)
|
||||||
if( !(*fi).V(j)->IsD() && (*fi).V(j)->IsRW() )
|
if( !(*fi).V(j)->IsD() && (*fi).V(j)->IsRW() )
|
||||||
(*fi).V(j)->N() += t;
|
(*fi).V(j)->N() += t;
|
||||||
|
@ -765,6 +763,30 @@ void PartialUpdateNormals()
|
||||||
if( !(*vi).IsD() && (*vi).IsRW() )
|
if( !(*vi).IsD() && (*vi).IsRW() )
|
||||||
(*vi).N().Normalize();
|
(*vi).N().Normalize();
|
||||||
|
|
||||||
|
//MyTriMesh::FaceIterator fi;
|
||||||
|
//for (fi=m->face.begin();fi!=m->face.end();++fi)
|
||||||
|
// if ((!(*fi).IsD())&&(!(*fi).intersected))
|
||||||
|
// (*fi).ComputeNormalizedNormal();
|
||||||
|
|
||||||
|
/////update only on active vertices
|
||||||
|
//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=m->face.begin();fi!=m->face.end();++fi)
|
||||||
|
// if( !(*fi).IsD() && (*fi).IsR() &&(!(*fi).intersected))//(!(*fi).IsBlocked())&&
|
||||||
|
// {
|
||||||
|
// MyFace::NormalType t = (*fi).N();
|
||||||
|
// for(int j=0; j<3; ++j)
|
||||||
|
// if( !(*fi).V(j)->IsD() && (*fi).V(j)->IsRW())//&& (!(*fi).V(j)->blocked))
|
||||||
|
// (*fi).V(j)->N() += t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//for(vi=P_Vertex.begin();vi!=P_Vertex.end();++vi)
|
||||||
|
// if( !(*vi).IsD() && (*vi).IsRW() )
|
||||||
|
// (*vi).N().Normalize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool SelectToRefine()
|
//bool SelectToRefine()
|
||||||
|
@ -829,6 +851,7 @@ void RefineStep(float _edge_size)
|
||||||
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);*/
|
vcg::tri::UpdateNormals<MyTriMesh>::PerVertexNormalized(*m);*/
|
||||||
|
|
||||||
PartialUpdateNormals();
|
PartialUpdateNormals();
|
||||||
|
PartialReinitPhysicMesh();
|
||||||
|
|
||||||
//#ifdef _DEBUG
|
//#ifdef _DEBUG
|
||||||
// vcg::tri::UpdateTopology<MyTriMesh>::TestFaceFace(*m);
|
// vcg::tri::UpdateTopology<MyTriMesh>::TestFaceFace(*m);
|
||||||
|
@ -839,14 +862,10 @@ void RefineStep(float _edge_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
///reset vertex position and unblock them
|
///reset vertex position and unblock them
|
||||||
void ReinitPhysicMesh()
|
void PartialReinitPhysicMesh()
|
||||||
{
|
{
|
||||||
Part_FaceContainer::iterator pfi;
|
Part_FaceContainer::iterator pfi;
|
||||||
|
|
||||||
/*for (pfi=P_Faces.begin();pfi<P_Faces.end();++pfi)
|
|
||||||
if((!(*pfi).IsD())&&((!(*pfi).intersected)))
|
|
||||||
(*pfi).Init(k_elanst,mass,k_dihedral);*/
|
|
||||||
|
|
||||||
Part_VertexContainer::iterator pvi;
|
Part_VertexContainer::iterator pvi;
|
||||||
for (pvi=P_Vertex.begin();pvi<P_Vertex.end();++pvi)
|
for (pvi=P_Vertex.begin();pvi<P_Vertex.end();++pvi)
|
||||||
if(!(*pvi).IsD())
|
if(!(*pvi).IsD())
|
||||||
|
@ -856,8 +875,19 @@ void ReinitPhysicMesh()
|
||||||
if((!(*pfi).IsD())&&((!(*pfi).intersected)))
|
if((!(*pfi).IsD())&&((!(*pfi).intersected)))
|
||||||
(*pfi).Init(k_elanst,mass,k_dihedral);
|
(*pfi).Init(k_elanst,mass,k_dihedral);
|
||||||
|
|
||||||
|
|
||||||
|
/*MyTriMesh::VertexIterator pvi;
|
||||||
|
MyTriMesh::FaceIterator pfi;
|
||||||
|
|
||||||
//PartialUpdateNormals();
|
for (pvi=m->vert.begin();pvi<m->vert.end();++pvi)
|
||||||
|
if(!(*pvi).IsD())
|
||||||
|
(*pvi).SetRestPos();
|
||||||
|
|
||||||
|
for (pfi=m->face.begin();pfi<m->face.end();++pfi)
|
||||||
|
if((!(*pfi).IsD())&&((!(*pfi).intersected)))
|
||||||
|
(*pfi).Init(k_elanst,mass,k_dihedral);
|
||||||
|
|
||||||
|
PartialUpdateNormals();*/
|
||||||
|
|
||||||
/*for (MyTriMesh::VertexIterator vi=m.vert.begin();vi<m.vert.end();vi++)
|
/*for (MyTriMesh::VertexIterator vi=m.vert.begin();vi<m.vert.end();vi++)
|
||||||
ClearStopped(&*vi);*/
|
ClearStopped(&*vi);*/
|
||||||
|
@ -907,14 +937,23 @@ void LoadFromDir(char *in, char *out)
|
||||||
{
|
{
|
||||||
inDir=in;
|
inDir=in;
|
||||||
outDir=out;
|
outDir=out;
|
||||||
|
|
||||||
//caso optimized
|
//caso optimized
|
||||||
/*V.Resample(inDir,outDir);
|
/*V.LoadJpg(inDir,outDir);
|
||||||
|
|
||||||
V.Init(1000,outDir);*/
|
V.Init(1000,outDir);*/
|
||||||
V.Load(inDir);
|
|
||||||
|
V.LoadJpg(inDir);
|
||||||
bbox=vcg::Box3<float>(MapToSpace((V.Min())),(MapToSpace(V.Max())));
|
bbox=vcg::Box3<float>(MapToSpace((V.Min())),(MapToSpace(V.Max())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///set the input
|
||||||
|
void LoadFromRaw(char *inDir)
|
||||||
|
{
|
||||||
|
/*V.LoadRaw(inDir);
|
||||||
|
bbox=vcg::Box3<float>(MapToSpace((V.Min())),(MapToSpace(V.Max())));*/
|
||||||
|
}
|
||||||
|
|
||||||
///set parameters for segmentation
|
///set parameters for segmentation
|
||||||
void SetSegmentParameters(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),
|
||||||
|
@ -952,7 +991,7 @@ void InitSegmentation(MyTriMesh::CoordType b)
|
||||||
//init the mesh with new
|
//init the mesh with new
|
||||||
Reinit_PVectors();
|
Reinit_PVectors();
|
||||||
|
|
||||||
ReinitPhysicMesh();
|
PartialReinitPhysicMesh();
|
||||||
|
|
||||||
CollDet->Init(bbox.min,bbox.max,5.f);
|
CollDet->Init(bbox.min,bbox.max,5.f);
|
||||||
}
|
}
|
||||||
|
@ -970,13 +1009,16 @@ void Step(float t,float _edge_size)
|
||||||
{
|
{
|
||||||
AddExtForces();
|
AddExtForces();
|
||||||
TrINT->Step(t);
|
TrINT->Step(t);
|
||||||
|
PartialUpdateNormals();
|
||||||
VerifyForces();
|
VerifyForces();
|
||||||
Refresh_PVectors();
|
Refresh_PVectors();
|
||||||
if (end_loop)
|
if (end_loop)
|
||||||
{
|
{
|
||||||
RefineStep(_edge_size);
|
|
||||||
ReinitPhysicMesh();
|
|
||||||
ClearStopped();
|
ClearStopped();
|
||||||
|
Reinit_PVectors();
|
||||||
|
PartialReinitPhysicMesh();
|
||||||
|
RefineStep(_edge_size);
|
||||||
|
/*ReinitPhysicMesh();*/
|
||||||
}
|
}
|
||||||
if (TimeSelfIntersection())
|
if (TimeSelfIntersection())
|
||||||
CollisionDetection();
|
CollisionDetection();
|
||||||
|
@ -985,7 +1027,9 @@ void Step(float t,float _edge_size)
|
||||||
|
|
||||||
void Smooth()
|
void Smooth()
|
||||||
{
|
{
|
||||||
ScaleLaplacianSmooth<MyTriMesh>(*m,1,0.5);
|
//ScaleLaplacianSmooth<MyTriMesh>(*m,1,0.5);
|
||||||
|
vcg::tri::UpdateTopology<MyTriMesh>::VertexFace(*m);
|
||||||
|
PasoDobleSmooth<MyTriMesh>(*m,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoStep()
|
void AutoStep()
|
||||||
|
@ -1002,6 +1046,18 @@ void AutoStep()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void MarchingCubeExtraction()
|
||||||
|
//{
|
||||||
|
// /*
|
||||||
|
// new_m = new MyTriMesh();
|
||||||
|
// mcE.Extract(gray_init,&V,vcg::Point3i(2,2,2),*new_m);*/
|
||||||
|
//
|
||||||
|
// MC_Extractor<MyTriMesh> mcE;
|
||||||
|
// mcE.Extract(gray_init,V,vcg::Point3i(256,256,100),*m,gray_init);
|
||||||
|
// //mcE.Extract(gray_init,V,vcg::Point3i(512,512,240),*m,gray_init);
|
||||||
|
// //mcE.Extract(gray_init,V,vcg::Point3i(128,128,60),*m,gray_init);
|
||||||
|
//}
|
||||||
|
|
||||||
///set as deleted intersected vertices
|
///set as deleted intersected vertices
|
||||||
void ClearIntersectedFaces()
|
void ClearIntersectedFaces()
|
||||||
{
|
{
|
||||||
|
@ -1033,14 +1089,14 @@ void Resample()
|
||||||
Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision),edge_init);
|
Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision),edge_init);
|
||||||
#else
|
#else
|
||||||
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),edge_size*2.f);
|
Point3i((int) edge_precision/2.0,(int) edge_precision/2.0,(int) edge_precision/2.0),edge_size*2.f);
|
||||||
#endif
|
#endif
|
||||||
// delete(new_m0);
|
// delete(new_m0);
|
||||||
delete(m);
|
delete(m);
|
||||||
|
|
||||||
m=new_m;
|
m=new_m;
|
||||||
Reinit_PVectors();
|
Reinit_PVectors();
|
||||||
ReinitPhysicMesh();
|
PartialReinitPhysicMesh();
|
||||||
|
|
||||||
CollDet->Init(bbox.min,bbox.max,5.f);
|
CollDet->Init(bbox.min,bbox.max,5.f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>211</width>
|
<width>211</width>
|
||||||
<height>839</height>
|
<height>868</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="caption">
|
<property name="caption">
|
||||||
|
@ -559,75 +559,6 @@
|
||||||
<string>SavePly</string>
|
<string>SavePly</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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>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">
|
<widget class="QPushButton">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>ApplyButton</cstring>
|
<cstring>ApplyButton</cstring>
|
||||||
|
@ -710,22 +641,6 @@
|
||||||
<enum>Horizontal</enum>
|
<enum>Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit">
|
<widget class="QLineEdit">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>T_step</cstring>
|
<cstring>T_step</cstring>
|
||||||
|
@ -756,6 +671,94 @@
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Marching_Cubes</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>620</y>
|
||||||
|
<width>141</width>
|
||||||
|
<height>31</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Resample mesh</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Down, Down, Esc, Ctrl+Z</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>
|
</widget>
|
||||||
</hbox>
|
</hbox>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -769,6 +772,10 @@
|
||||||
<separator/>
|
<separator/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<action name="fileExitAction"/>
|
<action name="fileExitAction"/>
|
||||||
|
<action name="fileOpenRawAction"/>
|
||||||
|
</item>
|
||||||
|
<separator/>
|
||||||
|
<item text="new menu" name="new_menu">
|
||||||
</item>
|
</item>
|
||||||
</menubar>
|
</menubar>
|
||||||
<toolbars>
|
<toolbars>
|
||||||
|
@ -802,8 +809,9 @@
|
||||||
<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="">Clear()</slot>
|
||||||
<slot access="public" specifier="">slot()</slot>
|
|
||||||
<slot access="public" specifier="">SetSegmentColor()</slot>
|
<slot access="public" specifier="">SetSegmentColor()</slot>
|
||||||
|
<slot access="public" specifier="">OpenRawFile()</slot>
|
||||||
|
<slot access="public" specifier="">slot()</slot>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<actions>
|
<actions>
|
||||||
|
@ -883,6 +891,17 @@
|
||||||
<string>new item</string>
|
<string>new item</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>fileOpenRawAction</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>OpenRaw</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuText">
|
||||||
|
<string>OpenRaw</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
<images>
|
<images>
|
||||||
<image name="image0">
|
<image name="image0">
|
||||||
|
@ -980,6 +999,12 @@
|
||||||
<receiver>simpleGLWidget1</receiver>
|
<receiver>simpleGLWidget1</receiver>
|
||||||
<slot>SetSegmentColor()</slot>
|
<slot>SetSegmentColor()</slot>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>fileOpenRawAction</sender>
|
||||||
|
<signal>activated()</signal>
|
||||||
|
<receiver>simpleGLWidget1</receiver>
|
||||||
|
<slot>OpenRawFile()</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<pixmapinproject/>
|
<pixmapinproject/>
|
||||||
<layoutdefaults spacing="2" margin="4"/>
|
<layoutdefaults spacing="2" margin="4"/>
|
||||||
|
|
|
@ -55,13 +55,16 @@ void SimpleGLWidget::LoadMatrix()
|
||||||
}
|
}
|
||||||
|
|
||||||
//load as texture the i jpg of the directory
|
//load as texture the i jpg of the directory
|
||||||
void SimpleGLWidget::LoadTexture(QString p,int level)
|
void SimpleGLWidget::LoadTextureJpg(QString p,int level)
|
||||||
{
|
{
|
||||||
|
int e=glGetError();
|
||||||
|
|
||||||
QImage qI=QImage();
|
QImage qI=QImage();
|
||||||
QDir Qd=QDir(p);
|
QDir Qd=QDir(p);
|
||||||
QString qformat;
|
QString qformat;
|
||||||
QString Path=QString(p);
|
QString Path=QString(p);
|
||||||
Qd.setNameFilter("*.jpg");
|
Qd.setNameFilter("*.jpg");
|
||||||
|
//Qd.setNameFilter("*.bmp");
|
||||||
|
|
||||||
Qd.setSorting(QDir::Name);
|
Qd.setSorting(QDir::Name);
|
||||||
QString PathFile=Path;
|
QString PathFile=Path;
|
||||||
|
@ -78,7 +81,21 @@ void SimpleGLWidget::LoadTexture(QString p,int level)
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
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_MIN_FILTER,GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||||
|
|
||||||
|
e=glGetError();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//load the texture corrisponding to a level
|
||||||
|
void SimpleGLWidget::LoadTextureRaw(int level)
|
||||||
|
{
|
||||||
|
//glGenTextures(1, &texName);
|
||||||
|
//glBindTexture(GL_TEXTURE_2D, texName);
|
||||||
|
//glTexImage2D( GL_TEXTURE_2D, 0,GL_LUMINANCE, 512, 512, 0,GL_LUMINANCE, GL_SHORT, &s->V.Data[level*512*512] );
|
||||||
|
//glEnable(GL_TEXTURE_2D);
|
||||||
|
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleGLWidget::drawSlide()
|
void SimpleGLWidget::drawSlide()
|
||||||
|
@ -88,9 +105,12 @@ void SimpleGLWidget::drawSlide()
|
||||||
glMatrixMode (GL_TEXTURE);
|
glMatrixMode (GL_TEXTURE);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_NORMALIZE);
|
/*glEnable(GL_NORMALIZE);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
|
*/
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glDisable(GL_LIGHT0);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
float dx=s->BBox().DimX();
|
float dx=s->BBox().DimX();
|
||||||
|
@ -107,7 +127,7 @@ void SimpleGLWidget::drawSlide()
|
||||||
Point3f p2=p0+Point3f(dx,dy,0.f);
|
Point3f p2=p0+Point3f(dx,dy,0.f);
|
||||||
Point3f p3=p0+Point3f(0.f,dy,0.f);
|
Point3f p3=p0+Point3f(0.f,dy,0.f);
|
||||||
|
|
||||||
glColor3d(1,1,1);
|
glColor3d(0.8,0.8,0.8);
|
||||||
|
|
||||||
///texture
|
///texture
|
||||||
//_numslide
|
//_numslide
|
||||||
|
@ -263,7 +283,8 @@ void SimpleGLWidget::SmoothMesh()
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleGLWidget::glDraw(){
|
void SimpleGLWidget::glDraw(){
|
||||||
glClearColor(0.2f,0.2f,0.2f,1.f);
|
//glClearColor(0.2f,0.2f,0.2f,1.f);
|
||||||
|
glClearColor(1.f,1.f,1.f,1.f);
|
||||||
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();
|
||||||
|
@ -352,7 +373,14 @@ void SimpleGLWidget::glDraw(){
|
||||||
assert(0);
|
assert(0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
glColor3d(0.4,0.8,0.8);
|
//glColor3d(0.4,0.8,0.8);
|
||||||
|
if (wire)
|
||||||
|
{
|
||||||
|
glColor3d(0,0,0);
|
||||||
|
glLineWidth(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
glColor3d(0.4,0.8,0.8);
|
||||||
if ((fi->intersected)&&(wire))
|
if ((fi->intersected)&&(wire))
|
||||||
glColor3d(1.f,0,0);
|
glColor3d(1.f,0,0);
|
||||||
|
|
||||||
|
@ -396,12 +424,36 @@ void SimpleGLWidget::OpenDirectory()
|
||||||
"Choose a Directory" );
|
"Choose a Directory" );
|
||||||
if (filename!=NULL)
|
if (filename!=NULL)
|
||||||
{
|
{
|
||||||
|
rawImage=false;
|
||||||
filename+="/";
|
filename+="/";
|
||||||
path=filename;
|
path=filename;
|
||||||
const char *pa=filename.ascii();
|
const char *pa=filename.ascii();
|
||||||
char *p=(char*)pa;
|
char *p=(char*)pa;
|
||||||
s->LoadFromDir(p,"prova.txt");
|
s->LoadFromDir(p,"prova.txt");
|
||||||
LoadTexture(p,0);
|
LoadTextureJpg(p,0);
|
||||||
|
_showslides=true;
|
||||||
|
w->SlidesButton->setOn(true);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///open the directiry and initialize dataset
|
||||||
|
void SimpleGLWidget::OpenRaw()
|
||||||
|
{
|
||||||
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
|
"D:/Endocas/",
|
||||||
|
"Raw Files(*.raw)",
|
||||||
|
this,
|
||||||
|
"open file dialog"
|
||||||
|
"Choose a Raw file" );
|
||||||
|
|
||||||
|
if (filename!=NULL)
|
||||||
|
{
|
||||||
|
rawImage=true;
|
||||||
|
const char *pa=filename.ascii();
|
||||||
|
char *p=(char*)pa;
|
||||||
|
s->LoadFromRaw(p);
|
||||||
|
LoadTextureRaw(0);
|
||||||
_showslides=true;
|
_showslides=true;
|
||||||
w->SlidesButton->setOn(true);
|
w->SlidesButton->setOn(true);
|
||||||
repaint();
|
repaint();
|
||||||
|
@ -506,7 +558,10 @@ void SimpleGLWidget::wheelEvent(QWheelEvent *e)
|
||||||
_numslide=oldnum;
|
_numslide=oldnum;
|
||||||
if (s!=0)
|
if (s!=0)
|
||||||
{
|
{
|
||||||
LoadTexture(path,_numslide);
|
if (!rawImage)
|
||||||
|
LoadTextureJpg(path,_numslide);
|
||||||
|
else
|
||||||
|
LoadTextureRaw(_numslide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,6 +587,15 @@ void SimpleGLWidget::Step()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void SimpleGLWidget::MarchingCubesExtraction()
|
||||||
|
// {
|
||||||
|
// if (s!=0)
|
||||||
|
// {
|
||||||
|
// s->MarchingCubeExtraction();
|
||||||
|
// repaint();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
void SimpleGLWidget::MarchingCube()
|
void SimpleGLWidget::MarchingCube()
|
||||||
{
|
{
|
||||||
if (s->m->fn>0)
|
if (s->m->fn>0)
|
||||||
|
|
|
@ -31,6 +31,7 @@ private :
|
||||||
bool intForces;
|
bool intForces;
|
||||||
bool resultForces;
|
bool resultForces;
|
||||||
bool continue_int;
|
bool continue_int;
|
||||||
|
bool rawImage;
|
||||||
GLuint texName;
|
GLuint texName;
|
||||||
|
|
||||||
//Segmentator *s;
|
//Segmentator *s;
|
||||||
|
@ -55,7 +56,8 @@ public:
|
||||||
virtual void SaveMatrix();
|
virtual void SaveMatrix();
|
||||||
virtual void Save();
|
virtual void Save();
|
||||||
void LoadMatrix();
|
void LoadMatrix();
|
||||||
void LoadTexture(QString path,int level);
|
void LoadTextureJpg(QString path,int level);
|
||||||
|
void LoadTextureRaw(int level);
|
||||||
void drawSlide();
|
void drawSlide();
|
||||||
void SmoothMesh();
|
void SmoothMesh();
|
||||||
void Step();
|
void Step();
|
||||||
|
@ -63,10 +65,11 @@ public:
|
||||||
void WriteInfo();
|
void WriteInfo();
|
||||||
void ClearMesh();
|
void ClearMesh();
|
||||||
void OpenDirectory();
|
void OpenDirectory();
|
||||||
|
void OpenRaw();
|
||||||
void MarchingCube();
|
void MarchingCube();
|
||||||
void UpdateBBMesh();
|
void UpdateBBMesh();
|
||||||
void setColor();
|
void setColor();
|
||||||
|
//void MarchingCubesExtraction();
|
||||||
//virtual void keyPressEvent(QKeyEvent *qk);
|
//virtual void keyPressEvent(QKeyEvent *qk);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -75,6 +78,11 @@ public:
|
||||||
{
|
{
|
||||||
OpenDirectory();
|
OpenDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenRawFile()
|
||||||
|
{
|
||||||
|
OpenRaw();
|
||||||
|
}
|
||||||
|
|
||||||
void ShowSlides()
|
void ShowSlides()
|
||||||
{
|
{
|
||||||
|
@ -147,6 +155,25 @@ public:
|
||||||
//}
|
//}
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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()
|
void Update()
|
||||||
{
|
{
|
||||||
|
@ -168,7 +195,12 @@ public:
|
||||||
#endif
|
#endif
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
void MCExtraction()
|
||||||
|
{
|
||||||
|
MarchingCubesExtraction();
|
||||||
|
}*/
|
||||||
|
|
||||||
void SetSegmentColor()
|
void SetSegmentColor()
|
||||||
{
|
{
|
||||||
setColor();
|
setColor();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define LimX 512
|
#define LimX 512
|
||||||
#define LimY 512
|
#define LimY 512
|
||||||
|
@ -200,7 +201,7 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
///build and save the strucure made fo blocks
|
///build and save the strucure made fo blocks
|
||||||
void Resample(char *path,char *_newFile)
|
void LoadJpg(char *path,char *_newFile)
|
||||||
{
|
{
|
||||||
pFile=fopen (_newFile,"w+b");
|
pFile=fopen (_newFile,"w+b");
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
///set initial size of buffer in terms of cell
|
///set initial size of buffer in terms of cell
|
||||||
void Init(int size,char* archive,int timeSort=3000)
|
void Init(int size,char* archive,int _timeSort=3000)
|
||||||
{
|
{
|
||||||
timestamp=0;
|
timestamp=0;
|
||||||
n_element=0;
|
n_element=0;
|
||||||
|
@ -264,6 +265,7 @@ public:
|
||||||
CurrStack.clear();
|
CurrStack.clear();
|
||||||
pFile=fopen (archive,"r+b");
|
pFile=fopen (archive,"r+b");
|
||||||
timestamp=0;
|
timestamp=0;
|
||||||
|
timesort=_timeSort;
|
||||||
for(int z=0;z<TLBz;z++)
|
for(int z=0;z<TLBz;z++)
|
||||||
for(int x=0;x<TLBx;x++)
|
for(int x=0;x<TLBx;x++)
|
||||||
for(int y=0;y<TLBy;y++)
|
for(int y=0;y<TLBy;y++)
|
||||||
|
@ -405,9 +407,39 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/*template <class Type, int N=1>
|
||||||
|
Type * Loadraw(char * filename){
|
||||||
|
FILE * f = fopen(filename,"rb");
|
||||||
|
fseek(f,0,SEEK_END);
|
||||||
|
int l= ftell(f);
|
||||||
|
fseek(f,0,SEEK_SET);
|
||||||
|
Type * res = (Type *) malloc(l);
|
||||||
|
int readed = fread(res,sizeof(Type),l/sizeof(Type),f);
|
||||||
|
fclose(f);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
void LoadRaw(char * filename){
|
||||||
|
FILE * f = fopen(filename,"rb");
|
||||||
|
fseek(f,0,SEEK_END);
|
||||||
|
int l= ftell(f);
|
||||||
|
fseek(f,0,SEEK_SET);
|
||||||
|
int n=l/sizeof(ScalarType);
|
||||||
|
int readed = fread(&Data,sizeof(ScalarType),l/sizeof(ScalarType),f);
|
||||||
|
for (int i=0;i<readed;i++){
|
||||||
|
//((unsigned short*)&Data[0][0][0])[i]/=((float)(1<<12))*(float)255;
|
||||||
|
((short*)&Data[0][0][0])[i]+=3024;
|
||||||
|
float a=(float)((short*)&Data[0][0][0])[i]/5324;
|
||||||
|
((short*)&Data[0][0][0])[i]=a*255;
|
||||||
|
}
|
||||||
|
int levels=n/(512*512);
|
||||||
|
Resize(512,512,levels);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
///build and save the strucure made fo blocks
|
///build and save the strucure made fo blocks
|
||||||
void Load(char *path)
|
void LoadJpg(char *path)
|
||||||
{
|
{
|
||||||
//load first one image to see dimensions
|
//load first one image to see dimensions
|
||||||
QImage qI=QImage();
|
QImage qI=QImage();
|
||||||
|
@ -415,6 +447,7 @@ public:
|
||||||
QString qformat;
|
QString qformat;
|
||||||
QString Path=QString(path);
|
QString Path=QString(path);
|
||||||
Qd.setNameFilter("*.jpg");
|
Qd.setNameFilter("*.jpg");
|
||||||
|
//Qd.setNameFilter("*.bmp");
|
||||||
int levels=Qd.count();
|
int levels=Qd.count();
|
||||||
|
|
||||||
Qd.setSorting(QDir::Name);
|
Qd.setSorting(QDir::Name);
|
||||||
|
@ -477,7 +510,7 @@ public:
|
||||||
///return the value of the element in position point3i(i0,i1,i2)
|
///return the value of the element in position point3i(i0,i1,i2)
|
||||||
ScalarType getAt(Point3i p)
|
ScalarType getAt(Point3i p)
|
||||||
{
|
{
|
||||||
assert ((p.V(0)<dimX())&&(p.V(1)<dimY())&&(p.V(2)<dimZ()));
|
assert ((p.V(0)<=dimX())&&(p.V(1)<=dimY())&&(p.V(2)<=dimZ()));
|
||||||
assert ((p.V(0)>=0)&&(p.V(1)>=0)&&(p.V(2)>=0));
|
assert ((p.V(0)>=0)&&(p.V(1)>=0)&&(p.V(2)>=0));
|
||||||
return (Data[p.V(0)][p.V(1)][p.V(2)]);
|
return (Data[p.V(0)][p.V(1)][p.V(2)]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue