From a506fdf8c7bed40422acdfa33eaac9154a59262e Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Mon, 18 Jul 2005 15:46:23 +0000 Subject: [PATCH] minor changes --- .../test/segmentation3d/collision_detection.h | 1 + apps/test/segmentation3d/main.cpp | 6 +- apps/test/segmentation3d/segmentation3d.pro | 20 ++ apps/test/segmentation3d/segmentator.h | 182 ++++++++++------ apps/test/segmentation3d/segmentform.ui | 199 ++++++++++-------- apps/test/segmentation3d/simpleglwidget.cpp | 80 ++++++- apps/test/segmentation3d/simpleglwidget.h | 38 +++- apps/test/segmentation3d/volume_dataset.h | 41 +++- 8 files changed, 399 insertions(+), 168 deletions(-) diff --git a/apps/test/segmentation3d/collision_detection.h b/apps/test/segmentation3d/collision_detection.h index 746de764..bd2ed29c 100644 --- a/apps/test/segmentation3d/collision_detection.h +++ b/apps/test/segmentation3d/collision_detection.h @@ -82,6 +82,7 @@ public: { if (!(*si).IsD()) { + (*si).Mark()=0; if (!(*si).IsActive()) HTable->AddElem(&*si); diff --git a/apps/test/segmentation3d/main.cpp b/apps/test/segmentation3d/main.cpp index d2ef98eb..8f037706 100644 --- a/apps/test/segmentation3d/main.cpp +++ b/apps/test/segmentation3d/main.cpp @@ -31,8 +31,8 @@ int main( int argc, char ** argv ) #ifdef _TORUS //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.8f,0.8f,0.2f,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.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().max=Point3f(40.f,40.f,40.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 ); 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() ) ); diff --git a/apps/test/segmentation3d/segmentation3d.pro b/apps/test/segmentation3d/segmentation3d.pro index 6965ca4e..bf671130 100644 --- a/apps/test/segmentation3d/segmentation3d.pro +++ b/apps/test/segmentation3d/segmentation3d.pro @@ -242,6 +242,26 @@ FORMS = segmentform.ui \ + + + + + + + + + + + + + + + + + + + + diff --git a/apps/test/segmentation3d/segmentator.h b/apps/test/segmentation3d/segmentator.h index 96901331..e293f1c1 100644 --- a/apps/test/segmentation3d/segmentator.h +++ b/apps/test/segmentation3d/segmentator.h @@ -8,8 +8,8 @@ // #include //#else -#include -#include +#include +#include //#endif @@ -43,6 +43,7 @@ #include #include +//#include class Segmentator{ @@ -52,11 +53,11 @@ struct DummyEdge; struct DummyTetra; struct MyFace; -#ifdef _EXTENDED_MARCH +//#ifdef _EXTENDED_MARCH +// struct MyVertex: public ParticleBasic > +//#else struct MyVertex: public ParticleBasic > -#else - struct MyVertex: public ParticleBasic > -#endif +//#endif { public: @@ -100,7 +101,7 @@ public: }; ///this class implements the deformable triangle in a mass spring system - struct MyFace : public TriangleMassSpring< vcg::FaceAFFNFMRT > + struct MyFace : public TriangleMassSpring< vcg::FaceAFAVFNFMRT > { public: bool intersected; @@ -108,18 +109,28 @@ public: ScalarType AreaRep; int _Mark; + CoordType old_N; + MyFace() { intersected=false; ClearFlags(); } - + + bool NormInversion() + { + return (((old_N*NormalizedNormal())<0)||(Normal().Norm()<0.01)); + } + void Init ( double k, double mass,float k_dihedral ) { __super::Init(k,mass); kdihedral=k_dihedral; AreaRep=((V(1)->RPos() - V(0)->RPos()) ^ (V(2)->RPos() - V(0)->RPos())).Norm(); SetS(); + ComputeNormal(); + old_N=Normal(); + old_N.Normalize(); } bool IsActive() @@ -171,7 +182,7 @@ public: ///update of the internal forces using the dihedral angle 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++) { @@ -185,6 +196,15 @@ public: if ((foppintersected))//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 CoordType DirEdge=(V(i)->P()-V((i+1)%3)->P()).Normalize(); 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()); - ///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; ///new @@ -371,7 +365,7 @@ private: MyTriMesh::CoordType p1=MyTriMesh::CoordType(p.X(),p.Z(),p.Y()); 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); else return (0.f); @@ -489,6 +483,8 @@ private: { f->intersected=true; f->ClearS(); + SetBlockedFace(f); + //if ((!f->intersected)&&(!f->IsD())) //{ // f->intersected=true; @@ -589,11 +585,10 @@ MyTriMesh::CoordType GradientFactor(MyTriMesh::VertexType *v) void AddExtForces() { Part_VertexContainer::iterator vi; - //PartialUpdateNormals(); + /*PartialUpdateNormals();*/ end_loop=true; for (vi=P_Vertex.begin();viIsD())&&(!vi->blocked)) 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)); } @@ -645,7 +640,7 @@ void Reinit_PVectors() MyTriMesh::FaceIterator fi; for (fi=m->face.begin();fiface.end();fi++) { - if ((!fi->IsD())&&(!fi->IsBlocked())) + if ((!fi->IsD())&&(!fi->IsBlocked())&&(!fi->intersected)) P_Faces.push_back(&(*fi)); } } @@ -659,17 +654,20 @@ void Refresh_PVectors() P_VertexAux.clear(); unsigned int i=0; + ///as first control normal inversion + for (i=0;iNormInversion())//if one step inversion the block vertices + SetIntersectedFace(P_Faces[i]); + else + P_Faces[i]->old_N=NormalizedNormal(*P_Faces[i]); + for (i=0;iIsD())&&(!P_Vertex[i]->blocked)) + if ((!P_Vertex[i]->IsD())&&(!P_Vertex[i]->blocked))//&&(!P_Vertex[i]->stopped)) P_VertexAux.push_back(P_Vertex[i]); - } for (i=0;iIsD())&&(!P_Faces[i]->IsBlocked())) + if ((!P_Faces[i]->IsD())&&(!P_Faces[i]->intersected)&&(!P_Faces[i]->IsBlocked()))//&&(!P_Faces[i]->IsActive()))//&&(!P_Faces[i]->IsBlocked())) P_FacesAux.push_back(P_Faces[i]); - } P_Faces.clear(); P_Vertex.clear(); @@ -739,8 +737,8 @@ bool TimeSelfIntersection() void PartialUpdateNormals() { - //vcg::tri::UpdateNormals::PerFaceNormalized(*m); - //vcg::tri::UpdateNormals::PerVertexNormalized(*m); + /*vcg::tri::UpdateNormals::PerFaceNormalized(*m); + vcg::tri::UpdateNormals::PerVertexNormalized(*m);*/ Part_FaceContainer::iterator fi; for (fi=P_Faces.begin();fiIsD() && (*fi).V(j)->IsRW() ) (*fi).V(j)->N() += t; @@ -765,6 +763,30 @@ void PartialUpdateNormals() if( !(*vi).IsD() && (*vi).IsRW() ) (*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();viface.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() @@ -829,6 +851,7 @@ void RefineStep(float _edge_size) vcg::tri::UpdateNormals::PerVertexNormalized(*m);*/ PartialUpdateNormals(); + PartialReinitPhysicMesh(); //#ifdef _DEBUG // vcg::tri::UpdateTopology::TestFaceFace(*m); @@ -839,14 +862,10 @@ void RefineStep(float _edge_size) } ///reset vertex position and unblock them -void ReinitPhysicMesh() +void PartialReinitPhysicMesh() { Part_FaceContainer::iterator pfi; - /*for (pfi=P_Faces.begin();pfivert.begin();pvivert.end();++pvi) + if(!(*pvi).IsD()) + (*pvi).SetRestPos(); + + for (pfi=m->face.begin();pfiface.end();++pfi) + if((!(*pfi).IsD())&&((!(*pfi).intersected))) + (*pfi).Init(k_elanst,mass,k_dihedral); + + PartialUpdateNormals();*/ /*for (MyTriMesh::VertexIterator vi=m.vert.begin();vi(MapToSpace((V.Min())),(MapToSpace(V.Max()))); } +///set the input +void LoadFromRaw(char *inDir) +{ + /*V.LoadRaw(inDir); + bbox=vcg::Box3(MapToSpace((V.Min())),(MapToSpace(V.Max())));*/ +} + ///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, 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 Reinit_PVectors(); - ReinitPhysicMesh(); + PartialReinitPhysicMesh(); CollDet->Init(bbox.min,bbox.max,5.f); } @@ -970,13 +1009,16 @@ void Step(float t,float _edge_size) { AddExtForces(); TrINT->Step(t); + PartialUpdateNormals(); VerifyForces(); Refresh_PVectors(); if (end_loop) { - RefineStep(_edge_size); - ReinitPhysicMesh(); ClearStopped(); + Reinit_PVectors(); + PartialReinitPhysicMesh(); + RefineStep(_edge_size); + /*ReinitPhysicMesh();*/ } if (TimeSelfIntersection()) CollisionDetection(); @@ -985,7 +1027,9 @@ void Step(float t,float _edge_size) void Smooth() { - ScaleLaplacianSmooth(*m,1,0.5); + //ScaleLaplacianSmooth(*m,1,0.5); + vcg::tri::UpdateTopology::VertexFace(*m); + PasoDobleSmooth(*m,1); } 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 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 void ClearIntersectedFaces() { @@ -1033,14 +1089,14 @@ void Resample() Point3i((int) edge_precision,(int) edge_precision,(int) edge_precision),edge_init); #else vcg::trimesh::Resampler::Resample(*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 // delete(new_m0); delete(m); m=new_m; Reinit_PVectors(); - ReinitPhysicMesh(); + PartialReinitPhysicMesh(); CollDet->Init(bbox.min,bbox.max,5.f); } diff --git a/apps/test/segmentation3d/segmentform.ui b/apps/test/segmentation3d/segmentform.ui index b1d395cb..05a39fe7 100644 --- a/apps/test/segmentation3d/segmentform.ui +++ b/apps/test/segmentation3d/segmentform.ui @@ -15,7 +15,7 @@ 211 - 839 + 868 @@ -559,75 +559,6 @@ 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 @@ -710,22 +641,6 @@ Horizontal - - - GrayScale - - - - 14 - 460 - 170 - 31 - - - - true - - T_step @@ -756,6 +671,94 @@ 3 + + + GrayScale + + + + 14 + 460 + 170 + 31 + + + + true + + + + + Marching_Cubes + + + + 30 + 620 + 141 + 31 + + + + + 10 + + + + Resample mesh + + + Down, Down, Esc, Ctrl+Z + + + + + SegmentButton + + + + 30 + 580 + 141 + 31 + + + + + 10 + + + + Extract + + + true + + + + + ClearButton + + + + 30 + 740 + 140 + 30 + + + + + 10 + + + + 0 + + + ClearMesh + + @@ -769,6 +772,10 @@ + + + + @@ -802,8 +809,9 @@ Open() CleanMesh() Clear() - slot() SetSegmentColor() + OpenRawFile() + slot() @@ -883,6 +891,17 @@ new item + + + fileOpenRawAction + + + OpenRaw + + + OpenRaw + + @@ -980,6 +999,12 @@ simpleGLWidget1 SetSegmentColor() + + fileOpenRawAction + activated() + simpleGLWidget1 + OpenRawFile() + diff --git a/apps/test/segmentation3d/simpleglwidget.cpp b/apps/test/segmentation3d/simpleglwidget.cpp index f9c8b101..92b8b093 100644 --- a/apps/test/segmentation3d/simpleglwidget.cpp +++ b/apps/test/segmentation3d/simpleglwidget.cpp @@ -55,13 +55,16 @@ void SimpleGLWidget::LoadMatrix() } //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(); QDir Qd=QDir(p); QString qformat; QString Path=QString(p); Qd.setNameFilter("*.jpg"); + //Qd.setNameFilter("*.bmp"); Qd.setSorting(QDir::Name); QString PathFile=Path; @@ -78,7 +81,21 @@ void SimpleGLWidget::LoadTexture(QString p,int level) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - + + 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() @@ -88,9 +105,12 @@ void SimpleGLWidget::drawSlide() glMatrixMode (GL_TEXTURE); glLoadIdentity(); glEnable(GL_TEXTURE_2D); - glEnable(GL_NORMALIZE); + /*glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + */ + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); float dx=s->BBox().DimX(); @@ -107,7 +127,7 @@ void SimpleGLWidget::drawSlide() Point3f p2=p0+Point3f(dx,dy,0.f); Point3f p3=p0+Point3f(0.f,dy,0.f); - glColor3d(1,1,1); + glColor3d(0.8,0.8,0.8); ///texture //_numslide @@ -263,7 +283,8 @@ void SimpleGLWidget::SmoothMesh() } 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); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -352,7 +373,14 @@ void SimpleGLWidget::glDraw(){ 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)) glColor3d(1.f,0,0); @@ -396,12 +424,36 @@ void SimpleGLWidget::OpenDirectory() "Choose a Directory" ); if (filename!=NULL) { + rawImage=false; filename+="/"; path=filename; const char *pa=filename.ascii(); char *p=(char*)pa; 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; w->SlidesButton->setOn(true); repaint(); @@ -506,7 +558,10 @@ void SimpleGLWidget::wheelEvent(QWheelEvent *e) _numslide=oldnum; 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() { if (s->m->fn>0) diff --git a/apps/test/segmentation3d/simpleglwidget.h b/apps/test/segmentation3d/simpleglwidget.h index da0cfed2..a3b9b287 100644 --- a/apps/test/segmentation3d/simpleglwidget.h +++ b/apps/test/segmentation3d/simpleglwidget.h @@ -31,6 +31,7 @@ private : bool intForces; bool resultForces; bool continue_int; + bool rawImage; GLuint texName; //Segmentator *s; @@ -55,7 +56,8 @@ public: virtual void SaveMatrix(); virtual void Save(); void LoadMatrix(); - void LoadTexture(QString path,int level); + void LoadTextureJpg(QString path,int level); + void LoadTextureRaw(int level); void drawSlide(); void SmoothMesh(); void Step(); @@ -63,10 +65,11 @@ public: void WriteInfo(); void ClearMesh(); void OpenDirectory(); + void OpenRaw(); void MarchingCube(); void UpdateBBMesh(); void setColor(); - + //void MarchingCubesExtraction(); //virtual void keyPressEvent(QKeyEvent *qk); public slots: @@ -75,6 +78,11 @@ public: { OpenDirectory(); } + + void OpenRawFile() + { + OpenRaw(); + } void ShowSlides() { @@ -147,6 +155,25 @@ public: //} 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() { @@ -168,7 +195,12 @@ public: #endif repaint(); } - + /* + void MCExtraction() + { + MarchingCubesExtraction(); + }*/ + void SetSegmentColor() { setColor(); diff --git a/apps/test/segmentation3d/volume_dataset.h b/apps/test/segmentation3d/volume_dataset.h index 6e0ddbf9..12d6e58e 100644 --- a/apps/test/segmentation3d/volume_dataset.h +++ b/apps/test/segmentation3d/volume_dataset.h @@ -7,6 +7,7 @@ #include #include #include +#include #define LimX 512 #define LimY 512 @@ -200,7 +201,7 @@ private: public: ///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"); @@ -256,7 +257,7 @@ public: } ///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; n_element=0; @@ -264,6 +265,7 @@ public: CurrStack.clear(); pFile=fopen (archive,"r+b"); timestamp=0; + timesort=_timeSort; for(int z=0;z + 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=0)&&(p.V(1)>=0)&&(p.V(2)>=0)); return (Data[p.V(0)][p.V(1)][p.V(2)]); }