From: prascle Date: Mon, 8 Nov 2010 14:48:23 +0000 (+0000) Subject: PR: debug autotests in progress, still 41 bugs X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7eead704777e29097a53162b594f32d3c5abf970;p=modules%2Fsmesh.git PR: debug autotests in progress, still 41 bugs --- diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 267ab9e7d..c679edd9b 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -971,6 +971,9 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, for(MED::TInt iDim=0;iDimAddNodeWithID(aCoords[0],aCoords[1],aCoords[2],(int)iNode); + if (!aNode) { + EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode); + } if((aGrilleInfo->myFamNumNode).size() > 0){ TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode); @@ -1026,7 +1029,9 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, default: break; } - + if (!anElement) { + EXCEPTION(runtime_error,"buildMeshGrille Error. Element not created! "<myFamNum).size() > 0){ TInt aFamNum = aGrilleInfo->GetFamNum(iCell); if ( checkFamilyID ( aFamily, aFamNum )){ diff --git a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx index 1049c4682..ffa50cbe7 100644 --- a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx @@ -158,7 +158,7 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() TElementLab aLabel = anElem->GetID(); int aNbNodes = anElem->NbNodes(); - MESSAGE("aNbNodes="<GetNumberOfPoints()==0) { + MESSAGE("buildPrs"); buildPrs(); // Fill unstructured grid return true; } diff --git a/src/SMDS/SMDS_EdgePosition.cxx b/src/SMDS/SMDS_EdgePosition.cxx index 76df7471c..fa6e45249 100644 --- a/src/SMDS/SMDS_EdgePosition.cxx +++ b/src/SMDS/SMDS_EdgePosition.cxx @@ -39,6 +39,7 @@ using namespace std; SMDS_EdgePosition::SMDS_EdgePosition(const int aEdgeId, const double aUParam):SMDS_Position(aEdgeId), myUParameter(aUParam) { + //MESSAGE("********************************* SMDS_EdgePosition "<< aEdgeId << " " << myUParameter); } //======================================================================= @@ -57,11 +58,13 @@ const double *SMDS_EdgePosition::Coords() const */ SMDS_TypeOfPosition SMDS_EdgePosition::GetTypeOfPosition() const { + //MESSAGE("###################################### SMDS_EdgePosition::GetTypeOfPosition"); return SMDS_TOP_EDGE; } void SMDS_EdgePosition::SetUParameter(double aUparam) { + //MESSAGE("############################### SMDS_EdgePosition::SetUParameter " << aUparam); myUParameter = aUparam; } @@ -72,5 +75,6 @@ void SMDS_EdgePosition::SetUParameter(double aUparam) double SMDS_EdgePosition::GetUParameter() const { + //MESSAGE("########################## SMDS_EdgePosition::GetUParameter " << myUParameter); return myUParameter; } diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx index 2d545861d..c02ad1a2b 100644 --- a/src/SMDS/SMDS_FaceOfEdges.cxx +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -29,6 +29,7 @@ #include "SMDS_FaceOfEdges.hxx" #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" +#include "utilities.h" using namespace std; @@ -111,6 +112,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1, const SMDS_MeshEdge* edge2, const SMDS_MeshEdge* edge3) { + //MESSAGE("****************************************************** SMDS_FaceOfEdges"); myNbEdges = 3; myEdges[0]=edge1; myEdges[1]=edge2; @@ -123,6 +125,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1, const SMDS_MeshEdge* edge3, const SMDS_MeshEdge* edge4) { + //MESSAGE("****************************************************** SMDS_FaceOfEdges"); myNbEdges = 4; myEdges[0]=edge1; myEdges[1]=edge2; diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx index d92a89a3e..ce99398ca 100644 --- a/src/SMDS/SMDS_FaceOfNodes.cxx +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -133,6 +133,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1, const SMDS_MeshNode* node2, const SMDS_MeshNode* node3) { + //MESSAGE("******************************************************* SMDS_FaceOfNodes"); myNbNodes = 3; myNodes[0]=node1; myNodes[1]=node2; @@ -145,6 +146,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1, const SMDS_MeshNode* node3, const SMDS_MeshNode* node4) { + //MESSAGE("******************************************************* SMDS_FaceOfNodes"); myNbNodes = 4; myNodes[0]=node1; myNodes[1]=node2; diff --git a/src/SMDS/SMDS_FacePosition.cxx b/src/SMDS/SMDS_FacePosition.cxx index da93899b6..b51b0ac90 100644 --- a/src/SMDS/SMDS_FacePosition.cxx +++ b/src/SMDS/SMDS_FacePosition.cxx @@ -42,6 +42,7 @@ SMDS_FacePosition::SMDS_FacePosition(const int aEdgeId, :SMDS_Position(aEdgeId), myUParameter(aUParam),myVParameter(aVParam) { + //MESSAGE("******************************************************** SMDS_FacePosition"); } //======================================================================= diff --git a/src/SMDS/SMDS_LinearEdge.cxx b/src/SMDS/SMDS_LinearEdge.cxx index 21d7d84b0..7bb1ea2ae 100644 --- a/src/SMDS/SMDS_LinearEdge.cxx +++ b/src/SMDS/SMDS_LinearEdge.cxx @@ -112,10 +112,10 @@ SMDS_ElemIteratorPtr SMDS_LinearEdge::elementsIterator(SMDSAbs_ElementType type) bool operator<(const SMDS_LinearEdge & e1, const SMDS_LinearEdge & e2) { - int id11 = e1.myNodes[0]->GetID(); - int id21 = e2.myNodes[0]->GetID(); - int id12 = e1.myNodes[1]->GetID(); - int id22 = e2.myNodes[1]->GetID(); + int id11 = e1.myNodes[0]->getVtkId(); + int id21 = e2.myNodes[0]->getVtkId(); + int id12 = e1.myNodes[1]->getVtkId(); + int id22 = e2.myNodes[1]->getVtkId(); int tmp; if (id11 >= id12) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 96bd25b96..462ddbc75 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -145,8 +145,8 @@ SMDS_Mesh::SMDS_Mesh() myNodes.clear(); myCells.clear(); - myIDElements.clear(); - myVtkIndex.clear(); + myCellIdSmdsToVtk.clear(); + myCellIdVtkToSmds.clear(); myGrid = SMDS_UnstructuredGrid::New(); myGrid->setSMDS_mesh(this); myGrid->Initialize(); @@ -207,15 +207,19 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID) // find the MeshNode corresponding to ID const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID); if(!node){ - //if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); - //SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z); + // TODO ID < 1 + if (ID <= 0) + { + MESSAGE("=============> Bad Node Id: " << ID); + ID = myNodeIDFactory->GetFreeID(); + } myNodeIDFactory->adjustMaxId(ID); SMDS_MeshNode * node = myNodePool->getNew(); node->init(ID, myMeshId, -1, x, y, z); if (ID >= myNodes.size()) { myNodes.resize(ID+SMDS_Mesh::chunkSize, 0); - //MESSAGE(" ------------------ myNodes resize " << ID << " --> " << ID+SMDS_Mesh::chunkSize); + MESSAGE(" ------------------ myNodes resize " << ID << " --> " << ID+SMDS_Mesh::chunkSize); } myNodes[ID] = node; myNodeIDFactory->BindID(ID,node); @@ -315,8 +319,8 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, // --- retreive nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); edgevtk->init(nodeIds, this); @@ -598,10 +602,10 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n3->getId()); // order SMDS-->VTK - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n4->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n3->getVtkId()); // order SMDS-->VTK + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n4->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -705,11 +709,11 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n5->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n5->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -818,12 +822,12 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n5->getId()); - nodeIds.push_back(n6->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n5->getVtkId()); + nodeIds.push_back(n6->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -944,14 +948,14 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n5->getId()); - nodeIds.push_back(n8->getId()); - nodeIds.push_back(n7->getId()); - nodeIds.push_back(n6->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n5->getVtkId()); + nodeIds.push_back(n8->getVtkId()); + nodeIds.push_back(n7->getVtkId()); + nodeIds.push_back(n6->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -1158,7 +1162,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID nodeIds.clear(); vector::iterator it = nodes.begin(); for ( ; it != nodes.end(); ++it) - nodeIds.push_back((*it)->getId()); + nodeIds.push_back((*it)->getVtkId()); SMDS_VtkFace *facevtk = myFacePool->getNew(); facevtk->initPoly(nodeIds, this); @@ -1253,7 +1257,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID nodeIds.clear(); vector::iterator it = nodes.begin(); for (; it != nodes.end(); ++it) - nodeIds.push_back((*it)->getId()); + nodeIds.push_back((*it)->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->initPoly(nodeIds, quantities, this); @@ -1307,9 +1311,9 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) { //MESSAGE("registerElement " << ID); - if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound + if ((ID < myCellIdSmdsToVtk.size()) && myCellIdSmdsToVtk[ID] >= 0) // --- already bound { - MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]); + MESSAGE(" --------------------------------- already bound "<< ID << " " << myCellIdSmdsToVtk[ID]); return false; } @@ -1322,32 +1326,32 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) if (vtkId == -1) vtkId = myElementIDFactory->SetInVtkGrid(element); - if (ID >= myIDElements.size()) // --- resize local vector + if (ID >= myCellIdSmdsToVtk.size()) // --- resize local vector { - MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID + SMDS_Mesh::chunkSize); - myIDElements.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1 + MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << ID << " --> " << ID + SMDS_Mesh::chunkSize); + myCellIdSmdsToVtk.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1 } - myIDElements[ID] = vtkId; + myCellIdSmdsToVtk[ID] = vtkId; //MESSAGE("smds:" << ID << " vtk:" << vtkId ); - if (vtkId >= myVtkIndex.size()) // --- resize local vector + if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector { - MESSAGE(" --------------------- resize myVtkIndex " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize); - myVtkIndex.resize(vtkId + SMDS_Mesh::chunkSize, -1); + MESSAGE(" --------------------- resize myCellIdVtkToSmds " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize); + myCellIdVtkToSmds.resize(vtkId + SMDS_Mesh::chunkSize, -1); } - myVtkIndex[vtkId] = ID; + myCellIdVtkToSmds[vtkId] = ID; myElementIDFactory->updateMinMax(ID); return true; } /////////////////////////////////////////////////////////////////////////////// -/// Return the node whose ID is 'ID'. +/// Return the node whose SMDS ID is 'ID'. /////////////////////////////////////////////////////////////////////////////// const SMDS_MeshNode * SMDS_Mesh::FindNode(int ID) const { - if (ID < 0 || ID >= myNodes.size()) + if (ID < 1 || ID >= myNodes.size()) { MESSAGE("------------------------------------------------------------------------- "); MESSAGE("----------------------------------- bad ID " << ID << " " << myNodes.size()); @@ -1357,6 +1361,22 @@ const SMDS_MeshNode * SMDS_Mesh::FindNode(int ID) const return (const SMDS_MeshNode *)myNodes[ID]; } +/////////////////////////////////////////////////////////////////////////////// +/// Return the node whose VTK ID is 'vtkId'. +/////////////////////////////////////////////////////////////////////////////// +const SMDS_MeshNode * SMDS_Mesh::FindNodeVtk(int vtkId) const +{ + // TODO if needed use mesh->nodeIdFromVtkToSmds + if (vtkId < 0 || vtkId >= (myNodes.size() -1)) + { + MESSAGE("------------------------------------------------------------------------- "); + MESSAGE("---------------------------- bad VTK ID " << vtkId << " " << myNodes.size()); + MESSAGE("------------------------------------------------------------------------- "); + return 0; + } + return (const SMDS_MeshNode *)myNodes[vtkId+1]; +} + /////////////////////////////////////////////////////////////////////////////// ///Create a triangle and add it to the current mesh. This method do not bind an ///ID to the create triangle. @@ -1387,9 +1407,9 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(node1->getId()); - nodeIds.push_back(node2->getId()); - nodeIds.push_back(node3->getId()); + nodeIds.push_back(node1->getVtkId()); + nodeIds.push_back(node2->getVtkId()); + nodeIds.push_back(node3->getVtkId()); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); @@ -1441,10 +1461,10 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(node1->getId()); - nodeIds.push_back(node2->getId()); - nodeIds.push_back(node3->getId()); - nodeIds.push_back(node4->getId()); + nodeIds.push_back(node1->getVtkId()); + nodeIds.push_back(node2->getVtkId()); + nodeIds.push_back(node3->getVtkId()); + nodeIds.push_back(node4->getVtkId()); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); @@ -1561,13 +1581,16 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * element, set oldNodes; SMDS_ElemIteratorPtr itn = element->nodesIterator(); while(itn->more()) - oldNodes.insert( itn->next() ); + oldNodes.insert(itn->next()); // change nodes bool Ok = false; SMDS_MeshCell* cell = dynamic_cast((SMDS_MeshElement*) element); if (cell) - Ok = cell->ChangeNodes(nodes, nbnodes); + { + Ok = cell->vtkOrder(nodes, nbnodes); + Ok = cell->ChangeNodes(nodes, nbnodes); + } if ( Ok ) { // update InverseElements @@ -1752,8 +1775,8 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1, adjustmyCellsCapacity(ID); vector nodeIds; nodeIds.clear(); - nodeIds.push_back(node1->getId()); - nodeIds.push_back(node2->getId()); + nodeIds.push_back(node1->getVtkId()); + nodeIds.push_back(node2->getVtkId()); SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); edgevtk->init(nodeIds, this); @@ -2045,7 +2068,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1, const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const { - if ((IDelem < 0) || IDelem >= myCells.size()) + if ((IDelem <= 0) || IDelem >= myCells.size()) { MESSAGE("--------------------------------------------------------------------------------- "); MESSAGE("----------------------------------- bad IDelem " << IDelem << " " << myCells.size()); @@ -2348,6 +2371,7 @@ SMDS_Mesh::~SMDS_Mesh() void SMDS_Mesh::Clear() { + MESSAGE("SMDS_Mesh::Clear"); if (myParent!=NULL) { SMDS_ElemIteratorPtr eIt = elementsIterator(); @@ -2387,6 +2411,8 @@ void SMDS_Mesh::Clear() } } myCells.clear(); + myCellIdVtkToSmds.clear(); + myCellIdSmdsToVtk.clear(); SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) @@ -2514,6 +2540,13 @@ struct MYElem_Map_Iterator: public FATHER { _ctr = 0; _type = typ; + while (_ctr < _map.size()) // go to the first valid element + { + if (_map[_ctr]) + if ( (_type == SMDSAbs_All) || (_map[_ctr]->GetType() == _type)) + break; + _ctr++; + } } bool more() @@ -2831,7 +2864,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, list& removedNodes, bool removenodes) { - //MESSAGE("SMDS_Mesh::RemoveElement " << elem->GetID() << " " << removenodes); + //MESSAGE("SMDS_Mesh::RemoveElement " << elem->getVtkId() << " " << removenodes); // get finite elements built on elem set * s1; if (elem->GetType() == SMDSAbs_0DElement || elem->GetType() == SMDSAbs_Edge && !hasConstructionEdges() @@ -2984,6 +3017,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) SMDSAbs_ElementType aType = elem->GetType(); SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); if (aType == SMDSAbs_Node) { + //MESSAGE("Remove free node " << elemId); // only free node can be removed by this method const SMDS_MeshNode* n = static_cast(todest); SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); @@ -2998,6 +3032,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) // this methods is only for meshes without descendants return; + //MESSAGE("Remove free element " << elemId); int vtkid = this->fromSmdsToVtk(elemId); // Remove element from of its nodes @@ -3221,9 +3256,9 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n12->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n12->getVtkId()); SMDS_MeshEdge * edge = 0; SMDS_VtkEdge *edgevtk = myEdgePool->getNew(); @@ -3302,12 +3337,12 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n12->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n31->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n12->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n31->getVtkId()); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); @@ -3392,14 +3427,14 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n12->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n34->getId()); - nodeIds.push_back(n41->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n12->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n34->getVtkId()); + nodeIds.push_back(n41->getVtkId()); SMDS_MeshFace * face = 0; SMDS_VtkFace *facevtk = myFacePool->getNew(); @@ -3493,18 +3528,18 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n4->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n4->getVtkId()); - nodeIds.push_back(n31->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n12->getId()); + nodeIds.push_back(n31->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n12->getVtkId()); - nodeIds.push_back(n14->getId()); - nodeIds.push_back(n34->getId()); - nodeIds.push_back(n24->getId()); + nodeIds.push_back(n14->getVtkId()); + nodeIds.push_back(n34->getVtkId()); + nodeIds.push_back(n24->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -3606,21 +3641,21 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n5->getId()); - - nodeIds.push_back(n41->getId()); - nodeIds.push_back(n34->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n12->getId()); - - nodeIds.push_back(n15->getId()); - nodeIds.push_back(n45->getId()); - nodeIds.push_back(n35->getId()); - nodeIds.push_back(n25->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n5->getVtkId()); + + nodeIds.push_back(n41->getVtkId()); + nodeIds.push_back(n34->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n12->getVtkId()); + + nodeIds.push_back(n15->getVtkId()); + nodeIds.push_back(n45->getVtkId()); + nodeIds.push_back(n35->getVtkId()); + nodeIds.push_back(n25->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -3730,25 +3765,25 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n2->getId()); - nodeIds.push_back(n3->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + nodeIds.push_back(n3->getVtkId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n5->getId()); - nodeIds.push_back(n6->getId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n5->getVtkId()); + nodeIds.push_back(n6->getVtkId()); - nodeIds.push_back(n12->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n31->getId()); + nodeIds.push_back(n12->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n31->getVtkId()); - nodeIds.push_back(n45->getId()); - nodeIds.push_back(n56->getId()); - nodeIds.push_back(n64->getId()); + nodeIds.push_back(n45->getVtkId()); + nodeIds.push_back(n56->getVtkId()); + nodeIds.push_back(n64->getVtkId()); - nodeIds.push_back(n14->getId()); - nodeIds.push_back(n25->getId()); - nodeIds.push_back(n36->getId()); + nodeIds.push_back(n14->getVtkId()); + nodeIds.push_back(n25->getVtkId()); + nodeIds.push_back(n36->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -3873,30 +3908,30 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); - nodeIds.push_back(n1->getId()); - nodeIds.push_back(n4->getId()); - nodeIds.push_back(n3->getId()); - nodeIds.push_back(n2->getId()); - - nodeIds.push_back(n5->getId()); - nodeIds.push_back(n8->getId()); - nodeIds.push_back(n7->getId()); - nodeIds.push_back(n6->getId()); - - nodeIds.push_back(n41->getId()); - nodeIds.push_back(n34->getId()); - nodeIds.push_back(n23->getId()); - nodeIds.push_back(n12->getId()); - - nodeIds.push_back(n85->getId()); - nodeIds.push_back(n78->getId()); - nodeIds.push_back(n67->getId()); - nodeIds.push_back(n56->getId()); - - nodeIds.push_back(n15->getId()); - nodeIds.push_back(n48->getId()); - nodeIds.push_back(n37->getId()); - nodeIds.push_back(n26->getId()); + nodeIds.push_back(n1->getVtkId()); + nodeIds.push_back(n4->getVtkId()); + nodeIds.push_back(n3->getVtkId()); + nodeIds.push_back(n2->getVtkId()); + + nodeIds.push_back(n5->getVtkId()); + nodeIds.push_back(n8->getVtkId()); + nodeIds.push_back(n7->getVtkId()); + nodeIds.push_back(n6->getVtkId()); + + nodeIds.push_back(n41->getVtkId()); + nodeIds.push_back(n34->getVtkId()); + nodeIds.push_back(n23->getVtkId()); + nodeIds.push_back(n12->getVtkId()); + + nodeIds.push_back(n85->getVtkId()); + nodeIds.push_back(n78->getVtkId()); + nodeIds.push_back(n67->getVtkId()); + nodeIds.push_back(n56->getVtkId()); + + nodeIds.push_back(n15->getVtkId()); + nodeIds.push_back(n48->getVtkId()); + nodeIds.push_back(n37->getVtkId()); + nodeIds.push_back(n26->getVtkId()); SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(nodeIds, this); @@ -3934,9 +3969,9 @@ void SMDS_Mesh::updateNodeMinMax() void SMDS_Mesh::incrementNodesCapacity(int nbNodes) { - int val = myIDElements.size(); - MESSAGE(" ------------------- resize myIDElements " << val << " --> " << val + nbNodes); - myIDElements.resize(val + nbNodes, -1); // fill new elements with -1 + int val = myCellIdSmdsToVtk.size(); + MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << val << " --> " << val + nbNodes); + myCellIdSmdsToVtk.resize(val + nbNodes, -1); // fill new elements with -1 val = myNodes.size(); MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes); myNodes.resize(val +nbNodes, 0); @@ -3944,9 +3979,9 @@ void SMDS_Mesh::incrementNodesCapacity(int nbNodes) void SMDS_Mesh::incrementCellsCapacity(int nbCells) { - int val = myVtkIndex.size(); - MESSAGE(" ------------------- resize myVtkIndex " << val << " --> " << val + nbCells); - myVtkIndex.resize(val + nbCells, -1); // fill new elements with -1 + int val = myCellIdVtkToSmds.size(); + MESSAGE(" ------------------- resize myCellIdVtkToSmds " << val << " --> " << val + nbCells); + myCellIdVtkToSmds.resize(val + nbCells, -1); // fill new elements with -1 val = myCells.size(); MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells); myNodes.resize(val +nbCells, 0); @@ -3954,7 +3989,7 @@ void SMDS_Mesh::incrementCellsCapacity(int nbCells) void SMDS_Mesh::adjustStructure() { - myGrid->GetPoints()->GetData()->SetNumberOfTuples(myNodeIDFactory->GetMaxID()+1); + myGrid->GetPoints()->GetData()->SetNumberOfTuples(myNodeIDFactory->GetMaxID()); } void SMDS_Mesh::dumpGrid(string ficdump) @@ -4012,3 +4047,17 @@ void SMDS_Mesh::compactMesh() { MESSAGE("SMDS_Mesh::compactMesh do nothing!"); } + +int SMDS_Mesh::fromVtkToSmds(int vtkid) +{ + if (vtkid >= 0 && vtkid < myCellIdVtkToSmds.size()) + return myCellIdVtkToSmds[vtkid]; + throw SALOME_Exception(LOCALIZED ("vtk id out of bounds")); +} + +int SMDS_Mesh::fromSmdsToVtk(int smdsid) +{ + if (smdsid >= 0 && smdsid < myCellIdSmdsToVtk.size()) + return myCellIdSmdsToVtk[smdsid]; + throw SALOME_Exception(LOCALIZED ("smds id out of bounds")); +} diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 914f14cde..e3fc06c81 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -475,6 +475,7 @@ public: virtual void compactMesh(); const SMDS_MeshNode *FindNode(int idnode) const; + const SMDS_MeshNode *FindNodeVtk(int idnode) const; const SMDS_Mesh0DElement* Find0DElement(int idnode) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const; @@ -567,8 +568,8 @@ public: typedef std::vector SetOfCells; void updateNodeMinMax(); - inline int fromVtkToSmds(int vtkid) { MYASSERT(vtkid>=0); return myVtkIndex[vtkid]; }; - inline int fromSmdsToVtk(int smdsid) { MYASSERT(smdsid>=0); return myIDElements[smdsid]; }; + int fromVtkToSmds(int vtkid); + int fromSmdsToVtk(int smdsid); void incrementNodesCapacity(int nbNodes); void incrementCellsCapacity(int nbCells); @@ -636,10 +637,10 @@ protected: SetOfCells myCells; //! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid - std::vector myIDElements; + std::vector myCellIdSmdsToVtk; //! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users - std::vector myVtkIndex; + std::vector myCellIdVtkToSmds; SMDS_Mesh * myParent; std::list myChildren; diff --git a/src/SMDS/SMDS_Mesh0DElement.cxx b/src/SMDS/SMDS_Mesh0DElement.cxx index 14f5e3f3a..49b4d4abc 100644 --- a/src/SMDS/SMDS_Mesh0DElement.cxx +++ b/src/SMDS/SMDS_Mesh0DElement.cxx @@ -131,8 +131,8 @@ SMDS_ElemIteratorPtr SMDS_Mesh0DElement::elementsIterator (SMDSAbs_ElementType t //======================================================================= bool operator< (const SMDS_Mesh0DElement & e1, const SMDS_Mesh0DElement & e2) { - int id1 = e1.myNode->GetID(); - int id2 = e2.myNode->GetID(); + int id1 = e1.myNode->getVtkId(); + int id2 = e2.myNode->getVtkId(); return (id1 < id2); } diff --git a/src/SMDS/SMDS_MeshCell.hxx b/src/SMDS/SMDS_MeshCell.hxx index aa5ba12c9..792696f73 100644 --- a/src/SMDS/SMDS_MeshCell.hxx +++ b/src/SMDS/SMDS_MeshCell.hxx @@ -14,20 +14,17 @@ public: virtual ~SMDS_MeshCell(); virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)= 0; + virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) {return true; }; - inline void setVtkId(int vtkId) - { - myVtkID = vtkId; - } + static int nbCells; - inline int getVtkId() const +protected: + inline void exchange(const SMDS_MeshNode* nodes[],int a, int b) { - return myVtkID; + const SMDS_MeshNode* noda = nodes[a]; + nodes[a] = nodes[b]; + nodes[b] = noda; } - - static int nbCells; -protected: - int myVtkID; }; #endif diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index dc9049cac..714a8bced 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -182,14 +182,6 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); } -/////////////////////////////////////////////////////////////////////////////// -///Return the ID of the element -/////////////////////////////////////////////////////////////////////////////// -int SMDS_MeshElement::GetID() const -{ - return myID; -} - bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2) { if(e1.GetType()!=e2.GetType()) return false; diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 57a77e451..6e05123c8 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -75,7 +75,7 @@ public: virtual int NbNodes() const; virtual int NbEdges() const; virtual int NbFaces() const; - int GetID() const; + inline int GetID() const { return myID; }; ///Return the type of the current element virtual SMDSAbs_ElementType GetType() const = 0; @@ -137,13 +137,23 @@ public: */ int GetNodeIndex( const SMDS_MeshNode* node ) const; - inline int getId() const {return myID; }; + //inline int getId() const {return myID; }; inline ShortType getMeshId() const {return myMeshId; }; inline ShortType getshapeId() const {return myShapeId; }; inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; }; inline int getIdInShape() const { return myIdInShape; }; inline void setIdInShape(int id) { myIdInShape = id; }; + inline void setVtkId(int vtkId) + { + myVtkID = vtkId; + } + + inline int getVtkId() const + { + return myVtkID; + } + protected: inline void setId(int id) {myID = id; }; SMDS_MeshElement(int ID=-1); @@ -153,6 +163,9 @@ protected: //! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells int myID; + // index in vtkUnstructuredGrid + int myVtkID; + //! SMDS_Mesh identification in SMESH ShortType myMeshId; diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index e6755edc5..e447e3517 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -81,12 +81,14 @@ int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem) { // --- retrieve nodes ID + SMDS_MeshCell *cell = dynamic_cast(elem); + assert(cell); vector nodeIds; SMDS_ElemIteratorPtr it = elem->nodesIterator(); while(it->more()) { - int nodeId = it->next()->GetID(); - //MESSAGE(" node in cell " << ID << " : " <(it->next()))->getVtkId(); + MESSAGE(" node in cell " << cell->getVtkId() << " : " << nodeId) nodeIds.push_back(nodeId); } @@ -95,8 +97,6 @@ int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem) vtkUnstructuredGrid * grid = myMesh->getGrid(); int typ = GetVtkCellType(elem->GetType()); int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]); - SMDS_MeshCell *cell = dynamic_cast(elem); - assert(cell); cell->setVtkId(cellId); //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId); return cellId; @@ -120,7 +120,7 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) //======================================================================= SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) { - if ((ID<0) || (ID>myMax) || (myMesh->myIDElements[ID]<0)) + if ((ID<1) || (ID>myMax) || (myMesh->myCellIdSmdsToVtk[ID]<0)) return NULL; const SMDS_MeshElement* elem = GetMesh()->FindElement(ID); return (SMDS_MeshElement*)(elem); @@ -132,17 +132,17 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) //======================================================================= void SMDS_MeshElementIDFactory::ReleaseID(const int ID) { - if (ID < 0) + if (ID < 1) { //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); return; } - int vtkId = myMesh->myIDElements[ID]; + int vtkId = myMesh->myCellIdSmdsToVtk[ID]; //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId); if (ID >=0) { - myMesh->myIDElements[ID] = -1; - myMesh->myVtkIndex[vtkId] = -1; + myMesh->myCellIdSmdsToVtk[ID] = -1; + myMesh->myCellIdVtkToSmds[vtkId] = -1; } SMDS_MeshIDFactory::ReleaseID(ID); if (ID == myMax) @@ -160,8 +160,8 @@ void SMDS_MeshElementIDFactory::updateMinMax() const { myMin = IntegerLast(); myMax = 0; - for (int i=0; imyIDElements.size(); i++) - if (int id=myMesh->myIDElements[i] >=0) + for (int i=0; imyCellIdSmdsToVtk.size(); i++) + if (int id=myMesh->myCellIdSmdsToVtk[i] >=0) { if (id > myMax) myMax = id; if (id < myMin) myMin = id; @@ -182,7 +182,7 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const void SMDS_MeshElementIDFactory::Clear() { - myMesh->myIDElements.clear(); + myMesh->myCellIdSmdsToVtk.clear(); myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); } diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index ccb2ad658..30d44ddc9 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -36,7 +36,7 @@ using namespace std; //purpose : //======================================================================= -SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(-1), myMesh(0) +SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0), myMesh(0) { } @@ -64,7 +64,7 @@ int SMDS_MeshIDFactory::GetFreeID() //======================================================================= void SMDS_MeshIDFactory::ReleaseID(const int ID) { - if ( ID >= 0 ) + if ( ID > 0 ) { if ( ID < myMaxID ) { @@ -91,7 +91,7 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID) void SMDS_MeshIDFactory::Clear() { - myMaxID = -1; + myMaxID = 0; myPoolOfID.clear(); } @@ -107,8 +107,8 @@ SMDS_Mesh* SMDS_MeshIDFactory::GetMesh() void SMDS_MeshIDFactory::emptyPool(int maxId) { - MESSAGE("SMDS_MeshIDFactory::emptyPool " << myMaxID << " --> " << maxId-1); - myMaxID = maxId-1; + MESSAGE("SMDS_MeshIDFactory::emptyPool " << myMaxID << " --> " << maxId); + myMaxID = maxId; myPoolOfID.clear(); } diff --git a/src/SMDS/SMDS_MeshIDFactory.hxx b/src/SMDS/SMDS_MeshIDFactory.hxx index e936d0fed..87c515145 100644 --- a/src/SMDS/SMDS_MeshIDFactory.hxx +++ b/src/SMDS/SMDS_MeshIDFactory.hxx @@ -44,7 +44,7 @@ public: void SetMesh(SMDS_Mesh *mesh); SMDS_Mesh* GetMesh(); inline bool isPoolIdEmpty() { return myPoolOfID.empty(); }; - void emptyPool(int maxId); + virtual void emptyPool(int maxId); inline void adjustMaxId(int ID) { if (ID > myMaxID) myMaxID = ID;}; protected: SMDS_MeshIDFactory(); diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 71019c101..444a977a7 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -65,18 +65,20 @@ SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z) { + myVtkID = id -1; + assert(myVtkID >= 0); myID = id; myMeshId = meshId; myShapeId = shapeId; myIdInShape = -1; - //MESSAGE("Node " << myID << " (" << x << ", " << y << ", " << z << ")"); + //MESSAGE("Node " << myID << " " << myVtkID << " (" << x << ", " << y << ", " << z << ")"); SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId]; vtkUnstructuredGrid * grid = mesh->getGrid(); vtkPoints *points = grid->GetPoints(); - points->InsertPoint(myID, x, y, z); + points->InsertPoint(myVtkID, x, y, z); vtkCellLinks *cellLinks = grid->GetCellLinks(); - if (myID >=cellLinks->Size) - cellLinks->Resize(myID+SMDS_Mesh::chunkSize); + if (myVtkID >=cellLinks->Size) + cellLinks->Resize(myVtkID+SMDS_Mesh::chunkSize); } SMDS_MeshNode::~SMDS_MeshNode() @@ -94,7 +96,7 @@ void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent) //MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID()); const SMDS_MeshCell* cell = dynamic_cast(parent); MYASSERT(cell); - SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myID, cell->getVtkId()); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId()); } //======================================================================= @@ -193,7 +195,7 @@ public: SMDS_ElemIteratorPtr SMDS_MeshNode:: GetInverseElementIterator(SMDSAbs_ElementType type) const { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID); //MESSAGE("myID " << myID << " ncells " << l.ncells); return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } @@ -253,7 +255,7 @@ SMDS_ElemIteratorPtr SMDS_MeshNode:: return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); else { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID); return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } } @@ -266,7 +268,7 @@ int SMDS_MeshNode::NbNodes() const double* SMDS_MeshNode::getCoord() const { - return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myID); + return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID); } double SMDS_MeshNode::X() const @@ -291,7 +293,7 @@ double SMDS_MeshNode::Z() const void SMDS_MeshNode::setXYZ(double x, double y, double z) { vtkPoints *points = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoints(); - points->InsertPoint(myID, x, y, z); + points->InsertPoint(myVtkID, x, y, z); } SMDSAbs_ElementType SMDS_MeshNode::GetType() const @@ -312,7 +314,7 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME) { const SMDS_MeshCell *cell = dynamic_cast(ME); assert(cell); - SMDS_Mesh::_meshList[myMeshId]->getGrid()->AddReferenceToCell(myID, cell->getVtkId()); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->AddReferenceToCell(myVtkID, cell->getVtkId()); } //======================================================================= @@ -321,12 +323,12 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME) //======================================================================= void SMDS_MeshNode::ClearInverseElements() { - SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myID, 0); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myVtkID, 0); } bool SMDS_MeshNode::emptyInverseElements() { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID); return (l.ncells == 0); } @@ -338,7 +340,7 @@ bool SMDS_MeshNode::emptyInverseElements() int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID); if ( type == SMDSAbs_All ) return l.ncells; @@ -347,7 +349,7 @@ int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; for (int i=0; iFindNode(l.cells[i]); + const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i])); if (elem->GetType() == type) nb++; } @@ -359,7 +361,7 @@ int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const /////////////////////////////////////////////////////////////////////////////// bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2) { - return e1.GetID() class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement { - public: - SMDS_MeshNode(); - SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); - virtual ~SMDS_MeshNode(); + friend class SMESHDS_Mesh; + friend class SMDS_Mesh; + friend class ObjectPool; - void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); - double* getCoord() const; - void Print(std::ostream & OS) const; double X() const; double Y() const; double Z() const; - void AddInverseElement(const SMDS_MeshElement * ME); - void RemoveInverseElement(const SMDS_MeshElement * parent); - void ClearInverseElements(); - bool emptyInverseElements(); SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const; int NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const; - void SetPosition(const SMDS_PositionPtr& aPos); const SMDS_PositionPtr& GetPosition() const; SMDSAbs_ElementType GetType() const; virtual vtkIdType GetVtkType() const; SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;} int NbNodes() const; - void setXYZ(double x, double y, double z); + friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2); + void SetPosition(const SMDS_PositionPtr& aPos); + void AddInverseElement(const SMDS_MeshElement * ME); + void RemoveInverseElement(const SMDS_MeshElement * parent); + void ClearInverseElements(); + bool emptyInverseElements(); + void setXYZ(double x, double y, double z); + /*! * \brief Return node by its index * \param ind - node index * \retval const SMDS_MeshNode* - the node */ - virtual const SMDS_MeshNode* GetNode(const int) const { return this; } + //virtual const SMDS_MeshNode* GetNode(const int) const { return this; } static int nbNodes; + protected: + SMDS_MeshNode(); + SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); + virtual ~SMDS_MeshNode(); + void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); + inline void setVtkId(int vtkId) { myVtkID = vtkId; }; + SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.cxx b/src/SMDS/SMDS_MeshNodeIDFactory.cxx index 34259a2e2..d1a74b82b 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.cxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.cxx @@ -62,7 +62,7 @@ bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem) //======================================================================= SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID) { - if ((ID < 0) || (ID > myMax)) + if ((ID < 1) || (ID > myMax)) return NULL; const SMDS_MeshElement* elem = GetMesh()->FindNode(ID); return (SMDS_MeshElement*) (elem); @@ -127,3 +127,9 @@ void SMDS_MeshNodeIDFactory::Clear() myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); } + +void SMDS_MeshNodeIDFactory::emptyPool(int maxId) +{ + SMDS_MeshIDFactory::emptyPool(maxId); + myMax = maxId; +} diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.hxx b/src/SMDS/SMDS_MeshNodeIDFactory.hxx index 4caadf465..759dc8866 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.hxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.hxx @@ -46,6 +46,7 @@ public: int GetMinID() const; SMDS_ElemIteratorPtr elementsIterator() const; virtual void Clear(); + virtual void emptyPool(int maxId); protected: void updateMinMax() const; diff --git a/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx index b441db266..9d7be9028 100644 --- a/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx +++ b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx @@ -43,6 +43,7 @@ using namespace std; SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes (std::vector nodes) { + //MESSAGE("******************************************** SMDS_PolygonalFaceOfNodes"); myNodes = nodes; } diff --git a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx index 54143251a..1de208b1b 100644 --- a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx +++ b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx @@ -45,6 +45,7 @@ SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes vector quantities) : SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL) { + //MESSAGE("****************************************** SMDS_PolyhedralVolumeOfNodes"); ChangeNodes(nodes, quantities); } diff --git a/src/SMDS/SMDS_Position.cxx b/src/SMDS/SMDS_Position.cxx index a2dfc7847..7a84243be 100644 --- a/src/SMDS/SMDS_Position.cxx +++ b/src/SMDS/SMDS_Position.cxx @@ -26,6 +26,7 @@ // Module : SMESH // #include "SMDS_Position.hxx" +#include "utilities.h" //======================================================================= //function : SMDS_Position @@ -34,6 +35,7 @@ SMDS_Position::SMDS_Position(int aShapeId) :myShapeId(aShapeId) { + //MESSAGE("########################## SMDS_Position " << myShapeId); } //======================================================================= @@ -43,6 +45,7 @@ SMDS_Position::SMDS_Position(int aShapeId) :myShapeId(aShapeId) void SMDS_Position::SetShapeId(int aShapeId) { + //MESSAGE("############################## SetShapeId "<< aShapeId); myShapeId = aShapeId; } @@ -53,6 +56,7 @@ void SMDS_Position::SetShapeId(int aShapeId) int SMDS_Position::GetShapeId() const { + //MESSAGE("################################# GetShapeId " << myShapeId); return myShapeId; } diff --git a/src/SMDS/SMDS_QuadraticEdge.cxx b/src/SMDS/SMDS_QuadraticEdge.cxx index dcb11b06b..46d0e0f1c 100644 --- a/src/SMDS/SMDS_QuadraticEdge.cxx +++ b/src/SMDS/SMDS_QuadraticEdge.cxx @@ -30,6 +30,7 @@ #include "SMDS_SetIterator.hxx" #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" +#include "utilities.h" using namespace std; @@ -43,6 +44,7 @@ SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1, const SMDS_MeshNode * node12) :SMDS_LinearEdge(node1,node2) { + //MESSAGE("******************************************************* SMDS_QuadraticEdge"); myNodes[2]=node12; } diff --git a/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx index 6b69227ce..5170f492b 100644 --- a/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx +++ b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx @@ -49,6 +49,7 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1, const SMDS_MeshNode * n23, const SMDS_MeshNode * n31) { + //MESSAGE("********************************************** SMDS_QuadraticFaceOfNodes 1"); myNodes.resize( 6 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; @@ -73,6 +74,7 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1, const SMDS_MeshNode * n34, const SMDS_MeshNode * n41) { + //MESSAGE("********************************************* SMDS_QuadraticFaceOfNodes 2"); myNodes.resize( 8 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; diff --git a/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx index ea1147a4c..ff5e4eacd 100644 --- a/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx +++ b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx @@ -54,6 +54,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes const SMDS_MeshNode * n24, const SMDS_MeshNode * n34) { + //MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes"); myNodes.resize( 10 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; @@ -88,6 +89,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes const SMDS_MeshNode * n35, const SMDS_MeshNode * n45) { + //MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes"); myNodes.resize( 13 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; @@ -127,6 +129,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes const SMDS_MeshNode * n25, const SMDS_MeshNode * n36) { + //MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes"); myNodes.resize( 15 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; @@ -173,6 +176,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes const SMDS_MeshNode * n37, const SMDS_MeshNode * n48) { + //MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes"); myNodes.resize( 20 ); myNodes[ 0 ] = n1; myNodes[ 1 ] = n2; diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 9edb767cb..d676ffa70 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -205,12 +205,10 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New(); newTypes->Initialize(); - //newTypes->Allocate(oldCellSize); newTypes->SetNumberOfValues(newCellSize); vtkIdTypeArray *newLocations = vtkIdTypeArray::New(); newLocations->Initialize(); - //newLocations->Allocate(oldCellSize); newLocations->SetNumberOfValues(newCellSize); startHole = 0; @@ -251,7 +249,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n startBloc = i; compactState = lookBlocEnd; holes += endHole - startHole; - //alreadyCopied = startBloc -holes; } break; case lookBlocEnd: @@ -324,7 +321,8 @@ void SMDS_UnstructuredGrid::copyNodes(vtkPoints *newPoints, std::vector& id { memcpy(target, source, 3 * sizeof(float) * nbPoints); for (int j = start; j < end; j++) - idNodesOldToNew[j] = alreadyCopied++; + idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId + //idNodesOldToNew[alreadyCopied++] = idNodesOldToNew[j]; // new vtkId --> old SMDS id } } @@ -337,7 +335,7 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, std::vector for (int j = start; j < end; j++) { newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); - idCellsOldToNew[j] = alreadyCopied; + idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId vtkIdType oldLoc = this->Locations->GetValue(j); vtkIdType nbpts; vtkIdType *oldPtsCell = 0; diff --git a/src/SMDS/SMDS_VertexPosition.cxx b/src/SMDS/SMDS_VertexPosition.cxx index 6a2b7dc0d..4510dd330 100644 --- a/src/SMDS/SMDS_VertexPosition.cxx +++ b/src/SMDS/SMDS_VertexPosition.cxx @@ -39,6 +39,7 @@ using namespace std; SMDS_VertexPosition:: SMDS_VertexPosition(const int aVertexId) :SMDS_Position(aVertexId) { + //MESSAGE("*********************************************** SMDS_VertexPosition " << aVertexId); } //======================================================================= @@ -49,12 +50,13 @@ SMDS_VertexPosition:: SMDS_VertexPosition(const int aVertexId) const double *SMDS_VertexPosition::Coords() const { const static double origin[]={0,0,0}; - MESSAGE("SMDS_VertexPosition::Coords not implemented"); + //MESSAGE("######################### SMDS_VertexPosition::Coords not implemented"); return origin; } SMDS_TypeOfPosition SMDS_VertexPosition::GetTypeOfPosition() const { + //MESSAGE("################################################# GetTypeOfPosition"); return SMDS_TOP_VERTEX; } diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx index 6b006b938..4b3cabc1f 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.cxx +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -31,6 +31,7 @@ #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_IteratorOfElements.hxx" +#include "utilities.h" using namespace std; @@ -96,6 +97,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1, const SMDS_MeshFace * face3, const SMDS_MeshFace * face4) { + //MESSAGE("****************************************************** SMDS_VolumeOfFaces"); myNbFaces = 4; myFaces[0]=face1; myFaces[1]=face2; @@ -111,6 +113,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1, const SMDS_MeshFace * face4, const SMDS_MeshFace * face5) { + //MESSAGE("****************************************************** SMDS_VolumeOfFaces"); myNbFaces = 5; myFaces[0]=face1; myFaces[1]=face2; @@ -127,6 +130,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1, const SMDS_MeshFace * face5, const SMDS_MeshFace * face6) { + //MESSAGE("****************************************************** SMDS_VolumeOfFaces"); myNbFaces = 6; myFaces[0]=face1; myFaces[1]=face2; diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index 507fea94e..c17e21d26 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -49,6 +49,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node7, const SMDS_MeshNode * node8) { + //MESSAGE("***************************************************** SMDS_VolumeOfNodes"); myNbNodes = 8; myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; @@ -67,6 +68,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node3, const SMDS_MeshNode * node4) { + //MESSAGE("***************************************************** SMDS_VolumeOfNodes"); myNbNodes = 4; myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; @@ -82,6 +84,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node4, const SMDS_MeshNode * node5) { + //MESSAGE("***************************************************** SMDS_VolumeOfNodes"); myNbNodes = 5; myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; @@ -99,6 +102,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node5, const SMDS_MeshNode * node6) { + //MESSAGE("***************************************************** SMDS_VolumeOfNodes"); myNbNodes = 6; myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index fdf2be3f8..86660e54b 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -418,6 +418,7 @@ SMDS_VolumeTool::SMDS_VolumeTool () myFaceNodeIndices( NULL ), myFaceNodes( NULL ) { + //MESSAGE("******************************************************** SMDS_VolumeToo"); } //======================================================================= @@ -438,6 +439,7 @@ SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume) myFaceNodeIndices( NULL ), myFaceNodes( NULL ) { + //MESSAGE("******************************************************** SMDS_VolumeToo"); Set( theVolume ); } @@ -692,12 +694,13 @@ double SMDS_VolumeTool::GetSize() const if ( !myPolyedre ) return 0.; + SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myPolyedre->getMeshId()]; // split a polyhedron into tetrahedrons SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this ); XYZ baryCenter; me->GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z); - SMDS_MeshNode bcNode ( baryCenter.x, baryCenter.y, baryCenter.z ); + SMDS_MeshNode *bcNode = mesh->AddNode( baryCenter.x, baryCenter.y, baryCenter.z ); for ( int f = 0; f < NbFaces(); ++f ) { @@ -707,11 +710,12 @@ double SMDS_VolumeTool::GetSize() const double Vn = getTetraVolume( myFaceNodes[ 0 ], myFaceNodes[ n-1 ], myFaceNodes[ n ], - & bcNode ); + bcNode ); /// cout <<"++++ " << Vn << " nodes " <GetID() << " " <GetID() << " " <GetID() << " < " << V << endl; V += externalFace ? -Vn : Vn; } } + mesh->RemoveNode(bcNode); } else { diff --git a/src/SMDS/SMDS_VtkCellIterator.cxx b/src/SMDS/SMDS_VtkCellIterator.cxx index ef8f23a87..0a4163bb9 100644 --- a/src/SMDS/SMDS_VtkCellIterator.cxx +++ b/src/SMDS/SMDS_VtkCellIterator.cxx @@ -90,7 +90,7 @@ bool SMDS_VtkCellIterator::more() const SMDS_MeshElement* SMDS_VtkCellIterator::next() { vtkIdType id = _vtkIdList->GetId(_index++); - return _mesh->FindNode(id); + return _mesh->FindNodeVtk(id); } SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : diff --git a/src/SMDS/SMDS_VtkEdge.cxx b/src/SMDS/SMDS_VtkEdge.cxx index 1583839f0..b260e4e68 100644 --- a/src/SMDS/SMDS_VtkEdge.cxx +++ b/src/SMDS/SMDS_VtkEdge.cxx @@ -32,6 +32,7 @@ void SMDS_VtkEdge::init(std::vector nodeIds, SMDS_Mesh* mesh) if (nodeIds.size() == 3) aType = VTK_QUADRATIC_EDGE; myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + //MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID); } bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2) @@ -53,7 +54,7 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) } for (int i = 0; i < nbNodes; i++) { - pts[i] = nodes[i]->GetID(); + pts[i] = nodes[i]->getVtkId(); } return true; } @@ -64,7 +65,7 @@ bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const vtkIdType npts = 0; vtkIdType* pts = 0; grid->GetCellPoints(myVtkID, npts, pts); - return ((npts == 3) && (node->GetID() == pts[2])); + return ((npts == 3) && (node->getVtkId() == pts[2])); } void SMDS_VtkEdge::Print(std::ostream & OS) const diff --git a/src/SMDS/SMDS_VtkFace.cxx b/src/SMDS/SMDS_VtkFace.cxx index a69382dbb..83c4119b7 100644 --- a/src/SMDS/SMDS_VtkFace.cxx +++ b/src/SMDS/SMDS_VtkFace.cxx @@ -47,6 +47,7 @@ void SMDS_VtkFace::init(std::vector nodeIds, SMDS_Mesh* mesh) break; } myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + //MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID); } void SMDS_VtkFace::initPoly(std::vector nodeIds, SMDS_Mesh* mesh) @@ -70,7 +71,7 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) } for (int i = 0; i < nbNodes; i++) { - pts[i] = nodes[i]->GetID(); + pts[i] = nodes[i]->getVtkId(); } return true; } @@ -150,6 +151,43 @@ bool SMDS_VtkFace::IsPoly() const return (aVtkType == VTK_POLYGON); } +bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + int rankFirstMedium = 0; + switch (aVtkType) + { + case VTK_QUADRATIC_TRIANGLE: + rankFirstMedium = 3; // medium nodes are of rank 3,4,5 + break; + case VTK_QUADRATIC_QUAD: + rankFirstMedium = 4; // medium nodes are of rank 4,5,6,7 + break; + default: + return false; + } + vtkIdType npts = 0; + vtkIdType* pts = 0; + grid->GetCellPoints(myVtkID, npts, pts); + vtkIdType nodeId = node->getVtkId(); + for (int rank = 0; rank < npts; rank++) + { + if (pts[rank] == nodeId) + { + if (rank < rankFirstMedium) + return false; + else + return true; + } + } + //throw SALOME_Exception(LOCALIZED("node does not belong to this element")); + MESSAGE("======================================================"); + MESSAGE("= IsMediumNode: node does not belong to this element ="); + MESSAGE("======================================================"); + return false; +} + SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); diff --git a/src/SMDS/SMDS_VtkFace.hxx b/src/SMDS/SMDS_VtkFace.hxx index c5fee77d2..10cbf7ec3 100644 --- a/src/SMDS/SMDS_VtkFace.hxx +++ b/src/SMDS/SMDS_VtkFace.hxx @@ -27,6 +27,7 @@ public: virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual bool IsQuadratic() const; virtual bool IsPoly() const; + virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const; diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 123b91f71..4217efc03 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -56,6 +56,7 @@ void SMDS_VtkVolume::init(std::vector nodeIds, SMDS_Mesh* mesh) break; } myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + //MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID); } #ifdef VTK_HAVE_POLYHEDRON @@ -108,11 +109,66 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes } for (int i = 0; i < nbNodes; i++) { - pts[i] = nodes[i]->GetID(); + pts[i] = nodes[i]->getVtkId(); } return true; } +/*! + * Reorder in VTK order a list of nodes given in SMDS order. + * To be used before ChangeNodes: lists are given or computed in SMDS order. + */ +bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) +{ + if (nbNodes != this->NbNodes()) + { + MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes()); + return false; + } + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + switch (aVtkType) + { + case VTK_TETRA: + this->exchange(nodes, 1, 2); + break; + case VTK_QUADRATIC_TETRA: + this->exchange(nodes, 1, 2); + this->exchange(nodes, 4, 6); + this->exchange(nodes, 8, 9); + break; + case VTK_PYRAMID: + this->exchange(nodes, 1, 3); + break; + case VTK_WEDGE: + break; + case VTK_QUADRATIC_PYRAMID: + this->exchange(nodes, 1, 3); + this->exchange(nodes, 5, 8); + this->exchange(nodes, 6, 7); + this->exchange(nodes, 10, 12); + break; + case VTK_QUADRATIC_WEDGE: + break; + case VTK_HEXAHEDRON: + this->exchange(nodes, 1, 3); + this->exchange(nodes, 5, 7); + break; + case VTK_QUADRATIC_HEXAHEDRON: + this->exchange(nodes, 1, 3); + this->exchange(nodes, 5, 7); + this->exchange(nodes, 8, 11); + this->exchange(nodes, 9, 10); + this->exchange(nodes, 12, 15); + this->exchange(nodes, 13, 14); + this->exchange(nodes, 17, 19); + break; + case VTK_POLYHEDRON: + default: + break; + } +} + SMDS_VtkVolume::~SMDS_VtkVolume() { } @@ -283,7 +339,7 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int n 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 + node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node break; } id += (nodesInFace + 1); @@ -387,6 +443,49 @@ bool SMDS_VtkVolume::IsPoly() const return (aVtkType == VTK_POLYHEDRON); } +bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + int rankFirstMedium = 0; + switch (aVtkType) + { + case VTK_QUADRATIC_TETRA: + rankFirstMedium = 4; // medium nodes are of rank 4 to 9 + break; + case VTK_QUADRATIC_PYRAMID: + rankFirstMedium = 5; // medium nodes are of rank 5 to 12 + break; + case VTK_QUADRATIC_WEDGE: + rankFirstMedium = 6; // medium nodes are of rank 6 to 14 + break; + case VTK_QUADRATIC_HEXAHEDRON: + rankFirstMedium = 8; // medium nodes are of rank 8 to 19 + break; + default: + return false; + } + vtkIdType npts = 0; + vtkIdType* pts = 0; + grid->GetCellPoints(myVtkID, npts, pts); + vtkIdType nodeId = node->getVtkId(); + for (int rank = 0; rank < npts; rank++) + { + if (pts[rank] == nodeId) + { + if (rank < rankFirstMedium) + return false; + else + return true; + } + } + //throw SALOME_Exception(LOCALIZED("node does not belong to this element")); + MESSAGE("======================================================"); + MESSAGE("= IsMediumNode: node does not belong to this element ="); + MESSAGE("======================================================"); + return false; +} + SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); diff --git a/src/SMDS/SMDS_VtkVolume.hxx b/src/SMDS/SMDS_VtkVolume.hxx index 407a34c62..56b50b570 100644 --- a/src/SMDS/SMDS_VtkVolume.hxx +++ b/src/SMDS/SMDS_VtkVolume.hxx @@ -17,7 +17,8 @@ public: #ifdef VTK_HAVE_POLYHEDRON void initPoly(std::vector nodeIds, std::vector nbNodesPerFace, SMDS_Mesh* mesh); #endif - bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); + virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); + virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes); void Print(std::ostream & OS) const; int NbFaces() const; @@ -36,6 +37,7 @@ public: virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual bool IsQuadratic() const; virtual bool IsPoly() const; + virtual bool IsMediumNode(const SMDS_MeshNode* node) const; static void gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 2a885349c..8cee113f6 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -435,6 +435,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM const SMDS_EdgePosition* epos = static_cast(node->GetPosition()); theNodes.insert( make_pair( epos->GetUParameter(), node )); + //MESSAGE("U " << epos->GetUParameter() << " ID " << node->GetID()); ++nbNodes; } } @@ -443,6 +444,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM TopExp::Vertices(theEdge, v1, v2); const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh ); const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh ); + //MESSAGE("Vertices ID " << n1->GetID() << " " << n2->GetID()); Standard_Real f, l; BRep_Tool::Range(theEdge, f, l); if ( v1.Orientation() != TopAbs_FORWARD ) diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index c1d0bb871..aeac42ca2 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -796,6 +796,11 @@ bool SMESH_MeshEditor::DeleteDiag (const SMDS_MeshNode * theNode1, newElem = aMesh->AddFace( aNodes[0], aNodes[1], aNodes[2], aNodes[3] ); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr2 ); @@ -841,6 +846,11 @@ bool SMESH_MeshEditor::DeleteDiag (const SMDS_MeshNode * theNode1, aNodes[4], aNodes[5], aNodes[6], aNodes[7]); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr2 ); @@ -2148,6 +2158,11 @@ bool SMESH_MeshEditor::TriToQuad (TIDSortedElemSet & theElems, newElem = aMesh->AddFace(n12[0], n12[1], n12[2], n12[3] ); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr2 ); } @@ -2172,6 +2187,11 @@ bool SMESH_MeshEditor::TriToQuad (TIDSortedElemSet & theElems, aNodes[4], aNodes[5], aNodes[6], aNodes[7]); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr2 ); // remove middle node (9) @@ -2186,6 +2206,11 @@ bool SMESH_MeshEditor::TriToQuad (TIDSortedElemSet & theElems, newElem = aMesh->AddFace(n13[0], n13[1], n13[2], n13[3] ); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr3 ); } @@ -2210,6 +2235,11 @@ bool SMESH_MeshEditor::TriToQuad (TIDSortedElemSet & theElems, aNodes[4], aNodes[5], aNodes[6], aNodes[7]); myLastCreatedElems.Append(newElem); AddToSameGroups( newElem, tr1, aMesh ); + int aShapeId = tr1->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } aMesh->RemoveElement( tr1 ); aMesh->RemoveElement( tr3 ); // remove middle node (9) @@ -3299,7 +3329,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, } } - //cout<<" nbSame = "<GetID() ); //INFOS( " Too many same nodes of element " << elem->GetID() ); @@ -3336,6 +3366,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, } // make new elements + const SMDS_MeshElement* lastElem = elem; for (int iStep = 0; iStep < nbSteps; iStep++ ) { // get next nodes for ( iNode = 0; iNode < nbNodes; iNode++ ) { @@ -3351,7 +3382,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, nextNod[ iNode ] = *itNN[ iNode ]; itNN[ iNode ]++; } - else if(!elem->IsQuadratic() || elem->IsMediumNode(prevNod[iNode]) ) { + else if(!elem->IsQuadratic() || lastElem->IsMediumNode(prevNod[iNode]) ) { // we have to use each second node //itNN[ iNode ]++; nextNod[ iNode ] = *itNN[ iNode ]; @@ -3656,6 +3687,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, newElems.push_back( aNewElem ); myLastCreatedElems.Append(aNewElem); srcElements.Append( elem ); + lastElem = aNewElem; } // set new prev nodes @@ -4455,6 +4487,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, const gp_Pnt& theRefPoint, const bool theMakeGroups) { + MESSAGE("ExtrusionAlongTrack"); myLastCreatedElems.Clear(); myLastCreatedNodes.Clear(); @@ -4858,6 +4891,7 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet& theElements, const gp_Pnt& theRefPoint, const bool theMakeGroups) { + MESSAGE("MakeExtrElements"); //cout<<"MakeExtrElements fullList.size() = "< aPPs(aNbTP); @@ -5013,6 +5047,7 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet& theElements, } // make new node + //MESSAGE("elem->IsQuadratic " << elem->IsQuadratic() << " " << elem->IsMediumNode(node)); if( elem->IsQuadratic() && !elem->IsMediumNode(node) ) { // create additional node double x = ( aPN1.X() + aPN0.X() )/2.; @@ -5982,9 +6017,8 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher */ const SMDS_MeshNode* FindClosestTo( const gp_Pnt& thePnt ) { - SMDS_MeshNode tgtNode( thePnt.X(), thePnt.Y(), thePnt.Z() ); map dist2Nodes; - myOctreeNode->NodesAround( &tgtNode, dist2Nodes, myHalfLeafSize ); + myOctreeNode->NodesAround( thePnt.Coord(), dist2Nodes, myHalfLeafSize ); if ( !dist2Nodes.empty() ) return dist2Nodes.begin()->second; list nodes; @@ -6000,13 +6034,12 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher list< SMESH_OctreeNode* >::iterator trIt; treeList.push_back( myOctreeNode ); - SMDS_MeshNode pointNode( thePnt.X(), thePnt.Y(), thePnt.Z() ); for ( trIt = treeList.begin(); trIt != treeList.end(); ++trIt) { SMESH_OctreeNode* tree = *trIt; if ( !tree->isLeaf() ) // put children to the queue { - if ( !tree->isInside( &pointNode, myHalfLeafSize )) continue; + if ( !tree->isInside( thePnt.Coord(), myHalfLeafSize )) continue; SMESH_OctreeNodeIteratorPtr cIt = tree->GetChildrenIterator(); while ( cIt->more() ) treeList.push_back( cIt->next() ); @@ -6359,7 +6392,6 @@ double SMESH_ElementSearcherImpl::getTolerance() meshInfo.NbElements( SMDSAbs_ElementType( complexType )) < 1 ) --complexType; if ( complexType == SMDSAbs_All ) return 0; // empty mesh - double elemSize; if ( complexType == int( SMDSAbs_Node )) { @@ -6370,8 +6402,9 @@ double SMESH_ElementSearcherImpl::getTolerance() } else { - const SMDS_MeshElement* elem = - _mesh->elementsIterator( SMDSAbs_ElementType( complexType ))->next(); + SMDS_ElemIteratorPtr elemIt = + _mesh->elementsIterator( SMDSAbs_ElementType( complexType )); + const SMDS_MeshElement* elem = elemIt->next(); SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); SMESH_MeshEditor::TNodeXYZ n1( cast2Node( nodeIt->next() )); while ( nodeIt->more() ) @@ -6833,6 +6866,7 @@ bool SMESH_MeshEditor::isOut( const SMDS_MeshElement* element, const gp_Pnt& poi // get ordered nodes vector< gp_XYZ > xyz; + vector nodeList; SMDS_ElemIteratorPtr nodeIt = element->nodesIterator(); if ( element->IsQuadratic() ) @@ -6842,7 +6876,11 @@ bool SMESH_MeshEditor::isOut( const SMDS_MeshElement* element, const gp_Pnt& poi nodeIt = e->interlacedNodesElemIterator(); while ( nodeIt->more() ) - xyz.push_back( TNodeXYZ( cast2Node( nodeIt->next() ))); + { + const SMDS_MeshNode* node = cast2Node( nodeIt->next() ); + xyz.push_back( TNodeXYZ(node) ); + nodeList.push_back(node); + } int i, nbNodes = element->NbNodes(); @@ -6851,6 +6889,7 @@ bool SMESH_MeshEditor::isOut( const SMDS_MeshElement* element, const gp_Pnt& poi // compute face normal gp_Vec faceNorm(0,0,0); xyz.push_back( xyz.front() ); + nodeList.push_back( nodeList.front() ); for ( i = 0; i < nbNodes; ++i ) { gp_Vec edge1( xyz[i+1], xyz[i]); @@ -6863,9 +6902,7 @@ bool SMESH_MeshEditor::isOut( const SMDS_MeshElement* element, const gp_Pnt& poi // degenerated face: point is out if it is out of all face edges for ( i = 0; i < nbNodes; ++i ) { - SMDS_MeshNode n1( xyz[i].X(), xyz[i].Y(), xyz[i].Z() ); - SMDS_MeshNode n2( xyz[i+1].X(), xyz[i+1].Y(), xyz[i+1].Z() ); - SMDS_LinearEdge edge( &n1, &n2 ); + SMDS_LinearEdge edge( nodeList[i], nodeList[i+1] ); if ( !isOut( &edge, point, tol )) return false; } @@ -9271,7 +9308,8 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, // face does not exist SMESHDS_Mesh* aMesh = GetMeshDS(); - SMDS_Mesh aTmpFacesMesh; + // TODO algoritm not OK with vtkUnstructuredGrid: 2 meshes can't share nodes + //SMDS_Mesh aTmpFacesMesh; // try to use the same mesh set faceSet1, faceSet2; set volSet1, volSet2; set nodeSet1, nodeSet2; @@ -9281,6 +9319,7 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, TIDSortedElemSet * elemSetPtr[] = { &theSide1, &theSide2 }; int iSide, iFace, iNode; + list tempFaceList; for ( iSide = 0; iSide < 2; iSide++ ) { set * nodeSet = nodeSetPtr[ iSide ]; TIDSortedElemSet * elemSet = elemSetPtr[ iSide ]; @@ -9400,18 +9439,23 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, if ( !aFreeFace ) { // create a temporary face if ( nbNodes == 3 ) { - aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2] ); + //aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2] ); + aFreeFace = aMesh->AddFace( fNodes[0],fNodes[1],fNodes[2] ); } else if ( nbNodes == 4 ) { - aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + //aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + aFreeFace = aMesh->AddFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); } else { vector poly_nodes ( fNodes, & fNodes[nbNodes]); - aFreeFace = aTmpFacesMesh.AddPolygonalFace(poly_nodes); + //aFreeFace = aTmpFacesMesh.AddPolygonalFace(poly_nodes); + aFreeFace = aMesh->AddPolygonalFace(poly_nodes); } } - if ( aFreeFace ) + if ( aFreeFace ) { freeFaceList.push_back( aFreeFace ); + tempFaceList.push_back( aFreeFace ); + } } // loop on faces of a volume @@ -9525,9 +9569,12 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, if ( faceSet1.size() != faceSet2.size() ) { // delete temporary faces: they are in reverseElements of actual nodes - SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); - while ( tmpFaceIt->more() ) - aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); +// SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); +// while ( tmpFaceIt->more() ) +// aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); +// list::iterator tmpFaceIt = tempFaceList.begin(); +// for (; tmpFaceIt !=tempFaceList.end(); ++tmpFaceIt) +// aMesh->RemoveElement(*tmpFaceIt); MESSAGE("Diff nb of faces"); return SEW_TOPO_DIFF_SETS_OF_ELEMENTS; } @@ -9783,9 +9830,12 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, // ==================================================================== // delete temporary faces: they are in reverseElements of actual nodes - SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); - while ( tmpFaceIt->more() ) - aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); +// SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); +// while ( tmpFaceIt->more() ) +// aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); +// list::iterator tmpFaceIt = tempFaceList.begin(); +// for (; tmpFaceIt !=tempFaceList.end(); ++tmpFaceIt) +// aMesh->RemoveElement(*tmpFaceIt); if ( aResult != SEW_OK) return aResult; @@ -9826,6 +9876,11 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1, { myLastCreatedElems.Append(newElem); AddToSameGroups(newElem, e, aMesh); + int aShapeId = e->getshapeId(); + if ( aShapeId ) + { + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } } aMesh->RemoveElement(e); } @@ -10377,7 +10432,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromSmdsToVtk(anElem->getId()); + int vtkId = meshDS->fromSmdsToVtk(anElem->GetID()); int neighborsVtkIds[NBMAXNEIGHBORS]; int downIds[NBMAXNEIGHBORS]; unsigned char downTypes[NBMAXNEIGHBORS]; diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 33e7ceb70..c25a16ee9 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -651,6 +651,8 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge& E, { if ( force || !myOkNodePosShapes.count( n->GetPosition()->GetShapeId() )) { + double toldis = tol; + // TODO if (toldis < 5.e-5) toldis = 5.e-5; // nodes coordinates are stored in float format // check that u is correct TopLoc_Location loc; double f,l; Handle(Geom_Curve) curve = BRep_Tool::Curve( E,loc,f,l ); @@ -666,7 +668,7 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge& E, { gp_Pnt nodePnt = SMESH_MeshEditor::TNodeXYZ( n ); if ( !loc.IsIdentity() ) nodePnt.Transform( loc.Transformation().Inverted() ); - if ( nodePnt.Distance( curve->Value( u )) > tol ) + if ( nodePnt.Distance( curve->Value( u )) > toldis ) { // u incorrect, project the node to the curve GeomAPI_ProjectPointOnCurve projector( nodePnt, curve, f, l ); @@ -676,9 +678,10 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge& E, return false; } Quantity_Parameter U = projector.LowerDistanceParameter(); - if ( nodePnt.Distance( curve->Value( U )) > tol ) + if ( nodePnt.Distance( curve->Value( U )) > toldis ) { MESSAGE( "SMESH_MesherHelper::CheckNodeU(), invalid projection" ); + MESSAGE("distance " << nodePnt.Distance(curve->Value( U )) << " " << toldis); return false; } u = double( U ); diff --git a/src/SMESH/SMESH_OctreeNode.cxx b/src/SMESH/SMESH_OctreeNode.cxx index 37a7d4f1b..1832abc23 100644 --- a/src/SMESH/SMESH_OctreeNode.cxx +++ b/src/SMESH/SMESH_OctreeNode.cxx @@ -24,7 +24,7 @@ // inherites global class SMESH_Octree // File : SMESH_OctreeNode.cxx // Created : Tue Jan 16 16:00:00 2007 -// Author : Nicolas Geimer & Aurélien Motteux (OCC) +// Author : Nicolas Geimer & Aurelien Motteux (OCC) // Module : SMESH // #include "SMESH_OctreeNode.hxx" @@ -107,9 +107,9 @@ Bnd_B3d* SMESH_OctreeNode::buildRootBox() */ //==================================================================================== -const bool SMESH_OctreeNode::isInside (const SMDS_MeshNode * Node, const double precision) +const bool SMESH_OctreeNode::isInside (const gp_XYZ& p, const double precision) { - gp_XYZ p (Node->X(),Node->Y(),Node->Z()); + //gp_XYZ p (Node->X(),Node->Y(),Node->Z()); if (precision <= 0.) return !(getBox().IsOut(p)); Bnd_B3d BoxWithPrecision = getBox(); @@ -159,7 +159,8 @@ void SMESH_OctreeNode::NodesAround (const SMDS_MeshNode * Node, list* Result, const double precision) { - if (isInside(Node,precision)) + gp_XYZ p(Node->X(), Node->Y(), Node->Z()); + if (isInside(p, precision)) { if (isLeaf()) { @@ -186,7 +187,7 @@ void SMESH_OctreeNode::NodesAround (const SMDS_MeshNode * Node, */ //================================================================================ -bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode * node, +bool SMESH_OctreeNode::NodesAround(const gp_XYZ &node, map& dist2Nodes, double precision) { @@ -195,13 +196,14 @@ bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode * node, else if ( precision == 0. ) precision = maxSize() / 2; - if (isInside(node,precision)) + //gp_XYZ p(node->X(), node->Y(), node->Z()); + if (isInside(node, precision)) { if (!isLeaf()) { // first check a child containing node gp_XYZ mid = (getBox().CornerMin() + getBox().CornerMax()) / 2.; - int nodeChild = getChildIndex( node->X(), node->Y(), node->Z(), mid ); + int nodeChild = getChildIndex( node.X(), node.Y(), node.Z(), mid ); if ( ((SMESH_OctreeNode*) myChildren[nodeChild])->NodesAround(node, dist2Nodes, precision)) return true; @@ -213,7 +215,7 @@ bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode * node, else if ( NbNodes() > 0 ) { double minDist = precision * precision; - gp_Pnt p1 ( node->X(), node->Y(), node->Z() ); + gp_Pnt p1 ( node.X(), node.Y(), node.Z() ); set::iterator nIt = myNodes.begin(); for ( ; nIt != myNodes.end(); ++nIt ) { @@ -320,7 +322,8 @@ void SMESH_OctreeNode::FindCoincidentNodes (const SMDS_MeshNode * Node, list* Result, const double precision) { - bool isInsideBool = isInside(Node,precision); + gp_XYZ p(Node->X(), Node->Y(), Node->Z()); + bool isInsideBool = isInside(p, precision); if (isInsideBool) { @@ -386,8 +389,7 @@ void SMESH_OctreeNode::UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt set::iterator pNode = myNodes.find( node ); bool nodeInMe = ( pNode != myNodes.end() ); - SMDS_MeshNode pointNode( toPnt.X(), toPnt.Y(), toPnt.Z() ); - bool pointInMe = isInside( &pointNode, 1e-10 ); + bool pointInMe = isInside( toPnt.Coord(), 1e-10 ); if ( pointInMe != nodeInMe ) { diff --git a/src/SMESH/SMESH_OctreeNode.hxx b/src/SMESH/SMESH_OctreeNode.hxx index f5e3fbf52..477a76350 100644 --- a/src/SMESH/SMESH_OctreeNode.hxx +++ b/src/SMESH/SMESH_OctreeNode.hxx @@ -24,13 +24,14 @@ // inherites global class SMESH_Octree // File : SMESH_OctreeNode.hxx // Created : Tue Jan 16 16:00:00 2007 -// Author : Nicolas Geimer & Aurélien Motteux (OCC) +// Author : Nicolas Geimer & Aurelien Motteux (OCC) // Module : SMESH // #ifndef _SMESH_OCTREENODE_HXX_ #define _SMESH_OCTREENODE_HXX_ #include "SMESH_Octree.hxx" +#include #include #include @@ -61,7 +62,7 @@ public: virtual ~SMESH_OctreeNode () {}; // Tells us if Node is inside the current box with the precision "precision" - virtual const bool isInside(const SMDS_MeshNode * Node, const double precision = 0.); + virtual const bool isInside(const gp_XYZ& p, const double precision = 0.); // Return in Result a list of Nodes potentials to be near Node void NodesAround(const SMDS_MeshNode * Node, @@ -69,7 +70,7 @@ public: const double precision = 0.); // Return in dist2Nodes nodes mapped to their square distance from Node - bool NodesAround(const SMDS_MeshNode * Node, + bool NodesAround(const gp_XYZ& node, std::map& dist2Nodes, double precision); diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index db558bd89..825f37664 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -1808,33 +1808,14 @@ void SMESHDS_Mesh::compactMesh() { if (myNodes[i]) { - idNodesOldToNew[i] = i; // all valid id are >= 0 + int vtkid = myNodes[i]->getVtkId(); + idNodesOldToNew[vtkid] = i; // old vtkId --> old smdsId (valid smdsId are >= 0) newNodeSize++; } } bool areNodesModified = (newNodeSize < nbVtkNodes); - MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified); - -// bool areNodesModified = !myNodeIDFactory->isPoolIdEmpty(); -// MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified); -// if (areNodesModified) -// { -// for (int i = 0; i < nbNodes; i++) -// { -// if (myNodes[i]) -// { -// idNodesOldToNew[i] = i; // all valid id are >= 0 -// newNodeSize++; -// } -// } -// } -// else -// { -// for (int i = 0; i < nbNodes; i++) -// idNodesOldToNew[i] = i; -// if (nbNodes > nbVtkNodes) -// newNodeSize = nbVtkNodes; // else 0 means nothing to change (no need to compact vtkPoints) -// } + MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified); + areNodesModified = true; int newCellSize = 0; int nbCells = myCells.size(); @@ -1851,11 +1832,29 @@ void SMESHDS_Mesh::compactMesh() { if (myCells[i]) { - idCellsOldToNew[i] = myVtkIndex[i]; // valid vtk indexes are > = 0 +// //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0 +// int vtkid = myCells[i]->getVtkId(); +// idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input) newCellSize++; } } - myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize); + if (areNodesModified) + myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize); + else + myGrid->compactGrid(idNodesOldToNew, 0, idCellsOldToNew, newCellSize); + + int nbVtkPts = myGrid->GetNumberOfPoints(); + nbVtkCells = myGrid->GetNumberOfCells(); + if (nbVtkPts != newNodeSize) + { + MESSAGE("===> nbVtkPts != newNodeSize " << nbVtkPts << " " << newNodeSize); + if (nbVtkPts > newNodeSize) newNodeSize = nbVtkPts; // several points with same SMDS Id + } + if (nbVtkCells != newCellSize) + { + MESSAGE("===> nbVtkCells != newCellSize " << nbVtkCells << " " << newCellSize); + if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id + } // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory @@ -1863,51 +1862,55 @@ void SMESHDS_Mesh::compactMesh() { MESSAGE("-------------- modify myNodes"); SetOfNodes newNodes; - newNodes.resize(newNodeSize); - + newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n + int newSmdsId = 0; for (int i = 0; i < nbNodes; i++) { if (myNodes[i]) { - int newid = idNodesOldToNew[i]; - //MESSAGE(i << " --> " << newid);; - myNodes[i]->setId(newid); - newNodes[newid] = myNodes[i]; + newSmdsId++; // SMDS id start to 1 + int oldVtkId = myNodes[i]->getVtkId(); + int newVtkId = idNodesOldToNew[oldVtkId]; + //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId); + myNodes[i]->setVtkId(newVtkId); + myNodes[i]->setId(newSmdsId); + newNodes[newSmdsId] = myNodes[i]; + //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]"); } } myNodes.swap(newNodes); - this->myNodeIDFactory->emptyPool(newNodeSize); + this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes + MESSAGE("myNodes.size " << myNodes.size()); } - // --- SMDS_MeshCell, myIDElements and myVtkIndex (myCells and myElementIdFactory are not compacted) + // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells - int vtkIndexSize = myVtkIndex.size(); - int maxVtkId = 0; + int vtkIndexSize = myCellIdVtkToSmds.size(); + int maxVtkId = -1; for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++) { - int smdsId = this->myVtkIndex[oldVtkId]; - if (smdsId >= 0) + int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId]; + if (oldSmdsId > 0) { int newVtkId = idCellsOldToNew[oldVtkId]; if (newVtkId > maxVtkId) maxVtkId = newVtkId; - //MESSAGE("===========> smdsId newVtkId " << smdsId << " " << newVtkId); - myCells[smdsId]->setVtkId(newVtkId); - myIDElements[smdsId] = newVtkId; - myVtkIndex[newVtkId] = smdsId; + //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId); + myCells[oldSmdsId]->setVtkId(newVtkId); } } - maxVtkId++; - MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() ); - MESSAGE("maxVtkId=" << maxVtkId); +// MESSAGE("myCells.size()=" << myCells.size() +// << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size() +// << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() ); SetOfCells newCells; vector newSmdsToVtk; vector newVtkToSmds; - newCells.resize(maxVtkId, 0); - newSmdsToVtk.resize(maxVtkId, -1); - newVtkToSmds.resize(maxVtkId, -1); + assert(maxVtkId < newCellSize); + newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n + newSmdsToVtk.resize(newCellSize+1, -1); + newVtkToSmds.resize(newCellSize+1, -1); int myCellsSize = myCells.size(); int newSmdsId = 0; @@ -1915,24 +1918,28 @@ void SMESHDS_Mesh::compactMesh() { if (myCells[i]) { - //MESSAGE(newSmdsId << " " << i); + newSmdsId++; // SMDS id start to 1 + assert(newSmdsId <= newCellSize); newCells[newSmdsId] = myCells[i]; + newCells[newSmdsId]->setId(newSmdsId); + //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]"); int idvtk = myCells[i]->getVtkId(); newSmdsToVtk[newSmdsId] = idvtk; - assert(idvtk < maxVtkId); + assert(idvtk < newCellSize); newVtkToSmds[idvtk] = newSmdsId; - myCells[i]->setId(newSmdsId); - newSmdsId++; - assert(newSmdsId <= maxVtkId); } } myCells.swap(newCells); - myIDElements.swap(newSmdsToVtk); - myVtkIndex.swap(newVtkToSmds); - MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() ); + myCellIdSmdsToVtk.swap(newSmdsToVtk); + myCellIdVtkToSmds.swap(newVtkToSmds); + MESSAGE("myCells.size()=" << myCells.size() + << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size() + << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() ); this->myElementIDFactory->emptyPool(newSmdsId); + this->myScript->SetModified(true); // notify GUI client for buildPrs when update + // ---TODO: myNodes, myElements in submeshes // map::iterator it = myShapeIndexToSubMesh.begin(); diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index ee44a116b..4e2bcba7f 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -121,7 +121,7 @@ namespace SMESH TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey); if(anIter != VISUAL_OBJ_CONT.end()) { // for unknown reason, object destructor is not called, so clear object manually - anIter->second->GetUnstructuredGrid()->SetCells(0,0,0); + anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0); anIter->second->GetUnstructuredGrid()->SetPoints(0); } VISUAL_OBJ_CONT.erase(aKey); @@ -163,7 +163,7 @@ namespace SMESH TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin(); for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) { // for unknown reason, object destructor is not called, so clear object manually - anIter->second->GetUnstructuredGrid()->SetCells(0,0,0); + anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0); anIter->second->GetUnstructuredGrid()->SetPoints(0); } VISUAL_OBJ_CONT.clear(); @@ -208,7 +208,7 @@ namespace SMESH int curId = anIter->first.first; if ( curId == studyID ) { // for unknown reason, object destructor is not called, so clear object manually - anIter->second->GetUnstructuredGrid()->SetCells(0,0,0); + anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0); anIter->second->GetUnstructuredGrid()->SetPoints(0); VISUAL_OBJ_CONT.erase( anIter-- ); // dercement occures before erase() } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index d05ec1a6a..4a1bbbc5e 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1984,6 +1984,7 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme SMESH::SMESH_MeshEditor::Extrusion_Error & theError, const SMDSAbs_ElementType theElementType) { + MESSAGE("extrusionAlongPath"); initData(); if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) { @@ -2150,6 +2151,7 @@ SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfEleme CORBA::Boolean theHasRefPoint, const SMESH::PointStruct & theRefPoint) { + MESSAGE("ExtrusionAlongPath"); if ( !myPreviewMode ) { TPythonDump() << "error = " << this << ".ExtrusionAlongPath( " << theIDsOfElements << ", " diff --git a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx index 24a1e3fa9..d278711db 100644 --- a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx @@ -1004,8 +1004,8 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh ) // store the rest nodes row by row - SMDS_MeshNode dummy(0,0,0); - const SMDS_MeshElement* firstQuad = &dummy;// most left face above the last row of found nodes + const SMDS_MeshNode* dummy = mesh.GetMeshDS()->AddNode(0,0,0); + const SMDS_MeshElement* firstQuad = dummy; // most left face above the last row of found nodes int nbFoundNodes = myIndexer._xSize; while ( nbFoundNodes != myGrid.size() ) @@ -1072,7 +1072,7 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh ) n1up = n2up; } } - + mesh.GetMeshDS()->RemoveNode(dummy); DumpGrid(); // debug return true; diff --git a/src/StdMeshers/StdMeshers_Projection_2D.cxx b/src/StdMeshers/StdMeshers_Projection_2D.cxx index 7af5ee189..0b52cde5f 100644 --- a/src/StdMeshers/StdMeshers_Projection_2D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_2D.cxx @@ -374,6 +374,7 @@ namespace { SMESH_Mesh * srcMesh, const TAssocTool::TShapeShapeMap& shape2ShapeMap) { + MESSAGE("projectPartner"); const double tol = 1e-6; gp_Trsf trsf; // transformation to get location of target nodes from source ones @@ -412,6 +413,7 @@ namespace { { gp_Vec p0p1( srcPP[0], srcPP[1] ), p0p( srcPP[0], p ); pOK = !p0p1.IsParallel( p0p, tol ); + // TODO angle pOK = !p0p1.IsParallel( p0p, 3.14/6 ); break; } } @@ -544,6 +546,7 @@ namespace { // create a new node gp_Pnt tgtP = gp_Pnt(srcNode->X(),srcNode->Y(),srcNode->Z()).Transformed( trsf ); srcN_tgtN->second = helper.AddNode( tgtP.X(), tgtP.Y(), tgtP.Z() ); + //MESSAGE(tgtP.X() << " " << tgtP.Y() << " " << tgtP.Z()); } tgtFaceNodes.push_back( srcN_tgtN->second ); } @@ -566,6 +569,7 @@ namespace { bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) { + MESSAGE("Projection_2D Compute"); if ( !_sourceHypo ) return false;