• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ elements函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中elements函数的典型用法代码示例。如果您正苦于以下问题:C++ elements函数的具体用法?C++ elements怎么用?C++ elements使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了elements函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getRndMode_cf

Value*
getRndMode_cf(Value** arg_list, int count)
{
	check_arg_count(getRndMode, 0, count);
	def_render_types();
	one_typed_value_local(Array* result);
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	DWORD			mode	= gw->getRndMode();

	vl.result = new Array(3);
	for (int i=0; i < elements(renderTypes); i++)
		if ((renderTypes[i].id) & mode) 
			vl.result->append(renderTypes[i].val);		
	return_value (vl.result); // LAM - 5/18/01 - was return vl.result
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:21,代码来源:GraphicsWindow.cpp


示例2: setRndLimits_cf

Value*
setRndLimits_cf(Value** arg_list, int count)
{
	check_arg_count(setRndLimits, 1, count);
	def_render_types();
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	Array			*arr	= (Array*)arg_list[0];
	DWORD			lim		=0;

	type_check(arr, Array, _T("setRndLimits"));
	for (int i=0; i < arr->size; i++)
		lim |= GetID(renderTypes, elements(renderTypes), arr->data[i]);
	gw->setRndLimits(lim);
	return &ok;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:21,代码来源:GraphicsWindow.cpp


示例3: owner

cell factor_vm::code_block_owner(code_block *compiled)
{
	tagged<object> owner(compiled->owner);

	/* Cold generic word call sites point to quotations that call the
	inline-cache-miss and inline-cache-miss-tail primitives. */
	if(owner.type_p(QUOTATION_TYPE))
	{
		tagged<quotation> quot(owner.as<quotation>());
		tagged<array> elements(quot->array);
#ifdef FACTOR_DEBUG
		assert(array_capacity(elements.untagged()) == 5);
		assert(array_nth(elements.untagged(),4) == special_objects[PIC_MISS_WORD]
			|| array_nth(elements.untagged(),4) == special_objects[PIC_MISS_TAIL_WORD]);
#endif
		tagged<wrapper> word_wrapper(array_nth(elements.untagged(),0));
		return word_wrapper->object;
	}
	else
		return compiled->owner;
}
开发者ID:8byte-jose,项目名称:factor,代码行数:21,代码来源:code_blocks.cpp


示例4: elements

/*******************************************************************
* Function Name: externalFunction
* Description: 
********************************************************************/
Model &cola::externalFunction( const ExternalMessage &msg )
{
	if( msg.port() == in )
	{
		elements().push_back( msg.value() ) ;
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == done )
	{
		ocupado (0);
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == stop )
	{ 
		ocupado (1);
		this->passivate();
	}

	return *this;
}
开发者ID:melkyades,项目名称:cdpp,代码行数:26,代码来源:cola.cpp


示例5: tic

//template< typename Expr_convection, typename Expr_bc >
void
PreconditionerAS<space_type,coef_space_type>::update( sparse_matrix_ptrtype Pm,   // A + g M
                                                      sparse_matrix_ptrtype L,    // e_r * grad grad
                                                      sparse_matrix_ptrtype hatL, // 1/mu * grad grad
                                                      sparse_matrix_ptrtype Q     // e_r * id id
                                                      )
{
    tic();
    if(this->type() == AS)
    {
        // A = Pm
        backend()->diag(Pm,M_diagPm);
        M_diagPm->close();

        /*
         * hat(L) = 1/mu * grad grad = 1/(mu*e_r) * L
         * bar(L) = diag( hat(L), hat(L), hat(L) )
         * bar(Q) = diag( er*Q, er*Q, er*Q ) with Q = mass matrix on Qh3
         * blockms.11.1 <=> bar(L) + g*bar(Q) y = s = Pt*r
         * blockms.11.2 <=> L z = t = trans(C)*r
         */

        // Operator hat(L) + g Q
        sparse_matrix_ptrtype Lgq = hatL;
        Lgq->addMatrix(M_g,Q);
        M_lgqOp = op( Lgq, "blockms.11.1");
        // Operator L
        M_lOp = op(L,"blockms.11.2");
    }
    else if(this->type() == SIMPLE)
    {
        auto uu = M_Vh->element("uu");
        auto f22 = form2(M_Vh, M_Vh);
        f22 = integrate(_range=elements(M_Vh->mesh()),
                        _expr=inner(id(uu),idt(uu)));
        SimpleOp = op( f22.matrixPtr(),"blockms.11.1");
    }
    toc( "PreconditionerAS::update", FLAGS_v > 0 );
}
开发者ID:feelpp,项目名称:feelpp,代码行数:40,代码来源:preconditioneras.hpp


示例6: work

void PeriodogramDisplay::work(void)
{
    for (auto inPort : this->inputs())
    {
        if (not inPort->hasMessage()) continue;
        const auto msg = inPort->popMessage();

        //label-based messages have in-line commands
        if (msg.type() == typeid(Pothos::Label))
        {
            const auto &label = msg.convert<Pothos::Label>();
            if (label.id == _freqLabelId and label.data.canConvert(typeid(double)))
            {
                this->setCenterFrequency(label.data.convert<double>());
            }
            if (label.id == _rateLabelId and label.data.canConvert(typeid(double)))
            {
                this->setSampleRate(label.data.convert<double>());
            }
        }

        //packet-based messages have payloads to FFT
        if (msg.type() == typeid(Pothos::Packet))
        {
            const auto &buff = msg.convert<Pothos::Packet>().payload;
            auto floatBuff = buff.convert(Pothos::DType(typeid(std::complex<float>)), buff.elements());

            //safe guard against FFT size changes, old buffers could still be in-flight
            if (floatBuff.elements() != this->numFFTBins()) continue;

            //power bins to points on the curve
            CArray fftBins(floatBuff.as<const std::complex<float> *>(), this->numFFTBins());
            const auto powerBins = fftPowerSpectrum(fftBins, _window.call<std::vector<double>>("window"), _window.call<double>("power"));
            if (not _queueDepth[inPort->index()]) _queueDepth[inPort->index()].reset(new std::atomic<size_t>(0));
            _queueDepth[inPort->index()]->fetch_add(1);
            QMetaObject::invokeMethod(this, "handlePowerBins", Qt::QueuedConnection, Q_ARG(int, inPort->index()), Q_ARG(std::valarray<float>, powerBins));
        }
    }
}
开发者ID:m0x72,项目名称:pothos,代码行数:39,代码来源:PeriodogramWork.cpp


示例7: extensions

std::vector<IIntroDescriptor::Pointer> IntroRegistry::GetIntros() const
{
  const IExtensionPoint* point =
      Platform::GetExtensionPointService()->GetExtensionPoint(
          PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_INTRO);
  if (!point)
  {
    return std::vector<IIntroDescriptor::Pointer>();
  }

  std::vector<const IExtension*> extensions(point->GetExtensions());
  extensions = RegistryReader::OrderExtensions(extensions);

  std::vector<IIntroDescriptor::Pointer> list;
  for (std::size_t i = 0; i < extensions.size(); i++)
  {
    std::vector<IConfigurationElement::Pointer> elements(
        extensions[i] ->GetConfigurationElements());
    for (std::size_t j = 0; j < elements.size(); j++)
    {
      if (elements[j]->GetName() == TAG_INTRO)
      {
        try
        {
          IIntroDescriptor::Pointer
              descriptor(new IntroDescriptor(elements[j]));
          list.push_back(descriptor);
        } catch (CoreException& e)
        {
          // log an error since its not safe to open a dialog here
          //TODO IStatus
          WorkbenchPlugin::Log("Unable to create intro descriptor", e); // e.getStatus());
        }
      }
    }
  }

  return list;
}
开发者ID:test-fd301,项目名称:MITK,代码行数:39,代码来源:berryIntroRegistry.cpp


示例8: enumeration_element_list

ProcessParameter::enumeration_element_list ProcessParameter::EnumerationElements() const
{
   if ( !IsEnumeration() )
      return enumeration_element_list();

   size_type count = (*API->Process->GetParameterElementCount)( m_data->handle );
   if ( count == 0 )
      throw APIFunctionError( "GetParameterElementCount" );

   enumeration_element_list elements( count );

   for ( size_type i = 0; i < count; ++i )
   {
      size_type len = 0;
      (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, 0, &len );
      if ( len == 0 )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.SetLength( len );
      if ( (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, elements[i].id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.ResizeToNullTerminated();

      len = 0;
      (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, 0, &len );
      if ( len > 0 )
      {
         IsoString aliases;
         aliases.SetLength( len );
         if ( (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, aliases.c_str(), &len ) == api_false )
            throw APIFunctionError( "GetParameterElementAliasIdentifiers" );
         aliases.ResizeToNullTerminated();
         aliases.Break( elements[i].aliases, ',' );
      }

      elements[i].value = (*API->Process->GetParameterElementValue)( m_data->handle, i );
   }

   return elements;
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:39,代码来源:ProcessParameter.cpp


示例9: operator

      void operator()( viennagrid::detail::tag<ElementT> )
      {
        typedef typename viennagrid::result_of::element_range<MeshViewT, ElementT>::type ToEraseElementRangeType;
        typedef typename viennagrid::result_of::iterator<ToEraseElementRangeType>::type ToEraseElementRangeIterator;

        typedef typename viennagrid::result_of::handle<MeshT, ElementT>::type ElementHandle;
        typedef typename viennagrid::result_of::element_range<MeshT, ElementT>::type ElementRangeType;
        typedef typename viennagrid::result_of::iterator<ElementRangeType>::type ElementRangeIterator;

        typedef typename viennagrid::result_of::id<ElementT>::type id_type;

  //             std::vector< std::pair<element_range_iterator, element_range_iterator> > swtiching_map;

        std::deque<id_type> ids_to_erase;

        ToEraseElementRangeType elements_to_erase(view_to_erase_);
        for (ToEraseElementRangeIterator it = elements_to_erase.begin(); it != elements_to_erase.end(); ++it)
          ids_to_erase.push_back( it->id() );

        ElementRangeType elements(mesh_obj_);

        for (typename std::deque<id_type>::iterator it = ids_to_erase.begin(); it != ids_to_erase.end(); ++it)
        {
          ElementRangeIterator to_erase_it = find( mesh_obj_, *it );
          ElementRangeIterator back_it = --elements.end();

          if (back_it != to_erase_it)
          {
            ElementHandle old_handle = back_it.handle();
            std::swap( *back_it, *to_erase_it );
            ElementHandle new_handle = to_erase_it.handle();

            switch_handle( mesh_obj_, old_handle, new_handle );
          }

          elements.erase( back_it );
        }
      }
开发者ID:masteroftime,项目名称:viennagrid-dev,代码行数:38,代码来源:element_deletion.hpp


示例10: copy

      void copy(viennashe::math::sparse_matrix<NumericT> const & assembled_matrix,
                viennacl::compressed_matrix<NumericT>          &       vcl_matrix)
      {
        std::size_t nonzeros = assembled_matrix.nnz();
        viennacl::backend::typesafe_host_array<unsigned int> row_buffer(vcl_matrix.handle1(), assembled_matrix.size1() + 1);
        viennacl::backend::typesafe_host_array<unsigned int> col_buffer(vcl_matrix.handle2(), nonzeros);
        std::vector<NumericT> elements(nonzeros);

        std::size_t data_index = 0;

        for (std::size_t i  = 0;
                         i != assembled_matrix.size1();
                       ++i)
        {
          typedef typename viennashe::math::sparse_matrix<NumericT>::const_iterator2   AlongRowIterator;
          typedef typename viennashe::math::sparse_matrix<NumericT>::row_type          RowType;

          row_buffer.set(i, data_index);
          RowType const & row_i = assembled_matrix.row(i);

          for (AlongRowIterator col_it  = row_i.begin();
                                col_it != row_i.end();
                              ++col_it)
          {
            col_buffer.set(data_index, col_it->first);
            elements[data_index] = col_it->second;
            ++data_index;
          }
        }
        row_buffer.set(assembled_matrix.size1(), data_index);

        vcl_matrix.set(row_buffer.get(),
                       col_buffer.get(),
                       &elements[0],
                       assembled_matrix.size1(),
                       assembled_matrix.size2(),
                       nonzeros);
      }
开发者ID:viennashe,项目名称:viennashe-dev,代码行数:38,代码来源:serial_linear_solver.hpp


示例11: mapNodeFace

void FaceCellConnectivity::build_connectivity()
{

  if (used().size() == 0 )
  {
    CFwarn << "No elements are given to build faces of" << CFendl;
    return;
  }

  // sanity check
//  CFinfo << "building face_cell connectivity using " << CFendl;
//  boost_foreach(Handle< Component > cells, used() )
//  {
//    CFinfo << "  " << cells->uri().path() << CFendl;
//  }

  // declartions
  m_connectivity->resize(0);
  common::Table<Entity>::Buffer f2c = m_connectivity->create_buffer();
  common::Table<Uint>::Buffer face_number = m_face_nb_in_elem->create_buffer();
  common::List<bool>::Buffer is_bdry_face = m_is_bdry_face->create_buffer();
  Dictionary& geometry_fields = find_parent_component<Mesh>(*used()[0]).geometry_fields();
  Uint tot_nb_nodes = geometry_fields.size();
  std::vector < std::vector<Uint> > mapNodeFace(tot_nb_nodes);
  std::vector<Uint> face_nodes;  face_nodes.reserve(100);
  std::vector<Entity> dummy_element_row(2);
  std::vector<Uint> dummy_idx_row(2);
  Uint max_nb_faces(0);

  // calculate max_nb_faces
  boost_foreach ( Handle< Component > elements_comp, used() )
  {
    Handle<Elements> elements(elements_comp);
    if (elements->element_type().dimensionality() != elements->element_type().dimension() )
      continue;
    const Uint nb_faces = elements->element_type().nb_faces();
    max_nb_faces += nb_faces * elements->size() ;
  }
开发者ID:jaswi,项目名称:coolfluid3,代码行数:38,代码来源:FaceCellConnectivity.cpp


示例12: work

    void work(void)
    {
        auto inputPort = this->input(0);
        auto outputPort = this->output(0);

        while (inputPort->hasMessage() and _elementsLeft != 0)
        {
            auto m = inputPort->popMessage();
            outputPort->postMessage(m);
            _elementsLeft -= 1;
        }

        auto buffer = inputPort->buffer();
        //input port type unspecified, inspect buffer for actual element count
        const size_t elems = std::min(_elementsLeft, buffer.elements());
        if (elems != 0)
        {
            buffer.length = elems*buffer.dtype.size();
            outputPort->postBuffer(buffer);
            inputPort->consume(buffer.length);
            _elementsLeft -= elems;
        }
    }
开发者ID:arunlodhi,项目名称:pothos,代码行数:23,代码来源:FiniteRelease.cpp


示例13: strides

void Array<T>::eval()
{
    if (isReady()) return;

    this->setId(getActiveDeviceId());
    data = std::shared_ptr<T>(memAlloc<T>(elements()), memFree<T>);
    T *ptr = data.get();

    dim4 ostrs = strides();
    dim4 odims = dims();

    for (int w = 0; w < (int)odims[3]; w++) {
        dim_t offw = w * ostrs[3];

        for (int z = 0; z < (int)odims[2]; z++) {
            dim_t offz = z * ostrs[2] + offw;

            for (int y = 0; y < (int)odims[1]; y++) {
                dim_t offy = y * ostrs[1] + offz;

                for (int x = 0; x < (int)odims[0]; x++) {
                    dim_t id = x + offy;

                    ptr[id] = *(T *)node->calc(x, y, z, w);
                }
            }
        }
    }


    ready = true;

    Node_ptr prev = node;
    prev->reset();
    // FIXME: Replace the current node in any JIT possible trees with the new BufferNode
    node.reset();
}
开发者ID:klemmster,项目名称:arrayfire,代码行数:37,代码来源:Array.cpp


示例14: assert

void LogicAnalyzerDisplay::populateChannel(const int channel, const Pothos::Packet &packet)
{
    //convert buffer (does not convert when type matches)
    const auto numericBuff = packet.payload.convert(typeid(T));
    assert(_chData.size() > channel);
    _chData[channel] = packet;
    _chData[channel].payload = numericBuff;

    //load element data into table
    for (size_t i = 0; i < numericBuff.elements(); i++)
    {
        const auto num = numericBuff.as<const T *>()[i];
        const auto s = toStr(num, _chBase.at(channel));
        auto item = new QTableWidgetItem(s);
        auto flags = item->flags();
        flags &= ~Qt::ItemIsEditable;
        item->setFlags(flags);
        item->setTextAlignment(Qt::AlignRight);
        _tableView->setItem(channel, i, item);
    }

    //inspect labels to decorate table
    for (const auto &label : packet.labels)
    {
        const int column = label.index;
        assert(column < _tableView->columnCount());
        auto item = _tableView->item(channel, column);

        //highlight and display label id
        item->setBackground(Qt::yellow);
        item->setText(QString("%1\n%2")
            .arg(item->text())
            .arg(QString::fromStdString(label.id)));
        _tableView->resizeColumnToContents(column);
    }
}
开发者ID:m0x72,项目名称:pothos,代码行数:36,代码来源:LogicAnalyzerDisplay.cpp


示例15: permute_sign

int permute_sign(int n, ...){
	int sign=1;
	va_list ap;
	va_start(ap,n);
	vector<int> elements(n,0);
	
	for(int j=0; j<n; j++){
		elements[j]=va_arg(ap,int);
	}
	va_end(ap);
	
	int temp;
	for(int j=n;j>0;j--){
		for(int i=0;i<j-1;i++){
			if(elements[i]>elements[i+1]){
				 temp=elements[i];
				 elements[i]=elements[i+1];
				 elements[i+1]=temp;
				 sign*=-1;
			}
		}
	}
	return sign;
}		
开发者ID:scottgeraedts,项目名称:myClibrary,代码行数:24,代码来源:utils.cpp


示例16: getfreeset

//------------------------------add_liveout------------------------------------
// Add a vector of live-out values to a given blocks live-out set.
void PhaseLive::add_liveout( Block *p, IndexSet *lo, VectorSet &first_pass ) {
  IndexSet *live = &_live[p->_pre_order-1];
  IndexSet *defs = &_defs[p->_pre_order-1];
  IndexSet *on_worklist = _deltas[p->_pre_order-1];
  IndexSet *delta = on_worklist ? on_worklist : getfreeset();

  IndexSetIterator elements(lo);
  uint r;
  while ((r = elements.next()) != 0) {
    if( live->insert(r) &&      // If actually inserted...
        !defs->member( r ) )    // and not defined locally
      delta->insert(r);         // Then add to live-in set
  }

  if( delta->count() ) {                // If actually added things
    _deltas[p->_pre_order-1] = delta; // Flag as on worklist now
    if( !on_worklist &&         // Not on worklist?
        first_pass.test(p->_pre_order) )
      _worklist->push(p);       // Actually go on worklist if already 1st pass
  } else {                      // Nothing there; just free it
    delta->set_next(_free_IndexSet);
    _free_IndexSet = delta;     // Drop onto free list
  }
}
开发者ID:subxiang,项目名称:jdk-source-code,代码行数:26,代码来源:live.cpp


示例17: write_attribute

inline typename boost::enable_if<boost::mpl::and_<
    is_vector<T>, boost::is_fundamental<typename T::value_type>
>, void>::type
write_attribute(H5::H5Object const& object, std::string const& name, T const& value)
{
    typedef typename T::value_type value_type;

    H5::Attribute attr;
    try {
        H5XX_NO_AUTO_PRINT(H5::AttributeIException);
        attr = object.openAttribute(name);
        if (!has_type<T>(attr) || elements(attr) != value.size()) {
            // recreate attribute with proper type
            object.removeAttr(name);
            throw H5::AttributeIException();
        }
    }
    catch (H5::AttributeIException const&) {
        hsize_t dim[1] = { value.size() };
        H5::DataSpace ds(1, dim);
        attr = object.createAttribute(name, ctype<value_type>::hid(), ds);
    }
    attr.write(ctype<value_type>::hid(), &*value.begin());
}
开发者ID:jb--,项目名称:h5xx,代码行数:24,代码来源:attribute.hpp


示例18: Grad

void
PreconditionerBlockMS<space_type>::initAMS( void )
    {
        M_grad  = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh);

        // This preconditioner is linked to that backend : the backend will
        // automatically use the preconditioner.
        auto prec = preconditioner(_pc=pcTypeConvertStrToEnum(soption(M_prefix_11+".pc-type")),
                                   _backend=backend(_name=M_prefix_11),
                                   _prefix=M_prefix_11,
                                   _matrix=M_11
                                  );
        prec->setMatrix(M_11);
        prec->attachAuxiliarySparseMatrix("G",M_grad.matPtr());
        if(boption(M_prefix_11+".useEdge"))
        {
            LOG(INFO) << "[ AMS ] : using SetConstantEdgeVector \n";
            ozz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(1),cst(0),cst(0)));
            zoz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(1),cst(0)));
            zzo.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(0),cst(1)));
            *M_ozz = ozz; M_ozz->close();
            *M_zoz = zoz; M_zoz->close();
            *M_zzo = zzo; M_zzo->close();

            prec->attachAuxiliaryVector("Px",M_ozz);
            prec->attachAuxiliaryVector("Py",M_zoz);
            prec->attachAuxiliaryVector("Pz",M_zzo);
        }
        else
        {
            LOG(INFO) << "[ AMS ] : using SetCoordinates \n";
            X.on(_range=elements(M_Vh->mesh()),_expr=Px());
            Y.on(_range=elements(M_Vh->mesh()),_expr=Py());
            Z.on(_range=elements(M_Vh->mesh()),_expr=Pz());
            *M_X = X; M_X->close();
            *M_Y = Y; M_Y->close();
            *M_Z = Z; M_Z->close();
            prec->attachAuxiliaryVector("X",M_X);
            prec->attachAuxiliaryVector("Y",M_Y);
            prec->attachAuxiliaryVector("Z",M_Z);
        }
    }
