Stamper Tutorial
Introduction
The purpose of this tutorial is to provide explanation on how to use the classes defined in this library to perform feature stamping. The examples provided in this tutorial refer to test cases that are in the /tutorial/TutStamping.cpp source file.
The library contains classes for performing feature stamping. The basic idea is to associate cross sections with a center line to produce a new feature (a "fill" embankment, a "cut" channel). The output from the feature stamp is a TIN and a set of break lines defining distinct characteristics of the new feature, such as the center line, shoulder, toe, and end cap.
The xms::StStamperIo class is used to set up the inputs to the stamp operation and it also contains the outputs of the operation in the member variables m_outTin and m_outBreakLines;
Example - Fill Embankment Feature Stamp
The following example shows how to use the stamper to make a simple fill embankment. The testing code for this example is TutStampingTests::test_StampFillEmbankment.
{
cs.
m_left = {{0, 15}, {5, 15}, {6, 14}};
const int numPixelsX = 41, numPixelsY = 11;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-20.0, 0.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, 5);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testFillEmbankment_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testFillEmbankment_base.asc"));
xms::VecPt3d basePts = {{0, 0, 15}, {0, 10, 15}, {-5, 0, 15}, {-20, 0, 0}, {-5, 10, 15},
{-20, 10, 0}, {5, 0, 15}, {20, 0, 0}, {5, 10, 15}, {20, 10, 0}};
xms::VecInt baseLines = {0, 1};
baseLines = {3, 2, 0, 6, 7};
baseLines = {5, 4, 1, 8, 9};
baseLines = {3, 5};
baseLines = {7, 9};
baseLines = {2, 4};
baseLines = {6, 8};
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testFillEmbankmentTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image.
Example - Cut Embankment Feature Stamp
The following example shows how to use the stamper to make a simple cut embankment. This is just like the fill embankment but we have flipped the specified cross sections. The testing code for this example is TutStampingTests::test_StampCutEmbankment.
{
cs.
m_left = {{0, 0}, {5, 0}, {6, 1}};
const int numPixelsX = 41, numPixelsY = 11;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-20.0, 0.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, 5);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testCutEmbankment_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testCutEmbankment_base.asc"));
xms::VecPt3d basePts = {{0, 0, 0}, {0, 10, 0}, {-5, 0, 0}, {-20, 0, 15}, {-5, 10, 0},
{-20, 10, 15}, {5, 0, 0}, {20, 0, 15}, {5, 10, 0}, {20, 10, 15}};
xms::VecInt baseLines = {0, 1};
baseLines = {3, 2, 0, 6, 7};
baseLines = {5, 4, 1, 8, 9};
baseLines = {3, 5};
baseLines = {7, 9};
baseLines = {2, 4};
baseLines = {6, 8};
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testCutEmbankmentTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image.
Example - Wing Wall with Fill Embankment Feature Stamp
The following example shows how to use the stamper to make a fill embankment with a wing wall end cap with a specified angle. An angle can be specified with all end caps and it will affect the orientation of the end cap from the center line to the shoulder. The wing wall has an additional angle that can be specified that changes the orientation from the shoulder to the toe. The testing code for this example is TutStampingTests::test_StampWingWall.
{
cs.
m_left = {{0, 15}, {5, 15}, {6, 14}};
const int numPixelsX = 46, numPixelsY = 45;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-16.0, -8.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, XM_NODATA);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testWingWall_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testWingWall_base.asc"));
xms::VecPt3d basePts = {{0, 0, 15}, {20, 20, 15}, {-4.5, 2.6, 15}, {-15.1, 13.2, 0},
{17.4, 24.5, 15}, {7.7, 36, 0}, {4.5, -2.6, 15}, {21.2, -7.1, 0},
{22.6, 15.5, 15}, {28.2, 0, 0}};
xms::VecInt baseLines = {0, 1};
baseLines = {3, 2, 0, 6, 7};
baseLines = {5, 4, 1, 8, 9};
baseLines = {3, 5};
baseLines = {7, 9};
baseLines = {2, 4};
baseLines = {6, 8};
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testWingWallTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image.
Example - Sloped Abutment with Fill Embankment Feature Stamp
The following example shows how to use the stamper to make a fill embankment with a sloped abutment end cap. The testing code for this example is TutStampingTests::test_StampSlopedAbutment.
{
cs.
m_left = {{0, 15}, {5, 15}, {6, 14}};
const int numPixelsX = 56, numPixelsY = 53;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-17.0, -17.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, XM_NODATA);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testSlopedAbutment_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testSlopedAbutment_base.asc"));
xms::VecPt3d basePts = {
{0, 0, 15}, {20, 20, 15}, {-3.5, 3.5, 15}, {-14.1, 14.1, 0},
{15.2, 22.2, 15}, {4.6, 32.9, 0}, {3.5, -3.5, 15}, {14.1, -14.1, 0},
{24.8, 17.8, 15}, {35.4, 7.1, 0}, {-10.6, -3.5, 5}, {-12.9, -1.9, 4.2},
{-14.8, 0.5, 3.3}, {-16, 3.5, 2.5}, {-16.4, 7, 1.7}, {-15.8, 10.6, 0.8},
{-3.5, -10.6, 5.0}, {-1.9, -12.9, 4.2}, {0.5, -14.8, 3.3}, {3.5, -16.0, 2.5},
{7.0, -16.4, 1.7}, {10.6, -15.8, 0.8}, {19.4, 31.3, 5}, {16.6, 33.4, 3.8},
{13, 34.6, 2.5}, {8.8, 34.4, 1.3}, {29, 26.8, 5}, {31.8, 25.9, 4.3},
{34.3, 24.1, 3.6}, {36.4, 21.5, 2.9}, {37.7, 18.2, 2.1}, {38, 14.6, 1.4},
{37.3, 10.8, 0.7}};
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testSlopedAbutmentTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image.
Example - Guidebank with Fill Embankment Feature Stamp
The following example shows how to use the stamper to make a fill embankment with a guidebank end cap. The testing code for this example is TutStampingTests::test_StampGuidebank.
{
cs.
m_left = {{0, 15}, {5, 15}, {6, 14}};
const int numPixelsX = 90, numPixelsY = 81;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-21.0, -12.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, XM_NODATA);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testGuidebank_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testGuidebank_base.asc"));
TS_ASSERT_EQUALS(144, io.
m_outTin->Points().size());
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testGuidebankTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image.
Example - Fill Embankment Feature Stamp Intersecting Bathymetry
The following example shows how to use the stamper to make a fill embankment with an underlying bathymetry. The stamp is intersected and potentially cut off by the bathymetry. The testing code for this example is TutStampingTests::test_StampIntersectBathymetry.
{
cs.
m_left = {{0, 15}, {5, 15}, {6, 14}};
BSHP<xms::VecPt3d> tPts(new xms::VecPt3d());
*tPts = {{-1, 25, 6}, {-15, 11, 6}, {5, -11, 10}, {20, 4, 10}};
BSHP<xms::VecInt> tTris(new xms::VecInt());
*tTris = {0, 1, 2, 1, 3, 2};
tin->SetPoints(tPts);
tin->SetTriangles(tTris);
const int numPixelsX = 29, numPixelsY = 34;
const double pixelSize = 1.0;
const xms::Pt3d minPt(-10.0, -8.0);
const std::vector<double> rasterVals(numPixelsX * numPixelsY, XM_NODATA);
xms::XmStampRaster raster(numPixelsX, numPixelsY, pixelSize, pixelSize, minPt, rasterVals, XM_NODATA);
st->DoStamp(io);
std::string rasterFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testIntersectBathymetry_out.asc"));
std::string baseFile(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testIntersectBathymetry_base.asc"));
xms::VecPt3d basePts = {{0, 0, 15}, {10, 10, 15}, {-3.54, 3.54, 15},
{-9.42, 9.42, 6.68}, {6.46, 13.54, 15}, {-4.14, 24.14, 0},
{3.54, -3.54, 15}, {7.18, -7.18, 9.84}, {13.54, 6.46, 15},
{17.18, 2.82, 9.84}};
std::string tinFileName(XMS_TEST_PATH + std::string("stamping/rasterTestFiles/testIntersectBathymetryTin_out.tin"));
std::ofstream ofs(tinFileName, std::ofstream::trunc);
}
The output from this test looks like the following image. The red triangles are the bathymetry.