// OiBSurfZPlane_t.cpp #include "OiBSurfZPlane.h" #include "Inventor/SoDB.h" #include "Inventor/nodes/SoSeparator.h" #include "Inventor/nodes/SoMaterial.h" #include "Inventor/actions/SoWriteAction.h" #include "trfzp/BSurfZPlane.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; //********************************************************************** int main( ) { string component = "OiBSurfZPlane"; 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 xmin = 5.0; double xmax = 15.0; double ymin = 0.0; double ymax = 20.0; BSurfZPlane zpl1( z1, xmin, xmax, ymin, ymax ); BSurfZPlane zpl2( z2, xmin, xmax, ymin, ymax ); //******************************************************************** cout << ok_prefix << "Construct streamer." << endl; SoDB::init(); OiBSurfZPlane 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(zpl1,traits) ); psep->addChild( oisrf.generate_representation(zpl2,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; //******************************************************************** }