本文整理汇总了C++中Coordinate::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::begin方法的具体用法?C++ Coordinate::begin怎么用?C++ Coordinate::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinate
的用法示例。
在下文中一共展示了Coordinate::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//when we call this, we must be sure the object is 2d
PtrLineList Draw2DQuads(){
Coordinate::iterator Di = Dimensions.begin();
Coordinate::iterator Li = Location.begin();
glVertex3f(Li[0],Li[1],Li[2]);
}
示例2: at
Coordinate
Dimensions::getCoordinate(const size_t index) const
{
Coordinate coordinate;
size_t x = index;
size_t product = 1;
for(size_type i = 0; i < size(); i++)
{
product *= at(i);
}
for(size_type i = size()-1; i != (size_type)-1; i--)
{
product/=at(i);
coordinate.insert(coordinate.begin(), x/product);
x%=product;
}
return coordinate;
}
示例3: GetShape
//This will return a list of polygons that can be used to explicitly
//outline the bounding structure. This is being created for collision
//debugging, and may not be appropriate for rendering complex arbitrary
//hulls due to many redundant shared verticies.
PtrLineList GetShape(){
//Create a wireframe for our AABB
//Store the wires we've found
PtrLineList result(new LineList);
//We are finished when we run out of verticies to consider
set<Coordinate> WorkingVerticies;
set<Coordinate> WorkingVerticiesSwapBuffer;
//add our first vertex as a seed
WorkingVerticies.insert(Location);
Coordinate CurrentV;
Coordinate::iterator CVi;
Coordinate PreviousV;
//to iterate over our location and dimensions
Coordinate::iterator Li;
Coordinate::iterator Di;
Line L;
//When both vertex buffers are empty, we exit
while(WorkingVerticies.size() > 0){
//When one vertex buffer is empty, we swap the new one in its place
while(WorkingVerticies.size() > 0){
//(re)set our iterators
Di = Dimensions.begin();
Li = Location.begin();
//begin processing the first vertex.
CurrentV = PreviousV = *WorkingVerticies.begin();
CVi = CurrentV.begin();
//Go through our location dimension by dimension.
while(CVi!=CurrentV.end()){
//if this dimension has not been incremented to its extreme
if(*CVi == *Li){
//increment it to it's extreme
*CVi = (*Li) + (*Di);
//verticies in the swap buffer will be processed
//in the next iterative pass.
WorkingVerticiesSwapBuffer.insert(CurrentV);
//Add our new line segment
L.first = PreviousV;
L.second = CurrentV;
result->push_back(L);
if(debug){
Coordinate::iterator Ci = PreviousV.begin();
while(Ci != PreviousV.end()){
++Ci;
}
Ci = CurrentV.begin();
while(Ci != CurrentV.end()){
++Ci;
}
}
//Undo our increment and move on
*CVi = *Li;
}
++CVi;
++Li;
++Di;
}
//We are done processing this vertex. Remove it.
WorkingVerticies.erase(WorkingVerticies.begin());
}
//Dump swap buffer into WorkingVerticies. if swap.size()>0, we iterate.
WorkingVerticies = WorkingVerticiesSwapBuffer;
WorkingVerticiesSwapBuffer.clear();
}
return result;
}
示例4: load
bool MapBuilder::load(const string& filename)
{
const string strLocation = "location";
const string strBoundary = "boundary";
const string strWind = "wind";
const string strBuilding = "building";
const string strUnit = "unit";
const string strPotential = "potential";
const string strOrigin = "origin";
const string strIndex = "index";
const string strCoord = "coordinate";
using boost::property_tree::ptree;
using boost::lexical_cast;
ptree pt;
read_json(filename, pt);
unit_ = pt.get<unit_t>(strUnit);
auto potentialNode = pt.get_optional<coord_item_t>(strPotential);
if (potentialNode)
{
setLocalPotential(*potentialNode);
}
auto node_boundary = pt.get_child(strBoundary);
transform(node_boundary.begin(), node_boundary.end(), boundary_.begin(), [](ptree::value_type& v)
{
return lexical_cast<coord_item_t>(v.second.data());
});
auto node_location = pt.get_child_optional(strLocation);
if (node_location)
{
setStartIndex(Coordinate());
transform(node_location->begin(), node_location->end(), (*startIndex_).begin(), [](ptree::value_type& v)
{
return lexical_cast<coord_item_t>(v.second.data());
});
}
auto node_wind = pt.get_child_optional(strWind);
if (node_wind)
{
setWind(WindVector());
transform(node_wind->begin(), node_wind->end(), wind_->begin(), [](ptree::value_type& v)
{
return lexical_cast<wv_item_t>(v.second.data());
});
}
auto node_origin = pt.get_child_optional(strOrigin);
if (node_origin)
{
auto node_index = node_origin->get_child(strIndex);
Coordinate index;
transform(node_index.begin(), node_index.end(), index.begin(), [](ptree::value_type& v)
{
return lexical_cast<coord_item_t>(v.second.data());
});
auto node_coord = node_origin->get_child(strCoord);
WindVector coord;
transform(node_coord.begin(), node_coord.end(), coord.begin(), [](ptree::value_type& v)
{
return lexical_cast<wv_item_t>(v.second.data());
});
setOrigin(make_pair(index, coord));
}
auto node_buildings = pt.get_child_optional(strBuilding);
if (node_buildings)
{
for (auto node_building : *node_buildings)
{
auto node_bld_tree = node_building.second;
stBuilding building;
auto node_location = node_bld_tree.get_child(strLocation);
transform(node_location.begin(), node_location.end(), building.location_.begin(), [](ptree::value_type& v)
{
return lexical_cast<coord_item_t>(v.second.data());
});
auto node_boudnary = node_bld_tree.get_child(strBoundary);
transform(node_boudnary.begin(), node_boudnary.end(), building.boundary_.begin(), [](ptree::value_type& v)
{
return lexical_cast<coord_item_t>(v.second.data());
});
buildings_.push_back(building);
}
}
return true;
}