// SimInteractorRegistry_t.cpp #include "SimInteractorTest.h" #include "SurfTest.h" #include "SimInteractorRegistry.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; using trf::SurfacePtr; using trf::SimInteractorRegistry; typedef Ptr< SimInteractor, SharedDeletePolicy > SimInteractorPtr; int main( void ){ string component = "SimInteractorRegistry"; 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; } // make some surfaces: SurfacePtr srf1(new BSurfTest( 10.0, 1 )); SurfacePtr srf2(new BSurfTest( 20.0, 2 )); SurfacePtr srf3(new BSurfTest( 30.0, 3 )); SurfacePtr srf4(new BSurfTest( 40.0, 4 )); TrackVector trkv; trkv(0) = 2; trkv(1) = 3; VTrack vtrk1( srf1, trkv ); VTrack vtrk2( srf2, trkv ); VTrack vtrk3( srf3, trkv ); VTrack vtrk4( srf4, trkv ); // make some interactors: SimInteractorPtr pint1( new SimInteractorTest( 0.001, 1.0 ) ); SimInteractorPtr pint2( new SimInteractorTest( 0.001, 2.0 ) ); SimInteractorPtr pint3( new SimInteractorTest( 0.001, 3.0 ) ); /// make the surface registry: SimInteractorRegistry regInter; regInter.register_interactor( srf1, pint1 ); regInter.register_interactor( srf2, pint2 ); regInter.register_interactor( srf3, pint3 ); cout << "Before scattering " << vtrk1 << endl; regInter.interact( vtrk1 ); cout << "After scattering " << vtrk1 << endl; regInter.interact( vtrk2 ); regInter.interact( vtrk3 ); //regInter.interact( vtrk4 ); const TrackVector& vtrk1_p = vtrk1.get_vector(); const TrackVector& vtrk2_p = vtrk2.get_vector(); const TrackVector& vtrk3_p = vtrk3.get_vector(); assert( vtrk1_p(0) == trkv(0) ); assert( vtrk1_p(1) == trkv(1) ); assert( vtrk2_p(0) == 2*trkv(0) ); assert( vtrk2_p(1) == 2*trkv(1) ); assert( vtrk3_p(0) == 3*trkv(0) ); assert( vtrk3_p(1) == 3*trkv(1) ); return 0; }