diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp index 1b694d8c96a02ce910de25622af9c6489d188090..9d4d60ba4aebbf35ef250886ffb3836fffd74e05 100644 --- a/Plugin/Annotate.cpp +++ b/Plugin/Annotate.cpp @@ -1,4 +1,4 @@ -// $Id: Annotate.cpp,v 1.21 2008-03-20 11:44:12 geuzaine Exp $ +// $Id: Annotate.cpp,v 1.22 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,11 +54,6 @@ extern "C" } } -GMSH_AnnotatePlugin::GMSH_AnnotatePlugin() -{ - ; -} - static double getStyle() { int fontsize = (int)AnnotateOptions_Number[4].def, font = 0, align = 0; diff --git a/Plugin/Annotate.h b/Plugin/Annotate.h index 604f8f9099187313655519f81a40353a0f364a68..76a7fb5087b98555b2891d3470d830aaf4fd69d9 100644 --- a/Plugin/Annotate.h +++ b/Plugin/Annotate.h @@ -34,14 +34,14 @@ private: double step, double min, double max); static const char *callbackStr(int num, int action, const char *value, const char **opt); public: - GMSH_AnnotatePlugin(); + GMSH_AnnotatePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); int getNbOptionsStr() const; - StringXString* getOptionStr(int iopt); + StringXString *getOptionStr(int iopt); PView *execute(PView *); static double callbackX(int, int, double); diff --git a/Plugin/Curl.cpp b/Plugin/Curl.cpp index 51fcd685219fc5751c6055af7a25d5d5bc390a06..795fb6fe848be9b33dbf4942c8b03866065fd5d6 100644 --- a/Plugin/Curl.cpp +++ b/Plugin/Curl.cpp @@ -1,4 +1,4 @@ -// $Id: Curl.cpp,v 1.8 2008-04-05 09:21:37 geuzaine Exp $ +// $Id: Curl.cpp,v 1.9 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -34,18 +34,13 @@ extern "C" } } -GMSH_CurlPlugin::GMSH_CurlPlugin() -{ - ; -} - void GMSH_CurlPlugin::getName(char *name) const { strcpy(name, "Curl"); } void GMSH_CurlPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); diff --git a/Plugin/Curl.h b/Plugin/Curl.h index 0a16c4f154992cb9714be839b0988153f607e203..9a1fb708f3854e2613bfeb07df2f106d41324678 100644 --- a/Plugin/Curl.h +++ b/Plugin/Curl.h @@ -30,12 +30,12 @@ extern "C" class GMSH_CurlPlugin : public GMSH_Post_Plugin { public: - GMSH_CurlPlugin(); + GMSH_CurlPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp index 2768f6a1abf3f0406bb0ba6282c98bad78b434e2..0b09f5b00819b9bf24d03a6de941601c0e95a0d2 100644 --- a/Plugin/CutGrid.cpp +++ b/Plugin/CutGrid.cpp @@ -1,4 +1,4 @@ -// $Id: CutGrid.cpp,v 1.26 2008-03-20 11:44:12 geuzaine Exp $ +// $Id: CutGrid.cpp,v 1.27 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,11 +54,6 @@ extern "C" } } -GMSH_CutGridPlugin::GMSH_CutGridPlugin() -{ - ; -} - void GMSH_CutGridPlugin::draw() { #if defined(HAVE_FLTK) diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h index 57adfe30bf4efbf3ac6872803271f5cc2d5cae2a..e50e90b0799da37b745ca41ea0b9b9bb881bb7d5 100644 --- a/Plugin/CutGrid.h +++ b/Plugin/CutGrid.h @@ -38,15 +38,13 @@ class GMSH_CutGridPlugin : public GMSH_Post_Plugin List_T *Q, int *nQ); PView *GenerateView (PView *v, int connectPoints); public: - GMSH_CutGridPlugin(); - void getName (char *name) const; - void getInfos (char *author, - char *copyright, - char *help_text) const; - void catchErrorMessage (char *errorMessage) const; + GMSH_CutGridPlugin(){} + void getName(char *name) const; + void getInfos(char *author, char *copyright, char *help_text) const; + void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber *getOption (int iopt); - PView *execute (PView *); + StringXNumber *getOption(int iopt); + PView *execute(PView *); static int getNbU (); static int getNbV (); diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index 654d8d366e6801e57a2cf483442c1b4a2b34b654..e1a76f480c9f9c2c9acc84231106775e3d3cc306 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -1,4 +1,4 @@ -// $Id: CutMap.cpp,v 1.58 2008-03-20 11:44:12 geuzaine Exp $ +// $Id: CutMap.cpp,v 1.59 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -42,11 +42,6 @@ extern "C" } } -GMSH_CutMapPlugin::GMSH_CutMapPlugin() -{ - ; -} - double GMSH_CutMapPlugin::callbackA(int num, int action, double value) { double min = 0., max = 1.; diff --git a/Plugin/CutMap.h b/Plugin/CutMap.h index 1a08923fde4b1e315666d53a962128aa653786fa..badd4e6cb482f5a6ce8dba4ff790c247ce0cb918 100644 --- a/Plugin/CutMap.h +++ b/Plugin/CutMap.h @@ -31,13 +31,13 @@ class GMSH_CutMapPlugin : public GMSH_LevelsetPlugin { double levelset(double x, double y, double z, double val) const; public: - GMSH_CutMapPlugin(); + GMSH_CutMapPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption (int iopt); - PView *execute (PView *); + StringXNumber *getOption(int iopt); + PView *execute(PView *); static double callbackA(int, int, double); static double callbackVol(int, int, double); static double callbackRecur(int, int, double); diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp index aecf25a1431a103e1cca31ca62cb0058fc6aaaf1..ca4b429e90843cb7097fefc83cada7a01190caf1 100644 --- a/Plugin/CutParametric.cpp +++ b/Plugin/CutParametric.cpp @@ -1,4 +1,4 @@ -// $Id: CutParametric.cpp,v 1.27 2008-03-20 11:44:12 geuzaine Exp $ +// $Id: CutParametric.cpp,v 1.28 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -57,12 +57,6 @@ extern "C" } } - -GMSH_CutParametricPlugin::GMSH_CutParametricPlugin() -{ - ; -} - static double getU(int i) { double minU = CutParametricOptions_Number[0].def; diff --git a/Plugin/CutParametric.h b/Plugin/CutParametric.h index abf81766914e7f5450aa85d851b4a153e9892b21..b085506621d4ab49334c1723ade69d8efe595028 100644 --- a/Plugin/CutParametric.h +++ b/Plugin/CutParametric.h @@ -40,14 +40,14 @@ private: static int recompute; static std::vector<double> x, y, z; public: - GMSH_CutParametricPlugin(); + GMSH_CutParametricPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; StringXNumber *getOption(int iopt); int getNbOptionsStr() const; - StringXString* getOptionStr(int iopt); + StringXString *getOptionStr(int iopt); PView *execute(PView *); static double callbackMinU(int, int, double); diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index 19f25977ef7c090ef1b1575fefa525b78edcee25..792c27b2d32763521e5f920cd779f82712efa734 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -1,4 +1,4 @@ -// $Id: CutPlane.cpp,v 1.56 2008-03-20 11:44:13 geuzaine Exp $ +// $Id: CutPlane.cpp,v 1.57 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -51,11 +51,6 @@ extern "C" } } -GMSH_CutPlanePlugin::GMSH_CutPlanePlugin() -{ - ; -} - void GMSH_CutPlanePlugin::draw() { #if defined(HAVE_FLTK) diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h index 656bf9d1ee90cb9c921ef3e2ae25f3e65737f0c6..68f0f7303b2a147fbfc0324d8d5ce4e4bbcff4b5 100644 --- a/Plugin/CutPlane.h +++ b/Plugin/CutPlane.h @@ -34,7 +34,7 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin double step, double min, double max); static int iview; public: - GMSH_CutPlanePlugin(); + GMSH_CutPlanePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index 438c40782a82b8dff1d9650d44d4b8e6387db61e..ea203df8bac07c158cc9d8dbf403c9f6aa96500e 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -1,4 +1,4 @@ -// $Id: CutSphere.cpp,v 1.50 2008-03-20 11:44:13 geuzaine Exp $ +// $Id: CutSphere.cpp,v 1.51 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -49,11 +49,6 @@ extern "C" } } -GMSH_CutSpherePlugin::GMSH_CutSpherePlugin() -{ - ; -} - void GMSH_CutSpherePlugin::draw() { #if defined(HAVE_FLTK) diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h index 546afc647b7fcba67ec570ece1a11daf2ca9e1cd..d6b5d33c7891902b32aa816587f69cc8d7a97031 100644 --- a/Plugin/CutSphere.h +++ b/Plugin/CutSphere.h @@ -33,12 +33,12 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin static double callback(int num, int action, double value, double *opt, double step, double min, double max); public: - GMSH_CutSpherePlugin(); + GMSH_CutSpherePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); static double callbackX(int, int, double); diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp index 3c36f8429227de27edf6b3f681638a76c20e2460..8dc1c56dcef93361061bda8c155896e986721540 100644 --- a/Plugin/Divergence.cpp +++ b/Plugin/Divergence.cpp @@ -1,4 +1,4 @@ -// $Id: Divergence.cpp,v 1.8 2008-04-05 09:21:37 geuzaine Exp $ +// $Id: Divergence.cpp,v 1.9 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -34,18 +34,13 @@ extern "C" } } -GMSH_DivergencePlugin::GMSH_DivergencePlugin() -{ - ; -} - void GMSH_DivergencePlugin::getName(char *name) const { strcpy(name, "Divergence"); } void GMSH_DivergencePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); diff --git a/Plugin/Divergence.h b/Plugin/Divergence.h index 6c0e1126ae46abe95e6dbb058a403c5992f1c646..1a7dd26b2bd723deb100a7ee3755eba499fe8766 100644 --- a/Plugin/Divergence.h +++ b/Plugin/Divergence.h @@ -30,12 +30,12 @@ extern "C" class GMSH_DivergencePlugin : public GMSH_Post_Plugin { public: - GMSH_DivergencePlugin(); + GMSH_DivergencePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Eigenvalues.cpp b/Plugin/Eigenvalues.cpp index 3ea813d9482131beee665be6bea898aca794ab7d..f9c381bbce7d03e86e3958e7e92e9c4a3fc68a24 100644 --- a/Plugin/Eigenvalues.cpp +++ b/Plugin/Eigenvalues.cpp @@ -1,4 +1,4 @@ -// $Id: Eigenvalues.cpp,v 1.7 2008-03-20 11:44:13 geuzaine Exp $ +// $Id: Eigenvalues.cpp,v 1.8 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -71,39 +71,18 @@ void GMSH_EigenvaluesPlugin::catchErrorMessage(char *errorMessage) const strcpy(errorMessage, "Eigenvalues failed..."); } -static void eigenvalues(List_T *inList, int inNb, - int nbNod, int nbTime, - List_T *minList, int *minNb, - List_T *midList, int *midNb, - List_T *maxList, int *maxNb) +static List_T *incrementList(PViewDataList *data2, int numEdges) { - if(!inNb) return; - - int nb = List_Nbr(inList) / inNb; - for(int i = 0; i < List_Nbr(inList); i += nb) { - for(int j = 0; j < 3 * nbNod; j++){ - List_Add(minList, List_Pointer_Fast(inList, i + j)); - List_Add(midList, List_Pointer_Fast(inList, i + j)); - List_Add(maxList, List_Pointer_Fast(inList, i + j)); - } - for(int j = 0; j < nbTime; j++){ - for(int k = 0; k < nbNod; k++){ - double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - nbNod * 9 * j + 9 * k); - double w[3], A[3][3] = { {v[0], v[1], v[2]}, - {v[3], v[4], v[5]}, - {v[6], v[7], v[8]} }; - eigenvalue(A, w); - for(int l = 0; l < 3; l++){ - List_Add(minList, &w[2]); - List_Add(midList, &w[1]); - List_Add(maxList, &w[0]); - } - } - } - (*minNb)++; - (*midNb)++; - (*maxNb)++; + switch(numEdges){ + case 0: data2->NbSP++; return data2->SP; + case 1: data2->NbSL++; return data2->SL; + case 3: data2->NbST++; return data2->ST; + case 4: data2->NbSQ++; return data2->SQ; + case 6: data2->NbSS++; return data2->SS; + case 12: data2->NbSH++; return data2->SH; + case 9: data2->NbSI++; return data2->SI; + case 8: data2->NbSY++; return data2->SY; + default: return 0; } } @@ -114,8 +93,11 @@ PView *GMSH_EigenvaluesPlugin::execute(PView *v) PView *v1 = getView(iView, v); if(!v1) return v; - PViewDataList *data1 = getDataList(v1); - if(!data1) return v; + PViewData *data1 = v1->getData(); + if(data1->hasMultipleMeshes()){ + Msg(GERROR, "Eigenvalues plugin cannot be run on multi-mesh views"); + return v; + } PView *min = new PView(true); PView *mid = new PView(true); @@ -125,27 +107,57 @@ PView *GMSH_EigenvaluesPlugin::execute(PView *v) PViewDataList *dmid = getDataList(mid); PViewDataList *dmax = getDataList(max); - eigenvalues(data1->TP, data1->NbTP, 1, data1->getNumTimeSteps(), - dmin->SP, &dmin->NbSP, dmid->SP, &dmid->NbSP, dmax->SP, &dmax->NbSP); - eigenvalues(data1->TL, data1->NbTL, 2, data1->getNumTimeSteps(), - dmin->SL, &dmin->NbSL, dmid->SL, &dmid->NbSL, dmax->SL, &dmax->NbSL); - eigenvalues(data1->TT, data1->NbTT, 3, data1->getNumTimeSteps(), - dmin->ST, &dmin->NbST, dmid->ST, &dmid->NbST, dmax->ST, &dmax->NbST); - eigenvalues(data1->TQ, data1->NbTQ, 4, data1->getNumTimeSteps(), - dmin->SQ, &dmin->NbSQ, dmid->SQ, &dmid->NbSQ, dmax->SQ, &dmax->NbSQ); - eigenvalues(data1->TS, data1->NbTS, 4, data1->getNumTimeSteps(), - dmin->SS, &dmin->NbSS, dmid->SS, &dmid->NbSS, dmax->SS, &dmax->NbSS); - eigenvalues(data1->TH, data1->NbTH, 8, data1->getNumTimeSteps(), - dmin->SH, &dmin->NbSH, dmid->SH, &dmid->NbSH, dmax->SH, &dmax->NbSH); - eigenvalues(data1->TI, data1->NbTI, 6, data1->getNumTimeSteps(), - dmin->SI, &dmin->NbSI, dmid->SI, &dmid->NbSI, dmax->SI, &dmax->NbSI); - eigenvalues(data1->TY, data1->NbTY, 5, data1->getNumTimeSteps(), - dmin->SY, &dmin->NbSY, dmid->SY, &dmid->NbSY, dmax->SY, &dmax->NbSY); - - for(int i = 0; i < List_Nbr(data1->Time); i++){ - List_Add(dmin->Time, List_Pointer(data1->Time, i)); - List_Add(dmid->Time, List_Pointer(data1->Time, i)); - List_Add(dmax->Time, List_Pointer(data1->Time, i)); + for(int ent = 0; ent < data1->getNumEntities(0); ent++){ + for(int ele = 0; ele < data1->getNumElements(0, ent); ele++){ + if(data1->skipElement(0, ent, ele)) continue; + int numComp = data1->getNumComponents(0, ent, ele); + if(numComp != 9) continue; + int numEdges = data1->getNumEdges(0, ent, ele); + List_T *outmin = incrementList(dmin, numEdges); + List_T *outmid = incrementList(dmid, numEdges); + List_T *outmax = incrementList(dmax, numEdges); + if(!outmin || !outmid || !outmax) continue; + int numNodes = data1->getNumNodes(0, ent, ele); + double x[8], y[8], z[8]; + for(int nod = 0; nod < numNodes; nod++) + data1->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); + for(int nod = 0; nod < numNodes; nod++){ + List_Add(outmin, &x[nod]); + List_Add(outmid, &x[nod]); + List_Add(outmax, &x[nod]); + } + for(int nod = 0; nod < numNodes; nod++){ + List_Add(outmin, &y[nod]); + List_Add(outmid, &y[nod]); + List_Add(outmax, &y[nod]); + } + for(int nod = 0; nod < numNodes; nod++){ + List_Add(outmin, &z[nod]); + List_Add(outmid, &z[nod]); + List_Add(outmax, &z[nod]); + } + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + for(int nod = 0; nod < numNodes; nod++){ + double val[9]; + for(int comp = 0; comp < numComp; comp++) + data1->getValue(step, ent, ele, nod, comp, val[comp]); + double w[3], A[3][3] = { {val[0], val[1], val[2]}, + {val[3], val[4], val[5]}, + {val[6], val[7], val[8]} }; + eigenvalue(A, w); + List_Add(outmin, &w[2]); + List_Add(outmid, &w[1]); + List_Add(outmax, &w[0]); + } + } + } + } + + for(int i = 0; i < data1->getNumTimeSteps(); i++){ + double time = data1->getTime(i); + List_Add(dmin->Time, &time); + List_Add(dmid->Time, &time); + List_Add(dmax->Time, &time); } dmin->setName(data1->getName() + "_MinEigenvalues"); dmin->setFileName(data1->getName() + "_MinEigenvalues.pos"); diff --git a/Plugin/Eigenvalues.h b/Plugin/Eigenvalues.h index 4142aea88ec51eb267b16f3e50434372b63b19ce..f761bce36e3097d4b576b0f4586d25b3f9b5a5e6 100644 --- a/Plugin/Eigenvalues.h +++ b/Plugin/Eigenvalues.h @@ -35,7 +35,7 @@ class GMSH_EigenvaluesPlugin : public GMSH_Post_Plugin void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Evaluate.cpp b/Plugin/Evaluate.cpp index 79396180fe3d34c09b1dd7d4a2661389ca11c9aa..f6891baa3788e355d971c3e48e41f6ec9f280890 100644 --- a/Plugin/Evaluate.cpp +++ b/Plugin/Evaluate.cpp @@ -1,4 +1,4 @@ -// $Id: Evaluate.cpp,v 1.36 2008-03-21 17:09:06 geuzaine Exp $ +// $Id: Evaluate.cpp,v 1.37 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,12 +45,6 @@ extern "C" } } - -GMSH_EvaluatePlugin::GMSH_EvaluatePlugin() -{ - ; -} - void GMSH_EvaluatePlugin::getName(char *name) const { strcpy(name, "Evaluate"); diff --git a/Plugin/Evaluate.h b/Plugin/Evaluate.h index 7af020345048d0f7ae299e7f6b13619dcc963c5a..17cc1c2b0d3586a27b416d7cfbb143cfff80c34f 100644 --- a/Plugin/Evaluate.h +++ b/Plugin/Evaluate.h @@ -38,7 +38,7 @@ private: int timeStep, int timeStep2, const char *expression); public: - GMSH_EvaluatePlugin(); + GMSH_EvaluatePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp index 25a4eb564edca8c2650308aa8419e3988183b249..012f21c43766229abe24358a97ac096d1874224f 100644 --- a/Plugin/Extract.cpp +++ b/Plugin/Extract.cpp @@ -1,4 +1,4 @@ -// $Id: Extract.cpp,v 1.27 2008-03-20 11:44:13 geuzaine Exp $ +// $Id: Extract.cpp,v 1.28 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,11 +54,6 @@ extern "C" } } -GMSH_ExtractPlugin::GMSH_ExtractPlugin() -{ - ; -} - void GMSH_ExtractPlugin::getName(char *name) const { strcpy(name, "Extract"); diff --git a/Plugin/Extract.h b/Plugin/Extract.h index 8068b0b8102b1c19fa8c53724cc90a12264f1741..8555eb403844ecf04037a2a5af8c5e252941e474 100644 --- a/Plugin/Extract.h +++ b/Plugin/Extract.h @@ -30,7 +30,7 @@ extern "C" class GMSH_ExtractPlugin : public GMSH_Post_Plugin { public: - GMSH_ExtractPlugin(); + GMSH_ExtractPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp index efa5985402154b3c251b4dc489771ecc2aa2afc8..c8832ef5af473fb515d5bf61a543eadf2c21105e 100644 --- a/Plugin/ExtractElements.cpp +++ b/Plugin/ExtractElements.cpp @@ -1,4 +1,4 @@ -// $Id: ExtractElements.cpp,v 1.12 2008-03-20 11:44:13 geuzaine Exp $ +// $Id: ExtractElements.cpp,v 1.13 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -37,11 +37,6 @@ extern "C" } } -GMSH_ExtractElementsPlugin::GMSH_ExtractElementsPlugin() -{ - ; -} - void GMSH_ExtractElementsPlugin::getName(char *name) const { strcpy(name, "Extract Elements"); diff --git a/Plugin/ExtractElements.h b/Plugin/ExtractElements.h index f4f2f57b1e9d9dc7dda754211b12a45a79a7e31c..62c17886b602bfa67c06386aa21ab9d8f6ddbccf 100644 --- a/Plugin/ExtractElements.h +++ b/Plugin/ExtractElements.h @@ -30,7 +30,7 @@ extern "C" class GMSH_ExtractElementsPlugin : public GMSH_Post_Plugin { public: - GMSH_ExtractElementsPlugin(); + GMSH_ExtractElementsPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/Gradient.cpp b/Plugin/Gradient.cpp index b96daa4d7a4f4eb10ad6d832e238727c4ebc6e6c..2779dd3b7c0753e1bf5b1ee7a432d49f00ed5657 100644 --- a/Plugin/Gradient.cpp +++ b/Plugin/Gradient.cpp @@ -1,4 +1,4 @@ -// $Id: Gradient.cpp,v 1.13 2008-04-05 09:21:37 geuzaine Exp $ +// $Id: Gradient.cpp,v 1.14 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -34,18 +34,13 @@ extern "C" } } -GMSH_GradientPlugin::GMSH_GradientPlugin() -{ - ; -} - void GMSH_GradientPlugin::getName(char *name) const { strcpy(name, "Gradient"); } void GMSH_GradientPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); diff --git a/Plugin/Gradient.h b/Plugin/Gradient.h index 86315daa7818137373ecbcfdd5debbd592c9b0e7..5ace582bd9c6348599c679bd2d545bab06819b70 100644 --- a/Plugin/Gradient.h +++ b/Plugin/Gradient.h @@ -30,12 +30,12 @@ extern "C" class GMSH_GradientPlugin : public GMSH_Post_Plugin { public: - GMSH_GradientPlugin(); + GMSH_GradientPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp index 4094118c689dd0abdb0fe710589794b48b74e785..6c75bfd8e3d39cb050fa25d7d82d8c28307a19aa 100644 --- a/Plugin/Probe.cpp +++ b/Plugin/Probe.cpp @@ -1,4 +1,4 @@ -// $Id: Probe.cpp,v 1.21 2008-03-20 11:44:14 geuzaine Exp $ +// $Id: Probe.cpp,v 1.22 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -47,11 +47,6 @@ extern "C" } } -GMSH_ProbePlugin::GMSH_ProbePlugin() -{ - ; -} - void GMSH_ProbePlugin::draw() { #if defined(HAVE_FLTK) diff --git a/Plugin/Probe.h b/Plugin/Probe.h index 961fa14247ec2740ac5f19254828271ace4ff56a..6a6ba2eef003e977cd61ab115ecc5aecf3af678b 100644 --- a/Plugin/Probe.h +++ b/Plugin/Probe.h @@ -33,7 +33,7 @@ class GMSH_ProbePlugin : public GMSH_Post_Plugin static double callback(int num, int action, double value, double *opt); static int iview; public: - GMSH_ProbePlugin(); + GMSH_ProbePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/Remove.cpp b/Plugin/Remove.cpp index 74cd3c09d75037ddcac2f40c3e7a44bc7f53a608..bc9283c3a1813b3c952a304e15344bc63dd5abd2 100644 --- a/Plugin/Remove.cpp +++ b/Plugin/Remove.cpp @@ -1,4 +1,4 @@ -// $Id: Remove.cpp,v 1.14 2008-03-20 11:44:14 geuzaine Exp $ +// $Id: Remove.cpp,v 1.15 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -46,11 +46,6 @@ extern "C" } } -GMSH_RemovePlugin::GMSH_RemovePlugin() -{ - ; -} - void GMSH_RemovePlugin::getName(char *name) const { strcpy(name, "Remove"); diff --git a/Plugin/Remove.h b/Plugin/Remove.h index b7b4a100acc5bd46c0cb249fdf4676cd5a9cc404..e7295d1c8afeb23823d5a9edb4a1ab3cc8609243 100644 --- a/Plugin/Remove.h +++ b/Plugin/Remove.h @@ -30,12 +30,12 @@ extern "C" class GMSH_RemovePlugin : public GMSH_Post_Plugin { public: - GMSH_RemovePlugin(); + GMSH_RemovePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index 51b6aa048bcd6c97823e09b8cd2c8bed0db06fd0..ca9aeb90f206a6129de8328cbbdb85e4e9c56de5 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -1,4 +1,4 @@ -// $Id: Skin.cpp,v 1.37 2008-03-20 11:44:14 geuzaine Exp $ +// $Id: Skin.cpp,v 1.38 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -44,11 +44,6 @@ extern "C" } } -GMSH_SkinPlugin::GMSH_SkinPlugin() -{ - ; -} - void GMSH_SkinPlugin::getName(char *name) const { strcpy(name, "Skin"); diff --git a/Plugin/Skin.h b/Plugin/Skin.h index d3b7005983413db1f47531a3d44cff2f5f7e807c..ba4436cefc686d3bbc78d2e8b41f1833152dbb52 100644 --- a/Plugin/Skin.h +++ b/Plugin/Skin.h @@ -43,12 +43,12 @@ class GMSH_SkinPlugin : public GMSH_Post_Plugin void skinList(List_T *inList, int inNbList, int inNbNod, int inNbFac, int fxn[6][4]); public: - GMSH_SkinPlugin(); + GMSH_SkinPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp index 01d526b8cf4b93ee2eead4700512ee6c04f7a863..1f97c6862fff1c6cead81c17e3508198f1e6427c 100644 --- a/Plugin/Smooth.cpp +++ b/Plugin/Smooth.cpp @@ -1,4 +1,4 @@ -// $Id: Smooth.cpp,v 1.31 2008-03-20 11:44:14 geuzaine Exp $ +// $Id: Smooth.cpp,v 1.32 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -33,12 +33,6 @@ extern "C" } } - -GMSH_SmoothPlugin::GMSH_SmoothPlugin() -{ - ; -} - void GMSH_SmoothPlugin::getName(char *name) const { strcpy(name, "Smooth"); diff --git a/Plugin/Smooth.h b/Plugin/Smooth.h index 33edc0396d30ac38b7473fc755669ef3d219e127..9b369f2a78422cfcb7e5c498f0bb8c89db19ee56 100644 --- a/Plugin/Smooth.h +++ b/Plugin/Smooth.h @@ -30,12 +30,12 @@ extern "C" class GMSH_SmoothPlugin : public GMSH_Post_Plugin { public: - GMSH_SmoothPlugin(); + GMSH_SmoothPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp index 22184277520740bed91a4ad32152b35a8d5d3920..9624fd84b731bfc96514b49b62424e4311c20972 100644 --- a/Plugin/SphericalRaise.cpp +++ b/Plugin/SphericalRaise.cpp @@ -1,4 +1,4 @@ -// $Id: SphericalRaise.cpp,v 1.32 2008-03-20 11:44:14 geuzaine Exp $ +// $Id: SphericalRaise.cpp,v 1.33 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -40,12 +40,6 @@ extern "C" } } - -GMSH_SphericalRaisePlugin::GMSH_SphericalRaisePlugin() -{ - ; -} - void GMSH_SphericalRaisePlugin::getName(char *name) const { strcpy(name, "Spherical Raise"); @@ -89,47 +83,6 @@ void GMSH_SphericalRaisePlugin::catchErrorMessage(char *errorMessage) const strcpy(errorMessage, "SphericalRaise failed..."); } -static void sphericalRaise(PViewData *data, List_T *list, int nbElm, - int nbNod, int timeStep, double center[3], - double raise, double offset) -{ - double *x, *y, *z, *val, d[3], coef; - int nb, i, j; - - if(!nbElm) - return; - - if(timeStep < 0 || timeStep > data->getNumTimeSteps() - 1){ - Msg(GERROR, "Invalid TimeStep (%d) in view", timeStep); - return; - } - - // 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 + (offset+raise*val)*(dx,dy,dz) - - nb = List_Nbr(list) / nbElm; - for(i = 0; i < List_Nbr(list); i += nb) { - x = (double *)List_Pointer_Fast(list, i); - y = (double *)List_Pointer_Fast(list, i + nbNod); - z = (double *)List_Pointer_Fast(list, i + 2 * nbNod); - val = (double *)List_Pointer_Fast(list, i + 3 * nbNod); - for(j = 0; j < nbNod; j++) { - d[0] = x[j] - center[0]; - d[1] = y[j] - center[1]; - d[2] = z[j] - center[2]; - norme(d); - coef = offset + raise * val[nbNod * timeStep + j]; - x[j] += coef * d[0]; - y[j] += coef * d[1]; - z[j] += coef * d[2]; - } - } -} - PView *GMSH_SphericalRaisePlugin::execute(PView *v) { double center[3]; @@ -144,17 +97,55 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v) PView *v1 = getView(iView, v); if(!v1) return v; - PViewDataList *data1 = getDataList(v1); - if(!data1) return v; - - sphericalRaise(data1, data1->SP, data1->NbSP, 1, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SL, data1->NbSL, 2, timeStep, center, raise, offset); - sphericalRaise(data1, data1->ST, data1->NbST, 3, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SQ, data1->NbSQ, 4, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SS, data1->NbSS, 4, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SH, data1->NbSH, 8, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SI, data1->NbSI, 6, timeStep, center, raise, offset); - sphericalRaise(data1, data1->SY, data1->NbSY, 5, timeStep, center, raise, offset); + PViewData *data1 = v1->getData(); + + // sanity checks + if(timeStep < 0 || timeStep > data1->getNumTimeSteps() - 1){ + Msg(GERROR, "Invalid TimeStep (%d) in view", timeStep); + return v; + } + + // tag all the nodes with "0" (the default tag) + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + for(int ent = 0; ent < data1->getNumEntities(step); ent++){ + for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ + if(data1->skipElement(step, ent, ele)) continue; + int numNodes = data1->getNumNodes(step, ent, ele); + for(int nod = 0; nod < numNodes; nod++){ + double x, y, z; + data1->getNode(step, ent, ele, nod, x, y, z); + data1->setNode(step, ent, ele, nod, x, y, z, 0); + } + } + } + } + + // transform all "0" nodes + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + for(int ent = 0; ent < data1->getNumEntities(step); ent++){ + for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ + if(data1->skipElement(step, ent, ele)) continue; + int numNodes = data1->getNumNodes(step, ent, ele); + for(int nod = 0; nod < numNodes; nod++){ + double x, y, z; + int tag = data1->getNode(step, ent, ele, nod, x, y, z); + if(!tag){ + double r[3], val; + r[0] = x - center[0]; + r[1] = y - center[1]; + r[2] = z - center[2]; + norme(r); + data1->getScalarValue(step, ent, ele, nod, val); + double coef = offset + raise * val; + x += coef * r[0]; + y += coef * r[1]; + z += coef * r[2]; + data1->setNode(step, ent, ele, nod, x, y, z, 1); + } + } + } + } + } data1->finalize(); v1->setChanged(true); diff --git a/Plugin/SphericalRaise.h b/Plugin/SphericalRaise.h index eb852caa197a10cf7d10dcc4b59ef49b7fde64f0..9ed37207425caf74f857d4448a14c19e2c319ce5 100644 --- a/Plugin/SphericalRaise.h +++ b/Plugin/SphericalRaise.h @@ -30,12 +30,12 @@ extern "C" class GMSH_SphericalRaisePlugin : public GMSH_Post_Plugin { public: - GMSH_SphericalRaisePlugin(); + GMSH_SphericalRaisePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp index ba3ec4375319ff9a236e1e84f7ecc17c734b9d44..38c413449edfaa77e9851027b11008d0d4071cf1 100644 --- a/Plugin/Transform.cpp +++ b/Plugin/Transform.cpp @@ -1,4 +1,4 @@ -// $Id: Transform.cpp,v 1.39 2008-04-05 09:21:37 geuzaine Exp $ +// $Id: Transform.cpp,v 1.40 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -46,11 +46,6 @@ extern "C" } } -GMSH_TransformPlugin::GMSH_TransformPlugin() -{ - ; -} - void GMSH_TransformPlugin::getName(char *name) const { strcpy(name, "Transform"); diff --git a/Plugin/Transform.h b/Plugin/Transform.h index 7634e6effcd79420835f2bad01f4227c6b446b57..b4534ec55d11b96bb01ce81bfa8b18cedc5a7b67 100644 --- a/Plugin/Transform.h +++ b/Plugin/Transform.h @@ -30,12 +30,12 @@ extern "C" class GMSH_TransformPlugin : public GMSH_Post_Plugin { public: - GMSH_TransformPlugin(); + GMSH_TransformPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); }; diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 567a2ed789d17791f211e8d8cb5040f3de462c08..9f977b6c33b5eeff710a909b09ba93b07997cdb6 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -1,4 +1,4 @@ -// $Id: Triangulate.cpp,v 1.47 2008-03-20 11:44:15 geuzaine Exp $ +// $Id: Triangulate.cpp,v 1.48 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -42,11 +42,6 @@ extern "C" } } -GMSH_TriangulatePlugin::GMSH_TriangulatePlugin() -{ - ; -} - void GMSH_TriangulatePlugin::getName(char *name) const { strcpy(name, "Triangulate"); diff --git a/Plugin/Triangulate.h b/Plugin/Triangulate.h index 7d01482bf4b4b910a69618d450352f5dc1414a18..b126a49e51274b2e8bf378621f3cf61a00430487 100644 --- a/Plugin/Triangulate.h +++ b/Plugin/Triangulate.h @@ -30,7 +30,7 @@ extern "C" class GMSH_TriangulatePlugin : public GMSH_Post_Plugin { public: - GMSH_TriangulatePlugin(); + GMSH_TriangulatePlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *helpText) const; void catchErrorMessage(char *errorMessage) const; diff --git a/Plugin/Warp.cpp b/Plugin/Warp.cpp index 01144819bb6d47fe404a63b2342f8d87f05285ed..e342ccca78bf6055fcc2b7637fc67c51fd7fa3a5 100644 --- a/Plugin/Warp.cpp +++ b/Plugin/Warp.cpp @@ -1,4 +1,4 @@ -// $Id: Warp.cpp,v 1.13 2008-03-20 11:44:15 geuzaine Exp $ +// $Id: Warp.cpp,v 1.14 2008-04-05 17:49:23 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -27,7 +27,6 @@ StringXNumber WarpOptions_Number[] = { {GMSH_FULLRC, "Factor", NULL, 1.}, {GMSH_FULLRC, "TimeStep", NULL, 0.}, {GMSH_FULLRC, "SmoothingAngle", NULL, 180.}, - {GMSH_FULLRC, "Explode", NULL, 1.}, {GMSH_FULLRC, "dView", NULL, -1.}, {GMSH_FULLRC, "iView", NULL, -1.} }; @@ -40,19 +39,13 @@ extern "C" } } - -GMSH_WarpPlugin::GMSH_WarpPlugin() -{ - ; -} - void GMSH_WarpPlugin::getName(char *name) const { strcpy(name, "Warp"); } void GMSH_WarpPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); @@ -86,174 +79,106 @@ void GMSH_WarpPlugin::catchErrorMessage(char *errorMessage) const strcpy(errorMessage, "Warp failed..."); } -static void addNormals(List_T *listElm, int nbElm, int nbNod, - smooth_normals *normals) -{ - if(!nbElm || nbNod < 3) return; - int nb = List_Nbr(listElm) / nbElm; - for(int i = 0; i < List_Nbr(listElm); i += nb) { - double *x = (double *)List_Pointer_Fast(listElm, i); - double *y = (double *)List_Pointer_Fast(listElm, i + nbNod); - double *z = (double *)List_Pointer_Fast(listElm, i + 2 * nbNod); - double nn[3]; - normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], nn); - for(int k = 0; k < nbNod; k++) - normals->add(x[k], y[k], z[k], nn[0], nn[1], nn[2]); - } -} - -static void warpList(List_T *iList, int iNbElm, - List_T *dList, int dNbElm, - int nbNod, double factor, int TimeStep, - int nbComp, smooth_normals *normals, double explode) -{ - if(!iNbElm) - return; - - if(!normals && (iNbElm != dNbElm)){ - Msg(GERROR, "Views have a different number of elements (%d != %d)", - iNbElm, dNbElm); - return; - } - - // for each element - // for each node - // (x,y,z) += factor * (valx,valy,valz) - - int iNb = List_Nbr(iList) / iNbElm; - int dNb = normals ? 0 : List_Nbr(dList) / dNbElm; - for(int i = 0, j = 0; i < List_Nbr(iList); i += iNb, j += dNb) { - double *x = (double *)List_Pointer_Fast(iList, i); - double *y = (double *)List_Pointer_Fast(iList, i + nbNod); - double *z = (double *)List_Pointer_Fast(iList, i + 2 * nbNod); - double *val; - if(normals) - val = (double *)List_Pointer_Fast(iList, i + 3 * nbNod); - else - val = (double *)List_Pointer_Fast(dList, j + 3 * nbNod); - - double nn[3] = {0., 0., 1.}; - if(normals && nbNod > 2) - normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], nn); - - for(int k = 0; k < nbNod; k++) { - if(normals){ - double d = 1.; - if(TimeStep >= 0){ - double *v = &val[nbComp * nbNod * TimeStep + nbComp * k]; - if(nbComp == 1) - d = v[0]; - else if(nbComp == 3) - d = sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2])); - else if(nbComp == 9) - d = ComputeVonMises(v); - } - normals->get(x[k], y[k], z[k], nn[0], nn[1], nn[2]); - x[k] += factor * d * nn[0]; - y[k] += factor * d * nn[1]; - z[k] += factor * d * nn[2]; - } - else{ - if(TimeStep < 0) TimeStep = 0; - x[k] += factor * val[3 * nbNod * TimeStep + 3 * k]; - y[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 1]; - z[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 2]; - } - } - - if(explode != 1.){ - double cg[3] = {0., 0., 0.}; - for(int k = 0; k < nbNod; k++) { - cg[0] += x[k]; - cg[1] += y[k]; - cg[2] += z[k]; - } - for(int k = 0; k < 3; k++) cg[k] /= (double)nbNod; - for(int k = 0; k < nbNod; k++) { - x[k] = cg[0] + explode * (x[k] - cg[0]); - y[k] = cg[1] + explode * (y[k] - cg[1]); - z[k] = cg[2] + explode * (z[k] - cg[2]); - } - } - - } - -} - -static void warp(PViewDataList *data1, PViewDataList *data2, double factor, - int ts, double tol, double e) -{ - smooth_normals *nn = 0; - if(WarpOptions_Number[4].def < 0){ - nn = new smooth_normals(tol); - addNormals(data1->ST, data1->NbST, 3, nn); - addNormals(data1->VT, data1->NbVT, 3, nn); - addNormals(data1->TT, data1->NbTT, 3, nn); - addNormals(data1->SQ, data1->NbSQ, 4, nn); - addNormals(data1->VQ, data1->NbVQ, 4, nn); - addNormals(data1->TQ, data1->NbTQ, 4, nn); - } - - warpList(data1->SP, data1->NbSP, data2->VP, data2->NbVP, 1, factor, ts, 1, nn, e); - warpList(data1->SL, data1->NbSL, data2->VL, data2->NbVL, 2, factor, ts, 1, nn, e); - warpList(data1->ST, data1->NbST, data2->VT, data2->NbVT, 3, factor, ts, 1, nn, e); - warpList(data1->SQ, data1->NbSQ, data2->VQ, data2->NbVQ, 4, factor, ts, 1, nn, e); - warpList(data1->SS, data1->NbSS, data2->VS, data2->NbVS, 4, factor, ts, 1, nn, e); - warpList(data1->SH, data1->NbSH, data2->VH, data2->NbVH, 8, factor, ts, 1, nn, e); - warpList(data1->SI, data1->NbSI, data2->VI, data2->NbVI, 6, factor, ts, 1, nn, e); - warpList(data1->SY, data1->NbSY, data2->VY, data2->NbVY, 5, factor, ts, 1, nn, e); - - warpList(data1->VP, data1->NbVP, data2->VP, data2->NbVP, 1, factor, ts, 3, nn, e); - warpList(data1->VL, data1->NbVL, data2->VL, data2->NbVL, 2, factor, ts, 3, nn, e); - warpList(data1->VT, data1->NbVT, data2->VT, data2->NbVT, 3, factor, ts, 3, nn, e); - warpList(data1->VQ, data1->NbVQ, data2->VQ, data2->NbVQ, 4, factor, ts, 3, nn, e); - warpList(data1->VS, data1->NbVS, data2->VS, data2->NbVS, 4, factor, ts, 3, nn, e); - warpList(data1->VH, data1->NbVH, data2->VH, data2->NbVH, 8, factor, ts, 3, nn, e); - warpList(data1->VI, data1->NbVI, data2->VI, data2->NbVI, 6, factor, ts, 3, nn, e); - warpList(data1->VY, data1->NbVY, data2->VY, data2->NbVY, 5, factor, ts, 3, nn, e); - - warpList(data1->TP, data1->NbTP, data2->VP, data2->NbVP, 1, factor, ts, 9, nn, e); - warpList(data1->TL, data1->NbTL, data2->VL, data2->NbVL, 2, factor, ts, 9, nn, e); - warpList(data1->TT, data1->NbTT, data2->VT, data2->NbVT, 3, factor, ts, 9, nn, e); - warpList(data1->TQ, data1->NbTQ, data2->VQ, data2->NbVQ, 4, factor, ts, 9, nn, e); - warpList(data1->TS, data1->NbTS, data2->VS, data2->NbVS, 4, factor, ts, 9, nn, e); - warpList(data1->TH, data1->NbTH, data2->VH, data2->NbVH, 8, factor, ts, 9, nn, e); - warpList(data1->TI, data1->NbTI, data2->VI, data2->NbVI, 6, factor, ts, 9, nn, e); - warpList(data1->TY, data1->NbTY, data2->VY, data2->NbVY, 5, factor, ts, 9, nn, e); - - if(nn) delete nn; -} - PView *GMSH_WarpPlugin::execute(PView *v) { double factor = WarpOptions_Number[0].def; int TimeStep = (int)WarpOptions_Number[1].def; double AngleTol = WarpOptions_Number[2].def; - double Explode = WarpOptions_Number[3].def; - int dView = (int)WarpOptions_Number[4].def; - int iView = (int)WarpOptions_Number[5].def; + int dView = (int)WarpOptions_Number[3].def; + int iView = (int)WarpOptions_Number[4].def; PView *v1 = getView(iView, v); if(!v1) return v; - - PViewDataList *data1 = getDataList(v1); - if(!data1) return v; - if(dView < 0) dView = iView; - PView *v2 = getView(dView, v); if(!v2) return v; - PViewDataList *data2 = getDataList(v2); - if(!data2) return v; + PViewData *data1 = v1->getData(); + PViewData *data2 = v2->getData(); - if(TimeStep > data2->getNumTimeSteps() - 1){ - // we allow TimeStep < 0 (to apply fixed warps) + // sanity checks + if(data1->getNumEntities() != data2->getNumEntities() || + data1->getNumElements() != data2->getNumElements()){ + Msg(GERROR, "Incompatible views"); + return v; + } + if(TimeStep < 0 || TimeStep > data2->getNumTimeSteps() - 1){ Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", TimeStep, v2->getIndex()); return v; } + + // create smooth normal field if we don't have an explicit warp field + smooth_normals *normals = 0; + if(dView < 0){ + normals = new smooth_normals(AngleTol); + for(int ent = 0; ent < data1->getNumEntities(0); ent++){ + for(int ele = 0; ele < data1->getNumElements(0, ent); ele++){ + if(data1->skipElement(0, ent, ele)) continue; + int numEdges = data1->getNumEdges(0, ent, ele); + if(numEdges == 3 || numEdges == 4){ + double x[4], y[4], z[4], n[4]; + for(int nod = 0; nod < numEdges; nod++) + data1->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); + normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n); + for(int nod = 0; nod < numEdges; nod++) + normals->add(x[nod], y[nod], z[nod], n[0], n[1], n[2]); + } + } + } + } + + // tag all the nodes with "0" (the default tag) + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + for(int ent = 0; ent < data1->getNumEntities(step); ent++){ + for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ + if(data1->skipElement(step, ent, ele)) continue; + int numNodes = data1->getNumNodes(step, ent, ele); + for(int nod = 0; nod < numNodes; nod++){ + double x, y, z; + data1->getNode(step, ent, ele, nod, x, y, z); + data1->setNode(step, ent, ele, nod, x, y, z, 0); + } + } + } + } - warp(data1, data2, factor, TimeStep, AngleTol, Explode); + // transform each "0" node: (x,y,z) += factor * mult * (valx, valy, valz) + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + for(int ent = 0; ent < data1->getNumEntities(step); ent++){ + for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ + if(data1->skipElement(step, ent, ele)) continue; + int numNodes = data1->getNumNodes(step, ent, ele); + double x[8], y[8], z[8], n[3] = {0., 0., 0.}; + int tag[8]; + for(int nod = 0; nod < numNodes; nod++) + tag[nod] = data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]); + int dim = data1->getDimension(step, ent, ele); + if(normals && dim == 2) + normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n); + for(int nod = 0; nod < numNodes; nod++){ + if(tag[nod]) continue; // already transformed + double mult = 1., val[3] = {n[0], n[1], n[2]}; + if(normals){ + if(dim == 2){ + normals->get(x[nod], y[nod], z[nod], val[0], val[1], val[2]); + data1->getScalarValue(step, ent, ele, nod, mult); + } + } + else if(data2->getNumComponents(TimeStep, ent, ele) == 3 && + data2->getNumNodes(TimeStep, ent, ele) == numNodes){ + for(int comp = 0; comp < 3; comp++) + data2->getValue(TimeStep, ent, ele, nod, comp, val[comp]); + } + x[nod] += factor * mult * val[0]; + y[nod] += factor * mult * val[1]; + z[nod] += factor * mult * val[2]; + data1->setNode(step, ent, ele, nod, x[nod], y[nod], z[nod], 1); + } + } + } + } + + if(normals) delete normals; data1->finalize(); v1->setChanged(true); diff --git a/Plugin/Warp.h b/Plugin/Warp.h index 81ca9c7f28c0df32db4a84c1d61290106e008b73..04f9272b2dd4b70a023f2579459ea4cea5341020 100644 --- a/Plugin/Warp.h +++ b/Plugin/Warp.h @@ -30,12 +30,12 @@ extern "C" class GMSH_WarpPlugin : public GMSH_Post_Plugin { public: - GMSH_WarpPlugin(); + GMSH_WarpPlugin(){} void getName(char *name) const; void getInfos(char *author, char *copyright, char *help_text) const; void catchErrorMessage(char *errorMessage) const; int getNbOptions() const; - StringXNumber* getOption(int iopt); + StringXNumber *getOption(int iopt); PView *execute(PView *); };