Exemple #1
0
 void dir_cpi_impl::sync_is_dir (bool    & is_dir, 
                                 saga::url url)
 {
    instance_data idata (this);
    is_dir = false;
   
    saga::url dir_url(idata->location_);
    boost::filesystem::path name (url.get_path(), boost::filesystem::native);
    boost::filesystem::path path (idata->location_.get_path(), boost::filesystem::native);
   
    if ( ! name.has_root_path () )
      path /= name;
    else
      path = name;
   
    if(hdfsExists(fs_, path.string().c_str()) == 0)
    {
       //Check to see if it is a directory
       hdfsFileInfo *info;
       instance_data idata(this);
    
       info = hdfsGetPathInfo(fs_, path.string().c_str());
       if(info == NULL)
       {
          SAGA_ADAPTOR_THROW("file_cpi_impl::init failed",
                           saga::NoSuccess);
       }
       if(info->mKind == kObjectKindDirectory)
          is_dir = true;
       hdfsFreeFileInfo(info, 1);
     }
 }
logical cClassCodeBase :: InsertBlock ( )
{
  DPoint             dpos      = GetPosition();
  std::string        idata("");
  logical            term      = NO;
BEGINSEQ
  if ( ProvideData() )                               ERROR 

  idata.append("{\n");
  idata.append(dpos.X-1+2,' ');
  idata.append("\n");
  idata.append(dpos.X-1,' ');
  idata.append("}\n");
  
  data.insert(offset,idata);
  SetData((char *)data.c_str());
  
  dpos.Y++;
  dpos.X+=2;
  SetPosition(dpos);
RECOVER
  term = YES;
ENDSEQ
  return(term);
}
Exemple #3
0
  file_cpi_impl::file_cpi_impl (proxy                * p, 
                                cpi_info       const & info,
                                saga::ini::ini const & glob_ini,
                                saga::ini::ini const & adap_ini,
                                boost::shared_ptr <saga::adaptor> adaptor)

      : file_cpi (p, info, adaptor, cpi::Noflags)
  {        
    adaptor_data_t       adata (this);
    file_instance_data_t idata (this);

    //SAGA_ADAPTOR_THROW ("Not Implemented (yet), but soon will be!", saga::NotImplemented);
  
    saga::url location(idata->location_);
    std::string host(location.get_host());
    std::string scheme(location.get_scheme());

    // make sure that we only allow globusonline:// URLs

    if (scheme != "globusonline")
    {
       SAGA_OSSTREAM strm;
       strm << "Could not initialize file object for [" << idata->location_ << "]. "
            << "Only globusonline:// schemes are supported.";
       SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
    }
  }
