コード例 #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int TriangleGeom::readGeometryFromHDF5(hid_t parentId, bool preflight)
{
  herr_t err = 0;
  SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err);
  SharedTriList::Pointer tris = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedQuadList>(DREAM3D::Geometry::SharedTriList, parentId, preflight, err);
  if (tris.get() == NULL || vertices.get() == NULL)
  {
    return -1;
  }
  size_t numTris = tris->getNumberOfTuples();
  size_t numVerts = vertices->getNumberOfTuples();
  SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedEdgeList>(DREAM3D::Geometry::SharedEdgeList, parentId, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  SharedEdgeList::Pointer bEdges = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedEdgeList>(DREAM3D::Geometry::UnsharedEdgeList, parentId, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  FloatArrayType::Pointer triCentroids = GeometryHelpers::GeomIO::ReadListFromHDF5<FloatArrayType>(DREAM3D::StringConstants::TriangleCentroids, parentId, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  ElementDynamicList::Pointer triNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::TriangleNeighbors, parentId, numTris, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  ElementDynamicList::Pointer trisContainingVert = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::TrianglesContainingVert, parentId, numVerts, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }

  setVertices(vertices);
  setEdges(edges);
  setUnsharedEdges(bEdges);
  setTriangles(tris);
  setElementCentroids(triCentroids);
  setElementNeighbors(triNeighbors);
  setElementsContainingVert(trisContainingVert);

  return 1;
}
コード例 #2
0
    void generate(size_t start, size_t end) const
    {
      float* nodes = m_Nodes->getPointer(0);
      int64_t* triangles = m_Triangles->getPointer(0);

      for (size_t i = start; i < end; i++)
      {
        m_Centroids[i * 3]  = (nodes[triangles[i * 3] * 3 + 0] + nodes[triangles[i * 3 + 1] * 3 + 0] + nodes[triangles[i * 3 + 2] * 3 + 0]) / 3.0;
        m_Centroids[i * 3 + 1] = (nodes[triangles[i * 3] * 3 + 1] + nodes[triangles[i * 3 + 1] * 3 + 1] + nodes[triangles[i * 3 + 2] * 3 + 1]) / 3.0;
        m_Centroids[i * 3 + 2]  = (nodes[triangles[i * 3] * 3 + 2] + nodes[triangles[i * 3 + 1] * 3 + 2] + nodes[triangles[i * 3 + 2] * 3 + 2]) / 3.0;
      }
    }
コード例 #3
0
    void generate(size_t start, size_t end) const
    {
        int64_t* triangles = m_Triangles->getPointer(0);

        for (size_t i = start; i < end; i++)
        {
            // Swap the indices
            int64_t nId0 = triangles[i * 3 + 0];
            int64_t nId2 = triangles[i * 3 + 2];

            triangles[i * 3 + 0] = nId2;
            triangles[i * 3 + 2] = nId0;
        }
    }
コード例 #4
0
    void generate(size_t start, size_t end) const
    {
      float* nodes = m_Nodes->getPointer(0);
      int64_t* triangles = m_Triangles->getPointer(0);
      int64_t nIdx0 = 0, nIdx1 = 0, nIdx2 = 0;
      for (size_t i = start; i < end; i++)
      {
        nIdx0 = triangles[i * 3] * 3;
        nIdx1 = triangles[i * 3 + 1] * 3;
        nIdx2 = triangles[i * 3 + 2] * 3;
        float* n0 = &(nodes[nIdx0]);
        float* n1 = &(nodes[nIdx1]);
        float* n2 = &(nodes[nIdx2]);

        VectorType normal = TriangleOps::computeNormal(n0, n1, n2);
        m_Normals[i * 3 + 0] = normal.x;
        m_Normals[i * 3 + 1] = normal.y;
        m_Normals[i * 3 + 2] = normal.z;
      }
    }
コード例 #5
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
TriangleGeom::Pointer TriangleGeom::CreateGeometry(SharedTriList::Pointer triangles, SharedVertexList::Pointer vertices, const QString& name)
{
  if (name.isEmpty() == true)
  {
    return NullPointer();
  }
  if (vertices.get() == NULL)
  {
    return TriangleGeom::NullPointer();
  }
  if (triangles.get() == NULL)
  {
    return TriangleGeom::NullPointer();
  }
  TriangleGeom* d = new TriangleGeom();
  d->setVertices(vertices);
  d->setTriangles(triangles);
  d->setName(name);
  Pointer ptr(d);
  return ptr;
}
コード例 #6
0
    void generate(size_t start, size_t end) const
    {
      int64_t* triangles = m_Triangles->getPointer(0);
      int64_t nIdx0 = 0, nIdx1 = 0, nIdx2 = 0;
      float vecA[3] = { 0.0f, 0.0f, 0.0f };
      float vecB[3] = { 0.0f, 0.0f, 0.0f };
      float cross[3] = { 0.0f, 0.0f, 0.0f };
      for (size_t i = start; i < end; i++)
      {
        nIdx0 = triangles[i * 3];
        nIdx1 = triangles[i * 3 + 1];
        nIdx2 = triangles[i * 3 + 2];
        float* A = m_Nodes->getPointer(nIdx0 * 3);
        float* B = m_Nodes->getPointer(nIdx1 * 3);
        float* C = m_Nodes->getPointer(nIdx2 * 3);

        MatrixMath::Subtract3x1s(A, B, vecA);
        MatrixMath::Subtract3x1s(A, C, vecB);
        MatrixMath::CrossProduct(vecA, vecB, cross);
        float area = 0.5f * MatrixMath::Magnitude3x1(cross);
        m_Areas[i] = area;
      }
    }