From: prascle Date: Mon, 25 Oct 2010 08:29:59 +0000 (+0000) Subject: PR: debug autotests in progress, still 87 bugs X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56c2e2996137a14f4573bad5cf23d2bcee292b7a;p=modules%2Fsmesh.git PR: debug autotests in progress, still 87 bugs --- diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 6116315ba..ac41f3310 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -223,11 +223,11 @@ bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem, if ( anElem->IsQuadratic() ) { switch ( anElem->GetType() ) { case SMDSAbs_Edge: - anIter = static_cast + anIter = dynamic_cast (anElem)->interlacedNodesElemIterator(); break; case SMDSAbs_Face: - anIter = static_cast + anIter = dynamic_cast (anElem)->interlacedNodesElemIterator(); break; default: @@ -1247,10 +1247,10 @@ void Length2D::GetValues(TValues& theValues){ const SMDS_MeshFace* anElem = anIter->next(); if(anElem->IsQuadratic()) { - const SMDS_QuadraticFaceOfNodes* F = - static_cast(anElem); + const SMDS_VtkFace* F = + dynamic_cast(anElem); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); long aNodeId[4]; gp_Pnt P[4]; @@ -1444,7 +1444,7 @@ void MultiConnection2D::GetValues(MValues& theValues){ const SMDS_MeshFace* anElem = anIter->next(); SMDS_ElemIteratorPtr aNodesIter; if ( anElem->IsQuadratic() ) - aNodesIter = static_cast + aNodesIter = dynamic_cast (anElem)->interlacedNodesElemIterator(); else aNodesIter = anElem->nodesIterator(); @@ -1603,7 +1603,7 @@ bool FreeEdges::IsSatisfy( long theId ) SMDS_ElemIteratorPtr anIter; if ( aFace->IsQuadratic() ) { - anIter = static_cast + anIter = dynamic_cast (aFace)->interlacedNodesElemIterator(); } else { @@ -1672,7 +1672,7 @@ void FreeEdges::GetBoreders(TBorders& theBorders) long anElemId = anElem->GetID(); SMDS_ElemIteratorPtr aNodesIter; if ( anElem->IsQuadratic() ) - aNodesIter = static_cast(anElem)-> + aNodesIter = static_cast(anElem)-> interlacedNodesElemIterator(); else aNodesIter = anElem->nodesIterator(); diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 27edfccff..267ab9e7d 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -274,21 +274,35 @@ DriverMED_R_SMESHDS_Mesh typedef MED::TVector TQuantities; TQuantities aQuantities(aNbFaces); TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem); + //MESSAGE("--- aNbNodes " << aNbNodes); TNodeIds aNodeIds(aNbNodes); for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){ + //MESSAGE("--- iface " << aNbFaces << " " << iFace); MED::TCConnSlice aConnSlice = aConnSliceArr[iFace]; TInt aNbConn = aConnSlice.size(); aQuantities[iFace] = aNbConn; #ifdef _EDF_NODE_IDS_ + //MESSAGE(anIsNodeNum); if(anIsNodeNum) for(TInt iConn = 0; iConn < aNbConn; iConn++) - aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1); + { + //MESSAGE("iConn " << iConn << " aConnSlice[iConn] " << aConnSlice[iConn]); + aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1); + //MESSAGE("aNodeIds[" << iNode << "]=" << aNodeIds[iNode]); + iNode++; + } else for(TInt iConn = 0; iConn < aNbConn; iConn++) + { + //MESSAGE("iConn " << iConn); aNodeIds[iNode++] = aConnSlice[iConn]; + } #else for(TInt iConn = 0; iConn < aNbConn; iConn++) + { + //MESSAGE("iConn " << iConn); aNodeIds[iNode++] = aConnSlice[iConn]; + } #endif } @@ -707,7 +721,7 @@ DriverMED_R_SMESHDS_Mesh // } #ifndef _DEXCEPT_ }catch(const std::exception& exc){ - INFOS("Following exception was caught:\n\t"< DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus) } } }catch(const std::exception& exc){ - INFOS("Follow exception was caught:\n\t"<_geomType == ePOLYEDRE ) { + //MESSAGE("_geomType == ePOLYEDRE"); if ( nbPolyhedronNodes == 0 ) { // Count nb of nodes while ( const SMDS_MeshElement* anElem = elemIterator->next() ) { - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - dynamic_cast( anElem ); - if ( aPolyedre ) { + const SMDS_VtkVolume *aPolyedre = dynamic_cast(anElem); + if ( aPolyedre && aPolyedre->IsPoly()) { nbPolyhedronNodes += aPolyedre->NbNodes(); nbPolyhedronFaces += aPolyedre->NbFaces(); if ( ++iElem == aElemTypeData->_nbElems ) break; } } + //MESSAGE("nbPolyhedronNodes=" << nbPolyhedronNodes); + //MESSAGE("nbPolyhedronFaces=" << nbPolyhedronFaces); + //MESSAGE("_nbElems="<< aElemTypeData->_nbElems); } else { // Store in med file @@ -771,19 +775,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() TInt iFace = 0, iNode = 0; while ( const SMDS_MeshElement* anElem = elemIterator->next() ) { - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - dynamic_cast( anElem ); + const SMDS_VtkVolume *aPolyedre = dynamic_cast(anElem); if ( !aPolyedre ) continue; - + if ( !aPolyedre->IsPoly() ) + continue; + //MESSAGE("index[" << iElem << "]=" << index[iElem] << " iElem=" << iElem); // index TInt aNbFaces = aPolyedre->NbFaces(); index[ iElem+1 ] = index[ iElem ] + aNbFaces; + //MESSAGE("index[" << iElem+1 << "]=" << index[iElem+1] << " iElem=" << iElem); // face index for (TInt f = 1; f <= aNbFaces; ++f, ++iFace ) { int aNbFaceNodes = aPolyedre->NbFaceNodes( f ); faces[ iFace+1 ] = faces[ iFace ] + aNbFaceNodes; + //MESSAGE("faces[" << iFace+1 << "]=" << faces[iFace+1] << " iFace=" << iFace); } // connectivity SMDS_ElemIteratorPtr nodeIt = anElem->nodesIterator(); @@ -791,8 +798,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() const SMDS_MeshElement* aNode = nodeIt->next(); #ifdef _EDF_NODE_IDS_ conn[ iNode ] = aNodeIdMap[aNode->GetID()]; + //MESSAGE("conn["<< iNode << "]=" << conn[iNode] << " aNode->GetID()=" << aNode->GetID()); #else conn[ iNode ] = aNode->GetID(); + //MESSAGE("conn["<< iNode << "]=" << conn[iNode]); #endif ++iNode; } @@ -868,11 +877,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() } catch(const std::exception& exc) { - INFOS("Follow exception was cought:\n\t"<nodesIteratorToUNV(); if ( anElem->IsPoly() ) { MESSAGE("anElem->IsPoly"); - if ( const SMDS_PolyhedralVolumeOfNodes* ph = - dynamic_cast (anElem)) + if ( const SMDS_VtkVolume* ph = + dynamic_cast (anElem)) { aNbNodes = ph->NbUniqueNodes(); aNodesIter = ph->uniqueNodesIterator(); diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index a2141b54e..0dca894b9 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -416,8 +416,8 @@ void SMESH_VisualObjDef::buildElemPrs() // Convertions connectivities from SMDS to VTK if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE - if ( const SMDS_PolyhedralVolumeOfNodes* ph = - dynamic_cast (anElem)) + if ( const SMDS_VtkVolume* ph = + dynamic_cast (anElem)) { aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect); anIdList->SetNumberOfIds( aNbNodes ); diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index ec297f49d..96bd25b96 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -1608,7 +1608,7 @@ bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem, return false; } - const SMDS_PolyhedralVolumeOfNodes* vol = dynamic_cast(elem); + const SMDS_VtkVolume* vol = dynamic_cast(elem); if (!vol) { return false; } @@ -1621,7 +1621,9 @@ bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem, } // change nodes - bool Ok = const_cast(vol)->ChangeNodes(nodes, quantities); + // TODO remove this function + //bool Ok = const_cast(vol)->ChangeNodes(nodes, quantities); + bool Ok = false; if (!Ok) { return false; } diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index 46451674f..dc9049cac 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -175,6 +175,13 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); } +//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes +SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const +{ + MESSAGE("Iterator not implemented"); + return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); +} + /////////////////////////////////////////////////////////////////////////////// ///Return the ID of the element /////////////////////////////////////////////////////////////////////////////// diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index c93085b1d..57a77e451 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -65,6 +65,7 @@ public: SMDS_ElemIteratorPtr facesIterator() const; virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const; + virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const; // std-like iteration on nodes typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator; diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 08eb325c6..9edb767cb 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -221,7 +221,8 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n holes = 0; compactState = lookHoleStart; - vtkIdType tmpid[50]; + // TODO some polyhedron may be huge (only in some tests) + vtkIdType tmpid[NBMAXNODESINCELL]; vtkIdType *pointsCell = &tmpid[0]; // --- points id to fill a new cell for (int i = 0; i < oldCellSize; i++) @@ -341,6 +342,7 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, std::vector vtkIdType nbpts; vtkIdType *oldPtsCell = 0; this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); + assert(nbpts < NBMAXNODESINCELL); //MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts ); for (int l = 0; l < nbpts; l++) { diff --git a/src/SMDS/SMDS_UnstructuredGrid.hxx b/src/SMDS/SMDS_UnstructuredGrid.hxx index 214e65310..bf1c20f5b 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.hxx +++ b/src/SMDS/SMDS_UnstructuredGrid.hxx @@ -24,6 +24,9 @@ #define NBMAXNEIGHBORS 10 +// allow very huge polyhedrons in tests +#define NBMAXNODESINCELL 5000 + class SMDS_Downward; class SMDS_Mesh; diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 52633d610..fdf2be3f8 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -32,7 +32,7 @@ #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" -#include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMDS_VtkVolume.hxx" #include "SMDS_Mesh.hxx" #include "utilities.h" @@ -499,7 +499,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume) } if (myVolume->IsPoly()) { - myPolyedre = static_cast( myVolume ); + myPolyedre = dynamic_cast( myVolume ); if (!myPolyedre) { MESSAGE("Warning: bad volumic element"); return false; diff --git a/src/SMDS/SMDS_VolumeTool.hxx b/src/SMDS/SMDS_VolumeTool.hxx index 6791fb9c7..d7201ed8a 100644 --- a/src/SMDS/SMDS_VolumeTool.hxx +++ b/src/SMDS/SMDS_VolumeTool.hxx @@ -33,7 +33,7 @@ class SMDS_MeshElement; class SMDS_MeshNode; -class SMDS_PolyhedralVolumeOfNodes; +class SMDS_VtkVolume; class SMDS_MeshVolume; #include @@ -205,7 +205,7 @@ private: bool setFace( int faceIndex ); const SMDS_MeshElement* myVolume; - const SMDS_PolyhedralVolumeOfNodes* myPolyedre; + const SMDS_VtkVolume* myPolyedre; bool myVolForward; int myNbFaces; diff --git a/src/SMDS/SMDS_VtkCellIterator.cxx b/src/SMDS/SMDS_VtkCellIterator.cxx index 3346bc101..ef8f23a87 100644 --- a/src/SMDS/SMDS_VtkCellIterator.cxx +++ b/src/SMDS/SMDS_VtkCellIterator.cxx @@ -70,10 +70,8 @@ SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSA break; } case SMDSEntity_Polyhedra: - { - MESSAGE("SMDS_VtkCellIterator Polyhedra"); - break; - } + MESSAGE("SMDS_VtkCellIterator Polyhedra (iterate on actual nodes)"); + break; default: break; } @@ -95,16 +93,14 @@ const SMDS_MeshElement* SMDS_VtkCellIterator::next() return _mesh->FindNode(id); } -SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, - int vtkCellId, - SMDSAbs_EntityType aType) -: SMDS_VtkCellIterator() +SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : + SMDS_VtkCellIterator() { _mesh = mesh; _cellId = vtkCellId; _index = 0; _type = aType; - //MESSAGE("SMDS_VtkCellInterlacedIterator " << _type); + //MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type); _vtkIdList = vtkIdList::New(); vtkIdType* pts; @@ -116,51 +112,51 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, { case SMDSEntity_Quad_Edge: { - static int id[] = {0,2,1}; + static int id[] = { 0, 2, 1 }; ids = id; break; } case SMDSEntity_Quad_Triangle: { - static int id[] = {0,3,1,4,2,5}; + static int id[] = { 0, 3, 1, 4, 2, 5 }; ids = id; break; } case SMDSEntity_Quad_Quadrangle: { - static int id[] = {0,4,1,5,2,6,3,7}; + static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 }; ids = id; break; } - case SMDSEntity_Quad_Tetra: + case SMDSEntity_Quad_Tetra: { - static int id[] = {0,4,1,5,2,6,7,8,9,3}; + static int id[] = { 0, 4, 1, 5, 2, 6, 7, 8, 9, 3 }; ids = id; break; } case SMDSEntity_Quad_Pyramid: { - static int id[] = {0,5,1,6,2,7,3,8,9,10,11,12,4}; + static int id[] = { 0, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11, 12, 4 }; ids = id; break; } case SMDSEntity_Penta: { - static int id[] = {0,2,1,3,5,4}; + static int id[] = { 0, 2, 1, 3, 5, 4 }; ids = id; break; } - case SMDSEntity_Quad_Penta: + case SMDSEntity_Quad_Penta: { - static int id[] = {0,8,2,7,1,6,12,14,13,3,11,5,10,4,9}; + static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 }; ids = id; break; } case SMDSEntity_Quad_Hexa: { - static int id[] = {0,8,1,9,2,10,3,11,16,17,18,19,4,12,5,13,6,14,7,15}; + static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 }; ids = id; - break; + break; } case SMDSEntity_Polygon: case SMDSEntity_Quad_Polygon: @@ -168,13 +164,14 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, case SMDSEntity_Quad_Polyhedra: default: { - static int id[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}; + static int id[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29 }; ids = id; break; } } //MESSAGE("_nbNodes " << _nbNodes); - for (int i=0; i<_nbNodes; i++) + for (int i = 0; i < _nbNodes; i++) _vtkIdList->SetId(i, pts[ids[i]]); } @@ -182,3 +179,56 @@ SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV() { } +SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : + SMDS_VtkCellIterator() +{ + _mesh = mesh; + _cellId = vtkCellId; + _index = 0; + _type = aType; + //MESSAGE("SMDS_VtkCellIteratorPolyH " << _type); + _vtkIdList = vtkIdList::New(); + vtkUnstructuredGrid* grid = _mesh->getGrid(); + grid->GetCellPoints(_cellId, _vtkIdList); + _nbNodes = _vtkIdList->GetNumberOfIds(); + switch (_type) + { + case SMDSEntity_Polyhedra: + { + //MESSAGE("SMDS_VtkCellIterator Polyhedra"); + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(_cellId, nFaces, ptIds); + int id = 0; + _nbNodesInFaces = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + _nbNodesInFaces += nodesInFace; + id += (nodesInFace + 1); + } + _vtkIdList->SetNumberOfIds(_nbNodesInFaces); + id = 0; + int n = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + for (int k = 1; k <= nodesInFace; k++) + _vtkIdList->SetId(n++, ptIds[id + k]); + id += (nodesInFace + 1); + } + break; + } + default: + assert(0); + } +} + +SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH() +{ +} + +bool SMDS_VtkCellIteratorPolyH::more() +{ + return (_index < _nbNodesInFaces); +} diff --git a/src/SMDS/SMDS_VtkCellIterator.hxx b/src/SMDS/SMDS_VtkCellIterator.hxx index bd7bf90ab..91ab3dcb8 100644 --- a/src/SMDS/SMDS_VtkCellIterator.hxx +++ b/src/SMDS/SMDS_VtkCellIterator.hxx @@ -40,4 +40,14 @@ public: virtual ~SMDS_VtkCellIteratorToUNV(); }; +class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator +{ +public: + SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType); + virtual ~SMDS_VtkCellIteratorPolyH(); + virtual bool more(); +protected: + int _nbNodesInFaces; +}; + #endif diff --git a/src/SMDS/SMDS_VtkEdge.cxx b/src/SMDS/SMDS_VtkEdge.cxx index f893a752d..1583839f0 100644 --- a/src/SMDS/SMDS_VtkEdge.cxx +++ b/src/SMDS/SMDS_VtkEdge.cxx @@ -139,3 +139,8 @@ SMDS_ElemIteratorPtr SMDS_VtkEdge::nodesIteratorToUNV() const { return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); } + +SMDS_ElemIteratorPtr SMDS_VtkEdge::interlacedNodesElemIterator() const +{ + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); +} diff --git a/src/SMDS/SMDS_VtkEdge.hxx b/src/SMDS/SMDS_VtkEdge.hxx index 1f1cddcbe..e7aa32bed 100644 --- a/src/SMDS/SMDS_VtkEdge.hxx +++ b/src/SMDS/SMDS_VtkEdge.hxx @@ -28,8 +28,9 @@ public: virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual bool IsQuadratic() const; -protected: virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const; + virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const; +protected: }; #endif diff --git a/src/SMDS/SMDS_VtkFace.cxx b/src/SMDS/SMDS_VtkFace.cxx index fc6e591ab..a69382dbb 100644 --- a/src/SMDS/SMDS_VtkFace.cxx +++ b/src/SMDS/SMDS_VtkFace.cxx @@ -199,3 +199,8 @@ SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const { return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); } + + SMDS_ElemIteratorPtr SMDS_VtkFace::interlacedNodesElemIterator() const + { + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); + } diff --git a/src/SMDS/SMDS_VtkFace.hxx b/src/SMDS/SMDS_VtkFace.hxx index baa4b9ac6..c5fee77d2 100644 --- a/src/SMDS/SMDS_VtkFace.hxx +++ b/src/SMDS/SMDS_VtkFace.hxx @@ -28,9 +28,10 @@ public: virtual bool IsQuadratic() const; virtual bool IsPoly() const; -protected: virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const; + virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const; +protected: }; #endif diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 88af62331..123b91f71 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -77,9 +77,9 @@ void SMDS_VtkVolume::initPoly(std::vector nodeIds, std::vector n double a[3]; double b[3]; double c[3]; - grid->GetPoints()->GetPoint(nodeIds[k],a); - grid->GetPoints()->GetPoint(nodeIds[k+1],b); - grid->GetPoints()->GetPoint(nodeIds[k+2],c); + grid->GetPoints()->GetPoint(nodeIds[k], a); + grid->GetPoints()->GetPoint(nodeIds[k + 1], b); + grid->GetPoints()->GetPoint(nodeIds[k + 2], c); bool isFaceForward = this->isForward(a, b, c, center); //MESSAGE("isFaceForward " << i << " " << isFaceForward); vtkIdType *facePts = &nodeIds[k]; @@ -87,7 +87,7 @@ void SMDS_VtkVolume::initPoly(std::vector nodeIds, std::vector n for (int n = 0; n < nf; n++) ptIds.push_back(facePts[n]); else - for (int n = nf-1; n >= 0; n--) + for (int n = nf - 1; n >= 0; n--) ptIds.push_back(facePts[n]); k += nf; } @@ -106,7 +106,7 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); return false; } - for (int i=0; iGetID(); } @@ -142,16 +142,18 @@ int SMDS_VtkVolume::NbFaces() const case VTK_HEXAHEDRON: case VTK_QUADRATIC_HEXAHEDRON: nbFaces = 6; - break; + break; case VTK_POLYHEDRON: { vtkIdType nFaces = 0; vtkIdType* ptIds = 0; grid->GetFaceStream(this->myVtkID, nFaces, ptIds); nbFaces = nFaces; + break; } default: - MESSAGE("invalid volume type"); + MESSAGE("invalid volume type") + ; nbFaces = 0; break; } @@ -161,7 +163,25 @@ int SMDS_VtkVolume::NbFaces() const int SMDS_VtkVolume::NbNodes() const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); - int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + int nbPoints = 0; + if (aVtkType != VTK_POLYHEDRON) + { + nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints(); + } + else + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; + nbPoints += nodesInFace; + id += (nodesInFace + 1); + } + } return nbPoints; } @@ -187,7 +207,7 @@ int SMDS_VtkVolume::NbEdges() const case VTK_HEXAHEDRON: case VTK_QUADRATIC_HEXAHEDRON: nbEdges = 12; - break; + break; case VTK_POLYHEDRON: { vtkIdType nFaces = 0; @@ -205,19 +225,111 @@ int SMDS_VtkVolume::NbEdges() const break; } default: - MESSAGE("invalid volume type"); + MESSAGE("invalid volume type") + ; nbEdges = 0; break; } return nbEdges; } +/*! polyhedron only, + * 1 <= face_ind <= NbFaces() + */ +int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + int nbNodes = 0; + if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; + id += (nodesInFace + 1); + if (i == face_ind - 1) + { + nbNodes = nodesInFace; + break; + } + } + } + return nbNodes; +} + +/*! polyhedron only, + * 1 <= face_ind <= NbFaces() + * 1 <= node_ind <= NbFaceNodes() + */ +const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int node_ind) const +{ + SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; + vtkUnstructuredGrid* grid = mesh->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + const SMDS_MeshNode* node = 0; + if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + if (i == face_ind - 1) // first face is number 1 + { + if ((node_ind > 0) && (node_ind <= nodesInFace)) + node = mesh->FindNode(ptIds[id + node_ind]); // ptIds[id+1] : first node + break; + } + id += (nodesInFace + 1); + } + } + return node; +} + +/*! polyhedron only, + * return number of nodes for each face + */ +const std::vector & SMDS_VtkVolume::GetQuantities() const +{ + vector quantities; + quantities.clear(); + SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; + vtkUnstructuredGrid* grid = mesh->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + if (aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] + quantities.push_back(nodesInFace); + id += (nodesInFace + 1); + } + } + return quantities; +} + SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const { switch (type) { case SMDSAbs_Node: - return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); + { + SMDSAbs_EntityType aType = this->GetEntityType(); + if (aType == SMDSEntity_Polyhedra) + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorPolyH(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType)); + else + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType)); + } default: MESSAGE("ERROR : Iterator not implemented"); return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); @@ -229,6 +341,10 @@ SMDS_ElemIteratorPtr SMDS_VtkVolume::nodesIteratorToUNV() const return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); } +SMDS_ElemIteratorPtr SMDS_VtkVolume::interlacedNodesElemIterator() const +{ + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); +} SMDSAbs_ElementType SMDS_VtkVolume::GetType() const { @@ -242,7 +358,8 @@ SMDSAbs_ElementType SMDS_VtkVolume::GetType() const */ const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const { - return SMDS_MeshElement::GetNode(ind); // --- a optimiser ! + // TODO optimize if possible (vtkCellIterator) + return SMDS_MeshElement::GetNode(ind); } bool SMDS_VtkVolume::IsQuadratic() const @@ -321,26 +438,26 @@ vtkIdType SMDS_VtkVolume::GetVtkType() const return aType; } - void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result) +void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result) { - for (int j=0; j<3; j++) + for (int j = 0; j < 3; j++) result[j] = 0; - if (nbNodes <= 0) + if (nbNodes <= 0) return; - for (int i =0; i< nbNodes; i++) + for (int i = 0; i < nbNodes; i++) { double *coords = grid->GetPoint(nodeIds[i]); - for (int j=0; j<3; j++) + for (int j = 0; j < 3; j++) result[j] += coords[j]; } - for (int j=0; j<3; j++) - result[j] = result[j]/nbNodes; + for (int j = 0; j < 3; j++) + result[j] = result[j] / nbNodes; //MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]); return; } - bool SMDS_VtkVolume::isForward(double* a,double* b,double* c,double* d) - { +bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d) +{ double u[3], v[3], w[3]; for (int j = 0; j < 3; j++) { @@ -350,8 +467,25 @@ vtkIdType SMDS_VtkVolume::GetVtkType() const w[j] = d[j] - a[j]; //MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]); } - double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1] - + (u[3] * v[1] - u[1] * v[3]) * w[2] - + (u[1] * v[2] - u[2] * v[1]) * w[3]; + double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1] + (u[3] * v[1] - u[1] * v[3]) * w[2] + (u[1] * v[2] - u[2] + * v[1]) * w[3]; return (prodmixte >= 0); } + +/*! For polyhedron only + * @return actual number of nodes (not the sum of nodes of all faces) + */ +int SMDS_VtkVolume::NbUniqueNodes() const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + return grid->GetCell(myVtkID)->GetNumberOfPoints(); +} + +/*! For polyhedron use only + * @return iterator on actual nodes (not through the faces) + */ +SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const +{ + MESSAGE("uniqueNodesIterator"); + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); +} diff --git a/src/SMDS/SMDS_VtkVolume.hxx b/src/SMDS/SMDS_VtkVolume.hxx index 68f3d7877..407a34c62 100644 --- a/src/SMDS/SMDS_VtkVolume.hxx +++ b/src/SMDS/SMDS_VtkVolume.hxx @@ -23,6 +23,13 @@ public: int NbFaces() const; int NbNodes() const; int NbEdges() const; + + // 1 <= face_ind <= NbFaces() + int NbFaceNodes (const int face_ind) const; + // 1 <= face_ind <= NbFaces() + // 1 <= node_ind <= NbFaceNodes() + const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const; + virtual SMDSAbs_ElementType GetType() const; virtual vtkIdType GetVtkType() const; virtual SMDSAbs_EntityType GetEntityType() const; @@ -34,10 +41,15 @@ public: int nbNodes, double* result); static bool isForward(double* a,double* b,double* c,double* d); + int NbUniqueNodes() const; + SMDS_ElemIteratorPtr uniqueNodesIterator() const; + const std::vector & GetQuantities() const; -protected: virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const; + virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const; + +protected: }; #endif diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 543bace8a..c1d0bb871 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -34,7 +34,7 @@ #include "SMDS_PolyhedralVolumeOfNodes.hxx" #include "SMDS_FacePosition.hxx" #include "SMDS_SpacePosition.hxx" -#include "SMDS_QuadraticFaceOfNodes.hxx" +//#include "SMDS_QuadraticFaceOfNodes.hxx" #include "SMDS_MeshGroup.hxx" #include "SMDS_LinearEdge.hxx" #include "SMDS_Downward.hxx" @@ -906,8 +906,8 @@ bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem) if (theElem->IsPoly()) { // TODO reorient vtk polyhedron MESSAGE("reorient vtk polyhedron ?"); - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - static_cast( theElem ); + const SMDS_VtkVolume* aPolyedre = + dynamic_cast( theElem ); if (!aPolyedre) { MESSAGE("Warning: bad volumic element"); return false; @@ -3176,14 +3176,14 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, helper.SetSubShape( face ); list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin(); for ( ; elemIt != elemsOnFace.end(); ++elemIt ) { - const SMDS_QuadraticFaceOfNodes* QF = - dynamic_cast (*elemIt); - if(QF) { + const SMDS_VtkFace* QF = + dynamic_cast (*elemIt); + if(QF && QF->IsQuadratic()) { vector Ns; Ns.reserve(QF->NbNodes()+1); - SMDS_NodeIteratorPtr anIter = QF->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = QF->interlacedNodesElemIterator(); while ( anIter->more() ) - Ns.push_back( anIter->next() ); + Ns.push_back( cast2Node(anIter->next()) ); Ns.push_back( Ns[0] ); double x, y, z; for(int i=0; iNbNodes(); i=i+2) { @@ -5317,8 +5317,8 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, case SMDSAbs_Volume: { // ATTENTION: Reversing is not yet done!!! - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - dynamic_cast( elem ); + const SMDS_VtkVolume* aPolyedre = + dynamic_cast( elem ); if (!aPolyedre) { MESSAGE("Warning: bad volumic element"); continue; @@ -5640,8 +5640,8 @@ SMESH_MeshEditor::Scale (TIDSortedElemSet & theElems, case SMDSAbs_Volume: { // ATTENTION: Reversing is not yet done!!! - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - dynamic_cast( elem ); + const SMDS_VtkVolume* aPolyedre = + dynamic_cast( elem ); if (!aPolyedre) { MESSAGE("Warning: bad volumic element"); continue; @@ -6836,9 +6836,9 @@ bool SMESH_MeshEditor::isOut( const SMDS_MeshElement* element, const gp_Pnt& poi SMDS_ElemIteratorPtr nodeIt = element->nodesIterator(); if ( element->IsQuadratic() ) - if (const SMDS_QuadraticFaceOfNodes* f=dynamic_cast(element)) + if (const SMDS_VtkFace* f=dynamic_cast(element)) nodeIt = f->interlacedNodesElemIterator(); - else if (const SMDS_QuadraticEdge* e =dynamic_cast(element)) + else if (const SMDS_VtkEdge* e =dynamic_cast(element)) nodeIt = e->interlacedNodesElemIterator(); while ( nodeIt->more() ) @@ -7182,8 +7182,19 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) if (aShapeId) aMesh->SetMeshElementOnShape(newElem, aShapeId); } - MESSAGE("ChangeElementNodes MergeNodes Poly"); - aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]); + + MESSAGE("ChangeElementNodes MergeNodes Polygon"); + //aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]); + vector polynodes(polygons_nodes.begin()+inode,polygons_nodes.end()); + int quid =0; + if (nbNew > 0) quid = nbNew - 1; + vector newquant(quantities.begin()+quid, quantities.end()); + const SMDS_MeshElement* newElem = 0; + newElem = aMesh->AddPolyhedralVolume(polynodes, newquant); + myLastCreatedElems.Append(newElem); + if ( aShapeId && newElem ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + rmElemIds.push_back(elem->GetID()); } else { rmElemIds.push_back(elem->GetID()); @@ -7196,9 +7207,9 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) rmElemIds.push_back(elem->GetID()); } else { - // each face has to be analized in order to check volume validity - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - static_cast( elem ); + // each face has to be analyzed in order to check volume validity + const SMDS_VtkVolume* aPolyedre = + dynamic_cast( elem ); if (aPolyedre) { int nbFaces = aPolyedre->NbFaces(); @@ -7226,10 +7237,16 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) } if (quantities.size() > 3) - aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities); - else - rmElemIds.push_back(elem->GetID()); - + { + MESSAGE("ChangeElementNodes MergeNodes Polyhedron"); + //aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities); + const SMDS_MeshElement* newElem = 0; + newElem = aMesh->AddPolyhedralVolume(poly_nodes, quantities); + myLastCreatedElems.Append(newElem); + if ( aShapeId && newElem ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + rmElemIds.push_back(elem->GetID()); + } } else { rmElemIds.push_back(elem->GetID()); @@ -7580,8 +7597,8 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) if ( isOk ) { if (elem->IsPoly() && elem->GetType() == SMDSAbs_Volume) { // Change nodes of polyedre - const SMDS_PolyhedralVolumeOfNodes* aPolyedre = - static_cast( elem ); + const SMDS_VtkVolume* aPolyedre = + dynamic_cast( elem ); if (aPolyedre) { int nbFaces = aPolyedre->NbFaces(); @@ -7815,10 +7832,11 @@ SMESH_MeshEditor::FindFaceInSet(const SMDS_MeshNode* n1, if ( !face && elem->IsQuadratic()) { // analysis for quadratic elements using all nodes - const SMDS_QuadraticFaceOfNodes* F = - static_cast(elem); + const SMDS_VtkFace* F = + dynamic_cast(elem); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); const SMDS_MeshNode* prevN = cast2Node( anIter->next() ); for ( i1 = -1, i2 = 0; anIter->more() && !face; i1++, i2++ ) { @@ -7902,12 +7920,13 @@ bool SMESH_MeshEditor::FindFreeBorder (const SMDS_MeshNode* theFirst vector nodes(nbNodes+1); if(e->IsQuadratic()) { - const SMDS_QuadraticFaceOfNodes* F = - static_cast(e); + const SMDS_VtkFace* F = + dynamic_cast(e); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); while( anIter->more() ) { - nodes[ iNode++ ] = anIter->next(); + nodes[ iNode++ ] = cast2Node(anIter->next()); } } else { @@ -8175,12 +8194,13 @@ SMESH_MeshEditor::SewFreeBorder (const SMDS_MeshNode* theBordFirstNode, else if ( elem->GetType()==SMDSAbs_Face ) { // --face // retrieve all face nodes and find iPrevNode - an index of the prevSideNode if(elem->IsQuadratic()) { - const SMDS_QuadraticFaceOfNodes* F = - static_cast(elem); + const SMDS_VtkFace* F = + dynamic_cast(elem); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); while( anIter->more() ) { - nodes[ iNode ] = anIter->next(); + nodes[ iNode ] = cast2Node(anIter->next()); if ( nodes[ iNode++ ] == prevSideNode ) iPrevNode = iNode - 1; } @@ -8494,12 +8514,13 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, vector nodes( theFace->NbNodes() ); if(theFace->IsQuadratic()) { - const SMDS_QuadraticFaceOfNodes* F = - static_cast(theFace); + const SMDS_VtkFace* F = + dynamic_cast(theFace); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); while( anIter->more() ) { - const SMDS_MeshNode* n = anIter->next(); + const SMDS_MeshNode* n = cast2Node(anIter->next()); if ( n == theBetweenNode1 ) il1 = iNode; else if ( n == theBetweenNode2 ) @@ -8555,12 +8576,13 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, bool isFLN = false; if(theFace->IsQuadratic()) { - const SMDS_QuadraticFaceOfNodes* F = - static_cast(theFace); + const SMDS_VtkFace* F = + dynamic_cast(theFace); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); while( anIter->more() && !isFLN ) { - const SMDS_MeshNode* n = anIter->next(); + const SMDS_MeshNode* n = cast2Node(anIter->next()); poly_nodes[iNode++] = n; if (n == nodes[il1]) { isFLN = true; @@ -8573,7 +8595,7 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, } // add nodes of face starting from last node of link while ( anIter->more() ) { - poly_nodes[iNode++] = anIter->next(); + poly_nodes[iNode++] = cast2Node(anIter->next()); } } else { @@ -9618,10 +9640,11 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, } } else { // f->IsQuadratic() - const SMDS_QuadraticFaceOfNodes* F = - static_cast(f); + const SMDS_VtkFace* F = + dynamic_cast(f); + if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace")); // use special nodes iterator - SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator(); + SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); while ( anIter->more() ) { const SMDS_MeshNode* n = static_cast( anIter->next() ); diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 785a03846..af6d88f7e 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1997,11 +1997,11 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray, // creates a corresponding element on existent nodes in new mesh if ( anElem->IsPoly() && anElemType == SMDSAbs_Volume ) { - const SMDS_PolyhedralVolumeOfNodes* aVolume = - dynamic_cast (anElem); + const SMDS_VtkVolume* aVolume = + dynamic_cast (anElem); if ( aVolume ) { aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray, - aVolume->GetQuanities()); + aVolume->GetQuantities()); elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID())); if( theCommonGroups ) anIDsVolumes[anNbVolumes++] = aNewElem->GetID(); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 054b424f7..d05ec1a6a 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -129,11 +129,11 @@ namespace { SMDS_MeshElement* anElemCopy = 0; if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume ) { - const SMDS_PolyhedralVolumeOfNodes* ph = - dynamic_cast (anElem); + const SMDS_VtkVolume* ph = + dynamic_cast (anElem); if ( ph ) anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID - (anElemNodesID, ph->GetQuanities(),anElem->GetID()); + (anElemNodesID, ph->GetQuantities(),anElem->GetID()); } else { anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID, diff --git a/src/StdMeshers/StdMeshers_Projection_3D.cxx b/src/StdMeshers/StdMeshers_Projection_3D.cxx index e30980e32..689c92006 100644 --- a/src/StdMeshers/StdMeshers_Projection_3D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_3D.cxx @@ -407,11 +407,13 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS nodes[6], nodes[7], id, force3d); break; default: // polyhedron - const SMDS_PolyhedralVolumeOfNodes * poly = - dynamic_cast( srcVol ); + const SMDS_VtkVolume * poly = + dynamic_cast( srcVol ); if ( !poly ) RETURN_BAD_RESULT("Unexpected volume type"); - tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuanities() ); + if ( !poly->IsPoly()) + RETURN_BAD_RESULT("Unexpected volume type"); + tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuantities() ); } if ( tgtVol ) { tgtMeshDS->SetMeshElementOnShape( tgtVol, helper.GetSubShapeID() );