-typedef double (SMDS_MeshNode::* TGetCoord)() const;
-typedef const char* TName;
-typedef const char* TUnit;
-
-static TUnit aUnit[3] = {"m","m","m"};
-
-static TGetCoord aXYZGetCoord[3] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Y,
- &SMDS_MeshNode::Z
-};
-static TName aXYZName[3] = {"x","y","z"};
-
-
-static TGetCoord aXYGetCoord[2] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Y
-};
-static TName aXYName[2] = {"x","y"};
-
-static TGetCoord aYZGetCoord[2] = {
- &SMDS_MeshNode::Y,
- &SMDS_MeshNode::Z
-};
-static TName aYZName[2] = {"y","z"};
-
-static TGetCoord aXZGetCoord[2] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Z
-};
-static TName aXZName[2] = {"x","z"};
-
-
-static TGetCoord aXGetCoord[1] = {
- &SMDS_MeshNode::X
-};
-static TName aXName[1] = {"x"};
-
-static TGetCoord aYGetCoord[1] = {
- &SMDS_MeshNode::Y
-};
-static TName aYName[1] = {"y"};
-
-static TGetCoord aZGetCoord[1] = {
- &SMDS_MeshNode::Z
-};
-static TName aZName[1] = {"z"};
-
-
-class TCoordHelper{
- SMDS_NodeIteratorPtr myNodeIter;
- const SMDS_MeshNode* myCurrentNode;
- TGetCoord* myGetCoord;
- TName* myName;
- TUnit* myUnit;
-public:
- TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
- TGetCoord* theGetCoord,
- TName* theName,
- TUnit* theUnit = aUnit):
- myNodeIter(theNodeIter),
- myGetCoord(theGetCoord),
- myName(theName),
- myUnit(theUnit)
- {}
- virtual ~TCoordHelper(){}
- bool Next(){
- return myNodeIter->more() &&
- (myCurrentNode = myNodeIter->next());
- }
- const SMDS_MeshNode* GetNode(){
- return myCurrentNode;
- }
- MED::TIntVector::value_type GetID(){
- return myCurrentNode->GetID();
- }
- MED::TFloatVector::value_type GetCoord(med_int theCoodId){
- return (myCurrentNode->*myGetCoord[theCoodId])();
- }
- MED::TStringVector::value_type GetName(med_int theDimId){
- return myName[theDimId];
- }
- MED::TStringVector::value_type GetUnit(med_int theDimId){
- return myUnit[theDimId];
+namespace{
+ typedef double (SMDS_MeshNode::* TGetCoord)() const;
+ typedef const char* TName;
+ typedef const char* TUnit;
+
+ // name length in a mesh must be equal to 16 :
+ // 1234567890123456
+ TName M = "m ";
+ TName X = "x ";
+ TName Y = "y ";
+ TName Z = "z ";
+
+ TUnit aUnit[3] = {M,M,M};
+
+ // 3 dim
+ TGetCoord aXYZGetCoord[3] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Y,
+ &SMDS_MeshNode::Z
+ };
+ TName aXYZName[3] = {X,Y,Z};
+
+ // 2 dim
+ TGetCoord aXYGetCoord[2] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Y
+ };
+ TName aXYName[2] = {X,Y};
+
+ TGetCoord aYZGetCoord[2] = {
+ &SMDS_MeshNode::Y,
+ &SMDS_MeshNode::Z
+ };
+ TName aYZName[2] = {Y,Z};
+
+ TGetCoord aXZGetCoord[2] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Z
+ };
+ TName aXZName[2] = {X,Z};
+
+ // 1 dim
+ TGetCoord aXGetCoord[1] = {
+ &SMDS_MeshNode::X
+ };
+ TName aXName[1] = {X};
+
+ TGetCoord aYGetCoord[1] = {
+ &SMDS_MeshNode::Y
+ };
+ TName aYName[1] = {Y};
+
+ TGetCoord aZGetCoord[1] = {
+ &SMDS_MeshNode::Z
+ };
+ TName aZName[1] = {Z};
+
+
+ class TCoordHelper{
+ SMDS_NodeIteratorPtr myNodeIter;
+ const SMDS_MeshNode* myCurrentNode;
+ TGetCoord* myGetCoord;
+ TName* myName;
+ TUnit* myUnit;
+ public:
+ TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
+ TGetCoord* theGetCoord,
+ TName* theName,
+ TUnit* theUnit = aUnit):
+ myNodeIter(theNodeIter),
+ myGetCoord(theGetCoord),
+ myName(theName),
+ myUnit(theUnit)
+ {}
+ virtual ~TCoordHelper(){}
+ bool Next(){
+ return myNodeIter->more() &&
+ (myCurrentNode = myNodeIter->next());
+ }
+ const SMDS_MeshNode* GetNode(){
+ return myCurrentNode;
+ }
+ MED::TIntVector::value_type GetID(){
+ return myCurrentNode->GetID();
+ }
+ MED::TFloatVector::value_type GetCoord(TInt theCoodId){
+ return (myCurrentNode->*myGetCoord[theCoodId])();
+ }
+ MED::TStringVector::value_type GetName(TInt theDimId){
+ return myName[theDimId];
+ }
+ MED::TStringVector::value_type GetUnit(TInt theDimId){
+ return myUnit[theDimId];
+ }
+ };
+ typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
+
+
+ //-------------------------------------------------------
+ /*!
+ * \brief Class helping to use either SMDS_0DElementIterator,
+ * SMDS_EdgeIterator, SMDS_FaceIterator or SMDS_VolumeIterator
+ * in the same code
+ */
+ //-------------------------------------------------------
+ struct TElemIterator
+ {
+ virtual const SMDS_MeshElement* next() = 0;
+ virtual ~TElemIterator() {}
+ };
+ typedef boost::shared_ptr<TElemIterator> PElemIterator;
+
+ template< class SMDSIteratorPtr > class TypedElemIterator: public TElemIterator
+ {
+ SMDSIteratorPtr myItPtr;
+ public:
+ TypedElemIterator(SMDSIteratorPtr it): myItPtr(it) {}
+ virtual const SMDS_MeshElement* next() {
+ if ( myItPtr->more() ) return myItPtr->next();
+ else return 0;
+ }
+ };
+ typedef TypedElemIterator< SMDS_0DElementIteratorPtr > T0DElementIterator;
+ typedef TypedElemIterator< SMDS_EdgeIteratorPtr > TEdgeIterator;
+ typedef TypedElemIterator< SMDS_FaceIteratorPtr > TFaceIterator;
+ typedef TypedElemIterator< SMDS_VolumeIteratorPtr > TVolumeIterator;
+
+ //-------------------------------------------------------
+ /*!
+ * \brief Structure describing element type
+ */
+ //-------------------------------------------------------
+ struct TElemTypeData
+ {
+ EEntiteMaillage _entity;
+ EGeometrieElement _geomType;
+ TInt _nbElems;
+ SMDSAbs_ElementType _smdsType;
+
+ TElemTypeData (EEntiteMaillage entity, EGeometrieElement geom, TInt nb, SMDSAbs_ElementType type)
+ : _entity(entity), _geomType(geom), _nbElems( nb ), _smdsType( type ) {}
+ };
+
+
+ typedef NCollection_DataMap< Standard_Address, int > TElemFamilyMap;
+ //typedef map<const SMDS_MeshElement *, int> TElemFamilyMap;
+
+ //================================================================================
+ /*!
+ * \brief Fills element to famaly ID map for element type.
+ * Removes all families of anElemType
+ */
+ //================================================================================
+
+ void fillElemFamilyMap( TElemFamilyMap & anElemFamMap,
+ list<DriverMED_FamilyPtr> & aFamilies,
+ const SMDSAbs_ElementType anElemType)
+ {
+ anElemFamMap.Clear();
+ //anElemFamMap.clear();
+ list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+ while ( aFamsIter != aFamilies.end() )
+ {
+ if ((*aFamsIter)->GetType() != anElemType) {
+ aFamsIter++;
+ }
+ else {
+ int aFamId = (*aFamsIter)->GetId();
+ const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
+ set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
+ for (; anElemsIter != anElems.end(); anElemsIter++)
+ {
+ anElemFamMap.Bind( (Standard_Address)*anElemsIter, aFamId );
+ //anElemFamMap[*anElemsIter] = aFamId;
+ }
+ // remove a family from the list
+ aFamilies.erase( aFamsIter++ );
+ }
+ }