本文整理汇总了C++中Mesh::BeginEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::BeginEdge方法的具体用法?C++ Mesh::BeginEdge怎么用?C++ Mesh::BeginEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::BeginEdge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
double nx = 2.0/7.0, ny = 6.0/7.0, nz = 3.0/7.0;
double px = 0.5, py = 0.5, pz = 0.5;
if( argc < 2 )
{
std::cout << "Usage: " << argv[0] << " mesh [mesh_out=grid.pmf] [nx=0] [ny=0] [nz=1] [px=0.5] [py=0.5] [pz=0.5]" << std::endl;
return -1;
}
std::string grid_out = "grid.pmf";
if( argc > 2 ) grid_out = std::string(argv[2]);
if( argc > 3 ) nx = atof(argv[3]);
if( argc > 4 ) ny = atof(argv[4]);
if( argc > 5 ) nz = atof(argv[5]);
if( argc > 6 ) px = atof(argv[6]);
if( argc > 7 ) py = atof(argv[7]);
if( argc > 8 ) pz = atof(argv[8]);
double d = nx*px+ny*py+nz*pz;
Mesh m;
m.Load(argv[1]);
m.SetTopologyCheck(NEED_TEST_CLOSURE|PROHIBIT_MULTILINE|PROHIBIT_MULTIPOLYGON|GRID_CONFORMITY|DEGENERATE_EDGE|DEGENERATE_FACE|DEGENERATE_CELL | FACE_EDGES_ORDER);
//m.RemTopologyCheck(THROW_EXCEPTION);
Tag sliced = m.CreateTag("SLICED",DATA_BULK,FACE|EDGE|NODE,FACE|EDGE|NODE,1);
std::cout << "Cells: " << m.NumberOfCells() << std::endl;
std::cout << "Faces: " << m.NumberOfFaces() << std::endl;
MarkerType slice = m.CreateMarker();
int nslice = 0, nmark = 0;
for(Mesh::iteratorEdge it = m.BeginEdge(); it != m.EndEdge(); ++it)
{
double p[3];
Storage::real_array c0 = it->getBeg()->Coords();
Storage::real_array c1 = it->getEnd()->Coords();
double r0 = c0[0]*nx+c0[1]*ny+c0[2]*nz - d;
double r1 = c1[0]*nx+c1[1]*ny+c1[2]*nz - d;
//std::cout << "r0 " << r0 << " r1 " << r1 << std::endl;
if( r0*r1 < -1.0e-12 )
{
p[0] = (r0*c1[0] - r1*c0[0])/(r0-r1);
p[1] = (r0*c1[1] - r1*c0[1])/(r0-r1);
p[2] = (r0*c1[2] - r1*c0[2])/(r0-r1);
//std::cout << "p " << p[0] << " " << p[1] << " " << p[2] << std::endl;
Node n = m.CreateNode(p);
n.Bulk(sliced) = 1;
n.SetMarker(slice);
bool was_sliced = it->HaveData(sliced) ? true : false;
ElementArray<Edge> ret = Edge::SplitEdge(it->self(),ElementArray<Node>(&m,1,n.GetHandle()),0);
if( was_sliced ) for(int q = 0; q < ret.size(); ++q) ret[q]->Bulk(sliced) = 1;
nslice++;
}
else
{
if( fabs(r0) < 1.0e-6 )
{
it->getBeg()->SetMarker(slice);
nmark++;
}
if( fabs(r1) < 1.0e-6 )
{
it->getEnd()->SetMarker(slice);
nmark++;
}
}
}
std::cout << "sliced edges: " << nslice << " marked nodes: " << nmark << std::endl;
if( !Element::CheckConnectivity(&m) )
std::cout << "Connectivity is broken" << std::endl;
nslice = 0;
for(Mesh::iteratorFace it = m.BeginFace(); it != m.EndFace(); ++it)
{
ElementArray<Node> nodes = it->getNodes(slice); //those nodes should be ordered so that each pair forms an edge
if( nodes.size() > 1 ) // if there is 1, then only one vertex touches the plane
{
//if there is more then two, then original face is non-convex
if( nodes.size() > 2 ) std::cout << "Looks like face " << it->LocalID() << " is nonconvex" << std::endl;
else
{
Edge e = m.CreateEdge(nodes).first;
e.Bulk(sliced) = 1;
e.SetMarker(slice);
bool was_sliced = it->HaveData(sliced) ? true : false;
ElementArray<Face> ret = Face::SplitFace(it->self(),ElementArray<Edge>(&m,1,e.GetHandle()),0);
if( was_sliced ) for(int q = 0; q < ret.size(); ++q) ret[q]->Bulk(sliced) = 1;
nslice++;
}
}
//else std::cout << "Only one adjacent slice node, face " << it->LocalID() << std::endl;
}
nmark = 0;
for(Mesh::iteratorEdge it = m.BeginEdge(); it != m.EndEdge(); ++it)
//.........这里部分代码省略.........