开发者ID:MarieHouillon,项目名称:feelpp,代码行数:42,代码来源:preconditionerblockms.hpp


示例19: memcpy

//! Create an element sequence
ErrorCode ReadGmsh::create_elements(const GmshElemType& type,
                                    const std::vector<int>& elem_ids,
                                    const std::vector<int>& matl_ids,
                                    const std::vector<int>& geom_ids,
                                    const std::vector<int>& prtn_ids,
                                    const std::vector<EntityHandle>& connectivity,
                                    const Tag* file_id_tag)
{
  ErrorCode result;

  // Make sure input is consistent
  const unsigned long num_elem = elem_ids.size();
  const int node_per_elem = type.num_nodes;
  if (matl_ids.size() != num_elem ||
      geom_ids.size() != num_elem ||
      prtn_ids.size() != num_elem ||
      connectivity.size() != num_elem*node_per_elem)
    return MB_FAILURE;

  // Create the element sequence
  // do not do anything for point type
  if (type.mb_type==MBVERTEX)
    return MB_SUCCESS; // do not create anything
  EntityHandle handle = 0;
  EntityHandle* conn_array;
  result = readMeshIface->get_element_connect(num_elem, node_per_elem, type.mb_type,
                                              MB_START_ID,
                                              handle, conn_array);
  if (MB_SUCCESS != result)
    return result;

  // Copy passed element connectivity into entity sequence data.
  if (type.node_order) {
    for (unsigned long i = 0; i < num_elem; ++i)
      for (int j = 0; j < node_per_elem; ++j)
        conn_array[i*node_per_elem + type.node_order[j]] = connectivity[i*node_per_elem + j];
  }
  else {
    memcpy(conn_array, &connectivity[0], connectivity.size() * sizeof(EntityHandle));
  }

  // Notify MOAB of the new elements
  result = readMeshIface->update_adjacencies(handle, num_elem, node_per_elem, conn_array);
  if (MB_SUCCESS != result)
    return result;

  // Store element IDs
  Range elements(handle, handle + num_elem - 1);
  result = mdbImpl->tag_set_data(globalId, elements, &elem_ids[0]);
  if (MB_SUCCESS != result)
    return result;
  if (file_id_tag) {
    result = mdbImpl->tag_set_data(*file_id_tag, elements, &elem_ids[0]);
    if (MB_SUCCESS != result) 
      return result;
  }

  // Add elements to material sets
  result = create_sets(type.mb_type, elements, matl_ids, 0);
  if (MB_SUCCESS != result)
    return result;
  // Add elements to geometric sets
  result = create_sets(type.mb_type, elements, geom_ids, 1);
  if (MB_SUCCESS != result)
    return result;
  // Add elements to parallel partitions
  result = create_sets(type.mb_type, elements, prtn_ids, 2);
  if (MB_SUCCESS != result)
    return result;

  return MB_SUCCESS;
}
开发者ID:vibraphone,项目名称:SMTK,代码行数:73,代码来源:ReadGmsh.cpp


