// OiBSurfXYPlane_t.cpp #include "OiBSurfXYPlane.h" #include "Inventor/SoDB.h" #include "Inventor/nodes/SoSeparator.h" #include "Inventor/nodes/SoMaterial.h" #include "Inventor/actions/SoWriteAction.h" #include "trfxyp/BSurfXYPlane.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; const double PI = acos(-1.0); const double PI2 = 0.5*PI; //********************************************************************** int main( ) { string component = "OiBSurfXYPlane"; 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 planes." << endl; BSurfXYPlane xyp1( 10.0, 0.0, 0.0, 5.0, 0.0, 10.0 ); BSurfXYPlane xyp2( 10.0, PI, -5.0, 0.0, 0.0, 10.0 ); BSurfXYPlane xyp3( 5.0, PI2, -10.0, 10.0, 0.0, 10.0 ); //******************************************************************** cout << ok_prefix << "Construct streamer." << endl; SoDB::init(); OiBSurfXYPlane 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.5,0.5,0.9); psep->addChild(pmat); } psep->addChild( oisrf.generate_representation(xyp1,traits) ); { SoMaterial* pmat = new SoMaterial; pmat->diffuseColor.setValue(0.5,0.9,0.5); psep->addChild(pmat); } psep->addChild( oisrf.generate_representation(xyp2,traits) ); { SoMaterial* pmat = new SoMaterial; pmat->diffuseColor.setValue(0.9,0.5,0.5); psep->addChild(pmat); } psep->addChild( oisrf.generate_representation(xyp3,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; //******************************************************************** }