From 71c51542ecf6ecc72d4447a14bbd7c698a20a96f Mon Sep 17 00:00:00 2001 From: wieners <wieners> Date: Sat, 23 Nov 1996 21:28:36 +0000 Subject: [PATCH] plotproc wieder eingefuert mit der $s Option kann nun ein SymbolName an die preprocess Funktion uebergeben werden Bitte fuegt hier Plot Funktionen hinzu, die nur die Standard shapefunctions aus shape.c verwenden. [[Imported from SVN: r1243]] --- graphics/uggraph/Makefile.uggraph | 4 +- graphics/uggraph/initgraph.c | 16 +- graphics/uggraph/plotproc.c | 234 ++++++++++++++++++++++++++++++ graphics/uggraph/plotproc.h | 65 +++++++++ graphics/uggraph/wpm.c | 12 +- 5 files changed, 320 insertions(+), 11 deletions(-) create mode 100644 graphics/uggraph/plotproc.c create mode 100644 graphics/uggraph/plotproc.h diff --git a/graphics/uggraph/Makefile.uggraph b/graphics/uggraph/Makefile.uggraph index 3a5b3fd2a..f3aa2f24e 100644 --- a/graphics/uggraph/Makefile.uggraph +++ b/graphics/uggraph/Makefile.uggraph @@ -6,12 +6,10 @@ # # ############################################################################## - - # include configuration and all makefile macro definitions include ../../ug.conf -OBJECTS = wpm.o graph.o wop.o initgraph.o +OBJECTS = wpm.o graph.o wop.o initgraph.o plotproc.o # local C compiler flags LCFLAGS = -I../../include diff --git a/graphics/uggraph/initgraph.c b/graphics/uggraph/initgraph.c index 5c3fe8edd..4544b1085 100644 --- a/graphics/uggraph/initgraph.c +++ b/graphics/uggraph/initgraph.c @@ -11,7 +11,7 @@ /* Universitaet Stuttgart */ /* Pfaffenwaldring 27 */ /* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ +/* email: ug@ica3.uni-stuttgart.de */ /* */ /* History: 27.02.95 begin, ug version 3.0 */ /* */ @@ -39,6 +39,7 @@ /* graph module */ #include "wpm.h" #include "wop.h" +#include "plotproc.h" /* own header */ #include "initgraph.h" @@ -53,7 +54,7 @@ RCSID("$Header$",UG_RCS_STRING) /****************************************************************************/ -/*D +/* InitGraph - Call the inits for the graph module SYNOPSIS: @@ -68,8 +69,8 @@ RCSID("$Header$",UG_RCS_STRING) RETURN VALUE: INT .n 0 if ok - .n 1 if some error occured. - D*/ + .n __LINE__ if some error occured. + */ /****************************************************************************/ INT InitGraph () @@ -90,5 +91,12 @@ INT InitGraph () return (err); } + /* init plotproc.c */ + if ((err=InitPlotProc())!=0) + { + SetHiWrd(err,__LINE__); + return (err); + } + return (0); } diff --git a/graphics/uggraph/plotproc.c b/graphics/uggraph/plotproc.c new file mode 100644 index 000000000..26a873c86 --- /dev/null +++ b/graphics/uggraph/plotproc.c @@ -0,0 +1,234 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +/****************************************************************************/ +/* */ +/* File: plotproc.c */ +/* */ +/* Purpose: generic plot functions for node vectors */ +/* */ +/* */ +/* Author: Christian Wieners */ +/* Institut fuer Computeranwendungen III */ +/* Universitaet Stuttgart */ +/* Pfaffenwaldring 27 */ +/* 70569 Stuttgart */ +/* email: ug@ica3.uni-stuttgart.de */ +/* */ +/* History: November 23, 1996 */ +/* */ +/* Remarks: */ +/* */ +/****************************************************************************/ + +/****************************************************************************/ +/* */ +/* include files */ +/* system include files */ +/* application include files */ +/* */ +/****************************************************************************/ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include "general.h" + +#include "gm.h" +#include "ugenv.h" +#include "evm.h" +#include "devices.h" +#include "shapes.h" +#include "num.h" + +/****************************************************************************/ +/* */ +/* 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!) */ +/* */ +/****************************************************************************/ + +static INT nodecomp; + +/* RCS string */ +RCSID("$Header$",UG_RCS_STRING) + +/****************************************************************************/ +/* */ +/* forward declarations of functions used before they are defined */ +/* */ +/****************************************************************************/ + + +/**************************************************************************/ +/* + NodeValue - generic plot funtion + + SYNOPSIS: + static DOUBLE NodeValue (const ELEMENT *theElement, + const COORD **CornersCoord, COORD *LocalCoord); + + PARAMETERS: + . theElement - pointer to an element + . CornersCoord - corner coordinates + . LocalCoord - local coordinate + + DESCRIPTION: + This function plots the values of a node vector, interpolated by the + standard shape functions. + + RETURN VALUE: + DOUBLE value + */ +/*************************************************************************/ + +static INT PreprocessNodeValue (const char *name, MULTIGRID *theMG) +{ + VECDATA_DESC *theVD; + + theVD = GetVecDataDescByName(theMG,(char *)name); + + if (theVD == NULL) + return (1); + + if (VD_NCMPS_IN_TYPE(theVD,NODEVECTOR)<1) + return (1); + + nodecomp = VD_CMP_OF_TYPE(theVD,NODEVECTOR,0); + + return (0); +} + +static DOUBLE NodeValue (const ELEMENT *theElement, + const COORD **CornersCoord, COORD *LocalCoord) +{ + INT i,n; + DOUBLE phi; + + n = CORNERS_OF_ELEM(theElement); + phi = 0.0; + for (i=0; i<n; i++) + phi += GN(n,i,LocalCoord)*VVALUE(NVECTOR(CORNER(theElement,i)),nodecomp); + + return(phi); +} + +/**************************************************************************/ +/* + NodeVector - plots the vector of node values + + SYNOPSIS: + static void NodeVector (const ELEMENT *theElement, + const COORD **theCorners, COORD *LocalCoord, DOUBLE *values); + + PARAMETERS: + . theElement - pointer to an element + . CornersCoord - corner coordinates + . LocalCoord - local coordinate + . values - plot vector + + DESCRIPTION: + This function plots the vector of node values. + + RETURN VALUE: + void + */ +/*************************************************************************/ + +static INT PreprocessNodeVector (const char *name, MULTIGRID *theMG) +{ + VECDATA_DESC *theVD; + INT i; + + theVD = GetVecDataDescByName(theMG,(char *)name); + + if (theVD == NULL) + return (1); + + if (VD_NCMPS_IN_TYPE(theVD,NODEVECTOR)<DIM) + return (1); + + nodecomp = VD_CMP_OF_TYPE(theVD,NODEVECTOR,0); + + for (i=1; i<DIM; i++) + if ((nodecomp+i) != VD_CMP_OF_TYPE(theVD,NODEVECTOR,i)) + return (1); + + return (0); +} + +static void NodeVector (const ELEMENT *theElement, const COORD **theCorners, + COORD *LocalCoord, DOUBLE *values) +{ + VECTOR *v; + INT i,j,n; + DOUBLE s; + + n = CORNERS_OF_ELEM(theElement); + V_DIM_CLEAR(values); + + for (i=0; i<n; i++) + { + v = NVECTOR(CORNER(theElement,i)); + s = GN(n,i,LocalCoord); + for (j=0; j<DIM; j++) + values[i] += s*VVALUE(v,nodecomp+i); + } + + return; +} + +/****************************************************************************/ +/* + InitPlotProc - Init this file + + SYNOPSIS: + INT InitPlotProc (); + + PARAMETERS: + . void - + + DESCRIPTION: + This function inits this file. + + RETURN VALUE: + INT + .n 0 if ok + .n 1 if error occured. + */ +/****************************************************************************/ + +INT InitPlotProc () +{ + /* install general plot procs */ + if (CreateElementValueEvalProc("nvalue",PreprocessNodeValue, + NodeValue)==NULL) + return(1); + if (CreateElementVectorEvalProc("nvector",PreprocessNodeVector, + NodeVector,DIM)==NULL) + return(1); + + return (0); +} diff --git a/graphics/uggraph/plotproc.h b/graphics/uggraph/plotproc.h new file mode 100644 index 000000000..6fb3ebdfc --- /dev/null +++ b/graphics/uggraph/plotproc.h @@ -0,0 +1,65 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +/****************************************************************************/ +/* */ +/* File: plotproc.h */ +/* */ +/* Purpose: header for generic plot functions */ +/* */ +/* Author: Christian Wieners */ +/* Institut fuer Computeranwendungen III */ +/* Universitaet Stuttgart */ +/* Pfaffenwaldring 27 */ +/* 70569 Stuttgart */ +/* email: ug@ica3.uni-stuttgart.de */ +/* */ +/* History: November 23, 1996 */ +/* */ +/* Remarks: */ +/* */ +/****************************************************************************/ + +/****************************************************************************/ +/* */ +/* auto include mechanism and other include files */ +/* */ +/****************************************************************************/ + +#ifndef __PLOTPROC__ +#define __PLOTPROC__ + +#include "compiler.h" + +/****************************************************************************/ +/* */ +/* 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 */ +/* */ +/****************************************************************************/ + +INT InitPlotProc (void); + +#endif diff --git a/graphics/uggraph/wpm.c b/graphics/uggraph/wpm.c index 0ed425436..525c22d42 100644 --- a/graphics/uggraph/wpm.c +++ b/graphics/uggraph/wpm.c @@ -3250,7 +3250,8 @@ static INT InitScalarFieldPlotObject_2D (PLOTOBJ *thePlotObj, INT argc, char **a break; if (strlen(buffer)>=NAMESIZE) break; strcpy(PO_NAME(theEspo),buffer); - theEspo->EvalFct = GetElementValueEvalProc("nvalue"); + if (theEspo->EvalFct == NULL) + theEspo->EvalFct = GetElementValueEvalProc("nvalue"); break; } @@ -3467,7 +3468,8 @@ static INT InitVectorFieldPlotObject_2D (PLOTOBJ *thePlotObj, INT argc, char **a break; if (strlen(buffer)>=NAMESIZE) break; strcpy(PO_NAME(theEvpo),buffer); - theEvpo->EvalFct = GetElementVectorEvalProc("nvector"); + if (theEvpo->EvalFct == NULL) + theEvpo->EvalFct = GetElementVectorEvalProc("nvector"); break; } @@ -4138,7 +4140,8 @@ static INT InitScalarFieldPlotObject_3D (PLOTOBJ *thePlotObj, INT argc, char **a break; if (strlen(buffer)>=NAMESIZE) break; strcpy(PO_NAME(theEspo),buffer); - theEspo->EvalFct = GetElementValueEvalProc("nvalue"); + if (theEspo->EvalFct == NULL) + theEspo->EvalFct = GetElementValueEvalProc("nvalue"); break; } @@ -4351,7 +4354,8 @@ static INT InitVectorFieldPlotObject_3D (PLOTOBJ *thePlotObj, INT argc, char **a break; if (strlen(buffer)>=NAMESIZE) break; strcpy(PO_NAME(theEvpo),buffer); - theEvpo->EvalFct = GetElementVectorEvalProc("nvector"); + if (theEvpo->EvalFct == NULL) + theEvpo->EvalFct = GetElementVectorEvalProc("nvector"); break; } -- GitLab