#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
-#include "SMDS_VtkVolume.hxx"
#include "SMDS_Mesh.hxx"
-#include "utilities.h"
+#include <utilities.h>
#include <map>
#include <limits>
#include <numeric>
#include <algorithm>
-using namespace std;
-
namespace
{
// ======================================================
SaveFacet( SMDS_VolumeTool::Facet& facet ): myToRestore( facet )
{
mySaved = facet;
+ mySaved.myNodes.swap( facet.myNodes );
}
~SaveFacet()
{
if ( myToRestore.myIndex != mySaved.myIndex )
myToRestore = mySaved;
+ myToRestore.myNodes.swap( mySaved.myNodes );
}
};
//purpose : Set volume to iterate on
//=======================================================================
-bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume,
- const bool ignoreCentralNodes)
+bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume,
+ const bool ignoreCentralNodes,
+ const std::vector<const SMDS_MeshNode*>* otherNodes)
{
// reset fields
myVolume = 0;
myNbFaces = theVolume->NbFaces();
if ( myVolume->IsPoly() )
{
- myPolyedre = dynamic_cast<const SMDS_VtkVolume*>( myVolume );
+ myPolyedre = SMDS_Mesh::DownCast<SMDS_MeshVolume>( myVolume );
myPolyFacetOri.resize( myNbFaces, 0 );
}
// set nodes
- int iNode = 0;
myVolumeNodes.resize( myVolume->NbNodes() );
- SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
- while ( nodeIt->more() )
- myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ if ( otherNodes )
+ {
+ if ( otherNodes->size() != myVolumeNodes.size() )
+ return ( myVolume = 0 );
+ for ( size_t i = 0; i < otherNodes->size(); ++i )
+ if ( ! ( myVolumeNodes[i] = (*otherNodes)[0] ))
+ return ( myVolume = 0 );
+ }
+ else
+ {
+ myVolumeNodes.assign( myVolume->begin_nodes(), myVolume->end_nodes() );
+ }
// check validity
if ( !setFace(0) )
//purpose : Return a set of face nodes.
//=======================================================================
-bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
- set<const SMDS_MeshNode*>& theFaceNodes ) const
+bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
+ std::set<const SMDS_MeshNode*>& theFaceNodes ) const
{
if ( !setFace( faceIndex ))
return false;
{
ori = ( -minProj < maxProj ? -1 : +1 );
double convexity = std::min( -minProj, maxProj ) / std::max( -minProj, maxProj );
- convexity2face.insert( make_pair( convexity, iF * ori ));
+ convexity2face.insert( std::make_pair( convexity, iF * ori ));
}
}
if ( faceMostConvex < 0 ) // none facet has nodes on the same side
// compare orientation of links of the facet with myFwdLinks
ori = 0;
setFace( faceIndex );
- vector< NLink > links( myCurFace.myNbNodes ), links2;
+ std::vector< NLink > links( myCurFace.myNbNodes ), links2;
for ( int i = 0; i < myCurFace.myNbNodes && !ori; ++i )
{
NLink link( myCurFace.myNodes[i], myCurFace.myNodes[i+1] );
}
double size = cross.Magnitude();
- if ( size <= numeric_limits<double>::min() )
+ if ( size <= std::numeric_limits<double>::min() )
return false;
X = cross.x / size;
} else {
d2 = 0;
}
- vector<const SMDS_MeshNode*>::const_iterator i;
+ std::vector<const SMDS_MeshNode*>::const_iterator i;
for (int iface = 0; iface < myNbFaces; iface++)
{
from = to;
return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
}
- int minInd = min( theNode1Index, theNode2Index );
- int maxInd = max( theNode1Index, theNode2Index );
+ int minInd = std::min( theNode1Index, theNode2Index );
+ int maxInd = std::max( theNode1Index, theNode2Index );
if ( minInd < 0 || maxInd > (int)myVolumeNodes.size() - 1 || maxInd == minInd )
return false;
*/
//================================================================================
-int SMDS_VolumeTool::GetAllExistingFaces(vector<const SMDS_MeshElement*> & faces) const
+int SMDS_VolumeTool::GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces) const
{
faces.clear();
SaveFacet savedFacet( myCurFace );
*/
//================================================================================
-int SMDS_VolumeTool::GetAllExistingEdges(vector<const SMDS_MeshElement*> & edges) const
+int SMDS_VolumeTool::GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const
{
edges.clear();
edges.reserve( myVolumeNodes.size() * 2 );
//================================================================================
/*!
- * \brief fast check that only one volume is build on the face nodes
+ * \brief Fast quickly check that only one volume is built on the face nodes
* This check is valid for conformal meshes only
*/
//================================================================================
// int nb = myCurFace.myNbNodes;
// if ( myVolume->GetEntityType() != vol->GetEntityType() )
// nb -= ( GetCenterNodeIndex(0) > 0 );
- // set<const SMDS_MeshNode*> faceNodes( nodes, nodes + nb );
+ // std::set<const SMDS_MeshNode*> faceNodes( nodes, nodes + nb );
// if ( SMDS_VolumeTool( vol ).GetFaceIndex( faceNodes ) < 0 )
// continue;
// }
//================================================================================
/*!
- * \brief Thorough check that only one volume is build on the face nodes
+ * \brief Thorough check that only one volume is built on the face nodes
*/
//================================================================================
// evaluate nb of face nodes shared by other volumes
int maxNbShared = -1;
- typedef map< const SMDS_MeshElement*, int > TElemIntMap;
+ typedef std::map< const SMDS_MeshElement*, int > TElemIntMap;
TElemIntMap volNbShared;
TElemIntMap::iterator vNbIt;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
while ( eIt->more() ) {
const SMDS_MeshElement* elem = eIt->next();
if ( elem != myVolume ) {
- vNbIt = volNbShared.insert( make_pair( elem, 0 )).first;
+ vNbIt = volNbShared.insert( std::make_pair( elem, 0 )).first;
(*vNbIt).second++;
if ( vNbIt->second > maxNbShared )
maxNbShared = vNbIt->second;
//purpose : Return index of a face formed by theFaceNodes
//=======================================================================
-int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes,
+int SMDS_VolumeTool::GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes,
const int theFaceIndexHint ) const
{
if ( theFaceIndexHint >= 0 )
//purpose : Return index of a face formed by theFaceNodes
//=======================================================================
-/*int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices )
+/*int SMDS_VolumeTool::GetFaceIndex( const std::set<int>& theFaceNodesIndices )
{
for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
const int* nodes = GetFaceNodesIndices( iFace );
int nbFaceNodes = NbFaceNodes( iFace );
- set<int> nodeSet;
+ std::set<int> nodeSet;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
nodeSet.insert( nodes[ iNode ] );
if ( theFaceNodesIndices == nodeSet )
if (myVolume->IsPoly())
{
- if (!myPolyedre) {
+ if ( !myPolyedre ) {
MESSAGE("Warning: bad volumic element");
return false;
}