// OiSurfPolygon_t.cpp #include "OiSurfPolygon.h" #include "Inventor/SoDB.h" #include "Inventor/nodes/SoSeparator.h" #include "Inventor/nodes/SoMaterial.h" #include "Inventor/actions/SoWriteAction.h" #include "trfzp/SurfPolygon.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; //********************************************************************** int main( ) { string component = "OiSurfPolygon"; string ok_prefix = component + " (I): "; string error_prefix = component + " test (E): "; cout << ok_prefix << "---------- Testing component " + component + ". ----------" << endl; // Make sure assert is enabled. bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //******************************************************************** cout << ok_prefix << "Construct zplane." << endl; double z1 = 10.0; double z2 = 20.0; double xl1 = 0.0; double xl2 = 10.0; double xu1 = 3.0; double xu2 = 7.0; double yl = 0.0; double yu = 10.0; SurfPolygon::Points pts; pts.push_back( CartesianTwoPoint(xl1,yl) ); pts.push_back( CartesianTwoPoint(xl2,yl) ); pts.push_back( CartesianTwoPoint(xu2,yu) ); pts.push_back( CartesianTwoPoint(xu1,yu) ); SurfPolygon pgn1( z1, pts ); SurfPolygon pgn2( z2, pts ); //******************************************************************** cout << ok_prefix << "Construct streamer." << endl; SoDB::init(); OiSurfPolygon oizpl; const OiSurface& oisrf = oizpl; oisrf.init_class(); OiSurfaceTraits traits; //******************************************************************** cout << ok_prefix << "Generate OI rep and write to out.iv." << endl; SoSeparator* psep = new SoSeparator; SoMaterial* pmat = new SoMaterial; pmat->diffuseColor.setValue(0.6,0.6,0.9); psep->addChild(pmat); psep->addChild( oisrf.generate_representation(pgn1,traits) ); psep->addChild( oisrf.generate_representation(pgn2,traits) ); SoWriteAction writer; writer.getOutput()->openFile("out.iv"); writer.getOutput()->setBinary(FALSE); writer.apply(psep); writer.getOutput()->closeFile(); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }