本文整理汇总了C++中SMESHDS_Mesh::SetNodeOnEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::SetNodeOnEdge方法的具体用法?C++ SMESHDS_Mesh::SetNodeOnEdge怎么用?C++ SMESHDS_Mesh::SetNodeOnEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::SetNodeOnEdge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNode
SMDS_MeshNode* SMESH_MesherHelper::AddNode(double x, double y, double z, int ID)
{
SMESHDS_Mesh * meshDS = GetMeshDS();
SMDS_MeshNode* node = 0;
if ( ID )
node = meshDS->AddNodeWithID( x, y, z, ID );
else
node = meshDS->AddNode( x, y, z );
if ( mySetElemOnShape && myShapeID > 0 ) {
switch ( myShape.ShapeType() ) {
case TopAbs_SOLID: meshDS->SetNodeInVolume( node, myShapeID); break;
case TopAbs_SHELL: meshDS->SetNodeInVolume( node, myShapeID); break;
case TopAbs_FACE: meshDS->SetNodeOnFace( node, myShapeID); break;
case TopAbs_EDGE: meshDS->SetNodeOnEdge( node, myShapeID); break;
case TopAbs_VERTEX: meshDS->SetNodeOnVertex( node, myShapeID); break;
default: ;
}
}
return node;
}
示例2: Compute
//.........这里部分代码省略.........
{
const netgen::Segment& seg = ngMesh->LineSegment(i);
Link link(seg.p1, seg.p2);
if (linkMap.Contains(link))
continue;
linkMap.Add(link);
TopoDS_Edge aEdge;
int pinds[3] = { seg.p1, seg.p2, seg.pmid };
int nbp = 0;
double param2 = 0;
for (int j=0; j < 3; ++j)
{
int pind = pinds[j];
if (pind <= 0) continue;
++nbp;
double param;
if (j < 2)
{
if (aEdge.IsNull())
{
int aGeomEdgeInd = seg.epgeominfo[j].edgenr;
if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent())
aEdge = TopoDS::Edge(occgeo.emap(aGeomEdgeInd));
}
param = seg.epgeominfo[j].dist;
param2 += param;
}
else
param = param2 * 0.5;
if (pind <= nbInitNod || pindMap.Contains(pind))
continue;
if (!aEdge.IsNull())
{
meshDS->SetNodeOnEdge(nodeVec.at(pind), aEdge, param);
pindMap.Add(pind);
}
}
SMDS_MeshEdge* edge;
if (nbp < 3) // second order ?
edge = meshDS->AddEdge(nodeVec.at(pinds[0]), nodeVec.at(pinds[1]));
else
edge = meshDS->AddEdge(nodeVec.at(pinds[0]), nodeVec.at(pinds[1]),
nodeVec.at(pinds[2]));
if (!edge)
{
if ( !comment.size() ) comment << "Cannot create a mesh edge";
MESSAGE("Cannot create a mesh edge");
nbSeg = nbFac = nbVol = isOK = 0;
break;
}
if (!aEdge.IsNull())
meshDS->SetMeshElementOnShape(edge, aEdge);
}
// create mesh faces along geometric faces
for (i = nbInitFac+1; i <= nbFac/* && isOK*/; ++i )
{
const netgen::Element2d& elem = ngMesh->SurfaceElement(i);
int aGeomFaceInd = elem.GetIndex();
TopoDS_Face aFace;
if (aGeomFaceInd > 0 && aGeomFaceInd <= occgeo.fmap.Extent())
aFace = TopoDS::Face(occgeo.fmap(aGeomFaceInd));
vector<SMDS_MeshNode*> nodes;
for (int j=1; j <= elem.GetNP(); ++j)
{
int pind = elem.PNum(j);
示例3: 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 );
//.........这里部分代码省略.........
示例4: GetMediumNode
//.........这里部分代码省略.........
// obtaining a face and 2d points for nodes
TopoDS_Face F;
if( myShape.IsNull() )
F = TopoDS::Face(meshDS->IndexToShape(faceID));
else {
F = TopoDS::Face(myShape);
faceID = myShapeID;
}
gp_XY p1 = GetNodeUV(F,n1,n2);
gp_XY p2 = GetNodeUV(F,n2,n1);
if ( IsDegenShape( Pos1->GetShapeId() ))
p1.SetCoord( myParIndex, p2.Coord( myParIndex ));
else if ( IsDegenShape( Pos2->GetShapeId() ))
p2.SetCoord( myParIndex, p1.Coord( myParIndex ));
//checking if surface is periodic
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
Standard_Real UF,UL,VF,VL;
S->Bounds(UF,UL,VF,VL);
Standard_Real u,v;
Standard_Boolean isUPeriodic = S->IsUPeriodic();
if(isUPeriodic) {
Standard_Real UPeriod = S->UPeriod();
Standard_Real p2x = p2.X()+ShapeAnalysis::AdjustByPeriod(p2.X(),p1.X(),UPeriod);
Standard_Real pmid = (p1.X()+p2x)/2.;
u = pmid+ShapeAnalysis::AdjustToPeriod(pmid,UF,UL);
}
else
u= (p1.X()+p2.X())/2.;
Standard_Boolean isVPeriodic = S->IsVPeriodic();
if(isVPeriodic) {
Standard_Real VPeriod = S->VPeriod();
Standard_Real p2y = p2.Y()+ShapeAnalysis::AdjustByPeriod(p2.Y(),p1.Y(),VPeriod);
Standard_Real pmid = (p1.Y()+p2y)/2.;
v = pmid+ShapeAnalysis::AdjustToPeriod(pmid,VF,VL);
}
else
v = (p1.Y()+p2.Y())/2.;
gp_Pnt P = S->Value(u, v);
n12 = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(n12, faceID, u, v);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
if (edgeID>-1 || shapeType == TopAbs_EDGE) {
TopoDS_Edge E;
if( myShape.IsNull() )
E = TopoDS::Edge(meshDS->IndexToShape(edgeID));
else {
E = TopoDS::Edge(myShape);
edgeID = myShapeID;
}
double p1 = GetNodeU(E,n1);
double p2 = GetNodeU(E,n2);
double f,l;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, f, l);
if(!C.IsNull()) {
Standard_Boolean isPeriodic = C->IsPeriodic();
double u;
if(isPeriodic) {
Standard_Real Period = C->Period();
Standard_Real p = p2+ShapeAnalysis::AdjustByPeriod(p2,p1,Period);
Standard_Real pmid = (p1+p)/2.;
u = pmid+ShapeAnalysis::AdjustToPeriod(pmid,C->FirstParameter(),C->LastParameter());
}
else
u = (p1+p2)/2.;
gp_Pnt P = C->Value( u );
n12 = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(n12, edgeID, u);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
}
}
// 3d variant
double x = ( n1->X() + n2->X() )/2.;
double y = ( n1->Y() + n2->Y() )/2.;
double z = ( n1->Z() + n2->Z() )/2.;
n12 = meshDS->AddNode(x,y,z);
if(edgeID>-1)
meshDS->SetNodeOnEdge(n12, edgeID);
else if(faceID>-1)
meshDS->SetNodeOnFace(n12, faceID);
else
meshDS->SetNodeInVolume(n12, myShapeID);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
}
示例5: error
//.........这里部分代码省略.........
itn = theNodes.begin();
for ( int i = Nodes1.size()-1; i > -1; ++itn, ++ritn, --i )
{
(*pNodes1)[i] = ritn->second;
(*pNodes2)[i] = itn->second;
Points.Append( gpXYZ( Nodes1[i]));
Pnts2d1.Append( myHelper->GetNodeUV( F, Nodes1[i]));
}
NC = const_cast<SMDS_MeshNode*>( itn->second );
Points.Remove( Nodes1.size() );
}
else
{
gp_Vec aVec(P0,P1);
int edgeID = meshDS->ShapeToIndex(LinEdge1);
// check orientation
Handle(Geom_Curve) Crv = BRep_Tool::Curve(LinEdge1,fp,lp);
gp_Pnt Ptmp;
Crv->D0(fp,Ptmp);
bool ori = true;
if( P1.Distance(Ptmp) > Precision::Confusion() )
ori = false;
// get UV points for edge
gp_Pnt2d PF,PL;
BRep_Tool::UVPoints( LinEdge1, TopoDS::Face(aShape), PF, PL );
PC = gp_Pnt2d( (PF.X()+PL.X())/2, (PF.Y()+PL.Y())/2 );
gp_Vec2d V2d;
if(ori) V2d = gp_Vec2d(PC,PF);
else V2d = gp_Vec2d(PC,PL);
// add nodes on edge
double cp = (fp+lp)/2;
double dp2 = (lp-fp)/2;
NC = meshDS->AddNode(P0.X(), P0.Y(), P0.Z());
meshDS->SetNodeOnEdge(NC, edgeID, cp);
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;
double param;
if(ori)
param = fp + dp2*(1-myLayerPositions[i]);
else
param = cp + dp2*myLayerPositions[i];
meshDS->SetNodeOnEdge(node, edgeID, param);
P = gp_Pnt( P0.X() - aVec.X()*myLayerPositions[i],
P0.Y() - aVec.Y()*myLayerPositions[i],
P0.Z() - aVec.Z()*myLayerPositions[i] );
node = meshDS->AddNode(P.X(), P.Y(), P.Z());
Nodes2[i] = node;
if(!ori)
param = fp + dp2*(1-myLayerPositions[i]);
else
param = cp + dp2*myLayerPositions[i];
meshDS->SetNodeOnEdge(node, edgeID, param);
// parameters on face
gp_Pnt2d P2d( PC.X() + V2d.X()*myLayerPositions[i],
PC.Y() + V2d.Y()*myLayerPositions[i] );
Pnts2d1.Append(P2d);
}
Nodes1[ myLayerPositions.size() ] = NF;