#include <TensorBlossom.H>
#include <SubdivisionManifold.H>
using namespace xchen;
using namespace std;
int main()
{
TensorBlossom<1> *circle = new TensorBlossom<1>(2,4);
(*circle).ControlMesh() = E3(-1, -1, 0), E3(-1, 1, 0), E3(1, 1, 0), E3(1, -1, 0);
circle->KnotVector() = 0.,1,2,3,4;
circle->SetPeriodicEnd();
cout << *circle << endl;
circle->Convert2Bzr();
cout << "after to bzr\n" << *circle << "\n-----------------\n";
circle->Subdivide(5);
TensorBlossom<2> srf(3,5, 2,3);
srf.ControlMesh() =
E3(0.0, 0.0, 1.0), E3(0.0, 1.0), E3(0.0, 2.0, 1.0),
E3(1.0, 0.0), E3(1.0, 1.0, 2.0), E3(1.0, 2.0),
E3(2.0, 0.0, 2.0), E3(2.0, 1.0), E3(2.0, 2.0, 2.0),
E3(3.0, 0.0), E3(3.0, 1.0, 2.0), E3(3.0, 2.0),
E3(4.0, 0.0, 1.0), E3(4.0, 1.0), E3(4.0, 2.0, 1.0);
srf.KnotVector() =
0., 1, 2, 3,
0, 1, 2, 3, 4, 5, 6;
srf.SetPeriodicEnd();
cout << srf << endl;
srf.Subdivide(5);
cout << "srf is \n" << srf << endl;
TensorBlossom<2> bls(2,3, 2,3);
bls.ControlMesh() =
E3(0,0,0), E3(.5,.5,0), E3(1,0,0),
E3(0,0,1), E3(.5,.5,1), E3(1,0,1),
E3(0,0,2), E3(.5,.5,2), E3(1,0,2);
double kv[] =
{
0, 1.5, 2.5, 3.5,
0, 1.5, 2.5, 3.5
};
cout << bls << endl;
cout << "after pop_front(1)\n" << bls << endl;
bool use_1d_blossom = !true;
if(use_1d_blossom)
{
bls.Evaluate(0.5);
cout << "after evaluate(.5)\n" << bls << endl;
bls.Evaluate(0.5);
cout << "after evaluate(.5)again \n" << bls << endl;
}
else
{
bls.Insert(0.5);
cout << "after insert(.5)\n" << bls << endl;
bls.Insert(0.5);
cout << "after insert(.5)again \n" << bls << endl;
}
{
TensorBlossom<1> blsm(2, 3);
blsm.ControlMesh() = E3(.0), E3(1.0), E3(.0);
blsm.KnotVector() = 0.,0,3,3;
cout << blsm << endl;
if( blsm.Insert(1) )
cout << blsm << endl;
else
cout << "insert error\n";
if( blsm.Insert(2) )
cout << blsm << endl;
else
cout << "insert error\n";
cout << *blsm.GetSegment(0) << endl;
cout << *blsm.GetSegment(1) << endl;
cout << *blsm.GetSegment(2) << endl;
cout << *blsm.GetSegment(3) << endl;
}
return 0;
}