#!/bin/sh 
## ==========================================================================
##
##      FFFFF  RRRR   EEEEE  EEEEE  FFFFF   OOOO   RRRR   M    M 
##      F      R   R  E      E      F      O    O  R   R  MM  MM 
##      FFF    RRRR   EEE    EEE    FFF    O    O  RRRR   M MM M 
##      F      R  R   E      E      F      O    O  R  R   M    M 
##      F      R   R  E      E      F      O    O  R   R  M    M 
##      F      R   R  EEEEE  EEEEE  F       OOOO   R   R  M    M 
##
##
##           SSSSS  PPPPP   L      III  N    N  EEEEE   SSSSS    
##          S       P    P  L       I   NN   N  E      S
##           SSSS   PPPP    L       I   N N  N  EEE     SSSS
##               S  P       L       I   N  N N  E           S
##               S  P       L       I   N   NN  E           S
##          SSSSS   P       LLLLL  III  N    N  EEEEE  SSSSS 
##
## ==========================================================================
##  
##   Project:     "Freeform splines software package" of 
##
##                     University of Karlsruhe (TH)
##                     Institute for Operating and Dialog Systems
##                     Research Group on Computer Aided Geometric Design
##                     Head of research group: Prof. Dr. H. Prautzsch
##                     WWW: http://i33www.ira.uka.de
##
##
##   Program name: off2bez
##
##   Version:      1.1
##
##   Author:       Thomas Mueller, Stephan Bischoff
##  
##   Date:         July, 1997
##
##   Changes:      September, 1999
##                 Can now handle G^2-fillings with method 3:
##                 The .bez-file is subdivided and converted
##                 to a .list-file which contains the Bezier-net
##                 of the subdivided patches.
##
##   Usage:        off2bez OFF-FILE METHOD
##
##   Description:  Unites the functionality of the programs 'off2invec', 
##                 'fill_hole' and 'outvec2bez': Reads the control net of 
##                 the rim surface given in the Geomview .off-file OFF-FILE, 
##                 fills the corresponding n-sided hole depending on the 
##                 chosen METHOD and feeds the resulting surface patches 
##                 to GeomviewE.
##                
##                 For details refer to the documentation provided in 
##                        user_manual.ps.
##
##   Examples:     An example is described in the user manual.
##
##                 Or take a look at our research-page:
##                        http://i33www.ira.uka.de
##
##   Contact:      Please let use hear from you in case you have any 
##                 suggestions or problems with our software:
##                        prau@ira.uka.de
##                        umlauf@ira.uka.de
##
##

TMP_DIR=tmp

if [ $# = 2 ] 
then
   off2invec $1 $TMP_DIR/invec.vec
   fill_hole $TMP_DIR/invec.vec $TMP_DIR/outvec.vec $2
   outvec2bez $TMP_DIR/outvec.vec $TMP_DIR/filled_hole.bez
   if (grep -c BEZDD3 $TMP_DIR/filled_hole.bez > /dev/null)
   then
     echo 'Subdividing...'
     subdivide $TMP_DIR/filled_hole.bez $TMP_DIR/filled_hole1.bez
     echo 'Extracting the Bezier-net...'
     bez2list $TMP_DIR/filled_hole1.bez $TMP_DIR/filled_hole1.list
     echo 'Visualizing...'
     geomview -b 1 1 1 $TMP_DIR/filled_hole1.list
   else
     echo 'Visualizing...'
     geomview -b 1 1 1 $TMP_DIR/filled_hole.bez
   fi
else
   echo
   echo 'Usage:  off2bez OFF-FILE METHOD'
   echo ''
   echo 'Reads control net corresponding to a surface ring with an n-sided'
   echo 'hole from Geomview off-file OFF-FILE and fills the hole with method'
   echo 'METHOD (0 or 1 or 2 or 3). The resulting surface is displayed by'
   echo 'Geomview. This surface is'
   echo '    G^1-continuous if the given control net has an n-sided face and' 
   echo '    G^2-continuous if there is an extraordinary point.' 
   echo ''
   echo 'For details refer to the documentation in user_manual.ps.'
   echo ''
fi

