本文整理汇总了C++中SMESHDS_Mesh::AddEdgeWithID方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::AddEdgeWithID方法的具体用法?C++ SMESHDS_Mesh::AddEdgeWithID怎么用?C++ SMESHDS_Mesh::AddEdgeWithID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::AddEdgeWithID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddEdge
SMDS_MeshEdge* SMESH_MesherHelper::AddEdge(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const int id,
const bool force3d)
{
SMESHDS_Mesh * meshDS = GetMeshDS();
SMDS_MeshEdge* edge = 0;
if (myCreateQuadratic) {
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
if(id)
edge = meshDS->AddEdgeWithID(n1, n2, n12, id);
else
edge = meshDS->AddEdge(n1, n2, n12);
}
else {
if(id)
edge = meshDS->AddEdgeWithID(n1, n2, id);
else
edge = meshDS->AddEdge(n1, n2);
}
if ( mySetElemOnShape && myShapeID > 0 )
meshDS->SetMeshElementOnShape( edge, myShapeID );
return edge;
}
示例2: addEdge
PyObject* FemMeshPy::addEdge(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2;
if (PyArg_ParseTuple(args, "ii",&n1,&n2)) {
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
if (!node1 || !node2)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshEdge* edge = meshDS->AddEdge(node1, node2);
if (!edge)
throw std::runtime_error("Failed to add edge");
return Py::new_reference_to(Py::Long(edge->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
return 0;
}
}
PyErr_Clear();
PyObject *obj;
int ElementId=-1;
if (PyArg_ParseTuple(args, "O!|i", &PyList_Type, &obj, &ElementId))
{
Py::List list(obj);
std::vector<const SMDS_MeshNode*> Nodes;
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
#if PY_MAJOR_VERSION >= 3
Py::Long NoNr(*it);
#else
Py::Int NoNr(*it);
#endif
const SMDS_MeshNode* node = meshDS->FindNode(NoNr);
if (!node)
throw std::runtime_error("Failed to get node of the given indices");
Nodes.push_back(node);
}
SMDS_MeshEdge* edge=0;
if(ElementId != -1) {
switch(Nodes.size()){
case 2:
edge = meshDS->AddEdgeWithID(Nodes[0],Nodes[1],ElementId);
if (!edge)
throw std::runtime_error("Failed to add edge with given ElementId");
break;
case 3:
edge = meshDS->AddEdgeWithID(Nodes[0],Nodes[1],Nodes[2],ElementId);
if (!edge)
throw std::runtime_error("Failed to add edge with given ElementId");
break;
default:
throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type
}
}
else {
switch(Nodes.size()){
case 2:
edge = meshDS->AddEdge(Nodes[0],Nodes[1]);
if (!edge)
throw std::runtime_error("Failed to add edge");
break;
case 3:
edge = meshDS->AddEdge(Nodes[0],Nodes[1],Nodes[2]);
if (!edge)
throw std::runtime_error("Failed to add edge");
break;
default:
throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type
}
}
#if PY_MAJOR_VERSION >= 3
return Py::new_reference_to(Py::Long(edge->GetID()));
#else
return Py::new_reference_to(Py::Int(edge->GetID()));
#endif
}
PyErr_SetString(PyExc_TypeError, "addEdge accepts:\n"
"-- int,int\n"
"-- [2|3],[int]\n");
return 0;
}