From 833bdbac88a6ee3c8a7e048d3d9a8e26f8120b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= <ulman@mpi-cbg.de> Date: Thu, 13 Oct 2016 01:22:46 +0200 Subject: [PATCH] Added LoadNewMesh() and RenderMesh(), added loading of sample sequence. --- cmath3d/TriangleMesh.cpp | 2 +- src/graphics.cpp | 4 +- src/main.cpp | 105 ++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 31 deletions(-) diff --git a/cmath3d/TriangleMesh.cpp b/cmath3d/TriangleMesh.cpp index 8e1eb64..658b26a 100644 --- a/cmath3d/TriangleMesh.cpp +++ b/cmath3d/TriangleMesh.cpp @@ -401,7 +401,7 @@ int ActiveMesh::ImportVTK_Volumetric(const char *filename) int ActiveMesh::ImportVTK_Ftree(const char *filename,bool resetMesh) { const int PointsOnRadiusPeriphery=10; - const float radiusCorrection=0.2f; + const float radiusCorrection=0.1f; if (resetMesh) { diff --git a/src/graphics.cpp b/src/graphics.cpp index 0af17c1..7234685 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -57,13 +57,15 @@ bool showVertexSurface=false; bool showQuadricSurface=false; bool showTEST=false; +int LoadNewMesh(int fileNo); +int RenderMesh(int fileNo); ///manage \e count steps of the simulation and then print and draw void step(int count) { while ((params.currTime < params.stopTime) && (count > 0)) { - //do some job + LoadNewMesh(int(params.currTime)); params.currTime += params.incrTime; --count; diff --git a/src/main.cpp b/src/main.cpp index 5801cae..eba0f1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,37 +10,28 @@ void ParamsSetup(void); // ActiveMesh mesh; +int LoadNewMesh(int fileNo); +int RenderMesh(int fileNo); int main(void) { ParamsSetup(); - //load mesh +/* + //SURFACE FITTING: + //char filename[]="../sample_input/samplecell.stl"; //char filename[]="../sample_input/torus_100_30.stl"; char filename[]="../sample_input/sphere.stl"; - char VTKfile[]="../sample_input/ID1_t001_nucleusSurf2148.vtk"; //surface - //char VTKfile[]="../sample_input/ID1_t001_nucleus2038.vtk"; //volumetric - - //int retval=mesh.ImportSTL(filename); - int retval=mesh.ImportVTK(VTKfile); - //int retval=mesh.ImportVTK_Volumetric(VTKfile); + int retval=mesh.ImportSTL(filename); if (retval) { std::cout << "some error reading file: " << retval << "\n"; return(1); } - retval=mesh.ImportVTK_Ftree("../sample_input/ID1_t001_fTree01.vtk"); - retval=mesh.ImportVTK_Ftree("../sample_input/ID1_t001_fTree02.vtk"); - if (retval) - { - std::cout << "some error reading f-tree: " << retval << "\n"; - return(2); - } - - //std::cout << "mesh: " << filename << "\n"; + std::cout << "mesh: " << filename << "\n"; std::cout << "vertices #: " << mesh.Pos.size() << "\n"; std::cout << "triangles #: " << mesh.ID.size()/3 << "\n"; std::cout << "normals #: " << mesh.norm.size() << "\n"; @@ -48,22 +39,17 @@ int main(void) mesh.CenterMesh(params.sceneCentre); //work with mesh -/* float surf_coeff[10]; mesh.CalcQuadricSurface_Taubin(10,surf_coeff); */ + + //ISBI: + LoadNewMesh(0); + + /* //render mesh - i3d::Image3d<i3d::GRAY16> mask; - mask.SetOffset(i3d::Offset(0.0,0.0,0.0)); - //mask.SetResolution(i3d::Resolution(20.0,20.0,20.0)); //for torus - //mask.MakeRoom(300,300,300); - mask.SetResolution(i3d::Resolution(2.0,2.0,2.0)); //for sample cell - mask.MakeRoom(600,600,600); - mask.GetVoxelData()=0; - mesh.RenderMask(mask); - mask.SaveImage("mesh.ics"); */ initializeGL(); @@ -99,9 +85,9 @@ void ParamsSetup(void) //adapted for cell cycle length of 24 hours params.cellCycleLength=14.5*60; //[min] - params.currTime=0.f; //all three are in units of minutes - params.incrTime=0.1f; - params.stopTime=5000.f; + params.currTime=0.0f; //all three are in units of minutes + params.incrTime=1.0f; + params.stopTime=50.0f; params.imgSizeX=500; //pixels params.imgSizeY=500; @@ -115,3 +101,64 @@ void ParamsSetup(void) params.imgPhCFilename="PhCImg%05d.tif"; params.tracksFilename="tracks.txt"; } + + +int LoadNewMesh(int fileNo) +{ + char VTK_nucleusSurf[1024]; + char VTK_nucleus[1024]; + char VTK_fTreeA[1024]; + char VTK_fTreeB[1024]; + + sprintf(VTK_nucleusSurf,"../sample_sequence/ID05_t%03d_nucleusSurf.vtk",fileNo); + sprintf(VTK_nucleus, "../sample_sequence/ID05_t%03d_nucleus.vtk",fileNo); + sprintf(VTK_fTreeA, "../sample_sequence/ID05_t%03d_fTree01.vtk",fileNo); + sprintf(VTK_fTreeB, "../sample_sequence/ID05_t%03d_fTree02.vtk",fileNo); + + int retval=mesh.ImportVTK(VTK_nucleusSurf); + //int retval=mesh.ImportVTK_Volumetric(VTK_nucleus); + if (retval) + { + std::cout << "some error reading nucleus: " << retval << "\n"; + return(1); + } + + retval=mesh.ImportVTK_Ftree(VTK_fTreeA); + if (retval) + { + std::cout << "some error reading f-tree: " << retval << "\n"; + return(2); + } + + retval=mesh.ImportVTK_Ftree(VTK_fTreeB); + if (retval) + { + std::cout << "some error reading f-tree: " << retval << "\n"; + return(2); + } + + mesh.CenterMesh(params.sceneCentre); + std::cout << "loaded mesh #" << fileNo << "\n"; + + return(0); +} + + +int RenderMesh(int fileNo) +{ + i3d::Image3d<i3d::GRAY16> mask; + mask.SetOffset(i3d::Offset(0.0,0.0,0.0)); + //mask.SetResolution(i3d::Resolution(20.0,20.0,20.0)); //for torus + //mask.MakeRoom(300,300,300); + mask.SetResolution(i3d::Resolution(2.0,2.0,2.0)); //for sample cell + mask.MakeRoom(600,600,600); + mask.GetVoxelData()=0; + mesh.RenderMask(mask); + + char fileName[1024]; + sprintf(fileName,"mesh_t%03d.tif"); + mask.SaveImage(fileName); + std::cout << "rendered mesh #" << fileNo << "\n"; + + return(0); +} -- GitLab