Exemple #1
0
static void		reshapeCB(GLsizei w, GLsizei h)
{
  aspectRatio = (GLdouble)w / (GLdouble)h;
  glViewport(0, 0, w, h);
  initProjection();
  glutPostRedisplay();
}
Exemple #2
0
void App::initProjectionFiles(void) {
    const QString file_gcs = "gcs.csv";
    const QString file_pcs = "pcs.csv";
    readProjections(file_gcs);
    readProjections(file_pcs);
    initProjection();
}
EnumerationConstraint* ModelEnumerator::doInit(SharedContext& ctx, SharedMinimizeData* opt, int numModels) {
	initProjection(ctx);
	uint32 st = strategy();
	if (detectStrategy() || (ctx.concurrency() > 1 && !ModelEnumerator::supportsParallel())) {
		st = 0;
	}
	bool optOne  = opt && opt->mode() == MinimizeMode_t::optimize;
	bool trivial = optOne || std::abs(numModels) == 1;
	if (optOne && projectionEnabled()) {
		for (const WeightLiteral* it =  minimizer()->lits; !isSentinel(it->first) && trivial; ++it) {
			trivial = ctx.varInfo(it->first.var()).project();
		}
		if (!trivial) { ctx.report(warning(Event::subsystem_prepare, "Projection: Optimization may depend on enumeration order.")); }
	}
	if (st == strategy_auto) { st  = trivial || (projectionEnabled() && ctx.concurrency() > 1) ? strategy_record : strategy_backtrack; }
	if (trivial)             { st |= trivial_flag; }
	options_ &= ~uint32(strategy_opts_mask);
	options_ |= st;
	const LitVec* dom = (projectOpts() & project_dom_lits) != 0 ? (ctx.heuristic.domRec = &domRec_) : 0;
	EnumerationConstraint* c = st == strategy_backtrack
	  ? static_cast<ConPtr>(new BacktrackFinder(projectOpts()))
	  : static_cast<ConPtr>(new RecordFinder(dom));
	if (projectionEnabled()) { setIgnoreSymmetric(true); }
	return c;
}
EnumerationConstraint* ModelEnumerator::doInit(SharedContext& ctx, MinimizeConstraint* min, int numModels) {
	delete queue_;
	queue_ = 0;
	initProjection(ctx); 
	uint32 st = strategy();
	if (detectStrategy() || (ctx.concurrency() > 1 && !ModelEnumerator::supportsParallel())) {
		st = 0;
	}
	bool optOne  = minimizer() && minimizer()->mode() == MinimizeMode_t::optimize;
	bool trivial = optOne || std::abs(numModels) == 1;
	if (optOne && project_) {
		const SharedMinimizeData* min = minimizer();
		for (const WeightLiteral* it = min->lits; !isSentinel(it->first) && trivial; ++it) {
			trivial = ctx.varInfo(it->first.var()).project();
		}
		if (!trivial) { ctx.report(warning(Event::subsystem_prepare, "Projection: Optimization may depend on enumeration order.")); }
	}
	if (st == strategy_auto) { st  = trivial || (project_ && ctx.concurrency() > 1) ? strategy_record : strategy_backtrack; }
	if (trivial)             { st |= trivial_flag; }
	if (ctx.concurrency() > 1 && !trivial && st != strategy_backtrack) {
		queue_ = new SolutionQueue(ctx.concurrency()); 
		queue_->reserve(ctx.concurrency() + 1);
	}
	options_ &= ~uint32(strategy_opts_mask);
	options_ |= st;
	Solver& s = *ctx.master();
	EnumerationConstraint* c = st == strategy_backtrack 
	  ? static_cast<ConPtr>(new BacktrackFinder(s, min, project_, projectOpts()))
	  : static_cast<ConPtr>(new RecordFinder(s, min, project_, queue_));
	if (projectionEnabled()) { setIgnoreSymmetric(true); }
	return c;
}
Exemple #5
0
static void		handleMenu(int value)
{
  switch (value) {
    default:
      break;

    case MENU_SHOW_GLOBE:
      mapMode = 0;
      initProjection();
      glutPostRedisplay();
      glutChangeToMenuEntry(2, "Show Globe *", MENU_SHOW_GLOBE);
      glutChangeToMenuEntry(3, "Show Map", MENU_SHOW_MAP);
      break;

    case MENU_SHOW_MAP:
      mapMode = 1;
      initProjection();
      glutPostRedisplay();
      glutChangeToMenuEntry(2, "Show Globe", MENU_SHOW_GLOBE);
      glutChangeToMenuEntry(3, "Show Map *", MENU_SHOW_MAP);
      break;

    case MENU_ADJUST_GLOBE:
      adjustMode = 0;
      glutChangeToMenuEntry(4, "Adjust Globe *", MENU_ADJUST_GLOBE);
      glutChangeToMenuEntry(5, "Adjust Day", MENU_ADJUST_DAY);
      glutChangeToMenuEntry(6, "Adjust Time", MENU_ADJUST_TIME);
      break;

    case MENU_ADJUST_DAY:
      adjustMode = 1;
      glutChangeToMenuEntry(4, "Adjust Globe", MENU_ADJUST_GLOBE);
      glutChangeToMenuEntry(5, "Adjust Day *", MENU_ADJUST_DAY);
      glutChangeToMenuEntry(6, "Adjust Time", MENU_ADJUST_TIME);
      break;

    case MENU_ADJUST_TIME:
      adjustMode = 2;
      glutChangeToMenuEntry(4, "Adjust Globe", MENU_ADJUST_GLOBE);
      glutChangeToMenuEntry(5, "Adjust Day", MENU_ADJUST_DAY);
      glutChangeToMenuEntry(6, "Adjust Time *", MENU_ADJUST_TIME);
      break;

    case MENU_QUIT:
      exit(0);
  }
}
Exemple #6
0
Camera::Camera():
Node(),
m_fov(45.0f),
m_near(0.01f),
m_far(100.0f)
{
	initProjection();
}
Exemple #7
0
Camera::Camera(Node *inParent, const ID &inID,const float &inFOV, const float &inNear, const float &inFar) :
Node(inParent, inID),
m_fov(45.0f),
m_near(0.01f),
m_far(100.0f){

	initProjection();

}
/**
* resize retina color filter object (resize all allocated buffers)
* @param NBrows: the new height size
* @param NBcolumns: the new width size
*/
void ImageLogPolProjection::resize(const unsigned int NBrows, const unsigned int NBcolumns)
{
    BasicRetinaFilter::resize(NBrows, NBcolumns);
    initProjection(_reductionFactor, _samplingStrenght);

    // reset buffers method
    clearAllBuffers();

}
ElectricSheepEngine::ElectricSheepEngine(float width, float height) {
    reshape(width, height);
    
    const char *vertexShaderPath = pathForFile("vertex", "glsl");
    const char *fragmentShaderPath = pathForFile("fragment", "glsl");
    initShaders(vertexShaderPath, fragmentShaderPath);
    initCamera();
    initProjection();
}
Exemple #10
0
bool ossimLasReader::initFromExternalMetadata()
{
   static const char M[] = "ossimLasReader::initFromExternalMetadata";
   if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   
   bool result = false;

   ossimFilename fgdcFile = theImageFile;
   fgdcFile.setExtension("txt");
   if ( fgdcFile.exists() == false )
   {
      fgdcFile.setExtension("TXT");
   }

   if ( fgdcFile.exists() )
   {
      ossimRefPtr<ossimFgdcTxtDoc> fgdcDoc = new ossimFgdcTxtDoc();
      if ( fgdcDoc->open( fgdcFile ) )
      {
         fgdcDoc->getProjection( m_proj );
         if ( m_proj.valid() )
         {
            // Units must be set before initValues and initProjection.
            std::string units;
            fgdcDoc->getAltitudeDistanceUnits(units);
            if ( ( units == "feet" ) || ( units == "international feet" ) )
            {
               m_units = OSSIM_FEET;
            }
            else if ( units == "survey feet" )
            {
               m_units = OSSIM_US_SURVEY_FEET;
            }
            else
            {
               m_units = OSSIM_METERS;
            }
            
            // Must be called before initProjection.
            initValues();
            
            result = initProjection();  // Sets the ties and scale...
            
            if (traceDebug())
            {
               m_proj->print(ossimNotify(ossimNotifyLevel_DEBUG));
            }
         }
      }
   }

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exit status = " << (result?"true\n":"false\n");
   }   
   return result;
}
Exemple #11
0
int			main(int argc, char** argv)
{
  /*
   * initialize GLUT and open a window
   */
  glutInit(&argc, argv);
  glutInitWindowSize(512, 512);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  glutCreateWindow("Sunlight");
  glutDisplayFunc(redrawCB);
  glutReshapeFunc(reshapeCB);
  glutMouseFunc(mouseCB);
  glutMotionFunc(motionCB);
  glutKeyboardFunc(keyCB);

  /*
   * make the menu
   */
  glutCreateMenu(handleMenu);
  glutAddMenuEntry("SUNLIGHT", 0);
  glutAddMenuEntry("Show Globe *", MENU_SHOW_GLOBE);
  glutAddMenuEntry("Show Map", MENU_SHOW_MAP);
  glutAddMenuEntry("Adjust Globe *", MENU_ADJUST_GLOBE);
  glutAddMenuEntry("Adjust Day", MENU_ADJUST_DAY);
  glutAddMenuEntry("Adjust Time", MENU_ADJUST_TIME);
  glutAddMenuEntry("Quit", MENU_QUIT);
  glutAttachMenu(GLUT_RIGHT_BUTTON);

  /*
   * initialize GL
   */
  initProjection();
  gluLookAt(0.0, 0.0, 3.0,
	    0.0, 0.0, 0.0,
	    0.0, 1.0, 0.0);
  initSunlight();
  glEnable(GL_LIGHTING);
  glEnable(GL_CULL_FACE);
  glEnable(GL_TEXTURE_2D);

  /*
   * initialize data structures
   */
  initSphere();
  initMap();
  initTexture("globe.raw");

  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 4) {
    fprintf(stderr, "\nusage: %s [OPTIONS] PROJPARA [SYMMETRY:]MBSTATE [SYMMETRY:]MBSTATE\n", argv[0]);
    exit(-1);
  }

  /* manage command-line options */

  char* projpar = argv[optind];
  char** mbfile = &argv[optind+1];

  SlaterDet Q[2];
  Symmetry S[2];
  int odd;

  int i;
  for (i=0; i<2; i++) {
    extractSymmetryfromString(&mbfile[i], &S[i]);
    if (readSlaterDetfromFile(&Q[i], mbfile[i]))
      exit(-1);
  }

  // odd numer of nucleons ?
  odd = Q[0].A % 2;

  // Projection parameters
  Projection P;
  initProjection(&P, odd, projpar);

  void* radiime = initprojectedMBME(&P, &OpRadiiAll); 

  // read or calculate matrix elements

  if (readprojectedMBMEfromFile(mbfile[0], mbfile[1], &P, 
                                &OpRadiiAll, S[0], S[1], 
                                radiime)) {
    calcprojectedMBME(&P, &OpRadiiAll, &Q[0], &Q[1], 
                      S[0], S[1], radiime);
    writeprojectedMBMEtoFile(mbfile[0], mbfile[1], &P, 
                             &OpRadiiAll, S[0], S[1], 
                             radiime);
  } 

  return 0;
}
Exemple #13
0
bool ossimLasReader::parseVarRecords()
{
   static const char M[] = "ossimLasReader::parseVarRecords";
   if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   
   bool result = false;

   if ( isOpen() )
   {
      std::streampos origPos = m_str.tellg();
      std::streamoff pos = static_cast<std::streamoff>(m_hdr->getHeaderSize());

      m_str.clear();
      m_str.seekg(pos, std::ios_base::beg);

      ossim_uint32 vlrCount = m_hdr->getNumberOfVlrs();
      ossim_uint16 reserved;
      char uid[17];
      uid[16]='\n';
      ossim_uint16 recordId;
      ossim_uint16 length;
      char des[33];
      des[32] = '\n';

      //---
      // Things we need to save for printGeoKeys:
      //---
      ossim_uint16*  geoKeyBlock     = 0;
      ossim_uint64   geoKeyLength    = 0;
      ossim_float64* geoDoubleBlock  = 0;
      ossim_uint64   geoDoubleLength = 0;
      ossim_int8*    geoAsciiBlock   = 0;
      ossim_uint64   geoAsciiLength  = 0;
     
      ossimEndian* endian = 0;
      // LAS LITTLE ENDIAN:
      if ( ossim::byteOrder() == OSSIM_BIG_ENDIAN )
      {
         endian = new ossimEndian;
      }
      
      for ( ossim_uint32 i = 0; i < vlrCount; ++i )
      {
         m_str.read((char*)&reserved, 2);
         m_str.read(uid, 16);
         m_str.read((char*)&recordId, 2);
         m_str.read((char*)&length, 2);
         m_str.read(des, 32);

         // LAS LITTLE ENDIAN:
         if ( endian )
         {
            endian->swap(recordId);
            endian->swap(length);
         }
 
         if ( traceDebug() )
         {
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "uid:      " << uid
               << "\nrecordId: " << recordId
               << "\nlength:   " << length
               << "\ndes:      " << des
               << std::endl;
         }
         
         if (recordId == 34735) // GeoTiff projection keys.
         {
            geoKeyLength = length/2;
            if ( geoKeyBlock )
            {
               delete [] geoKeyBlock;
            }
            geoKeyBlock = new ossim_uint16[geoKeyLength];
            m_str.read((char*)geoKeyBlock, length);
            if ( endian )
            {
               endian->swap(geoKeyBlock, geoKeyLength);
            }
         }
         else if (recordId == 34736) // GeoTiff double parameters.
         {
            geoDoubleLength = length/8;
            if ( geoDoubleBlock )
            {
               delete [] geoDoubleBlock;
            }
            geoDoubleBlock = new ossim_float64[geoDoubleLength];
            m_str.read((char*)geoDoubleBlock, length);
            if ( endian )
            {
               endian->swap(geoDoubleBlock, geoDoubleLength);
            }
         }
         else if (recordId == 34737) // GeoTiff ascii block.
         {
            geoAsciiLength = length;
            if (geoAsciiBlock)
            {
               delete [] geoAsciiBlock;
            }
            geoAsciiBlock = new ossim_int8[length];
            m_str.read((char*)geoAsciiBlock, length);
         }
         else
         {
            m_str.seekg(length, ios_base::cur);
         }
      }

      //---
      // Must have at mimimum the geoKeyBlock for a projection.
      // Note the geoDoubleBlock is needed for some.
      // Note the geoAsciiBlock is not needed, i.e. only informational.
      //---
      if ( geoKeyBlock )
      {       
         //---
         // Give the geokeys to ossimTiffInfo to get back a keyword list that can be fed to
         // ossimProjectionFactoryRegistry::createProjection
         //---
         ossimTiffInfo info;
         ossimKeywordlist geomKwl;
         info.getImageGeometry(geoKeyLength, geoKeyBlock,
                               geoDoubleLength,geoDoubleBlock,
                               geoAsciiLength,geoAsciiBlock,
                               geomKwl);
         
         // Create the projection.
         m_proj = ossimProjectionFactoryRegistry::instance()->createProjection(geomKwl);
         if (m_proj.valid())
         {
            // Units must be set before initValues and initProjection.
            initUnits(geomKwl);
            
            // Must be called before initProjection.
            initValues();
            
            result = initProjection();  // Sets the ties and scale...
            
            if (traceDebug())
            {
               m_proj->print(ossimNotify(ossimNotifyLevel_DEBUG));
            }
         }
      }

      if ( geoKeyBlock )
      {
         delete [] geoKeyBlock;
         geoKeyBlock = 0;
      }
      if (geoDoubleBlock)
      {
         delete [] geoDoubleBlock;
         geoDoubleBlock = 0;
      }
      if (geoAsciiBlock)
      {
         delete [] geoAsciiBlock;
         geoAsciiBlock = 0;
      }

      m_str.seekg(origPos);

      if ( endian )
      {
         delete endian;
         endian = 0;
      }
   }  

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exit status = " << (result?"true\n":"false\n");
   }   
   return result;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 3) {
    fprintf(stderr, "\nusage: %s [OPTIONS] PROJPARA INTERACTION NUCSFILE"
	    "\n   -h             hermitize matrix elements"
	    "\n   -d             diagonal matrix elements only\n",
	    argv[0]);
    exit(-1);
  }

  int hermit=0;
  int diagonal=0;
  int odd;


  char c;

  /* manage command-line options */

  while ((c = getopt(argc, argv, "dh")) != -1)
    switch (c) {
    case 'd':
      diagonal=1;
      break;
    case 'h':
      hermit=1;
      break;
    }

  char* projpar = argv[optind];
  char* interactionfile = argv[optind+1];
  char* nucsfile = argv[optind+2];

  char* mbfile[MAXSTATES];
  int n;

  if (readstringsfromfile(nucsfile, &n, mbfile))
    return -1;

  SlaterDet Q[n];
  Symmetry S[n];

  int i;
  for (i=0; i<n; i++) {
    extractSymmetryfromString(&mbfile[i], &S[i]);
    if (readSlaterDetfromFile(&Q[i], mbfile[i]))
      exit(-1);;
  }

  Interaction Int;
  if (readInteractionfromFile(&Int, interactionfile))
    exit(-1);
  Int.cm = 1;

  // odd numer of nucleons ?
  odd = Q[0].A % 2;

  // Projection parameters
  Projection P;
  initProjection(&P, odd, projpar);

  // check that no cm-projection was used
  if (P.cm != CMNone) {
    fprintf(stderr, "You have to use cm-none! for Projection\n");
    exit(-1);
  }
    
  initOpObservables(&Int);

  int a,b; 

  // calculate norms of Slater determinants
  SlaterDetAux X;
  double norm[n];

  initSlaterDetAux(&Q[0], &X);

  for (i=0; i<n; i++) {
    calcSlaterDetAuxod(&Q[i], &Q[i], &X);
    norm[i] = sqrt(creal(X.ovlap));
  }

  /* 
  // calculate cm factor
  double tcm[n];
  for (i=0; i<n; i++) {
    calcSlaterDetAux(&Q[i], &X);
    calcTCM(&Q[i], &X, &tcm[i]);
  }

  double meantcm = 0.0;
  for (i=0; i<n; i++)
    meantcm += tcm[i]/n;

  double alpha = 0.25/0.75*(meantcm*(mproton*Q[0].Z+mneutron*Q[0].N));
  double cmfactor = 0.125*pow(M_PI*alpha,-1.5);
  */

  // initialize space for matrix elements
  Observablesod** obsme[n*n];
  for (b=0; b<n; b++)	
    for (a=0; a<n; a++)
      obsme[a+b*n] = initprojectedMBME(&P, &OpObservables);

  // read or calculate matrix elements
  for (b=0; b<n; b++)
    for (a=diagonal ? b : 0; a<n; a += diagonal ? n : 1)
	if (readprojectedMBMEfromFile(mbfile[a], mbfile[b], &P, &OpObservables,
				    S[a], S[b], obsme[a+b*n])) {
	fprintf(stderr, "Matrix elements between %s and %s missing\n",
		mbfile[a], mbfile[b]);
	exit(-1);
      }

  if (hermit)
    hermitizeprojectedMBME(&P, &OpObservables, obsme, n);

  int pi, j;
  for (pi=0; pi<=1; pi++) 
    for (j=odd; j<P.jmax; j=j+2)
      extractmatrices(nucsfile, &P, S, &Int, obsme, norm, 1.0, n, diagonal, j, pi);

}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 4) {
    fprintf(stderr, "\nusage: %s PROJPARA MBSTATE MBSTATE\n",
	    argv[0]);
    exit(-1);
  }

  int odd;

  char* projpar = argv[optind];
  char** mbfile = &argv[optind+1];

  MultiSlaterDet Q[2];
  Indices In[2];

  int i;
  for (i=0; i<2; i++) {
    extractIndicesfromString(&mbfile, &In[i]);
    if (readMultiSlaterDetfromFile(&Q[i], &In[i], mbfile[i]))
      exit(-1);
  }

  // odd numer of nucleons ?
  odd = Q[0].A % 2;

  // Projection parameters
  Projection P;
  initProjection(&P, odd, projpar);

  void* emome   = initprojectedMultiMBME(&P, &OpEMonopole, &Q[0], &Q[1]); 
  void* edipme  = initprojectedMultiMBME(&P, &OpEDipole, &Q[0], &Q[1]); 
  void* mdipme  = initprojectedMultiMBME(&P, &OpMDipole, &Q[0], &Q[1]);
  void* equadme = initprojectedMultiMBME(&P, &OpEQuadrupole, &Q[0], &Q[1]);

  // read or calculate matrix elements

  if (readprojectedMultiMBMEfromFile(mbfile[0], mbfile[1], &Q[0], &Q[1],
				     &P, &OpEMonopole, emome)) {
    calcprojectedMultiMBME(&P, &OpEMonopole, &Q[0], &Q[1], emome);
    writeprojectedMultiMBMEtoFile(mbfile[0], mbfile[1], &Q[0], &Q[1], 
				  &P, &OpEMonopole, emome);
  }
  if (readprojectedMultiMBMEfromFile(mbfile[0], mbfile[1], &Q[0], &Q[1],
				     &P, &OpEDipole, edipme)) {
    calcprojectedMultiMBME(&P, &OpEDipole, &Q[0], &Q[1], edipme);
    writeprojectedMultiMBMEtoFile(mbfile[0], mbfile[1], &Q[0], &Q[1], 
				  &P, &OpEDipole, edipme);
  }
  if (readprojectedMultiMBMEfromFile(mbfile[0], mbfile[1], &Q[0], &Q[1],
				     &P, &OpMDipole, mdipme)) {
    calcprojectedMultiMBME(&P, &OpMDipole, &Q[0], &Q[1], mdipme);
    writeprojectedMultiMBMEtoFile(mbfile[0], mbfile[1], &Q[0], &Q[1], 
				  &P, &OpMDipole, mdipme);
  }
  if (readprojectedMultiMBMEfromFile(mbfile[0], mbfile[1], &Q[0], &Q[1],
				     &P, &OpEQuadrupole, equadme)) {
    calcprojectedMultiMBME(&P, &OpEQuadrupole, &Q[0], &Q[1], equadme);
    writeprojectedMultiMBMEtoFile(mbfile[0], mbfile[1], &Q[0], &Q[1], 
				  &P, &OpEQuadrupole, equadme);  
  }  

}
Exemple #16
0
ProjectionCylindric::ProjectionCylindric(int v1_new)
{
  v1 = 0.0;
  i_v1 = 0;
  initProjection(v1_new);
}
Exemple #17
0
/**
 * Loads the parameters specific to this projection from a stream
 */
void ProjectionCylindric::loadParameters(QDataStream & s)
{
  qint32 i=0;
  s >> i;
  initProjection(i);
}