PAL13460 (PAL EDF 301 force the mesh to go through a point)

+  SMESH_NodeSearcher* GetNodeSearcher();
    fix AddElement() with 4 nodes
This commit is contained in:
eap 2007-02-26 13:39:01 +00:00
parent b20d6d4b1e
commit e406de3c30
2 changed files with 75 additions and 4 deletions

View File

@ -86,6 +86,10 @@ typedef map<const SMDS_MeshElement*, vector<TNodeOfNodeListMapItr> > TElemOfVecO
typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink; typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
struct TNodeXYZ : public gp_XYZ {
TNodeXYZ( const SMDS_MeshNode* n ):gp_XYZ( n->X(), n->Y(), n->Z() ) {}
};
//======================================================================= //=======================================================================
//function : SMESH_MeshEditor //function : SMESH_MeshEditor
//purpose : //purpose :
@ -134,10 +138,10 @@ SMESH_MeshEditor::AddElement(const vector<const SMDS_MeshNode*> & node,
else e = mesh->AddFace (node[0], node[1], node[2], node[3], else e = mesh->AddFace (node[0], node[1], node[2], node[3],
node[4], node[5] ); node[4], node[5] );
else if (nbnode == 8) else if (nbnode == 8)
if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[2], if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3],
node[3], node[4], node[5], node[2], ID); node[4], node[5], node[6], node[7], ID);
else e = mesh->AddFace (node[0], node[1], node[2], node[2], else e = mesh->AddFace (node[0], node[1], node[2], node[3],
node[3], node[4], node[5], node[2] ); node[4], node[5], node[6], node[7] );
} else { } else {
if ( ID ) e = mesh->AddPolygonalFaceWithID(node, ID); if ( ID ) e = mesh->AddPolygonalFaceWithID(node, ID);
else e = mesh->AddPolygonalFace (node ); else e = mesh->AddPolygonalFace (node );
@ -4301,6 +4305,57 @@ void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes
} }
//=======================================================================
/*!
* \brief Implementation of search for the node closest to point
*/
//=======================================================================
struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher
{
SMESH_NodeSearcherImpl( const SMESHDS_Mesh* theMesh )
{
set<const SMDS_MeshNode*> nodes;
if ( theMesh ) {
SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator();
while ( nIt->more() )
nodes.insert( nodes.end(), nIt->next() );
}
myOctreeNode = new SMESH_OctreeNode(nodes) ;
}
const SMDS_MeshNode* FindClosestTo( const gp_Pnt& thePnt )
{
SMDS_MeshNode tgtNode( thePnt.X(), thePnt.Y(), thePnt.Z() );
list<const SMDS_MeshNode*> nodes;
myOctreeNode->NodesAround( &tgtNode, &nodes, 1e-7);
const SMDS_MeshNode* closestNode = 0;
double minSqDist = DBL_MAX;
list<const SMDS_MeshNode*>::iterator nIt = nodes.begin();
for ( ; nIt != nodes.end(); ++nIt ) {
double sqDist = thePnt.SquareDistance( TNodeXYZ( *nIt ) );
if ( minSqDist > sqDist ) {
closestNode = *nIt;
minSqDist = sqDist;
}
}
return closestNode;
}
~SMESH_NodeSearcherImpl() { delete myOctreeNode; }
private:
SMESH_OctreeNode* myOctreeNode;
};
//=======================================================================
/*!
* \brief Return SMESH_NodeSearcher
*/
//=======================================================================
SMESH_NodeSearcher* SMESH_MeshEditor::GetNodeSearcher()
{
return new SMESH_NodeSearcherImpl( GetMeshDS() );
}
//======================================================================= //=======================================================================
//function : SimplifyFace //function : SimplifyFace
//purpose : //purpose :

View File

@ -67,6 +67,17 @@ struct TIDCompare {
}; };
typedef std::set< const SMDS_MeshElement*, TIDCompare< SMDS_MeshElement> > TIDSortedElemSet; typedef std::set< const SMDS_MeshElement*, TIDCompare< SMDS_MeshElement> > TIDSortedElemSet;
// ============================================================
/*!
* \brief Searcher for the node closest to point
*/
// ============================================================
struct SMESH_NodeSearcher
{
virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
};
// ============================================================ // ============================================================
/*! /*!
* \brief Editor of a mesh * \brief Editor of a mesh
@ -289,6 +300,11 @@ public:
// Return list of group of nodes close to each other within theTolerance. // Return list of group of nodes close to each other within theTolerance.
// Search among theNodes or in the whole mesh if theNodes is empty. // Search among theNodes or in the whole mesh if theNodes is empty.
/*!
* \brief Return SMESH_NodeSearcher
*/
SMESH_NodeSearcher* GetNodeSearcher();
int SimplifyFace (const vector<const SMDS_MeshNode *> faceNodes, int SimplifyFace (const vector<const SMDS_MeshNode *> faceNodes,
vector<const SMDS_MeshNode *>& poly_nodes, vector<const SMDS_MeshNode *>& poly_nodes,
vector<int>& quantities) const; vector<int>& quantities) const;