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

replace CutCircle/CutCurve with CutParametric
parent 04a0d9ff
No related branches found
No related tags found
No related merge requests found
# $Id: Makefile,v 1.57 2004-05-29 10:11:10 geuzaine Exp $
# $Id: Makefile,v 1.58 2004-06-15 18:20:53 geuzaine Exp $
#
# Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
#
......@@ -101,6 +101,6 @@ Visibility.o: Visibility.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
Trackball.o: Trackball.cpp Trackball.h
VertexArray.o: VertexArray.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
VertexArray.h Context.h
VertexArray.h Context.h ../Numeric/Numeric.h
License.o: License.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h
// $Id: CutCircle.cpp,v 1.1 2004-06-15 16:17:58 remacle Exp $
//
// Copyright (C) 1997-2004 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 "CutCircle.h"
#include "List.h"
#include "Context.h"
#include <math.h>
extern Context_T CTX;
StringXNumber CutCircleOptions_Number[] = {
{GMSH_FULLRC, "Xc", NULL, 0.},
{GMSH_FULLRC, "Yc", NULL, 0.},
{GMSH_FULLRC, "Zc", NULL, 0.},
{GMSH_FULLRC, "R", NULL, 1},
{GMSH_FULLRC, "nbPoints", NULL, 360},
{GMSH_FULLRC, "iView", NULL, -1.}
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutCirclePlugin()
{
return new GMSH_CutCirclePlugin();
}
}
GMSH_CutCirclePlugin::GMSH_CutCirclePlugin()
{
;
}
void GMSH_CutCirclePlugin::getName(char *name) const
{
strcpy(name, "Cut circle");
}
void GMSH_CutCirclePlugin::getInfos(char *author, char *copyright,
char *help_text) const
{
strcpy(author, "J.-F. Remacle (remacle@gce.ucl.ac.be)");
strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text,
"Plugin(CutCircle) cuts the view `iView' with\n"
"the circle centered at Xc,Yc,Zc and of Radius R If\n"
"`iView' < 0, the plugin is run on the current\n"
"view.\n"
"\n"
"Plugin(CutCircle) creates one new view.\n");
}
int GMSH_CutCirclePlugin::getNbOptions() const
{
return sizeof(CutCircleOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_CutCirclePlugin::getOption(int iopt)
{
return &CutCircleOptions_Number[iopt];
}
void GMSH_CutCirclePlugin::catchErrorMessage(char *errorMessage) const
{
strcpy(errorMessage, "CutCircle failed...");
}
void GMSH_CutCirclePlugin::getPoint(const double &u, double &x, double &y, double &z) const
{
const double Xc =CutCircleOptions_Number[0].def;
const double Yc =CutCircleOptions_Number[1].def;
const double Zc =CutCircleOptions_Number[2].def;
const double R =CutCircleOptions_Number[3].def;
const double theta = u * 2 * 3.1415926;
x = Xc + R * cos (theta);
y = Yc + R * sin (theta);
z = 0.0;
}
int GMSH_CutCirclePlugin::getNbPoints() const
{
return (int)CutCircleOptions_Number[4].def;
}
Post_View *GMSH_CutCirclePlugin::execute(Post_View * v)
{
int iView = (int)CutCircleOptions_Number[5].def;
if(iView < 0)
iView = v ? v->Index : 0;
if(!List_Pointer_Test(CTX.post.list, iView)) {
Msg(GERROR, "View[%d] does not exist", iView);
return v;
}
Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView);
return GMSH_CutCurvePlugin:: GenerateView(v1);
}
// $Id: CutCurve.cpp,v 1.1 2004-06-15 16:17:58 remacle Exp $
//
// Copyright (C) 1997-2004 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 "OctreePost.h"
#include "CutCurve.h"
#include "List.h"
#include "Context.h"
#include "Views.h"
#include "Message.h"
extern Context_T CTX;
GMSH_CutCurvePlugin::GMSH_CutCurvePlugin()
{
;
}
Post_View * GMSH_CutCurvePlugin::GenerateView(Post_View * v) const
{
Post_View * View = BeginView(1);
double *VALUES = new double [9*v->NbTimeStep];
OctreePost o(v);
for(int i = 0; i < getNbPoints(); ++i){
const double xi = (double)(i)/(double)(getNbPoints()-1);
double x,y,z;
getPoint (xi,x,y,z);
if(v->NbSS || v->NbSH || v->NbST || v->NbSQ){
List_Add(View->SP, &x);
List_Add(View->SP, &y);
List_Add(View->SP, &z);
View->NbSP++;
o.searchScalar(x, y, z, VALUES);
for(int k = 0; k < v->NbTimeStep; ++k){
List_Add(View->SP, &VALUES[k]);
}
}
}
char name[1024], filename[1024];
sprintf(name, "%s_CutCurve", v->Name);
sprintf(filename, "%s_CutCurve.pos", v->Name);
EndView(View, v->NbTimeStep, filename, name);
delete [] VALUES;
return View;
}
#ifndef _CUT_GRID_H_
#define _CUT_GRID_H
// Copyright (C) 1997-2004 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"
class GMSH_CutCurvePlugin : public GMSH_Post_Plugin
{
protected:
virtual void getPoint ( const double &u , double &x, double &y, double &z) const = 0;
virtual int getNbPoints ( ) const = 0;
public:
GMSH_CutCurvePlugin();
virtual Post_View * GenerateView (Post_View * v) const ;
};
#endif
// $Id: CutParametric.cpp,v 1.1 2004-06-15 18:20:53 geuzaine Exp $
//
// Copyright (C) 1997-2004 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 "OctreePost.h"
#include "CutParametric.h"
#include "List.h"
#include "Context.h"
#include <math.h>
#if defined(HAVE_MATH_EVAL)
#include "matheval.h"
#endif
extern Context_T CTX;
StringXNumber CutParametricOptions_Number[] = {
{GMSH_FULLRC, "minU", NULL, 0.},
{GMSH_FULLRC, "maxU", NULL, 2*M_PI},
{GMSH_FULLRC, "nbU", NULL, 360.},
//{GMSH_FULLRC, "minV", NULL, 0.},
//{GMSH_FULLRC, "maxV", NULL, 1.},
//{GMSH_FULLRC, "nbV", NULL, 0.},
//{GMSH_FULLRC, "minW", NULL, 0.},
//{GMSH_FULLRC, "maxW", NULL, 1.},
//{GMSH_FULLRC, "nbW", NULL, 0.},
{GMSH_FULLRC, "iView", NULL, -1.}
};
StringXString CutParametricOptions_String[] = {
{GMSH_FULLRC, "X", NULL, "0 + 1 * Cos(u)"},
{GMSH_FULLRC, "Y", NULL, "0 + 1 * Sin(u)"},
{GMSH_FULLRC, "Z", NULL, "0"},
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutParametricPlugin()
{
return new GMSH_CutParametricPlugin();
}
}
GMSH_CutParametricPlugin::GMSH_CutParametricPlugin()
{
;
}
void GMSH_CutParametricPlugin::getName(char *name) const
{
strcpy(name, "Cut parametric");
}
void GMSH_CutParametricPlugin::getInfos(char *author, char *copyright,
char *help_text) const
{
strcpy(author, "C. Geuzaine (geuzaine@acm.caltech.edu)");
strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text,
"Plugin(CutParametric) cuts the view `iView' with\n"
"the parametric function (`X'(u), `Y'(u), `Z'(u)),\n"
"using `nbU' values of the parameter u in [`minU',\n"
"`maxU']. If `iView' < 0, the plugin is run on the\n"
"current view.\n"
"\n"
"Plugin(CutParametric) creates one new view.\n");
}
int GMSH_CutParametricPlugin::getNbOptions() const
{
return sizeof(CutParametricOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_CutParametricPlugin::getOption(int iopt)
{
return &CutParametricOptions_Number[iopt];
}
int GMSH_CutParametricPlugin::getNbOptionsStr() const
{
return sizeof(CutParametricOptions_String) / sizeof(StringXString);
}
StringXString *GMSH_CutParametricPlugin::getOptionStr(int iopt)
{
return &CutParametricOptions_String[iopt];
}
void GMSH_CutParametricPlugin::catchErrorMessage(char *errorMessage) const
{
strcpy(errorMessage, "CutParametric failed...");
}
Post_View *GMSH_CutParametricPlugin::execute(Post_View * v)
{
int iView = (int)CutParametricOptions_Number[3].def;
if(iView < 0)
iView = v ? v->Index : 0;
if(!List_Pointer_Test(CTX.post.list, iView)) {
Msg(GERROR, "View[%d] does not exist", iView);
return v;
}
#if !defined(HAVE_MATH_EVAL)
Msg(GERROR, "MathEval is not compiled in this version of Gmsh");
return v;
#else
double minU = CutParametricOptions_Number[0].def;
double maxU = CutParametricOptions_Number[1].def;
int nbU = (int)CutParametricOptions_Number[2].def;
char *exprx = CutParametricOptions_String[0].def;
char *expry = CutParametricOptions_String[1].def;
char *exprz = CutParametricOptions_String[2].def;
void *fx = evaluator_create(exprx);
if(!fx){
Msg(GERROR, "Invalid expression '%s'", exprx);
return v;
}
void *fy = evaluator_create(expry);
if(!fy){
Msg(GERROR, "Invalid expression '%s'", expry);
return v;
}
void *fz = evaluator_create(exprz);
if(!fz){
Msg(GERROR, "Invalid expression '%s'", exprz);
return v;
}
Post_View *v2 = BeginView(1);
Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView);
OctreePost o(v1);
double *res = new double[9*v1->NbTimeStep];
for(int i = 0; i < nbU; ++i){
double u = minU + (double)(i)/(double)(nbU-1) * (maxU - minU);
char *names[] = { "u" };
double values[] = { u };
double x = evaluator_evaluate(fx, sizeof(names)/sizeof(names[0]), names, values);
double y = evaluator_evaluate(fy, sizeof(names)/sizeof(names[0]), names, values);
double z = evaluator_evaluate(fz, sizeof(names)/sizeof(names[0]), names, values);
List_Add(v2->SP, &x);
List_Add(v2->SP, &y);
List_Add(v2->SP, &z);
v2->NbSP++;
o.searchScalar(x, y, z, res);
for(int k = 0; k < v1->NbTimeStep; ++k){
List_Add(v2->SP, &res[k]);
}
}
char name[1024], filename[1024];
sprintf(name, "%s_CutParametric", v1->Name);
sprintf(filename, "%s_CutParametric.pos", v1->Name);
EndView(v2, 1, filename, name);
delete [] res;
return v2;
#endif
}
#ifndef _CUT_CIRCLE_H_
#define _CUT_CIRCLE_H
#ifndef _CUT_PARAMETRIC_H_
#define _CUT_PARAMETRIC_H
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -20,19 +20,17 @@
//
// Please report all bugs and problems to <gmsh@geuz.org>.
#include "CutCurve.h"
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutCirclePlugin ();
GMSH_Plugin *GMSH_RegisterCutParametricPlugin ();
}
class GMSH_CutCirclePlugin : public GMSH_CutCurvePlugin
class GMSH_CutParametricPlugin : public GMSH_Post_Plugin
{
virtual void getPoint ( const double &u , double &x, double &y, double &z) const ;
virtual int getNbPoints ( ) const ;
public:
GMSH_CutCirclePlugin();
GMSH_CutParametricPlugin();
void getName (char *name) const;
void getInfos (char *author,
char *copyright,
......@@ -40,6 +38,8 @@ public:
void catchErrorMessage (char *errorMessage) const;
int getNbOptions() const;
StringXNumber *getOption (int iopt);
int getNbOptionsStr() const;
StringXString* getOptionStr(int iopt);
Post_View *execute (Post_View *);
};
......
# $Id: Makefile,v 1.50 2004-06-15 16:17:58 remacle Exp $
# $Id: Makefile,v 1.51 2004-06-15 18:20:53 geuzaine Exp $
#
# Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
#
......@@ -29,7 +29,7 @@ CFLAGS = -DMPICH_SKIP_MPICXX ${OPTIM} ${FLAGS} ${INCLUDE}
SRC = Plugin.cpp\
Levelset.cpp\
CutPlane.cpp CutSphere.cpp CutMap.cpp \
Smooth.cpp CutCurve.cpp CutCircle.cpp\
Smooth.cpp CutParametric.cpp\
Octree.cpp OctreeInternals.cpp OctreePost.cpp\
StreamLines.cpp CutGrid.cpp\
Transform.cpp\
......@@ -68,7 +68,7 @@ depend:
Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \
../Common/VertexArray.h PluginManager.h CutMap.h Levelset.h CutGrid.h \
StreamLines.h CutPlane.h CutCircle.h CutCurve.h CutSphere.h Skin.h \
StreamLines.h CutPlane.h CutParametric.h CutSphere.h Skin.h \
../DataStr/Tree.h ../DataStr/avl.h Extract.h Harmonic2Time.h \
DecomposeInSimplex.h Smooth.h Transform.h Triangulate.h \
SphericalRaise.h DisplacementRaise.h Evaluate.h
......@@ -91,14 +91,10 @@ CutMap.o: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \
Smooth.o: Smooth.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \
../Common/VertexArray.h Smooth.h ../Common/Context.h
CutCurve.o: CutCurve.cpp OctreePost.h Octree.h OctreeInternals.h \
CutCurve.h Plugin.h ../Common/Options.h ../Common/Message.h \
../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \
../Common/VertexArray.h ../Common/Context.h
CutCircle.o: CutCircle.cpp CutCircle.h CutCurve.h Plugin.h \
../Common/Options.h ../Common/Message.h ../Common/Views.h \
../Common/ColorTable.h ../DataStr/List.h ../Common/VertexArray.h \
../Common/Context.h
CutParametric.o: CutParametric.cpp OctreePost.h Octree.h \
OctreeInternals.h CutParametric.h Plugin.h ../Common/Options.h \
../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \
../DataStr/List.h ../Common/VertexArray.h ../Common/Context.h
Octree.o: Octree.cpp Octree.h OctreeInternals.h
OctreeInternals.o: OctreeInternals.cpp ../Common/Message.h \
OctreeInternals.h
......
// $Id: Plugin.cpp,v 1.53 2004-06-15 16:17:59 remacle Exp $
// $Id: Plugin.cpp,v 1.54 2004-06-15 18:20:53 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -36,7 +36,7 @@
#include "CutGrid.h"
#include "StreamLines.h"
#include "CutPlane.h"
#include "CutCircle.h"
#include "CutParametric.h"
#include "CutSphere.h"
#include "Skin.h"
#include "Extract.h"
......@@ -147,7 +147,7 @@ void GMSH_PluginManager::registerDefaultPlugins()
allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("CutPlane", GMSH_RegisterCutPlanePlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("CutCircle", GMSH_RegisterCutCirclePlugin()));
("CutParametric", GMSH_RegisterCutParametricPlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("CutSphere", GMSH_RegisterCutSpherePlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * >
......
$Id: VERSIONS,v 1.223 2004-06-12 18:48:29 geuzaine Exp $
$Id: VERSIONS,v 1.224 2004-06-15 18:20:53 geuzaine Exp $
New since 1.53: fixed UNV output; make Layers' region numbering
consistent between lines/surfaces/volumes; fixed home directory
problem on Win98; small bug fixes and cleanups.
problem on Win98; new Plugin(CutParametric); small bug fixes and
cleanups.
New in 1.53: completed support for second order elements in the mesh
module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment