OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimIgen Class Reference

#include <ossimIgen.h>

Inheritance diagram for ossimIgen:
ossimReferenced ossimOrthoIgen

Public Member Functions

 ossimIgen ()
 
virtual ~ossimIgen ()
 
virtual void initialize (const ossimKeywordlist &kwl)
 
virtual void outputProduct ()
 Writes the output product image. Throws an ossimException if error encountered. More...
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

void initializeAttributes ()
 
void slaveSetup ()
 
bool loadProductSpec ()
 
void setView ()
 Initializes all clients of the view projection to the current product projection. More...
 
void initThumbnailProjection ()
 Modifies the production chain to output redused-resolution thumbnail image. More...
 
void initializeChain ()
 
bool writeToFile (ossimImageFileWriter *writer)
 Consolidates job of actually writing to the output file. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimRefPtr< ossimConnectableContainertheContainer
 
ossimRefPtr< ossimMapProjectiontheProductProjection
 
ossimRefPtr< ossimImageChaintheProductChain
 
ossimRefPtr< ossimTilingtheTiling
 
ossimDrect theOutputRect
 
bool theBuildThumbnailFlag
 
ossimIpt theThumbnailSize
 
long theNumberOfTilesToBuffer
 
ossimKeywordlist theKwl
 
bool theTilingEnabled
 
bool theProgressFlag
 
bool theStdoutFlag
 
ossim_uint32 theThreadCount
 

Detailed Description

Definition at line 37 of file ossimIgen.h.

Constructor & Destructor Documentation

◆ ossimIgen()

ossimIgen::ossimIgen ( )

Definition at line 44 of file ossimIgen.cpp.

References ossimDrect::makeNan(), and theOutputRect.

45 :
52 theThumbnailSize(0, 0),
54 theKwl(),
55 theTilingEnabled(false),
56 theProgressFlag(true),
57 theStdoutFlag(false),
58 theThreadCount(9999) // Default no threading
59 {
61 }
void makeNan()
Definition: ossimDrect.h:388
ossimRefPtr< ossimConnectableContainer > theContainer
Definition: ossimIgen.h:55
bool theBuildThumbnailFlag
Definition: ossimIgen.h:60
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
bool theProgressFlag
Definition: ossimIgen.h:65
ossimRefPtr< ossimImageChain > theProductChain
Definition: ossimIgen.h:57
ossim_uint32 theThreadCount
Definition: ossimIgen.h:67
ossimRefPtr< ossimTiling > theTiling
Definition: ossimIgen.h:58
ossimIpt theThumbnailSize
Definition: ossimIgen.h:61
long theNumberOfTilesToBuffer
Definition: ossimIgen.h:62
ossimDrect theOutputRect
Definition: ossimIgen.h:59
bool theTilingEnabled
Definition: ossimIgen.h:64
bool theStdoutFlag
Definition: ossimIgen.h:66
ossimKeywordlist theKwl
Definition: ossimIgen.h:63

◆ ~ossimIgen()

ossimIgen::~ossimIgen ( )
virtual

Definition at line 63 of file ossimIgen.cpp.

References ossimConnectableContainer::deleteAllChildren(), ossimConnectableObject::disconnect(), theContainer, theProductProjection, and theTiling.

64 {
66  theTiling = 0;
69  theContainer = 0;
70 }
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
ossimRefPtr< ossimConnectableContainer > theContainer
Definition: ossimIgen.h:55
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
ossimRefPtr< ossimTiling > theTiling
Definition: ossimIgen.h:58

Member Function Documentation

◆ initialize()

void ossimIgen::initialize ( const ossimKeywordlist kwl)
virtual

Definition at line 247 of file ossimIgen.cpp.

References ossimMpi::instance(), slaveSetup(), and theKwl.

