本文整理汇总了C++中SMESHDS_Mesh::AddVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::AddVolume方法的具体用法?C++ SMESHDS_Mesh::AddVolume怎么用?C++ SMESHDS_Mesh::AddVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::AddVolume方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddVolume
SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4,
const int id,
const bool force3d)
{
SMESHDS_Mesh * meshDS = GetMeshDS();
SMDS_MeshVolume* elem = 0;
if(!myCreateQuadratic) {
if(id)
elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, id);
else
elem = meshDS->AddVolume(n1, n2, n3, n4);
}
else {
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d);
const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d);
const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,force3d);
const SMDS_MeshNode* n24 = GetMediumNode(n2,n4,force3d);
const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d);
if(id)
elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34, id);
else
elem = meshDS->AddVolume(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34);
}
if ( mySetElemOnShape && myShapeID > 0 )
meshDS->SetMeshElementOnShape( elem, myShapeID );
return elem;
}
示例2: addVolume
PyObject* FemMeshPy::addVolume(PyObject *args)
{
int n1,n2,n3,n4;
if (!PyArg_ParseTuple(args, "iiii",&n1,&n2,&n3,&n4))
return 0;
try {
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
const SMDS_MeshNode* node3 = meshDS->FindNode(n3);
const SMDS_MeshNode* node4 = meshDS->FindNode(n4);
if (!node1 || !node2 || !node3 || !node4)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshVolume* vol = meshDS->AddVolume(node1, node2, node3, node4);
if (!vol)
throw std::runtime_error("Failed to add volume");
return Py::new_reference_to(Py::Int(vol->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
return 0;
}
}
示例3: Compute
//.........这里部分代码省略.........
face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[5],nodes[3],nodes[4]);
break;
case netgen::QUAD8:
face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3],
nodes[4],nodes[7],nodes[5],nodes[6]);
break;
default:
MESSAGE("NETGEN created a face of unexpected type, ignoring");
continue;
}
if (!face)
{
if ( !comment.size() ) comment << "Cannot create a mesh face";
MESSAGE("Cannot create a mesh face");
nbSeg = nbFac = nbVol = isOK = 0;
break;
}
if (!aFace.IsNull())
meshDS->SetMeshElementOnShape(face, aFace);
}
// create tetrahedra
for (i = 1; i <= nbVol/* && isOK*/; ++i)
{
const netgen::Element& elem = ngMesh->VolumeElement(i);
int aSolidInd = elem.GetIndex();
TopoDS_Solid aSolid;
if (aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent())
aSolid = TopoDS::Solid(occgeo.somap(aSolidInd));
vector<SMDS_MeshNode*> nodes;
for (int j=1; j <= elem.GetNP(); ++j)
{
int pind = elem.PNum(j);
SMDS_MeshNode* node = nodeVec.at(pind);
nodes.push_back(node);
if (pind <= nbInitNod || pindMap.Contains(pind))
continue;
if (!aSolid.IsNull())
{
// point in solid
meshDS->SetNodeInVolume(node, aSolid);
pindMap.Add(pind);
}
}
SMDS_MeshVolume* vol = NULL;
switch (elem.GetType())
{
case netgen::TET:
vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3]);
break;
case netgen::TET10:
vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3],
nodes[4],nodes[7],nodes[5],nodes[6],nodes[8],nodes[9]);
break;
default:
MESSAGE("NETGEN created a volume of unexpected type, ignoring");
continue;
}
if (!vol)
{
if ( !comment.size() ) comment << "Cannot create a mesh volume";
MESSAGE("Cannot create a mesh volume");
nbSeg = nbFac = nbVol = isOK = 0;
break;
}
if (!aSolid.IsNull())
meshDS->SetMeshElementOnShape(vol, aSolid);
}
}
if ( error->IsOK() && ( !isOK || comment.size() > 0 ))
error->myName = COMPERR_ALGO_FAILED;
if ( !comment.empty() )
error->myComment = comment;
// set bad compute error to subshapes of all failed subshapes shapes
if ( !error->IsOK() && err )
{
for (int i = 1; i <= occgeo.fmap.Extent(); i++) {
int status = occgeo.facemeshstatus[i-1];
if (status == 1 ) continue;
if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( occgeo.fmap( i ))) {
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
if ( !smError || smError->IsOK() ) {
if ( status == -1 )
smError.reset( new SMESH_ComputeError( error->myName, error->myComment ));
else
smError.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED, "Ignored" ));
}
}
}
}
nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
nglib::Ng_Exit();
RemoveTmpFiles();
return error->IsOK();
}
示例4: addVolume
PyObject* FemMeshPy::addVolume(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2,n3,n4;
if (PyArg_ParseTuple(args, "iiii",&n1,&n2,&n3,&n4))
{
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
const SMDS_MeshNode* node3 = meshDS->FindNode(n3);
const SMDS_MeshNode* node4 = meshDS->FindNode(n4);
if (!node1 || !node2 || !node3 || !node4)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshVolume* vol = meshDS->AddVolume(node1, node2, node3, node4);
if (!vol)
throw std::runtime_error("Failed to add volume");
return Py::new_reference_to(Py::Long(vol->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_MeshVolume* vol=0;
if(ElementId != -1) {
switch(Nodes.size()){
case 4:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Tet4 volume with given ElementId");
break;
case 5:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Pyra5 volume with given ElementId");
break;
case 6:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Penta6 volume with given ElementId");
break;
case 8:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Hexa8 volume with given ElementId");
break;
case 10:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Tet10 volume with given ElementId");
break;
case 13:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9],Nodes[10],Nodes[11],Nodes[12],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Pyra13 volume with given ElementId");
break;
case 15:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9],Nodes[10],Nodes[11],Nodes[12],Nodes[13],Nodes[14],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Penta15 volume with given ElementId");
break;
case 20:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9],Nodes[10],Nodes[11],Nodes[12],Nodes[13],Nodes[14],Nodes[15],Nodes[16],Nodes[17],Nodes[18],Nodes[19],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Hexa20 volume with given ElementId");
break;
default: throw std::runtime_error("Unknown node count, [4|5|6|8|10|13|15|20] are allowed"); //unknown volume type
}
}else{
switch(Nodes.size()){
case 4:
vol = meshDS->AddVolume(Nodes[0],Nodes[1],Nodes[2],Nodes[3]);
if (!vol)
throw std::runtime_error("Failed to add Tet4 volume");
break;
case 5:
vol = meshDS->AddVolume(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4]);
if (!vol)
//.........这里部分代码省略.........
示例5: addVolume
PyObject* FemMeshPy::addVolume(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2,n3,n4;
if (PyArg_ParseTuple(args, "iiii",&n1,&n2,&n3,&n4))
{
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
const SMDS_MeshNode* node3 = meshDS->FindNode(n3);
const SMDS_MeshNode* node4 = meshDS->FindNode(n4);
if (!node1 || !node2 || !node3 || !node4)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshVolume* vol = meshDS->AddVolume(node1, node2, node3, node4);
if (!vol)
throw std::runtime_error("Failed to add volume");
return Py::new_reference_to(Py::Int(vol->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) {
Py::Int NoNr(*it);
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_MeshVolume* vol=0;
if(ElementId != -1) {
switch(Nodes.size()){
case 4:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Tet4 volume");
break;
case 8:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Tet10 volume");
break;
case 10:
vol = meshDS->AddVolumeWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9],ElementId);
if (!vol)
throw std::runtime_error("Failed to add Tet10 volume");
break;
default: throw std::runtime_error("Unknown node count, [4|5|6|8|10|13|18] are allowed"); //unknown face type
}
}else{
switch(Nodes.size()){
case 4:
vol = meshDS->AddVolume(Nodes[0],Nodes[1],Nodes[2],Nodes[3]);
if (!vol)
throw std::runtime_error("Failed to add Tet4 volume");
break;
case 8:
vol = meshDS->AddVolume(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7]);
if (!vol)
throw std::runtime_error("Failed to add Tet10 volume");
break;
case 10:
vol = meshDS->AddVolume(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],Nodes[8],Nodes[9]);
if (!vol)
throw std::runtime_error("Failed to add Tet10 volume");
break;
default: throw std::runtime_error("Unknown node count, [4|5|6|8|10|13|18] are allowed"); //unknown face type
}
}
return Py::new_reference_to(Py::Int(vol->GetID()));
}
PyErr_SetString(PyExc_TypeError, "Line constructor accepts:\n"
"-- empty parameter list\n"
"-- Line\n"
"-- Point, Point");
return 0;
}