Skip to content
Snippets Groups Projects
Commit a4655580 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent 871c6739
No related branches found
No related tags found
No related merge requests found
// $Id: Mesh.cpp,v 1.164 2006-08-15 05:19:28 geuzaine Exp $ // $Id: Mesh.cpp,v 1.165 2006-08-15 06:16:43 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -78,6 +78,8 @@ static void drawArrays(VertexArray *va, GLint type, bool useColorArray, ...@@ -78,6 +78,8 @@ static void drawArrays(VertexArray *va, GLint type, bool useColorArray,
bool useNormalArray, bool usePolygonOffset, bool useNormalArray, bool usePolygonOffset,
unsigned int uniformColor, bool drawOutline=false) unsigned int uniformColor, bool drawOutline=false)
{ {
if(!va) return;
glVertexPointer(3, GL_FLOAT, 0, va->vertices->array); glVertexPointer(3, GL_FLOAT, 0, va->vertices->array);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, va->colors->array); glColorPointer(4, GL_UNSIGNED_BYTE, 0, va->colors->array);
glNormalPointer(GL_FLOAT, 0, va->normals->array); glNormalPointer(GL_FLOAT, 0, va->normals->array);
...@@ -257,16 +259,9 @@ class initMeshGFace { ...@@ -257,16 +259,9 @@ class initMeshGFace {
// glDrawElements() instead of glDrawArrays(). // glDrawElements() instead of glDrawArrays().
// 2) we can use tc to stripe the triangles to create strips // 2) we can use tc to stripe the triangles to create strips
if(f->meshRep->va_lines) delete f->meshRep->va_lines;
f->meshRep->va_lines = new VertexArray(2, f->meshRep->edges.size());
if(f->meshRep->va_triangles) delete f->meshRep->va_triangles;
f->meshRep->va_triangles = new VertexArray(3, f->triangles.size());
if(f->meshRep->va_quads) delete f->meshRep->va_quads;
f->meshRep->va_quads = new VertexArray(4, f->quadrangles.size());
if(useEdges && CTX.mesh.surfaces_edges){ if(useEdges && CTX.mesh.surfaces_edges){
if(f->meshRep->va_lines) delete f->meshRep->va_lines;
f->meshRep->va_lines = new VertexArray(2, f->meshRep->edges.size());
std::set<MEdge>::const_iterator it = f->meshRep->edges.begin(); std::set<MEdge>::const_iterator it = f->meshRep->edges.begin();
for(; it != f->meshRep->edges.end(); ++it){ for(; it != f->meshRep->edges.end(); ++it){
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
...@@ -283,8 +278,13 @@ class initMeshGFace { ...@@ -283,8 +278,13 @@ class initMeshGFace {
} }
if(CTX.mesh.surfaces_faces || (!useEdges && CTX.mesh.surfaces_edges)){ if(CTX.mesh.surfaces_faces || (!useEdges && CTX.mesh.surfaces_edges)){
if(f->meshRep->va_triangles) delete f->meshRep->va_triangles;
f->meshRep->va_triangles = new VertexArray(3, f->triangles.size());
_addInArray(f, f->meshRep->va_triangles, f->triangles); _addInArray(f, f->meshRep->va_triangles, f->triangles);
_addInArray(f, f->meshRep->va_triangles, f->quadrangles);
if(f->meshRep->va_quads) delete f->meshRep->va_quads;
f->meshRep->va_quads = new VertexArray(4, f->quadrangles.size());
_addInArray(f, f->meshRep->va_quads, f->quadrangles);
} }
} }
}; };
...@@ -437,20 +437,24 @@ void Draw_Mesh() ...@@ -437,20 +437,24 @@ void Draw_Mesh()
if(!CTX.threads_lock){ if(!CTX.threads_lock){
CTX.threads_lock = 1; CTX.threads_lock = 1;
int stat = GMODEL->getMeshStatus();
if(CTX.mesh.changed) { if(CTX.mesh.changed) {
if(CTX.mesh.smooth_normals){ if(stat > 1 && CTX.mesh.smooth_normals){
if(GMODEL->normals) delete GMODEL->normals; if(GMODEL->normals) delete GMODEL->normals;
GMODEL->normals = new smooth_normals(CTX.mesh.angle_smooth_normals); GMODEL->normals = new smooth_normals(CTX.mesh.angle_smooth_normals);
std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), initSmoothNormalsGFace()); std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), initSmoothNormalsGFace());
} }
std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), initMeshGFace()); if(stat > 1)
std::for_each(GMODEL->firstRegion(), GMODEL->lastRegion(), initMeshGRegion()); std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), initMeshGFace());
if(stat > 2)
std::for_each(GMODEL->firstRegion(), GMODEL->lastRegion(), initMeshGRegion());
} }
if(CTX.mesh.surfaces_faces || CTX.mesh.surfaces_edges) if(stat > 1 && (CTX.mesh.surfaces_faces || CTX.mesh.surfaces_edges))
std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), drawMeshGFace()); std::for_each(GMODEL->firstFace(), GMODEL->lastFace(), drawMeshGFace());
if(CTX.mesh.volumes_faces || CTX.mesh.volumes_edges) if(stat > 2 && (CTX.mesh.volumes_faces || CTX.mesh.volumes_edges))
std::for_each(GMODEL->firstRegion(), GMODEL->lastRegion(), drawMeshGRegion()); std::for_each(GMODEL->firstRegion(), GMODEL->lastRegion(), drawMeshGRegion());
CTX.mesh.changed = 0; CTX.mesh.changed = 0;
......
// $Id: OpenFile.cpp,v 1.111 2006-08-15 04:15:19 geuzaine Exp $ // $Id: OpenFile.cpp,v 1.112 2006-08-15 06:16:43 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -248,12 +248,16 @@ int MergeProblem(char *name, int warn_if_missing) ...@@ -248,12 +248,16 @@ int MergeProblem(char *name, int warn_if_missing)
{ {
// added 'b' for pure Windows programs, since some of these files // added 'b' for pure Windows programs, since some of these files
// contain binary data // contain binary data
FILE *fp; FILE *fp = fopen(name, "rb");
if(!(fp = fopen(name, "rb"))){ if(!fp){
if(warn_if_missing) Msg(WARNING, "Unable to open file '%s'", name); if(warn_if_missing) Msg(WARNING, "Unable to open file '%s'", name);
return 0; return 0;
} }
char header[256];
fgets(header, sizeof(header), fp);
fclose(fp);
Msg(STATUS2, "Reading '%s'", name); Msg(STATUS2, "Reading '%s'", name);
char ext[256], base[256]; char ext[256], base[256];
...@@ -266,7 +270,6 @@ int MergeProblem(char *name, int warn_if_missing) ...@@ -266,7 +270,6 @@ int MergeProblem(char *name, int warn_if_missing)
// terms of gzFile, but until then, this is better than nothing // terms of gzFile, but until then, this is better than nothing
if(fl_choice("File '%s' is in gzip format.\n\nDo you want to uncompress it?", if(fl_choice("File '%s' is in gzip format.\n\nDo you want to uncompress it?",
"Cancel", "Uncompress", NULL, name)){ "Cancel", "Uncompress", NULL, name)){
fclose(fp);
char tmp[256]; char tmp[256];
sprintf(tmp, "gunzip -c %s > %s", name, base); sprintf(tmp, "gunzip -c %s > %s", name, base);
SystemCall(tmp); SystemCall(tmp);
...@@ -308,17 +311,13 @@ int MergeProblem(char *name, int warn_if_missing) ...@@ -308,17 +311,13 @@ int MergeProblem(char *name, int warn_if_missing)
#endif #endif
#endif #endif
else { else {
fpos_t position; if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) ||
fgetpos(fp, &position); !strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) ||
char tmp[256]; !strncmp(header, "$MeshFormat", 11)) {
fgets(tmp, sizeof(tmp), fp);
fsetpos(fp, &position);
if(!strncmp(tmp, "$PTS", 4) || !strncmp(tmp, "$NO", 3) ||
!strncmp(tmp, "$PARA", 5) || !strncmp(tmp, "$ELM", 4) ||
!strncmp(tmp, "$MeshFormat", 11)) {
status = GMODEL->readMSH(name); status = GMODEL->readMSH(name);
} }
else if(!strncmp(tmp, "$PostFormat", 11) || !strncmp(tmp, "$View", 5)) { else if(!strncmp(header, "$PostFormat", 11) ||
!strncmp(header, "$View", 5)) {
status = ReadView(name); status = ReadView(name);
} }
else { else {
...@@ -329,7 +328,6 @@ int MergeProblem(char *name, int warn_if_missing) ...@@ -329,7 +328,6 @@ int MergeProblem(char *name, int warn_if_missing)
SetBoundingBox(); SetBoundingBox();
CTX.mesh.changed = 1; CTX.mesh.changed = 1;
Msg(STATUS2, "Read '%s'", name); Msg(STATUS2, "Read '%s'", name);
fclose(fp);
return status; return status;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment