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; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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); 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; } }