示例20: free

void LogStatistics::format(char **buf, uid_t uid, unsigned int logMask) {
    static const unsigned short spaces_total = 19;

    if (*buf) {
        free(*buf);
        *buf = NULL;
    }

    // Report on total logging, current and for all time

    android::String8 output("size/num");
    size_t oldLength;
    short spaces = 1;

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }
        oldLength = output.length();
        if (spaces < 0) {
            spaces = 0;
        }
        output.appendFormat("%*s%s", spaces, "", android_log_id_to_name(id));
        spaces += spaces_total + oldLength - output.length();
    }

    spaces = 4;
    output.appendFormat("\nTotal");

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }
        oldLength = output.length();
        if (spaces < 0) {
            spaces = 0;
        }
        output.appendFormat("%*s%zu/%zu", spaces, "",
                            sizesTotal(id), elementsTotal(id));
        spaces += spaces_total + oldLength - output.length();
    }

    spaces = 6;
    output.appendFormat("\nNow");

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }

        size_t els = elements(id);
        if (els) {
            oldLength = output.length();
            if (spaces < 0) {
                spaces = 0;
            }
            output.appendFormat("%*s%zu/%zu", spaces, "", sizes(id), els);
            spaces -= output.length() - oldLength;
        }
        spaces += spaces_total;
    }

    // Report on Chattiest

    // Chattiest by application (UID)
    static const size_t maximum_sorted_entries = 32;
    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }

        bool headerPrinted = false;
        std::unique_ptr<const UidEntry *[]> sorted = sort(maximum_sorted_entries, id);
        ssize_t index = -1;
        while ((index = uidTable_t::next(index, sorted, maximum_sorted_entries)) >= 0) {
            const UidEntry *entry = sorted[index];
            uid_t u = entry->getKey();
            if ((uid != AID_ROOT) && (u != uid)) {
                continue;
            }

            if (!headerPrinted) {
                if (uid == AID_ROOT) {
                    output.appendFormat(
                        "\n\nChattiest UIDs in %s:\n",
                        android_log_id_to_name(id));
                } else {
                    output.appendFormat(
                        "\n\nLogging for your UID in %s:\n",
                        android_log_id_to_name(id));
                }
                android::String8 name("UID");
                android::String8 size("Size");
                android::String8 pruned("Pruned");
                if (!worstUidEnabledForLogid(id)) {
                    pruned.setTo("");
                }
                format_line(output, name, size, pruned);
                headerPrinted = true;
            }
//.........这里部分代码省略.........
开发者ID:ThiagoVinicius,项目名称:platform_system_core,代码行数:101,代码来源:LogStatistics.cpp



注:本文中的elements函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ elf_begin函数代码示例发布时间:2022-05-30
下一篇:
C++ element_set函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap