35 #ifndef AIMS_ROI_MASKITERATOR_H
36 #define AIMS_ROI_MASKITERATOR_H
129 const std::vector<std::string> & ) {}
152 std::vector<std::string> _nameAttributes;
157 const std::vector<std::string> & name_attributes
158 = std::vector<std::string>() );
162 const std::vector<std::string> & attributes );
174 std::list<std::string> _attributeNames;
175 std::list<std::string>::const_iterator _itAttributeNames;
179 std::unique_ptr< NodeFilter > _nodeFilter;
181 std::vector<std::string> _nameAttributes;
184 _findBucketAttributeNames(
const Graph &graph,
186 std::list<std::string> &attributeNames );
189 void _getRequiredAttributes();
202 const std::vector<std::string> & regionNameAttributes =
203 std::vector<std::string>() );
211 const std::string &label,
214 const std::vector<std::string> & regionNameAttributes =
215 std::vector<std::string>() );
225 const std::vector<std::string> & regionNameAttributes =
226 std::vector<std::string>() );
230 virtual float voxelVolume()
const {
return _voxelSize[0]*_voxelSize[1]*_voxelSize[2]; }
293 carto::Object o = _data->header().getProperty(
"voxel_size" );
294 vs[0] = o->getArrayItem( 0 )->getScalar();
295 vs[1] = o->getArrayItem( 1 )->getScalar();
296 vs[2] = o->getArrayItem( 2 )->getScalar();
306 return vs[0] * vs[1] * vs[2];
321 virtual void restart(
const T &label );
335 _voxelSampler( voxelSampler )
347 _voxelSampler( voxelSampler )
360 _voxelSampler( voxelSampler )
369 MaskIteratorOf(
const std::string &fileName,
372 _voxelSampler( voxelSampler )
375 _data.reset( reader.
read() );
383 MaskIteratorOf(
const std::string &fileName,
const T &label,
386 _voxelSampler( voxelSampler )
389 _data.reset( reader.
read() );
398 MaskIteratorOf(
const std::string &fileName,
const specifiedLabels &labels,
401 _voxelSampler( voxelSampler )
404 _data.reset( reader.
read() );
428 if ( _voxelSampler.
isNull() )
430 return Point3df( _current[0] * vs[0],
432 _current[2] * vs[2] );
434 const Point3df &voxelSample = _voxelSampler->value();
435 return Point3df( ( _current[0] + voxelSample[ 0 ] ) * vs[0],
436 ( _current[1] + voxelSample[ 1 ] ) * vs[1],
437 ( _current[2] + voxelSample[ 2 ] ) * vs[2] );
445 if ( (_useLabel && (*_data)( _current ) == (T) _label) ||
446 (!_useLabel && (*_data)( _current ) ) )
449 if ( ! _voxelSampler.
isNull() )
451 _voxelSampler->next();
452 if ( _voxelSampler->isValid() )
457 if ( ! _voxelSampler.
isNull() )
459 _voxelSampler->restart();
462 if ( _current == _lastPoint )
464 _current[ 0 ] = _data->getSizeX();
465 _current[ 1 ] = _data->getSizeY();
466 _current[ 2 ] = _data->getSizeZ();
471 if ( _current[ 0 ] == _data->getSizeX() ) {
474 if ( _current[ 1 ] == _data->getSizeY() ) {
479 }
while( isValid() && ( _useLabel ?
480 (*_data)( _current ) != (T) _label :
481 ! (*_data)( _current ) ) );
489 return _current[ 2 ] < _data->getSizeZ();
496 if ( ! _voxelSampler.
isNull() )
498 _voxelSampler->restart();
501 _current[ 0 ] = _current[ 1 ] = _current[ 2 ] = 0;
502 _lastPoint[ 0 ] = _data->getSizeX()-1;
503 _lastPoint[ 1 ] = _data->getSizeY()-1;
504 _lastPoint[ 2 ] = _data->getSizeZ()-1;
506 if ( isValid() && ( _useLabel ?
507 (*_data)( _current ) != (T) _label :
508 ! (*_data)( _current ) ) ) next();
515 if ( ! _voxelSampler.
isNull() )
517 _voxelSampler->restart();
522 _current[ 0 ] = _current[ 1 ] = _current[ 2 ] = 0;
523 _lastPoint[ 0 ] = _data->getSizeX()-1;
524 _lastPoint[ 1 ] = _data->getSizeY()-1;
525 _lastPoint[ 2 ] = _data->getSizeZ()-1;
527 if ( isValid() && ( (*_data)( _current ) != _label ) )
538 if ( ! _voxelSampler.
isNull() )
540 _voxelSampler->restart();
554 if ( p[ 0 ] >= 0 && p[ 0 ] < _data->getSizeX() &&
555 p[ 1 ] >= 0 && p[ 1 ] < _data->getSizeY() &&
556 p[ 2 ] >= 0 && p[ 2 ] < _data->getSizeZ() )
560 return (*_data)( p ) == _label;
564 return (*_data)( p );
576 const Point3d pixel( (
short) rint( p[ 0 ] / vs[0] ),
577 (
short) rint( p[ 1 ] / vs[1] ),
578 (
short) rint( p[ 2 ] / vs[2] ) );
579 return contains( pixel );
587 return Point3d( _data->getSizeX(), _data->getSizeY(), _data->getSizeZ() );
VSet::const_iterator const_iterator
An alternate, ordered, representation for buckets (voxels lists).
LabelNodeFilter(int label)
virtual ~LabelNodeFilter()
virtual bool filter(const carto::AttributedObject &) const
MaskIteratorOf(const std::string &fileName, const std::string &label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >(), const std::vector< std::string > ®ionNameAttributes=std::vector< std::string >())
MaskIteratorOf(const Graph &roi, const std::string &label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >(), const std::vector< std::string > ®ionNameAttributes=std::vector< std::string >())
virtual const Point3df valueMillimeters() const
MaskIteratorOf(const carto::rc_ptr< Graph > &roi, const std::string &label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >(), const std::vector< std::string > ®ionNameAttributes=std::vector< std::string >())
MaskIteratorOf(const std::string &fileName, int label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
virtual float voxelVolume() const
MaskIteratorOf(const std::string &fileName, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
virtual bool contains(const Point3d &) const
MaskIteratorOf(const carto::rc_ptr< Graph > &roi, int label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
MaskIteratorOf(const carto::rc_ptr< Graph > &roi, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
virtual const Point3d volumeDimension() const
MaskIteratorOf(const Graph &roi, int label, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
virtual void setRegionNameAttributes(const std::vector< std::string > &attributes)
Set region name attribute in graph.
virtual const Point3df voxelSize() const
virtual const Point3d & value() const
virtual bool isValid() const
MaskIteratorOf(const Graph &roi, carto::rc_ptr< VoxelSampler > voxelSampler=carto::rc_ptr< VoxelSampler >())
virtual std::string regionName() const
virtual ~MaskIteratorOf()
virtual bool contains(const Point3df &) const
virtual const Point3df voxelSize() const
virtual float voxelVolume() const
virtual const Point3d volumeDimension() const =0
virtual bool isValid() const =0
virtual bool contains(const Point3d &) const =0
virtual std::string regionName() const =0
virtual bool contains(const Point3df &) const =0
virtual float voxelVolume() const =0
virtual const Point3df voxelSize() const =0
virtual const Point3d & value() const =0
virtual const Point3df valueMillimeters() const =0
AffineTransformation3d _motion
virtual bool contains(const Point3d &) const
virtual bool contains(const Point3df &) const
virtual const Point3df valueMillimeters() const
MotionedMaskIterator(const carto::rc_ptr< MaskIterator > &, const AffineTransformation3d &)
virtual ~MotionedMaskIterator()
virtual float voxelVolume() const
AffineTransformation3d _inverseMotion
virtual const Point3d & value() const
virtual std::string regionName() const
virtual bool isValid() const
carto::rc_ptr< MaskIterator > _maskIterator
virtual const Point3df voxelSize() const
virtual const Point3d volumeDimension() const
virtual bool filter(const carto::AttributedObject &) const
virtual ~NameNodeFilter()
virtual void setRegionNameAttributes(const std::vector< std::string > &attributes)
NameNodeFilter(const std::string &name, const std::vector< std::string > &name_attributes=std::vector< std::string >())
virtual bool filter(const carto::AttributedObject &) const
virtual void setRegionNameAttributes(const std::vector< std::string > &)
Generic reader for every format of Aims object.
virtual bool read(T &obj, int border=0, const std::string *format=0, int frame=-1)
Finds the correct format and reads the object. if format is specified, this format is tried first,...
The class for EcatSino data write operation.
carto::rc_ptr< MaskIterator > getMaskIterator(const std::string &fileName)
std::string toString(const T &object)