前言
前面写过三篇关于Gmsh的教程:
以上文章对Gmsh都有一定的介绍,在此不再重复直接接剖三维网格的C++代码。
注:因有一个OpenCASCADE库暂时没安装好,所以目前只能用插点,连线,线连面,面拼体的方式构造三维几何体。
一、程序代码
#include <iostream>
#include <gmsh.h>
#include <vector>
#include <fstream>
#include <iomanip>
using namespace std;
int main(int argc, char **argv)
{
// Before using any functions in the C++ API, Gmsh must be initialized.
gmsh::initialize();
// By default Gmsh will not print out any messages: in order to output
// messages on the terminal, just set the standard Gmsh option
// "General.Terminal" (same format and meaning as in .geo files) using
// gmsh::option::setNumber():
gmsh::option::setNumber("General.Terminal", 1);
// This adds a new model, named "t1". If gmsh::model::add() is not called, a
// new default (unnamed) model will be created on the fly, if necessary.
gmsh::model::add("Test1");
// The C++ API provides direct access to the internal CAD kernels. The
// built-in CAD kernel was used in t1.geo: the corresponding API functions
// live in the "gmsh::model::geo" namespace. To create geometrical points with
// the built-in CAD kernel, one thus uses gmsh::model::geo::addPoint():
//
// - the first 3 arguments are the point coordinates (x, y, z)
//
// - the next (optional) argument is the target mesh size close to the point
//
// - the last (optional) argument is the point tag
double lc = 1;
int pIndex = 1;
gmsh::model::geo::addPoint(-4, -4, -4, lc, pIndex++);
gmsh::model::geo::addPoint(4, -4, -4

最低0.47元/天 解锁文章
2012

被折叠的 条评论
为什么被折叠?



