本文整理汇总了C++中Polyhedron::get_facets方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyhedron::get_facets方法的具体用法?C++ Polyhedron::get_facets怎么用?C++ Polyhedron::get_facets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyhedron
的用法示例。
在下文中一共展示了Polyhedron::get_facets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_vrml
/// Sends this polyhedron to the specified stream using VRML
void Polyhedron::to_vrml(std::ostream& out, const Polyhedron& p, Vector3 diffuse_color, bool wireframe)
{
const unsigned X = 0, Y = 1, Z = 2;
// get the vertices and the facets
const std::vector<Vector3>& vertices = p.get_vertices();
const std::vector<IndexedTri>& facets = p.get_facets();
out << "Shape {" << std::endl;
out << " appearance Appearance { material Material { diffuseColor " << diffuse_color[0] << " " << diffuse_color[1] << " " << diffuse_color[2] << " } }" << std::endl;
out << " geometry ";
if (!wireframe)
out << "IndexedFaceSet {" << std::endl;
else
out << "IndexedLineSet {" << std::endl;
out << " coord Coordinate { point [ ";
for (unsigned i=0; i< vertices.size(); i++)
out << vertices[i][X] << " " << vertices[i][Y] << " " << vertices[i][Z] << ", ";
out << " ] }" << std::endl;
out << " coordIndex [ ";
if (!wireframe)
for (unsigned i=0; i< facets.size(); i++)
out << facets[i].a << " " << facets[i].b << " " << facets[i].c << " -1, ";
else
for (unsigned i=0; i< facets.size(); i++)
out << facets[i].a << " " << facets[i].b << " " << facets[i].c << " " << facets[i].a << " -1, ";
out << " ] } }" << std::endl;
}
示例2:
static void write_poly2(const Polyhedron& p, std::ostream& out)
{
const unsigned X = 0, Y = 1, Z = 2;
const vector<Vector3>& v = p.get_mesh().get_vertices();
for (unsigned i=0; i< v.size(); i++)
{
out << "Transform {" << std::endl;
out << " translation " << v[i][0] << " " << v[i][1] << " " << v[i][2] << std::endl;
out << " scale 0.1 0.1 0.1" << std::endl;
out << " children Shape { " << std::endl;
out << " geometry Text { " << std::endl;
out << " string \"" << i << "\"" << std::endl;
out << " } } }" << std::endl;
}
// get the vertices and the facets
const std::vector<Vector3>& vertices = p.get_vertices();
const std::vector<IndexedTri>& facets = p.get_facets();
// first write the consistent edges
out << "Shape {" << std::endl;
out << " appearance Appearance { material Material { diffuseColor 1 1 1 } }" << std::endl;
out << " geometry ";
out << "IndexedLineSet {" << std::endl;
out << " coord Coordinate { point [ ";
for (unsigned i=0; i< vertices.size(); i++)
out << vertices[i][X] << " " << vertices[i][Y] << " " << vertices[i][Z] << ", ";
out << " ] }" << std::endl;
out << " coordIndex [ ";
for (unsigned i=0; i< facets.size(); i++)
{
if (consistent(facets, facets[i].a, facets[i].b))
out << facets[i].a << " " << facets[i].b << " -1, ";
if (consistent(facets, facets[i].b, facets[i].c))
out << facets[i].b << " " << facets[i].c << " -1, ";
if (consistent(facets, facets[i].a, facets[i].c))
out << facets[i].a << " " << facets[i].c << " -1, ";
}
out << " ] } }" << std::endl;
// now write the inconsistent edges
std::set<pair<unsigned, unsigned> > marked;
out << "Shape {" << std::endl;
out << " appearance Appearance { material Material { diffuseColor 1 0 0 } }" << std::endl;
out << " geometry ";
out << "IndexedLineSet {" << std::endl;
out << " coord Coordinate { point [ ";
for (unsigned i=0; i< vertices.size(); i++)
out << vertices[i][X] << " " << vertices[i][Y] << " " << vertices[i][Z] << ", ";
out << " ] }" << std::endl;
out << " coordIndex [ ";
for (unsigned i=0; i< facets.size(); i++)
{
if (marked.find(make_pair(facets[i].a, facets[i].b)) == marked.end() &&
!consistent(facets, facets[i].a, facets[i].b))
{
out << facets[i].a << " " << facets[i].b << " -1, ";
marked.insert(make_pair(facets[i].a, facets[i].b));
std::cout << "edge: " << facets[i].a << " " << facets[i].b << std::endl;
}
if (marked.find(make_pair(facets[i].b, facets[i].c)) == marked.end() &&
!consistent(facets, facets[i].b, facets[i].c))
{
out << facets[i].b << " " << facets[i].c << " -1, ";
marked.insert(make_pair(facets[i].b, facets[i].c));
std::cout << "edge: " << facets[i].b << " " << facets[i].c << std::endl;
}
if (marked.find(make_pair(facets[i].a, facets[i].c)) == marked.end() &&
!consistent(facets, facets[i].a, facets[i].c))
{
out << facets[i].a << " " << facets[i].c << " -1, ";
marked.insert(make_pair(facets[i].a, facets[i].c));
std::cout << "edge: " << facets[i].a << " " << facets[i].c << std::endl;
}
}
out << " ] } }" << std::endl;
}