00001 #include "SIGEL_GP/SIG_GPFullDataRecorder.h" 00002 00003 #include <cmath> 00004 00005 namespace SIGEL_GP 00006 { 00007 00008 SIG_GPFullDataRecorder::SIG_GPFullDataRecorder( int recordingFrequency ) 00009 : SIGEL_Simulation::SIG_Recorder(), 00010 recordingFrequency( recordingFrequency ), 00011 frameCounter( 0 ) 00012 { 00013 positions.setAutoDelete( true ); 00014 rotations.setAutoDelete( true ); 00015 00016 if (recordingFrequency <= 0) 00017 recordingFrequency = 1; 00018 }; 00019 00020 void SIG_GPFullDataRecorder::init() 00021 throw (SIGEL_Simulation::SIG_RecorderNoQueriesSetException, 00022 SIGEL_Simulation::SIG_RecorderBadRecordingOrderException) 00023 { 00024 SIGEL_Simulation::SIG_Recorder::init(); 00025 00026 record(); 00027 }; 00028 00029 void SIG_GPFullDataRecorder::record() 00030 throw (SIGEL_Simulation::SIG_RecorderNoQueriesSetException, 00031 SIGEL_Simulation::SIG_RecorderBadRecordingOrderException) 00032 { 00033 if (frameCounter == 0) 00034 { 00035 int rootLinkNumber = simulationQueries->getRootNumber(); 00036 00037 DL_vector *newPosition = new DL_vector(); 00038 DL_matrix *newRotation = new DL_matrix(); 00039 00040 *newPosition = simulationQueries->getLinkPosition( rootLinkNumber ); 00041 00042 *newRotation = simulationQueries->getLinkOrientation( rootLinkNumber ); 00043 00044 positions.append( newPosition ); 00045 00046 rotations.append( newRotation ); 00047 }; 00048 00049 frameCounter++; 00050 frameCounter %= recordingFrequency; 00051 }; 00052 00053 void SIG_GPFullDataRecorder::finish() 00054 throw (SIGEL_Simulation::SIG_RecorderNoQueriesSetException, 00055 SIGEL_Simulation::SIG_RecorderBadRecordingOrderException) 00056 { 00057 SIGEL_Simulation::SIG_Recorder::finish(); 00058 00059 int rootLinkNumber = simulationQueries->getRootNumber(); 00060 00061 endPosition = simulationQueries->getLinkPosition( rootLinkNumber ); 00062 endRotation = simulationQueries->getLinkOrientation( rootLinkNumber ); 00063 }; 00064 00065 }