本文整理汇总了C++中SMDS_NodeIteratorPtr类的典型用法代码示例。如果您正苦于以下问题:C++ SMDS_NodeIteratorPtr类的具体用法?C++ SMDS_NodeIteratorPtr怎么用?C++ SMDS_NodeIteratorPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMDS_NodeIteratorPtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSortedNodesOnEdge
bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
const bool ignoreMediumNodes,
map< double, const SMDS_MeshNode* > & theNodes)
{
theNodes.clear();
if ( !theMesh || theEdge.IsNull() )
return false;
SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
if ( !eSubMesh || !eSubMesh->GetElements()->more() )
return false; // edge is not meshed
int nbNodes = 0;
set < double > paramSet;
if ( eSubMesh )
{
// loop on nodes of an edge: sort them by param on edge
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() )
{
const SMDS_MeshNode* node = nIt->next();
if ( ignoreMediumNodes ) {
SMDS_ElemIteratorPtr elemIt = node->GetInverseElementIterator();
if ( elemIt->more() && elemIt->next()->IsMediumNode( node ))
continue;
}
const SMDS_PositionPtr& pos = node->GetPosition();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
theNodes.insert( make_pair( epos->GetUParameter(), node ));
++nbNodes;
}
}
// add vertex nodes
TopoDS_Vertex v1, v2;
TopExp::Vertices(theEdge, v1, v2);
const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh );
const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh );
Standard_Real f, l;
BRep_Tool::Range(theEdge, f, l);
if ( v1.Orientation() != TopAbs_FORWARD )
std::swap( f, l );
if ( n1 && ++nbNodes )
theNodes.insert( make_pair( f, n1 ));
if ( n2 && ++nbNodes )
theNodes.insert( make_pair( l, n2 ));
return theNodes.size() == nbNodes;
}
示例2: GetNodeParamOnEdge
bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
vector< double > & theParams)
{
theParams.clear();
if ( !theMesh || theEdge.IsNull() )
return false;
SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
if ( !eSubMesh || !eSubMesh->GetElements()->more() )
return false; // edge is not meshed
//int nbEdgeNodes = 0;
set < double > paramSet;
if ( eSubMesh )
{
// loop on nodes of an edge: sort them by param on edge
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() )
{
const SMDS_MeshNode* node = nIt->next();
const SMDS_PositionPtr& pos = node->GetPosition();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
if ( !paramSet.insert( epos->GetUParameter() ).second )
return false; // equal parameters
}
}
// add vertex nodes params
TopoDS_Vertex V1,V2;
TopExp::Vertices( theEdge, V1, V2);
if ( VertexNode( V1, theMesh ) &&
!paramSet.insert( BRep_Tool::Parameter(V1,theEdge) ).second )
return false; // there are equal parameters
if ( VertexNode( V2, theMesh ) &&
!paramSet.insert( BRep_Tool::Parameter(V2,theEdge) ).second )
return false; // there are equal parameters
// fill the vector
theParams.resize( paramSet.size() );
set < double >::iterator par = paramSet.begin();
vector< double >::iterator vecPar = theParams.begin();
for ( ; par != paramSet.end(); ++par, ++vecPar )
*vecPar = *par;
return theParams.size() > 1;
}
示例3: DefineNodes
void TaskCreateNodeSet::DefineNodes(const Base::Polygon2D &polygon,const Gui::ViewVolumeProjection &proj,bool inner)
{
const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(pcObject->FemMesh.getValue<Fem::FemMeshObject*>()->FemMesh.getValue().getSMesh())->GetMeshDS();
SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
Base::Vector3f pt2d;
if(! ui->checkBox_Add->isChecked())
tempSet.clear();
while (aNodeIter->more()) {
const SMDS_MeshNode* aNode = aNodeIter->next();
Base::Vector3f vec(aNode->X(),aNode->Y(),aNode->Z());
pt2d = proj(vec);
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == inner)
tempSet.insert(aNode->GetID());
}
MeshViewProvider->setHighlightNodes(tempSet);
}
示例4: getFemMeshPtr
Py::Dict FemMeshPy::getNodes(void) const
{
//int count = getFemMeshPtr()->getSMesh()->GetMeshDS()->NbNodes();
//Py::Tuple tup(count);
Py::Dict dict;
// get the actual transform of the FemMesh
Base::Matrix4D Mtrx = getFemMeshPtr()->getTransform();
SMDS_NodeIteratorPtr aNodeIter = getFemMeshPtr()->getSMesh()->GetMeshDS()->nodesIterator();
for (int i=0;aNodeIter->more();i++) {
const SMDS_MeshNode* aNode = aNodeIter->next();
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
int id = aNode->GetID();
dict[Py::Long(id)] = Py::asObject(new Base::VectorPy( vec ));
}
return dict;
}
示例5: MESSAGE
//.........这里部分代码省略.........
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;
for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i )
{
const netgen::Segment& seg = ngMesh->LineSegment(i);
示例6: helper
//.........这里部分代码省略.........
case TopAbs_FACE: { // FACE
// ----------------------
const TopoDS_Face& geomFace = TopoDS::Face( sm->GetSubShape() );
helper.SetSubShape( geomFace );
// Find solids the geomFace bounds
int solidID1 = 0, solidID2 = 0;
const TopTools_ListOfShape& ancestors = _mesh->GetAncestors( geomFace );
TopTools_ListIteratorOfListOfShape ancestorIt ( ancestors );
for ( ; ancestorIt.More(); ancestorIt.Next() )
{
const TopoDS_Shape & solid = ancestorIt.Value();
if ( solid.ShapeType() == TopAbs_SOLID ) {
int id = occgeom.somap.FindIndex ( solid );
if ( solidID1 && id != solidID1 ) solidID2 = id;
else solidID1 = id;
}
}
faceID++;
_faceDescriptors[ faceID ].first = solidID1;
_faceDescriptors[ faceID ].second = solidID2;
// Orient the face correctly in solidID1 (issue 0020206)
bool reverse = false;
if ( solidID1 ) {
TopoDS_Shape solid = occgeom.somap( solidID1 );
for ( TopExp_Explorer f( solid, TopAbs_FACE ); f.More(); f.Next() ) {
if ( geomFace.IsSame( f.Current() )) {
reverse = SMESH_Algo::IsReversedSubMesh( TopoDS::Face( f.Current()), helper.GetMeshDS() );
break;
}
}
}
// Add surface elements
SMDS_ElemIteratorPtr faces = smDS->GetElements();
while ( faces->more() ) {
const SMDS_MeshElement* f = faces->next();
if ( f->NbNodes() % 3 != 0 ) { // not triangle
for ( ancestorIt.Initialize(ancestors); ancestorIt.More(); ancestorIt.Next() )
if ( ancestorIt.Value().ShapeType() == TopAbs_SOLID ) {
sm = _mesh->GetSubMesh( ancestorIt.Value() );
break;
}
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle submesh"));
smError->myBadElements.push_back( f );
return false;
}
netgen::Element2d tri(3);
tri.SetIndex ( faceID );
for ( int i = 0; i < 3; ++i ) {
const SMDS_MeshNode* node = f->GetNode( i ), * inFaceNode=0;
if ( helper.IsSeamShape( node->GetPosition()->GetShapeId() ))
if ( helper.IsSeamShape( f->GetNodeWrap( i+1 )->GetPosition()->GetShapeId() ))
inFaceNode = f->GetNodeWrap( i-1 );
else
inFaceNode = f->GetNodeWrap( i+1 );
gp_XY uv = helper.GetNodeUV( geomFace, node, inFaceNode );
if ( reverse ) {
tri.GeomInfoPi(3-i).u = uv.X();
tri.GeomInfoPi(3-i).v = uv.Y();
tri.PNum (3-i) = ngNodeId( node, ngMesh, nodeNgIdMap );
} else {
tri.GeomInfoPi(i+1).u = uv.X();
tri.GeomInfoPi(i+1).v = uv.Y();
tri.PNum (i+1) = ngNodeId( node, ngMesh, nodeNgIdMap );
}
}
ngMesh.AddSurfaceElement (tri);
}
break;
} //
case TopAbs_VERTEX: { // VERTEX
// --------------------------
SMDS_NodeIteratorPtr nodeIt = smDS->GetNodes();
if ( nodeIt->more() )
ngNodeId( nodeIt->next(), ngMesh, nodeNgIdMap );
break;
}
default:;
} // switch
} // loop on submeshes
// fill nodeVec
nodeVec.resize( ngMesh.GetNP() + 1 );
TNode2IdMap::iterator node_NgId, nodeNgIdEnd = nodeNgIdMap.end();
for ( node_NgId = nodeNgIdMap.begin(); node_NgId != nodeNgIdEnd; ++node_NgId)
nodeVec[ node_NgId->second ] = (SMDS_MeshNode*) node_NgId->first;
return true;
}
示例7: DefineNodesCallback
void DefineNodesCallback(void * ud, SoEventCallback * n)
{
Fem::FemAnalysis *Analysis;
if(getConstraintPrerequisits(&Analysis))
return;
// show the wait cursor because this could take quite some time
Gui::WaitCursor wc;
// When this callback function is invoked we must in either case leave the edit mode
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud);
n->setHandled();
SbBool clip_inner;
std::vector<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
if (clPoly.size() < 3)
return;
if (clPoly.front() != clPoly.back())
clPoly.push_back(clPoly.front());
SoCamera* cam = view->getCamera();
SbViewVolume vv = cam->getViewVolume();
Gui::ViewVolumeProjection proj(vv);
Base::Polygon2D polygon;
for (std::vector<SbVec2f>::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it)
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId());
if(docObj.size() !=1)
return;
const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(dynamic_cast<Fem::FemMeshObject*>(docObj[0])->FemMesh.getValue().getSMesh())->GetMeshDS();
SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
Base::Vector3f pt2d;
std::set<int> IntSet;
for (int i=0;aNodeIter->more();) {
const SMDS_MeshNode* aNode = aNodeIter->next();
Base::Vector3f vec(aNode->X(),aNode->Y(),aNode->Z());
pt2d = proj(vec);
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == true)
IntSet.insert(aNode->GetID());
}
std::stringstream set;
set << "[";
for(std::set<int>::const_iterator it=IntSet.begin();it!=IntSet.end();++it)
if(it==IntSet.begin())
set << *it ;
else
set << "," << *it ;
set << "]";
Gui::Command::openCommand("Place robot");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.addObject('Fem::FemSetNodesObject','NodeSet')");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.ActiveObject.Nodes = %s",set.str().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().NodeSet]",Analysis->getNameInDocument(),Analysis->getNameInDocument());
////Gui::Command::updateActive();
Gui::Command::commitCommand();
//std::vector<Gui::ViewProvider*> views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId());
//if (!views.empty()) {
// Gui::Application::Instance->activeDocument()->openCommand("Cut");
// for (std::vector<Gui::ViewProvider*>::iterator it = views.begin(); it != views.end(); ++it) {
// ViewProviderMesh* that = static_cast<ViewProviderMesh*>(*it);
// if (that->getEditingMode() > -1) {
// that->finishEditing();
// that->cutMesh(clPoly, *view, clip_inner);
// }
// }
// Gui::Application::Instance->activeDocument()->commitCommand();
// view->render();
//}
}
示例8: exp
//.........这里部分代码省略.........
// sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
// return false;
// }
}
else {
RETURN_BAD_RESULT( "Wrong nb face nodes: " <<
sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
}
}
// IJ size
int vsize = sm1->NbNodes() + 2;
int hsize = smb->NbNodes() + 2;
if(isQuadraticMesh) {
vsize = vsize - sm1->NbNodes()/2 -1;
hsize = hsize - smb->NbNodes()/2 -1;
}
// load nodes from theBaseEdge
std::set<const SMDS_MeshNode*> loadedNodes;
const SMDS_MeshNode* nullNode = 0;
std::vector<const SMDS_MeshNode*> & nVecf = theParam2ColumnMap[ 0.];
nVecf.resize( vsize, nullNode );
loadedNodes.insert( nVecf[ 0 ] = smVfb->GetNodes()->next() );
std::vector<const SMDS_MeshNode*> & nVecl = theParam2ColumnMap[ 1.];
nVecl.resize( vsize, nullNode );
loadedNodes.insert( nVecl[ 0 ] = smVlb->GetNodes()->next() );
double f, l;
BRep_Tool::Range( eFrw, f, l );
double range = l - f;
SMDS_NodeIteratorPtr nIt = smb->GetNodes();
const SMDS_MeshNode* node;
while ( nIt->more() ) {
node = nIt->next();
if(IsMedium(node, SMDSAbs_Edge))
continue;
const SMDS_EdgePosition* pos =
dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
if ( !pos ) {
return false;
}
double u = ( pos->GetUParameter() - f ) / range;
std::vector<const SMDS_MeshNode*> & nVec = theParam2ColumnMap[ u ];
nVec.resize( vsize, nullNode );
loadedNodes.insert( nVec[ 0 ] = node );
}
if ( theParam2ColumnMap.size() != hsize ) {
RETURN_BAD_RESULT( "Wrong node positions on theBaseEdge" );
}
// load nodes from e1
std::map< double, const SMDS_MeshNode*> sortedNodes; // sort by param on edge
nIt = sm1->GetNodes();
while ( nIt->more() ) {
node = nIt->next();
if(IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
if ( !pos ) {
return false;
}
示例9: createMesh
void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, SoCoordinate3* coords, SoIndexedFaceSet* faces) const
{
const Fem::PropertyFemMesh* mesh = static_cast<const Fem::PropertyFemMesh*>(prop);
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(mesh->getValue().getSMesh())->GetMeshDS();
const SMDS_MeshInfo& info = data->GetMeshInfo();
int numNode = info.NbNodes();
int numTria = info.NbTriangles();
int numQuad = info.NbQuadrangles();
//int numPoly = info.NbPolygons();
//int numVolu = info.NbVolumes();
int numTetr = info.NbTetras();
//int numHexa = info.NbHexas();
//int numPyrd = info.NbPyramids();
//int numPris = info.NbPrisms();
//int numHedr = info.NbPolyhedrons();
int index=0;
std::map<const SMDS_MeshNode*, int> mapNodeIndex;
// set the point coordinates
coords->point.setNum(numNode);
SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
unsigned int i=0;
SbVec3f* verts = coords->point.startEditing();
for (;aNodeIter->more();) {
const SMDS_MeshNode* aNode = aNodeIter->next();
verts[i++].setValue((float)aNode->X(),(float)aNode->Y(),(float)aNode->Z());
mapNodeIndex[aNode] = index++;
}
coords->point.finishEditing();
// set the face indices
index=0;
faces->coordIndex.setNum(4*numTria + 5*numQuad + 16*numTetr);
int32_t* indices = faces->coordIndex.startEditing();
SMDS_FaceIteratorPtr aFaceIter = data->facesIterator();
for (;aFaceIter->more();) {
const SMDS_MeshFace* aFace = aFaceIter->next();
int num = aFace->NbNodes();
if (num != 3 && num != 4)
continue;
for (int j=0; j<num;j++) {
const SMDS_MeshNode* node = aFace->GetNode(j);
indices[index++] = mapNodeIndex[node];
}
indices[index++] = SO_END_FACE_INDEX;
}
SMDS_VolumeIteratorPtr aVolIter = data->volumesIterator();
for (;aVolIter->more();) {
const SMDS_MeshVolume* aVol = aVolIter->next();
int num = aVol->NbNodes();
if (num != 4)
continue;
int i1 = mapNodeIndex[aVol->GetNode(0)];
int i2 = mapNodeIndex[aVol->GetNode(1)];
int i3 = mapNodeIndex[aVol->GetNode(2)];
int i4 = mapNodeIndex[aVol->GetNode(3)];
indices[index++] = i1;
indices[index++] = i3;
indices[index++] = i2;
indices[index++] = SO_END_FACE_INDEX;
indices[index++] = i1;
indices[index++] = i2;
indices[index++] = i4;
indices[index++] = SO_END_FACE_INDEX;
indices[index++] = i1;
indices[index++] = i4;
indices[index++] = i3;
indices[index++] = SO_END_FACE_INDEX;
indices[index++] = i2;
indices[index++] = i3;
indices[index++] = i4;
indices[index++] = SO_END_FACE_INDEX;
}
faces->coordIndex.finishEditing();
}
示例10: StlMesh_Mesh
//.........这里部分代码省略.........
hypoth.push_back(hyp1d);
}
if (regular) {
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++,0,meshgen);
hypoth.push_back(hyp1d);
}
StdMeshers_TrianglePreference* hyp2d_1 = new StdMeshers_TrianglePreference(hyp++,0,meshgen);
hypoth.push_back(hyp2d_1);
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++,0,meshgen);
hypoth.push_back(alg2d);
} break;
#endif
default:
break;
}
// Set new cout
MeshingOutput stdcout;
std::streambuf* oldcout = std::cout.rdbuf(&stdcout);
// Apply the hypothesis and create the mesh
mesh->ShapeToMesh(shape);
for (int i=0; i<hyp;i++)
mesh->AddHypothesis(shape, i);
meshgen->Compute(*mesh, mesh->GetShapeToMesh());
// Restore old cout
std::cout.rdbuf(oldcout);
// build up the mesh structure
SMDS_FaceIteratorPtr aFaceIter = mesh->GetMeshDS()->facesIterator();
SMDS_NodeIteratorPtr aNodeIter = mesh->GetMeshDS()->nodesIterator();
MeshCore::MeshPointArray verts;
MeshCore::MeshFacetArray faces;
verts.reserve(mesh->NbNodes());
faces.reserve(mesh->NbFaces());
int index=0;
std::map<const SMDS_MeshNode*, int> mapNodeIndex;
for (;aNodeIter->more();) {
const SMDS_MeshNode* aNode = aNodeIter->next();
MeshCore::MeshPoint p;
p.Set((float)aNode->X(), (float)aNode->Y(), (float)aNode->Z());
verts.push_back(p);
mapNodeIndex[aNode] = index++;
}
for (;aFaceIter->more();) {
const SMDS_MeshFace* aFace = aFaceIter->next();
if (aFace->NbNodes() == 3) {
MeshCore::MeshFacet f;
for (int i=0; i<3;i++) {
const SMDS_MeshNode* node = aFace->GetNode(i);
f._aulPoints[i] = mapNodeIndex[node];
}
faces.push_back(f);
}
else if (aFace->NbNodes() == 4) {
MeshCore::MeshFacet f1, f2;
const SMDS_MeshNode* node0 = aFace->GetNode(0);
const SMDS_MeshNode* node1 = aFace->GetNode(1);
const SMDS_MeshNode* node2 = aFace->GetNode(2);
const SMDS_MeshNode* node3 = aFace->GetNode(3);
示例11: make_pair
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();
//.........这里部分代码省略.........
示例12: switch
//.........这里部分代码省略.........
hypoth.push_back(hyp1d);
}
if (regular) {
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++,0,meshgen);
hypoth.push_back(hyp1d);
}
StdMeshers_TrianglePreference* hyp2d_1 = new StdMeshers_TrianglePreference(hyp++,0,meshgen);
hypoth.push_back(hyp2d_1);
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++,0,meshgen);
hypoth.push_back(alg2d);
} break;
#endif
default:
break;
}
// Set new cout
MeshingOutput stdcout;
std::streambuf* oldcout = std::cout.rdbuf(&stdcout);
// Apply the hypothesis and create the mesh
mesh->ShapeToMesh(shape);
for (int i=0; i<hyp;i++)
mesh->AddHypothesis(shape, i);
meshgen->Compute(*mesh, mesh->GetShapeToMesh());
// Restore old cout
std::cout.rdbuf(oldcout);
// build up the mesh structure
SMDS_FaceIteratorPtr aFaceIter = mesh->GetMeshDS()->facesIterator();
SMDS_NodeIteratorPtr aNodeIter = mesh->GetMeshDS()->nodesIterator();
MeshCore::MeshPointArray verts;
MeshCore::MeshFacetArray faces;
verts.reserve(mesh->NbNodes());
faces.reserve(mesh->NbFaces());
int index=0;
std::map<const SMDS_MeshNode*, int> mapNodeIndex;
for (;aNodeIter->more();) {
const SMDS_MeshNode* aNode = aNodeIter->next();
MeshCore::MeshPoint p;
p.Set((float)aNode->X(), (float)aNode->Y(), (float)aNode->Z());
verts.push_back(p);
mapNodeIndex[aNode] = index++;
}
for (;aFaceIter->more();) {
const SMDS_MeshFace* aFace = aFaceIter->next();
if (aFace->NbNodes() == 3) {
MeshCore::MeshFacet f;
for (int i=0; i<3;i++) {
const SMDS_MeshNode* node = aFace->GetNode(i);
f._aulPoints[i] = mapNodeIndex[node];
}
faces.push_back(f);
}
else if (aFace->NbNodes() == 4) {
MeshCore::MeshFacet f1, f2;
const SMDS_MeshNode* node0 = aFace->GetNode(0);
const SMDS_MeshNode* node1 = aFace->GetNode(1);
const SMDS_MeshNode* node2 = aFace->GetNode(2);
const SMDS_MeshNode* node3 = aFace->GetNode(3);
示例13: next
const SMDS_MeshElement* next()
{
if ( myType == SMDSAbs_Node && (myNodeIt!=NULL) )
return myNodeIt->next();
const SMDS_MeshElement* res = myElem;
myElem = 0;
while ( (myElemIt!=NULL) && myElemIt->more() ) {
myElem = myElemIt->next();
if ( myElem && myElem->GetType() == myType )
break;
else
myElem = 0;
}
}
示例14: more
bool more()
{
if ( myType == SMDSAbs_Node && myNodeIt )
return myNodeIt->more();
return ( myElem != 0 );
}