本文整理汇总了C++中GeometryType::size方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryType::size方法的具体用法?C++ GeometryType::size怎么用?C++ GeometryType::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryType
的用法示例。
在下文中一共展示了GeometryType::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_polygon_wkb
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
using point_type = std::pair<double,double>;
using linear_ring = std::vector<point_type>;
boost::ptr_vector<linear_ring> rings;
double x = 0;
double y = 0;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
rings.back().push_back(std::make_pair(x,y));
size += 4; // num_points
size += 2 * 8; // point
}
else if (command == SEG_LINETO)
{
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
for ( linear_ring const& ring : rings)
{
unsigned num_ring_points = ring.size();
write(ss,num_ring_points,4,byte_order);
for ( point_type const& pt : ring)
{
write(ss,pt.first,8,byte_order);
write(ss,pt.second,8,byte_order);
}
}
assert(ss.good());
return std::move(wkb);
}
示例2: to_point_wkb
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::Point);
write(ss,type,4,byte_order);
double x = 0;
double y = 0;
g.vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return std::move(wkb);
}
示例3: to_polygon_wkb
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
typedef std::pair<double,double> point_type;
typedef std::vector<point_type> linear_ring;
boost::ptr_vector<linear_ring> rings;
double x = 0;
double y = 0;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
rings.back().push_back(std::make_pair(x,y));
size += 4; // num_points
size += 2 * 8; // point
}
else if (command == SEG_LINETO)
{
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
BOOST_FOREACH ( linear_ring const& ring, rings)
{
unsigned num_ring_points = ring.size();
write(ss,num_ring_points,4,byte_order);
BOOST_FOREACH ( point_type const& pt, ring)
{
write(ss,pt.first,8,byte_order);
write(ss,pt.second,8,byte_order);
}
示例4: to_point_wkb
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
write(ss,type,4,byte_order);
double x = 0;
double y = 0;
g.vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return wkb;
}
示例5: to_line_string_wkb
wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.size();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::geometry_type::types::LineString);
write(ss,type,4,byte_order);
write(ss,num_points,4,byte_order);
double x = 0;
double y = 0;
for (unsigned i=0; i< num_points; ++i)
{
g.vertex(i,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
}
assert(ss.good());
return std::move(wkb);
}
示例6: Cel
void IsotropicRankineDamage2D::CalculateMaterialResponse(const Vector& StrainVector,
const Matrix& DeformationGradient,
Vector& StressVector,
Matrix& AlgorithmicTangent,
const ProcessInfo& CurrentProcessInfo,
const Properties& props,
const GeometryType& geom,
const Vector& ShapeFunctionsValues,
bool CalculateStresses,
int CalculateTangent,
bool SaveInternalVariables)
{
//get material parameters
const double E = props[YOUNG_MODULUS];
const double NU = props[POISSON_RATIO];
const double Gf = props[FRACTURE_ENERGY]; //***************************
const double sigma0 = props[YIELD_STRESS]; //***************************
const double r0 = sigma0; //***************************
const double retat = props[VISCOSITY];
//compute elastic stress
Matrix Cel(3,3);
Vector stress(3);
CalculateElasticMatrix(Cel, E, NU);
noalias(stress) = prod(Cel,StrainVector);
//compute stress max eigenvalue
const double sigma_m = 0.5*(stress[0]+ stress[1]);
const double R = sqrt(stress[2]*stress[2] + 0.25*(stress[0]-stress[1])*(stress[0]-stress[1]) );
double smax = sigma_m + R;
//compute tau
double tau = smax;
if(tau < 0) tau=0.0;
//compute actualized damage indicator
double r = mrold;
if(tau > r)
{
if(retat == 0) r=tau;
else
{
double dt = CurrentProcessInfo[DELTA_TIME];
double ratio = dt/retat;
r = std::max( r , (mrold + ratio*tau)/(1.0+ratio) );
}
}
//compute element lenght
double he=0.0;
for(unsigned int i=0; i<geom.size(); i++)
{
const double hn = geom[i].GetSolutionStepValue(NODAL_H);
he += hn*ShapeFunctionsValues[i];
}
// double A = geom.Area();
// const double he = sqrt(2.0*A);
const double lch=2.0*he;
const double ls =2.0*E*Gf/(sigma0*sigma0);
double Hs = lch/(ls -lch);
if(Hs < 0.0) Hs=1.0e10;
// KRATOS_WATCH(Hs);
double d=0.0;
if(r>=r0)
d = 1.0 - r0/r*exp(-2.0*Hs*(r-r0)/r0);
if(d > 0.9999)
d = 0.9999;
// KRATOS_WATCH(d);
//write outputs as needed
if(CalculateStresses == true)
noalias(StressVector) = (1.0-d)*stress;
if(CalculateTangent == 1)
noalias(AlgorithmicTangent) = (1.0-d)*Cel;
//keep trace of internal variables if allowed, otherwise reset them
if(SaveInternalVariables == false)
mr = mrold;
else
{
mr = r;
//save variable for output
md=d;
}
// KRATOS_WATCH(md);
//std::cout << this << " inside calculate md " << md << std::endl;
}