本文整理汇总了C++中SMESHDS_Mesh::IndexToShape方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::IndexToShape方法的具体用法?C++ SMESHDS_Mesh::IndexToShape怎么用?C++ SMESHDS_Mesh::IndexToShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::IndexToShape方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNodeU
double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E,
const SMDS_MeshNode* n)
{
double param = 0;
const SMDS_PositionPtr Pos = n->GetPosition();
if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE) {
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
param = epos->GetUParameter();
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) {
SMESHDS_Mesh * meshDS = GetMeshDS();
int vertexID = n->GetPosition()->GetShapeId();
const TopoDS_Vertex& V = TopoDS::Vertex(meshDS->IndexToShape(vertexID));
param = BRep_Tool::Parameter( V, E );
}
return param;
}
示例2: helper
bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
netgen::multithread.terminate = 0;
netgen::multithread.task = "Volume meshing";
_progressByTic = -1.;
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
SMESH_MesherHelper helper(aMesh);
bool _quadraticMesh = helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
int Netgen_NbOfNodes = 0;
double Netgen_point[3];
int Netgen_triangle[3];
NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec;
{
const int invalid_ID = -1;
SMESH::Controls::Area areaControl;
SMESH::Controls::TSequenceOfXYZ nodesCoords;
// maps nodes to ng ID
typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
typedef TNodeToIDMap::value_type TN2ID;
TNodeToIDMap nodeToNetgenID;
// find internal shapes
NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true );
// ---------------------------------
// Feed the Netgen with surface mesh
// ---------------------------------
TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType();
bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID );
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
if ( _viscousLayersHyp )
{
netgen::multithread.percent = 3;
proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape );
if ( !proxyMesh )
return false;
}
if ( aMesh.NbQuadrangles() > 0 )
{
netgen::multithread.percent = 6;
StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor;
Adaptor->Compute(aMesh,aShape,proxyMesh.get());
proxyMesh.reset( Adaptor );
}
for ( TopExp_Explorer exFa( aShape, TopAbs_FACE ); exFa.More(); exFa.Next())
{
const TopoDS_Shape& aShapeFace = exFa.Current();
int faceID = meshDS->ShapeToIndex( aShapeFace );
bool isInternalFace = internals.isInternalShape( faceID );
bool isRev = false;
if ( checkReverse && !isInternalFace &&
helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 )
// IsReversedSubMesh() can work wrong on strongly curved faces,
// so we use it as less as possible
isRev = helper.IsReversedSubMesh( TopoDS::Face( aShapeFace ));
const SMESHDS_SubMesh * aSubMeshDSFace = proxyMesh->GetSubMesh( aShapeFace );
if ( !aSubMeshDSFace ) continue;
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
while ( iteratorElem->more() ) // loop on elements on a geom face
{
// check mesh face
const SMDS_MeshElement* elem = iteratorElem->next();
if ( !elem )
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
if ( elem->NbCornerNodes() != 3 )
return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
// Add nodes of triangles and triangles them-selves to netgen mesh
// add three nodes of triangle
bool hasDegen = false;
for ( int iN = 0; iN < 3; ++iN )
{
const SMDS_MeshNode* node = elem->GetNode( iN );
const int shapeID = node->getshapeId();
if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE &&
helper.IsDegenShape( shapeID ))
{
// ignore all nodes on degeneraged edge and use node on its vertex instead
TopoDS_Shape vertex = TopoDS_Iterator( meshDS->IndexToShape( shapeID )).Value();
node = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), meshDS );
hasDegen = true;
}
int& ngID = nodeToNetgenID.insert(TN2ID( node, invalid_ID )).first->second;
//.........这里部分代码省略.........
示例3: GetMediumNode
/*!
* Special function for search or creation medium node
*/
const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
bool force3d)
{
TopAbs_ShapeEnum shapeType = myShape.IsNull() ? TopAbs_SHAPE : myShape.ShapeType();
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
ItNLinkNode itLN = myNLinkNodeMap.find( link );
if ( itLN != myNLinkNodeMap.end() ) {
return (*itLN).second;
}
else {
// create medium node
SMDS_MeshNode* n12;
SMESHDS_Mesh* meshDS = GetMeshDS();
int faceID = -1, edgeID = -1;
const SMDS_PositionPtr Pos1 = n1->GetPosition();
const SMDS_PositionPtr Pos2 = n2->GetPosition();
if( myShape.IsNull() )
{
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos1->GetShapeId();
}
else if( Pos2->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos2->GetShapeId();
}
if( Pos1->GetTypeOfPosition()==SMDS_TOP_EDGE ) {
edgeID = Pos1->GetShapeId();
}
if( Pos2->GetTypeOfPosition()==SMDS_TOP_EDGE ) {
edgeID = Pos2->GetShapeId();
}
}
if(!force3d) {
// we try to create medium node using UV parameters of
// nodes, else - medium between corresponding 3d points
if(faceID>-1 || shapeType == TopAbs_FACE) {
// obtaining a face and 2d points for nodes
TopoDS_Face F;
if( myShape.IsNull() )
F = TopoDS::Face(meshDS->IndexToShape(faceID));
else {
F = TopoDS::Face(myShape);
faceID = myShapeID;
}
gp_XY p1 = GetNodeUV(F,n1,n2);
gp_XY p2 = GetNodeUV(F,n2,n1);
if ( IsDegenShape( Pos1->GetShapeId() ))
p1.SetCoord( myParIndex, p2.Coord( myParIndex ));
else if ( IsDegenShape( Pos2->GetShapeId() ))
p2.SetCoord( myParIndex, p1.Coord( myParIndex ));
//checking if surface is periodic
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
Standard_Real UF,UL,VF,VL;
S->Bounds(UF,UL,VF,VL);
Standard_Real u,v;
Standard_Boolean isUPeriodic = S->IsUPeriodic();
if(isUPeriodic) {
Standard_Real UPeriod = S->UPeriod();
Standard_Real p2x = p2.X()+ShapeAnalysis::AdjustByPeriod(p2.X(),p1.X(),UPeriod);
Standard_Real pmid = (p1.X()+p2x)/2.;
u = pmid+ShapeAnalysis::AdjustToPeriod(pmid,UF,UL);
}
else
u= (p1.X()+p2.X())/2.;
Standard_Boolean isVPeriodic = S->IsVPeriodic();
if(isVPeriodic) {
Standard_Real VPeriod = S->VPeriod();
Standard_Real p2y = p2.Y()+ShapeAnalysis::AdjustByPeriod(p2.Y(),p1.Y(),VPeriod);
Standard_Real pmid = (p1.Y()+p2y)/2.;
v = pmid+ShapeAnalysis::AdjustToPeriod(pmid,VF,VL);
}
else
v = (p1.Y()+p2.Y())/2.;
gp_Pnt P = S->Value(u, v);
n12 = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(n12, faceID, u, v);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
if (edgeID>-1 || shapeType == TopAbs_EDGE) {
TopoDS_Edge E;
if( myShape.IsNull() )
E = TopoDS::Edge(meshDS->IndexToShape(edgeID));
else {
E = TopoDS::Edge(myShape);
edgeID = myShapeID;
//.........这里部分代码省略.........
示例4: GetNodeUV
gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F,
const SMDS_MeshNode* n,
const SMDS_MeshNode* n2) const
{
gp_Pnt2d uv( 1e100, 1e100 );
const SMDS_PositionPtr Pos = n->GetPosition();
if(Pos->GetTypeOfPosition()==SMDS_TOP_FACE)
{
// node has position on face
const SMDS_FacePosition* fpos =
static_cast<const SMDS_FacePosition*>(n->GetPosition().get());
uv = gp_Pnt2d(fpos->GetUParameter(),fpos->GetVParameter());
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE)
{
// node has position on edge => it is needed to find
// corresponding edge from face, get pcurve for this
// edge and recieve value from this pcurve
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
SMESHDS_Mesh* meshDS = GetMeshDS();
int edgeID = Pos->GetShapeId();
TopoDS_Edge E = TopoDS::Edge(meshDS->IndexToShape(edgeID));
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
uv = C2d->Value( epos->GetUParameter() );
// for a node on a seam edge select one of UVs on 2 pcurves
if ( n2 && IsSeamShape( edgeID ) )
uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 ));
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX)
{
if ( int vertexID = n->GetPosition()->GetShapeId() ) {
bool ok = true;
const TopoDS_Vertex& V = TopoDS::Vertex(GetMeshDS()->IndexToShape(vertexID));
try {
uv = BRep_Tool::Parameters( V, F );
}
catch (Standard_Failure& exc) {
ok = false;
}
if ( !ok ) {
for ( TopExp_Explorer vert(F,TopAbs_VERTEX); !ok && vert.More(); vert.Next() )
ok = ( V == vert.Current() );
if ( !ok ) {
#ifdef _DEBUG_
MESSAGE ( "SMESH_MesherHelper::GetNodeUV(); Vertex " << vertexID
<< " not in face " << GetMeshDS()->ShapeToIndex( F ) );
#endif
// get UV of a vertex closest to the node
double dist = 1e100;
gp_Pnt pn ( n->X(),n->Y(),n->Z() );
for ( TopExp_Explorer vert(F,TopAbs_VERTEX); !ok && vert.More(); vert.Next() ) {
TopoDS_Vertex curV = TopoDS::Vertex( vert.Current() );
gp_Pnt p = BRep_Tool::Pnt( curV );
double curDist = p.SquareDistance( pn );
if ( curDist < dist ) {
dist = curDist;
uv = BRep_Tool::Parameters( curV, F );
if ( dist < DBL_MIN ) break;
}
}
}
else {
TopTools_ListIteratorOfListOfShape it( myMesh->GetAncestors( V ));
for ( ; it.More(); it.Next() ) {
if ( it.Value().ShapeType() == TopAbs_EDGE ) {
const TopoDS_Edge & edge = TopoDS::Edge( it.Value() );
double f,l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edge, F, f, l);
if ( !C2d.IsNull() ) {
double u = ( V == TopExp::FirstVertex( edge ) ) ? f : l;
uv = C2d->Value( u );
break;
}
}
}
}
}
if ( n2 && IsSeamShape( vertexID ) )
uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 ));
}
}
return uv.XY();
}