コード例 #1
0
void cartesianMeshExtractor::createMesh()
{
    Info << "Extracting polyMesh" << endl;

    //- create points and pointLeaves addressing
    createPointsAndAddressing();

    //- create the mesh
    createPolyMesh();

    //- decompose split-hex cells into tetrahedra and pyramids
    decomposeSplitHexesIntoTetsAndPyramids();

    //- remove unused vertices
    polyMeshGenModifier(mesh_).removeUnusedVertices();

    Info << "Mesh has :" << nl
        << mesh_.points().size() << " vertices " << nl
        << mesh_.faces().size() << " faces" << nl
        << mesh_.cells().size() << " cells" << endl;

    if( Pstream::parRun() )
    {
        label nCells = mesh_.cells().size();
        reduce(nCells, sumOp<label>());
        Info << "Total number of cells " << nCells << endl;
    }
    if( mesh_.cells().size() == 0 )
    {
        FatalErrorIn
        (
            "void cartesianMeshExtractor::createMesh()"
        ) << "There are no cells in the mesh!"
        << nl << "The reasons for this can be fwofold:"
        << nl << "1. Inadequate mesh resolution."
        << nl << "2. You maxCellSize is a multiplier of the domain length."
        << " This can be reolved by reducing the maxCellSize by a fraction."
        << "i.e. 2.49999 instead of 2.5." << exit(FatalError);
    }

    Info << "Finished extracting polyMesh" << endl;
}
コード例 #2
0
void voronoiMeshExtractor::createMesh()
{
    Info << "Extracting voronoi mesh" << endl;

    //- copy tet points into the mesh
    createPoints();

    //- create the mesh
    createPolyMesh();

    polyMeshGenModifier(mesh_).reorderBoundaryFaces();
    polyMeshGenModifier(mesh_).removeUnusedVertices();

    Info << "Mesh has :" << nl
        << mesh_.points().size() << " vertices " << nl
        << mesh_.faces().size() << " faces" << nl
        << mesh_.cells().size() << " cells" << endl;

    Info << "Finished extracting voronoi mesh" << endl;
}
コード例 #3
0
ファイル: navMesh.cpp プロジェクト: belzilep/Torque3D
   bool NavMesh::generateMesh()
   {
      // Parse objects from level into RC-compatible format
      NavModelData data = NavMeshLoader::mergeModels(
         NavMeshLoader::parseTerrainData(getWorldBox(), 0),
         NavMeshLoader::parseStaticObjects(getWorldBox()),
         true);

      // Check for no geometry
      if(!data.getVertCount())
         return false;

      // Free intermediate and final results
      freeIntermediates(true);

      // Create mInPolys if we don't have one already
      if(!mInPolys && mSaveIntermediates)
         mInPolys = new ConcretePolyList();

      // Reconstruct input geometry from out data
      if(mSaveIntermediates)
         RCtoPolyList(&data, mInPolys);

      // Recast initialisation data
      rcContext ctx(false);
      rcConfig cfg;

      dMemset(&cfg, 0, sizeof(cfg));
      cfg.cs = mCellSize;
      cfg.ch = mCellHeight;
      rcCalcBounds(data.verts, data.getVertCount(), cfg.bmin, cfg.bmax);
      rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height);
      cfg.walkableHeight = mCeil(mWalkableHeight / mCellHeight);
      cfg.walkableClimb = mCeil(mWalkableClimb / mCellHeight);
      cfg.walkableRadius = mCeil(mWalkableRadius / mCellSize);
      cfg.walkableSlopeAngle = mWalkableSlope;
      cfg.borderSize = mBorderSize;
      cfg.detailSampleDist = mDetailSampleDist;
      cfg.detailSampleMaxError = mDetailSampleMaxError;
      cfg.maxEdgeLen = mMaxEdgeLen;
      cfg.maxSimplificationError = mMaxSimplificationError;
      cfg.maxVertsPerPoly = 3;
      cfg.minRegionArea = mMinRegionArea;
      cfg.mergeRegionArea = mMergeRegionArea;
      cfg.tileSize = mTileSize;

      if(!createPolyMesh(cfg, data, &ctx))
         return false;

      //Detour initialisation data
      dtNavMeshCreateParams params;
      dMemset(&params, 0, sizeof(params));

      params.walkableHeight = cfg.walkableHeight;
      params.walkableRadius = cfg.walkableRadius;
      params.walkableClimb = cfg.walkableClimb;
      params.tileX = 0;
      params.tileY = 0;
      params.tileLayer = 0;
      rcVcopy(params.bmax, cfg.bmax);
      rcVcopy(params.bmin, cfg.bmin);
      params.buildBvTree = true;
      params.ch = cfg.ch;
      params.cs = cfg.cs;

      params.verts = pm->verts;
      params.vertCount = pm->nverts;
      params.polys = pm->polys;
      params.polyAreas = pm->areas;
      params.polyFlags = pm->flags;
      params.polyCount = pm->npolys;
      params.nvp = pm->nvp;

      params.detailMeshes = pmd->meshes;
      params.detailVerts = pmd->verts;
      params.detailVertsCount = pmd->nverts;
      params.detailTris = pmd->tris;
      params.detailTriCount = pmd->ntris;

      if(!createNavMesh(params))
         return false;

      return true;
   }