248 {
249 #if OSSIM_HAS_MPI
250  if(ossimMpi::instance()->getNumberOfProcessors() > 0)
251  {
252  if(ossimMpi::instance()->getRank() != 0)
253  {
254  slaveSetup();
255  return;
256  }
257  }
258 #endif
259  theKwl = kwl;
260  if(traceDebug())
261  {
263  << "The igen kewyord list ==== \n" << theKwl << std::endl;
264  }
266 
267  kwlPrefs.addPrefixToAll("preferences.");
268  theKwl.add(kwlPrefs);
269 
271 
272  // now stream it to all slave processors
273  //
274 #if OSSIM_HAS_MPI
275  if(ossimMpi::instance()->getNumberOfProcessors() > 0)
276  {
277  std::ostringstream outputKeywordlist;
278 
279  theKwl.writeToStream(outputKeywordlist);
280  ossimString kwlString = outputKeywordlist.str();
281  ossim_uint32 size = kwlString.size();
282 
283  for(long processor = 1;
284  processor < ossimMpi::instance()->getNumberOfProcessors();
285  ++processor)
286  {
287  // let's send the keywordlist argument.
288  // This is two steps. We send a message to
289  // indicate the size and then we send the
290  // string.
291  //
292  MPI_Send(&size,
293  1,
294  MPI_INT,
295  processor,
296  0,
297  MPI_COMM_WORLD);
298 
299  MPI_Send((void*)kwlString.c_str(),
300  size,
301  MPI_CHAR,
302  processor,
303  0,
304  MPI_COMM_WORLD);
305  }
306  }
307 #endif
308  loadProductSpec();
309 
310 }
const ossimKeywordlist & preferencesKWL() const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
Represents serializable keyword/value map.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
yy_size_t size
void slaveSetup()
Definition: ossimIgen.cpp:162
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
void initializeAttributes()
Definition: ossimIgen.cpp:72
virtual void writeToStream(std::ostream &out) const
static ossimPreferences * instance()
int getNumberOfProcessors() const
Definition: ossimMpi.cpp:154
bool loadProductSpec()
Definition: ossimIgen.cpp:312
void addPrefixToAll(const ossimString &prefix)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimKeywordlist theKwl
Definition: ossimIgen.h:63

◆ initializeAttributes()

void ossimIgen::initializeAttributes ( )
protected

Definition at line 72 of file ossimIgen.cpp.

References ossimPreferences::addPreferences(), ossimKeywordlist::find(), ossimMpi::instance(), ossimPreferences::instance(), theBuildThumbnailFlag, theKwl, theProgressFlag, theThumbnailSize, theTilingEnabled, and ossimString::toBool().

Referenced by slaveSetup().

73 {
74  theBuildThumbnailFlag = false;
76  theTilingEnabled = false;
77 
78  if(ossimMpi::instance()->getRank() != 0)
79  {
81  "preferences.",
82  true);
83  }
84 
85  const char* lookup = theKwl.find("igen.output_progress");
86  if (lookup)
87  {
88  ossimString os = lookup;
89  theProgressFlag = os.toBool();
90  }
91 
92  const char* thumbnailStr = theKwl.find("igen.thumbnail");
93  if(traceDebug())
94  {
96  << "Thumbnail string = " << ossimString(thumbnailStr) << std::endl;
97  }
98  if(thumbnailStr)
99  {
100  theBuildThumbnailFlag= ossimString(thumbnailStr).toBool();
101  if(traceDebug())
102  {
104  << "Generate thumbnail attribute is set to "
105  << theBuildThumbnailFlag << std::endl;
106  }
108  {
109  const char* resStr = theKwl.find("igen.thumbnail_res");
110  if(resStr)
111  {
112  theThumbnailSize = ossimIpt(0,0);
113  std::istringstream in(resStr);
114  ossimString x,y;
115 
116  in >> x >> y;
117 
118  ossim_int32 ix = x.toInt32();
119  ossim_int32 iy = y.toInt32();
120 
121  if (ix > 0)
122  {
123  theThumbnailSize.x = ix;
124  }
125  else
126  {
127  theThumbnailSize.x = 128;
128  }
129 
130  if (iy > 0)
131  {
132  theThumbnailSize.y = iy;
133  }
134  else
135  {
137  }
138  }
139  else
140  {
141  theThumbnailSize = ossimIpt(128, 128);
142  }
143  }
144  }
145  const char* numberOfSlaveTileBuffersStr = theKwl.find("igen.slave_tile_buffers");
146  if(numberOfSlaveTileBuffersStr)
147  {
148  theNumberOfTilesToBuffer = ossimString(numberOfSlaveTileBuffersStr).toLong();
149  }
150 
151  const char* tilingKw = theKwl.find("igen.tiling.type");
152  if(tilingKw)
153  {
154  theTilingEnabled = true;
155  if(!theTiling->loadState(theKwl, "igen.tiling."))
156  {
157  theTilingEnabled = false;
158  }
159  }
160 }
ossim_uint32 x
ossim_uint32 y
const char * find(const char *key) const
bool theBuildThumbnailFlag
Definition: ossimIgen.h:60
bool theProgressFlag
Definition: ossimIgen.h:65
bool toBool() const
String to numeric methods.
ossimRefPtr< ossimTiling > theTiling
Definition: ossimIgen.h:58
static ossimPreferences * instance()
ossimIpt theThumbnailSize
Definition: ossimIgen.h:61
long theNumberOfTilesToBuffer
Definition: ossimIgen.h:62
long toLong() const
toLong&#39;s deprecated, please use the toInts...
bool theTilingEnabled
Definition: ossimIgen.h:64
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossim_int32 y
Definition: ossimIpt.h:142
void addPreferences(const ossimKeywordlist &kwl, const char *prefix=0, bool stripPrefix=true)
ossim_int32 x
Definition: ossimIpt.h:141
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
ossimKeywordlist theKwl
Definition: ossimIgen.h:63

