本文整理汇总了C++中object::ptr类的典型用法代码示例。如果您正苦于以下问题:C++ ptr类的具体用法?C++ ptr怎么用?C++ ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ptr类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int_object_to_signed_long
signed long long vanilla::int_object_to_signed_longlong(object::ptr const& obj)
{
#if LLONG_MAX == LONG_MAX
return int_object_to_signed_long(obj);
#endif
if(obj->type_id() != OBJECT_ID_INT)
{
BOOST_THROW_EXCEPTION(error::bad_cast_error()
<< error::first_operand(obj)
<< error::cast_target_name("int"));
}
mpz_t& mpz = static_cast<int_object const*>(obj.get())->value().mpz();
if(mpz_sizeinbase(mpz, 2) + 1 > sizeof(long long) * CHAR_BIT)
{
BOOST_THROW_EXCEPTION(error::integer_conversion_overflow_error()
<< error::first_operand(obj)
<< error::integer_conversion_target_type("signed long long"));
}
size_t count = 0;
long long result = 0;
mpz_export(&result, &count, -1, sizeof(result), 0, 0, mpz);
assert(count == 1);
return result;
}
示例2: lhs
vanilla::object::ptr vanilla::int_object::neq(object::ptr const& other)
{
switch(other->type_id())
{
case OBJECT_ID_INT:
{
int_object const* rhs = static_cast<int_object const*>(other.get());
int result = mpz_cmp(_v.mpz(), rhs->value().mpz());
return allocate_object<bool_object>(result != 0);
}
case OBJECT_ID_FLOAT:
{
float_object const* rhs = static_cast<float_object const*>(other.get());
if(!mpf_integer_p(rhs->value().mpf()))
return allocate_object<bool_object>(true);
float_object::float_type lhs( (_v.mpz()) );
return allocate_object<bool_object>(mpf_cmp(lhs.mpf(), rhs->value().mpf()) != 0);
}
default:
{
return object::ge(other);
}
}
}
示例3: compute
bool CutGeometry::compute() {
Object::const_ptr oin = expect<Object>("grid_in");
if (!oin)
return false;
Object::ptr object = cutGeometry(oin);
if (object) {
object->copyAttributes(oin);
addObject("grid_out", object);
}
return true;
}
示例4: work
bool IsoSurface::work(vistle::UnstructuredGrid::const_ptr gridS,
vistle::Vec<vistle::Scalar>::const_ptr dataS,
vistle::DataBase::const_ptr mapdata) {
const int processorType = getIntParameter("processortype");
#ifdef CUTTINGSURFACE
const Scalar isoValue = 0.0;
#else
const Scalar isoValue = getFloatParameter("isovalue");
#endif
Leveller l(isocontrol, gridS, isoValue, processorType);
#ifndef CUTTINGSURFACE
l.setIsoData(dataS);
#endif
if(mapdata){
l.addMappedData(mapdata);
};
l.process();
#ifndef CUTTINGSURFACE
auto minmax = dataS->getMinMax();
if (minmax.first[0] < m_min)
m_min = minmax.first[0];
if (minmax.second[0] > m_max)
m_max = minmax.second[0];
#endif
Object::ptr result = l.result();
DataBase::ptr mapresult = l.mapresult();
if (result) {
#ifndef CUTTINGSURFACE
result->copyAttributes(dataS);
#endif
result->copyAttributes(gridS, false);
if (mapdata && mapresult) {
mapresult->copyAttributes(mapdata);
mapresult->setGrid(result);
addObject(m_dataOut, mapresult);
}
#ifndef CUTTINGSURFACE
else {
addObject(m_dataOut, result);
}
#endif
}
return true;
}
示例5: compute
bool ColorAttribute::compute() {
//std::cerr << "ColorAttribute: compute: execcount=" << m_executionCount << std::endl;
auto color = p_color->getValue();
Object::const_ptr obj = expect<Object>("data_in");
if (!obj)
return false;
Object::ptr out = obj->clone();
out->addAttribute("_color", color);
addObject("data_out", out);
return true;
}
示例6: compute
bool AddAttribute::compute() {
Object::const_ptr obj = expect<Object>("data_in");
if (!obj)
return true;
Object::ptr out = obj->clone();
for (int i=0; i<NumAttributes; ++i) {
if (!p_name[i]->getValue().empty()) {
out->addAttribute(p_name[i]->getValue(), p_value[i]->getValue());
}
}
addObject("data_out", out);
return true;
}
示例7: compute
bool CellToVert::compute() {
coCellToVert algo;
Object::const_ptr grid = expect<Object>("grid_in");
Object::const_ptr data = expect<Object>("data_in");
if (!grid || !data)
return false;
Object::ptr out = algo.interpolate(grid, data);
if (out) {
out->copyAttributes(data);
addObject("data_out", out);
passThroughObject("grid_out", grid);
}
return true;
}
示例8: compute
bool IsoSurface::compute() {
const Scalar isoValue = getFloatParameter("isovalue");
Object::const_ptr grid = expect<Object>("grid_in");
Object::const_ptr data = expect<Object>("data_in");
if (!grid || !data)
return false;
Object::ptr object = generateIsoSurface(grid, data, isoValue);
if (object) {
object->copyAttributes(data);
object->copyAttributes(grid, false);
addObject("grid_out", object);
}
return true;
}
示例9: float_object_to_double
double vanilla::float_object_to_double(object::ptr const& obj)
{
if(obj->type_id() != OBJECT_ID_FLOAT)
{
BOOST_THROW_EXCEPTION(error::bad_cast_error()
<< error::first_operand(obj)
<< error::cast_target_name("float"));
}
mpf_t& mpf = static_cast<float_object const*>(obj.get())->value().mpf();
double result = mpf_get_d(mpf);
if(std::numeric_limits<double>::has_infinity &&
result == std::numeric_limits<double>::infinity())
{
BOOST_THROW_EXCEPTION(error::float_conversion_overflow_error()
<< error::first_operand(obj)
<< error::float_conversion_target_type("double"));
}
return result;
}
示例10: work
bool IsoSurface::work(vistle::Object::const_ptr grid,
vistle::Vec<vistle::Scalar>::const_ptr dataS,
vistle::DataBase::const_ptr mapdata) {
const int processorType = getIntParameter("processortype");
#ifdef CUTTINGSURFACE
const Scalar isoValue = 0.0;
#else
const Scalar isoValue = getFloatParameter("isovalue");
#endif
Leveller l(isocontrol, grid, isoValue, processorType);
l.setComputeNormals(m_computeNormals->getValue());
#ifndef CUTTINGSURFACE
l.setIsoData(dataS);
#endif
if(mapdata){
l.addMappedData(mapdata);
};
l.process();
#ifndef CUTTINGSURFACE
auto minmax = dataS->getMinMax();
if (minmax.first[0] < m_min)
m_min = minmax.first[0];
if (minmax.second[0] > m_max)
m_max = minmax.second[0];
#endif
Object::ptr result = l.result();
DataBase::ptr mapresult = l.mapresult();
if (result && !result->isEmpty()) {
#ifndef CUTTINGSURFACE
result->copyAttributes(dataS);
#endif
result->updateInternals();
result->copyAttributes(grid, false);
result->setTransform(grid->getTransform());
if (result->getTimestep() < 0) {
result->setTimestep(grid->getTimestep());
result->setNumTimesteps(grid->getNumTimesteps());
}
if (result->getBlock() < 0) {
result->setBlock(grid->getBlock());
result->setNumBlocks(grid->getNumBlocks());
}
if (mapdata && mapresult) {
mapresult->updateInternals();
mapresult->copyAttributes(mapdata);
mapresult->setGrid(result);
addObject(m_dataOut, mapresult);
}
#ifndef CUTTINGSURFACE
else {
addObject(m_dataOut, result);
}
#endif
}
return true;
}