From 43a4d0b5c1ac4677ceb09f3059053e60c911bcf6 Mon Sep 17 00:00:00 2001 From: prascle Date: Sun, 5 Dec 2010 19:22:06 +0000 Subject: [PATCH] PR: debug polygons and merge nodes --- src/SMDS/SMDS_Mesh.cxx | 4 ++-- src/SMDS/SMDS_UnstructuredGrid.cxx | 6 +++--- src/SMDS/SMDS_VtkVolume.cxx | 25 ++++++++++++------------- src/SMESH/SMESH_MeshEditor.cxx | 24 +++++++++++++++++++++--- src/SMESHDS/SMESHDS_Mesh.cxx | 2 +- src/SMESHGUI/SMESHGUI_MeshInfo.cxx | 6 ++++-- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 5660a566d..b5a86f8dc 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -1162,7 +1162,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID else { //#ifdef VTK_HAVE_POLYHEDRON - MESSAGE("AddPolygonalFaceWithID vtk " << ID); + //MESSAGE("AddPolygonalFaceWithID vtk " << ID); vector nodeIds; nodeIds.clear(); vector::iterator it = nodes.begin(); @@ -1257,7 +1257,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID else { //#ifdef VTK_HAVE_POLYHEDRON - MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); + //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); vector nodeIds; nodeIds.clear(); vector::iterator it = nodes.begin(); diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 6ac09cc31..00d50a9d4 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -92,7 +92,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); // --- type = VTK_POLYHEDRON - MESSAGE("InsertNextLinkedCell VTK_POLYHEDRON"); + //MESSAGE("InsertNextLinkedCell VTK_POLYHEDRON"); int cellid = this->InsertNextCell(type, npts, pts); set setOfNodes; @@ -105,7 +105,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p i++; for (int k = 0; k < nbnodes; k++) { - MESSAGE(" cell " << cellid << " face " << nf << " node " << pts[i]); + //MESSAGE(" cell " << cellid << " face " << nf << " node " << pts[i]); setOfNodes.insert(pts[i]); i++; } @@ -114,7 +114,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p set::iterator it = setOfNodes.begin(); for (; it != setOfNodes.end(); ++it) { - MESSAGE("reverse link for node " << *it << " cell " << cellid); + //MESSAGE("reverse link for node " << *it << " cell " << cellid); this->Links->ResizeCellList(*it, 1); this->Links->AddCellReference(cellid, *it); } diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index b76fe9d65..3f5026f37 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -63,9 +63,8 @@ void SMDS_VtkVolume::init(std::vector nodeIds, SMDS_Mesh* mesh) //#ifdef VTK_HAVE_POLYHEDRON void SMDS_VtkVolume::initPoly(std::vector nodeIds, std::vector nbNodesPerFace, SMDS_Mesh* mesh) { - MESSAGE("SMDS_VtkVolume::initPoly"); + //MESSAGE("SMDS_VtkVolume::initPoly"); SMDS_UnstructuredGrid* grid = mesh->getGrid(); - // TODO is it useful to orient faces ? double center[3]; this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), ¢er[0]); vector ptIds; @@ -76,14 +75,13 @@ void SMDS_VtkVolume::initPoly(std::vector nodeIds, std::vector n { int nf = nbNodesPerFace[i]; ptIds.push_back(nf); -// double a[3]; -// double b[3]; -// double c[3]; -// grid->GetPoints()->GetPoint(nodeIds[k], a); -// grid->GetPoints()->GetPoint(nodeIds[k + 1], b); -// grid->GetPoints()->GetPoint(nodeIds[k + 2], c); -// bool isFaceForward = this->isForward(a, b, c, center); - bool isFaceForward = true; + double a[3]; + double b[3]; + double c[3]; + grid->GetPoints()->GetPoint(nodeIds[k], a); + grid->GetPoints()->GetPoint(nodeIds[k + 1], b); + grid->GetPoints()->GetPoint(nodeIds[k + 2], c); + bool isFaceForward = this->isForward(a, b, c, center); //MESSAGE("isFaceForward " << i << " " << isFaceForward); vtkIdType *facePts = &nodeIds[k]; if (isFaceForward) @@ -571,9 +569,10 @@ bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d) w[j] = d[j] - a[j]; //MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]); } - double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1] + (u[3] * v[1] - u[1] * v[3]) * w[2] + (u[1] * v[2] - u[2] - * v[1]) * w[3]; - return (prodmixte >= 0); + double prodmixte = (u[1]*v[2] - u[2]*v[1]) * w[0] + + (u[2]*v[0] - u[0]*v[2]) * w[1] + + (u[0]*v[1] - u[1]*v[0]) * w[2]; + return (prodmixte < 0); } /*! For polyhedron only diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index b5c2af386..5579ca090 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -5310,22 +5310,37 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, string groupPostfix; switch ( theTrsf.Form() ) { case gp_PntMirror: + MESSAGE("gp_PntMirror"); + needReverse = true; + groupPostfix = "mirrored"; + break; case gp_Ax1Mirror: + MESSAGE("gp_Ax1Mirror"); + groupPostfix = "mirrored"; + break; case gp_Ax2Mirror: + MESSAGE("gp_Ax2Mirror"); needReverse = true; groupPostfix = "mirrored"; break; case gp_Rotation: + MESSAGE("gp_Rotation"); groupPostfix = "rotated"; break; case gp_Translation: + MESSAGE("gp_Translation"); groupPostfix = "translated"; break; case gp_Scale: + MESSAGE("gp_Scale"); + groupPostfix = "scaled"; + break; case gp_CompoundTrsf: // different scale by axis + MESSAGE("gp_CompoundTrsf"); groupPostfix = "scaled"; break; default: + MESSAGE("default"); needReverse = false; groupPostfix = "transformed"; } @@ -7368,10 +7383,9 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) vector polygons_nodes; vector quantities; int nbNew = SimplifyFace(face_nodes, polygons_nodes, quantities); - if (nbNew > 0) { inode = 0; - for (int iface = 0; iface < nbNew - 1; iface++) { + for (int iface = 0; iface < nbNew; iface++) { int nbNodes = quantities[iface]; vector poly_nodes (nbNodes); for (int ii = 0; ii < nbNodes; ii++, inode++) { @@ -7838,7 +7852,11 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) //MESSAGE("Change regular element or polygon " << elemId); SMDSAbs_ElementType etyp = elem->GetType(); uniqueNodes.resize(nbUniqueNodes); - SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false); + SMDS_MeshElement* newElem = 0; + if (elem->GetEntityType() == SMDSEntity_Polygon) + newElem = this->AddElement(uniqueNodes, etyp, true); + else + newElem = this->AddElement(uniqueNodes, etyp, false); if (newElem) { myLastCreatedElems.Append(newElem); diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 2b6fde92f..4d522b5d7 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -216,7 +216,7 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, const SMDS_MeshNode * nodes[], const int nbnodes) { - MESSAGE("SMESHDS_Mesh::ChangeElementNodes"); + //MESSAGE("SMESHDS_Mesh::ChangeElementNodes"); if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes )) return false; diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index 16a33b199..255951008 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -55,6 +55,8 @@ #include #include +#include "utilities.h" + #include #include CORBA_SERVER_HEADER(SMESH_Group) @@ -667,7 +669,7 @@ void SMESHGUI_SimpleElemInfo::showInfo( long id, bool isElem ) gtype = tr( "QUADRANGLE" ); break; case SMDSEntity_Polygon: case SMDSEntity_Quad_Polygon: - gtype = tr( "QUADRANGLE" ); break; + gtype = tr( "POLYGON" ); break; case SMDSEntity_Tetra: case SMDSEntity_Quad_Tetra: gtype = tr( "TETRAHEDRON" ); break; @@ -913,7 +915,7 @@ void SMESHGUI_TreeElemInfo::showInfo( long id, bool isElem ) gtype = tr( "QUADRANGLE" ); break; case SMDSEntity_Polygon: case SMDSEntity_Quad_Polygon: - gtype = tr( "QUADRANGLE" ); break; + gtype = tr( "POLYGON" ); break; case SMDSEntity_Tetra: case SMDSEntity_Quad_Tetra: gtype = tr( "TETRAHEDRON" ); break; -- 2.39.2