logical cClassCodeBase :: InsertExpression ( )
{
  DPoint        dpos     = GetPosition();
  int           line_end = 0;
  std::string   idata("");
  logical       term     = NO;
BEGINSEQ
  if ( ProvideData() )                               ERROR 

  line_end = matches[dpos.Y - 1].second;

  idata.append("if (  )");
  if ( dpos.X < line_end )
  {
    idata.append("\n");
    idata.append(dpos.X+2,' ');
  }

  data.insert(offset,idata);
  SetData((char *)data.c_str());
  
  dpos.X+=5;
  SetPosition(dpos);
RECOVER
  term = YES;
ENDSEQ
  return(term);
}
Exemple #5
0
////////////////////////////////////////////////////////////////////////////////
// Test boost::simd::output_iterator behavior with std::vector
////////////////////////////////////////////////////////////////////////////////
NT2_TEST_CASE_TPL(simd_vector_output_iterator, BOOST_SIMD_SIMD_TYPES )
{
  typedef typename boost::simd::output_iterator<T> oit_;
  typedef typename boost::simd::input_iterator<T>  iit_;
  typedef typename boost::simd::pack<T> p_t;
  static const std::size_t card = boost::simd::meta::cardinal_of<p_t>::value;
  //  static const std::size_t at_ = card - 1;

  std::vector<T, boost::simd::memory::allocator<T> > idata(3*card);
  std::vector<T, boost::simd::memory::allocator<T> > odata(3*card);

  for(int i=0; i<3*card; ++i) idata[i] = i;

  oit_ obegin = boost::simd::output_begin(odata.begin());
  oit_ oend   = boost::simd::output_end(odata.end());
  iit_ ibegin = boost::simd::input_begin(idata.begin());
  iit_ iend   = boost::simd::input_end(idata.end());  
  
  for(; obegin != oend; ++obegin) *obegin = *ibegin++;

  iit_ rbegin = boost::simd::input_begin(&odata[0]);
  iit_ rend   = boost::simd::input_end(&odata[0]+3*card);  

  for(int c = 0; rbegin != rend; ++rbegin, c++)
  {
    for(int i=0;i<card;++i)
     NT2_TEST_EQUAL( (*rbegin)[i], idata[i + c*card]);
  }
}
Exemple #6
0
void encode(const std::vector<boost::shared_ptr<std::vector<double> > >& input,
    const Model& model, std::vector<boost::shared_ptr<std::vector<double> > >& output)
{
  assert(input.size());

  const size_t rows = input.size(), cols = input[0]->size();

  assert(cols == (size_t)model.getModel()->high_dim());

  const int lowdim = model.getModel()->low_dim();

  std::vector<double> idata(rows * cols);
  std::vector<double> odata(rows * lowdim);

  for (size_t i = 0; i < input.size(); ++i) {
    std::copy(input[i]->begin(), input[i]->end(), idata.begin() + cols * i);
  }

  YA_WRAP_RM(double) input_w(&idata[0], rows, cols);
  YA_WRAP_RM(double) output_w(&odata[0], rows, lowdim);

  model.getModel()->forward_t(input_w, output_w);

  output.clear();
  for (size_t i = 0; i < rows; ++i) {
    output.push_back(boost::make_shared<std::vector<double> >(odata.begin() + i * lowdim, odata.begin() + (i+1) * lowdim));
  }
}
logical cClassCodeBase :: InsertSwitch ( )
{
  DPoint        dpos     = GetPosition();
  int           line_end = 0;
  std::string   idata("");
  logical       term     = NO;
BEGINSEQ
  if ( ProvideData() )                               ERROR 

  idata.append("switch (  )\n");
  idata.append(dpos.X-1,' ');
  idata.append("{\n");
  idata.append(dpos.X-1+2,' ');
  idata.append("case    : \n");
  idata.append(dpos.X-1+12,' ');
  idata.append("break;\n");
  idata.append(dpos.X-1+2,' ');
  idata.append("default : ;\n");
  idata.append(dpos.X-1,' ');
  idata.append("}\n");
  
  data.insert(offset,idata);
  SetData((char *)data.c_str());
  
  dpos.X+=9;
  SetPosition(dpos);
RECOVER
  term = YES;
ENDSEQ
  return(term);
}
Exemple #8
0
 void dir_cpi_impl::sync_open_dir (saga::filesystem::directory & ret, 
                                   saga::url                     name_to_open,
                                   int                           openmode) {
     instance_data idata (this);
     bool exists = false; 
     bool is_dir = false; 
    
     saga::url file_url(idata->location_);
     boost::filesystem::path name (name_to_open.get_path(), boost::filesystem::native);
     boost::filesystem::path path (file_url.get_path(), boost::filesystem::native);
    
     if ( ! name.has_root_path () ) {
       path /= name;
       file_url.set_path(path.string());
     }
     else {
       path = name;
       file_url = saga::url(name.string());
     }
     if(fs_->Exists(path.string().c_str())) {
        exists = true;
        //Check to see if it is a directory
        if(fs_->IsDirectory(path.string().c_str()))
           is_dir = true;
     }
     if ( exists && !is_dir) {
       SAGA_ADAPTOR_THROW(path.string() + ": doesn't refer to a file object",
         saga::DoesNotExist);
     }
    
     ret = saga::filesystem::directory (this->get_proxy()->get_session(), file_url.get_url(),
                              openmode);
     //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
  ///////////////////////////////////////////////////////////////////////////////
  //
  // init() is called whenever the cpi's instance data have changed.  In that
  // case, it re-initializes the proxy directory instance which points into the
  // locally mounted sshfs name spaces, or into the local file system in
  // general. 
  //
  // init() will generally throw if the idata->location points elsewhere.
  // init() is however assumed to be atomic, so it either succeeds, or it fails
  // but then leaves the object state unchanged.  That way, the individual
  // methods don't need to attempt to recover from a failed init.  The only side
  // effect can be an additionally mounted sshfs, which is getting cleaned up by
  // the adaptor d'tor (that cleanup is optional though).
  //
  // The single argument, the url 'save', is used to restore state on failure
  //
  void dir_cpi_impl::init (void)
  {
    adaptor_instance_data_t   adata (this);
    directory_instance_data_t idata (this);

    if ( idata->location_.get_scheme () != "ssh" &&
         idata->location_.get_scheme () != "any" )
    {
      SAGA_LOG_DEBUG ("sshfs can not handle url:");
      SAGA_LOG_DEBUG (idata->location_.get_string ().c_str ());

      std::stringstream ss;
      ss << "Cannot handle URL scheme " << idata->location_.get_scheme ()
         << " - can only handle schemas 'ssh' or 'any'." << std::endl;

      SAGA_ADAPTOR_THROW_NO_CONTEXT (ss.str ().c_str (), 
                                     saga::adaptors::AdaptorDeclined);
    }


    // create a new api object from the changed instance data.
    try
    {
      d_ = saga::filesystem::directory (adata->strip_session (s_),
                                        adata->try_translate (s_, idata->location_), 
                                        idata->mode_);
    }
    catch ( const saga:: exception & e )
    {
      std::stringstream ss;
      ss << "Cannot handle URL: \n\t" << e.what () << "\n";

      SSH_ADAPTOR_RETHROW (e, ss.str ().c_str (), saga::BadParameter);
    }
  }
Exemple #10
0
// Functions of class Retinex_MSRCR
Frame &Retinex_MSRCR::process_Frame(Frame &dst, const Frame &src)
{
    PCType i, j, upper;
    PCType height = src.Height();
    PCType width = src.Width();
    PCType stride = src.Stride();

    if (src.isRGB())
    {
        const Plane &srcR = src.R();
        const Plane &srcG = src.G();
        const Plane &srcB = src.B();
        Plane &dstR = dst.R();
        Plane &dstG = dst.G();
        Plane &dstB = dst.B();

        DType sFloor = srcR.Floor();
        DType dFloor = dstR.Floor();
        FLType dRangeFL = static_cast<FLType>(dstR.ValueRange());

        Plane_FL idata(srcR, false);

        RangeConvert(idata, srcR);
        Plane_FL odataR = Kernel(idata);
        RangeConvert(idata, srcG);
        Plane_FL odataG = Kernel(idata);
        RangeConvert(idata, srcB);
        Plane_FL odataB = Kernel(idata);

        DType Rval, Gval, Bval;
        FLType temp;

        for (j = 0; j < height; ++j)
        {
            i = j * stride;
            for (upper = i + width; i < upper; ++i)
            {
                Rval = srcR[i] - sFloor;
                Gval = srcG[i] - sFloor;
                Bval = srcB[i] - sFloor;
                temp = static_cast<FLType>(Rval + Gval + Bval);
                temp = temp <= 0 ? 0 : para.restore / temp;
                odataR[i] *= log(Rval * temp + 1);
                odataG[i] *= log(Gval * temp + 1);
                odataB[i] *= log(Bval * temp + 1);
            }
        }

        SimplestColorBalance(dst, odataR, odataG, odataB, para.lower_thr, para.upper_thr, para.HistBins);
    }
    else
    {
        DEBUG_FAIL("Retinex_MSRCR::process: invalid PixelType of Frame \"src\", should be RGB.");
    }

    return dst;
}
Exemple #11
0
Plane &Retinex_MSR::process_Plane(Plane &dst, const Plane &src)
{
    Plane_FL idata(src);
    Plane_FL odata = Kernel(idata);

    SimplestColorBalance(dst, odata, para.lower_thr, para.upper_thr, para.HistBins);

    return dst;
}
  void file_cpi_impl::sync_get_size (saga::off_t & size_out)
  {
    file_instance_data_t    idata (this);
    adaptor_instance_data_t adata (this);

    /// suite_instance_data_t   sdata (this);

    SSH_ADAPTOR_TRY
      size_out = f_.get_size ();
    SSH_ADAPTOR_CATCH;
  }
  void dir_cpi_impl::sync_is_file (bool    & is_file, 
                                   saga::url name)
  {
    adaptor_instance_data_t   adata (this);
    directory_instance_data_t idata (this);

    saga::url u = adata->make_absolute (idata->location_, name);

    SSH_ADAPTOR_TRY
      is_file = d_.is_file (adata->try_translate (s_, u));
    SSH_ADAPTOR_CATCH;
  }
Exemple #14
0
PyResult Command_createitem( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() < 2 ) {
		throw PyException( MakeCustomError("Correct Usage: /create [typeID]") );
	}
	
	//basically, a copy/paste from Command_create. The client seems to call this multiple times, 
	//each time it creates an item
	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "Argument 1 must be type ID." ) );
    const uint32 typeID = atoi( args.arg( 1 ).c_str() );
 
	uint32 qty = 1;
    if( 2 < args.argCount() )
    {
	    if( args.isNumber( 2 ) )
		    qty = atoi( args.arg( 2 ).c_str() );
    }

    sLog.Log("command message", "Create %s %u times", args.arg( 1 ).c_str(), qty );

	//create into their cargo hold unless they are docked in a station,
	//then stick it in their hangar instead.
	uint32 locationID;
	EVEItemFlags flag;
	if( who->IsInSpace() )
    {
		locationID = who->GetShipID();
		flag = flagCargoHold;
	}
    else
    {
		locationID = who->GetStationID();
		flag = flagHangar;
	}
	
	ItemData idata(
		typeID,
		who->GetCharacterID(),
		0, //temp location
		flag,
		qty
	);

	InventoryItemRef i = services->item_factory.SpawnItem( idata );
	if( !i )
		throw PyException( MakeCustomError( "Unable to create item of type %s.", args.arg( 1 ).c_str() ) );

	//Move to location
	i->Move( locationID, flag, true );

	return new PyString( "Creation successful." );
}
Exemple #15
0
  // constructor
  job_cpi_impl::job_cpi_impl (proxy                           * p, 
                              cpi_info const                  & info,
                              saga::ini::ini const            & glob_ini, 
                              saga::ini::ini const            & adap_ini,
                              TR1::shared_ptr <saga::adaptor>   adaptor)
    : base_cpi (p, info, adaptor, cpi::Noflags)
    , session_ (p->get_session ())
    , state_   (saga::job::New)
  {
    instance_data     idata (this);
    adaptor_data_type adata (this);

    saga::url contact_url = idata->rm_;

    SAGA_LOG_INFO("url: " + contact_url.get_url ());

    // check if URL is usable
    if ( ! contact_url.get_scheme ().empty ()    &&
           contact_url.get_scheme () != "drmaa"    &&
           contact_url.get_scheme () != "any"    )
    {
      SAGA_OSSTREAM strm;
      strm << "Could not initialize job service for [" << contact_url << "]. "
           << "Only these schemas are supported: any://, drmaa://, or none.";

      SAGA_ADAPTOR_THROW (SAGA_OSSTREAM_GETSTRING (strm), 
                          saga::adaptors::AdaptorDeclined);
    }

    // TODO: load drmaa && drmaa_init
    SAGA_LOG_INFO("getting DRMAA singleton");

    drmaa_ = &(saga::adaptors::utils::get_singleton<psnc_drmaa::drmaa>());

    if ( idata->init_from_jobid_ )
    {
      jobid_ = idata->jobid_;
      state_ = drmaa_->get_state(jobid_);
    }
    else
    {
      // init from job description
      jd_ = idata->jd_;
      state_ = saga::job::New;
      
      if ( ! jd_.attribute_exists (sja::description_executable) )
      {
        SAGA_ADAPTOR_THROW ("job description misses executable", saga::BadParameter);
      }
    }

    // FIXME: register metrics etc.
  }
  dir_cpi_impl::dir_cpi_impl (proxy                * p, 
                              cpi_info       const & info,
                              saga::ini::ini const & glob_ini,
                              saga::ini::ini const & adap_ini,
                              boost::shared_ptr<saga::adaptor> adaptor)

      : directory_cpi (p, info, adaptor, cpi::Noflags)
  {
    adaptor_data_t            adata (this);
    directory_instance_data_t idata (this);

    SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
  }
  void dir_cpi_impl::sync_get_size (saga::off_t & size_out, 
                                    saga::url      name, 
                                    int            flag)
  {
    adaptor_instance_data_t   adata (this);
    directory_instance_data_t idata (this);

    saga::url u = adata->make_absolute (idata->location_, name);

    SSH_ADAPTOR_TRY
      size_out = d_.get_size (adata->try_translate (s_, u), flag);
    SSH_ADAPTOR_CATCH;
  }
  file_cpi_impl::file_cpi_impl (proxy                * p, 
                                cpi_info       const & info,
                                saga::ini::ini const & glob_ini,
                                saga::ini::ini const & adap_ini,
                                boost::shared_ptr <saga::adaptor> adaptor)
      : file_cpi (p, info, adaptor, cpi::Noflags)
  {
    adaptor_instance_data_t adata (this);
    file_instance_data_t    idata (this);

    s_ = p->get_session ();

    init ();
  }
