本文整理汇总了C++中SMESHDS_Mesh::ShapeToIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::ShapeToIndex方法的具体用法?C++ SMESHDS_Mesh::ShapeToIndex怎么用?C++ SMESHDS_Mesh::ShapeToIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::ShapeToIndex方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: helper
//.........这里部分代码省略.........
}
else {
// keep a triangle
triangles.push_back( elem );
isReversed.push_back( isRev );
// put elem nodes to nodeToNetgenID map
SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator();
while ( triangleNodesIt->more() ) {
const SMDS_MeshNode * node =
static_cast<const SMDS_MeshNode *>(triangleNodesIt->next());
if(myTool->IsMedium(node))
continue;
nodeToNetgenID.insert( make_pair( node, invalid_ID ));
}
}
#ifdef _DEBUG_
// check if a trainge is degenerated
areaControl.GetPoints( elem, nodesCoords );
double area = areaControl.GetValue( nodesCoords );
if ( area <= DBL_MIN ) {
MESSAGE( "Warning: Degenerated " << elem );
}
#endif
}
// look for degeneraged edges and vetices
for (TopExp_Explorer expE(aShapeFace,TopAbs_EDGE); expE.More(); expE.Next())
{
TopoDS_Edge aShapeEdge = TopoDS::Edge( expE.Current() );
if ( BRep_Tool::Degenerated( aShapeEdge ))
{
degenNgIds.push_back( invalid_ID );
int* ptrIdOnEdge = & degenNgIds.back();
// remember edge id
int edgeID = meshDS->ShapeToIndex( aShapeEdge );
degenShapeIdToPtrNgId.insert( make_pair( edgeID, ptrIdOnEdge ));
// remember vertex id
int vertexID = meshDS->ShapeToIndex( TopExp::FirstVertex( aShapeEdge ));
degenShapeIdToPtrNgId.insert( make_pair( vertexID, ptrIdOnEdge ));
}
}
}
}
// ---------------------------------
// Feed the Netgen with surface mesh
// ---------------------------------
int Netgen_NbOfNodes = 0;
int Netgen_param2ndOrder = 0;
double Netgen_paramFine = 1.;
double Netgen_paramSize = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
double Netgen_point[3];
int Netgen_triangle[3];
int Netgen_tetrahedron[4];
Ng_Init();
Ng_Mesh * Netgen_mesh = Ng_NewMesh();
// set nodes and remember thier netgen IDs
bool isDegen = false, hasDegen = !degenShapeIdToPtrNgId.empty();
TNodeToIDMap::iterator n_id = nodeToNetgenID.begin();
for ( ; n_id != nodeToNetgenID.end(); ++n_id )
{
const SMDS_MeshNode* node = n_id->first;
示例3: helper
bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::Compute()");
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
int faceID = meshDS->ShapeToIndex( aShape );
SMESH_MesherHelper helper(aMesh);
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
const bool ignoreMediumNodes = _quadraticMesh;
// ------------------------
// get all edges of a face
// ------------------------
const TopoDS_Face F = TopoDS::Face( aShape.Oriented( TopAbs_FORWARD ));
TError problem;
TSideVector wires = StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, problem );
if ( problem && !problem->IsOK() )
return error( problem );
int nbWires = wires.size();
if ( nbWires == 0 )
return error( "Problem in StdMeshers_FaceSide::GetFaceWires()");
if ( wires[0]->NbSegments() < 3 ) // ex: a circle with 2 segments
return error(COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Too few segments: ")<<wires[0]->NbSegments());
// -------------------------
// Make input netgen mesh
// -------------------------
Ng_Init();
netgen::Mesh * ngMesh = new netgen::Mesh ();
netgen::OCCGeometry occgeo;
NETGENPlugin_Mesher::PrepareOCCgeometry( occgeo, F, aMesh );
occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978)
occgeo.fmap.Add( F );
vector< const SMDS_MeshNode* > nodeVec;
problem = AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec );
if ( problem && !problem->IsOK() ) {
delete ngMesh; Ng_Exit();
return error( problem );
}
// --------------------
// compute edge length
// --------------------
double edgeLength = 0;
if (_hypLengthFromEdges || (!_hypLengthFromEdges && !_hypMaxElementArea))
{
int nbSegments = 0;
for ( int iW = 0; iW < nbWires; ++iW )
{
edgeLength += wires[ iW ]->Length();
nbSegments += wires[ iW ]->NbSegments();
}
if ( nbSegments )
edgeLength /= nbSegments;
}
if ( _hypMaxElementArea )
{
double maxArea = _hypMaxElementArea->GetMaxArea();
edgeLength = sqrt(2. * maxArea/sqrt(3.0));
}
if ( edgeLength < DBL_MIN )
edgeLength = occgeo.GetBoundingBox().Diam();
//cout << " edgeLength = " << edgeLength << endl;
netgen::mparam.maxh = edgeLength;
netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
//ngMesh->SetGlobalH ( edgeLength );
// -------------------------
// Generate surface mesh
// -------------------------
char *optstr = 0;
int startWith = MESHCONST_MESHSURFACE;
int endWith = MESHCONST_OPTSURFACE;
int err = 1;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,netgen::mparam, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
}
catch (Standard_Failure& ex) {
string comment = ex.DynamicType()->Name();
if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
comment += ": ";
//.........这里部分代码省略.........
示例4: SetSubShape
void SMESH_MesherHelper::SetSubShape(const TopoDS_Shape& aSh)
{
if ( myShape.IsSame( aSh ))
return;
myShape = aSh;
mySeamShapeIds.clear();
myDegenShapeIds.clear();
if ( myShape.IsNull() ) {
myShapeID = -1;
return;
}
SMESHDS_Mesh* meshDS = GetMeshDS();
myShapeID = meshDS->ShapeToIndex(aSh);
// treatment of periodic faces
for ( TopExp_Explorer eF( aSh, TopAbs_FACE ); eF.More(); eF.Next() )
{
const TopoDS_Face& face = TopoDS::Face( eF.Current() );
BRepAdaptor_Surface surface( face );
if ( surface.IsUPeriodic() || surface.IsVPeriodic() )
{
for (TopExp_Explorer exp( face, TopAbs_EDGE ); exp.More(); exp.Next())
{
// look for a seam edge
const TopoDS_Edge& edge = TopoDS::Edge( exp.Current() );
if ( BRep_Tool::IsClosed( edge, face )) {
// initialize myPar1, myPar2 and myParIndex
if ( mySeamShapeIds.empty() ) {
gp_Pnt2d uv1, uv2;
BRep_Tool::UVPoints( edge, face, uv1, uv2 );
if ( Abs( uv1.Coord(1) - uv2.Coord(1) ) < Abs( uv1.Coord(2) - uv2.Coord(2) ))
{
myParIndex = 1; // U periodic
myPar1 = surface.FirstUParameter();
myPar2 = surface.LastUParameter();
}
else {
myParIndex = 2; // V periodic
myPar1 = surface.FirstVParameter();
myPar2 = surface.LastVParameter();
}
}
// store seam shape indices, negative if shape encounters twice
int edgeID = meshDS->ShapeToIndex( edge );
mySeamShapeIds.insert( IsSeamShape( edgeID ) ? -edgeID : edgeID );
for ( TopExp_Explorer v( edge, TopAbs_VERTEX ); v.More(); v.Next() ) {
int vertexID = meshDS->ShapeToIndex( v.Current() );
mySeamShapeIds.insert( IsSeamShape( vertexID ) ? -vertexID : vertexID );
}
}
// look for a degenerated edge
if ( BRep_Tool::Degenerated( edge )) {
myDegenShapeIds.insert( meshDS->ShapeToIndex( edge ));
for ( TopExp_Explorer v( edge, TopAbs_VERTEX ); v.More(); v.Next() )
myDegenShapeIds.insert( meshDS->ShapeToIndex( v.Current() ));
}
}
}
}
}
示例5: error
bool StdMeshers_CompositeSegment_1D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
{
TopoDS_Edge edge = TopoDS::Edge( aShape );
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
// Get edges to be discretized as a whole
TopoDS_Face nullFace;
auto_ptr< StdMeshers_FaceSide > side( GetFaceSide(aMesh, edge, nullFace, true ));
//side->dump("IN COMPOSITE SEG");
if ( side->NbEdges() < 2 )
return StdMeshers_Regular_1D::Compute( aMesh, aShape );
// update segment lenght computed by StdMeshers_AutomaticLength
const list <const SMESHDS_Hypothesis * > & hyps = GetUsedHypothesis(aMesh, aShape);
if ( !hyps.empty() ) {
StdMeshers_AutomaticLength * autoLenHyp = const_cast<StdMeshers_AutomaticLength *>
(dynamic_cast <const StdMeshers_AutomaticLength * >(hyps.front()));
if ( autoLenHyp )
_value[ BEG_LENGTH_IND ]= autoLenHyp->GetLength( &aMesh, side->Length() );
}
// Compute node parameters
auto_ptr< BRepAdaptor_CompCurve > C3d ( side->GetCurve3d() );
double f = C3d->FirstParameter(), l = C3d->LastParameter();
list< double > params;
if ( !computeInternalParameters ( aMesh, *C3d, side->Length(), f, l, params, false ))
return false;
// Redistribute parameters near ends
TopoDS_Vertex VFirst = side->FirstVertex();
TopoDS_Vertex VLast = side->LastVertex();
redistributeNearVertices( aMesh, *C3d, side->Length(), params, VFirst, VLast );
params.push_front(f);
params.push_back(l);
int nbNodes = params.size();
// Create mesh
const SMDS_MeshNode * nFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS );
if (!nFirst)
return error(COMPERR_BAD_INPUT_MESH, TComm("No node on vertex ")
<<meshDS->ShapeToIndex(VFirst));
if (!nLast)
return error(COMPERR_BAD_INPUT_MESH, TComm("No node on vertex ")
<<meshDS->ShapeToIndex(VLast));
vector<const SMDS_MeshNode*> nodes( nbNodes, (const SMDS_MeshNode*)0 );
nodes.front() = nFirst;
nodes.back() = nLast;
// create internal nodes
list< double >::iterator parIt = params.begin();
double prevPar = *parIt;
Standard_Real u;
for ( int iN = 0; parIt != params.end(); ++iN, ++parIt)
{
if ( !nodes[ iN ] ) {
gp_Pnt p = C3d->Value( *parIt );
SMDS_MeshNode* n = meshDS->AddNode( p.X(), p.Y(), p.Z());
C3d->Edge( *parIt, edge, u );
meshDS->SetNodeOnEdge( n, edge, u );
// cout << "new NODE: par="<<*parIt<<" ePar="<<u<<" e="<<edge.TShape().operator->()
// << " " << n << endl;
nodes[ iN ] = n;
}
// create edges
if ( iN ) {
double mPar = ( prevPar + *parIt )/2;
if ( _quadraticMesh ) {
// create medium node
double segLen = GCPnts_AbscissaPoint::Length(*C3d, prevPar, *parIt);
GCPnts_AbscissaPoint ruler( *C3d, segLen/2., prevPar );
if ( ruler.IsDone() )
mPar = ruler.Parameter();
gp_Pnt p = C3d->Value( mPar );
SMDS_MeshNode* n = meshDS->AddNode( p.X(), p.Y(), p.Z());
//cout << "new NODE "<< n << endl;
meshDS->SetNodeOnEdge( n, edge, u );
SMDS_MeshEdge * seg = meshDS->AddEdge(nodes[ iN-1 ], nodes[ iN ], n);
meshDS->SetMeshElementOnShape(seg, edge);
}
else {
C3d->Edge( mPar, edge, u );
SMDS_MeshEdge * seg = meshDS->AddEdge(nodes[ iN-1 ], nodes[ iN ]);
meshDS->SetMeshElementOnShape(seg, edge);
}
}
prevPar = *parIt;
}
// remove nodes on internal vertices
for ( int iE = 1; iE < side->NbEdges(); ++iE )
{
TopoDS_Vertex V = side->FirstVertex( iE );
while ( const SMDS_MeshNode * n = SMESH_Algo::VertexNode( V, meshDS ))
meshDS->RemoveNode( n );
//.........这里部分代码省略.........
示例6: error
bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
{
TopExp_Explorer exp;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
myHelper = new SMESH_MesherHelper( aMesh );
myHelper->IsQuadraticSubMesh( aShape );
// to delete helper at exit from Compute()
std::auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
// get 2 shells
TopoDS_Solid solid = TopoDS::Solid( aShape );
TopoDS_Shell outerShell = BRepClass3d::OuterShell( solid );
TopoDS_Shape innerShell;
int nbShells = 0;
for ( TopoDS_Iterator It (solid); It.More(); It.Next(), ++nbShells )
if ( !outerShell.IsSame( It.Value() ))
innerShell = It.Value();
if ( nbShells != 2 )
return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<<nbShells);
// ----------------------------------
// Associate sub-shapes of the shells
// ----------------------------------
ProjectionUtils::TShapeShapeMap shape2ShapeMaps[2];
bool mapOk1 = ProjectionUtils::FindSubShapeAssociation( innerShell, &aMesh,
outerShell, &aMesh,
shape2ShapeMaps[0]);
bool mapOk2 = ProjectionUtils::FindSubShapeAssociation( innerShell.Reversed(), &aMesh,
outerShell, &aMesh,
shape2ShapeMaps[1]);
if ( !mapOk1 && !mapOk2 )
return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
int iMap;
if ( shape2ShapeMaps[0].Extent() == shape2ShapeMaps[1].Extent() )
{
// choose an assiciation by shortest distance between VERTEXes
double dist1 = 0, dist2 = 0;
TopTools_DataMapIteratorOfDataMapOfShapeShape ssIt( shape2ShapeMaps[0]._map1to2 );
for (; ssIt.More(); ssIt.Next() )
{
if ( ssIt.Key().ShapeType() != TopAbs_VERTEX ) continue;
gp_Pnt pIn = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Key() ));
gp_Pnt pOut1 = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Value() ));
gp_Pnt pOut2 = BRep_Tool::Pnt( TopoDS::Vertex( shape2ShapeMaps[1]( ssIt.Key() )));
dist1 += pIn.SquareDistance( pOut1 );
dist2 += pIn.SquareDistance( pOut2 );
}
iMap = ( dist1 < dist2 ) ? 0 : 1;
}
else
{
iMap = ( shape2ShapeMaps[0].Extent() > shape2ShapeMaps[1].Extent() ) ? 0 : 1;
}
ProjectionUtils::TShapeShapeMap& shape2ShapeMap = shape2ShapeMaps[iMap];
// ------------------
// Make mesh
// ------------------
TNode2ColumnMap node2columnMap;
myLayerPositions.clear();
for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
{
// Corresponding sub-shapes
TopoDS_Face outFace = TopoDS::Face( exp.Current() );
TopoDS_Face inFace;
if ( !shape2ShapeMap.IsBound( outFace, /*isOut=*/true )) {
return error(SMESH_Comment("Corresponding inner face not found for face #" )
<< meshDS->ShapeToIndex( outFace ));
} else {
inFace = TopoDS::Face( shape2ShapeMap( outFace, /*isOut=*/true ));
}
// Find matching nodes of in and out faces
ProjectionUtils::TNodeNodeMap nodeIn2OutMap;
if ( ! ProjectionUtils::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
shape2ShapeMap, nodeIn2OutMap ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< meshDS->ShapeToIndex( outFace ) << " and "
<< meshDS->ShapeToIndex( inFace ) << " seems different" );
// Create volumes
SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements();
while ( faceIt->more() ) // loop on faces on inFace
{
const SMDS_MeshElement* face = faceIt->next();
if ( !face || face->GetType() != SMDSAbs_Face )
continue;
int nbNodes = face->NbNodes();
if ( face->IsQuadratic() )
nbNodes /= 2;
// find node columns for each node
vector< const TNodeColumn* > columns( nbNodes );
for ( int i = 0; i < nbNodes; ++i )
//.........这里部分代码省略.........
示例7: error
bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
{
TopExp_Explorer exp;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
myHelper = new SMESH_MesherHelper( aMesh );
myHelper->IsQuadraticSubMesh( aShape );
// to delete helper at exit from Compute()
std::auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
// get 2 shells
TopoDS_Solid solid = TopoDS::Solid( aShape );
TopoDS_Shell outerShell = BRepClass3d::OuterShell( solid );
TopoDS_Shape innerShell;
int nbShells = 0;
for ( TopoDS_Iterator It (solid); It.More(); It.Next(), ++nbShells )
if ( !outerShell.IsSame( It.Value() ))
innerShell = It.Value();
if ( nbShells != 2 )
return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<<nbShells);
// ----------------------------------
// Associate subshapes of the shells
// ----------------------------------
TAssocTool::TShapeShapeMap shape2ShapeMap;
if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
innerShell, &aMesh,
shape2ShapeMap) )
return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
// ------------------
// Make mesh
// ------------------
TNode2ColumnMap node2columnMap;
myLayerPositions.clear();
for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
{
// Corresponding subshapes
TopoDS_Face outFace = TopoDS::Face( exp.Current() );
TopoDS_Face inFace;
if ( !shape2ShapeMap.IsBound( outFace )) {
return error(SMESH_Comment("Corresponding inner face not found for face #" )
<< meshDS->ShapeToIndex( outFace ));
} else {
inFace = TopoDS::Face( shape2ShapeMap( outFace ));
}
// Find matching nodes of in and out faces
TNodeNodeMap nodeIn2OutMap;
if ( ! TAssocTool::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
shape2ShapeMap, nodeIn2OutMap ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< meshDS->ShapeToIndex( outFace ) << " and "
<< meshDS->ShapeToIndex( inFace ) << " seems different" );
// Create volumes
SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements();
while ( faceIt->more() ) // loop on faces on inFace
{
const SMDS_MeshElement* face = faceIt->next();
if ( !face || face->GetType() != SMDSAbs_Face )
continue;
int nbNodes = face->NbNodes();
if ( face->IsQuadratic() )
nbNodes /= 2;
// find node columns for each node
vector< const TNodeColumn* > columns( nbNodes );
for ( int i = 0; i < nbNodes; ++i )
{
const SMDS_MeshNode* nIn = face->GetNode( i );
TNode2ColumnMap::iterator n_col = node2columnMap.find( nIn );
if ( n_col != node2columnMap.end() ) {
columns[ i ] = & n_col->second;
}
else {
TNodeNodeMap::iterator nInOut = nodeIn2OutMap.find( nIn );
if ( nInOut == nodeIn2OutMap.end() )
RETURN_BAD_RESULT("No matching node for "<< nIn->GetID() <<
" in face "<< face->GetID());
columns[ i ] = makeNodeColumn( node2columnMap, nIn, nInOut->second );
}
}
StdMeshers_Prism_3D::AddPrisms( columns, myHelper );
}
} // loop on faces of out shell
return true;
}
示例8: exp
//.........这里部分代码省略.........
return error(COMPERR_BAD_SHAPE, "Can't detect block subshapes. Not a block?");
if ( !srcBlock.LoadBlockShapes( srcShell, srcV000, srcV100, scrShapes ))
return error(COMPERR_BAD_SHAPE, "Can't detect block subshapes. Not a block?");
// Find matching nodes of src and tgt shells
TNodeNodeMap src2tgtNodeMap;
for ( int fId = SMESH_Block::ID_FirstF; fId < SMESH_Block::ID_Shell; ++fId )
{
// Corresponding subshapes
TopoDS_Face srcFace = TopoDS::Face( scrShapes( fId ));
TopoDS_Face tgtFace = TopoDS::Face( tgtShapes( fId ));
if ( _sourceHypo->HasVertexAssociation() ) { // associate face subshapes
shape2ShapeMap.Clear();
vector< int > edgeIdVec;
SMESH_Block::GetFaceEdgesIDs( fId, edgeIdVec );
for ( int i = 0; i < edgeIdVec.size(); ++i ) {
int eID = edgeIdVec[ i ];
shape2ShapeMap.Bind( tgtShapes( eID ), scrShapes( eID ));
if ( i < 2 ) {
vector< int > vertexIdVec;
SMESH_Block::GetEdgeVertexIDs( eID, vertexIdVec );
shape2ShapeMap.Bind( tgtShapes( vertexIdVec[0] ), scrShapes( vertexIdVec[0] ));
shape2ShapeMap.Bind( tgtShapes( vertexIdVec[1] ), scrShapes( vertexIdVec[1] ));
}
}
}
// Find matching nodes of tgt and src faces
TNodeNodeMap faceMatchingNodes;
if ( ! TAssocTool::FindMatchingNodesOnFaces( srcFace, srcMesh, tgtFace, tgtMesh,
shape2ShapeMap, faceMatchingNodes ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< srcMeshDS->ShapeToIndex( srcFace ) << " and "
<< tgtMeshDS->ShapeToIndex( tgtFace ) << " seems different" );
// put found matching nodes of 2 faces to the global map
src2tgtNodeMap.insert( faceMatchingNodes.begin(), faceMatchingNodes.end() );
}
// ------------------
// Make mesh
// ------------------
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 );
示例9: error
bool StdMeshers_RadialQuadrangle_1D2D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
TopExp_Explorer exp;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
myHelper = new SMESH_MesherHelper( aMesh );
myHelper->IsQuadraticSubMesh( aShape );
// to delete helper at exit from Compute()
auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
myLayerPositions.clear();
TopoDS_Edge CircEdge, LinEdge1, LinEdge2;
int nbe = analyseFace( aShape, CircEdge, LinEdge1, LinEdge2 );
if( nbe>3 || nbe < 1 || CircEdge.IsNull() )
return error(COMPERR_BAD_SHAPE);
gp_Pnt P0,P1;
// points for rotation
TColgp_SequenceOfPnt Points;
// angles for rotation
TColStd_SequenceOfReal Angles;
// Nodes1 and Nodes2 - nodes along radiuses
// CNodes - nodes on circle edge
vector< const SMDS_MeshNode* > Nodes1, Nodes2, CNodes;
SMDS_MeshNode * NC;
// parameters edge nodes on face
TColgp_SequenceOfPnt2d Pnts2d1;
gp_Pnt2d PC;
int faceID = meshDS->ShapeToIndex(aShape);
TopoDS_Face F = TopoDS::Face(aShape);
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
if(nbe==1)
{
Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast( getCurve( CircEdge ));
bool ok = _gen->Compute( aMesh, CircEdge );
if( !ok ) return false;
map< double, const SMDS_MeshNode* > theNodes;
ok = GetSortedNodesOnEdge(aMesh.GetMeshDS(),CircEdge,true,theNodes);
if( !ok ) return false;
CNodes.clear();
map< double, const SMDS_MeshNode* >::iterator itn = theNodes.begin();
const SMDS_MeshNode* NF = (*itn).second;
CNodes.push_back( (*itn).second );
double fang = (*itn).first;
if ( itn != theNodes.end() ) {
itn++;
for(; itn != theNodes.end(); itn++ ) {
CNodes.push_back( (*itn).second );
double ang = (*itn).first - fang;
if( ang>M_PI ) ang = ang - 2*M_PI;
if( ang<-M_PI ) ang = ang + 2*M_PI;
Angles.Append( ang );
}
}
P1 = gp_Pnt( NF->X(), NF->Y(), NF->Z() );
P0 = aCirc->Location();
myLayerPositions.clear();
computeLayerPositions(P0,P1);
exp.Init( CircEdge, TopAbs_VERTEX );
TopoDS_Vertex V1 = TopoDS::Vertex( exp.Current() );
gp_Pnt2d p2dV = BRep_Tool::Parameters( V1, TopoDS::Face(aShape) );
NC = meshDS->AddNode(P0.X(), P0.Y(), P0.Z());
GeomAPI_ProjectPointOnSurf PPS(P0,S);
double U0,V0;
PPS.Parameters(1,U0,V0);
meshDS->SetNodeOnFace(NC, faceID, U0, V0);
PC = gp_Pnt2d(U0,V0);
gp_Vec aVec(P0,P1);
gp_Vec2d aVec2d(PC,p2dV);
Nodes1.resize( myLayerPositions.size()+1 );
Nodes2.resize( myLayerPositions.size()+1 );
int i = 0;
for(; i<myLayerPositions.size(); i++) {
gp_Pnt P( P0.X() + aVec.X()*myLayerPositions[i],
P0.Y() + aVec.Y()*myLayerPositions[i],
P0.Z() + aVec.Z()*myLayerPositions[i] );
Points.Append(P);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
Nodes1[i] = node;
Nodes2[i] = node;
double U = PC.X() + aVec2d.X()*myLayerPositions[i];
double V = PC.Y() + aVec2d.Y()*myLayerPositions[i];
meshDS->SetNodeOnFace( node, faceID, U, V );
Pnts2d1.Append(gp_Pnt2d(U,V));
}
Nodes1[Nodes1.size()-1] = NF;
Nodes2[Nodes1.size()-1] = NF;
}
else if(nbe==2 && LinEdge1.Orientation() != TopAbs_INTERNAL )
{
//.........这里部分代码省略.........
示例10: helper
//.........这里部分代码省略.........
TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap );
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
{
const TopoDS_Shape& edge = edgeMap( iE );
if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))/* ||
helper.IsSubShape( edge, aShape )*/)
continue;
SMESHDS_SubMesh* smDS = meshDS->MeshElements( edge );
if ( !smDS ) continue;
SMDS_ElemIteratorPtr segIt = smDS->GetElements();
while ( segIt->more() )
{
const SMDS_MeshElement* seg = segIt->next();
SMESH_TNodeXYZ n1 = seg->GetNode(0);
SMESH_TNodeXYZ n2 = seg->GetNode(1);
gp_XYZ p = 0.5 * ( n1 + n2 );
netgen::Point3d pi(p.X(), p.Y(), p.Z());
ngMeshes[0]->RestrictLocalH( pi, factor * ( n1 - n2 ).Modulus() );
}
}
}
netgen::mparam.uselocalh = toOptimize; // restore as it is used at surface optimization
// ==================
// Loop on all FACEs
// ==================
vector< const SMDS_MeshNode* > nodeVec;
TopExp_Explorer fExp( aShape, TopAbs_FACE );
for ( int iF = 0; fExp.More(); fExp.Next(), ++iF )
{
TopoDS_Face F = TopoDS::Face( fExp.Current() /*.Oriented( TopAbs_FORWARD )*/);
int faceID = meshDS->ShapeToIndex( F );
SMESH_ComputeErrorPtr& faceErr = aMesh.GetSubMesh( F )->GetComputeError();
_quadraticMesh = helper.IsQuadraticSubMesh( F );
const bool ignoreMediumNodes = _quadraticMesh;
// build viscous layers if required
if ( F.Orientation() != TopAbs_FORWARD &&
F.Orientation() != TopAbs_REVERSED )
F.Orientation( TopAbs_FORWARD ); // avoid pb with TopAbs_INTERNAL
SMESH_ProxyMesh::Ptr proxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F );
if ( !proxyMesh )
continue;
// ------------------------
// get all EDGEs of a FACE
// ------------------------
TSideVector wires =
StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, faceErr, proxyMesh );
if ( faceErr && !faceErr->IsOK() )
continue;
int nbWires = wires.size();
if ( nbWires == 0 )
{
faceErr.reset
( new SMESH_ComputeError
( COMPERR_ALGO_FAILED, "Problem in StdMeshers_FaceSide::GetFaceWires()" ));
continue;
}
if ( wires[0]->NbSegments() < 3 ) // ex: a circle with 2 segments
{
faceErr.reset
( new SMESH_ComputeError
示例11: error
bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)// throw(SALOME_Exception)
{
// PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside
//Unexpect aCatch(SalomeException);
MESSAGE("StdMeshers_Hexa_3D::Compute");
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
// 0. - shape and face mesh verification
// 0.1 - shape must be a solid (or a shell) with 6 faces
vector < SMESH_subMesh * >meshFaces;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
ASSERT(aSubMesh);
meshFaces.push_back(aSubMesh);
}
if (meshFaces.size() != 6) {
//return error(COMPERR_BAD_SHAPE, TComm(meshFaces.size())<<" instead of 6 faces in a block");
static StdMeshers_CompositeHexa_3D compositeHexa(-10, 0, aMesh.GetGen());
if ( !compositeHexa.Compute( aMesh, aShape ))
return error( compositeHexa.GetComputeError() );
return true;
}
// 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
// tool for working with quadratic elements
SMESH_MesherHelper aTool (aMesh);
_quadraticMesh = aTool.IsQuadraticSubMesh(aShape);
// cube structure
typedef struct cubeStruct
{
TopoDS_Vertex V000;
TopoDS_Vertex V001;
TopoDS_Vertex V010;
TopoDS_Vertex V011;
TopoDS_Vertex V100;
TopoDS_Vertex V101;
TopoDS_Vertex V110;
TopoDS_Vertex V111;
faceQuadStruct* quad_X0;
faceQuadStruct* quad_X1;
faceQuadStruct* quad_Y0;
faceQuadStruct* quad_Y1;
faceQuadStruct* quad_Z0;
faceQuadStruct* quad_Z1;
Point3DStruct* np; // normalised 3D coordinates
} CubeStruct;
CubeStruct aCube;
// bounding faces
FaceQuadStruct* aQuads[6];
for (int i = 0; i < 6; i++)
aQuads[i] = 0;
for (int i = 0; i < 6; i++)
{
TopoDS_Shape aFace = meshFaces[i]->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace);
string algoName = algo->GetName();
bool isAllQuad = false;
if (algoName == "Quadrangle_2D") {
SMESHDS_SubMesh * sm = meshDS->MeshElements( aFace );
if ( sm ) {
isAllQuad = true;
SMDS_ElemIteratorPtr eIt = sm->GetElements();
while ( isAllQuad && eIt->more() ) {
const SMDS_MeshElement* elem = eIt->next();
isAllQuad = ( elem->NbNodes()==4 ||(_quadraticMesh && elem->NbNodes()==8) );
}
}
}
if ( ! isAllQuad ) {
SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape);
return ClearAndReturn( aQuads, error(err));
}
StdMeshers_Quadrangle_2D *quadAlgo =
dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
ASSERT(quadAlgo);
try {
aQuads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, _quadraticMesh);
if(!aQuads[i]) {
return error( quadAlgo->GetComputeError());
}
}
catch(SALOME_Exception & S_ex) {
return ClearAndReturn( aQuads, error(COMPERR_SLM_EXCEPTION,TComm(S_ex.what()) <<
" Raised by StdMeshers_Quadrangle_2D "
" on face #" << meshDS->ShapeToIndex( aFace )));
}
// 0.2.1 - number of points on the opposite edges must be the same
if (aQuads[i]->side[0]->NbPoints() != aQuads[i]->side[2]->NbPoints() ||
aQuads[i]->side[1]->NbPoints() != aQuads[i]->side[3]->NbPoints()
/*aQuads[i]->side[0]->NbEdges() != 1 ||
aQuads[i]->side[1]->NbEdges() != 1 ||
aQuads[i]->side[2]->NbEdges() != 1 ||
//.........这里部分代码省略.........