gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
6 #include "GmshConfig.h"
17 #if defined(HAVE_OPENGL)
21 #if defined(HAVE_FLTK)
23 #include "graphicWindow.h"
24 #include "openglWindow.h"
37 else if(ext ==
".py_unrolled")
return FORMAT_PY;
40 else if(ext ==
".msh1") {
if(version) *version = 1.0;
return FORMAT_MSH; }
41 else if(ext ==
".msh2") {
if(version) *version = 2.2;
return FORMAT_MSH; }
42 else if(ext ==
".msh22") {
if(version) *version = 2.2;
return FORMAT_MSH; }
43 else if(ext ==
".msh3") {
if(version) *version = 3.0;
return FORMAT_MSH; }
44 else if(ext ==
".msh4") {
if(version) *version = 4.1;
return FORMAT_MSH; }
45 else if(ext ==
".msh40") {
if(version) *version = 4.0;
return FORMAT_MSH; }
46 else if(ext ==
".msh41") {
if(version) *version = 4.1;
return FORMAT_MSH; }
112 case FORMAT_GEO: name =
".geo_unrolled";
break;
113 case FORMAT_PY: name =
".py_unrolled";
break;
114 case FORMAT_MSH: name =
".msh"; mesh =
true;
break;
116 case FORMAT_X3D: name =
".x3d"; mesh =
true;
break;
119 case FORMAT_UNV: name =
".unv"; mesh =
true;
break;
120 case FORMAT_VTK: name =
".vtk"; mesh =
true;
break;
123 case FORMAT_STL: name =
".stl"; mesh =
true;
break;
124 case FORMAT_CGNS: name =
".cgns"; mesh =
true;
break;
125 case FORMAT_MED: name =
".med"; mesh =
true;
break;
127 case FORMAT_IR3: name =
".ir3"; mesh =
true;
break;
128 case FORMAT_MESH: name =
".mesh"; mesh =
true;
break;
129 case FORMAT_OFF: name =
".off"; mesh =
true;
break;
130 case FORMAT_MAIL: name =
".mail"; mesh =
true;
break;
131 case FORMAT_BDF: name =
".bdf"; mesh =
true;
break;
132 case FORMAT_DIFF: name =
".diff"; mesh =
true;
break;
133 case FORMAT_INP: name =
".inp"; mesh =
true;
break;
134 case FORMAT_KEY: name =
".key"; mesh =
true;
break;
135 case FORMAT_RAD: name =
".rad"; mesh =
true;
break;
137 case FORMAT_SU2: name =
".su2"; mesh =
true;
break;
138 case FORMAT_P3D: name =
".p3d"; mesh =
true;
break;
139 case FORMAT_VRML: name =
".wrl"; mesh =
true;
break;
140 case FORMAT_PLY2: name =
".ply2"; mesh =
true;
break;
157 case FORMAT_NEU: name =
".neu"; mesh =
true;
break;
159 default: name =
"";
break;
161 if(onlyMeshFormats && !mesh)
return "";
168 std::string name = split[0] + split[1];
175 std::string all =
"auto, msh1, msh2, msh22, msh3, msh4, msh40, msh41";
176 for(
int i = 1; i < 1000; i++){
179 all +=
", " + ext.substr(1);
185 #if defined(HAVE_FLTK)
186 static PixelBuffer *GetCompositePixelBuffer(GLenum format, GLenum type)
188 openglWindow *newg =
nullptr;
191 GLint width = FlGui::instance()->getCurrentOpenglWindow()->pixel_w();
192 GLint height = FlGui::instance()->getCurrentOpenglWindow()->pixel_h();
207 newg =
new openglWindow(100, 100, width, height);
208 int mode = FL_RGB | FL_DEPTH | (
CTX::instance()->
db ? FL_DOUBLE : FL_SINGLE);
212 newg->getDrawContext()->copyViewAttributes
213 (FlGui::instance()->getCurrentOpenglWindow()->getDrawContext());
215 openglWindow::setLastHandled(newg);
219 while(!newg->valid()) Fl::wait();
224 GLint width = FlGui::instance()->getCurrentOpenglWindow()->pixel_w();
225 GLint height = FlGui::instance()->getCurrentOpenglWindow()->pixel_h();
226 buffer =
new PixelBuffer(width, height, format, type);
230 graphicWindow *g = FlGui::instance()->graph[0];
231 for(std::size_t i = 1; i < FlGui::instance()->graph.size(); i++){
232 for(std::size_t j = 0; j < FlGui::instance()->graph[i]->gl.size(); j++){
233 if(FlGui::instance()->graph[i]->gl[j] ==
234 FlGui::instance()->getCurrentOpenglWindow()){
235 g = FlGui::instance()->graph[i];
240 int xmin = 10000000, ymin = 10000000;
241 for(std::size_t i = 0; i < g->gl.size(); i++){
242 xmin = std::min(xmin, g->gl[i]->x());
243 ymin = std::min(ymin, g->gl[i]->y());
246 std::vector<PixelBuffer*> buffers;
247 for(std::size_t i = 0; i < g->gl.size(); i++){
248 openglWindow::setLastHandled(g->gl[i]);
249 buffer =
new PixelBuffer(g->gl[i]->pixel_w(), g->gl[i]->pixel_h(),
252 buffers.push_back(buffer);
253 double fact = g->gl[i]->getDrawContext()->highResolutionPixelFactor();
254 ww = std::max(ww, (
int)(fact * (g->gl[i]->x() - xmin)) + g->gl[i]->pixel_w());
255 hh = std::max(hh, (
int)(fact * (g->gl[i]->y() - ymin)) + g->gl[i]->pixel_h());
258 for(std::size_t i = 0; i < g->gl.size(); i++){
259 double fact = g->gl[i]->getDrawContext()->highResolutionPixelFactor();
260 buffer->
copyPixels(fact * (g->gl[i]->x() - xmin),
261 hh - g->gl[i]->pixel_h() - fact * (g->gl[i]->y() - ymin),
268 openglWindow::setLastHandled(
nullptr);
282 if(steps <= 0) steps = 1;
283 double step = (last - first) / steps;
285 Msg::Info(
"Setting Print.Parameter = %g", v);
293 std::string name = fileName;
324 splitName[0] += splitName[1];
339 splitName[0] += splitName[1] +
"_topology.pro";
502 Msg::Error(
"No OpenCASCADE CAD data found for BREP export");
511 Msg::Error(
"No suitable CAD data found for STEP export");
523 Msg::Error(
"No Parasolid CAD data found for XMT export");
526 #if defined(HAVE_FLTK)
533 if(!FlGui::available()){
534 Msg::Error(
"Creating '%s' requires a graphical interface context", name.c_str());
538 FILE *fp =
Fopen(name.c_str(),
"wb");
540 Msg::Error(
"Unable to open file '%s'", name.c_str());
545 PixelBuffer *buffer = GetCompositePixelBuffer(GL_RGB, GL_UNSIGNED_BYTE);
575 if(!FlGui::available()){
576 Msg::Error(
"Creating '%s' requires a graphical interface context", name.c_str());
580 FILE *fp =
Fopen(name.c_str(),
"wb");
582 Msg::Error(
"Unable to open file '%s'", name.c_str());
587 GLint width = FlGui::instance()->getCurrentOpenglWindow()->pixel_w();
588 GLint height = FlGui::instance()->getCurrentOpenglWindow()->pixel_h();
589 GLint pixel_viewport[4] = {0, 0, width, height};
591 PixelBuffer buffer(width, height, GL_RGB, GL_FLOAT);
617 buffsize += 2048 * 2048;
619 psformat, pssort, psoptions, GL_RGBA, 0,
nullptr,
620 15, 20, 10, buffsize, fp, base.c_str());
623 glGetDoublev(GL_PROJECTION_MATRIX,
projection);
624 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
625 glMatrixMode(GL_PROJECTION);
627 glOrtho((
double)pixel_viewport[0], (
double)pixel_viewport[2],
628 (
double)pixel_viewport[1], (
double)pixel_viewport[3], -1., 1.);
629 glMatrixMode(GL_MODELVIEW);
633 glMatrixMode(GL_PROJECTION);
635 glMatrixMode(GL_MODELVIEW);
636 glLoadMatrixd(modelview);
651 if(!FlGui::available()){
652 Msg::Error(
"Creating '%s' requires a graphical interface context", name.c_str());
656 FILE *fp =
Fopen(name.c_str(),
"w");
658 Msg::Error(
"Unable to open file '%s'", name.c_str());
663 GLint width = FlGui::instance()->getCurrentOpenglWindow()->pixel_w();
664 GLint height = FlGui::instance()->getCurrentOpenglWindow()->pixel_h();
666 GLfloat scaling = 1.;
667 if(width_desired_in_mm > 0) {
668 GLfloat width_desired_in_pt = width_desired_in_mm * 72.27 / 25.4;
669 scaling = width_desired_in_pt / width;
671 GLint pixel_viewport[4] = {0, 0, width, height};
675 buffsize += 2048 * 2048;
680 0, 0, 0, buffsize, fp, base.c_str());
694 if(!FlGui::available()){
695 Msg::Error(
"Creating '%s' requires a graphical interface context", name.c_str());
714 PixelBuffer *buffer = GetCompositePixelBuffer(GL_RGB, GL_UNSIGNED_BYTE);
715 drawContext *ctx = FlGui::instance()->getCurrentOpenglWindow()->getDrawContext();
716 GLint width = FlGui::instance()->getCurrentOpenglWindow()->pixel_w();
717 GLint height = FlGui::instance()->getCurrentOpenglWindow()->pixel_h();
718 GLint pixel_viewport[4] = {0, 0, width, height};
729 #if defined(HAVE_MPEG_ENCODE)
733 if(!FlGui::available()){
734 Msg::Error(
"Creating '%s' requires a graphical interface context", name.c_str());
741 fp =
Fopen(parFileName.c_str(),
"w");
743 Msg::Error(
"Unable to open file '%s'", parFileName.c_str());
753 for(
int i = 0; i < numViews; i++){
755 numSteps = std::max(numSteps,
766 std::vector<std::string> frames;
769 sprintf(tmp,
".gmsh-%06d.ppm", (
int)frames.size());
770 frames.push_back(tmp);
773 status_play_manual(!cycle, 0,
false);
774 for(std::size_t i = 0; i < frames.size(); i++){
789 if(repeat < 1) repeat = 1;
790 std::string pattern(
"I");
794 fprintf(fp,
"PATTERN %s\nBASE_FILE_FORMAT PPM\nGOP_SIZE %d\n"
795 "SLICES_PER_FRAME 1\nPIXEL FULL\nRANGE 10\n"
796 "PSEARCH_ALG EXHAUSTIVE\nBSEARCH_ALG CROSS2\n"
797 "IQSCALE 1\nPQSCALE 1\nBQSCALE 25\nREFERENCE_FRAME DECODED\n"
798 "OUTPUT %s\nINPUT_CONVERT *\nINPUT_DIR %s\nINPUT\n",
799 pattern.c_str(), repeat, name.c_str(),
801 for(std::size_t i = 0; i < frames.size(); i++){
802 fprintf(fp,
"%s", frames[i].c_str());
803 if(repeat > 1) fprintf(fp,
" [1-%d]", repeat);
806 fprintf(fp,
"END_INPUT\n");
808 extern int mpeg_encode_main(
int,
char**);
809 char *args[] = {(
char*)
"gmsh", (
char*)parFileName.c_str()};
811 mpeg_encode_main(2, args);
813 catch (
const char *msg){
819 for(std::size_t i = 0; i < frames.size(); i++)
std::string GetKnownFileFormats(bool onlyMeshFormats)
int writeCGNS(const std::string &name, bool saveAll=false, double scalingFactor=1.0, bool structured=false)
std::vector< std::string > SplitFileName(const std::string &fileName)
int writeMAIL(const std::string &name, bool saveAll, double scalingFactor)
double opt_view_show_scale(OPT_ARGS_NUM)
int writePartitionedTopology(std::string &name)
GL2PSDLL_API GLint gl2psSetTexScaling(GLfloat scaling)
int GuessFileFormatFromFileName(const std::string &fileName, double *version)
int writeVRML(const std::string &name, bool saveAll=false, double scalingFactor=1.0)
int writeNEU(const std::string &name, bool saveAll, double scalingFactor)
int writeKEY(const std::string &name, int saveAll=0, int saveGroupsOfNodes=0, double scalingFactor=1.0)
int writeGEO(const std::string &name, bool printLabels=true, bool onlyPhysicals=false)
std::string GetDefaultFileExtension(int format, bool onlyMeshFormats)
static void Info(const char *fmt,...)
int writeOFF(const std::string &name, bool saveAll=false, double scalingFactor=1.0)
int stlOneSolidPerSurface
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
double opt_general_small_axes(OPT_ARGS_NUM)
int writeP3D(const std::string &name, bool saveAll=false, double scalingFactor=1.0)
void CreateOutputFile(const std::string &fileName, int format, bool status)
static void Error(const char *fmt,...)
static void StatusBar(bool log, const char *fmt,...)
static void ChangePrintParameter(int frame)
int writeRAD(const std::string &name, int saveAll=0, int saveGroupsOfNodes=0, double scalingFactor=1.0)
static double projection(SPoint3 &p1, SPoint3 &p2, SPoint3 &q, SPoint3 &result)
virtual void drawCurrentOpenglWindow(bool make_current)
int writeCELUM(const std::string &name, bool saveAll=false, double scalingFactor=1.0)
int print_pgf(const std::string &name, const int num, const int cnt, PixelBuffer *buffer, double *eulerAngles, int *viewport, double *proj, double *model)
int writeX3D(const std::string &name, bool saveAll=false, double scalingFactor=1.0, int x3dsurfaces=1, int x3dedges=0, int x3dvertices=0, int x3dvolumes=0, int x3dcolorize=0)
int UnlinkFile(const std::string &fileName)
#define GL2PS_NO_TEX_FONTSIZE
#define FORMAT_MPEG_PREVIEW
int writePLY2(const std::string &name)
#define GL2PS_DRAW_BACKGROUND
static drawContextGlobal * global()
FILE * Fopen(const char *f, const char *mode)
std::string GetDefaultFileName(int format)
int writeDIFF(const std::string &name, bool binary=false, bool saveAll=false, double scalingFactor=1.0)
double opt_post_nb_views(OPT_ARGS_NUM)
virtual void draw(bool rateLimited=true)
void ParseString(const std::string &str, bool inCurrentModelDir)
int writePY(const std::string &name, bool printLabels=true, bool onlyPhysicals=false)
int writeSTL(const std::string &name, bool binary=false, bool saveAll=false, double scalingFactor=1.0, int oneSolidPerSurface=0)
void PrintOptions(int num, int level, int diff, int help, const char *filename, std::vector< std::string > *vec)
void create_png(FILE *file, PixelBuffer *buffer, int quality)
double opt_print_delete_tmp_files(OPT_ARGS_NUM)
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
int writeTOCHNOG(const std::string &name, bool saveAll=false, int saveGroupsOfNodes=0, double scalingFactor=1.0)
GL2PSDLL_API GLint gl2psEndPage(void)
void create_yuv(FILE *outfile, PixelBuffer *buffer)
int writeOCCBREP(const std::string &name)
int writeUNV(const std::string &name, bool saveAll=false, int saveGroupsOfElements=0, int saveGroupsOfNodes=0, double scalingFactor=1.0)
int writePOS(const std::string &name, bool printElementary, bool printElementNumber, bool printSICN, bool printSIGE, bool printGamma, bool printDisto, bool saveAll=false, double scalingFactor=1.0)
int writeINP(const std::string &name, bool saveAll=false, int saveGroupsOfElements=0, int saveGroupsOfNodes=0, double scalingFactor=1.0)
void create_ppm(FILE *outfile, PixelBuffer *buffer)
int writeMSH(const std::string &name, double version=2.2, bool binary=false, bool saveAll=false, bool saveParametric=false, double scalingFactor=1.0, int elementStartNum=0, int saveSinglePartition=0, bool append=false)
int writeParasolidXMT(const std::string &name)
int writeSU2(const std::string &name, bool saveAll, double scalingFactor)
double opt_view_nb_non_empty_timestep(OPT_ARGS_NUM)
int writeParasolidSTEP(const std::string &name)
int writeMESH(const std::string &name, int elementTagType=1, bool saveAll=false, double scalingFactor=1.0)
int GetFileFormatFromExtension(const std::string &ext, double *version)
int writeMATLAB(const std::string &name, bool binary=false, bool saveAll=false, double scalingFactor=1.0, int filetype=1)
#define GL2PS_SIMPLE_SORT
void create_gif(FILE *outfile, PixelBuffer *buffer, int dither, int sort, int interlace, int transparency)
void create_jpeg(FILE *outfile, PixelBuffer *buffer, int quality, int smoothing)
int writeVTK(const std::string &name, bool binary=false, bool saveAll=false, double scalingFactor=1.0, bool bigEndian=false)
void copyPixels(int x, int y, PixelBuffer *buffer)
void SleepInSeconds(double s)
int writeMED(const std::string &name, bool saveAll=false, double scalingFactor=1.0)
#define GL2PS_NO_PS3_SHADING
std::string parameterCommand
double opt_general_axes(OPT_ARGS_NUM)
int writeBDF(const std::string &name, int format=0, int elementTagType=1, bool saveAll=false, double scalingFactor=1.0)
double opt_view_visible(OPT_ARGS_NUM)
#define GL2PS_OCCLUSION_CULL
double opt_print_parameter(OPT_ARGS_NUM)
#define GL2PS_SIMPLE_LINE_OFFSET
static GModel * current(int index=-1)
int writeOCCSTEP(const std::string &name)
int writeIR3(const std::string &name, int elementTagType, bool saveAll, double scalingFactor)
int writePartitionedMSH(const std::string &baseName, double version=2.2, bool binary=false, bool saveAll=false, bool saveParametric=false, double scalingFactor=1.0)