Ver Fonte

*** empty log message ***

David Rose há 24 anos atrás
pai
commit
4ef7ac822c

+ 22 - 2
pandaapp/src/stitch/stitchImageProgram.cxx

@@ -47,12 +47,19 @@ StitchImageProgram() {
      &StitchImageProgram::dispatch_double, NULL, &_filter_factor);
      &StitchImageProgram::dispatch_double, NULL, &_filter_factor);
 
 
   add_option
   add_option
-    ("n", "name", 0,
+    ("o", "name", 0,
      "Generates only the named output image.  This may be repeated to "
      "Generates only the named output image.  This may be repeated to "
      "generate multiple images in one run.  If omitted, all output images "
      "generate multiple images in one run.  If omitted, all output images "
-     "in the file are generated.",
+     "in the file are generated.  The name may include filename globbing "
+     "symbols, e.g. 'grid*'.  You should quote such names to protect them "
+     "from shell expansion.",
      &StitchImageProgram::dispatch_output_name);
      &StitchImageProgram::dispatch_output_name);
 
 
+  add_option
+    ("i", "name", 0,
+     "Generates only the named input image or images, as above.",
+     &StitchImageProgram::dispatch_input_name);
+
   add_option
   add_option
     ("s", "xsize,ysize", 0,
     ("s", "xsize,ysize", 0,
      "Generates the output image(s) at the specified size, rather than the "
      "Generates the output image(s) at the specified size, rather than the "
@@ -89,6 +96,19 @@ dispatch_output_name(ProgramBase *self, const string &opt,
   return true;
   return true;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: StitchImageProgram::dispatch_input_name
+//       Access: Protected, Static
+//  Description: Dispatch function for an input image name.
+////////////////////////////////////////////////////////////////////
+bool StitchImageProgram::
+dispatch_input_name(ProgramBase *self, const string &opt,
+                    const string &arg, void *) {
+  StitchImageProgram *prog = (StitchImageProgram *)self;
+  prog->_outputter.add_input_name(arg);
+  return true;
+}
+
 
 
 int main(int argc, char *argv[]) {
 int main(int argc, char *argv[]) {
   StitchImageProgram prog;
   StitchImageProgram prog;

+ 2 - 0
pandaapp/src/stitch/stitchImageProgram.h

@@ -39,6 +39,8 @@ public:
 protected:
 protected:
   static bool dispatch_output_name(ProgramBase *self, const string &opt,
   static bool dispatch_output_name(ProgramBase *self, const string &opt,
                                    const string &arg, void *);
                                    const string &arg, void *);
+  static bool dispatch_input_name(ProgramBase *self, const string &opt,
+                                  const string &arg, void *);
 
 
 private:
 private:
   double _filter_factor;
   double _filter_factor;

+ 6 - 1
pandaapp/src/stitchbase/stitchImage.cxx

@@ -22,6 +22,7 @@
 
 
 #include "compose_matrix.h"
 #include "compose_matrix.h"
 #include "rotate_to.h"
 #include "rotate_to.h"
+#include "executionEnvironment.h"
 
 
 StitchImage::
 StitchImage::
 StitchImage(const string &name, const string &filename,
 StitchImage(const string &name, const string &filename,
@@ -34,9 +35,13 @@ StitchImage(const string &name, const string &filename,
   _film_offset_mm(film_offset_mm),
   _film_offset_mm(film_offset_mm),
   _transform(LMatrix4d::ident_mat()),
   _transform(LMatrix4d::ident_mat()),
   _inv_transform(LMatrix4d::ident_mat()),
   _inv_transform(LMatrix4d::ident_mat()),
-  _filename(filename),
   _name(name)
   _name(name)
 {
 {
+  _filename = ExecutionEnvironment::expand_string(filename);
+  if (_name.empty()) {
+    _name = _filename.get_basename_wo_extension();
+  }
+
   _size_mm.set((_size_pixels[0] - 1.0) / _pixels_per_mm[0],
   _size_mm.set((_size_pixels[0] - 1.0) / _pixels_per_mm[0],
                (_size_pixels[1] - 1.0) / _pixels_per_mm[1]);
                (_size_pixels[1] - 1.0) / _pixels_per_mm[1]);
   _orig_size_pixels = _size_pixels;
   _orig_size_pixels = _size_pixels;

+ 57 - 9
pandaapp/src/stitchbase/stitchImageRasterizer.cxx

@@ -32,20 +32,21 @@ StitchImageRasterizer() {
 
 
 void StitchImageRasterizer::
 void StitchImageRasterizer::
 add_input_image(StitchImage *image) {
 add_input_image(StitchImage *image) {
-  _input_images.push_back(image);
+  if (has_input_name(image->get_name())) {
+    cerr << "Input image " << image->get_name() << "\n";
+    _input_images.push_back(image);
+  }
 }
 }
 
 
 void StitchImageRasterizer::
 void StitchImageRasterizer::
 add_output_image(StitchImage *image) {
 add_output_image(StitchImage *image) {
   if (has_output_name(image->get_name())) {
   if (has_output_name(image->get_name())) {
+    cerr << "Output image " << image->get_name() << "\n";
     if (_got_output_size) {
     if (_got_output_size) {
       image->set_size_pixels(LPoint2d(_output_xsize, _output_ysize));
       image->set_size_pixels(LPoint2d(_output_xsize, _output_ysize));
     }
     }
     image->set_output_scale_factor(_filter_factor);
     image->set_output_scale_factor(_filter_factor);
     _output_images.push_back(image);
     _output_images.push_back(image);
-
-  } else {
-    cerr << "Ignoring output image " << image->get_name() << "\n";
   }
   }
 }
 }
 
 
@@ -99,16 +100,56 @@ execute() {
   }
   }
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: StitchImageRasterizer::add_input_name
+//       Access: Public
+//  Description: Adds the indicated name to the set of input image
+//               names that will be generated.  The name may include
+//               globbing symbols.  If no names are added, all input
+//               images will be generated.
+////////////////////////////////////////////////////////////////////
+void StitchImageRasterizer::
+add_input_name(const string &name) {
+  _input_names.push_back(GlobPattern(name));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: StitchImageRasterizer::has_input_name
+//       Access: Public
+//  Description: Returns true if the indicated input image name is
+//               one that should be generated.  This will be true if
+//               this name has been added via add_input_name(), or if
+//               no names at all have been added.
+////////////////////////////////////////////////////////////////////
+bool StitchImageRasterizer::
+has_input_name(const string &name) const {
+  if (_input_names.empty()) {
+    // If no names have been added, all names are good.
+    return true;
+  }
+
+  // Otherwise, the name is good only if it matches a name on the list.
+  Names::const_iterator ni;
+  for (ni = _input_names.begin(); ni != _input_names.end(); ++ni) {
+    if ((*ni).matches(name)) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: StitchImageRasterizer::add_output_name
 //     Function: StitchImageRasterizer::add_output_name
 //       Access: Public
 //       Access: Public
 //  Description: Adds the indicated name to the set of output image
 //  Description: Adds the indicated name to the set of output image
-//               names that will be generated.  If no names are added,
-//               all output images will be generated.
+//               names that will be generated.  The name may include
+//               globbing symbols.  If no names are added, all output
+//               images will be generated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void StitchImageRasterizer::
 void StitchImageRasterizer::
 add_output_name(const string &name) {
 add_output_name(const string &name) {
-  _output_names.insert(name);
+  _output_names.push_back(GlobPattern(name));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -126,8 +167,15 @@ has_output_name(const string &name) const {
     return true;
     return true;
   }
   }
 
 
-  // Otherwise, the name is good only if it is on the list.
-  return (_output_names.count(name) != 0);
+  // Otherwise, the name is good only if it matches a name on the list.
+  Names::const_iterator ni;
+  for (ni = _output_names.begin(); ni != _output_names.end(); ++ni) {
+    if ((*ni).matches(name)) {
+      return true;
+    }
+  }
+
+  return false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 5 - 2
pandaapp/src/stitchbase/stitchImageRasterizer.h

@@ -22,8 +22,8 @@
 #include "stitchImageOutputter.h"
 #include "stitchImageOutputter.h"
 
 
 #include "pvector.h"
 #include "pvector.h"
-#include "pset.h"
 #include "luse.h"
 #include "luse.h"
+#include "globPattern.h"
 
 
 class Stitcher;
 class Stitcher;
 class StitchImage;
 class StitchImage;
@@ -38,6 +38,8 @@ public:
 
 
   virtual void execute();
   virtual void execute();
 
 
+  void add_input_name(const string &name);
+  bool has_input_name(const string &name) const;
   void add_output_name(const string &name);
   void add_output_name(const string &name);
   bool has_output_name(const string &name) const;
   bool has_output_name(const string &name) const;
 
 
@@ -62,7 +64,8 @@ private:
   typedef pvector<Stitcher *> Stitchers;
   typedef pvector<Stitcher *> Stitchers;
   Stitchers _stitchers;
   Stitchers _stitchers;
 
 
-  typedef pset<string> Names;
+  typedef pvector<GlobPattern> Names;
+  Names _input_names;
   Names _output_names;
   Names _output_names;
 
 
   double _filter_factor;
   double _filter_factor;

+ 1 - 1
pandaapp/src/stitchbase/stitchLexer.lxx

@@ -307,7 +307,7 @@ NUMERIC         ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
   return STRING;
   return STRING;
 }
 }
 
 
-[a-zA-Z][a-zA-Z0-9_]* {
+[a-zA-Z][a-zA-Z0-9_-]* {
   // Identifier or keyword.
   // Identifier or keyword.
   accept();
   accept();
   string str = yytext;
   string str = yytext;