diff -ruN ug-orig/arch/AIX/CVS/Entries ug-patched/arch/AIX/CVS/Entries
--- ug-orig/arch/AIX/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIX/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.6/Fri Jan 24 15:46:27 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/AIX/CVS/Repository ug-patched/arch/AIX/CVS/Repository
--- ug-orig/arch/AIX/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIX/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/AIX
diff -ruN ug-orig/arch/AIX/CVS/Root ug-patched/arch/AIX/CVS/Root
--- ug-orig/arch/AIX/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIX/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/AIX/CVS/Tag ug-patched/arch/AIX/CVS/Tag
--- ug-orig/arch/AIX/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIX/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/AIXGCC/CVS/Entries ug-patched/arch/AIXGCC/CVS/Entries
--- ug-orig/arch/AIXGCC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIXGCC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Fri Jan 24 15:46:29 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/AIXGCC/CVS/Repository ug-patched/arch/AIXGCC/CVS/Repository
--- ug-orig/arch/AIXGCC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIXGCC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/AIXGCC
diff -ruN ug-orig/arch/AIXGCC/CVS/Root ug-patched/arch/AIXGCC/CVS/Root
--- ug-orig/arch/AIXGCC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIXGCC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/AIXGCC/CVS/Tag ug-patched/arch/AIXGCC/CVS/Tag
--- ug-orig/arch/AIXGCC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AIXGCC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/AMD64/CVS/Entries ug-patched/arch/AMD64/CVS/Entries
--- ug-orig/arch/AMD64/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AMD64/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.5/Wed Jul  9 15:39:31 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/AMD64/CVS/Repository ug-patched/arch/AMD64/CVS/Repository
--- ug-orig/arch/AMD64/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AMD64/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/AMD64
diff -ruN ug-orig/arch/AMD64/CVS/Root ug-patched/arch/AMD64/CVS/Root
--- ug-orig/arch/AMD64/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AMD64/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/AMD64/CVS/Tag ug-patched/arch/AMD64/CVS/Tag
--- ug-orig/arch/AMD64/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/AMD64/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/AMD64/mk.arch ug-patched/arch/AMD64/mk.arch
--- ug-orig/arch/AMD64/mk.arch	2008-07-09 17:39:31.000000000 +0200
+++ ug-patched/arch/AMD64/mk.arch	2003-11-21 17:22:12.000000000 +0100
@@ -9,15 +9,15 @@
 ARCH_MAKE     = make
 ARCH_CC       = gcc
 ARCH_C++      = g++
-ARCH_F77      = gfortran
 ARCH_LINK     = gcc
 ARCH_AR       = ar
 ARCH_SUFFIX   = 
 ARCH_POSTLINK = true
 
 ARCH_LIBS     = -lm
+
 ARCH_CFLAGS   = -pipe
-ARCH_NOOPTIM  = -g3 -gdwarf-2
+ARCH_NOOPTIM  = -g
 ARCH_OPTIM    = -O3 -fomit-frame-pointer -funroll-loops -fno-strict-aliasing
 ARCH_C++FLAGS = -fpermissive
 ARCH_LFLAGS   =
diff -ruN ug-orig/arch/BGP/CVS/Entries ug-patched/arch/BGP/CVS/Entries
--- ug-orig/arch/BGP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/BGP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Wed Apr  2 17:20:16 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/BGP/CVS/Repository ug-patched/arch/BGP/CVS/Repository
--- ug-orig/arch/BGP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/BGP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/BGP
diff -ruN ug-orig/arch/BGP/CVS/Root ug-patched/arch/BGP/CVS/Root
--- ug-orig/arch/BGP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/BGP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/BGP/CVS/Tag ug-patched/arch/BGP/CVS/Tag
--- ug-orig/arch/BGP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/BGP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/BGP/mk.arch ug-patched/arch/BGP/mk.arch
--- ug-orig/arch/BGP/mk.arch	2008-04-02 19:20:16.000000000 +0200
+++ ug-patched/arch/BGP/mk.arch	1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
-#
-#	ARCH MAKEFILE OPTIONS
-#
-#	for BlueGene/P
-#
-
-ARCH_TYPE     = __BGP__
-
-ARCH_MAKE     = make
-ARCH_CC       = /bgsys/drivers/ppcfloor/comm/bin/mpixlc
-ARCH_C++      = /bgsys/drivers/ppcfloor/comm/bin/mpixlcxx
-ARCH_LINK     = /bgsys/drivers/ppcfloor/comm/bin/mpixlc
-ARCH_AR       = ar
-ARCH_SUFFIX   = 
-ARCH_POSTLINK = true
-
-ARCH_LIBS     = -lm
-
-ARCH_CFLAGS   =
-ARCH_NOOPTIM  = -g
-ARCH_OPTIM    = -O3 -qarch=450
-ARCH_C++FLAGS = 
-ARCH_LFLAGS   =
-ARCH_ARFLAGS  = rus
-
-ARCH_XINCLUDES =
-ARCH_XLIBS     =
-
diff -ruN ug-orig/arch/C90/CVS/Entries ug-patched/arch/C90/CVS/Entries
--- ug-orig/arch/C90/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/C90/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Fri Jan 24 15:46:31 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/C90/CVS/Repository ug-patched/arch/C90/CVS/Repository
--- ug-orig/arch/C90/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/C90/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/C90
diff -ruN ug-orig/arch/C90/CVS/Root ug-patched/arch/C90/CVS/Root
--- ug-orig/arch/C90/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/C90/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/C90/CVS/Tag ug-patched/arch/C90/CVS/Tag
--- ug-orig/arch/C90/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/C90/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/CC/CVS/Entries ug-patched/arch/CC/CVS/Entries
--- ug-orig/arch/CC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.4/Fri Jan 24 15:46:34 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/CC/CVS/Repository ug-patched/arch/CC/CVS/Repository
--- ug-orig/arch/CC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/CC
diff -ruN ug-orig/arch/CC/CVS/Root ug-patched/arch/CC/CVS/Root
--- ug-orig/arch/CC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/CC/CVS/Tag ug-patched/arch/CC/CVS/Tag
--- ug-orig/arch/CC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/compiler.h ug-patched/arch/compiler.h
--- ug-orig/arch/compiler.h	2008-07-09 17:39:30.000000000 +0200
+++ ug-patched/arch/compiler.h	2010-06-29 12:23:53.000000000 +0200
@@ -18,18 +18,44 @@
 /*                                                                          */
 /****************************************************************************/
 
+/** \file
+    \brief Header file for defining standard constants (machine dependent)
+    
+    This file is part of the old build system.  We strongly suggest you use
+    the new AutoTools build system which does not use this file. 
+
+    In the definitions of the `CFLAGS` in the file 'mk.arch' the
+    key word for a special machine has to be chosen. For example by the 
+    compiler option '-D__HP__' ug is about to run on a HP computer. 
+    Concerning this option the corresponding definitions of the standard 
+    types in the file 'compiler.h' are taken.
+    (The file compiler.h is located in $UGROOT/arch.)
+    
+    As this header file 'compiler.h' defines the standard types used in ug
+    it has to be included in `all` source files of ug!!! 
+    
+    The constant 'ALIGNMENT' has to be set equal to '4' or '8' depending on 
+    the 32 or 64 bit architecture of the machine used. It is also related 
+    to the constant 'ALIGNMASK', which has correspondingly to be set equal 
+    to '0xFFFFFFFC' or '0xFFFFFFF8' to clear the last two or three bits 
+    of a memory address.
+    
+    If you have to add a new mk.? file to support a new machine you also
+    have to provide a new entry in the 'compiler.h' file defining the basic 
+    data types and memory alignment. 
+    To that end you include a flag -D<your new machine>
+    in the CFLAGS section of your new mk.<your new machine> file and add
+    a new paragraph depending on this flag in 'compiler.h'.
+    
+*/
+
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/arch/compiler.h,v 1.74 2008/07/09 15:39:30 lampe Exp $
+$Header$
 */
 
 #ifndef __COMPILER__
 #define __COMPILER__
 
-/* try to import stuff found by autoconf. This is the first time I can
-   use that C-compilers don't fail compilation if a header doesn't
-   exist... */
-#include "config.h"
-
 /* Include the custom type declarations.  This should eventually be included
    directly by the headers who need it and not via compiler.h */
 #include "ugtypes.h"
@@ -76,6 +102,9 @@
 #define _fmt_lG			"lG"
 #define _fmt_lf			"lf"
 
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
 /****************************************************************************/
 /*                                                                          */
 /* #define exactly one of the following constants: (in Makefile)            */
@@ -130,6 +159,7 @@
 #define malloc(n) ((void *) NewPtr((Size) n))
 #define free(p) DisposPtr((Ptr) p)
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -152,6 +182,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -177,6 +208,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -203,6 +235,7 @@
 
 /* memory */
 #define ALIGNMENT 4					    /* power of 2 and >= sizeof(int) !  */ 
+#define ALIGNMASK 0xFFFFFFFC			/* compatible to alignment			*/
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -230,6 +263,7 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) !  */ 
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -260,6 +294,7 @@
 
 /* memory */
 #define ALIGNMENT 8					    /* power of 2 and >= sizeof(int) !  */ 
+#define ALIGNMASK 0xFFFFFFF8			/* compatible to alignment			*/
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -286,6 +321,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -307,6 +343,7 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -329,6 +366,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -353,6 +391,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -373,6 +412,7 @@
 
 /* memory */
 #define ALIGNMENT   8                   /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -397,9 +437,10 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -446,9 +487,10 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym)  lsym ## _
+#define F77SYM(lsym,usym)  lsym
 
 #endif
 
@@ -469,9 +511,10 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -496,9 +539,10 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -523,9 +567,10 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -550,9 +595,10 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -575,31 +621,7 @@
 
 /* memory */
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) !  */
-
-/* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
-
-/* current time as DOUBLE value */
-#undef CURRENT_TIME
-#define CURRENT_TIME   (((DOUBLE)clock())/((DOUBLE)CLOCKS_PER_SEC))
-
-#endif
-
-/****************************************************************************/
-/*                                                                          */
-/* Definitions for BGP                                                      */
-/*                                                                          */
-/****************************************************************************/
-
-#ifdef __BGP__
-#undef __MWCW__
-
-#define ARCHNAME	"BGP"
-
-#include <time.h>
-
-/* memory */
-#define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym) lsym
@@ -626,6 +648,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  usym
@@ -654,6 +677,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  usym
@@ -678,6 +702,7 @@
 
 /* memory */
 #define ALIGNMENT 8               /* power of 2 and >=sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8     /*  compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -700,6 +725,7 @@
 
 /* memory */
 #define ALIGNMENT 4               /* power of 2 and >=sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFFC     /*  compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -720,6 +746,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -741,6 +768,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -763,6 +791,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -790,6 +819,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -814,6 +844,7 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(int) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym ## _
@@ -838,9 +869,10 @@
 
 /* memory */
 #define ALIGNMENT     4             /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK     0xFFFFFFFC    /* compatible to alignment */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym)  lsym ## _
+#define F77SYM(lsym,usym)  lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -860,20 +892,20 @@
 
 #define ARCHNAME	"Mac OS X"
 
-#ifdef __LITTLE_ENDIAN__
-#define __SWAPBYTES__ 1
-#endif
-
 /* memory */
 #define ALIGNMENT     4             /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK     0xFFFFFFFC    /* compatible to alignment */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym)  lsym ## _
+#define F77SYM(lsym,usym)  lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
 #define CURRENT_TIME   (((DOUBLE)clock())/((DOUBLE)CLOCKS_PER_SEC))
 
+    /* MAcOS does not have malloc.h */
+#undef HAVE_MALLOC_H
+
 #endif
 
 #ifdef __PPC64__
@@ -883,9 +915,10 @@
 
 /* memory */
 #define ALIGNMENT 8                     /* power of 2 and >= sizeof(INT) !  */
+#define ALIGNMASK 0xFFFFFFF8            /* compatible to alignment          */
 
 /* fortran interfacing */
-#define F77SYM(lsym,usym) lsym ## _
+#define F77SYM(lsym,usym) lsym
 
 /* current time as DOUBLE value */
 #undef CURRENT_TIME
@@ -917,6 +950,7 @@
 /*#define malloc(n) ((void *) NewPtr((Size) n))
 #define free(p) DisposPtr((Ptr) p)*/
 #define ALIGNMENT 4                     /* power of 2 and >= sizeof(int) ! */
+#define ALIGNMASK 0xFFFFFFFC            /* compatible to alignment */
 
 /* fortran interfacing */
 #define F77SYM(lsym,usym)  lsym
@@ -964,14 +998,7 @@
 
 #define ARCH_VERSION "ARCH_1_0"
 
-/* The following is actually a definition (and not just a declaration) in a header
-   file.  Since DUNE actually includes compiler.h twice from a single source, this
-   definition has to go.  Yes, I know, including a header twice is not nice, but
-   I currently see no other way.
-*/     
-#ifndef FOR_DUNE
-static char compilerrcs_id[] = "$Id: compiler.h,v 1.74 2008/07/09 15:39:30 lampe Exp $";
-#endif
+static char compilerrcs_id[] = "$Id: compiler.h 8369 2010-06-29 10:23:53Z sander $";
 
 /* limits of the basic types */
 #define MAX_S            SHRT_MAX        
diff -ruN ug-orig/arch/CVS/Entries ug-patched/arch/CVS/Entries
--- ug-orig/arch/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-/.cvsignore/1.1/Thu Sep  9 14:44:57 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  9 14:44:57 2004//D2008.11.12.23.00.00
-/compiler.h/1.74/Wed Jul  9 15:39:30 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/CVS/Entries.Log ug-patched/arch/CVS/Entries.Log
--- ug-orig/arch/CVS/Entries.Log	2009-04-28 16:21:30.000000000 +0200
+++ ug-patched/arch/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-A D/AIX////
-A D/AIXGCC////
-A D/AMD64////
-A D/BGP////
-A D/C90////
-A D/CC////
-A D/CYGWIN////
-A D/DEC////
-A D/HP////
-A D/HP20////
-A D/HPUX9////
-A D/LINUXAXP////
-A D/LINUXIA64////
-A D/LINUXPPC////
-A D/MACCLUSTER////
-A D/MACOSX////
-A D/MACOSX64////
-A D/MACOSXSERVER////
-A D/MKLINUX////
-A D/NECSX4////
-A D/NEXTSTEP////
-A D/OPENSTEP////
-A D/ORIGIN////
-A D/PARAGON////
-A D/PC////
-A D/PCCLUSTER////
-A D/PCCPP////
-A D/PCGCOV////
-A D/PCI////
-A D/PCICLUSTER////
-A D/PCICPP////
-A D/POWERGC////
-A D/SGI////
-A D/SGI10////
-A D/SOLARIS////
-A D/SOLARISGCC////
-A D/SP2////
-A D/SR2201////
-A D/SUN4GCC////
-A D/T3D////
-A D/T3E////
-A D/YDL64////
-A D/YMP////
-R D/OPENSTEP////
-R D/NEXTSTEP////
diff -ruN ug-orig/arch/CVS/Repository ug-patched/arch/CVS/Repository
--- ug-orig/arch/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch
diff -ruN ug-orig/arch/CVS/Root ug-patched/arch/CVS/Root
--- ug-orig/arch/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/CVS/Tag ug-patched/arch/CVS/Tag
--- ug-orig/arch/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/.cvsignore ug-patched/arch/.cvsignore
--- ug-orig/arch/.cvsignore	2004-09-09 16:44:57.000000000 +0200
+++ ug-patched/arch/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-semantic.cache
diff -ruN ug-orig/arch/CYGWIN/CVS/Entries ug-patched/arch/CYGWIN/CVS/Entries
--- ug-orig/arch/CYGWIN/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CYGWIN/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Tue Mar  9 16:07:01 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/CYGWIN/CVS/Repository ug-patched/arch/CYGWIN/CVS/Repository
--- ug-orig/arch/CYGWIN/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CYGWIN/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/CYGWIN
diff -ruN ug-orig/arch/CYGWIN/CVS/Root ug-patched/arch/CYGWIN/CVS/Root
--- ug-orig/arch/CYGWIN/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CYGWIN/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/CYGWIN/CVS/Tag ug-patched/arch/CYGWIN/CVS/Tag
--- ug-orig/arch/CYGWIN/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/CYGWIN/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/CYGWIN/mk.arch ug-patched/arch/CYGWIN/mk.arch
--- ug-orig/arch/CYGWIN/mk.arch	2004-03-09 17:07:01.000000000 +0100
+++ ug-patched/arch/CYGWIN/mk.arch	2004-03-09 17:07:06.000000000 +0100
@@ -1,27 +1,27 @@
-#
-#	ARCH MAKEFILE OPTIONS
-#
-#	for Windows + Cygwin
-#
-
-ARCH_TYPE     = __CYGWIN__
-
-ARCH_MAKE     = make
-ARCH_CC       = gcc
-ARCH_C++      = g++
-ARCH_LINK     = gcc
-ARCH_AR       = ar
-ARCH_SUFFIX   = 
-ARCH_POSTLINK = true
-
-ARCH_LIBS     = -lrpclib -lm
-
-ARCH_CFLAGS   = -pipe
-ARCH_NOOPTIM  = -g -Wall -Wno-unused -Wno-parentheses
-ARCH_OPTIM    = -s -O3 -march=i686 -fomit-frame-pointer -funroll-loops -fno-strict-aliasing
-ARCH_C++FLAGS = -fpermissive
-ARCH_LFLAGS   =
-ARCH_ARFLAGS  = rus
-
-ARCH_XINCLUDES = -I/usr/X11R6/include
-ARCH_XLIBS     = -L/usr/X11R6/lib -lXaw -lXt -lXpm -lXmu -lX11 -lXext -lSM -lICE
+#
+#	ARCH MAKEFILE OPTIONS
+#
+#	for Windows + Cygwin
+#
+
+ARCH_TYPE     = __CYGWIN__
+
+ARCH_MAKE     = make
+ARCH_CC       = gcc
+ARCH_C++      = g++
+ARCH_LINK     = gcc
+ARCH_AR       = ar
+ARCH_SUFFIX   = 
+ARCH_POSTLINK = true
+
+ARCH_LIBS     = -lrpclib -lm
+
+ARCH_CFLAGS   = -pipe
+ARCH_NOOPTIM  = -g -Wall -Wno-unused -Wno-parentheses
+ARCH_OPTIM    = -s -O3 -march=i686 -fomit-frame-pointer -funroll-loops -fno-strict-aliasing
+ARCH_C++FLAGS = -fpermissive
+ARCH_LFLAGS   =
+ARCH_ARFLAGS  = rus
+
+ARCH_XINCLUDES = -I/usr/X11R6/include
+ARCH_XLIBS     = -L/usr/X11R6/lib -lXaw -lXt -lXpm -lXmu -lX11 -lXext -lSM -lICE
diff -ruN ug-orig/arch/DEC/CVS/Entries ug-patched/arch/DEC/CVS/Entries
--- ug-orig/arch/DEC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/DEC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Tue Apr  7 12:33:57 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/DEC/CVS/Repository ug-patched/arch/DEC/CVS/Repository
--- ug-orig/arch/DEC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/DEC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/DEC
diff -ruN ug-orig/arch/DEC/CVS/Root ug-patched/arch/DEC/CVS/Root
--- ug-orig/arch/DEC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/DEC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/DEC/CVS/Tag ug-patched/arch/DEC/CVS/Tag
--- ug-orig/arch/DEC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/DEC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/HP/CVS/Entries ug-patched/arch/HP/CVS/Entries
--- ug-orig/arch/HP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.12/Tue Oct 13 14:35:07 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/HP/CVS/Repository ug-patched/arch/HP/CVS/Repository
--- ug-orig/arch/HP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/HP
diff -ruN ug-orig/arch/HP/CVS/Root ug-patched/arch/HP/CVS/Root
--- ug-orig/arch/HP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/HP/CVS/Tag ug-patched/arch/HP/CVS/Tag
--- ug-orig/arch/HP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/HP20/CVS/Entries ug-patched/arch/HP20/CVS/Entries
--- ug-orig/arch/HP20/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP20/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.7/Thu Dec  3 15:00:08 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/HP20/CVS/Repository ug-patched/arch/HP20/CVS/Repository
--- ug-orig/arch/HP20/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP20/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/HP20
diff -ruN ug-orig/arch/HP20/CVS/Root ug-patched/arch/HP20/CVS/Root
--- ug-orig/arch/HP20/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP20/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/HP20/CVS/Tag ug-patched/arch/HP20/CVS/Tag
--- ug-orig/arch/HP20/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HP20/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/HPUX9/CVS/Entries ug-patched/arch/HPUX9/CVS/Entries
--- ug-orig/arch/HPUX9/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HPUX9/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Fri Jan 24 15:46:40 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/HPUX9/CVS/Repository ug-patched/arch/HPUX9/CVS/Repository
--- ug-orig/arch/HPUX9/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HPUX9/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/HPUX9
diff -ruN ug-orig/arch/HPUX9/CVS/Root ug-patched/arch/HPUX9/CVS/Root
--- ug-orig/arch/HPUX9/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HPUX9/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/HPUX9/CVS/Tag ug-patched/arch/HPUX9/CVS/Tag
--- ug-orig/arch/HPUX9/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/HPUX9/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/LINUXAXP/CVS/Entries ug-patched/arch/LINUXAXP/CVS/Entries
--- ug-orig/arch/LINUXAXP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXAXP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Fri Nov 17 14:06:18 2000//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/LINUXAXP/CVS/Repository ug-patched/arch/LINUXAXP/CVS/Repository
--- ug-orig/arch/LINUXAXP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXAXP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/LINUXAXP
diff -ruN ug-orig/arch/LINUXAXP/CVS/Root ug-patched/arch/LINUXAXP/CVS/Root
--- ug-orig/arch/LINUXAXP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXAXP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/LINUXAXP/CVS/Tag ug-patched/arch/LINUXAXP/CVS/Tag
--- ug-orig/arch/LINUXAXP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXAXP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/LINUXIA64/CVS/Entries ug-patched/arch/LINUXIA64/CVS/Entries
--- ug-orig/arch/LINUXIA64/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXIA64/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Thu Oct 25 15:09:45 2007//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/LINUXIA64/CVS/Repository ug-patched/arch/LINUXIA64/CVS/Repository
--- ug-orig/arch/LINUXIA64/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXIA64/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/LINUXIA64
diff -ruN ug-orig/arch/LINUXIA64/CVS/Root ug-patched/arch/LINUXIA64/CVS/Root
--- ug-orig/arch/LINUXIA64/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXIA64/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/LINUXIA64/CVS/Tag ug-patched/arch/LINUXIA64/CVS/Tag
--- ug-orig/arch/LINUXIA64/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXIA64/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/LINUXIA64/mk.arch ug-patched/arch/LINUXIA64/mk.arch
--- ug-orig/arch/LINUXIA64/mk.arch	2007-10-25 17:09:45.000000000 +0200
+++ ug-patched/arch/LINUXIA64/mk.arch	2001-09-12 18:46:29.000000000 +0200
@@ -7,21 +7,21 @@
 ARCH_TYPE     = __LINUXIA64__
 
 ARCH_MAKE     = make
-ARCH_CC       = mpicc
-ARCH_C++      = mpiCC
-ARCH_LINK     = mpicc
+ARCH_CC       = ecc
+ARCH_C++      =
+ARCH_LINK     = ecc
 ARCH_AR       = ar
 ARCH_SUFFIX   = 
 ARCH_POSTLINK = true
 
 ARCH_LIBS     = 
 
-ARCH_CFLAGS   = 
-ARCH_NOOPTIM  = -g
-ARCH_OPTIM    = -O3 -tpp2 -ip
+ARCH_CFLAGS   = -O3 -ip # ecc beta: leave it exactly as it is and recompile
+ARCH_NOOPTIM  =         # ug/np/algebra/fvgeom.c and ug/parallel/ddd/basic/lowcomm.c
+ARCH_OPTIM    =         # by hand with -O2 -ip only (Sep 2001) !!!
 ARCH_C++FLAGS =
-ARCH_LFLAGS   = 
+ARCH_LFLAGS   = -Wl,-relax
 ARCH_ARFLAGS  = rus
 
 ARCH_XINCLUDES = 
-ARCH_XLIBS     = 
+ARCH_XLIBS     = #-L/usr/X11R6/lib -lXaw -lXt -lXmu -lXpm -lXext -lX11 -lSM -lICE
diff -ruN ug-orig/arch/LINUXPPC/CVS/Entries ug-patched/arch/LINUXPPC/CVS/Entries
--- ug-orig/arch/LINUXPPC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXPPC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.5/Tue Mar  9 16:07:06 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/LINUXPPC/CVS/Repository ug-patched/arch/LINUXPPC/CVS/Repository
--- ug-orig/arch/LINUXPPC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXPPC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/LINUXPPC
diff -ruN ug-orig/arch/LINUXPPC/CVS/Root ug-patched/arch/LINUXPPC/CVS/Root
--- ug-orig/arch/LINUXPPC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXPPC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/LINUXPPC/CVS/Tag ug-patched/arch/LINUXPPC/CVS/Tag
--- ug-orig/arch/LINUXPPC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/LINUXPPC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/MACCLUSTER/CVS/Entries ug-patched/arch/MACCLUSTER/CVS/Entries
--- ug-orig/arch/MACCLUSTER/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACCLUSTER/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Fri May  6 12:53:16 2005//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/MACCLUSTER/CVS/Repository ug-patched/arch/MACCLUSTER/CVS/Repository
--- ug-orig/arch/MACCLUSTER/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACCLUSTER/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/MACCLUSTER
diff -ruN ug-orig/arch/MACCLUSTER/CVS/Root ug-patched/arch/MACCLUSTER/CVS/Root
--- ug-orig/arch/MACCLUSTER/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACCLUSTER/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/MACCLUSTER/CVS/Tag ug-patched/arch/MACCLUSTER/CVS/Tag
--- ug-orig/arch/MACCLUSTER/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACCLUSTER/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/MACOSX/CVS/Entries ug-patched/arch/MACOSX/CVS/Entries
--- ug-orig/arch/MACOSX/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.11/Wed Jul  9 15:39:31 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/MACOSX/CVS/Repository ug-patched/arch/MACOSX/CVS/Repository
--- ug-orig/arch/MACOSX/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/MACOSX
diff -ruN ug-orig/arch/MACOSX/CVS/Root ug-patched/arch/MACOSX/CVS/Root
--- ug-orig/arch/MACOSX/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/MACOSX/CVS/Tag ug-patched/arch/MACOSX/CVS/Tag
--- ug-orig/arch/MACOSX/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/MACOSX/mk.arch ug-patched/arch/MACOSX/mk.arch
--- ug-orig/arch/MACOSX/mk.arch	2008-07-09 17:39:31.000000000 +0200
+++ ug-patched/arch/MACOSX/mk.arch	2006-05-31 10:36:57.000000000 +0200
@@ -11,7 +11,6 @@
 ARCH_PMAKE     = gnumake -j 4
 ARCH_CC       = cc
 ARCH_C++      = c++
-ARCH_F77      = g77
 ARCH_LINK     = cc
 ARCH_AR       = ugarranlib ar
 ARCH_SUFFIX   = 
diff -ruN ug-orig/arch/MACOSX64/CVS/Entries ug-patched/arch/MACOSX64/CVS/Entries
--- ug-orig/arch/MACOSX64/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX64/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Mon Feb 11 19:05:34 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/MACOSX64/CVS/Repository ug-patched/arch/MACOSX64/CVS/Repository
--- ug-orig/arch/MACOSX64/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX64/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/MACOSX64
diff -ruN ug-orig/arch/MACOSX64/CVS/Root ug-patched/arch/MACOSX64/CVS/Root
--- ug-orig/arch/MACOSX64/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX64/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/MACOSX64/CVS/Tag ug-patched/arch/MACOSX64/CVS/Tag
--- ug-orig/arch/MACOSX64/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSX64/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/MACOSX64/mk.arch ug-patched/arch/MACOSX64/mk.arch
--- ug-orig/arch/MACOSX64/mk.arch	2008-02-11 20:05:34.000000000 +0100
+++ ug-patched/arch/MACOSX64/mk.arch	2006-06-10 16:14:21.000000000 +0200
@@ -1,37 +1,46 @@
-#
 #       ARCH MAKEFILE OPTIONS
 #
 #       for MacOS X on a 64-bit processor
 #
+#		change the last lines if you want to use Quartz instead of X11
+#
 
-# use this for G5 Macs
-#ARCH_TYPE     = __PPC64__
-
-# use this for Intel Macs
-ARCH_TYPE     = __AMD64__
+ARCH_TYPE     = __PPC64__
 
 ARCH_MAKE     = gnumake
+ARCH_PMAKE     = gnumake -j 4
 ARCH_CC       = gcc
 ARCH_C++      = g++
 ARCH_LINK     = gcc
 ARCH_AR       = ugarranlib ar
 ARCH_SUFFIX   = 
-ARCH_POSTLINK = true
+#ARCH_POSTLINK = ugmacosxpostlink $(PROGNAME) $(APPL)
+ARCH_POSTLINK =
 
 ARCH_LIBS     = 
+ARCH_PLIBS    =
+ARCH_FLIBS    =
 
+#ARCH_CFLAGS   = -arch ppc64 -Wchar-subscripts -Wformat -Wimplicit -Wparentheses -Wno-four-char-constants -Wreturn-type -Wswitch -Wtrigraphs -O -Wuninitialized
+#ARCH_CFLAGS   = -arch ppc64 -gccincludes -ext o -I/usr/include -I/System/Library/Frameworks/System.framework/Versions/B/Headers
 ARCH_CFLAGS   = -m64
+ARCH_C++FLAGS = -m64
 ARCH_NOOPTIM  = -g
 ARCH_OPTIM    = -O3 -fomit-frame-pointer -funroll-loops -fno-strict-aliasing
-ARCH_C++FLAGS = $(ARCH_CFLAGS)
-ARCH_LFLAGS   = $(ARCH_CFLAGS)
+#ARCH_LFLAGS   = -arch ppc64 -sectcreate __ICON __header $(APPL).iconheader -segprot __ICON r r -sectcreate __ICON app $(UGROOT)/dev/mif/UGIcon.tiff -framework AppKit -framework Foundation
+ARCH_LFLAGS   = -m64
 ARCH_ARFLAGS  = ru
+ARCH_FFLAGS   =
+ARCH_EXFLAGS  =
+
+# use these settings if you want to use MacOS X GUI
+#ARCH_XINCLUDES =
+#ARCH_XLIBS     = -framework Cocoa
 
 # use these settings if you want to use X11
-# last time I checked, Apple didn't supply 64-bit X libs
-#ARCH_XINCLUDES = -I/usr/X11R6/include
-#ARCH_XLIBS     = -L/usr/X11R6/lib -lXaw -lXt -lXpm -lXmu -lX11 -lXext -lSM -lICE
+#ARCH_XINCLUDES = -I/usr/X11R6/include/
+#ARCH_XLIBS     = -L/usr/X11R6/lib  -lXaw -lXt -lXpm -lXmu -lX11 -lXext -lSM -lICE
 
-# use these settings if you do not use X11
+# use these settings if you do not use a GUI
 ARCH_XINCLUDES =
 ARCH_XLIBS     =
diff -ruN ug-orig/arch/MACOSXSERVER/CVS/Entries ug-patched/arch/MACOSXSERVER/CVS/Entries
--- ug-orig/arch/MACOSXSERVER/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSXSERVER/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.4/Wed Sep  8 15:18:52 1999//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/MACOSXSERVER/CVS/Repository ug-patched/arch/MACOSXSERVER/CVS/Repository
--- ug-orig/arch/MACOSXSERVER/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSXSERVER/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/MACOSXSERVER
diff -ruN ug-orig/arch/MACOSXSERVER/CVS/Root ug-patched/arch/MACOSXSERVER/CVS/Root
--- ug-orig/arch/MACOSXSERVER/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSXSERVER/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/MACOSXSERVER/CVS/Tag ug-patched/arch/MACOSXSERVER/CVS/Tag
--- ug-orig/arch/MACOSXSERVER/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MACOSXSERVER/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/Makefile.am ug-patched/arch/Makefile.am
--- ug-orig/arch/Makefile.am	2004-09-09 16:44:57.000000000 +0200
+++ ug-patched/arch/Makefile.am	2010-07-04 20:39:07.000000000 +0200
@@ -1,6 +1,7 @@
-# $Id: Makefile.am,v 1.1 2004/09/09 14:44:57 thimo Exp $
+# $Id: Makefile.am 8376 2010-07-04 18:39:07Z christi $
 
 SOURCES = compiler.h
 
 # don't install anymore when autotools are fully used!
-include_HEADERS = compiler.h
+archincludedir = $(pkgincludedir)
+archinclude_HEADERS = compiler.h
diff -ruN ug-orig/arch/MKLINUX/CVS/Entries ug-patched/arch/MKLINUX/CVS/Entries
--- ug-orig/arch/MKLINUX/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MKLINUX/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Tue Jul 22 09:21:40 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/MKLINUX/CVS/Repository ug-patched/arch/MKLINUX/CVS/Repository
--- ug-orig/arch/MKLINUX/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MKLINUX/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/MKLINUX
diff -ruN ug-orig/arch/MKLINUX/CVS/Root ug-patched/arch/MKLINUX/CVS/Root
--- ug-orig/arch/MKLINUX/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MKLINUX/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/MKLINUX/CVS/Tag ug-patched/arch/MKLINUX/CVS/Tag
--- ug-orig/arch/MKLINUX/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/MKLINUX/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/NECSX4/CVS/Entries ug-patched/arch/NECSX4/CVS/Entries
--- ug-orig/arch/NECSX4/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/NECSX4/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.8/Wed Apr  9 12:38:21 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/NECSX4/CVS/Repository ug-patched/arch/NECSX4/CVS/Repository
--- ug-orig/arch/NECSX4/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/NECSX4/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/NECSX4
diff -ruN ug-orig/arch/NECSX4/CVS/Root ug-patched/arch/NECSX4/CVS/Root
--- ug-orig/arch/NECSX4/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/NECSX4/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/NECSX4/CVS/Tag ug-patched/arch/NECSX4/CVS/Tag
--- ug-orig/arch/NECSX4/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/NECSX4/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/ORIGIN/CVS/Entries ug-patched/arch/ORIGIN/CVS/Entries
--- ug-orig/arch/ORIGIN/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/ORIGIN/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.14/Fri Oct 16 08:56:41 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/ORIGIN/CVS/Repository ug-patched/arch/ORIGIN/CVS/Repository
--- ug-orig/arch/ORIGIN/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/ORIGIN/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/ORIGIN
diff -ruN ug-orig/arch/ORIGIN/CVS/Root ug-patched/arch/ORIGIN/CVS/Root
--- ug-orig/arch/ORIGIN/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/ORIGIN/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/ORIGIN/CVS/Tag ug-patched/arch/ORIGIN/CVS/Tag
--- ug-orig/arch/ORIGIN/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/ORIGIN/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PARAGON/CVS/Entries ug-patched/arch/PARAGON/CVS/Entries
--- ug-orig/arch/PARAGON/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PARAGON/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.14/Thu Apr 16 14:41:32 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PARAGON/CVS/Repository ug-patched/arch/PARAGON/CVS/Repository
--- ug-orig/arch/PARAGON/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PARAGON/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PARAGON
diff -ruN ug-orig/arch/PARAGON/CVS/Root ug-patched/arch/PARAGON/CVS/Root
--- ug-orig/arch/PARAGON/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PARAGON/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PARAGON/CVS/Tag ug-patched/arch/PARAGON/CVS/Tag
--- ug-orig/arch/PARAGON/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PARAGON/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PC/CVS/Entries ug-patched/arch/PC/CVS/Entries
--- ug-orig/arch/PC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.18/Wed Jul  9 15:39:31 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PC/CVS/Repository ug-patched/arch/PC/CVS/Repository
--- ug-orig/arch/PC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PC
diff -ruN ug-orig/arch/PC/CVS/Root ug-patched/arch/PC/CVS/Root
--- ug-orig/arch/PC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PC/CVS/Tag ug-patched/arch/PC/CVS/Tag
--- ug-orig/arch/PC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PC/mk.arch ug-patched/arch/PC/mk.arch
--- ug-orig/arch/PC/mk.arch	2008-07-09 17:39:31.000000000 +0200
+++ ug-patched/arch/PC/mk.arch	2004-07-23 15:47:28.000000000 +0200
@@ -9,7 +9,6 @@
 ARCH_MAKE     = make
 ARCH_CC       = gcc
 ARCH_C++      = g++
-ARCH_F77      = g77
 ARCH_LINK     = gcc
 ARCH_AR       = ar
 ARCH_SUFFIX   = 
diff -ruN ug-orig/arch/PCCLUSTER/CVS/Entries ug-patched/arch/PCCLUSTER/CVS/Entries
--- ug-orig/arch/PCCLUSTER/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCLUSTER/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.5/Mon Nov 24 17:06:43 2003//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCCLUSTER/CVS/Repository ug-patched/arch/PCCLUSTER/CVS/Repository
--- ug-orig/arch/PCCLUSTER/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCLUSTER/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCCLUSTER
diff -ruN ug-orig/arch/PCCLUSTER/CVS/Root ug-patched/arch/PCCLUSTER/CVS/Root
--- ug-orig/arch/PCCLUSTER/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCLUSTER/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCCLUSTER/CVS/Tag ug-patched/arch/PCCLUSTER/CVS/Tag
--- ug-orig/arch/PCCLUSTER/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCLUSTER/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PCCPP/CVS/Entries ug-patched/arch/PCCPP/CVS/Entries
--- ug-orig/arch/PCCPP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCPP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Wed Jul 14 14:43:15 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCCPP/CVS/Repository ug-patched/arch/PCCPP/CVS/Repository
--- ug-orig/arch/PCCPP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCPP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCCPP
diff -ruN ug-orig/arch/PCCPP/CVS/Root ug-patched/arch/PCCPP/CVS/Root
--- ug-orig/arch/PCCPP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCPP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCCPP/CVS/Tag ug-patched/arch/PCCPP/CVS/Tag
--- ug-orig/arch/PCCPP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCCPP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PCGCOV/CVS/Entries ug-patched/arch/PCGCOV/CVS/Entries
--- ug-orig/arch/PCGCOV/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCGCOV/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Thu Nov 27 09:48:20 2003//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCGCOV/CVS/Repository ug-patched/arch/PCGCOV/CVS/Repository
--- ug-orig/arch/PCGCOV/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCGCOV/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCGCOV
diff -ruN ug-orig/arch/PCGCOV/CVS/Root ug-patched/arch/PCGCOV/CVS/Root
--- ug-orig/arch/PCGCOV/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCGCOV/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCGCOV/CVS/Tag ug-patched/arch/PCGCOV/CVS/Tag
--- ug-orig/arch/PCGCOV/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCGCOV/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PCI/CVS/Entries ug-patched/arch/PCI/CVS/Entries
--- ug-orig/arch/PCI/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCI/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.3/Wed Jan 21 14:43:29 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCI/CVS/Repository ug-patched/arch/PCI/CVS/Repository
--- ug-orig/arch/PCI/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCI/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCI
diff -ruN ug-orig/arch/PCI/CVS/Root ug-patched/arch/PCI/CVS/Root
--- ug-orig/arch/PCI/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCI/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCI/CVS/Tag ug-patched/arch/PCI/CVS/Tag
--- ug-orig/arch/PCI/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCI/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PCICLUSTER/CVS/Entries ug-patched/arch/PCICLUSTER/CVS/Entries
--- ug-orig/arch/PCICLUSTER/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICLUSTER/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Mon Jul  7 12:29:08 2003//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCICLUSTER/CVS/Repository ug-patched/arch/PCICLUSTER/CVS/Repository
--- ug-orig/arch/PCICLUSTER/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICLUSTER/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCICLUSTER
diff -ruN ug-orig/arch/PCICLUSTER/CVS/Root ug-patched/arch/PCICLUSTER/CVS/Root
--- ug-orig/arch/PCICLUSTER/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICLUSTER/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCICLUSTER/CVS/Tag ug-patched/arch/PCICLUSTER/CVS/Tag
--- ug-orig/arch/PCICLUSTER/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICLUSTER/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/PCICPP/CVS/Entries ug-patched/arch/PCICPP/CVS/Entries
--- ug-orig/arch/PCICPP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICPP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Wed Jul 14 14:40:13 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/PCICPP/CVS/Repository ug-patched/arch/PCICPP/CVS/Repository
--- ug-orig/arch/PCICPP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICPP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/PCICPP
diff -ruN ug-orig/arch/PCICPP/CVS/Root ug-patched/arch/PCICPP/CVS/Root
--- ug-orig/arch/PCICPP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICPP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/PCICPP/CVS/Tag ug-patched/arch/PCICPP/CVS/Tag
--- ug-orig/arch/PCICPP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/PCICPP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/POWERGC/CVS/Entries ug-patched/arch/POWERGC/CVS/Entries
--- ug-orig/arch/POWERGC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/POWERGC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.5/Fri Jan 24 15:46:47 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/POWERGC/CVS/Repository ug-patched/arch/POWERGC/CVS/Repository
--- ug-orig/arch/POWERGC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/POWERGC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/POWERGC
diff -ruN ug-orig/arch/POWERGC/CVS/Root ug-patched/arch/POWERGC/CVS/Root
--- ug-orig/arch/POWERGC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/POWERGC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/POWERGC/CVS/Tag ug-patched/arch/POWERGC/CVS/Tag
--- ug-orig/arch/POWERGC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/POWERGC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SGI/CVS/Entries ug-patched/arch/SGI/CVS/Entries
--- ug-orig/arch/SGI/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.14/Thu Dec  3 14:13:34 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SGI/CVS/Repository ug-patched/arch/SGI/CVS/Repository
--- ug-orig/arch/SGI/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SGI
diff -ruN ug-orig/arch/SGI/CVS/Root ug-patched/arch/SGI/CVS/Root
--- ug-orig/arch/SGI/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SGI/CVS/Tag ug-patched/arch/SGI/CVS/Tag
--- ug-orig/arch/SGI/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SGI10/CVS/Entries ug-patched/arch/SGI10/CVS/Entries
--- ug-orig/arch/SGI10/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI10/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-/mk.arch/1.2/Fri May 28 08:03:43 1999//D2008.11.12.23.00.00
-/mk.arch.gcc/1.1/Fri May 28 08:03:44 1999//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SGI10/CVS/Repository ug-patched/arch/SGI10/CVS/Repository
--- ug-orig/arch/SGI10/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI10/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SGI10
diff -ruN ug-orig/arch/SGI10/CVS/Root ug-patched/arch/SGI10/CVS/Root
--- ug-orig/arch/SGI10/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI10/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SGI10/CVS/Tag ug-patched/arch/SGI10/CVS/Tag
--- ug-orig/arch/SGI10/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SGI10/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SOLARIS/CVS/Entries ug-patched/arch/SOLARIS/CVS/Entries
--- ug-orig/arch/SOLARIS/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARIS/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.12/Thu Jul 15 14:59:16 1999//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SOLARIS/CVS/Repository ug-patched/arch/SOLARIS/CVS/Repository
--- ug-orig/arch/SOLARIS/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARIS/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SOLARIS
diff -ruN ug-orig/arch/SOLARIS/CVS/Root ug-patched/arch/SOLARIS/CVS/Root
--- ug-orig/arch/SOLARIS/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARIS/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SOLARIS/CVS/Tag ug-patched/arch/SOLARIS/CVS/Tag
--- ug-orig/arch/SOLARIS/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARIS/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SOLARISGCC/CVS/Entries ug-patched/arch/SOLARISGCC/CVS/Entries
--- ug-orig/arch/SOLARISGCC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARISGCC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Mon May 26 12:34:38 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SOLARISGCC/CVS/Repository ug-patched/arch/SOLARISGCC/CVS/Repository
--- ug-orig/arch/SOLARISGCC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARISGCC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SOLARISGCC
diff -ruN ug-orig/arch/SOLARISGCC/CVS/Root ug-patched/arch/SOLARISGCC/CVS/Root
--- ug-orig/arch/SOLARISGCC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARISGCC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SOLARISGCC/CVS/Tag ug-patched/arch/SOLARISGCC/CVS/Tag
--- ug-orig/arch/SOLARISGCC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SOLARISGCC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SP2/CVS/Entries ug-patched/arch/SP2/CVS/Entries
--- ug-orig/arch/SP2/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SP2/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.4/Tue Dec 15 14:44:14 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SP2/CVS/Repository ug-patched/arch/SP2/CVS/Repository
--- ug-orig/arch/SP2/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SP2/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SP2
diff -ruN ug-orig/arch/SP2/CVS/Root ug-patched/arch/SP2/CVS/Root
--- ug-orig/arch/SP2/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SP2/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SP2/CVS/Tag ug-patched/arch/SP2/CVS/Tag
--- ug-orig/arch/SP2/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SP2/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SR2201/CVS/Entries ug-patched/arch/SR2201/CVS/Entries
--- ug-orig/arch/SR2201/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SR2201/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Fri May 30 13:38:28 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SR2201/CVS/Repository ug-patched/arch/SR2201/CVS/Repository
--- ug-orig/arch/SR2201/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SR2201/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SR2201
diff -ruN ug-orig/arch/SR2201/CVS/Root ug-patched/arch/SR2201/CVS/Root
--- ug-orig/arch/SR2201/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SR2201/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SR2201/CVS/Tag ug-patched/arch/SR2201/CVS/Tag
--- ug-orig/arch/SR2201/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SR2201/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/SUN4GCC/CVS/Entries ug-patched/arch/SUN4GCC/CVS/Entries
--- ug-orig/arch/SUN4GCC/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SUN4GCC/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.5/Fri Jan 24 15:46:51 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/SUN4GCC/CVS/Repository ug-patched/arch/SUN4GCC/CVS/Repository
--- ug-orig/arch/SUN4GCC/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SUN4GCC/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/SUN4GCC
diff -ruN ug-orig/arch/SUN4GCC/CVS/Root ug-patched/arch/SUN4GCC/CVS/Root
--- ug-orig/arch/SUN4GCC/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SUN4GCC/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/SUN4GCC/CVS/Tag ug-patched/arch/SUN4GCC/CVS/Tag
--- ug-orig/arch/SUN4GCC/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/SUN4GCC/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/T3D/CVS/Entries ug-patched/arch/T3D/CVS/Entries
--- ug-orig/arch/T3D/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3D/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.11/Fri Sep 26 16:48:21 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/T3D/CVS/Repository ug-patched/arch/T3D/CVS/Repository
--- ug-orig/arch/T3D/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3D/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/T3D
diff -ruN ug-orig/arch/T3D/CVS/Root ug-patched/arch/T3D/CVS/Root
--- ug-orig/arch/T3D/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3D/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/T3D/CVS/Tag ug-patched/arch/T3D/CVS/Tag
--- ug-orig/arch/T3D/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3D/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/T3E/CVS/Entries ug-patched/arch/T3E/CVS/Entries
--- ug-orig/arch/T3E/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3E/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.8/Tue Jun  1 14:19:14 1999//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/T3E/CVS/Repository ug-patched/arch/T3E/CVS/Repository
--- ug-orig/arch/T3E/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3E/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/T3E
diff -ruN ug-orig/arch/T3E/CVS/Root ug-patched/arch/T3E/CVS/Root
--- ug-orig/arch/T3E/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3E/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/T3E/CVS/Tag ug-patched/arch/T3E/CVS/Tag
--- ug-orig/arch/T3E/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/T3E/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/YDL64/CVS/Entries ug-patched/arch/YDL64/CVS/Entries
--- ug-orig/arch/YDL64/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YDL64/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.2/Wed Feb 16 16:58:32 2005//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/YDL64/CVS/Repository ug-patched/arch/YDL64/CVS/Repository
--- ug-orig/arch/YDL64/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YDL64/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/YDL64
diff -ruN ug-orig/arch/YDL64/CVS/Root ug-patched/arch/YDL64/CVS/Root
--- ug-orig/arch/YDL64/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YDL64/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/YDL64/CVS/Tag ug-patched/arch/YDL64/CVS/Tag
--- ug-orig/arch/YDL64/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YDL64/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/arch/YMP/CVS/Entries ug-patched/arch/YMP/CVS/Entries
--- ug-orig/arch/YMP/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YMP/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/mk.arch/1.1/Wed Sep 10 16:01:23 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/arch/YMP/CVS/Repository ug-patched/arch/YMP/CVS/Repository
--- ug-orig/arch/YMP/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YMP/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/arch/YMP
diff -ruN ug-orig/arch/YMP/CVS/Root ug-patched/arch/YMP/CVS/Root
--- ug-orig/arch/YMP/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YMP/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/arch/YMP/CVS/Tag ug-patched/arch/YMP/CVS/Tag
--- ug-orig/arch/YMP/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/arch/YMP/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/autogen.sh ug-patched/autogen.sh
--- ug-orig/autogen.sh	2007-05-22 09:11:27.000000000 +0200
+++ ug-patched/autogen.sh	2007-02-14 19:46:04.000000000 +0100
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: autogen.sh,v 1.5 2007/05/22 07:11:27 sander Exp $
+# $Id: autogen.sh 8266 2007-02-14 18:46:04Z christi $
 
 # barf on errors
 set -e
@@ -112,4 +112,4 @@
 export CFLAGS="$COMPFLAGS"
 export CXXFLAGS="$COMPFLAGS"
 
-#eval ./configure $DEFAULTCONFOPT $CONFOPT
+# eval ./configure $DEFAULTCONFOPT $CONFOPT
diff -ruN ug-orig/bin/CVS/Entries ug-patched/bin/CVS/Entries
--- ug-orig/bin/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/bin/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,89 +0,0 @@
-/art2lgm/1.3/Wed Nov 15 10:40:02 2000//D2008.11.12.23.00.00
-/art2lgm2d/1.3/Tue Feb  6 13:50:53 2001//D2008.11.12.23.00.00
-/bin.doc/1.2/Thu Oct 19 07:14:51 1995//D2008.11.12.23.00.00
-/lgm2dto3d/1.4/Thu Dec 16 14:48:43 1999//D2008.11.12.23.00.00
-/lgm2gnu/1.7/Thu Nov  3 16:03:19 2005//D2008.11.12.23.00.00
-/lgm2ng2d/1.2/Wed Nov 24 13:27:04 2004//D2008.11.12.23.00.00
-/lgm_es/1.1/Wed Jul  2 15:28:29 2003//D2008.11.12.23.00.00
-/lgm_insertline/1.1/Wed Nov 24 13:34:13 2004//D2008.11.12.23.00.00
-/raw2ng/1.2/Thu Dec  5 16:58:31 2002//D2008.11.12.23.00.00
-/sci_spec/1.1/Thu Aug 30 13:46:47 2001//D2008.11.12.23.00.00
-/split_line/1.1/Wed Nov 24 13:34:13 2004//D2008.11.12.23.00.00
-/split_subdomain/1.1/Wed Nov 24 13:34:13 2004//D2008.11.12.23.00.00
-/ug4to6/1.1/Tue Jan 13 12:19:36 1998//D2008.11.12.23.00.00
-/ugMacClean/1.1.1.1/Fri Sep 15 16:54:18 1995//D2008.11.12.23.00.00
-/ugMacCleanAll/1.1.1.1/Fri Sep 15 16:54:17 1995//D2008.11.12.23.00.00
-/ug_dart.pl/1.8/Wed Dec  1 09:47:37 2004//D2008.11.12.23.00.00
-/ug_dart_client_test/1.7/Wed Dec  1 09:47:37 2004//D2008.11.12.23.00.00
-/ug_dart_conf.pl/1.5/Tue Jul 13 08:50:25 2004//D2008.11.12.23.00.00
-/ug_dart_copy_html/1.2/Thu Feb 10 10:40:53 2005//D2008.11.12.23.00.00
-/ug_dart_cron/1.2/Tue Mar 30 10:05:14 2004//D2008.11.12.23.00.00
-/ug_dart_manage_html.pl/1.1/Wed Jun  1 09:01:54 2005//D2008.11.12.23.00.00
-/ug_dart_server_start/1.3/Tue Feb 24 09:56:52 2004//D2008.11.12.23.00.00
-/ug_dart_server_stop/1.3/Tue Feb 24 09:56:52 2004//D2008.11.12.23.00.00
-/ug_dart_tests.pl/1.4/Wed Dec  1 09:47:37 2004//D2008.11.12.23.00.00
-/ug_dart_tree/1.2/Wed Jun  1 09:01:54 2005//D2008.11.12.23.00.00
-/ugarranlib/1.5/Mon Jun 28 11:47:57 2004//D2008.11.12.23.00.00
-/ugbcheck/1.6/Wed Jun 17 09:34:45 1998//D2008.11.12.23.00.00
-/ugbcheck.awk/1.4/Thu Jun 27 09:54:41 1996//D2008.11.12.23.00.00
-/ugbcheck_fix1.awk/1.1/Tue Jun 25 22:34:40 1996//D2008.11.12.23.00.00
-/ugbuild/1.1/Thu Jan 15 10:37:42 2004//D2008.11.12.23.00.00
-/ugcheckcoord/1.1/Fri Jan  3 12:46:44 1997//D2008.11.12.23.00.00
-/ugckid/1.3/Thu Dec  5 17:26:22 1996//D2008.11.12.23.00.00
-/ugckid.awk/1.1/Mon Dec  2 15:21:31 1996//D2008.11.12.23.00.00
-/ugclean/1.18/Mon Oct 13 13:02:16 1997//D2008.11.12.23.00.00
-/ugcmpid/1.1/Thu Dec  5 17:26:23 1996//D2008.11.12.23.00.00
-/ugcmpid.awk/1.1/Thu Dec  5 17:26:23 1996//D2008.11.12.23.00.00
-/ugconf/1.69/Wed Jul  9 15:39:32 2008//D2008.11.12.23.00.00
-/ugdemo/1.6/Mon Jun 16 10:32:48 1997//D2008.11.12.23.00.00
-/ugeps2mpg/1.1/Wed Oct 15 17:38:24 2003//D2008.11.12.23.00.00
-/ugetags/1.2/Thu May 20 12:28:06 1999//D2008.11.12.23.00.00
-/ugexo2lgm/1.9/Tue Mar  9 10:38:28 2004//D2008.11.12.23.00.00
-/ugexo2lgm_amd/1.1/Wed Oct 29 09:06:23 2003//D2008.11.12.23.00.00
-/ugexo2lgm_usn/1.1/Fri Mar  5 13:02:49 2004//D2008.11.12.23.00.00
-/ugexo2mbg_vol/1.1/Wed Apr  6 11:23:11 2005//D2008.11.12.23.00.00
-/ugexo2ng/1.7/Tue Mar 23 17:10:24 2004//D2008.11.12.23.00.00
-/ugexo2ng_bss/1.1/Fri Mar  5 13:02:49 2004//D2008.11.12.23.00.00
-/ugexoall/1.2/Fri Mar  5 13:04:23 2004//D2008.11.12.23.00.00
-/ugexoenroll/1.4/Mon Mar 29 15:06:50 2004//D2008.11.12.23.00.00
-/ugfilm/1.1/Wed Jun  4 16:13:19 1997//D2008.11.12.23.00.00
-/uggrep/1.9/Fri Feb 20 10:59:17 1998//D2008.11.12.23.00.00
-/uggrepc/1.9/Tue Aug 31 14:52:43 2004//D2008.11.12.23.00.00
-/uggreph/1.9/Fri Feb 20 10:59:18 1998//D2008.11.12.23.00.00
-/ugkillall/1.4/Thu Feb 20 15:22:02 1997//D2008.11.12.23.00.00
-/ugm2mpeg/1.7/Tue Apr 27 16:24:33 1999//D2008.11.12.23.00.00
-/ugmacosxpostlink/1.3/Mon May 27 12:55:41 2002//D2008.11.12.23.00.00
-/ugmake/1.26/Mon Aug 30 13:49:26 2004//D2008.11.12.23.00.00
-/ugmake.pl/1.4/Tue Nov 14 10:55:07 2000//D2008.11.12.23.00.00
-/ugmakealiases/1.4/Wed Jul  3 15:19:35 1996//D2008.11.12.23.00.00
-/ugmakealiases.pl/1.2/Mon Feb 19 16:16:16 2001//D2008.11.12.23.00.00
-/ugmakecat/1.1/Mon Oct 23 10:27:22 1995//D2008.11.12.23.00.00
-/ugmakecatman/1.1/Thu Oct 19 07:14:57 1995//D2008.11.12.23.00.00
-/ugmakelatex/1.8/Sun Apr  6 17:32:58 1997//D2008.11.12.23.00.00
-/ugmakelatexrefs/1.1.1.1/Fri Sep 15 16:54:18 1995//D2008.11.12.23.00.00
-/ugmakelinks/1.10/Thu Aug 13 12:37:27 1998//D2008.11.12.23.00.00
-/ugmakeman/1.14/Fri Dec  4 17:57:35 1998//D2008.11.12.23.00.00
-/ugmakeref/1.2/Tue Apr  9 18:10:54 1996//D2008.11.12.23.00.00
-/ugmaketrees/1.7/Fri Dec  4 17:57:36 1998//D2008.11.12.23.00.00
-/ugman/1.6/Fri Dec  4 17:57:37 1998//D2008.11.12.23.00.00
-/ugpmake/1.6/Fri Oct  8 13:30:29 1999//D2008.11.12.23.00.00
-/ugppm2avi/1.1/Fri Mar  7 18:22:25 2003//D2008.11.12.23.00.00
-/ugppm2mpg/1.5/Mon Aug  2 11:29:13 1999//D2008.11.12.23.00.00
-/ugprep4serv/1.5/Sun May 11 15:43:12 1997//D2008.11.12.23.00.00
-/ugproject/1.30/Thu Nov 13 21:52:20 1997//D2008.11.12.23.00.00
-/ugpvd/1.1/Thu Mar  6 15:33:46 2008//D2008.11.12.23.00.00
-/ugpvmcontext/1.2/Sat Sep 28 09:17:00 1996//D2008.11.12.23.00.00
-/ugrecurse/1.1.1.1/Fri Sep 15 16:54:18 1995//D2008.11.12.23.00.00
-/ugrm4serv/1.12/Wed Oct 14 16:28:39 1998//D2008.11.12.23.00.00
-/ugrmcoord/1.3/Thu Jan  2 11:15:55 1997//D2008.11.12.23.00.00
-/ugrun/1.24/Mon Aug  3 10:11:46 1998//D2008.11.12.23.00.00
-/ugsetcvsaccess/1.19/Fri Jun  4 11:40:09 1999//D2008.11.12.23.00.00
-/ugtdev/1.10/Tue Aug 13 16:24:30 2002//D2008.11.12.23.00.00
-/ugtest/1.12/Thu Oct 15 02:42:43 1998//D2008.11.12.23.00.00
-/ugtex/1.1.1.1/Fri Sep 15 16:54:17 1995//D2008.11.12.23.00.00
-/uguv/1.1/Mon Jun  8 17:35:30 1998//D2008.11.12.23.00.00
-/ugvisit/1.1/Thu Mar  6 15:35:00 2008//D2008.11.12.23.00.00
-/ugxpro/1.1/Thu Nov 14 11:25:27 1996//D2008.11.12.23.00.00
-/up/1.1/Thu Apr  5 09:48:57 2001//D2008.11.12.23.00.00
-/xugman/1.7/Sun May 11 18:59:41 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/bin/CVS/Repository ug-patched/bin/CVS/Repository
--- ug-orig/bin/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/bin/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/bin
diff -ruN ug-orig/bin/CVS/Root ug-patched/bin/CVS/Root
--- ug-orig/bin/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/bin/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/bin/CVS/Tag ug-patched/bin/CVS/Tag
--- ug-orig/bin/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/bin/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/bin/ugbcheck.awk ug-patched/bin/ugbcheck.awk
--- ug-orig/bin/ugbcheck.awk	1996-06-27 11:54:41.000000000 +0200
+++ ug-patched/bin/ugbcheck.awk	1996-06-27 11:54:41.000000000 +0200
@@ -8,16 +8,16 @@
 #   the output is piped into this awk-script in order to check for
 #   valid configurations.
 #
-#   the executable must contain the keywords $Header: /home/cvsroot/UG/ug/bin/ugbcheck.awk,v 1.4 1996/06/27 09:54:41 birken Exp $ and $State: Exp $
-#   for each object file. the $State: Exp $ line must give information with
+#   the executable must contain the keywords $Header$ and $State$
+#   for each object file. the $State$ line must give information with
 #   syntax PROPERTY=VALUE, where PROPERTY is the name of a compile time
 #   switch (or #define) and VALUE is its value at compile time.
 #   sample excerpt from 'ident libddd.a' output:
 #
-#   $Header: /home/cvsroot/UG/ug/bin/ugbcheck.awk,v 1.4 1996/06/27 09:54:41 birken Exp $
-#   $State: Exp $
-#   $Header: /home/cvsroot/UG/ug/bin/ugbcheck.awk,v 1.4 1996/06/27 09:54:41 birken Exp $
-#   $State: Exp $
+#   $Header$
+#   $State$
+#   $Header$
+#   $State$
 #   [...]
 #
 #   this awk-script builds up a database for this P-V-pairs, and 
diff -ruN ug-orig/bin/ugconf ug-patched/bin/ugconf
--- ug-orig/bin/ugconf	2008-07-09 17:39:32.000000000 +0200
+++ ug-patched/bin/ugconf	2006-05-03 14:18:34.000000000 +0200
@@ -18,7 +18,7 @@
 	echo "             AIX (set ARCH = AIX)";
 	echo "             AIXGCC (set ARCH = AIXGCC)";
 	echo "             AMD64 (set ARCH = AMD64)";
-	echo "             BGP (set ARCH = BGP)";
+	echo "             YDL64 (set ARCH = YDL64)";
 	echo "             C90 (set ARCH = C90)";
 	echo "             CC (set ARCH = CC)";
 	echo "             CYGWIN (set ARCH = CYGWIN)";
@@ -54,7 +54,6 @@
 	echo "             SUN4GCC (set ARCH = SUN4GCC)";
 	echo "             T3D (set ARCH = T3D)";
 	echo "             T3E (set ARCH = T3E)";
-	echo "             YDL64 (set ARCH = YDL64)";
 	echo "             YMP (set ARCH = YMP)";
 }
 
@@ -137,10 +136,6 @@
 	echo "             CAD (set CAD = ON)";
 	echo "             NOCAD (set CAD = OFF)";
 
-	echo "         interface to REB's mlilu solver";
-	echo "             MLILU (set MLILU = ON)";
-	echo "             NOMLILU (set MLILU = OFF)";
-
 	echo "         debug flag";
 	echo "             DEBUG (set DEBUG_MODE = ON)";
 	echo "             NODEBUG (set DEBUG_MODE = OFF)";
@@ -217,7 +212,7 @@
 
 grep_valid_entries()
 {
-	egrep '^[ ]*ARCH|^[ ]*MODEL |^[ ]*DIM|^[ ]*GRAPE |^[ ]*COVISE|^[ ]*PV3|^[ ]*NETGEN|^[ ]*REMOTE_IF|^[ ]*IF|^[ ]*DOM_MODULE|^[ ]*DEBUG_MODE|^[ ]*OPTIM_MODE|^[ ]*CHACO|^[ ]*CAD|^[ ]*GUI|^[ ]*MLILU' $1;
+	egrep '^[ ]*ARCH|^[ ]*MODEL |^[ ]*DIM|^[ ]*GRAPE |^[ ]*COVISE|^[ ]*PV3|^[ ]*NETGEN|^[ ]*REMOTE_IF|^[ ]*IF|^[ ]*DOM_MODULE|^[ ]*DEBUG_MODE|^[ ]*OPTIM_MODE|^[ ]*CHACO|^[ ]*CAD|^[ ]*GUI' $1;
 }
 
 
@@ -430,23 +425,23 @@
 		sed 's/^ARCH.*$/ARCH = PCGCOV/' $1 > $1.tmp
 		;;
 	PCCPP)
-		sed 's/^ARCH.*$/ARCH = PCCPP/' $1 > $1.tmp
-		;;
+                sed 's/^ARCH.*$/ARCH = PCCPP/' $1 > $1.tmp
+                ;;
 	PCI)
 		sed 's/^ARCH.*$/ARCH = PCI/' $1 > $1.tmp
 		;;
-	PCICPP)
-		sed 's/^ARCH.*$/ARCH = PCICPP/' $1 > $1.tmp
-		;;
+        PCICPP)
+                sed 's/^ARCH.*$/ARCH = PCICPP/' $1 > $1.tmp
+                ;;
 	PCCLUSTER)
 		sed 's/^ARCH.*$/ARCH = PCCLUSTER/' $1 > $1.tmp
 		mv $1.tmp $1
-		sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
+                sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
 		;;
 	PCICLUSTER)
 		sed 's/^ARCH.*$/ARCH = PCICLUSTER/' $1 > $1.tmp
 		mv $1.tmp $1
-		sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
+                sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
 		;;
 	MKLINUX)
 		sed 's/^ARCH.*$/ARCH = MKLINUX/' $1 > $1.tmp
@@ -454,11 +449,6 @@
 	LINUXPPC)
 		sed 's/^ARCH.*$/ARCH = LINUXPPC/' $1 > $1.tmp
 		;;
-	BGP)
-		sed 's/^ARCH.*$/ARCH = BGP/' $1 > $1.tmp
-		mv $1.tmp $1
-		sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
-		;;
 	LINUXAXP)
 		sed 's/^ARCH.*$/ARCH = LINUXAXP/' $1 > $1.tmp
 		;;
@@ -466,7 +456,7 @@
 		sed 's/^ARCH.*$/ARCH = LINUXIA64/' $1 > $1.tmp
 		;;
 	CYGWIN)
-		sed 's/^ARCH.*$/ARCH = CYGWIN/' $1 > $1.tmp
+	        sed 's/^ARCH.*$/ARCH = CYGWIN/' $1 > $1.tmp
 		;;
 	POWERGC)
 		sed 's/^ARCH.*$/ARCH = POWERGC/' $1 > $1.tmp
@@ -510,7 +500,7 @@
 	MACCLUSTER)
 		sed 's/^ARCH.*$/ARCH = MACCLUSTER/' $1 > $1.tmp
 		mv $1.tmp $1
-		sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
+                sed 's/^MODEL[ \t].*$/MODEL = MPI/' $1 >$1.tmp
 		;;
 	MACOSXSERVER)
 		sed 's/^ARCH.*$/ARCH = MACOSXSERVER/' $1 > $1.tmp
@@ -587,12 +577,6 @@
 		sed 's/^CAD.*$/CAD = OFF/' $1 > $1.tmp
 		;;
 
-	MLILU)
-		sed 's/^MLILU.*$/MLILU = ON/' $1 > $1.tmp
-		;;
-	NOMLILU)
-		sed 's/^MLILU.*$/MLILU = OFF/' $1 > $1.tmp
-		;;
 	*)
 		echo "error: unrecognized option '" $2 "'. use '$PROGNAME -help' for help.";
 		cp $1 $1.tmp
diff -ruN ug-orig/bin/ugexo2lgm ug-patched/bin/ugexo2lgm
--- ug-orig/bin/ugexo2lgm	2004-03-09 11:38:28.000000000 +0100
+++ ug-patched/bin/ugexo2lgm	2004-03-09 11:38:28.000000000 +0100
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexo2lgm,v 1.9 2004/03/09 10:38:28 stefan Exp $
+# $Header$
 # usage: ugexo2lgm <exo2filename> <lgmfilename>
 # 		<exo2filename> - exodus II file with surface triangulation and node 
 #					 assoziativity info
diff -ruN ug-orig/bin/ugexo2lgm_usn ug-patched/bin/ugexo2lgm_usn
--- ug-orig/bin/ugexo2lgm_usn	2004-03-05 14:02:49.000000000 +0100
+++ ug-patched/bin/ugexo2lgm_usn	2004-03-05 14:02:49.000000000 +0100
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexo2lgm_usn,v 1.1 2004/03/05 13:02:49 stefan Exp $
+# $Header$
 # usage: ugexo2lgm_usn <cubit_logfile> <cubit_sncmd_file>
 #
 # author: Stefan Lang, INF 368, IWR, University of Heidelberg
diff -ruN ug-orig/bin/ugexo2mbg_vol ug-patched/bin/ugexo2mbg_vol
--- ug-orig/bin/ugexo2mbg_vol	2005-04-06 13:23:11.000000000 +0200
+++ ug-patched/bin/ugexo2mbg_vol	2005-04-06 13:23:11.000000000 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexo2mbg_vol,v 1.1 2005/04/06 11:23:11 stefan Exp $
+# $Header$
 # usage: ugexo2mbg_vol <cubit_logfile> <cubit_volcmd_file>
 #
 # author: Stefan Lang, INF 368, IWR, University of Heidelberg
diff -ruN ug-orig/bin/ugexo2ng ug-patched/bin/ugexo2ng
--- ug-orig/bin/ugexo2ng	2004-03-23 18:10:24.000000000 +0100
+++ ug-patched/bin/ugexo2ng	2004-03-23 18:10:24.000000000 +0100
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexo2ng,v 1.7 2004/03/23 17:10:24 stefan Exp $
+# $Header$
 # usage: ugexo2ng <exo2filename> <lgmfilename> <ngfilename>
 # 		<exo2filename> - exodus II file with volume meshing and nodeset/sideset 
 #					 assoziativity info
diff -ruN ug-orig/bin/ugexo2ng_bss ug-patched/bin/ugexo2ng_bss
--- ug-orig/bin/ugexo2ng_bss	2004-03-05 14:02:49.000000000 +0100
+++ ug-patched/bin/ugexo2ng_bss	2004-03-05 14:02:49.000000000 +0100
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexo2ng_bss,v 1.1 2004/03/05 13:02:49 stefan Exp $
+# $Header$
 # usage: ugexo2ng_bss <cubit_logfile> <cubit_sscmd_file>
 #
 # author: Stefan Lang, INF 368, IWR, University of Heidelberg
diff -ruN ug-orig/bin/ugexoenroll ug-patched/bin/ugexoenroll
--- ug-orig/bin/ugexoenroll	2004-03-29 17:06:50.000000000 +0200
+++ ug-patched/bin/ugexoenroll	2004-03-29 17:06:50.000000000 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w #-d
-# $Header: /home/cvsroot/UG/ug/bin/ugexoenroll,v 1.4 2004/03/29 15:06:50 stefan Exp $
+# $Header$
 # usage: ugexoenroll <modelname> <lgmfilename>
 #       <modelname> - name of model to generate mesh for
 #
diff -ruN ug-orig/bin/ugmake ug-patched/bin/ugmake
--- ug-orig/bin/ugmake	2004-08-30 15:49:26.000000000 +0200
+++ ug-patched/bin/ugmake	2004-08-30 15:49:26.000000000 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: ugmake,v 1.26 2004/08/30 13:49:26 thimo Exp $
+# $Id: ugmake 7746 2004-08-30 13:49:26Z thimo $
 
 # TODO:
 #
diff -ruN ug-orig/bin/ugpvd ug-patched/bin/ugpvd
--- ug-orig/bin/ugpvd	2008-03-06 16:33:46.000000000 +0100
+++ ug-patched/bin/ugpvd	1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-#!/bin/tcsh -f
-
-if ( $# != 2) then
-    echo 'usage:   ugpvd <pattern for (p)vtu files> <pvd file to create>'
-    echo 'purpose: create ParaView pvd file that relates timesteps to data files'
-    echo 'example: ugpvd foo.\*.vtu foo.pvd'
-    exit
-endif
-
-echo '<?xml version="1.0"?>' > "$2"
-echo '<VTKFile type="Collection" version="0.1">' >> "$2"
-echo '  <Collection>' >> "$2"
-
-foreach f ( $1 )
-    set t = `grep -m1 -o timestep='".*"' "$f"`
-    echo '    <DataSet '"$t"' file="'"$f"'"/>' >> "$2"
-end
-
-echo '  </Collection>' >> "$2"
-echo '</VTKFile>' >> "$2"
diff -ruN ug-orig/bin/ugvisit ug-patched/bin/ugvisit
--- ug-orig/bin/ugvisit	2008-03-06 16:35:00.000000000 +0100
+++ ug-patched/bin/ugvisit	1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-#!/bin/tcsh -f
-
-if ( $# != 2) then
-    echo 'usage:   ugvisit <pattern for pvtu files> <visit file to create>'
-    echo 'purpose: create visit file that puts pieces together and also (if'
-    echo '         pattern expands to several files) defines a time series'
-    echo 'example: ugvisit foo.\*.pvtu foo.visit'
-    exit
-endif
-
-@ n = 0;
-
-foreach f ( $1 )
-    if ( $n == 0 ) then
-        @ n = `grep -c 'Piece Source' "$f"`
-        echo "\!NBLOCKS $n" > "$2"
-    endif
-    awk -F'"' '/Piece Source/ {print $2}' "$f" >> "$2"
-end
diff -ruN ug-orig/config.h ug-patched/config.h
--- ug-orig/config.h	2008-10-30 13:29:04.000000000 +0100
+++ ug-patched/config.h	2008-12-19 11:03:42.000000000 +0100
@@ -2,20 +2,18 @@
 
  This header is a dummy header so that both the classical UG build
  system and a automake/autoconf-approach can be used. arch/compiler.h
- switches it's functionality depending on symbols in config.h. As the
+ switches its functionality depending on symbols in config.h. As the
  compiler complains if no config.h is found we need this dummy.
 
- $Id: config.h,v 1.8 2008/10/30 12:29:04 dmitriy Exp $
+ $Id: config.h 8332 2008-12-19 10:03:42Z sander $
 */
 
-/* Define if you don't want namespaces even with C++ */
-#define NO_NAMESPACES
-
 /* Define this if you want to use the full refinement rule set for tetrahedra */
 #ifdef ModelP
 #define TET_RULESET 
 #endif
 
+
 /* define this to use DYNAMIC_MEMORY_ALLOCMODEL */
 /* matrices and vectors (for amg) are allocated */
 /* using Mark/Release                           */
@@ -24,7 +22,3 @@
 /* enables use of Athena Text Widget in libXaw, libXt */
 /* undefine USE_XAW, if you want pure X (only libX11) */
 #define USE_XAW
-
-/* The degenerated elements: */
-#undef WITH_DEGENERATED_ELEM /* define to allow the degenerated elements */
-#define DEGENERATED_SIZE 1e-4 /* relative size of the degenerated sides/edges */
diff -ruN ug-orig/configs/CVS/Entries ug-patched/configs/CVS/Entries
--- ug-orig/configs/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/configs/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,40 +0,0 @@
-/2FTFF.conf/1.5/Fri Mar 29 19:05:42 1996//D2008.11.12.23.00.00
-/2TFFF.conf/1.5/Fri Mar 29 19:05:43 1996//D2008.11.12.23.00.00
-/2TTFF.conf/1.4/Fri Mar 29 19:05:44 1996//D2008.11.12.23.00.00
-/3FFTF.conf/1.6/Fri Mar 29 19:05:44 1996//D2008.11.12.23.00.00
-/3TFFF.conf/1.10/Fri Mar 29 19:05:45 1996//D2008.11.12.23.00.00
-/mk.cad.OFF/1.1/Mon Feb 17 11:31:23 1997//D2008.11.12.23.00.00
-/mk.cad.ON/1.1/Mon Feb 17 11:31:24 1997//D2008.11.12.23.00.00
-/mk.chaco.OFF/1.3/Thu Nov 14 14:00:45 1996//D2008.11.12.23.00.00
-/mk.chaco.ON/1.2/Tue Sep 24 07:56:39 1996//D2008.11.12.23.00.00
-/mk.covise.OFF/1.1/Tue Dec 16 16:26:47 1997//D2008.11.12.23.00.00
-/mk.covise.ON/1.2/Tue Dec 23 14:37:10 1997//D2008.11.12.23.00.00
-/mk.debug.OFF/1.2/Fri Aug 23 17:16:50 1996//D2008.11.12.23.00.00
-/mk.debug.ON/1.1/Thu Jun 20 13:50:16 1996//D2008.11.12.23.00.00
-/mk.dom.GEN_DOMAIN/1.1/Tue Dec 14 13:41:24 1999//D2008.11.12.23.00.00
-/mk.dom.LGM_DOMAIN/1.1/Mon Oct 20 10:31:55 1997//D2008.11.12.23.00.00
-/mk.dom.STD_DOMAIN/1.1/Mon Oct 20 10:31:56 1997//D2008.11.12.23.00.00
-/mk.grape.OFF/1.2/Fri Sep 27 10:22:37 1996//D2008.11.12.23.00.00
-/mk.grape.ON/1.4/Fri Sep 27 10:22:37 1996//D2008.11.12.23.00.00
-/mk.gui.OFF/1.1/Thu Feb 19 16:39:03 1998//D2008.11.12.23.00.00
-/mk.gui.ON/1.2/Tue Mar 10 18:27:53 1998//D2008.11.12.23.00.00
-/mk.mlilu.OFF/1.1/Wed Jul  9 15:33:39 2008//D2008.11.12.23.00.00
-/mk.mlilu.ON/1.1/Wed Jul  9 15:33:39 2008//D2008.11.12.23.00.00
-/mk.model.MPI/1.2/Thu Sep 26 08:51:47 1996//D2008.11.12.23.00.00
-/mk.model.NX/1.2/Thu Sep 26 17:12:57 1996//D2008.11.12.23.00.00
-/mk.model.NXLIB/1.1/Thu Jun 20 12:31:10 1996//D2008.11.12.23.00.00
-/mk.model.PARIX/1.1/Thu Jun 20 12:31:11 1996//D2008.11.12.23.00.00
-/mk.model.PVM/1.2/Tue Nov 26 13:34:59 1996//D2008.11.12.23.00.00
-/mk.model.SEQ/1.2/Fri Aug 23 10:45:23 1996//D2008.11.12.23.00.00
-/mk.model.SHMEM/1.2/Mon Feb 10 14:32:36 1997//D2008.11.12.23.00.00
-/mk.model.SHMEMT3D/1.1/Thu Jun 20 12:31:12 1996//D2008.11.12.23.00.00
-/mk.netgen.OFF/1.4/Fri Sep 27 10:22:36 1996//D2008.11.12.23.00.00
-/mk.netgen.ON/1.5/Fri Sep 27 10:22:35 1996//D2008.11.12.23.00.00
-/mk.optim.OFF/1.1/Thu Dec  3 14:11:53 1998//D2008.11.12.23.00.00
-/mk.optim.ON/1.1/Thu Dec  3 14:11:53 1998//D2008.11.12.23.00.00
-/mk.pv3.OFF/1.1/Thu Feb  6 14:12:20 2003//D2008.11.12.23.00.00
-/mk.pv3.ON/1.1/Thu Feb  6 14:12:20 2003//D2008.11.12.23.00.00
-/mk.rif.OFF/1.2/Thu Sep 26 08:51:47 1996//D2008.11.12.23.00.00
-/mk.rif.ON/1.2/Thu Sep 26 08:51:48 1996//D2008.11.12.23.00.00
-/mk.ugsettings/1.32/Wed Jul  9 15:39:32 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/configs/CVS/Repository ug-patched/configs/CVS/Repository
--- ug-orig/configs/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/configs/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/configs
diff -ruN ug-orig/configs/CVS/Root ug-patched/configs/CVS/Root
--- ug-orig/configs/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/configs/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/configs/CVS/Tag ug-patched/configs/CVS/Tag
--- ug-orig/configs/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/configs/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/configs/mk.mlilu.OFF ug-patched/configs/mk.mlilu.OFF
--- ug-orig/configs/mk.mlilu.OFF	2008-07-09 17:33:39.000000000 +0200
+++ ug-patched/configs/mk.mlilu.OFF	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-# this file is for internal ug configuration. don't change it!
-
-MLILU_TARGET = MLILU_OFF
diff -ruN ug-orig/configs/mk.mlilu.ON ug-patched/configs/mk.mlilu.ON
--- ug-orig/configs/mk.mlilu.ON	2008-07-09 17:33:39.000000000 +0200
+++ ug-patched/configs/mk.mlilu.ON	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-# this file is for internal ug configuration. don't change it!
-
-MLILU_TARGET = MLILU_ON
-MLILU_CFLAGS = -D_MLILU
-
-# if mlilu is requested, we need C++ _and_ Fortran linkage. Blah!!
-MLILU_LFLAGS = -lstdc++
-UG_LINK = $(ARCH_F77)
diff -ruN ug-orig/configs/mk.ugsettings ug-patched/configs/mk.ugsettings
--- ug-orig/configs/mk.ugsettings	2008-07-09 17:39:32.000000000 +0200
+++ ug-patched/configs/mk.ugsettings	2004-09-10 11:39:28.000000000 +0200
@@ -62,9 +62,6 @@
 # include macro definitions for gui
 include $(UGROOT)/configs/mk.gui.$(GUI)
 
-#include macro definitions for mlilu
-include $(UGROOT)/configs/mk.mlilu.$(MLILU)
-
 # -- list of automatically provided includes
 
 # this is the compatible setting: use the include-directory with all
@@ -84,7 +81,7 @@
 			$(RIF_CFLAGS) $(CHACO_CFLAGS) \
 			$(NETGEN_CFLAGS) $(COVISE_CFLAGS) $(GRAPE_CFLAGS) \
 			$(PV3_CFLAGS) $(CAD_CFLAGS) $(GUI_CFLAGS) \
-			$(MLILU_CFLAGS) $(UG_INCLUDES)
+			$(UG_INCLUDES)
 
 UG_COFLAGS = -c -D_$(DIM) -D$(ARCH_TYPE) $(UGDEBUG_CFLAGS) \
 			$(ARCH_CFLAGS) $(ARCH_OPTIM) $(PPIF_CFLAGS) $(MODEL_CFLAGS) \
@@ -92,9 +89,9 @@
 			$(RIF_CFLAGS) $(CHACO_CFLAGS) \
 			$(NETGEN_CFLAGS) $(COVISE_CFLAGS) $(GRAPE_CFLAGS) \
 			$(PV3_CFLAGS) $(CAD_CFLAGS) $(GUI_CFLAGS) \
-			$(MLILU_CFLAGS) $(UG_INCLUDES)
+			$(UG_INCLUDES)
 
-UG_C++FLAGS = -c -D_$(DIM) -D$(ARCH_TYPE) $(UGDEBUG_CFLAGS) $(UG_OFLAGS) \
+UG_C++FLAGS = -c -D_$(DIM) -D$(ARCH_TYPE) $(UGDEBUG_CFLAGS) $(UG_OFLAGS)\
 			$(ARCH_C++FLAGS) $(MODEL_CFLAGS) $(UG_INCLUDES)
 
 UG_FFLAGS = -c $(ARCH_FFLAGS)
@@ -102,7 +99,7 @@
 UG_LFLAGS = $(ARCH_LFLAGS) $(PPIF_LFLAGS) $(MODEL_LFLAGS) $(GRAPE_LFLAGS) \
 			$(GUI_LFLAGS) $(ARCH_XLIBS) $(ARCH_LIBS) $(ENV_LFLAGS) $(ARCH_PLIBS) \
 			$(NETGEN_LFLAGS) $(COVISE_LFLAGS) $(PV3_LFLAGS) $(CHACO_LFLAGS) \
-			$(CAD_LFLAGS) $(MLILU_LFLAGS)
+			$(CAD_LFLAGS)
 
 UG_LIB    = $(UGROOT)/lib/libug$(UG_LIBSUFFIX).a 
 
diff -ruN ug-orig/configure.ac ug-patched/configure.ac
--- ug-orig/configure.ac	2006-11-15 15:06:01.000000000 +0100
+++ ug-patched/configure.ac	2012-01-26 16:48:44.000000000 +0100
@@ -2,8 +2,10 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT(UG, 3.9.1, UG-REPORT-ADDRESS)
-AM_INIT_AUTOMAKE(UG, 3.9.1, UG-REPORT-ADDRESS)
+
+AC_INIT(ug, 3.9.1-patch7, UG-REPORT-ADDRESS)
+AM_INIT_AUTOMAKE
+
 AC_CONFIG_SRCDIR([initug.c])
 AM_CONFIG_HEADER([config.h])
 
@@ -13,6 +15,8 @@
 AC_PROG_CXX
 AC_PROG_MAKE_SET
 AC_PROG_LN_S
+#for per-target flags
+AM_PROG_CC_C_O
 # for dom/lgm/ngin
 AM_PROG_LEX
 AC_PROG_YACC
@@ -119,6 +123,7 @@
   # set define
   UG_EXTRAFLAGS="-DModelP"
 fi
+AC_SUBST(parallel)
 
 #
 ## Support for DUNE.  Building with --enable-dune sets the compiler flag -DFOR_DUNE
@@ -132,6 +137,7 @@
   # set define
   UG_EXTRAFLAGS="$UG_EXTRAFLAGS -DFOR_DUNE"
 fi
+AC_SUBST(fordune, "$dune")
 
 # debugging
 
@@ -142,17 +148,14 @@
   UG_EXTRAFLAGS="$UG_EXTRAFLAGS -DDebug"
 fi
 
-# the DUNE-test for MPI-package and parameters
+# check for some DDD parameters
+DDD_PARAMETERS
 
-# use C++-test and hope that the flags will work in the C-case as well
-# Unfortunately the AC_LANG-mechanism is evaluated by m4 and not
-# during runtime of ./configure
-AC_LANG_PUSH([C++])
-DUNE_MPI
-if test x$parallel = xyes -a x$with_mpi = xno ; then
+# the DUNE-test for MPI-package and parameters
+UG_MPI
+if test "x$parallel" = "xyes" -a "x$with_mpi" = "xno"; then
    AC_MSG_ERROR([MPI needed for the parallel UG-lib!])
 fi
-AC_LANG_POP([C++])
 
 # set results as automake-conditionals
 AM_CONDITIONAL(PARALLEL, test x$parallel = xyes)
@@ -230,9 +233,6 @@
 		 np/amglib/Makefile
 		 np/field/Makefile
 		 np/procs/Makefile
-		 np/slu/Makefile
-		 np/slu/cblas/Makefile
-		 np/slu/src/Makefile
 		 np/udm/Makefile
 		 tools/Makefile
                  ui/Makefile
@@ -255,6 +255,9 @@
 dnl                  gm/gg3/netgen/linalg/makefile
 dnl                  gm/gg3/netgen/meshing/makefile
 dnl                  gm/gg3/netgen/opti/makefile
+# The chaco stuff is not built because it is not available
+# in the anonymous Heidelberg CVS and not in the set of patches
+# we provide either.  AFAIK it doesn't work anyways.
 dnl                  parallel/chaco/Makefile
 dnl                  parallel/chaco/assign/Makefile
 dnl                  parallel/chaco/bpmatch/Makefile
diff -ruN ug-orig/CVS/Entries ug-patched/CVS/Entries
--- ug-orig/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-/.cvsignore/1.2/Thu Sep  9 14:43:05 2004//D2008.11.12.23.00.00
-/Makefile/1.43/Tue Jul 13 09:00:16 2004//D2008.11.12.23.00.00
-/Makefile.am/1.6/Tue Jan 18 18:20:47 2005//D2008.11.12.23.00.00
-/README.autotools/1.1/Thu Sep  2 12:22:03 2004//D2008.11.12.23.00.00
-/TestCases/1.1/Tue Jun  8 08:52:00 2004//D2008.11.12.23.00.00
-/TestCases.all/1.1/Tue Jun  8 08:52:00 2004//D2008.11.12.23.00.00
-/autogen.sh/1.5/Tue May 22 07:11:27 2007//D2008.11.12.23.00.00
-/config.h/1.8/Thu Oct 30 12:29:04 2008//D2008.11.12.23.00.00
-/configure.ac/1.21/Wed Nov 15 14:06:01 2006//D2008.11.12.23.00.00
-/gcc.opts/1.1/Thu Sep  2 12:22:03 2004//D2008.11.12.23.00.00
-/icc.opts/1.1/Thu Sep  2 12:22:03 2004//D2008.11.12.23.00.00
-/initug.c/1.41/Mon Jul 18 13:44:18 2005//D2008.11.12.23.00.00
-/initug.h/1.12/Fri Jun  2 16:12:03 2006//D2008.11.12.23.00.00
-/libug.pc.in/1.2/Fri Sep  3 16:28:45 2004//D2008.11.12.23.00.00
-/mainpage.doc/1.2/Mon Mar  8 08:38:04 2004//D2008.11.12.23.00.00
-/ug.conf/1.39/Tue Aug 19 13:17:28 2008//D2008.11.12.23.00.00
-/ug.doc/1.3/Fri Oct 27 20:21:23 1995//D2008.11.12.23.00.00
-/ug.make/1.3/Wed Nov 15 18:45:46 1995//D2008.11.12.23.00.00
-/ugd.c/1.12/Thu Jul 15 13:00:12 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/CVS/Entries.Log ug-patched/CVS/Entries.Log
--- ug-orig/CVS/Entries.Log	2009-04-28 16:21:30.000000000 +0200
+++ ug-patched/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,16 +0,0 @@
-A D/arch////
-A D/bin////
-A D/configs////
-A D/dev////
-A D/doc////
-A D/dom////
-A D/gm////
-A D/graphics////
-A D/lib////
-A D/low////
-A D/m4////
-A D/np////
-A D/parallel////
-A D/pm////
-A D/tools////
-A D/ui////
diff -ruN ug-orig/CVS/Repository ug-patched/CVS/Repository
--- ug-orig/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug
diff -ruN ug-orig/CVS/Root ug-patched/CVS/Root
--- ug-orig/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/CVS/Tag ug-patched/CVS/Tag
--- ug-orig/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/.cvsignore ug-patched/.cvsignore
--- ug-orig/.cvsignore	2004-09-09 16:43:05.000000000 +0200
+++ ug-patched/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-Automake.global
-Makefile
-Makefile.in
-.deps
-config.*
-configure
-aclocal.m4
-autom4te.cache
-depcomp
-install-sh
-missing
-mkinstalldirs
-libtool
-stamp-h*
-libug.pc
-semantic.cache
-
diff -ruN ug-orig/dev/CVS/Entries ug-patched/dev/CVS/Entries
--- ug-orig/dev/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:12 2004//D2008.11.12.23.00.00
-/Makefile.am/1.2/Wed Sep  8 11:29:50 2004//D2008.11.12.23.00.00
-/Makefile.dev/1.22/Thu Oct  9 11:04:36 2003//D2008.11.12.23.00.00
-/dev.make/1.4/Fri Aug  7 14:41:56 1998//D2008.11.12.23.00.00
-/initdev.h/1.12/Wed Jul 21 09:20:02 2004//D2008.11.12.23.00.00
-/sockcomm.c/1.8/Wed Sep 10 10:32:42 1997//D2008.11.12.23.00.00
-/sockcomm.h/1.8/Wed Oct  8 17:45:43 1997//D2008.11.12.23.00.00
-/ugdevices.c/1.12/Mon Jul 18 13:42:28 2005//D2008.11.12.23.00.00
-/ugdevices.doc/1.1/Fri Aug  7 14:42:03 1998//D2008.11.12.23.00.00
-/ugdevices.h/1.9/Fri Jul 18 14:05:09 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/CVS/Entries.Log ug-patched/dev/CVS/Entries.Log
--- ug-orig/dev/CVS/Entries.Log	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-A D/meta////
-A D/mif////
-A D/nif////
-A D/ppm////
-A D/ps////
-A D/rif////
-A D/sif////
-A D/xif////
diff -ruN ug-orig/dev/CVS/Repository ug-patched/dev/CVS/Repository
--- ug-orig/dev/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev
diff -ruN ug-orig/dev/CVS/Root ug-patched/dev/CVS/Root
--- ug-orig/dev/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/CVS/Tag ug-patched/dev/CVS/Tag
--- ug-orig/dev/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/.cvsignore ug-patched/dev/.cvsignore
--- ug-orig/dev/.cvsignore	2004-09-08 16:14:12.000000000 +0200
+++ ug-patched/dev/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/initdev.h ug-patched/dev/initdev.h
--- ug-orig/dev/initdev.h	2004-07-21 11:20:02.000000000 +0200
+++ ug-patched/dev/initdev.h	2009-04-29 14:30:36.000000000 +0200
@@ -22,7 +22,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/initdev.h,v 1.12 2004/07/21 09:20:02 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -67,7 +67,7 @@
 /* ppm device */
 INT InitPPMDevice(void);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
 
diff -ruN ug-orig/dev/Makefile.am ug-patched/dev/Makefile.am
--- ug-orig/dev/Makefile.am	2004-09-08 13:29:50.000000000 +0200
+++ ug-patched/dev/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/09/08 11:29:50 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 # !!! test and include them:
 #
@@ -20,7 +20,8 @@
 
 SOURCES = ugdevices.c sockcomm.c initdev.h sockcomm.h ugdevices.h
 
-include_HEADERS = ugdevices.h
+devincludedir = $(pkgincludedir)
+devinclude_HEADERS = ugdevices.h
 
 libdevices_la_SOURCES = $(SOURCES)
 libdevices_la_LIBADD = ppm/libdevice_ppm.la \
diff -ruN ug-orig/dev/meta/CVS/Entries ug-patched/dev/meta/CVS/Entries
--- ug-orig/dev/meta/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/meta/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:09 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:03 2004//D2008.11.12.23.00.00
-/Makefile.meta/1.4/Mon Jun 16 10:44:45 1997//D2008.11.12.23.00.00
-/meta.make/1.2/Wed Nov 15 18:46:13 1995//D2008.11.12.23.00.00
-/metafile.c/1.23/Fri Jun  2 16:25:20 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/meta/CVS/Repository ug-patched/dev/meta/CVS/Repository
--- ug-orig/dev/meta/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/meta/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/meta
diff -ruN ug-orig/dev/meta/CVS/Root ug-patched/dev/meta/CVS/Root
--- ug-orig/dev/meta/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/meta/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/meta/CVS/Tag ug-patched/dev/meta/CVS/Tag
--- ug-orig/dev/meta/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/meta/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/meta/.cvsignore ug-patched/dev/meta/.cvsignore
--- ug-orig/dev/meta/.cvsignore	2004-09-08 16:14:09.000000000 +0200
+++ ug-patched/dev/meta/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/meta/Makefile.am ug-patched/dev/meta/Makefile.am
--- ug-orig/dev/meta/Makefile.am	2004-09-02 14:22:03.000000000 +0200
+++ ug-patched/dev/meta/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:03 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS)
 
diff -ruN ug-orig/dev/meta/metafile.c ug-patched/dev/meta/metafile.c
--- ug-orig/dev/meta/metafile.c	2006-06-02 18:25:20.000000000 +0200
+++ ug-patched/dev/meta/metafile.c	2006-06-02 18:25:44.000000000 +0200
@@ -129,7 +129,7 @@
 static long saveColor;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/meta/metafile.c,v 1.23 2006/06/02 16:25:20 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/CVS/Entries ug-patched/dev/mif/CVS/Entries
--- ug-orig/dev/mif/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,39 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:09 2004//D2008.11.12.23.00.00
-/MAppController.h/1.2/Fri Jun 18 10:50:06 1999//D2008.11.12.23.00.00
-/MAppController.m/1.4/Wed Sep  8 15:23:55 1999//D2008.11.12.23.00.00
-/MGraphicView.h/1.4/Wed May 15 15:18:57 2002//D2008.11.12.23.00.00
-/MGraphicView.m/1.4/Wed May 15 15:18:57 2002//D2008.11.12.23.00.00
-/MGraphicWindow.h/1.6/Tue May  4 13:26:16 2004//D2008.11.12.23.00.00
-/MGraphicWindow.m/1.4/Wed May 15 15:18:57 2002//D2008.11.12.23.00.00
-/MInterface.h/1.2/Wed May 15 15:18:57 2002//D2008.11.12.23.00.00
-/MInterface.m/1.6/Tue May  4 13:05:18 2004//D2008.11.12.23.00.00
-/MShell.h/1.4/Wed Sep  8 15:23:59 1999//D2008.11.12.23.00.00
-/MShell.m/1.4/Wed Sep  8 15:23:59 1999//D2008.11.12.23.00.00
-/MShellTextView.h/1.3/Fri Jun 18 10:50:11 1999//D2008.11.12.23.00.00
-/MShellTextView.m/1.4/Wed Sep  8 15:24:00 1999//D2008.11.12.23.00.00
-/MShellView.h/1.2/Thu Jun 10 18:47:15 1999//D2008.11.12.23.00.00
-/MShellView.m/1.4/Wed Sep  8 15:24:00 1999//D2008.11.12.23.00.00
-/MShellWindow.h/1.2/Thu Jun 10 18:47:16 1999//D2008.11.12.23.00.00
-/MShellWindow.m/1.3/Fri Jun 18 10:50:12 1999//D2008.11.12.23.00.00
-/MacGraph.c/1.22/Fri Jun  2 16:25:44 2006//D2008.11.12.23.00.00
-/MacGraph.h/1.8/Tue Feb 12 16:48:50 2002//D2008.11.12.23.00.00
-/MacMain.c/1.17/Fri Jun  2 16:25:44 2006//D2008.11.12.23.00.00
-/MacMain.h/1.3/Fri Jul 18 14:58:44 1997//D2008.11.12.23.00.00
-/MacMain.m/1.3/Wed Sep  2 12:29:56 1998//D2008.11.12.23.00.00
-/MacShell.c/1.17/Fri Jun  2 16:25:44 2006//D2008.11.12.23.00.00
-/MacShell.h/1.5/Tue Feb 12 16:48:50 2002//D2008.11.12.23.00.00
-/MacSurface.c/1.12/Fri Jun  2 16:25:44 2006//D2008.11.12.23.00.00
-/MacSurface.h/1.4/Tue Feb 12 16:48:50 2002//D2008.11.12.23.00.00
-/Makefile/1.2/Wed Sep  8 15:24:01 1999//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:04 2004//D2008.11.12.23.00.00
-/Makefile.mif/1.5/Wed May 15 15:28:37 2002//D2008.11.12.23.00.00
-/Makefile.postamble/1.1/Wed Jun  9 15:33:58 1999//D2008.11.12.23.00.00
-/Makefile.preamble/1.1/Wed Jun  9 15:33:59 1999//D2008.11.12.23.00.00
-/PB.project/1.2/Wed Sep  8 15:24:02 1999//D2008.11.12.23.00.00
-/README.MacInterface/1.1/Wed Jun  9 15:34:00 1999//D2008.11.12.23.00.00
-/h.template/1.1/Wed Jun  9 15:34:00 1999//D2008.11.12.23.00.00
-/m.template/1.1/Wed Jun  9 15:34:00 1999//D2008.11.12.23.00.00
-/mif.make/1.2/Wed Nov 15 18:46:28 1995//D2008.11.12.23.00.00
-/ugrsrc.r/1.3/Wed Sep  2 12:30:05 1998//D2008.11.12.23.00.00
-/ugrsrc.resedit.sit.hqx/1.1/Thu Aug 24 12:01:20 2000//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/CVS/Entries.Log ug-patched/dev/mif/CVS/Entries.Log
--- ug-orig/dev/mif/CVS/Entries.Log	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-A D/English.lproj////
-A D/Icons16x16////
-A D/Icons20x20////
-A D/Icons24x24////
-A D/PBUserInfo////
-A D/mif.pbproj////
diff -ruN ug-orig/dev/mif/CVS/Repository ug-patched/dev/mif/CVS/Repository
--- ug-orig/dev/mif/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif
diff -ruN ug-orig/dev/mif/CVS/Root ug-patched/dev/mif/CVS/Root
--- ug-orig/dev/mif/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/CVS/Tag ug-patched/dev/mif/CVS/Tag
--- ug-orig/dev/mif/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/mif/.cvsignore ug-patched/dev/mif/.cvsignore
--- ug-orig/dev/mif/.cvsignore	2004-09-08 16:14:09.000000000 +0200
+++ ug-patched/dev/mif/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/mif/English.lproj/CVS/Entries ug-patched/dev/mif/English.lproj/CVS/Entries
--- ug-orig/dev/mif/English.lproj/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D
diff -ruN ug-orig/dev/mif/English.lproj/CVS/Entries.Log ug-patched/dev/mif/English.lproj/CVS/Entries.Log
--- ug-orig/dev/mif/English.lproj/CVS/Entries.Log	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/UG_MacOSXServer.nib////
diff -ruN ug-orig/dev/mif/English.lproj/CVS/Repository ug-patched/dev/mif/English.lproj/CVS/Repository
--- ug-orig/dev/mif/English.lproj/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/English.lproj
diff -ruN ug-orig/dev/mif/English.lproj/CVS/Root ug-patched/dev/mif/English.lproj/CVS/Root
--- ug-orig/dev/mif/English.lproj/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/English.lproj/CVS/Tag ug-patched/dev/mif/English.lproj/CVS/Tag
--- ug-orig/dev/mif/English.lproj/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Entries ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Entries
--- ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/Arrow.tiff/1.1/Wed Nov 22 18:45:12 2000/-kb/D2008.11.12.23.00.00
-/Magnify.tiff/1.1/Wed Nov 22 18:45:12 2000/-kb/D2008.11.12.23.00.00
-/NSAppleMenuImage.tiff/1.1/Wed Jun  9 15:34:01 1999/-kb/D2008.11.12.23.00.00
-/classes.nib/1.3/Fri Jun 18 10:50:13 1999//D2008.11.12.23.00.00
-/objects.nib/1.4/Wed Sep  8 15:24:03 1999/-kb/D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Repository ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Repository
--- ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/English.lproj/UG_MacOSXServer.nib
diff -ruN ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Root ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Root
--- ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Tag ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Tag
--- ug-orig/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/English.lproj/UG_MacOSXServer.nib/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
BinÃ¤rdateien ug-orig/dev/mif/Icons16x16/Arrow.tiff and ug-patched/dev/mif/Icons16x16/Arrow.tiff sind verschieden.
diff -ruN ug-orig/dev/mif/Icons16x16/CVS/Entries ug-patched/dev/mif/Icons16x16/CVS/Entries
--- ug-orig/dev/mif/Icons16x16/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons16x16/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-/1-Arrow.tiff/1.1/Wed Jun  9 15:34:03 1999/-kb/D2008.11.12.23.00.00
-/2-Cross.tiff/1.1/Wed Jun  9 15:34:03 1999/-kb/D2008.11.12.23.00.00
-/3-Plus.tiff/1.1/Wed Jun  9 15:34:04 1999/-kb/D2008.11.12.23.00.00
-/4-Circle.tiff/1.1/Wed Jun  9 15:34:04 1999/-kb/D2008.11.12.23.00.00
-/5-Hand.tiff/1.1/Wed Jun  9 15:34:04 1999/-kb/D2008.11.12.23.00.00
-/6-Heart.tiff/1.1/Wed Jun  9 15:34:05 1999/-kb/D2008.11.12.23.00.00
-/7-Spiral.tiff/1.1/Wed Jun  9 15:34:05 1999/-kb/D2008.11.12.23.00.00
-/Arrow.tiff/1.1/Wed Nov 22 18:41:39 2000//D2008.11.12.23.00.00
-/Magnify.tiff/1.1/Wed Nov 22 18:41:39 2000//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/Icons16x16/CVS/Repository ug-patched/dev/mif/Icons16x16/CVS/Repository
--- ug-orig/dev/mif/Icons16x16/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons16x16/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/Icons16x16
diff -ruN ug-orig/dev/mif/Icons16x16/CVS/Root ug-patched/dev/mif/Icons16x16/CVS/Root
--- ug-orig/dev/mif/Icons16x16/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons16x16/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/Icons16x16/CVS/Tag ug-patched/dev/mif/Icons16x16/CVS/Tag
--- ug-orig/dev/mif/Icons16x16/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons16x16/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
BinÃ¤rdateien ug-orig/dev/mif/Icons16x16/Magnify.tiff and ug-patched/dev/mif/Icons16x16/Magnify.tiff sind verschieden.
diff -ruN ug-orig/dev/mif/Icons20x20/CVS/Entries ug-patched/dev/mif/Icons20x20/CVS/Entries
--- ug-orig/dev/mif/Icons20x20/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons20x20/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-/1-Arrow.tiff/1.1/Wed Jun  9 15:34:06 1999/-kb/D2008.11.12.23.00.00
-/2-Cross.tiff/1.1/Wed Jun  9 15:34:06 1999/-kb/D2008.11.12.23.00.00
-/3-Plus.tiff/1.1/Wed Jun  9 15:34:07 1999/-kb/D2008.11.12.23.00.00
-/4-Circle.tiff/1.1/Wed Jun  9 15:34:07 1999/-kb/D2008.11.12.23.00.00
-/5-Hand.tiff/1.1/Wed Jun  9 15:34:08 1999/-kb/D2008.11.12.23.00.00
-/6-Heart.tiff/1.1/Wed Jun  9 15:34:08 1999/-kb/D2008.11.12.23.00.00
-/7-Spiral.tiff/1.1/Wed Jun  9 15:34:08 1999/-kb/D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/Icons20x20/CVS/Repository ug-patched/dev/mif/Icons20x20/CVS/Repository
--- ug-orig/dev/mif/Icons20x20/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons20x20/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/Icons20x20
diff -ruN ug-orig/dev/mif/Icons20x20/CVS/Root ug-patched/dev/mif/Icons20x20/CVS/Root
--- ug-orig/dev/mif/Icons20x20/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons20x20/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/Icons20x20/CVS/Tag ug-patched/dev/mif/Icons20x20/CVS/Tag
--- ug-orig/dev/mif/Icons20x20/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons20x20/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/mif/Icons24x24/CVS/Entries ug-patched/dev/mif/Icons24x24/CVS/Entries
--- ug-orig/dev/mif/Icons24x24/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons24x24/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,15 +0,0 @@
-/1-arrow.tiff/1.1/Wed Jun  9 15:34:09 1999/-kb/D2008.11.12.23.00.00
-/1-arrowi.tiff/1.1/Wed Jun  9 15:34:10 1999/-kb/D2008.11.12.23.00.00
-/2-cross.tiff/1.1/Wed Jun  9 15:34:10 1999/-kb/D2008.11.12.23.00.00
-/2-crossi.tiff/1.1/Wed Jun  9 15:34:10 1999/-kb/D2008.11.12.23.00.00
-/3-plus.tiff/1.1/Wed Jun  9 15:34:11 1999/-kb/D2008.11.12.23.00.00
-/3-plusi.tiff/1.1/Wed Jun  9 15:34:11 1999/-kb/D2008.11.12.23.00.00
-/4-circle.tiff/1.1/Wed Jun  9 15:34:12 1999/-kb/D2008.11.12.23.00.00
-/4-circlei.tiff/1.1/Wed Jun  9 15:34:12 1999/-kb/D2008.11.12.23.00.00
-/5-hand.tiff/1.1/Wed Jun  9 15:34:12 1999/-kb/D2008.11.12.23.00.00
-/5-handi.tiff/1.1/Wed Jun  9 15:34:13 1999/-kb/D2008.11.12.23.00.00
-/6-heart.tiff/1.1/Wed Jun  9 15:34:13 1999/-kb/D2008.11.12.23.00.00
-/6-hearti.tiff/1.1/Wed Jun  9 15:34:14 1999/-kb/D2008.11.12.23.00.00
-/7-spiral.tiff/1.1/Wed Jun  9 15:34:14 1999/-kb/D2008.11.12.23.00.00
-/7-spirali.tiff/1.1/Wed Jun  9 15:34:14 1999/-kb/D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/Icons24x24/CVS/Repository ug-patched/dev/mif/Icons24x24/CVS/Repository
--- ug-orig/dev/mif/Icons24x24/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons24x24/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/Icons24x24
diff -ruN ug-orig/dev/mif/Icons24x24/CVS/Root ug-patched/dev/mif/Icons24x24/CVS/Root
--- ug-orig/dev/mif/Icons24x24/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons24x24/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/Icons24x24/CVS/Tag ug-patched/dev/mif/Icons24x24/CVS/Tag
--- ug-orig/dev/mif/Icons24x24/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/Icons24x24/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/mif/MacGraph.c ug-patched/dev/mif/MacGraph.c
--- ug-orig/dev/mif/MacGraph.c	2006-06-02 18:25:44.000000000 +0200
+++ ug-patched/dev/mif/MacGraph.c	2006-06-02 18:25:44.000000000 +0200
@@ -109,7 +109,7 @@
 static char buffer[255];
 	
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/mif/MacGraph.c,v 1.22 2006/06/02 16:25:44 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/MacGraph.h ug-patched/dev/mif/MacGraph.h
--- ug-orig/dev/mif/MacGraph.h	2002-02-12 17:48:50.000000000 +0100
+++ ug-patched/dev/mif/MacGraph.h	2002-02-12 17:48:50.000000000 +0100
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/mif/MacGraph.h,v 1.8 2002/02/12 16:48:50 reichenb Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/mif/MacMain.c ug-patched/dev/mif/MacMain.c
--- ug-orig/dev/mif/MacMain.c	2006-06-02 18:25:44.000000000 +0200
+++ ug-patched/dev/mif/MacMain.c	2006-06-02 18:25:44.000000000 +0200
@@ -109,7 +109,7 @@
 static OUTPUTDEVICE *MacOutputDevice;	/* ptr to MacOutputDevice			*/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/mif/MacMain.c,v 1.17 2006/06/02 16:25:44 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/MacMain.h ug-patched/dev/mif/MacMain.h
--- ug-orig/dev/mif/MacMain.h	1997-07-18 16:58:44.000000000 +0200
+++ ug-patched/dev/mif/MacMain.h	1997-07-18 17:00:14.000000000 +0200
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/mif/MacMain.h,v 1.3 1997/07/18 14:58:44 birken Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/mif/MacShell.c ug-patched/dev/mif/MacShell.c
--- ug-orig/dev/mif/MacShell.c	2006-06-02 18:25:44.000000000 +0200
+++ ug-patched/dev/mif/MacShell.c	2006-06-02 18:25:44.000000000 +0200
@@ -134,7 +134,7 @@
 static ControlActionUPP MyShellScrollActionPtr;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/mif/MacShell.c,v 1.17 2006/06/02 16:25:44 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/MacShell.h ug-patched/dev/mif/MacShell.h
--- ug-orig/dev/mif/MacShell.h	2002-02-12 17:48:50.000000000 +0100
+++ ug-patched/dev/mif/MacShell.h	2002-02-12 17:48:50.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/mif/MacShell.h,v 1.5 2002/02/12 16:48:50 reichenb Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/mif/MacSurface.c ug-patched/dev/mif/MacSurface.c
--- ug-orig/dev/mif/MacSurface.c	2006-06-02 18:25:44.000000000 +0200
+++ ug-patched/dev/mif/MacSurface.c	2006-06-02 18:25:44.000000000 +0200
@@ -100,7 +100,7 @@
 int screenHeight;					/* screen size while program is running */
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/mif/MacSurface.c,v 1.12 2006/06/02 16:25:44 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/MacSurface.h ug-patched/dev/mif/MacSurface.h
--- ug-orig/dev/mif/MacSurface.h	2002-02-12 17:48:50.000000000 +0100
+++ ug-patched/dev/mif/MacSurface.h	2002-02-12 17:48:50.000000000 +0100
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/mif/MacSurface.h,v 1.4 2002/02/12 16:48:50 reichenb Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/mif/Makefile.am ug-patched/dev/mif/Makefile.am
--- ug-orig/dev/mif/Makefile.am	2004-09-02 14:22:04.000000000 +0200
+++ ug-patched/dev/mif/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:04 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS)
 
diff -ruN ug-orig/dev/mif/MAppController.h ug-patched/dev/mif/MAppController.h
--- ug-orig/dev/mif/MAppController.h	1999-06-18 12:50:06.000000000 +0200
+++ ug-patched/dev/mif/MAppController.h	1999-06-18 12:50:13.000000000 +0200
@@ -35,4 +35,4 @@
 - (void)showInspector:(id)sender;
 - (void)showPreferences:(id)sender;
 - (void)dealloc;
-@end
\ Kein Zeilenumbruch am Dateiende.
+@end
diff -ruN ug-orig/dev/mif/MAppController.m ug-patched/dev/mif/MAppController.m
--- ug-orig/dev/mif/MAppController.m	1999-09-08 17:23:55.000000000 +0200
+++ ug-patched/dev/mif/MAppController.m	1999-09-08 17:24:03.000000000 +0200
@@ -101,4 +101,4 @@
     [super dealloc];
 }
 
-@end
\ Kein Zeilenumbruch am Dateiende.
+@end
diff -ruN ug-orig/dev/mif/mif.pbproj/CVS/Entries ug-patched/dev/mif/mif.pbproj/CVS/Entries
--- ug-orig/dev/mif/mif.pbproj/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/mif.pbproj/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/project.pbxproj/1.1/Wed May 15 15:44:13 2002//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/mif.pbproj/CVS/Repository ug-patched/dev/mif/mif.pbproj/CVS/Repository
--- ug-orig/dev/mif/mif.pbproj/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/mif.pbproj/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/mif.pbproj
diff -ruN ug-orig/dev/mif/mif.pbproj/CVS/Root ug-patched/dev/mif/mif.pbproj/CVS/Root
--- ug-orig/dev/mif/mif.pbproj/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/mif.pbproj/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/mif.pbproj/CVS/Tag ug-patched/dev/mif/mif.pbproj/CVS/Tag
--- ug-orig/dev/mif/mif.pbproj/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/mif.pbproj/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/mif/MInterface.m ug-patched/dev/mif/MInterface.m
--- ug-orig/dev/mif/MInterface.m	2004-05-04 15:05:18.000000000 +0200
+++ ug-patched/dev/mif/MInterface.m	2004-05-04 15:05:18.000000000 +0200
@@ -60,7 +60,7 @@
 /*		  macros															*/
 /*																			*/
 /****************************************************************************/
-#define VERSION 	"This is "UG_VERSION" from $Date: 2004/05/04 13:05:18 $\n"
+#define VERSION 	"This is "UG_VERSION" from $Date: 2004-05-04 15:05:18 +0200 (Di, 04. Mai 2004) $\n"
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/mif/MShell.h ug-patched/dev/mif/MShell.h
--- ug-orig/dev/mif/MShell.h	1999-09-08 17:23:59.000000000 +0200
+++ ug-patched/dev/mif/MShell.h	1999-09-08 17:24:03.000000000 +0200
@@ -58,4 +58,4 @@
 - (NSRange)textView:(NSTextView *)aTextView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange;*/
 @end
 
-#endif
\ Kein Zeilenumbruch am Dateiende.
+#endif
diff -ruN ug-orig/dev/mif/MShell.m ug-patched/dev/mif/MShell.m
--- ug-orig/dev/mif/MShell.m	1999-09-08 17:23:59.000000000 +0200
+++ ug-patched/dev/mif/MShell.m	1999-09-08 17:24:03.000000000 +0200
@@ -215,4 +215,4 @@
     return YES;
 }
 @end
-
\ Kein Zeilenumbruch am Dateiende.
+
diff -ruN ug-orig/dev/mif/MShellTextView.h ug-patched/dev/mif/MShellTextView.h
--- ug-orig/dev/mif/MShellTextView.h	1999-06-18 12:50:11.000000000 +0200
+++ ug-patched/dev/mif/MShellTextView.h	1999-06-18 12:50:13.000000000 +0200
@@ -25,7 +25,7 @@
 @interface MShellTextView : NSTextView
 {
 	int startPosition;					// This is the start of the current command.
-    NSTextStorage *theTextStore;
+    NSTextStorage *theTextStore;
 
     NSMutableArray	*theCommandList;	// store the history of entered commands
     unsigned int	commandCount;		// count the number of entered commands
@@ -44,10 +44,10 @@
 
 - (void) appendText:(NSString *)str;
 
-- (void)keyDown:(NSEvent *)theEvent;
+- (void)keyDown:(NSEvent *)theEvent;
 
 - (void) replaceCurrentCommandWith:(NSString *)command;
 
-- (void)highlightError;
+- (void)highlightError;
 
-@end
\ Kein Zeilenumbruch am Dateiende.
+@end
diff -ruN ug-orig/dev/mif/MShellTextView.m ug-patched/dev/mif/MShellTextView.m
--- ug-orig/dev/mif/MShellTextView.m	1999-09-08 17:24:00.000000000 +0200
+++ ug-patched/dev/mif/MShellTextView.m	1999-09-08 17:24:03.000000000 +0200
@@ -21,7 +21,7 @@
 #include "cmdint.h"
 
 
-#define RETURN    @"\015"
+#define RETURN    @"\015"
 #define BACKSPACE @"\010"
 
 
@@ -86,7 +86,7 @@
     [self setFont:[NSFont userFixedPitchFontOfSize:10.0]];
 
     /*[self setFont:[NSFont userFixedPitchFontOfSize:10]
-          range:NSMakeRange(0,[[self string] length])];
+          range:NSMakeRange(0,[[self string] length])];
 
     printf ("4 Desired font is %s, ", [[[NSFont userFixedPitchFontOfSize:18] displayName] lossyCString]);
     printf ("Current font is %s ", [[[self font] displayName] lossyCString]);
@@ -97,7 +97,7 @@
     if ([self shouldChangeTextInRange:NSMakeRange(0,[[self string] length])
                     replacementString:nil])
     {
-        [theTextStore beginEditing];
+        [theTextStore beginEditing];
         [theTextStore addAttributes:textAttributes range:NSMakeRange(0,[[self string] length])];
         [theTextStore fixAttributesInRange:NSMakeRange(0,[[self string] length])];
         [theTextStore endEditing];
@@ -121,12 +121,12 @@
     if ([self shouldChangeTextInRange:NSMakeRange([theTextStore length]-plen, plen)
                     replacementString:nil])
     {
-        [theTextStore beginEditing];
-        [theTextStore addAttributes:promptAttributes range:NSMakeRange([theTextStore length]-plen, plen-1)];
-        [theTextStore addAttributes:cmdlineAttributes range:NSMakeRange([theTextStore length]-1, 1)];
+        [theTextStore beginEditing];
+        [theTextStore addAttributes:promptAttributes range:NSMakeRange([theTextStore length]-plen, plen-1)];
+        [theTextStore addAttributes:cmdlineAttributes range:NSMakeRange([theTextStore length]-1, 1)];
         [theTextStore endEditing];
         [self didChangeText];
-    }
+    }
 
     startPosition = [theTextStore length];
     [self scrollRangeToVisible:NSMakeRange(startPosition, 0)];
@@ -138,7 +138,7 @@
 {
     static int i;
 
-    [self moveToEndOfDocument:self];
+    [self moveToEndOfDocument:self];
     /* this changes the font back to Helvetica! 
     [theTextStore
             replaceCharactersInRange:NSMakeRange([theTextStore length], 0)
@@ -157,7 +157,7 @@
     return;
 }
 
-- (void) keyDown:(NSEvent *)theEvent
+- (void) keyDown:(NSEvent *)theEvent
 {
     unichar key;
     
@@ -166,12 +166,12 @@
         return;
     }
     
-    if ([self selectedRange].location < startPosition)
-    {
+    if ([self selectedRange].location < startPosition)
+    {
         [self moveToEndOfDocument:self]; 	// ...not implemented yet
         [self setSelectedRange:NSMakeRange([[self string] length],0)];
-        [self scrollRangeToVisible:[self selectedRange]];  
-    }
+        [self scrollRangeToVisible:[self selectedRange]];  
+    }
 
     key = [[theEvent characters] characterAtIndex:0];
 
@@ -200,19 +200,19 @@
         [self moveToEndOfDocument:self];
         [self setSelectedRange:NSMakeRange([[self string] length],0)];
 
-        [super keyDown:theEvent];
+        [super keyDown:theEvent];
         [theUGshell interpretCommand:command];
-        [self appendPrompt];
-        [self scrollRangeToVisible:[self selectedRange]];
-        startPosition = [[self string] length];
+        [self appendPrompt];
+        [self scrollRangeToVisible:[self selectedRange]];
+        startPosition = [[self string] length];
         [currentLine setString:@""];
-    }
+    }
 	
     else if ( key==NSLeftArrowFunctionKey
               && !([theEvent modifierFlags] & NSCommandKeyMask))
    {
-      	if ([self selectedRange].location > startPosition)
-       		[super keyDown:theEvent];
+      	if ([self selectedRange].location > startPosition)
+       		[super keyDown:theEvent];
     }
     
     else if ( key==NSUpArrowFunctionKey
@@ -232,9 +232,9 @@
             currCommandNumber--;
             [self replaceCurrentCommandWith:[theCommandList objectAtIndex:currCommandNumber%MAX_BUFFERED_COMMANDS]];
         }
-    }
+    }
 
-    else if ( key==NSDownArrowFunctionKey 
+    else if ( key==NSDownArrowFunctionKey 
               && !([theEvent modifierFlags] & NSCommandKeyMask))
     {
         currCommandNumber++;
@@ -245,12 +245,12 @@
             [self replaceCurrentCommandWith:currentLine];
             currCommandNumber = commandCount;
         }
-    }
+    }
 
     else if ( (key==NSBackspaceCharacter || key==NSBackTabCharacter || key==NSDeleteCharacter)
               && !([theEvent modifierFlags] & NSCommandKeyMask))
     {
-        if ([self selectedRange].location > startPosition)	{
+        if ([self selectedRange].location > startPosition)	{
             [super keyDown:theEvent];
        	}
 	}
@@ -285,11 +285,11 @@
         [self moveToEndOfDocument:self];
         [self setSelectedRange:NSMakeRange([[self string] length],0)];
 
-        [super keyDown:theEvent];
+        [super keyDown:theEvent];
         [theUGshell interpretCommand:command];
-        [self appendPrompt];
-        [self scrollRangeToVisible:[self selectedRange]];
-        startPosition = [[self string] length];
+        [self appendPrompt];
+        [self scrollRangeToVisible:[self selectedRange]];
+        startPosition = [[self string] length];
         [currentLine setString:@""];*/
     }
     
@@ -301,17 +301,17 @@
 }
 
 - (void) replaceCurrentCommandWith:(NSString *)command
-{
+{
     [self setSelectedRange:NSMakeRange(startPosition,[[self string] length]-startPosition)];
     [theTextStore addAttributes:cmdlineAttributes range:NSMakeRange(startPosition,[[self string] length]-startPosition)];
-    [self insertText:command];
-    [self moveToEndOfDocument:self];
+    [self insertText:command];
+    [self moveToEndOfDocument:self];
     [self scrollRangeToVisible:[self selectedRange]];
 
     return;
-}
+}
 
-- (void)highlightError
+- (void)highlightError
 {
 	NSRange range=[[theTextStore string] rangeOfString:@"\n" options:NSLiteralSearch
 				range:NSMakeRange(startPosition,[[self string] length]-startPosition)];
@@ -319,12 +319,12 @@
 	if ( range.length>0 )
         if ([self shouldChangeTextInRange:NSMakeRange(startPosition,range.location-startPosition) replacementString:nil])
         {
-            [theTextStore beginEditing];
-            [theTextStore addAttributes:errorAttributes range:NSMakeRange(startPosition,range.location-startPosition)];
+            [theTextStore beginEditing];
+            [theTextStore addAttributes:errorAttributes range:NSMakeRange(startPosition,range.location-startPosition)];
             [theTextStore endEditing];
             [self didChangeText];
-        }
+        }
 }
-
 
-@end
\ Kein Zeilenumbruch am Dateiende.
+
+@end
diff -ruN ug-orig/dev/mif/MShellView.h ug-patched/dev/mif/MShellView.h
--- ug-orig/dev/mif/MShellView.h	1999-06-10 20:47:15.000000000 +0200
+++ ug-patched/dev/mif/MShellView.h	1999-06-10 20:47:19.000000000 +0200
@@ -41,4 +41,4 @@
 - (MShellTextView *)textView;
 - (NSScrollView *)scrollView;
 
-@end
\ Kein Zeilenumbruch am Dateiende.
+@end
diff -ruN ug-orig/dev/mif/MShellView.m ug-patched/dev/mif/MShellView.m
--- ug-orig/dev/mif/MShellView.m	1999-09-08 17:24:00.000000000 +0200
+++ ug-patched/dev/mif/MShellView.m	1999-09-08 17:24:03.000000000 +0200
@@ -139,4 +139,4 @@
   return theScrollView;
 }
 
-@end
\ Kein Zeilenumbruch am Dateiende.
+@end
diff -ruN ug-orig/dev/mif/MShellWindow.h ug-patched/dev/mif/MShellWindow.h
--- ug-orig/dev/mif/MShellWindow.h	1999-06-10 20:47:16.000000000 +0200
+++ ug-patched/dev/mif/MShellWindow.h	1999-06-10 20:47:19.000000000 +0200
@@ -32,4 +32,4 @@
                 defer:(BOOL)flag;
 @end
 
-#endif
\ Kein Zeilenumbruch am Dateiende.
+#endif
diff -ruN ug-orig/dev/mif/MShellWindow.m ug-patched/dev/mif/MShellWindow.m
--- ug-orig/dev/mif/MShellWindow.m	1999-06-18 12:50:12.000000000 +0200
+++ ug-patched/dev/mif/MShellWindow.m	1999-06-18 12:50:13.000000000 +0200
@@ -49,4 +49,4 @@
 }
 
 @end
-
\ Kein Zeilenumbruch am Dateiende.
+
diff -ruN ug-orig/dev/mif/PBUserInfo/CVS/Entries ug-patched/dev/mif/PBUserInfo/CVS/Entries
--- ug-orig/dev/mif/PBUserInfo/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/PBUserInfo/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/PBUserInfo_reichenb.plist/1.1/Wed Jun  9 15:34:15 1999//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/mif/PBUserInfo/CVS/Repository ug-patched/dev/mif/PBUserInfo/CVS/Repository
--- ug-orig/dev/mif/PBUserInfo/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/PBUserInfo/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/mif/PBUserInfo
diff -ruN ug-orig/dev/mif/PBUserInfo/CVS/Root ug-patched/dev/mif/PBUserInfo/CVS/Root
--- ug-orig/dev/mif/PBUserInfo/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/PBUserInfo/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/mif/PBUserInfo/CVS/Tag ug-patched/dev/mif/PBUserInfo/CVS/Tag
--- ug-orig/dev/mif/PBUserInfo/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/mif/PBUserInfo/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/nif/CVS/Entries ug-patched/dev/nif/CVS/Entries
--- ug-orig/dev/nif/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/nif/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:09 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:04 2004//D2008.11.12.23.00.00
-/Makefile.nif/1.2/Wed Feb  4 14:26:19 1998//D2008.11.12.23.00.00
-/NeXTInterface.h/1.3/Wed Sep  2 12:25:21 1998//D2008.11.12.23.00.00
-/NeXTInterface.m/1.2/Fri Aug  7 13:36:53 1998//D2008.11.12.23.00.00
-/UGGraphWindow.h/1.3/Wed Sep  2 12:25:23 1998//D2008.11.12.23.00.00
-/UGGraphWindow.m/1.1/Wed Feb  4 14:22:20 1998//D2008.11.12.23.00.00
-/UGShellWindow.h/1.1/Wed Feb  4 14:22:20 1998//D2008.11.12.23.00.00
-/UGShellWindow.m/1.2/Fri Aug  7 13:36:55 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/nif/CVS/Repository ug-patched/dev/nif/CVS/Repository
--- ug-orig/dev/nif/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/nif/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/nif
diff -ruN ug-orig/dev/nif/CVS/Root ug-patched/dev/nif/CVS/Root
--- ug-orig/dev/nif/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/nif/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/nif/CVS/Tag ug-patched/dev/nif/CVS/Tag
--- ug-orig/dev/nif/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/nif/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/nif/.cvsignore ug-patched/dev/nif/.cvsignore
--- ug-orig/dev/nif/.cvsignore	2004-09-08 16:14:09.000000000 +0200
+++ ug-patched/dev/nif/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/nif/Makefile.am ug-patched/dev/nif/Makefile.am
--- ug-orig/dev/nif/Makefile.am	2004-09-02 14:22:04.000000000 +0200
+++ ug-patched/dev/nif/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,3 +1,3 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:04 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 
diff -ruN ug-orig/dev/nif/NeXTInterface.h ug-patched/dev/nif/NeXTInterface.h
--- ug-orig/dev/nif/NeXTInterface.h	1998-09-02 14:25:21.000000000 +0200
+++ ug-patched/dev/nif/NeXTInterface.h	1998-09-02 14:28:06.000000000 +0200
@@ -38,7 +38,7 @@
 #import <appkit/Window.h>
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/nif/NeXTInterface.h,v 1.3 1998/09/02 12:25:21 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/nif/NeXTInterface.m ug-patched/dev/nif/NeXTInterface.m
--- ug-orig/dev/nif/NeXTInterface.m	1998-08-07 15:36:53.000000000 +0200
+++ ug-patched/dev/nif/NeXTInterface.m	1998-08-07 15:39:05.000000000 +0200
@@ -60,7 +60,7 @@
 /*		  macros															*/
 /*																			*/
 /****************************************************************************/
-#define VERSION 	"This is "UG_VERSION" from $Date: 1998/08/07 13:36:53 $\n"
+#define VERSION 	"This is "UG_VERSION" from $Date: 1998-08-07 15:39:05 +0200 (Fr, 07. Aug 1998) $\n"
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/nif/UGGraphWindow.h ug-patched/dev/nif/UGGraphWindow.h
--- ug-orig/dev/nif/UGGraphWindow.h	1998-09-02 14:25:23.000000000 +0200
+++ ug-patched/dev/nif/UGGraphWindow.h	1998-09-02 14:28:06.000000000 +0200
@@ -29,7 +29,7 @@
 #endif
  
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/nif/UGGraphWindow.h,v 1.3 1998/09/02 12:25:23 henrik Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/dev/ppm/CVS/Entries ug-patched/dev/ppm/CVS/Entries
--- ug-orig/dev/ppm/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ppm/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:10 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:05 2004//D2008.11.12.23.00.00
-/Makefile.ppm/1.1.1.1/Wed Nov 25 09:20:37 1998//D2008.11.12.23.00.00
-/ppm.c/1.10/Tue Nov  2 10:35:33 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/ppm/CVS/Repository ug-patched/dev/ppm/CVS/Repository
--- ug-orig/dev/ppm/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ppm/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/ppm
diff -ruN ug-orig/dev/ppm/CVS/Root ug-patched/dev/ppm/CVS/Root
--- ug-orig/dev/ppm/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ppm/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/ppm/CVS/Tag ug-patched/dev/ppm/CVS/Tag
--- ug-orig/dev/ppm/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ppm/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/ppm/.cvsignore ug-patched/dev/ppm/.cvsignore
--- ug-orig/dev/ppm/.cvsignore	2004-09-08 16:14:10.000000000 +0200
+++ ug-patched/dev/ppm/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/ppm/Makefile.am ug-patched/dev/ppm/Makefile.am
--- ug-orig/dev/ppm/Makefile.am	2004-09-02 14:22:05.000000000 +0200
+++ ug-patched/dev/ppm/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:05 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS)
 
diff -ruN ug-orig/dev/ppm/ppm.c ug-patched/dev/ppm/ppm.c
--- ug-orig/dev/ppm/ppm.c	2004-11-02 11:35:33.000000000 +0100
+++ ug-patched/dev/ppm/ppm.c	2008-12-19 11:14:03.000000000 +0100
@@ -24,6 +24,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -71,7 +72,7 @@
 static short BlueTab[COLORS]; 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/ppm/ppm.c,v 1.10 2004/11/02 10:35:33 thimo Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/ps/CVS/Entries ug-patched/dev/ps/CVS/Entries
--- ug-orig/dev/ps/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ps/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:10 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:05 2004//D2008.11.12.23.00.00
-/Makefile.ps/1.5/Sun Nov  8 19:55:55 1998//D2008.11.12.23.00.00
-/postscript.c/1.28/Wed Jul 21 09:20:03 2004//D2008.11.12.23.00.00
-/postscriptbw.c/1.7/Fri Jul 22 13:01:14 2005//D2008.11.12.23.00.00
-/ps.make/1.2/Sun Nov 24 22:21:49 1996//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/ps/CVS/Repository ug-patched/dev/ps/CVS/Repository
--- ug-orig/dev/ps/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ps/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/ps
diff -ruN ug-orig/dev/ps/CVS/Root ug-patched/dev/ps/CVS/Root
--- ug-orig/dev/ps/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ps/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/ps/CVS/Tag ug-patched/dev/ps/CVS/Tag
--- ug-orig/dev/ps/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/ps/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/ps/.cvsignore ug-patched/dev/ps/.cvsignore
--- ug-orig/dev/ps/.cvsignore	2004-09-08 16:14:10.000000000 +0200
+++ ug-patched/dev/ps/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/ps/Makefile.am ug-patched/dev/ps/Makefile.am
--- ug-orig/dev/ps/Makefile.am	2004-09-02 14:22:05.000000000 +0200
+++ ug-patched/dev/ps/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:05 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS)
 
diff -ruN ug-orig/dev/ps/postscriptbw.c ug-patched/dev/ps/postscriptbw.c
--- ug-orig/dev/ps/postscriptbw.c	2005-07-22 15:01:14.000000000 +0200
+++ ug-patched/dev/ps/postscriptbw.c	2008-12-19 11:14:03.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stddef.h>
 #include <string.h>
 #include <stdio.h>
@@ -116,7 +117,7 @@
 static float blue[COLORS];
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/ps/postscriptbw.c,v 1.7 2005/07/22 13:01:14 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/ps/postscript.c ug-patched/dev/ps/postscript.c
--- ug-orig/dev/ps/postscript.c	2004-07-21 11:20:03.000000000 +0200
+++ ug-patched/dev/ps/postscript.c	2008-12-19 11:14:03.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stddef.h>
 #include <string.h>
 #include <stdio.h>
@@ -115,7 +116,7 @@
 static float blue[COLORS];
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/ps/postscript.c,v 1.28 2004/07/21 09:20:03 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/rif/CVS/Entries ug-patched/dev/rif/CVS/Entries
--- ug-orig/dev/rif/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/rif/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:11 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:06 2004//D2008.11.12.23.00.00
-/Makefile.rif/1.3/Mon Jun 16 10:45:36 1997//D2008.11.12.23.00.00
-/remote.c/1.14/Thu Jul 14 11:40:24 2005//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/rif/CVS/Repository ug-patched/dev/rif/CVS/Repository
--- ug-orig/dev/rif/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/rif/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/rif
diff -ruN ug-orig/dev/rif/CVS/Root ug-patched/dev/rif/CVS/Root
--- ug-orig/dev/rif/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/rif/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/rif/CVS/Tag ug-patched/dev/rif/CVS/Tag
--- ug-orig/dev/rif/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/rif/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/rif/.cvsignore ug-patched/dev/rif/.cvsignore
--- ug-orig/dev/rif/.cvsignore	2004-09-08 16:14:11.000000000 +0200
+++ ug-patched/dev/rif/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/rif/Makefile.am ug-patched/dev/rif/Makefile.am
--- ug-orig/dev/rif/Makefile.am	2004-09-02 14:22:06.000000000 +0200
+++ ug-patched/dev/rif/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:06 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS)
 
diff -ruN ug-orig/dev/rif/remote.c ug-patched/dev/rif/remote.c
--- ug-orig/dev/rif/remote.c	2005-07-14 13:40:24.000000000 +0200
+++ ug-patched/dev/rif/remote.c	2008-12-19 11:14:03.000000000 +0100
@@ -29,6 +29,7 @@
 /****************************************************************************/
 
 
+#include "config.h"
 #include "sockcomm.h"
 
 
@@ -82,7 +83,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/rif/remote.c,v 1.14 2005/07/14 11:40:24 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 
diff -ruN ug-orig/dev/sif/CVS/Entries ug-patched/dev/sif/CVS/Entries
--- ug-orig/dev/sif/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/sif/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:11 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:06 2004//D2008.11.12.23.00.00
-/Makefile.sif/1.4/Mon Jun 16 10:45:37 1997//D2008.11.12.23.00.00
-/sif.c/1.13/Wed Jul 21 09:20:04 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/sif/CVS/Repository ug-patched/dev/sif/CVS/Repository
--- ug-orig/dev/sif/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/sif/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/sif
diff -ruN ug-orig/dev/sif/CVS/Root ug-patched/dev/sif/CVS/Root
--- ug-orig/dev/sif/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/sif/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/sif/CVS/Tag ug-patched/dev/sif/CVS/Tag
--- ug-orig/dev/sif/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/sif/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/sif/.cvsignore ug-patched/dev/sif/.cvsignore
--- ug-orig/dev/sif/.cvsignore	2004-09-08 16:14:11.000000000 +0200
+++ ug-patched/dev/sif/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/sif/Makefile.am ug-patched/dev/sif/Makefile.am
--- ug-orig/dev/sif/Makefile.am	2004-09-02 14:22:06.000000000 +0200
+++ ug-patched/dev/sif/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:06 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 AM_CPPFLAGS = $(UG_CPPFLAGS) -I$(top_srcdir)/low
 
diff -ruN ug-orig/dev/sif/sif.c ug-patched/dev/sif/sif.c
--- ug-orig/dev/sif/sif.c	2004-07-21 11:20:04.000000000 +0200
+++ ug-patched/dev/sif/sif.c	2008-12-19 11:14:03.000000000 +0100
@@ -25,6 +25,7 @@
 /****************************************************************************/
 
 /* standard C includes */
+#include "config.h"
 #include <string.h>
 #include <math.h>
 #include <stddef.h>
@@ -58,7 +59,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/sif/sif.c,v 1.13 2004/07/21 09:20:04 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/sockcomm.c ug-patched/dev/sockcomm.c
--- ug-orig/dev/sockcomm.c	1997-09-10 12:32:42.000000000 +0200
+++ ug-patched/dev/sockcomm.c	2008-12-19 11:14:03.000000000 +0100
@@ -26,6 +26,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include "compiler.h"
 #include "general.h"
 
@@ -38,7 +39,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/sockcomm.c,v 1.8 1997/09/10 10:32:42 wieners Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 /****************************************************************************/
diff -ruN ug-orig/dev/sockcomm.h ug-patched/dev/sockcomm.h
--- ug-orig/dev/sockcomm.h	1997-10-08 19:45:43.000000000 +0200
+++ ug-patched/dev/sockcomm.h	1997-10-08 19:45:43.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/sockcomm.h,v 1.8 1997/10/08 17:45:43 reichenb Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/dev/ugdevices.c ug-patched/dev/ugdevices.c
--- ug-orig/dev/ugdevices.c	2005-07-18 15:42:28.000000000 +0200
+++ ug-patched/dev/ugdevices.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -90,9 +91,14 @@
 /*																			*/
 /****************************************************************************/
 
-/* the mute level is set by the MuteCommand and used for output control		*/
-/* convention: 0 is default, <0 produces less output, >0 produces more outpu*/
+/* the mute level is set by the MuteCommand and used for output control.
+   convention: 0 is default, <0 produces less output, >0 produces more output.
+   When compiling for DUNE, the default is -1001, which equals total silence. */
+#ifndef FOR_DUNE
 static INT mutelevel=0;
+#else
+static INT mutelevel=-1001;
+#endif
 
 static FILE *logFile=NULL;						/* log file pointer 		*/
 static OUTPUTDEVICE *defaultOuputDevice=NULL;	/* console graphical outp.	*/
@@ -101,7 +107,7 @@
 static INT theOutputDevVarID;			/* env type for Output Device vars	*/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/ugdevices.c,v 1.12 2005/07/18 13:42:28 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -130,7 +136,7 @@
 D*/
 /****************************************************************************/
 
-OUTPUTDEVICE * NS_PREFIX CreateOutputDevice (char *name)
+OUTPUTDEVICE * NS_PREFIX CreateOutputDevice (const char *name)
 {
 	OUTPUTDEVICE *dev;
 	
diff -ruN ug-orig/dev/ugdevices.doc ug-patched/dev/ugdevices.doc
--- ug-orig/dev/ugdevices.doc	1998-08-07 16:42:03.000000000 +0200
+++ ug-patched/dev/ugdevices.doc	2007-12-04 10:57:48.000000000 +0100
@@ -67,124 +67,6 @@
 /*D
     OUTPUTDEVICE - data structure to define an interface to output devices
     
-    PURPOSE:
-    The struct 'OUTPUTDEVICE' defines an interface to an output device with
-    graphics capabilites. ug uses a default output device which usually is your
-    computer monitor. Additionally there can be defined several other output devices.
-    
-    Up to now there is implemented an interface to XWindows of UNIX and to the
-    Macintosh OS with the possibilties of window handling and plotting.
-    They serve as default output device.
-    
-    Another output is the 'meta' ouput device. This is a format to write graphics commands
-    to file which later can be view with the 'xugv' tool or that can be translated to PostScript
-    format using the 'm2ps' tool. It is a lean storage format
-    suited quite well for producing and viewing "films" with many pictures of time dependent solutions.
-    It is also a helpful tool for production runs on large problems which often will run
-    in batch mode.
-    
-    In the near future probably also a PostScript output device will exist.
-    
-    The output device struct requires functions for opening, closing, activating and updating
-    a window on the device. Then there is a collection of graphics functions to set color,
-    line width move the cursor, draw lines and higher level functions to plot filled polygons
-    and text.
-    
-    Additionally there is information specified on the color palette used and some standard
-    colors are defined.
-    
-    DEFINITION:
-.vb
-// abstract graphical output device 
-struct outputdevice {
-
-    // This is an environment variable 
-    ENVVAR v;
-
-    // properties 
-    long black;                         // value for black                                      
-    long white;                         // value for white                                      
-    long red;                           // value for red                                        
-    long green;                         // value for green                                      
-    long blue;                          // value for blue                                       
-    long cyan;                          // value for cyan                                       
-    long orange;                        // value for orange                                     
-    long yellow;                        // value for yellow                                     
-    long darkyellow;                    // value for yellow                                     
-    long magenta;                       // value for magenta                                    
-    short hasPalette;                   // 1 if device has a color lookup table                 
-    long range;                         // # of possible color indices                          
-    long spectrumStart;                 // usable range for a continuous                        
-    long spectrumEnd;                   // color spectrum                                       
-    DOUBLE PixelRatio;                   // ratio of (physical) hight to width of a pixel        
-
-    // pointers to basic drawing functions 
-    void (*Move) (SHORT_POINT);             // move in device coordinates       
-    void (*Draw) (SHORT_POINT);             // draw from current point to given 
-    void (*Polyline) (SHORT_POINT *, INT ); // draw a polyline                  
-    void (*InversePolyline) (SHORT_POINT *, INT );          
-                                            // draw an inverted polyline        
-    void (*Polygon) (SHORT_POINT *, INT );  // fill a polygon w. curr. col      
-    void (*InversePolygon) (SHORT_POINT *, INT );           
-                                            // invert a polygon w. curr. col    
-    void (*ErasePolygon) (SHORT_POINT *, INT );             
-                                            // erase a polygon w. curr. col     
-    void (*Polymark) (short, SHORT_POINT *);// place markers                    
-    
-    void (*Text) (const char *, INT);       // draw text in current size/font
-    void (*CenteredText) (SHORT_POINT, const char *, INT);  
-                                            // draw text centered at x,y        
-                                            // possible text modes are 
-                                            // TEXT_REGULAR and TEXT_INVERSE 
-                                            // (the last argument)
-    
-    void (*ClearViewPort)(void);            // clear a view port                
-    
-    // pointers to set functions 
-    void (*SetLineWidth) (short);           // line width in pixels (points)    
-    void (*SetTextSize) (short);            // text size in pixels (points)     
-    void (*SetMarker) (short);              // set marker id                    
-    void (*SetMarkerSize) (short);          // marker size in pixels (points)   
-    void (*SetColor) (long);                // arg is index or direct col value 
-    void (*SetPaletteEntry) (long,short,short,short);       
-                                            // set index to value               
-    void (*SetNewPalette) (long,long,short*,short*,short*); 
-                                            // replace entry                    
-    
-    // pointers to miscellaneous functions 
-    void (*GetPaletteEntry) (long,short *,short *,short *); 
-                                            // read color table                 
-    void (*Flush) (void);                   // flush graphics buffer            
-    
-    // operations for managing windows 
-    OpenOutputPtr OpenOutput;               // function to open a window                              
-    CloseOutputPtr CloseOutput;             // function to close a window                             
-    ActivateOutputPtr ActivateOutput;       // function to activate window                            
-    UpdateOutputPtr UpdateOutput;           // function to draw outline with tool
-                                            // and info box        
-};
-
-typedef struct outputdevice     OUTPUTDEVICE;
-
-// type for device coordinates 
-typedef struct
-{
-    short x;
-    short y;
-} SHORT_POINT ;
-
-// identification of windows 
-typedef INT WINDOWID;
-
-// function types exported by OUTPUTDEVICE 
-typedef WINDOWID (*OpenOutputPtr)     (const char *title,
-                      INT x, INT y, INT width, INT height,
-                      INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, INT *error); 
-typedef INT      (*CloseOutputPtr)    (WINDOWID win);
-typedef INT      (*ActivateOutputPtr) (WINDOWID win);
-typedef INT      (*UpdateOutputPtr)   (WINDOWID win, char *s, INT tool);
-.ve
-
     STRUCT COMPONENTS:
     We only explain the function pointers together with their arguments and types in correct order.
     
@@ -198,7 +80,7 @@
 .   ErasePolygon    - erase filled polygon (closed) connecting 'SHORT_POINT points[], INT nPoints' in total
 .   Polymark        - plot 'short nMarkers' at 'SHORT_POINT points[]'
 .   Text            - write text at 'SHORT_POINT position' with 'INT mode' TEXT_REGULAR or TEXT_INVERSE
-.   CenteredText    - write centered text at'SHORT_POINT position' with 'INT mode' TEXT_REGULAR or TEXT_INVERSE
+.   CenteredText    - write centered text at 'SHORT_POINT position' with 'INT mode' TEXT_REGULAR or TEXT_INVERSE
 .   ClearViewPort   - clear the whole view port of the window
 .   SetLineWidth    - set current line width to 'short width'
 .   SetTextSize     - set current text size to 'short size'
@@ -228,118 +110,3 @@
 D*/
 /****************************************************************************/
 
-/****************************************************************************/
-/*D
-    EVENT - data structure for the ug event handling
-    
-    PURPOSE:
-    The event handling of ug defines several possible event types the interface
-    function 'GetNextUGEvent' can return to 'ProcessEvent'. Depending on the
-    event type data are transferred by the corresponding component in the union.
-    The events are distinguished by the 'Type' component in the 'EVENT'
-    
-    DEFINITION:
-.vb
-typedef union {
-    INT Type;
-    NO_UGEVENT              NoEvent;
-    TERM_GOAWAY_EVENT       TermGoAway;
-    TERM_CMDKEY_EVENT       TermCmdKey;
-    TERM_STRING_EVENT       TermString;
-    DOC_GOAWAY_EVENT        DocGoAway;
-    DOC_ACTIVATE_EVENT      DocActivate;
-    DOC_DRAG_EVENT          DocDrag;
-    DOC_GROW_EVENT          DocGrow;
-    DOC_CHANGETOOL_EVENT    DocChangeTool;
-    DOC_CONTENTCLICK_EVENT  DocContentClick;
-    DOC_UPDATE_EVENT        DocUpdate;
-} EVENT;
-
-typedef struct {                    // no event                                 
-    INT Type;                       // event type                               
-    
-    // data 
-    INT InterfaceEvent;             // 1 if the interface event was handled     
-} NO_UGEVENT;
-
-typedef struct {                    // go away event for terminal window        
-    INT Type;                       // event type                               
-} TERM_GOAWAY_EVENT;
-
-typedef struct {                    // cmd key event for terminal window        
-    INT Type;                       // event type                               
-    
-    // data 
-    char CmdKey;                    // character from keyboard                  
-} TERM_CMDKEY_EVENT;
-
-typedef struct {                    // string event for terminal window         
-    INT Type;                       // event type                               
-    
-    // data 
-    char String[INPUTBUFFERLEN];    // string from keyboard                     
-} TERM_STRING_EVENT;
-
-typedef struct {                    // go away event for view                   
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-} DOC_GOAWAY_EVENT;
-
-typedef struct {                    // activate event for view                  
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-} DOC_ACTIVATE_EVENT;
-
-typedef struct {                    // drag event for view                      
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-    INT Global_LL[2];               // new absolute position of window on screen
-    INT Global_UR[2];               //                                          
-} DOC_DRAG_EVENT;
-
-typedef struct {                    // grow event for view                      
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-    INT Global_LL[2];               // new absolute position of window on screen
-    INT Global_UR[2];               //                                          
-    INT Local_LL[2];                // range of pixels used for plotting (view port)        
-    INT Local_UR[2];                //                                          
-} DOC_GROW_EVENT;
-
-typedef struct {                    // change tool event for view               
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-    INT Tool;                       // change to that tool                      
-} DOC_CHANGETOOL_EVENT;
-
-typedef struct {                    // content click event for view             
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-    INT MousePosition[2];           // mouse position                           
-} DOC_CONTENTCLICK_EVENT;
-
-typedef struct {                    // update event for view                    
-    INT Type;                       // event type                               
-    
-    // data 
-    WINDOWID win;                   // the window                               
-} DOC_UPDATE_EVENT;
-.ve
-
-    SEE ALSO:
-    ProcessEvent, GetNextUGEvent
-
-D*/
-/****************************************************************************/
diff -ruN ug-orig/dev/ugdevices.h ug-patched/dev/ugdevices.h
--- ug-orig/dev/ugdevices.h	2008-07-18 16:05:09.000000000 +0200
+++ ug-patched/dev/ugdevices.h	2009-04-29 15:11:55.000000000 +0200
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/ugdevices.h,v 1.9 2008/07/18 14:05:09 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -94,7 +94,7 @@
 };
 
 /* buffer space for command line input */
-#define INPUTBUFFERLEN                  65536
+#define INPUTBUFFERLEN                  4096 
 
 /* event types */
 enum EventType {EVENT_ERROR,
@@ -132,11 +132,11 @@
 /*                                                                                                                                                      */
 /****************************************************************************/
 
-/* identification of windows, used to carry a pointer (xif, ppm, ps)
+/** \brief Identification of windows, used to carry a pointer (xif, ppm, ps)
    or INT (rif) */
 typedef void* WINDOWID;
 
-/* type for device coordinates */
+/** \brief Type for device coordinates */
 typedef struct
 {
         short x;
@@ -149,13 +149,38 @@
 typedef INT      (*ActivateOutputPtr) (WINDOWID win);
 typedef INT      (*UpdateOutputPtr)   (WINDOWID win, INT tool);
 
-/* abstract graphical output device */
+/** \brief Data structure to define an interface to output devices
+    
+    The struct 'OUTPUTDEVICE' defines an interface to an output device with
+    graphics capabilites. ug uses a default output device which usually is your
+    computer monitor. Additionally there can be defined several other output devices.
+    
+    Up to now there is implemented an interface to XWindows of UNIX and to the
+    Macintosh OS with the possibilties of window handling and plotting.
+    They serve as default output device.
+    
+    Another output is the 'meta' ouput device. This is a format to write graphics commands
+    to file which later can be view with the 'xugv' tool or that can be translated to PostScript
+    format using the 'm2ps' tool. It is a lean storage format
+    suited quite well for producing and viewing "films" with many pictures of time dependent solutions.
+    It is also a helpful tool for production runs on large problems which often will run
+    in batch mode.
+    
+    In the near future probably also a PostScript output device will exist.
+    
+    The output device struct requires functions for opening, closing, activating and updating
+    a window on the device. Then there is a collection of graphics functions to set color,
+    line width move the cursor, draw lines and higher level functions to plot filled polygons
+    and text.
+    
+    Additionally there is information specified on the color palette used and some standard
+    colors are defined.
+*/
 struct outputdevice {
 
-        /* This is an environment variable */
+    /** \brief This is an environment variable */
         ENVVAR v;
 
-        /* properties */
         long black;                                             /* value for black                                                                              */
         long gray;                          /* value for gray                                       */
         long white;                                             /* value for white                                                                              */
@@ -214,8 +239,8 @@
 
 
 
-/* event structure */
-typedef struct {                                        /* no event                                                             */
+/** \brief No event */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
@@ -224,39 +249,45 @@
         INT Mouse[2];                                   /* current mouse coord (rel. to window)         */
 } NO_UGEVENT;
 
-typedef struct {                                        /* go away event for terminal window            */
+/** \brief Go away event for terminal window            */
+typedef struct {
         INT Type;                                               /* event type                                                           */
 } TERM_GOAWAY_EVENT;
 
-typedef struct {                                        /* cmd key event for terminal window            */
+/** \brief Cmd key event for terminal window            */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
         char CmdKey;                                    /* character from keyboard                                      */
 } TERM_CMDKEY_EVENT;
 
-typedef struct {                                        /* string event for terminal window             */
+/** \brief String event for terminal window             */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
         char String[INPUTBUFFERLEN];    /* string from keyboard                                         */
 } TERM_STRING_EVENT;
 
-typedef struct {                                        /* go away event for view                                       */
+/** \brief Go away event for view                                       */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
         WINDOWID win;                                   /* the window                                                           */
 } DOC_GOAWAY_EVENT;
 
-typedef struct {                                        /* activate event for view                                      */
+/** \brief Activate event for view                                      */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
         WINDOWID win;                                   /* the window                                                           */
 } DOC_ACTIVATE_EVENT;
 
-typedef struct {                                        /* drag event for view                                          */
+/** \brief Drag event for view                                          */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
@@ -265,7 +296,8 @@
         INT Global_UR[2];                               /*                                                                                      */
 } DOC_DRAG_EVENT;
 
-typedef struct {                                        /* grow event for view                                          */
+/** \brief Grow event for view                                          */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
@@ -276,7 +308,8 @@
         INT Local_UR[2];                                /*                                                                                      */
 } DOC_GROW_EVENT;
 
-typedef struct {                                        /* change tool event for view                           */
+/** \brief Change tool event for view                           */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
@@ -285,7 +318,8 @@
         INT MousePosition[2];                   /* mouse position                                                       */
 } DOC_CHANGETOOL_EVENT;
 
-typedef struct {                                        /* content click event for view                         */
+/** \brief Content click event for view                         */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
@@ -293,13 +327,21 @@
         INT MousePosition[2];                   /* mouse position                                                       */
 } DOC_CONTENTCLICK_EVENT;
 
-typedef struct {                                        /* update event for view                                        */
+/** \brief Update event for view                                        */
+typedef struct {
         INT Type;                                               /* event type                                                           */
         
         /* data */
         WINDOWID win;                                   /* the window                                                           */
 } DOC_UPDATE_EVENT;
 
+/** \brief Data structure for the ug event handling
+    
+    The event handling of ug defines several possible event types the interface
+    function 'GetNextUGEvent' can return to 'ProcessEvent'. Depending on the
+    event type data are transferred by the corresponding component in the union.
+    The events are distinguished by the 'Type' component in the 'EVENT'
+*/
 typedef union {
         INT Type;
         NO_UGEVENT                              NoEvent;
@@ -337,7 +379,7 @@
 INT               GetMuteLevel                          (void);
 
 /* multiple output devices */
-OUTPUTDEVICE *CreateOutputDevice                (char *name);
+OUTPUTDEVICE *CreateOutputDevice                (const char *name);
 OUTPUTDEVICE *GetOutputDevice                   (const char *name);
 OUTPUTDEVICE *GetDefaultOutputDevice    (void);
 
@@ -368,7 +410,7 @@
 void              DrawInfoBox                           (WINDOWID win, const char *info);
 INT                       WhichTool                                     (WINDOWID win, const INT mouse[2], INT *tool);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
 
diff -ruN ug-orig/dev/xif/CVS/Entries ug-patched/dev/xif/CVS/Entries
--- ug-orig/dev/xif/CVS/Entries	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/xif/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:11 2004//D2008.11.12.23.00.00
-/Makefile.am/1.2/Wed Jan 19 14:53:16 2005//D2008.11.12.23.00.00
-/Makefile.xif/1.7/Thu Feb 19 19:08:47 1998//D2008.11.12.23.00.00
-/shades.h/1.2/Mon Nov 10 15:39:25 1997//D2008.11.12.23.00.00
-/shell-icon/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool0/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool1/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool2/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool3/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool4/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool5/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/tool6/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/view-icon/1.1.1.1/Fri Sep 15 16:53:33 1995//D2008.11.12.23.00.00
-/xgraph.c/1.39/Tue Feb 26 17:24:35 2008//D2008.11.12.23.00.00
-/xgraph.h/1.8/Mon Aug 30 14:44:02 2004//D2008.11.12.23.00.00
-/xmain.c/1.40/Mon May  8 12:31:52 2006//D2008.11.12.23.00.00
-/xmain.h/1.10/Fri Dec 17 18:21:46 2004//D2008.11.12.23.00.00
-/xshell.c/1.31/Tue Feb 26 17:24:35 2008//D2008.11.12.23.00.00
-/xshell.h/1.6/Fri Jul 18 14:58:48 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dev/xif/CVS/Repository ug-patched/dev/xif/CVS/Repository
--- ug-orig/dev/xif/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/xif/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dev/xif
diff -ruN ug-orig/dev/xif/CVS/Root ug-patched/dev/xif/CVS/Root
--- ug-orig/dev/xif/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/xif/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dev/xif/CVS/Tag ug-patched/dev/xif/CVS/Tag
--- ug-orig/dev/xif/CVS/Tag	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/dev/xif/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dev/xif/.cvsignore ug-patched/dev/xif/.cvsignore
--- ug-orig/dev/xif/.cvsignore	2004-09-08 16:14:11.000000000 +0200
+++ ug-patched/dev/xif/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
diff -ruN ug-orig/dev/xif/Makefile.am ug-patched/dev/xif/Makefile.am
--- ug-orig/dev/xif/Makefile.am	2005-01-19 15:53:16.000000000 +0100
+++ ug-patched/dev/xif/Makefile.am	2005-01-19 15:53:16.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2005/01/19 14:53:16 thimo Exp $
+# $Id: Makefile.am 7937 2005-01-19 14:53:16Z thimo $
 
 # commands.h will gm.h und der braucht Dimension
 AM_CPPFLAGS = $(UG_2DFLAGS) -I$(top_srcdir)/low
diff -ruN ug-orig/dev/xif/shades.h ug-patched/dev/xif/shades.h
--- ug-orig/dev/xif/shades.h	1997-11-10 16:39:25.000000000 +0100
+++ ug-patched/dev/xif/shades.h	1997-11-10 16:39:25.000000000 +0100
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/xif/shades.h,v 1.2 1997/11/10 15:39:25 wieners Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dev/xif/xgraph.c ug-patched/dev/xif/xgraph.c
--- ug-orig/dev/xif/xgraph.c	2008-02-26 18:24:35.000000000 +0100
+++ ug-patched/dev/xif/xgraph.c	2009-04-29 15:11:55.000000000 +0200
@@ -30,6 +30,7 @@
 /****************************************************************************/
 
 /* X11 includes */
+#include "config.h"
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
@@ -41,6 +42,9 @@
 
 /* standard C includes */
 #include <stdio.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <stddef.h>
 #include <string.h>
 
@@ -136,7 +140,7 @@
 static int red_shift, green_shift, blue_shift;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/xif/xgraph.c,v 1.39 2008/02/26 17:24:35 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 unsigned long NS_PREFIX UGBlack (void)
 {
@@ -1326,9 +1330,9 @@
 static int GraphOpen (GraphWindow *gw, char *window_name, int x, int y, int width, int height)
 {
 	unsigned int border_width = DEFAULTBORDER;
-	char *icon_name = GRAPHICONNAME;
-	char *Fontname;
-	char *ug_name = RESOURCENAME;
+    char *icon_name = (char *) GRAPHICONNAME;
+	const char *Fontname;
+	const char *ug_name = RESOURCENAME;
 	unsigned long valuemask = 0;
 	static char dash_list[] = {12,24};
 	XGCValues values;
@@ -1416,7 +1420,7 @@
 	wm_hints.icon_pixmap = gw->icon_pixmap;
 	wm_hints.flags = StateHint | IconPixmapHint | InputHint;
 	class_hints.res_name = prog_name;
-	class_hints.res_class = ug_name;
+	class_hints.res_class = (char*) ug_name;
 	XSetWMProperties(display,gw->win,&gw->window_name,&gw->icon_name,if_argv,if_argc,
 		&size_hints,&wm_hints,&class_hints);
 
diff -ruN ug-orig/dev/xif/xgraph.h ug-patched/dev/xif/xgraph.h
--- ug-orig/dev/xif/xgraph.h	2004-08-30 16:44:02.000000000 +0200
+++ ug-patched/dev/xif/xgraph.h	2009-04-29 14:30:36.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/xif/xgraph.h,v 1.8 2004/08/30 14:44:02 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -117,6 +117,6 @@
 GraphWindow     *WhichGW                        (Window win);
 void                    SetCurrentGW            (GraphWindow *g);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/dev/xif/xmain.c ug-patched/dev/xif/xmain.c
--- ug-orig/dev/xif/xmain.c	2006-05-08 14:31:52.000000000 +0200
+++ ug-patched/dev/xif/xmain.c	2006-05-08 14:31:52.000000000 +0200
@@ -95,7 +95,7 @@
 FILE *o_pipe=NULL;						    /* output from ug               */
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/xif/xmain.c,v 1.40 2006/05/08 12:31:52 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dev/xif/xmain.h ug-patched/dev/xif/xmain.h
--- ug-orig/dev/xif/xmain.h	2004-12-17 19:21:46.000000000 +0100
+++ ug-patched/dev/xif/xmain.h	2009-04-29 14:30:36.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/xif/xmain.h,v 1.10 2004/12/17 18:21:46 klaus Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -115,6 +115,6 @@
 /*                                                                                                                                                      */
 /****************************************************************************/
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/dev/xif/xshell.c ug-patched/dev/xif/xshell.c
--- ug-orig/dev/xif/xshell.c	2008-02-26 18:24:35.000000000 +0100
+++ ug-patched/dev/xif/xshell.c	2009-04-29 15:11:55.000000000 +0200
@@ -49,6 +49,9 @@
 /* standard C includes */
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <string.h>
 #include <ctype.h>
 
@@ -151,7 +154,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dev/xif/xshell.c,v 1.31 2008/02/26 17:24:35 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -222,10 +225,10 @@
 	unsigned int width, height;
 	int x, y, i;
 	unsigned int border_width = DEFAULTBORDER;
-	char *window_name = SHELLWINNAME;
-	char *icon_name = SHELLICONNAME;
+	const char *window_name = SHELLWINNAME;
+	const char *icon_name = SHELLICONNAME;
 	char *Geometry, *Fontname;
-	char *ug_name = RESOURCENAME;
+	const char *ug_name = RESOURCENAME;
 	int flags;
 	unsigned long valuemask = 0;
 	static char dash_list[] = {12,24};
@@ -239,10 +242,10 @@
 	Arg   args[20];
 	XtTranslations NewTranslations;
 	XtActionsRec actions[] = {
-		{"UpAction", UpAction},
-		{"DownAction", DownAction},
-		{"LeftAction", LeftAction},
-		{"RightAction",RightAction},
+		{(char*) "UpAction", UpAction},
+		{(char*) "DownAction", DownAction},
+		{(char*) "LeftAction", LeftAction},
+		{(char*) "RightAction",RightAction},
 		};
 	#endif /* USE_XAW */
 
@@ -313,20 +316,20 @@
 
 	#ifdef USE_XAW
 	n=0;
-	XtSetArg(args[n], XtNx, x); n++;
-	XtSetArg(args[n], XtNy, y); n++;
-	XtSetArg(args[n], XtNwidth, width+sh->font_width); n++;
-	XtSetArg(args[n], XtNheight, height+sh->font_height+sh->font_info->descent); n++;
-	XtSetArg(args[n], XtNborderWidth, border_width); n++;
-	XtSetArg(args[n], XtNscrollVertical, XawtextScrollWhenNeeded); n++;
-	XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollWhenNeeded); n++;
-	XtSetArg(args[n], XtNstring, sh->lineStart[0]); n++;
-	XtSetArg(args[n], XtNlength, MAXLINES*(MAXCOLS+1)); n++;
-	XtSetArg(args[n], XtNpieceSize, MAXLINES*(MAXCOLS+1)); n++;
-	XtSetArg(args[n], XtNeditType, XawtextEdit); n++;
+	XtSetArg(args[n], (char*) XtNx, x); n++;
+	XtSetArg(args[n], (char*) XtNy, y); n++;
+	XtSetArg(args[n], (char*) XtNwidth, width+sh->font_width); n++;
+	XtSetArg(args[n], (char*) XtNheight, height+sh->font_height+sh->font_info->descent); n++;
+	XtSetArg(args[n], (char*) XtNborderWidth, border_width); n++;
+	XtSetArg(args[n], (char*) XtNscrollVertical, XawtextScrollWhenNeeded); n++;
+	XtSetArg(args[n], (char*) XtNscrollHorizontal, XawtextScrollWhenNeeded); n++;
+	XtSetArg(args[n], (char*) XtNstring, sh->lineStart[0]); n++;
+	XtSetArg(args[n], (char*) XtNlength, MAXLINES*(MAXCOLS+1)); n++;
+	XtSetArg(args[n], (char*) XtNpieceSize, MAXLINES*(MAXCOLS+1)); n++;
+	XtSetArg(args[n], (char*) XtNeditType, XawtextEdit); n++;
 	/* TODO: delete this, line wrapping does not work correctly
-	XtSetArg(args[n], XtNwrap,XawtextWrapLine); n++; */
-	XtSetArg(args[n], XtNfont,sh->font_info); n++;
+	XtSetArg(args[n],  XtNwrap,XawtextWrapLine); n++; */
+	XtSetArg(args[n], (char*) XtNfont,sh->font_info); n++;
 	XtSetArg(args[n], XtNbackground,WhitePixel(display,screen_num)); n++;
 	XtSetArg(args[n], XtNforeground,BlackPixel(display,screen_num)); n++;
 
@@ -388,12 +391,12 @@
 	size_hints.flags = USPosition | USSize | PMinSize;
 	size_hints.min_width = DEFAULTMINX;
 	size_hints.min_height = DEFAULTMINY;
-	if (XStringListToTextProperty(&window_name,1,&(sh->window_name))==0)
+	if (XStringListToTextProperty((char**) &window_name,1,&(sh->window_name))==0)
 	{
 		fprintf(stderr,"%s: structure alloc for window_name failed.\n",prog_name);
 		exit(-1);
 	}
-	if (XStringListToTextProperty(&icon_name,1,&(sh->icon_name))==0)
+	if (XStringListToTextProperty((char**) &icon_name,1,&(sh->icon_name))==0)
 	{
 		fprintf(stderr,"%s: structure alloc for icon_name failed.\n",prog_name);
 		exit(-1);
@@ -403,7 +406,7 @@
 	wm_hints.icon_pixmap = sh->icon_pixmap;
 	wm_hints.flags = StateHint | IconPixmapHint | InputHint;
 	class_hints.res_name = prog_name;
-	class_hints.res_class = ug_name;
+	class_hints.res_class = (char*) ug_name;
 	XSetWMProperties(display,sh->win,&sh->window_name,&sh->icon_name,if_argv,if_argc,
 		&size_hints,&wm_hints,&class_hints);
 
diff -ruN ug-orig/dev/xif/xshell.h ug-patched/dev/xif/xshell.h
--- ug-orig/dev/xif/xshell.h	1997-07-18 16:58:48.000000000 +0200
+++ ug-patched/dev/xif/xshell.h	1997-07-18 17:00:14.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dev/xif/xshell.h,v 1.6 1997/07/18 14:58:48 birken Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/doc/CVS/Entries ug-patched/doc/CVS/Entries
--- ug-orig/doc/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-/DataStructure.eps/1.1.1.1/Fri Sep 15 16:53:36 1995//D2008.11.12.23.00.00
-/Doxyfile/1.2/Thu Apr  7 10:22:19 2005//D2008.11.12.23.00.00
-/HOWTO/1.9/Fri Mar 25 18:01:25 2005//D2008.11.12.23.00.00
-/KNOWNBUGS/1.3/Tue Apr 20 13:07:49 2004//D2008.11.12.23.00.00
-/applmanual.tex/1.3/Sun Apr  6 17:34:31 1997//D2008.11.12.23.00.00
-/art10.sty/1.1/Wed Oct 11 16:30:30 1995//D2008.11.12.23.00.00
-/art11.sty/1.1/Wed Oct 11 16:30:18 1995//D2008.11.12.23.00.00
-/art12.sty/1.1/Wed Oct 11 16:27:03 1995//D2008.11.12.23.00.00
-/bndseg2d.eps/1.1.1.1/Fri Sep 15 16:53:37 1995//D2008.11.12.23.00.00
-/bndseg3d.eps/1.1.1.1/Fri Sep 15 16:53:37 1995//D2008.11.12.23.00.00
-/const.tex/1.1.1.1/Fri Sep 15 16:53:37 1995//D2008.11.12.23.00.00
-/cubit2lgmng.txt/1.3/Fri Mar  5 13:07:37 2004//D2008.11.12.23.00.00
-/dart_scripts.txt/1.1/Thu Nov 27 09:30:53 2003//D2008.11.12.23.00.00
-/dart_setup.txt/1.1/Thu Nov 27 09:30:53 2003//D2008.11.12.23.00.00
-/exercise.doc/1.2/Tue Sep 17 13:35:12 2002//D2008.11.12.23.00.00
-/header.h/1.4/Tue Aug 12 09:57:49 1997//D2008.11.12.23.00.00
-/installation.doc/1.7/Tue Sep 17 13:35:12 2002//D2008.11.12.23.00.00
-/makefiles.doc/1.4/Mon Jun 24 08:18:33 1996//D2008.11.12.23.00.00
-/mandesc/1.7/Sun Apr  6 17:34:30 1997//D2008.11.12.23.00.00
-/modules.doc/1.3/Thu Sep  5 09:42:00 1996//D2008.11.12.23.00.00
-/parallel.txt/1.3/Thu Feb 13 10:09:21 1997//D2008.11.12.23.00.00
-/progmanual.tex/1.8/Sun Apr  6 17:34:32 1997//D2008.11.12.23.00.00
-/refman.sty/1.2/Sun Oct 22 19:29:41 1995//D2008.11.12.23.00.00
-/refmanualI.tex/1.1/Sun May 11 10:22:21 1997//D2008.11.12.23.00.00
-/refmanualII.tex/1.1/Sun May 11 10:22:22 1997//D2008.11.12.23.00.00
-/sample.doc/1.3/Fri Jul 12 15:21:05 1996//D2008.11.12.23.00.00
-/source.c/1.5/Thu Jan 16 21:48:41 1997//D2008.11.12.23.00.00
-/titlepag.sty/1.1/Mon Jun 24 10:17:50 1996//D2008.11.12.23.00.00
-/tutorial-3.0.ps.gz/1.1/Wed Mar 10 15:03:26 2004/-kb/D2008.11.12.23.00.00
-/ugart.sty/1.1/Wed Oct 11 16:20:20 1995//D2008.11.12.23.00.00
-/ugdemo.doc/1.2/Tue Sep 17 13:35:12 2002//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/doc/CVS/Entries.Log ug-patched/doc/CVS/Entries.Log
--- ug-orig/doc/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/testing////
diff -ruN ug-orig/doc/CVS/Repository ug-patched/doc/CVS/Repository
--- ug-orig/doc/CVS/Repository	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/doc/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/doc
diff -ruN ug-orig/doc/CVS/Root ug-patched/doc/CVS/Root
--- ug-orig/doc/CVS/Root	2009-04-28 16:21:26.000000000 +0200
+++ ug-patched/doc/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/doc/CVS/Tag ug-patched/doc/CVS/Tag
--- ug-orig/doc/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/doc/Doxyfile ug-patched/doc/Doxyfile
--- ug-orig/doc/Doxyfile	2005-04-07 12:22:19.000000000 +0200
+++ ug-patched/doc/Doxyfile	2009-10-08 16:04:45.000000000 +0200
@@ -1,4 +1,4 @@
-# Doxyfile 1.3.4
+# Doxyfile 1.6.1
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
@@ -14,424 +14,665 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
 # by quotes) that should identify the project.
 
 PROJECT_NAME           = "UG 4.0"
 
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER         = 
+PROJECT_NUMBER         =
 
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
 # where doxygen was started. If left blank the current directory will be used.
 
 OUTPUT_DIRECTORY       = .
 
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
-# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
-# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
-# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
 
-# This tag can be used to specify the encoding used in the generated output. 
-# The encoding is not always determined by the language that is chosen, 
-# but also whether or not the output is meant for Windows or non-Windows users. 
-# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
-# forces the Windows encoding (this is the default for the Windows binary), 
-# whereas setting the tag to NO uses a Unix-style encoding (the default for 
-# all platforms other than Windows).
-
-USE_WINDOWS_ENCODING   = NO
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
 # Set to NO to disable this.
 
 BRIEF_MEMBER_DESC      = YES
 
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
 
 REPEAT_BRIEF           = YES
 
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
 # description.
 
 ALWAYS_DETAILED_SEC    = NO
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
-# members of a class in the documentation of that class as if those members were 
-# ordinary class members. Constructors, destructors and assignment operators of 
-# the base classes will not be shown.
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
 
 INLINE_INHERITED_MEMB  = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
 # to NO the shortest path that makes the file name unique will be used.
 
 FULL_PATH_NAMES        = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. It is allowed to use relative paths in the argument list.
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
 
-STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    =
 
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
 SHORT_NAMES            = NO
 
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like the Qt-style comments (thus requiring an 
-# explict @brief command for a brief description.
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
 
 JAVADOC_AUTOBRIEF      = NO
 
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
 # description. Set this tag to YES if you prefer the old behaviour instead.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member 
-# documentation.
-
-DETAILS_AT_TOP         = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# reimplements.
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
 
 INHERIT_DOCS           = YES
 
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
-# all members of a group must be documented explicitly.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
 
-DISTRIBUTE_GROUP_DOC   = NO
+SEPARATE_MEMBER_PAGES  = NO
 
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
 # Doxygen uses this value to replace tabs by spaces in code fragments.
 
 TAB_SIZE               = 8
 
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
 # You can put \n's in the value part of an alias to insert newlines.
 
-ALIASES                = 
+ALIASES                =
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
-# only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
 OPTIMIZE_OUTPUT_FOR_C  = YES
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
-# only. Doxygen will then generate output that is more tailored for Java. 
-# For instance, namespaces will be presented as packages, qualified scopes 
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
 # the \nosubgrouping command.
 
 SUBGROUPING            = YES
 
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
 
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
 EXTRACT_ALL            = YES
 
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
 # will be included in the documentation.
 
 EXTRACT_PRIVATE        = NO
 
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
 # will be included in the documentation.
 
 EXTRACT_STATIC         = YES
 
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
 # If set to NO only classes defined in header files are included.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
 # This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_MEMBERS     = NO
 
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
 # overviews. This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_CLASSES     = NO
 
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
 # documentation.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
 # function's detailed documentation block.
 
 HIDE_IN_BODY_DOCS      = NO
 
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
 # Set it to YES to include the internal documentation.
 
 INTERNAL_DOCS          = NO
 
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
-# users are advised to set this option to NO.
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
 
 CASE_SENSE_NAMES       = YES
 
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
 # documentation. If set to YES the scope will be hidden.
 
 HIDE_SCOPE_NAMES       = NO
 
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
 # of that file.
 
 SHOW_INCLUDE_FILES     = YES
 
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
 # is inserted in the documentation for inline members.
 
 INLINE_INFO            = YES
 
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
 # declaration order.
 
 SORT_MEMBER_DOCS       = YES
 
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
 # commands in the documentation.
 
 GENERATE_TODOLIST      = YES
 
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
 # commands in the documentation.
 
 GENERATE_TESTLIST      = YES
 
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
 # commands in the documentation.
 
 GENERATE_BUGLIST       = YES
 
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
 # \deprecated commands in the documentation.
 
 GENERATE_DEPRECATEDLIST= YES
 
-# The ENABLED_SECTIONS tag can be used to enable conditional 
+# The ENABLED_SECTIONS tag can be used to enable conditional
 # documentation sections, marked by \if sectionname ... \endif.
 
-ENABLED_SECTIONS       = 
+ENABLED_SECTIONS       =
 
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
 # command in the documentation regardless of this setting.
 
 MAX_INITIALIZER_LINES  = 30
 
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
 # list will mention the files that were used to generate the documentation.
 
 SHOW_USED_FILES        = YES
 
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
-# The QUIET tag can be used to turn on/off the messages that are generated 
+# The QUIET tag can be used to turn on/off the messages that are generated
 # by doxygen. Possible values are YES and NO. If left blank NO is used.
 
 QUIET                  = NO
 
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
 # NO is used.
 
 WARNINGS               = YES
 
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
 # automatically be disabled.
 
 WARN_IF_UNDOCUMENTED   = YES
 
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
 # don't exist or using markup commands wrongly.
 
 WARN_IF_DOC_ERROR      = YES
 
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text.
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
 
 WARN_FORMAT            = "$file:$line: $text"
 
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
 # to stderr.
 
-WARN_LOGFILE           = 
+WARN_LOGFILE           =
 
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
 
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
 INPUT                  = ..
 
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
-
-FILE_PATTERNS          = *.c *.h *.doc
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = *.c \
+                         *.h \
+                         *.doc
 
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
 # If left blank NO is used.
 
 RECURSIVE              = YES
 
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
 EXCLUDE                = ../include
 
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
 
 EXCLUDE_SYMLINKS       = YES
 
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories.
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
 
-EXCLUDE_PATTERNS       = 
+EXCLUDE_SYMBOLS        =
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
 # the \include command).
 
-EXAMPLE_PATH           = 
+EXAMPLE_PATH           =
 
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
 # blank all files are included.
 
-EXAMPLE_PATTERNS       = 
+EXAMPLE_PATTERNS       =
 
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
 # Possible values are YES and NO. If left blank NO is used.
 
 EXAMPLE_RECURSIVE      = NO
 
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
 # the \image command).
 
-IMAGE_PATH             = 
+IMAGE_PATH             =
 
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
 # to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER           =
 
-INPUT_FILTER           = 
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
 
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
 
 FILTER_SOURCE_FILES    = NO
@@ -440,36 +681,54 @@
 # configuration options related to source browsing
 #---------------------------------------------------------------------------
 
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
 # be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
 
 SOURCE_BROWSER         = NO
 
-# Setting the INLINE_SOURCES tag to YES will include the body 
+# Setting the INLINE_SOURCES tag to YES will include the body
 # of functions and classes directly in the documentation.
 
 INLINE_SOURCES         = NO
 
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
 # fragments. Normal C and C++ comments will always remain visible.
 
 STRIP_CODE_COMMENTS    = YES
 
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
 # functions referencing it will be listed.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
 # called/used by that function will be listed.
 
 REFERENCES_RELATION    = YES
 
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
 # which an include is specified. Set to NO to disable this.
 
 VERBATIM_HEADERS       = YES
@@ -478,277 +737,393 @@
 # configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
 # contains a lot of classes, structs, unions or interfaces.
 
 ALPHABETICAL_INDEX     = NO
 
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
 # in which this list will be split (can be a number in the range [1..20])
 
 COLS_IN_ALPHA_INDEX    = 5
 
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
 # should be ignored while generating the index headers.
 
-IGNORE_PREFIX          = 
+IGNORE_PREFIX          =
 
 #---------------------------------------------------------------------------
 # configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
 # generate HTML output.
 
 GENERATE_HTML          = YES
 
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `html' will be used as the default path.
 
 HTML_OUTPUT            = html
 
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
 # doxygen will generate files with .html extension.
 
 HTML_FILE_EXTENSION    = .html
 
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard header.
 
-HTML_HEADER            = 
+HTML_HEADER            =
 
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
-HTML_FOOTER            = 
+HTML_FOOTER            =
 
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
 
-HTML_STYLESHEET        = 
+HTML_STYLESHEET        =
 
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
 # NO a bullet list will be used.
 
 HTML_ALIGN_MEMBERS     = YES
 
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
 # of the generated HTML documentation.
 
 GENERATE_HTMLHELP      = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
-# written to the html output dir.
-
-CHM_FILE               = 
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE               =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
 # the HTML help compiler on the generated index.hhp.
 
-HHC_LOCATION           = 
+HHC_LOCATION           =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
 # it should be included in the master .chm file (NO).
 
 GENERATE_CHI           = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
 # normal table of contents (NO) in the .chm file.
 
 BINARY_TOC             = NO
 
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
 # to the contents of the HTML help documentation and to the tree view.
 
 TOC_EXPAND             = NO
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
 # the value YES disables it.
 
 DISABLE_INDEX          = NO
 
-# This tag can be used to set the number of enum values (range [1..20]) 
+# This tag can be used to set the number of enum values (range [1..20])
 # that doxygen will group on one line in the generated HTML documentation.
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
 
 GENERATE_TREEVIEW      = NO
 
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
 
 TREEVIEW_WIDTH         = 250
 
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
+# there is already a search function so this one should typically
+# be disabled.
+
+SEARCHENGINE           = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
 # generate Latex output.
 
 GENERATE_LATEX         = NO
 
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `latex' will be used as the default path.
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
 # invoked. If left blank `latex' will be used as the default command name.
 
 LATEX_CMD_NAME         = latex
 
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
 # default command name.
 
 MAKEINDEX_CMD_NAME     = makeindex
 
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_LATEX          = NO
 
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
 # executive. If left blank a4wide will be used.
 
 PAPER_TYPE             = a4wide
 
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
 # packages that should be included in the LaTeX output.
 
-EXTRA_PACKAGES         = 
+EXTRA_PACKAGES         =
 
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
 # standard header. Notice: only use this tag if you know what you are doing!
 
-LATEX_HEADER           = 
+LATEX_HEADER           =
 
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
 # This makes the output suitable for online browsing using a pdf viewer.
 
 PDF_HYPERLINKS         = NO
 
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
 # higher quality PDF documentation.
 
 USE_PDFLATEX           = NO
 
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
 # This option is also used when generating formulas in HTML.
 
 LATEX_BATCHMODE        = NO
 
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
 # in the output.
 
 LATEX_HIDE_INDICES     = NO
 
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimised for Word 97 and may not look very pretty with 
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
 # other RTF readers or editors.
 
 GENERATE_RTF           = NO
 
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `rtf' will be used as the default path.
 
 RTF_OUTPUT             = rtf
 
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_RTF            = NO
 
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
 # Note: wordpad (write) and others do not support links.
 
 RTF_HYPERLINKS         = NO
 
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assigments. You only have to provide 
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
 # replacements, missing definitions are set to their default value.
 
-RTF_STYLESHEET_FILE    = 
+RTF_STYLESHEET_FILE    =
 
-# Set optional variables used in the generation of an rtf document. 
+# Set optional variables used in the generation of an rtf document.
 # Syntax is similar to doxygen's config file.
 
-RTF_EXTENSIONS_FILE    = 
+RTF_EXTENSIONS_FILE    =
 
 #---------------------------------------------------------------------------
 # configuration options related to the man page output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
 # generate man pages
 
 GENERATE_MAN           = NO
 
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `man' will be used as the default path.
 
 MAN_OUTPUT             = man
 
-# The MAN_EXTENSION tag determines the extension that is added to 
+# The MAN_EXTENSION tag determines the extension that is added to
 # the generated man pages (default is the subroutine's section .3)
 
 MAN_EXTENSION          = .3
 
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
 # would be unable to find the correct page. The default is NO.
 
 MAN_LINKS              = NO
@@ -757,40 +1132,45 @@
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
 
 GENERATE_XML           = NO
 
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `xml' will be used as the default path.
 
 XML_OUTPUT             = xml
 
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_SCHEMA             = 
+XML_SCHEMA             =
 
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_DTD                = 
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
 
 #---------------------------------------------------------------------------
 # configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
 # and incomplete at the moment.
 
 GENERATE_AUTOGEN_DEF   = NO
@@ -799,280 +1179,338 @@
 # configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
 # moment.
 
 GENERATE_PERLMOD       = NO
 
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
 # to generate PDF and DVI output from the Perl module output.
 
 PERLMOD_LATEX          = NO
 
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
 # and Perl will parse it just the same.
 
 PERLMOD_PRETTY         = YES
 
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
 # Makefile don't overwrite each other's variables.
 
-PERLMOD_MAKEVAR_PREFIX = 
+PERLMOD_MAKEVAR_PREFIX =
 
 #---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
+# Configuration options related to the preprocessor
 #---------------------------------------------------------------------------
 
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
 # files.
 
 ENABLE_PREPROCESSING   = YES
 
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
 MACRO_EXPANSION        = NO
 
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
 
 EXPAND_ONLY_PREDEF     = NO
 
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
 # in the INCLUDE_PATH (see below) will be search if a #include is found.
 
 SEARCH_INCLUDES        = YES
 
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
 # the preprocessor.
 
-INCLUDE_PATH           = 
+INCLUDE_PATH           =
 
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
 # be used.
 
-INCLUDE_FILE_PATTERNS  = 
+INCLUDE_FILE_PATTERNS  =
 
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed.
-
-PREDEFINED             = 
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED             =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
 # Use the PREDEFINED tag if you want to use a different macro definition.
 
-EXPAND_AS_DEFINED      = 
+EXPAND_AS_DEFINED      =
 
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all function-like macros that are alone 
-# on a line, have an all uppercase name, and do not end with a semicolon. Such 
-# function macros are typically used for boiler-plate code, and will confuse the 
-# parser if not removed.
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
 
 SKIP_FUNCTION_MACROS   = YES
 
 #---------------------------------------------------------------------------
-# Configuration::addtions related to external references   
+# Configuration::additions related to external references
 #---------------------------------------------------------------------------
 
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. The format of a tag file without 
-# this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths or 
-# URLs. If a location is present for each tag, the installdox tool 
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
 # does not have to be run to correct the links.
 # Note that each tag file must have a unique name
 # (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen 
+# If a tag file is not located in the directory in which doxygen
 # is run, you must also specify the path to the tagfile here.
 
-TAGFILES               = 
+TAGFILES               =
 
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
 # a tag file that is based on the input files it reads.
 
 GENERATE_TAGFILE       = UG_Kernel.tag
 
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
 # will be listed.
 
 ALLEXTERNALS           = NO
 
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
 # be listed.
 
 EXTERNAL_GROUPS        = YES
 
-# The PERL_PATH should be the absolute path and name of the perl script 
+# The PERL_PATH should be the absolute path and name of the perl script
 # interpreter (i.e. the result of `which perl').
 
 PERL_PATH              = /usr/bin/perl
 
 #---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
+# Configuration options related to the dot tool
 #---------------------------------------------------------------------------
 
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
-# super classes. Setting the tag to NO turns the diagrams off. Note that this 
-# option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
-# recommended to install and use dot, since it yields more powerful graphs.
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
 
 CLASS_DIAGRAMS         = YES
 
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
 # or is not a class.
 
 HIDE_UNDOC_RELATIONS   = YES
 
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
 # have no effect if this option is set to NO (the default)
 
 HAVE_DOT               = NO
 
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
 # the CLASS_DIAGRAMS tag to NO.
 
 CLASS_GRAPH            = YES
 
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
 # class references variables) of the class with other documented classes.
 
 COLLABORATION_GRAPH    = YES
 
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similiar to the OMG's Unified Modeling 
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
 # Language.
 
 UML_LOOK               = NO
 
-# If set to YES, the inheritance and collaboration graphs will show the 
+# If set to YES, the inheritance and collaboration graphs will show the
 # relations between templates and their instances.
 
 TEMPLATE_RELATIONS     = NO
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
 # other documented files.
 
 INCLUDE_GRAPH          = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
 # indirectly include this file.
 
 INCLUDED_BY_GRAPH      = YES
 
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
-# generate a call dependency graph for every global function or class method. 
-# Note that enabling this option will significantly increase the time of a run. 
-# So in most cases it will be better to enable call graphs for selected 
-# functions only using the \callgraph command.
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
 
 CALL_GRAPH             = NO
 
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
 # will graphical hierarchy of all classes instead of a textual one.
 
 GRAPHICAL_HIERARCHY    = YES
 
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
 # generated by dot. Possible values are png, jpg, or gif
 # If left blank png will be used.
 
 DOT_IMAGE_FORMAT       = png
 
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
-# found. If left blank, it is assumed the dot tool can be found on the path.
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
 
-DOT_PATH               = 
+DOT_PATH               =
 
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
 # \dotfile command).
 
-DOTFILE_DIRS           = 
+DOTFILE_DIRS           =
 
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
-# this value, doxygen will try to truncate the graph, so that it fits within 
-# the specified constraint. Beware that most browsers cannot cope with very 
-# large images.
-
-MAX_DOT_GRAPH_WIDTH    = 1024
-
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
-# this value, doxygen will try to truncate the graph, so that it fits within 
-# the specified constraint. Beware that most browsers cannot cope with very 
-# large images.
-
-MAX_DOT_GRAPH_HEIGHT   = 1024
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes that 
-# lay further from the root node will be omitted. Note that setting this option to 
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
-# note that a graph may be further truncated if the graph's image dimensions are 
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
 
 MAX_DOT_GRAPH_DEPTH    = 0
 
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
 # arrows in the dot generated graphs.
 
 GENERATE_LEGEND        = YES
 
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
 # the various graphs.
 
 DOT_CLEANUP            = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE           = NO
diff -ruN ug-orig/doc/header.h ug-patched/doc/header.h
--- ug-orig/doc/header.h	1997-08-12 11:57:49.000000000 +0200
+++ ug-patched/doc/header.h	1997-08-12 11:57:49.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/doc/header.h,v 1.4 1997/08/12 09:57:49 df Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/doc/source.c ug-patched/doc/source.c
--- ug-orig/doc/source.c	1997-01-16 22:48:41.000000000 +0100
+++ ug-patched/doc/source.c	2008-12-19 11:18:36.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "general.h"
 
 /****************************************************************************/
@@ -63,7 +64,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/doc/source.c,v 1.5 1997/01/16 21:48:41 henrik Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/doc/testing/CVS/Entries ug-patched/doc/testing/CVS/Entries
--- ug-orig/doc/testing/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/testing/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-/Dart-UG.fig/1.3/Tue May 25 09:51:34 2004//D2008.11.12.23.00.00
-/DartCycleTimeline.fig/1.1/Tue May  4 08:32:10 2004//D2008.11.12.23.00.00
-/README/1.1/Tue May 25 09:53:12 2004//D2008.11.12.23.00.00
-/README_ADVANCED.txt/1.2/Tue May 25 09:51:08 2004//D2008.11.12.23.00.00
-/README_SCRIPTS.txt/1.4/Tue May 25 09:51:08 2004//D2008.11.12.23.00.00
-/README_SETUP.txt/1.3/Tue May 25 09:51:08 2004//D2008.11.12.23.00.00
-/README_TESTS.txt/1.2/Tue May 25 09:51:08 2004//D2008.11.12.23.00.00
-/TODO/1.10/Thu Sep 16 09:08:58 2004//D2008.11.12.23.00.00
-/valgrind.txt/1.1/Tue May 25 09:53:12 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/doc/testing/CVS/Repository ug-patched/doc/testing/CVS/Repository
--- ug-orig/doc/testing/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/testing/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/doc/testing
diff -ruN ug-orig/doc/testing/CVS/Root ug-patched/doc/testing/CVS/Root
--- ug-orig/doc/testing/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/testing/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/doc/testing/CVS/Tag ug-patched/doc/testing/CVS/Tag
--- ug-orig/doc/testing/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/doc/testing/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/CVS/Entries ug-patched/dom/CVS/Entries
--- ug-orig/dom/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:15 2004//D2008.11.12.23.00.00
-/Makefile.am/1.2/Wed Oct  6 12:18:01 2004//D2008.11.12.23.00.00
-/Makefile.dom/1.13/Thu Oct  9 11:04:36 2003//D2008.11.12.23.00.00
-/domain.h/1.48/Fri Jun  2 16:12:21 2006//D2008.11.12.23.00.00
-/switch.h/1.3/Mon Feb  6 08:56:44 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/CVS/Entries.Log ug-patched/dom/CVS/Entries.Log
--- ug-orig/dom/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-A D/gen////
-A D/lgm////
-A D/std////
diff -ruN ug-orig/dom/CVS/Repository ug-patched/dom/CVS/Repository
--- ug-orig/dom/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom
diff -ruN ug-orig/dom/CVS/Root ug-patched/dom/CVS/Root
--- ug-orig/dom/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/CVS/Tag ug-patched/dom/CVS/Tag
--- ug-orig/dom/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/.cvsignore ug-patched/dom/.cvsignore
--- ug-orig/dom/.cvsignore	2004-09-08 16:14:15.000000000 +0200
+++ ug-patched/dom/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/dom/domain.h ug-patched/dom/domain.h
--- ug-orig/dom/domain.h	2006-06-02 18:12:21.000000000 +0200
+++ ug-patched/dom/domain.h	2009-04-29 15:11:55.000000000 +0200
@@ -32,7 +32,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/domain.h,v 1.48 2006/06/02 16:12:21 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -318,7 +318,7 @@
  * </ul>
 */
 /****************************************************************************/
-INT BVP_Save (BVP *theBVP, char *name, char *mgname, NS_PREFIX HEAP *theHeap, INT argc, char **argv);
+INT BVP_Save (BVP *theBVP, const char *name, const char *mgname, NS_PREFIX HEAP *theHeap, INT argc, char **argv);
 
 /****************************************************************************/
 /** \brief Load a BVP
@@ -334,7 +334,7 @@
  * </ul>
 */
 /****************************************************************************/
-BVP        *BVP_Load              (char *name, INT argc, char **argv);
+BVP        *BVP_Load              (const char *name, INT argc, char **argv);
 
 /****************************************************************************/
 /** \brief Get pointer to BVP by name
@@ -368,7 +368,7 @@
  * </ul>   
  */
 /****************************************************************************/
-BVP *BVP_Init (char *filename, NS_PREFIX HEAP *theHeap, MESH *Mesh, INT MarkKey);
+BVP *BVP_Init (const char *filename, NS_PREFIX HEAP *theHeap, MESH *Mesh, INT MarkKey);
 
 /****************************************************************************/
 /** \brief Dispose a BVP
diff -ruN ug-orig/dom/gen/CVS/Entries ug-patched/dom/gen/CVS/Entries
--- ug-orig/dom/gen/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/gen/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:12 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:07 2004//D2008.11.12.23.00.00
-/Makefile.gen/1.1.1.1/Tue Dec 14 13:53:50 1999//D2008.11.12.23.00.00
-/gen.c/1.10/Sun Feb 27 23:58:19 2000//D2008.11.12.23.00.00
-/gen.h/1.6/Thu Feb 10 11:48:52 2000//D2008.11.12.23.00.00
-/gen_parallel.c/1.4/Wed Jul  6 09:49:04 2005//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/gen/CVS/Repository ug-patched/dom/gen/CVS/Repository
--- ug-orig/dom/gen/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/gen/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/gen
diff -ruN ug-orig/dom/gen/CVS/Root ug-patched/dom/gen/CVS/Root
--- ug-orig/dom/gen/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/gen/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/gen/CVS/Tag ug-patched/dom/gen/CVS/Tag
--- ug-orig/dom/gen/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/gen/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/gen/.cvsignore ug-patched/dom/gen/.cvsignore
--- ug-orig/dom/gen/.cvsignore	2004-09-08 16:14:12.000000000 +0200
+++ ug-patched/dom/gen/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/dom/gen/gen.c ug-patched/dom/gen/gen.c
--- ug-orig/dom/gen/gen.c	2000-02-28 00:58:19.000000000 +0100
+++ ug-patched/dom/gen/gen.c	2008-12-19 11:15:14.000000000 +0100
@@ -26,6 +26,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -90,7 +91,7 @@
 static BndGeomProcPtr Geom;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/gen/gen.c,v 1.10 2000/02/27 23:58:19 wieners Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dom/gen/gen.h ug-patched/dom/gen/gen.h
--- ug-orig/dom/gen/gen.h	2000-02-10 12:48:52.000000000 +0100
+++ ug-patched/dom/gen/gen.h	2000-02-10 12:48:54.000000000 +0100
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/gen/gen.h,v 1.6 2000/02/10 11:48:52 wieners Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dom/gen/gen_parallel.c ug-patched/dom/gen/gen_parallel.c
--- ug-orig/dom/gen/gen_parallel.c	2005-07-06 11:49:04.000000000 +0200
+++ ug-patched/dom/gen/gen_parallel.c	2008-12-19 11:15:14.000000000 +0100
@@ -28,6 +28,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -83,7 +84,7 @@
 static INT BVP_type = BVP_GENERAL;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/gen/gen_parallel.c,v 1.4 2005/07/06 09:49:04 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/dom/gen/Makefile.am ug-patched/dom/gen/Makefile.am
--- ug-orig/dom/gen/Makefile.am	2004-09-02 14:22:07.000000000 +0200
+++ ug-patched/dom/gen/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:07 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 SOURCES = gen.c gen_parallel.c gen.h
 
diff -ruN ug-orig/dom/lgm/ansys2lgm.c ug-patched/dom/lgm/ansys2lgm.c
--- ug-orig/dom/lgm/ansys2lgm.c	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/ansys2lgm.c	2009-04-29 15:11:55.000000000 +0200
@@ -26,6 +26,7 @@
 /****************************************************************************/
 
 
+#include "config.h"
 #include <assert.h>
 
 #include "defaults.h"
@@ -211,7 +212,7 @@
 /* ... DIRKS NEU */
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/ansys2lgm.c,v 1.36 2006/11/08 15:35:43 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 
@@ -1231,7 +1232,7 @@
 	return(1);
 }
 /*An der Stelle 0 des KomponentenNamenArray den NotSet-String eintragen :*/
-KomponentenNamenArray = "< NOT SET IN ANSYS-FILE >";
+strcpy(KomponentenNamenArray, "< NOT SET IN ANSYS-FILE >");
 
 
 
diff -ruN ug-orig/dom/lgm/ansys2lgm.h ug-patched/dom/lgm/ansys2lgm.h
--- ug-orig/dom/lgm/ansys2lgm.h	2006-05-08 14:18:23.000000000 +0200
+++ ug-patched/dom/lgm/ansys2lgm.h	2006-05-08 14:31:31.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/ansys2lgm.h,v 1.13 2006/05/08 12:18:23 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dom/lgm/CVS/Entries ug-patched/dom/lgm/CVS/Entries
--- ug-orig/dom/lgm/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:14 2004//D2008.11.12.23.00.00
-/Makefile.am/1.2/Thu Sep  9 17:50:24 2004//D2008.11.12.23.00.00
-/Makefile.lgm/1.10/Mon Jul 26 15:32:33 2004//D2008.11.12.23.00.00
-/ansys2lgm.c/1.36/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/ansys2lgm.h/1.13/Mon May  8 12:18:23 2006//D2008.11.12.23.00.00
-/lgm_accel.c/1.4/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/lgm_accel.h/1.4/Mon May  8 12:18:23 2006//D2008.11.12.23.00.00
-/lgm_domain.c/1.39/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/lgm_domain.h/1.39/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/lgm_domain2d.c/1.26/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/lgm_domain3d.c/1.82/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/lgm_load.c/1.50/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/lgm_load.h/1.14/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/lgm_macros.h/1.1/Mon Aug  4 11:59:09 1997//D2008.11.12.23.00.00
-/lgm_parallel.c/1.11/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/lgm_transfer.h/1.22/Wed Nov  8 15:35:43 2006//D2008.11.12.23.00.00
-/lgm_transfer2d.c/1.17/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/lgm_transfer3d.c/1.26/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/lgm/CVS/Entries.Log ug-patched/dom/lgm/CVS/Entries.Log
--- ug-orig/dom/lgm/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-A D/netgen////
-A D/ngin////
-A D/ngin2d////
diff -ruN ug-orig/dom/lgm/CVS/Repository ug-patched/dom/lgm/CVS/Repository
--- ug-orig/dom/lgm/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/lgm
diff -ruN ug-orig/dom/lgm/CVS/Root ug-patched/dom/lgm/CVS/Root
--- ug-orig/dom/lgm/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/lgm/CVS/Tag ug-patched/dom/lgm/CVS/Tag
--- ug-orig/dom/lgm/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/lgm/.cvsignore ug-patched/dom/lgm/.cvsignore
--- ug-orig/dom/lgm/.cvsignore	2004-09-08 16:14:14.000000000 +0200
+++ ug-patched/dom/lgm/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/dom/lgm/lgm_accel.c ug-patched/dom/lgm/lgm_accel.c
--- ug-orig/dom/lgm/lgm_accel.c	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/lgm_accel.c	2008-12-19 11:15:14.000000000 +0100
@@ -13,6 +13,7 @@
  *            system include files                                           *
  *            application include files                                      *
  *****************************************************************************/
+#include "config.h"
 #include <assert.h>
 #include "compiler.h"   /* for INT etc.                              */
 #include "debug.h"      /* for IFDEBUG() and  MIN(), MAX() by misc.h */
diff -ruN ug-orig/dom/lgm/lgm_domain2d.c ug-patched/dom/lgm/lgm_domain2d.c
--- ug-orig/dom/lgm/lgm_domain2d.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_domain2d.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -87,7 +88,7 @@
 /****************************************************************************/
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_domain2d.c,v 1.26 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -1194,7 +1195,7 @@
 }
 
 /* domain interface function: for description see domain.h */
-INT NS_DIM_PREFIX BVP_Save (BVP *theBVP, char *name, char *mgname, HEAP *theHeap, INT argc, char **argv)
+INT NS_DIM_PREFIX BVP_Save (BVP *theBVP, const char *name, const char *mgname, HEAP *theHeap, INT argc, char **argv)
 {
 	LGM_DOMAIN *lgm_domain;
 	LGM_LINE *theLine, **LinePtrList;
diff -ruN ug-orig/dom/lgm/lgm_domain3d.c ug-patched/dom/lgm/lgm_domain3d.c
--- ug-orig/dom/lgm/lgm_domain3d.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_domain3d.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,8 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
+
 #undef OCC_GEOMETRY
 #ifdef OCC_GEOMETRY
 #include "occ/occ_geom.hh"
@@ -127,7 +129,7 @@
 extern int AddGeomElement (int node0, int node1, int node2, int neigbor0, int neigbor1, int neigbor2);
 
 /* data for CVS */
-/*static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_domain3d.c,v 1.82 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+/*static char RCS_ID("$Header$",UG_RCS_STRING);
 */
 static INT currSubdom, currSurface, currLine;
 
@@ -687,7 +689,7 @@
 }
 
 /* domain interface function: for description see domain.h */
-INT NS_DIM_PREFIX BVP_Save (BVP *theBVP, char *name, char *mgname, HEAP *theHeap, INT argc, char **argv)
+INT NS_DIM_PREFIX BVP_Save (BVP *theBVP, const char *name, const char *mgname, HEAP *theHeap, INT argc, char **argv)
 {
 	UserWrite("SORRY: not implemented yet\n");
 	return (1);
@@ -1431,20 +1433,24 @@
 	n1[1] = p2[1] - p0[1];
 	n1[2] = p2[2] - p0[2];
 
-	l1 = Lenght(n1);
-	Scale(n1, 1.0/l1);
+        V3_EUKLIDNORM(n1,l1);
+/* 	Scale(n1, 1.0/l1); */
+        V3_SCALE(1.0/l1,n1);
 
 	n2[0] = p2[0] - p1[0];
 	n2[1] = p2[1] - p1[1];
 	n2[2] = p2[2] - p1[2];
 
-	l2 = Lenght(n2);
-	Scale(n2, 1.0/l2);
+        V3_EUKLIDNORM(n2,l2);
+/* 	Scale(n2, 1.0/l2); */
+        V3_SCALE(1.0/l2, n2);
+
+/* 	Cross(n, n1, n2); */
+        V3_VECTOR_PRODUCT(n1,n2,n);
+        V3_EUKLIDNORM(n,l);
+/* 	Scale(n, 1.0/l); */
+        V3_SCALE(1.0/l, n);
 
-	Cross(n, n1, n2);
-	l = Lenght(n);
-	Scale(n, 1.0/l);
-	
 	return(0);
 }
 
@@ -1466,7 +1472,8 @@
 	/* get Normalvector to the Triangle j */
 	Normal_Vector(p0, p1, p2, &n2[0]);
 
-	scalarproduct =  Mult(n1, n2);
+/* 	scalarproduct =  Mult(n1, n2); */
+        V3_SCALAR_PRODUCT(n1, n2, scalarproduct);
 	return(scalarproduct);
 }
 
@@ -1636,7 +1643,7 @@
 }
 
 
-static INT Write_Surface(LGM_SURFACE *theSurface, char *name, char *name1)
+static INT Write_Surface(LGM_SURFACE *theSurface, const char *name, const char *name1)
 {
 	INT i, id;
 	FILE *stream;
@@ -1712,7 +1719,8 @@
 	/* get Normalvector to the Triangle i */
 	Normal_Vector(p0, p1, p2, &n1[0]);
 
-	scalarproduct =  Mult(n1, n);
+/* 	scalarproduct =  Mult(n1, n); */
+        V3_SCALAR_PRODUCT(n1, n, scalarproduct);
 	return(scalarproduct);
 }
 
@@ -3040,15 +3048,15 @@
 		
 	/* compute 2 vectors in the plane + normalvector */	
 	Minus(n0,e2,e0);
-	l = Lenght(n0);
+        V3_EUKLIDNORM(n0,l);
 	Scale(n0,1.0/l);
 
 	Minus(n1,e2,e1);
-	l = Lenght(n1);
+        V3_EUKLIDNORM(n1,l);
 	Scale(n1,1.0/l);
 
 	Cross(n2,n0,n1);
-	l = Lenght(n2);
+        V3_EUKLIDNORM(n2,l);
 	Scale(n2,1.0/l);
 
 	p[0] = global[0];
@@ -3125,7 +3133,8 @@
 	lam[1] = bb[1];
 	lam[2] = 1 - bb[0] - bb[1];
 
-	return(Lenght(hp));
+        V3_EUKLIDNORM(hp,l);
+        return l;
 }	
 
 static INT NormalVector(LGM_TRIANGLE *theSurfaceTriangle, DOUBLE *n)
@@ -5734,7 +5743,7 @@
 	B[0] = globalp2[0] - globalp1[0];
 	B[1] = globalp2[1] - globalp1[1];
 	B[2] = globalp2[2] - globalp1[2];
-	LGM_VECTOR_PRODUCT(A, B, BNDP_NV);
+	V3_VECTOR_PRODUCT(A, B, BNDP_NV);
 // This is wrong. OS_CHANGED
 //	V_DIM_SCALE(1.0/sqrt(V_DIM_SCAL_PROD(BNDP_NV, BNDP_NV)),BNDP_NV);
 
@@ -5966,9 +5975,9 @@
 	B[2] = LGM_POINT_POS(LGM_TRIANGLE_CORNER(LGM_SURFACE_TRIANGLE(theSurface,ilocal),2))[2]
 			- LGM_POINT_POS(LGM_TRIANGLE_CORNER(LGM_SURFACE_TRIANGLE(theSurface,ilocal),1))[2];
 		
-	LGM_VECTOR_PRODUCT(A, B, Surface_NV);
+	V3_VECTOR_PRODUCT(A, B, Surface_NV);
 
-	LGM_SCALAR_PRODUCT(BNDP_NV, Surface_NV, sp);
+	V3_SCALAR_PRODUCT(BNDP_NV, Surface_NV, sp);
 
 
 	if(sp>0.0)
diff -ruN ug-orig/dom/lgm/lgm_domain.c ug-patched/dom/lgm/lgm_domain.c
--- ug-orig/dom/lgm/lgm_domain.c	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/lgm_domain.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -57,7 +58,7 @@
 static INT theProblemVarID;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_domain.c,v 1.39 2006/11/08 15:35:43 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 /****************************************************************************/
@@ -87,7 +88,7 @@
 D*/
 /****************************************************************************/
 
-LGM_PROBLEM* NS_DIM_PREFIX CreateProblem (char *name, InitProcPtr init, DomainSizeConfig domconfig, BndCondProcPtr BndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[])
+LGM_PROBLEM* NS_DIM_PREFIX CreateProblem (const char *name, InitProcPtr init, DomainSizeConfig domconfig, BndCondProcPtr BndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[])
 {
 	LGM_PROBLEM *newProblem;
 	int i;
@@ -114,7 +115,7 @@
 	return (newProblem);
 }
 
-LGM_PROBLEM* NS_DIM_PREFIX CreateProblemWithInnerBCs (char *name, InitProcPtr init, DomainSizeConfig domconfig, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[])
+LGM_PROBLEM* NS_DIM_PREFIX CreateProblemWithInnerBCs (const char *name, InitProcPtr init, DomainSizeConfig domconfig, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[])
 {
 	LGM_PROBLEM *newProblem;
 	int i;
@@ -161,11 +162,17 @@
 */
 /****************************************************************************/
 
-static LGM_PROBLEM *Lgm_Problem_GetByName (char *name)
+static LGM_PROBLEM *Lgm_Problem_GetByName (const char *name)
 {
 	return((LGM_PROBLEM *) SearchEnv(name,"/LGM_PROBLEM",theProblemVarID,theProblemDirID));
 }
 
+void NS_DIM_PREFIX
+Set_Current_BVP(BVP* theBVP)
+{
+  return;
+}
+
 /* domain interface function: for description see domain.h */
 BVP *NS_DIM_PREFIX
 BVP_GetByName (const char *name)
@@ -194,7 +201,7 @@
 }
 
 /* domain interface function: for description see domain.h */
-BVP* NS_DIM_PREFIX BVP_Init (char *name, HEAP *Heap, MESH *Mesh, INT MarkKey)
+BVP* NS_DIM_PREFIX BVP_Init (const char *name, HEAP *Heap, MESH *Mesh, INT MarkKey)
 {
 	LGM_DOMAIN *theDomain;
 	LGM_PROBLEM *theProblem;
@@ -307,7 +314,7 @@
 }
 
 /* domain interface function: for description see domain.h */
-BVP* NS_DIM_PREFIX BVP_Load (char *name, INT argc, char **argv)
+BVP* NS_DIM_PREFIX BVP_Load (const char *name, INT argc, char **argv)
 {
 	return (NULL);
 }
diff -ruN ug-orig/dom/lgm/lgm_domain.h ug-patched/dom/lgm/lgm_domain.h
--- ug-orig/dom/lgm/lgm_domain.h	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/lgm_domain.h	2009-04-29 15:11:55.000000000 +0200
@@ -26,7 +26,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_domain.h,v 1.39 2006/11/08 15:35:43 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -741,8 +741,8 @@
 #endif
 
 #ifndef Grape
-LGM_PROBLEM *CreateProblem (char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
-LGM_PROBLEM *CreateProblemWithInnerBCs (char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
+LGM_PROBLEM *CreateProblem (const char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
+LGM_PROBLEM *CreateProblemWithInnerBCs (const char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
 #endif
 INT SetBoundaryCondition (LGM_DOMAIN *theDomain, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond);
 INT SetDomainSize (LGM_DOMAIN *theDomain);
diff -ruN ug-orig/dom/lgm/lgm_load.c ug-patched/dom/lgm/lgm_load.c
--- ug-orig/dom/lgm/lgm_load.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_load.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -86,12 +87,12 @@
 /*																			*/
 /****************************************************************************/
 
-typedef int (*ReadDomainProc)		(HEAP *theHeap, char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey);
+typedef int (*ReadDomainProc)		(HEAP *theHeap, const char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey);
 typedef int (*ReadSizesProc)		(LGM_SIZES *lgm_sizes);
 typedef int (*ReadSubDomainProc)	(int i, LGM_SUBDOMAIN_INFO *subdom_info);
 typedef int (*ReadLinesProc)		(int i, LGM_LINE_INFO *line_info);
 typedef int (*ReadPointsProc)		(LGM_POINT_INFO *lgm_point_info);
-typedef int (*ReadMeshProc)	        (char *name, HEAP *theHeap, LGM_MESH_INFO *lgm_mesh_info, INT MarkKey);
+typedef int (*ReadMeshProc)	        (const char *name, HEAP *theHeap, LGM_MESH_INFO *lgm_mesh_info, INT MarkKey);
 
 #if (LGM_DIM==3)
 typedef int (*ReadSurfaceProc) 		(int i, LGM_SURFACE_INFO *surface_info);
@@ -133,7 +134,7 @@
 #endif
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_load.c,v 1.50 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -166,7 +167,7 @@
 
 #if (LGM_DIM==2)
 
-LGM_DOMAIN* NS_DIM_PREFIX LGM_LoadDomain (char *filename, char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey)
+LGM_DOMAIN* NS_DIM_PREFIX LGM_LoadDomain (const char *filename, const char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey)
 {
 	LGM_DOMAIN *theDomain;
 	LGM_DOMAIN_INFO theDomInfo;
@@ -177,7 +178,7 @@
 	LGM_LINE **LinePtrList;
 	LGM_POINT_INFO *piptr;
 	LGM_LINE_INFO theLineInfo;
-	char *p;
+	const char *p;
 
 	/* set transfer functions */
 	p = filename + strlen(filename) - 4;
@@ -312,7 +313,7 @@
 	return (theDomain);
 }
 
-INT NS_DIM_PREFIX LGM_LoadMesh (char *name, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey)
+INT NS_DIM_PREFIX LGM_LoadMesh (const char *name, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey)
 {
 	INT i,j,size;
 	LGM_MESH_INFO lgm_mesh_info;
@@ -323,7 +324,7 @@
 	if (ReadMesh==NULL) return (1);
 
 	/* do the right thing */
-   	if ((*ReadMesh)(name,theHeap,&lgm_mesh_info,MarkKey)) return (1);
+   	if ((*ReadMesh)((char*) name,theHeap,&lgm_mesh_info,MarkKey)) return (1);
 
     /* copy mesh_info to mesh and create BNDPs */
 	theMesh->mesh_status              = MESHSTAT_MESH;
@@ -639,7 +640,7 @@
 
 
 
-LGM_DOMAIN* NS_DIM_PREFIX LGM_LoadDomain (char *filename, char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey)
+LGM_DOMAIN* NS_DIM_PREFIX LGM_LoadDomain (const char *filename, const char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey)
 {
 	LGM_DOMAIN *theDomain;
 	LGM_DOMAIN_INFO theDomInfo;
@@ -653,7 +654,7 @@
 	LGM_LINE **LinePtrList;
 	LGM_SURFACE **SurfacePtrList;
 	LGM_LINE_INFO theLineInfo;	
-	char *p;
+	const char *p;
 
 #ifdef OCC_GEOMETRY
 	occ_geom.Import_Geometry("geometry.iges");
@@ -1044,7 +1045,7 @@
 	return (theDomain);
 }
 
-INT NS_DIM_PREFIX LGM_LoadMesh (char *name, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey)
+INT NS_DIM_PREFIX LGM_LoadMesh (const char *name, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey)
 {
 	LGM_MESH_INFO lgm_mesh_info;
     INT i;
diff -ruN ug-orig/dom/lgm/lgm_load.h ug-patched/dom/lgm/lgm_load.h
--- ug-orig/dom/lgm/lgm_load.h	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/lgm_load.h	2009-04-29 15:11:55.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_load.h,v 1.14 2006/11/08 15:35:43 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -76,8 +76,8 @@
 /*																			*/
 /****************************************************************************/
 
-LGM_DOMAIN *LGM_LoadDomain	(char *filename, char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey);
-INT			LGM_LoadMesh	(char *filename, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey);
+LGM_DOMAIN *LGM_LoadDomain	(const char *filename, const char *name, HEAP *theHeap, INT DomainVarID, INT MarkKey);
+INT			LGM_LoadMesh	(const char *filename, HEAP *theHeap, MESH *theMesh, LGM_DOMAIN *theDomain, INT MarkKey);
 INT			InitLGMLoad		(void);
 
 
diff -ruN ug-orig/dom/lgm/lgm_parallel.c ug-patched/dom/lgm/lgm_parallel.c
--- ug-orig/dom/lgm/lgm_parallel.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_parallel.c	2009-01-05 14:05:16.000000000 +0100
@@ -28,6 +28,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -51,7 +52,14 @@
 
 #include "namespace.h"
 
-USING_UG_NAMESPACES
+//USING_UG_NAMESPACES
+USING_UGDIM_NAMESPACE
+USING_UG_NAMESPACE
+
+#ifdef ModelP
+USING_PPIF_NAMESPACE
+#endif
+
 
 
 /****************************************************************************/
@@ -122,7 +130,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_parallel.c,v 1.11 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 /****************************************************************************/
@@ -234,7 +242,7 @@
 				LGM_OBJECT_ID_2_OBJECT((INT) LGM_BNDS_OBJECT((LGM_BNDS *)data))));
 
 			LGM_BNDS_OBJECT(bs) = 
-				LGM_OBJECT_ID_2_OBJECT((INT) LGM_BNDS_OBJECT((LGM_BNDS *)data));
+				LGM_OBJECT_ID_2_OBJECT((long int) LGM_BNDS_OBJECT((LGM_BNDS *)data));
 		}
 		else
 			PRINTDEBUG(dom,2,(PFMT "BElementScatterBndS(): ignoring i=%d "
@@ -409,8 +417,7 @@
 				 &((*bndp)->Surf[(i)].s.theSurf)));
 
 			LGM_BNDP_LINE(*bndp,i) = 
-				LGM_LINE_ID_2_LINE((INT) 
-							   LGM_BNDP_LINE_GLINE(((LGM_BNDP_PLINE *)data)[i]));
+				LGM_LINE_ID_2_LINE((long int) LGM_BNDP_LINE_GLINE(((LGM_BNDP_PLINE *)data)[i]));
 
 			PRINTDEBUG(dom,3,(PFMT "BVertexScatterBndP(): outside buffer: "
 				"line=%x local_left=%11.4E local_right=%11.4E\n",me,
@@ -438,8 +445,7 @@
 				 me,bndp,*bndp));
 
 			LGM_BNDP_OBJECT(*bndp,i) = 
-				LGM_OBJECT_ID_2_OBJECT((INT) 
-							   LGM_BNDP_OBJECT_GOBJECT(((LGM_BNDP_POBJECT *)data)[0]));
+				LGM_OBJECT_ID_2_OBJECT((long int)LGM_BNDP_OBJECT_GOBJECT(((LGM_BNDP_POBJECT *)data)[0]));
 
 			PRINTDEBUG(dom,3,(PFMT "BVertexScatterBndP(): outside buffer: "
 				"line=%x local=%11.4E\n",me,
diff -ruN ug-orig/dom/lgm/lgm_transfer2d.c ug-patched/dom/lgm/lgm_transfer2d.c
--- ug-orig/dom/lgm/lgm_transfer2d.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_transfer2d.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -72,7 +73,7 @@
 /****************************************************************************/
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_transfer2d.c,v 1.17 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 static FILE *stream;
 static INT lgmdomainpathes_set;
@@ -107,7 +108,7 @@
 	return (0);
 }
 
-static int ReadCommentLine (char *comment)
+static int ReadCommentLine (const char *comment)
 {
 	char buffer[256];
 
@@ -145,7 +146,7 @@
 static fpos_t filepos,filepos2,UnitInfoFilepos;
 static HEAP *theHeap;
 
-int NS_DIM_PREFIX LGM_ReadDomain (HEAP *Heap, char *filename, LGM_DOMAIN_INFO *domain_info, INT dummy)
+int NS_DIM_PREFIX LGM_ReadDomain (HEAP *Heap, const char *filename, LGM_DOMAIN_INFO *domain_info, INT dummy)
 {
 	int i;
 	char buffer[256];
@@ -517,7 +518,7 @@
 D*/
 /****************************************************************************/
 
-FILE * NS_DIM_PREFIX LGM_WriteOpenFile (char* name)
+FILE * NS_DIM_PREFIX LGM_WriteOpenFile (const char* name)
 {
 	FILE *stream;
 	
diff -ruN ug-orig/dom/lgm/lgm_transfer3d.c ug-patched/dom/lgm/lgm_transfer3d.c
--- ug-orig/dom/lgm/lgm_transfer3d.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/lgm_transfer3d.c	2009-04-29 15:11:55.000000000 +0200
@@ -17,6 +17,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -47,7 +48,7 @@
 static INT LGM_DEBUG = 0;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_transfer3d.c,v 1.26 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 static int SkipBTN (void)
 {
@@ -81,7 +82,7 @@
 }
 
 
-static int ReadCommentLine (char *comment)
+static int ReadCommentLine (const char *comment)
 {
 	char buffer[256];
 
@@ -120,7 +121,7 @@
 static fpos_t fileposline;
 static fpos_t filepossurface;
 
-int NS_DIM_PREFIX LGM_ReadDomain (HEAP *Heap, char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey)
+int NS_DIM_PREFIX LGM_ReadDomain (HEAP *Heap, const char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey)
 {
 	int i,i0,i1,i2;
 	char buffer[256];
@@ -850,7 +851,7 @@
 D*/
 /****************************************************************************/
 
-FILE* NS_DIM_PREFIX LGM_WriteOpenFile (char* name)
+FILE* NS_DIM_PREFIX LGM_WriteOpenFile (const char* name)
 {
 	FILE *stream;
 	
diff -ruN ug-orig/dom/lgm/lgm_transfer.h ug-patched/dom/lgm/lgm_transfer.h
--- ug-orig/dom/lgm/lgm_transfer.h	2006-11-08 16:35:43.000000000 +0100
+++ ug-patched/dom/lgm/lgm_transfer.h	2009-04-29 15:11:55.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/lgm_transfer.h,v 1.22 2006/11/08 15:35:43 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -258,7 +258,7 @@
 /*																			*/
 /****************************************************************************/
 
-int LGM_ReadDomain 			(HEAP *theHeap, char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey);
+int LGM_ReadDomain 			(HEAP *theHeap, const char *filename, LGM_DOMAIN_INFO *domain_info, INT MarkKey);
 int LGM_ReadSizes 			(LGM_SIZES *lgm_sizes);
 int LGM_ReadSubDomain 		(int i, LGM_SUBDOMAIN_INFO *subdom_info);
 int LGM_ReadLines 			(int i, LGM_LINE_INFO *line_info);
@@ -272,7 +272,7 @@
 int HGM_ReadSurface 		(int i, LGM_SURFACE_INFO *surface_info);
 #endif
 
-FILE *LGM_WriteOpenFile 	(char* name);
+FILE *LGM_WriteOpenFile 	(const char* name);
 INT InitLGMTransfer 		(void);
 
 END_UGDIM_NAMESPACE
diff -ruN ug-orig/dom/lgm/Makefile.am ug-patched/dom/lgm/Makefile.am
--- ug-orig/dom/lgm/Makefile.am	2004-09-09 19:50:24.000000000 +0200
+++ ug-patched/dom/lgm/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/09/09 17:50:24 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 if BUILD2D
   LIB_2D = libdomL2.la
@@ -20,9 +20,10 @@
 
 SOURCES = lgm_domain.c lgm_load.c lgm_parallel.c ansys2lgm.h lgm_domain.h lgm_load.h lgm_macros.h lgm_transfer.h 
 
-include_HEADERS = lgm_domain.h
+domincludedir = $(pkgincludedir)
+dominclude_HEADERS = lgm_domain.h
 
-lib_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
+noinst_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
 
 libdomL2_la_SOURCES = $(SOURCES) lgm_transfer2d.c lgm_domain2d.c
 libdomL2_la_CPPFLAGS = $(UG_2DFLAGS)
diff -ruN ug-orig/dom/lgm/netgen/CVS/Entries ug-patched/dom/lgm/netgen/CVS/Entries
--- ug-orig/dom/lgm/netgen/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:13 2004//D2008.11.12.23.00.00
-/gt.cc/1.6/Tue Oct  8 13:31:11 2002//D2008.11.12.23.00.00
-/lgm.hh/1.5/Mon May  4 12:12:14 1998//D2008.11.12.23.00.00
-/lgm_gginterface.h/1.7/Wed Mar 18 17:44:57 1998//D2008.11.12.23.00.00
-/lgm_makefile.netgen/1.4/Tue Mar  8 13:09:47 2005//D2008.11.12.23.00.00
-/nginterface3d.cc/1.19/Wed Dec  3 17:27:16 2003//D2008.11.12.23.00.00
-/surface.c/1.15/Mon Jul 26 15:34:00 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/lgm/netgen/CVS/Entries.Log ug-patched/dom/lgm/netgen/CVS/Entries.Log
--- ug-orig/dom/lgm/netgen/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/ptrepository////
diff -ruN ug-orig/dom/lgm/netgen/CVS/Repository ug-patched/dom/lgm/netgen/CVS/Repository
--- ug-orig/dom/lgm/netgen/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/lgm/netgen
diff -ruN ug-orig/dom/lgm/netgen/CVS/Root ug-patched/dom/lgm/netgen/CVS/Root
--- ug-orig/dom/lgm/netgen/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/lgm/netgen/CVS/Tag ug-patched/dom/lgm/netgen/CVS/Tag
--- ug-orig/dom/lgm/netgen/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/lgm/netgen/.cvsignore ug-patched/dom/lgm/netgen/.cvsignore
--- ug-orig/dom/lgm/netgen/.cvsignore	2004-09-08 16:14:13.000000000 +0200
+++ ug-patched/dom/lgm/netgen/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/dom/lgm/netgen/lgm_gginterface.h ug-patched/dom/lgm/netgen/lgm_gginterface.h
--- ug-orig/dom/lgm/netgen/lgm_gginterface.h	1998-03-18 18:44:57.000000000 +0100
+++ ug-patched/dom/lgm/netgen/lgm_gginterface.h	1998-03-18 18:45:01.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/netgen/lgm_gginterface.h,v 1.7 1998/03/18 17:44:57 klaus Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/dom/lgm/netgen/ptrepository/CVS/Entries ug-patched/dom/lgm/netgen/ptrepository/CVS/Entries
--- ug-orig/dom/lgm/netgen/ptrepository/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/ptrepository/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-/_lock/1.1/Tue May 13 12:44:10 1997//D2008.11.12.23.00.00
-/defmap/1.3/Thu Mar 19 17:25:05 1998//D2008.11.12.23.00.00
-/defmap.old/1.3/Thu Mar 19 17:25:06 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/lgm/netgen/ptrepository/CVS/Repository ug-patched/dom/lgm/netgen/ptrepository/CVS/Repository
--- ug-orig/dom/lgm/netgen/ptrepository/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/ptrepository/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/lgm/netgen/ptrepository
diff -ruN ug-orig/dom/lgm/netgen/ptrepository/CVS/Root ug-patched/dom/lgm/netgen/ptrepository/CVS/Root
--- ug-orig/dom/lgm/netgen/ptrepository/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/ptrepository/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/lgm/netgen/ptrepository/CVS/Tag ug-patched/dom/lgm/netgen/ptrepository/CVS/Tag
--- ug-orig/dom/lgm/netgen/ptrepository/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/netgen/ptrepository/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/lgm/netgen/surface.c ug-patched/dom/lgm/netgen/surface.c
--- ug-orig/dom/lgm/netgen/surface.c	2004-07-26 17:34:00.000000000 +0200
+++ ug-patched/dom/lgm/netgen/surface.c	2008-12-19 11:15:14.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -87,7 +88,7 @@
 static CoeffProcPtr 			LOCAL_H;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/netgen/surface.c,v 1.15 2004/07/26 15:34:00 stefan Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
diff -ruN ug-orig/dom/lgm/ngin/CVS/Entries ug-patched/dom/lgm/ngin/CVS/Entries
--- ug-orig/dom/lgm/ngin/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-/.cvsignore/1.2/Fri Mar 17 09:44:12 2006//D2008.11.12.23.00.00
-/Makefile.am/1.2/Thu Sep  9 17:50:24 2004//D2008.11.12.23.00.00
-/Makefile.ngin/1.6/Wed Sep 21 08:09:21 2005//D2008.11.12.23.00.00
-/ng.c/1.23/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/ng.h/1.14/Fri Nov 17 10:46:10 2006//D2008.11.12.23.00.00
-/ngin-lex.h/1.1/Tue Sep  7 14:31:10 2004//D2008.11.12.23.00.00
-/ngin-lex.l/1.4/Fri Jun  2 15:38:35 2006//D2008.11.12.23.00.00
-/ngin-yacc.y/1.7/Tue Nov 21 17:04:59 2006//D2008.11.12.23.00.00
-/ngin.ps/1.2/Wed Oct 24 09:25:08 2001//D2008.11.12.23.00.00
-/test.ng/1.3/Wed Feb 25 14:08:36 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/lgm/ngin/CVS/Repository ug-patched/dom/lgm/ngin/CVS/Repository
--- ug-orig/dom/lgm/ngin/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/lgm/ngin
diff -ruN ug-orig/dom/lgm/ngin/CVS/Root ug-patched/dom/lgm/ngin/CVS/Root
--- ug-orig/dom/lgm/ngin/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/lgm/ngin/CVS/Tag ug-patched/dom/lgm/ngin/CVS/Tag
--- ug-orig/dom/lgm/ngin/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/lgm/ngin/.cvsignore ug-patched/dom/lgm/ngin/.cvsignore
--- ug-orig/dom/lgm/ngin/.cvsignore	2006-03-17 10:44:12.000000000 +0100
+++ ug-patched/dom/lgm/ngin/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-ngin-lex.c
-ngin-yacc.c
-ngin-yacc.h
-semantic.cache
-
diff -ruN ug-orig/dom/lgm/ngin/Makefile.am ug-patched/dom/lgm/ngin/Makefile.am
--- ug-orig/dom/lgm/ngin/Makefile.am	2004-09-09 19:50:24.000000000 +0200
+++ ug-patched/dom/lgm/ngin/Makefile.am	2004-09-09 19:50:27.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/09/09 17:50:24 thimo Exp $
+# $Id: Makefile.am 7795 2004-09-09 17:50:27Z thimo $
 
 if BUILD3D
   LIB_3D = libngin.la
diff -ruN ug-orig/dom/lgm/ngin/ng.c ug-patched/dom/lgm/ngin/ng.c
--- ug-orig/dom/lgm/ngin/ng.c	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/ngin/ng.c	2009-04-29 15:11:55.000000000 +0200
@@ -98,7 +98,7 @@
 #endif
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/ngin/ng.c,v 1.23 2006/11/17 10:46:10 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -481,11 +481,11 @@
 	ng_abort=1;
 }
 
-int NS_DIM_PREFIX NG_ReadMesh (char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey)
+int NS_DIM_PREFIX NG_ReadMesh (const char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey)
 {
 	int i,j,error;
 	char ngname[128];
-	char *tmp;
+	const char *tmp;
 
 	/* init */
 	ng_abort=0;
diff -ruN ug-orig/dom/lgm/ngin/ng.h ug-patched/dom/lgm/ngin/ng.h
--- ug-orig/dom/lgm/ngin/ng.h	2006-11-17 11:46:10.000000000 +0100
+++ ug-patched/dom/lgm/ngin/ng.h	2009-04-29 15:11:55.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/ngin/ng.h,v 1.14 2006/11/17 10:46:10 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -160,7 +160,7 @@
 int PutBndNode (BND_NODE *BndNode);
 int PutInnerNode (INNER_NODE *InnNode);
 int PutElement (NG_ELEMENT *Elem);
-int NG_ReadMesh (char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey);
+int NG_ReadMesh (const char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey);
 
 #ifdef __USE_IN_UG__
 	int NG_Init (int domainpaths_set);
diff -ruN ug-orig/dom/lgm/ngin/ngin-lex.l ug-patched/dom/lgm/ngin/ngin-lex.l
--- ug-orig/dom/lgm/ngin/ngin-lex.l	2006-06-02 17:38:35.000000000 +0200
+++ ug-patched/dom/lgm/ngin/ngin-lex.l	2006-06-02 17:38:35.000000000 +0200
@@ -26,7 +26,7 @@
 static int noline=1;
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/ngin/ngin-lex.l,v 1.4 2006/06/02 15:38:35 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /* forward declare stuff from ngin-yacc.y */
 int ngerror (char *s); 
diff -ruN ug-orig/dom/lgm/ngin/ngin-yacc.y ug-patched/dom/lgm/ngin/ngin-yacc.y
--- ug-orig/dom/lgm/ngin/ngin-yacc.y	2006-11-21 18:04:59.000000000 +0100
+++ ug-patched/dom/lgm/ngin/ngin-yacc.y	2009-04-29 14:00:07.000000000 +0200
@@ -50,7 +50,7 @@
 
  /* forward declare my own function (referenced by automatic parser) */ 
  int ngerror (char *s);
- int ngwrap();
+extern "C" int ngwrap();
 %}
 
 %union 
@@ -200,7 +200,7 @@
 														BndNode.global[0]=$2;
 														BndNode.global[1]=$3;
 														BndNode.global[2]=$4;
-														$$=&BndNode;
+														$<bs>$=&BndNode;
 													}
 	BndSpec 										{PutBndNode(&BndNode);}
 	TEND			
@@ -255,10 +255,13 @@
 %%
 
 
+extern "C"
+{
 int ngwrap ()
 {
     return (1);
 }
+}
 
 int ngerror (char *s)
 {
diff -ruN ug-orig/dom/lgm/ngin2d/CVS/Entries ug-patched/dom/lgm/ngin2d/CVS/Entries
--- ug-orig/dom/lgm/ngin2d/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-/.cvsignore/1.2/Fri Mar 17 09:44:12 2006//D2008.11.12.23.00.00
-/Makefile.am/1.2/Thu Sep  9 17:50:25 2004//D2008.11.12.23.00.00
-/Makefile.ngin/1.4/Wed Sep 21 08:09:22 2005//D2008.11.12.23.00.00
-/geometry/1.1/Mon Jul 31 13:34:12 2000//D2008.11.12.23.00.00
-/geometry.ng/1.1/Mon Jul 31 13:34:13 2000//D2008.11.12.23.00.00
-/ng.c/1.11/Thu Oct 30 12:29:05 2008//D2008.11.12.23.00.00
-/ng2d.h/1.7/Mon May  8 12:18:23 2006//D2008.11.12.23.00.00
-/ngin-lex.h/1.1/Tue Sep  7 14:31:11 2004//D2008.11.12.23.00.00
-/ngin-lex.l/1.4/Fri Jun  2 15:38:11 2006//D2008.11.12.23.00.00
-/ngin-yacc.y/1.6/Tue Nov 21 17:05:00 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/lgm/ngin2d/CVS/Repository ug-patched/dom/lgm/ngin2d/CVS/Repository
--- ug-orig/dom/lgm/ngin2d/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/lgm/ngin2d
diff -ruN ug-orig/dom/lgm/ngin2d/CVS/Root ug-patched/dom/lgm/ngin2d/CVS/Root
--- ug-orig/dom/lgm/ngin2d/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/lgm/ngin2d/CVS/Tag ug-patched/dom/lgm/ngin2d/CVS/Tag
--- ug-orig/dom/lgm/ngin2d/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/lgm/ngin2d/.cvsignore ug-patched/dom/lgm/ngin2d/.cvsignore
--- ug-orig/dom/lgm/ngin2d/.cvsignore	2006-03-17 10:44:12.000000000 +0100
+++ ug-patched/dom/lgm/ngin2d/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-ngin-lex.c
-ngin-yacc.c
-ngin-yacc.h
-semantic.cache
-
diff -ruN ug-orig/dom/lgm/ngin2d/Makefile.am ug-patched/dom/lgm/ngin2d/Makefile.am
--- ug-orig/dom/lgm/ngin2d/Makefile.am	2004-09-09 19:50:25.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/Makefile.am	2006-12-14 20:25:22.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/09/09 17:50:25 thimo Exp $ 
+# $Id: Makefile.am 8235 2006-12-14 19:25:22Z langsn $ 
 
 if BUILD2D
   LIB_2D = libngin2d.la
@@ -9,7 +9,7 @@
 noinst_LTLIBRARIES = $(LIB_2D)
 
 # prefix to use instead of 'yy'
-PARSERPREFIX = ng
+PARSERPREFIX = ng2d
 
 # generate header file, rename prefix
 AM_YFLAGS = -d -p $(PARSERPREFIX)
diff -ruN ug-orig/dom/lgm/ngin2d/ng2d.h ug-patched/dom/lgm/ngin2d/ng2d.h
--- ug-orig/dom/lgm/ngin2d/ng2d.h	2006-05-08 14:18:23.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/ng2d.h	2009-04-29 15:11:55.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/lgm/ngin2d/ng2d.h,v 1.7 2006/05/08 12:18:23 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -145,14 +145,14 @@
 int PutBndNode (BND_NODE *BndNode);
 int PutInnerNode (INNER_NODE *InnNode);
 int PutElement (NG_ELEMENT *Elem);
-int NG_ReadMesh (char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey);
+int NG_ReadMesh (const char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey);
 
 #ifdef __USE_IN_UG__
 	int NG_Init (int domainpaths_set);
 #endif
 
-END_UGDIM_NAMESPACE
-
 void ngbreak (void);
 
+END_UGDIM_NAMESPACE
+
 #endif
diff -ruN ug-orig/dom/lgm/ngin2d/ng.c ug-patched/dom/lgm/ngin2d/ng.c
--- ug-orig/dom/lgm/ngin2d/ng.c	2008-10-30 13:29:05.000000000 +0100
+++ ug-patched/dom/lgm/ngin2d/ng.c	2009-04-29 15:11:55.000000000 +0200
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
-#include <math.h>
 
 #include "ng2d.h"
 #ifdef __USE_IN_UG__
@@ -42,7 +41,9 @@
 
 #include "namespace.h"
 
-USING_UG_NAMESPACES
+USING_UG_NAMESPACE
+USING_UGDIM_NAMESPACE
+
 
 
 /****************************************************************************/
@@ -76,6 +77,7 @@
 /*																			*/
 /****************************************************************************/
 
+#define ngin ng2din
 extern FILE *ngin;
 
 /****************************************************************************/
@@ -97,14 +99,14 @@
 #endif
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/ngin2d/ng.c,v 1.11 2008/10/30 12:29:05 dmitriy Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
 /* forward declarations of functions used before they are defined			*/
 /*																			*/
 /****************************************************************************/
-
+#define ngparse ng2dparse
 int ngparse (void);
 
 
@@ -144,7 +146,7 @@
 	return (0);
 }
 
-int NP_ElemSideOnBnd (NG_ELEMENT *Elem)
+static int NP_ElemSideOnBnd (NG_ELEMENT *Elem)
 {
 	int i,j,esob,c1,c2,ec1,ec2;
 
@@ -164,79 +166,10 @@
 	return (esob);
 }
 
-#ifdef WITH_DEGENERATED_ELEM
-
-static int IsDegeneratedElem (int n_c, double p [] [2], int * start_ind)
-{
-	int i, j;
-	double x, y;
-	double t, min_dist, max_dist, dist_0;
-	
-	x = p [1] [0] - p [0] [0]; y = p [1] [1] - p [0] [1];
-	max_dist = min_dist = dist_0 = x * x + y * y;
-	for (i = 0; i < n_c; i++)
-		for (j = i + 1; j < n_c; j++)
-		{
-			x = p [j] [0] - p [i] [0]; y = p [j] [1] - p [i] [1];
-			t = x * x + y * y;
-			if (t > max_dist) max_dist = t;
-			else if (t < min_dist) min_dist = t;
-		}
-	min_dist = sqrt (min_dist); max_dist = sqrt (max_dist);
-	
-	if (min_dist > DEGENERATED_SIZE * max_dist)
-		return 0; /* is not degenerated */
-	
-	/* This is a degenerated element. Find its ordering: */
-	dist_0 = sqrt (dist_0);
-	
-	if (n_c == 3)
-	{ /* a degenerated triangle */
-		if (dist_0 > DEGENERATED_SIZE * max_dist)
-		{
-			x = p [2] [0] - p [1] [0]; y = p [2] [1] - p [1] [1];
-			t = x * x + y * y;
-			*start_ind = (t > DEGENERATED_SIZE * max_dist)? 0 : 2;
-		}
-		else * start_ind = 1;
-	}
-	else if (n_c == 4)
-	{ /* a degenerated quadrilateral? */
-        if (dist_0 > DEGENERATED_SIZE * max_dist)
-            *start_ind = i = 0;
-        else
-        {
-            *start_ind = i = 1;
-			x = p [2] [0] - p [1] [0]; y = p [2] [1] - p [1] [1];
-			t = x * x + y * y;
-            if (t <= DEGENERATED_SIZE * max_dist) return 0; /* illegal set of points */
-        }
-        
-		x = p [i+2] [0] - p [i+1] [0]; y = p [i+2] [1] - p [i+1] [1];
-		t = x * x + y * y;
-        if (t > DEGENERATED_SIZE * max_dist) return 0; /* illegal set of points */
-        
-        if (i == 0)
-        {
-			x = p [3] [0] - p [0] [0]; y = p [3] [1] - p [0] [1];
-			t = x * x + y * y;
-            if (t > DEGENERATED_SIZE * max_dist) return 0; /* illegal set of points */
-        }
-	}
-	else return 0; /* to be on the safe side */
-	
-	return 1;
-}
-
-#endif
-
-int OrientateElem (NG_ELEMENT *Elem)
+static int OrientateElem (NG_ELEMENT *Elem)
 {
     int i;
     double p[4][2];
-#ifdef WITH_DEGENERATED_ELEM
-	int j, k;
-#endif
 
     for (i=0; i<Elem->n_c; i++)
         if (Elem->c_id[i]<Global_Mesh->nBndP)
@@ -249,21 +182,6 @@
             p[i][0]=Global_Mesh->InnPosition[Elem->c_id[i]-Global_Mesh->nBndP][0];
             p[i][1]=Global_Mesh->InnPosition[Elem->c_id[i]-Global_Mesh->nBndP][1];
         }
-	
-#ifdef WITH_DEGENERATED_ELEM
-	if (IsDegeneratedElem (Elem->n_c, p, &k))
-	{
-        while (k-- != 0)
-            for (i = 1; i < Elem->n_c; i++)
-            {
-				j = Elem->c_id[i-1];
-				Elem->c_id[i-1] = Elem->c_id[i];
-				Elem->c_id[i] = j;
-            }
-		return 0;
-	}
-#endif
-	
     for (i=1; i<Elem->n_c; i++)
     {
         p[i][0]-=p[0][0];
@@ -286,7 +204,7 @@
  */
 /****************************************************************************/
 
-int PutBndNode (BND_NODE *BndNode)
+int NS_DIM_PREFIX PutBndNode (BND_NODE *BndNode)
 {
 	int i,line_id;
 
@@ -339,7 +257,7 @@
 	return (0);
 }
 
-int PutInnerNode (INNER_NODE *InnNode)
+int NS_DIM_PREFIX PutInnerNode (INNER_NODE *InnNode)
 {
 	switch (mode)
 	{
@@ -358,7 +276,7 @@
 	return (0);
 }
 
-int PutElement (NG_ELEMENT *Elem)
+int NS_DIM_PREFIX PutElement (NG_ELEMENT *Elem)
 {
 	int i,j,side;
 
@@ -400,16 +318,16 @@
 	return (0);
 }
 
-void ngbreak (void)
+void NS_DIM_PREFIX ngbreak (void)
 {
 	ng_abort=1;
 }
 
-int NG_ReadMesh (char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey)
+int NS_DIM_PREFIX NG_ReadMesh (const char *name, HEAP *Heap, LGM_MESH_INFO *theMesh, INT MarkKey)
 {
 	int i,j,error;
 	char ngname[128];
-	char *tmp;
+	const char *tmp;
 
 	/* init */
 	ng_abort=0;
@@ -556,7 +474,7 @@
 
 #ifdef __USE_IN_UG__
 
-int NG_Init (int domainpathes_set)
+int NS_DIM_PREFIX NG_Init (int domainpathes_set)
 {
 	lgmdomainpathes_set = domainpathes_set;
 
diff -ruN ug-orig/dom/lgm/ngin2d/ngin-lex.h ug-patched/dom/lgm/ngin2d/ngin-lex.h
--- ug-orig/dom/lgm/ngin2d/ngin-lex.h	2004-09-07 16:31:11.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/ngin-lex.h	2006-12-14 20:25:22.000000000 +0100
@@ -2,9 +2,9 @@
 #define UG_NGIN_LEX_H
 
 /* C++-compilers don't like this defined implicitly */
-int nglex();
+int ng2dlex();
 
 /* error function used in YACC-parser as well */
-int NP_Error (int *line, char *text);
+int NP2d_Error (int *line, char *text);
 
 #endif
diff -ruN ug-orig/dom/lgm/ngin2d/ngin-lex.l ug-patched/dom/lgm/ngin2d/ngin-lex.l
--- ug-orig/dom/lgm/ngin2d/ngin-lex.l	2006-06-02 17:38:11.000000000 +0200
+++ ug-patched/dom/lgm/ngin2d/ngin-lex.l	2006-12-14 20:25:22.000000000 +0100
@@ -28,10 +28,10 @@
 static int noline=1;
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/lgm/ngin2d/ngin-lex.l,v 1.4 2006/06/02 15:38:11 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /* forward declare stuff from ngin-yacc.y */
-int ngerror (char *s); 
+int ng2derror (char *s); 
 
 %}
 
@@ -51,19 +51,19 @@
 [ \t]+              ;
 [\n]                {noline++;}
 {COMMENT}           ;
-{KEY_INT}			{nglval.ival=atol((const char *)yytext); return (INT_VALUE);}
-{KEY_DOUBLE}		{nglval.dval=strtod((const char *)yytext,NULL); return (DOUBLE_VALUE);}
+{KEY_INT}			{ng2dlval.ival=atol((const char *)yytext); return (INT_VALUE);}
+{KEY_DOUBLE}		{ng2dlval.dval=strtod((const char *)yytext,NULL); return (DOUBLE_VALUE);}
 {KEY_INODE}			{return (INODE);}
 {KEY_BNODE}			{return (BNODE);}
 {KEY_LINE}			{return (LINE);}
 {KEY_ELEM}			{return (ELEM);}
 {KEY_SIDE}			{return (SIDE);}
 {KEY_TEND}			{return (TEND);}
-.                   {ngerror(NULL);}
+.                   {ng2derror(NULL);}
 
 %%
 
-int NP_Error (int *line, char *text)
+int NP2d_Error (int *line, char *text)
 {
 	*line=noline;
 	strcpy(text,yytext);
diff -ruN ug-orig/dom/lgm/ngin2d/ngin-yacc.y ug-patched/dom/lgm/ngin2d/ngin-yacc.y
--- ug-orig/dom/lgm/ngin2d/ngin-yacc.y	2006-11-21 18:05:00.000000000 +0100
+++ ug-patched/dom/lgm/ngin2d/ngin-yacc.y	2009-04-29 14:00:07.000000000 +0200
@@ -48,8 +48,8 @@
 static NG_ELEMENT Elem;
 
  /* forward declare my own function (referenced by automatic parser) */ 
- int ngerror (char *s);
- int ngwrap();
+ int ng2derror (char *s);
+
 
 %}
 
@@ -157,7 +157,7 @@
 														BndNode.n_lp=0;
 														BndNode.global[0]=$2;
 														BndNode.global[1]=$3;
-														$$=&BndNode;
+														$<bs>$=&BndNode;
 													}
 	BndSpec 										{PutBndNode(&BndNode);}
 	TEND			
@@ -192,18 +192,20 @@
 
 %%
 
-
-int ngwrap ()
+extern "C" 
+{
+int ng2dwrap (void )
 {
     return (1);
 }
+}
 
-int ngerror (char *s)
+int ng2derror (char *s)
 {
 	int line;
 	char text[128];
 
-	NP_Error(&line,text);
+	NP2d_Error(&line,text);
     NG_Print(ERROR_PREFIX "'%s', line %d\n",text,line);
     ngbreak();
 	return 0;
diff -ruN ug-orig/dom/Makefile.am ug-patched/dom/Makefile.am
--- ug-orig/dom/Makefile.am	2004-10-06 14:18:01.000000000 +0200
+++ ug-patched/dom/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/10/06 12:18:01 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 # compile the different domain-modules
 SUBDIRS = std lgm 
@@ -6,7 +6,8 @@
 # gen
 
 # install the central header
-include_HEADERS = domain.h
+domincludedir = $(pkgincludedir)
+dominclude_HEADERS = domain.h
 
 
 
diff -ruN ug-orig/dom/std/CVS/Entries ug-patched/dom/std/CVS/Entries
--- ug-orig/dom/std/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/std/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:14 2004//D2008.11.12.23.00.00
-/Makefile.am/1.4/Tue Nov  2 16:28:03 2004//D2008.11.12.23.00.00
-/Makefile.std/1.6/Sun Jun 28 20:52:04 1998//D2008.11.12.23.00.00
-/domains2d.c/1.57/Fri Jun  2 16:11:18 2006//D2008.11.12.23.00.00
-/domains3d.c/1.21/Thu Sep  9 14:38:06 2004//D2008.11.12.23.00.00
-/repair.c/1.11/Fri Jun  2 16:11:18 2006//D2008.11.12.23.00.00
-/std_domain.c/1.114/Fri Jun  2 16:11:18 2006//D2008.11.12.23.00.00
-/std_domain.h/1.34/Mon May  8 12:21:44 2006//D2008.11.12.23.00.00
-/std_internal.h/1.5/Mon May  8 12:21:44 2006//D2008.11.12.23.00.00
-/std_parallel.c/1.12/Tue Jul 25 08:46:49 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/dom/std/CVS/Repository ug-patched/dom/std/CVS/Repository
--- ug-orig/dom/std/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/std/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/dom/std
diff -ruN ug-orig/dom/std/CVS/Root ug-patched/dom/std/CVS/Root
--- ug-orig/dom/std/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/std/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/dom/std/CVS/Tag ug-patched/dom/std/CVS/Tag
--- ug-orig/dom/std/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/dom/std/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/dom/std/.cvsignore ug-patched/dom/std/.cvsignore
--- ug-orig/dom/std/.cvsignore	2004-09-08 16:14:14.000000000 +0200
+++ ug-patched/dom/std/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/dom/std/domains2d.c ug-patched/dom/std/domains2d.c
--- ug-orig/dom/std/domains2d.c	2006-06-02 18:11:18.000000000 +0200
+++ ug-patched/dom/std/domains2d.c	2006-06-02 18:15:34.000000000 +0200
@@ -625,7 +625,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/std/domains2d.c,v 1.57 2006/06/02 16:11:18 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /****************************************************************************/
diff -ruN ug-orig/dom/std/domains3d.c ug-patched/dom/std/domains3d.c
--- ug-orig/dom/std/domains3d.c	2004-09-09 16:38:06.000000000 +0200
+++ ug-patched/dom/std/domains3d.c	2008-12-19 11:15:14.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -106,7 +107,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/std/domains3d.c,v 1.21 2004/09/09 14:38:06 thimo Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /****************************************************************************/
diff -ruN ug-orig/dom/std/Makefile.am ug-patched/dom/std/Makefile.am
--- ug-orig/dom/std/Makefile.am	2004-11-02 17:28:03.000000000 +0100
+++ ug-patched/dom/std/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,34 +1,26 @@
-# $Id: Makefile.am,v 1.4 2004/11/02 16:28:03 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 SOURCES = std_domain.c std_parallel.c std_domain.h std_internal.h 
 
-EXTRALIBS = ../../low/liblow.la ../../dev/libdevices.la
 if BUILD2D
   LIB_2D = libdomS2.la
-if PARALLEL
-  PLIBS2 = ../../gm/libug_gm2.la ../../parallel/libparallel2.la
-endif
 else
   LIB_2D =
 endif
 
 if BUILD3D
   LIB_3D = libdomS3.la
-if PARALLEL
-  PLIBS3 = ../../gm/libug_gm3.la ../../parallel/libparallel3.la
-endif
 else
   LIB_3D =
 endif
 
-lib_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
+noinst_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
 
-include_HEADERS = std_domain.h
+domincludedir = $(pkgincludedir)
+dominclude_HEADERS = std_domain.h
 
 libdomS2_la_SOURCES = $(SOURCES) domains2d.c
 libdomS2_la_CPPFLAGS = $(UG_2DFLAGS)
-libdomS2_la_LIBADD = $(PLIBS2) $(EXTRALIBS) 
 
-libdomS3_la_SOURCES = $(SOURCES) repair.c domains3d.c
+libdomS3_la_SOURCES = $(SOURCES) domains3d.c
 libdomS3_la_CPPFLAGS = $(UG_3DFLAGS)
-libdomS3_la_LIBADD = $(PLIBS3) $(EXTRALIBS) 
diff -ruN ug-orig/dom/std/Makefile.std ug-patched/dom/std/Makefile.std
--- ug-orig/dom/std/Makefile.std	1998-06-28 22:52:04.000000000 +0200
+++ ug-patched/dom/std/Makefile.std	2007-04-24 16:02:10.000000000 +0200
@@ -10,7 +10,7 @@
 # include configuration and all makefile macro definitions
 include ../../ug.conf
 
-OBJECTS = std_domain.o domains$(DIM)d.o std_parallel.o repair.o
+OBJECTS = std_domain.o domains$(DIM)d.o std_parallel.o
 
 # local C compiler flags
 LCFLAGS = -I../../include
diff -ruN ug-orig/dom/std/repair.c ug-patched/dom/std/repair.c
--- ug-orig/dom/std/repair.c	2006-06-02 18:11:18.000000000 +0200
+++ ug-patched/dom/std/repair.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,651 +0,0 @@
-/****************************************************************************/
-/*                                                                          */
-/* File:      repair.c                                                      */
-/*                                                                          */
-/* Purpose:   repair tool                   								*/
-/*																			*/
-/* Author:	  Christian Wieners                  	  						*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70550 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de								*/
-/*																			*/
-/* History:   Jun 28 for Marc                        						*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include "config.h"
-
-/* standard C library */
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-
-/* Needs to be the first UG include for the dimension and the namespace */
-#include "domain.h"
-
-/* low modules */
-#include "compiler.h"
-#include "heaps.h"
-#include "ugenv.h"
-#include "bio.h"
-#include "misc.h"
-#include "fileopen.h"
-#include "defaults.h"
-#include "general.h"
-#include "debug.h"
-#include "evm.h"
-
-/* dev modules */
-#include "ugdevices.h" 
-
-/* domain module */
-#include "std_internal.h"
-
-USING_UG_NAMESPACE
-USING_UGDIM_NAMESPACE
-
-/****************************************************************************/
-/*                                                                          */
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define SMALL_DIFF   SMALL_C*100
-#define RESOLUTION   100
-
-#define DEFAULTDOMMEMORY 50000
-
-#define OPTIONLEN 32
-
-#define V2_LINCOMB(a,A,b,B,C)		   {(C)[0] = (a)*(A)[0] + (b)*(B)[0];\
-										(C)[1] = (a)*(A)[1] + (b)*(B)[1];}
-
-#define V2_EUKLIDNORM_OF_DIFF(A,B,b)	(b) = sqrt((double)(((A)[0]-(B)[0])*((A)[0]-(B)[0])+((A)[1]-(B)[1])*((A)[1]-(B)[1])));
-
-#define V3_EUKLIDNORM_OF_DIFF(A,B,b)	(b) = (sqrt((double)(((A)[0]-(B)[0])*((A)[0]-(B)[0])+((A)[1]-(B)[1])*((A)[1]-(B)[1])+((A)[2]-(B)[2])*((A)[2]-(B)[2]))));
-
-#ifdef __TWODIM__
-#define V_DIM_EUKLIDNORM_OF_DIFF(A,B,b)	V2_EUKLIDNORM_OF_DIFF(A,B,b)
-#else
-#define V_DIM_EUKLIDNORM_OF_DIFF(A,B,b)	V3_EUKLIDNORM_OF_DIFF(A,B,b)
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of exported global variables                                  */
-/*                                                                          */
-/****************************************************************************/
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of variables global to this source file only (static!)        */
-/*                                                                          */
-/****************************************************************************/
-
-REP_ERR_FILE;
-
-/* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/std/repair.c,v 1.11 2006/06/02 16:11:18 sander Exp $",UG_RCS_STRING);
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef __THREEDIM__
-
-typedef struct {
-	INT corners_of_elem;					/* number of corners    		*/
-	INT sides_of_elem;						/* number of sides  			*/
-	INT corners_of_side[MAX_SIDES_OF_ELEM]; /* nb. of corners for each side */
-	INT corner_of_side[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE];
-
-} REFERENCE_ELEMENT;
-
-static REFERENCE_ELEMENT Tetrahedron = {
-	4,										/* tag							*/ 
-	4, 										/* number of sides				*/
-	{3,3,3,3,-1,-1},						/* corners for each side		*/
-	{{0,2,1,-1},{1,2,3,-1},{0,3,2,-1},{0,1,3,-1}}
-};
-
-static REFERENCE_ELEMENT Pyramid = {
-	5,										/* tag							*/ 
-	5, 										/* number of sides				*/
-	{4,3,3,3,3,-1},							/* corners for each side		*/
-	{{0,3,2,1},{0,1,4,-1},{1,2,4,-1},		/* number of corner j of side i */
-	 {2,3,4,-1},{3,0,4,-1}}
-};
-
-static REFERENCE_ELEMENT Prism = {
-	6,										/* tag							*/ 
-	5, 										/* number of sides				*/
-	{3,4,4,4,3,-1},							/* corners for each side		*/
-	{{0,2,1,-1},{0,1,4,3},{1,2,5,4},		/* number of corner j of side i */
-	 {2,0,3,5},{3,4,5,-1}}
-};
-
-static REFERENCE_ELEMENT Hexahedron = {
-	8,										/* tag							*/ 
-	6, 										/* number of sides				*/
-	{4,4,4,4,4,4},							/* corners for each side		*/
-	{{0,3,2,1},{0,1,5,4},{1,2,6,5},			/* number of corner j of side i */
-	 {2,3,7,6},{3,0,4,7},{4,5,6,7}}
-};
-
-INT NS_DIM_PREFIX CheckPrisms (INT *corner, INT n0, INT n1 , INT n2, INT n3)
-{
-	INT i,j,k,s[4];
-
-	s[0] = n0;
-	s[1] = n1;
-	s[2] = n2;
-	s[3] = n3;
-
-	for (j=0; j<6; j++) 
-	{
-	    INT side[4];
-
-		for (k=0; k<4; k++) 
-		    side[k] = corner[Hexahedron.corner_of_side[j][k]];
-
-		for (i=0; i<4; i++) 
-		    if (side[i] == s[0]) {
-
-/*
-	printf("s %d %d %d %d\n",s[0],s[1],s[2],s[3]);
-	printf("t %d %d %d %d\n",side[0],side[1],side[2],side[3]);
-*/
-
-			  for (k=1; k<4; k++) 
-				if (side[(4+i-k)%4] != s[k])
-				    break;
-			  if (k == 4) return(1);
-			}
-	  }
-return(0);
-  }
-
-
-static INT  CheckOnSide (INT *corner, INT n, INT **ids, INT *flag)
-{
-    INT rv = 0;
-	INT i,j,k,m;
-
-	for (j=0; j<6; j++) 
-	{
-	    INT side[4];
-
-		for (k=0; k<4; k++) 
-		    side[k] = corner[Hexahedron.corner_of_side[j][k]];
-
-	    flag[j] = 0;
-
-		for (i=0; i<n; i++) 
-		{
-		    m = 0;
-			for (k=0; k<4; k++) {
-			    if (side[k] == ids[i][Prism.corner_of_side[0][0]]) m++;
-			    else if (side[k] == ids[i][Prism.corner_of_side[0][1]]) m++;
-			    else if (side[k] == ids[i][Prism.corner_of_side[0][2]]) m++;
-			}
-			if (m == 3) {
-			    rv = 1;
-				for (k=0; k<4; k++) {
-				    if (side[k] == ids[i][Prism.corner_of_side[0][0]]) 
-					    continue;
-					else if (side[k] == ids[i][Prism.corner_of_side[0][1]]) 
-					    continue;
-					else if (side[k] == ids[i][Prism.corner_of_side[0][2]]) 
-					    continue; 
-					break;
-				}
-				if (k == 0) flag[j] = 2;
-				else if (k == 1) flag[j] = 1;
-				else if (k == 2) flag[j] = 2;
-				else if (k == 3) flag[j] = 1;
-
-
-			if (0){
-				UserWriteF("\nside[%d]  ",j);
-				for(k=0; k<4; k++)
-				  UserWriteF("_%05d",side[k]);
-				UserWriteF("\n");
-			}
-
-			}
-			m = 0;
-			for (k=0; k<4; k++) {
-			    if (side[k] == ids[i][Prism.corner_of_side[4][0]]) m++;
-			    else if (side[k] == ids[i][Prism.corner_of_side[4][1]]) m++;
-			    else if (side[k] == ids[i][Prism.corner_of_side[4][2]]) m++;
-			}
-			if (m == 3) {
-			    rv = 1;
-				for (k=0; k<4; k++) {
-				    if (side[k] == ids[i][Prism.corner_of_side[4][0]]) 
-					    continue;
-					else if (side[k] == ids[i][Prism.corner_of_side[4][1]]) 
-					    continue;
-					else if (side[k] == ids[i][Prism.corner_of_side[4][2]]) 
-					    continue; 
-					break;
-				}
-				if (k == 0) assert(flag[j] == 2);
-				else if (k == 1) assert(flag[j] == 1);
-				else if (k == 2) assert(flag[j] == 2);
-				else if (k == 3) assert(flag[j] == 1);
-			}
-		}
-	}
-
-    return(rv);
-}
-
-static INT CheckOrientation (INT i, INT n,
-							 DOUBLE *x, DOUBLE *y, DOUBLE *z, DOUBLE *w)
-{
-    DOUBLE_VECTOR diff[3],rot;
-	DOUBLE det;
-	INT j;
-   
-	V3_SUBTRACT(y,x,diff[0]);
-	V3_SUBTRACT(z,x,diff[1]);
-	V3_SUBTRACT(w,x,diff[2]);
-	V3_VECTOR_PRODUCT(diff[0],diff[1],rot);
-	V3_SCALAR_PRODUCT(rot,diff[2],det);
-
-	if (det < 0.0) {
-	    UserWriteF(" ID(Elem)=%d n=%d  det %f\n",i,n,det);
-		for (j=0; j<3; j++)
-		    UserWriteF("        diff[%d]=%5.2f %5.2f %5.2f\n",
-					   j,diff[j][0],diff[j][1],diff[j][2]);
-		UserWriteF("\n");
-
-	    return(1);
-	}
-	return(0);
-}
-#endif
-
-
-#ifdef __THREEDIM__
-
-INT  NS_DIM_PREFIX RepairMesh (HEAP *Heap, INT MarkKey, MESH *Mesh)
-{
-    INT i,sd;
-	DOUBLE **pos = Mesh->Position;
-	DOUBLE **p;
-	INT c[8];
-
-
-	Mesh->Position = (DOUBLE **)
-	    GetTmpMem(Heap,Mesh->nInnP*2*sizeof(DOUBLE *),MarkKey);
-	for (i=0; i<Mesh->nInnP; i++)
-	    Mesh->Position[i] = pos[i];   
-
-	p = (DOUBLE **)
-	    GetTmpMem(Heap,(Mesh->nInnP+Mesh->nBndP)*sizeof(DOUBLE *),MarkKey);
-
-	for (i=0; i<Mesh->nBndP; i++) {
-	    p[i] = (DOUBLE *)
-		  GetTmpMem(Heap,3*sizeof(DOUBLE),MarkKey);
-		BNDP_Global(Mesh->theBndPs[i],p[i]);
-	}
-	for (i=Mesh->nBndP; i<Mesh->nBndP+Mesh->nInnP; i++)
-	    p[i] = pos[i-Mesh->nBndP];   
-
-	for (sd=1; sd<=Mesh->nSubDomains; sd++) 
-	{  
-	    INT nElem = Mesh->nElements[sd];
-		INT *corners = Mesh->Element_corners[sd];
-		INT **corner = Mesh->Element_corner_ids[sd];
-		INT j,k,nPrism;
-		
-
-		if (0)
-		for (i=0; i<nElem; i++) {
-		    if (corners[i] == 6) {
-			    CheckOrientation(i,6,
-								 p[corner[i][0]],p[corner[i][1]],
-								 p[corner[i][2]],p[corner[i][3]]);
-
-				/*
-				UserWriteF(" ID(Elem)=%d\n",i);
-				for (j=0; j<6; j++)
-				  UserWriteF("        pos[%d]=%5.2f %5.2f %5.2f\n",
-							 j,p[corner[i][j]][0],
-							 p[corner[i][j]][1],
-							 p[corner[i][j]][2]);
-							 */
-
-			}
-		    if (corners[i] == 8) {
-			    if (CheckOrientation(i,8,
-									 p[corner[i][0]],p[corner[i][1]],
-									 p[corner[i][2]],p[corner[i][4]])) {
-				    
-				    for (j=0; j<8; j++)
-					    c[j] = corner[i][j];
-					for (j=0; j<4; j++) {
-					    corner[i][j] = c[j+4]; 
-					    corner[i][j+4] = c[j]; 
-					}
-				}
-			    CheckOrientation(i,8,
-								 p[corner[i][0]],p[corner[i][1]],
-								 p[corner[i][2]],p[corner[i][4]]);
-
-
-				/*
-				UserWriteF(" ID(Elem)=%d\n",i);
-				for (j=0; j<8; j++)
-				  UserWriteF("        pos[%d]=%5.2f %5.2f %5.2f\n",
-							 j,p[corner[i][j]][0],
-							 p[corner[i][j]][1],
-							 p[corner[i][j]][2]);
-							 */
-
-			}
-		}
-
-		nPrism = 0;
-		for (i=0; i<nElem; i++)
-		    if (corners[i] == 6) nPrism++;
-
-		Mesh->Element_corners[sd] = (INT *)  
-		    GetTmpMem(Heap,(nElem+11*(nElem-nPrism))*sizeof(INT),MarkKey);
-		Mesh->Element_corner_ids[sd] = (INT **) 
-			GetTmpMem(Heap,(nElem+11*(nElem-nPrism))*sizeof(INT*),MarkKey);
-
-		nPrism = 0;
-		for (i=0; i<nElem; i++)
-		    if (corners[i] == 6) {
-			    Mesh->Element_corners[sd][nPrism] = 6;  
-				Mesh->Element_corner_ids[sd][nPrism] = corner[i];
-				/*
-				Mesh->Element_corner_ids[sd][nPrism] = (INT *) 
-				    GetTmpMem(Heap,6*sizeof(INT),MarkKey);
-			    for (j=0; j<6; j++)
-				    Mesh->Element_corner_ids[sd][nPrism][j] = corner[i][j];
-				*/
-				nPrism++;
-			}
-		Mesh->nElements[sd] = nPrism;
-					  
-		for (i=0; i<nElem; i++) 
-		{
-		    INT flag[6];
-
-			if (corners[i] == 6) continue;
-
-			if (0){
-
-	UserWriteF("repair element[%d]\n",i);
-	for (j=0; j<6; j++)
-	{
-	    UserWriteF("corner[%d]  ",j);
-	    for(k=0; k<4; k++)
-		{
-		    UserWriteF("_%05d",corner[i][Hexahedron.corner_of_side[j][k]]);
-		}
-		UserWriteF("\n");
-	}
-	UserWriteF("\n");
-			}
-
-
-			if (CheckOnSide(corner[i],nPrism,
-							Mesh->Element_corner_ids[sd],flag)) 
-			{
-			    DOUBLE_VECTOR global;
-				DOUBLE scale = 0.125;
-
-				V_DIM_CLEAR(global);
-			  
-				for (j=0; j<8; j++) {
-				    V_DIM_LINCOMB(1.0,global,scale,pos[corner[i][j]],global);
-				}
-				Mesh->Position[Mesh->nInnP] = (DOUBLE *)
-				    GetTmpMem(Heap,3*sizeof(DOUBLE),MarkKey);
-				V_DIM_COPY(global,Mesh->Position[Mesh->nInnP]);
-
-
-			if (0){
-				UserWriteF(" el[%i] midPoint %8.4f %8.4f %8.4f\n",
-						   i,global[0],global[1],global[2]);
-				for (j=0; j<8; j++) 
-				  UserWriteF("   corner[%d] %8.4f %8.4f %8.4f\n",
-							 j,pos[corner[i][j]][0],
-							   pos[corner[i][j]][1],
-							   pos[corner[i][j]][2]);
-			}
-
-
-				for (j=0; j<6; j++) {
-				    if (flag[j] == 0) {
-					    Mesh->Element_corners[sd][Mesh->nElements[sd]] = 5;
-						Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = 
-						    (INT *) GetTmpMem(Heap,5*sizeof(INT),MarkKey);
-						for (k=0; k<4; k++)	 
-						  Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Pyramid.corner_of_side[0][k]]=
-							corner[i][Hexahedron.corner_of_side[j][k]];
-						Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][4] =
-						  Mesh->nInnP;
-						
-                                                if(0)
-                                                    {
-                                                        INT j1,k1;
-                                                        
-                                                        
-                                                        UserWriteF("repaired element[%d]\n",Mesh->nElements[sd]);
-                                                        for (j1=0; j1<5; j1++)
-                                                            {
-                                                                UserWriteF("corner[%d]  ",j1);
-                                                                for(k1=0; k1<Pyramid.corners_of_side[j1]; k1++)
-                                                                    {
-                                                                        UserWriteF("_%05d",
-                                                                                   Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Pyramid.corner_of_side[j1][k1]]);
-                                                                    }
-                                                                UserWriteF("\n");
-                                                            }
-                                                        UserWriteF("\n");
-                                                        
-                                                    }
-                                                
-                                                
-						Mesh->nElements[sd]++;			
-                                    }
-				    else if (flag[j] == 1) {
-                                        Mesh->Element_corners[sd][Mesh->nElements[sd]] = 4;
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = 
-                                            (INT *) GetTmpMem(Heap,4*sizeof(INT),MarkKey);
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][0]=
-                                            corner[i][Hexahedron.corner_of_side[j][0]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][1]=
-                                            corner[i][Hexahedron.corner_of_side[j][2]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][2]=
-                                            corner[i][Hexahedron.corner_of_side[j][1]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][3] =
-                                            Mesh->nInnP;
-                                        
-                                        
-                                        
-                                        if(0)
-                                            {
-                                                INT j1,k1;
-                                                
-                                                
-                                                UserWriteF("A repaired element[%d] flag %d\n",Mesh->nElements[sd],flag[j]);
-                                                for (j1=0; j1<4; j1++)
-                                                    {
-                                                        UserWriteF("corner[%d]  ",j1);
-                                                        for(k1=0; k1<Tetrahedron.corners_of_side[j1]; k1++)
-                                                            {
-                                                                UserWriteF("_%05d",
-                                                                           Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Tetrahedron.corner_of_side[j1][k1]]);
-                                                            }
-                                                        UserWriteF("\n");
-                                                    }
-                                                UserWriteF("\n");
-                                                
-                                            }
-                                        
-                                        
-                                        
-                                        
-                                        
-                                        
-                                        
-                                        
-                                        
-                                        Mesh->nElements[sd]++;			
-                                        Mesh->Element_corners[sd][Mesh->nElements[sd]] = 4;
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = 
-                                            (INT *) GetTmpMem(Heap,4*sizeof(INT),MarkKey);
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][0]=
-                                            corner[i][Hexahedron.corner_of_side[j][0]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][2]=
-                                            corner[i][Hexahedron.corner_of_side[j][2]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][1]=
-                                            corner[i][Hexahedron.corner_of_side[j][3]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][3] =
-                                            Mesh->nInnP;
-                                        
-                                        if(0)
-                                            {
-                                                INT j1,k1;
-                                                
-                                                
-                                                UserWriteF("B repaired element[%d] flag %d\n",Mesh->nElements[sd],flag[j]);
-                                                for (j1=0; j1<4; j1++)
-                                                    {
-                                                        UserWriteF("corner[%d]  ",j1);
-                                                        for(k1=0; k1<Tetrahedron.corners_of_side[j1]; k1++)
-                                                            {
-                                                                UserWriteF("_%05d",
-                                                                           Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Tetrahedron.corner_of_side[j1][k1]]);
-                                                            }
-                                                        UserWriteF("\n");
-                                                    }
-                                                UserWriteF("\n");
-                                                
-                                            }
-                                        
-                                        
-                                        
-                                        Mesh->nElements[sd]++;			
-                                    }
-				    else if (flag[j] == 2) {
-                                        Mesh->Element_corners[sd][Mesh->nElements[sd]] = 4;
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = 
-                                            (INT *) GetTmpMem(Heap,4*sizeof(INT),MarkKey);
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][0]=
-                                            corner[i][Hexahedron.corner_of_side[j][0]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][2]=
-                                            corner[i][Hexahedron.corner_of_side[j][1]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][1]=
-                                            corner[i][Hexahedron.corner_of_side[j][3]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][3] =
-                                            Mesh->nInnP;
-                                        
-                                        if(0)
-                                            {
-                                                INT j1,k1;
-                                                
-                                                
-                                                UserWriteF("C repaired element[%d] flag %d\n",Mesh->nElements[sd],flag[j]);
-                                                for (j1=0; j1<4; j1++)
-                                                    {
-                                                        UserWriteF("corner[%d]  ",j1);
-                                                        for(k1=0; k1<Tetrahedron.corners_of_side[j1]; k1++)
-                                                            {
-                                                                UserWriteF("_%05d",
-                                                                           Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Tetrahedron.corner_of_side[j1][k1]]);
-                                                            }
-                                                        UserWriteF("\n");
-                                                    }
-                                                UserWriteF("\n");
-                                                
-                                            }
-                                        
-                                        
-                                        
-                                        Mesh->nElements[sd]++;			
-                                        Mesh->Element_corners[sd][Mesh->nElements[sd]] = 4;
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = 
-                                            (INT *) GetTmpMem(Heap,4*sizeof(INT),MarkKey);
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][0]=
-                                            corner[i][Hexahedron.corner_of_side[j][1]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][2]=
-                                            corner[i][Hexahedron.corner_of_side[j][2]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][1]=
-                                            corner[i][Hexahedron.corner_of_side[j][3]];
-                                        Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][3] =
-                                            Mesh->nInnP;
-                                        
-                                        if(0)
-                                            {
-                                                INT j1,k1;
-                                                
-                                                
-                                                UserWriteF("D repaired element[%d] flag %d\n",Mesh->nElements[sd],flag[j]);
-                                                for (j1=0; j1<4; j1++)
-                                                    {
-                                                        UserWriteF("corner[%d]  ",j1);
-                                                        for(k1=0; k1<Tetrahedron.corners_of_side[j1]; k1++)
-                                                            {
-                                                                UserWriteF("_%05d",
-                                                                           Mesh->Element_corner_ids[sd][Mesh->nElements[sd]][Tetrahedron.corner_of_side[j1][k1]]);
-                                                            }
-                                                        UserWriteF("\n");
-                                                    }
-                                                UserWriteF("\n");
-                                                
-                                            }
-                                        
-                                        
-                                        
-                                        Mesh->nElements[sd]++;			
-                                    }
-				}
-                                Mesh->nInnP++;
-			}  
-			else {
-			    Mesh->Element_corners[sd][Mesh->nElements[sd]] = 8;  
-                            Mesh->Element_corner_ids[sd][Mesh->nElements[sd]] = corner[i];
-			    Mesh->nElements[sd]++;			
-			}
-		}
-	}
-
-    return(0);
-}
-#endif
diff -ruN ug-orig/dom/std/std_domain.c ug-patched/dom/std/std_domain.c
--- ug-orig/dom/std/std_domain.c	2006-06-02 18:11:18.000000000 +0200
+++ ug-patched/dom/std/std_domain.c	2010-07-11 21:36:58.000000000 +0200
@@ -46,6 +46,14 @@
 #include <assert.h>
 #include <math.h>
 
+/* standard C++ library */
+/* set needed in BVP_Init */
+#ifdef __cplusplus 
+#include <set>
+#else
+#define STDDOM_QUADRATIC_LINE_INSERTION
+#endif
+
 #include "domain.h"
 
 /* low modules */
@@ -109,1519 +117,49 @@
 /****************************************************************************/
 /*                                                                          */
 /* data structures used in this source file (exported data structures are   */
-/* in the corresponding include file!)                                      */
-/*                                                                          */
-/****************************************************************************/
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of exported global variables	                                 */
-/*                                                                          */
-/****************************************************************************/
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of variables global to this source file only (static!)	    */
-/*                                                                          */
-/****************************************************************************/
-
-static INT theProblemDirID;	/*!< env type for Problem dir                   */
-static INT theBdryCondVarID;	/*!<  env type for Problem vars                 */
-
-static INT theDomainDirID;	/*!<  env type for Domain dir                           */
-static INT theBdrySegVarID;	/*!<  env type for bdry segment vars            */
-static INT theLinSegVarID;	/*!<  env type for linear segment vars              */
-
-static INT theBVPDirID;		/*!<  env type for BVP dir                                      */
-
-static STD_BVP *currBVP;
-
-REP_ERR_FILE;
-
-/* RCS string */
-static char
-RCS_ID
-("$Header: /home/cvsroot/UG/ug/dom/std/std_domain.c,v 1.114 2006/06/02 16:11:18 sander Exp $",
-UG_RCS_STRING);
-
-/****************************************************************************/
-/*                                                                          */
-/* forward declarations of functions used before they are defined	    */
-/*                                                                          */
-/****************************************************************************/
-
-static INT BndPointGlobal (BNDP * aBndP, DOUBLE * global);
-static INT PatchGlobal (PATCH * p, DOUBLE * lambda, DOUBLE * global);
-
-/* Marc specials */
-
-#define MAX_LEN		200
-#ifdef __THREEDIM__
-#define PRISM_MOD
-#endif
-
-static char theLine[MAX_LEN + 1];
-static INT nCorners, nBndP, nElem, nPPatch, nLPatch, nTPatch, nPri, nFound;
-static INT Marc_Extended;
-
-static int
-ExpandLine (char *theLine)
-{
-  unsigned int i, j, k, l;
-
-  if (Marc_Extended)
-    {
-      i = 76;
-      j = 69;
-      for (l = 0; l < 3; l++)
-	{
-	  theLine[i] = ' ';
-	  i--;
-	  theLine[i] = theLine[j];
-	  i--;
-	  j--;
-	  theLine[i] = theLine[j];
-	  i--;
-	  j--;
-	  theLine[i] = 'e';
-	  i--;
-	  for (k = 0; k < 18; k++)
-	    {
-	      theLine[i] = theLine[j];
-	      i--;
-	      j--;
-	    }
-	}
-      theLine[i] = ' ';
-      /*printf("%s",theLine); */
-    }
-  else
-    {
-      i = 41;
-      j = 34;
-      for (l = 0; l < 3; l++)
-	{
-	  theLine[i] = ' ';
-	  i--;
-	  theLine[i] = theLine[j];
-	  i--;
-	  j--;
-	  theLine[i] = theLine[j];
-	  i--;
-	  j--;
-	  theLine[i] = 'e';
-	  i--;
-	  for (k = 0; k < 8; k++)
-	    {
-	      theLine[i] = theLine[j];
-	      i--;
-	      j--;
-	    }
-	}
-      theLine[i] = ' ';
-    }
-
-  for (i = 5; i < strlen (theLine); i++)
-    if (theLine[i] == '-')
-      if (theLine[i + 1] == 'e')
-	{
-	  theLine[i] = 'e';
-	  theLine[i + 1] = '-';
-	}
-
-  return (0);
-}
-
-static INT
-file_readline (FILE * f, char *key)
-{
-  INT len = strlen (key);
-
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-      if (strncmp (theLine, key, len) == 0)
-	return (0);
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-file_elements (FILE * f)
-{
-  int id, n, c[8];
-
-  nElem = 0;
-  nPri = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-      /*printf("%s",theLine); */
-
-      if (strlen (theLine) < 3)
-	continue;
-
-      if (Marc_Extended == 0)
-	{
-	  theLine[66] = 0;
-	  theLine[65] = ' ';
-	  theLine[64] = theLine[54];
-	  theLine[63] = theLine[53];
-	  theLine[62] = theLine[52];
-	  theLine[61] = theLine[51];
-	  theLine[60] = theLine[50];
-	  theLine[59] = ' ';
-	  theLine[58] = theLine[49];
-	  theLine[57] = theLine[48];
-	  theLine[56] = theLine[47];
-	  theLine[55] = theLine[46];
-	  theLine[54] = theLine[45];
-	  theLine[53] = ' ';
-	  theLine[52] = theLine[44];
-	  theLine[51] = theLine[43];
-	  theLine[50] = theLine[42];
-	  theLine[49] = theLine[41];
-	  theLine[48] = theLine[40];
-	  theLine[47] = ' ';
-	  theLine[46] = theLine[39];
-	  theLine[45] = theLine[38];
-	  theLine[44] = theLine[37];
-	  theLine[43] = theLine[36];
-	  theLine[42] = theLine[35];
-	  theLine[41] = ' ';
-	  theLine[40] = theLine[34];
-	  theLine[39] = theLine[33];
-	  theLine[38] = theLine[32];
-	  theLine[37] = theLine[31];
-	  theLine[36] = theLine[30];
-	  theLine[35] = ' ';
-	  theLine[34] = theLine[29];
-	  theLine[33] = theLine[28];
-	  theLine[32] = theLine[27];
-	  theLine[31] = theLine[26];
-	  theLine[30] = theLine[25];
-	  theLine[29] = ' ';
-	  theLine[28] = theLine[24];
-	  theLine[27] = theLine[23];
-	  theLine[26] = theLine[22];
-	  theLine[25] = theLine[21];
-	  theLine[24] = theLine[20];
-	  theLine[23] = ' ';
-	  theLine[22] = theLine[19];
-	  theLine[21] = theLine[18];
-	  theLine[20] = theLine[17];
-	  theLine[19] = theLine[16];
-	  theLine[18] = theLine[15];
-	  theLine[17] = ' ';
-	  theLine[16] = theLine[14];
-	  theLine[15] = theLine[13];
-	  theLine[14] = theLine[12];
-	  theLine[13] = theLine[11];
-	  theLine[12] = theLine[10];
-	  theLine[11] = ' ';
-	  theLine[10] = theLine[9];
-	  theLine[9] = theLine[8];
-	  theLine[8] = theLine[7];
-	  theLine[7] = theLine[6];
-	  theLine[6] = theLine[5];
-	  theLine[5] = ' ';
-	  theLine[4] = theLine[4];
-	  theLine[3] = theLine[3];
-	  theLine[2] = theLine[2];
-	  theLine[1] = theLine[1];
-	  theLine[0] = theLine[0];
-	}
-
-      if (sscanf (theLine, "%d %d", &id, &n) != 2)
-	return (0);
-
-      if (sscanf (theLine, "%d %d %d %d %d %d %d %d %d %d",
-		  &id, &n, c, c + 1, c + 2, c + 3, c + 4, c + 5, c + 6,
-		  c + 7) != 3 + n)
-	return (0);
-
-
-      if (c[0] == c[1])
-	if (c[4] == c[5])
-	  nPri++;
-
-      nElem++;
-
-      /* printf("file_elem %d %d %d %d %d\n",id,n,c[0],c[1],c[2]);  */
-
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-file_corners (FILE * f)
-{
-  int N, n, id, i;
-  double c[3];
-
-  fgets (theLine, MAX_LEN, f);
-
-  /* printf("%s",theLine);  */
-
-  if (Marc_Extended == 0)
-    {
-      theLine[12] = 0;
-      theLine[11] = ' ';
-      theLine[10] = theLine[9];
-      theLine[9] = theLine[8];
-      theLine[8] = theLine[7];
-      theLine[7] = theLine[6];
-      theLine[6] = theLine[5];
-      theLine[5] = ' ';
-      theLine[4] = theLine[4];
-      theLine[3] = theLine[3];
-      theLine[2] = theLine[2];
-      theLine[1] = theLine[1];
-      theLine[0] = theLine[0];
-    }
-
-  if (sscanf (theLine, "%d %d", &N, &n) != 2)
-    return (1);
-
-  nCorners = 0;
-  for (i = 0; i < n; i++)
-    {
-      fgets (theLine, MAX_LEN, f);
-
-      /* printf(" %d %s",i,theLine);  */
-
-      ExpandLine (theLine);
-
-      if (sscanf (theLine, "%d %lg %lg %lg", &id, c, c + 1, c + 2) != 1 + N)
-	return (0);
-      nCorners++;
-
-      /* printf("%d %f %f %f\n",id,c[0],c[1],c[2]); */
-    }
-
-  return (0);
-}
-
-static INT
-file_contact (FILE * f)
-{
-  int id, c;
-
-  /* fgets(theLine, MAX_LEN, f); */
-
-  nBndP = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-      if (sscanf (theLine, "%d %d", &id, &c) != 2)
-	return (0);
-      nBndP++;
-
-      /* printf("%d %d \n",id,c);  */
-
-    }
-  while (!feof (f));
-
-  UserWrite ("BVP: no contact\n");
-
-  return (0);
-}
-
-static INT
-file_triangles (FILE * f)
-{
-  int id, n, c[3];
-
-  nTPatch = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-      if (strlen (theLine) < 3)
-	continue;
-      if (sscanf (theLine, "%5d%5d%5d%5d%5d",
-		  &id, &n, c, c + 1, c + 2) != 2 + DIM)
-	return (0);
-      nTPatch++;
-
-      /*printf("%d %d %d %d %d\n",id,n,c[0],c[1],c[2]); */
-
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-file_positions (FILE * f)
-{
-  int id;
-  double c[3];
-
-  fgets (theLine, MAX_LEN, f);
-
-  nPPatch = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-
-      ExpandLine (theLine);
-
-      if (sscanf (theLine, "%d %lg %lg %lg", &id, c, c + 1, c + 2) != 1 + DIM)
-	return (0);
-
-      nPPatch++;
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-Marc_GetPosition (MESH * Mesh, INT i, DOUBLE * x)
-{
-  INT k;
-
-  if (i < nBndP)
-    {
-      M_BNDP *p = (M_BNDP *) Mesh->theBndPs[i];
-
-      for (k = 0; k < DIM; k++)
-	x[k] = p->pos[k];
-    }
-  else
-    for (k = 0; k < DIM; k++)
-      x[k] = Mesh->Position[i - nBndP][k];
-  /*printf("i %6d nBndP %d x %6.3f %6.3f %6.3f\n",i,nBndP,x[0],x[1],x[2]); */
-
-  return (0);
-}
-
-static INT
-file_elements_fill (FILE * f, HEAP * Heap, MESH * Mesh, INT MarkKey)
-{
-  int id, n, i, c[8], c0, c1, c2, c3, c4, c5, c6, c7;
-
-  nElem = 0;
-  nPri = 0;
-  nFound = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-      if (strlen (theLine) < 3)
-	continue;
-
-      if (Marc_Extended == 0)
-	{
-	  theLine[66] = 0;
-	  theLine[65] = ' ';
-	  theLine[64] = theLine[54];
-	  theLine[63] = theLine[53];
-	  theLine[62] = theLine[52];
-	  theLine[61] = theLine[51];
-	  theLine[60] = theLine[50];
-	  theLine[59] = ' ';
-	  theLine[58] = theLine[49];
-	  theLine[57] = theLine[48];
-	  theLine[56] = theLine[47];
-	  theLine[55] = theLine[46];
-	  theLine[54] = theLine[45];
-	  theLine[53] = ' ';
-	  theLine[52] = theLine[44];
-	  theLine[51] = theLine[43];
-	  theLine[50] = theLine[42];
-	  theLine[49] = theLine[41];
-	  theLine[48] = theLine[40];
-	  theLine[47] = ' ';
-	  theLine[46] = theLine[39];
-	  theLine[45] = theLine[38];
-	  theLine[44] = theLine[37];
-	  theLine[43] = theLine[36];
-	  theLine[42] = theLine[35];
-	  theLine[41] = ' ';
-	  theLine[40] = theLine[34];
-	  theLine[39] = theLine[33];
-	  theLine[38] = theLine[32];
-	  theLine[37] = theLine[31];
-	  theLine[36] = theLine[30];
-	  theLine[35] = ' ';
-	  theLine[34] = theLine[29];
-	  theLine[33] = theLine[28];
-	  theLine[32] = theLine[27];
-	  theLine[31] = theLine[26];
-	  theLine[30] = theLine[25];
-	  theLine[29] = ' ';
-	  theLine[28] = theLine[24];
-	  theLine[27] = theLine[23];
-	  theLine[26] = theLine[22];
-	  theLine[25] = theLine[21];
-	  theLine[24] = theLine[20];
-	  theLine[23] = ' ';
-	  theLine[22] = theLine[19];
-	  theLine[21] = theLine[18];
-	  theLine[20] = theLine[17];
-	  theLine[19] = theLine[16];
-	  theLine[18] = theLine[15];
-	  theLine[17] = ' ';
-	  theLine[16] = theLine[14];
-	  theLine[15] = theLine[13];
-	  theLine[14] = theLine[12];
-	  theLine[13] = theLine[11];
-	  theLine[12] = theLine[10];
-	  theLine[11] = ' ';
-	  theLine[10] = theLine[9];
-	  theLine[9] = theLine[8];
-	  theLine[8] = theLine[7];
-	  theLine[7] = theLine[6];
-	  theLine[6] = theLine[5];
-	  theLine[5] = ' ';
-	  theLine[4] = theLine[4];
-	  theLine[3] = theLine[3];
-	  theLine[2] = theLine[2];
-	  theLine[1] = theLine[1];
-	  theLine[0] = theLine[0];
-	}
-
-      if (sscanf (theLine, "%d %d", &id, &n) != 2)
-	return (0);
-
-      if (sscanf (theLine, "%d %d %d %d %d %d %d %d %d %d",
-		  &id, &n, &c0, &c1, &c2, &c3, &c4, &c5, &c6, &c7) != 3 + n)
-	return (0);
-
-      c[0] = c0;
-      c[1] = c1;
-      c[2] = c2;
-      c[3] = c3;
-      c[4] = c4;
-      c[5] = c5;
-      c[6] = c6;
-      c[7] = c7;
-
-      if (Mesh != NULL)
-	if (c[0] == c[1])
-	  {
-	    if (c[4] != c[5])
-	      return (1);
-	    Mesh->Element_corners[1][nElem] = 6;
-	    Mesh->Element_corner_ids[1][nElem][0] = c[0] - 1;
-	    Mesh->Element_corner_ids[1][nElem][1] = c[2] - 1;
-	    Mesh->Element_corner_ids[1][nElem][2] = c[3] - 1;
-	    Mesh->Element_corner_ids[1][nElem][3] = c[4] - 1;
-	    Mesh->Element_corner_ids[1][nElem][4] = c[6] - 1;
-	    Mesh->Element_corner_ids[1][nElem][5] = c[7] - 1;
-
-	    nPri++;
-
-#ifdef PRISM_MOD
-
-	    if ((nPri % 2) == 0)
-	      {
-		INT l, d[6];
-		DOUBLE_VECTOR pos;
-
-		for (l = 0; l < 6; l++)
-		  d[l] = Mesh->Element_corner_ids[1][nElem - 1][l];
-		c[0] = c[0] - 1;
-		c[1] = c[2] - 1;
-		c[2] = c[3] - 1;
-		c[3] = c[4] - 1;
-		c[4] = c[6] - 1;
-		c[5] = c[7] - 1;
-
-		Marc_GetPosition (Mesh, d[0], pos);
-		for (l = 0; l < DIM; l++)
-		  Mesh->Position[nCorners - nBndP][l] = 0.25 * pos[l];
-		Marc_GetPosition (Mesh, d[1], pos);
-		for (l = 0; l < DIM; l++)
-		  Mesh->Position[nCorners - nBndP][l] += 0.25 * pos[l];
-		Marc_GetPosition (Mesh, d[3], pos);
-		for (l = 0; l < DIM; l++)
-		  Mesh->Position[nCorners - nBndP][l] += 0.25 * pos[l];
-		Marc_GetPosition (Mesh, d[4], pos);
-		for (l = 0; l < DIM; l++)
-		  Mesh->Position[nCorners - nBndP][l] += 0.25 * pos[l];
-
-
-		IFDEBUG (dom, 2)
-		  assert (Mesh->Element_corners[1][nElem - 1] == 6);
-
-		for (l = 0; l < nElem; l++)
-		  if (Mesh->Element_corners[1][l] == 8)
-		    if (CheckPrisms (Mesh->Element_corner_ids[1][l],
-				     Mesh->Element_corner_ids[1][nElem -
-								 1][2],
-				     Mesh->Element_corner_ids[1][nElem -
-								 1][1],
-				     Mesh->Element_corner_ids[1][nElem][1],
-				     Mesh->Element_corner_ids[1][nElem -
-								 1][0]))
-		      nFound++;
-		assert (Mesh->Element_corner_ids[1][nElem - 1][0]
-			== Mesh->Element_corner_ids[1][nElem][0]);
-		assert (Mesh->Element_corner_ids[1][nElem - 1][3]
-			== Mesh->Element_corner_ids[1][nElem][3]);
-		assert (Mesh->Element_corner_ids[1][nElem - 1][1]
-			== Mesh->Element_corner_ids[1][nElem][2]);
-		assert (Mesh->Element_corner_ids[1][nElem - 1][4]
-			== Mesh->Element_corner_ids[1][nElem][5]);
-		ENDDEBUG nElem--;
-
-		Mesh->Element_corners[1][nElem] = 5;
-		Mesh->Element_corner_ids[1][nElem][0] = c[0];
-		Mesh->Element_corner_ids[1][nElem][1] = c[1];
-		Mesh->Element_corner_ids[1][nElem][2] = c[2];
-		Mesh->Element_corner_ids[1][nElem][3] = d[2];
-		Mesh->Element_corner_ids[1][nElem][4] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 5;
-		Mesh->Element_corner_ids[1][nElem][0] = d[0];
-		Mesh->Element_corner_ids[1][nElem][1] = d[2];
-		Mesh->Element_corner_ids[1][nElem][2] = d[5];
-		Mesh->Element_corner_ids[1][nElem][3] = d[3];
-		Mesh->Element_corner_ids[1][nElem][4] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 5;
-		Mesh->Element_corner_ids[1][nElem][0] = d[5];
-		Mesh->Element_corner_ids[1][nElem][1] = d[2];
-		Mesh->Element_corner_ids[1][nElem][2] = d[1];
-		Mesh->Element_corner_ids[1][nElem][3] = d[4];
-		Mesh->Element_corner_ids[1][nElem][4] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 5;
-		Mesh->Element_corner_ids[1][nElem][0] = c[0];
-		Mesh->Element_corner_ids[1][nElem][1] = c[3];
-		Mesh->Element_corner_ids[1][nElem][2] = c[4];
-		Mesh->Element_corner_ids[1][nElem][3] = c[1];
-		Mesh->Element_corner_ids[1][nElem][4] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 5;
-		Mesh->Element_corner_ids[1][nElem][0] = c[1];
-		Mesh->Element_corner_ids[1][nElem][1] = c[4];
-		Mesh->Element_corner_ids[1][nElem][2] = c[5];
-		Mesh->Element_corner_ids[1][nElem][3] = c[2];
-		Mesh->Element_corner_ids[1][nElem][4] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 4;
-		Mesh->Element_corner_ids[1][nElem][0] = d[3];
-		Mesh->Element_corner_ids[1][nElem][1] = d[5];
-		Mesh->Element_corner_ids[1][nElem][2] = d[4];
-		Mesh->Element_corner_ids[1][nElem][3] = nCorners;
-		nElem++;
-		Mesh->Element_corners[1][nElem] = 4;
-		Mesh->Element_corner_ids[1][nElem][0] = c[3];
-		Mesh->Element_corner_ids[1][nElem][1] = c[5];
-		Mesh->Element_corner_ids[1][nElem][2] = c[4];
-		Mesh->Element_corner_ids[1][nElem][3] = nCorners;
-
-		nCorners++;
-
-
-	      }
-#endif
-	  }
-	else
-	  {
-	    Mesh->Element_corners[1][nElem] = n + 1;
-	    for (i = 0; i <= n; i++)
-	      Mesh->Element_corner_ids[1][nElem][i] = c[i] - 1;
-	  }
-      nElem++;
-
-/*		printf("%d %d %d %d %d\n",id,n,c[0],c[1],c[2]); */
-
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-file_corners_fill (FILE * f, HEAP * Heap, MESH * Mesh, INT MarkKey,
-		   DOUBLE * radius, DOUBLE * midpoint)
-{
-  int N, n, id, i, j;
-  double c[3], s;
-
-  fgets (theLine, MAX_LEN, f);
-  /* printf("%s",theLine); */
-
-  if (Marc_Extended == 0)
-    {
-      theLine[12] = 0;
-      theLine[11] = ' ';
-      theLine[10] = theLine[9];
-      theLine[9] = theLine[8];
-      theLine[8] = theLine[7];
-      theLine[7] = theLine[6];
-      theLine[6] = theLine[5];
-      theLine[5] = ' ';
-      theLine[4] = theLine[4];
-      theLine[3] = theLine[3];
-      theLine[2] = theLine[2];
-      theLine[1] = theLine[1];
-      theLine[0] = theLine[0];
-    }
-
-  if (sscanf (theLine, "%d %d", &N, &n) != 2)
-    return (1);
-
-  nCorners = n;
-
-  for (j = 0; j < 3; j++)
-    midpoint[j] = 0.0;
-
-  for (i = 0; i < n; i++)
-    {
-      fgets (theLine, MAX_LEN, f);
-
-      /* printf("in\n%s\n",theLine); */
-
-      ExpandLine (theLine);
-
-      if (sscanf (theLine, "%d %lg %lg %lg", &id, c, c + 1, c + 2) != 1 + N)
-	return (0);
-
-      if (i < nBndP)
-	for (j = 0; j < DIM; j++)
-	  midpoint[j] += c[j];
-
-      if (Mesh != NULL)
-	{
-	  if (i < nBndP)
-	    {
-	      M_BNDP *p = (M_BNDP *) Mesh->theBndPs[i];
-
-	      /* TODO remove  */
-	      M0_PATCH *patch = (M0_PATCH *) currBVP->patches[i];
-
-	      patch->type = MARC_0_PATCH_TYPE;
-	      patch->id = i;
-	      for (j = 0; j < DIM; j++)
-		patch->pos[j] = c[j];
-	      /*   */
-
-	      p->patch_id = i;
-	      for (j = 0; j < DIM; j++)
-		p->pos[j] = c[j];
-	    }
-	  else
-	    for (j = 0; j < 3; j++)
-	      Mesh->Position[i - nBndP][j] = c[j];
-	}
-      /* printf("%d %f %f %f\n",id,c[0],c[1],c[2]);  */
-    }
-  s = 1.0 / nBndP;
-  for (j = 0; j < DIM; j++)
-    midpoint[j] *= s;
-  if (Mesh != NULL)
-    {
-      *radius = 0.0;
-      for (i = 0; i < nBndP; i++)
-	{
-	  M_BNDP *p = (M_BNDP *) Mesh->theBndPs[i];
-
-	  for (j = 0; j < DIM; j++)
-	    *radius = MAX (*radius, fabs (midpoint[j] - p->pos[j]));
-	}
-    }
-  else
-    {
-      *radius = 0.0;
-      for (j = 0; j < DIM; j++)
-	*radius += ABS (midpoint[j]);
-    }
-
-  return (0);
-}
-
-static INT
-file_contact_fill (FILE * f, HEAP * Heap, MESH * Mesh, INT MarkKey)
-{
-  int id, c;
-
-  /* TODO: adapt for surface mesh */
-  return (0);
-
-/*	fgets(theLine, MAX_LEN, f); */
-
-  if (Mesh == NULL)
-    return (0);
-
-  nBndP = 0;
-  do
-    {
-      M_BNDP *p = (M_BNDP *) Mesh->theBndPs[nBndP];
-
-      fgets (theLine, MAX_LEN, f);
-      if (sscanf (theLine, "%d %d", &id, &c) != 2)
-	return (0);
-      nBndP++;
-
-      p->patch_id = nPPatch + c - 1;
-
-      /* printf("%d %d \n",id,c);  */
-
-    }
-  while (!feof (f));
-
-  UserWrite ("BVP: no contact\n");
-
-  return (0);
-}
-
-static INT
-file_triangles_fill (FILE * f, HEAP * Heap, MESH * Mesh, INT MarkKey)
-{
-  int id, n, i, c[3];
-
-  nTPatch = 0;
-  do
-    {
-      M2_PATCH *p = (M2_PATCH *) currBVP->patches[nPPatch + nTPatch];
-
-      fgets (theLine, MAX_LEN, f);
-      if (strlen (theLine) < 3)
-	continue;
-      if (sscanf (theLine, "%5d%5d%5d%5d%5d",
-		  &id, &n, c, c + 1, c + 2) != 2 + DIM)
-	return (0);
-
-      p->type = MARC_2_PATCH_TYPE;
-      p->c = n;
-      p->id = nTPatch + nPPatch;
-      for (i = 0; i < 3; i++)
-	p->p[i] = c[i] - 1;
-
-      nTPatch++;
-
-      /* printf("%d id %d %d %d %d %d\n",id,p->id,n,c[0],c[1],c[2]); */
-
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-file_positions_fill (FILE * f, HEAP * Heap, MESH * Mesh, INT MarkKey)
-{
-  int id, j;
-  double c[3];
-  M0_PATCH *p;
-
-  /** \todo adapt for surface mesh */
-  return (0);
-
-  fgets (theLine, MAX_LEN, f);
-  nPPatch = 0;
-  do
-    {
-      fgets (theLine, MAX_LEN, f);
-
-      ExpandLine (theLine);
-
-      if (sscanf (theLine, "%d %lg %lg %lg", &id, c, c + 1, c + 2) != 1 + DIM)
-	return (0);
-
-      p = (M0_PATCH *) currBVP->patches[nPPatch];
-      p->type = MARC_0_PATCH_TYPE;
-      p->id = nPPatch;
-      for (j = 0; j < 3; j++)
-	p->pos[j] = c[j];
-
-      nPPatch++;
-
-      /* printf("%d %f %f %f nP %d\n",id,c[0],c[1],c[2],nPPatch); */
-
-    }
-  while (!feof (f));
-
-  return (1);
-}
-
-static INT
-Marc_Configure (INT argc, char **argv)
-{
-  STD_BVP *theBVP;
-  char BVPName[NAMESIZE];
-  INT i;
-  char name[NAMESIZE];
-
-  /* get BVP name */
-  if ((sscanf
-       (argv[0], expandfmt (CONCAT3 (" configure %", NAMELENSTR, "[ -~]")),
-	BVPName) != 1) || (strlen (BVPName) == 0))
-    {
-      for (i = 0; i < argc; i++)
-	if (argv[i][0] == 'b')
-	  if ((sscanf
-	       (argv[i], expandfmt (CONCAT3 ("b %", NAMELENSTR, "[ -~]")),
-		BVPName) == 1) && (strlen (BVPName) > 0))
-	    break;
-      if (i >= argc)
-	RETURN (1);
-    }
-  theBVP = (STD_BVP *) BVP_GetByName (BVPName);
-  if (theBVP == NULL)
-    RETURN (1);
-
-  for (i = 1; i < argc; i++)
-    {
-      if (argv[i][0] == 'm')
-	{
-	  if (sscanf (argv[i], "mesh %s", name) != 1)
-	    continue;
-	  strcpy (theBVP->mesh_file, name);
-	}
-      if (argv[i][0] == 'b')
-	{
-	  if (sscanf (argv[i], "bnd %s", name) != 1)
-	    continue;
-	  strcpy (theBVP->bnd_file, name);
-	}
-    }
-
-  return (0);
-}
-
-static BVP *
-Init_MarcBVP (STD_BVP * theBVP, HEAP * Heap, MESH * Mesh, INT MarkKey)
-{
-  FILE *stream;
-  INT i;
-
-  currBVP = theBVP;
-#ifdef ModelP
-  SetBVPType (theBVP->type);
-#endif
-  STD_BVP_NDOMPART (theBVP) = 1;
-  STD_BVP_NSUBDOM (theBVP) = 1;
-  STD_BVP_S2P_PTR (theBVP) = (INT *)
-    GetFreelistMemory (Heap, (1 + STD_BVP_NSUBDOM (theBVP)) * sizeof (INT));
-  if (STD_BVP_S2P_PTR (theBVP) == NULL)
-    return (NULL);
-  STD_BVP_S2P_PTR (theBVP)[0] = 0;
-  STD_BVP_S2P_PTR (theBVP)[1] = 0;
-
-#ifdef ModelP
-  if (me == 0)
-    {
-#endif
-
-      nPPatch = nLPatch = nTPatch = 0;
-
-      /* read numbers of objects */
-      stream = fileopen (theBVP->mesh_file, "r");
-      if (stream == NULL)
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not open file");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_readline (stream, "extended"))
-	{
-	  Marc_Extended = 0;
-	  fclose (stream);
-	  stream = fileopen (theBVP->mesh_file, "r");
-	}
-      else
-	{
-	  Marc_Extended = 1;
-	}
-      if (file_readline (stream, "connectivity"))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP",
-			     "could not read connectivity");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_elements (stream))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not read element");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_corners (stream))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not read corners");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_readline (stream, "surface"))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not read surface");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_contact (stream))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not read contact");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      fclose (stream);
-      stream = fileopen (theBVP->bnd_file, "r");
-      if (stream == NULL)
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not open file");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_readline (stream, "connectivity"))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP",
-			     "could not store connectivity");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_triangles (stream))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not store surface");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_positions (stream))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP",
-			     "could not store positions");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      fclose (stream);
-
-      PRINTDEBUG (dom, 1,
-		  ("A: nCorners %d nBndP %d nElem %d nPPatch %d nTPatch %d nPri %d\n",
-		   nCorners, nBndP, nElem, nPPatch, nTPatch, nPri));
-
-#ifdef PRISM_MOD
-      nPri = nPri / 2;
-      nElem += 5 * nPri;
-      nCorners += nPri;
-#endif
-
-      nPPatch = MAX (nPPatch, nBndP);
-
-#ifdef ModelP
-    }
-  Broadcast (&nCorners, sizeof (INT));
-  Broadcast (&nBndP, sizeof (INT));
-  Broadcast (&nElem, sizeof (INT));
-  Broadcast (&nPPatch, sizeof (INT));
-  Broadcast (&nTPatch, sizeof (INT));
-#endif
-
-  /* fill mesh and patch infos */
-  if (Mesh != NULL)
-    {
-      Mesh->mesh_status = MESHSTAT_MESH;
-      Mesh->nBndP = nBndP;
-      Mesh->theBndPs =
-	(BNDP **) GetTmpMem (Heap, nBndP * sizeof (M_BNDP *), MarkKey);
-      if (Mesh->theBndPs == NULL)
-	REP_ERR_RETURN_PTR (NULL);
-      for (i = 0; i < nBndP; i++)
-	{
-	  Mesh->theBndPs[i] =
-	    (BNDP *) GetFreelistMemory (Heap, sizeof (M_BNDP));
-	  if (Mesh->theBndPs[i] == NULL)
-	    REP_ERR_RETURN_PTR (NULL);
-	}
-      Mesh->nInnP = nCorners - nBndP;
-      Mesh->Position = (DOUBLE **)
-	GetTmpMem (Heap, (nCorners - nBndP) * sizeof (DOUBLE *), MarkKey);
-      if (nCorners > nBndP)
-	if (Mesh->Position == NULL)
-	  REP_ERR_RETURN_PTR (NULL);
-      for (i = 0; i < nCorners - nBndP; i++)
-	{
-	  Mesh->Position[i] = (DOUBLE *)
-	    GetTmpMem (Heap, 3 * sizeof (DOUBLE), MarkKey);
-	  if (Mesh->Position[i] == NULL)
-	    REP_ERR_RETURN_PTR (NULL);
-	}
-      Mesh->nSubDomains = 1;
-      Mesh->nSides = NULL;
-      Mesh->Side_corners = NULL;
-      Mesh->xy_Side = NULL;
-      Mesh->Side_corner_ids = NULL;
-      Mesh->nElements = (INT *)
-	GetTmpMem (Heap, (Mesh->nSubDomains + 1) * sizeof (INT), MarkKey);
-      Mesh->nElements[0] = 0;
-      Mesh->nElements[1] = nElem;
-      Mesh->Element_corners = (INT **)
-	GetTmpMem (Heap, (Mesh->nSubDomains + 1) * sizeof (INT), MarkKey);
-      Mesh->Element_corners[0] = NULL;
-      Mesh->Element_corners[1] = (INT *)
-	GetTmpMem (Heap, nElem * sizeof (INT), MarkKey);
-      for (i = 0; i < nElem; i++)
-	Mesh->Element_corners[1][i] = 8;
-      Mesh->Element_corner_ids = (INT ***)
-	GetTmpMem (Heap, (Mesh->nSubDomains + 1) * sizeof (INT **), MarkKey);
-      Mesh->Element_corner_ids[0] = NULL;
-      Mesh->Element_corner_ids[1] = (INT **)
-	GetTmpMem (Heap, nElem * sizeof (INT *), MarkKey);
-      for (i = 0; i < nElem; i++)
-	{
-	  Mesh->Element_corner_ids[1][i] = (INT *)
-	    GetTmpMem (Heap, Mesh->Element_corners[1][i] * sizeof (INT),
-		       MarkKey);
-	}
-      Mesh->nbElements = NULL;
-      Mesh->ElemSideOnBnd = NULL;
-
-      /* parallel part */
-      Mesh->VertexLevel = NULL;
-      Mesh->VertexPrio = NULL;
-      Mesh->ElementLevel = NULL;
-      Mesh->ElementPrio = NULL;
-    }
-  theBVP->patches = (PATCH **)
-    GetFreelistMemory (Heap, (nPPatch + nTPatch) * sizeof (PATCH *));
-  for (i = 0; i < nPPatch; i++)
-    {
-      M0_PATCH *patch =
-	(M0_PATCH *) GetFreelistMemory (Heap, sizeof (M0_PATCH));
-
-      patch->type = MARC_0_PATCH_TYPE;
-      patch->id = i;
-      theBVP->patches[i] = (PATCH *) patch;
-    }
-  for (i = nPPatch; i < nPPatch + nLPatch; i++)
-    theBVP->patches[i] = (PATCH *)
-      GetFreelistMemory (Heap, sizeof (M1_PATCH));
-  for (i = nPPatch + nLPatch; i < nPPatch + nLPatch + nTPatch; i++)
-    theBVP->patches[i] = (PATCH *)
-      GetFreelistMemory (Heap, sizeof (M2_PATCH));
-  currBVP->sideoffset = nPPatch + nLPatch;
-
-  PRINTDEBUG (dom, 1,
-	      ("B: nCorners %d nBndP %d nElem %d nPPatch %d nTPatch %d\n",
-	       nCorners, nBndP, nElem, nPPatch, nTPatch));
-
-#ifdef ModelP
-  if (me == 0)
-    {
-#endif
-
-      stream = fileopen (theBVP->bnd_file, "r");
-      if (stream == NULL)
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_readline (stream, "connectivity"))
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_triangles_fill (stream, Heap, Mesh, MarkKey))
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_positions_fill (stream, Heap, Mesh, MarkKey))
-	REP_ERR_RETURN_PTR (NULL);
-
-      fclose (stream);
-
-      stream = fileopen (theBVP->mesh_file, "r");
-      if (stream == NULL)
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_readline (stream, "coordinates"))
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_corners_fill (stream, Heap, Mesh, MarkKey,
-			     &(theBVP->radius), theBVP->MidPoint))
-	REP_ERR_RETURN_PTR (NULL);
-
-      fclose (stream);
-
-      stream = fileopen (theBVP->mesh_file, "r");
-      if (stream == NULL)
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_readline (stream, "connectivity"))
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_elements_fill (stream, Heap, Mesh, MarkKey))
-	REP_ERR_RETURN_PTR (NULL);
-
-      if (file_readline (stream, "surface"))
-	{
-	  PrintErrorMessage ('F', "Init_MarcBVP", "could not read surface");
-	  REP_ERR_RETURN_PTR (NULL);
-	}
-      if (file_contact_fill (stream, Heap, Mesh, MarkKey))
-	REP_ERR_RETURN_PTR (NULL);
-
-      fclose (stream);
-
-      /*
-         #ifdef __THREEDIM__
-         if (Mesh != NULL)
-         RepairMesh(Heap,MarkKey,Mesh);
-         #endif
-       */
-
-#ifdef ModelP
-    }
-  for (i = 0; i < nPPatch; i++)
-    Broadcast (theBVP->patches[i], sizeof (M0_PATCH));
-  for (i = nPPatch; i < nPPatch + nLPatch; i++)
-    Broadcast (theBVP->patches[i], sizeof (M1_PATCH));
-  for (i = nPPatch + nLPatch; i < nPPatch + nLPatch + nTPatch; i++)
-    Broadcast (theBVP->patches[i], sizeof (M2_PATCH));
-  Broadcast (&(theBVP->radius), sizeof (DOUBLE));
-  Broadcast (theBVP->MidPoint, DIM * sizeof (DOUBLE));
-#endif
-
-  STD_BVP_NDOMPART (theBVP) = 1;
-  STD_BVP_NSUBDOM (theBVP) = 1;
-  STD_BVP_S2P_PTR (theBVP) = (INT *)
-    GetFreelistMemory (Heap, (1 + STD_BVP_NSUBDOM (theBVP)) * sizeof (INT));
-  if (STD_BVP_S2P_PTR (theBVP) == NULL)
-    REP_ERR_RETURN_PTR (NULL);
-  STD_BVP_S2P_PTR (theBVP)[0] = 0;
-  STD_BVP_S2P_PTR (theBVP)[1] = 0;
-
-
-  PRINTDEBUG (dom, 1,
-	      ("C: nCorners %d nBndP %d nElem %d nPPatch %d nTPatch %d nFound %d\n",
-	       nCorners, nBndP, nElem, nPPatch, nTPatch, nFound));
-
-  return ((BVP *) theBVP);
-}
-
-static INT
-M_BNDP_Global (BNDP * bp, DOUBLE * global)
-{
-  M_BNDP *p = (M_BNDP *) bp;
-  INT j;
-
-  for (j = 0; j < DIM; j++)
-    global[j] = p->pos[j];
-
-  return (0);
-}
-
-static INT
-M_BNDP_Move (BNDP * aBndP, const DOUBLE global[])
-{
-  printf ("not implemented line %d\n", __LINE__);
-
-  return (1);
-}
-
-static INT
-M_BNDP_BndCond (BNDP * theBndP, INT * n, INT i,
-		DOUBLE * in, DOUBLE * value, INT * type)
-{
-  printf ("not implemented line %d\n", __LINE__);
-
-  return (1);
-}
-
-static INT
-M_BNDP_BndPDesc (BNDP * theBndP, INT * move, INT * part)
-{
-  *move = 0;
-  *part = 0;
-
-  return (0);
-}
-
-static INT
-M_BNDP_BndEDesc (BNDP * theBndP0, BNDP * theBndP1, INT * part)
-{
-  *part = 0;
-
-  return (0);
-}
-
-static BNDS *
-M_BNDP_CreateBndS (HEAP * Heap, BNDP ** theBndP, INT n)
-{
-  M_BNDS *p = (M_BNDS *) GetFreelistMemory (Heap, M_BNDS_NSIZE (n));
-  INT i, j;
-
-  for (i = 0; i < n; i++)
-    {
-      M_BNDP *b = (M_BNDP *) theBndP[i];
-      p->p[i].patch_id = b->patch_id;
-      for (j = 0; j < DIM; j++)
-	p->p[i].pos[j] = b->pos[j];
-    }
-  p->n = n;
-
-  return ((BNDS *) p);
-}
-
-#ifdef __THREEDIM__
-/*#define CYLINDER */
-#define BENCHMARK
-#endif
-
-static BNDP *
-M_BNDP_CreateBndP (HEAP * Heap, BNDP * theBndP0,
-		   BNDP * theBndP1, DOUBLE lcoord)
-{
-  M_BNDP *p0 = (M_BNDP *) theBndP0;
-  M_BNDP *p1 = (M_BNDP *) theBndP1;
-  M_BNDP *p = (M_BNDP *) GetFreelistMemory (Heap, sizeof (M_BNDP));
-  INT j;
-
-  ASSERT (p != NULL);
-
-  for (j = 0; j < DIM; j++)
-    p->pos[j] = (1.0 - lcoord) * p0->pos[j] + lcoord * p1->pos[j];
-#ifdef CYLINDER
-  {
-    DOUBLE r0 = p0->pos[0] * p0->pos[0] + p0->pos[1] * p0->pos[1];
-    DOUBLE r1 = p1->pos[0] * p1->pos[0] + p1->pos[1] * p1->pos[1];
-
-    if ((r1 > 0.01) && (ABS (r1 - r0) < 0.01))
-      {
-	DOUBLE r = p->pos[0] * p->pos[0] + p->pos[1] * p->pos[1];
-	DOUBLE s = sqrt (r1 / r);
-
-	p->pos[0] *= s;
-	p->pos[1] *= s;
-      }
-  }
-#endif
-#ifdef BENCHMARK
-  {
-    DOUBLE r0 =
-      (p0->pos[0] - 10) * (p0->pos[0] - 10) + p0->pos[1] * p0->pos[1];
-    DOUBLE r1 =
-      (p1->pos[0] - 10) * (p1->pos[0] - 10) + p1->pos[1] * p1->pos[1];
-
-    if ((r1 > 0.01) && (ABS (r1 - r0) < 0.01))
-      {
-	DOUBLE r =
-	  (p->pos[0] - 10) * (p->pos[0] - 10) + p->pos[1] * p->pos[1];
-	DOUBLE s = sqrt (r1 / r);
-
-	p->pos[0] = 10 + s * (p->pos[0] - 10);
-	p->pos[1] *= s;
-      }
-  }
-#endif
-
-  return ((BNDP *) p);
-}
-
-static INT
-M_BNDP_Dispose (HEAP * Heap, BNDP * theBndP)
-{
-  return (PutFreelistMemory (Heap, theBndP, sizeof (M_BNDP)));
-}
-
-static INT
-M_BNDP_SaveBndP (BNDP * theBndP)
-{
-  M_BNDP *p = (M_BNDP *) theBndP;
-  INT j;
-  int iList[1];
-  double dList[DIM];
-
-  iList[0] = p->patch_id;
-  if (Bio_Write_mint (1, iList))
-    return (1);
-
-  for (j = 0; j < DIM; j++)
-    dList[j] = p->pos[j];
-  if (Bio_Write_mdouble (DIM, dList))
-    return (1);
-
-  return (0);
-}
-
-static INT
-M_BNDP_SaveInsertedBndP (BNDP * theBndP, char *data, INT max_data_size)
-{
-  printf ("not implemented line %d\n", __LINE__);
-
-  return (1);
-}
-
-static BNDP *
-M_BNDP_LoadBndP (BVP * theBVP, HEAP * Heap)
-{
-  M_BNDP *p = (M_BNDP *) GetFreelistMemory (Heap, sizeof (M_BNDP));
-  INT j;
-  int iList[1];
-  double dList[DIM];
-
-  if (Bio_Read_mint (1, iList))
-    return (NULL);
-  p->patch_id = iList[0];
-  if (Bio_Read_mdouble (DIM, dList))
-    return (NULL);
-
-  for (j = 0; j < DIM; j++)
-    p->pos[j] = dList[j];
-
-  return ((BNDP *) p);
-}
-
-static INT
-M_BNDS_Global (BNDS * theBndS, DOUBLE * local, DOUBLE * global)
-{
-  M_BNDS *p = (M_BNDS *) theBndS;
-  INT i;
-
-#ifdef __TWODIM__
-  for (i = 0; i < DIM; i++)
-    global[i] = (1.0 - local[0]) * p->p[0].pos[i] + local[0] * p->p[1].pos[i];
-#endif
-#ifdef __THREEDIM__
-  if (p->n == 4)
-    for (i = 0; i < DIM; i++)
-      global[i] = (1.0 - local[0]) * (1.0 - local[1]) * p->p[0].pos[i]
-    + local[0] * (1.0 - local[1]) * p->p[1].pos[i]
-    + local[0] * local[1] * p->p[2].pos[i]
-    + (1.0 - local[0]) * local[1] * p->p[3].pos[i];
-  else
-if (p->n == 3)
-  for (i = 0; i < DIM; i++)
-    global[i] = (1.0 - local[0] - local[1]) * p->p[0].pos[i]
-    + local[0] * p->p[1].pos[i] + local[1] * p->p[2].pos[i];
-#endif
-
-#ifdef CYLINDER
-  {
-    DOUBLE r[4];
-    INT flag = 1;
-
-    if (p->n != 4)
-      return (0);
-    for (i = 0; i < p->n; i++)
-      {
-	r[i] =
-	  p->p[i].pos[0] * p->p[i].pos[0] + p->p[i].pos[1] * p->p[i].pos[1];
-	if (i == 0)
-	  if (r[0] < 0.01)
-	    flag = 0;
-	if (i > 0)
-	  if (ABS (r[i] - r[0]) > 0.01)
-	    flag = 0;
-      }
-    if (flag == 0)
-      {
-	flag = 1;
-	for (i = 1; i < p->n; i++)
-	  if (ABS (p->p[i].pos[2] - p->p[0].pos[2]) > 0.01)
-	    flag = 0;
-      }
-    if (flag)
-      {
-	DOUBLE q = global[0] * global[0] + global[1] * global[1];
-
-	if (q > 0.000001)
-	  {
-	    DOUBLE s = sqrt (0.25 * (r[0] + r[1] + r[2] + r[3]) / q);
-
-	    global[0] *= s;
-	    global[1] *= s;
-	  }
-      }
-  }
-#endif
-#ifdef BENCHMARK
-  {
-    DOUBLE r[4];
-    INT flag = 1;
-
-    if (p->n != 4)
-      return (0);
-    for (i = 0; i < p->n; i++)
-      {
-	r[i] = (p->p[i].pos[0] - 10) * (p->p[i].pos[0] - 10)
-	  + p->p[i].pos[1] * p->p[i].pos[1];
-
-	if (i == 0)
-	  {
-	    if (r[0] < 0.99)
-	      flag = 0;
-	    if (r[0] > 1.01)
-	      flag = 0;
-	  }
-	if (i > 0)
-	  if (ABS (r[i] - r[0]) > 0.01)
-	    flag = 0;
-      }
-    if (flag)
-      {
-	DOUBLE q = (global[0] - 10) *(global[0] - 10) +global[1] * global[1];
-
-	if (q > 0.000001)
-	  {
-	    DOUBLE s = sqrt (0.25 * (r[0] + r[1] + r[2] + r[3]) / q);
-
-	    global[0] = 10 + s * (global[0] - 10);
-	    global[1] *= s;
-	  }
-      }
-  }
-#endif
-
-  return (0);
-}
-
-static INT
-M_BNDS_BndCond (BNDS * theBndS, DOUBLE * local,
-		DOUBLE * in, DOUBLE * value, INT * type)
-{
-  M_BNDS *p = (M_BNDS *) theBndS;
-
-  ASSERT (p != NULL);
-
-  if (currBVP->GeneralBndCond != NULL)
-    {
-      DOUBLE_VECTOR global;
-      INT i;
-      M2_PATCH *patch = (M2_PATCH *) currBVP->patches[p->patch_id];
-
-      type[0] = patch->c;
-      M_BNDS_Global (theBndS, local, global);
-
-      if (in == NULL)
-	return ((*(currBVP->GeneralBndCond))
-		(NULL, NULL, global, value, type));
-
-      for (i = 0; i < DIM; i++)
-	in[i] = global[i];
-
-      return ((*(currBVP->GeneralBndCond)) (NULL, NULL, in, value, type));
-    }
+/* in the corresponding include file!)                                      */
+/*                                                                          */
+/****************************************************************************/
 
-  printf ("not implemented line %d\n", __LINE__);
+/****************************************************************************/
+/*                                                                          */
+/* definition of exported global variables	                                 */
+/*                                                                          */
+/****************************************************************************/
 
-  return (1);
-}
+/****************************************************************************/
+/*                                                                          */
+/* definition of variables global to this source file only (static!)	    */
+/*                                                                          */
+/****************************************************************************/
 
-static INT
-M_BNDS_BndSDesc (BNDS * theBndS, INT * id, INT * nbid, INT * part)
-{
-  *id = 1;
-  *nbid = 0;
-  *part = 0;
+static INT theProblemDirID;	/*!< env type for Problem dir                   */
+static INT theBdryCondVarID;	/*!<  env type for Problem vars                 */
 
-  return (0);
-}
+static INT theDomainDirID;	/*!<  env type for Domain dir                           */
+static INT theBdrySegVarID;	/*!<  env type for bdry segment vars            */
+static INT theLinSegVarID;	/*!<  env type for linear segment vars              */
 
-static BNDP *
-M_BNDS_CreateBndP (HEAP * Heap, BNDS * theBndS, DOUBLE * local)
-{
-  M_BNDS *ps = (M_BNDS *) theBndS;
-  M_BNDP *p = (M_BNDP *) GetFreelistMemory (Heap, sizeof (M_BNDP));
+static INT theBVPDirID;		/*!<  env type for BVP dir                                      */
 
-  ASSERT (ps != NULL);
-/*	ASSERT(ps->n == 4); */
-  ASSERT (p != NULL);
+static STD_BVP *currBVP;
 
-  M_BNDS_Global (theBndS, local, p->pos);
-  p->patch_id = ps->patch_id;
+REP_ERR_FILE;
 
-  return ((BNDP *) p);
-}
+/* RCS string */
+static char
+RCS_ID
+("$Header$",
+UG_RCS_STRING);
 
-static INT
-M_BNDS_Dispose (HEAP * Heap, BNDS * theBndS)
-{
-  return (PutFreelistMemory (Heap, theBndS, M_BNDS_SIZE (theBndS)));
-}
+/****************************************************************************/
+/*                                                                          */
+/* forward declarations of functions used before they are defined	    */
+/*                                                                          */
+/****************************************************************************/
 
+static INT BndPointGlobal (const BNDP * aBndP, DOUBLE * global);
+static INT PatchGlobal (const PATCH * p, DOUBLE * lambda, DOUBLE * global);
 
 /****************************************************************************/
 /** \brief Create a new PROBLEM structure
@@ -1645,7 +183,7 @@
 /****************************************************************************/
 
 void *
-NS_DIM_PREFIX CreateProblem (char *domain, char *name, int id, ConfigProcPtr config,
+NS_DIM_PREFIX CreateProblem (const char *domain, const char *name, int id, ConfigProcPtr config,
                              int numOfCoefficients, CoeffProcPtr coeffs[],
                              int numOfUserFct, UserProcPtr userfct[])
 {
@@ -1728,7 +266,7 @@
 /****************************************************************************/
 
 void * NS_DIM_PREFIX
-CreateBoundaryCondition (char *name, INT id, BndCondProcPtr theBndCond,
+CreateBoundaryCondition (const char *name, INT id, BndCondProcPtr theBndCond,
 			 void *Data)
 {
   BOUNDARY_CONDITION *newBndCond;
@@ -1904,13 +442,34 @@
 /****************************************************************************/
 
 DOMAIN *NS_DIM_PREFIX
-GetDomain (char *name)
+GetDomain (const char *name)
 {
   return ((DOMAIN *)
 	  SearchEnv (name, "/Domains", theDomainDirID, theDomainDirID));
 }
 
 /****************************************************************************/
+/** \brief Remove a domain structure
+ *
+ * @param  name - name of the domain
+ *
+ * This function searches the environment for a domain with the name `name`
+ * and removes it.
+ *
+*/
+/****************************************************************************/
+
+void NS_DIM_PREFIX
+RemoveDomain (const char *name)
+{
+    ENVITEM* d = SearchEnv (name, "/Domains", theDomainDirID, theDomainDirID);
+    if (d!=0) {
+        d->v.locked = FALSE;
+        RemoveEnvDir(d);
+    }
+}
+
+/****************************************************************************/
 /** \brief Create a new BOUNDARY_SEGMENT 
  *
  * @param  name - name of the boundary segment
@@ -1938,7 +497,7 @@
 void *NS_DIM_PREFIX
 CreateBoundarySegment (const char *name,
 		       INT left, INT right, INT id, enum BoundaryType type, INT res,
-		       INT * point, const DOUBLE * alpha, const DOUBLE * beta,
+		       const INT * point, const DOUBLE * alpha, const DOUBLE * beta,
 		       BndSegFuncPtr BndSegFunc, void *data)
 {
   BOUNDARY_SEGMENT *newSegment;
@@ -2053,7 +612,7 @@
 /****************************************************************************/
 
 void *NS_DIM_PREFIX
-CreateBoundarySegment2D (char *name, int left, int right,
+CreateBoundarySegment2D (const char *name, int left, int right,
 			 int id, int from, int to, int res, DOUBLE alpha,
 			 DOUBLE beta, BndSegFuncPtr BndSegFunc, void *data)
 {
@@ -2090,16 +649,16 @@
 */
 /****************************************************************************/
 
-LINEAR_SEGMENT *NS_DIM_PREFIX
-CreateLinearSegment (char *name,
+void *NS_DIM_PREFIX
+CreateLinearSegment (const char *name,
 		     INT left, INT right, INT id,
-		     INT n, INT * point,
-		     DOUBLE x[MAX_CORNERS_OF_LINEAR_PATCH][DIM_OF_BND])
+		     INT n, const INT * point,
+		     DOUBLE x[CORNERS_OF_BND_SEG][DIM])
 {
   LINEAR_SEGMENT *newSegment;
   INT i, k;
 
-  if (n > MAX_CORNERS_OF_LINEAR_PATCH)
+  if (n > CORNERS_OF_BND_SEG)
     return (NULL);
 
   /* allocate the boundary segment */
@@ -2117,13 +676,31 @@
   for (i = 0; i < n; i++)
     {
       newSegment->points[i] = point[i];
-      for (k = 0; k < DIM_OF_BND; k++)
+      for (k = 0; k < DIM; k++)
 	newSegment->x[i][k] = x[i][k];
     }
 
   return (newSegment);
 }
 
+UINT NS_DIM_PREFIX GetBoundarySegmentId(BNDS* boundarySegment)
+{
+    BND_PS *ps;
+    PATCH *patch;
+
+    ps = (BND_PS *) boundarySegment;
+    patch = currBVP->patches[ps->patch_id];
+    if (patch == NULL) {
+        PrintErrorMessageF ('E', "GetBoundarySegmentId", "invalid argument");
+        return 0;
+    }
+
+    /* The ids in the patch data structure are consecutive but they
+       start at currBVP->sideoffset instead of zero. */
+    return PATCH_ID(patch) - currBVP->sideoffset;
+}
+        
+
 static LINEAR_SEGMENT *
 GetNextLinearSegment (LINEAR_SEGMENT * theBSeg)
 {
@@ -2153,48 +730,6 @@
 
 
 BVP *NS_DIM_PREFIX
-Create_MarcBVP (char *BVPName, BndCondProcPtr theBndCond,
-		int numOfCoeffFct, CoeffProcPtr coeffs[],
-		int numOfUserFct, UserProcPtr userfct[])
-{
-  STD_BVP *theBVP;
-  INT i, n;
-
-  /* change to /BVP directory */
-  if (ChangeEnvDir ("/BVP") == NULL)
-    return (NULL);
-
-  /* allocate new domain structure */
-  n = (numOfCoeffFct + numOfUserFct - 1) * sizeof (void *);
-  theBVP =
-    (STD_BVP *) MakeEnvItem (BVPName, theBVPDirID, sizeof (STD_BVP) + n);
-  if (theBVP == NULL)
-    return (NULL);
-  if (ChangeEnvDir (BVPName) == NULL)
-    return (NULL);
-
-  theBVP->numOfCoeffFct = numOfCoeffFct;
-  theBVP->numOfUserFct = numOfUserFct;
-  for (i = 0; i < numOfCoeffFct; i++)
-    theBVP->CU_ProcPtr[i] = (void *) (coeffs[i]);
-  for (i = 0; i < numOfUserFct; i++)
-    theBVP->CU_ProcPtr[i + numOfCoeffFct] = (void *) (userfct[i]);
-
-  STD_BVP_S2P_PTR (theBVP) = NULL;
-
-  theBVP->Domain = NULL;
-  theBVP->Problem = NULL;
-  theBVP->ConfigProc = Marc_Configure;
-  theBVP->GeneralBndCond = theBndCond;
-
-  theBVP->type = BVP_MARC;
-
-  UserWriteF ("BVP %s installed.\n", BVPName);
-
-  return ((BVP *) theBVP);
-}
-
-BVP *NS_DIM_PREFIX
 CreateBoundaryValueProblem (const char *BVPName, BndCondProcPtr theBndCond,
 			    int numOfCoeffFct, CoeffProcPtr coeffs[],
 			    int numOfUserFct, UserProcPtr userfct[])
@@ -2229,8 +764,6 @@
   theBVP->ConfigProc = STD_BVP_Configure;
   theBVP->GeneralBndCond = theBndCond;
 
-  theBVP->type = BVP_STANDARD;
-
   UserWriteF ("BVP %s installed.\n", BVPName);
 
   return ((BVP *) theBVP);
@@ -2250,7 +783,7 @@
 *//****************************************************************************/
 
 BVP *NS_DIM_PREFIX
-CreateBVP (char *BVPName, char *DomainName, char *ProblemName)
+CreateBVP (const char *BVPName, const char *DomainName, const char *ProblemName)
 {
   STD_BVP *theBVP;
   DOMAIN *theDomain;
@@ -2295,8 +828,6 @@
   theBVP->ConfigProc = theProblem->ConfigProblem;
   theBVP->GeneralBndCond = NULL;
 
-  theBVP->type = BVP_STANDARD;
-
   UserWriteF ("BVP %s installed.\n", BVPName);
 
   return ((BVP *) theBVP);
@@ -2353,7 +884,7 @@
 }
 
 BVP *NS_DIM_PREFIX
-CreateBVP_Problem (char *BVPName, char *DomainName, char *ProblemName)
+CreateBVP_Problem (const char *BVPName, const char *DomainName, const char *ProblemName)
 {
   STD_BVP *theBVP;
   DOMAIN *theDomain;
@@ -2398,8 +929,6 @@
   theBVP->ConfigProc = Problem_Configure;
   theBVP->GeneralBndCond = NULL;
 
-  theBVP->type = BVP_STANDARD;
-
   UserWriteF ("BVP %s installed.\n", BVPName);
 
   return ((BVP *) theBVP);
@@ -2451,6 +980,7 @@
 {
   switch (PATCH_TYPE (p))
     {
+    case LINEAR_PATCH_TYPE:
     case PARAMETRIC_PATCH_TYPE:
       return (PATCH_ID (p));
     case POINT_PATCH_TYPE:
@@ -2461,6 +991,7 @@
 #endif
     }
 
+  assert(0);
   return (-1);
 }
 
@@ -2553,7 +1084,12 @@
 	      ps->local[j][1] = 0.0;
 	      break;
 	    case 2:
-	      ps->local[j][0] = 0.0;
+              /* This coordinate depends on whether we're looking at a triangle or a quadrilateral */
+              ps->local[j][0] = (LINEAR_PATCH_N(pp)==3) ? 0.0 : 1.0;
+              ps->local[j][1] = 1.0;
+	      break;
+            case 3:
+              ps->local[j][0] = 0.0;
 	      ps->local[j][1] = 1.0;
 	      break;
 #endif
@@ -2591,8 +1127,118 @@
   return (0);
 }
 
+#ifdef __THREEDIM__
+/** \brief Add a line between two vertices to the boundary data structure
+
+\param i, j  The line goes from vertex i to vertex j
+\param corners Array with pointers to all vertices
+*/
+static INT
+CreateLine(INT i, INT j, HEAP *Heap, PATCH *thePatch, PATCH **corners, PATCH **lines, PATCH **sides, 
+           INT *nlines, INT *err)
+{
+    INT k, n, m;
+    INT freePatches;
+
+    k = 0;
+    for (n = 0; n < POINT_PATCH_N (corners[i]); n++)
+        for (m = 0; m < POINT_PATCH_N (corners[j]); m++)
+	    if (POINT_PATCH_PID (corners[i], n) ==
+		POINT_PATCH_PID (corners[j], m))
+                k++;
+    /* points share one patch only and lie on opposite corners of this patch */
+    if (k < 2) return (NULL);
+    
+    thePatch =
+        (PATCH *) GetFreelistMemory (Heap, sizeof (LINE_PATCH)
+                                     + (k -
+                                        1) * sizeof (struct line_on_patch));
+    if (thePatch == NULL)
+        return (NULL);
+    PATCH_TYPE (thePatch) = LINE_PATCH_TYPE;
+    PATCH_ID (thePatch) = *nlines;
+    LINE_PATCH_C0 (thePatch) = i;
+    LINE_PATCH_C1 (thePatch) = j;
+    k = 0;
+    freePatches = 0;
+    for (n = 0; n < POINT_PATCH_N (corners[i]); n++)
+        for (m = 0; m < POINT_PATCH_N (corners[j]); m++)
+	    if (POINT_PATCH_PID (corners[i], n) ==
+		POINT_PATCH_PID (corners[j], m))
+                {
+                    LINE_PATCH_PID (thePatch, k) =
+                        POINT_PATCH_PID (corners[i], n);
+                    LINE_PATCH_CID0 (thePatch, k) =
+                        POINT_PATCH_CID (corners[i], n);
+                    LINE_PATCH_CID1 (thePatch, k) =
+                        POINT_PATCH_CID (corners[j], m);
+                    if (PATCH_IS_FREE (sides[LINE_PATCH_PID (thePatch, k)]))
+                        freePatches++;
+                    k++;
+                }
+    LINE_PATCH_N (thePatch) = k;
+    
+    for (n = 0; n < LINE_PATCH_N (thePatch); n++)
+        PRINTDEBUG (dom, 1, (" pid %d cid %d %d",
+                             LINE_PATCH_PID (thePatch, n),
+                             LINE_PATCH_CID0 (thePatch, n),
+                             LINE_PATCH_CID1 (thePatch, n)));
+    PRINTDEBUG (dom, 1, ("\n"));
+    
+    IFDEBUG (dom, 10) if (k == 2)
+        {
+	    INT o0, o1, s0, s1;
+            
+	    s0 = LINE_PATCH_PID (thePatch, 0);
+	    s1 = LINE_PATCH_PID (thePatch, 1);
+	    o0 =
+                (LINE_PATCH_CID0 (thePatch, 0) ==
+                 ((LINE_PATCH_CID1 (thePatch, 0) + 1) % (2 * DIM_OF_BND)));
+	    o1 =
+                (LINE_PATCH_CID0 (thePatch, 1) ==
+                 ((LINE_PATCH_CID1 (thePatch, 1) + 1) % (2 * DIM_OF_BND)));
+	    if (o0 != o1)
+                {
+                    if ((PARAM_PATCH_LEFT (sides[s0]) !=
+                         PARAM_PATCH_LEFT (sides[s1]))
+                        || ((PARAM_PATCH_RIGHT (sides[s0]) !=
+                             PARAM_PATCH_RIGHT (sides[s1]))))
+                        {
+                            PRINTDEBUG (dom, 0, ("patch %d and patch %d:"
+                                                 "orientation not maches\n", s0, s1));
+                            (*err)++;
+                        }
+                }
+	    else
+                {
+                    if ((PARAM_PATCH_LEFT (sides[s0]) !=
+                         PARAM_PATCH_RIGHT (sides[s1]))
+                        || ((PARAM_PATCH_RIGHT (sides[s0]) !=
+                             PARAM_PATCH_LEFT (sides[s1]))))
+                        {
+                            PRINTDEBUG (dom, 0, ("patch %d and patch %d:"
+                                                 "orientation not maches\n", s0, s1));
+                            (*err)++;
+                        }
+                }
+        }
+    ENDDEBUG if (freePatches == k)
+        PATCH_STATE (thePatch) = PATCH_FREE;
+    else if (freePatches == 0)
+        PATCH_STATE (thePatch) = PATCH_FIXED;
+    else
+        PATCH_STATE (thePatch) = PATCH_BND_OF_FREE;
+    lines[(*nlines)++] = thePatch;
+    PRINTDEBUG (dom, 1, ("lines id %d type %d n %d\n",
+                         PATCH_ID (thePatch), PATCH_TYPE (thePatch),
+                         LINE_PATCH_N (thePatch)));
+
+
+}
+#endif
+
 BVP *NS_DIM_PREFIX
-BVP_Init (char *name, HEAP * Heap, MESH * Mesh, INT MarkKey)
+BVP_Init (const char *name, HEAP * Heap, MESH * Mesh, INT MarkKey)
 {
   STD_BVP *theBVP;
   DOMAIN *theDomain;
@@ -2601,22 +1247,18 @@
   LINEAR_SEGMENT *theLinSegment;
   BOUNDARY_CONDITION *theBndCond;
   PATCH **corners, **sides, *thePatch;
-  INT i, j, n, m, maxSubDomains, ncorners, nlines, nsides, free;
+  unsigned short* segmentsPerPoint, *freeSegmentsPerPoint, *cornerCounters;
+  INT i, j, n, m, maxSubDomains, ncorners, nlines, nsides;
 #	ifdef __THREEDIM__
   PATCH **lines;
   INT k, err;
+  INT nn;
 #	endif
 
   theBVP = (STD_BVP *) BVP_GetByName (name);
   if (theBVP == NULL)
     return (NULL);
   currBVP = theBVP;
-#ifdef ModelP
-  SetBVPType (theBVP->type);
-#endif
-
-  if (theBVP->type == BVP_MARC)
-    return (Init_MarcBVP (theBVP, Heap, Mesh, MarkKey));
 
   theDomain = theBVP->Domain;
   if (theDomain == NULL)
@@ -2739,70 +1381,89 @@
   if (corners == NULL)
     return (NULL);
   theBVP->ncorners = ncorners;
-  for (i = 0; i < ncorners; i++)
-    {
-      m = 0;
-      /* count parameter patchs */
-      for (j = 0; j < nsides; j++)
-	{
-	  if (PATCH_TYPE (sides[j]) == LINEAR_PATCH_TYPE)
-	    {
-	      for (n = 0; n < LINEAR_PATCH_N (sides[j]); n++)
-		if (LINEAR_PATCH_POINTS (sides[j], n) == i)
-		  m++;
-	    }
-	  else if (PATCH_TYPE (sides[j]) == PARAMETRIC_PATCH_TYPE)
-	    {
-	      for (n = 0; n < 2 * DIM_OF_BND; n++)
-		if (PARAM_PATCH_POINTS (sides[j], n) == i)
-		  m++;
-	    }
-	}
+
+  /* precompute the number of segments at each point patch */
+  segmentsPerPoint = (unsigned short*)calloc(ncorners,sizeof(unsigned short));
+  freeSegmentsPerPoint = (unsigned short*)calloc(ncorners,sizeof(unsigned short));
+
+  for (j = 0; j < nsides; j++) {
+
+      if (PATCH_TYPE (sides[j]) == LINEAR_PATCH_TYPE) {
+          for (n = 0; n < LINEAR_PATCH_N (sides[j]); n++)
+              segmentsPerPoint[LINEAR_PATCH_POINTS (sides[j], n)]++;
+
+          if (PATCH_IS_FREE(sides[j]))
+              for (n = 0; n < LINEAR_PATCH_N (sides[j]); n++)
+                  freeSegmentsPerPoint[LINEAR_PATCH_POINTS (sides[j], n)]++;
+
+      } else if (PATCH_TYPE (sides[j]) == PARAMETRIC_PATCH_TYPE) {
+          for (n = 0; n < 2 * DIM_OF_BND; n++)
+              if (PARAM_PATCH_POINTS (sides[j], n) >= 0) /* Entry may be -1 for triangular faces */
+                  segmentsPerPoint[PARAM_PATCH_POINTS (sides[j], n)]++;
+
+          if (PATCH_IS_FREE(sides[j]))
+              for (n = 0; n < 2 * DIM_OF_BND; n++)
+              if (PARAM_PATCH_POINTS (sides[j], n) >= 0) /* Entry may be -1 for triangular faces */
+                  freeSegmentsPerPoint[PARAM_PATCH_POINTS (sides[j], n)]++;
+
+      }
+
+  }
+
+  /* Allocate point patches */
+  for (i = 0; i < ncorners; i++) {
+
+      m = segmentsPerPoint[i];
+      
       thePatch =
-	(PATCH *) GetFreelistMemory (Heap, sizeof (POINT_PATCH)
-				     + (m -
-					1) * sizeof (struct point_on_patch));
+          (PATCH *) GetFreelistMemory (Heap, sizeof (POINT_PATCH)
+                                       + (m-1) * sizeof (struct point_on_patch));
       if (thePatch == NULL)
-	return (NULL);
+          return (NULL);
+
       PATCH_TYPE (thePatch) = POINT_PATCH_TYPE;
       PATCH_ID (thePatch) = i;
-      m = 0;
-      free = 0;
-      for (j = 0; j < nsides; j++)
-	{
+      
+      POINT_PATCH_N (thePatch) = m;
+      corners[i] = thePatch;
+
+  }
+
+  cornerCounters = (unsigned short*)calloc(ncorners,sizeof(unsigned short));
+
+  for (j = 0; j < nsides; j++)
+      {
 	  if (PATCH_TYPE (sides[j]) == LINEAR_PATCH_TYPE)
-	    {
-	      for (n = 0; n < LINEAR_PATCH_N (sides[j]); n++)
-		if (LINEAR_PATCH_POINTS (sides[j], n) == i)
-		  {
-		    POINT_PATCH_PID (thePatch, m) = j;
-		    POINT_PATCH_CID (thePatch, m++) = n;
-		    if (PATCH_IS_FREE (sides[j]))
-		      free++;
-		  }
-	    }
+              {
+                  for (n = 0; n < LINEAR_PATCH_N (sides[j]); n++) 
+                      {
+                          i = LINEAR_PATCH_POINTS (sides[j], n);
+                          POINT_PATCH_PID (corners[i], cornerCounters[i]) = j;
+                          POINT_PATCH_CID (corners[i], cornerCounters[i]++) = n;
+                      }
+              }
 	  else if (PATCH_TYPE (sides[j]) == PARAMETRIC_PATCH_TYPE)
-	    {
-	      for (n = 0; n < 2 * DIM_OF_BND; n++)
-		if (PARAM_PATCH_POINTS (sides[j], n) == i)
-		  {
-		    POINT_PATCH_PID (thePatch, m) = j;
-		    POINT_PATCH_CID (thePatch, m++) = n;
-		    if (PATCH_IS_FREE (sides[j]))
-		      free++;
-		  }
-	    }
-	}
-      if (free == m)
+              {
+                  for (n = 0; n < 2 * DIM_OF_BND; n++)
+                      {
+                          i = PARAM_PATCH_POINTS (sides[j], n);
+                          if (i>=0 && i<ncorners) {
+                              POINT_PATCH_PID (corners[i], cornerCounters[i]) = j;
+                              POINT_PATCH_CID (corners[i], cornerCounters[i]++) = n;
+                          }
+                      }
+              }
+      }
+
+  for (i = 0; i < ncorners; i++) {
+      /* Shouldn't the 'thePatch' be replaced 'corners[i]' in this loop?  OS */
+      if (freeSegmentsPerPoint[i] == cornerCounters[i])
 	PATCH_STATE (thePatch) = PATCH_FREE;
-      else if (free == 0)
+      else if (freeSegmentsPerPoint[i] == 0)
 	PATCH_STATE (thePatch) = PATCH_FIXED;
       else
 	PATCH_STATE (thePatch) = PATCH_BND_OF_FREE;
 
-      for (j = 0; j < nsides; j++)
-	POINT_PATCH_N (thePatch) = m;
-      corners[i] = thePatch;
       PRINTDEBUG (dom, 1, ("corners id %d type %d n %d\n",
 			   PATCH_ID (thePatch), PATCH_TYPE (thePatch),
 			   POINT_PATCH_N (thePatch)));
@@ -2812,111 +1473,102 @@
 			     POINT_PATCH_CID (thePatch, j)));
     }
 
+  /* Return memory that will not be used anymore */
+  free(segmentsPerPoint);
+  free(freeSegmentsPerPoint);
+  free(cornerCounters);
+
   /* create line patches */
   nlines = 0;
 #ifdef __THREEDIM__
+  /* The maximum number of boundary lines is equal to the number of
+     boundary faces (nsides) times the max number of lines per face (=4)
+     divided by two. */
   lines =
-    (PATCH **) GetTmpMem (Heap, ncorners * ncorners * sizeof (PATCH *),
+    (PATCH **) GetTmpMem (Heap, nsides * 2 * sizeof (PATCH *),
 			  MarkKey);
   if (lines == NULL)
     return (NULL);
   err = 0;
+
+  /* We create the set of all boundary lines by looping over the sides
+     and for each side loop over the edges of this side.  That way, we
+     meet each boundary line twice.  We cannot assume
+     that the sides are properly oriented. Thus we introduce a c++-std::set
+     which saves the index pair of the nodes defining the line.
+     When a line is visited the second time, the pair is expunged from the
+     set in order to save memory.
+  */
+#ifdef STDDOM_QUADRATIC_LINE_INSERTION
+  /* the previous quadratic c-algorithm */
   for (i = 0; i < ncorners; i++)
     for (j = i + 1; j < ncorners; j++)
-      {
-	k = 0;
-	for (n = 0; n < POINT_PATCH_N (corners[i]); n++)
-	  for (m = 0; m < POINT_PATCH_N (corners[j]); m++)
-	    if (POINT_PATCH_PID (corners[i], n) ==
-		POINT_PATCH_PID (corners[j], m))
-	      k++;
-	if (k < 2)
-	  /* points share one patch only and ly on opposite corners of this patch */
-	  continue;
-	thePatch =
-	  (PATCH *) GetFreelistMemory (Heap, sizeof (LINE_PATCH)
-				       + (k -
-					  1) * sizeof (struct line_on_patch));
-	if (thePatch == NULL)
-	  return (NULL);
-	PATCH_TYPE (thePatch) = LINE_PATCH_TYPE;
-	PATCH_ID (thePatch) = nlines;
-	LINE_PATCH_C0 (thePatch) = i;
-	LINE_PATCH_C1 (thePatch) = j;
-	k = 0;
-	free = 0;
-	for (n = 0; n < POINT_PATCH_N (corners[i]); n++)
-	  for (m = 0; m < POINT_PATCH_N (corners[j]); m++)
-	    if (POINT_PATCH_PID (corners[i], n) ==
-		POINT_PATCH_PID (corners[j], m))
-	      {
-		LINE_PATCH_PID (thePatch, k) =
-		  POINT_PATCH_PID (corners[i], n);
-		LINE_PATCH_CID0 (thePatch, k) =
-		  POINT_PATCH_CID (corners[i], n);
-		LINE_PATCH_CID1 (thePatch, k) =
-		  POINT_PATCH_CID (corners[j], m);
-		if (PATCH_IS_FREE (sides[LINE_PATCH_PID (thePatch, k)]))
-		  free++;
-		k++;
-	      }
-	LINE_PATCH_N (thePatch) = k;
-
-	for (n = 0; n < LINE_PATCH_N (thePatch); n++)
-	  PRINTDEBUG (dom, 1, (" pid %d cid %d %d",
-			       LINE_PATCH_PID (thePatch, n),
-			       LINE_PATCH_CID0 (thePatch, n),
-			       LINE_PATCH_CID1 (thePatch, n)));
-	PRINTDEBUG (dom, 1, ("\n"));
-
-	IFDEBUG (dom, 10) if (k == 2)
-	  {
-	    INT o0, o1, s0, s1;
+    {
+      CreateLine(i, j, Heap, thePatch, corners, lines, sides, &nlines, &err);
+    }
+#else
+  typedef std::set<std::pair<long,long> > set;
+  typedef std::set<std::pair<long,long> >::iterator iterator;
+  set bnd_edges;
+
+  for (int s=0; s<nsides; s++) {
+
+      if (PATCH_TYPE (sides[s]) == LINEAR_PATCH_TYPE) {
+
+      for (nn = 0; nn < LINEAR_PATCH_N (sides[s]); nn++) 
+          {
+              i = LINEAR_PATCH_POINTS (sides[s], nn);
+              j = LINEAR_PATCH_POINTS (sides[s], (nn+1)%LINEAR_PATCH_N(sides[s]));
+
+              long max = std::max(i,j);
+              long min = i + j - max;
+              std::pair<long, long> z(min,max);
+              
+              if ( bnd_edges.insert(z).second ) /* true if bnd_edges didn't contain z yet */
+              {
+                  /* Insert the line into the boundary data structure */
+                  CreateLine(min, max, Heap, thePatch, corners, lines, sides, &nlines, &err);
+              }
+              else
+                  bnd_edges.erase(z);
+
+          }
+
+      } else if (PATCH_TYPE (sides[s]) == PARAMETRIC_PATCH_TYPE) {
+
+          /* Handle edges of parametric patches */
+
+          /* Determine whether the boundary segment is a triangle or a quadrilateral.
+             We assume that it is a triangle if the fourth vertex is invalid, and
+             a quadrilateral otherwise.  This is the best we can do.
+          */
+
+          int cornersOfParametricPatch = (PARAM_PATCH_POINTS (sides[s], 3) < 0 || PARAM_PATCH_POINTS (sides[s], 3) > ncorners) ? 3 : 4;
+
+          for (nn = 0; nn < cornersOfParametricPatch; nn++) 
+              {
+                  i = PARAM_PATCH_POINTS (sides[s], nn);
+                  j = PARAM_PATCH_POINTS (sides[s], (nn+1)%cornersOfParametricPatch);
+
+                  long max = std::max(i,j);
+                  long min = i + j - max;
+                  std::pair<long, long> z(min,max);
+
+                  if ( bnd_edges.insert(z).second )  /* true if bnd_edges didn't contain z yet */
+                  {
+                      /* Insert the line into the boundary data structure */
+                      CreateLine(min, max, Heap, thePatch, corners, lines, sides, &nlines, &err);
+                  }
+                  else
+                      bnd_edges.erase(z);
+
+              }
+          
+      } else
+          UserWrite("Error: unknown PATCH_TYPE found for a boundary side!\n");
 
-	    s0 = LINE_PATCH_PID (thePatch, 0);
-	    s1 = LINE_PATCH_PID (thePatch, 1);
-	    o0 =
-	      (LINE_PATCH_CID0 (thePatch, 0) ==
-	       ((LINE_PATCH_CID1 (thePatch, 0) + 1) % (2 * DIM_OF_BND)));
-	    o1 =
-	      (LINE_PATCH_CID0 (thePatch, 1) ==
-	       ((LINE_PATCH_CID1 (thePatch, 1) + 1) % (2 * DIM_OF_BND)));
-	    if (o0 != o1)
-	      {
-		if ((PARAM_PATCH_LEFT (sides[s0]) !=
-		     PARAM_PATCH_LEFT (sides[s1]))
-		    || ((PARAM_PATCH_RIGHT (sides[s0]) !=
-			 PARAM_PATCH_RIGHT (sides[s1]))))
-		  {
-		    PRINTDEBUG (dom, 0, ("patch %d and patch %d:"
-					 "orientation not maches\n", s0, s1));
-		    err++;
-		  }
-	      }
-	    else
-	      {
-		if ((PARAM_PATCH_LEFT (sides[s0]) !=
-		     PARAM_PATCH_RIGHT (sides[s1]))
-		    || ((PARAM_PATCH_RIGHT (sides[s0]) !=
-			 PARAM_PATCH_LEFT (sides[s1]))))
-		  {
-		    PRINTDEBUG (dom, 0, ("patch %d and patch %d:"
-					 "orientation not maches\n", s0, s1));
-		    err++;
-		  }
-	      }
-	  }
-	ENDDEBUG if (free == k)
-	  PATCH_STATE (thePatch) = PATCH_FREE;
-	else if (free == 0)
-	  PATCH_STATE (thePatch) = PATCH_FIXED;
-	else
-	  PATCH_STATE (thePatch) = PATCH_BND_OF_FREE;
-	lines[nlines++] = thePatch;
-	PRINTDEBUG (dom, 1, ("lines id %d type %d n %d\n",
-			     PATCH_ID (thePatch), PATCH_TYPE (thePatch),
-			     LINE_PATCH_N (thePatch)));
-      }
+  }
+#endif /* STDDOM_QUADRATIC_LINE_INSERTION */
   ASSERT (err == 0);
 #endif
 
@@ -3016,9 +1668,21 @@
 }
 
 /* domain interface function: for description see domain.h */
+/** \todo This implementation leaks memory.  A BVP points to
+    a set of patches which have to be properly deallocated as
+    well.
+*/
 INT NS_DIM_PREFIX
 BVP_Dispose (BVP * theBVP)
 {
+    /* Unlock the item so it can be deleted from the environment tree */
+    ((ENVITEM*)theBVP)->d.locked = 0;
+
+    if (ChangeEnvDir("/BVP")==NULL)
+        return (1);
+    if (RemoveEnvItem((ENVITEM *)theBVP))
+        return (1);
+	
   return (0);
 }
 
@@ -3167,6 +1831,7 @@
   return (cnt);
 }
 
+#ifdef __THREEDIM__
 static INT
 GetCommonPatchId (PATCH * p0, PATCH * p1, INT k)
 {
@@ -3182,7 +1847,6 @@
   return (-1);
 }
 
-#ifdef __THREEDIM__
 static INT
 GetCommonLinePatchId (PATCH * p0, PATCH * p1)
 {
@@ -4555,7 +3219,7 @@
 /****************************************************************************/
 
 static INT
-PatchGlobal (PATCH * p, DOUBLE * lambda, DOUBLE * global)
+PatchGlobal (const PATCH * p, DOUBLE * lambda, DOUBLE * global)
 {
   if (PATCH_TYPE (p) == PARAMETRIC_PATCH_TYPE)
     return ((*PARAM_PATCH_BS (p)) (PARAM_PATCH_BSD (p), lambda, global));
@@ -4568,15 +3232,24 @@
 	+ lambda[0] * LINEAR_PATCH_POS (p, 1)[1];
 #endif
 #ifdef __THREEDIM__
-      global[0] = (1 - lambda[0] - lambda[1]) * LINEAR_PATCH_POS (p, 0)[0]
-	+ lambda[0] * LINEAR_PATCH_POS (p, 1)[0]
-	+ lambda[1] * LINEAR_PATCH_POS (p, 2)[0];
-      global[1] = (1 - lambda[0] - lambda[1]) * LINEAR_PATCH_POS (p, 0)[1]
-	+ lambda[0] * LINEAR_PATCH_POS (p, 1)[1]
-	+ lambda[1] * LINEAR_PATCH_POS (p, 2)[1];
-      global[2] = (1 - lambda[0] - lambda[1]) * LINEAR_PATCH_POS (p, 0)[2]
-	+ lambda[0] * LINEAR_PATCH_POS (p, 1)[2]
-	+ lambda[1] * LINEAR_PATCH_POS (p, 2)[2];
+
+      if (LINEAR_PATCH_N(p) ==3) {
+          /* Linear interpolation for a triangle boundary segment */
+          int i;
+          for (i=0; i<3; i++)
+              global[i] = (1 - lambda[0] - lambda[1]) * LINEAR_PATCH_POS (p, 0)[i]
+                  + lambda[0] * LINEAR_PATCH_POS (p, 1)[i]
+                  + lambda[1] * LINEAR_PATCH_POS (p, 2)[i];
+
+      } else {
+          /* Bilinear interpolation for a quadrilateral boundary segment */
+          int i;
+          for (i=0; i<3; i++)
+              global[i] = LINEAR_PATCH_POS (p, 0)[i] 
+                  + lambda[0]*(LINEAR_PATCH_POS (p, 1)[i] - LINEAR_PATCH_POS (p, 0)[i]) 
+                  + lambda[1]*(LINEAR_PATCH_POS (p, 3)[i] - LINEAR_PATCH_POS (p, 0)[i]) 
+                  + lambda[0]*lambda[1]*(LINEAR_PATCH_POS (p, 0)[i]+LINEAR_PATCH_POS (p, 2)[i]-LINEAR_PATCH_POS (p, 1)[i]-LINEAR_PATCH_POS (p, 3)[i]);
+      }
 #endif
       return (0);
     }
@@ -4620,7 +3293,7 @@
       break;
     case 4:
       for (i = 0; i < DIM; i++)
-	global[0] = (1.0 - local[0]) * (1.0 - local[1]) * pos[0][i]
+	global[i] = (1.0 - local[0]) * (1.0 - local[1]) * pos[0][i]
 	+ local[0] * (1.0 - local[1]) * pos[1][i]
 	+ local[0] * local[1] * pos[2][i]
 	+ (1.0 - local[0]) * local[1] * pos[3][i];
@@ -4684,8 +3357,6 @@
   if (p == NULL)
     return (1);
 
-  IF_MARC (aBndS) return (M_BNDS_Global (aBndS, local, global));
-
   PRINTDEBUG (dom, 1, (" Bnds global loc %f pid %d\n",
 		       local[0], PATCH_ID (p)));
 
@@ -4743,8 +3414,6 @@
   if (ps == NULL)
     return (1);
 
-  IF_MARC (aBndS) return (M_BNDS_BndCond (aBndS, local, in, value, type));
-
   p = currBVP->patches[ps->patch_id];
 
   PRINTDEBUG (dom, 1, (" BndCond %d %x\n", PATCH_TYPE (p), p));
@@ -4805,8 +3474,6 @@
   PATCH *p;
   INT left, right;
 
-  IF_MARC (theBndS) return (M_BNDS_BndSDesc (theBndS, id, nbid, part));
-
   ps = (BND_PS *) theBndS;
   p = currBVP->patches[ps->patch_id];
 
@@ -4861,8 +3528,6 @@
   if (aBndS == NULL)
     return (NULL);
 
-  IF_MARC (aBndS) return (M_BNDS_CreateBndP (Heap, aBndS, local));
-
   ps = (BND_PS *) aBndS;
   p = currBVP->patches[ps->patch_id];
 
@@ -4901,7 +3566,7 @@
 /****************************************************************************/
 
 static INT
-BndPointGlobal (BNDP * aBndP, DOUBLE * global)
+BndPointGlobal (const BNDP * aBndP, DOUBLE * global)
 {
   BND_PS *ps;
   PATCH *p, *s;
@@ -4920,39 +3585,41 @@
     case LINEAR_PATCH_TYPE:
       return (PatchGlobal (p, ps->local[0], global));
     case POINT_PATCH_TYPE:
+
       s = currBVP->patches[POINT_PATCH_PID (p, 0)];
+
       PRINTDEBUG (dom, 1, (" bndp n %d %d loc %f %f gl \n",
 			   POINT_PATCH_N (p),
 			   POINT_PATCH_PID (p, 0),
 			   ps->local[0][0], ps->local[0][1]));
-      if ((*PARAM_PATCH_BS (s)) (PARAM_PATCH_BSD (s), ps->local[0], global))
-	REP_ERR_RETURN (1);
-      PRINTDEBUG (dom, 1, (" bndp n %d %d loc %f %f gl %f %f %f\n",
-			   POINT_PATCH_N (p),
-			   POINT_PATCH_PID (p, 0),
-			   ps->local[0][0],
-			   ps->local[0][1], global[0], global[1], global[2]));
+
+          PatchGlobal(s, ps->local[0], global);
+
       for (j = 1; j < POINT_PATCH_N (p); j++)
 	{
 	  s = currBVP->patches[POINT_PATCH_PID (p, j)];
-	  if ((*PARAM_PATCH_BS (s))
-	      (PARAM_PATCH_BSD (s), ps->local[j], pglobal))
-	    REP_ERR_RETURN (1);
-	  PRINTDEBUG (dom, 1, (" bndp    j %d %d loc %f %f gl %f %f %f\n", j,
+
+          if (PatchGlobal(s, ps->local[j], pglobal))
+              REP_ERR_RETURN (1);
+
+        PRINTDEBUG (dom,1, (" bndp    j %d %d loc %f %f gl %f %f %f\n", j,
 			       POINT_PATCH_PID (p, j),
 			       ps->local[j][0],
 			       ps->local[j][1],
-			       pglobal[0], pglobal[1], pglobal[2]));
+                             pglobal[0], pglobal[1], pglobal[2]));
 	  for (k = 0; k < DIM; k++)
 	    if (ABS (pglobal[k] - global[k]) > SMALL_DIFF)
 	        REP_ERR_RETURN (1);
 	}
+
       return (0);
 #ifdef __THREEDIM__
     case LINE_PATCH_TYPE:
       s = currBVP->patches[LINE_PATCH_PID (p, 0)];
-      if ((*PARAM_PATCH_BS (s)) (PARAM_PATCH_BSD (s), ps->local[0], global))
-	REP_ERR_RETURN (1);
+
+      if (PatchGlobal(s, ps->local[0], global))
+          REP_ERR_RETURN (1);
+
       PRINTDEBUG (dom, 1, (" bndp    n %d %d loc %f %f gl %f %f %f\n",
 			   POINT_PATCH_N (p),
 			   LINE_PATCH_PID (p, 0),
@@ -4961,9 +3628,10 @@
       for (j = 1; j < LINE_PATCH_N (p); j++)
 	{
 	  s = currBVP->patches[LINE_PATCH_PID (p, j)];
-	  if ((*PARAM_PATCH_BS (s))
-	      (PARAM_PATCH_BSD (s), ps->local[j], pglobal))
-	    return (1);
+
+          if (PatchGlobal(s, ps->local[j], pglobal))
+              REP_ERR_RETURN (1);
+
 	  PRINTDEBUG (dom, 1, (" bndp    j %d %d loc %f %f gl %f %f %f\n", j,
 			       LINE_PATCH_PID (p, j),
 			       ps->local[j][0],
@@ -4988,8 +3656,6 @@
   DOUBLE *pos;
   INT i;
 
-  IF_MARC (aBndP) return (M_BNDP_Global (aBndP, global));
-
   if (!PATCH_IS_FIXED (currBVP->patches[ps->patch_id]))
     {
       /* copy globals */
@@ -5009,8 +3675,6 @@
   BND_PS *ps;
   PATCH *p;
 
-  IF_MARC (theBndP) return (M_BNDP_BndPDesc (theBndP, move, part));
-
   ps = (BND_PS *) theBndP;
   p = STD_BVP_PATCH (currBVP, ps->patch_id);
 
@@ -5061,8 +3725,6 @@
   if ((bp0 == NULL) || (bp1 == NULL))
     REP_ERR_RETURN (1);
 
-  IF_MARC (aBndP0) return (M_BNDP_BndEDesc (aBndP0, aBndP1, part));
-
   /* default part is 0 */
   *part = 0;
 
@@ -5113,8 +3775,6 @@
   INT k;
 #	endif
 
-  IF_MARC (aBndP[0]) return (M_BNDP_CreateBndS (Heap, aBndP, n));
-
   PRINTDEBUG (dom, 1, ("Create BNDS:\n"));
   for (i = 0; i < n; i++)
     {
@@ -5232,8 +3892,6 @@
   if ((bp0 == NULL) || (bp1 == NULL))
     return (NULL);
 
-  IF_MARC (aBndP0) return (M_BNDP_CreateBndP (Heap, aBndP0, aBndP1, lcoord));
-
   p0 = currBVP->patches[bp0->patch_id];
   p1 = currBVP->patches[bp1->patch_id];
 
@@ -5381,9 +4039,6 @@
   if (bp == NULL)
     return (1);
 
-  IF_MARC (theBndP)
-    return (M_BNDP_SaveInsertedBndP (theBndP, data, max_data_size));
-
   pid = bp->patch_id;
   p = currBVP->patches[pid];
 
@@ -5438,8 +4093,6 @@
   if (ps == NULL)
     return (1);
 
-  IF_MARC (aBndP) return (M_BNDP_BndCond (aBndP, n, i, in, value, type));
-
   p = currBVP->patches[ps->patch_id];
 
   switch (PATCH_TYPE (p))
@@ -5539,8 +4192,6 @@
   if (theBndP == NULL)
     return (0);
 
-  IF_MARC (theBndP) return (M_BNDP_Dispose (Heap, theBndP));
-
   ps = (BND_PS *) theBndP;
   if (!PATCH_IS_FIXED (currBVP->patches[ps->patch_id]))
     if (PutFreelistMemory (Heap, BND_DATA (ps), DIM * sizeof (DOUBLE)))
@@ -5557,8 +4208,6 @@
   if (theBndS == NULL)
     return (0);
 
-  IF_MARC (theBndS) return (M_BNDS_Dispose (Heap, theBndS));
-
   ps = (BND_PS *) theBndS;
   if (!PATCH_IS_FIXED (currBVP->patches[ps->patch_id]))
     if (PutFreelistMemory (Heap, BND_DATA (ps), BND_N (ps) * sizeof (BNDP *)))
@@ -5568,7 +4217,7 @@
 
 /* the following interface functions are not available in std_domain.c */
 INT NS_DIM_PREFIX
-BVP_Save (BVP * theBVP, char *name, char *mgname, HEAP * theHeap, INT argc,
+BVP_Save (BVP * theBVP, const char *name, const char *mgname, HEAP * theHeap, INT argc,
 	  char **argv)
 {
   UserWrite ("ERROR: std domain cannot be saved\n");
@@ -5576,7 +4225,7 @@
 }
 
 BVP *NS_DIM_PREFIX
-BVP_Load (char *name, INT argc, char **argv)
+BVP_Load (const char *name, INT argc, char **argv)
 {
   return (NULL);
 }
@@ -5590,8 +4239,6 @@
   int iList[2];
   double dList[DIM];
 
-  IF_MARC (BndP) return (M_BNDP_SaveBndP (BndP));
-
   iList[0] = BND_PATCH_ID (BndP);
   iList[1] = BND_N (BndP);
   if (Bio_Write_mint (2, iList))
@@ -5620,9 +4267,6 @@
 }
 
 
-#define IO_MARC
-
-
 INT NS_DIM_PREFIX
 BNDP_SaveBndP_Ext (BNDP * BndP)
 {
@@ -5631,22 +4275,6 @@
   int iList[2];
   double dList[DIM - 1];
 
-#ifdef IO_MARC
-  {
-    M_BNDP *p = (M_BNDP *) BndP;
-
-    iList[0] = p->patch_id;
-    if (Bio_Write_mint (1, iList))
-      return (1);
-
-    for (j = 0; j < DIM; j++)
-      dList[j] = p->pos[j];
-    if (Bio_Write_mdouble (DIM, dList))
-      return (1);
-    return (0);
-  }
-#endif
-
   /* TODO: save free boundary points */
   iList[0] = BND_PATCH_ID (BndP);
   iList[1] = BND_N (BndP);
@@ -5684,9 +4312,6 @@
   int iList[2];
   double dList[DIM];
 
-  if (((STD_BVP *) theBVP)->type == BVP_MARC)
-    return (M_BNDP_LoadBndP (theBVP, Heap));
-
   if (Bio_Read_mint (2, iList))
     return (NULL);
   pid = iList[0];
@@ -5732,23 +4357,6 @@
   int iList[2];
   double dList[DIM - 1];
 
-#ifdef IO_MARC
-  {
-    M_BNDP *p = (M_BNDP *) malloc (sizeof (M_BNDP));
-
-    if (Bio_Read_mint (1, iList))
-      return (NULL);
-    p->patch_id = iList[0];
-    if (Bio_Read_mdouble (DIM, dList))
-      return (NULL);
-
-    for (j = 0; j < DIM; j++)
-      p->pos[j] = dList[j];
-
-    return ((BNDP *) p);
-  }
-#endif
-
   if (Bio_Read_mint (2, iList))
     return (NULL);
   pid = iList[0];
@@ -5769,7 +4377,7 @@
 }
 
 INT NS_DIM_PREFIX
-ReadAndPrintArgvPosition (char *name, INT argc, char **argv, DOUBLE * pos)
+ReadAndPrintArgvPosition (const char *name, INT argc, char **argv, DOUBLE * pos)
 {
   INT i;
   char option[OPTIONLEN];
diff -ruN ug-orig/dom/std/std_domain.h ug-patched/dom/std/std_domain.h
--- ug-orig/dom/std/std_domain.h	2006-05-08 14:21:44.000000000 +0200
+++ ug-patched/dom/std/std_domain.h	2009-04-29 15:11:55.000000000 +0200
@@ -31,7 +31,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/dom/std/std_domain.h,v 1.34 2006/05/08 12:21:44 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -100,42 +100,49 @@
                                                                  DOUBLE radius, INT segments, 
                                                                  INT corners, INT Convex);
 
+void RemoveDomain(const char* name);
+
 void   *CreateBoundarySegment       (const char *name, INT left, INT right,
                                                  INT id, enum BoundaryType type, INT res,
-                                                 INT *point, 
+                                                 const INT *point, 
                                      const DOUBLE *alpha, const DOUBLE *beta, 
                                                  BndSegFuncPtr BndSegFunc, 
                                                  void *data);
 
-void   *CreateBoundarySegment2D     (char *name, int left, int right, 
+void   *CreateBoundarySegment2D     (const char *name, int left, int right, 
                                                  int id, int from, int to, int res,
                                                  DOUBLE alpha, DOUBLE beta, 
                                                  BndSegFuncPtr BndSegFunc, 
                                                  void *data);
 
+void *CreateLinearSegment (const char *name,
+                           INT left, INT right,INT id,
+                           INT n, const INT *point, 
+                           DOUBLE x[CORNERS_OF_BND_SEG][DIM]);
+
+/** \brief Access the id of the segment (used by DUNE) */
+UINT GetBoundarySegmentId(BNDS* boundarySegment);
+
 /* problem definition */
-void                    *CreateProblem                       (char *domain, char *name, 
+void                    *CreateProblem                       (const char *domain, const char *name, 
                                                                  int id, ConfigProcPtr config, 
                                                                  int numOfCoefficients, 
                                                                  CoeffProcPtr coeffs[], 
                                                                  int numOfUserFct, 
                                                                  UserProcPtr userfct[]);
 
-void *CreateBoundaryCondition (char *name, INT id, 
+void *CreateBoundaryCondition (const char *name, INT id, 
                                              BndCondProcPtr theBndCond, 
                                              void *Data);
 
 BVP   *CreateBoundaryValueProblem (const char *BVPname, BndCondProcPtr theBndCond,
                                                                    int numOfCoeffFct, CoeffProcPtr coeffs[],
                                                                    int numOfUserFct, UserProcPtr userfct[]);
-BVP       *CreateBVP                              (char *BVP, char *Domain, char *Problem);
+BVP       *CreateBVP              (const char *BVP, const char *Domain, const char *Problem);
 const char *GetBVP_DomainName     (const BVP *aBVP);
 const char *GetBVP_ProblemName    (const BVP *aBVP);
-BVP   *Create_MarcBVP             (char *BVPname, BndCondProcPtr theBndCond,
-                                                                   int numOfCoeffFct, CoeffProcPtr coeffs[],
-                                                                   int numOfUserFct, UserProcPtr userfct[]);
 
-BVP *CreateBVP_Problem (char *BVPName, char *DomainName, char *ProblemName);
+BVP *CreateBVP_Problem (const char *BVPName, const char *DomainName, const char *ProblemName);
 
 END_UGDIM_NAMESPACE
 
diff -ruN ug-orig/dom/std/std_internal.h ug-patched/dom/std/std_internal.h
--- ug-orig/dom/std/std_internal.h	2006-05-08 14:21:44.000000000 +0200
+++ ug-patched/dom/std/std_internal.h	2008-03-10 09:50:51.000000000 +0100
@@ -26,16 +26,12 @@
 
 typedef DOUBLE COORD_BND_VECTOR[DIM_OF_BND];
 
-enum {BVP_STANDARD, 
-      BVP_MARC};
-
 enum PatchType {POINT_PATCH_TYPE,
+#ifdef __THREEDIM__
                 LINE_PATCH_TYPE,
+#endif
                 LINEAR_PATCH_TYPE,
-                PARAMETRIC_PATCH_TYPE,
-                MARC_0_PATCH_TYPE,
-                MARC_1_PATCH_TYPE,
-                MARC_2_PATCH_TYPE};
+                PARAMETRIC_PATCH_TYPE};
 
 /** @name  Macros for DOMAIN_PART_INFO */
 /*@{*/
@@ -62,9 +58,6 @@
 
 /** @name Macros for STD_BVP */
 /*@{*/
-#define MAX_CORNERS_OF_LINEAR_PATCH      DIM
-
-
 #define STD_BVP_NAME(p)                                 ENVITEM_NAME(p)
 
 #define STD_BVP_DOMAIN(p)                               ((p)->Domain)
@@ -128,9 +121,9 @@
 
 /** @name Macros for patches */
 /*@{*/
-#define PATCH_FIXED                             0
-#define PATCH_BND_OF_FREE               1
-#define PATCH_FREE                              2
+enum {PATCH_FIXED,
+      PATCH_BND_OF_FREE,
+      PATCH_FREE};
 
 #define PATCH_TYPE(p)           (p)->ge.type
 #define PATCH_STATE(p)          (p)->ge.state
@@ -169,8 +162,6 @@
 #define M_BNDS_NSIZE(n)         (((n)-1)*sizeof(M_BNDP)+sizeof(M_BNDS))
 #define M_BNDS_SIZE(p)          M_BNDS_NSIZE(((M_BNDS *)(p))->n)
 
-#define IF_MARC(p) \
-    if (PATCH_TYPE(currBVP->patches[BND_PATCH_ID(p)]) >= MARC_0_PATCH_TYPE)
 /*@}*/
 
 /****************************************************************************/
@@ -277,10 +268,10 @@
     INT n;
 
     /** \brief  Numbers of the vertices (ID)*/
-    INT points[MAX_CORNERS_OF_LINEAR_PATCH];
+    INT points[CORNERS_OF_BND_SEG];
 
     /** \brief  Coordinates  */
-    DOUBLE x[MAX_CORNERS_OF_LINEAR_PATCH][DIM_OF_BND];
+    DOUBLE x[CORNERS_OF_BND_SEG][DIM];
 };
 
 /****************************************************************************/
@@ -379,9 +370,6 @@
     /** \brief Fields for environment directory */
     NS_PREFIX ENVDIR d;
     
-    /* init */
-    INT type; 
-
     /** \brief Domain pointer                      */
     struct domain *Domain;
 
@@ -557,10 +545,10 @@
     INT corners;
 
     /** \brief Ids of points */
-    INT points[MAX_CORNERS_OF_LINEAR_PATCH];
+    INT points[CORNERS_OF_BND_SEG];
 
     /** \brief Position */
-    DOUBLE pos[MAX_CORNERS_OF_LINEAR_PATCH][DIM];
+    DOUBLE pos[CORNERS_OF_BND_SEG][DIM];
 };
     /** \brief ???
      *
@@ -609,66 +597,6 @@
      *
      * \todo Please doc me! 
      */
-struct marc_0_patch {
-
-    /** \brief Patch type                           */
-    enum PatchType type;
-
-    /** \brief Fixed/bnd of free/free               */
-    INT state;
-    
-    /** \brief Unique id used for load/store        */
-    INT id;
-
-    /** \brief Position                             */
-    DOUBLE pos[3];
-};
-
-    /** \brief ???
-     *
-     * \todo Please doc me! 
-     */
-struct marc_1_patch {
-
-    /** \brief Patch type                           */
-    enum PatchType type;
-    
-    /** \brief Fixed/bnd of free/free               */
-    INT state;
-
-    /** \brief Unique id used for load/store        */
-    INT id;
-    
-    /** \brief Line between two points              */
-    INT p[2];
-};
-
-    /** \brief ???
-     *
-     * \todo Please doc me! 
-     */
-struct marc_2_patch {
-
-    /** \brief Patch type                           */
-    enum PatchType type;
-    
-    /** \brief Fixed/bnd of free/free               */
-    INT state;
-    
-    /** \brief Unique id used for load/store        */
-    INT id;
-    
-    /** \brief Bnd cond                             */
-    INT c;
-    
-    /** \brief Triangle of three points             */
-    INT p[3];
-};
-
-    /** \brief ???
-     *
-     * \todo Please doc me! 
-     */
 union patch {
         struct generic_patch   ge;
         struct point_patch     po;
@@ -677,9 +605,6 @@
     #ifdef __THREEDIM__
         struct line_patch      li;
         #endif
-        struct marc_0_patch    m0;
-        struct marc_1_patch    m1;
-        struct marc_2_patch    m2;
 } ;
 
     /** \brief ???
@@ -700,34 +625,6 @@
     /** \brief Parameter range                      */
     COORD_BND_VECTOR local[1];
 };
-    /** \brief ???
-     *
-     * \todo Please doc me! 
-     */
-struct marc_bndp {
-
-    /** \brief Associated patch                     */
-    INT patch_id;
-
-    /** \brief Position                             */
-    DOUBLE pos[3];
-};
-
-    /** \brief ???
-     *
-     * \todo Please doc me! 
-     */
-struct marc_bnds {
-
-    /** \brief associated patch */
-    INT patch_id;
-
-    /** \brief number of corners */
-    INT n;
-
-    /** \brief corners */
-    struct marc_bndp p[1];
-};
 
 /*----------- typedef for structs ------------------------------------------*/
 
@@ -745,12 +642,7 @@
 typedef struct line_patch               LINE_PATCH;
 typedef struct linear_patch             LINEAR_PATCH;
 typedef struct parameter_patch          PARAMETER_PATCH;
-typedef struct marc_0_patch             M0_PATCH;
-typedef struct marc_1_patch             M1_PATCH;
-typedef struct marc_2_patch             M2_PATCH;
 typedef struct bnd_ps                   BND_PS;
-typedef struct marc_bndp                M_BNDP;
-typedef struct marc_bnds                M_BNDS;
 
 /****************************************************************************/
 /*                                                                          */
@@ -764,24 +656,13 @@
 /*                                                                          */
 /****************************************************************************/
 
-# ifdef __THREEDIM__
-INT RepairMesh (NS_PREFIX HEAP *Heap, INT MarkKey, MESH *mesh);
-INT CheckPrisms (INT *corner, INT n0, INT n1 , INT n2, INT n3);
-# endif
-void SetBVPType(INT type);
-
-DOMAIN *GetDomain                           (char *name);
-
-LINEAR_SEGMENT *CreateLinearSegment (char *name,
-                                     INT left, INT right,INT id,
-                                     INT n, INT *point, 
-                                     DOUBLE x[MAX_CORNERS_OF_LINEAR_PATCH][DIM_OF_BND]);
+DOMAIN *GetDomain                           (const char *name);
 
 /* BVP definition */
 INT   STD_BVP_Configure           (INT argc, char **argv);
 
 /* scanning of coordinates */
-INT   ReadAndPrintArgvPosition    (char *name, INT argc, char **argv, DOUBLE *pos);
+INT   ReadAndPrintArgvPosition    (const char *name, INT argc, char **argv, DOUBLE *pos);
 
 END_UGDIM_NAMESPACE
 
diff -ruN ug-orig/dom/std/std_parallel.c ug-patched/dom/std/std_parallel.c
--- ug-orig/dom/std/std_parallel.c	2006-07-25 10:46:49.000000000 +0200
+++ ug-patched/dom/std/std_parallel.c	2008-12-19 11:15:14.000000000 +0100
@@ -28,6 +28,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -52,7 +53,14 @@
 /* domain module */
 #include "std_internal.h"
 
-USING_UG_NAMESPACES
+#include "namespace.h"
+
+USING_UGDIM_NAMESPACE
+USING_UG_NAMESPACE
+
+#ifdef ModelP
+USING_PPIF_NAMESPACE
+#endif
 
 /****************************************************************************/
 /*																			*/
@@ -83,10 +91,8 @@
 /*																			*/
 /****************************************************************************/
 
-static INT BVP_type = BVP_STANDARD;
-
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/dom/std/std_parallel.c,v 1.12 2006/07/25 08:46:49 sander Exp $",UG_RCS_STRING); 
+static char RCS_ID("$Header$",UG_RCS_STRING); 
 
 /****************************************************************************/
 /*																			*/
@@ -94,11 +100,6 @@
 /*																			*/
 /****************************************************************************/
 
-void NS_DIM_PREFIX SetBVPType(INT type)
-{
-    BVP_type = type;
-}
-
 void NS_DIM_PREFIX DomInitParallel (INT TypeBndP, INT TypeBndS)
 {
 }
@@ -107,121 +108,10 @@
 {    
 }
 
-static void M_BElementXferBndS (BNDS **bnds, int n, int proc, int prio)
-{
-    INT size,i,size0;
-
-	size = CEIL(sizeof(INT));
-	for (i=0; i<n; i++)	  
-	  if (bnds[i] != NULL) 
-		{
-		  size0 = M_BNDS_SIZE(bnds[i]);
-		  size += CEIL(size0) + CEIL(sizeof(INT));
-
-			PRINTDEBUG(dom,2,("BElementXferBndS(): Xfer  me %x "
-				"%d pid %d n %d size %d\n",
-				me,bnds[i],BND_PATCH_ID(bnds[i]),
-				(int)(((M_BNDS *)(bnds[i]))->n),size0));
-
-		}
-
-	DDD_XferAddData(size,DDD_DOMAIN_DATA);
-}
-
-static void M_BElementGatherBndS (BNDS **bnds, int n, int cnt, char *data)
-{
-    INT size,i;
-
-	for (i=0; i<n; i++)	  
-	  if (bnds[i] != NULL) 
-		{
-		  size = M_BNDS_SIZE(bnds[i]);
-
-		  PRINTDEBUG(dom,2,("BElementGatherBndS(): %d  "
-							"me %d %x pid %d n %d size %d\n",i,
-							me,bnds[i],BND_PATCH_ID(bnds[i]),
-							(int)(((M_BNDS *)(bnds[i]))->n),size));
-
-
-		  memcpy(data,&i,sizeof(INT));
-		  data += CEIL(sizeof(INT));
-		  memcpy(data,bnds[i],size);
-		  data += CEIL(size);
-		}
-	i = -1;
-	memcpy(data,&i,sizeof(INT));
-}
-
-static void M_BElementScatterBndS (BNDS **bnds, int n, int cnt, char *data)
-{
-    INT size,i;
-	BNDS *bs;
-
-	memcpy(&i,data,sizeof(INT));
-	while (i != -1)
-	  {
-		data += CEIL(sizeof(INT));
-		bs = (BNDS *) data;
-		size = M_BNDS_SIZE(bs);
-
-		PRINTDEBUG(dom,1,("BElementScatterBndS(): %d me %d\n",i,size));
-
-		if (bnds[i] == NULL)
-		  {
-			bs = (BNDS *) memmgr_AllocOMEM((size_t)size,TypeBndS,0,0);
-			memcpy(bs,data,size);
-			bnds[i] = bs;
-		  }
-		data += CEIL(size);
-		memcpy(&i,data,sizeof(INT));
-	  }
-}
-
-static void M_BVertexXferBndP (BNDP *bndp, int proc, int prio)
-{
-    INT size;
-
-	size = sizeof(M_BNDP);
-
-	PRINTDEBUG(dom,2,("BVertexXferBndP():  me %x %d pid %d n %d size %d\n",
-					  me,bndp,BND_PATCH_ID(bndp),BND_N(bndp),BND_SIZE(bndp)));
-
-	DDD_XferAddData(size,DDD_DOMAIN_DATA);
-}
-
-static void M_BVertexGatherBndP (BNDP *bndp, int cnt, char *data)
-{
-	PRINTDEBUG(dom,2,("BVertexGatherBnd():  me %d pid %d "
-		"n %d size %d cnt %d\n",
-		me,BND_PATCH_ID(bndp),
-		BND_N(bndp),BND_SIZE(bndp),cnt));
-
-    ASSERT(cnt == sizeof(M_BNDP));
-
-	memcpy(data,bndp,cnt);
-}
-
-static void M_BVertexScatterBndP (BNDP **bndp, int cnt, char *data)
-{
-	if (*bndp == NULL)
-	  {
-		*bndp = (BNDP *) memmgr_AllocOMEM((size_t)cnt,TypeBndP,0,0);
-		memcpy(*bndp,data,cnt);
-		PRINTDEBUG(dom,2,("BVertexScatterBndP():  me %d pid "
-			"%d n %d size %d cnt %d\n",
-			me,BND_PATCH_ID(*bndp),
-			BND_N(*bndp),BND_SIZE(*bndp),cnt));
-	  }
-}
-
 void NS_DIM_PREFIX BElementXferBndS (BNDS **bnds, int n, int proc, int prio)
 {
     INT size,i,size0;
 
-	if (BVP_type == BVP_MARC) {
-	    M_BElementXferBndS(bnds,n,proc,prio);
-		return;
-	}
 	size = CEIL(sizeof(INT));
 	for (i=0; i<n; i++)	  
 	  if (bnds[i] != NULL) 
@@ -243,10 +133,6 @@
 {
     INT size,i;
 
-	if (BVP_type == BVP_MARC) {
-	    M_BElementGatherBndS(bnds,n,cnt,data);
-		return;
-	}
 	for (i=0; i<n; i++)	  
 	  if (bnds[i] != NULL) 
 		{
@@ -272,10 +158,6 @@
     INT size,i;
 	BNDS *bs;
 
-	if (BVP_type == BVP_MARC) {
-	    M_BElementScatterBndS(bnds,n,cnt,data);
-		return;
-	}
 	memcpy(&i,data,sizeof(INT));
 	while (i != -1)
 	  {
@@ -300,10 +182,6 @@
 {
     INT size;
 
-	if (BVP_type == BVP_MARC) {
-	    M_BVertexXferBndP(bndp,proc,prio);
-		return;
-	}
 	size = BND_SIZE(bndp);
 
 	PRINTDEBUG(dom,1,("BVertexXferBndP():  me %x %d pid %d n %d size %d\n",
@@ -314,10 +192,6 @@
 
 void NS_DIM_PREFIX BVertexGatherBndP (BNDP *bndp, int cnt, char *data)
 {
-	if (BVP_type == BVP_MARC) {
-	    M_BVertexGatherBndP(bndp,cnt,data);
-		return;
-	}
 	PRINTDEBUG(dom,1,("BVertexGatherBnd():  me %d pid %d "
 		"n %d size %d cnt %d\n",
 		me,BND_PATCH_ID(bndp),
@@ -331,10 +205,6 @@
 
 void NS_DIM_PREFIX BVertexScatterBndP (BNDP **bndp, int cnt, char *data)
 {
-	if (BVP_type == BVP_MARC) {
-	    M_BVertexScatterBndP(bndp,cnt,data);
-		return;
-	}
 	if (*bndp == NULL)
 	  {
 		*bndp = (BNDS *) memmgr_AllocOMEM((size_t)cnt,TypeBndP,0,0);
diff -ruN ug-orig/dom/switch.h ug-patched/dom/switch.h
--- ug-orig/dom/switch.h	2006-02-06 09:56:44.000000000 +0100
+++ ug-patched/dom/switch.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,226 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  switch.h														*/
-/*																			*/
-/* Purpose:   standard header file template 								*/
-/*																			*/
-/* Author:	  Klaus Johannsen												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de 				*/
-/*																			*/
-/* History:   29.10.93 begin, ug 3D-version 								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __SWITCH__
-#define __SWITCH__
-
-
-#include "compiler.h"
-#include "dimension.h"
-
-#ifdef __MWCW__
-#include "MWCW.cmdlinedefs"
-#endif
-
-/*D
-switch - switch header file, extracts makefile switches and sets some constants
-
-DESCRIPTION:
-
-This file processes the switches defined in the 'makefile' (see page 'makefiles')
-and sets some constants depending on these switches. This file is included
-in all UG source files.
-
-The following constants defined with the '#define' preprocessor command
-can be used for conditional compilation.
-
-.vb
-__NODEDATA__
-__EDGEDATA__
-__SIDEDATA__
-__ELEMDATA__
-.ve
-
-If defined, these constants indicate that degrees of freedom are allowed
-in the respective object.
-
-.vb
-__TWODIM__
-__THREEDIM__
-.ve
-
-One of these two constants is defined, indicating compilation
-of a 2D or 3D version.
-
-.vb
-__version23__
-__version3__
-.ve
-
-Indicates which version is compiled. '__version23__' is for a version
-that is compatible with UG version 2.3 (a version without the
-matrix vector structure).
-
-.vb
-DIM
-DIM_OF_BND
-CORNERS_OF_BND_SEG
-MAXVECTORS
-.ve
-
-These constants are dimension-dependent and are set to the space
-dimension, the dimension of the boundary, the number of corners
-of a boundary segment and the possible number of different 'VECTOR'
-sizes.
-
-.vb
-NODEVECTOR
-EDGEVECTOR
-ELEMVECTOR
-SIDEVECTOR
-.ve
-
-These constants encode the geometric position of a 'VECTOR'.
-
-D*/
- 
- 
-/****************************************************************************/
-/*																			*/
-/* check for defines from makefile											*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef NodeT
-#define Nodeon
-#else
-#define Nodeoff
-#endif
-
-#ifdef EdgeT
-#define Edgeon
-#else
-#define Edgeoff
-#endif
-
-#ifdef SideT
-#define Sideon
-#else
-#define Sideoff
-#endif
-
-#ifdef ElemT
-#define Elemon
-#else
-#define Elemoff
-#endif
-
-#if defined Nodeoff && defined Edgeoff && defined Sideoff && defined Elemoff
-	#ifdef _3
-	#error ****	define at least one of NodeT, ElemT, SideT, EdgeT for 3d version	   ****
-	#endif
-#define __version23__
-#endif
-
-#ifdef two
-#ifdef Sideon
-#error ****   two dimensional case cannot have side data	****
-#endif
-#endif
-
-#undef __GRAPE_TRUE__
-#ifdef _3
-#ifdef GRAPET
-#define __GRAPE_TRUE__
-#endif
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* basic switch-defines for:												*/
-/*	  dimensions															*/
-/*	  user data in geometric components (nodes,edges,sides,elems)			*/
-/*																			*/
-/*	  dependent of makefile-defines 										*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef Nodeon
-#define __NODEDATA__
-#define NODE_DATA	1
-#endif
-#ifndef Nodeon
-#define NODE_DATA	0
-#endif
-
-#ifdef Edgeon
-#define __EDGEDATA__
-#define EDGE_DATA	2
-#endif
-#ifndef Edgeon
-#define EDGE_DATA	0
-#endif
-
-#ifdef Elemon
-#define __ELEMDATA__
-#define ELEM_DATA	4
-#endif
-#ifndef Elemon
-#define ELEM_DATA	0
-#endif
-
-#ifdef Sideon
-#define __SIDEDATA__
-#define SIDE_DATA	8
-#endif
-#ifndef Sideon
-#define SIDE_DATA	0
-#endif
-
-#ifndef __version23__
-#define __version3__
-#endif
-
-#define DATA_TYPES			(NODE_DATA | EDGE_DATA | SIDE_DATA | ELEM_DATA)
-#define ALL_TYPES		(NODE_DATA | EDGE_DATA | SIDE_DATA | ELEM_DATA)
-#define TYPES_EXISTING(t)	((((t)|DATA_TYPES)==DATA_TYPES)&&(t))
-
-/****************************************************************************/
-/*																			*/
-/* switch-define dependent defines											*/
-/*																			*/
-/****************************************************************************/
-
-#define DIM_MAX 					3				/* maximal space dimension						*/
-#define DIM_OF_BND_MAX				2				/* maximal dimension of boundary surface		*/
-
-#ifdef __TWODIM__
-	#define DIM 					2				/* space dimension								*/
-	#define DIM_OF_BND				1				/* dimension of boundary surface				*/
-	#define CORNERS_OF_BND_SEG		2				/* number of corners of a boundary side 		*/
-	#define MAXVECTORS				3				/* three different data types					*/
-#endif
-
-#ifdef __THREEDIM__
-	#define DIM 					3				/* space dimension								*/
-	#define DIM_OF_BND				2				/* dimension of boundary surface				*/
-	#define CORNERS_OF_BND_SEG		4				/* number of corners of a boundary side 		*/
-	#define MAXVECTORS				4				/* four different data types					*/
-	#define __MIDNODE__
-#endif
-
-/* values for vectors */
-#define NODEVECTOR					0				/* vector associated to a node					*/
-#define EDGEVECTOR					1				/* vector associated to an edge 				*/
-#define ELEMVECTOR					2				/* vector associated to an element				*/
-#define SIDEVECTOR					3				/* vector associated to an elementside			*/
-
-#define DATATYPE_FROM_VECTORTYPE(t) (1<<(t))	/* transforms VectorType into DataType			*/
-
-#endif
diff -ruN ug-orig/gcc.opts ug-patched/gcc.opts
--- ug-orig/gcc.opts	2004-09-02 14:22:03.000000000 +0200
+++ ug-patched/gcc.opts	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: gcc.opts,v 1.1 2004/09/02 12:22:03 thimo Exp $
+# $Id: gcc.opts 7772 2004-09-02 12:22:17Z thimo $
 
 # options for gcc/g++
 # remember to run ./autogen.sh after changing these values!
diff -ruN ug-orig/gm/algebra.c ug-patched/gm/algebra.c
--- ug-orig/gm/algebra.c	2006-06-14 09:51:37.000000000 +0200
+++ ug-patched/gm/algebra.c	2009-04-29 14:30:36.000000000 +0200
@@ -52,6 +52,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -299,7 +300,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/algebra.c,v 1.171 2006/06/14 07:51:37 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -497,8 +498,8 @@
 
 BLOCKVECTOR *NS_DIM_PREFIX FindBV( const GRID *grid, const BV_DESC *bvd, const BV_DESC_FORMAT *bvdf )
 {
-	register BLOCKVECTOR *bv;
-	register BLOCKNUMBER nr;
+	BLOCKVECTOR *bv;
+	BLOCKNUMBER nr;
 	BV_DESC copy_bvd = *bvd;
 
 	/* initialize the search with the topmost blockvector in the grid */
@@ -709,6 +710,13 @@
 	SETVNEW(pv,1);
 	/* SETPRIO(pv,PrioMaster); */
 
+#ifdef FOR_DUNE
+        /** \todo This line is a hack.  It is used to implement face ids for Dune.
+            As soon as the face data structure is available the id should be stored
+            there.  Then this code can be removed again. */
+        pv->id = (theGrid->mg->vectorIdCounter)++;
+#endif
+
     #ifdef __BLOCK_VECTOR_DESC__ 
 	BVD_INIT( &VBVD( pv ) );
     #endif
@@ -1328,7 +1336,7 @@
 
 static void FreeBVList (GRID *grid, BLOCKVECTOR *bv)
 {
-	register BLOCKVECTOR *bv_h;
+	BLOCKVECTOR *bv_h;
 
 	if ( bv == NULL )
 		return;
@@ -3438,7 +3446,7 @@
 */										
 /****************************************************************************/
 
-static INT CheckVector (const FORMAT *fmt, const INT s2p[], GEOM_OBJECT *theObject, char *ObjectString, 
+static INT CheckVector (const FORMAT *fmt, const INT s2p[], GEOM_OBJECT *theObject, const char *ObjectString, 
 		VECTOR *theVector, INT VectorObjType, INT side)
 {
 	GEOM_OBJECT *VecObject;
@@ -4439,7 +4447,7 @@
 	PRINTDEBUG(gm,1,("\n" PFMT "PropagateNextVectorClasses(): 1. communication\n",me))
    	/* exchange VNCLASS of vectors */
 	DDD_IFAExchange(BorderVectorSymmIF,GRID_ATTR(theGrid),sizeof(INT),
-				  Gather_VectorVNClass, Scatter_VectorVNClass);
+                    Gather_VectorVNClass, Scatter_VectorVNClass);
     #endif
 
 	if (PropagateNextVectorClass(theGrid,3)) REP_ERR_RETURN(1);
@@ -4811,7 +4819,7 @@
 */										
 /****************************************************************************/
 
-FIND_CUT * NS_DIM_PREFIX CreateFindCutProc (char *name, FindCutProcPtr FindCutProc)
+FIND_CUT * NS_DIM_PREFIX CreateFindCutProc (const char *name, FindCutProcPtr FindCutProc)
 {
 	FIND_CUT *newFindCut;
 
@@ -4839,7 +4847,7 @@
 */										
 /****************************************************************************/
 
-ALG_DEP * NS_DIM_PREFIX CreateAlgebraicDependency (char *name, DependencyProcPtr DependencyProc)
+ALG_DEP * NS_DIM_PREFIX CreateAlgebraicDependency (const char *name, DependencyProcPtr DependencyProc)
 {
 	ALG_DEP *newAlgDep;
 
@@ -6856,9 +6864,9 @@
 static INT CreateBVPlane( BLOCKVECTOR **bv_plane, const BV_DESC *bvd_plane, const BV_DESC_FORMAT *bvdf, VECTOR **v, INT stripes, INT vectors_per_stripe, GRID *grid )
 {
 	BLOCKVECTOR *bv;
-	register BLOCKVECTOR *prev;
-	register INT i, j;
-	register VECTOR *pred_v;
+	BLOCKVECTOR *prev;
+	INT i, j;
+	VECTOR *pred_v;
 
 	(void)CreateBlockvector( grid, bv_plane );
 	if ( *bv_plane == NULL )
@@ -7252,7 +7260,7 @@
 #ifdef __BLOCK_VECTOR_DESC__ 
 	BLOCKVECTOR *bv;
 	INT ret;
-	register VECTOR *v, *end_v;
+	VECTOR *v, *end_v;
 	
 	if ( GFIRSTBV( grid ) != NULL )
 		FreeAllBV( grid );
@@ -7335,7 +7343,7 @@
 {
 	VECTOR *v, *vpred, *end_v, **v0, **v1, **vi;
 	BLOCKVECTOR *bv0, *bv1, *bvi;
-	register INT index, interface, nr_0, nr_1, nr_i;
+	INT index, interface, nr_0, nr_1, nr_i;
 	VECTOR *pred_first_vec;
 
     #ifndef __BLOCK_VECTOR_DESC__ 
diff -ruN ug-orig/gm/algebra.h ug-patched/gm/algebra.h
--- ug-orig/gm/algebra.h	2006-06-02 18:12:47.000000000 +0200
+++ ug-patched/gm/algebra.h	2007-04-17 16:02:22.000000000 +0200
@@ -38,7 +38,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/algebra.h,v 1.37 2006/06/02 16:12:47 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -74,9 +74,9 @@
 };
 
 #define GET_MATRIX(v,w,m)                                                   \
-{ register MATRIX *theMatrix0;                                              \
-  register VECTOR *theVector0 = (v);                                        \
-  register VECTOR *theVector1 = (w);                                        \
+{ MATRIX *theMatrix0;                                                       \
+  VECTOR *theVector0 = (v);                                                 \
+  VECTOR *theVector1 = (w);                                                 \
   (m) = NULL;                                                               \
   if (theVector0 == theVector1) (m) = VSTART(theVector0);                   \
   else if (VINDEX(theVector0) > VINDEX(theVector1)) {                       \
diff -ruN ug-orig/gm/CVS/Entries ug-patched/gm/CVS/Entries
--- ug-orig/gm/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,63 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:16 2004//D2008.11.12.23.00.00
-/2Dversion/1.1/Fri Nov 10 21:04:45 1995//D2008.11.12.23.00.00
-/3Dversion/1.1/Fri Nov 10 21:05:04 1995//D2008.11.12.23.00.00
-/GenerateRules.c/1.3/Fri Jul 18 14:58:56 1997//D2008.11.12.23.00.00
-/GenerateRules.h/1.3/Wed Jan 21 10:16:10 2004//D2008.11.12.23.00.00
-/GenerateRules.make/1.1.1.1/Fri Sep 15 16:53:38 1995//D2008.11.12.23.00.00
-/Makefile.am/1.2/Fri Oct 15 14:22:28 2004//D2008.11.12.23.00.00
-/Makefile.gm/1.17/Tue May  7 14:19:15 2002//D2008.11.12.23.00.00
-/algebra.c/1.171/Wed Jun 14 07:51:37 2006//D2008.11.12.23.00.00
-/algebra.h/1.37/Fri Jun  2 16:12:47 2006//D2008.11.12.23.00.00
-/cw.c/1.48/Mon Jul 18 13:42:57 2005//D2008.11.12.23.00.00
-/cw.h/1.11/Mon May  8 12:29:56 2006//D2008.11.12.23.00.00
-/dlmgr.c/1.12/Fri Jun  2 15:36:28 2006//D2008.11.12.23.00.00
-/dlmgr.h/1.23/Mon May  8 12:29:56 2006//D2008.11.12.23.00.00
-/dlmgr.t/1.20/Tue Oct 16 12:46:53 2007//D2008.11.12.23.00.00
-/elements.c/1.38/Wed Jan 26 13:18:58 2005//D2008.11.12.23.00.00
-/elements.h/1.15/Mon May  8 12:29:56 2006//D2008.11.12.23.00.00
-/enrol.c/1.23/Wed Jul 21 09:18:35 2004//D2008.11.12.23.00.00
-/enrol.h/1.12/Mon May  8 12:29:56 2006//D2008.11.12.23.00.00
-/er.c/1.19/Mon Jul 18 08:19:27 2005//D2008.11.12.23.00.00
-/er.h/1.7/Mon May  8 12:29:56 2006//D2008.11.12.23.00.00
-/evalproc.c/1.25/Fri Jun  2 15:36:29 2006//D2008.11.12.23.00.00
-/evm.c/1.30/Mon Nov 19 18:48:21 2007//D2008.11.12.23.00.00
-/evm.h/1.40/Fri Jun  2 16:12:47 2006//D2008.11.12.23.00.00
-/gm.doc/1.16/Mon Mar  8 08:38:05 2004//D2008.11.12.23.00.00
-/gm.h/1.252/Fri Feb  1 12:57:04 2008//D2008.11.12.23.00.00
-/gm.make/1.2/Wed Nov 15 18:47:22 1995//D2008.11.12.23.00.00
-/gmcheck.c/1.51/Wed Jul 12 12:55:48 2006//D2008.11.12.23.00.00
-/gr.make/1.1.1.1/Fri Sep 15 16:53:42 1995//D2008.11.12.23.00.00
-/initgm.c/1.23/Tue Jun 14 16:01:22 2005//D2008.11.12.23.00.00
-/initgm.h/1.10/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/mgheapmgr.c/1.8/Wed Jul 21 09:18:36 2004//D2008.11.12.23.00.00
-/mgheapmgr.h/1.6/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/mgio.c/1.65/Fri Jun  2 16:13:11 2006//D2008.11.12.23.00.00
-/mgio.h/1.51/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/pargm.h/1.48/Fri Dec  7 18:45:03 2007//D2008.11.12.23.00.00
-/refine.c/1.206/Tue Oct 16 12:46:53 2007//D2008.11.12.23.00.00
-/refine.h/1.29/Fri Jun  2 16:12:47 2006//D2008.11.12.23.00.00
-/rm.c/1.87/Thu Oct 30 12:29:06 2008//D2008.11.12.23.00.00
-/rm.h/1.46/Mon Nov 13 09:34:16 2006//D2008.11.12.23.00.00
-/shapes.c/1.44/Thu Oct 30 12:29:06 2008//D2008.11.12.23.00.00
-/shapes.h/1.37/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/shapes2d.c/1.4/Wed Nov 15 18:47:24 1995//D2008.11.12.23.00.00
-/shapes2d.h/1.3/Tue Feb 27 10:21:29 1996//D2008.11.12.23.00.00
-/shapes3d.c/1.7/Wed Mar 13 11:43:36 1996//D2008.11.12.23.00.00
-/shapes3d.h/1.6/Wed Mar 13 11:43:51 1996//D2008.11.12.23.00.00
-/simplex.c/1.3/Thu Nov 30 11:24:39 1995//D2008.11.12.23.00.00
-/simplex.h/1.3/Thu Nov 30 11:24:40 1995//D2008.11.12.23.00.00
-/smooth.c/1.37/Mon Jul 18 13:42:57 2005//D2008.11.12.23.00.00
-/ugio.c/1.214/Mon Aug  8 08:48:25 2005//D2008.11.12.23.00.00
-/ugio.h/1.9/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/ugm.c/1.380/Thu Oct 30 12:29:06 2008//D2008.11.12.23.00.00
-/ugm.h/1.74/Thu Oct 30 12:29:06 2008//D2008.11.12.23.00.00
-/ugm2d.c/1.4/Thu Feb 22 17:29:33 1996//D2008.11.12.23.00.00
-/ugm2d.h/1.2/Wed Nov 15 18:47:39 1995//D2008.11.12.23.00.00
-/ugm3d.c/1.2/Wed Nov 15 18:47:40 1995//D2008.11.12.23.00.00
-/ugm3d.h/1.2/Wed Nov 15 18:47:40 1995//D2008.11.12.23.00.00
-/ugrefine.h/1.2/Wed Nov 15 18:47:41 1995//D2008.11.12.23.00.00
-/ugrefine2d.c/1.10/Thu Aug 11 12:14:59 2005//D2008.11.12.23.00.00
-/ugrefine2d.h/1.2/Wed Nov 15 18:47:43 1995//D2008.11.12.23.00.00
-/ugrefine3d.c/1.10/Thu Aug 11 12:14:59 2005//D2008.11.12.23.00.00
-/ugrefine3d.h/1.2/Wed Nov 15 18:47:45 1995//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/gm/CVS/Entries.Log ug-patched/gm/CVS/Entries.Log
--- ug-orig/gm/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-A D/gg2////
-A D/gg3////
diff -ruN ug-orig/gm/CVS/Repository ug-patched/gm/CVS/Repository
--- ug-orig/gm/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/gm
diff -ruN ug-orig/gm/CVS/Root ug-patched/gm/CVS/Root
--- ug-orig/gm/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/gm/CVS/Tag ug-patched/gm/CVS/Tag
--- ug-orig/gm/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/gm/.cvsignore ug-patched/gm/.cvsignore
--- ug-orig/gm/.cvsignore	2004-09-08 16:14:16.000000000 +0200
+++ ug-patched/gm/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/gm/cw.c ug-patched/gm/cw.c
--- ug-orig/gm/cw.c	2005-07-18 15:42:57.000000000 +0200
+++ ug-patched/gm/cw.c	2008-12-19 11:02:55.000000000 +0100
@@ -17,6 +17,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 
@@ -74,7 +75,7 @@
 /** \brief Description of a control word predefines */
 typedef struct {
     INT used;	        /**< Used this entry					*/
-    char *name;        /**< Name string						*/
+    const char *name;        /**< Name string						*/
     INT control_word_id;	/**< Index in control_words			*/
     UINT offset_in_object ; 	/**< Where in object is it ?			*/
     INT objt_used;				/**< Bitwise object ID */
@@ -83,7 +84,7 @@
 /** \brief Description of a control entry predefines */
 typedef struct {
     INT used;                /**< Used this entry					*/
-    char *name;	             /**< Name string						*/
+    const char *name;	             /**< Name string						*/
     INT control_word;        /**< Index of corresp. controlword	*/
     INT control_entry_id;    /**< Index in control_entries 		*/
     INT offset_in_word;      /**< Shift in control word			*/
@@ -236,7 +237,7 @@
 static CE_USAGE ce_usage[MAX_CONTROL_ENTRIES];
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/cw.c,v 1.48 2005/07/18 13:42:57 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /** \brief Print all control entries of an objects control word
diff -ruN ug-orig/gm/cw.h ug-patched/gm/cw.h
--- ug-orig/gm/cw.h	2006-05-08 14:29:56.000000000 +0200
+++ ug-patched/gm/cw.h	2008-03-10 09:51:35.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/cw.h,v 1.11 2006/05/08 12:29:56 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -50,7 +50,7 @@
     INT used;
 
     /** \brief name string */
-    char *name;
+    const char *name;
 
     /** \brief where in object is it ? */
     UINT offset_in_object;
@@ -70,7 +70,7 @@
     INT used;
 
     /** \brief name string */
-    char *name;
+    const char *name;
 
     /** \brief pointer to corresponding control word */
     INT control_word;
diff -ruN ug-orig/gm/dlmgr.c ug-patched/gm/dlmgr.c
--- ug-orig/gm/dlmgr.c	2006-06-02 17:36:28.000000000 +0200
+++ ug-patched/gm/dlmgr.c	2006-06-02 17:38:35.000000000 +0200
@@ -47,7 +47,7 @@
 #include "ppif_namespace.h"
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/dlmgr.c,v 1.12 2006/06/02 15:36:28 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 USING_UG_NAMESPACES
 USING_PPIF_NAMESPACE
diff -ruN ug-orig/gm/dlmgr.h ug-patched/gm/dlmgr.h
--- ug-orig/gm/dlmgr.h	2006-05-08 14:29:56.000000000 +0200
+++ ug-patched/gm/dlmgr.h	2006-05-08 14:31:31.000000000 +0200
@@ -36,7 +36,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/dlmgr.h,v 1.23 2006/05/08 12:29:56 sander Exp $
+$Header$
 */
 
 #ifndef __DLMGR_H__
diff -ruN ug-orig/gm/dlmgr.t ug-patched/gm/dlmgr.t
--- ug-orig/gm/dlmgr.t	2007-10-16 14:46:53.000000000 +0200
+++ ug-patched/gm/dlmgr.t	2006-05-08 14:31:31.000000000 +0200
@@ -255,7 +255,7 @@
 
 		IFDEBUG(gm,2) 
 			printf("%d: GRID_LINK_" STR(OTYPE) "():" STR(OTYPE) 
-				" has listpart=%d for prio=%d obj=%p\n",me,listpart,Prio,Object);
+				" has listpart=%d for prio=%d obj=%x\n",me,listpart,Prio,Object);
 			fflush(stdout);
 		ENDDEBUG 
 
@@ -439,7 +439,7 @@
 	{
 		IFDEBUG(gm,2)
 		printf(PFMT " GRID_LINKX_" STR(OTYPE) "():" STR(OTYPE) 
-			" calling GRID_LINK_" STR(OTYPE) "(): Object=%p After=%p \n",me,Object,After);
+			" calling GRID_LINK_" STR(OTYPE) "(): Object=%x After=%x \n",me,Object,After);
 		ENDDEBUG
 
 		CAT(GRID_LINK_,OTYPE) (Grid,Object,Prio);
@@ -462,7 +462,7 @@
 
 	IFDEBUG(gm,2) 
 		printf("%d: GRID_LINKX_" STR(OTYPE) "():" STR(OTYPE) 
-			" has listpart=%d for prio=%d obj=%p\n",me,listpart,Prio,Object);
+			" has listpart=%d for prio=%d obj=%x\n",me,listpart,Prio,Object);
 		fflush(stdout);
 	ENDDEBUG 
 
@@ -601,7 +601,7 @@
 {
 	if (prios==2)
 	{
-		printf (PFMT "  fg=%p fg=%p fm=%p lm=%p\n",me,
+		printf (PFMT "  fg=%x fg=%x fm=%x lm=%x\n",me,
 			CAT(LISTPART_FIRST,OTYPE(Grid,0)),
 			CAT(LISTPART_LAST,OTYPE(Grid,0)),
 			CAT(LISTPART_FIRST,OTYPE(Grid,1)),
@@ -609,7 +609,7 @@
 	}
 	else
 	{
-		printf (PFMT "  fg=%p fg=%p fb=%p lb=%p fm=%p lm=%p\n",me,
+		printf (PFMT "  fg=%x fg=%x fb=%x lb=%x fm=%x lm=%x\n",me,
 			CAT(LISTPART_FIRST,OTYPE(Grid,0)),
 			CAT(LISTPART_LAST,OTYPE(Grid,0)),
 			CAT(LISTPART_FIRST,OTYPE(Grid,1)),
diff -ruN ug-orig/gm/elements.c ug-patched/gm/elements.c
--- ug-orig/gm/elements.c	2005-01-26 14:18:58.000000000 +0100
+++ ug-patched/gm/elements.c	2008-12-19 11:02:55.000000000 +0100
@@ -18,6 +18,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 
 #include "general.h"
@@ -192,7 +193,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/elements.c,v 1.38 2005/01/26 13:18:58 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /** \brief Compute index fields for a given element type
diff -ruN ug-orig/gm/elements.h ug-patched/gm/elements.h
--- ug-orig/gm/elements.h	2006-05-08 14:29:56.000000000 +0200
+++ ug-patched/gm/elements.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/elements.h,v 1.15 2006/05/08 12:29:56 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/enrol.c ug-patched/gm/enrol.c
--- ug-orig/gm/enrol.c	2004-07-21 11:18:35.000000000 +0200
+++ ug-patched/gm/enrol.c	2008-12-19 11:02:55.000000000 +0100
@@ -37,6 +37,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -97,7 +98,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/enrol.c,v 1.23 2004/07/21 09:18:35 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*D
diff -ruN ug-orig/gm/enrol.h ug-patched/gm/enrol.h
--- ug-orig/gm/enrol.h	2006-05-08 14:29:56.000000000 +0200
+++ ug-patched/gm/enrol.h	2006-05-08 14:31:31.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/enrol.h,v 1.12 2006/05/08 12:29:56 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/er.c ug-patched/gm/er.c
--- ug-orig/gm/er.c	2005-07-18 10:19:27.000000000 +0200
+++ ug-patched/gm/er.c	2009-04-29 15:11:55.000000000 +0200
@@ -58,6 +58,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 
 /* low */
@@ -157,8 +158,11 @@
 #else
 #define PD_ERR(l,x,e)			/* no debug */
 #define PD(x)					/* no debug */
+#ifdef PrintDebug
+#undef PrintDebug
 #define PrintDebug              printf
 #endif
+#endif
 
 /****************************************************************************/
 /*																			*/
@@ -242,7 +246,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/er.c,v 1.19 2005/07/18 08:19:27 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/gm/er.h ug-patched/gm/er.h
--- ug-orig/gm/er.h	2006-05-08 14:29:56.000000000 +0200
+++ ug-patched/gm/er.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/er.h,v 1.7 2006/05/08 12:29:56 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/evalproc.c ug-patched/gm/evalproc.c
--- ug-orig/gm/evalproc.c	2006-06-02 17:36:29.000000000 +0200
+++ ug-patched/gm/evalproc.c	2006-06-02 17:38:35.000000000 +0200
@@ -98,7 +98,7 @@
 static struct Coubling_CoeffProc_Name Couple_for_ElemVector;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/evalproc.c,v 1.25 2006/06/02 15:36:29 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/gm/evm.c ug-patched/gm/evm.c
--- ug-orig/gm/evm.c	2007-11-19 19:48:21.000000000 +0100
+++ ug-patched/gm/evm.c	2008-12-19 11:02:55.000000000 +0100
@@ -26,6 +26,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include <assert.h>
 #include <stdlib.h>
@@ -84,7 +85,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/evm.c,v 1.30 2007/11/19 18:48:21 dmitriy Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -1615,8 +1616,8 @@
 
 INT  NS_DIM_PREFIX Yams (INT n, DOUBLE *sol, DOUBLE *mat, DOUBLE *rhs)
 {
-    register DOUBLE dinv,piv,sum;
-    register INT i,j,k;
+    DOUBLE dinv,piv,sum;
+    INT i,j,k;
 	DOUBLE *ipv=mat+(n*n);
 
 	if (rhs==NULL)
diff -ruN ug-orig/gm/evm.h ug-patched/gm/evm.h
--- ug-orig/gm/evm.h	2006-06-02 18:12:47.000000000 +0200
+++ ug-patched/gm/evm.h	2006-06-02 18:15:49.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/evm.h,v 1.40 2006/06/02 16:12:47 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/GenerateRules.c ug-patched/gm/GenerateRules.c
--- ug-orig/gm/GenerateRules.c	1997-07-18 16:58:56.000000000 +0200
+++ ug-patched/gm/GenerateRules.c	2008-12-19 11:02:55.000000000 +0100
@@ -14,6 +14,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -112,7 +113,7 @@
 	};
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/GenerateRules.c,v 1.3 1997/07/18 14:58:56 birken Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/gm/GenerateRules.h ug-patched/gm/GenerateRules.h
--- ug-orig/gm/GenerateRules.h	2004-01-21 11:16:10.000000000 +0100
+++ ug-patched/gm/GenerateRules.h	2003-09-16 17:08:55.000000000 +0200
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/GenerateRules.h,v 1.3 2004/01/21 10:16:10 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/gg2/CVS/Entries ug-patched/gm/gg2/CVS/Entries
--- ug-orig/gm/gg2/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg2/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:15 2004//D2008.11.12.23.00.00
-/2Dversion/1.1/Fri Nov 10 21:03:19 1995//D2008.11.12.23.00.00
-/3Dversion/1.1/Fri Nov 10 21:03:50 1995//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:10 2004//D2008.11.12.23.00.00
-/Makefile.gg2/1.4/Fri Dec 20 10:20:14 1996//D2008.11.12.23.00.00
-/gg.doc/1.4/Fri Jan  3 13:13:27 1997//D2008.11.12.23.00.00
-/gg.make/1.2/Sun Nov 24 22:31:46 1996//D2008.11.12.23.00.00
-/ggaccel.c/1.20/Wed Jul 21 09:18:38 2004//D2008.11.12.23.00.00
-/ggaccel.h/1.9/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/ggm.c/1.24/Wed Jul  6 09:51:20 2005//D2008.11.12.23.00.00
-/ggm.h/1.16/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-/ggmain.c/1.67/Fri Jun  2 16:13:12 2006//D2008.11.12.23.00.00
-/ggmain.h/1.13/Mon May  8 12:29:57 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/gm/gg2/CVS/Repository ug-patched/gm/gg2/CVS/Repository
--- ug-orig/gm/gg2/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg2/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/gm/gg2
diff -ruN ug-orig/gm/gg2/CVS/Root ug-patched/gm/gg2/CVS/Root
--- ug-orig/gm/gg2/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg2/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/gm/gg2/CVS/Tag ug-patched/gm/gg2/CVS/Tag
--- ug-orig/gm/gg2/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg2/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/gm/gg2/.cvsignore ug-patched/gm/gg2/.cvsignore
--- ug-orig/gm/gg2/.cvsignore	2004-09-08 16:14:15.000000000 +0200
+++ ug-patched/gm/gg2/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/gm/gg2/ggaccel.c ug-patched/gm/gg2/ggaccel.c
--- ug-orig/gm/gg2/ggaccel.c	2004-07-21 11:18:38.000000000 +0200
+++ ug-patched/gm/gg2/ggaccel.c	2008-12-19 11:02:55.000000000 +0100
@@ -20,6 +20,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include  <stdlib.h>
 #include  "ggaccel.h"
 #include  "misc.h"
@@ -70,7 +71,7 @@
 static GG_PARAM *myPars;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/gg2/ggaccel.c,v 1.20 2004/07/21 09:18:38 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 static INT QuObj; 
 static INT ScObj; 
diff -ruN ug-orig/gm/gg2/ggaccel.h ug-patched/gm/gg2/ggaccel.h
--- ug-orig/gm/gg2/ggaccel.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/gg2/ggaccel.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gg2/ggaccel.h,v 1.9 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/gm/gg2/ggmain.c ug-patched/gm/gg2/ggmain.c
--- ug-orig/gm/gg2/ggmain.c	2006-06-02 18:13:12.000000000 +0200
+++ ug-patched/gm/gg2/ggmain.c	2006-06-02 18:15:34.000000000 +0200
@@ -176,7 +176,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/gg2/ggmain.c,v 1.67 2006/06/02 16:13:12 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 static INT IflObj; 
 static INT FlObj; 
diff -ruN ug-orig/gm/gg2/ggmain.h ug-patched/gm/gg2/ggmain.h
--- ug-orig/gm/gg2/ggmain.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/gg2/ggmain.h	2006-05-08 14:31:31.000000000 +0200
@@ -27,7 +27,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gg2/ggmain.h,v 1.13 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/gg2/ggm.c ug-patched/gm/gg2/ggm.c
--- ug-orig/gm/gg2/ggm.c	2005-07-06 11:51:20.000000000 +0200
+++ ug-patched/gm/gg2/ggm.c	2008-12-19 11:02:55.000000000 +0100
@@ -26,6 +26,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -80,7 +81,7 @@
 static INT FcObj;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/gg2/ggm.c,v 1.24 2005/07/06 09:51:20 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
diff -ruN ug-orig/gm/gg2/ggm.h ug-patched/gm/gg2/ggm.h
--- ug-orig/gm/gg2/ggm.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/gg2/ggm.h	2006-05-08 14:31:31.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gg2/ggm.h,v 1.16 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/gm/gg2/Makefile.am ug-patched/gm/gg2/Makefile.am
--- ug-orig/gm/gg2/Makefile.am	2004-09-02 14:22:10.000000000 +0200
+++ ug-patched/gm/gg2/Makefile.am	2007-02-14 21:27:52.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:10 thimo Exp $
+# $Id: Makefile.am 8267 2007-02-14 20:27:52Z christi $
 
 if BUILD2D
   LIB_2D = libgg2.la
@@ -7,7 +7,7 @@
 endif
 
 # should be installed
-lib_LTLIBRARIES = $(LIB_2D)
+noinst_LTLIBRARIES = $(LIB_2D)
 
 libgg2_la_SOURCES = ggmain.c ggaccel.c ggm.c ggaccel.h ggmain.h ggm.h
 libgg2_la_CPPFLAGS = $(UG_2DFLAGS)
diff -ruN ug-orig/gm/gg3/CVS/Entries ug-patched/gm/gg3/CVS/Entries
--- ug-orig/gm/gg3/CVS/Entries	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg3/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,9 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:15 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:10 2004//D2008.11.12.23.00.00
-/Makefile.gg3/1.6/Fri Dec 20 11:07:10 1996//D2008.11.12.23.00.00
-/gg3d.c/1.32/Mon Jul  4 15:54:00 2005//D2008.11.12.23.00.00
-/gg3d.h/1.13/Mon May  8 12:29:58 2006//D2008.11.12.23.00.00
-/gginterface.h/1.10/Wed Jan 21 10:16:11 2004//D2008.11.12.23.00.00
-/netgen.doc/1.4/Mon Jun 24 10:22:13 1996//D2008.11.12.23.00.00
-/netgenlicence.ps/1.1/Fri Mar 29 17:39:07 1996//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/gm/gg3/CVS/Entries.Log ug-patched/gm/gg3/CVS/Entries.Log
--- ug-orig/gm/gg3/CVS/Entries.Log	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg3/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/netgen////
diff -ruN ug-orig/gm/gg3/CVS/Repository ug-patched/gm/gg3/CVS/Repository
--- ug-orig/gm/gg3/CVS/Repository	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg3/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/gm/gg3
diff -ruN ug-orig/gm/gg3/CVS/Root ug-patched/gm/gg3/CVS/Root
--- ug-orig/gm/gg3/CVS/Root	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg3/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/gm/gg3/CVS/Tag ug-patched/gm/gg3/CVS/Tag
--- ug-orig/gm/gg3/CVS/Tag	2009-04-28 16:21:27.000000000 +0200
+++ ug-patched/gm/gg3/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/gm/gg3/.cvsignore ug-patched/gm/gg3/.cvsignore
--- ug-orig/gm/gg3/.cvsignore	2004-09-08 16:14:15.000000000 +0200
+++ ug-patched/gm/gg3/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/gm/gg3/gg3d.c ug-patched/gm/gg3/gg3d.c
--- ug-orig/gm/gg3/gg3d.c	2005-07-04 17:54:00.000000000 +0200
+++ ug-patched/gm/gg3/gg3d.c	2008-12-19 11:02:55.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -112,7 +113,7 @@
 										(C)[2][2] = (A)[2][0]*(B)[0][2]+(A)[2][1]*(B)[1][2]+(A)[2][2]*(B)[2][2];}
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/gg3/gg3d.c,v 1.32 2005/07/04 15:54:00 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
diff -ruN ug-orig/gm/gg3/gg3d.h ug-patched/gm/gg3/gg3d.h
--- ug-orig/gm/gg3/gg3d.h	2006-05-08 14:29:58.000000000 +0200
+++ ug-patched/gm/gg3/gg3d.h	2006-05-08 14:31:31.000000000 +0200
@@ -26,7 +26,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gg3/gg3d.h,v 1.13 2006/05/08 12:29:58 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/gg3/gginterface.h ug-patched/gm/gg3/gginterface.h
--- ug-orig/gm/gg3/gginterface.h	2004-01-21 11:16:11.000000000 +0100
+++ ug-patched/gm/gg3/gginterface.h	2003-09-16 17:08:55.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gg3/gginterface.h,v 1.10 2004/01/21 10:16:11 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/gg3/Makefile.am ug-patched/gm/gg3/Makefile.am
--- ug-orig/gm/gg3/Makefile.am	2004-09-02 14:22:10.000000000 +0200
+++ ug-patched/gm/gg3/Makefile.am	2007-02-14 21:27:52.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:10 thimo Exp $
+# $Id: Makefile.am 8267 2007-02-14 20:27:52Z christi $
 
 if BUILD3D
   LIB_3D = libgg3.la
@@ -7,7 +7,7 @@
 endif
 
 # this lib should be directly installed
-lib_LTLIBRARIES = libgg3.la
+noinst_LTLIBRARIES = libgg3.la
 
 libgg3_la_SOURCES = gg3d.c gg3d.h gginterface.h
 libgg3_la_CPPFLAGS = $(UG_3DFLAGS)
diff -ruN ug-orig/gm/gg3/netgen/general/array.hh ug-patched/gm/gg3/netgen/general/array.hh
--- ug-orig/gm/gg3/netgen/general/array.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/array.hh	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,69 @@
+#ifndef FILE_ARRAY
+#define FILE_ARRAY
+
+/**************************************************************************/
+/* File:   array.hh                                                       */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type ARRAY
+   
+   ARRAY<T> is an automatically increasing array containing elements of the
+   generic type T. The allocated size may be larger then the logical size
+   of the array. 
+   The elements may be accessed by the brackets [ ] in the range from
+   1 to size. In opposite to this possibility the elements can be accessed
+   by the Methods Set, Get and Elem without range checking.
+*/
+
+
+class BASE_ARRAY
+  {
+  protected:
+  void * data;
+  INDEX actsize, allocsize, inc;
+
+  BASE_ARRAY(INDEX asize, INDEX ainc, int elmentsize);
+  void ReSize (INDEX minsize, int elementsize);
+  int RangeOk (INDEX i) const;
+  int CheckNonEmpty () const;
+  };
+
+
+
+template <class T>
+class ARRAY : private BASE_ARRAY
+  {
+public:
+  inline ARRAY(INDEX asize = 0, INDEX ainc = 0);
+  inline ~ARRAY ();
+
+  inline INDEX Size() const;
+  inline void SetSize(INDEX nsize);
+  inline void SetAllocSize (INDEX nallocsize);
+
+  inline T & operator[] (INDEX i);
+  inline const T & operator[] (INDEX i) const;
+  inline T & Elem (INDEX i);
+  inline const T & Get (INDEX i) const;
+  inline void Set (INDEX i, const T & el);
+  inline T & Last ();
+  inline const T & Last () const;
+
+  inline INDEX Append (const T & el);
+  inline void DeleteElement (INDEX i);
+  inline void DeleteLast ();
+  inline void DeleteAll ();
+
+  private:
+  ARRAY<T> & operator= (ARRAY<T> &);
+  ARRAY (const ARRAY<T> &);
+  };
+
+
+#include <array.icc>
+
+#endif
+
diff -ruN ug-orig/gm/gg3/netgen/general/array.icc ug-patched/gm/gg3/netgen/general/array.icc
--- ug-orig/gm/gg3/netgen/general/array.icc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/array.icc	1997-10-10 15:26:18.000000000 +0200
@@ -0,0 +1,130 @@
+/**************************************************************************/
+/* File:   array.icc                                                      */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type ARRAY
+*/
+
+template <class T>
+inline ARRAY<T> :: ARRAY(INDEX asize, INDEX ainc)
+  : BASE_ARRAY (asize, ainc, sizeof (T)) 
+  { 
+    ;
+  }
+
+template <class T>
+inline ARRAY<T> :: ~ARRAY ()
+  {
+  if (data) 
+    delete (void*)data;
+  }
+
+template <class T>
+inline INDEX ARRAY<T> :: Size() const
+  {
+  return actsize;
+  }
+
+template <class T>
+inline void ARRAY<T> :: SetSize(INDEX nsize)
+  {
+  if (nsize > allocsize)
+    ReSize (nsize, sizeof(T));
+  actsize = nsize;
+  }
+
+template <class T>
+inline void ARRAY<T> :: SetAllocSize (INDEX nallocsize)
+  {
+  if (nallocsize > allocsize)
+    ReSize (nallocsize, sizeof(T));
+  }
+
+template <class T>
+inline T & ARRAY<T> :: operator[] (INDEX i)
+  {
+  RangeOk (i);
+  return ((T*)data)[i-1];
+  }
+
+template <class T>
+inline const T & ARRAY<T> :: operator[] (INDEX i) const
+  {
+  RangeOk (i);
+  return ((const T*)data)[i-1];
+  }
+
+template <class T>
+inline T & ARRAY<T> :: Elem (INDEX i)
+  {
+  return ((T*)data)[i-1];
+  }
+
+template <class T>
+inline const T & ARRAY<T> :: Get (INDEX i) const
+  {
+  return ((const T*)data)[i-1];
+  }
+
+template <class T>
+inline void ARRAY<T> :: Set (INDEX i, const T & el)
+  {
+  #if defined(__HP__) || defined(__HPUX9__)
+  ((T*)data)[i-1] = el;
+  #else
+  ((T*)data)[i-1] = (T)el;
+  #endif
+  }
+
+template <class T>
+inline T & ARRAY<T> :: Last ()
+  {
+  CheckNonEmpty ();
+  return ((T*)data)[actsize-1];
+  }
+
+template <class T>
+inline const T & ARRAY<T> :: Last () const
+  {
+  CheckNonEmpty ();
+  return ((const T*)data)[actsize-1];
+  }
+
+template <class T>
+inline INDEX ARRAY<T> :: Append (const T & el)
+  {
+  if (actsize == allocsize) ReSize (actsize+1, sizeof (T));
+  #if defined(__HP__) || defined(__HPUX9__)
+  ((T*)data)[actsize] = el;
+  #else
+  ((T*)data)[actsize] = (T)el;
+  #endif
+  actsize++;
+  return actsize;
+  }
+
+template <class T>
+inline void ARRAY<T> :: DeleteElement (INDEX i)
+  {
+  RangeOk (i);
+  ((T*)data)[i-1] = ((T*)data)[actsize-1];
+  actsize--;
+  }
+
+template <class T>
+inline void ARRAY<T> :: DeleteLast ()
+  {
+  CheckNonEmpty ();
+  actsize--;
+  }
+
+template <class T>
+inline void ARRAY<T> :: DeleteAll ()
+  {
+  if (data) delete (void*)data;
+  data = NULL;
+  actsize = allocsize = 0;
+  }
diff -ruN ug-orig/gm/gg3/netgen/general/bitarray.cc ug-patched/gm/gg3/netgen/general/bitarray.cc
--- ug-orig/gm/gg3/netgen/general/bitarray.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/bitarray.cc	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,61 @@
+/**************************************************************************/
+/* File:   bitarray.cc                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   data type BitArray
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <template.hh>
+
+#include "bitarray.hh"
+
+BitArray :: BitArray ()
+  {
+  size = 0;
+  data = NULL;
+  }
+
+BitArray :: BitArray (INDEX asize)
+  {
+  size = 0;
+  data = NULL;
+  SetSize (asize);
+  }
+
+BitArray :: ~BitArray ()
+  {
+  if (data) delete data;
+  }
+
+void BitArray :: SetSize (INDEX asize)
+  {
+  if (size == asize) return;
+  if (data) delete data;
+
+  size = asize;
+  data = new unsigned char [Addr (size)+1];
+  }
+
+void BitArray :: Set ()
+  {
+  INDEX i;
+  if (!size) return;
+  for (i = 0; i <= Addr (size); i++)
+    data[i] = UCHAR_MAX;
+  }
+
+void BitArray :: Clear ()
+  {
+  INDEX i;
+  if (!size) return;
+  for (i = 0; i <= Addr (size); i++)
+    data[i] = 0;
+  }
+
+
diff -ruN ug-orig/gm/gg3/netgen/general/bitarray.hh ug-patched/gm/gg3/netgen/general/bitarray.hh
--- ug-orig/gm/gg3/netgen/general/bitarray.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/bitarray.hh	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,48 @@
+#ifndef FILE_BitArray
+#define FILE_BitArray
+
+/**************************************************************************/
+/* File:   bitarray.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   data type BitArray
+   
+   BitArray is a compressed array of Boolean information. By Set and Clear
+   the whole array or one bit can be set or reset, respectively. 
+   Test returns the state of the accoring bit.
+   No range checking is done.
+*/
+
+#include <limits.h>
+
+class BitArray
+  {
+  INDEX size;
+  unsigned char * data;
+
+  public:
+  BitArray ();
+  BitArray (INDEX asize);
+  ~BitArray ();
+
+  void SetSize (INDEX asize);
+  inline INDEX Size () const;
+
+  void Set ();
+  inline void Set (INDEX i);
+  void Clear ();
+  inline void Clear (INDEX i);
+  inline BOOL Test (INDEX i) const;
+
+  private:
+  inline unsigned char Mask (INDEX i) const;
+  inline INDEX Addr (INDEX i) const;
+  };
+
+
+#include <bitarray.icc>
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/general/bitarray.icc ug-patched/gm/gg3/netgen/general/bitarray.icc
--- ug-orig/gm/gg3/netgen/general/bitarray.icc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/bitarray.icc	1996-10-01 19:57:09.000000000 +0200
@@ -0,0 +1,46 @@
+/**************************************************************************/
+/* File:   bitarray.icc                                                   */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   data type BitArray
+*/
+
+
+inline
+INDEX BitArray :: Size () const
+  {
+  return size;
+  }
+
+inline
+unsigned char BitArray :: Mask (INDEX i) const
+  {
+  return char(1) << (i % CHAR_BIT);
+  }
+
+inline
+INDEX BitArray :: Addr (INDEX i) const
+  {
+  return (i / CHAR_BIT);
+  }
+
+inline
+void BitArray :: Set (INDEX i)
+  {
+  data[Addr(i)] |= Mask(i);
+  }
+
+inline
+void BitArray :: Clear (INDEX i)
+  {
+  data[Addr(i)] &= ~Mask(i);
+  }
+
+inline
+BOOL BitArray :: Test (INDEX i) const
+  {
+  return (data[i / CHAR_BIT] & (char(1) << (i % CHAR_BIT) ) ) ? 1 : 0;
+  }
diff -ruN ug-orig/gm/gg3/netgen/general/FlexLexer.h ug-patched/gm/gg3/netgen/general/FlexLexer.h
--- ug-orig/gm/gg3/netgen/general/FlexLexer.h	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/FlexLexer.h	1996-03-27 16:38:10.000000000 +0100
@@ -0,0 +1,175 @@
+// $Header$
+
+// FlexLexer.h -- define classes for lexical analyzers generated by flex
+
+// Copyright (c) 1993 The Regents of the University of California.
+// All rights reserved.
+//
+// This code is derived from software contributed to Berkeley by
+// Kent Williams and Tom Epperly.
+//
+// Redistribution and use in source and binary forms are permitted provided
+// that: (1) source distributions retain this entire copyright notice and
+// comment, and (2) distributions including binaries display the following
+// acknowledgement:  ``This product includes software developed by the
+// University of California, Berkeley and its contributors'' in the
+// documentation or other materials provided with the distribution and in
+// all advertising materials mentioning features or use of this software.
+// Neither the name of the University nor the names of its contributors may
+// be used to endorse or promote products derived from this software without
+// specific prior written permission.
+// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+#ifndef __FLEX_LEXER_H
+#define __FLEX_LEXER_H
+
+
+// This file defines two classes.  The first, FlexLexer, is an abstract
+// class which specifies the external interface provided to flex C++
+// lexer objects.  The second, yyFlexLexer, fills out most of the meat
+// of the lexer class; its internals may vary from lexer to lexer
+// depending on things like whether REJECT is used.
+//
+// If you want to create multiple lexer classes, you use the -P flag
+// to rename each yyFlexLexer to some other xxFlexLexer.
+
+#include <iostream.h>
+
+extern "C++" {
+
+struct yy_buffer_state;
+typedef int yy_state_type;
+
+class FlexLexer {
+public:
+	virtual ~FlexLexer()	{ }
+
+	const char* YYText()	{ return yytext; }
+	int YYLeng()		{ return yyleng; }
+
+	virtual void
+		yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
+	virtual struct yy_buffer_state*
+		yy_create_buffer( istream* s, int size ) = 0;
+	virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
+	virtual void yyrestart( istream* s ) = 0;
+
+	virtual int yylex() = 0;
+
+protected:
+	char* yytext;
+	int yyleng;
+};
+
+
+class yyFlexLexer : public FlexLexer {
+public:
+	// arg_yyin and arg_yyout default to the cin and cout, but we
+	// only make that assignment when initializing in yylex().
+	yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )
+		{
+		yyin = arg_yyin;
+		yyout = arg_yyout;
+		yy_c_buf_p = 0;
+		yy_init = 1;
+		yy_start = 0;
+
+		yy_did_buffer_switch_on_eof = 0;
+
+		yy_looking_for_trail_begin = 0;
+		yy_more_flag = 0;
+		yy_more_len = 0;
+
+		yy_start_stack_ptr = yy_start_stack_depth = 0;
+		yy_start_stack = 0;
+
+		yy_current_buffer = 0;
+
+#ifdef YY_USES_REJECT
+		yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
+#else
+		yy_state_buf = 0;
+#endif
+		}
+
+	virtual ~yyFlexLexer()
+		{
+		delete yy_state_buf;
+		}
+
+	void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
+	struct yy_buffer_state* yy_create_buffer( istream* s, int size );
+	void yy_delete_buffer( struct yy_buffer_state* b );
+	void yyrestart( istream* s );
+
+	virtual int yylex();
+
+protected:
+	virtual int LexerInput( char* buf, int max_size );
+	virtual void LexerOutput( const char* buf, int size );
+	virtual void LexerError( const char* msg );
+
+	void yyunput( int c, char* buf_ptr );
+	int yyinput();
+
+	void yy_load_buffer_state();
+	void yy_init_buffer( struct yy_buffer_state* b, istream* s );
+
+	int yy_start_stack_ptr;
+	int yy_start_stack_depth;
+	int* yy_start_stack;
+
+	void yy_push_state( int new_state );
+	void yy_pop_state();
+	int yy_top_state();
+
+	yy_state_type yy_get_previous_state();
+	yy_state_type yy_try_NUL_trans( yy_state_type current_state );
+	int yy_get_next_buffer();
+
+	istream* yyin;	// input source for default LexerInput
+	ostream* yyout;	// output sink for default LexerOutput
+
+	struct yy_buffer_state* yy_current_buffer;
+
+	// yy_hold_char holds the character lost when yytext is formed.
+	char yy_hold_char;
+
+	// Number of characters read into yy_ch_buf.
+	int yy_n_chars;
+
+	// Points to current character in buffer.
+	char* yy_c_buf_p;
+
+	int yy_init;		// whether we need to initialize
+	int yy_start;		// start state number
+
+	// Flag which is used to allow yywrap()'s to do buffer switches
+	// instead of setting up a fresh yyin.  A bit of a hack ...
+	int yy_did_buffer_switch_on_eof;
+
+	// The following are not always needed, but may be depending
+	// on use of certain flex features (like REJECT or yymore()).
+
+	yy_state_type yy_last_accepting_state;
+	char* yy_last_accepting_cpos;
+
+	yy_state_type* yy_state_buf;
+	yy_state_type* yy_state_ptr;
+
+	char* yy_full_match;
+	int* yy_full_state;
+	int yy_full_lp;
+
+	int yy_lp;
+	int yy_looking_for_trail_begin;
+
+	int yy_more_flag;
+	int yy_more_len;
+};
+
+}
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/general/genarray.cc ug-patched/gm/gg3/netgen/general/genarray.cc
--- ug-orig/gm/gg3/netgen/general/genarray.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/genarray.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,99 @@
+/**************************************************************************/
+/* File:   array.cc                                                       */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type ARRAY
+*/
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <template.hh>
+#include <array.hh>
+
+
+BASE_ARRAY :: BASE_ARRAY(INDEX asize, INDEX ainc, int elementsize)
+  {
+  void * p;
+
+  if (asize)
+    {
+    p = new char[asize * elementsize];
+
+    if (p)
+      {
+      data = p;
+      actsize = allocsize = asize; inc = ainc;
+      return;
+      }
+    else
+      {
+      MyError ("Array not allocated");
+      }
+    }
+
+  data = NULL;
+  actsize = allocsize = 0;
+  inc = ainc;
+  }
+
+
+
+void BASE_ARRAY :: ReSize (INDEX minsize, int elementsize)
+  {
+  void * p;
+  INDEX nsize = (inc) ? allocsize + inc : 2 * allocsize;
+  if (nsize < minsize) nsize = minsize;
+
+/*
+  if (long(nsize) * long(sizeof(T)) > 32767)
+    MyError ("Array too large");
+*/
+
+  if (data)
+    {
+    p = new char [nsize * elementsize];
+    memcpy (p, data, (ng_min (nsize, actsize)) * elementsize);
+
+    delete data;
+    data = p;
+    }
+  else
+    {
+    p = new char[nsize * elementsize];
+    data = p;
+    }
+
+  if (!data) MyError ("Array not allocated");
+
+  allocsize = nsize;
+  }
+
+
+
+int BASE_ARRAY :: RangeOk (INDEX i) const
+  {
+  if (i < 1 || i > actsize)
+    {
+    MyError ("Array out of Range");
+    return 0;
+    }
+  return 1;
+  }
+
+int BASE_ARRAY :: CheckNonEmpty () const
+  {
+  if (!actsize)
+    {
+    MyError ("Array souldn't be empty");
+    return 0;
+    }
+  return 1;
+  }
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/general/hashtabl.cc ug-patched/gm/gg3/netgen/general/hashtabl.cc
--- ug-orig/gm/gg3/netgen/general/hashtabl.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/hashtabl.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,49 @@
+
+/**************************************************************************/
+/* File:   hashtabl.cc                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type HASHTABLE
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <table.hh>
+#include <hashtabl.hh>
+
+
+void INDEX_2 :: Sort ()
+  {
+  if (i1 > i2) ng_swap (i1, i2);
+  }
+
+void INDEX_3 :: Sort ()
+  {
+  if (i1 > i2) ng_swap (i1, i2);
+  if (i2 > i3) ng_swap (i2, i3);
+  if (i1 > i2) ng_swap (i1, i2);
+  }
+
+int BASE_INDEX_2_HASHTABLE :: Position (int bnr, const INDEX_2 & ind) const
+  {
+  int i;
+  for (i = 1; i <= hash.EntrySize (bnr); i++)
+    if (hash.Get(bnr, i) == ind)
+      return i;
+  return 0;
+  }
+  
+int BASE_INDEX_3_HASHTABLE :: Position (int bnr, const INDEX_3 & ind) const
+  {
+  int i;
+  for (i = 1; i <= hash.EntrySize (bnr); i++)
+    if (hash.Get(bnr, i) == ind)
+      return i;
+  return 0;
+  }
diff -ruN ug-orig/gm/gg3/netgen/general/hashtabl.hh ug-patched/gm/gg3/netgen/general/hashtabl.hh
--- ug-orig/gm/gg3/netgen/general/hashtabl.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/hashtabl.hh	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,290 @@
+#ifndef FILE_HASHTABL
+#define FILE_HASHTABL
+
+/**************************************************************************/
+/* File:   hashtabl.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type HASHTABLE
+*/
+
+
+
+class BASE_INDEX_HASHTABLE
+  {
+  protected:
+  TABLE<INDEX> hash;
+
+  public:
+  BASE_INDEX_HASHTABLE (int size)
+    : hash (size) { };
+
+  protected:
+  int HashValue (const INDEX & ind) const;
+  int Position (int bnr, const INDEX & ind) const;
+  };
+
+template <class T>
+class INDEX_HASHTABLE : private BASE_INDEX_HASHTABLE
+  {
+  TABLE<T> cont;
+
+  public:
+  INDEX_HASHTABLE (int size)
+    : BASE_INDEX_HASHTABLE (size), cont(size)
+    {
+      ;
+    }
+
+  void Set (const INDEX & hash, const T & acont)
+    {
+    int bnr = HashValue (hash);
+    int pos = Position (bnr, hash);
+    if (pos)
+      cont.Set (bnr, pos, acont);
+    else
+      {
+      data.Add (bnr, hash);
+      cont.Add (bnr, acont);
+      }
+    }
+
+  const T & Get (const INDEX & ahash) const
+    {
+    int bnr = HashValue (hash);
+    int pos = Position (bnr, hash);
+    return cont.Get (bnr, pos);
+    }
+
+  int Used (const INDEX & ahash) const
+    {
+    return (Position (Hashvalue (hash), hash)) ? 1 : 0;
+    }
+
+  int GetNBags () const
+    {
+    return data.Size();
+    }
+
+  int GetBagSize (int bnr) const
+    {
+    return data.Get(bnr).size;
+    }
+
+  void GetData (int bnr, int colnr, INDEX & ahash, T & acont)
+    {
+    ahash = data.Get(bnr).col[colnr-1];
+    acont = cont.Get(bnr).col[colnr-1];
+    }
+  };
+
+
+
+
+
+
+
+
+
+
+
+
+
+class INDEX_2
+  {
+  INDEX i1, i2;
+
+  public:
+  INDEX_2 () { }
+  INDEX_2 (INDEX ai1, INDEX ai2)
+    { i1 = ai1; i2 = ai2; }
+
+  INDEX_2 (const INDEX_2 & in2)
+    { i1 = in2.i1; i2 = in2.i2; }
+
+  int operator== (const INDEX_2 & in2) const
+    { return i1 == in2.i1 && i2 == in2.i2; }
+
+  void Sort ();
+  INDEX & I1 () { return i1; }
+  INDEX & I2 () { return i2; }
+  const INDEX & I1 () const { return i1; }
+  const INDEX & I2 () const { return i2; }
+  };
+
+
+class BASE_INDEX_2_HASHTABLE
+  {
+  protected:
+  TABLE<INDEX_2> hash;
+
+  public:
+  BASE_INDEX_2_HASHTABLE (int size)
+    : hash (size) { };
+
+  protected:
+  int HashValue (const INDEX_2 & ind) const
+    {
+    return (ind.I1() + ind.I2()) % hash.Size() + 1;
+    }
+  int Position (int bnr, const INDEX_2 & ind) const;
+  };
+
+
+template <class T>
+class INDEX_2_HASHTABLE : private BASE_INDEX_2_HASHTABLE
+  {
+  TABLE<T> cont;
+
+  public:
+  INDEX_2_HASHTABLE (int size)
+    : BASE_INDEX_2_HASHTABLE (size), cont(size)
+    {
+      ;
+    }
+
+  void Set (const INDEX_2 & ahash, const T & acont)
+    {
+    int bnr = HashValue (ahash);
+    int pos = Position (bnr, ahash);
+    if (pos)
+      cont.Set (bnr, pos, acont);
+    else
+      {
+      hash.Add (bnr, ahash);
+      cont.Add (bnr, acont);
+      }
+    }
+
+  const T & Get (const INDEX_2 & ahash) const
+    {
+    int bnr = HashValue (ahash);
+    int pos = Position (bnr, ahash);
+    return cont.Get (bnr, pos);
+    }
+
+  int Used (const INDEX_2 & ahash) const
+    {
+    return (Position (HashValue (ahash), ahash)) ? 1 : 0;
+    }
+
+  int GetNBags () const
+    {
+    return cont.Size();
+    }
+
+  int GetBagSize (int bnr) const
+    {
+    return cont.EntrySize (bnr);
+    }
+
+  void GetData (int bnr, int colnr, INDEX_2 & ahash, T & acont)
+    {
+    ahash = hash.Get(bnr, colnr);
+    acont = cont.Get(bnr, colnr);
+    }
+  };
+
+
+class INDEX_3
+  {
+  INDEX i1, i2, i3;
+
+  public:
+  INDEX_3 () { }
+  INDEX_3 (INDEX ai1, INDEX ai2, INDEX ai3)
+    { i1 = ai1; i2 = ai2; i3 = ai3; }
+
+  INDEX_3 (const INDEX_3 & in2)
+    { i1 = in2.i1; i2 = in2.i2; i3 = in2.i3; }
+
+  void Sort ();
+
+  int operator== (const INDEX_3 & in2) const
+    { return i1 == in2.i1 && i2 == in2.i2 && i3 == in2.i3;}
+
+  INDEX & I1 () { return i1; }
+  INDEX & I2 () { return i2; }
+  INDEX & I3 () { return i3; }
+  const INDEX & I1 () const { return i1; }
+  const INDEX & I2 () const { return i2; }
+  const INDEX & I3 () const { return i3; }
+  };
+
+
+class BASE_INDEX_3_HASHTABLE
+  {
+  protected:
+  TABLE<INDEX_3> hash;
+
+  public:
+  BASE_INDEX_3_HASHTABLE (int size)
+    : hash (size) { };
+
+  protected:
+  int HashValue (const INDEX_3 & ind) const
+    {
+    return (ind.I1() + ind.I2() + ind.I3()) % hash.Size() + 1;
+    }
+  int Position (int bnr, const INDEX_3 & ind) const;
+  };
+
+
+template <class T>
+class INDEX_3_HASHTABLE : private BASE_INDEX_3_HASHTABLE
+  {
+  TABLE<T> cont;
+
+  public:
+  INDEX_3_HASHTABLE (int size)
+    : BASE_INDEX_3_HASHTABLE (size), cont(size)
+    {
+      ;
+    }
+
+  void Set (const INDEX_3 & ahash, const T & acont)
+    {
+    int bnr = HashValue (ahash);
+    int pos = Position (bnr, ahash);
+    if (pos)
+      cont.Set (bnr, pos, acont);
+    else
+      {
+      hash.Add (bnr, ahash);
+      cont.Add (bnr, acont);
+      }
+    }
+
+  const T & Get (const INDEX_3 & ahash) const
+    {
+    int bnr = HashValue (ahash);
+    int pos = Position (bnr, ahash);
+    return cont.Get (bnr, pos);
+    }
+
+  int Used (const INDEX_3 & ahash) const
+    {
+    return (Position (HashValue (ahash), ahash)) ? 1 : 0;
+    }
+
+  int GetNBags () const
+    {
+    return cont.Size();
+    }
+
+  int GetBagSize (int bnr) const
+    {
+    return cont.EntrySize (bnr);
+    }
+
+  void GetData (int bnr, int colnr, INDEX_3 & ahash, T & acont)
+    {
+    ahash = hash.Get(bnr, colnr);
+    acont = cont.Get(bnr, colnr);
+    }
+  };
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/general/makefile ug-patched/gm/gg3/netgen/general/makefile
--- ug-orig/gm/gg3/netgen/general/makefile	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/makefile	1996-03-29 18:25:29.000000000 +0100
@@ -0,0 +1,8 @@
+objects = bitarray.o genarray.o table.o hashtabl.o
+# lib = gen
+# zip = $(src) evalfunc.hh array.hh hashtabl.hh template.hh symbolta.hh \
+#        sp_ar_2d.hh bitarray.hh spbita2d.hh table.hh myadt.h
+#
+#
+include ../makefile.inc
+#
diff -ruN ug-orig/gm/gg3/netgen/general/myadt.hh ug-patched/gm/gg3/netgen/general/myadt.hh
--- ug-orig/gm/gg3/netgen/general/myadt.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/myadt.hh	1996-10-01 19:49:28.000000000 +0200
@@ -0,0 +1,22 @@
+#ifndef FILE_MYADT
+#define FILE_MYADT
+
+/**************************************************************************/
+/* File:   myadt.hh                                                       */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   include fot all abstract data types
+*/
+
+#include <template.hh>
+#include <array.hh>
+#include <table.hh>
+#include <hashtabl.hh>
+//  #include <symbolta.hh>
+#include <bitarray.hh>
+//  #include <spbita2d.hh>
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/general/table.cc ug-patched/gm/gg3/netgen/general/table.cc
--- ug-orig/gm/gg3/netgen/general/table.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/table.cc	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,78 @@
+/**************************************************************************/
+/* File:   table.cc                                                       */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type TABLE
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <table.hh>
+
+
+BASE_TABLE :: BASE_TABLE (int size)
+  : data(size)
+  {
+  int i;
+  for (i = 1; i <= size; i++)
+    {
+    data.Elem(i).maxsize = 0;
+    data.Elem(i).size = 0;
+    data.Elem(i).col = NULL;
+    }
+  }
+
+BASE_TABLE :: ~BASE_TABLE ()
+  {
+  int i;
+  for (i = 1; i <= data.Size(); i++)
+    if (data.Get(i).col)
+      delete data[i].col;
+  }
+
+void BASE_TABLE :: SetSize (int size)
+  {
+  int i;
+  data.SetSize(size);
+  for (i = 1; i <= size; i++)
+    {
+    data.Elem(i).maxsize = 0;
+    data.Elem(i).size = 0;
+    data.Elem(i).col = NULL;
+    }    
+  }
+
+void BASE_TABLE :: IncSize (int i, int elsize)
+  {
+  if (i < 1 || i > data.Size())
+    {
+    MyError ("BASE_TABLE::Inc: Out of range");
+    return;
+    }
+
+  linestruct & line = data.Elem (i);
+
+  if (line.size == line.maxsize)
+    {
+    void * p = new char [(line.maxsize+5) * elsize];
+
+    if (!p)
+      {
+      MyError ("BASE_TABLE::Inc: Out of memory");
+      return;
+      }
+
+    memcpy (p, line.col, line.maxsize * elsize);
+    delete line.col;
+    line.col = p;
+    line.maxsize += 5;
+    }
+
+  line.size++;
+  }
diff -ruN ug-orig/gm/gg3/netgen/general/table.hh ug-patched/gm/gg3/netgen/general/table.hh
--- ug-orig/gm/gg3/netgen/general/table.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/table.hh	1996-10-01 19:43:15.000000000 +0200
@@ -0,0 +1,57 @@
+#ifndef FILE_TABLE
+#define FILE_TABLE
+
+/**************************************************************************/
+/* File:   table.hh                                                       */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type TABLE
+   
+   To an integer i in the range from 1 to size a set of elements of the
+   generic type T is associated. 
+*/
+
+
+class BASE_TABLE
+  {
+  protected:
+
+  class linestruct
+    {
+    public:
+    int size, maxsize;
+    void * col;
+    };
+
+  ARRAY<linestruct> data;
+
+  public:
+  BASE_TABLE (int size);
+  ~BASE_TABLE ();
+  void SetSize (int size);
+  void IncSize (int i, int elsize);
+  };
+
+
+template <class T>
+class TABLE : public BASE_TABLE
+  {
+  public:
+
+  inline TABLE ();
+  inline TABLE (int size);
+  inline void SetSize (int size);
+  inline void Add (INDEX i, const T & acont);
+  inline void Set (INDEX i, int nr, const T & acont);
+  inline const T & Get (INDEX i, int nr) const;
+  inline int Size () const;
+  inline int EntrySize (int i) const;
+  };
+
+#include <table.icc>
+
+#endif
+
diff -ruN ug-orig/gm/gg3/netgen/general/table.icc ug-patched/gm/gg3/netgen/general/table.icc
--- ug-orig/gm/gg3/netgen/general/table.icc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/table.icc	1996-10-01 19:57:09.000000000 +0200
@@ -0,0 +1,60 @@
+/**************************************************************************/
+/* File:   table.icc                                                      */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   Abstract data type TABLE
+*/
+
+template<class T>
+inline TABLE<T> :: TABLE () 
+  : BASE_TABLE (0)
+  {
+    ;
+  }
+
+template<class T>
+inline TABLE<T> :: TABLE (int size) 
+  : BASE_TABLE (size)
+  {
+    ;
+  }
+
+template<class T>
+inline void TABLE<T> :: SetSize (int size) 
+  {
+  BASE_TABLE::SetSize (size);
+  }
+
+template<class T>
+inline void TABLE<T> :: Add (INDEX i, const T & acont)
+  {
+  IncSize (i, sizeof (T));
+  ((T*)data.Elem(i).col)[data.Elem(i).size-1] = acont;
+  }
+
+template<class T>
+inline void TABLE<T> :: Set (INDEX i, int nr, const T & acont)
+  {
+  ((T*)data.Get(i).col)[nr-1] = acont;
+  }
+
+template<class T>
+inline const T & TABLE<T> :: Get (INDEX i, int nr) const
+  {
+  return ((T*)data.Get(i).col)[nr-1];
+  }
+
+template<class T>
+inline int TABLE<T> :: Size () const
+  {
+  return data.Size();
+  }
+
+template<class T>
+inline int TABLE<T> :: EntrySize (int i) const
+  {
+  return data.Get(i).size;
+  }
diff -ruN ug-orig/gm/gg3/netgen/general/template.hh ug-patched/gm/gg3/netgen/general/template.hh
--- ug-orig/gm/gg3/netgen/general/template.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/general/template.hh	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,75 @@
+#ifndef FILE_TEMPLATE
+#define FILE_TEMPLATE
+
+/**************************************************************************/
+/* File:   template.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+   templates, global types, defines and variables
+*/
+
+
+class ostream;
+extern ostream * testout;
+extern void MyError (char * ch);
+
+// #define MYGRAPH
+// #define SOLIDGEOM
+
+
+typedef int INDEX;
+typedef int BOOL;
+
+class twoint { 
+public: int i1, i2; twoint() {};  
+twoint(int ii1, int ii2) {i1 = ii1; i2 = ii2;}
+};
+class threeint { public: int i1, i2, i3; threeint() {}; };
+class fourint { public: int i1, i2, i3, i4; fourint() {}; };
+
+
+template <class T>
+inline T ng_min (T a, T b)
+  {
+  return (a < b) ? a : b;
+  }
+template <class T>
+inline T ng_max (T a, T b)
+  {
+  return (a > b) ? a : b;
+  }
+template <class T>
+inline T ng_min (T a, T b, T c)
+  {
+  return (a < b) ? (a < c) ? a : c
+                 : (b < c) ? b : c;
+  }
+template <class T>
+inline T ng_max (T a, T b, T c)
+  {
+  return (a > b) ? ((a > c) ? a : c)
+                 : ((b > c) ? b : c);
+  }
+
+template <class T>
+inline void ng_swap (T & a, T & b)
+  {
+  T temp = a;
+  a = b;
+  b = temp;
+  }
+
+template <class T>
+inline int sgn (T a)
+  {
+  return (a > 0) ? 1 : (   ( a < 0) ? 0 : -1 );
+  }
+
+template <class T>
+inline T sqr (T a)
+  { return a * a; }
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/geom/geom2d.cc ug-patched/gm/gg3/netgen/geom/geom2d.cc
--- ug-orig/gm/gg3/netgen/geom/geom2d.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/geom2d.cc	1996-10-01 19:43:25.000000000 +0200
@@ -0,0 +1,371 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <template.hh>
+#include <geom/geom2d.hh>
+
+#ifndef M_PI
+#define M_PI        3.14159265358979323846
+#endif
+
+ostream & operator<<(ostream  & s, const Point2d & p)
+  {
+  return s << "(" << p.px << ", " << p.py << ")";
+  }
+
+ostream & operator<<(ostream  & s, const Vec2d & v)
+  {
+  return s << "(" << v.vx << ", " << v.vy << ")";
+  }
+
+ostream & operator<<(ostream  & s, const LINE2D & l)
+  {
+  return s << l.p1 << "-" << l.p2;
+  }
+
+ostream & operator<<(ostream  & s, const TRIANGLE2D & t)
+  {
+  return s << t.p1 << "-" << t.p2 << "-" << t.p3;
+  }
+
+
+
+double Fastatan2 (double x, double y)
+  {
+  if (y > 0)
+    {
+    if (x > 0)
+      return y / (x+y);
+    else
+      return 1 - x / (y-x);
+    }
+  else if (y < 0)
+    {
+    if (x < 0)
+      return 2 + y / (x+y);
+    else
+      return 3 - x / (y-x);
+    }
+  else 
+    {
+    if (x >= 0)
+      return 0;
+    else
+      return 2;
+    }
+  }
+
+
+double Angle (const Vec2d & v)
+  {
+  if (v.X() == 0 && v.Y() == 0) return 0;
+  double ang = atan2 (v.Y(), v.X());
+  if (ang < 0) ang+= 2 * M_PI;
+  return ang;
+  }
+
+double FastAngle (const Vec2d & v)
+  {
+  return Fastatan2 (v.X(), v.Y());
+  }
+
+double Angle (const Vec2d & v1, const Vec2d & v2)
+  {
+  double ang = Angle(v2) - Angle(v1);
+  if (ang < 0) ang += 2 * M_PI;
+  return ang;
+  }
+
+double FastAngle (const Vec2d & v1, const Vec2d & v2)
+  {
+  double ang = FastAngle(v2) - FastAngle(v1);
+  if (ang < 0) ang += 4;
+  return ang;
+  }
+
+
+
+
+
+
+int CW (const Point2d & p1,const Point2d & p2,const Point2d & p3)
+  {
+  return Cross (p2 - p1, p3 - p2) < 0;
+  }
+
+int CCW (const Point2d & p1,const Point2d & p2,const Point2d & p3)
+  {
+  return Cross (p2 - p1, p3 - p2) > 0;
+  }
+
+
+Point2d CrossPoint (const LINE2D & l1, const LINE2D & l2)
+  {
+  double den = Cross (l1.Delta(), l2.Delta());
+  double num = Cross ( (l2.P1() - l1.P1()), l2.Delta());
+
+  if (den == 0) return l1.P1();
+  else
+    return l1.P1() + (num/den) * l1.Delta();
+  }
+
+
+int Parallel (const LINE2D & l1, const LINE2D & l2, double peps)
+  {
+  double p = fabs (Cross (l1.Delta(), l2.Delta()));
+  return p <= peps * l1.Length() * l2.Length();
+  }
+
+int IsOnLine (const LINE2D & l, const Point2d & p, double heps)
+  {
+  double c1 = (p - l.P1()) * l.Delta();
+  double c2 = (p - l.P2()) * l.Delta();
+  double d = fabs (Cross ( (p - l.P1()), l.Delta()));
+  double len2 = l.Length2();
+
+  return c1 >= -heps * len2 && c2 <= heps * len2 && d <= heps * len2;
+  };
+
+int IsOnLine (const PLINE2D & l, const Point2d & p, double heps)
+  {
+  double c1 = (p - l.P1()) * l.Delta();
+  double c2 = (p - l.P2()) * l.Delta();
+  double d = fabs (Cross ( (p - l.P1()), l.Delta()));
+  double len2 = l.Length2();
+
+  return c1 >= -heps * len2 && c2 <= heps * len2 && d <= heps * len2;
+  };
+
+int IsOnLongLine (const LINE2D & l, const Point2d & p)
+  {
+  double d = fabs (Cross ( (p - l.P1()), l.Delta()));
+  return d <= EPSGEOM * l.Length();
+  };
+
+int Hit (const LINE2D & l1, const LINE2D & l2, double heps)
+  {
+  double den =  Cross ( (l1.P2() - l1.P1()), (l2.P1() - l2.P2()));
+  double num1 = Cross ( (l2.P1() - l1.P1()), (l2.P1() - l2.P2()));
+  double num2 = Cross ( (l1.P2() - l1.P1()), (l2.P1() - l1.P1()));
+  num1 *= sgn (den);
+  num2 *= sgn (den);
+  den = fabs (den);
+
+  int ch = (-den * heps <= num1 && num1 <= den * (1 + heps) &&
+             -den * heps <= num2 && num2 <= den * (1 + heps));
+  return ch;
+  };
+
+
+
+int TRIANGLE2D :: IsOn (const Point2d & p) const
+  {
+  return IsOnLine (LINE2D (p1, p2), p) ||
+         IsOnLine (LINE2D (p1, p3), p) ||
+         IsOnLine (LINE2D (p2, p3), p);
+  }
+
+
+int TRIANGLE2D :: IsIn (const Point2d & p) const
+  {
+  return ::CW(p, p1, p2) == ::CW(p, p2, p3) &&
+         ::CW(p, p1, p2) == ::CW(p, p3, p1);
+  }
+
+
+
+int PTRIANGLE2D :: IsOn (const Point2d & p) const
+  {
+  return IsOnLine (LINE2D (*p1, *p2), p) ||
+         IsOnLine (LINE2D (*p1, *p3), p) ||
+         IsOnLine (LINE2D (*p2, *p3), p);
+  }
+
+
+int PTRIANGLE2D :: IsIn (const Point2d & p) const
+  {
+  return ::CW(p, *p1, *p2) == ::CW(p, *p2, *p3) &&
+         ::CW(p, *p1, *p2) == ::CW(p, *p3, *p1);
+  }
+
+
+
+
+
+
+
+
+/*
+
+
+
+
+double POLYGON2D :: HArea () const
+  {
+  CURSOR c;
+  double ar = 0;
+  Point2d * p1, * p2, p0 = Point2d(0, 0);
+  Vec2d v1, v2 = Vec2d(1, 0);
+
+  p2 = points[points.Last()];
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    p1 = p2;
+    p2 = points[c];
+    ar += Cross ( (*p2-*p1), (*p1 - p0));
+    }
+
+  return ar / 2;
+  }
+
+
+char POLYGON2D :: IsOn (const Point2d & p) const
+  {
+  CURSOR c;
+  Point2d * p1, * p2;
+
+  p2 = points[points.Last()];
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    p1 = p2;
+    p2 = points[c];
+    if (IsOnLine (LINE2D(*p1, *p2), p)) return 1;
+    }
+
+  return 0;
+  }
+
+
+char POLYGON2D :: IsIn (const Point2d & p) const
+  {
+  CURSOR c;
+  Point2d * p1, * p2;
+  double sum = 0, ang;
+
+  p2 = points[points.Last()];
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    p1 = p2;
+    p2 = points[c];
+    ang = Angle ( (*p1 - p), (*p2 - p) );
+    if (ang > M_PI) ang -= 2 * M_PI;
+    sum += ang;
+    }
+
+  return fabs(sum) > M_PI;
+  }
+
+char POLYGON2D :: Convex () const
+  {
+  Point2d *p, *pold, *pnew;
+  char cw;
+  CURSOR c;
+
+  if (points.Length() < 3) return 0;
+
+  c = points.Last();
+  p = points[c];
+  c--;
+  pold = points[c];
+  pnew = points[points.First()];
+  cw = ::CW (*pold, *p, *pnew);
+
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    pnew = points[c];
+    if (cw != ::CW (*pold, *p, *pnew))
+      return 0;
+    pold = p;
+    p = pnew;
+    }
+  return 1;
+  }
+
+
+char POLYGON2D :: IsStarPoint (const Point2d & p) const
+  {
+  Point2d *pnew, *pold;
+  char cw;
+  CURSOR c;
+
+  if (points.Length() < 3) return 0;
+
+  pold = points[points.Last()];
+  pnew = points[points.First()];
+
+  cw = ::CW (p, *pold, *pnew);
+
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    pnew = points[c];
+    if (cw != ::CW (p, *pold, *pnew))
+      return 0;
+    pold = pnew;
+    }
+  return 1;
+  }
+
+
+Point2d POLYGON2D :: Center () const
+  {
+  double ai, a = 0, x = 0, y = 0;
+  Point2d * p, *p2;
+  Point2d p0 = Point2d(0, 0);
+  CURSOR c;
+
+  p2 = points[points.Last()];
+
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    p = points[c];
+    ai = Cross (*p2 - p0, *p - p0);
+    x += ai / 3 * (p2->X() + p->X());
+    y += ai / 3 * (p2->Y() + p->Y());
+    a+= ai;
+    p2 = p;
+    }
+  if (a != 0)
+    return Point2d (x / a, y / a);
+  else
+    return Point2d (0, 0);
+  }
+
+
+
+Point2d POLYGON2D :: EqualAreaPoint () const
+  {
+  double a11 = 0, a12 = 0, a21= 0, a22 = 0;
+  double b1 = 0, b2 = 0, dx, dy;
+  double det;
+  Point2d * p, *p2;
+  CURSOR c;
+
+  p = points[points.Last()];
+
+  for (c = points.First(); c != points.Head(); c++)
+    {
+    p2 = p;
+    p = points[c];
+
+    dx = p->X() - p2->X();
+    dy = p->Y() - p2->Y();
+
+    a11 += sqr (dy);
+    a12 -= dx * dy;
+    a21 -= dx * dy;
+    a22 += sqr (dx);
+    b1 -= dy * (p->X() * p2->Y() - p2->X() * p->Y());
+    b2 -= dx * (p->Y() * p2->X() - p2->Y() * p->X());
+    }
+
+  det = a11 * a22 - a21 * a12;
+
+  if (det != 0)
+    return Point2d ( (b1 * a22 - b2 * a12) / det,
+                     (a11 * b2 - a21 * b1) / det);
+  else
+    return Point2d (0, 0);
+  }
+
+*/
diff -ruN ug-orig/gm/gg3/netgen/geom/geom2d.hh ug-patched/gm/gg3/netgen/geom/geom2d.hh
--- ug-orig/gm/gg3/netgen/geom/geom2d.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/geom2d.hh	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,456 @@
+/* Geometric Algorithms */
+
+#define EPSGEOM 1E-5
+
+extern void MyError (char * ch);
+class ostream;
+
+class Point2d;
+class Vec2d;
+class LINE2D;
+
+
+
+class Point2d
+  {
+  friend Vec2d;
+
+protected:
+  double px, py;
+
+public:
+  Point2d() { /* px = py = 0; */ }
+  Point2d(double ax, double ay) { px = ax; py = ay; }
+  Point2d(const Point2d & p2) { px = p2.px; py = p2.py; }
+
+  Point2d & operator= (const Point2d & p2)
+    { px = p2.px; py = p2.py; return *this; }
+
+  double & X() { return px; }
+  double & Y() { return py; }
+  double X() const { return px; }
+  double Y() const { return py; }
+
+  friend inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
+  friend inline Point2d operator- (const Point2d & p1, const Vec2d & v);
+  friend inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
+
+  friend inline Point2d Center (const Point2d & p1, const Point2d & p2);
+
+  friend double Dist (const Point2d & p1, const Point2d & p2)
+    { return sqrt ( sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) ); }
+  friend double Dist2 (const Point2d & p1, const Point2d & p2)
+    { return sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) ; }
+
+  friend int CW (const Point2d & p1, const Point2d & p2, const Point2d & p3);
+  friend int CCW (const Point2d & p1, const Point2d & p2, const Point2d & p3);
+
+  friend inline void PpSmV (const Point2d & p1, double s, const Vec2d & v, Point2d & p2);
+  friend inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v);
+
+  friend ostream & operator<<(ostream  & s, const Point2d & p);
+  };
+
+
+
+class Vec2d
+  {
+protected:
+  double vx, vy;
+
+public:
+  Vec2d() { /* vx = vy = 0; */ }
+  Vec2d(double ax, double ay)
+              { vx = ax; vy = ay; }
+  Vec2d(const Vec2d & v2)
+              { vx = v2.vx; vy = v2.vy; }
+  Vec2d(const Point2d & p1, const Point2d & p2)
+              { vx = p2.px - p1.px; vy = p2.py - p1.py; }
+
+  Vec2d & operator= (const Vec2d & p2)
+    { vx = p2.vx; vy = p2.vy; return *this; }
+
+  double & X() { return vx; }
+  double & Y() { return vy; }
+  double X() const { return vx; }
+  double Y() const { return vy; }
+
+  double Length() const { return sqrt (vx * vx + vy * vy); }
+  double Length2() const { return vx * vx + vy * vy; }
+
+  inline Vec2d & operator+= (const Vec2d & v2);
+  inline Vec2d & operator-= (const Vec2d & v2);
+  inline Vec2d & operator*= (double s);
+  inline Vec2d & operator/= (double s);
+
+  friend inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
+  friend inline Point2d operator- (const Point2d & p1, const Vec2d & v);
+  friend inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
+  friend inline Vec2d operator- (const Vec2d & p1, const Vec2d & v);
+  friend inline Vec2d operator+ (const Vec2d & p1, const Vec2d & v);
+  friend inline Vec2d operator* (double scal, const Vec2d & v);
+
+  friend double operator* (const Vec2d & v1, const Vec2d & v2)
+    { return v1.X() * v2.X() + v1.Y() * v2.Y(); }
+
+
+  friend double Cross (const Vec2d & v1, const Vec2d & v2)
+    { return double(v1.X()) * double(v2.Y()) -
+             double(v1.Y()) * double(v2.X()); }
+
+  friend inline void PpSmV (const Point2d & p1, double s, const Vec2d & v, Point2d & p2);
+  friend inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v);
+
+
+  friend double Angle (const Vec2d & v);
+  friend double FastAngle (const Vec2d & v);
+  friend double Angle (const Vec2d & v1, const Vec2d & v2);
+  friend double FastAngle (const Vec2d & v1, const Vec2d & v2);
+
+  friend ostream & operator<<(ostream  & s, const Vec2d & v);
+  };
+
+
+
+class LINE2D
+  {
+protected:
+  Point2d p1, p2;
+
+public:
+  LINE2D() : p1(), p2() { };
+  LINE2D(const Point2d & ap1, const Point2d & ap2)
+    { p1 = ap1; p2 = ap2; }
+
+  LINE2D & operator= (const LINE2D & l2)
+    { p1 = l2.p1; p2 = l2.p2; return *this;}
+
+  Point2d & P1() { return p1; }
+  Point2d & P2() { return p2; }
+  const Point2d & P1() const { return p1; }
+  const Point2d & P2() const { return p2; }
+
+  double XMax() const { return ng_max (p1.X(), p2.X()); }
+  double YMax() const { return ng_max (p1.Y(), p2.Y()); }
+  double XMin() const { return ng_min (p1.X(), p2.X()); }
+  double YMin() const { return ng_min (p1.Y(), p2.Y()); }
+
+
+  Vec2d Delta () const { return Vec2d (p2.X()-p1.X(), p2.Y()-p1.Y()); }
+  double Length () const { return Delta().Length(); }
+  double Length2 () const
+        { return sqr (p1.X() - p2.X()) +
+                 sqr (p1.Y() - p2.Y()); }
+
+  friend Point2d CrossPoint (const LINE2D & l1, const LINE2D & l2);
+  friend int Parallel (const LINE2D & l1, const LINE2D & l2, double peps = EPSGEOM);
+  friend int IsOnLine (const LINE2D & l, const Point2d & p, double heps = EPSGEOM);
+  friend int IsOnLongLine (const LINE2D & l, const Point2d & p);
+  friend int Hit (const LINE2D & l1, const LINE2D & l2, double heps = EPSGEOM);
+
+  friend ostream & operator<<(ostream  & s, const LINE2D & l);
+  };
+
+class PLINE2D
+  {
+protected:
+  Point2d const * p1, *p2;
+
+public:
+  PLINE2D() { };
+  PLINE2D(Point2d const * ap1, Point2d const * ap2)
+    { p1 = ap1; p2 = ap2; }
+
+  PLINE2D & operator= (const PLINE2D & l2)
+    { p1 = l2.p1; p2 = l2.p2; return *this;}
+
+  const Point2d *& P1() { return p1; }
+  const Point2d *& P2() { return p2; }
+  const Point2d & P1() const { return *p1; }
+  const Point2d & P2() const { return *p2; }
+
+  double XMax() const { return ng_max (p1->X(), p2->X()); }
+  double YMax() const { return ng_max (p1->Y(), p2->Y()); }
+  double XMin() const { return ng_min (p1->X(), p2->X()); }
+  double YMin() const { return ng_min (p1->Y(), p2->Y()); }
+
+
+  Vec2d Delta () const { return Vec2d (p2->X()-p1->X(), p2->Y()-p1->Y()); }
+  double Length () const { return Delta().Length(); }
+  double Length2 () const
+        { return sqr (p1->X() - p2->X()) +
+                 sqr (p1->Y() - p2->Y()); }
+
+  friend Point2d CrossPoint (const PLINE2D & l1, const PLINE2D & l2);
+  friend int Parallel (const PLINE2D & l1, const PLINE2D & l2, double peps = EPSGEOM);
+  friend int IsOnLine (const PLINE2D & l, const Point2d & p, double heps = EPSGEOM);
+  friend int IsOnLongLine (const PLINE2D & l, const Point2d & p);
+  friend int Hit (const PLINE2D & l1, const LINE2D & l2, double heps = EPSGEOM);
+
+  friend ostream & operator<<(ostream  & s, const LINE2D & l);
+  };
+
+
+
+class ILINE
+  {
+  INDEX i[2];
+
+  public:
+  ILINE() {};
+  ILINE(INDEX i1, INDEX i2) { i[0] = i1; i[1] = i2; }
+  ILINE(const ILINE & l) { i[0] = l.i[0]; i[1] = l.i[1]; }
+
+  ILINE & operator= (const ILINE & l)
+    { i[0] = l.i[0]; i[1] = l.i[1]; return *this; }
+
+  const INDEX & I(int ai) const { return i[ai-1]; }
+  const INDEX & X() const { return i[0]; }
+  const INDEX & Y() const { return i[1]; }
+  const INDEX & I1() const { return i[0]; }
+  const INDEX & I2() const { return i[1]; }
+
+  INDEX & I(int ai) { return i[ai-1]; }
+  INDEX & X() { return i[0]; }
+  INDEX & Y() { return i[1]; }
+  INDEX & I1() { return i[0]; }
+  INDEX & I2() { return i[1]; }
+  };
+
+
+
+
+class TRIANGLE2D
+  {
+private:
+  Point2d p1, p2, p3;
+
+public:
+  TRIANGLE2D() { };
+  TRIANGLE2D (const Point2d & ap1, const Point2d & ap2,
+              const Point2d & ap3)
+    { p1 = ap1; p2 = ap2; p3 = ap3;}
+
+  TRIANGLE2D & operator= (const TRIANGLE2D & t2)
+    { p1 = t2.p1; p2 = t2.p2; p3 = t2.p3; return *this; }
+
+  Point2d & P1() { return p1; }
+  Point2d & P2() { return p2; }
+  Point2d & P3() { return p3; }
+  const Point2d & P1() const { return p1; }
+  const Point2d & P2() const { return p2; }
+  const Point2d & P3() const { return p3; }
+
+  double XMax() const { return ng_max (p1.X(), p2.X(), p3.X()); }
+  double YMax() const { return ng_max (p1.Y(), p2.Y(), p3.Y()); }
+  double XMin() const { return ng_min (p1.X(), p2.X(), p3.X()); }
+  double YMin() const { return ng_min (p1.Y(), p2.Y(), p3.Y()); }
+
+  inline Point2d Center () const
+   { return Point2d( (p1.X()+p2.X()+p3.X())/3, (p1.Y()+p2.Y()+p3.Y())/3); }
+
+  int Regular() const;
+  int CW () const;
+  int CCW () const;
+
+  int IsOn (const Point2d & p) const;
+  int IsIn (const Point2d & p) const;
+  friend ostream & operator<<(ostream  & s, const TRIANGLE2D & t);
+  };
+
+
+class PTRIANGLE2D
+  {
+private:
+  Point2d const *p1, *p2, *p3;
+
+public:
+  PTRIANGLE2D() { };
+  PTRIANGLE2D (const Point2d * ap1, const Point2d * ap2,
+              const Point2d * ap3)
+    { p1 = ap1; p2 = ap2; p3 = ap3;}
+
+  PTRIANGLE2D & operator= (const PTRIANGLE2D & t2)
+    { p1 = t2.p1; p2 = t2.p2; p3 = t2.p3; return *this; }
+
+  const Point2d *& P1() { return p1; }
+  const Point2d *& P2() { return p2; }
+  const Point2d *& P3() { return p3; }
+  const Point2d * P1() const { return p1; }
+  const Point2d * P2() const { return p2; }
+  const Point2d * P3() const { return p3; }
+
+  double XMax() const { return ng_max (p1->X(), p2->X(), p3->X()); }
+  double YMax() const { return ng_max (p1->Y(), p2->Y(), p3->Y()); }
+  double XMin() const { return ng_min (p1->X(), p2->X(), p3->X()); }
+  double YMin() const { return ng_min (p1->Y(), p2->Y(), p3->Y()); }
+
+  Point2d Center () const
+   { return Point2d( (p1->X()+p2->X()+p3->X())/3, (p1->Y()+p2->Y()+p3->Y())/3); }
+
+
+  int Regular() const;
+  int CW () const;
+  int CCW () const;
+
+  int IsOn (const Point2d & p) const;
+  int IsIn (const Point2d & p) const;
+  friend ostream & operator<<(ostream & s, const PTRIANGLE2D & t);
+  };
+
+
+
+/*
+class POLYGON2D
+  {
+protected:
+  PLIST<Point2d> points;
+
+public:
+  POLYGON2D () : points() { };
+
+  void Insert (Point2d * p) { points.Insert(p); }
+
+  double Area () const { return fabs (HArea()); }
+  char CW () const { return HArea() > 0; }
+  char CCW () const { return HArea() < 0; }
+
+  char IsOn (const Point2d & p) const;
+  char IsIn (const Point2d & p) const;
+  char Convex () const;
+  char IsStarPoint (const Point2d & p) const;
+  Point2d Center() const;
+  Point2d EqualAreaPoint () const;
+private:
+  double HArea () const;
+  };
+*/
+
+
+extern double Fastatan2 (double x, double y);
+
+
+
+
+
+// Inline - Functions:
+
+inline Vec2d & Vec2d :: operator+= (const Vec2d & v2)
+  {
+  vx += v2.vx;
+  vy += v2.vy;
+  return *this;
+  }
+
+inline Vec2d & Vec2d :: operator-= (const Vec2d & v2)
+  {
+  vx -= v2.vx;
+  vy -= v2.vy;
+  return *this;
+  }
+
+inline Vec2d & Vec2d :: operator*= (double s)
+  {
+  vx *= s;
+  vy *= s;
+  return *this;
+  }
+
+inline Vec2d & Vec2d :: operator/= (double s)
+  {
+  if (s != 0)
+    {
+    vx /= s;
+    vy /= s;
+    }
+  else
+    {
+    MyError ("Vec3d::operator /=: Divisioin by zero");
+    }
+  return *this;
+  }
+
+
+inline Vec2d operator- (const Point2d & p1, const Point2d & p2)
+  {
+  return Vec2d (p1.X() - p2.X(), p1.Y() - p2.Y());
+  }
+
+inline Point2d operator- (const Point2d & p1, const Vec2d & v)
+  {
+  return Point2d (p1.X() - v.X(), p1.Y() - v.Y());
+  }
+
+inline Point2d operator+ (const Point2d & p1, const Vec2d & v)
+  {
+  return Point2d (p1.X() + v.X(), p1.Y() + v.Y());
+  }
+
+inline Point2d Center (const Point2d & p1, const Point2d & p2)
+  {
+  return Point2d ((p1.X() + p2.X()) / 2, (p1.Y() + p2.Y()) / 2);
+  }
+
+inline Vec2d operator- (const Vec2d & v1, const Vec2d & v2)
+  {
+  return Vec2d (v1.X() - v2.X(), v1.Y() - v2.Y());
+  }
+
+inline Vec2d operator+ (const Vec2d & v1, const Vec2d & v2)
+  {
+  return Vec2d (v1.X() + v2.X(), v1.Y() + v2.Y());
+  }
+
+inline Vec2d operator* (double scal, const Vec2d & v)
+  {
+  return Vec2d (scal * v.X(), scal * v.Y());
+  }
+
+inline void PpSmV (const Point2d & p1, double s,
+                   const Vec2d & v, Point2d & p2)
+  {
+  p2.X() = p1.X() + s * v.X();
+  p2.Y() = p1.Y() + s * v.Y();
+  }
+
+inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v)
+  {
+  v.X() = p1.X() - p2.X();
+  v.Y() = p1.Y() - p2.Y();
+  }
+
+
+
+
+
+inline int TRIANGLE2D :: Regular() const
+    {
+    return fabs(Cross ( p2 - p1, p3 - p2)) > EPSGEOM;
+    }
+
+inline int TRIANGLE2D :: CW () const
+    {
+    return Cross ( p2 - p1, p3 - p2) < 0;
+    }
+
+inline int TRIANGLE2D :: CCW () const
+    {
+    return Cross ( p2 - p1, p3 - p2) > 0;
+    }
+
+
+
+inline int PTRIANGLE2D :: Regular() const
+    {
+    return fabs(Cross ( *p2 - *p1, *p3 - *p2)) > EPSGEOM;
+    }
+
+inline int PTRIANGLE2D :: CW () const
+    {
+    return Cross ( *p2 - *p1, *p3 - *p2) < 0;
+    }
+
+inline int PTRIANGLE2D :: CCW () const
+    {
+    return Cross ( *p2 - *p1, *p3 - *p2) > 0;
+    }
diff -ruN ug-orig/gm/gg3/netgen/geom/geom3d.cc ug-patched/gm/gg3/netgen/geom/geom3d.cc
--- ug-orig/gm/gg3/netgen/geom/geom3d.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/geom3d.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,252 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <math.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <geom/geom3d.hh>
+
+extern void NewError (int dummy);
+
+Vec3d & Vec3d :: operator/= (double s)
+  {
+  if (s != 0)
+    {
+    vx /= s;
+    vy /= s;
+    vz /= s;
+    }
+  else
+    {
+    NewError (1);
+    }
+  return *this;
+  }
+
+ostream & operator<<(ostream  & s, const Point3d & p)
+  {
+  return s << "(" << p.px << ", " << p.py << ", " << p.pz << ")";
+  }
+
+ostream & operator<<(ostream  & s, const Vec3d & v)
+  {
+  return s << "(" << v.vx << ", " << v.vy << ", " << v.vz << ")";
+  }
+
+double Angle (const Vec3d & v1, const Vec3d & v2)
+  {
+  double co = (v1 * v2) / (v1.Length() * v2.Length());
+  if (co > 1) co = 1;
+  if (co < -1) co = -1;
+  return acos ( co );
+  }
+
+void Vec3d :: GetNormal (Vec3d & n)
+  {
+  if (fabs (X()) > fabs (Z()))
+    {
+    n.X() = -Y();
+    n.Y() = X();
+    n.Z() = 0;
+    }
+  else
+    {
+    n.X() = 0;
+    n.Y() = Z();
+    n.Z() = -n.Y();
+    }
+  double len = n.Length();
+  if (len == 0)
+    {
+    n.X() = 1;
+    n.Y() = n.Z() = 0;
+    }
+  else
+    n /= len;
+  }
+
+/*
+ostream & operator<<(ostream  & s, const ROTDenseMatrix3D & r)
+  {
+  return s << "{ (" << r.txx << ", " << r.txy << ", " << r.txz << ") , ("
+                    << r.tyx << ", " << r.tyy << ", " << r.tyz << ") , ("
+                    << r.tzx << ", " << r.tzy << ", " << r.tzz << ") }";
+  }
+*/
+
+/*
+Vec3d operator- (const Point3d & p1, const Point3d & p2)
+  {
+  return Vec3d (p1.X() - p2.X(), p1.Y() - p2.Y(),p1.Z() - p2.Z());
+  }
+
+Point3d operator- (const Point3d & p1, const Vec3d & v)
+  {
+  return Point3d (p1.X() - v.X(), p1.Y() - v.Y(),p1.Z() - v.Z());
+  }
+
+Point3d operator+ (const Point3d & p1, const Vec3d & v)
+  {
+  return Point3d (p1.X() + v.X(), p1.Y() + v.Y(),p1.Z() + v.Z());
+  }
+
+Vec3d operator- (const Vec3d & v1, const Vec3d & v2)
+  {
+  return Vec3d (v1.X() - v2.X(), v1.Y() - v2.Y(),v1.Z() - v2.Z());
+  }
+
+Vec3d operator+ (const Vec3d & v1, const Vec3d & v2)
+  {
+  return Vec3d (v1.X() + v2.X(), v1.Y() + v2.Y(),v1.Z() + v2.Z());
+  }
+
+Vec3d operator* (double scal, const Vec3d & v)
+  {
+  return Vec3d (scal * v.X(), scal * v.Y(), scal * v.Z());
+  }
+*/
+/*
+double operator* (const Vec3d & v1, const Vec3d & v2)
+  {
+  return v1.X() * v2.X() + v1.Y() * v2.Y() + v1.Z() * v2.Z();
+  }
+
+double Cross (const Vec3d & v1, const Vec3d & v2)
+  {
+  return v1.X() * v2.Y() - v1.Y() * v2.X();
+  }
+*/
+
+/*
+void ROTDenseMatrix3D :: CalcRotMat(double ag, double bg, double lg, double size2, Vec3d r)
+  {
+  size = size2;
+  txx=size * ( cos(bg) * cos(lg) );
+  txy=size * ( cos(bg) * sin(lg) );
+  txz=size * (-sin(bg)           );
+
+  tyx=size * ( sin(ag) * sin(bg) * cos(lg) - cos(ag) * sin(lg) );
+  tyy=size * ( sin(ag) * sin(bg) * sin(lg) + cos(ag) * cos(lg) );
+  tyz=size * ( sin(ag) * cos(bg)                               );
+
+  tzx=size * ( cos(ag) * sin(bg) * cos(lg) + sin(ag) * sin(lg) );
+  tzy=size * ( cos(ag) * sin(bg) * sin(lg) - sin(ag) * cos(lg) );
+  tzz=size * ( cos(ag) * cos(bg)                               );
+
+  deltaR=r;
+  }
+ROTDenseMatrix3D :: ROTDenseMatrix3D(double ag, double bg, double lg, double size2, Vec3d r)
+  {CalcRotMat(ag, bg, lg, size2, r); }
+
+ROTDenseMatrix3D :: ROTDenseMatrix3D(Vec3d rot2)
+  {
+  Vec3d r2(0,0,0);
+  CalcRotMat(rot2.X(), rot2.Y(), rot2.Z(), 1, r2);
+  }
+
+ROTDenseMatrix3D ROTDenseMatrix3D :: INV()
+  {
+  ROTDenseMatrix3D rinv(txx/sqr(size),tyx/sqr(size),tzx/sqr(size),
+                   txy/sqr(size),tyy/sqr(size),tzy/sqr(size),
+                   txz/sqr(size),tyz/sqr(size),tzz/sqr(size),
+                   1/size,deltaR);
+  return rinv;
+  }
+
+Vec3d operator* (const ROTDenseMatrix3D & r, const Vec3d & v)
+  {
+  return Vec3d (r.XX() * v.X() + r.XY() * v.Y() + r.XZ() * v.Z(),
+                r.YX() * v.X() + r.YY() * v.Y() + r.YZ() * v.Z(),
+                r.ZX() * v.X() + r.ZY() * v.Y() + r.ZZ() * v.Z() );
+  }
+
+Point3d operator* (const ROTDenseMatrix3D & r, const Point3d & p)
+  {
+  return Point3d (r.XX() * p.X() + r.XY() * p.Y() + r.XZ() * p.Z(),
+                  r.YX() * p.X() + r.YY() * p.Y() + r.YZ() * p.Z(),
+                  r.ZX() * p.X() + r.ZY() * p.Y() + r.ZZ() * p.Z() );
+  }
+*/
+
+
+
+
+
+
+
+box3d :: box3d ( double aminx, double amaxx,
+                 double aminy, double amaxy,
+                 double aminz, double amaxz )
+  {
+  minx = aminx; maxx = amaxx;
+  miny = aminy; maxy = amaxy;
+  minz = aminz; maxz = amaxz;
+  CalcDiamCenter ();
+  }
+
+
+void box3d :: CalcDiamCenter ()
+  {
+  diam = sqrt( sqr (maxx - minx) + sqr (maxy - miny) + sqr (maxz - minz));
+
+  c.X() = 0.5 * (minx + maxx);
+  c.Y() = 0.5 * (miny + maxy);
+  c.Z() = 0.5 * (minz + maxz);
+
+  inner = ng_min ( ng_min (maxx - minx, maxy - miny), maxz - minz) / 2;
+  }
+
+
+void box3d :: CalcSubBox (int i, box3d & sbox) const
+  {
+  i--;
+  if (i & 1)
+    {
+    sbox.minx = c.X();
+    sbox.maxx = maxx;
+    }
+  else
+    {
+    sbox.minx = minx;
+    sbox.maxx = c.X();
+    }
+  if (i & 2)
+    {
+    sbox.miny = c.Y();
+    sbox.maxy = maxy;
+    }
+  else
+    {
+    sbox.miny = miny;
+    sbox.maxy = c.Y();
+    }
+  if (i & 4)
+    {
+    sbox.minz = c.Z();
+    sbox.maxz = maxz;
+    }
+  else
+    {
+    sbox.minz = minz;
+    sbox.maxz = c.Z();
+    }
+
+//  sbox.CalcDiamCenter ();
+
+  sbox.c.X() = 0.5 * (sbox.minx + sbox.maxx);
+  sbox.c.Y() = 0.5 * (sbox.miny + sbox.maxy);
+  sbox.c.Z() = 0.5 * (sbox.minz + sbox.maxz);
+  sbox.diam = 0.5 * diam;
+  sbox.inner = 0.5 * inner;
+  }
+
+void box3d :: GetPointNr (int i, Point3d & point) const
+  {
+  i--;
+  point.X() = (i & 1) ? maxx : minx;
+  point.Y() = (i & 2) ? maxy : miny;
+  point.Z() = (i & 4) ? maxz : minz;
+  }
+
+
diff -ruN ug-orig/gm/gg3/netgen/geom/geom3d.hh ug-patched/gm/gg3/netgen/geom/geom3d.hh
--- ug-orig/gm/gg3/netgen/geom/geom3d.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/geom3d.hh	2002-04-16 14:58:00.000000000 +0200
@@ -0,0 +1,231 @@
+extern void MyError (char * ch);
+class ostream;
+
+class Point3d;
+class Vec3d;
+
+class Point3d
+  {
+protected:
+  double px, py, pz;
+
+public:
+  Point3d() { px = py = pz = 0; }
+  Point3d(double ax, double ay, double az) { px = ax; py = ay; pz = az; }
+  Point3d(const Point3d & p2) { px = p2.px; py = p2.py; pz = p2.pz; }
+
+  Point3d & operator= (const Point3d & p2)
+    { px = p2.px; py = p2.py; pz = p2.pz; return *this; }
+
+  double & X() { return px; }
+  double & Y() { return py; }
+  double & Z() { return pz; }
+  double X() const { return px; }
+  double Y() const { return py; }
+  double Z() const { return pz; }
+
+  friend inline Vec3d operator- (const Point3d & p1, const Point3d & p2);
+  friend inline Point3d operator- (const Point3d & p1, const Vec3d & v);
+  friend inline Point3d operator+ (const Point3d & p1, const Vec3d & v);
+  friend double Dist (const Point3d & p1, const Point3d & p2)
+    { return sqrt ( sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) +
+                    sqr (p1.Z()-p2.Z()) ); }
+  friend double Dist2 (const Point3d & p1, const Point3d & p2)
+    { return sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) +
+                  sqr (p1.Z()-p2.Z()) ; }
+  friend inline Point3d Center (const Point3d & p1, const Point3d & p2);
+  friend inline Point3d Center (const Point3d & p1, const Point3d & p2, const Point3d & p3);
+  friend ostream & operator<<(ostream  & s, const Point3d & p);
+  };
+
+
+class Vec3d
+  {
+protected:
+  double vx, vy, vz;
+
+public:
+  Vec3d() { vx = vy = vz = 0; }
+  Vec3d(double ax, double ay, double az) { vx = ax; vy = ay; vz = az; }
+  Vec3d(const Vec3d & v2) { vx = v2.vx; vy = v2.vy; vz = v2.vz; }
+
+  Vec3d & operator= (const Vec3d & v2)
+    { vx = v2.vx; vy = v2.vy; vz = v2.vz; return *this; }
+
+  double & X() { return vx; }
+  double & Y() { return vy; }
+  double & Z() { return vz; }
+  double X() const { return vx; }
+  double Y() const { return vy; }
+  double Z() const { return vz; }
+
+  double Length() const { return sqrt (vx * vx + vy * vy + vz * vz); }
+  double Length2() const { return vx * vx + vy * vy + vz * vz; }
+
+  Vec3d & operator+= (const Vec3d & v2);
+  Vec3d & operator-= (const Vec3d & v2);
+  Vec3d & operator*= (double s);
+  Vec3d & operator/= (double s);
+
+  friend inline Vec3d operator- (const Point3d & p1, const Point3d & p2);
+  friend inline Point3d operator- (const Point3d & p1, const Vec3d & v);
+  friend inline Point3d operator+ (const Point3d & p1, const Vec3d & v);
+  friend inline Vec3d operator- (const Vec3d & p1, const Vec3d & v);
+  friend inline Vec3d operator+ (const Vec3d & p1, const Vec3d & v);
+  friend inline Vec3d operator* (double scal, const Vec3d & v);
+
+  friend inline double operator* (const Vec3d & v1, const Vec3d & v2);
+  friend inline Vec3d Cross (const Vec3d & v1, const Vec3d & v2);
+
+  void GetNormal (Vec3d & n);
+  friend double Angle (const Vec3d & v);
+  friend double FastAngle (const Vec3d & v);
+  friend double Angle (const Vec3d & v1, const Vec3d & v2);
+  friend double FastAngle (const Vec3d & v1, const Vec3d & v2);
+
+  friend ostream & operator<<(ostream  & s, const Vec3d & v);
+  };
+
+
+
+
+inline Point3d Center (const Point3d & p1, const Point3d & p2)
+    {
+    return Point3d (0.5 * (p1.X() + p2.X()),
+                    0.5 * (p1.Y() + p2.Y()),
+                    0.5 * (p1.Z() + p2.Z()));
+    }
+
+inline Point3d Center (const Point3d & p1, const Point3d & p2,
+                       const Point3d & p3)
+    {
+    return Point3d (1.0/3.0 * (p1.X() + p2.X() + p3.X()),
+                    1.0/3.0 * (p1.Y() + p2.Y() + p3.Y()),
+                    1.0/3.0 * (p1.Z() + p2.Z() + p3.Z()));
+    }
+
+
+inline Vec3d & Vec3d :: operator+= (const Vec3d & v2)
+  {
+  vx += v2.vx;
+  vy += v2.vy;
+  vz += v2.vz;
+  return *this;
+  }
+
+inline Vec3d & Vec3d :: operator-= (const Vec3d & v2)
+  {
+  vx -= v2.vx;
+  vy -= v2.vy;
+  vz -= v2.vz;
+  return *this;
+  }
+
+inline Vec3d & Vec3d :: operator*= (double s)
+  {
+  vx *= s;
+  vy *= s;
+  vz *= s;
+  return *this;
+  }
+
+// moved to geom3d.cc
+/*inline Vec3d & Vec3d :: operator/= (double s)
+  {
+  if (s != 0)
+    {
+    vx /= s;
+    vy /= s;
+    vz /= s;
+    }
+  else
+    {
+    MyError ("Vec3d::operator /=: Divisioin by zero");
+    }
+  return *this;
+  }
+*/
+
+
+
+
+inline Vec3d operator- (const Point3d & p1, const Point3d & p2)
+  {
+  return Vec3d (p1.X() - p2.X(), p1.Y() - p2.Y(),p1.Z() - p2.Z());
+  }
+
+inline Point3d operator- (const Point3d & p1, const Vec3d & v)
+  {
+  return Point3d (p1.X() - v.X(), p1.Y() - v.Y(),p1.Z() - v.Z());
+  }
+
+inline Point3d operator+ (const Point3d & p1, const Vec3d & v)
+  {
+  return Point3d (p1.X() + v.X(), p1.Y() + v.Y(),p1.Z() + v.Z());
+  }
+
+inline Vec3d operator- (const Vec3d & v1, const Vec3d & v2)
+  {
+  return Vec3d (v1.X() - v2.X(), v1.Y() - v2.Y(),v1.Z() - v2.Z());
+  }
+
+inline Vec3d operator+ (const Vec3d & v1, const Vec3d & v2)
+  {
+  return Vec3d (v1.X() + v2.X(), v1.Y() + v2.Y(),v1.Z() + v2.Z());
+  }
+
+inline Vec3d operator* (double scal, const Vec3d & v)
+  {
+  return Vec3d (scal * v.X(), scal * v.Y(), scal * v.Z());
+  }
+
+
+inline double operator* (const Vec3d & v1, const Vec3d & v2)
+  {
+  return v1.X() * v2.X() + v1.Y() * v2.Y() + v1.Z() * v2.Z();
+  }
+
+
+inline Vec3d Cross (const Vec3d & v1, const Vec3d & v2)
+  {
+  return Vec3d
+     ( v1.Y() * v2.Z() - v1.Z() * v2.Y(),
+       v1.Z() * v2.X() - v1.X() * v2.Z(),
+       v1.X() * v2.Y() - v1.Y() * v2.X());
+  }
+
+
+class box3d
+  {
+  double minx, maxx, miny, maxy, minz, maxz;
+  double diam, inner;
+  Point3d c;
+
+
+  public:
+
+  box3d () { };
+
+  box3d ( double aminx, double amaxx,
+          double aminy, double amaxy,
+          double aminz, double amaxz );
+
+
+  const Point3d & Center () const { return c; }
+  double Diam () const { return diam; }
+  double Inner () const { return inner; }
+  double MinX () const { return minx; }
+  double MaxX () const { return maxx; }
+  double MinY () const { return miny; }
+  double MaxY () const { return maxy; }
+  double MinZ () const { return minz; }
+  double MaxZ () const { return maxz; }
+
+  void CalcSubBox (int i, box3d & sbox) const;
+  void GetPointNr (int i, Point3d & point) const;
+
+  private:
+  void CalcDiamCenter ();
+  };
+
+
diff -ruN ug-orig/gm/gg3/netgen/geom/makefile ug-patched/gm/gg3/netgen/geom/makefile
--- ug-orig/gm/gg3/netgen/geom/makefile	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/makefile	1996-03-27 16:38:10.000000000 +0100
@@ -0,0 +1,9 @@
+objects = geom2d.o geom3d.o reftrans.o
+lib = geom
+#
+# CCFL    += -Wall
+# CCFL     += -pg
+#
+include ../makefile.inc
+#
+# CCFL += -O4
diff -ruN ug-orig/gm/gg3/netgen/geom/reftrans.cc ug-patched/gm/gg3/netgen/geom/reftrans.cc
--- ug-orig/gm/gg3/netgen/geom/reftrans.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/reftrans.cc	1996-10-01 19:43:25.000000000 +0200
@@ -0,0 +1,77 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+#include <math.h>
+#include <new.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+// #include <linalg/linalg.hh>
+
+#include <geom/reftrans.hh>
+
+
+
+void referencetransform :: Set (const Point3d & p1, const Point3d & p2,
+                                const Point3d & p3, double ah)
+  {
+  ex = p2 - p1;
+  ex /= ex.Length();
+  ey = p3 - p1;
+  ey -= (ex * ey) * ex;
+  ey /= ey.Length();
+  ez = Cross (ex, ey);
+  rp = p1;
+  h = ah;
+
+  exh = ah * ex;
+  eyh = ah * ey;
+  ezh = ah * ez;
+  ah = 1 / ah;
+  ex_h = ah * ex;
+  ey_h = ah * ey;
+  ez_h = ah * ez;
+  }
+
+void referencetransform :: ToPlain (const Point3d & p, Point3d & pp) const
+  {
+  Vec3d v;
+  v = p - rp;
+  pp.X() = (ex_h * v);
+  pp.Y() = (ey_h * v);
+  pp.Z() = (ez_h * v);
+  }
+
+void referencetransform :: ToPlain (const ARRAY<Point3d> & p,
+                                    ARRAY<Point3d> & pp) const
+  {
+  Vec3d v;
+  int i;
+
+  pp.SetSize (p.Size());
+  for (i = 1; i <= p.Size(); i++)
+    {
+    v = p.Get(i) - rp;
+    pp.Elem(i).X() = (ex_h * v);
+    pp.Elem(i).Y() = (ey_h * v);
+    pp.Elem(i).Z() = (ez_h * v);
+    }
+  }
+
+void referencetransform :: FromPlain (const Point3d & pp, Point3d & p) const
+  {
+  Vec3d v;
+//  v = (h * pp.X()) * ex + (h * pp.Y()) * ey + (h * pp.Z()) * ez;
+//  p = rp + v;
+  v.X() = pp.X() * exh.X() + pp.Y() * eyh.X() + pp.Z() * ezh.X();
+  v.Y() = pp.X() * exh.Y() + pp.Y() * eyh.Y() + pp.Z() * ezh.Y();
+  v.Z() = pp.X() * exh.Z() + pp.Y() * eyh.Z() + pp.Z() * ezh.Z();
+  p.X() = rp.X() + v.X();
+  p.Y() = rp.Y() + v.Y();
+  p.Z() = rp.Z() + v.Z();
+  }
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/geom/reftrans.hh ug-patched/gm/gg3/netgen/geom/reftrans.hh
--- ug-orig/gm/gg3/netgen/geom/reftrans.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/geom/reftrans.hh	1996-10-01 19:43:25.000000000 +0200
@@ -0,0 +1,23 @@
+#ifndef FILE_REFTRANS
+#define FILE_REFTRANS
+
+class referencetransform
+  {
+  Vec3d ex, ey, ez;
+  Vec3d exh, eyh, ezh;
+  Vec3d ex_h, ey_h, ez_h;
+  Point3d rp;
+  double h;
+
+  public:
+
+  void Set (const Point3d & p1, const Point3d & p2,
+            const Point3d & p3, double ah);
+
+  void ToPlain (const Point3d & p, Point3d & pp) const;
+  void ToPlain (const ARRAY<Point3d> & p, ARRAY<Point3d> & pp) const;
+  void FromPlain (const Point3d & pp, Point3d & p) const;
+  };
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/basemat.cc ug-patched/gm/gg3/netgen/linalg/basemat.cc
--- ug-orig/gm/gg3/netgen/linalg/basemat.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/basemat.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,482 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <string.h>
+#include <math.h>
+
+
+#include <myadt.hh>
+#include <linalg/linalg.hh>
+
+
+//ofstream myerr ("error.out");
+// ofstream myerr ("NUL");
+
+
+
+
+double BaseMatrix :: shit = 0;
+
+
+BaseMatrix :: BaseMatrix ()
+  {
+  height = width = 0;
+  symmetric = 0;
+  }
+
+BaseMatrix :: BaseMatrix (INDEX h, INDEX w)
+  {
+  if (!w) w = h;
+  height = h;
+  width = w;
+  symmetric = 0;
+  }
+
+void BaseMatrix :: SetSize (INDEX h, INDEX w)
+  {
+  if (!w) w = h;
+  height = h;
+  width = w;
+  }
+
+void BaseMatrix :: SetSymmetric (int sym)
+  {
+  symmetric = sym;
+  }
+
+double & BaseMatrix :: operator() (INDEX, INDEX)
+  {
+//  myerr << "BaseMatrix: operator() called" << endl;
+  return shit;
+  }
+
+double BaseMatrix :: operator() (INDEX, INDEX) const
+  {
+//  myerr << "BaseMatrix: operator() called" << endl;
+  return 0;
+  }
+
+
+
+ostream & operator<<(ostream & s, const BaseMatrix & m)
+  {
+  return m.Print (s);
+  }
+
+ostream & BaseMatrix :: Print (ostream & s) const
+  {
+  if (Symmetric()) s << "Symmetric" << endl;
+  for (INDEX i = 1; i <= Height(); i++)
+    {
+    for (INDEX j = 1; j < Width(); j++)
+      s << (*this)(i, j) << "  ";
+    s << (*this)(i, Width()) << endl;
+    }
+
+  return s;
+  }
+
+
+
+TempVector BaseMatrix :: operator* (const BaseVector & v) const
+  {
+  Vector * prod = new Vector(Height());
+
+  if (Width() != v.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit 1" << endl;
+	;
+    }
+  else if (Height() != prod->Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+	;
+    }
+  else
+    {
+    Mult (v, *prod);
+    }
+
+  return *prod;
+  }
+
+
+
+DenseMatrix operator* (const BaseMatrix & m1, const BaseMatrix & m2)
+  {
+  DenseMatrix temp (m1.Height(), m2.Width());
+  double sum;
+
+  if (m1.Width() != m2.Height())
+         {
+//         myerr << "BaseMatrix :: operator*: Matrix Size does not fit" << endl;
+			;
+         }
+  else if (temp.Height() != m1.Height())
+         {
+//         myerr << "BaseMatrix :: operator*: temp not allocated" << endl;
+			;
+    }
+  else
+    {
+    for (INDEX i = 1; i <= m1.Height(); i++)
+      for (INDEX j = 1; j <= m2.Width(); j++)
+        {
+        sum = 0;
+        for (INDEX k = 1; k <= m1.Width(); k++)
+          sum += m1(i, k) * m2(k, j);
+        temp(i, j) = sum;
+        }
+    }
+  return temp;
+  }
+
+
+DenseMatrix operator+ (const BaseMatrix & m1, const BaseMatrix & m2)
+  {
+  DenseMatrix temp (m1.Height(), m1.Width());
+  INDEX i, j;
+
+  if (m1.Width() != m2.Width() || m1.Height() != m2.Height())
+    {
+//    myerr << "BaseMatrix :: operator+: Matrix Size does not fit" << endl;
+		;
+    }
+  else if (temp.Height() != m1.Height())
+    {
+//    myerr << "BaseMatrix :: operator+: temp not allocated" << endl;
+		;
+    }
+  else
+    {
+    for (i = 1; i <= m1.Height(); i++)
+      for (j = 1; j <= m1.Width(); j++)
+        {
+        temp(i, j) = m1(i, j) + m2(i, j);
+        }
+    }
+  return temp;
+  }
+
+
+void BaseMatrix :: Mult (const BaseVector & /* v */,
+      BaseVector & /* prod */) const
+  {  
+//  myerr << "BaseMatrix :: Mult called" << endl;
+	;
+  }
+
+void BaseMatrix :: MultTrans (const BaseVector &  v,
+      BaseVector & prod) const
+  {
+  if (Symmetric())
+    Mult (v, prod);
+//  else
+//    myerr << "BaseMatrix :: MultTrans called for non symmetric matrix" << endl;
+  }
+
+void BaseMatrix :: Residuum (const BaseVector &  x,
+      const BaseVector & b, BaseVector & res) const
+  {
+  Mult (x, res);
+  res *= -1;
+  res.Add (1, b);
+  }
+
+void BaseMatrix :: ResiduumTrans (const BaseVector & x,
+      const BaseVector & b, BaseVector & res) const
+  {
+  MultTrans (x, res);
+  res *= -1;
+  res.Add (1, b);
+  }
+
+BaseMatrix * BaseMatrix :: Copy () const
+  {
+//  myerr << "BaseMatrix :: Copy called" << endl;
+  return NULL;
+  }
+
+
+BaseVector * BaseMatrix :: CreateVector () const
+  {
+  return new Vector (Height());
+  }
+
+
+
+/*
+void BaseMatrix :: Mult (const Vector & v, Vector & prod) const
+  {
+  double sum;
+
+  prod.SetLength (Height());
+
+  if (Width() != v.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit 2" << endl;
+    }
+  else if (Height() != prod.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+		;
+    }
+  else
+    {
+    for (INDEX i = 1; i <= Height(); i++)
+      {
+      sum = 0;
+
+      for (INDEX j = 1; j <= Width(); j++)
+        sum += (*this)(i,j) * v.Get(j);
+
+      prod.Set (i, sum);
+      }
+    }
+  }
+
+
+void BaseMatrix :: MultTrans (const Vector & v, Vector & prod) const
+  {
+  double sum;
+
+  prod.SetLength (Width());
+
+  if (Height() != v.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit 3" << endl;
+		;
+    }
+  else if (Width() != prod.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+		;
+    }
+  else
+    {
+    for (INDEX i = 1; i <= Width(); i++)
+      {
+      sum = 0;
+
+      for (INDEX j = 1; j <= Height(); j++)
+        sum += (*this)(j, i) * v.Get(j);
+
+      prod.Set (i, sum);
+      }
+    }
+  }
+
+
+void BaseMatrix :: Residuum (const Vector & x, const Vector & b, Vector & res) const
+  {
+  double sum;
+
+  res.SetLength (Height());
+
+  if (Width() != x.Length() || Height() != b.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit 4" << endl;
+		;
+    }
+  else if (Height() != res.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+		;
+    }
+  else
+    {
+    for (INDEX i = 1; i <= Height(); i++)
+      {
+      sum = b.Get(i);
+
+      for (INDEX j = 1; j <= Width(); j++)
+        sum -= (*this)(i,j) * x.Get(j);
+
+      res.Set (i, sum);
+      }
+    }
+  }
+*/
+
+
+
+
+
+
+
+void BaseMatrix :: SolveDestroy (const Vector & v, Vector & sol)
+  {
+  INDEX i, j, k;
+  double q;
+
+  if (Width() != Height())
+    {
+//    myerr << "SolveDestroy: Matrix not square";
+    return;
+    }
+  if (Width() != v.Length())
+    {
+//    myerr << "SolveDestroy: Matrix and Vector don't fit";
+    return;
+    }
+
+  sol = v;
+  if (Height() != sol.Length())
+    {
+//    myerr << "SolveDestroy: Solution Vector not ok";
+    return;
+    }
+
+  for (i = 1; i <= Height(); i++)
+    {
+    for (j = i+1; j <= Height(); j++)
+      {
+      q=(*this)(j,i) / (*this)(i,i);
+      for (k = i+1; k <= Height(); k++)
+        {
+        (*this)(j, k) -= q * (*this)(i,k);
+        }
+      sol.Elem(j) -= q * sol.Get(i);
+      }
+    }
+
+  for (i = Height(); i >= 1; i--)
+    {
+    q = sol(i);
+    for (j = i+1; j <= Height(); j++)
+      {
+      q -= (*this)(i,j) * sol.Get(j);
+      }
+    sol.Set(i, q / (*this)(i,i));
+    }
+  }
+
+void BaseMatrix :: Solve (const Vector & v, Vector & sol) const
+  {
+  BaseMatrix * temp = Copy();
+
+  if (temp->Height() != Height())
+    {
+//    myerr << "Solve: Matrix temp not allocated" << endl;
+    return;
+    }
+
+  temp->SolveDestroy (v, sol);
+
+  delete temp;
+  }
+
+
+Vector BaseMatrix :: SolveDestroyFunc (const Vector & /* b */) const
+{
+  return Vector(0);
+}
+
+
+
+Vector BaseMatrix :: Solve (const Vector & v) const
+  {
+  Vector sol (v.Length());
+
+  if (Width() != Height())
+    {
+//    myerr << "Solve: Matrix not square";
+    return v;
+    }
+  if (Width() != v.Length())
+    {
+//    myerr << "Solve: Matrix and Vector don't fit";
+    return v;
+    }
+  if (Width() != sol.Length())
+    {
+//    myerr << "Solve: Vector sol not allocated" << endl;
+    }
+
+  Solve (v, sol);
+
+  return sol;
+  }
+
+
+
+
+
+
+
+void BaseMatrix :: LU_Decomposition (DenseMatrix & l, DenseMatrix & u) const
+  {
+  INDEX i, j ,k;
+  double sum;
+  l.SetSize (Width());
+  u.SetSize (Width());
+
+  for (i = 1; i <= Width(); i++)
+    for (j = 1; j <= Width(); j++)
+      l(i, j) = u(i, j) = 0;
+
+  for (i = 1; i <= Width(); i++)
+    {
+    for (k = 1; k < i; k++)
+      {
+      sum = (*this)(i, k);
+      for (j = 1; j < k; j++)
+        sum -= l(i, j) * u(j, k);
+      l(i, k) = sum / u(k, k);
+      }
+    l(i, i) = 1;
+
+    for (k = i; k <= Width(); k++)
+      {
+      sum = (*this)(i, k);
+      for (j = 1; j < i; j++)
+        sum -= l(i, j) * u(j, k);
+      u(i, k) = sum;
+      }
+    }
+  }
+
+
+
+void Transpose (const BaseMatrix & m1, DenseMatrix & m2)
+  {
+  m2.SetSize (m1.Width(), m1.Height());
+  INDEX i, j;
+
+  for (i = 1; i <= m1.Height(); i++)
+    for (j = 1; j <= m1.Width(); j++)
+      m2(j, i) = m1(i, j);
+  }
+
+
+
+DenseMatrix * BaseMatrix :: MakeDenseMatrix () const
+{
+  DenseMatrix * dmat = new DenseMatrix (Height(), Width());
+  dmat -> SetSymmetric(Symmetric());
+
+  Vector x(Width()), y(Height());
+  INDEX i, j;
+
+  for (i = 1; i <= Width(); i++)
+    {
+      x = 0;
+      x.Elem(i) = 1;
+      Mult (x, y);
+      
+      for (j = 1; j <= Height(); j++)
+	dmat->Elem(j, i) = y.Get(j);
+    }
+
+  return dmat;
+}
+ 
+
+BaseMatrix * BaseMatrix :: InverseMatrix (const BitArray * /* inner */) const
+{
+  cout << "called basematrix::inversemarix" << endl;
+  return NULL;
+}
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/linalg/basemat.hh ug-patched/gm/gg3/netgen/linalg/basemat.hh
--- ug-orig/gm/gg3/netgen/linalg/basemat.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/basemat.hh	1998-03-18 19:05:16.000000000 +0100
@@ -0,0 +1,105 @@
+#ifndef FILE_BASEMAT
+#define FILE_BASEMAT
+
+/**************************************************************************/
+/* File:   basemat.hh                                                     */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Oct. 94                                                    */
+/**************************************************************************/
+
+/* 
+   Base type for linear operator
+*/
+
+class DenseMatrix;
+
+///
+class BaseMatrix
+{
+protected:
+  ///
+  INDEX height, width;
+  ///
+  BOOL symmetric;
+  ///
+  static double shit;
+
+public:
+  ///
+  BaseMatrix ();
+  ///
+  BaseMatrix (INDEX h, INDEX w = 0);
+  ///
+  virtual ~BaseMatrix () { };
+
+  ///
+  INDEX Width () const { return width; }
+  ///
+  INDEX Height () const { return height; }
+  ///
+  BOOL Symmetric () const { return symmetric; }
+
+  ///
+  virtual void SetSize (INDEX h, INDEX w = 0);
+  ///
+  virtual void SetSymmetric (int sym = 1);
+
+  ///
+  virtual double & operator() (INDEX i, INDEX j);
+  ///
+  virtual double operator() (INDEX i, INDEX j) const;
+
+  ///
+  friend ostream & operator<<(ostream & s, const BaseMatrix & m);
+  ///
+  virtual ostream & Print (ostream & s) const;
+
+  ///
+  TempVector operator* (const BaseVector & v) const;
+
+
+  ///
+  virtual void Mult (const BaseVector & v, BaseVector & prod) const;
+  ///
+  virtual void MultTrans (const BaseVector & v, BaseVector & prod) const;
+  ///
+  virtual void Residuum (const BaseVector & x, const BaseVector & b, BaseVector & res) const;
+  ///
+  virtual void ResiduumTrans (const BaseVector & x, const BaseVector & b, BaseVector & res) const;
+  //  virtual double EvaluateBilinearform (const BaseVector & x);
+
+  virtual BaseMatrix * Copy () const;
+  ///
+  virtual BaseVector * CreateVector () const;
+
+  ///
+  virtual void AddElementMatrix (const ARRAY<INDEX> & /* pnum */, 
+				 const BaseMatrix & /* elemmat */) { };
+  ///
+  virtual void MultElementMatrix (const ARRAY<INDEX> & /* pnum */, 
+				  const BaseVector & /* x */, BaseVector & /* y */) { };
+  ///
+  virtual void MultTransElementMatrix (const ARRAY<INDEX> & /* pnum */, 
+				       const BaseVector & /* x */, BaseVector & /* y */) { };
+
+
+  ///
+  virtual DenseMatrix * MakeDenseMatrix () const;
+  ///
+  virtual BaseMatrix * InverseMatrix (const class BitArray * inner = NULL)
+    const;
+
+  ///
+  virtual void SolveDestroy (const Vector & b, Vector & x);
+  ///
+  void Solve (const Vector & b, Vector & x) const;
+  ///
+  virtual Vector SolveDestroyFunc (const Vector & b) const;
+  ///
+  Vector Solve (const Vector & b) const;
+  ///
+  virtual void LU_Decomposition (DenseMatrix & l, DenseMatrix & u) const;
+};
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/densemat.cc ug-patched/gm/gg3/netgen/linalg/densemat.cc
--- ug-orig/gm/gg3/netgen/linalg/densemat.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/densemat.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,1399 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+#include <string.h>
+
+#include <template.hh>
+#include <myadt.hh>
+#include <linalg/linalg.hh>
+
+
+//extern ofstream myerr;
+
+DenseMatrix :: DenseMatrix () : BaseMatrix ()
+  {
+  data = NULL;
+  }
+
+DenseMatrix :: DenseMatrix (INDEX h, INDEX w) : BaseMatrix (h, w)
+  {
+  if (!w) w = h;
+  data = new double[h*w];
+  if(!data)
+    {
+    height = width = 0;
+//    myerr << "Matrix not allocated" << endl;
+    }
+  }
+
+DenseMatrix :: DenseMatrix (INDEX h, INDEX w, const double * d) 
+    : BaseMatrix (h, w)
+  {
+  int size = h * w;  
+  int i;
+  
+  data = new double[size]; 
+  for (i = 0; i < size; i++)
+    data[i] = d[i];
+  }    
+
+
+DenseMatrix :: DenseMatrix (const DenseMatrix & m2)
+  {
+  data = NULL;
+  SetSize (m2.Height(), m2.Width());
+  SetSymmetric (m2.Symmetric());
+
+  if (data)
+    memcpy (data, m2.data, sizeof(double) * m2.Height() * m2.Width());
+//  else
+//    myerr << "DenseMatrix::MATIRX(DenseMatrix&): Matrix not allocated" << endl;
+  }
+
+
+DenseMatrix :: DenseMatrix (const BaseMatrix & m2)
+  {
+  data = NULL;
+  height = width = 0;
+
+  *this = m2;
+
+//  if (!data)
+//    myerr << "DenseMatrix::DenseMatrix (m2): Matrix not allocated" << endl;
+  }
+
+
+DenseMatrix :: ~DenseMatrix ()
+  {
+  if (data) delete [] data;
+  }
+
+
+void DenseMatrix :: SetSize (INDEX h, INDEX w)
+  {
+  if (!w) w = h;
+  if (height == h && width == w) return;
+
+  height = h;
+  width = w;
+
+  if (data) delete[] data;
+  data = new double[h*w];
+
+  if(!data)
+    {
+    height = width = 0;
+//         myerr << "Matrix::SetSize: Matrix not allocated" << endl;
+    }
+  }
+
+
+DenseMatrix & DenseMatrix :: operator= (const BaseMatrix & m2)
+  {
+  INDEX i, j;
+
+  SetSize (m2.Height(), m2.Width());
+
+  if (data)
+    for (i = 1; i <= Height(); i++)
+      for (j = 1; j <= Width(); j++)
+        Set (i, j, m2(i, j));
+//  else
+//    myerr << "DenseMatrix::Operator=: Matrix not allocated" << endl;
+
+  return *this;
+  }
+
+
+
+DenseMatrix & DenseMatrix :: operator= (const DenseMatrix & m2)
+  {
+  SetSize (m2.Height(), m2.Width());
+
+  if (data)
+    memcpy (data, m2.data, sizeof(double) * m2.Height() * m2.Width());
+//  else
+//    myerr << "DenseMatrix::Operator=: Matrix not allocated" << endl;
+
+  return *this;
+  }
+
+
+DenseMatrix & DenseMatrix :: operator+= (const DenseMatrix & m2)
+  {
+  INDEX i;
+  double * p, * q;
+
+  if (Height() != m2.Height() || Width() != m2.Width())
+    {
+//    myerr << "DenseMatrix::Operator+=: Sizes don't fit" << endl;
+    return *this;
+    }
+
+  if (data)
+    {
+    p = data;
+    q = m2.data;
+    for (i = Width() * Height(); i > 0; i--)
+      {
+      *p += *q;
+      p++;
+      q++;
+      }
+    }
+//  else
+//    myerr << "DenseMatrix::Operator+=: Matrix not allocated" << endl;
+
+  return *this;
+  }
+
+DenseMatrix & DenseMatrix :: operator-= (const DenseMatrix & m2)
+  {
+  INDEX i;
+  double * p, * q;
+
+  if (Height() != m2.Height() || Width() != m2.Width())
+    {
+//    myerr << "DenseMatrix::Operator-=: Sizes don't fit" << endl;
+    return *this;
+    }
+
+  if (data)
+    {
+    p = data;
+    q = m2.data;
+    for (i = Width() * Height(); i > 0; i--)
+      {
+      *p -= *q;
+      p++;
+      q++;
+      }
+    }
+//  else
+//    myerr << "DenseMatrix::Operator-=: Matrix not allocated" << endl;
+
+  return *this;
+  }
+
+
+
+
+
+double & DenseMatrix :: operator() (INDEX i, INDEX j)
+  {
+  if (i >= 1 && j >= 1 && i <= height && j <= width)
+    return Elem(i,j);
+//  else myerr << "DenseMatrix: index (" << i << "," << j << ") out of range (1.."
+//            << height << ",1.." << width << ")\n";
+  return shit;
+  }
+
+double DenseMatrix :: operator() (INDEX i, INDEX j) const
+  {
+  if (i >= 1 && j >= 1 && i <= height && j <= width)
+    return Get(i,j);
+//  else myerr << "DenseMatrix: index (" << i << "," << j << ") out of range (1.."
+//            << height << ",1.." << width << ")\n";
+  return shit;
+  }
+
+
+DenseMatrix & DenseMatrix :: operator= (double v)
+  {
+  INDEX i;
+  double * p = data;
+
+  if (data)
+    for (i = width*height; i > 0; i--, p++)
+      *p = v;
+
+  return *this;
+  }
+
+
+
+DenseMatrix & DenseMatrix :: operator*= (double v)
+  {
+  INDEX i;
+  double * p = data;
+
+  if (data)
+    for (i = width*height; i > 0; i--, p++)
+      *p *= v;
+
+  return *this;
+  }
+
+
+double DenseMatrix :: Det () const
+  {
+  if (width != height)
+    {
+//    myerr << "DenseMatrix :: Det: width != height" << endl;
+    return 0;
+    }
+
+  switch (width)
+    {
+    case 1: return Get(1, 1);
+    case 2: return Get(1) * Get(4) - Get(2) * Get(3);
+
+    case 3: return Get(1) * Get(5) * Get(9)
+                 + Get(2) * Get(6) * Get(7)
+                 + Get(3) * Get(4) * Get(8)
+                 - Get(1) * Get(6) * Get(8)
+                 - Get(2) * Get(4) * Get(9)
+                 - Get(3) * Get(5) * Get(7);
+    default:
+      {
+//      myerr << "Matrix :: Det:  general size not implemented (size=" << width << ")" << endl;
+      return 0;
+      }
+    }
+  }
+
+
+void CalcInverse (const DenseMatrix & m1, DenseMatrix & m2)
+  {
+    //  int i, j, k, n;
+  double det;
+  //  DenseMatrix m1 = hm1;
+
+  if (m1.width != m1.height)
+    {
+//    myerr << "CalcInverse: matrix not symmetric" << endl;
+    return;
+    }
+  if (m1.width != m2.width || m1.height != m2.height)
+    {
+//    myerr << "CalcInverse: dim(m2) != dim(m1)" << endl;
+    return;
+    }
+
+
+  if (m1.Width() <= 3)
+    {
+    det = m1.Det();
+    if (det == 0)
+      {
+//      myerr << "CalcInverse: Matrix singular" << endl;
+      return;
+      }
+
+    det = 1e0 / det;
+    switch (m1.width)
+      {
+      case 1:
+        {
+        m2.Set(1, 1, det);
+        return;
+        }
+      case 2:
+        {
+        m2.Set(1, 1, det * m1.Get(4));
+        m2.Set(2, 2, det * m1.Get(1));  
+        m2.Set(1, 2, - det * m1.Get(2));
+        m2.Set(2, 1, - det * m1.Get(3));
+        return;
+        }
+      case 3:
+        {
+        m2.Set(1, 1,  det * (m1.Get(5) * m1.Get(9) - m1.Get(6) * m1.Get(8)));
+        m2.Set(2, 1, -det * (m1.Get(4) * m1.Get(9) - m1.Get(6) * m1.Get(7)));
+        m2.Set(3, 1,  det * (m1.Get(4) * m1.Get(8) - m1.Get(5) * m1.Get(7)));
+
+        m2.Set(1, 2, -det * (m1.Get(2) * m1.Get(9) - m1.Get(3) * m1.Get(8)));
+        m2.Set(2, 2,  det * (m1.Get(1) * m1.Get(9) - m1.Get(3) * m1.Get(7)));
+        m2.Set(3, 2, -det * (m1.Get(1) * m1.Get(8) - m1.Get(2) * m1.Get(7)));
+
+        m2.Set(1, 3,  det * (m1.Get(2) * m1.Get(6) - m1.Get(3) * m1.Get(5)));
+        m2.Set(2, 3, -det * (m1.Get(1) * m1.Get(6) - m1.Get(3) * m1.Get(4)));
+        m2.Set(3, 3,  det * (m1.Get(1) * m1.Get(5) - m1.Get(2) * m1.Get(4)));
+        return;
+        }
+      }
+    }
+    
+  else
+    {
+      int i, j, k, n;
+      n = m1.Height();
+      
+      int dots = (n > 200);
+
+      // Cholesky
+      
+      double x;
+      Vector p(n);
+
+      m2 = m1;
+      m2.SetSymmetric();
+      if (!m2.Symmetric())
+	cerr << "m should be symmetric for Cholesky" << endl;
+
+      for (i = 1; i <= n; i++)
+	for (j = 1; j < i; j++)
+	  m2.Elem(j, i) = m2.Get(i, j);
+      
+      for (i = 1; i <= n; i++)
+	{
+	  if (dots && i % 10 == 0)
+	    cout << "." << flush;
+
+	  for (j = i; j <= n; j++)
+	    {
+	      x = m2.Get(i, j);
+
+	      const double * pik = &m2.Get(i, 1);
+	      const double * pjk = &m2.Get(j, 1);
+
+	      for (k = i-2; k >= 0; --k, ++pik, ++pjk)
+		x -= (*pik) * (*pjk);
+		  
+	      // for (k = i-1; k >= 1; --k)
+	      //   x -= m2.Get(j, k) * m2.Get(i, k);
+
+	      if (i == j)
+		{
+		  if (x <= 0)
+		    {
+		      cerr << "Matrix indefinite" << endl;
+		      return;
+		    }
+		  
+		  p.Elem(i) = 1 / sqrt(x);
+		}
+	      else
+		{
+		  m2.Elem(j, i) = x * p.Get(i);
+		}
+	    }
+	}
+
+      for (i = 1; i <= n; i++)
+	m2.Elem(i, i) = 1 / p.Get(i);
+
+      // calc L^{-1}, store upper triangle
+
+      
+      //      DenseMatrix hm(n);
+      //      hm = m2;
+
+      for (i = 1; i <= n; i++)
+	{
+	  if (dots && i % 10 == 0)
+	    cout << "+" << flush;
+
+	  for (j = i; j <= n; j++)
+	    {
+	      x = 0;
+	      if (j == i) x = 1;
+
+	      const double * pjk = &m2.Get(j, i);
+	      const double * pik = &m2.Get(i, i);
+	      for (k = i; k < j; k++, ++pjk, ++pik)
+		x -= *pik * *pjk;
+
+	      //  for (k = i; k < j; k++)
+	      //  x -= m2.Get(j, k) * m2.Get(i, k);
+
+	      m2.Elem(i, j) = x / m2.Get(j, j);
+	    }
+	}
+      
+      // calc A^-1 = L^-T * L^-1
+
+      for (i = 1; i <= n; i++)
+	{
+	  if (dots && i % 10 == 0)
+	    cout << "-" << flush;
+
+	  for (j = 1; j <= i; j++)
+	    {
+	      x = 0;
+	      k = i;
+	      if (j > i) k = j;
+
+	      const double * pik = &m2.Get(i, k);
+	      const double * pjk = &m2.Get(j, k);
+
+	      for ( ; k <= n; ++k, ++pik, ++pjk)
+		x += *pik * *pjk;
+	      // for (  ; k <= n; k++)
+	      //   x += m2.Get(i, k) * m2.Get(j, k);
+	      
+	      m2.Elem(i, j) = x;
+	    }
+	}
+	  
+      for (i = 1; i <= n; i++)
+	for (j = 1; j < i; j++)
+	  m2.Elem(j, i) = m2.Get(i, j);
+      
+      if (dots) cout << endl;
+
+    /*
+
+      Gauss - Jordan - algorithm
+
+    int r, hi;
+    double max, hr;
+
+
+    ARRAY<int> p(n);   // pivot-permutation
+    Vector hv(n);
+    
+
+    m2 = m1;
+
+    if (m2.Symmetric())
+      for (i = 1; i <= n; i++)
+	for (j = 1; j < i; j++)
+	  m2.Elem(j, i) = m2.Get(i, j);
+
+
+    // Algorithm of Stoer, Einf. i. d. Num. Math, S 145
+
+    for (j = 1; j <= n; j++)
+      p.Set(j, j);
+    
+    for (j = 1; j <= n; j++)
+      {
+	// pivot search
+	
+	max = fabs(m2.Get(j, j));
+	r = j;
+
+	for (i = j+1; i <= n ;i++)
+	  if (fabs (m2.Get(i, j)) > max)
+	    {
+	      r = i;
+	      max = fabs (m2.Get(i, j));
+	    }
+
+	if (max < 1e-20)
+	  {
+	    cerr << "Inverse matrix: matrix singular" << endl;
+	    return;
+	  }
+
+	r = j;
+
+	// exchange rows
+	if (r > j)
+	  {
+	    for (k = 1; k <= n; k++)
+	      {
+		hr = m2.Get(j, k);
+		m2.Elem(j, k) = m2.Get(r, k);
+		m2.Elem(r, k) = hr;
+	      }
+	    hi = p.Get(j);
+	    p.Elem(j) = p.Get(r);
+	    p.Elem(r) = hi;
+	  }
+	  
+
+	// transformation
+	
+	hr = 1 / m2.Get(j, j);
+	for (i = 1; i <= n; i++)
+	  m2.Elem(i, j) *= hr;
+	m2.Elem(j, j) = hr;
+
+	for (k = 1; k <= n; k++)
+	  if (k != j)
+	    {
+	      for (i = 1; i <= n; i++)
+		if (i != j)
+		  m2.Elem(i, k) -= m2.Elem(i, j) * m2.Elem(j, k);
+	      m2.Elem(j, k) *= -hr;
+	    }
+      }
+
+    // col exchange
+    
+    for (i = 1; i <= n; i++)
+      {
+	for (k = 1; k <= n; k++)
+	  hv.Elem(p.Get(k)) = m2.Get(i, k);
+	for (k = 1; k <= n; k++)
+	  m2.Elem(i, k) = hv.Get(k);
+      }
+      
+      */
+
+
+
+
+
+    /*
+    if (m1.Symmetric())
+      for (i = 1; i <= n; i++)
+	for (j = 1; j < i; j++)
+	  m1.Elem(j, i) = m1.Get(i, j);
+
+    m2 = 0;
+    
+    for (i = 1; i <= n; i++)
+      m2.Elem(i, i) = 1;
+      
+    for (i = 1; i <= n; i++)
+      {
+	//	cout << '.' << flush;
+      q = m1.Get(i, i);
+      for (k = 1; k <= n; k++)
+        {
+        m1.Elem(i, k) /= q;
+        m2.Elem(i, k) /= q;
+        }
+        
+      for (j = i+1; j <= n; j++)
+        {
+        q = m1.Elem(j, i);
+
+	double * m1pi = &m1.Elem(i, i);
+	double * m1pj = &m1.Elem(j, i);
+
+	for (k = n; k >= i; --k, ++m1pi, ++m1pj)
+	    *m1pj -= q * (*m1pi);
+
+	double * m2pi = &m2.Elem(i, 1);
+	double * m2pj = &m2.Elem(j, 1);
+
+	for (k = i; k > 0; --k, ++m2pi, ++m2pj)
+	    *m2pj -= q * (*m2pi);
+
+	    //        for (k = 1; k <= n; k++)  
+	    //          {
+	    //          m1.Elem(j, k) -= q * m1.Elem(i, k);
+	    //          m2.Elem(j, k) -= q * m2.Elem(i, k);
+	    //          }
+	  
+        }
+      }  
+            
+    for (i = n; i >= 1; i--)
+      {
+	//	cout << "+" << flush;
+	for (j = 1; j < i; j++)
+	  {
+	    q = m1.Elem(j, i);
+
+	    double * m2pi = &m2.Elem(i, 1);
+	    double * m2pj = &m2.Elem(j, 1);
+
+	    for (k = n; k > 0; --k, ++m2pi, ++m2pj)
+	      *m2pj -= q * (*m2pi);	    
+
+	    
+	    //	    for (k = 1; k <= n; k++)
+	    //	      {
+	    //		m1.Elem(j, k) -= q * m1.Elem(i, k);
+	    //		m2.Elem(j, k) -= q * m2.Elem(i, k);
+	    //	      }    
+	  }         
+      }
+
+    if (m2.Symmetric())
+      {
+	for (i = 1; i <= n; i++)
+	  for (j = 1; j < i; j++)
+	    m2.Elem(i, j) = m2.Elem(j, i);
+      }
+*/
+    }
+  }
+
+
+void CalcAAt (const DenseMatrix & a, DenseMatrix & m2)
+  {
+  INDEX n1 = a.Height();
+  INDEX n2 = a.Width();
+  INDEX i, j, k;
+  double sum;
+  const double *p, *q, *p0;
+
+  if (m2.Height() != n1 || m2.Width() != n1)
+    {
+//    myerr << "CalcAAt: sizes don't fit" << endl;
+    return;
+    }
+
+  for (i = 1; i <= n1; i++)
+    {
+    sum = 0;
+    p = &a.ConstElem(i, 1);
+    for (k = 1; k <= n2; k++)
+      {
+      sum += *p * *p;
+      p++;
+      }
+    m2.Set(i, i, sum);
+
+    p0 = &a.ConstElem(i, 1);
+    q = a.data;
+    for (j = 1; j < i; j++)
+      {
+      sum = 0;
+      p = p0;
+
+      for (k = 1; k <= n2; k++)
+        {
+        sum += *p * *q;
+        p++;
+        q++;
+        }
+      m2.Set(i, j, sum);
+      m2.Set(j, i, sum);
+      }
+    }
+  }
+
+
+
+
+BaseMatrix * DenseMatrix :: InverseMatrix (const BitArray * /* inner */) const
+{
+  if (Height() != Width())
+    {
+//      myerr << "BaseMatrix::InverseMatrix(): Matrix not symmetric" << endl;
+      return new DenseMatrix(1);
+    }
+  else
+    {
+      if (Symmetric())
+	{	
+//	  cout << "Invmat not available" << endl;
+	  BaseMatrix * invmat = NULL;
+	  return invmat;
+	}
+
+      DenseMatrix * invmat = new DenseMatrix (Height());
+
+      CalcInverse (*this, *invmat);
+      return invmat;
+    }
+}
+
+
+
+
+void CalcAtA (const DenseMatrix & a, DenseMatrix & m2)
+  {
+  INDEX n1 = a.Height();
+  INDEX n2 = a.Width();
+  INDEX i, j, k;
+  double sum;
+
+  if (m2.Height() != n2 || m2.Width() != n2)
+    {
+//    myerr << "CalcAtA: sizes don't fit" << endl;
+    return;
+    }
+
+  for (i = 1; i <= n2; i++)
+    for (j = 1; j <= n2; j++)
+      {
+      sum = 0;
+      for (k = 1; k <= n1; k++)
+        sum += a.Get(k, i) * a.Get(k, j);
+      m2(i, j) = sum;
+      }
+  }
+
+
+
+
+
+
+void CalcABt (const DenseMatrix & a, const DenseMatrix & b, DenseMatrix & m2)
+  {
+  INDEX n1 = a.Height();
+  INDEX n2 = a.Width();
+  INDEX n3 = b.Height();
+  INDEX i, j, k;
+  double sum;
+
+  if (m2.Height() != n1 || m2.Width() != n3 || b.Width() != n2)
+    {
+//    myerr << "CalcABt: sizes don't fit" << endl;
+    return;
+    }
+
+  double * pm2 = &m2.Elem(1, 1);
+  const double * pa1 = &a.Get(1, 1);
+
+  for (i = 1; i <= n1; i++)
+    {
+      const double * pb = &b.Get(1, 1);
+      for (j = 1; j <= n3; j++)
+	{
+	  sum = 0;
+	  const double * pa = pa1;
+	  
+	  for (k = 1; k <= n2; k++)
+	    {
+	      sum += *pa * *pb;
+	      pa++; pb++;
+	    }
+	  
+	  *pm2 = sum;
+	  pm2++;
+	}
+      pa1 += n2;
+    }
+  }
+
+
+void CalcAtB (const DenseMatrix & a, const DenseMatrix & b, DenseMatrix & m2)
+  {
+  INDEX n1 = a.Height();
+  INDEX n2 = a.Width();
+  INDEX n3 = b.Width();
+  INDEX i, j, k;
+
+  if (m2.Height() != n2 || m2.Width() != n3 || b.Height() != n1)
+    {
+//    myerr << "CalcAtB: sizes don't fit" << endl;
+    return;
+    }
+
+  for (i = 1; i <= n2 * n3; i++)
+    m2.data[i-1] = 0;
+
+  for (i = 1; i <= n1; i++)
+    for (j = 1; j <= n2; j++)
+      {
+	const double va = a.Get(i, j);
+	double * pm2 = &m2.Elem(j, 1);
+	const double * pb = &b.Get(i, 1);
+
+	for (k = 1; k <= n3; ++k, ++pm2, ++pb)
+	  *pm2 += va * *pb;
+	//	for (k = 1; k <= n3; k++)
+	//	  m2.Elem(j, k) += va * b.Get(i, k);
+      }
+  /*
+  for (i = 1; i <= n2; i++)
+    for (j = 1; j <= n3; j++)
+      {
+	sum = 0;
+	for (k = 1; k <= n1; k++)
+	  sum += a.Get(k, i) * b.Get(k, j);
+	m2.Elem(i, j) = sum;
+      }
+      */
+  }
+
+
+
+
+
+
+
+DenseMatrix operator* (const DenseMatrix & m1, const DenseMatrix & m2)
+  {
+  DenseMatrix temp (m1.Height(), m2.Width());
+
+  if (m1.Width() != m2.Height())
+    {
+//    myerr << "DenseMatrix :: operator*: Matrix Size does not fit" << endl;
+		;
+    }
+  else if (temp.Height() != m1.Height())
+    {
+//    myerr << "DenseMatrix :: operator*: temp not allocated" << endl;
+		;
+    }
+  else
+    {
+    Mult (m1, m2, temp);
+    }
+  return temp;
+  }
+
+
+void Mult (const DenseMatrix & m1, const DenseMatrix & m2, DenseMatrix & m3)
+  {
+  double sum;
+  double *p1, *p1s, *p1sn, *p1snn, *p2, *p2s, *p2sn, *p3;
+
+  if (m1.Width() != m2.Height() || m1.Height() != m3.Height() ||
+       m2.Width() != m3.Width() )
+    {
+//    myerr << "DenseMatrix :: Mult: Matrix Size does not fit" << endl;
+//    myerr << "m1: " << m1.Height() << " x " << m1.Width() << endl;
+//    myerr << "m2: " << m2.Height() << " x " << m2.Width() << endl;
+//    myerr << "m3: " << m3.Height() << " x " << m3.Width() << endl;
+    return;
+    }
+  else if (m1.Symmetric() || m2.Symmetric() || m3.Symmetric())
+    {
+//    myerr << "DenseMatrix :: Mult: not implemented for symmetric matrices" << endl;
+    return;
+    }
+  else
+    {
+      //      int i, j, k;
+      int n1 = m1.Height();
+      int n2 = m2.Width();
+      int n3 = m1.Width();
+
+      /*
+      for (i = n1 * n2-1; i >= 0; --i)
+	m3.data[i] = 0;
+
+      const double * pm1 = &m1.Get(1, 1);
+      for (i = 1; i <= n1; i++)
+	{
+	  const double * pm2 = &m2.Get(1, 1);
+	  double * pm3i = &m3.Elem(i, 1);
+
+	  for (j = 1; j <= n3; j++)
+	    {
+	      const double vm1 = *pm1;
+	      ++pm1;
+	      //	      const double vm1 = m1.Get(i, j);
+	      double * pm3 = pm3i;
+	      //	      const double * pm2 = &m2.Get(j, 1);
+
+	      for (k = 0; k < n2; k++)
+		{
+		  *pm3 += vm1 * *pm2;
+		  ++pm2;
+		  ++pm3;
+		}
+
+	    //	    for (k = 1; k <= n2; k++)
+	    //	      m3.Elem(i, k) += m1.Get(i, j) * m2.Get(j, k);
+	    }
+	}
+	*/
+
+      /*
+      for (i = 1; i <= n1; i++)
+	for (j = 1; j <= n2; j++)
+	  {
+	    sum = 0;
+	    for (k = 1; k <= n3; k++)
+	      sum += m1.Get(i, k) * m2.Get(k, j);
+	    m3.Set(i, j, sum);
+	  }
+	  */
+
+
+      /*
+      for (i = 1; i <= n1; i++)
+	{
+	  const double pm1i = &m1.Get(i, 1);
+	  const double pm2j = &m2.Get(1, 1);
+
+	  for (j = 1; j <= n2; j++)
+	    {
+	      double sum = 0;
+	      const double * pm1 = pm1i;
+	      const double * pm2 = pm2j;
+	      pm2j++;
+
+	      for (k = 1; k <= n3; k++)
+		{
+		  sum += *pm1 * *pm2;
+		  ++pm1;
+		  pm2 += n2;
+		}
+	      
+	      m3.Set (i, j, sum);
+	    }
+	}
+	*/
+
+
+      p3 = m3.data;
+      p1s = m1.data;
+      p2sn = m2.data + n2;
+      p1snn = p1s + n1 * n3;
+
+      while (p1s != p1snn)
+	{
+	  p1sn = p1s + n3;
+	  p2s = m2.data;
+	  
+	  while (p2s != p2sn)
+	    {
+	      sum = 0;
+	      p1 = p1s;
+	      p2 = p2s;
+	      p2s++;
+
+	      while (p1 != p1sn)
+		{
+		  sum += *p1 * *p2;
+		  p1++;
+		  p2 += n2;
+		}
+	      *p3++ = sum;
+	    }
+	  p1s = p1sn;
+	}
+    }
+  }  
+
+
+
+DenseMatrix operator+ (const DenseMatrix & m1, const DenseMatrix & m2)
+  {
+  DenseMatrix temp (m1.Height(), m1.Width());
+  INDEX i, j;
+
+  if (m1.Width() != m2.Width() || m1.Height() != m2.Height())
+    {
+//    myerr << "BaseMatrix :: operator+: Matrix Size does not fit" << endl;
+		;
+    }
+  else if (temp.Height() != m1.Height())
+    {
+//    myerr << "BaseMatrix :: operator+: temp not allocated" << endl;
+		;
+    }
+  else
+    {
+    for (i = 1; i <= m1.Height(); i++)
+      for (j = 1; j <= m1.Width(); j++)
+        {
+        temp.Set(i, j, m1.Get(i, j) + m2.Get(i, j));
+        }
+    }
+  return temp;
+  }
+
+
+
+
+void Transpose (const DenseMatrix & m1, DenseMatrix & m2)
+{
+  int w = m1.Width();
+  int h = m1.Height();
+  int i, j;
+
+  m2.SetSize (w, h);
+
+  double * pm2 = &m2.Elem(1, 1);
+  for (j = 1; j <= w; j++)
+    {
+      const double * pm1 = &m1.Get(1, j);
+      for (i = 1; i <= h; i++)
+	{
+	  *pm2 = *pm1;
+	  pm2 ++;
+	  pm1 += w;
+	}
+    }
+}
+
+
+
+void DenseMatrix :: Mult (const BaseVector & bv, BaseVector & bprod) const
+  {
+  double sum, val;
+  const double * mp, * sp;
+  double * dp;
+  const Vector & v = bv.CastToVector();
+  Vector & prod = bprod.CastToVector();
+  
+
+  int n = Height();
+  int m = Width();
+
+  if (prod.Length() != n)
+    prod.SetLength (n);
+
+  if (m != v.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit" << endl;
+		;
+   }
+  else if (Height() != prod.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+		;
+    }
+  else
+    {
+      if (Symmetric())
+	{
+	  INDEX i, j;
+
+
+	  for (i = 1; i <= n; i++)
+	    {
+	      sp = &v.Get(1);
+	      dp = &prod.Elem(1);
+	      mp = &Get(i, 1);
+
+	      val = v.Get(i);
+	      sum = Get(i, i) * val;
+
+	      for (j = 1; j < i; ++j, ++mp, ++sp, ++dp)
+		{
+		  sum += *mp * *sp;
+		  *dp += val * *mp;
+		}
+
+	      prod.Elem(i) = sum;
+	    }
+	}
+      else
+	{
+	  mp = data;
+	  dp = &prod.Elem(1);
+	  for (INDEX i = 1; i <= n; i++)
+	    {
+	      sum = 0;
+	      sp = &v.Get(1);
+	      
+	      for (INDEX j = 1; j <= m; j++)
+		{
+		  //        sum += Get(i,j) * v.Get(j);
+		  sum += *mp * *sp;
+		  mp++;
+		  sp++;
+		}
+	      
+	      //      prod.Set (i, sum);
+	      *dp = sum;
+	      dp++;
+	    }
+	}
+    }
+  }
+
+
+void DenseMatrix :: MultTrans (const BaseVector & bv, BaseVector & bprod) const
+{
+  const Vector & v = (const Vector&)bv; // .CastToVector();
+  Vector & prod = (Vector & )bprod;     // .CastToVector();
+
+  /*
+  if (Height() != v.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit" << endl;
+    }
+  else if (Width() != prod.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+    }
+  else
+  */
+    {
+      int i, j;
+      int w = Width(), h = Height();
+      if (prod.Length() != w)
+	prod.SetLength (w);
+
+      const double * pmat = &Get(1, 1);
+      const double * pv = &v.Get(1);
+
+      prod = 0;
+
+      for (i = 1; i <= h; i++)
+	{
+	  double val = *pv;
+	  ++pv;
+
+	  double * pprod = &prod.Elem(1);
+
+	  for (j = w-1; j >= 0; --j, ++pmat, ++pprod)
+	    {
+	      *pprod += val * *pmat;
+	    }
+	}
+	
+      /*
+      double sum;
+
+      for (i = 1; i <= Width(); i++)
+	{
+	  sum = 0;
+	  
+	  for (INDEX j = 1; j <= Height(); j++)
+	    sum += Get(j, i) * v.Get(j);
+	  
+	  prod.Set (i, sum);
+	}
+      */
+    }
+  }
+
+
+void DenseMatrix :: Residuum (const BaseVector & bx, const BaseVector & bb,
+      BaseVector & bres) const
+  {
+  double sum;
+  const Vector & x = bx.CastToVector();
+  const Vector & b = bb.CastToVector();
+  Vector & res = bres.CastToVector();
+
+  res.SetLength (Height());
+
+  if (Width() != x.Length() || Height() != b.Length())
+    {
+//    myerr << "\nMatrix and Vector don't fit" << endl;
+		;
+    }
+  else if (Height() != res.Length())
+    {
+//    myerr << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
+		;
+    }
+  else
+    {
+      int i, j;
+      int h = Height(); 
+      int w = Width();
+      const double * mp = &Get(1, 1);
+
+      for (i = 1; i <= h; i++)
+	{
+	  sum = b.Get(i);
+	  const double * xp = &x.Get(1);
+
+	  for (j = 1; j <= w; ++j, ++mp, ++xp)
+	    sum -= *mp * *xp;
+	  
+	  res.Set (i, sum);
+	}
+    }
+  }
+
+double DenseMatrix :: EvaluateBilinearform (const BaseVector & x) const
+  {
+  double sum = 0, hsum;
+  const Vector & hx = x.CastToVector();
+  INDEX i, j;
+
+  if (Width() != hx.Length() || Height() != hx.Length())
+    {
+//    myerr << "Matrix::EvaluateBilinearForm: sizes don't fit" << endl;
+		;
+    }
+  else
+    {
+    for (i = 1; i <= Height(); i++)
+      {
+      hsum = 0;
+      for (j = 1; j <= Height(); j++)
+        {
+        hsum += Get(i, j) * hx.Get(j);
+        }
+      sum += hsum * hx.Get(i);
+      }
+    }
+
+  return sum;
+  }
+
+
+void DenseMatrix :: MultElementMatrix (const ARRAY<INDEX> & pnum, 
+      const BaseVector & x, BaseVector & y)
+  {
+  int i, j;
+  const Vector & hx = x.CastToVector();
+  Vector & hy = y.CastToVector();
+
+  if (Symmetric())
+    {
+    for (i = 1; i <= Height(); i++)
+      {
+      for (j = 1; j < i; j++)
+        {
+	hy.Elem(pnum.Get(i)) += Get(i, j) * hx.Get(pnum.Get(j));
+	hy.Elem(pnum.Get(j)) += Get(i, j) * hx.Get(pnum.Get(i));
+	}
+      hy.Elem(pnum.Get(j)) += Get(i, i) * hx.Get(pnum.Get(i));	
+      }
+    }
+  else
+    for (i = 1; i <= Height(); i++)
+      for (j = 1; j <= Width(); j++)
+	hy.Elem(pnum.Get(i)) += Get(i, j) * hx.Get(pnum.Get(j));
+    
+  }
+  
+void DenseMatrix :: MultTransElementMatrix (const ARRAY<INDEX> & pnum, 
+      const BaseVector & x, BaseVector & y)
+  {
+  int i, j;
+  const Vector & hx = x.CastToVector();
+  Vector & hy = y.CastToVector();
+
+  if (Symmetric())
+    MultElementMatrix (pnum, x, y);
+  else
+    for (i = 1; i <= Height(); i++)
+      for (j = 1; j <= Width(); j++)
+	hy.Elem(pnum.Get(i)) += Get(j, i) * hx.Get(pnum.Get(j));
+  }
+
+
+
+void DenseMatrix :: SolveDestroy (const Vector & v, Vector & sol)
+  {
+  double q;
+
+  if (Width() != Height())
+    {
+//    myerr << "SolveDestroy: Matrix not square";
+    return;
+    }
+  if (Width() != v.Length())
+    {
+//    myerr << "SolveDestroy: Matrix and Vector don't fit";
+    return;
+    }
+
+  sol = v;
+  if (Height() != sol.Length())
+    {
+//    myerr << "SolveDestroy: Solution Vector not ok";
+    return;
+    }
+
+
+  if (0 /* Symmetric() */)
+    {
+      
+      // Cholesky factorization
+
+      int i, j, k, n;
+      n = Height();
+      
+      // Cholesky
+      
+      double x;
+      Vector p(n);
+
+      for (i = 1; i <= n; i++)
+	for (j = 1; j < i; j++)
+	  Elem(j, i) = Get(i, j);
+      
+      for (i = 1; i <= n; i++)
+	{
+	  // cout << "." << flush;
+	  for (j = i; j <= n; j++)
+	    {
+	      x = Get(i, j);
+
+	      const double * pik = &Get(i, 1);
+	      const double * pjk = &Get(j, 1);
+
+	      for (k = i-2; k >= 0; --k, ++pik, ++pjk)
+		x -= (*pik) * (*pjk);
+		  
+	      // for (k = i-1; k >= 1; --k)
+	      //   x -= Get(j, k) * Get(i, k);
+
+	      if (i == j)
+		{
+		  if (x <= 0)
+		    {
+		      cerr << "Matrix indefinite" << endl;
+		      return;
+		    }
+		  
+		  p.Elem(i) = 1 / sqrt(x);
+		}
+	      else
+		{
+		  Elem(j, i) = x * p.Get(i);
+		}
+	    }
+	}
+
+      for (i = 1; i <= n; i++)
+        Elem(i, i) = 1 / p.Get(i);
+
+      // A = L L^t 
+      // L stored in left-lower triangle
+
+
+      sol = v;
+
+      // Solve L sol = sol
+
+      for (i = 1; i <= n; i++)
+	{
+	  double val = sol.Get(i);
+
+	  const double * pij = &Get(i, 1);
+	  const double * solj = &sol.Get(1);
+
+	  for (j = 1; j < i; j++, ++pij, ++solj)
+	    val -= *pij * *solj;
+	  //	  for (j = 1; j < i; j++)
+	  //	    val -= Get(i, j) * sol.Get(j);
+
+	  sol.Elem(i) = val / Get(i, i);
+	}
+
+      // Solve L^t sol = sol
+
+      for (i = n; i >= 1; i--)
+	{
+	  double val = sol.Get(i) / Get(i, i);
+	  sol.Elem(i) = val;
+
+	  double * solj = &sol.Elem(1);
+	  const double * pij = &Get(i, 1);
+
+	  for (j = 1; j < i; ++j, ++pij, ++solj)
+	    *solj -= val * *pij;
+	  //	  for (j = 1; j < i; j++)
+	  //	    sol.Elem(j) -= Get(i, j) * val;
+	}
+
+
+    }
+  else
+    {
+      //      cout << "gauss" << endl;
+      int i, j, k, n = Height();
+      for (i = 1; i <= n; i++)
+	{
+	  for (j = i+1; j <= n; j++)
+	    {
+	      q = Get(j,i) / Get(i,i);
+	      if (q)
+		{
+		  const double * pik = &Get(i, i+1);
+		  double * pjk = &Elem(j, i+1);
+
+		  for (k = i+1; k <= n; ++k, ++pik, ++pjk)
+		    *pjk -= q * *pik;
+		  
+		  //  for (k = i+1; k <= Height(); k++)
+		  //	Elem(j, k) -= q * Get(i,k);
+
+
+		  sol.Elem(j) -= q * sol.Get(i);
+		}
+	    }
+	}
+      
+      for (i = n; i >= 1; i--)
+	{
+	  q = sol.Get(i);
+	  for (j = i+1; j <= n; j++)
+	      q -= Get(i,j) * sol.Get(j);
+
+	  sol.Set(i, q / Get(i,i));
+	}
+    }
+  }
+
+
+BaseMatrix * DenseMatrix :: Copy () const
+  {
+  return new DenseMatrix (*this);
+  }
diff -ruN ug-orig/gm/gg3/netgen/linalg/densemat.hh ug-patched/gm/gg3/netgen/linalg/densemat.hh
--- ug-orig/gm/gg3/netgen/linalg/densemat.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/densemat.hh	1998-03-18 19:05:16.000000000 +0100
@@ -0,0 +1,124 @@
+#ifndef FILE_DENSEMAT
+#define FILE_DENSEMAT
+
+/**************************************************************************/
+/* File:   densemat.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Oct. 94                                                    */
+/**************************************************************************/
+
+/** 
+   Data type dense matrix
+*/
+
+
+
+class DenseMatrix : public BaseMatrix
+  {
+protected:
+  ///
+  double * data;
+
+public:
+  ///
+  DenseMatrix ();
+  ///
+  DenseMatrix (INDEX h, INDEX w = 0);
+  ///
+  DenseMatrix (INDEX h, INDEX w, const double * d);
+  ///
+  DenseMatrix (const DenseMatrix & m2);
+  ///
+  DenseMatrix (const BaseMatrix & m2);
+  ///
+  ~DenseMatrix ();
+
+  ///
+  virtual void SetSize (INDEX h, INDEX w = 0);
+
+
+  ///
+  virtual double & operator() (INDEX i, INDEX j);
+  ///
+  virtual double operator() (INDEX i, INDEX j) const;
+
+  ///
+  DenseMatrix & operator= (const BaseMatrix & m2);
+  ///
+  DenseMatrix & operator= (const DenseMatrix & m2);
+
+  ///
+  DenseMatrix & operator+= (const DenseMatrix & m2);
+  ///
+  DenseMatrix & operator-= (const DenseMatrix & m2);
+
+  ///
+  DenseMatrix & operator= (double v);
+  ///
+  DenseMatrix & operator*= (double v);
+
+  ///
+  virtual void Mult (const BaseVector & v, BaseVector & prod) const;
+  ///
+  virtual void MultTrans (const BaseVector & v, BaseVector & prod) const;
+  ///
+  virtual void Residuum (const BaseVector & x, const BaseVector & b, BaseVector & res) const;
+  ///
+  virtual double EvaluateBilinearform (const BaseVector & x) const;
+
+  ///
+  virtual BaseMatrix * Copy () const;
+
+  ///
+  virtual void MultElementMatrix (const ARRAY<INDEX> & pnum, 
+      const BaseVector & x, BaseVector & y);
+  ///
+  virtual void MultTransElementMatrix (const ARRAY<INDEX> & pnum, 
+      const BaseVector & x, BaseVector & y);
+
+
+  ///
+  double Det () const;
+
+  ///
+  friend DenseMatrix operator* (const DenseMatrix & m1, const DenseMatrix & m2);
+  ///
+  friend DenseMatrix operator+ (const DenseMatrix & m1, const DenseMatrix & m2);
+
+    /// 
+    friend void Transpose (const DenseMatrix & m1, DenseMatrix & m2);
+  ///
+  friend void Mult (const DenseMatrix & m1, const DenseMatrix & m2, DenseMatrix & m3);
+  ///
+  friend void CalcInverse (const DenseMatrix & m1, DenseMatrix & m2);
+  ///
+  friend void CalcAAt (const DenseMatrix & a, DenseMatrix & m2);
+  ///
+  friend void CalcAtA (const DenseMatrix & a, DenseMatrix & m2);
+  ///
+  friend void CalcABt (const DenseMatrix & a, const DenseMatrix & b, DenseMatrix & m2);
+  ///
+  friend void CalcAtB (const DenseMatrix & a, const DenseMatrix & b, DenseMatrix & m2);
+  ///
+  virtual void SolveDestroy (const Vector & b, Vector & x);
+
+    ///
+    virtual BaseMatrix * InverseMatrix (const class BitArray * inner = NULL)
+      const;
+
+
+  ///
+  const double & Get(INDEX i, INDEX j) const { return data[(i-1)*width+j-1]; }
+  ///
+  const double & Get(INDEX i) const { return data[i-1]; }
+  ///
+  void Set(INDEX i, INDEX j, double v) { data[(i-1)*width+j-1] = v; }
+  ///
+  double & Elem(INDEX i, INDEX j) { return data[(i-1)*width+j-1]; }
+  ///
+  const double & ConstElem(INDEX i, INDEX j) const { return data[(i-1)*width+j-1]; }
+  };
+
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/iterativ.cc ug-patched/gm/gg3/netgen/linalg/iterativ.cc
--- ug-orig/gm/gg3/netgen/linalg/iterativ.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/iterativ.cc	1996-03-29 18:25:49.000000000 +0100
@@ -0,0 +1,1611 @@
+/************************************************************************/
+/*                                                                      */
+/* This file is a part of NETGEN                                        */
+/*                                                                      */
+/* File:   iterativ.cc                                                  */
+/* Author: Joachim Schoeberl                                            */
+/*                                                                      */
+/************************************************************************/
+
+
+
+/* Iterative Solvers */
+
+#include <stdlib.h>
+
+#include <fstream.h>
+
+#include <math.h>
+
+#include <limits.h>
+
+
+
+#include <template.hh>
+
+#include <array.hh>
+
+#include <bitarray.hh>
+
+
+
+#include <linalg/linalg.hh>
+
+
+
+
+
+ofstream itfile ("iterativ.out");
+
+
+
+extern void MyError (char * ch);
+
+
+
+extern void IterationDone (int it, double err);
+
+
+
+
+
+
+
+VECTOR BASE_MATRIX :: Jacobi (const VECTOR & b, float eps) const
+
+  {
+
+  VECTOR x(b.Length());
+
+  VECTOR r(b.Length());
+
+  INDEX i, n = 0;
+
+  float res = 2 * eps;
+
+  double c = 0;
+
+
+
+  for (i = 1; i <= Height(); i++)
+
+    if ((*this)(i, i) > c) c = (*this)(i, i);
+
+
+
+  c = 1/c;
+
+  x = 0;
+
+
+
+  while (n++ < 10000 && res > eps)
+
+    {
+
+    (*this).Residuum (x, b, r);
+
+    x.Add (c, r);
+
+    res = r.L2Norm() / sqrt (x.Length());
+
+//    if (! (n % 50)) itfile << "n = " << n << " res = " << res << endl;
+
+    }
+
+
+
+  return x;
+
+  }
+
+
+
+/*
+
+void BASE_MATRIX :: CG (const BASE_VECTOR & b, BASE_VECTOR & x, float eps) const
+
+  {
+
+  const INDEX len = b.Length();
+
+  VECTOR r(len), p(len), h(len);
+
+  INDEX n = 0;
+
+  double res, lam, hd;
+
+
+
+  VECTOR & hx = x.CastToVector ();
+
+  hx.SetLength (Width());
+
+
+
+  hx = 0;
+
+  p = r = b;
+
+  eps *= b.L2Norm();
+
+  res = 2 * eps;
+
+
+
+//  itfile << "this = " << (*this) << endl;
+
+//  itfile << "x = " << x << endl;
+
+//  itfile << "b = " << b << endl;
+
+
+
+
+
+  while (n++ < 50000 && res > eps)
+
+    {
+
+    (*this).Mult (p, h);
+
+
+
+    hd = h * p;
+
+    if (!hd) break;
+
+    lam = (r * p) / hd;
+
+
+
+    hx.Add (lam, p);
+
+    r.Add (-lam, h);
+
+    p.Set (1, r, -(r*h) / hd, p);
+
+//    p = r - (r*h) / hd * p;
+
+    res = r.L2Norm();
+
+//    res = lam;
+
+
+
+//    itfile << "n = " << n << " res = " << res << " hd = " << hd << endl;
+
+
+
+//    if (n % 1000 == 0)
+
+//      cout << "n = " << n << " res = " << res << endl;
+
+//    itfile << "n = " << n << " res = " << res << "hd = " << hd
+
+//           << "lam = " << lam << endl;
+
+    }
+
+  itfile << n << " its" << endl;
+
+  itfile << "err = " << res << endl;
+
+  }
+
+*/
+
+
+
+
+
+void BASE_MATRIX :: CG (const BASE_VECTOR & b, BASE_VECTOR & x, float eps) const
+
+  {
+
+  BASE_VECTOR & d = *b.Copy();
+
+  BASE_VECTOR & w = *b.Copy();
+
+  BASE_VECTOR & s = *b.Copy();
+
+  BASE_VECTOR & ks = *b.Copy();
+
+
+
+  INDEX n = 0;
+
+  double al, be, wd, wdn, kss;
+
+
+
+  x = 0;
+
+  d = b;
+
+  w = d;
+
+//  pre.Mult (d, w);
+
+  s = w;
+
+
+
+  eps = eps*eps;
+
+  wdn = w * d;
+
+  while (n++ < 10000 && wdn > eps)
+
+    {
+
+    (*this).Mult (s, ks);
+
+
+
+    wd = wdn;
+
+    kss = ks * s;
+
+
+
+    if (!kss) break;
+
+
+
+    al = wd / kss;
+
+
+
+    x.Add (al, s);
+
+    d.Add (-al, ks);
+
+
+
+//    pre.Mult (d, w);
+
+    w = d;
+
+
+
+    wdn = w * d;
+
+    be = wdn / wd;
+
+
+
+    s *= be;
+
+    s.Add (1, w);
+
+
+
+//    itfile << n << " " << wdn << endl;
+
+    }
+
+//  itfile << "CG: " << n << " Iterations" << endl;
+
+
+
+  d.~BASE_VECTOR();
+
+  w.~BASE_VECTOR();
+
+  s.~BASE_VECTOR();
+
+  ks.~BASE_VECTOR();
+
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+VECTOR BASE_MATRIX :: CG (const VECTOR & b, float eps) const
+
+  {
+
+  const INDEX len = b.Length();
+
+  VECTOR r(len), p(len), x(len), h(len);
+
+  INDEX n = 0;
+
+  double res, lam, hd;
+
+
+
+  x = 0;
+
+  p = r = b;
+
+  eps *= b.L2Norm();
+
+  res = 2 * eps;
+
+
+
+  while (n++ < 1000 && res > eps)
+
+    {
+
+    (*this).Mult (p, h);
+
+
+
+    hd = h * p;
+
+    if (!hd) break;
+
+    lam = (r * p) / hd;
+
+
+
+    x.Add (lam, p);
+
+    r.Add (-lam, h);
+
+    p = r - (r*h) / hd * p;
+
+
+
+    res = r.L2Norm();
+
+    itfile << "n = " << n << " res = " << res << endl;
+
+    }
+
+
+
+  return x;
+
+  }
+
+
+
+
+
+
+
+
+
+void BASE_MATRIX :: PCG (const BASE_MATRIX & pre, const VECTOR & f, VECTOR & u,
+
+                         float eps) const
+
+  {
+
+  const INDEX len = f.Length();
+
+  VECTOR d(len), w(len), s(len), ks(len);
+
+  INDEX n = 0;
+
+  double al, be, wd, wdn, kss;
+
+
+
+  u = 0;
+
+  d = f;
+
+  pre.Mult (d, w);
+
+  s = w;
+
+
+
+  wdn = w * d;
+
+  eps = eps*eps * wdn + 1e-20;
+
+
+
+  while (n++ < 10000 && wdn > eps)
+
+    {
+
+    (*this).Mult (s, ks);
+
+
+
+    wd = wdn;
+
+    kss = ks * s;
+
+
+
+//    itfile << "wdn = " << wdn << "  kss = " << kss << endl;
+
+
+
+    if (!kss) break;
+
+
+
+    al = wd / kss;
+
+
+
+    u.Add (al, s);
+
+    d.Add (-al, ks);
+
+
+
+    pre.Mult (d, w);
+
+
+
+    wdn = w * d;
+
+    be = wdn / wd;
+
+
+
+    s *= be;
+
+    s.Add (1, w);
+
+
+
+//    cout << n << " " << wdn << endl;
+
+    }
+
+  itfile << "PCG: " << n << " Iterations" << endl;
+
+  }
+
+
+
+
+
+
+
+
+
+void SPARSE_MATRIX :: GSStep (const VECTOR & b, VECTOR & x, double dump) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+
+
+  n = Height();
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStep: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    for (i = 1; i <= n; i++)
+
+      {
+
+      lin = &lins.Get(i);
+
+      sum = b.Get(i);
+
+      col = lin->col;
+
+      diag = 1;
+
+
+
+      for (j = lin->size; j > 0; j--, col++)
+
+        {
+
+        sum -= col->data * x.Get(col->colnr);
+
+        if (col->colnr == i) diag = col->data;
+
+        }
+
+
+
+      x.Elem(i) += dump / diag * sum;
+
+      }
+
+    }
+
+  else
+
+    {
+
+    for (i = 1; i <= n; i++)
+
+      {
+
+      lin = &lins.Get(i);
+
+      col = lin->col;
+
+      val = x.Get(i);
+
+
+
+      for (j = lin->size; j > 1; j--, col++)
+
+        x.Elem(col->colnr) -= col->data * val;
+
+
+
+      x.Set(i, b.Get(i));
+
+      }
+
+
+
+    for (i = 1; i <= n; i++)
+
+      {
+
+      lin = &lins.Get(i);
+
+      col = lin->col;
+
+      sum = x.Get(i);
+
+
+
+      for (j = lin->size; j > 1; j--, col++)
+
+        sum -= col->data * x.Get(col->colnr);
+
+
+
+      x.Set(i, sum / col->data);
+
+      }
+
+    }
+
+  }
+
+
+
+void SPARSE_MATRIX :: GSStepBack (const VECTOR & b, VECTOR & x, double dump) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+
+
+  n = Height();
+
+
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStepBack: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      lin = &lins.Get(i);
+
+      sum = b.Get(i);
+
+      col = lin->col;
+
+      diag = 1;
+
+
+
+      for (j = lin->size; j > 0; j--, col++)
+
+        {
+
+        sum -= col->data * x.Get(col->colnr);
+
+        if (col->colnr == i) diag = col->data;
+
+        }
+
+
+
+      x.Elem(i) += dump / diag * sum;
+
+      }
+
+    }
+
+  else
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      lin = &lins.Get(i);
+
+      col = lin->col;
+
+      sum = b.Get(i);
+
+
+
+      for (j = lin->size; j > 1; j--, col++)
+
+        sum -= col->data * x.Get(col->colnr);
+
+
+
+      x.Set(i, sum);
+
+      }
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      lin = &lins.Get(i);
+
+      col = lin->col;
+
+//      x.Elem(i) /= GetData(i, ElementsInLine(i));
+
+      x.Elem(i) /= col[lin->size - 1].data;
+
+      val = x.Get(i);
+
+
+
+      for (j = lin->size; j > 1; j--, col++)
+
+        x.Elem(col->colnr) -= col->data * val;
+
+      }
+
+    }
+
+/*
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      sum = b.Get(i);
+
+      for (j = 1; j < ElementsInLine(i); j++)
+
+        {
+
+        colnr = GetIndex (i, j);
+
+        sum -= GetData (i, j) * x.Get(colnr);
+
+        }
+
+      x.Set(i, sum);
+
+      }
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      x.Elem(i) /= GetData(i, ElementsInLine(i));
+
+
+
+      for (j = 1; j < ElementsInLine(i); j++)
+
+        {
+
+        colnr = GetIndex (i, j);
+
+        x.Elem(colnr) -= GetData (i, j) * x.Get(i);
+
+        }
+
+      }
+
+    }
+
+*/
+
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void SPARSE_MATRIX :: GSStepInner (const VECTOR & b, VECTOR & x, double dump,
+
+      const BITARRAY & inner) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+
+
+  n = Height();
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStep: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    for (i = 1; i <= n; i++)
+
+      {
+
+      lin = &lins.Get(i);
+
+      sum = b.Get(i);
+
+      col = lin->col;
+
+      diag = 1;
+
+
+
+      for (j = lin->size; j > 0; j--, col++)
+
+        {
+
+        sum -= col->data * x.Get(col->colnr);
+
+        if (col->colnr == i) diag = col->data;
+
+        }
+
+
+
+      x.Elem(i) += dump / diag * sum;
+
+      }
+
+    }
+
+  else
+
+    {
+
+    for (i = 1; i <= n; i++)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        val = x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            x.Elem(col->colnr) -= col->data * val;
+
+
+
+        x.Set(i, b.Get(i));
+
+        }
+
+
+
+
+
+    for (i = 1; i <= n; i++)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        sum = x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            sum -= col->data * x.Get(col->colnr);
+
+
+
+        x.Set(i, sum / col->data);
+
+        }
+
+    }
+
+  }
+
+
+
+void SPARSE_MATRIX :: GSStepBackInner (const VECTOR & b, VECTOR & x,
+
+      double dump, const BITARRAY & inner) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+
+
+  n = Height();
+
+
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStepBack: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      lin = &lins.Get(i);
+
+      sum = b.Get(i);
+
+      col = lin->col;
+
+      diag = 1;
+
+
+
+      for (j = lin->size; j > 0; j--, col++)
+
+        {
+
+        sum -= col->data * x.Get(col->colnr);
+
+        if (col->colnr == i) diag = col->data;
+
+        }
+
+
+
+      x.Elem(i) += dump / diag * sum;
+
+      }
+
+    }
+
+  else
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        sum = b.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            sum -= col->data * x.Get(col->colnr);
+
+
+
+        x.Set(i, sum);
+
+        }
+
+
+
+    for (i = n; i >= 1; i--)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        x.Elem(i) /= col[lin->size - 1].data;
+
+        val = x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            x.Elem(col->colnr) -= col->data * val;
+
+        }
+
+
+
+    }
+
+/*
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      sum = b.Get(i);
+
+      for (j = 1; j < ElementsInLine(i); j++)
+
+        {
+
+        colnr = GetIndex (i, j);
+
+        sum -= GetData (i, j) * x.Get(colnr);
+
+        }
+
+      x.Set(i, sum);
+
+      }
+
+    for (i = n; i >= 1; i--)
+
+      {
+
+      x.Elem(i) /= GetData(i, ElementsInLine(i));
+
+
+
+      for (j = 1; j < ElementsInLine(i); j++)
+
+        {
+
+        colnr = GetIndex (i, j);
+
+        x.Elem(colnr) -= GetData (i, j) * x.Get(i);
+
+        }
+
+      }
+
+    }
+
+*/
+
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void SPARSE_MATRIX :: GSStepToInner (const VECTOR & b, VECTOR & x, double dump,
+
+      const BITARRAY & inner) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+
+
+  n = Height();
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStep: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    MyError ("GSStepToInner: non symmetric case not implemented");
+
+    }
+
+  else
+
+    {
+
+    for (i = 1; i <= n; i++)
+
+//      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        val = x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            x.Elem(col->colnr) -= col->data * val;
+
+
+
+        if (inner.Test(i))
+
+          x.Set(i, b.Get(i));
+
+        }
+
+
+
+    for (i = 1; i <= n; i++)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        sum = x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+//          if (inner.Test(col->colnr))
+
+            sum -= col->data * x.Get(col->colnr);
+
+
+
+        x.Set(i, sum / col->data);
+
+        }
+
+    }
+
+  }
+
+
+
+void SPARSE_MATRIX :: GSStepBackToInner (const VECTOR & b, VECTOR & x,
+
+      double dump, const BITARRAY & inner) const
+
+  {
+
+  double sum, diag, val;
+
+  INDEX i, j, n;
+
+  colstruct * col;
+
+  const linestruct * lin;
+
+//  VECTOR hx(x.Length());
+
+
+
+  n = Height();
+
+
+
+  if (n != b.Length() || n != x.Length())
+
+    {
+
+    MyError ("GSStepBack: Sizes don't fit");
+
+    return;
+
+    }
+
+
+
+  if (! Symmetric ())
+
+    {
+
+    MyError ("GSStepToInner: non symmetric case not implemented");
+
+    }
+
+  else
+
+    {
+
+    for (i = n; i >= 1; i--)
+
+      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+        val = x.Get(i) / col[lin->size - 1].data;
+
+        x.Elem(i) = val;
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+//          if (inner.Test(col->colnr))
+
+            x.Elem(col->colnr) -= col->data * val;
+
+        }
+
+
+
+
+
+    for (i = n; i >= 1; i--)
+
+//      if (inner.Test(i))
+
+        {
+
+        lin = &lins.Get(i);
+
+        col = lin->col;
+
+
+
+        sum = b.Get(i);
+
+        if (!inner.Test(i)) sum += x.Get(i);
+
+
+
+        for (j = lin->size; j > 1; j--, col++)
+
+          if (inner.Test(col->colnr))
+
+            sum -= col->data * x.Get(col->colnr);
+
+
+
+        x.Set(i, sum);
+
+        }
+
+    }
+
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+VECTOR SPARSE_MATRIX :: ILU (const VECTOR & b, float eps) const
+
+  {
+
+  VECTOR x(b.Length()), r(b.Length()), temp(b.Length()), temp2(b.Length());
+
+  INDEX n = 0;
+
+  float res = 2 * eps;
+
+
+
+  LOWER_SPARSE_MATRIX l;
+
+  UPPER_SPARSE_MATRIX u;
+
+
+
+  ILU_Decomposition (l, u);
+
+
+
+//  x = 0;
+
+
+
+  l.Solve (b, temp);
+
+  u.Solve (temp, x);
+
+  Residuum (x, b, r);
+
+  res = r.L2Norm() / sqrt (x.Length());
+
+
+
+  while (n++ < 2000 && res > eps)
+
+    {
+
+    l.Solve (r, temp);
+
+    u.Solve (temp, temp2);
+
+
+
+    x += temp2;
+
+
+
+    Residuum (x, b, r);
+
+    res = r.L2Norm() / sqrt (x.Length());
+
+
+
+//    if (n % 50 == 0) itfile << "n = " << n << " res = " << res << endl;
+
+    }
+
+  return x;
+
+  }
+
+
+
+
+
+
+
+void SPARSE_MATRIX :: ILU_PCG (const VECTOR & b, VECTOR & x, const LOWER_SPARSE_MATRIX & l,
+
+                  const UPPER_SPARSE_MATRIX & u, float eps) const
+
+  {
+
+  const INDEX len = b.Length();
+
+  VECTOR r(len), p(len), h(len), h2(len), h3(len);
+
+  INDEX n = 0;
+
+  double res = 2 * eps, lam, shp, shh2;
+
+
+
+  x = 0;
+
+  r = b;
+
+
+
+  l.Solve (r, h2);
+
+  u.Solve (h2, h3);
+
+//  p = u.Solve (l.Solve (r));
+
+  p = h3;
+
+
+
+  while (n++ < 1000 && res > eps)
+
+    {
+
+    (*this).Mult (p, h);
+
+
+
+    shp = h * p;
+
+    if (!shp) break;
+
+    lam = (r * p) / shp;
+
+
+
+    x.Add (lam, p);
+
+    r.Add (-lam, h);
+
+
+
+    l.Solve (r, h3);
+
+    u.Solve (h3, h2);
+
+//    h2 = u.Solve (l.Solve (r));
+
+    shh2 = h * h2;
+
+
+
+    h2.Add (-shh2 / shp, p);
+
+    p = h2;
+
+
+
+
+
+    res = r.L2Norm() / sqrt (len);
+
+    itfile << "n = " << n << " res = " << res << endl;
+
+    }
+
+  itfile << "ILU_PCG: " << n << " Iterations" << endl;
+
+  }
+
+
+
+
+
+
+
+
+
+VECTOR SPARSE_MATRIX :: ILU_PCG (const VECTOR & b, float eps) const
+
+  {
+
+  VECTOR x(b.Length());
+
+
+
+  LOWER_SPARSE_MATRIX l;
+
+  UPPER_SPARSE_MATRIX u;
+
+
+
+  ILU_Decomposition (l, u);
+
+
+
+
+
+  ILU_PCG (b, x, l, u, eps);
+
+
+
+  return x;
+
+  }
+
+
+
+
+
+void BASE_MATRIX :: PrecondRichardson (const BASE_MATRIX & pre,
+
+      const BASE_VECTOR & b, BASE_VECTOR & x, double tau, double eps) const
+
+  {
+
+  double err, err0;
+
+  int it;
+
+  BASE_VECTOR * d = b.Copy();
+
+  BASE_VECTOR * w = b.Copy();
+
+
+
+  it = 0;
+
+
+
+  do
+
+    {
+
+    it++;
+
+
+
+    Residuum (x, b, *d);
+
+    pre.Mult (*d, *w);
+
+    x.Add (tau, *w);
+
+
+
+    err = sqrt (*d * *w);
+
+    if (it == 1) err0 = err;
+
+    if (err0 < 1e-30) break;
+
+    IterationDone (it, err/err0);
+
+    }
+
+  while (err > eps * err0);
+
+
+
+  delete d;
+
+  delete w;
+
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/linalg/linalg.cc ug-patched/gm/gg3/netgen/linalg/linalg.cc
--- ug-orig/gm/gg3/netgen/linalg/linalg.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/linalg.cc	1996-03-29 18:25:49.000000000 +0100
@@ -0,0 +1,886 @@
+/************************************************************************/
+/*                                                                      */
+/* This file is a part of NETGEN                                        */
+/*                                                                      */
+/* File:   linalg.cc                                                    */
+/* Author: Joachim Schoeberl                                            */
+/*                                                                      */
+/************************************************************************/
+
+
+
+#include <stdlib.h>
+
+#include <fstream.h>
+
+#include <string.h>
+
+#include <math.h>
+
+
+
+#include <template.hh>
+
+#include <array.hh>
+
+#include <linalg/linalg.hh>
+
+
+
+
+
+ofstream myerr ("error.out");
+
+// ofstream myerr ("NUL");
+
+
+
+
+
+
+
+
+
+double BASE_MATRIX :: shit = 0;
+
+
+
+
+
+BASE_MATRIX :: BASE_MATRIX ()
+
+  {
+
+  height = width = 0;
+
+  symmetric = 0;
+
+  }
+
+
+
+BASE_MATRIX :: BASE_MATRIX (INDEX h, INDEX w)
+
+  {
+
+  if (!w) w = h;
+
+  height = h;
+
+  width = w;
+
+  symmetric = 0;
+
+  }
+
+
+
+void BASE_MATRIX :: SetSize (INDEX h, INDEX w)
+
+  {
+
+  if (!w) w = h;
+
+  height = h;
+
+  width = w;
+
+  }
+
+
+
+void BASE_MATRIX :: SetSymmetric (int sym)
+
+  {
+
+  symmetric = sym;
+
+  }
+
+
+
+double & BASE_MATRIX :: operator() (INDEX, INDEX)
+
+  {
+
+  myerr << "BASE_MATRIX: operator() called" << endl;
+
+  return shit;
+
+  }
+
+
+
+double BASE_MATRIX :: operator() (INDEX, INDEX) const
+
+  {
+
+  myerr << "BASE_MATRIX: operator() called" << endl;
+
+  return 0;
+
+  }
+
+
+
+
+
+
+
+ostream & operator<<(ostream & s, const BASE_MATRIX & m)
+
+  {
+
+  return m.Print (s);
+
+  }
+
+
+
+ostream & BASE_MATRIX :: Print (ostream & s) const
+
+  {
+
+  for (INDEX i = 1; i <= Height(); i++)
+
+    {
+
+    for (INDEX j = 1; j < Width(); j++)
+
+      s << (*this)(i, j) << "  ";
+
+    s << (*this)(i, Width()) << endl;
+
+    }
+
+
+
+  return s;
+
+  }
+
+
+
+
+
+
+
+TEMP_VECTOR BASE_MATRIX :: operator* (const BASE_VECTOR & v) const
+
+  {
+
+  VECTOR * prod = new VECTOR(Height());
+
+
+
+  if (Width() != v.Length())
+
+    {
+
+    myerr << "\nMatrix and Vector don't fit" << endl;
+
+    }
+
+  else if (Height() != prod->Length())
+
+    {
+
+    myerr << "Base_Matrix::operator*(VECTOR): prod vector not ok" << endl;
+
+    }
+
+  else
+
+    {
+
+    Mult (v, *prod);
+
+    }
+
+
+
+  return *prod;
+
+  }
+
+
+
+
+
+
+
+MATRIX operator* (const BASE_MATRIX & m1, const BASE_MATRIX & m2)
+
+  {
+
+  MATRIX temp (m1.Height(), m2.Width());
+
+  double sum;
+
+
+
+  if (m1.Width() != m2.Height())
+
+         {
+
+         myerr << "BASE_MATRIX :: operator*: Matrix Size does not fit" << endl;
+
+         }
+
+  else if (temp.Height() != m1.Height())
+
+         {
+
+         myerr << "BASE_MATRIX :: operator*: temp not allocated" << endl;
+
+    }
+
+  else
+
+    {
+
+    for (INDEX i = 1; i <= m1.Height(); i++)
+
+      for (INDEX j = 1; j <= m2.Width(); j++)
+
+        {
+
+        sum = 0;
+
+        for (INDEX k = 1; k <= m1.Width(); k++)
+
+          sum += m1(i, k) * m2(k, j);
+
+        temp(i, j) = sum;
+
+        }
+
+    }
+
+  return temp;
+
+  }
+
+
+
+
+
+MATRIX operator+ (const BASE_MATRIX & m1, const BASE_MATRIX & m2)
+
+  {
+
+  MATRIX temp (m1.Height(), m1.Width());
+
+  INDEX i, j;
+
+
+
+  if (m1.Width() != m2.Width() || m1.Height() != m2.Height())
+
+    {
+
+    myerr << "BASE_MATRIX :: operator+: Matrix Size does not fit" << endl;
+
+    }
+
+  else if (temp.Height() != m1.Height())
+
+    {
+
+    myerr << "BASE_MATRIX :: operator+: temp not allocated" << endl;
+
+    }
+
+  else
+
+    {
+
+    for (i = 1; i <= m1.Height(); i++)
+
+      for (j = 1; j <= m1.Width(); j++)
+
+        {
+
+        temp(i, j) = m1(i, j) + m2(i, j);
+
+        }
+
+    }
+
+  return temp;
+
+  }
+
+
+
+
+
+void BASE_MATRIX :: Mult (const BASE_VECTOR & /* v */,
+
+      BASE_VECTOR & /* prod */) const
+
+  {
+
+  myerr << "BASE_MATRIX :: Mult called" << endl;
+
+  }
+
+
+
+void BASE_MATRIX :: MultTrans (const BASE_VECTOR & /* v */,
+
+      BASE_VECTOR & /* prod */) const
+
+  {
+
+  myerr << "BASE_MATRIX :: MultTrans called" << endl;
+
+  }
+
+
+
+void BASE_MATRIX :: Residuum (const BASE_VECTOR & /* x */,
+
+      const BASE_VECTOR & /* b */, BASE_VECTOR & /* res */) const
+
+  {
+
+  myerr << "BASE_MATRIX :: Residuum called" << endl;
+
+  }
+
+
+
+BASE_MATRIX * BASE_MATRIX :: Copy () const
+
+  {
+
+  myerr << "BASE_MATRIX :: Copy called" << endl;
+
+  return NULL;
+
+  }
+
+
+
+
+
+BASE_VECTOR * BASE_MATRIX :: CreateVector () const
+
+  {
+
+  return new VECTOR (Height());
+
+  }
+
+
+
+
+
+
+
+/*
+
+void BASE_MATRIX :: Mult (const VECTOR & v, VECTOR & prod) const
+
+  {
+
+  float sum;
+
+
+
+  prod.SetLength (Height());
+
+
+
+  if (Width() != v.Length())
+
+    {
+
+    myerr << "\nMatrix and Vector don't fit" << endl;
+
+    }
+
+  else if (Height() != prod.Length())
+
+    {
+
+    myerr << "Base_Matrix::operator*(VECTOR): prod vector not ok" << endl;
+
+    }
+
+  else
+
+    {
+
+    for (INDEX i = 1; i <= Height(); i++)
+
+      {
+
+      sum = 0;
+
+
+
+      for (INDEX j = 1; j <= Width(); j++)
+
+        sum += (*this)(i,j) * v.Get(j);
+
+
+
+      prod.Set (i, sum);
+
+      }
+
+    }
+
+  }
+
+
+
+
+
+void BASE_MATRIX :: MultTrans (const VECTOR & v, VECTOR & prod) const
+
+  {
+
+  float sum;
+
+
+
+  prod.SetLength (Width());
+
+
+
+  if (Height() != v.Length())
+
+    {
+
+    myerr << "\nMatrix and Vector don't fit" << endl;
+
+    }
+
+  else if (Width() != prod.Length())
+
+    {
+
+    myerr << "Base_Matrix::operator*(VECTOR): prod vector not ok" << endl;
+
+    }
+
+  else
+
+    {
+
+    for (INDEX i = 1; i <= Width(); i++)
+
+      {
+
+      sum = 0;
+
+
+
+      for (INDEX j = 1; j <= Height(); j++)
+
+        sum += (*this)(j, i) * v.Get(j);
+
+
+
+      prod.Set (i, sum);
+
+      }
+
+    }
+
+  }
+
+
+
+
+
+void BASE_MATRIX :: Residuum (const VECTOR & x, const VECTOR & b, VECTOR & res) const
+
+  {
+
+  float sum;
+
+
+
+  res.SetLength (Height());
+
+
+
+  if (Width() != x.Length() || Height() != b.Length())
+
+    {
+
+    myerr << "\nMatrix and Vector don't fit" << endl;
+
+    }
+
+  else if (Height() != res.Length())
+
+    {
+
+    myerr << "Base_Matrix::operator*(VECTOR): prod vector not ok" << endl;
+
+    }
+
+  else
+
+    {
+
+    for (INDEX i = 1; i <= Height(); i++)
+
+      {
+
+      sum = b.Get(i);
+
+
+
+      for (INDEX j = 1; j <= Width(); j++)
+
+        sum -= (*this)(i,j) * x.Get(j);
+
+
+
+      res.Set (i, sum);
+
+      }
+
+    }
+
+  }
+
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void BASE_MATRIX :: SolveDestroy (const VECTOR & v, VECTOR & sol)
+
+  {
+
+  INDEX i, j, k;
+
+  double q;
+
+
+
+  if (Width() != Height())
+
+    {
+
+    myerr << "SolveDestroy: Matrix not square";
+
+    return;
+
+    }
+
+  if (Width() != v.Length())
+
+    {
+
+    myerr << "SolveDestroy: Matrix and Vector don't fit";
+
+    return;
+
+    }
+
+
+
+  sol = v;
+
+  if (Height() != sol.Length())
+
+    {
+
+    myerr << "SolveDestroy: Solution Vector not ok";
+
+    return;
+
+    }
+
+
+
+  for (i = 1; i <= Height(); i++)
+
+    {
+
+    for (j = i+1; j <= Height(); j++)
+
+      {
+
+      q=(*this)(j,i) / (*this)(i,i);
+
+      for (k = i+1; k <= Height(); k++)
+
+        {
+
+        (*this)(j, k) -= q * (*this)(i,k);
+
+        }
+
+      sol.Elem(j) -= q * sol.Get(i);
+
+      }
+
+    }
+
+
+
+  for (i = Height(); i >= 1; i--)
+
+    {
+
+    q = sol(i);
+
+    for (j = i+1; j <= Height(); j++)
+
+      {
+
+      q -= (*this)(i,j) * sol.Get(j);
+
+      }
+
+    sol.Set(i, q / (*this)(i,i));
+
+    }
+
+  }
+
+
+
+void BASE_MATRIX :: Solve (const VECTOR & v, VECTOR & sol) const
+
+  {
+
+  BASE_MATRIX * temp = Copy();
+
+
+
+  if (temp->Height() != Height())
+
+    {
+
+    myerr << "Solve: Matrix temp not allocated" << endl;
+
+    return;
+
+    }
+
+
+
+  temp->SolveDestroy (v, sol);
+
+
+
+  delete temp;
+
+  }
+
+
+
+
+
+
+
+VECTOR BASE_MATRIX :: Solve (const VECTOR & v) const
+
+  {
+
+  VECTOR sol (v.Length());
+
+
+
+  if (Width() != Height())
+
+    {
+
+    myerr << "Solve: Matrix not square";
+
+    return v;
+
+    }
+
+  if (Width() != v.Length())
+
+    {
+
+    myerr << "Solve: Matrix and Vector don't fit";
+
+    return v;
+
+    }
+
+  if (Width() != sol.Length())
+
+    {
+
+    myerr << "Solve: Vector sol not allocated" << endl;
+
+    }
+
+
+
+  Solve (v, sol);
+
+
+
+  return sol;
+
+  }
+
+
+
+
+
+void BASE_MATRIX :: SolvePI (const VECTOR & v, VECTOR & sol) const
+
+  {
+
+/*     
+  VECTOR sol2(v.Length());
+
+
+
+  Solve (v, sol2);
+
+  Solve (*(VECTOR*)&(v - (*this) * sol2), sol);
+
+  sol += sol2;
+*/
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void BASE_MATRIX :: LU_Decomposition (MATRIX & l, MATRIX & u) const
+
+  {
+
+  INDEX i, j ,k;
+
+  double sum;
+
+  l.SetSize (Width());
+
+  u.SetSize (Width());
+
+
+
+  for (i = 1; i <= Width(); i++)
+
+    for (j = 1; j <= Width(); j++)
+
+      l(i, j) = u(i, j) = 0;
+
+
+
+  for (i = 1; i <= Width(); i++)
+
+    {
+
+    for (k = 1; k < i; k++)
+
+      {
+
+      sum = (*this)(i, k);
+
+      for (j = 1; j < k; j++)
+
+        sum -= l(i, j) * u(j, k);
+
+      l(i, k) = sum / u(k, k);
+
+      }
+
+    l(i, i) = 1;
+
+
+
+    for (k = i; k <= Width(); k++)
+
+      {
+
+      sum = (*this)(i, k);
+
+      for (j = 1; j < i; j++)
+
+        sum -= l(i, j) * u(j, k);
+
+      u(i, k) = sum;
+
+      }
+
+    }
+
+  }
+
+
+
+
+
+
+
+void Transpose (const BASE_MATRIX & m1, MATRIX & m2)
+
+  {
+
+  m2.SetSize (m1.Width(), m1.Height());
+
+  INDEX i, j;
+
+
+
+  for (i = 1; i <= m1.Height(); i++)
+
+    for (j = 1; j <= m1.Width(); j++)
+
+      m2(j, i) = m1(i, j);
+
+  }
+
+
+
+
+
+
+
+
+
+
+
+void BASE_MATRIX :: Gerschgorin (double & min, double & max) const
+
+  {
+
+  min = 0;
+
+  max = 0;
+
+  }
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/linalg/linalg.hh ug-patched/gm/gg3/netgen/linalg/linalg.hh
--- ug-orig/gm/gg3/netgen/linalg/linalg.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/linalg.hh	1998-03-18 19:05:16.000000000 +0100
@@ -0,0 +1,28 @@
+#ifndef FILE_LINALG
+#define FILE_LINALG
+
+/* *************************************************************************/
+/* File:   linalg.hh                                                      */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Oct. 94                                                    */
+/* *************************************************************************/
+
+/* 
+
+   Data types for basic linear algebra
+   more data types are found in linalgl.hh
+   
+   The basic concepts include the data types 
+   
+    Vector
+    SparseMatrix
+    DenseMatrix
+
+*/
+
+#include <linalg/vector.hh>
+#include <linalg/basemat.hh>
+#include <linalg/densemat.hh>
+#include <linalg/sparsmat.hh>
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/makefile ug-patched/gm/gg3/netgen/linalg/makefile
--- ug-orig/gm/gg3/netgen/linalg/makefile	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/makefile	1998-03-18 19:05:16.000000000 +0100
@@ -0,0 +1,10 @@
+objects = vector.o sparsmat.o densemat.o basemat.o 
+# vector.cc sparsmat.cc densemat.cc \
+# iterativ.cc supervec.cc supermat.cc calccond.cc specmat.cc
+#
+# CCFL    += -pg
+#
+include ../makefile.inc
+#
+#
+
diff -ruN ug-orig/gm/gg3/netgen/linalg/sparsmat.cc ug-patched/gm/gg3/netgen/linalg/sparsmat.cc
--- ug-orig/gm/gg3/netgen/linalg/sparsmat.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/sparsmat.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,1712 @@
+#include <stdlib.h> 
+#include <iostream.h>
+#include <fstream.h>
+#include <string.h>
+#include <math.h>
+
+#include <template.hh>
+#include <myadt.hh>
+#include <linalg/linalg.hh>
+
+
+//extern ofstream myerr;
+
+
+
+MatrixGraph :: MatrixGraph (int size, int aincrement)
+{
+  int i;
+  increment = aincrement;
+  
+  lines.SetSize (size);
+  for (i = 1;i <= size; i++)
+    {
+      lines.Elem(i).allocsize = increment;
+      lines.Elem(i).size = 1;
+      lines.Elem(i).diag = 1;
+      lines.Elem(i).col = new INDEX[increment];
+      lines.Elem(i).col[0] = i;
+    }
+}
+
+MatrixGraph :: MatrixGraph (const ARRAY<int> & linesize)
+{
+  INDEX i;
+  INDEX n = linesize.Size();
+  INDEX sum = 0;
+  INDEX * cola;
+
+  lines.SetSize (n);
+  increment = 0;
+
+  for (i = 1; i <= n; i++)
+    sum += linesize.Get(i);
+  
+  cola = new INDEX[sum];
+
+  sum = 0;
+  for (i = 1; i <= n; i++)
+    {
+      lines.Elem(i).allocsize=linesize.Get(i);
+      lines.Elem(i).size = 1;
+      lines.Elem(i).diag = 1;
+      lines.Elem(i).col = &cola[sum];
+      cola[sum] = i;
+      sum += linesize.Get(i);
+    }
+}
+
+int MatrixGraph :: GetPosition (INDEX i, INDEX j) const
+{
+  int k;
+  
+  INDEX * ip = lines.Get(i).col;
+  INDEX n = lines.Get(i).size;
+  for (k = 1; k <= n; k++, ip++)
+    {
+      if (j == *ip) return k;
+    }
+
+  return 0;
+  
+  /*  
+  //  quick search:
+
+  const INDEX * ip = lines.Get(i).col;
+  int max = lines.Get(i).size;
+
+  int l = 0, k = 1, newind;
+  
+  while (k < max)
+    k <<= 1;
+
+  while (k > 0)
+    {
+      k >>= 1;
+      newind = k+l;
+      if (newind >= max) continue;
+      if (ip[newind] <= j)
+	l += k;
+    }
+
+  if (l < max && ip[l] == j) 
+    return l+1;
+
+  return 0;
+  */
+}
+
+
+
+int MatrixGraph :: CreatePosition (INDEX i, INDEX j)    
+  {
+  int k;
+  MatrixGraph::linestruct * lin = &lines.Elem(i);
+
+ 
+
+  for (k = 1; k <= lin->size; k++)
+    {
+      if (lin->col[k-1] == j) 
+	return 0;
+      if (lin->col[k-1] > j) 
+	break;
+    }
+
+  // k ... position to enter new element
+
+  if (lin->size == lin->allocsize)
+    {
+      INDEX * tmpcol = new INDEX[lin->size + increment];
+      memcpy (tmpcol, lin->col, sizeof(INDEX) * lin->size);
+      delete lin->col;
+      lin->col = tmpcol;
+      lin->allocsize+=increment;
+    }
+
+  if (k <= lin->size)
+    memmove (&lin->col[k], &lin->col[k-1], 
+	     sizeof(INDEX) * (lin->size + 1 - k));
+  
+  lin->col[k-1] = j;
+  lin->size++;
+  if (j < i) lin->diag++;
+
+  return 1;
+  }
+
+
+
+double & SparseMatrix :: operator() (INDEX i, INDEX j)
+{
+  if (i >= 1 && i <= height && j >= 1 && j <= width)
+    return Elem(i, j);
+  else
+    {
+//    myerr << "SparseMatirx::operator(): out of range" << endl;
+    return shit;
+    }
+}
+ 
+double SparseMatrix :: operator() (INDEX i, INDEX j) const
+{
+  if (i >= 1 && i <= height && j >= 1 && j <= width)
+    return Get(i, j);
+  else
+    {
+//    myerr << "SparseMatirx::operator(): out of range" << endl;
+    return shit;
+    }
+}
+   
+
+
+
+
+
+SparseMatrix :: SparseMatrix (INDEX h, INDEX w)
+  : BaseMatrix (h, w)
+{
+  ;
+}
+
+
+
+
+void SparseMatrix :: Mult (const BaseVector & bv, BaseVector & bprod) const
+  {
+  double sum, vi;
+  INDEX i, j, n;
+
+  const INDEX * col;
+  const double * valp;
+
+  const Vector & v = bv.CastToVector();
+  Vector & prod = bprod.CastToVector();
+
+  prod.SetLength (Height());
+
+  /*
+  if (prod.Length() != Height() || v.Length() != Width())
+    {
+//    myerr << "SparseMatrix::Mult: Dimensions don't fit" << endl;
+    return;
+    }
+    */
+
+  if (!Symmetric())
+    {
+      n = Height();
+      INDEX w = Width();
+
+      /*
+      const MatrixGraph::linestruct * linep = &graph->lines.Get(1);   
+
+      for (i = 1; i <= n; i++) 
+	{
+	  sum = 0; 
+	  col = linep->col;
+	  valp = data.Get(i);
+	  
+	  for (j = 0; j < linep->size; j++, valp++, col++)
+	    sum += *valp * v.Get(*col); 
+
+	  linep++;
+	  prod.Set (i, sum);
+	}
+	*/
+
+      const MatrixGraph::linestruct * linep = &graph->lines.Get(1);   
+      const double * vp = &v.Get(1);
+      vp--;
+
+      for (i = 1; i <= n; i++) 
+	{
+	  sum = 0; 
+	  col = linep->col;
+	  valp = data.Get(i);
+	  const int ls = linep->size;
+	  
+	  if (i <= w)
+	    for (j = 0; j < ls; j++)
+	      sum += valp[j] * vp[col[j]];
+	  else
+	    // decrement one, because of diagonal element outside
+	    for (j = 0; j < ls-1; j++)
+	      sum += valp[j] * vp[col[j]];
+
+	  
+	  linep++;
+	  prod.Set (i, sum);
+	}
+
+    }
+  else
+    {
+      prod = 0;
+      n = Height();
+      
+      const MatrixGraph::linestruct * linep = &graph->lines.Get(1);   
+
+      for (i = 1; i <= n; i++)
+	{
+	  sum = 0; 
+	  //	  col = graph->lines.Get(i).col;
+	  col = linep->col;
+	  valp = data.Get(i);
+	  vi = v.Get(i);
+	  
+	  for (j = linep->diag-1; j > 0; j--, col++, valp++)
+	    {
+	      sum += (*valp) * v.Get(*col);
+	      prod.Elem(*col) += (*valp) * vi;
+	    }
+	  
+	  linep++;
+	  sum += (*valp) * v.Get(*col);
+	  prod.Elem(i) += sum;
+	}
+    }
+  }
+
+void SparseMatrix :: MultTrans (const BaseVector & bv, BaseVector & bprod) const
+  {
+  INDEX i, j, n, coln;
+  const Vector & v = bv.CastToVector();
+  Vector & prod = bprod.CastToVector();
+  const INDEX * col;
+  const double * valp;
+  double val;
+
+  prod.SetLength (Width());
+
+  if (prod.Length() != Width() || v.Length() != Height())
+    {
+//    myerr << "SparseMatrix::Mult: Dimensions don't fit" << endl;
+    return;
+    }
+
+  if (!Symmetric())
+    {
+    n = Height();
+    prod = 0;
+
+    for (i = 1; i <= n; i++)
+      {
+	col = graph->lines.Get(i).col;
+	valp = data.Get(i);
+	coln = graph->lines.Get(i).size;
+	val = v.Get(i);
+
+	//      lin = &lins.Get(i);
+	//      col = lin->col;
+	//      val = v.Get(i);
+      
+      for (j = 1; j <= coln; j++, col++, valp++)
+        prod.Elem(*col) += (*valp) * val;
+      }
+    }
+  else
+    {
+    Mult (v, prod);
+    }
+  }
+
+
+
+
+void SparseMatrix :: Residuum (const BaseVector & bx, const BaseVector & bb,
+      BaseVector & bres) const
+  {
+    BaseMatrix :: Residuum (bx, bb, bres);
+    /*
+  double sum, xi;
+  INDEX i, j, n;
+  colstruct * col;
+  const linestruct * lin;
+  const Vector & x = bx.CastToVector();
+  const Vector & b = bb.CastToVector();
+  Vector & res = bres.CastToVector();
+
+  res.SetLength (b.Length());
+
+  if (res.Length() != b.Length() || b.Length() != Height() ||
+      x.Length() != Width())
+    {
+//    myerr << "SparseMatrix::Residuum: Dimensions don't fit" << endl;
+    return;
+    }
+
+  n = Height();
+  if (!Symmetric())
+    {
+    for (i = 1; i <= Height(); i++)
+      {
+      lin = &lins.Get(i);
+      sum = b.Get(i);
+      col = lin->col;
+
+      for (j = lin->size; j > 0; j--, col++)
+        sum -= col->data * x.Get(col->colnr);
+
+      res.Set (i, sum);
+      }
+    }
+  else
+    {
+    res = b;
+    for (i = 1; i <= n; i++)
+      {
+      lin = &lins.Get(i);
+      sum = 0;
+      col = lin->col;
+      xi = x.Get(i);
+
+      for (j = lin->size; j > 0; j--, col++)
+        {
+        sum -= col->data * x.Get(col->colnr);
+        if (col->colnr != i)
+          res.Elem(col->colnr) -= col->data * xi;
+        }
+
+      res.Elem(i) += sum;
+      }
+    }
+    */
+  }
+
+
+void SparseMatrix :: ResiduumTrans (const BaseVector & /* bx */, 
+				    const BaseVector & /* bb */,
+				    BaseVector & /* bres */) const
+  {
+    cerr << "SparseMastrix :: Residuumtrans called, but not implemented" << endl;
+
+    /*
+  INDEX i, j, n;
+  colstruct * col;
+  const linestruct * lin;
+  const Vector & x = bx.CastToVector();
+  const Vector & b = bb.CastToVector();
+  Vector & res = bres.CastToVector();
+
+
+  res.SetLength (Width());
+
+  if (res.Length() != b.Length() || b.Length() != Width() ||
+      x.Length() != Height())
+    {
+//    myerr << "SparseMatrix::ResiduumTrans: Dimensions don't fit" << endl;
+    return;
+    }
+  
+  if (!Symmetric())
+    {
+    n = Height();
+
+    res = b;
+
+    for (i = 1; i <= n; i++)
+      {
+      lin = &lins.Get(i);
+      col = lin->col;
+
+      for (j = lin->size; j > 0; j--, col++)
+        res.Elem(col->colnr) -= col->data * x.Get(i);
+      }
+    }
+  else
+    {
+    Residuum (bx, bb, bres);
+    }
+    */
+  }
+
+
+
+ostream & SparseMatrix :: Print (ostream & s) const
+  {
+  INDEX i, j;
+
+  if (Symmetric()) s << "Lower half of matrix:" << endl;
+
+  for (i = 1; i <= Height(); i++)
+    {
+    s << "Line " << i << " ";
+
+    if (Symmetric())
+      {
+	for (j = 1 ; j <= GetDiagPos (i); j++)
+	  s << "(" << GetColIndex (i, j) << ": " << GetData (i, j) << ") ";
+      }
+    else
+      {
+	for (j = 1 ; j <= ElementsInLine (i); j++)
+	  s << "(" << GetColIndex (i, j) << ": " << GetData (i, j) << ") ";
+      }
+
+    s << endl;
+    }
+  return s;
+  }
+
+
+
+
+
+
+void SparseMatrix :: AddElementMatrix (const ARRAY<INDEX> & pnum,
+      const BaseMatrix & elemmat)
+{
+  int i, j, i1, i2, n;
+
+  n = pnum.Size();
+  static ARRAY<int> spnum, map;
+  spnum.SetSize (n);
+  map.SetSize (n);
+
+  for (i = 1; i <= n; i++)
+    spnum.Elem(i) = pnum.Get(i);
+
+  for (i = 1; i <= n; i++)
+    for (j = 1; j <= n-1; j++)
+      if (spnum.Elem(j) > spnum.Elem(j+1))
+	ng_swap (spnum.Elem(j), spnum.Elem(j+1));
+
+  for (i = 1; i <= n; i++)
+    for (j = 1; j <= n; j++)
+      if (pnum.Get(i) == spnum.Get(j))
+	map.Elem(j) = i;
+
+
+  const DenseMatrix & delemmat = (const DenseMatrix&)elemmat;
+  if (Symmetric())
+    {
+      for (i1 = 1; i1 <= n; i1++)
+	{
+	  INDEX ii1 = spnum.Get(i1);
+	  const INDEX * coli = graph->lines.Get(ii1).col;
+	  double * val = data.Get(ii1);
+	  int ncol = graph->lines.Get(ii1).size;
+
+	  int hi = 0;
+	  for (i2 = 1; i2 <= i1; i2++)
+	    {
+	      while (coli[hi] < spnum.Get(i2))
+		hi++;
+	      val[hi] += delemmat.Get(map.Get(i1), map.Get(i2));
+	    }
+	}
+
+      /*
+      for (i1 = 1; i1 <= pnum.Size(); i1++)
+	for (i2 = 1; i2 <= i1; i2++)
+	  Elem(pnum.Get(i1), pnum.Get(i2)) += delemmat.Get(i1, i2);
+	  */
+    }
+  else
+    {
+      for (i1 = 1; i1 <= n; i1++)
+	{
+	  INDEX ii1 = spnum.Get(i1);
+	  const INDEX * coli = graph->lines.Get(ii1).col;
+	  double * val = data.Get(ii1);
+	  int ncol = graph->lines.Get(ii1).size;
+
+	  int hi = 0;
+	  for (i2 = 1; i2 <= n; i2++)
+	    {
+	      while (coli[hi] < spnum.Get(i2))
+		hi++;
+	      val[hi] += delemmat.Get(map.Get(i1), map.Get(i2));
+	    }
+	}
+
+      /*
+      for (i1 = 1; i1 <= pnum.Size(); i1++)
+	for (i2 = 1; i2 <= pnum.Size(); i2++)
+	  Elem(pnum.Get(i1), pnum.Get(i2)) += delemmat.Get(i1, i2);
+	  */
+    }
+}
+
+
+
+
+double SparseMatrix :: RowTimesVector (INDEX i, const Vector & v) const
+  {
+  const double * valp;
+  const INDEX * col;
+  int coln;
+  double sum;
+  int j;
+
+  /*
+  if (Width() > v.Length())
+    {
+    cerr << "SparseMatrix::RowTimesVector: Size doesn't fit" << endl;
+    return 0;
+    }
+    */
+
+  col = graph->lines.Get(i).col;
+  valp = data.Get(i);
+  sum = 0;
+  coln = Symmetric() ? graph->lines.Get(i).diag : graph->lines.Get(i).size;
+
+  for (j = 1; j <= coln; ++j, ++col, ++valp)
+    sum += (*valp) * v.Get(*col);
+
+  return sum;
+
+  /*
+	col = graph->lines.Get(i).col;
+	valp = data.Get(i);
+	coln = graph->lines.Get(i).size;
+	val = v.Get(i);
+
+	//      lin = &lins.Get(i);
+	//      col = lin->col;
+	//      val = v.Get(i);
+      
+      for (j = 1; j <= coln; j++, col++, valp++)
+        prod.Elem(*col) += (*valp) * val;
+	*/
+
+
+  }
+  
+
+
+void SparseMatrix :: AddRowToVector (INDEX i, double s, Vector & v) const
+{
+  const double * valp;
+  const INDEX * col;
+  double * vp;
+  int coln, j;
+  
+#ifdef debug  
+  if (Width() > v.Length())
+    {
+      cerr << "SparseMatrix::AddRowToVector: Size doesn't fit" 
+	   << "w = " << Width() << " len = " << v.Length() << endl;
+      return;
+    }
+#endif    
+
+  vp = &v.Elem(1) - 1;
+  valp = data.Get(i);
+  col = graph->lines.Get(i).col;
+  coln =  Symmetric() ? graph->lines.Get(i).diag : graph->lines.Get(i).size;
+
+  //  for (j = 0; j < coln; j++)
+  //    vp[col[j]] += s * valp[j];
+
+  for (j = coln-1; j >= 0; --j, ++valp, ++col)
+    vp[*col] += s * (*valp);
+}
+
+
+
+
+
+
+char SparseMatrix :: Used (INDEX i, INDEX j) const
+  {
+  return (graph->GetPosition(i, j) != 0);
+  }
+
+
+
+double SparseMatrix :: Get(INDEX i, INDEX j) const
+  {
+  if (Symmetric() && (j > i)) ng_swap (i, j);
+    
+  int pos = graph->GetPosition(i, j);
+  if (pos)
+    return data.Get(i)[pos-1];
+  else 
+    return 0;
+  }
+  
+
+/*
+  quick search:
+
+  const colstruct * col = lins.Get(i).col;
+  INDEX max = lins.Get(i).size;
+
+  int l = 0, k = 1, newind;
+
+  while (k < max)
+    k <<= 1;
+
+
+  while (k > 0)
+    {
+    k >>= 1;
+    newind = k+l;
+    if (newind >= max) continue;
+    if (col[newind].colnr <= j)
+      l += k;
+    }
+
+  if (l < max && col[l].colnr == j) return col[l].data;
+
+  return 0;
+  */
+  
+
+
+void SparseMatrix :: Set(INDEX i, INDEX j, double v)
+  {
+  Elem (i, j) = v;
+  }
+
+
+
+double & SparseMatrix :: Elem(INDEX i, INDEX j)
+  {
+  if (Symmetric() && j > i) ng_swap (i, j);
+  
+  int pos = graph->GetPosition (i, j);
+  if (!pos)
+    {
+      CreatePosition (i, j);
+      pos = graph->GetPosition (i, j);
+    }
+
+  return data.Elem(i)[pos-1];
+  }
+
+
+
+
+
+
+
+
+SparseMatrixFlex :: SparseMatrixFlex (INDEX h, INDEX w)
+  : SparseMatrix (h, w)
+{
+  INDEX i;
+  graph = 
+    mygraph = new MatrixGraph (h);
+
+  data.SetSize (h);
+  for (i = 1; i <= graph->Size(); i++)
+    {
+      data.Elem(i) = new double[graph->lines.Get(i).allocsize];
+      data.Elem(i)[0] = 0;
+    }
+}
+
+SparseMatrixFlex :: ~SparseMatrixFlex ()
+{
+  ;
+}
+
+
+void SparseMatrixFlex :: SetSize (INDEX /* h */, INDEX /* w */)
+{
+  cerr << "SparseMatrixFlex :: SetSize() not implemented" << endl;
+}
+
+void SparseMatrixFlex :: SetSymmetric (int sym)
+{
+  BaseMatrix::SetSymmetric (sym);
+}
+
+void SparseMatrixFlex :: ChangeSize (INDEX /* h */, INDEX /* w */)
+{
+  cerr << "SparseMatrixFlex :: ChangeSize() not implemented" << endl;
+}
+
+
+void SparseMatrixFlex :: DeleteElements ()
+{
+  ;
+} 
+
+BaseMatrix * SparseMatrixFlex :: Copy () const
+{
+  return (SparseMatrixFlex*)this;
+}
+
+
+int SparseMatrixFlex :: CreatePosition (INDEX i, INDEX j)
+{
+  int oldlinesize = graph->lines.Get(i).allocsize;
+  if (mygraph->CreatePosition(i, j))
+    {
+      int newlinesize = graph->lines.Get(i).allocsize;
+      if (oldlinesize != newlinesize)
+	{
+	  double * hdp = new double[newlinesize];
+	  memcpy (hdp, data.Elem(i), sizeof(double) * oldlinesize);
+	  delete data.Elem(i);
+	  data.Elem(i) = hdp;
+	}
+
+      int pos = graph->GetPosition (i, j);
+      int size = graph->lines.Get(i).size;
+
+      memmove (&data.Elem(i)[pos], &data.Elem(i)[pos-1], 
+	       sizeof(double) * (size-pos));
+      data.Elem(i)[pos-1] = 0;
+    }
+
+  return 0;
+}
+
+
+
+
+SparseMatrixFix :: SparseMatrixFix (const MatrixGraph & agraph,
+				     int asymmetric)
+  : SparseMatrix (agraph.Size())
+{
+  graph = &agraph;
+  SetSymmetric (asymmetric);
+
+  data.SetSize (graph->Size());
+
+  int i, nne;
+  double * block;
+  
+  nne = 0;
+  for (i = 1; i <= graph->Size(); i++)
+    {
+    if (Symmetric())
+      nne += graph->lines.Get(i).diag;
+    else
+      nne += graph->lines.Get(i).size;
+    }
+    
+  block = new double[nne];
+  
+  for (i = 0; i < nne; i++)
+    block[i] = 0;
+
+  nne = 0;
+  for (i = 1; i <= graph->Size(); i++)
+    {
+    data.Elem(i) = &block[nne];
+    if (Symmetric())
+      nne += graph->lines.Get(i).diag;
+    else
+      nne += graph->lines.Get(i).size;
+    }
+
+}
+
+
+SparseMatrixFix :: ~SparseMatrixFix ()
+{
+  ;
+}
+
+int SparseMatrixFix :: CreatePosition (INDEX i, INDEX j)
+{
+//  myerr << "SparseMatrixFix cannot change graph, requested: " 
+//       << i << "-" << j << endl;
+  return 0;
+}
+
+#ifdef nothing
+
+
+SparseMatrix :: SparseMatrix () : BaseMatrix (), lins()
+  {
+  };
+
+SparseMatrix :: SparseMatrix (INDEX h, INDEX w) : BaseMatrix (h, w), lins (h)
+  {
+  if (!w) w = h;
+
+  for (INDEX i = 1; i <= h; i++)
+    {
+    lins[i].size = 0;
+    lins[i].maxsize = 0;
+    lins[i].col = NULL;
+    }
+  }
+
+SparseMatrix :: SparseMatrix (const SparseMatrix & m2) : BaseMatrix(), lins()
+  {
+  (*this) = m2;
+  }
+
+
+SparseMatrix :: ~SparseMatrix ()
+  {
+  DeleteElements ();
+  }
+
+
+
+void SparseMatrix :: SetSize (INDEX h, INDEX w)
+  {
+  if (!w) w = h;
+  DeleteElements ();
+
+  if (height == h && width == w) return;
+
+  height = h;
+  width = w;
+  lins.SetSize (height);
+
+  if (lins.Size () == height)
+    {
+    for (INDEX i = 1; i <= h; i++)
+      {
+      lins[i].size = 0;
+      lins[i].maxsize = 0;
+      lins[i].col = NULL;
+      }
+    }
+  else
+    {
+    height = width = 0;
+//    myerr << "SparseMatrix::SetSize: Out of memory" << endl;
+    }
+  }
+
+
+void SparseMatrix :: ChangeSize (INDEX h, INDEX w)
+  {
+  INDEX i;
+
+  if (!w) w = h;
+  if (height == h && width == w) return;
+
+  lins.SetSize (h);
+
+  if (lins.Size () == h)
+    {
+    for (i = height+1; i <= h; i++)
+      {
+      lins[i].size = 0;
+      lins[i].maxsize = 0;
+      lins[i].col = NULL;
+      }
+    for (i = h+1; i <= height; i++)
+      {
+      if (lins[i].col)
+        {
+        DeleteColStruct (lins[i].col, lins[i].maxsize);
+
+        lins[i].col = NULL;
+        lins[i].size = 0;
+        lins[i].maxsize = 0;
+        }
+      }
+
+    height = h;
+    width = w;
+    }
+  else
+    {
+    height = width = 0;
+//    myerr << "SparseMatrix::SetSize: Out of memory" << endl;
+    }
+  }
+
+
+void SparseMatrix :: SetSymmetric (int sym)
+  {
+  INDEX i, j;
+  int nr;
+
+  if (sym != Symmetric())
+    {
+    BaseMatrix :: SetSymmetric (sym);
+
+    if (!sym)
+      {
+      for (i = 1; i <= Height(); i++)
+        for (nr = 1; nr <= ElementsInLine (i); nr++)
+          {
+          j = GetIndex (i, nr);
+          if (j < i)
+            Elem (j, i) = GetData (i, nr);
+          }
+      }
+    else
+      {
+      DeleteElements();
+      }
+    }
+  }
+
+
+void SparseMatrix :: DeleteElements ()
+  {
+  for (INDEX i = 1; i <= lins.Size(); i++)
+    {
+    if (lins[i].col)
+      {
+      DeleteColStruct (lins[i].col, lins[i].maxsize);
+
+      lins[i].col = NULL;
+      lins[i].size = 0;
+      lins[i].maxsize = 0;
+      }
+    }
+  }
+
+
+
+double & SparseMatrix::operator() (INDEX i, INDEX j)
+{
+  if (i >= 1 && j >= 1 && i <= height && j <= width)
+    {
+      return Elem(i, j);
+    }
+//  else myerr << "\nindex (" << i << "," << j << ") out of range (1.."
+//	     << height << ",1.." << width << ")\n";
+  return shit;
+}
+
+double SparseMatrix::operator() (INDEX i, INDEX j) const
+{
+  if (i >= 1 && j >= 1 && i <= height && j <= width)
+    {
+    return Get(i, j);
+    }
+//  else myerr << "\nindex (" << i << "," << j << ") out of range (1.."
+//	     << height << ",1.." << width << ")\n";
+  return 0;
+}
+
+SparseMatrix & SparseMatrix :: operator= (const SparseMatrix & m2)
+  {
+  INDEX i, j;
+
+  SetSize (m2.Height(), m2.Width());
+  SetSymmetric (m2.Symmetric());
+
+  for (i = 1; i <= m2.Height(); i++)
+    for (j = 1; j <= m2.ElementsInLine(i); j++)
+      (*this).Elem(i, m2.GetIndex(i, j)) = m2.GetData(i, j);
+  return *this;
+  }
+
+
+SparseMatrix & SparseMatrix :: operator*= (double v)
+  {
+  INDEX i, j;
+
+  for (i = 1; i <= Height(); i++)
+    for (j = 1; j <= ElementsInLine(i); j++)
+      GetDataRef(i, j) *= v;
+  return *this;
+  }
+
+
+
+char SparseMatrix :: Used (INDEX i, INDEX j) const
+  {
+  if (Symmetric() && j > i) ng_swap (i, j);
+
+  if (i < 1 || i > height) return 0;
+
+  const colstruct * col = lins.Get(i).col;
+  INDEX max = lins.Get(i).size;
+
+  for (int k = 0; k < max; k++, col++)
+    if (col->colnr == j) return 1;
+
+  return 0;
+  }
+
+
+
+double SparseMatrix :: Get(INDEX i, INDEX j) const
+  {
+  if (Symmetric() && j > i) ng_swap (i, j);
+
+  const colstruct * col = lins.Get(i).col;
+  INDEX max = lins.Get(i).size;
+
+  int l = 0, k = 1, newind;
+
+  while (k < max)
+    k <<= 1;
+
+
+  while (k > 0)
+    {
+    k >>= 1;
+    newind = k+l;
+    if (newind >= max) continue;
+    if (col[newind].colnr <= j)
+      l += k;
+    }
+
+  if (l < max && col[l].colnr == j) return col[l].data;
+
+  return 0;
+
+  /*
+  for (INDEX k = 0; k < max; k++, col++)
+    if (col->colnr == j) 
+      {
+	if (l != k) cerr << "Set: ind not ok" << endl;
+        else cerr << "is ok" << endl;
+      return col->data;
+      }
+
+  return 0;
+  */
+  }
+
+
+void SparseMatrix :: Set(INDEX i, INDEX j, double v)
+  {
+  Elem (i, j) = v;
+  }
+
+
+
+double & SparseMatrix :: Elem(INDEX i, INDEX j)
+  {
+  if (Symmetric() && j > i) ng_swap (i, j);
+
+  linestruct * lin = &lins.Elem(i);
+  colstruct * col, *ncol;
+
+  int size = lin->size;
+  int pos;
+
+  if (size)
+    {
+
+    // bereits Elemente in der Liste
+
+    if (j > lin->col[size-1].colnr)
+      {
+
+      // neues Element an letzter Position einfuegen
+
+      if (lin->maxsize > size)
+        {
+        lin->size++;
+        lin->col[size].colnr = j;
+        return lin->col[size].data = 0;
+        }
+
+      if ( (ncol = NewColStruct(lin->maxsize+4)/* new colstruct[lin->maxsize+4] */) != NULL)
+        {
+        memcpy (ncol, lin->col, sizeof(colstruct) * size);
+
+        DeleteColStruct (lin->col, lin->maxsize);
+
+        lin->maxsize += 4;
+        lin->col = ncol;
+        lin->size++;
+        ncol[size].colnr = j;
+        return ncol[size].data = 0;
+        }
+      else
+        {
+//        myerr << "SparseMatrix::Elem: Out of memory 1" << endl;
+        return shit;
+        }
+
+      }
+    else
+      {
+
+      for (col = lin->col; col->colnr < j; col++);
+                                        // Zeilenliste durchsuchen
+
+      if (col->colnr == j) return col->data;
+                                        // Element exisitiert bereits
+
+      if (lin->maxsize > size)
+        {
+        memmove (col+1, col, size_t((char*)&lin->col[size] - (char*)col));
+
+        lin->size++;
+        col->colnr = j;
+        return col->data = 0;
+        }
+
+      pos = size_t (col - lin->col);
+
+      if ( (ncol = NewColStruct(lin->maxsize+4) ) != NULL)
+        {
+
+        if (pos) memcpy (ncol, lin->col, sizeof(colstruct) * pos);
+        memcpy (ncol+(pos+1), col, sizeof(colstruct) * (size-pos));
+
+        DeleteColStruct (lin->col, lin->maxsize);
+//        delete lin->col;
+
+        lin->maxsize += 4;
+        lin->col = ncol;
+        lin->size++;
+        ncol[pos].colnr = j;
+        return ncol[pos].data = 0;
+        }
+      else
+        {
+//        myerr << "SparseMatrix::Elem: Out of memory 2" << endl;
+        return shit;
+        }
+      }
+    }
+  else
+    {
+    // kein Element in der Liste
+
+    if (lin->maxsize)
+      {
+      // Liste bereits angelegt
+
+      lin->size = 1;
+      lin->col->colnr = j;
+      return lin->col->data = 0;
+      }
+    else
+      {
+      if ( (lin->col = NewColStruct(6) ) != NULL )
+        {
+        lin->maxsize = 6;
+        lin->size = 1;
+        lin->col->colnr = j;
+        return lin->col->data = 0;
+        }
+      else
+        {
+//        myerr << "SparseMatrix::Elem: Out of memory 3" << endl;
+        return shit;
+        }
+      }
+    }
+  }
+
+
+
+void SparseMatrix :: Delete (INDEX i, int nr)
+  {
+  colstruct * col = lins[i].col;
+
+  nr--;
+  while (nr < lins[i].size-1)
+    {
+    col[nr].data = col[nr+1].data;
+    col[nr].colnr = col[nr+1].colnr;
+    nr++;
+    }
+  lins[i].size--;
+  }
+
+void SparseMatrix :: DeleteElem (INDEX i, INDEX j)
+  {
+  int nr;
+  int dec = 0;
+
+  if (Symmetric() && j > i) ng_swap (i, j);
+
+  colstruct * col = lins[i].col;
+
+  for (nr = 0; nr < lins[i].size; nr++)
+    {
+    if (dec)
+      {
+      col[nr-1].data = col[nr].data;
+      col[nr-1].colnr = col[nr].colnr;
+      }
+    if (col[nr].colnr == j) dec = 1;
+    }
+  if (dec)
+    lins[i].size--;
+  }
+
+
+void SparseMatrix :: SetLineAllocSize (INDEX i, int j)
+  {
+  colstruct * ncol;
+
+
+  if (lins[i].maxsize < j)
+    {
+    if ( (ncol = NewColStruct(j)) != NULL)
+      {
+      memcpy (ncol, lins[i].col, sizeof(colstruct) * lins[i].size);
+
+      if (lins[i].maxsize)
+        DeleteColStruct (lins[i].col, lins[i].maxsize);
+
+      lins[i].maxsize = j;
+      lins[i].col = ncol;
+      }
+    else
+//      myerr << "SPARSE_MATIRX :: SetLineAllocSize: Out of Memory" << endl;
+    }
+  }
+
+
+
+
+
+
+
+
+
+  
+  
+
+
+
+SparseMatrix operator* (const SparseMatrix & m1,
+                         const SparseMatrix & m2)
+  {
+  SparseMatrix m(m1.Height(), m2.Width());
+  INDEX i, j, k, nr;
+
+  if (!m1.Symmetric() && !m2.Symmetric())
+    {
+    for (i = 1; i <= m1.Height(); i++)
+      {
+      for (j = 1; j <= m1.ElementsInLine(i); j++)
+        {
+        nr = m1.GetIndex (i, j);
+        for (k = 1; k <= m2.ElementsInLine(nr); k++)
+          {
+          m(i, m2.GetIndex(nr, k)) += m1.GetData(i, j) * m2.GetData(nr, k);
+          }
+        }
+      }
+    }
+  else
+    {
+//    myerr << "SparseMatrix :: operator* not implemented for symmetric case" << endl;
+    }
+  return m;
+  }
+
+
+SparseMatrix & SparseMatrix :: operator+= (const SparseMatrix & m2)
+  {
+  INDEX i, k;
+  int j;
+
+  if (Symmetric() == m2.Symmetric())
+    {
+    for (i = 1; i <= Height(); i++)
+      for (j = 1; j <= m2.ElementsInLine (i); j++)
+        {
+        k = m2.GetIndex (i, j);
+        Elem(i, k) += m2.GetData (i, j);
+        }
+    }
+  else
+    {
+//    myerr << "SparseMatrix :: operator+= not implemented for different cases" << endl;
+		;
+    }
+  return *this;
+  }
+
+
+
+SparseMatrix & SparseMatrix :: operator*= (const SparseMatrix & m2)
+  {
+  INDEX i, k;
+  int j, l;
+  colstruct * cs;
+  int ms, s;
+
+  if (!Symmetric() && !m2.Symmetric())
+    {
+    for (i = 1; i <= Height(); i++)
+      {
+      cs = lins[i].col;
+      s = lins[i].size;
+      ms = lins[i].maxsize;
+
+      lins[i].col = NULL;
+      lins[i].size = 0;
+      lins[i].maxsize = 0;
+
+
+      for (j = 0; j < s; j++)
+        {
+        k = cs[j].colnr;
+
+        for (l = 1; l <= m2.ElementsInLine (k); l++)
+          Elem(i, m2.GetIndex(k, l)) += cs[j].data * m2.GetData(k, l);
+        }
+
+      DeleteColStruct (cs, ms);
+      }
+    }
+  else
+    {
+//    myerr << "SparseMatrix :: operator*= not implemented for Symmetric matrices" << endl;
+		;
+    }
+
+  return *this;
+  }
+
+
+void SparseMatrix :: Solve (const Vector & v, Vector & sol) const
+  {
+  SparseMatrix temp = *this;
+  INDEX i, j, nr, k;
+  double q;
+
+  sol = v;
+
+
+  if (!Symmetric())
+    {
+    for (i = 1; i <= Height(); i++)
+      {
+      if (temp.ElementsInLine(i) < 1 || temp.GetIndex(i, 1) != i)
+        {
+//        myerr << "i = " << i << endl;
+//        myerr << "Solve: Matrix singular" << endl;
+        char ch;
+        cin >> ch;
+        }
+      for (j = 2; j <= temp.ElementsInLine(i); j++)
+        {
+        nr = temp.GetIndex(i, j);
+        if (temp.GetIndex(nr, 1) != i)
+          {
+//          myerr << temp << endl;
+//          myerr << "i = " << i << "j = " << j << "nr = " << nr << endl;
+//          myerr << "Solve: Graph not symmetrix" << endl;
+          char ch;
+          cin >> ch;
+          }
+
+        q = temp.GetData (nr, 1) / temp.GetData(i, 1);
+        temp.Delete (nr, 1);
+
+        for (k = 2; k <= temp.ElementsInLine (i); k++)
+          temp.Elem(nr, temp.GetIndex(i, k)) -= q * temp.GetData(i, k);
+
+        sol(nr) -= q * sol(i);
+        }
+      }
+
+    for (i = temp.Height(); i >= 1; i--)
+      {
+      for (j = 2; j <= temp.ElementsInLine(i); j++)
+        {
+        sol(i) -= temp.GetData(i, j) * sol(temp.GetIndex(i, j));
+        }
+      sol(i) /= temp.GetData(i, 1);
+      }
+    }
+//  else
+//    myerr << "SparseMatrix :: Solve not implemented for symmetic case" << endl;
+  }
+
+
+
+
+
+void Transpose (const SparseMatrix & m1, SparseMatrix & m2)
+  {
+  INDEX i, j;
+
+  m2.SetSize(m1.Width(), m1.Height());
+  m2.SetSymmetric(m1.Symmetric());
+
+  if (!m1.Symmetric())
+    {
+    for (i = 1; i <= m1.Height(); i++)
+      for (j = 1; j <= m1.ElementsInLine(i); j++)
+        m2(m1.GetIndex(i, j), i) = m1.GetData(i, j);
+    }
+  else
+    m2 = m1;
+  }
+
+
+
+BaseMatrix * SparseMatrix :: Copy () const
+  {
+  return new SparseMatrix (*this);
+  }
+
+
+
+
+
+
+
+void SparseMatrix :: AddRowMatrix (INDEX row, const SparseMatrix & m2)
+  {
+  int i1, i2, i;
+  colstruct * cs1, * cs2, * ncs;
+  int s1, s2, s;
+
+  s1 = lins[row].size;
+  s2 = m2.lins[1].size;
+  cs1 = lins[row].col;
+  cs2 = m2.lins[1].col;
+
+  i1 = 0;
+  i2 = 0;
+  i = 0;
+
+
+  if (Symmetric())
+    {
+    while (s2 && cs2[s2-1].colnr > row) s2--;
+    }
+
+
+  while (i1 < s1 && i2 < s2)
+    {
+    if (cs1[i1].colnr < cs2[i2].colnr) i1++;
+    else if (cs1[i1].colnr > cs2[i2].colnr) i2++;
+    else { i1++; i2++; }
+    i++;
+    }
+
+  i += (s1 - i1);
+  i += (s2 - i2);
+
+  s = i;
+
+  if (s > s1)
+    {
+    ncs = NewColStruct (s);
+
+    i1 = 0;
+    i2 = 0;
+    i = 0;
+
+    while (i1 < s1 && i2 < s2)
+      {
+      if (cs1[i1].colnr < cs2[i2].colnr)
+        {
+        ncs[i].colnr = cs1[i1].colnr;
+        ncs[i].data = cs1[i1].data;
+        i1++;
+        }
+      else if (cs1[i1].colnr > cs2[i2].colnr)
+        {
+        ncs[i].colnr = cs2[i2].colnr;
+        ncs[i].data = cs2[i2].data;
+        i2++;
+        }
+      else
+        {
+        ncs[i].colnr = cs1[i1].colnr;
+        ncs[i].data = cs1[i1].data + cs2[i2].data;
+        i1++;
+        i2++;
+        }
+      i++;
+      }
+
+    while (i1 < s1)
+      {
+      ncs[i].colnr = cs1[i1].colnr;
+      ncs[i].data = cs1[i1].data;
+      i1++;
+      i++;
+      }
+
+    while (i2 < s2)
+      {
+      ncs[i].colnr = cs2[i2].colnr;
+      ncs[i].data = cs2[i2].data;
+      i2++;
+      i++;
+      }
+
+    if (lins[row].maxsize)
+      DeleteColStruct (cs1, lins[row].maxsize);
+
+    lins[row].col = ncs;
+    lins[row].size = s;
+    lins[row].maxsize = s;
+    }
+
+
+  else
+    {
+    i1 = 0;
+    i2 = 0;
+
+    while (i2 < s2)
+      {
+      if (cs1[i1].colnr == cs2[i2].colnr)
+        {
+        cs1[i1].data += cs2[i2].data;
+        i2++;
+        }
+      i1++;
+      }
+    }
+  }
+
+
+double SparseMatrix :: RowTimesVector (INDEX i, const Vector & v) const
+  {
+  const linestruct * lin;
+  const colstruct * col;
+  double sum;
+  int j;
+
+  if (Width() > v.Length())
+    {
+    cerr << "SparseMatrix::RowTimesVector: Size doesn't fit" << endl;
+    return 0;
+    }
+
+  lin = &lins.Get(i);
+  sum = 0;
+  col = lin->col;
+
+  for (j = lin->size; j > 0; j--, col++)
+    sum += col->data * v.Get(col->colnr);
+
+  return sum;
+  }
+  
+void SparseMatrix :: AddRowToVector (INDEX i, double s, Vector & v) const
+  {
+  const linestruct * lin;
+  const colstruct * col;
+  int j;
+
+  if (Width() > v.Length())
+    {
+    cerr << "SparseMatrix::AddRowToVector: Size doesn't fit" 
+    	 << "w = " << Width() << " len = " << v.Length() << endl;
+    return;
+    }
+
+  lin = &lins.Get(i);
+  col = lin->col;
+
+  for (j = lin->size; j > 0; j--, col++)
+    v.Elem(col->colnr) += s * col->data;
+  }
+
+
+static ARRAY<void*> poolarray;
+static ARRAY<int> poolsizes;
+
+
+SparseMatrix::colstruct * SparseMatrix :: NewColStruct (int s)
+  {
+//  return new colstruct[s];
+
+
+  int i, j;
+  void * p;
+  colstruct * cs;
+
+  if (s > 20) return new colstruct[s];
+
+  for (i = 1; i <= poolsizes.Size(); i++)
+    if (poolsizes.Get(i) == s) break;
+
+  if (i > poolsizes.Size())
+    {
+    poolsizes.Append(s);
+    poolarray.Append((void*)NULL);
+    i = poolsizes.Size();
+    }
+
+  p = poolarray.Get(i);
+  if (!p)
+    {
+    poolarray.Elem(i) = p = cs = new colstruct[10 * s];
+    for (j = 0; j < 9; j++)
+      *(void**)(void*)(&cs[s * j]) = &cs[s * (j+1)];
+    *(void**)(void*)(&cs[s * 9]) = NULL;
+    }
+
+  poolarray.Elem(i) = *(void**)p;
+  return (colstruct*)p;
+  }
+
+void SparseMatrix :: DeleteColStruct (colstruct * cs, int s)
+  {
+//  delete cs;
+//  return;
+
+  int i;
+
+  if (s > 20)
+    {
+    delete cs;
+    return;
+    }
+
+  for (i = 1; i <= poolsizes.Size(); i++)
+    if (poolsizes.Get(i) == s) break;
+
+
+  if (i > poolsizes.Size())
+    {
+//    myerr << "SparseMatrix :: DeleteColStruct: Size not found" << endl;
+    return;
+    }
+
+
+  *(void**)(void*)cs = poolarray.Get(i);
+  poolarray.Elem(i) = cs;
+  }
+
+void SparseMatrix :: SetGraph (const class TABLE<INDEX> & graph)
+  { 
+  int i, j, es, ad, nne;
+  colstruct * block;
+  
+  nne = 0;
+  for (i = 1; i <= graph.Size(); i++)
+    {
+    if (Symmetric())
+      {
+      es = 0;
+      for (j = 1; j <= graph.EntrySize(i); j++)
+        if (graph.Get(i, j) <= i)
+          es++;
+      }
+    else
+      es = graph.EntrySize(i);
+    nne += es;
+    }
+    
+  oneblock = 1;
+  block = new colstruct[nne];
+  
+  ad = 0;
+  for (i = 1; i <= graph.Size(); i++)
+    {
+    if (Symmetric())
+      {
+      es = 0;
+      for (j = 1; j <= graph.EntrySize(i); j++)
+        if (graph.Get(i, j) <= i)
+          es++;
+      }
+    else
+      es = graph.EntrySize(i);
+      
+    lins.Elem(i).size = 0;
+    lins.Elem(i).maxsize = es;
+    lins.Elem(i).col = &block[ad];
+    ad += es;
+    }
+  }
+
+
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/sparsmat.hh ug-patched/gm/gg3/netgen/linalg/sparsmat.hh
--- ug-orig/gm/gg3/netgen/linalg/sparsmat.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/sparsmat.hh	1998-04-20 19:12:12.000000000 +0200
@@ -0,0 +1,260 @@
+#ifndef FILE_SPARSMAT
+#define FILE_SPARSMAT
+
+/* *************************************************************************/
+/* File:   sparsmat.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Oct. 94                                                    */
+/* *************************************************************************/
+
+#include"../general/bitarray.hh"
+
+/** 
+  The graph of a sparse matrix.
+  The graph is stored for a non-symmetric matrix
+*/
+class MatrixGraph
+{
+  /// data structure for one row of matrix
+  struct linestruct 
+  { 
+    /// allocated size
+    int allocsize;    
+    /// used size
+    int size;    
+    /// diag element (always allocated)      
+    int diag;  
+    /// colume numbers  
+    INDEX* col;
+  };
+
+  /// graph of matrix
+  ARRAY<linestruct> lines;
+  /// increment of allocated line-memory on overflow
+  int increment;
+  
+public:
+  //@{ @name Constructors, Destructor
+
+  /// Height of matrix, increment value for line-overflow
+  MatrixGraph (int size, int aincrement = 5);
+  /// Allocates graph with elements per row given in ARRAY linesize
+  MatrixGraph (const ARRAY<int> & linesize);
+  //@}
+
+  
+  /// returns position of Element (i, j), 0 for unused
+  int GetPosition (INDEX i, INDEX j) const;
+
+  /// returns position of new element
+  int CreatePosition (INDEX i, INDEX j); 
+
+  /// Returns height of matrix
+  int Size() const { return lines.Size(); }
+
+
+  friend class SparseMatrix;
+  friend class SparseMatrixFlex;
+  friend class SparseMatrixFix;
+  friend class PointJacobiPrecond;
+};
+
+
+
+
+
+
+/**
+  Base class for sparse matrix.
+  Matrix to work with in most applications
+  */
+class SparseMatrix : public BaseMatrix
+{
+protected:
+  /// graph of matrix
+  const MatrixGraph * graph;
+  /// pointer to matrix values in each row
+  ARRAY<double*> data;
+
+public:
+
+  /// returns reference, fail save but slow
+  virtual double & operator() (INDEX i, INDEX j);
+  /// returns value, fail save but slow
+  virtual double operator() (INDEX i, INDEX j) const;
+
+
+  /// prod = matrix x v
+  virtual void Mult (const BaseVector & v, BaseVector & prod) const;
+  /// prod = matrix^T x v
+  virtual void MultTrans (const BaseVector & v, BaseVector & prod) const;
+  /// res = b - mat x x
+  virtual void Residuum (const BaseVector & x, const BaseVector & b, 
+			 BaseVector & res) const;
+  /// res = b - mat^T x x
+  virtual void ResiduumTrans (const BaseVector & x, const BaseVector & b,
+			      BaseVector & res) const;
+
+
+  /**
+    Add element matrix to sparse matrix.
+    The graph of the element-matrix must be symmetric.
+    Global point numbers are given in pnum.
+   */
+  virtual void AddElementMatrix (const ARRAY<INDEX> & pnum, const BaseMatrix & elemmat);
+
+  /// for multigrid-extension, should be removed from here
+  void GSStepToInner (const Vector & b, Vector & x, double dump,
+      const BitArray & inner) const;
+
+  /// for multigrid-extension, should be removed from here
+  void GSStepBackToInner (const Vector & b, Vector & x, double dump,
+      const BitArray & inner) const;
+
+  /// 
+  virtual ostream & Print (ostream & s) const;
+
+  /** Scalar product of i-th row times vector.
+    For symmetric matrices only lower left block 
+    (including diagonal) is used.
+    */
+  double RowTimesVector (INDEX i, const Vector & v) const;
+  /** Adds s times the i-th row of matrix to vector v.
+    For symmetric matrices only lower left block 
+    (including diagonal) is used.
+    */
+  void AddRowToVector (INDEX i, double s, Vector & v) const;
+
+  /** Number of elements in line.
+    For symmetric matrices GetDiagPos must be used for
+    most purposes.
+    */
+  int ElementsInLine (INDEX i) const 
+    { return graph->lines.Get(i).size; }
+
+  /** Columne index of nr-th non-zero element in row i */
+  INDEX GetColIndex (INDEX i, int nr) const
+    { return graph->lines.Get(i).col[nr-1]; }
+
+  /** Referece to columne index of nr-th non-zero 
+    element in row i */
+  const INDEX & GetColIndexRef (INDEX i, int nr) const
+    { return graph->lines.Get(i).col[nr-1]; }
+
+  /** Value of nr-th non-zero element in row i */
+  double GetData (INDEX i, int nr) const 
+    { return data.Get(i)[nr-1]; }
+
+  /** Reference to value of nr-th non-zero element in row i */
+  const double & GetDataRef (INDEX i, int nr) const
+    { return data.Get(i)[nr-1]; }
+
+  /** Returns value of diagonal element in row i */
+  double GetDiag (INDEX i) const 
+    { return data.Get(i)[graph->lines.Get(i).diag-1]; }
+
+  /** Which position has diagonal element in row i ? */
+  int GetDiagPos (INDEX i) const
+    { return graph->lines.Get(i).diag; }
+
+  /** Returns matrix value of row i, col j.
+    For symmetric matrices the indices will be sorted in
+    this function */
+  double Get(INDEX i, INDEX j) const;
+
+  /** Set value of element (i, j) to v.
+    For symmetric matrices element (j, i) is set. */
+  void Set(INDEX i, INDEX j, double v);
+
+  /** Returns reference to element (i, j).
+    For symmetric matrices a reference to (j, i) is returned */
+  double & Elem(INDEX i, INDEX j);
+
+  /** Is element (i, j) used ? */
+  char Used (INDEX i, INDEX j) const;
+
+protected:
+  /// A sparse matrix must not be constructed
+  SparseMatrix (INDEX h, INDEX w = 0);
+  /// Allocates matrix position
+  virtual int CreatePosition (INDEX i, INDEX j) = 0;
+
+private:
+  ///
+  friend class ScalarBlockJacobiPrecond;
+  friend class PointJacobiPrecond;
+};
+
+
+
+
+/** Sparse matrix with flexible graph.
+  On demand, a matrix position is allocated */
+class SparseMatrixFlex : public SparseMatrix
+{ 
+ /// non-const pointer to graph.
+ MatrixGraph * mygraph;
+
+public:
+  ///
+  SparseMatrixFlex ();
+  ///
+  SparseMatrixFlex (INDEX h, INDEX w = 0);
+  ///
+  SparseMatrixFlex (const SparseMatrix & m2);
+  ///
+  virtual ~SparseMatrixFlex ();
+
+  /// 
+  virtual void SetSize (INDEX h, INDEX w = 0);
+  ///
+  virtual void SetSymmetric (int sym = 1);
+  ///
+  virtual void ChangeSize (INDEX h, INDEX w = 0);
+  ///
+  void DeleteElements ();
+
+
+  ///
+  SparseMatrix & operator= (const SparseMatrix & m2);
+  ///
+  SparseMatrix & operator*= (double v);
+
+
+  ///
+  virtual BaseMatrix * Copy () const;
+  ///
+  void Delete (INDEX i, int nr);
+  ///
+  void DeleteElem (INDEX i, INDEX j);
+
+  ///
+  void SetLineAllocSize (INDEX i, int j);
+
+protected:
+  ///
+  virtual int CreatePosition (INDEX i, INDEX j);
+
+};
+
+
+
+
+/** Sparse matrix with fixed graph.
+  After construction of the matrix, the graph
+  must not be changed. */
+class SparseMatrixFix : public SparseMatrix
+{
+public:
+  ///
+  SparseMatrixFix (const MatrixGraph & agraph, int asymmetric = 0);
+  ///
+  virtual ~SparseMatrixFix ();
+  
+protected:
+  /// CreatePosition is not allowed for SparseMatrixFix -> error
+  virtual int CreatePosition (INDEX i, INDEX j);
+};
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/linalg/vector.cc ug-patched/gm/gg3/netgen/linalg/vector.cc
--- ug-orig/gm/gg3/netgen/linalg/vector.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/vector.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,769 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <string.h>
+#include <math.h>
+
+#include <template.hh>
+#include <myadt.hh>
+#include <linalg/linalg.hh>
+
+
+//extern ofstream myerr;
+
+
+double BaseVector :: shit = 0;
+
+// %FD Constructs a vector of length zero
+BaseVector :: BaseVector ()
+  {
+  length = 0;
+  }
+
+// %FD Constructs a vector of given length
+BaseVector :: BaseVector (
+    INDEX alength  // length of the vector
+    )
+  {
+  length = alength;
+  }
+
+// %FD Sets length of the vector, old vector will be destroyed
+void
+BaseVector :: SetLength (
+    INDEX alength        // new length of the vector
+    )
+  {
+  length = alength;
+  }
+
+// %FD Changes length of the vector, old values stay valid
+void
+BaseVector :: ChangeLength (
+    INDEX alength        // new length of the vector
+    )
+  {
+  length = alength;
+  }
+
+
+
+// %FD { Write a vector with the help of the '<<' operator onto a stream }
+ostream &    // stream for further use
+operator<< (
+    ostream & s,            // stream to write vector onto
+    const BaseVector & v   // vector to write
+    )
+  {
+  return v.Print (s);
+  }
+
+
+// %FD{ Divides every component of the vector by the scalar c.
+//      The function checks for division by zero }
+BaseVector &      // result vector
+BaseVector :: operator/= (
+    double c       // scalar to divide by
+    )
+  {
+  if (c)
+    return (*this) *= (1/c);
+  else
+    {
+//    myerr << "operator/=: division by zero" << endl;
+    return *this;
+    }
+  }
+
+
+// %FD Creates a copy of the object
+BaseVector *      // pointer to the new vector
+BaseVector :: Copy () const
+  {
+  cerr << "Base_vector::Copy called" << endl << flush;
+  return NULL;
+  }
+
+
+
+
+void BaseVector :: GetElementVector (const ARRAY<INDEX> & pnum,
+				 BaseVector & elvec) const
+{
+  int i;
+  for (i = 1; i <= pnum.Size(); i++)
+    elvec(i) = (*this)(pnum.Get(i));
+}
+
+void BaseVector :: SetElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec)
+{
+  int i;
+  for (i = 1; i <= pnum.Size(); i++)
+    (*this)(pnum.Get(i)) = elvec(i);
+}
+
+
+void BaseVector :: AddElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec)
+{
+  int i;
+  for (i = 1; i <= pnum.Size(); i++)
+    (*this)(pnum.Get(i)) += elvec(i);
+}
+
+
+
+
+
+
+
+
+
+
+
+TempVector :: ~TempVector ()
+  {
+  delete vec;
+  }
+
+TempVector BaseVector :: operator+ (const BaseVector & v2) const
+  {
+  return (*Copy()) += v2;
+  }
+
+TempVector BaseVector :: operator- (const BaseVector & v2) const
+  {
+  return (*Copy()) -= v2;
+  }
+
+TempVector BaseVector :: operator- () const
+  {
+  return (*Copy()) *= -1;
+  }
+
+
+TempVector operator* (const BaseVector & v1, double scal) 
+  {
+  return (*v1.Copy()) *= scal;
+  }
+
+TempVector operator/ (const BaseVector & v1, double scal) 
+  {
+  return (*v1.Copy()) /= scal;
+  }
+
+
+TempVector operator* (double scal, const BaseVector & v1)
+  {
+  return v1 * scal;
+  }
+
+
+
+
+
+BaseVector * TempVector :: Copy () const
+  {
+  return vec->Copy();
+  }
+
+
+
+
+
+
+
+
+
+
+double Vector :: shit = 0;
+
+static ARRAY<double *> vecpool;
+static ARRAY<INDEX> poolveclen;
+
+static double * NewDouble (INDEX len)
+{
+  if (len < 10)
+    return new double[len];
+  else
+    {
+      int i;
+      for (i = 1; i <= poolveclen.Size(); i++)
+	if (poolveclen.Get(i) == len)
+	  {
+	    double * hvec = vecpool.Get(i);
+	    vecpool.DeleteElement(i);
+	    poolveclen.DeleteElement(i);
+	    return hvec;
+	  }
+
+      return new double[len];
+    }
+}
+
+static void DeleteDouble (INDEX len, double * dp)
+{
+  if (len < 10)
+    delete dp;
+  else
+    {
+      vecpool.Append (dp);
+      poolveclen.Append (len);
+    }
+}
+
+
+
+Vector :: Vector () : BaseVector()
+  {
+  data = NULL;
+  }
+
+Vector :: Vector (INDEX alength) : BaseVector (alength)
+  {
+  if (length)
+    {
+      //    data = new double[length];
+      data = NewDouble (length);
+
+    if (!data)
+      {
+      length = 0;
+//      myerr << "Vector not allocated" << endl;
+      }
+    }
+  else
+    data = NULL;
+  }
+
+
+Vector :: Vector (const Vector & v2)
+  {
+  length = v2.length;
+
+  if (length)
+    {
+      //    data = new double[length];
+      data = NewDouble (length);
+
+    if (data)
+      {
+      memcpy (data, v2.data, length * sizeof (double));
+      }
+    else
+      {
+      length = 0;
+//      myerr << "Vector::Vector : Vector not allocated" << endl;
+      }
+    }
+  else
+    data = NULL;
+  }
+
+
+Vector :: ~Vector ()
+{
+  //  veclenfile << "~Vector delete: " << length << endl;
+  if (data) 
+    {
+      DeleteDouble (length, data);
+      //      delete [] data;
+    }
+
+}
+
+void Vector :: SetLength (INDEX alength)
+  {
+  if (length == alength) return;
+
+  if (data) 
+    {
+      DeleteDouble (length, data);
+      //      delete [] data;
+    }
+  data = NULL;
+  length = alength;
+
+  if (length == 0) return;
+  //  data = new double[length];
+  data = NewDouble (length);
+
+  if (!data)
+    {
+    length = 0;
+//    myerr << "Vector::SetLength: Vector not allocated" << endl;
+    }
+  }
+
+void Vector :: ChangeLength (INDEX alength)
+  {
+    cout << "Vector::ChangeLength called" << endl;
+  if (length == alength) return;
+
+  if (alength == 0)
+    {
+      //    delete [] data;
+    DeleteDouble (length, data);
+    length = 0;
+    return;
+    }
+
+  double * olddata = data;
+
+  data = NewDouble (alength);
+  //  data = new double[alength];
+  if (!data)
+    {
+    length = 0;
+//    myerr << "Vector::SetLength: Vector not allocated" << endl;
+    delete [] olddata;
+    }
+
+  memcpy (data, olddata, ng_min(alength, length));
+
+  delete [] olddata;
+  length = alength;
+  }
+
+/// NEW RM
+void Vector::SetBlockLength (INDEX /* blength */)
+{
+  MyError("BaseVector::SetBlockLength was called for a Vector");
+}
+
+
+double & Vector :: operator() (INDEX i)
+  {
+  if (i >= 1 && i <= length) return Elem(i);
+//  else myerr << "\nindex " << i << " out of range ("
+//                                << 1 << "," << Length() << ")\n";
+  return shit;
+  }
+
+double Vector :: operator() (INDEX i) const
+  {
+  if (i >= 1 && i <= length) return Get(i);
+//  else myerr << "\nindex " << i << " out of range ("
+//                                << 1 << "," << Length() << ")\n" << flush;
+  return shit;
+  }
+
+
+
+double Vector :: SupNorm () const
+  {
+  double sup = 0;
+
+  for (INDEX i = 1; i <= Length(); i++)
+    if (fabs (Get(i)) > sup)
+      sup = fabs(Get(i));
+
+  return sup;
+  }
+
+double Vector :: L2Norm () const
+  {
+  double sum = 0;
+
+  for (INDEX i = 1; i <= Length(); i++)
+    sum += Get(i) * Get(i);
+
+  return sqrt (sum);
+  }
+
+double Vector :: L1Norm () const
+  {
+  double sum = 0;
+
+  for (INDEX i = 1; i <= Length(); i++)
+    sum += fabs (Get(i));
+
+  return sum;
+  }
+
+double Vector :: Max () const
+  {
+  if (!Length()) return 0;
+  double m = Get(1);
+  for (INDEX i = 2; i <= Length(); i++)
+    if (Get(i) > m) m = Get(i);
+  return m;
+  }
+
+double Vector :: Min () const
+  {
+  if (!Length()) return 0;
+  double m = Get(1);
+  for (INDEX i = 2; i <= Length(); i++)
+    if (Get(i) < m) m = Get(i);
+  return m;
+  }
+
+
+/*
+ostream & operator<<(ostream & s, const Vector & v)
+  {
+  int w = s.width();
+  if (v.Length())
+    {
+    s.width(0);
+    s << '(';
+    for (INDEX i = 1; i < v.Length(); i++)
+      {
+      s.width(w);
+      s << v.Get(i) << ",";
+      if (i % 8 == 0) s << endl << ' ';
+      }
+    s.width(w);
+    s << v.Get(v.Length()) << ')';
+    }
+  else
+    s << "(Vector not allocated)";
+
+  return s;
+  }
+*/
+
+ostream & Vector :: Print (ostream & s) const
+  {
+  int w = s.width();
+  if (Length())
+    {
+    s.width(0);
+    s << '(';
+    for (INDEX i = 1; i < Length(); i++)
+      {
+      s.width(w);
+      s << Get(i) << ",";
+      if (i % 8 == 0) s << endl << ' ';
+      }
+    s.width(w);
+    s << Get(Length()) << ')';
+    }
+  else
+    s << "(Vector not allocated)";
+
+  return s;
+  }
+
+
+
+BaseVector & Vector :: operator+= (const BaseVector & v2)
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  if (Length() == hv2.Length())
+    for (INDEX i = 1; i <= Length(); i++)
+      Elem (i) += hv2.Get(i);
+//  else
+//    myerr << "operator+= illegal dimension" << endl;
+  return *this;
+  }
+
+BaseVector & Vector :: operator-= (const BaseVector & v2)
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  if (Length() == hv2.Length())
+    for (INDEX i = 1; i <= Length(); i++)
+      Elem (i) -= hv2.Get(i);
+//  else
+//    myerr << "operator-= illegal dimension" << endl;
+  return *this;
+  }
+
+BaseVector & Vector :: operator*= (double c)
+  {
+  for (INDEX i = 1; i <= Length(); i++)
+    Elem(i) *= c;
+  return *this;
+  }
+
+
+
+BaseVector & Vector :: Add (double scal, const BaseVector & v2)
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  if (Length() == hv2.Length())
+    {
+    double * p1 = data;
+    double * p2 = hv2.data;
+
+    for (INDEX i = Length(); i > 0; i--)
+      {
+      (*p1) += scal * (*p2);
+      p1++; p2++;
+      }
+    }
+//  else
+//    myerr << "Vector::Add: illegal dimension" << endl;
+  return *this;
+  }
+
+BaseVector & Vector :: Add (double scal, const BaseVector & v2,
+                             double scal3, const BaseVector & v3)
+  {
+  const Vector & hv2 = v2.CastToVector();
+  const Vector & hv3 = v3.CastToVector();
+
+  if (Length() == hv2.Length())
+    {
+    double * p1 = data;
+    double * p2 = hv2.data;
+    double * p3 = hv3.data;
+
+    for (INDEX i = Length(); i > 0; i--)
+      {
+      (*p1) += (scal * (*p2) + scal3 * (*p3));
+      p1++; p2++; p3++;
+      }
+    }
+//  else
+//    myerr << "Vector::Add: illegal dimension" << endl;
+  return *this;
+  }
+
+BaseVector & Vector :: Set (double scal, const BaseVector & v2)
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  if (Length() == hv2.Length())
+    {
+    double * p1 = data;
+    double * p2 = hv2.data;
+
+    for (INDEX i = Length(); i > 0; i--)
+      {
+      (*p1) = scal * (*p2);
+      p1++; p2++;
+      }
+    }
+//  else
+//    myerr << "Vector::Set: illegal dimension" << endl;
+  return *this;
+  }
+
+
+BaseVector & Vector :: Set (double scal , const BaseVector & v2,
+      double scal3, const BaseVector & v3)
+  {
+  const Vector & hv2 = v2.CastToVector();
+  const Vector & hv3 = v3.CastToVector();
+
+
+  if (Length() == hv2.Length())
+    {
+    double * p1 = data;
+    double * p2 = hv2.data;
+    double * p3 = hv3.data;
+
+    for (INDEX i = Length(); i > 0; i--)
+      {
+      (*p1) = scal * (*p2) + scal3 * (*p3);
+      p1++; p2++; p3++;
+      }
+    }
+//  else
+//    myerr << "Vector::Set: illegal dimension" << endl;
+  return *this;
+  }
+
+
+void Vector :: GetPart (int startpos, BaseVector & v2) const
+{
+  Vector & hv2 = v2.CastToVector();
+
+  if (Length() >= startpos + v2.Length() - 1)
+    {
+      const double * p1 = &Get(startpos);
+      double * p2 = &hv2.Elem(1);
+      
+      memcpy (p2, p1, hv2.Length() * sizeof(double));
+    }
+  else
+    MyError ("Vector::GetPart: Vector to short");
+}
+
+
+// NEW RM
+void Vector :: SetPart (int startpos, const BaseVector & v2)
+{
+  const Vector & hv2 = v2.CastToVector();
+  INDEX i;
+  INDEX n = v2.Length();
+
+  if (Length() >= startpos + n - 1)
+    {
+      double * p1 = &Elem(startpos);
+      const double * p2 = &hv2.Get(1);
+
+      for (i = 1; i <= n; i++)
+	{
+	  (*p1) = (*p2);
+	  p1++;
+	  p2++;
+	}
+    }
+  else
+    MyError ("Vector::SetPart: Vector to short");
+}
+
+void Vector :: AddPart (int startpos, double val, const BaseVector & v2)
+{
+  const Vector & hv2 = v2.CastToVector();
+  INDEX i;
+  INDEX n = v2.Length();
+
+  if (Length() >= startpos + n - 1)
+    {
+      double * p1 = &Elem(startpos);
+      const double * p2 = &hv2.Get(1);
+
+      for (i = 1; i <= n; i++)
+	{
+	  (*p1) += val * (*p2);
+	  p1++;
+	  p2++;
+	}
+    }
+  else
+    MyError ("Vector::AddPart: Vector to short");
+}
+
+
+
+
+double Vector :: operator* (const BaseVector & v2) const
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  double sum = 0;
+  double * p1 = data;
+  double * p2 = hv2.data;
+
+  if (Length() == hv2.Length())
+    {
+    for (INDEX i = Length(); i > 0; i--)
+      {
+      sum += (*p1) * (*p2);
+      p1++; p2++;
+      }
+    }
+//  else
+//    myerr << "Scalarproduct illegal dimension" << endl;
+  return sum;
+  }
+
+void Vector :: SetRandom ()
+  {
+  INDEX i;
+  for (i = 1; i <= Length(); i++)
+//    Elem(i) = 1.0 / double(i);
+    Elem(i) = drand48();
+  }
+
+
+/*
+TempVector Vector :: operator- () const
+  {
+  Vector & sum = *(Vector*)Copy();
+
+  if (sum.Length () == Length())
+    {
+    for (INDEX i = 1; i <= Length(); i++)
+      sum.Set (i, Get(i));
+    }
+//  else
+//    myerr << "operator+ (Vector, Vector): sum.Length() not ok" << endl;
+  return sum;
+  }
+*/
+
+BaseVector & Vector::operator= (const Vector & v2)
+  {
+  SetLength (v2.Length());
+
+  if (data == v2.data) return *this;
+  
+  if (v2.Length() == Length())
+    memcpy (data, v2.data, sizeof (double) * Length());
+//  else
+//    myerr << "Vector::operator=: not allocated" << endl;
+
+  return *this;
+  }
+
+BaseVector & Vector::operator= (const BaseVector & v2)
+  {
+  const Vector & hv2 = v2.CastToVector();
+
+  SetLength (hv2.Length());
+
+  if (data == hv2.data) return *this;
+  
+  if (hv2.Length() == Length())
+    memcpy (data, hv2.data, sizeof (double) * Length());
+//  else
+//    myerr << "Vector::operator=: not allocated" << endl;
+
+  return *this;
+  }
+
+
+BaseVector & Vector::operator= (double scal)
+  {
+//  if (!Length()) myerr << "Vector::operator= (double) : data not allocated"
+//                      << endl;
+
+  for (INDEX i = 1; i <= Length(); i++)
+    Set (i, scal);
+
+  return *this;
+  }
+
+
+BaseVector * Vector :: Copy () const
+  {
+  return new Vector (*this);
+  }
+
+
+void Vector :: Swap (BaseVector & v2)
+  {
+  Vector & hv2 = v2.CastToVector();
+  ng_swap (length, hv2.length);
+  ng_swap (data, hv2.data);
+  }
+
+
+
+
+void Vector :: GetElementVector (const ARRAY<INDEX> & pnum,
+				 BaseVector & elvec) const
+{
+  int i;
+  Vector & helvec = elvec.CastToVector();
+  for (i = 1; i <= pnum.Size(); i++)
+    helvec.Elem(i) = Get(pnum.Get(i));
+}
+
+void Vector :: SetElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec)
+{
+  int i;
+  const Vector & helvec = elvec.CastToVector();
+  for (i = 1; i <= pnum.Size(); i++)
+    Elem(pnum.Get(i)) = helvec.Get(i);
+}
+
+
+void Vector :: AddElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec)
+{
+  int i;
+  const Vector & helvec = elvec.CastToVector();
+  for (i = 1; i <= pnum.Size(); i++)
+    Elem(pnum.Get(i)) += helvec.Get(i);
+}
diff -ruN ug-orig/gm/gg3/netgen/linalg/vector.hh ug-patched/gm/gg3/netgen/linalg/vector.hh
--- ug-orig/gm/gg3/netgen/linalg/vector.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/linalg/vector.hh	1998-03-18 19:05:16.000000000 +0100
@@ -0,0 +1,348 @@
+#ifndef FILE_VECTOR
+#define FILE_VECTOR
+
+/* *************************************************************************/
+/* File:   vector.hh                                                      */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Oct. 94                                                    */
+/* *************************************************************************/
+
+class TempVector;
+class Vector;
+class BlockVector;
+
+/** Data types for vectors.
+   
+   Every Vector data structure is derived from a BaseVector class.
+   A BaseVector provides virtual functions for the scalar-vector
+   and vector-vector operations. 
+   If the return value of a function is a vector, then there should
+   be used a TempVector class. This avoids one additional constructor/
+   destructor call.
+   Finally, a Vector - class contains the data of a Vector in dense
+   form.
+   
+   Vector - Operations:
+   
+     Vector ( x )       Constructor empty, with given length or 
+                        given vector to copy  
+                       
+     SetLength () 
+     ChangeLength()     Change vector-length with/without destroing the vector
+     Length()           return vector-length
+     
+     Copy()             Construct a vector of same type and contents
+     
+     operator()         Save vector access
+     Set, Get, Elem:    Fast vector access for setting, receiving and reference
+
+     +, -, *, =, +=, -=, *=, /=
+     			virtual vector operations
+                     
+     SupNorm, L2Norm, L1Norm, Min, Max
+			Vector operations 
+			
+     Set (s, v), Add (s, v)
+     			Fast scalar-vector operations
+     			
+     Print ()           stream output of a vector
+
+*/
+
+class BaseVector
+{
+  protected:
+  ///
+  INDEX length;
+  ///
+  static double shit;
+
+  public:
+  ///
+  BaseVector ();
+  ///
+  BaseVector (INDEX alength);
+  ///
+  virtual ~BaseVector () { };
+  ///
+  virtual void SetSize (INDEX asize) { SetLength(asize); }
+  ///
+  virtual void SetLength (INDEX alength);
+  ///
+  virtual void ChangeLength (INDEX alength);
+  /// Size should be prefered !!!
+  INDEX Length () const { return length; }
+  /// 
+  INDEX Size() const { return length; }
+
+    // NEW RM ---> in BlockVector
+    // rtual void SetBlockLength (INDEX blength) = 0;
+
+  ///
+  virtual BaseVector & operator= (const BaseVector & /* v2 */) { return *this; }
+  ///
+  virtual BaseVector & operator= (double /* scal */) { return *this; }
+
+  ///
+  virtual double & operator() (INDEX /* i */) { return shit; }
+  ///
+  virtual double operator() (INDEX /* i */) const { return 0; }
+
+  ///
+  virtual double SupNorm () const = 0;
+  ///
+  virtual double L2Norm () const = 0;
+  ///
+  virtual double L1Norm () const = 0;
+  ///
+  virtual double Min () const = 0;
+  ///
+  virtual double Max () const = 0;
+
+  ///
+  virtual BaseVector & operator+= (const BaseVector & v2) = 0;
+  ///
+  virtual BaseVector & operator-= (const BaseVector & v2) = 0;
+  ///
+  virtual BaseVector & operator*= (double scal) = 0;
+  ///
+  virtual BaseVector & operator/= (double scal);
+
+  ///
+  virtual TempVector operator+ (const BaseVector & v2) const;
+  ///
+  virtual TempVector operator- (const BaseVector & v2) const;
+  ///
+  virtual TempVector operator- () const;
+  ///
+  virtual double operator* (const BaseVector & v2) const = 0;
+  ///
+  friend TempVector operator* (const BaseVector & v1, double scal);
+  ///
+  friend TempVector operator/ (const BaseVector & v1, double scal);
+  ///
+  friend TempVector operator* (double scal, const BaseVector & v1);
+
+  ///
+  virtual BaseVector & Add (double /* scal */, const BaseVector & /* v2 */) { return *this; }
+  ///
+  virtual BaseVector & Add (double /* scal */, const BaseVector & /* v2 */,
+                        double /* scal3 */, const BaseVector & /* v3 */) { return *this; }
+  ///
+  virtual BaseVector & Set (double /* scal */, const BaseVector & /* v2 */) { return *this; }
+  ///
+  virtual BaseVector & Set (double /* scal */, const BaseVector & /* v2 */,
+                        double /* scal3 */, const BaseVector & /* v3 */) { return *this; }
+
+    ///
+    virtual void SetRandom () { };
+
+    
+    ///
+    virtual void GetPart (int /* startpos */, 
+			  BaseVector & /* v2*/ ) const { };
+    ///
+    virtual void SetPart (int /* startpos */,  
+			  const BaseVector & /* v2 */) { };
+    ///
+    virtual void AddPart (int /* startpos */, double /* val */, 
+			  const BaseVector & /* v2 */) { };
+
+  ///
+  virtual void GetElementVector (const ARRAY<INDEX> & pnum,
+				 BaseVector & elvec) const;
+  ///
+  virtual void SetElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec);
+  ///
+  virtual void AddElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec);
+
+  ///
+  friend ostream & operator<<(ostream & s, const BaseVector & v);
+  ///
+  virtual ostream & Print (ostream & s) const { return s; }
+
+  ///
+  virtual BaseVector * Copy () const;
+  /// 
+  virtual BOOL IsVector () const { return 0; }
+  ///
+  virtual BOOL IsBlockVector () const { return 0; }
+  ///
+  virtual Vector & CastToVector () { return *(Vector*)this; }
+  ///
+  virtual const Vector & CastToVector () const { return *(Vector*)this; }
+  ///
+  virtual BlockVector & CastToBlockVector () { return *(BlockVector*)this; }
+  ///
+  virtual const BlockVector & CastToBlockVector () const { return *(BlockVector*)this; }
+  };
+
+
+///
+class TempVector : public BaseVector
+{
+  ///
+  BaseVector * vec;
+
+  public:
+  ///
+  TempVector (BaseVector & v1) { vec = & v1; }
+  ///
+  ~TempVector ();
+  ///
+  virtual Vector & CastToVector ()
+      { return vec->CastToVector(); }
+  ///
+  virtual const Vector & CastToVector () const
+      { return vec->CastToVector(); }
+  ///
+  virtual BlockVector & CastToBlockVector ()
+      { return vec->CastToBlockVector(); }
+  ///
+  virtual const BlockVector & CastToBlockVector () const
+      { return vec->CastToBlockVector(); }
+
+
+  ///
+  virtual BaseVector & operator+= (const BaseVector & /* v2 */) { return *this; }
+  ///
+  virtual BaseVector & operator-= (const BaseVector & /* v2 */) { return *this; }
+  ///
+  virtual BaseVector & operator*= (double /* scal */) { return *this; }
+  ///
+  virtual double operator* (const BaseVector & /* v2 */) const { return 0; }
+
+  ///
+  virtual double SupNorm () const { return vec->SupNorm(); }
+  ///
+  virtual double L2Norm () const { return vec->L2Norm(); }
+  ///
+  virtual double L1Norm () const { return vec->L1Norm(); }
+  ///
+  virtual double Min () const { return vec->Min(); }
+  ///
+  virtual double Max () const { return vec->Max(); }
+
+  ///
+  virtual void Swap (BaseVector &) { };
+  ///
+  virtual BaseVector * Copy () const;
+
+
+  };
+
+
+///
+class Vector : public BaseVector
+{
+  ///
+  double * data;
+  ///
+  static double shit;
+  
+public:
+  ///
+  Vector ();
+  ///
+  Vector (INDEX alength);
+  ///
+  Vector (const Vector & v2);
+  ///
+  virtual ~Vector ();
+
+  ///
+  virtual void SetLength (INDEX alength);
+  ///
+  virtual void ChangeLength (INDEX alength);
+  /// NEW RM
+  virtual void SetBlockLength (INDEX blength);
+
+  ///
+  virtual BaseVector & operator= (const BaseVector & v2);
+  ///
+  virtual BaseVector & operator= (const Vector & v2);
+  ///
+  virtual BaseVector & operator= (double scal);
+
+  ///
+  double & operator() (INDEX i);
+  ///
+  double operator() (INDEX i) const;
+
+  ///
+  virtual double SupNorm () const;
+  ///
+  virtual double L2Norm () const;
+  ///
+  virtual double L1Norm () const;
+  ///
+  virtual double Min () const;
+  ///
+  virtual double Max () const;
+
+  ///
+  virtual BaseVector & operator+= (const BaseVector & v2);
+  ///
+  virtual BaseVector & operator-= (const BaseVector & v2);
+  ///
+  virtual BaseVector & operator*= (double scal);
+
+  ///
+  virtual double operator* (const BaseVector & v2) const;
+
+
+  ///
+  virtual BaseVector & Add (double scal, const BaseVector & v2);
+  ///
+  virtual BaseVector & Add (double scal, const BaseVector & v2,
+                        double scal3, const BaseVector & v3);
+  ///
+  virtual BaseVector & Set (double scal, const BaseVector & v2);
+  ///
+  virtual BaseVector & Set (double scal , const BaseVector & v2,
+                        double scal3, const BaseVector & v3);
+
+    ///
+    virtual void GetPart (int startpos, BaseVector & v2) const;
+    ///
+    virtual void SetPart (int startpos, const BaseVector & v2);
+    ///
+    virtual void AddPart (int startpos, double val, const BaseVector & v2);
+
+  ///
+  virtual void SetRandom ();
+
+  ///
+  virtual ostream & Print (ostream & s) const;
+  ///
+  virtual BaseVector * Copy () const;
+  ///
+  virtual void Swap (BaseVector &);
+
+  ///
+  const double & Get (INDEX i) const { return data[i-1]; }
+  ///
+  void Set (INDEX i, double v) { data[i-1] = v; }
+  ///
+  double & Elem (INDEX i) { return data[i-1]; }
+
+  ///
+  virtual BOOL IsVector () const { return 1; }
+
+
+  ///
+  virtual void GetElementVector (const ARRAY<INDEX> & pnum,
+				 BaseVector & elvec) const;
+  ///
+  virtual void SetElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec);
+  ///
+  virtual void AddElementVector (const ARRAY<INDEX> & pnum,
+				 const BaseVector & elvec);
+  };
+
+#endif
+
+
diff -ruN ug-orig/gm/gg3/netgen/makefile.inc ug-patched/gm/gg3/netgen/makefile.inc
--- ug-orig/gm/gg3/netgen/makefile.inc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/makefile.inc	1996-10-01 19:43:03.000000000 +0200
@@ -0,0 +1,24 @@
+##############################################################################
+#																			 #
+#	Makefile for netgen								 #
+#																			 #
+#       created by Joachim Schoeberl												 #
+#																			 #
+##############################################################################
+
+# load architecture dependent makefile	
+include ../../../../ug.conf
+
+default: $(objects) 
+	$(ARCH_AR) $(ARCH_ARFLAGS)  ../../../../lib/libnetgen.a $(objects)
+
+.PRECIOUS:   .cc
+.SUFFIXES:   .cc
+# default rule
+.cc.o:
+	$(ARCH_C++) $(UG_C++FLAGS) -I../general -I.. $<
+
+# clean up
+clean:
+	rm -f *.o
+
diff -ruN ug-orig/gm/gg3/netgen/Makefile.netgen ug-patched/gm/gg3/netgen/Makefile.netgen
--- ug-orig/gm/gg3/netgen/Makefile.netgen	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/Makefile.netgen	1996-06-25 23:59:34.000000000 +0200
@@ -0,0 +1,25 @@
+##############################################################################
+#																			 #
+#	Makefile for netgen								 #
+#																			 #
+#	created by Joachim												 #
+#																			 #
+##############################################################################
+
+# load configuration
+include ../../../ug.conf
+
+
+GMAKE = make
+
+
+default:
+	cd meshing; $(GMAKE); cd ..;
+	cd general; $(GMAKE); cd ..;
+	cd linalg;  $(GMAKE); cd ..;
+	cd geom;    $(GMAKE); cd ..;
+	cd opti;    $(GMAKE); cd ..;
+
+# clean up
+clean:
+	find . -name '*.o' -exec rm {} \; -print
diff -ruN ug-orig/gm/gg3/netgen/meshing/adfront2.cc ug-patched/gm/gg3/netgen/meshing/adfront2.cc
--- ug-orig/gm/gg3/netgen/meshing/adfront2.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/adfront2.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,330 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+#include <limits.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+extern int Test_Line(Point3d p1, Point3d p2, Point3d sp1, Point3d sp2, double xh,double dist);
+extern int Test_Point(Point3d p, Point3d sp1, Point3d sp2, double xh);
+
+
+
+#include <meshing/adfront2.hh>
+
+
+ADFRONT2::frontpoint2 :: frontpoint2 ()
+  {
+  globalindex = 0;
+  nlinetopoint = 0;
+  frontnr = INT_MAX-10;    // attention: overflow on calculating  INT_MAX + 1
+  }
+
+ADFRONT2::frontpoint2 :: frontpoint2 (const Point3d & ap, INDEX agi)
+  {
+  p = ap;
+  globalindex = agi;
+  nlinetopoint = 0;
+  frontnr = INT_MAX-10;
+  }
+
+
+
+
+ADFRONT2::frontline :: frontline ()
+  {
+  lineclass = 1;
+  surfaceindex = 0;
+  }
+
+ADFRONT2::frontline :: frontline (const ILINE & al, int asi)
+  {
+  l = al;
+  surfaceindex = asi;
+  lineclass = 1;
+  }
+
+
+
+
+
+
+ADFRONT2 :: ADFRONT2 ()
+  {
+  nfl = 0;
+  }
+
+
+
+void ADFRONT2 :: GetPoints (ARRAY<Point3d> & apoints) const
+  {
+  INDEX i;
+
+  for (i = 1; i <= points.Size(); i++)
+    apoints.Append (points.Get(i).P());
+  }
+
+
+
+
+
+INDEX ADFRONT2 :: AddPoint (const Point3d & p, INDEX globind)
+  {
+  // inserts at empty position or resizes array
+  INDEX pi;
+
+  if (delpointl.Size() != 0)
+    {
+    pi = delpointl.Last();
+    delpointl.DeleteLast ();
+
+    points.Elem(pi) = frontpoint2 (p, globind);
+    }
+  else
+    {
+    pi = points.Append (frontpoint2 (p, globind));
+    }
+
+  return pi;
+  }
+
+
+INDEX ADFRONT2 :: AddLine (INDEX pi1, INDEX pi2, int asurfaceind)
+  {
+  int minfn;
+  INDEX li;
+
+  frontpoint2 & p1 = points[pi1];
+  frontpoint2 & p2 = points[pi2];
+
+  nfl++;
+
+  p1.AddLine();
+  p2.AddLine();
+
+  minfn = ng_min (p1.FrontNr(), p2.FrontNr());
+  p1.DecFrontNr (minfn+1);
+  p2.DecFrontNr (minfn+1);
+
+  if (dellinel.Size() != 0)
+    {
+    li = dellinel.Last();
+    dellinel.DeleteLast ();
+
+    lines.Elem(li) = frontline (ILINE(pi1, pi2), asurfaceind);
+    }
+  else
+    {
+    li = lines.Append(frontline (ILINE(pi1, pi2), asurfaceind));
+    }
+
+  return li;
+  }
+
+
+void ADFRONT2 :: DeleteLine (INDEX li)
+  {
+  int i;
+  INDEX pi;
+
+  nfl--;
+
+  for (i = 1; i <= 2; i++)
+    {
+    pi = lines.Get(li).L().I(i);
+    points.Elem(pi).RemoveLine();
+
+    if (!points.Get(pi).Valid())
+      delpointl.Append (pi);
+    }
+
+  lines.Elem(li).Invalidate();
+  dellinel.Append (li);
+  }
+
+
+
+void ADFRONT2 :: IncrementClass (INDEX li)
+  {
+  lines[li].IncrementClass();
+  }
+
+
+void ADFRONT2 :: ResetClass (INDEX li)
+  {
+  lines[li].ResetClass();
+  }
+
+
+
+
+int ADFRONT2 :: GetLocals (ARRAY<Point3d> & locpoints,
+                           ARRAY<ILINE> & loclines,   // local index
+                           ARRAY<INDEX> & pindex,
+                           ARRAY<INDEX> & lindex,
+                           int & asurfaceind,
+                           double xh,
+						   double dist)
+  {
+  INDEX i, j, k;
+  INDEX lstind, pstind;
+  char found;
+  INDEX pi;
+  Point3d midp, p0,p1,p2,sp1,sp2,p;
+  double min,l;
+  int qual;
+  
+  min = INT_MAX;
+
+	// Neues Auswahlkriterium
+
+	j = 1;
+	lstind = -1;
+	do
+	{
+	 	for (i = 1; i<= lines.Size(); i++)
+		{
+			qual = points.Get(lines.Get(i).L().I1()).FrontNr();
+			if(qual > points.Get(lines.Get(i).L().I2()).FrontNr())
+				qual = points.Get(lines.Get(i).L().I2()).FrontNr();
+			qual = qual + lines.Get(i).LineClass();
+			if( (qual==j) && (lines.Get(i).Valid()) )
+			{
+	      		l = Dist(points.Get(lines.Get(i).L().I1()).P(),points.Get(lines.Get(i).L().I2()).P());
+				if (l < min)
+	  			{
+	 		 		min = l;
+	   				lstind = i;
+      			}
+	  		}
+  		}
+		j++;
+  	}
+  	while(lstind<0);
+//	cout << lstind << endl;
+//  cin >> lstind;
+//lstind = 50;
+  asurfaceind = lines[lstind].SurfaceIndex();
+
+  pstind = lines[lstind].L().I1();
+  sp1 = points.Get(lines.Get(lstind).L().I1()).P();
+  sp2 = points.Get(lines.Get(lstind).L().I2()).P();
+  p0 = points[pstind].P();
+
+  loclines.Append(lines[lstind].L());
+  lindex.Append(lstind);
+
+  for (i = 1; i <= lines.Size(); i++)
+    {
+    if (lines.Get(i).Valid() && i != lstind)
+      {
+      midp = Center (points.Get(lines.Get(i).L().I1()).P(),
+                     points.Get(lines.Get(i).L().I2()).P());
+
+      p1 = points.Get(lines.Get(i).L().I1()).P();
+      p2 = points.Get(lines.Get(i).L().I2()).P();
+	
+      if (Test_Line(p1,p2,sp1,sp2,xh,dist))
+        {
+        loclines.Append(lines.Get(i).L());
+        lindex.Append(i);
+        }
+      }
+    }
+
+  for (i = 1; i <= loclines.Size(); i++)
+    {
+    for (j = 1; j <= 2; j++)
+      {
+      found = 0;
+      pi = loclines.Get(i).I(j);
+
+      for (k = 1; k <= pindex.Size() && !found; k++)
+        {
+        if (pindex.Get(k) == pi)
+          {
+          loclines.Elem(i).I(j) = k;
+          found = 1;
+          }
+        }
+
+      if (!found)
+        {
+        pindex.Append (pi);
+        locpoints.Append (points.Get(pi).P());
+        loclines.Elem(i).I(j) = locpoints.Size();
+        }
+      }
+    }
+
+  return lines.Get(lstind).LineClass();
+
+  }
+
+
+
+
+INDEX ADFRONT2 :: GetGlobalIndex (INDEX pi) const
+  {
+  return points[pi].GlobalIndex();
+  }
+
+
+void ADFRONT2 :: SetStartFront ()
+  {
+  INDEX i;
+  int j;
+
+  for (i = 1; i <= lines.Size(); i++)
+    if (lines.Get(i).Valid())
+      for (j = 1; j <= 2; j++)
+        points[lines[i].L().I(j)].DecFrontNr(0);
+
+//  for (i = 1; i <= points.Size(); i++)
+//    points[i].DecFrontNr(0);
+  }
+
+
+
+
+void ADFRONT2 :: Print (ostream & ost) const
+  {
+  INDEX i;
+
+  ost << points.Size() << " Points: " << endl;
+  for (i = 1; i <= points.Size(); i++)
+    if (points[i].Valid())
+      ost << i << "  " << points[i].P() << endl;
+
+  ost << nfl << " Lines: " << endl;
+  for (i = 1; i <= lines.Size(); i++)
+    if (lines[i].Valid())
+      ost << lines[i].L().I1() << " - " << lines[i].L().I2() << endl;
+
+  ost << flush;
+  }
+
+void ADFRONT2 :: ugPrint (ostream & ost) const
+{
+	INDEX i;
+	FILE *file;
+
+	file = fopen("netgen","a");
+	fprintf(file, "%d\n",points.Size());
+	for (i = 1; i <= points.Size(); i++)
+		if (points[i].Valid())
+			fprintf(file, "%f %f %f\n", points[i].P().X(),
+										points[i].P().Y(),
+										points[i].P().Z());
+	fprintf(file, "%d\n",nfl);
+	for (i = 1; i <= lines.Size(); i++)
+		if (lines[i].Valid())
+			fprintf(file, "%d %d\n", 	lines[i].L().I1(),
+										lines[i].L().I2());
+	fclose(file);
+}
diff -ruN ug-orig/gm/gg3/netgen/meshing/adfront2.hh ug-patched/gm/gg3/netgen/meshing/adfront2.hh
--- ug-orig/gm/gg3/netgen/meshing/adfront2.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/adfront2.hh	1998-03-07 16:10:52.000000000 +0100
@@ -0,0 +1,199 @@
+#ifndef FILE_ADFRONT2
+#define FILE_ADFRONT2
+
+#include <meshing/meshtype.hh>
+
+class ADFRONT2
+  {
+
+  class frontpoint2
+    {
+    Point3d p;             // coordinates
+    INDEX globalindex;     // global node index
+    int nlinetopoint;      // number of front lines connected to point
+    int frontnr;           // distance to original boundary
+
+    public:
+
+    frontpoint2 ();
+    frontpoint2 (const Point3d & ap, INDEX agi);
+
+    const Point3d & P () const;
+    INDEX GlobalIndex () const;
+
+    void AddLine ();
+    void RemoveLine ();
+    int Valid () const;
+
+    void DecFrontNr (int afrontnr);
+    int FrontNr () const;
+    };
+
+
+  class frontline
+    {
+    ILINE l;             // Point Indizes
+    int lineclass;       // quality class
+    int surfaceindex;    // index of geometric surface
+
+    public:
+
+    frontline ();
+    frontline (const ILINE & al, int asi);
+
+    const ILINE & L () const;
+    int SurfaceIndex () const;
+
+    int LineClass () const;
+
+    void IncrementClass ();
+    void ResetClass ();
+
+    int Valid () const;
+    void Invalidate ();
+    };
+
+
+
+  ARRAY<frontpoint2> points;
+  ARRAY<frontline> lines;
+
+  ARRAY<INDEX> delpointl;
+  ARRAY<INDEX> dellinel;
+
+  INDEX nfl;  // number of front lines;
+
+
+  public:
+
+  ADFRONT2 ();
+
+  void GetPoints (ARRAY<Point3d> & apoints) const;
+  void Print (ostream & ost) const;
+  void ugPrint (ostream & ost) const;
+
+  int Empty () const;
+
+  int GetLocals (ARRAY<Point3d> & locpoints,
+                 ARRAY<ILINE> & loclines,   // local index
+                 ARRAY<INDEX> & pindex,
+                 ARRAY<INDEX> & lindex,
+                 int & surfind,
+                 double xh,
+				 double dist);
+
+  void DeleteLine (INDEX li);
+  INDEX AddPoint (const Point3d & p, INDEX globind);
+  INDEX AddLine (INDEX pi1, INDEX pi2, int asurfaceind);
+  void IncrementClass (INDEX li);
+  void ResetClass (INDEX li);
+
+  INDEX GetGlobalIndex (INDEX pi) const;
+  void SetStartFront ();
+  };
+
+
+
+
+
+
+
+
+// inline functions
+
+inline int ADFRONT2::frontpoint2 :: Valid () const
+  {
+  return nlinetopoint >= 0;
+  }
+
+inline const Point3d & ADFRONT2::frontpoint2 :: P () const
+  {
+  return p;
+  }
+
+inline INDEX ADFRONT2::frontpoint2 :: GlobalIndex () const
+  {
+  return globalindex;
+  }
+
+inline void ADFRONT2::frontpoint2 :: AddLine ()
+  {
+  nlinetopoint++;
+  }
+
+inline void ADFRONT2::frontpoint2 :: RemoveLine ()
+  {
+  nlinetopoint--;
+  if (nlinetopoint == 0)
+    nlinetopoint = -1;
+  }
+
+inline int ADFRONT2::frontpoint2 :: FrontNr () const
+  {
+  return frontnr;
+  }
+
+inline void ADFRONT2::frontpoint2 :: DecFrontNr (int afrontnr)
+  {
+  if (frontnr > afrontnr) frontnr = afrontnr;
+  }
+
+
+
+
+
+
+
+
+
+
+inline int ADFRONT2::frontline :: Valid () const
+  {
+  return l.I1() != 0;
+  }
+
+inline void ADFRONT2::frontline :: Invalidate ()
+  {
+  l.I1() = 0;
+  l.I2() = 0;
+  lineclass = 1000;
+  }
+
+inline const ILINE & ADFRONT2::frontline :: L () const
+  {
+  return l;
+  }
+
+inline int ADFRONT2::frontline :: SurfaceIndex () const
+  {
+  return surfaceindex;
+  }
+
+
+inline int ADFRONT2::frontline :: LineClass () const
+  {
+  return lineclass;
+  }
+
+inline void ADFRONT2::frontline :: IncrementClass ()
+  {
+  lineclass++;
+  }
+
+inline void ADFRONT2::frontline :: ResetClass ()
+  {
+  lineclass = 1;
+  }
+
+
+inline int ADFRONT2 :: Empty () const
+  {
+  return nfl == 0;
+  }
+
+/*inline INDEX ADFRONT2 :: GetGlobalIndex (INDEX pi) const
+  {
+  return points[pi].GlobalIndex();
+  }*/
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/adfront3.cc ug-patched/gm/gg3/netgen/meshing/adfront3.cc
--- ug-orig/gm/gg3/netgen/meshing/adfront3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/adfront3.cc	1998-08-07 16:47:34.000000000 +0200
@@ -0,0 +1,808 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <myadt.hh>
+
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/adfront3.hh>
+
+int pf;
+
+ADFRONT3 :: FrontPoint3 :: FrontPoint3 () 
+  { 
+  globalindex = 0;
+  nfacetopoint = 0; 
+  frontnr = 1000; 
+  }
+
+
+ADFRONT3 :: FrontPoint3 :: FrontPoint3 (const Point3d & ap, INDEX agi)
+  { 
+  p = ap; 
+  globalindex = agi;
+  nfacetopoint = 0; 
+  frontnr = 1000; 
+  }
+
+
+ADFRONT3 :: FrontFace :: FrontFace () 
+  { 
+  qualclass = 1; 
+  oldfront = 0; 
+  }
+
+ADFRONT3 :: FrontFace :: FrontFace (const Element & af)
+  { 
+  f = af; 
+  oldfront = 0; 
+  qualclass = 1; 
+  prism_flag = pf;
+  pf = -1;
+  }
+
+
+void ADFRONT3 :: FrontFace :: Invalidate ()
+  { 
+  f.PNum(1) = 0; 
+  oldfront = 0; 
+  qualclass = 1000; 
+  }
+ 
+
+ADFRONT3 :: ADFRONT3 ()
+  {
+  nff = 0;
+  vol = 0;
+  }
+
+
+
+void ADFRONT3 :: GetPoints (ARRAY<Point3d> & apoints) const
+  {
+  INDEX i;
+  for (i = 1; i <= points.Size(); i++)
+    apoints.Append (points[i].P());
+  }
+
+
+
+INDEX ADFRONT3 :: AddPoint (const Point3d & p, INDEX globind)
+  {
+  if (delpointl.Size() != 0)
+    {
+    INDEX pi = delpointl[delpointl.Size()];
+    delpointl.DeleteLast ();
+
+    points[pi] = FrontPoint3 (p, globind);
+    return pi;
+    }
+  else
+    {
+    return points.Append (FrontPoint3 (p, globind));
+    }
+  }
+
+
+INDEX ADFRONT3 :: AddFace (const Element & aface, int prism_flag)
+  {
+  int i, minfn;
+  
+  nff++;
+
+  for (i = 1; i <= aface.NP(); i++)
+    points[aface.PNum(i)].AddFace();
+
+  const Point3d & p1 = points[aface.PNum(1)].P();
+  const Point3d & p2 = points[aface.PNum(2)].P();
+  const Point3d & p3 = points[aface.PNum(3)].P();
+
+  vol += 1.0/6.0 * (p1.X() + p2.X() + p3.X()) *
+      ( (p2.Y() - p1.Y()) * (p3.Z() - p1.Z()) -
+        (p2.Z() - p1.Z()) * (p3.Y() - p1.Y()) );
+
+  if(aface.NP()==4)
+    vol += 1.0/6.0 * (p1.X() + p3.X() + points[aface.PNum(4)].P().X()) *
+        ( (p3.Y() - p1.Y()) * (points[aface.PNum(4)].P().Z() - p1.Z()) -
+          (p3.Z() - p1.Z()) * (points[aface.PNum(4)].P().Y() - p1.Y()) );
+
+
+  minfn = 1000;
+  for (i = 1; i <= aface.NP(); i++)
+    if (i == 1 || points[aface.PNum(i)].FrontNr() < minfn)
+      minfn = points[aface.PNum(i)].FrontNr();
+
+  for (i = 1; i <= aface.NP(); i++)
+    points[aface.PNum(i)].DecFrontNr (minfn+1);
+  
+  pf = prism_flag;
+  return faces.Append(FrontFace (aface));
+  }
+
+
+void ADFRONT3 :: DeleteFace (INDEX fi)
+  {
+  int i;
+  INDEX pi;
+
+  nff--;
+
+  for (i = 1; i <= faces[fi].Face().NP(); i++)
+    {
+    pi = faces[fi].Face().PNum(i);
+    points[pi].RemoveFace();
+    if (!points[pi].Valid())
+      delpointl.Append (pi);
+    }
+
+  const Point3d & p1 = points[faces[fi].Face().PNum(1)].P();
+  const Point3d & p2 = points[faces[fi].Face().PNum(2)].P();
+  const Point3d & p3 = points[faces[fi].Face().PNum(3)].P();
+
+  vol -= 1.0/6.0 * (p1.X() + p2.X() + p3.X()) *
+      ( (p2.Y() - p1.Y()) * (p3.Z() - p1.Z()) -
+        (p2.Z() - p1.Z()) * (p3.Y() - p1.Y()) );
+
+  if(faces[fi].Face().NP()==4)
+    vol -= 1.0/6.0 * (p1.X() + p3.X() + points[faces[fi].Face().PNum(4)].P().X()) *
+        ( (p3.Y() - p1.Y()) * (points[faces[fi].Face().PNum(4)].P().Z() - p1.Z()) -
+          (p3.Z() - p1.Z()) * (points[faces[fi].Face().PNum(4)].P().Y() - p1.Y()) );
+
+  faces[fi].Invalidate();
+  }
+
+
+
+void ADFRONT3 :: IncrementClass (INDEX fi)
+  {
+  faces[fi].IncrementQualClass();
+  }
+
+void ADFRONT3 :: ResetPrism (INDEX fi)
+  {
+  faces[fi].ResetPrismFlag();
+  }
+
+
+void ADFRONT3 :: ResetClass (INDEX fi)
+  {
+  faces[fi].ResetQualClass();
+  }
+
+
+
+int ADFRONT3 :: GetLocals_Tetrahedra_new (ARRAY<Point3d> & locpoints,
+			   ARRAY<Element> & locfaces,   // local index
+			   ARRAY<INDEX> & pindex,
+			   ARRAY<INDEX> & findex,
+			   float xh,
+			   float relh,
+			   INDEX& facesplit, 
+			   int dummy)
+{
+  INDEX i, j;
+  INDEX fstind, pstind;
+  int  hi;
+  INDEX pi;
+  Point3d midp, p0;
+  static ARRAY<int> invpindex;
+  double min,f;
+  
+  static ARRAY<Element> locfaces2;           //all local faces in radius xh
+  static ARRAY<int> locfaces3;           // all faces in outer radius relh
+  static ARRAY<INDEX> findex2;
+
+  locfaces2.SetSize(0);
+  locfaces3.SetSize(0);
+  findex2.SetSize(0);
+
+  static int minval = -1;
+  static int lasti = 0;
+
+if(dummy==0)
+{
+  if (faces.Size() > 2 * nff)
+    {
+      // compress facelist
+      
+      hi = 0;
+      for (i = 1; i <= faces.Size(); i++)
+	if (faces.Get(i).Valid())
+	  {
+	    hi++;
+	    faces.Elem(hi) = faces.Get(i);
+	  }
+      
+      faces.SetSize (nff);
+      lasti = 0;
+    }
+  
+  fstind = 0;
+
+  for (i = lasti+1; i <= faces.Size() && !fstind; i++)
+    if (faces.Elem(i).Valid())
+      {
+	hi = faces.Get(i).QualClass() +
+	  points.Get(faces.Get(i).Face().PNum(1)).FrontNr() +
+	  points.Get(faces.Get(i).Face().PNum(2)).FrontNr() +
+	  points.Get(faces.Get(i).Face().PNum(3)).FrontNr();
+	
+	if (hi <= minval)
+	  {
+	    minval = hi;
+	    fstind = i;
+	    lasti = fstind;
+	  }
+      }
+  
+  if (!fstind)
+    {
+      minval = INT_MAX;
+      for (i = 1; i <= faces.Size(); i++)
+	if (faces.Elem(i).Valid())
+	  {
+	    hi = faces.Get(i).QualClass() +
+	      points.Get(faces.Get(i).Face().PNum(1)).FrontNr() +
+	      points.Get(faces.Get(i).Face().PNum(2)).FrontNr() +
+	      points.Get(faces.Get(i).Face().PNum(3)).FrontNr();
+	    
+	    if (hi <= minval)
+	      {
+		minval = hi;
+		fstind = i;
+		lasti = 0;
+	      }
+	  }
+    }
+}
+else
+{  
+	min = INT_MAX;
+	j = 1;
+	fstind = -1;
+	do
+	{
+	 	for (i = 1; i<= faces.Size(); i++)
+		{
+			if((faces.Get(i).QualClass()==j))
+			{
+				// Flaeche = Grundseite * Hoehe / 2
+				f = 0.5 * Dist(points.Get(faces.Get(i).Face().PNum(1)).P(),
+							   points.Get(faces.Get(i).Face().PNum(2)).P())
+						* Dist(points.Get(faces.Get(i).Face().PNum(3)).P(),
+							   Center(points.Get(faces.Get(i).Face().PNum(1)).P(),
+							   		  points.Get(faces.Get(i).Face().PNum(2)).P()));
+				f = f;
+				if (f < min)
+	  			{
+	 		 		min = f;
+	   				fstind = i;
+      			}
+	  		}
+  		}
+		j++;
+    	}
+    	while(fstind<0);	
+  }
+
+  pstind = faces[fstind].Face().PNum(1);
+  p0 = points[pstind].P();
+  
+  locfaces2.Append(faces[fstind].Face());
+  findex2.Append(fstind);
+
+  if (0)
+    {
+    }
+  else
+    {
+      for (i = 1; i <= faces.Size(); i++)
+	{
+	  const Element & face = faces.Get(i).Face();
+	  if (faces.Get(i).Valid() && i != fstind)
+	    {
+	      const Point3d & p1 = points.Get(face.PNum(1)).P();
+	      const Point3d & p2 = points.Get(face.PNum(2)).P();
+	      const Point3d & p3 = points.Get(face.PNum(3)).P();
+	      
+	      //	  midp = Center (p1, p2, p3);
+	      midp.X() = (1.0/3.0) * (p1.X() + p2.X() + p3.X());
+	      midp.Y() = (1.0/3.0) * (p1.Y() + p2.Y() + p3.Y());
+	      midp.Z() = (1.0/3.0) * (p1.Z() + p2.Z() + p3.Z());
+	      
+	      
+	      //	  if (Dist2 (midp, p0) <= xh*xh)
+	      if ( (midp.X()-p0.X()) * (midp.X()-p0.X()) + 
+		   (midp.Y()-p0.Y()) * (midp.Y()-p0.Y()) + 
+		   (midp.Z()-p0.Z()) * (midp.Z()-p0.Z())   <= xh * xh)
+		{
+		  locfaces2.Append(faces.Get(i).Face());
+		  findex2.Append(i);
+		}
+	    }
+	}
+    }
+
+  //local faces for inner radius:
+  for (i = 1; i <= locfaces2.Size(); i++)
+    {
+      /*
+	midp = Center (points.Get(locfaces2.Get(i).PNum(1)).P(),
+	points.Get(locfaces2.Get(i).PNum(2)).P());
+	if (Dist (midp, p0) <= relh || i==1)
+	*/
+
+      const Element & face = locfaces2.Get(i);
+      const Point3d & p1 = points.Get(face.PNum(1)).P();
+      const Point3d & p2 = points.Get(face.PNum(2)).P();
+      const Point3d & p3 = points.Get(face.PNum(3)).P();
+
+      midp.X() = (1.0/3.0) * (p1.X() + p2.X() + p3.X());
+      midp.Y() = (1.0/3.0) * (p1.Y() + p2.Y() + p3.Y());
+      midp.Z() = (1.0/3.0) * (p1.Z() + p2.Z() + p3.Z());
+	
+      if ( (midp.X()-p0.X()) * (midp.X()-p0.X()) + 
+	   (midp.Y()-p0.Y()) * (midp.Y()-p0.Y()) + 
+	   (midp.Z()-p0.Z()) * (midp.Z()-p0.Z())   <= relh * relh || i == 1)
+	{
+          locfaces.Append(locfaces2.Get(i));
+	  findex.Append(findex2.Get(i));
+	}
+      else
+	locfaces3.Append (i);
+    }
+  
+  facesplit=locfaces.Size();
+  
+  
+  //local faces for outer radius:
+  for (i = 1; i <= locfaces3.Size(); i++)
+    {
+      locfaces.Append (locfaces2.Get(locfaces3.Get(i)));
+      findex.Append (findex2.Get(locfaces3.Get(i)));
+    }
+
+
+  invpindex.SetSize (points.Size());
+  for (i = 1; i <= points.Size(); i++)
+    invpindex.Elem(i) = 0;
+  
+  for (i = 1; i <= locfaces.Size(); i++)
+    {
+    for (j = 1; j <= 3; j++)
+      {
+      pi = locfaces.Get(i).PNum(j);
+      if (invpindex.Get(pi) == 0)
+        {
+        pindex.Append (pi);
+        invpindex.Elem(pi) = pindex.Size();
+        locfaces.Elem(i).PNum(j) = locpoints.Append (points.Get(pi).P());
+        }
+      else
+        locfaces.Elem(i).PNum(j) = invpindex.Get(pi);
+
+      }
+    }
+
+  return faces.Get(fstind).QualClass();
+}
+
+
+int ADFRONT3 :: GetLocals_Tetrahedra (ARRAY<Point3d> & locpoints,
+                               ARRAY<Element> & locfaces,   // local index
+                               ARRAY<INDEX> & pindex,
+                               ARRAY<INDEX> & findex,
+                               float xh)
+{
+	return(0);
+}
+
+int ADFRONT3 :: GetLocals_Prism(ARRAY<Point3d> & locpoints,
+                               	ARRAY<Element> & locfaces,  
+                               	ARRAY<INDEX> & pindex,
+                               	ARRAY<INDEX> & findex,
+                               	float xh,
+								ARRAY<int> & prism_flags)
+{
+	INDEX i, j, k;
+	INDEX fstind;
+	int minval, hi,found;
+	INDEX pi;
+	Point3d midp,p0,p1,p2,p3,p4;
+
+	minval = INT_MAX;
+	fstind = -1;
+	for (i = 1; i<= faces.Size(); i++)
+		if(faces.Get(i).Valid())
+			if(faces.Get(i).PrismFlag()!=-1)
+				if(faces.Get(i).Face().NP()==3)
+				{
+					hi = faces.Get(i).QualClass();
+					if (hi < minval || i == 1)
+					{
+						minval = hi;
+						fstind = i;
+					}
+				}
+	if(fstind==-1)
+		return(-1);
+	else
+	{
+		p1 =  points[faces[fstind].Face().PNum(1)].P();
+		p2 =  points[faces[fstind].Face().PNum(2)].P();
+		p3 =  points[faces[fstind].Face().PNum(3)].P();
+		p0.X() = (p1.X()+p2.X()+p3.X())/3;
+		p0.Y() = (p1.Y()+p2.Y()+p3.Y())/3;
+		p0.Z() = (p1.Z()+p2.Z()+p3.Z())/3;
+
+		locfaces.Append(faces[fstind].Face());
+		findex.Append(fstind);
+ 		prism_flags.Append(faces.Get(fstind).PrismFlag());
+
+		for (i = 1; i <= faces.Size(); i++)
+			if (faces.Get(i).Valid() && i != fstind)
+			{
+				if(faces.Get(i).Face().NP()==4)
+				{
+					p1 = points.Get(faces.Get(i).Face().PNum(1)).P();
+					p2 = points.Get(faces.Get(i).Face().PNum(2)).P();
+					p3 = points.Get(faces.Get(i).Face().PNum(3)).P();
+					p4 = points.Get(faces.Get(i).Face().PNum(4)).P();
+					
+					midp.X() = (p1.X()+p2.X()+p3.X()+p4.X())/4;
+					midp.Y() = (p1.Y()+p2.Y()+p3.Y()+p4.Y())/4;
+					midp.Z() = (p1.Z()+p2.Z()+p3.Z()+p4.Z())/4;	
+
+					if (Dist (midp, p0) <= xh)
+					{
+						locfaces.Append(faces.Get(i).Face());
+						findex.Append(i);
+						prism_flags.Append(faces.Get(i).PrismFlag());
+					}
+				}
+				else
+				{
+					p1 = points.Get(faces.Get(i).Face().PNum(1)).P();
+					p2 = points.Get(faces.Get(i).Face().PNum(2)).P();
+					p3 = points.Get(faces.Get(i).Face().PNum(3)).P();
+				
+					midp.X() = (p1.X()+p2.X()+p3.X())/3;
+					midp.Y() = (p1.Y()+p2.Y()+p3.Y())/3;
+					midp.Z() = (p1.Z()+p2.Z()+p3.Z())/3;	
+
+					if (Dist (midp, p0) <= xh)
+					{
+						locfaces.Append(faces.Get(i).Face());
+						findex.Append(i);
+						prism_flags.Append(faces.Get(i).PrismFlag());
+					}
+				} 
+			}
+		for (i = 1; i <= locfaces.Size(); i++)
+		{
+			for (j = 1; j <= locfaces.Get(i).NP(); j++)
+			{
+				found = 0;
+				pi = locfaces.Get(i).PNum(j);	
+
+				for (k = 1; k <= pindex.Size() && !found; k++)
+					if (pindex.Get(k) == pi)
+					{
+						locfaces.Elem(i).PNum(j) = k;
+						found = 1;
+					}	
+
+				if (!found)
+				{
+					pindex.Append (pi);
+					locfaces.Elem(i).PNum(j) = locpoints.Append (points.Get(pi).P());
+				}
+			}
+		}
+		return(minval);
+	}
+}
+
+int ADFRONT3 :: GetLocals_Pyramid(	ARRAY<Point3d> & locpoints,
+                               		ARRAY<Element> & locfaces,  
+                               		ARRAY<INDEX> & pindex,
+                               		ARRAY<INDEX> & findex,
+                               		float xh)
+{
+	INDEX i, j, k;
+	INDEX fstind;
+	char found;
+	INDEX pi;
+	Point3d midp,p0,p1,p2,p3,p4;
+
+	fstind = -1;
+	for (i = 1; i<= faces.Size(); i++)
+		if(faces.Get(i).Valid())
+			if(faces.Get(i).Face().NP()==4)
+			{
+				fstind = i;
+    			break;
+			}
+	
+	if(fstind==-1)
+		return(-1);
+	else
+	{
+		p1 =  points[faces[fstind].Face().PNum(1)].P();
+		p2 =  points[faces[fstind].Face().PNum(2)].P();
+		p3 =  points[faces[fstind].Face().PNum(3)].P();
+		p4 =  points[faces[fstind].Face().PNum(4)].P();
+		p0.X() = (p1.X()+p2.X()+p3.X()+p4.X())/4;
+		p0.Y() = (p1.Y()+p2.Y()+p3.Y()+p4.Y())/4;
+		p0.Z() = (p1.Z()+p2.Z()+p3.Z()+p4.Z())/4;
+
+		locfaces.Append(faces[fstind].Face());
+		findex.Append(fstind);
+ 
+		for (i = 1; i <= faces.Size(); i++)
+			if (faces.Get(i).Valid() && i != fstind)
+			{
+				if(faces.Get(i).Face().NP()==4)
+				{
+					p1 = points.Get(faces.Get(i).Face().PNum(1)).P();
+					p2 = points.Get(faces.Get(i).Face().PNum(2)).P();
+					p3 = points.Get(faces.Get(i).Face().PNum(3)).P();
+					p4 = points.Get(faces.Get(i).Face().PNum(4)).P();
+				
+					midp.X() = (p1.X()+p2.X()+p3.X()+p4.X())/4;
+					midp.Y() = (p1.Y()+p2.Y()+p3.Y()+p4.Y())/4;
+					midp.Z() = (p1.Z()+p2.Z()+p3.Z()+p4.Z())/4;
+
+					if (Dist (midp, p0) <= xh)
+					{
+						locfaces.Append(faces.Get(i).Face());
+						findex.Append(i);
+					}
+				}
+				else
+				{
+					p1 = points.Get(faces.Get(i).Face().PNum(1)).P();
+					p2 = points.Get(faces.Get(i).Face().PNum(2)).P();
+					p3 = points.Get(faces.Get(i).Face().PNum(3)).P();
+				
+					midp.X() = (p1.X()+p2.X()+p3.X())/3;
+					midp.Y() = (p1.Y()+p2.Y()+p3.Y())/3;
+					midp.Z() = (p1.Z()+p2.Z()+p3.Z())/3;
+
+					if (Dist (midp, p0) <= xh)
+					{
+						locfaces.Append(faces.Get(i).Face());
+						findex.Append(i);
+					}
+				} 
+			}
+	}
+
+	for (i = 1; i <= locfaces.Size(); i++)
+	{
+		for (j = 1; j <= locfaces.Get(i).NP(); j++)
+		{
+			found = 0;
+			pi = locfaces.Get(i).PNum(j);
+
+			for (k = 1; k <= pindex.Size() && !found; k++)
+				if (pindex.Get(k) == pi)
+				{
+					locfaces.Elem(i).PNum(j) = k;
+					found = 1;
+				}
+
+			if (!found)
+			{
+				pindex.Append (pi);
+				locfaces.Elem(i).PNum(j) = locpoints.Append (points.Get(pi).P());
+			}
+		}
+	}
+
+	return(1);
+}
+
+
+void ADFRONT3 :: GetGroup (int fi,
+      ARRAY<Point3d> & grouppoints,
+      ARRAY<Element> & groupelements,
+      ARRAY<INDEX> & pindex,
+      ARRAY<INDEX> & findex
+      ) const
+  {
+  ARRAY<char> pingroup(points.Size());
+  INDEX i;
+  int j, changed, fused;
+
+  for (i = 1; i <= pingroup.Size(); i++)
+    pingroup[i] = 0;
+  for (j = 1; j <= 3; j++)
+    pingroup.Elem (faces.Get(fi).Face().PNum(j)) = 1;
+
+  do
+    {
+    changed = 0;
+
+    for (i = 1; i <= faces.Size(); i++)
+      if (faces.Get(i).Valid())
+        {
+        fused = 0;
+        for (j = 1; j <= faces.Get(i).Face().NP(); j++)
+          if (pingroup[faces[i].Face().PNum(j)]) 
+            fused++;
+            
+        if (fused >= 2)
+          for (j = 1; j <= faces[i].Face().NP(); j++)
+            if (!pingroup[faces[i].Face().PNum(j)])
+              {
+              pingroup[faces[i].Face().PNum(j)] = 1;
+              changed = 1;
+              }
+        }
+
+    }
+  while (changed);
+
+
+  for (i = 1; i <= points.Size(); i++)
+    {
+    grouppoints.Append (points[i].P());
+    pindex.Append (i);
+    }
+
+  for (i = 1; i <= faces.Size(); i++)
+    if (faces[i].Valid())
+      {
+      fused = 0;
+      for (j = 1; j <= faces[i].Face().NP(); j++)
+         if (pingroup[faces[i].Face().PNum(j)])
+          fused++;
+
+      if (fused >= 2)
+        {
+        groupelements.Append (faces[i].Face());
+        findex.Append (i);
+        }
+      }
+  }
+
+void ADFRONT3 :: SetClass (INDEX fi, int i)
+  {
+  faces[fi].SetQualClass (i);
+  }
+
+int ADFRONT3 :: Prism () const
+{
+	int i;
+	for (i = 1; i <= faces.Size(); i++)
+		if (faces.Get(i).PrismFlag()!=-1)
+			return(1);
+	return(0);
+}
+
+void ADFRONT3 :: SetStartFront ()
+{
+	INDEX i;
+	int j;
+
+	for (i = 1; i <= faces.Size(); i++)
+		if (faces.Get(i).Valid())
+	for (j = 1; j <= faces[i].Face().NP(); j++)
+	points[faces[i].Face().PNum(j)].DecFrontNr(0);
+}
+
+void ADFRONT3 :: Print () const
+{
+	INDEX i,j,n;
+
+	cout << "Front:" << endl;
+	n = 0;
+	for (i=1;i<=points.Size();i++)
+	    if (points[i].Valid())
+			n++;
+
+	cout << n << " Points: " << endl;
+	for (i=1;i<=points.Size();i++)
+	    if (points[i].Valid())
+			cout << i <<  " (" << points[i].P().X() << "," << points[i].P().Y() << "," << points[i].P().Z() << ")" << endl;
+	cout << endl;
+
+	n = 0;
+	for (i=1;i<=faces.Size();i++)
+		if (faces[i].Valid())
+			n++;
+				
+	cout << n << " Faces: " << endl;
+	for (i=1;i<=faces.Size();i++)
+	{
+		if (faces[i].Valid())
+		{
+			for(j=1;j<faces[i].Face().NP();j++)
+				cout << faces[i].Face().PNum(j) << " - ";
+			cout << faces[i].Face().PNum(faces[i].Face().NP()) << "      ";
+			cout << faces[i].QualClass() << "  " << faces[i].Valid() << endl;
+		}
+	}
+	cout << endl;
+}
+
+void ADFRONT3 :: Grape () const
+{
+	INDEX i,n;
+	FILE *file;
+	
+	file = fopen("grape", "w+");
+	n = 0;
+	for (i=1;i<=points.Size();i++)
+		n++;
+
+	fprintf(file, "%d\n", n);
+
+	for (i=1;i<=points.Size();i++)
+		fprintf(file, "%f %f %f\n", points[i].P().X(), points[i].P().Y(), points[i].P().Z());
+
+	n = 0;
+	for (i=1;i<=faces.Size();i++)
+		if (faces[i].Valid())
+			n++;
+
+	fprintf(file, "%d\n", n);
+				
+	for (i=1;i<=faces.Size();i++)
+		if (faces[i].Valid())
+			fprintf(file, "%d %d %d\n", faces[i].Face().PNum(1), faces[i].Face().PNum(2), faces[i].Face().PNum(3));
+	fclose(file);
+  }
+
+
+
+void ADFRONT3 :: SaveSurface (char * filename, double h)
+  {
+  INDEX i, np, nf;
+  int j;
+  ofstream outfile(filename);
+  ARRAY<INDEX> pointnr;
+
+
+  pointnr.SetSize (points.Size());
+  for (i = 1; i <= pointnr.Size(); i++)
+    pointnr[i] = 0;
+
+  np = 0;
+  nf = 0;
+  for (i = 1; i <= faces.Size(); i++)
+    if (faces[i].Valid())
+      {
+      nf++;
+      for (j = 1; j <= faces[i].Face().NP(); j++)
+        if (pointnr[faces[i].Face().PNum(j)] == 0)
+         {
+         np++;
+         pointnr[faces[i].Face().PNum(j)] = np;
+         }
+      }
+
+  outfile << "surfacemesh" << endl;
+  outfile << h << endl;
+  outfile << np << endl;
+
+  for (j = 1; j <= np; j++)
+    for (i = 1; i <= points.Size(); i++)
+      if (pointnr[i] == j)
+        outfile << points[i].P().X() << " "
+                << points[i].P().Y() << " "
+                << points[i].P().Z() << endl;
+
+  outfile << nf << endl;
+  for (i = 1; i <= faces.Size(); i++)
+    if (faces[i].Valid())
+      outfile << pointnr[faces[i].Face().PNum(1)] << " "
+              << pointnr[faces[i].Face().PNum(2)] << " "
+              << pointnr[faces[i].Face().PNum(3)] << endl;
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/adfront3.hh ug-patched/gm/gg3/netgen/meshing/adfront3.hh
--- ug-orig/gm/gg3/netgen/meshing/adfront3.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/adfront3.hh	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,273 @@
+#ifndef FILE_ADFRONT3
+#define FILE_ADFRONT3
+
+/**************************************************************************/
+/* File:   adfront3.hh                                                    */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Okt. 95                                                    */
+/**************************************************************************/
+
+/*
+    Advancing front class for volume meshing
+*/
+
+
+#include <meshing/meshtype.hh>
+
+
+
+class ADFRONT3
+  {
+
+  class FrontPoint3
+    {
+    Point3d p;            // coordinates
+    INDEX globalindex;    // global node index
+    int nfacetopoint;     // number of faces connected to point
+    int frontnr;          // distance to original boundary
+
+    public:
+
+    FrontPoint3 ();
+    FrontPoint3 (const Point3d & ap, INDEX agi);
+
+    const Point3d & P () const;
+    INDEX GlobalIndex () const;
+
+    void AddFace ();
+    void RemoveFace();
+
+    int Valid () const;
+//    void Invalidate ();
+
+    void DecFrontNr (int afrontnr);
+    int FrontNr () const;
+    };
+
+  class FrontFace
+    {
+    Element f;
+    int qualclass;
+    char oldfront;
+	int prism_flag;
+	
+    public:
+    FrontFace ();
+    FrontFace (const Element & af);
+    const Element & Face () const;
+
+    int QualClass () const;
+    int PrismFlag () const;
+    void IncrementQualClass ();
+    void ResetPrismFlag ();
+    void SetQualClass (int i);
+    void SetPrismFlag (int i);
+    void ResetQualClass ();
+    int Valid () const;
+    void Invalidate ();
+    };
+
+
+
+
+  ARRAY<FrontPoint3> points;
+  ARRAY<FrontFace> faces;
+
+  ARRAY<INDEX> delpointl;
+
+  INDEX nff;  // number of front faces;
+
+  double h;
+  double vol;
+
+  public:
+
+  ADFRONT3 ();
+//  void Load (char * filename, float & h);
+//  void Save (char * filename, float h);
+
+
+  void GetPoints (ARRAY<Point3d> & apoints) const;
+  int Prism () const;
+  void Print () const;
+  void Grape () const;
+  
+  int Empty () const;
+
+  int GetLocals_Tetrahedra_new (ARRAY<Point3d> & locpoints,
+			   ARRAY<Element> & locfaces,   // local index
+			   ARRAY<INDEX> & pindex,
+			   ARRAY<INDEX> & findex,
+			   float xh,
+			   float relh,
+			   INDEX& facesplit,
+			   int dummy);
+			   
+  int GetLocals_Tetrahedra (ARRAY<Point3d> & locpoints,
+                 			ARRAY<Element> & locfaces,   // local index
+                			ARRAY<INDEX> & pindex,
+                 			ARRAY<INDEX> & findex,
+                 			float xh);
+
+  int GetLocals_Prism(	ARRAY<Point3d> & locpoints,
+                 		ARRAY<Element> & locfaces,   // local index
+                		ARRAY<INDEX> & pindex,
+                 		ARRAY<INDEX> & findex,
+                 		float xh,
+						ARRAY<int> & prism_flags);
+
+  int GetLocals_Pyramid(ARRAY<Point3d> & locpoints,
+                 		ARRAY<Element> & locfaces,   // local index
+                		ARRAY<INDEX> & pindex,
+                 		ARRAY<INDEX> & findex,
+                 		float xh);
+
+  void GetGroup (int fi,
+                 ARRAY<Point3d> & grouppoints,
+                 ARRAY<Element> & groupelements,
+                 ARRAY<INDEX> & pindex,
+                 ARRAY<INDEX> & findex
+                 ) const;
+
+  void DeleteFace (INDEX fi);
+  INDEX AddPoint (const Point3d & p, INDEX globind);
+  INDEX AddFace (const Element & e,int prism_flag);
+  void IncrementClass (INDEX fi);
+  void ResetPrism (INDEX fi);
+  void ResetClass (INDEX fi);
+  void SetClass (INDEX fi, int i);
+  void SetStartFront ();
+
+  INDEX GetGlobalIndex (INDEX pi) const;
+  double Volume () const;
+  int NFF () const;
+
+
+  void SaveSurface (char * filename, double h);
+  void PrintSurface () const;
+  };
+
+
+
+inline const Point3d & ADFRONT3 :: FrontPoint3 :: P () const 
+  {
+  return p;
+  }
+
+inline INDEX ADFRONT3 :: FrontPoint3 :: GlobalIndex () const
+  {
+  return globalindex;
+  }
+
+inline void ADFRONT3::FrontPoint3 :: AddFace ()
+  {
+  nfacetopoint++;
+  }
+
+inline void ADFRONT3::FrontPoint3 :: RemoveFace ()
+  {
+  nfacetopoint--;
+  if (nfacetopoint == 0)
+    nfacetopoint = -1;
+  }
+
+
+
+inline int ADFRONT3 :: FrontPoint3 :: Valid () const 
+  { 
+  return nfacetopoint >= 0; 
+  }
+  
+/*
+inline void ADFRONT3 :: FrontPoint3 :: Invalidate () 
+  { 
+  nfacetopoint = -1; 
+  }
+*/
+
+inline int ADFRONT3 :: FrontPoint3 :: FrontNr () const
+  {
+  return frontnr;
+  }
+
+inline void ADFRONT3 :: FrontPoint3 :: DecFrontNr (int afrontnr)
+  {
+  if (frontnr > afrontnr) frontnr = afrontnr;
+  }
+
+
+
+
+
+
+inline int ADFRONT3 :: FrontFace :: Valid () const 
+  { 
+  return f.PNum(1) != 0; 
+  }
+
+inline void ADFRONT3 :: FrontFace :: SetQualClass (int i)
+  {
+  qualclass = i;
+  }
+
+inline void ADFRONT3 :: FrontFace :: SetPrismFlag (int i)
+  {
+  prism_flag = i;
+  }
+
+inline const Element & ADFRONT3 :: FrontFace :: Face() const
+  {
+  return f;
+  } 
+
+inline int ADFRONT3 :: FrontFace :: QualClass () const
+  {
+  return qualclass;
+  }
+
+inline int ADFRONT3 :: FrontFace :: PrismFlag () const
+  {
+  return prism_flag;
+  }
+
+inline void ADFRONT3 :: FrontFace :: IncrementQualClass ()
+  {
+  qualclass++;
+  }
+
+inline void ADFRONT3 :: FrontFace :: ResetPrismFlag ()
+  {
+  prism_flag = -1;
+  }
+
+inline void ADFRONT3 :: FrontFace :: ResetQualClass ()
+  {
+  if (qualclass > 1)
+    {
+    qualclass = 1;
+    oldfront = 0;
+    }
+  }
+
+inline int ADFRONT3 :: Empty () const 
+  { 
+  return nff == 0; 
+  }
+
+inline INDEX ADFRONT3 :: GetGlobalIndex (INDEX pi) const 
+  { 
+  return points[pi].GlobalIndex(); 
+  }
+
+inline double ADFRONT3 :: Volume () const 
+  { 
+  return vol; 
+  }
+
+inline int ADFRONT3 :: NFF () const 
+  { 
+  return nff; 
+  }
+
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/cross_check.cc ug-patched/gm/gg3/netgen/meshing/cross_check.cc
--- ug-orig/gm/gg3/netgen/meshing/cross_check.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/cross_check.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,1275 @@
+#include <stdio.h>
+#include <math.h>
+#include <math.h>
+
+#include "cross_check.hh"
+
+
+double ex[3], ey[3], ez[3], pp[3];
+
+static int Check_One_point_common(	double p1[3][3], int *id1,
+									double p2[3][3], int *id2, 
+									int i0, int i1, int i2, int j0, int j1, int j2, 
+									double *p10, double *p11, double *p12, 
+									double *p20, double *p21, double *p22);
+static int Calculate_Point(double *n1, double *p1_0, double *n2, double *p2_0, double *sp, double *ep, double *p);
+
+static double ABS(double a)
+{
+	if(a>=0.0)
+		return(a);
+	else
+		return(-a);
+}
+
+int Element_Inside_Check(	double *p0, double *p1, double *p2,
+					double *p3, double *p4)
+{
+	int i;
+	double a[3][3], rhs[3], sol[4];
+	
+	for(i=0;i<3;i++)
+	{
+		a[i][0] = p0[i] - p3[i];
+		a[i][1] = p1[i] - p3[i];
+		a[i][2] = p2[i] - p3[i];
+		rhs[i] = p4[i] - p3[i];
+	}
+	
+	InvMatMult3d(sol,rhs,a);	
+
+	sol[3] = 1 - sol[0] - sol[1] - sol[2];
+	
+	if( (0<sol[0])&&(sol[0]<1.0)
+	&&	(0<sol[1])&&(sol[1]<1.0)
+	&&	(0<sol[2])&&(sol[2]<1.0) 
+	&&	(0<sol[3])&&(sol[3]<1.0) )
+		return(1);
+	else 
+		return(0);
+}
+
+double Delaunay(double *p1, double *p2, double *p3, double *p4, double *p5)
+{
+	int i;
+	double a[3][3], rhs[3], det, n[3], l1;
+	
+	rhs[0] = rhs[1] = rhs[2] = 0.0;
+	for(i=0;i<3;i++)
+	{
+		a[0][i] = p1[i] - p2[i];
+		a[1][i] = p1[i] - p3[i];
+		a[2][i] = p1[i] - p4[i];
+		rhs[0] = rhs[0] + (p1[i]*p1[i] - p2[i]*p2[i]) * 0.5; 
+		rhs[1] = rhs[1] + (p1[i]*p1[i] - p3[i]*p3[i]) * 0.5; 
+		rhs[2] = rhs[2] + (p1[i]*p1[i] - p4[i]*p4[i]) * 0.5; 
+	}
+	det = Det3d(a);
+	if(ABS(det)>SMALL)
+	{
+		InvMatMult3d(p5,rhs,a);
+	}
+	else
+	{
+		for(i=0;i<3;i++)
+		{
+			a[0][i] = p2[i] - p1[i];
+			a[1][i] = p2[i] - p3[i];
+			a[2][i] = p2[i] - p4[i];
+			rhs[0] = rhs[0] + (p2[i]*p2[i] - p1[i]*p1[i]) * 0.5; 
+			rhs[1] = rhs[1] + (p2[i]*p2[i] - p3[i]*p3[i]) * 0.5; 
+			rhs[2] = rhs[2] + (p2[i]*p2[i] - p4[i]*p4[i]) * 0.5; 		
+		}
+		det = Det3d(a);
+		if(ABS(det)>SMALL)
+		{
+			InvMatMult3d(p5,rhs,a);
+		}
+		else
+		{
+			for(i=0;i<3;i++)
+			{
+				a[0][i] = p3[i] - p1[i];
+				a[1][i] = p3[i] - p2[i];
+				a[2][i] = p3[i] - p4[i];
+				rhs[0] = rhs[0] + (p3[i]*p3[i] - p1[i]*p1[i]) * 0.5; 
+				rhs[1] = rhs[1] + (p3[i]*p3[i] - p2[i]*p2[i]) * 0.5; 
+				rhs[2] = rhs[2] + (p3[i]*p3[i] - p4[i]*p4[i]) * 0.5; 		
+			}
+			det = Det3d(a);
+			if(ABS(det)>SMALL)
+			{
+				InvMatMult3d(p5,rhs,a);
+			}
+			else
+			{
+				for(i=0;i<3;i++)
+				{
+					a[0][i] = p4[i] - p1[i];
+					a[1][i] = p4[i] - p2[i];
+					a[2][i] = p4[i] - p4[i];
+					rhs[0] = rhs[0] + (p4[i]*p4[i] - p1[i]*p1[i]) * 0.5; 
+					rhs[1] = rhs[1] + (p4[i]*p4[i] - p2[i]*p2[i]) * 0.5; 
+					rhs[2] = rhs[2] + (p4[i]*p4[i] - p3[i]*p3[i]) * 0.5; 		
+				}
+				det = Det3d(a);
+				if(ABS(det)>SMALL)
+				{
+					InvMatMult3d(p5,rhs,a);
+				}
+				else
+				{
+//					printf("%s\n", "S L I V E R");
+					return(-1.0);
+				}
+			}
+		}
+	}
+
+	/* check distance */
+	Minus(n,p1,p5);
+	l1 = Lenght(n);
+
+	return(l1);
+}
+
+double Calc_D_M(double *p1,double *p2,double *p3,double *D,double *M)
+{
+	int i;
+	double dist,l,m[3];
+
+	dist = 1000000000.0;
+	for(i=0;i<3;i++)
+		M[i] = ( p1[i] + p2[i] + p3[i] ) / 3; 
+	
+	Minus(m,p1,M);
+	l = Lenght(m);
+	if(l<dist)
+	{
+		dist = l;
+		VecCopy3d(D, p1);	
+	}
+	Minus(m,p2,M);
+	l = Lenght(m);
+	if(l<dist)
+	{
+		dist = l;
+		VecCopy3d(D, p2);	
+	}
+	Minus(m,p3,M);
+	l = Lenght(m);
+	if(l<dist)
+	{
+		dist = l;
+		VecCopy3d(D, p3);	
+	}
+
+	return(0);
+}
+
+double Sphere_radius(double *Q,double *P,double *D,double *M)
+{
+	int i;
+	double dist2,dist3,m[3],lb,lc,lambda,PP[3];
+	
+	lb = 	( D[0] - M[0] ) * ( D[0] - M[0] )
+		+	( D[1] - M[1] ) * ( D[1] - M[1] )
+		+	( D[2] - M[2] ) * ( D[2] - M[2] )
+		-	( Q[0] - M[0] ) * ( Q[0] - M[0] )
+		-	( Q[1] - M[1] ) * ( Q[1] - M[1] )
+		-	( Q[2] - M[2] ) * ( Q[2] - M[2] );
+	lc =  	( P[0] - M[0] ) * ( D[0] - Q[0] )
+		+	( P[1] - M[1] ) * ( D[1] - Q[1] )
+		+	( P[2] - M[2] ) * ( D[2] - Q[2] );
+	lambda = lb / (2 *lc);
+	
+	for(i=0;i<3;i++)
+		PP[i] = M[i] + lambda * ( P[i] - M[i]);
+
+	/* check */
+	Minus(m,M,PP);
+	dist2 = Lenght(m);
+	Minus(m,D,PP);
+	dist2 = Lenght(m);
+	Minus(m,Q,PP);
+	dist3 = Lenght(m);
+	if((ABS(dist2-dist3)<SMALL))
+		return(dist2);
+	else
+		return(100.0);
+}
+
+
+static double MAX2(double a,  double b)
+{
+	if(a>b)
+		return(a);
+	else
+		return(b);
+}
+
+static double MAX3(double a,  double b, double c)
+{
+	return(MAX2(MAX2(a, b), c));
+}
+
+static double MIN2(double a,  double b)
+{
+	if(a<b)
+		return(a);
+	else
+		return(b);
+}
+
+static double MIN3(double a,  double b, double c)
+{
+	return(MIN2(MIN2(a, b), c));
+}
+
+static int Bounding_Box_3d(	double *p1_0,
+							double *p1_1,
+							double *p1_2,
+							double *p2_0,
+							double *p2_1,
+							double *p2_2)
+{
+	double max1[3], min1[3], max2[3], min2[3];
+	
+	max1[0] = MAX3(p1_0[0], p1_1[0], p1_2[0]);
+	max1[1] = MAX3(p1_0[1], p1_1[1], p1_2[1]);
+	max1[2] = MAX3(p1_0[2], p1_1[2], p1_2[2]);
+	
+	min1[0] = MIN3(p1_0[0], p1_1[0], p1_2[0]);
+	min1[1] = MIN3(p1_0[1], p1_1[1], p1_2[1]);
+	min1[2] = MIN3(p1_0[2], p1_1[2], p1_2[2]);
+
+	max2[0] = MAX3(p2_0[0], p2_1[0], p2_2[0]);
+	max2[1] = MAX3(p2_0[1], p2_1[1], p2_2[1]);
+	max2[2] = MAX3(p2_0[2], p2_1[2], p2_2[2]);
+
+	min2[0] = MIN3(p2_0[0], p2_1[0], p2_2[0]);
+	min2[1] = MIN3(p2_0[1], p2_1[1], p2_2[1]);
+	min2[2] = MIN3(p2_0[2], p2_1[2], p2_2[2]);
+
+	if( ( (max1[0]<min2[0]) || (max1[1]<min2[1]) || (max1[2]<min2[2]) )
+	||  ( (min1[0]>max2[0]) || (min1[1]>max2[1]) || (min1[2]>max2[2]) ) )
+	{
+//		printf("%s\n", "Bounding_Box_3d: keine Ueberschneidung");
+		return(0);		/* keine Ueberschneidung der Bounding Boxes */
+	}
+	else
+	{
+//		printf("%s\n", "Bounding_Box_3d: Ueberschneidung ist moeglich");
+		return(1);
+	}
+}
+
+int GetNormalVector(double *p0, double *p1, double *p2, double *n)
+{
+	double n1[3], n2[3], l;
+	
+	Minus(n1, p1, p0);
+	l = Lenght(n1);
+	Scale(n1,1/l);
+	Minus(n2, p2, p0);
+	l = Lenght(n2);
+	Scale(n2,1/l);
+	Cross(n, n1, n2);
+	l = Lenght(n);
+	Scale(n,1/l);
+	
+	return(1);	
+}
+
+static int Faces_in_the_same_Plane(	double *p1_0, double *p1_1, double *p1_2,
+									double *p2_0, double *p2_1, double *p2_2, int *flag)
+{
+	double n1[3], n2[3], sp, m[3], a;
+	
+	GetNormalVector(p1_0, p1_1, p1_2, n1);
+	GetNormalVector(p2_0, p2_1, p2_2, n2);
+	
+	*flag = 0;
+	sp = Mult(n1, n2);
+	if((sp>1-SMALL)||(sp<-1+SMALL))
+	{
+//		printf("%s\n", "Faces_in_the_same_Plane: Faces nearly planar");
+		/* Check, if the triangles define the same plane */
+		Minus(m, p1_0, p2_0);
+		a = Mult(n1, m);
+		if(ABS(a)<SMALL)
+			*flag = 1;
+		return(1);
+	}
+	else
+	{
+//		printf("%s\n", "Faces_in_the_same_Plane: Faces not planar");
+		return(0);
+	}
+}
+
+static int Two_points_common(int *id1, int*id2)
+{
+	int i, j, f[3], g;
+	
+	f[0] = f[1] = f[2] = 0;
+	for(i=0;i<3;i++)
+		for(j=0;j<3;j++)
+			if(id1[i]==id2[j])
+				f[i]++;
+
+	g = 0;
+	for(i=0;i<3;i++)
+		if(f[i]==1)
+			g++;
+	if(g==2)
+		return(1);
+	else
+		return(0);
+}
+
+static int One_point_common(double *p1_0, double *p1_1, double *p1_2, int *id1, 
+							double *p2_0, double *p2_1, double *p2_2, int *id2, 
+							double p1[3][3], double p2[3][3], int *flag1)
+{
+	int i, flag, comp;
+	double n1[3], n2[3], m2[3], m3[3],b, c;
+	double p10[3], p11[3], p12[3], p20[3], p21[3], p22[3];
+	double pt1[3], pt2[3], m[3], l, max;
+	
+	for(i=0;i<3;i++)
+	{
+		p1[i][0] = p1_0[i]; p1[i][1] = p1_1[i]; p1[i][2] = p1_2[i];
+		p2[i][0] = p2_0[i]; p2[i][1] = p2_1[i]; p2[i][2] = p2_2[i];
+	}
+	flag = 0;
+	
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 0, 2, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 1, 0, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 2, 1, 0, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 2, 0, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 0, 1, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 1, 2, 0, p10, p11, p12, p20, p21, p22)) flag = 1; else
+
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 0, 2, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 1, 0, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 2, 1, 0, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 2, 0, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 0, 1, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 1, 2, 0, p10, p11, p12, p20, p21, p22)) flag = 1; else
+
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 0, 2, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 1, 0, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 2, 1, 0, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 2, 0, 1, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 0, 1, 2, p10, p11, p12, p20, p21, p22)) flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 1, 2, 0, p10, p11, p12, p20, p21, p22)) flag = 1; 
+
+	if(flag)
+	{
+		GetNormalVector(p1_0, p1_1, p1_2, n1);
+		for(i=0;i<3;i++)
+		{
+			m2[i] = p10[i] - p21[i];
+			m3[i] = p10[i] - p22[i];
+		}
+		b = Mult(n1, m2);
+		c = Mult(n1, m3);
+		if( (b<-SMALL)&&(c<-SMALL) )
+		{
+			*flag1 = 0;
+			return(1);
+		}
+		if( (b>SMALL)&&(c>SMALL) )
+		{
+			*flag1 = 0;
+			return(1);
+		}
+
+		GetNormalVector(p2_0, p2_1, p2_2, n1);
+		for(i=0;i<3;i++)
+		{
+			m2[i] = p20[i] - p11[i];
+			m3[i] = p20[i] - p12[i];
+		}
+		b = Mult(n1, m2);
+		c = Mult(n1, m3);
+		if( (b<-SMALL)&&(c<-SMALL) )
+		{
+			*flag1 = 0;
+			return(1);
+		}
+		if( (b>SMALL)&&(c>SMALL) )
+		{
+			*flag1 = 0;
+			return(1);
+		}
+
+		GetNormalVector(p1_0, p1_1, p1_2, n1);
+		GetNormalVector(p2_0, p2_1, p2_2, n2);
+		Calculate_Point(n1, p1_0, n2, p2_0, p11, p12, pt1);	
+		Calculate_Point(n1, p1_0, n2, p2_0, p21, p22, pt2);	
+
+		Minus(m, pt2, pt1);
+		l = Lenght(m);
+		if(l>SMALL)
+			Scale(m,1/l);
+
+		max = 0.0;
+		for(i=0;i<3;i++)
+		{
+			if(max<ABS(m[i]))
+			{
+				comp = i;
+				max = ABS(m[i]);
+			}
+		}
+	
+		if( ((pt1[comp]<p10[comp])&&(p10[comp]<pt2[comp])) || ((pt1[comp]>p10[comp])&&(p10[comp]>pt2[comp])) )
+			*flag1 = 0;			/* no intersection */
+		else
+			*flag1 = 1;
+		
+		return(1);
+	}
+	else
+	{
+		*flag1 = 0;
+		return(0);
+	}
+}
+
+static int Faces_on_the_same_side(	double *p1_0, double *p1_1, double *p1_2,
+									double *p2_0, double *p2_1, double *p2_2)
+{
+	double n1[3], m1[3], m2[3], m3[3], a, b, c;
+	
+	GetNormalVector(p1_0, p1_1, p1_2, n1);
+	Minus(m1, p1_0, p2_0);
+	Minus(m2, p1_0, p2_1);
+	Minus(m3, p1_0, p2_2);
+	a = Mult(n1, m1);
+	b = Mult(n1, m2);
+	c = Mult(n1, m3);
+	if( ( ( a<-SMALL )&&( b<-SMALL )&&( c<-SMALL ) ) 
+	||  ( ( a> SMALL )&&( b> SMALL )&&( b> SMALL ) ) )
+		return(1);
+
+	GetNormalVector(p2_0, p2_1, p2_2, n1);
+	Minus(m1, p2_0, p1_0);
+	Minus(m2, p2_0, p1_1);
+	Minus(m3, p2_0, p1_2);
+	a = Mult(n1, m1);
+	b = Mult(n1, m2);
+	c = Mult(n1, m3);
+	if( ( ( a<-SMALL )&&( b<-SMALL )&&( c<-SMALL ) ) 
+	||  ( ( a> SMALL )&&( b> SMALL )&&( b> SMALL ) ) )
+		return(1);
+
+	return(0);		
+}
+
+static int Faces_nearly_on_the_same_side(	double *p1_0, double *p1_1, double *p1_2, int *id1, 
+											double *p2_0, double *p2_1, double *p2_2, int *id2)
+{
+	double n1[3], m1[3], m2[3], m3[3], a, b, c;
+
+	GetNormalVector(p1_0, p1_1, p1_2, n1);
+	Minus(m1, p1_0, p2_0);
+	Minus(m2, p1_0, p2_1);
+	Minus(m3, p1_0, p2_2);
+	a = Mult(n1, m1);
+	b = Mult(n1, m2);
+	c = Mult(n1, m3);
+	
+	if( ( (ABS(a)<SMALL)&&(b<-SMALL)&&(c<-SMALL) )
+	 || ( (a<-SMALL)&&(ABS(b)<SMALL)&&(c<-SMALL) )
+	 || ( (a<-SMALL)&&(b<-SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(b>SMALL)&&(c>SMALL) )
+	 || ( (a>SMALL)&&(ABS(b)<SMALL)&&(c>SMALL) )
+	 || ( (a>SMALL)&&(b>SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(ABS(b)<SMALL)&&(c<-SMALL) )
+	 || ( (ABS(a)<SMALL)&&(b<-SMALL)&&(ABS(c)<SMALL) )
+	 || ( (a<-SMALL)&&(ABS(b)<SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(ABS(b)<SMALL)&&(c>SMALL) )
+	 || ( (ABS(a)<SMALL)&&(b>SMALL)&&(ABS(c)<SMALL) )
+	 || ( (a>SMALL)&&(ABS(b)<SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+		
+	GetNormalVector(p2_0, p2_1, p2_2, n1);
+	Minus(m1, p2_0, p1_0);
+	Minus(m2, p2_0, p1_1);
+	Minus(m3, p2_0, p1_2);
+	a = Mult(n1, m1);
+	b = Mult(n1, m2);
+	c = Mult(n1, m3);
+
+	if( ( (ABS(a)<SMALL)&&(b<-SMALL)&&(c<-SMALL) )
+	 || ( (a<-SMALL)&&(ABS(b)<SMALL)&&(c<-SMALL) )
+	 || ( (a<-SMALL)&&(b<-SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(b>SMALL)&&(c>SMALL) )
+	 || ( (a>SMALL)&&(ABS(b)<SMALL)&&(c>SMALL) )
+	 || ( (a>SMALL)&&(b>SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(ABS(b)<SMALL)&&(c<-SMALL) )
+	 || ( (ABS(a)<SMALL)&&(b<-SMALL)&&(ABS(c)<SMALL) )
+	 || ( (a<-SMALL)&&(ABS(b)<SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+	if( ( (ABS(a)<SMALL)&&(ABS(b)<SMALL)&&(c>SMALL) )
+	 || ( (ABS(a)<SMALL)&&(b>SMALL)&&(ABS(c)<SMALL) )
+	 || ( (a>SMALL)&&(ABS(b)<SMALL)&&(ABS(c)<SMALL) ) )
+		return(1);
+
+	return(0);		
+}
+
+static int Check_Two_points_common(	double p1[3][3], int *id1,
+									double p2[3][3], int *id2, 
+									int i0, int i1, int i2, int j0, int j1, int j2, 
+									double *p10, double *p11, double *p12, 
+									double *p20, double *p21, double *p22)
+{
+	int i;
+	
+	if( (id1[i0]==id2[j0])&&(id1[i1]==id2[j1])&&(id1[i2]!=id2[j2]) )
+	{
+		for(i=0;i<3;i++)
+		{
+			p10[i]=p1[i][i0];
+			p11[i]=p1[i][i1];
+			p12[i]=p1[i][i2];
+
+			p20[i]=p2[i][j0];
+			p21[i]=p2[i][j1];
+			p22[i]=p2[i][j2];
+		}
+		return(1);
+	}
+	else
+		return(0);
+}
+
+static int Define_Tangential_Plane(double p[3][3])
+{
+	int i;
+	double l, e1[3], e2[3];
+	
+	for(i=0;i<3;i++)
+	{
+		pp[i] = p[i][0];
+		e1[i] = p[i][1] - p[i][0];
+		e2[i] = p[i][2] - p[i][0];
+		ex[i] = p[i][1] - p[i][0];
+	}
+	
+	l = Lenght(e1);
+	if(l>SMALL)
+		Scale(e1,1/l);
+	l = Lenght(e2);
+	if(l>SMALL)
+		Scale(e2,1/l);
+	Cross(ez, e1, e2);
+	l = Lenght(ez);
+	if(l>SMALL)
+		Scale(ez,1/l);
+
+	l = Lenght(ex);
+	if(l>SMALL)
+		Scale(ex,1/l);
+		
+	l = Mult(ex, ez);
+	for(i=0;i<3;i++)
+		ex[i] = ex[i] - l * ez[i];
+	l = Lenght(ex);
+	if(l>SMALL)
+		Scale(ex,1/l);
+
+	Cross(ey, ez, ex);
+	l = Lenght(ey);
+	Scale(ey,1/l);
+
+	return(1);
+}
+
+static int Project_Point_to_plane(double *p, double *p_plain)
+{
+	int i;
+	double help[3], help1[3], help2[3], l;
+
+	Minus(help, p, pp);
+	l = Mult(help, ez);
+	for(i=0;i<3;i++)
+		help1[i] = ez[i] * l;
+
+	Minus(help2, help, help1);
+
+	p_plain[0] = Mult(help2, ex);	
+	p_plain[1] = Mult(help2, ey);	
+	
+	return(0);	
+}
+
+static int Check_Cross(double *ps, double *pe, double *p1, double *p2)
+{
+	double m[2], n[2], l, c, v1, v2;
+	
+	/* HNF der Geraden durch ps und pe */
+	m[0] = pe[0] - ps[0];
+	m[1] = pe[1] - ps[1];
+	
+	l = sqrt(m[0]*m[0]+m[1]*m[1]);
+	m[0] = m[0] / l;
+	m[1] = m[1] / l;
+
+	n[0] = m[1];
+	n[1] = -m[0];
+	c = ps[0]*n[0] + ps[1]*n[1]; 
+	
+	v1 = n[0]*p1[0] + n[1]*p1[1] - c;
+	v2 = n[0]*p2[0] + n[1]*p2[1] - c;
+	
+	if( ((v1>0.0) && (v2<0.0)) || ((v1<0.0) && (v2>0.0)) )
+		return(0);					/* kein Schnittpunkt */
+	else
+		return(1);
+}
+
+static int In_Plane_Two_points_common(	double *p1_0, double *p1_1, double *p1_2, int *id1,
+										double *p2_0, double *p2_1, double *p2_2, int *id2, int *flag)
+{
+	int i;
+	double p10[3], p11[3], p12[3], p20[3], p21[3], p22[3], p1[3][3], p2[3][3];
+	double p_10[2], p_11[2], p_12[2], p_20[2], p_21[2], p_22[2];
+	
+	for(i=0;i<3;i++)
+	{
+		p1[i][0] = p1_0[i]; p1[i][1] = p1_1[i]; p1[i][2] = p1_2[i];
+		p2[i][0] = p2_0[i]; p2[i][1] = p2_1[i]; p2[i][2] = p2_2[i];
+	}
+	*flag = 0;
+	
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 0, 1, 2, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 2, 0, 1, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else 
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_Two_points_common(p1, id1, p2, id2, 1, 2, 0, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; 
+
+	if(*flag)
+	{
+		Define_Tangential_Plane(p1);
+		Project_Point_to_plane(p10, p_10);
+		Project_Point_to_plane(p11, p_11);
+		Project_Point_to_plane(p12, p_12);
+		Project_Point_to_plane(p20, p_20);
+		Project_Point_to_plane(p21, p_21);
+		Project_Point_to_plane(p22, p_22);
+//		printf("%s\n", "In_Plane_Two_points_common: 2 Punkte gemeinsam");
+		
+		if(Check_Cross(p_10, p_11, p_12, p_22))
+		{
+//			printf("%s\n", "Schnittpunkt");
+			return(1);
+		}
+		else
+		{
+//			printf("%s\n", "kein Schnittpunkt");
+			*flag = 0;
+			return(1);			
+		}
+	}
+		
+	return(0);
+}
+
+static int Check_One_point_common(	double p1[3][3], int *id1,
+									double p2[3][3], int *id2, 
+									int i0, int i1, int i2, int j0, int j1, int j2, 
+									double *p10, double *p11, double *p12, 
+									double *p20, double *p21, double *p22)
+{
+	int i;
+	
+	if( (id1[i0]==id2[j0])&&(id1[i1]!=id2[j1])&&(id1[i2]!=id2[j2]) )
+	{
+		for(i=0;i<3;i++)
+		{
+			p10[i]=p1[i][i0];
+			p11[i]=p1[i][i1];
+			p12[i]=p1[i][i2];
+
+			p20[i]=p2[i][j0];
+			p21[i]=p2[i][j1];
+			p22[i]=p2[i][j2];
+		}
+		return(1);
+	}
+	else
+		return(0);
+}
+
+static double Get_Angle(double *n)
+{
+	double l, a, b, n1[2], n2[2], p2;
+	
+	p2 = PI/2;
+	l = sqrt(n[0]*n[0]+n[1]*n[1]);
+	
+	n1[0] = 1.0;
+	n1[1] = 0.0;
+	n2[0] = 0.0;
+	n2[1] = 1.0;
+
+	a = acos( (n[0]*n1[0]+n[1]*n1[1]) / l);
+	b = acos( (n[0]*n2[0]+n[1]*n2[1]) / l);
+	
+	if( (a>=0.0)&&(a<p2)&&(b>=0.0)&&(b<p2) )
+		return(a);
+	if( (a>=p2)&&(a<2*p2)&&(b>=0.0)&&(b<p2) )
+		return(a);
+	if( (a>=p2)&&(a<2*p2)&&(b>=p2)&&(b<2*p2) )
+		return(4*p2-a);
+	if( (a>=0)&&(a<p2)&&(b>=p2)&&(b<2*p2) )
+		return(4*p2-a);
+	return(0.0);
+}
+
+static int Check_Angle(double *p, double *p1, double *p2, double *p3, double *p4)
+{
+	int i;
+	double n1[2], n2[2], n3[2], n4[2], a1, a2, b1, b2, a[2];
+	
+	for(i=0;i<2;i++)
+	{
+		n1[i] = p1[i] - p[i];
+		n2[i] = p2[i] - p[i];
+		n3[i] = p3[i] - p[i];
+		n4[i] = p4[i] - p[i];
+	}
+	
+	a[0] = Get_Angle(n1);
+	a[1] = Get_Angle(n2);
+	
+	if(a[0]<a[1])
+	{
+		a1 = a[0];
+		b1 = a[1];
+	}
+	else
+	{
+		a1 = a[1];
+		b1 = a[0];
+	}
+	
+	a[0] = Get_Angle(n3);
+	a[1] = Get_Angle(n4);
+	
+	if(a[0]<a[1])
+	{
+		a2 = a[0];
+		b2 = a[1];
+	}
+	else
+	{
+		a2 = a[1];
+		b2 = a[0];
+	}
+	if( (b1-a1<PI)&&(a1<a2)&&(a2<b1)
+	||  (b1-a1<PI)&&(a1<b2)&&(b2<b1)
+	||  (b2-a2<PI)&&(a2<a1)&&(a1<b2)
+	||  (b2-a2<PI)&&(a2<b1)&&(b1<b2)
+	||  (b1-a1>=PI)&&!((a1<a2)&&(a2<b1))
+	||  (b1-a1>=PI)&&!((a1<b2)&&(b2<b1))
+	||  (b2-a2>=PI)&&!((a2<a1)&&(a1<b2))
+	||  (b2-a2>=PI)&&!((a2<b1)&&(b1<b2)) )
+		return(1);
+	else
+		return(0);
+}
+
+static int In_Plane_One_point_common(	double *p1_0, double *p1_1, double *p1_2, int *id1,
+										double *p2_0, double *p2_1, double *p2_2, int *id2, int *flag)
+{
+	int i;
+	double p10[3], p11[3], p12[3], p20[3], p21[3], p22[3], p1[3][3], p2[3][3];
+	double p_10[2], p_11[2], p_12[2], p_20[2], p_21[2], p_22[2];
+	
+	for(i=0;i<3;i++)
+	{
+		p1[i][0] = p1_0[i]; p1[i][1] = p1_1[i]; p1[i][2] = p1_2[i];
+		p2[i][0] = p2_0[i]; p2[i][1] = p2_1[i]; p2[i][2] = p2_2[i];
+	}
+	*flag = 0;
+	
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 0, 1, 2, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 2, 0, 1, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 0, 2, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 1, 0, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 2, 1, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 2, 0, 1, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 0, 1, 2, p10, p11, p12, p20, p21, p22)) *flag = 1; else
+	if(Check_One_point_common(p1, id1, p2, id2, 1, 2, 0, 1, 2, 0, p10, p11, p12, p20, p21, p22)) *flag = 1; 
+
+	if(*flag)
+	{
+		Define_Tangential_Plane(p1);
+		Project_Point_to_plane(p10, p_10);
+		Project_Point_to_plane(p11, p_11);
+		Project_Point_to_plane(p12, p_12);
+		Project_Point_to_plane(p20, p_20);
+		Project_Point_to_plane(p21, p_21);
+		Project_Point_to_plane(p22, p_22);
+//		printf("%s\n", "In_Plane_One_point_common: 1 Punkt gemeinsam");
+		
+		if(Check_Angle(p_10, p_11, p_12, p_21, p_22))
+		{
+//			printf("%s\n", "Schnittpunkt");
+			return(1);
+		}
+		else
+		{
+//			printf("%s\n", "kein Schnittpunkt");
+			*flag = 0;
+			return(1);			
+		}
+	}
+		
+	return(0);
+}
+
+static int Line_Cross_2d(double *p1_0, double *p1_1, double *p2_0, double *p2_1)
+{
+	double n1[2], n2[2], l, m, a[2][2], rhs[2], sol[2], p1[2], p2[2];
+	
+	n1[0] = p1_1[0] - p1_0[0];
+	n1[1] = p1_1[1] - p1_0[1];
+
+	n2[0] = p2_1[0] - p2_0[0];
+	n2[1] = p2_1[1] - p2_0[1];
+
+	a[0][0] = n1[0];
+	a[0][1] = -n2[0];
+	a[1][0] = n1[1];
+	a[1][1] = -n2[1];
+
+	rhs[0] = p2_0[0] - p1_0[0];
+	rhs[1] = p2_0[1] - p1_0[1];
+
+	if( (Det2d(a)>SMALL) || (Det2d(a)<-SMALL) )
+	{
+		InvMatMult2d(sol, rhs, a);
+	
+		l = sol[0];
+		m = sol[1];
+	
+		p1[0] = p1_0[0] + l * n1[0];
+		p1[1] = p1_0[1] + l * n1[1];
+		p2[0] = p2_0[0] + m * n2[0];
+		p2[1] = p2_0[1] + m * n2[1];
+	
+		if(sqrt( (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]) )>SMALL)
+			printf("%s\n", "error");	
+
+		if( (-SMALL<l)&&(l<1.0+SMALL)&&(-SMALL<m)&&(m<1.0+SMALL) )
+			return(1);					/* intersection */
+		else
+			return(0);
+	}
+	else
+		return(0);
+}
+
+static int Cut_Test_2d(	double *p1_0, double *p1_1, double *p1_2,
+						double *p2_0, double *p2_1, double *p2_2)
+{
+	int i;
+	double p1[3][3];
+	double p_10[2], p_11[2], p_12[2], p_20[2], p_21[2], p_22[2];
+	
+	for(i=0;i<3;i++)
+	{
+		p1[i][0] = p1_0[i]; p1[i][1] = p1_1[i]; p1[i][2] = p1_2[i];
+	}
+		
+	Define_Tangential_Plane(p1);
+	Project_Point_to_plane(p1_0, p_10);
+	Project_Point_to_plane(p1_1, p_11);
+	Project_Point_to_plane(p1_2, p_12);
+	Project_Point_to_plane(p2_0, p_20);
+	Project_Point_to_plane(p2_1, p_21);
+	Project_Point_to_plane(p2_2, p_22);
+
+	if(Line_Cross_2d(p_10, p_11, p_20, p_21))	return(1); else
+	if(Line_Cross_2d(p_10, p_11, p_21, p_22))	return(1); else
+	if(Line_Cross_2d(p_10, p_11, p_22, p_20))	return(1); else
+	if(Line_Cross_2d(p_11, p_12, p_20, p_21))	return(1); else
+	if(Line_Cross_2d(p_11, p_12, p_21, p_22))	return(1); else
+	if(Line_Cross_2d(p_11, p_12, p_22, p_20))	return(1); else
+	if(Line_Cross_2d(p_12, p_10, p_20, p_21))	return(1); else
+	if(Line_Cross_2d(p_12, p_10, p_21, p_22))	return(1); else
+	if(Line_Cross_2d(p_12, p_10, p_22, p_20))	return(1); else		return(0);
+
+}
+
+static int Points_on_different_sides(double *n, double *p, double *p1, double *p2, double *sp, double *ep)
+{
+	double m1[3], m2[3], a, b;
+	
+	Minus(m1, p, p1);
+	Minus(m2, p, p2);
+	a = Mult(n, m1);
+	b = Mult(n, m2);
+	
+	if( ((a<=0.0)&&(b>0)) || ((b<=0.0)&&(a>0)) )
+	{
+		/* endpoint on different sides of the face */
+		sp[0] = p1[0];
+		sp[1] = p1[1];
+		sp[2] = p1[2];
+		ep[0] = p2[0];
+		ep[1] = p2[1];
+		ep[2] = p2[2];
+		return(1);
+	}
+	else
+		return(0);
+}
+
+static int Calculate_Point(double *n1, double *p1_0, double *n2, double *p2_0, double *sp, double *ep, double *p) 
+{
+	double n3[3], p1[3], p2[3], p3[3], det1, det2, det3, det, rhs1[3], rhs2[3], rhs3[3], help[3];
+	double a1[3][3], a2[3][3], a3[3][3], l;
+		
+	p1[0] = p1[1] = p1[2] = 0.0;
+	p2[0] = p2[1] = p2[2] = 0.0;
+	p3[0] = p3[1] = p3[2] = 0.0;
+	det1 = det2 = det3 = 0.0;
+	
+	n3[0] = ep[1] - sp[1];
+	n3[1] = sp[0] - ep[0];
+	n3[2] = 0.0;
+	l = Lenght(n3);
+	if(l>SMALL)
+	{
+		Scale(n3,1/l);
+		help[0] = sp[0];
+		help[1] = sp[1];
+		help[2] = 0.0;
+		rhs1[0] = Mult(n1, p1_0);
+		rhs1[1] = Mult(n2, p2_0);
+		rhs1[2] = Mult(n3, help);
+		a1[0][0] = n1[0]; a1[0][1] = n1[1]; a1[0][2] = n1[2];
+		a1[1][0] = n2[0]; a1[1][1] = n2[1]; a1[1][2] = n2[2];
+		a1[2][0] = n3[0]; a1[2][1] = n3[1]; a1[2][2] = n3[2];
+		det1 = ABS(Det3d(a1));
+		if(det1>SMALL)
+		{
+			InvMatMult3d(p1,rhs1,a1);	
+		}
+	}
+
+	n3[0] = 0.0;
+	n3[1] = ep[2] - sp[2];
+	n3[2] = sp[1] - ep[1];
+	l = Lenght(n3);
+	if(l>SMALL)
+	{
+		Scale(n3,1/l);
+		help[0] = 0.0;
+		help[1] = sp[1];
+		help[2] = sp[2];
+		rhs2[0] = Mult(n1, p1_0);
+		rhs2[1] = Mult(n2, p2_0);
+		rhs2[2] = Mult(n3, help);
+		a2[0][0] = n1[0]; a2[0][1] = n1[1]; a2[0][2] = n1[2];
+		a2[1][0] = n2[0]; a2[1][1] = n2[1]; a2[1][2] = n2[2];
+		a2[2][0] = n3[0]; a2[2][1] = n3[1]; a2[2][2] = n3[2];
+		det2 = ABS(Det3d(a2));
+		if(det2>SMALL)
+		{
+			InvMatMult3d(p2,rhs2,a2);	
+		}
+	}
+
+
+	n3[0] = sp[2] - ep[2];
+	n3[1] = 0.0;
+	n3[2] = ep[0] - sp[0];
+	l = Lenght(n3);
+	if(l>SMALL)
+	{
+		Scale(n3,1/l);
+		help[0] = sp[0];
+		help[1] = 0.0;
+		help[2] = sp[2];
+		rhs3[0] = Mult(n1, p1_0);
+		rhs3[1] = Mult(n2, p2_0);
+		rhs3[2] = Mult(n3, help);
+		a3[0][0] = n1[0]; a3[0][1] = n1[1]; a3[0][2] = n1[2];	
+		a3[1][0] = n2[0]; a3[1][1] = n2[1]; a3[1][2] = n2[2];
+		a3[2][0] = n3[0]; a3[2][1] = n3[1]; a3[2][2] = n3[2];
+		det3 = ABS(Det3d(a3));
+		if(det3>SMALL)
+		{
+			InvMatMult3d(p3,rhs3,a3);	
+		}
+	}
+
+	det = det1;
+	VecCopy3d(p, p1);
+	if(det2>det)
+	{
+		det = det2;
+		VecCopy3d(p, p2);
+	}
+	if(det3>det)
+	{
+		det = det3;
+		VecCopy3d(p, p3);
+	}
+	return(1);
+}
+
+static int Cut_Test_3d(double *p1_0, double *p1_1, double *p1_2,
+					double *p2_0, double *p2_1, double *p2_2)
+{
+	int i, count, comp;
+	double n1[3], n2[3];
+	double spl[3], epl[3], sp1[2][3], ep1[2][3], sp2[2][3], ep2[2][3];
+	double p1[3], p2[3], p3[3], p4[3], sp[3], ep[3];
+	double m[3], l, max, x11, x12, x21, x22;
+	
+	GetNormalVector(p1_0, p1_1, p1_2, n1);
+	GetNormalVector(p2_0, p2_1, p2_2, n2);
+	
+	count = 0;
+	if(Points_on_different_sides(n1, p1_0, p2_0, p2_1, spl, epl))
+	{
+		sp2[count][0] = spl[0]; sp2[count][1] = spl[1]; sp2[count][2] = spl[2];
+		ep2[count][0] = epl[0]; ep2[count][1] = epl[1]; ep2[count][2] = epl[2];
+		count++;
+	}
+	if(Points_on_different_sides(n1, p1_0, p2_1, p2_2, spl, epl))
+	{
+		sp2[count][0] = spl[0]; sp2[count][1] = spl[1]; sp2[count][2] = spl[2];
+		ep2[count][0] = epl[0]; ep2[count][1] = epl[1]; ep2[count][2] = epl[2];
+		count++;
+	}
+	if(Points_on_different_sides(n1, p1_0, p2_2, p2_0, spl, epl))
+	{
+		sp2[count][0] = spl[0]; sp2[count][1] = spl[1]; sp2[count][2] = spl[2];
+		ep2[count][0] = epl[0]; ep2[count][1] = epl[1]; ep2[count][2] = epl[2];
+		count++;
+	}
+	if(count!=2)
+		printf("%s\n", "ERROR");
+		
+	count = 0;
+	if(Points_on_different_sides(n2, p2_0, p1_0, p1_1, spl, epl))
+	{
+		sp1[count][0] = spl[0]; sp1[count][1] = spl[1]; sp1[count][2] = spl[2];
+		ep1[count][0] = epl[0]; ep1[count][1] = epl[1]; ep1[count][2] = epl[2];
+		count++;
+	}
+	if(Points_on_different_sides(n2, p2_0, p1_1, p1_2, spl, epl))
+	{
+		sp1[count][0] = spl[0]; sp1[count][1] = spl[1]; sp1[count][2] = spl[2];
+		ep1[count][0] = epl[0]; ep1[count][1] = epl[1]; ep1[count][2] = epl[2];
+		count++;
+	}
+	if(Points_on_different_sides(n2, p2_0, p1_2, p1_0, spl, epl))
+	{
+		sp1[count][0] = spl[0]; sp1[count][1] = spl[1]; sp1[count][2] = spl[2];
+		ep1[count][0] = epl[0]; ep1[count][1] = epl[1]; ep1[count][2] = epl[2];
+		count++;
+	}
+	if(count!=2)
+		printf("%s\n", "ERROR");
+		
+	/* search crosspoint edge + 2 face planes */
+	sp[0] = sp1[0][0];
+	sp[1] = sp1[0][1];
+	sp[2] = sp1[0][2];
+	ep[0] = ep1[0][0];
+	ep[1] = ep1[0][1];
+	ep[2] = ep1[0][2];
+	Calculate_Point(n1, p1_0, n2, p2_0, sp, ep, p1) ;	
+
+	sp[0] = sp1[1][0];
+	sp[1] = sp1[1][1];
+	sp[2] = sp1[1][2];
+	ep[0] = ep1[1][0];
+	ep[1] = ep1[1][1];
+	ep[2] = ep1[1][2];
+	Calculate_Point(n1, p1_0, n2, p2_0, sp, ep, p2) ;	
+	
+	sp[0] = sp2[0][0];
+	sp[1] = sp2[0][1];
+	sp[2] = sp2[0][2];
+	ep[0] = ep2[0][0];
+	ep[1] = ep2[0][1];
+	ep[2] = ep2[0][2];
+	Calculate_Point(n1, p1_0, n2, p2_0, sp, ep, p3) ;	
+
+	sp[0] = sp2[1][0];
+	sp[1] = sp2[1][1];
+	sp[2] = sp2[1][2];
+	ep[0] = ep2[1][0];
+	ep[1] = ep2[1][1];
+	ep[2] = ep2[1][2];
+	Calculate_Point(n1, p1_0, n2, p2_0, sp, ep, p4) ;	
+	
+	/* check, if intersection occur */
+	Minus(m, p2, p1);
+	l = Lenght(m);
+	if(l>SMALL)
+		Scale(m,1/l);
+
+	max = 0.0;
+	for(i=0;i<3;i++)
+	{
+		if(max<ABS(m[i]))
+		{
+			comp = i;
+			max = ABS(m[i]);
+		}
+	}
+	if(p1[comp]<p2[comp])
+	{
+		x11 = p1[comp];
+		x12 = p2[comp];
+	}	
+	else
+	{
+		x11 = p2[comp];
+		x12 = p1[comp];
+	}	
+	if(p3[comp]<p4[comp])
+	{
+		x21 = p3[comp];
+		x22 = p4[comp];
+	}	
+	else
+	{
+		x21 = p4[comp];
+		x22 = p3[comp];
+	}	
+	
+	if( (x12<x21) || (x11>x22) )
+		return(0);
+	else
+		return(1);
+}
+
+static int Three_Points_in_common(int *id1, int *id2)
+{
+	if( ( (id1[0]==id2[0])&&(id1[1]==id2[1])&&(id1[2]==id2[2]) )
+	||  ( (id1[0]==id2[1])&&(id1[1]==id2[2])&&(id1[2]==id2[0]) )
+	||  ( (id1[0]==id2[2])&&(id1[1]==id2[0])&&(id1[2]==id2[1]) )
+	||	( (id1[1]==id2[0])&&(id1[0]==id2[1])&&(id1[2]==id2[2]) )
+	||  ( (id1[1]==id2[1])&&(id1[0]==id2[2])&&(id1[2]==id2[0]) )
+	||  ( (id1[1]==id2[2])&&(id1[0]==id2[0])&&(id1[2]==id2[1]) )	)
+	{
+//		printf("%s\n", "Three_Points_in_common: gleiche Dreiecke");
+		return(0);		/* keine Ueberschneidung */
+	}
+	else
+	{
+//		printf("%s\n", "Three_Points_in_common: Ueberschneidung ist moeglich");
+		return(1);
+	}
+}
+
+int Cross_Check(double *p1_0, double *p1_1, double *p1_2, int *id1,
+				double *p2_0, double *p2_1, double *p2_2, int *id2)
+{
+	int flag, flag1;	
+	double p1[3][3], p2[3][3];
+		
+	flag = 0;
+	if(Three_Points_in_common(id1, id2))
+	{
+		if(Bounding_Box_3d(p1_0, p1_1, p1_2, p2_0, p2_1, p2_2))
+		{
+			if(Faces_in_the_same_Plane(p1_0, p1_1, p1_2, p2_0, p2_1, p2_2, &flag1))
+			{
+				if(flag1==1)
+				{
+					if(In_Plane_Two_points_common(p1_0, p1_1, p1_2, id1, p2_0, p2_1, p2_2, id2, &flag1))
+						flag = flag1;	
+					else
+						if(In_Plane_One_point_common(p1_0, p1_1, p1_2, id1, p2_0, p2_1, p2_2, id2, &flag1))
+							flag = flag1;
+						else
+							if(Cut_Test_2d(p1_0, p1_1, p1_2, p2_0, p2_1, p2_2))
+								flag = 1;
+							else
+								flag = 0;
+				}
+				else
+					flag = 0;
+			}
+			else
+			{
+				if(Two_points_common(id1, id2))
+					flag = 0;
+				else	
+				{
+					if(One_point_common(p1_0, p1_1, p1_2, id1, p2_0, p2_1, p2_2, id2, p1, p2, &flag1))
+						flag = flag1;
+					else
+					{
+						if(Faces_on_the_same_side(p1_0, p1_1, p1_2, p2_0, p2_1, p2_2))	
+							flag = 0;
+						else
+						{			
+							if(Faces_nearly_on_the_same_side(p1_0, p1_1, p1_2, id1, p2_0, p2_1, p2_2, id2))	
+								flag = 0;
+							else	
+							{
+								/* richtiger Schnitt-Test */
+								if(Cut_Test_3d(p1_0, p1_1, p1_2, p2_0, p2_1, p2_2))		
+									flag = 1;	
+								else 
+									flag = 0;		
+							}
+						}
+					}
+				}
+			}
+		}
+		else
+			flag = 0;
+	}
+	return(flag);
+}
diff -ruN ug-orig/gm/gg3/netgen/meshing/cross_check.hh ug-patched/gm/gg3/netgen/meshing/cross_check.hh
--- ug-orig/gm/gg3/netgen/meshing/cross_check.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/cross_check.hh	1998-03-07 16:10:52.000000000 +0100
@@ -0,0 +1,94 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <math.h>
+
+
+#define SMALL 1e-8
+#define MAXDOUBLE 1e200
+#define PI 3.141592654
+
+#define Lenght(vec)		sqrt(vec[0]*vec[0]	\
+							+vec[1]*vec[1]	\
+							+vec[2]*vec[2])
+
+#define Cross(vec,vec1,vec2)	vec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];	\
+								vec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];	\
+								vec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; 
+
+#define Minus(sol,vec1,vec2)	sol[0] = vec1[0] - vec2[0];	\
+								sol[1] = vec1[1] - vec2[1];	\
+								sol[2] = vec1[2] - vec2[2];
+
+#define Plus(sol,vec1,vec2)	sol[0] = vec1[0] + vec2[0];	\
+							sol[1] = vec1[1] + vec2[1];	\
+							sol[2] = vec1[2] + vec2[2];	
+				 
+#define Mult(vec1,vec2)		( vec1[0] * vec2[0]	\
+							+ vec1[1] * vec2[1]	\
+							+ vec1[2] * vec2[2])
+
+#define Scale(vec,l)		vec[0] = vec[0] * l;		\
+							vec[1] = vec[1] * l;		\
+							vec[2] = vec[2] * l;		 
+				
+#define Det(a)			(	- a[0] * a[4] * a[8] 	\
+							+ a[0] * a[5] * a[7] 	\
+							+ a[3] * a[1] * a[8] 	\
+							- a[3] * a[2] * a[7] 	\
+							- a[6] * a[1] * a[5] 	\
+							+ a[6] * a[2] * a[4])
+
+#define Det3d(a)		(	  a[0][0] * a[1][1] * a[2][2] 	\
+							+ a[0][1] * a[1][2] * a[2][0] 	\
+							+ a[0][2] * a[1][0] * a[2][1] 	\
+							- a[0][0] * a[1][2] * a[2][1] 	\
+							- a[0][1] * a[1][0] * a[2][2] 	\
+							- a[0][2] * a[1][1] * a[2][0])
+
+#define InvMatMult(b,c,a)		b[0] =    ( a[5] * a[7] - a[4] * a[8] ) * c[0]		\
+										+ ( a[1] * a[8] - a[2] * a[7] ) * c[1]		\
+										+ ( a[2] * a[4] - a[1] * a[5] ) * c[2];		\
+								b[1] =    ( a[3] * a[8] - a[5] * a[6] ) * c[0]		\
+										+ ( a[2] * a[6] - a[0] * a[8] ) * c[1]		\
+										+ ( a[0] * a[5] - a[2] * a[3] ) * c[2];		\
+								b[2] =    ( a[4] * a[6] - a[3] * a[7] ) * c[0]		\
+										+ ( a[0] * a[7] - a[1] * a[6] ) * c[1]		\
+										+ ( a[1] * a[3] - a[0] * a[4] ) * c[2];		\
+								b[0] = b[0] / Det(a);					\
+								b[1] = b[1] / Det(a);					\
+								b[2] = b[2] / Det(a);
+
+#define InvMatMult3d(b,c,a)		b[0] =    ( a[1][1] * a[2][2] - a[1][2] * a[2][1] ) * c[0]		\
+										+ ( a[0][2] * a[2][1] - a[0][1] * a[2][2] ) * c[1]		\
+										+ ( a[0][1] * a[1][2] - a[0][2] * a[1][1] ) * c[2];		\
+								b[1] =    ( a[1][2] * a[2][0] - a[1][0] * a[2][2] ) * c[0]		\
+										+ ( a[0][0] * a[2][2] - a[0][2] * a[2][0] ) * c[1]		\
+										+ ( a[0][2] * a[1][0] - a[0][0] * a[1][2] ) * c[2];		\
+								b[2] =    ( a[1][0] * a[2][1] - a[1][1] * a[2][0] ) * c[0]		\
+										+ ( a[0][1] * a[2][0] - a[0][0] * a[2][1] ) * c[1]		\
+										+ ( a[0][0] * a[1][1] - a[0][1] * a[1][0] ) * c[2];		\
+								b[0] = b[0] / Det3d(a);											\
+								b[1] = b[1] / Det3d(a);											\
+								b[2] = b[2] / Det3d(a);
+						
+
+
+#define Det2d(a)				( a[0][0] * a[1][1] - a[1][0] * a[0][1] )
+
+#define InvMatMult2d(b,c,a)		b[0] =    a[1][1] * c[0]		\
+										- a[0][1] * c[1];		\
+								b[1] =  - a[1][0] * c[0]		\
+										+ a[0][0] * c[1];		\
+								b[0] = b[0] / Det2d(a);		\
+								b[1] = b[1] / Det2d(a);
+
+#define MatCopy3d(a, b)			a[0][0] = b[0][0];	a[0][1] = b[0][1];	a[0][2] = b[0][2];	\
+								a[1][0] = b[1][0];	a[1][1] = b[1][1];	a[1][2] = b[1][2];	\
+								a[2][0] = b[2][0];	a[2][1] = b[2][1];	a[2][2] = b[2][2];	
+
+#define VecCopy3d(a, b)			a[0] = b[0];	\
+								a[1] = b[1];	\
+								a[2] = b[2];
+
+int GetNormalVector(double *p0, double *p1, double *p2, double *n);
diff -ruN ug-orig/gm/gg3/netgen/meshing/findip.cc ug-patched/gm/gg3/netgen/meshing/findip.cc
--- ug-orig/gm/gg3/netgen/meshing/findip.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/findip.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,109 @@
+// find inner point
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <new.h>
+#include <ctype.h>
+#include <string.h>
+
+#include <myadt.hh>
+
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+#include <linalg/linalg.hh>
+
+// #include <geom/solid.hh>
+
+#ifdef MYGRAPH
+#include <geom/rot3d.hh>
+#include <graphics/mygraph.hh>
+#endif
+
+#include <meshing/global.hh>
+
+
+
+int FindInnerPoint (const ARRAY<Point3d> & points,
+                     const ARRAY<Element> & faces,
+                     Point3d & p)
+  {
+  int i;
+  ARRAY<Vec3d> a;
+  ARRAY<double> c;
+  Point3d p1, pmin;
+  int i1, i2, i3, i4;
+  int nf;
+  DenseMatrix m(3), inv(3);
+  Vector rs(3), x(3);
+  double f, fmin, hd,l;
+
+  nf = faces.Size();
+
+  a.SetSize (nf);
+  c.SetSize (nf);
+
+  for (i = 1; i <= nf; i++)
+    {
+    p1 = points[faces[i].PNum(1)];
+    a[i] = Cross (points[faces[i].PNum(2)] - points[faces[i].PNum(1)],
+                  points[faces[i].PNum(3)] - points[faces[i].PNum(1)]);
+    a[i] /= a[i].Length();
+    c[i] = - (a[i].X() * p1.X() + a[i].Y() * p1.Y() + a[i].Z() * p1.Z());
+    }
+
+  fmin = 100;
+  pmin = Point3d (0, 0, 0);
+  for (i1 = 1; i1 <= nf; i1++)
+    for (i2 = i1+1; i2 <= nf; i2++)
+      for (i3 = i2+1; i3 <= nf; i3++)
+        for (i4 = i3+1; i4 <= nf; i4++)
+          {
+          m.Elem(1, 1) = a.Get(i1).X() - a.Get(i2).X();
+          m.Elem(1, 2) = a.Get(i1).Y() - a.Get(i2).Y();
+          m.Elem(1, 3) = a.Get(i1).Z() - a.Get(i2).Z();
+          rs.Elem(1) = c.Get(i2) - c.Get(i1);
+
+          m.Elem(2, 1) = a.Get(i1).X() - a.Get(i3).X();
+          m.Elem(2, 2) = a.Get(i1).Y() - a.Get(i3).Y();
+          m.Elem(2, 3) = a.Get(i1).Z() - a.Get(i3).Z();
+          rs.Elem(2) = c.Get(i3) - c.Get(i1);
+
+          m.Elem(3, 1) = a.Get(i1).X() - a.Get(i4).X();
+          m.Elem(3, 2) = a.Get(i1).Y() - a.Get(i4).Y();
+          m.Elem(3, 3) = a.Get(i1).Z() - a.Get(i4).Z();
+          rs.Elem(3) = c.Get(i4) - c.Get(i1);
+
+		  l = sqrt(rs.Elem(1)*rs.Elem(1) + rs.Elem(2)*rs.Elem(2) + rs.Elem(3)*rs.Elem(3));
+		  
+          if ( (fabs (m.Det()) > 1e-10) && (l > 1e-10))
+            {
+            CalcInverse (m, inv);
+            inv.Mult (rs, x);
+
+            f = -1e10;
+            for (i = 1; i <= nf; i++)
+              {
+              hd = x.Elem(1) * a.Get(i).X()
+                 + x.Elem(2) * a.Get(i).Y()
+                 + x.Elem(3) * a.Get(i).Z()
+                 + c.Get(i);
+              if (hd > f) f = hd;
+              }
+
+            if (f < fmin)
+              {
+              fmin = f;
+              pmin.X() = x.Elem(1);
+              pmin.Y() = x.Elem(2);
+              pmin.Z() = x.Elem(3);
+              }
+            }
+          }
+
+  p = pmin;
+  return (fmin < 0) ? 1 : 0;
+  }
diff -ruN ug-orig/gm/gg3/netgen/meshing/gen_elem.cc ug-patched/gm/gg3/netgen/meshing/gen_elem.cc
--- ug-orig/gm/gg3/netgen/meshing/gen_elem.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/gen_elem.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,750 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+
+#include <myadt.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+#include <meshing/ruler3.hh>
+
+const int npoint = 5;
+const int aux_point = 0;
+
+const double search_radius = 1.75;
+static int DEBUG = 0;
+
+double Sphere_radius(double *p,double *p_opt,double *D,double *M);
+double Calc_D_M(double *p1,double *p2,double *p3,double *D,double *M);
+extern double Delaunay(double *p1, double *p2, double *p3, double *p4, double *p5);
+int Check_All_Points(ARRAY<Point3d> & points,Element element);
+extern int Cross_Check(	double *p1_0, double *p1_1, double *p1_2, int *id1,
+						double *p2_0, double *p2_1, double *p2_2, int *id2);
+
+
+static Vec3d Get_Normalvector_Triang(Point3d p1,Point3d p2,Point3d p3)
+{
+	Vec3d n,n1,n2;
+	
+	n1 = p2 - p1;
+	n1 /= n1.Length();
+	n2 = p3 - p1;
+	n2 /= n2.Length();
+	
+	n = Cross(n1,n2);
+	n /= n.Length();
+	
+	return(n);
+}
+
+static Vec3d Get_Normalvector_Quad(Point3d A,Point3d B,Point3d C,Point3d D)
+{
+	Vec3d a,b,n;
+	
+	a = (B - A) + (C - D);
+	a /= a.Length();
+	b = (D - A) + (C - B);
+	b /= b.Length();
+	n = Cross(a,b);
+	n /= n.Length();
+	return(n);
+}
+
+int Search_TriangFace(ARRAY<Element> &lfaces,int id1,int id2,int id3)
+{
+	int i, id;
+	
+	id = 0;
+	for(i=1;i<=lfaces.Size();i++)
+	{
+		if(lfaces.Get(i).NP()==3)
+		{
+			if( (lfaces.Get(i).PNum(1)==id1)&&(lfaces.Get(i).PNum(2)==id2)&&(lfaces.Get(i).PNum(3)==id3) 
+			 || (lfaces.Get(i).PNum(1)==id2)&&(lfaces.Get(i).PNum(2)==id3)&&(lfaces.Get(i).PNum(3)==id1)
+			 || (lfaces.Get(i).PNum(1)==id3)&&(lfaces.Get(i).PNum(2)==id1)&&(lfaces.Get(i).PNum(3)==id2) )
+				id = i;
+		}
+	}
+	return(id);
+}
+
+int RemoveOrAdd_Triangle(	ARRAY<Element> & lfaces,
+							ARRAY<INDEX> & delfaces,
+							int id1,int id2,int id3)
+{
+	int flag;
+	Element element;
+	
+	flag = Search_TriangFace(lfaces,id1,id2,id3);
+	if(flag!=0)
+	{
+	 	delfaces.Append(flag);
+		if(DEBUG) printf("%s %d %d %d\n","remove face",lfaces.Get(flag).PNum(1),lfaces.Get(flag).PNum(2),lfaces.Get(flag).PNum(3));
+	}
+	else
+	{
+		element.PNum(1) = id2;	
+		element.PNum(2) = id1;	
+		element.PNum(3) = id3;	
+		element.PNum(4) = 0;
+		element.SetNP(3);
+		lfaces.Append(element);
+		if(DEBUG) printf("%s %d %d %d\n","add face",id1,id2,id3);
+	}
+	return(1);
+}
+
+int Search_QuadFace(ARRAY<Element> &lfaces,int id1,int id2,int id3,int id4)
+{
+	int i,id;
+	
+	id = 0;
+	for(i=1;i<=lfaces.Size();i++)
+	{
+		if(lfaces.Get(i).NP()==4)
+		{
+			if( (lfaces.Get(i).PNum(1)==id1)&&(lfaces.Get(i).PNum(2)==id2)&&(lfaces.Get(i).PNum(3)==id3)&&(lfaces.Get(i).PNum(4)==id4) 
+			 || (lfaces.Get(i).PNum(1)==id2)&&(lfaces.Get(i).PNum(2)==id3)&&(lfaces.Get(i).PNum(3)==id4)&&(lfaces.Get(i).PNum(4)==id1)
+			 || (lfaces.Get(i).PNum(1)==id3)&&(lfaces.Get(i).PNum(2)==id4)&&(lfaces.Get(i).PNum(3)==id1)&&(lfaces.Get(i).PNum(4)==id2)
+			 || (lfaces.Get(i).PNum(1)==id4)&&(lfaces.Get(i).PNum(2)==id1)&&(lfaces.Get(i).PNum(3)==id2)&&(lfaces.Get(i).PNum(4)==id3) )
+			{
+			 	id = i;
+			}
+		}
+	}	
+	return(id);
+}
+
+int RemoveOrAdd_Quadrilateral(	ARRAY<Element> & lfaces,
+								ARRAY<INDEX> & delfaces,
+								int id1,int id2,int id3,int id4)
+{
+	int flag;
+	Element element;
+	
+	flag = Search_QuadFace(lfaces,id1,id2,id3,id4);
+	if(flag!=0)
+	{
+		delfaces.Append(flag);
+		if(DEBUG) printf("%s %d %d %d %d\n","remove face",lfaces.Get(flag).PNum(1),lfaces.Get(flag).PNum(2),lfaces.Get(flag).PNum(3),lfaces.Get(flag).PNum(4));
+	}
+	else
+	{
+		element.PNum(1) = id4;	
+		element.PNum(2) = id3;	
+		element.PNum(3) = id2;	
+		element.PNum(4) = id1;
+		element.SetNP(4);
+		lfaces.Append(element);
+		if(DEBUG) printf("%s %d %d %d %d\n","add face",id1,id2,id3,id4);
+	}
+	return(1);
+}
+
+int Cut(int i1, int i2 ,int test_id, ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces, Point3d testpoint)
+{
+	int j,flag;
+	int id1[3],id2[3];
+	double p1_0[3], p1_1[3], p1_2[3], p2_0[3], p2_1[3], p2_2[3];
+	
+	flag = 0;
+	id1[0] = lfaces.Get(1).PNum(i1);
+	id1[1] = lfaces.Get(1).PNum(i2);
+	id1[2] = test_id;
+	p1_0[0] = lpoints[lfaces.Get(1).PNum(i1)].X();
+	p1_0[1] = lpoints[lfaces.Get(1).PNum(i1)].Y();
+	p1_0[2] = lpoints[lfaces.Get(1).PNum(i1)].Z();
+	p1_1[0] = lpoints[lfaces.Get(1).PNum(i2)].X();
+	p1_1[1] = lpoints[lfaces.Get(1).PNum(i2)].Y();
+	p1_1[2] = lpoints[lfaces.Get(1).PNum(i2)].Z();
+	p1_2[0] = testpoint.X();
+	p1_2[1] = testpoint.Y();
+	p1_2[2] = testpoint.Z();
+	for(j=2;j<=lfaces.Size();j++)
+	{
+		id2[0] = lfaces.Get(j).PNum(1);
+		id2[1] = lfaces.Get(j).PNum(2);
+		id2[2] = lfaces.Get(j).PNum(3);
+		p2_0[0] = lpoints[id2[0]].X();
+		p2_0[1] = lpoints[id2[0]].Y();
+		p2_0[2] = lpoints[id2[0]].Z();
+		p2_1[0] = lpoints[id2[1]].X();
+		p2_1[1] = lpoints[id2[1]].Y();
+		p2_1[2] = lpoints[id2[1]].Z();
+		p2_2[0] = lpoints[id2[2]].X();
+		p2_2[1] = lpoints[id2[2]].Y();
+		p2_2[2] = lpoints[id2[2]].Z();
+		
+		if(Cross_Check(p1_0,p1_1,p1_2,id1,p2_0,p2_1,p2_2,id2))
+			return(1);
+
+		if(lfaces.Get(j).NP()==4)
+		{
+			id2[0] = lfaces.Get(j).PNum(1);
+			id2[1] = lfaces.Get(j).PNum(3);
+			id2[2] = lfaces.Get(j).PNum(4);
+			p2_0[0] = lpoints[id2[0]].X();
+			p2_0[1] = lpoints[id2[0]].Y();
+			p2_0[2] = lpoints[id2[0]].Z();
+			p2_1[0] = lpoints[id2[1]].X();
+			p2_1[1] = lpoints[id2[1]].Y();
+			p2_1[2] = lpoints[id2[1]].Z();
+			p2_2[0] = lpoints[id2[2]].X();
+			p2_2[1] = lpoints[id2[2]].Y();
+			p2_2[2] = lpoints[id2[2]].Z();
+
+			if(Cross_Check(p1_0,p1_1,p1_2,id1,p2_0,p2_1,p2_2,id2))
+				return(1);
+		}
+	}
+	
+	return(flag);
+}
+
+int Save_local_Situation(	ARRAY<Point3d> & lpoints,
+							ARRAY<Element> & lfaces,
+							Element element)
+{
+	FILE *file;
+	int i;
+		
+	file = fopen("grape", "w+");
+	fprintf(file, "%d\n", lpoints.Size());
+	for (i=1;i<=lpoints.Size();i++)
+		fprintf(file, "%f %f %f\n", lpoints[i].X(), lpoints[i].Y(), lpoints[i].Z());
+	fprintf(file, "%d\n", lfaces.Size());	
+	for (i=1;i<=lfaces.Size();i++)
+	{
+		fprintf(file, "%d %d %d\n", lfaces.Get(i).PNum(1), lfaces.Get(i).PNum(2), lfaces.Get(i).PNum(3));
+		if(lfaces.Get(i).NP()==4)
+			fprintf(file, "%d %d %d\n", lfaces.Get(i).PNum(1), lfaces.Get(i).PNum(3), lfaces.Get(i).PNum(4));
+	}
+	if(element.NP()==4)
+		fprintf(file, "%d %d %d %d\n",  element.PNum(1),
+										element.PNum(2),
+										element.PNum(3),
+										element.PNum(4));
+	
+	
+	fclose(file);
+	return(0);
+}
+
+
+
+static int Local_Out(ARRAY<Point3d> & lpoints,ARRAY<Element> & lfaces, ARRAY<int> & prism_flags)
+{
+	int i,j;
+
+	printf("%s\n","points");
+	for(i=1;i<=lpoints.Size();i++)
+		printf("%f %f %f\n",lpoints[i].X(),lpoints[i].Y(),lpoints[i].Z());
+	printf("%s\n","faces");
+	for(i=1;i<=lfaces.Size();i++)
+	{
+		for(j=1;j<=lfaces[i].NP()-1;j++)
+			printf("%d %s",lfaces.Get(i).PNum(j),"- ");
+		printf("%d %d\n",lfaces.Get(i).PNum(lfaces[i].NP()),prism_flags.Get(i));
+	}
+	return(1);
+}
+
+int Search_PrismTriangle(	ARRAY<Point3d> & lpoints,ARRAY<Element> & lfaces,
+							ARRAY<Point3d> & ASL,ARRAY<Point3d> & BSL,ARRAY<Point3d> & CSL,
+							ARRAY<int> & id_ASL,ARRAY<int> & id_BSL,ARRAY<int> & id_CSL,
+							ARRAY<int> & prism_flags,
+							int &id1,int &id2,int&id3)
+{
+	int i,id;	
+	
+	id = 0;
+	if( (ASL.Size()==1)&&(BSL.Size()==1)&&(CSL.Size()==1) )
+	{
+		for(i=1;i<=lfaces.Size();i++)
+		{
+			if(lfaces.Get(i).NP()==3)
+			{
+				if( (lfaces.Get(i).PNum(1)==id_ASL.Get(1))&&(lfaces.Get(i).PNum(3)==id_BSL.Get(1))&&(lfaces.Get(i).PNum(2)==id_CSL.Get(1)) )
+				{
+					id = i;
+					id1 = lfaces.Get(i).PNum(1);
+					id2 = lfaces.Get(i).PNum(3);
+					id3 = lfaces.Get(i).PNum(2);
+				}
+				if( (lfaces.Get(i).PNum(3)==id_ASL.Get(1))&&(lfaces.Get(i).PNum(2)==id_BSL.Get(1))&&(lfaces.Get(i).PNum(1)==id_CSL.Get(1)) )
+				{
+					id = i;
+					id1 = lfaces.Get(i).PNum(3);
+					id2 = lfaces.Get(i).PNum(2);
+					id3 = lfaces.Get(i).PNum(1);
+				}
+				if( (lfaces.Get(i).PNum(2)==id_ASL.Get(1))&&(lfaces.Get(i).PNum(1)==id_BSL.Get(1))&&(lfaces.Get(i).PNum(3)==id_CSL.Get(1)) )
+				{
+					id = i;
+					id1 = lfaces.Get(i).PNum(2);
+					id2 = lfaces.Get(i).PNum(1);
+					id3 = lfaces.Get(i).PNum(3);
+				}
+			}
+		}
+	}
+	
+	if(prism_flags.Get(1)==prism_flags.Get(id))
+		return(id);		// gefunden
+	else
+		return(-1);
+}
+
+int Free_Prism(	ARRAY<Point3d> & lpoints,ARRAY<Element> & lfaces,Element & element,
+				ARRAY<Point3d> & AL,ARRAY<Point3d> & BL,ARRAY<Point3d> & CL,
+				ARRAY<int> & id_AL,ARRAY<int> & id_BL,ARRAY<int> & id_CL,
+				ARRAY<Point3d> & ASL,ARRAY<Point3d> & BSL,ARRAY<Point3d> & CSL,
+				ARRAY<int> & id_ASL,ARRAY<int> & id_BSL,ARRAY<int> & id_CSL,
+				Point3d AN,Point3d BN,Point3d CN)
+{
+	if( (AL.Size()==0)&&(BL.Size()==0)&&(CL.Size()==0) )
+	{
+		element.PNum(1) = 1;
+		element.PNum(2) = 2;
+		element.PNum(3) = 3;
+		element.PNum(4) = lpoints.Size() + 1;
+		element.PNum(5) = lpoints.Size() + 2;
+		element.PNum(6) = lpoints.Size() + 3;
+		element.SetNP(6);
+		
+		lpoints.Append(AN);	
+		lpoints.Append(BN);	
+		lpoints.Append(CN);	
+	
+		return(1);
+	}
+	else
+		return(0);
+}
+
+#define xy_dist 0.1
+
+int Generate_Prism (ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+					ARRAY<Element> & elements,
+					ARRAY<INDEX> & delfaces, ARRAY<int> & prism_flags)
+{
+	int i,face_id, id1, id2, id3;
+	double max_l,l,dA,dB,dC;
+	Point3d A,B,C,AN,BN,CN,M,dummy;
+	Vec3d a,b,c,m,n,dist_A,dist_B,dist_C;
+	Element element;
+	ARRAY<Point3d> AL;
+	ARRAY<int> id_AL;
+	ARRAY<Point3d> BL;
+	ARRAY<int> id_BL;
+	ARRAY<Point3d> CL;
+	ARRAY<int> id_CL;
+	ARRAY<Point3d> ASL;
+	ARRAY<int> id_ASL;
+	ARRAY<Point3d> BSL;
+	ARRAY<int> id_BSL;
+	ARRAY<Point3d> CSL;
+	ARRAY<int> id_CSL;
+	
+	
+	if(DEBUG) Local_Out(lpoints,lfaces,prism_flags);
+
+	A = lpoints[lfaces.Get(1).PNum(1)];
+	B = lpoints[lfaces.Get(1).PNum(2)];
+	C = lpoints[lfaces.Get(1).PNum(3)];
+
+	/* centroid of the face */ 
+	M.X() = ( A.X() + B.X() + C.X() ) / 3;
+	M.Y() = ( A.Y() + B.Y() + C.Y() ) / 3;
+	M.Z() = ( A.Z() + B.Z() + C.Z() ) / 3;
+
+	/* normalvector on the first face */
+	n = Get_Normalvector_Triang(A,B,C);
+	
+	max_l = (B - A).Length();
+	l =  (C - A).Length();
+	if(l>max_l)
+		max_l = l;
+	l =  (C - B).Length();
+	if(l>max_l)
+		max_l = l;
+
+	/* determine best new points */
+	AN = A - n;
+	BN = B - n;
+	CN = C - n;
+	
+	AL.SetSize(0);
+	id_AL.SetSize(0);
+	BL.SetSize(0);
+	id_BL.SetSize(0);
+	BL.SetSize(0);
+	id_BL.SetSize(0);
+	
+	for(i=1;i<=lpoints.Size();i++)
+	{
+		if( (i!=lfaces.Get(1).PNum(1)) && (i!=lfaces.Get(1).PNum(2)) && (i!=lfaces.Get(1).PNum(3)) )
+		{
+			m = lpoints[i] - M;
+			dummy = lpoints[i];
+			m /= m.Length();
+			if(m*n<-0.0)
+			{
+				dist_A = lpoints[i] - A;
+				dist_B = lpoints[i] - B;
+				dist_C = lpoints[i] - C;
+				dA = dist_A.Length();
+				dB = dist_B.Length();
+				dC = dist_C.Length();
+				if( (dA<dB)&&(dA<dC)&&(dA<search_radius) )
+				{
+					AL.Append(dummy);
+					id_AL.Append(i);
+				}
+				else 
+				{
+					if( (dB<dA)&&(dB<dC)&&(dB<search_radius) )
+					{
+						BL.Append(dummy);
+						id_BL.Append(i);
+					}
+					else
+						if( (dC<search_radius) )
+						{
+							CL.Append(dummy);
+							id_CL.Append(i);
+						}
+				}
+			}
+		}
+	}
+	
+	for(i=1;i<=AL.Size();i++)
+	{
+		a = AL[i]-AN; 
+		a.Z() = 0.0;
+		if(a.Length()<xy_dist)
+		{
+			ASL.Append(AL[i]);
+			id_ASL.Append(id_AL[i]);
+		}
+	}
+	for(i=1;i<=BL.Size();i++)
+	{
+		b = BL[i]-BN; 
+		b.Z() = 0.0;
+		if(b.Length()<xy_dist)
+		{
+			BSL.Append(BL[i]);
+			id_BSL.Append(id_BL[i]);
+		}
+	}
+	for(i=1;i<=CL.Size();i++)
+	{
+		c = CL[i]-CN; 
+		c.Z() = 0.0;
+		if(c.Length()<xy_dist)
+		{
+			CSL.Append(CL[i]);
+			id_CSL.Append(id_CL[i]);
+		}
+	}
+
+	if(DEBUG)
+	{
+		printf("%s\n","AL");
+		for(i=1;i<=AL.Size();i++)
+			printf("%f %f %f %d\n",AL[i].X(),AL[i].Y(),AL[i].Z(),id_AL[i]);
+		printf("%s\n","BL");
+		for(i=1;i<=BL.Size();i++)
+			printf("%f %f %f %d\n",BL[i].X(),BL[i].Y(),BL[i].Z(),id_BL[i]);
+		printf("%s\n","CL");
+		for(i=1;i<=CL.Size();i++)
+			printf("%f %f %f %d\n",CL[i].X(),CL[i].Y(),CL[i].Z(),id_CL[i]);
+		printf("%s\n","################");
+		printf("%s\n","ASL");
+		for(i=1;i<=ASL.Size();i++)
+			printf("%f %f %f %d\n",ASL[i].X(),ASL[i].Y(),ASL[i].Z(),id_ASL[i]);
+		printf("%s\n","BSL");
+		for(i=1;i<=BSL.Size();i++)
+			printf("%f %f %f %d\n",BSL[i].X(),BSL[i].Y(),BSL[i].Z(),id_BSL[i]);
+		printf("%s\n","CSL");
+		for(i=1;i<=CSL.Size();i++)
+			printf("%f %f %f %d\n",CSL[i].X(),CSL[i].Y(),CSL[i].Z(),id_CSL[i]);
+	}
+	
+	face_id = Search_PrismTriangle(lpoints,lfaces,ASL,BSL,CSL,id_ASL,id_BSL,id_CSL, prism_flags, id1, id2, id3);
+	if(face_id==-1)
+		return(0);
+	else
+	{
+		// create element		
+		element.PNum(1) = 1;
+		element.PNum(2) = 2;
+		element.PNum(3) = 3;
+		element.PNum(4) = id1;
+		element.PNum(5) = id2;
+		element.PNum(6) = id3;
+		element.SetNP(6);
+		
+		// cross check
+		
+		// in_element check
+
+		elements.Append (element);
+		if(DEBUG) printf("%s %d %d %d %d %d %d\n","create element",element.PNum(1),element.PNum(2),element.PNum(3),element.PNum(4),
+														element.PNum(5),element.PNum(6));
+		RemoveOrAdd_Triangle(lfaces,delfaces,element.PNum(5),element.PNum(4),element.PNum(6));		
+		RemoveOrAdd_Quadrilateral(lfaces,delfaces,element.PNum(4),element.PNum(5),element.PNum(2),element.PNum(1));	
+		RemoveOrAdd_Quadrilateral(lfaces,delfaces,element.PNum(5),element.PNum(6),element.PNum(3),element.PNum(2));	
+		RemoveOrAdd_Quadrilateral(lfaces,delfaces,element.PNum(6),element.PNum(4),element.PNum(1),element.PNum(3));	
+		delfaces.Append(1);
+		return(1);
+		
+	}
+}
+
+int Order_List3(ARRAY<Point3d> & lpoints,
+				ARRAY<Element> & lfaces,
+				ARRAY<Point3d> &Q,
+				Point3d P[1+npoint+aux_point],
+				ARRAY<int> &id_Q,
+				ARRAY<double> &distance,
+				ARRAY<Point3d> &OL,
+				ARRAY<int> &id_OL)
+{
+	int i,j,help_id,min_j;
+	double p1[3],p2[3],p3[3],p4[3],p5[3],helpx,helpy,helpz,min,help,D[3],M[3],p_opt[3];
+	Point3d dummy;
+	double distance1[20];
+	dummy = P[0];
+	Q.Append(dummy);
+	id_Q.Append(lpoints.Size()+1);
+		
+	p1[0] = lpoints[lfaces.Get(1).PNum(1)].X();
+	p1[1] = lpoints[lfaces.Get(1).PNum(1)].Y();
+	p1[2] = lpoints[lfaces.Get(1).PNum(1)].Z();
+
+	p2[0] = lpoints[lfaces.Get(1).PNum(2)].X();
+	p2[1] = lpoints[lfaces.Get(1).PNum(2)].Y();
+	p2[2] = lpoints[lfaces.Get(1).PNum(2)].Z();
+
+	p3[0] = lpoints[lfaces.Get(1).PNum(3)].X();
+	p3[1] = lpoints[lfaces.Get(1).PNum(3)].Y();
+	p3[2] = lpoints[lfaces.Get(1).PNum(3)].Z();
+	
+	Calc_D_M(p1,p2,p3,D,M);
+	
+	p_opt[0] = dummy.X();
+	p_opt[1] = dummy.Y();
+	p_opt[2] = dummy.Z();
+	
+	for(i=0;i<20;i++)
+		distance1[i] = -1.0;
+	for(i=1;i<=Q.Size();i++)
+	{
+		p4[0] = Q[i].X();
+		p4[1] = Q[i].Y();
+		p4[2] = Q[i].Z();
+
+		distance[i] = Sphere_radius(p4,p_opt,D,M);
+		distance1[i] = Delaunay(p1,p2,p3,p4,p5);
+		if(i==Q.Size())
+			distance[i] = distance[i] * 1.65;
+	}
+
+	/* order  Q's */
+	for(i=1;i<=Q.Size();i++)
+	{
+		min = 1000000.0;
+		for(j=i;j<=Q.Size();j++)
+		{
+			if(min>distance[j])
+			{
+				min_j = j;
+				min = distance[j];
+			}
+		}
+		/* vertauschen */
+		help = distance[i];
+		help_id = id_Q[i];
+		helpx = Q[i].X();
+		helpy = Q[i].Y();
+		helpz = Q[i].Z();
+	
+		distance[i] = distance[min_j];
+		id_Q[i] = id_Q[min_j];
+		Q[i].X() = Q[min_j].X();
+		Q[i].Y() = Q[min_j].Y();
+		Q[i].Z() = Q[min_j].Z();
+	
+		distance[min_j] = help;
+		id_Q[min_j] = help_id;
+		Q[min_j].X() = helpx;
+		Q[min_j].Y() = helpy;
+		Q[min_j].Z() = helpz;
+	}
+		
+	for(i=1;i<npoint+aux_point;i++)
+	{
+		dummy = P[i];
+		Q.Append(dummy);
+		id_Q.Append(lpoints.Size()+1);
+	}
+	for(i=1;i<=Q.Size();i++)
+	{
+		OL.Append(Q[i]);
+		id_OL.Append(id_Q[i]);
+	}
+
+	if(DEBUG)
+	{
+		for(i=1;i<=OL.Size();i++)
+			printf("%f %f %f %d %f %f\n",OL[i].X(),OL[i].Y(),OL[i].Z(),id_OL[i],distance[i],distance1[i]);
+		printf("\n");
+	}
+	return(1);
+}
+
+
+int Generate_Pyramid (	ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+						ARRAY<Element> & elements,
+						ARRAY<INDEX> & delfaces, ARRAY<int> & prism_flags)
+{
+	int i,j,flag1,flag2,flag3,flag4,new_id,test_id;
+	double l,max_l,dist;
+	Point3d A,B,C,D,M,dummy,P[1+npoint+aux_point],testpoint;
+	Vec3d a,b,n,m,dist_vec;
+	Element element;
+	ARRAY<Point3d> Q;
+	ARRAY<int> id_Q;
+	ARRAY<Point3d> OL;
+	ARRAY<int> id_OL;
+	ARRAY<Point3d> npoints;
+	ARRAY<double> distance;
+	ARRAY<Element> elem;
+
+	if(DEBUG) Local_Out(lpoints,lfaces,prism_flags);
+
+	A = lpoints[lfaces.Get(1).PNum(1)];
+	B = lpoints[lfaces.Get(1).PNum(2)];
+	C = lpoints[lfaces.Get(1).PNum(3)];
+	D = lpoints[lfaces.Get(1).PNum(4)];
+
+	/* centroid of the face */ 
+	M.X() = ( A.X() + B.X() + C.X() + D.X() ) / 4;
+	M.Y() = ( A.Y() + B.Y() + C.Y() + D.Y() ) / 4;
+	M.Z() = ( A.Z() + B.Z() + C.Z() + D.Z() ) / 4;
+
+	/* normalvector on the first face */
+	n = Get_Normalvector_Quad(A,B,C,D);
+	
+	max_l = (B - A).Length();
+	l =  (C - A).Length();
+	if(l>max_l)
+		max_l = l;
+	l =  (C - B).Length();
+	if(l>max_l)
+		max_l = l;
+
+	/* determine inner points */
+	for(i=0;i<npoint;i++)
+	{ 
+		P[i].X() = M.X() - 1.0 * ((double)(npoint-i) / (double)(npoint)) * n.X()/1.0;
+		P[i].Y() = M.Y() - 1.0 * ((double)(npoint-i) / (double)(npoint)) * n.Y()/1.0;
+		P[i].Z() = M.Z() - 1.0 * ((double)(npoint-i) / (double)(npoint)) * n.Z()/1.0;
+	}
+
+	for(i=0;i<aux_point;i++)
+	{
+		P[npoint+i].X() = (M.X()+P[npoint-1+i].X())/2;
+		P[npoint+i].Y() = (M.Y()+P[npoint-1+i].Y())/2;
+		P[npoint+i].Z() = (M.Z()+P[npoint-1+i].Z())/2;
+	}
+	
+	for(i=1;i<=lpoints.Size();i++)
+	{
+		if( (i!=lfaces.Get(1).PNum(1)) && (i!=lfaces.Get(1).PNum(2)) && (i!=lfaces.Get(1).PNum(3)) && (i!=lfaces.Get(1).PNum(4)) )
+		{
+			m = lpoints[i] - M;
+			dummy = lpoints[i];
+			m /= m.Length();
+			if(m*n<0.0)
+			{
+				dist_vec = lpoints[i] - P[0];
+				dist = dist_vec.Length();
+				if((dist<search_radius))
+				{
+					Q.Append(dummy);
+					id_Q.Append(i);
+				}
+			}
+		}
+	}
+
+	OL.SetSize(0);
+	id_OL.SetSize(0);
+	distance.SetSize(Q.Size()+npoint+aux_point+1);
+	for(i=1;i<=Q.Size()+npoint+aux_point;i++)
+		distance[i]=-1.0;
+
+	Order_List3(lpoints,lfaces,Q,P,id_Q,distance,OL,id_OL);
+	
+	new_id = -1;
+	elem.SetSize(0);
+	
+	for(i=1;i<=OL.Size();i++)
+	{
+		test_id = id_OL[i];
+		testpoint.X() = OL[i].X();
+		testpoint.Y() = OL[i].Y();
+		testpoint.Z() = OL[i].Z();
+		flag1 = Cut(1,2,test_id,lpoints,lfaces,testpoint);
+		flag2 = Cut(2,3,test_id,lpoints,lfaces,testpoint);
+		flag3 = Cut(3,4,test_id,lpoints,lfaces,testpoint);
+		flag4 = Cut(4,1,test_id,lpoints,lfaces,testpoint);
+		if( (flag1==0)&&(flag2==0)&&(flag3==0)&&(flag4==0) )
+		{
+			new_id = id_OL[i];
+			for(j=1;j<=lpoints.Size();j++)
+				npoints.Append(lpoints[i]);
+			if(new_id>lpoints.Size())
+				npoints.Append(OL[i]);
+			element.PNum(1) = lfaces.Get(1).PNum(1);
+			element.PNum(2) = lfaces.Get(1).PNum(2);
+			element.PNum(3) = lfaces.Get(1).PNum(3);
+			element.PNum(4) = lfaces.Get(1).PNum(4);
+			element.PNum(5) = new_id;
+			element.SetNP(5);
+			if(new_id>lpoints.Size())
+				lpoints.Append(OL[i]);
+			break;
+		}
+	}
+
+	if(DEBUG)
+		Save_local_Situation(lpoints,lfaces,element);
+		
+	/* create Element */
+	if(new_id==-1)
+	{
+		return(0);
+	}
+	if(DEBUG) printf("%s %d %d %d %d %d\n","create element",	element.PNum(1),element.PNum(2),element.PNum(3),element.PNum(4),element.PNum(5));
+	elements.Append (element);
+		
+	/* delfaces and lfaces */
+	delfaces.Append(1);
+
+	RemoveOrAdd_Triangle(lfaces,delfaces,element.PNum(5),element.PNum(2),element.PNum(1));		
+	RemoveOrAdd_Triangle(lfaces,delfaces,element.PNum(5),element.PNum(3),element.PNum(2));			
+	RemoveOrAdd_Triangle(lfaces,delfaces,element.PNum(5),element.PNum(4),element.PNum(3));		
+	RemoveOrAdd_Triangle(lfaces,delfaces,element.PNum(5),element.PNum(1),element.PNum(4));		
+
+	return(1);
+}
diff -ruN ug-orig/gm/gg3/netgen/meshing/global.cc ug-patched/gm/gg3/netgen/meshing/global.cc
--- ug-orig/gm/gg3/netgen/meshing/global.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/global.cc	2003-12-03 18:27:16.000000000 +0100
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+//#include <strstream.h>
+#include <math.h>
+#include <new.h>
+#include <ctype.h>
+#include <string.h>
+#include <time.h>
+
+
+#include <myadt.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+
+#ifdef MYGRAPH
+#include <geom/rot3d.hh>
+ROT3D rot;
+#endif
+
+#include <meshing/global.hh>
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/global.hh ug-patched/gm/gg3/netgen/meshing/global.hh
--- ug-orig/gm/gg3/netgen/meshing/global.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/global.hh	1996-10-01 19:43:55.000000000 +0200
@@ -0,0 +1,26 @@
+#ifndef FILE_GLOBAL
+#define FILE_GLOBAL
+
+#include <meshing/meshtype.hh>
+
+/**************************************************************************/
+/* File:   global.hh                                                      */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Okt. 95                                                    */
+/**************************************************************************/
+
+/*
+  global functions and variables
+*/
+
+
+class ROT3D;
+extern ROT3D rot;
+
+extern int GetTime ();
+extern int testmode;
+
+class ostream;
+extern ostream * testout;
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/improve3.cc ug-patched/gm/gg3/netgen/meshing/improve3.cc
--- ug-orig/gm/gg3/netgen/meshing/improve3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/improve3.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,821 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <math.h>
+
+#include <myadt.hh>
+
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+
+#include <linalg/linalg.hh>
+
+#include <meshing/global.hh>
+#include <meshing/meshing3.hh>
+// #include <meshing/meshtool.hh>
+
+#include <opti/opti.hh>
+
+static double CalcTetBadness (const Point3d & p1, const Point3d & p2,
+  const Point3d & p3, const Point3d & p4, double h)
+  {
+  double vol, l, l4, l5, l6;
+  double err;
+
+  Vec3d v1 = p2 - p1;
+  Vec3d v2 = p3 - p1;
+  Vec3d v3 = p4 - p1;
+
+  vol = - (Cross (v1, v2) * v3) / 6;
+  l4 = Dist (p2, p3);
+  l5 = Dist (p2, p4);
+  l6 = Dist (p3, p4);
+
+  l = v1.Length() + v2.Length() + v3.Length() + l4 + l5 + l6;
+
+  if (vol < 1e-12) return 1e14;
+  err = (l*l*l) / (1832.82 * vol);    // 6^4 * sqrt(2)
+  
+  if (h > 0)
+    err += l / h + 
+	h * ( 1 / v1.Length() + 1 / v2.Length() + 1 / v3.Length() + 
+		 1 / l4 + 1 / l5 + 1 / l6) - 12;
+  return err;
+  }
+
+
+class PointFunction 
+  {
+  public:
+  ARRAY<Point3d> & points;
+  const ARRAY<Element> & elements;
+  TABLE<INDEX> elementsonpoint;
+  int actpind;
+  double h;
+  
+  public:
+  PointFunction (ARRAY<Point3d> & apoints, 
+                 const ARRAY<Element> & aelements);
+  
+  void SetPointIndex (int aactpind) { actpind = aactpind; }  
+  void SetLocalH (double ah) { h = ah; }
+  double PointFunctionValue (const Point3d & pp) const;
+  double PointFunctionValueGrad (const Point3d & pp, Vector & grad) const;
+  };
+
+
+PointFunction :: PointFunction (ARRAY<Point3d> & apoints, 
+    const ARRAY<Element> & aelements)
+  : points(apoints), elements(aelements), elementsonpoint(apoints.Size())
+  {
+  INDEX i;
+  int j;
+  
+  for (i = 1; i <= elements.Size(); i++)
+    for (j = 1; j <= elements[i].NP(); j++)
+      elementsonpoint.Add (elements[i].PNum(j), i);  
+  }
+
+double PointFunction :: PointFunctionValue (const Point3d & pp) const
+  {
+  int j;
+  INDEX eli;
+  const Element * el;
+  double badness;
+  ARRAY<const Point3d*> p(4);
+  Point3d hp;
+
+  badness = 0;
+
+  hp = points.Elem(actpind);
+  points.Elem(actpind) = pp;
+
+  for (j = 1; j <= elementsonpoint.EntrySize(actpind); j++)
+    {
+    eli = elementsonpoint.Get(actpind, j);
+    el = &elements.Get(eli);
+    badness += CalcTetBadness (points.Get(el->PNum(1)), 
+        points.Get(el->PNum(2)), points.Get(el->PNum(3)), 
+        points.Get(el->PNum(4)), h);
+    }
+  
+  points.Elem(actpind) = hp; 
+  return badness;
+  }
+
+
+double PointFunction :: PointFunctionValueGrad (const Point3d & pp, Vector & grad) const
+  {
+  double f, fr, fl, delta = 1e-6;
+  Point3d hpp;
+
+  f = PointFunctionValue (pp);
+
+  hpp = pp;
+  hpp.X() = pp.X() + delta;
+  fr = PointFunctionValue (hpp);
+  hpp.X() = pp.X() - delta;
+  fl = PointFunctionValue (hpp);
+  grad.Elem(1) = (fr - fl) / (2 * delta);
+
+  hpp = pp;
+  hpp.Y() = pp.Y() + delta;
+  fr = PointFunctionValue (hpp);
+  hpp.Y() = pp.Y() - delta;
+  fl = PointFunctionValue (hpp);
+  grad.Elem(2) = (fr - fl) / (2 * delta);
+
+  hpp = pp;
+  hpp.Z() = pp.Z() + delta;
+  fr = PointFunctionValue (hpp);
+  hpp.Z() = pp.Z() - delta;
+  fl = PointFunctionValue (hpp);
+  grad.Elem(3) = (fr - fl) / (2 * delta);
+
+  return f;
+  }
+
+
+
+
+class Opti3FreeMinFunction : public MinFunction
+  {
+  const PointFunction & pf;
+  Point3d sp1;
+  
+  public:
+  Opti3FreeMinFunction (const PointFunction & apf);
+  void SetPoint (const Point3d & asp1) { sp1 = asp1; }
+  virtual double FuncGrad (const Vector & x, Vector & g) const;
+  };
+
+
+Opti3FreeMinFunction :: Opti3FreeMinFunction (const PointFunction & apf)
+  : pf(apf)
+  {
+    ;
+  }
+  
+double Opti3FreeMinFunction :: FuncGrad (const Vector & x, Vector & grad) const
+  {
+  Point3d pp;
+  pp.X() = sp1.X() + x.Get(1);
+  pp.Y() = sp1.Y() + x.Get(2);
+  pp.Z() = sp1.Z() + x.Get(3);
+
+  return pf.PointFunctionValueGrad (pp, grad);
+  }
+
+  
+void Meshing3 :: ImproveMesh (ARRAY<Point3d> & points,
+      const ARRAY<Element> & elements,
+      int nboundnodes, double h)
+  {
+  INDEX i;
+  
+  Vector x(3);
+
+  PointFunction pf(points, elements);
+  pf.SetLocalH (h);
+  
+  Opti3FreeMinFunction freeminf(pf);
+  
+  for (i = nboundnodes+1; i <= points.Size(); i++)
+    {
+    
+    freeminf.SetPoint (points.Elem(i));
+    pf.SetPointIndex (i);
+
+    x = 0;
+    BFGS (x, freeminf);
+
+    points.Elem(i).X() += x.Get(1);
+    points.Elem(i).Y() += x.Get(2);
+    points.Elem(i).Z() += x.Get(3);
+    }
+  }
+
+
+
+static double CalcBad (const ARRAY<Point3d> & points,
+	const Element & elem, double h)
+  {
+  return CalcTetBadness ( 
+            points.Get(elem.PNum(1)), 
+            points.Get(elem.PNum(2)),  
+            points.Get(elem.PNum(3)),  
+            points.Get(elem.PNum(4)), h);  
+  }
+
+
+void Meshing3 :: CombineImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements,
+      int nboundnodes, double /* h */)
+  {
+  int i, j, k, l;
+  Point3d p1, p2, pnew;
+  int pi1, pi2;
+  Element * elem;
+  double bad1, bad2;
+
+  TABLE<int> elementsonnode(points.Size()); 
+  ARRAY<Element*> hasonepoint;
+  ARRAY<Element*> hasbothpoints;
+  
+  for (i = 1; i <= elements.Size(); i++)
+    for (j = 1; j <= elements.Get(i).NP(); j++)
+      elementsonnode.Add (elements.Get(i).PNum(j), i);
+
+  bad1 = 0;
+  for (i = 1; i <= elements.Size(); i++)
+    bad1 += CalcBad (points, elements.Get(i), 0);
+
+  for (i = 1; i <= elements.Size(); i++)
+    {
+    for (j = 1; j <= 6; j++)
+      {
+      elem = &elements.Elem(i);
+      if (elem->PNum(1) == 0) continue;
+
+      switch (j)
+        {
+        case 1: pi1 = elem->PNum(1); pi2 = elem->PNum(2); break;
+        case 2: pi1 = elem->PNum(1); pi2 = elem->PNum(3); break;
+        case 3: pi1 = elem->PNum(1); pi2 = elem->PNum(4); break;
+        case 4: pi1 = elem->PNum(2); pi2 = elem->PNum(3); break;
+        case 5: pi1 = elem->PNum(2); pi2 = elem->PNum(4); break;
+        case 6: pi1 = elem->PNum(3); pi2 = elem->PNum(4); break;
+        }
+
+      if (pi2 < pi1) ng_swap (pi1, pi2);
+      
+      hasonepoint.SetSize(0);
+      hasbothpoints.SetSize(0);
+
+      for (k = 1; k <= elementsonnode.EntrySize(pi1); k++)
+        {
+        elem = &elements[elementsonnode.Get (pi1, k)];
+        if (elem->PNum(1) > 0)
+          {
+          if (elem->PNum(1) == pi2 || elem->PNum(2) == pi2 ||
+              elem->PNum(3) == pi2 || elem->PNum(4) == pi2)
+            hasbothpoints.Append (elem);
+          else
+            hasonepoint.Append (elem);    
+          } 
+        } 
+
+      for (k = 1; k <= elementsonnode.EntrySize(pi2); k++)
+        {
+        elem = &elements[elementsonnode.Get (pi2, k)];
+        if (elem->PNum(1) > 0)
+          {
+          if (elem->PNum(1) == pi1 || elem->PNum(2) == pi1 ||
+              elem->PNum(3) == pi1 || elem->PNum(4) == pi1)
+            ;
+          else
+            hasonepoint.Append (elem);    
+          } 
+        } 
+       
+      bad1 = 0;
+      for (k = 1; k <= hasonepoint.Size(); k++)
+        {
+        elem = hasonepoint.Get(k);
+        bad1 += CalcTetBadness ( 
+            points.Get(elem->PNum(1)), 
+            points.Get(elem->PNum(2)),  
+            points.Get(elem->PNum(3)),  
+            points.Get(elem->PNum(4)), 0);
+        }
+
+      for (k = 1; k <= hasbothpoints.Size(); k++)
+        {
+        elem = hasbothpoints.Get(k);
+        bad1 += CalcTetBadness ( 
+            points.Get(elem->PNum(1)), 
+            points.Get(elem->PNum(2)),  
+            points.Get(elem->PNum(3)),  
+            points.Get(elem->PNum(4)), 0);
+        }
+      
+        
+      p1 = points[pi1];
+      p2 = points[pi2];
+
+      if (pi2 <= nboundnodes) 
+        continue;
+	
+      if (pi1 <= nboundnodes)
+        pnew = p1;
+      else
+        pnew = Center (p1, p2);
+	
+      points[pi1] = pnew;
+      points[pi2] = pnew;
+
+      bad2 = 0;
+      for (k = 1; k <= hasonepoint.Size(); k++)
+        {
+        elem = hasonepoint.Get(k);
+        bad2 += CalcTetBadness ( 
+            points.Get(elem->PNum(1)), 
+            points.Get(elem->PNum(2)),  
+            points.Get(elem->PNum(3)),  
+            points.Get(elem->PNum(4)), 0);
+        }
+       
+      points[pi1] = p1;
+      points[pi2] = p2;
+ 
+      if (bad2 / hasonepoint.Size()  < 
+      	  bad1 / (hasonepoint.Size()+hasbothpoints.Size())  )
+        {
+        points[pi1] = pnew;
+        for (k = 1; k <= elementsonnode.EntrySize(pi2); k++)
+          {
+          elem = &elements[elementsonnode.Get (pi2, k)];
+	  elementsonnode.Add (pi1, elementsonnode.Get (pi2, k));
+          for (l = 1; l <= elem->NP(); l++)
+            if (elem->PNum(l) == pi2)
+              elem->PNum(l) = pi1;
+          }
+
+        for (k = 1; k <= hasbothpoints.Size(); k++)
+          for (l = 1; l <= 4; l++)
+            hasbothpoints[k] -> PNum(l) = 0;
+
+        // cout << "bad1 = " << bad1 << " bad2 = " << bad2 << endl;  
+        }
+      }
+    }
+
+  for (k = elements.Size(); k >= 1; k--)
+    if (elements[k].PNum(1) == 0)
+      elements.DeleteElement(k);
+
+  } 
+
+
+void Meshing3 :: SplitImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements, ARRAY<Element> & surfelements, 
+      double /* h */)
+  {
+  int i, j, k, l;
+  INDEX_2 i2;
+  Point3d p1, p2, pnew;
+  int elnr;
+  int pi1, pi2;
+  Element * elem;
+  double bad1, bad2;
+  int has1, has2;
+
+  TABLE<int> elementsonnode(points.Size()); 
+  ARRAY<int> hasbothpoints;
+  INDEX_2_HASHTABLE<int> boundaryedges(surfelements.Size());
+  
+
+  bad1 = 0;
+  for (i = 1; i <= elements.Size(); i++)
+    bad1 += CalcBad (points, elements.Get(i), 0);
+
+  for (i = 1; i <= surfelements.Size(); i++)
+    for (j = 1; j <= 3; j++)
+      {
+      i2.I1() = surfelements.Get(i).PNumMod(j);
+      i2.I2() = surfelements.Get(i).PNumMod(j+1);
+      if (i2.I1() > i2.I2()) ng_swap (i2.I1(), i2.I2());
+      boundaryedges.Set (i2, 1);
+      }
+
+  for (i = 1; i <= elements.Size(); i++)
+    for (j = 1; j <= elements.Get(i).NP(); j++)
+      elementsonnode.Add (elements.Get(i).PNum(j), i);
+
+  for (i = 1; i <= elements.Size(); i++)
+    {
+    for (j = 1; j <= 6; j++)
+      {
+      elem = &elements.Elem(i);
+      switch (j)
+        {
+        case 1: pi1 = elem->PNum(1); pi2 = elem->PNum(2); break;
+        case 2: pi1 = elem->PNum(1); pi2 = elem->PNum(3); break;
+        case 3: pi1 = elem->PNum(1); pi2 = elem->PNum(4); break;
+        case 4: pi1 = elem->PNum(2); pi2 = elem->PNum(3); break;
+        case 5: pi1 = elem->PNum(2); pi2 = elem->PNum(4); break;
+        case 6: pi1 = elem->PNum(3); pi2 = elem->PNum(4); break;
+        }
+
+      if (pi2 < pi1) ng_swap (pi1, pi2);
+
+      if (pi2 > elementsonnode.Size()) continue;
+  
+      i2.I1() = pi1;
+      i2.I2() = pi2;    
+      if (boundaryedges.Used (i2)) continue;
+
+
+      hasbothpoints.SetSize (0);
+      for (k = 1; k <= elementsonnode.EntrySize(pi1); k++)
+        {
+	has1 = has2 = 0;
+	elnr = elementsonnode.Get(pi1, k);
+	elem = &elements.Elem (elnr);
+	for (l = 1; l <= elem->NP(); l++)
+	  {
+	  if (elem->PNum(l) == pi1) has1 = 1;
+	  if (elem->PNum(l) == pi2) has2 = 1;
+	  }
+	if (has1 && has2) 
+	  { // only once
+	  for (l = 1; l <= hasbothpoints.Size(); l++)
+	    if (hasbothpoints.Get(l) == elnr)
+	      has1 = 0;
+	      
+	  if (has1)
+            hasbothpoints.Append (elnr);
+	  }
+	}
+      
+
+      bad1 = 0;
+      for (k = 1; k <= hasbothpoints.Size(); k++)
+        bad1 += CalcBad (points, elements.Get(hasbothpoints.Get(k)), 0);
+
+      p1 = points.Get(pi1);
+      p2 = points.Get(pi2);
+      pnew = Center (p1, p2);
+
+      points.Elem(pi1) = pnew;
+      bad2 = 0;
+      for (k = 1; k <= hasbothpoints.Size(); k++)
+        bad2 += CalcBad (points, elements.Get(hasbothpoints.Get(k)), 0);
+      points.Elem(pi1) = p1;
+
+      points.Elem(pi2) = pnew;
+      for (k = 1; k <= hasbothpoints.Size(); k++)
+        bad2 += CalcBad (points, elements.Get(hasbothpoints.Get(k)), 0);
+      points.Elem(pi2) = p2;
+
+      if (bad2 < bad1)
+        {
+        // cout << "Split Edge" << endl;
+        }
+      }
+    }
+  }
+       
+
+      
+  
+
+void Meshing3 :: SwapImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements, ARRAY<Element> & surfelements, 
+      double /* h */)
+  {
+  int i, j, k, l;
+  INDEX_2 i2;
+  int elnr;
+  int pi1, pi2, pi3, pi4, pi5, pi6;
+  Element el21(4), el22(4), el31(4), el32(4), el33(4);
+  Element el1(4), el2(4), el3(4), el4(4);
+  Element el1b(4), el2b(4), el3b(4), el4b(4);
+  Element * elem;
+  double bad1, bad2, bad3;
+  int has1, has2;
+
+  TABLE<int> elementsonnode(points.Size()); 
+  ARRAY<int> hasbothpoints;
+  INDEX_2_HASHTABLE<int> boundaryedges(surfelements.Size());
+  
+
+  // cout << "SwapImprove" << endl;
+  // cout << "Vol = " << CalcVolume (points, elements) << endl;
+
+  bad1 = 0;
+  for (i = 1; i <= elements.Size(); i++)
+    bad1 += CalcBad (points, elements.Get(i), 0);
+  // cout << "Total badness = " << bad1 << endl;
+
+  for (i = 1; i <= surfelements.Size(); i++)
+    for (j = 1; j <= 3; j++)
+      {
+      i2.I1() = surfelements.Get(i).PNumMod(j);
+      i2.I2() = surfelements.Get(i).PNumMod(j+1);
+      if (i2.I1() > i2.I2()) ng_swap (i2.I1(), i2.I2());
+      boundaryedges.Set (i2, 1);
+      }
+
+  for (i = 1; i <= elements.Size(); i++)
+    for (j = 1; j <= elements.Get(i).NP(); j++)
+      elementsonnode.Add (elements.Get(i).PNum(j), i);
+
+  for (i = 1; i <= elements.Size(); i++)
+    {
+    for (j = 1; j <= 6; j++)
+      {
+      elem = &elements.Elem(i);
+      if (elem->PNum(1) == 0) continue;
+
+      switch (j)
+        {
+        case 1: pi1 = elem->PNum(1); pi2 = elem->PNum(2); break;
+        case 2: pi1 = elem->PNum(1); pi2 = elem->PNum(3); break;
+        case 3: pi1 = elem->PNum(1); pi2 = elem->PNum(4); break;
+        case 4: pi1 = elem->PNum(2); pi2 = elem->PNum(3); break;
+        case 5: pi1 = elem->PNum(2); pi2 = elem->PNum(4); break;
+        case 6: pi1 = elem->PNum(3); pi2 = elem->PNum(4); break;
+        }
+
+      if (pi2 < pi1) ng_swap (pi1, pi2);
+  
+      i2.I1() = pi1;
+      i2.I2() = pi2;    
+      if (boundaryedges.Used (i2)) continue;
+//      if (pi2 <= nboundnodes) continue;
+      
+      hasbothpoints.SetSize (0);
+      for (k = 1; k <= elementsonnode.EntrySize(pi1); k++)
+        {
+	has1 = has2 = 0;
+	elnr = elementsonnode.Get(pi1, k);
+	elem = &elements.Elem (elnr);
+	for (l = 1; l <= elem->NP(); l++)
+	  {
+	  if (elem->PNum(l) == pi1) has1 = 1;
+	  if (elem->PNum(l) == pi2) has2 = 1;
+	  }
+	if (has1 && has2) 
+	  { // only once
+	  for (l = 1; l <= hasbothpoints.Size(); l++)
+	    if (hasbothpoints.Get(l) == elnr)
+	      has1 = 0;
+	      
+	  if (has1)
+            hasbothpoints.Append (elnr);
+	  }
+	}
+	
+      
+      if (hasbothpoints.Size() == 3)
+        {
+	elem = &elements.Elem (hasbothpoints.Get(1));
+	for (l = 1; l <= 4; l++)
+	  if (elem->PNum(l) != pi1 && elem->PNum(l) != pi2)
+	    {
+	    pi4 = pi3;
+	    pi3 = elem->PNum(l);
+	    }
+
+	el31.PNum(1) = pi1;
+	el31.PNum(2) = pi2;
+	el31.PNum(3) = pi3;
+	el31.PNum(4) = pi4;
+	if (CalcBad (points, el31, 0) > 1e8)
+	  {
+	  ng_swap (pi3, pi4);
+	  el31.PNum(3) = pi3;
+	  el31.PNum(4) = pi4;
+	  }
+	  
+	pi5 = 0;
+	for (k = 2; k <= 3; k++)
+	  {
+	  elem = &elements.Elem(hasbothpoints.Get(k));
+	  has1 = 0;
+	  for (l = 1; l <= 4; l++)
+	    if (elem->PNum(l) == pi4)
+	      has1 = 1;
+	  if (has1)
+	    {
+	    for (l = 1; l <=4; l++)
+	      if (elem->PNum(l) != pi1 && elem->PNum(l) != pi2 && 
+	      	  elem->PNum(l) != pi4)
+		pi5 = elem->PNum(l);
+	    }
+	  }
+	  
+	el32.PNum(1) = pi1;  
+	el32.PNum(2) = pi2;  
+	el32.PNum(3) = pi4;  
+	el32.PNum(4) = pi5;  
+	
+        el33.PNum(1) = pi1;  
+	el33.PNum(2) = pi2;  
+	el33.PNum(3) = pi5;  
+	el33.PNum(4) = pi3;  
+
+        elementsonnode.Add (pi4, hasbothpoints.Elem(2));
+        elementsonnode.Add (pi3, hasbothpoints.Elem(3));
+		
+	bad1 = CalcBad (points, el31, 0) + CalcBad (points, el32, 0) +
+	       CalcBad (points, el33, 0);
+ 	
+	el21.PNum(1) = pi3;
+	el21.PNum(2) = pi4;
+	el21.PNum(3) = pi5;
+	el21.PNum(4) = pi2;
+	
+	el22.PNum(1) = pi5;
+	el22.PNum(2) = pi4;
+	el22.PNum(3) = pi3;
+	el22.PNum(4) = pi1;
+	
+	bad2 = CalcBad (points, el21, 0) + CalcBad (points, el22, 0);
+	
+	if (bad2 < bad1)
+	  {
+	  // cout << "3->2 conversion" << endl;
+	  elements.Elem (hasbothpoints.Get(1)) = el21;
+	  elements.Elem (hasbothpoints.Get(2)) = el22;
+	  for (l = 1; l <= 4; l++)
+	    elements.Elem (hasbothpoints.Get(3)).PNum(l) = 0;
+
+          for (k = 1; k <= 2; k++)
+            for (l = 1; l <= 4; l++)
+              elementsonnode.Add (
+	      	elements.Get(hasbothpoints.Get(k)).PNum(l), 
+		hasbothpoints.Get(k));
+	  }
+	}
+
+
+
+      if (hasbothpoints.Size() == 4)
+        {
+	elem = &elements.Elem (hasbothpoints.Get(1));
+	for (l = 1; l <= 4; l++)
+	  if (elem->PNum(l) != pi1 && elem->PNum(l) != pi2)
+	    {
+	    pi4 = pi3;
+	    pi3 = elem->PNum(l);
+	    }
+
+	el1.PNum(1) = pi1;
+	el1.PNum(2) = pi2;
+	el1.PNum(3) = pi3;
+	el1.PNum(4) = pi4;
+	if (CalcBad (points, el1, 0) > 1e8)
+	  {
+	  ng_swap (pi3, pi4);
+	  el1.PNum(3) = pi3;
+	  el1.PNum(4) = pi4;
+	  }
+	  
+	pi5 = 0;
+	for (k = 2; k <= 4; k++)
+	  {
+	  elem = &elements.Elem(hasbothpoints.Get(k));
+	  has1 = 0;
+	  for (l = 1; l <= 4; l++)
+	    if (elem->PNum(l) == pi4)
+	      has1 = 1;
+	  if (has1)
+	    {
+	    for (l = 1; l <=4; l++)
+	      if (elem->PNum(l) != pi1 && elem->PNum(l) != pi2 && 
+	      	  elem->PNum(l) != pi4)
+		pi5 = elem->PNum(l);
+	    }
+	  }
+
+	pi6 = 0;
+	for (k = 2; k <= 4; k++)
+	  {
+	  elem = &elements.Elem(hasbothpoints.Get(k));
+	  has1 = 0;
+	  for (l = 1; l <= 4; l++)
+	    if (elem->PNum(l) == pi3)
+	      has1 = 1;
+	  if (has1)
+	    {
+	    for (l = 1; l <=4; l++)
+	      if (elem->PNum(l) != pi1 && elem->PNum(l) != pi2 && 
+	      	  elem->PNum(l) != pi3)
+		pi6 = elem->PNum(l);
+	    }
+	  }
+
+	  
+	el1.PNum(1) = pi1;  
+	el1.PNum(2) = pi2;  
+	el1.PNum(3) = pi3;  
+	el1.PNum(4) = pi4; 
+	 
+	el2.PNum(1) = pi1;  
+	el2.PNum(2) = pi2;  
+	el2.PNum(3) = pi4;  
+	el2.PNum(4) = pi5;  
+	  
+	el3.PNum(1) = pi1;  
+	el3.PNum(2) = pi2;  
+	el3.PNum(3) = pi5;  
+	el3.PNum(4) = pi6;  
+	  
+	el4.PNum(1) = pi1;  
+	el4.PNum(2) = pi2;  
+	el4.PNum(3) = pi6;  
+	el4.PNum(4) = pi3;  
+
+//        elementsonnode.Add (pi4, hasbothpoints.Elem(2));
+//        elementsonnode.Add (pi3, hasbothpoints.Elem(3));
+		
+	bad1 = CalcBad (points, el1, 0) + CalcBad (points, el2, 0) +
+	       CalcBad (points, el3, 0) + CalcBad (points, el4, 0);
+ 	
+	
+	el1.PNum(1) = pi3;  
+	el1.PNum(2) = pi5;  
+	el1.PNum(3) = pi2;  
+	el1.PNum(4) = pi4; 
+	 
+	el2.PNum(1) = pi3;  
+	el2.PNum(2) = pi5;  
+	el2.PNum(3) = pi4;  
+	el2.PNum(4) = pi1;  
+	  
+	el3.PNum(1) = pi3;  
+	el3.PNum(2) = pi5;  
+	el3.PNum(3) = pi1;  
+	el3.PNum(4) = pi6;  
+	  
+	el4.PNum(1) = pi3;  
+	el4.PNum(2) = pi5;  
+	el4.PNum(3) = pi6;  
+	el4.PNum(4) = pi2;  
+		
+	bad2 = CalcBad (points, el1, 0) + CalcBad (points, el2, 0) +
+	       CalcBad (points, el3, 0) + CalcBad (points, el4, 0);
+ 	
+	el1b.PNum(1) = pi4;  
+	el1b.PNum(2) = pi6;  
+	el1b.PNum(3) = pi3;  
+	el1b.PNum(4) = pi2; 
+	 
+	el2b.PNum(1) = pi4;  
+	el2b.PNum(2) = pi6;  
+	el2b.PNum(3) = pi2;  
+	el2b.PNum(4) = pi5;  
+	  
+	el3b.PNum(1) = pi4;  
+	el3b.PNum(2) = pi6;  
+	el3b.PNum(3) = pi5;  
+	el3b.PNum(4) = pi1;  
+	  
+	el4b.PNum(1) = pi4;  
+	el4b.PNum(2) = pi6;  
+	el4b.PNum(3) = pi1;  
+	el4b.PNum(4) = pi3;  
+		
+	bad3 = CalcBad (points, el1b, 0) + CalcBad (points, el2b, 0) +
+	       CalcBad (points, el3b, 0) + CalcBad (points, el4b, 0);
+ 	
+
+	if (bad2 < bad1 && bad2 < bad3)
+	  {
+          // cout << "bad1 = " << bad1 << " bad2 = " << bad2 << endl;
+	  
+	  elements.Elem (hasbothpoints.Get(1)) = el1;
+	  elements.Elem (hasbothpoints.Get(2)) = el2;
+	  elements.Elem (hasbothpoints.Get(3)) = el3;
+	  elements.Elem (hasbothpoints.Get(4)) = el4;
+
+          for (k = 1; k <= 4; k++)
+            for (l = 1; l <= 4; l++)
+              elementsonnode.Add (
+	      	elements.Get(hasbothpoints.Get(k)).PNum(l), 
+		hasbothpoints.Get(k));
+	  }
+	else if (bad3 < bad1)
+	  {
+          // cout << "bad1 = " << bad1 << " bad3 = " << bad3 << endl;
+	  
+	  elements.Elem (hasbothpoints.Get(1)) = el1b;
+	  elements.Elem (hasbothpoints.Get(2)) = el2b;
+	  elements.Elem (hasbothpoints.Get(3)) = el3b;
+	  elements.Elem (hasbothpoints.Get(4)) = el4b;
+
+          for (k = 1; k <= 4; k++)
+            for (l = 1; l <= 4; l++)
+              elementsonnode.Add (
+	      	elements.Get(hasbothpoints.Get(k)).PNum(l), 
+		hasbothpoints.Get(k));
+	  }
+	}
+
+
+
+
+      }
+    }
+    
+  for (k = elements.Size(); k >= 1; k--)
+    if (elements[k].PNum(1) == 0)
+      elements.DeleteElement(k);
+      
+  }
+  
diff -ruN ug-orig/gm/gg3/netgen/meshing/makefile ug-patched/gm/gg3/netgen/meshing/makefile
--- ug-orig/gm/gg3/netgen/meshing/makefile	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/makefile	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,7 @@
+objects = adfront3.o adfront2.o meshing3.o meshing2.o netrule3.o netrule2.o \
+	  parser3.o parser2.o ruler3.o ruler2.o findip.o gen_elem.o cross_check.o\
+          global.o meshtype.o nginterface.o improve3.o
+
+
+include ../makefile.inc
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshing2.cc ug-patched/gm/gg3/netgen/meshing/meshing2.cc
--- ug-orig/gm/gg3/netgen/meshing/meshing2.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshing2.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,586 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <new.h>
+#include <ctype.h>
+#include <string.h>
+
+#include <template.hh>
+#include <array.hh>
+#include <table.hh>
+
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+#include <linalg/linalg.hh>
+
+
+#include <meshing/meshtype.hh>
+#include <meshing/global.hh>
+
+#include <meshing/adfront2.hh>
+#include <meshing/ruler2.hh>
+
+#include <meshing/meshing2.hh>
+
+
+extern void PlotSurface (const ROT3D & r, char key);
+extern void SteepestDescent (Vector & x, double (*f) (const Vector & x, Vector & g));
+extern void Drawowngeo(Element & ele,const ROT3D & r);
+
+
+
+
+static ARRAY<Point3d> locpoints;
+static ARRAY<Point2d> plainpoints;
+static ARRAY<ILINE> loclines;
+static int cntelem;
+static int oldnl;
+static int qualclass, surfind;
+static const Meshing2 * meshthis;
+
+
+Meshing2 :: Meshing2 (char * rulefilename)
+  {
+//  LoadRules ("triangle.rls");
+  adfront = new ADFRONT2();
+  }
+
+Meshing2 :: ~Meshing2 ()
+  {
+  int i;
+  if (adfront) delete adfront;
+  adfront = NULL;
+  for (i = 1; i <= rules.Size(); i++)
+    delete rules[i];
+  rules.SetSize (0);
+  }
+
+void Meshing2 :: AddPoint (const Point3d & p, INDEX globind)
+  {
+  adfront ->AddPoint (p, globind);
+  }
+
+void Meshing2 :: AddBoundaryElement (INDEX i1, INDEX i2, int surfind)
+  {
+  adfront ->AddLine (i1, i2, surfind);
+  }
+
+
+void Meshing2 :: StartMesh ()
+  {
+  int i;
+
+  ruleused.SetSize (rules.Size());
+  for (i = 1; i <= ruleused.Size(); i++)
+    ruleused[i] = 0;
+  cntelem = 0;
+  }
+
+void Meshing2 :: EndMesh ()
+  {
+  }
+
+double Meshing2 :: CalcLocalH (const Point3d &  p, int /* surfind */,
+        double gh) const
+  {
+  return gh;
+  }
+
+
+
+static Vec3d ex, ey;
+static Point3d globp1;
+
+void Meshing2 :: DefineTransformation (INDEX /* surfind */, Point3d & p1, Point3d & p2)
+  {
+  globp1 = p1;
+  ex = p2 - p1;
+  ex /= ex.Length();
+  ey.X() = -ex.Y();
+  ey.Y() =  ex.X();
+  ey.Z() = 0;
+  }
+
+void Meshing2 :: TransformToPlain (INDEX /* surfind */, const Point3d & locpoint,
+      Point2d & plainpoint, double h)
+  {
+  Vec3d p1p;
+
+  p1p = locpoint - globp1;
+  p1p /= h;
+  plainpoint.X() = p1p * ex;
+  plainpoint.Y() = p1p * ey;
+  }
+
+void Meshing2 :: TransformFromPlain (INDEX /* surfind */, Point2d & plainpoint,
+      Point3d & locpoint, double h)
+  {
+  Vec3d p1p;
+
+  p1p = plainpoint.X() * ex + plainpoint.Y() * ey;
+  p1p *= h;
+  locpoint = globp1 + p1p;
+  }
+
+void Meshing2 :: GetNormalVector(INDEX /* surfind */, const Point3d & /* p */, Vec3d & n) const
+  {
+  n.X() = 0;
+  n.Y() = 0;
+  n.Z() = 1;
+  }
+
+
+
+
+
+void Meshing2 :: Mesh (double gh)
+{
+  ARRAY<INDEX> pindex, lindex;
+  ARRAY<int> delpoints, dellines;
+  ARRAY<Element> locelements;
+  int i, j, oldnp,flag;
+  char found;
+  INDEX globind;
+  static ARRAY<Point3d> locp;
+
+  double h;
+  Point2d bemp, bemp1, bemp2;
+
+  testmode = 0;
+  meshthis = this;
+
+  StartMesh();
+
+  adfront ->SetStartFront ();
+  while (!adfront ->Empty())
+
+    {
+        
+    qualclass =
+        adfront ->GetLocals (locpoints, loclines, pindex, lindex,
+                          surfind, 60 * gh, 1.0);
+    oldnp = locpoints.Size();
+    oldnl = loclines.Size();
+
+
+    bemp1.X() = locpoints[loclines[1].I1()].X();
+    bemp1.Y() = locpoints[loclines[1].I1()].Y();
+    bemp2.X() = locpoints[loclines[1].I2()].X();
+    bemp2.Y() = locpoints[loclines[1].I2()].Y();
+
+    bemp = Center (bemp1, bemp2);
+    bemp.Y() += 0.1 * (bemp2.X() - bemp1.X());
+    bemp.X() -= 0.1 * (bemp2.Y() - bemp1.Y());
+
+    h = CalcLocalH (Point3d (bemp.X(), bemp.Y(), 0), surfind, gh);
+
+    DefineTransformation (surfind, locpoints[loclines[1].I1()],
+                                   locpoints[loclines[1].I2()]);
+
+    plainpoints.SetSize (locpoints.Size());
+    for (i = 1; i <= locpoints.Size(); i++)
+      TransformToPlain (surfind, locpoints[i], plainpoints[i], h);
+
+    cout << " locpoints and plainpoints" << endl;
+    for (i = 1; i <= locpoints.Size(); i++)
+    {
+      cout << locpoints[i].X() << "  " <<  locpoints[i].Y() << "  " <<  locpoints[i].Z() << endl; 
+      cout << plainpoints[i].X() << "  " <<  plainpoints[i].Y() << endl; 
+    }
+
+
+    for (i = 2; i <= loclines.Size(); i++)  // don't remove first line
+      {
+      if (plainpoints[loclines[i].I1()].X() > 1e6 ||
+          plainpoints[loclines[i].I2()].X() > 1e6)
+        {
+        loclines.DeleteElement(i);
+        lindex.DeleteElement(i);
+        oldnl--;
+        i--;
+        }
+      }
+
+
+    found = ApplyRules (rules, plainpoints, loclines, locelements,
+                        dellines, qualclass);
+
+    flag = 1;
+    if(found)
+      locpoints.SetSize (plainpoints.Size());
+      for (i = oldnp+1; i <= plainpoints.Size(); i++)
+        TransformFromPlain (surfind, plainpoints[i], locpoints[i], h);
+      pindex.SetSize(locpoints.Size());
+      for (i = oldnp+1; i <= locpoints.Size(); i++)
+      {
+	TestPoint(locpoints[i],flag);
+      }
+
+    if (found)
+      {
+      ruleused[found]++;
+
+      locpoints.SetSize (plainpoints.Size());
+      for (i = oldnp+1; i <= plainpoints.Size(); i++)
+        TransformFromPlain (surfind, plainpoints[i], locpoints[i], h);
+
+      pindex.SetSize(locpoints.Size());
+
+      for (i = oldnp+1; i <= locpoints.Size(); i++)
+        {
+        globind = SavePoint (locpoints[i]);
+        pindex[i] = adfront -> AddPoint (locpoints[i], globind);
+        }
+
+      for (i = oldnl+1; i <= loclines.Size(); i++)
+      {
+        adfront -> AddLine (pindex[loclines[i].I1()],
+                            pindex[loclines[i].I2()], surfind);
+      }
+
+      for (i = 1; i <= locelements.Size(); i++)
+        {
+        for (j = 1; j <= locelements[i].NP(); j++)
+          locelements[i].PNum(j) =
+              adfront -> GetGlobalIndex (pindex[locelements[i].PNum(j)]);
+
+
+        locelements[i].SetSurfaceIndex (surfind);
+
+        SaveElement (locelements[i]);
+        cntelem++;
+        }
+
+      for (i = 1; i <= dellines.Size(); i++)
+      {
+        adfront -> DeleteLine (lindex[dellines[i]]);
+      }
+
+      }
+    else
+      {
+      adfront -> IncrementClass (lindex[1]);
+      }
+
+    locpoints.SetSize(0);
+    loclines.SetSize(0);
+    pindex.SetSize(0);
+    lindex.SetSize(0);
+    delpoints.SetSize(0);
+    dellines.SetSize(0);
+    locelements.SetSize(0);
+    
+
+    }
+
+  EndMesh ();
+  }
+
+
+
+static void CalcTriangleBadness (double x2, double x3, double y3, int err2,
+      double h, double & badness, double & g1x, double & g1y)
+  {
+  // badness = sqrt(3) /36 * circumference^2 / area - 1 +
+  //           h / li + li / h - 2
+
+  // p1 = (0, 0), p2 = (x2, 0), p3 = (x3, y3);
+
+  Vec2d v23;
+  double l12, l13, l23, cir, area;
+  static const double c = sqrt(3) / 36;
+  double c1, c2, c3, c4;
+
+  v23.X() = x3 - x2;
+  v23.Y() = y3;
+
+  l12 = x2;
+  l13 = sqrt (x3*x3 + y3*y3);
+  l23 = v23.Length();
+
+  cir = l12 + l13 + l23;
+  area = 0.5 * x2 * y3;
+
+  if (area < 0)
+    {
+    g1x = 0;
+    g1y = 0;
+    badness = 1e10;
+    return;
+    }
+
+  badness = c * cir * cir / area - 1;
+
+  c1 = 2 * c * cir / area;
+  c2 = 0.5 * c * cir * cir / (area * area);
+
+  g1x = c1 * ( - 1 - x3 / l13) - c2 * (-v23.Y());
+  g1y = c1 * (     - y3 / l13) - c2 * ( v23.X());
+
+  if (err2)
+    {
+    badness += cir / h + h/l12 + h/l13 + h/l23 - 6;
+    c3 = 1 / (h * l12) - h / (l12 * l12 * l12);
+    c4 = 1 / (h * l13) - h / (l13 * l13 * l13);
+    g1x -= c3 * x2 + c4 * x3;
+    g1y -= c4 * y3;
+    }
+  }
+
+
+
+static Point3d sp1;
+static Vec3d n, t1, t2;
+static ARRAY<INDEX> locelements(0);
+static ARRAY<int> locrots(0);
+static ARRAY<Point3d> * optpoints;
+static const ARRAY<Element> * optelements;
+static int locerr2;
+static double loch;
+static int surfi, surfi2;
+
+
+double Opti2FunctionValueGrad (const Vector & x, Vector & grad)
+  {
+  int j, rot;
+  INDEX eli;
+  const Element * el;
+  Vec3d n, v1, v2, e1, e2, vgrad;
+  Point3d pp1;
+  Vec2d g1, g2, g3;
+  double badness, hbadness;
+
+  vgrad.X() = 0;
+  vgrad.Y() = 0;
+  vgrad.Z() = 0;
+  badness = 0;
+
+  pp1 = sp1 + (x.Get(1) * t1) + (x.Get(2) * t2);
+  meshthis -> ProjectPoint (surfi, pp1);
+  meshthis -> GetNormalVector (surfi, pp1, n);
+
+  for (j = 1; j <= locelements.Size(); j++)
+    {
+    eli = locelements.Get(j);
+    rot = locrots.Get(j);
+    el = &optelements->Get(eli);
+
+    v1 = optpoints->Get(el->PNumMod(rot + 1)) - pp1;
+    v2 = optpoints->Get(el->PNumMod(rot + 2)) - pp1;
+
+    e1 = v1;
+    e2 = v2;
+    e1 /= e1.Length();
+    e2 -= (e1 * e2) * e1;
+    e2 /= e2.Length();
+
+    if (Cross (e1, e2) * n > 0)
+      {
+      CalcTriangleBadness ( (e1 * v1), (e1 * v2), (e2 * v2), locerr2, loch,
+                            hbadness, g1.X(), g1.Y());
+
+      badness += hbadness;
+
+      vgrad.X() += g1.X() * e1.X() + g1.Y() * e2.X();
+      vgrad.Y() += g1.X() * e1.Y() + g1.Y() * e2.Y();
+      vgrad.Z() += g1.X() * e1.Z() + g1.Y() * e2.Z();
+      }
+    else
+      badness += 1e8;
+    }
+
+  vgrad -= (vgrad * n) * n;
+
+  grad.Elem(1) = vgrad * t1;
+  grad.Elem(2) = vgrad * t2;
+  return badness;
+  }
+
+
+double Opti2EdgeFunctionValueGrad (const Vector & x, Vector & grad)
+  {
+  int j, rot;
+  INDEX eli;
+  const Element * el;
+  Vec3d n1, n2, v1, v2, e1, e2, vgrad;
+  Point3d pp1;
+  Vec2d g1, g2, g3;
+  double badness, hbadness;
+
+  vgrad.X() = 0;
+  vgrad.Y() = 0;
+  vgrad.Z() = 0;
+  badness = 0;
+
+  pp1 = sp1 + x.Get(1) * t1;
+  meshthis -> ProjectPoint2 (surfi, surfi2, pp1);
+
+  for (j = 1; j <= locelements.Size(); j++)
+    {
+    eli = locelements.Get(j);
+    rot = locrots.Get(j);
+    el = &optelements->Get(eli);
+
+    v1 = optpoints->Get(el->PNumMod(rot + 1)) - pp1;
+    v2 = optpoints->Get(el->PNumMod(rot + 2)) - pp1;
+
+    e1 = v1;
+    e2 = v2;
+    e1 /= e1.Length();
+    e2 -= (e1 * e2) * e1;
+    e2 /= e2.Length();
+
+    CalcTriangleBadness ( (e1 * v1), (e1 * v2), (e2 * v2), locerr2, loch,
+                          hbadness, g1.X(), g1.Y());
+
+    badness += hbadness;
+
+    vgrad.X() += g1.X() * e1.X() + g1.Y() * e2.X();
+    vgrad.Y() += g1.X() * e1.Y() + g1.Y() * e2.Y();
+    vgrad.Z() += g1.X() * e1.Z() + g1.Y() * e2.Z();
+    }
+
+  meshthis -> GetNormalVector (surfi, pp1, n1);
+  meshthis -> GetNormalVector (surfi2, pp1, n2);
+
+  v1 = Cross (n1, n2);
+  v1 /= v1.Length();
+
+//  vgrad -= (vgrad * n) * n;
+//  grad.Elem(1) = vgrad * t1;
+//  grad.Elem(2) = vgrad * t2;
+
+  grad.Elem(1) = (vgrad * v1) * (t1 * v1);
+
+  return badness;
+  }
+
+
+
+
+
+
+void Meshing2 :: ImproveMesh (ARRAY<Point3d> & points, const ARRAY<Element> & elements,
+         int improveedges, int numboundarypoints, double h, int steps, int err2)
+  {
+  INDEX i, eli;
+  int j, surfi3;
+  const Element * el;
+
+  Vec3d n1, n2;
+  TABLE<INDEX> elementsonpoint(points.Size());
+  Vector x(2), xedge(1);
+
+  for (i = 1; i <= elements.Size(); i++)
+    for (j = 1; j <= elements[i].NP(); j++)
+      elementsonpoint.Add (elements[i].PNum(j), i);
+
+  loch = h;
+  locerr2 = err2;
+  optpoints = &points;
+  optelements = &elements;
+  meshthis = this;
+
+  if (improveedges)
+    for (i = 1; i <= numboundarypoints; i++)
+      {
+      sp1 = points.Elem(i);
+
+      locelements.SetSize(0);
+      locrots.SetSize (0);
+      surfi = surfi2 = surfi3 = 0;
+
+      for (j = 1; j <= elementsonpoint.EntrySize(i); j++)
+        {
+        eli = elementsonpoint.Get(i, j);
+        el = &elements.Get(eli);
+
+        if (!surfi)
+          surfi = el->SurfaceIndex();
+        else if (surfi != el->SurfaceIndex())
+          {
+          if (surfi2 != 0 && surfi2 != el->SurfaceIndex())
+            surfi3 = el->SurfaceIndex();
+          else
+            surfi2 = el->SurfaceIndex();
+          }
+
+        locelements.Append (eli);
+
+        if (el->PNum(1) == i)
+          locrots.Append (1);
+        else if (el->PNum(2) == i)
+          locrots.Append (2);
+        else
+          locrots.Append (3);
+        }
+
+      if (surfi2 && !surfi3)
+        {
+        GetNormalVector (surfi, sp1, n1);
+        GetNormalVector (surfi2, sp1, n2);
+        t1 = Cross (n1, n2);
+
+         xedge = 0;
+//        BFGS (xedge, Opti2EdgeFunctionValueGrad);
+
+        points.Elem(i).X() += xedge.Get(1) * t1.X();
+        points.Elem(i).Y() += xedge.Get(1) * t1.Y();
+        points.Elem(i).Z() += xedge.Get(1) * t1.Z();
+        ProjectPoint2 (surfi, surfi2, points.Elem(i));
+        }
+      }
+
+
+  for (i = numboundarypoints+1; i <= elementsonpoint.Size(); i++)
+    {
+    sp1 = points.Elem(i);
+
+    locelements.SetSize(0);
+    locrots.SetSize (0);
+    for (j = 1; j <= elementsonpoint.EntrySize(i); j++)
+      {
+      eli = elementsonpoint.Get(i, j);
+      el = &elements.Get(eli);
+      surfi = el->SurfaceIndex();
+
+      locelements.Append (eli);
+
+      if (el->PNum(1) == i)
+        locrots.Append (1);
+      else if (el->PNum(2) == i)
+        locrots.Append (2);
+      else
+        locrots.Append (3);
+      }
+
+    GetNormalVector (surfi, sp1, n);
+    if (fabs (n.X()) > 0.3)
+      {
+      t1.X() = n.Y();
+      t1.Y() = -n.X();
+      t1.Z() = 0;
+      t1 /= t1.Length();
+      }
+    else
+      {
+      t1.X() = 0;
+      t1.Y() = -n.Z();
+      t1.Z() = n.Y();
+      t1 /= t1.Length();
+      }
+    t2 = Cross (n, t1);
+
+    x = 0;
+//    BFGS (x, Opti2FunctionValueGrad);
+
+    points.Elem(i).X() += (x.Get(1) * t1.X() + x.Get(2) * t2.X());
+    points.Elem(i).Y() += (x.Get(1) * t1.Y() + x.Get(2) * t2.Y());
+    points.Elem(i).Z() += (x.Get(1) * t1.Z() + x.Get(2) * t2.Z());
+    ProjectPoint (surfi, points.Elem(i));
+    }
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshing2.hh ug-patched/gm/gg3/netgen/meshing/meshing2.hh
--- ug-orig/gm/gg3/netgen/meshing/meshing2.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshing2.hh	1997-03-04 20:50:59.000000000 +0100
@@ -0,0 +1,51 @@
+#ifndef FILE_MESHING2
+#define FILE_MESHING2
+
+#include <meshing/meshtype.hh>
+#include <meshing/ruler2.hh>
+#include <meshing/adfront2.hh>
+
+class Meshing2
+  {
+  ADFRONT2 * adfront;
+  ARRAY<netrule*> rules;
+  ARRAY<int> ruleused;
+
+  public:
+  Meshing2 (char * rulefilename);
+  virtual ~Meshing2 ();
+
+  void LoadRules (char * filename);
+  void Mesh (double gh);
+
+  void ImproveMesh (ARRAY<Point3d> & points, const ARRAY<Element> & elements,
+         int improveedges, int numboundarypoints, double h, int steps, int err2);
+
+  void AddPoint (const Point3d & p, INDEX globind);
+  void AddBoundaryElement (INDEX i1, INDEX i2, int surfind);
+
+  virtual int SavePoint (const Point3d & /* p */) { return 0; }
+  virtual void SaveElement (const Element & /* elem */) { };
+  virtual void TestPoint (const Point3d & /* p */,int flag) { };
+
+  virtual void DrawTransformation (const ROT3D & /* rot */) const { };
+
+  protected:
+  virtual void StartMesh ();
+  virtual void EndMesh ();
+  virtual double CalcLocalH (const Point3d & p, int surfind, double gh) const;
+
+  virtual void DefineTransformation (INDEX surfind, Point3d & p1, Point3d & p2);
+  virtual void TransformToPlain (INDEX ind, const Point3d & locpoint,
+      Point2d & plainpoint, double h);
+  virtual void TransformFromPlain (INDEX surfind, Point2d & plainpoint,
+      Point3d & locpoint, double h);
+  virtual void ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { };
+  virtual void ProjectPoint2 (INDEX /* surfind */, INDEX /* surfind2 */, Point3d & /* p */) const { };
+  virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const;
+
+  friend double Opti2FunctionValueGrad (const Vector & x, Vector & grad);
+  friend double Opti2EdgeFunctionValueGrad (const Vector & x, Vector & grad);
+  };
+
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshing3.cc ug-patched/gm/gg3/netgen/meshing/meshing3.cc
--- ug-orig/gm/gg3/netgen/meshing/meshing3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshing3.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,758 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <new.h>
+#include <ctype.h>
+#include <string.h>
+#include <limits.h>
+
+#include <myadt.hh>
+
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+#include <geom/reftrans.hh>
+
+#ifdef MYGRAPH
+#include <geom/rot3d.hh>
+#include <graphics/mygraph.hh>
+#endif
+
+#include <linalg/linalg.hh>
+
+#include <meshing/global.hh>
+#include <meshing/meshing3.hh>
+
+/*#include "../../../include/gginterface.h"*/
+
+// global variables for plotting:
+
+static ARRAY<Point3d> locpoints;
+static ARRAY<Element> locfaces;
+static ARRAY<INDEX> pindex, findex;
+static ARRAY<int> style;
+static int cntsucc = 0;
+static long cnttrials = 0;
+static int cntelem = 0;
+static int qualclass;
+static float err;
+static int MESH_DEBUG = 0;
+static int NEW = 1;
+double h;
+
+static ARRAY<Point3d> grouppoints;
+static ARRAY<Element> groupfaces;
+static ARRAY<INDEX> grouppindex, groupfindex;
+
+extern int FindInnerPoint (const ARRAY<Point3d> & grouppoints,
+                            const ARRAY<Element> & groupfaces,
+                            Point3d & p);
+
+Meshing3 :: Meshing3 (char * rulefilename)
+{
+	int i;
+
+	adfront = new ADFRONT3;
+
+	LoadRules_new (rulefilename);
+	ruleused.SetSize (rules_new.Size());
+	for (i = 1; i <= ruleused.Size(); i++)
+		ruleused[i] = 0;
+
+	problems.SetSize (rules_new.Size());
+	for (i = 1; i <= problems.Size(); i++)
+		problems[i] = new char[255];
+}
+
+Meshing3 :: ~Meshing3 ()
+{
+}
+
+void Meshing3 :: AddPoint (const Point3d & p, INDEX globind)
+{
+	adfront->AddPoint (p, globind);
+}
+
+void Meshing3 :: AddBoundaryElement (const Element & elem, int inverse, int prism_flag)
+  {
+  Element helem;
+  INDEX hi;
+
+  helem = elem;
+  if (inverse)
+    {
+    hi = helem.PNum(1);
+    helem.PNum(1) = helem.PNum(2);
+    helem.PNum(2) = hi;
+    }
+
+  adfront->AddFace (helem,prism_flag);
+  }
+
+
+
+
+
+
+void DrawPnF(const ARRAY<Point3d> & pointl, const ARRAY<Element> & facel,
+             ARRAY<int> & style, float xh , const ROT3D & r)
+  {
+#ifdef MYGRAPH
+  INDEX i;
+  int j;
+  const Element * face;
+  int points2d[8];
+  int nold = 0, nnew = 0;
+
+  Point3d c, c2;
+
+  MySetColor (LIGHTBLUE);
+
+  c = Center (pointl[facel[1].PNum(1)], pointl[facel[1].PNum(2)],
+              pointl[facel[1].PNum(3)]);
+
+  for (i = 1; i <= facel.Size(); i++)
+    {
+    c2 = Center (pointl[facel[i].PNum(1)], pointl[facel[i].PNum(2)],
+                 pointl[facel[i].PNum(3)]);
+
+    if (Dist(c, c2) > xh) continue;
+
+    face = &facel[i];
+    for (j = 0; j <= face->NP(); j++)
+      {
+      points2d[2*j  ] = int (r.X(pointl[face->PNumMod(j+1)]));
+      points2d[2*j+1] = int (r.Y(pointl[face->PNumMod(j+1)]));
+      }
+
+    switch (style[i])
+      {
+      case 1: case 2:
+        {
+        MySetColor (RED);
+        MyFillPoly (4, points2d, nold % 4);
+        nold++;
+        break;
+        }
+      case 3:
+        {
+        MySetColor (BLUE);
+        MyFillPoly (4, points2d, nnew % 4 + 4);
+        nnew++;
+        break;
+        }
+      default:
+        {
+        MySetColor (LIGHTBLUE);
+        MyLine3D (pointl[facel[i].PNum(1)], pointl[facel[i].PNum(2)], r);
+        MyLine3D (pointl[facel[i].PNum(1)], pointl[facel[i].PNum(3)], r);
+        MyLine3D (pointl[facel[i].PNum(2)], pointl[facel[i].PNum(3)], r);
+        }
+      }
+    }
+#endif  
+  }
+
+
+
+
+void PlotVolMesh (const ROT3D & r, char key)
+  {
+  }
+
+
+void Meshing3 :: Mesh (double ah,int make_prism)
+{
+	ARRAY<Point3d> plainpoints;
+	ARRAY<int> delpoints, delfaces;
+	ARRAY<int> changepoints;
+	ARRAY<Element> locelements;
+	int i, j, oldnp, oldnf;
+	int found,rotind;
+	referencetransform trans;
+	int gen_prism, gen_pyramid, prism, pyramid;
+	INDEX globind;
+	Point3d inp,bemp,bemp1,bemp2,bemp3;
+	Point3d *hp1, *hp2, *hp3, *hp4, *hp5, *hp6;
+	double in[5];
+	float minerr;
+	int hasfound,dummy;
+	double tetvol,prismvol,pyramidvol;
+	INDEX locfacesplit;
+
+	ARRAY<Point3d> tempnewpoints;
+	ARRAY<Element> tempnewfaces;
+	ARRAY<int> tempdelfaces;
+	ARRAY<Element> templocelements;
+	ARRAY<int> prism_flags;
+	
+	if(ah<0.0)
+		dummy = 1;
+	else
+		dummy = 0;
+		
+	h = ah;
+	adfront->SetStartFront ();
+
+	found = 0;
+	tetvol = 0.0;
+	prismvol = 0.0;
+	pyramidvol = 0.0;
+	
+	gen_pyramid = 0;
+	qualclass = 1;
+//	gen_prism = adfront->Prism();
+	gen_prism = make_prism;
+
+	// generate prism if possible
+	if(gen_prism)
+		while (!adfront -> Empty())
+		{
+			//adfront->Print();
+			h = ah;
+			locpoints.SetSize(0);
+			locfaces.SetSize(0);
+			pindex.SetSize(0);
+			findex.SetSize(0);
+
+			prism = adfront->GetLocals_Prism(locpoints, locfaces, pindex, findex, 3 * h, prism_flags);
+			if(prism==-1)
+			{	
+				gen_prism = 0;
+				gen_pyramid = 1;
+				break;
+			}
+
+			oldnp = locpoints.Size();
+			oldnf = locfaces.Size();
+			found = 0;
+			hasfound = 0;
+			minerr = 1000;	
+
+			trans.Set (	locpoints[locfaces[1].PNumMod(1)],
+						locpoints[locfaces[1].PNumMod(2)],
+						locpoints[locfaces[1].PNumMod(3)], h);
+
+			trans.ToPlain (locpoints, plainpoints);
+
+			cnttrials++;
+
+			found = Generate_Prism (plainpoints, locfaces, locelements,
+									delfaces, prism_flags);
+
+			if (found) cntsucc++;
+
+			locpoints.SetSize (plainpoints.Size());
+			for (i = oldnp+1; i <= plainpoints.Size(); i++)
+				trans.FromPlain (plainpoints[i], locpoints[i]);
+
+			tempnewfaces.SetSize (0);
+			for (i = oldnf+1; i <= locfaces.Size(); i++)
+				tempnewfaces.Append (locfaces[i]);
+
+			tempdelfaces.SetSize (0);
+			for (i = 1; i <= delfaces.Size(); i++)
+				tempdelfaces.Append (delfaces[i]);
+
+			templocelements.SetSize (0);
+			for (i = 1; i <= locelements.Size(); i++)
+				templocelements.Append (locelements[i]);
+
+			locpoints.SetSize (oldnp);
+			locfaces.SetSize (oldnf);
+			delfaces.SetSize (0);
+			locelements.SetSize (0);
+
+			if (found)
+			{
+				for (i = 1; i <= tempnewfaces.Size(); i++)
+					locfaces.Append (tempnewfaces[i]);
+				for (i = 1; i <= tempdelfaces.Size(); i++)
+					delfaces.Append (tempdelfaces[i]);
+				for (i = 1; i <= templocelements.Size(); i++)
+					locelements.Append (templocelements[i]);
+	
+				pindex.SetSize(locpoints.Size());		
+
+				for (i = 1; i <= locelements.Size(); i++)
+				{
+					hp1 = &locpoints[locelements[i].PNum(1)];
+					hp2 = &locpoints[locelements[i].PNum(2)];
+					hp3 = &locpoints[locelements[i].PNum(3)];
+					hp4 = &locpoints[locelements[i].PNum(4)];
+					hp5 = &locpoints[locelements[i].PNum(5)];
+					hp6 = &locpoints[locelements[i].PNum(6)];	
+
+					if(MESH_DEBUG)
+					{
+						cout << locelements[i].PNum(1) <<  " (" << 	locpoints[locelements[i].PNum(1)].X() << "," << 
+																	locpoints[locelements[i].PNum(1)].Y() << "," << 
+																	locpoints[locelements[i].PNum(1)].Z() << ")" << endl;
+						cout << locelements[i].PNum(2) <<  " (" << 	locpoints[locelements[i].PNum(2)].X() << "," << 
+																	locpoints[locelements[i].PNum(2)].Y() << "," << 
+																	locpoints[locelements[i].PNum(2)].Z() << ")" << endl;
+						cout << locelements[i].PNum(3) <<  " (" << 	locpoints[locelements[i].PNum(3)].X() << "," << 
+																	locpoints[locelements[i].PNum(3)].Y() << "," << 
+																	locpoints[locelements[i].PNum(3)].Z() << ")" << endl;
+						cout << locelements[i].PNum(4) <<  " (" << 	locpoints[locelements[i].PNum(4)].X() << "," << 
+																	locpoints[locelements[i].PNum(4)].Y() << "," << 
+																	locpoints[locelements[i].PNum(4)].Z() << ")" << endl;
+						cout << locelements[i].PNum(5) <<  " (" << 	locpoints[locelements[i].PNum(5)].X() << "," << 
+																	locpoints[locelements[i].PNum(5)].Y() << "," << 
+																	locpoints[locelements[i].PNum(5)].Z() << ")" << endl;
+						cout << locelements[i].PNum(6) <<  " (" << 	locpoints[locelements[i].PNum(6)].X() << "," << 
+																	locpoints[locelements[i].PNum(6)].Y() << "," << 
+																	locpoints[locelements[i].PNum(6)].Z() << ")" << endl;
+
+						printf("%d %d %d %d %d %d\n",	locelements[i].PNum(1), 
+															locelements[i].PNum(2), 
+														locelements[i].PNum(3), 
+														locelements[i].PNum(4), 
+														locelements[i].PNum(5), 
+														locelements[i].PNum(6)
+														);
+//						printf("%s %d\n","nff:",adfront->NFF());
+					}
+					prismvol = prismvol 
+							 + (1.0 / 6.0) * ( Cross ( *hp2 - *hp1, *hp3 - *hp1) * (*hp4 - *hp1) )
+							 + (1.0 / 6.0) * ( Cross ( *hp4 - *hp3, *hp5 - *hp3) * (*hp6 - *hp3) )
+							 + (1.0 / 6.0) * ( Cross ( *hp3 - *hp2, *hp4 - *hp2) * (*hp5 - *hp2) );		
+
+					for (j = 1; j <= locelements[i].NP(); j++)
+						locelements[i].PNum(j) =
+							adfront -> GetGlobalIndex (pindex[locelements[i].PNum(j)]);
+
+					SaveElement (locelements[i]);
+					cntelem++;
+				}
+
+				for (i = oldnf+1; i <= locfaces.Size(); i++)
+				{
+					for (j = 1; j <= locfaces[i].NP(); j++)
+						locfaces[i].PNum(j) = pindex[locfaces[i].PNum(j)];
+					adfront->AddFace (locfaces[i],-1);
+				}
+
+				for (i = 1; i <= delfaces.Size(); i++)
+					adfront->DeleteFace (findex[delfaces[i]]);
+			}
+			else		
+				adfront->ResetPrism (findex[1]);
+
+			locelements.SetSize (0);
+			delpoints.SetSize(0);
+			delfaces.SetSize(0);
+			prism_flags.SetSize(0);
+		}
+
+	//adfront->Print();
+	
+	// close with pyramids, if nessesary
+	if(gen_pyramid)
+	{
+		while (!adfront -> Empty())
+		{
+			//adfront->Print();
+			h = ah;
+			locpoints.SetSize(0);
+			locfaces.SetSize(0);
+			pindex.SetSize(0);
+			findex.SetSize(0);
+
+			pyramid = adfront->GetLocals_Pyramid(locpoints, locfaces, pindex, findex, 3 * h);
+			if(pyramid==-1)
+			{
+				gen_pyramid = 0;
+				break;
+			}
+
+			oldnp = locpoints.Size();
+			oldnf = locfaces.Size();
+			found = 0;
+			hasfound = 0;
+			minerr = 1000;
+
+			trans.Set (	locpoints[locfaces[1].PNumMod(1)],
+						locpoints[locfaces[1].PNumMod(2)],
+						locpoints[locfaces[1].PNumMod(3)], h);
+
+			trans.ToPlain (locpoints, plainpoints);
+
+			cnttrials++;
+
+			found = Generate_Pyramid (	plainpoints, locfaces, locelements,
+										delfaces, prism_flags);	
+
+			if (found) cntsucc++;
+
+			locpoints.SetSize (plainpoints.Size());
+			for (i = oldnp+1; i <= plainpoints.Size(); i++)
+				trans.FromPlain (plainpoints[i], locpoints[i]);
+
+			tempnewpoints.SetSize (0);
+			for (i = oldnp+1; i <= locpoints.Size(); i++)
+				tempnewpoints.Append (locpoints[i]);
+
+			tempnewfaces.SetSize (0);
+			for (i = oldnf+1; i <= locfaces.Size(); i++)
+				tempnewfaces.Append (locfaces[i]);
+
+			tempdelfaces.SetSize (0);
+			for (i = 1; i <= delfaces.Size(); i++)
+				tempdelfaces.Append (delfaces[i]);
+
+			templocelements.SetSize (0);
+			for (i = 1; i <= locelements.Size(); i++)
+				templocelements.Append (locelements[i]);
+			
+			locpoints.SetSize (oldnp);
+			locfaces.SetSize (oldnf);
+			delfaces.SetSize (0);
+			locelements.SetSize (0);
+		
+
+			if (found)
+			{
+				for (i = 1; i <= tempnewpoints.Size(); i++)
+					locpoints.Append (tempnewpoints[i]);
+				for (i = 1; i <= tempnewfaces.Size(); i++)
+					locfaces.Append (tempnewfaces[i]);
+				for (i = 1; i <= tempdelfaces.Size(); i++)
+					delfaces.Append (tempdelfaces[i]);
+				for (i = 1; i <= templocelements.Size(); i++)
+					locelements.Append (templocelements[i]);
+	
+				pindex.SetSize(locpoints.Size());		
+
+				for (i = oldnp+1; i <= locpoints.Size(); i++)
+				{
+					globind = SavePoint (locpoints[i]);
+					pindex[i] = adfront -> AddPoint (locpoints[i], globind);
+				}
+
+		 		for (i = 1; i <= locelements.Size(); i++)
+				{
+					hp1 = &locpoints[locelements[i].PNum(1)];
+					hp2 = &locpoints[locelements[i].PNum(2)];
+					hp3 = &locpoints[locelements[i].PNum(3)];
+					hp4 = &locpoints[locelements[i].PNum(4)];
+					hp5 = &locpoints[locelements[i].PNum(5)];	
+
+					if(MESH_DEBUG)
+					{
+						cout << locelements[i].PNum(1) <<  " (" << 	locpoints[locelements[i].PNum(1)].X() << "," << 
+																	locpoints[locelements[i].PNum(1)].Y() << "," << 
+																	locpoints[locelements[i].PNum(1)].Z() << ")" << endl;
+						cout << locelements[i].PNum(2) <<  " (" << 	locpoints[locelements[i].PNum(2)].X() << "," << 
+																	locpoints[locelements[i].PNum(2)].Y() << "," << 
+																	locpoints[locelements[i].PNum(2)].Z() << ")" << endl;
+						cout << locelements[i].PNum(3) <<  " (" << 	locpoints[locelements[i].PNum(3)].X() << "," << 
+																	locpoints[locelements[i].PNum(3)].Y() << "," << 
+																	locpoints[locelements[i].PNum(3)].Z() << ")" << endl;
+						cout << locelements[i].PNum(4) <<  " (" << 	locpoints[locelements[i].PNum(4)].X() << "," << 
+																	locpoints[locelements[i].PNum(4)].Y() << "," << 
+																	locpoints[locelements[i].PNum(4)].Z() << ")" << endl;
+						cout << locelements[i].PNum(5) <<  " (" << 	locpoints[locelements[i].PNum(5)].X() << "," << 
+																	locpoints[locelements[i].PNum(5)].Y() << "," << 
+																	locpoints[locelements[i].PNum(5)].Z() << ")" << endl;
+		
+						printf("%d %d %d %d %d\n",	locelements[i].PNum(1),
+													locelements[i].PNum(2),
+													locelements[i].PNum(3),
+													locelements[i].PNum(4),
+													locelements[i].PNum(5)
+													);
+//						printf("%s %d\n","nff:",adfront->NFF());
+					}
+					pyramidvol = pyramidvol
+							   + (1.0 / 6.0) * ( Cross ( *hp2 - *hp1, *hp4 - *hp1) * (*hp5 - *hp1) )
+							   + (1.0 / 6.0) * ( Cross ( *hp3 - *hp2, *hp4 - *hp2) * (*hp5 - *hp2) );		
+
+					for (j = 1; j <= locelements[i].NP(); j++)
+						locelements[i].PNum(j) = 
+							adfront -> GetGlobalIndex (pindex[locelements[i].PNum(j)]);
+
+					SaveElement (locelements[i]);
+					cntelem++;
+				}
+
+				for (i = oldnf+1; i <= locfaces.Size(); i++)
+				{
+					for (j = 1; j <= locfaces[i].NP(); j++)
+						locfaces[i].PNum(j) = pindex[locfaces[i].PNum(j)];	
+
+					adfront->AddFace (locfaces[i],-1);
+				}	
+
+				for (i = 1; i <= delfaces.Size(); i++)
+					adfront->DeleteFace (findex[delfaces[i]]);
+			}
+			else
+			{
+				printf("%s\n", "Can not create pyramid");
+				assert(0);
+			}
+			locelements.SetSize (0);
+			delpoints.SetSize(0);
+			delfaces.SetSize(0);
+		}
+	}
+	if(make_prism)
+		for(i=1;i<=adfront->NFF();i++)
+			adfront->SetClass(i,1);
+
+	// and now the tetrahedra
+	while (!adfront -> Empty())
+	{
+		//adfront->Print();
+		locpoints.SetSize(0);
+		locfaces.SetSize(0);
+		pindex.SetSize(0);
+		findex.SetSize(0);
+
+		h = ah;
+		if(h>0.0)
+			if(NEW)
+				qualclass = adfront -> GetLocals_Tetrahedra_new (locpoints, locfaces, 
+			      pindex, findex, 3.0 * h, 5.0 * h, locfacesplit,dummy);
+			else
+				qualclass = adfront -> GetLocals_Tetrahedra (locpoints, locfaces, pindex, findex, 3 * h);
+		else
+		{
+			if(NEW)
+				qualclass = adfront -> GetLocals_Tetrahedra_new (locpoints, locfaces, 
+			      pindex, findex, 3.0 * h, 5.0 * h, locfacesplit,dummy);
+			else
+				qualclass = adfront -> GetLocals_Tetrahedra (locpoints, locfaces, pindex, findex, -3 * h);
+ 
+			bemp1.X() = locpoints[locfaces[1].PNum(1)].X();
+			bemp1.Y() = locpoints[locfaces[1].PNum(1)].Y();
+			bemp1.Z() = locpoints[locfaces[1].PNum(1)].Z();
+			bemp2.X() = locpoints[locfaces[1].PNum(2)].X();
+			bemp2.Y() = locpoints[locfaces[1].PNum(2)].Y();
+			bemp2.Z() = locpoints[locfaces[1].PNum(2)].Z();
+			bemp3.X() = locpoints[locfaces[1].PNum(3)].X();
+			bemp3.Y() = locpoints[locfaces[1].PNum(3)].Y();
+			bemp3.Z() = locpoints[locfaces[1].PNum(3)].Z();
+
+			bemp.X() = ( bemp1.X() + bemp2.X() + bemp3.X() ) / 3;
+			bemp.Y() = ( bemp1.Y() + bemp2.Y() + bemp3.Y() ) / 3;
+			bemp.Z() = ( bemp1.Z() + bemp2.Z() + bemp3.Z() ) / 3;
+
+			locpoints.SetSize(0);
+			locfaces.SetSize(0);
+			pindex.SetSize(0);
+			findex.SetSize(0);
+
+			in[0] = bemp.X();
+			in[1] = bemp.Y();
+			in[2] = bemp.Z();
+			in[3] = ah;
+			Get_Local_h_3d(in,&h);
+			if(NEW)
+				qualclass = adfront -> GetLocals_Tetrahedra_new (locpoints, locfaces, 
+			      pindex, findex, 3.0 * h, 5.0 * h, locfacesplit,dummy);
+			else
+				qualclass = adfront -> GetLocals_Tetrahedra (locpoints, locfaces, pindex, findex, 3 * h);
+		}
+
+		oldnp = locpoints.Size();
+		oldnf = locfaces.Size();
+
+		if (qualclass >= 4)
+		{
+			grouppoints.SetSize (0);
+			groupfaces.SetSize (0);
+			grouppindex.SetSize (0);
+			groupfindex.SetSize (0);
+
+			adfront -> GetGroup (findex[1], grouppoints, groupfaces, grouppindex, groupfindex);
+			if (groupfaces.Size() <= 20 && FindInnerPoint (grouppoints, groupfaces, inp))
+			{
+				for (i = 1; i <= groupfaces.Size(); i++)
+					adfront -> DeleteFace (groupfindex[i]);
+
+				for (i = 1; i <= groupfaces.Size(); i++)
+					for (j = 1; j <= locfaces.Size(); j++)
+						if (findex[j] == groupfindex[i])
+							delfaces.Append (j);
+
+				style.SetSize (locfaces.Size());
+				for (i = 1; i <= style.Size(); i++)
+					style[i] = 0;
+				for (i = 1; i <= delfaces.Size(); i++)
+					style[delfaces[i]] = 2;
+				style[1] = 1;
+
+				delfaces.SetSize (0);
+
+				INDEX npi;
+				Element newel;
+
+				npi = SavePoint (inp);
+				newel.SetNP(4);
+				newel.PNum(4) = npi;
+
+				for (i = 1; i <= groupfaces.Size(); i++)
+				{
+					for (j = 1; j <= 3; j++)
+						newel.PNum(j) = adfront->GetGlobalIndex (groupfaces.Get(i).PNum(j));
+					SaveElement (newel);
+				}
+				continue;
+			}
+		}
+
+		found = 0;
+		hasfound = 0;
+		minerr = 1000;
+
+		for (rotind = 1; rotind <= 3; rotind++)
+		{
+			trans.Set (	locpoints[locfaces[1].PNumMod(1+rotind)],
+						locpoints[locfaces[1].PNumMod(2+rotind)],
+						locpoints[locfaces[1].PNumMod(3+rotind)], h);
+
+			trans.ToPlain (locpoints, plainpoints);
+
+			cnttrials++;
+			if(NEW)
+				found = ApplyVRules_new (rules_new, tolfak, plainpoints, locfaces, locfacesplit, locelements,
+										delfaces, qualclass, rotind, err, problems);			
+			else
+				found = ApplyVRules (	rules, tolfak, plainpoints, locfaces, locelements,
+										delfaces, qualclass, rotind, err, problems);
+
+		if (found) cntsucc++;
+
+		locpoints.SetSize (plainpoints.Size());
+		for (i = oldnp+1; i <= plainpoints.Size(); i++)
+			trans.FromPlain (plainpoints[i], locpoints[i]);
+
+		style.SetSize (locfaces.Size());
+		for (i = 1; i <= oldnf; i++)
+			style[i] = 0;
+		for (i = oldnf+1; i <= locfaces.Size(); i++)
+			style[i] = 3;
+		for (i = 1; i <= delfaces.Size(); i++)
+			style[delfaces[i]] = 2;
+		style[1] = 1;
+
+		if (found)
+		{
+			ruleused[found]++;
+
+			ARRAY<Point3d> pts;
+			Point3d hp;
+
+			if(NEW)
+				pts.SetSize (rules_new[found]->GetTransFreeZone().Size());
+			else
+				pts.SetSize (rules[found]->GetTransFreeZone().Size());
+
+			for (i = 1; i <= pts.Size(); i++)
+			{
+				if(NEW)
+					trans.FromPlain (rules_new[found]->GetTransFreeZone().Get(i), hp);
+				else
+					trans.FromPlain (rules[found]->GetTransFreeZone().Get(i), hp);
+				pts.Set(i, hp);
+			}
+		}
+
+		if (found && (!hasfound || err < minerr) )
+		{
+			hasfound = found;
+			minerr = err;
+		
+			tempnewpoints.SetSize (0);
+			for (i = oldnp+1; i <= locpoints.Size(); i++)
+				tempnewpoints.Append (locpoints[i]);
+
+			tempnewfaces.SetSize (0);
+			for (i = oldnf+1; i <= locfaces.Size(); i++)
+				tempnewfaces.Append (locfaces[i]);
+
+			tempdelfaces.SetSize (0);
+			for (i = 1; i <= delfaces.Size(); i++)
+				tempdelfaces.Append (delfaces[i]);
+
+			templocelements.SetSize (0);
+			for (i = 1; i <= locelements.Size(); i++)
+				templocelements.Append (locelements[i]);
+		}
+
+		locpoints.SetSize (oldnp);
+		locfaces.SetSize (oldnf);
+		delfaces.SetSize (0);
+		locelements.SetSize (0);
+	}
+
+
+	if (hasfound)
+	{
+		for (i = 1; i <= tempnewpoints.Size(); i++)
+			locpoints.Append (tempnewpoints[i]);
+		for (i = 1; i <= tempnewfaces.Size(); i++)
+			locfaces.Append (tempnewfaces[i]);
+		for (i = 1; i <= tempdelfaces.Size(); i++)
+			delfaces.Append (tempdelfaces[i]);
+		for (i = 1; i <= templocelements.Size(); i++)
+			locelements.Append (templocelements[i]);
+
+		pindex.SetSize(locpoints.Size());
+
+		for (i = oldnp+1; i <= locpoints.Size(); i++)
+		{
+			globind = SavePoint (locpoints[i]);
+			pindex[i] = adfront -> AddPoint (locpoints[i], globind);
+		}
+
+		for (i = 1; i <= locelements.Size(); i++)
+		{
+			Point3d * hp1, * hp2, * hp3, * hp4;
+			hp1 = &locpoints[locelements[i].PNum(1)];
+			hp2 = &locpoints[locelements[i].PNum(2)];
+			hp3 = &locpoints[locelements[i].PNum(3)];
+			hp4 = &locpoints[locelements[i].PNum(4)];
+
+			tetvol += (1.0 / 6.0) * ( Cross ( *hp2 - *hp1, *hp3 - *hp1) * (*hp4 - *hp1) );
+
+			for (j = 1; j <= locelements[i].NP(); j++)
+				locelements[i].PNum(j) = adfront -> GetGlobalIndex (pindex[locelements[i].PNum(j)]);
+//			if(MESH_DEBUG)
+//				printf("%s %d\n","NFF:",adfront->NFF());
+			
+			SaveElement (locelements[i]);
+			cntelem++;
+		}
+
+		for (i = oldnf+1; i <= locfaces.Size(); i++)
+		{
+			for (j = 1; j <= locfaces[i].NP(); j++)
+				locfaces[i].PNum(j) = pindex[locfaces[i].PNum(j)];
+
+			adfront->AddFace (locfaces[i], -1);
+		}
+
+		for (i = 1; i <= delfaces.Size(); i++)
+		{
+			adfront->DeleteFace (findex[delfaces[i]]);
+		}
+
+		}
+		else
+		{
+			adfront->IncrementClass (findex[1]);
+		}
+
+		locelements.SetSize (0);
+		delpoints.SetSize(0);
+		delfaces.SetSize(0);
+	}
+
+}
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshing3.hh ug-patched/gm/gg3/netgen/meshing/meshing3.hh
--- ug-orig/gm/gg3/netgen/meshing/meshing3.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshing3.hh	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,61 @@
+#ifndef FILE_MESHING3
+#define FILE_MESHING3
+
+#include <meshing/meshtype.hh>
+#include <meshing/adfront3.hh>
+#include <meshing/ruler3.hh>
+
+class Meshing3
+  {
+  protected:
+  ADFRONT3 * adfront;
+  ARRAY<vnetrule*> rules;
+  ARRAY<vnetrule_new*> rules_new;
+  ARRAY<int> ruleused;
+  ARRAY<char*> problems;
+  double tolfak;
+
+  public:
+  Meshing3 (char * rulefilename);
+  virtual ~Meshing3 ();
+
+  void LoadRules (char * filename);
+  void LoadRules_new (char * filename);
+  void Mesh (double gh,int prism);
+
+  void ImproveMesh (ARRAY<Point3d> & points, 
+      const ARRAY<Element> & surfelements,
+      const ARRAY<Element> & elements,
+      double h);
+      
+  void ImproveMesh (ARRAY<Point3d> & points, 
+      const ARRAY<Element> & elements,
+      int nboundnodes,
+      double h);
+
+  void CombineImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements, 
+      int nboundnodes,
+      double h);
+
+  void SplitImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements, ARRAY<Element> & surfelements,
+      double h);
+
+  void SwapImprove (ARRAY<Point3d> & points,
+      ARRAY<Element> & elements, ARRAY<Element> & surfelements,
+      double h);
+
+
+  void AddPoint (const Point3d & p, INDEX globind);
+  void AddBoundaryElement (const Element & elem, int inverse, int prism_flag);
+
+  virtual int SavePoint (const Point3d & /* p */) { return 0; }
+  virtual void SaveElement (const Element & /* elem */) { };
+  virtual void Get_Local_h_3d(double *in,double *out) { };
+
+  friend void PlotVolMesh (const ROT3D & r, char key);
+  friend void TestRules ();
+
+  };
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshtype.cc ug-patched/gm/gg3/netgen/meshing/meshtype.cc
--- ug-orig/gm/gg3/netgen/meshing/meshtype.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshtype.cc	1998-03-07 16:10:52.000000000 +0100
@@ -0,0 +1,15 @@
+#include <meshing/meshtype.hh>
+
+Element & Element :: operator= (const Element & el2)
+  {
+  pnum[0] = el2.pnum[0];
+  pnum[1] = el2.pnum[1];
+  pnum[2] = el2.pnum[2];
+  pnum[3] = el2.pnum[3];
+  pnum[4] = el2.pnum[4];
+  pnum[5] = el2.pnum[5];
+  surfaceind = el2.surfaceind;
+  np = el2.np;
+  return *this;
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/meshtype.hh ug-patched/gm/gg3/netgen/meshing/meshtype.hh
--- ug-orig/gm/gg3/netgen/meshing/meshtype.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/meshtype.hh	1998-03-07 16:10:52.000000000 +0100
@@ -0,0 +1,38 @@
+#ifndef MESHTYPE
+#define MESHTYPE
+
+class Element
+  {
+  int np;
+  int pnum[6];
+  int surfaceind;
+
+  public:
+  Element () { np = 0; }
+  Element (int anp) { np = anp; }
+  Element & operator= (const Element & el2);
+
+  void SetNP (int anp) { np = anp; }
+  int NP () const { return np; }
+  int & PNum (int i) { return pnum[i-1]; }
+  const int & PNum (int i) const { return pnum[i-1]; }
+  int & PNumMod (int i) { return pnum[(i-1) % np]; }
+  const int & PNumMod (int i) const { return pnum[(i-1) % np]; }
+  void SetSurfaceIndex (int si) { surfaceind = si; }
+  int SurfaceIndex () const { return surfaceind; }
+  };
+
+
+class Segment
+  {
+  public:
+  Segment() { p1 = p2 = 0; }
+  int p1, p2;         // point indices
+  int s1, s2;         // surface indices
+  int edgenr;	      // edge index
+  int invs1, invs2;   // inverse direction for surface 1 resp surface 2
+  };
+
+
+class Surface;  
+#endif
diff -ruN ug-orig/gm/gg3/netgen/meshing/netrule2.cc ug-patched/gm/gg3/netgen/meshing/netrule2.cc
--- ug-orig/gm/gg3/netgen/meshing/netrule2.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/netrule2.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,63 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+// #include <conio.h>
+
+#include <template.hh>
+#include <array.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+#include <meshing/ruler2.hh>
+
+
+netrule :: netrule ()
+  {
+  }
+
+
+void netrule :: SetFreeZoneTransformation (const Vector & u)
+  {
+  }
+
+
+int netrule :: IsInFreeZone (const Point2d & p) const
+  {
+  	return(0);
+  }
+
+int netrule :: ConvexFreeZone () const
+  {
+  	return(0);
+  }
+
+
+
+float netrule :: CalcPointDist (int pi, const Point2d & p) const
+  {
+  	return(0.0);
+  }
+
+
+float netrule :: CalcLineError (int li, const Vec2d & v) const
+  {
+  	return(0.0);
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/netrule3.cc ug-patched/gm/gg3/netgen/meshing/netrule3.cc
--- ug-orig/gm/gg3/netgen/meshing/netrule3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/netrule3.cc	1998-03-18 19:08:00.000000000 +0100
@@ -0,0 +1,1168 @@
+#include <stdlib.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <myadt.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+#include <meshing/ruler3.hh>
+
+
+
+
+
+
+vnetrule :: vnetrule ()
+  {
+  name = "";
+  quality = 0;
+  }
+
+
+int vnetrule :: TestFlag (char flag) const
+  {
+  int i;
+  for (i = 1; i <= flags.Size(); i++)
+    if (flags.Get(i) == flag) return 1;
+  return 0;
+  }
+
+
+void vnetrule :: SetFreeZoneTransformation (const Vector & u)
+  {
+  int i;
+  double nx, ny, nz, v1x, v1y, v1z, v2x, v2y, v2z;
+  double nl;
+  const threeint * ti;
+  int fs;
+
+
+  transfreezone.SetSize (freezone.Size());
+
+  for (i = 1; i <= freezone.Size(); i++)
+    {
+    transfreezone.Elem(i).X() = freezone.Elem(i).X() + u.Get(3 * i - 2);
+    transfreezone.Elem(i).Y() = freezone.Elem(i).Y() + u.Get(3 * i - 1);
+    transfreezone.Elem(i).Z() = freezone.Elem(i).Z() + u.Get(3 * i);
+
+    if (i == 1)
+      {
+      fzmaxx = fzminx = transfreezone.Elem(1).X();
+      fzmaxy = fzminy = transfreezone.Elem(1).Y();
+      fzmaxz = fzminz = transfreezone.Elem(1).Z();
+      }
+    else
+      {
+      if (transfreezone.Elem(i).X() > fzmaxx)
+          fzmaxx = transfreezone.Elem(i).X();
+      if (transfreezone.Elem(i).X() < fzminx)
+          fzminx = transfreezone.Elem(i).X();
+      if (transfreezone.Elem(i).Y() > fzmaxy)
+          fzmaxy = transfreezone.Elem(i).Y();
+      if (transfreezone.Elem(i).Y() < fzminy)
+          fzminy = transfreezone.Elem(i).Y();
+      if (transfreezone.Elem(i).Z() > fzmaxz)
+          fzmaxz = transfreezone.Elem(i).Z();
+      if (transfreezone.Elem(i).Z() < fzminz)
+          fzminz = transfreezone.Elem(i).Z();
+      }
+    }
+
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+    ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+    DenseMatrix & freesetinequ = *freefaceinequ.Get(fs);
+
+    for (i = 1; i <= freesetfaces.Size(); i++)
+      {
+      ti = &freesetfaces.Get(i);
+      const Point3d & p1 = transfreezone.Get(ti->i1);
+      const Point3d & p2 = transfreezone.Get(ti->i2);
+      const Point3d & p3 = transfreezone.Get(ti->i3);
+
+      v1x = p2.X() - p1.X();
+      v1y = p2.Y() - p1.Y();
+      v1z = p2.Z() - p1.Z();
+      v2x = p3.X() - p1.X();
+      v2y = p3.Y() - p1.Y();
+      v2z = p3.Z() - p1.Z();
+
+      nx = - v2y * v1z + v2z * v1y;
+      ny = - v2z * v1x + v2x * v1z;
+      nz = - v2x * v1y + v2y * v1x;
+
+      nl = sqrt (nx * nx + ny * ny + nz * nz);
+
+      if (nl < 1e-10)
+        {
+        freesetinequ.Set(1, 1, 0);
+        freesetinequ.Set(1, 1, 0);
+        freesetinequ.Set(1, 1, 0);
+        freesetinequ.Set(1, 1, -1);
+        }
+      else
+        {
+        nx /= nl;
+        ny /= nl;
+        nz /= nl;
+
+        freesetinequ.Set(i, 1, nx);
+        freesetinequ.Set(i, 2, ny);
+        freesetinequ.Set(i, 3, nz);
+        freesetinequ.Set(i, 4,
+            -(p1.X() * nx + p1.Y() * ny + p1.Z() * nz));
+        }
+      }
+    }
+  }
+
+
+int vnetrule :: ConvexFreeZone () const
+  {
+  int i, j, jj, fs;
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+    ARRAY<threeint> & freesetfaces = *freefaces[fs];
+    DenseMatrix & freesetinequ = *freefaceinequ[fs];
+    ARRAY<int> & freeset = *freesets[fs];
+
+    for (i = 1; i <= freesetfaces.Size(); i++)
+      {
+      for (jj = 1; jj <= freeset.Size(); jj++)
+        {
+        j = freeset.Get(jj);
+        if ( j != freesetfaces.Get(i).i1 && j != freesetfaces.Get(i).i2 &&
+             j != freesetfaces.Get(i).i3 &&
+             freesetinequ.Get(i, 1) * transfreezone.Get(j).X() +
+             freesetinequ.Get(i, 2) * transfreezone.Get(j).Y() +
+             freesetinequ.Get(i, 3) * transfreezone.Get(j).Z() +
+             freesetinequ.Get(i, 4) > 0 )
+          {
+          return 0;
+          }
+        }
+      }
+    }
+
+  return 1;
+  }
+
+
+int vnetrule :: IsInFreeZone (const Point3d & p) const
+  {
+  int i, fs;
+  char inthis;
+
+  if (p.X() < fzminx || p.X() > fzmaxx || p.Y() < fzminy ||
+      p.Y() > fzmaxy || p.Z() < fzminz || p.Z() > fzmaxz) return 0;
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+    inthis = 1;
+    ARRAY<threeint> & freesetfaces = *freefaces[fs];
+    DenseMatrix & freesetinequ = *freefaceinequ[fs];
+
+    for (i = 1; i <= freesetfaces.Size() && inthis; i++)
+      {
+      if (freesetinequ.Get(i, 1) * p.X() + freesetinequ.Get(i, 2) * p.Y() +
+          freesetinequ.Get(i, 3) * p.Z() + freesetinequ.Get(i, 4) > 0)
+        inthis = 0;
+      }
+
+    if (inthis) return 1;
+    }
+
+  return 0;
+  }
+
+
+int vnetrule :: IsTriangleInFreeZone (const Point3d & p1, const Point3d & p2, const Point3d & p3)
+  {
+  int fs;
+  int infreeset, cannot = 0;
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+    infreeset = IsTriangleInFreeSet(p1, p2, p3, fs);
+    if (infreeset == 1) return 1;
+    if (infreeset == -1) cannot = -1;
+    }
+
+  return cannot;
+  }
+
+
+int vnetrule :: IsTriangleInFreeSet (const Point3d & p1, const Point3d & p2,
+                                     const Point3d & p3, int fs)
+  {
+  int i, ii;
+  Vec3d n;
+  int allleft, allright;
+  int hos1, hos2, hos3, os1, os2, os3;
+  double hf, lam1, lam2, f, c1, c2, alpha;
+  double v1n, v2n, h11, h12, h22, dflam1, dflam2;
+  double lam1old, lam2old, fold;
+  double hpx, hpy, hpz, v1x, v1y, v1z, v2x, v2y, v2z;
+  int act1, act2, act3, it;
+  int cntout;
+  static ARRAY<int> activefaces;
+  int isin;
+
+
+  ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+  DenseMatrix & freesetinequ = *freefaceinequ[fs];
+
+
+  if (p1.X() <= fzminx && p2.X() <= fzminx && p3.X() <= fzminx ||
+      p1.X() >= fzmaxx && p2.X() >= fzmaxx && p3.X() >= fzmaxx ||
+      p1.Y() <= fzminy && p2.Y() <= fzminy && p3.Y() <= fzminy ||
+      p1.Y() >= fzmaxy && p2.Y() >= fzmaxy && p3.Y() >= fzmaxy ||
+      p1.Z() <= fzminz && p2.Z() <= fzminz && p3.Z() <= fzminz ||
+      p1.Z() >= fzmaxz && p2.Z() >= fzmaxz && p3.Z() >= fzmaxz) return 0;
+
+  os1 = os2 = os3 = 0;
+
+  activefaces.SetSize(0);
+
+  for (i = 1; i <= freesetfaces.Size(); i++)
+    {
+    hos1 = freesetinequ.Get(i, 1) * p1.X() +
+           freesetinequ.Get(i, 2) * p1.Y() +
+           freesetinequ.Get(i, 3) * p1.Z() +
+           freesetinequ.Get(i, 4) > -1E-5;
+
+    hos2 = freesetinequ.Get(i, 1) * p2.X() +
+           freesetinequ.Get(i, 2) * p2.Y() +
+           freesetinequ.Get(i, 3) * p2.Z() +
+           freesetinequ.Get(i, 4) > -1E-5;
+
+    hos3 = freesetinequ.Get(i, 1) * p3.X() +
+           freesetinequ.Get(i, 2) * p3.Y() +
+           freesetinequ.Get(i, 3) * p3.Z() +
+           freesetinequ.Get(i, 4) > -1E-5;
+
+    if (hos1 && hos2 && hos3) return 0;
+
+    if (hos1) os1 = 1;
+    if (hos2) os2 = 1;
+    if (hos3) os3 = 1;
+
+    if (hos1 || hos2 || hos3) activefaces.Append (i);
+    }
+
+  if (!os1 || !os2 || !os3) return 1;
+
+
+  v1x = p2.X() - p1.X();
+  v1y = p2.Y() - p1.Y();
+  v1z = p2.Z() - p1.Z();
+
+  v2x = p3.X() - p1.X();
+  v2y = p3.Y() - p1.Y();
+  v2z = p3.Z() - p1.Z();
+
+  n.X() = v1y * v2z - v1z * v2y;
+  n.Y() = v1z * v2x - v1x * v2z;
+  n.Z() = v1x * v2y - v1y * v2x;
+  n /= n.Length();
+
+  allleft = allright = 1;
+  for (i = 1; i <= transfreezone.Size() && (allleft || allright); i++)
+    {
+    const Point3d & p = transfreezone.Get(i);
+    float scal = (p.X() - p1.X()) * n.X() +
+                 (p.Y() - p1.Y()) * n.Y() +
+                 (p.Z() - p1.Z()) * n.Z();
+
+    if ( scal >  1E-8 ) allleft = 0;
+    if ( scal < -1E-8 ) allright = 0;
+    }
+
+  if (allleft || allright) return 0;
+
+
+
+
+  lam1old = lam2old = lam1 = lam2 = 1.0 / 3.0;
+
+  it = 0;
+  fold = 1E10;
+
+  while (1)
+    {
+    it++;
+
+    if (it > 1000) return -1;
+
+    if (lam1 < 0) lam1 = 0;
+    if (lam2 < 0) lam2 = 0;
+    if (lam1 + lam2 > 1) lam1 = 1 - lam2;
+
+    hpx = p1.X() + lam1 * v1x + lam2 * v2x;
+    hpy = p1.Y() + lam1 * v1y + lam2 * v2y;
+    hpz = p1.Z() + lam1 * v1z + lam2 * v2z;
+
+    f = 0;
+
+    h11 = h12 = h22 = dflam1 = dflam2 = 0;
+    cntout = 0;
+
+    isin = 1;
+
+    for (i = 1; i <= activefaces.Size(); i++)
+      {
+      ii = activefaces[i];
+
+      hf = freesetinequ.Get(ii, 1) * hpx +
+           freesetinequ.Get(ii, 2) * hpy +
+           freesetinequ.Get(ii, 3) * hpz +
+           freesetinequ.Get(ii, 4);
+
+      if (hf > -1E-7) isin = 0;
+
+      hf += 1E-4;
+      if (hf > 0)
+        {
+        f += hf * hf;
+
+        v1n = freesetinequ.Get(ii, 1) * v1x +
+              freesetinequ.Get(ii, 2) * v1y +
+              freesetinequ.Get(ii, 3) * v1z;
+        v2n = freesetinequ.Get(ii, 1) * v2x +
+              freesetinequ.Get(ii, 2) * v2y +
+              freesetinequ.Get(ii, 3) * v2z;
+
+        h11 += 2 * v1n * v1n;
+        h12 += 2 * v1n * v2n;
+        h22 += 2 * v2n * v2n;
+        dflam1 += 2 * hf * v1n;
+        dflam2 += 2 * hf * v2n;
+        cntout++;
+        }
+      }
+
+    if (isin) return 1;
+
+    if (f >= fold)
+      {
+      lam1 = 0.100000000000000 * lam1 + 0.9000000000000000 * lam1old;
+      lam2 = 0.100000000000000 * lam2 + 0.9000000000000000 * lam2old;
+      }
+    else
+      {
+      lam1old = lam1;
+      lam2old = lam2;
+      fold = f;
+
+
+      if (f < 1E-9) return 1;
+
+      h11 += 1E-10;
+      h22 += 1E-10;
+      c1 = - ( h22 * dflam1 - h12 * dflam2) / (h11 * h22 - h12 * h12);
+      c2 = - (-h12 * dflam1 + h11 * dflam2) / (h11 * h22 - h12 * h12);
+      alpha = 1;
+
+      act1 = lam1 <= 1E-6 && c1 <= 0;
+      act2 = lam2 <= 1E-6 && c2 <= 0;
+      act3 = lam1 + lam2 >= 1 - 1E-6 && c1 + c2 >= 0;
+
+      if (act1 && act2 || act1 && act3 || act2 && act3) return 0;
+
+      if (act1)
+        {
+        c1 = 0;
+        c2 = - dflam2 / h22;
+        }
+
+      if (act2)
+        {
+        c1 = - dflam1 / h11;
+        c2 = 0;
+        }
+
+      if (act3)
+        {
+        c1 = - (dflam1 - dflam2) / (h11 + h22 - 2 * h12);
+        c2 = -c1;
+        }
+
+      if (f > 100 * sqrt (sqr (c1) + sqr (c2))) return 0;
+
+
+      if (lam1 + alpha * c1 < 0 && !act1)
+        alpha = -lam1 / c1;
+      if (lam2 + alpha * c2 < 0 && !act2)
+        alpha = -lam2 / c2;
+      if (lam1 + lam2 + alpha * (c1 + c2) > 1 && !act3)
+        alpha = (1 - lam1 - lam2) / (c1 + c2);
+
+      lam1 += alpha * c1;
+      lam2 += alpha * c2;
+      }
+    }
+  }
+
+
+
+
+
+
+
+float vnetrule :: CalcPointDist (int pi, const Point3d & p) const
+  {
+  float dx = p.X() - points.Get(pi).X();
+  float dy = p.Y() - points.Get(pi).Y();
+  float dz = p.Z() - points.Get(pi).Z();
+
+//  const threefloat * tf = &tolerances.Get(pi);
+//  return tf->f1 * dx * dx + tf->f2 * dx * dy + tf->f3 * dy * dy;
+  return tolerances.Get(pi) * (dx * dx + dy * dy + dz * dz);
+  }
+
+
+int vnetrule :: TestOk () const
+  {
+  ARRAY<int> cntpused(points.Size());
+  ARRAY<int> edge1, edge2;
+  ARRAY<int> delf(faces.Size());
+  int i, j, k;
+  int pi1, pi2;
+  int found;
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    cntpused[i] = 0;
+  for (i = 1; i <= faces.Size(); i++)
+    delf[i] = 0;
+  for (i = 1; i <= delfaces.Size(); i++)
+    delf[delfaces[i]] = 1;
+
+
+  for (i = 1; i <= faces.Size(); i++)
+    if (delf[i] || i > noldf)
+      for (j = 1; j <= faces[i].NP(); j++)
+        cntpused[faces[i].PNum(j)]++;
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    if (cntpused[i] > 0 && cntpused[i] < 2)
+      {
+      cout << "Fall 1";
+      return 0;
+      }
+
+
+  for (i = 1; i <= faces.Size(); i++)
+    {
+    for (j = 1; j <= faces[i].NP(); j++)
+      {
+      pi1 = 0; pi2 = 0;
+      if (delf[i])
+        {
+        pi1 = faces[i].PNumMod(j);
+        pi2 = faces[i].PNumMod(j+1);
+        }
+      if (i > noldf)
+        {
+        pi1 = faces[i].PNumMod(j+1);
+        pi2 = faces[i].PNumMod(j);
+        }
+
+      found = 0;
+      if (pi1)
+        {
+        for (k = 1; k <= edge1.Size(); k++)
+          if (edge1[k] == pi1 && edge2[k] == pi2)
+            {
+            found = 1;
+            edge1.DeleteElement(k);
+            edge2.DeleteElement(k);
+            k--;
+            }
+        if (!found)
+          {
+          edge1.Append (pi2);
+          edge2.Append (pi1);
+          }
+        }
+      }
+    }
+
+  if (edge1.Size() > 0)
+    {
+    cout << "Fall 2" << endl;
+    return 0;
+    }
+
+/*
+  cntpused.SetSize(freezone.Size());
+  for (i = 1; i <= cntpused.Size(); i++)
+    cntpused[i] = 0;
+
+  for (i = 1; i <= freefaces.Size(); i++)
+    {
+    cntpused[freefaces[i].i1]++;
+    cntpused[freefaces[i].i2]++;
+    cntpused[freefaces[i].i3]++;
+    }
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    if (cntpused[i] < 3)
+      {
+      cout << "Fall 3" << endl;
+      return 0;
+      }
+
+
+
+  for (i = 1; i <= freefaces.Size(); i++)
+    {
+    for (j = 1; j <= 3; j++)
+      {
+      if (j == 1)
+        {
+        pi1 = freefaces[i].i1;
+        pi2 = freefaces[i].i2;
+        }
+      if (j == 2)
+        {
+        pi1 = freefaces[i].i2;
+        pi2 = freefaces[i].i3;
+        }
+      if (j == 3)
+        {
+        pi1 = freefaces[i].i3;
+        pi2 = freefaces[i].i1;
+        }
+
+      found = 0;
+      for (k = 1; k <= edge1.Size(); k++)
+        if (edge1[k] == pi1 && edge2[k] == pi2)
+          {
+          found = 1;
+          edge1.DeleteElement(k);
+          edge2.DeleteElement(k);
+          k--;
+          }
+
+      if (!found)
+        {
+        edge1.Append (pi2);
+        edge2.Append (pi1);
+        }
+      }
+    }
+
+  if (edge1.Size() > 0)
+    {
+    cout << "Fall 4" << endl;
+    return 0;
+    }
+*/
+  return 1;
+  }
+
+
+int vnetrule :: IsDelFace (int fn) const
+  {
+  int i;
+  for (i = 1; i <= GetNDelF(); i++)
+    if (GetDelFace(i) == fn) return 1;
+  return 0;
+  }
+
+
+
+vnetrule_new :: vnetrule_new ()
+  {
+  name = "";
+  quality = 0;
+  }
+
+
+/*
+void vnetrule :: GetFreeZone (ARRAY<Point3d> & afreezone)
+  {
+  int i;
+
+  afreezone.SetSize (freezone.Size());
+  for (i = 1; i <= freezone.Size(); i++)
+    afreezone[i] = freezone[i];
+  }
+*/
+
+int vnetrule_new :: TestFlag (char flag) const
+  {
+  int i;
+  for (i = 1; i <= flags.Size(); i++)
+    if (flags.Get(i) == flag) return 1;
+  return 0;
+  }
+
+
+void vnetrule_new :: SetFreeZoneTransformation (const Vector & devp, int tolclass)
+  {
+  int i;
+  double nx, ny, nz, v1x, v1y, v1z, v2x, v2y, v2z;
+  double nl;
+  const threeint * ti;
+  int fs;
+
+  double lam1 = 1.0/(2 * tolclass - 1);
+  double lam2 = 1-lam1;
+
+  static Vector devfree, devfree1, devfree2;
+
+  oldutofreezone->Mult (devp, devfree1);
+  oldutofreezonelimit->Mult (devp, devfree2);
+  devfree.SetLength (devfree1.Length());
+  devfree.Set (lam1, devfree1, lam2, devfree2);
+
+  transfreezone.SetSize (freezone.Size());
+  
+  for (i = 1; i <= freezone.Size(); i++)
+    {
+      transfreezone.Elem(i).X() = lam1 * freezone.Elem(i).X() +
+      lam2 * freezonelimit.Elem(i).X() + devfree.Get(3 * i - 2);
+      transfreezone.Elem(i).Y() = lam1 * freezone.Elem(i).Y() +
+	lam2 * freezonelimit.Elem(i).Y() + devfree.Get(3 * i - 1);
+      transfreezone.Elem(i).Z() = lam1 * freezone.Elem(i).Z() + 
+	lam2 * freezonelimit.Elem(i).Z() + devfree.Get(3 * i);
+      
+      if (i == 1)
+      {
+      fzmaxx = fzminx = transfreezone.Elem(1).X();
+      fzmaxy = fzminy = transfreezone.Elem(1).Y();
+      fzmaxz = fzminz = transfreezone.Elem(1).Z();
+      }
+    else
+      {
+      if (transfreezone.Elem(i).X() > fzmaxx)
+          fzmaxx = transfreezone.Elem(i).X();
+      if (transfreezone.Elem(i).X() < fzminx)
+          fzminx = transfreezone.Elem(i).X();
+      if (transfreezone.Elem(i).Y() > fzmaxy)
+          fzmaxy = transfreezone.Elem(i).Y();
+      if (transfreezone.Elem(i).Y() < fzminy)
+          fzminy = transfreezone.Elem(i).Y();
+      if (transfreezone.Elem(i).Z() > fzmaxz)
+          fzmaxz = transfreezone.Elem(i).Z();
+      if (transfreezone.Elem(i).Z() < fzminz)
+          fzminz = transfreezone.Elem(i).Z();
+      }
+    }
+
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+      DenseMatrix & freesetinequ = *freefaceinequ.Get(fs);
+      
+      for (i = 1; i <= freesetfaces.Size(); i++)
+	{
+	  ti = &freesetfaces.Get(i);
+	  const Point3d & p1 = transfreezone.Get(ti->i1);
+	  const Point3d & p2 = transfreezone.Get(ti->i2);
+	  const Point3d & p3 = transfreezone.Get(ti->i3);
+	  
+	  v1x = p2.X() - p1.X();
+	  v1y = p2.Y() - p1.Y();
+	  v1z = p2.Z() - p1.Z();
+	  v2x = p3.X() - p1.X();
+	  v2y = p3.Y() - p1.Y();
+	  v2z = p3.Z() - p1.Z();
+	  
+	  nx = - v2y * v1z + v2z * v1y;
+	  ny = - v2z * v1x + v2x * v1z;
+	  nz = - v2x * v1y + v2y * v1x;
+	  
+	  nl = sqrt (nx * nx + ny * ny + nz * nz);
+
+	  if (nl < 1e-10)
+	    {
+	      freesetinequ.Set(1, 1, 0);
+	      freesetinequ.Set(1, 2, 0);
+	      freesetinequ.Set(1, 3, 0);
+	      freesetinequ.Set(1, 4, -1);
+	    }
+	  else
+	    {
+	      nx /= nl;
+	      ny /= nl;
+	      nz /= nl;
+	      
+	      freesetinequ.Set(i, 1, nx);
+	      freesetinequ.Set(i, 2, ny);
+	      freesetinequ.Set(i, 3, nz);
+	      freesetinequ.Set(i, 4,
+			       -(p1.X() * nx + p1.Y() * ny + p1.Z() * nz));
+	    }
+	}
+    }
+
+  }
+
+int vnetrule_new :: ConvexFreeZone () const
+{
+  int i, j, k, fs;
+
+  // cout << "Convex free zone...\n";
+  
+  int ret1=1;
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      const DenseMatrix & freesetinequ = *freefaceinequ.Get(fs);
+
+      const ARRAY<int> & freeset = *freesets.Get(fs);
+      const ARRAY<twoint> & freesetedges = *freeedges.Get(fs);
+      const ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+      
+      for (i = 1; i <= freesetedges.Size(); i++)
+	{
+	  j = freesetedges.Get(i).i1;    //triangle j with opposite point k
+	  k = freesetedges.Get(i).i2;
+	  
+	  if ( freesetinequ.Get(j, 1) * transfreezone.Get(k).X() +
+	       freesetinequ.Get(j, 2) * transfreezone.Get(k).Y() +
+	       freesetinequ.Get(j, 3) * transfreezone.Get(k).Z() +
+	       freesetinequ.Get(j, 4) > 0 )
+	    {
+	      ret1=0;
+	    }
+	}
+      
+    }
+
+  return ret1;
+}
+
+
+int vnetrule_new :: IsInFreeZone (const Point3d & p) const
+{
+  int i, fs;
+  char inthis;
+  
+  
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      inthis = 1;
+      ARRAY<threeint> & freesetfaces = *freefaces[fs];
+      DenseMatrix & freesetinequ = *freefaceinequ[fs];
+      
+      for (i = 1; i <= freesetfaces.Size() && inthis; i++)
+	{
+	  if (freesetinequ.Get(i, 1) * p.X() + freesetinequ.Get(i, 2) * p.Y() +
+	      freesetinequ.Get(i, 3) * p.Z() + freesetinequ.Get(i, 4) > 0)
+	    inthis = 0;
+	}
+      
+      if (inthis) return 1;
+    }
+  
+  return 0;
+}
+
+
+int vnetrule_new :: IsTriangleInFreeZone (const Point3d & p1, 
+				      const Point3d & p2,
+				      const Point3d & p3)
+{
+  int fs;
+  int infreeset, cannot = 0;
+  /*
+  // far away ?
+  
+  if (p1.X() <= fzminx && p2.X() <= fzminx && p3.X() <= fzminx ||
+      p1.X() >= fzmaxx && p2.X() >= fzmaxx && p3.X() >= fzmaxx ||
+      p1.Y() <= fzminy && p2.Y() <= fzminy && p3.Y() <= fzminy ||
+      p1.Y() >= fzmaxy && p2.Y() >= fzmaxy && p3.Y() >= fzmaxy ||
+      p1.Z() <= fzminz && p2.Z() <= fzminz && p3.Z() <= fzminz ||
+      p1.Z() >= fzmaxz && p2.Z() >= fzmaxz && p3.Z() >= fzmaxz) return 0;
+      */
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      infreeset = IsTriangleInFreeSet(p1, p2, p3, fs);
+      if (infreeset == 1) return 1;
+      if (infreeset == -1) cannot = -1;
+    }
+  
+  return cannot;
+}
+
+
+int vnetrule_new :: IsTriangleInFreeSet (const Point3d & p1, const Point3d & p2,
+                                     const Point3d & p3, int fs)
+{
+  int i, ii;
+  Vec3d n;
+  int allleft, allright;
+  int hos1, hos2, hos3, os1, os2, os3;
+  double hf, lam1, lam2, f, c1, c2, alpha;
+  double v1n, v2n, h11, h12, h22, dflam1, dflam2;
+  double lam1old, lam2old, fold;
+  double hpx, hpy, hpz, v1x, v1y, v1z, v2x, v2y, v2z;
+  int act1, act2, act3, it;
+  int cntout;
+  static ARRAY<int> activefaces;
+  int isin;
+  
+  
+  ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+  DenseMatrix & freesetinequ = *freefaceinequ.Get(fs);
+  
+
+  
+  os1 = os2 = os3 = 0;
+  activefaces.SetSize(0);
+
+  // is point inside ?
+
+  for (i = 1; i <= freesetfaces.Size(); i++)
+    {
+      hos1 = freesetinequ.Get(i, 1) * p1.X() +
+	freesetinequ.Get(i, 2) * p1.Y() +
+	freesetinequ.Get(i, 3) * p1.Z() +
+	freesetinequ.Get(i, 4) > -1E-5;
+      
+      hos2 = freesetinequ.Get(i, 1) * p2.X() +
+	freesetinequ.Get(i, 2) * p2.Y() +
+	freesetinequ.Get(i, 3) * p2.Z() +
+	freesetinequ.Get(i, 4) > -1E-5;
+      
+      hos3 = freesetinequ.Get(i, 1) * p3.X() +
+	freesetinequ.Get(i, 2) * p3.Y() +
+	freesetinequ.Get(i, 3) * p3.Z() +
+	freesetinequ.Get(i, 4) > -1E-5;
+      
+      if (hos1 && hos2 && hos3) return 0;
+      
+      if (hos1) os1 = 1;
+      if (hos2) os2 = 1;
+      if (hos3) os3 = 1;
+      
+      if (hos1 || hos2 || hos3) activefaces.Append (i);
+    }
+  
+  if (!os1 || !os2 || !os3) return 1;
+
+  v1x = p2.X() - p1.X();
+  v1y = p2.Y() - p1.Y();
+  v1z = p2.Z() - p1.Z();
+
+  v2x = p3.X() - p1.X();
+  v2y = p3.Y() - p1.Y();
+  v2z = p3.Z() - p1.Z();
+
+  n.X() = v1y * v2z - v1z * v2y;
+  n.Y() = v1z * v2x - v1x * v2z;
+  n.Z() = v1x * v2y - v1y * v2x;
+  n /= n.Length();
+
+  allleft = allright = 1;
+  for (i = 1; i <= transfreezone.Size() && (allleft || allright); i++)
+    {
+    const Point3d & p = transfreezone.Get(i);
+    float scal = (p.X() - p1.X()) * n.X() +
+                 (p.Y() - p1.Y()) * n.Y() +
+                 (p.Z() - p1.Z()) * n.Z();
+
+    if ( scal >  1E-8 ) allleft = 0;
+    if ( scal < -1E-8 ) allright = 0;
+    }
+
+  if (allleft || allright) return 0;
+
+
+  lam1old = lam2old = lam1 = lam2 = 1.0 / 3.0;
+
+  it = 0;
+  fold = 1E10;
+
+  while (1)
+    {
+    it++;
+
+    if (it > 1000) return -1;
+
+    if (lam1 < 0) lam1 = 0;
+    if (lam2 < 0) lam2 = 0;
+    if (lam1 + lam2 > 1) lam1 = 1 - lam2;
+
+    hpx = p1.X() + lam1 * v1x + lam2 * v2x;
+    hpy = p1.Y() + lam1 * v1y + lam2 * v2y;
+    hpz = p1.Z() + lam1 * v1z + lam2 * v2z;
+
+    f = 0;
+
+    h11 = h12 = h22 = dflam1 = dflam2 = 0;
+    cntout = 0;
+
+    isin = 1;
+
+    for (i = 1; i <= activefaces.Size(); i++)
+      {
+      ii = activefaces.Get(i);
+
+      hf = freesetinequ.Get(ii, 1) * hpx +
+           freesetinequ.Get(ii, 2) * hpy +
+           freesetinequ.Get(ii, 3) * hpz +
+           freesetinequ.Get(ii, 4);
+
+      if (hf > -1E-7) isin = 0;
+
+      hf += 1E-4;
+      if (hf > 0)
+        {
+        f += hf * hf;
+
+        v1n = freesetinequ.Get(ii, 1) * v1x +
+              freesetinequ.Get(ii, 2) * v1y +
+              freesetinequ.Get(ii, 3) * v1z;
+        v2n = freesetinequ.Get(ii, 1) * v2x +
+              freesetinequ.Get(ii, 2) * v2y +
+              freesetinequ.Get(ii, 3) * v2z;
+
+        h11 += 2 * v1n * v1n;
+        h12 += 2 * v1n * v2n;
+        h22 += 2 * v2n * v2n;
+        dflam1 += 2 * hf * v1n;
+        dflam2 += 2 * hf * v2n;
+        cntout++;
+        }
+      }
+
+    if (isin) return 1;
+
+    if (f >= fold)
+      {
+      lam1 = 0.100000000000000 * lam1 + 0.9000000000000000 * lam1old;
+      lam2 = 0.100000000000000 * lam2 + 0.9000000000000000 * lam2old;
+      }
+    else
+      {
+      lam1old = lam1;
+      lam2old = lam2;
+      fold = f;
+
+
+      if (f < 1E-9) return 1;
+
+      h11 += 1E-10;
+      h22 += 1E-10;
+      c1 = - ( h22 * dflam1 - h12 * dflam2) / (h11 * h22 - h12 * h12);
+      c2 = - (-h12 * dflam1 + h11 * dflam2) / (h11 * h22 - h12 * h12);
+      alpha = 1;
+
+      act1 = lam1 <= 1E-6 && c1 <= 0;
+      act2 = lam2 <= 1E-6 && c2 <= 0;
+      act3 = lam1 + lam2 >= 1 - 1E-6 && c1 + c2 >= 0;
+
+      if (act1 && act2 || act1 && act3 || act2 && act3) return 0;
+
+      if (act1)
+        {
+        c1 = 0;
+        c2 = - dflam2 / h22;
+        }
+
+      if (act2)
+        {
+        c1 = - dflam1 / h11;
+        c2 = 0;
+        }
+
+      if (act3)
+        {
+        c1 = - (dflam1 - dflam2) / (h11 + h22 - 2 * h12);
+        c2 = -c1;
+        }
+
+      if (f > 100 * sqrt (sqr (c1) + sqr (c2))) return 0;
+
+      if (lam1 + alpha * c1 < 0 && !act1)
+        alpha = -lam1 / c1;
+      if (lam2 + alpha * c2 < 0 && !act2)
+        alpha = -lam2 / c2;
+      if (lam1 + lam2 + alpha * (c1 + c2) > 1 && !act3)
+        alpha = (1 - lam1 - lam2) / (c1 + c2);
+
+      lam1 += alpha * c1;
+      lam2 += alpha * c2;
+      }
+    }
+  }
+
+
+
+
+
+
+float vnetrule_new :: CalcPointDist (int pi, const Point3d & p) const
+{
+  float dx = p.X() - points.Get(pi).X();
+  float dy = p.Y() - points.Get(pi).Y();
+  float dz = p.Z() - points.Get(pi).Z();
+  
+  //  const threefloat * tf = &tolerances.Get(pi);
+  //  return tf->f1 * dx * dx + tf->f2 * dx * dy + tf->f3 * dy * dy;
+  return tolerances.Get(pi) * (dx * dx + dy * dy + dz * dz);
+}
+
+
+int vnetrule_new :: TestOk () const
+  {
+  ARRAY<int> cntpused(points.Size());
+  ARRAY<int> edge1, edge2;
+  ARRAY<int> delf(faces.Size());
+  int i, j, k;
+  int pi1, pi2;
+  int found;
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    cntpused[i] = 0;
+  for (i = 1; i <= faces.Size(); i++)
+    delf[i] = 0;
+  for (i = 1; i <= delfaces.Size(); i++)
+    delf[delfaces[i]] = 1;
+
+
+  for (i = 1; i <= faces.Size(); i++)
+    if (delf[i] || i > noldf)
+      for (j = 1; j <= 3; j++)
+        cntpused[faces[i].PNum(j)]++;
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    if (cntpused[i] > 0 && cntpused[i] < 2)
+      {
+      cout << "Fall 1";
+      return 0;
+      }
+
+
+  for (i = 1; i <= faces.Size(); i++)
+    {
+    for (j = 1; j <= 3; j++)
+      {
+      pi1 = 0; pi2 = 0;
+      if (delf[i])
+        {
+        pi1 = faces[i].PNumMod(j);
+        pi2 = faces[i].PNumMod(j+1);
+        }
+      if (i > noldf)
+        {
+        pi1 = faces[i].PNumMod(j+1);
+        pi2 = faces[i].PNumMod(j);
+        }
+
+      found = 0;
+      if (pi1)
+        {
+        for (k = 1; k <= edge1.Size(); k++)
+          if (edge1[k] == pi1 && edge2[k] == pi2)
+            {
+            found = 1;
+            edge1.DeleteElement(k);
+            edge2.DeleteElement(k);
+            k--;
+            }
+        if (!found)
+          {
+          edge1.Append (pi2);
+          edge2.Append (pi1);
+          }
+        }
+      }
+    }
+
+  if (edge1.Size() > 0)
+    {
+    cout << "Fall 2" << endl;
+    return 0;
+    }
+
+/*
+  cntpused.SetSize(freezone.Size());
+  for (i = 1; i <= cntpused.Size(); i++)
+    cntpused[i] = 0;
+
+  for (i = 1; i <= freefaces.Size(); i++)
+    {
+    cntpused[freefaces[i].i1]++;
+    cntpused[freefaces[i].i2]++;
+    cntpused[freefaces[i].i3]++;
+    }
+
+  for (i = 1; i <= cntpused.Size(); i++)
+    if (cntpused[i] < 3)
+      {
+      cout << "Fall 3" << endl;
+      return 0;
+      }
+
+
+
+  for (i = 1; i <= freefaces.Size(); i++)
+    {
+    for (j = 1; j <= 3; j++)
+      {
+      if (j == 1)
+        {
+        pi1 = freefaces[i].i1;
+        pi2 = freefaces[i].i2;
+        }
+      if (j == 2)
+        {
+        pi1 = freefaces[i].i2;
+        pi2 = freefaces[i].i3;
+        }
+      if (j == 3)
+        {
+        pi1 = freefaces[i].i3;
+        pi2 = freefaces[i].i1;
+        }
+
+      found = 0;
+      for (k = 1; k <= edge1.Size(); k++)
+        if (edge1[k] == pi1 && edge2[k] == pi2)
+          {
+          found = 1;
+          edge1.DeleteElement(k);
+          edge2.DeleteElement(k);
+          k--;
+          }
+
+      if (!found)
+        {
+        edge1.Append (pi2);
+        edge2.Append (pi1);
+        }
+      }
+    }
+
+  if (edge1.Size() > 0)
+    {
+    cout << "Fall 4" << endl;
+    return 0;
+    }
+*/
+  return 1;
+  }
+
+
+int vnetrule_new :: IsDelFace (int fn) const
+  {
+  int i;
+  for (i = 1; i <= GetNDelF(); i++)
+    if (GetDelFace(i) == fn) return 1;
+  return 0;
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/nginterface.cc ug-patched/gm/gg3/netgen/meshing/nginterface.cc
--- ug-orig/gm/gg3/netgen/meshing/nginterface.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/nginterface.cc	2003-12-03 18:27:16.000000000 +0100
@@ -0,0 +1,384 @@
+/************************************************************************/
+/*                                                                      */
+/* This file is a part of NETGEN                                        */
+/*                                                                      */
+/* File:   nginterface.cc                                               */
+/* Author: Joachim Schoeberl                                            */
+/*                                                                      */
+/************************************************************************/
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <iomanip.h>
+//#include <strstream.h>
+#include <math.h>
+#include <new.h>
+#include <ctype.h>
+#include <string.h>
+#include <time.h>
+
+
+
+#include <myadt.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+#include <linalg/linalg.hh>
+
+// #include <meshing/meshtool.hh>
+// #include <meshing/meshing2.hh>
+// #include <meshing/meshsurf.hh>
+
+#include <meshing/global.hh>
+#include <meshing/meshing3.hh>
+
+static int GG_DEBUG = 0;
+
+extern "C"
+   {
+#include "../../gginterface.h"      
+   }   
+
+int testmode;
+
+extern "C"
+   void UserWriteF (char * ch, ...);
+
+
+void MyError (char * ch)
+  {
+  UserWriteF (ch);
+  }
+   
+
+
+static ARRAY<Point3d> * points;
+static ARRAY<Element> * volelements;
+static int nbp,disp;          
+static double vol0;
+
+class my_meshing3 : public Meshing3
+  {
+  public:
+  my_meshing3 (char * rulefilename);
+  virtual int SavePoint (const Point3d & p);
+  virtual void SaveElement (const Element & elem);
+  virtual void Get_Local_h_3d(double *in,double *out);
+
+  friend int StartNetgen (double h, int smooth, int display,int prism);
+  };
+
+
+
+my_meshing3 :: my_meshing3 (char * rulefilename)
+  : Meshing3 (rulefilename)
+  {
+    ;  
+  }
+  
+int my_meshing3 :: SavePoint (const Point3d & p)
+  {
+  return points -> Append (p);
+  }
+
+#define SMALL 1e-10
+#define MAXDOUBLE 1e200
+#define PI 3.141592654
+
+#define Lenght(vec)		sqrt(vec[0]*vec[0]	\
+							+vec[1]*vec[1]	\
+							+vec[2]*vec[2])
+
+#define Cross(vec,vec1,vec2)	vec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];	\
+								vec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];	\
+								vec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; 
+
+#define Minus(sol,vec1,vec2)	sol[0] = vec1[0] - vec2[0];	\
+								sol[1] = vec1[1] - vec2[1];	\
+								sol[2] = vec1[2] - vec2[2];
+				
+
+#define V3_ADD(A,B,C)				   {(C)[0] = (A)[0] + (B)[0];\
+										(C)[1] = (A)[1] + (B)[1];\
+										(C)[2] = (A)[2] + (B)[2];}
+
+#define V3_SCALE(c,C)				   {(C)[0] = (c)*(C)[0];\
+										(C)[1] = (c)*(C)[1];\
+										(C)[2] = (c)*(C)[2];}
+
+#define V3_EUKLIDNORM_OF_DIFF(A,B,b)	(b) = (sqrt((double)(((A)[0]-(B)[0])*((A)[0]-(B)[0])+((A)[1]-(B)[1])*((A)[1]-(B)[1])+((A)[2]-(B)[2])*((A)[2]-(B)[2]))));
+
+#define V3_CLEAR(A) 				   {(A)[0] = 0.0; (A)[1]= 0.0; (A)[2] = 0.0;}
+
+static double IN_CIRC(Element elem,float vol)
+{
+	double p1[3],p2[3],p3[3],p4[3],n1[3],n2[3],n3[3],s1,s2,s3,s4,in_circ;
+	p1[0] = (double)points->Get(elem.PNum(1)).X();
+	p1[1] = (double)points->Get(elem.PNum(1)).Y();
+	p1[2] = (double)points->Get(elem.PNum(1)).Z();
+
+	p2[0] = (double)points->Get(elem.PNum(2)).X();
+	p2[1] = (double)points->Get(elem.PNum(2)).Y();
+	p2[2] = (double)points->Get(elem.PNum(2)).Z();
+
+	p3[0] = (double)points->Get(elem.PNum(3)).X();
+	p3[1] = (double)points->Get(elem.PNum(3)).Y();
+	p3[2] = (double)points->Get(elem.PNum(3)).Z();
+
+	p4[0] = (double)points->Get(elem.PNum(4)).X();
+	p4[1] = (double)points->Get(elem.PNum(4)).Y();
+	p4[2] = (double)points->Get(elem.PNum(4)).Z();
+  
+	Minus(n1,p2,p1);
+	Minus(n2,p3,p1);
+	Cross(n3,n1,n2);
+	s1 = Lenght(n3)/2;
+
+	Minus(n1,p4,p1);
+	Minus(n2,p2,p1);
+	Cross(n3,n1,n2);
+	s2 = Lenght(n3)/2;
+		
+	Minus(n1,p4,p1);
+	Minus(n2,p3,p1);
+	Cross(n3,n1,n2);
+	s3 = Lenght(n3)/2;
+		
+	Minus(n1,p4,p2);
+	Minus(n2,p4,p3);
+	Cross(n3,n1,n2);
+	s4 = Lenght(n3)/2;
+	
+	in_circ = - 3 * vol / (s1 + s2 + s3 + s4);
+	
+	return(in_circ);
+}
+
+static double OUT_CIRC(Element elem,float vol)
+{
+	double p0[3],p1[3],p2[3],p3[3],n1[3],out_circ;
+	double A,B,C,D,E,F,a,b,c,nn;
+		
+	p0[0] = (double)points->Get(elem.PNum(1)).X();
+	p0[1] = (double)points->Get(elem.PNum(1)).Y();
+	p0[2] = (double)points->Get(elem.PNum(1)).Z();
+
+	p1[0] = (double)points->Get(elem.PNum(2)).X();
+	p1[1] = (double)points->Get(elem.PNum(2)).Y();
+	p1[2] = (double)points->Get(elem.PNum(2)).Z();
+
+	p2[0] = (double)points->Get(elem.PNum(3)).X();
+	p2[1] = (double)points->Get(elem.PNum(3)).Y();
+	p2[2] = (double)points->Get(elem.PNum(3)).Z();
+
+	p3[0] = (double)points->Get(elem.PNum(4)).X();
+	p3[1] = (double)points->Get(elem.PNum(4)).Y();
+	p3[2] = (double)points->Get(elem.PNum(4)).Z();
+  
+	Minus(n1,p0,p1);
+	A = Lenght(n1);
+	Minus(n1,p1,p2);
+	B = Lenght(n1);
+	Minus(n1,p2,p0);
+	C = Lenght(n1);
+	Minus(n1,p0,p3);
+	D = Lenght(n1);
+	Minus(n1,p1,p3);
+	E = Lenght(n1);
+	Minus(n1,p2,p3);
+	F = Lenght(n1);
+	
+	a = C * E;
+	b = A * F;
+	c = B * D;
+	
+	nn = (a+b+c)*(a+b-c)*(a-b+c)*(-a+b+c);
+	if(nn<0.0)
+		nn = (a+c+b)*(a+c-b)*(a-c+b)*(-a+c+b);
+	if(nn<0.0)
+		nn = (b+a+c)*(b+a-c)*(b-a+c)*(-b+a+c);
+	if(nn<0.0)
+		nn = (b+c+a)*(b+c-a)*(b-c+a)*(-b+c+a);
+	if(nn<0.0)
+		nn = (c+a+b)*(c+a-b)*(c-a+b)*(-c+a+b);
+	if(nn<0.0)
+		nn = (c+b+a)*(c+b-a)*(c-b+a)*(-c+b+a);
+		
+	out_circ = - sqrt(nn) / (24 * vol);
+	
+	return(out_circ);
+}
+
+static double VOL(Element elem)
+{
+	double x[4][3],vol;
+
+	x[0][0] = points -> Get(elem.PNum(1)).X();
+	x[0][1] = points -> Get(elem.PNum(1)).Y();
+	x[0][2] = points -> Get(elem.PNum(1)).Z();
+	x[1][0] = points -> Get(elem.PNum(2)).X();
+	x[1][1] = points -> Get(elem.PNum(2)).Y();
+	x[1][2] = points -> Get(elem.PNum(2)).Z();
+	x[2][0] = points -> Get(elem.PNum(3)).X();
+	x[2][1] = points -> Get(elem.PNum(3)).Y();
+	x[2][2] = points -> Get(elem.PNum(3)).Z();
+	x[3][0] = points -> Get(elem.PNum(4)).X();
+	x[3][1] = points -> Get(elem.PNum(4)).Y();
+	x[3][2] = points -> Get(elem.PNum(4)).Z();
+
+	vol = ( 	(x[1][0] - x[0][0]) * (x[2][1] - x[0][1]) * (x[3][2] - x[0][2]) 
+			- 	(x[1][0] - x[0][0]) * (x[3][1] - x[0][1]) * (x[2][2] - x[0][2])
+			+	(x[2][0] - x[0][0]) * (x[3][1] - x[0][1]) * (x[1][2] - x[0][2]) 
+			- 	(x[2][0] - x[0][0]) * (x[1][1] - x[0][1]) * (x[3][2] - x[0][2])
+			+	(x[3][0] - x[0][0]) * (x[1][1] - x[0][1]) * (x[2][2] - x[0][2]) 
+			- 	(x[3][0] - x[0][0]) * (x[2][1] - x[0][1]) * (x[1][2] - x[0][2])
+			) / 6;
+			
+	return(vol);
+}
+
+void my_meshing3 :: SaveElement (const Element & elem)
+{
+	double in_circ,out_circ,rho,vol,percent;
+	int i,j;
+	FILE *file;
+	char name[10],buff[5];
+	
+	if (disp)
+	{
+		volelements -> Append (elem);
+//		printf("%s %d %d %d %d\n","element",elem.PNum(1)-1,elem.PNum(2)-1,elem.PNum(3)-1,elem.PNum(4)-1);	  
+	  
+		percent = 100.0 * adfront->Volume() / vol0;
+
+		if(elem.NP()==4)
+		{
+			vol = VOL(elem);
+			in_circ = IN_CIRC(elem,vol);
+			out_circ = OUT_CIRC(elem,vol);
+			rho = 3 * in_circ / out_circ;
+		}
+		
+		if(elem.NP()==4)
+			UserWriteF(" ID(Tetrahedra)=%4d in_circ %6.2f out_circ %7.2f rho %4.2f vol %9.6f%\n",
+						volelements -> Size(),in_circ,out_circ,rho,percent);
+		if(elem.NP()==5)
+			UserWriteF(" ID(Pyramid)=%4d vol %9.6f%\n",
+						volelements -> Size(),percent);
+		if(elem.NP()==6)
+			UserWriteF(" ID(Prism)=%4d vol %9.6f%\n",
+						volelements -> Size(),percent);
+	}
+	if(GG_DEBUG)
+	{
+	 	if(volelements->Size() % 50 == 0)
+		{
+			name[0] = 'g';
+			name[1] = 'r';
+			name[2] = 'a';
+			name[3] = 'p';
+			name[4] = 'e';
+			sprintf(buff,"%d",volelements->Size());
+			name[5] = buff[0];
+			name[6] = buff[1];
+			name[7] = buff[2];
+			name[8] = buff[3];
+			name[9] = buff[4];
+			file = fopen(name,"w");
+			fprintf(file, "%s\n", "volmesh");
+			fprintf(file, "%d\n", volelements->Size());
+			for(i=1;i<=volelements->Size();i++)
+			{
+				fprintf(file, "%d\n",volelements->Get(i).NP());
+				for(j=1;j<=volelements->Get(i).NP()-1;j++)
+					fprintf(file, "%d ",  volelements->Get(i).PNum(j)-1);
+				fprintf(file, "%d\n",  volelements->Get(i).PNum(volelements->Get(i).NP())-1);
+			}
+			fprintf(file, "%d\n", points->Size());
+			for(i=1;i<=points->Size();i++)
+				fprintf(file, "%f %f %f\n", points->Get(i).X(), points->Get(i).Y(), points->Get(i).Z());
+			fclose(file);
+		}
+	}
+}
+
+void my_meshing3 :: Get_Local_h_3d(double *in,double *out)
+  {
+  	Get_h(in,out);
+  }
+
+
+static my_meshing3 * meshing;
+
+
+int AddSurfaceNode (int nodeid, double x, double y, double z)
+  {
+  points -> Append (Point3d(x, y, z*1));   
+  meshing -> AddPoint (Point3d(x, y, z*1), nodeid+1);
+  return 0;
+  }
+  
+  
+int AddSurfaceTriangle (int node0, int node1, int node2,int prism_flag)
+  {
+  Element elem(3);
+  
+  elem.PNum(1) = node0 + 1;
+  elem.PNum(2) = node1 + 1;
+  elem.PNum(3) = node2 + 1;
+  elem.SetSurfaceIndex (1);
+  meshing -> AddBoundaryElement (elem, 0, prism_flag);
+  
+  return 0;
+  }
+  
+int InitNetgen (char * rulefilename)
+  {
+  meshing = new my_meshing3(rulefilename);
+
+  points = new ARRAY<Point3d>;
+  volelements = new ARRAY<Element>;
+  nbp = 0;
+
+  return 0;
+  } 
+
+int StartNetgen (double h, int smooth, int display,int prism)
+ {
+	int i;
+
+	nbp = points->Size();
+	disp = display;
+	vol0 = meshing->adfront->Volume();  
+
+	meshing -> Mesh (h,prism);
+  
+	for (i=0; i<smooth; i++)
+		meshing -> ImproveMesh (*points, *volelements, nbp, h);
+
+	AllMemInnerPoints(points -> Size()-nbp);
+	for (i = nbp + 1; i <= points -> Size(); i++)
+	{
+		AddInnerNode (	points -> Get(i).X(), 
+						points -> Get(i).Y(), 
+						points -> Get(i).Z()/1);
+	}
+  
+	AllMemElements(volelements -> Size());
+	for (i = 1; i <= volelements -> Size(); i++)
+	{
+		AddElement (volelements -> Get(i).NP(),
+					volelements -> Get(i).PNum(1) - 1, 
+					volelements -> Get(i).PNum(2) - 1, 
+					volelements -> Get(i).PNum(3) - 1, 
+					volelements -> Get(i).PNum(4) - 1, 
+					volelements -> Get(i).PNum(5) - 1, 
+					volelements -> Get(i).PNum(6) - 1); 
+	}
+	volelements->SetSize(0);
+	points->SetSize(0);
+	return (0);
+}
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/parser2.cc ug-patched/gm/gg3/netgen/meshing/parser2.cc
--- ug-orig/gm/gg3/netgen/meshing/parser2.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/parser2.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+#include <string.h>
+
+#include <template.hh>
+#include <array.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+
+#include <meshing/ruler2.hh>
+#include <meshing/meshing2.hh>
+
+
+
+void LoadMatrixLine (istream & ist, DenseMatrix & m, int line)
+  {
+  }
+
+
+void netrule :: LoadRule (istream & ist)
+  {
+  }
+
+
+
+void Meshing2 :: LoadRules (char * filename)
+  {
+  }
+
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/parser3.cc ug-patched/gm/gg3/netgen/meshing/parser3.cc
--- ug-orig/gm/gg3/netgen/meshing/parser3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/parser3.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,755 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+#include <string.h>
+
+#include <myadt.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+
+#include <meshing/ruler3.hh>
+#include <meshing/meshing3.hh>
+
+
+void LoadVMatrixLine (istream & ist, DenseMatrix & m, int line)
+{
+  char ch;
+  int pnum;
+  float f;
+  
+  ist >> ch;
+  while (ch != '}')
+    {
+      ist.putback (ch);
+      ist >> f;
+      ist >> ch;
+      ist >> pnum;
+      
+      if (ch == 'x' || ch == 'X')
+	m(line, 3 * pnum - 2) = f;
+      if (ch == 'y' || ch == 'Y')
+	m(line, 3 * pnum - 1) = f;
+      if (ch == 'z' || ch == 'Z')
+	m(line, 3 * pnum    ) = f;
+
+      if (ch == 'p' || ch == 'P')
+	{
+	  m(line  , 3 * pnum-2) = f;
+	  m(line+1, 3 * pnum-1) = f;
+	  m(line+2, 3 * pnum  ) = f;
+	}
+
+      ist >> ch;
+      if (ch == ',')
+	ist >> ch;
+    }
+}
+
+void vnetrule :: LoadRule (istream & ist)
+  {
+  }
+
+void Meshing3 :: LoadRules (char * filename)
+  {
+  }
+
+int vnetrule_new :: NeighbourTrianglePoint (const threeint & t1, const threeint & t2) const
+{
+  ARRAY<int> tr1(3);
+  ARRAY<int> tr2(3);
+  tr1.Elem(1)=t1.i1;
+  tr1.Elem(2)=t1.i2;
+  tr1.Elem(3)=t1.i3;
+  tr2.Elem(1)=t2.i1;
+  tr2.Elem(2)=t2.i2;
+  tr2.Elem(3)=t2.i3;
+
+  int ret=0;
+
+  for (int i=1; i<=3; i++)
+    {
+      for (int j=1; j<=3; j++)
+	{
+	  if ((tr1.Get(i)==tr2.Get(j) && tr1.Get((i%3)+1)==tr2.Get((j%3)+1)) ||
+              (tr1.Get(i)==tr2.Get((j%3)+1) && tr1.Get((i%3)+1)==tr2.Get(j)))
+	    {ret = tr2.Get((j+1)%3+1);}
+	}      
+    }
+
+  return ret;
+
+}
+
+
+void vnetrule_new :: LoadRule(istream & ist)
+  {
+  char buf[256];
+  char ch, ok;
+  Point3d p;
+  Element face;
+  int i, j, i1, i2, i3, fs, ii, ii1, ii2, ii3;
+  twoint edge;
+  DenseMatrix tempoldutonewu(30, 20), 
+    tempoldutofreezone(30, 20),
+  tempoldutofreezonelimit(30, 20);
+
+  tempoldutonewu = 0;
+  tempoldutofreezone = 0;
+
+
+  noldp = 0;
+  noldf = 0;
+
+  ist.get (buf, sizeof(buf), '"');
+  ist.get (ch);
+  ist.get (buf, sizeof(buf), '"');
+  ist.get (ch);
+
+  name = new char[strlen (buf) + 1];
+  strcpy (name, buf);
+//  cout << "Rule " << name << " found." << endl;
+
+  do
+    {
+    ist >> buf;
+
+    if (strcmp (buf, "quality") == 0)
+
+      {
+      ist >> quality;
+      }
+
+    else if (strcmp (buf, "flags") == 0)
+      {
+      ist >> ch;
+      while (ch != ';')
+        {
+        flags.Append (ch);
+        ist >> ch;
+        }
+      }
+
+    else if (strcmp (buf, "mappoints") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        ist >> p.X();
+        ist >> ch;    // ','
+        ist >> p.Y();
+        ist >> ch;    // ','
+        ist >> p.Z();
+        ist >> ch;    // ')'
+
+        points.Append (p);
+        noldp++;
+
+        tolerances.SetSize (noldp);
+        tolerances[noldp] = 1;
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          if (ch == '{')
+            {
+            ist >> tolerances[noldp];
+            ist >> ch;  // '}'
+            }
+
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+
+    else if (strcmp (buf, "mapfaces") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        face.SetNP (3);
+        ist >> face.PNum(1);
+        ist >> ch;    // ','
+        ist >> face.PNum(2);
+        ist >> ch;    // ','
+        ist >> face.PNum(3);
+        ist >> ch;    // ')'
+
+        faces.Append (face);
+        noldf++;
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          if (ch == 'd')
+            {
+            delfaces.Append (noldf);
+            ist >> ch; // 'e'
+            ist >> ch; // 'l'
+            }
+
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+    else if (strcmp (buf, "mapedges") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        ist >> edge.i1;
+        ist >> ch;    // ','
+        ist >> edge.i2;
+        ist >> ch;    // ')'
+
+        edges.Append (edge);
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+
+    else if (strcmp (buf, "newpoints") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        ist >> p.X();
+        ist >> ch;    // ','
+        ist >> p.Y();
+        ist >> ch;    // ','
+        ist >> p.Z();
+        ist >> ch;    // ')'
+
+        points.Append (p);
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          if (ch == '{')
+            {
+            LoadVMatrixLine (ist, tempoldutonewu,
+                            3 * (points.Size()-noldp) - 2);
+
+            ist >> ch; // '{'
+            LoadVMatrixLine (ist, tempoldutonewu,
+                            3 * (points.Size()-noldp) - 1);
+
+            ist >> ch; // '{'
+            LoadVMatrixLine (ist, tempoldutonewu,
+                            3 * (points.Size()-noldp)    );
+            }
+
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+    else if (strcmp (buf, "newfaces") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        face.SetNP (3);
+        ist >> face.PNum(1);
+        ist >> ch;    // ','
+        ist >> face.PNum(2);
+        ist >> ch;    // ','
+        ist >> face.PNum(3);
+        ist >> ch;    // ')'
+
+        faces.Append (face);
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+    else if (strcmp (buf, "freezone") == 0)
+      {
+	ist >> ch;
+	
+	while (ch == '(')
+	  {
+	    ist >> p.X();
+	    ist >> ch;    // ','
+	    ist >> p.Y();
+	    ist >> ch;    // ','
+	    ist >> p.Z();
+	    ist >> ch;    // ')'
+	    
+	    freezone.Append (p);
+	    
+	    ist >> ch;
+	    while (ch != ';')
+	      {
+		if (ch == '{')
+		  {
+		    LoadVMatrixLine (ist, tempoldutofreezone,
+				     3 * freezone.Size() - 2);
+		    
+		    ist >> ch; // '{'
+		    LoadVMatrixLine (ist, tempoldutofreezone,
+				     3 * freezone.Size() - 1);
+		    
+		    ist >> ch; // '{'
+		    LoadVMatrixLine (ist, tempoldutofreezone,
+				     3 * freezone.Size()    );
+		  }
+		
+		ist >> ch;
+	      }
+	    
+	    ist >> ch;
+	  }
+	
+	ist.putback (ch);
+      }
+    else if (strcmp (buf, "freezone2") == 0)
+      {
+	int i, j, k, nfp;
+	Point3d p;
+
+	nfp = 0;
+	ist >> ch;
+
+	DenseMatrix hm1(3, 50), hm2(50, 50), hm3(50, 50);
+	hm3 = 0;
+
+	while (ch == '{')
+	  {
+	    hm1 = 0;
+	    nfp++;
+	    LoadVMatrixLine (ist, hm1, 1);
+
+	    p.X() = p.Y() = p.Z() = 0;
+	    for (i = 1; i <= points.Size(); i++)
+	      {
+		p.X() += hm1.Get(1, 3*i-2) * points.Get(i).X();
+		p.Y() += hm1.Get(1, 3*i-2) * points.Get(i).Y();
+		p.Z() += hm1.Get(1, 3*i-2) * points.Get(i).Z();
+	      }
+	    freezone.Append (p);
+	    freezonelimit.Append (p);
+	    
+	    hm2 = 0;
+	    for (i = 1; i <= 3 * noldp; i++)
+	      hm2.Elem(i, i) = 1;
+	    for (i = 1; i <= 3 * noldp; i++)
+	      for (j = 1; j <= 3 * (points.Size() - noldp); j++)
+		hm2.Elem(j + 3 * noldp, i) = tempoldutonewu.Get(j, i);
+		  
+	    for (i = 1; i <= 3; i++)
+	      for (j = 1; j <= 3 * noldp; j++)
+		{
+		  double sum = 0;
+		  for (k = 1; k <= 3 * points.Size(); k++)
+		    sum += hm1.Get(i, k) * hm2.Get(k, j);
+		  
+		  hm3.Elem(i + 3 * (nfp-1), j) = sum;
+		}
+
+	    while (ch != ';')
+	      ist >> ch; 
+
+	    ist >> ch;
+	  }
+
+	tempoldutofreezone = hm3;
+	tempoldutofreezonelimit = hm3;
+	ist.putback(ch);
+      }
+
+    else if (strcmp (buf, "freezonelimit") == 0)
+      {
+	int i, j, k, nfp;
+	Point3d p;
+
+	nfp = 0;
+	ist >> ch;
+
+	DenseMatrix hm1(3, 50), hm2(50, 50), hm3(50, 50);
+	hm3 = 0;
+
+	while (ch == '{')
+	  {
+	    hm1 = 0;
+	    nfp++;
+	    LoadVMatrixLine (ist, hm1, 1);
+
+	    p.X() = p.Y() = p.Z() = 0;
+	    for (i = 1; i <= points.Size(); i++)
+	      {
+		p.X() += hm1.Get(1, 3*i-2) * points.Get(i).X();
+		p.Y() += hm1.Get(1, 3*i-2) * points.Get(i).Y();
+		p.Z() += hm1.Get(1, 3*i-2) * points.Get(i).Z();
+	      }
+	    freezonelimit.Elem(nfp) = p;
+	    
+	    hm2 = 0;
+	    for (i = 1; i <= 3 * noldp; i++)
+	      hm2.Elem(i, i) = 1;
+	    for (i = 1; i <= 3 * noldp; i++)
+	      for (j = 1; j <= 3 * (points.Size() - noldp); j++)
+		hm2.Elem(j + 3 * noldp, i) = tempoldutonewu.Get(j, i);
+		  
+	    for (i = 1; i <= 3; i++)
+	      for (j = 1; j <= 3 * noldp; j++)
+		{
+		  double sum = 0;
+		  for (k = 1; k <= 3 * points.Size(); k++)
+		    sum += hm1.Get(i, k) * hm2.Get(k, j);
+		  
+		  hm3.Elem(i + 3 * (nfp-1), j) = sum;
+		}
+
+	    while (ch != ';')
+	      ist >> ch; 
+
+	    ist >> ch;
+	  }
+
+	tempoldutofreezonelimit = hm3;
+	ist.putback(ch);
+      }
+
+    else if (strcmp (buf, "freeset") == 0)
+      {
+      freesets.Append (new ARRAY<int>);
+
+      ist >> ch;
+
+      while (ch != ';')
+        {
+        ist.putback (ch);
+        ist >> i;
+        freesets.Last()->Append(i);
+        ist >> ch;
+        }
+      }
+
+    else if (strcmp (buf, "elements") == 0)
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+        elements.Append (Element());
+
+        elements.Last().SetNP(1);
+        ist >> elements.Last().PNum(1);
+        ist >> ch;    // ','
+
+        if (ch == ',')
+          {
+          elements.Last().SetNP(2);
+          ist >> elements.Last().PNum(2);
+          ist >> ch;    // ','
+          }
+        if (ch == ',')
+          {
+          elements.Last().SetNP(3);
+          ist >> elements.Last().PNum(3);
+          ist >> ch;    // ','
+          }
+        if (ch == ',')
+          {
+          elements.Last().SetNP(4);
+          ist >> elements.Last().PNum(4);
+          ist >> ch;    // ','
+          }
+
+        orientations.Append (fourint());
+        orientations.Last().i1 = elements.Last().PNum(1);
+        orientations.Last().i2 = elements.Last().PNum(2);
+        orientations.Last().i3 = elements.Last().PNum(3);
+        orientations.Last().i4 = elements.Last().PNum(4);
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+    else if (strcmp (buf, "orientations") == 0)
+
+      {
+      ist >> ch;
+
+      while (ch == '(')
+        {
+//        fourint a = fourint();
+        orientations.Append (fourint());
+
+        ist >> orientations.Last().i1;
+        ist >> ch;    // ','
+        ist >> orientations.Last().i2;
+        ist >> ch;    // ','
+        ist >> orientations.Last().i3;
+        ist >> ch;    // ','
+        ist >> orientations.Last().i4;
+        ist >> ch;    // ','
+
+
+        ist >> ch;
+        while (ch != ';')
+          {
+          ist >> ch;
+          }
+
+        ist >> ch;
+        }
+
+      ist.putback (ch);
+      }
+
+
+    else if (strcmp (buf, "endrule") != 0)
+      {
+      cout << "Unknown: " << buf << endl;
+      }
+    }
+  while (!ist.eof() && strcmp (buf, "endrule") != 0);
+
+
+  oldutonewu.SetSize (3 * (points.Size() - noldp), 3 * noldp);
+  oldutonewu = 0;
+
+  oldutofreezone = new SparseMatrixFlex (3 * freezone.Size(), 3 * noldp);
+  oldutofreezonelimit = new SparseMatrixFlex (3 * freezone.Size(), 3 * noldp);
+
+  oldutofreezone -> SetSymmetric(0);
+  oldutofreezonelimit -> SetSymmetric(0);
+
+  //  oldutofreezone = new DenseMatrix (3 * freezone.Size(), 3 * noldp);
+  //  oldutofreezonelimit = new DenseMatrix (3 * freezone.Size(), 3 * noldp);
+
+  for (i = 1; i <= oldutonewu.Height(); i++)
+    for (j = 1; j <= oldutonewu.Width(); j++)
+      oldutonewu(i, j) = tempoldutonewu(i, j);
+  
+  for (i = 1; i <= oldutofreezone->Height(); i++)
+    for (j = 1; j <= oldutofreezone->Width(); j++)
+      if (j == 4 || j >= 7)
+	{
+	  if (tempoldutofreezone.Elem(i, j))
+	    (*oldutofreezone)(i, j) = tempoldutofreezone(i, j);
+	  if (tempoldutofreezonelimit.Elem(i, j))
+	    (*oldutofreezonelimit)(i, j) = tempoldutofreezonelimit(i, j);
+	}
+
+
+  for (i = 1; i <= elements.Size(); i++)
+    {
+    orientations.Append (fourint());
+    orientations.Last().i1 = elements[i].PNum(1);
+    orientations.Last().i2 = elements[i].PNum(2);
+    orientations.Last().i3 = elements[i].PNum(3);
+    orientations.Last().i4 = elements[i].PNum(4);
+    }
+
+
+  if (freesets.Size() == 0)
+    {
+    freesets.Append (new ARRAY<int>);
+    for (i = 1; i <= freezone.Size(); i++)
+      freesets[1]->Append(i);
+    }
+
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+    freefaces.Append (new ARRAY<threeint>);
+
+    ARRAY<int> & freeset = *freesets[fs];
+    ARRAY<threeint> & freesetfaces = *freefaces.Last();
+
+    for (ii1 = 1; ii1 <= freeset.Size(); ii1++)
+      for (ii2 = 1; ii2 <= freeset.Size(); ii2++)
+        for (ii3 = 1; ii3 <= freeset.Size(); ii3++)
+          if (ii1 < ii2 && ii1 < ii3 && ii2 != ii3)
+            {
+            i1 = freeset[ii1];
+            i2 = freeset[ii2];
+            i3 = freeset[ii3];
+
+            Vec3d v1, v2, n;
+
+            v1 = freezone[i3] - freezone[i1];
+            v2 = freezone[i2] - freezone[i1];
+            n = Cross (v1, v2);
+            n /= n.Length();
+
+            ok = 1;
+            for (ii = 1; ii <= freeset.Size(); ii++)
+              {
+              i = freeset[ii];
+              if (i != i1 && i != i2 && i != i3)
+                if ( (freezone[i] - freezone[i1]) * n < 0 ) ok = 0;
+              }
+
+            if (ok)
+              {
+              freesetfaces.Append (threeint());
+              freesetfaces.Last().i1 = i1;
+              freesetfaces.Last().i2 = i2;
+              freesetfaces.Last().i3 = i3;
+
+              }
+            }
+    }
+
+  for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      freefaceinequ.Append (new DenseMatrix (freefaces[fs]->Size(), 4));
+    }
+
+
+    {
+    char ok;
+    int minn;
+    ARRAY<int> pnearness (noldp);
+
+    for (i = 1; i <= pnearness.Size(); i++)
+      pnearness[i] = 1000;
+
+    for (j = 1; j <= 3; j++)
+      pnearness[GetPointNr (1, j)] = 0;
+
+    do
+      {
+      ok = 1;
+
+      for (i = 1; i <= noldf; i++)
+        {
+        minn = 1000;
+        for (j = 1; j <= 3; j++)
+          minn = ng_min (minn, pnearness[GetPointNr (i, j)]);
+
+        for (j = 1; j <= 3; j++)
+          if (pnearness[GetPointNr (i, j)] > minn+1)
+            {
+            ok = 0;
+            pnearness[GetPointNr (i, j)] = minn+1;
+            }
+        }
+      }
+    while (!ok);
+
+    fnearness.SetSize (noldf);
+
+    for (i = 1; i <= noldf; i++)
+      {
+	fnearness[i] = 0;
+	for (j = 1; j <= 3; j++)
+	  fnearness[i] += pnearness[GetPointNr (i, j)];
+	
+      }
+    }
+
+    for (fs = 1; fs <= freesets.Size(); fs++)
+    {
+      freeedges.Append (new ARRAY<twoint>);
+      
+      ARRAY<int> & freeset = *freesets[fs];
+      ARRAY<twoint> & freesetedges = *freeedges.Last();
+      ARRAY<threeint> & freesetfaces = *freefaces.Get(fs);
+      int k,l;
+      INDEX ind;
+      
+      for (k = 1; k <= freesetfaces.Size(); k++)
+	{
+          threeint tr=freesetfaces.Get(k);
+	  for (l = k+1; l <= freesetfaces.Size(); l++)
+	    {
+	      if (ind = NeighbourTrianglePoint(freesetfaces.Get(k),freesetfaces.Get(l)))
+		{
+		  freesetedges.Append(twoint(k,ind));
+		}
+	    }	
+	}
+    }
+    
+  }
+
+
+
+
+
+void Meshing3 :: LoadRules_new (char * filename)
+  {
+    char buf[256];
+    ifstream ist (filename);
+  
+    if (!ist.good())
+      {
+	cerr << "Rule description file " << filename << " not found" << endl;
+	exit (1);
+      }
+    
+    while (!ist.eof())
+      {
+	buf[0] = 0;
+	ist >> buf;
+	
+	if (strcmp (buf, "rule") == 0)
+	  {
+	    vnetrule_new * rule = new vnetrule_new;
+	    rule -> LoadRule(ist);
+	    rules_new.Append (rule);
+	    if (!rule->TestOk())
+	      {
+		cout << "Rule " << rules.Size() << " not ok" << endl;
+		exit (1);
+	      }
+	  }
+	else if (strcmp (buf, "tolfak") == 0)
+	  {
+	    ist >> tolfak;
+	  }
+      }
+  }
diff -ruN ug-orig/gm/gg3/netgen/meshing/ruler2.cc ug-patched/gm/gg3/netgen/meshing/ruler2.cc
--- ug-orig/gm/gg3/netgen/meshing/ruler2.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/ruler2.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+
+#include <template.hh>
+#include <array.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+#include <meshing/ruler2.hh>
+
+
+int ApplyRules ( const ARRAY<netrule*> & rules,
+                 ARRAY<Point2d> & lpoints, ARRAY<ILINE> & llines,
+                 ARRAY<Element> & elements,
+                 ARRAY<INDEX> & dellines, int tolerance)
+{
+	return(0);
+}
+
+
+
+
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/ruler2.hh ug-patched/gm/gg3/netgen/meshing/ruler2.hh
--- ug-orig/gm/gg3/netgen/meshing/ruler2.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/ruler2.hh	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,76 @@
+#ifndef FILE_NETRULE
+#define FILE_NETRULE
+
+#include <iostream.h>
+
+class netrule
+  {
+  typedef struct tf { float f1, f2, f3; } threefloat;
+  class threeint { public: int i1, i2, i3; threeint() { } };
+
+  int quality;
+  char * name;
+  ARRAY<Point2d> points;
+  ARRAY<ILINE> lines;
+  ARRAY<Point2d> freezone;
+  ARRAY<Point2d> transfreezone;
+
+  ARRAY<int> dellines;
+  ARRAY<Element> elements;
+  ARRAY<threefloat> tolerances, linetolerances;
+  ARRAY<threeint> orientations;
+//  SparseMatrix oldutonewu, oldutofreearea;
+//  SparseMatrix freesetinequ;
+
+  ARRAY<Vec2d> linevecs;
+
+  int noldp, noldl;
+  float fzminx, fzmaxx, fzminy, fzmaxy;
+
+  public:
+
+  netrule ();
+
+  int GetNP () const { return points.Size(); }
+  int GetNL () const { return lines.Size(); }
+  int GetNE () const { return elements.Size(); }
+  int GetNOldP () const { return noldp; }
+  int GetNOldL () const { return noldl; }
+  int GetNDelL () const { return dellines.Size(); }
+  int GetNOrientations () const { return orientations.Size(); }
+  int GetQuality () const { return quality; }
+
+  const Point2d & GetPoint (int i) const { return points.Get(i); }
+  const ILINE & GetLine (int i) const { return lines.Get(i); }
+  const Element & GetElement (int i) const { return elements.Get(i); }
+  const threeint & GetOrientation (int i) const { return orientations.Get(i); }
+  int GetDelLine (int i) const { return dellines.Get(i); }
+
+  void GetFreeZone (ARRAY<Point2d> & afreearea);
+  float CalcPointDist (int pi, const Point2d & p) const;
+  float CalcLineError (int li, const Vec2d & v) const;
+
+  void SetFreeZoneTransformation (const Vector & u);
+  int IsInFreeZone (const Point2d & p) const;
+  int IsLineInFreeZone (const Point2d & p1, const Point2d & p2) const;
+  int ConvexFreeZone () const;
+  const ARRAY<Point2d> & GetTransFreeZone () { return transfreezone; }
+
+  int GetPointNr (int ln, int endp) const { return lines.Get(ln).I(endp); }
+
+//  const SparseMatrix & GetOldUToNewU () const { return oldutonewu; }
+//  const SparseMatrix & GetOldUToFreeArea () const { return oldutofreearea; }
+  const char * Name () const { return name; }
+
+  void LoadRule (istream & ist);
+  };
+
+
+extern int ApplyRules (const ARRAY<netrule*> & rules,
+                  ARRAY<Point2d> & lpoints, ARRAY<ILINE> & llines,
+                 ARRAY<Element> & elements, ARRAY<INDEX> & dellines,
+                 int tolerance);
+
+extern void DrawRules ();
+#endif
+
diff -ruN ug-orig/gm/gg3/netgen/meshing/ruler3.cc ug-patched/gm/gg3/netgen/meshing/ruler3.cc
--- ug-orig/gm/gg3/netgen/meshing/ruler3.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/ruler3.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,901 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <math.h>
+
+#include <myadt.hh>
+
+#include <linalg/linalg.hh>
+#include <geom/geom2d.hh>
+#include <geom/geom3d.hh>
+
+#include <meshing/global.hh>
+#include <meshing/ruler3.hh>
+
+static double CalcElementBadness (const ARRAY<Point3d> & points,
+      const Element & elem)
+{
+	double vol, l, l4, l5, l6;
+
+	Vec3d v1 = points[elem.PNum(2)] - points[elem.PNum(1)];
+	Vec3d v2 = points[elem.PNum(3)] - points[elem.PNum(1)];
+	Vec3d v3 = points[elem.PNum(4)] - points[elem.PNum(1)];
+
+	vol = - (Cross(v1, v2) * v3);
+	l4 = Dist (points[elem.PNum(2)], points[elem.PNum(3)]);
+	l5 = Dist (points[elem.PNum(2)], points[elem.PNum(4)]);
+	l6 = Dist (points[elem.PNum(3)], points[elem.PNum(4)]);
+
+	l = v1.Length() + v2.Length() + v3.Length() + l4 + l5 + l6;
+
+	if (vol < 1e-8) 
+		return 1e10;
+
+	return (l*l*l/vol)/500;
+}
+
+int ApplyVRules (const ARRAY<vnetrule*> & rules, double tolfak,
+                 ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+                 ARRAY<Element> & elements,
+                 ARRAY<INDEX> & delfaces, int tolerance, int rotind1,
+                 float & retminerr, ARRAY<char*> & problems)
+{
+	return(0);
+}
+
+int ApplyVRules_new
+(
+ const ARRAY<vnetrule_new*> & rules, double tolfak,
+ ARRAY<Point3d> & lpoints,     // in: local points, out: old+new local points
+ ARRAY<Element> & lfaces,   // in: local faces, out: old+new local faces
+ INDEX lfacesplit,	       // for local faces in outer radius
+ ARRAY<Element> & elements,    // out: new elements
+ ARRAY<INDEX> & delfaces,      // out: face indices of faces to delete
+ int tolerance,                // quality class: 1 best 
+ int rotind1,                  // how to rotate base element
+ float & retminerr,            // element error 
+ ARRAY<char*> & problems
+ )
+
+{
+  const int rotsym = 3;
+  int i, j, k, ri, nfok, npok, incnpok, refpi, locpi, locfi, locfr;
+  int hi, minn, hpi;
+  float hf, err, minerr, teterr, minteterr;
+  char ok, found, hc;
+  vnetrule_new * rule;
+  Vector oldu, newu, newu1, newu2;
+  Vec3d ui;
+  Point3d np;
+  int oldnp, noldlp, noldlf;
+  const Element * locface = NULL;
+  int loktestmode;
+  Element own;
+  
+  static ARRAY<int> pused;       // point is already mapped
+  static ARRAY<int> fused;       // face is already mapped
+  static ARRAY<int> pmap;        // map of reference point to local point
+  static ARRAY<int> pfixed;      // ???
+  static ARRAY<int> fmapi;       // face in reference is mapped to face nr ...
+  static ARRAY<int> fmapr;       // face in reference is rotated to map 
+  static ARRAY<Point3d> transfreezone;  // transformed free-zone
+  static INDEX cnt = 0;
+  INDEX_2_HASHTABLE<int> ledges(lfaces.Size());  // edges in local environment
+  
+  static ARRAY<Point3d> tempnewpoints;
+  static ARRAY<Element> tempnewfaces;
+  static ARRAY<int> tempdelfaces;
+  static ARRAY<Element> tempelements;
+
+  static ARRAY<double> triminx, trimaxx, triminy, trimaxy, triminz, trimaxz;
+  
+  //  static ARRAY<int> notnewnewfaces;
+  
+  static ARRAY<int> pnearness;
+  static ARRAY<int> fnearness;
+  
+  cnt++;
+  
+  delfaces.SetSize (0);
+  elements.SetSize (0);
+
+
+  // determine topological distance of faces and points to
+  // base element
+
+  pnearness.SetSize (lpoints.Size());
+  fnearness.SetSize (lfacesplit);
+
+  for (i = 1; i <= pnearness.Size(); i++)
+    pnearness.Set(i, INT_MAX/4);
+  
+  for (j = 1; j <= 3; j++)
+    pnearness.Set(lfaces.Get(1).PNum(j), 0);
+
+  do
+    {
+      ok = 1;
+      
+      for (i = 1; i <= lfacesplit; i++)
+	//      for (i = 1; i <= lfaces.Size(); i++)
+	{
+	  const Element & hface = lfaces.Get(i);
+
+	  minn = INT_MAX-1;
+	  for (j = 1; j <= 3; j++)
+	    {
+	      hi = pnearness.Get(hface.PNum(j));
+	      if (hi < minn) minn = hi;
+	    }
+	  
+	  for (j = 1; j <= 3; j++)
+	    {
+	      hpi = hface.PNum(j);
+	      if (pnearness.Get(hpi) > minn+1)
+		{
+		  ok = 0;
+		  pnearness.Set(hpi, minn+1);
+		}
+	    }
+	}
+    }
+  while (!ok);
+  
+  for (i = 1; i <= fnearness.Size(); i++)
+    {
+      fnearness.Set(i, 0);
+      for (j = 1; j <= 3; j++)
+	fnearness.Elem(i) += pnearness.Get(lfaces.Get(i).PNum(j));
+    }
+
+
+  triminx.SetSize (lfaces.Size());
+  trimaxx.SetSize (lfaces.Size());
+  triminy.SetSize (lfaces.Size());
+  trimaxy.SetSize (lfaces.Size());
+  triminz.SetSize (lfaces.Size());
+  trimaxz.SetSize (lfaces.Size());
+
+  for (i = 1; i <= lfaces.Size(); i++)
+    {
+      const Element & face = lfaces.Get(i);
+      const Point3d & p1 = lpoints.Get(face.PNum(1));
+      const Point3d & p2 = lpoints.Get(face.PNum(2));
+      const Point3d & p3 = lpoints.Get(face.PNum(3));
+      triminx.Elem(i) = ng_min (p1.X(), p2.X(), p3.X());
+      trimaxx.Elem(i) = ng_max (p1.X(), p2.X(), p3.X());
+      triminy.Elem(i) = ng_min (p1.Y(), p2.Y(), p3.Y());
+      trimaxy.Elem(i) = ng_max (p1.Y(), p2.Y(), p3.Y());
+      triminz.Elem(i) = ng_min (p1.Z(), p2.Z(), p3.Z());
+      trimaxz.Elem(i) = ng_max (p1.Z(), p2.Z(), p3.Z());
+    }
+
+  
+
+  for (j = 1; j <= lfacesplit; j++)
+  {
+	INDEX_2 i2;
+	own = lfaces.Get(j);
+	i2.I1() = lfaces.Get(j).PNumMod(1);
+	i2.I2() = lfaces.Get(j).PNumMod(2);
+	ledges.Set (i2, 1);
+	i2.I1() = lfaces.Get(j).PNumMod(2);
+	i2.I2() = lfaces.Get(j).PNumMod(3);
+	ledges.Set (i2, 1);
+	i2.I1() = lfaces.Get(j).PNumMod(3);
+	i2.I2() = lfaces.Get(j).PNumMod(1);
+	ledges.Set (i2, 1);
+  }
+  
+  
+
+  
+  pused.SetSize (lpoints.Size());
+  fused.SetSize (lfaces.Size());
+  
+
+
+  found = 0;
+  minerr = tolfak * tolerance * tolerance;
+  minteterr = 500 * tolerance * tolerance;
+
+  // check each rule:
+
+  for (ri = 1; ri <= rules.Size(); ri++)
+    { // loop ri
+      
+      
+      rule = rules.Get(ri);
+      
+      if (rule->GetQuality() > tolerance)
+	{
+	  if (testmode)
+	    sprintf (problems[ri], "Quality not ok");
+	  continue;
+	}
+      
+      if (testmode)
+	sprintf (problems[ri], "no mapping found");
+      
+      loktestmode = testmode || rule->TestFlag ('t');
+      
+      pmap.SetSize (rule->GetNP());
+      fmapi.SetSize (rule->GetNF());
+      fmapr.SetSize (rule->GetNF());
+      
+      for (i = 1; i <= lfaces.Size(); i++)
+	fused.Set (i, 0);
+      for (i = 1; i <= lpoints.Size(); i++)
+	pused.Set (i, 0);
+      for (i = 1; i <= pmap.Size(); i++)
+	pmap.Set(i, 0);
+      for (i = 1; i <= fmapi.Size(); i++)
+	fmapi.Set(i, 0);
+      for (i = 1; i <= fmapr.Size(); i++)
+	fmapr.Set(i, 3);
+      
+      fused.Set (1, 1);
+      
+      fmapi.Set (1, 1);
+      fmapr.Set (1, rotind1);
+
+      
+      for (j = 1; j <= 3; j++)
+	{
+	  locpi = lfaces.Get(1).PNumMod (j+rotind1);
+	  pmap.Set (rule->GetPointNr (1, j), locpi);
+	  pused.Elem(locpi)++;
+	}
+
+
+
+      /*
+	map all faces
+	nfok .. first nfok-1 faces are mapped properly
+       */
+
+      nfok = 2;
+      while (nfok >= 2)
+	{
+	  
+	  if (nfok <= rule->GetNOldF())
+	    {
+	      // not all faces mapped
+
+	      ok = 0;
+	      locfi = fmapi.Get(nfok);
+	      locfr = fmapr.Get(nfok);
+	      
+	      while (!ok)
+		{
+		  locfr++;
+		  if (locfr == rotsym + 1)
+		    {
+		      locfr = 1;
+		      locfi++;
+		      if (locfi > lfacesplit) break;
+		    }
+		  
+		  
+		  if (fnearness.Get(locfi) > rule->GetFNearness (nfok) ||
+		      fused.Get(locfi) )
+		    {
+		      // face not feasible in any rotation
+
+		      locfr = rotsym;
+		    }
+		  else
+		    {
+		      
+		      ok = 1;
+		      
+		      locface = &lfaces.Get(locfi);
+		      
+		      // reference point already mapped differently ?
+		      for (j = 1; j <= 3 && ok; j++)
+			{
+			  locpi = pmap.Get(rule->GetPointNr (nfok, j));
+			  
+			  if (locpi && locpi != locface->PNumMod(j+locfr))
+			    ok = 0;
+			}
+		      
+		      // local point already used or point outside tolerance ?
+		      for (j = 1; j <= 3 && ok; j++)
+			{
+			  refpi = rule->GetPointNr (nfok, j);
+			  
+			  if (pmap.Get(refpi) == 0)
+			    {
+			      locpi = locface->PNumMod (j + locfr);
+
+			      /*
+			      if (pused.Get(locpi) ||
+				  rule->CalcPointDist (refpi, lpoints.Get(locpi)) > minerr)
+				ok = 0;
+				*/
+
+			      if (pused.Get(locpi))
+				ok = 0;
+			      else
+				{
+				  const Point3d & lp = lpoints.Get(locpi);
+				  const Point3d & rp = rule->GetPoint(refpi);
+				  if ( ( (lp.X()-rp.X())*(lp.X()-rp.X()) + 
+					 (lp.Y()-rp.Y())*(lp.Y()-rp.Y()) + 
+					 (lp.Z()-rp.Z())*(lp.Z()-rp.Z()) )
+					 * rule->PointDistFactor(refpi) > minerr)
+				    //				  if (Dist2(lp, rp) * rule->PointDistFactor(refpi) > minerr)
+				    ok = 0;
+				}
+			    }
+			}
+		    }
+		}
+	      
+	      
+	      if (ok)
+		{
+		  // map face nfok
+
+		  fmapi.Set (nfok, locfi);
+		  fmapr.Set (nfok, locfr);
+		  fused.Set (locfi, 1);
+		  
+		  for (j = 1; j <= rule->GetNP (nfok); j++)
+		    {
+		      locpi = locface->PNumMod(j+locfr);
+		      
+		      if (rule->GetPointNr (nfok, j) <= 3 &&
+			  pmap.Get(rule->GetPointNr(nfok, j)) != locpi)
+			cout << "change face1 point, mark1" << endl;
+		      
+		      pmap.Set(rule->GetPointNr (nfok, j), locpi);
+		      pused.Elem(locpi)++;
+		    }
+		  
+		  nfok++;
+		}
+	      else
+		{
+		  // backtrack one face
+		  fmapi.Set (nfok, 0);
+		  fmapr.Set (nfok, 3);
+		  nfok--;
+		  
+		  fused.Set (fmapi.Get(nfok), 0);
+		  for (j = 1; j <= rule->GetNP (nfok); j++)
+		    {
+		      refpi = rule->GetPointNr (nfok, j);
+		      pused.Elem(pmap.Get(refpi))--;
+		      
+		      if (pused.Get(pmap.Get(refpi)) == 0)
+			{
+			  pmap.Set(refpi, 0);
+			}
+		    }
+		}
+	    }
+	  
+	  else
+	    
+	    { 
+
+	      // all faces are mapped
+	      // now map all isolated points:
+	      
+	      if (loktestmode)
+		{
+		  sprintf (problems[ri], "Faces Ok");
+		}
+	      
+	      npok = 1;
+	      incnpok = 1;
+	      
+	      pfixed.SetSize (pmap.Size());
+	      for (i = 1; i <= pmap.Size(); i++)
+		pfixed.Set(i, (pmap.Get(i) != 0) );
+	      
+	      while (npok >= 1)
+		{
+		  
+		  if (npok <= rule->GetNOldP())
+		    {
+		      
+		      if (pfixed.Get(npok))
+			
+			{
+			  if (incnpok)
+			    npok++;
+			  else
+			    npok--;
+			}
+		      
+		      else
+			
+			{
+			  locpi = pmap.Elem(npok);
+			  ok = 0;
+			  
+			  if (locpi)
+			    pused.Elem(locpi)--;
+			  
+			  while (!ok && locpi < lpoints.Size())
+			    {
+			      ok = 1;
+			      locpi++;
+			      
+			      if (pused.Get(locpi))
+				{
+				  ok = 0;
+				}
+			      else
+				{
+				  // if (rule->CalcPointDist (npok, lpoints.Get(locpi)) > minerr)
+				  //    ok = 0;
+
+				  const Point3d & lp = lpoints.Get(locpi);
+				  const Point3d & rp = rule->GetPoint(npok);
+				  if ( ( (lp.X()-rp.X())*(lp.X()-rp.X()) + 
+					 (lp.Y()-rp.Y())*(lp.Y()-rp.Y()) + 
+					 (lp.Z()-rp.Z())*(lp.Z()-rp.Z()) )
+					 * rule->PointDistFactor(npok) > minerr)
+				    ok = 0;
+				}
+			    }
+			  
+			  
+			  if (ok)
+			    {
+			      pmap.Set (npok, locpi);
+			      			      
+			      pused.Elem(locpi)++;
+			      npok++;
+			      incnpok = 1;
+			    }
+			  
+			  else
+			    
+			    {
+			      pmap.Set (npok, 0);
+			      			      
+			      npok--;
+			      incnpok = 0;
+			    }
+			}
+		    }
+		  
+		  else
+		    
+		    {
+		      
+		      // all points are mapped
+		      
+		      if (loktestmode)
+			{
+			  sprintf (problems[ri], "mapping found");
+			}
+		      
+		      ok = 1;
+		      
+		      
+		      // check mapedges:
+		      
+
+		      
+		      for (i = 1; i <= rule->GetNEd(); i++)
+			{
+
+			  int i1, i2;
+			  i1 = pmap.Get(rule->GetEdge(i).i1);
+			  i2 = pmap.Get(rule->GetEdge(i).i2);
+
+			  INDEX_2 in2(i1, i2);
+			  if (!ledges.Used (in2)) ok = 0;
+			}
+
+		      
+		      for (i = rule->GetNOldF() + 1; i <= rule->GetNF(); i++)
+			fmapi.Set(i, 0);
+		      
+		      
+
+		      // deviation of existing points
+
+		      oldu.SetLength (3 * rule->GetNOldP());
+
+		      for (i = 1; i <= rule->GetNOldP(); i++)
+			{
+			  //			  ui = lpoints.Get(pmap.Get(i)) - rule->GetPoint(i);
+			  const Point3d & lp = lpoints.Get(pmap.Get(i));
+			  const Point3d & rp = rule->GetPoint(i);
+			  oldu.Set (3*i-2, lp.X()-rp.X());
+			  oldu.Set (3*i-1, lp.Y()-rp.Y());
+			  oldu.Set (3*i  , lp.Z()-rp.Z());
+			}
+		      
+
+		      //		      rule->GetOldUToFreeZone().Mult (oldu, newu);
+		      //		      rule->SetFreeZoneTransformation (newu);
+		      rule->SetFreeZoneTransformation (oldu, tolerance);
+
+		      if (!rule->ConvexFreeZone())
+			{
+			  if (loktestmode)
+			    {
+			      sprintf (problems[ri], "Freezone not convex");
+			    }
+			  ok = 0;
+			}
+		      
+
+		      // check freezone:
+		      
+		      for (i = 1; i <= lpoints.Size(); i++)
+			{
+			  if ( !pused.Get(i) )
+			    {
+			      const Point3d & lp = lpoints.Get(i);
+
+			      if (lp.X() >= rule->fzminx && lp.X() <= rule->fzmaxx &&
+				  lp.Y() >= rule->fzminy && lp.Y() <= rule->fzmaxy &&
+				  lp.Z() >= rule->fzminz && lp.Z() <= rule->fzmaxz)
+				{
+				  if (rule->IsInFreeZone(lpoints.Get(i)))
+				    {
+				      if (loktestmode)
+					{
+					  sprintf (problems[ri], 
+						   "locpoint %d in Freezone", i);
+					}
+				      ok = 0;
+				      break;
+				    }
+				}
+			    }
+			}
+		      
+		      
+		      for (i = 1; i <= lfaces.Size() && ok; i++)
+			{
+			  if (!fused.Get(i))
+			    { 
+			      int triin;
+
+			      if (triminx.Elem(i) > rule->fzmaxx ||
+				  trimaxx.Elem(i) < rule->fzminx ||
+				  triminy.Elem(i) > rule->fzmaxy ||
+				  trimaxy.Elem(i) < rule->fzminy ||
+				  triminz.Elem(i) > rule->fzmaxz ||
+				  trimaxz.Elem(i) < rule->fzminz)
+				triin = 0;
+			      else
+				triin = rule->IsTriangleInFreeZone 
+				  (
+				   lpoints.Get(lfaces.Get(i).PNum(1)),
+				   lpoints.Get(lfaces.Get(i).PNum(2)),
+				   lpoints.Get(lfaces.Get(i).PNum(3)) 
+				   );
+			      
+			      if (triin == -1)
+				{
+				  ok = 0;
+				}
+			      
+			      if (triin == 1)
+				{
+				  hc = 0;
+				  for (k = rule->GetNOldF() + 1; k <= rule->GetNF(); k++)
+				    {
+				      if (rule->GetPointNr(k, 1) <= rule->GetNOldP() &&
+					  rule->GetPointNr(k, 2) <= rule->GetNOldP() &&
+					  rule->GetPointNr(k, 3) <= rule->GetNOldP())
+					{
+					  for (j = 1; j <= 3; j++)
+					    if (lfaces.Get(i).PNumMod(j  ) == pmap.Get(rule->GetPointNr(k, 1)) &&
+						lfaces.Get(i).PNumMod(j+1) == pmap.Get(rule->GetPointNr(k, 3)) &&
+						lfaces.Get(i).PNumMod(j+2) == pmap.Get(rule->GetPointNr(k, 2)))
+					      {
+						fmapi.Elem(k) = i;
+						hc = 1;
+					      }
+					}
+				    }
+				  
+				  if (!hc)
+				    {
+				      if (loktestmode)
+					{
+					  sprintf (problems[ri], "triangle (%d, %d, %d) in Freezone",
+						   lfaces.Get(i).PNum(1), lfaces.Get(i).PNum(2),
+						   lfaces.Get(i).PNum(3));
+					}
+				      ok = 0;
+				    }
+				}
+			    }
+			}
+
+		      
+		      if (ok)
+			{
+			  
+			  err = 0;
+			  for (i = 1; i <= rule->GetNOldP(); i++)
+			    {
+			      hf = rule->CalcPointDist (i, lpoints[pmap[i]]);
+			      if (hf > err) err = hf;
+			    }
+			  
+			  if (loktestmode)
+			    {
+			      sprintf (problems[ri], "Rule ok, err = %f", err);
+			    }
+			  
+			  newu = rule->GetOldUToNewU() * oldu;
+
+			  // set new points:
+			  
+			  oldnp = rule->GetNOldP();
+			  noldlp = lpoints.Size();
+			  noldlf = lfaces.Size();
+			  
+			  
+			  for (i = oldnp + 1; i <= rule->GetNP(); i++)
+			    {
+			      np = rule->GetPoint(i);
+			      np.X() += newu (3 * (i-oldnp) - 2);
+			      np.Y() += newu (3 * (i-oldnp) - 1);
+			      np.Z() += newu (3 * (i-oldnp));
+			      
+			      pmap[i] = lpoints.Append (np);
+			    }
+			  
+			  // Set new Faces:
+			  
+			  for (i = rule->GetNOldF() + 1; i <= rule->GetNF(); i++)
+			    if (!fmapi[i])
+			      {
+				Element nface;
+				for (j = 1; j <= 3; j++)
+				  nface.PNum(j) = pmap[rule->GetPointNr (i, j)];
+				nface.SetNP(3);
+				lfaces.Append (nface);
+			      }
+			  
+			  
+			  // Delete old Faces:
+
+			  for (i = 1; i <= rule->GetNDelF(); i++)
+			    delfaces.Append (fmapi.Get(rule->GetDelFace(i)));
+			  for (i = rule->GetNOldF()+1; i <= rule->GetNF(); i++)
+			    if (fmapi.Get(i))
+			      {
+				delfaces.Append (fmapi[i]);
+				fmapi[i] = 0;
+			      }
+			  
+
+			  for (i = 1; i <= rule->GetNO() && ok; i++)
+			    {
+			      const fourint * fouri;
+			      double v1x, v1y, v1z, v2x, v2y, v2z, v3x, v3y, v3z;
+			      
+			      fouri = &rule->GetOrientation(i);
+			      
+			      v1x = lpoints.Get(pmap.Get(fouri->i2)).X() -
+				lpoints.Get(pmap.Get(fouri->i1)).X();
+			      v1y = lpoints.Get(pmap.Get(fouri->i2)).Y() -
+				lpoints.Get(pmap.Get(fouri->i1)).Y();
+			      v1z = lpoints.Get(pmap.Get(fouri->i2)).Z() -
+				lpoints.Get(pmap.Get(fouri->i1)).Z();
+			      
+			      v2x = lpoints.Get(pmap.Get(fouri->i3)).X() -
+				lpoints.Get(pmap.Get(fouri->i1)).X();
+			      v2y = lpoints.Get(pmap.Get(fouri->i3)).Y() -
+				lpoints.Get(pmap.Get(fouri->i1)).Y();
+			      v2z = lpoints.Get(pmap.Get(fouri->i3)).Z() -
+				lpoints.Get(pmap.Get(fouri->i1)).Z();
+			      
+			      v3x = lpoints.Get(pmap.Get(fouri->i4)).X() -
+				lpoints.Get(pmap.Get(fouri->i1)).X();
+			      v3y = lpoints.Get(pmap.Get(fouri->i4)).Y() -
+				lpoints.Get(pmap.Get(fouri->i1)).Y();
+			      v3z = lpoints.Get(pmap.Get(fouri->i4)).Z() -
+				lpoints.Get(pmap.Get(fouri->i1)).Z();
+			      
+			      
+			      if (v1x * v2y * v3z +
+				  v1y * v2z * v3x +
+				  v1z * v2x * v3y -
+				  v1x * v2z * v3y -
+				  v1y * v2x * v3z -
+				  v1z * v2y * v3x > -1E-7)
+				{
+				  if (loktestmode)
+				    {
+				      sprintf (problems[ri], "Orientation wrong");
+				    }
+				  ok = 0;
+				}
+			    }
+			  
+
+			  // new points in free-zone ?
+			  for (i = rule->GetNOldP() + 1; i <= rule->GetNP() && ok; i++)
+			    if (!rule->IsInFreeZone (lpoints[pmap[i]]))
+			      {
+				if (loktestmode)
+				  {
+				    sprintf (problems[ri], "newpoint outside convex hull");
+				  }
+				ok = 0;
+				
+			      }
+			  
+			  // insert new elements
+			  
+			  for (i = 1; i <= rule->GetNE(); i++)
+			    {
+			      elements.Append (rule->GetElement(i));
+			      for (j = 1; j <= elements[i].NP(); j++)
+				elements[i].PNum(j) = pmap[elements[i].PNum(j)];
+			    }
+			  
+
+			  // Calculate Element badness
+			  
+			  teterr = 0;
+			  for (i = 1; i <= elements.Size(); i++)
+			    {
+			      hf = CalcElementBadness (lpoints, elements[i]);
+			      if (hf > teterr) teterr = hf;
+			    }
+
+			  if (ok && teterr < 1e6 &&
+			      (rule->TestFlag('b') || tolerance > 10) )
+			    {
+			    //  cout << "Reset teterr " 
+				//   << rule->Name() 
+				//   << " err = " << teterr 
+				//   << endl;
+				   printf("Reset teterr %s err = %g\n",rule->Name(),teterr);
+			      teterr = 1;
+			    }
+
+			  // compare edgelength
+			  if (rule->TestFlag('l'))
+			    {
+			      double oldlen = 0;
+			      double newlen = 0;
+
+			      for (i = 1; i <= rule->GetNDelF(); i++)
+				{
+				  const Element & face = 
+				    rule->GetFace (rule->GetDelFace(i));
+				  for (j = 1; j <= 3; j++)
+				    {
+				      const Point3d & p1 =
+					lpoints.Get(pmap.Get(face.PNumMod(j)));
+				      const Point3d & p2 =
+					lpoints.Get(pmap.Get(face.PNumMod(j+1)));
+				      oldlen += Dist(p1, p2);
+				    }
+				}
+
+			      for (i = rule->GetNOldF()+1; i <= rule->GetNF(); i++)
+				{
+				  const Element & face = rule->GetFace (i);
+				  for (j = 1; j <= 3; j++)
+				    {
+				      const Point3d & p1 =
+					lpoints.Get(pmap.Get(face.PNumMod(j)));
+				      const Point3d & p2 =
+					lpoints.Get(pmap.Get(face.PNumMod(j+1)));
+				      newlen += Dist(p1, p2);
+				    }
+				}
+
+			      if (oldlen < newlen) 
+				{
+				  ok = 0;
+				  if (loktestmode)
+				    sprintf (problems[ri], "oldlen < newlen");
+				}
+			    }
+			  
+			  if (ok && teterr < minteterr)
+			    {
+			      found = ri;
+			      minteterr = teterr;
+			      
+			      if (testmode)
+				{
+				}
+			      
+			      tempnewpoints.SetSize (0);
+			      for (i = noldlp+1; i <= lpoints.Size(); i++)
+				tempnewpoints.Append (lpoints[i]);
+			      
+			      tempnewfaces.SetSize (0);
+			      for (i = noldlf+1; i <= lfaces.Size(); i++)
+				tempnewfaces.Append (lfaces[i]);
+
+			      tempdelfaces.SetSize (0);
+			      for (i = 1; i <= delfaces.Size(); i++)
+				tempdelfaces.Append (delfaces[i]);
+			      
+			      tempelements.SetSize (0);
+			      for (i = 1; i <= elements.Size(); i++)
+				tempelements.Append (elements[i]);
+			    }
+			  
+			  lpoints.SetSize (noldlp);
+			  lfaces.SetSize (noldlf);
+			  delfaces.SetSize (0);
+			  elements.SetSize (0);
+			}
+		      
+		      npok = rule->GetNOldP();
+		      incnpok = 0;
+		    }
+		}
+	      
+	      nfok = rule->GetNOldF();
+	      
+	      for (j = 1; j <= rule->GetNP (nfok); j++)
+		{
+		  refpi = rule->GetPointNr (nfok, j);
+		  pused.Elem(pmap.Get(refpi))--;
+		  
+		  if (pused.Get(pmap.Get(refpi)) == 0)
+		    {
+		      pmap.Set(refpi, 0);
+		    }
+		}
+	      
+	    }
+	}
+    }
+
+
+  // if successfull, reload best choice
+  
+  if (found)
+    {
+
+#ifdef debug
+      // if face in advancing front ???
+      for (i = 1; i <= tempnewfaces.Size(); i++)
+	{
+	  hc = 1;
+	  for (k = 1; k <= lfaces.Size() && hc; k++)
+	    for (j = 1; j <= 3 && hc; j++)
+	      if (tempnewfaces.Elem(i).PNumMod(j  ) == lfaces.Get(k).PNum(1) &&
+		  tempnewfaces.Elem(i).PNumMod(j+1) == lfaces.Get(k).PNum(3) &&
+		  tempnewfaces.Elem(i).PNumMod(j+2) == lfaces.Get(k).PNum(2))
+		{
+		  tempdelfaces.Append(k);
+		  tempnewfaces.Elem(i).PNum(1) = 0;
+		  hc = 0;
+		  cerr << "Ruler-reload necessary" << endl;
+		}
+	}
+#endif
+      
+      for (i = 1; i <= tempnewpoints.Size(); i++)
+	lpoints.Append (tempnewpoints.Get(i));
+      for (i = 1; i <= tempnewfaces.Size(); i++)
+	if (tempnewfaces.Get(i).PNum(1))
+	  lfaces.Append (tempnewfaces.Get(i));
+      for (i = 1; i <= tempdelfaces.Size(); i++)
+	delfaces.Append (tempdelfaces.Get(i));
+      for (i = 1; i <= tempelements.Size(); i++)
+	elements.Append (tempelements.Get(i));
+    }
+  
+  retminerr = minerr;
+  return found;
+}
+ 
diff -ruN ug-orig/gm/gg3/netgen/meshing/ruler3.hh ug-patched/gm/gg3/netgen/meshing/ruler3.hh
--- ug-orig/gm/gg3/netgen/meshing/ruler3.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/meshing/ruler3.hh	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,299 @@
+#ifndef FILE_RULER3
+#define FILE_RULER3
+
+#include <iostream.h>
+
+class vnetrule
+  {
+  public:
+//  struct twoint { int i1, i2; };
+//  struct threeint { int i1, i2, i3; };
+//  struct fourint { int i1, i2, i3, i4; };
+  
+  private:
+  
+  int quality;
+  char * name;
+  ARRAY<Point3d> points;
+  ARRAY<Element> faces;
+  ARRAY<twoint> edges;
+
+  ARRAY<Point3d> freezone;
+  ARRAY<ARRAY<threeint>*> freefaces;
+  ARRAY<ARRAY<int>*> freesets;
+  ARRAY<Point3d> transfreezone;
+
+  ARRAY<int> delfaces;
+  ARRAY<Element> elements;
+  ARRAY<double> tolerances, linetolerances;
+//  SparseMatrix oldutonewu, oldutofreezone;
+  ARRAY<DenseMatrix*> freefaceinequ;
+  ARRAY<fourint> orientations;
+  ARRAY<char> flags;
+  ARRAY<int> fnearness;
+
+  int noldp, noldf;
+  float fzminx, fzmaxx, fzminy, fzmaxy, fzminz, fzmaxz;
+
+
+  public:
+
+  vnetrule ();
+
+  int GetNP () const { return points.Size(); }
+  int GetNF () const { return faces.Size(); }
+  int GetNE () const { return elements.Size(); }
+  int GetNO () const { return orientations.Size(); }
+  int GetNEd () const { return edges.Size(); }
+  int GetNOldP () const { return noldp; }
+  int GetNOldF () const { return noldf; }
+  int GetNDelF () const { return delfaces.Size(); }
+  int GetQuality () const { return quality; }
+  int GetFNearness (int fi) const { return fnearness.Get(fi); }
+
+
+  const Point3d & GetPoint (int i) const { return points.Get(i); }
+  const Element & GetFace (int i) const { return faces.Get(i); }
+  const Element & GetElement (int i) const { return elements.Get(i); }
+  const twoint & GetEdge (int i) const { return edges.Get(i); }
+  int GetDelFace (int i) const { return delfaces.Get(i); }
+  int IsDelFace (int fn) const;
+
+  float CalcPointDist (int pi, const Point3d & p) const;
+
+  void SetFreeZoneTransformation (const Vector & u);
+  int IsInFreeZone (const Point3d & p) const;
+  int IsTriangleInFreeZone (const Point3d & p1, const Point3d & p2,
+                            const Point3d & p3);
+  int IsTriangleInFreeSet (const Point3d & p1, const Point3d & p2,
+                           const Point3d & p3, int fs);
+  int ConvexFreeZone () const;
+  const Point3d & GetTransFreeZone (int i) { return transfreezone.Get(i); }
+
+  int GetNP (int fn) const
+         { return faces.Get(fn).NP(); }
+  int GetPointNr (int fn, int endp) const
+         { return faces.Get(fn).PNum(endp); }
+  int GetPointNrMod (int fn, int endp) const
+         { return faces.Get(fn).PNumMod(endp); }
+  const fourint & GetOrientation (int i) { return orientations.Get(i); }
+
+  int TestFlag (char flag) const;
+
+//  const SparseMatrix & GetOldUToNewU () const { return oldutonewu; }
+//  const SparseMatrix & GetOldUToFreeZone () const { return oldutofreezone; }
+  const char * Name () const { return name; }
+  void LoadRule (istream & ist);
+
+  const ARRAY<Point3d> & GetTransFreeZone () { return transfreezone; }
+  int TestOk () const;
+
+  friend void TestRules ();
+  friend void Plot3DRule (const ROT3D & r, char key);
+  };
+
+class vnetrule_new
+{
+private:
+  /// rule is applicable for quality classes above this value
+  int quality;
+  /// name of rule
+  char * name;
+  /// point coordinates in reference position
+  ARRAY<Point3d> points;
+  /// old and new faces in reference numbering
+  ARRAY<Element> faces;
+  /// additional edges of rule
+  ARRAY<twoint> edges;
+
+  /// points of freezone in reference coordinates
+  ARRAY<Point3d> freezone;
+  /// points of freezone in reference coordinates in tolcalss to infty
+  ARRAY<Point3d> freezonelimit;
+  /// faces of each convex part of freezone
+  ARRAY<ARRAY<threeint>*> freefaces;
+  /// set of points of each convex part of freezone
+  ARRAY<ARRAY<int>*> freesets;
+  /// points of transformed freezone
+  ARRAY<Point3d> transfreezone;
+  /// edges of each convex part of freezone
+  ARRAY<ARRAY<twoint>*> freeedges;
+
+  /// face numbers to be deleted
+  ARRAY<int> delfaces;
+  /// elements to be generated
+  ARRAY<Element> elements;
+  /// tolerances for points and faces (used ??)
+  ARRAY<double> tolerances, linetolerances;
+  /// transformation matrix 
+  DenseMatrix oldutonewu;
+  /// transformation matrix: deviation old point to dev. freezone
+  BaseMatrix * oldutofreezone;
+  /** transformation matrix: deviation old point to dev. freezone, 
+    quality class to infinity */
+  BaseMatrix * oldutofreezonelimit;
+  /**
+    a point is outside of convex part of freezone, 
+    iff mat * (point, 1) >= 0 for each component (correct ?)
+    */
+  ARRAY<DenseMatrix*> freefaceinequ;
+  /// 
+  ARRAY<fourint> orientations;
+  /**
+    flags specified in rule-description file:
+    t .. test rule
+    */
+  ARRAY<char> flags;
+
+  /**
+    topological distance of face to base element
+    non-connected: > 100  (??) 
+    */
+  ARRAY<int> fnearness;
+  
+  /// number of old points in rule
+  int noldp;
+  /// number of new poitns in rule
+  int noldf;
+  /// box containing free-zone
+public:  
+  double fzminx, fzmaxx, fzminy, fzmaxy, fzminz, fzmaxz;
+
+
+public:
+  
+  ///
+  vnetrule_new ();
+  ///
+  int GetNP () const { return points.Size(); }
+  ///
+  int GetNF () const { return faces.Size(); }
+  ///
+  int GetNE () const { return elements.Size(); }
+  ///
+  int GetNO () const { return orientations.Size(); }
+  ///
+  int GetNEd () const { return edges.Size(); }
+  ///
+  int GetNOldP () const { return noldp; }
+  ///
+  int GetNOldF () const { return noldf; }
+  ///
+  int GetNDelF () const { return delfaces.Size(); }
+  ///
+  int GetQuality () const { return quality; }
+  ///
+  int GetFNearness (int fi) const { return fnearness.Get(fi); }
+
+
+  ///
+  const Point3d & GetPoint (int i) const { return points.Get(i); }
+  ///
+  const Element & GetFace (int i) const { return faces.Get(i); }
+  ///
+  const Element & GetElement (int i) const { return elements.Get(i); }
+  ///
+  const twoint & GetEdge (int i) const { return edges.Get(i); }
+  ///
+  int GetDelFace (int i) const { return delfaces.Get(i); }
+  ///
+  int IsDelFace (int fn) const;
+  
+  ///
+  float CalcPointDist (int pi, const Point3d & p) const;
+  ///
+  double PointDistFactor (int pi) const
+    {
+      return tolerances.Get(pi);
+    }
+  ///
+  void SetFreeZoneTransformation (const Vector & devp, 
+				  int tolclass);
+  ///
+  int IsInFreeZone (const Point3d & p) const;
+  /**
+    0 not in free-zone
+    1 in free-zone
+    -1 maybe 
+   */
+  int IsTriangleInFreeZone (const Point3d & p1, const Point3d & p2,
+                            const Point3d & p3);
+  ///
+  int IsTriangleInFreeSet (const Point3d & p1, const Point3d & p2,
+                           const Point3d & p3, int fs);
+  ///
+  int ConvexFreeZone () const;
+  
+  /// if t1 and t2 are neighbourtriangles, NTP returns the opposite Point of t1 in t2
+  int NeighbourTrianglePoint (const threeint & t1, const threeint & t2) const;
+  ///
+  const Point3d & GetTransFreeZone (int i) { return transfreezone.Get(i); }
+
+  ///
+  int GetNP (int /* fn */) const
+         { return 3; }
+  ///
+  int GetPointNr (int fn, int endp) const
+         { return faces.Get(fn).PNum(endp); }
+  ///
+  int GetPointNrMod (int fn, int endp) const
+         { return faces.Get(fn).PNumMod(endp); }
+  ///
+  const fourint & GetOrientation (int i) { return orientations.Get(i); }
+
+  ///
+  int TestFlag (char flag) const;
+
+  ///
+  const DenseMatrix & GetOldUToNewU () const { return oldutonewu; }
+  //
+  //  const DenseMatrix & GetOldUToFreeZone () const { return oldutofreezone; }
+  //
+  //  const DenseMatrix & GetOldUToFreeZoneLimit () const 
+  //    { return oldutofreezonelimit; }
+  ///
+  const char * Name () const { return name; }
+  ///
+  void LoadRule (istream & ist);
+
+  ///
+  const ARRAY<Point3d> & GetTransFreeZone () { return transfreezone; }
+  ///
+  int TestOk () const;
+
+  ///
+  friend void TestRules ();
+  ///
+  friend void Plot3DRule (const ROT3D & r, char key);
+};
+
+
+
+extern int ApplyVRules_new
+(
+ const ARRAY<vnetrule_new*> & rules, double tolfak,
+ ARRAY<Point3d> & lpoints,     // in: local points, out: old+new local points
+ ARRAY<Element> & lfaces,   // in: local faces, out: old+new local faces
+ INDEX lfacesplit,	       // for local faces in outer radius
+ ARRAY<Element> & elements,    // out: new elements
+ ARRAY<INDEX> & delfaces,      // out: face indices of faces to delete
+ int tolerance,                // quality class: 1 best 
+ int rotind1,                  // how to rotate base element
+ float & retminerr,             // element error 
+ ARRAY<char*> & problems
+ );
+
+extern int ApplyVRules (const ARRAY<vnetrule*> & rules, double tolfak,
+                 ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+                 ARRAY<Element> & elements,
+                 ARRAY<INDEX> & delfaces, int tolerance, int rotind1,
+                 float & retminerr, ARRAY<char*> & problems);
+
+int Generate_Prism (ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+					ARRAY<Element> & elements,
+					ARRAY<INDEX> & delfaces, ARRAY<int> & prism_flags);
+
+int Generate_Pyramid (	ARRAY<Point3d> & lpoints, ARRAY<Element> & lfaces,
+						ARRAY<Element> & elements,
+						ARRAY<INDEX> & delfaces, ARRAY<int> & prism_flags);
+#endif
diff -ruN ug-orig/gm/gg3/netgen/opti/bfgs.cc ug-patched/gm/gg3/netgen/opti/bfgs.cc
--- ug-orig/gm/gg3/netgen/opti/bfgs.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/opti/bfgs.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,241 @@
+/***************************************************************************/
+/*                                                                         */
+/* Vorlesung Optimierung I, Gfrerer, WS94/95                               */
+/* BFGS-Verfahren zur Lösung freier nichtlinearer Optimierungsprobleme     */
+/*                                                                         */
+/* Programmautor:  Joachim Schöberl                                        */
+/* Matrikelnummer: 9155284                                                 */
+/*                                                                         */
+/***************************************************************************/
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <values.h>       // MINDOUBLE, MAXDOUBLE
+
+#include <myadt.hh>  // min, max, sqr
+
+#include <linalg/linalg.hh>
+#include <opti/opti.hh>
+
+void MultLDLt (const DenseMatrix & l, const Vector & d, const Vector & g, Vector & p)
+  {
+  int i, j, n;
+  double val;
+
+  n = l.Height();
+  p = g;
+  for (i = 1; i <= n; i++)
+    {
+    val = 0;
+    for (j = i; j <= n; j++)
+      val += p.Get(j) * l.Get(j, i);
+    p.Set(i, val);
+    }
+  for (i = 1; i <= n; i++)
+    p.Elem(i) *= d.Get(i);
+
+  for (i = n; i >= 1; i--)
+    {
+    val = 0;
+    for (j = 1; j <= i; j++)
+      val += p.Get(j) * l.Get(i, j);
+    p.Set(i, val);
+    }
+  }
+
+void SolveLDLt (const DenseMatrix & l, const Vector & d, const Vector & g, Vector & p)
+  {
+  int i, j, n;
+  double val;
+
+  n = l.Height();
+  p = g;
+
+  for (i = 1; i <= n; i++)
+    {
+    val = 0;
+    for (j = 1; j < i; j++)
+      val += p.Get(j) * l.Get(i, j);
+    p.Elem(i) -= val;
+    }
+  for (i = 1; i <= n; i++)
+    p.Elem(i) /= d.Get(i);
+
+  for (i = n; i >= 1; i--)
+    {
+    val = 0;
+    for (j = i+1; j <= n; j++)
+      val += p.Get(j) * l.Get(j, i);
+    p.Elem(i) -= val;
+    }
+  }
+
+int LDLtUpdate (DenseMatrix & l, Vector & d, double a, const Vector & u)
+  {
+  // Bemerkung: Es wird a aus R erlaubt
+  // Rueckgabewert: 0 .. D bleibt positiv definit
+  //               1 .. sonst
+
+  int i, j, n;
+
+  n = l.Height();
+
+  Vector v(n);
+  double t, told, xi;
+
+  told = 1;
+  v = u;
+
+  for (j = 1; j <= n; j++)
+    {
+    t = told + a * sqr (v.Elem(j)) / d.Get(j);
+
+    if (t <= 0) return 1;
+
+    xi = a * v.Elem(j) / (d.Get(j) * t);
+
+    d.Elem(j) *= t / told;
+
+    for (i = j + 1; i <= n; i++)
+      {
+      v.Elem(i) -= v.Elem(j) * l.Elem(i, j);
+      l.Elem(i, j) += xi * v.Elem(i);
+      }
+
+    told = t;
+    }
+
+  return 0;
+  }
+
+
+void BFGS (
+  Vector & x,         // i: Startwert
+                      // o: Loesung, falls IFAIL = 0
+  const MinFunction & fun
+  )
+
+  {
+
+  int i, j, n = x.Length();
+  long it;
+  char a1crit, a3acrit;
+
+
+  Vector d(n), g(n), p(n), temp(n), bs(n), xneu(n), y(n), s(n);
+  DenseMatrix l(n);
+
+  double /* normg, */ alphahat, hd, fold;
+  double a1, a2;
+  const double mu1 = 0.1, sigma = 0.1, xi1 = 1, xi2 = 10;
+  const double tau = 0.1, tau1 = 0.1, tau2 = 0.6;
+
+  Vector typx(x.Length());      // i: typische Groessenordnung der Komponenten
+  double f, typf;               // i: typische Groessenordnung der Loesung
+  double fmin = -1e5;           // i: untere Schranke fuer Funktionswert
+  double eps = 1e-8;            // i: Abbruchschranke fuer relativen Gradienten
+  double tauf = 0.1;            // i: Abbruchschranke fuer die relative Aenderung der
+                                //    Funktionswerte
+  long itmax = 100;             // i: Maximale Iterationszahl
+  int ifail;                    // o:  0 .. Erfolg
+                                //    -1 .. Unterschreitung von fmin
+                                //     1 .. kein Erfolg bei Liniensuche
+                                //     2 .. Überschreitung von itmax
+
+  typx = 1;
+  typf = 1;
+
+
+  l = 0;
+  for (i = 1; i <= n; i++)
+    l.Elem(i, i) = 1;
+
+  f = fun.FuncGrad (x, g);
+
+  it = 0;
+  do
+    {
+    // Restart
+
+    if (it % (5 * n) == 0)
+      {
+      for (i = 1; i <= n; i++)
+        d.Elem(i) = 1;
+      for (i = 2; i <= n; i++)
+        for (j = 1; j < i; j++)
+          l.Elem(i, j) = 0;
+      }
+
+    it++;
+    if (it > itmax)
+      {
+      ifail = 2;
+      break;
+      }
+
+
+    // Solve with factorized B
+
+    SolveLDLt (l, d, g, p);
+
+
+    p *= -1;
+    y = g;
+
+    fold = f;
+
+    // line search
+
+    alphahat = 1;
+    lines (x, xneu, p, f, g, fun, alphahat, fmin,
+           mu1, sigma, xi1, xi2, tau, tau1, tau2, ifail);
+
+    if (ifail != 0) break;
+
+    s = xneu - x;
+    y *= -1;
+    y += g;
+
+    x = xneu;
+
+    // BFGS Update
+
+    MultLDLt (l, d, s, bs);
+
+    a1 = y * s;
+    a2 = s * bs;
+
+    if (a1 > 0 && a2 > 0)
+      {
+      if (LDLtUpdate (l, d, 1 / a1, y) != 0)
+        {
+        ifail = 1;
+        break;
+        }
+
+      if (LDLtUpdate (l, d, -1 / a2, bs) != 0)
+        {
+        ifail = 1;
+        break;
+        }
+      }
+
+    // Calculate stop conditions
+
+    hd = eps * ng_max (typf, fabs (f));
+    a1crit = 1;
+    for (i = 1; i <= n; i++)
+      if ( fabs (g.Elem(i)) * ng_max (typx.Elem(i), fabs (x.Elem(i))) > hd)
+        a1crit = 0;
+
+
+    a3acrit = (fold - f <= tauf * ng_max (typf, fabs (f)));
+
+    }
+  while (!a1crit || !a3acrit);
+
+  }
+
diff -ruN ug-orig/gm/gg3/netgen/opti/linsearch.cc ug-patched/gm/gg3/netgen/opti/linsearch.cc
--- ug-orig/gm/gg3/netgen/opti/linsearch.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/opti/linsearch.cc	2002-10-08 15:31:12.000000000 +0200
@@ -0,0 +1,205 @@
+/***************************************************************************/
+/*                                                                         */
+/* Problem:        Liniensuche                                             */
+/*                                                                         */
+/* Programmautor:  Joachim Schöberl                                        */
+/* Matrikelnummer: 9155284                                                 */
+/*                                                                         */
+/* Algorithmus nach:                                                       */
+/*                                                                         */
+/*   Optimierung I, Gfrerer, WS94/95                                       */
+/*   Algorithmus 2.1: Liniensuche Problem (ii)                             */
+/*                                                                         */
+/***************************************************************************/
+
+
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <values.h>       // MINDOUBLE, MAXDOUBLE
+
+#include <myadt.hh>  // min, max, sqr
+
+#include <linalg/linalg.hh>
+#include <opti/opti.hh>
+
+const double eps0 = 1E-15;
+
+// Liniensuche
+
+
+double MinFunction :: Func (const Vector & /* x */) const
+  {
+  cerr << "Func of MinFunction called" << endl;
+  return 0;
+  }
+
+void MinFunction :: Grad (const Vector & /* x */, Vector & /* g */) const
+  {
+  cerr << "Grad of MinFunction called" << endl;
+  }
+  
+double MinFunction :: FuncGrad (const Vector & /* x */, Vector & /* g */) const
+  {
+  cerr << "Grad of MinFunction called" << endl;
+  return 0;
+  }
+
+
+void lines (
+  Vector & x,         // i: Ausgangspunkt der Liniensuche
+  Vector & xneu,      // o: Loesung der Liniensuche bei Erfolg
+  Vector & p,         // i: Suchrichtung
+  double & f,         // i: Funktionswert an der Stelle x
+                      // o: Funktionswert an der Stelle xneu, falls ifail = 0
+  Vector & g,         // i: Gradient an der Stelle x
+                      // o: Gradient an der Stelle xneu, falls ifail = 0
+  const MinFunction & fun,  // function to minimize
+//  double (*fun) (const Vector & x, Vector & g),
+  double & alphahat,  // i: Startwert für alpha_hat
+                      // o: Loesung falls ifail = 0
+  double fmin,        // i: untere Schranke für f
+  double mu1,         // i: Parameter mu_1 aus Alg.2.1
+  double sigma,       // i: Parameter sigma aus Alg.2.1
+  double xi1,         // i: Parameter xi_1 aus Alg.2.1
+  double xi2,         // i: Parameter xi_1 aus Alg.2.1
+  double tau,         // i: Parameter tau aus Alg.2.1
+  double tau1,        // i: Parameter tau_1 aus Alg.2.1
+  double tau2,        // i: Parameter tau_2 aus Alg.2.1
+  int & ifail)        // o:  0 bei erfolgreicher Liniensuche
+                      //    -1 bei Abbruch wegen Unterschreiten von fmin
+                      //     1 bei Abbruch, aus sonstigen Gründen
+
+  {
+  double phi0, phi0prime, phi1, phi1prime, phihatprime;
+  double alpha1, alpha2, alphaincr, c;
+  char flag = 1;
+  long it;
+
+  alpha1 = 0;
+  alpha2 = 1e50;
+  phi0 = phi1 = f;
+
+  phi0prime = g * p;
+
+  if (phi0prime > 0)
+    {
+    ifail = 1;
+    return;
+    }
+
+  phi1prime = phi0prime;
+
+  it = 100000l;
+
+  while (it-- >= 0)
+    {
+    xneu.Set (1, x, alphahat, p);
+
+    f = fun.FuncGrad (xneu, g);
+
+    if (f < fmin)
+      {
+      ifail = -1;
+      break;
+      }
+
+    if (alpha2 - alpha1 < eps0 * alpha2)
+      {
+      ifail = 0;
+      break;
+      }
+
+    if (f - phi0 > mu1 * alphahat * phi1prime + eps0 * fabs (phi0))
+
+      {
+      flag = 0;
+      alpha2 = alphahat;
+
+      c = (f - phi1 - phi1prime * (alphahat-alpha1)) / sqr (alphahat-alpha1);
+
+      alphahat = alpha1 - 0.5 * phi1prime / c;
+
+      if (alphahat > alpha2)
+        alphahat = alpha1 + 1/(4*c) * ( (sigma+mu1) * phi0prime - 2*phi1prime
+                   + sqrt (sqr(phi1prime - mu1 * phi0prime) -
+                           4 * (phi1 - phi0 - mu1 * alpha1 * phi0prime) * c));
+
+      alphahat = ng_max (alphahat, alpha1 + tau * (alpha2 - alpha1));
+      alphahat = ng_min (alphahat, alpha2 - tau * (alpha2 - alpha1));
+      }
+
+    else
+
+      {
+//      dfunk (xneu, f, g, funk);
+      f = fun.FuncGrad (xneu, g);
+
+      phihatprime = g * p;
+
+      if (phihatprime < sigma * phi0prime * (1 + eps0))
+
+        {
+        if (phi1prime < phihatprime)   // Approximationsfunktion ist konvex
+
+          alphaincr = (alphahat - alpha1) * phihatprime /
+                       (phi1prime - phihatprime);
+
+        else
+          alphaincr = MAXDOUBLE;
+
+        if (flag)
+          {
+          alphaincr = ng_max (alphaincr, xi1 * (alphahat-alpha1));
+          alphaincr = ng_min (alphaincr, xi2 * (alphahat-alpha1));
+          }
+        else
+          {
+          alphaincr = ng_max (alphaincr, tau1 * (alpha2 - alphahat));
+          alphaincr = ng_min (alphaincr, tau2 * (alpha2 - alphahat));
+          }
+
+        alpha1 = alphahat;
+        alphahat += alphaincr;
+        phi1 = f;
+        phi1prime = phihatprime;
+        }
+
+      else
+
+        {
+        ifail = 0;     // Erfolg !!
+        break;
+        }
+      }
+
+    }
+
+  if (it < 0)
+    ifail = 1;
+  }
+
+
+
+void SteepestDescent (Vector & x, const MinFunction & fun)
+  {
+  int it, n = x.Length();
+  Vector xnew(n), p(n), g(n), g2(n);
+  double val, alphahat;
+  int fail;
+
+  val = fun.FuncGrad(x, g);
+
+  alphahat = 1;
+  for (it = 0; it < 10; it++)
+    {
+    p = -g;
+    lines (x, xnew, p, val, g, fun, alphahat, -1e5,
+           0.1, 0.1, 1, 10, 0.1, 0.1, 0.6, fail);
+
+    x = xnew;
+    }
+  }
diff -ruN ug-orig/gm/gg3/netgen/opti/linsuch.cc ug-patched/gm/gg3/netgen/opti/linsuch.cc
--- ug-orig/gm/gg3/netgen/opti/linsuch.cc	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/opti/linsuch.cc	1996-03-29 18:25:55.000000000 +0100
@@ -0,0 +1,208 @@
+/************************************************************************/
+/*                                                                      */
+/* This file is a part of NETGEN                                        */
+/*                                                                      */
+/* File:   linsuch.cc                                                   */
+/* Author: Joachim Schoeberl                                            */
+/*                                                                      */
+/************************************************************************/
+
+
+
+/***************************************************************************/
+/*                                                                         */
+/* Algorithmus nach:                                                       */
+/*                                                                         */
+/*   Optimierung I, Gfrerer, JKU-Linz, WS94/95                             */
+/*   Algorithmus 2.1: Liniensuche Problem (ii)                             */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <iomanip.h>
+#include <math.h>
+#include <values.h>       // MINDOUBLE, MAXDOUBLE
+
+#include <template.hh>  // min, max, sqr
+#include <array.hh>
+#include <linalg/linalg.hh>
+
+const double eps0 = 1E-15;
+
+extern ofstream testout;
+
+// Liniensuche
+
+void lines (
+  VECTOR & x,         // i: Ausgangspunkt der Liniensuche
+  VECTOR & xneu,      // o: Loesung der Liniensuche bei Erfolg
+  VECTOR & p,         // i: Suchrichtung
+  double & f,         // i: Funktionswert an der Stelle x
+                      // o: Funktionswert an der Stelle xneu, falls ifail = 0
+  VECTOR & g,         // i: Gradient an der Stelle x
+                      // o: Gradient an der Stelle xneu, falls ifail = 0
+
+  double (*fun) (const VECTOR & x, VECTOR & g),
+  double & alphahat,  // i: Startwert für alpha_hat
+                      // o: Loesung falls ifail = 0
+  double fmin,        // i: untere Schranke für f
+  double mu1,         // i: Parameter mu_1 aus Alg.2.1
+  double sigma,       // i: Parameter sigma aus Alg.2.1
+  double xi1,         // i: Parameter xi_1 aus Alg.2.1
+  double xi2,         // i: Parameter xi_1 aus Alg.2.1
+  double tau,         // i: Parameter tau aus Alg.2.1
+  double tau1,        // i: Parameter tau_1 aus Alg.2.1
+  double tau2,        // i: Parameter tau_2 aus Alg.2.1
+  int & ifail)        // o:  0 bei erfolgreicher Liniensuche
+                      //    -1 bei Abbruch wegen Unterschreiten von fmin
+                      //     1 bei Abbruch, aus sonstigen Gründen
+
+  {
+  double phi0, phi0prime, phi1, phi1prime, phihatprime;
+  double alpha1, alpha2, alphaincr, c;
+  char flag = 1;
+  int i;
+  long it;
+  int n = x.Length();
+
+  alpha1 = 0;
+  alpha2 = 1e50;
+  phi0 = phi1 = f;
+
+  phi0prime = g * p;
+
+  if (phi0prime > 0)
+    {
+    ifail = 1;
+    return;
+    }
+
+  phi1prime = phi0prime;
+
+  it = 100000l;
+
+//  testout << "phi0prime = " << phi0prime << endl;
+
+  while (it-- >= 0)
+    {
+//    testout << "it = " << it << " f = " << f
+//            << " al1 = " << alpha1 << " al2 = " << alpha2
+//            << " f = " << f << endl;
+
+    xneu.Set (1, x, alphahat, p);
+
+//    for (i = 1; i <= n; i++)
+//      xneu.Elem(i) = x.Elem(i) + alphahat * p.Elem(i);
+
+//    f = funk(xneu);
+    f = fun (xneu, g);
+
+    if (f < fmin)
+      {
+      ifail = -1;
+      break;
+      }
+
+    if (alpha2 - alpha1 < eps0 * alpha2)
+      {
+      ifail = 0;
+      break;
+      }
+
+    if (f - phi0 > mu1 * alphahat * phi1prime + eps0 * fabs (phi0))
+
+      {
+      flag = 0;
+      alpha2 = alphahat;
+
+      c = (f - phi1 - phi1prime * (alphahat-alpha1)) / sqr (alphahat-alpha1);
+
+      alphahat = alpha1 - 0.5 * phi1prime / c;
+
+      if (alphahat > alpha2)
+        alphahat = alpha1 + 1/(4*c) * ( (sigma+mu1) * phi0prime - 2*phi1prime
+                   + sqrt (sqr(phi1prime - mu1 * phi0prime) -
+                           4 * (phi1 - phi0 - mu1 * alpha1 * phi0prime) * c));
+
+      alphahat = max (alphahat, alpha1 + tau * (alpha2 - alpha1));
+      alphahat = min (alphahat, alpha2 - tau * (alpha2 - alpha1));
+      }
+
+    else
+
+      {
+//      dfunk (xneu, f, g, funk);
+      f = fun (xneu, g);
+
+      phihatprime = g * p;
+
+      if (phihatprime < sigma * phi0prime * (1 + eps0))
+
+        {
+        if (phi1prime < phihatprime)   // Approximationsfunktion ist konvex
+
+          alphaincr = (alphahat - alpha1) * phihatprime /
+                       (phi1prime - phihatprime);
+
+        else
+          alphaincr = MAXDOUBLE;
+
+        if (flag)
+          {
+          alphaincr = max (alphaincr, xi1 * (alphahat-alpha1));
+          alphaincr = min (alphaincr, xi2 * (alphahat-alpha1));
+          }
+        else
+          {
+          alphaincr = max (alphaincr, tau1 * (alpha2 - alphahat));
+          alphaincr = min (alphaincr, tau2 * (alpha2 - alphahat));
+          }
+
+        alpha1 = alphahat;
+        alphahat += alphaincr;
+        phi1 = f;
+        phi1prime = phihatprime;
+        }
+
+      else
+
+        {
+        ifail = 0;     // Erfolg !!
+        break;
+        }
+      }
+
+    }
+
+  if (it < 0)
+    ifail = 1;
+  }
+
+
+
+void SteepestDescent (VECTOR & x, double (*f) (const VECTOR & x, VECTOR & g))
+  {
+  int it, n = x.Length();
+  VECTOR xnew(n), p(n), g(n), g2(n);
+  double val, v2, alphahat;
+  int fail;
+
+  val = f(x, g);
+
+  alphahat = 1;
+//  testout << "f = ";
+  for (it = 0; it < 10; it++)
+    {
+//    testout << val << " ";
+
+    p = -g;
+    lines (x, xnew, p, val, g, f, alphahat, -1e5,
+           0.1, 0.1, 1, 10, 0.1, 0.1, 0.6, fail);
+
+    x = xnew;
+    }
+//  testout << endl;
+  }
diff -ruN ug-orig/gm/gg3/netgen/opti/makefile ug-patched/gm/gg3/netgen/opti/makefile
--- ug-orig/gm/gg3/netgen/opti/makefile	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/opti/makefile	1996-10-01 19:44:06.000000000 +0200
@@ -0,0 +1,4 @@
+objects = bfgs.o linsearch.o
+include ../makefile.inc
+#
+#
diff -ruN ug-orig/gm/gg3/netgen/opti/opti.hh ug-patched/gm/gg3/netgen/opti/opti.hh
--- ug-orig/gm/gg3/netgen/opti/opti.hh	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/gm/gg3/netgen/opti/opti.hh	1996-10-01 19:57:09.000000000 +0200
@@ -0,0 +1,57 @@
+#ifndef FILE_OPTI
+#define FILE_OPTI
+
+/**************************************************************************/
+/* File:   opti.hh                                                        */
+/* Author: Joachim Schoeberl                                              */
+/* Date:   01. Jun. 95                                                    */
+/**************************************************************************/
+
+/* 
+  Optimisation functions
+*/
+
+
+class MinFunction 
+  {
+  public:
+  virtual double Func (const Vector & x) const;
+  virtual void Grad (const Vector & x, Vector & g) const;
+  virtual double FuncGrad (const Vector & x, Vector & g) const;
+  };
+  
+  
+extern void BFGS (Vector & x, const MinFunction & fun);
+void SteepestDescent (Vector & x, const MinFunction & fun);
+
+
+extern void lines (
+  Vector & x,         // i: Ausgangspunkt der Liniensuche
+  Vector & xneu,      // o: Loesung der Liniensuche bei Erfolg
+  Vector & p,         // i: Suchrichtung
+  double & f,         // i: Funktionswert an der Stelle x
+                      // o: Funktionswert an der Stelle xneu, falls ifail = 0
+  Vector & g,         // i: Gradient an der Stelle x
+                      // o: Gradient an der Stelle xneu, falls ifail = 0
+
+  const MinFunction & fun,  // function to minmize
+
+  double & alphahat,  // i: Startwert für alpha_hat
+                      // o: Loesung falls ifail = 0
+  double fmin,        // i: untere Schranke für f
+  double mu1,         // i: Parameter mu_1 aus Alg.2.1
+  double sigma,       // i: Parameter sigma aus Alg.2.1
+  double xi1,         // i: Parameter xi_1 aus Alg.2.1
+  double xi2,         // i: Parameter xi_1 aus Alg.2.1
+  double tau,         // i: Parameter tau aus Alg.2.1
+  double tau1,        // i: Parameter tau_1 aus Alg.2.1
+  double tau2,        // i: Parameter tau_2 aus Alg.2.1
+  int & ifail);        // o:  0 bei erfolgreicher Liniensuche
+                      //    -1 bei Abbruch wegen Unterschreiten von fmin
+                      //     1 bei Abbruch, aus sonstigen Gründen
+
+
+
+
+
+#endif
diff -ruN ug-orig/gm/gmcheck.c ug-patched/gm/gmcheck.c
--- ug-orig/gm/gmcheck.c	2006-07-12 14:55:48.000000000 +0200
+++ ug-patched/gm/gmcheck.c	2012-01-26 12:06:32.000000000 +0100
@@ -31,6 +31,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -111,7 +112,7 @@
 static DOUBLE hghost_overlap = 1.0;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/gmcheck.c,v 1.51 2006/07/12 12:55:48 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
@@ -508,19 +509,12 @@
 
 						if (MIDNODE(FatherEdge) != theNode)
 						{
-#ifndef EDGE_WITH_DDDHDR
-							UserWriteF(PFMT " midnode=" ID_FMTX 
-								" has edge father with wrong backptr=%x\n", 
-								me,ID_PRTX(theNode),MIDNODE(FatherEdge));
-							nerrors++;
-#else
 							UserWriteF(PFMT " midnode=" ID_FMTX 
 								" has edge  father=" ID_FMTX " with wrong backptr=%x\n", 
 								me,ID_PRTX(theNode),ID_PRTX(FatherEdge),MIDNODE(FatherEdge));
 /* TODO: this should be deleted */
 if (0) MIDNODE(FatherEdge) = theNode;
 else						nerrors++;
-#endif
 							/*nerrors++; temp. auskommentiert, um Reperaturwirkung wirklich nutzen zu koennen */
 						}
 					}
@@ -570,7 +564,7 @@
 
         /** \todo Commented out because it uses GetElemLink, which does not exist */
 #if 0
-#	if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#	if defined(__TWODIM__)
 	{
 		int elemlink,no_of_elem,No_Of_Elem;
 		NODE *n0,*n1;
@@ -702,7 +696,6 @@
 	return(nerrors);
 }
 
-#ifdef EDGE_WITH_DDDHDR
 int EdgeHasTMasterCopy (ELEMENT *e, int i)
 {
 	int nmaster,nborder,nall;
@@ -726,7 +719,6 @@
 
 	return(nall-1);
 }
-#endif
 
 static INT CheckElement (GRID *theGrid, ELEMENT *theElement, INT *SideError, INT *EdgeError,
 						 INT *NodeError, INT *ESonError, INT *NSonError, INT *errors)
@@ -944,7 +936,7 @@
 				if (OBJT(theElement) == IEOBJ)
 				#ifdef ModelP
 				if (EMASTER(theElement))
-				#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+				#if defined(__TWODIM__)
 				if (hghost_overlap!=0.0 || EdgeHasTMasterCopy(theElement,i)==0)
 				#endif
 				#endif
@@ -956,7 +948,7 @@
 				{
 				  #ifdef ModelP
 				  if (EMASTER(theElement))
-				  #if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+				  #if defined(__TWODIM__)
 					if (hghost_overlap!=0.0 || EdgeHasTMasterCopy(theElement,i)==0)
 				  #endif
 				  #endif
@@ -976,7 +968,7 @@
 				else if (ECLASS(theElement)!=YELLOW_CLASS)
 					#ifdef ModelP
 					if (EMASTER(theElement))
-				    #if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+				    #if defined(__TWODIM__)
 					if (hghost_overlap!=0.0 || EdgeHasTMasterCopy(theElement,i)==0)
 					#endif
 					#endif
@@ -1749,14 +1741,10 @@
 			{
 				errors++;
 				UserWriteF("edge" 
-					#ifdef EDGE_WITH_DDDHDR
 					ID_FMTX
-					#endif
 					" between " ID_FMTX " and " ID_FMTX 
 					" has no element, NO_OF_ELEM=%d \n",
-					#ifdef EDGE_WITH_DDDHDR
 					ID_PRTX(theEdge),
-					#endif
 					ID_PRTX(theNode),ID_PRTX(NBNODE(theLink)),
 					NO_OF_ELEM(theEdge));
 
diff -ruN ug-orig/gm/gm.h ug-patched/gm/gm.h
--- ug-orig/gm/gm.h	2008-02-01 13:57:04.000000000 +0100
+++ ug-patched/gm/gm.h	2012-01-26 12:06:32.000000000 +0100
@@ -34,7 +34,7 @@
 /******************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/gm.h,v 1.252 2008/02/01 12:57:04 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -340,6 +340,9 @@
      PRISM_ROTATE_RGHT = 11,
      PRISM_QUADSECT_HEXPRI0 = 14,
      PRISM_RED_HEX = 15,
+     PRISM_BISECT_0_1,  /* No explicit numbers.  Maybe they are not necessary? */
+     PRISM_BISECT_0_2,
+     PRISM_BISECT_0_3,
      
      HEX_BISECT_0_1 = 5,
      HEX_BISECT_0_2 = 6,
@@ -364,7 +367,7 @@
                     };
 
     /** \brief Values for node types (relative to the father element of the vertex) */
-    enum {CORNER_NODE,
+enum NodeType {CORNER_NODE,
           MID_NODE,
           SIDE_NODE,
           CENTER_NODE,
@@ -609,7 +612,7 @@
 
 #ifdef ModelP
     /** \todo Please doc me! */
-    DDD_HEADER ddd;
+    NS_DIM_PREFIX DDD_HEADER ddd;
 #endif
         
     /** \brief double linked list of vectors                */
@@ -618,6 +621,14 @@
     /** \brief ordering of unknowns                                 */
     UINT index;
 
+#ifdef FOR_DUNE
+    /** \brief A unique and persistent, but not necessarily consecutive index 
+        \todo This line is a hack.  It is used to implement face ids for Dune.
+        As soon as the face data structure is available the id should be stored
+        there.  Then this code can be removed again. */
+    INT id;
+#endif
+
     /** \brief used bitwise to skip unknowns                */
     UINT skip;
 
@@ -719,9 +730,6 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Vertex position                                              */
     DOUBLE x[DIM];
 
@@ -771,15 +779,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Vertex position */
     DOUBLE x[DIM];
 
     /** \brief Local coordinates in father element  */
     DOUBLE xi[DIM];
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per node */
@@ -837,9 +842,6 @@
     /** \brief Unique id used for load/store                */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per node */
@@ -847,6 +849,9 @@
     /** \brief An index hat is unique and consecutive per level.
         Controlled by DUNE */
     int levelIndex;
+
+    /** \brief Information if this node is on the leaf. */
+    bool isLeaf;
 #endif
 
 #ifdef ModelP
@@ -894,7 +899,7 @@
     struct node *nbnode;
 
     /** \brief ptr to neighboring elem                              */
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
     union element *elem;
 #endif
 
@@ -918,11 +923,13 @@
     /** \brief An index hat is unique and consecutive on the grid surface.
         Controlled by DUNE */
     int leafIndex;
+
+    /** \brief A unique and persistent, but not necessarily consecutive index */
+    INT id;
 #endif
 
-#ifdef EDGE_WITH_DDDHDR
+    /** Bookkeeping information for DDD */
     DDD_HEADER ddd;
-#endif
     
     /** \brief Pointer to mid node on next finer grid */
     struct node *midnode;
@@ -945,9 +952,6 @@
     /** \brief unique id used for load/store        */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief additional flags for elements        */
     UINT  flag;
 
@@ -994,7 +998,9 @@
 
 };
 
-/** \brief A triangle element in a 2d grid */
+/** \brief A triangle element in a 2d grid 
+    \implements generic_element
+*/
 struct triangle {
 
     /** \brief Object identification, various flags */
@@ -1003,15 +1009,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Additional flags for elements */
     UINT  flag;
 
     /** \brief Even more property bits */
     INT  property;
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per element */
@@ -1081,7 +1084,9 @@
     void *data;
 };
 
-/** \brief A quadrilateral element in a 2d grid */
+/** \brief A quadrilateral element in a 2d grid
+    \implements generic_element
+*/
 struct quadrilateral {
 
     /** \brief object identification, various flags */
@@ -1090,9 +1095,6 @@
     /** \brief unique id used for load/store                */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief additional flags for elements                */
     UINT flag;
 
@@ -1169,7 +1171,9 @@
     void *data;
 };
 
-/** \brief A tetrahedral element in a 3d grid */
+/** \brief A tetrahedral element in a 3d grid
+    \implements generic_element
+*/
 struct tetrahedron {
 
     /** \brief object identification, various flags */
@@ -1178,15 +1182,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Additional flags */
     UINT  flag;
 
     /** \brief Even more flags */
     INT  property;
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per element */
@@ -1262,7 +1263,9 @@
     void *data;
 };
 
-/** \brief A pyramid element in a 3d grid */
+/** \brief A pyramid element in a 3d grid
+    \implements generic_element
+*/
 struct pyramid {
 
     /** \brief object identification, various flags */
@@ -1271,15 +1274,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Additional flags for elements */
     UINT  flag;
 
     /** \brief Even more flags */
     INT  property;
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per element */
@@ -1353,7 +1353,9 @@
     void *data;
 };
 
-/** \brief A prism element in a 3d grid */
+/** \brief A prism element in a 3d grid
+    \implements generic_element
+*/
 struct prism {
 
     /** \brief object identification, various flags */
@@ -1362,15 +1364,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-
     /** \brief Additional flags for this element */
     UINT flag;
 
     /** \brief Even more flags */
     INT property;
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per element */
@@ -1445,7 +1444,9 @@
     void *data;
 };
 
-/** \brief A hexahedral element in a 3d grid */
+/** \brief A hexahedral element in a 3d grid
+    \implements generic_element
+*/
 struct hexahedron {
 
     /** \brief object identification, various flags */
@@ -1454,15 +1455,12 @@
     /** \brief Unique id used for load/store */
     INT id;
 
-	/** \brief extra field for miscellanea */
-	INT extra;
-	
     /** \brief Additional flags for this element */
     UINT  flag;
 
     /** \brief Even more flags */
     INT  property;
-
+        
 #ifdef FOR_DUNE
     /* When UG is used as part of the DUNE numerics system we need
        a few more indices per element */
@@ -1600,19 +1598,19 @@
     INT level;
 
     /** \brief Number of vertices */
-    INT nVert[NS_PREFIX MAX_PRIOS];
+    INT nVert[NS_DIM_PREFIX MAX_PRIOS];
 
     /** \brief Number of nodes on this grid level */
-    INT nNode[NS_PREFIX MAX_PRIOS];
+    INT nNode[NS_DIM_PREFIX MAX_PRIOS];
 
     /** \brief Number of elements on this grid level */
-    INT nElem[NS_PREFIX MAX_PRIOS];
+    INT nElem[NS_DIM_PREFIX MAX_PRIOS];
 
     /** \brief Number of edges on this grid level */
     INT nEdge;
 
     /** \brief Number of vectors on this grid level */
-    INT nVector[NS_PREFIX MAX_PRIOS];
+    INT nVector[NS_DIM_PREFIX MAX_PRIOS];
 
     /** \brief Number of connections on this grid level */
     INT nCon;
@@ -1624,14 +1622,14 @@
     DATA_STATUS data_status;        /* memory management for vectors|matrix */
                                     /* status for consistent and collect    */
         /* pointers */
-        union  element *elements[NS_PREFIX ELEMENT_LISTPARTS]; /* pointer to first element*/
-        union  element *lastelement[NS_PREFIX ELEMENT_LISTPARTS];/*pointer to last element*/
-        union  vertex *vertices[NS_PREFIX VERTEX_LISTPARTS];      /* pointer to first vertex      */
-        union  vertex *lastvertex[NS_PREFIX VERTEX_LISTPARTS];/* pointer to last vertex   */
-        struct node *firstNode[NS_PREFIX NODE_LISTPARTS]; /* pointer to first node                */
-        struct node *lastNode[NS_PREFIX NODE_LISTPARTS];  /* pointer to last node                 */
-        VECTOR *firstVector[NS_PREFIX VECTOR_LISTPARTS];  /* pointer to first vector              */
-        VECTOR *lastVector[NS_PREFIX VECTOR_LISTPARTS];   /* pointer to last vector               */
+        union  element *elements[NS_DIM_PREFIX ELEMENT_LISTPARTS]; /* pointer to first element*/
+        union  element *lastelement[NS_DIM_PREFIX ELEMENT_LISTPARTS];/*pointer to last element*/
+        union  vertex *vertices[NS_DIM_PREFIX VERTEX_LISTPARTS];      /* pointer to first vertex      */
+        union  vertex *lastvertex[NS_DIM_PREFIX VERTEX_LISTPARTS];/* pointer to last vertex   */
+        struct node *firstNode[NS_DIM_PREFIX NODE_LISTPARTS]; /* pointer to first node                */
+        struct node *lastNode[NS_DIM_PREFIX NODE_LISTPARTS];  /* pointer to last node                 */
+        VECTOR *firstVector[NS_DIM_PREFIX VECTOR_LISTPARTS];  /* pointer to first vector              */
+        VECTOR *lastVector[NS_DIM_PREFIX VECTOR_LISTPARTS];   /* pointer to last vector               */
     
     /** \brief Pointer to the first blockvector
 
@@ -1674,6 +1672,17 @@
     /** \brief count objects in that multigrid              */
     INT elemIdCounter;
 
+#ifdef FOR_DUNE
+    /** \brief count objects in that multigrid              */
+    INT edgeIdCounter;
+
+    /** \brief Count vector objects in that multigrid
+        \todo This line is a hack.  It is used to implement face ids for Dune.
+        As soon as the face data structure is available the id should be stored
+        there.  Then this code can be removed again. */
+    INT vectorIdCounter;
+#endif
+
     /** \brief depth of the element tree                    */
     INT topLevel;
 
@@ -2090,7 +2099,8 @@
 /* VOTYPE        |0 - 1 |*| | node-,edge-,side- or elemvector               */
 /* VCFLAG        |3     |*| | flag for general use                          */
 /* VCUSED        |4     |*| | flag for general use                          */
-/* VCOUNT        |5-6   |*| |                                               */
+/* VCOUNT        |5-6   |*| | The number of elements that reference         */
+/*                            the vector (if it is a side vector)           */
 /* VECTORSIDE|7 - 9 |*| | nb of side the side vect corr. to (in object elem)*/
 /* VCLASS        |11-12 |*| | class of v. (3: if corr. to red/green elem) */
 /*                                        (2: if corr. to first algebraic nb.) */
@@ -2591,7 +2601,7 @@
 
 #define OBJ_SHIFT                                       28
 #define OBJ_LEN                                         4
-#define OBJT(p)                                         CW_READ_STATIC(p,OBJ_,GENERAL_)
+#define OBJT(p)                                         (enum GM_OBJECTS)CW_READ_STATIC(p,OBJ_,GENERAL_)
 #define SETOBJT(p,n)                            CW_WRITE_STATIC(p,OBJ_,GENERAL_,n)
 #define OBJT_MAX                                        (POW2(OBJ_LEN)-1)
 
@@ -2620,8 +2630,6 @@
 #define CTRL(p)         (*((UINT *)(p)))
 #define ID(p)           (((INT *)(p))[1])
 
-#define EXTRA(p)        (((INT *)(p))[2])
-
 /****************************************************************************/
 /*                                                                                                                                                      */
 /* macros for vertices                                                                                                          */
@@ -2783,7 +2791,7 @@
 #define MYEDGE(p)                                       ((EDGE *)((p)-LOFFSET(p)))
 #define REVERSE(p)                                      ((p)+(1-LOFFSET(p)*2))
 
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
 #define LELEM(p)                                        ((p)->elem)
 #define SET_LELEM(p,e)                                  ((p)->elem = (e)) 
 #endif
@@ -2843,8 +2851,8 @@
 
 /* control word offsets */
 #define ELEMENT_OFFSET                                  0
-#define FLAG_OFFSET                                     3
-#define PROPERTY_OFFSET                                 4
+#define FLAG_OFFSET                                             2
+#define PROPERTY_OFFSET                                 3
 
 /* macros for control word */
 #define ECLASS_SHIFT                                    8
@@ -2995,7 +3003,7 @@
 /** \todo NbElem is declared in ugm.h, but never defined.
     We need a clean solution. */
 /*
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
 #define NBELEM(p,i)     NbElem((p),(i))
 #else
 */
@@ -3033,7 +3041,7 @@
 /** \todo Set_NbElem is declared in ugm.h, but never defined.
     We need a clean solution. */
 /*
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
 #define SET_NBELEM(p,i,q)       Set_NbElem((p),(i),(q))
 #else
 */
@@ -3041,7 +3049,7 @@
 /*
 #endif
 */
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
 #define VOID_NBELEM(p,i)        NBELEM(p,i)
 #else
 #define VOID_NBELEM(p,i)        ((p)->ge.refs[nb_offset[TAG(p)]+(i)])
@@ -3252,6 +3260,9 @@
 #define EDATA_DEF_IN_GRID(p)   (GFORMAT(p)->elementdata)
 #define NDATA_DEF_IN_GRID(p)   (GFORMAT(p)->nodedata)
 
+#define GRID_ATTR(g) ((unsigned char) (GLEVEL(g)+32))
+#define ATTR_TO_GLEVEL(i) (i-32)
+
 /****************************************************************************/
 /*                                                                          */
 /* macros for multigrids                                                    */
@@ -3457,10 +3468,10 @@
                             INT optimizedIE, INT insertMesh);
 MULTIGRID *OpenMGFromDataFile(MULTIGRID *theMG, INT number, char *type, 
                               char *DataFileName, NS_PREFIX MEM heapSize);
-MULTIGRID       *LoadMultiGrid  (char *MultigridName, char *name, char *type, 
-                                                         char *BndValProblem, char *format, 
-                                                         unsigned long heapSize,INT force,INT optimizedIE, INT autosave);
-INT             SaveMultiGrid (MULTIGRID *theMG, char *name, char *type, char *comment, INT autosave, INT rename);
+MULTIGRID       *LoadMultiGrid  (const char *MultigridName, const char *name, const char *type, 
+                                 const char *BndValProblem, const char *format, 
+                                 unsigned long heapSize,INT force,INT optimizedIE, INT autosave);
+INT             SaveMultiGrid (MULTIGRID *theMG, const char *name, const char *type, const char *comment, INT autosave, INT rename);
 INT         DisposeGrid             (GRID *theGrid);
 INT             DisposeMultiGrid                (MULTIGRID *theMG);
 INT         DisposeAMGLevels        (MULTIGRID *theMG);
@@ -3554,8 +3565,8 @@
                                                                          VECTOR **vec);
 
 /* searching */
-NODE            *FindNodeFromId                 (GRID *theGrid, INT id);
-NODE            *FindNodeFromPosition   (GRID *theGrid, DOUBLE *pos, DOUBLE *tol);
+NODE            *FindNodeFromId                 (const GRID *theGrid, INT id);
+NODE            *FindNodeFromPosition   (const GRID *theGrid, const DOUBLE *pos, const DOUBLE *tol);
 VECTOR          *FindVectorFromPosition (GRID *theGrid, DOUBLE *pos, DOUBLE *tol);
 VECTOR      *FindVectorFromIndex    (GRID *theGrid, INT index);
 ELEMENT         *FindElementFromId              (GRID *theGrid, INT id);
@@ -3568,36 +3579,36 @@
 
 /* list */
 void            ListMultiGridHeader     (const INT longformat);
-void            ListMultiGrid                   (MULTIGRID *theMG, const INT isCurrent, const INT longformat);
-INT         MultiGridStatus         (MULTIGRID *theMG, INT gridflag, INT greenflag, INT lbflag, INT verbose);
+void            ListMultiGrid           (const MULTIGRID *theMG, const INT isCurrent, const INT longformat);
+INT         MultiGridStatus             (const MULTIGRID *theMG, INT gridflag, INT greenflag, INT lbflag, INT verbose);
 void            ListGrids                               (const MULTIGRID *theMG);
-void            ListNode                                (MULTIGRID *theMG, NODE *theNode,               INT dataopt, INT bopt, INT nbopt, INT vopt);
+void            ListNode                                (const MULTIGRID *theMG, const NODE *theNode, INT dataopt, INT bopt, INT nbopt, INT vopt);
 void            ListNodeSelection               (MULTIGRID *theMG,                                              INT dataopt, INT bopt, INT nbopt, INT vopt);
 void            ListNodeRange                   (MULTIGRID *theMG, INT from, INT to,    INT idopt, INT dataopt, INT bopt, INT nbopt, INT vopt);
-void            ListElement                     (MULTIGRID *theMG, ELEMENT *theElement, INT dataopt, INT bopt, INT nbopt, INT vopt);
-void            ListElementSelection    (MULTIGRID *theMG,                                              INT dataopt, INT bopt, INT nbopt, INT vopt);
-void            ListElementRange                (MULTIGRID *theMG, INT from, INT to,    INT idopt, INT dataopt, INT bopt, INT nbopt, INT vopt, INT lopt);
-void            ListVector                              (MULTIGRID *theMG, VECTOR *theVector,   INT matrixopt, INT dataopt, INT modifiers);
-void            ListVectorSelection     (MULTIGRID *theMG,                                              INT matrixopt, INT dataopt, INT modifiers);
-void            ListVectorOfElementSelection(MULTIGRID *theMG,                                  INT matrixopt, INT dataopt, INT modifiers);
-void            ListVectorRange                 (MULTIGRID *theMG, INT fl, INT tl, INT from, INT to, INT idopt, INT matrixopt, INT dataopt, INT datatypes, INT modifiers);
+void            ListElement                     (const MULTIGRID *theMG, const ELEMENT *theElement, INT dataopt, INT bopt, INT nbopt, INT vopt);
+void            ListElementSelection    (const MULTIGRID *theMG, INT dataopt, INT bopt, INT nbopt, INT vopt);
+void            ListElementRange                (const MULTIGRID *theMG, INT from, INT to,    INT idopt, INT dataopt, INT bopt, INT nbopt, INT vopt, INT lopt);
+void            ListVector                      (const MULTIGRID *theMG, const VECTOR *theVector, INT matrixopt, INT dataopt, INT modifiers);
+void            ListVectorSelection     (const MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers);
+void            ListVectorOfElementSelection(const MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers);
+void            ListVectorRange                 (const MULTIGRID *theMG, INT fl, INT tl, INT from, INT to, INT idopt, INT matrixopt, INT dataopt, INT datatypes, INT modifiers);
 
 /* query */
-LINK            *GetLink                                (NODE *from, NODE *to);
-EDGE            *GetSonEdge                             (EDGE *theEdge);
-INT                     GetSonEdges                             (EDGE *theEdge, EDGE *SonEdges[MAX_SON_EDGES]);
-EDGE            *GetFatherEdge                  (EDGE *theEdge);
+LINK            *GetLink                                (const NODE *from, const NODE *to);
+EDGE            *GetSonEdge                             (const EDGE *theEdge);
+INT                     GetSonEdges                             (const EDGE *theEdge, EDGE *SonEdges[MAX_SON_EDGES]);
+EDGE            *GetFatherEdge                  (const EDGE *theEdge);
 #ifdef __THREEDIM__
 EDGE            *FatherEdge                             (NODE **SideNodes, INT ncorners, NODE **Nodes, EDGE *theEdge);
 #endif
-EDGE            *GetEdge                                (NODE *from, NODE *to);
+EDGE            *GetEdge                                (const NODE *from, const NODE *to);
 INT             GetSons                                 (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
 #ifdef ModelP
 INT             GetAllSons                              (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
 #endif
 INT             VectorPosition                  (const VECTOR *theVector, DOUBLE *position);
 INT             VectorInElement                 (ELEMENT *theElement, VECTOR *theVector);
-INT             MinMaxAngle                     (ELEMENT *theElement, DOUBLE *amin, DOUBLE *amax);
+INT             MinMaxAngle                     (const ELEMENT *theElement, DOUBLE *amin, DOUBLE *amax);
 
 /* check */
 #ifndef ModelP
@@ -3613,9 +3624,9 @@
 INT             AddNodeToSelection              (MULTIGRID *theMG, NODE *theNode);
 INT             IsNodeSelected                  (MULTIGRID *theMG, NODE *theNode);
 INT             AddElementToSelection   (MULTIGRID *theMG, ELEMENT *theElement);
-INT             IsElementSelected               (MULTIGRID *theMG, ELEMENT *theElement);
+INT             IsElementSelected               (const MULTIGRID *theMG, const ELEMENT *theElement);
 INT             AddVectorToSelection    (MULTIGRID *theMG, VECTOR *theVector);
-INT             IsVectorSelected                (MULTIGRID *theMG, VECTOR *theVector);
+INT             IsVectorSelected                (const MULTIGRID *theMG, const VECTOR *theVector);
 INT             RemoveNodeFromSelection (MULTIGRID *theMG, NODE *theNode);
 INT             RemoveElementFromSelection(MULTIGRID *theMG, ELEMENT *theElement);
 INT             RemoveVectorFromSelection(MULTIGRID *theMG, VECTOR *theVector);
@@ -3635,8 +3646,8 @@
 NS_PREFIX BLOCK_DESC      *GetMGUDBlockDescriptor (NS_PREFIX BLOCK_ID id);
 
 /* ordering of degrees of freedom */
-ALG_DEP         *CreateAlgebraicDependency              (char *name, DependencyProcPtr DependencyProc);
-FIND_CUT        *CreateFindCutProc                              (char *name, FindCutProcPtr FindCutProc);
+ALG_DEP         *CreateAlgebraicDependency              (const char *name, DependencyProcPtr DependencyProc);
+FIND_CUT        *CreateFindCutProc                              (const char *name, FindCutProcPtr FindCutProc);
 INT                     LexOrderVectorsInGrid                   (GRID *theGrid, INT mode, const INT *order, const INT *sign, INT which, INT SpecSkipVecs, INT AlsoOrderMatrices);
 INT             OrderVectors                                    (MULTIGRID *theMG, INT levels, INT mode, INT PutSkipFirst, INT SkipPat, const char *dependency, const char *dep_options, const char *findcut);
 INT                     ShellOrderVectors                               (GRID *theGrid, VECTOR *seed);
@@ -3675,10 +3686,6 @@
 /** \todo remove the following functions after the code will never need any debugging */
 char *PrintElementInfo (ELEMENT *theElement,INT full);
 
-/** \todo  This is a static function in standard UG.  Dune calls it at the
-   moment, so I made it nonstatic. */
-INT SetEdgeAndNodeSubdomainFromElements (GRID *theGrid);
-
 END_UGDIM_NAMESPACE
 
 #endif
diff -ruN ug-orig/gm/initgm.c ug-patched/gm/initgm.c
--- ug-orig/gm/initgm.c	2005-06-14 18:01:22.000000000 +0200
+++ ug-patched/gm/initgm.c	2008-12-19 11:02:55.000000000 +0100
@@ -27,6 +27,7 @@
 /****************************************************************************/
 
 /* ANSI-C includes */
+#include "config.h"
 #include <stdio.h>
 
 /* low module */
@@ -66,7 +67,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/initgm.c,v 1.23 2005/06/14 16:01:22 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*
diff -ruN ug-orig/gm/initgm.h ug-patched/gm/initgm.h
--- ug-orig/gm/initgm.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/initgm.h	2006-05-08 14:31:31.000000000 +0200
@@ -27,7 +27,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/initgm.h,v 1.10 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 #ifndef __INITGM__
diff -ruN ug-orig/gm/Makefile.am ug-patched/gm/Makefile.am
--- ug-orig/gm/Makefile.am	2004-10-15 16:22:28.000000000 +0200
+++ ug-patched/gm/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.2 2004/10/15 14:22:28 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 SUBDIRS = gg2 gg3
 
@@ -7,26 +7,20 @@
 # put this "template" into distribution-tarball as well
 EXTRA_DIST = dlmgr.t
 
-include_HEADERS = gm.h pargm.h evm.h shapes.h dlmgr.h algebra.h \
+gmincludedir = $(pkgincludedir)
+gminclude_HEADERS = gm.h pargm.h evm.h shapes.h dlmgr.h algebra.h \
   rm.h refine.h 
 
 
 
-EXTRALIBS =
 if BUILD2D
   LIB_2D = libug_gm2.la 
-if PARALLEL
-  EXTRALIBS += ../parallel/dddif/libdddif2.la
-endif
 else
   LIB_2D =
 endif
 
 if BUILD3D
   LIB_3D = libug_gm3.la
-if PARALLEL
-  EXTRALIBS += ../parallel/dddif/libdddif3.la
-endif
 else
   LIB_3D =
 endif
diff -ruN ug-orig/gm/mgheapmgr.c ug-patched/gm/mgheapmgr.c
--- ug-orig/gm/mgheapmgr.c	2004-07-21 11:18:36.000000000 +0200
+++ ug-patched/gm/mgheapmgr.c	2008-12-19 11:02:55.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "general.h"
 #include "compiler.h"
 #include "heaps.h"
@@ -71,7 +72,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/mgheapmgr.c,v 1.8 2004/07/21 09:18:36 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/gm/mgheapmgr.h ug-patched/gm/mgheapmgr.h
--- ug-orig/gm/mgheapmgr.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/mgheapmgr.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/mgheapmgr.h,v 1.6 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/mgio.c ug-patched/gm/mgio.c
--- ug-orig/gm/mgio.c	2006-06-02 18:13:11.000000000 +0200
+++ ug-patched/gm/mgio.c	2006-06-02 18:15:34.000000000 +0200
@@ -127,7 +127,7 @@
 
 #ifdef __MGIO_USE_IN_UG__
 
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/mgio.c,v 1.65 2006/06/02 16:13:11 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 #endif
 
diff -ruN ug-orig/gm/mgio.h ug-patched/gm/mgio.h
--- ug-orig/gm/mgio.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/mgio.h	2006-05-08 14:31:31.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/mgio.h,v 1.51 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 /* switch */
diff -ruN ug-orig/gm/pargm.h ug-patched/gm/pargm.h
--- ug-orig/gm/pargm.h	2007-12-07 19:45:03.000000000 +0100
+++ ug-patched/gm/pargm.h	2012-01-26 12:06:32.000000000 +0100
@@ -26,7 +26,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/pargm.h,v 1.48 2007/12/07 18:45:03 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -38,6 +38,7 @@
 #ifndef __PARGM_H__
 #define __PARGM_H__
 
+#include "ugtypes.h"
 
 #ifdef ModelP
 #include "ppif.h"
@@ -45,9 +46,8 @@
 #endif
 
 #include "namespace.h"
-#include "ppif_namespace.h"
 
-START_UG_NAMESPACE
+START_UGDIM_NAMESPACE
 
 /****************************************************************************/
 /*                                                                                                                                                      */
@@ -59,13 +59,6 @@
 /*                                                                                                                                                      */
 /****************************************************************************/
 
-#if defined(ModelP)
-/* switch on/off whether struct edge has DDD Header */
-/* former this was only for 3D the case using:      */
-/* #if defined(ModelP) && defined(__THREEDIM__)     */
-#define EDGE_WITH_DDDHDR
-#endif
-
 /* object priorties */
 enum Priorities
 {
@@ -149,24 +142,10 @@
 /* map pointer to structure onto a pointer to its DDD_HDR */
 #define PARHDR(obj)    (&((obj)->ddd))
 
-#ifndef EDGE_WITH_DDDHDR
-#define GETGID(x)	((OBJT(x)==IEOBJ || OBJT(x)==BEOBJ)? EGID((ELEMENT*)(x)):  \
-					 ((OBJT(x)==IVOBJ || OBJT(x)==BVOBJ)? VXGID((VERTEX *)(x)):\
-					 ((OBJT(x)==NDOBJ || OBJT(x)==VEOBJ)? GID((NODE *)(x)):    \
-					 -1)))
-#else
 #define GETGID(x)       (( OBJT(x)==IEOBJ || OBJT(x)==BEOBJ)? EGID((ELEMENT*)(x)): \
                                          ((OBJT(x)==IVOBJ || OBJT(x)==BVOBJ)? VXGID((VERTEX *)(x)):\
                                          ((OBJT(x)==NDOBJ || OBJT(x)==VEOBJ || OBJT(x)==EDOBJ)?    \
                                                 GID((NODE *)(x)) : -1)))
-#endif
-
-/*
-#define CDBG(x,y)       if (GETGID(x)==0x25000d) {y}
-*/
-#define CDBG(x,y)
-
-
 
 #else   /* not ModelP */
 
@@ -184,9 +163,7 @@
 enum {VECTOR_LISTPARTS = 1};
 enum {VERTEX_LISTPARTS = 1};
 
-/* define mapping from object priority to position in linked list */
-
-/* define mapping from object priority to position in linked list */
+/** \brief define mapping from object priority to position in linked list */
 #define PRIO2LISTPART(listtype,prio) 0
 
 /* define mapping from position in linked list to object priority */
@@ -195,14 +172,8 @@
 /* define mapping from position in linked list to object priority */
 #define PRIO2INDEX(prio)  0
 
-#define CDBG(x,y)
-
 #endif
 
-#define GRID_ATTR(g) ((unsigned char) (GLEVEL(g)+32))
-#define ATTR_TO_GLEVEL(i) (i-32)
-
-
 /*
         printing of IDs via printf()
 
@@ -223,14 +194,14 @@
 
 #ifdef ModelP
 
-#define ID_FMT      "%ld/%016llx"
-#define ID_FFMT     "%9ld/%016llx"
+#define ID_FMT      "%ld/%08x"
+#define ID_FFMT     "%9ld/%08x"
 #define ID_PRT(x)   ((long)ID(x)),GID(x)
-#define ID_FMTE     "%ld/%016llx/%d"
-#define ID_FFMTE    "%9ld/%016llx/%02d"
+#define ID_FMTE     "%ld/%08x/%d"
+#define ID_FFMTE    "%9ld/%08x/%02d"
 #define ID_PRTE(x)  ((long)ID(x)),GID(x),PRIO(x)
-#define ID_FMTX     "%d/%ld/%016llx/%d"
-#define ID_FFMTX    "%x/%9ld/%016llx/%02d"
+#define ID_FMTX     "%d/%ld/%08x/%d"
+#define ID_FFMTX    "%x/%9ld/%08x/%02d"
 #define ID_PRTX(x)  KeyForObject((KEY_OBJECT *)x),((long)ID(x)),GID(x),PRIO(x)
 
 #define VID_FMT     ID_FMT
@@ -264,27 +235,15 @@
 #define VINDEX_FFMTX   ID_FFMTX
 #define VINDEX_PRTX(x) KeyForObject((KEY_OBJECT *)x),((long)VINDEX(x)),GID(x),PRIO(x)
 
-#ifndef EDGE_WITH_DDDHDR
-#define EDID_FMT     "%016llx"
-#define EDID_FFMT    EDID_FMT
-#define EDID_PRT(x)  (x)
-#define EDID_FMTE    "%016llx"
-#define EDID_FFMTE   EDID_FMTE
-#define EDID_PRTE(x) (x)
-#define EDID_FMTX    "%016llx"
-#define EDID_FFMTX   EDID_FMTX
-#define EDID_PRTX(x) (x)
-#else 
-#define EDID_FMT     "%016llx"
+#define EDID_FMT     "%08x"
 #define EDID_FFMT    EDID_FMT
 #define EDID_PRT(x)  GID(x)
-#define EDID_FMTE    "%016llx/%d"
+#define EDID_FMTE    "%08x/%d"
 #define EDID_FFMTE   EDID_FMTE
 #define EDID_PRTE(x) GID(x),PRIO(x)
-#define EDID_FMTX    "%x/%016llx/%d"
+#define EDID_FMTX    "%x/%08x/%d"
 #define EDID_FFMTX   EDID_FMTX
 #define EDID_PRTX(x) x,GID(x),PRIO(x)
-#endif
 
 
 #define PFMT            "%3d:"
@@ -336,13 +295,13 @@
 #define VINDEX_FFMTX   ID_FFMTX
 #define VINDEX_PRTX(x) VINDEX_PRT(x)
 
-#define EDID_FMT     "%016llx"
+#define EDID_FMT     "%08x"
 #define EDID_FFMT    EDID_FMT
 #define EDID_PRT(x)  (x)
-#define EDID_FMTE    "%016llx"
+#define EDID_FMTE    "%08x"
 #define EDID_FFMTE   EDID_FMTE
 #define EDID_PRTE(x) (x)
-#define EDID_FMTX    "%016llx"
+#define EDID_FMTX    "%08x"
 #define EDID_FFMTX   EDID_FMTX
 #define EDID_PRTX(x) (x)
 
@@ -413,7 +372,6 @@
 #define UG_GlobalSumNDOUBLE(x,y)
 #define UG_GlobalMaxNDOUBLE(x,y)
 #define UG_GlobalMinNDOUBLE(x,y)
-#define UG_GlobalMaxGID(x) x
 #endif
 
 
@@ -443,9 +401,8 @@
 void   UG_GlobalSumNDOUBLE (INT n, DOUBLE *x);
 void   UG_GlobalMaxNDOUBLE (INT n, DOUBLE *x);
 void   UG_GlobalMinNDOUBLE (INT n, DOUBLE *x);
-DDD_GID UG_GlobalMaxGID    (DDD_GID x);
 #endif
 
-END_NAMESPACE
+END_UGDIM_NAMESPACE
 
 #endif /* __PARGM_H__ */
diff -ruN ug-orig/gm/refine.c ug-patched/gm/refine.c
--- ug-orig/gm/refine.c	2007-10-16 14:46:53.000000000 +0200
+++ ug-patched/gm/refine.c	2008-12-19 11:02:55.000000000 +0100
@@ -56,6 +56,7 @@
 /****************************************************************************/
 
 /* standard C library */
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -113,9 +114,9 @@
 /* defines in the following order                                           */
 /*                                                                          */
 /*    compile time constants defining static data size (i.e. arrays)        */
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
+/*    other constants                                                       */
+/*    macros                                                                */
+/*                                                                          */
 /****************************************************************************/
 
 /* undefine if overlap should be only updated where needed */
@@ -264,9 +265,8 @@
 		}
 /*@}*/
 
-/** \todo delete special debug */
+/** \todo delete special debug
 static ELEMENT *debugelem=NULL;
-/*
 #define PRINTELEMID(id)                                                      \
 		if (ID(theElement)==(id) && (id)!=10120)                             \
 		{                                                                    \
@@ -359,22 +359,47 @@
 /*																			*/
 /****************************************************************************/
 
-static int rFlag=GM_REFINE_TRULY_LOCAL; /* type of refine                   */
-static int hFlag=0;						/* refine with hanging nodes?		*/
-static int fifoFlag=0;					/* use fifo? 0=no 1=yes				*/
-static int first;						/* fifo loop counter 				*/
-static ELEMENT *fifo_first=NULL;		/* first element in fifo work list	*/
-static ELEMENT *fifo_last=NULL;			/* last element in fifo	work list	*/
-static ELEMENT *fifo_insertfirst=NULL;	/* first element in fifo insertlist */
-static ELEMENT *fifo_insertlast=NULL;	/* last element in fifo insertlist	*/
-static ELEMENT *firstElement=NULL;		/* first element to consider for    */
-										/* next loop						*/
-static INT No_Green_Update;				/* counter for green refinements	*/
-										/* need not to be updated			*/
-static INT Green_Marks;					/* green refined element counter	*/
-static INT refine_seq = 0;				/* 0/1: do/do not parallel part		*/
-static INT fifoloop = 0;				/* counter for FIFO loops			*/
-static INT total_adapted = 0;           /* count of adapted elements        */
+/** \brief type of refinement                   */
+static int rFlag=GM_REFINE_TRULY_LOCAL;
+
+/** \brief refine with hanging nodes?		*/
+static int hFlag=0;
+
+/** \brief use fifo? 0=no 1=yes				*/
+static int fifoFlag=0;
+
+/** \brief fifo loop counter 				*/
+static int first;
+
+/** \brief first element in fifo work list	*/
+static ELEMENT *fifo_first=NULL;
+
+/** \brief last element in fifo	work list	*/
+static ELEMENT *fifo_last=NULL;
+
+/** \brief first element in fifo insertlist */
+static ELEMENT *fifo_insertfirst=NULL;
+
+/** \brief last element in fifo insertlist	*/
+static ELEMENT *fifo_insertlast=NULL;
+
+/** \brief first element to consider for next loop   */
+static ELEMENT *firstElement=NULL;
+
+/** \brief Counter for green refinements doesn't need to be updated */
+static INT No_Green_Update;
+
+/** \brief green refined element counter	*/
+static INT Green_Marks;
+
+/** \brief 0/1: do/do not parallel part		*/
+static INT refine_seq = 0;
+
+/** \brief counter for FIFO loops			*/
+static INT fifoloop = 0;
+
+/** \brief count of adapted elements        */
+static INT total_adapted = 0;
 
 #ifdef STAT_OUT
 /* timing variables */
@@ -383,6 +408,7 @@
 static int algebra_timer;
 #endif
 
+#ifdef TET_RULESET
 /* determine number of edge from reduced (i.e. restricted to one side) edgepattern */
 /* if there are two edges marked for bisection, if not deliver -1. If the edge-    */
 /* is not reduced (i.e. marked edges lying on more than one side) deliver -2       */
@@ -399,11 +425,12 @@
 
 /* the indices of the edges of each side */
 static INT  CondensedEdgeOfSide[4] = {0x07,0x32,0x2C,0x19};
+#endif
 
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/refine.c,v 1.206 2007/10/16 12:46:53 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -411,8 +438,9 @@
 /*																			*/
 /****************************************************************************/
 
+#ifdef ModelP
 static void CheckConsistency (MULTIGRID *theMG, INT level ,INT debugstart, INT gmlevel, int *check);
-
+#endif
 
 /****************************************************************************/
 /** \brief Fill refineinfo structure
@@ -2798,13 +2826,16 @@
 		}
 			
 		if (flag) continue;
+
+		/* preserve regular refinement marks */
+		if (hFlag==0 && SonList[0]==NULL) continue;
 	
 		/* remove refinement */
 		SETMARK(theElement,NO_REFINEMENT);
 		SETMARKCLASS(theElement,NO_CLASS);
 		SETCOARSEN(theElement,1);
 	}
-	/** \todo delete special debug */ PRINTELEMID(-1);
+	/** \todo delete/ special debug */ PRINTELEMID(-1);
 #ifdef __PERIODIC_BOUNDARY__
 	#ifdef ModelP
 	PRINTDEBUG(gm,1,("\n" PFMT "exchange USED flag for restrict marks\n",me));
@@ -3154,7 +3185,8 @@
 		if (SONNODE(theNode)==NULL)
 		{
 			SONNODE(theNode) = CreateSonNode(theGrid,theNode);
-			if (SONNODE(theNode)==NULL) RETURN(GM_FATAL);
+			if (SONNODE(theNode)==NULL) 
+                            RETURN(GM_FATAL);
 			#ifdef IDENT_ONLY_NEW
 			SETNEW_NIDENT(SONNODE(theNode),1);
 			#endif
@@ -3217,7 +3249,8 @@
 			if (MidNodes[i] == NULL)
 			{
 				MidNodes[i] = CreateMidNode(theGrid,theElement,NULL,i);
-				if (MidNodes[i]==NULL) RETURN(GM_FATAL);
+				if (MidNodes[i]==NULL) 
+                                    RETURN(GM_FATAL);
 				#ifdef IDENT_ONLY_NEW
 				SETNEW_NIDENT(MidNodes[i],1);
 				#endif
@@ -3335,11 +3368,9 @@
 			{
 
 				/* allocate the sidenode */
-				if ((SideNodes[i] = CreateSideNode(theGrid,theElement,NULL,i)) 
-					== NULL) 
-				{
-					RETURN(GM_FATAL);
-				}
+				if ((SideNodes[i] = CreateSideNode(theGrid,theElement,NULL,i)) == NULL) 
+                                    RETURN(GM_FATAL);
+
                 #ifdef IDENT_ONLY_NEW
 				SETNEW_NIDENT(SideNodes[i],1);
 				#endif
@@ -3504,36 +3535,22 @@
 
 struct compare_record
 { 
-	ELEMENT *elem; 		 /* element to connect 					 */
-	INT side;			 /* side of elem to connect 			 */
-	INT nodes;		     /* number of nodes of side 			 */
-	NODE *nodeptr[4]; 	 /* pointer of nodes in descending order */
-};
-typedef struct compare_record COMPARE_RECORD;
-
-
-/****************************************************************************/
-/*
-   GetSonSideNodes - 
-
-   SYNOPSIS:
-   INT GetSonSideNodes (ELEMENT *theElement, INT side, INT *nodes, NODE *SideNodes[MAX_SIDE_NODES], INT ioflag));
+    /** \brief Element to connect */
+    ELEMENT *elem;
 
-   PARAMETERS:
-.  theElement
-.  side
-.  nodes
-.  SideNodes[MAX_SIDE_NODES]
-.  ioflag
+    /** \brief Side of element to connect */
+    INT side;
+    
+    /** \brief Number of nodes of side */
+    INT nodes;
 
-   DESCRIPTION:
+    /** \brief Number of nodes in descending order */
+    NODE *nodeptr[4];
+};
+typedef struct compare_record COMPARE_RECORD;
 
-   \return <ul>
-   INT 
-*/
-/****************************************************************************/
 
-INT NS_DIM_PREFIX GetSonSideNodes (ELEMENT *theElement, INT side, INT *nodes, 
+INT NS_DIM_PREFIX GetSonSideNodes (const ELEMENT *theElement, INT side, INT *nodes, 
 					 NODE *SideNodes[MAX_SIDE_NODES], INT ioflag)
 {
 	INT i,ncorners,nedges;
@@ -3671,6 +3688,8 @@
 \param[out] SonSides Output element side numbers
 \param[in] NeedSons If this is false, the correct list of sons is expected to be
   provided in SonList.  If not it is recomputed.
+\param[in] ioflag An obsolete debugging flag
+\param[in] useRefineClass 
 
   For a given side of an element, this routine computes all element sides
   on the next finer grid level which are topological sons of the input
@@ -3678,9 +3697,13 @@
 */
 /****************************************************************************/
 
-INT NS_DIM_PREFIX Get_Sons_of_ElementSide (ELEMENT *theElement, INT side, INT *Sons_of_Side,
-							 ELEMENT *SonList[MAX_SONS], INT *SonSides, 
-							 INT NeedSons, INT ioflag)
+INT NS_DIM_PREFIX Get_Sons_of_ElementSide (const ELEMENT *theElement, INT side, INT *Sons_of_Side,
+                                           ELEMENT *SonList[MAX_SONS], INT *SonSides, 
+                                           INT NeedSons, INT ioflag
+#ifdef FOR_DUNE
+                                           , INT useRefineClass
+#endif
+                                           )
 {
 	INT i,j,nsons;
         enum MarkClass markclass;
@@ -3708,7 +3731,18 @@
 	markclass = RED_CLASS;
 	#endif
 	#ifdef __THREEDIM__
-	markclass = (enum MarkClass)MARKCLASS(theElement);
+        /* The following line used to read: markclass = (enum MarkClass) MARKCLASS(theElement);
+           This works well within the UG grid refinement context.  However, now I want to use this
+           method within the DUNE UGGridLeafIntersectionIterator.  The problem is that the user
+           may have randomly marked elements before calling the iterator.  In that case the
+           mark classes may not be set the way this method expects it.  Hence we allow the option
+           to use REFINECLASS instead.  To be absolutely certain we don't break existing code
+           we keep the old behaviour as the default.*/
+        #ifdef FOR_DUNE
+	markclass = (enum MarkClass) ((useRefineClass) ? REFINECLASS(theElement) : MARKCLASS(theElement));
+        #else
+        markclass = (enum MarkClass) MARKCLASS(theElement);
+        #endif
 	#endif
 
         /** \todo quick fix */
@@ -4999,7 +5033,7 @@
 							INT node,k;
 							/*INT maxedge=-1;*/
 							#ifdef ModelP
-							DDD_GID maxid = 0;
+							unsigned int maxid = 0;
 							#else
 							INT maxid = -1;
 							#endif
@@ -5791,7 +5825,8 @@
 	GRID *UpGrid;
 	
 	UpGrid = UPGRID(theGrid);
-	if (UpGrid==NULL) RETURN(GM_FATAL);
+	if (UpGrid==NULL) 
+            RETURN(GM_FATAL);
 
 	REFINE_GRID_LIST(1,MYMG(theGrid),GLEVEL(theGrid),("AdaptGrid(%d):\n",GLEVEL(theGrid)),"");
 
@@ -5864,14 +5899,16 @@
 
 			if (hFlag==0 && MARKCLASS(theElement)!=RED_CLASS)
 			{
+				/* remove copy marks */
 				SETMARK(theElement,NO_REFINEMENT);
 				SETMARKCLASS(theElement,NO_CLASS);
-				continue; 
+/*				continue;  */
 			}
 
 			REFINE_ELEMENT_LIST(1,theElement,"REFINING element: ");
 
-			if (UnrefineElement(UpGrid,theElement))				RETURN(GM_FATAL);
+			if (UnrefineElement(UpGrid,theElement))
+                            RETURN(GM_FATAL);
 
 			#ifdef ModelP
 			/* dispose hghost elements with EFATHER==NULL */
@@ -5891,7 +5928,8 @@
 
 			if (EMASTER(theElement))
 			{
-				if (UpdateContext(UpGrid,theElement,theContext)!=0)	RETURN(GM_FATAL);
+				if (UpdateContext(UpGrid,theElement,theContext)!=0) 
+                                    RETURN(GM_FATAL);
 
 				REFINE_CONTEXT_LIST(2,theContext);
 
@@ -5901,7 +5939,8 @@
 
 				/* is something to do ? */
 				if (MARKED(theElement))
-					if (RefineElement(UpGrid,theElement,theContext))	RETURN(GM_FATAL);
+					if (RefineElement(UpGrid,theElement,theContext))
+                                            RETURN(GM_FATAL);
 			}
 
 			/* refine and refineclass flag */
@@ -6013,7 +6052,8 @@
 	DDD_ObjMgrBegin();
 	#endif
 	if (level<toplevel || newlevel)
-		if (AdaptLocalGrid(theGrid,nadapted)!=GM_OK)				RETURN(GM_FATAL);
+		if (AdaptLocalGrid(theGrid,nadapted)!=GM_OK) 
+                    RETURN(GM_FATAL);
 	#ifdef DDDOBJMGR
 	DDD_ObjMgrEnd();
 	#endif
@@ -6445,7 +6485,6 @@
 	#endif
 
 	#ifdef __PERIODIC_BOUNDARY__
-if (1)
 	if (MG_MakePeriodicMarksConsistent(theMG)) REP_ERR_RETURN(1);
 	#endif
 	
@@ -6626,7 +6665,6 @@
 		}
 		#endif
 #ifdef __PERIODIC_BOUNDARY__
-if (1)
 		/* initialize USED flag on next lower grid level */
 		if (InitializePeriodicFlags(GRID_ON_LEVEL(theMG,level-1)))
 			RETURN(GM_ERROR);
@@ -6732,7 +6770,8 @@
 #endif
 		if (newlevel)
 		{
-			if (CreateNewLevel(theMG,0)==NULL) RETURN(GM_FATAL);
+			if (CreateNewLevel(theMG,0)==NULL) 
+                            RETURN(GM_FATAL);
 			FinerGrid = GRID_ON_LEVEL(theMG,toplevel+1);
 		}
 		
@@ -6748,9 +6787,11 @@
 
 		if (level<toplevel || newlevel)
 			#ifndef ModelP
-			if (AdaptGrid(theGrid,&nadapted)!=GM_OK)							RETURN(GM_FATAL);
+			if (AdaptGrid(theGrid,&nadapted)!=GM_OK)
+                            RETURN(GM_FATAL);
 			#else
-			if (AdaptGrid(theGrid,toplevel,level,newlevel,&nadapted)!=GM_OK)	RETURN(GM_FATAL);
+			if (AdaptGrid(theGrid,toplevel,level,newlevel,&nadapted)!=GM_OK)
+                            RETURN(GM_FATAL);
 			#endif
 
 		SUM_TIMER(gridadapt_timer)
@@ -6767,7 +6808,8 @@
 			#ifndef DYNAMIC_MEMORY_ALLOCMODEL
 			/* now rebuild connections in neighborhood of elements which have EBUILDCON set */
 			/* This flag has been set either by GridDisposeConnection or by CreateElement	*/
-			if (GridCreateConnection(FinerGrid)) RETURN(GM_FATAL);
+			if (GridCreateConnection(FinerGrid)) 
+                            RETURN(GM_FATAL);
 			#endif
 			
 			/* and compute the vector classes on the new (or changed) level */
diff -ruN ug-orig/gm/refine.h ug-patched/gm/refine.h
--- ug-orig/gm/refine.h	2006-06-02 18:12:47.000000000 +0200
+++ ug-patched/gm/refine.h	2007-06-01 13:51:44.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/refine.h,v 1.29 2006/06/02 16:12:47 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -257,9 +257,19 @@
 /*                                                                                                                                                      */
 /****************************************************************************/
 
-INT     Set_Get_Sons_of_ElementSideProc                 (Get_Sons_of_ElementSideProcPtr Proc);
-INT     GetSonSideNodes                                                 (ELEMENT *theElement, INT side, INT *nodes, NODE *SideNodes[MAX_SIDE_NODES], INT ioflag);
-INT             Get_Sons_of_ElementSide                                 (ELEMENT *theElement, INT side, INT *Sons_of_Side, ELEMENT *SonList[MAX_SONS], INT *SonSides, INT NeedSons, INT ioflag);
+INT     GetSonSideNodes                                                 (const ELEMENT *theElement, INT side, INT *nodes, NODE *SideNodes[MAX_SIDE_NODES], INT ioflag);
+INT Get_Sons_of_ElementSide(const ELEMENT *theElement, 
+                            INT side, 
+                            INT *Sons_of_Side, 
+                            ELEMENT *SonList[MAX_SONS], 
+                            INT *SonSides, 
+                            INT NeedSons, 
+                            INT ioflag
+#ifdef FOR_DUNE 
+                            /* Only used by Dune.  And default parameters are only allowed in C++ */
+                            , INT useRefineClass=0
+#endif
+                            );
 INT     Connect_Sons_of_ElementSide                     (GRID *theGrid, ELEMENT *theElement, INT side, INT Sons_of_Side, ELEMENT **Sons_of_Side_List, INT *SonSides, INT ioflag);
 INT             Refinement_Changes                                              (ELEMENT *theElement);
 
diff -ruN ug-orig/gm/rm.c ug-patched/gm/rm.c
--- ug-orig/gm/rm.c	2008-10-30 13:29:06.000000000 +0100
+++ ug-patched/gm/rm.c	2007-05-29 09:19:06.000000000 +0200
@@ -128,9 +128,6 @@
 static REFRULE Empty_Rule = 
                       {-1,-1,NO_CLASS,-1,{-1,-1,-1,-1},-1, 
 				       {{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}}, 
-					   {{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-					    {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-					    {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 					   {{-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1}, 
 					    {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1}, 
 					    {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1}, 
@@ -142,9 +139,6 @@
 			   {TRIANGLE,T_NOREF,NO_CLASS,0,
 				{0,0,0,0},0,
 				{{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
-				{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -154,9 +148,6 @@
 			   {TRIANGLE,T_COPY,RED_CLASS|GREEN_CLASS,1,
 				{0,0,0,0},0,
 				{{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
-				{{4,0,1,-1},{4,1,2,-1},{4,2,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,2,-1},{FO+0,FO+1,FO+2,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -166,9 +157,6 @@
 			   {TRIANGLE,T_RED,RED_CLASS|GREEN_CLASS|SWITCH_CLASS,4,
 				{1,1,1,0},(1<<3)-1,
 				{{0,1},{1,2},{0,2},{-1,-1},{-1,-1}},
-				{{3,0,3,0},{3,3,1,0},{3,1,4,0},{3,4,2,0},
-				 {3,2,5,0},{3,5,0,2},{1,3,4,0},{1,4,5,0},
-				 {1,5,3,0},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 3,FO+2,-1},0},
 				 {TRIANGLE,{3,1,4,-1},{FO+0,FO+1, 3,-1},0},
 				 {TRIANGLE,{4,2,5,-1},{ FO+1,FO+2,3,-1},0},
@@ -179,9 +167,6 @@
 			   {TRIANGLE,T_BISECT_1_0,RED_CLASS|GREEN_CLASS,2,
 				{1,0,0,0},1,
 				{{0,1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
-				{{3,0,3,-1},{3,3,1,-1},{ 1, 3, 2,-1},{4,1,2,-1},
-				 {4,2,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,2,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{3,1,2,-1},{FO+0,FO+1, 0,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -191,9 +176,6 @@
 			   {TRIANGLE,T_BISECT_1_1,RED_CLASS|GREEN_CLASS,2,
 				{0,1,0,0},1<<1,
 				{{-1,-1},{0,2},{-1,-1},{-1,-1},{-1,-1}},
-				{{3,1,4,-1},{3,4,2,-1},{ 1, 4, 0,-1},{4,0,1,-1},
-				 {4,2,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,4,-1},{FO+0,FO+1, 1,-1},0},
 				 {TRIANGLE,{0,4,2,-1},{ 0,FO+1,FO+2,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -203,9 +185,6 @@
 			   {TRIANGLE,T_BISECT_1_2,RED_CLASS|GREEN_CLASS,2,
 				{0,0,1,0},1<<2,
 				{{-1,-1},{-1,-1},{0,2},{-1,-1},{-1,-1}},
-				{{3,2,5,-1},{3,5,0,-1},{ 1, 5, 1,-1},{4,0,1,-1},
-				 {4,1,2,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{5,1,2,-1},{ 0,FO+1,FO+2,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -216,9 +195,6 @@
 			   {TRIANGLE,T_BISECT_2_T1_2,RED_CLASS|GREEN_CLASS,3,
 				{1,1,0,0},(1<<2)-1,
 				{{0,1},{1,2},{-1,-1},{-1,-1},{-1,-1}},
-				{{1,3,2,-1},{1,3,4,-1},{ 3, 0, 3,-1},{ 3, 3, 1,-1},
-				 {3,1,4,-1},{3,4,2,-1},{4,0,2,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,2,-1},{FO+0, 2,FO+2,-1},0},
 				 {TRIANGLE,{3,1,4,-1},{FO+0,FO+1, 2,-1},0},
 				 {TRIANGLE,{3,4,2,-1},{ 1,FO+1, 0,-1},0},
@@ -228,9 +204,6 @@
 			   {TRIANGLE,T_BISECT_2_T1_0,RED_CLASS|GREEN_CLASS,3,
 				{0,1,1,0},6,
 				{{-1,-1},{0,2},{1,2},{-1,-1},{-1,-1}},
-				{{1,0,4,-1},{1,4,5,-1},{4,0,1,-1},{3,1,4,-1},
-				 {3,4,2,-1},{3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,4,-1},{FO+0,FO+1, 1,-1},0},
 				 {TRIANGLE,{0,4,5,-1},{ 0, 2,FO+2,-1},0},
 				 {TRIANGLE,{5,4,2,-1},{ 1,FO+1,FO+2,-1},0},
@@ -240,9 +213,6 @@
 			   {TRIANGLE,T_BISECT_2_T1_1,RED_CLASS|GREEN_CLASS,3,
 				{1,0,1,0},5,
 				{{0,1},{-1,-1},{1,2},{-1,-1},{-1,-1}},
-				{{1,3,5,-1},{1,1,5,-1},{3,0,3,-1},{3,3,1,-1},
-				 {4,1,2,-1},{3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{3,1,5,-1},{FO+0, 2, 0,-1},0},
 				 {TRIANGLE,{5,1,2,-1},{ 1,FO+1,FO+2,-1},0},
@@ -252,9 +222,6 @@
 			   {TRIANGLE,T_BISECT_2_T2_1,RED_CLASS|GREEN_CLASS,3,
 				{1,0,1,0},5,
 				{{0,1},{-1,-1},{0,2},{-1,-1},{-1,-1}},
-				{{1,3,5,-1},{1,3,2,-1},{3,0,3,-1},{3,3,1,-1},
-				 {4,1,2,-1},{3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{5,3,2,-1},{ 0, 2,FO+2,-1},0},
 				 {TRIANGLE,{3,1,2,-1},{FO+0,FO+1, 1,-1},0},
@@ -264,9 +231,6 @@
 			   {TRIANGLE,T_BISECT_2_T2_2,RED_CLASS|GREEN_CLASS,3,
 				{1,1,0,0},3,
 				{{0,1},{0,2},{-1,-1},{-1,-1},{-1,-1}},
-				{{1,3,4,-1},{1,4,0,-1},{3,0,3,-1},{3,3,1,-1},
-				 {3,1,4,-1},{3,4,2,-1},{4,2,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,4,-1},{FO+0, 1, 2,-1},0},
 				 {TRIANGLE,{3,1,4,-1},{FO+0,FO+1, 0,-1},0},
 				 {TRIANGLE,{0,4,2,-1},{ 0,FO+1,FO+2,-1},0},
@@ -276,9 +240,6 @@
 			   {TRIANGLE,T_BISECT_2_T2_0,RED_CLASS|GREEN_CLASS,3,
 				{0,1,1,0},6,
 				{{-1,-1},{1,2},{0,2},{-1,-1},{-1,-1}},
-				{{1,4,5,-1},{1,5,1,-1},{4,0,1,-1},{3,1,4,-1},
-				 {3,4,2,-1},{3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{5,1,4,-1},{ 0,FO+1, 2,-1},0},
 				 {TRIANGLE,{5,4,2,-1},{ 1,FO+1,FO+2,-1},0},
@@ -288,9 +249,6 @@
 			   {TRIANGLE,T_BISECT_2_Q_0,RED_CLASS|GREEN_CLASS,2,
 				{0,1,1,0},6,
 				{{-1,-1},{0,2},{0,3},{-1,-1},{-1,-1}},
-				{{1,4,5,-1},{4,0,1,-1},{3,1,4,-1},{3,4,2,-1},
-				 {3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,4,5},{FO+0,FO+1, 1,FO+2},0},
 				 {TRIANGLE,{5,4,2,-1},{ 0,FO+1,FO+2,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -300,9 +258,6 @@
 			   {TRIANGLE,T_BISECT_2_Q_1,RED_CLASS|GREEN_CLASS,2,
 				{1,0,1,0},5,
 				{{0,1},{-1,-1},{0,2},{-1,-1},{-1,-1}},
-				{{1,3,5,-1},{3,0,3,-1},{3,3,1,-1},{4,1,2,-1},
-				 {3,2,5,-1},{3,5,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {QUADRILATERAL,{3,1,2,5},{FO+0,FO+1,FO+2, 0},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -312,9 +267,6 @@
 			   {TRIANGLE,T_BISECT_2_Q_2,RED_CLASS|GREEN_CLASS,2,
 				{1,1,0,0},3,
 				{{0,1},{0,2},{-1,-1},{-1,-1},{-1,-1}},
-				{{1,3,4,-1},{3,0,3,-1},{3,3,1,-1},{3,1,4,-1},
-				 {3,4,2,-1},{4,2,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,3,4,2},{FO+0, 1,FO+1,FO+2},0},
 				 {TRIANGLE,{3,1,4,-1},{FO+0,FO+1, 0,-1},0},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -324,9 +276,6 @@
 			   {TRIANGLE,T_BISECT_3_0,RED_CLASS|GREEN_CLASS,4,
 				{1,1,1,0},7,
 				{{0,1},{3,2},{0,2},{-1,-1},{-1,-1}},
-				{{1,3,4,-1},{1,3,2,-1},{1,3,5,-1},{3,0,3,-1},
-				 {3,3,1,-1},{3,1,4,-1},{3,4,2,-1},{3,2,5,-1},
-				 {3,5,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{5,3,2,-1},{ 0, 2,FO+2,-1},0},
 				 {TRIANGLE,{3,4,2,-1},{ 3,FO+1, 1,-1},0},
@@ -336,9 +285,6 @@
 			   {TRIANGLE,T_BISECT_3_1,RED_CLASS|GREEN_CLASS,4,
 				{1,1,1,0},7,
 				{{0,1},{0,2},{1,2},{-1,-1},{-1,-1}},
-				{{1,4,0,-1},{1,4,3,-1},{1,4,5,-1},{3,0,3,-1},
-				 {3,3,1,-1},{3,1,4,-1},{3,4,2,-1},{3,2,5,-1},
-				 {3,5,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,4,-1},{FO+0, 3, 1,-1},0},
 				 {TRIANGLE,{0,4,5,-1},{ 0, 2,FO+2,-1},0},
 				 {TRIANGLE,{5,4,2,-1},{ 1,FO+1,FO+2,-1},0},
@@ -348,9 +294,6 @@
 			   {TRIANGLE,T_BISECT_3_2,RED_CLASS|GREEN_CLASS,4,
 				{1,1,1,0},7,
 				{{0,1},{2,2},{1,2},{-1,-1},{-1,-1}},
-				{{1,5,3,-1},{1,5,1,-1},{1,5,4,-1},{3,0,3,-1},
-				 {3,3,1,-1},{3,1,4,-1},{3,4,2,-1},{3,2,5,-1},
-				 {3,5,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,3,5,-1},{FO+0, 1,FO+2,-1},0},
 				 {TRIANGLE,{3,1,5,-1},{FO+0, 2, 0,-1},0},
 				 {TRIANGLE,{5,1,4,-1},{ 1,FO+1, 3,-1},0},
@@ -365,9 +308,6 @@
 		  	   {QUADRILATERAL,Q_NOREF,NO_CLASS,0,
 				{0,0,0,0},0,
 				{{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
-				{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -377,9 +317,6 @@
 		  	   {QUADRILATERAL,Q_COPY,RED_CLASS|GREEN_CLASS,1,
 				{0,0,0,0},0,
 				{{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
-				{{4,0,1,-1},{4,1,2,-1},{4,2,3,-1},{4,3,0,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,2,3},{FO+0,FO+1,FO+2,FO+3},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -389,9 +326,6 @@
 		  	   {QUADRILATERAL,Q_RED,RED_CLASS|GREEN_CLASS|SWITCH_CLASS,4,
 				{1,1,1,1,1},(1<<5)-1,
 				{{0,1},{1,2},{2,3},{3,0},{0,2}},
-				{{3,0,4,-1},{3,4,1,-1},{3,1,5,-1},{3,5,2,-1},
-				 {3,2,6,-1},{3,6,3,-1},{3,3,7,-1},{3,7,0,-1},
-				 {1,4,8,-1},{1,5,8,-1},{1,6,8,-1},{1,7,8,-1}},
 				{{QUADRILATERAL,{0,4,8,7},{FO+0, 1, 3,FO+3},-1},
 				 {QUADRILATERAL,{4,1,5,8},{FO+0,FO+1, 2, 0},-1},
 				 {QUADRILATERAL,{8,5,2,6},{ 1,FO+1,FO+2, 3},-1},
@@ -401,9 +335,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_1_0,RED_CLASS|GREEN_CLASS,3,
 				{1,1,0,0,1},3+16,
 				{{0,1},{1,2},{-1,-1},{-1,-1},{0,2}},
-				{{1,4,8,-1},{1,5,8,-1},{1,3,8,-1},{3,0,4,-1},
-				 {3,4,1,-1},{3,1,5,-1},{3,5,2,-1},{4,2,3,-1},
-				 {4,3,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,4,8,3},{FO+0, 1, 2,FO+3},-1},
 				 {QUADRILATERAL,{4,1,5,8},{FO+0,FO+1, 2, 0},-1},
 				 {QUADRILATERAL,{8,5,2,3},{ 1,FO+1,FO+2, 0},-1},
@@ -413,9 +344,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_1_1,RED_CLASS|GREEN_CLASS,3,
 				{0,1,1,0,1},6+16,
 				{{-1,-1},{0,2},{1,3},{-1,-1},{0,3}},
-				{{1,0,8,-1},{1,5,8,-1},{1,6,8,-1},{4,0,1,-1},
-				 {3,1,5,-1},{3,5,2,-1},{3,2,6,-1},{3,6,3,-1},
-				 {4,3,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,5,8},{FO+0,FO+1, 1, 2},-1},
 				 {QUADRILATERAL,{8,5,2,6},{ 0,FO+1,FO+2, 2},-1},
 				 {QUADRILATERAL,{0,8,6,3},{ 0, 1,FO+2,FO+3},-1},
@@ -425,9 +353,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_1_2,RED_CLASS|GREEN_CLASS,3,
 				{0,0,1,1,1},12+16,
 				{{-1,-1},{-1,-1},{1,3},{0,3},{0,2}},
-				{{1,1,8,-1},{1,6,8,-1},{1,7,8,-1},{4,0,1,-1},
-				 {4,1,2,-1},{3,2,6,-1},{3,6,3,-1},{3,3,7,-1},
-				 {3,7,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,8,7},{FO+0, 1, 2,FO+3},-1},
 				 {QUADRILATERAL,{8,1,2,6},{ 0,FO+1,FO+2, 2},-1},
 				 {QUADRILATERAL,{7,8,6,3},{ 0, 1,FO+2,FO+3},-1},
@@ -437,9 +362,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_1_3,RED_CLASS|GREEN_CLASS,3,
 				{1,0,0,1,1},9+16,
 				{{0,1},{-1,-1},{-1,-1},{0,3},{0,2}},
-				{{1,4,8,-1},{1,2,8,-1},{1,7,8,-1},{3,0,4,-1},
-				 {3,4,1,-1},{4,1,2,-1},{4,2,3,-1},{3,3,7,-1},
-				 {3,7,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,4,8,7},{FO+0, 1, 2,FO+3},-1},
 				 {QUADRILATERAL,{4,1,2,8},{FO+0,FO+1, 2, 0},-1},
 				 {QUADRILATERAL,{7,8,2,3},{ 0, 1,FO+2,FO+3},-1},
@@ -449,9 +371,6 @@
 		  	   {QUADRILATERAL,Q_BLUE_0,RED_CLASS|GREEN_CLASS,2,
 				{1,0,1,0,0},5,
 				{{0,1},{-1,-1},{0,2},{-1,-1},{-1,-1}},
-				{{1,4,6,-1},{3,0,4,-1},{3,4,1,-1},{4,1,2,-1},
-				 {3,2,6,-1},{3,6,3,-1},{4,3,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,4,6,3},{FO+0, 1,FO+2,FO+3},-1},
 				 {QUADRILATERAL,{4,1,2,6},{FO+0,FO+1,FO+2, 0},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -461,9 +380,6 @@
 		  	   {QUADRILATERAL,Q_BLUE_1,RED_CLASS|GREEN_CLASS,2,
 				{0,1,0,1,0},10,
 				{{-1,-1},{0,2},{-1,-1},{0,3},{-1,-1}},
-				{{1,5,7,-1},{4,0,1,-1},{3,1,5,-1},{3,5,2,-1},
-				 {4,2,3,-1},{3,3,7,-1},{3,7,0,-1},{-1,-1,-1,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,5,7},{FO+0,FO+1, 1,FO+3},-1},
 				 {QUADRILATERAL,{7,5,2,3},{ 0,FO+1,FO+2,FO+3},-1},
 				 {-1,{-1,-1,-1,-1},{-1,-1,-1,-1},-1},
@@ -473,9 +389,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_2_0,RED_CLASS|GREEN_CLASS,3,
 				{1,0,0,0,1},1+16,
 				{{0,1},{-1,-1},{-1,-1},{-1,-1},{0,2}},
-				{{1,4,8,-1},{1,2,8,-1},{1,3,8,-1},{3,0,4,-1},
-				 {3,4,1,-1},{4,1,2,-1},{4,2,3,-1},{4,3,0,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,4,8,3},{FO+0, 1, 2,FO+3},-1},
 				 {QUADRILATERAL,{4,1,2,8},{FO+0,FO+1, 2, 0},-1},
 				 {TRIANGLE,{8,2,3,-1},{ 1,FO+2, 0,-1},-1},
@@ -485,9 +398,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_2_1,RED_CLASS|GREEN_CLASS,3,
 				{0,1,0,0,1},2+16,
 				{{-1,-1},{0,2},{-1,-1},{-1,-1},{0,3}},
-				{{1,0,8,-1},{1,5,8,-1},{1,3,8,-1},{4,0,1,-1},
-				 {3,1,5,-1},{3,5,2,-1},{4,2,3,-1},{4,3,0,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,5,8},{FO+0,FO+1, 1, 2},-1},
 				 {QUADRILATERAL,{8,5,2,3},{ 0,FO+1,FO+2, 2},-1},
 				 {TRIANGLE,{0,8,3,-1},{ 0, 1,FO+3,-1},-1},
@@ -497,9 +407,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_2_2,RED_CLASS|GREEN_CLASS,3,
 				{0,0,1,0,1},4+16,
 				{{-1,-1},{-1,-1},{1,3},{-1,-1},{0,2}},
-				{{1,0,8,-1},{1,1,8,-1},{1,6,8,-1},{4,0,1,-1},
-				 {4,1,2,-1},{3,2,6,-1},{3,6,3,-1},{4,3,0,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{TRIANGLE,{0,1,8,-1},{FO+0, 1, 2,-1},-1},
 				 {QUADRILATERAL,{8,1,2,6},{ 0,FO+1,FO+2, 2},-1},
 				 {QUADRILATERAL,{0,8,6,3},{ 0, 1,FO+2,FO+3},-1},
@@ -509,9 +416,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_2_3,RED_CLASS|GREEN_CLASS,3,
 				{0,0,0,1,1},8+16,
 				{{-1,-1},{-1,-1},{-1,-1},{0,3},{0,2}},
-				{{1,1,8,-1},{1,2,8,-1},{1,7,8,-1},{4,0,1,-1},
-				 {4,1,2,-1},{4,2,3,-1},{3,3,7,-1},{3,7,0,-1},
-				 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,8,7},{FO+0, 1, 2,FO+3},-1},
 			 	 {TRIANGLE,{1,2,8,-1},{FO+1, 2, 0,-1},-1},
 				 {QUADRILATERAL,{7,8,2,3},{ 0, 1,FO+2,FO+3},-1},
@@ -521,9 +425,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_3_0,RED_CLASS|GREEN_CLASS,4,
 				{0,1,1,1,0},14,
 				{{-1,-1},{0,2},{1,2},{0,3},{-1,-1}},
-				{{1,7,5,-1},{1,5,6,-1},{1,6,7,-1},{4,0,1,-1},
-				 {3,1,5,-1},{3,5,2,-1},{3,2,6,-1},{3,6,3,-1},
-				 {3,3,7,-1},{3,7,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,1,5,7},{FO+0,FO+1, 1,FO+3},-1},
 			 	 {TRIANGLE,{7,5,6,-1},{ 0, 2, 3,-1},-1},
 				 {TRIANGLE,{5,2,6,-1},{FO+1,FO+2, 1,-1},-1},
@@ -533,9 +434,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_3_1,RED_CLASS|GREEN_CLASS,4,
 				{1,0,1,1,0},13,
 				{{0,1},{-1,-1},{1,2},{0,2},{-1,-1}},
-				{{1,7,4,-1},{1,4,6,-1},{1,6,7,-1},{3,0,4,-1},
-				 {3,4,1,-1},{4,1,2,-1},{3,2,6,-1},{3,6,3,-1},
-				 {3,3,7,-1},{3,7,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 			 	{{TRIANGLE,{0,4,7,-1},{FO+0, 1,FO+3,-1},-1},
 			 	 {TRIANGLE,{7,4,6,-1},{ 0, 3, 2,-1},-1},
 				 {TRIANGLE,{7,6,3,-1},{ 1,FO+2,FO+3,-1},-1},
@@ -545,9 +443,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_3_2,RED_CLASS|GREEN_CLASS,4,
 				{1,1,0,1,0},11,
 				{{0,1},{2,2},{-1,-1},{0,2},{-1,-1}},
-				{{1,7,4,-1},{1,4,5,-1},{1,5,7,-1},{3,0,4,-1},
-				 {3,4,1,-1},{3,1,5,-1},{3,5,2,-1},{4,2,3,-1},
-				 {3,3,7,-1},{3,7,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 			 	{{TRIANGLE,{0,4,7,-1},{FO+0, 1,FO+3,-1},-1},
 			 	 {TRIANGLE,{4,5,7,-1},{ 2, 3, 0,-1},-1},
 				 {TRIANGLE,{4,1,5,-1},{FO+0,FO+1, 1,-1},-1},
@@ -557,9 +452,6 @@
 		  	   {QUADRILATERAL,Q_CLOSE_3_3,RED_CLASS|GREEN_CLASS,4,
 				{1,1,1,0,0},7,
 				{{0,1},{2,2},{0,2},{-1,-1},{-1,-1}},
-				{{1,6,4,-1},{1,4,5,-1},{1,5,6,-1},{3,0,4,-1},
-				 {3,4,1,-1},{3,1,5,-1},{3,5,2,-1},{3,2,6,-1},
-				 {3,6,3,-1},{4,3,0,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}},
 				{{QUADRILATERAL,{0,4,6,3},{FO+0, 1,FO+2,FO+3},-1},
 			 	 {TRIANGLE,{4,5,6,-1},{ 2, 3, 0,-1},-1},
 			 	 {TRIANGLE,{4,1,5,-1},{FO+0,FO+1, 1,-1},-1},
@@ -572,6 +464,7 @@
 #ifdef __THREEDIM__
 
 static INT theBFRRDirID;      /* env type for BestFullRefRule       */
+static INT theBFRRVarID;
 
 static REFRULE Empty_Rule = 
                       {-1,-1,NO_CLASS,-1,
@@ -580,20 +473,6 @@
 						 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 						 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 						 {-1,-1}},  
-						{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-						 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 						{{-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 						 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 						 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -618,20 +497,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -651,20 +516,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 0,-1},{ 4, 0, 3,-1}, 
-			 { 4, 1, 3,-1},{ 4, 2, 3,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{TETRAHEDRON,{ 0, 1, 2, 3,-1,-1,-1,-1},{FO+0,FO+1,FO+2,FO+3,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -688,23 +539,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /* TODO: not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{TETRAHEDRON,{0,4,6,7,-1,-1,-1,-1},{FO+0,4,FO+2,FO+3,-1,-1},0x0}, 
 			 {TETRAHEDRON,{4,5,8,1,-1,-1,-1,-1},{5,FO+1,FO+3,FO+0,-1,-1},
@@ -736,23 +570,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{TETRAHEDRON,{5,6,9,2,-1,-1,-1,-1},{4,FO+2,FO+1,FO+0,-1,-1},0x0}, 
 			 {TETRAHEDRON,{4,5,8,1,-1,-1,-1,-1},{5,FO+1,FO+3,FO+0,-1,-1},
@@ -784,23 +601,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /* TODO: not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{TETRAHEDRON,{7,8,9,3,-1,-1,-1,-1},{4,FO+1,FO+2,FO+3,-1,-1},0x0}, 
 			 {TETRAHEDRON,{4,5,8,1,-1,-1,-1,-1},{5,FO+1,FO+3,FO+0,-1,-1},
@@ -832,23 +632,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{HEXAHEDRON,{4,1,5,10,13,8,11,14},{FO+0,FO+3,FO+1,1,2,3},0x0}, 
 			 {HEXAHEDRON,{5,2,6,10,11,9,12,14},{FO+0,FO+1,FO+2,2,0,3},0x0},
@@ -876,20 +659,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -909,20 +678,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 3,-1},{ 4, 3, 0,-1}, 
-			 { 4, 0, 4,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{PYRAMID,{ 0, 1, 2, 3, 4,-1,-1,-1},{FO+0,FO+1,FO+2,FO+3,FO+4,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -946,23 +701,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /* TODO: not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PYRAMID,{ 0, 5, 13, 8, 9,-1,-1,-1},{FO+0,FO+1,4,7,FO+4,-1},-1}, 
 			 {PYRAMID,{5,1,6,13,10,-1,-1,-1},{FO+0,FO+1,FO+2,5,4,-1},
@@ -996,23 +734,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PYRAMID,{ 0, 5, 7, 3, 4,-1,-1,-1},{FO+0,FO+1,1,FO+3,FO+4,-1},-1}, 
 			 {PYRAMID,{5,1,2,7,4,-1,-1,-1},{FO+0,FO+1,FO+2,FO+3,0,-1},
@@ -1038,23 +759,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{ 3, 0, 5,-1},{ 3, 5, 1,-1},{ 3, 1, 6,-1},{ 3, 6, 2,-1}, 
-			 { 3, 2, 7,-1},{ 4, 1, 4,-1},{ 4, 2, 4,-1},{ 4, 3, 4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PYRAMID,{ 0, 1, 6, 8, 4,-1,-1,-1},{FO+0,FO+1,FO+2,1,FO+4,-1},-1}, 
 			 {PYRAMID,{8,6,2,3,4,-1,-1,-1},{FO+0,0,FO+2,FO+3,FO+4,-1},
@@ -1082,20 +786,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1115,20 +805,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 0,-1},{ 4, 0, 3,-1}, 
-			 { 4, 1, 4,-1},{ 4, 2, 5,-1},{ 4, 3, 4,-1},{ 4, 4, 5,-1}, 
-			 { 4, 5, 3,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{PRISM,{ 0, 1, 2, 3, 4, 5,-1,-1},{FO+0,FO+1,FO+2,FO+3,FO+4,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1153,23 +829,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,6,8,9,16,18,-1,-1},{FO+0,FO+1,2,FO+3,4,-1},-1}, 
 			 {PRISM,{6,1,7,16,10,17,-1,-1},{FO+0,FO+1,FO+2,2,5,-1},
@@ -1202,23 +861,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,6,8,3,12,14,-1,-1},{FO+0,FO+1,2,FO+3,FO+4,-1},-1}, 
 			 {PRISM,{6,1,7,12,4,13,-1,-1},{FO+0,FO+1,FO+2,2,FO+4,-1},
@@ -1236,34 +878,17 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_0_1 */
+	/* PRI_BISECT_0_1 */
 		  {PRISM,4,RED_CLASS|SWITCH_CLASS,2,
 			{1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
 			1 + 1<<6, 
 
 			 /* sonandnode */
-			{{0,1},{1,1},{0,2},{0,3},{1,4},{2,5}, 
-			 {4,4},{5,5},{4,5},{-1,-1},{0,4},{1,5},{0,5}, 
+			{{0,1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
+			 {0,4},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,6,2,3,12,5,-1,-1},{FO+0,FO+1,1,FO+3,FO+4,-1},-1}, 
 			 {PRISM,{6,1,2,12,4,5,-1,-1},{FO+0,FO+1,FO+2,0,FO+4,-1},
@@ -1279,34 +904,17 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_0_2 */
+	/* PRI_BISECT_0_2 */
 		  {PRISM,5,RED_CLASS|SWITCH_CLASS,2,
 			{0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
 			1<<1 + 1<<7, 
 
 			 /* sonandnode */
-			{{0,1},{1,1},{0,2},{0,3},{1,4},{2,5}, 
-			 {4,4},{5,5},{4,5},{-1,-1},{0,4},{1,5},{0,5}, 
+			{{-1,-1},{0,1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
+			 {-1,-1},{0,4},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,7,2,3,13,5,-1,-1},{FO+0,1,FO+2,FO+3,FO+4,-1},-1}, 
 			 {PRISM,{0,1,7,3,4,13,-1,-1},{FO+0,FO+1,FO+2,0,FO+4,-1},
@@ -1322,34 +930,17 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_0_3 */
+	/* PRI_BISECT_0_3 */
 		  {PRISM,6,RED_CLASS|SWITCH_CLASS,2,
 			{0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
 			1<<2 + 1<<8,
 
 			 /* sonandnode */
-			{{0,1},{1,1},{0,2},{0,3},{1,4},{2,5}, 
-			 {4,4},{5,5},{4,5},{-1,-1},{0,4},{1,5},{0,5}, 
+			{{-1,-1},{-1,-1},{0,2},{-1,-1},{-1,-1},{-1,-1}, 
+			 {-1,-1},{-1,-1},{0,5},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,1,8,3,4,14,-1,-1},{FO+0,FO+1,1,FO+3,FO+4,-1},-1}, 
 			 {PRISM,{8,1,2,14,4,5,-1,-1},{FO+0,0,FO+2,FO+3,FO+4,-1},
@@ -1365,7 +956,7 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_1_2 */
+	/* PRI_BISECT_1_2 */
 		  {PRISM,7,RED_CLASS|SWITCH_CLASS,2,
 			{0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0},
 			1<<3 + 1<<4 + 1<<5,
@@ -1376,23 +967,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,1,2,9,10,11,-1,-1},{FO+0,FO+1,FO+2,FO+3,1,-1},-1}, 
 			 {PRISM,{9,10,11,3,4,5,-1,-1},{0,FO+1,FO+2,FO+3,FO+4,-1},
@@ -1408,7 +982,7 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_hex_0 */
+	/* PRI_BISECT_HEX0 */
 		  {PRISM,8,RED_CLASS|SWITCH_CLASS,2,
 			{1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
 			1+1<<2+1<<6+1<<8, 
@@ -1419,23 +993,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{PRISM,{0,6,8,3,12,14,-1,-1},{FO+0,FO+1,1,FO+3,FO+4,-1},-1}, 
 			 {HEXAHEDRON,{6,1,2,8,12,4,5,14},{FO+0,FO+1,FO+2,FO+3,0,FO+4},
@@ -1451,7 +1008,7 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_hex_1 */
+	/* PRI_BISECT_HEX1 */
 		  {PRISM,9,RED_CLASS|SWITCH_CLASS,2,
 			{0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0},
 			1<<1+1<<2+1<<7+1<<8, 
@@ -1462,23 +1019,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{HEXAHEDRON,{0,1,7,8,3,4,13,14},{FO+0,FO+1,FO+2,1,FO+3,FO+4},-1}, 
 			 {PRISM,{7,8,2,13,14,5,-1,-1},{FO+0,0,FO+2,FO+3,FO+4,-1},
@@ -1494,7 +1034,7 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_bisect_hex_2 */
+	/* PRI_BISECT_HEX2 */
 		  {PRISM,10,RED_CLASS|SWITCH_CLASS,2,
 			{1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0},
 			1+1<<1+1<<6+1<<7, 
@@ -1505,23 +1045,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
 			{{HEXAHEDRON,{6,7,2,0,12,13,5,3},{FO+0,1,FO+2,FO+3,FO+1,FO+4},-1}, 
 			 {PRISM,{6,1,7,12,4,13,-1,-1},{FO+0,FO+1,FO+2,0,FO+4,-1},
@@ -1548,23 +1071,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
 			 {-1,-1}},  
 
-			 /* new edges */
-			 /** \todo not complete, since not needed any more */
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
-
 			 /* sons */
             {{HEXAHEDRON,{ 0, 6,15,8,3,12,19,14},{FO+0,FO+1,1,2,FO+3,FO+4},-1},
 		 	 {HEXAHEDRON,{ 6, 1, 7,15,12,4,13,19},{FO+0,FO+1,FO+2,2,0,FO+4},
@@ -1588,20 +1094,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 0,-1},{ 4, 0, 3,-1}, 
-			 { 4, 1, 4,-1},{ 4, 2, 5,-1},{ 4, 3, 4,-1},{ 4, 4, 5,-1}, 
-			 { 4, 5, 3,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{PRISM,{ 1, 2, 0, 4, 5, 3,-1,-1},{FO+0,FO+2,FO+3,FO+1,FO+4,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1622,20 +1114,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 0,-1},{ 4, 0, 3,-1}, 
-			 { 4, 1, 4,-1},{ 4, 2, 5,-1},{ 4, 3, 4,-1},{ 4, 4, 5,-1}, 
-			 { 4, 5, 3,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{PRISM,{ 2, 0, 1, 5, 3, 4,-1,-1},{FO+0,FO+3,FO+1,FO+2,FO+4,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1649,7 +1127,7 @@
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}}},
 
-	/* PRI_quadsect_hexpri0 */
+	/* PRI_QUADSECT_HEXPRI0 */
 		  {PRISM,14,RED_CLASS,4,
 			{1,1,0,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0},
                          3 + 1<<3 + 1<<4 + 1<<5 + 1<<6 + 1<<7 + 1<<10 + 1<<11,
@@ -1658,20 +1136,6 @@
 			 {3,5},{3,6},{-1,-1},{-1,-1},{0,5},{0,6},
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{ 4, 0, 1,-1},{ 4, 1, 2,-1},{ 4, 2, 0,-1},{ 4, 0, 3,-1}, 
-			 { 4, 1, 4,-1},{ 4, 2, 5,-1},{ 4, 3, 4,-1},{ 4, 4, 5,-1}, 
-			 { 4, 5, 3,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{HEXAHEDRON,{11, 9, 0, 2,17,16,6, 7},{FO+3,3,FO+1,FO+0,FO+2,1},-1}, 
 			 {PRISM,{ 6, 1, 7,16,10,17,-1,-1},{FO+0,FO+1,FO+2,0,2,-1},-1}, 
 			 {PRISM,{16,10,17,12, 4,13,-1,-1},{1,FO+1,FO+2,3,FO+4,-1},-1}, 
@@ -1697,20 +1161,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1731,20 +1181,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
-			{{4,0,1,-1},{4,1,2,-1},{4,2,3,-1},{4,3,0,-1}, 
-			 {4,0,4,-1},{4,1,5,-1},{4,2,6,-1},{4,3,7,-1}, 
-			 {4,4,5,-1},{4,5,6,-1},{4,6,7,-1},{4,7,4,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}, 
-			 {-1,-1,-1,-1},{-1,-1,-1,-1}}, 
 			{{HEXAHEDRON,{0,1,2,3,4,5,6,7},{FO+0,FO+1,FO+2,FO+3,FO+4,FO+5},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
 			 {-1,{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1},-1}, 
@@ -1768,27 +1204,6 @@
 			{4,5},{5,6},{6,7},{7,4},
 			{0,2},{0,5},{1,6},{2,7},{0,7},{4,6},{0,6}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 8,20,11,12,21,26,24},{FO+0,FO+1, 1, 3,FO+4, 4},-1},
 		 	{HEXAHEDRON,{ 8, 1, 9,20,21,13,22,26},{FO+0,FO+1,FO+2, 2, 0, 5},
@@ -1822,27 +1237,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 8,10,3,4,16,18,7},{FO+0,FO+1, 1,FO+3,FO+4,FO+5},-1},
 		 	{HEXAHEDRON,{ 8, 1, 2,10,16,5,6,18},{FO+0,FO+1,FO+2,FO+3, 0,FO+5},
@@ -1869,27 +1263,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 1,9,11,4,5,17,19},{FO+0,FO+1,FO+2,1,FO+4,FO+5},-1},
 		 	{HEXAHEDRON,{ 11, 9, 2,3,19,17,6,7},{FO+0,0,FO+2,FO+3,FO+4,FO+5},
@@ -1916,27 +1289,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 1,2,3,12,13,14,15},{FO+0,FO+1,FO+2,FO+3,FO+4,1},-1},
 		 	{HEXAHEDRON,{ 12,13,14,15,4,5,6,7},{0,FO+1,FO+2,FO+3,FO+4,FO+5},
@@ -1963,27 +1315,6 @@
 			{0,5},{1,6},{2,7},{0,7},
 			{0,2},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{0,6},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 8,20,11,4,16,25,19},{FO+0,FO+1,1,3,FO+4,FO+5},-1},
 		 	{HEXAHEDRON,{ 8, 1, 9,20,16,5,17,25},{FO+0,FO+1,FO+2,2,0,FO+5},
@@ -2012,27 +1343,6 @@
 			{3,5},{-1,-1},{3,6},{-1,-1},
 			{-1,-1},{0,5},{-1,-1},{0,6},{-1,-1},{-1,-1},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 8,10,3,12,21,23,15},{FO+0,FO+1,1,FO+3,FO+4,3},-1},
 		 	{HEXAHEDRON,{ 8, 1, 2,10,21,13,14,23},{FO+0,FO+1,FO+2,FO+3,0,2},
@@ -2061,27 +1371,6 @@
 			{-1,-1},{3,6},{-1,-1},{3,7},
 			{-1,-1},{-1,-1},{0,6},{-1,-1},{0,7},{-1,-1},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{HEXAHEDRON,{ 0, 1,9,11,12,13,22,24},{FO+0,FO+1,FO+2,1,FO+4,3},-1},
 			{HEXAHEDRON,{ 11, 9, 2,3,24,22,14,15},{FO+0,0,FO+2,FO+3,FO+4,2},
@@ -2109,27 +1398,6 @@
 			 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 
 			 {-1,-1}},  
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {{PRISM,{0,4,8,3,7,10,-1,-1},{FO+1,FO+4,1,FO+0,FO+3,-1},-1},
 		 	 {PRISM,{ 4, 5, 8,7,6,10,-1,-1},{FO+1,FO+5,2,0,FO+3,-1},
@@ -2157,27 +1425,6 @@
 			{0,0},{-1,-1},{0,0},{-1,-1},
 			{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {
 			{PRISM,{ 4, 16,0,7,18,3,-1,-1},{FO+1,FO+5,1,FO+4,FO+3,-1},-1},
@@ -2204,27 +1451,6 @@
 			{-1,-1},{-1,-1},{-1,-1},{0,7},
 			{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {
 			{HEXAHEDRON,{ 0, 1, 2,11, 4, 5, 6,19},{FO+0,FO+1,FO+2,1,FO+4,FO+5},-1},
@@ -2251,27 +1477,6 @@
 			{0,4},{-1,-1},{-1,-1},{-1,-1},
 			{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}},
 
-			/* new edges */
-		   {{3, 0, 8,-1},{3, 8, 1,-1},{3, 1, 9,-1},{3, 9, 2,-1},
-			{3, 2,10,-1},{3,10, 3,-1},{3, 3,11,-1},{3,11, 0,-1},
-			{2, 8,20, 0},{2, 9,20, 0},{2,10,20, 0},{2,11,20, 0},
-
-			{3, 0,12,-1},{2, 8,21, 1},{3, 1,13,-1},{2, 9,22, 2},
-			{3, 2,14,-1},{2,10,23, 3},{3, 3,15,-1},{2,11,24, 4},
-			{1,20,26,-1},
-
-			{2,12,21, 1},{2,21,13, 1},{2,13,22, 2},{2,22,14, 2},
-			{2,14,23, 3},{2,23,15, 3},{2,15,24, 4},{2,24,12, 4},
-			{1,21,26,-1},{1,22,26,-1},{1,23,26,-1},{1,24,26,-1},
-
-			{3,12, 4,-1},{2,21,16, 1},{3,13, 5,-1},{2,22,17, 2},
-			{3,14, 6,-1},{2,23,18, 3},{3,15, 7,-1},{2,24,19, 4},
-			{1,26,25,-1},
-
-			{3, 4,16,-1},{3,16, 5,-1},{3, 5,17,-1},{3,17, 6,-1},
-			{3, 6,18,-1},{3,18, 7,-1},{3, 7,19,-1},{3,19, 4,-1},
-			{2,16,25, 5},{2,17,25, 5},{2,18,25, 5},{2,19,25, 5}},
-
 			/* sons */
 		   {
 			{HEXAHEDRON,{ 8, 1, 2, 3,16, 5, 6, 7},{FO+0,FO+1,FO+2,FO+3,1,FO+5},-1},
@@ -2291,7 +1496,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/rm.c,v 1.87 2008/10/30 12:29:06 dmitriy Exp $",UG_RCS_STRING) ;
+static char RCS_ID("$Header$",UG_RCS_STRING) ;
 
 /****************************************************************************/
 /*                                                                          */
@@ -3011,120 +2216,6 @@
 }
 #endif /* __THREEDIM__ */
 
-#ifdef WITH_DEGENERATED_ELEM
-
-/****************************************************************************/
-/** \brief MarkForRefinementDegenerated - mark a degenerated element for refinement
-
- \param elem - element to be refined
- \param rule - type of refinement mark
-
-   This function marks a degenerated element for refinement. If the element
-   is not degenerated, the function returns 0 and does nothing. Degenerated
-   elements are refined in a special way and they cannot be the closure
-   elements. For this, they are processed separatedly.
-
-   \return <ul>
-   <li> 0 if this is not a degenerated element </li>
-   <li> -1 if the element is degenerated and processed by this function </li>
-   <li> a positive value on an error </li>
-   </ul>
-*/
-/****************************************************************************/
-INT NS_DIM_PREFIX MarkForRefinementDegenerated (ELEMENT * elem, enum RefinementRule rule)
-{
-#ifdef __TWODIM__
-    INT start_ind, n_co;
-    
-    if (! ElemIsDegenerated (elem, &start_ind))
-        return 0; /* this is a normal element, it is not processed here */
-    
-    switch (n_co = TAG (elem))
-    {
-        case (TRIANGLE):
-            switch (rule)
-            {
-                case COARSE:
-                    SETCOARSEN (elem, 1);
-                    SETMARK (elem, NO_REFINEMENT);
-                    SETMARKCLASS (elem, 0);
-                    break;
-                    
-                case NO_REFINEMENT:
-                    SETMARK (elem, NO_REFINEMENT);
-                    SETMARKCLASS (elem, 0);
-                    break;
-                
-                case COPY:
-                    SETMARK (elem, T_COPY);
-                    SETMARKCLASS (elem, RED_CLASS);
-                    break;
-                
-                case RED:
-                    start_ind = (start_ind + 2) % n_co; /* start_ind = the degener. side */
-                    switch (start_ind)
-                    {
-                        case 0: SETMARK (elem, T_BISECT_2_Q_0); break;
-                        case 1: SETMARK (elem, T_BISECT_2_Q_1); break;
-                        case 2: SETMARK (elem, T_BISECT_2_Q_2); break;
-                        default: return __LINE__;
-                    }
-                    SETMARKCLASS (elem, RED_CLASS);
-                    break;
-                
-                default:
-                    return __LINE__;
-            }
-            break;
-
-        case (QUADRILATERAL):
-            switch (rule)
-            {
-                case COARSE:
-                    SETCOARSEN (elem, 1);
-                    SETMARKCLASS (elem, 0);
-                    SETMARK (elem, NO_REFINEMENT);
-                    break;
-
-                case NO_REFINEMENT:
-                    SETMARK (elem, NO_REFINEMENT);
-                    SETMARKCLASS (elem, 0);
-                    break;
-                
-                case COPY:
-                    SETMARK (elem, Q_COPY);
-                    SETMARKCLASS (elem, RED_CLASS);
-                    break;
-                
-                case RED:
-                    start_ind = (start_ind + 1) % n_co; /* start_ind = the degener. side */
-                    switch (start_ind)
-                    {
-                        case 0: SETMARK (elem, Q_BLUE_1); break;
-                        case 1: SETMARK (elem, Q_BLUE_0); break;
-                        default: return __LINE__;
-                    }
-                    SETMARKCLASS (elem, RED_CLASS);
-                    break;
-                
-                default:
-                    return __LINE__;
-            }
-            break;
-
-        default:
-            return __LINE__;
-    }
-    
-    return -1;
-#else
-    
-    return 0; /* not implemented yet */
-    
-#endif /* __TWODIM__ */
-}
-
-#endif
 
 /****************************************************************************/
 /** \brief Mark an element for refinement
@@ -3143,10 +2234,6 @@
 
 INT NS_DIM_PREFIX MarkForRefinement (ELEMENT *theElement, enum RefinementRule rule, INT side)
 {
-    #ifdef WITH_DEGENERATED_ELEM
-    INT i;
-    #endif
-    
 	if (theElement == NULL) return(0);
 	#ifdef ModelP
 	if (EGHOST(theElement)) return(0);
@@ -3161,320 +2248,340 @@
     PRINTDEBUG(gm,4,(PFMT "MarkForRefinement() e=" EID_FMTX "rule=%d\n",
 			me,EID_PRTX(theElement),rule))
 			
-    #ifdef WITH_DEGENERATED_ELEM
-    if ((i = MarkForRefinementDegenerated (theElement, rule)) != 0)
-        return (i > 0)? GM_ERROR : GM_OK;
-    #endif
-    
 	/* choose dimension */
-    #ifdef __TWODIM__
-    /* 2D case */
-    switch (TAG(theElement))
-    {
-        case (TRIANGLE):
-            switch (rule)
-            {
-                case COARSE:
-                    SETCOARSEN(theElement,1);
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                    
-                case NO_REFINEMENT:
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                
-                case COPY:
-                    SETMARK(theElement,T_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case RED:
-                    SETMARK(theElement,T_RED);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                /* TODO: these marks must be introduced first
-                case BISECTION_3:
-                    if (side<0) return (GM_ERROR);
-                    SETMARK(theElement,TRI_BISECT_3+side%3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case BISECTION_1:
-                    if (side<0) return (GM_ERROR);
-                    SETMARK(theElement,TRI_BISECT_1+side%3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case BISECTION_2_Q:
-                    if (side<0) return (GM_ERROR);
-                    SETMARK(theElement,TRI_BISECT_2_Q+side%3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case BISECTION_2_T1:
-                    if (side<0) return (GM_ERROR);
-                    SETMARK(theElement,TRI_BISECT_2_T1+side%3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case BISECTION_2_T2:
-                    if (side<0) return (GM_ERROR);
-                    SETMARK(theElement,TRI_BISECT_2_T2+side%3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                */
-                
-                default:
-                    return(GM_ERROR);
-            }
-            break;
-
-        case (QUADRILATERAL):
-            switch (rule)
-            {
-                case COARSE:
-                    SETCOARSEN(theElement,1);
-                    SETMARKCLASS(theElement,0);
-                    SETMARK(theElement,NO_REFINEMENT);
-                    break;
-
-                case NO_REFINEMENT:
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                
-                case COPY:
-                    SETMARK(theElement,Q_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                case RED:
-                    SETMARK(theElement,Q_RED);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                /* TODO: these mark must be introduced first */
-                case BLUE:
-                    if (side<0) return (GM_ERROR);
-                    if (side%2 == 0)
-                        SETMARK(theElement,Q_BLUE_0);
-                    else
-                        SETMARK(theElement,Q_BLUE_1);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                
-                default:
-                    return(GM_ERROR);
-            }
-            break;
+	switch (DIM)
+	{
+		#ifdef __TWODIM__
+		/* 2D case */
+		case (2):
 
-        default:
-            return(GM_ERROR);
-    }
-    #endif /* __TWODIM__ */
+			switch (TAG(theElement))
+			{
+				case (TRIANGLE):
+					switch (rule)
+					{
+						case COARSE:
+							SETCOARSEN(theElement,1);
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+							
+						case NO_REFINEMENT:
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						
+						case COPY:
+							SETMARK(theElement,T_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case RED:
+							SETMARK(theElement,T_RED);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						/* TODO: these marks must be introduced first
+						case BISECTION_3:
+							if (side<0) return (GM_ERROR);
+							SETMARK(theElement,TRI_BISECT_3+side%3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case BISECTION_1:
+							if (side<0) return (GM_ERROR);
+							SETMARK(theElement,TRI_BISECT_1+side%3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case BISECTION_2_Q:
+							if (side<0) return (GM_ERROR);
+							SETMARK(theElement,TRI_BISECT_2_Q+side%3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case BISECTION_2_T1:
+							if (side<0) return (GM_ERROR);
+							SETMARK(theElement,TRI_BISECT_2_T1+side%3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case BISECTION_2_T2:
+							if (side<0) return (GM_ERROR);
+							SETMARK(theElement,TRI_BISECT_2_T2+side%3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						*/
+						
+						default:
+							return(GM_ERROR);
+					}
+					break;
+
+				case (QUADRILATERAL):
+					switch (rule)
+					{
+						case COARSE:
+							SETCOARSEN(theElement,1);
+							SETMARKCLASS(theElement,0);
+							SETMARK(theElement,NO_REFINEMENT);
+							break;
+
+						case NO_REFINEMENT:
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						
+						case COPY:
+							SETMARK(theElement,Q_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						case RED:
+							SETMARK(theElement,Q_RED);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						/* TODO: these mark must be introduced first */
+						case BLUE:
+							if (side<0) return (GM_ERROR);
+							if (side%2 == 0)
+								SETMARK(theElement,Q_BLUE_0);
+							else
+								SETMARK(theElement,Q_BLUE_1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						
+						default:
+							return(GM_ERROR);
+					}
+					break;
 
-    #ifdef __THREEDIM__
-    /* 3D case */
-    switch (TAG(theElement))
-    {
-        case (TETRAHEDRON):
-            switch(rule)
-            {
-                case (COARSE):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    SETCOARSEN(theElement,1);
-                    break;
-                case (NO_REFINEMENT):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                case (COPY):
-                    SETMARK(theElement,TET_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (RED):
-                    SETMARK(theElement,(*theFullRefRule)(theElement));
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
+				default:
+					return(GM_ERROR);
+			}
+			break;
+			#endif /* __TWODIM__ */
+
+
+		#ifdef __THREEDIM__
+		/* 3D case */
+		case (3):
+			switch (TAG(theElement))
+			{
+				case (TETRAHEDRON):
+					switch(rule)
+					{
+						case (COARSE):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							SETCOARSEN(theElement,1);
+							break;
+						case (NO_REFINEMENT):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						case (COPY):
+							SETMARK(theElement,TET_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (RED):
+							SETMARK(theElement,(*theFullRefRule)(theElement));
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
 #ifndef TET_RULESET
-                case (TETRA_RED_HEX):
-                    SETMARK(theElement,TET_RED_HEX);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
+						case (TETRA_RED_HEX):
+							SETMARK(theElement,TET_RED_HEX);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
 #endif
-                default:
-                    return(GM_ERROR);
-            }
-            break;
-
-        case (PYRAMID):
-            switch(rule)
-            {
-                case (COARSE):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    SETCOARSEN(theElement,1);
-                    break;
-                case (NO_REFINEMENT):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                case (COPY):
-                    SETMARK(theElement,PYR_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (RED):
-                    SETMARK(theElement,PYR_RED);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                default:
-                    return(GM_ERROR);
-            }
-            break;
-
-        case (PRISM):
-            switch(rule)
-            {
-                case (COARSE):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    SETCOARSEN(theElement,1);
-                    break;
-                case (NO_REFINEMENT):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                case (COPY):
-                    SETMARK(theElement,PRI_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (RED):
-                    SETMARKCLASS(theElement,RED_CLASS);
-
-                    #ifdef __ANISOTROPIC__
-                    {
-                        INT newrule;
-
-                        if (GetRule_AnisotropicRed(theElement,&newrule))
-                        {
-                            SETMARK(theElement,newrule);
-                            break;
-                        }
-                    }
-                    #endif
-
-                    SETMARK(theElement,PRI_RED);
-                    break;
-                case (PRISM_BISECT_1_2):
-                    SETMARK(theElement,PRI_BISECT_1_2);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_QUADSECT):
-                    SETMARK(theElement,PRI_QUADSECT);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_BISECT_HEX0):
-                    SETMARK(theElement,PRI_BISECT_HEX0);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_BISECT_HEX1):
-                    SETMARK(theElement,PRI_BISECT_HEX1);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_BISECT_HEX2):
-                    SETMARK(theElement,PRI_BISECT_HEX2);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_ROTATE_LEFT):
-                    SETMARK(theElement,PRI_ROT_L);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_ROTATE_RGHT):
-                    SETMARK(theElement,PRI_ROT_R);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (PRISM_QUADSECT_HEXPRI0):
-                    SETMARK(theElement,PRI_QUADSECT_HEXPRI0);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                default:
-                    return(GM_ERROR);
-            }
-            break;
-
-        case (HEXAHEDRON):
-            switch(rule)
-            {
-                case (COARSE):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    SETCOARSEN(theElement,1);
-                    break;
-                case (NO_REFINEMENT):
-                    SETMARK(theElement,NO_REFINEMENT);
-                    SETMARKCLASS(theElement,0);
-                    break;
-                case (COPY):
-                    SETMARK(theElement,HEXA_COPY);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (RED):
-                    SETMARK(theElement,HEXA_RED);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_BISECT_0_1):
-                    SETMARK(theElement,HEXA_BISECT_0_1);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_BISECT_0_2):
-                    SETMARK(theElement,HEXA_BISECT_0_2);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_BISECT_0_3):
-                    SETMARK(theElement,HEXA_BISECT_0_3);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_TRISECT_0):
-                    SETMARK(theElement,HEXA_TRISECT_0);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_TRISECT_5):
-                    SETMARK(theElement,HEXA_TRISECT_5);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_QUADSECT_0):
-                    SETMARK(theElement,HEXA_QUADSECT_0);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_QUADSECT_1):
-                    SETMARK(theElement,HEXA_QUADSECT_1);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_QUADSECT_2):
-                    SETMARK(theElement,HEXA_QUADSECT_2);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_BISECT_HEXPRI0):
-                    SETMARK(theElement,HEXA_BISECT_HEXPRI0);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                case (HEX_BISECT_HEXPRI1):
-                    SETMARK(theElement,HEXA_BISECT_HEXPRI1);
-                    SETMARKCLASS(theElement,RED_CLASS);
-                    break;
-                default:
-                    return(GM_ERROR);
-            }
-            break;
+						default:
+							return(GM_ERROR);
+					}
+					break;
+
+				case (PYRAMID):
+					switch(rule)
+					{
+						case (COARSE):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							SETCOARSEN(theElement,1);
+							break;
+						case (NO_REFINEMENT):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						case (COPY):
+							SETMARK(theElement,PYR_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (RED):
+							SETMARK(theElement,PYR_RED);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						default:
+							return(GM_ERROR);
+					}
+					break;
+
+				case (PRISM):
+					switch(rule)
+					{
+						case (COARSE):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							SETCOARSEN(theElement,1);
+							break;
+						case (NO_REFINEMENT):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						case (COPY):
+							SETMARK(theElement,PRI_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (RED):
+							SETMARKCLASS(theElement,RED_CLASS);
+
+							#ifdef __ANISOTROPIC__
+							{
+								INT newrule;
+
+								if (GetRule_AnisotropicRed(theElement,&newrule))
+								{
+									SETMARK(theElement,newrule);
+									break;
+								}
+							}
+							#endif
+
+							SETMARK(theElement,PRI_RED);
+							break;
+						case (PRISM_BISECT_1_2):
+							SETMARK(theElement,PRI_BISECT_1_2);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_QUADSECT):
+							SETMARK(theElement,PRI_QUADSECT);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_HEX0):
+							SETMARK(theElement,PRI_BISECT_HEX0);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_HEX1):
+							SETMARK(theElement,PRI_BISECT_HEX1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_HEX2):
+							SETMARK(theElement,PRI_BISECT_HEX2);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_ROTATE_LEFT):
+							SETMARK(theElement,PRI_ROT_L);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_ROTATE_RGHT):
+							SETMARK(theElement,PRI_ROT_R);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_QUADSECT_HEXPRI0):
+							SETMARK(theElement,PRI_QUADSECT_HEXPRI0);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_0_1):
+							SETMARK(theElement,PRI_BISECT_0_1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_0_2):
+							SETMARK(theElement,PRI_BISECT_0_2);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (PRISM_BISECT_0_3):
+							SETMARK(theElement,PRI_BISECT_0_3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+
+						default:
+							return(GM_ERROR);
+					}
+					break;
+
+				case (HEXAHEDRON):
+					switch(rule)
+					{
+						case (COARSE):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							SETCOARSEN(theElement,1);
+							break;
+						case (NO_REFINEMENT):
+							SETMARK(theElement,NO_REFINEMENT);
+							SETMARKCLASS(theElement,0);
+							break;
+						case (COPY):
+							SETMARK(theElement,HEXA_COPY);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (RED):
+							SETMARK(theElement,HEXA_RED);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_BISECT_0_1):
+							SETMARK(theElement,HEXA_BISECT_0_1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_BISECT_0_2):
+							SETMARK(theElement,HEXA_BISECT_0_2);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_BISECT_0_3):
+							SETMARK(theElement,HEXA_BISECT_0_3);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_TRISECT_0):
+							SETMARK(theElement,HEXA_TRISECT_0);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_TRISECT_5):
+							SETMARK(theElement,HEXA_TRISECT_5);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_QUADSECT_0):
+							SETMARK(theElement,HEXA_QUADSECT_0);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_QUADSECT_1):
+							SETMARK(theElement,HEXA_QUADSECT_1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_QUADSECT_2):
+							SETMARK(theElement,HEXA_QUADSECT_2);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_BISECT_HEXPRI0):
+							SETMARK(theElement,HEXA_BISECT_HEXPRI0);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						case (HEX_BISECT_HEXPRI1):
+							SETMARK(theElement,HEXA_BISECT_HEXPRI1);
+							SETMARKCLASS(theElement,RED_CLASS);
+							break;
+						default:
+							return(GM_ERROR);
+					}
+					break;
 
-        default:
-            return(GM_ERROR);
-    }
-    #endif /* __THREEDIM__ */
+				default:
+					return(GM_ERROR);
+			}
+			break;
+			#endif /* __THREEDIM__ */
+
+		default:
+			return(GM_ERROR);
+	}
 
 	return(GM_OK);
 }
@@ -3563,18 +2670,11 @@
 
 INT NS_DIM_PREFIX Patterns2Rules(ELEMENT *theElement, INT pattern)
 {
-    #ifdef WITH_DEGENERATED_ELEM
-    /* Do not change the element's mark if it has the same pattern: */
-    if (MARK (theElement) >= 0
-        && MARK2PAT (theElement, MARK (theElement)) == pattern)
-        return MARK (theElement);
-    #endif
-    
 	#ifdef __TWODIM__
 		switch (TAG(theElement)) {
 			case (TRIANGLE):
 				switch (pattern) {
-					/* TODO: 0 can mean T_COPY OR T_NOREF */
+                                    /** \todo 0 can mean T_COPY OR T_NOREF */
 					case (0): return(T_NOREF);
 					case (1): return(T_BISECT_1_0);
 					case (2): return(T_BISECT_1_1);
@@ -3699,8 +2799,22 @@
 						return(PRI_RED);
 					case (455):
 						return(PRI_QUADSECT);
+                                        case 56:
+                                                return PRI_BISECT_1_2;
+                                        case 65:
+                                                return PRI_BISECT_0_1;
+                                        case 130:
+                                                return PRI_BISECT_0_2;
+                                        case 260:
+                                                return PRI_BISECT_0_3;
+                                        case 325:
+                                            return PRI_BISECT_HEX0;
+                                        case 195:
+                                            return PRI_BISECT_HEX1;
+                                        case 390:
+                                            return PRI_BISECT_HEX2;
 					default:
-						PrintErrorMessage('E',"Patterns2Rules","no mapping for PRISM and this pattern!");
+                                            PrintErrorMessageF('E',"Patterns2Rules","no mapping for PRISM and pattern %d!", pattern);
 						#ifndef __ANISOTROPIC__
 						assert(0);
 						#endif
@@ -3877,34 +2991,6 @@
     return(0);
 }
 
-
-/****************************************************************************/
-/*
-   PrintEdgeData - 
-
-   SYNOPSIS:
-   static INT PrintEdgeData (struct edgedata theEdgeData);
-
-   PARAMETERS:
- \param theEdgeData
-
-   DESCRIPTION:
-
-   \return
-   INT
-*/
-/****************************************************************************/
-
-static INT PrintEdgeData (struct edgedata theEdgeData)
-{
-	UserWriteF("typ=%d from=%2d to=%2d side=%2d",(int)theEdgeData.type
-							   ,(int)theEdgeData.from
-							   ,(int)theEdgeData.to
-							   ,(int)theEdgeData.side);
-	return(0);	
-}
-
-
 /****************************************************************************/
 /*
    PrintSonData - 
@@ -4102,12 +3188,6 @@
 	for (i=0; i<16; i++)
 	{
 		if (fscanf(stream," %d %d %d %d",&type,&from,&to,&side)!=4) return (1);
-		theRule->edges[i].type = type;
-		if (from == 10) from = 14;
-		theRule->edges[i].from = from;
-		if (to == 10) to = 14;
-		theRule->edges[i].to   = to;
-		theRule->edges[i].side = side;
 	}
 	
 	/* MAX_SONS = 12 for tetrahedra */
@@ -4705,9 +3785,9 @@
 	RefRules[PYRAMID] = PyramidRules; 
 
 	/************************************************************************/
-	/*																		*/
-	/*  init refinement rules from for pyramids                         	*/
-	/*																		*/
+	/*                                                                      */
+	/*  init refinement rules for prisms                                    */
+	/*                                                                      */
 	/************************************************************************/
 
 	nRules = MAX_PRI_RULES;
@@ -4756,38 +3836,40 @@
 	if (ChangeEnvDir("/best full refrule")==NULL)
 		return(__LINE__);
 
-	newFRR = (FULLREFRULE *) MakeEnvItem("shortestie",theBFRRDirID,sizeof(FULLREFRULE));
+        theBFRRVarID = GetNewEnvVarID();
+
+	newFRR = (FULLREFRULE *) MakeEnvItem("shortestie",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = ShortestInteriorEdge;
 	
-	newFRR = (FULLREFRULE *) MakeEnvItem("maxper",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("maxper",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = MaxPerpendicular;
 	
-	newFRR = (FULLREFRULE *) MakeEnvItem("mra",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("mra",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = MaxRightAngle;
 	
-	newFRR = (FULLREFRULE *) MakeEnvItem("maxarea",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("maxarea",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = MaxArea;
 
 #ifdef __ALLRULES__
-	newFRR = (FULLREFRULE *) MakeEnvItem("minangle",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("minangle",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = MinimalSideAngle;
 	
-	newFRR = (FULLREFRULE *) MakeEnvItem("bestm",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("bestm",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = BestLaplaceMMatrix;
 	
-	newFRR = (FULLREFRULE *) MakeEnvItem("minentry",theBFRRDirID,sizeof(FULLREFRULE));
+	newFRR = (FULLREFRULE *) MakeEnvItem("minentry",theBFRRVarID,sizeof(FULLREFRULE));
 	if (newFRR==NULL)
 		return(__LINE__);
 	newFRR->theFullRefRule = MinimalSideEntry;
@@ -4871,7 +3953,7 @@
 
 	/* get storage for Pattern2Rule */
 	nPatterns = 17; /* there are 2^3 different patterns */
-	/* TODO: delete all concerning Pattern2Rule */
+	/** \todo delete all concerning Pattern2Rule */
 	Pattern2Rule[TRIANGLE] = (SHORT *) malloc(nPatterns*sizeof(SHORT));
 	if (Pattern2Rule[TRIANGLE]==NULL)
 	{
@@ -4905,7 +3987,7 @@
 
 	/* get storage for Pattern2Rule */
 	nPatterns = 32; /* there are 2^5 different patterns */
-	/* TODO: delete all concerning Pattern2Rule */
+	/** \todo delete all concerning Pattern2Rule */
 	Pattern2Rule[QUADRILATERAL] = (SHORT *) malloc(nPatterns*sizeof(SHORT));
 	if (Pattern2Rule[QUADRILATERAL]==NULL)
 	{
diff -ruN ug-orig/gm/rm.h ug-patched/gm/rm.h
--- ug-orig/gm/rm.h	2006-11-13 10:34:16.000000000 +0100
+++ ug-patched/gm/rm.h	2007-05-29 09:18:14.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/rm.h,v 1.46 2006/11/13 09:34:16 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -35,7 +35,6 @@
 #ifndef __RULEMANAGER__
 #define __RULEMANAGER__
 
-#include "compiler.h"
 #include "gm.h"
 #include "refine.h"
 
@@ -56,11 +55,11 @@
 /* Declaration of TET_RULESET has been moved to config.h */
 /* uncomment this if you want to use the full rule set for tetrahedra */
 
-/* defines for edge types */
-#define INNER_EDGE          1
-#define SIDE_EDGE           2
-#define HALF_FATHER_EDGE    3
-#define FATHER_EDGE         4
+/** \brief Defines for edge types */
+enum {INNER_EDGE        = 1,
+      SIDE_EDGE         = 2,
+      HALF_FATHER_EDGE  = 3,
+      FATHER_EDGE       = 4};
 
 #define NEXTSIDEMASKHEX         0x00000007
 #define NEXTSIDEHEX(i,n)        (((i) & (NEXTSIDEMASKHEX<<(3*(n))))>>(3*(n)))
@@ -134,43 +133,43 @@
 #define MARKED(e)               (MARK(e)!=NO_REFINEMENT)
 #define LEAFELEM(e)                     (!IS_REFINED(e))
 
-/* indices of rules in rule array */
-#define T_NOREF                         0
-#define T_COPY                  1
-#define T_RED                           2
-#define T_BISECT_1_0            3
-#define T_BISECT_1_1            4
-#define T_BISECT_1_2            5
-#define T_BISECT_2_T1_0         7
-#define T_BISECT_2_T1_1         8
-#define T_BISECT_2_T1_2         6
-#define T_BISECT_2_T2_0         11
-#define T_BISECT_2_T2_1         9
-#define T_BISECT_2_T2_2         10
-#define T_BISECT_2_Q_0          12
-#define T_BISECT_2_Q_1          13
-#define T_BISECT_2_Q_2          14
-#define T_BISECT_3_0            15
-#define T_BISECT_3_1            16
-#define T_BISECT_3_2            17
-
-#define Q_NOREF                         0
-#define Q_COPY                          1
-#define Q_RED                           2
-#define Q_CLOSE_1_0                     3
-#define Q_CLOSE_1_1                     4
-#define Q_CLOSE_1_2                     5
-#define Q_CLOSE_1_3                     6
-#define Q_BLUE_0                        7
-#define Q_BLUE_1                        8
-#define Q_CLOSE_2_0                     9
-#define Q_CLOSE_2_1                     10
-#define Q_CLOSE_2_2                     11
-#define Q_CLOSE_2_3                     12
-#define Q_CLOSE_3_0                     13
-#define Q_CLOSE_3_1                     14
-#define Q_CLOSE_3_2                     15
-#define Q_CLOSE_3_3                     16
+/** \brief Indices of rules in rule array */
+enum {T_NOREF               = 0,
+      T_COPY                = 1,
+      T_RED                 = 2,
+      T_BISECT_1_0          = 3,
+      T_BISECT_1_1          = 4,
+      T_BISECT_1_2          = 5,
+      T_BISECT_2_T1_0       = 7,
+      T_BISECT_2_T1_1       = 8,
+      T_BISECT_2_T1_2       = 6,
+      T_BISECT_2_T2_0       = 11,
+      T_BISECT_2_T2_1       = 9,
+      T_BISECT_2_T2_2       = 10,
+      T_BISECT_2_Q_0        = 12,
+      T_BISECT_2_Q_1        = 13,
+      T_BISECT_2_Q_2        = 14,
+      T_BISECT_3_0          = 15,
+      T_BISECT_3_1          = 16,
+      T_BISECT_3_2          = 17};
+
+enum {Q_NOREF,
+      Q_COPY,
+      Q_RED,
+      Q_CLOSE_1_0,
+      Q_CLOSE_1_1,
+      Q_CLOSE_1_2,
+      Q_CLOSE_1_3,
+      Q_BLUE_0,
+      Q_BLUE_1,
+      Q_CLOSE_2_0,
+      Q_CLOSE_2_1,
+      Q_CLOSE_2_2,
+      Q_CLOSE_2_3,
+      Q_CLOSE_3_0,
+      Q_CLOSE_3_1,
+      Q_CLOSE_3_2,
+      Q_CLOSE_3_3};
 
 #define TET_COPY                        1
 #ifdef TET_RULESET
@@ -194,33 +193,38 @@
 #define TET_RED_HEX                     5
 #endif
 
-#define PYR_COPY                        1
-#define PYR_RED                         2
-
-#define PRI_COPY                        1
-#define PRI_RED                         2
-#define PRI_QUADSECT            3
-#define PRI_BISECT_1_2      7
-#define PRI_BISECT_HEX0         8
-#define PRI_BISECT_HEX1         9
-#define PRI_BISECT_HEX2         10
-#define PRI_RED_HEX                     11
-#define PRI_ROT_L                       12
-#define PRI_ROT_R                       13
-#define PRI_QUADSECT_HEXPRI0 14
-
-#define HEXA_COPY                       1
-#define HEXA_RED                        2
-#define HEXA_BISECT_0_1     3
-#define HEXA_BISECT_0_2     4
-#define HEXA_BISECT_0_3     5
-#define HEXA_QUADSECT_0     6
-#define HEXA_QUADSECT_1     7
-#define HEXA_QUADSECT_2     8
-#define HEXA_TRISECT_0      9
-#define HEXA_TRISECT_5      10
-#define HEXA_BISECT_HEXPRI0 11
-#define HEXA_BISECT_HEXPRI1 12
+enum {PYR_COPY       = 1,
+      PYR_RED        = 2,
+      PYR_BISECT_0_1 = 3,
+      PYR_BISECT_0_2 = 4};
+
+enum {PRI_COPY             = 1,
+      PRI_RED              = 2,
+      PRI_QUADSECT         = 3,
+      PRI_BISECT_0_1       = 4,
+      PRI_BISECT_0_2       = 5,
+      PRI_BISECT_0_3       = 6,
+      PRI_BISECT_1_2       = 7,
+      PRI_BISECT_HEX0      = 8,
+      PRI_BISECT_HEX1      = 9,
+      PRI_BISECT_HEX2      = 10,
+      PRI_RED_HEX          = 11,
+      PRI_ROT_L            = 12,
+      PRI_ROT_R            = 13,
+      PRI_QUADSECT_HEXPRI0 = 14};
+
+enum {HEXA_COPY           = 1,
+      HEXA_RED            = 2,
+      HEXA_BISECT_0_1     = 3,
+      HEXA_BISECT_0_2     = 4,
+      HEXA_BISECT_0_3     = 5,
+      HEXA_QUADSECT_0     = 6,
+      HEXA_QUADSECT_1     = 7,
+      HEXA_QUADSECT_2     = 8,
+      HEXA_TRISECT_0      = 9,
+      HEXA_TRISECT_5      = 10,
+      HEXA_BISECT_HEXPRI0 = 11,
+      HEXA_BISECT_HEXPRI1 = 12};
 
 
 /****************************************************************************/
@@ -229,29 +233,15 @@
 /*                                                                                                                                                      */
 /****************************************************************************/
 
-/* Hacks for HITACHI SR2201 will be eliminated as soon as the HITACHI
-   compiler bug is removed */
-
 #define TAG_OF_RULE(r)              ((r)->tag)
 #define MARK_OF_RULE(r)             ((r)->mark)
-#ifdef __SR2201__
-#define CLASS_OF_RULE(r)            ((*(r)).rclass)
-#define NSONS_OF_RULE(r)            ((*(r)).nsons)
-#define SON_OF_RULE(r,s)            (&((*(r)).sons[(s)]))
-#else
 #define CLASS_OF_RULE(r)            ((r)->rclass)
 #define NSONS_OF_RULE(r)            ((r)->nsons)
 #define SON_OF_RULE(r,s)            (&((r)->sons[(s)]))
-#endif
 #define PATTERN_OF_RULE(r,i)            ((r)->pattern[(i)])
 #define PAT_OF_RULE(r)                          ((r)->pat)
 #define SON_OF_NODE_OF_RULE(r,n)        ((r)->sonandnode[(n)][0])
 #define SONNODE_OF_NODE_OF_RULE(r,n)((r)->sonandnode[(n)][0])
-#define EDGE_OF_RULE(r,e)                       (&((r)->edges[(e)]))
-#define EDGE_TYPE_OF_RULE(r,e)          ((r)->edges[(e)].type)
-#define EDGE_FROM_OF_RULE(r,e)          ((r)->edges[(e)].from)
-#define EDGE_TO_OF_RULE(r,e)            ((r)->edges[(e)].to)
-#define EDGE_SIDE_OF_RULE(r,e)          ((r)->edges[(e)].side)
 #define SON_TAG_OF_RULE(r,s)            ((r)->sons[(s)].tag)
 #define SON_TAG(s)                                      ((s)->tag)
 #define SON_CORNER_OF_RULE(r,s,n)       ((r)->sons[(s)].corners[(n)])
@@ -290,31 +280,14 @@
 typedef INT (*FULLREFRULEPTR) (ELEMENT *);
 
 typedef struct {
-        INT type;                              /* one of the variable types above          */
-        INT locked;                            /* may not be changed or deleted            */
-        union envitem *next;
-        union envitem *previous;               /* double linked list of environment items  */
-        char name[NS_PREFIX NAMESIZE];                   /* name of that item (view)                 */
+    /** \brief Fields for environment list variable */
+    NS_PREFIX ENVVAR v;
 
         /* full ref rule spezific stuff */
         FULLREFRULEPTR theFullRefRule;         /* the best full refrule                    */
 
 } FULLREFRULE;
 
-/* 
-   edge type  : 1 = inner edge of the father
-                2 = inner edge of one side (3D only)
-                3 = half an edge of the father element
-                4 = edge of the father itself
-*/
-
-struct edgedata{
-        SHORT type;                /* interior edge of the tetra or only of one side        */
-        SHORT from;                /* indices of the first endpoint (0..9 for t)            */
-        SHORT to;                  /* indices of the second endpoint (4..9 for t)           */
-        SHORT side;                /* side, for which edge is interior, if type 2 (3D only) */
-};
-
 struct sondata{
         SHORT  tag;                              /* which element type is the son                           */
         SHORT  corners[MAX_CORNERS_OF_ELEM_DIM]; /* corners of the son                                  */
@@ -333,12 +306,10 @@
         INT                 pat;                                /* bitwise format of pattern               */
         SHORT           sonandnode[MAX_NEW_CORNERS_DIM][2]; /* for each new node the number of the son */
                                                                                                         /* and the local node number of the node   */
-        struct edgedata edges[MAX_NEW_EDGES_DIM];
         struct sondata  sons[MAX_SONS_DIM];
 };
 
 typedef struct sondata SONDATA;
-typedef struct edgedata EDGEDATA;
 typedef struct refrule REFRULE;
 
 
diff -ruN ug-orig/gm/shapes2d.c ug-patched/gm/shapes2d.c
--- ug-orig/gm/shapes2d.c	1995-11-15 19:47:24.000000000 +0100
+++ ug-patched/gm/shapes2d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,852 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  shapes.c														*/
-/*																			*/
-/* Purpose:   shape functions for triangles and quadrilaterals				*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   08.04.92 begin, ug version 2.0								*/
-/*			  20.11.94 moved shapes.c from ug to cd folder					*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <math.h>
-#include <assert.h>
-
-#include "compiler.h"
-#include "misc.h"
-#include "gm.h"
-#include "evm.h"
-#include "shapes2d.h"
-
-
-#ifdef __THREEDIM__
-#error this source file is for 2D ONLY
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/shapes2d.c,v 1.4 1995/11/15 18:47:24 wieners Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*D
-   N - Shape function
-
-   SYNOPSIS:
-   DOUBLE N (int n, int i, DOUBLE s, DOUBLE t);
-
-   PARAMETERS:
-.  n - number of sides (3 for triangle, 4 for quadrangle)
-.  i - corner number (corner number [0..n-1])
-.  s,t - local DOUBLEinates
-
-   DESCRIPTION:
-   This function finds the linear shape functions Ni(s,t) to approximate the
-   solution u in the integration point ip for triangles and quadrilaterals
-   
-.n   uip(s,t) = SUM Ni(s,t)*ui
-
-   where the sum runs over all nodes of the element to which the considered
-   ip belongs. The shape function is defined as
-   
-   - for all elements who do not have the node i as a corner
-.n   Ni = 0
-
-   - for the elements
-.n   Ni(node i) = 1
-.n   Ni(node k) = 0, if k is not equal i.
-   
-   RETURN VALUE:
-   DOUBLE
-.n          value
-D*/   
-/****************************************************************************/
-
-DOUBLE N (int n, int i, DOUBLE s, DOUBLE t)
-{
-	if (n==3)
-	{
-		switch (i)
-		{
-			case 0 : return(1-s-t);
-			case 1 : return(s);
-			case 2 : return(t);
-		}
-	}
-	else if (n==4)
-	{
-		switch (i)
-		{
-			case 0 : return(0.25*(1-s)*(1-t));
-			case 1 : return(0.25*(1+s)*(1-t));
-			case 2 : return(0.25*(1+s)*(1+t));
-			case 3 : return(0.25*(1-s)*(1+t));
-		}
-	}
-	
-	/* ERROR: i<0 || i>=n */
-	return (-1.0);
-}
-
-/****************************************************************************/
-/*D
-   dNds	-  Partial derivative of shape function	
-
-   SYNOPSIS:
-   DOUBLE dNds (int n, int i, DOUBLE s, DOUBLE t);
-
-   PARAMETERS:
-.  n - number of sides (3 for triangle, 4 for quadrangle)
-.  i - corner number [0..n-1]
-.  s - local DOUBLEinates
-.  t - local DOUBLEinates
-
-   DESCRIPTION:
-   This function calculates the partial derivative of the shape function Ni(s,t) 
-   with respect to s.		
-
-   RETURN VALUE:
-   DOUBLE											
-.n          value
-D*/
-/****************************************************************************/
-
-DOUBLE dNds (int n, int i, DOUBLE s, DOUBLE t)
-{
-	if (n==3)
-	{
-		switch (i)
-		{
-			case 0 : return(-1);
-			case 1 : return(1);
-			case 2 : return(0);
-		}
-	}
-	else if (n==4)
-	{
-		switch (i)
-		{
-			case 0 : return(-0.25*(1-t));
-			case 1 : return(0.25*(1-t));
-			case 2 : return(0.25*(1+t));
-			case 3 : return(-0.25*(1+t));
-		}
-	}
-	
-	/* ERROR: i<0 || i>=n */
-	return (-1.0);
-}
-
-/****************************************************************************/
-/*D
-   dNdt	- Partial derivative of shape function	
-
-   SYNOPSIS:
-   DOUBLE dNdt (int n, int i, DOUBLE s, DOUBLE t);
-
-   PARAMETERS:
-.  n - number of sides (for triangle, 4 for quadrangle)
-.  i - corner number [0..n-1]
-.  s - local DOUBLEinates				
-.  t - local DOUBLEinates	
-
-   DESCRIPTION:
-   This function calculates the partial derivative of the shape function Ni(s,t) 
-   with respect to t.												
-
-   RETURN VALUE:
-   DOUBLE
-.n          value
-D*/
-/****************************************************************************/
-
-DOUBLE dNdt (int n, int i, DOUBLE s, DOUBLE t)
-{
-	if (n==3)
-	{
-		switch (i)
-		{
-			case 0 : return(-1);
-			case 1 : return(0);
-			case 2 : return(1);
-		}
-	}
-	else if (n==4)
-	{
-		switch (i)
-		{
-			case 0 : return(-0.25*(1-s));
-			case 1 : return(-0.25*(1+s));
-			case 2 : return(0.25*(1+s));
-			case 3 : return(0.25*(1-s));
-		}
-	}
-	
-	/* ERROR: i<0 || i>=n */
-	return (-1.0);
-}
-
-/****************************************************************************/
-/*D
-   Derivatives - Compute partial derivatives of the shape functions and 
-   determinant of coordinate transformation
-
-   SYNOPSIS:
-   int Derivatives (int n, const DOUBLE *px, const DOUBLE *py, DOUBLE ips, 
-   DOUBLE ipt, DOUBLE *dNdx, DOUBLE *dNdy, DOUBLE *DetJ);
-
-   PARAMETERS:
-.  n - number of sides (3 for triangle, 4 for quadrangle)
-.  px - x,y DOUBLEinates of corners
-.  py - x,y DOUBLEinates of corners
-.  ips - location to compute derivatives in s,t DOUBLE
-.  ipt - location to compute derivatives in s,t DOUBLE
-.  dNdx - output array for derivatives
-.  dNdy - output array for derivatives
-.  DetJ - determinant of coordinate transformation
-
-   DESCRIPTION:
-   This function computes the partial derivatives of the shape 
-   functions with respect to x,y coordinates at a given 
-   point (ips,ipt) in s,t DOUBLEinates. 
-   It is used to compute derivatives	of variables 
-   in the interior of an element at specific locations. Furthermore 
-   the determinant of coordinate transformation is calculated.
-
-   RETURN VALUE:
-   int
-.n    0 if ok 
-.n    1 if determinant of coordinate transformation too small.
-D*/
-/****************************************************************************/
-
-int Derivatives (int n, const DOUBLE *px, const DOUBLE *py, DOUBLE ips, DOUBLE ipt, DOUBLE *dNdx, DOUBLE *dNdy, DOUBLE *DetJ)
-{
-	DOUBLE dydt,dyds,dxdt,dxds,detJ;
-	int j;
-	
-	dydt = 0.0; for (j=0; j<n; j++) dydt += dNdt(n,j,ips,ipt)*py[j];
-	dyds = 0.0; for (j=0; j<n; j++) dyds += dNds(n,j,ips,ipt)*py[j];
-	dxdt = 0.0; for (j=0; j<n; j++) dxdt += dNdt(n,j,ips,ipt)*px[j];
-	dxds = 0.0; for (j=0; j<n; j++) dxds += dNds(n,j,ips,ipt)*px[j];
-	detJ = dxds*dydt-dyds*dxdt;
-	if (fabs(detJ)<=SMALL_D) return(1);
-	for (j=0; j<n; j++)
-	{
-		dNdx[j] = ( dydt*dNds(n,j,ips,ipt)-dyds*dNdt(n,j,ips,ipt))/detJ;
-		dNdy[j] = (-dxdt*dNds(n,j,ips,ipt)+dxds*dNdt(n,j,ips,ipt))/detJ;
-	}
-	*DetJ = detJ;
-	return(0);
-}
-/****************************************************************************/
-/*D
-   Gradients - Compute gradients of the shape functions and 
-   determinant of coordinate transformation	
-
-   SYNOPSIS:
-   INT Gradients (INT n, const COORD **theCorners, DOUBLE ips, DOUBLE ipt, 
-   DOUBLE_VECTOR Gradient[MAX_CORNERS_OF_ELEM], DOUBLE *DetJ);
-
-   PARAMETERS:
-.  n - number of sides (3 for triangle, 4 for quadrangle)
-.  theCorners - coordinates of the element corners
-.  ips - location to compute derivatives in s,t DOUBLE
-.  ipt - location to compute derivatives in s,t DOUBLE
-.  Gradient - output array for gradients 
-.  DetJ - determinant of coordinate transformation
-
-   DESCRIPTION:
-   This function computes gradients of the shape functions with respect to 
-   x,y Coordinates at a given point (ips,ipt) and the determinant of 
-   coordinate transformation.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok 
-.n    1 if determinant of coordinate transformation too small. 
-D*/
-/****************************************************************************/
-
-INT Gradients (INT n, const COORD **theCorners, DOUBLE ips, DOUBLE ipt, DOUBLE_VECTOR Gradient[MAX_CORNERS_OF_ELEM], DOUBLE *DetJ)
-{
-	DOUBLE dydt,dyds,dxdt,dxds,detJ;
-	int j;
-	
-	dydt = 0.0; for (j=0; j<n; j++) dydt += dNdt(n,j,ips,ipt)*theCorners[j][1];
-	dyds = 0.0; for (j=0; j<n; j++) dyds += dNds(n,j,ips,ipt)*theCorners[j][1];
-	dxdt = 0.0; for (j=0; j<n; j++) dxdt += dNdt(n,j,ips,ipt)*theCorners[j][0];
-	dxds = 0.0; for (j=0; j<n; j++) dxds += dNds(n,j,ips,ipt)*theCorners[j][0];
-	detJ = dxds*dydt-dyds*dxdt;
-	if (fabs(detJ)<=SMALL_D) return(1);
-	for (j=0; j<n; j++)
-	{
-		Gradient[j][_X_] = ( dydt*dNds(n,j,ips,ipt)-dyds*dNdt(n,j,ips,ipt))/detJ;
-		Gradient[j][_Y_] = (-dxdt*dNds(n,j,ips,ipt)+dxds*dNdt(n,j,ips,ipt))/detJ;
-	}
-	*DetJ = detJ;
-	return(0);
-}
-/************************************************************/
-/*D
-   COORD x_dot_y - Computes the scalar product in 2D
-
-   SYNOPSIS:
-   static COORD x_dot_y (const COORD x[2], const COORD y[2]);
-
-   PARAMETERS:
-.  x[2] - coordinates of a point
-.  y[2] - coordinates of a point
-
-   DESCRIPTION:
-   This function computes the scalar product of two coordinate
-   vectors in two dimensions.
-
-   RETURN VALUE:
-   COORD (x[0]*y[0]+x[1]*y[1])
-D*/
-/***********************************************************/
-static COORD x_dot_y (const COORD x[2], const COORD y[2])
-{
-	return (x[0]*y[0]+x[1]*y[1]);
-}
-
-/************************************************************/
-/*D
-   x_dot_normal_to_y - dot product in 2D
-
-   SYNOPSIS:
-   static COORD x_dot_normal_to_y (const COORD x[2], const COORD y[2]);
-
-   PARAMETERS:
-.  x[2] - coordinates of a point     
-.  y[2] - coordinates of a point
-
-   DESCRIPTION:
-   This function computes the dot product of two coordinate vectors 
-   in two dimensions.
-
-   RETURN VALUE:
-   COORD (x[0]*y[1]-x[1]*y[0])
-D*/
-/***********************************************************/
-static COORD x_dot_normal_to_y (const COORD x[2], const COORD y[2])
-{
-	return (x[0]*y[1]-x[1]*y[0]);
-}
-
-/************************************************************/
-/*D
-   set_x_plus_ay - Adds two coordinate vectors
-
-   SYNOPSIS:
-   static INT set_x_plus_ay (COORD res[2], const COORD x[2], const COORD s, 
-   const COORD y[2]);
-
-   PARAMETERS:
-.  res[2] - result of adding two coordinate vectors
-.  x[2] - coordinates of a point
-.  s - scalar for multiplication
-.  y[2] - coordinates of a point
-
-   DESCRIPTION:
-   This function computes the sum of two coordinate vectors where
-   one vector before is multplied with a scalar.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if operation failed.   
-D*/
-/***********************************************************/
-static INT set_x_plus_ay (COORD res[2], const COORD x[2], const COORD s, const COORD y[2])
-{
-	res[0] = x[0]+s*y[0];
-	res[1] = x[1]+s*y[1];
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   LocalToGlobal2d - Transform local coordinates to global 												
-
-   SYNOPSIS:
-   INT LocalToGlobal2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, 
-   COORD_VECTOR GlobalCoord);
-
-   PARAMETERS:
-.  n - corner number (3 or 4) 
-.  Corners - coordinates of corners
-.  EvalPoint - local coordinates
-.  GlobalCoord - resulting global coordinates
-
-   DESCRIPTION:
-   This function computes the shape functions in an evaluated point and transforms
-   the local coordinates to global in triangular and quadrilateral elements.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok 
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT LocalToGlobal2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR GlobalCoord)
-{
-	COORD N0,N1,N2,N3;
-	
-	if (n==3)
-	{
-		N0 = N(3,0,EvalPoint[0],EvalPoint[1]);
-		N1 = N(3,1,EvalPoint[0],EvalPoint[1]);
-		N2 = N(3,2,EvalPoint[0],EvalPoint[1]);
-		V2_LINCOMB(N0,Corners[0],N1,Corners[1],GlobalCoord)
-		V2_LINCOMB(1.0,GlobalCoord,N2,Corners[2],GlobalCoord)
-		return (0);
-	}
-	if (n==4)
-	{
-		N0 = N(4,0,EvalPoint[0],EvalPoint[1]);
-		N1 = N(4,1,EvalPoint[0],EvalPoint[1]);
-		N2 = N(4,2,EvalPoint[0],EvalPoint[1]);
-		N3 = N(4,3,EvalPoint[0],EvalPoint[1]);
-		V2_LINCOMB(N0,Corners[0],N1,Corners[1],GlobalCoord)
-		V2_LINCOMB(1.0,GlobalCoord,N2,Corners[2],GlobalCoord)
-		V2_LINCOMB(1.0,GlobalCoord,N3,Corners[3],GlobalCoord)
-		return (0);
-	}
-	return (1);
-}
-
-/****************************************************************************/
-/*D
-   L2GDerivative2d - Derivative of LocalToGlobal2d
-
-   SYNOPSIS:
-   INT L2GDerivative2d (INT n, const COORD **Corners,
-   const COORD_VECTOR EvalPoint, COORD *Derivative);
-
-   PARAMETERS:
-.  n - corner number  
-.  Corners - coordinates of corners
-.  EvalPoint - local coordinates
-.  Derivative - df1/ds, df2/ds, df1/dt, df2/dt   
-
-   DESCRIPTION:
-   This function calculates the derivates of the shape functions in an
-   evaluated point and transforms the local coordinates of the derivates to 
-   global in triangular and quadrilateral elements.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-
-   SEE ALSO:
-   LocalToGlobal2d
-D*/
-/****************************************************************************/
-
-INT L2GDerivative2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD *Derivative)
-{
-	COORD dNds0,dNds1,dNds2,dNds3;
-	COORD dNdt0,dNdt1,dNdt2,dNdt3;
-	
-	if (n==3)
-	{
-		dNds0 = dNds(3,0,EvalPoint[0],EvalPoint[1]);
-		dNds1 = dNds(3,1,EvalPoint[0],EvalPoint[1]);
-		dNds2 = dNds(3,2,EvalPoint[0],EvalPoint[1]);
-		dNdt0 = dNdt(3,0,EvalPoint[0],EvalPoint[1]);
-		dNdt1 = dNdt(3,1,EvalPoint[0],EvalPoint[1]);
-		dNdt2 = dNdt(3,2,EvalPoint[0],EvalPoint[1]);
-		V2_LINCOMB(dNds0,Corners[0],dNds1,Corners[1],Derivative)
-		V2_LINCOMB(1.0,Derivative,dNds2,Corners[2],Derivative)
-		V2_LINCOMB(dNdt0,Corners[0],dNdt1,Corners[1],Derivative+2)
-		V2_LINCOMB(1.0,Derivative+2,dNdt2,Corners[2],Derivative+2)
-		return (0);
-	}
-	if (n==4)
-	{
-		dNds0 = dNds(4,0,EvalPoint[0],EvalPoint[1]);
-		dNds1 = dNds(4,1,EvalPoint[0],EvalPoint[1]);
-		dNds2 = dNds(4,2,EvalPoint[0],EvalPoint[1]);
-		dNds3 = dNds(4,3,EvalPoint[0],EvalPoint[1]);
-		dNdt0 = dNdt(4,0,EvalPoint[0],EvalPoint[1]);
-		dNdt1 = dNdt(4,1,EvalPoint[0],EvalPoint[1]);
-		dNdt2 = dNdt(4,2,EvalPoint[0],EvalPoint[1]);
-		dNdt3 = dNdt(4,3,EvalPoint[0],EvalPoint[1]);
-		V2_LINCOMB(dNds0,Corners[0],dNds1,Corners[1],Derivative)
-		V2_LINCOMB(1.0,Derivative,dNds2,Corners[2],Derivative)
-		V2_LINCOMB(1.0,Derivative,dNds3,Corners[3],Derivative)
-		V2_LINCOMB(dNdt0,Corners[0],dNdt1,Corners[1],Derivative+2)
-		V2_LINCOMB(1.0,Derivative+2,dNdt2,Corners[2],Derivative+2)
-		V2_LINCOMB(1.0,Derivative+2,dNdt3,Corners[3],Derivative+2)
-		return (0);
-	}
-	return (1);
-}
-
-/****************************************************************************/
-/*D
-   GlobalToLocal2d - Transforms global coordinates to local 
-
-   SYNOPSIS:
-   INT GlobalToLocal2d (INT n, const COORD **Corners, 
-   const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord);
-
-   PARAMETERS:
-.  n - corner number
-.  Corners - coordinates of the element corners
-.  EvalPoint - global coordinates
-.  LocalCoord - resulting local coordinates
-
-   DESCRIPTION:
-   This function transforms global coordinates to local in triangular and
-   quadrilateral element. The global point has to be inside the triangle/quadrilateral.
-
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
-/****************************************************************************/
-
-INT GlobalToLocal2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord)
-{
-	COORD xs[2],xt[2],xst[2],x0[2],aux1[2],aux2[2];
-	COORD xtdnxst,xsdnxst,a,b,c,t1,t2;
-	COORD t1x,t2x,t3x,t1y,t2y,t3y,D;
-	
-	
-	if (n==3)
-	{
-		/* its a triangle */
-		t1x = Corners[1][0]-Corners[0][0];
-		t2x = Corners[2][0]-Corners[0][0];
-		t3x = Corners[0][0];
-		t1y = Corners[1][1]-Corners[0][1];
-		t2y = Corners[2][1]-Corners[0][1];
-		t3y = Corners[0][1];
-		
-		D = t1x*t2y-t2x*t1y;
-		
-		if (D<0.0)
-			return(1);
-		
-		LocalCoord[0] = (t2y*(EvalPoint[0]-t3x)-t2x*(EvalPoint[1]-t3y))/D;
-		LocalCoord[1] = (-t1y*(EvalPoint[0]-t3x)+t1x*(EvalPoint[1]-t3y))/D;
-		
-		return (0);
-	}
-	
-	if (n!=4)
-		return (2);
-	
-	/* coeefficients of the local coordinates s,t in the bilinear form:
-	   EvalPoint = sum_i N_i(s,t) Corners_i */
-	
-	/* vector from center of mass to EvalPoint */
-	x0[0]  = EvalPoint[0] - 0.25 * ( Corners[0][0]+Corners[1][0]+Corners[2][0]+Corners[3][0]);
-	x0[1]  = EvalPoint[1] - 0.25 * ( Corners[0][1]+Corners[1][1]+Corners[2][1]+Corners[3][1]);
-	
-	/* vector from mid of side 3 to side 1 */
-	xs[0]  = 0.25 * (-Corners[0][0]+Corners[1][0]+Corners[2][0]-Corners[3][0]);
-	xs[1]  = 0.25 * (-Corners[0][1]+Corners[1][1]+Corners[2][1]-Corners[3][1]);
-	
-	/* vector from mid of side 2 to side 0 */
-	xt[0]  = 0.25 * (-Corners[0][0]-Corners[1][0]+Corners[2][0]+Corners[3][0]);
-	xt[1]  = 0.25 * (-Corners[0][1]-Corners[1][1]+Corners[2][1]+Corners[3][1]);
-	
-	/* vector from mid of diagonal 1 to diagonal 0 */
-	xst[0] = 0.25 * ( Corners[0][0]-Corners[1][0]+Corners[2][0]-Corners[3][0]);
-	xst[1] = 0.25 * ( Corners[0][1]-Corners[1][1]+Corners[2][1]-Corners[3][1]);
-	
-	
-	/* scalarproducts with normal vectors (if vanishing ==> vectors parallel) */
-	xtdnxst = x_dot_normal_to_y(xt,xst);
-	xsdnxst = x_dot_normal_to_y(xs,xst);
-	
-	/* NB: xs || xt only in the degenerate case */
-	
-	/* case 1: xst = (0,0)-vector --- this is the case of a parallelogram */
-	if (x_dot_y(xst,xst)<SMALL_C)
-	{
-		a = x_dot_normal_to_y(xs,xt);
-		
-		LocalCoord[0] =  x_dot_normal_to_y(x0,xt) / a;
-		LocalCoord[1] = -x_dot_normal_to_y(x0,xs) / a;		/* xddny = -nxdy */
-		
-		return (0);
-	}
-	
-	/* case 2: xs || xst --- this is the case of a trapezoid, side 0 parallel side 2 */
-	if (fabs(xsdnxst)<SMALL_C)
-	{
-		LocalCoord[1] = x_dot_normal_to_y(x0,xst) / xtdnxst;
-		
-		set_x_plus_ay(aux1,x0,-LocalCoord[1],xt);
-		set_x_plus_ay(aux2,xs,LocalCoord[1],xst);
-		
-		LocalCoord[0] = x_dot_y(aux1,aux2) / x_dot_y(aux2,aux2);
-		
-		return (0);
-	}
-	
-	/* case 3: xt || xst --- this is the case of a trapezoid, side 1 parallel side 3 */
-	if (fabs(xtdnxst)<SMALL_C)
-	{
-		LocalCoord[0] = x_dot_normal_to_y(x0,xst) / xsdnxst;
-		
-		set_x_plus_ay(aux1,x0,-LocalCoord[0],xs);
-		set_x_plus_ay(aux2,xt,LocalCoord[0],xst);
-		
-		LocalCoord[1] = x_dot_y(aux1,aux2) / x_dot_y(aux2,aux2);
-		
-		return (0);
-	}
-	
-	/* the general case */
-	a = 0.5*(x_dot_normal_to_y(xt,xs) - x_dot_normal_to_y(x0,xst)) / xtdnxst;
-	b = -x_dot_normal_to_y(x0,xs) / xtdnxst;
-	c = a*a - b;
-	
-	if (c<0.0)
-		return (3);
-	c = sqrt(c);
-	
-	t1 = -a + c;
-	t2 = -a - c;
-	
-	if ((-1.1<=t1) && (t1<=1.1))
-	{
-		LocalCoord[1] = t1;
-		
-		set_x_plus_ay(aux1,x0,-t1,xt);
-		LocalCoord[0] = x_dot_normal_to_y(aux1,xst) / xsdnxst;
-	}
-	else if ((-1.1<=t2) && (t2<=1.1))
-	{
-		LocalCoord[1] = t2;
-		
-		set_x_plus_ay(aux1,x0,-t2,xt);
-		LocalCoord[0] = x_dot_normal_to_y(aux1,xst) / xsdnxst;
-	}
-	else
-		return (4);
-	
-	if ((-1.1<=LocalCoord[0]) && (LocalCoord[0]<=1.1))
-		return (0);
-	else
-		return (5);
-}
-
-/* in the specialGlobalToLocal2d the global point has not to be inside the triangle/quadrilateral */
-/**************************************************************/
-/*D
-   specialGlobalToLocal2d - Transforms global coordinates to local
-
-   SYNOPSIS:
-   INT specialGlobalToLocal2d (INT n, const COORD **Corners, 
-   const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord);
-
-   PARAMETERS:
-.  n - corner number
-.  Corners - coordinates of corners
-.  EvalPoint - global coordinates
-.  LocalCoord - resulting local coordinates
-
-   DESCRIPTION:
-   This function transforms global coordinates to local in triangular and
-   quadrilateral element. The global point has not to be inside the triangle/quadrilateral.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-D*/
-/***************************************************************/
-INT specialGlobalToLocal2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord)
-{
-	COORD xs[2],xt[2],xst[2],x0[2],aux1[2],aux2[2];
-	COORD xtdnxst,xsdnxst,a,b,c,t1,t2,s1,s2;
-	COORD t1x,t2x,t3x,t1y,t2y,t3y,D;
-	
-	
-	if (n==3)
-	{
-		/* its a triangle */
-		t1x = Corners[1][0]-Corners[0][0];
-		t2x = Corners[2][0]-Corners[0][0];
-		t3x = Corners[0][0];
-		t1y = Corners[1][1]-Corners[0][1];
-		t2y = Corners[2][1]-Corners[0][1];
-		t3y = Corners[0][1];
-		
-		D = t1x*t2y-t2x*t1y;
-		
-		if (D<0.0)
-			return(1);
-		
-		LocalCoord[0] = (t2y*(EvalPoint[0]-t3x)-t2x*(EvalPoint[1]-t3y))/D;
-		LocalCoord[1] = (-t1y*(EvalPoint[0]-t3x)+t1x*(EvalPoint[1]-t3y))/D;
-		
-		return (0);
-	}
-	
-	if (n!=4)
-		return (2);
-	
-	/* coeefficients of the local coordinates s,t in the bilinear form:
-	   EvalPoint = sum_i N_i(s,t) Corners_i */
-	
-	/* center of mass */
-	x0[0]  = EvalPoint[0] - 0.25 * ( Corners[0][0]+Corners[1][0]+Corners[2][0]+Corners[3][0]);
-	x0[1]  = EvalPoint[1] - 0.25 * ( Corners[0][1]+Corners[1][1]+Corners[2][1]+Corners[3][1]);
-	
-	/* vector from mid of side 3 to side 1 */
-	xs[0]  = 0.25 * (-Corners[0][0]+Corners[1][0]+Corners[2][0]-Corners[3][0]);
-	xs[1]  = 0.25 * (-Corners[0][1]+Corners[1][1]+Corners[2][1]-Corners[3][1]);
-	
-	/* vector from mid of side 2 to side 0 */
-	xt[0]  = 0.25 * (-Corners[0][0]-Corners[1][0]+Corners[2][0]+Corners[3][0]);
-	xt[1]  = 0.25 * (-Corners[0][1]-Corners[1][1]+Corners[2][1]+Corners[3][1]);
-	
-	/* vector from mid of diagonal 1 to diagonal 0 */
-	xst[0] = 0.25 * ( Corners[0][0]-Corners[1][0]+Corners[2][0]-Corners[3][0]);
-	xst[1] = 0.25 * ( Corners[0][1]-Corners[1][1]+Corners[2][1]-Corners[3][1]);
-	
-	
-	/* scalarproducts with normal vectors (if vanishing ==> vectors parallel) */
-	xtdnxst = x_dot_normal_to_y(xt,xst);
-	xsdnxst = x_dot_normal_to_y(xs,xst);
-	
-	/* NB: xs || xt only in the degenerate case */
-	
-	/* case 1: xst = (0,0)-vector --- this is the case of a parallelogram */
-	if (x_dot_y(xst,xst)<SMALL_C)
-	{
-		a = x_dot_normal_to_y(xs,xt);
-		LocalCoord[0] =  x_dot_normal_to_y(x0,xt) / a;
-		LocalCoord[1] = -x_dot_normal_to_y(x0,xs) / a;		/* xddny = -nxdy */
-		
-		return (0);
-	}
-	
-	/* case 2: xs || xst --- this is the case of a trapezoid, side 0 parallel side 2 */
-	if (fabs(xsdnxst)<SMALL_C)
-	{
-		LocalCoord[1] = x_dot_normal_to_y(x0,xst) / xtdnxst;
-		
-		set_x_plus_ay(aux1,x0,-LocalCoord[1],xt);
-		set_x_plus_ay(aux2,xs,LocalCoord[1],xst);
-		
-		LocalCoord[0] = x_dot_y(aux1,aux2) / x_dot_y(aux2,aux2);
-		
-		return (0);
-	}
-	
-	/* case 3: xt || xst --- this is the case of a trapezoid, side 1 parallel side 3 */
-	if (fabs(xtdnxst)<SMALL_C)
-	{
-		LocalCoord[0] = x_dot_normal_to_y(x0,xst) / xsdnxst;
-		
-		set_x_plus_ay(aux1,x0,-LocalCoord[0],xs);
-		set_x_plus_ay(aux2,xt,LocalCoord[0],xst);
-		
-		LocalCoord[1] = x_dot_y(aux1,aux2) / x_dot_y(aux2,aux2);
-		
-		return (0);
-	}
-	
-	/* the general case */
-	a = 0.5*(x_dot_normal_to_y(xt,xs) - x_dot_normal_to_y(x0,xst)) / xtdnxst;
-	b = -x_dot_normal_to_y(x0,xs) / xtdnxst;
-	c = a*a - b;
-	
-	if (c<0.0)
-		return (3);
-	c = sqrt(c);
-	
-	/* first solution */
-	t1 = -a + c;
-	set_x_plus_ay(aux1,x0,-t1,xt);
-	s1 = x_dot_normal_to_y(aux1,xst) / xsdnxst;
-	
-	/* second solution */
-	t2 = -a - c;
-	set_x_plus_ay(aux1,x0,-t2,xt);
-	s2 = x_dot_normal_to_y(aux1,xst) / xsdnxst;
-	
-	/* take the one next to the origin */
-	if ((s1*s1+t1*t1) < (s2*s2+t2*t2))
-	{
-		LocalCoord[0] = s1;
-		LocalCoord[1] = t1;
-	}
-	else
-	{
-		LocalCoord[0] = s2;
-		LocalCoord[1] = t2;
-	}
-	
-	return (0);
-}
diff -ruN ug-orig/gm/shapes2d.h ug-patched/gm/shapes2d.h
--- ug-orig/gm/shapes2d.h	1996-02-27 11:21:29.000000000 +0100
+++ ug-patched/gm/shapes2d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,115 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  shapes.h														*/
-/*																			*/
-/* Purpose:   header file for shape functions								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   29.01.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __SHAPES2D__
-#define __SHAPES2D__
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define DNDS(n,i,s,t,r) 		if (n==3)\
-								{\
-									switch (i)\
-									{\
-										case 0 : r=-1.0; break;\
-										case 1 : r=1.0; break;\
-										case 2 : r=0.0; break;\
-									}\
-								}\
-								else if (n==4)\
-								{\
-									switch (i)\
-									{\
-										case 0 : r=-0.25*(1-t); break;\
-										case 1 : r=0.25*(1-t); break;\
-										case 2 : r=0.25*(1+t); break;\
-										case 3 : r=-0.25*(1+t); break;\
-									}\
-								}
-
-#define DNDT(n,i,s,t,r)		    if (n==3)\
-								{\
-									switch (i)\
-									{\
-										case 0 : r=-1; break;\
-										case 1 : r=0; break;\
-										case 2 : r=1; break;\
-									}\
-								}\
-								else if (n==4)\
-								{\
-									switch (i)\
-									{\
-										case 0 : r=-0.25*(1-s); break;\
-										case 1 : r=-0.25*(1+s); break;\
-										case 2 : r=0.25*(1+s); break;\
-										case 3 : r=0.25*(1-s); break;\
-									}\
-								}
-
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-DOUBLE	N				(int n, int i, DOUBLE s, DOUBLE t);
-DOUBLE	dNds			(int n, int i, DOUBLE s, DOUBLE t);
-DOUBLE	dNdt			(int n, int i, DOUBLE s, DOUBLE t);
-
-int 	Derivatives 	(int n, const DOUBLE *px, const DOUBLE *py, DOUBLE ips, DOUBLE ipt, DOUBLE *dNdx, DOUBLE *dNdy, DOUBLE *detJ);
-INT		Gradients		(INT n, const COORD **theCorners, DOUBLE ips, DOUBLE ipt, DOUBLE_VECTOR Gradient[MAX_CORNERS_OF_ELEM], DOUBLE *DetJ);
-
-INT		L2GDerivative2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD *Derivative);
-INT		LocalToGlobal2d	(INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR GlobalCoord);
-INT 	GlobalToLocal2d (INT n,const  COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord);
-INT		specialGlobalToLocal2d (INT n, const COORD **Corners, const COORD_VECTOR EvalPoint, COORD_VECTOR LocalCoord);
-
-#endif
diff -ruN ug-orig/gm/shapes3d.c ug-patched/gm/shapes3d.c
--- ug-orig/gm/shapes3d.c	1996-03-13 12:43:36.000000000 +0100
+++ ug-patched/gm/shapes3d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,1912 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  shapes3d.c														*/
-/*																			*/
-/* Purpose:   shape functions for triangles and quadrangles 				*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   08.04.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <math.h>
-#include <assert.h>
-
-#include "compiler.h"
-#include "misc.h"
-
-#include "evm.h"
-#include "shapes3d.h"
-#include "simplex.h"
-
-#ifdef __TWODIM__
-#error this source file is for 3D ONLY
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/shapes3d.c,v 1.7 1996/03/13 11:43:36 peter Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*D
-   N - Shape function
-
-   SYNOPSIS:
-   DOUBLE N (INT i, COORD *LocalCoord);
-
-   PARAMETERS:
-.  i - corner number [0..3]
-.  LocalCoord - local coordinates
-  
-   DESCRIPTION:
-   This function finds the linear shape functions Ni(s,t) to approximate the
-   solution u in the integration point ip for tetrahedrons
-   
-.n   uip(s,t) = SUM Ni(s,t)*ui
-
-   where the sum runs over all nodes of the element to which the considered
-   ip belongs. 
-
-   RETURN VALUE:
-   DOUBLE
-D*/
-/****************************************************************************/
-
-DOUBLE N (const INT i, const COORD *LocalCoord)
-{
-	switch (i)
-	{
-		case 0 : return((DOUBLE)(1.0-LocalCoord[0]-LocalCoord[1]-LocalCoord[2]));
-		case 1 : return((DOUBLE)LocalCoord[0]);
-		case 2 : return((DOUBLE)LocalCoord[1]);
-		case 3 : return((DOUBLE)LocalCoord[2]);
-	}
-	
-	/* error */
-	assert(FALSE);
-	return (-1);
-}
-
-/****************************************************************************/
-/*D
-   GlobalToLocal3d - Transform global coordinates to local
-
-   SYNOPSIS:
-   INT GlobalToLocal3d (COORD **Corners,COORD *EvalPoint, 
-   COORD *LocalCoord);
-
-   PARAMETERS:
-.  Corners - coordinates of corners 
-.  EvalPoint - global coordinates
-.  LocalCoord - local coordinates 
-
-   DESCRIPTION:
-   This function transforms global coordinates to local in an evaluated point
-   in 3D.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT GlobalToLocal3d (const COORD **Corners, const COORD *EvalPoint, COORD *LocalCoord)
-{
-	COORD_VECTOR a;
-	COORD M[9],I[9];
-
-	V3_SUBTRACT(EvalPoint,Corners[0],a)
-	V3_SUBTRACT(Corners[1],Corners[0],M)
-	V3_SUBTRACT(Corners[2],Corners[0],M+3)
-	V3_SUBTRACT(Corners[3],Corners[0],M+6)
-	if (M3_Invert(I,M)) return (1);
-	M3_TIMES_V3(I,a,LocalCoord)
-
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   TetraSideNormals - Calculate inner normals of tetrahedra
-
-   SYNOPSIS:
-   INT TetraSideNormals (COORD **theCorners, COORD_VECTOR theNormals[MAX_SIDES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  theNormals - normals of tetrahedra
-
-   DESCRIPTION:
-   This function calculates the inner normals on the sides of a tetrahedron.	
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT TetraSideNormals (const COORD **theCorners, COORD_VECTOR theNormals[MAX_SIDES_OF_ELEM])
-{
-	COORD_VECTOR a, b;
-	COORD h;
-	INT j,k;
-
-	for (j=0; j<MAX_CORNERS_OF_ELEM; j++)
-	{
-		k = OppositeSide[j];
-		V3_SUBTRACT(theCorners[(j+1)%MAX_CORNERS_OF_ELEM],theCorners[(j+2)%MAX_CORNERS_OF_ELEM],a)
-		V3_SUBTRACT(theCorners[(j+1)%MAX_CORNERS_OF_ELEM],theCorners[(j+3)%MAX_CORNERS_OF_ELEM],b)
-		V3_VECTOR_PRODUCT(a,b,theNormals[k])
-		V3_Normalize(theNormals[k]);
-		V3_SUBTRACT(theCorners[j],theCorners[(j+1)%MAX_CORNERS_OF_ELEM],a)
-		V3_SCALAR_PRODUCT(theNormals[k],a,h);
-		if (ABS(h)<SMALL_C) return (1);
-		if (h<0.0)
-			V3_SCALE(-1.0,theNormals[k]);
-	}
-
-	return (0);
-
-}
-
-/****************************************************************************/
-/*D
-   TetMaxSideAngle - Calculate maximal side angle of Tetrahedron
-
-   SYNOPSIS:
-   INT TetMaxSideAngle (COORD **theCorners, COORD *MaxAngle);
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  MaxAngle - max side angle
-
-   DESCRIPTION:
-   This function calculates the maximal side angle of the tetrahedron.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT TetMaxSideAngle (const COORD **theCorners, COORD *MaxAngle)
-{
-	COORD_VECTOR theNormal[MAX_SIDES_OF_ELEM];
-	COORD max,help;
-	INT i;
-
-	if (TetraSideNormals (theCorners,theNormal)) return (1);
-	max = -1.0;
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		V3_SCALAR_PRODUCT(theNormal[SideWithEdge[i][0]],theNormal[SideWithEdge[i][1]],help)
-		max = MAX(help,max);
-	}
-	max = MIN(max,1.0);
-	*MaxAngle = 180.0/PI*acos(-max);
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   TetAngleAndLength - Calculates side angle and length of edge of Tetrahedron
-
-   SYNOPSIS:
-   INT TetAngleAndLength (COORD **theCorners, COORD *Angle, COORD *Length);
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  Angle - side angle
-.  Length - sidelength
-
-   DESCRIPTION:
-   This function calculates the side angle of a tetrahedron and the lengths of 
-   the edges belonging to this side.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT TetAngleAndLength (const COORD **theCorners, COORD *Angle, COORD *Length)
-{
-	COORD_VECTOR theNormals[MAX_SIDES_OF_ELEM],theEdge[MAX_EDGES_OF_ELEM];
-	COORD h;
-	INT j,k;
-
-	for (j=0; j<MAX_EDGES_OF_ELEM; j++)
-	{
-		V3_SUBTRACT(theCorners[CornerOfEdge[j][1]],theCorners[CornerOfEdge[j][0]],theEdge[j])
-		V3_EUKLIDNORM(theEdge[j],Length[j])
-	}
-	for (j=0; j<MAX_SIDES_OF_ELEM; j++)
-	{
-		V3_VECTOR_PRODUCT(theEdge[EdgeOfSide[j][0]],theEdge[EdgeOfSide[j][1]],theNormals[j])
-		V3_Normalize(theNormals[j]);
-		k = EdgesOfCorner[OppositeCorner[j]][0];
-		V3_SCALAR_PRODUCT(theNormals[j],theEdge[k],h)
-		if (ABS(h)<SMALL_C) return (1);
-		if ( (h<0.0 && CornerOfEdge[k][1]==OppositeCorner[j]) ||
-			 (h>0.0 && CornerOfEdge[k][0]==OppositeCorner[j])	 )
-			V3_SCALE(-1.0,theNormals[j]);
-	}
-	for (j=0; j<MAX_EDGES_OF_ELEM; j++)
-	{
-		V3_SCALAR_PRODUCT(theNormals[SideWithEdge[j][0]],theNormals[SideWithEdge[j][1]],Angle[j])
-		Angle[j] = MAX(Angle[j],-1.0);
-		Angle[j] = MIN(Angle[j], 1.0);
-		Angle[j] = (COORD)acos((double)Angle[j]);
-	}
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   TetraDerivative - Calculates gradient of shape function for tetrahedron
-
-   SYNOPSIS:
-   INT TetraDerivative (COORD **theCorners, COORD_VECTOR theGradient[MAX_CORNERS_OF_ELEM])
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  theGradient - gradients of shape functions
-
-   DESCRIPTION:
-   This function calculates the gradient of shape function for tetrahedron.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT TetraDerivative (const COORD **theCorners, COORD_VECTOR theGradient[MAX_CORNERS_OF_ELEM])
-{
-	COORD_VECTOR a, b;
-	COORD h;
-	INT j;
-
-	for (j=0; j<MAX_CORNERS_OF_ELEM; j++)
-	{
-		V3_SUBTRACT(theCorners[(j+1)%4],theCorners[(j+2)%4],a)
-		V3_SUBTRACT(theCorners[(j+1)%4],theCorners[(j+3)%4],b)
-		V3_VECTOR_PRODUCT(a,b,theGradient[j])
-		V3_Normalize(theGradient[j]);
-		V3_SUBTRACT(theCorners[j],theCorners[(j+1)%4],a)
-		V3_SCALAR_PRODUCT(theGradient[j],a,h)
-		if (ABS(h)<SMALL_C) return (1);
-		V3_SCALE(1/h,theGradient[j])
-	}
-
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   TetraVolume - Calculate volume of tetrahedron
-
-   SYNOPSIS:
-   INT TetraVolume (COORD **theCorners, COORD *volume);
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  volume - volume of tetrahedron
-
-   DESCRIPTION:
-   This function calculates the volume of a tetrahedron.	
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT TetraVolume (const COORD **theCorners, COORD *volume)
-{
-	COORD_VECTOR a, b, n;
-
-	/* compute volume of tetrahedron */
-	V3_SUBTRACT(theCorners[0],theCorners[1],a)
-	V3_SUBTRACT(theCorners[0],theCorners[2],b)
-	V3_VECTOR_PRODUCT(a,b,n)
-	V3_SUBTRACT(theCorners[0],theCorners[3],a)
-	V3_SCALAR_PRODUCT(n,a,volume[0])
-	*volume = ABS(*volume)/6;
-	
-	return (0); 
-}
-
-/****************************************************************************/
-/*D
-   FV_TetInfo - Calculate control volume subsurfaces and global integration points
-
-   SYNOPSIS:
-   INT FV_TetInfo (COORD **theCorners, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], 
-   COORD_VECTOR GIP[MAX_EDGES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - coordinates of the element corners
-.  Area - area of subsurface
-.  GIP - global integration point
-
-   DESCRIPTION:
-   This function calculates the subsurfaces (SCV) of the control volume (CV) in 
-   tetrahedron elements. The global integration points are computed in the 
-   center of mass on these subsurfaces.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT FV_TetInfo (const COORD **theCorners, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], COORD_VECTOR GIP[MAX_EDGES_OF_ELEM])
-{
-	COORD_VECTOR emp[MAX_EDGES_OF_ELEM], diff, a, b;
-	COORD sp;
-	INT i;
-
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		V3_LINCOMB(0.5,theCorners[CornerOfEdge[i][0]],0.5,theCorners[CornerOfEdge[i][1]],emp[i])
-		V3_SUBTRACT (theCorners[CornerOfOppEdge[i][0]],emp[i],a)
-		V3_SUBTRACT (theCorners[CornerOfOppEdge[i][1]],emp[i],b)
-		V3_VECTOR_PRODUCT(a,b,Area[i])
-		V3_SUBTRACT (theCorners[CornerOfEdge[i][1]],theCorners[CornerOfEdge[i][0]],diff)
-		V3_SCALAR_PRODUCT(Area[i],diff,sp)
-		if (sp>0.0)
-			V3_SCALE(1/12.0,Area[i])
-		else
-			V3_SCALE(-1/12.0,Area[i])
-	}
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-		V3_LINCOMB(17.0/24.0,emp[i],7.0/24.0,emp[OppositeEdge[i]],GIP[i])
-
-	return (0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  FV_AliTetInfo													*/
-/*																			*/
-/* Purpose:   calc gradient of shape function i 							*/
-/*																			*/
-/* Input:	  int i: corner number [0..3]									*/
-/*			  COORD **Corners: list of ptrs to phys corner vectors			*/
-/*																			*/
-/* Output:	  COORD **theGradient: list of ptrs to gradients				*/
-/*																			*/
-/* Return:	  INT 0: ok 													*/
-/*				  1: error													*/
-/*																			*/
-/****************************************************************************/
-
-static INT FindCrossParam3D (const COORD_VECTOR p1, const COORD_VECTOR p2, const COORD_VECTOR p3, const COORD_VECTOR p4, DOUBLE_VECTOR v, COORD_VECTOR param)
-{
-	COORD M[9], I[9];
-	
-	V3_SUBTRACT(p1,p2,M)
-	V3_SUBTRACT(p4,p3,M+3)
-	V3_COPY(v,M+6)
-	if (M3_Invert(I,M))
-		return (1);
-	V3_SUBTRACT(p1,p3,M)
-	M3_TIMES_V3(I,M,param)
-	
-	return (0);
-}
-
-static INT MirrorAtPlane (const COORD *in, const COORD *pp, const COORD *pn, COORD *out)
-{
-	COORD_VECTOR a;
-	
-	V3_SUBTRACT(pp,in,a)
-	if (V3_Project(a,pn,out))
-	V3_LINCOMB(1.0,in,2.0,out,out)
-	
-	return (0);
-}
-
-#define V3_TRI_CM(a,b,c,e)			   {(e)[0] = 0.333333333333*((a)[0]+(b)[0]+(c)[0]);\
-										(e)[1] = 0.333333333333*((a)[1]+(b)[1]+(c)[1]);\
-										(e)[2] = 0.333333333333*((a)[2]+(b)[2]+(c)[2]);}
-#define V3_QUA_CM(a,b,c,d,e)		   {(e)[0] = 0.25*((a)[0]+(b)[0]+(c)[0]+(d)[0]);\
-										(e)[1] = 0.25*((a)[1]+(b)[1]+(c)[1]+(d)[1]);\
-										(e)[2] = 0.25*((a)[2]+(b)[2]+(c)[2]+(d)[2]);}
-
-INT FV_AliTetInfo (const COORD **CornerPoints, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv, COORD_VECTOR GIP[MAX_EDGES_OF_ELEM], COORD_VECTOR LIP[MAX_EDGES_OF_ELEM])
-{
-	COORD sp, alpha, check[2], M[9], Inv[9];
-	COORD_VECTOR a, b, c, d, e, cm, normal, param, EdgeMidPoints[6], SideMidPoints[4];
-	INT i, help, noutflow, ninflow, outflow[4], inflow[4], OpEdge[3], GrEdge[3], side[3], OpCorner, corner[3], inverted, First;
-	INT BackEdge, FrontEdge, BackCorner[2], FrontCorner[2], EdgeF0B0, EdgeF0B1, EdgeF1B0, EdgeF1B1, flags, changed;
-	
-	/* reset areas and integrationpoints */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		V3_CLEAR(Area[i])
-		V3_CLEAR(GIP[i])
-		V3_COPY(LIP[i],LIP[i])
-	}
-	
-	/* edge mid points */
-	for (i=0; i<6; i++)	V3_LINCOMB(0.5,CornerPoints[CornerOfEdge[i][0]],0.5,CornerPoints[CornerOfEdge[i][1]],EdgeMidPoints[i])
-			
-	/* side mid points */
-	for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-	{
-		V3_ADD(CornerPoints[CornerOfSide[i][0]],CornerPoints[CornerOfSide[i][1]],a)
-		V3_ADD(CornerPoints[CornerOfSide[i][2]],a,SideMidPoints[i])
-		V3_SCALE(0.33333333333333333,SideMidPoints[i])
-	}
-
-	/* in/outflow sides */
-	noutflow = ninflow = 0;
-	for (i=0; i<4; i++)
-	{
-		V3_SUBTRACT(CornerPoints[CornerOfSide[i][1]],CornerPoints[CornerOfSide[i][0]],a)
-		V3_SUBTRACT(CornerPoints[CornerOfSide[i][2]],CornerPoints[CornerOfSide[i][0]],b)
-		V3_VECTOR_PRODUCT(a,b,normal)
-		V3_SUBTRACT(CornerPoints[OppositeCorner[i]],CornerPoints[CornerOfSide[i][0]],a)
-		V3_SCALAR_PRODUCT(a,normal,sp)
-		if (sp>0.0) V3_SCALE(-1.0,normal)
-		V3_SCALAR_PRODUCT(conv,normal,sp)
-		if (sp>=0.0) 	outflow[noutflow++] = i;
-		if (sp<0.0)		inflow[ninflow++] = i;
-	}
-	
-	/* check */
-	check[0]=check[1]=0.0;
-	for (i=0; i<ninflow; i++)
-	{
-		V3_SUBTRACT(CornerPoints[CornerOfSide[inflow[i]][1]],CornerPoints[CornerOfSide[inflow[i]][0]],a)
-		V3_SUBTRACT(CornerPoints[CornerOfSide[inflow[i]][2]],CornerPoints[CornerOfSide[inflow[i]][0]],b)
-		V3_VECTOR_PRODUCT(a,b,normal)
-		V3_SCALAR_PRODUCT(conv,normal,sp)
-		check[0] += ABS(0.5*sp);
-	}
-	for (i=0; i<noutflow; i++)
-	{
-		V3_SUBTRACT(CornerPoints[CornerOfSide[outflow[i]][1]],CornerPoints[CornerOfSide[outflow[i]][0]],a)
-		V3_SUBTRACT(CornerPoints[CornerOfSide[outflow[i]][2]],CornerPoints[CornerOfSide[outflow[i]][0]],b)
-		V3_VECTOR_PRODUCT(a,b,normal)
-		V3_SCALAR_PRODUCT(conv,normal,sp)
-		check[1] += ABS(0.5*sp);
-	}
-	assert((check[0]-check[1])<=1e-6*(check[0]+check[1]));
-
-	/* change if inflow > outflow */
-	inverted = 0;
-	if (ninflow>noutflow)
-	{
-		inverted = 1;
-		for (i=0; i<ninflow; i++)	{help = inflow[i]; inflow[i] = outflow[i]; outflow[i] = help;}
-		help = ninflow; ninflow = noutflow; noutflow = help;
-	}
-	if ( ninflow+noutflow!=4 || ninflow<1 || ninflow>2) 
-		return (1);
-		
-	/* handle different cases */
-	switch (ninflow)
-	{
-		case 2:
-			/* two in-, two outflow */
-			BackEdge = EdgeOf2Sides[inflow[0]][inflow[1]];
-			FrontEdge = EdgeOf2Sides[outflow[0]][outflow[1]];
-			BackCorner[0] = CornerOfSideAndEdge[outflow[0]][FrontEdge];
-			BackCorner[1] = CornerOfSideAndEdge[outflow[1]][FrontEdge];
-			FrontCorner[0] = CornerOfSideAndEdge[inflow[0]][BackEdge];
-			FrontCorner[1] = CornerOfSideAndEdge[inflow[1]][BackEdge];
-			EdgeF0B0 = EdgeWithCorners[FrontCorner[0]][BackCorner[0]];
-			EdgeF0B1 = EdgeWithCorners[FrontCorner[0]][BackCorner[1]];
-			EdgeF1B0 = EdgeWithCorners[FrontCorner[1]][BackCorner[0]];
-			EdgeF1B1 = EdgeWithCorners[FrontCorner[1]][BackCorner[1]];
-			
-			if (FindCrossParam3D(CornerPoints[FrontCorner[0]],CornerPoints[FrontCorner[1]],CornerPoints[BackCorner[0]],CornerPoints[BackCorner[1]],conv,param)) return (1);
-			if (param[0]<0.0 || param[0]>1.0 || param[1]<0.0 || param[1]>1.0)
-				i=i;
-			changed=0;
-			if (param[0]<0.5)
-			{
-				param[0]=1.0-param[0];
-				help=inflow[0]; inflow[0]=inflow[1]; inflow[1]=help;
-				changed=1;
-			}
-			if (param[1]<0.5)
-			{
-				param[1]=1.0-param[1];
-				help=outflow[0]; outflow[0]=outflow[1]; outflow[1]=help;
-				changed=1;
-			}
-			if (changed)
-			{
-				BackCorner[0] = CornerOfSideAndEdge[outflow[0]][FrontEdge];
-				BackCorner[1] = CornerOfSideAndEdge[outflow[1]][FrontEdge];
-				FrontCorner[0] = CornerOfSideAndEdge[inflow[0]][BackEdge];
-				FrontCorner[1] = CornerOfSideAndEdge[inflow[1]][BackEdge];
-				EdgeF0B0 = EdgeWithCorners[FrontCorner[0]][BackCorner[0]];
-				EdgeF0B1 = EdgeWithCorners[FrontCorner[0]][BackCorner[1]];
-				EdgeF1B0 = EdgeWithCorners[FrontCorner[1]][BackCorner[0]];
-				EdgeF1B1 = EdgeWithCorners[FrontCorner[1]][BackCorner[1]];
-			}
-			flags = (param[0]>0.5) | ((param[1]>0.5)<<1);
-			switch (flags)
-			{
-				case 0:
-					/* totaly symmetric */
-					V3_SUBTRACT(CornerPoints[BackCorner[1]],CornerPoints[BackCorner[0]],a)
-					V3_SUBTRACT(CornerPoints[FrontCorner[1]],CornerPoints[FrontCorner[0]],b)
-					V3_VECTOR_PRODUCT(a,b,c)
-					V3_SCALE(0.041666666666666666,c) V3_COPY(c,d)
-					V3_SCALAR_PRODUCT(conv,c,sp)
-					if (sp>0.0) V3_SCALE(-1.0,d)
-					else 		{V3_SCALE(-1.0,c); sp = -sp;}
-					
-					V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],EdgeMidPoints[BackEdge],GIP[EdgeF0B0])
-					if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])		V3_COPY(d,Area[EdgeF0B0])
-					else												V3_COPY(c,Area[EdgeF0B0])
-			
-					V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF0B1],EdgeMidPoints[BackEdge],GIP[EdgeF0B1])
-					if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])		V3_COPY(d,Area[EdgeF0B1])
-					else												V3_COPY(c,Area[EdgeF0B1])
-					
-					V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B0],EdgeMidPoints[BackEdge],GIP[EdgeF1B0])
-					if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])		V3_COPY(d,Area[EdgeF1B0])
-					else												V3_COPY(c,Area[EdgeF1B0])
-
-					V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF1B1],EdgeMidPoints[BackEdge],GIP[EdgeF1B1])
-					if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])		V3_COPY(d,Area[EdgeF1B1])
-					else												V3_COPY(c,Area[EdgeF1B1])
-					break;
-				case 1:
-					/* FrontEdgeMidPoint in 'inflow[0]' ,symmetric in 'outflow' */
-					if (param[0]<=0.75)
-					{
-						/* no coupling of F0 and F1 */
-						
-						/* entries F1B0 and F1B1 */
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],EdgeMidPoints[EdgeF1B0],a)
-						V3_SUBTRACT(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALE(0.5,c) V3_COPY(c,d)
-						V3_SCALAR_PRODUCT(conv,c,sp)
-						if (sp>0.0) V3_SCALE(-1.0,d)
-						else 		{V3_SCALE(-1.0,c); sp = -sp;}
-						
-						V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B0],EdgeMidPoints[FrontEdge],GIP[EdgeF1B0])
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B0])
-						else											V3_COPY(c,Area[EdgeF1B0])
-						
-						V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF1B1],EdgeMidPoints[FrontEdge],GIP[EdgeF1B1])
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B1])
-						else											V3_COPY(c,Area[EdgeF1B1])
-						
-						/* entries F0B0 and F0B1 */
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],EdgeMidPoints[EdgeF0B0],a)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALE(0.5,c) V3_COPY(c,d)
-						V3_SCALAR_PRODUCT(conv,c,sp)
-						if (sp>0.0) V3_SCALE(-1.0,d)
-						else 		{V3_SCALE(-1.0,c); sp = -sp;}
-						
-						V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],EdgeMidPoints[FrontEdge],GIP[EdgeF0B0])
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])	V3_COPY(d,Area[EdgeF0B0])
-						else											V3_COPY(c,Area[EdgeF0B0])
-
-						V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF0B1],EdgeMidPoints[FrontEdge],GIP[EdgeF0B1])
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])	V3_COPY(d,Area[EdgeF0B1])
-						else											V3_COPY(c,Area[EdgeF0B1])
-					}
-					else
-					{
-						/* coupling of F0 and F1 */
-						
-						/* entries for F0F1, F0B0, F0B1 */
-						if (FindCrossParam3D(EdgeMidPoints[FrontEdge],SideMidPoints[outflow[0]],SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF0B0],conv,param)) return (1);
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],SideMidPoints[outflow[0]],a)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF0B0],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) {V3_SCALE(-1.0,c); sp = -sp;}
-
-						V3_LINCOMB(0.5,SideMidPoints[inflow[0]],0.5,EdgeMidPoints[FrontEdge],GIP[FrontEdge])
-						V3_COPY(c,Area[FrontEdge])
-						if (CornerOfEdge[FrontEdge][0]==FrontCorner[1]) alpha = -param[0]*param[1];
-						else											alpha = param[0]*param[1];
-						V3_SCALE(alpha,Area[FrontEdge])
-
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[FrontEdge],param[0],SideMidPoints[outflow[0]],a)
-						V3_TRI_CM(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],a,GIP[EdgeF0B0])
-						V3_COPY(c,Area[EdgeF0B0])
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF0B0])
-						V3_COPY(c,Area[EdgeF0B1])
-
-							
-						V3_SUBTRACT(CornerPoints[FrontCorner[1]],CornerPoints[FrontCorner[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],CornerPoints[FrontCorner[0]],b)
-						V3_VECTOR_PRODUCT(a,b,d)
-						if (MirrorAtPlane(GIP[EdgeF0B0],CornerPoints[FrontCorner[0]],d,GIP[EdgeF0B1])) return (1);
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF0B1])
-						
-						/* entries for F1B0, F1B1 */
-						V3_COPY(c,d) alpha=0.5*(1.0-param[0])*param[1]; V3_SCALE(alpha,d)
-
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[FrontEdge],param[0],SideMidPoints[outflow[0]],a)
-						V3_TRI_CM(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],a,GIP[EdgeF1B0])
-						V3_SCALE(sp*alpha,GIP[EdgeF1B0])
-					
-						V3_SUBTRACT(SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF1B0],a)
-						V3_SUBTRACT(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) {V3_SCALE(-0.5,c);sp=-sp;} else V3_SCALE(0.5,c)
-						V3_ADD(c,d,c) V3_COPY(c,d) V3_SCALE(-1.0,d)
-							
-						
-						V3_QUA_CM(SideMidPoints[outflow[0]],SideMidPoints[inflow[1]],EdgeMidPoints[EdgeF1B0],SideMidPoints[inflow[0]],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF1B0],0.5*sp,cm,GIP[EdgeF1B0])
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B0])
-						else											V3_COPY(c,Area[EdgeF1B0])
-						V3_SCALAR_PRODUCT(conv,Area[EdgeF1B0],sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF1B0])
-
-						V3_SUBTRACT(CornerPoints[FrontCorner[1]],CornerPoints[FrontCorner[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],CornerPoints[FrontCorner[0]],b)
-						V3_VECTOR_PRODUCT(a,b,e)
-						if (MirrorAtPlane(GIP[EdgeF1B0],CornerPoints[FrontCorner[0]],e,GIP[EdgeF1B1])) return (1);
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B1])
-						else											V3_COPY(c,Area[EdgeF1B1])
-							
-						/* the local upwind intergration points */
-						V3_COPY(TRefCoord[FrontCorner[0]],LIP[FrontEdge])
-					}
-					break;
-				case 2:
-					/* FrontEdgeMidPoint in 'outflow[1]' ,symmetric in 'inflow' */
-					if (param[1]<=0.75)
-					{
-						/* no coupling of B0 and B1 */
-						
-						/* entries for F0B1 and F1B1 */
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],EdgeMidPoints[EdgeF0B1],a)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],SideMidPoints[outflow[1]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALE(0.5,c) V3_COPY(c,d)
-						V3_SCALAR_PRODUCT(conv,c,sp)
-						if (sp>0.0) V3_SCALE(-1.0,d)
-						else 		V3_SCALE(-1.0,c)
-						
-						V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF0B1],EdgeMidPoints[BackEdge],GIP[EdgeF0B1])
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])	V3_COPY(d,Area[EdgeF0B1])
-						else											V3_COPY(c,Area[EdgeF0B1])
-						
-						V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF1B1],EdgeMidPoints[BackEdge],GIP[EdgeF1B1])
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B1])
-						else											V3_COPY(c,Area[EdgeF1B1])
-						
-						/* entries for F0B0 and F1B0 */
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],EdgeMidPoints[EdgeF0B0],a)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALE(0.5,c) V3_COPY(c,d)
-						V3_SCALAR_PRODUCT(conv,c,sp)
-						if (sp>0.0) V3_SCALE(-1.0,d)
-						else 		V3_SCALE(-1.0,c)
-						
-						V3_QUA_CM(SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],EdgeMidPoints[BackEdge],GIP[EdgeF0B0])
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])	V3_COPY(d,Area[EdgeF0B0])
-						else											V3_COPY(c,Area[EdgeF0B0])
-						
-						V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B0],EdgeMidPoints[BackEdge],GIP[EdgeF1B0])
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B0])
-						else											V3_COPY(c,Area[EdgeF1B0])
-					}
-					else
-					{
-						/* coupling of B0 and B1 */
-						
-						/* entries for B0B1, F0B0 and F1B0 */
-						if (FindCrossParam3D(EdgeMidPoints[BackEdge],SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],conv,param)) return (1);
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],SideMidPoints[inflow[0]],a)
-						V3_SUBTRACT(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) {V3_SCALE(-1.0,c); sp = -sp;}
-
-						V3_LINCOMB(0.5,SideMidPoints[outflow[0]],0.5,EdgeMidPoints[BackEdge],GIP[BackEdge])
-						V3_COPY(c,Area[BackEdge])
-						if (CornerOfEdge[BackEdge][0]==BackCorner[0]) alpha = -param[0]*param[1];
-						else										  alpha = param[0]*param[1];
-						V3_SCALE(alpha,Area[BackEdge])
-							
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[0]],a)
-						V3_TRI_CM(SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF0B0],a,GIP[EdgeF0B0])
-						V3_COPY(c,Area[EdgeF0B0])
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF0B0])
-							
-						V3_SUBTRACT(CornerPoints[BackCorner[1]],CornerPoints[BackCorner[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],CornerPoints[BackCorner[0]],b)
-						V3_VECTOR_PRODUCT(a,b,d)
-						if (MirrorAtPlane(GIP[EdgeF0B0],CornerPoints[BackCorner[0]],d,GIP[EdgeF1B0])) return (1);
-						V3_COPY(c,Area[EdgeF1B0])
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF1B0])
-						
-						/* entries for F1B1 and F0B1 */
-						V3_COPY(c,d) alpha=0.5*(1.0-param[0])*param[1]; V3_SCALE(alpha,d)
-
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[0]],a)
-						V3_TRI_CM(SideMidPoints[inflow[0]],EdgeMidPoints[BackEdge],a,GIP[EdgeF0B1])
-						V3_SCALE(sp*alpha,GIP[EdgeF0B1])
-					
-						V3_SUBTRACT(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B1],a)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],SideMidPoints[outflow[1]],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) {V3_SCALE(-0.5,c);sp=-sp;} else V3_SCALE(0.5,c)
-						V3_ADD(c,d,c) V3_COPY(c,d) V3_SCALE(-1.0,d)
-							
-						V3_QUA_CM(SideMidPoints[outflow[1]],SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF0B1],SideMidPoints[outflow[0]],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF0B1],0.5*sp,cm,GIP[EdgeF0B1])
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])	V3_COPY(d,Area[EdgeF0B1])
-						else											V3_COPY(c,Area[EdgeF0B1])
-							
-						V3_SUBTRACT(CornerPoints[BackCorner[1]],CornerPoints[BackCorner[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],CornerPoints[BackCorner[0]],b)
-						V3_VECTOR_PRODUCT(a,b,e)
-						if (MirrorAtPlane(GIP[EdgeF0B1],CornerPoints[BackCorner[0]],e,GIP[EdgeF1B1])) return (1);
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])	V3_COPY(d,Area[EdgeF1B1])
-						else											V3_COPY(c,Area[EdgeF1B1])
-							
-						/* the local upwind intergration points */
-						V3_COPY(TRefCoord[BackCorner[1]],LIP[BackEdge])
-					}
-					break;
-				case 3:
-					/* FrontEdgeMidPoint in 'inflow[0]' and 'outflow[1]' */
-					if (FindCrossParam3D(SideMidPoints[outflow[0]],EdgeMidPoints[FrontEdge],EdgeMidPoints[BackEdge],SideMidPoints[inflow[0]],conv,param)) return (1);
-					if (param[0]>=0.0 )
-					{
-						/* no coupling of B0 and B1 */
-						V3_LINCOMB(1.0-param[0],SideMidPoints[outflow[0]],param[0],EdgeMidPoints[FrontEdge],a)
-
-						/* coupling F0-B1 */
-						V3_SUBTRACT(a,EdgeMidPoints[EdgeF0B1],b)
-						V3_SUBTRACT(SideMidPoints[inflow[0]],EdgeMidPoints[FrontEdge],c)
-						V3_VECTOR_PRODUCT(b,c,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_QUA_CM(a,EdgeMidPoints[EdgeF0B1],SideMidPoints[inflow[0]],EdgeMidPoints[FrontEdge],GIP[EdgeF0B1])
-						V3_SCALE(0.5*sp,GIP[EdgeF0B1])
-						V3_SUBTRACT(EdgeMidPoints[EdgeF0B1],EdgeMidPoints[FrontEdge],b)
-						V3_SUBTRACT(SideMidPoints[outflow[1]],EdgeMidPoints[FrontEdge],c)
-						V3_VECTOR_PRODUCT(b,c,e)
-						V3_SCALAR_PRODUCT(conv,e,sp) sp = ABS(sp);
-						V3_TRI_CM(EdgeMidPoints[EdgeF0B1],EdgeMidPoints[FrontEdge],SideMidPoints[outflow[1]],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF0B1],0.5*sp,cm,GIP[EdgeF0B1])
-						V3_ADD(d,e,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) if (sp<0.0) V3_SCALE(-1.0,d)
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])	V3_SCALE(-1.0,d)
-						V3_SCALE(0.5,d) V3_COPY(d,Area[EdgeF0B1])
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF0B1])
-
-						/* coupling F1-B1 */
-						V3_SUBTRACT(a,SideMidPoints[inflow[1]],b)
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],EdgeMidPoints[BackEdge],c)
-						V3_VECTOR_PRODUCT(b,c,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_QUA_CM(a,SideMidPoints[inflow[1]],EdgeMidPoints[FrontEdge],EdgeMidPoints[BackEdge],GIP[EdgeF1B1])
-						V3_SCALE(0.5*sp,GIP[EdgeF1B1])
-						V3_SUBTRACT(EdgeMidPoints[EdgeF1B1],EdgeMidPoints[FrontEdge],b)
-						V3_SUBTRACT(SideMidPoints[inflow[1]],SideMidPoints[outflow[1]],c)
-						V3_VECTOR_PRODUCT(b,c,e)
-						V3_SCALAR_PRODUCT(conv,e,sp) sp = ABS(sp);
-						V3_QUA_CM(SideMidPoints[inflow[1]],SideMidPoints[outflow[1]],EdgeMidPoints[EdgeF1B1],EdgeMidPoints[FrontEdge],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF1B1],0.5*sp,cm,GIP[EdgeF1B1])
-						V3_ADD(d,e,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) if (sp<0.0) V3_SCALE(-1.0,d)
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])	V3_SCALE(-1.0,d)
-						V3_SCALE(0.5,d) V3_COPY(d,Area[EdgeF1B1])
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF1B1])
-
-						/* coupling F1-B0 */
-						V3_SUBTRACT(a,EdgeMidPoints[EdgeF1B0],b)
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],SideMidPoints[outflow[0]],c)
-						V3_VECTOR_PRODUCT(b,c,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_QUA_CM(a,EdgeMidPoints[EdgeF1B0],EdgeMidPoints[BackEdge],SideMidPoints[outflow[0]],GIP[EdgeF1B0])
-						V3_SCALE(0.5*sp,GIP[EdgeF1B0])
-						V3_SUBTRACT(SideMidPoints[inflow[1]],EdgeMidPoints[BackEdge],b)
-						V3_SUBTRACT(EdgeMidPoints[EdgeF1B0],EdgeMidPoints[BackEdge],c)
-						V3_VECTOR_PRODUCT(b,c,e)
-						V3_SCALAR_PRODUCT(conv,e,sp) sp = ABS(sp);
-						V3_TRI_CM(SideMidPoints[inflow[1]],EdgeMidPoints[BackEdge],EdgeMidPoints[EdgeF1B0],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF1B0],0.5*sp,cm,GIP[EdgeF1B0])
-						V3_ADD(d,e,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) if (sp<0.0) V3_SCALE(-1.0,d)
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])	V3_SCALE(-1.0,d)
-						V3_SCALE(0.5,d) V3_COPY(d,Area[EdgeF1B0])
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF1B0])
-
-						/* coupling F0-B0 */
-						V3_QUA_CM(a,EdgeMidPoints[EdgeF0B0],SideMidPoints[outflow[0]],SideMidPoints[inflow[0]],GIP[EdgeF0B0])
-						V3_SUBTRACT(a,EdgeMidPoints[EdgeF0B0],b)
-						V3_SUBTRACT(SideMidPoints[outflow[0]],SideMidPoints[inflow[0]],c)
-						V3_VECTOR_PRODUCT(b,c,d)
-						V3_SCALAR_PRODUCT(conv,d,sp) if (sp<0.0) V3_SCALE(-1.0,d)
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])	V3_SCALE(-1.0,d)
-						V3_SCALE(0.5,d) V3_COPY(d,Area[EdgeF0B0])
-					}
-					else
-					{
-						/* coupling of B0 and B1 */
-						
-						/* entries for B0B1(the half) and F0B0 */
-						if (FindCrossParam3D(EdgeMidPoints[BackEdge],SideMidPoints[inflow[0]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],conv,param)) return (1);
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],SideMidPoints[inflow[0]],a)
-						V3_SUBTRACT(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF0B0],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) {V3_SCALE(-1.0,c); sp = -sp;}
-							
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[0]],GIP[BackEdge])
-						V3_COPY(c,Area[BackEdge])
-						if (CornerOfEdge[BackEdge][0]==BackCorner[0]) alpha = -0.5*param[0]*param[1];
-						else										  alpha = 0.5*param[0]*param[1];
-						V3_SCALE(alpha,Area[BackEdge])
-							
-						V3_TRI_CM(GIP[BackEdge],SideMidPoints[inflow[0]],EdgeMidPoints[EdgeF0B0],GIP[EdgeF0B0])
-						V3_COPY(c,Area[EdgeF0B0])
-						if (CornerOfEdge[EdgeF0B0][0]==FrontCorner[0])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF0B0])
-
-						/* entry for F0B1 */
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[0]],e)
-						V3_SUBTRACT(EdgeMidPoints[EdgeF0B1],e,a)
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],SideMidPoints[inflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp);
-						V3_QUA_CM(EdgeMidPoints[EdgeF0B1],e,EdgeMidPoints[FrontEdge],SideMidPoints[inflow[0]],GIP[EdgeF0B1])
-						V3_SCALE(0.5*sp,GIP[EdgeF0B1])
-						V3_SUBTRACT(EdgeMidPoints[EdgeF0B1],EdgeMidPoints[FrontEdge],a)
-						V3_SUBTRACT(SideMidPoints[outflow[1]],EdgeMidPoints[FrontEdge],b)
-						V3_VECTOR_PRODUCT(a,b,d) V3_ADD(c,d,c) 
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_TRI_CM(EdgeMidPoints[EdgeF0B1],EdgeMidPoints[FrontEdge],SideMidPoints[outflow[1]],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF0B1],0.5*sp,cm,GIP[EdgeF0B1])
-						V3_SUBTRACT(EdgeMidPoints[FrontEdge],e,a)
-						V3_SUBTRACT(SideMidPoints[outflow[0]],e,b)
-						V3_VECTOR_PRODUCT(a,b,d) V3_ADD(c,d,c) 
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_TRI_CM(EdgeMidPoints[FrontEdge],e,SideMidPoints[outflow[0]],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF0B1],0.5*sp,cm,GIP[EdgeF0B1])
-    					V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) V3_SCALE(-0.5,c) else V3_SCALE(0.5,c)
-						if (CornerOfEdge[EdgeF0B1][0]==FrontCorner[0])  V3_SCALE(-1.0,c)
-						V3_COPY(c,Area[EdgeF0B1])
-						V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF0B1])
-							
-						/* entries for B0B1 (the half) and F1B0 */
-						if (FindCrossParam3D(EdgeMidPoints[BackEdge],SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B0],conv,param)) return (1);
-						V3_SUBTRACT(EdgeMidPoints[BackEdge],SideMidPoints[inflow[1]],a)
-						V3_SUBTRACT(SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B0],b)
-						V3_VECTOR_PRODUCT(a,b,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) V3_SCALE(-1.0,c)
-						V3_COPY(c,d)
-						
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[1]],e)
-						V3_ADD(GIP[BackEdge],e,GIP[BackEdge])
-						if (CornerOfEdge[BackEdge][0]==BackCorner[0]) alpha = -0.5*param[0]*param[1];
-						else										  alpha = 0.5*param[0]*param[1];
-						V3_SCALE(alpha,d) V3_ADD(d,Area[BackEdge],Area[BackEdge])
-						V3_ADD(EdgeMidPoints[BackEdge],GIP[BackEdge],GIP[BackEdge]) V3_ADD(SideMidPoints[outflow[0]],GIP[BackEdge],GIP[BackEdge])
-						V3_SCALE(0.25,GIP[BackEdge])
-							
-						V3_TRI_CM(e,SideMidPoints[inflow[1]],EdgeMidPoints[EdgeF1B0],GIP[EdgeF1B0])
-						V3_COPY(c,Area[EdgeF1B0])
-						if (CornerOfEdge[EdgeF1B0][0]==FrontCorner[1])  alpha = 0.5*(1.0-param[0])*(param[1]-1.0);
-						else											alpha = 0.5*(1.0-param[0])*(1.0-param[1]);
-						V3_SCALE(alpha,Area[EdgeF1B0])
-
-						/* entry for F1B1 */	
-						V3_LINCOMB(1.0-param[0],EdgeMidPoints[BackEdge],param[0],SideMidPoints[inflow[1]],e)
-						V3_SUBTRACT(EdgeMidPoints[EdgeF1B1],e,a)
-						V3_SUBTRACT(SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp);
-						V3_QUA_CM(EdgeMidPoints[EdgeF1B1],e,SideMidPoints[inflow[1]],SideMidPoints[outflow[0]],GIP[EdgeF1B1])
-						V3_SCALE(0.5*sp,GIP[EdgeF1B1])
-						V3_SUBTRACT(SideMidPoints[outflow[1]],SideMidPoints[outflow[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[EdgeF1B1],EdgeMidPoints[FrontEdge],b)
-						V3_VECTOR_PRODUCT(a,b,d) V3_ADD(c,d,c) V3_SCALAR_PRODUCT(conv,c,sp) if (sp<0.0) V3_SCALE(-0.5,c) else V3_SCALE(0.5,c)
-						if (CornerOfEdge[EdgeF1B1][0]==FrontCorner[1])  V3_SCALE(-1.0,c)
-						V3_COPY(c,Area[EdgeF1B1])
-						V3_SCALAR_PRODUCT(conv,d,sp) sp = ABS(sp);
-						V3_QUA_CM(SideMidPoints[outflow[1]],SideMidPoints[outflow[0]],EdgeMidPoints[EdgeF1B1],EdgeMidPoints[FrontEdge],cm)
-						V3_LINCOMB(1.0,GIP[EdgeF1B1],0.5*sp,cm,GIP[EdgeF1B1])
-						V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp); if (sp>0.0) V3_SCALE(1.0/sp,GIP[EdgeF1B1])
-							
-						/* the local upwind intergration points */
-						V3_COPY(TRefCoord[BackCorner[1]],LIP[BackEdge])
-					}
-					break;
-				default :
-					return (1);
-			}
-						
-			/* the local upwind intergration points */
-			V3_COPY(TRefCoord[BackCorner[0]],LIP[EdgeF0B0])
-			V3_COPY(TRefCoord[BackCorner[0]],LIP[EdgeF1B0])
-			V3_COPY(TRefCoord[BackCorner[1]],LIP[EdgeF0B1])
-			V3_COPY(TRefCoord[BackCorner[1]],LIP[EdgeF1B1])
-			break;
-		case 1:
-			/* one in-, three outflow */
-			OpCorner = OppositeCorner[inflow[0]];
-			for (i=0; i<3; i++)
-			{
-				corner[i] = CornerOfSide[inflow[0]][i];
-				OpEdge[i] = EdgeWithCorners[corner[i]][OpCorner];
-				GrEdge[i] = EdgeWithCorners[corner[i]][CornerOfSide[inflow[0]][(i+1)%3]];
-				side[i]   = SideOfCorners[corner[i]][CornerOfSide[inflow[0]][(i+1)%3]][OpCorner];
-			}
-			
-			/* calculate the three quadrilaterals */
-			V3_SUBTRACT(CornerPoints[corner[1]],CornerPoints[corner[0]],a)	/* a = P1 - P0 	*/
-			V3_SUBTRACT(CornerPoints[corner[2]],CornerPoints[corner[0]],b)	/* b = P2 - P0 	*/
-			V3_VECTOR_PRODUCT(a,b,c)
-			V3_SCALE(0.02777777777777777777,c)
-			for (i=0; i<3; i++)
-			{
-				V3_SUBTRACT(CornerPoints[corner[(i+2)%3]],CornerPoints[corner[(i+1)%3]],a)
-				V3_SUBTRACT(CornerPoints[OpCorner],CornerPoints[corner[(i+1)%3]],b)
-				V3_VECTOR_PRODUCT(a,b,d)
-				V3_SCALE(0.08333333333333333333,d)
-				V3_ADD(c,d,Area[OpEdge[i]])
-				
-				V3_SCALAR_PRODUCT(conv,Area[OpEdge[i]],sp) sp = ABS(sp);
-				V3_QUA_CM(EdgeMidPoints[OpEdge[i]],SideMidPoints[side[i]],SideMidPoints[inflow[0]],SideMidPoints[side[(i+2)%3]],GIP[OpEdge[i]])
-					/*V3_SCALE(sp,GIP[OpEdge[i]])*/
-			}
-			
-			/* calculate triangles from crosspoints */
-			for (i=0; i<3; i++)
-			{
-				if (FindCrossParam3D(SideMidPoints[side[i]],EdgeMidPoints[OpEdge[i]],SideMidPoints[inflow[0]],EdgeMidPoints[GrEdge[i]],conv,param)) return (1);
-				if (param[0]>0.0)
-				{
-					/* subtract first triangle to corrisponding quadrilateral */
-					V3_SUBTRACT(EdgeMidPoints[OpEdge[i]],SideMidPoints[inflow[0]],a)
-					V3_SUBTRACT(SideMidPoints[side[i]],SideMidPoints[inflow[0]],b)
-					V3_VECTOR_PRODUCT(a,b,c)
-					if (param[0]>=1.0)
-						V3_SCALE(0.5,c)
-					else
-						V3_SCALE(0.5*param[0],c)
-					V3_SUBTRACT(Area[OpEdge[i]],c,Area[OpEdge[i]])
-					V3_ADD(Area[OpEdge[(i+1)%3]],c,Area[OpEdge[(i+1)%3]])
-
-					V3_LINCOMB(1.0-param[0],SideMidPoints[side[i]],param[0],EdgeMidPoints[OpEdge[i]],e)/*
-					V3_TRI_CM(e,SideMidPoints[side[i]],SideMidPoints[inflow[0]],cm)
-					V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp);
-					V3_SCALE(sp,cm)
-					V3_SUBTRACT(GIP[OpEdge[i]],cm,GIP[OpEdge[i]])
-					V3_ADD(GIP[OpEdge[(i+1)%3]],cm,GIP[OpEdge[(i+1)%3]])*/		/* still to normalize !! */
-							
-					/* connections of P0 and P1 */
-					V3_SUBTRACT(EdgeMidPoints[OpEdge[i]],EdgeMidPoints[GrEdge[i]],a)
-					V3_SUBTRACT(SideMidPoints[side[i]],EdgeMidPoints[GrEdge[i]],b)
-					V3_VECTOR_PRODUCT(a,b,Area[GrEdge[i]])
-					if (param[0]>=1.0)
-						V3_SCALE(0.5,Area[GrEdge[i]])
-					else
-						V3_SCALE(0.5*param[0],Area[GrEdge[i]])
-					V3_TRI_CM(e,SideMidPoints[side[i]],EdgeMidPoints[GrEdge[i]],GIP[GrEdge[i]])					
-
-					First = (CornerOfEdge[GrEdge[i]][0]==corner[i]);
-					V3_SCALAR_PRODUCT(conv,Area[GrEdge[i]],sp)
-					if ((!inverted && !First && sp<0.0) ||	
-					    (!inverted && First && sp>0.0) ||	
-				 	    (inverted && First && sp<0.0) ||	
-				   	    (inverted && !First && sp>0.0))	
-						V3_SCALE(-1.0,Area[GrEdge[i]])
-					V3_COPY(TRefCoord[corner[(i+1)%3]],LIP[GrEdge[i]])
-				}
-				else if (param[0]<0.0)
-				{
-					if (FindCrossParam3D(SideMidPoints[side[i]],EdgeMidPoints[OpEdge[(i+1)%3]],SideMidPoints[inflow[0]],EdgeMidPoints[GrEdge[i]],conv,param)) return (1);
-					if (param[0]>0.0)
-					{
-						V3_SUBTRACT(SideMidPoints[side[i]],SideMidPoints[inflow[0]],a)
-						V3_SUBTRACT(EdgeMidPoints[OpEdge[(i+1)%3]],SideMidPoints[inflow[0]],b)
-						V3_VECTOR_PRODUCT(a,b,c)
-						if (param[0]>=1.0)
-							V3_SCALE(0.5,c)
-						else
-							V3_SCALE(0.5*param[0],c)
-						V3_ADD(Area[OpEdge[i]],c,Area[OpEdge[i]])
-						V3_SUBTRACT(Area[OpEdge[(i+1)%3]],c,Area[OpEdge[(i+1)%3]])
-
-						V3_LINCOMB(1.0-param[0],SideMidPoints[side[i]],param[0],EdgeMidPoints[OpEdge[(i+1)%3]],e)/*
-						V3_TRI_CM(e,SideMidPoints[side[i]],SideMidPoints[inflow[0]],cm)
-						V3_SCALAR_PRODUCT(conv,c,sp) sp = ABS(sp);
-						V3_SCALE(sp,cm)
-						V3_ADD(GIP[OpEdge[i]],cm,GIP[OpEdge[i]])
-						V3_SUBTRACT(GIP[OpEdge[(i+1)%3]],cm,GIP[OpEdge[(i+1)%3]])*/	/* still to normalize !! */
-							
-						/* connections of P0 and P1 */
-						V3_SUBTRACT(EdgeMidPoints[OpEdge[(i+1)%3]],EdgeMidPoints[GrEdge[i]],a)
-						V3_SUBTRACT(SideMidPoints[side[i]],EdgeMidPoints[GrEdge[i]],b)
-						V3_VECTOR_PRODUCT(a,b,Area[GrEdge[i]])
-						if (param[0]>=1.0)
-							V3_SCALE(0.5,Area[GrEdge[i]])
-						else
-							V3_SCALE(0.5*param[0],Area[GrEdge[i]])
-						V3_TRI_CM(e,SideMidPoints[side[i]],EdgeMidPoints[GrEdge[i]],GIP[GrEdge[i]])					
-
-						First = (CornerOfEdge[GrEdge[i]][0]==corner[i]);
-						V3_SCALAR_PRODUCT(conv,Area[GrEdge[i]],sp)
-						if ((!inverted && !First && sp>0.0) ||	
-					 	   (!inverted && First && sp<0.0) ||	
-				 	  	   (inverted && First && sp>0.0) ||	
-				   	   	   (inverted && !First && sp<0.0))	
-							V3_SCALE(-1.0,Area[GrEdge[i]])
-						V3_COPY(TRefCoord[corner[i]],LIP[GrEdge[i]])
-					}
-				}
-				else
-					V3_LINCOMB(0.5,SideMidPoints[side[i]],0.5,EdgeMidPoints[GrEdge[i]],GIP[GrEdge[i]])
-			}
-
-			/*for (i=0; i<3; i++)
-			{
-				V3_SCALAR_PRODUCT(conv,Area[OpEdge[i]],sp) sp = ABS(sp);
-				if (sp>0.0)	V3_SCALE(1.0/sp,GIP[OpEdge[i]])
-			}*/
-			
-			/* turn to the right direction and set LIPs */			
-			for (i=0; i<3; i++)
-			{
-				/* the main connections */
-				First = (CornerOfEdge[OpEdge[i]][1]==OpCorner);
-				V3_SCALAR_PRODUCT(conv,Area[OpEdge[i]],sp)
-				if ((!inverted && !First && sp>0.0) ||	
-				    (!inverted && First && sp<0.0) ||	
-				    (inverted && First && sp>0.0) ||	
-				    (inverted && !First && sp<0.0))	
-					V3_SCALE(-1.0,Area[OpEdge[i]])
-				
-				if (inverted)
-					V3_COPY(TRefCoord[OpCorner],LIP[OpEdge[i]])
-				else
-					V3_COPY(TRefCoord[corner[i]],LIP[OpEdge[i]])
-			}
-			break;			
-		default:
-			return (1);		
-	}
-	
-	/* local IP's from global IP's */
-	V3_SUBTRACT(CornerPoints[1],CornerPoints[0],M)
-	V3_SUBTRACT(CornerPoints[2],CornerPoints[0],M+3)
-	V3_SUBTRACT(CornerPoints[3],CornerPoints[0],M+6);
-	if (M3_Invert(Inv,M)) return (1);
-	for (i=0; i<6; i++)
-	{ 
-		V3_SUBTRACT(GIP[i],CornerPoints[0],a)
-		M3_TIMES_V3(Inv,a,LIP[i])
-	}
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  FV_TetInfo_for_conv											*/
-/*																			*/
-/* Purpose:   calc gradient of shape function i 							*/
-/*																			*/
-/* Input:	  int i: corner number [0..3]									*/
-/*			  COORD **Corners: list of ptrs to phys corner vectors			*/
-/*																			*/
-/* Output:	  COORD **theGradient: list of ptrs to gradients				*/
-/*																			*/
-/* Return:	  INT 0: ok 													*/
-/*				  1: error													*/
-/*																			*/
-/****************************************************************************/
-
-INT FV_TetInfo_for_conv (const COORD **CornerPoints, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], COORD_VECTOR GIP[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM], COORD_VECTOR conv)
-{
-	COORD sp, spn, spz, alpha1, alpha2;
-	COORD_VECTOR a, b, c, normal;
-	COORD_VECTOR EdgeMidPoints[6], SideMidPoints[4];
-	INT i, j, help, noutflow, ninflow, outflow[4], inflow[4], edge, inverted, side;
-	
-	/* reset areas and integrationpoints */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		V3_CLEAR(Area[i])
-		V3_CLEAR(GIP[i])
-		V3_CLEAR(LUIP[i])
-	}
-	
-	/* edge mid points */
-	for (i=0; i<6; i++)	V3_LINCOMB(0.5,CornerPoints[CornerOfEdge[i][0]],0.5,CornerPoints[CornerOfEdge[i][1]],EdgeMidPoints[i])
-			
-	/* side mid points */
-	for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-	{
-		V3_ADD(CornerPoints[CornerOfSide[i][0]],CornerPoints[CornerOfSide[i][1]],a)
-		V3_ADD(CornerPoints[CornerOfSide[i][2]],a,a)
-		V3_SCALE(0.33333333333333333,SideMidPoints[i])
-	}
-
-	/* in/outflow sides */
-	noutflow = ninflow = 0;
-	for (i=0; i<4; i++)
-	{
-		V3_SUBTRACT(CornerPoints[CornerOfSide[i][1]],CornerPoints[CornerOfSide[i][0]],a)
-		V3_SUBTRACT(CornerPoints[CornerOfSide[i][2]],CornerPoints[CornerOfSide[i][0]],b)
-		V3_VECTOR_PRODUCT(a,b,normal)
-		V3_SUBTRACT(CornerPoints[OppositeCorner[i]],CornerPoints[CornerOfSide[i][0]],a)
-		V3_SCALAR_PRODUCT(a,normal,sp)
-		if (sp>0.0) V3_SCALE(-1.0,normal)
-		V3_SCALAR_PRODUCT(conv,normal,sp)
-		if (sp>=0.0) 	outflow[noutflow++] = i;
-		if (sp<0.0)		inflow[ninflow++] = i;
-	}
-
-	/* change if inflow > outflow */
-	inverted=0;
-	if (ninflow>noutflow)
-	{
-		inverted=1;
-		for (i=0; i<ninflow; i++)	{help = inflow[i]; inflow[i] = outflow[i]; outflow[i] = help;}
-		help = ninflow; ninflow = noutflow; noutflow = help;
-	}
-	if ( ninflow+noutflow!=4 || ninflow<1 || ninflow>2) 
-		return (1);
-		
-	/* handle different cases */
-	switch (ninflow)
-	{
-		case 2:
-			break;
-		case 1:
-			/* one in-, three outflow */
-			for (i=0; i<3; i++)	
-			{
-				/* P0 = corners of element-side[i]  */
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][i]][OppositeCorner[inflow[0]]];								/* edge: P0 ~ P3	*/
-				V3_SUBTRACT(SideMidPoints[inflow[0]],EdgeMidPoints[edge],a)													/* P012 - P3		*/
-				V3_SUBTRACT(CornerPoints[CornerOfSide[inflow[0]][(i+2)%3]],CornerPoints[CornerOfSide[inflow[0]][(i+1)%3]],b)/* P2 - P1 			*/
-				V3_VECTOR_PRODUCT(a,b,Area[edge])
-				V3_SCALE(0.1666666666,Area[edge])
-
-				/* P2 = corners of element-side[i]  */
-				/* calc alpha1 */
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+1)%3]][OppositeCorner[inflow[0]]];						/* edge: P0 ~ P3 	*/
-				V3_SUBTRACT(EdgeMidPoints[edge],CornerPoints[CornerOfSide[inflow[0]][(i+2)%3]],a)							/* P03 - P1 		*/
-				V3_VECTOR_PRODUCT(conv,a,c)
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+1)%3]][CornerOfSide[inflow[0]][(i+2)%3]];					/* edge: P0 ~ P1 */
-				V3_SUBTRACT(EdgeMidPoints[edge],CornerPoints[CornerOfSide[inflow[0]][i]],b)									/* P01 - P2 */
-				V3_SCALAR_PRODUCT(b,c,spn)
-				if (spn==0.0) continue;
-				V3_SUBTRACT(CornerPoints[OppositeCorner[inflow[0]]],CornerPoints[CornerOfSide[inflow[0]][i]],b)				/* P3 - P2 */
-				V3_SCALAR_PRODUCT(b,c,spz)
-				alpha1 = spz/spn;
-				assert (alpha1>=0.0);
-				
-				/* calc alpha2 */
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+2)%3]][OppositeCorner[inflow[0]]];						/* edge: P1 ~ P3 	*/
-				V3_SUBTRACT(EdgeMidPoints[edge],CornerPoints[CornerOfSide[inflow[0]][(i+1)%3]],a)							/* P13 - P0 		*/
-				V3_VECTOR_PRODUCT(conv,a,c)
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+1)%3]][CornerOfSide[inflow[0]][(i+2)%3]];					/* edge: P0 ~ P1 	*/
-				V3_SUBTRACT(EdgeMidPoints[edge],CornerPoints[CornerOfSide[inflow[0]][i]],b)									/* P01 - P2 		*/
-				V3_SCALAR_PRODUCT(b,c,spn)
-				assert (spn!=0.0);
-				V3_SUBTRACT(CornerPoints[OppositeCorner[inflow[0]]],CornerPoints[CornerOfSide[inflow[0]][i]],b)				/* P3 - P2 			*/
-				V3_SCALAR_PRODUCT(b,c,spz)
-				alpha2 = spz/spn;
-				assert (alpha2>=0.0);
-				
-				/* take the right triangle */
-				V3_SUBTRACT(CornerPoints[CornerOfSide[inflow[0]][i]],CornerPoints[OppositeCorner[inflow[0]]],a)				/* P2 - P3 			*/
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+1)%3]][CornerOfSide[inflow[0]][(i+2)%3]];					/* edge: P0 ~ P1 	*/
-				V3_SUBTRACT(EdgeMidPoints[edge],CornerPoints[CornerOfSide[inflow[0]][i]],b)									/* P01 - P2 		*/
-				V3_VECTOR_PRODUCT(a,b,c)
-				if (alpha1<alpha2)		j=1;
-				else if (alpha2<alpha1) j=0;
-				else
-				{
-					side = OppositeSide[CornerOfSide[inflow[0]][i]];														/* side 013 		*/
-					V3_SUBTRACT(SideMidPoints[side],CornerPoints[CornerOfSide[inflow[0]][(i+2)%3]],a)						/* P013 - P1 		*/
-					V3_EUKLIDNORM(a,alpha1)
-					V3_SUBTRACT(SideMidPoints[side],CornerPoints[CornerOfSide[inflow[0]][(i+1)%3]],a)						/* P013 - P0 		*/
-					V3_EUKLIDNORM(a,alpha2)
-					if (alpha1<alpha2)		j=1;
-					else if (alpha2<alpha1) j=0;
-					else continue;
-				}
-				if (j)
-				{
-					V3_SCALE(alpha1/18.0,c)
-					edge = EdgeWithCorners[CornerOfSide[inflow[0]][i]][OppositeCorner[inflow[0]]];							/* edge: P0 ~ P3 	*/
-					V3_SUBTRACT(Area[edge],c,Area[edge])			
-					edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+2)%3]][OppositeCorner[inflow[0]]];					/* edge: P1 ~ P3 	*/
-					V3_ADD(Area[edge],c,Area[edge])			
-				}
-				else
-				{
-					V3_SCALE(alpha2/18.0,c)
-					edge = EdgeWithCorners[CornerOfSide[inflow[0]][i]][OppositeCorner[inflow[0]]];							/* edge: P0 ~ P3 	*/
-					V3_ADD(Area[edge],c,Area[edge])			
-					edge = EdgeWithCorners[CornerOfSide[inflow[0]][(i+2)%3]][OppositeCorner[inflow[0]]];					/* edge: P1 ~ P3 	*/
-					V3_SUBTRACT(Area[edge],c,Area[edge])			
-				}
-			}
-			
-			/* orientate the areas */
-			for (i=0; i<6; i++)	
-			{
-				V3_SUBTRACT(CornerPoints[CornerOfEdge[i][1]],CornerPoints[CornerOfEdge[i][0]],a)
-				V3_SCALAR_PRODUCT(a,Area[i],sp)
-				if (sp<0.0)
-					V3_SCALE(-1.0,Area[i])
-			}
-			
-			/* set LUIP */
-			for (i=0; i<3; i++)	
-			{			
-				edge = EdgeWithCorners[CornerOfSide[inflow[0]][i]][OppositeCorner[inflow[0]]];
-				if (inverted)	V3_COPY(TRefCoord[OppositeCorner[inflow[0]]],LUIP[edge])
-				else			V3_COPY(TRefCoord[CornerOfSide[inflow[0]][i]],LUIP[edge])
-			}
-			break;
-		default:
-			return (1);		
-	}
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   Side_TetInfo	- Calculate subsurfaces and integration points on elementside of tetrahedron 
-
-   SYNOPSIS:
-   INT Side_TetInfo (COORD **theCorners, INT side, COORD_VECTOR Area, 
-   COORD_VECTOR GIP[3]);
-
-   PARAMETERS:
-.  theCorners - list of pointers to phys corner vectors
-.  side - side of tetrahedron
-.  Area - area of subsurface on an element side
-.  Gip[3] - surface integration points
-
-   DESCRIPTION:
-   The tetrahedrons are subdevided into four subcontrol volumes, defined by the
-   edge midpoints, the center of mass of the sides and the center of mass
-   of the volume for the discretization. In natural one elementside decomposes
-   in three subsurfaces. The area and the global integration points of these
-   subsurfaces are calculated in this function.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT Side_TetInfo (const COORD **theCorners, INT side, COORD_VECTOR Area, COORD_VECTOR GIP[3])
-{
-	COORD_VECTOR a,b,c;
-	COORD scalarprd;
-	INT i0, i1, i2, i3;
-	
-	i0 = CornerOfSide[side][0];
-	i1 = CornerOfSide[side][1];
-	i2 = CornerOfSide[side][2];
-	i3 = OppositeCorner[side];
-
-	/* get Area */
-	V3_SUBTRACT(theCorners[i1],theCorners[i0],a)
-	V3_SUBTRACT(theCorners[i2],theCorners[i0],b)	
-	V3_SUBTRACT(theCorners[i3],theCorners[i0],c)
-	V3_VECTOR_PRODUCT(a,b,Area)
-	V3_SCALAR_PRODUCT(c,Area,scalarprd)
-	if (scalarprd > 0.0)
-		V3_SCALE(-1.0/6.0,Area)
-	else
-		V3_SCALE( 1.0/6.0,Area)
-	
-	/* get three surface integration points */
-	V3_LINCOMB(14.0/24.0,theCorners[i0],5.0/24.0,theCorners[i1],a)
-	V3_LINCOMB(5.0/24.0,theCorners[i2],1.0,a,GIP[0])
-	
-	V3_LINCOMB(14.0/24.0,theCorners[i1],5.0/24.0,theCorners[i2],a)
-	V3_LINCOMB(5.0/24.0,theCorners[i0],1.0,a,GIP[1])
-	
-	V3_LINCOMB(14.0/24.0,theCorners[i2],5.0/24.0,theCorners[i0],a)
-	V3_LINCOMB(5.0/24.0,theCorners[i1],1.0,a,GIP[2])
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*D
-   GSUIP - Calculate upwind integration point
-
-   SYNOPSIS:
-   INT GSUIP (COORD **theCorners, COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], 
-   DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - coordinates of the element corners
-.  LIP - integration point
-.  conv - velocity
-.  LUIP - upwind integration point
-
-   DESCRIPTION:
-   This function calculates the upwind integration points LUIP on the surface
-   using the `standard upwind discretization`, where the LUIP is defined downstream
-   at the node on the intersection of the local flow vector `conv`, defined in the
-   integration point IP, with the element boundary.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.	
-D*/			
-/****************************************************************************/
-
-INT GetSkewedUIP (const COORD_VECTOR *theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], const DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM])
-{
-	COORD_VECTOR lconv;
-	COORD alpha;
-	COORD M[9],I[9];
-	INT flags, i;
-
-	V3_SUBTRACT(theCorners[1],theCorners[0],M)
-	V3_SUBTRACT(theCorners[2],theCorners[0],M+3)
-	V3_SUBTRACT(theCorners[3],theCorners[0],M+6)
-	if (M3_Invert(I,M)) return (1);
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		M3_TIMES_V3 (I,conv[i],lconv)
-		flags = (ABS(lconv[0])<SMALL_C);
-		flags |= ((ABS(lconv[1])<SMALL_C)<<1);
-		flags |= ((ABS(lconv[2])<SMALL_C)<<2);
-		switch(flags)
-		{
-			case 0:
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-					LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-					if (LUIP[i][1]>=0.0 && LUIP[i][2]>=0.0 && LUIP[i][1]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][0]=0.0;
-						break;
-					}
-				}
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-					LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-					if (LUIP[i][0]>=0.0 && LUIP[i][2]>=0.0 && LUIP[i][0]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][1]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-					LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-					if (LUIP[i][0]>=0.0 && LUIP[i][1]>=0.0 && LUIP[i][0]+LUIP[i][1]<=1.0)
-					{
-						LUIP[i][2]=0.0;
-						break;
-					}
-				}
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[1]+lconv[2]);
-				LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-				LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-				LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 1:
-				LUIP[i][0]=LIP[i][0];
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-					if (LUIP[i][2]>=0.0 && LUIP[i][0]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][1]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-					if (LUIP[i][1]>=0.0 && LUIP[i][0]+LUIP[i][1]<=1.0)
-					{
-						LUIP[i][2]=0.0;
-						break;
-					}
-				}	
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[1]+lconv[2]);
-				LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-				LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 2:
-				LUIP[i][1]=LIP[i][1];
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-					if (LUIP[i][2]>=0.0 && LUIP[i][1]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][0]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-					if (LUIP[i][0]>=0.0 && LUIP[i][0]+LUIP[i][1]<=1.0)
-					{
-						LUIP[i][2]=0.0;
-						break;
-					}
-				}	
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[2]);
-				LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-				LUIP[i][2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 3:
-				LUIP[i][0]=LIP[i][0];
-				LUIP[i][1]=LIP[i][1];
-				if (lconv[2]>0.0)
-					LUIP[i][2]=0.0;
-				else
-					LUIP[i][2]=1.0-LIP[i][0]-LIP[i][1];
-				break;
-			case 4:
-				LUIP[i][2]=LIP[i][2];
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-					if (LUIP[i][1]>=0.0 && LUIP[i][1]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][0]=0.0;
-						break;
-					}
-				}
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-					if (LUIP[i][0]>=0.0 && LUIP[i][0]+LUIP[i][2]<=1.0)
-					{
-						LUIP[i][1]=0.0;
-						break;
-					}
-				}
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[1]);
-				LUIP[i][0]=LIP[i][0]-alpha*lconv[0];
-				LUIP[i][1]=LIP[i][1]-alpha*lconv[1];
-				break;
-			case 5:
-				LUIP[i][0]=LIP[i][0];
-				if (lconv[1]>0.0)
-					LUIP[i][1]=0.0;
-				else
-					LUIP[i][1]=1.0-LIP[i][0]-LIP[i][2];
-				LUIP[i][2]=LIP[i][2];
-				break;
-			case 6:
-				if (lconv[0]>0.0)
-					LUIP[i][0]=0.0;
-				else
-					LUIP[i][0]=1.0-LIP[i][1]-LIP[i][2];
-				LUIP[i][1]=LIP[i][1];
-				LUIP[i][2]=LIP[i][2];
-				break;
-			case 7:
-				LUIP[i][0]=LIP[i][0];
-				LUIP[i][1]=LIP[i][1];
-				LUIP[i][2]=LIP[i][2];
-				break;
-		}
-	/*	if ((LUIP[i][0]<-SMALL_C) || (LUIP[i][1]<-SMALL_C) || (LUIP[i][2]<-SMALL_C) || (LUIP[i][0]+LUIP[i][1]+LUIP[i][2]>1.0+SMALL_C))
-			return (1);*/
-	}
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   GFUIP - Calculate upwind integration point
-
-   SYNOPSIS:
-   INT GFUIP (COORD **theCorners, COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], 
-   DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - coordinates of the element corners
-.  LIP - integration point
-.  conv - velocity in the integration point
-.  LUIP - upwind integration point
-
-   DESCRIPTION:
-   This function calculates the upwind integration points LUIP using the
-   `fast upwind discretization`. There the LUIP is defined at the corner with
-   the maximum distance upstream to the intersection of the local flow vector
-   `conv`, defined in the integration point IP, with the element boundary.
-   
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.													
-D*/
-/****************************************************************************/
-
-INT GFUIP (const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM])
-{
-	COORD_VECTOR lconv;
-	COORD sp, min;
-	COORD M[9],I[9];
-	INT j, i, ip[MAX_CORNERS_OF_ELEM], n;
-
-	V3_SUBTRACT(theCorners[1],theCorners[0],M)
-	V3_SUBTRACT(theCorners[2],theCorners[0],M+3)
-	V3_SUBTRACT(theCorners[3],theCorners[0],M+6)
-	if (M3_Invert(I,M)) return (1);
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		M3_TIMES_V3(I,conv[i],lconv)
-		min = MAX_C; n = 0;
-		for (j=0; j<MAX_CORNERS_OF_ELEM; j++)
-		{
-			V3_SCALAR_PRODUCT(lconv,TRefCoord[j],sp)
-			if (min==sp)
-				ip[n++] = j;
-			if (min>sp)
-			{
-				n = 0;
-				min =sp;
-				ip[n++] = j;
-			}
-		}
-		assert(n>0);
-		V3_CLEAR(LUIP[i])
-		for (j=0; j<n; j++)
-			V3_ADD(TRefCoord[ip[j]],LUIP[i],LUIP[i])
-		V3_SCALE(1.0/(COORD)n,LUIP[i])
-	}
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   GCUIP - Calculate upwind integration point
-
-   SYNOPSIS:
-   INT GCUIP (COORD **theCorners, COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], 
-   DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - coordinates of the element corners
-.  LIP - integration point
-.  conv - velocity
-.  LUIP - upwind integration point
-
-
-   DESCRIPTION:
-   This function calculates the upwind integration point LUIP using the
-   `corner upwind discretization`, where the LUIP is defined downstream at the
-   corner next to the intersection-point of the local flow vector `conv`, defined
-   in the integration point IP, with the element boundary.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT GCUIP (const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM])
-{
-	COORD_VECTOR a, lconv, SUIP;
-	COORD alpha, sp, min;
-	COORD M[9],I[9];
-	INT flags, i, j, k; 
-
-	V3_SUBTRACT(theCorners[1],theCorners[0],M)
-	V3_SUBTRACT(theCorners[2],theCorners[0],M+3)
-	V3_SUBTRACT(theCorners[3],theCorners[0],M+6)
-	if (M3_Invert(I,M)) return (1);
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		V3_SUBTRACT(conv[i],theCorners[0],a)
-		M3_TIMES_V3 (I,a,lconv)
-		flags = (ABS(lconv[0])<SMALL_C);
-		flags |= ((ABS(lconv[1])<SMALL_C)<<1);
-		flags |= ((ABS(lconv[2])<SMALL_C)<<2);
-		switch(flags)
-		{
-			case 0:
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					SUIP[1]=LIP[i][1]-alpha*lconv[1];
-					SUIP[2]=LIP[i][2]-alpha*lconv[2];
-					if (SUIP[1]>=0.0 && SUIP[2]>=0.0 && SUIP[1]+SUIP[2]<=1.0)
-					{
-						SUIP[0]=0.0;
-						break;
-					}
-				}
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					SUIP[0]=LIP[i][0]-alpha*lconv[0];
-					SUIP[2]=LIP[i][2]-alpha*lconv[2];
-					if (SUIP[0]>=0.0 && SUIP[2]>=0.0 && SUIP[0]+SUIP[2]<=1.0)
-					{
-						SUIP[1]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					SUIP[0]=LIP[i][0]-alpha*lconv[0];
-					SUIP[1]=LIP[i][1]-alpha*lconv[1];
-					if (SUIP[0]>=0.0 && SUIP[1]>=0.0 && SUIP[0]+SUIP[1]<=1.0)
-					{
-						SUIP[2]=0.0;
-						break;
-					}
-				}
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[1]+lconv[2]);
-				SUIP[0]=LIP[i][0]-alpha*lconv[0];
-				SUIP[1]=LIP[i][1]-alpha*lconv[1];
-				SUIP[2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 1:
-				SUIP[0]=LIP[i][0];
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					SUIP[2]=LIP[i][2]-alpha*lconv[2];
-					if (SUIP[2]>=0.0 && SUIP[0]+SUIP[2]<=1.0)
-					{
-						SUIP[1]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					SUIP[1]=LIP[i][1]-alpha*lconv[1];
-					if (SUIP[1]>=0.0 && SUIP[0]+SUIP[1]<=1.0)
-					{
-						SUIP[2]=0.0;
-						break;
-					}
-				}	
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[1]+lconv[2]);
-				SUIP[1]=LIP[i][1]-alpha*lconv[1];
-				SUIP[2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 2:
-				SUIP[1]=LIP[i][1];
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					SUIP[2]=LIP[i][2]-alpha*lconv[2];
-					if (SUIP[2]>=0.0 && SUIP[1]+SUIP[2]<=1.0)
-					{
-						SUIP[0]=0.0;
-						break;
-					}
-				}
-				if (lconv[2]>0.0)
-				{
-					alpha = LIP[i][2]/lconv[2];
-					SUIP[0]=LIP[i][0]-alpha*lconv[0];
-					if (SUIP[0]>=0.0 && SUIP[0]+SUIP[1]<=1.0)
-					{
-						SUIP[2]=0.0;
-						break;
-					}
-				}	
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[2]);
-				SUIP[0]=LIP[i][0]-alpha*lconv[0];
-				SUIP[2]=LIP[i][2]-alpha*lconv[2];
-				break;
-			case 3:
-				SUIP[0]=LIP[i][0];
-				SUIP[1]=LIP[i][1];
-				if (lconv[2]>0.0)
-					SUIP[2]=0.0;
-				else
-					SUIP[2]=1.0-LIP[i][0]-LIP[i][1];
-				break;
-			case 4:
-				SUIP[2]=LIP[i][2];
-				if (lconv[0]>0.0)
-				{
-					alpha = LIP[i][0]/lconv[0];
-					SUIP[1]=LIP[i][1]-alpha*lconv[1];
-					if (SUIP[1]>=0.0 && SUIP[1]+SUIP[2]<=1.0)
-					{
-						SUIP[0]=0.0;
-						break;
-					}
-				}
-				if (lconv[1]>0.0)
-				{
-					alpha = LIP[i][1]/lconv[1];
-					SUIP[0]=LIP[i][0]-alpha*lconv[0];
-					if (SUIP[0]>=0.0 && SUIP[0]+SUIP[2]<=1.0)
-					{
-						SUIP[1]=0.0;
-						break;
-					}
-				}
-				alpha = (LIP[i][0]+LIP[i][1]+LIP[i][2]-1.0)/(lconv[0]+lconv[1]);
-				SUIP[0]=LIP[i][0]-alpha*lconv[0];
-				SUIP[1]=LIP[i][1]-alpha*lconv[1];
-				break;
-			case 5:
-				SUIP[0]=LIP[i][0];
-				if (lconv[1]>0.0)
-					SUIP[1]=0.0;
-				else
-					SUIP[1]=1.0-LIP[i][0]-LIP[i][2];
-				SUIP[2]=LIP[i][2];
-				break;
-			case 6:
-				if (lconv[0]>0.0)
-					SUIP[0]=0.0;
-				else
-					SUIP[0]=1.0-LIP[i][1]-LIP[i][2];
-				SUIP[1]=LIP[i][1];
-				SUIP[2]=LIP[i][2];
-				break;
-			case 7:
-				SUIP[0]=LIP[i][0];
-				SUIP[1]=LIP[i][1];
-				SUIP[2]=LIP[i][2];
-				break;
-		}
-		
-		/* now find corner */
-		min = MAX_C;
-		for (j=0; j<MAX_CORNERS_OF_ELEM; j++)
-		{
-			V3_EUKLIDNORM_OF_DIFF(SUIP,TRefCoord[j],sp)
-			if (min>sp)
-			{
-				k=j;
-				min=sp;
-			}
-		}
-		assert(k>=0 && k<MAX_CORNERS_OF_ELEM);
-		LUIP[i][0] = TRefCoord[k][0];
-		LUIP[i][1] = TRefCoord[k][1];
-		LUIP[i][2] = TRefCoord[k][2];
-	}
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   COPYIP - Copy integration points
-
-   SYNOPSIS:
-   INT COPYIP (COORD **theCorners, COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], 
-   DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-
-   PARAMETERS:
-.  theCorners - coordinates of the element corners
-.  LIP - integration point
-.  conv - velocity 
-.  LUIP - upwind integration point
-  
-   DESCRIPTION:
-   This function copies integration points on the upwind integration points.
-
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    1 if error occured.
-D*/
-/****************************************************************************/
-
-INT COPYIP (const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM])
-{
-	INT i;
-	
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-		V3_COPY(LIP[i],LUIP[i])
-	
-	return (0);
-}
-
diff -ruN ug-orig/gm/shapes3d.h ug-patched/gm/shapes3d.h
--- ug-orig/gm/shapes3d.h	1996-03-13 12:43:51.000000000 +0100
+++ ug-patched/gm/shapes3d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,86 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  shapes.h														*/
-/*																			*/
-/* Purpose:   header file for shape functions								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   29.01.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __SHAPES3D__
-#define __SHAPES3D__
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define LOCAL_TO_GLOBAL(A,B,C)		{C[0] = (1.0-B[0]-B[1]-B[2])*A[0][0]+B[0]*A[1][0]+B[1]*A[2][0]+B[2]*A[3][0];\
-					 C[1] = (1.0-B[0]-B[1]-B[2])*A[0][1]+B[0]*A[1][1]+B[1]*A[2][1]+B[2]*A[3][1];\
-					 C[2] = (1.0-B[0]-B[1]-B[2])*A[0][2]+B[0]*A[1][2]+B[1]*A[2][2]+B[2]*A[3][2];}
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-typedef INT (*UpwindProcPtr) (COORD **, COORD_VECTOR *,DOUBLE_VECTOR *, COORD_VECTOR *);
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-DOUBLE	N					(const INT i, const COORD *LocalCoord);
-INT 	GlobalToLocal3d 	(const COORD **Corners, const COORD *EvalPoint, COORD *LocalCoord);
-INT 	TetraDerivative 	(const COORD **theCorners, COORD_VECTOR theGradient[MAX_CORNERS_OF_ELEM]);
-INT 	TetraVolume 		(const COORD **theCorners, COORD *volume);
-INT 	FV_TetInfo			(const COORD **theCorners, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], COORD_VECTOR GIP[MAX_EDGES_OF_ELEM]);
-INT 	FV_TetInfo_for_conv (const COORD **theCorners, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], COORD_VECTOR GIP[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM], COORD_VECTOR conv);
-INT 	FV_AliTetInfo 		(const COORD **CornerPoints, COORD_VECTOR Area[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv, COORD_VECTOR GIP[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-INT 	Side_TetInfo		(const COORD **theCorners, INT side, COORD_VECTOR Area, COORD_VECTOR GIP[3]);
-INT 	GetSkewedUIP 		(const COORD_VECTOR *theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], const DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-INT 	GFUIP				(const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-INT 	GCUIP				(const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-INT 	COPYIP 				(const COORD **theCorners, const COORD_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], COORD_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
-INT 	TetraSideNormals	(const COORD **theCorners, COORD_VECTOR theNormals[MAX_SIDES_OF_ELEM]);
-INT 	TetMaxSideAngle 	(const COORD **theCorners, COORD *MaxAngle);
-INT 	TetAngleAndLength	(const COORD **theCorners, COORD *Angle, COORD *Length);
-
-#endif
diff -ruN ug-orig/gm/shapes.c ug-patched/gm/shapes.c
--- ug-orig/gm/shapes.c	2008-10-30 13:29:06.000000000 +0100
+++ ug-patched/gm/shapes.c	2008-12-19 11:02:55.000000000 +0100
@@ -26,6 +26,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include <assert.h>
 #include <stddef.h>
@@ -141,7 +142,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/shapes.c,v 1.44 2008/10/30 12:29:06 dmitriy Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -1202,23 +1203,6 @@
 	INT i;
 	
 	V_DIM_SUBTRACT(EvalPoint,Corners[0],diff);
-
-#ifdef WITH_DEGENERATED_ELEM
-	
-#ifdef __TWODIM__
-	V_DIM_EUKLIDNORM_OF_DIFF (Corners[1], Corners[0], s);
-	V_DIM_EUKLIDNORM_OF_DIFF (Corners[n-1], Corners[0], IMdet);
-	if (IMdet / s <= DEGENERATED_SIZE)
-	{ /* This is a denenerated element, i.e. a segment: */
-		LocalCoord [1] = 0;
-		V_DIM_SUBTRACT (Corners[1], Corners[0], tmp);
-		LocalCoord [0] = V_DIM_SCAL_PROD (diff, tmp) / s;
-		return 0;
-	}
-#endif /* __TWODIM__ */
-
-#endif /* WITH_DEGENERATED_ELEM */
-	
 	if (n == DIM+1)
 	  {
 		TRANSFORMATION(DIM+1,Corners,LocalCoord,M);
diff -ruN ug-orig/gm/shapes.h ug-patched/gm/shapes.h
--- ug-orig/gm/shapes.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/shapes.h	2007-01-14 17:21:35.000000000 +0100
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/shapes.h,v 1.37 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -132,8 +132,7 @@
 #define CORNER_COORDINATES(e,n,x)                               \
  {if (TAG((e))==TRIANGLE)                                       \
                  CORNER_COORDINATES_TRIANGLE((e),(n),(x))       \
-  else if (TAG((e))==QUADRILATERAL)                             \
-                 CORNER_COORDINATES_QUADRILATERAL((e),(n),(x))}
+  else           CORNER_COORDINATES_QUADRILATERAL((e),(n),(x))}
 
 #define COPY_CORNER_COORDINATES(e,n,x)                          \
  {if (TAG((e))==TRIANGLE)                                       \
@@ -201,7 +200,7 @@
 
 #define TRANSFORMATION_2D(n,x,local,M)                                      \
  {if ((n) == 3)      {TRANSFORMATION_OF_TRIANGLE((x),(M));}              \
-  else if ((n) == 4) {TRANSFORMATION_OF_QUADRILATERAL((x),(local),(M));} }
+  else TRANSFORMATION_OF_QUADRILATERAL((x),(local),(M)); }
 
 #define SIDE_NORMAL_2D(n,i,x,normal)                 \
    { DOUBLE s; DOUBLE_VECTOR y;                   \
@@ -318,7 +317,7 @@
   {if (TAG((e))==TETRAHEDRON)     CORNER_COORDINATES_TETRAHEDRON((e),(n),(x))\
    else if (TAG((e))==PYRAMID)    CORNER_COORDINATES_PYRAMID((e),(n),(x))    \
    else if (TAG((e))==PRISM)      CORNER_COORDINATES_PRISM((e),(n),(x))      \
-   else if (TAG((e))==HEXAHEDRON) CORNER_COORDINATES_HEXAHEDRON((e),(n),(x))}
+   else CORNER_COORDINATES_HEXAHEDRON((e),(n),(x))}
  
 #define COPY_CORNER_COORDINATES(e,n,x)                                     \
   {if (TAG((e))==TETRAHEDRON)     COPY_COORDINATES_TETRAHEDRON((e),(n),(x))\
@@ -595,7 +594,7 @@
  {if ((n) == 4)      {TRANSFORMATION_OF_TETRAHEDRON((x),(M));}          \
   else if ((n) == 5) {TRANSFORMATION_OF_PYRAMID((x),(local),(M));}      \
   else if ((n) == 6) {TRANSFORMATION_OF_PRISM((x),(local),(M));}        \
-  else if ((n) == 8) {TRANSFORMATION_OF_HEXAHEDRON((x),(local),(M));}}
+  else TRANSFORMATION_OF_HEXAHEDRON((x),(local),(M));}
 
 #define SIDE_NORMAL_3D(n,i,x,normal)                                \
   { DOUBLE s; DOUBLE_VECTOR a,b;                                 \
diff -ruN ug-orig/gm/simplex.c ug-patched/gm/simplex.c
--- ug-orig/gm/simplex.c	1995-11-30 12:24:39.000000000 +0100
+++ ug-patched/gm/simplex.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,235 +0,0 @@
-/***************************************************************************
- *																		   *
- *	File:		 simplex.c												   *
- *																		   *
- *	Purpose:	 definition and algorithms for simlices 				   *
- *																		   *
- *	Author: 	 Juergen Bey											   *
- *				 Mathematisches Institut								   *
- *				 Auf der Morgenstelle 10								   *
- *				 7400 Tuebingen 										   *
- *			     email: ug@ica3.uni-stuttgart.de					       * 
- *																		   *
- *	History:	 10.12.92  begin										   *
- *																		   *
- *	Remarks:															   *
- *																		   *
- ***************************************************************************/
-
-
-
-
-/***************************************************************************
- *																		   *
- *								 Includes								   *
- *																		   *
- ***************************************************************************/
-
-#include  "simplex.h"
-#include  "gm.h"
-
-
-#ifdef __TWODIM__
-#error this source file is for 3D ONLY
-#endif
-
-/***************************************************************************
- *																		   *
- *								 Constants								   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *								  Macros								   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *							  Data structures							   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *							  Global variables							   *
- *																		   *
- ***************************************************************************/
-
-/***************************************************************************
- *																		   *
- *								 Tetrahedras							   *
- *																		   *
- ***************************************************************************/
-
-/* definition of a reference tetrahedron for local coordinates */
-COORD_VECTOR TRefCoord[MAX_CORNERS_OF_ELEM] = {{0.0,0.0,0.0},{1.0,0.0,0.0},
-									   {0.0,1.0,0.0},{0.0,0.0,1.0}};
-
-/* local itegration points in reference tet */
-COORD_VECTOR LIP[MAX_EDGES_OF_ELEM] = {{17.0/48.0,7.0/48.0,7.0/48.0},
-			   {17.0/48.0,17.0/48.0,7.0/48.0},
-			   {7.0/48.0,17.0/48.0,7.0/48.0},
-			   {7.0/48.0,7.0/48.0,17.0/48.0},
-			   {17.0/48.0,7.0/48.0,17.0/48.0},
-			   {7.0/48.0,17.0/48.0,17.0/48.0}};
-
-/* local surface itegration points in reference tet */
-COORD_VECTOR LSIP[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE] = 	   {{{ 5.0/24.0, 5.0/24.0,		0.0},{14.0/24.0, 5.0/24.0,		0.0},{ 5.0/24.0,14.0/24.0,		0.0}},					
-								{{14.0/24.0, 5.0/24.0, 5.0/24.0},{ 5.0/24.0,14.0/24.0, 5.0/24.0},{ 5.0/24.0, 5.0/24.0,14.0/24.0}},		
-								{{		0.0,14.0/24.0, 5.0/24.0},{		0.0, 5.0/24.0,14.0/24.0},{		0.0, 5.0/24.0, 5.0/24.0}},		
-								{{ 5.0/24.0,	  0.0,14.0/24.0},{ 5.0/24.0,	  0.0, 5.0/24.0},{14.0/24.0,	  0.0, 5.0/24.0}}}; 	
-
-/* get next two edges of surface itegration point */
-INT NextEdgeToSIP[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE][2] = {{{0,2},{0,1},{1,2}},
-								{{1,4},{1,5},{4,5}},
-								{{2,5},{3,5},{2,3}},
-								{{3,4},{0,3},{0,4}}};
-
-/* The indices of the corners of each side. */
-INT  CornerOfSide[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE] = {{0,2,1}, {1,2,3}, {2,0,3}, {3,0,1}};
-/* gives the position of specified corner on specified side or -1 if it does not ly on that side */
-INT  CornerOfSideInv[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_ELEM]  = {{0,2,1,-1}, {-1,0,1,2}, {1,-1,0,2}, {1,2,-1,0}};
-
-INT CornerOfSideAndEdge[MAX_SIDES_OF_ELEM][MAX_EDGES_OF_ELEM] = {{ 2, 0, 1,-1,-1,-1},
-																 {-1, 3,-1,-1, 2, 1},
-																 {-1,-1, 3, 2,-1, 0},
-																 { 3,-1,-1, 1, 0,-1}};
-
-/* The indices of the corner opposite to three corners. */
-INT  CornerOppCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM] =
-				{ {{-1,-1,-1,-1}, {-1,-1, 3, 2}, {-1, 3,-1, 1}, {-1, 2, 1,-1}}, 
-				  {{-1,-1, 3, 2}, {-1,-1,-1,-1}, { 3,-1,-1, 0}, { 2,-1, 0,-1}},
-				  {{-1, 3,-1, 1}, { 3,-1,-1, 0}, {-1,-1,-1,-1}, { 1, 0,-1,-1}},
-				  {{-1, 2, 1,-1}, { 2,-1, 0,-1}, { 1, 0,-1,-1}, {-1,-1,-1,-1}} };
-
-
-INT  SideOfCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM] =
-				{ {{-1,-1,-1,-1}, {-1,-1, 0, 3}, {-1, 0,-1, 2}, {-1, 3, 2,-1}}, 
-				  {{-1,-1, 0, 3}, {-1,-1,-1,-1}, { 0,-1,-1, 1}, { 3,-1, 1,-1}},
-				  {{-1, 0,-1, 2}, { 0,-1,-1, 1}, {-1,-1,-1,-1}, { 2, 1,-1,-1}},
-				  {{-1, 3, 2,-1}, { 3,-1, 1,-1}, { 2, 1,-1,-1}, {-1,-1,-1,-1}} };
-
-/* The indices of the corners of each edge and its opposite edge */
-/* dont change order !											 */
-INT  CornerOfEdge[MAX_EDGES_OF_ELEM][CORNERS_OF_EDGE]	 = {{0,1},{1,2},{0,2},{0,3},{1,3},{2,3}};
-INT  CornerOfOppEdge[MAX_EDGES_OF_ELEM][CORNERS_OF_EDGE] = {{2,3},{0,3},{3,1},{1,2},{2,0},{0,1}};
-
-
-/* the indices of the edges between two corners */
-INT  EdgeWithCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM] = {{-1,0,2,3},{0,-1,1,4},
-												  {2,1,-1,5},{3,4,5,-1}};
-
-/* the indices of the sides around each edge */
-INT  SideWithEdge[MAX_EDGES_OF_ELEM][MAX_SIDES_OF_EDGE] = {{0,3},{0,1},{0,2},{2,3},{1,3},{1,2}};
-
-/* the index of the side having to specified edges */
-INT  SideOf2Edges[MAX_EDGES_OF_ELEM][MAX_EDGES_OF_ELEM] = {{-1,0,0,3,3,-1},{0,-1,0,-1,1,1},{0,0,-1,2,-1,2},{3,-1,2,-1,3,2},{3,1,-1,3,-1,1},{-1,1,2,2,1,-1}};
-
-/* the index of the edge having to specified sides */
-INT  EdgeOf2Sides[MAX_SIDES_OF_ELEM][MAX_SIDES_OF_ELEM] = {{-1,1,2,0},{1,-1,5,4},{2,5,-1,3},{0,4,3,-1}};
-
-/* the indices of the edges of each side */
-INT  EdgeOfSide[MAX_SIDES_OF_ELEM][EDGES_OF_TETRASIDE] = {{0,1,2},{1,5,4},{2,3,5},{0,4,3}};
-INT  CondensedEdgeOfSide[MAX_SIDES_OF_ELEM] = {0x07,0x32,0x2C,0x19};
-
-
-/* the indices of opposite corners for each side */
-INT OppositeCorner[MAX_SIDES_OF_ELEM] = {3,0,1,2};
-
-
-/* the indices of opposite sides for each corner */
-INT OppositeSide[MAX_CORNERS_OF_ELEM] = {1,2,3,0};
-
-/* determine from NodeOrder (0,24( the order of nodes of a tetrahedron :			*/
-/*	   Index=0 means the one with the largest Z-component in Cutting ref system 	*/
-/*	   Index=3 means the one with the smallest Z-component in Cutting ref system	*/
-INT CornerIndex[24][MAX_CORNERS_OF_ELEM] = {{0,1,2,3},{0,1,3,2},{0,2,1,3},{0,2,3,1},{0,3,1,2},{0,3,2,1},
-										{1,0,2,3},{1,0,3,2},{1,2,0,3},{1,2,3,0},{1,3,0,2},{1,3,2,0},
-										{2,0,1,3},{2,0,3,1},{2,1,0,3},{2,1,3,0},{2,3,0,1},{2,3,1,0},
-										{3,0,1,2},{3,0,2,1},{3,1,0,2},{3,1,2,0},{3,2,0,1},{3,2,1,0}  };
-							
-/* determine from NodeOrder (0,24( the order of nodes of a side of a tetrahedron :	*/
-/*	   Index=0 means the one with the largest Z-component in Cutting ref system 	*/
-/*	   Index=2 means the one with the smallest Z-component in Cutting ref system	*/
-INT SideCornerIndex[MAX_SIDES_OF_ELEM][24][MAX_CORNERS_OF_SIDE] =
-						 {
-						   { {0,1,2},{0,1,2},{0,2,1},{0,2,1},{0,1,2},{0,2,1},
-							 {1,0,2},{1,0,2},{1,2,0},{1,2,0},{1,0,2},{1,2,0},
-							 {2,0,1},{2,0,1},{2,1,0},{2,1,0},{2,0,1},{2,1,0},
-							 {0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0} },
-						   { {1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1},
-							 {1,2,3},{1,3,2},{1,2,3},{1,2,3},{1,3,2},{1,3,2},
-							 {2,1,3},{2,3,1},{2,1,3},{2,1,3},{2,3,1},{2,3,1},
-							 {3,1,2},{3,2,1},{3,1,2},{3,1,2},{3,2,1},{3,2,1} },
-						   { {0,2,3},{0,3,2},{0,2,3},{0,2,3},{0,3,2},{0,3,2},
-							 {0,2,3},{0,3,2},{2,0,3},{2,3,0},{3,0,2},{3,2,0},
-							 {2,0,3},{2,0,3},{2,0,3},{2,3,0},{2,3,0},{2,3,0},
-							 {3,0,2},{3,0,2},{3,0,2},{3,2,0},{3,2,0},{3,2,0} },
-						   { {0,1,3},{0,1,3},{0,1,3},{0,3,1},{0,3,1},{0,3,1},
-							 {1,0,3},{1,0,3},{1,0,3},{1,3,0},{1,3,0},{1,3,0},
-							 {0,1,3},{0,3,1},{1,0,3},{1,3,0},{3,0,1},{3,1,0},
-							 {3,0,1},{3,0,1},{3,1,0},{3,1,0},{3,0,1},{3,1,0} } };
-							
-/* determine number of edge from reduced (i.e. restricted to one side) edgepattern */
-/* if there are two edges marked for bisection, if not deliver -1. If the edge-    */
-/* is not reduced (i.e. marked edges lying on more than one side) deliver -2	   */
-INT TriSectionEdge[64][2] = {  {-1,-1},{-1,-1},{-1,-1},{ 1, 0},{-1,-1},{ 0, 2},{ 2, 1},{-1,-1},
-							   {-1,-1},{ 3, 0},{-2,-2},{-2,-2},{ 2, 3},{-2,-2},{-2,-2},{-2,-2},
-							   {-1,-1},{ 0, 4},{ 4, 1},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},
-							   { 4, 3},{-1,-1},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},
-							   {-1,-1},{-2,-2},{ 1, 5},{-2,-2},{ 5, 2},{-2,-2},{-2,-2},{-2,-2},
-							   { 3, 5},{-2,-2},{-2,-2},{-2,-2},{-1,-1},{-2,-2},{-2,-2},{-2,-2},
-							   { 5, 4},{-2,-2},{-1,-1},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},
-							   {-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2},{-2,-2}	};
-
-/* midnode of edge */
-INT MidNodeOfEdge[MAX_EDGES_OF_ELEM] = {4,5,6,7,8,9};
-
-/* the unique disjoint edge */
-INT OppositeEdge[MAX_EDGES_OF_ELEM] = {5,3,4,1,2,0};
-
-/* two times [second entry] two [third entry] edges for spec. edge [first entry] which bild up a side */
-INT SideEdgesOfEdge[MAX_EDGES_OF_ELEM][2][2] = {{{1,2},{3,4}},
-					{{0,2},{4,5}},
-					{{0,1},{3,5}},
-					{{2,5},{0,4}},
-					{{1,5},{0,3}},
-					{{1,4},{2,3}}};
-
-/* edges with a given corner */ 
-INT EdgesOfCorner[MAX_CORNERS_OF_ELEM][3] = {{0,2,3},{0,1,4},{1,2,5},{3,4,5}};
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of variables global to this source file only (static!)        */
-/*                                                                          */
-/****************************************************************************/
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/simplex.c,v 1.3 1995/11/30 11:24:39 klaus Exp $";
-
-/***************************************************************************
- *																		   *
- *							 Forward functions							   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *							  Implementation							   *
- *																		   *
- ***************************************************************************/
-
-/***************************************************************************
- *																		   *
- *								 The End								   *
- *																		   *
- ***************************************************************************/
-
-
diff -ruN ug-orig/gm/simplex.h ug-patched/gm/simplex.h
--- ug-orig/gm/simplex.h	1995-11-30 12:24:40.000000000 +0100
+++ ug-patched/gm/simplex.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,108 +0,0 @@
-/***************************************************************************
- *																		   *
- *	File:		 simplex.h												   *
- *																		   *
- *	Purpose:	 definition and algorithms for simplices header file	   *
- *																		   *
- *	Author: 	 Juergen Bey											   *
- *				 Mathematisches Institut								   *
- *				 Auf der Morgenstelle 10								   *
- *				 7400 Tuebingen 										   *
- *			     email: ug@ica3.uni-stuttgart.de					       * 
- *																		   *
- *	History:	 10.12.92  begin										   *
- *																		   *
- *	Remarks:															   *
- *																		   *
- ***************************************************************************/
-
-#ifndef __SIMPLEX__
-#define __SIMPLEX__
-
-/***************************************************************************
- *																		   *
- *								 Includes								   *
- *																		   *
- ***************************************************************************/
-
-#ifdef __MISC__
-#include "misc.h"
-#endif
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-/***************************************************************************
- *																		   *
- *								 Constants								   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *								  Macros								   *
- *																		   *
- ***************************************************************************/
-
-#define CORNERS_OF_TETRASIDE	3
-#define EDGES_OF_TETRASIDE		3
-
-/***************************************************************************
- *																		   *
- *							  Data structures							   *
- *																		   *
- ***************************************************************************/
-
-
-/***************************************************************************
- *																		   *
- *							  Global variables							   *
- *																		   *
- ***************************************************************************/
-
-extern	COORD			TRefCoord[MAX_CORNERS_OF_ELEM][DIM];
-extern	COORD_VECTOR	LIP[MAX_EDGES_OF_ELEM];
-extern	COORD_VECTOR	LSIP[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE];
-
-extern	INT   CornerOfSide[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE];
-extern	INT   SignOfSide[2][MAX_SIDES_OF_ELEM]; 
-extern	INT   CornerOfEdge[MAX_EDGES_OF_ELEM][CORNERS_OF_EDGE];
-extern	INT   CornerOfOppEdge[MAX_EDGES_OF_ELEM][CORNERS_OF_EDGE];
-extern	INT   EdgeWithCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM];
-extern	INT   SideWithEdge[MAX_EDGES_OF_ELEM][MAX_SIDES_OF_EDGE];
-extern	INT   EdgeOfSide[MAX_SIDES_OF_ELEM][EDGES_OF_TETRASIDE];
-extern	INT   OppositeCorner[MAX_SIDES_OF_ELEM];
-extern	INT   OppositeSide[MAX_SIDES_OF_ELEM];
-extern	INT   CornerOppCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM];
-extern	INT   CornerIndex[24][MAX_CORNERS_OF_ELEM];
-extern	INT   SideCornerIndex[MAX_SIDES_OF_ELEM][24][MAX_CORNERS_OF_SIDE];
-extern	INT   CondensedEdgeOfSide[MAX_SIDES_OF_ELEM];
-extern	INT   TriSectionEdge[64][2];
-extern	INT   CornerOfSideInv[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_ELEM];
-extern	INT   MidNodeOfEdge[MAX_EDGES_OF_ELEM];
-extern	INT   OppositeEdge[MAX_EDGES_OF_ELEM];
-extern	INT   EdgesOfCorner[MAX_CORNERS_OF_ELEM][3];
-extern	INT   SideEdgesOfEdge[MAX_EDGES_OF_ELEM][2][2];
-extern	INT   NextEdgeToSIP[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE][2];
-extern  INT   SideOf2Edges[MAX_EDGES_OF_ELEM][MAX_EDGES_OF_ELEM];
-extern  INT   EdgeOf2Sides[MAX_SIDES_OF_ELEM][MAX_SIDES_OF_ELEM];
-extern 	INT	  CornerOfSideAndEdge[MAX_SIDES_OF_ELEM][MAX_EDGES_OF_ELEM];
-extern  INT   SideOfCorners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM];
-
-/***************************************************************************
- *																		   *
- *							  Extern functions							   *
- *																		   *
- ***************************************************************************/
-
-
-#endif
-
-/***************************************************************************
- *																		   *
- *								 The End								   *
- *																		   *
- ***************************************************************************/
-
diff -ruN ug-orig/gm/smooth.c ug-patched/gm/smooth.c
--- ug-orig/gm/smooth.c	2005-07-18 15:42:57.000000000 +0200
+++ ug-patched/gm/smooth.c	2008-12-19 11:02:55.000000000 +0100
@@ -24,6 +24,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -69,7 +70,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/smooth.c,v 1.37 2005/07/18 13:42:57 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /** \brief Calculate displacement of the center point along one local coordinate
diff -ruN ug-orig/gm/ugio.c ug-patched/gm/ugio.c
--- ug-orig/gm/ugio.c	2005-08-08 10:48:25.000000000 +0200
+++ ug-patched/gm/ugio.c	2009-04-29 15:11:55.000000000 +0200
@@ -31,6 +31,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -159,7 +160,7 @@
 static int proc_list_size = -1;				/* hold the computed value for PROCLISTSIZE; initialized with crazy dummy */
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/ugio.c,v 1.214 2005/08/08 08:48:25 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -169,24 +170,6 @@
 
 static INT WriteElementParInfo (GRID *theGrid, ELEMENT *theElement, MGIO_PARINFO *pinfo);
 
-/****************************************************************************/
-/*D
-   RenumberMultiGrid - Recalculate ids in the current order
-
-   SYNOPSIS:
-   INT RenumberMultiGrid (MULTIGRID *theMG);
-
-   PARAMETERS:
-.  theMG - structure to renumber
-
-   DESCRIPTION:
-   This function recalculates ids in the current order.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-D*/
-/****************************************************************************/
 
 /************************************************************************************/
 /*     																				*/
@@ -267,29 +250,6 @@
 	return (0);
 }
 
-/****************************************************************************/
-/*D
-	SaveMultiGrid - Save complete multigrid structure in a text file
-	
-	SYNOPSIS:
-	INT SaveMultiGrid (MULTIGRID *theMG, char *name, char *comment);
-	
-	PARAMETERS:
-	.  theMG - pointer to multigrid
-	.  name - name of the text file
-	.  comment - to be included at beginning of file
-	
-	DESCRIPTION:
-	This function saves the grid on level 0 to a text file.
-	The text file can be used in a script to load the grid.
-	
-	RETURN VALUE:
-	INT
-	.n    0 if ok
-	.n    >0 if error occured.
-	D*/
-/****************************************************************************/
-
 static INT SaveSurfaceGrid  (MULTIGRID *theMG, FILE *stream)
 {
 	NODE *theNode;
@@ -380,7 +340,7 @@
 	return(GM_OK);
 }
 
-static INT SaveMultiGrid_SCR (MULTIGRID *theMG, char *name, char *comment)
+static INT SaveMultiGrid_SCR (MULTIGRID *theMG, const char *name, const char *comment)
 {
 	FILE *stream;
 	GRID *theGrid;
@@ -389,7 +349,7 @@
 	VERTEX *theVertex;
 	DOUBLE *global;
 	time_t Time;
-	char *fmt;
+	const char *fmt;
 	char buffer[BUFFERSIZE];
 	BVP_DESC theBVPDesc;
 	INT i,id,move,part;
@@ -687,6 +647,17 @@
 	return(error);
 }
 
+/****************************************************************************/
+/** \brief Recalculate ids in the current order
+
+\param theMG - structure to renumber
+
+   This function recalculates ids in the current order.
+
+   \return 0 if ok
+*/
+/****************************************************************************/
+
 INT NS_DIM_PREFIX RenumberMultiGrid (MULTIGRID *theMG, INT *nboe, INT *nioe, INT *nbov, INT *niov, NODE ***vid_n, INT *foid, INT *non, INT MarkKey)
 {
 	NODE *theNode;
@@ -1308,7 +1279,7 @@
 }
 #endif
 
-static INT SaveMultiGrid_SPF (MULTIGRID *theMG, char *name, char *type, char *comment, INT autosave, INT rename)
+static INT SaveMultiGrid_SPF (MULTIGRID *theMG, const char *name, const char *type, const char *comment, INT autosave, INT rename)
 {
 	GRID *theGrid;
 	NODE *theNode;
@@ -1732,7 +1703,24 @@
 	return (0);
 }
 
-INT NS_DIM_PREFIX SaveMultiGrid (MULTIGRID *theMG, char *name, char *type, char *comment, INT autosave, INT rename)
+/****************************************************************************/
+/** \brief Save complete multigrid structure in a text file
+	
+ \param theMG - pointer to multigrid
+ \param name - name of the text file
+ \param comment - to be included at beginning of file
+	
+ This function saves the grid on level 0 to a text file.
+ The text file can be used in a script to load the grid.
+	
+ \return <ul>
+ <li> 0 if ok </li>
+ <li> >0 if error occured </li>
+ </ul>
+*/
+/****************************************************************************/
+
+INT NS_DIM_PREFIX SaveMultiGrid (MULTIGRID *theMG, const char *name, const char *type, const char *comment, INT autosave, INT rename)
 {
 	/* check name convention */
 	if (name==NULL || strcmp(name+strlen(name)-4,".scr")!=0)
@@ -1746,31 +1734,6 @@
 	return (0);
 }
 
-/****************************************************************************/
-/*
-LoadMultiGrid - Load complete multigrid structure from a text file
-
-SYNOPSIS:
-MULTIGRID *LoadMultiGrid (char *MultigridName, char *FileName, 
-char *BVPName, char *format, unsigned long heapSize);
-
-PARAMETERS:
-.  MultigridName - Name of the new 'MULTIGRID' structure in memory.
-.  FileName - Name of the file to be read.
-.  BVPName - `Name` of the BVP used for the 'MULTIGRID'.
-.  format - `Name` of the 'FORMAT' to be used for the 'MULTIGRID'.
-.  heapSize - Size of the heap in bytes that will be allocated for the 'MULTIGRID'.
-
-DESCRIPTION:
-This function can read grid files produced with the 'SaveMultiGrid' function.
-
-RETURN VALUE:
-INT
-.n    NULL if an error occured
-.n    else pointer to new 'MULTIGRID'
-*/
-/****************************************************************************/
-
 static INT Evaluate_pinfo (GRID *theGrid, ELEMENT *theElement, MGIO_PARINFO *pinfo)
 {
 	INT			i,j,s,prio,where,oldwhere,old;
@@ -2755,7 +2718,32 @@
 }
 #endif
 	
-MULTIGRID * NS_DIM_PREFIX LoadMultiGrid (char *MultigridName, char *name, char *type, char *BVPName, char *format, unsigned long heapSize, INT force, INT optimizedIE, INT autosave)
+/****************************************************************************/
+/** \brief  Load complete multigrid structure from a text file
+
+\param MultigridName - Name of the new 'MULTIGRID' structure in memory.
+\param FileName - Name of the file to be read.
+\param BVPName - `Name` of the BVP used for the 'MULTIGRID'.
+\param format - `Name` of the 'FORMAT' to be used for the 'MULTIGRID'.
+\param heapSize - Size of the heap in bytes that will be allocated for the 'MULTIGRID'.
+
+This function can read grid files produced with the 'SaveMultiGrid' function.
+
+\return
+  NULL if an error occured else a pointer to new 'MULTIGRID'
+*/
+/****************************************************************************/
+
+
+MULTIGRID * NS_DIM_PREFIX LoadMultiGrid (const char *MultigridName, 
+                                         const char *name, 
+                                         const char *type, 
+                                         const char *BVPName, 
+                                         const char *format, 
+                                         unsigned long heapSize, 
+                                         INT force, 
+                                         INT optimizedIE, 
+                                         INT autosave)
 /* Documentation of the intended programm flow resp. communication requirements.
    Functions introducing a global communication (all processors without any exception)
    are:
diff -ruN ug-orig/gm/ugio.h ug-patched/gm/ugio.h
--- ug-orig/gm/ugio.h	2006-05-08 14:29:57.000000000 +0200
+++ ug-patched/gm/ugio.h	2006-05-08 14:31:31.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/ugio.h,v 1.9 2006/05/08 12:29:57 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/gm/ugm2d.c ug-patched/gm/ugm2d.c
--- ug-orig/gm/ugm2d.c	1996-02-22 18:29:33.000000000 +0100
+++ ug-patched/gm/ugm2d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,1065 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugm2d.c														*/
-/*																			*/
-/* Purpose:   Functions only available in 2D								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70569 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de					    		*/
-/*																			*/
-/* History:   13.12.94 begin, ug version 3.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "compiler.h"
-#include "heaps.h"
-#include "ugenv.h"
-
-#include "devices.h"
-
-#include "switch.h"
-#include "gm.h"
-#include "misc.h"
-#include "ugm.h"
-#include "ugm2d.h"
-#include "shapes2d.h"
-
-
-#ifdef __THREEDIM__
-#error this source file is for 2D ONLY
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define SMALL1 0.001
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/ugm2d.c,v 1.4 1996/02/22 17:29:33 wieners Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*D
-   FindFather - Find the new father element
-
-   SYNOPSIS:
-   static ELEMENT *FindFather(VERTEX *vptr);
-
-   PARAMETERS:
-.  vptr - Pointer to 'VERTEX' whose father element is to be found.
-
-   DESCRIPTION:
-   This function finds the new father element of the given vertex.  
-   It assumes that the  new father is one of the neighbors of the 
-   old father element. The current father of 'vptr' is not changed.
-
-   RETURN VALUE:
-   ELEMENT *
-.n     pointer to an element
-.n     NULL if none or no correct father is found or vertex is level 0
-D*/
-/****************************************************************************/
-
-static ELEMENT *FindFather(VERTEX *vptr)
-{
-	short i;
-	COORD x[2],lambda,lambda1,lambda2;
-	ELEMENT *eptr,*eptr1;
-	ELEMENTSIDE *eside;
-	VSEGMENT *vseg;
-	
-	if ((eptr=VFATHER(vptr))==NULL)
-		return(NULL);
-	
-	if (OBJT(vptr)==BVOBJ)
-	{
-		/* for boundary vertices only a consistency check is made */
-		eside=SIDE(eptr,ONEDGE(vptr));
-		vseg = VSEG(vptr);
-		
-		if (VS_PATCH(vseg)!=ES_PATCH(eside))
-			return(NULL);
-		
-		/* for higher dimensions (3d) the following must be generalized */
-		lambda=LAMBDA(vseg,0);
-		lambda1=PARAM(eside,0,0);
-		lambda2=PARAM(eside,1,0);
-		if ( ((lambda1<=lambda)&&(lambda2>=lambda)) || ((lambda2<=lambda)&&(lambda1>=lambda)) )
-			return(eptr);
-		else
-			return(NULL);
-	}
-	
-	x[0]=XC(vptr); x[1]=YC(vptr);
-	
-	eptr=VFATHER(vptr);
-	if (PointInElement(x,eptr))
-		return(eptr);
-	
-	for (i=0; i<SIDES_OF_ELEM(eptr); i++)
-		if (PointInElement(x,(eptr1=NBELEM(eptr,i))))
-			return(eptr1);
-		
-	return(NULL);
-}
-
-
-
-/****************************************************************************/
-/*D
-   Local2Global - Updates the global coordinates of a vertex
-
-   SYNOPSIS:
-   static INT Local2Global (MULTIGRID *theMG, VERTEX *vptr);
-
-   PARAMETERS:
-.  theMG - pointer to 'MULTIGRID' structure.
-.  vptr - pointer to a 'VERTEX'
-
-   DESCRIPTION:
-   This function updates the global coordinates of a vertex by
-   evaluating the local coordinates in the father element of the vertex.
-   This function overwrites the current coordinates, it works for interior
-   and boundary vertices.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   >0 if an error occured or vertex is on level 0	
-D*/
-/****************************************************************************/
-
-static INT Local2Global (MULTIGRID *theMG, VERTEX *vptr)
-{
-	short i,n,side;
-	COORD x[DIM],xi,eta;
-	COORD lambda1,lambda2,lambdaa,lambdae;
-	ELEMENT *eptr;
-	VERTEX *vptr1,*vptr2,*vptra,*vptre;
-	VSEGMENT *vseg;
-	PATCH *thePatch;
-	PATCH_DESC 	 thePatchDesc;
-
-	if ((eptr=VFATHER(vptr))==NULL)
-		return(8040);
-	
-	n=TAG(eptr);
-	if (OBJT(vptr)==BVOBJ)
-	{
-		vseg = VSEG(vptr);
-		if ((thePatch=VS_PATCH(vseg))==NULL)	return(8041);
-		if (Patch_GetPatchDesc(thePatch,&thePatchDesc)) return(8041);
-		
-		side=ONEDGE(vptr);
-		vptr1=MYVERTEX(CORNER(eptr,side));
-		vptr2=MYVERTEX(CORNER(eptr,(side+1)%n));
-		
-		vptra=theMG->corners[PATCH_CID(thePatchDesc,0)]; lambdaa=PATCH_LCVECT(thePatchDesc,0)[0];
-		vptre=theMG->corners[PATCH_CID(thePatchDesc,1)]; lambdae=PATCH_LCVECT(thePatchDesc,1)[0];
-		
-		if (vptr1==vptra)
-			lambda1=lambdaa;
-		else
-			if (vptr1==vptre)
-				lambda1=lambdae;
-			else
-				lambda1=LAMBDA(VSEG(vptr1),0);
-		
-		if (vptr2==vptra)
-			lambda2=lambdaa;
-		else
-			if (vptr2==vptre)
-				lambda2=lambdae;
-			else
-				lambda2=LAMBDA(VSEG(vptr2),0);
-		
-				
-		LAMBDA(vseg,0)=(1-ZETA(vseg))*lambda1+ZETA(vseg)*lambda2;
-		if (Patch_local2global(thePatch,PVECT(vseg),CVECT(vptr))) return(8041);
-	}
-	else
-	{
-		xi=XI(vptr); eta=ETA(vptr);
-		x[0]=x[1]=0;
-		for (i=0; i<n; i++)
-		{
-			vptr1=MYVERTEX(CORNER(eptr,i));
-			x[0]+=XC(vptr1)*N(n,i,xi,eta);
-			x[1]+=YC(vptr1)*N(n,i,xi,eta);
-		}
-		
-		XC(vptr)=x[0]; YC(vptr)=x[1];
-	}
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   Global2Local - Updates the local coordinates of a vertex
-
-   SYNOPSIS:
-   static INT Global2Local (MULTIGRID *theMG, VERTEX *vptr);
-
-   PARAMETERS:
-.  theMG - pointer to 'MULTIGRID'
-.  vptr - pointer to a 'VERTEX'
-
-   DESCRIPTION:
-   This function updates the local coordinates of a vertex in the
-   local coordinate system of the father element. It is assumed that
-   the vertex is inside the father element. If not an error is returned.
-
-   RETURN VALUE:
-   INT 
-.n    0 if ok vertex is level 0
-.n    >0 if error occured (invalid trafo, not inside)
-D*/
-/***************************************************************************/
-
-static INT Global2Local (MULTIGRID *theMG, VERTEX *vptr)
-{
-	short n,side;
-	DOUBLE t1x,t2x,t3x,t1y,t2y,t3y,a,b,c,D,xi1,xi2,eta1,eta2;
-	DOUBLE x1,x2,y1,y2,x3,y3,x4,y4,x,y;
-	DOUBLE a1,a2,a3,a4,b1,b2,b3,b4;
-	COORD lambda1,lambda2,lambdaa,lambdae;
-	ELEMENT *eptr;
-	VERTEX *vptr1,*vptr2,*vptra,*vptre;
-	VSEGMENT *vseg;
-	PATCH *thePatch;
-	PATCH_DESC thePatchDesc;
-	
-	if ((eptr=VFATHER(vptr))==NULL)
-		return(0);
-		
-	if (OBJT(vptr)==BVOBJ)
-	{
-		n=TAG(eptr);
-		vseg = VSEG(vptr);
-		thePatch=VS_PATCH(vseg);
-		if (Patch_GetPatchDesc(thePatch,&thePatchDesc)) return (1);
-		side=ONEDGE(vptr);
-		vptr1=MYVERTEX(CORNER(eptr,side));
-		vptr2=MYVERTEX(CORNER(eptr,(side+1)%n));
-		
-		vptra=theMG->corners[PATCH_CID(thePatchDesc,0)]; lambdaa=PATCH_LCVECT(thePatchDesc,0)[0];
-		vptre=theMG->corners[PATCH_CID(thePatchDesc,1)]; lambdae=PATCH_LCVECT(thePatchDesc,1)[0];
-		
-		if (vptr1==vptra)
-			lambda1=lambdaa;
-		else
-			if (vptr1==vptre)
-				lambda1=lambdae;
-			else
-				lambda1=LAMBDA(VSEG(vptr1),0);
-		
-		if (vptr2==vptra)
-			lambda2=lambdaa;
-		else
-			if (vptr2==vptre)
-				lambda2=lambdae;
-			else
-				lambda2=LAMBDA(VSEG(vptr2),0);
-		
-		/* falls sich Projektion auf Edge als sinnvoller erweist
-		x = XC(vptr); y = YC(vptr);
-		x1 = XC(vptr1); y1 = YC(vptr1);
-		x2 = XC(vptr2); y2 = YC(vptr2);
-		a=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
-		b=sqrt(pow(x-x1,2)+pow(y-y1,2));
-		assert(errno==0);
-		if (a*b==0) 
-			return(8052);
-		c=((x-x1)*(x2-x1)+(y-y1)*(y2-y1))/(a*b);
-		if ((c<.1)||(c>.9))
-			return(8053);
-		*/
-		
-		/* set local boundary coordinate */
-		ZETA(vseg)=c=(LAMBDA(vseg,0)-lambda1)/(lambda2-lambda1);
-		
-		/* set local coordinates */
-		switch(n)
-		{
-			case TRIANGLE:
-			XI(vptr) = ETA(vptr) = 0.0;
-			switch (side)
-			{
-				case 0: XI(vptr)=c; break;
-				case 1: XI(vptr)=1-c; ETA(vptr)=c; break;
-				case 2: ETA(vptr)=1-c; break;
-			}
-			break;
-			
-			case QUADRILATERAL:
-			switch (side)
-			{
-				case 0: XI(vptr)=2*c-1; ETA(vptr) = -1;  break;
-				case 1: XI(vptr) = 1;	ETA(vptr)=2*c-1; break;
-				case 2: XI(vptr)=1-2*c; ETA(vptr) = 1;	 break;
-				case 3: XI(vptr) = -1;	ETA(vptr)=1-2*c; break;
-			}
-			break;
-		}
-	}
-	else
-	{
-		/* compute local coordinates */
-		vptr1=MYVERTEX(CORNER(eptr,0)); x1 = XC(vptr1); y1 = YC(vptr1);
-		vptr1=MYVERTEX(CORNER(eptr,1)); x2 = XC(vptr1); y2 = YC(vptr1);
-		vptr1=MYVERTEX(CORNER(eptr,2)); x3 = XC(vptr1); y3 = YC(vptr1);
-		x = XC(vptr);
-		y = YC(vptr);
-		
-		switch (TAG(eptr))
-		{
-			case TRIANGLE:
-			t1x = x2-x1; t2x = x3-x1; t3x = x1;
-			t1y = y2-y1; t2y = y3-y1; t3y = y1;
-			D = t1x*t2y-t2x*t1y;
-			if (D<0.0)
-				return(8051);
-			
-			XI(vptr) = (t2y*(x-t3x)-t2x*(y-t3y))/D;
-			ETA(vptr) = (-t1y*(x-t3x)+t1x*(y-t3y))/D;
-			break;
-			
-			case QUADRILATERAL:
-			vptr1=MYVERTEX(CORNER(eptr,3)); x4 = XC(vptr1); y4 = YC(vptr1);
-			
-			a1=-x+.25*(x1+x2+x3+x4); b1=-y+.25*(y1+y2+y3+y4);
-			a2=.25*(-x1+x2+x3-x4); b2=.25*(-y1+y2+y3-y4);
-			a3=.25*(-x1-x2+x3+x4); b3=.25*(-y1-y2+y3+y4);
-			a4=.25*(x1-x2+x3-x4); b4=.25*(y1-y2+y3-y4);
-			
-			c=a2*b1-a1*b2;
-			b=a4*b1-a3*b2+a2*b3-a1*b4;
-			a=a4*b3-a3*b4;
-			
-			if (ABS(a)<SMALL_D)
-			{
-				if (ABS(b)<SMALL_D)
-					return(8051);
-				
-				eta1 = eta2 = -c/b;
-			}
-			else
-			{
-				D=b*b-4*a*c;
-				if (D<0) return(8051);
-				
-				eta1=(-b+sqrt(D))/(2*a); eta2=(-b-sqrt(D))/(2*a);
-			}
-			
-			c=a3*b1-a1*b3;
-			b=a4*b1+a3*b2-a2*b3-a1*b4;
-			a=a4*b2-a2*b4;
-			
-			if (ABS(a)<SMALL_D)
-			{
-				if (ABS(b)<SMALL_D)
-					return(8051);
-				
-				xi1 = xi2 = -c/b;
-			}
-			else
-			{
-				D=b*b-4*a*c;
-				if (D<0) return(8051);
-				
-				xi1=(-b+sqrt(D))/(2*a); xi2=(-b-sqrt(D))/(2*a);
-			}
-			
-			if ((xi1>=-1-SMALL1)&&(xi1<=1+SMALL1)&&(eta1>=-1-SMALL1)&&(eta1<=1+SMALL1))
-			{
-				XI(vptr) = xi1;
-				ETA(vptr) = eta1;
-				break;
-			}
-			
-			if ((xi2>=-1-SMALL1)&&(xi2<=1+SMALL1)&&(eta1>=-1-SMALL1)&&(eta1<=1+SMALL1))
-			{
-				XI(vptr) = xi2;
-				ETA(vptr) = eta1;
-				break;
-			}
-			
-			if ((xi1>=-1-SMALL1)&&(xi1<=1+SMALL1)&&(eta2>=-1-SMALL1)&&(eta2<=1+SMALL1))
-			{
-				XI(vptr) = xi1;
-				ETA(vptr) = eta2;
-				break;
-			}
-			
-			if ((xi2>=-1-SMALL1)&&(xi2<=1+SMALL1)&&(eta2>=-1-SMALL1)&&(eta2<=1+SMALL1))
-			{
-				XI(vptr) = xi2;
-				ETA(vptr) = eta2;
-				break;
-			}
-			
-			return(8051);
-			break;
-		}
-	}
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*D
-   MoveInnerNode - Let user enter a new position for an inner node
-
-   SYNOPSIS:
-   INT MoveInnerNode (MULTIGRID *theMG, NODE *theNode, COORD *newPos);
-
-   PARAMETERS:
-.  theMG - pointer to multigrid
-.  theNode - node to move
-.  newPos - new position (x,y)
-
-   DESCRIPTION:
-   This function moves a given node to a new position. The complete
-   multigrid structure is moved hierachically, that all global coordinates
-   of nodes are updated in order to reflect the changes on coarser grids.
-
-   `Function only implemented in 2D version !`
-
-   RETURN VALUE:
-   INT
-.n   0 when ok
-.n   >0 when error occured.	 
-D*/
-/****************************************************************************/
-
-INT MoveInnerNode (MULTIGRID *theMG, NODE *theNode, COORD *newPos)
-{
-	GRID *theGrid2;
-	int k,k2;
-	NODE *theNode2;
-	VERTEX *theVertex,*theVertex2;
-	ELEMENT *theElement,*oldElement;
-	double x,y,oldx,oldy;
-
-	k = LEVEL(theNode);
-
-	/* set k (and theNode) to the level where the node appears the first time */
-	while ((theNode2=NFATHER(theNode))!=NULL)
-	{
-		theNode=theNode2;
-		k=k-1;
-	}
-	
-	theVertex = MYVERTEX(theNode);
-	oldx = XC(theVertex); oldy = YC(theVertex);
-
-	if (OBJT(theVertex)!=IVOBJ)
-	{
-		PrintErrorMessage('E',"MoveInnerNode","no inner node passed");
-		return(GM_ERROR);
-	}
-	
-	x = newPos[0]; y = newPos[1];
-	
-	/* set values */
-	XC(theVertex) = x; YC(theVertex) = y;
-	if (VFATHER(theVertex)!=NULL)
-	{
-		oldElement=VFATHER(theVertex);
-		if ((theElement=FindFather(theVertex))==NULL)
-		{
-			PrintErrorMessage('E',"MoveInnerNode","No father element! Probably you tried to move the vertex too far!");
-			XC(theVertex) = oldx; YC(theVertex) = oldy;
-			return(GM_ERROR);
-		}
-		else
-			VFATHER(theVertex)=theElement;
-		
-		if (Global2Local(theMG,theVertex)!=0)
-		{
-			PrintErrorMessage('E',"MoveInnerNode","Error in Global2Local");
-			VFATHER(theVertex)=oldElement;
-			XC(theVertex) = oldx; YC(theVertex) = oldy;
-			return(GM_ERROR);
-		}
-	}
-	
-	/*	now we correct the global coordinates for all levels above, since it is not
-		easy to find exactly the vertices whose global coordinates have changed */
-	
-	for(k2=k+1; k2<=theMG->topLevel; k2++)
-	{
-		theGrid2 = theMG->grids[k2];
-		for (theVertex2=FIRSTVERTEX(theGrid2); theVertex2!=NULL; theVertex2=SUCCV(theVertex2))
-			if (Local2Global(theMG,theVertex2)!=0)
-			{
-				PrintErrorMessage('E',"MoveInnerNode","Fatal error in correcting global coordinates for higher levels. Grid may be inconsistent from now on.");
-				return(GM_ERROR);
-			}
-	}
-	
-	/* OK, done */
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*D
-   MoveBoundaryNode - Let user enter a new position
-
-   SYNOPSIS:
-   INT MoveBoundaryNode (MULTIGRID *theMG, NODE *theNode, INT segid, 
-   COORD *newPos);
-
-   PARAMETERS:
-.  theMG - pointer to multigrid
-.  theNode - node to move
-.  segid - new boundary segment id
-.  newPos - new parameter lambda
-
-   DESCRIPTION:
-   This function moves a boundary node to a new position. The position of
-   all nodes on finer grids is updated to reflect these changes.
-
-   `Function only implemented in 2D version!`
-
-   RETURN VALUE:
-   INT
-.n    0 when ok
-.n    >0 when error occured.		 
-D*/
-/****************************************************************************/
-
-INT MoveBoundaryNode (MULTIGRID *theMG, NODE *theNode, INT patchid, COORD *newPos)
-{
-	GRID *theGrid,*theGrid2;
-	int i,n,k,k2;
-	NODE *theNode2;
-	VERTEX *theVertex,*theVertex2;
-	ELEMENT *theElement,*oldElement;
-	ELEMENTSIDE *theSide;
-	double oldx,oldy,l,oldl;
-	BVP 		*theBVP;
-	BVP_DESC 	 theBVPDesc;
-	PATCH *thePatch, *oldPatch;
-	PATCH_DESC 	 thePatchDesc;
-
-	/* get BVP description */
-	theBVP = MG_BVP(theMG);
-	if (BVP_GetBVPDesc(theBVP,&theBVPDesc))
-	{
-		PrintErrorMessage('E',"MoveBoundaryNode","cannot evaluate BVP");
-		return(1);
-	}	
-
-	k = LEVEL(theNode);
-	theGrid = GRID_ON_LEVEL(theMG,k);
-
-	/* set k (and theNode) to the level where the node appears the first time */
-	while ((theNode2=NFATHER(theNode))!=NULL)
-	{
-		theNode=theNode2;
-		k=k-1;
-	}
-	
-	theVertex = MYVERTEX(theNode);
-	oldx = XC(theVertex); oldy = YC(theVertex);
-
-	if (OBJT(theVertex)!=BVOBJ)
-	{
-		PrintErrorMessage('E',"MoveBoundaryNode","no boundary node passed");
-		return(GM_ERROR);
-	}
-
-	if (MOVE(theVertex)==0)
-	{
-		PrintErrorMessage('W',"MoveBoundaryNode","corners cannot be moved");
-		return(GM_ERROR);
-	}
-
-	l = oldl = LAMBDA(VSEG(theVertex),0);
-	oldPatch = VS_PATCH(VSEG(theVertex));
-	if (START(theNode)==NULL)
-	{
-		if(patchid >= BVPD_NPATCHES(theBVPDesc))
-		{
-			PrintErrorMessage('E',"MoveBoundaryNode","patchid out of range");
-			return(GM_ERROR);
-		}
-		thePatch = Patch_GetPatchByID(theBVP,patchid);
-	}
-	else	thePatch = VS_PATCH(VSEG(theVertex));
-
-	if (Patch_GetPatchDesc(thePatch,&thePatchDesc)) return (1);
-	patchid = PATCH_ID(thePatchDesc);
-		
-	l = newPos[0];
-
-	if ((l<PATCH_LCVECT(thePatchDesc,0)[0]) || (l>PATCH_LCVECT(thePatchDesc,1)[0]))
-	{
-		PrintErrorMessage('E',"MoveBoundaryNode","parameter out of range");
-		return(GM_ERROR);
-	}
-		
-	LAMBDA(VSEG(theVertex),0) = l;
-	if (Patch_local2global(thePatch,PVECT(VSEG(theVertex)),CVECT(theVertex))) return (1);
-	VS_PATCH(VSEG(theVertex)) = thePatch;
-	
-	if (VFATHER(theVertex)!=NULL)
-	{
-		oldElement=VFATHER(theVertex);
-		if ((theElement=FindFather(theVertex))==NULL)
-		{
-			PrintErrorMessage('E',"MoveBoundaryNode","No father element! Probably you have tried to move the vertex too far");
-			XC(theVertex) = oldx; YC(theVertex) = oldy; LAMBDA(VSEG(theVertex),0)=oldl; VS_PATCH(VSEG(theVertex)) = oldPatch;
-			return(GM_ERROR);
-		}
-		else
-			VFATHER(theVertex)=theElement;
-		
-		if (Global2Local(theMG,theVertex)!=0)
-		{
-			PrintErrorMessage('E',"MoveBoundaryNode","Error in Global2Local!");
-			VFATHER(theVertex)=oldElement;
-			XC(theVertex) = oldx; YC(theVertex) = oldy; LAMBDA(VSEG(theVertex),0)=oldl;
-			return(GM_ERROR);
-		}
-	}
-	
-	/*	now we correct the global coordinates for all new vertices in the levels above, since it is not
-		easy to find exactly the vertices whose global coordinates have changed */
-	for(k2=k+1; k2<=theMG->topLevel; k2++)
-	{
-		theGrid2 = theMG->grids[k2];
-		for (theVertex2=FIRSTVERTEX(theGrid2); theVertex2!=NULL; theVertex2=SUCCV(theVertex2))
-			if (Local2Global(theMG,theVertex2)!=0)
-			{
-				PrintErrorMessage('E',"MoveBoundaryNode","Fatal error in correcting global coordinates for higher levels. Grid may be inconsistent from now on");
-				return(GM_ERROR);
-			}
-	}
-	
-	/* update element sides on this level */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if (OBJT(theElement)==BEOBJ)
-		{
-			n = SIDES_OF_ELEM(theElement);
-			for (i=0; i<n; i++)
-			{
-				theSide = SIDE(theElement,i);
-				if (theSide!=NULL)
-				{
-					if (MYVERTEX(CORNER(theElement,i))==theVertex)
-						PARAM(theSide,0,0) = l;
-					if (MYVERTEX(CORNER(theElement,(i+1)%n))==theVertex)
-						PARAM(theSide,1,0) = l;
-				}
-			}
-		}
-	
-	/* update (for simplicity) all sides on that segment for all levels above */
-	for(k2=k+1; k2<=theMG->topLevel; k2++)
-	{
-		theGrid2 = theMG->grids[k2];
-		for (theElement=theGrid2->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		{
-			if (OBJT(theElement)==BEOBJ)
-			{
-				n = SIDES_OF_ELEM(theElement);
-				for (i=0; i<n; i++)
-				{
-					theSide = SIDE(theElement,i);
-					if (theSide!=NULL)
-					{
-						theNode2=CORNER(theElement,i);
-						if (NFATHER(theNode2)==NULL)
-						{
-							theVertex2=MYVERTEX(theNode2);
-							if (VS_PATCH(VSEG(theVertex2))==thePatch)
-								PARAM(theSide,0,0) = LAMBDA(VSEG(theVertex2),0);
-						}
-						theNode2=CORNER(theElement,(i+1)%n);
-						if (NFATHER(theNode2)==NULL)
-						{
-							theVertex2=MYVERTEX(theNode2);
-							if (VS_PATCH(VSEG(theVertex2))==VS_PATCH(VSEG(theVertex)))
-								PARAM(theSide,1,0) = LAMBDA(VSEG(theVertex2),0);
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*D
-   SmoothMultiGrid - Interprete and execute a smooth multigrid command	
-
-   SYNOPSIS:
-   INT SmoothMultiGrid (MULTIGRID *theMG, INT niter, INT bdryFlag);
-
-   PARAMETERS:
-.  theMG - pointer to multigrid
-.  niter - number of iterations to do
-.  bdryFlag - see 'smoothmg' command.
-
-   DESCRIPTION:
-   This function smoothes all grid levels of a multigrid hierarchy.
-   It processes all grid levels from bottom to top. Within each grid
-   level all nodes that are not already in coarser levels are set to
-   a new position obtained by the center of gravity of their neighboring
-   nodes. The processing from bottom to top level ensures fast convergence
-   of the algorithm. Caution! The algorithm may produce undesirable
-   results for non-convex domains.
-
-   `This function is available in 2D version only!`
-
-   RETURN VALUE:
-   INT 
-.n    0 if ok
-.n    >0 if error occured.
-D*/
-/****************************************************************************/
-
-INT SmoothMultiGrid (MULTIGRID *theMG, INT niter, INT bdryFlag)
-{
-	int l,i,n;
-	double ratio;
-	DOUBLE N;
-	/* COORD beta,gamma; */
-	COORD lambda,lambda0,lambda1,lambda2,lambdaa,lambdae;
-	GRID *theGrid;
-	NODE *node,*node2;
-	ELEMENT *eptr;
-	ELEMENTSIDE *eside;
-	VERTEX *vptr0,*vptr1,*vptr2,*vptra,*vptre,*vptr;
-	LINK *lptr;
-	PATCH *thePatch;
-	PATCH_DESC thePatchDesc;
-	
-	COORD x[2];
-
-	n = niter;	
-	if (n<=0) n = 1;
-	if (n>50) n = 50;
-	
-	ratio=.5;
-	
-	for (i=0; i<n; i++)
-	{
-		for (l=0; l<=theMG->topLevel; l++)
-		{
-			theGrid=theMG->grids[l];
-			
-			/* update global coordinates of new nodes */
-			if (l!=0)
-				for (node=theGrid->firstNode; node!=NULL; node=SUCCN(node))
-					if (NFATHER(node)==NULL)
-					{
-						vptr=MYVERTEX(node);
-						if ((OBJT(vptr)!=BVOBJ)||(bdryFlag!=0))
-							if (Local2Global(theMG,vptr)!=0)
-								return(GM_ERROR);
-					}
-			
-			for (node=theGrid->firstNode; node!=NULL; node=SUCCN(node))
-			{
-				/* skip node if it is a copy from a lower level */
-				if (NFATHER(node)!=NULL) continue;
-				
-				vptr0=MYVERTEX(node);
-				if (OBJT(vptr0)==BVOBJ)
-				{
-					if (bdryFlag==0) continue;		/* boundary is not allowed to move */
-					if (MOVE(vptr0)==0) continue;	/* corner: do not move it */
-					
-					/* test if free boundary: since that type is determined by the grid it may only
-					be smoothed in certain cases and in a special way */
-					thePatch=VS_PATCH(VSEG(vptr0));
-					if(Patch_GetPatchDesc(thePatch,&thePatchDesc)) return(1);
-					if (PATCH_TYPE(thePatchDesc)==FREE)
-						continue;	/*free boundary is not allowed to be smoothed */
-					
-					/* first find endpoints of vptr0's boundary segment */
-					lambda0=LAMBDA(VSEG(vptr0),0);
-					vptra=theMG->corners[PATCH_CID(thePatchDesc,0)]; lambdaa=PATCH_LCVECT(thePatchDesc,0)[0];
-					vptre=theMG->corners[PATCH_CID(thePatchDesc,1)]; lambdae=PATCH_LCVECT(thePatchDesc,1)[0];
-					
-					/* search for the two nearest neighbors on the same segment */
-					vptr1=vptr2=NULL;
-					for (lptr=START(node); lptr!=NULL; lptr=NEXT(lptr))
-						if (EXTRA(MYEDGE(lptr))==0)
-						{
-							node2=NBNODE(lptr);
-							vptr=MYVERTEX(node2);
-							if (OBJT(vptr)!=BVOBJ)
-								continue;
-							
-							/* if on same segment get lambda value */
-							if (vptr==vptra)
-								lambda=lambdaa;
-							else
-								if (vptr==vptre)
-									lambda=lambdae;
-								else
-									if (thePatch==VS_PATCH(VSEG(vptr)))
-										lambda=LAMBDA(VSEG(vptr),0);
-									else
-										continue;
-							
-							if (lambda>lambda0)
-							{
-								if (vptr2==NULL)
-								{
-									vptr2=vptr;
-									lambda2=lambda;
-								}
-								else
-									if (lambda<lambda2)
-									{
-										vptr2=vptr;
-										lambda2=lambda;
-									}
-							}
-							else
-							{
-								if (vptr1==NULL)
-								{
-									vptr1=vptr;
-									lambda1=lambda;
-								}
-								else
-									if (lambda>lambda1)
-									{
-										vptr1=vptr;
-										lambda1=lambda;
-									}
-							}
-						}
-					
-					if ((vptr1==NULL)||(vptr2==NULL))
-						return(GM_ERROR);
-					
-					if (PATCH_TYPE(thePatchDesc)==FREE)
-					{
-						/*	This is only sensible if the free boundary is a line and the endpoints are moved.
-							A more general smoothing would be to use e.g. a quadratic interpolant. */
-						XC(vptr0)=.5*(XC(vptr1)+XC(vptr2));
-						YC(vptr0)=.5*(YC(vptr1)+YC(vptr2));
-						/*	since local and global boundary coordinates are given by the grid itself
-							they are assumed to be correct. */
-					}
-					else
-					{
-						LAMBDA(VSEG(vptr0),0)=.5*(lambda1+lambda2);
-						/* set global coordinates */
-						if (Patch_local2global(thePatch,PVECT(VSEG(vptr0)),CVECT(vptr0))) return (GM_ERROR);
-					
-						/* set local boundary coordinates */
-						if (Global2Local(theMG,vptr0)!=0)
-							return(GM_ERROR);
-					}
-				}
-				else
-				{
-					x[0]=x[1]=0; N=0;
-					
-					for (lptr=START(node); lptr!=NULL; lptr=NEXT(lptr))
-					{
-						node2=NBNODE(lptr);
-						vptr=MYVERTEX(node2);
-						
-						if (EXTRA(MYEDGE(lptr))==0)
-						{
-							x[0]+=XC(vptr);
-							x[1]+=YC(vptr);
-							N+=1;
-						}
-						else
-						{
-							x[0]+=ratio*XC(vptr);
-							x[1]+=ratio*YC(vptr);
-							N+= ratio;
-						}
-					}
-					
-					XC(vptr0)=x[0]/N; YC(vptr0)=x[1]/N;
-					
-					/* if there is a father element, change local variables */
-					if (l!=0)
-						if ((eptr=FindFather(vptr0))!=NULL)
-						{
-							VFATHER(vptr0)=eptr;
-							if (Global2Local(theMG,vptr0)!=0)
-								return(GM_ERROR);
-						}
-						else
-							return(GM_ERROR);
-				}
-			}
-			
-			/* at last, the boundary element sides of this level must be updated! */
-			for (eptr=theGrid->elements; eptr!=NULL; eptr=SUCCE(eptr))
-				if (OBJT(eptr)==BEOBJ)
-				{
-					n=SIDES_OF_ELEM(eptr);
-					for (i=0; i<n; i++)
-						if ((eside=SIDE(eptr,i))!=NULL)
-						{
-							/* for higher dimensions (3d) the following must be generalized */
-							vptr=MYVERTEX(CORNER(eptr,i));
-							if (MOVE(vptr)!=0)
-								PARAM(eside,0,0)=LAMBDA(VSEG(vptr),0);
-							vptr=MYVERTEX(CORNER(eptr,(i+1)%n));
-							if (MOVE(vptr)!=0)
-								PARAM(eside,1,0)=LAMBDA(VSEG(vptr),0);
-						}
-				}
-		}
-	}
-	
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*D
-   CreateAuxEdge - Inserts an 'EDGE' with AUXEDGE flag set
-
-   SYNOPSIS:
-   EDGE *CreateAuxEdge (GRID *theGrid, NODE *from, NODE *to);
-
-   PARAMETERS:
-.  theGrid - grid to remove from
-.  from - starting 'NODE'
-.  to - destination 'NODE'
-
-   DESCRIPTION:
-   This function inserts a new edge between given nodes.
-   This function is useful only in version 2.3 compatibility mode which is
-   not documented. 
-
-   RETURN VALUE:
-   INT
-.n     NULL when alloc failed 
-.n     else it returns a pointer to the new edge
-D*/
-/****************************************************************************/
-
-EDGE *CreateAuxEdge (GRID *theGrid, NODE *from, NODE *to)
-{
-	EDGE *theEdge;
-	
-	theEdge = CreateEdge(theGrid,from,to);
-	if (theEdge==NULL) return(NULL);
-	SETEXTRA(theEdge,1);
-	SETAUXEDGE(theEdge,1);
-	return(theEdge);
-}
-
-/****************************************************************************/
-/*D
-   DisposeAuxEdges - Remove edges with AUXEDGE flag set from theGrid
-
-   SYNOPSIS:
-   INT DisposeAuxEdges (GRID *theGrid);
-
-   PARAMETERS:
-.  theGrid - pointer to grid
-
-   DESCRIPTION:
-   This function removes all 'EDGE' objects with AUXEDGE flag set from the
-   given grid level. This function is provided for compatibility with
-   version 2.3.
-
-   RETURN VALUE:
-   INT
-.n    -1 in case of an error
-.n    else it returns the number of edges that have been disposed
-D*/
-/****************************************************************************/
-
-INT DisposeAuxEdges (GRID *theGrid)
-{
-	NODE *theNode;
-	LINK *theLink;
-	long cnt;
-	
-	cnt = 0;
-	
-	/* throw away the AUXEDGEs */
-	for (theNode=FIRSTNODE(theGrid); theNode!= NULL; theNode=SUCCN(theNode))
-		for (theLink=START(theNode); theLink!=NULL; theLink=NEXT(theLink))
-			if (AUXEDGE(MYEDGE(theLink)))
-				if (DisposeEdge(theGrid,MYEDGE(theLink)))
-					return (-1);
-				else
-					cnt++;
-	
-	if (cnt)
-		GSTATUS(theGrid) = 1;
-	
-	return (cnt);
-}
-
diff -ruN ug-orig/gm/ugm2d.h ug-patched/gm/ugm2d.h
--- ug-orig/gm/ugm2d.h	1995-11-15 19:47:39.000000000 +0100
+++ ug-patched/gm/ugm2d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,75 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugm2d.h														*/
-/*																			*/
-/* Purpose:   dimension dependent utilities 								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70569 Stuttgart												*/
-/*			  email: ica3.uni-stuttgart.de									*/
-/*																			*/
-/* History:   13.12.94 begin, ug version 3.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __UGM2D__
-#define __UGM2D__
-
-#ifndef __COMPILER__
-#include "compiler.h"
-#endif
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-/* miscellaneous */
-INT 		 CheckOrientation		(INT n, VERTEX **vertices);
-INT 		 QualityElement 		(int n, DOUBLE *xc, DOUBLE *yc, DOUBLE *lmin, DOUBLE *lmax);
-EDGE		*CreateAuxEdge			(GRID *theGrid, NODE *from, NODE *to);
-INT 		 DisposeAuxEdges		(GRID *theGrid);
-
-#endif
diff -ruN ug-orig/gm/ugm3d.c ug-patched/gm/ugm3d.c
--- ug-orig/gm/ugm3d.c	1995-11-15 19:47:40.000000000 +0100
+++ ug-patched/gm/ugm3d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,386 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugm2d.c														*/
-/*																			*/
-/* Purpose:   Functions only available in 3D								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70550 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de							*/
-/*																			*/
-/* History:   13.12.94 begin, ug version 3.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-
-#include "compiler.h"
-#include "heaps.h"
-#include "ugenv.h"
-
-#include "devices.h"
-
-#include "switch.h"
-#include "gm.h"
-#include "evm.h"
-#include "simplex.h"
-#include "ugm.h"
-#include "ugm3d.h"
-
-
-#ifdef __TWODIM__
-#error this source file is for 3D ONLY
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/ugm3d.c,v 1.2 1995/11/15 18:47:40 wieners Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*D
-   DisposeEdgesFromElement - Dispose all edges of element not needed otherwise
-
-   SYNOPSIS:
-   INT DisposeEdgesFromElement  (GRID *theGrid, ELEMENT *theElement);
-
-   PARAMETERS:
-.  theGrid - grid to remove from
-.  theElement - element whose edges are to be removed
-
-   DESCRIPTION:
-   This function disposes all edge of element not needed otherwise.
-   It runs through all edges of the element and decreases the 'NO_OF_ELEM' number.
-   If this number is zero then the edge is removed.
-
-   RETURN VALUE:
-   INT 
-.n    0 if ok
-.n    1 if edge with zeroin elements found (before decrement).
-D*/
-/****************************************************************************/
-
-INT DisposeEdgesFromElement  (GRID *theGrid, ELEMENT *theElement)
-{
-	INT i,j,ret;
-	EDGE *theEdge;
-
-	ret=0;
-	for (i=0; i<CORNERS_OF_ELEM(theElement); i++)
-		for (j=i+1; j<CORNERS_OF_ELEM(theElement); j++)
-		{
-			theEdge = GetEdge(CORNER(theElement,i),CORNER(theElement,j));
-			if (theEdge!=NULL)
-			{
-				if (NO_OF_ELEM(theEdge)<1)
-					ret=1;
-				if (NO_OF_ELEM(theEdge)==1)
-					DisposeEdge(theGrid,theEdge);
-				else
-					DEC_NO_OF_ELEM(theEdge);
-			}
-		}
-
-	return(ret);
-}
-
-/*******************************************************************/
-/*
-   MoveInnerNode - Assign new position to inner node
-
-   SYNOPSIS:
-   INT MoveInnerNode (MULTIGRID *theMG, NODE *theNode, COORD *newPos);
-
-   PARAMETERS:
-.  theMG - pointer to 'MULTIGRID' structure
-.  theNode - pointer to 'NODE' to be moved
-.  newPos - new position
-
-   DESCRIPTION:
-   This function 
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-*/
-/*******************************************************************/
-	
-INT MoveInnerNode (MULTIGRID *theMG, NODE *theNode, COORD *newPos)
-{
-	UserWrite("MoveInnerNode not implemented in 3D version jet\n");
-	return (0);
-}
-
-/*******************************************************************/
-/*
-   MoveBoundaryNode - Assign new position to boundary node
-
-   SYNOPSIS:
-   INT MoveBoundaryNode (MULTIGRID *theMG, NODE *theNode, INT segid, 
-   COORD *newPos);
-
-   PARAMETERS:
-.  theMG - pointer to 'MULTIGRID' structure
-.  theNode - pointer to 'NODE' to be moved
-.  segid - new segment id
-.  newPos - new parameter (lambda,mu)
-
-   DESCRIPTION:
-   This function not implemented in 3D!
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-*/
-/*******************************************************************/
-
-INT MoveBoundaryNode (MULTIGRID *theMG, NODE *theNode, INT segid, COORD *newPos)
-{
-	UserWrite("MoveBoundaryNode not implemented in 3D version jet\n");
-	return (0);
-}
-
-/*******************************************************************/
-/*
-   SmoothMultiGrid - 
-
-   SYNOPSIS:
-   INT  SmoothMultiGrid (MULTIGRID *theMG, INT niter, INT bdryFlag);
-
-   PARAMETERS:
-.  theMG -
-.  niter -
-.  bdryFlag -
-
-   DESCRIPTION:
-   This function 
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-*/
-/*******************************************************************/
-
-INT  SmoothMultiGrid (MULTIGRID *theMG, INT niter, INT bdryFlag)
-{
-	UserWrite("SmoothMultiGrid not implemented in 3D version jet\n");
-	return (0);
-}
-
-/****************************************************************************/
-/*
-   SetParityOfElement - Set parity of element	
-
-   SYNOPSIS:
-   INT SetParityOfElement (ELEMENT *theElement);
-
-   PARAMETERS:
-.  theElement -	pointer to 'ELEMENT'
-
-   DESCRIPTION:
-   This function sets parity of element.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.									
-*/
-/****************************************************************************/
-
-INT SetParityOfElement (ELEMENT *theElement)
-{
-	INT j;
-	ELEMENT *e;
-	ELEMENTSIDE *s;
-	NODE *n;
-	COORD sp,*x[4];
-	COORD_VECTOR a,b,c,d;
-	#ifdef __SIDEDATA__
-		VECTOR *v;
-	#endif
-	
-	if (TAG(theElement)!=TETRAHEDRON) return (1);
-	if (EFATHER(theElement)!=NULL) return (1);
-	if (NSONS(theElement)!=0) return (1);
-			
-	/* check orientation */
-	for (j=0; j<4; j++)	x[j] = CVECT(MYVERTEX(CORNER(theElement,j)));
-	V3_SUBTRACT(x[CornerOfSide[0][1]],x[CornerOfSide[0][0]],a)
-	V3_SUBTRACT(x[CornerOfSide[0][2]],x[CornerOfSide[0][0]],b)
-	V3_SUBTRACT(x[OppositeCorner[0]],x[CornerOfSide[0][0]],c)
-	V3_VECTOR_PRODUCT(a,b,d)
-	V3_SCALAR_PRODUCT(c,d,sp)
-	if (sp<0.0) return(0);
-			
-	/* invert orientaion */
-	n = CORNER(theElement,0);
-	SET_CORNER(theElement,0,CORNER(theElement,1));
-	SET_CORNER(theElement,1,CORNER(theElement,2));
-	SET_CORNER(theElement,2,CORNER(theElement,3));
-	SET_CORNER(theElement,3,n);
-			
-	e = NBELEM(theElement,0);
-	SET_NBELEM(theElement,0,NBELEM(theElement,1));
-	SET_NBELEM(theElement,1,NBELEM(theElement,2));
-	SET_NBELEM(theElement,2,NBELEM(theElement,3));
-	SET_NBELEM(theElement,3,e);
-			
-	#ifdef __SIDEDATA__
-	v = SVECTOR(theElement,0);
-	SET_SVECTOR(theElement,0,SVECTOR(theElement,1));			
-	SET_SVECTOR(theElement,1,SVECTOR(theElement,2));			
-	SET_SVECTOR(theElement,2,SVECTOR(theElement,3));			
-	SET_SVECTOR(theElement,3,v);			
-	#endif
-
-	if (OBJT(theElement)==IEOBJ) return(0);
-	s = SIDE(theElement,0);
-	SET_SIDE(theElement,0,SIDE(theElement,1));
-	SET_SIDE(theElement,1,SIDE(theElement,2));
-	SET_SIDE(theElement,2,SIDE(theElement,3));
-	SET_SIDE(theElement,3,s);
-	
-	return(0);
-}
-
-/****************************************************************************/
-/*
-   SetParityInGrid - Set parity of elements in grid
-
-   SYNOPSIS:
-   INT SetParityInGrid (GRID* theGrid);
-
-   PARAMETERS:
-.  theGrid - pointer to grid
-
-   DESCRIPTION:
-   This function sets parity of elements in grid.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-*/
-/****************************************************************************/
-
-INT SetParityInGrid (GRID* theGrid)
-{
-	ELEMENT *theElement;
-	
-	if (UPGRID(theGrid)!=NULL) return (1);
-	if (DOWNGRID(theGrid)!=NULL) return (1);
-	
-	for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement))
-		if (SetParityOfElement(theElement)) return (1);
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*
-   CheckParityOfElements - Check parity of elements in multigrid
-
-   SYNOPSIS:
-   INT CheckParityOfElements (MULTIGRID* theMG);
-
-   PARAMETERS:
-.  theMG - pointer to multigrid
-
-   DESCRIPTION:
-   This function checks parity of elements in multigrid.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured.
-*/
-/****************************************************************************/
-
-INT CheckParityOfElements (MULTIGRID* theMG)
-{
-	INT i,j;
-	ELEMENT *theElement;
-	COORD sp,*x[4];
-	COORD_VECTOR a,b,c,d;
-	char buffer[128];
-	
-	for (i=0; i<=TOPLEVEL(theMG); i++)
-		for (theElement=FIRSTELEMENT(GRID_ON_LEVEL(theMG,i)); theElement!=NULL; theElement=SUCCE(theElement))
-		{
-			if (TAG(theElement)!=TETRAHEDRON) return (1);
-			
-			/* check orientation */
-			for (j=0; j<4; j++)	x[j] = CVECT(MYVERTEX(CORNER(theElement,j)));
-			V3_SUBTRACT(x[CornerOfSide[0][1]],x[CornerOfSide[0][0]],a)
-			V3_SUBTRACT(x[CornerOfSide[0][2]],x[CornerOfSide[0][0]],b)
-			V3_SUBTRACT(x[OppositeCorner[0]],x[CornerOfSide[0][0]],c)
-			V3_VECTOR_PRODUCT(a,b,d)
-			V3_SCALAR_PRODUCT(c,d,sp)
-			if (sp<0.0) continue;
-			
-			sprintf(buffer,"parity wrong: IS = %d\n",(int)ID(theElement));
-			UserWrite(buffer);
-		}
-	
-	return(0);
-}
-
diff -ruN ug-orig/gm/ugm3d.h ug-patched/gm/ugm3d.h
--- ug-orig/gm/ugm3d.h	1995-11-15 19:47:40.000000000 +0100
+++ ug-patched/gm/ugm3d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,75 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugm3d.h														*/
-/*																			*/
-/* Purpose:   dimension dependent utilities 								*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70550 Stuttgart												*/
-/*			  email: ica3.uni-stuttgart.de									*/
-/*																			*/
-/* History:   13.12.94 begin, ug version 3.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __UGM3D__
-#define __UGM3D__
-
-#ifndef __COMPILER__
-#include "compiler.h"
-#endif
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-/* miscellaneous */
-INT DisposeEdgesFromElement  (GRID *theGrid, ELEMENT *theElement);
-INT 		CheckParityOfElements 			(MULTIGRID* theMG);
-INT			SetParityInGrid 				(GRID *theGrid);
-INT 		SetParityOfElement 				(ELEMENT *theElement);
-
-#endif
diff -ruN ug-orig/gm/ugm.c ug-patched/gm/ugm.c
--- ug-orig/gm/ugm.c	2008-10-30 13:29:06.000000000 +0100
+++ ug-patched/gm/ugm.c	2009-11-20 14:57:11.000000000 +0100
@@ -36,6 +36,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -105,7 +106,7 @@
 /* local refinement hack */
 #undef _SCHALE_X_ 
 
-/* macro for controlling debugging output by conditions on objects */
+/** \brief macro for controlling debugging output by conditions on objects */
 #define UGM_CDBG(x,y)   
 
 /****************************************************************************/
@@ -132,9 +133,11 @@
 /*                                                                          */
 /****************************************************************************/
 
-static char buffer[4*256];			/* general purpose text buffer			*/
+/** \brief General purpose text buffer */
+static char buffer[4*256];
 
-static VIRT_HEAP_MGMT *theGenMGUDM; /* general user data space management	*/
+/** \brief General user data space management	*/
+static VIRT_HEAP_MGMT *theGenMGUDM;
 
 static INT theMGDirID;				/* env var ID for the multigrids		*/
 static INT theMGRootDirID; 			/* env dir ID for the multigrids		*/
@@ -146,7 +149,7 @@
 static DOUBLE InvMeshSize;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/gm/ugm.c,v 1.380 2008/10/30 12:29:06 dmitriy Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
@@ -976,24 +979,6 @@
 	return(theNode);	
 }
 
-
-/****************************************************************************/
-/*
-   GetSideNode - 
-
-   SYNOPSIS:
-   NODE *GetSideNode (ELEMENT *theElement, INT side);
-
-   PARAMETERS:
- * @param   theElement
- * @param   side
-
-   DESCRIPTION:
-
-   @return
-*/
-/****************************************************************************/
-
 static NODE *GetSideNodeX (const ELEMENT *theElement, INT side, INT n, 
 						   NODE **MidNodes)
 {
@@ -1233,18 +1218,6 @@
 	return(theNode);
 }
 
-/****************************************************************************/
-/** \brief ???
-   PARAMETERS:
- * @param   theElement
- * @param   theNode
-
-   DESCRIPTION:
-
-   @return ???
-*/
-/****************************************************************************/
-
 static int CountSideNodes (ELEMENT *e)
 {
 	int i,side;
@@ -1935,7 +1908,7 @@
 </ul> */
 /****************************************************************************/
 
-EDGE * NS_DIM_PREFIX GetSonEdge (EDGE *theEdge)
+EDGE * NS_DIM_PREFIX GetSonEdge (const EDGE *theEdge)
 {
 	EDGE *SonEdge=NULL;
 	NODE *Node0,*Node1,*SonNode0,*SonNode1;
@@ -1954,8 +1927,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   GetSonEdges - Return pointer to son edges if it exists
+/** \brief Return pointer to son edges if it exists
 
  * @param   theEdge - edge for which son is searched
  * @param   SonEdges - array of pointers will be filled with son edges
@@ -1967,7 +1939,7 @@
 </ul> */
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX GetSonEdges (EDGE *theEdge, EDGE *SonEdges[MAX_SON_EDGES])
+INT  NS_DIM_PREFIX GetSonEdges (const EDGE *theEdge, EDGE *SonEdges[MAX_SON_EDGES])
 {
 	INT nedges;
 	NODE *Node0,*Node1,*SonNode0,*SonNode1,*MidNode;
@@ -2017,8 +1989,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   GetFatherEdge - Return pointer to father edge if it exists
+/** \brief Return pointer to father edge if it exists
 
  * @param   theEdge - edge for which father is searched
 
@@ -2030,7 +2001,7 @@
 </ul> */
 /****************************************************************************/
 
-EDGE * NS_DIM_PREFIX GetFatherEdge (EDGE *theEdge)
+EDGE * NS_DIM_PREFIX GetFatherEdge (const EDGE *theEdge)
 {
 	NODE *theNode0 = NBNODE(LINK0(theEdge));
 	NODE *theNode1 = NBNODE(LINK1(theEdge));
@@ -2076,17 +2047,14 @@
 			return(NULL);
 	}
 
-	/* one case not considered */
-	assert(0);
-	
-	return NULL;	/* in case NDEBUG defined */
+        /* No father available */
+	return NULL;
 }
 
 #ifdef __THREEDIM__
 
 /****************************************************************************/
-/** \brief
-   FatherEdge - Return pointer to father edge if it exists
+/** \brief Return pointer to father edge if it exists
 
  * @param   SideNodes - nodes of the side
  * @param   ncorners - number of sidenodes
@@ -2225,8 +2193,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   GetEdge - Return pointer to edge if it exists
+/** \brief Return pointer to edge if it exists
 
  * @param   from - starting node of edge
  * @param   to - end node of edge
@@ -2239,7 +2206,7 @@
 </ul> */
 /****************************************************************************/
 
-EDGE * NS_DIM_PREFIX GetEdge (NODE *from, NODE *to)
+EDGE * NS_DIM_PREFIX GetEdge (const NODE *from, const NODE *to)
 {
 	LINK *pl;
 
@@ -2253,8 +2220,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   CreateEdge - Return pointer to a new edge structure
+/** \brief Return pointer to a new edge structure
 
  * @param   theGrid - grid where vertex should be inserted 
  * @param   theElement - pointer to element
@@ -2317,6 +2283,10 @@
 	SETOBJT(link1,LIOBJ);
 	#endif
 	SETLOFFSET(link1,1);
+
+#ifdef FOR_DUNE
+        pe->id = (theGrid->mg->edgeIdCounter)++;
+#endif
 	
 	SETLEVEL(pe,GLEVEL(theGrid));
 	#if (defined ModelP) && (defined __THREEDIM__)
@@ -2530,8 +2500,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   GetLink - Return pointer to link if it exists
+/** \brief Return pointer to link if it exists
 
  * @param   from - starting node of link
  * @param   to - end node of link
@@ -2544,7 +2513,7 @@
 </ul> */
 /****************************************************************************/
 
-LINK *GetLink (NODE *from, NODE *to)
+LINK *GetLink (const NODE *from, const NODE *to)
 {
 	LINK *pl;
 	
@@ -2558,8 +2527,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   CreateElement - Return a pointer to  a new element structure
+/** \brief Return a pointer to  a new element structure
 
  * @param   theGrid - grid structure to extend
  * @param   tag - the element type 
@@ -2709,8 +2677,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   CreateSonElementSide - creates the element sides of son elements
+/** \brief Creates the element sides of son elements
 
  * @param   theGrid - grid for which to create
  * @param   theElement - pointer to a boundary element 
@@ -2824,8 +2791,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   CreateNewLevel - Return pointer to new grid structure
+/** \brief Return pointer to new grid structure
 
  * @param   theMG - multigrid structure
 
@@ -2903,8 +2869,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   CreateNewLevelAMG - Create new amg level
+/** \brief Create new amg level
 
  * @param   theMG - multigrid structure
 
@@ -2963,8 +2928,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MakeMGItem - Create a multigrid environment item 
+/** \brief Create a multigrid environment item 
 
  * @param   name - name of the multigrid
 
@@ -3063,8 +3027,7 @@
    
 
 /****************************************************************************/
-/** \brief
-   GetMultigrid - Find the multigrid environment item with name
+/** \brief Find the multigrid environment item with name
 
  * @param   name - name of the multigrid to find
 
@@ -3084,10 +3047,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   GetFirstMultigrid - Return a pointer to the first multigrid 
-
- * @param   void
+/** \brief Return a pointer to the first multigrid 
 
    This function returns a pointer to the first multigrid in the /Multigrids 
    directory.
@@ -3150,8 +3110,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   CreateMultiGrid - Return a pointer to new multigrid structure
+/** \brief Return a pointer to new multigrid structure
 
  * @param   MultigridName - name of multigrid
  * @param   domain - name of domain description from environment
@@ -3275,6 +3234,14 @@
 	theMG->vertIdCounter = 0;
 	theMG->nodeIdCounter = 0;
 	theMG->elemIdCounter = 0;
+#ifdef FOR_DUNE
+        theMG->edgeIdCounter = 0;
+        /** \brief Count vector objects in that multigrid
+            \todo This line is a hack.  It is used to implement face ids for Dune.
+            As soon as the face data structure is available the id should be stored
+            there.  Then this code can be removed again. */
+        theMG->vectorIdCounter = 0;
+#endif
 	theMG->topLevel = -1;
 	theMG->bottomLevel = 0;
 	MG_BVP(theMG) = theBVP;
@@ -3562,8 +3529,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeVertex - Remove vertex from the data structure
+/** \brief Remove vertex from the data structure
 
  * @param   theGrid - grid to remove from
  * @param   theVertex - vertex to remove
@@ -3601,8 +3567,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeElement - Remove element from the data structure
+/** \brief Remove element from the data structure
 
  * @param   theGrid - grid to remove from
  * @param   theElement - element to remove
@@ -3904,10 +3869,6 @@
 				}
 				else
 				{
-					#ifdef ModelP
-					/* TODO: sidevector case must be tested */
-					assert(0);
-					#endif
 					if (!FindNeighborElement (theElement,i,&theNeighbor,&j))
 						RETURN (1);
 					VOBJECT(theVector) = (GEOM_OBJECT *)theNeighbor;
@@ -3968,8 +3929,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   Collapse - construct coarse grid from surface
+/** \brief Construct coarse grid from surface
 
  * @param   theMG - multigrid to collapse
 
@@ -4130,8 +4090,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeTopLevel - Remove top level grid from multigrid  structure
+/** \brief Remove top level grid from multigrid  structure
 
  * @param   theMG - multigrid to remove from
 
@@ -4181,8 +4140,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeGrid - dispose top level grid 
+/** \brief Dispose top level grid 
 
  * @param   theGrid - grid to be removed
 
@@ -4242,8 +4200,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeAMGLevel - dispose bottom AMG level 
+/** \brief Dispose bottom AMG level 
 
  * @param   theMG - multigrid to remove from
 
@@ -4302,8 +4259,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DisposeAMGLevels - dispose all AMG level 
+/** \brief Dispose all AMG level 
 
  * @param   theMG - multigrid to remove from
 
@@ -4491,8 +4447,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   OrderNodesInGrid - reorder double linked 'NODE' list 
+/** \brief Reorder double linked 'NODE' list 
 
  * @param   theGrid - grid to order
  * @param   order - precedence of coordinate directions
@@ -4604,8 +4559,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   PutAtEndOfList - reorder a given set of elements and put them first in the list
+/** \brief Reorder a given set of elements and put them first in the list
 
  * @param   theGrid - elements are part of that level (not checked)
  * @param   cnt - number of elements in list
@@ -4668,8 +4622,7 @@
 }
 
 /****************************************************************************/
-/** \brief
- *     Determine neighbor and side of neighbor that goes back to element
+/** \brief Determine neighbor and side of neighbor that goes back to element
  *
  * @param   theElement - considered element
  * @param   Side - side of that element
@@ -4751,8 +4704,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   InsertBoundaryNode - Insert a boundary node 
+/** \brief Insert a boundary node 
 
  * @param   theGrid - grid structure
  * @param   bndp - boundary point descriptor
@@ -4817,8 +4769,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DeleteNode - Delete a node
+/** \brief Delete a node
 
  * @param   theGrid - grid structure
  * @param   theNode - node to delete
@@ -4867,8 +4818,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DeleteNodeWithID - Delete the node with id 
+/** \brief Delete the node with id 
 
  * @param   theGrid - grid structure
  * @param   id - id of node to delete
@@ -4897,8 +4847,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindFather - Find the new father element
+/** \brief Find the new father element
 
  * @param   theVertex -
 
@@ -4939,8 +4888,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   RecreateBNDSofNode - searche the boundary sides and recreate the corresponding BNDS
+/** \brief Search the boundary sides and recreate the corresponding BNDS
 
  * @param   theMG - multigrid structure
  * @param   theNode - node with new BNDP
@@ -5021,8 +4969,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MoveBndMidNode - set new position for a midnode on a boundary
+/** \brief Set new position for a midnode on a boundary
 
  * @param   theMG - pointer to multigrid
  * @param   theVertex - vertex to move
@@ -5130,8 +5077,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MoveMidNode - set new position for a midnode
+/** \brief Set new position for a midnode
 
  * @param   theMG - pointer to multigrid
  * @param   theNode - node to move
@@ -5220,8 +5166,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MoveCenterNode - set new position for a centernode
+/** \brief Set new position for a centernode
 
  * @param   theMG - pointer to multigrid
  * @param   theNode - node to move
@@ -5285,8 +5230,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MoveSideNode - set new position for a sidenode
+/** \brief Set new position for a sidenode
 
  * @param   theMG - pointer to multigrid
  * @param   theNode - node to move
@@ -5388,8 +5332,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   MoveNode - Let user enter a new position for an inner node
+/** \brief Let user enter a new position for an inner node
 
  * @param   theMG - pointer to multigrid
  * @param   theNode - node to move
@@ -5476,8 +5419,7 @@
 }
 
 /****************************************************************************/
-/** \brief
- *    Assign new local and global coords to a vertex
+/** \brief Assign new local and global coords to a vertex
 
  * @param   theMG - pointer to multigrid
  * @param   vert - vertex to move
@@ -5507,8 +5449,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MoveFreeBoundaryVertex - move a vertex on a free boundary
+/** \brief Move a vertex on a free boundary
 
  * @param   theMG - pointer to multigrid
  * @param   vert - vertex to move
@@ -5552,8 +5493,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FinishMovingFreeBoundaryVertices - finish moving of free boundary vertices
+/** \brief Finish moving of free boundary vertices
 
  * @param   theMG - pointer to multigrid
 
@@ -5604,8 +5544,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   GetMidNodeParam - Get local position of a midnode on an edge
+/** \brief Get local position of a midnode on an edge
 
  * @param   theNode - midnode 
  * @param   lambda  - local coordinate of midnode w.r.t. the edge
@@ -5693,191 +5632,25 @@
 
 #ifdef __TWODIM__
 
-#ifdef WITH_DEGENERATED_ELEM
-
-/****************************************************************************/
-/** \brief
-   ElemVertDegenerated - Check whether these vertices belong to a degenerated element.
-
- * @param   n - number of the vertices
- * @param   vertex - array of the vertices
- * @param   start_ind - to write the starting index of the proper vertex ordering
- 
-  This function checks whether the given vertices describe a degenerate
-  element. If all the vertices are located at different geometric positions
-  (i.e. this is no degenerate element), the function returns 0. If there are
-  vertices with equal geometric positions, the function checks whether this
-  is a proper degenerate element. If so, the function returns -1 and initializes
-  (* start_ind) with the index of the starting index of the proper ordering
-  of the vertices. In all the other cases, the function returns a positive value.
-  Note that this is the 2D version of the function.
-  
-  Unlike for the normal elements, we assume for the degenerate elements that
-  the nodes of degenerated elements are ordered in the input. This ordering
-  should correspond to the run over the sides of the element, i.e. for every
-  'i', '(vertex[i], vertex[(i+1)%n])' should be a side of the element. This
-  should be valid in the input. By setting '* start_ind', this function
-  induces the 'proper ordering' in which '(vertex[0], vertex[1])' is
-  a non-degenerated side.
-
-   @return <ul>
-   <li>   0 for normal (non-degenerated) elements </li>
-   <li>   -1 for the proper degenerated elements </li>	 
-   <li>   a positive value in all the other cases </li>	 
-   </ul>
-*/
-/****************************************************************************/
-
-INT NS_DIM_PREFIX ElemVertDegenerated (INT n, VERTEX * * vertex, INT * start_ind)
-{
-    INT i, j;
-    DOUBLE dist, min_dist, max_dist, dist_0;
-    
-    V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [0]), CVECT (vertex [1]), dist_0);
-    min_dist = max_dist = dist_0;
-    for (i = 0; i < n; i++)
-        for (j = i + 1; j < n; j++)
-            {
-                V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [i]), CVECT (vertex [j]), dist);
-                if (dist > max_dist) max_dist = dist;
-                else if (dist < min_dist) min_dist = dist;
-            };
-    
-    if (max_dist <= SMALL_C) return __LINE__; /* this is an illegal set of points */
-    if (min_dist > DEGENERATED_SIZE * max_dist) return 0; /* this is not a degenerated element */
-    
-    if (n == 3)
-    { /* This is a degenerated triangle. */
-        if (dist_0 > DEGENERATED_SIZE * max_dist)
-        {
-            V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [1]), CVECT (vertex [2]), dist);
-            *start_ind = (dist > DEGENERATED_SIZE * max_dist)? 0 : 2;
-        }
-        else *start_ind = 1;
-    }
-    else if (n == 4)
-    { /* This may be a degenerated quadrilateral. */
-        if (dist_0 > DEGENERATED_SIZE * max_dist)
-            *start_ind = i = 0;
-        else
-        {
-            *start_ind = i = 1;
-            V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [1]), CVECT (vertex [2]), dist);
-            if (dist <= DEGENERATED_SIZE * max_dist) return __LINE__; /* illegal set of points */
-        }
-        
-        V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [i+1]), CVECT (vertex [i+2]), dist);
-        if (dist > DEGENERATED_SIZE * max_dist) return __LINE__; /* illegal set of points */
-        
-        if (i == 0)
-        {
-            V_DIM_EUKLIDNORM_OF_DIFF (CVECT (vertex [3]), CVECT (vertex [0]), dist);
-            if (dist > DEGENERATED_SIZE * max_dist) return __LINE__; /* illegal set of points */
-        }
-    }
-    else return __LINE__; /* too many points */
-    
-    return -1;
-}
 
 /****************************************************************************/
-/** \brief
-   ElemIsDegenerated - Check whether this element is degenerated.
+/** \todo Please doc me!
 
- * @param   elem - the element
- * @param   start_ind - to write the starting index of the proper vertex ordering
- 
-  This function checks whether the given element is degenerated by
-  calling ElemVertDegenerated.
+   CheckOrientation - 
 
-   @return <ul>
-   <li>   0 for normal (non-degenerated) elements </li>
-   <li>   non-zero for the proper degenerated elements </li>	 
-   </ul>
-*/
-/****************************************************************************/
-INT NS_DIM_PREFIX ElemIsDegenerated (ELEMENT * elem, INT * start_ind)
-{
-    INT i, n_co;
-    VERTEX * vert [MAX_CORNERS_OF_ELEM];
-    
-    n_co = TAG (elem);
-    for (i = 0; i < n_co; i++)
-        vert [i] = MYVERTEX (CORNER (elem, i));
-    if (ElemVertDegenerated (n_co, vert, start_ind) == -1)
-        return 1;
-    return 0;
-}
+   SYNOPSIS:
+   INT CheckOrientation (INT n, VERTEX **vertices);
 
-/****************************************************************************/
-/** \brief
-   GetDegElemAssNodes - Check whether this element is degenerated.
+   
+ * @param   n
+ * @param   vertices
 
- * @param   elem - the element
- * @param   side_1 - one of the non-degenerated sides
- * @param   side_2 - the another non-degenerated side
- * @param   ass_nd - array of MAX_CORNERS_OF_ELEM entries for the corner associations
- 
-  This function checks whether the given element is degenerated. If so
-  it initializes 'side_1', 'side_2' and 'ass_nd'. Then 'ass_nd [i]' is
-  set to the index of the corner that has the same geometric position
-  as the corner #i.
+   DESCRIPTION:
 
-   @return <ul>
-   <li>   0 for normal (non-degenerated) elements </li>
-   <li>   non-zero for the proper degenerated elements </li>	 
-   </ul>
+   @return
+   INT
 */
 /****************************************************************************/
-INT NS_DIM_PREFIX GetDegElemAssNodes (ELEMENT * elem, INT * side_1, INT * side_2, INT * ass_nd)
-{
-	INT start_ind, n_co;
-	
-	if (! ElemIsDegenerated (elem, &start_ind))
-		return 0;
-	
-	switch (n_co = TAG (elem))
-	{
-	case 3: /* a "degenerated triangle" */
-		*side_1 = start_ind; *side_2 = (start_ind + 1) % 3;
-		ass_nd [start_ind] = (start_ind + 2) % 3;
-		ass_nd [(start_ind + 1) % 3] = (start_ind + 1) % 3; /* the same node */
-		ass_nd [(start_ind + 2) % 3] = start_ind;
-		break;
-	
-	case 4: /* a "degenerated quadrilateral" */
-		*side_1 = start_ind; *side_2 = (start_ind + 2) % 4;
-		ass_nd [start_ind] = (start_ind + 3) % 4;
-		ass_nd [(start_ind + 1) % 4] = (start_ind + 2) % 4;
-		ass_nd [(start_ind + 2) % 4] = (start_ind + 1) % 4;
-		ass_nd [(start_ind + 3) % 4] = start_ind;
-		break;
-	
-	default:
-		return 0;
-	}
-	
-	return 1;
-}
-
-#endif
-
-/****************************************************************************/
-/** \brief
-   CheckOrientation - Check whether the sequence of the vertices describes to a convex polygon
-
- * @param   n - number of the vertices
- * @param   vertices - array of the vertices
-
-   This function checks whether the vertices listed in the array describe
-   a convex polygon and their order corresponds to the clockwise
-   run over the sides of this polygon. This function works only in 2D. 
-
-   @return <ul>
-   <li>   0 if both these conditions are true </li>
-   <li>   non-zero either for the improper ordering of the vertices OR if the polygon is non-convex </li>	 
-</ul> */
-/****************************************************************************/
 
 INT  NS_DIM_PREFIX CheckOrientation (INT n, VERTEX **vertices)
 {
@@ -6265,7 +6038,7 @@
 			{
 				/*only in this case  problems like Attention !!! Node has more than ELEMS_OF_NODE_MAX !!iare possible*/
 				
-    			while(  (MGNDELEMBLKENTRY(theMG,cornerID[IndexOfDivPart],Index) != NULL) && (MGNDELEMPTRARRAY(theMG) != NULL) )
+                       while( (MGNDELEMPTRARRAY(theMG) != NULL) && (MGNDELEMBLKENTRY(theMG,cornerID[IndexOfDivPart],Index) != NULL) )
     			{
         			Index++;
 					helpIndex = Index - merkeIndex;
@@ -6483,8 +6256,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   InsertElement - Insert an element
+/** \brief Insert an element
 
  * @param   theGrid - grid structure
  * @param   n
@@ -6556,7 +6328,7 @@
 			tag = HEXAHEDRON;
 			break;
 		default:
-			PrintErrorMessage('E',"InsertElement","only tetrahedrons, pyramids and hexahedrons are allowed in the 3D coarse grid");
+			PrintErrorMessage('E',"InsertElement","only tetrahedra, prisms, pyramids, and hexahedra are allowed in the 3D coarse grid");
 			return(NULL);
 	}
     #endif
@@ -6570,25 +6342,6 @@
 	}
 
     #ifdef __TWODIM__
-    #ifdef WITH_DEGENERATED_ELEM
-    if ((i = ElemVertDegenerated (n, Vertex, &k)) != 0)
-    { /* This may be a degenerated element: */
-        if (i > 0)
-        {
-            PrintErrorMessageF ('E', "InsertElement",
-			 "Illegal degenerated element: ElemIsDegenerated returned %d", (int) i);
-            return NULL;
-        }
-        /* Shift the vertices and the nodes: */
-        while (k-- != 0)
-            for (i = 1; i < n; i++)
-            {
-                SWAP_IJ (Node, i - 1, i, theNode);
-                SWAP_IJ (Vertex, i - 1, i, theVertex);
-            }
-    }
-    else
-    #endif
 	/* find orientation */
 	if (!CheckOrientation(n,Vertex))
 	{
@@ -6695,6 +6448,7 @@
 	}
       /**********************************************************************/
 	  /* here begins the revised(03/97) part of InsertElement ...	        */
+	  /* documentation see ftp://ftp.ica3.uni-stuttgart.de/pub/text/dirk.   */
 	  /*                                                                    */
 	if (ElemList == NULL)
 	{
@@ -6835,8 +6589,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   InsertElementFromIDs - Insert element with node ids
+/** \brief Insert element with node ids
 
  * @param   theGrid - grid structure
  * @param   n - number of nodes in node id list
@@ -6904,8 +6657,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DeleteElement - Delete an element 
+/** \brief Delete an element 
 
  * @param   theMG - multigrid structure
  * @param   theElement - element to delete
@@ -7001,8 +6753,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   InsertMesh - Insert a mesh described by the domain
+/** \brief Insert a mesh described by the domain
 
  * @param   theMG - multigrid structure
  * @param   theMesh - mesh structure
@@ -7129,17 +6880,6 @@
                 for (l=0; l<SIDES_OF_REF(n); l++) ElemSideOnBnd[l] = (theMesh->ElemSideOnBnd[j][k]&(1<<l));
 				theElement = InsertElement (theGrid,n,Nodes,NULL,NULL,ElemSideOnBnd);
 			}
-			if (theElement==NULL)
-			{
-                PrintErrorMessageF ('E', "InsertMesh", "Could not insert an element with %d corners at", n);
-				for (l=0; l<n; l++)
-#ifdef __TWODIM__
-					PrintErrorMessageF ('E', "InsertMesh", "%d: (%lg, %lg)", l, XC(MYVERTEX(Nodes[l])), YC(MYVERTEX(Nodes[l])));
-#else
-					PrintErrorMessageF ('E', "InsertMesh", "%d: (%lg, %lg, %lg)", l, XC(MYVERTEX(Nodes[l])), YC(MYVERTEX(Nodes[l])), ZC(MYVERTEX(Nodes[l])));
-#endif
-                return(GM_ERROR);
-			};
 			SETSUBDOMAIN(theElement,j);
 		}
 
@@ -7147,8 +6887,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindNodeFromId - Find a node with given id
+/** \brief Find a node with given id
 
  * @param   theGrid - grid level to search.
 
@@ -7160,7 +6899,7 @@
 </ul> */
 /****************************************************************************/
 
-NODE * NS_DIM_PREFIX FindNodeFromId (GRID *theGrid, INT id)
+NODE * NS_DIM_PREFIX FindNodeFromId (const GRID *theGrid, INT id)
 {
 	NODE *theNode;
 	
@@ -7172,8 +6911,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   FindNodeFromPosition - Find node from position
+/** \brief Find node from position
 
  * @param   theGrid - grid level to search
  * @param   pos - given position
@@ -7187,7 +6925,7 @@
 </ul> */
 /****************************************************************************/
 
-NODE * NS_DIM_PREFIX FindNodeFromPosition (GRID *theGrid, DOUBLE *pos, DOUBLE *tol)
+NODE * NS_DIM_PREFIX FindNodeFromPosition (const GRID *theGrid, const DOUBLE *pos, const DOUBLE *tol)
 {
 	NODE *theNode;
 	int i,found;
@@ -7204,8 +6942,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindVectorFromPosition - Find vector from position
+/** \brief Find vector from position
 
  * @param   theGrid - grid level to search
  * @param   pos - given position
@@ -7238,8 +6975,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindVectorFromIndex - Find vector from Index
+/** \brief Find vector from Index
 
  * @param   theGrid - grid level to search
  * @param   index - given index
@@ -7264,8 +7000,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindElementFromId - Find element with id 
+/** \brief Find element with id 
 
  * @param   theGrid - grid level to search
  * @param   id - id to search 
@@ -7291,8 +7026,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   PointInElement - Determine whether point is contained in element
+/** \brief Determine whether point is contained in element
 
  * @param   x - coordinates of given point
  * @param   theElement - element to scan
@@ -7366,8 +7100,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   PointOnSide - Determine whether point is on an element side
+/** \brief Determine whether point is on an element side
 
  * @param   x - coordinates of given point
  * @param   theElement - element to scan
@@ -7434,8 +7167,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   DOUBLESide - Determine distance of a point to an element side
+/** \brief Determine distance of a point to an element side
 
  * @param   x - coordinates of given point
  * @param   theElement - element to scan
@@ -7498,8 +7230,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   FindFlippedElements - Determine whether elements are flipped
+/** \brief Determine whether elements are flipped
 
  * @param   theMG - multigrid
  * @param   verbose - verbose mode
@@ -7513,7 +7244,7 @@
 </ul> */
 /****************************************************************************/
 #ifdef __THREEDIM__
-INT NS_DIM_PREFIX FindFlippedElements(MULTIGRID *theMG, INT verbose)
+INT NS_DIM_PREFIX FindFlippedElements(const MULTIGRID *theMG, INT verbose)
 {
     ELEMENT *e;
 	INT l,n,i,j,fn,found,bfound,bfather;
@@ -7584,8 +7315,7 @@
 }
 #endif
 /****************************************************************************/
-/** \brief
-   FindElementFromPosition - Find element containing position 
+/** \brief Find element containing position 
 
  * @param   theGrid - grid level to search
  * @param   pos - given position
@@ -7659,8 +7389,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   FindElementOnSurfaceCached - Find element containing position  
+/** \brief Find element containing position  
 
  * @param   theMG - multigrid level to search
  * @param   global - given position
@@ -7736,8 +7465,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   NeighbourElement - get the neighbouring element
+/** \brief Get the neighbouring element
 
  * @param   theElement - pointer to an element
  * @param   side - number of an element side
@@ -7837,7 +7565,7 @@
 */
 /****************************************************************************/
 
-static void CalculateCenterOfMassOfSide(ELEMENT *theElement, int side, DOUBLE_VECTOR global, DOUBLE_VECTOR local)
+static void CalculateCenterOfMassOfSide(const ELEMENT *theElement, int side, DOUBLE_VECTOR global, DOUBLE_VECTOR local)
 {
 	DOUBLE *corner;
 	DOUBLE *l_corner;
@@ -7860,8 +7588,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   KeyForObject - calculate an (hopefully) unique key for the geometric object
+/** \brief Calculate an (hopefully) unique key for the geometric object
 
  * @param   obj - geometric object which from the key is needed (can be one of VERTEX, ELEMENT, NODE or VECTOR)
 
@@ -7948,9 +7675,16 @@
 	return (GM_ERROR);
 }
 
+void  NS_DIM_PREFIX ListMultiGridHeader (const INT longformat)
+{
+	if (longformat)
+		sprintf(buffer,"   %-20.20s %-20.20s %-20.20s %10.10s %10.10s\n","mg name","domain name","problem name","heap size","heap used");
+	else
+		sprintf(buffer,"   %-20.20s\n","mg name");
+}
+
 /****************************************************************************/
-/** \brief
-   ListMultiGrid - List general information about multigrid structure
+/** \brief List general information about multigrid structure
 
  * @param   theMG - structure to list
  * @param   isCurrent - is `theMG` current multigrid 
@@ -7961,19 +7695,11 @@
 */
 /****************************************************************************/
 
-void  NS_DIM_PREFIX ListMultiGridHeader (const INT longformat)
-{
-	if (longformat)
-		sprintf(buffer,"   %-20.20s %-20.20s %-20.20s %10.10s %10.10s\n","mg name","domain name","problem name","heap size","heap used");
-	else
-		sprintf(buffer,"   %-20.20s\n","mg name");
-}
-
-void  NS_DIM_PREFIX ListMultiGrid (MULTIGRID *theMG, const INT isCurrent, const INT longformat)
+void  NS_DIM_PREFIX ListMultiGrid (const MULTIGRID *theMG, const INT isCurrent, const INT longformat)
 {
 	char c;
 	BVP *theBVP;
-	BVP_DESC *theBVPDesc;
+	const BVP_DESC *theBVPDesc;
 	
 	/* get BVP description */
 	theBVP = MG_BVP(theMG);
@@ -7991,8 +7717,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MultiGridStatus - List information about refinement type distribution
+/** \brief List information about refinement type distribution
 
  * @param   theMG - structure to list
  * @param   gridflag -
@@ -8006,7 +7731,7 @@
 */
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX MultiGridStatus (MULTIGRID *theMG, INT gridflag, INT greenflag, INT lbflag, INT verbose)
+INT  NS_DIM_PREFIX MultiGridStatus (const MULTIGRID *theMG, INT gridflag, INT greenflag, INT lbflag, INT verbose)
 {
 	INT		i,j,sons,maxsons,heap,used,free_bytes;
 	INT		red, green, yellow; 
@@ -8464,8 +8189,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   ListGrids - list general information about grids of multigrid
+/** \brief List general information about grids of multigrid
 
  * @param   theMG - multigrid structure
 
@@ -8779,8 +8503,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   ListNode - List information about node in multigrid
+/** \brief List information about node in multigrid
 
  * @param   theMG - structure containing the node
  * @param   theNode - node to list
@@ -8794,7 +8517,7 @@
 */
 /****************************************************************************/
 
-void NS_DIM_PREFIX ListNode (MULTIGRID *theMG, NODE *theNode, INT dataopt, INT bopt, INT nbopt, INT vopt)
+void NS_DIM_PREFIX ListNode (const MULTIGRID *theMG, const NODE *theNode, INT dataopt, INT bopt, INT nbopt, INT vopt)
 {
 	VERTEX *theVertex;
 	LINK *theLink;
@@ -8904,8 +8627,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   ListNodeSelection - List information about all nodes in selection
+/** \brief List information about all nodes in selection
 
  * @param   theMG - structure containing the nodes
  * @param   dataopt - list user data if true
@@ -8964,8 +8686,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   ListNodeRange - List information about nodes in given range of ids 
+/** \brief List information about nodes in given range of ids 
 
  * @param   theMG - structure to list
  * @param   from - first id 
@@ -9027,7 +8748,7 @@
 */
 /****************************************************************************/
 
-void NS_DIM_PREFIX ListElement (MULTIGRID *theMG, ELEMENT *theElement, INT dataopt, INT bopt, INT nbopt, INT vopt)
+void NS_DIM_PREFIX ListElement (const MULTIGRID *theMG, const ELEMENT *theElement, INT dataopt, INT bopt, INT nbopt, INT vopt)
 {
 	char etype[10];
 	char ekind[8];
@@ -9077,26 +8798,14 @@
 			UserWriteF("    FA=NULL");
 
 		UserWriteF("  NSONS=%d\n",NSONS(theElement));
-                /** \todo delete this
-		#ifdef __TWODIM__
-		for (i=0; i<SONS_OF_ELEM(theElement); i++)
-			if (SON(theElement,i)!=NULL)
-			{
-				UserWriteF("    S%d=" EID_FMTX ,
-					i,EID_PRTX(SON(theElement,i)));
-			}
-		#endif
-		#ifdef __THREEDIM__
-*/
+
 		if (GetAllSons(theElement,SonList)!=0) return;
 		for (i=0; SonList[i] != NULL; i++)
 		{
 			UserWriteF("    S%d=" EID_FMTX ,i,EID_PRTX(SonList[i]));
 			if ((i+1)%4 == 0) UserWrite("\n");
 		}
-/*
-		#endif
-*/
+
 	}
 	if (nbopt)
 	{
@@ -9134,8 +8843,7 @@
 
 
 /****************************************************************************/
-/** \brief
-    ListElementSelection - list information about elements in selection
+/** \brief List information about elements in selection
 
     * @param  theMG multigrid structure to list
  * @param   dataopt - list user data if true
@@ -9146,7 +8854,7 @@
 */
 /****************************************************************************/
 
-void  NS_DIM_PREFIX ListElementSelection (MULTIGRID *theMG, INT dataopt, INT bopt, INT nbopt, INT vopt)
+void  NS_DIM_PREFIX ListElementSelection (const MULTIGRID *theMG, INT dataopt, INT bopt, INT nbopt, INT vopt)
 {
 	int j;
 	ELEMENT *theElement;
@@ -9166,8 +8874,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   IsElementSelected - Check whether element is in selection list
+/** \brief Check whether element is in selection list
 
  * @param   theMG - multigrid structure
  * @param   theElement - element to check
@@ -9180,7 +8887,7 @@
 </ul> */
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX IsElementSelected (MULTIGRID *theMG, ELEMENT *theElement)
+INT NS_DIM_PREFIX IsElementSelected (const MULTIGRID *theMG, const ELEMENT *theElement)
 {
 	int j;
 
@@ -9193,8 +8900,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   ListElementRange - List information about elements in range of ids
+/** \brief List information about elements in range of ids
 
  * @param   theMG - multigrid structure to list
  * @param   from - first id
@@ -9208,7 +8914,7 @@
 */
 /****************************************************************************/
 
-void  NS_DIM_PREFIX ListElementRange (MULTIGRID *theMG, INT from, INT to, INT idopt, INT dataopt, INT bopt, INT nbopt, INT vopt, INT lopt)
+void  NS_DIM_PREFIX ListElementRange (const MULTIGRID *theMG, INT from, INT to, INT idopt, INT dataopt, INT bopt, INT nbopt, INT vopt, INT lopt)
 {
 	int level,fromlevel,tolevel;
 	ELEMENT *theElement;
@@ -9249,8 +8955,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   ListVector - List information about vector
+/** \brief List information about vector
 
  * @param   theMG - multigrid structure to list
  * @param   theVector - vector to list
@@ -9263,7 +8968,7 @@
 */
 /****************************************************************************/
 
-void NS_DIM_PREFIX ListVector (MULTIGRID *theMG, VECTOR *theVector, INT matrixopt, INT dataopt, INT modifiers)
+void NS_DIM_PREFIX ListVector (const MULTIGRID *theMG, const VECTOR *theVector, INT matrixopt, INT dataopt, INT modifiers)
 {
 	FORMAT *theFormat;
 	NODE *theNode;
@@ -9395,8 +9100,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   ListVectorOfElementSelection - List info about vectors of elements in selection
+/** \brief List info about vectors of elements in selection
 
  * @param   theMG -  structure to list
  * @param   matrixopt - list line of matrix corresponding to theVector
@@ -9408,7 +9112,7 @@
 */
 /****************************************************************************/
 
-void NS_DIM_PREFIX  ListVectorOfElementSelection (MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers)
+void NS_DIM_PREFIX  ListVectorOfElementSelection (const MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers)
 {
 	int i,j;
 	ELEMENT *theElement;
@@ -9451,8 +9155,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   ListVectorSelection - list information about vectors in selection
+/** \brief List information about vectors in selection
 
  * @param   theMG: multigrid structure to list
  * @param   matrixopt - list matrices of this vector
@@ -9464,7 +9167,7 @@
 */
 /****************************************************************************/
 
-void  NS_DIM_PREFIX ListVectorSelection (MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers)
+void NS_DIM_PREFIX ListVectorSelection (const MULTIGRID *theMG, INT matrixopt, INT dataopt, INT modifiers)
 {
 	int j;
 	VECTOR *theVector;
@@ -9483,8 +9186,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   IsVectorSelected - Check whether vector is in selection list
+/** \brief Check whether vector is in selection list
 
  * @param   theMG - multigrid structure
  * @param   theVector - vector to check
@@ -9497,7 +9199,7 @@
 </ul> */
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX IsVectorSelected (MULTIGRID *theMG, VECTOR *theVector)
+INT NS_DIM_PREFIX IsVectorSelected (const MULTIGRID *theMG, const VECTOR *theVector)
 {
 	int j;
 
@@ -9509,8 +9211,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   ListVectorRange - list information about vectors in range of ids
+/** \brief List information about vectors in range of ids
 
  * @param   theMG - structure to list
  * @param   from - first index
@@ -9526,7 +9227,7 @@
 */
 /****************************************************************************/
 
-void NS_DIM_PREFIX ListVectorRange (MULTIGRID *theMG, INT fl, INT tl, INT from, INT to, INT idopt, INT matrixopt, INT dataopt, INT datatypes, INT modifiers)
+void NS_DIM_PREFIX ListVectorRange (const MULTIGRID *theMG, INT fl, INT tl, INT from, INT to, INT idopt, INT matrixopt, INT dataopt, INT datatypes, INT modifiers)
 {
 	int level;
 	VECTOR *theVector;
@@ -9558,26 +9259,8 @@
 			}
 }
 
-/*
-void ListConnections (GRID *theGrid)
-{
-	VECTOR *v;
-	MATRIX *m;
-	INT len; 
-    buffer[256];
-
-	for (v=PFIRSTVECTOR(theGrid); v!=NULL; v=SUCCVC(v)) {
-		len = sprintf(buffer,"%d: prio=%d  %8d ->",me,PRIO(v),GID(v));
-		for (m=START(v); m!=NULL; m=MNEXT(m))
-		    len += sprintf(buffer+len," %8d",GID(MDEST(m)));
-		printf("%s\n",buffer);
-	}
-}
-*/
-
 /****************************************************************************/
-/** \brief
-   ClearSelection - Clear selection buffer
+/** \brief Clear selection buffer
 
  * @param   theMG - multigrid structure
 
@@ -9946,8 +9629,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   MinMaxAngle - Determine min and max angle in degrees
+/** \brief Determine min and max angle in degrees
 
  * @param   theElement - element to check
  * @param   amin - minimum angle
@@ -9961,7 +9643,7 @@
 </ul> */
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX MinMaxAngle (ELEMENT *theElement, DOUBLE *amin, DOUBLE *amax)
+INT NS_DIM_PREFIX MinMaxAngle (const ELEMENT *theElement, DOUBLE *amin, DOUBLE *amax)
 {
 	INT error,i,s1,s2,tag;
 	DOUBLE angle,*x[MAX_CORNERS_OF_SIDE],n1[DIM],n2[DIM];
@@ -10035,8 +9717,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   DefineMGUDBlock - Define block in general MG user data space
+/** \brief Define block in general MG user data space
 
  * @param   id - the id of the block to be allocated
  * @param   size - size of the data block
@@ -10059,8 +9740,7 @@
 
 
 /****************************************************************************/
-/** \brief
-   FreeMGUDBlock - Free block in general MG user data space
+/** \brief Free block in general MG user data space
 
  * @param   id: the id of the block to be allocated 
 
@@ -10081,8 +9761,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   GetMGUDBlockDescriptor - Return pointer to block descriptor with id
+/** \brief Return pointer to block descriptor with id
 
  * @param   id - the id of the block to be allocated
 
@@ -10094,7 +9773,7 @@
 </ul> */
 /****************************************************************************/
 
-BLOCK_DESC	* NS_DIM_PREFIX GetMGUDBlockDescriptor (BLOCK_ID id)
+BLOCK_DESC* NS_DIM_PREFIX GetMGUDBlockDescriptor (BLOCK_ID id)
 {
 	return (GetBlockDesc(theGenMGUDM,id));
 }
@@ -10105,8 +9784,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MaxNodeClass - Returns highest Node class of a dof on next level
+/** \brief Returns highest Node class of a dof on next level
 
  * @param   theElement - pointer to a element
 
@@ -10119,7 +9797,7 @@
 </ul> */										
 /****************************************************************************/
 
-static INT MaxNodeClass (ELEMENT *theElement)
+static INT MaxNodeClass (const ELEMENT *theElement)
 {
     INT m = 0;
 	INT i;
@@ -10134,8 +9812,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MaxNextNodeClass - Returns highest Node class of a dof on next level
+/** \brief Returns highest Node class of a dof on next level
 
  * @param   theElement - pointer to a element
 
@@ -10148,7 +9825,7 @@
 </ul> */										
 /****************************************************************************/
 
-INT NS_DIM_PREFIX MaxNextNodeClass (ELEMENT *theElement)
+INT NS_DIM_PREFIX MaxNextNodeClass (const ELEMENT *theElement)
 {
     INT m = 0;
 	INT i;
@@ -10191,8 +9868,7 @@
 #endif
 
 /****************************************************************************/
-/** \brief
-   MinNodeClass - Returns minimal Node class of a dof on next level
+/** \brief Returns minimal Node class of a dof on next level
 
  * @param   theElement - pointer to a element
 
@@ -10205,7 +9881,7 @@
 </ul> */										
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX MinNodeClass (ELEMENT *theElement)
+INT NS_DIM_PREFIX MinNodeClass (const ELEMENT *theElement)
 {
     INT m = 3;
 	INT i;
@@ -10220,8 +9896,7 @@
 }
 
 /****************************************************************************/
-/** \brief
-   MinNextNodeClass - Returns minimal Node class of a dof on next level
+/** \brief Returns minimal Node class of a dof on next level
 
  * @param   theElement - pointer to a element
 
@@ -10234,7 +9909,7 @@
 </ul> */										
 /****************************************************************************/
 
-INT  NS_DIM_PREFIX MinNextNodeClass (ELEMENT *theElement)
+INT  NS_DIM_PREFIX MinNextNodeClass (const ELEMENT *theElement)
 {
     INT m = 3;
 	INT i;
@@ -10249,8 +9924,7 @@
 }
 
 /****************************************************************************/
-/** \brief										
-   SeedNodeClasses - Initialize node classes
+/** \brief Initialize node classes
 
  * @param   theGrid - given grid
  * @param   theElement - given element
@@ -10274,8 +9948,7 @@
 }
 
 /****************************************************************************/
-/** \brief										
-   ClearNodeClasses - Reset node classes
+/** \brief Reset node classes
 
  * @param   theGrid - pointer to grid 
 
@@ -10297,20 +9970,6 @@
 
 	return(0);
 }
-/****************************************************************************/
-/** \brief										
-   PropagateNodeClasses - Compute Node classes after initialization
-
- * @param   theGrid - pointer to grid 
-
-   After Node classes have been reset and initialized, this function
-   now computes the class 2 and class 1 Nodes.
-
-   @return <ul>
-   <li>      0 if ok </li>
-   <li>      1 if error occured </li>				
-</ul> */										
-/****************************************************************************/
 
 #ifdef ModelP
 static int Gather_NodeClass (DDD_OBJ obj, void *data)
@@ -10341,6 +10000,19 @@
 }
 #endif
 
+/****************************************************************************/
+/** \brief Compute Node classes after initialization
+
+ * @param   theGrid - pointer to grid 
+
+   After Node classes have been reset and initialized, this function
+   now computes the class 2 and class 1 Nodes.
+
+   @return <ul>
+   <li>      0 if ok </li>
+   <li>      1 if error occured </li>				
+</ul> */										
+/****************************************************************************/
 static INT PropagateNodeClass (GRID *theGrid, INT nclass)
 {
     ELEMENT *theElement;
@@ -10554,13 +10226,12 @@
 		SETNNCLASS(theNode,0);
 	
 	/* now the refinement algorithm will initialize the class 3 Nodes   */
-	/* on the *NEXT* level.      										*/
+	/* on the *NEXT* level. */
 	return(0);
 }
 
 /****************************************************************************/
-/** \brief										
-   SeedNextNodeClasses - Set 'NNCLASS' in all Nodes associated with element
+/** \brief Set 'NNCLASS' in all Nodes associated with element
 
  * @param   theElement - pointer to element
 
@@ -10818,7 +10489,7 @@
 </ul> */
 /****************************************************************************/
 
-INT NS_DIM_PREFIX SetEdgeAndNodeSubdomainFromElements (GRID *theGrid)
+static INT SetEdgeAndNodeSubdomainFromElements (GRID *theGrid)
 {
 	ELEMENT *theElement;
 	NODE *n0,*n1;
@@ -11312,24 +10983,11 @@
 					break;
 			assert(i<SIDES_OF_ELEM(theElement));
 			
-#ifdef WITH_DEGENERATED_ELEM
-			if (SUBDOMAIN (theElement) != 0)
-				id = SUBDOMAIN (theElement);
-			else
-			{
-				/* set id from BNDS */
-				if (BNDS_BndSDesc(ELEM_BNDS(theElement,i),&id,&nbid,&part)) 
-					REP_ERR_RETURN (GM_ERROR);
-				assert(id>0);
-				SETSUBDOMAIN(theElement,id);
-			}
-#else
 			/* set id from BNDS */
 			if (BNDS_BndSDesc(ELEM_BNDS(theElement,i),&id,&nbid,&part)) 
 			    REP_ERR_RETURN (GM_ERROR);
 			assert(id>0);
 			SETSUBDOMAIN(theElement,id);
-#endif
 			SETUSED(theElement,1);			
 			fifo_in(&myfifo,(void *)theElement);
 			PRINTDEBUG(gm,1,("elem %3d sid %d\n",ID(theElement),SUBDOMAIN(theElement)));
@@ -11359,37 +11017,7 @@
 			if (USED(theNeighbor))
 			{
 				if (INNER_SIDE(theElement,i))
-				{
-					if (SUBDOMAIN(theElement)!=SUBDOMAIN(theNeighbor))
-					{
-						UserWriteF
-						 ("Error: Element %d (subdom. %d) shares an inner side %d "
-						  "with element %d from a different subdom %d.\n",
-						  ID (theElement), SUBDOMAIN(theElement), i,
-						  ID (theNeighbor), SUBDOMAIN(theNeighbor));
-						UserWriteF ("Element %d has vertices at", ID (theElement));
-						for (i = 0; i < TAG (theElement); i++)
-						{
-							UserWrite (" (");
-							for (j = 0; j < DIM; j++)
-								UserWriteF (" %lg", CVECT (MYVERTEX (CORNER (theElement, i))) [j]);
-							UserWrite (")");
-						}
-						UserWriteF ("\nElement %d has vertices at", ID (theNeighbor));
-						for (i = 0; i < TAG (theNeighbor); i++)
-						{
-							UserWrite (" (");
-							for (j = 0; j < DIM; j++)
-								UserWriteF (" %lg", CVECT (MYVERTEX (CORNER (theNeighbor, i))) [j]);
-							UserWrite (")");
-						}
-						UserWrite ("\n");
-						return GM_ERROR;
-					}
-					/* The old 'error message':
 					assert(SUBDOMAIN(theElement)==SUBDOMAIN(theNeighbor));
-					 */
-				}
 				continue;
 			}
 			SETSUBDOMAIN(theNeighbor,SUBDOMAIN(theElement));
@@ -12217,7 +11845,7 @@
 	{
 		ASSERT(NVECTOR(coordlist[i].node)!=NULL);
 		ASSERT(coordlist[i].vp[j]!=NULL);
-		PRINTDEBUG(gm,1,(" GID=%016llx",
+		PRINTDEBUG(gm,1,(" GID=%08x",
 			GID(coordlist[i].vp[j])))
 
 		DDD_IdentifyNumber(PARHDR(NVECTOR(coordlist[i].node)),p,
@@ -12259,7 +11887,7 @@
 		{
 			ASSERT(NVECTOR(coordlist[i].node)!=NULL);
 			ASSERT(coordlist[i].vp[j]!=NULL);
-			PRINTDEBUG(gm,1,(" GID=%016llx",
+			PRINTDEBUG(gm,1,(" GID=%08x",
 				GID(coordlist[i].vp[j])))
 
 if (0)
@@ -12813,7 +12441,7 @@
 	  MATRIX *mat;
 	  
 	  /* print all information available */
-	  PRINTDEBUG(gm,0,("#%8d: per_node GID= %016llx VGID= %016llx PRIO=%d coord: ( %f %f %f )\n",nn,GID(node),GID(NVECTOR(node)), PRIO(NVECTOR(node)), own_coord[0],own_coord[1],own_coord[2]));
+	  PRINTDEBUG(gm,0,("#%8d: per_node GID= %08x VGID= %08x PRIO=%d coord: ( %f %f %f )\n",nn,GID(node),GID(NVECTOR(node)), PRIO(NVECTOR(node)), own_coord[0],own_coord[1],own_coord[2]));
 	  nn++;
 
 	  if (((NODE *)VOBJECT(NVECTOR(node)))==NULL) {
@@ -12832,7 +12460,7 @@
 		  PRINTDEBUG(gm,0,("no destination vector -> continue\n"));
 		  continue;
 		}
-		PRINTDEBUG(gm,0,("\tGID=%016llx PRIO=%d\n",GID(MDEST(mat)),PRIO(MDEST(mat))));
+		PRINTDEBUG(gm,0,("\tGID=%08x PRIO=%d\n",GID(MDEST(mat)),PRIO(MDEST(mat))));
 	  }
 	}
   }
@@ -12853,7 +12481,7 @@
 	return(GM_OK);
 }
 
-static INT ListPeriodicNodeAndVec (GRID *g, DDD_GID vgid)
+static INT ListPeriodicNodeAndVec (GRID *g, INT vgid)
 {
 	VECTOR *v;
 	NODE *n,*nref;
@@ -12915,14 +12543,14 @@
 	DOUBLE tol[3] = {SMALL_DOUBLE,SMALL_DOUBLE,SMALL_DOUBLE};
 	NODE *n = FindNodeFromPosition(g,pos,tol);
 	INT i,found;
-	DDD_GID vgid;
+	INT vgid;
 
 	if (n != NULL)
 		vgid = GID(NVECTOR(n));
 	else
 		vgid = -1;
-	ASSERT(vgid==UG_GlobalMaxGID(vgid) || vgid==-1);
-	vgid = UG_GlobalMaxGID(vgid);
+	ASSERT(vgid==UG_GlobalMaxINT(vgid) || vgid==-1);
+	vgid = UG_GlobalMaxINT(vgid);
 	
 	if (vgid == -1)
 	{
diff -ruN ug-orig/gm/ugm.h ug-patched/gm/ugm.h
--- ug-orig/gm/ugm.h	2008-10-30 13:29:06.000000000 +0100
+++ ug-patched/gm/ugm.h	2012-01-26 12:06:32.000000000 +0100
@@ -26,7 +26,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/gm/ugm.h,v 1.74 2008/10/30 12:29:06 dmitriy Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -101,7 +101,7 @@
 /* create basic objects */
 /** \todo Commented out because no definitions exist for these declarations
 
-#if defined(EDGE_WITH_DDDHDR) && defined(__TWODIM__)
+#if defined(__TWODIM__)
 int      GetElemLink (NODE *from, NODE *to, ELEMENT *theElement);
 ELEMENT *NbElem     (const ELEMENT *theElement, int i);
 void     Set_NbElem (ELEMENT *theElement, int i, ELEMENT *Neighbor);
@@ -130,7 +130,7 @@
 INT              PointInElement                 (const DOUBLE*, const ELEMENT *theElement);
 INT          PointOnSide            (const DOUBLE *global, const ELEMENT *theElement, INT side);
 DOUBLE       DistanceFromSide       (const DOUBLE *global, const ELEMENT *theElement, INT side);
-INT FindFlippedElements				(MULTIGRID *theMG, INT verbose);
+INT FindFlippedElements				(const MULTIGRID *theMG, INT verbose);
 NS_PREFIX VIRT_HEAP_MGMT *GetGenMGUDM             (void);
 INT             CheckOrientation                (INT n, VERTEX **vertices);
 INT             CheckOrientationInGrid  (GRID *theGrid);
@@ -166,9 +166,9 @@
 INT             ClearNextNodeClasses            (GRID *theGrid);
 INT             SeedNextNodeClasses             (ELEMENT *theElement);
 INT             PropagateNextNodeClasses        (GRID *theGrid);
-INT             MaxNextNodeClass                        (ELEMENT *theElement);
-INT             MinNodeClass                            (ELEMENT *theElement);
-INT             MinNextNodeClass                        (ELEMENT *theElement);
+INT             MaxNextNodeClass                        (const ELEMENT *theElement);
+INT             MinNodeClass                            (const ELEMENT *theElement);
+INT             MinNextNodeClass                        (const ELEMENT *theElement);
 #endif
 
 #ifdef __PERIODIC_BOUNDARY__
@@ -180,11 +180,6 @@
 INT                     Grid_CheckPeriodicity           (GRID *g);
 #endif
 
-#ifdef WITH_DEGENERATED_ELEM
-INT ElemIsDegenerated (ELEMENT * elem, INT * start_ind);
-INT GetDegElemAssNodes (ELEMENT * elem, INT * side_1, INT * side_2, INT * ass_nd);
-#endif
-
 END_UGDIM_NAMESPACE
 
 #endif
diff -ruN ug-orig/gm/ugrefine2d.c ug-patched/gm/ugrefine2d.c
--- ug-orig/gm/ugrefine2d.c	2005-08-11 14:14:59.000000000 +0200
+++ ug-patched/gm/ugrefine2d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,2666 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugrefine2d.c													*/
-/*																			*/
-/* Purpose:   unstructured grid refinement (tree version)					*/
-/*																			*/
-/* Author:	  Peter Bastian, Nicolas Neuss									*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  email: ug@ica3.uni-stuttgart.de           					*/
-/*																			*/
-/* History:   09.03.92 begin, ug version 2.0								*/
-/*			  17.11.92 new rules, more efficient							*/
-/*			  01.12.92 tree structure locally abandoned (N. Neuss)			*/
-/*			  01.01.93 new and more flexible rules, better					*/
-/*					   concept for irregular elements (N.Neuss) 			*/
-/*			  09.02.93 grid rebuilding included (N.Neuss)					*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef __MPW32__
-#pragma segment ugrefine
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <stdlib.h>
-#include <assert.h>
-
-#include "compiler.h"
-
-#include "devices.h"
-
-#include "switch.h"
-#include "cw.h"
-#include "gm.h"
-#include "misc.h"
-#include "evm.h"
-#include "shapes2d.h"
-#include "ugm.h"
-#include "ugrefine.h"
-#include "ugrefine2d.h"
-#include "algebra.h"
-
-
-#ifdef __THREEDIM__
-#error this source file is for 2D ONLY
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define MAXBASICRULES	14			/* number of basic refinement rules 	*/
-
-#define MAXRULES		100 		/* maximum number of refinement rules	*/
-
-#define MINANGLE		10.0		/* min angle for switching from T4 to T3*/
-#define MAXANGLE		170.0		/* max angle for switching from T4 to T3*/
-
-#define BMNRESOLUTION	10			/* resolution for creating boundary midn*/
-
-#define MINVNCLASS		2			/* determines copies, dep. on discr. !	*/
-
-/* numbers of basic rules */
-#define NO_REF			0
-#define T_COPY			1
-#define T_RED			2
-#define T_BISECT_1		3
-#define T_BISECT_2_T1	4
-#define T_BISECT_2_T2	5
-#define T_BISECT_2_Q	6
-#define T_BISECT_3		7
-
-#define Q_COPY			8
-#define Q_RED			9
-#define Q_CLOSE_1		10
-#define Q_BLUE			11
-#define Q_CLOSE_2		12
-#define Q_CLOSE_3		13
-
-/* swap rules */
-#define Q0 0
-#define Q1 1
-#define Q2 2
-#define TT0 3
-#define TT1 4
-#define TT2 5
-#define QT0 6
-#define QT1 7
-#define QT2 8
-#define QT3 9
-#define QT4 10
-#define QT5 11
-#define QT6 12
-#define QQ0 13
-#define QQ1 14
-#define QQ2 15
-#define QQ3 16
-#define QQ4 17
-#define QQ5 18
-#define QQ6 19
-#define QQ7 20
-#define QQ8 21
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-typedef struct {
-	int tag;
-	int corners[4];
-	int outer[4];
-	int nb[4];
-} SON_DATA ;
-
-typedef struct {
-	int tag;
-	int rule;
-	int class;
-	int variant;
-	int nsons;
-	int pattern[4];
-	int condensedPattern;
-	SON_DATA sons[4];
-	int midSon[5],midCorner[5],nbSon[8],nbSide[8];
-	int followRule[16];
-} REFRULE;
-
-typedef struct {
-	int rule;
-	int nsons;
-	int class;
-	SON_DATA sons[4];
-} CHANGE_RULE;
-
-typedef struct {
-	INT tag;						/* for which element type				*/
-	INT offset; 					/* offset of rule... is computed		*/
-	INT classOffset[3]; 			/* offset of class... is computed		*/
-	INT variantOffset[4];			/* offset of variant... is computed 	*/
-	INT classes[3]; 				/* 1 if class available 				*/
-	INT variants[4];				/* 1 if variant available				*/
-	INT pattern[4]; 				/* 1 if side is refined 				*/
-	INT nsons;						/* number of sons						*/
-	SON_DATA sons[4];
-	INT followRule[16]; 	/* is equal to T/QStandardFollowRule if ==-1	*/
-	INT followVariant[16];	/* is equal to T/QStandardFollowVariant if ==-1 */
-} basicRule;
-
-typedef struct {
-	NODE *Nodes[4]; 				/* corner nodes of an element to be ref.*/
-	NODE *MidNodes[4];				/* nodes on refined edges				*/
-	NODE *Interior; 				/* the interior node					*/
-	ELEMENT *Neighbors[8];			/* neighbors on next higher level		*/
-	ELEMENT **BackPtrs[8];			/* locations where neighbs store my adr */
-} ElementContext ;
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-static INT rFlag=GM_REFINE_TRULY_LOCAL; /* type of refine					*/
-static INT MaxRules=0;	/* actual number of rules generated from BasicRules */
-static REFRULE Rules[MAXRULES]; 		/* the generated rules				*/
-
-static basicRule BasicRules[MAXBASICRULES] = {
-	{3,0,{0,0,0},{0,0,0,0},{1,0,0},{1,0,0,0},{0,0,0,0},0,{					/* NO_REF=0  */
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{1,1,1},{1,0,0,0},{0,0,0,0},1,{					/* T_COPY=1  */
-		{3,{0,1,2,0},{1,1,1,0},{0,2,4,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,0,1},{1,0,0,0},{1,1,1,0},4,{					/* T_RED=2	*/
-		{3,{0,4,6,0},{1,0,1,0},{0,3,5,0}},
-		{3,{4,1,5,0},{1,1,0,0},{1,2,3,0}},
-		{3,{6,5,2,0},{0,1,1,0},{3,3,4,0}},
-		{3,{5,6,4,0},{0,0,0,0},{2,0,1,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,0},{1,0,0,0},2,{					/* T_BISECT_1=3  */
-		{3,{4,2,0,0},{0,1,1,0},{1,4,0,0}},
-		{3,{4,1,2,0},{1,1,0,0},{1,2,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,T_BISECT_2_T1,-1,T_BISECT_2_T2,-1,T_BISECT_3,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,			  0,-1, 		   2,-1,		 0,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,0},{1,1,0,0},3,{					/* T_BISECT_2_T1=4	*/
-		{3,{4,2,0,0},{0,1,1,0},{1,4,0,0}},
-		{3,{4,5,2,0},{0,1,0,0},{2,3,0,0}},
-		{3,{4,1,5,0},{1,1,0,0},{1,2,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,0},{1,1,0,0},3,{					/* T_BISECT_2_T2=5	*/
-		{3,{5,4,1,0},{0,1,1,0},{1,1,2,0}},
-		{3,{4,5,0,0},{0,0,1,0},{0,2,0,0}},
-		{3,{0,5,2,0},{0,1,1,0},{1,3,4,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,0},{1,1,0,0},2,{					/* T_BISECT_2_Q=6  */
-		{3,{5,4,1,0},{0,1,1,0},{1,1,2,0}},
-		{4,{4,5,2,0},{0,1,1,1},{0,3,4,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{3,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,0},{1,1,1,0},4,{					/* T_BISECT_3=7  */
-		{3,{4,1,5,0},{1,1,0,0},{1,2,1,0}},
-		{3,{4,5,2,0},{0,1,0,0},{0,3,2,0}},
-		{3,{4,2,6,0},{0,1,0,0},{1,4,3,0}},
-		{3,{4,6,0,0},{0,1,1,0},{2,5,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{1,1,1},{1,0,0,0},{0,0,0,0},1,{					/* Q_COPY=8  */
-		{4,{0,1,2,3},{1,1,1,1},{0,2,4,6}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{0,0,1},{1,0,0,0},{1,1,1,1},4,{					/* Q_RED=9 */
-		{4,{0,4,8,7},{1,0,0,1},{0,1,3,7}},
-		{4,{4,1,5,8},{1,1,0,0},{1,2,2,0}},
-		{4,{8,5,2,6},{0,1,1,0},{1,3,4,3}},
-		{4,{7,8,6,3},{0,0,1,1},{0,2,5,6}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,1},{1,0,0,0},3,{					/* Q_CLOSE_1=10 */
-		{3,{4,3,0,0},{0,1,1,0},{1,6,0,0}},
-		{3,{4,2,3,0},{0,1,0,0},{2,4,0,0}},
-		{3,{4,1,2,0},{1,1,0,0},{1,2,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,0,0},{1,0,1,0},2,{					/* Q_BLUE=11 */
-		{4,{0,4,6,3},{1,0,1,1},{0,1,5,6}},
-		{4,{4,1,2,6},{1,1,1,0},{1,2,4,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,1},{1,1,0,0},3,{					/* Q_CLOSE_2=12 */
-		{4,{4,8,3,0},{0,0,1,1},{1,2,6,0}},
-		{4,{4,1,5,8},{1,1,0,0},{1,2,2,0}},
-		{4,{5,2,3,8},{1,1,0,0},{3,4,0,1}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	},
-	{4,0,{0,0,0},{0,0,0,0},{0,1,1},{1,1,1,1},{1,1,1,0},4,{					/* Q_CLOSE_3=13 */
-		{3,{5,4,1,0},{0,1,1,0},{3,1,2,0}},
-		{3,{5,2,6,0},{1,1,0,0},{3,4,3,0}},
-		{4,{4,6,3,0},{0,1,1,1},{3,5,6,0}},
-		{3,{5,6,4,0},{0,0,0,0},{1,2,0,0}}},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-		{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-	}
-} ;
-
-/*static INT StandardFollowRule_T[8]	=	{T_COPY,T_BISECT_1,T_BISECT_1,T_BISECT_2_Q,T_BISECT_1,T_BISECT_2_Q,T_BISECT_2_Q,T_RED};*/
-static INT StandardFollowRule_T[8]	=	{T_COPY,T_BISECT_1,T_BISECT_1,T_BISECT_2_T1,T_BISECT_1,T_BISECT_2_T1,T_BISECT_2_T1,T_RED};
-static INT StandardFollowVariant_T[8]=	{	  0,		 0, 		1,			  0,		 2, 		   2,			 1,    0};
-static INT StandardFollowRule_Q[16] =	{Q_COPY,Q_CLOSE_1,Q_CLOSE_1,Q_CLOSE_2,Q_CLOSE_1,Q_BLUE,Q_CLOSE_2,Q_CLOSE_3,Q_CLOSE_1,Q_CLOSE_2,Q_BLUE,Q_CLOSE_3,Q_CLOSE_2,Q_CLOSE_3,Q_CLOSE_3,Q_RED};
-static INT StandardFollowVariant_Q[16]= {	  0,		0,		  1,		0,		  2,	 0, 	   1,		 0, 	   3,		 3, 	1,		  3,		2,		  2,		1,	  0};
-
-static CHANGE_RULE CRules[]=
-{
-	{Q0,1,REGULAR_CLASS,
-		{
-			{4,{0,1,2,3},{1,1,1,1},{0,1,2,3}},
-			{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-			{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-			{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{Q1,2,REGULAR_CLASS,
-		{
-		{3,{0,1,2,0},{1,1,0,0},{0,1,1,0}},
-		{3,{0,2,3,0},{0,1,1,0},{0,2,3,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{Q2,2,REGULAR_CLASS,
-		{
-		{3,{0,1,3,0},{1,0,1,0},{0,1,3,0}},
-		{3,{1,2,3,0},{1,1,0,0},{1,2,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{TT0,2,REGULAR_CLASS,
-		{
-		{3,{0,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{3,{4,5,6,0},{0,1,1,0},{0,5,6,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{TT1,1,REGULAR_CLASS,
-		{
-		{4,{5,6,1,2},{1,1,1,1},{5,6,1,2}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{TT2,2,REGULAR_CLASS,
-		{
-		{3,{2,5,6,0},{1,1,0,0},{2,5,1,0}},
-		{3,{2,6,1,0},{0,1,1,0},{0,6,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT0,2,REGULAR_CLASS,
-		{
-		{4,{0,1,2,3},{0,1,1,1},{1,1,2,3}},
-		{3,{4,5,6,0},{0,1,1,0},{0,5,6,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT1,2,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{4,{5,6,1,2},{1,1,1,0},{5,6,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT2,2,REGULAR_CLASS,
-		{
-		{4,{5,6,2,3},{1,0,1,1},{5,1,2,3}},
-		{3,{6,1,2,0},{1,1,0,0},{6,1,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT3,3,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{3,{5,6,2,0},{1,0,0,0},{5,2,0,0}},
-		{3,{6,1,2,0},{1,1,0,0},{6,1,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT4,2,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{4,{4,3,5,6},{0,1,1,1},{0,3,5,6}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT5,2,REGULAR_CLASS,
-		{
-		{4,{3,6,1,2},{0,1,1,1},{1,6,1,2}},
-		{3,{3,5,6,0},{1,1,0,0},{3,5,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QT6,3,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{3,{3,6,4,0},{0,1,0,0},{2,6,0,0}},
-		{3,{3,5,6,0},{1,1,0,0},{3,5,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ0,2,REGULAR_CLASS,
-		{
-		{4,{0,1,2,3},{0,1,1,1},{1,1,2,3}},
-		{4,{4,5,6,7},{0,1,1,1},{0,5,6,7}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ1,3,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{4,{5,6,1,2},{1,0,1,0},{5,2,1,0}},
-		{3,{6,7,4,0},{1,1,0,0},{6,7,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ2,4,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{3,{5,6,2,1},{1,0,0,0},{5,2,0,0}},
-		{3,{6,1,2,0},{0,1,0,0},{3,1,1,0}},
-		{3,{6,7,4,0},{1,1,0,0},{6,7,2,0}}
-		}
-	},
-	{QQ3,3,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{4,{5,7,1,2},{0,1,1,0},{2,7,1,0}},
-		{3,{5,6,7,0},{1,1,0,0},{5,6,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ4,4,REGULAR_CLASS,
-		{
-		{3,{0,2,3,0},{0,1,1,0},{1,2,3,0}},
-		{3,{5,7,2,0},{0,0,0,0},{2,3,0,0}},
-		{3,{5,6,7,0},{1,1,0,0},{5,6,1,0}},
-		{3,{1,2,7,0},{1,0,1,0},{1,1,7,0}}
-		}
-	},
-	{QQ5,3,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{4,{5,7,1,3},{0,1,0,1},{2,7,0,3}},
-		{3,{5,6,7,0},{1,1,0,0},{5,6,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ6,4,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{3,{3,7,4,0},{0,1,0,0},{2,7,0,0}},
-		{3,{3,0,7,0},{1,0,0,0},{3,3,1,0}},
-		{3,{5,6,7,0},{1,1,0,0},{5,6,2,0}}
-		}
-	},
-	{QQ7,3,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{4,{5,6,1,3},{1,0,0,1},{5,2,0,3}},
-		{3,{6,7,4,0},{1,1,0,0},{6,7,1,0}},
-		{0,{0,0,0,0},{0,0,0,0},{0,0,0,0}}
-		}
-	},
-	{QQ8,4,REGULAR_CLASS,
-		{
-		{3,{3,1,2,0},{0,1,1,0},{1,1,2,0}},
-		{3,{3,6,4,0},{0,0,0,0},{3,2,0,0}},
-		{3,{6,7,4,0},{1,1,0,0},{6,7,1,0}},
-		{3,{3,5,6,0},{1,1,0,0},{3,5,1,0}}
-		}
-	}
-};
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/ugrefine2d.c,v 1.10 2005/08/11 12:14:59 sander Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* Function:  GetRulePtr													*/
-/*																			*/
-/* Purpose:   permits access to the refinement rules						*/
-/*																			*/
-/* Input:	  INT rule														*/
-/*																			*/
-/* Output:	  pointer to rule												*/
-/*																			*/
-/****************************************************************************/
-
-static REFRULE *GetRulePtr(INT rule)
-{
-	return(&(Rules[rule]));
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  GetCRulePtr													*/
-/*																			*/
-/* Purpose:   permits access to the swap rules								*/
-/*																			*/
-/* Input:	  INT rule														*/
-/*																			*/
-/* Output:	  pointer to rule												*/
-/*																			*/
-/****************************************************************************/
-
-static CHANGE_RULE *GetCRulePtr(INT rule)
-{
-	return(&(CRules[rule]));
-}
-
-/****************************************************************************/
-/*																			*/
-/*							   Grid Refinement								*/
-/*																			*/
-/*	The purpose of the following routines is to compute a new sequence of	*/
-/*	nested triangulations from an existing one. Since the currently finest	*/
-/*	triangulation of the domain omega is stored distributed over several	*/
-/*	levels the input of the algorithm must be provided on the elements, 	*/
-/*	which have no regular sons. (the elements where EstimateHere(e)==TRUE). */
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CloseElement													*/
-/*																			*/
-/* Purpose:   makes the new refinement marks consistent 					*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: pointer to element						*/
-/*																			*/
-/* return:	  0: element will not be refined								*/
-/*			  1: this element will be refined in some way					*/
-/*			  -1: error occurred											*/
-/****************************************************************************/
-
-static INT CloseElement (ELEMENT *theElement)
-{
-	ELEMENT *theNeighbor;
-	INT i,l,n,myRule,myBasicRule,nbRule,myClass,myVariant;
-	INT myPattern,newPattern,nbPattern0,nbPattern1,regFlag;
-	
-	n = TAG(theElement);
-
-	/* get my pattern from current refinement rule */
-	myRule = MARK(theElement);
-	myPattern = Rules[myRule].condensedPattern;
-	myClass = Rules[myRule].class;
-	
-	/* check if rule can be applied */
-	if (MARK(theElement)!=0)
-		if (Rules[myRule].tag!=n)
-		{
-			PrintErrorMessage('E',"CloseElement","rule does not fit");
-			return(-1);
-		}
-	
-	if (ECLASS(theElement)==COPY_CLASS) return(0);	/* nothing should be done for copies */
-	
-	/* compute pattern the neighbors with regular refinement rule imply (here could be some optimizing!) */
-	nbPattern0 = 0; nbPattern1=0; regFlag=0;
-	for (i=n-1; i>=0; i--)
-	{
-		nbPattern0 = nbPattern0<<1;
-		nbPattern1 = nbPattern1<<1;
-		theNeighbor = NBELEM(theElement,i);
-		if (theNeighbor!=NULL)
-			if (ECLASS(theNeighbor)==REGULAR_CLASS)
-				if (Rules[nbRule=MARK(theNeighbor)].rule!=NO_REF)
-					if (Rules[nbRule].class==REGULAR_CLASS)
-					{
-						regFlag=1;
-						for (l=0; l<TAG(theNeighbor); l++)
-							if (NBELEM(theNeighbor,l)==theElement)
-								break;
-						
-						if (Rules[nbRule].pattern[l]==0)
-							nbPattern0++;
-						else
-							nbPattern1++;
-					}
-	}
-	
-	newPattern=(myPattern&(~nbPattern0))|nbPattern1;
-	
-	/* if patterns are not consistent change to new rule */
-	if ((myPattern!=newPattern)||regFlag)
-	{
-		if (myRule==NO_REF)
-		{
-			if (n==TRIANGLE)
-			{
-				myBasicRule=StandardFollowRule_T[newPattern];
-				myVariant=StandardFollowVariant_T[newPattern];
-			}
-			else
-			{
-				myBasicRule=StandardFollowRule_Q[newPattern];
-				myVariant=StandardFollowVariant_Q[newPattern];
-			}
-		}
-		else
-		{
-			myRule=Rules[myRule].followRule[newPattern];
-			if (myRule==-1)
-			{
-				PrintErrorMessage('E',"CloseElement","follow rule has not been set");
-				return(-1);
-			}
-			
-			myBasicRule=Rules[myRule].rule;
-			myVariant=Rules[myRule].variant;
-		}
-		
-		/* if previous rule was not regular the rule is irregular */
-		if (myClass!=REGULAR_CLASS)
-			myRule=BasicRules[myBasicRule].classOffset[IRREGULAR_CLASS]+BasicRules[myBasicRule].variantOffset[myVariant];
-		else
-			myRule=BasicRules[myBasicRule].classOffset[REGULAR_CLASS]+BasicRules[myBasicRule].variantOffset[myVariant];
-			
-		SETMARK(theElement,myRule);
-	}
-	
-	if ((ECLASS(theElement)==REGULAR_CLASS)&&(Rules[myRule].class==REGULAR_CLASS))
-		return(1);
-	else
-		return(0);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CloseGrid 													*/
-/*																			*/
-/* Purpose:   compute closure for next level								*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  INT >0: elements will be refined								*/
-/*			  INT 0: no elements will be refined							*/
-/*																			*/
-/****************************************************************************/
-
-static INT CloseGrid (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	INT status,cnt;
-	
-	cnt = 0;
-
-	/* go once through all elements */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if ((status=CloseElement(theElement))>=0)
-			cnt+=status;
-		else
-			return(-1);
-	
-	return(cnt);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ComputeNodeClasses											*/
-/*																			*/
-/* Purpose:   compute node classes from refinement							*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  0: ok 														*/
-/*																			*/
-/****************************************************************************/
-
-static INT ComputeDistance (NODE *theNode)
-{
-	LINK *link1,*link2;
-
-	/* distance 0 */
-	if (NCLASS(theNode)==3) return(0);
-	
-	/* search distance 1 */
-	for (link1=START(theNode); link1!=NULL; link1=NEXT(link1))
-		if (NCLASS(NBNODE(link1))==3) return(1);
-	
-	/* search distance 2 */
-	for (link1=START(theNode); link1!=NULL; link1=NEXT(link1))
-		for (link2=START(NBNODE(link1)); link2!=NULL; link2=NEXT(link2))
-			if (NCLASS(NBNODE(link2))==3) return(2);
-	
-	/* no class 3 node in distance <= 2 */
-	return(999);
-}
-
-static INT ComputeNodeClasses (GRID *theGrid)
-{
-	NODE *theNode;
-	ELEMENT *theElement;
-	INT i,flag;
-	
-	/* reset classes on next level */
-	for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-		SETNCLASS(theNode,0);
-
-	/* set corners of irregularly and regularly refined elements to class 3 */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if (Rules[MARK(theElement)].class>=IRREGULAR_CLASS)
-		{
-			flag=1;
-			for (i=0; i<TAG(theElement); i++)
-				SETNCLASS(CORNER(theElement,i),3);
-		}
-	
-	if (rFlag==GM_COPY_ALL)
-	{
-		if (flag)
-			for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-				SETNCLASS(theNode,3);
-	}
-	else
-	{
-		/* find class 2 nodes, this implementation better for parallel version */
-		for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-			SETNCLASS(theNode,MAX(0,3-ComputeDistance(theNode)));
-	}
-	
-	return(0);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ComputeCopies 												*/
-/*																			*/
-/* Purpose:   determine copy elements from node classes 					*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  0: ok 														*/
-/*																			*/
-/****************************************************************************/
-
-static INT ComputeCopies (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	INT i;
-	
-	/* determine node classes in any version, since it doesn't hurt */
-	ComputeNodeClasses(theGrid);
-
-	/* now this is only correct in the old version				*/
-	/* all unrefined elements with a corner >= 2 are set to copy*/
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if (MARK(theElement)==0)
-		{
-			for (i=0; i<TAG(theElement); i++)
-				if (NCLASS(CORNER(theElement,i))>=2)
-				{
-					if (TAG(theElement)==TRIANGLE)
-						SETMARK(theElement,BasicRules[T_COPY].classOffset[COPY_CLASS]);
-					else
-						SETMARK(theElement,BasicRules[Q_COPY].classOffset[COPY_CLASS]);
-					break;
-				}
-		}
-
-	return(0);
-}
-
-static INT Version3_ComputeCopies (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	INT flag;
-	
-	/* determine node classes in any version, since it doesn't hurt */
-	ComputeNodeClasses(theGrid);
-	
-	/* set class of all dofs on next level to 0 */
-	ClearNextVectorClasses(theGrid);
-	
-	/* seed dofs of regularly and irregularly refined elements to 3 */
-	flag = 0;
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if (Rules[MARK(theElement)].class>=IRREGULAR_CLASS)
-		{
-			SeedNextVectorClasses(theElement);
-			flag=1; /* there is at least one element to be refined */
-		}
-
-	/* copy all option or neighborhood */	
-	if (rFlag==GM_COPY_ALL)
-	{
-		if (flag)
-			for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-				SeedNextVectorClasses(theElement);
-	}
-	else
-	{
-		PropagateNextVectorClasses(theGrid);
-	}
-	
-	/* an element is copied if it has a dof of class 2 and higher */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if ((MARK(theElement)==0)&&(MaxNextVectorClass(theElement)>=MINVNCLASS))
-		{
-			if (TAG(theElement)==TRIANGLE)
-				SETMARK(theElement,BasicRules[T_COPY].classOffset[COPY_CLASS]);
-			else
-				SETMARK(theElement,BasicRules[Q_COPY].classOffset[COPY_CLASS]);
-		}
-
-	return(0);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RestrictMarks 												*/
-/*																			*/
-/* Purpose:   restrict refinement marks when going down 					*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void RestrictMarks (GRID *theGrid)
-{
-	ELEMENT *theElement,*theNeighbor;
-	INT myClass,sonClass,myRule,sonRule,nbRule,newRule,newVariant;
-	INT newPattern,nbPattern0,nbPattern1,orPattern;
-	INT i,l,m,flag;
-	
-	/* this loop handles COARSEN commands and sets MARK=OLDREF for regularly refined elements */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		myRule = REFINE(theElement);
-		if (myRule==NO_REF) continue;	/* leaf elements are marked by estimator */
-		
-		sonClass = Rules[myRule].class;
-		myClass = ECLASS(theElement);
-		
-		/* copies that have a copy son take the tag of the son */
-		if (myClass==COPY_CLASS)
-		{
-			SETMARK(theElement,MARK(SON(theElement,0)));
-			SETCOARSEN(theElement,COARSEN(SON(theElement,0)));
-			continue;
-		}
-
-		/* irregular elements that have a copy son take the tag of the son but cannot be coarsened */
-		if (myClass==IRREGULAR_CLASS) 	
-		{
-			SETMARK(theElement,MARK(SON(theElement,0)));
-			SETCOARSEN(theElement,0);
-			continue;
-		}
-		
-		/* now we are left with regular elements that are refined */
-		
-		/* son is a copy, take tag of the son */
-		if (sonClass==COPY_CLASS)
-		{
-			SETMARK(theElement,MARK(SON(theElement,0)));
-			SETCOARSEN(theElement,COARSEN(SON(theElement,0)));
-			continue;
-		}
-		
-		/* regular elements with irregular refinement are handled below */
-		if (sonClass==IRREGULAR_CLASS) continue;
-		
-		/* regular elements with regular refinement are the only ones to coarsen */
-		SETMARK(theElement,REFINE(theElement));
-		if (DECOUPLED(theElement)) continue;	/* tree has been broken up here: no coarsening possible! */
-		
-		flag = 0;
-		for (i=0; i<NSONS(theElement); i++)
-		{
-			/* if not all sons are marked no unrefinement is possible */
-			if (!COARSEN(SON(theElement,i)))
-			{
-				flag = 1;
-				break;
-			}
-		}
-		
-		if (!flag)
-		{
-			/* remove refinement */
-			SETMARK(theElement,0);
-			SETCOARSEN(theElement,0);
-		}
-	}
-	
-	/* now a second loop over all elements handles the regular elements with irregular sons */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		myRule = REFINE(theElement);
-		if (myRule==NO_REF) continue;
-		
-		sonClass = Rules[myRule].class;
-		if (sonClass!=IRREGULAR_CLASS) continue;	/* only regular elements are allowed to have irregular sons */
-		
-		/* is there a refinement mark on the regular father? */
-		if ((newRule=MARK(theElement))!=0)
-			flag=1;
-		else
-		{
-			/* no: check if its sons have a refinement flag set */
-			flag=0;
-			for (i=0; i<NSONS(theElement); i++)
-				if ((sonRule=MARK(SON(theElement,i)))!=0)
-				{
-					flag=1;
-					break;
-				}
-		}
-		
-		if (flag==0) continue;
-		
-		/* get the enforced pattern */
-		nbPattern0=0; nbPattern1=0; orPattern=0;
-		for (i=TAG(theElement)-1; i>=0; i--)
-		{
-			nbPattern0 = nbPattern0<<1;
-			nbPattern1 = nbPattern1<<1;
-			orPattern = orPattern<<1;
-			theNeighbor = NBELEM(theElement,i);
-			if (theNeighbor!=NULL)
-				if (ECLASS(theNeighbor)==REGULAR_CLASS)
-					if ((nbRule=MARK(theNeighbor))!=NO_REF)
-						if (Rules[nbRule].class==REGULAR_CLASS)
-						{
-							if (Rules[nbRule].rule==Q_BLUE)
-								orPattern++;
-							m = TAG(theNeighbor);
-							for (l=0; l<m; l++)
-								if (NBELEM(theNeighbor,l)==theElement)
-									break;
-							
-							if (Rules[nbRule].pattern[l]==0)
-								nbPattern0++;
-							else
-								nbPattern1++;
-						}
-		}
-		
-		if (newRule!=0)
-		{
-			/* there is a refinement order given: try to fulfill it as good as possible */
-			newPattern=(Rules[newRule].condensedPattern&(~nbPattern0)) | nbPattern1;
-			newRule=Rules[newRule].followRule[newPattern];
-			SETMARK(theElement,newRule);
-			continue;
-		}
-				
-		/*	no refinement given on the father, yet we must change the refinement to regular:
-			try to make it as good as possible (i.e. copy, red or blue) */
-		if (TAG(theElement)==TRIANGLE)
-		{
-			if (nbPattern0==0)
-			{
-				newRule=T_RED;
-				newVariant=0;
-			}
-			else
-			{
-				if (nbPattern1==0)
-				{
-					/* order copy refinement */
-					newRule=T_COPY;
-					newVariant=0;
-				}
-				else
-				{
-					/* no chance to make it more regular */
-					newRule=StandardFollowRule_T[nbPattern1];
-					newVariant=StandardFollowVariant_T[nbPattern1];
-				}
-			}
-		}
-		else
-		{
-			newRule=NO_REF;
-			if ((orPattern==(nbPattern0|nbPattern1)) && (nbPattern0!=0))
-			{
-				/* all regular neighbors are blue refined and we have the possibility of locality by blue refinement */
-				if (((5&(~nbPattern0))|nbPattern1)==5)
-				{
-					newRule=Q_BLUE;
-					newVariant=0;
-				}
-				else
-				{
-					if (((10&(~nbPattern0))|nbPattern1)==10)
-					{
-						newRule=Q_BLUE;
-						newVariant=1;
-					}
-				}
-			}
-			
-			if (newRule==NO_REF)
-			{
-				if (nbPattern0==0)
-				{
-					newRule=Q_RED;
-					newVariant=0;
-				}
-				else
-				{
-					if (nbPattern1==0)
-					{
-						newRule=Q_COPY;
-						newVariant=0;
-					}
-					else
-					{
-						newRule=StandardFollowRule_Q[nbPattern1];
-						newVariant=StandardFollowVariant_Q[nbPattern1];
-					}
-				}
-			}
-			
-		}
-		
-		newRule=BasicRules[newRule].classOffset[REGULAR_CLASS]+BasicRules[newRule].variantOffset[newVariant];
-		SETMARK(theElement,newRule);
-		continue;
-	
-	}	/* endfor */
-		
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CheckMemoryRequirements										*/
-/*																			*/
-/* Purpose:   check if there is enough memory for the following refinement	*/
-/*																			*/
-/* Param:	  MULTIGRID *theMG: pointer to multigrid structure with 		*/
-/*								computed refinement 						*/
-/*																			*/
-/* return:	  INT 1: enough memory for the operation						*/
-/*			  INT 0: not enough memory for the operation					*/
-/*																			*/
-/****************************************************************************/
-
-static INT CheckMemoryRequirements (MULTIGRID *theMG)
-{
-	if (theMG->theHeap->size-theMG->theHeap->used<=0)
-		return(0);
-	else
-		return(1);
-}
-
-	
-/****************************************************************************/
-/*																			*/
-/* Function:  CreateMidNode 												*/
-/*																			*/
-/* Purpose:   allocate a new node on a side of an element. Includes vertex	*/
-/*			  best fit boundary coordinates and local coordinates			*/
-/*			  insert also links to endpoints of the refined edge			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  INT side: side to refine										*/
-/*			  NODE *after: insert new node after that node					*/
-/*																			*/
-/* return:	  NODE* : pointer to new node									*/
-/*			  NULL	: could not allocate									*/
-/*																			*/
-/****************************************************************************/
-
-static NODE *CreateMidNode (GRID *theGrid,ELEMENT *theElement,INT side,NODE *after)
-{
-	ELEMENTSIDE *theSide;
-	COORD x,y;
-	COORD r[2],lambda1,lambda0,z;
-	COORD lambda,dlambda,s,lambdaopt,smin;
-	INT i,n;
-	VERTEX *theVertex;
-	VSEGMENT *vsnew;
-	NODE *theNode;
-	PATCH *thePatch;
-
-	n = TAG(theElement);
-	
-	/* calculate midpoint of edge */
-	x = 0.5*(XC(MYVERTEX(CORNER(theElement,side)))+XC(MYVERTEX(CORNER(theElement,(side+1)%n))));
-	y = 0.5*(YC(MYVERTEX(CORNER(theElement,side)))+YC(MYVERTEX(CORNER(theElement,(side+1)%n))));
-
-	/* allocate vertex */
-	if ((OBJT(theElement)==BEOBJ)&&(SIDE(theElement,side)!=NULL))
-	{
-		/* find optimal boundary coordinate for boundary vertex */
-		theSide = SIDE(theElement,side);
-		thePatch = ES_PATCH(theSide);
-		smin = 1.0E30;
-		lambda0 = PARAM(theSide,0,0);
-		lambda1 = PARAM(theSide,1,0);
-		dlambda = (lambda1-lambda0)/((COORD) BMNRESOLUTION);
-		lambda = lambda0;
-		for (i=1; i<BMNRESOLUTION; i++)
-		{
-			lambda += dlambda;
-			if (Patch_local2global(thePatch,&lambda,r)) return (NULL);
-			s = (r[0]-x)*(r[0]-x)+(r[1]-y)*(r[1]-y);
-			if (s<smin)
-			{
-				smin = s;
-				lambdaopt = lambda;
-			}
-		}
-		
-		/* create vertex */
-		theVertex = CreateBoundaryVertex(theGrid,NULL);
-		if (theVertex==NULL) return(NULL);
-		vsnew = CreateVertexSegment(theGrid, theVertex);
-		if (vsnew==NULL)
-		{
-			DisposeVertex(theGrid,theVertex);
-			UserWrite("cannot create vertexsegment\n");
-			return(NULL);
-		}
-		LAMBDA(vsnew,0) = lambdaopt;
-		if (Patch_local2global(thePatch,PVECT(vsnew),CVECT(theVertex))) return (NULL);
-		z = (lambdaopt-lambda0)/(lambda1-lambda0);
-		ZETA(vsnew) = z;
-		SETONEDGE(theVertex,side);
-		VS_PATCH(vsnew) = thePatch;
-		if (n==3)
-		{
-			if (side==0) { XI(theVertex)= z  ; ETA(theVertex)= 0.0; }
-			if (side==1) { XI(theVertex)= 1-z; ETA(theVertex)= z  ; }
-			if (side==2) { XI(theVertex)= 0.0; ETA(theVertex)= 1-z; }
-		}
-		else
-		{
-			if (side==0) { XI(theVertex)= 2*z-1; ETA(theVertex)= -1.0; }
-			if (side==1) { XI(theVertex)= 1.0;	 ETA(theVertex)= 2*z-1; }
-			if (side==2) { XI(theVertex)= 1-2*z; ETA(theVertex)= 1.0; }
-			if (side==3) { XI(theVertex)= -1.0;  ETA(theVertex)= 1-2*z; }
-		}
-		VFATHER(theVertex) = theElement;
-		SETMOVE(theVertex,1);
-	}
-	else
-	{
-		/* we need an inner vertex */
-		theVertex = CreateInnerVertex(theGrid,NULL);
-		if (theVertex==NULL) return(NULL);
-		XC(theVertex) = x;
-		YC(theVertex) = y;
-		if (n==3)
-		{
-			if (side==0) { XI(theVertex)= 0.5; ETA(theVertex)= 0.0; }
-			if (side==1) { XI(theVertex)= 0.5; ETA(theVertex)= 0.5; }
-			if (side==2) { XI(theVertex)= 0.0; ETA(theVertex)= 0.5; }
-		}
-		else
-		{
-			if (side==0) { XI(theVertex)= 0.0; ETA(theVertex)=-1.0; }
-			if (side==1) { XI(theVertex)= 1.0; ETA(theVertex)= 0.0; }
-			if (side==2) { XI(theVertex)= 0.0; ETA(theVertex)= 1.0; }
-			if (side==3) { XI(theVertex)=-1.0; ETA(theVertex)= 0.0; }
-		}
-		VFATHER(theVertex) = theElement;
-		SETMOVE(theVertex,2);
-	}
-
-	/* allocate node */
-	theNode = CreateNode(theGrid,after);
-	if (theNode==NULL)
-	{
-		DisposeVertex(theGrid,theVertex);
-		return(NULL);
-	}
-	MYVERTEX(theNode) = theVertex;
-	NFATHER(theNode) = NULL;
-	TOPNODE(theVertex) = theNode;
-	
-	return(theNode);	
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  GetCurrentContext 											*/
-/*																			*/
-/* Purpose:   assemble references to objects which interact with the sons	*/
-/*			  of the given element, as indicated by REFINE. 				*/
-/*			  (i)	 corner nodes											*/
-/*			  (ii)	 nodes at midpoints of edges							*/
-/*			  (iii)  neighboring elements									*/
-/*			  (iv)	 locations where neighbors store references to our sons */
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  ElementContext *theContext: context structure to fill 		*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void GetCurrentContext (ELEMENT *theElement, ElementContext *theContext) 
-{
-	NODE *theNode;					/* corner node							*/
-	ELEMENT *theNeighbor,*theSon;	/* neighbor and a son of current elem.	*/
-	ELEMENT *theNeighborOfSon;		/* a neighbor of theSon 				*/
-	INT i,l,m,n;					/* some integer variables				*/
-	NODE **Nodes;					/* corner nodes of an element to be ref.*/
-	NODE **MidNodes;				/* nodes on refined edges				*/
-	ELEMENT **Neighbors;			/* neighbors on next higher level		*/
-	ELEMENT ***BackPtrs;				/* locations where neighbs store my adr */
-	REFRULE *rule;					/* current refinement rule of theElement*/
-	REFRULE *nbrule;				/* current refinement rule of neighbor	*/
-
-	n = TAG(theElement);
-	rule = &(Rules[REFINE(theElement)]);
-	
-	Nodes = theContext->Nodes;
-	MidNodes = theContext->MidNodes;
-	Neighbors = theContext->Neighbors;
-	BackPtrs = theContext->BackPtrs;
-	theContext->Interior = NULL;
-	
-	for (i=0; i<4; i++) 			/* reset pointers						*/
-	{
-		Nodes[i] = MidNodes[i] = NULL;
-		Neighbors[2*i] = Neighbors[2*i+1] = NULL;
-		BackPtrs[2*i] = BackPtrs[2*i+1] = NULL;
-	}
-	
-	for (i=0; i<n; i++)
-	{								/* get corner nodes 					*/
-
-		theNode = CORNER(theElement,i);
-		Nodes[i] = SONNODE(theNode);
-	}
-	
-	for (i=0; i<n; i++)
-	{								/* get midpoint nodes					*/
-		if (rule->midSon[i]>=0)
-			MidNodes[i] = CORNER(SON(theElement,rule->midSon[i]),rule->midCorner[i]);
-	}
-	
-	/* get interior node */
-	if ((n==4)&&(rule->midSon[4]>=0))
-		theContext->Interior = CORNER(SON(theElement,rule->midSon[4]),rule->midCorner[4]);
-
-	for (i=0; i<n; i++)
-	{								/* get pointers to neighbors and locatio*/
-									/* of their pointers to us				*/
-
-		theNeighbor = NBELEM(theElement,i);
-		
-		if (theNeighbor!=NULL)
-		{
-			/*	If neighbor is decoupled then get information from the own sons via son->nb.
-				This is essential when abondoning locally the tree structure.	*/
-			
-			if (DECOUPLED(theNeighbor))
-			{
-				if (rule->nbSon[2*i]>=0)
-				{
-					theSon=SON(theElement,rule->nbSon[2*i]);
-					Neighbors[2*i]=theNeighborOfSon=NBELEM(theSon,rule->nbSide[2*i]);
-					if (theNeighborOfSon!=NULL)
-					{
-						/* now we have to search for sonEl */
-						for (l=0; l<TAG(theNeighborOfSon); l++)
-							if (NBELEM(theNeighborOfSon,l)==theSon)
-								break;
-						BackPtrs[2*i]  = (ELEMENT **) &(VOID_NBELEM(theNeighborOfSon,l));
-					}
-					
-					if (rule->nbSon[2*i+1]>=0)
-					{
-						theSon=SON(theElement,rule->nbSon[2*i+1]);
-						Neighbors[2*i+1]=theNeighborOfSon=NBELEM(theSon,rule->nbSide[2*i+1]);
-						if (theNeighborOfSon!=NULL)
-						{
-							/* now we have to search for sonEl */
-							for (l=0; l<TAG(theNeighborOfSon); l++)
-								if (NBELEM(theNeighborOfSon,l)==theSon)
-									break;
-							BackPtrs[2*i+1]  = (ELEMENT **) &(VOID_NBELEM(theNeighborOfSon,l));
-						}
-					}
-				}
-				continue;	/* next side of theElement */
-			}
-			
-			/* else get the neighbors of the sons from the tree structure via nb->son */
-			
-			m = TAG(theNeighbor);
-			for (l=0; l<m; l++)
-				if (NBELEM(theNeighbor,l)==theElement)
-					break;
-			nbrule = &(Rules[REFINE(theNeighbor)]);
-			
-			if (nbrule->nbSon[2*l]>=0)
-			{
-				if (nbrule->nbSon[2*l+1]>=0)
-				{
-					Neighbors[2*i] = SON(theNeighbor,nbrule->nbSon[2*l+1]);
-					if (Neighbors[2*i]!=NULL)
-						BackPtrs[2*i]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i],nbrule->nbSide[2*l+1]));
-					Neighbors[2*i+1] = SON(theNeighbor,nbrule->nbSon[2*l]);
-					if (Neighbors[2*i+1]!=NULL)
-						BackPtrs[2*i+1]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i+1],nbrule->nbSide[2*l]));
-				}
-				else
-				{
-					Neighbors[2*i] = SON(theNeighbor,nbrule->nbSon[2*l]);
-					if (Neighbors[2*i]!=NULL)
-						BackPtrs[2*i]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i],nbrule->nbSide[2*l]));
-				}
-			}
-		}
-	}
-	
-	return;
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  UpdateContext 												*/
-/*																			*/
-/* Purpose:   assemble references to objects which interact with the sons	*/
-/*			  of the given element, i.e.									*/
-/*			  objects are allocated, kept or deleted as indicated by MARK	*/
-/*			  (i)	 corner nodes											*/
-/*			  (ii)	 nodes at midpoints of edges							*/
-/*			  (iii)  neighboring elements									*/
-/*			  (iv)	 locations where neighbors store references to our sons */
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of the sons of theElement			*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ElementContext *theContext: context structure to update		*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-
-static INT UpdateContext (GRID *theGrid, ELEMENT *theElement, ElementContext *theContext)
-{
-	NODE *theNode;					/* corner node							*/
-	ELEMENT *theNeighbor;			/* neighbor and a son of current elem.	*/
-	EDGE *theEdge;					/* temporary storage for an edge		*/
-	INT i,l,m,n;					/* some integer variables				*/
-	NODE **Nodes;					/* corner nodes of an element to be ref.*/
-	NODE **MidNodes;				/* nodes on refined edges				*/
-	ELEMENT **Neighbors;			/* neighbors on next higher level		*/
-	ELEMENT ***BackPtrs;			/* locations where neighbs store my adr */
-	LINK *theLink;					/* scan through nodes neighbor list 	*/
-	INT candelete;
-	REFRULE *rule;					/* new refinement rule of theElement	*/
-	REFRULE *nbrule;				/* refinement rule of neighbor			*/
-
-	n = TAG(theElement);
-	Nodes = theContext->Nodes;
-	MidNodes = theContext->MidNodes;
-	Neighbors = theContext->Neighbors;
-	BackPtrs = theContext->BackPtrs;
-	rule = &(Rules[MARK(theElement)]);
-	
-	/* theContext holds current context */
-	
-	/* allocate corner nodes if necessary */
-	if (MARK(theElement)>0)
-	{
-		/* we need corner nodes */
-		for (i=0; i<n; i++)
-		{
-			theNode = CORNER(theElement,i);
-			if (SONNODE(theNode)==NULL)
-			{
-				SONNODE(theNode) = CreateNode(theGrid,NULL);
-				if (SONNODE(theNode)==NULL) return(1);
-				SETUSED(theNode,1);
-				theGrid->status |= 1;
-				MYVERTEX(SONNODE(theNode)) = MYVERTEX(theNode);
-				NFATHER(SONNODE(theNode)) = theNode;
-				Nodes[i] = SONNODE(theNode);
-				SETCLASS(Nodes[i],NCLASS(theNode));
-			}
-		}
-	}
-	
-	/* allocate,keep, or delete midpoint nodes */
-	/* allocate,keep, or delete corner/corner edges */
-	for (i=0; i<n; i++)
-	{
-		if (rule->pattern[i])
-		{
-			/* if a corner corner edge exists then delete it */
-			if ((theEdge = GetEdge(Nodes[i],Nodes[(i+1)%n]))!=NULL)
-				DisposeEdge(theGrid,theEdge);
-			
-			/* we need a midpoint node */
-			if (MidNodes[i]!=NULL) continue;
-			
-			/* lets see if neighbor has already one */
-			theNeighbor = NBELEM(theElement,i);
-			if (theNeighbor!=NULL)
-			{
-				m = TAG(theNeighbor);
-				for (l=0; l<m; l++)
-					if (NBELEM(theNeighbor,l)==theElement)
-						break;
-				nbrule = &(Rules[REFINE(theNeighbor)]);
-				if (nbrule->midSon[l]>=0)
-				{
-					MidNodes[i] = CORNER(SON(theNeighbor,nbrule->midSon[l]),nbrule->midCorner[l]);
-					continue;
-				}
-			}
-			
-			/* now we must allocate a new one */
-			MidNodes[i] = CreateMidNode(theGrid,theElement,i,Nodes[i]);
-			if (MidNodes[i]==NULL) return(1);
-			SETCLASS(MidNodes[i],4);
-			SETUSED(MidNodes[i],1);
-			theGrid->status |= 1;
-			if (CreateEdge(theGrid,Nodes[i],MidNodes[i])==NULL) return(1);
-			if (CreateEdge(theGrid,Nodes[(i+1)%n],MidNodes[i])==NULL) return(1);
-		}
-		else
-		{
-			/* if we need a corner corner edge then allocate it */
-			if (MARK(theElement)>0)
-			{
-				if ((theEdge = GetEdge(Nodes[i],Nodes[(i+1)%n]))==NULL)
-					theEdge = CreateEdge(theGrid,Nodes[i],Nodes[(i+1)%n]);
-			}
-			else
-			{
-				/* delete corner corner edge */
-				if (Neighbors[2*i]==NULL)
-				{
-					theEdge = GetEdge(Nodes[i],Nodes[(i+1)%n]);
-					if (theEdge!=NULL) DisposeEdge(theGrid,theEdge);
-				}
-			}
-
-			/* we don't need a midpoint node on that edge, lets see if it can be deleted */
-			if (MidNodes[i]==NULL) continue;
-
-			candelete = 1;
-			for (theLink=START(MidNodes[i]); theLink!=NULL; theLink=NEXT(theLink))
-			{
-				if (!EXTRA(theLink))
-					if ((NBNODE(theLink)!=Nodes[i])&&(NBNODE(theLink)!=Nodes[(i+1)%n]))
-					{
-						candelete = 0;
-						break;
-					}
-			}
-			
-			if (candelete)
-			{
-				DisposeVertex(theGrid,MYVERTEX(MidNodes[i]));
-				DisposeNode(theGrid,MidNodes[i]);
-				MidNodes[i] = NULL;
-			}
-		}
-	}
-
-	/* delete corner nodes if possible */
-	if (MARK(theElement)==0)
-	{
-		/* we need no corner nodes */
-		for (i=0; i<n; i++)
-		{
-			theNode = CORNER(theElement,i);
-			if (Nodes[i]!=NULL)
-			{
-				candelete = 1;
-				for (theLink=START(Nodes[i]); theLink!=NULL; theLink=NEXT(theLink))
-					if (!EXTRA(theLink))
-					{
-						candelete = 0;
-						break;
-					}
-				if (candelete)
-				{
-					DisposeNode(theGrid,Nodes[i]);
-					SONNODE(theNode) = NULL;
-					Nodes[i] = NULL;
-				}
-			}
-		}
-	}
-	
-	/* get neighbor refernces for following refine */
-	for (i=0; i<n; i++)
-	{								
-		/* get pointers to neighbors and location of their pointers to us */
-		theNeighbor = NBELEM(theElement,i);
-		if (theNeighbor!=NULL)
-		{
-			/* in the following case it is still useless to set the pointers */
-			if (REFINE(theNeighbor)!=MARK(theNeighbor)) continue;
-			
-			/*	if theNeighbor is still in the same state nothing should have changed
-				for the context */
-			if (THEFLAG(theNeighbor)==0)
-			if (ECLASS(theNeighbor)==REGULAR_CLASS)
-			if (Rules[REFINE(theNeighbor)].class==REGULAR_CLASS)
-				continue;
-			
-			/* get information about new neighborhood from tree */
-			m = TAG(theNeighbor);
-			for (l=0; l<m; l++)
-				if (NBELEM(theNeighbor,l)==theElement)
-					break;
-			nbrule = &(Rules[REFINE(theNeighbor)]);
-			if (nbrule->nbSon[2*l]>=0)
-			{
-				if (nbrule->nbSon[2*l+1]>=0)
-				{
-					Neighbors[2*i] = SON(theNeighbor,nbrule->nbSon[2*l+1]);
-					if (Neighbors[2*i]!=NULL)
-						BackPtrs[2*i]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i],nbrule->nbSide[2*l+1]));
-					else
-						BackPtrs[2*i]=NULL;
-					
-					Neighbors[2*i+1] = SON(theNeighbor,nbrule->nbSon[2*l]);
-					if (Neighbors[2*i+1]!=NULL)
-						BackPtrs[2*i+1]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i+1],nbrule->nbSide[2*l]));
-					else
-						BackPtrs[2*i+1]=NULL;
-				}
-				else
-				{
-					Neighbors[2*i] = SON(theNeighbor,nbrule->nbSon[2*l]);
-					if (Neighbors[2*i]!=NULL)
-						BackPtrs[2*i]  = (ELEMENT **) &(VOID_NBELEM(Neighbors[2*i],nbrule->nbSide[2*l]));
-					else
-						BackPtrs[2*i]=NULL;
-					
-					Neighbors[2*i+1]=NULL;
-					BackPtrs[2*i+1]=NULL;
-				}
-			}
-			else
-			{
-				Neighbors[2*i]=Neighbors[2*i+1]=NULL;
-				BackPtrs[2*i]=BackPtrs[2*i+1]=NULL;
-			}			
-		}
-	}
-
-	return(0);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  UnrefineElement												*/
-/*																			*/
-/* Purpose:   remove previous refinement of an element						*/
-/*			  (i)	 all interior nodes and edges are deletes				*/
-/*			  (ii)	 sons are deleted and references to sons reset to NULL	*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of sons of theElement				*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ElementContext *theContext: current context of element		*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void UnrefineElement (GRID *theGrid, ELEMENT *theElement, ElementContext *theContext)
-{
-	INT i,n,m,s;
-	EDGE *theEdge;
-	NODE *Nodes[9]; 				/* corner nodes of an element to be ref.*/
-	ELEMENT **Neighbors;			/* neighbors on next higher level		*/
-	ELEMENT ***BackPtrs;			/* locations where neighbs store my adr */
-	REFRULE *rule;					/* current refinement rule of theElement*/
-	REFRULE *newrule;				/* new refinement rule of theElement	*/
-	ElementContext sonContext;
-	ELEMENT *theSon;
-
-	/* something to do ? */
-	if ((REFINE(theElement)==0)||(theGrid==NULL)) return;
-	
-	/* remove elements above my sons (recursively!) */
-	for (s=0; s<NSONS(theElement); s++)
-	{
-		theSon = SON(theElement,s);
-		SETMARK(theSon,0);
-		if (REFINE(theSon)>0)
-		{
-			GetCurrentContext(theSon,&sonContext);
-			UnrefineElement(theGrid->finer,theSon,&sonContext);
-			UpdateContext(theGrid->finer,theSon,&sonContext);
-		}
-		SETREFINE(theSon,MARK(theSon));
-	}
-	
-	n = TAG(theElement);
-
-#ifdef __version3__
-	/* remove connections in neighborhood of sons */
-	for (i=0; i<NSONS(theElement); i++)
-		DisposeConnectionsInNeighborhood(theGrid,SON(theElement,i));
-#endif
-
-	/* remove my sons */
-	Neighbors = theContext->Neighbors;
-	BackPtrs = theContext->BackPtrs;
-	for (i=0; i<9; i++) Nodes[i] = NULL;
-	for (i=0; i<n; i++)
-	{
-		Nodes[i] = theContext->Nodes[i];
-		Nodes[i+4] = theContext->MidNodes[i];
-	}
-	if (n==4) Nodes[8] = theContext->Interior;
-	
-	rule = &(Rules[REFINE(theElement)]);
-
-	/* remove interior edges */
-	for (s=0; s<rule->nsons; s++)
-	{
-		m = rule->sons[s].tag;
-		for (i=0; i<m; i++)
-			if ((!rule->sons[s].outer[i])&&(rule->sons[s].nb[i]>s))
-			{
-				theEdge = GetEdge(Nodes[rule->sons[s].corners[i]],Nodes[rule->sons[s].corners[(i+1)%m]]);
-				if (theEdge!=NULL) DisposeEdge(theGrid,theEdge);
-			}
-		if (m==4)
-		{
-			theEdge = GetEdge(Nodes[rule->sons[s].corners[0]],Nodes[rule->sons[s].corners[2]]);
-			if (theEdge!=NULL) DisposeEdge(theGrid,theEdge);
-			theEdge = GetEdge(Nodes[rule->sons[s].corners[1]],Nodes[rule->sons[s].corners[3]]);
-			if (theEdge!=NULL) DisposeEdge(theGrid,theEdge);
-		}	
-	}
-	
-	/* remove son elements */
-	for (i=0; i<NSONS(theElement); i++)
-		DisposeElement(theGrid,SON(theElement,i));
-	SETNSONS(theElement,0);
-	for (i=0; i<SONS_OF_ELEM(theElement); i++) SET_SON(theElement,i,NULL);
-	
-	/* remove interior node, only if not needed in new refinement */
-	if ((Nodes[8]!=NULL)&&(n==4))
-	{
-		newrule = &(Rules[MARK(theElement)]);
-		if (newrule->midSon[4]<0)
-		{
-			DisposeVertex(theGrid,MYVERTEX(Nodes[8]));
-			DisposeNode(theGrid,Nodes[8]);
-			Nodes[8] = NULL;
-			theContext->Interior = NULL;
-		}
-	}
-	
-	/* set pointers in neighbors to NULL */
-	for (i=0; i<2*n; i++)
-		if (BackPtrs[i]!=NULL)
-			*(BackPtrs[i]) = NULL;
-	
-	SETTHEFLAG(theElement,1);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RefineElement 												*/
-/*																			*/
-/* Purpose:   refine an element in the given context						*/
-/*			  (i)	 corner and midnodes are already allocated				*/
-/*			  (ii)	 edges between corner and midnodes are ok				*/
-/*			  (iii)  create interior nodes and edges						*/
-/*			  (iv)	 create sons and set references to sons 				*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of sons of theElement				*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ElementContext *theContext: current context of element		*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-		
-static INT RefineElement (GRID *theGrid, ELEMENT *theElement, ElementContext *theContext)
-{
-	INT i,j,n,m,s;
-	NODE *theNode;
-	ELEMENT *theSon;
-	VERTEX *theVertex;
-	COORD sx,sy;
-	NODE *Nodes[9]; 				/* corner nodes of an element to be ref.*/
-	NODE **MidNodes;				/* nodes on refined edges				*/
-	ELEMENT **Neighbors;			/* neighbors on next higher level		*/
-	ELEMENT ***BackPtrs;			/* locations where neighbs store my adr */
-	ELEMENTSIDE *Sides[8];
-	ELEMENTSIDE *oldSide,*newSide0,*newSide1;
-	COORD_VECTOR pos,diff,corr;
-	COORD *corners[MAX_CORNERS_OF_ELEM];
-	INT boundaryelement,found;
-	REFRULE *rule;
-	#ifdef __version23__
-		EDGE *theEdge;
-	#endif
-
-	if (MARK(theElement)==0) return(0);
-
-	n = TAG(theElement);
-	MidNodes = theContext->MidNodes;
-	Neighbors = theContext->Neighbors;
-	BackPtrs = theContext->BackPtrs;
-	for (i=0; i<9; i++) Nodes[i] = NULL;
-	for (i=0; i<n; i++)
-	{
-		Nodes[i] = theContext->Nodes[i];
-		Nodes[i+4] = theContext->MidNodes[i];
-	}
-	if (n==4) Nodes[8] = theContext->Interior;	/* only possible for quadrilaterals */
-	
-
-	/* check if T4 on the boundary should be switched to T3 */
-	/*	I don't think this is a good way...
-	DOUBLE x[3],y[3],wmin,wmax;
-	if ((n==3)&&(Rules[MARK(theElement)].rule==T_RED)&&(OBJT(theElement)==BEOBJ))
-	{
-		for (i=0; i<n; i++)
-		{
-			x[i] = (DOUBLE) XC(MYVERTEX(MidNodes[i]));
-			y[i] = (DOUBLE) YC(MYVERTEX(MidNodes[i]));
-		}
-		wmin = 1000.0; wmax = -1000.0;
-		QualityElement(n,x,y,&wmin,&wmax);
-		if ((wmin<MINANGLE)||(wmax>MAXANGLE))
-		{
-			for (i=0; i<n; i++)
-				if (SIDE(theElement,i)!=NULL) break;
-			SETMARK(theElement,T_BISECT_3+i);
-		}
-	}
-	*/
-	/* get rule */
-	rule = &(Rules[MARK(theElement)]);
-	
-	/* get interior node (8) */
-	if ((Nodes[8]==NULL)&&(rule->midSon[4]>=0))
-	{
-		/* we need an interior node */
-		theVertex = CreateInnerVertex(theGrid,NULL);
-		theNode = CreateNode(theGrid,Nodes[0]);
-		if ((theNode==NULL)||(theVertex==NULL)) return(1);
-		SETUSED(theNode,1);
-		theGrid->status |= 1;
-		sx = sy = 0.0;
-		for (j=0; j<n; j++)
-		{
-			corners[j] = CVECT(MYVERTEX(Nodes[j]));
-			sx += corners[j][_X_];
-			sy += corners[j][_Y_];
-		}
-		/* standard coordinates of the midnode */
-		XC(theVertex) = 0.25*sx;
-		YC(theVertex) = 0.25*sy;
-		XI(theVertex) = 0.0;
-		ETA(theVertex) = 0.0;
-		/* adjust the midnode for quadrilaterals with boundary sides */
-		found = 0;
-		V2_CLEAR(corr);
-		if (OBJT(theElement)==BEOBJ)
-			for (j=0; j<n; j++)
-				if (Nodes[j+4]!=NULL)
-					if (SIDE(theElement,j)!=NULL)
-					{
-						/* the midnode lies on a boundary side */
-						found++;
-						/* calculate difference to sidemid */
-						V2_LINCOMB(0.5,corners[j],0.5,corners[(j+1)%n],pos);
-						V2_LINCOMB(0.5,CVECT(MYVERTEX(Nodes[j+4])),-0.5,pos,diff);
-						V2_ADD(corr,diff,corr);
-					}
-		if (found)
-		{
-			/* now shift the midnode */
-			V2_ADD(CVECT(theVertex),corr,CVECT(theVertex));
-			
-			/* calc local coordinates in the father element */
-			if (GlobalToLocal2d(n,(const COORD **) corners,CVECT(theVertex),LCVECT(theVertex))!=0) return (1);
-		}
-		VFATHER(theVertex) = theElement;
-		NFATHER(theNode) = NULL;
-		MYVERTEX(theNode) = theVertex;
-		TOPNODE(theVertex) = theNode;
-		Nodes[8] = theNode;
-	}
-
-	/* create interior edges */
-	for (s=0; s<rule->nsons; s++)
-	{
-		m = rule->sons[s].tag;
-		for (i=0; i<m; i++)
-			if ((!rule->sons[s].outer[i])&&(rule->sons[s].nb[i]>s))
-			{
-				if (CreateEdge(theGrid,Nodes[rule->sons[s].corners[i]],Nodes[rule->sons[s].corners[(i+1)%m]])==NULL) return(1);
-			}
-		#ifdef __version23__
-			/* introduce extra diagonal edges in quadrilaterals */
-			if (m==4)
-			{
-				theEdge = CreateEdge(theGrid,Nodes[rule->sons[s].corners[0]],Nodes[rule->sons[s].corners[2]]);
-				if (theEdge==NULL) return(1);
-				SETEXTRA(theEdge,1);
-				theEdge = CreateEdge(theGrid,Nodes[rule->sons[s].corners[1]],Nodes[rule->sons[s].corners[3]]);
-				if (theEdge==NULL) return(1);
-				SETEXTRA(theEdge,1);
-			}
-		#endif
-	}
-	
-	/* create element sides */
-	for (i=0; i<8; i++) Sides[i] = NULL;
-	if (OBJT(theElement)==BEOBJ)
-	{
-		for (i=0; i<n; i++)
-		{
-			oldSide = SIDE(theElement,i);
-			if (oldSide!=NULL)
-			{
-				if (MidNodes[i]!=NULL)
-				{
-					newSide0 = CreateElementSide(theGrid);
-					newSide1 = CreateElementSide(theGrid);
-					if ((newSide0==NULL)||(newSide1==NULL)) return(1);
-					Sides[2*i] = newSide0;
-					Sides[2*i+1] = newSide1;
-					ES_PATCH(newSide0) = ES_PATCH(newSide1) = ES_PATCH(oldSide);
-					PARAM(newSide0,0,0) = PARAM(oldSide,0,0);
-					PARAM(newSide1,1,0) = PARAM(oldSide,1,0);
-					PARAM(newSide0,1,0) = PARAM(newSide1,0,0) = LAMBDA(VSEG(MYVERTEX(MidNodes[i])),0);
-				}
-				else
-				{
-					newSide0 = CreateElementSide(theGrid);
-					if (newSide0==NULL) return(1);
-					Sides[2*i] = newSide0;
-					ES_PATCH(newSide0) = ES_PATCH(oldSide);
-					PARAM(newSide0,0,0) = PARAM(oldSide,0,0);
-					PARAM(newSide0,1,0) = PARAM(oldSide,1,0);
-				}
-			}
-		}
-	}
-	
-	/* create elements */
-	for (s=0; s<rule->nsons; s++)
-	{
-		m = rule->sons[s].tag;
-		boundaryelement = 0;
-		for (i=0; i<m; i++)
-			if ((rule->sons[s].outer[i])&&(Sides[rule->sons[s].nb[i]]!=NULL))
-			{
-				boundaryelement = 1;
-				break;
-			}
-		if (boundaryelement)
-			theSon = CreateBoundaryElement(theGrid,NULL,m);
-		else
-			theSon = CreateInnerElement(theGrid,NULL,m);
-		if (theSon==NULL) return(1);
-		SET_SON(theElement,s,theSon);
-		SETECLASS(theSon,rule->class);
-		/*if (rule->class==copy) SETLEVEL(theSon,LEVEL(theElement));*/
-		SETTAG(theSon,m);
-		SET_EFATHER(theSon,theElement);
-	}
-	SETNSONS(theElement,rule->nsons);
-	
-	/* connect elements */
-	for (s=0; s<rule->nsons; s++)
-	{
-		m = rule->sons[s].tag;
-		theSon = SON(theElement,s);
-		for (i=0; i<m; i++)
-		{
-			SET_CORNER(theSon,i,Nodes[rule->sons[s].corners[i]]);
-			if (rule->sons[s].outer[i])
-			{
-				if (Neighbors[rule->sons[s].nb[i]]!=NULL)
-				{
-					SET_NBELEM(theSon,i,Neighbors[rule->sons[s].nb[i]]);
-					*(BackPtrs[rule->sons[s].nb[i]]) = theSon;
-				}
-				if (OBJT(theSon)==BEOBJ)
-					SET_SIDE(theSon,i,Sides[rule->sons[s].nb[i]]);
-			}
-			else
-				SET_NBELEM(theSon,i,SON(theElement,rule->sons[s].nb[i]));
-		}
-	}
-
-	/* set modified flags of nodes */
-	for (i=0; i<9; i++)
-		if (Nodes[i]!=NULL)
-			SETMODIFIED(Nodes[i],1);
-
-	/* mark element as changed and set modified flag in grid record */
-	SETTHEFLAG(theElement,1);
-	SETMODIFIED(theGrid,1);
-	
-	return(0);
-}
-
-
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RefineGrid													*/
-/*																			*/
-/* Purpose:   refine one level of the grid									*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level to refine							*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-
-static INT exitFlag=0;
-
-static INT RefineGrid (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	ElementContext theContext;
-	GRID *fineGrid;
-	NODE *theNode;
-	
-	fineGrid = theGrid->finer;
-	if (fineGrid==NULL) return(1);
-	
-	/* refine elements */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (REFINE(theElement)!=MARK(theElement))
-		{
-			GetCurrentContext(theElement,&theContext);
-			UnrefineElement(fineGrid,theElement,&theContext);
-			if (UpdateContext(fineGrid,theElement,&theContext)!=0) return(1);
-			if (RefineElement(fineGrid,theElement,&theContext)!=0) return(1);
-			SETREFINE(theElement,MARK(theElement));
-		}
-	}
-
-	/* reset MARK flags */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		SETMARK(theElement,0);
-
-	/* set node class on next level */
-	for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-		if (SONNODE(theNode)!=NULL)
-		{
-			SETCLASS(SONNODE(theNode),NCLASS(theNode));
-			if (NCLASS(theNode)>=2) TOPNODE(MYVERTEX(theNode)) = SONNODE(theNode);
-		}
-	
-	return(0);
-}
-			
-
-/****************************************************************************/
-/*D
-   RefineMultiGrid - Refine whole multigrid structure						
-
-   SYNOPSIS:
-   INT RefineMultiGrid (MULTIGRID *theMG, INT flag);
-
-   PARAMETERS:
-.  theMG - multigrid to refine
-.  flag - refinement mode, see below
-.  direction - element evaluation direction
-
-   DESCRIPTION:
-   This function refines whole multigrid structure. It reads the
-   refinement tags set with the 'MarkForRefinement' function and
-   produces a consistent triangulation where at least all the
-   selected elements are refined.
-
-   The flag parameter can have two values. 'GM_REFINE_TRULY_LOCAL' refines
-   in such a way that a grid level is not required to cover the whole
-   domain. In this case the memory and run-time requirements are proportional
-   to the number of elements. If 'flag' is set to 'GM_COPY_ALL' then
-   elements not selected for refinement are copied to the next finer level,
-   i.e. each grid level covers the whole domain but memory and run-time
-   requirements are only optimal if there is a geometric growth in the
-   number of refined elements.
-
-   The direction is not considered.
-
-   RETURN VALUE:
-   INT
-.n    GM_OK when ok 
-.n    GM_ERROR when out of memory, but data structure as before
-.n    GM_FATAL when fatal memory error, data structure corrupted				  
-D*/
-/****************************************************************************/
-
-INT RefineMultiGrid (MULTIGRID *theMG, INT flag, EVECTOR *direction)
-{
-	INT j,k,r;
-	INT newlevel;
-	NODE *theNode;
-	GRID *theGrid,*theFineGrid;
-	ELEMENT *theElement;
-	
-	rFlag=flag; 	/* set global variable */
-	
-	j = theMG->topLevel;
-
-	for (k=0; k<=j; k++)
-		for (theElement=theMG->grids[k]->elements; theElement!=NULL; theElement=SUCCE(theElement))
-			SETTHEFLAG(theElement,0);
-
-#ifdef __version3__
-	PrepareAlgebraModification(theMG);
-#endif
-
-	/* compute modification of coarser levels from above */
-	for (k=j; k>0; k--)
-	{
-		theGrid = theMG->grids[k];
-		
-		/* make refinement rules consistent */
-		if (CloseGrid(theGrid)<0)
-		{
-			PrintErrorMessage('E',"RefineMultiGrid","error in occured in CloseGrid");
-			return(GM_ERROR);
-		}
-		
-		/* restrict marks on irregular elements and handle COARSEN flags */
-		RestrictMarks(theMG->grids[k-1]);
-	}
-
-	newlevel = 0;
-	for (k=0; k<=j; k++)
-	{
-		theGrid = GRID_ON_LEVEL(theMG,k);
-		if (k<j) theFineGrid = GRID_ON_LEVEL(theMG,k+1); else theFineGrid = NULL;
-
-		/* reset some flags */
-		SETMODIFIED(theGrid,0);
-		for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode)) SETMODIFIED(theNode,0);
-		
-		/* leave only regular marks */
-		for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		{
-			if ((ECLASS(theElement)==REGULAR_CLASS)&&(Rules[MARK(theElement)].class==REGULAR_CLASS)) continue;
-			SETMARK(theElement,0);
-		}
-		
-		/* determine regular and irregular elements on next level */
-		if ((r = CloseGrid(theGrid))<0)
-		{
-			PrintErrorMessage('E',"RefineMultiGrid","error occured in CloseGrid");
-			return(GM_FATAL);
-		}
-		
-		/* determine copies on next level		*/
-		/* this involves algebra in version 3 ! */
-#ifdef __version23__
-		ComputeCopies(theGrid);
-#endif
-#ifdef __version3__
-		Version3_ComputeCopies(theGrid);
-#endif
-
-#ifdef __version3__
-		/* dispose connections that may be changed on next level, this is determined */
-		/* by the neighborhood of elements were MARK != REFINE. 					 */
-		/* This will leave some flags where to rebuild connections later			 */
-		if (k<j)
-		{
-			for (theElement=FIRSTELEMENT(theFineGrid); theElement!=NULL; theElement=SUCCE(theElement))
-			{
-				assert (EFATHER(theElement) != NULL);
-				if (REFINE(EFATHER(theElement))!=MARK(EFATHER(theElement))) 
-					if (DisposeConnectionsInNeighborhood(theFineGrid,theElement)!=GM_OK)
-						return(GM_FATAL);
-			}
-		}
-#endif
-
-		/* create a new grid level, if at least one element is refined on finest level */		
-		if ((r>0)&&(k==j))
-		{
-			newlevel = 1;
-			if (CreateNewLevel(theMG)==NULL)
-			{
-				PrintErrorMessage('E',"RefineMultiGrid","could not create new level");
-				return(GM_FATAL);
-			}
-			theFineGrid = GRID_ON_LEVEL(theMG,j+1);
-		}
-
-		/* now really manipulate the next finer level */		
-		if ((k<j)||(newlevel))
-			if (RefineGrid(theGrid)!=0) return(GM_FATAL);
-
-#ifdef __version3__
-		if ((k<j)||(newlevel))
-		  {
-			/* now rebuild connections in neighborhood of elements which have EBUILDCON set */
-			/* This flag has been set either by GridDisposeConnection or by CreateElement	*/
-			if (GridCreateConnection(theFineGrid)) return (GM_FATAL);
-			/* and compute the vector classes on the new (or changed) level */
-
-			if (rFlag==GM_COPY_ALL)
-			  for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-				SeedVectorClasses(theElement);
-			else
-			  {
-				ClearVectorClasses(theFineGrid);
-				for (theElement=theFineGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-				  if (ECLASS(theElement)>=IRREGULAR_CLASS) SeedVectorClasses(theElement);
-				PropagateVectorClasses(theFineGrid);
-			  }
-		  }
-#endif
-	}
-
-	DisposeTopLevel(theMG); /* is only done when highest level is empty !*/
-	
-	return(GM_OK);
-}
-
-
-/****************************************************************************/
-/*D
-   MarkForRefinement - Mark an element for refinement											
-
-   SYNOPSIS:
-   INT MarkForRefinement (ELEMENT *theElement, INT rule, INT side);
-
-   PARAMETERS:
-.  theElement - element to be tagged for refinement
-.  rule - refinement rule
-.  side - side, if rule is not invariant under rotation
-  
-   DESCRIPTION:
-   This function marks an element for refinement. Only elements where
-   'EstimateHere' is true may be marked for refinement. Rule numbers
-   are declared in the 'REFINEMENT' page.
-  
-   RETURN VALUE:
-   INT
-.n    0 if ok
-.n    >0 if wrong rule.																	
-D*/
-/****************************************************************************/
-
-INT MarkForRefinement (ELEMENT *theElement, INT rule, INT side)
-{
-	INT n;
-	
-	if (!EstimateHere(theElement))
-		return (GM_ERROR);
-	
-	n = TAG(theElement);
-	SETCOARSEN(theElement,0);
-	
-	if (n==TRIANGLE)
-	{
-		switch (rule)
-		{
-			case UNREFINE:
-				SETCOARSEN(theElement,1);
-				SETMARK(theElement,BasicRules[NO_REF].offset);
-				break;
-				
-			case NO_REFINEMENT:
-				SETMARK(theElement,BasicRules[NO_REF].offset);
-				break;
-			
-			case COPY:
-				SETMARK(theElement,BasicRules[T_COPY].classOffset[REGULAR_CLASS]);
-				break;
-			
-			case RED:
-				SETMARK(theElement,BasicRules[T_RED].classOffset[REGULAR_CLASS]);
-				break;
-			
-			case BISECTION_3:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[T_BISECT_3].classOffset[REGULAR_CLASS]+BasicRules[T_BISECT_3].variantOffset[side%3]);
-				break;
-			
-			case BISECTION_1:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[T_BISECT_1].classOffset[REGULAR_CLASS]+BasicRules[T_BISECT_1].variantOffset[side%3]);
-				break;
-			
-			case BISECTION_2_Q:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[T_BISECT_2_Q].classOffset[REGULAR_CLASS]+BasicRules[T_BISECT_2_Q].variantOffset[side%3]);
-				break;
-			
-			case BISECTION_2_T1:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[T_BISECT_2_T1].classOffset[REGULAR_CLASS]+BasicRules[T_BISECT_2_T1].variantOffset[side%3]);
-				break;
-			
-			case BISECTION_2_T2:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[T_BISECT_2_T2].classOffset[REGULAR_CLASS]+BasicRules[T_BISECT_2_T2].variantOffset[side%3]);
-				break;
-			
-			default:
-				return(GM_ERROR);
-		}
-	}
-	else
-	{
-		switch (rule)
-		{
-			case UNREFINE:
-				SETCOARSEN(theElement,1);
-				SETMARK(theElement,BasicRules[NO_REF].offset);
-				break;
-
-			case NO_REFINEMENT:
-				SETMARK(theElement,BasicRules[NO_REF].offset);
-				break;
-			
-			case COPY:
-				SETMARK(theElement,BasicRules[Q_COPY].classOffset[REGULAR_CLASS]);
-				break;
-			
-			case RED:
-				SETMARK(theElement,BasicRules[Q_RED].classOffset[REGULAR_CLASS]);
-				break;
-			
-			case BLUE:
-				if (side<0) return (GM_ERROR);
-				SETMARK(theElement,BasicRules[Q_BLUE].classOffset[REGULAR_CLASS]+BasicRules[Q_BLUE].variantOffset[side%2]);
-				break;
-			
-			default:
-				return(GM_ERROR);
-		}
-	}
-
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*D
-   EstimateHere	- Determines elements allowed for refinement 
-
-   SYNOPSIS:
-   INT EstimateHere (ELEMENT *theElement);
-
-   PARAMETERS:
-.  theElement - element to be checked
-
-   DESCRIPTION:
-   This function returns true (1) when element can be tagged for refinement.
-
-   RETURN VALUE:
-   INT
-.n      0, do not tag element. 
-.n      1, element can be tagged for refinement
-D*/
-/****************************************************************************/
-
-INT EstimateHere (ELEMENT *theElement)
-{
-	return(REFINE(theElement)==NO_REF);
-}
-
-/****************************************************************************/
-/*D
-   GetRefinementMark - Get rule and variant of refinement
-
-   SYNOPSIS:
-   INT GetRefinementMark (const ELEMENT *theElement, INT *rule, INT *side);
-
-   PARAMETERS:
-.  theElement - element to be questioned				   
-.  rule - to be filled with current refinement rule
-.  side - to be filled with side, if rule is not invariant under rotation	
-
-   DESCRIPTION:
-   This function retieves rule and side of refinement.
-
-   RETURN VALUE:
-   INT
-.n    GM_RULE_WITH_ORIENTATION if side information valid 
-.n    GM_RULE_WITHOUT_ORIENTATION if rule without orientation.
-D*/
-/****************************************************************************/
-
-INT GetRefinementMark (const ELEMENT *theElement, INT *rule, INT *side)
-{
-	switch (Rules[MARK(theElement)].rule)
-	{
-		case NO_REF:
-			*rule=NO_REFINEMENT;
-			if (COARSEN(theElement)) *rule = UNREFINE;
-			break;
-		case T_COPY: 			*rule=COPY; break;
-		case T_RED: 			*rule=RED; break;
-		case T_BISECT_1: 		*rule=BISECTION_1; break;
-		case T_BISECT_2_T1:	 	*rule=BISECTION_2_T1;  break;
-		case T_BISECT_2_T2: 	*rule=BISECTION_2_T2;  break;
-		case T_BISECT_2_Q: 		*rule=BISECTION_2_Q; break;
-		case T_BISECT_3: 		*rule=BISECTION_3; break;
-
-		case Q_COPY: 			*rule=COPY; break;
-		case Q_RED: 			*rule=RED; break;
-		case Q_CLOSE_1: 		*rule=NO_REFINEMENT;  break;
-		case Q_BLUE: 			*rule=BLUE; break;
-		case Q_CLOSE_2: 		*rule=NO_REFINEMENT;   break;
-		case Q_CLOSE_3: 		*rule=NO_REFINEMENT;   break;
-		default: 				*rule=NO_REFINEMENT;  break;
-	}
-	if(Rules[MARK(theElement)].class == REGULAR_CLASS)
-	{
-		*side=Rules[MARK(theElement)].variant;
-		return(GM_RULE_WITH_ORIENTATION);
-	}
-	*side=0;
-	return(GM_RULE_WITHOUT_ORIENTATION);
-}
-
-/****************************************************************************/
-/*D
-   GetSons - Get pointers to all sons of an element
-
-   SYNOPSIS:
-   INT GetSons (ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
-
-   PARAMETERS:
-.  theElement - pointer to an element
-.  SonList - array of pointers to elements where result is placed
-
-   DESCRIPTION:
-   This function fills a user supplied array of pointers with all
-   sons of a given element. Use this function for access to sons,
-   since it is available in 2D and 3D. In 3D the sons are not directly
-   accessible!
-
-   RETURN VALUE:
-   INT
-.n     0 when ok 
-.n     1 when error occured.
-D*/
-/****************************************************************************/
-
-INT GetSons (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS])
-{
-	INT i;
-	
-	for (i=0; i<NSONS(theElement); i++) SonList[i] = SON(theElement,i);
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*D
-   GetFineNodeOnEdge - Get node in fine grid generated on edge  
-
-   SYNOPSIS:
-   NODE *GetFineNodeOnEdge (const ELEMENT *theElement, INT side);
-
-   PARAMETERS:
-.  theElement - pointer to an element
-.  side - side number of element
-
-   DESCRIPTION:
-   This function returns the node in the fine grid that is generated on the
-   edge given by 'side'. 
-
-   `This function is only available in 2D!`
-
-   RETURN VALUE:
-   NODE*
-.n      pointer to node
-.n      NULL if none.									
-D*/
-/****************************************************************************/
-
-NODE *GetFineNodeOnEdge (const ELEMENT *theElement, INT side)
-{
-	INT ref;
-	
-	ref = REFINE(theElement);
-	
-	if (!Rules[ref].pattern[side])
-		return (NULL);
-	
-	return (CORNER(SON(theElement,Rules[ref].midSon[side]),Rules[ref].midCorner[side]));
-}
-
-/****************************************************************************/
-/*
-   InitUgRefine	- Initialize rules from basic rules 
-
-   SYNOPSIS:
-   INT InitRefine2d (void);
-
-   PARAMETERS:
-.  void
-
-   DESCRIPTION:
-   This function initialize rules from basic rules.
-
-   RETURN VALUE:
-   void
-*/
-/****************************************************************************/
-
-INT InitRefine2d (void)
-{
-	REFRULE *rule;
-	basicRule *bRule;
-	SON_DATA *bSond,*sond;
-	INT i,j,k,l,m,n,s,BRule,Rule,Side;
-	INT class,followRule,followVariant,cPattern,cPattern0,nrVar;
-	
-	Rule=0;
-	
-	for (BRule=0; BRule<MAXBASICRULES; BRule++)
-	{
-		bRule=&(BasicRules[BRule]);
-		
-		/* compute offsets */
-		bRule->offset=Rule;
-		
-		nrVar=0;
-		for (k=0; k<4; k++)
-		{
-			if (bRule->variants[k])
-			{
-				if (k>nrVar)
-				{
-					PrintErrorMessage('E',"InitGM","variants are not consecutively ordered");
-					return(__LINE__);
-				}
-				
-				bRule->variantOffset[k]=k;
-				nrVar++;
-			}
-			else
-				bRule->variantOffset[k]=k%nrVar;
-		}
-		
-		/* go through all classes for which bRule exists */
-		for (class=0; class<3; class++)
-		{
-			bRule->classOffset[class]=bRule->offset;		/* smallest possible damage if not existent */
-			if (bRule->classes[class])
-			{
-				bRule->classOffset[class]=Rule;
-				/* go through all variants that exist */
-				for (k=0; k<4; k++)
-				if (bRule->variants[k])
-				{
-					/* generate corresponding rule */
-					if (Rule==MAXRULES)
-					{
-						PrintErrorMessage('E',"InitGM","too many rules to be generated");
-						return(__LINE__);
-					}
-					else
-						rule=&(Rules[Rule++]);
-					
-					n=rule->tag=bRule->tag;
-					rule->rule=BRule;
-					rule->class=class;
-					rule->variant=k;
-					rule->nsons=bRule->nsons;
-					
-					if (n==TRIANGLE)
-						rule->pattern[3]=0;
-					
-					cPattern=0;
-					for (Side=n-1; Side>=0; Side--)
-						cPattern=2*cPattern+(rule->pattern[Side]=bRule->pattern[(Side-k+n)%n]);
-					
-					rule->condensedPattern=cPattern;
-					
-					/* now loop through the sons */
-					for (l=0; l<4; l++)
-					{
-						bSond=&(bRule->sons[l]);
-						sond=&(rule->sons[l]);
-						if (l<rule->nsons)
-						{
-							sond->tag=bSond->tag;
-							
-							if (sond->tag==3)
-								sond->corners[3]=sond->outer[3]=sond->nb[3]=0;
-							else
-								if (sond->tag!=4)
-								{
-									PrintErrorMessage('E',"InitGM","false tag for son");
-									return(__LINE__);
-								}
-							
-							for (Side=0; Side<sond->tag; Side++)
-							{
-								if (bSond->corners[Side]==8)
-									sond->corners[Side]=8;
-								else
-									sond->corners[Side]=(bSond->corners[Side] & 4) + ((bSond->corners[Side] & 3) + k) %n;
-								
-								if ((sond->outer[Side]=bSond->outer[Side])==0)
-								{
-									/* inner side for refinement */
-									sond->nb[Side]=bSond->nb[Side];
-								}
-								else
-								{
-									/* outer side for refinement */
-									sond->nb[Side]=(bSond->nb[Side]+2*k)%(2*n);
-								}
-							}
-						}
-						else
-						{
-							if (bSond->tag!=0)
-							{
-								PrintErrorMessage('E',"InitGM","inconsistency with nsons");
-								return(__LINE__);
-							}
-							sond->tag=0;
-							for (Side=0; Side<4; Side++)
-								sond->corners[Side]=sond->outer[Side]=sond->nb[Side]=0;
-						}
-					}
-					
-					/* compute data for access of the centerpoints of the outer edges */
-					for (Side=0; Side<5; Side++)
-					{
-						m = Side+4;
-						rule->midSon[Side] = -1;
-						rule->midCorner[Side] = -1;
-						for (s=0; s<rule->nsons; s++)
-						{
-							for (i=0; i<rule->sons[s].tag; i++)
-								if (rule->sons[s].corners[i]==m)
-								{
-									rule->midSon[Side] = s;
-									rule->midCorner[Side] = i;
-									break;
-								}
-							if (rule->midSon[Side]>=0) break;
-						}
-					}
-					
-					/* compute data for access to the neighbors on the next level */
-					for (Side=0; Side<8; Side++)
-					{
-						rule->nbSon[Side] = -1;
-						rule->nbSide[Side] = -1;
-						for (s=0; s<rule->nsons; s++)
-						{
-							for (j=0; j<rule->sons[s].tag; j++)
-								if ((rule->sons[s].outer[j])&&(rule->sons[s].nb[j]==Side))
-								{
-									rule->nbSon[Side]  = s;
-									rule->nbSide[Side] = j;
-									break;
-								}
-							if (rule->nbSon[Side]>=0) break;
-						}
-					}
-					
-				}
-			}
-		}
-	}
-	
-	/* set size of rules field */
-	MaxRules=Rule;
-	
-	/* generate the follow rules */
-	for (Rule=0; Rule<MaxRules; Rule++)
-	{
-		rule=&(Rules[Rule]);
-		BRule=rule->rule;
-		bRule=&(BasicRules[BRule]);
-		n=rule->tag;
-		class=rule->class;
-		k=rule->variant;
-		
-		if (n==TRIANGLE)
-		{
-			for (cPattern=0; cPattern<8; cPattern++)
-			{
-				/* transform to 0-orientation */
-				cPattern0=(cPattern>>k) + ((cPattern<<(n-k))&0x00000007);
-				
-				if (bRule->followRule[cPattern0]==-1)
-				{
-					followRule=StandardFollowRule_T[cPattern0];
-					followVariant=StandardFollowVariant_T[cPattern0];
-				}
-				else
-				{
-					followRule=bRule->followRule[cPattern0];
-					followVariant=bRule->followVariant[cPattern0];
-				}
-				
-				/* transform back to Rules */
-				rule->followRule[cPattern]=BasicRules[followRule].classOffset[class]+BasicRules[followRule].variantOffset[(followVariant+k)%n];
-			}
-			
-			for (cPattern=8; cPattern<16; cPattern++)
-				rule->followRule[cPattern]=0;	/* should never be needed */
-		}
-		else
-		{
-			for (cPattern=0; cPattern<16; cPattern++)
-			{
-				/* transform to 0-orientation */
-				cPattern0=(cPattern>>k) + ((cPattern<<(n-k))&0x0000000f);
-				
-				if (bRule->followRule[cPattern0]==-1)
-				{
-					followRule=StandardFollowRule_Q[cPattern0];
-					followVariant=StandardFollowVariant_Q[cPattern0];
-				}
-				else
-				{
-					followRule=bRule->followRule[cPattern0];
-					followVariant=bRule->followVariant[cPattern0];
-				}
-				
-				/* transform back to Rules */
-				rule->followRule[cPattern]=BasicRules[followRule].classOffset[class]+BasicRules[followRule].variantOffset[(followVariant+k)%n];
-			}
-		}
-	}
-	
-	return(GM_OK);
-}
-
diff -ruN ug-orig/gm/ugrefine2d.h ug-patched/gm/ugrefine2d.h
--- ug-orig/gm/ugrefine2d.h	1995-11-15 19:47:43.000000000 +0100
+++ ug-patched/gm/ugrefine2d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,78 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugrefine2d.h													*/
-/*																			*/
-/* Purpose:   unstructured grid refinement header file						*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   09.03.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __UGREFINE2D__
-#define __UGREFINE2D__
-
-#include "compiler.h"
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* macros																	*/
-/*																			*/
-/****************************************************************************/
-
-#define LEAFELEM(e) 	 (NSONS(e)==0)
-#define LEAFNODE(n) 	 (SONNODE(n)==NULL)
-#define REGULAR(e)		 (ECLASS(e)==REGULAR_CLASS)
-#define IRREGULAR(e)	 (ECLASS(e)==IRREGULAR_CLASS)
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-INT			 InitRefine2d 		(void);
-
-#endif
diff -ruN ug-orig/gm/ugrefine3d.c ug-patched/gm/ugrefine3d.c
--- ug-orig/gm/ugrefine3d.c	2005-08-11 14:14:59.000000000 +0200
+++ ug-patched/gm/ugrefine3d.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,2561 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugrefine3d.c													*/
-/*																			*/
-/* Purpose:   unstructured 3d-grid refinement (tree version)				*/
-/*																			*/
-/* Author:	  Juergen Bey													*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 294										*/
-/*			  6900 Heidelberg												*/
-/*																			*/
-/*			  Klaus Johannsen												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70550 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de						    	*/
-/*																			*/
-/* History:   24.06.92 begin, ug3 version 1.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef __MPW32__
-#pragma segment ugrefine
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <math.h>
-
-#include "heaps.h"
-#include "ugenv.h"
-
-#include "devices.h"
-
-#include "compiler.h"
-#include "defaults.h"
-#include "fileopen.h"
-#include "switch.h"
-#include "gm.h"
-#include "GenerateRules.h"
-#include "misc.h"
-#include "evm.h"
-#include "ugm.h"
-#include "ugm3d.h"
-#include "algebra.h"
-#include "ugrefine.h"
-#include "ugrefine3d.h"
-#include "simplex.h"
-#include "shapes.h"
-#include "shapes3d.h"
-#include "cw.h"
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define RESOLUTION			20		/* resolution for creating boundary midn*/
-#define CENTER_NODE 		10		/* position in struct ELEMENTCONTEXT whe*/
-									/* ptr to center node is stored 		*/
-
-#define MINVNCLASS		2			/* determines copies, dep. on discr. !	*/
-
-#define INNER_EDGE			1
-#define SIDE_EDGE			2
-#define HALF_FATHER_EDGE	3
-#define FATHER_EDGE 		4
-
-/* macros concerning the MARK/REFINE flags */
-#define REF_TYPE_CHANGES(e) 		((REFINE(e)!=MARK(e)) || (REFINECLASS(e)!=MARKCLASS(e)))
-#define MARK_BISECT_EDGE(e,i)		((Rules[MARK(e)].pattern)[i])
-#define REFINE_BISECT_EDGE(e,i) 	((Rules[REFINE(e)].pattern)[i])
-
-/* macros defining best refrule, specify exactly one of them !! */
-/*#define __SHORTEST_INTERIOR_EDGE__*/
-/*#define __MIDDLE_INTERIOR_EDGE__*/
-#define __LONGEST_INTERIOR_EDGE__
-
-/****************************************************************************/
-/*																			*/
-/* data structures used in this source file (exported data structures are	*/
-/*		  in the corresponding include file!)								*/
-/*																			*/
-/****************************************************************************/
-
-typedef NODE *ELEMENTCONTEXT[MAX_CORNERS_OF_ELEM+NEWCORNERS];
-
-/****************************************************************************/
-/*																			*/
-/*	the refinement rules													*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* edge type  : INNER_EDGE		 = inner edge of the father 				*/
-/*				SIDE_EDGE		 = inner edge of one side					*/
-/*				HALF_FATHER_EDGE = half an edge of the father element		*/
-/*				FATHER_EDGE 	 = edge of the father itself				*/
-/*																			*/
-/*																			*/
-/****************************************************************************/
-
-REFRULE *Rules;
-static SHORT *PatternToRefrule;
-static FULLREFRULEPTR theFullRefRule;
-static int rFlag=GM_REFINE_TRULY_LOCAL; /* type of refine					*/
-static INT theBFRRDirID;				/* env type for BestFullRefRule		*/
-static ElementVectorProcPtr theDirectionElemEval;
-
-
-/* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/gm/Attic/ugrefine3d.c,v 1.10 2005/08/11 12:14:59 sander Exp $";
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ShowRefRule													*/
-/*																			*/
-/* Purpose:   fill SonList for theElement									*/
-/*																			*/
-/* Param:	  ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]				*/
-/*																			*/
-/* return:	  0: ok 														*/
-/*			  1: error														*/
-/*																			*/
-/****************************************************************************/
-
-static INT PrintEdgeData (struct edgedata theEdgeData)
-{
-	char buffer[128];
-
-	sprintf(buffer,"   type=%d from=%d to=%d side=%d\n",(int)theEdgeData.type
-							   ,(int)theEdgeData.from
-							   ,(int)theEdgeData.to
-							   ,(int)theEdgeData.side);
-	UserWrite(buffer);
-	return(0);	
-}
-
-static INT PrintSonData(struct sondata theSonData)
-{
-	char buffer[128];
-
-	sprintf(buffer,"   corners=%d %d %d %d\n",(int)theSonData.corners[0]
-							 ,(int)theSonData.corners[1]
-							 ,(int)theSonData.corners[2]
-							 ,(int)theSonData.corners[3]);
-	UserWrite(buffer);
-	sprintf(buffer,"   nb=%d %d %d %d\n",(int)theSonData.nb[0]
-						,(int)theSonData.nb[1]
-						,(int)theSonData.nb[2]
-						,(int)theSonData.nb[3]);
-	UserWrite(buffer);
-	UserWrite("\n");
-	return(0);	
-}
-
-INT ShowRefRule (INT nb)
-{
-	char buffer[128];
-	INT i,j;
-	REFRULE *theRule;
-	
-	if (nb>241) return (1);
-	
-	theRule=&(Rules[nb]);
-	
-	/* header */
-	UserWrite("\n");
-	sprintf(buffer,"refrule %d:\n",nb);
-	UserWrite(buffer);
-	
-	/* nsons */
-	sprintf(buffer,"   nsons=%d\n",(int)theRule->nsons);
-	UserWrite(buffer);
-	
-	/* pattern */
-	UserWrite("   pattern=");
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		sprintf(buffer,"%d ",(int)theRule->pattern[i]);
-		UserWrite(buffer);
-	}
-	UserWrite("\n");
-	
-	/* sonandnode */
-	for (i=0; i<NEWCORNERS; i++)
-	{
-		sprintf(buffer,"   sonandnode[%d][0]=%d\n",i,(int)theRule->sonandnode[i][0]);
-		UserWrite(buffer);
-		sprintf(buffer,"             [%d][1]=%d\n",i,(int)theRule->sonandnode[i][1]);
-		UserWrite(buffer);
-	}
-	UserWrite("\n");
-	
-	/* print edge data */
-	UserWrite("edge data\n");
-	for (i=0; i<MAXEDGES; i++)
-		PrintEdgeData(theRule->edges[i]);
-	UserWrite("\n");
-		
-	/* print sondata data */
-	UserWrite("son data\n");
-	for (i=0; i<(int)theRule->nsons; i++)
-		PrintSonData(theRule->sons[i]);
-		
-	return (0);
-}
-
-/****************************************************************************/
-/*
-   GetSons - Fill SonList for theElement
-
-   SYNOPSIS:
-   INT GetSons (ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
-
-   PARAMETERS:
-.  theElement -
-.  SonList[MAX_SONS]
-
-   DESCRIPTION:
-   This function fills SonList for theElement.														
-
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.																		
-*/
-/****************************************************************************/
-
-INT GetSons (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS])
-{
-	REFRULE *theRule;
-	ELEMENT *theSon;
-	int SonID,PathPos;
-	
-	if (theElement==NULL) return (GM_ERROR);
-	
-	for (SonID=0; SonID<SONS_OF_ELEM(theElement); SonID++)
-		SonList[SonID] = NULL;
-	
-	SonList[0] = SON(theElement,0);
-	
-	/* get other sons from path info in rules */
-	theRule = &(Rules[REFINE(theElement)]);
-	
-	for (SonID=1; SonID<theRule->nsons; SonID++)
-	{
-		theSon = SonList[0];
-		for (PathPos=0; PathPos<PATHDEPTH(theRule->sons[SonID].path); PathPos++)
-			theSon = NBELEM(theSon,NEXTSIDE(theRule->sons[SonID].path,PathPos));
-		
-		if (theSon==NULL)
-			return (GM_ERROR);
-		
-		SonList[SonID] = theSon;
-	}
-	
-	return (GM_OK);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ComputeCopies 												*/
-/*																			*/
-/* Purpose:   determine copy elements from node classes 					*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  0: ok 														*/
-/*																			*/
-/****************************************************************************/
-
-static int ComputeCopies (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	int i,flag;
-	
-	/* set class of all dofs on next level to 0 */
-	ClearNextVectorClasses(theGrid);
-	
-	/* seed dofs of regularly and irregularly refined elements to 3 */
-	flag = 0;
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if (MARK(theElement)!=NOREFRULE && (MARKCLASS(theElement)==RED || MARKCLASS(theElement)==GREEN))
-		{
-			SeedNextVectorClasses(theElement);
-			flag=1; /* there is at least one element to be refined */
-		}
-
-	/* copy all option or neighborhood */	
-	if (rFlag==GM_COPY_ALL) 
-	{
-		if (flag)
-			for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-				SeedNextVectorClasses(theElement);
-	}
-	else
-	{
-		PropagateNextVectorClasses(theGrid);
-	}
-	
-	/* an element is copied if it has a dof of class 2 and higher */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		if ((MARK(theElement)==NOREFRULE)&&(MaxNextVectorClass(theElement)>=MINVNCLASS))
-		{
-			SETMARK(theElement,COPY_REFRULE);
-			SETMARKCLASS(theElement,YELLOW);
-		}
-
-	return(0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RestrictMarks 												*/
-/*																			*/
-/* Purpose:   restrict refinement marks when going down 					*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void RestrictMarks (GRID *theGrid)
-{
-	ELEMENT *theElement,*SonList[MAX_SONS];
-	EDGE *theEdge;
-	int myClass,sonClass,myRule;
-	int i,j,flag,CondensedPattern;
-	
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (GetSons(theElement,SonList)!=0) return;
-		myRule = REFINE(theElement);
-		sonClass = REFINECLASS (theElement);
-		myClass = ECLASS(theElement);
-		
-		/* if element is not refined anyway */
-		if (myRule==NOREFRULE) continue;
-
-		/* copies always start with no refinement */
-		if (myClass==YELLOW)
-		{
-			SETMARK(theElement,NOREFRULE);
-			continue;
-		}
-		
-		/* irregular elements are marked by estimator */
-		if (myClass==GREEN) continue;
-
-		/* regular elements with GREEN copies are marked by estimator */
-		if (sonClass==YELLOW) continue;
-
-		/* regular elements with GREEN or copy refinement go to no refinement or red refinement */
-		if (sonClass==GREEN || sonClass==YELLOW)
-		{
-			for (i=0; i<NSONS(theElement); i++)
-				if (MARK(SonList[i])>0)
-				{
-					if (MARKCLASS(theElement)==RED)
-					{
-						/* theElement is marked from outside */
-						if (MARK(theElement)!=FULL_REFRULE)
-							SETMARK(theElement,REFINE(theElement));
-					}
-					else
-					{
-						/* theElement is not marked from outside, so find a regular rule being consistent */
-						/* with those neighbors of all sons of theElement which are marked for refine.	  */
-						/* this choice will make sure these markes will not be distroyed.				  */
-						CondensedPattern = Rules[REFINE(theElement)].pat;
-						for (j=0; j<MAX_EDGES_OF_ELEM; j++)
-						{
-							theEdge=GetEdge(CORNER(theElement,CornerOfEdge[j][0]),CORNER(theElement,CornerOfEdge[j][1]));
-							assert (theEdge != NULL);
-							if (MIDNODE(theEdge)==NULL)
-							{
-								theEdge=GetEdge(SONNODE(CORNER(theElement,CornerOfEdge[j][0])),SONNODE(CORNER(theElement,CornerOfEdge[j][1])));
-								assert(theEdge != NULL);
-								if (ADDPATTERN(theEdge))
-									CondensedPattern |= (1<<j);
-							}
-						}
-						SETMARK(theElement,PatternToRefrule[CondensedPattern]);
-						SETMARKCLASS(theElement,RED);
-					}
-					break;
-				}
-			continue;
-		}
-				
-		/* regular elements with regular refinement, are the only ones to coarsen */
-		if (REFINECLASS(theElement) == RED)
-		{
-			SETMARK(theElement,REFINE(theElement));
-			SETMARKCLASS(theElement,REFINECLASS(theElement));
-		}
-		flag = 0;
-		for (i=0; i<NSONS(theElement); i++)
-			if (!COARSEN(SonList[i]))
-			{
-				flag = 1;
-				break;
-			}
-			
-		/* at least one son has no coarsen flag set if flag==1 */
-		if (flag) continue;
-		/* remove refinement */
-		
-		SETMARK(theElement,NOREFRULE);
-		SETCOARSEN(theElement,0);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CheckMemoryRequirements										*/
-/*																			*/
-/* Purpose:   check if there is enough memory for the following refinement	*/
-/*																			*/
-/* Param:	  MULTIGRID *theMG: pointer to multigrid structure with 		*/
-/*								computed refinement 						*/
-/*																			*/
-/* return:	  INT 1: enough memory for the operation						*/
-/*			  INT 0: not enough memory for the operation					*/
-/*																			*/
-/****************************************************************************/
-
-INT CheckMemoryRequirements (MULTIGRID *theMG)
-{
-	return(1);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CreateMidNode 												*/
-/*																			*/
-/* Purpose:   allocate a new node on an edge of an element. Includes vertex */
-/*			  best fit boundary coordinates and local coordinates			*/
-/*			  insert also links to endpoints of the refined edge			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  int edge: edge to refine										*/
-/*			  NODE *after: insert new node after that node					*/
-/*																			*/
-/* return:	  NODE* : pointer to new node									*/
-/*			  NULL	: could not allocate									*/
-/*																			*/
-/****************************************************************************/
-
-static NODE *CreateMidNode (GRID *theGrid,ELEMENT *theElement,int edge,NODE *after)
-{
-	ELEMENTSIDE   *theSide;
-	ELEMENT 	  *BoundaryElement;
-	COORD		   s,smin;
-	COORD		   x[3],r[3], ropt[3], l[2], dl[2], Inverse[9], Matrix[9];
-	COORD_VECTOR   HelpVector;
-	COORD		  *lambda, *lambda1, *lambda2, *cvect;
-	int 		   i,ni0,ni1,iopt;
-	VERTEX		  *theVertex, *v1, *v2;
-	VSEGMENT	  *vs1,*vs2, *vs;
-	NODE		  *theNode;
-	PATCH	  	  *thePatch;
-	
-	/* calculate midpoint of edge */
-	ni0 = CornerOfEdge[edge][0];
-	ni1 = CornerOfEdge[edge][1];
-	v1	= MYVERTEX(CORNER(theElement,ni0));
-	v2	= MYVERTEX(CORNER(theElement,ni1));
-
-	/* calculate physical position of MidNode */
-	V3_LINCOMB(0.5, CVECT(v1), 0.5, CVECT(v2), x);
-	
-	/* check for boundary node */
-	theVertex = NULL;
-	if (OBJT(v1) == BVOBJ && OBJT(v2) == BVOBJ)
-	{
-		/* We now assume, that the edge is on the boundary if and only if	*/
-		/* there is at least one boundary segment containing both vertices. */
-		/* This works if we assume that there is no level 0 element 		*/
-		/* with a boundary side covering more than one boundary segment.	*/
-		/* See also "InsertElementCommand" in "plot3d.c".					*/
-
-		for (vs1=VSEG(v1); vs1!=NULL; vs1=NEXTSEG(vs1))
-		{
-			for (vs2=VSEG(v2); vs2!=NULL; vs2=NEXTSEG(vs2))
-			{
-				if (VS_PATCH(vs1) == VS_PATCH(vs2)) 
-				{
-					if (theVertex == NULL)
-					{
-						theVertex = CreateBoundaryVertex(theGrid,NULL);
-						cvect = CVECT(theVertex);
-					}
-					if (theVertex == NULL) return(NULL);
-					
-					if ((vs = CreateVertexSegment(theGrid,theVertex)) == NULL)
-					{
-						DisposeVertex(theGrid, theVertex);
-						return(NULL);
-					}
-					thePatch = VS_PATCH(vs) = VS_PATCH(vs1);
-	
-					/* find optimal parameters for this segment */
-					lambda1 = PVECT(vs1);
-					lambda2 = PVECT(vs2);
-					lambda	= PVECT(vs);
-					
-					/* test midpoint */
-					lambda[0] = 0.5*(lambda1[0] + lambda2[0]);
-					lambda[1] = 0.5*(lambda1[1] + lambda2[1]);
-					
-					if (Patch_local2global(thePatch,lambda,ropt)) 
-					  return (NULL);
-
-					V3_EUKLIDNORM_OF_DIFF(x,ropt,smin)
-					
-					/* perhaps not the midpoint */
-					if (smin>MAX_PAR_DIST) 
-					{
-						l[0] = lambda1[0];
-						l[1] = lambda1[1];
-					
-						assert (RESOLUTION > 0);
-						dl[0] = (lambda2[0] - lambda1[0])/((COORD) RESOLUTION);
-						dl[1] = (lambda2[1] - lambda1[1])/((COORD) RESOLUTION);
-					
-						for (i=0; i<=RESOLUTION; i++)
-						{
-							if (Patch_local2global(thePatch,l,r)) 
-							  continue;
-							V3_EUKLIDNORM_OF_DIFF(x,r,s)
-							if (s<smin)
-							{
-								smin = s;
-								lambda[0] = l[0];
-								lambda[1] = l[1];
-								V3_COPY(r,ropt);
-							}
-							l[0]+=dl[0];
-							l[1]+=dl[1];
-						}
-					} 
-					
-					/* if it is the first vertex segment found fill in geometric data else compare with other vertex segments */
-					if (NEXTSEG(vs) == NULL)
-					{
-						V3_COPY(ropt,cvect);
-						SETMOVED(theVertex, smin>MAX_PAR_DIST);
-					}
-					else
-					{
-						V3_EUKLIDNORM_OF_DIFF(cvect,ropt,s)	
-						if (s>MAX_PAR_DIST)
-						{
-							DisposeVertex(theGrid,theVertex);
-							UserWrite("two boundary segments with a common edge are not consistent\n");
-							return(NULL);
-						}
-					}
-				}				
-			}
-		}
-	}				
-
-	if (theVertex == NULL)
-	{
-		theVertex = CreateInnerVertex(theGrid,NULL);
-		if (theVertex == NULL) return(NULL);
-		V3_COPY(x,CVECT(theVertex));
-	}
-
-	VFATHER(theVertex) = theElement;
-	SETONEDGE(theVertex,edge);
-	
-	/* create node */
-	theNode = CreateNode(theGrid,after);
-	if (theNode==NULL)
-	{
-		DisposeVertex(theGrid,theVertex);
-		return(NULL);
-	}
-	MYVERTEX(theNode) = theVertex;
-	NFATHER(theNode) = NULL;
-	SETCLASS(theNode,4);
-	
-	/* local coordinates for the reference tetrahedron */
-	if (!MOVED(theVertex))
-	{
-		XI(theVertex)  = 0.5*(TRefCoord[ni0][0]+TRefCoord[ni1][0]);
-		ETA(theVertex) = 0.5*(TRefCoord[ni0][1]+TRefCoord[ni1][1]);
-		NU(theVertex)  = 0.5*(TRefCoord[ni0][2]+TRefCoord[ni1][2]);
-	}
-	else
-	{
-		/* set transformation matrix */
-		V3_SUBTRACT(CVECT(MYVERTEX(CORNER(theElement,1))), CVECT(MYVERTEX(CORNER(theElement,0))), Matrix)
-		V3_SUBTRACT(CVECT(MYVERTEX(CORNER(theElement,2))), CVECT(MYVERTEX(CORNER(theElement,0))), Matrix+3)
-		V3_SUBTRACT(CVECT(MYVERTEX(CORNER(theElement,3))), CVECT(MYVERTEX(CORNER(theElement,0))), Matrix+6)
-		
-		/* Invert it */
-		if (M3_Invert(Inverse, Matrix))
-		{
-			UserWrite("error: cannot create MidNode on edge of the element\n");
-			UserWrite("       the element is degenerated\n");
-			return (NULL);
-		}
-		V3_SUBTRACT(CVECT(theVertex), CVECT(MYVERTEX(CORNER(theElement,0))), HelpVector)
-		M3_TIMES_V3(Inverse,HelpVector,LCVECT(theVertex))
-	}
-
-	return(theNode);	
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  GetCurrentContext 											*/
-/*																			*/
-/* Purpose:   assemble references to objects which interact with the sons	*/
-/*			  of the given element, as indicated by REFINE. 				*/
-/*			  (i)	 corner nodes											*/
-/*			  (ii)	 nodes at midpoints of edges							*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  ELEMENTCONTEXT *theContext: context structure to fill 		*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void GetCurrentContext (ELEMENT *theElement, NODE **theElementContext)
-{
-	ELEMENT *SonList[MAX_SONS];
-	INT i;						
-	REFRULE *rule;
-	
-	if (GetSons(theElement,SonList)!=0) return;
-	
-	/* get nodes, can be NULL */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		theElementContext[i] = SONNODE(CORNER(theElement,i));
-
-	/* get midpoints */
-	rule = &(Rules[REFINE(theElement)]);
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{								
-		if (rule->pattern[i])
-			theElementContext[i+MAX_CORNERS_OF_ELEM] = CORNER(SonList[rule->sonandnode[i][0]],rule->sonandnode[i][1]);
-		else
-			theElementContext[i+MAX_CORNERS_OF_ELEM] = NULL;
-	}
-	
-	/* get center node */
-	if (rule->sonandnode[6][0] == NO_CENTER_NODE)
-		theElementContext[CENTER_NODE] = NULL;
-	else
-		theElementContext[CENTER_NODE] = CORNER(SonList[rule->sonandnode[6][0]],rule->sonandnode[6][1]);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  UpdateContext 												*/
-/*																			*/
-/* Purpose:   assemble references to objects which interact with the sons	*/
-/*			  of the given element, i.e.									*/
-/*			  objects are allocated, kept or deleted as indicated by MARK	*/
-/*			  (i)	 corner nodes											*/
-/*			  (ii)	 nodes at midpoints of edges							*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of the sons of theElement			*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ELEMENTCONTEXT *theContext: context structure to update		*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-
-static INT NodeNeededOnlyFor(NODE *theNode,NODE **theElementContext)
-{
-	LINK *theLink;
-	INT i, found;
-	
-	for (theLink=START(theNode); theLink!=NULL; theLink=NEXT(theLink))
-	{
-		found=0;
-		for (i=0; i<CENTER_NODE; i++)
-			if (NBNODE(theLink)==theElementContext[i])
-				found=1;
-		if (!found)
-			return (0);
-	}
-	
-	return (1);
-}
-
-static int UpdateContext (GRID *theGrid, ELEMENT *theElement, NODE **theElementContext) 
-{
-	NODE *theNode, *CenterNode; 			
-	ELEMENT *theNeighbor,*theSon;			/* neighbor and a son of current elem.	*/
-	EDGE *theEdge;							/* temporary storage for an edge		*/
-	INT i,j,r,Corner0, Corner1,candelete;	/* some integer variables				*/
-	NODE **MidNodes;						/* nodes on refined edges				*/
-	LINK *theLink;							/* scan through nodes neighbor list 	*/
-	NODE *Node0, *Node1;
-	VERTEX *CenterVertex;
-	EDGEDATA *edata;
-	COORD *x, *xi;
-	char buffer[64];
-
-
-	/* allocate corner nodes if necessary */
-	if (MARK(theElement)>0)
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		{
-			theNode = CORNER(theElement,i);
-			if (SONNODE(theNode)==NULL)
-			{
-				SONNODE(theNode) = CreateNode(theGrid,NULL);
-				if (SONNODE(theNode)==NULL) return(1);
-				MYVERTEX(SONNODE(theNode)) = MYVERTEX(theNode);
-				NFATHER(SONNODE(theNode)) = theNode;
-				theElementContext[i] = SONNODE(theNode);
-			}
-		}
-	
-	/* allocate,keep, or delete midpoint nodes */
-	/* allocate,keep, or delete corner/corner edges */
-	MidNodes = theElementContext+MAX_CORNERS_OF_ELEM;
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	{
-		Corner0 = CornerOfEdge[i][0];
-		Corner1 = CornerOfEdge[i][1];
-		if (MARK_BISECT_EDGE(theElement,i))
-		{
-			/* if a corner corner edge exists then delete it */
-			if ((theEdge = GetEdge(theElementContext[Corner0],theElementContext[Corner1]))!=NULL)
-				DisposeEdge(theGrid,theEdge);
-			
-			/* we need a midpoint node */
-			if (MidNodes[i]!=NULL) continue;
-			Node0 = CORNER(theElement,Corner0);
-			Node1 = CORNER(theElement,Corner1);
-			if ((theEdge = GetEdge(Node0,Node1))==NULL)
-			 return (1);
-		MidNodes[i] = MIDNODE(theEdge);
-		if (MidNodes[i] == NULL)
-		{
-			MidNodes[i] = CreateMidNode(theGrid,theElement,i,theElementContext[Corner0]);
-			if (MidNodes[i]==NULL) return(1);
-		MIDNODE(theEdge) = MidNodes[i];
-		if ((theEdge=CreateEdge(theGrid,theElementContext[Corner0],MidNodes[i]))==NULL) return(1);
-		if ((theEdge=CreateEdge(theGrid,theElementContext[Corner1],MidNodes[i]))==NULL) return(1);
-		 }
-		}
-		else
-		{
-			/* if we need a corner corner edge then allocate it */
-			if (MARK(theElement)>0)
-		{
-				if ((theEdge=CreateEdge(theGrid,theElementContext[Corner0],theElementContext[Corner1]))==NULL) return(1);
-		}
-		
-			/* we don't need a midpoint node on that edge, lets see if it can be deleted */
-			if (MidNodes[i]==NULL) continue;
-			candelete = 1;
-
-			/* This midnode can be deleted, if all of it's remaining links */
-			/* are to the endpoints of the father edge. In this case all   */
-			/* elements sharing that edge have been visited.			   */
-			for (theLink=START(MidNodes[i]); theLink!=NULL; theLink=NEXT(theLink))
-				if ((NBNODE(theLink)!=theElementContext[Corner0])&&(NBNODE(theLink)!=theElementContext[Corner1]))
-				{
-					candelete = 0;
-					break;
-				}
-			
-			if (candelete)
-			{
-				DisposeVertex(theGrid,MYVERTEX(MidNodes[i]));
-				DisposeNode(theGrid,MidNodes[i]);
-		theEdge = GetEdge(CORNER(theElement,Corner0),CORNER(theElement,Corner1));
-		MIDNODE(theEdge) = NULL;
-			}
-		}
-	}
-
-	/* delete corner nodes if possible */
-	if (MARK(theElement)==0)
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-			if (theElementContext[i]!=NULL)
-			{
-		if (NodeNeededOnlyFor(theElementContext[i],theElementContext))
-		{
-					DisposeNode(theGrid,theElementContext[i]);
-					SONNODE(CORNER(theElement,i)) = NULL;
-		}
-			}
-	
-	/* allocate/remove center node */
-	if ((theElementContext[CENTER_NODE] != NULL) && (Rules[MARK(theElement)].sonandnode[6][0] == NO_CENTER_NODE))
-	{
-		/* existing center node has to be removed */
-		DisposeVertex(theGrid,MYVERTEX(theElementContext[CENTER_NODE]));
-		DisposeNode(theGrid,theElementContext[CENTER_NODE]);
-		theElementContext[CENTER_NODE] = NULL;
-	}
-	if ((theElementContext[CENTER_NODE] == NULL) && (Rules[MARK(theElement)].sonandnode[6][0] != NO_CENTER_NODE))
-	{
-		/* there is no center node, but we need one: so allocate it */
-		CenterNode = CreateNode(theGrid,NULL);
-		if (CenterNode == NULL) return (1);
-
-		/* allocate center vertex and init local and global position */
-		CenterVertex = CreateInnerVertex(theGrid,NULL); 
-		if (CenterVertex == NULL) return (1);
-		x = CVECT(CenterVertex);
-		xi = LCVECT(CenterVertex);
-		V3_CLEAR(x)
-		V3_CLEAR(xi)
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		{
-			V3_LINCOMB(1.0, x, 1.0, CVECT(MYVERTEX(CORNER(theElement,i))), x);
-			V3_LINCOMB(1.0, xi, 1.0, TRefCoord[i], xi);
-		}
-		V3_SCALE(0.25, x)
-		V3_SCALE(0.25, xi)
-		
-		/* init ptrs */
-		VFATHER(CenterVertex) = theElement;
-		TOPNODE(CenterVertex) = CenterNode;
-		MYVERTEX(CenterNode) = CenterVertex;
-		
-		/* adjust element context */
-		theElementContext[CENTER_NODE] = CenterNode;
-	}
-
-	return(0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  UnrefineElement												*/
-/*																			*/
-/* Purpose:   remove previous refinement of an element						*/
-/*			  (i)	 all interior nodes and edges are deleted				*/
-/*			  (ii)	 sons are deleted and references to sons reset to NULL	*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of sons of theElement				*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ELEMENTCONTEXT *theContext: current context of element		*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static INT UnrefineElement (GRID *theGrid, ELEMENT *theElement, NODE **theElementContext)
-{
-	int i,j,s;
-	EDGE *theEdge;
-	NODE *CenterNode;
-	REFRULE *rule;					/* current refinement rule of theElement*/
-	ELEMENTCONTEXT sonContext;
-	ELEMENT *theSon,*SonList[MAX_SONS];
-	EDGEDATA *edata;
-
-	/* something to do ? */
-	if ((REFINE(theElement)==0)||(theGrid==NULL)) return(0);
-
-	if (GetSons(theElement,SonList)!=0) return(1);
-	
-	for (s=0; s<NSONS(theElement); s++)
-	{
-		theSon = SonList[s];
-		SETMARK(theSon,NOREFRULE);
-		if (REFINE(theSon)>0)
-		{
-				GetCurrentContext(theSon,sonContext);
-				if (UnrefineElement(theGrid->finer,theSon,sonContext)) return (1);
-				UpdateContext(theGrid->finer,theSon,sonContext);
-		}
-	}
-
-	/* remove connections in neighborhood of sons */
-	for (i=0; i<NSONS(theElement); i++)
-		DisposeConnectionsInNeighborhood(theGrid,SonList[i]);
-
-	/* remove son elements */
-	rule = &(Rules[REFINE(theElement)]);
-	for (s=0; s<rule->nsons; s++)
-	{
-		if (DisposeEdgesFromElement(theGrid,SonList[s])) return (1);
-		DisposeElement(theGrid,SonList[s]);
-	}
-
-
-	SETNSONS(theElement,0);
-	SET_SON(theElement,0,NULL);
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MarkForRefinement 											*/
-/*																			*/
-/* Purpose:   mark an element for refinement								*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  INT type: type of refinement mark:							*/
-/*						REGULAR_MARK										*/
-/*																			*/
-/* return:	  INT 1: element has been marked								*/
-/*				  0: element cannot be marked								*/
-/*																			*/
-/****************************************************************************/
-
-INT IsAllowedToRefine (const ELEMENT *theElement)
-{
-	if (REFINECLASS(theElement)==RED) return (FALSE);
-	return (TRUE);
-}
-
-INT MarkForRefinement (ELEMENT *theElement, INT rule, INT side)
-{
-	/* regulary refined elements can not be be marked */
-	if (REFINECLASS(theElement)==RED) return(GM_ERROR);
-	
-	SETCOARSEN(theElement,0);
-	switch(rule)
-	{
-		case (RED):
-			SETMARK(theElement,FULL_REFRULE);
-			SETMARKCLASS(theElement,RED);
-			break;
-		case (COPY):
-			SETMARK(theElement,COPY_REFRULE);
-			SETMARKCLASS(theElement,RED);
-			break;
-		case (NO_REFINEMENT):
-			SETMARK(theElement,NOREFRULE);
-			break;
-		case (UNREFINE):
-			SETMARK(theElement,NOREFRULE);
-			SETCOARSEN(theElement,1);
-			break;
-	}
-
-	return(GM_OK);
-}
-
-/****************************************************************************/
-/*
-   EstimateHere	- Return true (1) when element can be tagged for refinement
-
-   SYNOPSIS:
-   INT EstimateHere (ELEMENT *theElement);
-
-   PARAMETERS:
-.  theElement - element to refine
-
-   DESCRIPTION:
-   This function returns true (1) when element can be tagged for refinement.												
-
-   RETURN VALUE:
-   INT
-.n    false if do not tag element
-.n    true if element can be tagged for refinement.					
-*/
-/****************************************************************************/
-
-INT EstimateHere (ELEMENT *theElement)
-{
-	return(LEAFELEM(theElement));
-}
-
-/****************************************************************************/
-/*																*/
-/* Function:  GetRefinementMark 											*/
-/*																			*/
-/* Purpose:   gets rule and variant of refinement							*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: element to refine						*/
-/*			  int *rule: filled with current refinement rule				*/
-/*			  int *side: filled with side, if rule is oriented				*/
-/*																			*/
-/* return:	  int 0: side information valid 								*/
-/*			  int 1: rule without orientation								*/
-/*																			*/
-/****************************************************************************/
-
-INT GetRefinementMark (const ELEMENT *theElement, INT *rule, INT *side)
-{
-	if (MARK(theElement)==FULL_REFRULE) {*rule=RED; return(GM_RULE_WITHOUT_ORIENTATION);}
-	switch (MARK(theElement))
-	{
-		case NOREFRULE: 
-			*rule=NO_REFINEMENT;
-			if (COARSEN(theElement)) *rule = UNREFINE;
-			break;
-		case COPY_REFRULE: *rule=COPY; break;
-		default: *rule=NO_REFINEMENT;  break;
-	}
-	*side=0;
-	return(GM_RULE_WITHOUT_ORIENTATION);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RefineElement 												*/
-/*																			*/
-/* Purpose:   refine an element in the given context						*/
-/*			  (i)	 corner and midnodes are already allocated				*/
-/*			  (ii)	 edges between corner and midnodes are ok				*/
-/*			  (iii)  create interior nodes and edges						*/
-/*			  (iv)	 create sons and set references to sons 				*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level of sons of theElement				*/
-/*			  ELEMENT *theElement: element to refine						*/
-/*			  ELEMENTCONTEXT *theContext: current context of element		*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-		
-static int RefineElement (GRID *theGrid, ELEMENT *theElement, NODE **theElementContext)
-{
-	INT i,j,l,s,s2,ni,pi,nsi,p,q,side;
-	INT points,ni0,ni1,m;
-	ELEMENT *theSon,*theNeighbor;
-	EDGE *theEdge;
-	ELEMENT *SonList[MAX_SONS],*SonList2[MAX_SONS];
-	ELEMENTSIDE *oldSide,*newSide;
-	VERTEX *myvertex;
-	VSEGMENT *vs;
-	NODE *mynode;
-	COORD *v0,*v1,*v2, vd[3];
-	COORD *x;
-	INT boundaryelement, found;
-	REFRULE *rule, *rule2;
-	EDGEDATA *edata;
-	SONDATA *sdata, *sdata2;
-	
-	/* is something to do ? */
-	if (MARK(theElement)==0) return(0);
-	rule = &(Rules[MARK(theElement)]);
-
-	/* create interior edges */
-	for (s=0; s<MAXEDGES; s++)
-	{
-		edata = &(rule->edges[s]);
-		if (edata->type != INNER_EDGE) continue;
-		if ((theEdge=CreateEdge(theGrid,theElementContext[edata->from], theElementContext[edata->to]))==NULL)
-			return(1);
-	}
-
-	/* create elements */
-	for (s=0; s<rule->nsons; s++)
-	{
-		boundaryelement = 0;
-		if (OBJT(theElement) == BEOBJ)
-			for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-					if ( (side = rule->sons[s].nb[i]) >= FATHER_SIDE_OFFSET )  /* exterior side */
-						if (SIDE(theElement,side-FATHER_SIDE_OFFSET)!=NULL) 	/* at the boundary */
-							{
-								boundaryelement = 1;
-								break;
-							}
-		if (boundaryelement)
-				theSon = CreateBoundaryElement(theGrid,NULL,TETRAHEDRON);
-		else
-				theSon = CreateInnerElement(theGrid,NULL,TETRAHEDRON);
-		if (theSon==NULL) return(1);
-
-		/* fill in son data */
-		SonList[s] = theSon;
-		SETECLASS(theSon,MARKCLASS(theElement));
-		SET_EFATHER(theSon,theElement);
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-			SET_CORNER(theSon,i,theElementContext[rule->sons[s].corners[i]]);
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-			for (j=i+1; j<MAX_CORNERS_OF_ELEM; j++)
-		{
-			theEdge = CreateEdge(theGrid,CORNER(theSon,i),CORNER(theSon,j));
-			assert(theEdge!=NULL);
-			if (NO_OF_ELEM(theEdge)<NO_OF_ELEM_MAX-1)
-				INC_NO_OF_ELEM(theEdge);
-			else
-				return (1);
-		}
-	}
-	SETNSONS(theElement,rule->nsons);
-	SET_SON(theElement,0,SonList[0]);
-	
-		/* create element sides at the boundary */
-		if (OBJT(theElement)==BEOBJ)
-			for( s=0; s<rule->nsons; s++ )
-			{
-					if (OBJT(SonList[s]) != BEOBJ) continue;
-					for (j=0; j<MAX_SIDES_OF_ELEM; j++)
-					{
-						SET_SIDE(SonList[s],j,NULL);
-						if ((side = rule->sons[s].nb[j]) < FATHER_SIDE_OFFSET) continue;
-						side -= FATHER_SIDE_OFFSET;
-						if ((oldSide = SIDE(theElement,side)) == NULL) continue;
-
-						newSide = CreateElementSide(theGrid);
-						if (newSide==NULL) return(1);
-						SET_SIDE(SonList[s],j,newSide);
-						ES_PATCH(newSide) = ES_PATCH(oldSide);
-		
-						for (i=0; i<MAX_CORNERS_OF_SIDE; i++)
-						{
-								ni = CornerOfSide[j][i];		  /* node index of son	 */
-								pi = rule->sons[s].corners[ni];   /* point in theElement */
-
-								if (pi<MAX_CORNERS_OF_ELEM) /* a corner of theElement */
-								{
-									nsi = CornerOfSideInv[side][pi]; /* position of corner in side numeration */
-									assert(nsi != -1);
-									PARAM(newSide,i,0) = PARAM(oldSide,nsi,0);
-									PARAM(newSide,i,1) = PARAM(oldSide,nsi,1);
-								}
-								else /* a midpoint of an edge of theElement */
-								{
-									myvertex = MYVERTEX(theElementContext[pi]);
-									assert (OBJT(myvertex) == BVOBJ);
-						assert (VSEG(myvertex) != NULL);
-						
-									/* find common boundary segment */
-									for( vs=VSEG(myvertex); vs!=NULL; vs = NEXTSEG(vs) )
-									{
-											if (VS_PATCH(vs) == ES_PATCH(oldSide)) break;
-									}
-									assert(vs!=NULL);
-									PARAM(newSide,i,0) =  LAMBDA(vs,0);
-									PARAM(newSide,i,1) =  LAMBDA(vs,1);
-								}
-						}
-					}
-			}
-	
-		/* connect elements */
-		for (s=0; s<rule->nsons; s++)
-		{
-			sdata = &(rule->sons[s]);
-			for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-			{
-					SET_NBELEM(SonList[s],i,NULL);
-
-					/* an interior triangle face */
-					if ( (side = sdata->nb[i]) < FATHER_SIDE_OFFSET )
-					{
-						SET_NBELEM(SonList[s],i,SonList[side]);
-				
-				/* dispose doubled side vectors if */
-				#ifdef __SIDEDATA__
-					for (l=0; l<MAX_SIDES_OF_ELEM; l++)
-						if (rule->sons[side].nb[l]==s)
-							break;
-					if (DisposeDoubledSideVector(theGrid,SonList[s],i,SonList[side],l))
-						return (1);
-				#endif
-						continue;
-					}
-
-					/* the boundary case */
-					if ((OBJT(SonList[s]) == BEOBJ) && (SIDE(SonList[s],i) != NULL)) continue;
-
-					/* check, if neighbor has been refined */
-					side -= FATHER_SIDE_OFFSET;
-					theNeighbor = NBELEM(theElement,side);
-					if(theNeighbor==NULL) continue;
-			
-				if (REF_TYPE_CHANGES(theNeighbor) || (REFINE(theNeighbor) == 0 ))
-						continue;
-
-					for (l=0; l<MAX_SIDES_OF_ELEM; l++) 
-				if (NBELEM(theNeighbor,l) == theElement)
-					break;
-			assert(l<MAX_SIDES_OF_ELEM);			
-			
-					rule2 = &(Rules[REFINE(theNeighbor)]);
-					found = 0;
-			if (GetSons(theNeighbor,SonList2)!=0)
-				return (1);
-					for (s2=0; s2<rule2->nsons; s2++)
-					{
-						sdata2 = &(rule2->sons[s2]);
-						for (j=0; j<MAX_SIDES_OF_ELEM; j++)
-						{
-								if (sdata2->nb[j] != FATHER_SIDE_OFFSET+l) continue;
-								points=0;
-								for (p=0; p<MAX_CORNERS_OF_SIDE; p++)
-									for (q=0; q<MAX_CORNERS_OF_SIDE; q++)
-											if (CORNER(SonList[s],CornerOfSide[i][p]) == CORNER(SonList2[s2],CornerOfSide[j][q]))
-											{
-												points |= ((1<<p) + (8<<q));
-												break;
-											}
-							if (points == 63)	 /* neighbor found */
-								{
-						/* adjust pointers */
-									SET_NBELEM(SonList[s],i,SonList2[s2]);
-									SET_NBELEM(SonList2[s2],j,SonList[s]);
-						
-						/* dispose doubled side vectors if */
-						#ifdef __SIDEDATA__
-							if (DisposeDoubledSideVector(theGrid,SonList[s],i,SonList2[s2],j))
-								return (1);
-						#endif
-						
-									found=1;
-									break;
-								}
-						}
-						if (found) break;
-					}
-			assert (found==1);
-			}
-		}
-	
-		return(0);
-}
-			
-
-/****************************************************************************/
-/*																			*/
-/* Function:  RefineGrid													*/
-/*																			*/
-/* Purpose:   refine one level of the grid									*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid level to refine							*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: fatal memory error 									*/
-/*																			*/
-/****************************************************************************/
-
-static int RefineGrid (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	ELEMENTCONTEXT theContext;
-	GRID *fineGrid;
-	NODE *theNode;
-	
-	fineGrid = theGrid->finer;
-	if (fineGrid==NULL) return(1);
-	
-	/* refine elements */
-	RESETGSTATUS(fineGrid,GRID_CHANGED);
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (REF_TYPE_CHANGES(theElement))
-		{
-			GetCurrentContext(theElement,theContext);
-			if (UnrefineElement(fineGrid,theElement,theContext))  return(1);
-			if (UpdateContext(fineGrid,theElement,theContext)!=0) return(1);
-			if (RefineElement(fineGrid,theElement,theContext)!=0) return(1);
-			SETREFINE(theElement,MARK(theElement));
-			SETREFINECLASS(theElement,MARKCLASS(theElement));
-			SETGSTATUS(fineGrid,GRID_CHANGED);
-		}
-	}
-
-	/* reset newref flags */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		SETMARK(theElement,NOREFRULE);
-	}
-
-	/* set node class on next level */
-	for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-		if (SONNODE(theNode)!=NULL)
-		{
-			SETCLASS(SONNODE(theNode),NCLASS(theNode));
-			if (NCLASS(theNode)>=2) TOPNODE(MYVERTEX(theNode)) = SONNODE(theNode);
-		}
-
-	return(0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  Alignment														*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element according	*/
-/*			  to velocity													*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 						*/
-/*																			*/
-/* return:	  INT Mark: number of refrule									*/
-/*																			*/
-/****************************************************************************/
-
-static INT Alignment (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM], help, MidPoint;
-	DOUBLE_VECTOR Velocity;
-	INT i, flags, imax;
-	COORD Dist_0_5, Dist_1_3, Dist_2_4, max;
-
-	/* get physical position of the corners */
-	V3_CLEAR(MidPoint)
-	for (i=0; i<CORNERS_OF_ELEM(theElement); i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-	(*theDirectionElemEval)(theElement,Corners,LMP(CORNERS_OF_ELEM(theElement)),Velocity);
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-		V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* compute differences */
-	max=-MAX_C;
-	for (i=0; i<EDGES_OF_ELEM(theElement); i++)
-	{
-		V3_SUBTRACT(Corners[CornerOfEdge[i][0]], Corners[CornerOfEdge[i][1]], help)
-		V3_Normalize(help);
-		if (ABS(Velocity[0]*help[0]+Velocity[1]*help[1]+Velocity[2]*help[2])>max) {imax=i; max=ABS(Velocity[0]*help[0]+Velocity[1]*help[1]+Velocity[2]*help[2]);}
-	}
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[0], MidPoints[5], Dist_0_5)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[1], MidPoints[3], Dist_1_3)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[2], MidPoints[4], Dist_2_4)
-	switch (imax)
-	{
-		case 0:	if (Dist_1_3<Dist_2_4)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_2_4);
-		case 1:	if (Dist_0_5<Dist_2_4)	return (FULL_REFRULE_0_5);
-				else					return (FULL_REFRULE_2_4);
-		case 2:	if (Dist_1_3<Dist_0_5)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_0_5);
-		case 3:	if (Dist_0_5<Dist_2_4)	return (FULL_REFRULE_0_5);
-				else					return (FULL_REFRULE_2_4);
-		case 4:	if (Dist_1_3<Dist_0_5)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_0_5);
-		case 5:	if (Dist_1_3<Dist_2_4)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_2_4);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  YAlignment													*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element 			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 						*/
-/*																			*/
-/* return:	  INT Mark: number of refrule									*/
-/*																			*/
-/****************************************************************************/
-
-static INT YAlignment (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM], help;
-	INT i, flags, imax;
-	COORD Dist_0_5, Dist_1_3, Dist_2_4, max;
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* compute differences */
-	max=-1.0;
-	for (i=0; i<EDGES_OF_ELEM(theElement); i++)
-	{
-		V3_SUBTRACT(Corners[CornerOfEdge[i][0]], Corners[CornerOfEdge[i][1]], help)
-		V3_Normalize(help);
-		if (ABS(help[1]+help[2])>max) {imax=i; max=ABS(help[1]+help[2]);}
-	}
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[0], MidPoints[5], Dist_0_5)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[1], MidPoints[3], Dist_1_3)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[2], MidPoints[4], Dist_2_4)
-	switch (imax)
-	{
-		case 0:	if (Dist_1_3<Dist_2_4)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_2_4);
-		case 1:	if (Dist_0_5<Dist_2_4)	return (FULL_REFRULE_0_5);
-				else					return (FULL_REFRULE_2_4);
-		case 2:	if (Dist_1_3<Dist_0_5)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_0_5);
-		case 3:	if (Dist_0_5<Dist_2_4)	return (FULL_REFRULE_0_5);
-				else					return (FULL_REFRULE_2_4);
-		case 4:	if (Dist_1_3<Dist_0_5)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_0_5);
-		case 5:	if (Dist_1_3<Dist_2_4)	return (FULL_REFRULE_1_3);
-				else					return (FULL_REFRULE_2_4);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ShortestInteriorEdge											*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element 			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 						*/
-/*																			*/
-/* return:	  INT Mark: number of refrule									*/
-/*																			*/
-/****************************************************************************/
-
-static INT ShortestInteriorEdge (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM];
-	INT i, flags;
-	COORD Dist_0_5, Dist_1_3, Dist_2_4;
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* compute distances */
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[0], MidPoints[5], Dist_0_5)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[1], MidPoints[3], Dist_1_3)
-	V3_EUKLIDNORM_OF_DIFF(MidPoints[2], MidPoints[4], Dist_2_4)
-	
-	/* return best Refrule (shortest interior edge) */
-	flags = (Dist_0_5 < Dist_1_3) ;
-	flags |= ((Dist_1_3 < Dist_2_4) <<1) ;
-	flags |= ((Dist_2_4 < Dist_0_5) <<2) ;
-	assert(flags != 7);
-
-	switch(flags)
-	{
-		case 0: 				/* Dist_0_5 = Dist_2_4 = Dist_1_3 */
-			return (FULL_REFRULE_0_5);
-		case 1: 				/* Dist_0_5 < Dist_2_4 < Dist_1_3 */
-			return (FULL_REFRULE_0_5);
-		case 2: 				/* Dist_1_3 < Dist_0_5 < Dist_2_4 */
-			return (FULL_REFRULE_1_3);
-		case 3: 				/* Dist_0_5 < Dist_1_3 < Dist_2_4 */
-			return (FULL_REFRULE_0_5);
-		case 4: 				/* Dist_2_4 < Dist_1_3 < Dist_0_5 */
-			return (FULL_REFRULE_2_4);
-		case 5: 				/* Dist_2_4 < Dist_0_5 < Dist_1_3 */
-			return (FULL_REFRULE_2_4);
-		case 6: 				/* Dist_1_3 < Dist_2_4 < Dist_0_5 */
-			return (FULL_REFRULE_1_3);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MinimalSideAngle													*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element 			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 						*/
-/*																			*/
-/* return:	  INT Mark: number of refrule									*/
-/*																			*/
-/****************************************************************************/
-
-static INT MinimalSideAngle (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM];
-	INT i,j,k,l,imin;
-	COORD MaxAngle,Max,Min;
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Min = 190.0;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		Corners[2] = MidPoints[i];
-		Corners[3] = MidPoints[j];
-		
-		Max = 0.0;
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[i][k][l]];
-			if (TetMaxSideAngle (Corners,&MaxAngle))
-				return (FULL_REFRULE_0_5);
-			Max = MAX(Max,MaxAngle);
-		}
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[j][k][l]];
-			if (TetMaxSideAngle (Corners,&MaxAngle))
-				return (FULL_REFRULE_0_5);
-			Max = MAX(Max,MaxAngle);
-		}
-		if (Max<Min)
-		{
-			Min = Max;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			return (FULL_REFRULE_0_5);
-		case 1:
-			return (FULL_REFRULE_1_3);
-		case 2:
-			return (FULL_REFRULE_2_4);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MinimalSideEntry													*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element 			*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 						*/
-/*																			*/
-/* return:	  INT Mark: number of refrule									*/
-/*																			*/
-/****************************************************************************/
-
-static INT MinimalSideEntry (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM];
-	INT i,j,k,l,imin;
-	COORD Angle[MAX_EDGES_OF_ELEM],Length[MAX_EDGES_OF_ELEM],Max,Min,help;
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Min = MAX_C;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		Corners[2] = MidPoints[i];
-		Corners[3] = MidPoints[j];
-		
-		Max = 0.0;
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[i][k][l]];
-			if (TetAngleAndLength (Corners,Angle,Length))
-				return (FULL_REFRULE_0_5);
-			for (l=0; l<MAX_EDGES_OF_ELEM; l++)
-				if (Angle[l]>PI/2.0)
-				{
-					help = ABS(Length[l]*(COORD)(cos((double)Angle[l])/sin((double)Angle[l])));
-					Max = MAX(Max,help);
-				}
-		}
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[j][k][l]];
-			if (TetAngleAndLength (Corners,Angle,Length))
-				return (FULL_REFRULE_0_5);
-			for (l=0; l<MAX_EDGES_OF_ELEM; l++)
-				if (Angle[l]>PI/2.0)
-				{
-					help = ABS(Length[l]*(COORD)(cos((double)Angle[l])/sin((double)Angle[l])));
-					Max = MAX(Max,help);
-				}
-		}
-		if (Max<Min)
-		{
-			Min = Max;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			return (FULL_REFRULE_0_5);
-		case 1:
-			return (FULL_REFRULE_1_3);
-		case 2:
-			return (FULL_REFRULE_2_4);
-	}
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  BestLaplaceMMatrix										*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element:		*/
-/*			  optimal laplace-disc w.r.t. M-Matrix eigenschaft				*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 					*/
-/*																			*/
-/* return:	  INT Mark: number of refrule								*/
-/*																			*/
-/****************************************************************************/
-
-static INT BestLaplaceMMatrix (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM];
-	INT i,j,k,l,imin,TBFR,refrule;
-	COORD Angle[MAX_EDGES_OF_ELEM],Length[MAX_EDGES_OF_ELEM],sum,Min;
-	char buffer[64];
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Min = MAX_C; imin = -1;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		Corners[2] = MidPoints[i];
-		Corners[3] = MidPoints[j];
-		
-		sum = 0.0;
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[i][k][l]];
-			if (TetAngleAndLength (Corners,Angle,Length))
-				return (FULL_REFRULE_0_5);
-			for (l=0; l<MAX_EDGES_OF_ELEM; l++)
-				if (Angle[l]>PI/2.0)
-					sum += ABS(Length[l]*(COORD)cos((double)Angle[l])/(COORD)sin((double)Angle[l]));
-		}
-		for (k=0; k<2; k++)
-		{
-			for (l=0; l<2; l++)
-				Corners[l] = MidPoints[SideEdgesOfEdge[j][k][l]];
-			if (TetAngleAndLength (Corners,Angle,Length))
-				return (FULL_REFRULE_0_5);
-			for (l=0; l<MAX_EDGES_OF_ELEM; l++)
-				if (Angle[l]>PI/2.0)
-					sum += ABS(Length[l]*(COORD)cos((double)Angle[l])/(COORD)sin((double)Angle[l]));
-		}
-		if (sum<Min)
-		{
-			Min = sum;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			refrule = FULL_REFRULE_0_5;
-			break;
-		case 1:
-			refrule = FULL_REFRULE_1_3;
-			break;
-		case 2:
-			refrule = FULL_REFRULE_2_4;
-			break;
-	}
-	
-	
-	TBFR = ShortestInteriorEdge(theElement);
-	if (imin == -1)
-	{
-		refrule = TBFR;
-		UserWrite ("#");
-	}
-	
-	return (refrule);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MaxPerpendicular											*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element:		*/
-/*			  optimal laplace-disc w.r.t. M-Matrix eigenschaft				*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 					*/
-/*																			*/
-/* return:	  INT Mark: number of refrule								*/
-/*																			*/
-/****************************************************************************/
-
-static INT MaxPerpendicular (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM],a,b,c;
-	INT i,j,k,l,imin,TBFR,refrule;
-	COORD Angle[MAX_EDGES_OF_ELEM],Length[MAX_EDGES_OF_ELEM],sprd,Max;
-	char buffer[64];
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Max = -MAX_C; imin = -1;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		
-		V3_SUBTRACT(Corners[CornerOfEdge[i][0]],Corners[CornerOfEdge[i][1]],a)
-		V3_SUBTRACT(Corners[CornerOfEdge[j][0]],Corners[CornerOfEdge[j][1]],b)
-		V3_VECTOR_PRODUCT(a,b,c)
-		V3_Normalize(c);
-		V3_SUBTRACT(MidPoints[i],MidPoints[j],a)
-		V3_Normalize(a);
-		V3_SCALAR_PRODUCT(a,c,sprd)
-		sprd = ABS(sprd);
-
-		if (sprd>Max)
-		{
-			Max = sprd;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			refrule = FULL_REFRULE_0_5;
-			break;
-		case 1:
-			refrule = FULL_REFRULE_1_3;
-			break;
-		case 2:
-			refrule = FULL_REFRULE_2_4;
-			break;
-	}
-	
-	
-	TBFR = ShortestInteriorEdge (theElement);
-	if (imin == -1)
-	{
-		refrule = TBFR;
-		UserWrite ("#");
-	}
-	
-	return (refrule);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MaxRightAngle 											*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element:		*/
-/*			  optimal laplace-disc w.r.t. M-Matrix eigenschaft				*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 					*/
-/*																			*/
-/* return:	  INT Mark: number of refrule								*/
-/*																			*/
-/****************************************************************************/
-
-static INT MaxRightAngle (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM],a,b,c;
-	INT i,j,k,l,imin,TBFR,refrule;
-	COORD Angle[MAX_EDGES_OF_ELEM],Length[MAX_EDGES_OF_ELEM],sprd,Min;
-	char buffer[64];
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-	V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Min = MAX_C; imin = -1;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		
-		V3_SUBTRACT(Corners[CornerOfEdge[i][0]],Corners[CornerOfEdge[i][1]],a)
-		V3_Normalize(a);
-		V3_SUBTRACT(Corners[CornerOfEdge[j][0]],Corners[CornerOfEdge[j][1]],b)
-		V3_Normalize(b);
-		V3_SCALAR_PRODUCT(a,b,sprd)
-		sprd = ABS(sprd);
-
-		if (sprd<Min)
-		{
-			Min = sprd;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			refrule = FULL_REFRULE_0_5;
-			break;
-		case 1:
-			refrule = FULL_REFRULE_1_3;
-			break;
-		case 2:
-			refrule = FULL_REFRULE_2_4;
-			break;
-	}
-	
-	
-	TBFR = ShortestInteriorEdge (theElement);
-	if (imin == -1)
-	{
-		refrule = TBFR;
-		UserWrite ("#");
-	}
-	
-	return (refrule);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  MaxArea												*/
-/*																			*/
-/* Purpose:   compute best full refined refrule for the element:		*/
-/*			  optimal laplace-disc w.r.t. M-Matrix eigenschaft				*/
-/*																			*/
-/* Param:	  ELEMENT *theElement: for that element 					*/
-/*																			*/
-/* return:	  INT Mark: number of refrule								*/
-/*																			*/
-/****************************************************************************/
-
-static INT MaxArea (ELEMENT *theElement)
-{
-	COORD *Corners[MAX_CORNERS_OF_ELEM];
-	COORD_VECTOR MidPoints[MAX_EDGES_OF_ELEM],a,b,c;
-	INT i,j,k,l,imin,TBFR,refrule;
-	COORD Angle[MAX_EDGES_OF_ELEM],Length[MAX_EDGES_OF_ELEM],norm,Max;
-	char buffer[64];
-
-	/* get physical position of the corners */
-	for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-		Corners[i] = CVECT(MYVERTEX(CORNER(theElement,i)));
-		
-	/* get physical position of the midpoints of the edges */
-	for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-		V3_LINCOMB(0.5, Corners[CornerOfEdge[i][0]], 0.5, Corners[CornerOfEdge[i][1]], MidPoints[i]);
-		
-	/* try possebilities */
-	Max = -MAX_C; imin = -1;
-	for (i=0; i<3; i++)
-	{
-		j = OppositeEdge[i];
-		
-		V3_SUBTRACT(Corners[CornerOfEdge[i][0]],Corners[CornerOfEdge[i][1]],a)
-		V3_SUBTRACT(Corners[CornerOfEdge[j][0]],Corners[CornerOfEdge[j][1]],b)
-		V3_VECTOR_PRODUCT(a,b,c)
-		V3_EUKLIDNORM(c,norm)
-
-		if (norm>Max)
-		{
-			Max = norm;
-			imin = i;
-		}
-	}
-	
-	switch (imin)
-	{
-		case 0:
-			refrule = FULL_REFRULE_0_5;
-			break;
-		case 1:
-			refrule = FULL_REFRULE_1_3;
-			break;
-		case 2:
-			refrule = FULL_REFRULE_2_4;
-			break;
-	}
-	
-	
-	TBFR = ShortestInteriorEdge (theElement);
-	if (imin == -1)
-	{
-		refrule = TBFR;
-		UserWrite ("#");
-	}
-	
-	return (refrule);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  CloseGrid 													*/
-/*																			*/
-/* Purpose:   compute closure for next level								*/
-/*																			*/
-/* Param:	  GRID *theGrid: pointer to grid structure						*/
-/*																			*/
-/* return:	  INT >0: elements will be refined								*/
-/*			  INT 0: no elements will be refined							*/
-/*																			*/
-/****************************************************************************/
-
-static int CloseGrid (GRID *theGrid)
-{
-	ELEMENT *theElement, *NbElement;
-	EDGE *MyEdge, *NbEdge;
-	INT i, j, cnt;
-	INT Mark, MyEdgePattern, MySidePattern, MyEdgeNum;
-	INT NbEdgePattern, NbSidePattern, NbEdgeNum, NbSideMask;
-	SHORT *myPattern;
-	
-	/* reset pattern and used flag on the edges */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		SETUSED(theElement,0);
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-			for (j=i+1; j<MAX_CORNERS_OF_ELEM; j++)
-			{
-				MyEdge=GetEdge(CORNER(theElement,i),CORNER(theElement,j));
-				assert (MyEdge != NULL);
-				SETPATTERN(MyEdge,0);
-				SETADDPATTERN(MyEdge,1);
-			}
-	}
-	
-	/* set pattern on the edges and reset side-and edge pattern field */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (MARKCLASS(theElement)==RED)
-		{
-			Mark = MARK(theElement);
-			myPattern = Rules[Mark].pattern;
-			for (i=0; i<MAX_EDGES_OF_ELEM; i++)
-				if (myPattern[i])
-				{
-					MyEdge=GetEdge(CORNER(theElement,CornerOfEdge[i][0]),CORNER(theElement,CornerOfEdge[i][1]));
-					if (MyEdge != NULL)
-						SETPATTERN(MyEdge,1);
-				}
-		}
-		SETEDGEPATTERN(theElement,0);
-		SETSIDEPATTERN(theElement,0);
-	}
-	
-	/* set pattern (edge and side) on the elements */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		/* make edgepattern consistent with pattern of edges */
-		SETUSED(theElement,1);
-		MyEdgePattern = 0;
-		for (i=MAX_EDGES_OF_ELEM-1; i>=0; i--)
-		{
-			MyEdge=GetEdge(CORNER(theElement,CornerOfEdge[i][0]),CORNER(theElement,CornerOfEdge[i][1]));
-			MyEdgePattern = (MyEdgePattern<<1) | PATTERN(MyEdge);
-		}
-		SETEDGEPATTERN(theElement,MyEdgePattern);
-		
-		/* make SIDEPATTERN consistent with neighbors */
-		for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-		{
-			NbElement = NBELEM(theElement,i);
-			if (NbElement == NULL) continue;
-			if (!USED(NbElement)) continue;
-			/* now edgepattern from theelement and NbElement are in final state */
-			for (j=0; j<MAX_SIDES_OF_ELEM; j++)
-				if (NBELEM(NbElement,j) == theElement)
-					break;
-			
-			/* because SETSIDEPATTERN is set to zero, I choose TriSectionEdgeÉÉ[0] */
-			MyEdgeNum = TriSectionEdge[MyEdgePattern&CondensedEdgeOfSide[i]][0];
-			if (MyEdgeNum == -2) return (0);
-			if (MyEdgeNum == -1) continue;
-			
-			NbEdgePattern = EDGEPATTERN(NbElement);
-			NbEdgeNum = TriSectionEdge[NbEdgePattern&CondensedEdgeOfSide[j]][0];
-			if (NbEdgeNum == -2 || NbEdgeNum == -1) return (0);
-			
-			if (!( CORNER(theElement,CornerOfEdge[MyEdgeNum][0]) == CORNER(NbElement,CornerOfEdge[NbEdgeNum][0]) &&
-				   CORNER(theElement,CornerOfEdge[MyEdgeNum][1]) == CORNER(NbElement,CornerOfEdge[NbEdgeNum][1])	) &&
-				!( CORNER(theElement,CornerOfEdge[MyEdgeNum][0]) == CORNER(NbElement,CornerOfEdge[NbEdgeNum][1]) &&
-				   CORNER(theElement,CornerOfEdge[MyEdgeNum][1]) == CORNER(NbElement,CornerOfEdge[NbEdgeNum][0])	)	 )
-			{
-				NbSidePattern = SIDEPATTERN(NbElement);
-				NbSideMask = (1<<j);
-				if ( NbSidePattern & NbSideMask )
-					NbSidePattern &= ~NbSideMask;
-				else
-					NbSidePattern |= NbSideMask;
-				SETSIDEPATTERN(NbElement,NbSidePattern);
-			}
-		}
-	}
-
-	/* set refinement rules from edge- and sidepattern */
-	cnt = 0;
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		MyEdgePattern = EDGEPATTERN(theElement);
-		MySidePattern = SIDEPATTERN(theElement);
-		Mark = PatternToRefrule[MyEdgePattern | (MySidePattern<<MAX_EDGES_OF_ELEM)];
-		assert(Mark != -1);
-		if (Mark == FULL_REFRULE)
-			Mark = (*theFullRefRule)(theElement);
-		if (MARKCLASS(theElement)==RED && Mark==NOREFRULE)
-			Mark = COPY_REFRULE;
-		if (MARKCLASS(theElement)!=RED && Mark!=NOREFRULE)
-			SETMARKCLASS(theElement,GREEN);
-		if (Mark)
-			cnt++;
-		SETMARK(theElement,Mark);
-	}	
-	
-	/* build a green covering around the red elements */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (MARKCLASS(theElement)!=RED) continue;
-		for (i=0; i<MAX_SIDES_OF_ELEM; i++)
-		{
-			NbElement = NBELEM(theElement,i);
-			if (NbElement == NULL) continue;
-			if ((MARKCLASS(NbElement)==GREEN) || (MARKCLASS(NbElement)==RED)) continue;
-			if (MARK(NbElement) == NOREFRULE)
-				SETMARK(NbElement,COPY_REFRULE);
-			SETMARKCLASS(NbElement,GREEN);
-		}
-	}	
-	
-	/* set additional pattern on the edges */
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (MARKCLASS(theElement)!=RED) continue;
-		for (i=0; i<MAX_CORNERS_OF_ELEM; i++)
-			for (j=i+1; j<MAX_CORNERS_OF_ELEM; j++)
-			{
-				MyEdge=GetEdge(CORNER(theElement,i),CORNER(theElement,j));
-				assert (MyEdge != NULL);
-				SETADDPATTERN(MyEdge,0);
-			}
-	}
-	
-	return(cnt);
-}
-
-
-/****************************************************************************/
-/*																			*/
-/* Function:  PrintMarks													*/
-/*																			*/
-/* Purpose:   print marks of all the elements of that grid					*/
-/*																			*/
-/* Param:	  GRID *theGrid: grid to scan									*/
-/*																			*/
-/* return:	  none															*/
-/*																			*/
-/****************************************************************************/
-
-static void PrintMarks (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	char buffer[64];
-	
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		sprintf(buffer,"MARK (ID[ELEM] = %ld) = %ld \n",ID(theElement),MARK(theElement));
-		UserWrite(buffer);	
-	}
-
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  DropMarks 													*/
-/*																			*/
-/* Purpose:   drop marks from leafelements to first regular, and reset		*/
-/*			  marks on all element above (important for restrict marks) 	*/
-/*																			*/
-/* Param:	  MULTIGRID *theMG												*/
-/*																			*/
-/* return:	  INT 0: ok 													*/
-/*			  INT 1: error													*/
-/*																			*/
-/****************************************************************************/
-
-static INT DropMarks (MULTIGRID *theMG)
-{
-	INT k, Mark;
-	GRID *theGrid;
-	ELEMENT *theElement, *FatherElement;
-
-	for (k=theMG->topLevel; k>0; k--)
-	{
-		theGrid = GRID_ON_LEVEL(theMG,k);
-		for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-			if (LEAFELEM(theElement) && (MARKCLASS(theElement) == RED) && (ECLASS(theElement) != RED))
-			{
-				Mark = MARK(theElement);
-				FatherElement = theElement;
-				while(ECLASS(FatherElement) != RED)
-				{
-					SETMARK(FatherElement,NOREFRULE);
-					FatherElement = EFATHER(FatherElement);
-				}
-				SETMARK(FatherElement,Mark);
-				SETMARKCLASS(FatherElement,RED);
-			}
-	}
-	return (0);
-}
-
-/****************************************************************************/
-/*																			*/
-/* Function:  ComputEdgeTypes											*/
-/*																			*/
-/* Purpose:   refine whole multigrid structure					*/
-/*																			*/
-/* Param:	  MULTIGRID *theMG: multigrid to refine 				*/
-/*																			*/
-/* return:	  INT 0: ok 									*/
-/*			  INT 1: error								*/
-/*																			*/
-/****************************************************************************/
-
-static INT ResetEdgeNew (GRID *theGrid)
-{
-	NODE *theNode;
-	LINK *theLink;
-	EDGE *theEdge;
-
-	if (theGrid==NULL) return(0);
-	for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode))
-	{
-		for (theLink=START(theNode); theLink!=NULL; theLink=NEXT(theLink))
-			if (ID(NBNODE(theLink))>ID(theNode))
-			{
-				theEdge = MYEDGE(theLink);
-				assert(theEdge!=NULL);
-				SETEDGENEW(theEdge,0);
-			}
-	}
-	
-	return (0);
-	
-}
-
-static INT ComputEdgeTypes (GRID *theGrid)
-{
-	ELEMENT *theElement;
-	ELEMENTCONTEXT theContext;
-	EDGE *theEdge;
-	REFRULE *theRule;
-	EDGEDATA *eData;
-	INT i, j;
-	
-	for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-	{
-		if (REFINE(theElement)==NOREFRULE) continue;
-		theRule = &(Rules[REFINE(theElement)]);
-		GetCurrentContext (theElement,theContext);
-		for (eData=&(theRule->edges[0]); eData->type!=0; eData++)
-		{
-			theEdge = GetEdge(theContext[eData->from],theContext[eData->to]);
-			assert(theEdge!=NULL);
-			SETTAG(theEdge,eData->type);
-		}
-	}
-	
-	return (0);
-}
-
-
-/****************************************************************************/
-/*
-   RefineMultiGrid - Refine whole multigrid structure
-
-   SYNOPSIS:
-   INT RefineMultiGrid (MULTIGRID *theMG, INT flag, char *name);
-
-   PARAMETERS:
-.  theMG - multigrid to refine
-.  flag -
-.  direction - element evaluation function for the direction
-.n otherwise NULL
-
-   DESCRIPTION:
-   This function refines whole multigrid structure. The full refinement rule
-.n is chosen according to the direction.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok 
-.n   1 if out of memory, but data structure as before	
-.n   2 if fatal memory error, data structure corrupted.	
-*/
-/****************************************************************************/
-
-INT RefineMultiGrid (MULTIGRID *theMG, INT flag, EVECTOR *direction)
-{
-	int j,k,r;
-	int newlevel;
-	NODE *theNode;
-	GRID *theGrid, *FinerGrid;
-	ELEMENT *theElement, *FatherElement;
-	
-	/* get velocity */
-	if (direction != NULL)
-	{
-		if ((*(direction->PreprocessProc))(ENVITEM_NAME(direction),theMG)) return(1);
-		theDirectionElemEval = direction->EvalProc;
-		theFullRefRule = Alignment;
-	}
-	else
-		theFullRefRule = ShortestInteriorEdge;
-	
-	rFlag=flag; 	/* set global variable */
-	
-	/* drop marks to regular elements */
-	if (DropMarks(theMG))
-		return(GM_ERROR);
-
-	/* prepare algebra (set internal flags correctly */
-	PrepareAlgebraModification(theMG);
-	
-	/* compute modification of coarser levels from above */
-	j = theMG->topLevel;
-	for (k=j; k>0; k--)
-	{
-		theGrid = GRID_ON_LEVEL(theMG,k);
-		CloseGrid(theMG->grids[k]);
-		RestrictMarks(theMG->grids[k-1]);
-	}
-
-	newlevel = 0;
-	for (k=0; k<=j; k++)
-	{
-		theGrid = GRID_ON_LEVEL(theMG,k);
-		if (k<j) FinerGrid = GRID_ON_LEVEL(theMG,k+1); else FinerGrid = NULL;
-
-		/* reset some flags */
-		SETMODIFIED(theGrid,0);
-		for (theNode=theGrid->firstNode; theNode!=NULL; theNode=SUCCN(theNode)) SETMODIFIED(theNode,0);
-
-		/* leave only regular marks */
-		for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-		{
-			if ((ECLASS(theElement)==RED) && MARKCLASS(theElement)==RED) continue;
-			SETMARK(theElement,NOREFRULE);
-		}
-
-		/* determine regular and irregular elements on next level */
-		if ((r = CloseGrid(theGrid))<0)
-		{
-			PrintErrorMessage('E',"RefineMultiGrid","error in CloseGrid");
-			return(GM_FATAL);
-		}
-		
-		ComputeCopies(theGrid);
-
-		/* dispose connections that may be changed on next level, this is determined */
-		/* by the neighborhood of elements were MARK != REFINE. 					 */
-		/* This will leave some flags where to rebuild connections later			 */
-		if (k<j)
-		{
-			for (theElement=FIRSTELEMENT(FinerGrid); theElement!=NULL; theElement=SUCCE(theElement))
-			{
-				assert(EFATHER(theElement) != NULL);
-				if (REFINE(EFATHER(theElement))!=MARK(EFATHER(theElement))) 
-					if (DisposeConnectionsInNeighborhood(FinerGrid,theElement)!=GM_OK)
-						return(GM_FATAL);
-			}
-		}
-		
-		/* create a new grid level, if at least one element is refined on finest level */		
-		if ( (r>0) && (k==j) )
-		{
-			newlevel = 1;
-			if (CreateNewLevel(theMG)==NULL)
-				return(GM_FATAL);
-			FinerGrid = GRID_ON_LEVEL(theMG,j+1);
-		}
-		
-		/* now really manipulate the next finer level */		
-		if ( k<j || newlevel )
-			if (RefineGrid(theGrid)!=0) 
-				return(GM_FATAL);
-			
-		if ((k<j)||(newlevel))
-		{
-			/* now rebuild connections in neighborhood of elements which have EBUILDCON set */
-			/* This flag has been set either by GridDisposeConnection or by CreateElement	*/
-			if (GridCreateConnection(FinerGrid)) return (GM_FATAL);
-			/* and compute the vector classes on the new (or changed) level */
-
-			if (rFlag==GM_COPY_ALL)
-			  for (theElement=theGrid->elements; theElement!=NULL; theElement=SUCCE(theElement))
-				SeedVectorClasses(theElement);
-			else
-			  {
-				ClearVectorClasses(FinerGrid);
-				for (theElement=FIRSTELEMENT(FinerGrid); theElement!=NULL; theElement=SUCCE(theElement))
-				  if (ECLASS(theElement)>=IRREGULAR_CLASS) SeedVectorClasses(theElement);
-				PropagateVectorClasses(FinerGrid);
-			  }
-		}
-			
-	}
-
-	DisposeTopLevel(theMG);
-	theMG->currentLevel = theMG->topLevel;
-
-	/* set grid status of grid 0 */
-	RESETGSTATUS(theMG->grids[0],GRID_CHANGED);
-
-	return(GM_OK);
-}
-
-static int FReadRule (FILE *stream, REFRULE *theRule)
-{
-	int i;
-	int ns,p0,p1,p2,p3,p4,p5,p6,p7,pat;
-	int type,from,to,side;
-	int c0,c1,c2,c3,n0,n1,n2,n3,pa;
-	int sn0,sn1;
-	
-	if (fscanf(stream,"%d  %d %d %d %d %d %d  %d",&ns,&p0,&p1,&p2,&p3,&p4,&p5,&pat)!=8) return (1);
-	
-	theRule->nsons = ns;
-	theRule->pattern[0] = p0;
-	theRule->pattern[1] = p1;
-	theRule->pattern[2] = p2;
-	theRule->pattern[3] = p3;
-	theRule->pattern[4] = p4;
-	theRule->pattern[5] = p5;
-	theRule->pattern[6] = p6;
-	theRule->pattern[7] = p7;
-	theRule->pat = pat;
-	
-	for (i=0; i<MAXEDGES; i++)
-	{
-		if (fscanf(stream," %d %d %d %d",&type,&from,&to,&side)!=4) return (1);
-		theRule->edges[i].type = type;
-		theRule->edges[i].from = from;
-		theRule->edges[i].to   = to;
-		theRule->edges[i].side = side;
-	}
-	
-	for (i=0; i<MAX_SONS; i++)
-	{
-		if (fscanf(stream," %d %d %d %d %d %d %d %d %d",&c0,&c1,&c2,&c3,&n0,&n1,&n2,&n3,&pa)!=9) return (1);
-		theRule->sons[i].corners[0] = c0;
-		theRule->sons[i].corners[1] = c1;
-		theRule->sons[i].corners[2] = c2;
-		theRule->sons[i].corners[3] = c3;
-		theRule->sons[i].nb[0]		= n0;
-		theRule->sons[i].nb[1]		= n1;
-		theRule->sons[i].nb[2]		= n2;
-		theRule->sons[i].nb[3]		= n3;
-		theRule->sons[i].path		= pa;
-	}
-	
-	for (i=0; i<NEWCORNERS; i++)
-	{
-		if (fscanf(stream," %d %d",&sn0,&sn1)!=2) return (1);
-		theRule->sonandnode[i][0] = sn0;
-		theRule->sonandnode[i][1] = sn1;
-	}
-	
-	return (0);
-}
-
-/****************************************************************************/
-/*
-   InitRefine3d - Initialization of ugrefine
-
-   SYNOPSIS:
-   INT InitRefine3d (void);
-
-   PARAMETERS:
-.  void
-
-   DESCRIPTON:
-   This function initializes ugrefine.
-
-   RETURN VALUE:
-   INT
-.n   0 if ok
-.n   1 if error occured
-*/
-/****************************************************************************/
-
-INT InitRefine3d (void)
-{
-	int nRules, nPatterns, err, i, P2R;
-	FILE *stream;
-	FULLREFRULE *newFRR;
-	char buffer[256];
-
-	/************************************************************************/
-	/*																		*/
-	/* read refinement rules from file 'RefRules.data'						*/
-	/*																		*/
-	/************************************************************************/
-
-	/* open file */
-	if (GetDefaultValue(DEFAULTSFILENAME,"refrulefile",buffer)==0)
-	  stream = fileopen(buffer,"r");
-	else
-	  stream = fileopen("RefRules.data","r");
-	if (stream==NULL)
-	{
-		UserWrite("ERROR: could not open file 'RefRules.data'\n");
-		fclose(stream);
-		return (__LINE__);
-	}
-	
-	/* read Rules and nPatterns from file */
-	if (fscanf(stream,"%d %d\n",&nRules,&nPatterns)!=2)
-	{
-		UserWrite("ERROR: failed to read Rules and nPatterns\n");
-		fclose(stream);
-		return (__LINE__);
-	}
-	
-	/* get storage for Rules */
-	Rules = (REFRULE *) malloc(nRules*sizeof(REFRULE));
-	if (Rules==NULL)
-	{
-		UserWrite("ERROR: no storage for Rules\n");
-		fclose(stream);
-		return (__LINE__);
-	}
-	
-	/* get storage for PatternToRefrule */
-	PatternToRefrule = (SHORT *) malloc(nPatterns*sizeof(SHORT));
-	if (PatternToRefrule==NULL)
-	{
-		UserWrite("ERROR: no storage for PatternToRefrule\n");
-		fclose(stream);
-		return (__LINE__);
-	}
-	
-	/* read Rules */
-	for (i=0; i<nRules; i++)
-		if (FReadRule(stream,Rules+i)) return (__LINE__);
-	
-	/* read PatternToRefrule */
-	for (i=0; i<nPatterns; i++)
-	{
-		if (fscanf(stream,"%d",&P2R)!=1) return (__LINE__);
-		PatternToRefrule[i] = P2R;
-	}
-	
-	fclose(stream);
-	
-	UserWrite("RefRules installed\n");
-	
-	/************************************************************************/
-	/*																		*/
-	/* install best full refrules											*/
-	/*																		*/
-	/************************************************************************/
-
-	/* install the /Menu directory */
-	if (ChangeEnvDir("/")==NULL)
-	{
-		PrintErrorMessage('F',"InitRefine3d","could not changedir to root");
-		return(__LINE__);
-	}
-	theBFRRDirID = GetNewEnvDirID();
-	if (MakeEnvItem("best full refrule",theBFRRDirID,sizeof(ENVDIR))==NULL)
-	{
-		PrintErrorMessage('F',"InitRefine3d","could not install '/best full refrule' dir");
-		return(__LINE__);
-	}
-	if (ChangeEnvDir("/best full refrule")==NULL)
-		return(__LINE__);
-
-	newFRR = (FULLREFRULE *) MakeEnvItem("shortestie",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = ShortestInteriorEdge;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("minangle",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = MinimalSideAngle;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("bestm",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = BestLaplaceMMatrix;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("maxper",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = MaxPerpendicular;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("mra",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = MaxRightAngle;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("maxarea",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = MaxArea;
-	
-	newFRR = (FULLREFRULE *) MakeEnvItem("minentry",theBFRRDirID,sizeof(FULLREFRULE));
-	if (newFRR==NULL)
-		return(__LINE__);
-	newFRR->theFullRefRule = MinimalSideEntry;
-	
-	/* default full refrule */
-	theFullRefRule = ShortestInteriorEdge;
-	
-	return (GM_OK);
-}
-
diff -ruN ug-orig/gm/ugrefine3d.h ug-patched/gm/ugrefine3d.h
--- ug-orig/gm/ugrefine3d.h	1995-11-15 19:47:45.000000000 +0100
+++ ug-patched/gm/ugrefine3d.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,149 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugrefine3d.h													*/
-/*																			*/
-/* Purpose:   unstructured grid refinement header file						*/
-/*																			*/
-/* Author:	  Klaus Johannsen												*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70550 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de							*/
-/*																			*/
-/* History:   09.03.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __UGREFINE3__
-#define __UGREFINE3__
-
-#ifndef __gm__
-#include "gm.h"
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define LEAFELEM(e) 	(REFINE(e)==0)
-#define LEAFNODE(n) 	(SONNODE(n)==NULL)
-
-/* refinement rule numbers */
-#define  NOREFRULE			 0
-#define  COPY_REFRULE		 1
-#define  FULL_REFRULE		 PatternToRefrule[0x3F]
-#define  FULL_REFRULE_0_5	 (PatternToRefrule[0x3F]+1)
-#define  FULL_REFRULE_1_3	 (PatternToRefrule[0x3F]+2)
-#define  FULL_REFRULE_2_4	 (PatternToRefrule[0x3F]+0)
-
-
-#define MAXEDGES	16			/* max. no of type 1/2 edges				*/
-#define NEWCORNERS	7			/* midpoints on edges plus center			*/
-#define NOTUSED 	-1			/* SHORT has to be signed!					*/
-#define NO_CENTER_NODE	NOTUSED
-
-/* enumeration type for element class, now in gm.h ! */
-
-/* other macros */
-#define FATHER_SIDE_OFFSET	20 /* greater values indicate outside faces 	*/
-
-/* macros specifying mark used in MarkForRefinement, this is now in gm.h ! */
-#define NO_MARK 		 0
-#define FULL_REF_MARK	 1			
-#define COPY_REF_MARK	 2
-
-/****************************************************************************/
-/*																			*/
-/* data structures exported by the corresponding source file				*/
-/*																			*/
-/****************************************************************************/
-
-#define FULLREFRULE_VAR 	 82
-typedef INT (*FULLREFRULEPTR) (ELEMENT *);
-
-typedef struct {
-		INT type;									/* one of the variable types above								*/
-		INT locked; 								/* may not be changed or deleted								*/
-		union envitem *next;
-		union envitem *previous;					/* double linked list of environment items						*/
-		char name[NAMESIZE];						/* name of that item (view) 									*/
-
-		/* full ref rule spezific stuff */
-	FULLREFRULEPTR theFullRefRule;			/* the best full refrule						*/
-
-} FULLREFRULE;
-
-struct sondata{
-	SHORT  corners[MAX_SIDES_OF_ELEM];	   /* corners of the son */
-	SHORT  nb[MAX_SIDES_OF_ELEM];
-	INT    path;
-};
-
-/* edge type  : 1 = inner edge of the father
-				2 = inner edge of one side
-				3 = half an edge of the father element
-				4 = edge of the father itself
-*/
-
-struct edgedata{
-	SHORT type; 			   /* interior edge of the tetra or only of one side */
-	SHORT from; 			   /* indices of the first endpoint (0..9)			 */
-	SHORT to;				   /* indices of the second endpoint (4..9) 		 */
-	SHORT side; 			   /* side, for which edge is interior, if type 2	 */
-};
-
-struct refrule{
-	SHORT			nsons;
-	SHORT			pattern[MAX_EDGES_OF_ELEM];
-	SHORT			pat;
-	SHORT			sonandnode[NEWCORNERS][2];
-	struct edgedata edges[MAXEDGES];
-	struct sondata	sons[MAX_SONS];
-};
-
-
-typedef struct sondata SONDATA;
-typedef struct edgedata EDGEDATA;
-typedef struct refrule REFRULE;
-
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-extern	REFRULE *Rules;
-
-/****************************************************************************/
-/*																			*/
-/* control word entries 													*/
-/*																			*/
-/****************************************************************************/
-
-
-/****************************************************************************/
-/*																			*/
-/* function declarations													*/
-/*																			*/
-/****************************************************************************/
-
-INT InitRefine3d (void);
-INT ShowRefRule (INT nb);
-
-#endif
diff -ruN ug-orig/gm/ugrefine.h ug-patched/gm/ugrefine.h
--- ug-orig/gm/ugrefine.h	1995-11-15 19:47:41.000000000 +0100
+++ ug-patched/gm/ugrefine.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,121 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  ugrefine.h													*/
-/*																			*/
-/* Purpose:   definitions for two AND three dimensional refinement			*/
-/*																			*/
-/* Author:	  Peter Bastian 												*/
-/*			  Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen	*/
-/*			  Universitaet Heidelberg										*/
-/*			  Im Neuenheimer Feld 368										*/
-/*			  6900 Heidelberg												*/
-/*			  internet: ug@ica3.uni-stuttgart.de					*/
-/*																			*/
-/* History:   09.03.92 begin, ug version 2.0								*/
-/*																			*/
-/* Remarks: 																*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* auto include mechanism and other include files							*/
-/*																			*/
-/****************************************************************************/
-
-#ifndef __UGREFINE__
-#define __UGREFINE__
-
-#ifndef __COMPILER__
-#include "compiler.h"
-#endif
-
-#ifndef __GM__
-#include "gm.h"
-#endif
-
-
-/****************************************************************************/
-/*																			*/
-/* control word definitions 												*/
-/*																			*/
-/****************************************************************************/
-
-/* edges */
-#define PATTERN_CE					39
-#define PATTERN_SHIFT				10
-#define PATTERN_LEN 				1
-#define PATTERN(p)					CW_READ(p,PATTERN_CE)
-#define SETPATTERN(p,n) 			CW_WRITE(p,PATTERN_CE,n)
-
-#define ADDPATTERN_CE				40
-#define ADDPATTERN_SHIFT			11
-#define ADDPATTERN_LEN				1
-#define ADDPATTERN(p)				CW_READ(p,ADDPATTERN_CE)
-#define SETADDPATTERN(p,n)			CW_WRITE(p,ADDPATTERN_CE,n)
-
-
-/* element */
-#define REFINE_CE						45
-#define REFINE_SHIFT					0
-#define REFINE_LEN						8
-#define REFINE(p)						CW_READ(p,REFINE_CE)
-#define SETREFINE(p,n)					CW_WRITE(p,REFINE_CE,n)
-
-#define MARK_CE 						50
-#define MARK_SHIFT						0
-#define MARK_LEN						8
-#define MARK(p) 						CW_READ(p,MARK_CE)
-#define SETMARK(p,n)					CW_WRITE(p,MARK_CE,n)
-
-#define COARSEN_CE						51
-#define COARSEN_SHIFT					10
-#define COARSEN_LEN 					1
-#define COARSEN(p)						CW_READ(p,COARSEN_CE)
-#define SETCOARSEN(p,n) 				CW_WRITE(p,COARSEN_CE,n)
-
-#define DECOUPLED_CE					53
-#define DECOUPLED_SHIFT 				12
-#define DECOUPLED_LEN					1
-#define DECOUPLED(p)					CW_READ(p,DECOUPLED_CE) 
-#define SETDECOUPLED(p,n)				CW_WRITE(p,DECOUPLED_SHIFT,n)
-
-#define REFINECLASS_CE					49
-#define REFINECLASS_SHIFT				15
-#define REFINECLASS_LEN 				2
-#define REFINECLASS(p)					CW_READ(p,REFINECLASS_CE)
-#define SETREFINECLASS(p,n) 			CW_WRITE(p,REFINECLASS_CE,n)
-
-#define EDGEPATTERN_CE					54
-#define EDGEPATTERN_SHIFT				0
-#define EDGEPATTERN_LEN 				6
-#define EDGEPATTERN(p)					CW_READ(p,EDGEPATTERN_CE)
-#define SETEDGEPATTERN(p,n) 			CW_WRITE(p,EDGEPATTERN_CE,n)
-
-#define SIDEPATTERN_CE					55
-#define SIDEPATTERN_SHIFT				6
-#define SIDEPATTERN_LEN 				4
-#define SIDEPATTERN(p)					CW_READ(p,SIDEPATTERN_CE)
-#define SETSIDEPATTERN(p,n) 			CW_WRITE(p,SIDEPATTERN_CE,n)
-
-#define MARKCLASS_CE					58
-#define MARKCLASS_SHIFT 				13
-#define MARKCLASS_LEN					2
-#define MARKCLASS(p)					CW_READ(p,MARKCLASS_CE) 
-#define SETMARKCLASS(p,n)				CW_WRITE(p,MARKCLASS_CE,n)
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-#define  NOREFRULE			 0
-
-
-
-#endif
diff -ruN ug-orig/graphics/covise/coviseif.cpp ug-patched/graphics/covise/coviseif.cpp
--- ug-orig/graphics/covise/coviseif.cpp	1997-12-23 17:04:10.000000000 +0100
+++ ug-patched/graphics/covise/coviseif.cpp	1997-12-23 17:04:10.000000000 +0100
@@ -164,7 +164,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/covise/coviseif.cpp,v 1.3 1997/12/23 16:04:10 stefan Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/covise/coviseif.h ug-patched/graphics/covise/coviseif.h
--- ug-orig/graphics/covise/coviseif.h	1997-12-16 17:23:36.000000000 +0100
+++ ug-patched/graphics/covise/coviseif.h	1997-12-16 17:23:36.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/covise/coviseif.h,v 1.1 1997/12/16 16:23:36 birken Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/graphics/covise/CVS/Entries ug-patched/graphics/covise/CVS/Entries
--- ug-orig/graphics/covise/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/covise/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-/Makefile.covise/1.3/Tue Dec 23 14:30:02 1997//D2008.11.12.23.00.00
-/coviseif.cpp/1.3/Tue Dec 23 16:04:10 1997//D2008.11.12.23.00.00
-/coviseif.h/1.1/Tue Dec 16 16:23:36 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/graphics/covise/CVS/Repository ug-patched/graphics/covise/CVS/Repository
--- ug-orig/graphics/covise/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/covise/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/graphics/covise
diff -ruN ug-orig/graphics/covise/CVS/Root ug-patched/graphics/covise/CVS/Root
--- ug-orig/graphics/covise/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/covise/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/graphics/covise/CVS/Tag ug-patched/graphics/covise/CVS/Tag
--- ug-orig/graphics/covise/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/covise/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/graphics/CVS/Entries ug-patched/graphics/CVS/Entries
--- ug-orig/graphics/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:17 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:10 2004//D2008.11.12.23.00.00
-/Makefile.graphics/1.8/Thu Oct  9 11:04:37 2003//D2008.11.12.23.00.00
-/graphics.c/1.6/Wed Jul 21 09:21:44 2004//D2008.11.12.23.00.00
-/graphics.h/1.6/Mon May  8 12:29:20 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/graphics/CVS/Entries.Log ug-patched/graphics/CVS/Entries.Log
--- ug-orig/graphics/CVS/Entries.Log	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-A D/covise////
-A D/grape////
-A D/pv3////
-A D/uggraph////
diff -ruN ug-orig/graphics/CVS/Repository ug-patched/graphics/CVS/Repository
--- ug-orig/graphics/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/graphics
diff -ruN ug-orig/graphics/CVS/Root ug-patched/graphics/CVS/Root
--- ug-orig/graphics/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/graphics/CVS/Tag ug-patched/graphics/CVS/Tag
--- ug-orig/graphics/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/graphics/.cvsignore ug-patched/graphics/.cvsignore
--- ug-orig/graphics/.cvsignore	2004-09-08 16:14:17.000000000 +0200
+++ ug-patched/graphics/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/graphics/grape/connectuggrape.h ug-patched/graphics/grape/connectuggrape.h
--- ug-orig/graphics/grape/connectuggrape.h	2006-05-08 14:29:21.000000000 +0200
+++ ug-patched/graphics/grape/connectuggrape.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/grape/connectuggrape.h,v 1.9 2006/05/08 12:29:21 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/grape/connectuggrapeOFF.c ug-patched/graphics/grape/connectuggrapeOFF.c
--- ug-orig/graphics/grape/connectuggrapeOFF.c	2006-06-02 17:35:52.000000000 +0200
+++ ug-patched/graphics/grape/connectuggrapeOFF.c	2006-06-02 17:38:35.000000000 +0200
@@ -43,7 +43,7 @@
 USING_UG_NAMESPACES
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/grape/connectuggrapeOFF.c,v 1.12 2006/06/02 15:35:52 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 
diff -ruN ug-orig/graphics/grape/connectuggrapeON.c ug-patched/graphics/grape/connectuggrapeON.c
--- ug-orig/graphics/grape/connectuggrapeON.c	2006-06-02 18:21:18.000000000 +0200
+++ ug-patched/graphics/grape/connectuggrapeON.c	2009-04-29 14:30:36.000000000 +0200
@@ -277,7 +277,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/grape/connectuggrapeON.c,v 1.9 2006/06/02 16:21:18 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -1268,7 +1268,7 @@
 	return (ret);
 }
 
-int NS_PREFIX CallGrape (MULTIGRID *theMG)
+int NS_DIM_PREFIX CallGrape (MULTIGRID *theMG)
 { 
 	static HMESH *mesh;
 	int i,j;
diff -ruN ug-orig/graphics/grape/CVS/Entries ug-patched/graphics/grape/CVS/Entries
--- ug-orig/graphics/grape/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/grape/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:16 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:11 2004//D2008.11.12.23.00.00
-/Makefile.grape/1.6/Thu Nov 14 13:56:22 1996//D2008.11.12.23.00.00
-/connectuggrape.h/1.9/Mon May  8 12:29:21 2006//D2008.11.12.23.00.00
-/connectuggrapeOFF.c/1.12/Fri Jun  2 15:35:52 2006//D2008.11.12.23.00.00
-/connectuggrapeON.c/1.9/Fri Jun  2 16:21:18 2006//D2008.11.12.23.00.00
-/defs.h/1.3/Fri Jul 18 14:59:15 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/graphics/grape/CVS/Repository ug-patched/graphics/grape/CVS/Repository
--- ug-orig/graphics/grape/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/grape/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/graphics/grape
diff -ruN ug-orig/graphics/grape/CVS/Root ug-patched/graphics/grape/CVS/Root
--- ug-orig/graphics/grape/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/grape/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/graphics/grape/CVS/Tag ug-patched/graphics/grape/CVS/Tag
--- ug-orig/graphics/grape/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/grape/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/graphics/grape/.cvsignore ug-patched/graphics/grape/.cvsignore
--- ug-orig/graphics/grape/.cvsignore	2004-09-08 16:14:16.000000000 +0200
+++ ug-patched/graphics/grape/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/graphics/grape/defs.h ug-patched/graphics/grape/defs.h
--- ug-orig/graphics/grape/defs.h	1997-07-18 16:59:15.000000000 +0200
+++ ug-patched/graphics/grape/defs.h	1997-07-18 17:00:14.000000000 +0200
@@ -1,7 +1,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/grape/defs.h,v 1.3 1997/07/18 14:59:15 birken Exp $
+$Header$
 */
 
 #define LIST_LEN 200 
diff -ruN ug-orig/graphics/grape/Makefile.am ug-patched/graphics/grape/Makefile.am
--- ug-orig/graphics/grape/Makefile.am	2004-09-02 14:22:11.000000000 +0200
+++ ug-patched/graphics/grape/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:11 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 if BUILD2D
   LIB_2D = libuggrape2.la
diff -ruN ug-orig/graphics/graphics.c ug-patched/graphics/graphics.c
--- ug-orig/graphics/graphics.c	2004-07-21 11:21:44.000000000 +0200
+++ ug-patched/graphics/graphics.c	2008-12-19 11:13:29.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -96,7 +97,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/graphics.c,v 1.6 2004/07/21 09:21:44 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/graphics.h ug-patched/graphics/graphics.h
--- ug-orig/graphics/graphics.h	2006-05-08 14:29:20.000000000 +0200
+++ ug-patched/graphics/graphics.h	2006-05-08 14:31:31.000000000 +0200
@@ -26,7 +26,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/graphics.h,v 1.6 2006/05/08 12:29:20 sander Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/graphics/Makefile.am ug-patched/graphics/Makefile.am
--- ug-orig/graphics/Makefile.am	2004-09-02 14:22:10.000000000 +0200
+++ ug-patched/graphics/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:10 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
 SUBDIRS = uggraph grape
 
@@ -28,5 +28,6 @@
 libgraphics3_la_LIBADD = uggraph/libuggraph3.la \
                          grape/libuggrape3.la
 
-include_HEADERS = graphics.h
+graphicsincludedir = $(pkgincludedir)
+graphicsinclude_HEADERS = graphics.h
 
diff -ruN ug-orig/graphics/pv3/CVS/Entries ug-patched/graphics/pv3/CVS/Entries
--- ug-orig/graphics/pv3/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/pv3/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:17 2004//D2008.11.12.23.00.00
-/Makefile.pv3/1.1/Thu Feb  6 14:12:27 2003//D2008.11.12.23.00.00
-/pv3if.c/1.3/Fri Oct  8 15:41:03 2004//D2008.11.12.23.00.00
-/pv3if.h/1.1/Thu Feb  6 14:12:27 2003//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/graphics/pv3/CVS/Repository ug-patched/graphics/pv3/CVS/Repository
--- ug-orig/graphics/pv3/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/pv3/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/graphics/pv3
diff -ruN ug-orig/graphics/pv3/CVS/Root ug-patched/graphics/pv3/CVS/Root
--- ug-orig/graphics/pv3/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/pv3/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/graphics/pv3/CVS/Tag ug-patched/graphics/pv3/CVS/Tag
--- ug-orig/graphics/pv3/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/pv3/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/graphics/pv3/.cvsignore ug-patched/graphics/pv3/.cvsignore
--- ug-orig/graphics/pv3/.cvsignore	2004-09-08 16:14:17.000000000 +0200
+++ ug-patched/graphics/pv3/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/graphics/pv3/pv3if.c ug-patched/graphics/pv3/pv3if.c
--- ug-orig/graphics/pv3/pv3if.c	2004-10-08 17:41:03.000000000 +0200
+++ ug-patched/graphics/pv3/pv3if.c	2008-12-19 11:13:29.000000000 +0100
@@ -27,6 +27,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <pV3.h>
 
diff -ruN ug-orig/graphics/uggraph/bullet.c ug-patched/graphics/uggraph/bullet.c
--- ug-orig/graphics/uggraph/bullet.c	2005-07-18 15:41:11.000000000 +0200
+++ ug-patched/graphics/uggraph/bullet.c	2008-12-19 11:13:29.000000000 +0100
@@ -31,6 +31,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "bullet.h"
 #include "ugdevices.h"
 #include "commands.h"
@@ -46,7 +47,7 @@
 USING_UG_NAMESPACES
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/bullet.c,v 1.19 2005/07/18 13:41:11 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/uggraph/bullet.h ug-patched/graphics/uggraph/bullet.h
--- ug-orig/graphics/uggraph/bullet.h	2006-05-08 14:29:21.000000000 +0200
+++ ug-patched/graphics/uggraph/bullet.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/bullet.h,v 1.10 2006/05/08 12:29:21 sander Exp $
+$Header$
  */
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/uggraph/CVS/Entries ug-patched/graphics/uggraph/CVS/Entries
--- ug-orig/graphics/uggraph/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/uggraph/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:17 2004//D2008.11.12.23.00.00
-/2Dversion/1.1/Fri Nov 10 21:05:55 1995//D2008.11.12.23.00.00
-/3Dversion/1.1/Fri Nov 10 21:06:05 1995//D2008.11.12.23.00.00
-/GRAPH.doc/1.1.1.1/Fri Sep 15 16:53:57 1995//D2008.11.12.23.00.00
-/Makefile.am/1.3/Tue Jan 18 18:20:48 2005//D2008.11.12.23.00.00
-/Makefile.uggraph/1.11/Wed Oct 20 12:35:37 2004//D2008.11.12.23.00.00
-/bullet.c/1.19/Mon Jul 18 13:41:11 2005//D2008.11.12.23.00.00
-/bullet.h/1.10/Mon May  8 12:29:21 2006//D2008.11.12.23.00.00
-/graph.c/1.22/Mon Jul 18 13:41:11 2005//D2008.11.12.23.00.00
-/graph.doc/1.4/Fri Jan  3 13:13:36 1997//D2008.11.12.23.00.00
-/graph.h/1.13/Mon May  8 12:29:21 2006//D2008.11.12.23.00.00
-/graph.make/1.2/Wed Nov 15 18:47:52 1995//D2008.11.12.23.00.00
-/initgraph.c/1.12/Mon Aug  8 08:46:58 2005//D2008.11.12.23.00.00
-/initgraph.h/1.6/Mon May  8 12:29:21 2006//D2008.11.12.23.00.00
-/iso.c/1.13/Tue Mar 18 12:58:24 2008//D2008.11.12.23.00.00
-/iso.h/1.7/Mon Mar  3 15:58:50 2008//D2008.11.12.23.00.00
-/pixel.h/1.1/Tue Nov  2 10:35:35 2004//D2008.11.12.23.00.00
-/placer.c/1.11/Wed Jul 21 09:21:45 2004//D2008.11.12.23.00.00
-/ploteval.c/1.4/Thu Nov 16 15:55:02 1995//D2008.11.12.23.00.00
-/ploteval.h/1.3/Wed Nov 15 18:47:55 1995//D2008.11.12.23.00.00
-/plotproc.c/1.22/Fri Jun  2 15:35:22 2006//D2008.11.12.23.00.00
-/plotproc.h/1.4/Mon May  8 12:29:21 2006//D2008.11.12.23.00.00
-/wop.c/1.245/Mon Mar  3 15:59:47 2008//D2008.11.12.23.00.00
-/wop.csave/1.122/Thu Aug 14 10:11:35 1997//D2008.11.12.23.00.00
-/wop.h/1.31/Fri Apr  4 11:46:36 2008//D2008.11.12.23.00.00
-/wpm.c/1.101/Tue Mar 18 13:00:18 2008//D2008.11.12.23.00.00
-/wpm.h/1.59/Tue Mar 18 13:00:18 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/graphics/uggraph/CVS/Repository ug-patched/graphics/uggraph/CVS/Repository
--- ug-orig/graphics/uggraph/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/uggraph/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/graphics/uggraph
diff -ruN ug-orig/graphics/uggraph/CVS/Root ug-patched/graphics/uggraph/CVS/Root
--- ug-orig/graphics/uggraph/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/uggraph/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/graphics/uggraph/CVS/Tag ug-patched/graphics/uggraph/CVS/Tag
--- ug-orig/graphics/uggraph/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/graphics/uggraph/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/graphics/uggraph/.cvsignore ug-patched/graphics/uggraph/.cvsignore
--- ug-orig/graphics/uggraph/.cvsignore	2004-09-08 16:14:17.000000000 +0200
+++ ug-patched/graphics/uggraph/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/graphics/uggraph/graph.c ug-patched/graphics/uggraph/graph.c
--- ug-orig/graphics/uggraph/graph.c	2005-07-18 15:41:11.000000000 +0200
+++ ug-patched/graphics/uggraph/graph.c	2008-12-19 11:13:29.000000000 +0100
@@ -26,6 +26,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -96,7 +97,7 @@
 static char buffer[256];						/* general purpose text buff*/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/graph.c,v 1.22 2005/07/18 13:41:11 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/uggraph/graph.h ug-patched/graphics/uggraph/graph.h
--- ug-orig/graphics/uggraph/graph.h	2006-05-08 14:29:21.000000000 +0200
+++ ug-patched/graphics/uggraph/graph.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/graph.h,v 1.13 2006/05/08 12:29:21 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/uggraph/initgraph.c ug-patched/graphics/uggraph/initgraph.c
--- ug-orig/graphics/uggraph/initgraph.c	2005-08-08 10:46:58.000000000 +0200
+++ ug-patched/graphics/uggraph/initgraph.c	2008-12-19 11:13:29.000000000 +0100
@@ -27,6 +27,7 @@
 /****************************************************************************/
 
 /* ANSI-C includes */
+#include "config.h"
 #include <stdio.h>
 
 /* low module */
@@ -52,7 +53,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/initgraph.c,v 1.12 2005/08/08 08:46:58 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*
diff -ruN ug-orig/graphics/uggraph/initgraph.h ug-patched/graphics/uggraph/initgraph.h
--- ug-orig/graphics/uggraph/initgraph.h	2006-05-08 14:29:21.000000000 +0200
+++ ug-patched/graphics/uggraph/initgraph.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/initgraph.h,v 1.6 2006/05/08 12:29:21 sander Exp $
+$Header$
 */
 
 #ifndef __INITGRAPH__
diff -ruN ug-orig/graphics/uggraph/iso.c ug-patched/graphics/uggraph/iso.c
--- ug-orig/graphics/uggraph/iso.c	2008-03-18 13:58:24.000000000 +0100
+++ ug-patched/graphics/uggraph/iso.c	2008-12-19 11:13:29.000000000 +0100
@@ -13,7 +13,8 @@
 /*																			*/
 /* History:   30.10.04 begin, ug3-version                                   */
 /*																			*/
-/* Remarks:                                                                 */
+/* Remarks:   Simple version that just decomposes hexahedra into 6 pyramids */
+/*            and then into 12 tetrahedra.                                  */
 /*                                                                          */
 /****************************************************************************/
 
@@ -25,11 +26,10 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <limits.h>
 #include <assert.h>
-#include <math.h>
-#include <float.h>
 #include "general.h"
 #include "iso.h"
 
@@ -53,11 +53,11 @@
 /*																			*/
 /****************************************************************************/
 
-static signed char Pyr[2][8] = {
+static int Pyr[2][8] = {
 	{0, 1, 2, 4, 0, 2, 3, 4},
 	{0, 1, 3, 4, 1, 2, 3, 4}};
 
-static signed char Pri[8][12] = {
+static int Pri[8][12] = {
 	{0, 4, 5, 3, 1, 4, 2, 0, 4, 5, 2, 0},
 	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 	{0, 4, 5, 3, 1, 4, 5, 0, 1, 5, 2, 0},
@@ -67,182 +67,100 @@
 	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 	{1, 5, 3, 4, 0, 2, 3, 1, 2, 5, 3, 1}};
 
-static signed char Hex[64][24] = {
-	{0, 4, 5, 6, 0, 7, 4, 6, 1, 0, 5, 6, 0, 1, 2, 6, 2, 3, 0, 6, 3, 6, 7, 0},
-	{0, 4, 5, 6, 0, 7, 4, 6, 1, 0, 5, 6, 0, 1, 2, 6, 2, 3, 0, 7, 2, 6, 7, 0},
-	{7, 6, 4, 0, 6, 7, 3, 0, 6, 5, 4, 1, 4, 1, 0, 6, 3, 2, 6, 0, 2, 0, 1, 6},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 4, 5, 6, 0, 7, 4, 6, 2, 5, 6, 0, 0, 1, 2, 5, 2, 3, 0, 6, 3, 6, 7, 0},
-	{0, 4, 5, 6, 0, 7, 4, 6, 2, 5, 6, 0, 0, 1, 2, 5, 2, 3, 0, 7, 2, 6, 7, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{2, 6, 7, 4, 2, 5, 6, 4, 0, 7, 4, 2, 2, 3, 0, 7, 0, 1, 2, 4, 1, 4, 5, 2},
-	{6, 5, 4, 0, 6, 1, 5, 0, 3, 4, 0, 6, 6, 7, 3, 4, 3, 2, 6, 0, 2, 0, 1, 6},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 2, 3, 4, 1, 0, 4, 2, 6, 3, 2, 4, 4, 7, 6, 3, 4, 5, 1, 6, 1, 6, 2, 4},
-	{4, 7, 6, 2, 4, 3, 7, 2, 1, 6, 2, 4, 4, 5, 1, 6, 1, 0, 4, 2, 0, 2, 3, 4},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{2, 6, 7, 4, 2, 5, 6, 4, 3, 2, 7, 4, 2, 3, 0, 4, 0, 1, 2, 5, 0, 4, 5, 2},
-	{5, 4, 6, 2, 4, 5, 1, 2, 4, 7, 6, 3, 6, 3, 2, 4, 1, 0, 4, 2, 0, 2, 3, 4},
-	{2, 6, 7, 4, 2, 5, 6, 4, 3, 2, 7, 4, 2, 3, 0, 4, 0, 1, 2, 4, 1, 4, 5, 2},
-	{1, 0, 5, 6, 0, 1, 2, 6, 0, 4, 5, 7, 5, 7, 6, 0, 2, 3, 0, 6, 3, 6, 7, 0},
-	{1, 0, 5, 6, 0, 1, 2, 6, 0, 4, 5, 7, 5, 7, 6, 0, 2, 3, 0, 7, 2, 6, 7, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{7, 6, 5, 1, 7, 2, 6, 1, 4, 7, 5, 1, 7, 4, 0, 1, 0, 3, 7, 2, 0, 1, 2, 7},
-	{3, 6, 7, 0, 2, 3, 0, 6, 5, 7, 6, 0, 0, 4, 5, 7, 0, 1, 2, 5, 2, 5, 6, 0},
-	{0, 1, 2, 5, 2, 3, 0, 7, 0, 5, 2, 7, 0, 4, 5, 7, 2, 5, 6, 7,-1,-1,-1,-1},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 4, 5, 2, 0, 1, 2, 4, 7, 5, 4, 2, 2, 6, 7, 5, 2, 3, 0, 7, 0, 7, 4, 2},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{5, 4, 7, 3, 5, 0, 4, 3, 6, 5, 7, 3, 5, 6, 2, 3, 2, 1, 5, 0, 2, 3, 0, 5},
-	{3, 2, 7, 4, 2, 3, 0, 4, 2, 6, 7, 5, 7, 5, 4, 2, 0, 1, 2, 5, 0, 4, 5, 2},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{3, 2, 7, 4, 2, 3, 0, 4, 2, 6, 7, 5, 7, 5, 4, 2, 0, 1, 2, 4, 1, 4, 5, 2},
-	{6, 5, 4, 0, 6, 1, 5, 0, 7, 6, 4, 0, 6, 7, 3, 0, 3, 2, 6, 1, 3, 0, 1, 6},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 7, 4, 1, 3, 0, 1, 7, 6, 4, 7, 1, 1, 5, 6, 4, 1, 2, 3, 6, 3, 6, 7, 1},
-	{2, 1, 6, 7, 1, 2, 3, 7, 1, 5, 6, 4, 6, 4, 7, 1, 3, 0, 1, 7, 0, 7, 4, 1},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{0, 3, 4, 5, 3, 0, 1, 5, 3, 7, 4, 6, 4, 6, 5, 3, 1, 2, 3, 6, 1, 5, 6, 3},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 2, 3, 6, 3, 0, 1, 4, 1, 6, 3, 4, 1, 5, 6, 4, 3, 6, 7, 4,-1,-1,-1,-1},
-	{2, 1, 6, 7, 1, 2, 3, 7, 1, 5, 6, 4, 6, 4, 7, 1, 3, 0, 1, 4, 3, 7, 4, 1},
-	{0, 3, 4, 5, 3, 0, 1, 5, 3, 7, 4, 6, 4, 6, 5, 3, 1, 2, 3, 5, 2, 5, 6, 3},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{2, 5, 6, 3, 1, 2, 3, 5, 4, 6, 5, 3, 3, 7, 4, 6, 3, 0, 1, 4, 1, 4, 5, 3},
-	{4, 7, 6, 2, 4, 3, 7, 2, 5, 4, 6, 2, 4, 5, 1, 2, 1, 0, 4, 3, 1, 2, 3, 4},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{7, 6, 5, 1, 7, 2, 6, 1, 0, 5, 1, 7, 7, 4, 0, 5, 0, 3, 7, 1, 3, 1, 2, 7},
-	{1, 5, 6, 7, 1, 4, 5, 7, 3, 6, 7, 1, 1, 2, 3, 6, 3, 0, 1, 7, 0, 7, 4, 1},
-	{1, 5, 6, 7, 1, 4, 5, 7, 2, 1, 6, 7, 1, 2, 3, 7, 3, 0, 1, 7, 0, 7, 4, 1},
-	{6, 5, 7, 3, 5, 6, 2, 3, 5, 4, 7, 0, 7, 0, 3, 5, 2, 1, 5, 3, 1, 3, 0, 5},
-	{1, 3, 0, 5, 2, 1, 5, 3, 7, 0, 3, 5, 5, 4, 7, 0, 5, 6, 2, 7, 2, 7, 3, 5},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{4, 7, 5, 1, 7, 4, 0, 1, 7, 6, 5, 2, 5, 2, 1, 7, 0, 3, 7, 1, 3, 1, 2, 7},
-	{3, 7, 4, 5, 3, 6, 7, 5, 0, 3, 4, 5, 3, 0, 1, 5, 1, 2, 3, 6, 1, 5, 6, 3},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 5, 6, 7, 1, 4, 5, 7, 3, 6, 7, 1, 1, 2, 3, 6, 3, 0, 1, 4, 3, 7, 4, 1},
-	{1, 5, 6, 7, 1, 4, 5, 7, 2, 1, 6, 7, 1, 2, 3, 7, 3, 0, 1, 4, 3, 7, 4, 1},
-	{3, 7, 4, 5, 3, 6, 7, 5, 0, 3, 4, 5, 3, 0, 1, 5, 1, 2, 3, 5, 2, 5, 6, 3},
-	{5, 4, 7, 3, 5, 0, 4, 3, 2, 7, 3, 5, 5, 6, 2, 7, 2, 1, 5, 3, 1, 3, 0, 5},
-	{3, 7, 4, 5, 3, 6, 7, 5, 1, 4, 5, 3, 3, 0, 1, 4, 1, 2, 3, 5, 2, 5, 6, 3},
-	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
-
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/iso.c,v 1.13 2008/03/18 12:58:24 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
+
 
-static int Interpolate(double *x, TET *tet, double lambda, int i, int j)
+static void Interpolate(double *x, TET *tet, double lambda, int i, int j)
 {
-	double t, d;
-	
-	d = tet->v[j]-tet->v[i];
-	if (fabs(d) <= 5.0*(fabs(tet->v[i])+fabs(tet->v[j]))*DBL_EPSILON)
-		t = 0.5;
-	else
-		t = (lambda-tet->v[i])/d;
+	double t = (lambda-tet->v[i])/(tet->v[j]-tet->v[i]);
 
 	x[0] = tet->x[i][0]+t*(tet->x[j][0]-tet->x[i][0]);
 	x[1] = tet->x[i][1]+t*(tet->x[j][1]-tet->x[i][1]);
 	x[2] = tet->x[i][2]+t*(tet->x[j][2]-tet->x[i][2]);
-
-	if (fabs(t) <= 10.0*DBL_EPSILON)
-	    return -1;
-	if (fabs(1.0-t) <= 10.0*DBL_EPSILON)
-	    return 1;	
-	return 0;
 }
 
 static void ExtractTet(TET *tet, double lambda, POLY *poly)
 {
-	int c = 0, d = 0, n = 0, d1, d2, d3, d4;
+	int index = 0;
 
-	if (tet->v[0] >= lambda) c |= 1;
-	if (tet->v[1] >= lambda) c |= 2;
-	if (tet->v[2] >= lambda) c |= 4;
-	if (tet->v[3] >= lambda) c |= 8;
+	if (tet->v[0] >= lambda) index |= 1;
+	if (tet->v[1] >= lambda) index |= 2;
+	if (tet->v[2] >= lambda) index |= 4;
+	if (tet->v[3] >= lambda) index |= 8;
 
-	switch(c)
+	switch (index)
 	{
 	case 0x01:
 	case 0x0E:
-	    if (Interpolate(poly->x[0], tet, lambda, 0, 1) < 0) d++;
-	    if (Interpolate(poly->x[1], tet, lambda, 0, 2) < 0) d++;
-	    if (Interpolate(poly->x[2], tet, lambda, 0, 3) < 0) d++;
-		if  (d <= 1) n = 3;
+		Interpolate(poly->x[0], tet, lambda, 0, 1);
+		Interpolate(poly->x[1], tet, lambda, 0, 2);
+		Interpolate(poly->x[2], tet, lambda, 0, 3);
+		poly->n = 3;
 		break;
 	case 0x02:
 	case 0x0D:
-	    if (Interpolate(poly->x[0], tet, lambda, 1, 0) < 0) d++;
-	    if (Interpolate(poly->x[1], tet, lambda, 1, 2) < 0) d++;
-	    if (Interpolate(poly->x[2], tet, lambda, 1, 3) < 0) d++;
-		if (d <= 1) n = 3;
+		Interpolate(poly->x[0], tet, lambda, 1, 0);
+		Interpolate(poly->x[1], tet, lambda, 1, 2);
+		Interpolate(poly->x[2], tet, lambda, 1, 3);
+		poly->n = 3;
 		break;
 	case 0x03:
 	case 0x0C:
-		d1 = Interpolate(poly->x[n++], tet, lambda, 0, 2);
-		d2 = Interpolate(poly->x[n],   tet, lambda, 1, 2);
-		if (d1 <= 0 || d2 <= 0) n++;
-		d3 = Interpolate(poly->x[n],   tet, lambda, 1, 3);
-		if (d2 >= 0 || d3 >= 0) n++;
-		d4 = Interpolate(poly->x[n],   tet, lambda, 0, 3);
-		if ((d3 <= 0 || d4 <= 0) && (d1 >= 0 || d4 >= 0)) n++;
+		Interpolate(poly->x[0], tet, lambda, 0, 2);
+		Interpolate(poly->x[1], tet, lambda, 1, 2);
+		Interpolate(poly->x[2], tet, lambda, 1, 3);
+		Interpolate(poly->x[3], tet, lambda, 0, 3);
+		poly->n = 4;
 		break;
 	case 0x04:
 	case 0x0B:
-	    if (Interpolate(poly->x[0], tet, lambda, 0, 2) > 0) d++;
-		if (Interpolate(poly->x[1], tet, lambda, 1, 2) > 0) d++;
-		if (Interpolate(poly->x[2], tet, lambda, 2, 3) < 0) d++;
-		if (d <= 1) n = 3;
+		Interpolate(poly->x[0], tet, lambda, 0, 2);
+		Interpolate(poly->x[1], tet, lambda, 1, 2);
+		Interpolate(poly->x[2], tet, lambda, 2, 3);
+		poly->n = 3;
 		break;
 	case 0x05:
 	case 0x0A:
-		d1 = Interpolate(poly->x[n++], tet, lambda, 0, 1);
-		d2 = Interpolate(poly->x[n],   tet, lambda, 1, 2);
-		if (d1 <= 0 || d2 >= 0) n++; 
-		d3 = Interpolate(poly->x[n],   tet, lambda, 2, 3);
-		if (d2 <= 0 || d3 >= 0) n++;
-		d4 = Interpolate(poly->x[n],   tet, lambda, 0, 3);
-		if ((d3 <= 0 || d4 <= 0) && (d1 >= 0 || d4 >= 0)) n++;
+		Interpolate(poly->x[0], tet, lambda, 0, 1);
+		Interpolate(poly->x[1], tet, lambda, 1, 2);
+		Interpolate(poly->x[2], tet, lambda, 2, 3);
+		Interpolate(poly->x[3], tet, lambda, 0, 3);
+		poly->n = 4;
 		break;
 	case 0x06:
 	case 0x09:
-		d1 = Interpolate(poly->x[n++], tet, lambda, 0, 1);
-		d2 = Interpolate(poly->x[n],   tet, lambda, 1, 3);
-		if (d1 <= 0 || d2 >= 0) n++;
-		d3 = Interpolate(poly->x[n],   tet, lambda, 2, 3);
-		if (d2 <= 0 || d3 <= 0) n++;
-		d4 = Interpolate(poly->x[n],   tet, lambda, 0, 2);
-		if ((d3 >= 0 || d4 <= 0) && (d1 >= 0 || d4 >= 0)) n++;
+		Interpolate(poly->x[0], tet, lambda, 0, 1);
+		Interpolate(poly->x[1], tet, lambda, 1, 3);
+		Interpolate(poly->x[2], tet, lambda, 2, 3);
+		Interpolate(poly->x[3], tet, lambda, 0, 2);
+		poly->n = 4;
 		break;
 	case 0x07:
 	case 0x08:
-	    if (Interpolate(poly->x[0], tet, lambda, 0, 3) > 0) d++;
-		if (Interpolate(poly->x[1], tet, lambda, 1, 3) > 0) d++;
-		if (Interpolate(poly->x[2], tet, lambda, 2, 3) > 0) d++;
-		if (d <= 1) n = 3;
+		Interpolate(poly->x[0], tet, lambda, 0, 3);
+		Interpolate(poly->x[1], tet, lambda, 1, 3);
+		Interpolate(poly->x[2], tet, lambda, 2, 3);
+		poly->n = 3;
 		break;
 	default:
-	    break;
+		poly->n = 0;
 	}
-	poly->n = (n >= 3) ? n:0;
 }
 
 static int SplitSide(CELL *cell, int i0, int i1, int i2, int i3)
 {
-	long long m1, m2;
-	int k1, k2;
+	int a[4], i, k, m;
 
-	if (cell->order[i0] < cell->order[i1]) { m1 = cell->order[i0]; k1 = 0; }
-	else                                   { m1 = cell->order[i1]; k1 = 1; }
-	if (cell->order[i2] < cell->order[i3]) { m2 = cell->order[i2]; k2 = 2; }
-	else                                   { m2 = cell->order[i3]; k2 = 3; }
-	if (m1 < m2) return k1;
-	else         return k2;
+	k = 0;
+	m = cell->order[i0];
+	a[0] = i0; a[1] = i1; a[2] = i2, a[3] = i3;
+	for (i = 1; i < 4; i++)
+		if (cell->order[a[i]] <= m) {
+			m = cell->order[a[i]];
+			k = i;
+		}
+	return a[k];
 }
 
 static int DecomposePyr(CELL *cell)
@@ -254,22 +172,28 @@
 {
 	return
 		((SplitSide(cell, 0, 1, 4, 3) & 1) << 0) |
-		((SplitSide(cell, 2, 1, 4, 5) & 1) << 1) |
-		((SplitSide(cell, 0, 2, 5, 3) & 1) << 2);
+		((SplitSide(cell, 1, 2, 5, 4) & 1) << 1) |
+		((SplitSide(cell, 2, 0, 3, 5) & 2) << 1);
 }
 
-static int DecomposeHex(CELL *cell)
+static void CenterNode(CELL *cell, double *xc, double *vc)
 {
-	return
-		((SplitSide(cell, 0, 1, 2, 3) & 1) << 5) |
-		((SplitSide(cell, 4, 5, 6, 7) & 1) << 4) |
-		((SplitSide(cell, 0, 3, 7, 4) & 1) << 3) |
-		((SplitSide(cell, 1, 2, 6, 5) & 1) << 2) |
-		((SplitSide(cell, 0, 1, 5, 4) & 1) << 1) |
-		((SplitSide(cell, 3, 2, 6, 7) & 1) << 0);
+	int i;
+
+	xc[0] = xc[1] = xc[2] = *vc = 0.0;
+	for (i = 0; i < cell->n; i++) {
+		xc[0] += cell->x[i][0];
+		xc[1] += cell->x[i][1];
+		xc[2] += cell->x[i][2];
+		*vc   += cell->v[i];
+	}
+	xc[0] /= cell->n;
+	xc[1] /= cell->n;
+	xc[2] /= cell->n;
+	*vc   /= cell->n;
 }
 
-static void CopyNodes(TET *tet, CELL *cell, signed char *t)
+static void CopyNodes(TET *tet, CELL *cell, int *t)
 {
 	int i;
 	
@@ -279,10 +203,35 @@
 	}
 }
 
+static void CopyNodes2(CELL *pyr, CELL *cell, int i0, int i1, int i2, int i3,
+					   double *xc, double vc)
+{
+	memcpy(pyr->x[0], cell->x[i0], 3*sizeof(double));
+	memcpy(pyr->x[1], cell->x[i1], 3*sizeof(double));
+	memcpy(pyr->x[2], cell->x[i2], 3*sizeof(double));
+	memcpy(pyr->x[3], cell->x[i3], 3*sizeof(double));
+	memcpy(pyr->x[4], xc,          3*sizeof(double));
+
+	pyr->v[0] = cell->v[i0];
+	pyr->v[1] = cell->v[i1];
+	pyr->v[2] = cell->v[i2];
+	pyr->v[3] = cell->v[i3];
+	pyr->v[4] = vc;
+	
+	pyr->order[0] = cell->order[i0];
+	pyr->order[1] = cell->order[i1];
+	pyr->order[2] = cell->order[i2];
+	pyr->order[3] = cell->order[i3];
+
+	pyr->n = 5;
+}
+
 void NS_DIM_PREFIX ExtractElement(CELL *cell, double lambda, POLY *poly, int *npoly)
 {
 	int k;
+	double xc[3], vc;
 	TET tet;
+	CELL pyr;
 
 	switch (cell->n)
 	{
@@ -311,24 +260,20 @@
 		*npoly = 3;
 		break;
 	case 8:
-		k = DecomposeHex(cell);
-		CopyNodes(&tet, cell, Hex[k]+  0);
-		ExtractTet(&tet, lambda, poly+ 0);
-		CopyNodes(&tet, cell, Hex[k]+  4);
-		ExtractTet(&tet, lambda, poly+ 1);
-		CopyNodes(&tet, cell, Hex[k]+  8);
-		ExtractTet(&tet, lambda, poly+ 2);
-		CopyNodes(&tet, cell, Hex[k]+ 12);
-		ExtractTet(&tet, lambda, poly+ 3);
-		CopyNodes(&tet, cell, Hex[k]+ 16);
-		ExtractTet(&tet, lambda, poly+ 4);
-		if (Hex[k][20] < 0)
-			*npoly = 5;
-		else {
-			CopyNodes(&tet, cell, Hex[k]+ 20);
-			ExtractTet(&tet, lambda, poly+ 5);
-			*npoly = 6;
-		}
+		CenterNode(cell, xc, &vc);
+		CopyNodes2(&pyr, cell, 0, 4, 5, 1, xc, vc);
+		ExtractElement(&pyr, lambda, poly+ 0, npoly);
+		CopyNodes2(&pyr, cell, 1, 5, 6, 2, xc, vc);
+		ExtractElement(&pyr, lambda, poly+ 2, npoly);
+		CopyNodes2(&pyr, cell, 2, 6, 7, 3, xc, vc);
+		ExtractElement(&pyr, lambda, poly+ 4, npoly);
+		CopyNodes2(&pyr, cell, 0, 3, 7, 4, xc, vc);
+		ExtractElement(&pyr, lambda, poly+ 6, npoly);
+		CopyNodes2(&pyr, cell, 0, 1, 2, 3, xc, vc);
+		ExtractElement(&pyr, lambda, poly+ 8, npoly);
+		CopyNodes2(&pyr, cell, 4, 7, 6, 5, xc, vc);
+		ExtractElement(&pyr, lambda, poly+10, npoly);
+		*npoly = 12;
 		break;
 	default:
 		assert(0);
diff -ruN ug-orig/graphics/uggraph/iso.h ug-patched/graphics/uggraph/iso.h
--- ug-orig/graphics/uggraph/iso.h	2008-03-03 16:58:50.000000000 +0100
+++ ug-patched/graphics/uggraph/iso.h	2006-05-08 14:31:31.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/iso.h,v 1.7 2008/03/03 15:58:50 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -44,7 +44,7 @@
 /*																			*/
 /****************************************************************************/
 
-#define MAXPOLY 6
+#define MAXPOLY 12
 
 /****************************************************************************/
 /*																			*/
@@ -54,15 +54,14 @@
 
 typedef struct {
 	int n;
-	long long order[8];
+	int order[8];
 	double x[8][3];
 	double v[8];
 } CELL;
 
 typedef struct {
 	int n;
-	double x[5][3];
-	long c;
+	double x[4][3]; 
 } POLY;
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/uggraph/Makefile.am ug-patched/graphics/uggraph/Makefile.am
--- ug-orig/graphics/uggraph/Makefile.am	2005-01-18 19:20:48.000000000 +0100
+++ ug-patched/graphics/uggraph/Makefile.am	2005-01-18 19:20:49.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.3 2005/01/18 18:20:48 thimo Exp $
+# $Id: Makefile.am 7936 2005-01-18 18:20:49Z thimo $
 
 if BUILD2D
   LIB_2D = libuggraph2.la
diff -ruN ug-orig/graphics/uggraph/pixel.h ug-patched/graphics/uggraph/pixel.h
--- ug-orig/graphics/uggraph/pixel.h	2004-11-02 11:35:35.000000000 +0100
+++ ug-patched/graphics/uggraph/pixel.h	2004-11-02 11:35:35.000000000 +0100
@@ -1,4 +1,4 @@
-/* $Id: pixel.h,v 1.1 2004/11/02 10:35:35 thimo Exp $ */
+/* $Id: pixel.h 7889 2004-11-02 10:35:35Z thimo $ */
 
 #ifndef UG_PIXEL_H
 #define UG_PIXEL_H
diff -ruN ug-orig/graphics/uggraph/placer.c ug-patched/graphics/uggraph/placer.c
--- ug-orig/graphics/uggraph/placer.c	2004-07-21 11:21:45.000000000 +0200
+++ ug-patched/graphics/uggraph/placer.c	2008-12-19 11:13:29.000000000 +0100
@@ -35,6 +35,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <math.h>
 #include <assert.h>
@@ -118,7 +119,7 @@
 
 /* RCS string */
 #ifdef INSIDE_UG
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/placer.c,v 1.11 2004/07/21 09:21:45 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 #endif
 
 
diff -ruN ug-orig/graphics/uggraph/ploteval.c ug-patched/graphics/uggraph/ploteval.c
--- ug-orig/graphics/uggraph/ploteval.c	1995-11-16 16:55:02.000000000 +0100
+++ ug-patched/graphics/uggraph/ploteval.c	2008-12-19 11:13:29.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -89,7 +90,7 @@
 static INT theElemVectorVarID;
 
 /* data for CVS */
-static char rcsid[] = "$Header: /home/cvsroot/UG/ug/graphics/uggraph/Attic/ploteval.c,v 1.4 1995/11/16 15:55:02 wieners Exp $";
+static char rcsid[] = "$Header$";
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/uggraph/plotproc.c ug-patched/graphics/uggraph/plotproc.c
--- ug-orig/graphics/uggraph/plotproc.c	2006-06-02 17:35:22.000000000 +0200
+++ ug-patched/graphics/uggraph/plotproc.c	2006-06-02 17:38:35.000000000 +0200
@@ -86,7 +86,7 @@
 static INT GradientFlag;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/plotproc.c,v 1.22 2006/06/02 15:35:22 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/uggraph/plotproc.h ug-patched/graphics/uggraph/plotproc.h
--- ug-orig/graphics/uggraph/plotproc.h	2006-05-08 14:29:21.000000000 +0200
+++ ug-patched/graphics/uggraph/plotproc.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/plotproc.h,v 1.4 2006/05/08 12:29:21 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/graphics/uggraph/wop.c ug-patched/graphics/uggraph/wop.c
--- ug-orig/graphics/uggraph/wop.c	2008-03-03 16:59:47.000000000 +0100
+++ ug-patched/graphics/uggraph/wop.c	2009-04-29 15:11:55.000000000 +0200
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -116,6 +117,14 @@
 /* values for CUTMODE */
 enum {CM_BEHIND, CM_INTERSECT, CM_INFRONT};
 
+static INT ce_ELEMORD;
+#define ELEMORD_LEN 					2
+#define ELEMORD(p)						CW_READ(p,ce_ELEMORD)
+#define SETELEMORD(p,n) 				CW_WRITE(p,ce_ELEMORD,n)
+
+/* values for ELEMORD */
+enum {NOTHING_DONE, VSIDES_DONE, ALL_DONE};
+
 /* Macros for Node order */
 #define NODE_ORDER(p) 		   ((TAG(theElement) == TETRAHEDRON) ? \
 								NORDER(theElement) : (NODEORD(p)) )
@@ -124,7 +133,7 @@
 #define SETBITS(x,p,y)         (((y)<<((p)+1-(3)))|(x))
 #define CORNER_OF_SIDE0(t,s,c) (element_descriptors[t]->corner_of_side[(s)][(c)])
 
-/* Macros for ordering remote sons and collecting coarse grid (parallel only) */
+/* Macrod for ordering remote sons and collecting coarse grid (parallel only) */
 #ifdef ModelP
 #define HT_LEN                31
 #define GLEN                  (1+(3+MAX_SIDES_OF_ELEM)*MAX_SONS)
@@ -155,7 +164,7 @@
 #define CGG_SIDE(k)           (CGG_BLINK(k)->side)
 #define CGG_FVS(k)            (CGG_BLINK(k)->viewableBSide)
 #define CGG_FHS(k)            (CGG_BLINK(k)->hiddenBSide)
-#define CGG_2INT(d)           (*(DDD_GID *)d)
+#define CGG_2INT(d)           (*(INT *) d)
 #endif
 
 /* Macros for extended shell algorithm */
@@ -278,11 +287,11 @@
 } BS_DATA;
 
 typedef struct {
-	DDD_GID      gid;
+	INT          gid;
 	INT          gap;
 	INT          cnt;
 	INT          nad;
-	DDD_GID      *adjacent;
+	INT          *adjacent;
 	BS_DATA      *blink;
 } CGG_DATA;
 
@@ -292,13 +301,13 @@
 	INT          hisGap;
 	INT          cnt;
 	INT          nad;
-	DDD_GID      *adjacent;
+	INT          *adjacent;
 } GR_DATA;
 
 typedef struct {
-	DDD_GID      htab[HT_LEN];
+	INT          htab[HT_LEN];
 	GR_DATA      *GR_Data[HT_LEN];
-	DDD_GID      *table;
+	INT          *table;
 } SH_DATA;
 
 typedef struct {
@@ -432,6 +441,9 @@
 /*----------- used by DrawPictureFrame -------------------------------------*/
 static INT DoFramePicture=YES;
 
+/*----------- used by OrderElements_3D -------------------------------------*/
+static BLOCK_ID wopMGUDid;
+
 /****************************************************************************/
 /************ variables used for communication of functions *****************/
 /****************************************************************************/
@@ -800,19 +812,13 @@
 
 /*---------- working variables of 'EW_Isosurface3D' -------------------------*/
 static ElementEvalProcPtr   Isosurface3D_EvalFct;
-static DOUBLE               Isosurface3D_lambda[MAX_ISOS];
-static INT                  Isosurface3D_NoIsos;
+static DOUBLE               Isosurface3D_lambda;
 static DOUBLE               Isosurface3D_Min;
 static DOUBLE               Isosurface3D_Max;
 static INT                  Isosurface3D_DomainBackFaces;
 static DOUBLE               Isosurface3D_AmbientLight;
-static long                 Isosurface3D_color[MAX_ISOS];
+static long                 Isosurface3D_color;
 static long                 Isosurface3D_backcolor;
-static CUT                  *Isosurface3D_Cut;
-static INT                  Isosurface3D_DepthCueing;
-static DOUBLE_VECTOR        Isosurface3D_zDir;
-static DOUBLE               Isosurface3D_z1;
-static DOUBLE               Isosurface3D_z2;
 
 /*---------- working variables of 'GetNode...' routines --------------------*/
 static MULTIGRID	*GNode_MG;
@@ -892,7 +898,7 @@
 static INT do_bullet;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/wop.c,v 1.245 2008/03/03 15:59:47 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -933,7 +939,7 @@
 D*/										
 /****************************************************************************/
 
-PLOTOBJHANDLING * NS_DIM_PREFIX CreatePlotObjHandling (char *PlotObjTypeName)
+PLOTOBJHANDLING * NS_DIM_PREFIX CreatePlotObjHandling (const char *PlotObjTypeName)
 {
 	PLOTOBJHANDLING *poh;
 	INT i;
@@ -1927,9 +1933,9 @@
 
 static ELEMENT *EW_GetFirstElement_vert_fw_up (MULTIGRID *theMG, INT fromLevel, INT toLevel)
 {
-	ELEMENT *theElement;
+        ELEMENT *theElement;
 #ifdef ModelP
-	ELEMENT *next;
+        ELEMENT *next;
 	INT i;
 #endif
 	
@@ -9054,9 +9060,9 @@
 		DO_2s(theDO) = EE2D_TEXTSIZE; DO_inc(theDO);
 		V2_COPY(MidPoint,DO_2Cp(theDO)); DO_inc_n(theDO,2);
 		#ifdef ModelP
-			sprintf(DO_2cp(theDO),"%d/%llx",
+			sprintf(DO_2cp(theDO),"%d/%x",
 				(int)ID(theElement),
-				(long long)EGID(theElement));
+				(long)EGID(theElement));
 			DO_inc_str(theDO);
 		#else
 			if (EE2D_Subdom && EE2D_ElemID)
@@ -9257,9 +9263,9 @@
 		DO_2Cp(theDO)[0]=Element_Z;
 		DO_inc(theDO);
 		#ifdef ModelP
-			sprintf(DO_2cp(theDO),"%d/%llx",
+			sprintf(DO_2cp(theDO),"%d/%x",
 				(int)ID(theElement),
-				(long long)EGID(theElement));
+				(long)EGID(theElement));
 			DO_inc_str(theDO);
 		#else
 			if (EE2D_Subdom && EE2D_ElemID)
@@ -9367,9 +9373,9 @@
 		DO_2s(theDO) = EE2D_TEXTSIZE; DO_inc(theDO);
 		V2_COPY(CVECT(MYVERTEX(theNode)),DO_2Cp(theDO)); DO_inc_n(theDO,2);
 		#ifdef ModelP
-			sprintf(DO_2cp(theDO),"%d/%llx",
+			sprintf(DO_2cp(theDO),"%d/%x",
 				(int)ID(theNode),
-				(long long)GID(theNode));
+				(long)GID(theNode));
 			DO_inc_str(theDO);
 		#else
 			sprintf(DO_2cp(theDO),"%d",(int)ID(theNode)); DO_inc_str(theDO);
@@ -9443,9 +9449,9 @@
 		DO_2s(theDO) = EE2D_TEXTSIZE; DO_inc(theDO);
 		V2_COPY(CVECT(MYVERTEX(NE_Node)),DO_2Cp(theDO)); DO_inc_n(theDO,2);
 		#ifdef ModelP
-			sprintf(DO_2cp(theDO),"%d/%llx",
+			sprintf(DO_2cp(theDO),"%d/%x",
 				(int)ID(NE_Node),
-				(long long)GID(NE_Node));
+				(long)GID(NE_Node));
 			DO_inc_str(theDO);
 		#else
 			sprintf(DO_2cp(theDO),"%d",(int)ID(NE_Node)); DO_inc_str(theDO);
@@ -13036,12 +13042,12 @@
 			DO_2s(theDO) = EE3D_TEXTSIZE; DO_inc(theDO);
 			V3_COPY(x[EE3D_PlotNode[j]],DO_2Cp(theDO)); DO_inc_n(theDO,3);
 			#ifdef ModelP
-				sprintf(DO_2cp(theDO),"%ld/%llx",
-						(long)ID(CORNER(theElement,EE3D_PlotNode[j])),
-						(long long)GID(CORNER(theElement,EE3D_PlotNode[j])));
+				sprintf(DO_2cp(theDO),"%d/%x",
+					(int)ID(CORNER(theElement,EE3D_PlotNode[j])),
+					(long)GID(CORNER(theElement,EE3D_PlotNode[j])));
 				DO_inc_str(theDO);
 			#else
-				sprintf(DO_2cp(theDO),"%ld",(long)ID(CORNER(theElement,EE3D_PlotNode[j]))); DO_inc_str(theDO);
+				sprintf(DO_2cp(theDO),"%d",(int)ID(CORNER(theElement,EE3D_PlotNode[j]))); DO_inc_str(theDO);
 			#endif
 		}
 	
@@ -15617,7 +15623,6 @@
 		if (ActualPosition == NewShellBegin) {
 			/* no regular shell, try to break up cycle */
 			for (wanted = 1; wanted <= 5; wanted++) {
-				UserWriteF("OrderSons: trying to break up a cycle, wanted=%d\n", wanted);
 				for (i = 0; i < NewShellBegin; i++) {
 					for (j=0; j<SIDES_OF_ELEM(table[i]); j++)
 					{
@@ -16182,7 +16187,7 @@
 
 #ifndef ModelP
 
-static int CompareIDs (const void *p, const void *q)
+static INT CompareIDs (const void *p, const void *q)
 {
     INT a, b;
 
@@ -16199,7 +16204,7 @@
 
 static int CompareGIDs(const void *p, const void *q)
 {
-	DDD_GID a, b;
+	INT a, b;
 
 	a = ((CGG_DATA *) p)->gid;
 	b = ((CGG_DATA *) q)->gid;
@@ -16597,10 +16602,9 @@
 
 #else
 
-static INT Gid2Index(DDD_GID gid)
+static INT Gid2Index(INT gid)
 {
-	INT l, r, m;
-	DDD_GID key;
+	INT l, r, m, key;
 
 	l = 0;
 	r = OE_nGlobalCGelems-1;
@@ -16814,7 +16818,6 @@
 		if (pos == newBegin) {
 			/* no regular shell, try to break up cycle */
 			for (wanted = 1; wanted <= 10; wanted++) {
-				UserWriteF("OrderFathers: trying to break up a cycle, wanted=%d\n", wanted);
 				for (i = 0; i < newBegin; i++) {
 					p = table[i];
 					for (j = 0; j < SIDES_OF_ELEM(p); j++) {
@@ -16872,10 +16875,10 @@
 
 static int compare_gid(const void *p, const void *q)
 {
-	DDD_GID gid1, gid2;
+	INT gid1, gid2;
 
-	gid1 = *(DDD_GID *)p;
-	gid2 = *(DDD_GID *)q;
+	gid1 = *(INT *)p;
+	gid2 = *(INT *)q;
 
 	if (gid1 < gid2)
 		return -1;
@@ -16884,7 +16887,7 @@
 	return 0;
 }
 
-static INT OrderFathersXSH (MULTIGRID *mg, DDD_GID *table)
+static INT OrderFathersXSH (MULTIGRID *mg, INT *table)
 {
 	HEAP *heap;
 	ILIST *h;
@@ -17001,7 +17004,6 @@
 		if (pos == newBegin) {
 			/* no regular shell, try to break up cycle */
 			for (wanted = 1; wanted <= 10; wanted++) {
-				UserWriteF("OrderFathers: trying to break up a cycle, wanted=%d\n", wanted);
 				for (i = 0; i < newBegin; i+=2) {
 					l = table[i];
 					for (j = 0; j < CGG_NAD(l); j++) {
@@ -17049,7 +17051,7 @@
 	}
 
 	/* sort list by gid */
-	qsort((void *)table, OE_nGlobalCGelems, 2*sizeof(DDD_GID), compare_gid);
+	qsort((void *)table, OE_nGlobalCGelems, 2*sizeof(INT), compare_gid);
 
 	return 0;
 }
@@ -17238,7 +17240,7 @@
 
 /* -------------------- a little hashing ---------------------------------- */
 
-static INT Lookup(DDD_GID *htab, DDD_GID gid)
+static INT Lookup(INT *htab, INT gid)
 {
 	INT i;
 
@@ -17248,7 +17250,7 @@
 	return i;
 }
 
-static INT Insert(DDD_GID *htab, DDD_GID gid)
+static INT Insert(INT *htab, INT gid)
 {
 	INT i;
 	
@@ -17284,11 +17286,10 @@
 static int GatherGraphs(DDD_OBJ obj, void *data)
 {
 	ELEMENT *p, *son, *nbElem, *sonList[MAX_SONS];
-	INT i, j, na, cnt; 
-	DDD_GID *d, *d1, *d2;
+	INT *d, *d1, *d2, i, j, na, cnt; 
 
 	p = (ELEMENT *)obj;
-	d = (DDD_GID *)data;
+	d = (INT *)data;
 
 	/* something to send? */
 	if (N_GLOBAL_SONS(p) == N_LOCAL_SONS(p) || N_LOCAL_SONS(p) == 0) {
@@ -17327,11 +17328,10 @@
 static int ScatterGraphs(DDD_OBJ obj, void *data)
 {
 	ELEMENT *p;
-	INT i, j, n, na;
-	DDD_GID *d, *d1, gid;
+	INT *d, *d1, i, j, n, na, gid;
 
 	p = (ELEMENT *)obj;
-	d = (DDD_GID *)data;
+	d = (INT *)data;
 	
 	/* got something? */
 	if (*d == 0) return 0;
@@ -17363,8 +17363,8 @@
 		CNT(p, i)      = *d;  d++;
 		NAD(p, i) = na = *d;  d++;
 		if (na > 0) {
-			if ((ADJACENT(p, i) = (DDD_GID *)GetTmpMem(OE_Heap, na*sizeof(DDD_GID), 
-												       OE_MarkKey)) == NULL) {
+			if ((ADJACENT(p, i) = (INT *)GetTmpMem(OE_Heap, na*sizeof(INT), 
+												   OE_MarkKey)) == NULL) {
 				OE_Error = 1;
 				return 0;
 			}
@@ -17383,7 +17383,7 @@
 	OE_Error = 0;
 	OE_MarkKey = MarkKey;
 	DDD_IFAOneway(ElementVIF, GRID_ATTR(theGrid), 
-				  IF_BACKWARD, GLEN*sizeof(DDD_GID),
+				  IF_BACKWARD, GLEN*sizeof(INT),
 				  GatherGraphs, ScatterGraphs);
 	return UG_GlobalMaxINT(OE_Error);
 }
@@ -17412,8 +17412,8 @@
 static INT OrderRemoteSons (ELEMENT *p, INT MarkKey)
 {
 	ELEMENT *sonList[MAX_SONS], *son, *nbElem, *pel[HT_LEN];
-	INT i, j, k, l, pos, lastBegin, newBegin, na, cnt, pid, wanted;
-	DDD_GID adjacent[HT_LEN][MAX_SIDES_OF_ELEM-1];
+	INT i, j, k, l, pos, lastBegin, newBegin, na, cnt, pid, wanted,
+		adjacent[HT_LEN][MAX_SIDES_OF_ELEM-1];
 
 	/* add local partial graph */
 	for (i = 0; i < HT_LEN; i++)
@@ -17441,7 +17441,7 @@
 		ADJACENT(p, k) = adjacent[k];
 	}
 
-	if ((TABLE(p) = (DDD_GID *)GetTmpMem(OE_Heap, N_GLOBAL_SONS(p)*sizeof(DDD_GID), MarkKey)) == NULL)
+	if ((TABLE(p) = (INT *)GetTmpMem(OE_Heap, N_GLOBAL_SONS(p)*sizeof(INT), MarkKey)) == NULL)
 		return 1;
 
 	/* find first shell */
@@ -17474,7 +17474,6 @@
 			if (pos == newBegin) {
 				/* no regular shell, try to break up cycle */
 				for (wanted = 1; wanted <= 5; wanted++) {
-					UserWriteF("OrderSons: trying to break up a cycle, wanted=%d\n", wanted);
 					for (i = 0; i < newBegin; i++) {
 						for (j = 0; j < NAD(p, k); j++) {
 							l = Lookup(HTAB(p), ADJACENT(p, k)[j]);
@@ -17538,11 +17537,10 @@
 static int GatherOrdering(DDD_OBJ obj, void *data) 
 {
 	ELEMENT *p;
-	INT i, k, pid;
-	DDD_GID *d, gid;
+	INT *d, i, k, pid, gid;
 
 	p = (ELEMENT *)obj;
-	d = (DDD_GID *)data;
+	d = (INT *)data;
 
 	/* something to send? */
 	if (SH_LINK(p) == NULL) return 0;
@@ -17563,11 +17561,10 @@
 static int ScatterOrdering(DDD_OBJ obj, void *data) 
 {
 	ELEMENT *p, *son, *sonList[MAX_SONS];
-	INT pid[HT_LEN], i, k;
-	DDD_GID *d, htab[HT_LEN], gid;
+	INT *d, htab[HT_LEN], pid[HT_LEN], gid, i, k;
 
 	p = (ELEMENT *)obj;
-	d = (DDD_GID *)data;
+	d = (INT *)data;
 
 	/* got something? */
 	if (N_LOCAL_SONS(p) == N_GLOBAL_SONS(p)) return 0;
@@ -17598,7 +17595,7 @@
 static void DistributeOrdering (GRID *theGrid)
 {
 	DDD_IFAOneway(ElementVIF, GRID_ATTR(theGrid), 
-				  IF_FORWARD, 2*MAX_SONS*sizeof(DDD_GID),
+				  IF_FORWARD, 2*MAX_SONS*sizeof(INT),
 				  GatherOrdering, ScatterOrdering);
 }
 
@@ -17715,7 +17712,7 @@
 
 static int cmp_gid(const void *p, const void *q) 
 {
-    DDD_GID gid1, gid2;
+    INT gid1, gid2;
     
 	gid1 = EGID(*((ELEMENT **)p));
     gid2 = EGID(*((ELEMENT **)q));
@@ -17727,10 +17724,9 @@
 	return 0;
 }
 
-static INT NumberCoarseGrid(DDD_GID *table, MULTIGRID *mg)
+static INT NumberCoarseGrid(INT *table, MULTIGRID *mg)
 {
-	INT i, j, err;
-	DDD_GID me;
+	INT i, j, me, err;
 	ELEMENT **mine, *p;
 	HEAP *heap;
 	INT MarkKey;
@@ -17888,7 +17884,7 @@
 						CGG_NAD(k) = na = CGG_2INT(d);  d++;
 						if (na > 0) {
 							if ((CGG_ADJACENT(k) = 
-								(DDD_GID *)GetTmpMem(heap, na*sizeof(DDD_GID), MarkKeyMaster)) == NULL){
+								(INT *)GetTmpMem(heap, na*sizeof(INT), MarkKeyMaster)) == NULL){
 								error = 1;
 								UserWrite("CollectCoarseGrid(): error in stage 1\n");
 								break;
@@ -18145,7 +18141,7 @@
 	INT MarkKeyMaster;
 	ELEMENT *p;
 	INT n;
-	DDD_GID *table;
+	INT *table;
 	#else
 	ELEMENT **table;
 	#endif
@@ -18163,7 +18159,7 @@
 	OE_nGlobalCGelems = n = UG_GlobalSumINT(n);
 
 	/* allocate memory for ordering list and coarse grid graph */
-	table  = (DDD_GID *)GetTmpMem(heap, 2*n*sizeof(DDD_GID), MarkKey);
+	table  = (INT *)GetTmpMem(heap, 2*n*sizeof(INT), MarkKey);
 	err = (table == NULL);
 	err = UG_GlobalMaxINT(err);
 	if (err) {
@@ -18237,7 +18233,7 @@
 	}
 	Broadcast(&err, sizeof(err));
 	if (err == 0) {
-		Broadcast(table, 2*n*sizeof(DDD_GID));
+		Broadcast(table, 2*n*sizeof(INT));
 		NumberCoarseGrid(table, mg);
 		DistributePlotIDs(GRID_ON_LEVEL(mg,0));
 	}
@@ -18269,9 +18265,29 @@
 */
 /****************************************************************************/
 
+static void SaveSettings (const VIEWEDOBJ *vo, WOP_MG_DATA *data)
+{
+	data->init = 1;
+	
+	V3_COPY(VO_VP(vo),data->vpt);
+	V3_COPY(VO_VT(vo),data->tgt);
+	V3_COPY(VO_PMP(vo),data->pmp);
+}
+
+static INT SettingsEqual (const VIEWEDOBJ *vo, const WOP_MG_DATA *data)
+{
+	if (V3_ISEQUAL(VO_VP(vo),data->vpt))
+		if (V3_ISEQUAL(VO_VT(vo),data->tgt))
+			if (V3_ISEQUAL(VO_PMP(vo),data->pmp))
+				return (YES);
+	return (NO);
+}
+
 static INT OrderElements_3D (MULTIGRID *mg, VIEWEDOBJ *vo, INT bullet)
 {
-	INT i;
+	WOP_MG_DATA *myMGdata;
+	MEM offset;
+	INT ord, i;
     #ifdef ModelP
 	HEAP *heap;
 	GRID *grid;
@@ -18280,6 +18296,35 @@
 	INT MarkKey;
     #endif
 
+/* Forget about this; it simply doesn't work -- at all */
+/*  -ml                                                */
+#if 0
+	/* check if multigrid is already ordered */
+	offset   = OFFSET_IN_MGUD(wopMGUDid);
+	myMGdata = (WOP_MG_DATA*) GEN_MGUD_ADR(mg, offset);
+	
+	if (myMGdata == NULL)
+		return 1;
+
+	if (myMGdata->init == 0)
+		/* not yet initialized */
+		SaveSettings(vo, myMGdata);
+	else if (!OE_force_ordering)
+	{
+		if (SettingsEqual(vo, myMGdata)) {
+			#ifdef ModelP
+			ord = UG_GlobalMinINT(ELEMORD(mg));
+			#else
+			ord = (ELEMORD(mg));
+			#endif
+			if (ord == ALL_DONE || bullet && ord == VSIDES_DONE)
+				return 0;
+		}
+	}
+	
+	OE_force_ordering = FALSE;
+#endif
+	
 	/* inits */
 	OE_ViewedObj = vo;
 		
@@ -18288,7 +18333,10 @@
 		CalcViewableSidesOnGrid(GRID_ON_LEVEL(mg,i));
 
 	/* no more to do for bullet plotter */
-	if (bullet) return 0;
+	if (bullet) {
+		/*SETELEMORD(mg, VSIDES_DONE);*/
+		return 0;
+	}
 
 	/* allocate memory for and compute OS_Data (parallel case only) */
 	#ifdef ModelP
@@ -18348,6 +18396,8 @@
 	}
 	#endif
 
+	/*SETELEMORD(mg, ALL_DONE);*/
+
 	return (0);
 }
 
@@ -20409,28 +20459,18 @@
  *   
  *---------------------------------------------------------------------------*/
 
-static INT MarkElementsIsosurfaceCuts(MULTIGRID *theMG,
-									  INT fromLevel, INT toLevel)
+static void MarkElementsIsosurfaceCuts(MULTIGRID *theMG,
+									   INT fromLevel, INT toLevel)
 {
 	ELEMENT *theElement;
 	NODE *theNode;
-	INT i, j, k, first;
+	INT i, j, first;
 	DOUBLE value, *CornersOfElem[MAX_CORNERS_OF_ELEM], LocalCoord[DIM];
 	
 	fromLevel = MAX(fromLevel,0);
 	toLevel = MIN(toLevel,CURRENTLEVEL(theMG));
 	
-	/* initialize node & element flags to zero */
-	for (i=fromLevel; i<=toLevel; i++)
-		for (theNode=FIRSTNODE(GRID_ON_LEVEL(theMG, i));
-			 theNode!=NULL;theNode=SUCCN(theNode))
-			EXTRA(theNode)=0;
-	for (i=fromLevel; i<=toLevel; i++)
-		for (theElement=FIRSTELEMENT(GRID_ON_LEVEL(theMG,i));
-			 theElement!=NULL; theElement=SUCCE(theElement))
-			EXTRA(theElement)=0;
-	
-	/* for each lambda flag surface element nodes 0/1 if value </>= lambda */
+	/* mark surface element nodes 0/1 if value </>= iso value */
 	for (i=fromLevel; i<=toLevel; i++)
 		for (theNode=FIRSTNODE(GRID_ON_LEVEL(theMG, i));
 			 theNode!=NULL;theNode=SUCCN(theNode))
@@ -20443,37 +20483,33 @@
 				for (j = 0; j < CORNERS_OF_ELEM(theElement); j++)
 					CornersOfElem[j] = CVECT(MYVERTEX(CORNER(theElement, j)));
 				for (j = 0; j < CORNERS_OF_ELEM(theElement); j++) {
-					theNode=CORNER(theElement, j);
-					if (USED(theNode)) continue;
-					SETUSED(theNode, 1);
+					if (USED(CORNER(theElement, j))) continue;
+					SETUSED(CORNER(theElement, j), 1);
 					LocalCornerCoordinates(DIM,TAG(theElement),j,LocalCoord);
 					value = (*Isosurface3D_EvalFct)
 						(theElement,(const DOUBLE**)CornersOfElem,LocalCoord);
-					for (k = 0; k < Isosurface3D_NoIsos; k++)
-						if (value >= Isosurface3D_lambda[k])
-							EXTRA(theNode) |= 1<<k;
+					if (value < Isosurface3D_lambda)
+						SETTHEFLAG(CORNER(theElement, j), 0);
+					else
+						SETTHEFLAG(CORNER(theElement, j), 1);
 				}
 			}
 		}
-		
+	
 	for (i=fromLevel; i<=toLevel; i++)
 		for (theElement=FIRSTELEMENT(GRID_ON_LEVEL(theMG,i));
 			 theElement!=NULL; theElement=SUCCE(theElement))
 		{
 			SETUSED(theElement, 0);
 			if (!IS_REFINED(theElement) || LEVEL(theElement) == toLevel) {
-				/* for each lambda flag surface elements that are cut */
-				for (k = 0; k < Isosurface3D_NoIsos; k++) {
-					first = EXTRA(CORNER(theElement, 0)) & (1<<k);
-					for (j = 1; j < CORNERS_OF_ELEM(theElement); j++)
-						if (first != (EXTRA(CORNER(theElement, j)) & (1<<k))) {
-							EXTRA(theElement) |= 1<<k;
-							break;
-						}
-				}
-				if (EXTRA(theElement))
-					SETUSED(theElement, 1);
-				/* mark surface elements with domain boundary back sides iff */
+				/* mark surface elements that have not all nodes marked equally */
+				first = THEFLAG(CORNER(theElement, 0));
+				for (j = 1; j < CORNERS_OF_ELEM(theElement); j++)
+					if (first != THEFLAG(CORNER(theElement, j))) {
+						SETUSED(theElement, 1);
+						break;
+					}
+				/* mark domain boundary back sides iff */
 				if (Isosurface3D_DomainBackFaces && OBJT(theElement)==BEOBJ)
 					for (j=0; j<SIDES_OF_ELEM(theElement); j++)
 						if (!INNER_SIDE(theElement,j) && !VIEWABLE(theElement,j)) {
@@ -20482,7 +20518,6 @@
 						}
 			}
 		}
-	return 0;
 }
 
 static INT EW_PreProcess_Isosurface3D(PICTURE *thePicture, WORK *theWork)
@@ -20490,54 +20525,33 @@
 	struct IsosurfacePlotobject3D *theIpo;
 	OUTPUTDEVICE *theOD;
 	MULTIGRID *theMG;
-	DOUBLE len;
-	INT k;
-
+	
 	theIpo = &(PIC_PO(thePicture)->theIpo);
 	theOD  = PIC_OUTPUTDEV(thePicture);
 	theMG  = PO_MG(PIC_PO(thePicture));
 
 	Isosurface3D_EvalFct         = theIpo->EvalFct->EvalProc;
-	memcpy(Isosurface3D_lambda, theIpo->lambda, MAX_ISOS*sizeof(DOUBLE));
-	Isosurface3D_NoIsos          = theIpo->NoIsos;
+	Isosurface3D_lambda          = theIpo->lambda;
 	Isosurface3D_Min             = theIpo->min;
 	Isosurface3D_Max             = theIpo->max;
 	Isosurface3D_DomainBackFaces = theIpo->DomainBackFaces;
 	Isosurface3D_AmbientLight    = theIpo->AmbientLight;
-	Isosurface3D_DepthCueing     = theIpo->DepthCueing;
-
+ 
 	/* colors */
-	for(k = 0; k < Isosurface3D_NoIsos; k++){
-		Isosurface3D_color[k]    = theOD->spectrumStart + 
-			(Isosurface3D_lambda[k]-Isosurface3D_Min)/(Isosurface3D_Max-Isosurface3D_Min)
-			*(theOD->spectrumEnd-theOD->spectrumStart);
-		Isosurface3D_color[k]    = MIN(Isosurface3D_color[k], theOD->spectrumEnd);
-		Isosurface3D_color[k]    = MAX(Isosurface3D_color[k], theOD->spectrumStart);
-	}
+	Isosurface3D_color           = theOD->spectrumStart
+		+(Isosurface3D_lambda-Isosurface3D_Min)/(Isosurface3D_Max-Isosurface3D_Min)
+		*(theOD->spectrumEnd-theOD->spectrumStart);
+	Isosurface3D_color           = MIN(Isosurface3D_color,theOD->spectrumEnd);
+	Isosurface3D_color           = MAX(Isosurface3D_color,theOD->spectrumStart);
 	Isosurface3D_backcolor       = theOD->gray;
 
-	/* remember cut */
-	Isosurface3D_Cut             = VO_CUT(PIC_VO(thePicture));
-
-	/* set some constants for depth cueing iff */
-	if (Isosurface3D_DepthCueing == YES) {
-		V3_SUBTRACT(PO_MIDPOINT(PIC_PO(thePicture)), VO_VP(PIC_VO(thePicture)),
-					Isosurface3D_zDir);
-		V3_SCALAR_PRODUCT(Isosurface3D_zDir, Isosurface3D_zDir, len);
-		len = sqrt(len);
-		V3_SCALE(1.0/len, Isosurface3D_zDir);
-		Isosurface3D_z1 = len - PO_RADIUS(PIC_PO(thePicture));
-		Isosurface3D_z2 = len + PO_RADIUS(PIC_PO(thePicture));
-	}
-
 	/* prepare evaluation routine */
 	if (theIpo->EvalFct->PreprocessProc != NULL)
-	    if ((*theIpo->EvalFct->PreprocessProc)(PO_NAME(theIpo),theMG))
+		if ((*theIpo->EvalFct->PreprocessProc)(PO_NAME(theIpo),theMG))
 			return 1;
 	
 	/* mark surface elements the isosurface cuts */
-	if (MarkElementsIsosurfaceCuts(theMG, 0, CURRENTLEVEL(theMG)))
-		return 1;
+	MarkElementsIsosurfaceCuts(theMG, 0, CURRENTLEVEL(theMG));
 	
 	return 0;
 }
@@ -20567,7 +20581,7 @@
 	return CompareQuadrilaterals(Triangle, ScreenPoint, Corners);
 }
 
-static void SortPolygons(POLY *poly, int npoly)
+static void SortPolygons(POLY *poly, INT npoly)
 {
 	/* This is a special version from ug/low/misc.c!! */
 	SelectionSort(poly, npoly, sizeof(POLY), ComparePolygons);
@@ -20575,133 +20589,42 @@
 
 static DOUBLE LightPolygon(POLY *poly)
 {
-	int i;
-	DOUBLE_VECTOR xcs, lightDir, edge1, edge2, normal, cmo;
-	DOUBLE cosa, scale1, scale2, fidc, lightz;
+	INT i;
+	DOUBLE xcs[3], lightDir[3], edge1[3], edge2[3], normal[3];
+	DOUBLE cosa, scale1, scale2;
 
-	/* from light source to center of polygon */
-	V3_CLEAR(xcs);
-	for (i = 0; i < poly->n; i++)
-	    V3_ADD(poly->x[i], xcs, xcs);
-	V3_SCALE(1.0/poly->n, xcs);
-	V3_SUBTRACT(xcs, VO_VP(OE_ViewedObj), cmo);
-
-	/* direction of light */
-	if (OBS_Perspective == YES)
-	    V3_COPY(cmo, lightDir)
+	/* light direction */
+	if (OBS_Perspective == YES) {
+		V3_CLEAR(xcs);
+		for (i = 0; i < poly->n; i++)
+			V3_ADD(poly->x[i], xcs, xcs);
+		V3_SCALE(1.0/poly->n, xcs);
+		V3_SUBTRACT(VO_VP(OE_ViewedObj), xcs, lightDir);
+	}
 	else
-	    V3_SUBTRACT(PO_MIDPOINT(VO_PO(OE_ViewedObj)), VO_VP(OE_ViewedObj), lightDir);
+		V3_SUBTRACT(VO_VP(OE_ViewedObj), VO_VT(OE_ViewedObj), lightDir);
 
 	/* polygon normal */
 	V3_SUBTRACT(poly->x[1], poly->x[0], edge1);
 	V3_SUBTRACT(poly->x[2], poly->x[0], edge2);
 	V3_VECTOR_PRODUCT(edge1, edge2, normal);
-
+	
 	/* face intensity */
 	V3_SCALAR_PRODUCT(lightDir, normal, cosa);
 	V3_SCALAR_PRODUCT(normal, normal, scale1);
 	V3_SCALAR_PRODUCT(lightDir, lightDir, scale2);
 	cosa = ABS(cosa)/sqrt(scale1*scale2);
-
-	/* factor for intensity depth-cueing */
-	if (Isosurface3D_DepthCueing == YES) {
-		V3_SCALAR_PRODUCT(cmo, Isosurface3D_zDir, lightz);
-		fidc = 1.0 - 0.85*(lightz - Isosurface3D_z1)/(Isosurface3D_z2 - Isosurface3D_z1);
-		fidc = MIN(fidc, 1.0);
-		fidc = MAX(fidc, 0.0);
-	}
-	else
-		fidc = 1.0;
-
-	return fidc*(Isosurface3D_AmbientLight + (1.0-Isosurface3D_AmbientLight)*cosa);
-}
-
-static int BehindCut(DOUBLE *x)
-{
-	DOUBLE_VECTOR xmp;
-	DOUBLE t;
-	
-	V3_SUBTRACT(x, CUT_PP(Isosurface3D_Cut), xmp);
-	V3_SCALAR_PRODUCT(xmp, CUT_PN(Isosurface3D_Cut), t);
-	if (t <= 0.0)
-		return 1;
-	else
-		return 0;
-}
-
-static int IntersectWithCut(DOUBLE *a, DOUBLE *b, DOUBLE *s)
-{
-	DOUBLE_VECTOR bma, pma;
-	DOUBLE lambda, t1, t2;
-	
-	V3_SUBTRACT(b, a, bma);
-	V3_SUBTRACT(CUT_PP(Isosurface3D_Cut), a, pma);
-	V3_SCALAR_PRODUCT(pma, CUT_PN(Isosurface3D_Cut), t1);
-	V3_SCALAR_PRODUCT(bma, CUT_PN(Isosurface3D_Cut), t2);
-	lambda = t1/t2;
-	V3_SCALE(lambda, bma);
-	V3_ADD(a, bma, s);
-	if (ABS(lambda) <= SMALL_D)
-		return -1;
-	if (ABS(lambda-1.0) <= SMALL_D)
-	    return 1;
-	return 0;
-}
-
-static void CutPolygon(POLY *poly)
-{
-    int i, j, n, bc[4], c;
-	DOUBLE_VECTOR x[5], s;
-	
-	for (i = n = 0; i < poly->n; i++)
-	    n += (bc[i] = BehindCut(poly->x[i]));
-
-	if (n == poly->n)
-		return;
-	if (n == 0) {
-		poly->n = 0;
-		return;
-	}
-
-	/* Sutherland-Hodgman Polygon Clipper */
-	for (i = n = 0; i < poly->n; i++) {
-		j = (i+1) % poly->n;
-		c = bc[i] + (bc[j] << 1);
-		switch(c)
-		{
-		case 0:
-			/* NOP */
-			break;
-		case 1:
-		    if (IntersectWithCut(poly->x[i], poly->x[j], s) >= 0) {
-				memcpy(x[n], s, sizeof(s));
-				n++;
-			}
-			break;
-		case 2:
-		    if (IntersectWithCut(poly->x[i], poly->x[j], s) <= 0) {
-			    memcpy(x[n], s, sizeof(s));
-			    n++;
-			}
-			memcpy(x[n], poly->x[j], sizeof(DOUBLE_VECTOR));
-			n++;
-			break;
-		case 3:
-			memcpy(x[n], poly->x[j], sizeof(DOUBLE_VECTOR));
-			n++;
-		}
-	}
-	memcpy(poly->x, x, sizeof(x));
-	poly->n = (n >= 3)? n:0;
+	return Isosurface3D_AmbientLight + (1.0-Isosurface3D_AmbientLight)*cosa;
 }
 
 static INT EW_Isosurface3D (ELEMENT *theElement, DRAWINGOBJ *theDO)
 {
 	CELL cell;
-	POLY poly[MAX_ISOS*MAXPOLY];
-	int i, j, k, n, npoly;
+	POLY poly[MAXPOLY];
+	INT i, j;
+	int npoly;
 	DOUBLE *x[MAX_CORNERS_OF_ELEM], lc[DIM], intensity;
-	
+
 	cell.n = CORNERS_OF_ELEM(theElement);
 
 	for (i = 0; i < CORNERS_OF_ELEM(theElement); i++)
@@ -20742,31 +20665,23 @@
 			}
 
 	/* extract & plot isosurface polygons */
-	npoly = 0;
-	for (k = 0; k < Isosurface3D_NoIsos; k++)
-		if (EXTRA(theElement) & (1<<k)) {
-			ExtractElement(&cell, Isosurface3D_lambda[k], poly+npoly, &n);
-			for (i = 0; i < n; i++)
-				poly[npoly + i].c = Isosurface3D_color[k];
-			npoly += n;
-		}
-	if (!do_bullet && npoly > 1)
-		SortPolygons(poly, npoly);
-	for (i = 0; i < npoly; i++) {
-		if (CUT_STATUS(Isosurface3D_Cut) == ACTIVE && poly[i].n > 0)
-			CutPolygon(&poly[i]);
-		if (poly[i].n == 0) continue;
-		if (Isosurface3D_AmbientLight < 1.0)
-			intensity = LightPolygon(&poly[i]);
-		else
-			intensity = 1.0;
-		DO_2c(theDO) = DO_SHADED_POLYGON; DO_inc(theDO);
-		DO_2c(theDO) = poly[i].n; DO_inc(theDO);
-		DO_2l(theDO) = poly[i].c; DO_inc(theDO); 		
-		DO_2C(theDO) = intensity; DO_inc(theDO);
-		for (j = 0; j < poly[i].n; j++) {
-			V3_COPY(poly[i].x[j], DO_2Cp(theDO));
-			DO_inc_n(theDO,3);
+	ExtractElement(&cell, Isosurface3D_lambda, poly, &npoly);
+	if (npoly > 0) {
+		if (!do_bullet && npoly > 1) SortPolygons(poly, npoly);
+		for (i = 0; i < npoly; i++) {
+			if (poly[i].n == 0) continue;
+			if (Isosurface3D_AmbientLight < 1.0)
+				intensity = LightPolygon(&poly[i]);
+			else
+				intensity = 1.0;
+			DO_2c(theDO) = DO_SHADED_POLYGON; DO_inc(theDO);
+			DO_2c(theDO) = poly[i].n; DO_inc(theDO);
+			DO_2l(theDO) = Isosurface3D_color; DO_inc(theDO);
+			DO_2C(theDO) = intensity; DO_inc(theDO);
+			for (j = 0; j < poly[i].n; j++) {
+				V3_COPY(poly[i].x[j], DO_2Cp(theDO));
+				DO_inc_n(theDO,3);
+			}
 		}
 	}
 	DO_2c(theDO) = DO_NO_INST;
@@ -20777,11 +20692,11 @@
 	return 0;
 }
 
-static void MarkElementsOnSurface(MULTIGRID *theMG, INT fromLevel, INT toLevel)
+static void MarkElementsOnSurface(MULTIGRID *theMG,INT fromLevel, INT toLevel)
 {
+	INT i;
 	ELEMENT *theElement;
 	NODE *theNode;
-	INT i;
 
 	fromLevel = MAX(fromLevel,0);
 	toLevel = MIN(toLevel,CURRENTLEVEL(theMG));
@@ -20828,7 +20743,7 @@
 
 static INT EW_Isosurface3D_FR(ELEMENT *theElement, DRAWINGOBJ *theDO)
 {
-	int i;
+	INT i;
 	DOUBLE *CornersOfElem[MAX_CORNERS_OF_ELEM], LocalCoord[DIM], value;
 
 	for (i = 0; i < CORNERS_OF_ELEM(theElement); i++)
@@ -20852,9 +20767,7 @@
 static INT EW_PostProcess_Isosurface3D_FR(PICTURE *thePicture, WORK *theWork)
 {
 	struct FindRange_Work *FR_Work = W_FINDRANGE_WORK(theWork);
-	DOUBLE delta;
-	int i, n;
-
+	
 #ifdef ModelP
 	GEN_FR_min = UG_GlobalMinDOUBLE(GEN_FR_min);
 	GEN_FR_max = UG_GlobalMaxDOUBLE(GEN_FR_max);
@@ -20878,10 +20791,6 @@
 	if (GEN_FR_put == YES) {
 		PIC_PO(thePicture)->theIpo.min = GEN_FR_min;
 		PIC_PO(thePicture)->theIpo.max = GEN_FR_max;
-		n = PIC_PO(thePicture)->theIpo.NoIsos;
-		delta = (GEN_FR_max - GEN_FR_min)/(n + 1);
-		for (i = 0; i < n; i++)
-			PIC_PO(thePicture)->theIpo.lambda[i] = GEN_FR_min + (i+1)*delta;
 	}
 
 	return 0;
@@ -21244,7 +21153,6 @@
 }   
 
 
-
 /****************************************************************************/
 /*
    PWorkGEN_Quit - test for end of PWorkXX_Evaluate / PWorkXX_Execute loop
@@ -21404,16 +21312,16 @@
 			{
 				/* prepare next element */
 				(*WOP_EW_EvaluateProc)(WOP_Element, WOP_DrawingObject);
-				WOP_CurrDoLen = (INT)(WOP_DObjPnt) - (INT)(WOP_DrawingObject);
+				WOP_CurrDoLen = (long int)(WOP_DObjPnt) - (long int)(WOP_DrawingObject);
 				WOP_Element = (*WOP_EW_GetNextElementProc)(WOP_Element);
 			}
-		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((INT)(p) - (INT)(p1)) 
+		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((long int)(p) - (long int)(p1)) 
 				 > WOP_CurrDoLen);
 
 		/* set endmarker & length */
 		DO_2c(p) = DO_NO_INST;
 		DO_inc(p1);
-		DO_2INT(p1) = (INT)p-(INT)p1+2*sizeof(DRAWINGOBJ);
+		DO_2INT(p1) = (long int)p-(long int)p1+2*sizeof(DRAWINGOBJ);
 
 		/* book slot */
 		WOP_Count[i]++;
@@ -21597,10 +21505,10 @@
 					(*WOP_EW_EvaluateProc)(WOP_Element, WOP_DrawingObject);
 					WOP_nextID = ID(WOP_Element);
 					consecutive = GElem_Consecutive;
-					WOP_CurrDoLen = (INT)(WOP_DObjPnt) - (INT)(WOP_DrawingObject);
+					WOP_CurrDoLen = (long int)(WOP_DObjPnt) - (long int)(WOP_DrawingObject);
 					WOP_Element = (*WOP_EW_GetNextElementProc)(WOP_Element);
 				}
-			} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((INT)(p) - (INT)(p1)) 
+			} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((long int)(p) - (long int)(p1)) 
 					 > WOP_CurrDoLen && consecutive);
 
 		} while ( p == p2+2);
@@ -21610,7 +21518,7 @@
 		DO_2c(p) = DO_NO_INST;
 		DO_2INT(p2) = WOP_lastID;
 		DO_inc(p2);
-		DO_2INT(p2) = (INT)p-(INT)p1+sizeof(DRAWINGOBJ);;
+		DO_2INT(p2) = (long int)p-(long int)p1+sizeof(DRAWINGOBJ);;
 
 		/* book slot */
 		WOP_Count[i]++;
@@ -21659,14 +21567,14 @@
 			}
 			else {
 				(*WOP_NW_EvaluateProc)(WOP_Node, WOP_DrawingObject);
-				WOP_CurrDoLen = (INT)(WOP_DObjPnt) - (INT)(WOP_DrawingObject);
+				WOP_CurrDoLen = (long int)(WOP_DObjPnt) - (long int)(WOP_DrawingObject);
 				WOP_Node = (*WOP_NW_GetNextNodeProc)(WOP_Node);
 			}
-		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((INT)(p) - (INT)(p1)) 
+		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((long int)(p) - (long int)(p1)) 
 				 > WOP_CurrDoLen);
 		DO_2c(p) = DO_NO_INST;
 		DO_inc(p1);
-		DO_2INT(p1) = (INT)p-(INT)p1+2*sizeof(DRAWINGOBJ);
+		DO_2INT(p1) = (long int)p-(long int)p1+2*sizeof(DRAWINGOBJ);
 		WOP_Count[i]++;
 		WOP_Front[i] = (WOP_Front[i] + 1) % DO_BUFFER_SLOTS;
 	}
@@ -21714,14 +21622,14 @@
 			}
 			else {
 				(*WOP_VW_EvaluateProc)(WOP_Vector, WOP_DrawingObject);
-				WOP_CurrDoLen = (INT)(WOP_DObjPnt) - (INT)(WOP_DrawingObject);
+				WOP_CurrDoLen = (long int)(WOP_DObjPnt) - (long int)(WOP_DrawingObject);
 				WOP_Vector = (*WOP_VW_GetNextVectorProc)(WOP_Vector);
 			}
-		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((INT)(p) - (INT)(p1)) 
+		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((long int)(p) - (long int)(p1)) 
 				 > WOP_CurrDoLen);
 		DO_2c(p) = DO_NO_INST;
 		DO_inc(p1);
-		DO_2INT(p1) = (INT)p-(INT)p1+2*sizeof(DRAWINGOBJ);
+		DO_2INT(p1) = (long int)p-(long int)p1+2*sizeof(DRAWINGOBJ);
 		WOP_Count[i]++;
 		WOP_Front[i] = (WOP_Front[i] + 1) % DO_BUFFER_SLOTS;
 	}
@@ -21729,43 +21637,6 @@
 
 /****************************************************************************/
 /*
-   PWorkET_Init - Initialisation for PWorkET_Evaluate and PWorkET_Execute
-
-   SYNOPSIS:
-   void PWorkET_Init(void)
-
-   PARAMETERS:
-   none
-
-   RETURN VALUE:
-   void
-*/
-/****************************************************************************/
-static void PWorkET_Init(void)
-{
-	int i;
-
-	for (i=0; i<WopDownChannels; i++) {
-		WOP_Sending[i]   = 0;
-		WOP_Receiving[i] = 0; 
-		WOP_NbTokens[i]  = 0;
-		WOP_Count[i]     = 0;
-		WOP_Front[i]     = 0;
-		WOP_Rear[i]      = 0;
-		WOP_More[i]      = (WOP_DownChannel[i] != NULL);
-	}
-	WOP_Sending[WopDownChannels] = 0;
-	WOP_Count  [WopDownChannels] = 0;
-	WOP_Front  [WopDownChannels] = 0;
-	WOP_Rear   [WopDownChannels] = 0;
-	WOP_More   [WopDownChannels] = 1;
-
-	WOP_CurrDoLen = 0;
-
-}   
-
-/****************************************************************************/
-/*
    PWorkET_Evaluate - evaluates extern wise
 
    SYNOPSIS:
@@ -21807,13 +21678,13 @@
 			}
 			else {
 				(*WOP_EXT_EvaluateProc)(WOP_DrawingObject, &WOP_EXT_End);
-				WOP_CurrDoLen = (INT)(WOP_DObjPnt) - (INT)(WOP_DrawingObject);
+				WOP_CurrDoLen = (long int)(WOP_DObjPnt) - (long int)(WOP_DrawingObject);
 			}
-		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((INT)(p) - (INT)(p1)) 
+		} while (DO_SLOT_SIZE*sizeof(DRAWINGOBJ) - ((long int)(p) - (long int)(p1)) 
 				 > WOP_CurrDoLen);
 		DO_2c(p) = DO_NO_INST;
 		DO_inc(p1);
-		DO_2INT(p1) = (INT)p-(INT)p1+2*sizeof(DRAWINGOBJ);
+		DO_2INT(p1) = (long int)p-(long int)p1+2*sizeof(DRAWINGOBJ);
 		WOP_Count[i]++;
 		WOP_Front[i] = (WOP_Front[i] + 1) % DO_BUFFER_SLOTS;
 	}
@@ -21845,14 +21716,14 @@
 D*/
 /****************************************************************************/
 
-static INT WOP_Init(INT WOP_WorkMode, INT work_type, INT cycle, INT bullet)
+static INT WOP_Init(INT WOP_WorkMode, INT work_type, INT bullet)
 {
 	switch (WOP_WorkMode)
 	{
 		case ELEMENTWISE:
 		
 			/* order elements if */
-			if (WOP_ViewDim == TYPE_3D && cycle == 0)
+			if (WOP_ViewDim == TYPE_3D)
 			{
 				#ifdef __TWODIM__
 					if (OrderElements_2D(WOP_MG,WOP_ViewedObj /*,bullet */))
@@ -22247,17 +22118,16 @@
 		return 1;
 	}
 
-	PWorkET_Init();
+	PWorkGEN_Init();
 
 	WOP_EXT_End = !CONTEXT(me);
-
-
+				
 	for (;;) {
 		if (PWorkGEN_Quit()) break;
 		PWorkGEN_Execute();
 		PWorkET_Evaluate();
 	}
-
+  
 	ReleaseTmpMem(heap,MarkKey);
 	return (0);
 
@@ -22387,7 +22257,7 @@
 		WOP_WorkMode = WP_WORKMODE(WOP_WorkProcs);
 
 		/* initialize */
-		if (WOP_Init(WOP_WorkMode, W_ID(theWork), i, NO)!=0) return 1;
+		if (WOP_Init(WOP_WorkMode, W_ID(theWork), NO)!=0) return 1;
 
 		/* work */
 		if (WOP_GEN_PreProcessProc!=NULL)
@@ -22445,7 +22315,7 @@
 
 static INT BulletDrawWork(PICTURE *thePicture, WORK *theWork, DOUBLE zOffsetFactor)
 {
-	INT i, j, error;
+	INT i, error;
 
 	if (thePicture==NULL || theWork==NULL)	return (1);
 	WOP_Picture = thePicture;
@@ -22536,7 +22406,7 @@
 		WOP_WorkMode = WP_WORKMODE(WOP_WorkProcs);
 
 		/* initialize */
-		if (WOP_Init(WOP_WorkMode, DRAW_WORK, i, YES)!=0) return 1;
+		if (WOP_Init(WOP_WorkMode, DRAW_WORK, YES)!=0) return 1;
 
 		/* work */
 		if (WOP_GEN_PreProcessProc!=NULL)
@@ -22547,21 +22417,27 @@
 		{
 		case ELEMENTWISE:
 #ifdef ModelP
-			if (CONTEXT(me))
+			WOP_Element = (CONTEXT(me) ?
+			  (*WOP_EW_GetFirstElementProc)(WOP_MG, 0, WOP_MG->currentLevel) : NULL);
+#else
+			WOP_Element = (*WOP_EW_GetFirstElementProc)(WOP_MG,0,
+														WOP_MG->currentLevel);
 #endif
+			for (; WOP_Element != NULL; 
+				 WOP_Element=(*WOP_EW_GetNextElementProc)(WOP_Element)) 
 			{
-				for (j = 0; j <= WOP_MG->currentLevel; j++)
-					for (WOP_Element = FIRSTELEMENT(GRID_ON_LEVEL(WOP_MG, j));
-						 WOP_Element != NULL; WOP_Element = SUCCE(WOP_Element))
-						if (USED(WOP_Element)) {
-							if ((*WOP_EW_EvaluateProc)(WOP_Element, WOP_DrawingObject))
-								return 1;
-							if ((*WOP_GEN_ExecuteProc)(WOP_DrawingObject))
-								return 1;
-						}
+				if ((*WOP_EW_EvaluateProc)(WOP_Element,WOP_DrawingObject))	return 1;
+				if ((*WOP_GEN_ExecuteProc)(WOP_DrawingObject))				return (1);
+/*
+#ifdef __THREEDIM__
+				if (BulletDraw3D(WOP_DrawingObject)) return 1;
+#else
+				if (BulletDraw2D(WOP_DrawingObject)) return 1;
+#endif
+*/
 			}
 			break;
-			
+
 		case NODEWISE:
 		case VECTORWISE:
 		case EXTERN:
@@ -24078,6 +23954,12 @@
 	InitRotObsTrafo3d	= VirtSphereInitRotObsTrafo3d;
 	RotObsTrafo3d		= VirtSphereRotObsTrafo3d;
 	
+	/* allocate storage in general mg user data:
+	   store view to check neccessity for ordering elements */
+	wopMGUDid = GetNewBlockID();
+	
+	if (DefineMGUDBlock(wopMGUDid,sizeof(WOP_MG_DATA))!=GM_OK) return (__LINE__);
+	
 	/* create WorkHandling for 'Matrix' */
 	if ((thePOH=CreatePlotObjHandling ("Matrix"))	   == NULL) return (__LINE__);
 		
@@ -24535,6 +24417,10 @@
 			if (AllocateControlEntry(FLAG_CW,CUTMODE_LEN,&ce_CUTMODE) != GM_OK)
 				return (__LINE__);
 		
+		/* flag in MG status to indicated elements have been ordered */
+		if (AllocateControlEntry(MULTIGRID_STATUS_CW,ELEMORD_LEN,&ce_ELEMORD) != GM_OK)
+			return (__LINE__);
+		
 		/* create WorkHandling for 'VecMat' */
 		if ((thePOH=CreatePlotObjHandling ("VecMat")) 	== NULL) return (__LINE__);
 		
diff -ruN ug-orig/graphics/uggraph/wop.csave ug-patched/graphics/uggraph/wop.csave
--- ug-orig/graphics/uggraph/wop.csave	1997-08-14 12:11:35.000000000 +0200
+++ ug-patched/graphics/uggraph/wop.csave	1997-08-14 12:11:35.000000000 +0200
@@ -844,7 +844,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/Attic/wop.csave,v 1.122 1997/08/14 10:11:35 root Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/graphics/uggraph/wop.h ug-patched/graphics/uggraph/wop.h
--- ug-orig/graphics/uggraph/wop.h	2008-04-04 13:46:36.000000000 +0200
+++ ug-patched/graphics/uggraph/wop.h	2009-04-29 15:11:55.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/wop.h,v 1.31 2008/04/04 11:46:36 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -142,7 +142,7 @@
 /****************************************************************************/
 
 #ifdef ModelP
-#define WOP_DOWN_CHANNELS_MAX           128
+#define WOP_DOWN_CHANNELS_MAX           32
 #define DO_BUFFER_SLOTS                 2
 #define DO_SLOT_SIZE                    (DO_SIZE+3)
 #endif
@@ -502,7 +502,7 @@
 INT             ErasePicture                    (PICTURE *thePicture);
 INT                     SetOrderStrategy                (INT OrderStrategy);
 
-PLOTOBJHANDLING *CreatePlotObjHandling (char *PlotObjTypeName);
+PLOTOBJHANDLING *CreatePlotObjHandling (const char *PlotObjTypeName);
 INT             Draw2D                                  (DRAWINGOBJ *q);
 INT             Draw3D                                  (DRAWINGOBJ *q);
 
diff -ruN ug-orig/graphics/uggraph/wpm.c ug-patched/graphics/uggraph/wpm.c
--- ug-orig/graphics/uggraph/wpm.c	2008-03-18 14:00:18.000000000 +0100
+++ ug-patched/graphics/uggraph/wpm.c	2008-12-19 11:13:29.000000000 +0100
@@ -24,6 +24,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -76,7 +77,7 @@
 static INT thePlotObjTypesVarID;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/graphics/uggraph/wpm.c,v 1.101 2008/03/18 13:00:18 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 static INT SetDeviceInfo (void)
 {
@@ -5503,47 +5504,39 @@
 	return (0);
 }
 
-/****************************************************************************/
-/*D
-   Isosurface PlotObject - extract isosurface(s) from scalar field
- 
-   USAGE:
-   'setplotobject Isosurface [$l <lambda1> <lambda2> ... | $n <n>]
-                             [$f <from>] [$t <to>]
-                             [$b 0|1] [$a 0..1] [$c 0|1]
-                             $s <vecdatadesc> [$e <evalproc>]'
- 
-.   $l...    - isosurface value(s) (default: 0.5)
-.   $n...    - desired number of isosurfaces (use instead of $l)
-.   $f...    - min value of field (default: 0.0)
-.   $t...    - max value of field (default: 1.0)
-.   $b...    - whether to plot domain boundary back sides (default: 0)
-.   $a...    - lighting: share of ambient light (default: 0.4)
-.   $c...    - whether to use depth cueing with lighting (default: 1)
-.   $s...    - vecdata descriptor for field
-.   $e...    - evaluation procedure (default: nvalue)
-
-   KEYWORDS:
-   graphics, plot, window, picture, plotobject, vecdesc, function
-D*/
-/****************************************************************************/
+/*------------------[doxygen??, ug help sys??, blah!!]-----------------------*
+ *
+ *   Isosurface PlotObject---extract isosurface from scalar field
+ *
+ *   Usage:
+ *
+ *   setplotobject Isosurface [$l <lambda>] [$f <from>] [$t <to>] [$b 0|1]
+ *                            [$a 0..1] $s <vecdatadesc> [$e <evalproc>]
+ *
+ *   $l...    - isosurface value (default: 0.5)
+ *   $f...    - min value of field (default: 0.0)
+ *   $t...    - max value of field (default: 1.0)
+ *   $b...    - whether to plot domain boundary back sides (default: 0)
+ *   $a...    - lighting: share of ambient light (default: 0.4, nice)
+ *   $s...    - vecdata descriptor for field
+ *   $e...    - evaluation procedure (default: nvalue)
+ *
+ *---------------------------------------------------------------------------*/
 
 static INT InitIsosurfacePlotObject_3D (PLOTOBJ *thePlotObj, INT argc, char **argv)
 {
 	struct IsosurfacePlotobject3D *theIpo;
 	BVP_DESC *theBVPDesc;
 	char buffer[64];
-	INT i, j, n, ret, nopt;
+	INT i, ret;
 	int iValue;
 	float fValue;
-	float f[MAX_ISOS];
-	DOUBLE delta;
-
+	
 	theIpo = &(thePlotObj->theIpo);
 	theBVPDesc = MG_BVPD(PO_MG(thePlotObj));
 	V3_COPY(BVPD_MIDPOINT(theBVPDesc),PO_MIDPOINT(thePlotObj));
 	PO_RADIUS(thePlotObj) = BVPD_RADIUS(theBVPDesc);
-	PO_USESCUT(thePlotObj) = YES;
+	PO_USESCUT(thePlotObj) = NO;
 
 	ret = ACTIVE;
 	
@@ -5551,47 +5544,23 @@
 	if (PO_STATUS(thePlotObj)==NOT_INIT)
 	{
 		theIpo->EvalFct 		= NULL;
-		theIpo->lambda[0]       = 0.5;
-		theIpo->NoIsos          = 1;
+		theIpo->lambda          = 0.5;
 		theIpo->min			    = 0.0;
 		theIpo->max			    = 1.0;
 		theIpo->DomainBackFaces = NO;
 		theIpo->AmbientLight    = 0.4;
-		theIpo->DepthCueing     = YES;
 	}
 
-	/* get isosurface values */
+	/* get isosurface value */
 	for (i=1; i<argc; i++)
 		if (argv[i][0]=='l')
 		{
-			n = sscanf(argv[i],"l %g %g %g %g %g %g %g %g %g %g %g",
-					   f, f+1, f+2, f+3, f+4, f+5, f+6, f+7, f+8, f+9, &fValue);
-			if (n < 1 || n > MAX_ISOS) {
-				UserWriteF("Specify 1 to %d values with $l option\n", MAX_ISOS);
-				ret = NOT_ACTIVE;
-			}
-			else {
-				theIpo->NoIsos = n;
-				for(j = 0; j < n; j++)
-					theIpo->lambda[j] = f[j];
-			}
+			if (sscanf(argv[i],"l %g",&fValue)!=1)
+				break;
+			theIpo->lambda = fValue;
 			break;
 		}
 
-	/* get desired number of isosurfaces */
-	nopt = 0;
-	for (i=1; i<argc; i++)
-        if (argv[i][0]=='n')
-        {
-			sscanf(argv[i],"n %d",&iValue);
-			if (iValue < 1 || iValue > MAX_ISOS) { 
-				UserWriteF("Number of isosurfaces has to be between 1 and %d\n", MAX_ISOS);
-				ret = NOT_ACTIVE;
-			}
-			else
-				nopt = iValue;
-		}
-
 	/* set from option */
 	for (i=1; i<argc; i++)
 		if (argv[i][0]=='f')
@@ -5666,33 +5635,12 @@
 	if (theIpo->AmbientLight < 0.0 || theIpo->AmbientLight > 1.0)
 		theIpo->AmbientLight = 1.0;
 
-	/* depth cueing? */
-	for (i=1; i<argc; i++)
-		if (argv[i][0]=='c')
-		{
-			if (sscanf(argv[i],"c %d",&iValue)!=1)
-				break;
-			if (iValue==1)
-				theIpo->DepthCueing = YES;
-			else if (iValue==0)
-				theIpo->DepthCueing = NO;
-			break;
-		}	
-
 	if (theIpo->EvalFct == NULL)
 	{
 		UserWrite("cannot find plot procedure\n");
 		ret = NOT_ACTIVE;
 	}
-
-	/* if $n given compute values */
-	if (nopt) {
-		theIpo->NoIsos = nopt;
-		delta = (theIpo->max - theIpo->min)/(nopt + 1); 
-		for (i = 0; i < nopt; i++)
-			theIpo->lambda[i] = theIpo->min + (i+1)*delta;
-	}
-
+		
 	return (ret);
 }
 
@@ -5714,18 +5662,14 @@
 	else
 		UserWriteF(DISPLAY_PO_FORMAT_SS,"EvalProc","---");
 	UserWriteF(DISPLAY_PO_FORMAT_SS,"name",PO_NAME(theIpo));
-	UserWriteF(DISPLAY_PO_FORMAT_SI,"NoIsos",theIpo->NoIsos);
+	UserWriteF(DISPLAY_PO_FORMAT_SF,"lambda",(float)theIpo->lambda);
 	UserWriteF(DISPLAY_PO_FORMAT_SFF,"Range",(float)theIpo->min,(float)theIpo->max);
 	if (theIpo->DomainBackFaces == YES)
-		UserWriteF(DISPLAY_PO_FORMAT_SS,"BackFaces","YES");
+		UserWriteF(DISPLAY_PO_FORMAT_SS,"DomainBackFaces","YES");
 	else
-		UserWriteF(DISPLAY_PO_FORMAT_SS,"BackFaces","NO");	
+		UserWriteF(DISPLAY_PO_FORMAT_SS,"DomainBackFaces","NO");	
 	UserWriteF(DISPLAY_PO_FORMAT_SF,"AmbientLight",(float)theIpo->AmbientLight);
-	if (theIpo->DepthCueing == YES)
-        UserWriteF(DISPLAY_PO_FORMAT_SS,"DepthCueing","YES");
-    else
-        UserWriteF(DISPLAY_PO_FORMAT_SS,"DepthCueing","NO");
-
+	UserWrite("\n");
 	return 0;
 }
 
diff -ruN ug-orig/graphics/uggraph/wpm.h ug-patched/graphics/uggraph/wpm.h
--- ug-orig/graphics/uggraph/wpm.h	2008-03-18 14:00:18.000000000 +0100
+++ ug-patched/graphics/uggraph/wpm.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/graphics/uggraph/wpm.h,v 1.59 2008/03/18 13:00:18 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -443,18 +443,14 @@
                 INT UndispSubDom;                       /* subdomain not displayed OS_CHANGED           */
 };
 
-#define MAX_ISOS 10
-
 struct IsosurfacePlotobject3D {
 	struct PlotObjHead theHead; 			/* the head 									*/
 
 	EVALUES *EvalFct;						/* evaluation procedure	    					*/
-	DOUBLE lambda[MAX_ISOS];                /* isosurface values                            */
-	INT NoIsos;
+	DOUBLE lambda;                          /* isosurface value                             */
 	DOUBLE min, max;						/* range										*/
 	INT DomainBackFaces;                    /* plot domain boundary back faces?             */
 	DOUBLE AmbientLight;                    /* share of ambient light                       */
-	INT DepthCueing;
 };
 
 union PlotObj {
diff -ruN ug-orig/icc.opts ug-patched/icc.opts
--- ug-orig/icc.opts	2004-09-02 14:22:03.000000000 +0200
+++ ug-patched/icc.opts	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: icc.opts,v 1.1 2004/09/02 12:22:03 thimo Exp $
+# $Id: icc.opts 7772 2004-09-02 12:22:17Z thimo $
 
 # options for icc
 # remember to run ./autogen.sh after changing these values!
diff -ruN ug-orig/initug.c ug-patched/initug.c
--- ug-orig/initug.c	2005-07-18 15:44:18.000000000 +0200
+++ ug-patched/initug.c	2008-12-19 11:18:36.000000000 +0100
@@ -37,6 +37,7 @@
 /****************************************************************************/
 
 /* ANSI-C includes */
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 
@@ -103,7 +104,7 @@
 /* RCS string */
 static char
 RCS_ID
-("$Header: /home/cvsroot/UG/ug/initug.c,v 1.41 2005/07/18 13:44:18 sander Exp $",
+("$Header$",
 UG_RCS_STRING);
 
 /****************************************************************************/
diff -ruN ug-orig/initug.h ug-patched/initug.h
--- ug-orig/initug.h	2006-06-02 18:12:03.000000000 +0200
+++ ug-patched/initug.h	2006-06-02 18:15:49.000000000 +0200
@@ -25,7 +25,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/initug.h,v 1.12 2006/06/02 16:12:03 sander Exp $
+$Header$
 */
 
 #ifndef __INITUG__
diff -ruN ug-orig/lib/CVS/Entries ug-patched/lib/CVS/Entries
--- ug-orig/lib/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:18 2004//D2008.11.12.23.00.00
-/Makefile.am/1.5/Fri Apr  1 14:23:35 2005//D2008.11.12.23.00.00
-/empty.txt/1.1.1.1/Fri Sep 15 16:53:58 1995//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/CVS/Entries.Log ug-patched/lib/CVS/Entries.Log
--- ug-orig/lib/CVS/Entries.Log	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-A D/MWCW////
-A D/Xcode////
-A D/ugdata////
diff -ruN ug-orig/lib/CVS/Repository ug-patched/lib/CVS/Repository
--- ug-orig/lib/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib
diff -ruN ug-orig/lib/CVS/Root ug-patched/lib/CVS/Root
--- ug-orig/lib/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/CVS/Tag ug-patched/lib/CVS/Tag
--- ug-orig/lib/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/.cvsignore ug-patched/lib/.cvsignore
--- ug-orig/lib/.cvsignore	2004-09-08 16:14:18.000000000 +0200
+++ ug-patched/lib/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/lib/Makefile.am ug-patched/lib/Makefile.am
--- ug-orig/lib/Makefile.am	2005-04-01 16:23:35.000000000 +0200
+++ ug-patched/lib/Makefile.am	2010-01-24 19:33:26.000000000 +0100
@@ -1,47 +1,53 @@
-# $Id: Makefile.am,v 1.5 2005/04/01 14:23:35 thimo Exp $
+# $Id: Makefile.am 8363 2010-01-24 18:33:26Z joe $
 
 SUBDIRS = ugdata
 
 if BUILD2D
-  LIB_2D = libug2.la
+  LIB_2D = libugS2.la libugL2.la
 else
   LIB_2D =
 endif
 
 if BUILD3D
-  LIB_3D = libug3.la
+  LIB_3D = libugS3.la libugL3.la
 else
   LIB_3D =
 endif
 
+2DLIBS = ../gm/libug_gm2.la \
+         ../np/libnp2.la \
+         ../graphics/libgraphics2.la \
+         ../ui/libugui2.la \
+         ../dev/libdevices.la \
+         ../low/liblow2.la
+
+3DLIBS = ../gm/libug_gm3.la \
+         ../np/libnp3.la \
+         ../graphics/libgraphics3.la \
+         ../ui/libugui3.la \
+         ../dev/libdevices.la \
+         ../low/liblow3.la
+
+lib_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
+
+libugS2_la_SOURCES = ../initug.c
+libugS2_la_CPPFLAGS = $(UG_2DFLAGS)
+libugS2_la_LIBADD = $(2DLIBS) ../dom/std/libdomS2.la
 if PARALLEL
-  PLIBS_2D = ../parallel/libparallel2.la
-  PLIBS_3D = ../parallel/libparallel3.la
-else
-  PLIBS_2D =
-  PLIBS_3D =
+  libugS2_la_LIBADD += ../parallel/libparallel2.la
 endif
 
-lib_LTLIBRARIES = $(LIB_2D) $(LIB_3D)
+libugL2_la_SOURCES = ../initug.c
+libugL2_la_CPPFLAGS = $(UG_2DFLAGS)
+libugL2_la_LIBADD = $(2DLIBS) ../dom/lgm/libdomL2.la
+
+libugS3_la_SOURCES = ../initug.c
+libugS3_la_CPPFLAGS = $(UG_3DFLAGS)
+libugS3_la_LIBADD = $(3DLIBS) ../dom/std/libdomS3.la
+if PARALLEL
+  libugS3_la_LIBADD += ../parallel/libparallel3.la
+endif
 
-libug2_la_SOURCES = ../initug.c
-libug2_la_CPPFLAGS = $(UG_2DFLAGS)
-libug2_la_LIBADD = ../gm/libug_gm2.la \
-                   ../np/libnp2.la \
-                   ../graphics/libgraphics2.la \
-                   ../ui/libugui2.la \
-                   ../dev/libdevices.la \
-                   ../low/liblow2.la \
-                   ../parallel/util/libparutil.la \
-                   ../low/liblow.la $(PLIBS_2D)
-
-libug3_la_SOURCES = ../initug.c
-libug3_la_CPPFLAGS = $(UG_3DFLAGS)
-libug3_la_LIBADD = ../gm/libug_gm3.la \
-                   ../np/libnp3.la \
-                   ../graphics/libgraphics3.la \
-                   ../ui/libugui3.la \
-                   ../dev/libdevices.la \
-                   ../low/liblow3.la \
-                   ../parallel/util/libparutil.la \
-                   ../low/liblow.la $(PLIBS_3D)
+libugL3_la_SOURCES = ../initug.c
+libugL3_la_CPPFLAGS = $(UG_3DFLAGS)
+libugL3_la_LIBADD = $(3DLIBS) ../dom/lgm/libdomL3.la
diff -ruN ug-orig/lib/MWCW/2D/CVS/Entries ug-patched/lib/MWCW/2D/CVS/Entries
--- ug-orig/lib/MWCW/2D/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/2D/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/MWCW.cmdlinedefs/1.1/Sat Jul  5 14:26:24 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/MWCW/2D/CVS/Repository ug-patched/lib/MWCW/2D/CVS/Repository
--- ug-orig/lib/MWCW/2D/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/2D/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/MWCW/2D
diff -ruN ug-orig/lib/MWCW/2D/CVS/Root ug-patched/lib/MWCW/2D/CVS/Root
--- ug-orig/lib/MWCW/2D/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/2D/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/MWCW/2D/CVS/Tag ug-patched/lib/MWCW/2D/CVS/Tag
--- ug-orig/lib/MWCW/2D/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/2D/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/MWCW/3D/CVS/Entries ug-patched/lib/MWCW/3D/CVS/Entries
--- ug-orig/lib/MWCW/3D/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/3D/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/MWCW.cmdlinedefs/1.1/Sat Jul  5 14:26:43 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/MWCW/3D/CVS/Repository ug-patched/lib/MWCW/3D/CVS/Repository
--- ug-orig/lib/MWCW/3D/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/3D/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/MWCW/3D
diff -ruN ug-orig/lib/MWCW/3D/CVS/Root ug-patched/lib/MWCW/3D/CVS/Root
--- ug-orig/lib/MWCW/3D/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/3D/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/MWCW/3D/CVS/Tag ug-patched/lib/MWCW/3D/CVS/Tag
--- ug-orig/lib/MWCW/3D/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/3D/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/MWCW/CVS/Entries ug-patched/lib/MWCW/CVS/Entries
--- ug-orig/lib/MWCW/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-/UGheaders.h/1.2/Mon Aug  3 12:39:42 1998//D2008.11.12.23.00.00
-/UGheaders2d.pch/1.1/Wed May  6 14:35:59 1998//D2008.11.12.23.00.00
-/UGheaders3d.pch/1.1/Wed May  6 14:36:00 1998//D2008.11.12.23.00.00
-/UGkeywords/1.1/Tue Aug 11 10:31:34 1998//D2008.11.12.23.00.00
-/general_prefix.h/1.1/Wed May  6 14:36:01 1998//D2008.11.12.23.00.00
-/mif_prefix.h/1.1/Wed May  6 14:36:02 1998//D2008.11.12.23.00.00
-/pch2d_prefix.h/1.1/Wed May  6 14:36:03 1998//D2008.11.12.23.00.00
-/ug.proj.sit.hqx/1.7/Tue Apr  2 15:27:18 2002//D2008.11.12.23.00.00
-/ug2d_prefix.h/1.1/Wed May  6 14:36:08 1998//D2008.11.12.23.00.00
-/ug3d_prefix.h/1.1/Wed May  6 14:36:09 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/MWCW/CVS/Entries.Log ug-patched/lib/MWCW/CVS/Entries.Log
--- ug-orig/lib/MWCW/CVS/Entries.Log	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-A D/2D////
-A D/3D////
diff -ruN ug-orig/lib/MWCW/CVS/Repository ug-patched/lib/MWCW/CVS/Repository
--- ug-orig/lib/MWCW/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/MWCW
diff -ruN ug-orig/lib/MWCW/CVS/Root ug-patched/lib/MWCW/CVS/Root
--- ug-orig/lib/MWCW/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/MWCW/CVS/Tag ug-patched/lib/MWCW/CVS/Tag
--- ug-orig/lib/MWCW/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/MWCW/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/MWCW/general_prefix.h ug-patched/lib/MWCW/general_prefix.h
--- ug-orig/lib/MWCW/general_prefix.h	1998-05-06 16:36:01.000000000 +0200
+++ ug-patched/lib/MWCW/general_prefix.h	1998-05-06 16:36:09.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/general_prefix.h,v 1.1 1998/05/06 14:36:01 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/mif_prefix.h ug-patched/lib/MWCW/mif_prefix.h
--- ug-orig/lib/MWCW/mif_prefix.h	1998-05-06 16:36:02.000000000 +0200
+++ ug-patched/lib/MWCW/mif_prefix.h	1998-05-06 16:36:09.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/mif_prefix.h,v 1.1 1998/05/06 14:36:02 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/pch2d_prefix.h ug-patched/lib/MWCW/pch2d_prefix.h
--- ug-orig/lib/MWCW/pch2d_prefix.h	1998-05-06 16:36:03.000000000 +0200
+++ ug-patched/lib/MWCW/pch2d_prefix.h	1998-05-06 16:36:09.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/pch2d_prefix.h,v 1.1 1998/05/06 14:36:03 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/ug2d_prefix.h ug-patched/lib/MWCW/ug2d_prefix.h
--- ug-orig/lib/MWCW/ug2d_prefix.h	1998-05-06 16:36:08.000000000 +0200
+++ ug-patched/lib/MWCW/ug2d_prefix.h	1998-05-06 16:36:09.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/ug2d_prefix.h,v 1.1 1998/05/06 14:36:08 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/ug3d_prefix.h ug-patched/lib/MWCW/ug3d_prefix.h
--- ug-orig/lib/MWCW/ug3d_prefix.h	1998-05-06 16:36:09.000000000 +0200
+++ ug-patched/lib/MWCW/ug3d_prefix.h	1998-05-06 16:36:09.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/ug3d_prefix.h,v 1.1 1998/05/06 14:36:09 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/UGheaders2d.pch ug-patched/lib/MWCW/UGheaders2d.pch
--- ug-orig/lib/MWCW/UGheaders2d.pch	1998-05-06 16:35:59.000000000 +0200
+++ ug-patched/lib/MWCW/UGheaders2d.pch	1998-05-06 16:36:09.000000000 +0200
@@ -22,7 +22,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/UGheaders2d.pch,v 1.1 1998/05/06 14:35:59 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/UGheaders3d.pch ug-patched/lib/MWCW/UGheaders3d.pch
--- ug-orig/lib/MWCW/UGheaders3d.pch	1998-05-06 16:36:00.000000000 +0200
+++ ug-patched/lib/MWCW/UGheaders3d.pch	1998-05-06 16:36:09.000000000 +0200
@@ -22,7 +22,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/lib/MWCW/UGheaders3d.pch,v 1.1 1998/05/06 14:36:00 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/lib/MWCW/UGheaders.h ug-patched/lib/MWCW/UGheaders.h
--- ug-orig/lib/MWCW/UGheaders.h	1998-08-03 14:39:42.000000000 +0200
+++ ug-patched/lib/MWCW/UGheaders.h	1998-08-03 14:39:42.000000000 +0200
@@ -147,5 +147,5 @@
 #include "uginterface.h"
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/lib/MWCW/UGheaders.h,v 1.2 1998/08/03 12:39:42 reichenb Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
diff -ruN ug-orig/lib/MWCW/ug.proj.sit.hqx ug-patched/lib/MWCW/ug.proj.sit.hqx
--- ug-orig/lib/MWCW/ug.proj.sit.hqx	2002-04-02 17:27:18.000000000 +0200
+++ ug-patched/lib/MWCW/ug.proj.sit.hqx	2002-04-02 17:27:18.000000000 +0200
@@ -1 +1,647 @@
-(This file must be converted with BinHex 4.0):#h9R,R"bEfSZFfPd!&0*9$96593K!*!%H(m!N!4fYP0dG@CQ5A3J+'-T-6Nj0bda16Ni)%&XB@4ND@iJ8hPcG'9YFb`J5@jM,L`JD(4dF$S[,hH3!bjKE'&NC'PZFhPc,Q0[E5p6G(9QCNPd,`d+'J!&%!!!H(m!N!0b!!%!N!0bc,m0TD95CA0PFRCPC+@P!+@3"!%!!$F!!,*"C4ZicjGf!*!0"kb,!!IC8!!!Gl)!N!32!(9R,R"bEfS!!,C(68e3FN0A588!N!1L!!%!N!U!!*!(3X(9GB!K$Lj!V@DRS@D#!0Ni6qBLB"#'qA6j#HQ0G,F5'rJi0DN34kM)JT-1K&@U'!6(LA4R1C!!pV+DqIMlCRR(8C&bA&p19F0MLfm6rK2Q`G-J52`E9P[+KP$lU8qp`IcjE@#VqlikXRCBA@&DZbdX*a+QRf5P&Dek*D,bc$IYA4C-M552J`1%VcZ4b"8+KGmjf(9YJA63YBriT#*E@BiVZVKRKbP5RK`Mq5PkM'[k9fd,AEVEh@BI1XLLT99["Ii2f4cl2fJ#L'e+B0)YRkcU%,jR6-'K$,`-QpqK@dI(2eJNGS[l#f4rVTCeLhYBYY5+pHe`&e#EpLPpKVDefFrq"[b+A`ij18SM(1DL09"mk%HmNbE-RC'3!!l+$YiF9`%fi$fm64XaR%S[P3bV0Lj*(V4hj5)hmkSTkB8@mkE8(8-1eM'84(bTSH2qjLp*6pacB4lGCp9afr-6b)4KQ2F05'e%"F`q+Bac2CKY!&(HAd@ArB+VZeP'qdlm4`*fp228UiN9im+bVZL*SF1p+XCH!f-![[0*24QPU85S8dS6lkYIKGP5bCJpmJG)GPjf(%X(GE(BJYD9T!#*a'pkGjb@FZS4p#ND,X68D3`D[cq`2$,+NfrJ"FLkNmVX1&+iCB!!DI[HJhr&DDR+J0Y-mDDpJ+m)QF9TP1ib,a&pCP8BCM$+G[2lKAb[%,!"1qF58ifLJrJep4F!$D$`#Bh1CcaIJ3&F`-Rb!Ii5)J%SKS,VCH8"mk-pI&YG`GfS4&@Dd,k&`1@q6M,S$#JNm&BArFHe[*!!k5h`Z(XAhYM9kSiPlTL,0iTXqRlaDRT,EI$@![N2eGj2qh&CiZSFZm4MM*2m'K'pjTe*)JAhmlX"c[0"CaPplj,pekRcdhV-3)S-"*d4#+5HrP,&Ur98[DS6'Ke1&U(S-)EX$L0*YSR)dC9Gq!+2N8Vk'b0LV'l)80eT6B%jF2rU!1cdJD2a@cC$-Y,d"31C[,j*$I@5Ud@3!2pBKSHXAIHd53@'YN*rHZ62bXKmAX%5RrFU8'LFKPNbS$q$(heN,Q)BA*cbHB!4qe[N[PUTK!5SRaGlr'JKm$I++!TE[miQ83)3(%GHalCMjMp*&%TB4&eI-'N@%''m@AlNmE'DRNlj&&)T)bP9)5G$0,D9Yc3NSd20jEa4R`6r2`4@Q!hZe*j4AL`!0"G&QCB"TqKXmT5--p82+D)JAjdC`&I!Yf3%HFakp#Z2L6e'ceI4S91$lZ-[dX8mTV$$QpYCLh2!!'",fGmX)4r-X6)1C4T"cCX#BjQfc-PUIjrRYh*@4C(lKc%8@kK6L5Hib#G`(dmQQ%INDN*I55+BJUC%LKKjC-UG,[lAk'4*04Z!69XV29SC(aFN)afeV,c6h8`dAN6ja)1-#&ac1U-U[`hECkQG*qJrZ80PULZ2K"E"2,@b'a2aEbY80VD6[K'X&1fU*f9(,I$!5Tk4,4'hai!eFC5US"q@q9$hD-)@ThMpHDp+bddQ['EaDlCQ$29bk4BCGccY!XNHJrB1r5h,F3CVceQ@Q%R,DDS$Fid@E0AD6KSViNVhK)0RUE@#*S@8*dY%Xb8`Ll'q2$CmCJ`ipB#CFUrN)9`(l(Br8T3k#0I[GIN2iF$,1q"4lab@qA*lcq(lE0,)BKqPRii8TAABaq1Q2Tmprc#913Z9jSRF3Ahk,FP`%r'EKZ#8FZKF)AK+`!E&%kib8eV1Y8EQU-qDmVi!Qk3ijZaZ*FZT4+FP`'Z[B5H8+`G3q9S1QP!j*chC9+e+!Ml[DqhXfjUq",R)122)89Dfj9r!GNM!C%9(eA16eN`fS,qj2h+*jV4E%KX!El#0%m`C2ESrF*Gl&cefRBh9V6q!b%(GGZ,Jip5`$F&S8[,Y)fNdlTB%dK9N94AAAeNEpGAP*l'cV,SVFUAi'iDD(%R2TmpbYC*%,)-4Cc8r"G9qqUSIp3ETjT3fUd'F+"R3aTXfIJV%Z8UA#FApVRVjdKrY2[0IR4kkVI5TBV-Ycek%#(`,dfrJcabd8)KQ$f(CZ%3@T)eBLE4h$j4XC,e`,U6X**fdSQ9Tm*TZ*fAXfY#IbX8iFhaQU3RV12U9)636%KKMjZBHX$hGG&&ED+fqYY6$8HTb--U%lX5`)!GEYTe+Z3,!iPjB$j8lCYPmm8`ALQ&,iHV`2"X8M6*d$$9&*GclE('"NkedAlI-JN(+lGEqL4rVXN(5m8B8m"&)HX%pV5aa50kN(Aed0N3SZbRM+$[Kr"M8+)+4miJAYC!!RFJ+3S#-ZBMXpr(f9aZ`&Y)QPcdckXe(iIh0ffDX9Tfa'H'DCa8#C)9V-MHHaSVD90b3!(@K,9XmXVUE1@l,Lh`4EqMGe0kL,*rHbhGYAGH1ajfNZ9c@+$U69f`0iFhMFC8q3NBKGm2$#R*H6p3HD+)a@8hH)9$SQm`Bb%BkqCRFl5Z9&TH)(Ad55EVSYV,%93+e3jIhjc+ccZ+epb#R@6Ek4XHd%,Dbq60AF'9QpUi5j6Le0aXY$8,h4dFB[4*NBH6KcmNb3@a6hSVq(J0mb*eI'Bq[lY(`Q1MK#AYYRl,)c6T(E1@+)r2PND$TVa0('51HS-L3!%q-bkU+("`K[YVebZMh(MFm2qrT0e@h(ffh6kq'8%Y,0I!!Ca#TiM"-8Mb8Cf$RD%B%(*F`F(qC&CGB9AI&*!e*fVH0e,cU`lLm434&@PMRaBaG'm*qKP$LAhQQSIIF*FUe90UJ8kYS[LbK!eT3G6j&1i&J24A3XY[E48qN+YkL[HPAJCZ[hTDG8+b*pi+%3V#JU81T8EJ*lT0-MM#q"0DaY3$fXSQ"TeM%Hpb!j1!aYjPXQ&MYMZArT#J"mE+6PCHVh#U#IHbJ10Irbc)EpQj*MFq@m3&VL6*EB3,C"VD[E3med*QV`GUkFKeMY2!CkB4![8A8MU4[J2K-lTQd1U*GDA6(UIei#XY@M-B3pDJ[,IINTY@BaYr*LicHCQ(0hh+V)8-A9pkV1@B@215Sqb"8Qdr&!CK+Dq)+(HU$"J8c8k1SS@DfC3GaI@U-4,FM4*@8b6#L'SL,45q8QGDpKk&jhIir+MZL(BVq0TjUTL1N)e-CYqaZQ8*dP`[Bc&+aSEDIIJUq"al8)(d*%Gfi3c4E@*U`m5rE9r&TD#C%FVeKX0PPcBR@K(*hqQ*@X%d6k0G+[H3pi%YAVhFfIR`IiepUK0(dcN"TYe"e,&bJbBca8Hd%6$BAAKqP12+qP,!SAB&m3IZLLcQ0p$1IFlI('SIX,G26$R#aT592kdjZa3`d2J%*8Z@kXUfY88ppp-I9aqZ3!"$*e+dL-`AJj8S1P9#233J#A"("HQI#TfQGKj8D,0&kJ6V3a@q`*9039X3-1j!!-rXjB2Lb[lj$J#CjZ$`&HZ2M*FkZ1Z0**3h+`e()i)Z0e28B([qf5XCLf2kpDZ$@Q6(GUllSlF(Q,)HkR&m,UF$aef+@'RaEKfGI'Hi5A+GR*F*fPjN"2jrp*h+#XIhLZ$'IL,L0UTpX@19mN!#YClVmX6$hFI!"#E)1&#FL#IXmkp6Y6DciL3RB#1V%j[*p!M6)[4UM[&[6cS#'DQl,9YHGN!!mDK,eCP6PB`[l%CN9VkE%D'V6eNl+(m(pP9'*Cm'FjSe2lU+b@mUj'UA-BmLd!&%YQb"Q!,1h6SRd*1k"U%$SMp'ZIj9LX&U(2H#h8Cc,B5Q8iULKL!l+lLMpR*K-#%1lTLcm5mjIB@VKjX'a1hGbdI4GH'(IHfU5*rQXQSrP)MjhV2LcXph68BT'hfkfdR(YiJ*fa0%Elc,aDe,A&j!!J*kLG'fTF+HPCD&!eVfmKhIYD5KR&C(q8pGSh5@)[i+5--kr,Xr-`16S+RpKUd1MG)"0R*%@01@,3fmN"k@X[cA'["*+FHPMCeDXbEf[fZYF'1YhLjFp)Mi%CTl''C[LcATa+%L!'ES1AI&XCa*"I`A4TY-6YNT*LiXpHGl$Zj1Vhr1Za4X1Ef*`4*I+m*F1bh-keDJfQ!BRmAEI9+%YD*Ph#pX4XfYUG('jhR"iEGc0`Jk(+ThZ#I(p0,3[hXM[+E2I9F'jpeNYQ+dEN!!8!Ea(H405(RXdfUI!B8U)f9!r64$qrZ6l3b#!N6'laUCJ2XDpbB4DlC4,+G0RQ2fh)[G'C4Q#i3`ZmTM'@c%bYqq&e"-JIiTVXZl'2U6hV5Ald23Z-0N[N[Vrjr$`r'$3p2)*QKflAV)k9fcPmm@kM#f5fjaP&9&"Q0U0(NRHZ&ND84EYm,imH8Qh*5p0a2*Im%JGSNDSH%aZcBMJh'E2kQ6RUl0ebGDqGYeEUDC0h9CkDCS#(TkY83S(S8VT8R9"k80qJ5%X%P,HHkr-K-*FfQ4p)Fa33*3T[AQ8#j&P)`+VT@!Aepe5A3Cr5-i`!ElImDVC1eERc5HHfm*H,@GYkUQAq&k%fm"XE++G[`hXD5YDS,A3D9U+h@8-HL8&)I3rTX[8kGEJA`21Hq%ACcXX,54%DD#LB@K,ZcjrbP'V)lhf,GieV@IqDKidF+'*TA[ZepA4)Vc@pD"m&NrJ!6mIHlI(KPaK,rT$6F(Lrh2G4T5`8hK0bSFHAV*!$aS0UbFFll*46F,KJmF0qE#1`@qVSCUFD)+H1[fQrRL5#"K")A(cK[KpCH*f*arHN!#+q0&PlT1D9'S'QRq42l5MdkZa$4CjBL@fc(6mkjX*KdEP28,9G!q**q)Q)+dCH+L)F**)VjXelc)Xf81p0+'GBcJB3c8aP#eqL@@iPCNU'Gj2%j`ZEYM"e`cV"NpjEr"r'eS%B$f9ei'J,A"&N9AD82eX`K5mljDe'aIieM9kD8j#(UNNG1*q,J%-#m-KE3e4IPDNlS&+r!!ep"VcMXSar6'SEZDCf$#%@a)SDjVfk2H9c)SBlY'4X#V@Tkff[d16ZMqL9%JN)3CrTpeP1mBa"5RH@0QBR3Ap`'jAY9[HA,TR2RdXbi"!a#l3NS0jSDM6%2H@M"rMZkR3GrN2NQ"YEMi9)Kea0XAlF6#433!eUmDrT@68'#jJcpa*rq04$U*30&c!iD(hlL9($JGL"N89,)RkkaVJim"S#mE[DHP$dPS)fVSQb455+0'#i&[XVE%K+%ifLqEDRk[XYJ1c8rk!qGMAE0Y54[%QBE2F[+'I0#9DRY*3R%0-rcUT1r$2P8CU1lKXUMQM,33DZ#E5,Y4ZfBpcUUSlm-$Y*CV)aXRSP0k!4306*q8%`A'IXT*EUTEUq96C36JY-Ha092kK2!d82Y%@8%HmmApr"armR[[KJ1l&kFSNV8@-U![&Ncq6LdQ+VVhD)[!VAYqE%-j55'%YH`9N-@*NXAJ'Xem[U1'`&iV!iEHRcb3"iQQq3Kk82J[B[@2,PZkfQVp%X4LJa'Y&HV&R3H[1Gf1$Tdf*c6kBDbQNdMLJ2bdCEJIZ[rVZBr6Ka)V3MphY@,K1`NL69J!'iQ$bleiD*1+cDAjN2lj1GG$,SG)Pc9R&VSACL59*kq*R0TeXb&kq,fJ[ik`Ec"YFkaHq'dRf2fFbI++L%B[IQ!9*`XQ84DFa6VeDf&,!`*L@9BFFLFZT[-q2Tb'i0$!VD[!QlD0qkmprKZm#MUFF$CINU!CE!&%HkNTSj93T!3I%@i@C6[bkL'3jZAAc+@aQVdX*q5mlDh39A[+6`DekjI$"-`rNE#bFqU,8lVFDA,DIc"DI[KdXi4DRScX-iPAZ9Q)51TDhp#3NGIMpQd&mab%i6a0bC)d+FiF5hr`1M4Em$jUT&dB,1N#'%"BY96fYNJ`[k@E6k&V5bSQS!6p2#S8pkK9Fq"-Hqd!563jj98N8FXqbm+IHh!lL,k3Ti*MCb8`A(GHZl%4HLXR6`ICU5cTZH9[")rC1ES3$iU*jf@834PdSa3hqp`%`f5$&E[#f`5$a,ImfDZkk+%``%Vh'&f&M'llcRAJ$dAMS0TkpfQi&BH9Yp(r)e4B`50'R1JNa$N&$9hIE-CTkfb[@'mG@EJj$NCZ#AjKqH3'D18--RZV&Uk,Mhf@L*S[&)-&()i#G0-K4mH#$cYBpfcYrYBMJi(2MQkNq(B0jPr1cQr(m@K@&5@EmGTP'fPF30Cb0e3*8fpD8V#m,9EJ68VaBFiHh&-J%4pmm,E'%R(@&0Yh(PPMFFPXlH0hYi`VCI0ba0jb(%,cbG$pI&$rPGNbjrjdSGpXjk'lUVm$+%9*884m,fBkY',I[`aSRG$`46@QqT85%pSdQ5Hpe@1AfMR8A-f8adfAX[1(6G2E,KR'qA`m3GE4D14hL,EL9PNrk55LP!!f!Hl-DCMk[II@64kQkjDA@3Ch1#TCpcTqcJUc8`MEUeR-mMi54pC)KqARqR@Xjba$MR1hZMT20K4%ZC1dRPbF8TMFd9M%f&@2#UZIiGpQ`F*Y*@8Ap`+--PCb6b,DRE*FV-N6K-0`Q!RUVNeZl2jP6q,SMAHR,!B[4)9FCEmCDi9Y+m6cqc2D*pfV%AQc`b(Lka0XUZEp*E"F#bfl&j,&I4Nh*2+ieYi$NiZ&TCUmM"9!d+P)`R*d%9mF+dTh+h'6lUB[%AmN3ebd[Lq,5,[KQ,Ze$CG#9V4(1Pqj)Dar`YlfVZ%%SRZ)fh3LU+A5Q*9&3df,K'##4EeH)RD()@4NJ@+d!cS%H[)6BaJD!b4%l(`B)E'LL+C,"&id#MNAlIjIEKdY5QJX$4dl!@!#$Ba4k#lib)E4@S!U%jG)R#Sjr+QqHHL2R,aiNrPANpVPXN!"T!YFfQ'BhqmJC6@@'9bD$*P(+phQb'"3iqkDLbRhh5P8hlZ@aqE0C90hhl"LZ!qEP%`HS*MJDfGcIRX(,*GL4PaC#cHUf0MNKIj!!0r-GKII0*`A!$UVcZ6+RF`D9MM1F1X4CihdK(a$4Heh0`lkaZ`8MaTSc)ZF2i9N,B)0Ed!5lRpUVK%Rm`4C88a%%Bb@SV%m),'9QfV(e%iIBT32+aD2kc(82c*dm$"Q@S#@3!$"C33)[L(*Jhp9AlA65ZCTr[DZGPF$rNK[fYKTE[Xf$!Qe(PD"AZ)10rfir`R,A@P#,-VmJE@+J1iJlB#39e,l9Vh*2A-d*EAfF1,l&-BcDjcb86D3`c-3B6ma-(&i0F`@Z6X4@"8lai"3Ur(eNRcHXmMQ'"hRHre6L6CQl'Z6QS)FQd4Pq#H`[BBFVrG&)3b66@A#AdE4LY`YUY62[0m&X5C)J$r9CR2a4ak4-@XJq5hfEfE1*(FfiR!JZLe0ked+PKPFeY2*Y2@6MrSBXXb6UX&)N0R5JXi%MeYPV)5kE*6[lekZLr@$TQd3RXN'k$dG9DJ$qZ*dL1#41R-SP1B4pj9f14L)@LpTh`2VPlefl(MeC-dDcEBDCpL5r(KrhAqP+(D66+F3BY-,MDJGLp&M2%38RN6PLD-J'G)@&l+fJ29!pEcF32N66ebYTMpkIA58%e*-h""+4D5$3A*mdaJc9XdZ8NHG!jdeX*M%0K%#f*KrJ4+PR-IfV3Z*8'I*Y*EadPHc'M0#1Irpqi3X-!`4lQ9b5Q(l[,'$!6SJQ%pd6K!2rIK&CeH2f%UZ#+9r!A0kd0D6JD6FAl,a`QKHk-ipmNN9cJYrGZBI(TAp#1q-Lb+bkHf@bL#18'EhX-Y5XbGB4iDUlCL')cA9Le@f08heeJM)H(!S@&MQ(5Ll#q1ZVBr5Yl#28Z5E#JB"X-,`LYpJQRbp`%(AFZL!RbPl6DJ(@2X+h"P&1hBC59FNf8G+8@`FNrNFAVikS&9F4ZTH[Z1'hMUC"8EheH[&a(N`qm$eEd,2ie9rBG(TG,',KDD1+("55+cB4M`FGrkISh9"hfYPr)"'0UY$[U(!1c+BEM9d-a)ER,9E!`l(k(L4J4iiIa"N"*Chi8a$fEqb4dA&RM3$G-Nk9pF2d62Fk*SE+IX!rUKpcPL09b6!8I#mqTDC"lBi4#)a1KUl21dDX1cGqX[,Y&dTbEhm54bG&DYDDN[RQ@MPAk2&M,F@M#4J5NMC``30%kG81&a1fJ8R#`L)(NN*LrID"lNmAlCK%!)GTdl9PBNidBYUGP8BpXJrC,A(L!232@aa5$p`d#j&B"@rQiq+D[q`(iq"r8V"CEPa,`[$fq#2CA*BZXc9irrl0Z4+TGBS3HaD8El[rRFdm6FI`!VPV-kUkAmcd!NlA0"VUi6*K`TiiYf)5Api8[DXlqZVJA+!jk[3Ue3C444*0F#m@aNih,pSTZMZa*N3rYf9MAr@a%0iA%,!Vd#J%Nh'3!,8Zk2c-mr*a!,kUb-k,Fac4Tb)[3%5f'N-bCRXBahRVN@ljp#"8%iRj5RV9ZY4pC'AiSqHJfpef#ee&@*&%Pq2QcBeFj96pKbX6[&T(iM3q!q585+K6-e)lf%)8$lMH&V'NXBM(19FcSGfXQ+Ab!Y+#)!([ba-IJS'kV(4UF)hcTQqlX#G5Xe`J+IH*fbr$@U"AfdJPAb`-qNIHmR6fGH8ikm(3i0@fc*mqr0j[(JS(Vb(YQ-B))b'P"k`&@m"EA`[!J6a`QD"M1,3D8cLG!qbr$f`09ZI+FH1rZm*NRJa%6,[VhqlYAD$#8PIZk)"R-lpRN!"GGcU%['a*eEkZm8+rSLC0@kdf'BKUL@b9)@+%eN[I)%F1$MQST!(bNUM0B([R2SVmBrQ`6T4[DZYrlA#m0#)X1S4+2(M6h5+ke28RU[#VG8*e'bI-`R!2q@YXAG4d3k1Ar#U$!8H4`)V+Z%52Z"%)i*9h@,Cle!+$ET6q#[G4Cjj!fBP%KRQ3!#1DN!#Fqfr*)P-48F%ZC,+5$!PK+Ej6,,f&H,j8,hN`8GL%)k"`G$pq%(YhMBfA,2qVbS4kI2XT65MmLG"HRFN*hTiREU-'$jDb)'jdRK!(rmrEB#)XbS3NrmmUIQ#D%pqd8Zh4V5!ifc+i9*R9(ceILGSTGI#l`Gj*1la1AEHr0T9D9@JP(UE*58""hS*ZRIc`MB8he,GAKPm8p8h4U4I3#3-a+Il-SBkETMclGVhmX)kdaReAR"hQ#G8k!HFL'@(l"BV01q2$IcD'AibZ&4BK#eqHBlh$@mcC&*(`V*M`RkhG`(rcL"$jeVEYfRKp8XUY1p!5Khk#,+,hZKCrJbV1EPK[I@S4meL[(AG*8@8!E1#YQMK$N!$k*#JR5[eF0M53!-FrCNXV!Uk1&T&6%c*G!'ajfC'FKlDP*ABH+hm!r*)01R)0fLe+KCY,bA36kb[,qU@mYRT[EY!jST&"!l%RKkZ%mCH`33RHrcL*6jGk%rP0iRf"VJBTU+Z06ET'fNBQ*2K#QqKSHf0!Lk[r[fDM1f@)%DdQV%pGl8GZS5dhUeD%2G`"IZ9)U(-CJ4LlD'1qUlLD$IffbSbH2C!!K"3V@)%Y@ZXA)V2Uj@BF,8Qq'Y)"m[YpIHGkTBeX'@2KleMmR&TG+K!TF32568E0e"QCkb8i1`MNIGE$#X5e[ViY16L0T(5'aGe)K@9(UPb$!$'REZipdbQil,9Y!AXiQ1%20ZDS8'r%hT@N8A$QZBq440E#MXaR$KX,E3[G%YC,+VAKBEl*Xhm#VYe5"5`e)F3bE4#8c+DL-P+'1YVpR+i(LL6ILFKQ($SL!-FFh2,G!$0f1NLE)&e[b+G4)"RAA8DcC"*+bhXR'!2f!HccH[k&lZTl&4K[q@F#l0$hpjYGV$PjLeFSFPPLA)BaVaf49&Rf'LY)ccS8dP5mR3"cTk)IBI&6&DGQ01D3!#B%rIjD9(6)qKZKiCidIJRdqeb',df5iG8#!NGD&Cd0ZRSYEb1%MQ$%imbDJ")a'1P@"D,rm0eSN!#`01iMaI+1)4XKHrLb2(YH&jQLXRSLN!"1GS@I+pbYkSQX6U!m`I11l,*a63bVPd#+`dGNpR01lAiijGE5kLK%Vl*[ULUd,S@+C(JX%iXBFEKU&BkRIq$25rX%a)5aha!TC9["r*d&!RE9jTI14BY@$ETj&aPDP-cA!VXU'&iTQbhqfUjS0i0,'C)R1r#p+V-Um%q$4R%,rEX#*#lceT`l@J`F0C[#9DHa1DScd'd56h6Nqjl)G0mA(RfX5j!!(&aB)JY[Zj!!'J9NI8qh`MJb$h2iQA!d'B9SjU[l5[HHiTRNFmrVPkBG!!cIaXj5QT+j$bfHZ+0+S(hGmjq!%El1`a$)+LcFHc'BFY8"+&RkUFN&qF!&,FaB!JE4h$AP*kZd'@ZXIXKkQ-VNXe9(,['ZCe%aFBXJ6UcQ)G++%bBNk1bD129pVpYFXmhV9-Vj1m*eq,j1$ilbYH6N6kSFrVAf+!Y%NJUi#YJJ#6b9RZ*LQqm+`e0lNT2kSQlZ#X!eBQe4[qb+qR`&Gk`!"Ebp2`cHd2f9,cY(H+#)-#M-NBNZdeK52"VHCUT-"UPl`-K'm3RKCbj&iEErMZ[r6-X4LqLrUAf8$'merbi@SHdi%kLH&Z5Qd#m)a#C0CMf*Ra8r,U#SDiF8&%#p5KQ-9,hd5Y!IbmfLbbel@p3@[T41fZ2Nqr3Zc86e32+jAf'`Y6T&NkQV4XGpl`TSf0PQR'3CpaPGDJD8C0,U45qiHZUqH)6cCL'L5A4j6Rd!Ml'F!&XfU[C9&hicH1lCG-q@8L!D&QcSGjFlrkQ55&$5S"%j#pJcL3i'#&aVF!laj2+c#&e*m&iDc[63*!#K,J*hDjlkI!&k1iB8N!$m-&@l[)"&@PL&5CV2jHBaP+hN30J6'H5ir1YMZ#XplfAIf30h,p%rE$b*pkmcZ4A-1XmmcB0dQEDUcr9Z%J[SZCaE*E64JBJhcr99$Qk(JSMcK0dMAeVChT6mLlr8,$22U#[j8)'e8Ec"9Ba`&S[(VNhG9IbRVa#)ZpAe)B8V6VDCe@F[cb*jiR5hLd358!hXU(V)$QKe9[PhdYI0&cdELYc1#ki&Nj&PCad2BX8AiEd%6ESA9U+#8cF!k#$EBL*'A@+`hUjdZ5'14kfBcpP'S1$mH1!06`p+j1ecZ#KZ*djp'c*)hlU9Clm+M%-$+T3@6ajZPMiehF6rqMbDF@kYKfVYr!($#kD&XdJCjZMdDDLGMVVZ8FV`HRDGAe5UkpZkbQ&Xi4$c&"K4[+VI0jFT'FDG)+0RahmbAU1VR&2qbL@EZI%"[mr,,)kcMk*M["NVZaP9G9Si$cLJ(b6B2hDmL-5#(I+)Q'bhASE%#LJC-4S[9%kfala'-$,@U8LSG2$li`$S#H*)'8Qm9X-jQ+NYpP2[#D&+6r#NBK4C2B$1`"J)(*jXfHM`84P0Db@lKPD*)'EN1X%p90D$4AUUUG'S[QaRYje+D3TcLj!!f'0Pb-ppVaD[R&*86h0SRABN4B4HfRBBSU3IF6E&e$3QHN,9l5V1i(dph`aAjp!*K490Ch1l`E)J2aiPjer!34Qelc&8CCdY+ae%"4q,X0AHMGPSeK"8'!'&!dV&0Zep-c#4iqm-e+T(YrD1X0m*&LI9mTP#[qZL3`Kp#fiHiLU+SN1+-a"'K`+,!NSHi'8V9K)X"cD!&D66pCX'*cc*S-[6NeI[+#rN$'4#!N,`dHXjPSH@&N$kFM'E@(MdB9JTKZAiI[&m0P&aHElGVV5H3q*QcF[Mhbr8Ga58U'[pN!#43I5r(`(E(2@[dYcb%%pdTfJP+IZ5`"-)UBD1hAQL')dC2S[aIpT2dbbJ@L19GDZC&Nk('XUBJrSk-lrmqfPdl4RQ5rPICjLE1+fSH),Yj+R(!GALaY,4QBhiqle3$h5"m%NR#9ACf6K9Q"0AjHYb1#C8,0a2C!c4(#5aeK%D[3#3!2)k2RPac[CZVj+4pMrIG%SHaCj,@6l%q)[D6(-Q[(8YCp(@)VL(B$GM[&rKV"AhRYF[RR58EKl6l068cBPV1BI(cI5k(SpdTh6B8Uh6G28`-U2-8KP+G9[mhS5X$dS$-N-k,l"eD(eJFp9G@AREiN$'Rc3++dUCGeX4H*YJBQ%kEP'%KZIX1F4,b2VS69L+&l@m$Z@[rMB2JeYpb$djC2@l(icl$C&L&A)-fc8kR*480d&FA,2N-B6P#)j-60GXV&[CAdUU`i"XA[cfKU&*M*)H*!8(eY`%1MmI4`@Nmc+66C-je5@a%'),rHPej8mKHfhXZB@"d4`b9Ck#f,N2*85"%dG"mK-@NRQ5XSaq0Eid)$eh6D%p+!#DlcR(9Uqh6`8NNJ%TRmj2)lZ$UkjaZ4ZBV@#aCPaBqd8SZLC2f#2A0l!a'Gr@+@#IqAJ'1GFiqIQ+F&#lFF(h51&C-`#MCN'q)p4@G6fLf#3*P&lBIY'r5RLfEd`bDVAX+)ES&pjlMDYj50XI9Eb&G%0[HMqaLpI3XZK4cVZe(dK)M6SIHc31df*Z9Kq$5f4&EG8$0Q`F)I(H$@(i(MSTMXA(aMY1bp%NkB)"IrrqPlC5[MIRRc!Vc!E'#C8fGp!34"2!R**TLP(B*m#F`HlG`MmKB1NqETD$05"hJDe1e8$Ybj0j)'2(AS&)X5q)SVPm-9@8E6YF4XKEU&MqpBK94aa!YiMk8j,h5D99kqqVT%SI[RmcHL(-R['`b%D#"0QRRral)QQ)@AkGSN+keF0&,N9lN!$Mm(dmh&J9Hl(SP3B*S1XQAL+rCb`kXf8LGL"B"eJ!kQ)3[ah3&jF"f#TTeYMXL`JpNVUli6YK2rN@Xl03r,rL3GA&N!#%q@m+H)BDSB4QEJA1EkrU"L"-X@Mmddbc@N0e4XDT18YJmPI54@PF1Br9D2[THa4Tc)JAm6#8*He1SU,,(2((e$qUa'A*k&9lA6LC#[He!I(`4KFf9J$T$*RLh$'$0KALDDYlA5[DG5NaB5RA1@Jbm%fEAZe%[X2$irAkk+fDD@C,-%RNYZQa9,%jL)kU2hl9!aPHQ$eYQqUq6'rl+0MQ`VY'a)1KfeNC8%NbM%UUr[''BA*YN!#`JDJ&qY$[&ENUIPpP*SFmB&fE5&LJmaU5pY,`qkc9RF4hjAT'f-#!4MaRL++5S6VNa"ZeUG,'-T(jfE@JeCK&X`6cHHAcZJHFq`FU&HfP#[Bh9+MV6U+JF@[[*QS9le$*k8VGCp%S%jV6F!a#bm-+)ZN'iS+hH9[h(pJRhRSRl"h)')DKmib+$@UTYq#)E"SJ8QGMfj%&RUEZ#Vk2VHp*Fb3B9Mh&Iaca@8q+T`TA`&m3Rjd5$*hIac@G-qESc1$r-,H(m&h*ErQE$hj(8Mcdr$Ij1"%I)P9V'$C[39Zh'4!R1BHR2,&V2*D1#fLH8raI+ZjP2I23V#P,Q%YMl6ZlGS-NbB!*8DK4ecCA)A$ARY+i6'##Y2PSBJ+RY2-S-DCAR6KK-,HC(2!(i@r46JG)QJ"RPh3a+CI*)"`q(I1[!e5MK(ZS8aGSEI@F(@5)cHrr8ITNr"6!9V'm`d!5[8dQmiKYKXLFNE#r0e!YqF%XKGYldbrVhHQcT9fca**5`-NlC#iBp5e),FGd@p&cMP,AQP0KVqXPChNV$MGJE[+THq6PHXZ$CjhC,N4kVPi@pkdS%BH&!RC2XCJ[,0DBB`X'5R(c6ip@4X`!4JLJLM&S&ZUbT$CGTX*&CeNjNM5$q*U$d(I&k(r&U0BY)BGpIjd10(@$d!1b#QEVia5IZY)eSmIYX%@IE`LmSFe,R2)ahX$$A@F&%l-MbVlmpMXc6CZ`XqRY'lJ0BGMXhd[Aqqe&3NNU--YV(2-ES1Md6Hi3,&f%U5QNYJl*5)CT+PErF'+a"%GqAM,Q+X'eJ#'-SN#qLk+9lA0b18R(P6qBq&fP6d!E#H5HMmLCr6d&LJhdGj`dCmeX()!'e4XArVV2&J#IGT*NSCq(lc%EAr%-Q-m&3mHiS$-N,!BbjIjRq`X1$mJcF8bl&PhP+3pdIHikJU#T5@P4M8PTJSMeaK6)dYa*5eVI-(h!UHeTb`mBq1*F`qN6r"ed!IK#Np@I@D98pLS4cA)R-4SP@C)bG8JYB'bR1B9MH0cmKaQX)cm[DU6!T[ZF`CC9k!,+0T1b-S)UfQF#de$(#RL+JBm)eT(r!!PXdqJ[eK4qNDiJ+M$kTJ"a'95LjQ9f4qb'b&qfk`q3!)4,()8c#Yj8k)%j0+m(E3VQ0iXH%,YU*#I)cfZbS&5F'GBG@mV[rFi+[&Z6mkfP8E'mS@Z-j#+%Rd,-(V!+`%E+VTj2ZVqQqfhq&XAaq$*rXeJ9cc)0cip(NDZEa28q!+2`SHMBj3-('alc32b(d1rBN3$QRISchf5$D!!%4B1Uab4e+k*M&-53!(@DmQ+hXM`QZTF3-1j"DXMZrr4c"4qY+X"Vm%llAK0)c!X,YY'2PVNCUm%M`,G1U0"aG@`,E8U@4(PFBL$q+K3q5qXDm6B%qqcVUhjqSm4larGaAJS-Q9acj"Ee09i+k`0E6b8deTcCD%0H'!cSS@9l!a@iiIi&LTI1KX6D)Ck&6cj6T%94eF,'iJ[(GFM3VTpVmYi1EKZjL",k9KJ22FG&5pMCR(%+Z91+L6A11BdR4$'LbmHG!KIH")UpI2p&(1FSkQ2irCBCHHAR5r0h%Fq9pNR!aPE0Dr@L2Y3C'AM6'5mh"P([T)hK'a2mMGb6M0Z`qZD#iJ5,2Ra1RQrjqY,8Z4IXI!N[8`'%qHL$Sf"Be5V9rjHN[AUk5DT%V*!!9-*LH9IF(*rQi+RV%#[KIbBXlR8IU$X%fX[a(+@pSbY+N!!Gkc450"*B!MkQG@dI$@%b'mN0'fGJrY8iYVUaEr)T&S%hV@Ec-kq,46#X,j@AZ,fXJ4Sdd%$0+VUi59GL4YZTRU,S'eXQ$mD,[J#AU!4JRIA9j28NPP$I`iTJfSdQ2(q4@IfkJk,lcUm*kU)jD2h%VT9`2)VQqKL(@Va)*G+TEM@ZJmlXrm"SZ4P`-IY5'j2U5(0LfX@I5Brb'2ABG*P,"h09YQVI)*!!'"&6(bckS9J0Uq"+aBrTHrp!$Gk)(6+2%j3P,Vl*5EQSk)dqD@"DQ`E3LJmJ2+Jrd1JKV-"+I1T8[qJ%#PMM8R@KRhQ!qL)U1eLDiI!#XqB3%1Ha#`j4RpVE@%e''UDFq486pFQE2cQrh$rDiVHa9`He13PZb1QB-mKj*@10NhC5`QHEb@ehGE)SXcQl)BG9a23SRHL+A5fia5$jh$$4$1`MS4qHq19Za9-T2DH$4ZH$VCUAIXm9*EU+qSS6P8IPap08RB@+2VPL6SZkiDJ3k#&5B`6RjZ5Udd1hPS`%@!Lcfec94aY,,RUa3Gdr*T+cGfXqDSDZ9!i*VeGeb'ZY(#((U-$G)U4kb!$T,iLRh+b4)Y!L3kRA'*b'fHVUSIRkBL!!`T+Y'64GldZcM$0Ui"%,FM(R(%ZE-C@GF4C6pfq`B#"b9"Xl'PQ5DMdJbb'i&hZm-r5kZGQL1CCk%#DN%1Na*l5XZ`Jp1FP'E[lqNq3*"Nl08ICEEJ,8(!8!+21&MFE19$p)c&K,5JjQ-m6fHcMXV8qSibd%M[B@jAbc3QT@831P1k4qcj8cIhHeI[f2R9Ra5[L+2B$q5ea[,H!JaGX1FCjLF6'ULARFC&Q!QZ(H`qqka0[crMCBiDpC-B#8hEG%q5T5Q"Bdb"KE#LQHfLJ&GEFpA`EK@Kc0pIV#bE()jq'm(+P8l31mHF1r-9HF@`!`cZe+DPVAZJ&@a0VTVGrEdA438Sk*kiIClr(e%B+Q@J[i))-4$18L03G%$k[%#Y+S)+ZmqIPeXTdq(Yl'e["#fhm&XNVFf013!#lpI(U06J0p%H*04qHU8P2H&0(d*FYmR-SQI',+d-h%12F(@$qRBbS"5&$4d9j)#VQR(D"(XFJ+#b4lXT&S8r+3!2F2AeR52"f$K)USHF+$[T!!QNbQ[(&8L&H86"K3RT!!b@jGA1X%6L2YH!KEAM,%mXp%i"eTiN*M61Ar!#GGMj,rrcEC%Ye+I$kUbrM6Nm$J[bb@+4pBfXS%4JkV)PrL&eN3I'df&dI%PM9,c$)JkI"JbBKX2hE@N@Zr22#2ZZNZ5qXD0fN'k`Y%k9)(m'R[jmCTaVqNdMk@ET9P4c@Ek'S54qAJ#E-@DUM#9c0M-prKS8EHE#mB'[hrU[,0#B4TA"AlUY!FEV5ffPeQ[[Cfl18-X,JKBkm3*#(mSe1iC$`%Nl11F`2NSMpdUYr$QVPMADhAiNUFkU#fkKjIqrXj&FBQIHLA9&1MHR1pa6jD&V-cI@Fe@a+lm0,#V)(,8p0a,r)LE6"QlNNdk3-*dl1q$`*NaKYLLZ2J3AJ[d@(JkK1+Pi5*+qGddiUpm&b&iSG!,`URq[MF8$L3!$fL'+p*6Y+M[6aE[ji*b'0NjFJ3&8jpjN1c4bqN49f'T-@F@d@h8hDSRqdD(AUEm1d-'qk%Gf5fFEi1H!&'YhF"JEC@UI5i))b-&0,h,'"+bPAZZB10%`MFU&JR`D5TbBqa'mG8N!$aN!$6`mfXp6#CG1QVCCF%1Z+%EMI`C2!(*jM09"C1HYi-(#QkUNS+TAEjiC1VfZBpH4Xbb--9")'EXj&UCU@+T$2hY,,-Y$@Mc9rh,(JP8C@Jh*aU"2lU2-(NlrUqAr3b9JN1'F(E(Z,CAhhb2V*$,I@k8DTYUBiLZTGq5&JV!l%-L"&[V2e(@b*IfXKk0`&#`Q&5k3QFd8[!1ND5mYTliDF1T8-N@QXTF-Uh'10NBmAbENA"&T-H8RE"R)2UFS1T`6F!4$hm`Ge5KGLGmNN(MpklmfLbr3GIQ(3[Nr36RB5%D1e1D&FTc1)-XGE#H)RkV)0Tmh,L5UNBT"5DrfB4l4!%G#d$m(3Ljbi3)p#jD+@$+#%+U'S#DeIQ[((Yf8CGX-GT0p'"'p6qibS1$i#U,R2Dj8i!,eS[)Bid3f(YRjRH@Lhj02+Q%ENLKCSFXcp0jTefrH')N!"qV,GP5G-Nm*bmcLaNcc!)iI&iF,#AYC9"9MV,,FrYMl80XeY@HG&(6@2A3ASkQ0XrSbmf`[I8A908ZFNXUGT+E3ZX2MJCT6+GHZ45Mf%@1b4B83X'UN*AGdm&5MhkS@6Sm%90Jh55&1ac5DliY!r09El'GriJcH'DGK0#62B&P&UeL+F,B$K-JDdrU5ZJh1dri(`6RE44p%a(1%4#B8dr+&aaU!qq!A-la)L%@-MSEqaVDRH(f&,[I4&Ek-f-TSKh#FB9-M2YAf8e$UNirFcjbTSB2*,3E1J6NpjXQ"DZqhVAak6,&fA*N4[bPrrBI64Vc0HUhe,DkUrqe'4L*H60hbJ1YqSRQqdZphdL#aiHGIeCrVMiDD-ElNP*V$MkTB'aN[Ll9Ic0J&C&rUKb-dKR1j0ekJqYNlY)bZZ'FaqiB5(l8HqZ5'BM)8VNQrI`"@(DMNphE86mY1am+S#Br9r9F'qV!cQ!mXLCS-$ejrId1Xa2AahlL`-!Ch@3!$P0qM9bFIS(RCFe#2IcRb%0(`+2amB`KESNJGqhfT!!flP[IdT!lCC+LQU`k#QSBcUN8'4!GDL9YqN5YkfAcRNrKGF)U)3dm2&)r'L5aHU+G(aFU@9dNKV(C-BAXEPXH9')Ze1T%'cUD2I0MG)#lbm0$6QAlI(*DUi"4SCMkeYBhPF4hhaYFF@mEQISX#Bd1P28bG3YH%XQ3I19B*h6f(VT"FipEeNY5@-hHVU+M(F2kV![K'&#k`qJ8T69lC`bTiHX9IK+mC4ZNMH3!#12%Kb#5`5dfVSaB43lViKS6KpTh+a)KP(X,*26*2)1+%N'GfQKEMf9`@DAIj@'B`X$P(4)I-J%JGBiUj!!2eq0-9[N%"Vi,#0(9[XJqKDrb'F9Zm[G5Si44`XbFM'$CPS"[lJT2M09jNY8Y-dMaBh8!K9'pX5BS0!cU--GYbZqabAaP#j)3jC!Nc6rfC%-6N!prJ$-Md1XK-4Mp1Ebkdd4BDiP1edL9e8"VMfY"6d5c!9RaFrFUUm8,q1*pK50HFT2$NqrM0-RGI2Cq(lI,i5(4Zk6Fb!rZB"2[Af-q`MkU8b4S5hfa+kK+L*r!63fJe$)1Tc*iicFTZl)-K!0P'S(`61VqF2`KiAS@3QiD2eD[eHLNP+fG`+q)FR$p@-B+@rl)*!!k'i1Drp[VdL241DdHK"F504"5&0[ej'GiXi"EPe5J)J$T(@a)B6-",(NNUJ"*!Mm&qS3@9dBSciDjJ%!&AX2VHK*(+",jErZ#A3%!r5VcCfkLF&BFrhIKHlSd@V3XbTpJaikEN+lT)h)1F+LXNF8hdBer6)CM,4bA5Bi(C0h$dqI%Y9CbR4BDL&5Nh(IJU5q!9P9+HDT2X5@GJe#peI`-DL&V2#+NjaYJlCqKIX#Zm$E$63SKq$m8erFbYIE,G!*D5RBC#*2mBTYNi`G-mQ'rJ)0[X&rVr4-b"b49L5EZ*Ha`A2$FSJ&chk-3D#IM*,3Mp3H@[XP@IJYmC)QNMA!MC!!-Y5EP8TB$h%[K0NB(G#qJSHcVMXGRVYm9EL6B@@,Z--&U1i@Pkh[-"5)LKfc3UI2EJlC$8eKP1+J%@r$LL*bF0i@'`A$"JIBU('qFlrM[E'0e0!16!RI&RDqAD!KMRkeG9q[TC-DeH-DL+AcaYmUYhF4QZ98h!Z9JD'LFYIJTLk+dA@Tim`i[GEfG`SS+`eLLfJ,fLQ4Zf#8(32a@m#k"lQa'dUMbl8a%U@B30CrEQ1b@K6GUNa6P1T#IZYh0PcN26*YfVHUEaIpSMm&TAGP0!YF[ZH`2(rL-JpeGRb8CC6Jp3U0!SShCMG&&2Y"XBCmm(l&8Ea4$Er3GDRbFFb'CiqZDS1i-bHUid0&e'S#k43DV9VI3CraBBIm`ACTAL`l8p)d[+4GE8bYUe36FNrGeH6QVpPj#'bY8d0KeU%4A%!iNEkH)ABkiHS*PDS8Z8i&q+1U6b0q'm3kEL5Y8Q@TQ[Ch,ma''PqEZ!fr-PFcj#Q'0E0-Cfc`&l"GiSRAQJf%k,CT,D'8l12F6F6J6am!PEjIDK"JI`2""*4Ta"3D,ApjKV#9J,mmIdrY@93A4AqmPj5dD0&0C`9%2!JJ*rAjAlHBJ0Pmpp5!,l5bYNfUHbI0A(c5X$jAr*!!a6PRGVA5SfbLNS9RmT!!h8*9Qf(K+)2BlKLJBX0(F*qG1)ie@'jP'!jSfS,8l1mTR4YT9A3U8033I1J84GjA4S)eRU8L$pC0$M#FqY8*S0DdeHSa5h[2Z3A)rpXR2GR"8Ldj"90D((A1C1@@JfqMmb@Fchk"m)4,L!+Q*'EU-qC[36IMLNZfbFJ"P9ZQm3"I"$R`YMpT"23V0Q)#l"89DQ[q[-$''MUFNaLmNL&kh15"RXb3!-E+TaQf%M1%r!)2fabMBl$3Me6#cpjf)5-Scaaa(VET[dl%fZe4(h*'LaYLB*i)T$FKhfk4pZTXhGrC&K&AGM)r8mNdL%K#U1II#pdr6Vid!D'B0QT#"ET6ViZGf9(4B*Zj,EAQ%b)Vekee`9(I,X&NNY*HNG`f(bY$1q(li3DaNE8fLdArRU9mG$US2CHE)PJ30%hE&d5&P+V'dbcEkZVl"liDjl#al)qI%cr2V"*jlcbi(QM!EG,4Q@bC8930bcHm)0(I*R6-bl2*'(S1[P2F"ejalAha"1C(hS@1lN"amG#QXa,IIq8mk94-A"Kd(eQ0@k53!29lq@9hM-0NUkP'EMXc3ZUr3&"2ep#G8+I[*iB3)$TmUqCBCkC1l,F%qS)@feCi"kC4@S+bESA2lL!+bP-irLbh4V9"!LKQp0#c,4,H0bcQ%X`%[1"R+2X5F2(a`GjK634-%)8Y9lRHMUChG)e[CM630#l,&m(Q"&UTEAaUlQ$PK"HG1P0kmf-#HD"0)ee(JHB5j*(#b@`eHrAk*U%bi6fAaMB[5e@9#CdQ6q[YeQ`rQ%p(mX$N5*,%Z[GUQI!HIqLr)CRr9T-BQKbZ`KY!JH2b$KN+#p5-*lK3VJ0V$,Y+[F2VdeG[(I+3!$a9jNFD),m'69aqABP@)'++bHqPK8G@l*!!cld,SG)bAqerRAe4ekBQP",8p(eNbl@![`Lp@@+kYF!cV&3LH5PGVlKfL5+RYU&5@E%Q&#)R,C'p-VAVEJB$q-MIqTGHXh)d(EM@8#UlRrlS)%+EGi3cbhCm)P)C64c%PLFej03(RlPF82*(jICVJ'F*c1UXSE08&9P!JPC[ld*40bE@`rqdXSFlYmid6'`3'c!AZPZ'@U+UAbpPCV+kCDJFa)p0YQf$(VSb'bUU@A5Sp[jLGV$2LNKk6m`92JLBFrY[H+CAhEMNc(EZm2UG9`dTQ*)r+""K2Jpa*1J``5&S5,mcVdIMQ)"l34m(0Ta4iYAYjT6+*1c9l4l$4c#D'0Yha#!##%(2!5RK@'YfkUmQj5--X1AHABXm&TRJCK41c#RQ%+`i-)4Z`"%QFQq6R9h"SY6PeZ1DbI8X[T!!fm&k&LhFH&X4A@)iH2j'@Uj[ERP&GZSpqUA4#-U-FI+ZCQ$pda1Xdh[hik,-`1b`[l,4`CJBUC%jm(QLhT!!Y3IJQie6DJ(-l1[KB)RMPcGk,Xm%G,ZGFPK6`$P[HPSRKJmN'N)IEp)8FLKSJ988rYjqmb6M#I`l#Xcr6HB'0k0aIET25dhMU8-UV@0SGE&QXZcGG5cLHMrC!LN4""8XH!5A&f0re2lNA#RhDffm*2!)m4AGC4@*LPq!DQNkZ-jpJ2hHZ`+PLeZ(40-04AmU$4akEeLdqVcT@26@+Rb%G,NRFe'#8k*PkM+"kYQ`kMX++(p'K#X-EhN1#1MP3eC$44HhIY"4$G)89)qC8)YL60'Mr"m`NMc!CaeaV8)M&0)Md4&Cd1V*PMfA*IYLi9bXefVQmcJYNViR%`,BLEZRTX%aF%2DFPU0@h0DiZplQPiF)&Ui&iIaQ96U#B![H(h-c)h401XNc-qaC5L-jFIAN!#V%XIb(U0HFFCN1X,C$p1hH'hE&m[R3&cj1#cCKAh[9FYV3*pe9IbchTahicYGRB%rHqa5(DQ@-eI9$rqYRNp9K))``Yqk"rc1d1q,UCLKJ*P!04RED+`(hp*'kCP24C*1e[@)BZV1k@'bX$SL5jP%5(YIFJ)bR%'%(mP'q`kZVTamdR%eH9Ac8ZA5P*eIE"!6$BBkRjS+,$MRaH!qTJJ`qq'bNY01Zq#'[IM$T,eGR!Hc5HHf'[N&C91"AZj[lHlEd`++JZ%RBZ3Cl[A,6LDE,5LpGf09Aq*UA[FUJefkDqYa-[$JQ&Q14FdMfR3l[mM8THLT[cI8Ij@KQYN!$Q`qG2q`klJ[GH&3j1,+AqP-2UZb%)F8STT6Dh9j4#3lL9P0&"INF!"H2rQTAVrESiL'[d&&$jCCFK#j6pchLh8dq)%66`#$TPS,@6$rrfq1JlBj+l-,M151EZY5[@48AB9Vh2jMQG2P[#c5DP0br+*@r,mc[aM3#PVJ(K*MKHLJ+P#cIe4PB!#ab#q3!0*D@kV"rSeQ5M4IcJpLC&r@mG`,kiH6dRmYkYB+aR",&4AC66R(YK8aBZi-@lLMf+F@2rh3,!Kqdqk`25D2'T,jXJHJYYS$T'(RX$"Ufi,LHGURd#L`,f02Kl"rM*bf-d&3(jmkpqmqGTE4d'Nr-[#K`[6XK[lHB*kZQE!k32*B56aYUejF6jA`N8`bB(Y'HNkP5D%#4SS%l*!!#EmXUKcBRL8jXp'qFCj`JER`kKk)DG$apmCf6N9,5q3+6FYQpIG[e!SNLp&,M4d@A*+k,FphAB-E!EQ4&eMA1j9cdq$QP"&h$JbDmEHeIDm2rj9-Dd8UflQ8JIAJ4E3PG4iN`)#V!d)#2j!!3PViSR4PmG$)Y@)Fk)lDl"8N!1a1h[&YZhB&5!%a(4%+CVMYRlA8fYp1IhKSHR5&`-`*12(aAmA5#(&RAX%Jq8NPXm2K[[lNDDbaSm"Y)@&rac+f8)mGSiM4*k&5@AC3C(e!kc$2$)j-kb1f!kN0+Tq6UbQ6lAmBQEa&1MeAVcRRSHSaSUhURFN[J8KRC$(b6QV6322pb$II'P#3!,M[bd+3!2XV9FdVIRU'5YE'$#YTpDArV!ZJ$lQ8E$"4TK4"1E+hdAbBaR%`UAGU2k*BN!$'T,M#6)iXkmIMllFC!cqJ4qC(%r9k46C%eaRhjqIld3V1)99h!r#Q,qfR$f`TXc0ZSXP$(mhhX2a@39LGrHIX+l8FIj[`[*mkHM!+2HQjZKLcYif@T9k9&SIC5rkZ`qGQEN)mT+$0Yl58j1FZ2TQ[NSB*9B$!GY&a-*A@-mY)2B*iKF-REQ,bj`BG*j9r#p`b&(NZ2bTBl`[TL52KME9VjdUJGe@ZQTcP#+I!U3VQd1e'Zc+5b`4jJ*4&K,DZ[22ff44qBKa"bqR%crp!#!DXaHCL55Z4[bpIKJL&h`e01ilhBekr)VTGFD82T9-%8*aiM*!!8QfrKqLEf#e8Y,*eJ+dG6h`T#JI5F0S''[6XXd-#m91Tc5PTq9)mCC0bH(&QTiJJ`ESH(5b$9F'!M%CF5!(DdPf)SHmDa(lPMCVi6"#N8UKq21bEi)TkfhpL%#%S,Rk'(GHm*T!!U"0U)a[)eNhqlG0-Ib,!,E4F'0lY#pp[QQI,a#QbrqdVXa-Vi(K'LY6ed(K+0F#jMIGFchMKki)1QcL#@S3$0N(&j3Y$[jHHDY-r$4LD"bhZSXQNd+mdP"4[*dq8@H#Db3K!)dX[)&5+Ap#4FK4q%D4[X(5B-5SZSB32p0QBdr@G2KE81Yal[l1MK"Y%bKpqe3k$p#QJ,afm2NFa&5m2J0e'p&ErL[eQ4,UY'`VMG1K'ljQV$*iIm$d[NEYIrNHbN9('"1XHQl(Ma1'jQHVbX3%%3D,E'E4L)pH$I5U@5-RT2Ih)'I2,hE9Q9bM3B"Y*qB%`q5S4CX*RbS[qMQf12A@H9@&q&ehRY#dG-eVDb1!2RV%UU5Q0GbhX"`&!G!,CfU&C%c&J524Fr3#qL(0KZ4TI)'+9lk5XUL4"&KGCY!qJL-DR5YKSA*CD&)XX2k'%REeCAcN1'Rf*fflFB51%)E$Epi2aebXPXD*b&1B9b+0eH$)-+qMh1UiGB4p&@1Mk@a3p!JDjT`KD!hZEM+ADZibZ&HZKS[QE!)Dl6-(*E1kBJQ6pdDKK&N@Li#e8#qrPB5Hk&P$KM[,`5JciHq$GRZhBPq)pYbi)BMhI3VI5$N0ZX!#pY#@NieL"PK8i$G+FErR,'"cq%q(e0))@1khBjJVN@GrT2VmHHhNk(LkZ,'I@8KX+d'k*SLRTX5H-51(02X@#$`@`Gf[%Hf1@Ab%1GK2NdT-R,"FKM0*cY)4c$%[,%GhL-fceab$lHe$$mCFIET'NCG9i!JEI+Lj&Ph1&PJIIkPBN3U`#38(*#`2Xb8m*#j)GpYim"JK`p)`P6II2*$#U0cd%qQT!'EUXFDZGVdfCS2Ne+YEjGB!6+3B`FUEj$kJp)@IL6Uf5'd%*3E-+3`5-+jDPbFEPTNjer'p4m02Jp(Up'@,4kS(-l!L(lM`3$"f()i&m3l8LbDV"Q%k$2d5faP*&HK#RDf@dK$B(U@!$pV%EkDqc)cR2,%$T-XGEjRhqPFLP3,+"Fc#,q`B,faL+@)h6-FP"h4#,UVD@KT)Y64Fpb+p)EDF4%j+'-4-a918Cem9,H*lrfPM6#e82bG*ND5HddJaIcE*IA1DmjD%U8A#Y"'A0kJN#m43U[%GVii%K@)8DEhB`EmYYJr%,9YXkCDLkaV+cP9(rj8@K*Q'&MS`J9rHmC(a*pF$"Rr1E"l'Ra+e19&EHf4$qV,(YacZkD(PSR1)UqeiY6hM"jM%,GbfdBQ!$V("+5F)D+d)(qeJLC%)IcdTm*`&ZRbU,MCMTjHQ+4T[Ebl0J0jPUm,$KlE"pLp*d&$*%RVESiFqGfK'Q!iS2XjliFrek5eChe80b4K2qm&aSD,k`(Ca5#b5,5$(5VjC60Z#GJ@d&kZ@6pcMAf*`8V)L1&"TSh2HpRTK8fBMrjFBp[16US!lh48A1+%%JE,re*C1jlMU!9%`NdR5H+-P#'J`Zm%8%md&pKGUJ0Jp(ZqfHfE&BCKDYTV&"QTCLJrLG!Aa9i#Pq3%SeRk50Jcj9C@#GmlEDRhhdDI*&AjPlBe8dEr26`6@DrUMU[MU@a"+A1KT6'qrf+Q55N!"39G1+,f"#NbKiNiV6Pe"2qF2T@J0k5#ZG",*ML#$P%pBTXJ,!Jj)#MSQb63qShN#i8PUIfQ5YXP2L40[R0lZl1$PD3eDEPi)IQRNN-BUj[+VQGU+8D1E*3LdpQRA6N!#2LFDKZDTC#2Uqle!TpMr`ID(F04aR-AS'0k4NLc8(QcrZLCN&UR@DbFrL-!G-26(0ZMH9-56V6JI0,ha6A2[,PDeQ[hN"LV20prGre)8LB*k-2XR44Sl*f2@3!&)q`'j,-1$ALCN+J6Q[MNb$[XE@a!&iT5j8F%5Z&QHH2Rp)49HrY,@3!%&r1jR#)@km8eBp@f(99VPG+Z6$F2+S0@@c'lEU"NlprRbk)Rrm'4j,kDbkYPZaL$dPYDm%!iZ-%i%%@Hjj9,QXrjPLQ!2!3(2XEEJ"P`YBb!,U[+m2b@+q0A9@MVRR-di'i[VTTU`NfQ3e!0iG&b2A@J1JBPjqY9,,B&(+VPebark"kf(H!NmX4Y&laGRL3[Yp5K85['6[MMU-j4d[ZpR)i!D9F8R[4i)%ZHDJDQbpl"Bm"VN%p5CUSl3Q3PCDrK5*pAm+EA(Gcf5[CIajRbrF#j2J4QSqL%J%H@`AUb"4I3FfCG-'"K8LN!"9UA*HiGKl,HNQ`L"E,!QUqYqi,3k)29%`2faK6DMh3H6HAC!!L9YJKZEM)'1AbH[CPK$djJU69A8E3!MD!mZPPdCUPZj#$[6*blpF*f&bT,H,a[`&3B)*FS('fSRKl3Ifm1fmj[,*N!#6qkpK#8h!eA%Mh0kfq$SqS!pj'P&P44b!J[pM529[jXQ@VUkck[!4&6TJ[FcaTaK1D1"PVR`-0N@4BM2T9*HIp0-QPHc6kD!VRNEhVXeZdUH+@EF'!NH%[&aeG96paXmLL'D@"4FkH,N+hUrX$8Q"AYLJ)B#eBcm9[%C!a$Tfa&bUq-*[V$D*T9%4#MdrR6GK!1Ujqdpf05Ad#(S%5F1I'iem%QhN33D1NHB0HmPK46CX+4)Y3rlGKMfDeE8%U$(`YJG!1rP01MJ+HNT(b(fZ)!8fkjPil"6CdQ4G+m5!m#RLX$-2##cP(#b'SL&bIFhG-E'p*c1FI-qAJ8Aa"5ZRG!+l$CAiX9jHYXCS[8m*J%&dBL1MIkRpLPfCSSKhq2p)B)*PM!%G(l-MZm2DIRiADa,q-RURQ%'[UI8VYQQcXTHJ!pbhF&N51,"63kR&hKhY%AaKI#p)4A&@@1%EMiGAKp8q2d(&h5'XpkQM8,Qb#l,dK0D+M8,(ph3-"R[D8',j@i2PhFAkjLk42XlhJUJZcJBJ4(-PLPdcVM,4jMYUI,QaM2DT3$HSe#VP*L$%&EfI6DdM`'-!X-%ZB&)m(SVlqE`Rerm2U[YmF#'1m,[VV3m4phTdIN(FlYjV8IiVadIJVX-NY#YMYc*4p3V`#Jb",Af,%UYLhC!!J8J',VIKi#8L33k+5jER51C21*(kQq1F&4-c-&hV)RUTQf,'GIl5QXA3VIcNdGV'VR!h+@3Fj6Y4#IU@eY(ljjXK(rF#ZDQdV#NR&m4T#QDQSD@AlATGpA(R6)NRIJMRe9Y%-19F(R61Z)iT,kjm'+IIHMqAY%4Ecmrb6iELHT36#UX#RB+r)A[#q!-5bL9+D*%EJ%beJjR!c3D@c4Ec4cH3!1`@$5+VN`MEJ0b5[SRK9DmH2Na$mk)h2aj1Nr#LpE3&T"#UV&aY&&6)h+kPCi-'%Z6,&rTk1840[*k(GCC3XXQ*TJcm@2`Rq)kLB1IK2Q2BF*(6@EpPMfbM`Uk9)(PQM*UGDU)Me%DZ@e[8(*LK3Ffflc$AL')9HVNclcHT&IGlMj5`Vbkh$B2L#Ie(0%S*JXlMjNKNbk5leR$M*`m0,,*Vm4ZR-b&P"L2lleiBZfEID5PDM$r'cRp3bbGJZfcBB9V&L3Fq[%(jbljIklma10TiK5CE&!lR`A"5C0"%l6d1I`i-MB`RU!C!fX'N$m&paMQ`"4eb&4FqJK(p+5C2T-L,C1!@)C*Qcmm0Ue$Q%Cc`Z%peU@LIkPFPi5P"X([V)QBjNXPmHl(#lcDYlV[RR+0)8p6l&CF6UmmcZ+N'IKi#*"GUjqDNb0+256FX`&(SNpq@#Z*6-b%UUqNRc"![#8G,bkD[ET%pLK-aj5[q4,G!NNLA6bPJ[Y+TQ[T$aCATdU[lb,5+LNaXDH4EYHJUiE$JGdZ4fjmYr"8BlL6U(Jj1$,24MFS#,9@CZ-cGG!-j+LE-Xd*rJ-rN#Cajd$)j3iJUhVLKkmfG01Qi0XJc8R#9h[*)mU-bJ&q)hY21E0Z(Lj,G-I0GV`!Kq58Rb(4)rDMbLZE$f5l4+5BCfq52X4Fb*8aiQG9SlAr(6ZfPF106M2I'(RL-5M9efb@dkq1TR,Vbkp8-2+clC'd8S(&M@88PD#UfN!"MEh2-h"`6'#'b4bYQpGMiJ9d2NcKj$%c&R!AKp2*&Ah4%XVH%530IiIPe(5kF0e9U`&Z#PQramhqA'fK6[![YkU53!0Zq20@*K192S4!!Ul,,"U*"S@3S4@CDQL5*DBd,TNdKrkYbR#YEYG&)H-"@[p`KJ@%3Bpbj9'*@3(GI,Qhl,@m4&5lTK&iATJrYTT[m)$'C(i,$9e8bfU+`H1,B8Fm5GU,P+@K5cEUa4+BIfjPAURrYj+Li)@'He8djHi#JAML3!13"5IFAYipJ3Vlm!BQ8+kJmi!FCP8bcac!&C9`I9jje9QqYdBlESSd(*,DPfP0[hVeaF6+8f,%L'Ti!C[3iD-j%'MY"XNA(%eEcE,@"Tr2aHe*fSNX)AiRr*i8GUhf(BNETT[M'9M&6QLQNbXUNVipi)*(5kRfG(lG)*2f0["f3!+Gc[3*V4`jP2F4eAQZ6i`ET"(Y6HqIhrXhZ6Z-`m,H"@rp+qKj-m'8M"9!"Z92fB*82[SilpJh8'[A5H)E'V`,&V&%2FM4U%h3aMhKl``RGXkY4$%K%NPT"pBdmQ)-k9i!e$6kX&1L0liRr"KC-eqBmK`rFR0a+AdK0FmE-'Dp!B#baLqE#pXi,[KP!1NH[D1Bl+D'(hXcD'$ma&Q`IlI%(%'DmLb2S0(i64haim[6Gh"p""[4rN4B8RVXG'(ASD$hXL5jPLjTeS+0+0c-V3MCD(`D*VXb%r-ADl!q65Pm`DG@d`e)@+m9Qk1ZY6F"RZ0rNZJddU!qG"fJKTmU[9(0aDVMB#rQCGjj*%"@NeaKhdEiF"$'AKIEj"X4EKj21$[$QlHD-Mi8lLp@,i[QM6,chUrP4He4V-fH`NLQXh)2([Fe*2Ge93B#SXJp9`IB,UhH'!PMcFBX6cDfEH"FL'kN)TrEM$,e0SNjb235-8qlPkIfVGAd$E4[1$p[Ep%H'4dZ$qGhp*R9bc3NSXqZbQA2GP`mar2GNEZ!Tl,5p3c!,J%0@TI"Ikq*e8XkZBS[f`lcP!4(0I+NSE1*dZV30KbQJMb`PBClmqr*NdFHk@N3J"j'%aKHaY-QHG[$6ENVT*fkmYiZ#Mf(b$3iri6"RILKHEj!!'DbLK9Zmq5Jk%`'cQ85NEmU4TF5)ii,Bcd1I"L,8k8H!KXH3!!LYER)`iRB'Xj8FH00T"!b!rXJP!"#TUlqeDUMNp*TRaa`r8%aSe34qNeN[8Haji!Z04ZPpfDU@aY'-PM@H9lRbhXjK)2c-)4pNKc22pf[(Q1Y4dP,,[Q32%fX&39NdDY,LVRFbAV"'J*jmU"Uk"8JlcU1kkrMUXrkjr2NikLL!V$hJc"dMh*`k-bFVT,N1l9Dk[1!PNDGS68GiU2AeURTjVE1EliK1qA6S['-iI0ZFLCI-VL[9KhmRE@D$qDa%+%r"V&2@ICA6iSHi4KY8iY3+1T5"Tq1Fa-JXXjIF,)I%"IjH$'X(%lT(&ZQ@[5'Ff2HY-jiZe1FeG*pAXJ[-MXFPJ9*MQ5BcDj@#PJjj#%T4`kkH%E-lJa,5h"Q!N!#Ff2"K6X4%43%+1*9iQ2I1G5k@CCj5QQdc8dbm+&-5bSS%dRYa5Q'1m6pTrc#X&#DeRLU5+H#rJrKFfT45r3@)iNKKdA"Yq+*0lr5N8epI`Hhj0(KQdCmTFSaTlm)qM%%3RG,q2DQMaj''mk*69&mjS(9ZiN6)9ehM,cjSSH1e1$U&V-MGfEi9qd&kC0Ue33[R)8'XT1cR)SAJmlqZSQT[p9R6JpN5+LfG2bSdqUlr00MV(M22B4Gr(536EchB1(["V4djGZQb6D-4XreA$h2CZ-q`i%TFr)lQJ%I4k-"9'dHN")LikN`[[rcXH30AV`)$3TSR8bQ8YB9pFUM2#rh+XdILkCK+,U"QCA8c)@3Q4$4iphckJe0GFd[hYq),l8KY1I*(Q*baIdMb5ed(PYd%H8ZTA9FJDVkE`80C'k'lr'2)8XJp)N#+L63G&e"G@r3%%(rIHCLGAI+3!)2-Q["b3hYT9UJCPaUXIJBGaYbZ6I+,cL#P4[Pmk,60++8Z)N$`Q[qme46P+)QU5$k&6I`DPq,2'#Z02kB#LT+U)I,cqC)EbMrF23qAPB0(Tf`QLa+)@(-TpY&$U4`GRM'hdQI@HPe-j8VZ8piB'&9Z5Yf0hS9EDX9Fh$5*P%)TkqSQ0FNBBpQ&,(&41(4IRI9A8iJq5hK+0Gk-0'LpE)SS%FYhL%*5#[B'jbaAh(R,GQbYJ%b1KjJTbc"'j'K%Q",im,MG*3!8I2pGil$IlPEkjR4&%DR"qIf,Z%b2(*S1%ep%ACj0Hb*b%4P13(NrDaN%fh!&T#VCL`Q20,d8#8cb"j)pY$Kff)X2`"6&rH9[CpY4k+5B`Vq1qaAFkM@k58R$BQqJF$5eFVY[ZaTM+`[(l`(b"*+,lY%CV&LD-a8EdK0!)JF@pPIS@[9PrIdI5,Mq48ANQYbRm(r4[%AZjcbk,A6%+A-GP3"a8k-6'"r9jmFh,+Z9eP+1lZX#ST0X4Ai8B6m3TrCG"qSk$&XahJr[&qj*MATLpEbp4Q5C8&)jD-ZNX+Vrmc3`6YIcMB2D2U*kbf,H'Q'p++&(IAG`J[!04f5lEQN8Z'U9,"fE%mJr([ZeRfICH#,(3%-'A`r#HE"[ch-*%(Y2l2eSIYXQ3LamJ)[K5Ld3H4GC-C)q)[&G5bfi'f5c%XcD%k$N)cF39"B,E$ha%*,@'Akhfj,4d4P'a`RBSULe@8+94pe3'da*P!8L95PH!imkGG#@Xl[2U&62aJ2Pfq[+,fYEdqU2(EZ1!3`'*HmU@(@%[ZDf#KddEE+Rc`JSj2k-EmTZ+A3D4aHHU[L#'h8*E5GrVYaJA%@TR,6'MUB@&0&*I1fklG$FZ64DJd9V0#`!rD@I3A+VMVe)%L6EXSZ-5Nem5V'V&02brjl-SKCAK@JH-%0N2Q4!Gm6#m8"be@Ibi1hDaCr,N9Gf(T!!ddcHqc@'+5XKdH!mQmG#qY9cp3Lp0l9LQR3A*QY0fjNS8DQ5K'5"2br0eUK93`ARDeEfFbl!V2&(CC50[-'PXi*Kc%L'NDc(0HB)%,pf0G*1qNb#3&bDY%-r-HKJAr[DYhKkI%KHL&JTdrjm5!djHGE39ChikHqNUpjK8+"fGGRr"C5Q!TJKLbdL33*IVq3k-#MY54(5Zhl`bF$ki9kaDcP4dHA-XahKCrQ-m)VNV`!$@@l*GX9Y(N8iUi1Yq3b&eNB6P@c%-,%h)6iV([p3"9N`iDF)-CLHFcdJr!"X*NcC3$X$RjQYSXP-EDKm`biEUAEGDc2[fKd%C`SK@QiUb62iCZHqDIJe85!hEqMF+(EAqKBd+[*34kV&FCF9-`H&#d0aNYK1'0Ic`L3K%lAIFJSae#i#FC)p5UD"Rl4c8RG"[94PcJlPNr+FlB8lU!1)$Kjk`0ASeDUQV#`Z%faK[6GFhMY-2kLa31d68"295YI+(3eFm+kla4f4PR+G"NGARfE+DZ8)%VG"6pkl%D-U93Y(fp9lHrdkU5qbX,)hGVAp8mFa%`Nl6&mZ&"GCQjU'Fpe3R%(p8FK)`*!![V2m'@MhB`62!4@Ef3VT)LBU(k(3bTR&kdr0GD3#"N@d8'*!CpLeX%#,h("DJB[Fl*Xfm'1QGR@LDVS,&lqTHVm@L)"hbljKdbc"q@dHIB4TE&Va41YIfS'IlN5h,fh9!VX4Qj!!Pj@Kb@XJrDeaUqrI$`m[iR,X!MB,`GY,*fE5%&,1lXE3XCiVBYk9CHf0Y(K--(!+jpNS+i-!Sj!!QE-fV"[QCZ!4N9hZHp@9lF5kM9Fi(#0Mkk4V-HaUGNeKC@E(%fB+,#qN'A-@CD5$4!Kk'KE9AHliJ4`Q,0mZa*pAUJCCk2rK6PRFkI+5`9V@!%J#r'%CFCYf!BK2JRK'(qJ*`RMXB95JMh(KdPbRBSr28Ch[6bX&E$%p9cNMCbP)GqVC'4lIpQ&j*MfA'mhl56Fk@A8T3LiXRr4Uf4GVRZ,''fAThCU)1P`6(V3A@d8%40Z8PX1%"LI9P!D#(&CG`a',ZC',M'6BchY@@1*2mIQKL`l"[MX`&!k"E9$5B+mDHSDrm*qSRCSEY-AQ-d'Y,+FfhpVjLG-`kL3BD(J55C*5QHZd8D"AL8B-3mN1"(!&P($LA2IX+%dRp3lX[A)#!"@+C$%Y5Z@,HJk[YDpqTpEmElBD[$K$9k'Zq`UJ,25h5'QTDq`KHNbfDk53!0&%8[31AV36,rUV#Q25ipBc*IN`U`NmkiiL3'EDm'X4A%#-`T4K$Kji[l&i$+TNq4(ZfVA!'16,8A#"F%MYj2RkTEUpD1kMf[I,99-Jb3pN'KXGfYY4K4IIe&'LcFD4Y)C#3"5(L8+4bXDKirhSiFE*K&R&L'`bLcKYJbqkIF&ISBRX,mBHL5`*F&31RhCU%%SV9#KY64ip9T+$iCQFkUKeVCm"J56q+CV%1cE(NYNj+$r!fY14eAR4U4URI81Dr1ZCDrh+4$3p#@'UJq2GV'0&"T!!iH6b6M8HPSX0$`(Ua`34+[h,Sm*1p00Y3j0)#PaAqEMKhiTpZeIp,%Xe4D'0li(&eGV!LpJ4F'Gh,,X@!6$#'APrF)flE&IU#$(1[(r939`mGYU$XprJ6%1QBr"Jf9pKTeQVJ%Cb@JQ54Rd&`bRSLqQ-fHVe-PP`*C!!&N`ea"fF4XrBm@b#b2IdA+`"D,l"J$-"%Y%3R3%[$jP&H!5EL8`8I&UD!r*bmkT5FE!HJ4q-8V2PiTfjQ-C1C+9!ibmM1K*pC[hch4IiK"G!QE1-81GAb)(&"3d2M+lTblDLI&d`%l'+!K4c$XQ)JehEpmh8Z#b&6a5ApQ3AAFBj,'(1E2@$I#+V-&EEq2*AF'b%ZBq-1r6!QFpRU`*HLQ20kDUAd@iQjQ3d[rBUhUDZiPI'YVL@pp6MU(cbcCmD%0(2RjFI*!X&4JRkd)&H!d)T8jYE-&H3!,mm$e93Zj@HkCHK,)"RHAVP-8cTj5N(920BFNS,l!r5FBHPY8[6CYT,l04ap!PAjAP#ArU$fDbS3SG+YBkNe)&&MeBBj*aj)D6*'G'`"ie-d"R*$MU6D,D"CA[1L#Qp0Y)aNET)HfJl1DrJj-k%SZ'8jIYYm9*T#R,e+V)m)b"qp*-0lCV[+D6fG6KmDKiGAk4%m0YPS$2U92LYlK[G'4ZfCQ2r@4l2#M2a66JJUAjS+K66#8G3Z1r(H4(h`GMEK(mEFKLf4CrL9[i&kFiN1fkBF&im)lT4R+Sqh*ZmTSKFSjXFG0"6Zb%FYl'X(VU@Dh9aR85V6GR+DGI%c2p@QR8RdKNr-Ma2p8ZbMl,M,)#eZ*a,0BZkJ"BbNhEA6YF9XrAKecbec$K3J2BkIl3iQhidMhQjlqi)TTqJleIeRe,RpL#-6I[b-)iNQBZMqeY6*d'aqlhV,Q@,32j4@YF$3,3K9m6@91B0XTUJR!BAkBrBdafZjr'"rCcPK'&dSS-RjU*8M$'XrYlV!)fpES`2!VFqjNjp81YNc*,f5bm)DD@mPKrZ)H*3iPYD4mh4b1-#l6X`Nb`0Y,(BSmpAmA%1qqhV--dflJdaiiiqFl2flGIH!KC%DdD,a%$a"2j9Z+e2M'@6`JNIE#pd0m%#Rr-iaYl%)a$U30J[kbYlTqZ*[&d$lG!b%M4$p1YJrbcTNB"E@P5U*kN1l@-Zl-0UhQ&@%cd0X'[YH5V#%XD)U3jFNfR9Y!@')ilMQ@X,d@rKZVfKf9KLbpl&1T&EE-r6cReIiK-50qm'#DjP1b5Bc'mk8BE2fc2DIk9`l[,BT"'AiIlqU2&a#eMiV,9b[L88Rb*lIbffDTj+*ri#a,-[qK`9%ZC&f''[#pGE$a3*jT`h*Hmq`eP%J!D-5l'FUUJ$jSXaF',ASqhV!84TiSClLc&AKZVc82MJ*FBAHq)kKIQj8R4YV@M%1-PJ8h2S)*EcEk-[f!l%qP1(23N69jrh)qjj#K58Q+c86`V",m@YU'iC*Q!hJV4Gq`YNFFjcf4JkF3EZYEACi1Q[&VPaBVF''fZb(SMi5QVjlPVXN!#bcSa`'99IL,6ld5Z0chk`UEp9la0Sb$NVDa3p#9(Dm8QHA$D'&(TL(`mD*CFb[PNePc1Ii8B0C(@+6)Z4b+F`0ZMHdCek'!@@jL92-V`(IVX@$fS&i8)cNE2G'H&G`0mBK&J$&R3YVBqUeaE(NS2iYiV,MJHIcL$eUTDVdrj9Gk9K$&ffI1ik#ZalRkBTfS0#[l9QYP,X@kdDQ0YqJR-I9MNa8fXrP*3ZjFHe#[U9EJ!8D!!`%b+jl`-Q+8)jq`X44UP0SQD6fHABRA@Md`LPX5LQ"Hh`XN!EXM(q'R6mm3J%RI6m%`#UTl9(cRG($$1%*GB3FE,&1cTCPq!N5G*+kqkJ!`KM4kf-a$J9"#6BMjbJ8aZi"FBN"X&,!!)imi!jP@2P9icpf19Q"qc2rPFiL,L!'1qelP$+`YYVpI1CiGlCjSqB+M630(p,9CGU[NS&3$Y8d9"NVbG'qLlil8#SdE8X#5FZNRA30)YU*#hiAk*"ae&Rl0M%Q9C*HF1f9HN)ZdBpLE3!F-`,R9m6IK@@$5PB`$Y5VIq10")[i4%5YJr0QL#H#Y5$Aa,@km*B2dAf88Ue5c+al49eMI(Ab-F$,YS@aha)D5hSDh&8QQ$`"8-0MAqLd"F[rX-*"2i5E*r'Ea3&%D"1(q'M#42S[Cf1bINXah@f[hR4pEe32Q(38%NVJ!ZBRHSQ'N'mEp)"@USBY2BN04*b$&QFVa3H9RAjdpbdMmhUFDZ-Am#0elbKHaSk#CNVSG+Q3mflfV4a1,eq(V)S"R5R#2@ZppUSDH%2K0qTQ+N-TM-32Q@'Nf$lB$eX#9cSX'P`5G'[DQ0Yp(kk8(&C5RQ%a85',0(!F2adCblp$'D2'68&kFLX`Ra2qLdBFf%)iIr#lXMTS3LK@j[HB4k"5Q[1Pbr!rR@"JPm#9AB2BN1aCKRURUMkV@&1j!LP@R(AC*mGjl-)#hdGD%N6J@*LcZr')aC(Tq1'124XAUHMTRAMm6@*%N,!5TEEDG5rMR8ZlU@Z,#NRU6(1lERY1`0529f'hC0B3FJ%hbD-ZfIjA4ZijiR,a`kNpbmi)8rFcrY(p$TI-a6dEq2FJ!+DfSC#Ue*YZjpSKqCBAL$LQ-rVCEXN*q3Yf&FFNj!!%1`[U6B@#VXLlR,Ej%iMejP@0AI[`N(#Fci)ZrK`XicUpf&hjA#*YJ5d")%[2*c$I+Q(j4Jm#qL4J%QBcf9C*@MkIrRHMbPP+IQmC*aR)XdX6LD1L'%*HIm!U[F2Ip"C#)')bi6%T!L1,F"$JQ2+!J@@(UYj$G,,6TpSqaN'V4%Dd[PX$S6Z+22kb6r52!"+kk`8'AT@lSJr25+m9*KF9MBVm,0!m+10X$mRf#RI'b0Ap)*8D&(!VmBc+'-@HH12UGU)SL!MR$l#+`B4#LHr+19[k5$RAiY!mLb*6[N#`UP90h'TaE9#r*9Q@HAL*8RT%j&l"4jVEV31-UG!r'm[eeQH8dA2-Phe$KK1[Z!aQNRT#Z0jf!,'qCED!P,4XlDeh`p!H+M0bC`"G#Vab4GVap-&IFRF6TPrS$PRX``-RaYpaF!,bE#KCTqb@r&b+Ai9QS24RjLaRP4Q!S[,3RF)!VX61)[5*J!N[l8eHM$X#FCYbZJ1cJ30D9(U*qT8(r%0R9)5C$,@L[Hq1DL5*l6YfIN6kF6@2IlX"B1)'iU&1@Tc'$($&Zb0RL3)64KfBf)KhT@3!,BXQe*rpb1J'A[+"+8mdfBdbZY"NC8lM[-Tcj`jkFSf"Nrbp(-%JaibpZqX"*'AQB[0eZ)h*RUpXRJVHeQp#"fiYflKV2TB@PGr5Gh'XQbpT@0qUU$Ba[JARE9ib@X@`A16Y$IFp9Y4pd$)deH1Q-fP@-%k)&@)LC0S3,QrMRAGMh&ICELH`8S[-Ke(&`PXQ2mVCN*J5mkK)6&fXJjbRDhTNbqQiZR9,AK%$ZbLTGG9%ibG4IE5m2lmb6feUqaQ2h!iN!"e'crJVZ"hhL&fVpP8fJ!N0&aHQJm6GUrF9Z,erD,IF"(#9UF[(T*#KVFDb9lN3M"qXK2`62$lGMEJ[mMmqQF[Y-+!m[+8X2N#N!"A@a4ErCT$C52%PE#*DK#&)+"RGX`rS3bMjA@Kd8i5#bFMXQ*+G!L3!1aAXH"`rSl!eUJCMa*SD+,AHS0!L(U'Z&&!)mkZd%pM!5"e`'BD%j4(&L0UHbSV6G-HTh$LN!$ek2)eBq+XDN,TD1GejG+NEXbB2pRl36@PKX,e"-FJhQdeM&MFfP"E01QdR&b&4(J[4#R104A[jMj1,Flc))"-1H2&2CSHlMp&CZ'R52NQcmSEdM2f3kY*qNT,aEb0q'#G2(rK!6BG9qEA'`+q@eb3!#C+HFpmeYPEafC"XD&hcS9DP4#SQeU3!"JmQ%Ac,J9,'fHk%(9biJPi)d*#H6Rdhj'pb9Eb8CSDfE-rBGIP2DXYpb-&AAUYlPrd$@Mkbd5EfHS'k)pTc*5LmhCI6-a+"Yh$0L*d4ch$P1FCX49PbTQH#I`ImmE%kaRd*j1EPjDR+T-EeB4bD&[iB*PVXjZNaTHc[Vp8a$P1mF#Eq@XJeMFM14&U+`F@2UhmF"kV8[A86l%kDk6PlNP&f,)adL2(9f9Ih3PfprBE(6JaRXq1&08YrRa0%TiYl0hhQ!pKQ`iV1m3N"'[LZ(9m#DRREipX&#+Mm8&S5dD!BdZ3!!4lAPS%b+V8ViZ##FjNTMhfF!fbkdBE`2(VEPER'ml,#kTM&Jq@L,'#GJj#bB1UXAL"bKdH&CqV-Z,#4G$-1,kHA3JA["UmkU0!Rqq%,!@*jJk@8$[Srq*Blq&[jeHaD$lj$fU5l-d5&XQPGXi)Ralb$AC`jCFYJX0F'`mmaI@ZF*-GjT4VETpM4h&YPZVfSH$KdfP&$Ze3qCbcZjml[[e500d6R$1H66SqRD#[5UAj9'XIYaFe&PCRi$B5N[`9MXB!CI($`4cCd'Kk6*6)bCJ-3kIVpUqJD0P6*)MB[XrFidIN8!(*+[lIT%)iT(d,UaE'6iEaq@UZqV0e'H+KTC5IINS[iTV[UXi$#Ip5d30X%1r&bXrK9S1N"2Ef0c51EQKRU8I!S5TThK'DUb9*VkTPh"D@$ITe)kBU6kbd-f@3!+U,![Cri[Dcae(ic4eM`9RCrcV@P@XGh&9l'Q6Ad%bPI-MGGRd!6Dpfd)Q3!0#i!p[kqVD`&CaMD-qmVTfU0@9NMB`D,@"ihJ!GH1efhDV-&"`Jejq-888%ja(iNEb-m4*jG1Pf6JDT$iC4,Dmh[!36*3#erNU3!"5%k0E9b,h0M55DaE(LTSrrXbd9SlipHj-3+Y-YD3G44(eFVJBZXU2fD"'c(!3k"4h+G%X@P#5c"&e4e0X[1r'0fbGNe*5@0FBPrQa+E)2@m[5QeC[FK(@kSNX8IU3m0V1T,de+lV!KH$5"j6prCJ9SQdhcU0Y#)(MHL[aNJa0U**,-0MD[mjm['XB[J2jP0a%%TK0!&haVi)0CB(@j*NF#h4NGPF3(%S41-M+1bjUdV85Yk2q3!%JEcMLi$B3,YhqIC"S2bNb+V2HA9!E)QQTLHDV@4L1"Ec)pD6G"c0c'jBjXc-fa)C-UHL!YM[(m#ahjZB1+5pe+U5GlPCd3i4Q4he-JGlm1PN4-BQLh1S2Ii1YUpb`HG"d!l1q96iZ812GE&"CJq0bkD[rdmX5ZEX[4VLqj%lp9XJe8S)`[j!r,0+dXP+6Nk+4&h)34H,@&,bXeD"22Y#X-3aqQ"qdr[Z8L*l`D[3-5e%DKjVmFqH+1c4R%PVCMd2fGp&%M#k!kfljhU3YJPNA1JHir8)M%Z,,I"SZLN!!5hQ2S*,4a,K&"-,a#j+0Y5#YH%4UAa',9M$Q,mUf[`8bHhHrX!"XJe4B6Bi-D#,AD$cdD6"D-T4JK6[!ZVkPf"jMN'%l%JiN1!6b0M6-%S1l(eAhr6HrK*QQMdM*UFdMl(kDH(hBbSF[P5bD!TbIcmqjYjdB"A6BFP+,[ek@)Pd,K@N1rEPUie`D)0`hIXe60INmG$#lUp-)10IR+IJbVfq9&T$G$$N"Gf@R$BDG-!BG"@PG1fD9ULJaN%#iPF$UT[9#*`Yq8D,qGCG1"i(8ME"d+,LDTk)%'kHem5aqlRap)H2`##24$dRJPX)D*NI-G1dbTP4fN5N,P18%V)2qp)A8fk+30"Sa(Mk)i1eJjeT'UhX2CYrmrZ&#khl$`"*9B#fp-2`KXc2H$i-1'U5JLaa(!(#f1UV[$&C!!@Rr%mVV2,IcP1qrMPAE#+4Z!XmSVbC&YUp44RGKD1[3M+[GPphX#iAj!-U(a942q&%jN#0`SkY,E[rX13+ZQJ+fMVY!AcX[q`dFB!ErEQ[d5@Qf$kIIbdLd*HS&,r1b9hk"6HUI&(f$H81"M$+meUS*Mq4aa1!-HThrb*00+q"T@Gb22RDC9peZH+m1LlSfqlbh4Qd+[e)@hpTaPLTmYi0R)LRe$r2L$EIciZhJc1(2LPi&epNhRj3fEHI%3+l0H+UUPYT8'cdk0Em9qKc9bL%,pId@E@+@UiDr!6I$F3qc+@-%0qcDLVcb6VqLh98*N52eR%TJF5J(4Qid`8[B-Km-hJ31BRI$8T*Yhp'k#'$`2IKa8a)2TSMJ!QMGK&V,#0RY[Z8J0hek'lH5Y(h$[4`K6511lHM'!%$Kp[chir!c0D%`l'TV0c$8l"ZH-'M5d2Y-@@RRma+JLU8EPA#i#N4AG%Q5eFdS1H4NU#&QrLL4pCC,JQYD5hfl3#"l`p-8mTdcNVlZ-98e$PBbP!PCrF12k4rjSH#%dF13rm(+Z1BDarN5rrpSXeAV5XNKTC+X+UBKVBH,*p8#00"QV5N,F1*P$'RQEhKp%6m[I)+PUC(Nc['2LGpS!B)8CkH!5#9B11-p(2cXV$ZPF$'4G9Hq)%dp31`id%V5-d*!!pSKD$923"l@N3h1ZJb(DkEepb!FZCa0EU-bX$'bdqV#ma'bM0[YAlCdI``3$Pi"SSpa8,@Q,'l3NH"@,R9%-9,AjT"qi@1lQElk4J%5ph3P5CP"!mVPfAYh1I62HP%CFb$!ZHTL#&ZNG)R,1j+&Y&r!1$8@+1+lXI$1UNV1(3Y5T)1l8iql@19#pLC)QT@qNjF*Abh68mQ5!c!iGCS(6@+1B'Pf"DD([mDFMa0)a('rE)`0m2Sk1GQ19e-AT"jIEjDcEqdKcj8$U6ZF*&Tdk'dMX(Cq4-2,L4$irf`VmFSN+-4R'$%mLidh@'f084%fZ@i283`L3!!"@V-hmBMGG(Zdh"'mPZ&IX3JLQ((4V@,a)ebmj[HFIrA5FI0#S@!$d*V+IJNP[hEH'HMK$,qh5(p-DESkk*Me+TVUSQKHCl!2A4i#c%RTaTN#jMN+e-QE,$6+Ykmm6I+3$TRaI*(f(I,Uh(q3K4P4+Bl`hJH!&Q@LGP0!,B8+p&bKXapB'[cAd*+p5Ub02TPTGPKm@C[bIb)q8R&`JqFP'BmGrr!FqUK"43QB-*(qfN3)q!UL0j*1-FbjPm86akJem[B$m*j2"-%hJaSYlZT(PY5HUZ3%Q34++-'J'Z-elll)E5e9pYT9UZ64E`0mLUYIc0k'QVQ*V0&+#p'`a!-FA66T24@`V!!(442Y6F$m+R+B6Mm@V-52&SH22UBD91Y(1DeHeaMk`YA(K`NeiAU'dJD8@GRR[*DS2mPJI1"GpKfYbk&FE4[T,RphI'0E-ie1E&A-IKMPGCNUmDDfUJrC1,NhZm3'(@M[+@LFkPfl*Z*,%0X6aGKZUA,YVe%LIr$XY6HJ'"-)KZTR"fZZd@fURep[Zr*c@i[lkFcrK3b"8jlMEf-pSpd9STSU`6UjA4E[`9d!$hI(V-X'%kNX1'N(&I3E%E+)GcBqEJ@KY-&J&C%hU3qPe!lhjE"H'-rYp)X(D-"bJaS$2`'A6jY)5'dYB)%+)QA#B9J"mfKF2E1[fkS!2K9H4rkql6$XCrVBT&UhQaPHGmFJEZ(m6P3ccD"c`X'9f3,km0$&@M6m"+T2-#(#lIQ$0jU@TKHYZ#9J6ki'l@Hm%KaaP2kBq@STP8ZYR854Zd*jm54Ne04XS4q8FRIB*%QH9)%B@+6cC,bUjiYk1qJrM)J%E!A%E$9pQ"dFp2i8cm4"9&eeBiGfTpQ$H#F0'['24Lri*[bq,N!"T9)FQ*"3SN!"BkSklZh4bK#`ii-XD-+M`a-!9%-3,%Zp8rIi`*Jj2,"eH8"328kXEq`TG6J,VS'5DP1*MS95E0U["[9k*QdiZJf-e'+JYN9XlcE(e88[3!%&R4C0LAqA63JZG5TG@kq4,mpi!qCf9YHVrN!"SI5&@fh*#4!p$KmiQIalYC)QX&&KHq*TB[+a-XhKc0DXL5dmPAXiBqja*DeP*i2LfaiXM2,Y(@LT[l1bdh1XqaL'q8FMJA3J4aNdbYiYSjU$RTl$ZdT3UUk5)@"m[SB)(r!Y$Tr3E3H&#`AT-`DVqcBJ1L9&G9SJIYY+'AQC*b!X@k)Qhii2[de*b[i[kErI4eUmM8$(FieBAb'UlZ2b#DB2,JAil'dkKA+9C0acrN3Z`[I'Vr6D3!,!Z&4pk+UQH(dMBN!$ILVCe2VSSUi`Ejm[rC)H3!&)H,h[e&*ic)DM0Kp934G-1Y9G#UU4a+,L2b6Lk2i3rbahB@$D)h8HI*i`X10BSYBpmXq3*kkU"pL@dNb90NjfrjRFUeA0Dr*@VV9SF,VL9N!#BMBk5e!)Z2r5I&GGpD!C5'%1M+afSGH'M96Telq8H@b(FcL@634c+9LZVH6&B38F'GelfE$30V0J65[ZN)!pU6cj(8YP*&ifC3)q+iR2'AcI,b(,(r#lI"SPB#21U0Ur696e2$,#5-H(8U0`%VQT[H[kh[`P)E,UX,Ej-r@f*KSTF#-3XMfdDT3bLVj8l3C99%'%JBlBAC8a!IPMc+Q$PK0P&k*X6fIqI9cJKFDMB8R,DkMN$IQi-SU2a"($R8kSf31&5k`T5Zl&NH+Je0YUCj5*V4kNTKKAiD@m"VV$A3r(hm1eq8J6Gl0f5HUZlEH3KH#kep$eSMr9T6UEa6XFHk4VhHjQq8dq(P[mUI!5a&F!Z%$L0IGFTbiCmJFjTMK(qHF+0MAfZSHZ!bKh+XbH[e,2dMdAKFDCFdUU!2qrC9fDj#U8%dhpM&F*$kATBB1"ZVcLKkl@9MFLe'ddTeJ[qSfBp#%#hTeqbb#%0bEG6)(&4iNU(b&Chj6,US@Q$D[QCTD+G!*!!iP+jR6lJ9$a#9a,YEFLq9j&EIpp[0DmS`MXe219ZCQ#[e,qQBq@8jN4)+)$F@T!!1+-!P9dV5SA*NpF++T1jB*9bG&FZqj@pU0%VFh')Kbr36`"CYj'S6(VHbjXFQK%-!"jcRF'+kC%GaG`&ETm%f9FC$fA$LjiAZJdZ2Qm@h8#"a+MRdM&"0QrCP$cj!$5RlBU'Rc0$l8EZ9JZ,5lYIj2TYC)6ERXa[Mal!dq6LDPaRB"eBVHFjiTq(0S#%#D*)qfq&FJf4,iQM@2FA*Y)B&B8lLlRaPhQlKeUFF*DN#4$5'IULf6201@8[b+@ACE,!e$&,@N"VfjVE'(GT**GHRkIC'@R91T9G)PM-aX@['(2aAA-q'`ealJCTKXN9+01YK4i#H)rMG1!Ql2Kbi$2&Ed+EZd)hp3Drar@Ri'NMfaqNV)qIMbp8[jSe9"PYcUZEC'[QmN3$RhT9%INbQrR2b&K5'V1XVcbVVF&CfUeYbZjXfce0[dPhH%4HCKLJL*8I`SJP@m&#C1TEjIdYPTKm0ITKaX6HcjcQq$BYN9eASrk)Mp')h'JA,HG$+3HhaK8%H1LRqQFKD%`L4YN#r`!Lm@IRdTT[pKJ1Sm(DMMN*"'qKh'Rf4qmX-"PCFahqmDhJU[HH6j*aFk54-,@-#&"ll8b*`P(bE&95&1ld@(hc3T1@CF[I"RK8L4cm&QcMME28$Pf'Ze5%0&-#C1J0eXhq[CpBE@ER$X`%"2'aA[Pr0eJKNTXRZpc`YH&hDcDHF'iQE"Yd2D$Ch"ZNNYQS9()X`P04m,69JbK#XflDEQITM&l2+PICp(DprlQ1(3&M%M)CL6B2[!D0mjrq"r&JG#JSJ!h#RGD&E+p9Gldc%LaSl#p5[6UE(5E+F("faB0LqmCjep%Ea3VlUjrhdr&3-NK[4&6XAMBCa3pDhQVC'*fpXUjNFE00pNhf%@#DU,&B[K$Rk[!emdhh8[Aah0"[X1PReP1DHiQ!jXYJ)r4+JlhpN[Sjkc6!9SM5*a"'NqFqk%Ed-m)&Q4DSqa4UaYMf[FB`#06511@9rKY-Yf@jr+FaJVTimKN!S1rEf+b[,J@9!I38qPG[raQmp-`eMj`F6%[(hSY3hE-PBEMjb*`'5A@Be%5CPjJ5Ii(r)-YNpMh6I'3X2!',U#KAk`PY!KbV*b&$FDcdNAEqel%RV"Nm*28emNq`6&(SHR+626hk[3`p4!IML(%qNLplF0G!e3H&bdl+XR()"DZAZMLG4$&0KqQa4fKSb9,HMmrX2ePl53V-[KTDSI(!jB30NDB%lD2+Vj+r-k9GbM!C3@EkpcN'hZ+Xh'r*XF6ANkmbPpl!6VBSQXcrCMK'l$Lp)%@ALX`6bXp6k,0*#mG81@kd1-E#al4`b@I4MME$ENjbSMqPYT&dS'cQ,pj&@32P"Q9T-Zhc9%XH@Vk-4[KqEeZDG(HGQEU3!0faV55je$aPNbCmTlZVA'ab!fKBX`arDCl*4RDb!i!cj`!!:
\ Kein Zeilenumbruch am Dateiende.
+(This file must be converted with BinHex 4.0)
+:#h9R,R"bEfSZFfPd!&0*9$96593K!*!%H(m!N!4fYP0dG@CQ5A3J+'-T-6Nj0bd
+a16Ni)%&XB@4ND@iJ8hPcG'9YFb`J5@jM,L`JD(4dF$S[,hH3!bjKE'&NC'PZFhP
+c,Q0[E5p6G(9QCNPd,`d+'J!&%!!!H(m!N!0b!!%!N!0bc,m0TD95CA0PFRCPC+@
+P!+@3"!%!!$F!!,*"C4ZicjGf!*!0"kb,!!IC8!!!Gl)!N!32!(9R,R"bEfS!!,C
+(68e3FN0A588!N!1L!!%!N!U!!*!(3X(9GB!K$Lj!V@DRS@D#!0Ni6qBLB"#'qA6
+j#HQ0G,F5'rJi0DN34kM)JT-1K&@U'!6(LA4R1C!!pV+DqIMlCRR(8C&bA&p19F0
+MLfm6rK2Q`G-J52`E9P[+KP$lU8qp`IcjE@#VqlikXRCBA@&DZbdX*a+QRf5P&De
+k*D,bc$IYA4C-M552J`1%VcZ4b"8+KGmjf(9YJA63YBriT#*E@BiVZVKRKbP5RK`
+Mq5PkM'[k9fd,AEVEh@BI1XLLT99["Ii2f4cl2fJ#L'e+B0)YRkcU%,jR6-'K$,`
+-QpqK@dI(2eJNGS[l#f4rVTCeLhYBYY5+pHe`&e#EpLPpKVDefFrq"[b+A`ij18S
+M(1DL09"mk%HmNbE-RC'3!!l+$YiF9`%fi$fm64XaR%S[P3bV0Lj*(V4hj5)hmkS
+TkB8@mkE8(8-1eM'84(bTSH2qjLp*6pacB4lGCp9afr-6b)4KQ2F05'e%"F`q+Ba
+c2CKY!&(HAd@ArB+VZeP'qdlm4`*fp228UiN9im+bVZL*SF1p+XCH!f-![[0*24Q
+PU85S8dS6lkYIKGP5bCJpmJG)GPjf(%X(GE(BJYD9T!#*a'pkGjb@FZS4p#ND,X6
+8D3`D[cq`2$,+NfrJ"FLkNmVX1&+iCB!!DI[HJhr&DDR+J0Y-mDDpJ+m)QF9TP1i
+b,a&pCP8BCM$+G[2lKAb[%,!"1qF58ifLJrJep4F!$D$`#Bh1CcaIJ3&F`-Rb!Ii
+5)J%SKS,VCH8"mk-pI&YG`GfS4&@Dd,k&`1@q6M,S$#JNm&BArFHe[*!!k5h`Z(X
+AhYM9kSiPlTL,0iTXqRlaDRT,EI$@![N2eGj2qh&CiZSFZm4MM*2m'K'pjTe*)JA
+hmlX"c[0"CaPplj,pekRcdhV-3)S-"*d4#+5HrP,&Ur98[DS6'Ke1&U(S-)EX$L0
+*YSR)dC9Gq!+2N8Vk'b0LV'l)80eT6B%jF2rU!1cdJD2a@cC$-Y,d"31C[,j*$I@
+5Ud@3!2pBKSHXAIHd53@'YN*rHZ62bXKmAX%5RrFU8'LFKPNbS$q$(heN,Q)BA*c
+bHB!4qe[N[PUTK!5SRaGlr'JKm$I++!TE[miQ83)3(%GHalCMjMp*&%TB4&eI-'N
+@%''m@AlNmE'DRNlj&&)T)bP9)5G$0,D9Yc3NSd20jEa4R`6r2`4@Q!hZe*j4AL`
+!0"G&QCB"TqKXmT5--p82+D)JAjdC`&I!Yf3%HFakp#Z2L6e'ceI4S91$lZ-[dX8
+mTV$$QpYCLh2!!'",fGmX)4r-X6)1C4T"cCX#BjQfc-PUIjrRYh*@4C(lKc%8@kK
+6L5Hib#G`(dmQQ%INDN*I55+BJUC%LKKjC-UG,[lAk'4*04Z!69XV29SC(aFN)af
+eV,c6h8`dAN6ja)1-#&ac1U-U[`hECkQG*qJrZ80PULZ2K"E"2,@b'a2aEbY80VD
+6[K'X&1fU*f9(,I$!5Tk4,4'hai!eFC5US"q@q9$hD-)@ThMpHDp+bddQ['EaDlC
+Q$29bk4BCGccY!XNHJrB1r5h,F3CVceQ@Q%R,DDS$Fid@E0AD6KSViNVhK)0RUE@
+#*S@8*dY%Xb8`Ll'q2$CmCJ`ipB#CFUrN)9`(l(Br8T3k#0I[GIN2iF$,1q"4lab
+@qA*lcq(lE0,)BKqPRii8TAABaq1Q2Tmprc#913Z9jSRF3Ahk,FP`%r'EKZ#8FZK
+F)AK+`!E&%kib8eV1Y8EQU-qDmVi!Qk3ijZaZ*FZT4+FP`'Z[B5H8+`G3q9S1QP!
+j*chC9+e+!Ml[DqhXfjUq",R)122)89Dfj9r!GNM!C%9(eA16eN`fS,qj2h+*jV4
+E%KX!El#0%m`C2ESrF*Gl&cefRBh9V6q!b%(GGZ,Jip5`$F&S8[,Y)fNdlTB%dK9
+N94AAAeNEpGAP*l'cV,SVFUAi'iDD(%R2TmpbYC*%,)-4Cc8r"G9qqUSIp3ETjT3
+fUd'F+"R3aTXfIJV%Z8UA#FApVRVjdKrY2[0IR4kkVI5TBV-Ycek%#(`,dfrJcab
+d8)KQ$f(CZ%3@T)eBLE4h$j4XC,e`,U6X**fdSQ9Tm*TZ*fAXfY#IbX8iFhaQU3R
+V12U9)636%KKMjZBHX$hGG&&ED+fqYY6$8HTb--U%lX5`)!GEYTe+Z3,!iPjB$j8
+lCYPmm8`ALQ&,iHV`2"X8M6*d$$9&*GclE('"NkedAlI-JN(+lGEqL4rVXN(5m8B
+8m"&)HX%pV5aa50kN(Aed0N3SZbRM+$[Kr"M8+)+4miJAYC!!RFJ+3S#-ZBMXpr(
+f9aZ`&Y)QPcdckXe(iIh0ffDX9Tfa'H'DCa8#C)9V-MHHaSVD90b3!(@K,9XmXVU
+E1@l,Lh`4EqMGe0kL,*rHbhGYAGH1ajfNZ9c@+$U69f`0iFhMFC8q3NBKGm2$#R*
+H6p3HD+)a@8hH)9$SQm`Bb%BkqCRFl5Z9&TH)(Ad55EVSYV,%93+e3jIhjc+ccZ+
+epb#R@6Ek4XHd%,Dbq60AF'9QpUi5j6Le0aXY$8,h4dFB[4*NBH6KcmNb3@a6hSV
+q(J0mb*eI'Bq[lY(`Q1MK#AYYRl,)c6T(E1@+)r2PND$TVa0('51HS-L3!%q-bkU
++("`K[YVebZMh(MFm2qrT0e@h(ffh6kq'8%Y,0I!!Ca#TiM"-8Mb8Cf$RD%B%(*F
+`F(qC&CGB9AI&*!e*fVH0e,cU`lLm434&@PMRaBaG'm*qKP$LAhQQSIIF*FUe90U
+J8kYS[LbK!eT3G6j&1i&J24A3XY[E48qN+YkL[HPAJCZ[hTDG8+b*pi+%3V#JU81
+T8EJ*lT0-MM#q"0DaY3$fXSQ"TeM%Hpb!j1!aYjPXQ&MYMZArT#J"mE+6PCHVh#U
+#IHbJ10Irbc)EpQj*MFq@m3&VL6*EB3,C"VD[E3med*QV`GUkFKeMY2!CkB4![8A
+8MU4[J2K-lTQd1U*GDA6(UIei#XY@M-B3pDJ[,IINTY@BaYr*LicHCQ(0hh+V)8-
+A9pkV1@B@215Sqb"8Qdr&!CK+Dq)+(HU$"J8c8k1SS@DfC3GaI@U-4,FM4*@8b6#
+L'SL,45q8QGDpKk&jhIir+MZL(BVq0TjUTL1N)e-CYqaZQ8*dP`[Bc&+aSEDIIJU
+q"al8)(d*%Gfi3c4E@*U`m5rE9r&TD#C%FVeKX0PPcBR@K(*hqQ*@X%d6k0G+[H3
+pi%YAVhFfIR`IiepUK0(dcN"TYe"e,&bJbBca8Hd%6$BAAKqP12+qP,!SAB&m3IZ
+LLcQ0p$1IFlI('SIX,G26$R#aT592kdjZa3`d2J%*8Z@kXUfY88ppp-I9aqZ3!"$
+*e+dL-`AJj8S1P9#233J#A"("HQI#TfQGKj8D,0&kJ6V3a@q`*9039X3-1j!!-rX
+jB2Lb[lj$J#CjZ$`&HZ2M*FkZ1Z0**3h+`e()i)Z0e28B([qf5XCLf2kpDZ$@Q6(
+GUllSlF(Q,)HkR&m,UF$aef+@'RaEKfGI'Hi5A+GR*F*fPjN"2jrp*h+#XIhLZ$'
+IL,L0UTpX@19mN!#YClVmX6$hFI!"#E)1&#FL#IXmkp6Y6DciL3RB#1V%j[*p!M6
+)[4UM[&[6cS#'DQl,9YHGN!!mDK,eCP6PB`[l%CN9VkE%D'V6eNl+(m(pP9'*Cm'
+FjSe2lU+b@mUj'UA-BmLd!&%YQb"Q!,1h6SRd*1k"U%$SMp'ZIj9LX&U(2H#h8Cc
+,B5Q8iULKL!l+lLMpR*K-#%1lTLcm5mjIB@VKjX'a1hGbdI4GH'(IHfU5*rQXQSr
+P)MjhV2LcXph68BT'hfkfdR(YiJ*fa0%Elc,aDe,A&j!!J*kLG'fTF+HPCD&!eVf
+mKhIYD5KR&C(q8pGSh5@)[i+5--kr,Xr-`16S+RpKUd1MG)"0R*%@01@,3fmN"k@
+X[cA'["*+FHPMCeDXbEf[fZYF'1YhLjFp)Mi%CTl''C[LcATa+%L!'ES1AI&XCa*
+"I`A4TY-6YNT*LiXpHGl$Zj1Vhr1Za4X1Ef*`4*I+m*F1bh-keDJfQ!BRmAEI9+%
+YD*Ph#pX4XfYUG('jhR"iEGc0`Jk(+ThZ#I(p0,3[hXM[+E2I9F'jpeNYQ+dEN!!
+8!Ea(H405(RXdfUI!B8U)f9!r64$qrZ6l3b#!N6'laUCJ2XDpbB4DlC4,+G0RQ2f
+h)[G'C4Q#i3`ZmTM'@c%bYqq&e"-JIiTVXZl'2U6hV5Ald23Z-0N[N[Vrjr$`r'$
+3p2)*QKflAV)k9fcPmm@kM#f5fjaP&9&"Q0U0(NRHZ&ND84EYm,imH8Qh*5p0a2*
+Im%JGSNDSH%aZcBMJh'E2kQ6RUl0ebGDqGYeEUDC0h9CkDCS#(TkY83S(S8VT8R9
+"k80qJ5%X%P,HHkr-K-*FfQ4p)Fa33*3T[AQ8#j&P)`+VT@!Aepe5A3Cr5-i`!El
+ImDVC1eERc5HHfm*H,@GYkUQAq&k%fm"XE++G[`hXD5YDS,A3D9U+h@8-HL8&)I3
+rTX[8kGEJA`21Hq%ACcXX,54%DD#LB@K,ZcjrbP'V)lhf,GieV@IqDKidF+'*TA[
+ZepA4)Vc@pD"m&NrJ!6mIHlI(KPaK,rT$6F(Lrh2G4T5`8hK0bSFHAV*!$aS0UbF
+Fll*46F,KJmF0qE#1`@qVSCUFD)+H1[fQrRL5#"K")A(cK[KpCH*f*arHN!#+q0&
+PlT1D9'S'QRq42l5MdkZa$4CjBL@fc(6mkjX*KdEP28,9G!q**q)Q)+dCH+L)F**
+)VjXelc)Xf81p0+'GBcJB3c8aP#eqL@@iPCNU'Gj2%j`ZEYM"e`cV"NpjEr"r'eS
+%B$f9ei'J,A"&N9AD82eX`K5mljDe'aIieM9kD8j#(UNNG1*q,J%-#m-KE3e4IPD
+NlS&+r!!ep"VcMXSar6'SEZDCf$#%@a)SDjVfk2H9c)SBlY'4X#V@Tkff[d16ZMq
+L9%JN)3CrTpeP1mBa"5RH@0QBR3Ap`'jAY9[HA,TR2RdXbi"!a#l3NS0jSDM6%2H
+@M"rMZkR3GrN2NQ"YEMi9)Kea0XAlF6#433!eUmDrT@68'#jJcpa*rq04$U*30&c
+!iD(hlL9($JGL"N89,)RkkaVJim"S#mE[DHP$dPS)fVSQb455+0'#i&[XVE%K+%i
+fLqEDRk[XYJ1c8rk!qGMAE0Y54[%QBE2F[+'I0#9DRY*3R%0-rcUT1r$2P8CU1lK
+XUMQM,33DZ#E5,Y4ZfBpcUUSlm-$Y*CV)aXRSP0k!4306*q8%`A'IXT*EUTEUq96
+C36JY-Ha092kK2!d82Y%@8%HmmApr"armR[[KJ1l&kFSNV8@-U![&Ncq6LdQ+VVh
+D)[!VAYqE%-j55'%YH`9N-@*NXAJ'Xem[U1'`&iV!iEHRcb3"iQQq3Kk82J[B[@2
+,PZkfQVp%X4LJa'Y&HV&R3H[1Gf1$Tdf*c6kBDbQNdMLJ2bdCEJIZ[rVZBr6Ka)V
+3MphY@,K1`NL69J!'iQ$bleiD*1+cDAjN2lj1GG$,SG)Pc9R&VSACL59*kq*R0Te
+Xb&kq,fJ[ik`Ec"YFkaHq'dRf2fFbI++L%B[IQ!9*`XQ84DFa6VeDf&,!`*L@9BF
+FLFZT[-q2Tb'i0$!VD[!QlD0qkmprKZm#MUFF$CINU!CE!&%HkNTSj93T!3I%@i@
+C6[bkL'3jZAAc+@aQVdX*q5mlDh39A[+6`DekjI$"-`rNE#bFqU,8lVFDA,DIc"D
+I[KdXi4DRScX-iPAZ9Q)51TDhp#3NGIMpQd&mab%i6a0bC)d+FiF5hr`1M4Em$jU
+T&dB,1N#'%"BY96fYNJ`[k@E6k&V5bSQS!6p2#S8pkK9Fq"-Hqd!563jj98N8FXq
+bm+IHh!lL,k3Ti*MCb8`A(GHZl%4HLXR6`ICU5cTZH9[")rC1ES3$iU*jf@834Pd
+Sa3hqp`%`f5$&E[#f`5$a,ImfDZkk+%``%Vh'&f&M'llcRAJ$dAMS0TkpfQi&BH9
+Yp(r)e4B`50'R1JNa$N&$9hIE-CTkfb[@'mG@EJj$NCZ#AjKqH3'D18--RZV&Uk,
+Mhf@L*S[&)-&()i#G0-K4mH#$cYBpfcYrYBMJi(2MQkNq(B0jPr1cQr(m@K@&5@E
+mGTP'fPF30Cb0e3*8fpD8V#m,9EJ68VaBFiHh&-J%4pmm,E'%R(@&0Yh(PPMFFPX
+lH0hYi`VCI0ba0jb(%,cbG$pI&$rPGNbjrjdSGpXjk'lUVm$+%9*884m,fBkY',I
+[`aSRG$`46@QqT85%pSdQ5Hpe@1AfMR8A-f8adfAX[1(6G2E,KR'qA`m3GE4D14h
+L,EL9PNrk55LP!!f!Hl-DCMk[II@64kQkjDA@3Ch1#TCpcTqcJUc8`MEUeR-mMi5
+4pC)KqARqR@Xjba$MR1hZMT20K4%ZC1dRPbF8TMFd9M%f&@2#UZIiGpQ`F*Y*@8A
+p`+--PCb6b,DRE*FV-N6K-0`Q!RUVNeZl2jP6q,SMAHR,!B[4)9FCEmCDi9Y+m6c
+qc2D*pfV%AQc`b(Lka0XUZEp*E"F#bfl&j,&I4Nh*2+ieYi$NiZ&TCUmM"9!d+P)
+`R*d%9mF+dTh+h'6lUB[%AmN3ebd[Lq,5,[KQ,Ze$CG#9V4(1Pqj)Dar`YlfVZ%%
+SRZ)fh3LU+A5Q*9&3df,K'##4EeH)RD()@4NJ@+d!cS%H[)6BaJD!b4%l(`B)E'L
+L+C,"&id#MNAlIjIEKdY5QJX$4dl!@!#$Ba4k#lib)E4@S!U%jG)R#Sjr+QqHHL2
+R,aiNrPANpVPXN!"T!YFfQ'BhqmJC6@@'9bD$*P(+phQb'"3iqkDLbRhh5P8hlZ@
+aqE0C90hhl"LZ!qEP%`HS*MJDfGcIRX(,*GL4PaC#cHUf0MNKIj!!0r-GKII0*`A
+!$UVcZ6+RF`D9MM1F1X4CihdK(a$4Heh0`lkaZ`8MaTSc)ZF2i9N,B)0Ed!5lRpU
+VK%Rm`4C88a%%Bb@SV%m),'9QfV(e%iIBT32+aD2kc(82c*dm$"Q@S#@3!$"C33)
+[L(*Jhp9AlA65ZCTr[DZGPF$rNK[fYKTE[Xf$!Qe(PD"AZ)10rfir`R,A@P#,-Vm
+JE@+J1iJlB#39e,l9Vh*2A-d*EAfF1,l&-BcDjcb86D3`c-3B6ma-(&i0F`@Z6X4
+@"8lai"3Ur(eNRcHXmMQ'"hRHre6L6CQl'Z6QS)FQd4Pq#H`[BBFVrG&)3b66@A#
+AdE4LY`YUY62[0m&X5C)J$r9CR2a4ak4-@XJq5hfEfE1*(FfiR!JZLe0ked+PKPF
+eY2*Y2@6MrSBXXb6UX&)N0R5JXi%MeYPV)5kE*6[lekZLr@$TQd3RXN'k$dG9DJ$
+qZ*dL1#41R-SP1B4pj9f14L)@LpTh`2VPlefl(MeC-dDcEBDCpL5r(KrhAqP+(D6
+6+F3BY-,MDJGLp&M2%38RN6PLD-J'G)@&l+fJ29!pEcF32N66ebYTMpkIA58%e*-
+h""+4D5$3A*mdaJc9XdZ8NHG!jdeX*M%0K%#f*KrJ4+PR-IfV3Z*8'I*Y*EadPHc
+'M0#1Irpqi3X-!`4lQ9b5Q(l[,'$!6SJQ%pd6K!2rIK&CeH2f%UZ#+9r!A0kd0D6
+JD6FAl,a`QKHk-ipmNN9cJYrGZBI(TAp#1q-Lb+bkHf@bL#18'EhX-Y5XbGB4iDU
+lCL')cA9Le@f08heeJM)H(!S@&MQ(5Ll#q1ZVBr5Yl#28Z5E#JB"X-,`LYpJQRbp
+`%(AFZL!RbPl6DJ(@2X+h"P&1hBC59FNf8G+8@`FNrNFAVikS&9F4ZTH[Z1'hMUC
+"8EheH[&a(N`qm$eEd,2ie9rBG(TG,',KDD1+("55+cB4M`FGrkISh9"hfYPr)"'
+0UY$[U(!1c+BEM9d-a)ER,9E!`l(k(L4J4iiIa"N"*Chi8a$fEqb4dA&RM3$G-Nk
+9pF2d62Fk*SE+IX!rUKpcPL09b6!8I#mqTDC"lBi4#)a1KUl21dDX1cGqX[,Y&dT
+bEhm54bG&DYDDN[RQ@MPAk2&M,F@M#4J5NMC``30%kG81&a1fJ8R#`L)(NN*LrID
+"lNmAlCK%!)GTdl9PBNidBYUGP8BpXJrC,A(L!232@aa5$p`d#j&B"@rQiq+D[q`
+(iq"r8V"CEPa,`[$fq#2CA*BZXc9irrl0Z4+TGBS3HaD8El[rRFdm6FI`!VPV-kU
+kAmcd!NlA0"VUi6*K`TiiYf)5Api8[DXlqZVJA+!jk[3Ue3C444*0F#m@aNih,pS
+TZMZa*N3rYf9MAr@a%0iA%,!Vd#J%Nh'3!,8Zk2c-mr*a!,kUb-k,Fac4Tb)[3%5
+f'N-bCRXBahRVN@ljp#"8%iRj5RV9ZY4pC'AiSqHJfpef#ee&@*&%Pq2QcBeFj96
+pKbX6[&T(iM3q!q585+K6-e)lf%)8$lMH&V'NXBM(19FcSGfXQ+Ab!Y+#)!([ba-
+IJS'kV(4UF)hcTQqlX#G5Xe`J+IH*fbr$@U"AfdJPAb`-qNIHmR6fGH8ikm(3i0@
+fc*mqr0j[(JS(Vb(YQ-B))b'P"k`&@m"EA`[!J6a`QD"M1,3D8cLG!qbr$f`09ZI
++FH1rZm*NRJa%6,[VhqlYAD$#8PIZk)"R-lpRN!"GGcU%['a*eEkZm8+rSLC0@kd
+f'BKUL@b9)@+%eN[I)%F1$MQST!(bNUM0B([R2SVmBrQ`6T4[DZYrlA#m0#)X1S4
++2(M6h5+ke28RU[#VG8*e'bI-`R!2q@YXAG4d3k1Ar#U$!8H4`)V+Z%52Z"%)i*9
+h@,Cle!+$ET6q#[G4Cjj!fBP%KRQ3!#1DN!#Fqfr*)P-48F%ZC,+5$!PK+Ej6,,f
+&H,j8,hN`8GL%)k"`G$pq%(YhMBfA,2qVbS4kI2XT65MmLG"HRFN*hTiREU-'$jD
+b)'jdRK!(rmrEB#)XbS3NrmmUIQ#D%pqd8Zh4V5!ifc+i9*R9(ceILGSTGI#l`Gj
+*1la1AEHr0T9D9@JP(UE*58""hS*ZRIc`MB8he,GAKPm8p8h4U4I3#3-a+Il-SBk
+ETMclGVhmX)kdaReAR"hQ#G8k!HFL'@(l"BV01q2$IcD'AibZ&4BK#eqHBlh$@mc
+C&*(`V*M`RkhG`(rcL"$jeVEYfRKp8XUY1p!5Khk#,+,hZKCrJbV1EPK[I@S4meL
+[(AG*8@8!E1#YQMK$N!$k*#JR5[eF0M53!-FrCNXV!Uk1&T&6%c*G!'ajfC'FKlD
+P*ABH+hm!r*)01R)0fLe+KCY,bA36kb[,qU@mYRT[EY!jST&"!l%RKkZ%mCH`33R
+HrcL*6jGk%rP0iRf"VJBTU+Z06ET'fNBQ*2K#QqKSHf0!Lk[r[fDM1f@)%DdQV%p
+Gl8GZS5dhUeD%2G`"IZ9)U(-CJ4LlD'1qUlLD$IffbSbH2C!!K"3V@)%Y@ZXA)V2
+Uj@BF,8Qq'Y)"m[YpIHGkTBeX'@2KleMmR&TG+K!TF32568E0e"QCkb8i1`MNIGE
+$#X5e[ViY16L0T(5'aGe)K@9(UPb$!$'REZipdbQil,9Y!AXiQ1%20ZDS8'r%hT@
+N8A$QZBq440E#MXaR$KX,E3[G%YC,+VAKBEl*Xhm#VYe5"5`e)F3bE4#8c+DL-P+
+'1YVpR+i(LL6ILFKQ($SL!-FFh2,G!$0f1NLE)&e[b+G4)"RAA8DcC"*+bhXR'!2
+f!HccH[k&lZTl&4K[q@F#l0$hpjYGV$PjLeFSFPPLA)BaVaf49&Rf'LY)ccS8dP5
+mR3"cTk)IBI&6&DGQ01D3!#B%rIjD9(6)qKZKiCidIJRdqeb',df5iG8#!NGD&Cd
+0ZRSYEb1%MQ$%imbDJ")a'1P@"D,rm0eSN!#`01iMaI+1)4XKHrLb2(YH&jQLXRS
+LN!"1GS@I+pbYkSQX6U!m`I11l,*a63bVPd#+`dGNpR01lAiijGE5kLK%Vl*[ULU
+d,S@+C(JX%iXBFEKU&BkRIq$25rX%a)5aha!TC9["r*d&!RE9jTI14BY@$ETj&aP
+DP-cA!VXU'&iTQbhqfUjS0i0,'C)R1r#p+V-Um%q$4R%,rEX#*#lceT`l@J`F0C[
+#9DHa1DScd'd56h6Nqjl)G0mA(RfX5j!!(&aB)JY[Zj!!'J9NI8qh`MJb$h2iQA!
+d'B9SjU[l5[HHiTRNFmrVPkBG!!cIaXj5QT+j$bfHZ+0+S(hGmjq!%El1`a$)+Lc
+FHc'BFY8"+&RkUFN&qF!&,FaB!JE4h$AP*kZd'@ZXIXKkQ-VNXe9(,['ZCe%aFBX
+J6UcQ)G++%bBNk1bD129pVpYFXmhV9-Vj1m*eq,j1$ilbYH6N6kSFrVAf+!Y%NJU
+i#YJJ#6b9RZ*LQqm+`e0lNT2kSQlZ#X!eBQe4[qb+qR`&Gk`!"Ebp2`cHd2f9,cY
+(H+#)-#M-NBNZdeK52"VHCUT-"UPl`-K'm3RKCbj&iEErMZ[r6-X4LqLrUAf8$'m
+erbi@SHdi%kLH&Z5Qd#m)a#C0CMf*Ra8r,U#SDiF8&%#p5KQ-9,hd5Y!IbmfLbbe
+l@p3@[T41fZ2Nqr3Zc86e32+jAf'`Y6T&NkQV4XGpl`TSf0PQR'3CpaPGDJD8C0,
+U45qiHZUqH)6cCL'L5A4j6Rd!Ml'F!&XfU[C9&hicH1lCG-q@8L!D&QcSGjFlrkQ
+55&$5S"%j#pJcL3i'#&aVF!laj2+c#&e*m&iDc[63*!#K,J*hDjlkI!&k1iB8N!$
+m-&@l[)"&@PL&5CV2jHBaP+hN30J6'H5ir1YMZ#XplfAIf30h,p%rE$b*pkmcZ4A
+-1XmmcB0dQEDUcr9Z%J[SZCaE*E64JBJhcr99$Qk(JSMcK0dMAeVChT6mLlr8,$2
+2U#[j8)'e8Ec"9Ba`&S[(VNhG9IbRVa#)ZpAe)B8V6VDCe@F[cb*jiR5hLd358!h
+XU(V)$QKe9[PhdYI0&cdELYc1#ki&Nj&PCad2BX8AiEd%6ESA9U+#8cF!k#$EBL*
+'A@+`hUjdZ5'14kfBcpP'S1$mH1!06`p+j1ecZ#KZ*djp'c*)hlU9Clm+M%-$+T3
+@6ajZPMiehF6rqMbDF@kYKfVYr!($#kD&XdJCjZMdDDLGMVVZ8FV`HRDGAe5UkpZ
+kbQ&Xi4$c&"K4[+VI0jFT'FDG)+0RahmbAU1VR&2qbL@EZI%"[mr,,)kcMk*M["N
+VZaP9G9Si$cLJ(b6B2hDmL-5#(I+)Q'bhASE%#LJC-4S[9%kfala'-$,@U8LSG2$
+li`$S#H*)'8Qm9X-jQ+NYpP2[#D&+6r#NBK4C2B$1`"J)(*jXfHM`84P0Db@lKPD
+*)'EN1X%p90D$4AUUUG'S[QaRYje+D3TcLj!!f'0Pb-ppVaD[R&*86h0SRABN4B4
+HfRBBSU3IF6E&e$3QHN,9l5V1i(dph`aAjp!*K490Ch1l`E)J2aiPjer!34Qelc&
+8CCdY+ae%"4q,X0AHMGPSeK"8'!'&!dV&0Zep-c#4iqm-e+T(YrD1X0m*&LI9mTP
+#[qZL3`Kp#fiHiLU+SN1+-a"'K`+,!NSHi'8V9K)X"cD!&D66pCX'*cc*S-[6NeI
+[+#rN$'4#!N,`dHXjPSH@&N$kFM'E@(MdB9JTKZAiI[&m0P&aHElGVV5H3q*QcF[
+Mhbr8Ga58U'[pN!#43I5r(`(E(2@[dYcb%%pdTfJP+IZ5`"-)UBD1hAQL')dC2S[
+aIpT2dbbJ@L19GDZC&Nk('XUBJrSk-lrmqfPdl4RQ5rPICjLE1+fSH),Yj+R(!GA
+LaY,4QBhiqle3$h5"m%NR#9ACf6K9Q"0AjHYb1#C8,0a2C!c4(#5aeK%D[3#3!2)
+k2RPac[CZVj+4pMrIG%SHaCj,@6l%q)[D6(-Q[(8YCp(@)VL(B$GM[&rKV"AhRYF
+[RR58EKl6l068cBPV1BI(cI5k(SpdTh6B8Uh6G28`-U2-8KP+G9[mhS5X$dS$-N-
+k,l"eD(eJFp9G@AREiN$'Rc3++dUCGeX4H*YJBQ%kEP'%KZIX1F4,b2VS69L+&l@
+m$Z@[rMB2JeYpb$djC2@l(icl$C&L&A)-fc8kR*480d&FA,2N-B6P#)j-60GXV&[
+CAdUU`i"XA[cfKU&*M*)H*!8(eY`%1MmI4`@Nmc+66C-je5@a%'),rHPej8mKHfh
+XZB@"d4`b9Ck#f,N2*85"%dG"mK-@NRQ5XSaq0Eid)$eh6D%p+!#DlcR(9Uqh6`8
+NNJ%TRmj2)lZ$UkjaZ4ZBV@#aCPaBqd8SZLC2f#2A0l!a'Gr@+@#IqAJ'1GFiqIQ
++F&#lFF(h51&C-`#MCN'q)p4@G6fLf#3*P&lBIY'r5RLfEd`bDVAX+)ES&pjlMDY
+j50XI9Eb&G%0[HMqaLpI3XZK4cVZe(dK)M6SIHc31df*Z9Kq$5f4&EG8$0Q`F)I(
+H$@(i(MSTMXA(aMY1bp%NkB)"IrrqPlC5[MIRRc!Vc!E'#C8fGp!34"2!R**TLP(
+B*m#F`HlG`MmKB1NqETD$05"hJDe1e8$Ybj0j)'2(AS&)X5q)SVPm-9@8E6YF4XK
+EU&MqpBK94aa!YiMk8j,h5D99kqqVT%SI[RmcHL(-R['`b%D#"0QRRral)QQ)@Ak
+GSN+keF0&,N9lN!$Mm(dmh&J9Hl(SP3B*S1XQAL+rCb`kXf8LGL"B"eJ!kQ)3[ah
+3&jF"f#TTeYMXL`JpNVUli6YK2rN@Xl03r,rL3GA&N!#%q@m+H)BDSB4QEJA1Ekr
+U"L"-X@Mmddbc@N0e4XDT18YJmPI54@PF1Br9D2[THa4Tc)JAm6#8*He1SU,,(2(
+(e$qUa'A*k&9lA6LC#[He!I(`4KFf9J$T$*RLh$'$0KALDDYlA5[DG5NaB5RA1@J
+bm%fEAZe%[X2$irAkk+fDD@C,-%RNYZQa9,%jL)kU2hl9!aPHQ$eYQqUq6'rl+0M
+Q`VY'a)1KfeNC8%NbM%UUr[''BA*YN!#`JDJ&qY$[&ENUIPpP*SFmB&fE5&LJmaU
+5pY,`qkc9RF4hjAT'f-#!4MaRL++5S6VNa"ZeUG,'-T(jfE@JeCK&X`6cHHAcZJH
+Fq`FU&HfP#[Bh9+MV6U+JF@[[*QS9le$*k8VGCp%S%jV6F!a#bm-+)ZN'iS+hH9[
+h(pJRhRSRl"h)')DKmib+$@UTYq#)E"SJ8QGMfj%&RUEZ#Vk2VHp*Fb3B9Mh&Iac
+a@8q+T`TA`&m3Rjd5$*hIac@G-qESc1$r-,H(m&h*ErQE$hj(8Mcdr$Ij1"%I)P9
+V'$C[39Zh'4!R1BHR2,&V2*D1#fLH8raI+ZjP2I23V#P,Q%YMl6ZlGS-NbB!*8DK
+4ecCA)A$ARY+i6'##Y2PSBJ+RY2-S-DCAR6KK-,HC(2!(i@r46JG)QJ"RPh3a+CI
+*)"`q(I1[!e5MK(ZS8aGSEI@F(@5)cHrr8ITNr"6!9V'm`d!5[8dQmiKYKXLFNE#
+r0e!YqF%XKGYldbrVhHQcT9fca**5`-NlC#iBp5e),FGd@p&cMP,AQP0KVqXPChN
+V$MGJE[+THq6PHXZ$CjhC,N4kVPi@pkdS%BH&!RC2XCJ[,0DBB`X'5R(c6ip@4X`
+!4JLJLM&S&ZUbT$CGTX*&CeNjNM5$q*U$d(I&k(r&U0BY)BGpIjd10(@$d!1b#QE
+Via5IZY)eSmIYX%@IE`LmSFe,R2)ahX$$A@F&%l-MbVlmpMXc6CZ`XqRY'lJ0BGM
+Xhd[Aqqe&3NNU--YV(2-ES1Md6Hi3,&f%U5QNYJl*5)CT+PErF'+a"%GqAM,Q+X'
+eJ#'-SN#qLk+9lA0b18R(P6qBq&fP6d!E#H5HMmLCr6d&LJhdGj`dCmeX()!'e4X
+ArVV2&J#IGT*NSCq(lc%EAr%-Q-m&3mHiS$-N,!BbjIjRq`X1$mJcF8bl&PhP+3p
+dIHikJU#T5@P4M8PTJSMeaK6)dYa*5eVI-(h!UHeTb`mBq1*F`qN6r"ed!IK#Np@
+I@D98pLS4cA)R-4SP@C)bG8JYB'bR1B9MH0cmKaQX)cm[DU6!T[ZF`CC9k!,+0T1
+b-S)UfQF#de$(#RL+JBm)eT(r!!PXdqJ[eK4qNDiJ+M$kTJ"a'95LjQ9f4qb'b&q
+fk`q3!)4,()8c#Yj8k)%j0+m(E3VQ0iXH%,YU*#I)cfZbS&5F'GBG@mV[rFi+[&Z
+6mkfP8E'mS@Z-j#+%Rd,-(V!+`%E+VTj2ZVqQqfhq&XAaq$*rXeJ9cc)0cip(NDZ
+Ea28q!+2`SHMBj3-('alc32b(d1rBN3$QRISchf5$D!!%4B1Uab4e+k*M&-53!(@
+DmQ+hXM`QZTF3-1j"DXMZrr4c"4qY+X"Vm%llAK0)c!X,YY'2PVNCUm%M`,G1U0"
+aG@`,E8U@4(PFBL$q+K3q5qXDm6B%qqcVUhjqSm4larGaAJS-Q9acj"Ee09i+k`0
+E6b8deTcCD%0H'!cSS@9l!a@iiIi&LTI1KX6D)Ck&6cj6T%94eF,'iJ[(GFM3VTp
+VmYi1EKZjL",k9KJ22FG&5pMCR(%+Z91+L6A11BdR4$'LbmHG!KIH")UpI2p&(1F
+SkQ2irCBCHHAR5r0h%Fq9pNR!aPE0Dr@L2Y3C'AM6'5mh"P([T)hK'a2mMGb6M0Z
+`qZD#iJ5,2Ra1RQrjqY,8Z4IXI!N[8`'%qHL$Sf"Be5V9rjHN[AUk5DT%V*!!9-*
+LH9IF(*rQi+RV%#[KIbBXlR8IU$X%fX[a(+@pSbY+N!!Gkc450"*B!MkQG@dI$@%
+b'mN0'fGJrY8iYVUaEr)T&S%hV@Ec-kq,46#X,j@AZ,fXJ4Sdd%$0+VUi59GL4YZ
+TRU,S'eXQ$mD,[J#AU!4JRIA9j28NPP$I`iTJfSdQ2(q4@IfkJk,lcUm*kU)jD2h
+%VT9`2)VQqKL(@Va)*G+TEM@ZJmlXrm"SZ4P`-IY5'j2U5(0LfX@I5Brb'2ABG*P
+,"h09YQVI)*!!'"&6(bckS9J0Uq"+aBrTHrp!$Gk)(6+2%j3P,Vl*5EQSk)dqD@"
+DQ`E3LJmJ2+Jrd1JKV-"+I1T8[qJ%#PMM8R@KRhQ!qL)U1eLDiI!#XqB3%1Ha#`j
+4RpVE@%e''UDFq486pFQE2cQrh$rDiVHa9`He13PZb1QB-mKj*@10NhC5`QHEb@e
+hGE)SXcQl)BG9a23SRHL+A5fia5$jh$$4$1`MS4qHq19Za9-T2DH$4ZH$VCUAIXm
+9*EU+qSS6P8IPap08RB@+2VPL6SZkiDJ3k#&5B`6RjZ5Udd1hPS`%@!Lcfec94aY
+,,RUa3Gdr*T+cGfXqDSDZ9!i*VeGeb'ZY(#((U-$G)U4kb!$T,iLRh+b4)Y!L3kR
+A'*b'fHVUSIRkBL!!`T+Y'64GldZcM$0Ui"%,FM(R(%ZE-C@GF4C6pfq`B#"b9"X
+l'PQ5DMdJbb'i&hZm-r5kZGQL1CCk%#DN%1Na*l5XZ`Jp1FP'E[lqNq3*"Nl08IC
+EEJ,8(!8!+21&MFE19$p)c&K,5JjQ-m6fHcMXV8qSibd%M[B@jAbc3QT@831P1k4
+qcj8cIhHeI[f2R9Ra5[L+2B$q5ea[,H!JaGX1FCjLF6'ULARFC&Q!QZ(H`qqka0[
+crMCBiDpC-B#8hEG%q5T5Q"Bdb"KE#LQHfLJ&GEFpA`EK@Kc0pIV#bE()jq'm(+P
+8l31mHF1r-9HF@`!`cZe+DPVAZJ&@a0VTVGrEdA438Sk*kiIClr(e%B+Q@J[i))-
+4$18L03G%$k[%#Y+S)+ZmqIPeXTdq(Yl'e["#fhm&XNVFf013!#lpI(U06J0p%H*
+04qHU8P2H&0(d*FYmR-SQI',+d-h%12F(@$qRBbS"5&$4d9j)#VQR(D"(XFJ+#b4
+lXT&S8r+3!2F2AeR52"f$K)USHF+$[T!!QNbQ[(&8L&H86"K3RT!!b@jGA1X%6L2
+YH!KEAM,%mXp%i"eTiN*M61Ar!#GGMj,rrcEC%Ye+I$kUbrM6Nm$J[bb@+4pBfXS
+%4JkV)PrL&eN3I'df&dI%PM9,c$)JkI"JbBKX2hE@N@Zr22#2ZZNZ5qXD0fN'k`Y
+%k9)(m'R[jmCTaVqNdMk@ET9P4c@Ek'S54qAJ#E-@DUM#9c0M-prKS8EHE#mB'[h
+rU[,0#B4TA"AlUY!FEV5ffPeQ[[Cfl18-X,JKBkm3*#(mSe1iC$`%Nl11F`2NSMp
+dUYr$QVPMADhAiNUFkU#fkKjIqrXj&FBQIHLA9&1MHR1pa6jD&V-cI@Fe@a+lm0,
+#V)(,8p0a,r)LE6"QlNNdk3-*dl1q$`*NaKYLLZ2J3AJ[d@(JkK1+Pi5*+qGddiU
+pm&b&iSG!,`URq[MF8$L3!$fL'+p*6Y+M[6aE[ji*b'0NjFJ3&8jpjN1c4bqN49f
+'T-@F@d@h8hDSRqdD(AUEm1d-'qk%Gf5fFEi1H!&'YhF"JEC@UI5i))b-&0,h,'"
++bPAZZB10%`MFU&JR`D5TbBqa'mG8N!$aN!$6`mfXp6#CG1QVCCF%1Z+%EMI`C2!
+(*jM09"C1HYi-(#QkUNS+TAEjiC1VfZBpH4Xbb--9")'EXj&UCU@+T$2hY,,-Y$@
+Mc9rh,(JP8C@Jh*aU"2lU2-(NlrUqAr3b9JN1'F(E(Z,CAhhb2V*$,I@k8DTYUBi
+LZTGq5&JV!l%-L"&[V2e(@b*IfXKk0`&#`Q&5k3QFd8[!1ND5mYTliDF1T8-N@QX
+TF-Uh'10NBmAbENA"&T-H8RE"R)2UFS1T`6F!4$hm`Ge5KGLGmNN(MpklmfLbr3G
+IQ(3[Nr36RB5%D1e1D&FTc1)-XGE#H)RkV)0Tmh,L5UNBT"5DrfB4l4!%G#d$m(3
+Ljbi3)p#jD+@$+#%+U'S#DeIQ[((Yf8CGX-GT0p'"'p6qibS1$i#U,R2Dj8i!,eS
+[)Bid3f(YRjRH@Lhj02+Q%ENLKCSFXcp0jTefrH')N!"qV,GP5G-Nm*bmcLaNcc!
+)iI&iF,#AYC9"9MV,,FrYMl80XeY@HG&(6@2A3ASkQ0XrSbmf`[I8A908ZFNXUGT
++E3ZX2MJCT6+GHZ45Mf%@1b4B83X'UN*AGdm&5MhkS@6Sm%90Jh55&1ac5DliY!r
+09El'GriJcH'DGK0#62B&P&UeL+F,B$K-JDdrU5ZJh1dri(`6RE44p%a(1%4#B8d
+r+&aaU!qq!A-la)L%@-MSEqaVDRH(f&,[I4&Ek-f-TSKh#FB9-M2YAf8e$UNirFc
+jbTSB2*,3E1J6NpjXQ"DZqhVAak6,&fA*N4[bPrrBI64Vc0HUhe,DkUrqe'4L*H6
+0hbJ1YqSRQqdZphdL#aiHGIeCrVMiDD-ElNP*V$MkTB'aN[Ll9Ic0J&C&rUKb-dK
+R1j0ekJqYNlY)bZZ'FaqiB5(l8HqZ5'BM)8VNQrI`"@(DMNphE86mY1am+S#Br9r
+9F'qV!cQ!mXLCS-$ejrId1Xa2AahlL`-!Ch@3!$P0qM9bFIS(RCFe#2IcRb%0(`+
+2amB`KESNJGqhfT!!flP[IdT!lCC+LQU`k#QSBcUN8'4!GDL9YqN5YkfAcRNrKGF
+)U)3dm2&)r'L5aHU+G(aFU@9dNKV(C-BAXEPXH9')Ze1T%'cUD2I0MG)#lbm0$6Q
+AlI(*DUi"4SCMkeYBhPF4hhaYFF@mEQISX#Bd1P28bG3YH%XQ3I19B*h6f(VT"Fi
+pEeNY5@-hHVU+M(F2kV![K'&#k`qJ8T69lC`bTiHX9IK+mC4ZNMH3!#12%Kb#5`5
+dfVSaB43lViKS6KpTh+a)KP(X,*26*2)1+%N'GfQKEMf9`@DAIj@'B`X$P(4)I-J
+%JGBiUj!!2eq0-9[N%"Vi,#0(9[XJqKDrb'F9Zm[G5Si44`XbFM'$CPS"[lJT2M0
+9jNY8Y-dMaBh8!K9'pX5BS0!cU--GYbZqabAaP#j)3jC!Nc6rfC%-6N!prJ$-Md1
+XK-4Mp1Ebkdd4BDiP1edL9e8"VMfY"6d5c!9RaFrFUUm8,q1*pK50HFT2$NqrM0-
+RGI2Cq(lI,i5(4Zk6Fb!rZB"2[Af-q`MkU8b4S5hfa+kK+L*r!63fJe$)1Tc*iic
+FTZl)-K!0P'S(`61VqF2`KiAS@3QiD2eD[eHLNP+fG`+q)FR$p@-B+@rl)*!!k'i
+1Drp[VdL241DdHK"F504"5&0[ej'GiXi"EPe5J)J$T(@a)B6-",(NNUJ"*!Mm&qS
+3@9dBSciDjJ%!&AX2VHK*(+",jErZ#A3%!r5VcCfkLF&BFrhIKHlSd@V3XbTpJai
+kEN+lT)h)1F+LXNF8hdBer6)CM,4bA5Bi(C0h$dqI%Y9CbR4BDL&5Nh(IJU5q!9P
+9+HDT2X5@GJe#peI`-DL&V2#+NjaYJlCqKIX#Zm$E$63SKq$m8erFbYIE,G!*D5R
+BC#*2mBTYNi`G-mQ'rJ)0[X&rVr4-b"b49L5EZ*Ha`A2$FSJ&chk-3D#IM*,3Mp3
+H@[XP@IJYmC)QNMA!MC!!-Y5EP8TB$h%[K0NB(G#qJSHcVMXGRVYm9EL6B@@,Z--
+&U1i@Pkh[-"5)LKfc3UI2EJlC$8eKP1+J%@r$LL*bF0i@'`A$"JIBU('qFlrM[E'
+0e0!16!RI&RDqAD!KMRkeG9q[TC-DeH-DL+AcaYmUYhF4QZ98h!Z9JD'LFYIJTLk
++dA@Tim`i[GEfG`SS+`eLLfJ,fLQ4Zf#8(32a@m#k"lQa'dUMbl8a%U@B30CrEQ1
+b@K6GUNa6P1T#IZYh0PcN26*YfVHUEaIpSMm&TAGP0!YF[ZH`2(rL-JpeGRb8CC6
+Jp3U0!SShCMG&&2Y"XBCmm(l&8Ea4$Er3GDRbFFb'CiqZDS1i-bHUid0&e'S#k43
+DV9VI3CraBBIm`ACTAL`l8p)d[+4GE8bYUe36FNrGeH6QVpPj#'bY8d0KeU%4A%!
+iNEkH)ABkiHS*PDS8Z8i&q+1U6b0q'm3kEL5Y8Q@TQ[Ch,ma''PqEZ!fr-PFcj#Q
+'0E0-Cfc`&l"GiSRAQJf%k,CT,D'8l12F6F6J6am!PEjIDK"JI`2""*4Ta"3D,Ap
+jKV#9J,mmIdrY@93A4AqmPj5dD0&0C`9%2!JJ*rAjAlHBJ0Pmpp5!,l5bYNfUHbI
+0A(c5X$jAr*!!a6PRGVA5SfbLNS9RmT!!h8*9Qf(K+)2BlKLJBX0(F*qG1)ie@'j
+P'!jSfS,8l1mTR4YT9A3U8033I1J84GjA4S)eRU8L$pC0$M#FqY8*S0DdeHSa5h[
+2Z3A)rpXR2GR"8Ldj"90D((A1C1@@JfqMmb@Fchk"m)4,L!+Q*'EU-qC[36IMLNZ
+fbFJ"P9ZQm3"I"$R`YMpT"23V0Q)#l"89DQ[q[-$''MUFNaLmNL&kh15"RXb3!-E
++TaQf%M1%r!)2fabMBl$3Me6#cpjf)5-Scaaa(VET[dl%fZe4(h*'LaYLB*i)T$F
+Khfk4pZTXhGrC&K&AGM)r8mNdL%K#U1II#pdr6Vid!D'B0QT#"ET6ViZGf9(4B*Z
+j,EAQ%b)Vekee`9(I,X&NNY*HNG`f(bY$1q(li3DaNE8fLdArRU9mG$US2CHE)PJ
+30%hE&d5&P+V'dbcEkZVl"liDjl#al)qI%cr2V"*jlcbi(QM!EG,4Q@bC8930bcH
+m)0(I*R6-bl2*'(S1[P2F"ejalAha"1C(hS@1lN"amG#QXa,IIq8mk94-A"Kd(eQ
+0@k53!29lq@9hM-0NUkP'EMXc3ZUr3&"2ep#G8+I[*iB3)$TmUqCBCkC1l,F%qS)
+@feCi"kC4@S+bESA2lL!+bP-irLbh4V9"!LKQp0#c,4,H0bcQ%X`%[1"R+2X5F2(
+a`GjK634-%)8Y9lRHMUChG)e[CM630#l,&m(Q"&UTEAaUlQ$PK"HG1P0kmf-#HD"
+0)ee(JHB5j*(#b@`eHrAk*U%bi6fAaMB[5e@9#CdQ6q[YeQ`rQ%p(mX$N5*,%Z[G
+UQI!HIqLr)CRr9T-BQKbZ`KY!JH2b$KN+#p5-*lK3VJ0V$,Y+[F2VdeG[(I+3!$a
+9jNFD),m'69aqABP@)'++bHqPK8G@l*!!cld,SG)bAqerRAe4ekBQP",8p(eNbl@
+![`Lp@@+kYF!cV&3LH5PGVlKfL5+RYU&5@E%Q&#)R,C'p-VAVEJB$q-MIqTGHXh)
+d(EM@8#UlRrlS)%+EGi3cbhCm)P)C64c%PLFej03(RlPF82*(jICVJ'F*c1UXSE0
+8&9P!JPC[ld*40bE@`rqdXSFlYmid6'`3'c!AZPZ'@U+UAbpPCV+kCDJFa)p0YQf
+$(VSb'bUU@A5Sp[jLGV$2LNKk6m`92JLBFrY[H+CAhEMNc(EZm2UG9`dTQ*)r+""
+K2Jpa*1J``5&S5,mcVdIMQ)"l34m(0Ta4iYAYjT6+*1c9l4l$4c#D'0Yha#!##%(
+2!5RK@'YfkUmQj5--X1AHABXm&TRJCK41c#RQ%+`i-)4Z`"%QFQq6R9h"SY6PeZ1
+DbI8X[T!!fm&k&LhFH&X4A@)iH2j'@Uj[ERP&GZSpqUA4#-U-FI+ZCQ$pda1Xdh[
+hik,-`1b`[l,4`CJBUC%jm(QLhT!!Y3IJQie6DJ(-l1[KB)RMPcGk,Xm%G,ZGFPK
+6`$P[HPSRKJmN'N)IEp)8FLKSJ988rYjqmb6M#I`l#Xcr6HB'0k0aIET25dhMU8-
+UV@0SGE&QXZcGG5cLHMrC!LN4""8XH!5A&f0re2lNA#RhDffm*2!)m4AGC4@*LPq
+!DQNkZ-jpJ2hHZ`+PLeZ(40-04AmU$4akEeLdqVcT@26@+Rb%G,NRFe'#8k*PkM+
+"kYQ`kMX++(p'K#X-EhN1#1MP3eC$44HhIY"4$G)89)qC8)YL60'Mr"m`NMc!Cae
+aV8)M&0)Md4&Cd1V*PMfA*IYLi9bXefVQmcJYNViR%`,BLEZRTX%aF%2DFPU0@h0
+DiZplQPiF)&Ui&iIaQ96U#B![H(h-c)h401XNc-qaC5L-jFIAN!#V%XIb(U0HFFC
+N1X,C$p1hH'hE&m[R3&cj1#cCKAh[9FYV3*pe9IbchTahicYGRB%rHqa5(DQ@-eI
+9$rqYRNp9K))``Yqk"rc1d1q,UCLKJ*P!04RED+`(hp*'kCP24C*1e[@)BZV1k@'
+bX$SL5jP%5(YIFJ)bR%'%(mP'q`kZVTamdR%eH9Ac8ZA5P*eIE"!6$BBkRjS+,$M
+RaH!qTJJ`qq'bNY01Zq#'[IM$T,eGR!Hc5HHf'[N&C91"AZj[lHlEd`++JZ%RBZ3
+Cl[A,6LDE,5LpGf09Aq*UA[FUJefkDqYa-[$JQ&Q14FdMfR3l[mM8THLT[cI8Ij@
+KQYN!$Q`qG2q`klJ[GH&3j1,+AqP-2UZb%)F8STT6Dh9j4#3lL9P0&"INF!"H2rQ
+TAVrESiL'[d&&$jCCFK#j6pchLh8dq)%66`#$TPS,@6$rrfq1JlBj+l-,M151EZY
+5[@48AB9Vh2jMQG2P[#c5DP0br+*@r,mc[aM3#PVJ(K*MKHLJ+P#cIe4PB!#ab#q
+3!0*D@kV"rSeQ5M4IcJpLC&r@mG`,kiH6dRmYkYB+aR",&4AC66R(YK8aBZi-@lL
+Mf+F@2rh3,!Kqdqk`25D2'T,jXJHJYYS$T'(RX$"Ufi,LHGURd#L`,f02Kl"rM*b
+f-d&3(jmkpqmqGTE4d'Nr-[#K`[6XK[lHB*kZQE!k32*B56aYUejF6jA`N8`bB(Y
+'HNkP5D%#4SS%l*!!#EmXUKcBRL8jXp'qFCj`JER`kKk)DG$apmCf6N9,5q3+6FY
+QpIG[e!SNLp&,M4d@A*+k,FphAB-E!EQ4&eMA1j9cdq$QP"&h$JbDmEHeIDm2rj9
+-Dd8UflQ8JIAJ4E3PG4iN`)#V!d)#2j!!3PViSR4PmG$)Y@)Fk)lDl"8N!1a1h[&
+YZhB&5!%a(4%+CVMYRlA8fYp1IhKSHR5&`-`*12(aAmA5#(&RAX%Jq8NPXm2K[[l
+NDDbaSm"Y)@&rac+f8)mGSiM4*k&5@AC3C(e!kc$2$)j-kb1f!kN0+Tq6UbQ6lAm
+BQEa&1MeAVcRRSHSaSUhURFN[J8KRC$(b6QV6322pb$II'P#3!,M[bd+3!2XV9Fd
+VIRU'5YE'$#YTpDArV!ZJ$lQ8E$"4TK4"1E+hdAbBaR%`UAGU2k*BN!$'T,M#6)i
+XkmIMllFC!cqJ4qC(%r9k46C%eaRhjqIld3V1)99h!r#Q,qfR$f`TXc0ZSXP$(mh
+hX2a@39LGrHIX+l8FIj[`[*mkHM!+2HQjZKLcYif@T9k9&SIC5rkZ`qGQEN)mT+$
+0Yl58j1FZ2TQ[NSB*9B$!GY&a-*A@-mY)2B*iKF-REQ,bj`BG*j9r#p`b&(NZ2bT
+Bl`[TL52KME9VjdUJGe@ZQTcP#+I!U3VQd1e'Zc+5b`4jJ*4&K,DZ[22ff44qBKa
+"bqR%crp!#!DXaHCL55Z4[bpIKJL&h`e01ilhBekr)VTGFD82T9-%8*aiM*!!8Qf
+rKqLEf#e8Y,*eJ+dG6h`T#JI5F0S''[6XXd-#m91Tc5PTq9)mCC0bH(&QTiJJ`ES
+H(5b$9F'!M%CF5!(DdPf)SHmDa(lPMCVi6"#N8UKq21bEi)TkfhpL%#%S,Rk'(GH
+m*T!!U"0U)a[)eNhqlG0-Ib,!,E4F'0lY#pp[QQI,a#QbrqdVXa-Vi(K'LY6ed(K
++0F#jMIGFchMKki)1QcL#@S3$0N(&j3Y$[jHHDY-r$4LD"bhZSXQNd+mdP"4[*dq
+8@H#Db3K!)dX[)&5+Ap#4FK4q%D4[X(5B-5SZSB32p0QBdr@G2KE81Yal[l1MK"Y
+%bKpqe3k$p#QJ,afm2NFa&5m2J0e'p&ErL[eQ4,UY'`VMG1K'ljQV$*iIm$d[NEY
+IrNHbN9('"1XHQl(Ma1'jQHVbX3%%3D,E'E4L)pH$I5U@5-RT2Ih)'I2,hE9Q9bM
+3B"Y*qB%`q5S4CX*RbS[qMQf12A@H9@&q&ehRY#dG-eVDb1!2RV%UU5Q0GbhX"`&
+!G!,CfU&C%c&J524Fr3#qL(0KZ4TI)'+9lk5XUL4"&KGCY!qJL-DR5YKSA*CD&)X
+X2k'%REeCAcN1'Rf*fflFB51%)E$Epi2aebXPXD*b&1B9b+0eH$)-+qMh1UiGB4p
+&@1Mk@a3p!JDjT`KD!hZEM+ADZibZ&HZKS[QE!)Dl6-(*E1kBJQ6pdDKK&N@Li#e
+8#qrPB5Hk&P$KM[,`5JciHq$GRZhBPq)pYbi)BMhI3VI5$N0ZX!#pY#@NieL"PK8
+i$G+FErR,'"cq%q(e0))@1khBjJVN@GrT2VmHHhNk(LkZ,'I@8KX+d'k*SLRTX5H
+-51(02X@#$`@`Gf[%Hf1@Ab%1GK2NdT-R,"FKM0*cY)4c$%[,%GhL-fceab$lHe$
+$mCFIET'NCG9i!JEI+Lj&Ph1&PJIIkPBN3U`#38(*#`2Xb8m*#j)GpYim"JK`p)`
+P6II2*$#U0cd%qQT!'EUXFDZGVdfCS2Ne+YEjGB!6+3B`FUEj$kJp)@IL6Uf5'd%
+*3E-+3`5-+jDPbFEPTNjer'p4m02Jp(Up'@,4kS(-l!L(lM`3$"f()i&m3l8LbDV
+"Q%k$2d5faP*&HK#RDf@dK$B(U@!$pV%EkDqc)cR2,%$T-XGEjRhqPFLP3,+"Fc#
+,q`B,faL+@)h6-FP"h4#,UVD@KT)Y64Fpb+p)EDF4%j+'-4-a918Cem9,H*lrfPM
+6#e82bG*ND5HddJaIcE*IA1DmjD%U8A#Y"'A0kJN#m43U[%GVii%K@)8DEhB`EmY
+YJr%,9YXkCDLkaV+cP9(rj8@K*Q'&MS`J9rHmC(a*pF$"Rr1E"l'Ra+e19&EHf4$
+qV,(YacZkD(PSR1)UqeiY6hM"jM%,GbfdBQ!$V("+5F)D+d)(qeJLC%)IcdTm*`&
+ZRbU,MCMTjHQ+4T[Ebl0J0jPUm,$KlE"pLp*d&$*%RVESiFqGfK'Q!iS2XjliFre
+k5eChe80b4K2qm&aSD,k`(Ca5#b5,5$(5VjC60Z#GJ@d&kZ@6pcMAf*`8V)L1&"T
+Sh2HpRTK8fBMrjFBp[16US!lh48A1+%%JE,re*C1jlMU!9%`NdR5H+-P#'J`Zm%8
+%md&pKGUJ0Jp(ZqfHfE&BCKDYTV&"QTCLJrLG!Aa9i#Pq3%SeRk50Jcj9C@#GmlE
+DRhhdDI*&AjPlBe8dEr26`6@DrUMU[MU@a"+A1KT6'qrf+Q55N!"39G1+,f"#NbK
+iNiV6Pe"2qF2T@J0k5#ZG",*ML#$P%pBTXJ,!Jj)#MSQb63qShN#i8PUIfQ5YXP2
+L40[R0lZl1$PD3eDEPi)IQRNN-BUj[+VQGU+8D1E*3LdpQRA6N!#2LFDKZDTC#2U
+qle!TpMr`ID(F04aR-AS'0k4NLc8(QcrZLCN&UR@DbFrL-!G-26(0ZMH9-56V6JI
+0,ha6A2[,PDeQ[hN"LV20prGre)8LB*k-2XR44Sl*f2@3!&)q`'j,-1$ALCN+J6Q
+[MNb$[XE@a!&iT5j8F%5Z&QHH2Rp)49HrY,@3!%&r1jR#)@km8eBp@f(99VPG+Z6
+$F2+S0@@c'lEU"NlprRbk)Rrm'4j,kDbkYPZaL$dPYDm%!iZ-%i%%@Hjj9,QXrjP
+LQ!2!3(2XEEJ"P`YBb!,U[+m2b@+q0A9@MVRR-di'i[VTTU`NfQ3e!0iG&b2A@J1
+JBPjqY9,,B&(+VPebark"kf(H!NmX4Y&laGRL3[Yp5K85['6[MMU-j4d[ZpR)i!D
+9F8R[4i)%ZHDJDQbpl"Bm"VN%p5CUSl3Q3PCDrK5*pAm+EA(Gcf5[CIajRbrF#j2
+J4QSqL%J%H@`AUb"4I3FfCG-'"K8LN!"9UA*HiGKl,HNQ`L"E,!QUqYqi,3k)29%
+`2faK6DMh3H6HAC!!L9YJKZEM)'1AbH[CPK$djJU69A8E3!MD!mZPPdCUPZj#$[6
+*blpF*f&bT,H,a[`&3B)*FS('fSRKl3Ifm1fmj[,*N!#6qkpK#8h!eA%Mh0kfq$S
+qS!pj'P&P44b!J[pM529[jXQ@VUkck[!4&6TJ[FcaTaK1D1"PVR`-0N@4BM2T9*H
+Ip0-QPHc6kD!VRNEhVXeZdUH+@EF'!NH%[&aeG96paXmLL'D@"4FkH,N+hUrX$8Q
+"AYLJ)B#eBcm9[%C!a$Tfa&bUq-*[V$D*T9%4#MdrR6GK!1Ujqdpf05Ad#(S%5F1
+I'iem%QhN33D1NHB0HmPK46CX+4)Y3rlGKMfDeE8%U$(`YJG!1rP01MJ+HNT(b(f
+Z)!8fkjPil"6CdQ4G+m5!m#RLX$-2##cP(#b'SL&bIFhG-E'p*c1FI-qAJ8Aa"5Z
+RG!+l$CAiX9jHYXCS[8m*J%&dBL1MIkRpLPfCSSKhq2p)B)*PM!%G(l-MZm2DIRi
+ADa,q-RURQ%'[UI8VYQQcXTHJ!pbhF&N51,"63kR&hKhY%AaKI#p)4A&@@1%EMiG
+AKp8q2d(&h5'XpkQM8,Qb#l,dK0D+M8,(ph3-"R[D8',j@i2PhFAkjLk42XlhJUJ
+ZcJBJ4(-PLPdcVM,4jMYUI,QaM2DT3$HSe#VP*L$%&EfI6DdM`'-!X-%ZB&)m(SV
+lqE`Rerm2U[YmF#'1m,[VV3m4phTdIN(FlYjV8IiVadIJVX-NY#YMYc*4p3V`#Jb
+",Af,%UYLhC!!J8J',VIKi#8L33k+5jER51C21*(kQq1F&4-c-&hV)RUTQf,'GIl
+5QXA3VIcNdGV'VR!h+@3Fj6Y4#IU@eY(ljjXK(rF#ZDQdV#NR&m4T#QDQSD@AlAT
+GpA(R6)NRIJMRe9Y%-19F(R61Z)iT,kjm'+IIHMqAY%4Ecmrb6iELHT36#UX#RB+
+r)A[#q!-5bL9+D*%EJ%beJjR!c3D@c4Ec4cH3!1`@$5+VN`MEJ0b5[SRK9DmH2Na
+$mk)h2aj1Nr#LpE3&T"#UV&aY&&6)h+kPCi-'%Z6,&rTk1840[*k(GCC3XXQ*TJc
+m@2`Rq)kLB1IK2Q2BF*(6@EpPMfbM`Uk9)(PQM*UGDU)Me%DZ@e[8(*LK3Ffflc$
+AL')9HVNclcHT&IGlMj5`Vbkh$B2L#Ie(0%S*JXlMjNKNbk5leR$M*`m0,,*Vm4Z
+R-b&P"L2lleiBZfEID5PDM$r'cRp3bbGJZfcBB9V&L3Fq[%(jbljIklma10TiK5C
+E&!lR`A"5C0"%l6d1I`i-MB`RU!C!fX'N$m&paMQ`"4eb&4FqJK(p+5C2T-L,C1!
+@)C*Qcmm0Ue$Q%Cc`Z%peU@LIkPFPi5P"X([V)QBjNXPmHl(#lcDYlV[RR+0)8p6
+l&CF6UmmcZ+N'IKi#*"GUjqDNb0+256FX`&(SNpq@#Z*6-b%UUqNRc"![#8G,bkD
+[ET%pLK-aj5[q4,G!NNLA6bPJ[Y+TQ[T$aCATdU[lb,5+LNaXDH4EYHJUiE$JGdZ
+4fjmYr"8BlL6U(Jj1$,24MFS#,9@CZ-cGG!-j+LE-Xd*rJ-rN#Cajd$)j3iJUhVL
+KkmfG01Qi0XJc8R#9h[*)mU-bJ&q)hY21E0Z(Lj,G-I0GV`!Kq58Rb(4)rDMbLZE
+$f5l4+5BCfq52X4Fb*8aiQG9SlAr(6ZfPF106M2I'(RL-5M9efb@dkq1TR,Vbkp8
+-2+clC'd8S(&M@88PD#UfN!"MEh2-h"`6'#'b4bYQpGMiJ9d2NcKj$%c&R!AKp2*
+&Ah4%XVH%530IiIPe(5kF0e9U`&Z#PQramhqA'fK6[![YkU53!0Zq20@*K192S4!
+!Ul,,"U*"S@3S4@CDQL5*DBd,TNdKrkYbR#YEYG&)H-"@[p`KJ@%3Bpbj9'*@3(G
+I,Qhl,@m4&5lTK&iATJrYTT[m)$'C(i,$9e8bfU+`H1,B8Fm5GU,P+@K5cEUa4+B
+IfjPAURrYj+Li)@'He8djHi#JAML3!13"5IFAYipJ3Vlm!BQ8+kJmi!FCP8bcac!
+&C9`I9jje9QqYdBlESSd(*,DPfP0[hVeaF6+8f,%L'Ti!C[3iD-j%'MY"XNA(%eE
+cE,@"Tr2aHe*fSNX)AiRr*i8GUhf(BNETT[M'9M&6QLQNbXUNVipi)*(5kRfG(lG
+)*2f0["f3!+Gc[3*V4`jP2F4eAQZ6i`ET"(Y6HqIhrXhZ6Z-`m,H"@rp+qKj-m'8
+M"9!"Z92fB*82[SilpJh8'[A5H)E'V`,&V&%2FM4U%h3aMhKl``RGXkY4$%K%NPT
+"pBdmQ)-k9i!e$6kX&1L0liRr"KC-eqBmK`rFR0a+AdK0FmE-'Dp!B#baLqE#pXi
+,[KP!1NH[D1Bl+D'(hXcD'$ma&Q`IlI%(%'DmLb2S0(i64haim[6Gh"p""[4rN4B
+8RVXG'(ASD$hXL5jPLjTeS+0+0c-V3MCD(`D*VXb%r-ADl!q65Pm`DG@d`e)@+m9
+Qk1ZY6F"RZ0rNZJddU!qG"fJKTmU[9(0aDVMB#rQCGjj*%"@NeaKhdEiF"$'AKIE
+j"X4EKj21$[$QlHD-Mi8lLp@,i[QM6,chUrP4He4V-fH`NLQXh)2([Fe*2Ge93B#
+SXJp9`IB,UhH'!PMcFBX6cDfEH"FL'kN)TrEM$,e0SNjb235-8qlPkIfVGAd$E4[
+1$p[Ep%H'4dZ$qGhp*R9bc3NSXqZbQA2GP`mar2GNEZ!Tl,5p3c!,J%0@TI"Ikq*
+e8XkZBS[f`lcP!4(0I+NSE1*dZV30KbQJMb`PBClmqr*NdFHk@N3J"j'%aKHaY-Q
+HG[$6ENVT*fkmYiZ#Mf(b$3iri6"RILKHEj!!'DbLK9Zmq5Jk%`'cQ85NEmU4TF5
+)ii,Bcd1I"L,8k8H!KXH3!!LYER)`iRB'Xj8FH00T"!b!rXJP!"#TUlqeDUMNp*T
+Raa`r8%aSe34qNeN[8Haji!Z04ZPpfDU@aY'-PM@H9lRbhXjK)2c-)4pNKc22pf[
+(Q1Y4dP,,[Q32%fX&39NdDY,LVRFbAV"'J*jmU"Uk"8JlcU1kkrMUXrkjr2NikLL
+!V$hJc"dMh*`k-bFVT,N1l9Dk[1!PNDGS68GiU2AeURTjVE1EliK1qA6S['-iI0Z
+FLCI-VL[9KhmRE@D$qDa%+%r"V&2@ICA6iSHi4KY8iY3+1T5"Tq1Fa-JXXjIF,)I
+%"IjH$'X(%lT(&ZQ@[5'Ff2HY-jiZe1FeG*pAXJ[-MXFPJ9*MQ5BcDj@#PJjj#%T
+4`kkH%E-lJa,5h"Q!N!#Ff2"K6X4%43%+1*9iQ2I1G5k@CCj5QQdc8dbm+&-5bSS
+%dRYa5Q'1m6pTrc#X&#DeRLU5+H#rJrKFfT45r3@)iNKKdA"Yq+*0lr5N8epI`Hh
+j0(KQdCmTFSaTlm)qM%%3RG,q2DQMaj''mk*69&mjS(9ZiN6)9ehM,cjSSH1e1$U
+&V-MGfEi9qd&kC0Ue33[R)8'XT1cR)SAJmlqZSQT[p9R6JpN5+LfG2bSdqUlr00M
+V(M22B4Gr(536EchB1(["V4djGZQb6D-4XreA$h2CZ-q`i%TFr)lQJ%I4k-"9'dH
+N")LikN`[[rcXH30AV`)$3TSR8bQ8YB9pFUM2#rh+XdILkCK+,U"QCA8c)@3Q4$4
+iphckJe0GFd[hYq),l8KY1I*(Q*baIdMb5ed(PYd%H8ZTA9FJDVkE`80C'k'lr'2
+)8XJp)N#+L63G&e"G@r3%%(rIHCLGAI+3!)2-Q["b3hYT9UJCPaUXIJBGaYbZ6I+
+,cL#P4[Pmk,60++8Z)N$`Q[qme46P+)QU5$k&6I`DPq,2'#Z02kB#LT+U)I,cqC)
+EbMrF23qAPB0(Tf`QLa+)@(-TpY&$U4`GRM'hdQI@HPe-j8VZ8piB'&9Z5Yf0hS9
+EDX9Fh$5*P%)TkqSQ0FNBBpQ&,(&41(4IRI9A8iJq5hK+0Gk-0'LpE)SS%FYhL%*
+5#[B'jbaAh(R,GQbYJ%b1KjJTbc"'j'K%Q",im,MG*3!8I2pGil$IlPEkjR4&%DR
+"qIf,Z%b2(*S1%ep%ACj0Hb*b%4P13(NrDaN%fh!&T#VCL`Q20,d8#8cb"j)pY$K
+ff)X2`"6&rH9[CpY4k+5B`Vq1qaAFkM@k58R$BQqJF$5eFVY[ZaTM+`[(l`(b"*+
+,lY%CV&LD-a8EdK0!)JF@pPIS@[9PrIdI5,Mq48ANQYbRm(r4[%AZjcbk,A6%+A-
+GP3"a8k-6'"r9jmFh,+Z9eP+1lZX#ST0X4Ai8B6m3TrCG"qSk$&XahJr[&qj*MAT
+LpEbp4Q5C8&)jD-ZNX+Vrmc3`6YIcMB2D2U*kbf,H'Q'p++&(IAG`J[!04f5lEQN
+8Z'U9,"fE%mJr([ZeRfICH#,(3%-'A`r#HE"[ch-*%(Y2l2eSIYXQ3LamJ)[K5Ld
+3H4GC-C)q)[&G5bfi'f5c%XcD%k$N)cF39"B,E$ha%*,@'Akhfj,4d4P'a`RBSUL
+e@8+94pe3'da*P!8L95PH!imkGG#@Xl[2U&62aJ2Pfq[+,fYEdqU2(EZ1!3`'*Hm
+U@(@%[ZDf#KddEE+Rc`JSj2k-EmTZ+A3D4aHHU[L#'h8*E5GrVYaJA%@TR,6'MUB
+@&0&*I1fklG$FZ64DJd9V0#`!rD@I3A+VMVe)%L6EXSZ-5Nem5V'V&02brjl-SKC
+AK@JH-%0N2Q4!Gm6#m8"be@Ibi1hDaCr,N9Gf(T!!ddcHqc@'+5XKdH!mQmG#qY9
+cp3Lp0l9LQR3A*QY0fjNS8DQ5K'5"2br0eUK93`ARDeEfFbl!V2&(CC50[-'PXi*
+Kc%L'NDc(0HB)%,pf0G*1qNb#3&bDY%-r-HKJAr[DYhKkI%KHL&JTdrjm5!djHGE
+39ChikHqNUpjK8+"fGGRr"C5Q!TJKLbdL33*IVq3k-#MY54(5Zhl`bF$ki9kaDcP
+4dHA-XahKCrQ-m)VNV`!$@@l*GX9Y(N8iUi1Yq3b&eNB6P@c%-,%h)6iV([p3"9N
+`iDF)-CLHFcdJr!"X*NcC3$X$RjQYSXP-EDKm`biEUAEGDc2[fKd%C`SK@QiUb62
+iCZHqDIJe85!hEqMF+(EAqKBd+[*34kV&FCF9-`H&#d0aNYK1'0Ic`L3K%lAIFJS
+ae#i#FC)p5UD"Rl4c8RG"[94PcJlPNr+FlB8lU!1)$Kjk`0ASeDUQV#`Z%faK[6G
+FhMY-2kLa31d68"295YI+(3eFm+kla4f4PR+G"NGARfE+DZ8)%VG"6pkl%D-U93Y
+(fp9lHrdkU5qbX,)hGVAp8mFa%`Nl6&mZ&"GCQjU'Fpe3R%(p8FK)`*!![V2m'@M
+hB`62!4@Ef3VT)LBU(k(3bTR&kdr0GD3#"N@d8'*!CpLeX%#,h("DJB[Fl*Xfm'1
+QGR@LDVS,&lqTHVm@L)"hbljKdbc"q@dHIB4TE&Va41YIfS'IlN5h,fh9!VX4Qj!
+!Pj@Kb@XJrDeaUqrI$`m[iR,X!MB,`GY,*fE5%&,1lXE3XCiVBYk9CHf0Y(K--(!
++jpNS+i-!Sj!!QE-fV"[QCZ!4N9hZHp@9lF5kM9Fi(#0Mkk4V-HaUGNeKC@E(%fB
++,#qN'A-@CD5$4!Kk'KE9AHliJ4`Q,0mZa*pAUJCCk2rK6PRFkI+5`9V@!%J#r'%
+CFCYf!BK2JRK'(qJ*`RMXB95JMh(KdPbRBSr28Ch[6bX&E$%p9cNMCbP)GqVC'4l
+IpQ&j*MfA'mhl56Fk@A8T3LiXRr4Uf4GVRZ,''fAThCU)1P`6(V3A@d8%40Z8PX1
+%"LI9P!D#(&CG`a',ZC',M'6BchY@@1*2mIQKL`l"[MX`&!k"E9$5B+mDHSDrm*q
+SRCSEY-AQ-d'Y,+FfhpVjLG-`kL3BD(J55C*5QHZd8D"AL8B-3mN1"(!&P($LA2I
+X+%dRp3lX[A)#!"@+C$%Y5Z@,HJk[YDpqTpEmElBD[$K$9k'Zq`UJ,25h5'QTDq`
+KHNbfDk53!0&%8[31AV36,rUV#Q25ipBc*IN`U`NmkiiL3'EDm'X4A%#-`T4K$Kj
+i[l&i$+TNq4(ZfVA!'16,8A#"F%MYj2RkTEUpD1kMf[I,99-Jb3pN'KXGfYY4K4I
+Ie&'LcFD4Y)C#3"5(L8+4bXDKirhSiFE*K&R&L'`bLcKYJbqkIF&ISBRX,mBHL5`
+*F&31RhCU%%SV9#KY64ip9T+$iCQFkUKeVCm"J56q+CV%1cE(NYNj+$r!fY14eAR
+4U4URI81Dr1ZCDrh+4$3p#@'UJq2GV'0&"T!!iH6b6M8HPSX0$`(Ua`34+[h,Sm*
+1p00Y3j0)#PaAqEMKhiTpZeIp,%Xe4D'0li(&eGV!LpJ4F'Gh,,X@!6$#'APrF)f
+lE&IU#$(1[(r939`mGYU$XprJ6%1QBr"Jf9pKTeQVJ%Cb@JQ54Rd&`bRSLqQ-fHV
+e-PP`*C!!&N`ea"fF4XrBm@b#b2IdA+`"D,l"J$-"%Y%3R3%[$jP&H!5EL8`8I&U
+D!r*bmkT5FE!HJ4q-8V2PiTfjQ-C1C+9!ibmM1K*pC[hch4IiK"G!QE1-81GAb)(
+&"3d2M+lTblDLI&d`%l'+!K4c$XQ)JehEpmh8Z#b&6a5ApQ3AAFBj,'(1E2@$I#+
+V-&EEq2*AF'b%ZBq-1r6!QFpRU`*HLQ20kDUAd@iQjQ3d[rBUhUDZiPI'YVL@pp6
+MU(cbcCmD%0(2RjFI*!X&4JRkd)&H!d)T8jYE-&H3!,mm$e93Zj@HkCHK,)"RHAV
+P-8cTj5N(920BFNS,l!r5FBHPY8[6CYT,l04ap!PAjAP#ArU$fDbS3SG+YBkNe)&
+&MeBBj*aj)D6*'G'`"ie-d"R*$MU6D,D"CA[1L#Qp0Y)aNET)HfJl1DrJj-k%SZ'
+8jIYYm9*T#R,e+V)m)b"qp*-0lCV[+D6fG6KmDKiGAk4%m0YPS$2U92LYlK[G'4Z
+fCQ2r@4l2#M2a66JJUAjS+K66#8G3Z1r(H4(h`GMEK(mEFKLf4CrL9[i&kFiN1fk
+BF&im)lT4R+Sqh*ZmTSKFSjXFG0"6Zb%FYl'X(VU@Dh9aR85V6GR+DGI%c2p@QR8
+RdKNr-Ma2p8ZbMl,M,)#eZ*a,0BZkJ"BbNhEA6YF9XrAKecbec$K3J2BkIl3iQhi
+dMhQjlqi)TTqJleIeRe,RpL#-6I[b-)iNQBZMqeY6*d'aqlhV,Q@,32j4@YF$3,3
+K9m6@91B0XTUJR!BAkBrBdafZjr'"rCcPK'&dSS-RjU*8M$'XrYlV!)fpES`2!VF
+qjNjp81YNc*,f5bm)DD@mPKrZ)H*3iPYD4mh4b1-#l6X`Nb`0Y,(BSmpAmA%1qqh
+V--dflJdaiiiqFl2flGIH!KC%DdD,a%$a"2j9Z+e2M'@6`JNIE#pd0m%#Rr-iaYl
+%)a$U30J[kbYlTqZ*[&d$lG!b%M4$p1YJrbcTNB"E@P5U*kN1l@-Zl-0UhQ&@%cd
+0X'[YH5V#%XD)U3jFNfR9Y!@')ilMQ@X,d@rKZVfKf9KLbpl&1T&EE-r6cReIiK-
+50qm'#DjP1b5Bc'mk8BE2fc2DIk9`l[,BT"'AiIlqU2&a#eMiV,9b[L88Rb*lIbf
+fDTj+*ri#a,-[qK`9%ZC&f''[#pGE$a3*jT`h*Hmq`eP%J!D-5l'FUUJ$jSXaF',
+ASqhV!84TiSClLc&AKZVc82MJ*FBAHq)kKIQj8R4YV@M%1-PJ8h2S)*EcEk-[f!l
+%qP1(23N69jrh)qjj#K58Q+c86`V",m@YU'iC*Q!hJV4Gq`YNFFjcf4JkF3EZYEA
+Ci1Q[&VPaBVF''fZb(SMi5QVjlPVXN!#bcSa`'99IL,6ld5Z0chk`UEp9la0Sb$N
+VDa3p#9(Dm8QHA$D'&(TL(`mD*CFb[PNePc1Ii8B0C(@+6)Z4b+F`0ZMHdCek'!@
+@jL92-V`(IVX@$fS&i8)cNE2G'H&G`0mBK&J$&R3YVBqUeaE(NS2iYiV,MJHIcL$
+eUTDVdrj9Gk9K$&ffI1ik#ZalRkBTfS0#[l9QYP,X@kdDQ0YqJR-I9MNa8fXrP*3
+ZjFHe#[U9EJ!8D!!`%b+jl`-Q+8)jq`X44UP0SQD6fHABRA@Md`LPX5LQ"Hh`XN!
+EXM(q'R6mm3J%RI6m%`#UTl9(cRG($$1%*GB3FE,&1cTCPq!N5G*+kqkJ!`KM4kf
+-a$J9"#6BMjbJ8aZi"FBN"X&,!!)imi!jP@2P9icpf19Q"qc2rPFiL,L!'1qelP$
++`YYVpI1CiGlCjSqB+M630(p,9CGU[NS&3$Y8d9"NVbG'qLlil8#SdE8X#5FZNRA
+30)YU*#hiAk*"ae&Rl0M%Q9C*HF1f9HN)ZdBpLE3!F-`,R9m6IK@@$5PB`$Y5VIq
+10")[i4%5YJr0QL#H#Y5$Aa,@km*B2dAf88Ue5c+al49eMI(Ab-F$,YS@aha)D5h
+SDh&8QQ$`"8-0MAqLd"F[rX-*"2i5E*r'Ea3&%D"1(q'M#42S[Cf1bINXah@f[hR
+4pEe32Q(38%NVJ!ZBRHSQ'N'mEp)"@USBY2BN04*b$&QFVa3H9RAjdpbdMmhUFDZ
+-Am#0elbKHaSk#CNVSG+Q3mflfV4a1,eq(V)S"R5R#2@ZppUSDH%2K0qTQ+N-TM-
+32Q@'Nf$lB$eX#9cSX'P`5G'[DQ0Yp(kk8(&C5RQ%a85',0(!F2adCblp$'D2'68
+&kFLX`Ra2qLdBFf%)iIr#lXMTS3LK@j[HB4k"5Q[1Pbr!rR@"JPm#9AB2BN1aCKR
+URUMkV@&1j!LP@R(AC*mGjl-)#hdGD%N6J@*LcZr')aC(Tq1'124XAUHMTRAMm6@
+*%N,!5TEEDG5rMR8ZlU@Z,#NRU6(1lERY1`0529f'hC0B3FJ%hbD-ZfIjA4ZijiR
+,a`kNpbmi)8rFcrY(p$TI-a6dEq2FJ!+DfSC#Ue*YZjpSKqCBAL$LQ-rVCEXN*q3
+Yf&FFNj!!%1`[U6B@#VXLlR,Ej%iMejP@0AI[`N(#Fci)ZrK`XicUpf&hjA#*YJ5
+d")%[2*c$I+Q(j4Jm#qL4J%QBcf9C*@MkIrRHMbPP+IQmC*aR)XdX6LD1L'%*HIm
+!U[F2Ip"C#)')bi6%T!L1,F"$JQ2+!J@@(UYj$G,,6TpSqaN'V4%Dd[PX$S6Z+22
+kb6r52!"+kk`8'AT@lSJr25+m9*KF9MBVm,0!m+10X$mRf#RI'b0Ap)*8D&(!VmB
+c+'-@HH12UGU)SL!MR$l#+`B4#LHr+19[k5$RAiY!mLb*6[N#`UP90h'TaE9#r*9
+Q@HAL*8RT%j&l"4jVEV31-UG!r'm[eeQH8dA2-Phe$KK1[Z!aQNRT#Z0jf!,'qCE
+D!P,4XlDeh`p!H+M0bC`"G#Vab4GVap-&IFRF6TPrS$PRX``-RaYpaF!,bE#KCTq
+b@r&b+Ai9QS24RjLaRP4Q!S[,3RF)!VX61)[5*J!N[l8eHM$X#FCYbZJ1cJ30D9(
+U*qT8(r%0R9)5C$,@L[Hq1DL5*l6YfIN6kF6@2IlX"B1)'iU&1@Tc'$($&Zb0RL3
+)64KfBf)KhT@3!,BXQe*rpb1J'A[+"+8mdfBdbZY"NC8lM[-Tcj`jkFSf"Nrbp(-
+%JaibpZqX"*'AQB[0eZ)h*RUpXRJVHeQp#"fiYflKV2TB@PGr5Gh'XQbpT@0qUU$
+Ba[JARE9ib@X@`A16Y$IFp9Y4pd$)deH1Q-fP@-%k)&@)LC0S3,QrMRAGMh&ICEL
+H`8S[-Ke(&`PXQ2mVCN*J5mkK)6&fXJjbRDhTNbqQiZR9,AK%$ZbLTGG9%ibG4IE
+5m2lmb6feUqaQ2h!iN!"e'crJVZ"hhL&fVpP8fJ!N0&aHQJm6GUrF9Z,erD,IF"(
+#9UF[(T*#KVFDb9lN3M"qXK2`62$lGMEJ[mMmqQF[Y-+!m[+8X2N#N!"A@a4ErCT
+$C52%PE#*DK#&)+"RGX`rS3bMjA@Kd8i5#bFMXQ*+G!L3!1aAXH"`rSl!eUJCMa*
+SD+,AHS0!L(U'Z&&!)mkZd%pM!5"e`'BD%j4(&L0UHbSV6G-HTh$LN!$ek2)eBq+
+XDN,TD1GejG+NEXbB2pRl36@PKX,e"-FJhQdeM&MFfP"E01QdR&b&4(J[4#R104A
+[jMj1,Flc))"-1H2&2CSHlMp&CZ'R52NQcmSEdM2f3kY*qNT,aEb0q'#G2(rK!6B
+G9qEA'`+q@eb3!#C+HFpmeYPEafC"XD&hcS9DP4#SQeU3!"JmQ%Ac,J9,'fHk%(9
+biJPi)d*#H6Rdhj'pb9Eb8CSDfE-rBGIP2DXYpb-&AAUYlPrd$@Mkbd5EfHS'k)p
+Tc*5LmhCI6-a+"Yh$0L*d4ch$P1FCX49PbTQH#I`ImmE%kaRd*j1EPjDR+T-EeB4
+bD&[iB*PVXjZNaTHc[Vp8a$P1mF#Eq@XJeMFM14&U+`F@2UhmF"kV8[A86l%kDk6
+PlNP&f,)adL2(9f9Ih3PfprBE(6JaRXq1&08YrRa0%TiYl0hhQ!pKQ`iV1m3N"'[
+LZ(9m#DRREipX&#+Mm8&S5dD!BdZ3!!4lAPS%b+V8ViZ##FjNTMhfF!fbkdBE`2(
+VEPER'ml,#kTM&Jq@L,'#GJj#bB1UXAL"bKdH&CqV-Z,#4G$-1,kHA3JA["UmkU0
+!Rqq%,!@*jJk@8$[Srq*Blq&[jeHaD$lj$fU5l-d5&XQPGXi)Ralb$AC`jCFYJX0
+F'`mmaI@ZF*-GjT4VETpM4h&YPZVfSH$KdfP&$Ze3qCbcZjml[[e500d6R$1H66S
+qRD#[5UAj9'XIYaFe&PCRi$B5N[`9MXB!CI($`4cCd'Kk6*6)bCJ-3kIVpUqJD0P
+6*)MB[XrFidIN8!(*+[lIT%)iT(d,UaE'6iEaq@UZqV0e'H+KTC5IINS[iTV[UXi
+$#Ip5d30X%1r&bXrK9S1N"2Ef0c51EQKRU8I!S5TThK'DUb9*VkTPh"D@$ITe)kB
+U6kbd-f@3!+U,![Cri[Dcae(ic4eM`9RCrcV@P@XGh&9l'Q6Ad%bPI-MGGRd!6Dp
+fd)Q3!0#i!p[kqVD`&CaMD-qmVTfU0@9NMB`D,@"ihJ!GH1efhDV-&"`Jejq-888
+%ja(iNEb-m4*jG1Pf6JDT$iC4,Dmh[!36*3#erNU3!"5%k0E9b,h0M55DaE(LTSr
+rXbd9SlipHj-3+Y-YD3G44(eFVJBZXU2fD"'c(!3k"4h+G%X@P#5c"&e4e0X[1r'
+0fbGNe*5@0FBPrQa+E)2@m[5QeC[FK(@kSNX8IU3m0V1T,de+lV!KH$5"j6prCJ9
+SQdhcU0Y#)(MHL[aNJa0U**,-0MD[mjm['XB[J2jP0a%%TK0!&haVi)0CB(@j*NF
+#h4NGPF3(%S41-M+1bjUdV85Yk2q3!%JEcMLi$B3,YhqIC"S2bNb+V2HA9!E)QQT
+LHDV@4L1"Ec)pD6G"c0c'jBjXc-fa)C-UHL!YM[(m#ahjZB1+5pe+U5GlPCd3i4Q
+4he-JGlm1PN4-BQLh1S2Ii1YUpb`HG"d!l1q96iZ812GE&"CJq0bkD[rdmX5ZEX[
+4VLqj%lp9XJe8S)`[j!r,0+dXP+6Nk+4&h)34H,@&,bXeD"22Y#X-3aqQ"qdr[Z8
+L*l`D[3-5e%DKjVmFqH+1c4R%PVCMd2fGp&%M#k!kfljhU3YJPNA1JHir8)M%Z,,
+I"SZLN!!5hQ2S*,4a,K&"-,a#j+0Y5#YH%4UAa',9M$Q,mUf[`8bHhHrX!"XJe4B
+6Bi-D#,AD$cdD6"D-T4JK6[!ZVkPf"jMN'%l%JiN1!6b0M6-%S1l(eAhr6HrK*QQ
+MdM*UFdMl(kDH(hBbSF[P5bD!TbIcmqjYjdB"A6BFP+,[ek@)Pd,K@N1rEPUie`D
+)0`hIXe60INmG$#lUp-)10IR+IJbVfq9&T$G$$N"Gf@R$BDG-!BG"@PG1fD9ULJa
+N%#iPF$UT[9#*`Yq8D,qGCG1"i(8ME"d+,LDTk)%'kHem5aqlRap)H2`##24$dRJ
+PX)D*NI-G1dbTP4fN5N,P18%V)2qp)A8fk+30"Sa(Mk)i1eJjeT'UhX2CYrmrZ&#
+khl$`"*9B#fp-2`KXc2H$i-1'U5JLaa(!(#f1UV[$&C!!@Rr%mVV2,IcP1qrMPAE
+#+4Z!XmSVbC&YUp44RGKD1[3M+[GPphX#iAj!-U(a942q&%jN#0`SkY,E[rX13+Z
+QJ+fMVY!AcX[q`dFB!ErEQ[d5@Qf$kIIbdLd*HS&,r1b9hk"6HUI&(f$H81"M$+m
+eUS*Mq4aa1!-HThrb*00+q"T@Gb22RDC9peZH+m1LlSfqlbh4Qd+[e)@hpTaPLTm
+Yi0R)LRe$r2L$EIciZhJc1(2LPi&epNhRj3fEHI%3+l0H+UUPYT8'cdk0Em9qKc9
+bL%,pId@E@+@UiDr!6I$F3qc+@-%0qcDLVcb6VqLh98*N52eR%TJF5J(4Qid`8[B
+-Km-hJ31BRI$8T*Yhp'k#'$`2IKa8a)2TSMJ!QMGK&V,#0RY[Z8J0hek'lH5Y(h$
+[4`K6511lHM'!%$Kp[chir!c0D%`l'TV0c$8l"ZH-'M5d2Y-@@RRma+JLU8EPA#i
+#N4AG%Q5eFdS1H4NU#&QrLL4pCC,JQYD5hfl3#"l`p-8mTdcNVlZ-98e$PBbP!PC
+rF12k4rjSH#%dF13rm(+Z1BDarN5rrpSXeAV5XNKTC+X+UBKVBH,*p8#00"QV5N,
+F1*P$'RQEhKp%6m[I)+PUC(Nc['2LGpS!B)8CkH!5#9B11-p(2cXV$ZPF$'4G9Hq
+)%dp31`id%V5-d*!!pSKD$923"l@N3h1ZJb(DkEepb!FZCa0EU-bX$'bdqV#ma'b
+M0[YAlCdI``3$Pi"SSpa8,@Q,'l3NH"@,R9%-9,AjT"qi@1lQElk4J%5ph3P5CP"
+!mVPfAYh1I62HP%CFb$!ZHTL#&ZNG)R,1j+&Y&r!1$8@+1+lXI$1UNV1(3Y5T)1l
+8iql@19#pLC)QT@qNjF*Abh68mQ5!c!iGCS(6@+1B'Pf"DD([mDFMa0)a('rE)`0
+m2Sk1GQ19e-AT"jIEjDcEqdKcj8$U6ZF*&Tdk'dMX(Cq4-2,L4$irf`VmFSN+-4R
+'$%mLidh@'f084%fZ@i283`L3!!"@V-hmBMGG(Zdh"'mPZ&IX3JLQ((4V@,a)ebm
+j[HFIrA5FI0#S@!$d*V+IJNP[hEH'HMK$,qh5(p-DESkk*Me+TVUSQKHCl!2A4i#
+c%RTaTN#jMN+e-QE,$6+Ykmm6I+3$TRaI*(f(I,Uh(q3K4P4+Bl`hJH!&Q@LGP0!
+,B8+p&bKXapB'[cAd*+p5Ub02TPTGPKm@C[bIb)q8R&`JqFP'BmGrr!FqUK"43QB
+-*(qfN3)q!UL0j*1-FbjPm86akJem[B$m*j2"-%hJaSYlZT(PY5HUZ3%Q34++-'J
+'Z-elll)E5e9pYT9UZ64E`0mLUYIc0k'QVQ*V0&+#p'`a!-FA66T24@`V!!(442Y
+6F$m+R+B6Mm@V-52&SH22UBD91Y(1DeHeaMk`YA(K`NeiAU'dJD8@GRR[*DS2mPJ
+I1"GpKfYbk&FE4[T,RphI'0E-ie1E&A-IKMPGCNUmDDfUJrC1,NhZm3'(@M[+@LF
+kPfl*Z*,%0X6aGKZUA,YVe%LIr$XY6HJ'"-)KZTR"fZZd@fURep[Zr*c@i[lkFcr
+K3b"8jlMEf-pSpd9STSU`6UjA4E[`9d!$hI(V-X'%kNX1'N(&I3E%E+)GcBqEJ@K
+Y-&J&C%hU3qPe!lhjE"H'-rYp)X(D-"bJaS$2`'A6jY)5'dYB)%+)QA#B9J"mfKF
+2E1[fkS!2K9H4rkql6$XCrVBT&UhQaPHGmFJEZ(m6P3ccD"c`X'9f3,km0$&@M6m
+"+T2-#(#lIQ$0jU@TKHYZ#9J6ki'l@Hm%KaaP2kBq@STP8ZYR854Zd*jm54Ne04X
+S4q8FRIB*%QH9)%B@+6cC,bUjiYk1qJrM)J%E!A%E$9pQ"dFp2i8cm4"9&eeBiGf
+TpQ$H#F0'['24Lri*[bq,N!"T9)FQ*"3SN!"BkSklZh4bK#`ii-XD-+M`a-!9%-3
+,%Zp8rIi`*Jj2,"eH8"328kXEq`TG6J,VS'5DP1*MS95E0U["[9k*QdiZJf-e'+J
+YN9XlcE(e88[3!%&R4C0LAqA63JZG5TG@kq4,mpi!qCf9YHVrN!"SI5&@fh*#4!p
+$KmiQIalYC)QX&&KHq*TB[+a-XhKc0DXL5dmPAXiBqja*DeP*i2LfaiXM2,Y(@LT
+[l1bdh1XqaL'q8FMJA3J4aNdbYiYSjU$RTl$ZdT3UUk5)@"m[SB)(r!Y$Tr3E3H&
+#`AT-`DVqcBJ1L9&G9SJIYY+'AQC*b!X@k)Qhii2[de*b[i[kErI4eUmM8$(FieB
+Ab'UlZ2b#DB2,JAil'dkKA+9C0acrN3Z`[I'Vr6D3!,!Z&4pk+UQH(dMBN!$ILVC
+e2VSSUi`Ejm[rC)H3!&)H,h[e&*ic)DM0Kp934G-1Y9G#UU4a+,L2b6Lk2i3rbah
+B@$D)h8HI*i`X10BSYBpmXq3*kkU"pL@dNb90NjfrjRFUeA0Dr*@VV9SF,VL9N!#
+BMBk5e!)Z2r5I&GGpD!C5'%1M+afSGH'M96Telq8H@b(FcL@634c+9LZVH6&B38F
+'GelfE$30V0J65[ZN)!pU6cj(8YP*&ifC3)q+iR2'AcI,b(,(r#lI"SPB#21U0Ur
+696e2$,#5-H(8U0`%VQT[H[kh[`P)E,UX,Ej-r@f*KSTF#-3XMfdDT3bLVj8l3C9
+9%'%JBlBAC8a!IPMc+Q$PK0P&k*X6fIqI9cJKFDMB8R,DkMN$IQi-SU2a"($R8kS
+f31&5k`T5Zl&NH+Je0YUCj5*V4kNTKKAiD@m"VV$A3r(hm1eq8J6Gl0f5HUZlEH3
+KH#kep$eSMr9T6UEa6XFHk4VhHjQq8dq(P[mUI!5a&F!Z%$L0IGFTbiCmJFjTMK(
+qHF+0MAfZSHZ!bKh+XbH[e,2dMdAKFDCFdUU!2qrC9fDj#U8%dhpM&F*$kATBB1"
+ZVcLKkl@9MFLe'ddTeJ[qSfBp#%#hTeqbb#%0bEG6)(&4iNU(b&Chj6,US@Q$D[Q
+CTD+G!*!!iP+jR6lJ9$a#9a,YEFLq9j&EIpp[0DmS`MXe219ZCQ#[e,qQBq@8jN4
+)+)$F@T!!1+-!P9dV5SA*NpF++T1jB*9bG&FZqj@pU0%VFh')Kbr36`"CYj'S6(V
+HbjXFQK%-!"jcRF'+kC%GaG`&ETm%f9FC$fA$LjiAZJdZ2Qm@h8#"a+MRdM&"0Qr
+CP$cj!$5RlBU'Rc0$l8EZ9JZ,5lYIj2TYC)6ERXa[Mal!dq6LDPaRB"eBVHFjiTq
+(0S#%#D*)qfq&FJf4,iQM@2FA*Y)B&B8lLlRaPhQlKeUFF*DN#4$5'IULf6201@8
+[b+@ACE,!e$&,@N"VfjVE'(GT**GHRkIC'@R91T9G)PM-aX@['(2aAA-q'`ealJC
+TKXN9+01YK4i#H)rMG1!Ql2Kbi$2&Ed+EZd)hp3Drar@Ri'NMfaqNV)qIMbp8[jS
+e9"PYcUZEC'[QmN3$RhT9%INbQrR2b&K5'V1XVcbVVF&CfUeYbZjXfce0[dPhH%4
+HCKLJL*8I`SJP@m&#C1TEjIdYPTKm0ITKaX6HcjcQq$BYN9eASrk)Mp')h'JA,HG
+$+3HhaK8%H1LRqQFKD%`L4YN#r`!Lm@IRdTT[pKJ1Sm(DMMN*"'qKh'Rf4qmX-"P
+CFahqmDhJU[HH6j*aFk54-,@-#&"ll8b*`P(bE&95&1ld@(hc3T1@CF[I"RK8L4c
+m&QcMME28$Pf'Ze5%0&-#C1J0eXhq[CpBE@ER$X`%"2'aA[Pr0eJKNTXRZpc`YH&
+hDcDHF'iQE"Yd2D$Ch"ZNNYQS9()X`P04m,69JbK#XflDEQITM&l2+PICp(DprlQ
+1(3&M%M)CL6B2[!D0mjrq"r&JG#JSJ!h#RGD&E+p9Gldc%LaSl#p5[6UE(5E+F("
+faB0LqmCjep%Ea3VlUjrhdr&3-NK[4&6XAMBCa3pDhQVC'*fpXUjNFE00pNhf%@#
+DU,&B[K$Rk[!emdhh8[Aah0"[X1PReP1DHiQ!jXYJ)r4+JlhpN[Sjkc6!9SM5*a"
+'NqFqk%Ed-m)&Q4DSqa4UaYMf[FB`#06511@9rKY-Yf@jr+FaJVTimKN!S1rEf+b
+[,J@9!I38qPG[raQmp-`eMj`F6%[(hSY3hE-PBEMjb*`'5A@Be%5CPjJ5Ii(r)-Y
+NpMh6I'3X2!',U#KAk`PY!KbV*b&$FDcdNAEqel%RV"Nm*28emNq`6&(SHR+626h
+k[3`p4!IML(%qNLplF0G!e3H&bdl+XR()"DZAZMLG4$&0KqQa4fKSb9,HMmrX2eP
+l53V-[KTDSI(!jB30NDB%lD2+Vj+r-k9GbM!C3@EkpcN'hZ+Xh'r*XF6ANkmbPpl
+!6VBSQXcrCMK'l$Lp)%@ALX`6bXp6k,0*#mG81@kd1-E#al4`b@I4MME$ENjbSMq
+PYT&dS'cQ,pj&@32P"Q9T-Zhc9%XH@Vk-4[KqEeZDG(HGQEU3!0faV55je$aPNbC
+mTlZVA'ab!fKBX`arDCl*4RDb!i!cj`!!:
diff -ruN ug-orig/lib/ugdata/CVS/Entries ug-patched/lib/ugdata/CVS/Entries
--- ug-orig/lib/ugdata/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/ugdata/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-/.cvsignore/1.1/Fri Apr  1 14:23:35 2005//D2008.11.12.23.00.00
-/Makefile.am/1.1/Fri Apr  1 14:23:35 2005//D2008.11.12.23.00.00
-/RefRules.data/1.1.1.1/Mon Jun 24 09:04:38 1996//D2008.11.12.23.00.00
-/helpfile.list/1.3/Tue May 30 13:39:35 2000//D2008.11.12.23.00.00
-/tetra.rls/1.3/Wed Mar 18 17:50:01 1998//D2008.11.12.23.00.00
-/triangle.rls/1.1/Fri Feb 28 18:24:50 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/ugdata/CVS/Repository ug-patched/lib/ugdata/CVS/Repository
--- ug-orig/lib/ugdata/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/ugdata/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/ugdata
diff -ruN ug-orig/lib/ugdata/CVS/Root ug-patched/lib/ugdata/CVS/Root
--- ug-orig/lib/ugdata/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/ugdata/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/ugdata/CVS/Tag ug-patched/lib/ugdata/CVS/Tag
--- ug-orig/lib/ugdata/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/ugdata/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/ugdata/.cvsignore ug-patched/lib/ugdata/.cvsignore
--- ug-orig/lib/ugdata/.cvsignore	2005-04-01 16:23:35.000000000 +0200
+++ ug-patched/lib/ugdata/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/lib/ugdata/Makefile.am ug-patched/lib/ugdata/Makefile.am
--- ug-orig/lib/ugdata/Makefile.am	2005-04-01 16:23:35.000000000 +0200
+++ ug-patched/lib/ugdata/Makefile.am	2005-04-01 16:23:35.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2005/04/01 14:23:35 thimo Exp $
+# $Id: Makefile.am 7977 2005-04-01 14:23:35Z thimo $
 
 # install into share-directory
 dist_data_DATA = helpfile.list RefRules.data tetra.rls triangle.rls
diff -ruN ug-orig/lib/Xcode/CVS/Entries ug-patched/lib/Xcode/CVS/Entries
--- ug-orig/lib/Xcode/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D
diff -ruN ug-orig/lib/Xcode/CVS/Entries.Log ug-patched/lib/Xcode/CVS/Entries.Log
--- ug-orig/lib/Xcode/CVS/Entries.Log	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/UG.xcode////
diff -ruN ug-orig/lib/Xcode/CVS/Repository ug-patched/lib/Xcode/CVS/Repository
--- ug-orig/lib/Xcode/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/Xcode
diff -ruN ug-orig/lib/Xcode/CVS/Root ug-patched/lib/Xcode/CVS/Root
--- ug-orig/lib/Xcode/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/Xcode/CVS/Tag ug-patched/lib/Xcode/CVS/Tag
--- ug-orig/lib/Xcode/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/lib/Xcode/UG.xcode/CVS/Entries ug-patched/lib/Xcode/UG.xcode/CVS/Entries
--- ug-orig/lib/Xcode/UG.xcode/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/UG.xcode/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-/project.pbxproj/1.9/Tue Jun 22 18:20:29 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/lib/Xcode/UG.xcode/CVS/Repository ug-patched/lib/Xcode/UG.xcode/CVS/Repository
--- ug-orig/lib/Xcode/UG.xcode/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/UG.xcode/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/lib/Xcode/UG.xcode
diff -ruN ug-orig/lib/Xcode/UG.xcode/CVS/Root ug-patched/lib/Xcode/UG.xcode/CVS/Root
--- ug-orig/lib/Xcode/UG.xcode/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/UG.xcode/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/lib/Xcode/UG.xcode/CVS/Tag ug-patched/lib/Xcode/UG.xcode/CVS/Tag
--- ug-orig/lib/Xcode/UG.xcode/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/lib/Xcode/UG.xcode/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/libug.pc.in ug-patched/libug.pc.in
--- ug-orig/libug.pc.in	2004-09-03 18:28:45.000000000 +0200
+++ ug-patched/libug.pc.in	2010-07-07 11:39:41.000000000 +0200
@@ -2,10 +2,12 @@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
+parallel=@parallel@
+fordune=@fordune@
 
-Name: UG
+Name: libug
 Version: @VERSION@
 Description: library for the discretization of PDEs on unstructured grids
 Requires:
-Libs: -L${libdir}
-Cflags: -I${includedir} @UG_EXTRAFLAGS@ @UG_XLIBS@
+Libs: -L${libdir} -ldevS @UG_XLIBS@
+Cflags: -I${includedir}/ug @UG_EXTRAFLAGS@
diff -ruN ug-orig/low/architecture.h ug-patched/low/architecture.h
--- ug-orig/low/architecture.h	2004-09-02 13:45:58.000000000 +0200
+++ ug-patched/low/architecture.h	2010-06-29 12:23:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: architecture.h,v 1.1 2004/09/02 11:45:58 thimo Exp $ */
+/* $Id: architecture.h 8369 2010-06-29 10:23:53Z sander $ */
 
 /*
 
@@ -14,8 +14,6 @@
 #error Internal UG-lib header, must not be used in applications!
 #endif
 
-#include "config.h"
-
 /* --- numerical limits ---*/
 
 #ifdef HAVE_LIMITS_H
diff -ruN ug-orig/low/bbtree.c ug-patched/low/bbtree.c
--- ug-orig/low/bbtree.c	2005-01-04 11:24:23.000000000 +0100
+++ ug-patched/low/bbtree.c	2008-12-19 11:06:12.000000000 +0100
@@ -13,6 +13,7 @@
  *            system include files                                           *
  *            application include files                                      *
  *****************************************************************************/
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <float.h>
@@ -51,7 +52,7 @@
  * PRIVATE global variables (global to this source file)                     *
  *****************************************************************************/
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/bbtree.c,v 1.6 2005/01/04 10:24:23 stefan Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 INT theBBTDim = 0;
 HEAP *theBBTHeap = NULL;
diff -ruN ug-orig/low/bbtree.h ug-patched/low/bbtree.h
--- ug-orig/low/bbtree.h	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/bbtree.h	2009-05-07 10:00:28.000000000 +0200
@@ -81,7 +81,7 @@
 DOUBLE BBT_TreePointDistance(BBT_TREE *tree, DOUBLE *x, void **obj,
                                                          BBT_POINT_DIST_FUNC dist);
 
-END_NAMESPACE
+END_UG_NAMESPACE
         
 #endif
 
diff -ruN ug-orig/low/bio.c ug-patched/low/bio.c
--- ug-orig/low/bio.c	2008-05-05 15:30:21.000000000 +0200
+++ ug-patched/low/bio.c	2009-04-29 15:11:55.000000000 +0200
@@ -34,10 +34,11 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 
-#if !defined __MWCW__ && !defined __BGP__
+#ifndef __MWCW__
 #include <rpc/rpc.h>	/* to include xdr.h in a portable way */
 #endif
 
@@ -64,9 +65,12 @@
 /*                                                                          */
 /****************************************************************************/
 
-typedef int (*RW_mint_proc) (int n, int *intList);
-typedef int (*RW_mdouble_proc) (int n, double *doubleList);
-typedef int (*RW_string_proc) (char *string);
+typedef int (*R_mint_proc) (int n, int *intList);
+typedef int (*W_mint_proc) (int n, const int *intList);
+typedef int (*R_mdouble_proc) (int n, double *doubleList);
+typedef int (*W_mdouble_proc) (int n, const double *doubleList);
+typedef int (*R_string_proc) (char *string);
+typedef int (*W_string_proc) (const char *string);
 
 /****************************************************************************/
 /*                                                                          */
@@ -84,17 +88,20 @@
 static FILE *stream;
 static int n_byte;
 static fpos_t pos;
-#if !defined __MWCW__ && !defined __BGP__
+#ifndef __MWCW__
 static XDR xdrs;
 #endif
 
 /* low level read/write functions */
-static RW_mint_proc Read_mint, Write_mint;
-static RW_mdouble_proc Read_mdouble, Write_mdouble;
-static RW_string_proc Read_string, Write_string;
+static R_mint_proc Read_mint;
+static W_mint_proc Write_mint;
+static R_mdouble_proc Read_mdouble;
+static W_mdouble_proc Write_mdouble;
+static R_string_proc Read_string;
+static W_string_proc Write_string;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/bio.c,v 1.21 2008/05/05 13:30:21 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -107,7 +114,7 @@
 /* debug i/o                                                                */
 /*                                                                          */
 /****************************************************************************/
-#if !defined __MWCW__ && !defined __BGP__
+#ifndef __MWCW__
 
 static int XDR_Read_mint (int n, int *intList)
 {
@@ -124,7 +131,7 @@
 	return (0);
 }
 
-static int XDR_Write_mint (int n, int *intList)
+static int XDR_Write_mint (int n, const int *intList)
 {
 	int i;
 	
@@ -147,13 +154,13 @@
 	return (0);
 }
 
-static int XDR_Write_mdouble (int n, double *doubleList)
+static int XDR_Write_mdouble (int n, const double *doubleList)
 {
 	int i;
 	
 	for (i=0; i<n; i++)
 	{
-		if (!xdr_double(&xdrs,&(doubleList[i]))) return (1);
+		if (!xdr_double(&xdrs,(double*) &(doubleList[i]))) return (1);
 		n_byte += 8;
 	}
 	return (0);
@@ -177,7 +184,7 @@
 	return (0);
 }
 
-static int XDR_Write_string (char *string)
+static int XDR_Write_string (const char *string)
 {
 	int i,m,len;
 	
@@ -211,7 +218,7 @@
 	return (0);
 }
 
-static int ASCII_Write_mint (int n, int *intList)
+static int ASCII_Write_mint (int n, const int *intList)
 {
 	int i,m;
 	
@@ -233,7 +240,7 @@
 	return (0);
 }
 
-static int ASCII_Write_mdouble (int n, double *doubleList)
+static int ASCII_Write_mdouble (int n, const double *doubleList)
 {
 	int i,m;
 	
@@ -265,7 +272,7 @@
 }
 
 
-static int ASCII_Write_string (char *string)
+static int ASCII_Write_string (const char *string)
 {
 	int i,m,len;
 	
@@ -296,7 +303,7 @@
 	return (0);
 }
 
-static int BIN_Write_mint (int n, int *intList)
+static int BIN_Write_mint (int n, const int *intList)
 {
 	if (fwrite((void*)intList,sizeof(int)*n,1,stream)!=1)	return (1);
 	n_byte += n*sizeof(int);
@@ -309,7 +316,7 @@
 	return (0);
 }
 
-static int BIN_Write_mdouble (int n, double *doubleList)
+static int BIN_Write_mdouble (int n, const double *doubleList)
 {
 	if (fwrite((void*)doubleList,sizeof(double)*n,1,stream)!=1)	return (1);
 	n_byte += n*sizeof(double);
@@ -335,7 +342,7 @@
 }
 
 
-static int BIN_Write_string (char *string)
+static int BIN_Write_string (const char *string)
 {
 	int i,m,len;
 	
@@ -364,7 +371,7 @@
 	
 	switch (mode)
 	{
-		#if !defined __MWCW__ && !defined __BGP__
+		#ifndef __MWCW__
 		case BIO_XDR:
             if (rw=='r')      xdrstdio_create(&xdrs,file,XDR_DECODE);
             else if (rw=='w') xdrstdio_create(&xdrs,file,XDR_ENCODE);
@@ -425,7 +432,7 @@
 	return ((*Read_string)(string));
 }
 
-int NS_PREFIX Bio_Write_string (char *string)
+int NS_PREFIX Bio_Write_string (const char *string)
 {
 	return ((*Write_string)(string));
 }
diff -ruN ug-orig/low/bio.h ug-patched/low/bio.h
--- ug-orig/low/bio.h	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/bio.h	2009-05-07 10:00:28.000000000 +0200
@@ -28,7 +28,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/bio.h,v 1.8 2004/07/21 09:19:50 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -94,13 +94,13 @@
 int Bio_Read_mdouble            (int n, double *doubleList);
 int Bio_Write_mdouble           (int n, double *doubleList);
 int Bio_Read_string             (char *string);
-int Bio_Write_string            (char *string);
+int Bio_Write_string            (const char *string);
 int Bio_Jump_From                       (void);
 int Bio_Jump_To                         (void);
 int Bio_Jump                            (int dojump);
 
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 /** @} */
 #endif
diff -ruN ug-orig/low/boxtree.c ug-patched/low/boxtree.c
--- ug-orig/low/boxtree.c	2006-06-02 18:13:41.000000000 +0200
+++ ug-patched/low/boxtree.c	2006-06-02 18:15:34.000000000 +0200
@@ -51,7 +51,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/boxtree.c,v 1.3 2006/06/02 16:13:41 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/low/boxtree.h ug-patched/low/boxtree.h
--- ug-orig/low/boxtree.h	2004-08-31 12:03:02.000000000 +0200
+++ ug-patched/low/boxtree.h	2004-08-31 12:03:03.000000000 +0200
@@ -18,7 +18,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/boxtree.h,v 1.2 2004/08/31 10:03:02 thimo Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/low/CVS/Entries ug-patched/low/CVS/Entries
--- ug-orig/low/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/low/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,50 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:18 2004//D2008.11.12.23.00.00
-/Makefile.am/1.4/Fri Mar 17 09:38:28 2006//D2008.11.12.23.00.00
-/Makefile.low/1.14/Tue Mar  9 13:20:37 2004//D2008.11.12.23.00.00
-/architecture.h/1.1/Thu Sep  2 11:45:58 2004//D2008.11.12.23.00.00
-/bbtree.c/1.6/Tue Jan  4 10:24:23 2005//D2008.11.12.23.00.00
-/bbtree.h/1.3/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/bio.c/1.21/Mon May  5 13:30:21 2008//D2008.11.12.23.00.00
-/bio.h/1.8/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/boxtree.c/1.3/Fri Jun  2 16:13:41 2006//D2008.11.12.23.00.00
-/boxtree.h/1.2/Tue Aug 31 10:03:02 2004//D2008.11.12.23.00.00
-/debug.c/1.27/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/debug.h/1.30/Thu Jun  5 18:01:30 2008//D2008.11.12.23.00.00
-/defaults.c/1.16/Mon May  8 12:12:59 2006//D2008.11.12.23.00.00
-/defaults.h/1.7/Mon May  8 12:12:59 2006//D2008.11.12.23.00.00
-/dimension.h/1.2/Mon Feb  6 08:53:09 2006//D2008.11.12.23.00.00
-/dunemarker.c/1.2/Fri Nov 17 10:04:32 2006//D2008.11.12.23.00.00
-/dunemarker.h/1.1/Fri Mar 17 09:37:12 2006//D2008.11.12.23.00.00
-/fifo.c/1.10/Mon Mar 13 09:04:00 2006//D2008.11.12.23.00.00
-/fifo.h/1.6/Mon Mar 13 09:04:00 2006//D2008.11.12.23.00.00
-/fileopen.c/1.46/Mon Feb 11 19:08:46 2008//D2008.11.12.23.00.00
-/fileopen.h/1.19/Wed May  3 12:03:08 2006//D2008.11.12.23.00.00
-/general.h/1.18/Tue May 30 12:01:06 2006//D2008.11.12.23.00.00
-/heaps.c/1.36/Wed Jul  2 17:04:58 2008//D2008.11.12.23.00.00
-/heaps.h/1.25/Fri Jun  2 15:40:38 2006//D2008.11.12.23.00.00
-/initlow.c/1.12/Tue Jun 14 15:59:22 2005//D2008.11.12.23.00.00
-/initlow.h/1.10/Tue Jun 14 15:59:22 2005//D2008.11.12.23.00.00
-/low.doc/1.7/Mon Mar 13 09:07:10 2006//D2008.11.12.23.00.00
-/low.make/1.2/Wed Nov 15 18:48:31 1995//D2008.11.12.23.00.00
-/misc.c/1.32/Mon Jul 18 13:24:49 2005//D2008.11.12.23.00.00
-/misc.h/1.40/Fri Jun  2 15:40:38 2006//D2008.11.12.23.00.00
-/namespace.h/1.9/Thu Jun  5 17:57:46 2008//D2008.11.12.23.00.00
-/pfile.c/1.17/Sun Mar  9 18:11:45 2008//D2008.11.12.23.00.00
-/pfile.h/1.6/Wed Apr 16 12:56:11 2008//D2008.11.12.23.00.00
-/scan.c/1.16/Fri Jun  2 15:34:14 2006//D2008.11.12.23.00.00
-/scan.h/1.10/Wed Sep  8 13:33:35 2004//D2008.11.12.23.00.00
-/smallvecs.h/1.1/Thu Sep  2 11:45:58 2004//D2008.11.12.23.00.00
-/tree.c/1.8/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/tree.h/1.4/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/ugenv.c/1.21/Tue Apr 18 08:55:47 2006//D2008.11.12.23.00.00
-/ugenv.h/1.17/Fri Jun  2 15:40:38 2006//D2008.11.12.23.00.00
-/ugfile.h/1.1/Thu Sep  2 11:45:58 2004//D2008.11.12.23.00.00
-/ugmemory.h/1.1/Thu Sep  2 11:45:58 2004//D2008.11.12.23.00.00
-/ugstrings.h/1.1/Thu Sep  2 11:45:58 2004//D2008.11.12.23.00.00
-/ugstruct.c/1.17/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/ugstruct.h/1.10/Wed Jul 21 09:19:50 2004//D2008.11.12.23.00.00
-/ugtime.h/1.2/Wed Oct  6 09:16:37 2004//D2008.11.12.23.00.00
-/ugtimer.c/1.3/Mon Mar 13 09:05:05 2006//D2008.11.12.23.00.00
-/ugtimer.h/1.5/Mon Mar 13 09:05:05 2006//D2008.11.12.23.00.00
-/ugtypes.h/1.4/Mon Jun 12 11:44:46 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/low/CVS/Repository ug-patched/low/CVS/Repository
--- ug-orig/low/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/low/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/low
diff -ruN ug-orig/low/CVS/Root ug-patched/low/CVS/Root
--- ug-orig/low/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/low/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/low/CVS/Tag ug-patched/low/CVS/Tag
--- ug-orig/low/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/low/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/low/.cvsignore ug-patched/low/.cvsignore
--- ug-orig/low/.cvsignore	2004-09-08 16:14:18.000000000 +0200
+++ ug-patched/low/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/low/debug.c ug-patched/low/debug.c
--- ug-orig/low/debug.c	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/debug.c	2008-12-19 11:06:12.000000000 +0100
@@ -27,6 +27,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "general.h"
 
 #ifdef Debug
@@ -105,7 +106,7 @@
 static char 				*debugfilename;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/debug.c,v 1.27 2004/07/21 09:19:50 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/low/debug.h ug-patched/low/debug.h
--- ug-orig/low/debug.h	2008-06-05 20:01:30.000000000 +0200
+++ ug-patched/low/debug.h	2005-11-15 09:50:58.000000000 +0100
@@ -21,7 +21,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/debug.h,v 1.30 2008/06/05 18:01:30 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -36,10 +36,6 @@
 #include "general.h"
 #include "misc.h"
 
-#include "namespace.h"
-
-START_UG_NAMESPACE
-
 /****************************************************************************/
 /*																			*/
 /* defines in the following order											*/
@@ -180,6 +176,4 @@
 INT  PrintRepErrStack		(PrintfProcPtr print);
 #endif
 
-END_NAMESPACE
-
 #endif
diff -ruN ug-orig/low/defaults.c ug-patched/low/defaults.c
--- ug-orig/low/defaults.c	2006-05-08 14:12:59.000000000 +0200
+++ ug-patched/low/defaults.c	2008-12-19 11:06:12.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -50,44 +51,34 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/defaults.c,v 1.16 2006/05/08 12:12:59 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 #ifdef ModelP
 static char *defaults_buffer=NULL;
 #endif
 
+#define NAMESIZE    32
+#define NAMELEN     31
+#define NAMELENSTR    "31"
 
-/****************************************************************************/
-/*D
-   GetLocalizedDefaultValue - Provide access to defaults file
-
-   SYNOPSIS:
-   INT GetLocalizedDefaultValue (const char *filename, const char *name, char *value);
 
-   PARAMETERS:
-.  filename - pointer to char (const)
-.  name -     pointer to char (const)
-.  value -    pointer to char
+/****************************************************************************/
+/** \brief Provide access to defaults file
 
-   DESCRIPTION:
    This function provides access to defaults file. When 'ug' is started
    this function reads the defaults on file in order to set some
    parameters of 'ug' in advance.
 
-   RETURN VALUE:
-   INT
-.n    0 if OK
-.n    1 if error in opening or reading defaults file
-   
-   SEE ALSO:
+   \return <ul>
+   <li> 0 if OK </li>
+   <li> 1 if error in opening or reading defaults file </li>
+   </ul>
+
+   \sa
    GetDefaultValue
-D*/
+*/
 /****************************************************************************/
 
-#define NAMESIZE    32
-#define NAMELEN     31
-#define NAMELENSTR    "31"
-
 INT NS_PREFIX GetLocalizedDefaultValue (const char *filename, const char *name, char *value)
 {
     FILE *defaultsFile;
@@ -192,34 +183,6 @@
 }
 
 
-/****************************************************************************/
-/*D
-   GetDefaultValue - Provide access to defaults file
-
-   SYNOPSIS:
-   INT GetDefaultValue (const char *filename, const char *name, char *value);
-
-   PARAMETERS:
-.  filename - pointer to char (const)
-.  name -     pointer to char (const)
-.  value -    pointer to char
-
-   DESCRIPTION:
-   This function provides access to defaults file. When 'ug' is started
-   this function reads the defaults on file in order to set some
-   parameters of 'ug' in advance.
-
-   RETURN VALUE:
-   INT
-.n    0 if OK
-.n    1 if error in opening or reading defaults file
-   
-   SEE ALSO:
-   GetLocalizedDefaultValue
-D*/
-/****************************************************************************/
-
-
 #define MAX_PATH_LEN		1024
 enum {PATH_TOO_LONG = 1, COULD_NOT_STAT};
 
@@ -247,6 +210,23 @@
 	}
 }
 
+/****************************************************************************/
+/** \brief Provide access to defaults file
+
+   This function provides access to defaults file. When 'ug' is started
+   this function reads the defaults on file in order to set some
+   parameters of 'ug' in advance.
+
+   \return <ul>
+   <li> 0 if OK </li>
+   <li> 1 if error in opening or reading defaults file </li>
+   </ul>
+
+   \sa
+   GetLocalizedDefaultValue
+*/
+/****************************************************************************/
+
 INT NS_PREFIX GetDefaultValue (const char *filename, const char *name, char *value)
 {
 	#ifdef ModelP
diff -ruN ug-orig/low/defaults.h ug-patched/low/defaults.h
--- ug-orig/low/defaults.h	2006-05-08 14:12:59.000000000 +0200
+++ ug-patched/low/defaults.h	2009-05-07 10:00:28.000000000 +0200
@@ -21,7 +21,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/defaults.h,v 1.7 2006/05/08 12:12:59 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -72,7 +72,7 @@
 INT	GetDefaultValue				(const char *filename, const char *name, char *value);
 INT	GetLocalizedDefaultValue	(const char *filename, const char *name, char *value);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
 
diff -ruN ug-orig/low/dimension.h ug-patched/low/dimension.h
--- ug-orig/low/dimension.h	2006-02-06 09:53:09.000000000 +0100
+++ ug-patched/low/dimension.h	2006-02-06 09:53:09.000000000 +0100
@@ -1,4 +1,4 @@
-/* $Id: dimension.h,v 1.2 2006/02/06 08:53:09 sander Exp $ */
+/* $Id: dimension.h 8138 2006-02-06 08:53:09Z sander $ */
 
 /** \file
     \brief Provide the usual preprocessor-defines for the dimension and complain 
diff -ruN ug-orig/low/dunemarker.c ug-patched/low/dunemarker.c
--- ug-orig/low/dunemarker.c	2006-11-17 11:04:32.000000000 +0100
+++ ug-patched/low/dunemarker.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,35 +0,0 @@
-/****************************************************************************/
-/** \file
-    \brief Create a link time marker for the enable-dune build option.
-    \author Oliver Sander
-
-    If you want to use UG as part of DUNE, you have to build it with the
-    build-option --enable-dune.  However, this option affects header
-    files exclusively.  It is therefore impossible for the DUNE build
-    system to check whether UG has been built with this opion.  People
-    tend to forget it and then encounter strange errors.  To avoid this
-    we add a data field here which gets compiled into the UG library 
-    if --enable-dune is set and can therefore be checked by the
-    DUNE build system.
-*/    
-/****************************************************************************/
-
-
-/* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/dunemarker.c,v 1.2 2006/11/17 10:04:32 sander Exp $
-*/
-
-#include "namespace.h"
-#include "dunemarker.h"
-
-#ifdef FOR_DUNE
-
-#ifndef __cplusplus
-#error You must force the build system to compile as C++ when setting --enable-dune!
-#endif
-
-/** \brief Data field which is only there for the DUNE build system to check 
-    whether UG has been compiled with FOR_DUNE.
-*/
-int NS_PREFIX duneMarker = 0;
-#endif
diff -ruN ug-orig/low/dunemarker.h ug-patched/low/dunemarker.h
--- ug-orig/low/dunemarker.h	2006-03-17 10:37:12.000000000 +0100
+++ ug-patched/low/dunemarker.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,44 +0,0 @@
-/****************************************************************************/
-/** \file
-    \brief Create a link time marker for the enable-dune build option.
-    \author Oliver Sander
-
-    If you want to use UG as part of DUNE, you have to build it with the
-    build-option --enable-dune.  However, this option affects header
-    files exclusively.  It is therefore impossible for the DUNE build
-    system to check whether UG has been built with this opion.  People
-    tend to forget it and then encounter strange errors.  To avoid this
-    we add a data field here which gets compiled into the UG library 
-    if --enable-dune is set and can therefore be checked by the
-    DUNE build system.
-*/    
-/****************************************************************************/
-
-
-/* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/dunemarker.h,v 1.1 2006/03/17 09:37:12 sander Exp $
-*/
-
-#ifndef UG_DUNE_MARKER_H
-#define UG_DUNE_MARKER_H
-
-#include "namespace.h"
-
-START_UG_NAMESPACE
-
-/****************************************************************************/
-/*                                                                          */
-/* definition of exported global variables                                  */
-/*                                                                          */
-/****************************************************************************/
-
-#ifdef FOR_DUNE
-/** \brief Data field which is only there for the DUNE build system to check 
-    whether UG has been compiled with FOR_DUNE.
-*/
-extern int duneMarker;
-#endif
-
-END_NAMESPACE
-
-#endif
diff -ruN ug-orig/low/fifo.c ug-patched/low/fifo.c
--- ug-orig/low/fifo.c	2006-03-13 10:04:00.000000000 +0100
+++ ug-patched/low/fifo.c	2008-12-19 11:06:12.000000000 +0100
@@ -28,6 +28,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 
 #include "compiler.h"
@@ -43,7 +44,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/fifo.c,v 1.10 2006/03/13 09:04:00 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /** \brief Initialize fifo data structure 
diff -ruN ug-orig/low/fifo.h ug-patched/low/fifo.h
--- ug-orig/low/fifo.h	2006-03-13 10:04:00.000000000 +0100
+++ ug-patched/low/fifo.h	2009-05-07 10:00:28.000000000 +0200
@@ -22,7 +22,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/fifo.h,v 1.6 2006/03/13 09:04:00 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -66,6 +66,6 @@
 INT     fifo_in     (FIFO *myfifo, void *newelement);
 void    *fifo_out    (FIFO *myfifo);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/fileopen.c ug-patched/low/fileopen.c
--- ug-orig/low/fileopen.c	2008-02-11 20:08:46.000000000 +0100
+++ ug-patched/low/fileopen.c	2008-12-19 11:06:12.000000000 +0100
@@ -2,7 +2,7 @@
 /*																			*/
 /* File:	  fileopen.c													*/
 /*																			*/
-/* Purpose:   definition of an fopen fct. that accepts UNIX-style pathnames	*/
+/* Purpose:   definition of a fopen fct. that accepts UNIX-style pathnames	*/
 /*																			*/
 /* Author:	  Henrik Rentz-Reichert 										*/
 /*			  Institut fuer Computeranwendungen III 						*/
@@ -27,6 +27,7 @@
 
 
 /* standard C library */
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -71,7 +72,7 @@
 
 #include "fileopen.h"
 
-#ifndef __MACINTOSH__
+#if defined __HP__ || __SGI__ || __T3E__ || __PARAGON__ || __DEC__ || __SUN__ || __PC__ || __LINUXPPC__
 #include <dirent.h>
 #endif
 
@@ -136,7 +137,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/fileopen.c,v 1.46 2008/02/11 19:08:46 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
@@ -595,7 +596,7 @@
 {
 
 /* encapsulate implementation dependent stuff for DirWalk */
-#ifndef __MACINTOSH__  /* by now (2008) this means POSIX! */
+#if defined __HP__ || __SGI__ || __T3E__ || __PARAGON__ || __DEC__ || __SUN__ || __PC__ || __LINUXPPC__
  
 	typedef struct dirent	DIRENT;
 	#define D_NAME(d)		((d)->d_name)
@@ -638,7 +639,7 @@
 	closedir(dfd);
 	return 0;
 
-#else /* old Mac OS Classic -- untested by now for years! */
+#elif macintosh
 
 #define pstrlen(s)		((s)[0])		/* length of pascal string */
 
@@ -750,6 +751,10 @@
 	return 0;
 
 #endif
+
+	printf("fileopen.c: DirWalk() not implemented for architecture: %s\n",ARCHNAME);
+
+	REP_ERR_RETURN (NOT_IMPLEMENTED);
 }
 
 #ifdef PARALLEL
diff -ruN ug-orig/low/fileopen.h ug-patched/low/fileopen.h
--- ug-orig/low/fileopen.h	2006-05-03 14:03:08.000000000 +0200
+++ ug-patched/low/fileopen.h	2009-05-07 10:00:28.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/fileopen.h,v 1.19 2006/05/03 12:03:08 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -116,7 +116,7 @@
 
 INT                     InitFileOpen                            (void);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
 
diff -ruN ug-orig/low/general.h ug-patched/low/general.h
--- ug-orig/low/general.h	2006-05-30 14:01:06.000000000 +0200
+++ ug-patched/low/general.h	2006-05-30 14:01:06.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/general.h,v 1.18 2006/05/30 12:01:06 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/low/heaps.c ug-patched/low/heaps.c
--- ug-orig/low/heaps.c	2008-07-02 19:04:58.000000000 +0200
+++ ug-patched/low/heaps.c	2007-12-04 10:54:36.000000000 +0100
@@ -34,8 +34,6 @@
 #include <assert.h>
 #include <stdio.h> 
 
-#include "domain.h"
-
 #include "compiler.h"
 #include "heaps.h"
 #include "misc.h"
@@ -47,12 +45,9 @@
 #include "gm.h"
 #include "commands.h"
 #include "mgheapmgr.h"
+#endif
 #include "namespace.h"
 USING_UG_NAMESPACE
-#else
-USING_UG_NAMESPACE
-#endif
-USING_UGDIM_NAMESPACE
 
 /****************************************************************************/
 /*                                                                          */
@@ -64,7 +59,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-#define FLOOR(n)   ((n)&~(MEM)(ALIGNMENT-1)) /* lower next multiple of four */
+#define FLOOR(n)    ((n)&ALIGNMASK)     /* lower next multiple of four */
 
 
 /* defines and macros for the virtual heap management                        */
@@ -85,7 +80,7 @@
 REP_ERR_FILE;
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/heaps.c,v 1.36 2008/07/02 17:04:58 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -193,7 +188,7 @@
 */
 /****************************************************************************/
 
-HEAP *NS_PREFIX NewHeap (INT type, MEM size, void *buffer)
+HEAP *NS_PREFIX NewHeap (enum HeapType type, MEM size, void *buffer)
 {
     HEAP *theHeap;
 	INT i;
@@ -283,7 +278,7 @@
 void *NS_PREFIX GetMem (HEAP *theHeap, MEM n, INT mode)
 {
     BLOCK *theBlock,*newBlock;
-    MEM newsize,allocated;
+    long newsize,allocated;
 
 	#if defined(DYNAMIC_MEMORY_ALLOCMODEL) && defined(Debug)
 	if (GetCurrentMultigrid() != NULL)
@@ -589,7 +584,6 @@
 
  \param theHeap - pointer to Heap
  \param size - size of the object 
- \param type - type of the requested object 
 
    This function gets an object of type `type` from free list if possible,
    otherwise it allocates memory from the heap using 'GetMem'.
diff -ruN ug-orig/low/heaps.h ug-patched/low/heaps.h
--- ug-orig/low/heaps.h	2006-06-02 17:40:38.000000000 +0200
+++ ug-patched/low/heaps.h	2009-05-07 10:00:28.000000000 +0200
@@ -27,7 +27,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/heaps.h,v 1.25 2006/06/02 15:40:38 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -72,7 +72,7 @@
     /** \brief Max depth of mark/release calls */
 #define MARK_STACK_SIZE 128             
 
-    enum {GENERAL_HEAP,              /**< Heap with alloc/free mechanism  */
+    enum HeapType {GENERAL_HEAP,              /**< Heap with alloc/free mechanism  */
           SIMPLE_HEAP              /**< Heap with mark/release mechanism*/
     };
 
@@ -146,7 +146,7 @@
 };
 
 typedef struct {
-    INT type;
+    enum HeapType type;
     MEM size;
     MEM used;
     MEM freelistmem;
@@ -213,7 +213,7 @@
 
     /** @name Functions for the simple and general heap management */
     /* @{ */
-HEAP        *NewHeap                (INT type, MEM size, void *buffer);
+HEAP        *NewHeap                (enum HeapType type, MEM size, void *buffer);
 void        *GetMem                 (HEAP *theHeap, MEM n, INT mode);
 void            *GetMemUsingKey                 (HEAP *theHeap, MEM n, INT mode, INT key);
 void         DisposeMem             (HEAP *theHeap, void *buffer);
@@ -242,7 +242,7 @@
 INT          FreeBlock                (VIRT_HEAP_MGMT *theVHM, BLOCK_ID id);
  /* @} */
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 /** @} */
 
diff -ruN ug-orig/low/initlow.c ug-patched/low/initlow.c
--- ug-orig/low/initlow.c	2005-06-14 17:59:22.000000000 +0200
+++ ug-patched/low/initlow.c	2008-12-19 11:06:12.000000000 +0100
@@ -36,6 +36,7 @@
 /****************************************************************************/
 
 /* ANSI-C includes */
+#include "config.h"
 #include <stdio.h>
 
 /* low module */
@@ -60,7 +61,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/initlow.c,v 1.12 2005/06/14 15:59:22 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 
 
@@ -86,10 +87,6 @@
 	INT err;
 	char buffer[BUFFSIZE];
 	
-	/* keep type for sscanf */
-	int heapSize;
-	
-	
 	/* init heaps.c */
 	if ((err=InitHeaps())!=0)
 	{
@@ -98,12 +95,7 @@
 	}
 	
 	/* init ugenv.c */
-	if (GetDefaultValue(DEFAULTSFILENAME,"envmemory",buffer)==0)
-		sscanf(buffer," %d ",&heapSize);
-	else
-		heapSize = DEFAULTENVSIZE;
-	
-	if ((err=InitUgEnv(heapSize))!=0)
+	if ((err=InitUgEnv())!=0)
 	{
 		SetHiWrd(err,__LINE__);
 		return (err);
diff -ruN ug-orig/low/initlow.h ug-patched/low/initlow.h
--- ug-orig/low/initlow.h	2005-06-14 17:59:22.000000000 +0200
+++ ug-patched/low/initlow.h	2009-05-07 10:00:28.000000000 +0200
@@ -29,7 +29,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/initlow.h,v 1.10 2005/06/14 15:59:22 sander Exp $
+$Header$
 */
 
 #ifndef __INITLOW__
@@ -53,7 +53,7 @@
 
 INT ExitLow();
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 /** @} */
 #endif
diff -ruN ug-orig/low/low.doc ug-patched/low/low.doc
--- ug-orig/low/low.doc	2006-03-13 10:07:10.000000000 +0100
+++ ug-patched/low/low.doc	2007-07-30 10:18:58.000000000 +0200
@@ -1,41 +1,3 @@
-/***************************************************************************/
-/*D
-   compiler - Header file for defining standard types and constants (machine dependent)
-
-   DESCRIPTION:
-   In the definitions of the `CFLAGS` in the file 'mk.arch' the
-   key word for a special machine has to be chosen. For example by the 
-   compiler option '-D__HP__' ug is about to run on a HP computer. 
-   Concerning this option the corresponding definitions of the standard 
-   types in the file 'compiler.h' are taken.
-   (The file compiler.h is located in $UGROOT/arch.)
-
-   As this header file 'compiler.h' defines the standard types used in ug
-   it has to be included in `all` source files of ug!!! 
-
-   The basic types (normally 'short', 'int', 'float' and 'double') are 
-   replaced by 'SHORT', 'INT', 'FLOAT' and 'DOUBLE'. The type 'DOUBLE' 
-   is used for all Cartesian coordinates of the (x,y[,z])-directions of 
-   the grids and 'SCREEN_DOUBLE' is used for all transformed coordinates 
-   of the graphical interface.
-
-   The constant 'ALIGNMENT' has to be set equal to '4' or '8' depending on 
-   the 32 or 64 bit architecture of the machine used. It is also related 
-   to the constant 'ALIGNMASK', which has correspondingly to be set equal 
-   to '0xFFFFFFFC' or '0xFFFFFFF8' to clear the last two or three bits 
-   of a memory address.
-   
-   If you have to add a new mk.? file to support a new machine you also
-   have to provide a new entry in the 'compiler.h' file defining the basic 
-   data types and memory alignment. 
-   To that end you include a flag -D<your new machine>
-   in the CFLAGS section of your new mk.<your new machine> file and add
-   a new paragraph depending on this flag in 'compiler.h'.
- 
-D*/
-/***************************************************************************/
-
-
 /****************************************************************************/
 /*D
    heaps - Memory handling by the use of 'heaps'
@@ -129,70 +91,3 @@
 D*/
 /****************************************************************************/
 
-/***************************************************************************/
-/*D
-    ugenv - general data management concept in a tree structure
-    
-    PURPOSE:
-    The environment management of ug provides the possibility to store data in
-    a tree structure. The storage is taken from a 'GENERAL_HEAP' allocated at
-    initialization time with the size specified by 'envmemory' in the 'defaults'
-    file (if no 'defaults' file is available 'DEFAULTENVSIZE' is used).
-    
-    The data structures of the environment allow to create directories and items
-    of specified size. Both data structures start with a general head (among
-    others a name by which one can refer to it). The remaining memory up to the
-    specified size can be used in arbitrary way.
-    
-    The head is identical with the struct 'ENVVAR:'
-
-.vb
-typedef struct {                // user defined variable                    
-    INT type;                   // even number by GetNewEnvVarID            
-    INT locked;                 // may not be changed or deleted            
-    union envitem *next;
-    union envitem *previous;    // double linked list of environment items  
-    char name[NAMESIZE];        // name of that item                        
-                                
-//  ...                            may be longer, but of no interest for env
-
-} ENVVAR;
-.ve
-    
-    All items are members of doubly linked lists.
-    
-    The data structure for the directory has just an extra component to the
-    start of a list which is the directory contents (and can consist of
-    directories itself, of course).
-    
-.vb
-
-typedef struct {                // directory                                
-    INT type;                   // odd number by GetNewEnvDirID     
-    INT locked;                 // may not be changed or deleted            
-    union envitem *next;
-    union envitem *previous;    // double linked list of environment items  
-    char name[NAMESIZE];        // name of that item                        
-    union envitem *down;        // one level down in the tree               
-                                
-//  ...                            may be longer, but of no interest for env
-
-} ENVDIR;
-.ve
-    
-    The tree starts with a root directory "/" and there is always a current
-    or working directory. Paths are specified in UNIX-style. The current
-    directory can be changed using 'ChangeEnvDir' while 'GetCurrentDir'
-    returns a pointer to the current directory. The routine
-    'MakeEnvItem' creates the specified item in the current directory and
-    it is possible to 'RemoveEnvItem's created previously.
-    
-    Finally 'SearchEnv' offers the possibility to hierarchically search
-    the environment tree for an item specified by its name.
-    
-    SEE ALSO:
-    ENVITEM, ChangeEnvDir, GetCurrentDir, GetPathName, MakeEnvItem, RemoveEnvItem,
-    SearchEnv, GetNewEnvDirID, GetNewEnvVarID
-D*/
-/****************************************************************************/
-
diff -ruN ug-orig/low/Makefile.am ug-patched/low/Makefile.am
--- ug-orig/low/Makefile.am	2006-03-17 10:38:28.000000000 +0100
+++ ug-patched/low/Makefile.am	2011-11-11 16:54:43.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.4 2006/03/17 09:38:28 sander Exp $
+# $Id: Makefile.am 8398 2011-11-11 15:54:43Z sander $
 
 noinst_LTLIBRARIES = liblow.la liblow2.la liblow3.la
 
@@ -6,7 +6,7 @@
 liblow_la_SOURCES = ugenv.c heaps.c fifo.c misc.c \
                   defaults.c initlow.c fileopen.c \
                   ugstruct.c debug.c bio.c \
-                  scan.c ugtimer.c tree.c pfile.c dunemarker.c \
+                  scan.c ugtimer.c tree.c \
 architecture.h bio.h boxtree.h  debug.h  defaults.h  dimension.h  fifo.h \
 fileopen.h general.h heaps.h initlow.h misc.h pfile.h \
 scan.h smallvecs.h tree.h ugenv.h ugfile.h ugmemory.h ugstrings.h \
@@ -16,16 +16,19 @@
 liblow_la_CPPFLAGS = $(UG_CPPFLAGS)
 
 # normal headers
-include_HEADERS = heaps.h ugenv.h ugstruct.h misc.h debug.h ugtypes.h \
+lowincludedir = $(pkgincludedir)
+lowinclude_HEADERS = heaps.h ugenv.h ugstruct.h misc.h debug.h ugtypes.h \
                   general.h dimension.h smallvecs.h \
                   tree.h boxtree.h ugtimer.h scan.h defaults.h fileopen.h \
-                  namespace.h pfile.h dunemarker.h
+                  namespace.h pfile.h
 
 # special library for the parts of low that need a dimension
-DIMDEPSOURCES = boxtree.c
+DIMDEPSOURCES = boxtree.c pfile.c
 
 liblow2_la_SOURCES = $(DIMDEPSOURCES) 
 liblow2_la_CPPFLAGS = $(UG_2DFLAGS)
+liblow2_la_LIBADD = liblow.la
 
 liblow3_la_SOURCES = $(DIMDEPSOURCES) 
 liblow3_la_CPPFLAGS = $(UG_3DFLAGS)
+liblow3_la_LIBADD = liblow.la
diff -ruN ug-orig/low/misc.c ug-patched/low/misc.c
--- ug-orig/low/misc.c	2005-07-18 15:24:49.000000000 +0200
+++ ug-patched/low/misc.c	2008-12-19 11:06:12.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include <assert.h>
 #include <stdlib.h>
@@ -95,7 +96,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/misc.c,v 1.32 2005/07/18 13:24:49 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -122,23 +123,14 @@
 /****************************************************************************/
 
 /****************************************************************************/
-/*D
-   INT_2_bitpattern	- transform an INT into a bitpattern string
+/** \brief Transform an INT into a bitpattern string
 
-   SYNOPSIS:
-   static void INT_2_bitpattern (INT n, char *text)
+ \param n - integer to convert
+ \param text - string of size >= 33 for conversion
 
-   PARAMETERS:
-.  n - integer to convert
-.  text - string of size >= 33 for conversion
-
-   DESCRIPTION:
    This function transforms an INT into a bitpattern string consisting of 0s
    and 1s only.
-
-   RETURN VALUE:
-   void
-D*/									
+*/									
 /****************************************************************************/
 
 void NS_PREFIX INT_2_bitpattern (INT n, char text[33])
@@ -156,40 +148,19 @@
 }
 
 /****************************************************************************/
-/*																			*/
-/* Function:  CenterInPattern												*/
-/*																			*/
-/* Purpose:   fill str up to PatLen with pattern and center text in it.		*/
-/*			  Terminate the str with end									*/
-/*																			*/
-/* Input:	  s.a															*/
-/*																			*/
-/* Output:	  INT 0: ok														*/
-/*				  1: error													*/
-/*																			*/
-/****************************************************************************/
+/** \brief Compose a headline of chars with string centered
 
-/****************************************************************************/
-/*D
-   CenterInPattern	- compose a headline of chars with string centered
-
-   SYNOPSIS:
-   INT CenterInPattern (char *str, INT PatLen, const char *text, char p, const char *end)
-
-   PARAMETERS:
-.  str - string to print to
-.  PatLen - width of headline
-.  text - text to center in headline
-.  p - char replicated for headline
-.  end - trailing string (optional)
-
-   DESCRIPTION:
-   This function transforms an INT into a bitpattern string consisting of 0s
-   and 1s only.
-
-   RETURN VALUE:
-   void
-D*/									
+ \param str - string to print to
+ \param PatLen - width of headline
+ \param text - text to center in headline
+ \param p - char replicated for headline
+ \param end - trailing string (optional)
+
+   Fill str up to PatLen with pattern and center text in it. Terminate the str with end
+
+   \return
+   0 okay 1 error
+*/									
 /****************************************************************************/
 
 INT NS_PREFIX CenterInPattern (char *str, INT PatLen, const char *text, char p, const char *end)
@@ -218,25 +189,7 @@
 	return (0);
 }
 
-/****************************************************************************/
-/*D
-   expandfmt - Expand (make explicit) charset-ranges in scanf
 
-   SYNOPSIS:
-   char *expandfmt (const char *fmt)
-
-   PARAMETERS:
-.  fmt - pointer to char (const)
-
-   DESCRIPTION:
-   This function expands (make explicit) charset-ranges in scanf.
-   For example '%<number>[...a-d...]' --> '%<number>[...abcd...]'.
-
-   RETURN VALUE:
-   char*
-.n        new pointer to char
-D*/
-/****************************************************************************/
 
 /* install a user math error handler */
 static int UG_matherr(
@@ -258,6 +211,16 @@
 
 static char newfmt[FMTBUFFSIZE];
 
+/****************************************************************************/
+/** \brief Expand (make explicit) charset-ranges in scanf
+
+   This function expands (make explicit) charset-ranges in scanf.
+   For example '%<number>[...a-d...]' --> '%<number>[...abcd...]'.
+
+   \return
+.n        new pointer to char
+*/
+/****************************************************************************/
 char * NS_PREFIX expandfmt (const char *fmt)
 {
     const char *pos;
@@ -421,25 +384,18 @@
 }
 
 /****************************************************************************/
-/*D
-   StrTok - Copy a token out of a string (ANSI-C)
+/** \brief Copy a token out of a string (ANSI-C)
 
-   SYNOPSIS:
-   char *StrTok (char *s, const char *ct)
+ \param s -  pointer to char
+ \param ct - pointer to char (const)
 
-   PARAMETERS:
-.  s -  pointer to char
-.  ct - pointer to char (const)
-
-   DESCRIPTION:
    This function copies a token out of a string.
 
    See also ANSI-C for description of this function.
 
-   RETURN VALUE:
-   char
+   \return
 .n    pointer to char, modified string
-D*/
+*/
 /****************************************************************************/
 
 char * NS_PREFIX StrTok (char *s, const char *ct)
@@ -477,29 +433,22 @@
 }
 
 /****************************************************************************/
-/*D
-   strntok - Split a string into tokens each of maximal length 'n+1'
-
-   SYNOPSIS:
-   const char *strntok (const char *str, const char *sep, int n, char *token)
+/** \brief Split a string into tokens each of maximal length 'n+1'
 
-   PARAMETERS:
-.  str -   pointer to char (const)
-.  sep -   pointer to char (const)
-.  n -     integer, number of chars in token
-.  token - pointer to char
+ \param str -   pointer to char (const)
+ \param sep -   pointer to char (const)
+ \param n -     integer, number of chars in token
+ \param token - pointer to char
 
-   DESCRIPTION:
    This function splits a string into tokens each of maximal length 'n+1'.
    A pointer to the next char following the token (its a sep) is returned.
    NB: possibly check whether the returned char is a sep.
    If not: the token was to long and only the first n chars where copied!
 
-   RETURN VALUE:
-   char
+   \return
 .n     pointer to token
 .n     NULL if token larger than n.
-D*/
+*/
 /****************************************************************************/
 
 const char * NS_PREFIX strntok (const char *str, const char *sep, int n, char *token)
@@ -526,22 +475,15 @@
 }
 
 /****************************************************************************/
-/*D
-   StrDup - duplicate string to memory allocated with malloc
+/** \brief Duplicate string to memory allocated with malloc
 
-   SYNOPSIS:
-   char *StrDup (const char *s)
+ \param s - string to duplicate
 
-   PARAMETERS:
-.  s - string to duplicate
-
-   DESCRIPTION:
    This function duplicates a string to memory allocated with malloc.
 
-   RETURN VALUE:
-   char*
+   \return
 .n        pointer to new string
-D*/
+*/
 /****************************************************************************/
 
 char * NS_PREFIX StrDup (const char *s)
@@ -566,26 +508,17 @@
 }
 
 /****************************************************************************/
-/*D
-   QSort - Sorting routine (standard function)
-
-   SYNOPSIS:
-   void QSort (void *base,INT n,INT size,int (*cmp)(const void *,const void *))
+/** \brief Sorting routine (standard function)
 
-   PARAMETERS:
-.  base - pointer to void, field to be sorted
-.  n -    integer, length of string
-.  size - integer, number of characters to be sorted
-.  cmp -  pointer to function with two arguments
+ \param base - pointer to void, field to be sorted
+ \param n -    integer, length of string
+ \param size - integer, number of characters to be sorted
+ \param cmp -  pointer to function with two arguments
 
-   DESCRIPTION:
    This function sorts the values returned by a function given as argument.
    
    See also standard description of 'QSort'.
-
-   RETURN VALUE:
-   void
-D*/
+*/
 /****************************************************************************/
 void NS_PREFIX QSort (void *base, INT n, INT size, int (*cmp)(const void *, const void *))
 {
@@ -647,26 +580,17 @@
 }
 
 /****************************************************************************/
-/*D
-   SelectionSort - Sorting routine (standard)
-
-   SYNOPSIS:
-   void SelectionSort (void *base,INT n,INT size,int (*cmp)(const void *,const void *))
+/** \brief Sorting routine (standard)
 
-   PARAMETERS:
-.  base - pointer to void, field to be sorted
-.  n -    integer, length of string
-.  size - integer, number of characters to be sorted
-.  cmp -  pointer to function with two arguments
+ \param base - pointer to void, field to be sorted
+ \param n -    integer, length of string
+ \param size - integer, number of characters to be sorted
+ \param cmp -  pointer to function with two arguments
 
-   DESCRIPTION:
    This function sorts the arguments of the function.
 
    See also standard description of 'SelectionSort'.
-
-   RETURN VALUE:
-   void
-D*/
+*/
 /****************************************************************************/
 
 void  NS_PREFIX SelectionSort (void *base, INT n, INT size, int (*cmp)(const void *, const void *))
@@ -708,17 +632,11 @@
 
 
 /****************************************************************************/
-/*D
-    ReadMemSizeFromString - Convert a (memory)size specification from String to MEM (long int)
-
-   SYNOPSIS:
-   INT ReadMemSizeFromString (const char *s, MEM *mem_size ); 
+/** \brief Convert a (memory)size specification from String to MEM (long int)
 
-   PARAMETERS:
-.  s - input string
-.  mem_size - the specified mem size in byte
+ \param s - input string
+ \param mem_size - the specified mem size in byte
 
-   DESCRIPTION:
    This function converts a (memory)size specification from String to type MEM (an integer type).
    The size specification contains an integer number followed by an optional unit specifier:
       G for gigabyte
@@ -729,14 +647,14 @@
    EXAMPLE:
       "10M" is converted to 10485760 (10 mega byte).
 
-   RETURN VALUE:
+   \return
    INT: 0 ok
         1 integer could not be read
         2 invalid unit specifier
 
-   SEE ALSO:
+   \sa
    MEM, WriteMemSizeToString
-D*/
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX ReadMemSizeFromString (const char *s, MEM *mem_size )
@@ -766,26 +684,20 @@
 }
 
 /****************************************************************************/
-/*D
-    WriteMemSizeToString - Convert a (memory)size MEM to string
+/** \brief Convert a (memory)size MEM to string
 
-   SYNOPSIS:
-   INT WriteMemSizeToString (MEM mem_size, char *s)
+ \param s - input string
+ \param mem_size - the specified mem size in byte
 
-   PARAMETERS:
-.  s - input string
-.  mem_size - the specified mem size in byte
-
-   DESCRIPTION:
    This function writes a MEM size in MBytes to string in a format that is recognized by
    WriteMemSizeToString.
 
-   RETURN VALUE:
-   INT: 0 ok
+   \return
+   0 ok
 
-   SEE ALSO:
+   \sa
    MEM, ReadMemSizeFromString
-D*/
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX WriteMemSizeToString (MEM mem_size, char *s)
diff -ruN ug-orig/low/misc.h ug-patched/low/misc.h
--- ug-orig/low/misc.h	2006-06-02 17:40:38.000000000 +0200
+++ ug-patched/low/misc.h	2009-05-07 10:00:28.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/misc.h,v 1.40 2006/06/02 15:40:38 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -148,7 +148,7 @@
 #ifndef ModelP
 
 #ifdef __cplusplus
-END_NAMESPACE
+END_UG_NAMESPACE
 namespace PPIF {
 #endif
 extern int me;          /* to have in the serial case this variable as a dummy */
@@ -191,6 +191,6 @@
 
 INT                     MemoryParameters        (void);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/namespace.h ug-patched/low/namespace.h
--- ug-orig/low/namespace.h	2008-06-05 19:57:46.000000000 +0200
+++ ug-patched/low/namespace.h	2009-05-07 10:00:28.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: namespace.h,v 1.9 2008/06/05 17:57:46 lampe Exp $ */
+/* $Id: namespace.h 8353 2009-05-07 08:00:28Z sander $ */
 
 /** \file
 
@@ -14,7 +14,7 @@
 
     ...
 
-    END_NAMESPACE
+    END_UG_NAMESPACE
 
   for stuff that is independent of the space dimension or
 
@@ -50,10 +50,10 @@
 #ifndef UG_NAMESPACE_H
 #define UG_NAMESPACE_H
 
-#if defined __cplusplus && !defined NO_NAMESPACES
+#ifdef __cplusplus
 
 #define START_UG_NAMESPACE namespace UG {
-#define END_NAMESPACE }
+#define END_UG_NAMESPACE }
 #define END_UGDIM_NAMESPACE }}
 #define NS_PREFIX UG::
 #define USING_UG_NAMESPACE using namespace UG;
@@ -74,7 +74,7 @@
   /* normal C-compiler, no namespace-stuff */
 # define START_UG_NAMESPACE
 # define START_UGDIM_NAMESPACE
-# define END_NAMESPACE
+# define END_UG_NAMESPACE
 # define END_UGDIM_NAMESPACE
 # define NS_PREFIX
 #define NS_DIM_PREFIX
@@ -84,7 +84,7 @@
 #endif
 
 /* check if the required symbols exist */
-#if !defined(NS_PREFIX) || !defined(START_UG_NAMESPACE) || !defined(END_NAMESPACE)
+#if !defined(NS_PREFIX) || !defined(START_UG_NAMESPACE) || !defined(END_UG_NAMESPACE)
 # error missing symbol!
 #endif
 
diff -ruN ug-orig/low/pfile.c ug-patched/low/pfile.c
--- ug-orig/low/pfile.c	2008-03-09 19:11:45.000000000 +0100
+++ ug-patched/low/pfile.c	2009-04-29 14:30:36.000000000 +0200
@@ -1,17 +1,17 @@
 /****************************************************************************/
 /*                                                                          */
-/* File:      pfile.c		                                                */
+/* File:      pfile.c                                                       */
 /*                                                                          */
-/* Purpose:   a nice utility for writing a single file from parallel		*/
-/*            processes														*/
+/* Purpose:   a nice utility for writing a single file from parallel        */
+/*            processes                                                     */
 /*                                                                          */
-/* Author:	  Peter Bastian         										*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70569 Stuttgart												*/
-/*																			*/
-/* History:   28.01.97    begin												*/
+/* Author:    Peter Bastian                                                 */
+/*            Institut fuer Computeranwendungen III                         */
+/*            Universitaet Stuttgart                                        */
+/*            Pfaffenwaldring 27                                            */
+/*            70569 Stuttgart                                               */
+/*                                                                          */
+/* History:   28.01.97    begin                                             */
 /*                                                                          */
 /* Remarks:                                                                 */
 /*                                                                          */
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -72,7 +73,7 @@
 /****************************************************************************/
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/pfile.c,v 1.17 2008/03/09 18:11:45 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -81,10 +82,9 @@
 /****************************************************************************/
 
 /****************************************************************************/
-/*D																			
-   pfile - write single (text) file from parallel processes
+/** \file
+    \brief write single (text) file from parallel processes
 
-   DESCRIPTION:
    This module provides some useful functions to write a single
    file from multiple parallel processes. It is assumed that the
    file is subdivided into several segments. Each segment consists
@@ -110,9 +110,9 @@
 
    pfile uses the Concentrate, Broadcast calls of ppif.
          
-   FILE STRUCTURE:
+   \section File Structure
 
-.vb
+\verbatim
    segment 1
       item1 ... item n1
    segment 2
@@ -120,38 +120,33 @@
    ...
    segment m
       item1 ... item nm   
-.ve
+\endverbatim
 
-D*/																			
+*/
 /****************************************************************************/
 
 /****************************************************************************/
-/*D																			
-   pfile_open - open a parallel file
-
-   SYNOPSIS:
-   PFILE *pfile_open (char *name);
+/** \brief Open a parallel file
 
-   PARAMETERS:
-.  name - filename, relative paths are allowed
+ \param name - filename, relative paths are allowed
 
-   DESCRIPTION:
    Allocates a new PFILE data structure on all processors and
    returns a pointer to it. This function has to be called by
    all processes, but the file is only opened on the master.
    The PFILE data structure contains a buffer. The size of
    the buffer can be adjusted in pfile.h .
 
-   RETURN VALUE:
-.n NULL if any errors are encountered, this is a global state
-.n valid pointer if allocate successful on all processors
+   \return <ul>
+   <li> NULL if any errors are encountered, this is a global state </li>
+   <li> valid pointer if allocate successful on all processors </li>
+   </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_sync', 'pfile_puts', 'pfile_close'
-D*/																			
+*/
 /****************************************************************************/
 
-PFILE * NS_PREFIX pfile_open (char *name)
+NS_DIM_PREFIX PFILE * NS_DIM_PREFIX pfile_open (char *name)
 {
 #ifndef ModelP
 	return( (PFILE *) fileopen(name,"w") );
@@ -206,33 +201,28 @@
 
 
 /****************************************************************************/
-/*D																			
-   pfile_master_puts - write string to file immediately
+/** \brief Write string to file immediately
 
-   SYNOPSIS:
-   INT pfile_master_puts (PFILE *pf, char *s);
+ \param pf - pointer to parallel file
+ \param s - item to be written
 
-   PARAMETERS:
-.  pf - pointer to parallel file
-.  s - item to be written
-
-   DESCRIPTION:
    Enables the master process to write a string to the
    output file immediately. This function should be called
    immediately after pfile_open or pfile_sync. Otherwise
    the position of the string withinm the segment is not
    predictable.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> >0 if any errors are encountered, this is a LOCAL state </li>
+   </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_sync', 'pfile_open', 'pfile_close'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_master_puts (PFILE *pf, char *s)
+INT NS_DIM_PREFIX pfile_master_puts (PFILE *pf, char *s)
 {
 #ifndef ModelP
 	fputs(s,(FILE *) pf);
@@ -246,26 +236,20 @@
 
 #ifdef ModelP
 /****************************************************************************/
-/*																			
-   flush_buffer - flush buffer in global sequence
-
-   SYNOPSIS:
-static void flush_buffer (PFILE *pf)
+/** \brief Flush buffer in global sequence
 
-   PARAMETERS:
-.  pf - pointer to parallel file
+  \param pf - pointer to parallel file
 
-   DESCRIPTION:
+  \return <ul>
+ <li> 1 if all processors had local.nchars==0 </li>
+ <li> 0 else </li>
+ </ul>
 
-   RETURN VALUE:
-.n 1 if all processors had local.nchars==0
-.n 0 else
-
-   SEE ALSO:
+   \sa
    'pfile_sync', 'pfile_open', 'pfile_close'
-*/																			
+*/
 /****************************************************************************/
-static INT flush_buffer (PFILE *pf)
+static INT flush_buffer (NS_DIM_PREFIX PFILE *pf)
 {
 	INT i,j,min_key,min_index,finish=0;
 	char *buffer;
@@ -278,7 +262,7 @@
 	for (i=0; i<degree; i++)
 		if (!pf->valid_state[i])
 		{
-			GetConcentrate(i,pf->state+i,sizeof(PFILE_STATE));
+			GetConcentrate(i,pf->state+i,sizeof(NS_DIM_PREFIX PFILE_STATE));
 			pf->valid_state[i] = 1;
 #ifdef LOCAL_DEBUG
 			UserWriteF("receiving state from %d: n=%d, fst=%d, lst=%d\n",
@@ -313,7 +297,7 @@
 		if (me == master)
 			finish = 1; /* now all are finished */
 		else {
-			Concentrate(&pf->local,sizeof(PFILE_STATE)); /* has nchars==0 !  */
+			Concentrate(&pf->local,sizeof(NS_DIM_PREFIX PFILE_STATE)); /* has nchars==0 !  */
 			GetSpread(&finish,sizeof(INT));			     /* the global state */
 		}
 		
@@ -365,7 +349,7 @@
 		if (nchars>0) fputs(buffer,pf->stream);
 	}
 	else {
-		Concentrate(pf->state+min_index,sizeof(PFILE_STATE)); /* send state */
+		Concentrate(pf->state+min_index,sizeof(NS_DIM_PREFIX PFILE_STATE)); /* send state */
 		Concentrate(buffer,nchars+1);      /* send data  */
 	}
 	
@@ -377,17 +361,11 @@
 
 
 /****************************************************************************/
-/*D																			
-   pfile_puts - write string to parallel file
-
-   SYNOPSIS:
-   INT pfile_puts (PFILE *pf, char *s);
+/** \brief Write string to parallel file
 
-   PARAMETERS:
-.  pf - pointer to parallel file
-.  s - item to be written
+ \param pf - pointer to parallel file
+ \param s - item to be written
 
-   DESCRIPTION:
    Writes a string to a previously opened parallel file.
    It is ensured that the string s is written as a whole to
    the output file. The string is appended to the output buffer
@@ -395,16 +373,17 @@
 
    Any number of calls to pfile_puts may be issued by a single process.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> >0 if any errors are encountered, this is a LOCAL state </li>
+   </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_sync', 'pfile_open', 'pfile_close'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_puts (PFILE *pf, char *s)
+INT NS_DIM_PREFIX pfile_puts (PFILE *pf, char *s)
 {
 #ifndef ModelP
 	fputs(s,(FILE *) pf);
@@ -446,37 +425,8 @@
 
 
 
-/****************************************************************************/
-/*D																			
-   pfile_tagged_puts - write tagged string to parallel file
-
-   SYNOPSIS:
-   INT pfile_tagged_puts (PFILE *pf, char *s, INT key);
-
-   PARAMETERS:
-.  pf - pointer to parallel file
-.  s - item to be written
-.  key - key for this item
-
-   DESCRIPTION:
-   Writes a tagged item to the output file. Tags should be globally
-   unique and locally increasing within each segment. If tags
-   are out of order, a warning is issued and the item is treated
-   as in order.
-
-   Any number of calls to pfile_tagged_puts may be issued by a single process.
-
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
-
-   SEE ALSO:
-   'pfile_sync', 'pfile_open', 'pfile_close'
-D*/																			
-/****************************************************************************/
-
 #ifdef ModelP
-static INT append_buffer (PFILE *pf, char *s, INT key)
+static INT append_buffer (NS_DIM_PREFIX PFILE *pf, char *s, INT key)
 {
 	INT n;
 
@@ -510,7 +460,31 @@
 }
 #endif
 	
-INT NS_PREFIX pfile_tagged_puts (PFILE *pf, char *s, INT key)
+/****************************************************************************/
+/** \brief Write tagged string to parallel file
+
+ \param pf - pointer to parallel file
+ \param s - item to be written
+ \param key - key for this item
+
+   Writes a tagged item to the output file. Tags should be globally
+   unique and locally increasing within each segment. If tags
+   are out of order, a warning is issued and the item is treated
+   as in order.
+
+   Any number of calls to pfile_tagged_puts may be issued by a single process.
+
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> >0 if any errors are encountered, this is a LOCAL state </li>
+   </ul>
+
+   \sa
+   'pfile_sync', 'pfile_open', 'pfile_close'
+*/
+/****************************************************************************/
+
+INT NS_DIM_PREFIX pfile_tagged_puts (PFILE *pf, char *s, INT key)
 {
 #ifndef ModelP
 	fputs(s,(FILE *) pf);
@@ -545,31 +519,26 @@
 
 
 /****************************************************************************/
-/*D																			
-   pfile_sync - indicate end of file segment
-
-   SYNOPSIS:
-   INT pfile_sync (PFILE *pf);
+/** \brief Indicate end of file segment
 
-   PARAMETERS:
-.  pf - pointer to parallel file
+ \param pf - pointer to parallel file
 
-   DESCRIPTION:
    At the end of a segment this function has to be called by
    all processes. The function returns when all process
    have reached the end the current segment. Then the segment
    counter is increased.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+ <li> 0 if ok </li>
+ <li> >0 if any errors are encountered, this is a LOCAL state </li>
+ </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_puts', 'pfile_open', 'pfile_close'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_sync (PFILE *pf)
+INT NS_DIM_PREFIX pfile_sync (PFILE *pf)
 {
 #ifdef ModelP
 	/* wait until all processors reach end of segment */
@@ -582,31 +551,26 @@
 
 
 /****************************************************************************/
-/*D																			
-   pfile_close - indicate end of file
-
-   SYNOPSIS:
-   INT pfile_close (PFILE *pf);
+/** \brief Indicate end of file
 
-   PARAMETERS:
-.  pf - pointer to parallel file
+ \param pf - pointer to parallel file
 
-   DESCRIPTION:
    At the end of the file this function has to be called by
    all processes. The function returns when all process
    have reached the end of file. Then the file is closed
    and buffer space is released.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+ <li> 0 if ok </li>
+ <li> >0 if any errors are encountered, this is a LOCAL state </li>
+ </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_puts', 'pfile_open', 'pfile_sync'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_close (PFILE *pf)
+INT NS_DIM_PREFIX pfile_close (PFILE *pf)
 {
 #ifdef ModelP
 	/* wait until all processors reach end of segment */
@@ -625,16 +589,10 @@
 }
 
 /****************************************************************************/
-/*D																			
-   pfile_open_bin - open a parallel binary file
+/** \brief Open a parallel binary file
 
-   SYNOPSIS:
-   PFILE_BIN *pfile_open_bin (char *name);
+ \param name - filename, relative paths are allowed
 
-   PARAMETERS:
-.  name - filename, relative paths are allowed
-
-   DESCRIPTION:
    Allocates a new PFILE_BIN data structure on all processors and
    returns a pointer to it. This function has to be called by
    all processes, but the file is only opened on the master.
@@ -642,16 +600,17 @@
    and one for floats. The size of the buffer can be adjusted
    in pfile.h .
 
-   RETURN VALUE:
-.n NULL if any errors are encountered, this is a global state
-.n valid pointer if allocate successful on all processors
+   \return <ul>
+ <li> NULL if any errors are encountered, this is a global state </li>
+ <li> valid pointer if allocate successful on all processors </li>
+ </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_sync_bin', 'pfile_close_bin'
-D*/																			
+*/
 /****************************************************************************/
 
-PFILE_BIN* NS_PREFIX pfile_open_bin (char *name)
+NS_DIM_PREFIX PFILE_BIN* NS_DIM_PREFIX pfile_open_bin (char *name)
 {
 #ifndef ModelP
 	return( (PFILE_BIN *) fileopen(name,"wb") );
@@ -704,11 +663,11 @@
 #ifdef ModelP
 /****************************************************************************/
 /* change for BYTES not finished ! */
-static INT flush_buffer_bin (PFILE_BIN *pf)
+static INT flush_buffer_bin (NS_DIM_PREFIX PFILE_BIN *pf)
 {
 	INT i,j,min_key,min_index,finish=0;
-	int *buf_int;
-	float *buf_float;
+	INT *buf_INT;
+	FLOAT *buf_FLOAT;
 	INT nints, nfloats;
 	
 	/* copy local state to array */
@@ -717,7 +676,7 @@
 	/* update downtree states */
 	for (i=0; i<degree; i++)
 		if (!pf->valid_state[i]) {
-			GetConcentrate(i,pf->state+i,sizeof(PFILE_STATE_BIN));
+			GetConcentrate(i,pf->state+i,sizeof(NS_DIM_PREFIX PFILE_STATE_BIN));
 			pf->valid_state[i] = 1;
 #ifdef LOCAL_DEBUG
 			UserWriteF("receiving state from %d: nints=%d, nfloats=%d fst=%d, lst=%d\n",
@@ -749,7 +708,7 @@
 		if (me == master)
 			finish = 1; /* now all are finished */
 		else {
-			Concentrate(&pf->local,sizeof(PFILE_STATE_BIN)); /* has (nints && nfloats)==0 !  */
+			Concentrate(&pf->local,sizeof(NS_DIM_PREFIX PFILE_STATE_BIN)); /* has (nints && nfloats)==0 !  */
 			GetSpread(&finish,sizeof(INT));			         /* the global state */
 		}
 		
@@ -778,35 +737,35 @@
 #ifdef LOCAL_DEBUG
 		UserWriteF("Writing my own buffer, nints=%d, nfloats=%d\n",pf->local.nints,pf->local.nfloats);
 #endif
-		buf_int = pf->buf_int;
-		buf_float = pf->buf_float;
+		buf_INT = pf->buf_INT;
+		buf_FLOAT = pf->buf_FLOAT;
 		nints = pf->local.nints;
 		nfloats = pf->local.nfloats;
 		pf->local.nints = pf->local.nfloats = 0;  /* buffer is empty again */
 		pf->local.first_key = pf->local.last_key = 0;
 	} else {
 		/* fetch downtree data, we have only state ! */
-		GetConcentrate(min_index,pf->buf_int2,pf->state[min_index].nints*sizeof(int));
-		GetConcentrate(min_index,pf->buf_float2,pf->state[min_index].nfloats*sizeof(float));
+		GetConcentrate(min_index,pf->buf_INT2,pf->state[min_index].nints*sizeof(INT));
+		GetConcentrate(min_index,pf->buf_FLOAT2,pf->state[min_index].nfloats*sizeof(FLOAT));
 #ifdef LOCAL_DEBUG
 		UserWriteF("Writing buffer from %d, nints=%d, nfloats=%d\n",/
 				   min_index,pf->state[min_index].nints,pf->state[min_index].nfloats);
 #endif
-		buf_int = pf->buf_int2;
-		buf_float = pf->buf_float2;
+		buf_INT = pf->buf_INT2;
+		buf_FLOAT = pf->buf_FLOAT2;
 		nints = pf->state[min_index].nints;
 		nfloats = pf->state[min_index].nfloats;
 		pf->valid_state[min_index] = 0; /* get new state next time */
 	}
 	/* now process data */
 	if (me==master) {
-		if (nints>0) fwrite(buf_int, sizeof(int), nints, pf->stream);
-		if (nfloats>0) fwrite(buf_float, sizeof(float), nfloats, pf->stream);
+		if (nints>0) fwrite(buf_INT, sizeof(INT), nints, pf->stream);
+		if (nfloats>0) fwrite(buf_FLOAT, sizeof(FLOAT), nfloats, pf->stream);
 	}
 	else {
-		Concentrate(pf->state+min_index,sizeof(PFILE_STATE_BIN)); /* send state */
-		Concentrate(buf_int,nints*sizeof(int));                   /* send INT data  */
-		Concentrate(buf_float,nfloats*sizeof(float));             /* send FLOAT data  */
+		Concentrate(pf->state+min_index,sizeof(NS_DIM_PREFIX PFILE_STATE_BIN)); /* send state */
+		Concentrate(buf_INT,nints*sizeof(INT));                   /* send INT data  */
+		Concentrate(buf_FLOAT,nfloats*sizeof(FLOAT));             /* send FLOAT data  */
 	}
 	
 	/* Note: While sending data uptree we don't expect to get	*/
@@ -815,44 +774,12 @@
 }
 #endif
 
-/****************************************************************************/
-/*D																			
-   pfile_tagged_write_int - write tagged sequence of integers to
-   parallel binary file
-
-   SYNOPSIS:
-   INT pfile_tagged_write_int (PFILE_BIN *pf, int *values, int n, INT key);
-
-   PARAMETERS:
-.  pf - pointer to parallel binary file
-.  values - integers to be written
-.  n - number of integers
-.  key - key for this sequence of integers
-
-   DESCRIPTION:
-   Writes a tagged item to the output file. Tags should be globally
-   unique and locally increasing within each segment. If tags
-   are out of order, a warning is issued and the item is treated
-   as in order.
-
-   Any number of calls to pfile_tagged_write_INT may be issued by
-   a single process.
-
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
-
-   SEE ALSO:
-   'pfile_sync_bin', 'pfile_open_bin', 'pfile_close_bin'
-D*/																			
-/****************************************************************************/
-
 #ifdef ModelP
-static INT append_buffer_bin_int (PFILE_BIN *pf, int *values, int n, INT key)
+static INT append_buffer_bin_INT (NS_DIM_PREFIX PFILE_BIN *pf, INT *values, int n, INT key)
 {
 	int i;
 #ifdef LOCAL_DEBUG
-	UserWriteF("appending %d ints with key %d, nints=%d, lst=%d\n",n,key,
+	UserWriteF("appending %d INTs with key %d, nints=%d, lst=%d\n",n,key,
 		pf->local.nints,pf->local.last_key);
 #endif	
 	if (n+pf->local.nints<PFILE_BUFFER_SIZE)
@@ -862,7 +789,7 @@
 		
 		/* append to buffer */
 		for (i=0; i<n; i++)
-			pf->buf_int[pf->local.nints+i]=values[i];
+			pf->buf_INT[pf->local.nints+i]=values[i];
 		pf->local.nints += n;
 		
 		/* update last key */
@@ -881,33 +808,59 @@
 }
 #endif
 
-INT NS_PREFIX pfile_tagged_write_int (PFILE_BIN *pf, int *values, int n, INT key)
+/****************************************************************************/
+/** \brief Write tagged sequence of integers to parallel binary file
+
+ \param pf - pointer to parallel binary file
+ \param values - integers to be written
+ \param n - number of integers
+ \param key - key for this sequence of integers
+
+   Writes a tagged item to the output file. Tags should be globally
+   unique and locally increasing within each segment. If tags
+   are out of order, a warning is issued and the item is treated
+   as in order.
+
+   Any number of calls to pfile_tagged_write_INT may be issued by
+   a single process.
+
+   \return <ul>
+ <li> 0 if ok </li>
+ <li> >0 if any errors are encountered, this is a LOCAL state </li>
+ </ul>
+
+   \sa
+   'pfile_sync_bin', 'pfile_open_bin', 'pfile_close_bin'
+*/
+/****************************************************************************/
+
+INT NS_DIM_PREFIX pfile_tagged_write_INT (PFILE_BIN *pf, INT *values, int n, INT key)
 {
 #ifndef ModelP
-	fwrite(values, sizeof(int), n, (FILE *) pf);
+	fwrite(values, sizeof(INT), n, (FILE *) pf);
 #else
 	/* check order of keys */
 	if ( (pf->local.nints > 0) && (key < pf->local.last_key) )
 	{
-		PrintErrorMessage('W',"pfile_tagged_write_int","keys locally not ordered");
+		PrintErrorMessage('W',"pfile_tagged_write_INT","keys locally not ordered");
 		key = pf->local.last_key+1; /* treat as in order ! */
 	}
 
 	if ( (pf->local.nints > 0) && (key > pf->local.last_key+1) ) /* not consecutive case */
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_int","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
 
-	if (!append_buffer_bin_int(pf,values,n,key))
+	if (!append_buffer_bin_INT(pf,values,n,key))
 	{
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_int","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
-		append_buffer_bin_int(pf,values,n,key);
+		append_buffer_bin_INT(pf,values,n,key);
 	}
 #endif
 	return(0);
@@ -915,11 +868,11 @@
 
 /****************************************************************************/
 #ifdef ModelP
-static INT append_buffer_bin_float (PFILE_BIN *pf, float *values, int n, INT key)
+static INT append_buffer_bin_FLOAT (NS_DIM_PREFIX PFILE_BIN *pf, FLOAT *values, int n, INT key)
 {
 	int i;
 #ifdef LOCAL_DEBUG
-	UserWriteF("appending %d floats with key %d, nfloats=%d, lst=%d\n",n,key,
+	UserWriteF("appending %d FLOATs with key %d, nfloats=%d, lst=%d\n",n,key,
 		pf->local.nfloats,pf->local.last_key);
 #endif	
 	if (n+pf->local.nfloats<PFILE_BUFFER_SIZE)
@@ -929,7 +882,7 @@
 		
 		/* append to buffer */
 		for (i=0; i<n; i++)
-			pf->buf_float[pf->local.nfloats+i]=values[i];
+			pf->buf_FLOAT[pf->local.nfloats+i]=values[i];
 		pf->local.nfloats += n;
 		
 		/* update last key */
@@ -948,33 +901,33 @@
 }
 #endif
 
-INT NS_PREFIX pfile_tagged_write_float (PFILE_BIN *pf, float *values, int n, INT key)
+INT NS_DIM_PREFIX pfile_tagged_write_FLOAT (PFILE_BIN *pf, FLOAT *values, int n, INT key)
 {
 #ifndef ModelP
-	fwrite(values, sizeof(float), n, (FILE *) pf);
+	fwrite(values, sizeof(FLOAT), n, (FILE *) pf);
 #else
 	/* check order of keys */
 	if ( (pf->local.nfloats > 0) && (key < pf->local.last_key) )
 	{
-		PrintErrorMessage('W',"pfile_tagged_write_float","keys locally not ordered");
+		PrintErrorMessage('W',"pfile_tagged_write_INT","keys locally not ordered");
 		key = pf->local.last_key+1; /* treat as in order ! */
 	}
 
 	if ( (pf->local.nfloats > 0) && (key > pf->local.last_key+1) ) /* not consecutive case */
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_float","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
 
-	if (!append_buffer_bin_float(pf,values,n,key))
+	if (!append_buffer_bin_FLOAT(pf,values,n,key))
 	{
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_float","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
-		append_buffer_bin_float(pf,values,n,key);
+		append_buffer_bin_FLOAT(pf,values,n,key);
 	}
 #endif
 	return(0);
@@ -982,11 +935,11 @@
 
 /****************************************************************************/
 #ifdef ModelP
-static INT append_buffer_bin_byte (PFILE_BIN *pf, unsigned char *values, int n, INT key)
+static INT append_buffer_bin_BYTE (NS_DIM_PREFIX PFILE_BIN *pf, unsigned char *values, int n, INT key)
 {
 	int i;
 #ifdef LOCAL_DEBUG
-	UserWriteF("appending %d bytess with key %d, nbytes=%d, lst=%d\n",n,key,
+	UserWriteF("appending %d BYTEs with key %d, nbytes=%d, lst=%d\n",n,key,
 		pf->local.nbytes,pf->local.last_key);
 #endif	
 	if (n+pf->local.nbytes<PFILE_BUFFER_SIZE)
@@ -996,7 +949,7 @@
 		
 		/* append to buffer */
 		for (i=0; i<n; i++)
-			pf->buf_byte[pf->local.nbytes+i]=values[i];
+			pf->buf_BYTE[pf->local.nbytes+i]=values[i];
 		pf->local.nbytes += n;
 		
 		/* update last key */
@@ -1015,7 +968,7 @@
 }
 #endif
 
-INT NS_PREFIX pfile_tagged_write_byte (PFILE_BIN *pf, unsigned char *values, int n, INT key)
+INT NS_DIM_PREFIX pfile_tagged_write_BYTE (PFILE_BIN *pf, unsigned char *values, int n, INT key)
 {
 #ifndef ModelP
 	fwrite(values, sizeof(unsigned char), n, (FILE *) pf);
@@ -1023,56 +976,51 @@
 	/* check order of keys */
 	if ( (pf->local.nbytes > 0) && (key < pf->local.last_key) )
 	{
-		PrintErrorMessage('W',"pfile_tagged_write_byte","keys locally not ordered");
+		PrintErrorMessage('W',"pfile_tagged_write_INT","keys locally not ordered");
 		key = pf->local.last_key+1; /* treat as in order ! */
 	}
 
 	if ( (pf->local.nbytes > 0) && (key > pf->local.last_key+1) ) /* not consecutive case */
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_byte","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
 
-	if (!append_buffer_bin_byte(pf,values,n,key))
+	if (!append_buffer_bin_BYTE(pf,values,n,key))
 	{
 		if (flush_buffer_bin(pf))
 		{
-			PrintErrorMessage('E',"pfile_tagged_write_byte","unxepected finish");
+			PrintErrorMessage('E',"pfile_tagged_write_INT","unxepected finish");
 			return(1);
 		}
-		append_buffer_bin_byte(pf,values,n,key);
+		append_buffer_bin_BYTE(pf,values,n,key);
 	}
 #endif
 	return(0);
 }
 
 /****************************************************************************/
-/*D																			
-   pfile_sync_bin - indicate end of binary file segment
+/** \brief Indicate end of binary file segment
 
-   SYNOPSIS:
-   INT pfile_sync_bin (PFILE_BIN *pf);
+ \param pf - pointer to parallel binary file
 
-   PARAMETERS:
-.  pf - pointer to parallel binary file
-
-   DESCRIPTION:
    At the end of a segment this function has to be called by
    all processes. The function returns when all process
    have reached the end the current segment. Then the segment
    counter is increased.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> >0 if any errors are encountered, this is a LOCAL state </li>
+   </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_open_bin', 'pfile_close_bin'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_sync_bin (PFILE_BIN *pf)
+INT NS_DIM_PREFIX pfile_sync_bin (PFILE_BIN *pf)
 { 
 #ifdef ModelP
 	while (!flush_buffer_bin(pf));
@@ -1081,31 +1029,26 @@
 }
 
 /****************************************************************************/
-/*D																			
-   pfile_close_bin - indicate end of binary file
-
-   SYNOPSIS:
-   INT pfile_close_bin (PFILE_BIN *pf);
+/** \brief Indicate end of binary file
 
-   PARAMETERS:
-.  pf - pointer to parallel binary file
+ \param pf - pointer to parallel binary file
 
-   DESCRIPTION:
    At the end of the file this function has to be called by
    all processes. The function returns when all process
    have reached the end of file. Then the file is closed
    and buffer space is released.
 
-   RETURN VALUE:
-.n 0 if ok.
-.n >0 if any errors are encountered, this is a LOCAL state
+   \return <ul>
+ <li> 0 if ok </li>
+ <li> >0 if any errors are encountered, this is a LOCAL state </li>
+ </ul>
 
-   SEE ALSO:
+   \sa
    'pfile_open_bin', 'pfile_sync_bin'
-D*/																			
+*/
 /****************************************************************************/
 
-INT NS_PREFIX pfile_close_bin (PFILE_BIN *pf)
+INT NS_DIM_PREFIX pfile_close_bin (PFILE_BIN *pf)
 {
 #ifndef ModelP
 	fclose( (FILE *) pf);
diff -ruN ug-orig/low/pfile.h ug-patched/low/pfile.h
--- ug-orig/low/pfile.h	2008-04-16 14:56:11.000000000 +0200
+++ ug-patched/low/pfile.h	2009-04-29 14:30:36.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/pfile.h,v 1.6 2008/04/16 12:56:11 lampe Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -35,7 +35,7 @@
 #include "compiler.h"
 #include "namespace.h"
 
-START_UG_NAMESPACE
+START_UGDIM_NAMESPACE
 
 #define PFILE_BUFFER_SIZE	16384
 #define PFILE_MAX_TREE		32
@@ -72,12 +72,12 @@
 	PFILE_STATE_BIN state[PFILE_MAX_TREE+1];
 	INT robin;
 #ifdef ModelP
-	int buf_int[PFILE_BUFFER_SIZE];
-	int buf_int2[PFILE_BUFFER_SIZE];
-	float buf_float[PFILE_BUFFER_SIZE];
-	float buf_float2[PFILE_BUFFER_SIZE];
-	unsigned char buf_byte[PFILE_BUFFER_SIZE];
-	unsigned char buf_byte2[PFILE_BUFFER_SIZE];
+	INT buf_INT[PFILE_BUFFER_SIZE];
+	INT buf_INT2[PFILE_BUFFER_SIZE];
+	FLOAT buf_FLOAT[PFILE_BUFFER_SIZE];
+	FLOAT buf_FLOAT2[PFILE_BUFFER_SIZE];
+	unsigned char buf_BYTE[PFILE_BUFFER_SIZE];
+	unsigned char buf_BYTE2[PFILE_BUFFER_SIZE];
 #endif
 } PFILE_BIN ;
  
@@ -94,13 +94,13 @@
 INT    pfile_sync               (PFILE *pf);
 INT    pfile_close              (PFILE *pf);
 PFILE_BIN *pfile_open_bin           (char *name);
-INT        pfile_tagged_write_int   (PFILE_BIN *pf, int *values, int n, INT key);
-INT        pfile_tagged_write_float (PFILE_BIN *pf, float *values, int n, INT key);
-/* TODO: pfile_tagged_write_byte works only in seq Mode !!! */
-INT        pfile_tagged_write_byte  (PFILE_BIN *pf, unsigned char *values, int n, INT key);
+INT        pfile_tagged_write_INT   (PFILE_BIN *pf, INT *values, int n, INT key);
+INT        pfile_tagged_write_FLOAT (PFILE_BIN *pf, FLOAT *values, int n, INT key);
+/* TODO: pfile_tagged_write_BYTE works only in seq Mode !!! */
+INT        pfile_tagged_write_BYTE  (PFILE_BIN *pf, unsigned char *values, int n, INT key);
 INT        pfile_sync_bin           (PFILE_BIN *pf);
 INT        pfile_close_bin          (PFILE_BIN *pf);
 
-END_NAMESPACE
+END_UGDIM_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/scan.c ug-patched/low/scan.c
--- ug-orig/low/scan.c	2006-06-02 17:34:14.000000000 +0200
+++ ug-patched/low/scan.c	2006-06-02 17:38:35.000000000 +0200
@@ -73,7 +73,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/scan.c,v 1.16 2006/06/02 15:34:14 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
diff -ruN ug-orig/low/scan.h ug-patched/low/scan.h
--- ug-orig/low/scan.h	2004-09-08 15:33:35.000000000 +0200
+++ ug-patched/low/scan.h	2009-05-07 10:00:28.000000000 +0200
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/scan.h,v 1.10 2004/09/08 13:33:35 thimo Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -92,6 +92,6 @@
 INT ReadArgvMEM (const char *name, MEM *mem_size, INT argc, char **argv);
 INT ReadArgvOption (const char *name, INT argc, char **argv);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/smallvecs.h ug-patched/low/smallvecs.h
--- ug-orig/low/smallvecs.h	2004-09-02 13:45:58.000000000 +0200
+++ ug-patched/low/smallvecs.h	2004-09-02 13:45:58.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: smallvecs.h,v 1.1 2004/09/02 11:45:58 thimo Exp $ */
+/* $Id: smallvecs.h 7770 2004-09-02 11:45:58Z thimo $ */
 
 /*
 
diff -ruN ug-orig/low/tree.c ug-patched/low/tree.c
--- ug-orig/low/tree.c	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/tree.c	2008-12-19 11:06:12.000000000 +0100
@@ -23,6 +23,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <limits.h>
 #include <stdlib.h>
 #ifndef __MWCW__
@@ -57,32 +58,25 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/tree.c,v 1.8 2004/07/21 09:19:50 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header: /var/lib/cvs/UG/ug/low/tree.c,v 1.8 2004-07-21 09:19:50 sander Exp $",UG_RCS_STRING);
 
 
 /****************************************************************************/
-/*D
-   CreateTree - Create root of search tree
+/** \brief Create root of search tree
 
-   SYNOPSIS:
-   TREE *CreateTree(HEAP *theHeap, INT dim, DOUBLE *posrange)
-
-   PARAMETERS:
 .  HEAP - reference to Heap to get memory from
 .  dim - dimension of underlaying space
 .  posrange - array of ranges of positions in order x1min,x1max,x2min,...
 
-   DESCRIPTION:
    This function creates a new search tree.
 
    For dim equal to one the tree is a binary tree, for dim equal to two
    a quarttree...
 
    RETURN VALUE:
-   TREE *
 .n     pointer to the tree
 .n     NULL if an error occurred
-D*/
+*/
 /****************************************************************************/
 TREE *CreateTree (HEAP *theHeap, INT dim, DOUBLE *posrange)
 {
@@ -109,21 +103,14 @@
 }
 
 /****************************************************************************/
-/*D
-   DeleteTree - Removes a search tree
-
-   SYNOPSIS:
-   INT DeleteTree(TREE *theTree);
+/** \brief Removes a search tree
 
-   PARAMETERS:
 .  theTree - reference to the tree
 
-   DESCRIPTION:
    This function deletes a search tree and frees all the memory
    occupied by the tree and its objects.
 
    RETURN VALUE:
-   INT
 .n     0 if okay
 .n     1 if an error occurred
 D*/
@@ -200,26 +187,18 @@
 }
 
 /****************************************************************************/
-/*D
-   SearchInsertPoint - Gets position of insert point
+/** \brief Gets position of insert point
 
-   SYNOPSIS:
-   INT SearchInsertPoint(TREE *theTree, DOUBLE *position,
-                                  TREE_ENTRY **insertPoint)
-
-   PARAMETERS:
 .  theTree - reference to the tree
 .  Position - position of the object
 . insertPoint - Pointer to result
 
-   DESCRIPTION:
    This function searches the tree for the point for insertation of a new
    object. *insertPoint points to the insertation place and the return value
    indicates if the insertation point is at a free end of the tree or already
    occupied.
 
    RETURN VALUE:
-   INT
 .n 0 - tree not correct
 .n 1 - insertation point is a free end
 .n 2 - place is occupied
@@ -260,24 +239,17 @@
 
 
 /****************************************************************************/
-/*D
-   InsertinTree - Inserts object in search tree
-
-   SYNOPSIS:
-   void *InsertinTree(TREE *theTree, DOUBLE *Position);
+/** \brief Inserts object in search tree
 
-   PARAMETERS:
 .  theTree - reference to the tree
 .  Position - position of the object
 .  obj - pointer to object
 
-   DESCRIPTION:
    This function changes the search tree for a new object at Position.
    The tree leaf will hold a pointer to the object which has to exist
    before.
 
    RETURN VALUE:
-   INT
 .n     error code
 .n     0 if okay
 D*/
@@ -427,25 +399,18 @@
 }
 
 /****************************************************************************/
-/*D
-   DeleteObjinTree - Deletes object in search tree
-
-   SYNOPSIS:
-   void *DeleteObjinTree(TREE *theTree, DOUBLE *Position);
+/** \brief Deletes object in search tree
 
-   PARAMETERS:
 .  theTree - reference to the tree
 .  Position - position of the object
 
-   DESCRIPTION:
    This function deletes the tree leaf at Position and all
    unnecassary tree nodes from the search tree.
 
    RETURN VALUE:
-   void *
 .n     pointer to object at delete position
 .n     NULL if none or error occured
-D*/
+*/
 /****************************************************************************/
 void *DeleteObjinTree (TREE *theTree, DOUBLE *Position)
 {
@@ -534,29 +499,21 @@
 }
 
 /****************************************************************************/
-/*D
-   GetFirstLeafinQuader,GetNextLeafinQuader - Gives objects whitch are inside a hyper-rectangular
-
-   SYNOPSIS:
-   void *GetFirstLeafinQuader(TREE *theTree, DOUBLE *ll, DOUBLE *ur);
-.n void *GetNextLeafinQuader(TREE *theTree);
+/** \brief Gives objects whitch are inside a hyper-rectangular
 
-   PARAMETERS:
 .  theTree - reference to the tree
 .  ll: lower left ... corner coordinates
 .  ur: upper right ... corner coordinates
 
-   DESCRIPTION:
    GetFirstLeafinQuader initializes the fifo for a search and searches for
    a first leaf entry in the tree theTree which is lying inside the quader
    with lower left ... corner ll and upper right ... corner ur.
 .n GetNextLeafinQuader searches for the next object in the quader.
 
    RETURN VALUE:
-   INT
 .n     Pointer to the TREE_ENTRY
 .n     NULL if no leaf entry inside exists or an error occured
-D*/
+*/
 /****************************************************************************/
 TREE_ENTRY *GetFirstLeafinQuader(TREE *theTree, DOUBLE *ll, DOUBLE *ur)
 {
@@ -644,6 +601,23 @@
 	return(NULL);
 }
 
+/****************************************************************************/
+/** \brief Gives objects whitch are inside a hyper-rectangular
+
+.  theTree - reference to the tree
+.  ll: lower left ... corner coordinates
+.  ur: upper right ... corner coordinates
+
+   GetFirstLeafinQuader initializes the fifo for a search and searches for
+   a first leaf entry in the tree theTree which is lying inside the quader
+   with lower left ... corner ll and upper right ... corner ur.
+.n GetNextLeafinQuader searches for the next object in the quader.
+
+   RETURN VALUE:
+.n     Pointer to the TREE_ENTRY
+.n     NULL if no leaf entry inside exists or an error occured
+*/
+/****************************************************************************/
 TREE_ENTRY *GetNextLeafinQuader(TREE *theTree)
 {
 	INT i, dim, inside;
diff -ruN ug-orig/low/tree.h ug-patched/low/tree.h
--- ug-orig/low/tree.h	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/tree.h	2009-05-07 10:00:28.000000000 +0200
@@ -15,7 +15,7 @@
 /*                                                                          */
 /****************************************************************************/
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/tree.h,v 1.4 2004/07/21 09:19:50 sander Exp $
+$Header$
 */
 /****************************************************************************/
 /*                                                                          */
@@ -126,6 +126,6 @@
 TREE_ENTRY *GetNextLeafinQuader(TREE *theTree);
 
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/ugenv.c ug-patched/low/ugenv.c
--- ug-orig/low/ugenv.c	2006-04-18 10:55:47.000000000 +0200
+++ ug-patched/low/ugenv.c	2009-11-18 14:35:32.000000000 +0100
@@ -24,6 +24,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -56,12 +57,14 @@
 /*                                                                          */
 /****************************************************************************/
 
-static HEAP *envHeap=NULL;              /* heap used for the environment    */
-static ENVDIR *path[MAXENVPATH];        /* path to current directory        */
+/** \brief Path to current directory
+    
+We only need the first entry to be zero-initialized. */
+static ENVDIR *path[MAXENVPATH] = {NULL};
 static int pathIndex;                   /* entry to path array              */
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/ugenv.c,v 1.21 2006/04/18 08:55:47 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /** \brief Initialize the Environment and the heap
@@ -78,23 +81,17 @@
 */
 /****************************************************************************/
 
-INT NS_PREFIX InitUgEnv (INT heapSize)
+INT NS_PREFIX InitUgEnv ()
 {
-    void *buffer;
     ENVDIR *root;
 
     /* Environment heap already initialized? */
-    if (envHeap)
+    if (path[0])
         return 0;
-    
-    /* allocate memory from system */
-    if ((buffer=malloc(heapSize))==NULL) return(__LINE__);
-    
-    /* initialize heap structure */
-    if ((envHeap=NewHeap(GENERAL_HEAP,heapSize,buffer))==NULL) return(__LINE__);
-    
+
     /* allocate root directory */
-    if ((root=(ENVDIR*)GetMem(envHeap,sizeof(ENVDIR),0))==NULL) return(__LINE__);
+    if ((root=(ENVDIR*)malloc(sizeof(ENVDIR)))==NULL) return(__LINE__);
+
     root->type = ROOT_DIR;
     root->next = root->previous = root->down = NULL;
     strcpy(root->name,"root");
@@ -107,14 +104,6 @@
     return(0);
 }
 
-INT NS_PREFIX ExitUgEnv()
-{
-    free(envHeap);
-    envHeap = NULL;
-    return 0;
-}
-
-
 /****************************************************************************/
 /** \brief Change environment directory    
 
@@ -263,6 +252,8 @@
     /* check if name not already used in this directory */
     currentDir = path[pathIndex];
     anItem = lastItem = currentDir->down;
+
+#ifdef Debug
     while (anItem!=NULL)
     {
         if ((anItem->v.type==type)&&(strcmp(anItem->v.name,name)==0))
@@ -273,7 +264,8 @@
         lastItem = anItem;
         anItem = anItem->v.next;
     }
-    
+#endif    
+
     /* allocate memory from environment heap */
     switch (type)
     {
@@ -284,7 +276,8 @@
             if (type%2==0)
             {
                 /* new variable */
-                newItem=(ENVITEM *) GetMem(envHeap,size,0);
+                newItem=(ENVITEM*) malloc(size);
+
                 if (newItem==NULL)
 				{
 					UserWriteF("MakeEnvItem(): envHeap out of memory\n");
@@ -296,7 +289,8 @@
             {
                 /* new directory */
                 if (pathIndex+1>=MAXENVPATH) return(NULL);
-                newItem=(ENVITEM *) GetMem(envHeap,size,0);
+                newItem=(ENVITEM*) malloc(size);
+
                 if (newItem==NULL)
 				{
 					UserWriteF("MakeEnvItem(): envHeap out of memory\n");
@@ -322,10 +316,11 @@
     }
     else
     {
-        /* append to last Item */
-        lastItem->v.next = newItem;
-        newItem->v.previous = lastItem;
-        newItem->v.next = NULL;
+        /* insert before first item */
+        newItem->v.previous = NULL;
+        currentDir->down->v.previous = newItem;
+        newItem->v.next = currentDir->down;
+        currentDir->down = newItem;
     }
 
     /* return pointer to new item */
@@ -378,32 +373,12 @@
         theItem->v.next->v.previous = theItem->v.previous;
     
     /* deallocate memory */
-    DisposeMem(envHeap,theItem);
-    
+    free(theItem);
+
     /* return ok */
     return(0);
 }
 
-/****************************************************************************/
-/*D
-   RemoveEnvDir - Deallocate an environment directory
-
-   SYNOPSIS:
-   INT RemoveEnvItem (ENVITEM *theItem);
-
-   PARAMETERS:
- * @param   theItem - pointer to item
-
-   DESCRIPTION:
-   This function deallocates an environment directory.
-
-   @return <ul>
-   INT
- *   <li>     0 if OK
- *   <li>     3 if attempt is done to delete locked item.
-D*/
-/****************************************************************************/
-
 #ifndef __T3E__
 static 
 #endif
@@ -415,12 +390,28 @@
 		Next = NEXT_ENVITEM(Item);
 		if (IS_ENVDIR(Item)) 
 			RemoveEnvDirContent(ENVITEM_DOWN(Item));
-		DisposeMem(envHeap,Item);
+                free(Item);
 	}
 
     return(0);
 }
 
+/****************************************************************************/
+/** \brief Deallocate an environment directory
+
+ * @param   theItem - pointer to item
+
+   This function deallocates an environment directory.
+
+   @return <ul>
+   <li>     0 if OK
+   <li>     1 if item not found in current directory
+   <li>     2 if theItem is not a directory
+   <li>     3 if attempt is done to delete locked item
+   </ul>
+*/
+/****************************************************************************/
+
 INT NS_PREFIX RemoveEnvDir (ENVITEM *theItem)
 {
     ENVITEM *anItem;
@@ -448,7 +439,7 @@
         theItem->v.next->v.previous = theItem->v.previous;
     
     /* deallocate memory */
-    DisposeMem(envHeap,theItem);
+    free(theItem);
 
     return(0);
 }
@@ -580,11 +571,11 @@
 
 
 /****************************************************************************/
-/** \brief Allocate memory from environment heap
+/** \brief For backward compatibility: Allocate memory from environment heap
 
  * @param   size - number of bytes to be allocated
 
-   This function allocates memory from environment heap.
+ \deprecated Simply a wrapper for malloc()
 
    @return <ul>
    Pointer to allocated memory
@@ -593,37 +584,37 @@
 
 void * NS_PREFIX AllocEnvMemory (INT size)
 {
-    return(GetMem(envHeap,size,0));
+    return malloc(size);
 }
 
 /****************************************************************************/
-/** \brief Deallocate memory from environment heap 
+/** \brief For backward compatibility: Deallocate memory from environment heap 
 
  * @param   buffer - pointer to buffer previously allocated
 
-   This function deallocates memory from environment heap.
-
+ \deprecated Simply a wrapper for free()
 */
 /****************************************************************************/
 
 void  NS_PREFIX FreeEnvMemory (void *buffer)
 {
-    DisposeMem(envHeap,buffer);
+    free(buffer);
 }
 
 /****************************************************************************/
-/** \brief Print size and used of environment heap to string
+/** \brief For backward compatibility: Print size and used of environment heap to string
 
  * @param   s - string to print on
 
-   This function prints size and used of environment heap to string. 
-
+   This function used to print size and used percentage of the environment heap 
+   to a string.  Ever since the operating system heap is used this information
+   is not available anymore.
 */
 /****************************************************************************/
 
 void  NS_PREFIX EnvHeapInfo (char *s)
 {
-    sprintf(s,"   size: %ld\n   used: %ld\n",HeapSize(envHeap),HeapUsed(envHeap));
+    sprintf(s,"no heap information available\n");
 }
 
 /****************************************************************************/
@@ -665,3 +656,11 @@
 }
 
 
+INT NS_PREFIX ExitUgEnv()
+{
+    RemoveEnvDirContent((ENVITEM*)path[0]);
+    path[0] = NULL;
+    return 0;
+}
+
+
diff -ruN ug-orig/low/ugenv.h ug-patched/low/ugenv.h
--- ug-orig/low/ugenv.h	2006-06-02 17:40:38.000000000 +0200
+++ ug-patched/low/ugenv.h	2009-05-07 10:00:28.000000000 +0200
@@ -16,9 +16,39 @@
 /*                                                                          */
 /****************************************************************************/
 
+/** \file
+    \brief General data management concept in a tree structure
+
+    The environment management of ug provides the possibility to store data in
+    a tree structure.    
+    The data structures of the environment allow to create directories and items
+    of specified size. Both data structures start with a general head (among
+    others a name by which one can refer to it). The remaining memory up to the
+    specified size can be used in arbitrary way.
+    
+    The head is identical with the struct ENVVAR.
+
+    All items are members of doubly linked lists.
+    
+    The data structure for the directory ENVDIR has just an extra component to the
+    start of a list which is the directory contents (and can consist of
+    directories itself, of course).
+    
+    The tree starts with a root directory "/" and there is always a current
+    or working directory. Paths are specified in UNIX-style. The current
+    directory can be changed using 'ChangeEnvDir' while 'GetCurrentDir'
+    returns a pointer to the current directory. The routine
+    'MakeEnvItem' creates the specified item in the current directory and
+    it is possible to 'RemoveEnvItem's created previously.
+    
+    Finally 'SearchEnv' offers the possibility to hierarchically search
+    the environment tree for an item specified by its name.
+    
+*/
+
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/ugenv.h,v 1.17 2006/06/02 15:40:38 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -90,7 +120,7 @@
 /** \brief User-defined variable */
 typedef struct {
 
-    /** \brief One of the variable types above            */
+    /** \brief even number by GetNewEnvVarID           */
     INT type;
 
     /** \brief May not be changed or deleted            */
@@ -108,7 +138,7 @@
 /** \brief Directory */
 typedef struct {
 
-    /** \brief One of the directory types above         */
+    /** \brief odd number by GetNewEnvDirID        */
     INT type;
 
     /** \brief May not be changed or deleted            */
@@ -138,8 +168,8 @@
 /*                                                                          */
 /****************************************************************************/
 
-/* initialize environment with following heapSize */
-INT      InitUgEnv        (INT heapSize);
+/* initialize environment  */
+INT      InitUgEnv        ();
 
 /* Free all memory allocated for the environment */
 INT      ExitUgEnv();
@@ -182,6 +212,6 @@
 INT      GetNewEnvVarID (void);
 
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/ugfile.h ug-patched/low/ugfile.h
--- ug-orig/low/ugfile.h	2004-09-02 13:45:58.000000000 +0200
+++ ug-patched/low/ugfile.h	2010-06-29 12:23:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: ugfile.h,v 1.1 2004/09/02 11:45:58 thimo Exp $ */
+/* $Id: ugfile.h 8369 2010-06-29 10:23:53Z sander $ */
 
 /*
 
@@ -9,8 +9,6 @@
 #ifndef UG_UGFILE_H
 #define UG_UGFILE_H
 
-#include "config.h"
-
 #ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #endif
diff -ruN ug-orig/low/ugmemory.h ug-patched/low/ugmemory.h
--- ug-orig/low/ugmemory.h	2004-09-02 13:45:58.000000000 +0200
+++ ug-patched/low/ugmemory.h	2010-06-29 12:23:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: ugmemory.h,v 1.1 2004/09/02 11:45:58 thimo Exp $ */
+/* $Id: ugmemory.h 8369 2010-06-29 10:23:53Z sander $ */
 
 /*
 
@@ -18,8 +18,6 @@
 #error Internal UG-lib header, must not be used in applications!
 #endif
 
-#include "config.h"
-
 /*  try ISO header first */
 #ifdef HAVE_STDLIB_H
 # include <stdlib.h>
diff -ruN ug-orig/low/ugstrings.h ug-patched/low/ugstrings.h
--- ug-orig/low/ugstrings.h	2004-09-02 13:45:58.000000000 +0200
+++ ug-patched/low/ugstrings.h	2010-06-29 12:23:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: ugstrings.h,v 1.1 2004/09/02 11:45:58 thimo Exp $ */
+/* $Id: ugstrings.h 8369 2010-06-29 10:23:53Z sander $ */
 
 /*
 
@@ -13,8 +13,6 @@
 #error Internal UG-lib header, must not be used in applications!
 #endif
 
-#include "config.h"
-
 /*
   Try ISO C header <string.h>
 
@@ -28,7 +26,7 @@
 #if STDC_HEADERS
 # ifdef HAVE_STRING_H
 #  include <string.h>
-# elif
+# else
 #  ifdef HAVE_STRINGS_H
 #   include <strings.h>
 #  endif
diff -ruN ug-orig/low/ugstruct.c ug-patched/low/ugstruct.c
--- ug-orig/low/ugstruct.c	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/ugstruct.c	2009-04-29 15:11:55.000000000 +0200
@@ -30,6 +30,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -74,28 +75,21 @@
 static INT theStringVarID;			/* env type for String vars 			*/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/ugstruct.c,v 1.17 2004/07/21 09:19:50 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
-/*D
-   ChangeStructDir - change current structure directory
+/** \brief Change current structure directory
    
-   SYNOPSIS:
-   ENVDIR *ChangeStructDir (const char *name);
+\param name - name to which the current structure directory shall be changed
    
-   PARAMETERS:
-.  name - name to which the current structure directory shall be changed
-   
-   DESCRIPTION:
    Changes the current structure directory to the one given by name. The name is
    interpreted as starting from the previous end of the path. It is possible to
    use ".." to go to the parent directory and ":" at the beginning
    to start from the root directory.
    
-   RETURN VALUE:
-   ENVDIR *
-.n The new directory or NULL, if it was not found.
-D*/
+   \return
+   The new directory or NULL, if it was not found.
+*/
 /****************************************************************************/
 
 ENVDIR * NS_PREFIX ChangeStructDir (const char *name)
@@ -177,36 +171,29 @@
 	return(path[pathIndex]);
 }
 
+static char token[NAMESIZE]; 			/* must be global for lastnameHnd ! */
+static char nexttoken[NAMESIZE];        /* must be global for lastnameHnd ! */
+
 /****************************************************************************/
-/*D
-   FindStructDir - finds the directory with the given name or its parent
+/** \brief Finds the directory with the given name or its parent
    
-   SYNOPSIS:
-   ENVDIR *FindStructDir (const char *name, char **lastnameHnd);
+ \param name - name to be found (from current structure directory)
+ \param lastnameHnd - if not NULL it is set to a pointer to the last name
    
-   PARAMETERS:
-.  name - name to be found (from current structure directory)
-.  lastnameHnd - if not NULL it is set to a pointer to the last name
-   
-   DESCRIPTION:
    This function searchs (starting from the current structure directory)
    for the structure directory given by name and returns its adress.
    It does not change the current structure directory! If 'lastnameHnd!=NULL'
    it also sets '*lastNameHnd' to be a pointer to the last name of the directory.
    
-   SEE ALSO:
+   \sa
    strntok
    
-   RETURN VALUE:
-   ENVDIR *
-.n The directory, or NULL if not found.
-D*/
+   \return
+   The directory, or NULL if not found.
+*/
 /****************************************************************************/
 
-static char token[NAMESIZE]; 			/* must be global for lastnameHnd ! */
-static char nexttoken[NAMESIZE];        /* must be global for lastnameHnd ! */
-
-ENVDIR * NS_PREFIX FindStructDir (const char *name, char **lastnameHnd)
+ENVDIR * NS_PREFIX FindStructDir (const char *name, const char **lastnameHnd)
 {
 	ENVDIR *newPath[MAXENVPATH];
 	ENVDIR *theDir;
@@ -300,23 +287,14 @@
 }
 
 /****************************************************************************/
-/*D
-   FindStringVar - searches a string variable inside a directory/structure
+/** \brief Searches a string variable inside a directory/structure
    
-   SYNOPSIS:
-   STRVAR *FindStringVar (const ENVDIR *where, const char *name);
+ \param where - the directory to be searched
+ \param name - the name to be searched
 
-   PARAMETERS:
-.  where - the directory to be searched
-.  name - the name to be searched
-
-   DESCRIPTION:
-   See above.
-
-   RETURN VALUE:
-   STRVAR *
-.n The address of the variable or NULL, if not found.
-D*/
+   \return
+   The address of the variable or NULL, if not found.
+*/
 /****************************************************************************/
 
 STRVAR * NS_PREFIX FindStringVar (const ENVDIR *where, const char *name)
@@ -339,20 +317,14 @@
 }
 
 /****************************************************************************/
-/*D
-   FindStructure - searches a directory/structure inside a directory/structure
+/** \brief Searches a directory/structure inside a directory/structure
    
-   SYNOPSIS:
-   ENVDIR *FindStructure (const ENVDIR *where, const char *name)
+ \param where - the directory to be searched (if NULL then search is in root)
+ \param name - the name to be searched
    
-   PARAMETERS:
-.  where - the directory to be searched (if NULL then search is in root)
-.  name - the name to be searched
-   
-   RETURN VALUE:
-   ENVDIR *
-.n The address of the structure or NULL, if not found.
-D*/
+   \return
+   The address of the structure or NULL, if not found.
+*/
 /****************************************************************************/
 
 ENVDIR * NS_PREFIX FindStructure (const ENVDIR *where, const char *name)
@@ -377,28 +349,20 @@
 }
 
 /****************************************************************************/
-/*D
-    GetStringVar - Get string contained in the variable 'name'
+/** \brief Get string contained in the variable 'name'
 
-    SYNOPSIS:
-    char *GetStringVar (const char *name);
+ \param  name - name of the string variable (from the current structure directory)
 
-    PARAMETERS:
-.   name - name of the string variable (from the current structure directory)
-
-    DESCRIPTION:
     This function returns the string contained in the variable 'name'.	
 
-    RETURN VALUE:
-    char *
-.n  pointer to the string
-.n  NULL if not found
-D*/
+    \return
+   Pointer to the string, or NULL if not found
+*/
 /****************************************************************************/
 
 char * NS_PREFIX GetStringVar (const char *name)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	
@@ -412,30 +376,25 @@
 }
 
 /****************************************************************************/
-/*
-   GetStringValue - Get double value of the string contained in the variable 'name'
+/** \brief Get double value of the string contained in the variable 'name'
+
+ \param name - name of the string variable
+ \param value - address where the result is stored
+
+   Same as GetStringValueDouble. 
 
-   SYNOPSIS:
-   INT GetStringValue (const char *name, double *value);
+   \todo Should not be used and may be skipped in a future version.
 
-   PARAMETERS:
-.  name - name of the string variable
-.  value - address where the result is stored
-
-   DESCRIPTION:
-   Same as GetStringValueDouble. Should not be used and may be skipped
-   in a future version.
-
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> 1 if error occured </li>
+   </ul>
 */
 /****************************************************************************/
 
 INT  NS_PREFIX GetStringValue (const char *name, double *value)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	
@@ -452,30 +411,24 @@
 }
 
 /****************************************************************************/
-/*D
-   GetStringValueDouble	- Get double value of a variable
+/** \brief Get double value of a variable
 
-   SYNOPSIS:
-   INT GetStringValueDouble (const char *name, double *value);
+ \param name - name of the string variable
+ \param value - address where the result is stored
 
-   PARAMETERS:
-.  name - name of the string variable
-.  value - address where the result is stored
-
-   DESCRIPTION:
    This function evaluates a string variable holding a floating point number
    and returns the result.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> 1 if error occured </li>
+   </ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX GetStringValueDouble (const char *name, double *value)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	double val;
@@ -494,30 +447,24 @@
 }
 
 /****************************************************************************/
-/*D
-   GetStringValueInt - Get integer value of a variable
-
-   SYNOPSIS:
-   INT GetStringValueInt (const char *name, int *value);
+/** \brief Get integer value of a variable
 
-   PARAMETERS:
-.  name - name of the string variable
-.  value - place result here
+ \param name - name of the string variable
+ \param value - place result here
 
-   DESCRIPTION:
    This function evaluates a string variable holding an integer number
    and returns the result.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
+   \return <ul>
+   <li> 0 if ok </li>
+   <li> 1 if error occured </li>
+   </ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX GetStringValueInt (const char *name, int *value)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	int val;
@@ -536,35 +483,28 @@
 }
 
 /****************************************************************************/
-/*D
-   GetStringDOUBLEInRange - Get the double value of 'name' together with a range check
+/** \brief Get the double value of 'name' together with a range check
 
-   SYNOPSIS:
-   INT GetStringDOUBLEInRange (const char *name, DOUBLE min, 
-   DOUBLE max, DOUBLE *value);
-
-   PARAMETERS:
-.  name - memory address of the string variable
-.  min - left endpoint of interval
-.  max - right endpoint of interval
-.  value - address where the value is stored
+ \param name - memory address of the string variable
+ \param min - left endpoint of interval
+ \param max - right endpoint of interval
+ \param value - address where the value is stored
  
-   DESCRIPTION:
    This function gets the double value of the string variable 'name'
    and checks wether it is lying in the specified interval.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 variable not found
-.n     2 no legal value
-.n     3/4 outside of range
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 variable not found </li>
+<li>  2 no legal value </li>
+<li>  3/4 outside of range </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX GetStringDOUBLEInRange (const char *name, DOUBLE min, DOUBLE max, DOUBLE *value)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	double val;
@@ -580,34 +520,28 @@
 }
 
 /****************************************************************************/
-/*D
-   GetStringINTInRange - Get the integer value of 'name' together with a range check
+/** \brief Get the integer value of 'name' together with a range check
 
-   SYNOPSIS:
-   INT GetStringINTInRange (const char *name, INT min, INT max, INT *value);
+ \param name - memory address of the string variable
+ \param min - left endpoint of interval
+ \param max - right endpoint of interval
+ \param value - address where the value is stored
 
-   PARAMETERS:
-.  name - memory address of the string variable
-.  min - left endpoint of interval
-.  max - right endpoint of interval
-.  value - address where the value is stored
-
-   DESCRIPTION:
    This function gets the integer value of the string variable 'name'
    and checks wether it is lying in the specified interval.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 variable not found
-.n     2 no legal value
-.n     3/4 outside of range
-D*/
+   \return <ul>
+   <li>  0 if ok </li>
+   <li>  1 variable not found </li>
+   <li>  2 no legal value </li>
+   <li>  3/4 outside of range </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX GetStringINTInRange (const char *name, INT min, INT max, INT *value)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	int val;
@@ -623,23 +557,15 @@
 }
 
 /****************************************************************************/
-/*D
-   GetCurrentStructDir - get current structure directory
-
-   SYNOPSIS:
-   ENVDIR *GetCurrentStructDir ();
-
-   PARAMETERS:
-.  void -
+/** \brief Get current structure directory
 
-   DESCRIPTION:
    This function returns the current structure directory.
 
-   RETURN VALUE:
-   ENVDIR *
-.n     pointer to the directory
-.n     NULL
-D*/
+   \return <ul>
+<li>  pointer to the directory </li>
+<li>  NULL </li>
+</ul>
+*/
 /****************************************************************************/
 
 ENVDIR * NS_PREFIX GetCurrentStructDir ()
@@ -648,24 +574,17 @@
 }
 
 /****************************************************************************/
-/*D
-   GetStructPathName - Assemble pathname of current structure directory	
-
-   SYNOPSIS:
-   INT GetStructPathName (char *s, int n);
+/** \brief Assemble pathname of current structure directory	
 
-   PARAMETERS:
-.  s - pointer to buffer for the string						
-.  n - length of buffer
+ \param s - pointer to buffer for the string						
+ \param n - length of buffer
 
-   DESCRIPTION:
    This function assembles the pathname of the current structure directory. 
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
+   \return
+<li>  0 if ok </li>
+<li>  1 if error occured. </li>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX GetStructPathName (char *s, int n)
@@ -689,32 +608,25 @@
 }
 
 /****************************************************************************/
-/*D
-   MakeStructItem - Allocate a new environment item in the current directory 
+/** \brief Allocate a new environment item in the current directory 
 
-   SYNOPSIS:
-   ENVITEM *MakeStructItem (ENVDIR *where, const char *name, INT type, 
-  INT size);
-
-   PARAMETERS:
-.  where - directory in which the new one will be allocated
-.  name - name of the new item
-.  type - type of the new item
-.  size - total size if user defined, string size for string variable
+ \param where - directory in which the new one will be allocated
+ \param name - name of the new item
+ \param type - type of the new item
+ \param size - total size if user defined, string size for string variable
   
-   DESCRIPTION:
    This function allocates a new environment item in the current directory.
    It is some reduced form of 'MakeEnvItem' with the additional feature,
    that it can start from a given directory.
    
-   SEE ALSO:
+   \sa
    MakeEnvItem
    
-   RETURN VALUE:
-   ENVITEM *
-.n      pointer to
-.n      NULL if not enough memory in the environment heap or other error condition occurs
-D*/
+   \return <ul>
+<li>   pointer to </li>
+<li>   NULL if not enough memory in the environment heap or other error condition occurs </li>
+</ul>
+*/
 /****************************************************************************/
 
 ENVITEM * NS_PREFIX MakeStructItem (ENVDIR *where, const char *name, INT type, INT size)
@@ -785,25 +697,20 @@
 }
 
 /****************************************************************************/
-/*D
-   MakeStruct - Allocate a new structure
-
-   SYNOPSIS:
-   INT MakeStruct (const char *name);
+/** \brief Allocate a new structure
 
-   PARAMETERS:
-.  name - name of the new directory
+ \param name - name of the new directory
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 if error occured </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX MakeStruct (const char *name)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir,*theStruct;
 	
 	if ((theDir=FindStructDir(name,&lastname))==NULL)							return(1);
@@ -815,32 +722,27 @@
 }
 
 /****************************************************************************/
-/*D
-   DeleteStruct	- Delete an existing structure
-
-   SYNOPSIS:
-   INT DeleteStruct (char *name);
+/** \brief Delete an existing structure
 
-   PARAMETERS:
-.  name - structure name
+ \param name - structure name
 
    SEE ALSO:
    FindStructDir, FindStructure, CheckIfInStructPath, CheckStructTree, RemoveStructTree
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 structure directory not found
-.n     2 structure does not exist
-.n     3 structure is inside structure path
-.n     4 structure contains locked objects
-.n     5 structure could not be removed
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 structure directory not found </li>
+<li>  2 structure does not exist </li>
+<li>  3 structure is inside structure path </li>
+<li>  4 structure contains locked objects </li>
+<li>  5 structure could not be removed </li>
+</ul>
+*/
 /****************************************************************************/
 
-INT  NS_PREFIX DeleteStruct (char *name)
+INT  NS_PREFIX DeleteStruct (const char *name)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir,*theStruct;
 	
 	if ((theDir=FindStructDir(name,&lastname))==NULL)
@@ -862,26 +764,20 @@
 }
 
 /****************************************************************************/
-/*D
-   RemoveStringVar - remove a string variable fro the environment tree
-
-   SYNOPSIS:
-   INT RemoveStringVar (ENVDIR *homeDir, STRVAR *theVar)
+/** \brief Remove a string variable fro the environment tree
 
-   PARAMETERS:
-.  homeDir - theVar is located in this directory
-.  theVar - string var to remove
+ \param homeDir - theVar is located in this directory
+ \param theVar - string var to remove
 
-   DESCRIPTION:
    This function removes a string variable from the environment tree.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 homeDir==NULL
-.n     2 theVar==NULL
-.n     3 theVar is a directory
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 homeDir==NULL </li>
+<li>  2 theVar==NULL </li>
+<li>  3 theVar is a directory </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX RemoveStringVar (ENVDIR *homeDir, STRVAR *theVar)
@@ -906,31 +802,26 @@
 }
 
 /****************************************************************************/
-/*D
-   DeleteVariable	- Delete an existing string variable
+/** \brief Delete an existing string variable
 
-   SYNOPSIS:
-   INT DeleteVariable (char *name);
-
-   PARAMETERS:
-.  name - variable name
+ \param name - variable name
 
    SEE ALSO:
    FindStructDir, FindStructure, CheckIfInStructPath, CheckStructTree, RemoveStructTree
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 variable directory not found
-.n     2 variable does not exist
-.n     4 variable contains locked objects
-.n     5 variable could not be removed
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 variable directory not found </li>
+<li>  2 variable does not exist </li>
+<li>  4 variable contains locked objects </li>
+<li>  5 variable could not be removed </li>
+</ul>
+*/
 /****************************************************************************/
 
-INT  NS_PREFIX DeleteVariable (char *name)
+INT  NS_PREFIX DeleteVariable (const char *name)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	
@@ -950,35 +841,29 @@
 }
 
 /****************************************************************************/
-/*D
-   SetStringVar - Set a string variable to a given string
+/** \brief Set a string variable to a given string
 
-   SYNOPSIS:
-   INT SetStringVar (const char *name, const char *sval);
+ \param name - variable name	
+ \param sval - address of the string
 
-   PARAMETERS:
-.  name - variable name	
-.  sval - address of the string
-
-   DESCRIPTION:
    This function searches a string variable and sets it to the given string.
    If the string variable does not yet exist it is created, if it is
    too short for the string, it is removed and newly created.
 
-   SEE ALSO:
+   \sa
    FindStructDir, FindStringVar, RemoveStringVar, MakeStructItem
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 structure directory not found
-.n     2 could not allocate variable
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 structure directory not found </li>
+<li>  2 could not allocate variable </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX SetStringVar (const char *name, const char *sval)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	
@@ -1006,18 +891,12 @@
 }
 
 /****************************************************************************/
-/*D
-   SetnStringVar - Set a string variable to a given string
-
-   SYNOPSIS:
-   INT SetnStringVar (const char *name, const char *sval, int n);
+/** \brief Set a string variable to a given string
 
-   PARAMETERS:
-.  name - variable name
-.  sval - address of the string
-.  n - length of string
+ \param name - variable name
+ \param sval - address of the string
+ \param n - length of string
 
-   DESCRIPTION:
    This function searches a string variable and sets it to the given string.
    If the string variable does not yet exist it is created, if it is
    too short for the string, it is removed and newly created.
@@ -1025,20 +904,20 @@
    The difference to 'SetStringVar' is that the string is not terminated
    by '\0'.
 
-   SEE ALSO:
+   \sa
    SetStringVar, FindStructDir, FindStringVar, RemoveStringVar, MakeStructItem
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 structure directory not found
-.n     2 could not allocate variable
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 structure directory not found </li>
+<li>  2 could not allocate variable </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX SetnStringVar (const char *name, const char *sval, int n)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	
@@ -1066,35 +945,29 @@
 	return(0);
 }
 /****************************************************************************/
-/*D
-   SetStringVarNotify - Set a string variable to a given string and notify if changed
+/** \brief Set a string variable to a given string and notify if changed
 
-   SYNOPSIS:
-   INT SetStringVarNotify (const char *name, const char *sval);
+ \param name - variable name	
+ \param sval - address of the string
 
-   PARAMETERS:
-.  name - variable name	
-.  sval - address of the string
-
-   DESCRIPTION:
    This function searches a string variable and sets it to the given string.
    If the string variable does not yet exist it is created, if it is
    too short for the string, it is removed and newly created.
 
-   SEE ALSO:
+   \sa
    FindStructDir, FindStringVar, RemoveStringVar, MakeStructItem
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 structure directory not found
-.n     2 could not allocate variable
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 structure directory not found </li>
+<li>  2 could not allocate variable </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX SetStringVarNotify (const char *name, const char *sval)
 {
-	char *lastname;
+	const char *lastname;
 	ENVDIR *theDir;
 	STRVAR *myVar;
 	int notify = SV_NOT_CHANGED;
@@ -1126,26 +999,19 @@
 }
 
 /****************************************************************************/
-/*D
-   SetStringValue - Set a variable to a real value
-
-   SYNOPSIS:
-   INT SetStringValue (const char *name, double value);
+/** \brief Set a variable to a real value
 
-   PARAMETERS:
-.  name - variable name
-.  value - value
+ \param name - variable name
+ \param value - value
 
-   DESCRIPTION:
    This function sets a variable to a real value.
 
-   SEE ALSO:
+   \sa
    SetStringVar
 
-   RETURN VALUE:
-   INT
-.n     see 'SetStringVar'
-D*/
+   \return
+    see 'SetStringVar'
+*/
 /****************************************************************************/
 
 INT NS_PREFIX SetStringValue (const char *name, double value)
@@ -1158,25 +1024,19 @@
 
 
 /****************************************************************************/
-/*D
-   CheckStructTree - Check if LOCKED-Flag is set somewhere
+/** \brief Check if LOCKED-Flag is set somewhere
 
-   SYNOPSIS:
-   INT CheckStructTree (const ENVDIR *theDir);
+ \param theDir - directory in which struct is located
 
-   PARAMETERS:
-.  theDir - directory in which struct is located
-
-   DESCRIPTION:
    This function checks (recursively) if the LOCKED-Flag is set somewhere
    inside the directory tree starting at 'theDir'.
    Up to now the locking is not yet used.
 
-   RETURN VALUE:
-   INT
-.n     1 if LOCKED-Flag set somewhere
-.n     0 else.
-D*/											
+   \return <ul>
+<li>  1 if LOCKED-Flag set somewhere </li>
+<li>  0 else </li>
+</ul>
+*/											
 /****************************************************************************/
 
 INT NS_PREFIX CheckStructTree (const ENVDIR *theDir)
@@ -1195,23 +1055,15 @@
 }
 
 /****************************************************************************/
-/*D
-   CheckIfInStructPath - Searches '*theDir' inside the current structure path
-
-   SYNOPSIS:
-   INT CheckIfInStructPath (const ENVDIR *theDir);
+/** \brief Searches '*theDir' inside the current structure path
 
-   PARAMETERS:
-.  theDir - structure 
+ \param theDir - structure 
 
-   DESCRIPTION:
-   See above.
-
-   RETURN VALUE:
-   INT
-.n     1 if inside path
-.n     0 if not inside path.
-D*/
+   \return <ul>
+<li>  1 if inside path </li>
+<li>  0 if not inside path </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX CheckIfInStructPath (const ENVDIR *theDir)
@@ -1226,24 +1078,18 @@
 }		
 
 /****************************************************************************/
-/*D
-   RemoveStructTree - Removes the whole structure tree	
+/** \brief Removes the whole structure tree	
 
-   SYNOPSIS:
-   INT RemoveStructTree (ENVDIR *homeDir, ENVDIR *theDir);
+ \param homeDir - home directory
+ \param theDir - structure 
 
-   PARAMETERS:
-.  homeDir - home directory
-.  theDir - structure 
-
-   DESCRIPTION:
    This function removes recursively the whole structure tree.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if error occured.
-D*/
+   \return <ul>
+<li>  0 if ok </li>
+<li>  1 if error occured </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX RemoveStructTree (ENVDIR *homeDir, ENVDIR *theDir)
@@ -1270,34 +1116,28 @@
 }
 
 /****************************************************************************/
-/*D
-   DirOut - (recursively) print directory contents
+/** \brief (recursively) print directory contents
 
-   SYNOPSIS:
-   static INT DirOut (const ENVDIR *theDir, char *buffer, int bufLen, int ropt);
+ \param theDir - structure
+ \param buffer - address of buffer
+ \param bufLen - length of buffer
+ \param ropt - if set, the contents are printed recursively
 
-   PARAMETERS:
-.  theDir - structure
-.  buffer - address of buffer
-.  bufLen - length of buffer
-.  ropt - if set, the contents are printed recursively
-
-   DESCRIPTION:
    This function (recursively) prints the contents of theDir into the buffer.
    It will return the value 4 if the buffer is full and it is not yet ready.
    In this case it has to be called another time. If it is ready it returns
    the value 0.
 
-   RETURN VALUE:
-   INT
-.n    0 all is done
-.n    1 buffer too small
-.n    2 theDir is not a string directory
-.n    3 false type encountered (should never occur)
-.n    4 not yet ready with output (this is not an error!)
-.n    5 directory tree too deeply nested (should never occur)
-.n    6 this should also never occur
-D*/
+   \return <ul>
+<li> 0 all is done </li>
+<li> 1 buffer too small </li>
+<li> 2 theDir is not a string directory </li>
+<li> 3 false type encountered (should never occur) </li>
+<li> 4 not yet ready with output (this is not an error!) </li>
+<li> 5 directory tree too deeply nested (should never occur) </li>
+<li> 6 this should also never occur </li>
+</ul>
+*/
 /****************************************************************************/
 
 static INT DirOut (const ENVDIR *theDir, char *buffer, int bufLen, int ropt)
@@ -1427,29 +1267,23 @@
 }
 
 /****************************************************************************/
-/*D
-   VarOut - prints variable = content into a buffer
+/** \brief Prints variable = content into a buffer
 
-   SYNOPSIS:
-   static INT VarOut (const STRVAR *StrVar, char *buffer, int bufLen,);
+ \param StrVar - string variable
+ \param buffer - address of buffer
+ \param bufLen - length of buffer
 
-   PARAMETERS:
-.  StrVar - string variable
-.  buffer - address of buffer
-.  bufLen - length of buffer
-
-   DESCRIPTION:
    This function prints the contents of StrVar into the buffer.
    It will return the value 4 if the buffer is full and it is not yet ready.
    In this case it has to be called another time. If it is ready it returns
    the value 0.
 
-   RETURN VALUE:
-   INT
-.n    0 all is done
-.n    1 buffer too small
-.n    4 not yet ready with output (this is not an error!)
-D*/
+   \return <ul>
+<li> 0 all is done </li>
+<li> 1 buffer too small </li>
+<li> 4 not yet ready with output (this is not an error!) </li>
+</ul>
+*/
 /****************************************************************************/
 
 static INT VarOut (const STRVAR *StrVar, char *buffer, int bufLen)
@@ -1484,36 +1318,30 @@
 }
 
 /****************************************************************************/
-/*D
-   PrintStructContents - (recursively) print structure contents
+/** \brief (recursively) print structure contents
 
-   SYNOPSIS:
-   INT PrintStructContents (const char *name, char *buffer, int bufLen, int ropt);
+ \param name - name of structure(dir)
+ \param buffer - address of buffer
+ \param bufLen - length of buffer
+ \param ropt - if set, the contents are printed recursively
 
-   PARAMETERS:
-.  name - name of structure(dir)
-.  buffer - address of buffer
-.  bufLen - length of buffer
-.  ropt - if set, the contents are printed recursively
-
-   DESCRIPTION:
    This function prints the contents of the variable or structure 'name'.
    More or less it provides a call for the functions DirOut and VarOut.
    You should take care with error handling when using these function.
    
-   SEE ALSO:
+   \sa
    DirOut, VarOut, FindStructDir, FindStringVar, FindStructure
 
-   RETURN VALUE:
-   INT
-.n    0 all is done
-.n    1 buffer too small
-.n    2, 3 (should not occur)
-.n    4 not yet ready with output (this is not an error!)
-.n    5, 6 (should not occur)
-.n    7 structure path not found
-.n    8 structure not found
-D*/
+   \return <ul>
+<li> 0 all is done </li>
+<li> 1 buffer too small </li>
+<li> 2, 3 (should not occur) </li>
+<li> 4 not yet ready with output (this is not an error!) </li>
+<li> 5, 6 (should not occur) </li>
+<li> 7 structure path not found </li>
+<li> 8 structure not found </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX PrintStructContents (const char *name, char *buffer, int bufLen, int ropt)
@@ -1521,7 +1349,7 @@
 	static ENVDIR *theDir;
 	static STRVAR *StrVar;
 	static int status;
-	char *lastname;
+	const char *lastname;
 	int ret;
 	
 	buffer[0]=(char) 0;
@@ -1577,33 +1405,27 @@
 }
 
 /****************************************************************************/
-/*D
-   PrintCurrentStructContents - (recursively) print contents of current structure directory
-
-   SYNOPSIS:
-   INT PrintCurrentStructContents (int flag, char *buffer, int bufLen, int ropt);
+/** \brief (recursively) print contents of current structure directory
 
-   PARAMETERS:
-.  flag - 1 for the first call, 0 if others are necessary
-.  buffer - address of buffer
-.  bufLen - length of buffer
-.  ropt - if set, the contents are printed recursively
+ \param flag - 1 for the first call, 0 if others are necessary
+ \param buffer - address of buffer
+ \param bufLen - length of buffer
+ \param ropt - if set, the contents are printed recursively
 
-   DESCRIPTION:
    This function prints the contents of the of the current working structure.
    More or less it calls the function DirOut.
 
-   SEE ALSO:
+   \sa
    DirOut, PrintStructContents, FindStructDir, FindStringVar, FindStructure
 
-   RETURN VALUE:
-   INT
-.n    0 all is done
-.n    1 buffer too small
-.n    2, 3 (should not occur)
-.n    4 not yet ready with output (this is not an error!)
-.n    5, 6 (should not occur)
-D*/
+   \return <ul>
+<li> 0 all is done </li>
+<li> 1 buffer too small </li>
+<li> 2, 3 (should not occur) </li>
+<li> 4 not yet ready with output (this is not an error!) </li>
+<li> 5, 6 (should not occur) </li>
+</ul>
+*/
 /****************************************************************************/
 
 INT  NS_PREFIX PrintCurrentStructContents (int flag, char *buffer, int bufLen, int ropt)
@@ -1615,21 +1437,16 @@
 }
 
 /****************************************************************************/
-/*D
-   InitUgStruct	- Initialize ugstruct
+/** \brief Initialize ugstruct
 
-   PARAMETERS:
-.  none
-
-   DESCRIPTION:
    This function creates the '/Strings'-directory, gets an ID for
    string directories and sets the current structure path to '/Strings'.
 
-   RETURN VALUE:
-   INT
-.n     0 if ok
-.n     1 if not enough memory.
-D*/
+   \return <ul>
+   <li>  0 if ok </li>
+   <li>  1 if not enough memory </li>
+   </ul>
+*/
 /****************************************************************************/
 
 INT NS_PREFIX InitUgStruct ()
diff -ruN ug-orig/low/ugstruct.h ug-patched/low/ugstruct.h
--- ug-orig/low/ugstruct.h	2004-07-21 11:19:50.000000000 +0200
+++ ug-patched/low/ugstruct.h	2009-05-07 10:00:28.000000000 +0200
@@ -22,7 +22,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/ugstruct.h,v 1.10 2004/07/21 09:19:50 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -82,10 +82,10 @@
 
 /* hierarchical string directory */
 INT      MakeStruct                             (const char *name);
-INT      DeleteStruct                           (char *name);
-INT      DeleteVariable                         (char *name);
+INT      DeleteStruct                           (const char *name);
+INT      DeleteVariable                         (const char *name);
 ENVDIR  *ChangeStructDir                        (const char *s);
-ENVDIR  *FindStructDir                          (const char *name, char **lastnameHnd);
+ENVDIR  *FindStructDir                          (const char *name, const char **lastnameHnd);
 STRVAR  *FindStringVar                          (const ENVDIR *where, const char *name);
 ENVDIR  *FindStructure                          (const ENVDIR *where, const char *name);
 INT              RemoveStringVar                        (ENVDIR *homeDir, STRVAR *theVar);
@@ -111,7 +111,7 @@
 /* initialization of this module */
 INT     InitUgStruct                            (void);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
 
diff -ruN ug-orig/low/ugtime.h ug-patched/low/ugtime.h
--- ug-orig/low/ugtime.h	2004-10-06 11:16:37.000000000 +0200
+++ ug-patched/low/ugtime.h	2010-06-29 12:23:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: ugtime.h,v 1.2 2004/10/06 09:16:37 thimo Exp $ */
+/* $Id: ugtime.h 8369 2010-06-29 10:23:53Z sander $ */
 
 /*
 
@@ -9,8 +9,6 @@
 #ifndef UG_UGTIME_H
 #define UG_UGTIME_H
 
-#include "config.h"
-
 #ifdef AUTOTOOLS_BUILD
 
 #ifndef UGLIB
diff -ruN ug-orig/low/ugtimer.c ug-patched/low/ugtimer.c
--- ug-orig/low/ugtimer.c	2006-03-13 10:05:05.000000000 +0100
+++ ug-patched/low/ugtimer.c	2008-12-19 11:06:12.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <assert.h>
 
@@ -66,7 +67,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/low/ugtimer.c,v 1.3 2006/03/13 09:05:05 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/low/ugtimer.h ug-patched/low/ugtimer.h
--- ug-orig/low/ugtimer.h	2006-03-13 10:05:05.000000000 +0100
+++ ug-patched/low/ugtimer.h	2009-05-07 10:00:28.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/low/ugtimer.h,v 1.5 2006/03/13 09:05:05 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -90,6 +90,6 @@
 
 void new_timer (int *n);
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/low/ugtypes.h ug-patched/low/ugtypes.h
--- ug-orig/low/ugtypes.h	2006-06-12 13:44:46.000000000 +0200
+++ ug-patched/low/ugtypes.h	2009-05-07 10:00:28.000000000 +0200
@@ -1,9 +1,13 @@
-/* $Id: ugtypes.h,v 1.4 2006/06/12 11:44:46 sander Exp $ */
+/* $Id: ugtypes.h 8353 2009-05-07 08:00:28Z sander $ */
 
-/*
-
-  globally set data types
+/** \file
+    \brief Globally set data types
 
+    The basic types (normally 'short', 'int', 'float' and 'double') are 
+    replaced by 'SHORT', 'INT', 'FLOAT' and 'DOUBLE'. The type 'DOUBLE' 
+    is used for all Cartesian coordinates of the (x,y[,z])-directions of 
+    the grids and 'SCREEN_DOUBLE' is used for all transformed coordinates 
+    of the graphical interface.
 */
 
 #ifndef UGTYPES_H
@@ -53,6 +57,6 @@
 
 #endif
 
-END_NAMESPACE
+END_UG_NAMESPACE
 
 #endif
diff -ruN ug-orig/m4/CVS/Entries ug-patched/m4/CVS/Entries
--- ug-orig/m4/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/m4/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-/acx_mpi.m4/1.1/Thu Sep  2 11:48:20 2004//D2008.11.12.23.00.00
-/dune_mpi.m4/1.3/Thu Oct 28 12:11:17 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/m4/CVS/Repository ug-patched/m4/CVS/Repository
--- ug-orig/m4/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/m4/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/m4
diff -ruN ug-orig/m4/CVS/Root ug-patched/m4/CVS/Root
--- ug-orig/m4/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/m4/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/m4/CVS/Tag ug-patched/m4/CVS/Tag
--- ug-orig/m4/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/m4/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/m4/ddd.m4 ug-patched/m4/ddd.m4
--- ug-orig/m4/ddd.m4	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/m4/ddd.m4	2010-12-16 16:51:22.000000000 +0100
@@ -0,0 +1,11 @@
+AC_DEFUN([DDD_PARAMETERS],[
+  AC_ARG_WITH([ddd_maxprocbits],
+    AS_HELP_STRING([--with-ddd-maxprocbits],
+	  [Set number of bits of an unsigned int used to store the process number, 
+       the remaining bits are used to store the local entity id]),[],[with_ddd_maxprocbits=no])
+  AS_IF([test "x$with_ddd_maxprocbits" = "xno"],[
+    with_ddd_maxprocbits=9;
+  ])
+  AC_DEFINE_UNQUOTED(DDD_MAX_PROCBITS_IN_GID, $with_ddd_maxprocbits,
+                      [see parallel/ddd/dddi.h])
+])
diff -ruN ug-orig/m4/dune_mpi.m4 ug-patched/m4/dune_mpi.m4
--- ug-orig/m4/dune_mpi.m4	2004-10-28 14:11:17.000000000 +0200
+++ ug-patched/m4/dune_mpi.m4	1970-01-01 01:00:00.000000000 +0100
@@ -1,152 +0,0 @@
-# $Id: dune_mpi.m4,v 1.3 2004/10/28 12:11:17 thimo Exp $
-
-# wrapper for the autoconf-archive check. Note: compiling MPI-stuff sucks!
-
-# Explanation:
-# ============
-#
-
-# compilation of MPI-programs is normally done by a
-# mpicc/mpiCC-wrapper that adds all options needed. Thus, it may seem
-# possible to just replace the compiler call by the wrapper and
-# everything works. Unfortunately that's not the case: automake and
-# libtool both show strange behaviour.
-#
-# In detail: replacing the compiler globally via ./configure CXX=mpiCC
-# should work (at least I've found reports claiming this) but that is
-# not what we want: mainly, it just adds a level of possible errors
-# (mpiCC from MPICH does _nothing_ if "mpicc -c dummy.cc" is called!)
-# and might introduce nice library-clashes.
-#
-# The next approach would be to include
-#       if MPI
-#         CXX = $(MPICXX)
-#       endif
-# in the Makefile.am where MPI is needed. First, this will change
-# compilations of all binaries in this directory and secondly the
-# dependency-tracking seems to break: the first compilation worked but
-# the second failed with the compiler complaining about mismatching
-# flags... There is no 'program_CXX = ...' in automake but even if
-# there were it would break as well
-#
-# Thus, the best solution is to extract the flags needed for
-# compilation and linking. Unfortunately, the parameters and behaviour
-# of mpicc is not at all consistent over different
-# implementations. For MPICH the parameters -compile_info and
-# -link_info exist (albeit not being documented in the manpage, only
-# in -help), for LAM dummy-calls of compilation and linking together
-# with a -showme parameter (which is called -show in MPICH...) have to
-# be used. Obviously, we have to identify the type of package... this
-# is done via mpiCC-calls for now, I wouldn't be surprised if ths
-# breaks often. Bad luck. Blame the MPI folks for this mess. And blame
-# them a lot. [Thimo 26.8.2004]
-
-# TODO:
-#
-# - add --disable-mpi
-
-AC_DEFUN([DUNE_MPI],[
-  AC_PREREQ(2.50) dnl for AC_LANG_CASE
-
-  # implicitly sets the HAVE_MPI-define and the MPICXX-substitution
-  ACX_MPI()
-
-# somehow variables like $1, $2 seem to disappear after m4... Quote them...
-dune_mpi_getflags () {
-    # -- call mpiCC, remove compiler name
-    # compiler-name is first word in line _if_ it doesn't start with a dash!
-    # needed because mpiCC sometimes does not include compiler (newer LAM)
-
-    # the additional brackets keep m4 from interpreting the brackets
-    # in the sed-command...
-    retval=[`$MPICOMP ${1} ${2} 2>/dev/null | sed -e 's/^[^-][^ ]\+ //'`]
-    # remove dummy-parameter (if existing)
-    if test ${#} = 2 ; then
-      retval=`echo $retval | sed -e "s/${2}//"`
-    fi
-}
-
-  # get compilation script
-  AC_LANG_CASE([C],[
-	MPICOMP="$MPICC"
-],
-[C++],[
-	MPICOMP="$MPICXX"
-]
-)
-
-  # taken from acx_mpi: test succeeded if MPILIBS is not empty
-  if test x != x"$MPILIBS" -a x != x"$MPICOMP" ; then
-    with_mpi="no"
-
-    AC_MSG_CHECKING([MPI-package])
-    # the LAM mpiCC knows a -showme parameter
-    dune_mpi_getflags "-showme"
-    if test x"$retval" != x ; then
-      with_mpi="LAM"
-
-      # try new -showme:xxx function
-      dune_mpi_getflags "-showme:compile"
-      if test x"$retval" != x ; then
-        # seems like LAM >= 7.1 which supports extraction of parameters without
-        # dummy files
-        AC_MSG_RESULT([LAM >= 7.1])
-        MPI_CPPFLAGS="$retval"
-
-        dune_mpi_getflags "-showme:link"
-        MPI_LDFLAGS="$retval"
-      else
-        AC_MSG_RESULT([LAM <= 7.0])
-        # use -showme and dummy parameters to extract flags        
-        AC_LANG_CASE([C], [MPISOURCE="dummy.c"],
-	  [C++], [MPISOURCE="dummy.cc"])
-
-        dune_mpi_getflags "-showme" "-c $MPISOURCE"
-        MPI_CPPFLAGS="$retval"
-
-        dune_mpi_getflags "-showme" "dummy.o -o dummy"
-        MPI_LDFLAGS="$retval"
-      fi
-    else
-      # the MPICH mpiCC knows a -show parameter
-      dune_mpi_getflags "-show"
-      if test x"$retval" != x ; then
-        with_mpi="MPICH"
-
-        # use special commands to extract options      
-
-        dune_mpi_getflags "-compile_info"
-        MPI_CPPFLAGS="$retval"
-        # hack in option to disable MPICH-C++-bindings...
-        AC_LANG_CASE([C++], [MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPICH_SKIP_MPICXX"])
-
-        dune_mpi_getflags "-link_info"
-        MPI_LDFLAGS="$retval"
-
-        AC_MSG_RESULT([MPICH])
-      else
-        # neither MPICH nor LAM....
-        AC_MSG_RESULT([unknown])
-      fi
-    fi
-
-    # fallback... can't extract flags :( 
-    if test x$with_mpi = xno ; then
-      AC_MSG_WARN([Could not identify MPI-package! Please send a bugreport and tell us what MPI-package you're using])
-    fi
-  else
-    # ACX_MPI didn't find anything
-    with_mpi="no"
-  fi
-
-  # set flags
-  if test x$with_mpi != xno ; then
-    AC_SUBST(MPI_CPPFLAGS, $MPI_CPPFLAGS)
-    AC_SUBST(MPI_LDFLAGS, $MPI_LDFLAGS)
-  else
-    AC_SUBST(MPI_CPPFLAGS, "")
-    AC_SUBST(MPI_LDFLAGS, "")
-  fi
-
-  AM_CONDITIONAL(MPI, test x$with_mpi != xno)
-])
diff -ruN ug-orig/m4/mpi-config.m4 ug-patched/m4/mpi-config.m4
--- ug-orig/m4/mpi-config.m4	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/m4/mpi-config.m4	2010-10-25 15:09:56.000000000 +0200
@@ -0,0 +1,330 @@
+AC_DEFUN([MPI_CONFIG_HELPER],[
+
+mpi_trybuild () {
+  $MPICC ${1} > /dev/null 2>&1 || return 1
+  return 0
+}
+
+mpi_preprocess () {
+  $MPICC -E -c ${1} 2> /dev/null
+}
+
+mpi_getflags () {
+  # -- call mpiCC, remove compiler name
+  # compiler-name is first word in line _if_ it doesn't start with a dash!
+  # needed because mpiCC sometimes does not include compiler (newer LAM)
+
+  # the additional brackets keep m4 from interpreting the brackets
+  # in the sed-command...
+  retval=`$MPICC ${1} ${2} 2>/dev/null | head -1`
+  # remove compiler name
+  retval=`echo $retval | sed -e 's/^[[^-]][[^ ]][[^ ]]* //'`
+  # remove dummy-parameter (if existing)
+  retval=`echo $retval | sed -e "s/ ${1} / /"`
+  if test ${#} = 2 ; then
+    retval=`echo $retval | sed -e "s/ ${2} / /"`
+  fi
+  # remove optimization, warning, etc paramters
+  retval=`echo " $retval " | sed -e 's/ -g / /g' -e 's/ -W[[a-z0-9]]\+ / /g' -e 's/ -O[[0-9]]\+ / /g'`
+  # strip leading and trailing spaces
+  retval=`echo "$retval" | sed 's/^ *//g;s/ *$//g'`
+}
+
+# removes regexp $2 from string $1
+mpi_remove () {
+  retval=`echo ${1} | sed -e "s/ ${2} / /"`
+  # string to remove might be on the beginning of the line
+  retval=`echo ${retval} | sed -e "s/^${2} / /"`
+}
+
+test_lam () {
+  AC_MSG_CHECKING([for lam])
+  cat >conftest.c <<_EOF
+#include <mpi.h>
+#include <stdio.h>
+
+int main() {
+  printf ("%i%i\n", LAM_MAJOR_VERSION, LAM_MINOR_VERSION);
+  return 0;
+ }
+_EOF
+
+  if mpi_trybuild "-c conftest.c"; then
+    # try new -showme:xxx function
+    mpi_getflags "-showme:compile"
+    if test x"$retval" != x ; then
+      # seems like LAM >= 7.1 which supports extraction of parameters without
+      # dummy files
+      dune_MPI_VERSION="LAM >= 7.1"
+      if test x"$DUNEMPICPPFLAGS" = x; then
+        DUNEMPICPPFLAGS="$retval"
+      fi
+      if test x"$DUNEMPILIBS" = x; then
+        mpi_getflags "-showme:link"
+        DUNEMPILIBS="$retval"
+      fi
+    else
+      dune_MPI_VERSION="LAM < 7.1"
+      # use -showme and dummy parameters to extract flags        
+      if test x"$DUNEMPICPPFLAGS" = x; then
+        mpi_getflags "-showme" "-c $MPISOURCE"
+        DUNEMPICPPFLAGS="$retval"
+      fi
+      if test x"$DUNEMPILIBS" = x; then
+        mpi_getflags "-showme" "dummy.o -o dummy"
+        DUNEMPILIBS="$retval"
+      fi
+    fi
+    # hack in option to disable LAM-C++-bindings...
+    # we fake to have mpicxx.h read already
+    MPI_NOCXXFLAGS="-DMPIPP_H"
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0    
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+mpi_getmpichflags() {
+  if test x"$DUNEMPICPPFLAGS" = x; then
+    # use special commands to extract options      
+    mpi_getflags "-compile_info"
+    DUNEMPICPPFLAGS="$retval"
+    # remove implicitly set -c
+    mpi_remove "$DUNEMPICPPFLAGS" '-c'
+    DUNEMPICPPFLAGS="$retval"
+  fi
+    
+  if test x"$DUNEMPILIBS" = x; then
+    # get linker options
+    mpi_getflags "-link_info"
+    DUNEMPILIBS="$retval"
+    # strip -o option
+    mpi_remove "$DUNEMPILIBS" "-o"
+    DUNEMPILIBS="$retval"
+    #strip DUNEMPICPPFLAGS (which are included for mpich2 on jugene)
+    enc=`echo "$DUNEMPICPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
+    DUNEMPILIBS=`echo "$retval" | sed -e "s/$enc / /"`
+  fi
+
+  # hack in option to disable MPICH-C++-bindings...
+  MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
+}
+
+mpi_getmpich2flags() {
+  if test x"$DUNEMPICPPFLAGS" = x; then
+    # use special commands to extract options      
+    mpi_getflags "-show" "-c"
+    DUNEMPICPPFLAGS="$retval"
+    # remove implicitly set -c
+    mpi_remove "$DUNEMPICPPFLAGS" '-c'
+    DUNEMPICPPFLAGS="$retval"
+  fi
+    
+  if test x"$DUNEMPILIBS" = x; then
+    # get linker options
+    mpi_getflags "-show" "-o"
+    DUNEMPILIBS="$retval"
+    # strip -o option
+    mpi_remove "$DUNEMPILIBS" "-o"
+    DUNEMPILIBS="$retval"
+    #strip DUNEMPICPPFLAGS (which are included for mpich2 on jugene)
+    enc=`echo "$DUNEMPICPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
+    DUNEMPILIBS=`echo "$retval" | sed -e "s/$enc / /"`
+  fi
+
+  # hack in option to disable MPICH-C++-bindings...
+  MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
+}
+
+test_mpich () {
+  AC_MSG_CHECKING([for mpich])
+  cat >conftest.c <<_EOF
+#include <mpi.h>
+
+int main() { return 0; }
+_EOF
+
+  if (mpi_preprocess conftest.c \
+      | grep -q MPICHX_PARALLELSOCKETS_PARAMETERS); then
+    dune_MPI_VERSION="MPICH"
+    mpi_getmpichflags
+
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0    
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_mpich2 () {
+  AC_MSG_CHECKING([for mpich2])
+  cat >conftest.c <<_EOF
+#include <mpi.h>
+#include <stdio.h>
+int main() { printf ("%s\n", MPICH2_VERSION); return 0; }
+_EOF
+
+  if mpi_trybuild "-c conftest.c"; then
+    dune_MPI_VERSION="MPICH2"
+    mpi_getmpich2flags
+
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0    
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_openmpi () {
+  AC_MSG_CHECKING([for OpenMPI])
+  cat >conftest.c <<_EOF
+#include <mpi.h>
+
+int main() { return 0; }
+_EOF
+
+  if (mpi_preprocess conftest.c | grep -q ompi_communicator_t); then
+    dune_MPI_VERSION="OpenMPI"
+
+    if test x"$DUNEMPICPPFLAGS" = x; then
+      mpi_getflags "-showme:compile"
+      DUNEMPICPPFLAGS="$retval"
+    fi
+    if test x"$DUNEMPILIBS" = x; then
+      mpi_getflags "-showme:link"
+      DUNEMPILIBS="$retval"
+    fi
+    MPI_NOCXXFLAGS="-DMPIPP_H"
+
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0    
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_mvapich() {
+  AC_MSG_CHECKING([for MVAPICH])
+
+  mpi_getflags "-v" "-c dummy.c"
+  if (echo $dune_MPI_VERSION | grep ^MVAPICH>/dev/null);then
+      get_mpichflags
+
+      AC_MSG_RESULT([yes])
+      return 0 
+  fi
+
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_mvapich2() {
+  AC_MSG_CHECKING([for MVAPICH2])
+  cat >conftest.c <<_EOF
+#define _OSU_MVAPICH_
+#include <mpi.h>
+/* MVAPICH2_VERSION is only defined for MVAPICH2 1.4+
+ * MVAPICH_VERSION is only defined for MVAPICH2 1.2.*
+ * We can thus fall back to MVAPICH_VERSION if MVAPICH2_VERSION
+ * is not defined.
+ */
+#ifndef MVAPICH2_VERSION
+#define MVAPICH2_VERSION MVAPICH_VERSION
+#endif
+#include <stdio.h>
+int main() { printf("%s\n",MVAPICH2_VERSION); return 0; }
+_EOF
+
+  if mpi_trybuild "-c conftest.c"; then
+    dune_MPI_VERSION="MVAPICH2"
+    mpi_getmpich2flags
+
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0 
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_ibmmpi() {
+  AC_MSG_CHECKING([for IBM MPI])
+  if $MPICC -v -c conftest.c > /dev/null 2>&1; then
+    mpi_getflags "-v" "-c dummy.c"
+    if (echo $retval | grep '^xl[[cC]]'); then
+      dune_MPI_VERSION="IBM MPI"
+
+      if test x"$DUNEMPICPPFLAGS" = x; then
+        DUNEMPICPPFLAGS="$retval"
+      fi
+  
+      if test x"$DUNEMPILIBS" = x; then
+        mpi_getflags "-v" "dummy.o -o dummy"
+        DUNEMPILIBS="$retval"
+      fi
+
+      AC_MSG_RESULT([yes])
+      rm -f conftest*
+      return 0  
+    fi
+  fi
+  
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_intelmpi() {
+  AC_MSG_CHECKING([for Intel MPI])
+  mpi_getflags "-v"
+  if (echo $retval | grep 'Intel(R) MPI Library'); then
+    dune_MPI_VERSION="Intel MPI"
+    mpi_getmpich2flags
+
+    AC_MSG_RESULT([yes])
+    return 0
+  fi
+
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+get_mpiparameters() {
+  AC_MSG_NOTICE([Trying to identify the version of MPI compiler $MPICC])
+
+  if test x"$dune_MPI_VERSION" != x; then
+    return
+  fi 
+
+  test_lam && return
+  test_mpich && return
+  test_openmpi && return
+  test_mvapich && return
+  test_mvapich2 && return
+  test_mpich2 && return
+  test_ibmmpi && return
+  test_intelmpi && return
+   
+  dune_MPI_VERSION="unknown"
+  AC_MSG_ERROR([Could not identify MPI-package! Please send a bugreport and tell us what MPI-package you're using.])
+}
+])
+
+AC_DEFUN([MPI_CONFIG],[
+  AC_REQUIRE([MPI_CONFIG_HELPER])  
+  get_mpiparameters;
+])
diff -ruN ug-orig/m4/ug_mpi.m4 ug-patched/m4/ug_mpi.m4
--- ug-orig/m4/ug_mpi.m4	1970-01-01 01:00:00.000000000 +0100
+++ ug-patched/m4/ug_mpi.m4	2010-11-26 09:23:38.000000000 +0100
@@ -0,0 +1,138 @@
+# $Id: ug_mpi.m4 8390 2010-11-26 08:23:38Z christi $
+
+# wrapper for the autoconf-archive check. Note: compiling MPI-stuff sucks!
+
+# Explanation:
+# ============
+#
+
+# compilation of MPI-programs is normally done by a
+# mpicc/mpiCC-wrapper that adds all options needed. Thus, it may seem
+# possible to just replace the compiler call by the wrapper and
+# everything works. Unfortunately that's not the case: automake and
+# libtool both show strange behaviour.
+#
+# In detail: replacing the compiler globally via ./configure CXX=mpiCC
+# should work (at least I've found reports claiming this) but that is
+# not what we want: mainly, it just adds a level of possible errors
+# (mpiCC from MPICH does _nothing_ if "mpicc -c dummy.cc" is called!)
+# and might introduce nice library-clashes.
+#
+# The next approach would be to include
+#       if MPI
+#         CXX = $(MPICXX)
+#       endif
+# in the Makefile.am where MPI is needed. First, this will change
+# compilations of all binaries in this directory and secondly the
+# dependency-tracking seems to break: the first compilation worked but
+# the second failed with the compiler complaining about mismatching
+# flags... There is no 'program_CXX = ...' in automake but even if
+# there were it would break as well
+#
+# Thus, the best solution is to extract the flags needed for
+# compilation and linking. Unfortunately, the parameters and behaviour
+# of mpicc is not at all consistent over different
+# implementations. For MPICH the parameters -compile_info and
+# -link_info exist (albeit not being documented in the manpage, only
+# in -help), for LAM dummy-calls of compilation and linking together
+# with a -showme parameter (which is called -show in MPICH...) have to
+# be used. Obviously, we have to identify the type of package... this
+# is done via mpiCC-calls for now, I wouldn't be surprised if ths
+# breaks often. Bad luck. Blame the MPI folks for this mess. And blame
+# them a lot. [Thimo 26.8.2004]
+
+# TODO:
+#
+# - add --disable-mpi
+
+AC_DEFUN([UG_MPI],[
+  AC_PREREQ(2.50) dnl for AC_LANG_CASE
+
+  AS_IF([test -n "$MPICXX" -a -z "$MPICC"],[
+    MPICC=$MPICXX
+    AC_MSG_WARN(["You specified the MPICXX variable, but not MPICC. UG extracts the MPI flags using the C interface!])
+  ])
+  
+  AC_LANG_PUSH([C])
+
+  # enable/disable parallel features
+  AC_ARG_ENABLE(parallel,
+    AS_HELP_STRING([--enable-parallel],
+      [Enable the parallel features of UG. If enabled
+       configure will try to determine your MPI automatically. You can
+       overwrite this setting by specifying the MPICC variable]))
+  AC_SUBST(ENABLE_PARALLEL, "$enable_parallel")
+
+  with_mpi="no"
+
+  ## do nothing if --disable-parallel is used
+  AS_IF([test "x$enable_parallel" = "xyes"],[
+    ACX_MPI([
+      MPICOMP="$MPICC"
+
+      MPI_CONFIG()
+      MPI_CPPFLAGS="$DUNEMPICPPFLAGS $MPI_NOCXXFLAGS -DENABLE_MPI=1"
+	  MPI_LDFLAGS="$DUNEMPILDFLAGS $DUNEMPILIBS"
+
+      with_mpi="yes ($dune_MPI_VERSION)"
+    ],[
+      # ACX_MPI didn't find anything
+      with_mpi="no"
+    ])])
+
+  # if an MPI implementation was found..
+  AS_IF([test "x$with_mpi" != "xno"],[
+    ### do a sanity check: can we compile and link a trivial MPI program?
+    AC_MSG_CHECKING([whether compiling with $dune_MPI_VERSION works])
+
+    # store old values
+    ac_save_LIBS="$LIBS"
+    ac_save_LDFLAGS="$LDFLAGS"
+    ac_save_CPPFLAGS="$CPPFLAGS"
+    
+    # looks weird but as the -l... are contained in the MPI_LDFLAGS these
+    # parameters have to be last on the commandline: with LIBS this is true
+    LIBS="$DUNEMPILIBS $LIBS"
+    LDFLAGS="$LDFLAGS $DUNEMPILDFLAGS"
+    CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
+
+    # try to create MPI program
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE(
+      AC_LANG_SOURCE(
+        [ #include <mpi.h>
+          int main (int argc, char** argv) { 
+          MPI_Init(&argc, &argv); 
+          MPI_Finalize(); }]),
+        [ AC_MSG_RESULT([yes]) ],
+        [ AC_MSG_RESULT([no])
+          AC_MSG_ERROR([could not compile MPI testprogram!
+          See config.log for details])
+          with_mpi=no]
+    )
+    AC_LANG_POP
+
+    # Check for MPI-2 Standard
+    # We have to provide a dummy lib here as we do not know what the name
+    # of the mpi is. -lm should be save.
+    AC_CHECK_LIB(m,[MPI_Finalized], [AC_DEFINE(MPI_2, 1, [Define to 1 MPI supports MPI-2])])
+
+    # restore variables
+    LIBS="$ac_save_LIBS"
+    CPPFLAGS="$ac_save_CPPFLAGS"
+  ])
+    
+  # set flags
+  AS_IF([test "x$with_mpi" != "xno"],[
+    AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])
+    AC_SUBST(MPI_CPPFLAGS, $MPI_CPPFLAGS)
+    AC_SUBST(MPI_LDFLAGS, $MPI_LDFLAGS)
+  ],[
+    AC_SUBST(MPI_CPPFLAGS, "")
+    AC_SUBST(MPI_LDFLAGS, "")
+  ])
+  AC_SUBST(MPI_VERSION, $dune_MPI_VERSION)
+  AM_CONDITIONAL(MPI, [test "x$with_mpi" != "xno"])
+
+  AC_LANG_POP
+])
diff -ruN ug-orig/Makefile.am ug-patched/Makefile.am
--- ug-orig/Makefile.am	2005-01-18 19:20:47.000000000 +0100
+++ ug-patched/Makefile.am	2010-10-16 12:46:14.000000000 +0200
@@ -1,28 +1,34 @@
-# $Id: Makefile.am,v 1.6 2005/01/18 18:20:47 thimo Exp $
+# $Id: Makefile.am 8381 2010-10-16 10:46:14Z sander $
 
 # do everything in the subdirs (order matters!)
-SUBDIRS = arch low dev parallel gm dom graphics np ui lib tools
+SUBDIRS = arch parallel low dev gm dom graphics np ui lib tools
 #
 # libltdl after low will be needed for plugins later
 
-include_HEADERS = initug.h
+ugincludedir = $(pkgincludedir)
+uginclude_HEADERS = initug.h
 
 # install pkg-config information
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libug.pc
 
 # !!! crazy trick to get include-dir compatibility
+# Crazy indeed.  Let's at least not install f2c.h (because it creates
+# problems) and std_internal.h (because we definitely know that it is an internal header).
 install-data-hook:
-	find $(top_srcdir) -name \*.h -exec $(INSTALL_DATA) {} $(includedir)/ \;
-	rm -f $(includedir)/config.h
-	touch $(includedir)/config.h
+	test -z "$(DESTDIR)$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
+	$(INSTALL_DATA) $(top_srcdir)/arch/compiler.h "$(DESTDIR)$(pkgincludedir)"
+	find $(top_srcdir)/parallel -name \*.h -not -name "f2c.h" -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/low -name \*.h -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/dev -name \*.h -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/gm -name \*.h -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/dom -name \*.h -not -name "std_internal.h" -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/graphics -name \*.h -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
+	find $(top_srcdir)/np -name \*.h -exec $(INSTALL_DATA) {} "$(DESTDIR)$(pkgincludedir)" \;
 
 # distcheck checks uninstall as well: revert sick trick above
-#uninstall-hook:
-#	for HEADER in `find $(top_srcdir) -name \*.h` ; do \
-#	  BASE=`basename $$HEADER` ; \
-#	  rm -f $(includedir)/$$BASE ; \
-#	done
+uninstall-hook:
+	rm -rf $(DESTDIR)/$(pkgincludedir)
 
 #
 ## automake-options
diff -ruN ug-orig/np/algebra/amgtools.c ug-patched/np/algebra/amgtools.c
--- ug-orig/np/algebra/amgtools.c	2006-06-02 18:15:34.000000000 +0200
+++ ug-patched/np/algebra/amgtools.c	2006-06-02 18:15:34.000000000 +0200
@@ -101,7 +101,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/amgtools.c,v 1.48 2006/06/02 16:15:34 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 REP_ERR_FILE;
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/amgtools.h ug-patched/np/algebra/amgtools.h
--- ug-orig/np/algebra/amgtools.h	2006-05-08 14:27:33.000000000 +0200
+++ ug-patched/np/algebra/amgtools.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/amgtools.h,v 1.15 2006/05/08 12:27:33 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/block.c ug-patched/np/algebra/block.c
--- ug-orig/np/algebra/block.c	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/block.c	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 
 #include "ugdevices.h"
@@ -77,7 +78,7 @@
 static DOUBLE BL_mat1[LOCAL_DIM*LOCAL_DIM];
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/block.c,v 1.16 2006/05/08 12:27:34 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/np/algebra/block.h ug-patched/np/algebra/block.h
--- ug-orig/np/algebra/block.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/block.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/block.h,v 1.10 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/CVS/Entries ug-patched/np/algebra/CVS/Entries
--- ug-orig/np/algebra/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/algebra/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,39 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:19 2004//D2008.11.12.23.00.00
-/Makefile.algebra/1.11/Wed Oct 29 17:22:26 2008//D2008.11.12.23.00.00
-/Makefile.am/1.3/Wed Oct 29 17:22:26 2008//D2008.11.12.23.00.00
-/amgtools.c/1.48/Fri Jun  2 16:15:34 2006//D2008.11.12.23.00.00
-/amgtools.h/1.15/Mon May  8 12:27:33 2006//D2008.11.12.23.00.00
-/blasm.c/1.9/Fri Jun  2 15:33:31 2006//D2008.11.12.23.00.00
-/blasm.h/1.6/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/block.c/1.16/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/block.h/1.10/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/fegeom.c/1.6/Mon May 17 13:29:26 2004//D2008.11.12.23.00.00
-/fegeom.h/1.7/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/ff.c/1.21/Wed Jul 21 09:18:54 2004//D2008.11.12.23.00.00
-/ff.h/1.10/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/ff_gen.c/1.22/Tue Jul 25 08:47:53 2006//D2008.11.12.23.00.00
-/ff_gen.h/1.20/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/fvgeom.c/1.34/Thu Nov 24 09:13:53 2005//D2008.11.12.23.00.00
-/fvgeom.h/1.15/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/matfunc.ct/1.10/Thu Jul 15 16:22:44 1999//D2008.11.12.23.00.00
-/matloop.ct/1.5/Thu Jul 15 16:22:44 1999//D2008.11.12.23.00.00
-/matmode.ct/1.9/Tue Dec  6 11:21:36 2005//D2008.11.12.23.00.00
-/npcheck.c/1.13/Mon Jul 18 13:38:46 2005//D2008.11.12.23.00.00
-/npcheck.h/1.6/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/quadrature.c/1.26/Wed Jun 25 16:41:16 2008//D2008.11.12.23.00.00
-/quadrature.h/1.15/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/sidefvgeom.c/1.1/Wed Oct 29 17:22:26 2008//D2008.11.12.23.00.00
-/sidefvgeom.h/1.1/Wed Oct 29 17:22:26 2008//D2008.11.12.23.00.00
-/sm.c/1.6/Fri Jun  2 16:15:34 2006//D2008.11.12.23.00.00
-/sm.h/1.4/Fri Jun  2 16:15:49 2006//D2008.11.12.23.00.00
-/tff.c/1.4/Thu Mar 13 15:22:38 1997//D2008.11.12.23.00.00
-/transgrid.c/1.57/Tue Jul 12 15:08:17 2005//D2008.11.12.23.00.00
-/transgrid.h/1.3/Wed Jan 24 13:52:35 2001//D2008.11.12.23.00.00
-/ugblas.c/1.105/Fri Nov 17 10:59:50 2006//D2008.11.12.23.00.00
-/ugblas.h/1.13/Mon May  8 12:27:34 2006//D2008.11.12.23.00.00
-/ugeblas.c/1.5/Wed Jul 21 09:18:57 2004//D2008.11.12.23.00.00
-/ugiter.c/1.58/Fri Jun  2 16:15:34 2006//D2008.11.12.23.00.00
-/vecfunc.ct/1.8/Mon Jan 19 09:34:39 2004//D2008.11.12.23.00.00
-/vecloop.ct/1.1/Fri Jul 25 17:44:19 1997//D2008.11.12.23.00.00
-/vecmode.ct/1.4/Tue Dec  6 11:21:36 2005//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/algebra/CVS/Repository ug-patched/np/algebra/CVS/Repository
--- ug-orig/np/algebra/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/algebra/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/algebra
diff -ruN ug-orig/np/algebra/CVS/Root ug-patched/np/algebra/CVS/Root
--- ug-orig/np/algebra/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/algebra/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/algebra/CVS/Tag ug-patched/np/algebra/CVS/Tag
--- ug-orig/np/algebra/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/algebra/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/algebra/.cvsignore ug-patched/np/algebra/.cvsignore
--- ug-orig/np/algebra/.cvsignore	2004-09-08 16:14:19.000000000 +0200
+++ ug-patched/np/algebra/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/np/algebra/fegeom.c ug-patched/np/algebra/fegeom.c
--- ug-orig/np/algebra/fegeom.c	2004-05-17 15:29:26.000000000 +0200
+++ ug-patched/np/algebra/fegeom.c	2008-12-19 11:17:43.000000000 +0100
@@ -27,6 +27,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -131,7 +132,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/fegeom.c,v 1.6 2004/05/17 13:29:26 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/np/algebra/fegeom.h ug-patched/np/algebra/fegeom.h
--- ug-orig/np/algebra/fegeom.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/fegeom.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/fegeom.h,v 1.7 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/ff.c ug-patched/np/algebra/ff.c
--- ug-orig/np/algebra/ff.c	2004-07-21 11:18:54.000000000 +0200
+++ ug-patched/np/algebra/ff.c	2008-12-19 11:17:43.000000000 +0100
@@ -28,6 +28,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <time.h>
@@ -75,7 +76,7 @@
 /****************************************************************************/
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/ff.c,v 1.21 2004/07/21 09:18:54 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
diff -ruN ug-orig/np/algebra/ff_gen.c ug-patched/np/algebra/ff_gen.c
--- ug-orig/np/algebra/ff_gen.c	2006-07-25 10:47:53.000000000 +0200
+++ ug-patched/np/algebra/ff_gen.c	2009-04-29 15:11:55.000000000 +0200
@@ -28,6 +28,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <assert.h>
 #include <math.h>
 #include <string.h>
@@ -136,7 +137,7 @@
 /****************************************************************************/
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/ff_gen.c,v 1.22 2006/07/25 08:47:53 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
@@ -524,7 +525,7 @@
 
 #ifdef __BLOCK_VECTOR_DESC__
 
-static void printBVrec( BLOCKVECTOR *bv_first, char *indent, const BV_DESC *bvd_parent, const BV_DESC_FORMAT *bvdf )
+static void printBVrec( BLOCKVECTOR *bv_first, const char *indent, const BV_DESC *bvd_parent, const BV_DESC_FORMAT *bvdf )
 {
 	register VECTOR *v;
 	BLOCKVECTOR *bv;
diff -ruN ug-orig/np/algebra/ff_gen.h ug-patched/np/algebra/ff_gen.h
--- ug-orig/np/algebra/ff_gen.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/ff_gen.h	2006-05-08 14:31:31.000000000 +0200
@@ -22,7 +22,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/ff_gen.h,v 1.20 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/ff.h ug-patched/np/algebra/ff.h
--- ug-orig/np/algebra/ff.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/ff.h	2006-05-08 14:31:31.000000000 +0200
@@ -21,7 +21,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/ff.h,v 1.10 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/fvgeom.c ug-patched/np/algebra/fvgeom.c
--- ug-orig/np/algebra/fvgeom.c	2005-11-24 10:13:53.000000000 +0100
+++ ug-patched/np/algebra/fvgeom.c	2008-12-19 11:17:43.000000000 +0100
@@ -26,6 +26,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -171,7 +172,7 @@
 static LOCAL_DOUBLES LocalCoords[TAGS];
 
 /* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/fvgeom.c,v 1.34 2005/11/24 09:13:53 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
diff -ruN ug-orig/np/algebra/fvgeom.h ug-patched/np/algebra/fvgeom.h
--- ug-orig/np/algebra/fvgeom.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/fvgeom.h	2006-05-08 14:31:31.000000000 +0200
@@ -23,7 +23,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/fvgeom.h,v 1.15 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/Makefile.algebra ug-patched/np/algebra/Makefile.algebra
--- ug-orig/np/algebra/Makefile.algebra	2008-10-29 18:22:26.000000000 +0100
+++ ug-patched/np/algebra/Makefile.algebra	2002-08-06 19:04:29.000000000 +0200
@@ -10,7 +10,7 @@
 include $(UGROOT)/ug.conf
 
 OBJECTS = ugblas.o ugiter.o transgrid.o block.o quadrature.o fvgeom.o fegeom.o\
-	  sidefvgeom.o ff_gen.o ff.o amgtools.o npcheck.o sm.o blasm.o ugeblas.o
+	  ff_gen.o ff.o amgtools.o npcheck.o sm.o blasm.o ugeblas.o
 
 $(UG_LIB) : $(OBJECTS) Makefile.algebra
 	$(ARCH_AR)  $(ARCH_ARFLAGS) $(UG_LIB) $(OBJECTS)
diff -ruN ug-orig/np/algebra/Makefile.am ug-patched/np/algebra/Makefile.am
--- ug-orig/np/algebra/Makefile.am	2008-10-29 18:22:26.000000000 +0100
+++ ug-patched/np/algebra/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,6 +1,6 @@
-# $Id: Makefile.am,v 1.3 2008/10/29 17:22:26 dmitriy Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
-SOURCES = ugblas.c ugiter.c transgrid.c block.c quadrature.c fvgeom.c fegeom.c sidefvgeom.c ff_gen.c ff.c amgtools.c npcheck.c sm.c blasm.c ugeblas.c amgtools.h blasm.h block.h fegeom.h ff_gen.h ff.h fvgeom.h npcheck.h quadrature.h sm.h transgrid.h ugblas.h
+SOURCES = ugblas.c ugiter.c transgrid.c block.c quadrature.c fvgeom.c fegeom.c ff_gen.c ff.c amgtools.c npcheck.c sm.c blasm.c ugeblas.c amgtools.h blasm.h block.h fegeom.h ff_gen.h ff.h fvgeom.h npcheck.h quadrature.h sm.h transgrid.h ugblas.h
 
 if BUILD2D
   LIB_2D = libalgebra2.la
@@ -19,7 +19,8 @@
 # include templates in distribution tarball
 EXTRA_DIST = matfunc.ct matloop.ct matmode.ct vecfunc.ct vecloop.ct vecmode.ct
 
-include_HEADERS = sm.h fvgeom.h fegeom.h sidefvgeom.h quadrature.h block.h
+npincludedir = $(pkgincludedir)
+npinclude_HEADERS = sm.h fvgeom.h fegeom.h quadrature.h block.h
 
 libalgebra2_la_SOURCES = $(SOURCES)
 libalgebra2_la_CPPFLAGS = $(UG_2DFLAGS)
diff -ruN ug-orig/np/algebra/matfunc.ct ug-patched/np/algebra/matfunc.ct
--- ug-orig/np/algebra/matfunc.ct	1999-07-15 18:22:44.000000000 +0200
+++ ug-patched/np/algebra/matfunc.ct	1999-07-15 18:22:53.000000000 +0200
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/matfunc.ct,v 1.10 1999/07/15 16:22:44 niko Exp $
+$Header$
 */
 
 #ifdef T_USE_MATMUL
diff -ruN ug-orig/np/algebra/matloop.ct ug-patched/np/algebra/matloop.ct
--- ug-orig/np/algebra/matloop.ct	1999-07-15 18:22:44.000000000 +0200
+++ ug-patched/np/algebra/matloop.ct	1999-07-15 18:22:53.000000000 +0200
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/matloop.ct,v 1.5 1999/07/15 16:22:44 niko Exp $
+$Header$
 */
  	#ifdef T_SURFACE_MODE 
 	for (lev=FULLREFINELEVEL(mg); lev<tl; lev++)
diff -ruN ug-orig/np/algebra/matmode.ct ug-patched/np/algebra/matmode.ct
--- ug-orig/np/algebra/matmode.ct	2005-12-06 12:21:36.000000000 +0100
+++ ug-patched/np/algebra/matmode.ct	2005-12-06 12:21:36.000000000 +0100
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/matmode.ct,v 1.9 2005/12/06 11:21:36 sander Exp $
+$Header$
 */
 
 #ifdef T_MOD_SCAL
diff -ruN ug-orig/np/algebra/npcheck.c ug-patched/np/algebra/npcheck.c
--- ug-orig/np/algebra/npcheck.c	2005-07-18 15:38:46.000000000 +0200
+++ ug-patched/np/algebra/npcheck.c	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 
 #include "ugdevices.h"
@@ -80,7 +81,7 @@
 #endif
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/npcheck.c,v 1.13 2005/07/18 13:38:46 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 INT NS_DIM_PREFIX CheckSymmetryOfMatrix (GRID *theGrid, MATDATA_DESC *A)
 {
diff -ruN ug-orig/np/algebra/npcheck.h ug-patched/np/algebra/npcheck.h
--- ug-orig/np/algebra/npcheck.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/npcheck.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/npcheck.h,v 1.6 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/quadrature.c ug-patched/np/algebra/quadrature.c
--- ug-orig/np/algebra/quadrature.c	2008-06-25 18:41:16.000000000 +0200
+++ ug-patched/np/algebra/quadrature.c	2006-06-02 18:15:34.000000000 +0200
@@ -69,7 +69,7 @@
 
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/quadrature.c,v 1.26 2008/06/25 16:41:16 vadym Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
@@ -2301,246 +2301,6 @@
 #undef B_2
 #undef C
 
-
-/* Quadrature formulas from Cools' Encyclopaedia */
-/* Fully symmetric, positive weights, order=6, points=24 */
-#define s_1 0.214602871259152029288839219386284
-#define t_1 1.-3.*s_1
-#define s_2 0.0406739585346113531155794489564100
-#define t_2 1.-3.*s_2
-#define s_3 0.322337890142275510343994470762492
-#define t_3 1.-3.*s_3
-#define u_1 0.0636610018750175252992355276057269
-#define u_2 0.269672331458315808034097805727606
-#define u_3 1.-2.*u_1-u_2
-#define area 0.16666666666666666666666666666666
-#define w_1 ((6.65379170969458201661510459291332e-3)/area)
-#define w_2 ((1.67953517588677382466887290765614e-3)/area)
-#define w_3 ((9.22619692394245368252554630895433e-3)/area)
-#define w_4 ((8.03571428571428571428571428571428e-3)/area)
-
-static const DOUBLE_VECTOR_3D Quadrature3D46_l[] = {
-  {s_1,s_1,s_1},
-  {t_1,s_1,s_1},
-  {s_1,t_1,s_1},
-  {s_1,s_1,t_1},
-  {s_2,s_2,s_2},
-  {t_2,s_2,s_2},
-  {s_2,t_2,s_2},
-  {s_2,s_2,t_2},
-  {s_3,s_3,s_3},
-  {t_3,s_3,s_3},
-  {s_3,t_3,s_3},
-  {s_3,s_3,t_3},
-  {u_1,u_1,u_2},
-  {u_1,u_2,u_1},
-  {u_2,u_1,u_1},
-  {u_1,u_1,u_3},
-  {u_1,u_3,u_1},
-  {u_3,u_1,u_1},
-  {u_1,u_2,u_3},
-  {u_1,u_3,u_2},
-  {u_2,u_1,u_3},
-  {u_3,u_1,u_2},
-  {u_2,u_3,u_1},
-  {u_3,u_2,u_1}
-};
-static const DOUBLE Quadrature3D46_w[] = {
-  w_1,w_1,w_1,w_1,w_2,w_2,w_2,w_2,w_3,w_3,w_3,w_3,
-  w_4,w_4,w_4,w_4,w_4,w_4,w_4,w_4,w_4,w_4,w_4,w_4
-};
-static QUADRATURE Quadrature3D46 = {24, 6, Quadrature3D46_l, Quadrature3D46_w};
-
-#undef s_1
-#undef s_2
-#undef s_3
-#undef t_1
-#undef t_2
-#undef t_3
-#undef u_1
-#undef u_2
-#undef u_3
-#undef area
-#undef w_1
-#undef w_2
-#undef w_3
-#undef w_4
-
-/* Fully symmetric, 4 negative weights, order=7, points=31 */
-#define s_3 0.0782131923303180643739942508375545
-#define t_3 1.-3.*s_3
-#define s_4 0.121843216663905174652156372684818
-#define t_4 1.-3.*s_4
-#define s_5 0.332539164446420624152923823157707
-#define t_5 1.-3.*s_5
-#define u_1 0.1
-#define u_2 0.2
-#define u_3 1.-2.*u_1-u_2
-#define area 0.16666666666666666666666666666666
-#define w_1 ((9.70017636684303350970017636684303e-4)/area)
-#define w_2 (0.0182642234661088202912015685649462/area)
-#define w_3 (0.0105999415244136869164138748545257/area)
-#define w_4 (-0.0625177401143318516914703474927900/area)
-#define w_5 ((4.89142526307349938479576303671027e-3)/area)
-#define w_6 (0.0275573192239858906525573192239858/area)
-
-static const DOUBLE_VECTOR_3D Quadrature3D47_l[] = {
-  {0.5,0.5,0.},
-  {0.5,0.,0.5},
-  {0.,0.5,0.5},
-  {0.,0.,0.5},
-  {0.,0.5,0.},
-  {0.5,0.,0.},
-  {0.25,0.25,0.25},
-  {s_3,s_3,s_3},
-  {t_3,s_3,s_3},
-  {s_3,t_3,s_3},
-  {s_3,s_3,t_3},
-  {s_4,s_4,s_4},
-  {t_4,s_4,s_4},
-  {s_4,t_4,s_4},
-  {s_4,s_4,t_4},
-  {s_5,s_5,s_5},
-  {t_5,s_5,s_5},
-  {s_5,t_5,s_5},
-  {s_5,s_5,t_5},
-  {u_1,u_1,u_2},
-  {u_1,u_2,u_1},
-  {u_2,u_1,u_1},
-  {u_1,u_1,u_3},
-  {u_1,u_3,u_1},
-  {u_3,u_1,u_1},
-  {u_1,u_2,u_3},
-  {u_1,u_3,u_2},
-  {u_3,u_1,u_2},
-  {u_2,u_1,u_3},
-  {u_2,u_3,u_1},
-  {u_3,u_2,u_1}
-};
-static const DOUBLE Quadrature3D47_w[] = {
-  w_1,w_1,w_1,w_1,w_1,w_1,w_2,w_3,w_3,w_3,w_3,w_4,w_4,w_4,w_4,w_5,w_5,w_5,w_5,
-  w_6,w_6,w_6,w_6,w_6,w_6,w_6,w_6,w_6,w_6,w_6,w_6
-};
-static QUADRATURE Quadrature3D47 = {31, 7, Quadrature3D47_l, Quadrature3D47_w};
-
-#undef s_3
-#undef s_4
-#undef s_5
-#undef t_3
-#undef t_4
-#undef t_5
-#undef u_1
-#undef u_2
-#undef u_3
-#undef area
-#undef w_1
-#undef w_2
-#undef w_3
-#undef w_4
-#undef w_5
-#undef w_6
-
-/* Fully symmetric, one negative weight, order=8, points=43 */
-#define s_3 0.206829931610673204083980900024961
-#define t_3 1.-3.*s_3
-#define s_4 0.0821035883105467230906058078714215
-#define t_4 1.-3.*s_4
-#define s_5 5.78195050519799725317663886414270e-3
-#define t_5 1.-3.*s_5
-#define v_1 0.0505327400188942244256245285579071
-#define v_2 0.5-v_1
-#define u_1 0.229066536116811139600408854554753
-#define u_2 0.0356395827885340437169173969506114
-#define u_3 1.-2.*u_1-u_2
-#define y_1 0.0366077495531974236787738546327104
-#define y_2 0.190486041934633455699433285315099
-#define y_3 1.-2.*y_1-y_2
-#define area 0.16666666666666666666666666666666
-#define w_1 (-0.0205001886586399158405865177642941/area)
-#define w_3 (0.0142503058228669012484397415358704/area)
-#define w_4 ((1.96703331313390098756280342445466e-3)/area)
-#define w_5 ((1.69834109092887379837744566704016e-4)/area)
-#define w_6 ((4.57968382446728180074351446297276e-3)/area)
-#define w_7 ((5.70448580868191850680255862783040e-3)/area)
-#define w_8 ((2.14051914116209259648335300092023e-3)/area)
-
-static const DOUBLE_VECTOR_3D Quadrature3D48_l[] = {
-  {0.25,0.25,0.25},
-  {s_3,s_3,s_3},
-  {t_3,s_3,s_3},
-  {s_3,t_3,s_3},
-  {s_3,s_3,t_3},
-  {s_4,s_4,s_4},
-  {t_4,s_4,s_4},
-  {s_4,t_4,s_4},
-  {s_4,s_4,t_4},
-  {s_5,s_5,s_5},
-  {t_5,s_5,s_5},
-  {s_5,t_5,s_5},
-  {s_5,s_5,t_5},
-  {v_1,v_1,v_2},
-  {v_1,v_2,v_1},
-  {v_2,v_1,v_1},
-  {v_1,v_2,v_2},
-  {v_2,v_1,v_2},
-  {v_2,v_2,v_1},
-  {u_1,u_1,u_2},
-  {u_1,u_2,u_1},
-  {u_2,u_1,u_1},
-  {u_1,u_1,u_3},
-  {u_1,u_3,u_1},
-  {u_3,u_1,u_1},
-  {u_1,u_2,u_3},
-  {u_1,u_3,u_2},
-  {u_3,u_1,u_2},
-  {u_2,u_1,u_3},
-  {u_2,u_3,u_1},
-  {u_3,u_2,u_1},
-  {y_1,y_1,y_2},
-  {y_1,y_2,y_1},
-  {y_2,y_1,y_1},
-  {y_1,y_1,y_3},
-  {y_1,y_3,y_1},
-  {y_3,y_1,y_1},
-  {y_1,y_2,y_3},
-  {y_1,y_3,y_2},
-  {y_3,y_1,y_2},
-  {y_2,y_1,y_3},
-  {y_2,y_3,y_1},
-  {y_3,y_2,y_1}
-};
-static const DOUBLE Quadrature3D48_w[] = {
-  w_1,w_3,w_3,w_3,w_3,w_4,w_4,w_4,w_4,w_5,w_5,w_5,w_5,w_6,w_6,w_6,w_6,w_6,w_6,
-  w_7,w_7,w_7,w_7,w_7,w_7,w_7,w_7,w_7,w_7,w_7,w_7,
-  w_8,w_8,w_8,w_8,w_8,w_8,w_8,w_8,w_8,w_8,w_8,w_8
-};
-static QUADRATURE Quadrature3D48 = {43, 8, Quadrature3D48_l, Quadrature3D48_w};
-
-#undef s_3
-#undef s_4
-#undef s_5
-#undef t_3
-#undef t_4
-#undef t_5
-#undef v_1
-#undef v_2
-#undef u_1
-#undef u_2
-#undef u_3
-#undef y_1
-#undef y_2
-#undef y_3
-#undef area
-#undef w_1
-#undef w_3
-#undef w_4
-#undef w_5
-#undef w_6
-#undef w_7
-#undef w_8
-
-
-
 static const DOUBLE_VECTOR_3D Quadrature3D52_l[] = {{0.58541020, 0.72819660, 0.13819660},
     										  {0.13819660, 0.72819660, 0.13819660},
     										  {0.13819660, 0.27630920, 0.58541020},
@@ -3471,12 +3231,7 @@
 			  case 1:  return(&Quadrature3D41);
 			  case 2:  return(&Quadrature3D42);
 			  case 3:  return(&Quadrature3D43);
-			  case 4:
-              case 5:  return(&Quadrature3D45);
-			  case 6:  return(&Quadrature3D46);
-			  case 7:  return(&Quadrature3D47);
-			  case 8:  return(&Quadrature3D48);
-			  default: return(&Quadrature3D48);
+			  default: return(&Quadrature3D45);
 			  }
 		  case 5: return(&Quadrature3D52);
 		  case 6: 
@@ -3595,7 +3350,7 @@
 			  case 4:	return(&Quadrature2D_Triangle_P4_N6);
 			  case 5:	return(&Quadrature2D_Triangle_P5_N7);
 			  case 6:	return(&Quadrature2D_Triangle_P6_N12a);
-			  case 7:	return(&Quadrature2D_Triangle_P7_N15);
+			  case 7:	return(&Quadrature2D_Triangle_P7_N12);
 			  case 8:	return(&Quadrature2D_Triangle_P8_N16);
 			  case 9:	return(&Quadrature2D_Triangle_P9_N19);
 			  case 10:	return(&Quadrature2D_Triangle_P10_N25a);
@@ -3611,14 +3366,13 @@
 			  case 2:	return(&Quadrature2D_Quad_P2_N4);
 			  case 3:	return(&Quadrature2D_Quad_P3_N4a);
 			  case 4:
-			  case 5:	return(&Quadrature2D_Quad_P5_N8);
+			  case 5:	return(&Quadrature2D_Quad_P5_N7);
 			  case 6:
 			  case 7:	return(&Quadrature2D_Quad_P7_N12);
 			  case 8:
 			  case 9:	return(&Quadrature2D_Quad_P9_N20b);
-/* 			  case 10:	return(&Quadrature2D_Quad_P11_N24); */
-/* 			  default:	return(&Quadrature2D_Quad_P11_N24); */
-			  default:	return(&Quadrature2D_Quad_P9_N20b);
+			  case 10:	return(&Quadrature2D_Quad_P11_N24);
+			  default:	return(&Quadrature2D_Quad_P11_N24);
 			  }
 		  }
 	  case 3:
@@ -3631,12 +3385,7 @@
 			  case 1:  return(&Quadrature3D41);
 			  case 2:  return(&Quadrature3D42);
 			  case 3:  return(&Quadrature3D43);
-			  case 4:
-              case 5:  return(&Quadrature3D45);
-			  case 6:  return(&Quadrature3D46);
-              case 7:  return(&Quadrature3D47);
-			  case 8:  return(&Quadrature3D48);
-			  default: return(&Quadrature3D48);
+			  default: return(&Quadrature3D45);
 			  }
 		  case 5: return(&Quadrature3D52);
 		  case 6: 
diff -ruN ug-orig/np/algebra/quadrature.h ug-patched/np/algebra/quadrature.h
--- ug-orig/np/algebra/quadrature.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/quadrature.h	2006-05-08 14:31:31.000000000 +0200
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/quadrature.h,v 1.15 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/sidefvgeom.c ug-patched/np/algebra/sidefvgeom.c
--- ug-orig/np/algebra/sidefvgeom.c	2008-10-29 18:22:26.000000000 +0100
+++ ug-patched/np/algebra/sidefvgeom.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,641 +0,0 @@
-/* sidefvgeom.c - computation of the secondary grid geometry (for the FV-method)
- * on sides of primary grid elements.
- **
- * COORDINATE SYSTEMS:
- * There are 4 coordinate systems considered on the sides of grid elements:
- * 1. The global geometric coordinate system (in 2d or 3d). This system
- *    is used to identify the points in the whole domain. It is refered to
- *    as the 'global geometric coordinates'.
- * 2. The local (barycentric) coordinate system (of the same dimensionality
- *    as in 1.) of a given grid element. It is refered to as the 'local
- *    (barycentric) coordinates w.r.t. the grid element'.
- * 3. Every side is planar and equipped with a basis consisting of vectors
- *    in the global geometric space. In this basis, points in the side
- *    have coordinates called 'geometric coordinates w.r.t. the side basis'.
- * 4. For every side, local (barycentric) coordinates of the reduced
- *    dimensionality are considered. These coordinates are called 'side
- *    barycentric coordinates'.
- * The side barycentric coordinates are not equal to components of the set
- * the barycentric coordinates w.r.t. the grid element. But the transformation
- * of the side barycentric coordinates into the barycentric coordinates w.r.t.
- * the grid element is linear (even if the transformation is bilinear).
- **
- * SHAPE FUNCTIONS:
- * On the sides, linear and bilinear shape functions are considered. These
- * shape functions are restrictions of the shape functions considered for the
- * whole grid element.
- **
- *
- * History:
- * Sep. 26, 2007 - created
- * D. Logashenko
- */
-#include <stdio.h>
-#include <math.h>
-
-/* UG headers: */
-#include "ugdevices.h"
-#include "enrol.h"
-#include "compiler.h"
-#include "misc.h"
-#include "gm.h"
-#include "elements.h"
-#include "evm.h"
-#include "ugenv.h"
-#include "ugm.h"
-#include "algebra.h"
-#include "shapes.h"
-#include "cmdint.h"
-#include "commands.h"
-#include "helpmsg.h"
-#include "debug.h"
-#include "general.h"
-
-/* Own header: */
-#include "sidefvgeom.h"
-
-/* Local (barycentric) coordinates of important geometric points
- * w.r.t. the grid element:
- */
-struct local_geom_coord
- {
-  DOUBLE_VECTOR co [MAX_CORNERS_OF_ELEM]; /* corners */
-  DOUBLE_VECTOR sm [MAX_SIDES_OF_ELEM]; /* side midpoints */
-#ifdef __THREEDIM__
-  DOUBLE_VECTOR em [MAX_EDGES_OF_ELEM]; /* edge midpoints */
-#endif
- };
-
-static struct local_geom_coord LocalCoords [TAGS];
-
-/* Side local (barycentric) coordinates of important points (of a side): */
-struct local_sd_geom_coord
- {
-  DOUBLE co [MAX_CORNERS_OF_SIDE] [DIM-1]; /* corners */
-  DOUBLE cm [DIM-1]; /* center of mass */
-#ifdef __THREEDIM__
-  DOUBLE em [4] [DIM-1]; /* edge midpoints */
-  /* REMARK: We use the following numbering of the edges (sides of the side):
-   * edge i connects corners i and (i + 1) % (number of corners of the edge).
-   */
-#endif
- };
-
-#ifdef __THREEDIM__
-static struct local_sd_geom_coord SideLocalCoords [5];
-#else
-static struct local_sd_geom_coord SideLocalCoords [3];
-#endif
-
-/* fill_local_geom_coord - computes the local coordinates of
- * the important geometric points of different elements. The
- * function returns 0 if OK, non-zero on an error:
- */
-static INT fill_local_geom_coord
- (
-  INT tag /* tag of the element */
- )
- {
-  struct local_geom_coord * lc = LocalCoords + tag;
-  INT i, j, k;
-  INT nco, nsi, ned;
-  DOUBLE_VECTOR s;
-	
-  nco = CORNERS_OF_TAG(tag);
-  ned = EDGES_OF_TAG(tag);
-  nsi = SIDES_OF_TAG(tag);
-  
-  /* Corners: */
-  for (i = 0; i < nco; i++)
-   V_DIM_COPY (LOCAL_COORD_OF_TAG (tag, i), lc->co [i]);
-  
-#ifdef __THREEDIM__
-  /* Edge midpoints: */
-  for (k = 0; k < ned; k++)
-   {
-    i = CORNER_OF_EDGE_TAG (tag, k, 0);
-    j = CORNER_OF_EDGE_TAG (tag, k, 1);
-    V_DIM_AVG2 (lc->co [i], lc->co [j], lc->em [k]);
-   };
-#endif
-  
-  /* Side midpoints: */
-  for (k = 0; k < nsi; k++)
-   {
-    V_DIM_CLEAR (s);
-    j = CORNERS_OF_SIDE_TAG (tag, k);
-    for (i = 0; i < CORNERS_OF_SIDE_TAG (tag, k); i++)
-     V_DIM_ADD1 (lc->co [CORNER_OF_SIDE_TAG (tag, k, i)], s);
-    for (i = 0; i < DIM; i++) s [i] /= j;
-    V_DIM_COPY (s, lc->sm [k]);
-   };
-  
-  return 0;
- }
-
-/* fill_side_local_geom_coord - computes the side local coordinates
- * of the important geometric points of different elements. The
- * function returns 0 if OK, non-zero on an error:
- */
-static void fill_side_local_geom_coord ()
- {
-  struct local_sd_geom_coord * lc;
-  INT co, n_co;
-  
-#ifdef __TWODIM__
-  lc = SideLocalCoords + 2;
-  
-  lc->co[0][_X_] = 0; lc->co[1][_X_] = 1;
-  lc->cm [_X_] = 0.5;
-#else
-  
-  /* Triangle: */
-  lc = SideLocalCoords + 3;
-  lc->co [0] [_X_] = 0; lc->co [0] [_Y_] = 0;
-  lc->co [1] [_X_] = 1; lc->co [1] [_Y_] = 0;
-  lc->co [2] [_X_] = 0; lc->co [2] [_Y_] = 1;
-  
-  /* Quadrilateral: */
-  lc = SideLocalCoords + 4;
-  lc->co [0] [_X_] = 0; lc->co [0] [_Y_] = 0;
-  lc->co [1] [_X_] = 1; lc->co [1] [_Y_] = 0;
-  lc->co [2] [_X_] = 1; lc->co [2] [_Y_] = 1;
-  lc->co [3] [_X_] = 0; lc->co [3] [_Y_] = 1;
-  
-  /* General: */
-  for (n_co = 3; n_co <= 4; n_co++)
-   {
-    lc = SideLocalCoords + n_co;
-    
-    /* Center of mass: */
-    V2_COPY (lc->co [0], lc->cm);
-    for (co = 1; co < n_co; co++)
-     V2_ADD1 (lc->co [co], lc->cm);
-    V2_SCALE (1.0/n_co, lc->cm);
-    
-    /* Edge midpoints: */
-    for (co = 0; co < n_co; co++)
-     V2_AVG2 (lc->co [co], lc->co [(co + 1) % n_co], lc->em [co]);
-   };
-  
-#endif
- }
-
-#ifdef __THREEDIM__
-
-/* t_area_3d - returns area of a triangle in 3d: */
-static DOUBLE t_area_3d
- (
-  DOUBLE * x_0, DOUBLE * x_1, DOUBLE * x_2 /* coord. of the corners */
- )
- {
-  DOUBLE d_a [DIM], d_b [DIM], normal [DIM], t;
-  V3_SUBTRACT(x_1, x_0, d_a);
-  V3_SUBTRACT(x_2, x_0, d_b);
-  V3_VECTOR_PRODUCT(d_a, d_b, normal);
-  V3_EUKLIDNORM (normal, t);
-  return t / 2;
- }
-
-#endif
-
-/* fill_side_shapes_and_deriv - computes the values of the shape
- * functions and their gradients at the ip's. It is assumed that
- * the geometry data are already initialized. The function returns
- * 0 if OK and non-zero on an error:
- */
-static INT fill_side_shapes_and_deriv
- (
-  sd_FVGeometry * fvg /* the object of sd_FVGeometry to initialize */
- )
- {
-  INT i, co, i_scvf;
-  DOUBLE loc_grad [DIM-1], grad [DIM-1];
-#ifdef __TWODIM__
-  DOUBLE t;
-#else
-  DOUBLE J [DIM-1][DIM-1], J_inv [DIM-1][DIM-1];
-#endif
-  sd_SubControlVolumeFace * scvf;
-  sd_SubControlVolume * scv;
-  
-  /* The subcontrol-volume faces: */
-  for (i_scvf = 0; i_scvf < sd_FVG_NSCVF (fvg); i_scvf++)
-   {
-    scvf = sd_FVG_SCVF (fvg, i_scvf);
-	
-	for (co = 0; co < sd_FVG_NSCV (fvg); co++)
-     sd_SCVF_SHAPE (scvf, co) = sd_GN (sd_FVG_NSCV (fvg), co, sd_SCVF_sdLIP (scvf));
-    
-#ifdef __TWODIM__
-    t = 1 / (sd_SCV_VOL (sd_FVG_SCV(fvg,0)) + sd_SCV_VOL (sd_FVG_SCV(fvg,1)));
-	sd_SCVF_GRAD (scvf, 0) [0] = - t;
-	sd_SCVF_GRAD (scvf, 1) [0] = t;
-#else
-    if (GetSideTransformJ (fvg, sd_SCVF_sdLIP (scvf), J, J_inv)) return __LINE__;
-    for (co = 0; co < sd_FVG_NSCV (fvg); co++)
-     {
-	  if (sd_D_GN (sd_FVG_NSCV (fvg), co, sd_SCVF_sdLIP (scvf), loc_grad))
-	   return __LINE__;
-	  MM2_TIMES_V2 (J_inv, loc_grad, grad);
-	  V2_COPY (grad, sd_SCVF_GRAD (scvf, co));
-	 };
-#endif
-   };
-  
-  /* The subcontrol volumes: */
-  for (i_scvf = 0; i_scvf < sd_FVG_NSCV (fvg); i_scvf++)
-   {
-    scv = sd_FVG_SCV (fvg, i_scvf);
-	
-	for (co = 0; co < sd_FVG_NSCV (fvg); co++)
-     sd_SCV_SCSHAPE (scv, co) = sd_GN (sd_FVG_NSCV (fvg), co, sd_SCV_sdLSC (scv));
-   };
-  
-  return 0;
- }
-
-/* EvaluateSideFVGeometry - computes the values of all the fields
- * of an sd_FVGeometry object. Note that unlike 'EvaluateFVGeometry'
- * for 'FVElementGeometry' (cf. fvgeom.[ch]), this function computes
- * also the shapes and their derivatives. The function return 0 if
- * OK and non-zero on errors:
- */
-INT EvaluateSideFVGeometry
- (
-  ELEMENT * elem, /* element for which the geometry schould be computed */
-  INT side, /* side of the element */
-  sd_FVGeometry * fvg /* the object of sd_FVGeometry to initialize */
- )
- {
-  INT i, j, co, ed, n_scv, n_scvf;
-  DOUBLE side_center [DIM], t;
-  sd_SubControlVolume * scv;
-  sd_SubControlVolumeFace * scvf;
-  struct local_geom_coord * lc = LocalCoords + TAG (elem);
-  struct local_sd_geom_coord * side_lc;
-#ifdef __TWODIM__
-  DOUBLE scv_len;
-#else
-  INT co_1, side_co, side_co_1, side_ed;
-  char co_ind [MAX_CORNERS_OF_ELEM];
-  DOUBLE scvf_len;
-  DOUBLE edge_center [DIM], scvf_vec [DIM], vec_2d [DIM - 1];
-#endif
-  
-  /*** Check consistency: ***/
-  if (elem == NULL)
-   return __LINE__;
-  if (side < 0 || side >= SIDES_OF_ELEM (elem))
-   return __LINE__;
-  
-  /*** Initialize the object: ***/
-  
-  sd_FVG_ELEM (fvg) = elem;
-  sd_FVG_SIDE (fvg) = side;
-  
-#ifdef __TWODIM__
-  sd_FVG_NSCV (fvg) = n_scv = 2;
-  sd_FVG_NSCVF (fvg) = n_scvf = 1;
-#else
-  sd_FVG_NSCV (fvg) = n_scv = CORNERS_OF_SIDE (elem, side);
-  sd_FVG_NSCVF (fvg) = n_scvf = EDGES_OF_SIDE (elem, side);
-#endif
-  
-  side_lc = SideLocalCoords + n_scv;
-  
-  /*** Corners: ***/
-#ifdef __THREEDIM__
-  memset (co_ind, -1, MAX_CORNERS_OF_ELEM);
-#endif
-  for (i = 0; i < n_scv; i++)
-   {
-    sd_FVG_CO (fvg, i) = co = CORNER_OF_SIDE (elem, side, i);
-#ifdef __THREEDIM__
-    co_ind [co] = i;
-#endif
-    V_DIM_COPY (CVECT (MYVERTEX (CORNER (elem, co))), sd_FVG_GCO (fvg, i));
-    V_DIM_COPY (lc->co [co], sd_FVG_LCO (fvg, i));
-    V_BDIM_COPY (side_lc->co [i], sd_FVG_sdLCO (fvg, i));
-   };
-  
-  /*** The orthonormal basis: ***/
-#ifdef __TWODIM__
-  V_DIM_SUBTRACT (sd_FVG_GCO (fvg, 1), sd_FVG_GCO (fvg, 0), sd_FVG_BVEC (fvg, 0));
-  V_DIM_EUKLIDNORM (sd_FVG_BVEC (fvg, 0), t);
-  for (i = 0; i < DIM; i++) sd_FVG_BVEC (fvg, 0) [i] /= t;
-  for (co = CORNERS_OF_ELEM (elem) - 1; co >= 0; co--)
-   if (co != sd_FVG_CO (fvg, 0) && co != sd_FVG_CO (fvg, 1))
-    break;
-  V_DIM_SUBTRACT (CVECT (MYVERTEX (CORNER (elem, co))), sd_FVG_GCO (fvg, 0),
-   sd_FVG_BVEC (fvg, 1));
-  t = - V_DIM_SCAL_PROD (sd_FVG_BVEC (fvg, 1), sd_FVG_BVEC (fvg, 0));
-  V_DIM_SCALEADD1 (t, sd_FVG_BVEC (fvg, 0), sd_FVG_BVEC (fvg, 1));
-#else
-  V_DIM_SUBTRACT (sd_FVG_GCO (fvg, 1), sd_FVG_GCO (fvg, 0), sd_FVG_BVEC (fvg, 0));
-  V_DIM_EUKLIDNORM (sd_FVG_BVEC (fvg, 0), t);
-  for (i = 0; i < DIM; i++) sd_FVG_BVEC (fvg, 0) [i] /= t;
-  V_DIM_SUBTRACT (sd_FVG_GCO (fvg, 2), sd_FVG_GCO (fvg, 0), sd_FVG_BVEC (fvg, 1));
-  t = - V_DIM_SCAL_PROD (sd_FVG_BVEC (fvg, 0), sd_FVG_BVEC (fvg, 1))
-   / V_DIM_SCAL_PROD (sd_FVG_BVEC (fvg, 0), sd_FVG_BVEC (fvg, 0));
-  V_DIM_SCALEADD1 (t, sd_FVG_BVEC (fvg, 0), sd_FVG_BVEC (fvg, 1));
-  V_DIM_EUKLIDNORM (sd_FVG_BVEC (fvg, 1), t);
-  for (i = 0; i < DIM; i++) sd_FVG_BVEC (fvg, 1) [i] /= t;
-  for (co = CORNERS_OF_ELEM (elem) - 1; co >= 0; co--)
-   {
-    for (i = 0; i < n_scv; i++)
-	 if (co == sd_FVG_CO (fvg, i))
-	  goto try_next_corner;
-    break;
-	try_next_corner:;
-   };
-  V_DIM_SUBTRACT (CVECT (MYVERTEX (CORNER (elem, co))), sd_FVG_GCO (fvg, 0),
-   sd_FVG_BVEC (fvg, 2));
-  t = - V_DIM_SCAL_PROD (sd_FVG_BVEC (fvg, 2), sd_FVG_BVEC (fvg, 0));
-  V_DIM_SCALEADD1 (t, sd_FVG_BVEC (fvg, 0), sd_FVG_BVEC (fvg, 2));
-  t = - V_DIM_SCAL_PROD (sd_FVG_BVEC (fvg, 2), sd_FVG_BVEC (fvg, 1));
-  V_DIM_SCALEADD1 (t, sd_FVG_BVEC (fvg, 1), sd_FVG_BVEC (fvg, 2));
-#endif
-  
-  /*** Important geometric data: ***/
-  
-  V_DIM_CLEAR (side_center);
-  for (co = 0; co < n_scv; co++)
-   V_DIM_ADD1 (sd_FVG_GCO (fvg, co), side_center);
-  for (i = 0; i < DIM; i++)
-   side_center [i] /= n_scv;
-  V_DIM_COPY (side_center, sd_FVG_GCM (fvg));
-  
-  /*** Subcontrol volumes and their faces: ***/
-
-#ifdef __TWODIM__
-  
-  /* 2d: Two subcontrol volumes: */
-  
-  V_DIM_EUKLIDNORM_OF_DIFF (side_center, sd_FVG_GCO (fvg, 0), scv_len);
-  
-  scv = sd_FVG_SCV (fvg, 0);
-  sd_SCV_CO (scv) = sd_FVG_CO (fvg, 0);
-  V_DIM_COPY (sd_FVG_GCO (fvg, 0), sd_SCV_GCO (scv));
-  V_BDIM_AVG2 (sd_FVG_sdLCO (fvg, 0), side_lc->cm, sd_SCV_sdLSC (scv));
-  V_DIM_AVG2 (sd_FVG_LCO (fvg, 0), lc->sm [side], sd_SCV_LSC (scv));
-  V_DIM_AVG2 (sd_SCV_GCO (scv), side_center, sd_SCV_GSC (scv));
-  sd_SCV_VOL (scv) = scv_len;
-  
-  scv = sd_FVG_SCV (fvg, 1);
-  sd_SCV_CO (scv) = sd_FVG_CO (fvg, 1);
-  V_DIM_COPY (sd_FVG_GCO (fvg, 1), sd_SCV_GCO (scv));
-  V_BDIM_AVG2 (sd_FVG_sdLCO (fvg, 1), side_lc->cm, sd_SCV_sdLSC (scv));
-  V_DIM_AVG2 (sd_FVG_LCO (fvg, 1), lc->sm [side], sd_SCV_LSC (scv));
-  V_DIM_AVG2 (sd_SCV_GCO (scv), side_center, sd_SCV_GSC (scv));
-  sd_SCV_VOL (scv) = scv_len;
-  
-  /* 2d: Only one subcontrol volume face. */
-  scvf = sd_FVG_SCVF (fvg, 0);
-  sd_SCVF_FROM (scvf) = sd_FVG_CO (fvg, 0); sd_SCVF_sdFROM (scvf) = 0;
-  sd_SCVF_TO (scvf) = sd_FVG_CO (fvg, 1); sd_SCVF_sdTO (scvf) = 1;
-  sd_SCVF_NORMAL (scvf) [0] = 1;
-  V_BDIM_COPY (side_lc->cm, sd_SCVF_sdLIP (scvf));
-  V_DIM_COPY (lc->sm [side], sd_SCVF_LIP (scvf));
-  V_DIM_COPY (side_center, sd_SCVF_GIP (scvf));
-
-#else
-  
-  for (j = 0; j < n_scv; j++) /* j loops the corners of the side */
-   {
-    scv = sd_FVG_SCV (fvg, j);
-    sd_SCV_CO (scv) = sd_FVG_CO (fvg, j);
-    V_DIM_COPY (sd_FVG_GCO (fvg, j), sd_SCV_GCO (scv));
-    sd_SCV_VOL (scv) = 0; /* computed later */
-    
-    /* This is only the beginning of the computation of the scv centers: */
-	V_BDIM_ADD (sd_FVG_sdLCO (fvg, j), side_lc->sm, sd_SCV_sdLSC (scv));
-	V_DIM_ADD (sd_FVG_LCO (fvg, j), lc->sm [side], sd_SCV_LSC (scv));
-	V_DIM_ADD (sd_SCV_GCO (scv), side_center, sd_SCV_GSC (scv));
-   };
-  
-  for (i = 0; i < n_scvf; i++) /* i loops the edges of the side */
-   {
-    scvf = sd_FVG_SCVF (fvg, i);
-    ed = EDGE_OF_SIDE (elem, side, i);
-    V_DIM_AVG2 (CVECT (MYVERTEX (CORNER (elem, co = CORNER_OF_EDGE (elem, ed, 0)))),
-     CVECT (MYVERTEX (CORNER (elem, co_1 = CORNER_OF_EDGE (elem, ed, 1)))),
-      edge_center);
-    if ((side_co = co_ind [co]) == -1 || (side_co_1 = co_ind [co_1]) == -1)
-     return __LINE__;
-    if ((side_co == n_scv - 1 && side_co_1 == 0)
-        || (side_co == 0 && side_co_1 == n_scv - 1))
-     side_ed = n_scv - 1;
-    else if (side_co < side_co_1)
-     {
-      if (side_co_1 - side_co != 1) return __LINE__;
-      side_ed = side_co;
-     }
-    else if (side_co - side_co_1 == 1)
-     side_ed = side_co_1;
-    else return __LINE__;
-    
-    /* The volumes of the subcontrol volumes: */
-    
-    scv = sd_FVG_SCV (j = side_co);
-    sd_SCV_VOL (scv) += t_area_3d (side_center, sd_FVG_GCO (fvg, j), edge_center);
-	V_BDIM_ADD1 (side_lc->em [side_ed], sd_SCV_sdLSC (scv));
-	V_DIM_ADD1 (lc->em [ed], sd_SCV_LSC (scv));
-	V_DIM_ADD1 (edge_center, sd_SCV_GSC (scv));
-    
-    scv = sd_FVG_SCV (j = side_co_1);
-    sd_SCV_VOL (scv) += t_area_3d (side_center, sd_FVG_GCO (fvg, j), edge_center);
-	V_BDIM_ADD1 (side_lc->em [side_ed], sd_SCV_sdLSC (scv));
-	V_DIM_ADD1 (lc->em [ed], sd_SCV_LSC (scv));
-	V_DIM_ADD1 (edge_center, sd_SCV_GSC (scv));
-    
-    /* Global and barycentric coordinates of the ip: */
-    V_DIM_AVG2 (side_center, edge_center, sd_SCVF_GIP(scvf));
-    V_DIM_AVG2 (lc->sm [side], lc->em [ed], sd_SCVF_LIP(scvf));
-    V_DIM_AVG2 (side_lc->cm, lc->em [side_ed], sd_SCVF_sdLIP(scvf));
-    
-    /* The normal vector to the scvf (in the coordinates of the local basis): */
-    V_DIM_SUBTRACT (side_center, edge_center, scvf_vec);
-    V_DIM_EUKLIDNORM (scvf_vec, scvf_len);
-    sd_SCVF_NORMAL (scvf) [0] = - V_DIM_SCAL_PROD (scvf_vec, sd_FVG_BVEC (fvg, 1));
-    sd_SCVF_NORMAL (scvf) [1] = V_DIM_SCAL_PROD (scvf_vec, sd_FVG_BVEC (fvg, 0));
-    V2_EUKLIDNORM (sd_SCVF_NORMAL (scvf), t);
-    scvf_len /= t;
-    V2_SCALE (scvf_len, sd_SCVF_NORMAL (scvf));
-    
-    /* The from- and to- corners: */
-    V_DIM_SUBTRACT (CVECT (MYVERTEX (CORNER (elem, co))),
-     edge_center, scvf_vec);
-    vec_2d [0] = V_DIM_SCAL_PROD (scvf_vec, sd_FVG_BVEC (fvg, 0));
-    vec_2d [1] = V_DIM_SCAL_PROD (scvf_vec, sd_FVG_BVEC (fvg, 1));
-    if (V2_SCAL_PROD (vec_2d, sd_SCVF_NORMAL (scvf)) > 0)
-     {
-      sd_SCVF_FROM (scvf) = co_1; sd_SCVF_TO (scvf) = co;
-      sd_SCVF_sdFROM (scvf) = side_co_1; sd_SCVF_sdTO (scvf) = side_co;
-     }
-    else
-     {
-      sd_SCVF_FROM (scvf) = co; sd_SCVF_TO (scvf) = co_1;
-      sd_SCVF_sdFROM (scvf) = side_co; sd_SCVF_sdTO (scvf) = side_co_1;
-     };
-   };
-  
-  for (j = 0; j < n_scv; j++) /* j loops the corners of the side */
-   {
-    scv = sd_FVG_SCV (fvg, j);
-    V_BDIM_SCALE (0.25, sd_SCV_sdLSC (scv));
-    V_DIM_SCALE (0.25, sd_SCV_LSC (scv));
-    V_DIM_SCALE (0.25, sd_SCV_GSC (scv));
-   };
-  
-#endif
-  
-  /*** Compute the shape functions and their derivatives: ***/
-  return fill_side_shapes_and_deriv (fvg);
- }
-
-/* sd_GN - returns the value of the shape function depending on the side
- * barycentric coordinates. On an error, the function returns -1:
- */
-DOUBLE sd_GN
- (
-  INT n_co, /* num. of corners of the side */
-  INT shape_i, /* index of the shape func. (the corner, where the func. is 1) */
-  DOUBLE * l_coord /* DIM - 1 side barycentric coordinates */
- )
- {
-#ifdef __TWODIM__
-  /* The side is a segment: */
-  if (shape_i == 0) return 1 - *l_coord;
-  return *l_coord;
-#else
-  /* The side is either a triangle or a quadrilateral: */
-  if (n_co == 3)
-   {
-    if (shape_i == 0) return 1 - l_coord[0] - l_coord[1];
-    if (shape_i == 1) return l_coord[0];
-    return l_coord[1];
-   }
-  else if (n_co == 4)
-   {
-    if (shape_i == 0) return (1 - l_coord[0]) * (1 - l_coord[1]);
-    if (shape_i == 1) return l_coord[0] * (1 - l_coord[1]);
-    if (shape_i == 2) return l_coord[0] * l_coord[1];
-    return (1 - l_coord[0]) * l_coord[1];
-   }
-  else return -1;
-#endif
- }
-
-/* sd_D_GN - computes the gradients of the shape functions depending on the side
- * barycentric coordinates. The function returns 0 if OK, non-zero on an error:
- */
-INT sd_D_GN
- (
-  INT n_co, /* num. of corners of the side */
-  INT shape_i, /* index of the shape func. (the corner, where the func. is 1) */
-  DOUBLE * l_coord, /* DIM - 1 side barycentric coordinates */
-  DOUBLE * grad /* to save DIM - 1 components of the gradient */
- )
- {
-#ifdef __TWODIM__
-  /* The side is a segment: */
-  if (shape_i == 0) *grad = -1;
-  else *grad = 1;
-#else
-  /* The side is either a triangle or a quadrilateral: */
-  if (n_co == 3)
-   {
-    if (shape_i == 0) {grad[0] = -1; grad[1] = -1;};
-    else if (shape_i == 1) {grad[0] = 1; grad[1] = 0;};
-    else {grad[0] = 0; grad[1] = 1;};
-   }
-  else if (n_co == 4)
-   {
-    if (shape_i == 0) {grad[0] = -1 + l_coord[1]; grad[1] = -1 + l_coord[0];};
-    else if (shape_i == 1) {grad[0] = 1 - l_coord[1]; grad[1] = l_coord[0];};
-    else if (shape_i == 2) {grad[0] = l_coord[1]; grad[1] = l_coord[0];};
-    else {grad[0] = - l_coord[1]; grad[1] =  1 - l_coord[0];};
-   }
-  else return __LINE__;
-#endif
-  
-  return 0;
- }
-
-/* GetSideTransformJ - computes the Jacobian of the transformation
- * of the side barycentric coordinates into the geometric coordinates
- * w.r.t. the side basis. The function returns 0 if OK, nonzero
- * on an error:
- */
-INT GetSideTransformJ
- (
-  sd_FVGeometry * fvg, /* the FV-geometry of the side */
-  DOUBLE * l_coord, /* side baricentr. coord. of the pnt (DIM-1 values) */
-  DOUBLE J[][DIM-1], /* for the Jacobian ((DIM-1)*(DIM-1) values) */
-  DOUBLE J_inv[][DIM-1] /* for the inv. Jacobian ((DIM-1)*(DIM-1) values; may be NULL) */
- )
- {
-#ifdef __TWODIM__
-  /* The side is a segment: */
-  J[0][0] = sd_SCV_VOL (sd_FVG_SCV (fvg, 0)) + sd_SCV_VOL (sd_FVG_SCV (fvg, 1));
-  if (J_inv != NULL) J_inv[0][0] = 1 / J[0][0];
-#else
-  INT i, co, n_co;
-  DOUBLE co_coord [sd_MAXNC-1] [DIM - 1];
-  DOUBLE t, vec [DIM];
-  
-  n_co = sd_FVG_SCVF (fvg);
-  
-  for (co = 1; co < n_co; co++)
-   {
-    V_DIM_SUBTRACT (sd_FVG_GCO (fvg, co), sd_FVG_GCO (fvg, 0), vec);
-    for (i = 0; i < DIM; i++)
-     co_coord [co] [i-1] = V_BDIM_SCAL_PROD (vec, sd_FVG_BVEC (fvg, i));
-   };
-  
-  if (n_co == 3) /* if it is a triangle */
-   {
-    V_BDIM_COPY (co_coord [0], J[0]);
-    V_BDIM_COPY (co_coord [1], J[1]);
-   }
-  else /* if it is a quadrilateral */
-   {
-    t = 1 - l_coord[1];
-    J[0][0] = t * co_coord[0][0] + l_coord[1] * (co_coord[1][0] - co_coord[2][0]);
-    J[0][1] = t * co_coord[0][1] + l_coord[1] * (co_coord[1][1] - co_coord[2][1]);
-    t = 1 - l_coord[0];
-    J[1][0] = t * co_coord[2][0] + l_coord[0] * (co_coord[1][0] - co_coord[0][0]);
-    J[1][1] = t * co_coord[2][1] + l_coord[0] * (co_coord[1][1] - co_coord[0][1]);
-   }
-  
-  if (J_inv != NULL)
-   M2_INVERT (J, J_inv, t);
-#endif
-  
-  return 0;
- }
-
-/* InitSideFiniteVolumeTools - UG initializer of the library. The function
- * return 0 if OK, non-zero on an error:
- */
-INT InitSideFiniteVolumeTools ()
- {
-  INT err;
-  
-  fill_side_local_geom_coord ();
-  
-#ifdef __TWODIM__
-  if ((err = fill_local_geom_coord (TRIANGLE)) != 0) return err;
-  if ((err = fill_local_geom_coord (QUADRILATERAL)) != 0) return err;
-#else
-  if ((err = fill_local_geom_coord (TETRAHEDRON)) != 0) return err;
-  if ((err = fill_local_geom_coord (PYRAMID)) != 0) return err;
-  if ((err = fill_local_geom_coord (PRISM)) != 0) return err;
-  if ((err = fill_local_geom_coord (HEXAHEDRON)) != 0) return err;
-#endif
-  
-  return 0;
- }
-
-/* End of File */
diff -ruN ug-orig/np/algebra/sidefvgeom.h ug-patched/np/algebra/sidefvgeom.h
--- ug-orig/np/algebra/sidefvgeom.h	2008-10-29 18:22:26.000000000 +0100
+++ ug-patched/np/algebra/sidefvgeom.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,197 +0,0 @@
-/* sidefvgeom.h - the secondary grid geometry (for the FV method) on
- * sides of primary grid elements.
- *
- * History:
- * Sep. 26, 2007 - created
- * D. Logashenko
- */
-#ifndef __SIDE_FV_GEOM_H__
-#define __SIDE_FV_GEOM_H__
-
-/* UG headers: */
-#include "gm.h"
-
-/* Basic macros: */
-#ifdef __TWODIM__
-#define sd_MAXNC 2 /* max. number of corners per side */
-#define sd_MAXF 1 /* max. number of subcontrol volume faces */
-#else
-#define sd_MAXNC 4 /* max. number of corners per side */
-#define sd_MAXF 4 /* max. number of subcontrol volume faces */
-#endif
-
-/*** Subcontrol volumes on an element's side: ***/
-
-typedef struct
- {
-  INT co; /* corner of the grid element to which this scv is assigned */
-  DOUBLE center [DIM]; /* coord. of the node (the center of the whole CV) */
-  DOUBLE subc_sdloc [DIM-1]; /* side local (barycentric) coord. of the
-                              * subcontrol volume
-                              */
-  DOUBLE subc_local [DIM]; /* local (barycentric) coord. of the center of
-                            * the subcontrol volume w.r.t. the element
-							*/
-  DOUBLE subc_global [DIM]; /* global (geometric) coord. of the center of
-                             * the subcontrol volume
-							 */
-  DOUBLE subc_shape [sd_MAXNC]; /* shape functions at the center of the
-                                 * subcontrol volume
-								 */
-  DOUBLE volume; /* volume of the scv */
- } sd_SubControlVolume;
-
-#define sd_SCV_CO(scv) ((scv)->co)
-#define sd_SCV_GCO(scv) ((scv)->center)
-#define sd_SCV_sdLSC(scv) ((scv)->subc_sdloc)
-#define sd_SCV_LSC(scv) ((scv)->subc_local)
-#define sd_SCV_GSC(scv) ((scv)->subc_global)
-#define sd_SCV_SCSHAPE(scv,co) ((scv)->subc_shape [co])
-#define sd_SCV_VOL(scv) ((scv)->volume)
-
-/*** Faces of the subcontrol volumes: ***/
-
-typedef struct
- {
-  INT i, j; /* the face separates the subcontrol volumes
-             * assigned to corners i and j of the grid element;
-             * alternatively we say that corner i is the from-node, and
-             * that corner j is the to-node
-             */
-  INT side_i, side_j; /* indices of the corners 'i' and 'j' in the
-                       * local numbering of the side (for the side local
-                       * coordinates)
-                       */
-  DOUBLE ip_sdloc [DIM-1]; /* side local (barycentric) coordinates of the
-                            * integration point
-                            */
-  DOUBLE ip_local [DIM]; /* local (barycentric) coordinates of the
-                          * integration point w.r.t. the grid element
-                          */
-  DOUBLE ip_global [DIM]; /* global ('spatial') coordinates of the
-                           * integration point
-                           */
-  
-  DOUBLE normal [DIM-1]; /* the normal vector to the face in the LOCAL
-                          * basis of the side; the length of this vector
-                          * if the area of the face
-                          */
-  
-  DOUBLE shape [sd_MAXNC]; /* values of the shape functions at ip */
-  DOUBLE grad [sd_MAXNC] [DIM - 1]; /* derivatives of the shape functions at ip */
-  
- } sd_SubControlVolumeFace;
-
-#define sd_SCVF_FROM(scvf) ((scvf)->i)
-#define sd_SCVF_TO(scvf) ((scvf)->j)
-#define sd_SCVF_sdFROM(scvf) ((scvf)->side_i)
-#define sd_SCVF_sdTO(scvf) ((scvf)->side_j)
-#define sd_SCVF_sdLIP(scvf) ((scvf)->ip_sdloc)
-#define sd_SCVF_LIP(scvf) ((scvf)->ip_local)
-#define sd_SCVF_GIP(scvf) ((scvf)->ip_global)
-#define sd_SCVF_NORMAL(scvf) ((scvf)->normal)
-#define sd_SCVF_SHAPE(scvf,co) ((scvf)->shape [co])
-#define sd_SCVF_GRAD(scvf,co) ((scvf)->grad [co])
-
-/* REMARK: 'shape' stores only the values of the shape functions
- * assigned to the corners of the side. The same holds for 'grad'.
- * Furthermore, the gradients correspond to the parametrization of
- * the side w.r.t. the orthonormal basis stored in sd_FVGeometry
- * (s. below).
- */
-
-/**** The FV geometry: ****/
-
-typedef struct
- {
-  ELEMENT * e; /* the grid element */
-  INT side; /* the side of the element */
-  
-  INT n_scv; /* # of the subcontrol volumes (# of the corners of the side) */
-  INT n_scvf; /* # of the subcontrol volume faces */
-  
-  INT co_index [sd_MAXNC]; /* indices of the corners of the side in the element */
-  DOUBLE co_global [sd_MAXNC] [DIM]; /* global geometric coordinates of the corners */
-  DOUBLE co_local [sd_MAXNC] [DIM]; /* local (barycentric) coordinates of the corners */
-  DOUBLE co_sdloc [sd_MAXNC] [DIM-1]; /* side local (barycentric) coordinates of the corners */
-  
-  DOUBLE cm_global [DIM]; /* global geometric coordinates of the center of the side */
-  
-  DOUBLE basis [DIM] [DIM]; /* orthonormal basis of the side's plane (DIM-1 vectors)
-                               * and the normal vector to the side (vector # (DIM-1));
-							   * the latter normal points into the element
-							   */
-  
-  sd_SubControlVolume scv [sd_MAXNC]; /* the subcontrol volumes */
-  sd_SubControlVolumeFace scvf [sd_MAXF]; /* the subcontrol volume faces */
-  
- } sd_FVGeometry;
-
-#define sd_FVG_ELEM(fvg) ((fvg)->e)
-#define sd_FVG_SIDE(fvg) ((fvg)->side)
-#define sd_FVG_NSCV(fvg) ((fvg)->n_scv)
-#define sd_FVG_NSCVF(fvg) ((fvg)->n_scvf)
-#define sd_FVG_CO(fvg,i) ((fvg)->co_index [i])
-#define sd_FVG_GCO(fvg,i) ((fvg)->co_global [i])
-#define sd_FVG_LCO(fvg,i) ((fvg)->co_local [i])
-#define sd_FVG_sdLCO(fvg,i) ((fvg)->co_sdloc [i])
-#define sd_FVG_GCM(fvg) ((fvg)->cm_global)
-#define sd_FVG_BVEC(fvg,i) ((fvg)->basis [i])
-#define sd_FVG_SCV(fvg,i) ((fvg)->scv + (i))
-#define sd_FVG_SCVF(fvg,i) ((fvg)->scvf + (i))
-
-/**** Evaluation of the geometric quantities: ****/
-
-/* EvaluateSideFVGeometry - computes the values of all the fields
- * of an sd_FVGeometry object. Note that unlike 'EvaluateFVGeometry'
- * for 'FVElementGeometry' (cf. fvgeom.[ch]), this function computes
- * also the shapes and their derivatives. The function return 0 if
- * OK and non-zero on errors:
- */
-INT EvaluateSideFVGeometry
- (
-  ELEMENT * elem, /* the element for which the geometry schould be computed */
-  INT side, /* side of the element */
-  sd_FVGeometry * fvg /* the object of sd_FVGeometry to initialize */
- );
-
-/* sd_GN - returns the value of the shape function depending on the side
- * barycentric coordinates. On an error, the function returns -1:
- */
-DOUBLE sd_GN
- (
-  INT n_co, /* num. of corners of the side */
-  INT shape_i, /* index of the shape func. (the corner, where the func. is 1) */
-  DOUBLE * l_coord /* DIM - 1 side barycentric coordinates */
- );
-
-/* sd_D_GN - computes the gradients of the shape functions depending on the side
- * barycentric coordinates. The function returns 0 if OK, non-zero on an error:
- */
-INT sd_D_GN
- (
-  INT n_co, /* num. of corners of the side */
-  INT shape_i, /* index of the shape func. (the corner, where the func. is 1) */
-  DOUBLE * l_coord, /* DIM - 1 side barycentric coordinates */
-  DOUBLE * grad /* to save DIM - 1 components of the gradient */
- );
-
-/* GetSideTransformJ - computes the Jacobian of the transformation
- * of the side barycentric coordinates into the geometric coordinates
- * w.r.t. the side basis. The function returns 0 if OK, nonzero
- * on an error:
- */
-INT GetSideTransformJ
- (
-  sd_FVGeometry * fvg, /* the FV-geometry of the side */
-  DOUBLE * l_coord, /* side baricentr. coord. of the pnt (DIM-1 values) */
-  DOUBLE J[][DIM-1], /* for the Jacobian ((DIM-1)*(DIM-1) values) */
-  DOUBLE J_inv[][DIM-1] /* for the inv. Jacobian ((DIM-1)*(DIM-1) values; may be NULL) */
- );
-
-/**** Initializer of the library (must be called once): ****/
-INT InitSideFiniteVolumeTools ();
-
-#endif /* __SIDE_FV_GEOM_H__ */
-
-/* End of File */
diff -ruN ug-orig/np/algebra/sm.c ug-patched/np/algebra/sm.c
--- ug-orig/np/algebra/sm.c	2006-06-02 18:15:34.000000000 +0200
+++ ug-patched/np/algebra/sm.c	2009-04-29 14:30:36.000000000 +0200
@@ -34,7 +34,7 @@
 #ifndef __UG__
    #include "sm.h"
    #define ERR_FILE_ID 6
-#define NS_PREFIX
+#define NS_DIM_PREFIX
 #else /* __UG__ */
 
 #include "sm.h"
@@ -66,7 +66,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX ComputeSMSizeOfArray (SHORT nr, SHORT nc, const SHORT *comps,
+NS_PREFIX INT NS_DIM_PREFIX ComputeSMSizeOfArray (SHORT nr, SHORT nc, const SHORT *comps,
 						  SHORT *NPtr, SHORT *NredPtr)
 {
 	SHORT off,N,Nred;
@@ -122,7 +122,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM2Array (const SPARSE_MATRIX *sm, SHORT *comps)
+NS_PREFIX INT NS_DIM_PREFIX SM2Array (const SPARSE_MATRIX *sm, SHORT *comps)
 {
 	int i,j,nr,nc,off,posc;
 
@@ -179,7 +179,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX Array2SM (SHORT nr, SHORT nc, const SHORT *comps, SPARSE_MATRIX *sm)
+NS_PREFIX INT NS_DIM_PREFIX Array2SM (SHORT nr, SHORT nc, const SHORT *comps, SPARSE_MATRIX *sm)
 {
 	INT error;
 	SHORT off,posc,N,Nred;
@@ -244,7 +244,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX String2SMArray (SHORT n, char *str, SHORT *comps)
+NS_PREFIX INT NS_DIM_PREFIX String2SMArray (SHORT n, char *str, SHORT *comps)
 {
 	SHORT off;
 	int i;
@@ -314,7 +314,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Compute_Reduced_Size (SPARSE_MATRIX *sm)
+NS_PREFIX INT NS_DIM_PREFIX SM_Compute_Reduced_Size (SPARSE_MATRIX *sm)
 {
 	register INT i, j, off;
 	register INT ident_count;
@@ -359,7 +359,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Compute_Reduced_Offsets (SPARSE_MATRIX *sm, SHORT *reduced_offsets)
+NS_PREFIX INT NS_DIM_PREFIX SM_Compute_Reduced_Offsets (SPARSE_MATRIX *sm, SHORT *reduced_offsets)
 {
 	register INT i, j, k, off;
 	
@@ -405,7 +405,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Compare (SPARSE_MATRIX *sm1, SPARSE_MATRIX *sm2)
+NS_PREFIX INT NS_DIM_PREFIX SM_Compare (SPARSE_MATRIX *sm1, SPARSE_MATRIX *sm2)
 {
 	register INT i, j, off1, off2;
 
@@ -465,7 +465,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Compute_Diff_From_Offset (INT N, SHORT *offset, ptrdiff_t *Diff)
+NS_PREFIX INT NS_DIM_PREFIX SM_Compute_Diff_From_Offset (INT N, SHORT *offset, ptrdiff_t *Diff)
 {
 	register int i;
 	
@@ -506,7 +506,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Compute_yDiff_From_Offset (INT N, SHORT *col_ind, SHORT *cmp_off,
+NS_PREFIX INT NS_DIM_PREFIX SM_Compute_yDiff_From_Offset (INT N, SHORT *col_ind, SHORT *cmp_off,
 								  ptrdiff_t *Diff)
 {
 	register int i;
@@ -524,7 +524,7 @@
 	return(0);
 }
 
-NS_PREFIX INT NS_PREFIX Decompose_LR_pivot (int n, DOUBLE *mat, int *pivot)
+NS_PREFIX INT NS_DIM_PREFIX Decompose_LR_pivot (int n, DOUBLE *mat, int *pivot)
 {
 	register DOUBLE dinv, piv, sum, factor;
 	register int i, j, k, off_i, off_j;
@@ -574,7 +574,7 @@
 	return(0);
 }
 
-NS_PREFIX INT NS_PREFIX Solve_LR (int n, const DOUBLE *LR, const int *pivot, DOUBLE *x, const DOUBLE *b)
+NS_PREFIX INT NS_DIM_PREFIX Solve_LR (int n, const DOUBLE *LR, const int *pivot, DOUBLE *x, const DOUBLE *b)
 {
 	register int i, j, off_i;
 	register DOUBLE sum;
@@ -625,7 +625,7 @@
 */
 /****************************************************************************/
 
-NS_PREFIX INT NS_PREFIX SM_Decompose_LR_pivot (const SPARSE_MATRIX *sm, DOUBLE *values,
+NS_PREFIX INT NS_DIM_PREFIX SM_Decompose_LR_pivot (const SPARSE_MATRIX *sm, DOUBLE *values,
 						   DOUBLE *LR, int *pivot)
 {
 	register int i,j,k,n;
diff -ruN ug-orig/np/algebra/sm.h ug-patched/np/algebra/sm.h
--- ug-orig/np/algebra/sm.h	2006-06-02 18:15:49.000000000 +0200
+++ ug-patched/np/algebra/sm.h	2009-04-29 14:30:36.000000000 +0200
@@ -44,7 +44,7 @@
 
 #ifdef __UG__
 #include "namespace.h"
-START_UG_NAMESPACE
+START_UGDIM_NAMESPACE
 #endif
 
 /****************************************************************************/
@@ -99,7 +99,7 @@
 						   DOUBLE *LR, int *pivot);
 
 #ifdef __UG__
-END_NAMESPACE
+END_UGDIM_NAMESPACE
 #endif
 
 #endif /* __SM__ */
diff -ruN ug-orig/np/algebra/tff.c ug-patched/np/algebra/tff.c
--- ug-orig/np/algebra/tff.c	1997-03-13 16:22:38.000000000 +0100
+++ ug-patched/np/algebra/tff.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,1380 +0,0 @@
-/****************************************************************************/
-/*																			*/
-/* File:	  tff.c   														*/
-/*																			*/
-/* Purpose:   tangential frequency filtering decompostion routines          */
-/*      																	*/
-/* Author:	  Christian Wrobel              								*/
-/*			  Institut fuer Computeranwendungen III 						*/
-/*			  Universitaet Stuttgart										*/
-/*			  Pfaffenwaldring 27											*/
-/*			  70569 Stuttgart												*/
-/*			  email: ug@ica3.uni-stuttgart.de			       				*/
-/*																			*/
-/* History:   14.11.95 begin, ug version 3.1								*/
-/*																			*/
-/* Remarks:   FF is used as the abbreviation for "frequency filtering"		*/
-/* 			  TFF is used as the abbreviation for the "tangential frequency */
-/*			       filtering" method due to Christian Wagner, 1995			*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* include files															*/
-/*			  system include files											*/
-/*			  application include files 									*/
-/*																			*/
-/****************************************************************************/
-
-#include <assert.h>
-#include <math.h>
-#include <time.h>
-
-#include "switch.h"		/* for  __TWODIM__ and  __THREEDIM__ */
-#include "compiler.h"
-#include "gm.h"          /* for data structure               */
-#include "ugstruct.h"    /* for GetStringValue               */
-#include "misc.h"        /* for MIN, MAX, PI, ...            */
-#include "devices.h"     /* for UserWrite, PrintErrorMessage */
-#include "commands.h"    /* for GetCurrentMultigrid          */
-#include "debug.h"
-
-#include "num.h"
-#include "ugblas.h"
-
-#include "ff_gen.h"
-#include "tff.h"
-
-#ifdef T
-#undef T
-#endif
-
-/****************************************************************************/
-/*																			*/
-/* defines in the following order											*/
-/*																			*/
-/*		  compile time constants defining static data size (i.e. arrays)	*/
-/*		  other constants													*/
-/*		  macros															*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* definition of exported global variables									*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-/* data for CVS */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/Attic/tff.c,v 1.4 1997/03/13 15:22:38 henrik Exp $",UG_RCS_STRING);
-
-/* value below them a division is refused calculating a testvector */
-DOUBLE TFFsmallTV = 1e-3;
-
-/* ratio for a jump to be detected */
-DOUBLE TFFmuchBigger = 100.0;
-
-/* value below them a number is considered as 0.0 */
-DOUBLE TFFEPS = 1e-16;
-
-/* value below them an approximation error is considered as ok */
-DOUBLE TFFaccuracy = 1e-10;
-
-static DOUBLE glob_h;	/* used if THETA_ANA is defined */
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-
-#ifdef __BLOCK_VECTOR_DESC__
-
-void TFFConstructTestvector( const BLOCKVECTOR *bv, INT tv_comp, DOUBLE wavenr, DOUBLE wavenr_3D );
-
-INT TFFCalculateTheta( const BLOCKVECTOR *bv_dest, const BLOCKVECTOR *bv_source, const BV_DESC *bvd_dest, const BV_DESC *bvd_source, const BV_DESC_FORMAT *bvdf, INT Theta, INT Tinv, INT L, INT tv_comp, INT aux_comp, INT auxsub_comp, INT Lsub_comp );
-
-INT TFFUpdateDiagBlock( const BLOCKVECTOR *bv_dest, const BV_DESC *bvd_dest, const BV_DESC *bvd_source, const BV_DESC_FORMAT *bvdf, INT T, INT DL, INT Theta, GRID *grid );
-
-INT TFFMultWithM( const BLOCKVECTOR *bv, const BV_DESC *bvd, const BV_DESC_FORMAT *bvdf, INT y_comp, INT T_comp, INT L_comp, INT Tinv_comp, INT x_comp, INT aux_comp, INT auxsub_comp, INT Lsub_comp );
-
-INT InitTFF( void );
-
-/****************************************************************************/
-/*																			*/
-/* auxiliary routines for frequency filtering								*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*D
-   TFFConstructTestvector - construct a sine-shaped testvector (2D/3D)
-
-   SYNOPSIS:
-   INT TFFConstructTestvector( const BLOCKVECTOR *bv, INT tv_comp,
-							   DOUBLE wavenr, DOUBLE wavenr_3D );
-
-   PARAMETERS:
-.  bv - root of the blockvector tree in 2D/3D (plane/cube)
-.  tv_comp - component for the testvector in the vector-data
-.  wavenr - number of sine half-oszillations along one gridline (2D (sub)problems)
-.  wavenr3D - number of sine half-oszillations along the planes (only 3D problems)
-
-   DESCRIPTION:
-   Calculate the entries of a testvector to a given frequency with respect
-   to the meshwidth (calculated as the number of vectors within 1 gridline).
-   2D: let h be the meshwidth, (ih,jh) a grid point,
-   then tv(i,j) = sin( i*h*wavenr*pi )
-   3D: let h be the meshwidth, (ih,jh,kh) a grid point,
-   then tv(i,j,k) = sin( i*h*wavenr*pi ) * sin( j*h*wavenr*pi )
-
-   'wavenr3D' is used only in the 3D case.
-
-   RESTRICTIONS:
-   The grid must be ordered by a blockvector structure as created by
-   'CreateBVStripe2D'/'3D'. Especially the leaf-blockvectors must have
-   the right 'BVNUMBEROFVECTORS' and in 3D the sons of 'bv' must be numbered
-   consecutively to determine the right meshwidth.
-
-   The spcial dimension is determined staticly by '__TWODIM'/'__THREEDIM'.
-
-   The grid should be regular (i.e. each line/plane contains the same number of
-   vectors).
-
-   WARNING:
-   In 3D some lines may consist entirely of testvector entries 0.0. To
-   circumvent this problem use 'TFFConstructTestvector_loc'.
-
-   SEE ALSO:
-   TFFConstructTestvector_loc, CreateBVStripe2D, CreateBVStripe3D
-
-   RETURN VALUE:
-.n   void
-D*/
-/*************************************************************************/
-
-void TFFConstructTestvector( const BLOCKVECTOR *bv, INT tv_comp, DOUBLE wavenr, DOUBLE wavenr_3D )
-{
-	register DOUBLE hkpi, pos;
-	register VECTOR *v, *end_v;
-	register BLOCKVECTOR *bv_glob_end;
-	INT length;
-#	ifdef __THREEDIM__
-	register BLOCKVECTOR *bv_end,*bv_i;
-	register DOUBLE plane_pos, tensor;
-	DOUBLE plane_hkpi;
-	INT plane_length;
-#	endif
-
-	bv_glob_end = BVDOWNBVEND(bv);
-	bv = BVDOWNBV(bv);
-	for ( ; bv != bv_glob_end; bv = BVSUCC(bv) ) /* over all lines resp. planes */
-	{
-#ifdef __TWODIM__
-		assert( BVDOWNTYPE(bv) == BVDOWNTYPEVECTOR );
-		length = BVNUMBEROFVECTORS(bv) + 1;
-		hkpi = pos = ( PI * wavenr ) / (DOUBLE)length;
-		end_v = BVENDVECTOR( bv );
-		BLOCK_L_VLOOP( v, BVFIRSTVECTOR(bv), end_v )	/* over all points in the line */
-		{
-			VVALUE( v, tv_comp ) = sin( pos );
-			pos += hkpi;
-		}
-#else
-		assert( BVDOWNTYPE(bv) == BVDOWNTYPEBV );
-		bv_i = BVDOWNBV(bv);
-		bv_end = BVDOWNBVEND(bv);
-		
-		plane_length = BVNUMBER(BVDOWNBVLAST(bv)) - BVNUMBER(bv_i) + 2;
-		plane_hkpi = plane_pos = (PI * wavenr_3D) / (double)plane_length;
-		tensor = sin ( plane_pos );
-		
-		for ( ; bv_i != bv_end; bv_i = BVSUCC(bv_i) )	/* over all lines */
-		{
-			length = BVNUMBEROFVECTORS(bv_i) + 1;
-			hkpi = pos = ( PI * wavenr ) / (DOUBLE)length;
-			end_v = BVENDVECTOR( bv_i );
-			BLOCK_L_VLOOP( v, BVFIRSTVECTOR(bv_i), end_v )	/* over all points in the line */
-			{
-				VVALUE( v, tv_comp ) = tensor * sin( pos );
-				pos += hkpi;
-			}
-			plane_pos += plane_hkpi;
-			tensor = sin( plane_pos );
-		}
-#endif
-	}
-}
-
-/****************************************************************************/
-/*D
-   TFFConstructTestvector_loc - construct a sine-shaped testvector (2D/3D)
-
-   SYNOPSIS:
-   INT TFFConstructTestvector_loc( const BLOCKVECTOR *bv, INT tv_comp,
-								   DOUBLE wavenr, DOUBLE wavenr_3D );
-
-   PARAMETERS:
-.  bv - root of the blockvector tree in 2D/3D (plane/cube)
-.  tv_comp - component for the testvector in the vector-data
-.  wavenr - number of sine half-oszillations along one gridline (2D (sub)problems)
-.  wavenr3D - number of sine half-oszillations along the planes (only 3D problems)
-
-   DESCRIPTION:
-   Calculate the entries of a testvector to a given frequency with respect
-   to the meshwidth (calculated as the number of vectors within 1 gridline).
-   The distinction whether 'bv' represents a plane (2D) or a cube (3D) is made
-   dynamically by the blockvector structure itself: if 'bv' has only one
-   further level of blockvectors (representing grid lines!) it is
-   considered as a plane, otherwise as a cube.
-   plane: let h be the meshwidth, (ih,jh) a grid point,
-   then tv(i,j) = sin( i*h*wavenr*pi )
-   cube: let h be the meshwidth, (ih,jh,kh) a grid point,
-   then tv(i,j,k) = sin( i*h*wavenr*pi ) * sin( j*h*wavenr*pi )
-
-   In 3D some lines may consist entirely of testvector entries 0.0 only
-   in the case of the global decomposition; in the case of decomposing
-   local problems no 0-lines can occur!
-   'wavenr3D' is used only in the 3D case.
-
-   WARNING:
-   The local subproblems do not use the global testvector, but a local one.
-
-   RESTRICTIONS:
-   The grid must be ordered by a blockvector structure as created by
-   'CreateBVStripe2D'/'3D'.
-
-   The grid should be regular (i.e. each line/plane contains the same number of
-   vectors).
-
-   SEE ALSO:
-   TFFConstructTestvector, CreateBVStripe2D, CreateBVStripe3D
-
-   RETURN VALUE:
-.n   void
-D*/
-/*************************************************************************/
-
-static void TFFConstructTestvector_loc( const BLOCKVECTOR *bv, INT tv_comp, DOUBLE wavenr, DOUBLE wavenr_3D )
-{
-	register DOUBLE hkpi, pos, plane_pos, tensor;
-	register VECTOR *v, *end_v;
-	register BLOCKVECTOR *bv_i, *bv_end;
-	INT length, plane_length;
-	DOUBLE plane_hkpi;
-
-	if ( BV_IS_LEAF_BV( bv ) )
-		/* 2D block */
-	{
-		length = BVNUMBEROFVECTORS(bv) + 1;
-		hkpi = pos = ( PI * wavenr ) / (DOUBLE)length;
-		end_v = BVENDVECTOR( bv );
-		BLOCK_L_VLOOP( v, BVFIRSTVECTOR(bv), end_v )	/* over all points in the line */
-		{
-			/*printf("pos %g  sin %g\n", pos, sin(pos) );*/
-			VVALUE( v, tv_comp ) = sin( pos );
-			pos += hkpi;
-		}
-	}
-	else
-		/* 3D block */
-	{
-		assert( BVDOWNTYPE(bv) == BVDOWNTYPEBV );
-		bv_i = BVDOWNBV(bv);
-		bv_end = BVDOWNBVEND(bv);
-	
-		plane_length = BVNUMBER(BVDOWNBVLAST(bv)) - BVNUMBER(bv_i) + 2;
-		plane_hkpi = plane_pos = (PI * wavenr_3D) / (double)plane_length;
-		tensor = sin ( plane_pos );
-		
-		for ( ; bv_i != bv_end; bv_i = BVSUCC(bv_i) )	/* over all lines */
-		{
-			length = BVNUMBEROFVECTORS(bv_i) + 1;
-			hkpi = pos = ( PI * wavenr ) / (DOUBLE)length;
-			end_v = BVENDVECTOR( bv_i );
-			/*printf("tensor %g\n", tensor );*/
-			BLOCK_L_VLOOP( v, BVFIRSTVECTOR(bv_i), end_v )	/* over all points in the line */
-			{
-				VVALUE( v, tv_comp ) = tensor * sin( pos );
-				pos += hkpi;
-			}
-			plane_pos += plane_hkpi;
-			tensor = sin( plane_pos );
-		}
-
-	}
-}
-
-
-/****************************************************************************/
-/*D
-   TFFCalculateTheta - calculate the coupling matrix Theta
-
-   SYNOPSIS:
-   INT TFFCalculateTheta( const BLOCKVECTOR *bv_dest,
-						  const BLOCKVECTOR *bv_source,
-						  const BV_DESC *bvd_dest,
-						  const BV_DESC *bvd_source,
-						  const BV_DESC_FORMAT *bvdf,
-						  INT Theta,
-						  INT Tinv,
-						  INT L,
-						  INT tv_comp,
-						  INT aux_comp,
-						  INT auxsub_comp,
-						  INT Lsub_comp );
-
-   PARAMETERS:
-.  bv_dest - row-blockvector of Theta
-.  bv_source - column-blockvector of Theta (where the testvector lives)
-.  bvd_dest - description of the row-blockvector
-.  bvd_source - description of the column-blockvector
-.  bvdf - format to interpret the 'bvd's
-.  Theta - position of the Theta-component in the MATRIX-data
-.  Tinv - position of the component for the LU-decomposed diagonal blocks
-.  L - position of the off-diagonal component of the matrix to be decomposed
-.  tv_comp - position of the testvector-component in the VECTOR-data
-.  aux_comp - position of the auxiliary-component in the VECTOR-data
-.  auxsub_comp - position of the auxiliary-component for subproblems (only 3D)
-.  Lsub - position of the off-diagonal component of the subproblem-matrix to be decomposed (only 3D)
-
-   DESCRIPTION:
-   The diagonal entries of matrix Theta and Theta^T are calculated such that
-   they fullfil the filtering condition (d=dest, s=source)
-	   Theta_(d,s) * tv_s == T_(d,d)^-1 * L_(d,s) * tv_s
-   If a entry of the testvector is 0 the associated Theta-entry is set as the
-   average of the neighbouring entries (for details see the code).
-
-   To do certain experiments there can be activated variants of the usual
-   algorithm by defining macro-names. See the code.
-
-   'auxsub_comp' and 'Lsub_comp' are used only in the 3D case; in 2D you can
-   use an arbitrary number.
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-.n    NUM_ERROR if the testvector is constant 0.0
-D*/
-/****************************************************************************/
-
-INT TFFCalculateTheta( const BLOCKVECTOR *bv_dest, const BLOCKVECTOR *bv_source, const BV_DESC *bvd_dest, const BV_DESC *bvd_source, const BV_DESC_FORMAT *bvdf, INT Theta, INT Tinv, INT L, INT tv_comp, INT aux_comp, INT auxsub_comp, INT Lsub_comp )
-/* calculates Theta_(i,i-1) and Theta_(i-1,i) */
-/* only for regular grids */
-/* auxsub and Lsub only in the 3D case */
-{
-	register VECTOR *v_dest, *v_source, *end_dest, *pred_dest, *pred_source, *succ_dest, *succ_source, *start_dest;
-	register DOUBLE val, pred_val, succ_val;
-	register MATRIX *m;
-	INT missed, pred_found, succ_found, pred_in_block, succ_in_block;
-
-	/* aux_source := L_(source,dest) * tv_dest */
-	dsetBS( bv_source, aux_comp, 0.0 );
-	dmatmulBS( bv_source, bvd_dest, bvdf, aux_comp, L, tv_comp );
-
-	/* aux_source = (T_source)^-1 * aux_source */
-#ifdef THETA_EXACT
-	dcopyBS( bv_source, aux4_COMP, aux_comp );
-	dsetBS( bv_source, aux_comp, 0.0 );
-	gs_solveBS ( bv_source, bvd_source, bvdf, 1e-16, 100, Theta, aux_comp, aux4_COMP, aux5_COMP, TRUE );
-#else
-	TFFMultWithMInv( bv_source, bvd_source, bvdf, aux_comp, Lsub_comp, Tinv, aux_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#endif
-	
-	/* calculate Theta */
-	/* Theta must fulfill the equation Theta * tv = aux = T^-1 * L * tv */
-
-	missed = 0;
-	end_dest = BVENDVECTOR( bv_dest );
-	for ( v_dest = start_dest = BVFIRSTVECTOR( bv_dest ), v_source = BVFIRSTVECTOR( bv_source );
-		v_dest != end_dest;
-		v_dest = SUCCVC( v_dest ), v_source = SUCCVC( v_source ) )
-	{
-		val = VVALUE( v_dest, tv_comp );
-		if ( fabs( val ) < TFFsmallTV )
-		{
-			SETVCUSED( v_dest, TRUE );
-			missed++;
-		}
-		else
-		{
-			SETVCUSED( v_dest, FALSE );
-			m = GetMatrix( v_source, v_dest );
-			assert( m != NULL );
-			MVALUE( m, Theta ) = MVALUE( MADJ(m), Theta ) = VVALUE( v_source, aux_comp ) / val;
-		}
-    }
-
-	/* treat the missed members */
-
-	v_dest = start_dest;
-	v_source = BVFIRSTVECTOR( bv_source );
-	start_dest = PREDVC( start_dest );
-	
-	/*printf( "%4d. block row, theta = %12g lambda = %12g\n", BVNUMBER( bv_dest ), MVALUE(GetMatrix(v_source,v_dest),Theta),1/MVALUE(GetMatrix(v_source,v_dest),Theta));*/
-
-	while( missed > 0 )
-	{
-		if ( VCUSED( v_dest ) )
-		{
-#ifndef NDEBUG
-			if ( mute_level >= 50 )
-				UserWrite( "Missed vector in TFFCalculateTheta.\n" );
-#endif
-			/* the vector was missed */
-			/* search a not missed neighbor to calculate an approximate value */
-
-			missed--;
-			pred_dest = succ_dest = v_dest;
-			pred_source = succ_source = v_source;
-			pred_found = succ_found = FALSE;
-			pred_in_block = succ_in_block = TRUE;
-
-			while ( !pred_found && !succ_found && (pred_in_block || succ_in_block) )
-			{
-				if ( !VCUSED( pred_dest ) && pred_in_block )
-				{
-					pred_val = MVALUE( GetMatrix( pred_source, pred_dest ), Theta );
-					pred_found = TRUE;
-				}
-
-				if ( !VCUSED( succ_dest ) && succ_in_block )
-				{
-					succ_val = MVALUE( GetMatrix( succ_source, succ_dest ), Theta );
-					succ_found = TRUE;
-				}
-
-				if ( pred_in_block )
-				{
-					pred_dest = PREDVC( pred_dest );
-					pred_source = PREDVC( pred_source );
-					pred_in_block = (pred_dest != start_dest);
-				}
-
-				if ( succ_in_block )
-				{
-					succ_dest = SUCCVC( succ_dest );
-					succ_source = SUCCVC( succ_source );
-					succ_in_block = (succ_dest != end_dest);
-				}
-			} /* while !pred_found */
-
-			if ( pred_found )
-				if ( succ_found )
-				{
-					if ( fabs(pred_val) > TFFmuchBigger * fabs(succ_val ) )
-						val = succ_val;
-					else if ( fabs(succ_val) > TFFmuchBigger * fabs(pred_val ) )
-						val = pred_val;
-					else
-						val = (pred_val + succ_val) * 0.5;
-				}
-				else
-					val = pred_val;
-			else
-				if ( succ_found )
-					val = succ_val;
-				else
-				{
-					UserWrite( "Testvector was zero in TFFCalculateTheta.\n" );
-					m = GetMatrix( v_source, v_dest );
-					assert( m != NULL );
-					MVALUE( m, Theta ) = MVALUE( MADJ(m), Theta ) = 1e11;
-					return NUM_ERROR;
-				}
-
-			m = GetMatrix( v_source, v_dest );
-			assert( m != NULL );
-			MVALUE( m, Theta ) = MVALUE( MADJ(m), Theta ) = val;
-
-		} /* if !VCUSED */
-
-		v_dest = SUCCVC( v_dest );
-		v_source = SUCCVC( v_source );
-
-	} /* while missed */
-
-	return NUM_OK;
-}
-
-
-/****************************************************************************/
-/*D
-   TFFUpdateDiagBlock - calculate the filtered diagonal block
-
-   SYNOPSIS:
-   INT TFFUpdateDiagBlock( const BLOCKVECTOR *bv_dest,
-						   const BV_DESC *bvd_dest,
-						   const BV_DESC *bvd_source,
-						   const BV_DESC_FORMAT *bvdf,
-						   INT T,
-						   INT DL,
-						   INT Theta,
-						   GRID *grid )
-
-   PARAMETERS:
-.  bv_dest - new diagonal block and row-blockvector of Theta
-.  bvd_dest - description of the row-blockvector
-.  bvd_source - description of the last diagonal block and column-blockvector of Theta
-.  bvdf - format to interpret the 'bvd's
-.  T - position of the component of the filtered matrix in the MATRIX-data
-.  DL - position of the component of the given (stiffness) matrix
-.  Theta - position of the Theta-component in the MATRIX-data
-.  grid - grid where the matrixes lives on (for allocating extra connections)
-
-   DESCRIPTION:
-   Calculates for given Theta and T (d=dest, s=source)
-		T_dd += Theta_ds*T_ss*Theta_sd - Theta_ds*L_sd - L_ds*Theta_sd
-   If neccessary new connections are allocated as 'extra connections'.
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-.n    NUM_ERROR if the testvector is constant 0.0
-D*/
-/****************************************************************************/
-
-INT TFFUpdateDiagBlock( const BLOCKVECTOR *bv_dest, const BV_DESC *bvd_dest, const BV_DESC *bvd_source, const BV_DESC_FORMAT *bvdf, INT T, INT DL, INT Theta, GRID *grid )
-{
-	/* T_dest += Theta_(dest,source)*T_source*Theta_(source,dest) */
-	d3matmulBS( bv_dest, bvd_source, bvd_source, bvd_dest, bvdf, T, Theta, T, Theta, grid );
-
-	/* T_dest -= Theta_(dest,source)*L_(source,dest) */
-	d2matmul_minusBS( bv_dest, bvd_source, bvd_dest, bvdf, T, Theta, DL, grid );
-
-	/* T_dest -= L_(dest,source)*Theta_(source,dest) */
-	d2matmul_minusBS( bv_dest, bvd_source, bvd_dest, bvdf, T, DL, Theta, grid );
-
-	return NUM_OK;
-}
-
-
-/****************************************************************************/
-/*D
-   TFFMultWithM - for a frequency filtered matrix M calculate y := M * x
-
-   SYNOPSIS:
-   INT TFFMultWithM( const BLOCKVECTOR *bv,
-					 const BV_DESC *bvd,
-					 const BV_DESC_FORMAT *bvdf,
-					 INT y_comp,
-					 INT T_comp,
-					 INT L_comp,
-					 INT Tinv_comp,
-					 INT x_comp,
-					 INT aux_comp,
-					 INT auxsub_comp,
-					 INT Lsub_comp );
-
-   PARAMETERS:
-.  bv - blockvector covering M
-.  bvd - description of the blockvector
-.  bvdf - format to interpret the 'bvd'
-.  y_comp - position of the result in the VECTOR-data
-.  T_comp - position of the frequency filtered diagonal blocks of the stiffness matrix
-.  L_comp - position of the off-diagonal blocks of the stiffness matrix
-.  Tinv_comp - position of the LU-decomposed diagonal blocks
-.  x_comp - position of the vector to be multiplied in the VECTOR-data
-.  aux_comp - position of the auxiliary-component in the VECTOR-data
-.  auxsub_comp - position of the auxiliary-component for subproblems (only 3D)
-.  Lsub_comp - position of the off-diagonal blocks of the subproblem-matrix (only 3D)
-
-   DESCRIPTION:
-   'M' is an frequency filtered decomposed matrix as produced by 'TFFDecomp',
-   i.e. M = ( L + T ) * T^-1 * ( T + U ).
-   This function calculates the product 'y := M * x'. Do not mix up this
-   function with 'TFFMultWithMInv'!
-
-   Both the lower ('L') and upper ('U') off-diagonal part is stored in the
-   same component 'L_comp' in the MATRIX-data.
-
-   'auxsub_comp', 'Tsub_comp' and 'Lsub_comp' are used only in the 3D case;
-   in 2D you can use an arbitrary number.
-
-   WARNING:
-   'x_comp', 'y_comp' and 'aux_comp' must be pairwise different!
-
-   REMARK:
-   This function is needed only for experimenting, not for the pure solving
-   of a PDE.
-
-   SEE ALSO:
-   TFFDecomp, TFFMultWithMInv
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-D*/
-/****************************************************************************/
-
-INT TFFMultWithM( const BLOCKVECTOR *bv, const BV_DESC *bvd, const BV_DESC_FORMAT *bvdf, INT y_comp, INT T_comp, INT L_comp, INT Tinv_comp, INT x_comp, INT aux_comp, INT auxsub_comp, INT Lsub_comp )
-{
-	register BLOCKVECTOR *bv_i, *bv_ip1, *bv_stop;
-	register BV_DESC *bvd_i, *bvd_ip1, *bvd_temp;
-	BV_DESC bvd1, bvd2;
-	
-	/* To minimize the incrementation of BVDs there are used two (one for
-	   index i and the other for index i+1) which are swapped in the loop;
-	   thus only one incrementation by 2 is necessary */
-	bvd1 = bvd2 = *bvd;
-	bvd_i = &bvd1;
-	bvd_ip1 = &bvd2;
-	BVD_PUSH_ENTRY( bvd_i, 0, bvdf );
-	BVD_PUSH_ENTRY( bvd_ip1, 1, bvdf );
-	
-	/* calculate aux := T^-1*(U + T) * x = (T^-1 * U) * x + x */
-	bv_stop = BVDOWNBVLAST( bv );
-	for ( bv_i = BVDOWNBV(bv), bv_ip1 = BVSUCC( bv_i );
-		  bv_i != bv_stop; 		/* except the last blockvector */
-		  bv_i = bv_ip1, bv_ip1 = BVSUCC( bv_ip1 ) )
-	{
-		/* aux_i := 0 */
-		dsetBS( bv_i, aux_comp, 0.0 );
-			
-		/* aux_i += U_(i,i+1) * x_i+1 */
-		dmatmulBS( bv_i, bvd_ip1, bvdf, aux_comp, L_comp, x_comp );
-		
-		/* aux_i := (T_i)^-1 * aux_i */
-		TFFMultWithMInv( bv_i, bvd_i, bvdf, aux_comp, Lsub_comp, Tinv_comp, aux_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-		
-		/* aux_i += x_i */
-		daddBS( bv_i, aux_comp, x_comp );
-		
-		/* prepare BVDs for next loop */
-		SWAP( bvd_i, bvd_ip1, bvd_temp );
-		BVD_INC_LAST_ENTRY( bvd_ip1, 2, bvdf );
-	}
-	/* aux_last :=  T^-1*(U + T) * x_last = x_last */
-	dcopyBS( bv_i, aux_comp, x_comp );
-	
-	bv_ip1 = bv_i;
-	bv_i = BVPRED(bv_ip1);
-	SWAP( bvd_i, bvd_ip1, bvd_temp );
-	BVD_DEC_LAST_ENTRY( bvd_i, 2, bvdf );
-	/* now i+1 points to the last blockvector, i to its predecessor */
-	
-	/* calculate y := (L + T) * aux */
-	/* note the reverse direction of the calculation; this prevents y_i-1
-	   from beeing overriden in the i.th step, since it is needed in the
-	   step i-1 again. */
-	bv_stop = BVDOWNBV(bv);
-	for ( ;
-		  bv_ip1 != bv_stop;	/* except blockvector 0 */
-		  bv_ip1 = bv_i, bv_i = BVPRED( bv_ip1 ) )
-	{
-		/* y_i+1 := 0 */
-		dsetBS( bv_ip1, y_comp, 0.0 );
-		
-		/* y_i+1 += T_i+1 * aux_i+1 */
-		dmatmulBS( bv_ip1, bvd_ip1, bvdf, y_comp, T_comp, aux_comp );
-		
-		/* y_i+1 += L_(i+1,i) * aux_i */
-		dmatmulBS( bv_ip1, bvd_i, bvdf, y_comp, L_comp, aux_comp );
-
-		/* prepare BVDs for next loop */
-		SWAP( bvd_i, bvd_ip1, bvd_temp );
-		BVD_DEC_LAST_ENTRY( bvd_i, 2, bvdf );
-	}
-	/* y_0 := 0 */
-	dsetBS( bv_ip1, y_comp, 0.0 );
-	
-	/* y_0 += T_0 * aux_0 */
-	dmatmulBS( bv_ip1, bvd_ip1, bvdf, y_comp, T_comp, aux_comp );
-		
-	return NUM_OK;
-}
-
-
-/****************************************************************************/
-/*D
-   TFFMultWithMInv - for a frequency filtered matrix M calculate v := M^-1 * b
-
-   SYNOPSIS:
-   INT TFFMultWithMInv( const BLOCKVECTOR *bv,
-						const BV_DESC *bvd,
-						const BV_DESC_FORMAT *bvdf,
-						INT v_comp,
-						INT L_comp,
-						INT Tinv_comp,
-						INT b_comp,
-						INT aux_comp,
-						INT auxsub_comp,
-						INT Lsub_comp );
-
-   PARAMETERS:
-.  bv - blockvector covering M
-.  bvd - description of the blockvector
-.  bvdf - format to interpret the 'bvd'
-.  v_comp - position of the result in the VECTOR-data
-.  L_comp - position of the off-diagonal blocks of the stiffness matrix
-.  Tinv_comp - position of the LU-decomposed diagonal blocks
-.  b_comp - position of the right hand side vector in the VECTOR-data
-.  aux_comp - position of the auxiliary-component in the VECTOR-data
-.  auxsub_comp - position of the auxiliary-component for subproblems (only 3D)
-.  Lsub_comp - position of the off-diagonal blocks of the subproblem-matrix (only 3D)
-
-   DESCRIPTION:
-   'M' is an frequency filtered decomposed matrix as produced by 'TFFDecomp',
-   i.e. M = ( L + T ) * T^-1 * ( T + U ).
-   This function calculates 'v := M^-1 * b', i.e. solves 'M * v = b' for v.
-   Do not mix up this function with 'TFFMultWithM'!
-
-   Both the lower ('L') and upper ('U') off-diagonal part is stored in the
-   same component 'L_comp' in the MATRIX-data.
-
-   'v_comp' and 'b_comp' may be equal.
-
-   Destroys 'b_comp'.
-
-   'auxsub_comp' and 'Lsub_comp' are used only in the 3D case;
-   in 2D you can use an arbitrary number.
-   The distinction whether 'bv' represents a plane (2D) or a cube (3D) is made
-   dynamically by the blockvector structure itself: if 'bv' has only one
-   further level of blockvectors (representing grid lines!) it is
-   considered as a plane, otherwise as a cube.
-
-   To do certain experiments there can be activated variants of the usual
-   algorithm by defining macro-names. See the code.
-
-   SEE ALSO:
-   TFFDecomp, TFFMultWithM
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-.n    error code from 'solveLUMatBS'
-D*/
-/****************************************************************************/
-
-INT TFFMultWithMInv( const BLOCKVECTOR *bv,
-					 const BV_DESC *bvd, 
-					 const BV_DESC_FORMAT *bvdf, 
-					 INT v_comp, 
-					 INT L_comp, 
-					 INT Tinv_comp,
-					 INT b_comp,
-					 INT aux_comp, 
-					 INT auxsub_comp, 
-					 INT Lsub_comp )
-{
-	register BLOCKVECTOR *bv_i, *bv_ip1, *bv_stop;
-	register BV_DESC *bvd_i, *bvd_ip1, *bvd_temp;
-	BV_DESC bvd1, bvd2;
-
-	if ( BV_IS_LEAF_BV(bv) )
-		return 	solveLUMatBS( bv, bvd, bvdf, v_comp, Tinv_comp, b_comp );
-
-	ASSERT( v_comp != aux_comp );
-	ASSERT( b_comp != aux_comp );
-	ASSERT( L_comp != Tinv_comp );
-
-	IFDEBUG(np,0)
-	if ( auxsub_comp != DUMMY_COMP )
-	{
-		ASSERT( auxsub_comp != v_comp );
-		ASSERT( auxsub_comp != b_comp );
-		ASSERT( auxsub_comp != aux_comp );
-		ASSERT( Lsub_comp != DUMMY_COMP );
-		ASSERT( Lsub_comp != L_comp );
-		ASSERT( Lsub_comp != Tinv_comp );
-	}
-	ENDDEBUG
-	
-	/* To minimize the incrementation of BVDs there are used two (one for
-	   index i and the other for index i+1) which are swapped in the loop;
-	   thus only one incrementation by 2 is necessary */
-	bvd1 = bvd2 = *bvd;
-	bvd_i = &bvd1;
-	bvd_ip1 = &bvd2;
-	BVD_PUSH_ENTRY( &bvd1, 0, bvdf );
-	BVD_PUSH_ENTRY( &bvd2, 1, bvdf );
-
-	/* solve lower triangular matrix; except the last block in this loop */
-	/* aux := ( L + T )^-1 * b */
-	bv_stop = BVDOWNBVLAST(bv);
-	for ( bv_i = BVDOWNBV(bv), bv_ip1 = BVSUCC( bv_i );
-		  bv_i != bv_stop;
-		  bv_i = bv_ip1, bv_ip1 = BVSUCC( bv_ip1 ) )
-	{
-		/* aux_i := (T_i)^-1 * b_i */
-#ifdef MINV_2D_EXACT
-		if( L_comp == 0 )
-			gs_solveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF_COMP, aux_comp, b_comp, aux5_COMP, TRUE );
-		else
-			/*gs_solveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF3D_COMP, aux_comp, b_comp, aux5_COMP, TRUE );*/
-			TFFMultWithMInv( bv_i, bvd_i, bvdf, aux_comp, Lsub_comp, Tinv_comp, b_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#else
-		TFFMultWithMInv( bv_i, bvd_i, bvdf, aux_comp, Lsub_comp, Tinv_comp, b_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#endif
-	
-		/* b_i+1 -= L_(i+1,i) * aux_i */
-		dmatmul_minusBS( bv_ip1, bvd_i, bvdf, b_comp, L_comp, aux_comp );
-		
-		/* prepare BVDs for next loop */
-		SWAP( bvd_i, bvd_ip1, bvd_temp );
-		BVD_INC_LAST_ENTRY( bvd_ip1, 2, bvdf );
-	}	
-	/* special treatment: v_last = (T_last)^-1 * b_last */
-#ifdef MINV_2D_EXACT
-	if( L_comp == 0 )
-		gs_solveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF_COMP, aux_comp, b_comp, aux5_COMP, TRUE );
-	else
-		/*gssolveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF3D_COMP, aux_comp, b_comp, aux5_COMP, TRUE );*/
-		TFFMultWithMInv( bv_i, bvd_i, bvdf, v_comp, Lsub_comp, Tinv_comp, b_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#else
-	TFFMultWithMInv( bv_i, bvd_i, bvdf, v_comp, Lsub_comp, Tinv_comp, b_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#endif
-
-	/* solve upper triangular matrix; the last block is already calculated */
-	/* v := (T^-1*U + I )^-1 * aux */
-	assert( bv_i == BVDOWNBVLAST(bv) );
-	SWAP( bvd_i, bvd_ip1, bvd_temp );
-	BVD_DEC_LAST_ENTRY( bvd_i, 2, bvdf );
-	bv_stop = BVPRED( BVDOWNBV(bv) );
-	for ( bv_i = BVPRED( bv_i ); bv_i != bv_stop; bv_i = BVPRED( bv_i ) )
-	{
-		/* v_i := L_(i,i+1) * v_i+1 */
-		dsetBS( bv_i, v_comp, 0.0 );
-		dmatmulBS( bv_i, bvd_ip1, bvdf, v_comp, L_comp, v_comp );
-
-		/* v_i := (T_i)^-1 * v_i */
-#ifdef MINV_2D_EXACT
-		dcopyBS( bv_i, aux4_COMP, v_comp );
-		if( L_comp == 0 )
-			gs_solveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF_COMP, v_comp, aux4_COMP, aux5_COMP, TRUE );
-		else
-			/*gs_solveBS ( bv_i, bvd_i, bvdf, 1e-16, 100, FF3D_COMP, v_comp, aux4_COMP, aux5_COMP, TRUE );*/
-			TFFMultWithMInv( bv_i, bvd_i, bvdf, v_comp, Lsub_comp, Tinv_comp, v_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#else
-		TFFMultWithMInv( bv_i, bvd_i, bvdf, v_comp, Lsub_comp, Tinv_comp, v_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP );
-#endif
-
-		/* v_i := aux_i - v_i */
-		dminusaddBS( bv_i, v_comp, aux_comp );
-
-		/* prepare BVDs for next loop */
-		SWAP( bvd_i, bvd_ip1, bvd_temp );
-		BVD_DEC_LAST_ENTRY( bvd_i, 2, bvdf );
-	}
-
-	return NUM_OK;
-}
-
-/****************************************************************************/
-/*																			*/
-/* global exported routines													*/
-/*																			*/
-/****************************************************************************/
-
-/****************************************************************************/
-/*D
-   TFFDecomp - calculate the tangential frequency filtering decomposition of a matrix
-
-   SYNOPSIS:
-   INT TFFDecomp( DOUBLE wavenr,
-				  DOUBLE wavenr3D,
-				  const BLOCKVECTOR *bv,
-				  const BV_DESC *bvd,
-				  const BV_DESC_FORMAT *bvdf,
-				  INT LU_comp,
-				  INT FF_comp,
-				  INT K_comp,
-				  INT tv_comp,
-				  INT aux_comp,
-				  INT auxsub_comp,
-				  INT FFsub_comp,
-				  GRID *grid );
-
-   PARAMETERS:
-.  wavenr - number of sine half-oszillations along one gridline (2D (sub)problems)
-.  wavenr3D - number of sine half-oszillations along the planes (only 3D problems)
-.  bv - blockvector covering the matrix to be decomposed
-.  bvd - description of the blockvector
-.  bvdf - format to interpret the 'bvd'
-.  LU_comp - position of the component for the LU-decomposed (diagonal) blocks
-.  FF_comp - position of the Theta and filtered diagonal blocks in the MATRIX-data
-.  K_comp - position of the stiffness matrix to be decomposed
-.  tv_comp - position of the testvector-component in the VECTOR-data
-.  aux_comp - position of the auxiliary-component in the VECTOR-data
-.  auxsub_comp - position of the auxiliary-component for subproblems (only 3D)
-.  FFsub_comp - position of the Theta and filtered diagonal blocks of the subproblem-matrix (only 3D)
-.  grid - grid where the matrixes lives on (for allocating extra connections)
-
-   DESCRIPTION:
-   This function calculates the tangential frequency filtered decomposition
-   of the given matrix 'K'. It expects a blockvector structure according to a
-   linewise (2D) resp. plane-/linewise (3D) decomposition of the domain as
-   it is constructed by 'CreateBVStripe2D'/'CreateBVStripe3D'. The result is
-   a matrix 'M' in the form 'M = ( L + T ) * T^-1 * ( T + U )' where the
-   lower ('L') and upper ('U') off-diagonal blocks are the same as in
-   the given matrix ('K_comp'), 'T' is the frequency filtered diagonal
-   blockmatrix ('FF_comp'). The auxiliary matrix Theta is stored in the off-diagonal
-   blocks of 'FF_comp'.
-
-   In the 3D case the frequency filtered diagonal blocks are again decomposed
-   by TFF. The matrix to be decomposed is in the 'FF_comp' and the frequency
-   filtered diagonal blocks are stored in 'FFsub_comp' (their LU decomposition
-   finally in 'LU_comp'). 'auxsub_comp' and 'FFsub_comp' are used only in
-   the 3D case; in 2D you can use an arbitrary number.
-
-   The distinction whether 'bv' represents a plane (2D) or a cube (3D) is made
-   dynamically by the blockvector structure itself: if 'bv' has only one
-   further level of blockvectors (representing grid lines!) it is
-   considered as a plane, otherwise as a cube.
-
-   To do certain experiments there can be activated variants of the usual
-   algorithm by defining macro-names. See the code.
-
-   SEE ALSO:
-   TFFCalculateTheta, TFFConstructTestvector_loc, TFFConstructTestvector, TFFMultWithM, TFFMultWithMInv
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-.n    error code from 'LUDecomposeDiagBS'
-D*/
-/****************************************************************************/
-
-INT TFFDecomp( DOUBLE wavenr,
-			   DOUBLE wavenr3D,
-			   const BLOCKVECTOR *bv,
-			   const BV_DESC *bvd,
-			   const BV_DESC_FORMAT *bvdf,
-			   INT LU_comp,
-			   INT FF_comp,
-			   INT K_comp,
-			   INT tv_comp,
-			   INT aux_comp,
-			   INT auxsub_comp, 
-			   INT FFsub_comp,
-			   GRID *grid )
-{
-	register BLOCKVECTOR *bv_i, *bv_im1, *bv_end;
-	register BV_DESC *bvd_i, *bvd_im1, *bvd_temp;
-	BV_DESC bvd1, bvd2; 
-#ifdef THETA_ANA
-	DOUBLE lambda, li, a, bx, by, bz;
-	MATRIX *m;
-#endif
-	
-	if ( BV_IS_LEAF_BV(bv) )
-	{		
-		dmatcopyBS( bv, bvd, bvdf, LU_comp, K_comp );
-		return LUDecomposeDiagBS( bv, bvd, bvdf, LU_comp, grid );
-	}
-	
-	/* initialize the BVDs */
-	bvd1 = bvd2 = *bvd;		/* copy of the BVD */
-	bvd_i = &bvd1;
-	bvd_im1 = &bvd2;
-	BVD_PUSH_ENTRY( bvd_im1, 0, bvdf );
-	BVD_PUSH_ENTRY( bvd_i, 1, bvdf );
-
-#ifdef THETA_ANA
-	bv_im1 = BVDOWNBV(bv);
-	bv_i = BVSUCC( bv_im1 );
-	a = MVALUE( VSTART(BVFIRSTVECTOR( bv_im1 )), K_comp );
-	m = GetMatrix( BVFIRSTVECTOR(bv_im1), SUCCVC(BVFIRSTVECTOR(bv_im1)));
-	assert( m != NULL );
-	bx = MVALUE( m, K_comp );
-	if ( BV_IS_LEAF_BV( bv_im1 ) )
-	{	/* 2D block */
-		m = GetMatrix( BVFIRSTVECTOR(bv_im1), BVFIRSTVECTOR(bv_i));
-		assert( m != NULL );
-		by = MVALUE( m, K_comp );
-		li = lambda = (a + 2.0 * bx * cos(wavenr*PI*glob_h)) / by;
-		/*printf("a = %g bx = %g by = %g  lambda = %g  h= %g i = %g\n", a,bx, by,lambda, glob_h, wavenr );*/
-	}
-	else
-	{	/* 3D block */
-		m = GetMatrix( BVFIRSTVECTOR(BVDOWNBV(bv_im1)), BVFIRSTVECTOR(BVSUCC(BVDOWNBV(bv_im1))));
-		assert( m != NULL );
-		by = MVALUE( m, K_comp );
-		m = GetMatrix( BVFIRSTVECTOR(bv_im1), BVFIRSTVECTOR(bv_i));
-		assert( m != NULL );
-		bz = MVALUE( m, K_comp );
-		li = lambda = (a + 2.0 * bx * cos(wavenr*PI*glob_h) + 2.0 * by * cos(wavenr3D*PI*glob_h)) / bz;
-		/*printf("a = %g  bx = %g  by = %g  bz = %g  lambda = %g  h= %g i = %g  j = %g\n", a,bx,by,bz,lambda, glob_h, wavenr, wavenr3D );*/
-	}
-#endif
-	
-	/* the loop calculates (T_i-1)^-1 and Theta(i,j) for i=1..n-1 */
-	/* T_0 := D_0 */
-	bv_im1 = BVDOWNBV(bv);
-	dmatcopyBS( bv_im1, bvd_im1, bvdf, FF_comp, K_comp );
-	bv_end = BVDOWNBVEND(bv);
-	for ( bv_i = BVSUCC( bv_im1 );
-		  bv_i != bv_end;
-		  bv_im1 = bv_i, bv_i = BVSUCC( bv_i ) )
-	{
-		/* T_i-1 decompose */
-		TFFDecomp( wavenr, wavenr3D, bv_im1, bvd_im1, bvdf, LU_comp, FFsub_comp, FF_comp, tv_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP, grid );
-
-		/* calculate Theta_(i-1,i) and Theta_(i,i-1);
-		   result on off-digonal blocks of FF_comp */
-		TFFConstructTestvector_loc( bv_i, tv_comp, wavenr, wavenr3D );
-		
-#ifdef THETA_ANA
-		dmatsetBS( bv_i, bvd_im1, bvdf, FF_comp, 1.0/li );
-		dmatsetBS( bv_im1, bvd_i, bvdf, FF_comp, 1.0/li );
-		/*printf("theta = %g\n", 1.0 / li );*/
-		li = lambda - 1.0 / li;
-#else
-		TFFCalculateTheta( bv_i, bv_im1, bvd_i, bvd_im1, bvdf, FF_comp, LU_comp, K_comp, tv_comp, aux_comp, auxsub_comp, FF_comp );
-#endif
-	
-		/* T_i := D_i + Theta_(i,i-1)*T_i-1*Theta_(i-1,i) -
-				  Theta_(i,i-1)*L_(i-1,i) - L_(i,i-1)*Theta_(i-1,i) */
-		dmatcopyBS( bv_i, bvd_i, bvdf, FF_comp, K_comp );
-		TFFUpdateDiagBlock( bv_i, bvd_i, bvd_im1, bvdf, FF_comp, K_comp, FF_comp, grid );
-
-		/* update BVDs for the next loop */
-		SWAP( bvd_i, bvd_im1, bvd_temp );
-		BVD_INC_LAST_ENTRY( bvd_i, 2, bvdf );
-	}
-	/* now bv_im1 and bvd_im1 points to the last block */
-
-	/* calculate the last (T_n)^-1 */
-	TFFDecomp( wavenr, wavenr3D, bv_im1, bvd_im1, bvdf, LU_comp, FFsub_comp, FF_comp, tv_comp, auxsub_comp, DUMMY_COMP, DUMMY_COMP, grid );
-
-
-#ifdef CHECK_CALCULATION
-{
-	/* notice: for the first block exists no testvector. But it is still 0
-		       thus it do not disturb the check */
-	DOUBLE norm;
-
-/* to get the right global testvector for the tests */ 
-if( K_comp == 0 )
-  TFFConstructTestvector( bv, tv_comp, wavenr, wavenr3D );
-
-	/* aux2 := M * tv */
-	TFFMultWithM( bv, bvd, bvdf, aux2_COMP, FF_comp, K_comp, LU_comp, tv_comp, aux_comp, auxsub_comp, FF_comp );
-	
-	/* aux := K * tv */
-	dsetBS( bv, aux_comp, 0.0 );
-	dmatmulBS( bv, bvd, bvdf, aux_comp, K_comp, tv_comp );
-	
-	/* aux2 -= aux */
-	dsubBS( bv, aux2_COMP, aux_comp );
-	
-	/* norm of aux2 */
-	eunormBS( bv, aux2_COMP, &norm );
-	
-	if ( norm > TFFaccuracy )
-	{
-		printf( "approximation M *tv == K * tv (%g) is not good enough!!!!!!!!!!!!!!!!!\n", norm );
-		UserWriteF( "approximation M *tv == K * tv (%g) is not good enough!!!!!!!!!!!!!!!!!\n", norm );
-	}
-	else 
-		if ( mute_level >= 50 )
-
-		{
-			printf( "approximation M *tv == K * tv (%g) is good\n", norm );
-			UserWriteF( "approximation M *tv == K * tv (%g) is good\n", norm );
-		}
-}	
-#endif
-
-	/*printvBS(bv, tv_comp); printmBS(bv,bv,K_comp); printmBS(bv,bv,FF_comp); printmBS(bv,bv,LU_comp); printf("\n");*/
-	return NUM_OK;
-}
-
-
-/****************************************************************************/
-/*D
-   TFFSolve - solves an linear equation with the tangential frequency filtering method
-   
-   SYNOPSIS:
-   INT  TFFSolve( const BLOCKVECTOR *bv, 
-                  const BV_DESC *bvd, 
-				  const BV_DESC_FORMAT *bvdf, 
-				  INT K_comp, 
-				  INT u_comp, 
-				  INT f_comp, 
-				  INT cor_comp, 
-				  INT FF_comp, 
-				  INT LU_comp, 
-				  INT tv_comp, 
-				  INT aux_comp, 
-				  INT auxsub_comp, 
-				  INT FFsub_comp, 
-				  DOUBLE meshwidth, 
-				  DOUBLE eps, 
-				  GRID *grid );
-
-   PARAMETERS:
-.  bv - blockvector covering the matrix to be decomposed
-.  bvd - description of the blockvector
-.  bvdf - format to interpret the 'bvd'
-.  K_comp - position of the stiffness matrix in the MATRIX-data to be decomposed
-.  u_comp - position of the solution in the VECTOR-data
-.  f_comp - position of the right hand side in the VECTOR-data
-.  cor_comp - position of the correction of the solution in the VECTOR-data
-.  FF_comp - position of the Theta and filtered diagonal blocks in the MATRIX-data
-.  LU_comp - position of the component for the LU-decomposed (diagonal) blocks
-.  tv_comp - position of the testvector-component in the VECTOR-data
-.  aux_comp - position of the auxiliary-component in the VECTOR-data
-.  auxsub_comp - position of the auxiliary-component for subproblems (only 3D)
-.  FFsub_comp - position of the Theta and filtered diagonal blocks of the subproblem-matrix (only 3D)
-.  meshwidth - meshwidth of the regular grid
-.  eps - accuracy of the final solution (stopping criterion)
-.  grid - grid where the matrixes lives on (for allocating extra connections)
-
-   DESCRIPTION:
-   This function solves the linear equation 'K*u = f' with the tangential 
-   frequency filtering method (see the literature). 'u_comp' contains the
-   first approximation of the solution, the starting point of the iteration.
-   'f_comp' imports the right hand side vector and will be destroyed during
-   the iteration because it is used as the defect-vector.
-   
-   'auxsub_comp' and 'FFsub_comp' are used only in the 3D case; in 2D you 
-   can use an arbitrary number.
-   
-   To do certain experiments there can be activated variants of the usual
-   algorithm by defining macro-names. See the code. If CHECK_CALC is active
-   the constants aux2_COMP and aux3_COMP are used as further postions in the
-   VECTOR-data for checking calculations. This is dirty!
-
-   WARNING:
-   Destroys the right hand side 'f_comp'.
-   
-   Works only for regular meshes. Blockvector structure according to 
-   'CreateBVStripe2D'/'CreateBVStripe3D' must be prepared.
-
-   SEE ALSO:
-   TFFCalculateTheta, TFFConstructTestvector_loc, TFFConstructTestvector, TFFMultWithM, TFFMultWithMInv, TFFDecomp, CreateBVStripe2D, CreateBVStripe3D
-
-   RETURN VALUE:
-   INT
-.n    NUM_OK if ok
-D*/
-/****************************************************************************/
-
-INT  TFFSolve( const BLOCKVECTOR *bv, const BV_DESC *bvd, const BV_DESC_FORMAT *bvdf, INT K_comp, INT u_comp, INT f_comp, INT cor_comp, INT FF_comp, INT LU_comp, INT tv_comp, INT aux_comp, INT auxsub_comp, INT FFsub_comp, DOUBLE meshwidth, DOUBLE eps, GRID *grid )
-{
-	DOUBLE old_norm, new_norm, start_norm, step_norm, final_acc;
-	INT i, j=0, it, nr_TFFs;
-
-	/* calculate i with 1/pow(2,i) == meshwidth */
-	nr_TFFs = (INT)( log(1.0/meshwidth)/M_LN2 + 0.5 );
-	UserWriteF( "meshwidth %g = 1/%g  nr_TFFs %d\n", meshwidth, 1.0/meshwidth, nr_TFFs );
-
-	/* f := f - K * u */
-	start_norm = new_norm = CalculateDefectAndNormBS( bv, bvd, bvdf, f_comp, f_comp, K_comp, u_comp );
-	UserWriteF( "start defect %g\n", start_norm );
-	/* now the rhs is destroyed and is used as the defect */
-	
-	/* different possibilities for accuracy */
-	/*final_acc = eps * meshwidth * meshwidth;*/
-	/*final_acc = eps * meshwidth * meshwidth * start_norm;*/
-	final_acc = eps;
-	it = 0;
-	while ( new_norm > final_acc )
-	{
-		it++;
-
-		old_norm = new_norm;
-
-#ifdef __THREEDIM__
-		for ( j = 0; j < nr_TFFs; j++ )
-		{
-			i = j;
-#endif
-
-#ifdef __TWODIM__
-		for ( i = 0; i < nr_TFFs; i++ )
-		{
-#endif
-			
-#ifdef THETA_ANA
-			glob_h = meshwidth;
-#endif
-			step_norm = new_norm;
-
-			/* construct testvector */
-			/*TFFConstructTestvector( bv, tv_comp, (double)(1<<i), (double)(1<<j) );*/
-
-			/* Calculates the TFF decomposition of M = (L + T) * T^-1 * (L^T + T) */
-			TFFDecomp( (double)(1<<i), (double)(1<<j), bv, bvd, bvdf, LU_comp, FF_comp, K_comp, tv_comp, aux_comp, auxsub_comp, FFsub_comp, grid );
-
-			/* cor := M^-1 * f */
-			dcopyBS( bv, cor_comp, f_comp );
-			TFFMultWithMInv( bv, bvd, bvdf, cor_comp, K_comp, LU_comp, cor_comp, aux_comp, auxsub_comp, FF_comp );
-
-#ifdef CHECK_CALCULATION
-		{
-			DOUBLE norm;
-
-			/* check invertation of testvector tv == M^-1 * K * tv; 
-				must always be true since it is equivalent to 
-				S * tv == 0, i.e. solve exact on the tv-subspace*/
-
-			/* aux2 := K * tv */
-			dsetBS( bv, aux2_COMP, 0.0 );
-			dmatmulBS( bv, bvd, bvdf, aux2_COMP, K_comp, tv_comp );
-
-			/* aux2 := M^-1 * aux2 */
-			TFFMultWithMInv( bv, bvd, bvdf, aux2_COMP, K_comp, LU_comp, aux2_COMP, aux3_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 -= tv */
-			dsubBS( bv, aux2_COMP, tv_comp );
-
-			/* norm of aux2 */
-			eunormBS( bv, aux2_COMP, &norm );
-
-			if ( norm > TFFaccuracy )
-			{
-				printf( "M^-1*K*tv==tv is not good (%g)!!!!!!!!!!!!!!!!!\n", norm );
-				UserWriteF( "M^-1*K*tv==tv is not good (%g)!!!!!!!!!!!!!!!!!\n", norm );
-			}
-			else
-				if ( mute_level >= 50 )
-				{
-					printf( "M^-1*K*tv==tv is good  (%g)\n", norm );
-					UserWriteF( "M^-1*K*tv==tv is good (%g)\n", norm );
-				}
-
-			/* tests how good tv == M^-1 * M * tv is fullfiled; must always */
-		
-			/* aux2 := M * tv */
-			TFFMultWithM( bv, bvd, bvdf, aux2_COMP, FF_comp, K_comp, LU_comp, tv_comp, aux3_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 := M^-1 * aux2 */
-			dcopyBS( bv, aux_comp, tv_comp );
-			TFFMultWithMInv( bv, bvd, bvdf, aux2_COMP, K_comp, LU_comp, aux2_COMP, aux3_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 -= tv */
-			dsubBS( bv, aux2_COMP, tv_comp );
-
-			/* norm of aux2 */
-			eunormBS( bv, aux2_COMP, &norm );
-
-			if ( norm > TFFaccuracy )
-			{
-				printf( "M^-1*M*tv==tv is not good enough (%g)!!!!!!!!!!!!!!!!!\n", norm );
-				UserWriteF( "M^-1*M*tv==tv is not good enough (%g)!!!!!!!!!!!!!!!!!\n", norm );
-			}
-			else
-				if ( mute_level >= 50 )
-				{
-					printf( "M^-1*M*tv==tv is good  (%g)\n", norm );
-					UserWriteF( "M^-1*M*tv==tv is good (%g)\n", norm );
-				}
-
-			/* tests how good tv == M * M^-1 * tv is fullfiled */
-		
-			/* aux := M^-1 * tv */
-			dcopyBS( bv, aux_comp, tv_comp );
-			TFFMultWithMInv( bv, bvd, bvdf, aux_comp, K_comp, LU_comp, aux_comp, aux3_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 := M * aux */
-			TFFMultWithM( bv, bvd, bvdf, aux2_COMP, FF_comp, K_comp, LU_comp, aux_comp, aux3_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 -= tv */
-			dsubBS( bv, aux2_COMP, tv_comp );
-
-			/* norm of aux2 */
-			eunormBS( bv, aux2_COMP, &norm );
-
-			if ( norm > TFFaccuracy )
-			{
-				printf( "M*M^-1*tv==tv is not good enough (%g)..................\n", norm );
-				UserWriteF( "M*M^-1*tv==tv is not good enough (%g)..................\n", norm );
-			}
-			else
-				if ( mute_level >= 50 )
-				{
-					printf( "M*M^-1*tv==tv is good  (%g)\n", norm );
-					UserWriteF( "M*M^-1*tv==tv is good (%g)\n", norm );
-				}
-						
-			/* check invertation of testvector tv == K * M^-1 * tv */
-
-			/* aux3 := M^-1 * tv */
-			dcopyBS( bv, aux3_COMP, tv_comp );
-			TFFMultWithMInv( bv, bvd, bvdf, aux3_COMP, K_comp, LU_comp, aux3_COMP, aux2_COMP, auxsub_comp, FF_comp );
-
-			/* aux2 := K * aux3 */
-			dsetBS( bv, aux2_COMP, 0.0 );
-			dmatmulBS( bv, bvd, bvdf, aux2_COMP, K_comp, aux3_COMP );
-
-			/* aux2 -= tv */
-			dsubBS( bv, aux2_COMP, tv_comp );
-
-			/* norm of aux2 */
-			eunormBS( bv, aux2_COMP, &norm );
-
-			if ( norm > TFFaccuracy )
-			{
-				printf( "K*M^-1*tv==tv is not good (%g)..................\n", norm );
-				UserWriteF( "K*M^-1*tv==tv is not good (%g)..................\n", norm );
-			}
-			else
-				if ( mute_level >= 50 )
-				{
-					printf( "K*M^-1*tv==tv is good  (%g)\n", norm );
-					UserWriteF( "K*M^-1*tv==tv is good (%g)\n", norm );
-				}
-
-			
-			if ( mute_level >= 50 )
-			{
-				/* another test: compare with given stiffness matrix 
-				   K * cor - M * cor */
-
-				/* aux2 := K * cor */
-				dsetBS( bv, aux2_COMP, 0.0 );
-				dmatmulBS( bv, bvd, bvdf, aux2_COMP, K_comp, cor_comp );
-
-				/* aux2 -= aux */
-				dsubBS( bv, aux2_COMP, aux_comp );
-
-				/* norm of aux2 */
-				eunormBS( bv, aux2_COMP, &norm );
-
-				if ( norm > TFFaccuracy )
-				{
-					printf( "Invertation is not good enough (%g) resp. K\n", norm );
-					UserWriteF( "Invertation is not good enough (%g) resp. K\n", norm );
-				}
-				else
-				{
-					printf( "Invertation is good  (%g) resp. K\n", norm );
-					UserWriteF( "Invertation is good (%g) resp. K\n", norm );
-				}
-			}
-		}
-#endif
-
-			/* u := u + cor */
-			daddBS( bv, u_comp, cor_comp );
-
-			/* f := f - K * cor */
-			new_norm = CalculateDefectAndNormBS( bv, bvd, bvdf, f_comp, f_comp, K_comp, cor_comp );
-
-#ifdef __TWODIM__
-			UserWriteF( "Wavenumber = %2d new defect = %12lg conv. rate = %12lg\n", 1<<i, new_norm, new_norm/step_norm );
-#endif
-
-#ifdef __THREEDIM__
-			UserWriteF( "Wnr plane = %2d Wnr line = %2d new defect = %12lg conv. rate = %12lg\n", 1<<j, 1<<i, new_norm, new_norm/step_norm );
-#endif
-		} /* for */
-
-		UserWriteF( "new defect = %4lg conv. rate = %12lg\n", new_norm, new_norm/old_norm );
-	} /* while */
-
-	UserWriteF( "avarage of convergency rate ( %d iterations) = %12lg\n", it, pow( new_norm / start_norm, 1.0 / (DOUBLE)it ) );
-
-	return NUM_OK;
-}
-
-#endif /* __BLOCK_VECTOR_DESC__ */
diff -ruN ug-orig/np/algebra/transgrid.c ug-patched/np/algebra/transgrid.c
--- ug-orig/np/algebra/transgrid.c	2005-07-12 17:08:17.000000000 +0200
+++ ug-patched/np/algebra/transgrid.c	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
@@ -90,7 +91,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/transgrid.c,v 1.57 2005/07/12 15:08:17 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/np/algebra/transgrid.h ug-patched/np/algebra/transgrid.h
--- ug-orig/np/algebra/transgrid.h	2001-01-24 14:52:35.000000000 +0100
+++ ug-patched/np/algebra/transgrid.h	2001-01-24 14:52:35.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/transgrid.h,v 1.3 2001/01/24 13:52:35 wieners Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/ugblas.c ug-patched/np/algebra/ugblas.c
--- ug-orig/np/algebra/ugblas.c	2006-11-17 11:59:50.000000000 +0100
+++ ug-patched/np/algebra/ugblas.c	2008-12-19 11:17:43.000000000 +0100
@@ -40,6 +40,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -199,7 +200,7 @@
 static INT trace_ugblas=0;
 
 /* RCS string */
-const static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/ugblas.c,v 1.105 2006/11/17 10:59:50 sander Exp $",UG_RCS_STRING);
+const static char RCS_ID("$Header$",UG_RCS_STRING);
 
 REP_ERR_FILE;
 
diff -ruN ug-orig/np/algebra/ugblas.h ug-patched/np/algebra/ugblas.h
--- ug-orig/np/algebra/ugblas.h	2006-05-08 14:27:34.000000000 +0200
+++ ug-patched/np/algebra/ugblas.h	2006-05-08 14:31:31.000000000 +0200
@@ -30,7 +30,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/ugblas.h,v 1.13 2006/05/08 12:27:34 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/algebra/ugeblas.c ug-patched/np/algebra/ugeblas.c
--- ug-orig/np/algebra/ugeblas.c	2004-07-21 11:18:57.000000000 +0200
+++ ug-patched/np/algebra/ugeblas.c	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "general.h"
 #include "ugblas.h"
 
@@ -66,7 +67,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/ugeblas.c,v 1.5 2004/07/21 09:18:57 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/np/algebra/ugiter.c ug-patched/np/algebra/ugiter.c
--- ug-orig/np/algebra/ugiter.c	2006-06-02 18:15:34.000000000 +0200
+++ ug-patched/np/algebra/ugiter.c	2006-06-02 18:15:34.000000000 +0200
@@ -154,7 +154,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/algebra/ugiter.c,v 1.58 2006/06/02 16:15:34 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*                                                                          */
diff -ruN ug-orig/np/algebra/vecfunc.ct ug-patched/np/algebra/vecfunc.ct
--- ug-orig/np/algebra/vecfunc.ct	2004-01-19 10:34:39.000000000 +0100
+++ ug-patched/np/algebra/vecfunc.ct	2004-01-19 10:37:49.000000000 +0100
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/vecfunc.ct,v 1.8 2004/01/19 09:34:39 sander Exp $
+$Header$
 */
 
 INT T_FUNCNAME (MULTIGRID *mg, INT fl, INT tl, INT mode, const VECDATA_DESC *x T_ARGS)
diff -ruN ug-orig/np/algebra/vecloop.ct ug-patched/np/algebra/vecloop.ct
--- ug-orig/np/algebra/vecloop.ct	1997-07-25 19:44:19.000000000 +0200
+++ ug-patched/np/algebra/vecloop.ct	1997-07-25 19:44:29.000000000 +0200
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/vecloop.ct,v 1.1 1997/07/25 17:44:19 wieners Exp $
+$Header$
 */
  	#ifdef T_SURFACE_MODE 
 	for (lev= FULLREFINELEVEL(mg); lev<tl; lev++)
diff -ruN ug-orig/np/algebra/vecmode.ct ug-patched/np/algebra/vecmode.ct
--- ug-orig/np/algebra/vecmode.ct	2005-12-06 12:21:36.000000000 +0100
+++ ug-patched/np/algebra/vecmode.ct	2005-12-06 12:21:36.000000000 +0100
@@ -17,7 +17,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/algebra/vecmode.ct,v 1.4 2005/12/06 11:21:36 sander Exp $
+$Header$
 */
 
 #ifdef T_MOD_SCAL
diff -ruN ug-orig/np/amglib/amg_blas.c ug-patched/np/amglib/amg_blas.c
--- ug-orig/np/amglib/amg_blas.c	1997-10-20 11:03:48.000000000 +0200
+++ ug-patched/np/amglib/amg_blas.c	2008-12-19 11:17:43.000000000 +0100
@@ -30,6 +30,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
@@ -71,7 +72,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_blas.c,v 1.1 1997/10/20 09:03:48 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_blas.h ug-patched/np/amglib/amg_blas.h
--- ug-orig/np/amglib/amg_blas.h	1997-10-20 11:03:48.000000000 +0200
+++ ug-patched/np/amglib/amg_blas.h	1997-10-20 11:03:54.000000000 +0200
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_blas.h,v 1.1 1997/10/20 09:03:48 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_coarsen.c ug-patched/np/amglib/amg_coarsen.c
--- ug-orig/np/amglib/amg_coarsen.c	2005-11-24 10:10:40.000000000 +0100
+++ ug-patched/np/amglib/amg_coarsen.c	2008-12-19 11:17:43.000000000 +0100
@@ -29,6 +29,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
@@ -43,7 +44,7 @@
 #include "amg_coarsen.h"
 
 /* RCS string 
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/amglib/amg_coarsen.c,v 1.11 2005/11/24 09:10:40 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_coarsen.h ug-patched/np/amglib/amg_coarsen.h
--- ug-orig/np/amglib/amg_coarsen.h	1997-10-23 19:35:28.000000000 +0200
+++ ug-patched/np/amglib/amg_coarsen.h	1997-10-23 19:35:29.000000000 +0200
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_coarsen.h,v 1.3 1997/10/23 17:35:28 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_header.h ug-patched/np/amglib/amg_header.h
--- ug-orig/np/amglib/amg_header.h	1997-10-21 15:34:44.000000000 +0200
+++ ug-patched/np/amglib/amg_header.h	1997-10-21 15:34:47.000000000 +0200
@@ -22,7 +22,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_header.h,v 1.2 1997/10/21 13:34:44 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_iter.c ug-patched/np/amglib/amg_iter.c
--- ug-orig/np/amglib/amg_iter.c	1997-12-12 01:43:29.000000000 +0100
+++ ug-patched/np/amglib/amg_iter.c	2008-12-19 11:17:43.000000000 +0100
@@ -30,6 +30,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
@@ -70,7 +71,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_iter.c,v 1.3 1997/12/12 00:43:29 henrik Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_iter.h ug-patched/np/amglib/amg_iter.h
--- ug-orig/np/amglib/amg_iter.h	1997-10-21 15:34:45.000000000 +0200
+++ ug-patched/np/amglib/amg_iter.h	1997-10-21 15:34:47.000000000 +0200
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_iter.h,v 1.2 1997/10/21 13:34:45 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_low.c ug-patched/np/amglib/amg_low.c
--- ug-orig/np/amglib/amg_low.c	1997-10-20 11:03:51.000000000 +0200
+++ ug-patched/np/amglib/amg_low.c	2008-12-19 11:17:43.000000000 +0100
@@ -30,6 +30,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
@@ -75,7 +76,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_low.c,v 1.1 1997/10/20 09:03:51 peter Exp $
+$Header$
 */
 
 /* user installable print handler */
@@ -147,7 +148,7 @@
 D*/
 /****************************************************************************/
 
-int AMG_Print (char *s)
+int AMG_Print (const char *s)
 {
 	if (outFile!=NULL)
 	{
diff -ruN ug-orig/np/amglib/amg_low.h ug-patched/np/amglib/amg_low.h
--- ug-orig/np/amglib/amg_low.h	1997-10-20 11:03:51.000000000 +0200
+++ ug-patched/np/amglib/amg_low.h	2008-04-17 12:21:51.000000000 +0200
@@ -22,7 +22,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_low.h,v 1.1 1997/10/20 09:03:51 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -50,7 +50,7 @@
 /******** typedefs     ******************************************************/
 /****************************************************************************/
 
-typedef void (*AMG_PrintFuncPtr) (char *);
+typedef void (*AMG_PrintFuncPtr) (const char *);
 typedef void * (*AMG_MallocFuncPtr) (size_t n);
 
 /****************************************************************************/
@@ -59,7 +59,7 @@
 
 /* string i/o */
 int       AMG_InstallPrintHandler (AMG_PrintFuncPtr print);
-int       AMG_Print         (char *s);
+int       AMG_Print         (const char *s);
 int 	  AMG_RedirectToFile (char *name);
 int 	  AMG_RedirectToScreen (void);
 
diff -ruN ug-orig/np/amglib/amg_solve.c ug-patched/np/amglib/amg_solve.c
--- ug-orig/np/amglib/amg_solve.c	1998-09-02 14:25:01.000000000 +0200
+++ ug-patched/np/amglib/amg_solve.c	2008-12-19 11:17:43.000000000 +0100
@@ -29,6 +29,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
@@ -43,7 +44,7 @@
 #include "amg_solve.h"
 
 /* RCS string 
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/amglib/amg_solve.c,v 1.9 1998/09/02 12:25:01 henrik Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_solve.h ug-patched/np/amglib/amg_solve.h
--- ug-orig/np/amglib/amg_solve.h	1997-11-05 11:33:14.000000000 +0100
+++ ug-patched/np/amglib/amg_solve.h	1997-11-05 11:33:15.000000000 +0100
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_solve.h,v 1.3 1997/11/05 10:33:14 df Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/amg_sp.c ug-patched/np/amglib/amg_sp.c
--- ug-orig/np/amglib/amg_sp.c	2000-11-21 10:56:32.000000000 +0100
+++ ug-patched/np/amglib/amg_sp.c	2008-12-19 11:17:43.000000000 +0100
@@ -30,6 +30,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
@@ -41,7 +42,7 @@
 #include "amg_sp.h"
 
 /* RCS string 
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/amglib/amg_sp.c,v 1.6 2000/11/21 09:56:32 klaus Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 */
 
 /****************************************************************************/
@@ -102,7 +103,7 @@
 D*/
 /****************************************************************************/
 
-AMG_VECTOR *AMG_NewVector (int n, int b, char *name)
+AMG_VECTOR *AMG_NewVector (int n, int b, const char *name)
 {
 	AMG_VECTOR *New;
 	double *values;
@@ -157,7 +158,7 @@
 D*/
 /****************************************************************************/
 
-AMG_MATRIX *AMG_NewMatrix (int n, int b, int nonzeros, int system_as_scalar, char *name)
+AMG_MATRIX *AMG_NewMatrix (int n, int b, int nonzeros, int system_as_scalar, const char *name)
 {
 	AMG_MATRIX *New;
 	double *a;
diff -ruN ug-orig/np/amglib/amg_sp.h ug-patched/np/amglib/amg_sp.h
--- ug-orig/np/amglib/amg_sp.h	1997-10-21 15:34:47.000000000 +0200
+++ ug-patched/np/amglib/amg_sp.h	2008-03-31 10:58:07.000000000 +0200
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_sp.h,v 1.2 1997/10/21 13:34:47 peter Exp $
+$Header$
 */
 
 /****************************************************************************/
@@ -78,7 +78,7 @@
 #define AMG_VECTOR_X(p)				((p)->x)
 #define AMG_VECTOR_ENTRY(p,i,ii)	((p)->x[(i)*(p)->b+(ii)])
 
-AMG_VECTOR *AMG_NewVector (int n, int b, char *name);
+AMG_VECTOR *AMG_NewVector (int n, int b, const char *name);
 
 /****************************************************************************/
 /******** pattern of a general m x n sparse block matrix    *****************/
@@ -118,7 +118,7 @@
 #define AMG_MATRIX_A(p)				((p)->a)
 
 /* Construction */
-AMG_MATRIX *AMG_NewMatrix (int n, int b, int nonzeros, int system_as_scalar, char *name);
+AMG_MATRIX *AMG_NewMatrix (int n, int b, int nonzeros, int system_as_scalar, const char *name);
 AMG_MATRIX *AMG_CopyMatrix (AMG_MATRIX *A, char *name);
 int        	AMG_SetRowLength (AMG_MATRIX *A, int i, int l);
 int        	AMG_FindEntry (AMG_MATRIX *A, int i, int j);
diff -ruN ug-orig/np/amglib/amg_ug.c ug-patched/np/amglib/amg_ug.c
--- ug-orig/np/amglib/amg_ug.c	2006-04-18 10:57:21.000000000 +0200
+++ ug-patched/np/amglib/amg_ug.c	2008-12-19 11:17:43.000000000 +0100
@@ -33,6 +33,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -130,7 +131,7 @@
 REP_ERR_FILE;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/amglib/amg_ug.c,v 1.17 2006/04/18 08:57:21 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*																			*/
diff -ruN ug-orig/np/amglib/amg_ug.h ug-patched/np/amglib/amg_ug.h
--- ug-orig/np/amglib/amg_ug.h	2006-05-08 14:28:45.000000000 +0200
+++ ug-patched/np/amglib/amg_ug.h	2006-05-08 14:31:31.000000000 +0200
@@ -21,7 +21,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/amg_ug.h,v 1.3 2006/05/08 12:28:45 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/amglib/CVS/Entries ug-patched/np/amglib/CVS/Entries
--- ug-orig/np/amglib/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/amglib/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,21 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:19 2004//D2008.11.12.23.00.00
-/Makefile/1.1/Mon Oct 20 09:03:47 1997//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:13 2004//D2008.11.12.23.00.00
-/Makefile.amglib/1.1/Mon Oct 20 09:03:48 1997//D2008.11.12.23.00.00
-/amg_blas.c/1.1/Mon Oct 20 09:03:48 1997//D2008.11.12.23.00.00
-/amg_blas.h/1.1/Mon Oct 20 09:03:48 1997//D2008.11.12.23.00.00
-/amg_coarsen.c/1.11/Thu Nov 24 09:10:40 2005//D2008.11.12.23.00.00
-/amg_coarsen.h/1.3/Thu Oct 23 17:35:28 1997//D2008.11.12.23.00.00
-/amg_header.h/1.2/Tue Oct 21 13:34:44 1997//D2008.11.12.23.00.00
-/amg_iter.c/1.3/Fri Dec 12 00:43:29 1997//D2008.11.12.23.00.00
-/amg_iter.h/1.2/Tue Oct 21 13:34:45 1997//D2008.11.12.23.00.00
-/amg_low.c/1.1/Mon Oct 20 09:03:51 1997//D2008.11.12.23.00.00
-/amg_low.h/1.1/Mon Oct 20 09:03:51 1997//D2008.11.12.23.00.00
-/amg_solve.c/1.9/Wed Sep  2 12:25:01 1998//D2008.11.12.23.00.00
-/amg_solve.h/1.3/Wed Nov  5 10:33:14 1997//D2008.11.12.23.00.00
-/amg_sp.c/1.6/Tue Nov 21 09:56:32 2000//D2008.11.12.23.00.00
-/amg_sp.h/1.2/Tue Oct 21 13:34:47 1997//D2008.11.12.23.00.00
-/amg_ug.c/1.17/Tue Apr 18 08:57:21 2006//D2008.11.12.23.00.00
-/amg_ug.h/1.3/Mon May  8 12:28:45 2006//D2008.11.12.23.00.00
-/test.c/1.8/Wed Feb  4 11:26:25 1998//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/amglib/CVS/Repository ug-patched/np/amglib/CVS/Repository
--- ug-orig/np/amglib/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/amglib/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/amglib
diff -ruN ug-orig/np/amglib/CVS/Root ug-patched/np/amglib/CVS/Root
--- ug-orig/np/amglib/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/amglib/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/amglib/CVS/Tag ug-patched/np/amglib/CVS/Tag
--- ug-orig/np/amglib/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/amglib/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/amglib/.cvsignore ug-patched/np/amglib/.cvsignore
--- ug-orig/np/amglib/.cvsignore	2004-09-08 16:14:19.000000000 +0200
+++ ug-patched/np/amglib/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/np/amglib/Makefile.am ug-patched/np/amglib/Makefile.am
--- ug-orig/np/amglib/Makefile.am	2004-09-02 14:22:13.000000000 +0200
+++ ug-patched/np/amglib/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:13 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 SOURCES = amg_blas.c amg_coarsen.c amg_iter.c amg_low.c amg_solve.c amg_sp.c amg_ug.c amg_blas.h amg_coarsen.h amg_header.h amg_iter.h amg_low.h amg_solve.h amg_sp.h amg_ug.h
 
diff -ruN ug-orig/np/amglib/test.c ug-patched/np/amglib/test.c
--- ug-orig/np/amglib/test.c	1998-02-04 12:26:25.000000000 +0100
+++ ug-patched/np/amglib/test.c	2008-12-19 11:17:43.000000000 +0100
@@ -31,6 +31,8 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
+
 #ifdef MWCW
 #include <console.h>
 #endif
@@ -67,7 +69,7 @@
 /****************************************************************************/
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/amglib/test.c,v 1.8 1998/02/04 11:26:25 df Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/np/cpldisc/coupleddiscinit.c ug-patched/np/cpldisc/coupleddiscinit.c
--- ug-orig/np/cpldisc/coupleddiscinit.c	2006-06-20 18:24:56.000000000 +0200
+++ ug-patched/np/cpldisc/coupleddiscinit.c	2008-12-19 11:17:43.000000000 +0100
@@ -5,6 +5,7 @@
  * D. Logashenko
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <math.h>
 
diff -ruN ug-orig/np/cpldisc/CVS/Entries ug-patched/np/cpldisc/CVS/Entries
--- ug-orig/np/cpldisc/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/cpldisc/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-/Makefile/1.2/Thu Mar 24 10:27:17 2005//D2008.11.12.23.00.00
-/coupleddiscinit.c/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/coupleddiscinit.h/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/globdisc.cc/1.6/Mon May 26 14:01:22 2008//D2008.11.12.23.00.00
-/globdisc.h/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/multivd.c/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/multivd.h/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/partdisc.cc/1.5/Mon Dec  3 16:59:36 2007//D2008.11.12.23.00.00
-/partdisc.hh/1.3/Mon Dec  3 17:26:35 2007//D2008.11.12.23.00.00
-/sparsepattern.c/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-/sparsepattern.h/1.2/Tue Jun 20 16:24:56 2006//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/cpldisc/CVS/Repository ug-patched/np/cpldisc/CVS/Repository
--- ug-orig/np/cpldisc/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/cpldisc/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/cpldisc
diff -ruN ug-orig/np/cpldisc/CVS/Root ug-patched/np/cpldisc/CVS/Root
--- ug-orig/np/cpldisc/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/cpldisc/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/cpldisc/CVS/Tag ug-patched/np/cpldisc/CVS/Tag
--- ug-orig/np/cpldisc/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/cpldisc/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/cpldisc/globdisc.cc ug-patched/np/cpldisc/globdisc.cc
--- ug-orig/np/cpldisc/globdisc.cc	2008-05-26 16:01:22.000000000 +0200
+++ ug-patched/np/cpldisc/globdisc.cc	2006-06-20 18:24:56.000000000 +0200
@@ -622,7 +622,7 @@
  )
  {
   INT i;
-  int id; /* keep 'int' here for 'sscanf' and 'sprintf'! */
+  INT id;
   np_part_discretization * disc;
   char disc_name [64];
   DOUBLE scale;
@@ -640,7 +640,7 @@
      sprintf (disc_name, "scale%d", id);
      if (ReadArgvDOUBLE (disc_name, &scale, argc, argv))
       scale = 1;
-     if (add_discretization (disc, (INT) id, scale))
+     if (add_discretization (disc, id, scale))
       return __LINE__;
     };
   
@@ -783,7 +783,7 @@
  {
   INT i;
   char imp_name [64], exp_name [64];
-  int exp_id, imp_id; /* keep 'int' here for 'sscanf' and 'sprintf'! */
+  INT exp_id, imp_id;
   import_param * imp_param;
   export_param * exp_param;
   t_disc_list * disc_elem;
@@ -803,7 +803,7 @@
     {
      /* Find the discretisation for the import parameter: */
      disc_elem = disc_list;
-     while (disc_elem->disc->id != (INT) imp_id)
+     while (disc_elem->disc->id != imp_id)
       if ((disc_elem = disc_elem->tl) == NULL)
        {
         PrintErrorMessageF ('E', "globdisc",
@@ -817,9 +817,9 @@
         "Cannot find import param. '%s' for disc. id %d", imp_name, imp_id);
        return __LINE__;
       };
-     /* Find the discretisation for the export parameter: */
+      /* Find the discretisation for the export parameter: */
      disc_elem = disc_list;
-     while (disc_elem->disc->id != (INT) exp_id)
+     while (disc_elem->disc->id != exp_id)
       if ((disc_elem = disc_elem->tl) == NULL)
        {
         PrintErrorMessageF ('E', "globdisc",
@@ -986,8 +986,7 @@
  )
  {
   t_disc_list * disc_elem;
-  INT i;
-  int disc_id; /* keep 'int' here for 'sscanf' and 'sprintf' */
+  INT i, disc_id;
   import_param * param;
   char param_name [64];
   param_value * p_val;
@@ -1000,7 +999,7 @@
    {
     /* Find the discretisation for the import parameter: */
     disc_elem = disc_list;
-    while (disc_elem->disc->id != (INT) disc_id)
+    while (disc_elem->disc->id != disc_id)
      if ((disc_elem = disc_elem->tl) == NULL)
       {
        PrintErrorMessageF ('E', "globdisc",
@@ -1083,7 +1082,7 @@
   import_param * param;
   VECDATA_DESC * vd;
   param_vec_desc * param_vd;
-  int disc_id; /* keep 'int' here for 'sscanf' and 'sprintf'! */
+  INT disc_id;
   char param_name [64], vd_name [64];
   INT n;
   char * str = command + sizeof (vd_command);
@@ -1093,7 +1092,7 @@
    {
     /* Find the discretisation for the import parameter: */
     disc_elem = disc_list;
-    while (disc_elem->disc->id != (INT) disc_id)
+    while (disc_elem->disc->id != disc_id)
      if ((disc_elem = disc_elem->tl) == NULL)
       {
        PrintErrorMessageF ('E', "globdisc",
@@ -1530,7 +1529,7 @@
   * res = 0; return 0;
  }
 
-/* AssembleDefect - assembles the global defect of all the discretizations.
+/* AssembleDefect - assembles the global defect all the discretizations.
  * The defect is added to that kept in the vector descriptor.
  * Returns 0 if OK, nonzero on an error:
  */
@@ -2123,12 +2122,7 @@
               UserWriteF ("[");
               for (j = 0; j < np->n_equations; j++)
                if ((ind = J_entry_cmp [n_i_comp * np->n_equations + j]) >= 0)
-                {
-                 if (fabs (s = MVALUE (mat, ind)) >= 1e-12)
-                  UserWriteF (" %g", MVALUE (mat, ind));
-                 else
-                  UserWrite (" 0");
-                }
+                UserWriteF (" %g", MVALUE (mat, ind));
                else
                 UserWriteF (" @");
               UserWriteF ("]");
diff -ruN ug-orig/np/cpldisc/multivd.c ug-patched/np/cpldisc/multivd.c
--- ug-orig/np/cpldisc/multivd.c	2006-06-20 18:24:56.000000000 +0200
+++ ug-patched/np/cpldisc/multivd.c	2008-12-19 11:17:43.000000000 +0100
@@ -10,6 +10,7 @@
  * to the components of vector descriptors <vd1>, <vd2>, ... in the
  * order in which these descriptors are listed in the command.
  */
+#include "config.h"
 #include <stdio.h>
 #include <math.h>
 #include <stdlib.h>
diff -ruN ug-orig/np/cpldisc/partdisc.cc ug-patched/np/cpldisc/partdisc.cc
--- ug-orig/np/cpldisc/partdisc.cc	2007-12-03 17:59:36.000000000 +0100
+++ ug-patched/np/cpldisc/partdisc.cc	2007-12-04 11:02:04.000000000 +0100
@@ -120,7 +120,7 @@
   VEC_SCALAR damp /* damping factors */
  )
  {
-  INT i, k, n, vec_data_type;
+  INT i, k, n;
   SHORT * from_comp, * to_comp;
   GRID * fine_grid;
   NODE * node;
@@ -137,52 +137,50 @@
   if (n < np->n_equations)
    return __LINE__;
   
-  /* Get the data types: */
-  vec_data_type = VD_DATA_TYPES (dst);
-  
   /* Get the fine grid: */
   if (level < 1) return __LINE__;
   fine_grid = GRID_ON_LEVEL (NP_MG (np), level);
   
   /* Prolong the correction: */
   for (node = FIRSTNODE (fine_grid); node != NULL; node = SUCCN (node))
-   if (V_IN_DATATYPE (vec = NVECTOR (node), vec_data_type))
-    {
-     /* Set the components to zero: */
-     for (k = 0; k < np->n_equations; k++)
-      VVALUE (vec, to_comp [np->first_vec_cmp + k]) = 0;
-     
-     if (CORNERTYPE (node))
-      {
-       /* Copy the components of the vector: */
-       c_vec = NVECTOR ((NODE *) NFATHER (node));
-       for (k = 0; k < np->n_equations; k++)
-        if ((np->Dirichlet_bc == NULL)?
-            (vec->skip & (1 << (np->first_vec_cmp + k))) == 0
-             : np->Dirichlet_bc (np, vec->skip, k) == 0)
-         VVALUE (vec, to_comp [np->first_vec_cmp + k])
-          = damp [np->first_vec_cmp + k]
-           * VVALUE (c_vec, from_comp [np->first_vec_cmp + k]);
-      }
-     else
-      {
-       /* Sum the 'hat'-functions: */
-       vert = MYVERTEX (node);
-       elem = VFATHER (vert);
-       GNs ((n = CORNERS_OF_ELEM (elem)), LCVECT (vert), c);
-       for (i = 0; i < n; i++)
-        {
-         c_vec = NVECTOR (CORNER (elem, i));
-         for (k = 0; k < np->n_equations; k++)
-          if ((np->Dirichlet_bc == NULL)?
-              (vec->skip & (1 << (np->first_vec_cmp + k))) == 0
-               : np->Dirichlet_bc (np, vec->skip, k) == 0)
-           VVALUE (vec, to_comp [np->first_vec_cmp + k])
-            += damp [np->first_vec_cmp + k] * c [i]
-             * VVALUE (c_vec, from_comp [np->first_vec_cmp + k]);
-        };
-      };
-    };
+   {
+    vec = NVECTOR (node);
+    
+    /* Set the components to zero: */
+    for (k = 0; k < np->n_equations; k++)
+     VVALUE (vec, to_comp [np->first_vec_cmp + k]) = 0;
+    
+    if (CORNERTYPE (node))
+     {
+      /* Copy the components of the vector: */
+      c_vec = NVECTOR ((NODE *) NFATHER (node));
+      for (k = 0; k < np->n_equations; k++)
+       if ((np->Dirichlet_bc == NULL)?
+           (vec->skip & (1 << (np->first_vec_cmp + k))) == 0
+            : np->Dirichlet_bc (np, vec->skip, k) == 0)
+        VVALUE (vec, to_comp [np->first_vec_cmp + k])
+         = damp [np->first_vec_cmp + k]
+          * VVALUE (c_vec, from_comp [np->first_vec_cmp + k]);
+     }
+    else
+     {
+      /* Sum the 'hat'-functions: */
+      vert = MYVERTEX (node);
+      elem = VFATHER (vert);
+      GNs ((n = CORNERS_OF_ELEM (elem)), LCVECT (vert), c);
+      for (i = 0; i < n; i++)
+       {
+        c_vec = NVECTOR (CORNER (elem, i));
+        for (k = 0; k < np->n_equations; k++)
+         if ((np->Dirichlet_bc == NULL)?
+             (vec->skip & (1 << (np->first_vec_cmp + k))) == 0
+              : np->Dirichlet_bc (np, vec->skip, k) == 0)
+          VVALUE (vec, to_comp [np->first_vec_cmp + k])
+           += damp [np->first_vec_cmp + k] * c [i]
+            * VVALUE (c_vec, from_comp [np->first_vec_cmp + k]);
+       };
+     };
+   };
   
   return 0;
  }
@@ -197,7 +195,7 @@
   VEC_SCALAR damp /* damping factors */
  )
  {
-  INT i, k, n, vec_data_type;
+  INT i, k, n;
   SHORT * from_comp, * to_comp;
   GRID * fine_grid;
   NODE * node;
@@ -214,9 +212,6 @@
   if (n < np->n_equations)
    return __LINE__;
   
-  /* Get the data types: */
-  vec_data_type = VD_DATA_TYPES (dst);
-  
   /* Get the fine grid: */
   if (level < 1) return __LINE__;
   fine_grid = GRID_ON_LEVEL (NP_MG (np), level);
@@ -224,14 +219,13 @@
   /* Set the components to zero: */
   for (vec = PFIRSTVECTOR (GRID_ON_LEVEL (NP_MG (np), level - 1)); vec != NULL;
    vec = SUCCVC (vec))
-   if (V_IN_DATATYPE (vec, vec_data_type) && VNCLASS (vec) >= NEWDEF_CLASS)
+   if (VNCLASS (vec) >= NEWDEF_CLASS)
     for (k = 0; k < np->n_equations; k++)
      VVALUE (vec, to_comp [np->first_vec_cmp + k]) = 0;
   
-  /* Restrict the defect: */
+  /* Prolong the correction: */
   for (node = FIRSTNODE (fine_grid); node != NULL; node = SUCCN (node))
-   if (V_IN_DATATYPE (vec = NVECTOR (node), vec_data_type)
-    && VCLASS (vec) >= NEWDEF_CLASS)
+   if (VCLASS (vec = NVECTOR (node)) >= NEWDEF_CLASS)
     {
      /* Sum the 'hat'-functions: */
      if (CORNERTYPE (node))
diff -ruN ug-orig/np/cpldisc/sparsepattern.c ug-patched/np/cpldisc/sparsepattern.c
--- ug-orig/np/cpldisc/sparsepattern.c	2006-06-20 18:24:56.000000000 +0200
+++ ug-patched/np/cpldisc/sparsepattern.c	2008-12-19 11:17:43.000000000 +0100
@@ -41,6 +41,7 @@
  * set @var_name @i;
  * This sets 'diag_line2' to "2".
  */
+#include "config.h"
 #include <stdio.h>
 #include <math.h>
 #include <stdlib.h>
diff -ruN ug-orig/np/CVS/Entries ug-patched/np/CVS/Entries
--- ug-orig/np/CVS/Entries	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:22 2004//D2008.11.12.23.00.00
-/Makefile.am/1.2/Fri Sep  3 13:16:22 2004//D2008.11.12.23.00.00
-/Makefile.np/1.15/Wed Jul  9 15:39:33 2008//D2008.11.12.23.00.00
-/initnp.c/1.43/Wed Jul  9 15:39:33 2008//D2008.11.12.23.00.00
-/initnp.h/1.7/Mon May  8 12:28:44 2006//D2008.11.12.23.00.00
-/initnumerics.h/1.6/Mon May  8 12:28:44 2006//D2008.11.12.23.00.00
-/np.doc/1.4/Sun Apr  6 17:32:28 1997//D2008.11.12.23.00.00
-/np.h/1.73/Fri Nov 17 10:59:50 2006//D2008.11.12.23.00.00
-/num.h/1.2/Fri Jul 18 14:59:30 1997//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/CVS/Entries.Log ug-patched/np/CVS/Entries.Log
--- ug-orig/np/CVS/Entries.Log	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/CVS/Entries.Log	1970-01-01 01:00:00.000000000 +0100
@@ -1,9 +0,0 @@
-A D/algebra////
-A D/amglib////
-A D/cpldisc////
-A D/famglib////
-A D/field////
-A D/mlilu////
-A D/procs////
-A D/slu////
-A D/udm////
diff -ruN ug-orig/np/CVS/Repository ug-patched/np/CVS/Repository
--- ug-orig/np/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np
diff -ruN ug-orig/np/CVS/Root ug-patched/np/CVS/Root
--- ug-orig/np/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/CVS/Tag ug-patched/np/CVS/Tag
--- ug-orig/np/CVS/Tag	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/.cvsignore ug-patched/np/.cvsignore
--- ug-orig/np/.cvsignore	2004-09-08 16:14:22.000000000 +0200
+++ ug-patched/np/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/np/famglib/CVS/Entries ug-patched/np/famglib/CVS/Entries
--- ug-orig/np/famglib/CVS/Entries	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/famglib/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,49 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:19 2004//D2008.11.12.23.00.00
-/Makefile.famglib/1.9/Mon Oct  4 17:10:33 1999//D2008.11.12.23.00.00
-/README/1.3/Fri Sep 22 18:08:06 2000//D2008.11.12.23.00.00
-/famg.C/1.8/Fri Feb  4 10:03:38 2000//D2008.11.12.23.00.00
-/famg.in/1.2/Fri Aug 21 13:47:32 1998//D2008.11.12.23.00.00
-/famg_algebra.C/1.15/Tue Apr  4 15:44:17 2000//D2008.11.12.23.00.00
-/famg_algebra.h/1.19/Wed May 17 08:48:22 2000//D2008.11.12.23.00.00
-/famg_approx.C/1.5/Fri Aug 13 16:18:29 1999//D2008.11.12.23.00.00
-/famg_approxNew.C/1.7/Tue Oct  5 09:51:30 1999//D2008.11.12.23.00.00
-/famg_approxSparse.C/1.1/Mon Oct  4 17:10:35 1999//D2008.11.12.23.00.00
-/famg_arrayalgebra.C/1.1/Wed Sep 30 10:43:39 1998//D2008.11.12.23.00.00
-/famg_arrayalgebra.h/1.1/Wed Aug 26 19:20:40 1998//D2008.11.12.23.00.00
-/famg_coloring.C/1.17/Mon Nov 15 16:35:13 1999//D2008.11.12.23.00.00
-/famg_coloring.h/1.5/Mon Nov 15 16:01:23 1999//D2008.11.12.23.00.00
-/famg_construct.C/1.28/Fri Sep 22 17:52:41 2000//D2008.11.12.23.00.00
-/famg_decomp.C/1.1/Fri Aug 21 16:39:37 1998//D2008.11.12.23.00.00
-/famg_decomp.h/1.2/Wed Sep 30 10:43:41 1998//D2008.11.12.23.00.00
-/famg_fifo.h/1.1/Fri Aug 21 16:39:38 1998//D2008.11.12.23.00.00
-/famg_graph.C/1.9/Fri Aug 13 16:18:31 1999//D2008.11.12.23.00.00
-/famg_graph.h/1.14/Thu Feb  3 16:44:55 2000//D2008.11.12.23.00.00
-/famg_graphics.C/1.15/Thu Jul 20 12:28:18 2000//D2008.11.12.23.00.00
-/famg_grid.C/1.76/Fri Sep 22 17:55:31 2000//D2008.11.12.23.00.00
-/famg_grid.h/1.21/Thu Jun 29 16:43:43 2000//D2008.11.12.23.00.00
-/famg_heap.C/1.6/Mon Oct  4 13:30:25 1999//D2008.11.12.23.00.00
-/famg_heap.h/1.3/Mon Oct  4 13:30:26 1999//D2008.11.12.23.00.00
-/famg_interface.C/1.4/Wed Dec  8 15:16:14 1999//D2008.11.12.23.00.00
-/famg_interface.h/1.2/Wed Sep 30 10:43:46 1998//D2008.11.12.23.00.00
-/famg_matrix.C/1.2/Wed Sep 30 10:43:47 1998//D2008.11.12.23.00.00
-/famg_matrix.h/1.2/Wed Sep 30 10:43:48 1998//D2008.11.12.23.00.00
-/famg_misc.C/1.5/Wed Nov 10 12:47:50 1999//D2008.11.12.23.00.00
-/famg_misc.h/1.3/Mon Oct  4 17:10:39 1999//D2008.11.12.23.00.00
-/famg_multigrid.C/1.29/Fri Jul  7 12:50:26 2000//D2008.11.12.23.00.00
-/famg_multigrid.h/1.2/Wed Sep 30 10:43:49 1998//D2008.11.12.23.00.00
-/famg_onlyugalgebra.h/1.10/Thu Oct  7 11:06:27 1999//D2008.11.12.23.00.00
-/famg_sparse.C/1.3/Mon Oct  4 17:10:41 1999//D2008.11.12.23.00.00
-/famg_sparse.h/1.3/Mon Oct  4 17:10:42 1999//D2008.11.12.23.00.00
-/famg_system.C/1.8/Fri Aug 13 16:18:37 1999//D2008.11.12.23.00.00
-/famg_system.h/1.9/Wed Dec  8 15:16:15 1999//D2008.11.12.23.00.00
-/famg_transfer.C/1.21/Thu Jun 29 16:43:44 2000//D2008.11.12.23.00.00
-/famg_transfer.h/1.6/Fri Aug 13 19:42:32 1999//D2008.11.12.23.00.00
-/famg_traverse.template/1.1/Wed Sep 30 10:43:53 1998//D2008.11.12.23.00.00
-/famg_ugalgebra.C/1.11/Wed Apr 12 10:17:59 2000//D2008.11.12.23.00.00
-/famg_ugalgebra.h/1.17/Mon Oct  4 17:10:43 1999//D2008.11.12.23.00.00
-/famg_uginterface.C/1.19/Tue Apr  4 15:44:22 2000//D2008.11.12.23.00.00
-/famg_uginterface.h/1.10/Tue Apr  4 15:44:23 2000//D2008.11.12.23.00.00
-/makefile/1.2/Wed Sep 30 10:43:56 1998//D2008.11.12.23.00.00
-/ug-famg.C/1.39/Mon Aug 28 10:27:59 2000//D2008.11.12.23.00.00
-/ug-famg.h/1.9/Tue Apr  4 15:44:24 2000//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/famglib/CVS/Repository ug-patched/np/famglib/CVS/Repository
--- ug-orig/np/famglib/CVS/Repository	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/famglib/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/famglib
diff -ruN ug-orig/np/famglib/CVS/Root ug-patched/np/famglib/CVS/Root
--- ug-orig/np/famglib/CVS/Root	2009-04-28 16:21:28.000000000 +0200
+++ ug-patched/np/famglib/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/famglib/CVS/Tag ug-patched/np/famglib/CVS/Tag
--- ug-orig/np/famglib/CVS/Tag	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/famglib/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/famglib/.cvsignore ug-patched/np/famglib/.cvsignore
--- ug-orig/np/famglib/.cvsignore	2004-09-08 16:14:19.000000000 +0200
+++ ug-patched/np/famglib/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/np/famglib/famg_algebra.C ug-patched/np/famglib/famg_algebra.C
--- ug-orig/np/famglib/famg_algebra.C	2000-04-04 17:44:17.000000000 +0200
+++ ug-patched/np/famglib/famg_algebra.C	2008-12-19 11:17:43.000000000 +0100
@@ -18,6 +18,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 #include <assert.h>
@@ -37,7 +38,7 @@
 #include "famg_sparse.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_algebra.C,v 1.15 2000/04/04 15:44:17 christia Exp $
+$Header$
 */
 
 #ifdef __AIX__
diff -ruN ug-orig/np/famglib/famg_algebra.h ug-patched/np/famglib/famg_algebra.h
--- ug-orig/np/famglib/famg_algebra.h	2000-05-17 10:48:22.000000000 +0200
+++ ug-patched/np/famglib/famg_algebra.h	2000-05-17 10:48:22.000000000 +0200
@@ -22,7 +22,7 @@
 #define __FAMG_ALGEBRA__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_algebra.h,v 1.19 2000/05/17 08:48:22 christia Exp $
+$Header$
 */
 
 // if defined, only one type of alegra data structure is active (ug DS if USE_UG_DS is
diff -ruN ug-orig/np/famglib/famg_approx.C ug-patched/np/famglib/famg_approx.C
--- ug-orig/np/famglib/famg_approx.C	1999-08-13 18:18:29.000000000 +0200
+++ ug-patched/np/famglib/famg_approx.C	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 */
 
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <math.h>
@@ -37,7 +38,7 @@
 #include "famg_system.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_approx.C,v 1.5 1999/08/13 16:18:29 chris Exp $
+$Header$
 */
 
 #ifndef FAMG_SPARSE_BLOCK
diff -ruN ug-orig/np/famglib/famg_approxNew.C ug-patched/np/famglib/famg_approxNew.C
--- ug-orig/np/famglib/famg_approxNew.C	1999-10-05 11:51:30.000000000 +0200
+++ ug-patched/np/famglib/famg_approxNew.C	2008-12-19 11:17:43.000000000 +0100
@@ -20,6 +20,7 @@
 /****************************************************************************/
 
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <math.h>
diff -ruN ug-orig/np/famglib/famg_approxSparse.C ug-patched/np/famglib/famg_approxSparse.C
--- ug-orig/np/famglib/famg_approxSparse.C	1999-10-04 19:10:35.000000000 +0200
+++ ug-patched/np/famglib/famg_approxSparse.C	2008-12-19 11:17:43.000000000 +0100
@@ -20,6 +20,7 @@
 /****************************************************************************/
 
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <math.h>
diff -ruN ug-orig/np/famglib/famg_arrayalgebra.C ug-patched/np/famglib/famg_arrayalgebra.C
--- ug-orig/np/famglib/famg_arrayalgebra.C	1998-09-30 12:43:39.000000000 +0200
+++ ug-patched/np/famglib/famg_arrayalgebra.C	2008-12-19 11:17:43.000000000 +0100
@@ -18,12 +18,13 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 #include "famg_algebraalgebra.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_arrayalgebra.C,v 1.1 1998/09/30 10:43:39 christia Exp $
+$Header$
 */
 
 
diff -ruN ug-orig/np/famglib/famg_arrayalgebra.h ug-patched/np/famglib/famg_arrayalgebra.h
--- ug-orig/np/famglib/famg_arrayalgebra.h	1998-08-26 21:20:40.000000000 +0200
+++ ug-patched/np/famglib/famg_arrayalgebra.h	1998-08-26 21:20:40.000000000 +0200
@@ -22,7 +22,7 @@
 #define __FAMG_ARRAYALGEBRA__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_arrayalgebra.h,v 1.1 1998/08/26 19:20:40 christia Exp $
+$Header$
 */
 
 #endif
diff -ruN ug-orig/np/famglib/famg.C ug-patched/np/famglib/famg.C
--- ug-orig/np/famglib/famg.C	2000-02-04 11:03:38.000000000 +0100
+++ ug-patched/np/famglib/famg.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <strstream.h>
 #include <iostream.h>
 #include <fstream.h>
@@ -30,7 +31,7 @@
 #include "famg_system.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg.C,v 1.8 2000/02/04 10:03:38 christia Exp $
+$Header$
 */
 
 int firsti;
diff -ruN ug-orig/np/famglib/famg_coloring.C ug-patched/np/famglib/famg_coloring.C
--- ug-orig/np/famglib/famg_coloring.C	1999-11-15 17:35:13.000000000 +0100
+++ ug-patched/np/famglib/famg_coloring.C	2008-12-19 11:17:43.000000000 +0100
@@ -20,6 +20,7 @@
 
 #ifdef ModelP
 
+#include "config.h"
 #include <stdlib.h> 		// for (s)rand
 #include <string.h> 		// for memset
 #include <limits.h> 		// for INT_MAX
@@ -38,7 +39,7 @@
 #include "famg_ugalgebra.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_coloring.C,v 1.17 1999/11/15 16:35:13 christia Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/famglib/famg_coloring.h ug-patched/np/famglib/famg_coloring.h
--- ug-orig/np/famglib/famg_coloring.h	1999-11-15 17:01:23.000000000 +0100
+++ ug-patched/np/famglib/famg_coloring.h	1999-11-15 17:01:24.000000000 +0100
@@ -21,7 +21,7 @@
 #define __FAMG_COLORING__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_coloring.h,v 1.5 1999/11/15 16:01:23 christia Exp $
+$Header$
 */
 
 #ifdef ModelP
diff -ruN ug-orig/np/famglib/famg_construct.C ug-patched/np/famglib/famg_construct.C
--- ug-orig/np/famglib/famg_construct.C	2000-09-22 19:52:41.000000000 +0200
+++ ug-patched/np/famglib/famg_construct.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 
@@ -59,7 +60,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_construct.C,v 1.28 2000/09/22 17:52:41 christia Exp $
+$Header$
 */
 
 void prm(int level, int comp)
diff -ruN ug-orig/np/famglib/famg_decomp.C ug-patched/np/famglib/famg_decomp.C
--- ug-orig/np/famglib/famg_decomp.C	1998-08-21 18:39:37.000000000 +0200
+++ ug-patched/np/famglib/famg_decomp.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include "famg_decomp.h"
 #include "famg_heap.h"
@@ -26,7 +27,7 @@
 #include "famg_system.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_decomp.C,v 1.1 1998/08/21 16:39:37 christia Exp $
+$Header$
 */
 
 // Class FAMGDecompEntry
diff -ruN ug-orig/np/famglib/famg_decomp.h ug-patched/np/famglib/famg_decomp.h
--- ug-orig/np/famglib/famg_decomp.h	1998-09-30 12:43:41.000000000 +0200
+++ ug-patched/np/famglib/famg_decomp.h	1998-09-30 12:43:57.000000000 +0200
@@ -25,7 +25,7 @@
 #include "famg_algebra.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_decomp.h,v 1.2 1998/09/30 10:43:41 christia Exp $
+$Header$
 */
 
 struct FAMGDecompBitField
diff -ruN ug-orig/np/famglib/famg_fifo.h ug-patched/np/famglib/famg_fifo.h
--- ug-orig/np/famglib/famg_fifo.h	1998-08-21 18:39:38.000000000 +0200
+++ ug-patched/np/famglib/famg_fifo.h	1998-08-21 18:39:50.000000000 +0200
@@ -23,7 +23,7 @@
 #define __FAMG_FIFO__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_fifo.h,v 1.1 1998/08/21 16:39:38 christia Exp $
+$Header$
 */
 
 // integer fifo. for pointers: cast pointers to integer.
diff -ruN ug-orig/np/famglib/famg_graph.C ug-patched/np/famglib/famg_graph.C
--- ug-orig/np/famglib/famg_graph.C	1999-08-13 18:18:31.000000000 +0200
+++ ug-patched/np/famglib/famg_graph.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 
@@ -30,7 +31,7 @@
 #include "famg_fifo.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_graph.C,v 1.9 1999/08/13 16:18:31 chris Exp $
+$Header$
 */
    
     // Class List
diff -ruN ug-orig/np/famglib/famg_graph.h ug-patched/np/famglib/famg_graph.h
--- ug-orig/np/famglib/famg_graph.h	2000-02-03 17:44:55.000000000 +0100
+++ ug-patched/np/famglib/famg_graph.h	2000-02-03 17:44:55.000000000 +0100
@@ -33,7 +33,7 @@
 
 #include "famg_algebra.h"   
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_graph.h,v 1.14 2000/02/03 16:44:55 christia Exp $
+$Header$
 */
 
 const int FAMGMAXPARENTS=2;
diff -ruN ug-orig/np/famglib/famg_graphics.C ug-patched/np/famglib/famg_graphics.C
--- ug-orig/np/famglib/famg_graphics.C	2000-07-20 14:28:18.000000000 +0200
+++ ug-patched/np/famglib/famg_graphics.C	2008-12-19 11:17:43.000000000 +0100
@@ -20,6 +20,7 @@
 /****************************************************************************/
 
 
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -47,7 +48,7 @@
 #include "famg_uginterface.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_graphics.C,v 1.15 2000/07/20 12:28:18 christia Exp $
+$Header$
 */
 
 static long BlackColor; /* Black  */
diff -ruN ug-orig/np/famglib/famg_grid.C ug-patched/np/famglib/famg_grid.C
--- ug-orig/np/famglib/famg_grid.C	2000-09-22 19:55:31.000000000 +0200
+++ ug-patched/np/famglib/famg_grid.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <math.h>
@@ -82,7 +83,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_grid.C,v 1.76 2000/09/22 17:55:31 christia Exp $ 
+$Header$ 
 */
 
 #ifdef FAMG_CLEAREMPTY_PE
diff -ruN ug-orig/np/famglib/famg_grid.h ug-patched/np/famglib/famg_grid.h
--- ug-orig/np/famglib/famg_grid.h	2000-06-29 18:43:43.000000000 +0200
+++ ug-patched/np/famglib/famg_grid.h	2000-06-29 18:43:44.000000000 +0200
@@ -26,7 +26,7 @@
 #include "famg_transfer.h"    
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_grid.h,v 1.21 2000/06/29 16:43:43 christia Exp $
+$Header$
 */
 
 //additional measurement and output
diff -ruN ug-orig/np/famglib/famg_heap.C ug-patched/np/famglib/famg_heap.C
--- ug-orig/np/famglib/famg_heap.C	1999-10-04 15:30:25.000000000 +0200
+++ ug-patched/np/famglib/famg_heap.C	2008-12-19 11:17:43.000000000 +0100
@@ -17,6 +17,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <math.h>
@@ -33,7 +34,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_heap.C,v 1.6 1999/10/04 13:30:25 christia Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/famglib/famg_heap.h ug-patched/np/famglib/famg_heap.h
--- ug-orig/np/famglib/famg_heap.h	1999-10-04 15:30:26.000000000 +0200
+++ ug-patched/np/famglib/famg_heap.h	1999-10-04 15:30:26.000000000 +0200
@@ -23,7 +23,7 @@
 #define __FAMG_HEAP__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_heap.h,v 1.3 1999/10/04 13:30:26 christia Exp $
+$Header$
 */
 
 #define FAMGMAXSTACK 8
diff -ruN ug-orig/np/famglib/famg_interface.C ug-patched/np/famglib/famg_interface.C
--- ug-orig/np/famglib/famg_interface.C	1999-12-08 16:16:14.000000000 +0100
+++ ug-patched/np/famglib/famg_interface.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,12 +19,13 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "famg_system.h"
 #include "famg_heap.h"
 #include "famg_interface.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_interface.C,v 1.4 1999/12/08 15:16:14 christia Exp $
+$Header$
 */
 
 static FAMGSystem *famgsystemptr;
diff -ruN ug-orig/np/famglib/famg_interface.h ug-patched/np/famglib/famg_interface.h
--- ug-orig/np/famglib/famg_interface.h	1998-09-30 12:43:46.000000000 +0200
+++ ug-patched/np/famglib/famg_interface.h	1998-09-30 12:43:57.000000000 +0200
@@ -23,7 +23,7 @@
 #define FAMG_INTERFACE
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_interface.h,v 1.2 1998/09/30 10:43:46 christia Exp $
+$Header$
 */
 
 	// exported functions
diff -ruN ug-orig/np/famglib/famg_matrix.C ug-patched/np/famglib/famg_matrix.C
--- ug-orig/np/famglib/famg_matrix.C	1998-09-30 12:43:47.000000000 +0200
+++ ug-patched/np/famglib/famg_matrix.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 #include "famg_misc.h"
@@ -27,7 +28,7 @@
 #include "famg_grid.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_matrix.C,v 1.2 1998/09/30 10:43:47 christia Exp $
+$Header$
 */
 
 static double famgzero = 0.0;
diff -ruN ug-orig/np/famglib/famg_matrix.h ug-patched/np/famglib/famg_matrix.h
--- ug-orig/np/famglib/famg_matrix.h	1998-09-30 12:43:48.000000000 +0200
+++ ug-patched/np/famglib/famg_matrix.h	1998-09-30 12:43:57.000000000 +0200
@@ -27,7 +27,7 @@
 #include "famg_graph.h"    
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_matrix.h,v 1.2 1998/09/30 10:43:48 christia Exp $
+$Header$
 */
 
     // for other data structures, FAMGMatrixPtr may contain only
diff -ruN ug-orig/np/famglib/famg_misc.C ug-patched/np/famglib/famg_misc.C
--- ug-orig/np/famglib/famg_misc.C	1999-11-10 13:47:50.000000000 +0100
+++ ug-patched/np/famglib/famg_misc.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <math.h>
 #include "famg_misc.h"
 
@@ -38,7 +39,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_misc.C,v 1.5 1999/11/10 12:47:50 christia Exp $
+$Header$
 */
 
 void FAMGError(ostrstream &OutputString)
diff -ruN ug-orig/np/famglib/famg_misc.h ug-patched/np/famglib/famg_misc.h
--- ug-orig/np/famglib/famg_misc.h	1999-10-04 19:10:39.000000000 +0200
+++ ug-patched/np/famglib/famg_misc.h	1999-10-04 19:10:44.000000000 +0200
@@ -26,7 +26,7 @@
 #include <strstream.h>
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_misc.h,v 1.3 1999/10/04 17:10:39 chris Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/famglib/famg_multigrid.C ug-patched/np/famglib/famg_multigrid.C
--- ug-orig/np/famglib/famg_multigrid.C	2000-07-07 14:50:26.000000000 +0200
+++ ug-patched/np/famglib/famg_multigrid.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <math.h>
 
@@ -32,7 +33,7 @@
 #include "famg_sparse.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_multigrid.C,v 1.29 2000/07/07 12:50:26 christia Exp $
+$Header$
 */
 
 // data structure local to this file
diff -ruN ug-orig/np/famglib/famg_multigrid.h ug-patched/np/famglib/famg_multigrid.h
--- ug-orig/np/famglib/famg_multigrid.h	1998-09-30 12:43:49.000000000 +0200
+++ ug-patched/np/famglib/famg_multigrid.h	1998-09-30 12:43:57.000000000 +0200
@@ -25,7 +25,7 @@
 #include "famg_grid.h"  
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_multigrid.h,v 1.2 1998/09/30 10:43:49 christia Exp $
+$Header$
 */
 
 const int FAMGMAXGRIDS=32;  
diff -ruN ug-orig/np/famglib/famg_onlyugalgebra.h ug-patched/np/famglib/famg_onlyugalgebra.h
--- ug-orig/np/famglib/famg_onlyugalgebra.h	1999-10-07 13:06:27.000000000 +0200
+++ ug-patched/np/famglib/famg_onlyugalgebra.h	1999-10-07 13:06:27.000000000 +0200
@@ -23,7 +23,7 @@
 #define __FAMG_ONLYUGALGEBRA__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_onlyugalgebra.h,v 1.10 1999/10/07 11:06:27 christia Exp $
+$Header$
 */
 
 extern "C"
diff -ruN ug-orig/np/famglib/famg_sparse.C ug-patched/np/famglib/famg_sparse.C
--- ug-orig/np/famglib/famg_sparse.C	1999-10-04 19:10:41.000000000 +0200
+++ ug-patched/np/famglib/famg_sparse.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
  
+#include "config.h"
 #include <string.h>
 #include <strstream.h>
 #include "famg_sparse.h"
diff -ruN ug-orig/np/famglib/famg_system.C ug-patched/np/famglib/famg_system.C
--- ug-orig/np/famglib/famg_system.C	1999-08-13 18:18:37.000000000 +0200
+++ ug-patched/np/famglib/famg_system.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 #include <strstream.h>
 #include <fstream.h>
@@ -38,7 +39,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_system.C,v 1.8 1999/08/13 16:18:37 chris Exp $
+$Header$
 */
 
 // Class  Parameter
diff -ruN ug-orig/np/famglib/famg_system.h ug-patched/np/famglib/famg_system.h
--- ug-orig/np/famglib/famg_system.h	1999-12-08 16:16:15.000000000 +0100
+++ ug-patched/np/famglib/famg_system.h	1999-12-08 16:16:19.000000000 +0100
@@ -35,7 +35,7 @@
 #include "famg_sparse.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_system.h,v 1.9 1999/12/08 15:16:15 christia Exp $
+$Header$
 */
 
 const int FAMGMULTIGRIDS=1;
diff -ruN ug-orig/np/famglib/famg_transfer.C ug-patched/np/famglib/famg_transfer.C
--- ug-orig/np/famglib/famg_transfer.C	2000-06-29 18:43:44.000000000 +0200
+++ ug-patched/np/famglib/famg_transfer.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include "famg_transfer.h"
 #include "famg_heap.h"
 #include "famg_misc.h"
@@ -39,7 +40,7 @@
 #endif
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_transfer.C,v 1.21 2000/06/29 16:43:44 christia Exp $
+$Header$
 */
 
 //
diff -ruN ug-orig/np/famglib/famg_transfer.h ug-patched/np/famglib/famg_transfer.h
--- ug-orig/np/famglib/famg_transfer.h	1999-08-13 21:42:32.000000000 +0200
+++ ug-patched/np/famglib/famg_transfer.h	1999-08-13 21:42:32.000000000 +0200
@@ -40,7 +40,7 @@
 class FAMGGrid;
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_transfer.h,v 1.6 1999/08/13 19:42:32 chris Exp $
+$Header$
 */
 
 // Class FAMGTransferEntry
diff -ruN ug-orig/np/famglib/famg_traverse.template ug-patched/np/famglib/famg_traverse.template
--- ug-orig/np/famglib/famg_traverse.template	1998-09-30 12:43:53.000000000 +0200
+++ ug-patched/np/famglib/famg_traverse.template	1998-09-30 12:43:57.000000000 +0200
@@ -22,7 +22,7 @@
 #include "famg_algebra.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_traverse.template,v 1.1 1998/09/30 10:43:53 christia Exp $
+$Header$
 */
 
 // respected preprocessor variables:
diff -ruN ug-orig/np/famglib/famg_ugalgebra.C ug-patched/np/famglib/famg_ugalgebra.C
--- ug-orig/np/famglib/famg_ugalgebra.C	2000-04-12 12:17:59.000000000 +0200
+++ ug-patched/np/famglib/famg_ugalgebra.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /****************************************************************************/
 
 extern "C" {
+#include "config.h"
 #include <math.h>
 #include <gm.h>
 #include <algebra.h>
@@ -30,7 +31,7 @@
 #include "famg_sparse.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_ugalgebra.C,v 1.11 2000/04/12 10:17:59 christia Exp $
+$Header$
 */
  
 
diff -ruN ug-orig/np/famglib/famg_ugalgebra.h ug-patched/np/famglib/famg_ugalgebra.h
--- ug-orig/np/famglib/famg_ugalgebra.h	1999-10-04 19:10:43.000000000 +0200
+++ ug-patched/np/famglib/famg_ugalgebra.h	1999-10-04 19:10:44.000000000 +0200
@@ -35,7 +35,7 @@
 #include "famg_algebra.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_ugalgebra.h,v 1.17 1999/10/04 17:10:43 chris Exp $
+$Header$
 */
 
 //
diff -ruN ug-orig/np/famglib/famg_uginterface.C ug-patched/np/famglib/famg_uginterface.C
--- ug-orig/np/famglib/famg_uginterface.C	2000-04-04 17:44:22.000000000 +0200
+++ ug-patched/np/famglib/famg_uginterface.C	2008-12-19 11:17:43.000000000 +0100
@@ -19,6 +19,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <iostream.h>
 
 #include "famg_uginterface.h"
@@ -28,7 +29,7 @@
 #include "famg_sparse.h"
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_uginterface.C,v 1.19 2000/04/04 15:44:22 christia Exp $
+$Header$
 */
 
     // actually these should be a system member functions. Maybe it is more
diff -ruN ug-orig/np/famglib/famg_uginterface.h ug-patched/np/famglib/famg_uginterface.h
--- ug-orig/np/famglib/famg_uginterface.h	2000-04-04 17:44:23.000000000 +0200
+++ ug-patched/np/famglib/famg_uginterface.h	2000-04-04 17:44:27.000000000 +0200
@@ -23,7 +23,7 @@
 #define __FAMG_UGINTERFACE__
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/famg_uginterface.h,v 1.10 2000/04/04 15:44:23 christia Exp $
+$Header$
 */
 
 //#include "gm.h"        /* for ug data structure               */
diff -ruN ug-orig/np/famglib/ug-famg.C ug-patched/np/famglib/ug-famg.C
--- ug-orig/np/famglib/ug-famg.C	2000-08-28 12:27:59.000000000 +0200
+++ ug-patched/np/famglib/ug-famg.C	2008-12-19 11:17:43.000000000 +0100
@@ -27,6 +27,7 @@
 /*                                                                          */
 /****************************************************************************/
 
+#include "config.h"
 #include <strstream.h>
 
 extern "C"
@@ -108,7 +109,7 @@
 static struct FAMGParameter_ug famg_parameter;
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/ug-famg.C,v 1.39 2000/08/28 10:27:59 christia Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/famglib/ug-famg.h ug-patched/np/famglib/ug-famg.h
--- ug-orig/np/famglib/ug-famg.h	2000-04-04 17:44:24.000000000 +0200
+++ ug-patched/np/famglib/ug-famg.h	2000-04-04 17:44:27.000000000 +0200
@@ -24,7 +24,7 @@
 #include "amgtransfer.h"    
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/famglib/ug-famg.h,v 1.9 2000/04/04 15:44:24 christia Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/field/CVS/Entries ug-patched/np/field/CVS/Entries
--- ug-orig/np/field/CVS/Entries	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/field/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/.cvsignore/1.1/Wed Sep  8 14:14:20 2004//D2008.11.12.23.00.00
-/Makefile.am/1.1/Thu Sep  2 12:22:14 2004//D2008.11.12.23.00.00
-/Makefile.field/1.2/Wed Jul  3 10:10:08 2002//D2008.11.12.23.00.00
-/field.h/1.9/Mon May  8 12:26:01 2006//D2008.11.12.23.00.00
-/stoch.c/1.18/Wed Jul 21 09:18:58 2004//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/field/CVS/Repository ug-patched/np/field/CVS/Repository
--- ug-orig/np/field/CVS/Repository	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/field/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/field
diff -ruN ug-orig/np/field/CVS/Root ug-patched/np/field/CVS/Root
--- ug-orig/np/field/CVS/Root	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/field/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/field/CVS/Tag ug-patched/np/field/CVS/Tag
--- ug-orig/np/field/CVS/Tag	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/field/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/field/.cvsignore ug-patched/np/field/.cvsignore
--- ug-orig/np/field/.cvsignore	2004-09-08 16:14:20.000000000 +0200
+++ ug-patched/np/field/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-semantic.cache
-
diff -ruN ug-orig/np/field/field.h ug-patched/np/field/field.h
--- ug-orig/np/field/field.h	2006-05-08 14:26:01.000000000 +0200
+++ ug-patched/np/field/field.h	2006-05-08 14:31:31.000000000 +0200
@@ -18,7 +18,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/field/field.h,v 1.9 2006/05/08 12:26:01 sander Exp $
+$Header$
 */
 
 /****************************************************************************/
diff -ruN ug-orig/np/field/Makefile.am ug-patched/np/field/Makefile.am
--- ug-orig/np/field/Makefile.am	2004-09-02 14:22:14.000000000 +0200
+++ ug-patched/np/field/Makefile.am	2004-09-02 14:22:17.000000000 +0200
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.1 2004/09/02 12:22:14 thimo Exp $
+# $Id: Makefile.am 7772 2004-09-02 12:22:17Z thimo $
 
 SOURCES = stoch.c field.h
 
diff -ruN ug-orig/np/field/stoch.c ug-patched/np/field/stoch.c
--- ug-orig/np/field/stoch.c	2004-07-21 11:18:58.000000000 +0200
+++ ug-patched/np/field/stoch.c	2008-12-19 11:17:43.000000000 +0100
@@ -25,6 +25,7 @@
 /*																		*/
 /************************************************************************/
 
+#include "config.h"
 #include <ctype.h>
 #include <string.h>
 #include <stdio.h>
@@ -107,7 +108,7 @@
 static DOUBLE *H;
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/field/stoch.c,v 1.18 2004/07/21 09:18:58 sander Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /************************************************************************/
 /*																		*/
diff -ruN ug-orig/np/initnp.c ug-patched/np/initnp.c
--- ug-orig/np/initnp.c	2008-07-09 17:39:33.000000000 +0200
+++ ug-patched/np/initnp.c	2008-12-19 11:17:43.000000000 +0100
@@ -26,6 +26,7 @@
 /*																			*/
 /****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 
 #include "np.h"
@@ -63,8 +64,6 @@
 #include "initnp.h"
 #include "numproc.h"
 #include "amglib/amg_ug.h"
-#include "slu/slu.h"
-#include "mlilu/mlilulib.h"
 
 #ifdef USE_FAMG
 #include "ug-famg.h"
@@ -79,7 +78,7 @@
 /****************************************************************************/
 
 /* RCS string */
-static char RCS_ID("$Header: /home/cvsroot/UG/ug/np/initnp.c,v 1.43 2008/07/09 15:39:33 lampe Exp $",UG_RCS_STRING);
+static char RCS_ID("$Header$",UG_RCS_STRING);
 
 /****************************************************************************/
 /*D
@@ -235,14 +234,6 @@
 	}
 #endif
 
-#ifdef _MLILU
-	/* init mlilu solver */
-	if ((err=Init_MLILU())!=0) {
-		SetHiWrd(err,__LINE__);
-		return (err);
-	}
-#endif
-
 	/* init order numproc */
 	if ((err=InitOrder())!=0) {
 		SetHiWrd(err,__LINE__);
@@ -266,12 +257,6 @@
         SetHiWrd(err,__LINE__);
         return (err);
     }
-
-    /* init slu */
-    if ((err=InitSLU())!=0) {
-        SetHiWrd(err,__LINE__);
-        return (err);
-    }
 
     /* init els */
     if ((err=InitELinearSolver())!=0) {
diff -ruN ug-orig/np/initnp.h ug-patched/np/initnp.h
--- ug-orig/np/initnp.h	2006-05-08 14:28:44.000000000 +0200
+++ ug-patched/np/initnp.h	2006-05-08 14:31:31.000000000 +0200
@@ -27,7 +27,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/initnp.h,v 1.7 2006/05/08 12:28:44 sander Exp $
+$Header$
 */
 #ifndef __INITNP__
 #define __INITNP__
diff -ruN ug-orig/np/initnumerics.h ug-patched/np/initnumerics.h
--- ug-orig/np/initnumerics.h	2006-05-08 14:28:44.000000000 +0200
+++ ug-patched/np/initnumerics.h	2006-05-08 14:31:31.000000000 +0200
@@ -20,7 +20,7 @@
 
 
 /* RCS_ID
-$Header: /home/cvsroot/UG/ug/np/initnumerics.h,v 1.6 2006/05/08 12:28:44 sander Exp $
+$Header$
 */
 
 #ifndef __INITNUMERICS__
diff -ruN ug-orig/np/Makefile.am ug-patched/np/Makefile.am
--- ug-orig/np/Makefile.am	2004-09-03 15:16:22.000000000 +0200
+++ ug-patched/np/Makefile.am	2010-07-04 20:35:59.000000000 +0200
@@ -1,10 +1,11 @@
-# $Id: Makefile.am,v 1.2 2004/09/03 13:16:22 thimo Exp $
+# $Id: Makefile.am 8374 2010-07-04 18:35:59Z christi $
 
-SUBDIRS = algebra amglib field procs udm slu
+SUBDIRS = algebra amglib field procs udm
 
 # famglib ist auch im alten Makefile nicht drin
 
-include_HEADERS = np.h
+npincludedir = $(pkgincludedir)
+npinclude_HEADERS = np.h
 
 SOURCES = initnp.c initnp.h initnumerics.h np.h num.h
 
@@ -28,7 +29,6 @@
                    amglib/libamg2.la \
                    field/libfield2.la \
                    procs/libprocs2.la \
-                   slu/libslu2.la \
                    udm/libudm2.la
 
 libnp3_la_SOURCES = $(SOURCES)
@@ -37,6 +37,5 @@
                    amglib/libamg3.la \
                    field/libfield3.la \
                    procs/libprocs3.la \
-                   slu/libslu3.la \
                    udm/libudm3.la
 
diff -ruN ug-orig/np/Makefile.np ug-patched/np/Makefile.np
--- ug-orig/np/Makefile.np	2008-07-09 17:39:33.000000000 +0200
+++ ug-patched/np/Makefile.np	2007-09-17 16:29:22.000000000 +0200
@@ -10,8 +10,7 @@
 include $(UGROOT)/ug.conf
 
 # the following list may be extended
-MODULES = PROCStarget ALGEBRAtarget UDMtarget FIELDtarget AMGLIBtarget SLUtarget \
-	$(MLILU_TARGET)
+MODULES = PROCStarget ALGEBRAtarget UDMtarget FIELDtarget AMGLIBtarget SLUtarget
 
 # object files for both dimensions
 OBJECTS = initnp.o
@@ -46,14 +45,6 @@
 AMGLIBtarget:
 	cd amglib && make -f Makefile.amglib
 
-SLUtarget:
-	cd slu && make -f Makefile.slu
-
-MLILU_ON:
-	cd mlilu && make -f Makefile.mlilu
-
-MLILU_OFF:
-
 .SUFFIXES: .o .c
 
 .c.o:
@@ -66,8 +57,6 @@
 	cd udm && make -f Makefile.udm clean
 	cd field && make -f Makefile.field clean
 	cd amglib && make -f Makefile.amglib clean
-	cd slu && make -f Makefile.slu clean
-	cd mlilu && make -f Makefile.mlilu clean
 
 extract:
 	$(ARCH_AR) $(ARCH_EXFLAGS) $(UGROOT)/lib/libug$(UG_LIBSUFFIX).a $(OBJECTS)
@@ -76,7 +65,5 @@
 	cd udm && make -f Makefile.udm extract
 	cd field && make -f Makefile.field extract
 	cd amglib && make -f Makefile.amglib extract
-	cd slu && make -f Makefile.slu extract
-	cd mlilu && make -f Makefile.mlilu extract
 
 xmc: extract all clean
diff -ruN ug-orig/np/mlilu/CVS/Entries ug-patched/np/mlilu/CVS/Entries
--- ug-orig/np/mlilu/CVS/Entries	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/mlilu/CVS/Entries	1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-/Makefile.mlilu/1.2/Wed Jul  9 15:39:33 2008//D2008.11.12.23.00.00
-/README/1.2/Wed Jul  9 15:39:33 2008//D2008.11.12.23.00.00
-/UGTools.hh/1.1/Wed Jul  9 15:29:52 2008//D2008.11.12.23.00.00
-/mlilulib.cc/1.10/Wed Jul  9 16:43:34 2008//D2008.11.12.23.00.00
-/mlilulib.h/1.2/Sat Jun  7 12:52:01 2008//D2008.11.12.23.00.00
-D
diff -ruN ug-orig/np/mlilu/CVS/Repository ug-patched/np/mlilu/CVS/Repository
--- ug-orig/np/mlilu/CVS/Repository	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/mlilu/CVS/Repository	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-UG/ug/np/mlilu
diff -ruN ug-orig/np/mlilu/CVS/Root ug-patched/np/mlilu/CVS/Root
--- ug-orig/np/mlilu/CVS/Root	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/mlilu/CVS/Root	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-:ext:lampe@speedo:/home/cvsroot
diff -ruN ug-orig/np/mlilu/CVS/Tag ug-patched/np/mlilu/CVS/Tag
--- ug-orig/np/mlilu/CVS/Tag	2009-04-28 16:21:29.000000000 +0200
+++ ug-patched/np/mlilu/CVS/Tag	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-D2008.11.12.23.00.00
diff -ruN ug-orig/np/mlilu/Makefile.mlilu ug-patched/np/mlilu/Makefile.mlilu
--- ug-orig/np/mlilu/Makefile.mlilu	2008-07-09 17:39:33.000000000 +0200
+++ ug-patched/np/mlilu/Makefile.mlilu	1970-01-01 01:00:00.000000000 +0100
@@ -1,46 +0,0 @@
-##############################################################################
-#																			 #
-#	Makefile for all modules of ug version 3								 #
-#																			 #
-#	created 20 April 2007   												 #
-#																			 #
-##############################################################################
-
-########################################################################
-# Compiling and linking options
-########################################################################
-
-# include configuration and all makefile macro definitions
-include $(UGROOT)/ug.conf
-
-# the following list may be extended
-
-OBJECTS = mlilulib.o solver.o
-
-$(UG_LIB) : $(OBJECTS) Makefile.mlilu FORCE
-	$(ARCH_AR)  $(ARCH_ARFLAGS) $(UG_LIB) $(OBJECTS)
-
-# to assure that OBJECTS are archived
-FORCE:
-
-ar :
-	$(ARCH_AR)  $(ARCH_ARFLAGS) $(UG_LIB) $(OBJECTS)
-
-.SUFFIXES: .o .c .cc .f
-
-.c.o:
-	$(ARCH_CC) $(UG_CFLAGS) $(FAMGOPTIONS) $<
-
-.cc.o:
-	$(ARCH_C++) $(UG_CFLAGS) $(FAMGOPTIONS) $<
-
-.f.o:
-	$(ARCH_F77) -O3 -c $<
-
-clean:
-	rm -f *.o
-
-extract:
-	$(ARCH_AR) $(ARCH_EXFLAGS) $(UGROOT)/lib/libug$(UG_LIBSUFFIX).a $(OBJECTS)
-
-xmc: extract $(UG_LIB) clean
diff -ruN ug-orig/np/mlilu/mlilulib.cc ug-patched/np/mlilu/mlilulib.cc
--- ug-orig/np/mlilu/mlilulib.cc	2008-07-09 18:43:34.000000000 +0200
+++ ug-patched/np/mlilu/mlilulib.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,716 +0,0 @@
-//
-// mlilulib.cc
-// 
-// UG driver for Multilevel-ILU
-// Arne Naegel, Jun 08
-//
-
-#undef MLILU_DEBUG
-#define MLILU_TIMING
-
-const short MLILU_MaxHist = 22;
-
-// ug library
-extern "C"
-{
-#include "config.h"
-
-#include "gm.h"
-#include "udm.h"
-#include "numproc.h"
-#include "iter.h"
-#include "ugdevices.h" // UserWriteF 
-#include "scan.h"      // ReadArgvXXX
-}
-
-
-#ifdef MLILU_DEBUG
-#include <iostream>
-#endif
-
-#include "UGTools.hh"         // C++ access to UG data
-#include "mlilulib.h"         // my header
-
-#include "namespace.h"
-USING_UG_NAMESPACES
-/****************************************************************************/
-/*																			*/
-/* definition of variables global to this source file only (static!)		*/
-/*																			*/
-/****************************************************************************/
-
-REP_ERR_FILE;
-
-
-/****************************************************************************/
-/*																			*/
-/* forward declarations of functions used before they are defined			*/
-/*																			*/
-/****************************************************************************/
-// Declare calls to R. Bank's Fortran routines
-extern "C" void F77SYM(mginit,MGINIT)(int *n, int *ispd, int *maxja, int *ja,
-									  int *maxa, double*a, int *ncfact,
-									  int* maxlvl, int* stat, double *dtol,
-									  int *lenz, double *z, int *iflag);
-
-extern "C" void F77SYM(mg,MG)(int *ispd, int *maxcg , double *eps, int *ja,
-							  double* a, double *sol, double *rhs, int *stat,
-							  double *relerror, int *iflag, double *z,
-							  double *history);
-
-
-/****************************************************************************/
-/*																			*/
-/* interface																*/
-/*																			*/
-/****************************************************************************/
-
-//! Call Fortran init
-static int SolverInit(MLILU_Parameters &p, MLILU_MatVecData &d, MLILU_SolverStat &res)
-{
-  int iflag;
-  int lena = d.nvec + 1 + 2*d.noffd;
-  int lenz = d.maxz;
-
-#ifdef MLILU_TIMING
-  double time =CURRENT_TIME_LONG;
-#endif
-  
-  F77SYM(mginit,MGINIT)(&d.nvec, &p.ispd, &d.maxja, d.index, &d.maxa, d.value,
-						&p.ncfact,  &p.maxlvl, res.stat, &p.dtol,&d.maxz,
-						d.workspace, &res.iflag);
-  
-
-  if(res.iflag) UserWriteF("Error SolverInit: %d\n", res.iflag);
-#ifdef MLILU_TIMING
-  time=CURRENT_TIME_LONG-time;
-  UserWriteF("Timing (init): %f s\n",time);
-#endif
-
-  return res.iflag;
-}
-
-//! Call Fortran exec
-static int SolverExec(MLILU_Parameters &p,  MLILU_SolverParams &sp, MLILU_MatVecData &data, MLILU_SolverStat &res)
-{
-#ifdef MLILU_TIMING
-  double time =CURRENT_TIME_LONG;
-#endif
-  F77SYM(mg,MG)(&p.ispd, &sp.maxsweeps, &sp.eps, data.index, data.value, data.sol, data.rhs,
-				res.stat, &res.relerror, &res.iflag, data.workspace, res.history);
-
-#ifdef MLILU_TIMING
-  time=CURRENT_TIME_LONG-time;
-  UserWriteF("Timing (solver): %f s\n",time);
-#endif
-  
-  return res.iflag;
-};
-
-
-
-static INT ReadSetupParameters(INT argc, char **argv, MLILU_Parameters& p)
-{
-  INT n;
-
-  if (ReadArgvOption ("spd",argc,a
