本文整理汇总了C++中SMESHDS_Mesh::MeshElements方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::MeshElements方法的具体用法?C++ SMESHDS_Mesh::MeshElements怎么用?C++ SMESHDS_Mesh::MeshElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::MeshElements方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsQuadraticSubMesh
bool SMESH_MesherHelper::IsQuadraticSubMesh(const TopoDS_Shape& aSh)
{
SMESHDS_Mesh* meshDS = GetMeshDS();
// we can create quadratic elements only if all elements
// created on subshapes of given shape are quadratic
// also we have to fill myNLinkNodeMap
myCreateQuadratic = true;
mySeamShapeIds.clear();
myDegenShapeIds.clear();
TopAbs_ShapeEnum subType( aSh.ShapeType()==TopAbs_FACE ? TopAbs_EDGE : TopAbs_FACE );
SMDSAbs_ElementType elemType( subType==TopAbs_FACE ? SMDSAbs_Face : SMDSAbs_Edge );
int nbOldLinks = myNLinkNodeMap.size();
TopExp_Explorer exp( aSh, subType );
for (; exp.More() && myCreateQuadratic; exp.Next()) {
if ( SMESHDS_SubMesh * subMesh = meshDS->MeshElements( exp.Current() )) {
if ( SMDS_ElemIteratorPtr it = subMesh->GetElements() ) {
while(it->more()) {
const SMDS_MeshElement* e = it->next();
if ( e->GetType() != elemType || !e->IsQuadratic() ) {
myCreateQuadratic = false;
break;
}
else {
// fill NLinkNodeMap
switch ( e->NbNodes() ) {
case 3:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(2)); break;
case 6:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(3));
AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(4));
AddNLinkNode(e->GetNode(2),e->GetNode(0),e->GetNode(5)); break;
case 8:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(4));
AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(5));
AddNLinkNode(e->GetNode(2),e->GetNode(3),e->GetNode(6));
AddNLinkNode(e->GetNode(3),e->GetNode(0),e->GetNode(7));
break;
default:
myCreateQuadratic = false;
break;
}
}
}
}
}
}
if ( nbOldLinks == myNLinkNodeMap.size() )
myCreateQuadratic = false;
if(!myCreateQuadratic) {
myNLinkNodeMap.clear();
}
SetSubShape( aSh );
return myCreateQuadratic;
}
示例2: Compute
//.........这里部分代码省略.........
int nbSeg = ngMesh->GetNSeg();
int nbFac = ngMesh->GetNSE();
int nbVol = ngMesh->GetNE();
MESSAGE((err ? "Mesh Generation failure" : "End of Mesh Generation") <<
", nb nodes: " << nbNod <<
", nb segments: " << nbSeg <<
", nb faces: " << nbFac <<
", nb volumes: " << nbVol);
// -----------------------------------------------------------
// Feed back the SMESHDS with the generated Nodes and Elements
// -----------------------------------------------------------
SMESHDS_Mesh* meshDS = _mesh->GetMeshDS();
bool isOK = ( !err && (_isVolume ? (nbVol > 0) : (nbFac > 0)) );
if ( true /*isOK*/ ) // get whatever built
{
// map of nodes assigned to submeshes
NCollection_Map<int> pindMap;
// create and insert nodes into nodeVec
nodeVec.resize( nbNod + 1 );
int i;
for (i = nbInitNod+1; i <= nbNod /*&& isOK*/; ++i )
{
const netgen::MeshPoint& ngPoint = ngMesh->Point(i);
SMDS_MeshNode* node = NULL;
bool newNodeOnVertex = false;
TopoDS_Vertex aVert;
if (i-nbInitNod <= occgeo.vmap.Extent())
{
// point on vertex
aVert = TopoDS::Vertex(occgeo.vmap(i-nbInitNod));
SMESHDS_SubMesh * submesh = meshDS->MeshElements(aVert);
if (submesh)
{
SMDS_NodeIteratorPtr it = submesh->GetNodes();
if (it->more())
{
node = const_cast<SMDS_MeshNode*> (it->next());
pindMap.Add(i);
}
}
if (!node)
newNodeOnVertex = true;
}
if (!node)
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
if (!node)
{
MESSAGE("Cannot create a mesh node");
if ( !comment.size() ) comment << "Cannot create a mesh node";
nbSeg = nbFac = nbVol = isOK = 0;
break;
}
nodeVec.at(i) = node;
if (newNodeOnVertex)
{
// point on vertex
meshDS->SetNodeOnVertex(node, aVert);
pindMap.Add(i);
}
}
// create mesh segments along geometric edges
NCollection_Map<Link> linkMap;
示例3: helper
bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume);
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
const int invalid_ID = -1;
SMESH::Controls::Area areaControl;
SMESH::Controls::TSequenceOfXYZ nodesCoords;
// -------------------------------------------------------------------
// get triangles on aShell and make a map of nodes to Netgen node IDs
// -------------------------------------------------------------------
SMESH_MesherHelper helper(aMesh);
SMESH_MesherHelper* myTool = &helper;
bool _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
TNodeToIDMap nodeToNetgenID;
list< const SMDS_MeshElement* > triangles;
list< bool > isReversed; // orientation of triangles
TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType();
bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID );
// for the degeneraged edge: ignore all but one node on it;
// map storing ids of degen edges and vertices and their netgen id:
map< int, int* > degenShapeIdToPtrNgId;
map< int, int* >::iterator shId_ngId;
list< int > degenNgIds;
StdMeshers_QuadToTriaAdaptor Adaptor;
Adaptor.Compute(aMesh,aShape);
for (TopExp_Explorer exp(aShape,TopAbs_FACE); exp.More(); exp.Next())
{
const TopoDS_Shape& aShapeFace = exp.Current();
const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements( aShapeFace );
if ( aSubMeshDSFace )
{
bool isRev = false;
if ( checkReverse && helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 )
// IsReversedSubMesh() can work wrong on strongly curved faces,
// so we use it as less as possible
isRev = SMESH_Algo::IsReversedSubMesh( TopoDS::Face(aShapeFace), meshDS );
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
while ( iteratorElem->more() ) // loop on elements on a face
{
// check element
const SMDS_MeshElement* elem = iteratorElem->next();
if ( !elem )
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 ));
if ( !isTraingle ) {
//return error( COMPERR_BAD_INPUT_MESH,
// SMESH_Comment("Not triangle element ")<<elem->GetID());
// using adaptor
const list<const SMDS_FaceOfNodes*>* faces = Adaptor.GetTriangles(elem);
if(faces==0) {
return error( COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Not triangles in adaptor for element ")<<elem->GetID());
}
list<const SMDS_FaceOfNodes*>::const_iterator itf = faces->begin();
for(; itf!=faces->end(); itf++ ) {
triangles.push_back( (*itf) );
isReversed.push_back( isRev );
// put triange's nodes to nodeToNetgenID map
SMDS_ElemIteratorPtr triangleNodesIt = (*itf)->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 ));
}
}
}
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 ) {
//.........这里部分代码省略.........
示例4: SetShape
void SMESHDS_GroupOnGeom::SetShape( const TopoDS_Shape& theShape)
{
SMESHDS_Mesh* aMesh = const_cast<SMESHDS_Mesh*>( GetMesh() );
mySubMesh = aMesh->MeshElements( aMesh->AddCompoundSubmesh( theShape ));
myShape = theShape;
}
示例5: 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 )
//.........这里部分代码省略.........
示例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 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;
}
示例7: helper
bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
netgen::multithread.terminate = 0;
//netgen::multithread.task = "Surface meshing";
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
SMESH_MesherHelper helper(aMesh);
helper.SetElementsOnShape( true );
NETGENPlugin_NetgenLibWrapper ngLib;
ngLib._isComputeOk = false;
netgen::Mesh ngMeshNoLocSize;
#if NETGEN_VERSION < 6
netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib._ngMesh, & ngMeshNoLocSize };
#else
netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib._ngMesh.get(), & ngMeshNoLocSize };
#endif
netgen::OCCGeometry occgeoComm;
// min / max sizes are set as follows:
// if ( _hypParameters )
// min and max are defined by the user
// else if ( _hypLengthFromEdges )
// min = aMesher.GetDefaultMinSize()
// max = average segment len of a FACE
// else if ( _hypMaxElementArea )
// min = aMesher.GetDefaultMinSize()
// max = f( _hypMaxElementArea )
// else
// min = aMesher.GetDefaultMinSize()
// max = max segment len of a FACE
NETGENPlugin_Mesher aMesher( &aMesh, aShape, /*isVolume=*/false);
aMesher.SetParameters( _hypParameters ); // _hypParameters -> netgen::mparam
const bool toOptimize = _hypParameters ? _hypParameters->GetOptimize() : true;
if ( _hypMaxElementArea )
{
netgen::mparam.maxh = sqrt( 2. * _hypMaxElementArea->GetMaxArea() / sqrt(3.0) );
}
if ( _hypQuadranglePreference )
netgen::mparam.quad = true;
// local size is common for all FACEs in aShape?
const bool isCommonLocalSize = ( !_hypLengthFromEdges && !_hypMaxElementArea && netgen::mparam.uselocalh );
const bool isDefaultHyp = ( !_hypLengthFromEdges && !_hypMaxElementArea && !_hypParameters );
if ( isCommonLocalSize ) // compute common local size in ngMeshes[0]
{
//list< SMESH_subMesh* > meshedSM[4]; --> all sub-shapes are added to occgeoComm
aMesher.PrepareOCCgeometry( occgeoComm, aShape, aMesh );//, meshedSM );
// local size set at MESHCONST_ANALYSE step depends on
// minh, face_maxh, grading and curvaturesafety; find minh if not set by the user
if ( !_hypParameters || netgen::mparam.minh < DBL_MIN )
{
if ( !_hypParameters )
netgen::mparam.maxh = occgeoComm.GetBoundingBox().Diam() / 3.;
netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh );
}
// set local size depending on curvature and NOT closeness of EDGEs
netgen::occparam.resthcloseedgeenable = false;
//netgen::occparam.resthcloseedgefac = 1.0 + netgen::mparam.grading;
occgeoComm.face_maxh = netgen::mparam.maxh;
netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] );
occgeoComm.emap.Clear();
occgeoComm.vmap.Clear();
// set local size according to size of existing segments
const double factor = netgen::occparam.resthcloseedgefac;
TopTools_IndexedMapOfShape edgeMap;
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;
//.........这里部分代码省略.........
示例8: len
StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
list<TopoDS_Edge>& theEdges,
SMESH_Mesh* theMesh,
const bool theIsForward,
const bool theIgnoreMediumNodes)
{
int nbEdges = theEdges.size();
myEdge.resize( nbEdges );
myC2d.resize( nbEdges );
myFirst.resize( nbEdges );
myLast.resize( nbEdges );
myNormPar.resize( nbEdges );
myLength = 0;
myNbPonits = myNbSegments = 0;
myMesh = theMesh;
myMissingVertexNodes = false;
myIgnoreMediumNodes = theIgnoreMediumNodes;
if ( nbEdges == 0 ) return;
SMESHDS_Mesh* meshDS = theMesh->GetMeshDS();
vector<double> len( nbEdges );
int nbDegen = 0;
list<TopoDS_Edge>::iterator edge = theEdges.begin();
for ( int index = 0; edge != theEdges.end(); ++index, ++edge )
{
int i = theIsForward ? index : nbEdges - index - 1;
len[i] = SMESH_Algo::EdgeLength( *edge );
if ( len[i] < DBL_MIN ) nbDegen++;
myLength += len[i];
myEdge[i] = *edge;
if ( !theIsForward ) myEdge[i].Reverse();
if ( theFace.IsNull() )
BRep_Tool::Range( *edge, myFirst[i], myLast[i] );
else
myC2d[i] = BRep_Tool::CurveOnSurface( *edge, theFace, myFirst[i], myLast[i] );
if ( myEdge[i].Orientation() == TopAbs_REVERSED )
std::swap( myFirst[i], myLast[i] );
if ( SMESHDS_SubMesh* sm = meshDS->MeshElements( *edge )) {
int nbN = sm->NbNodes();
if ( theIgnoreMediumNodes ) {
SMDS_ElemIteratorPtr elemIt = sm->GetElements();
if ( elemIt->more() && elemIt->next()->IsQuadratic() )
nbN -= sm->NbElements();
}
myNbPonits += nbN;
myNbSegments += sm->NbElements();
}
if ( SMESH_Algo::VertexNode( TopExp::FirstVertex( *edge, 1), meshDS ))
myNbPonits += 1; // for the first end
else
myMissingVertexNodes = true;
}
if ( SMESH_Algo::VertexNode( TopExp::LastVertex( theEdges.back(), 1), meshDS ))
myNbPonits++; // for the last end
else
myMissingVertexNodes = true;
if ( nbEdges > 1 && myLength > DBL_MIN ) {
const double degenNormLen = 1.e-5;
double totLength = myLength;
if ( nbDegen )
totLength += myLength * degenNormLen * nbDegen;
double prevNormPar = 0;
for ( int i = 0; i < nbEdges; ++i ) {
if ( len[ i ] < DBL_MIN )
len[ i ] = myLength * degenNormLen;
myNormPar[ i ] = prevNormPar + len[i]/totLength;
prevNormPar = myNormPar[ i ];
}
}
myNormPar[nbEdges-1] = 1.;
//dump();
}
示例9: if
const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
double constValue) const
{
if ( myPoints.empty() ) {
if ( NbEdges() == 0 ) return myPoints;
SMESHDS_Mesh* meshDS = myMesh->GetMeshDS();
// sort nodes of all edges putting them into a map
map< double, const SMDS_MeshNode*> u2node;
//int nbOnDegen = 0;
for ( int i = 0; i < myEdge.size(); ++i )
{
// put 1st vertex node
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices( myEdge[i], VFirst, VLast, true);
const SMDS_MeshNode* node = SMESH_Algo::VertexNode( VFirst, meshDS );
double prevNormPar = ( i == 0 ? 0 : myNormPar[ i-1 ]); // normalized param
if ( node ) { // internal nodes may be missing
u2node.insert( make_pair( prevNormPar, node ));
} else if ( i == 0 ) {
MESSAGE(" NO NODE on VERTEX" );
return myPoints;
}
// put 2nd vertex node for a last edge
if ( i+1 == myEdge.size() ) {
node = SMESH_Algo::VertexNode( VLast, meshDS );
if ( !node ) {
MESSAGE(" NO NODE on VERTEX" );
return myPoints;
}
u2node.insert( make_pair( 1., node ));
}
// put internal nodes
SMESHDS_SubMesh* sm = meshDS->MeshElements( myEdge[i] );
if ( !sm ) continue;
SMDS_NodeIteratorPtr nItr = sm->GetNodes();
double paramSize = myLast[i] - myFirst[i], r = myNormPar[i] - prevNormPar;
while ( nItr->more() ) {
const SMDS_MeshNode* node = nItr->next();
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double u = epos->GetUParameter();
// paramSize is signed so orientation is taken into account
double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize;
#ifdef _DEBUG_
if ( normPar > 1 || normPar < 0) {
dump("DEBUG");
MESSAGE ( "WRONG normPar: "<<normPar<< " prevNormPar="<<prevNormPar
<< " u="<<u << " myFirst[i]="<<myFirst[i]<< " myLast[i]="<<myLast[i]
<< " paramSize="<<paramSize );
}
#endif
u2node.insert( make_pair( normPar, node ));
}
}
if ( u2node.size() != myNbPonits ) {
MESSAGE("Wrong node parameters on edges, u2node.size():"
<<u2node.size()<<" != myNbPonits:"<<myNbPonits);
return myPoints;
}
// fill array of UVPtStruct
vector<uvPtStruct>* points = const_cast<vector<uvPtStruct>*>( &myPoints );
points->resize( myNbPonits );
int EdgeIndex = 0;
double prevNormPar = 0, paramSize = myNormPar[ EdgeIndex ];
map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin();
for (int i = 0 ; u_node != u2node.end(); ++u_node, ++i ) {
UVPtStruct & uvPt = (*points)[i];
uvPt.node = u_node->second;
uvPt.x = uvPt.y = uvPt.normParam = u_node->first;
if ( isXConst ) uvPt.x = constValue;
else uvPt.y = constValue;
if ( myNormPar[ EdgeIndex ] < uvPt.normParam ) {
prevNormPar = myNormPar[ EdgeIndex ];
++EdgeIndex;
#ifdef _DEBUG_
if ( EdgeIndex >= myEdge.size() ) {
dump("DEBUG");
MESSAGE ( "WRONg EdgeIndex " << 1+EdgeIndex
<< " myNormPar.size()="<<myNormPar.size()
<< " myNormPar["<< EdgeIndex<<"]="<< myNormPar[ EdgeIndex ]
<< " uvPt.normParam="<<uvPt.normParam );
}
#endif
paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
}
const SMDS_EdgePosition* epos =
dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition().get());
if ( epos ) {
uvPt.param = epos->GetUParameter();
//.........这里部分代码省略.........
示例10: 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 ||
//.........这里部分代码省略.........