Exemple #19
0
Plane &Retinex_MSRCR_GIMP::process_Plane(Plane &dst, const Plane &src)
{
    Plane_FL idata(src);
    Plane_FL odata = Kernel(idata);

    FLType mean = odata.Mean();
    FLType var = odata.Variance(mean);
    FLType min = mean - para.dynamic * var;
    FLType max = mean + para.dynamic * var;

    RangeConvert(dst, odata, dst.Floor(), dst.Neutral(), dst.Ceil(), min, min, max, true);

    return dst;
}
Exemple #20
0
  void dir_cpi_impl::sync_remove (saga::impl::void_t & ret, 
                                  saga::url            url, 
                                  int                  flags)
  {
     instance_data idata (this);
     saga::url dir_url(idata->location_);
     boost::filesystem::path src_location (idata->location_.get_path(), boost::filesystem::native);
     // complete paths
     boost::filesystem::path src_path (url.get_path(), boost::filesystem::native);
     if ( ! src_path.has_root_path () )
         src_location /= src_path;
     else
         src_location = src_path;

     bool is_src_dir = false;
     if(hdfsExists(fs_, src_location.string().c_str()) != 0)
     {
         SAGA_ADAPTOR_THROW("directory::remove: Can't remove directory: "
           "Does not exist", saga::DoesNotExist);
     }
     else
     {
        hdfsFileInfo *info;
        info = hdfsGetPathInfo(fs_, src_location.string().c_str());
        if(info == NULL)
        {
           SAGA_ADAPTOR_THROW("file_cpi_impl::init failed",
                            saga::NoSuccess);
        }
        if(info->mKind == kObjectKindDirectory)
           is_src_dir = true;
        else
           is_src_dir = false;
        hdfsFreeFileInfo(info, 1);

     }
     if (is_src_dir) {
         if (saga::name_space::Recursive != flags)
         {
             SAGA_ADAPTOR_THROW("directory::remove: Can't remove directory. "
                 "Please use recursive mode!", saga::BadParameter);
         }
         else {
            saga_hdfs_delete(fs_, src_location.string().c_str()); 
         }
     }
     else {
        saga_hdfs_delete(fs_, src_location.string().c_str()); 
     }
  }
  void dir_cpi_impl::sync_open_dir (saga::filesystem::directory & ret, 
                                    saga::url                     name, 
                                    int                           openmode)
  {
    adaptor_instance_data_t   adata (this);
    directory_instance_data_t idata (this);

    saga::url u = adata->make_absolute (idata->location_, name);

    // we do *not* use the stripped session here, as the target is in all
    // likelyhood an ssh file
    SSH_ADAPTOR_TRY
      ret = saga::filesystem::directory (s_, u, openmode);
    SSH_ADAPTOR_CATCH
  }
