]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PR: debug polygons and merge nodes
authorprascle <prascle>
Sun, 5 Dec 2010 19:22:06 +0000 (19:22 +0000)
committerprascle <prascle>
Sun, 5 Dec 2010 19:22:06 +0000 (19:22 +0000)
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_UnstructuredGrid.cxx
src/SMDS/SMDS_VtkVolume.cxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHDS/SMESHDS_Mesh.cxx
src/SMESHGUI/SMESHGUI_MeshInfo.cxx

index 5660a566d642907460a9d40b165cf4e9afca890d..b5a86f8dcfaef86b57cd5326fd7ce234e4716902 100644 (file)
@@ -1162,7 +1162,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
   else
     {
 //#ifdef VTK_HAVE_POLYHEDRON
-    MESSAGE("AddPolygonalFaceWithID vtk " << ID);
+    //MESSAGE("AddPolygonalFaceWithID vtk " << ID);
     vector<vtkIdType> nodeIds;
     nodeIds.clear();
     vector<const SMDS_MeshNode*>::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<vtkIdType> nodeIds;
       nodeIds.clear();
       vector<const SMDS_MeshNode*>::iterator it = nodes.begin();
index 6ac09cc31d2a7030b9a37917c201893612e010b1..00d50a9d4b2d05ece0f25bcb580ab039109a78e6 100644 (file)
@@ -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<vtkIdType> 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<vtkIdType>::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);
     }
index b76fe9d65bbc2e0d2ed2d9ee3d8306a25d0e4375..3f5026f371b15f792872354221655b3140e570d0 100644 (file)
@@ -63,9 +63,8 @@ void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
 //#ifdef VTK_HAVE_POLYHEDRON
 void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> 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(), &center[0]);
   vector<vtkIdType> ptIds;
@@ -76,14 +75,13 @@ void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> 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
index b5c2af386a451fd74ead178ec2d79dbe01ba467f..5579ca090397014aa5c8ebe76471ea91bf1fa51e 100644 (file)
@@ -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<const SMDS_MeshNode *> polygons_nodes;
           vector<int> 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<const SMDS_MeshNode *> 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);
index 2b6fde92fd2235a4cbd726170b8d5f4495e6cf76..4d522b5d770ed3bc0ccc4308533175fd12ca7333 100644 (file)
@@ -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;
 
index 16a33b199ecc3fe06f73b5da7ae78db23569b032..255951008d61b34e164fef509623fdf3f1ce6537 100644 (file)
@@ -55,6 +55,8 @@
 #include <QTreeWidget>
 #include <QVBoxLayout>
 
+#include "utilities.h"
+
 #include <SALOMEconfig.h>
 #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;