本文整理汇总了C++中SMDS_NodeIteratorPtr::next方法的典型用法代码示例。如果您正苦于以下问题:C++ SMDS_NodeIteratorPtr::next方法的具体用法?C++ SMDS_NodeIteratorPtr::next怎么用?C++ SMDS_NodeIteratorPtr::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMDS_NodeIteratorPtr
的用法示例。
在下文中一共展示了SMDS_NodeIteratorPtr::next方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例4: 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);
}
示例5: getNodes
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;
}
示例6: Compute
//.........这里部分代码省略.........
", 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);
Link link(seg.p1, seg.p2);
if (linkMap.Contains(link))
continue;
示例7: fillNgMesh
bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
netgen::Mesh& ngMesh,
vector<SMDS_MeshNode*>& nodeVec,
const list< SMESH_subMesh* > & meshedSM)
{
TNode2IdMap nodeNgIdMap;
TopTools_MapOfShape visitedShapes;
SMESH_MesherHelper helper (*_mesh);
int faceID = occgeom.fmap.Extent();
_faceDescriptors.clear();
list< SMESH_subMesh* >::const_iterator smIt, smEnd = meshedSM.end();
for ( smIt = meshedSM.begin(); smIt != smEnd; ++smIt )
{
SMESH_subMesh* sm = *smIt;
if ( !visitedShapes.Add( sm->GetSubShape() ))
continue;
SMESHDS_SubMesh * smDS = sm->GetSubMeshDS();
switch ( sm->GetSubShape().ShapeType() )
{
case TopAbs_EDGE: { // EDGE
// ----------------------
const TopoDS_Edge& geomEdge = TopoDS::Edge( sm->GetSubShape() );
// Add ng segments for each not meshed face the edge bounds
TopTools_MapOfShape visitedAncestors;
const TopTools_ListOfShape& ancestors = _mesh->GetAncestors( geomEdge );
TopTools_ListIteratorOfListOfShape ancestorIt ( ancestors );
for ( ; ancestorIt.More(); ancestorIt.Next() )
{
const TopoDS_Shape & ans = ancestorIt.Value();
if ( ans.ShapeType() != TopAbs_FACE || !visitedAncestors.Add( ans ))
continue;
const TopoDS_Face& face = TopoDS::Face( ans );
int faceID = occgeom.fmap.FindIndex( face );
if ( faceID < 1 )
continue; // meshed face
// find out orientation of geomEdge within face
bool isForwad = false;
for ( TopExp_Explorer exp( face, TopAbs_EDGE ); exp.More(); exp.Next() ) {
if ( geomEdge.IsSame( exp.Current() )) {
isForwad = ( exp.Current().Orientation() == geomEdge.Orientation() );
break;
}
}
bool isQuad = smDS->GetElements()->next()->IsQuadratic();
// get all nodes from geomEdge
StdMeshers_FaceSide fSide( face, geomEdge, _mesh, isForwad, isQuad );
const vector<UVPtStruct>& points = fSide.GetUVPtStruct();
int i, nbSeg = fSide.NbSegments();
double otherSeamParam = 0;
helper.SetSubShape( face );
bool isSeam = helper.IsRealSeam( geomEdge );
if ( isSeam )
otherSeamParam =
helper.GetOtherParam( helper.GetPeriodicIndex() == 1 ? points[0].u : points[0].v );
// add segments
int prevNgId = ngNodeId( points[0].node, ngMesh, nodeNgIdMap );
for ( i = 0; i < nbSeg; ++i )
{
const UVPtStruct& p1 = points[ i ];
const UVPtStruct& p2 = points[ i+1 ];
netgen::Segment seg;
// ng node ids
seg.p1 = prevNgId;
seg.p2 = prevNgId = ngNodeId( p2.node, ngMesh, nodeNgIdMap );
// node param on curve
seg.epgeominfo[ 0 ].dist = p1.param;
seg.epgeominfo[ 1 ].dist = p2.param;
// uv on face
seg.epgeominfo[ 0 ].u = p1.u;
seg.epgeominfo[ 0 ].v = p1.v;
seg.epgeominfo[ 1 ].u = p2.u;
seg.epgeominfo[ 1 ].v = p2.v;
//seg.epgeominfo[ iEnd ].edgenr = edgeID; // = geom.emap.FindIndex(edge);
seg.si = faceID; // = geom.fmap.FindIndex (face);
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
ngMesh.AddSegment (seg);
if ( isSeam )
{
if ( helper.GetPeriodicIndex() == 1 ) {
seg.epgeominfo[ 0 ].u = otherSeamParam;
seg.epgeominfo[ 1 ].u = otherSeamParam;
swap (seg.epgeominfo[0].v, seg.epgeominfo[1].v);
} else {
//.........这里部分代码省略.........
示例8: 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();
//}
}
示例9: LoadNodeColumns
bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
const TopoDS_Face& theFace,
const TopoDS_Edge& theBaseEdge,
SMESHDS_Mesh* theMesh)
{
// get vertices of theBaseEdge
TopoDS_Vertex vfb, vlb, vft; // first and last, bottom and top vertices
TopoDS_Edge eFrw = TopoDS::Edge( theBaseEdge.Oriented( TopAbs_FORWARD ));
TopExp::Vertices( eFrw, vfb, vlb );
// find the other edges of theFace and orientation of e1
TopoDS_Edge e1, e2, eTop;
bool rev1, CumOri = false;
TopExp_Explorer exp( theFace, TopAbs_EDGE );
int nbEdges = 0;
for ( ; exp.More(); exp.Next() ) {
if ( ++nbEdges > 4 ) {
return false; // more than 4 edges in theFace
}
TopoDS_Edge e = TopoDS::Edge( exp.Current() );
if ( theBaseEdge.IsSame( e ))
continue;
TopoDS_Vertex vCommon;
if ( !TopExp::CommonVertex( theBaseEdge, e, vCommon ))
eTop = e;
else if ( vCommon.IsSame( vfb )) {
e1 = e;
vft = TopExp::LastVertex( e1, CumOri );
rev1 = vfb.IsSame( vft );
if ( rev1 )
vft = TopExp::FirstVertex( e1, CumOri );
}
else
e2 = e;
}
if ( nbEdges < 4 ) {
return false; // less than 4 edges in theFace
}
if ( e2.IsNull() && vfb.IsSame( vlb ))
e2 = e1;
// submeshes corresponding to shapes
SMESHDS_SubMesh* smFace = theMesh->MeshElements( theFace );
SMESHDS_SubMesh* smb = theMesh->MeshElements( theBaseEdge );
SMESHDS_SubMesh* smt = theMesh->MeshElements( eTop );
SMESHDS_SubMesh* sm1 = theMesh->MeshElements( e1 );
SMESHDS_SubMesh* sm2 = theMesh->MeshElements( e2 );
SMESHDS_SubMesh* smVfb = theMesh->MeshElements( vfb );
SMESHDS_SubMesh* smVlb = theMesh->MeshElements( vlb );
SMESHDS_SubMesh* smVft = theMesh->MeshElements( vft );
if (!smFace || !smb || !smt || !sm1 || !sm2 || !smVfb || !smVlb || !smVft ) {
RETURN_BAD_RESULT( "NULL submesh " <<smFace<<" "<<smb<<" "<<smt<<" "<<
sm1<<" "<<sm2<<" "<<smVfb<<" "<<smVlb<<" "<<smVft);
}
if ( smb->NbNodes() != smt->NbNodes() || sm1->NbNodes() != sm2->NbNodes() ) {
RETURN_BAD_RESULT(" Diff nb of nodes on opposite edges" );
}
if (smVfb->NbNodes() != 1 || smVlb->NbNodes() != 1 || smVft->NbNodes() != 1) {
RETURN_BAD_RESULT("Empty submesh of vertex");
}
// define whether mesh is quadratic
bool isQuadraticMesh = false;
SMDS_ElemIteratorPtr eIt = smFace->GetElements();
if ( !eIt->more() ) {
RETURN_BAD_RESULT("No elements on the face");
}
const SMDS_MeshElement* e = eIt->next();
isQuadraticMesh = e->IsQuadratic();
if ( sm1->NbNodes() * smb->NbNodes() != smFace->NbNodes() ) {
// check quadratic case
if ( isQuadraticMesh ) {
// what if there are quadrangles and triangles mixed?
// int n1 = sm1->NbNodes()/2;
// int n2 = smb->NbNodes()/2;
// int n3 = sm1->NbNodes() - n1;
// int n4 = smb->NbNodes() - n2;
// int nf = sm1->NbNodes()*smb->NbNodes() - n3*n4;
// if( nf != smFace->NbNodes() ) {
// MESSAGE( "Wrong nb face nodes: " <<
// 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;
//.........这里部分代码省略.........
示例10: 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();
}
示例11: createMesh
//.........这里部分代码省略.........
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);
f1._aulPoints[0] = mapNodeIndex[node0];
f1._aulPoints[1] = mapNodeIndex[node1];
f1._aulPoints[2] = mapNodeIndex[node2];
f2._aulPoints[0] = mapNodeIndex[node0];
f2._aulPoints[1] = mapNodeIndex[node2];
f2._aulPoints[2] = mapNodeIndex[node3];
faces.push_back(f1);
faces.push_back(f2);
示例12: 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();
//.........这里部分代码省略.........
示例13: createMesh
//.........这里部分代码省略.........
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);
f1._aulPoints[0] = mapNodeIndex[node0];
f1._aulPoints[1] = mapNodeIndex[node1];
f1._aulPoints[2] = mapNodeIndex[node2];
f2._aulPoints[0] = mapNodeIndex[node0];
f2._aulPoints[1] = mapNodeIndex[node2];
f2._aulPoints[2] = mapNodeIndex[node3];
faces.push_back(f1);
faces.push_back(f2);