Exemple #22
0
void trainModel(std::vector<boost::shared_ptr<std::vector<double> > >& input,
    DimensionalityReductionMethod method, int lowdim, int neighbors, Model& model)
{
  assert(input.size());

  const size_t rows = input.size(), cols = input[0]->size();

  std::vector<double> idata(rows * cols);
  std::vector<double> odata(rows * lowdim);

  for (size_t i = 0; i < input.size(); ++i) {
    std::copy(input[i]->begin(), input[i]->end(), idata.begin() + cols * i);
  }

  YA_WRAP_RM(double) input_w(&idata[0], rows, cols);
  YA_WRAP_RM(double) output_w(&odata[0], rows, lowdim);

  boost::shared_ptr<YADimReduce<double> > reductionMethod;

  switch(method) {
  case DimensionalityReductionMethod::PCA:
    reductionMethod = boost::make_shared<YAPCAReduce<double> >();
    break;

  case DimensionalityReductionMethod::LLE:
    reductionMethod = boost::make_shared<YALLEReduce<double> >();
    reductionMethod->neighbor_weight_mode(1);
    reductionMethod->neighbors(neighbors);
    reductionMethod->neighbor_mode(0);
    break;

  case DimensionalityReductionMethod::Isomap:
    reductionMethod = boost::make_shared<YAIsoReduce<double> >();
    reductionMethod->neighbor_weight_mode(0);
    reductionMethod->neighbors(neighbors);
    reductionMethod->neighbor_mode(0);
    break;
  }

  EigenOptions eigopts;
  reductionMethod->verbose(2);
  reductionMethod->find_t(input_w, output_w, lowdim, eigopts);

  model.setMethod(method);
  model.setModel(reductionMethod);
}
Exemple #23
0
 void dir_cpi_impl::sync_exists (bool    & exists, 
                                 saga::url url)
 {
    instance_data idata (this);
    
    saga::url dir_url(idata->location_);
    boost::filesystem::path name (url.get_path(), boost::filesystem::native);
    boost::filesystem::path path (idata->location_.get_path(), boost::filesystem::native);
    
    if ( ! name.has_root_path () )
      path /= name;
    else
      path = name;
    exists = false;
    if(hdfsExists(fs_, path.string().c_str()) == 0)
    {
       exists = true;
    }
 }
