52 #ifndef __PCL_AbstractImage_h
53 #define __PCL_AbstractImage_h
69 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
81 #define m_width m_geometry->width
82 #define m_height m_geometry->height
83 #define m_numberOfChannels m_geometry->numberOfChannels
85 #define m_colorSpace m_color->colorSpace
86 #define m_RGBWS m_color->RGBWS
169 PCL_PRECONDITION( NumberOfChannels() != 0 )
178 PCL_PRECONDITION( NumberOfChannels() != 0 )
189 return NumberOfPixels() * NumberOfAlphaChannels();
202 PCL_PRECONDITION( 0 <= c && c < m_numberOfChannels )
203 m_selected.channel = m_selected.lastChannel = c;
204 ValidateChannelRange();
217 return m_selected.channel;
229 PCL_PRECONDITION( 0 <= c0 && c0 < m_numberOfChannels )
230 PCL_PRECONDITION( 0 <= c1 && c1 < m_numberOfChannels )
231 m_selected.channel = c0;
232 m_selected.lastChannel = c1;
233 ValidateChannelRange();
242 m_selected.channel = 0;
244 ValidateChannelRange();
257 m_selected.lastChannel = m_numberOfChannels-1;
258 ValidateChannelRange();
267 m_selected.channel = 0;
268 m_selected.lastChannel =
pcl::Max( 0, m_numberOfChannels-1 );
276 return 1 + m_selected.lastChannel - m_selected.channel;
284 return m_selected.channel;
292 return m_selected.lastChannel;
304 c0 = m_selected.channel;
305 c1 = m_selected.lastChannel;
316 m_selected.point.MoveTo( x, y );
324 m_selected.point = p;
332 m_selected.point = 0;
340 return m_selected.point;
358 m_selected.rectangle.Set( x0, y0, x1, y1 );
359 Clip( m_selected.rectangle );
372 SelectRectangle( p0.x, p0.y, p1.x, p1.y );
381 SelectRectangle( r.x0, r.y0, r.x1, r.y1 );
389 m_selected.rectangle.Set( 0, 0, m_width, m_height );
397 return m_selected.rectangle.IsPointOrLine();
406 return m_selected.rectangle.x0 <= 0 &&
407 m_selected.rectangle.y0 <= 0 &&
408 m_selected.rectangle.x1 >= m_width &&
409 m_selected.rectangle.y1 >= m_height;
417 return m_selected.rectangle;
430 return m_selected.channel == 0 &&
431 m_selected.lastChannel >= m_numberOfChannels-1 &&
432 m_selected.rectangle.x0 <= 0 &&
433 m_selected.rectangle.y0 <= 0 &&
434 m_selected.rectangle.x1 >= m_width &&
435 m_selected.rectangle.y1 >= m_height;
444 return size_type( m_selected.rectangle.Width() ) *
size_type( m_selected.rectangle.Height() );
457 return NumberOfSelectedPixels()*
size_type( NumberOfSelectedChannels() );
484 return m_selected.clippedLow || m_selected.clippedHigh;
497 return m_selected.clippedLow;
510 return m_selected.clippedHigh;
520 m_selected.clippedLow = enableLow;
521 m_selected.clippedHigh = enableHigh;
531 m_selected.clippedLow = !disableLow;
532 m_selected.clippedHigh = !disableHigh;
542 return m_selected.clipLow;
552 return m_selected.clipHigh;
562 m_selected.clipLow = clipLow;
563 if ( m_selected.clipHigh < m_selected.clipLow )
564 pcl::Swap( m_selected.clipLow, m_selected.clipHigh );
574 m_selected.clipHigh = clipHigh;
575 if ( m_selected.clipHigh < m_selected.clipLow )
576 pcl::Swap( m_selected.clipLow, m_selected.clipHigh );
587 if ( clipHigh < clipLow )
589 m_selected.clipLow = clipLow;
590 m_selected.clipHigh = clipHigh;
591 m_selected.clippedLow = m_selected.clippedHigh =
true;
603 m_selected.clipLow = 0;
604 m_selected.clipHigh = 1;
605 m_selected.clippedLow = m_selected.clippedHigh =
false;
631 ResetRangeClipping();
648 m_savedSelections.Append( m_selected );
661 if ( CanPopSelections() )
665 m_savedSelections.Remove( i );
676 return !m_savedSelections.IsEmpty();
693 if ( !rect.IsRect() )
695 rect = m_selected.rectangle;
696 if ( !rect.IsRect() )
718 channel = m_selected.channel;
722 if ( channel >= m_numberOfChannels )
754 if ( !ParseRect( rect ) || !ParseChannel( firstChannel ) )
757 if ( lastChannel < 0 )
759 lastChannel = m_selected.lastChannel;
760 if ( lastChannel < 0 )
763 if ( lastChannel >= m_numberOfChannels )
766 if ( lastChannel < firstChannel )
791 return ParseRect( rect ) && ParseChannel( channel );
811 return m_status.Callback();
830 m_status.SetCallback( callback );
861 return m_parallel ?
pcl::Min( (maxProcessors > 0) ? maxProcessors : m_maxProcessors,
899 return NumberOfThreads( (rowCount > 0) ? rowCount : Height(),
948 m_parallel ? ((maxProcessors > 0) ? maxProcessors : m_maxProcessors) : 1 );
987 : status( image.Status() )
1001 : status( a_status )
1071 template <
class thread>
1094 useAffinity =
false;
1098 for ( thread& t : threads )
1099 t.Start( ThreadPriority::DefaultMax, useAffinity ? n++ : -1 );
1103 waitTime += waitTime >> 2;
1109 if ( !i->Wait( waitTime ) )
1112 if ( ++i == threads.
End() )
1114 if ( data.
total > 0 )
1124 if ( data.
total > 0 )
1127 lastCount = data.
count;
1137 for ( thread& t : threads )
1139 for ( thread& t : threads )
1151 mutable selection_stack m_savedSelections;
1162 ImageGeometry::Swap( image );
1163 ImageColor::Swap( image );
1165 pcl::Swap( m_selected, image.m_selected );
1166 pcl::Swap( m_savedSelections, image.m_savedSelections );
1170 void ValidateChannelRange() const noexcept
1172 if ( m_numberOfChannels > 0 )
1176 else if ( m_selected.
channel >= m_numberOfChannels )
1177 m_selected.
channel = m_numberOfChannels-1;
1181 else if ( m_selected.
lastChannel >= m_numberOfChannels )
1193 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
1194 friend class pi::SharedImage;
1202 #undef m_numberOfChannels
1226 #define INIT_THREAD_MONITOR() \
1227 size_type ___n___ = 0, ___n1___ = 0;
1314 #define UPDATE_THREAD_MONITOR( N ) \
1315 if ( ++___n1___ == (N) ) \
1317 if ( this->m_data.numThreads > 1 ) \
1319 if ( this->TryIsAborted() ) \
1322 if ( this->m_data.total > 0 ) \
1323 if ( this->m_data.mutex.TryLock() ) \
1325 this->m_data.count += ___n___; \
1326 this->m_data.mutex.Unlock(); \
1332 if ( this->m_data.total > 0 ) \
1333 this->m_data.status += (N); \
1335 ++this->m_data.status; \
1395 #define UPDATE_THREAD_MONITOR_CHUNK( N, chunkSize ) \
1396 if ( (___n1___ += (chunkSize)) == (N) ) \
1398 if ( this->m_data.numThreads > 1 ) \
1400 if ( this->TryIsAborted() ) \
1403 if ( this->m_data.total > 0 ) \
1404 if ( this->m_data.mutex.TryLock() ) \
1406 this->m_data.count += ___n___; \
1407 this->m_data.mutex.Unlock(); \
1413 if ( this->m_data.total > 0 ) \
1414 this->m_data.status += (N); \
1416 ++this->m_data.status; \
1425 #endif // __PCL_AbstractImage_h