// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
SharedVertexList::Pointer GEOM_CLASS_NAME::CreateSharedVertexList(int64_t numVertices)
{
  QVector<size_t> vertDims(1, 3);
  SharedVertexList::Pointer vertices = SharedVertexList::CreateArray(numVertices, vertDims, DREAM3D::Geometry::SharedVertexList);
  vertices->initializeWithZeros();
  return vertices;
}
Esempio n. 2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight)
{
  herr_t err = 0;
  SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err);
  SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedEdgeList>(DREAM3D::Geometry::SharedEdgeList, parentId, preflight, err);
  if (edges.get() == NULL || vertices.get() == NULL)
  {
    return -1;
  }
  size_t numEdges = edges->getNumberOfTuples();
  size_t numVerts = vertices->getNumberOfTuples();
  FloatArrayType::Pointer edgeCentroids = GeometryHelpers::GeomIO::ReadListFromHDF5<FloatArrayType>(DREAM3D::StringConstants::EdgeCentroids, parentId, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  ElementDynamicList::Pointer edgeNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgeNeighbors, parentId, numEdges, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }
  ElementDynamicList::Pointer edgesContainingVert = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgesContainingVert, parentId, numVerts, preflight, err);
  if (err < 0 && err != -2)
  {
    return -1;
  }

  setVertices(vertices);
  setEdges(edges);
  setElementCentroids(edgeCentroids);
  setElementNeighbors(edgeNeighbors);
  setElementsContainingVert(edgesContainingVert);

  return 1;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void GEOM_CLASS_NAME::setVertices(SharedVertexList::Pointer vertices)
{
  if (vertices.get() != NULL)
  {
    if (vertices->getName().compare(DREAM3D::Geometry::SharedVertexList) != 0)
    {
      vertices->setName(DREAM3D::Geometry::SharedVertexList);
    }
  }
  m_VertexList = vertices;
}
Esempio n. 4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int VertexGeom::readGeometryFromHDF5(hid_t parentId, bool preflight)
{
  herr_t err = 0;
  SharedVertexList::Pointer vertices = SharedVertexList::NullPointer();
  vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err);
  if (vertices.get() == NULL)
  {
    return -1;
  }

  setVertices(vertices);

  return 1;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MakeDataContainer::dataCheck()
{
  DataArrayPath tempPath;
  setErrorCondition(0);
  DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName());
  if (getErrorCondition() < 0)
  {
    return;
  }
  QVector<size_t> tDims(3, 64);
  AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell);
  if (getErrorCondition() < 0)
  {
    return;
  }
  //  tDims.resize(1);
  //  tDims[0] = 0;
  //  AttributeMatrix::Pointer cellEnsembleAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellEnsembleAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellEnsemble);
  //  if(getErrorCondition() < 0)
  //  {
  //    return;
  //  }

  QVector<size_t> dims(1, 1);
  m_FeatureIdsPtr = cellAttrMat->createNonPrereqArray<DataArray<int32_t>, AbstractFilter, int32_t>(this,  m_FeatureIdsArrayName, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */
  if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */
  {
    m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0);    /* Now assign the raw pointer to data from the DataArray<T> object */
  }

  //ImageGeom::Pointer image = ImageGeom::CreateGeometry("TestImageGeom");
  //image->setResolution(0.1f, 0.2f, 0.3f);
  //image->setOrigin(100.3f, 987.234f, 0.0f);
  //image->setDimensions(64, 64, 64);
  //m->setGeometry(image);

  VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(100, "TestVertexGeom");
  SharedVertexList::Pointer test = vertices->getVertices();
  float* verts = test->getPointer(0);
  for (int64_t i = 0; i < vertices->getNumberOfVertices(); i++)
  {
    verts[3 * i] = float(0.1 + i);
    verts[3 * i + 1] = float(0.2 + i);
    verts[3 * i + 2] = float(0.3 + i);
  }
  m->setGeometry(vertices);

}
    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;
      }
    }
    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;
      }
    }
Esempio n. 8
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
VertexGeom::Pointer VertexGeom::CreateGeometry(SharedVertexList::Pointer vertices, const QString& name)
{
  if (name.isEmpty() == true)
  {
    return VertexGeom::NullPointer();
  }
  if (vertices.get() == NULL)
  {
    return VertexGeom::NullPointer();
  }
  VertexGeom* d = new VertexGeom();
  d->setVertices(vertices);
  d->setName(name);
  Pointer ptr(d);
  return ptr;
}
Esempio n. 9
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;
      }
    }
Esempio n. 10
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QuadGeom::Pointer QuadGeom::CreateGeometry(SharedQuadList::Pointer quads, SharedVertexList::Pointer vertices, const QString& name)
{
  if (name.isEmpty() == true)
  {
    return NullPointer();
  }
  if (vertices.get() == NULL)
  {
    return QuadGeom::NullPointer();
  }
  if (quads.get() == NULL)
  {
    return QuadGeom::NullPointer();
  }
  QuadGeom* d = new QuadGeom();
  d->setVertices(vertices);
  d->setQuads(quads);
  d->setName(name);
  Pointer ptr(d);
  return ptr;
}