#include <iostream>
int main(int argc, char *argv[])
{
bool plot = false;
bool trim = false;
bool intersect = false;
gsCmdLine cmd(
"Tutorial 01 shows the use of BSpline curves.");
cmd.addSwitch("plot", "Plot result in ParaView format", plot);
cmd.addSwitch("trim", "Basic trim/merge operations", trim);
cmd.addSwitch("intersect", "Intersection operations", intersect);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
coefs << 0, 0, 0,
1, 2, 3,
2, 1, 4,
4, 4, 4;
gsInfo <<
"I am a " << curve <<
"\n";
if (plot)
{
coefs.transposeInPlace();
gsWriteParaview( curve, "bsplinecurve0", 100);
gsWriteParaview( curve, "bsplinecurve", 100, true, true);
}
else
gsInfo <<
"Done. No output created, re-run with --plot to get a ParaView "
"file containing the solution.\n";
if (trim)
{
gsInfo <<
"Original BSpline curve: " << curve <<
"\n";
gsWriteParaview( curve, "originalCurve", 100);
gsInfo <<
"Curve segment from u0 = 0.3 to u1 = 0.8: " << segment <<
"\n";
gsWriteParaview(segment, "segment", 100);
curve.
splitAt(0.4, segmentLeft, segmentRight);
gsInfo <<
"Curve segment from u0 = 0.0 to u1 = 0.4: " << segmentLeft <<
"\n";
gsInfo <<
"Curve segment from u0 = 0.4 to u1 = 1.0: " << segmentRight <<
"\n";
gsWriteParaview( segmentLeft, "segmentLeft", 100);
gsWriteParaview( segmentRight, "segmentRight", 100);
mergedCurve.
merge(&segmentRight);
gsInfo <<
"The merged curve: " << mergedCurve <<
"\n";
gsWriteParaview( mergedCurve, "mergedCurve", 100);
gsWriteParaview(bezSegments, "bezierContainer", 100);
}
else
gsInfo <<
"Done. Re-run with --trim to learn basic trim/merge operations\n";
if (intersect)
{
ctrPts1 << 0,0, 1,1, 2,1, 3,1;
ctrPts2 << 0,0, 1,2, 2,2, 3,0;
auto intersectPts = bsp1.intersect(bsp2, 1e-5);
gsInfo << intersectPts.size() <<
" intersections are found!" <<
"\n";
gsMatrix<> iPts(bsp1.geoDim(), intersectPts.size());
for (size_t j = 0; j < intersectPts.size(); ++j)
{
iPts.col(j) = intersectPts[j].getPoint();
}
if (!intersectPts.empty())
{
}
gsWriteParaview(bsp1, "bsp1", 2000);
gsWriteParaview(bsp2, "bsp2", 2000);
}
else
gsInfo <<
"Done. Re-run with --intersect to learn intersection operations\n";
return 0;
}
A B-spline function of one argument, with arbitrary target dimension.
Definition gsBSpline.h:51
void merge(gsGeometry< T > *otherG)
Merge other B-spline into this one.
Definition gsBSpline.hpp:29
void splitAt(T u0, gsBSpline< T > &left, gsBSpline< T > &right, T tolerance=1e-15) const
Definition gsBSpline.hpp:255
gsBSpline< T > segmentFromTo(T u0, T u1, T tolerance=1e-15) const
Definition gsBSpline.hpp:87
Class for command-line argument parsing.
Definition gsCmdLine.h:57
static void open(const std::string &fn)
Opens the file fn using the preferred application of the OS.
Definition gsFileManager.cpp:688
Class for representing a knot vector.
Definition gsKnotVector.h:80
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
Main header to be included by clients using the G+Smo library.
#define gsInfo
Definition gsDebug.h:43
The G+Smo namespace, containing all definitions for the library.
void gsWriteParaviewPoints(gsMatrix< T > const &X, gsMatrix< T > const &Y, std::string const &fn)
Export 2D Point set to Paraview file.
Definition gsWriteParaview.hpp:1383