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

New plugin to make nice spherical elevation plots (e.g. for far field visualization)

parent 4dd76121
No related branches found
No related tags found
No related merge requests found
# $Id: Makefile,v 1.26 2002-05-18 16:31:17 geuzaine Exp $ # $Id: Makefile,v 1.27 2002-08-14 17:47:48 geuzaine Exp $
# #
# Makefile for "libGmshPlugin.a" # Makefile for "libGmshPlugin.a"
# #
...@@ -26,6 +26,7 @@ SRC = Plugin.cpp\ ...@@ -26,6 +26,7 @@ SRC = Plugin.cpp\
Smooth.cpp\ Smooth.cpp\
Transform.cpp\ Transform.cpp\
Triangulate.cpp\ Triangulate.cpp\
SphericalRaise.cpp\
Skin.cpp Skin.cpp
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)
......
// $Id: Plugin.cpp,v 1.29 2002-05-20 18:28:30 geuzaine Exp $ // $Id: Plugin.cpp,v 1.30 2002-08-14 17:47:48 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "Smooth.h" #include "Smooth.h"
#include "Transform.h" #include "Transform.h"
#include "Triangulate.h" #include "Triangulate.h"
#include "SphericalRaise.h"
using namespace std; using namespace std;
...@@ -141,6 +142,8 @@ void GMSH_PluginManager::RegisterDefaultPlugins(){ ...@@ -141,6 +142,8 @@ void GMSH_PluginManager::RegisterDefaultPlugins(){
GMSH_RegisterTransformPlugin())); GMSH_RegisterTransformPlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Triangulate", allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Triangulate",
GMSH_RegisterTriangulatePlugin())); GMSH_RegisterTriangulatePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("SphericalRaise",
GMSH_RegisterSphericalRaisePlugin()));
#ifdef _FLTK #ifdef _FLTK
char *homeplugins = getenv ("GMSHPLUGINSHOME"); char *homeplugins = getenv ("GMSHPLUGINSHOME");
......
// $Id: SphericalRaise.cpp,v 1.1 2002-08-14 17:47:48 geuzaine Exp $
//
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "gmsh@geuz.org".
#include "Plugin.h"
#include "SphericalRaise.h"
#include "List.h"
#include "Views.h"
#include "Context.h"
#include "Numeric.h"
extern Context_T CTX;
StringXNumber SphericalRaiseOptions_Number[] = {
{ GMSH_FULLRC, "Xc" , NULL , 0. },
{ GMSH_FULLRC, "Yc" , NULL , 0. },
{ GMSH_FULLRC, "Zc" , NULL , 0. },
{ GMSH_FULLRC, "Raise" , NULL , 1. },
{ GMSH_FULLRC, "iView" , NULL , -1. }
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterSphericalRaisePlugin ()
{
return new GMSH_SphericalRaisePlugin ();
}
}
GMSH_SphericalRaisePlugin::GMSH_SphericalRaisePlugin()
{
}
void GMSH_SphericalRaisePlugin::getName(char *name) const
{
strcpy(name,"SphericalRaise");
}
void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, char *help_text) const
{
strcpy(author, "C. Geuzaine (geuz@geuz.org)");
strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text,
"SphericalRaise transforms the coordinates\n"
"of the elements in a view according to the\n"
"elements' associated values. Instead of\n"
"transforming the coordinates along the X,\n"
"Y, Z axes (as in Options->Offset->Raise),\n"
"the raise is applied along the radius of\n"
"a sphere centered at (Xc, Yc, Zc).\n"
"Script name: Plugin(SphericalRaise).");
}
int GMSH_SphericalRaisePlugin::getNbOptions() const
{
return sizeof(SphericalRaiseOptions_Number)/sizeof(StringXNumber);
}
StringXNumber *GMSH_SphericalRaisePlugin:: GetOption (int iopt)
{
return &SphericalRaiseOptions_Number[iopt];
}
void GMSH_SphericalRaisePlugin::CatchErrorMessage (char *errorMessage) const
{
strcpy(errorMessage,"SphericalRaise failed...");
}
static void sphericalRaise(Post_View *v, double center[3], double raise){
double *x,*y,*z,*val,d[3],coef;
int nb, nbvert, i, j;
// for each element
// for each node
// compute d=(x-Xc,y-Yc,z-Zc)
// norm d
// get nodal value val at xyz
// compute (x,y,z)_new = (x,y,z)_old + raise*val*(dx,dy,dz)
if(v->NbST){
nb = List_Nbr(v->ST) / v->NbST ;
nbvert = 3;
for(i = 0 ; i < List_Nbr(v->ST) ; i+=nb){
x = (double*)List_Pointer_Fast(v->ST,i);
y = (double*)List_Pointer_Fast(v->ST,i+nbvert);
z = (double*)List_Pointer_Fast(v->ST,i+2*nbvert);
val = (double*)List_Pointer_Fast(v->ST,i+3*nbvert);
for(j=0; j<nbvert; j++){
d[0] = x[j]-center[0];
d[1] = y[j]-center[1];
d[2] = z[j]-center[2];
norme(d);
coef = raise*val[j];
x[j] += coef*d[0];
y[j] += coef*d[1];
z[j] += coef*d[2];
}
}
v->Changed=1;
}
else{
Msg(WARNING, "No scalar triangles to transform");
}
}
Post_View *GMSH_SphericalRaisePlugin::execute (Post_View *v)
{
Post_View *vv;
double center[3], raise;
center[0] = SphericalRaiseOptions_Number[0].def;
center[1] = SphericalRaiseOptions_Number[1].def;
center[2] = SphericalRaiseOptions_Number[2].def;
raise = SphericalRaiseOptions_Number[3].def;
int iView = (int)SphericalRaiseOptions_Number[4].def;
if(v && iView < 0)
vv = v;
else{
if(!v && iView < 0) iView = 0;
if(!(vv = (Post_View*)List_Pointer_Test(CTX.post.list,iView))){
Msg(WARNING,"View[%d] does not exist",iView);
return 0;
}
}
sphericalRaise(vv,center,raise);
return vv;
}
void GMSH_SphericalRaisePlugin::Run ()
{
execute(0);
}
void GMSH_SphericalRaisePlugin::Save ()
{
}
#ifndef _SPHERICAL_RAISE_H_
#define _SPHERICAL_RAISE_H
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "gmsh@geuz.org".
extern "C"
{
GMSH_Plugin *GMSH_RegisterSphericalRaisePlugin ();
}
class GMSH_SphericalRaisePlugin : public GMSH_Post_Plugin
{
public:
GMSH_SphericalRaisePlugin();
virtual void Run();
virtual void Save();
virtual void getName (char *name) const;
virtual void getInfos (char *author,
char *copyright,
char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const;
virtual StringXNumber* GetOption (int iopt);
virtual Post_View *execute (Post_View *);
};
#endif
// $Id: Transform.cpp,v 1.12 2002-05-20 18:28:30 geuzaine Exp $ // $Id: Transform.cpp,v 1.13 2002-08-14 17:47:48 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -111,6 +111,7 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v) ...@@ -111,6 +111,7 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v)
} }
vv->transform(mat); vv->transform(mat);
vv->Changed = 1;
return vv; return vv;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment