本文整理汇总了C++中SMESHDS_Mesh::AddPolyhedralVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::AddPolyhedralVolume方法的具体用法?C++ SMESHDS_Mesh::AddPolyhedralVolume怎么用?C++ SMESHDS_Mesh::AddPolyhedralVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::AddPolyhedralVolume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exp
//.........这里部分代码省略.........
SMDS_VolumeTool volTool;
SMESH_MesherHelper helper( *tgtMesh );
helper.IsQuadraticSubMesh( aShape );
SMESHDS_SubMesh* srcSMDS = srcSubMesh->GetSubMeshDS();
SMDS_ElemIteratorPtr volIt = srcSMDS->GetElements();
while ( volIt->more() ) // loop on source volumes
{
const SMDS_MeshElement* srcVol = volIt->next();
if ( !srcVol || srcVol->GetType() != SMDSAbs_Volume )
continue;
int nbNodes = srcVol->NbNodes();
SMDS_VolumeTool::VolumeType volType = volTool.GetType( nbNodes );
if ( srcVol->IsQuadratic() )
nbNodes = volTool.NbCornerNodes( volType );
// Find or create a new tgt node for each node of a src volume
vector< const SMDS_MeshNode* > nodes( nbNodes );
for ( int i = 0; i < nbNodes; ++i )
{
const SMDS_MeshNode* srcNode = srcVol->GetNode( i );
const SMDS_MeshNode* tgtNode = 0;
TNodeNodeMap::iterator sN_tN = src2tgtNodeMap.find( srcNode );
if ( sN_tN != src2tgtNodeMap.end() ) // found
{
tgtNode = sN_tN->second;
}
else // Create a new tgt node
{
// compute normalized parameters of source node in srcBlock
gp_Pnt srcCoord = gpXYZ( srcNode );
gp_XYZ srcParam;
if ( !srcBlock.ComputeParameters( srcCoord, srcParam ))
return error(SMESH_Comment("Can't compute normalized parameters ")
<< "for source node " << srcNode->GetID());
// compute coordinates of target node by srcParam
gp_XYZ tgtXYZ;
if ( !tgtBlock.ShellPoint( srcParam, tgtXYZ ))
return error("Can't compute coordinates by normalized parameters");
// add node
SMDS_MeshNode* newNode = tgtMeshDS->AddNode( tgtXYZ.X(), tgtXYZ.Y(), tgtXYZ.Z() );
tgtMeshDS->SetNodeInVolume( newNode, helper.GetSubShapeID() );
tgtNode = newNode;
src2tgtNodeMap.insert( make_pair( srcNode, tgtNode ));
}
nodes[ i ] = tgtNode;
}
// Create a new volume
SMDS_MeshVolume * tgtVol = 0;
int id = 0, force3d = false;
switch ( volType ) {
case SMDS_VolumeTool::TETRA :
case SMDS_VolumeTool::QUAD_TETRA:
tgtVol = helper.AddVolume( nodes[0],
nodes[1],
nodes[2],
nodes[3], id, force3d); break;
case SMDS_VolumeTool::PYRAM :
case SMDS_VolumeTool::QUAD_PYRAM:
tgtVol = helper.AddVolume( nodes[0],
nodes[1],
nodes[2],
nodes[3],
nodes[4], id, force3d); break;
case SMDS_VolumeTool::PENTA :
case SMDS_VolumeTool::QUAD_PENTA:
tgtVol = helper.AddVolume( nodes[0],
nodes[1],
nodes[2],
nodes[3],
nodes[4],
nodes[5], id, force3d); break;
case SMDS_VolumeTool::HEXA :
case SMDS_VolumeTool::QUAD_HEXA :
tgtVol = helper.AddVolume( nodes[0],
nodes[1],
nodes[2],
nodes[3],
nodes[4],
nodes[5],
nodes[6],
nodes[7], id, force3d); break;
default: // polyhedron
const SMDS_PolyhedralVolumeOfNodes * poly =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( srcVol );
if ( !poly )
RETURN_BAD_RESULT("Unexpected volume type");
tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuanities() );
}
if ( tgtVol ) {
tgtMeshDS->SetMeshElementOnShape( tgtVol, helper.GetSubShapeID() );
}
} // loop on volumes of src shell
return true;
}