Exemple #24
0
  void dir_cpi_impl::sync_list (std::vector <saga::url> & list, 
                                std::string               pattern, 
                                int                       flags)
  {
     instance_data idata(this);
     int size = 0;
     hdfsFileInfo *results;

     results = hdfsListDirectory(fs_, idata->location_.get_path().c_str(), &size);
     if(hdfsListDirectory(fs_, idata->location_.get_path().c_str(), &size) == NULL)
     {
        SAGA_ADAPTOR_THROW ("List error", saga::NoSuccess);
     }
     for(int counter = 0; counter < size; counter++)
     {
        std::string string(results[counter].mName);
        list.push_back(saga::url(string));
     }
  }
logical cClassCode :: InsertErrString (char *text )
{
  DPoint       dpos       = GetPosition();
  int          line       = 0;
  int          line_end   = 0;
  int          col_pos    = 0;
  std::string  idata("");
  logical      term       = NO;
BEGINSEQ
  if ( ProvideData() )                               ERROR

  line = dpos.Y - 1;
  
  if ( line_end = matches[line].second )
  {
    if ( data.at(matches[line].first + line_end -1) == 0x0a )
      line_end--;
    if ( data.at(matches[line].first + line_end -1) == 0x0d )
      line_end--;
  }
  
  col_pos    = line_end;
  
  if ( line_end > ERR_MACRO_POS )
  {
    idata.append("\n");
    col_pos = 0;
    dpos.Y++;
  }
  idata.append(ERR_MACRO_POS-col_pos,' ');
  idata.append(text);
  
  data.insert(matches[line].first+line_end,idata);
  SetData((char *)data.c_str());
  
  dpos.X = ERR_MACRO_POS+strlen(text)+1;
  SetPosition(dpos);
RECOVER
  term = YES;
ENDSEQ
  return(term);
}
//---------------------------------------------------------------------------
//读取位移解及等效应变能数据
void Postprocessor::read_u_solution_equivalent_energy(const string &output_file_name, double equivalent_energy[])
{
	//-------------------------------------------------------------------------------------------------
	//二进制读取数据
	int us, uis;
	fstream idata(output_file_name.c_str(), ios::in|ios::binary);
	//读取位移解数据
	idata.read((char *)&us, sizeof(int));
	idata.read((char *)&uis, sizeof(int));
	vector<double> temp_u(uis);
	u.assign(us, temp_u);
	for(int i=0; i<us; i++)
		for(int j=0; j<uis; j++)
			idata.read((char *)&u[i][j], sizeof(double));

	//读取等效应变能数据
	idata.read((char *)equivalent_energy, sizeof(double)*9);

	idata.close();
}
Exemple #27
0
  dir_cpi_impl::dir_cpi_impl (proxy                * p, 
                              cpi_info       const & info,
                              saga::ini::ini const & glob_ini,
                              saga::ini::ini const & adap_ini,
                              boost::shared_ptr<saga::adaptor> adaptor)

      : directory_cpi (p, info, adaptor, cpi::Noflags), 
        dserv_( serv_.get_sector_dir_service())
  {
    std::string error ; 
    adaptor_data_t            adata (this);
    directory_instance_data_t idata (this);

    /* Parse the location and open the directory 
     */
    location =  idata->location_  ; 
    set_dir_name() ; 
    s_ = p->get_session() ; 
    mode = idata->mode_ ; 


    /* 
    if( !adata->get_auth_flag() )
    {
       bool auth = adata->authenticate( s_, location, mode, serv_, glob_ini, adap_ini ) ; 
       if( !auth )
       {
          SAGA_ADAPTOR_THROW ("Could not authenticate with the Sector/Sphere Master Server.", saga::NoSuccess ) ; 
       }
       adata->set_auth_flag() ; 
    }
    */

    bool open = open_dir( error ) ; 
    if( !open )
    {
      SAGA_ADAPTOR_THROW ( error , saga::NoSuccess ) ; 
    }

  }
