Skip to content
Snippets Groups Projects
Commit e35d300d authored by Gilles Marckmann's avatar Gilles Marckmann
Browse files

PViewX3D is a extension for Post-processing outputs :

creates a file in X3D format with the same features as what is visible in post-processing screen.
contact : gilles.marckmann@ec-nantes.fr
parent e34a7db3
No related branches found
No related tags found
No related merge requests found
......@@ -322,6 +322,8 @@ static int _save_view_med(const char *name){ return genericViewFileDialog
(name, "MED Options", 6); }
static int _save_view_txt(const char *name){ return genericViewFileDialog
(name, "TXT Options", 4); }
static int _save_view_wrl(const char *name){ return genericViewFileDialog
(name, "X3D Options", 7); }
static int _save_auto(const char *name)
{
......@@ -405,6 +407,7 @@ static void file_save_as_cb(Fl_Widget *w, void *data)
{"Mesh - PLY2 Surface" TT "*.ply2", _save_ply2},
{"Mesh - SU2" TT "*.su2", _save_su2},
{"Post-processing - Gmsh POS" TT "*.pos", _save_view_pos},
{"Post-processing - X3D (X3D)" TT "*.x3d", _save_view_wrl},
#if defined(HAVE_MED)
{"Post-processing - MED" TT "*.rmed", _save_view_med},
#endif
......
......@@ -408,6 +408,7 @@ class drawPView {
// use adaptive data if available
PViewData *data = p->getData(true);
PViewOptions *opt = p->getOptions();
p->setDrawContext(_ctx);
if(data->getDirty() || !data->getNumTimeSteps()) return;
if(!opt->visible || opt->type != PViewOptions::Plot3D) return;
......
......@@ -5,7 +5,7 @@
set(SRC
PView.cpp PViewIO.cpp PViewVertexArrays.cpp
PViewData.cpp PViewDataIO.cpp
PViewData.cpp PViewDataIO.cpp PViewX3D.cpp
PViewDataList.cpp PViewDataListIO.cpp
PViewDataGModel.cpp PViewDataGModelIO.cpp
PViewOptions.cpp
......
......@@ -354,3 +354,4 @@ double PView::getMemoryInMb()
mem += getData()->getMemoryInMb();
return mem;
}
......@@ -10,6 +10,8 @@
#include <map>
#include <string>
#include "SPoint3.h"
#include "drawContext.h"
class PViewData;
class PViewOptions;
......@@ -75,6 +77,8 @@ class PView{
// get/set the view data
PViewData *getData(bool useAdaptiveIfAvailable=false);
void setData(PViewData *val){ _data = val; }
// current drawContext
drawContext *_ctx;
// get the view tag (unique and immutable)
int getTag(){ return _tag; }
......@@ -93,6 +97,7 @@ class PView{
// get/set the eye position (for transparency calculations)
SPoint3 &getEye(){ return _eye; }
void setEye(SPoint3 &p){ _eye = p; }
void setDrawContext(drawContext *ctx){_ctx=ctx;}
// get (approx.) memory used by the view, in Mb
double getMemoryInMb();
......@@ -121,7 +126,7 @@ class PView{
static bool readPOS(const std::string &fileName, int fileIndex=-1);
static bool readMSH(const std::string &fileName, int fileIndex=-1);
static bool readMED(const std::string &fileName, int fileIndex=-1);
static bool writeX3D(const std::string &fileName );
// IO write routine
bool write(const std::string &fileName, int format, bool append=false);
......@@ -137,6 +142,9 @@ class PView{
// smoothed normals
smooth_normals *normals;
};
// this is the maximum number of nodes of elements we actually *draw*
......@@ -147,4 +155,8 @@ void changeCoordinates(PView *p, int ient, int iele,
double **xyz, double **val);
bool isElementVisible(PViewOptions *opt, int dim, int numNodes,
double **xyz);
#endif
......@@ -104,6 +104,8 @@ bool PViewData::writeTXT(const std::string &fileName)
return true;
}
bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed,
bool append)
{
......@@ -193,6 +195,9 @@ bool PViewData::writeMED(const std::string &fileName)
return false;
}
bool PViewData::toVector(std::vector<std::vector<double> > &vec)
{
vec.resize(getNumTimeSteps());
......
......@@ -6,8 +6,11 @@
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "PView.h"
#include "PViewData.h"
#include "PViewOptions.h"
#include "PViewDataList.h"
#include "PViewDataGModel.h"
#include "VertexArray.h"
#include "StringUtils.h"
#include "Context.h"
#include "OS.h"
......@@ -302,6 +305,7 @@ bool PView::write(const std::string &fileName, int format, bool append)
0, true, CTX::instance()->post.forceNodeData,
CTX::instance()->post.forceElementData); break;
case 6: ret = _data->writeMED(fileName); break;
case 7: ret = writeX3D(fileName); break;
case 10:
{
std::string ext = SplitFileName(fileName)[2];
......@@ -326,3 +330,6 @@ bool PView::write(const std::string &fileName, int format, bool append)
if(ret) Msg::StatusBar(true, "Done writing '%s'", fileName.c_str());
return ret;
}
This diff is collapsed.
// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
//
// PViewX3D is a extension for Post-processing outputs :
// creates a file in X3D format with the same features as
// what is visible in post-processing screen.
// contact : gilles.marckmann@ec-nantes.fr
#ifndef _PVIEWX3D_H_
#define _PVIEWX3D_H_
#include <iostream>
using namespace std;
static inline void UnsignedChar2rgba(unsigned char *glc,double*rgba){
rgba[0]=glc[0]/255.;
rgba[1]=glc[1]/255.;
rgba[2]=glc[2]/255.;
rgba[3]=glc[3]/255.;
}
static inline void unsignedInt2RGBA(unsigned int &color,double &r,double &g, double &b,double &a)
{
r = color & 255;
g = (color >> 8) & 255;
b = (color >> 16) & 255;
a = (color >> 24) & 255;
r =r /255.;
g =g /255.;
b =b /255.;
a =a /255.;
// cout<< "couleur="<<color<<" / decomposition: "<<" r="<<r<<", g="<<g<<", b="<<b<<", a="<<a<<endl;
return;
}
static void writeX3DScale(FILE *fp, PView *p, double xmin, double ymin, double width, double height, double tic, int horizontal,double ratio);
static void writeX3DScaleBar(FILE *fp, PView *p, double xmin, double ymin, double width, double height, double tic, int horizontal);
static void writeX3DScaleValues(FILE *fp, PView *p, double xmin, double ymin, double width, double height, double tic, int horizontal,double ratio);
static void writeX3DScaleLabel (FILE *fp, PView *p, double xmin, double ymin, double width, double height, double tic, int horizontal,double ratio);
static void writeX3DStringCenter( FILE *fp,char *label,double x, double y, double z,double font_size);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment