File: spline.cpp

package info (click to toggle)
gmsh 4.15.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,880 kB
  • sloc: cpp: 440,657; ansic: 114,930; f90: 15,611; python: 13,907; yacc: 7,438; java: 3,491; lisp: 3,206; lex: 633; perl: 571; makefile: 500; xml: 414; sh: 407; javascript: 113; modula3: 32
file content (45 lines) | stat: -rw-r--r-- 1,569 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <gmsh.h>
#include <set>

int main(int argc, char **argv)
{
  gmsh::initialize(argc, argv);

  gmsh::model::add("spline");

  for(unsigned int i = 1; i < 11; i++)
    gmsh::model::occ::addPoint(i + 1, sin(i / 9. * 2. * M_PI), 0, 0.1, i);

  gmsh::model::occ::addSpline({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 1);
  gmsh::model::occ::addBSpline({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 2);
  gmsh::model::occ::addBezier({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 3);

  gmsh::model::occ::addPoint(0.2, -1.6, 0, 0.1, 101);
  gmsh::model::occ::addPoint(1.2, -1.6, 0, 0.1, 102);
  gmsh::model::occ::addPoint(1.2, -1.1, 0, 0.1, 103);
  gmsh::model::occ::addPoint(0.3, -1.1, 0, 0.1, 104);
  gmsh::model::occ::addPoint(0.7, -1, 0, 0.1, 105);

  // periodic bspline through the control points
  gmsh::model::occ::addSpline({103, 102, 101, 104, 105, 103}, 100);

  // periodic bspline from given control points and default parameters - will
  // create a new vertex
  gmsh::model::occ::addBSpline({103, 102, 101, 104, 105, 103}, 101);

  // general bspline with explicit degree, knots and multiplicities
  gmsh::model::occ::addPoint(0, -2, 0, 0.1, 201);
  gmsh::model::occ::addPoint(1, -2, 0, 0.1, 202);
  gmsh::model::occ::addPoint(1, -3, 0, 0.1, 203);
  gmsh::model::occ::addPoint(0, -3, 0, 0.1, 204);
  gmsh::model::occ::addBSpline({201, 202, 203, 204}, 200, 2, {}, {0, 0.5, 1},
                               {3, 1, 3});

  gmsh::model::occ::synchronize();

  std::set<std::string> args(argv, argv + argc);
  if(!args.count("-nopopup")) gmsh::fltk::run();

  gmsh::finalize();
  return 0;
}