void SpawnAsteroid( SystemManager* system, uint32 typeID, double radius, const GVector& position )
{
    //TODO: make item in IsUniverseAsteroid() range...
    ItemData idata( typeID,
                    1 /* who->GetCorporationID() */, //owner
                    system->GetID(),
                    flagAutoFit,
                    "",    //name
                    position );

    InventoryItemRef i = system->itemFactory().SpawnItem( idata );
    if( !i )
        throw PyException( MakeCustomError( "Unable to spawn item of type %u.", typeID ) );

    //i->Set_radius( radius );
    // Calculate 1/10000th of the volume of a sphere with radius 'radius':
    // (this should yield around 90,000 units of Veldspar in an asteroid with 1000.0m radius)
    double volume = (1.0/10000.0) * (4.0/3.0) * M_PI * pow(radius,3);

	i->SetAttribute(AttrQuantity, EvilNumber(floor(100*(volume/(i->GetAttribute(AttrVolume).get_float())))));
    i->SetAttribute(AttrRadius, EvilNumber(radius));
    //i->SetAttribute(AttrVolume, EvilNumber(volume));
    //i->SetAttribute(AttrIsOnline,EvilNumber(1));                            // Is Online
    //i->SetAttribute(AttrDamage,EvilNumber(0.0));                            // Structure Damage
    //i->SetAttribute(AttrShieldCharge,i->GetAttribute(AttrShieldCapacity));  // Shield Charge
    //i->SetAttribute(AttrArmorDamage,EvilNumber(0.0));                       // Armor Damage
    //i->SetAttribute(AttrMass,EvilNumber(i->type().attributes.mass()));      // Mass
    //i->SetAttribute(AttrRadius,EvilNumber(i->type().attributes.radius()));  // Radius
    //i->SetAttribute(AttrVolume,EvilNumber(i->type().attributes.volume()));  // Volume

    // TODO: Rework this code now that
    AsteroidEntity* new_roid = NULL;
    new_roid = new AsteroidEntity( i, system, *(system->GetServiceMgr()), position );
    if( new_roid != NULL )
        sLog.Debug( "SpawnAsteroid()", "Spawned new asteroid of radius= %fm and volume= %f m3", radius, volume );
    //TODO: check for a local asteroid belt object?
    //TODO: actually add this to the asteroid belt too...
    system->AddEntity( new_roid );
}
  void job_service_cpi_impl::sync_get_job (saga::job::job & ret, 
                                           std::string      jobid)
  {
    instance_data idata (this);

    try
    {
      // create job from jobid
      ret = saga::adaptors::job (idata->rm_,
                                 jobid, 
                                 proxy_->get_session ());
    }
    catch ( const char & m )
    {
      SAGA_ADAPTOR_THROW ((std::string ("Could not create job: ") + m).c_str (), 
                          saga::NoSuccess);
    }
    catch ( const saga::exception & e )
    {
      SAGA_ADAPTOR_THROW ((std::string ("Could not create job: ") + e.what ()).c_str (), 
                          saga::NoSuccess);
    }
  }
Exemple #30
0
  void dir_cpi_impl::sync_make_dir (saga::impl::void_t & ret, 
                                    saga::url            url, 
                                    int                  flags)
  {
     instance_data idata (this);
    
     // verify current working directory is local
     saga::url dir_url(idata->location_);
    
     boost::filesystem::path src_location (idata->location_.get_path(), boost::filesystem::native);
     // complete paths
     boost::filesystem::path src_path (url.get_path(), boost::filesystem::native);
    
     if ( ! src_path.has_root_path () )
         src_location /= src_path;
     else
         src_location = src_path;

     if(hdfsCreateDirectory(fs_, src_location.string().c_str()) != 0)
     {
        SAGA_ADAPTOR_THROW("Could not create directory", saga::NoSuccess);
     }
  }