Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

/home/xchen/xia/src/manifold/demoTensorBlossom.cc

#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);
    //    return 0;
    
  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, 2, 2, 5, 6;
    0, 1, 2, 3, 4, 5, 6;

  srf.SetPeriodicEnd();
  
  cout << srf << endl;

  //  srf.Convert2OpenEnd();
  //  srf.Convert2Bzr();
  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 
    };
  //  bls.KnotVector() = kv;
  cout << bls << endl;
  
  //  bls.pop_front(1);
       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;
  }  
  
//   SubdivisionManifold<1, 3>* bsp_crv = new SubdivisionManifold<1,3>(4,5);
//   (*bsp_crv)() =  E3(0,0,0), E3(.25,.5,0), E3(.5,.75,0), E3(.75,.5,0), E3(1,0,0);

//   bsp_crv->bzr2floatingEndBspline(0);
  
//   bsp_crv->Subdivide(10);

  return 0;
}



Generated on Wed Apr 7 21:40:48 2004 by doxygen1.2.18