本文整理汇总了C++中SMESHDS_Mesh::AddEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ SMESHDS_Mesh::AddEdge方法的具体用法?C++ SMESHDS_Mesh::AddEdge怎么用?C++ SMESHDS_Mesh::AddEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMESHDS_Mesh
的用法示例。
在下文中一共展示了SMESHDS_Mesh::AddEdge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddEdge
SMDS_MeshEdge* SMESH_MesherHelper::AddEdge(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const int id,
const bool force3d)
{
SMESHDS_Mesh * meshDS = GetMeshDS();
SMDS_MeshEdge* edge = 0;
if (myCreateQuadratic) {
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
if(id)
edge = meshDS->AddEdgeWithID(n1, n2, n12, id);
else
edge = meshDS->AddEdge(n1, n2, n12);
}
else {
if(id)
edge = meshDS->AddEdgeWithID(n1, n2, id);
else
edge = meshDS->AddEdge(n1, n2);
}
if ( mySetElemOnShape && myShapeID > 0 )
meshDS->SetMeshElementOnShape( edge, myShapeID );
return edge;
}
示例2: addEdge
PyObject* FemMeshPy::addEdge(PyObject *args)
{
int n1,n2;
if (!PyArg_ParseTuple(args, "ii",&n1,&n2))
return 0;
try {
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
if (!node1 || !node2)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshEdge* edge = meshDS->AddEdge(node1, node2);
if (!edge)
throw std::runtime_error("Failed to add edge");
return Py::new_reference_to(Py::Int(edge->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
return 0;
}
}
示例3: Compute
//.........这里部分代码省略.........
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);
SMDS_MeshNode* node = nodeVec.at(pind);
nodes.push_back(node);
if (pind <= nbInitNod || pindMap.Contains(pind))
continue;
if (!aFace.IsNull())
{
示例4: addEdge
PyObject* FemMeshPy::addEdge(PyObject *args)
{
SMESH_Mesh* mesh = getFemMeshPtr()->getSMesh();
SMESHDS_Mesh* meshDS = mesh->GetMeshDS();
int n1,n2;
if (PyArg_ParseTuple(args, "ii",&n1,&n2)) {
try {
const SMDS_MeshNode* node1 = meshDS->FindNode(n1);
const SMDS_MeshNode* node2 = meshDS->FindNode(n2);
if (!node1 || !node2)
throw std::runtime_error("Failed to get node of the given indices");
SMDS_MeshEdge* edge = meshDS->AddEdge(node1, node2);
if (!edge)
throw std::runtime_error("Failed to add edge");
return Py::new_reference_to(Py::Long(edge->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
return 0;
}
}
PyErr_Clear();
PyObject *obj;
int ElementId=-1;
if (PyArg_ParseTuple(args, "O!|i", &PyList_Type, &obj, &ElementId))
{
Py::List list(obj);
std::vector<const SMDS_MeshNode*> Nodes;
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
#if PY_MAJOR_VERSION >= 3
Py::Long NoNr(*it);
#else
Py::Int NoNr(*it);
#endif
const SMDS_MeshNode* node = meshDS->FindNode(NoNr);
if (!node)
throw std::runtime_error("Failed to get node of the given indices");
Nodes.push_back(node);
}
SMDS_MeshEdge* edge=0;
if(ElementId != -1) {
switch(Nodes.size()){
case 2:
edge = meshDS->AddEdgeWithID(Nodes[0],Nodes[1],ElementId);
if (!edge)
throw std::runtime_error("Failed to add edge with given ElementId");
break;
case 3:
edge = meshDS->AddEdgeWithID(Nodes[0],Nodes[1],Nodes[2],ElementId);
if (!edge)
throw std::runtime_error("Failed to add edge with given ElementId");
break;
default:
throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type
}
}
else {
switch(Nodes.size()){
case 2:
edge = meshDS->AddEdge(Nodes[0],Nodes[1]);
if (!edge)
throw std::runtime_error("Failed to add edge");
break;
case 3:
edge = meshDS->AddEdge(Nodes[0],Nodes[1],Nodes[2]);
if (!edge)
throw std::runtime_error("Failed to add edge");
break;
default:
throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type
}
}
#if PY_MAJOR_VERSION >= 3
return Py::new_reference_to(Py::Long(edge->GetID()));
#else
return Py::new_reference_to(Py::Int(edge->GetID()));
#endif
}
PyErr_SetString(PyExc_TypeError, "addEdge accepts:\n"
"-- int,int\n"
"-- [2|3],[int]\n");
return 0;
}
示例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 );
//.........这里部分代码省略.........