◆ initializeChain()

void ossimIgen::initializeChain ( )
protected

Definition at line 725 of file ossimIgen.cpp.

References ossimRefPtr< T >::get(), ossimImageChain::getBoundingRect(), ossimImageChain::getImageGeometry(), ossimDrect::hasNans(), ossimImageChain::initialize(), ossimImageGeometry::setImageSize(), ossimDrect::size(), ossimDrect::stretchOut(), theOutputRect, and theProductChain.

Referenced by outputProduct(), and setView().

726 {
727  // Force initialization of the chain to recompute parameters:
730 
731  if(!theOutputRect.hasNans())
732  {
733  // Stretch the rectangle out to integer boundaries.
735 
736  // Communicate the new product size to the view's geometry object. This is a total HACK that
737  // external code needs to worry about setting this. Something is wrong with this picture
738  // (OLK 02/11)
740  if (geom)
742  }
743 }
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
virtual void initialize()
void setImageSize(const ossimIpt &size)
ossimRefPtr< ossimImageChain > theProductChain
Definition: ossimIgen.h:57
bool hasNans() const
Definition: ossimDrect.h:396
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Will pass this call to the head of the list.
ossimDrect theOutputRect
Definition: ossimIgen.h:59
ossimDpt size() const
Definition: ossimDrect.h:524
void stretchOut()
Definition: ossimDrect.cpp:379

◆ initThumbnailProjection()

void ossimIgen::initThumbnailProjection ( )
protected

Modifies the production chain to output redused-resolution thumbnail image.

Definition at line 691 of file ossimIgen.cpp.

References ossimMapProjection::applyScale(), ossimRefPtr< T >::get(), ossimDrect::hasNans(), ossimDrect::height(), ossimDrect::lr(), ossim::max(), setView(), theOutputRect, theProductProjection, theThumbnailSize, ossimDrect::ul(), ossimDrect::width(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

Referenced by outputProduct().

692 {
693  double thumb_size = ossim::max(theThumbnailSize.x, theThumbnailSize.y);
694  ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(theProductProjection.get());
695 
696  if(mapProj && !theOutputRect.hasNans())
697  {
698  double xScale = theOutputRect.width() / thumb_size;
699  double yScale = theOutputRect.height() / thumb_size;
700  double scale = ossim::max(xScale, yScale);
701  mapProj->applyScale(ossimDpt(scale, scale), true);
702  }
703 
704  // Need to change the view in the product chain:
705  setView();
706 
707  // Clamp output rectangle to thumbnail bounds.
708  ossimDpt ul = theOutputRect.ul();
709  ossimDpt lr = theOutputRect.lr();
710  if ( (lr.x - ul.x + 1) > thumb_size)
711  {
712  lr.x = ul.x + thumb_size - 1;
713  }
714  if ( (lr.y - ul.y + 1) > thumb_size )
715  {
716  lr.y = ul.y + thumb_size - 1;
717  }
718  theOutputRect = ossimDrect(ul, lr);
719 }
T max(T a, T b)
Definition: ossimCommon.h:236
ossim_float64 width() const
Definition: ossimDrect.h:522
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
bool hasNans() const
Definition: ossimDrect.h:396
ossim_float64 height() const
Definition: ossimDrect.h:517
ossimIpt theThumbnailSize
Definition: ossimIgen.h:61
ossimDrect theOutputRect
Definition: ossimIgen.h:59
void setView()
Initializes all clients of the view projection to the current product projection. ...
Definition: ossimIgen.cpp:653
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
ossim_int32 x
Definition: ossimIpt.h:141
const ossimDpt & lr() const
Definition: ossimDrect.h:341

◆ loadProductSpec()

bool ossimIgen::loadProductSpec ( )
protected

Definition at line 312 of file ossimIgen.cpp.

313 {
314  const char* MODULE = "ossimIgen::loadProductSpec";
315  if(traceDebug()) CLOG << "entered..." << std::endl;
316 
317  // Clear out the overall container and initialize it with spec in KWL:
320 
321  // There should be a product chain defined in the container:
322  // ossimConnectableObject* obj =
323  // theContainer->findFirstObjectOfType(STATIC_TYPE_NAME(ossimImageChain), false);
324  // theProductChain = PTR_CAST(ossimImageChain, obj);
325 
326  ossimTypeNameVisitor visitor( ossimString("ossimImageChain"),
327  true, // firstofTypeFlag
330  theContainer->accept( visitor );
331  theProductChain = visitor.getObjectAs<ossimImageChain>(0);
332 
333  if (!theProductChain.valid())
334  {
335  // Search for a connectable container specified that contains the entire product chain:
336  // ossimConnectableObject* obj2 =
337  // theContainer->findFirstObjectOfType(STATIC_TYPE_NAME(ossimImageFileWriter), true);
338  // ossimImageFileWriter* writer = PTR_CAST(ossimImageFileWriter, obj2);
339  visitor.reset();
340  visitor.setTypeName( ossimString( "ossimImageFileWriter" ) );
341  theContainer->accept( visitor );
342  ossimRefPtr<ossimImageFileWriter> writer = visitor.getObjectAs<ossimImageFileWriter>(0);
343  if ( writer.valid() )
344  {
345  theProductChain = dynamic_cast<ossimImageChain*>( writer->getInput() );
346  }
347 
348  if (!theProductChain.valid())
349  {
351  << " -- No processing chain defined for generating product." << std::endl;
352  return false;
353  }
354  }
355 
356  // The output projection is specified separately in the KWL:
357  ossimString prefix = "product.projection.";
358  theProductProjection = dynamic_cast<ossimMapProjection*>(
360 
361  const char* lookup = theKwl.find("igen.write_to_stdout");
362  if (lookup && ossimString(lookup).toBool())
363  {
364  theStdoutFlag = true;
365  }
366 
367  return true;
368 }
#define CLOG
Definition: ossimTrace.h:23
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
ossimRefPtr< ossimConnectableContainer > theContainer
Definition: ossimIgen.h:55
Pure virtual base class for image file writers.
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
ossimRefPtr< ossimImageChain > theProductChain
Definition: ossimIgen.h:57
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
static ossimProjectionFactoryRegistry * instance()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
bool theStdoutFlag
Definition: ossimIgen.h:66
ossimKeywordlist theKwl
Definition: ossimIgen.h:63

◆ outputProduct()

void ossimIgen::outputProduct ( )
virtual

Writes the output product image. Throws an ossimException if error encountered.

Definition at line 373 of file ossimIgen.cpp.

References ossimConnectableContainer::accept(), ossimImageChain::addFirst(), ossimImageFileWriter::changeSequencer(), ossimConnectableObject::connectMyInputTo(), ossimMultiThreadSequencer::d_cacheEmptyCount, ossimMultiThreadSequencer::d_idleTime2, ossimMultiThreadSequencer::d_idleTime5, ossimMultiThreadSequencer::d_jobGetTileT, ossimMultiThreadSequencer::d_maxCacheUsed, ossimFilename::dirCat(), ossimConnectableObject::disconnect(), ossimRefPtr< T >::get(), ossimTilingPoly::getExteriorCut(), ossimImageFileWriter::getFilename(), ossimTilingPoly::getInteriorCut(), ossimMultiThreadSequencer::getNumberOfThreads(), ossimCollectionVisitor::getObjectAs(), ossimMultiThreadSequencer::handlerGetTileT(), ossimTilingPoly::hasExteriorCut(), ossimTilingPoly::hasInteriorCut(), ossimTiling::initialize(), ossimImageFileWriter::initialize(), initializeChain(), initThumbnailProjection(), ossimMpi::instance(), ossimFilename::isDir(), ossimTilingPoly::isFeatureBoundingIntersect(), ossimTiling::next(), ossimFilename::path(), ossimImageFileWriter::setAreaOfInterest(), ossimImageFileWriter::setFilename(), ossimImageFileWriter::setOutputStream(), ossimRectangleCutFilter::setRectangle(), setView(), theBuildThumbnailFlag, theContainer, theNumberOfTilesToBuffer, theOutputRect, theProductChain, theProductProjection, theStdoutFlag, theThreadCount, theTiling, theTilingEnabled, ossimString::toString(), ossimTilingPoly::useMbr(), ossimRefPtr< T >::valid(), ossimVisitor::VISIT_CHILDREN, ossimVisitor::VISIT_INPUTS, and writeToFile().

374 {
375  // Verify that all vitals have been initialized:
376  if (!theProductChain.valid())
377  {
378  std::string err = "ossimIgen::outputProduct() ERROR: No product processing chain has yet"
379  " been established. Nothing to output!";
380  throw(ossimException(err));
381  }
383  {
384  std::string err = "ossimIgen::outputProduct() ERROR: No product projection has yet"
385  " been established. Nothing to output!";
386  throw(ossimException(err));
387  }
388 
389  // Update the chain with the product view specified:
390  setView();
391  initializeChain();
392 
393  // if it's a thumbnail then adjust the GSD and reset the view proj to the chain.
396 
398 
399 #if OSSIM_HAS_MPI
400  // only allocate the slave connection if the number of processors is larger than 1
401  if(ossimMpi::instance()->getNumberOfProcessors() > 1)
402  {
403  if(ossimMpi::instance()->getRank()!=0)
405  else
406  sequencer = new ossimImageMpiMWriterSequenceConnection();
407  }
408 #endif
409 
410  // we will just load a serial connection if MPI is not supported.
411  // Threading?
412  if (!sequencer.valid() && (theThreadCount != 9999))
413  sequencer = new ossimMultiThreadSequencer(0, theThreadCount);
414 
415  if (!sequencer.valid())
416  sequencer = new ossimImageSourceSequencer(0);
417 
418 
419  // Look for the first writer (should be the only writer) in our list of objects:
420 
421  // ossimRefPtr<ossimImageFileWriter> writer = 0;
422  // ossimConnectableObject::ConnectableObjectList imageWriters =
423  // theContainer->findAllObjectsOfType(STATIC_TYPE_INFO(ossimImageFileWriter), false);
424 
425  ossimTypeNameVisitor visitor( ossimString("ossimImageFileWriter"),
426  true, // firstofTypeFlag
429  theContainer->accept( visitor );
430  ossimRefPtr<ossimImageFileWriter> writer = visitor.getObjectAs<ossimImageFileWriter>(0);
431 
432  if ( !writer.valid() )
433  {
434  sequencer = 0;
435  std::string err = "ossimIgen::outputProduct() ERROR: No image writer object was found in "
436  " processing chain.";
437  throw(ossimException(err));
438  }
439 
440  // writer = PTR_CAST(ossimImageFileWriter, imageWriters[0].get());
441  writer->changeSequencer(sequencer.get());
443 
444  // Check for writing to standard output flag. Not all writers support this so check and
445  // throw an error if not supported.
446  if (theStdoutFlag)
447  {
448  if ( writer->setOutputStream(std::cout) == false )
449  {
450  std::string err = "ERROR: The write to standard out flag is set; however, writer does "
451  "not support going to standard out. Bummer...";
452  throw(ossimException(err));
453  }
454  }
455 
456  writer->initialize();
457 
458  if ( theBuildThumbnailFlag )
459  {
460  //---
461  // Use theOutputRect as it has been clamped to be within the requested thumbnail size.
462  //
463  // Relying of the bounding rectangle of the scaled product chain has given us off by
464  // one rectangles, i.e., a width of 513 instead of 512.
465  //
466  // NOTE: This must be called after the writer->initialize() as
467  // ossimImageFileWriter::initialize incorrectly resets theAreaOfInterest
468  // back to the bounding rect.
469  //---
471  }
472 
473  // If multi-file tiled output is not desired perform simple output, handle special:
475  {
477 
478  ossimRectangleCutFilter* cut = 0;
479  ossimTilingPoly* tilingPoly = dynamic_cast<ossimTilingPoly*>( theTiling.get() );
480 
481  ossimFilename tempFile = writer->getFilename();
482  if(!tempFile.isDir())
483  {
484  tempFile = tempFile.path();
485  }
486 
487  ossimString tileName;
488  ossimIrect clipRect;
489 
490  // 'next' method modifies the mapProj which is the same instance as theProductProjection,
491  // so this data member is modified here, then later accessed by setView:
492  while(theTiling->next(theProductProjection, clipRect, tileName))
493  {
494  if ( !tilingPoly )//use ossimTiling or ossimTilingRect
495  {
496  // Disconnect prior to setting up chain.
497  writer->disconnect();
498 
499  // This will progate the updated projection from theTiling->next call.
500  setView();
501 
502  // Recompute the bounding rect:
503  initializeChain();
504 
505  // Hook writer up:
507  writer->setFilename(tempFile.dirCat(tileName));
508  writer->initialize();
509 
510  // Set the clip rect for tile:
511  writer->setAreaOfInterest( clipRect );
512  }
513  else //otherwise use ossimTilingPoly
514  {
515  if (tilingPoly != NULL)
516  {
517  if (!tilingPoly->isFeatureBoundingIntersect())//if clip rect does not intersect with output rect, do nothing
518  {
519  continue;
520  }
521  if (tilingPoly->useMbr())//if use_mbr flag is set to true, all pixels within the MBR will be preserved
522  {
523  if (cut == NULL)
524  {
525  cut = new ossimRectangleCutFilter;
527  }
528  setView();
529  cut->setRectangle(clipRect);
530  }
531  else
532  {
533  if ( tilingPoly->hasExteriorCut() )
534  {
535  theProductChain->addFirst( tilingPoly->getExteriorCut().get() );
536  }
537  if ( tilingPoly->hasInteriorCut() )
538  {
539  theProductChain->addFirst( tilingPoly->getInteriorCut().get() );
540  }
541  }
542  }
543 
544  initializeChain();
545  writer->disconnect();
547  writer->setFilename(tempFile.dirCat(tileName));
548  writer->initialize();
549 
550  } // if ( !tilingPoly ){} else{
551 
552 
553  // Write the file:
554  if ( !writeToFile( writer.get() ))
555  {
556  break;
557  }
558  }
559  }
560  else
561  {
562  // No multi-file tiling, just conventional write to single file:
563  writeToFile(writer.get());
564  }
565 
566  //########## DEBUG CODE FOR TIMING MULTI THREAD LOCKS ##############
567  if (sequencer.valid() && (theThreadCount != 9999))
568  {
569  ossimMultiThreadSequencer* mts = dynamic_cast<ossimMultiThreadSequencer*>(sequencer.get());
570  if (mts != NULL)
571  {
572 
573  double jgtt = mts->d_jobGetTileT;
574  ossim_uint32 num_threads = mts->getNumberOfThreads();
575  double jgttpj = jgtt/num_threads;
576  cout<<setprecision(3)<<endl;
577  cout << "Multi-threading metrics ---"<<endl;
578  cout << " Number of threads: " << num_threads<< endl;
579  cout << " Max cache used: "<< mts->d_maxCacheUsed << endl;
580  cout << " Cache emptied count: "<< ossimString::toString(mts->d_cacheEmptyCount) << endl;
581  cout << " Time waiting on jobs: "<<mts->d_idleTime2<<" s"<<endl;
582  cout << " Time waiting on cache: "<<mts->d_idleTime5<<" s"<<endl;
583  cout << " Handler getTile T: "<<mts->handlerGetTileT()<<" s"<<endl;
584  cout << " Job getTile T: "<<jgtt<<" s"<<endl;
585  cout << " Average getTile T/job: "<<jgttpj<<" s\n"<<endl;
586  }
587  }
588  //##################################################################
589 }
void setRectangle(const ossimIrect &rect)
ossim_uint32 getNumberOfThreads() const
Fetches the number of threads being used. Useful when this object decides the quantity.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
ossimRefPtr< ossimGeoPolyCutter > & getExteriorCut()
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimGeoPolyCutter > & getInteriorCut()
bool writeToFile(ossimImageFileWriter *writer)
Consolidates job of actually writing to the output file.
Definition: ossimIgen.cpp:594
bool useMbr() const
void initializeChain()
Definition: ossimIgen.cpp:725
static ossimString toString(bool aValue)
Numeric to string methods.
bool hasExteriorCut() const
return true if exterior cut is initialized.
bool initialize(const ossimMapProjection &proj, const ossimIrect &boundingRect)
Definition: ossimTiling.cpp:48
ossimRefPtr< ossimConnectableContainer > theContainer
Definition: ossimIgen.h:55
Pure virtual base class for image file writers.
bool isDir() const
virtual bool setOutputStream(ossimRefPtr< ossimOStream > stream)
Sets the output stream to write to.
bool theBuildThumbnailFlag
Definition: ossimIgen.h:60
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
ossimRefPtr< ossimImageChain > theProductChain
Definition: ossimIgen.h:57
ossim_uint32 theThreadCount
Definition: ossimIgen.h:67
ossimRefPtr< ossimTiling > theTiling
Definition: ossimIgen.h:58
unsigned int ossim_uint32
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
long theNumberOfTilesToBuffer
Definition: ossimIgen.h:62
virtual void setFilename(const ossimFilename &file)
ossimDrect theOutputRect
Definition: ossimIgen.h:59
virtual const ossimFilename & getFilename() const
bool theTilingEnabled
Definition: ossimIgen.h:64
void initThumbnailProjection()
Modifies the production chain to output redused-resolution thumbnail image.
Definition: ossimIgen.cpp:691
void setView()
Initializes all clients of the view projection to the current product projection. ...
Definition: ossimIgen.cpp:653
This class manages the sequencing of tile requests across multiple threads.
virtual void initialize()
Initialize method.
virtual void setAreaOfInterest(const ossimIrect &inputRect)
ossimFilename dirCat(const ossimFilename &file) const
virtual void changeSequencer(ossimImageSourceSequencer *sequencer)
Sets the sequencer and connects it to the input of this.
bool isFeatureBoundingIntersect() const
bool next(ossimRefPtr< ossimMapProjection > &resultProjection, ossimIrect &resultingBounds, ossimString &resultingName) const
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
ossimFilename path() const
bool addFirst(ossimConnectableObject *obj)
Adds it to the start of the chain.
bool hasInteriorCut() const
return true if interior cut is initialized.
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
bool theStdoutFlag
Definition: ossimIgen.h:66

◆ setView()

void ossimIgen::setView ( )
protected

Initializes all clients of the view projection to the current product projection.

Definition at line 653 of file ossimIgen.cpp.

References ossimImageChain::accept(), ossimProjection::dup(), ossimCollectionVisitor::getObjectAs(), ossimCollectionVisitor::getObjects(), initializeChain(), ossimViewInterface::setView(), STATIC_TYPE_INFO, theProductChain, theProductProjection, ossimRefPtr< T >::valid(), ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

Referenced by initThumbnailProjection(), and outputProduct().

654 {
656  {
657  // Find all view clients in the chain, and notify them of the new view:
658 #if 0
660  theProductChain->findAllInputsOfType(clientList, STATIC_TYPE_INFO(ossimViewInterface), true, true);
661  for(ossim_uint32 i = 0; i < clientList.size();++i)
662  {
663  ossimViewInterface* viewClient = dynamic_cast<ossimViewInterface*>( clientList[i].get() );
664  if (viewClient)
665  viewClient->setView(theProductProjection->dup());
666  }
667 #endif
668 
669  ossimTypeNameVisitor visitor( ossimString("ossimViewInterface"),
670  false, // firstofTypeFlag
673  theProductChain->accept( visitor );
674  for( ossim_uint32 i = 0; i < visitor.getObjects().size(); ++i )
675  {
676  ossimViewInterface* viewClient = visitor.getObjectAs<ossimViewInterface>( i );
677  if (viewClient)
678  {
679  viewClient->setView( theProductProjection->dup() );
680  }
681  }
682 
683  // Force recompute of bounding rect:
684  initializeChain();
685  }
686 }
virtual ossimObject * dup() const =0
bool valid() const
Definition: ossimRefPtr.h:75
void initializeChain()
Definition: ossimIgen.cpp:725
ossimRefPtr< ossimMapProjection > theProductProjection
Definition: ossimIgen.h:56
ossimRefPtr< ossimImageChain > theProductChain
Definition: ossimIgen.h:57
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
unsigned int ossim_uint32
#define STATIC_TYPE_INFO(T)
Definition: ossimRtti.h:319
virtual bool setView(ossimObject *baseObject)=0

◆ slaveSetup()

void ossimIgen::slaveSetup ( )
protected

Definition at line 162 of file ossimIgen.cpp.

References ossimKeywordlist::clear(), ossimMpi::getRank(), initializeAttributes(), ossimMpi::instance(), ossimNotify(), ossimNotifyLevel_WARN, ossimKeywordlist::parseStream(), status, and theKwl.

Referenced by initialize().

163 {
164 #if OSSIM_HAS_MPI
165  int stringSize;
166  MPI_Status status;
167  int numberOfTimes = 0;
168 
169  memset((void *)&status, 0, sizeof(MPI_Status));
170 
171 
172  // we first need to receive the size of the keyword list to load
173  MPI_Recv(&stringSize,
174  1,
175  MPI_INT,
176  0, // source
177  0, // tag
178  MPI_COMM_WORLD,
179  &status);
180 
181  if(status.MPI_ERROR != MPI_SUCCESS)
182  {
184  << "SLAVE = "
186  << "Had errors receiving!!!!" << std::endl;
187  return;
188  }
189 
190  char* buf = new char[stringSize+1];
191 
192  numberOfTimes = 0;
193 
194  memset((void *)&status, 0, sizeof(MPI_Status));
195 
196  // now lets get the keywordlist as a string so we can load it up
197  MPI_Recv(buf,
198  stringSize,
199  MPI_CHAR,
200  0, // source
201  0, // tag
202  MPI_COMM_WORLD,
203  &status);
204 
205  if(status.MPI_ERROR != MPI_SUCCESS)
206  {
208  << "SLAVE = " << ossimMpi::instance()->getRank()
209  << "Had errors receiving in ossimIgen::slaveCreate(!!!!"
210  << std::endl;
211  return;
212  }
213  buf[stringSize] = '\0';
214 
215  if(status.MPI_ERROR != MPI_SUCCESS)
216  {
218  << "SLAVE = " << ossimMpi::instance()->getRank()
219  << "Had errors receiving!!!!" << std::endl;
220  return;
221  }
222 
223  // now lets convert the received keywordlist into an actual
224  // ossimKeywordlist by using the parsStream method.
225  std::ostringstream kwlStream;
226 
227  kwlStream << buf << ends;
228 
229  istringstream kwlInStream(kwlStream.str());
230  theKwl.clear();
231  theKwl.parseStream(kwlInStream);
233  delete [] buf;
234  buf = 0;
235 
236  if(traceDebug())
237  {
238  ossimNotify(ossimNotifyLevel_DEBUG) << "****************** KWL ************************" << std::endl;
239  ossimNotify(ossimNotifyLevel_DEBUG) << theKwl << std::endl;
240  ossimNotify(ossimNotifyLevel_DEBUG) << "**************** END KWL ************************" << std::endl;
241 
242  }
243  loadProductSpec();
244 #endif
245 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
void initializeAttributes()
Definition: ossimIgen.cpp:72
bool loadProductSpec()
Definition: ossimIgen.cpp:312
return status
int getRank() const
Definition: ossimMpi.cpp:140
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimKeywordlist theKwl
Definition: ossimIgen.h:63

◆ writeToFile()

bool ossimIgen::writeToFile ( ossimImageFileWriter writer)
protected

Consolidates job of actually writing to the output file.

Definition at line 594 of file ossimIgen.cpp.

References ossimImageFileWriter::addListener(), ossimMpi::instance(), and theProgressFlag.

Referenced by outputProduct().

595 {
596  ossimStdOutProgress* prog = 0;
597  if ( (ossimMpi::instance()->getRank() == 0) && theProgressFlag)
598  {
599  // Add a listener to master.
600  prog = new ossimStdOutProgress(0, true);
601  writer->addListener(prog);
602  }
603 
604  if (traceLog() && (ossimMpi::instance()->getRank() == 0))
605  {
606  ossimFilename logFile = writer->getFilename();
607  logFile.setExtension(ossimString("log"));
608 
610  writer->fillContainer(*container.get());
611  ossimKeywordlist logKwl;
612  container->saveState(logKwl);
613  logKwl.write(logFile.c_str());
614  }
615 
616  try
617  {
618  writer->execute();
619  }
620 
621  // Catch internal exceptions:
622  catch(const ossimException& e)
623  {
625  << "ossimIgen::outputProduct ERROR:\n"
626  << "Caught exception!\n"
627  << e.what()
628  << std::endl;
629  return false;
630  }
631  catch(...)
632  {
634  << "ossimIgen::outputProduct ERROR:\n"
635  << "Unknown exception caught!\n"
636  << std::endl;
637  return false;
638  }
639 
640  if (prog)
641  {
642  writer->removeListener(prog);
643  delete prog;
644  prog = 0;
645  }
646 
647  return true;
648 }
Represents serializable keyword/value map.
virtual bool addListener(ossimListener *listener)
Overrides base "addListener" this will capture the pointer and then call the base class "addListener"...
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
bool theProgressFlag
Definition: ossimIgen.h:65
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual const char * what() const
Returns the error message.
virtual const ossimFilename & getFilename() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual bool removeListener(ossimListener *listener)
Overrides base "removeListener".
virtual bool fillContainer(ossimConnectableContainer &container)
Inserts this object and all of its children and inputs into the container provided.
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()

Member Data Documentation

◆ theBuildThumbnailFlag

bool ossimIgen::theBuildThumbnailFlag
protected

Definition at line 60 of file ossimIgen.h.

Referenced by initializeAttributes(), and outputProduct().

◆ theContainer

ossimRefPtr<ossimConnectableContainer> ossimIgen::theContainer
protected

Definition at line 55 of file ossimIgen.h.

Referenced by outputProduct(), and ~ossimIgen().

◆ theKwl

ossimKeywordlist ossimIgen::theKwl
protected

Definition at line 63 of file ossimIgen.h.

Referenced by initialize(), initializeAttributes(), and slaveSetup().

◆ theNumberOfTilesToBuffer

long ossimIgen::theNumberOfTilesToBuffer
protected

Definition at line 62 of file ossimIgen.h.

Referenced by outputProduct().

◆ theOutputRect

ossimDrect ossimIgen::theOutputRect
protected

Definition at line 59 of file ossimIgen.h.

Referenced by initializeChain(), initThumbnailProjection(), ossimIgen(), and outputProduct().

◆ theProductChain

ossimRefPtr<ossimImageChain> ossimIgen::theProductChain
protected

Definition at line 57 of file ossimIgen.h.

Referenced by initializeChain(), outputProduct(), and setView().

◆ theProductProjection

ossimRefPtr<ossimMapProjection> ossimIgen::theProductProjection
protected

Definition at line 56 of file ossimIgen.h.

Referenced by initThumbnailProjection(), outputProduct(), setView(), and ~ossimIgen().

◆ theProgressFlag

bool ossimIgen::theProgressFlag
protected

Definition at line 65 of file ossimIgen.h.

Referenced by initializeAttributes(), and writeToFile().

◆ theStdoutFlag

bool ossimIgen::theStdoutFlag
protected

Definition at line 66 of file ossimIgen.h.

Referenced by outputProduct().

◆ theThreadCount

ossim_uint32 ossimIgen::theThreadCount
protected

Definition at line 67 of file ossimIgen.h.

Referenced by outputProduct().

◆ theThumbnailSize

ossimIpt ossimIgen::theThumbnailSize
protected

Definition at line 61 of file ossimIgen.h.

Referenced by initializeAttributes(), and initThumbnailProjection().

◆ theTiling

ossimRefPtr<ossimTiling> ossimIgen::theTiling
protected

Definition at line 58 of file ossimIgen.h.

Referenced by outputProduct(), and ~ossimIgen().

◆ theTilingEnabled

bool ossimIgen::theTilingEnabled
protected

Definition at line 64 of file ossimIgen.h.

Referenced by initializeAttributes(), and outputProduct().


The documentation for this class was generated from the following files: