本文整理汇总了C++中SMESHDS_Mesh::AddFace方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::AddFace方法的具体用法?C++ SMESHDS_Mesh::AddFace怎么用?C++ SMESHDS_Mesh::AddFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::AddFace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddFace
SMDS_MeshFace* SMESH_MesherHelper::AddFace(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_MeshFace* elem = 0;
if(!myCreateQuadratic) {
if(id)
elem = meshDS->AddFaceWithID(n1, n2, n3, n4, id);
else
elem = meshDS->AddFace(n1, n2, n3, n4);
}
else {
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d);
const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d);
const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d);
if(id)
elem = meshDS->AddFaceWithID(n1, n2, n3, n4, n12, n23, n34, n41, id);
else
elem = meshDS->AddFace(n1, n2, n3, n4, n12, n23, n34, n41);
}
if ( mySetElemOnShape && myShapeID > 0 )
meshDS->SetMeshElementOnShape( elem, myShapeID );
return elem;
}
示例2: addQuad
PyObject* FemMeshPy::addQuad(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_MeshFace* face = meshDS->AddFace(node1, node2, node3, node4);
if (!face)
throw std::runtime_error("Failed to add quad");
return Py::new_reference_to(Py::Int(face->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
return 0;
}
}
示例3: Compute
//.........这里部分代码省略.........
if ( ngMesh->GetNSeg() ) {
// we have to multiply length by 2 since for each TopoDS_Edge there
// are double set of NETGEN edges or, in other words, we have to
// divide ngMesh->GetNSeg() on 2.
mparams.maxh = 2*length / ngMesh->GetNSeg();
}
else
mparams.maxh = 1000;
mparams.grading = 0.2; // slow size growth
}
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
ngMesh->SetGlobalH (mparams.maxh);
netgen::Box<3> bb = occgeo.GetBoundingBox();
bb.Increase (bb.Diam()/20);
ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparams.grading);
}
// let netgen compute 2D mesh
startWith = netgen::MESHCONST_MESHSURFACE;
endWith = _optimize ? netgen::MESHCONST_OPTSURFACE : netgen::MESHCONST_MESHSURFACE;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
if (err) comment << "Error in netgen::OCCGenerateMesh() at surface mesh generation";
}
// ---------------------
// generate volume mesh
// ---------------------
if (!err && _isVolume)
{
// add ng face descriptors of meshed faces
std::map< int, std::pair<int,int> >::iterator fId_soIds = _faceDescriptors.begin();
for ( ; fId_soIds != _faceDescriptors.end(); ++fId_soIds ) {
int faceID = fId_soIds->first;
int solidID1 = fId_soIds->second.first;
int solidID2 = fId_soIds->second.second;
ngMesh->AddFaceDescriptor (netgen::FaceDescriptor(faceID, solidID1, solidID2, 0));
}
// pass 3D simple parameters to NETGEN
const NETGENPlugin_SimpleHypothesis_3D* simple3d =
dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D* > ( _simpleHyp );
if ( simple3d ) {
if ( double vol = simple3d->GetMaxElementVolume() ) {
// max volume
mparams.maxh = pow( 72, 1/6. ) * pow( vol, 1/3. );
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
}
else {
// length from faces
mparams.maxh = ngMesh->AverageH();
}
// netgen::ARRAY<double> maxhdom;
// maxhdom.SetSize (occgeo.NrSolids());
// maxhdom = mparams.maxh;
// ngMesh->SetMaxHDomain (maxhdom);
ngMesh->SetGlobalH (mparams.maxh);
mparams.grading = 0.4;
ngMesh->CalcLocalH();
}
// let netgen compute 3D mesh
startWith = netgen::MESHCONST_MESHVOLUME;
endWith = _optimize ? netgen::MESHCONST_OPTVOLUME : netgen::MESHCONST_MESHVOLUME;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
if (err) comment << "Error in netgen::OCCGenerateMesh()";
}
if (!err && mparams.secondorder > 0)
{
netgen::OCCRefinementSurfaces ref (occgeo);
ref.MakeSecondOrder (*ngMesh);
示例4: addFace
PyObject* FemMeshPy::addFace(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2,n3;
if (PyArg_ParseTuple(args, "iii",&n1,&n2,&n3))
{
// old form, deprecated
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
const SMDS_MeshNode* node3 = meshDS->FindNode(n3);
if (!node1 || !node2 || !node3)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshFace* face = meshDS->AddFace(node1, node2, node3);
if (!face)
throw std::runtime_error("Failed to add face");
return Py::new_reference_to(Py::Long(face->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_MeshFace* face=0;
if(ElementId != -1) {
switch(Nodes.size()){
case 3:
face = meshDS->AddFaceWithID(Nodes[0],Nodes[1],Nodes[2],ElementId);
if (!face)
throw std::runtime_error("Failed to add triangular face with given ElementId");
break;
case 4:
face = meshDS->AddFaceWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],ElementId);
if (!face)
throw std::runtime_error("Failed to add face with given ElementId");
break;
case 6:
face = meshDS->AddFaceWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],ElementId);
if (!face)
throw std::runtime_error("Failed to add face with given ElementId");
break;
case 8:
face = meshDS->AddFaceWithID(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7],ElementId);
if (!face)
throw std::runtime_error("Failed to add face with given ElementId");
break;
default:
throw std::runtime_error("Unknown node count, [3|4|6|8] are allowed"); //unknown face type
}
}else{
switch(Nodes.size()){
case 3:
face = meshDS->AddFace(Nodes[0],Nodes[1],Nodes[2]);
if (!face)
throw std::runtime_error("Failed to add triangular face");
break;
case 4:
face = meshDS->AddFace(Nodes[0],Nodes[1],Nodes[2],Nodes[3]);
if (!face)
throw std::runtime_error("Failed to add face");
break;
case 6:
face = meshDS->AddFace(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5]);
if (!face)
throw std::runtime_error("Failed to add face");
break;
case 8:
face = meshDS->AddFace(Nodes[0],Nodes[1],Nodes[2],Nodes[3],Nodes[4],Nodes[5],Nodes[6],Nodes[7]);
if (!face)
throw std::runtime_error("Failed to add face");
break;
default:
throw std::runtime_error("Unknown node count, [4|5|6|8] are allowed"); //unknown face type
}
}
return Py::new_reference_to(Py::Long(face->GetID()));
//.........这里部分代码省略.........
示例5: addFace
PyObject* FemMeshPy::addFace(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2,n3;
if (PyArg_ParseTuple(args, "iii",&n1,&n2,&n3))
{
// old form, debrekadet
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
const SMDS_MeshNode* node3 = meshDS->FindNode(n3);
if (!node1 || !node2 || !node3)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshFace* face = meshDS->AddFace(node1, node2, node3);
if (!face)
throw std::runtime_error("Failed to add face");
return Py::new_reference_to(Py::Int(face->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_MeshFace* face=0;
switch(Nodes.size()){
case 3:
face = meshDS->AddFace(Nodes[0],Nodes[1],Nodes[2]);
if (!face)
throw std::runtime_error("Failed to add triangular face");
break;
default: throw std::runtime_error("Unknown node count, [3|4|6|8] are allowed"); //unknown face type
}
return Py::new_reference_to(Py::Int(face->GetID()));
}
PyErr_SetString(PyExc_TypeError, "Line constructor accepts:\n"
"-- empty parameter list\n"
"-- Line\n"
"-- Point, Point");
return 0;
}