// OiBSurfCylinder_t.cpp #include "OiBSurfCylinder.h" #include "Inventor/SoDB.h" #include "Inventor/nodes/SoSeparator.h" #include "Inventor/nodes/SoMaterial.h" #include "Inventor/actions/SoWriteAction.h" #include "trfcyl/BSurfCylinder.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; //********************************************************************** int main( ) { string component = "OiBSurfCylinder"; 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 cylinder." << endl; BSurfCylinder cyl( 20, -100, 100 ); //******************************************************************** cout << ok_prefix << "Construct streamer." << endl; SoDB::init(); OiBSurfCylinder oicyl; const OiSurface& oisrf = oicyl; 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(cyl,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; //******************************************************************** }