#include <iostream>
using namespace gismo;
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)
{
gsWriteParaview( curve, "bsplinecurve", 100);
}
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;
}