In practice the borders to sew often coincide and in this case it is
difficult to specify the first and the last nodes of a border since
they coincide with the first and the last nodes of the other
-border. To cope with this, manually \ref merging_nodes_page to fuse
-each pair of coincident nodes into one.
+border. To cope with this,
+\ref merging_nodes_page "merge" coincident nodes into one
+beforehand. Two figures below illustrate this approach.
+\image html sew_using_merge.png "Merge coincident nodes which are difficult to distinguish"
+<br>
+\image html sew_after_merge.png "After merging nodes it is easy to specify border nodes"
The sewing algorithm is as follows:
<ol>
SMESHDS_SubMesh::SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index)
{
myParent = parent;
- myElements.clear();
- myNodes.clear();
myIndex = index;
myUnusedIdNodes = 0;
myUnusedIdElements = 0;
//=======================================================================
//function : AddElement
-//purpose :
+//purpose :
//=======================================================================
void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
{
if (!IsComplexSubmesh())
+ {
+ if ( ME->GetType() == SMDSAbs_Node )
+ {
+ AddNode( static_cast< const SMDS_MeshNode* >( ME ));
+ return;
+ }
+ int oldShapeId = ME->getshapeId();
+ if ( oldShapeId > 0 )
{
- if ( ME->GetType() == SMDSAbs_Node )
+ if (oldShapeId != myIndex)
{
- AddNode( static_cast< const SMDS_MeshNode* >( ME ));
- return;
+ throw SALOME_Exception
+ (LOCALIZED("add element in subshape already belonging to a subshape"));
}
- int oldShapeId = ME->getshapeId();
- if ( oldShapeId > 0 )
+ int idInSubShape = ME->getIdInShape();
+ if (idInSubShape >= 0)
+ {
+ MESSAGE("add element in subshape already belonging to that subshape "
+ << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
+ // check if ok: do nothing if ok
+ if (idInSubShape >= myElements.size())
{
- if (oldShapeId != myIndex)
- {
- MESSAGE("add element in subshape already belonging to another subshape "
- << ME->GetID() << " " << oldShapeId << " " << myIndex);
- throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
- }
- else
- {
- int idInSubShape = ME->getIdInShape();
- if (idInSubShape >= 0)
- {
- MESSAGE("add element in subshape already belonging to that subshape "
- << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
- // check if ok: do nothing if ok
- if (idInSubShape >= myElements.size())
- {
- MESSAGE("out of bounds " << idInSubShape << " " << myElements.size());
- throw SALOME_Exception(LOCALIZED("out of bounds"));
- }
- if (ME != myElements[idInSubShape])
- {
- MESSAGE("not the same element");
- throw SALOME_Exception(LOCALIZED("not the same element"));
- }
- MESSAGE("already done, OK, nothing to do");
- return;
- }
- }
+ throw SALOME_Exception(LOCALIZED("out of bounds"));
}
-
- SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
- elem->setShapeId(myIndex);
- elem->setIdInShape(myElements.size());
- myElements.push_back(ME);
+ if (ME != myElements[idInSubShape])
+ {
+ throw SALOME_Exception(LOCALIZED("not the same element"));
+ }
+ return;
+ }
}
+
+ SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
+ elem->setShapeId(myIndex);
+ elem->setIdInShape(myElements.size());
+ myElements.push_back(ME);
+ }
}
//=======================================================================
//function : RemoveElement
-//purpose :
+//purpose :
//=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
//=======================================================================
//function : RemoveNode
-//purpose :
+//purpose :
//=======================================================================
bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
if (!ME)
return false;
- if (IsComplexSubmesh())
- {
- set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
- for (; aSubIt != mySubMeshes.end(); aSubIt++)
- if ((*aSubIt)->Contains(ME))
- return true;
- return false;
- }
+ if ( IsComplexSubmesh() )
+ {
+ set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
+ for (; aSubIt != mySubMeshes.end(); aSubIt++)
+ if ((*aSubIt)->Contains(ME))
+ return true;
+ return false;
+ }
if (ME->GetType() == SMDSAbs_Node)
- {
- int idInShape = ME->getIdInShape();
- if ((idInShape >= 0) && (idInShape < myNodes.size()))
- if (myNodes[idInShape] == ME)
- return true;
- }
+ {
+ int idInShape = ME->getIdInShape();
+ if ((idInShape >= 0) && (idInShape < myNodes.size()))
+ if (myNodes[idInShape] == ME)
+ return true;
+ }
else
- {
- int idInShape = ME->getIdInShape();
- if ((idInShape >= 0) && (idInShape < myElements.size()))
- if (myElements[idInShape] == ME)
- return true;
- }
+ {
+ int idInShape = ME->getIdInShape();
+ if ((idInShape >= 0) && (idInShape < myElements.size()))
+ if (myElements[idInShape] == ME)
+ return true;
+ }
+ return false;
+}
+
+//=======================================================================
+//function : IsQuadratic
+//purpose : Return true if my 1st element is quadratic
+//=======================================================================
+
+bool SMESHDS_SubMesh::IsQuadratic() const
+{
+ if ( IsComplexSubmesh() )
+ {
+ set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
+ for (; aSubIt != mySubMeshes.end(); aSubIt++)
+ if ((*aSubIt)->IsQuadratic())
+ return true;
+ return false;
+ }
+
+ for ( size_t i = 0; i < myElements.size(); ++i )
+ if ( myElements[i] )
+ return myElements[i]->IsQuadratic();
+
return false;
}
virtual int NbNodes() const;
virtual SMDS_NodeIteratorPtr GetNodes() const;
virtual bool Contains(const SMDS_MeshElement * ME) const; // check if elem or node is in
+ virtual bool IsQuadratic() const;
// clear the contents
virtual void Clear();
- int getSize();
+ int getSize();
void compactList();
SMESHDS_Mesh* GetParent() const { return const_cast< SMESHDS_Mesh*>( myParent ); }
int GetID() const { return myIndex; }
private:
- SMESHDS_Mesh * myParent;
+ SMESHDS_Mesh * myParent;
std::vector<const SMDS_MeshElement*> myElements;
- std::vector<const SMDS_MeshNode*> myNodes;
+ std::vector<const SMDS_MeshNode*> myNodes;
int myUnusedIdNodes;
int myUnusedIdElements;
if not "ViscousLayers" in self.GetCompatibleHypothesis():
raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
if faces and isinstance( faces[0], geomBuilder.GEOM._objref_GEOM_Object ):
- import GEOM
- faceIDs = [self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in faces]
+ faceIDs = []
+ for shape in faces:
+ ff = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["FACE"] )
+ for f in ff:
+ faceIDs.append( self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f))
faces = faceIDs
hyp = self.Hypothesis("ViscousLayers",
[thickness, numberOfLayers, stretchFactor, faces, isFacesToIgnore],
if not "ViscousLayers2D" in self.GetCompatibleHypothesis():
raise TypeError, "ViscousLayers2D are not supported by %s"%self.algo.GetName()
if edges and isinstance( edges[0], geomBuilder.GEOM._objref_GEOM_Object ):
- edges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in edges ]
+ edgeIDs = []
+ for shape in edges:
+ ee = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["EDGE"])
+ for e in ee:
+ edgeIDs.append( self.mesh.geompyD.GetSubShapeID( self.mesh.geom, e ))
+ edges = edgeIDs
hyp = self.Hypothesis("ViscousLayers2D",
[thickness, numberOfLayers, stretchFactor, edges, isEdgesToIgnore],
toAdd=False)
StdMeshers_FaceSide* me = const_cast< StdMeshers_FaceSide* >( this );
SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
- SMESH_MesherHelper helper( *myProxyMesh->GetMesh() );
+ SMESH_MesherHelper eHelper( *myProxyMesh->GetMesh() );
+ SMESH_MesherHelper fHelper( *myProxyMesh->GetMesh() );
+ fHelper.SetSubShape( myFace );
bool paramOK;
double eps = 1e-100;
const double prevNormPar = ( iE == 0 ? 0 : myNormPar[ iE-1 ]); // normalized param
if ( node ) // nodes on internal vertices may be missing
{
- if ( vertexNodes.insert( node ).second )
+ if ( vertexNodes.insert( node ).second ||
+ fHelper.IsRealSeam( node->getshapeId() ))
u2node.insert( u2node.end(), make_pair( prevNormPar, node ));
}
else if ( iE == 0 )
u2nodeVec.clear();
double paramSize = myLast[iE] - myFirst[iE];
double r = myNormPar[iE] - prevNormPar;
- helper.SetSubShape( myEdge[iE] );
- helper.ToFixNodeParameters( true );
+ eHelper.SetSubShape( myEdge[iE] );
+ eHelper.ToFixNodeParameters( true );
if ( !myIsUniform[iE] )
for ( size_t i = 0; i < nodes.size(); ++i )
{
- double u = helper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
+ double u = eHelper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
double aLenU = GCPnts_AbscissaPoint::Length( me->myC3dAdaptor[iE], myFirst[iE], u );
if ( myEdgeLength[iE] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6"
{
if ( u2nodeVec.empty() )
for ( size_t i = 0; i < nodes.size(); ++i )
{
- double u = helper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
+ double u = eHelper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
// paramSize is signed so orientation is taken into account
double normPar = prevNormPar + r * ( u - myFirst[iE] ) / paramSize;
u2nodeVec.push_back( make_pair( normPar, nodes[i] ));
}
} // loop on myEdge's
- if ( u2node.empty() ) return myPoints;
-
// Add 2nd VERTEX node for a last EDGE
+ if ( !proxySubMesh.back() )
{
+ if ( u2node.empty() ) return myPoints;
+
const SMDS_MeshNode* node;
if ( IsClosed() )
node = u2node.begin()->second;
if ( NbEdges() == 0 ) return resultNodes;
SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
- SMESH_MesherHelper helper(*myProxyMesh->GetMesh());
+ SMESH_MesherHelper eHelper( *myProxyMesh->GetMesh() );
+ SMESH_MesherHelper fHelper( *myProxyMesh->GetMesh() );
+ fHelper.SetSubShape( myFace );
bool paramOK = true;
// Sort nodes of all edges putting them into a map
// Add 1st vertex node of a current EDGE
const SMDS_MeshNode* node = VertexNode( iE );
if ( node ) { // nodes on internal vertices may be missing
- if ( vertexNodes.insert( node ).second )
+ if ( vertexNodes.insert( node ).second ||
+ fHelper.IsRealSeam( node->getshapeId() ))
u2node.insert( make_pair( prevNormPar, node ));
}
else if ( iE == 0 )
{
double paramSize = myLast[iE] - myFirst[iE];
double r = myNormPar[iE] - prevNormPar;
- helper.SetSubShape( myEdge[iE] );
- helper.ToFixNodeParameters( true );
+ eHelper.SetSubShape( myEdge[iE] );
+ eHelper.ToFixNodeParameters( true );
for ( size_t i = 0; i < nodes.size(); ++i )
{
- double u = helper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
+ double u = eHelper.GetNodeU( myEdge[iE], nodes[i], 0, ¶mOK );
// paramSize is signed so orientation is taken into account
double normPar = prevNormPar + r * ( u - myFirst[iE] ) / paramSize;
u2node.insert( u2node.end(), make_pair( normPar, nodes[i] ));
if ( inlude1stVertex )
{
- const SMDS_MeshNode* n0 = VertexNode( i );
- if ( !n0 ) return false;
- nodes.push_back( n0 );
+ if ( const SMDS_MeshNode* n0 = VertexNode( i ))
+ nodes.push_back( n0 );
}
if ( sm && ( sm->NbElements() > 0 || sm->NbNodes() > 0 ))
if ( inludeLastVertex )
{
- const SMDS_MeshNode* n1 = VertexNode( i+1 );
- if ( !n1 ) return false;
- nodes.push_back( n1 );
+ if ( const SMDS_MeshNode* n1 = VertexNode( i+1 ))
+ nodes.push_back( n1 );
}
return true;
}
me->myNbSegments = 0;
me->myMissingVertexNodes = false;
+ vector<const SMDS_MeshNode*> nodes;
for ( int i = 0; i < NbEdges(); ++i )
{
- if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( Edge(i) )) {
- int nbN = sm->NbNodes();
- if ( sm->NbElements() > 0 ) {
- nbN = sm->NbElements() - 1; // nodes can be moved to other shapes by MergeNodes()
- if ( !myIgnoreMediumNodes &&
- sm->GetElements()->next()->IsQuadratic() )
- nbN += sm->NbElements();
+ if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( Edge(i) ))
+ {
+ if ( sm->NbNodes() == sm->NbElements() - 1 )
+ {
+ me->myNbPonits += sm->NbNodes();
+ if ( myIgnoreMediumNodes && sm->IsQuadratic() )
+ me->myNbPonits -= sm->NbElements();
+ }
+ else // nodes can be moved to other shapes by MergeNodes()
+ {
+ nodes.clear();
+ GetEdgeNodes( i, nodes, /*v1=*/false, /*v2=*/false );
+ me->myNbPonits += nodes.size();
}
- me->myNbPonits += nbN;
me->myNbSegments += sm->NbElements();
}
}
+ SMESH_MesherHelper helper( *myProxyMesh->GetMesh() );
+ helper.SetSubShape( myFace );
+
std::set< const SMDS_MeshNode* > vNodes;
- for ( int i = 0; i <= NbEdges(); ++i )
+ for ( int i = 0; i <= NbEdges(); ++i ) // nb VERTEXes is more than NbEdges() if !IsClosed()
if ( const SMDS_MeshNode* n = VertexNode( i ))
- vNodes.insert( n );
+ {
+ if ( !vNodes.insert( n ).second &&
+ helper.IsRealSeam( n->getshapeId() ) &&
+ i < NbEdges())
+ me->myNbPonits++;
+ }
else
+ {
me->myMissingVertexNodes = true;
+ }
me->myNbPonits += vNodes.size();
if ( IsClosed() )
if ( !tgtNodes.empty() )
{
vector< const SMDS_MeshNode* >::iterator tn = tgtNodes.begin();
- if ( srcWire->Edge(iE).Orientation() == tgtWire->Edge(iE).Orientation() )
+ //if ( srcWire->Edge(iE).Orientation() == tgtWire->Edge(iE).Orientation() )
{
vector< const SMDS_MeshNode* >::iterator sn = srcNodes.begin();
for ( ; tn != tgtNodes.end(); ++tn, ++sn)
src2tgtNodes.insert( make_pair( *sn, *tn ));
}
- else
- {
- vector< const SMDS_MeshNode* >::reverse_iterator sn = srcNodes.rbegin();
- for ( ; tn != tgtNodes.end(); ++tn, ++sn)
- src2tgtNodes.insert( make_pair( *sn, *tn ));
- }
+ // else
+ // {
+ // vector< const SMDS_MeshNode* >::reverse_iterator sn = srcNodes.rbegin();
+ // for ( ; tn != tgtNodes.end(); ++tn, ++sn)
+ // src2tgtNodes.insert( make_pair( *sn, *tn ));
+ // }
is1DComputed = true;
}
}
return error(COMPERR_BAD_SHAPE,
TComm("Face must have 4 sides but not ") << faceSide.NbEdges() );
- const int nbSegments = Max( faceSide.NbPoints()-1, faceSide.NbSegments() );
- if ( nbSegments < nbCorners )
- return error(COMPERR_BAD_INPUT_MESH, TComm("Too few boundary nodes: ") << nbSegments);
+ if ( theConsiderMesh )
+ {
+ const int nbSegments = Max( faceSide.NbPoints()-1, faceSide.NbSegments() );
+ if ( nbSegments < nbCorners )
+ return error(COMPERR_BAD_INPUT_MESH, TComm("Too few boundary nodes: ") << nbSegments);
+ }
if ( nbCorners == 3 )
{