Merge lp:~forsslundsystems/forssim/statistics into lp:forssim

Proposed by jocke
Status: Merged
Approved by: Martin Flodin
Approved revision: 275
Merged at revision: not available
Proposed branch: lp:~forsslundsystems/forssim/statistics
Merge into: lp:forssim
Diff against target: None lines
To merge this branch: bzr merge lp:~forsslundsystems/forssim/statistics
Reviewer Review Type Date Requested Status
Martin Flodin Approve
Review via email: mp+6410@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Flodin (mflodin) wrote :

Looks good. For future development the text should be changed, but as this was only a proof of concept it does what it should. I'll merge it into the main branch.

/Martin

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'FsWisdom/ApplicationNode.cpp'
2--- FsWisdom/ApplicationNode.cpp 2009-05-06 09:26:07 +0000
3+++ FsWisdom/ApplicationNode.cpp 2009-05-11 08:37:54 +0000
4@@ -291,6 +291,7 @@
5 this->setOverrideCursor(QCursor(Qt::WaitCursor));
6 volumeModel = static_cast <VolumeModel*> (glWindow->getSceneNode("VM"));
7 volumeModel->saveTimeStamps();
8+ volumeModel->saveStatistics();
9 this->restoreOverrideCursor();
10 // falls down into no
11 case QMessageBox::No:
12
13=== modified file 'src/VolumeModel.cpp'
14--- src/VolumeModel.cpp 2009-05-04 08:19:33 +0000
15+++ src/VolumeModel.cpp 2009-05-11 08:37:54 +0000
16@@ -836,6 +836,78 @@
17 timeStamps->saveDataToNrrdFile(filePath,noOfDimensions,dimensionLengths,spacings);
18 }
19
20+void VolumeModel::saveStatistics()
21+{
22+
23+ LoggingNode* loggingNode = static_cast< LoggingNode * >(loggingNodeField->getValue() );
24+ string userLoggingPath = loggingNode->userLoggingPathField->getValue();
25+
26+ MaterialSegmentationModel* materialSegmentationNode =
27+ static_cast< MaterialSegmentationModel * >(materialSegmentationModelField->getValue());
28+
29+ const float mm3PerM3 = 1000000.0;
30+ // construct string with current date and time
31+ time_t rawTime = time(0);
32+ struct tm* timeInfo;
33+ char strBuffer [80];
34+ timeInfo = localtime ( &rawTime );
35+ strftime (strBuffer,80,"%y%m%d%H%M%S",timeInfo);
36+ string timeString(strBuffer);
37+
38+ // construct file name
39+ string filePath = userLoggingPath+"/";
40+ filePath.append(timeString).append("_stat").append(".txt");
41+
42+ //creating file
43+ ofstream file;
44+ file.open(filePath.c_str(),ios::out);
45+
46+ /*Data*/
47+ //Total numbers of voxels and segments
48+ int totVoxels = height*width*depth;
49+ file<<"Total numbers of voxels: " << totVoxels << " (including Air)" << endl;
50+ file << "Number of Segments: "<<materialSegmentationNode->getNoOfSegments()<<endl;
51+
52+ //Total time on case
53+ double timeSpendBoring = 0;
54+ if(timestamp_map.size()>1)
55+ timeSpendBoring = (*(timestamp_map.rbegin())).first - (*(timestamp_map.begin())).first;
56+ file << "Time spent boring: "<<timeSpendBoring<<" secs"<<endl<<endl;
57+
58+ //Number of Forbidden voxels
59+ ForbiddenSegmentationModel* forbiddenSegmentationModel = static_cast< ForbiddenSegmentationModel * >(forbiddenSegmentationModelField->getValue());
60+
61+ //Number of voxels drilled in each segment
62+ int noOfSegments = materialSegmentationNode->getNoOfSegments();
63+ int voxelsEachSegArray[noOfSegments];
64+
65+ for (int i = 0; i < noOfSegments; i++)
66+ {
67+ voxelsEachSegArray[i] = 0;
68+ }
69+
70+ multimap<double, Vec3i>::iterator it;
71+ for ( it=timestamp_map.begin() ; it !=timestamp_map.end(); it++ )
72+ {
73+ int temp = getMaterialSegmentationId((*it).second);
74+ voxelsEachSegArray[temp] = voxelsEachSegArray[temp] + 1;
75+ }
76+ file << " Voxels drilled in " << endl;
77+ for (int i = 1; i < noOfSegments; i++) //Start at 1 since 0=Air
78+ {
79+ file << "Segment " << i << " - " << materialSegmentationNode->getName(i) << ": " << voxelsEachSegArray[i] << endl;
80+ }
81+
82+ //Forbidden segments
83+ file << endl;
84+ file << "(TODO These values are not the same as displayed in GUI. Check code...) Number of voxels drilled in forbidden areas" <<endl;
85+ file << "Wisdom Backside: " << forbiddenSegmentationModel->noOfVoxelsBoredByUser->getValue()[0] << endl;
86+ file << "Other teeth: " << forbiddenSegmentationModel->noOfVoxelsBoredByUser->getValue()[1] <<endl<<endl;
87+
88+ file.close();
89+ cout << "Saving statistics to file " << filePath << endl;
90+}
91+
92 /****************************************************************/
93
94 H3D::Vec3f VolumeModel::getGlobalCoordinate()
95
96=== modified file 'src/VolumeModel.h'
97--- src/VolumeModel.h 2009-03-31 09:45:57 +0000
98+++ src/VolumeModel.h 2009-05-11 08:37:54 +0000
99@@ -324,6 +324,11 @@
100 void saveTimeStamps();
101
102 /**
103+ * Save drilling statistics. Is done on Exit.
104+ */
105+ void saveStatistics();
106+
107+ /**
108 * Remove a partition giving its name
109 */
110 void removePartitionByName(string partitionName);

Subscribers

People subscribed via source and target branches

to all changes: