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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <stdio.h>
#include <ctype.h>
#include <metaContour.h>
int main(int , char * [])
{
METAIO_STREAM::cout << "Creating test file ..." << METAIO_STREAM::endl;
MetaContour Contour(3);
Contour.ID(0);
Contour.Name("First Contour");
ContourControlPnt* pnt;
METAIO_STREAM::cout << "Allocating points..." << METAIO_STREAM::endl;
unsigned int i;
for(i=0;i<10;i++)
{
pnt = new ContourControlPnt(3);
pnt->m_Id = i;
pnt->m_XPicked[0]=0;
pnt->m_XPicked[1]=1;
pnt->m_XPicked[2]=2;
pnt->m_X[0]=(float)0.2;
pnt->m_X[1]=(float)i;
pnt->m_X[2]=(float)i;
Contour.GetControlPoints().push_back(pnt);
}
Contour.Interpolation(MET_EXPLICIT_INTERPOLATION);
ContourInterpolatedPnt* pntI;
for(i=0;i<5;i++)
{
pntI = new ContourInterpolatedPnt(3);
pntI->m_Id = i;
pntI->m_X[0]=(float)0.2;
pntI->m_X[1]=(float)i;
pntI->m_X[2]=(float)i;
Contour.GetInterpolatedPoints().push_back(pntI);
}
METAIO_STREAM::cout << "Writing test file ..." << METAIO_STREAM::endl;
Contour.BinaryData(true);
Contour.Write("C:/Julien/Contours.meta");
METAIO_STREAM::cout << " done" << METAIO_STREAM::endl;
METAIO_STREAM::cout << "Reading test file ..." << METAIO_STREAM::endl;
Contour.Read("C:/Julien/Contours.meta");
METAIO_STREAM::cout << " done" << METAIO_STREAM::endl;
Contour.PrintInfo();
METAIO_STREAM::cout << "Accessing pointlist..." << METAIO_STREAM::endl;
MetaContour::ControlPointListType plist = Contour.GetControlPoints();
MetaContour::ControlPointListType::const_iterator it = plist.begin();
while(it != plist.end())
{
METAIO_STREAM::cout << (*it)->m_Id << " ";
unsigned int d;
for(d = 0; d < 3; d++)
{
METAIO_STREAM::cout << (*it)->m_X[d] << " ";
}
for(d = 0; d < 3; d++)
{
METAIO_STREAM::cout << (*it)->m_XPicked[d] << " ";
}
for(d = 0; d < 3; d++)
{
METAIO_STREAM::cout << (*it)->m_V[d] << " ";
}
METAIO_STREAM::cout << METAIO_STREAM::endl;
it++;
}
MetaContour::InterpolatedPointListType ilist = Contour.GetInterpolatedPoints();
MetaContour::InterpolatedPointListType::const_iterator iti = ilist.begin();
while(iti != ilist.end())
{
METAIO_STREAM::cout << (*iti)->m_Id << " ";
for(unsigned int d = 0; d < 3; d++)
{
METAIO_STREAM::cout << (*iti)->m_X[d] << " ";
}
METAIO_STREAM::cout << METAIO_STREAM::endl;
iti++;
}
METAIO_STREAM::cout << "done" << METAIO_STREAM::endl;
return 0;
}
|