void Foam::CV2D::insertGrid() { Info<< "insertInitialGrid: "; startOfInternalPoints_ = number_of_vertices(); label nVert = startOfInternalPoints_; scalar x0 = qSurf_.globalBounds().min().x(); scalar xR = qSurf_.globalBounds().max().x() - x0; int ni = int(xR/meshControls().minCellSize()) + 1; scalar deltax = xR/ni; scalar y0 = qSurf_.globalBounds().min().y(); scalar yR = qSurf_.globalBounds().max().y() - y0; int nj = int(yR/meshControls().minCellSize()) + 1; scalar deltay = yR/nj; Random rndGen(1321); scalar pert = meshControls().randomPerturbation()*min(deltax, deltay); for (int i=0; i<ni; i++) { for (int j=0; j<nj; j++) { point p(x0 + i*deltax, y0 + j*deltay, 0); if (meshControls().randomiseInitialGrid()) { p.x() += pert*(rndGen.scalar01() - 0.5); p.y() += pert*(rndGen.scalar01() - 0.5); } if (qSurf_.wellInside(p, 0.5*meshControls().minCellSize2())) { insert(Point(p.x(), p.y()))->index() = nVert++; } } } Info<< nVert << " vertices inserted" << endl; if (meshControls().objOutput()) { // Checking validity of triangulation assert(is_valid()); writeTriangles("initial_triangles.obj", true); writeFaces("initial_faces.obj", true); } }
void PartitionIO<MeshType>::write (const meshPartsPtr_Type& meshParts) { M_meshPartsOut = meshParts; M_numParts = M_meshPartsOut->size(); M_HDF5IO.openFile (M_fileName, M_comm, false); writeStats(); writePoints(); writeEdges(); writeFaces(); writeElements(); M_HDF5IO.closeFile(); M_meshPartsOut.reset(); }
void D3MFExporter::writeMesh( aiMesh *mesh ) { if ( nullptr == mesh ) { return; } mModelOutput << "<" << XmlTag::mesh << ">" << std::endl; mModelOutput << "<" << XmlTag::vertices << ">" << std::endl; for ( unsigned int i = 0; i < mesh->mNumVertices; ++i ) { writeVertex( mesh->mVertices[ i ] ); } mModelOutput << "</" << XmlTag::vertices << ">" << std::endl; writeFaces( mesh ); mModelOutput << "</" << XmlTag::mesh << ">" << std::endl; }
void Foam::CV2D::insertPoints ( const point2DField& points, const scalar nearness ) { Info<< "insertInitialPoints(const point2DField& points): "; startOfInternalPoints_ = number_of_vertices(); label nVert = startOfInternalPoints_; // Add the points and index them forAll(points, i) { const point2D& p = points[i]; if (qSurf_.wellInside(toPoint3D(p), nearness)) { insert(toPoint(p))->index() = nVert++; } else { Warning << "Rejecting point " << p << " outside surface" << endl; } } Info<< nVert << " vertices inserted" << endl; if (meshControls().objOutput()) { // Checking validity of triangulation assert(is_valid()); writeTriangles("initial_triangles.obj", true); writeFaces("initial_faces.obj", true); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SurfaceMeshDataContainerWriter::execute() { int err = 0; std::stringstream ss; setErrorCondition(err); SurfaceMeshDataContainer* sm = getSurfaceMeshDataContainer(); if(NULL == sm) { setErrorCondition(-999); notifyErrorMessage("The Surfacemesh DataContainer Object was NULL", -999); return; } setErrorCondition(0); // Create the HDF5 Group for the Data Container err = H5Utilities::createGroupsFromPath(DREAM3D::HDF5::SurfaceMeshDataContainerName.c_str(), m_HdfFileId); if (err < 0) { ss.str(""); ss << "Error creating HDF Group " << DREAM3D::HDF5::SurfaceMeshDataContainerName << std::endl; setErrorCondition(-60); addErrorMessage(getHumanLabel(), ss.str(), err); return; } hid_t dcGid = H5Gopen(m_HdfFileId, DREAM3D::HDF5::SurfaceMeshDataContainerName.c_str(), H5P_DEFAULT ); if (dcGid < 0) { ss.str(""); ss << "Error opening Group " << DREAM3D::HDF5::SurfaceMeshDataContainerName << std::endl; setErrorCondition(-61); addErrorMessage(getHumanLabel(), ss.str(), err); return; } // Add some VTK hints into the group err = createVtkObjectGroup(DREAM3D::HDF5::SurfaceMeshDataContainerName, H5_VTK_POLYDATA); if (err < 0) { return; } writeXdmfGridHeader(); H5GroupAutoCloser dcGidAutoCloser(&dcGid); err = writeVertices(dcGid); if (err < 0) { return; } err = writeMeshVertLinks(dcGid); if (err < 0) { return; } err = writeVertexAttributeData(dcGid); if (err < 0) { return; } err = writeFaces(dcGid); if (err < 0) { return; } err = writeMeshFaceNeighborLists(dcGid); if (err < 0) { return; } err = writeFaceAttributeData(dcGid); if (err < 0) { return; } err = writeEdges(dcGid); if (err < 0) { return; } err = writeEdgeAttributeData(dcGid); if (err < 0) { return; } err = writeFieldData(dcGid); if (err < 0) { H5Gclose(dcGid); // Close the Data Container Group return; } err = writeEnsembleData(dcGid); if (err < 0) { H5Gclose(dcGid); // Close the Data Container Group return; } // Now finally close the group and the HDf5 File H5Gclose(dcGid); // Close the Data Container Group dcGid = -1; writeXdmfGridFooter(); notifyStatusMessage("Complete"); }