Skip to content
Snippets Groups Projects
Commit 4e77e838 authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

- updated for the two testing meshes

- testing/highlighted vertex changeable with 'v'
- corrected bug when reading STL meshes
parent 31a1ce72
No related branches found
No related tags found
No related merge requests found
...@@ -95,12 +95,21 @@ int ActiveMesh::ImportSTL(const char *filename) ...@@ -95,12 +95,21 @@ int ActiveMesh::ImportSTL(const char *filename)
//read facet by facet //read facet by facet
while (file >> tmp) while (file >> tmp)
{ {
//check tmp for "facet" or complain //check tmp for "facet" or "endsolid" or complain
if (tmp[0] != 'f' if (tmp[0] != 'f'
|| tmp[1] != 'a' || tmp[1] != 'a'
|| tmp[2] != 'c' || tmp[2] != 'c'
|| tmp[3] != 'e' || tmp[3] != 'e'
|| tmp[4] != 't') { file.close(); return(2); } || tmp[4] != 't')
{
//no new face starting, end of file then?
if (tmp[0] != 'e'
|| tmp[1] != 'n'
|| tmp[2] != 'd'
|| tmp[3] != 's'
|| tmp[4] != 'o') { file.close(); return(3); }
else break;
}
//read normal //read normal
file >> tmp; //"normal" keyword file >> tmp; //"normal" keyword
...@@ -115,7 +124,7 @@ int ActiveMesh::ImportSTL(const char *filename) ...@@ -115,7 +124,7 @@ int ActiveMesh::ImportSTL(const char *filename)
|| tmp[1] != 'u' || tmp[1] != 'u'
|| tmp[2] != 't' || tmp[2] != 't'
|| tmp[3] != 'e' || tmp[3] != 'e'
|| tmp[4] != 'r') { file.close(); return(2); } || tmp[4] != 'r') { file.close(); return(4); }
file >> tmp; //"loop" keyword file >> tmp; //"loop" keyword
file >> tmp; //"vertex" keyword file >> tmp; //"vertex" keyword
......
...@@ -106,6 +106,7 @@ void displayAxes(void) ...@@ -106,6 +106,7 @@ void displayAxes(void)
} }
int VertexID=10;
void ActiveMesh::displayMesh(void) void ActiveMesh::displayMesh(void)
{ {
glColor3f(0.8,0.8,0.8); glColor3f(0.8,0.8,0.8);
...@@ -136,18 +137,19 @@ void ActiveMesh::displayMesh(void) ...@@ -136,18 +137,19 @@ void ActiveMesh::displayMesh(void)
glEnd(); glEnd();
} }
static int VertexID=10;
std::vector<size_t> neigs; std::vector<size_t> neigs;
ulm::getVertexImmediateNeighbours(*this,VertexID,neigs); ulm::getVertexImmediateNeighbours(*this,VertexID,neigs);
glPointSize(4.0f); glPointSize(4.0f);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
// centre vertex:
glColor3f(0.0,0.0,1.0);
glVertex3f(Pos[VertexID].x,Pos[VertexID].y,Pos[VertexID].z);
// neigs:
glColor3f(1.0,0.0,0.0);
for (unsigned int i=0; i < neigs.size(); ++i) for (unsigned int i=0; i < neigs.size(); ++i)
glVertex3f(Pos[neigs[i]].x,Pos[neigs[i]].y,Pos[neigs[i]].z); glVertex3f(Pos[neigs[i]].x,Pos[neigs[i]].y,Pos[neigs[i]].z);
glEnd(); glEnd();
++VertexID;
} }
...@@ -163,6 +165,7 @@ void display(void) ...@@ -163,6 +165,7 @@ void display(void)
eye.z+=params.sceneSize.z*cosf(uhel_x)*cosf(uhel_y); eye.z+=params.sceneSize.z*cosf(uhel_x)*cosf(uhel_y);
gluLookAt(eye.x,eye.y,eye.z, //eye gluLookAt(eye.x,eye.y,eye.z, //eye
params.sceneCentre.x,params.sceneCentre.y,params.sceneCentre.z, //center params.sceneCentre.x,params.sceneCentre.y,params.sceneCentre.z, //center
//0.0, cosf(-uhel_y), sinf(-uhel_y)); // up
0.0, 1.0, 0.0); // up 0.0, 1.0, 0.0); // up
displayFrame(); displayFrame();
...@@ -295,6 +298,11 @@ void keyboard(unsigned char key, int mx, int my) ...@@ -295,6 +298,11 @@ void keyboard(unsigned char key, int mx, int my)
glutPostRedisplay(); glutPostRedisplay();
break; break;
case 'v':
++VertexID;
glutPostRedisplay();
break;
case 'i': //inspect a cell case 'i': //inspect a cell
GetSceneViewSize(windowSizeX,windowSizeY, xVisF,xVisT,yVisF,yVisT); GetSceneViewSize(windowSizeX,windowSizeY, xVisF,xVisT,yVisF,yVisT);
sx=(float)mx /(float)windowSizeX * (xVisT-xVisF) + xVisF; sx=(float)mx /(float)windowSizeX * (xVisT-xVisF) + xVisF;
......
...@@ -18,11 +18,11 @@ int main(void) ...@@ -18,11 +18,11 @@ int main(void)
ParamsSetup(); ParamsSetup();
//load mesh //load mesh
//char filename[]="/home/cbia/prace/zerial_pc/DATA/Liver/3dliver--dataForCheckNeighborsFunctions/samplecell.stl"; char filename[]="../sample_input/samplecell.stl";
char filename[]="/home/cbia/prace/zerial_pc/DATA/MT_testingAlgorithms/MeshLab/torus_100_30.stl"; //char filename[]="../sample_input/torus_100_30.stl";
int retval=mesh.ImportSTL(filename); int retval=mesh.ImportSTL(filename);
if (! retval) if (retval)
{ {
std::cout << "some error reading file: " << retval << "\n"; std::cout << "some error reading file: " << retval << "\n";
return(1); return(1);
...@@ -49,13 +49,14 @@ void ParamsSetup(void) ...@@ -49,13 +49,14 @@ void ParamsSetup(void)
{ {
//set up the environment //set up the environment
params.sceneOffset=Vector3d<float>(0.f); params.sceneOffset=Vector3d<float>(0.f);
params.sceneSize=Vector3d<float>(15.f,15.f,15.f); //az se vyladi sily mezi nima //params.sceneSize=Vector3d<float>(15.f,15.f,15.f); //for torus
params.sceneSize=Vector3d<float>(150.f,150.f,150.f); //for sample cell
params.sceneCentre=params.sceneSize; params.sceneCentre=params.sceneSize;
params.sceneCentre/=2.0f; params.sceneCentre/=2.0f;
params.sceneCentre+=params.sceneOffset; params.sceneCentre+=params.sceneOffset;
params.sceneOuterBorder=Vector3d<float>(1.f); params.sceneOuterBorder=Vector3d<float>(2.f);
params.sceneBorderColour.r=0.5f; params.sceneBorderColour.r=0.5f;
params.sceneBorderColour.g=0.5f; params.sceneBorderColour.g=0.5f;
params.sceneBorderColour.b=0.5f; params.sceneBorderColour.b=0.5f;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment