Esempio n. 1
0
bool LaplaceSmoother::setNewPosition(vtkIdType id_node, vec3_t x_new)
{
  using namespace GeometryTools;

  vec3_t x_old;
  m_Grid->GetPoint(id_node, x_old.data());
  EG_VTKDCN(vtkCharArray, node_type, m_Grid, "node_type");
  bool move = true;
  if(m_NoCheck) {
    return move;
  }
  QVector<vec3_t> old_cell_normals(m_Part.n2cGSize(id_node));
  EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");
  for (int i = 0; i < m_Part.n2cGSize(id_node); ++i) {
    old_cell_normals[i] = GeometryTools::cellNormal(m_Grid, m_Part.n2cGG(id_node, i));
  }
  m_Grid->GetPoints()->SetPoint(id_node, x_new.data());

  for (int i = 0; i < m_Part.n2cGSize(id_node); ++i) {
    vec3_t n = GeometryTools::cellNormal(m_Grid, m_Part.n2cGG(id_node, i));
    if (n*old_cell_normals[i] < 0.2*old_cell_normals[i].abs2()) {
      move = false;
      break;
    }
  }
  if (!move) {
    m_Grid->GetPoints()->SetPoint(id_node, x_old.data());
  }
  return move;
}
Esempio n. 2
0
              //x_new = GuiMainWindow::pointer()->getCadInterface(bc)->correctCurvature(GuiMainWindow::pointer()->getCadInterface(bc)->lastProjTriangle(), x_new);
              x_new = GuiMainWindow::pointer()->getCadInterface(bc)->correctCurvature(x_new);
            }
          }
        }

      }
    }

    // compute the minimal length of any edge adjacent to this node
    // .. This will be used to limit the node movement.
    // .. Hopefully jammed topologies can be avoided this way.
    //
    EG_VTKDCN(vtkDoubleArray, cl, m_Grid, "node_meshdensity_desired");
    vec3_t x_old;
    m_Grid->GetPoint(id_node, x_old.data());
    double L_min = cl->GetValue(id_node);
    for (int i = 0; i < m_Part.n2nGSize(id_node); ++i) {
      vtkIdType id_neigh = m_Part.n2nGG(id_node, i);
      vec3_t x_neigh;
      m_Grid->GetPoint(id_neigh, x_neigh.data());
      L_min = min(L_min, (x_old - x_neigh).abs());
    }

    // limit node displacement
    vec3_t dx = x_new - x_old;
    if (dx.abs() > m_Limit*L_min) {
      x_new -= dx;
      dx.normalise();
      x_new += m_Limit*L_min*dx;
    }