~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/modules/atlasSurfaces/WMAtlasSurfaces.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
//---------------------------------------------------------------------------
24
24
 
25
25
#include <string>
 
26
#include <fstream>
26
27
#include <vector>
27
28
#include <utility>
28
29
 
39
40
#include "core/common/WAssert.h"
40
41
#include "core/common/WPathHelper.h"
41
42
#include "core/common/WThreadedFunction.h"
 
43
#include "core/common/WStringUtils.h"
42
44
#include "core/dataHandler/WDataSetScalar.h"
43
45
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
44
46
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
90
92
const std::string WMAtlasSurfaces::getDescription() const
91
93
{
92
94
    return "Use a scalar data set that stores numbers for atlas regions and a "
93
 
        "correspoding text file with labels for the numbers to create "
 
95
        "corresponding text file with labels for the numbers to create "
94
96
        "surfaces bounding the atlas regions. The surfaces can be picked to reveal "
95
97
        "their name in the HUD (module). Regions can be used as ROIs for fiber selection.";
96
98
}
148
150
 
149
151
            if( m_labelFile->get( true ) == boost::filesystem::path( "" ) )
150
152
            {
151
 
                std::string fn = m_dataSet->getFileName();
152
 
                std::string ext( ".nii.gz" );
 
153
                std::string fn = m_dataSet->getFilename();
 
154
 
 
155
                std::string ext( "" );
 
156
                if( fn.find( ".nii.gz" ) != std::string::npos )
 
157
                {
 
158
                    ext = ".nii.gz";
 
159
                }
 
160
                else if( fn.find( ".nii" ) != std::string::npos )
 
161
                {
 
162
                    ext = ".nii";
 
163
                }
 
164
 
153
165
                std::string csvExt( ".csv" );
154
 
                fn.replace( fn.find( ext ), ext.size(), csvExt );
 
166
                if( ext != "" )
 
167
                {
 
168
                    //                    fn.replace( fn.find( ext ), ext.size(), csvExt );
 
169
                }
 
170
                else
 
171
                {
 
172
                    fn.append( csvExt );
 
173
                }
155
174
                m_labelFile->set( fn );
156
175
            }
 
176
 
157
177
            if( !boost::filesystem::exists( m_labelFile->get() ) )
158
178
            {
159
179
                wlog::warn( "Atlas Surfaces" ) << "Expected label file does not exist! (" <<  m_labelFile->get().string() << ")";
223
243
                    new WCreateSurfaceJob<unsigned char>( m_dataSet, m_regionMeshes2, newProgress, pro ) );
224
244
            break;
225
245
        case W_DT_INT16:
 
246
            job = boost::shared_ptr<WCreateSurfaceJob<int16_t> >(
 
247
                    new WCreateSurfaceJob<int16_t>( m_dataSet, m_regionMeshes2, newProgress, pro ) );
226
248
            break;
227
249
        case W_DT_SIGNED_INT:
 
250
            job = boost::shared_ptr<WCreateSurfaceJob<int> >(
 
251
                    new WCreateSurfaceJob<int>( m_dataSet, m_regionMeshes2, newProgress, pro ) );
228
252
            break;
229
253
        case W_DT_FLOAT:
230
254
        case W_DT_DOUBLE:
231
255
        default:
232
 
            WAssert( false, "Unknown data type in MarchingCubes module" );
 
256
            WAssert( false, "Unknown data type in AtlasSurfaces module" );
233
257
    }
234
258
 
235
259
    WThreadedFunction< WThreadedJobs<WDataSetScalar, size_t> >threadPool( 4, job );
242
266
 
243
267
    for(size_t i = 1; i < m_dataSet->getMax() + 1; ++i )
244
268
    {
245
 
        std::string label = boost::lexical_cast<std::string>( i ) + std::string( " " ) + m_labels[i].second;
 
269
        std::string label = string_utils::toString( i ) + std::string( " " ) + m_labels[i].second;
246
270
        m_possibleSelections->addItem( label, "" );
247
271
    }
248
272
 
258
282
        osg::Geometry* surfaceGeometry = new osg::Geometry();
259
283
        osg::ref_ptr< osg::Geode > outputGeode = osg::ref_ptr< osg::Geode >( new osg::Geode );
260
284
 
261
 
        std::string label = boost::lexical_cast<std::string>( i ) + std::string( " " ) + m_labels[i].second;
 
285
        std::string label = string_utils::toString( i ) + std::string( " " ) + m_labels[i].second;
262
286
        outputGeode->setName( label );
263
287
 
264
288
        surfaceGeometry->setUseDisplayList( false );
382
406
            if( svec.size() == 3 )
383
407
            {
384
408
                std::pair< std::string, std::string >newLabel( svec[1], svec[2] );
385
 
                m_labels[boost::lexical_cast<size_t>( svec[0] )] = newLabel;
 
409
                m_labels[ string_utils::fromString< size_t >( svec[0] )] = newLabel;
386
410
            }
387
411
        }
388
412
        m_labelsLoaded = true;
448
472
    }
449
473
    else
450
474
    {
451
 
        newRoi->setName( std::string( "region " ) + boost::lexical_cast<std::string>( index ) );
 
475
        newRoi->setName( std::string( "region " ) + string_utils::toString( index ) );
452
476
    }
453
477
 
454
478
    if( WKernel::getRunningKernel()->getRoiManager()->getSelectedRoi() == NULL )