ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
    const Element& e,
    const CoordinateSystem &global_coords)
: _coords(global_coords), _matR2global(3,3)
{
    assert(e.getDimension() <= global_coords.getDimension());
    _points.reserve(e.getNNodes());
    for(unsigned i = 0; i < e.getNNodes(); i++)
        _points.emplace_back(e.getNode(i)->getCoords());

    auto const element_dimension = e.getDimension();
    auto const global_dimension = global_coords.getDimension();

    if (global_dimension == element_dimension)
    {
        _matR2global.setIdentity();
        return;
    }

    detail::getRotationMatrixToGlobal(element_dimension, global_dimension, _points, _matR2global);
#ifdef OGS_USE_EIGEN
    detail::rotateToLocal(_matR2global.transpose(), _points);
#else
    RotationMatrix* m(_matR2global.transpose());
    detail::rotateToLocal(*m, _points);
    delete m;
#endif
}
Esempio n. 2
0
//------------------------------------------------------------------------------
// void BuildValidCoordinateSystemList()
//------------------------------------------------------------------------------
void ShowSummaryDialog::BuildValidCoordinateSystemList()
{
   CoordinateSystem *tmpCS = NULL;
   SpacePoint       *origin = NULL;
   std::string      currentCS = coordSysComboBox->GetValue().c_str();
   std::string      newCS     = currentCS;
   Integer          sz;

   // The only valid coordinate system for use here:
   // 1) have a celestial body origin, and
   // 2) do not have a spacecraft as the origin or the primary or the secondary

   // get the names of the coordinate systems
   StringArray coordSystemNames;
   wxArrayString csNames = coordSysComboBox->GetStrings();
   for (Integer ii = 0; ii < (Integer) csNames.GetCount(); ii++)
      coordSystemNames.push_back((csNames.Item(ii)).c_str());
   sz = (Integer) coordSystemNames.size();

   coordSysComboBox->Clear();
   for (Integer ii = 0; ii < sz; ii++)
   {
      if (ii == 0)                                   newCS = coordSystemNames.at(ii);
      else if (currentCS == coordSystemNames.at(ii)) newCS = currentCS;
      tmpCS      = (CoordinateSystem*) theGuiInterpreter->GetConfiguredObject(coordSystemNames.at(ii));
      origin     = tmpCS->GetOrigin();
      if (origin->IsOfType("CelestialBody") && (!tmpCS->UsesSpacecraft()))  // add it to the list
         coordSysComboBox->Append(wxString(coordSystemNames[ii].c_str()));
   }
   coordSysComboBox->SetValue(newCS.c_str());
   currentCoordSysName = coordSysComboBox->GetValue().c_str();
}
SPFeatureI FeatureCoverage::newFeature(geos::geom::Geometry *geom, bool load) {

    if ( load) {
        Locker<std::mutex> lock(_loadmutex);
        if (!connector()->dataIsLoaded()) {
            connector()->loadData(this);
        }
    }

    Locker<> lock(_mutex);

    IlwisTypes tp = geometryType(geom);
    auto *newfeature =  createNewFeature(tp);
    if (newfeature ){
        if ( geom) {
            CoordinateSystem *csy = GeometryHelper::getCoordinateSystem(geom);
            if ( csy && !csy->isEqual(coordinateSystem().ptr())){
                CsyTransform trans(csy, coordinateSystem());
                geom->apply_rw(&trans);
            }
            GeometryHelper::setCoordinateSystem(geom, coordinateSystem().ptr());
            newfeature->geometry(geom);
        }else
            setFeatureCount(itUNKNOWN,1,0);

        _features.push_back(newfeature);
        return _features.back();
    }
    return SPFeatureI();

}
Esempio n. 4
0
void FrameMetricWrapper::spaceSelected()
{
	if (mInternalUpdate)
		return;
	CoordinateSystem space = mSpaceSelector->getValue();
	if (space.isValid())
		mData->setSpace(space);
}
Esempio n. 5
0
//------------------------------------------------------------------------------
void Publisher::SetDataMJ2000EqOrigin(CelestialBody *cb)
{
   if (cb == NULL)
      return;
   
   #if DBGLVL_PUBLISHER_DATA_REP
   MessageInterface::ShowMessage
      ("Publisher::SetDataMJ2000EqOrigin() cb=%s<%p>\n", cb->GetName().c_str(),
       cb);
   #endif
   
   dataMJ2000EqOrigin = cb;
   std::string originName = cb->GetName();
   std::string csName = originName + "MJ2000Eq";
      
   std::map<std::string, CoordinateSystem*>::iterator csIter =
      coordSysMap.find(csName);
   
   if (coordSysMap.find(csName) != coordSysMap.end())
   {
      // set coordinate system from the map
      dataCoordSystem = coordSysMap.find(csName)->second;
   }
   else
   {
      // check as local name
      csName = "Local-" + csName;
      if (coordSysMap.find(csName) != coordSysMap.end())
         dataCoordSystem = coordSysMap.find(csName)->second;
      else
      {
         // Create coordinate system if not exist
         CoordinateSystem *newCs = (CoordinateSystem*)internalCoordSystem->Clone();
         newCs->SetName(csName);
         newCs->SetStringParameter("Origin", originName);
         newCs->SetRefObject(cb, Gmat::CELESTIAL_BODY, originName);
         newCs->Initialize();
         coordSysMap[csName] = newCs;
         dataCoordSystem = newCs;
         
         #if DBGLVL_PUBLISHER_DATA_REP
         MessageInterface::ShowMessage
            ("   ===> %s not found in the map, so created <%p>\n", csName.c_str(),
             newCs);
         #endif
      }
   }
   
   // set to subscribers
   std::list<Subscriber*>::iterator current = subscriberList.begin();
   while (current != subscriberList.end())
   {
      (*current)->SetDataMJ2000EqOrigin(cb);
      (*current)->SetDataCoordSystem(dataCoordSystem);
      current++;
   }
}
bool CoordinateSystemConnector::loadMetaData(IlwisObject* data, const IOOptions& options)
{
    Ilwis3Connector::loadMetaData(data, options);
    CoordinateSystem *csy = static_cast<CoordinateSystem *>(data);
    QString ellipsoideName;

    IEllipsoid ell = getEllipsoid();
    GeodeticDatum *datum = getDatum(ellipsoideName);
    if ( !ell.isValid() && ellipsoideName != sUNDEF){
        QString ellres = QString("ilwis://tables/ellipsoid?code=%1").arg(ellipsoideName);
       if (!ell.prepare(ellres)) {
              return ERROR1("No ellipsoid for this code %1",ellipsoideName);
       }
    }

    QString cb = _odf->value("CoordSystem", "CoordBounds");
    QStringList cbparts = cb.split(" ");
    if ( cbparts.size() == 4 && cbparts[0] != "-1e+308") {
        bool ok1, ok2, ok3, ok4;
        Envelope box( Coordinate(
                                cbparts[0].toDouble(&ok1),
                                cbparts[1].toDouble(&ok2)),
                           Coordinate(
                                cbparts[2].toDouble(&ok3),
                                cbparts[3].toDouble(&ok4)));
        if ( !( ok1 && ok2 && ok3 && ok4)) {
            return ERROR2(ERR_NO_INITIALIZED_2, TR("envelop"), csy->name());
        }
        csy->envelope(box);
    } else {
        QString type = _odf->value("CoordSystem", "Type");
        if ( type == "LatLon") {
            Envelope box(Coordinate(-180,-90), Coordinate(180,90));
            csy->envelope(box);
        }
    }

    if ( type() == itCONVENTIONALCOORDSYSTEM ) {
        ConventionalCoordinateSystem *csycc = static_cast<ConventionalCoordinateSystem *>(csy);
        IProjection proj = getProjection(csycc);
        if ( !proj.isValid()) {
            return ERROR1(ERR_NO_INITIALIZED_1, "projection");
        }
        csycc->setDatum(datum);
        csycc->setEllipsoid(ell);
        csycc->setProjection(proj);
        proj->setCoordinateSystem(csycc);


        proj->setParameter(Projection::pvELLCODE, ell->toProj4());
        csycc->prepare();
    } else if ( type() == itUNKNOWN){
        //TODO: other types of csy
    }
    return true;
}
Esempio n. 7
0
void Ship :: setupCamera () const
{
	CoordinateSystem camera = getCameraCoordinateSystem();
	const Vector3& camera_position = camera.getPosition();
	const Vector3& camera_up       = camera.getUp();

	Vector3 look_at = camera_position + camera.getForward();

	gluLookAt(camera_position.x, camera_position.y, camera_position.z,
	          look_at.x,         look_at.y,         look_at.z,
	          camera_up.x,       camera_up.y,       camera_up.z);
}
Esempio n. 8
0
static void extrudePoint(double X[3],const double Z[3])
{
	if (Z[0]==0 && Z[1]==0 && Z[2]>=0) return; /*The coordinate system is WCS*/

	CoordinateSystem<double> XYZ;
	createObjectCoordSystem(&XYZ,Z);

	double nX[3];
	XYZ.fromLocalToGlobal(nX,X);

	vec_copy(X,nX);
}
int main(){
  int xsize, ysize;
  unsigned char * imgbuf;
  double inFluxScale;
#ifdef _WIN32
  if (!loadBitmap("G:\\sources2\\__BR\\RC\\crocodile\\reprojection-pseudocode\\lovell.bmp", &xsize, &ysize, &imgbuf, &inFluxScale)){
#else
  if (!loadBitmap("/home/awson/data/Work/crocodile/reprojection-pseudocode/lovell.bmp", &xsize, &ysize, &imgbuf, &inFluxScale)){
#endif
    printf("Can't load the input!");
    return -1;
  }
  CoordinateSystem inCS = {
  	{0, 0}
  , {500, 500}
  , { {-0.000027778, 0}
  	, { 0, 0.000027778}
    }
  };
  inCS.prepare();
  CoordinateSystem outCS = {
  	{0, 0}
  , {500, 500}
  , { {-0.00002, -0.00002}
  	, {-0.00002,  0.00002}
    }
  };
  outCS.prepare();

  vector<double> inp(xsize * ysize);
  vector<double> outp(xsize * ysize);

  unsigned char * it = imgbuf;
  for (double & v : inp) v = double(*it++);

  printf("Start repro ...\n");
  reprojection(
      inCS
    , outCS
    , {xsize, ysize}
    , {xsize, ysize}
    , inp.data()
    , outp.data()
  );
  printf("Done repro!\n");

  // Dirty! Reuse imgbuf.
  it = imgbuf;
  for (double v : outp) *it++ = (unsigned char)(min(255.0, v));

  saveBitmap("image.bmp", xsize, ysize, imgbuf, inFluxScale * pixelAreaRatio(inCS, outCS));
  free(imgbuf);
}
Esempio n. 10
0
void World::playerFireBullet()
{
	if (m_playerShip.isAlive() && m_playerShip.isBulletReady())
	{
		CoordinateSystem cs = m_playerShip.getCoordinate();
		m_bullets[m_nextBulletIndex].fire(cs.getPosition(), cs.getForward(), m_playerShip.getId());
		m_playerShip.reloadBullet();
		m_nextBulletIndex++;
		if (m_nextBulletIndex == Const::BULLET_COUNT){
			m_nextBulletIndex = 0;
		}
	}
}
Esempio n. 11
0
AxisConnector::AxisConnector(CoordinateSystem space, SpaceProviderPtr spaceProvider)
{
	mSpaceProvider = spaceProvider;
	mListener = mSpaceProvider->createListener();
	mListener->setSpace(space);
	connect(mListener.get(), SIGNAL(changed()), this, SLOT(changedSlot()));

	mRep = AxesRep::New(space.toString() + "_axis");
	mRep->setCaption(space.toString(), Vector3D(1, 0, 0));
	mRep->setShowAxesLabels(false);
	mRep->setFontSize(0.08);
	mRep->setAxisLength(0.03);
	this->changedSlot();
}
Esempio n. 12
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// clear the screen - any drawing before here will not display

	glLoadIdentity();
	// set up the camera here
    camera.setCamera();

	// camera is set up - any drawing before here will display incorrectly
    
    // Draw Skybox
    glPushMatrix();
        glTranslatef(camera.getPosition().x,
                     camera.getPosition().y,
                     camera.getPosition().z);
        glDepthMask(GL_FALSE);
        skybox.draw();
        glDepthMask(GL_TRUE);
    glPopMatrix();

    // Draw Saturn
    glPushMatrix();
        glTranslatef(saturnInfo.x, 0.f, saturnInfo.z);
        glScalef(saturnInfo.radius, saturnInfo.radius, saturnInfo.radius);
        saturn.draw();
    glPopMatrix();
    
    // Draw Moons
    for (int i = 0; i < 10; i++)
    {
        glPushMatrix();
            glTranslatef(moonInfo[i].x, 0.f, moonInfo[i].z);
            glScalef(moonInfo[i].radius, moonInfo[i].radius, moonInfo[i].radius);
            moons[i].draw();
        glPopMatrix();
    }
    
    // Draw rings
    glPushMatrix();
        glTranslatef(ringInfo.x, 0.f, ringInfo.z);
        glScalef(ringInfo.radius, ringInfo.radius, ringInfo.radius);
        ring.draw();
    glPopMatrix();
    
	// send the current image to the screen - any drawing after here will not display
	glutSwapBuffers();
}
Esempio n. 13
0
File: Body.C Progetto: 99731/GoTools
//---------------------------------------------------------------------------
Body::Body(const CoordinateSystem<3> xyz, shared_ptr<SurfaceModel>  shell)
    : coordinate_(xyz), toptol_(shell->getTolerances())
