I want to write a grid library,the code like belows
data HMesh m v hf f c=HMesh{
hmesh_get_vertices:: HMap.HashMap Int (HVertex v),
hmesh_get_halffaces:: HMap.HashMap Int (HHalfFace hf),
hmesh_get_faces:: HMap.HashMap Int (HFace f),
hmesh_get_cells:: HMap.HashMap Int (HCell c),
hmesh_get_vertices_name_id:: Int,
hmesh_get_halffaces_name_id:: Int,
hmesh_get_faces_name_id:: Int,
hmesh_get_cells_name_id:: Int,
hmesh_get_dimension:: Int,
hmesh_get_simplex:: Bool,
hmesh_get_manifold_require:: Bool,
hmesh_get_traits:: (Maybe m)
}deriving (Show)
When I create a mesh that contains 10000 triangles,my program runs well.
When I create a mesh that contains 400000 triangle, my program runs so slowly that I can’t wait for it’s result.
The every operation need to alter the mesh, I suspect Haskell needs to recalculate the data HMesh every time.
I want to know how to optimize this problem?I think the key point is to optimize the HashMap to avoid recalculate container.