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
//purpose :
else e = mesh->AddFace (node[0], node[1], node[2], node[3],
node[4], node[5] );
else if (nbnode == 8)
- if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[2],
- node[3], node[4], node[5], node[2], ID);
- else e = mesh->AddFace (node[0], node[1], node[2], node[2],
- node[3], node[4], node[5], node[2] );
+ if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3],
+ node[4], node[5], node[6], node[7], ID);
+ else e = mesh->AddFace (node[0], node[1], node[2], node[3],
+ node[4], node[5], node[6], node[7] );
} else {
if ( ID ) e = mesh->AddPolygonalFaceWithID(node, ID);
else e = mesh->AddPolygonalFace (node );
}
+//=======================================================================
+/*!
+ * \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
//purpose :
};
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
// Return list of group of nodes close to each other within theTolerance.
// 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,
vector<const SMDS_MeshNode *>& poly_nodes,
vector<int>& quantities) const;