本文整理汇总了C++中VolumeCollection::LoadVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ VolumeCollection::LoadVolume方法的具体用法?C++ VolumeCollection::LoadVolume怎么用?C++ VolumeCollection::LoadVolume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VolumeCollection
的用法示例。
在下文中一共展示了VolumeCollection::LoadVolume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
void
SegmentationVolumeReportTester::Test ( Tcl_Interp* iInterp ) {
try {
// Load our seg volume.
string fnSegVolume = "test_data/testSegmentationVolumeReportData-Seg.mgz";
VolumeCollection seg;
seg.SetFileName( fnSegVolume );
seg.LoadVolume();
seg.SetLabel( "Seg" );
// Load our intensity volume.
string fnIntVolume = "test_data/testSegmentationVolumeReportData-Int.mgz";
VolumeCollection vol;
vol.SetFileName( fnIntVolume );
vol.LoadVolume();
vol.SetLabel( "Int" );
// Load our LUT.
string fnLUT = "test_data/TestLUT.txt";
ScubaColorLUT lut;
lut.UseFile( fnLUT );
// Set up the report.
SegmentationVolumeReport& report =
SegmentationVolumeReport::GetReport();
report.SetSegmentation( seg );
if ( NULL == report.mSegVol ) {
stringstream ssError;
ssError << "Error on SetSegmentation, mSegVol was NULL";
throw runtime_error( ssError.str() );
}
if ( report.mSegVol->GetID() != seg.GetID() ) {
stringstream ssError;
ssError << "Error on SetSegmentation, mSegVol was the wrong volume (should be ID " << seg.GetID() << " but was " << report.mSegVol->GetID();
throw runtime_error( ssError.str() );
}
report.DontUseROI();
if ( report.mbUseROI ) {
stringstream ssError;
ssError << "Error on DontUseROI, mbUseROI was true";
throw runtime_error( ssError.str() );
}
report.SetColorLUT( lut );
if ( NULL == report.mLUT ) {
stringstream ssError;
ssError << "Error on SetColorLUT, mROI was NULL";
throw runtime_error( ssError.str() );
}
if ( report.mLUT->GetID() != lut.GetID() ) {
stringstream ssError;
ssError << "Error on SetColorLUT, id didn't match";
throw runtime_error( ssError.str() );
}
// Add 1-5 but not 3.
report.AddSegmentationStructure( 1 );
report.AddSegmentationStructure( 2 );
report.AddSegmentationStructure( 4 );
report.AddSegmentationStructure( 5 );
map<int,bool> structureMap;
list<int>::iterator tStructure;
for ( tStructure = report.mlStructures.begin();
tStructure != report.mlStructures.end(); ++tStructure ) {
int nStructure = *tStructure;
if ( nStructure != 1 && nStructure != 2 &&
nStructure != 4 && nStructure != 5 ) {
stringstream ssError;
ssError << "Error on AddSegmentationStructure, added an unknown structure " << nStructure;
throw runtime_error( ssError.str() );
}
structureMap[nStructure] = true;
}
if ( !(structureMap[1] && structureMap[2] &&
structureMap[4] && structureMap[5]) ) {
stringstream ssError;
ssError << "Error in AddSegmentationStructure, didn't add all structures";
throw runtime_error( ssError.str() );
}
// Test handling of undefined structures.
report.AddSegmentationStructure( 200 );
// Add the intensity volume. Also add the seg vol as an additional
// intensity volume.
report.AddIntensityVolume( vol );
report.AddIntensityVolume( seg );
map<int,bool> volsLoadedMap;
list<VolumeCollection*>::iterator tVolume;
for ( tVolume = report.mlIntVols.begin();
tVolume != report.mlIntVols.end(); ++tVolume ) {
VolumeCollection* testVol = *tVolume;
int volID = testVol->GetID();
//.........这里部分代码省略.........
示例2: fnSave
//.........这里部分代码省略.........
segIdxA.Set( 0, 5.5, 5.5 );
segIdxB.Set( 4, 5.5, 5.5 );
VectorOps::IntersectionResult rInt =
vol->VoxelIntersectsSegment( idx, segIdxA, segIdxB, intIdx );
if ( VectorOps::dontIntersect != rInt ) {
cerr << "Failed VoxelIntersectsSegment test: idx " << idx
<< ", seg " << segIdxA << ", " << segIdxB << endl
<< "\tIntersected" << endl;
throw runtime_error("failed");
}
}
// FindRASPointsOnSegment
{
}
// GetVoxelsWithValue
{
// This is a 5cubed volume whose values are set to the x
// coordinate. So for x=3,y=0..4,z=0..4, value = 3.
string fnVol = "test_data/testVolumeCollection-GetVoxelsWithValue.mgh";
ifstream fVol( fnMRI.c_str(), ios::in );
if ( !fVol ) {
throw runtime_error("Couldn't find necessary test data.");
}
fVol.close();
VolumeCollection* vol = new VolumeCollection();
vol->SetFileName( fnVol );
vol->LoadVolume();
// Get the values 0-4 and make sure we got the right voxels.
for ( int nStructure = 0; nStructure < 5; nStructure++ ) {
list<VolumeLocation> lLocations;
vol->GetVoxelsWithValue( nStructure, lLocations );
Volume3<bool> bGot( 5, 5, 5, false );
list<VolumeLocation>::iterator tLocation;
for ( tLocation = lLocations.begin(); tLocation != lLocations.end();
++tLocation ) {
VolumeLocation loc = *(tLocation);
bGot.Set( loc.Index()[0], loc.Index()[1], loc.Index()[2], true );
}
for ( int nZ = 0; nZ < 5; nZ++ ) {
for ( int nY = 0; nY < 5; nY++ ) {
for ( int nX = 0; nX < 5; nX++ ) {
if ( nX == nStructure && !bGot.Get( nX, nY, nZ ) ) {
stringstream ssErr;
ssErr << "Failed GetVoxelsWithValue test: "
<< " nStructure = " << nStructure
<< " index " << Point3<int>(nX,nY,nZ)
<< " - was supposed to get voxel but didn't";
throw runtime_error(ssErr.str());
}
if ( nX != nStructure && bGot.Get( nX, nY, nZ ) ) {
stringstream ssErr;
ssErr << "Failed GetVoxelsWithValue test: "
<< " nStructure = " << nStructure
<< " index " << Point3<int>(nX,nY,nZ)