本文整理汇总了C++中geolib::GEOObjects::addSurfaceVec方法的典型用法代码示例。如果您正苦于以下问题:C++ GEOObjects::addSurfaceVec方法的具体用法?C++ GEOObjects::addSurfaceVec怎么用?C++ GEOObjects::addSurfaceVec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geolib::GEOObjects
的用法示例。
在下文中一共展示了GEOObjects::addSurfaceVec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertMeshToGeo
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double eps)
{
if (mesh.getDimension() != 2)
{
ERR ("Mesh to geometry conversion is only working for 2D meshes.");
return false;
}
// nodes to points conversion
std::string mesh_name(mesh.getName());
{
auto points = std::make_unique<std::vector<GeoLib::Point*>>();
points->reserve(mesh.getNumberOfNodes());
for (auto node_ptr : mesh.getNodes())
points->push_back(new GeoLib::Point(*node_ptr, node_ptr->getID()));
geo_objects.addPointVec(std::move(points), mesh_name, nullptr, eps);
}
const std::vector<std::size_t> id_map (geo_objects.getPointVecObj(mesh_name)->getIDMap());
// elements to surface triangles conversion
std::string const mat_name ("MaterialIDs");
auto bounds (MeshInformation::getValueBounds<int>(mesh, mat_name));
const unsigned nMatGroups(bounds.second-bounds.first+1);
auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>();
sfcs->reserve(nMatGroups);
auto const& points = *geo_objects.getPointVec(mesh_name);
for (unsigned i=0; i<nMatGroups; ++i)
sfcs->push_back(new GeoLib::Surface(points));
const std::vector<MeshLib::Element*> &elements = mesh.getElements();
const std::size_t nElems (mesh.getNumberOfElements());
MeshLib::PropertyVector<int> const*const materialIds =
mesh.getProperties().existsPropertyVector<int>("MaterialIDs")
? mesh.getProperties().getPropertyVector<int>("MaterialIDs")
: nullptr;
for (unsigned i=0; i<nElems; ++i)
{
auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
MeshLib::Element* e (elements[i]);
if (e->getGeomType() == MeshElemType::TRIANGLE)
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
if (e->getGeomType() == MeshElemType::QUAD)
{
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(2)], id_map[e->getNodeIndex(3)]);
}
// all other element types are ignored (i.e. lines)
}
std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc){ if (sfc->getNumberOfTriangles()==0) delete sfc; sfc = nullptr;});
auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(), nullptr);
sfcs->erase(sfcs_end, sfcs->end());
geo_objects.addSurfaceVec(std::move(sfcs), mesh_name);
return true;
}
示例2: createSurfaces
void createSurfaces()
{
auto const points = geo_objects.getPointVec(geo_name);
const std::vector<std::size_t> pnt_id_map(
geo_objects.getPointVecObj(geo_name)->getIDMap());
auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>(
new std::vector<GeoLib::Surface*>(2));
std::map<std::string, std::size_t>* sfc_names =
new std::map<std::string, std::size_t>;
(*sfcs)[0] = new GeoLib::Surface(*points);
(*sfcs)[0]->addTriangle(pnt_id_map[0], pnt_id_map[3], pnt_id_map[1]);
(*sfcs)[0]->addTriangle(pnt_id_map[1], pnt_id_map[3], pnt_id_map[4]);
(*sfcs)[0]->addTriangle(pnt_id_map[1], pnt_id_map[4], pnt_id_map[2]);
(*sfcs)[0]->addTriangle(pnt_id_map[2], pnt_id_map[4], pnt_id_map[5]);
(*sfc_names)["FirstSurface"] = 0;
(*sfcs)[1] = new GeoLib::Surface(*points);
(*sfcs)[1]->addTriangle(pnt_id_map[3], pnt_id_map[6], pnt_id_map[8]);
(*sfcs)[1]->addTriangle(pnt_id_map[3], pnt_id_map[8], pnt_id_map[5]);
(*sfc_names)["SecondSurface"] = 1;
geo_objects.addSurfaceVec(std::move(sfcs), geo_name, sfc_names);
}