//---------------------------------------------------------------------------
{
    shells_.push_back(shell);
    addBodyPointers();
}
Esempio n. 14
0
		string Ellipse::createPathNodes(Point point, CoordinateSystem& drawing, bool alwaysShowFirstPoint) {
			string path("");
			Point startPoint = drawing.map(getFirstPoint());
			path += "M " + NumberUtil::formatFloat(startPoint.getX()) + "," 
						+ NumberUtil::formatFloat(startPoint.getY());
		
			for (int i = 1; i <= 4; i++) {
				Point nextPoint = drawing.map(EllipticalArc::point((float) (M_PI * i / 2.0),  m_radius, m_centre,m_eccentricity));
				path += " A " + NumberUtil::formatFloat(m_radius) + "," 
						+ NumberUtil::formatFloat(m_radius * m_eccentricity)
						+ NumberUtil::formatFloat(m_inclination) + " 0,0 "
						+ NumberUtil::formatFloat(nextPoint.getX()) + ","
						+ NumberUtil::formatFloat(nextPoint.getY());
			}
		
			path += " Z ";
			return path;
		}
void SOP_SceneCacheSource::transformObject( IECore::Object *object, const Imath::M44d &transform, bool &hasAnimatedTopology, bool &hasAnimatedPrimVars, std::vector<InternedString> &animatedPrimVars )
{
	Primitive *primitive = IECore::runTimeCast<Primitive>( object );
	if ( primitive )
	{
		TransformOpPtr transformer = new TransformOp();
		transformer->inputParameter()->setValue( primitive );
		transformer->copyParameter()->setTypedValue( false );
		transformer->matrixParameter()->setValue( new M44dData( transform ) );
		transformer->operate();
		
		std::vector<std::string> &primVars = transformer->primVarsParameter()->getTypedValue();
		for ( std::vector<std::string>::iterator it = primVars.begin(); it != primVars.end(); ++it )
		{
			if ( std::find( animatedPrimVars.begin(), animatedPrimVars.end(), *it ) == animatedPrimVars.end() )
			{
				animatedPrimVars.push_back( *it );
				hasAnimatedPrimVars = true;
			}
		}
		
		return;
	}
	
	Group *group = IECore::runTimeCast<Group>( object );
	if ( group )
	{
		MatrixTransformPtr matTransform = matrixTransform( transform );
		matTransform->matrix *= group->getTransform()->transform();
		group->setTransform( matTransform );
		return;
	}
	
	CoordinateSystem *coord = IECore::runTimeCast<CoordinateSystem>( object );
	if ( coord )
	{
		MatrixTransformPtr matTransform = matrixTransform( transform );
		matTransform->matrix *= coord->getTransform()->transform();
		coord->setTransform( matTransform );
		return;
	}
}
Esempio n. 16
0
void special(int special_key, int x, int y)
{
    special_key_pressed[special_key] = true;
    
	switch(special_key)
	{
        case GLUT_KEY_END:
            camera.reset();
            break;
	}
}
Esempio n. 17
0
void special(int special_key, int x, int y)
{
	switch(special_key)
	{
        case GLUT_KEY_RIGHT:
            camera.setYaw(-0.1);
            break;
        case GLUT_KEY_LEFT:
            camera.setYaw(0.1);
            break;
        case GLUT_KEY_UP:
            camera.setPitch(0.1);
            break;
        case GLUT_KEY_DOWN:
            camera.setPitch(-0.1);
            break;
        case GLUT_KEY_END:
            camera.reset();
            break;
	}
}
IlwisObject *InternalIlwisObjectFactory::createCsyFromCode(const Resource& resource, const IOOptions &options) const {
    QString code = resource.code();
    bool isUnknown = code == "unknown" || code == "csy:unknown";
    QString projParms = code;
    if ( code.left(6) == "proj4:"){
        projParms = code.mid(6);
    }else if(!isUnknown && code.left(5) == "epsg:"){
        QString query = QString("select * from projectedcsy where code='%1'").arg(code);
        InternalDatabaseConnection db;
        if ( db.exec(query)) {
            if (db.next()) {
                QSqlRecord rec = db.record();
                projParms = rec.value("proj_params").toString();
            } else {
                kernel()->issues()->log(TR(ERR_COULDNT_CREATE_OBJECT_FOR_2).arg("coordinatesystem", resource.name()));
                return 0;
            }
        }
    }
    CoordinateSystem *csy = 0;
    if ( isUnknown){
        csy = createFromResource<BoundsOnlyCoordinateSystem>(resource, options);
        csy->name("unknown");
        csy->code("unknown");
        csy->setDescription(TR("Unknown coordinate system"));
    }else {
        csy = createFromResource<ConventionalCoordinateSystem>(resource, options);
        csy->setDescription(resource.name());
        csy->prepare("proj4=" + projParms);
    }

    return csy;

}
Esempio n. 19
0
void keyboard(unsigned char key, int x, int y)
{
    Vector3 origin = Vector3::ZERO;
    Vector3 direction_to_origin;
	switch (key)
	{
        case 27: // on [ESC]
            exit(0); // normal exit
            break;
        case ' ':
            camera.moveForward(0.5);
            break;
        case 'w':
            camera.moveUp(0.5);
            break;
        case 'a':
            camera.moveLeft(0.5);
            break;
        case 's':
            camera.moveDown(0.5);
            break;
        case 'd':
            camera.moveRight(0.5);
            break;
        case 'h':
            direction_to_origin = origin - camera.getPosition();
            camera.rotateToVector(direction_to_origin, 0.1);
            break;
        case ',':
            camera.setRoll(0.1);
            break;
        case '.':
            camera.setRoll(-0.1);
            break;
        case '/':
            camera.moveBackward(0.5);
            break;
	}
}
Esempio n. 20
0
void World::update()
{
	handleKeyPress();

	m_playerShip.update(*this);
	int i = 0;
	// bullet
	for (; i < Const::BULLET_COUNT; i++)
	{ 
		m_bullets[i].update(*this);
	}
	int abc = 0;
	// enemy ships
	Vector3 playerPosition = m_playerShip.getPosition();
	for (i = 0; i < Const::ENEMY_SHIP_AMOUNT;i++){

		if (m_ships[i].isAlive()){
			double distance = m_ships[i].getPosition().getDistanceSquared(playerPosition);
			if (distance < Const::NEAR_TO_PLAYER){
				m_ships[i].runAi(*this);
				m_ships[i].update(*this);
				abc++;
			}
		}
	}

	CoordinateSystem cs = m_playerShip.getCoordinate();
	Vector3 position = cs.getPosition();
	Vector3 up = cs.getUp();
	m_camera.setUp(cs.getUp());
	Vector3 forward = cs.getForward();
	m_camera.setForward(forward);
	position += 20 * up;
	position -= 100 * forward;
	m_camera.setPosition(position);
	checkCollision();
}
bool CoordinateSystemSerializerV1::store(IlwisObject *obj, const IOOptions &options)
{
    if (!VersionedSerializer::store(obj, options))
        return false;

    CoordinateSystem *csy = static_cast<CoordinateSystem *>(obj);
    if ( csy->ilwisType() == itCONVENTIONALCOORDSYSTEM){
        VersionedDataStreamFactory *factory = kernel()->factory<VersionedDataStreamFactory>("ilwis::VersionedDataStreamFactory");
        if (!factory)
            return false;
        std::unique_ptr<DataInterface> projstreamer(factory->create(Version::interfaceVersion, itPROJECTION,_stream));
        if ( !projstreamer)
            return false;
        ConventionalCoordinateSystem *ccsy = static_cast<ConventionalCoordinateSystem *>(csy);
        storeSystemPath(ccsy->projection()->resource());
        projstreamer->store(ccsy->projection().ptr(),options);
        std::unique_ptr<DataInterface> ellstreamer(factory->create(Version::interfaceVersion, itELLIPSOID,_stream));
        if ( !ellstreamer)
            return false;
        storeSystemPath(ccsy->ellipsoid()->resource());
        ellstreamer->store(ccsy->ellipsoid().ptr(),options);

        const std::unique_ptr<GeodeticDatum>& datum = ccsy->datum();
        if ( datum){
            _stream << itGEODETICDATUM << datum->name() << datum->code() << datum->description() << datum->area() << datum->authority();
            for(int i =0; i < 10; ++i)
                _stream << datum->parameter((GeodeticDatum::DatumParameters)i);
        }else
            _stream << itUNKNOWN;

        _stream << ccsy->unit();

    }
    _stream << csy->envelope().min_corner().x << csy->envelope().min_corner().y << csy->envelope().max_corner().x << csy->envelope().max_corner().y;
    return true;

}
bool CoordinateSystemSerializerV1::loadMetaData(IlwisObject *obj, const IOOptions &options)
{
    if (!VersionedSerializer::loadMetaData(obj, options))
        return false;
    CoordinateSystem *csy = static_cast<CoordinateSystem *>(obj);
    VersionedDataStreamFactory *factory = kernel()->factory<VersionedDataStreamFactory>("ilwis::VersionedDataStreamFactory");
    if (!factory)
        return false;

    if ( csy->ilwisType() == itCONVENTIONALCOORDSYSTEM){
        ConventionalCoordinateSystem *convCsy = static_cast<ConventionalCoordinateSystem *>(obj);
        quint64 type;
        QString version, url;
        _stream >> url;
        _stream >> type;
        if ( type != itUNKNOWN){
            _stream >> version;
            std::unique_ptr<DataInterface> projstreamer(factory->create(version, type,_stream));
            if ( !projstreamer)
                return false;
            IProjection proj(itPROJECTION);
            projstreamer->loadMetaData(proj.ptr(), options );
            convCsy->setProjection(proj);
        }
Esempio n. 23
0
void init()
{
    for (int i = 0; i < 256; i++)
    {
        key_pressed[i] = false;
    }
    
    for (int i = 0; i < 128; i++)
    {
        special_key_pressed[i] = false;
    }
    
    initDisplay();
    camera.setPosition({70000.0, 0.0, 70000.0});
    world.init();
}
Esempio n. 24
0
File: Body.C Progetto: 99731/GoTools
//---------------------------------------------------------------------------
Body::Body(const CoordinateSystem<3> xyz, vector<shared_ptr<SurfaceModel> >& shells)
    : coordinate_(xyz), shells_(shells), toptol_(0.0, 0.0, 0.0, 0.0)
//---------------------------------------------------------------------------
{
    double gap=0.0, neighbour=0.0, kink=0.0, bend=0.0;
    for (size_t ki=0; ki<shells.size(); ki++)
    {
	tpTolerances toptol = shells[ki]->getTolerances();
	gap = std::max(toptol.gap, gap);
	neighbour = std::max(toptol.neighbour, neighbour);
	kink = std::max(toptol.kink, kink);
	bend = std::max(toptol.bend, bend);
    }
    toptol_ = tpTolerances(gap, neighbour, kink, bend);

    addBodyPointers();
}
Esempio n. 25
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// clear the screen - any drawing before here will not display

	glLoadIdentity();
	// set up the camera here
    camera.setCamera();

    // Draw the world
    world.drawSkybox(camera);
    world.drawSaturn();
    world.drawMoons();
    world.drawRings(camera);
    
	// send the current image to the screen - any drawing after here will not display
	glutSwapBuffers();
}
Esempio n. 26
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// clear the screen - any drawing before here will not display

	glLoadIdentity();
	// set up the camera here
    camera.setCamera();

	// camera is set up - any drawing before here will display incorrectly

	drawOrientationCube();
	glColor3f(0.75f, 0.75f, 0.75f);
	glutSolidSphere(0.5, 20, 15);

	// send the current image to the screen - any drawing after here will not display
	glutSwapBuffers();
}
IlwisObject *InternalIlwisObjectFactory::createCsy(const Resource& resource, const IOOptions &options) const {
    CoordinateSystem *csy = 0;
    if ( resource.ilwisType() == itBOUNDSONLYCSY){ // by default to csy unknow but this may be changed later
        csy = createFromResource<BoundsOnlyCoordinateSystem>(resource, options);
        csy->name("unknown");
        csy->code("unknown");
        csy->setDescription(TR("Unknown coordinate system"));
    }else if ( resource.ilwisType() == itCONVENTIONALCOORDSYSTEM){
        csy = createFromResource<ConventionalCoordinateSystem>(resource, options);
        csy->name(resource.name());
        csy->code(resource.code());
    }
    return csy;
}
Esempio n. 28
0
void L2Projector::init(const DiscreteSpace& space,
                       const CoordinateSystem& coordSys,
                       const Expr& expr,
                       const LinearSolver<double>& solver)
{
    TEST_FOR_EXCEPTION(space.basis().size() != expr.size(),
                       RuntimeError,
                       "mismatched vector structure between basis and expr");

    TEST_FOR_EXCEPTION(space.basis().size() == 0,
                       RuntimeError,
                       "Empty basis?");

    Expr v = new TestFunction(space.basis()[0], "dummy_v[0]");
    Expr u = new UnknownFunction(space.basis()[0], "dummy_u[0]");

    for (int i=1; i<space.basis().size(); i++)
    {
        v.append(new TestFunction(space.basis()[i], "dummy_v["
                                  + Teuchos::toString(i)+"]"));
        u.append(new UnknownFunction(space.basis()[i], "dummy_u["
                                     + Teuchos::toString(i)+"]"));
    }

    CellFilter interior = new MaximalCellFilter();

    Expr eqn = 0.0;
    Expr J = coordSys.jacobian();

    for (int i=0; i<space.basis().size(); i++)
    {
        eqn = eqn + Integral(space.cellFilters(i),
                             J*v[i]*(u[i]-expr[i]),
                             new GaussianQuadrature(4));
    }
    Expr bc;

    prob_ = LinearProblem(space.mesh(), eqn, bc, v, u, space.vecType());
    solver_ = solver;
}
Esempio n. 29
0
void init()
{
    for (int i = 0; i < 256; i++)
    {
        key_pressed[i] = false;
    }
    
    for (int i = 0; i < 20; i++)
    {
        special_key_pressed[i] = false;
    }
    
    initDisplay();
    camera.setPosition(Vector3(70000.0, 0.0, 70000.0));
    skybox.load("Models/Skybox.obj");
    saturn.load(saturnInfo.filename);
    for (int i = 0; i < 10; i++)
    {
        moons[i].load(moonInfo[i].filename);
    }
    ring.load(ringInfo.filename);
}
Esempio n. 30
0
void RingSystem :: draw (const CoordinateSystem& camera_coordinates) const
{
	const Vector3& camera_position = camera_coordinates.getPosition();
	RingSectorIndex camera_index(camera_position);

	if(DEBUGGING_CHOOSING_SECTORS)
		cout << "Drawing around ring sector " << camera_index << endl;

	for(int dx = -RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dx <= RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dx++)
	{
		short x = camera_index.getX() + dx;
		for(int dy = -RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dy <= RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dy++)
		{
			short y = camera_index.getY() + dy;
			for(int dz = -RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dz <= RING_SECTOR_DRAW_FROM_CAMERA_COUNT; dz++)
			{
				short z = camera_index.getZ() + dz;
				RingSectorIndex ring_sector_index(x, y, z);

				const RingSector& ring_sector = getRingSector(ring_sector_index);
				unsigned int particle_count = (unsigned int)ring_sector.mv_ring_particles.size();

				if(DEBUGGING_CHOOSING_SECTORS && dx == 0 && dy == 0 && dz == 0)
				{
					cout << "\tRing Sector " << ring_sector.m_index << "\t==> "     << ring_sector.m_index.getCenter() << endl;
					cout << "\t\t "          << particle_count      << " particles" << endl;
				}

				for(unsigned int i = 0; i < particle_count; i++)
				{
					ring_sector.mv_ring_particles[i].draw(camera_position);
					if(DEBUGGING_CHOOSING_SECTORS && dx == 0 && dy == 0 && dz == 0)
						cout << "\t\t#" << i << ":\t" << ring_sector.mv_ring_particles[i].getPosition() << endl;
					}
			}
		}
	}
}