From 5613d4c5844ccd1e66636c95b3dccf5b62062d09 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Tue, 8 Feb 2005 17:47:50 +0000 Subject: [PATCH] minor changes --- .../test/segmentation3d/collision_detection.h | 50 +- apps/test/segmentation3d/min_dist_point.h | 202 --- apps/test/segmentation3d/segmentation3d.pro | 56 +- apps/test/segmentation3d/segmentator.h | 189 ++- apps/test/segmentation3d/segmentform.ui | 1471 +++++++++-------- apps/test/segmentation3d/simpleglwidget.cpp | 68 +- apps/test/segmentation3d/simpleglwidget.h | 7 +- apps/test/segmentation3d/volume_dataset.h | 3 + 8 files changed, 1002 insertions(+), 1044 deletions(-) delete mode 100644 apps/test/segmentation3d/min_dist_point.h diff --git a/apps/test/segmentation3d/collision_detection.h b/apps/test/segmentation3d/collision_detection.h index 60c5eb78..090294e8 100644 --- a/apps/test/segmentation3d/collision_detection.h +++ b/apps/test/segmentation3d/collision_detection.h @@ -32,6 +32,7 @@ public: //control if two faces share an edge bool ShareEdge(SimplexType *f0,SimplexType *f1) { + assert((!f0->IsD())&&(!f1->IsD())); for (int i=0;i<3;i++) if (f0->FFp(i)==f1) return (true); @@ -49,6 +50,7 @@ public: //control if two faces share a vertex bool ShareVertex(SimplexType *f0,SimplexType *f1) { + assert((!f0->IsD())&&(!f1->IsD())); for (int i=0;i<3;i++) for (int j=0;j<3;j++) if (f0->V(i)==f1->V(j)) @@ -61,7 +63,7 @@ public: bool TestRealIntersection(SimplexType *f0,SimplexType *f1) { - if (((!f0->IsActive())&&(!f1->IsActive()))||(f0->IsD())||(f1->IsD())) + if ((f0->IsD())||(f1->IsD())||((!f0->IsActive())&&(!f1->IsActive()))) return false; //no adiacent faces if ((f0!=f1)&& (!ShareEdge(f0,f1)) @@ -71,26 +73,28 @@ public: } ///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 + if (!(*si).IsD()) { - std::vector cells=HTable->addSimplex(&*si); - for(std::vector::iterator it=cells.begin();itaddSimplex(&*si); + ///new now + else + { + std::vector cells=HTable->addSimplex(&*si); + for(std::vector::iterator it=cells.begin();it cells=HTable->addSimplex(&*si); for(std::vector::iterator it=cells.begin();itaddSimplex(&*newSimplex); + ///new now + else + { + std::vector cells=HTable->addSimplex(&*newSimplex); + for(std::vector::iterator it=cells.begin();it computeSelfIntersection() diff --git a/apps/test/segmentation3d/min_dist_point.h b/apps/test/segmentation3d/min_dist_point.h deleted file mode 100644 index 6cd4722b..00000000 --- a/apps/test/segmentation3d/min_dist_point.h +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -* VCGLib o o * -* Visual and Computer Graphics Library o o * -* _ O _ * -* Copyright(C) 2004 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ -/**************************************************************************** - History - -$Log: not supported by cvs2svn $ -Revision 1.6 2004/05/14 00:34:36 ganovelli -header added - -****************************************************************************/ - -#ifndef __VCG_MINDISTPOINT -#define __VCG_MINDISTPOINT -#include - -#include -#include -#include -#include -#include - - -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, ma non sono riuscito a definirlo implicitamente - -template -void MinDistPoint( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & mdist, - Point3 & normf, Point3 & bestq, typename MESH::FaceType * &f, Point3 &ip) -{ - typedef SCALAR scalar; - typedef Point3 Point3x; - typedef Box3 Box3x; - - if(!gr.bbox.IsIn(p)) return; - typedef typename GridStaticPtr::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(dxElem())) ) - { - 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=0 && iy=0 && izElem())) ) - { - 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) -void MinDistPoint( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & mdist, - Point3 & normf, Point3 & bestq, typename MESH::face_type * &f) -{ - Point3 ip; - MinDistPoint(mesh,p,gr,mdist,normf,bestq,f,ip); -} -#endif diff --git a/apps/test/segmentation3d/segmentation3d.pro b/apps/test/segmentation3d/segmentation3d.pro index 3d3307b1..821701da 100644 --- a/apps/test/segmentation3d/segmentation3d.pro +++ b/apps/test/segmentation3d/segmentation3d.pro @@ -14,7 +14,61 @@ SOURCES += D:/sf/wrap/gui/trackmode.cpp \ D:/sf/wrap/ply/plylib.cpp \ simpleglwidget.cpp \ main.cpp -FORMS = segmentform.ui +FORMS = segmentform.ui \ + d:\sf\apps\test\segmentation3d\segmentform.ui +IMAGES = D:/sf/apps/test/segmentation3d/slider.jpg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/test/segmentation3d/segmentator.h b/apps/test/segmentation3d/segmentator.h index fe370cf6..db2d0366 100644 --- a/apps/test/segmentation3d/segmentator.h +++ b/apps/test/segmentation3d/segmentator.h @@ -26,20 +26,8 @@ #include #include -//#include - -///marching cubes - -//#include #include -//#ifdef _EXTENDED_MARCH -// #include -//#else -// #include -//#endif - - #include #include @@ -51,9 +39,6 @@ #include #include -///debugghe -#include -///debugghe class Segmentator{ @@ -86,7 +71,6 @@ public: void UpdateAcceleration() { - //if ((!IsBlocked(this))&&(!IsStopped(this))) if ((!blocked)&&(!stopped)) { Acc()=(IntForce()+ExtForce())/Mass(); @@ -127,9 +111,9 @@ public: bool IsActive() { - return(!(((V(0)->blocked)||(V(0)->stopped))&& + return((!(((V(0)->blocked)||(V(0)->stopped))&& ((V(1)->blocked)||(V(1)->stopped))&& - ((V(2)->blocked)||(V(2)->stopped)))); + ((V(2)->blocked)||(V(2)->stopped))))&&(!intersected)); } bool IsBlocked() @@ -149,11 +133,16 @@ public: ///update of the internal forces using the dihedral angle bool Update ( void ) { + if (!this->IsD()) + { for (int i=0;i<3;i++) { MyFace *fopp=FFp(i); - MyFace *myAddr=fopp->FFp(FFi(i)); - if ((fopp!=0)||(foppIsD()) + MyFace *myAddr=fopp->FFp(FFi(i)); + + if ((fopp->IsD())||(fopp!=0)||(foppP()-V((i+1)%3)->P()).Normalize(); @@ -177,6 +166,7 @@ public: } } } + } return(__super::Update()); } }; @@ -248,27 +238,6 @@ public: { 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::PerFaceNormalized(m); - //vcg::tri::UpdateBounding::Box(m); - //vcg::tri::UpdateEdges::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(m,new_m,emc); - - //vcg::tri::io::ExporterPLY::Save(new_m,"D:/lillo.ply"); } ~Segmentator() @@ -386,10 +355,8 @@ private: bool OutOfLimits(MyTriMesh::CoordType p) { Point3f test=p; - /*Point3f max=UnScale(MapToSpace(V.Max())); - Point3f min=UnScale(MapToSpace(V.Min()));*/ - Point3f max=BBox().max;//last change - Point3f min=BBox().min;//last change + Point3f max=BBox().max-Point3f(1.f,1.f,1.f);//last change + Point3f min=BBox().min;//+Point3f(1.f,1.f,1.f);//last change for (int i=0;i<3;i++) { if(((test.V(i)>=max.V(i))||(test.V(i)<=min.V(i)))) @@ -422,6 +389,24 @@ private: void SetIntersectedFace(MyFace *f) { f->intersected=true; + ///detaching from ff topology + /*MyFace *f0=f->FFp(0); + MyFace *f1=f->FFp(1); + MyFace *f2=f->FFp(2); + int i0=f->FFi(0); + int i1=f->FFi(1); + int i2=f->FFi(2); + + f0->FFp(i0)=f0; + f1->FFp(i1)=f1; + f2->FFp(i2)=f2; + + f0->FFi(i0)=0; + f1->FFi(i1)=1; + f2->FFi(i2)=2; + + f->SetD();*/ + } bool IsStopped(MyVertex *v) @@ -443,20 +428,21 @@ private: v->stopped=false; } -///re-set physical pararmeters on the mesh -void InitPhysParam(float k_elanst,float mass,float k_dihedral) -{ - for (unsigned int i=0;iface.size();i++) - { - m->face[i].Init(k_elanst,mass,k_dihedral); - } -} +/////re-set physical pararmeters on the mesh +//void InitPhysParam(float k_elanst,float mass,float k_dihedral) +//{ +// for (unsigned int i=0;iface.size();i++) +// { +// if (!m->face[i].IsD()) +// m->face[i].Init(k_elanst,mass,k_dihedral); +// } +//} ///set the initial mesh of deformable object void InitMesh(MyTriMesh *m) { m->Clear(); - + vcg::tri::Icosahedron(*m); vcg::tri::UpdateTopology::FaceFace(*m); @@ -468,7 +454,7 @@ void InitMesh(MyTriMesh *m) { 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()); + // m.vert[i].P()=UnScale(m.vert[i].P()); // P_Vertex.push_back(&m.vert[i]); } @@ -481,7 +467,7 @@ void InitMesh(MyTriMesh *m) ///return true if the gray level of the vertex v differ from graylevel less than tolerance bool InTolerance(MyTriMesh::VertexType *v) { - return (abs(getColor(v->P())-gray_init)P())-(float)gray_init)<(float)tolerance); } ///add to the vertex v a containing force basing on diffence from tolerance @@ -511,7 +497,7 @@ MyTriMesh::CoordType GradientFactor(MyTriMesh::VertexType *v) void AddExtForces() { Part_VertexContainer::iterator vi; - + PartialUpdateNormals(); end_loop=true; for (vi=P_Vertex.begin();viblocked=true; + { SetBlocked(&*vi); + (*vi).ExtForce()=MyTriMesh::CoordType(0,0,0); + } + else if ((!IsBlocked(&*vi))&&(!IsStopped(&*vi))) { end_loop=false; @@ -565,7 +554,6 @@ void Reinit_PVectors() MyTriMesh::FaceIterator fi; for (fi=m->face.begin();fiface.end();fi++) { - //if ((!fi->IsBlocked())) if ((!fi->IsD())&&(!fi->IsBlocked())) P_Faces.push_back(&(*fi)); } @@ -582,13 +570,13 @@ void Refresh_PVectors() unsigned int i=0; for (i=0;iblocked) + if ((!P_Vertex[i]->IsD())&&(!P_Vertex[i]->blocked)) P_VertexAux.push_back(P_Vertex[i]); } for (i=0;iIsBlocked()) + if ((!P_Faces[i]->IsD())&&(!P_Faces[i]->IsBlocked())) P_FacesAux.push_back(P_Faces[i]); } @@ -604,13 +592,13 @@ void AddNewElements(MyTriMesh::VertexIterator vi,MyTriMesh::FaceIterator fi) { while (vi!=m->vert.end()) { - if (!(*vi).IsD()) + if ((!(*vi).IsD())&&(!(*vi).blocked)&&(!(*vi).stopped)) P_Vertex.push_back(&(*vi)); vi++; } while (fi!=m->face.end()) { - if (!(*fi).IsD()) + if ((!(*fi).IsD())&&((*fi).IsActive())) P_Faces.push_back(&(*fi)); fi++; } @@ -657,6 +645,35 @@ bool TimeSelfIntersection() return false; } + +void PartialUpdateNormals() +{ + Part_FaceContainer::iterator fi; + for (fi=P_Faces.begin();fiIsD() && (*fi).V(j)->IsRW() ) + (*fi).V(j)->N() += t; + } + + for(vi=P_Vertex.begin();vi!=P_Vertex.end();++vi) + if( !(*vi).IsD() && (*vi).IsRW() ) + (*vi).N().Normalize(); + +} + ///refine the mesh and re-update eventually void RefineStep(float _edge_size) { @@ -673,12 +690,19 @@ void RefineStep(float _edge_size) MyTriMesh::FaceIterator finit2=m->face.begin(); if ((vinit2!=vinit)||(finit2!=finit)) + { Reinit_PVectors(); + CollDet->RefreshElements(); + } else + { AddNewElements(vend,fend); + CollDet->UpdateStep(P_Faces); + } - vcg::tri::UpdateNormals::PerVertexNormalized(*m); - CollDet->RefreshElements(); + //vcg::tri::UpdateNormals::PerVertexNormalized(*m); + PartialUpdateNormals(); + //CollDet->RefreshElements(); } } @@ -688,7 +712,8 @@ void ReinitPhysicMesh() Part_FaceContainer::iterator pfi; for (pfi=P_Faces.begin();pfiUpdateStep(); CollDet->UpdateStep(P_Faces); std::vector coll=CollDet->computeSelfIntersection(); for (std::vector::iterator it=coll.begin();itIsD()) + { + SetBlockedFace(*it); + SetIntersectedFace(*it); + } } } @@ -745,7 +772,7 @@ void LoadFromDir(char *in, char *out) } ///set parameters for segmentation -void SetSegmentParameters(int color,int tol,float Mass=0.5f,float K_elanst=0.2f,float Dihedral=0.2f,float Time_stamp=0.2f, +void SetSegmentParameters(int tol,float Mass=0.5f,float K_elanst=0.2f,float Dihedral=0.2f,float Time_stamp=0.2f, float Edge_precision=4.f,Point3f ScaleFactor=Point3f(1.f,1.f,1.f), clock_t _interval=1000,clock_t _interval2=250) { @@ -775,17 +802,11 @@ void InitSegmentation(MyTriMesh::CoordType b) TrINT->SetPDESolver(PDESolvers::EULER_METHOD); - ////caso optimized - ///*V.Resample(inDir,outDir); - - //V.Init(1000,outDir);*/ - //V.Load(inDir); - // - /*bbox=vcg::Box3(MapToSpace(V.Min()),MapToSpace(V.Max()));*/ - InitMesh(m); + //init the mesh with new Reinit_PVectors(); + ReinitPhysicMesh(); CollDet->Init(bbox.min,bbox.max,5.f); @@ -836,10 +857,22 @@ void AutoStep() } } +/////set as deleted intersected vertices +//void ClearIntersectedFaces() +//{ +// MyTriMesh::FaceIterator fi; +// for (fi=m->face.begin();fiface.end();fi++) +// if ((*fi).intersected==true) +// (*fi).SetD(); +// +//} + ///first version void Resample() { + //ClearIntersectedFaces(); new_m=new MyTriMesh(); + vcg::tri::UpdateBounding::Box(*m); vcg::trimesh::Resampler::Resample(*m,*new_m, Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision)); diff --git a/apps/test/segmentation3d/segmentform.ui b/apps/test/segmentation3d/segmentform.ui index 9c2dd7b9..370a3ac1 100644 --- a/apps/test/segmentation3d/segmentform.ui +++ b/apps/test/segmentation3d/segmentform.ui @@ -8,741 +8,759 @@ 0 0 - 1232 - 981 + 1100 + 974 + + + 211 + 839 + + Segmentation - + - buttonGroup1 + unnamed - - - 10 - 0 - 1030 - 50 - - - - - - + - ResultButton - - - - 740 - 10 - 110 - 31 - - - - - 10 - - - - ResultForces - - - true + layout1 + + + unnamed + + + + buttonGroup1 + + + + 7 + 0 + 0 + 0 + + + + + + + + ResultButton + + + + 740 + 10 + 110 + 31 + + + + + 10 + + + + ResultForces + + + true + + + + + InternalButton + + + + 590 + 10 + 110 + 31 + + + + + 10 + + + + InternalForces + + + true + + + + + BlockedButton + + + + 270 + 10 + 110 + 31 + + + + + 10 + + + + BlockedFaces + + + true + + + + + SlidesButton + + + + 10 + 10 + 80 + 31 + + + + + 10 + + + + Slides + + + true + + + + + WireButton + + + + 130 + 10 + 100 + 31 + + + + + 10 + + + + Wire + + + true + + + true + + + true + + + + + ExternalButton + + + + 420 + 10 + 120 + 31 + + + + + 10 + + + + ExternalForces + + + true + + + + + + simpleGLWidget1 + + + + 5 + 5 + 0 + 0 + + + + - + - InternalButton + buttonGroup2 - - - 590 - 10 - 110 - 31 - + + + 0 + 3 + 0 + 0 + - - - 10 - - - - InternalForces - - - true - - - - - ExternalButton - - - - 420 - 10 - 120 - 31 - - - - - 10 - - - - ExternalForces - - - true - - - - - BlockedButton - - - - 270 - 10 - 110 - 31 - - - - - 10 - - - - BlockedFaces - - - true - - - - - SlidesButton - - - - 10 - 10 - 80 - 31 - - - - - 10 - - - - Slides - - - true - - - - - WireButton - - - - 130 - 10 - 100 - 31 - - - - - 10 - - - - Wire - - - true - - - true - - - true - - - - - - simpleGLWidget1 - - - - 0 - 50 - 1030 - 880 - - - - - - buttonGroup2 - - - - 1040 - 0 - 191 - 930 - - - - - 0 - 5 - 0 - 0 - - - - - - - - textLabel1_2 - - - - 30 - 190 - 90 - 21 - - - - - 10 - - - - initial time step - - - - - D_angle - - - - 30 - 150 - 70 - 31 - - - - - 10 - - - - LineEditPanel - - - Sunken - - - 0.2 - - - 3 - - - - - textLabel1_4 - - - - 30 - 130 - 150 - 21 - - - - - 10 - - - - dihedral angle constant - - - - - K_elanst - - - - 30 - 90 - 70 - 31 - - - - - 10 - - - - LineEditPanel - - - Sunken - - - 0.2 - - - 3 - - - - - textLabel1 - - - - 30 - 70 - 131 - 21 - - - - - 10 - - - - spring constant - - - - - M_particles - - - - 30 - 30 - 70 - 31 - - - - - 10 - - - - 2 - - - 0.5 - - - 3 - - - - - textLabel1_3 - - - - 30 - 10 - 131 - 21 - - - - - 10 - - - - mass of particles - - - - - textLabel1_2_2_2_3 - - - - 30 - 300 - 140 - 50 - - - - - 10 - - - - Slide dinstance (pixel) - - - - - textLabel1_2_2 - - - - 30 - 250 - 116 - 21 - - - - - 10 - - - - minimum edge size - - - - - S_dist - - - - 30 - 340 - 70 - 31 - - - - - 10 - - - - 1 - - - 1 - - - - - Tolerance - - - - 30 - 400 - 70 - 31 - - - - - 10 - - - - 10 - - - 2 - - - - - textLabel1_2_2_2_2 - - - - 30 - 440 - 116 - 21 - - - - - 10 - - - - color - - - - - Color - - - false - - - - 30 - 460 - 70 - 30 - - - - - 10 - - - - LineEditPanel - - - Sunken - - + - - 0 - + + + textLabel1_2 + + + + 30 + 190 + 90 + 21 + + + + + 10 + + + + initial time step + + + + + D_angle + + + + 30 + 150 + 70 + 31 + + + + + 10 + + + + LineEditPanel + + + Sunken + + + 0.2 + + + 3 + + + + + textLabel1_4 + + + + 30 + 130 + 150 + 21 + + + + + 10 + + + + dihedral angle constant + + + + + K_elanst + + + + 30 + 90 + 70 + 31 + + + + + 10 + + + + LineEditPanel + + + Sunken + + + 0.2 + + + 3 + + + + + textLabel1 + + + + 30 + 70 + 131 + 21 + + + + + 10 + + + + spring constant + + + + + M_particles + + + + 30 + 30 + 70 + 31 + + + + + 10 + + + + 2 + + + 0.5 + + + 3 + + + + + textLabel1_3 + + + + 30 + 10 + 131 + 21 + + + + + 10 + + + + mass of particles + + + + + textLabel1_2_2_2_3 + + + + 30 + 300 + 140 + 50 + + + + + 10 + + + + Slide dinstance (pixel) + + + + + textLabel1_2_2 + + + + 30 + 250 + 116 + 21 + + + + + 10 + + + + minimum edge size + + + + + S_dist + + + + 30 + 340 + 70 + 31 + + + + + 10 + + + + 1 + + + 1 + + + + + Tolerance + + + + 30 + 400 + 70 + 31 + + + + + 10 + + + + 10 + + + 2 + + + + + E_size + + + + 30 + 270 + 70 + 31 + + + + + 10 + + + + 4 + + + 1 + + + + + T_step + + + + 30 + 210 + 70 + 31 + + + + + 10 + + + + LineEditPanel + + + Sunken + + + 0.2 + + + 3 + + + + + SmoothButton + + + + 30 + 660 + 140 + 30 + + + + + 10 + + + + 0 + + + Smooth + + + + + SaveButton + + + + 30 + 700 + 140 + 31 + + + + + 10 + + + + SavePly + + + + + ClearButton + + + + 30 + 740 + 140 + 30 + + + + + 10 + + + + 0 + + + ClearMesh + + + + + Marching_Cubes + + + + 30 + 619 + 141 + 31 + + + + + 10 + + + + Marching Cube + + + + + SegmentButton + + + + 30 + 580 + 141 + 31 + + + + + 10 + + + + Extract + + + true + + + + + ApplyButton + + + + 30 + 540 + 141 + 31 + + + + + 10 + + + + Apply + + + + + textLabel1_2_2_2 + + + + 30 + 380 + 116 + 21 + + + + + 10 + + + + tolerance + + + + + textLabel1_2_2_2_2 + + + + 30 + 440 + 116 + 21 + + + + + 10 + + + + color + + + + + slider1 + + + + 14 + 505 + 170 + 20 + + + + 255 + + + Horizontal + + + + + GrayScale + + + + 14 + 460 + 170 + 31 + + + + slider.jpg + + + true + + - - - E_size - - - - 30 - 270 - 70 - 31 - - - - - 10 - - - - 4 - - - 1 - - - - - T_step - - - - 30 - 210 - 70 - 31 - - - - - 10 - - - - LineEditPanel - - - Sunken - - - 0.2 - - - 3 - - - - - SmoothButton - - - - 30 - 660 - 140 - 30 - - - - - 10 - - - - 0 - - - Smooth - - - - - SaveButton - - - - 30 - 700 - 140 - 31 - - - - - 10 - - - - SavePly - - - - - ClearButton - - - - 30 - 740 - 140 - 30 - - - - - 10 - - - - 0 - - - ClearMesh - - - - - Marching_Cubes - - - - 30 - 619 - 141 - 31 - - - - - 10 - - - - Marching Cube - - - - - SegmentButton - - - - 30 - 580 - 141 - 31 - - - - - 10 - - - - Extract - - - true - - - - - ApplyButton - - - - 30 - 540 - 141 - 31 - - - - - 10 - - - - Apply - - - - - textLabel1_2_2_2 - - - - 30 - 380 - 116 - 21 - - - - - 10 - - - - tolerance - - - + @@ -784,10 +802,11 @@ SavePly() Extract() Apply() - Clear() - slot() Open() CleanMesh() + Clear() + slot() + SetSegmentColor() @@ -870,7 +889,7 @@ - 789c534e494dcbcc4b554829cdcdad8c2fcf4c29c95030e0524611cd48cd4ccf28010a1797249664262b2467241641a592324b8aa363156c15aab914146aadb90067111b1f + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154789cad94514c5b5518c77fe7dc4b7b4b6150bb96324418ca32358bee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d6a78d0b027b3cd07d9e68c81c625a6c139408a4384f416100aed6d4b7bdb7b8e0fc0921a70c6ed7b3ae7e43bbff3fffedfc927e2f138bbd1dbdbab7902118fc785d8058f8d8de9aeae2e72b91cb66de338ce7f82e47239666767492412b8aefbf0dcdc553a323242f4501d918e2d3a8f15a9784584100809a609526eafd1a0f54e6142e029c5c21f3ef41583bb77a805efbe1ce9d86279e32619678eaab7853fa0f02a16abb64166ad0cdac75307eb3874b84cb0a14aa5a24108cc0688c48c9a4a1e826ddbe6f0b12219678e8ace610502ccdfafe3f68d3c33bf6c01c59dcc209d472c4e0d35d2f3ba81d205d06005e4de60c77170bd2255af80150870f70e8c0eaf009260a349577714e913a4175d16925b5cbe50607931cc3b677c68ca28a5f7066f5b26f00760febec9e8f032a0e81b68a17fc0201415989647a9d8c4c498cbe8f05f5cff3a4d4bac8bfe210b290b35e01afd428257b1b875cd01aaf4bd1de5dd0fea688e1530ad1c1bab16b7af17393558cf997311c0e49bafd670d6258621f6576c9ab09a3248fe5ae6c08103f49f36517213d33070369bf8e2529ee9c90ceb2b2eef7f14617c2c48722a4b7226845143fa87622905ebeb6514253a9eb5084504a66950c88618bee0303d99217cb09e9ed71a09369538fa523d00e9a50a42eed3bc6d8f41281fa0903e8561796cac86f8f2b33c33930ea0f0fb4d5adbeb30ad22866ffbbad226d2a805d7ee0484220208925aaa50deaa67e27b97e9c90ccdcdf5c462cdd8a94d2e7e62f3603244ea410989a4ed191f52a8fd156b056d9d553a9e0bf0e7ef45c6bf7339fd5e90ec7a88575e6d20d6e6e7e2a755ec854dce7fb8885b2cd014f6f3c2714d3a550bae55ac35c1068fb7061b00b87a7995899b25ce9e0b73e24d8fae97b37c7cbe9370b499fce6066eb54adf6098f6ee2a9a7ff9c70841a5023d270deca510d746537c7e29cdf8ad20475fb4307c82d4fc324ec6859d66fdfc6381e44014b36e9fe6e572393ca54068aa22cfd0598b686b3737aeae90bc9725796f0350802414b6e81b7c9a9f7e70708a2e6e5991cfeee3f1ecec2c0b0b3e8c068142a2a8d23728397132c6dc6f2e2b8b0a8da4b5ddc7f3c735ed47146f0cb4502983693a4c25ca7b83138904fa8a412466e00f48b4271086c2901263676c4a6990b615b6ade15b85694af239984a94585bf6f606bbae5b334f1f37e4a3531e031c8fc7c5a312ff17f849c3e3f1b8f81b8be6900aca9b61c90000000049454e44ae426082 @@ -958,9 +977,15 @@ simpleGLWidget1 Clear() + + slider1 + sliderMoved(int) + simpleGLWidget1 + SetSegmentColor() + - + simpleglwidget.h diff --git a/apps/test/segmentation3d/simpleglwidget.cpp b/apps/test/segmentation3d/simpleglwidget.cpp index 34df73db..5a9320f0 100644 --- a/apps/test/segmentation3d/simpleglwidget.cpp +++ b/apps/test/segmentation3d/simpleglwidget.cpp @@ -4,6 +4,7 @@ #include #include #include +#include extern Segmentator *s; @@ -66,7 +67,7 @@ void SimpleGLWidget::LoadTexture(QString p,int level) QString PathFile=Path; PathFile.append(Qd[level]); - bool b=qI.load(PathFile,qformat); + qI.load(PathFile,qformat); QImage tx = QGLWidget::convertToGLFormat (qI); @@ -155,7 +156,7 @@ void drawForces(Segmentator::Part_VertexContainer *pv,int typeForce) { Segmentator::Part_VertexContainer::iterator vi; glPushAttrib(GL_ALL_ATTRIB_BITS); -glLineWidth(0.3); +glLineWidth(0.3f); glDisable(GL_NORMALIZE); glDisable(GL_LIGHTING); glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); @@ -169,7 +170,7 @@ else if (typeForce==2) glColor3d(0,1,0); -for (vi=pv->begin();viend();vi++) +for (vi=pv->begin();viend();++vi) { glBegin(GL_LINE_LOOP); vcg::glVertex((*vi).P()); @@ -262,8 +263,7 @@ void SimpleGLWidget::SmoothMesh() } void SimpleGLWidget::glDraw(){ - - glClearColor(0.2,0.2,0.2,1); + glClearColor(0.2f,0.2f,0.2f,1.f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -336,31 +336,42 @@ void SimpleGLWidget::glDraw(){ else glPolygonMode(GL_FRONT,GL_FILL); - int i=0; if (s->m!=NULL) { glBegin(GL_TRIANGLES); for (fi=s->m->face.begin();fim->face.end();fi++) { - glColor3d(0.4,0.8,0.8); - if (fi->intersected) - glColor3d(1.f,0,0); + if(!(*fi).IsD()) + { + glColor3d(0.4,0.8,0.8); + if (fi->intersected) + glColor3d(1.f,0,0); - if (((blocked)&&(!fi->IsBlocked()))||(!blocked)) - { - - if (!wire) - vcg::glNormal(fi->Normal()); + if (((blocked)&&(!fi->IsBlocked()))||(!blocked)) + { + if (!wire) + { + vcg::glNormal(fi->V(0)->N()); + vcg::glVertex(fi->V(0)->P()); + vcg::glNormal(fi->V(1)->N()); + vcg::glVertex(fi->V(1)->P()); + vcg::glNormal(fi->V(2)->N()); + vcg::glVertex(fi->V(2)->P()); + } + else + { + vcg::glVertex(fi->V(0)->P()); + vcg::glVertex(fi->V(1)->P()); + vcg::glVertex(fi->V(2)->P()); + } - vcg::glVertex(fi->V(0)->P()); - vcg::glVertex(fi->V(1)->P()); - vcg::glVertex(fi->V(2)->P()); + } + } } } glEnd(); - } - glPopMatrix(); - //WriteInfo(); + glPopMatrix(); + //WriteInfo(); } QGLWidget::glDraw(); @@ -442,13 +453,11 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e ) //LoadMatrix(); glReadPixels(e->x(),_H-e->y(),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&winz); gluUnProject(e->x(),_H-e->y(),winz,modelMatrix,projection,viewport,&x,&y,&z); - QString color=""; - color.sprintf("%i",s->gray_init); - //w->Color->text()=color; + SetExtractionParameters(); - //s->SetInitialBarycenter(Point3f(x,y,_numslide)); - //s->InitSegmentation(Point3f(x,y,_numslide)); s->InitSegmentation(Point3f(x,y,z)); + w->slider1->setValue(s->gray_init); + UpdateBBMesh(); //vcg::tri::UpdateBounding::Box(*(s->m)); repaint(); @@ -456,6 +465,11 @@ void SimpleGLWidget::mousePressEvent ( QMouseEvent * e ) //vcg::tri::UpdateBounding::Box(s->m); } +void SimpleGLWidget::setColor() +{ + s->gray_init=w->slider1->value(); +} + void SimpleGLWidget::wheelEvent(QWheelEvent *e) { if (!_showslides) @@ -520,7 +534,7 @@ void SimpleGLWidget::SetExtractionParameters() //int color =atoi(w->Color->text()); ///to modify - s->SetSegmentParameters(s->gray_init,tolerance,mass,k_elanst,dihedral,timestep,edge,Point3f(1.f,1.f,dinstance)); + s->SetSegmentParameters(tolerance,mass,k_elanst,dihedral,timestep,edge,Point3f(1.f,1.f,dinstance)); } void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e ) @@ -536,7 +550,7 @@ void SimpleGLWidget::mouseMoveEvent ( QMouseEvent * e ) void SimpleGLWidget::initializeGL(){ - GLfloat f[4]={0.2,0.2,0.2,1.f}; + GLfloat f[4]={0.2f,0.2f,0.2f,1.f}; GLfloat p[4]={3,3,5,0}; glLightfv(GL_LIGHT0, GL_AMBIENT,f); glLightfv(GL_LIGHT1, GL_POSITION,p); diff --git a/apps/test/segmentation3d/simpleglwidget.h b/apps/test/segmentation3d/simpleglwidget.h index f3ace1dc..10387731 100644 --- a/apps/test/segmentation3d/simpleglwidget.h +++ b/apps/test/segmentation3d/simpleglwidget.h @@ -63,6 +63,7 @@ public: void OpenDirectory(); void MarchingCube(); void UpdateBBMesh(); + void setColor(); //virtual void keyPressEvent(QKeyEvent *qk); @@ -163,5 +164,9 @@ public: UpdateBBMesh(); repaint(); } - + + void SetSegmentColor() + { + setColor(); + } }; \ No newline at end of file diff --git a/apps/test/segmentation3d/volume_dataset.h b/apps/test/segmentation3d/volume_dataset.h index 2c575f67..6e0ddbf9 100644 --- a/apps/test/segmentation3d/volume_dataset.h +++ b/apps/test/segmentation3d/volume_dataset.h @@ -1,3 +1,5 @@ +#ifndef _SEG3D_VOLUMEDATASET +#define _SEG3D_VOLUMEDATASET #include #include @@ -481,3 +483,4 @@ public: } }; +#endif \ No newline at end of file