From 030aa909b562739cda4f2785d204415cfda55f9e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 8 Oct 2004 04:36:21 +0000
Subject: [PATCH] renamed mshdensify to mshsort and modified the spec file to
 install it in the rpm

---
 Makefile                                   |  6 ++++--
 doc/texinfo/gmsh.texi                      | 10 +++++++++-
 gmsh.spec                                  |  4 +++-
 utils/misc/{mshdensify.cpp => mshsort.cpp} | 14 ++++++--------
 4 files changed, 22 insertions(+), 12 deletions(-)
 rename utils/misc/{mshdensify.cpp => mshsort.cpp} (96%)

diff --git a/Makefile b/Makefile
index e316b5810a..2e970daf45 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.372 2004-10-04 05:08:14 geuzaine Exp $
+# $Id: Makefile,v 1.373 2004-10-08 04:36:20 geuzaine Exp $
 #
 # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 #
@@ -64,8 +64,10 @@ variables: configure
 parser:
 	cd Parser && ${MAKE} parser
 
-converters:
+.PHONY: utils
+utils:
 	cd utils/converters/autocad && ${MAKE}
+	cd utils/misc && ${MAKE}
 
 .PHONY: doc
 doc:
diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi
index fc6dd611ea..59df7d1367 100644
--- a/doc/texinfo/gmsh.texi
+++ b/doc/texinfo/gmsh.texi
@@ -1,5 +1,5 @@
 \input texinfo.tex @c -*-texinfo-*-
-@c $Id: gmsh.texi,v 1.134 2004-10-04 04:40:59 geuzaine Exp $
+@c $Id: gmsh.texi,v 1.135 2004-10-08 04:36:21 geuzaine Exp $
 @c
 @c Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 @c
@@ -2690,6 +2690,14 @@ All non-parsed file formats have sections enclosed between @code{$KEY} and
 @cindex File format, mesh
 @cindex @file{.msh} file
 
+Please note that the list of nodes and elements in Gmsh's mesh files do not
+have to be dense or ordered (i.e., the node and element numbers do not have
+to be given in a consecutive or even an ordered way). A sample C++ program
+to transform the formats so that all lists are dense and ordered is
+available in the source distribution (@file{utils/misc/mshsort.cpp}). This
+program is also a good example on how to read and write files in the
+@file{.msh} format.
+
 @menu
 * Version 1.0::                 
 * Version 2.0::                 
diff --git a/gmsh.spec b/gmsh.spec
index 72542f19b4..c56b6fc6ba 100644
--- a/gmsh.spec
+++ b/gmsh.spec
@@ -32,7 +32,7 @@ and/or post-processor.
 
 %build
 make distrib-unix
-make converters
+make utils
 make doc-info
 strip bin/gmsh
 rm -rf CVS */CVS */*/CVS
@@ -45,6 +45,7 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/info
 
 install -m 755 bin/gmsh $RPM_BUILD_ROOT/usr/bin/gmsh
 install -m 755 bin/dxf2geo $RPM_BUILD_ROOT/usr/bin/dxf2geo
+install -m 755 bin/mshsort $RPM_BUILD_ROOT/usr/bin/mshsort
 install -m 644 doc/gmsh.1 $RPM_BUILD_ROOT/usr/share/man/man1/gmsh.1
 install -m 644 doc/texinfo/gmsh.info* $RPM_BUILD_ROOT/usr/share/info/
 
@@ -59,5 +60,6 @@ rm -rf $RPM_BUILD_ROOT
 %doc doc/LICENSE doc/VERSIONS doc/FAQ doc/CREDITS demos tutorial
 /usr/bin/gmsh
 /usr/bin/dxf2geo
+/usr/bin/mshsort
 /usr/share/man/man1/gmsh*
 /usr/share/info/gmsh*
diff --git a/utils/misc/mshdensify.cpp b/utils/misc/mshsort.cpp
similarity index 96%
rename from utils/misc/mshdensify.cpp
rename to utils/misc/mshsort.cpp
index b6c971c360..9789a4f4bb 100644
--- a/utils/misc/mshdensify.cpp
+++ b/utils/misc/mshsort.cpp
@@ -1,4 +1,4 @@
-// $Id: mshdensify.cpp,v 1.1 2004-10-08 02:41:56 geuzaine Exp $
+// $Id: mshsort.cpp,v 1.1 2004-10-08 04:36:21 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -135,10 +135,8 @@ double readMesh(char *fileName, map<int, node*> &nodes, vector<element*> &elemen
 	  fprintf(stderr, "Error: node %d already exists\n", num);
 	  exit(1);
 	}
-	else{
-	  node *n = new node(x, y, z);
-	  nodes[num] = n;
-	}
+	else
+	  nodes[num] = new node(x, y, z);
       }
     }
     else if(!strncmp(&str[1], "ELM", 3) ||
@@ -184,9 +182,8 @@ double readMesh(char *fileName, map<int, node*> &nodes, vector<element*> &elemen
         for(int j = 0; j < numNodes; j++){
 	  int numNode;
           fscanf(fp, "%d", &numNode);
-	  if(nodes.count(numNode)){
+	  if(nodes.count(numNode))
 	    e->addNode(nodes[numNode]);
-	  }
 	  else{
             fprintf(stderr, "Error: Unknown vertex %d in element %d\n", numNode,  num);
 	    exit(1);
@@ -256,7 +253,8 @@ void printMesh(double version, map<int, node*> nodes, vector<element*> elements)
 int main(int argc, char **argv)
 {
   if(argc != 2){
-    fprintf(stderr, "Usage: %s file\n", argv[0]);
+    fprintf(stderr, "mshsort, a utility to reorder the node and element lists in Gmsh MSH files\n");
+    fprintf(stderr, "Usage: %s file.msh\n", argv[0]);
     exit(1);
   }
 
-- 
GitLab