Release triangulation data in TopoDS_Shape after it is displayed?

After TopoDS_Shape is rendered by AIS_Shape, triangulation data will be automatically generated, and this data will be stored inside TopoDS_Shape. After this data is rendered, it will still occupy memory. How can I clean up this part of memory?

Dmitrii Pasukhin's picture

Hello. BRepTools will help you

BRepTools::Clean OCCT/src/BRepTools/BRepTools.hxx at master · Open-Cascade-SAS/OCCT

  //! Removes all cached polygonal representation of the shape,
  //! i.e. the triangulations of the faces of <S> and polygons on
  //! triangulations and polygons 3d of the edges.
  //! In case polygonal representation is the only available representation
  //! for the shape (shape does not have geometry) it is not removed.
  //! @param theShape  [in] the shape to clean
  //! @param theForce  [in] allows removing all polygonal representations from the shape,
  //!                       including polygons on triangulations irrelevant for the faces of the given shape.
  Standard_EXPORT static void Clean (const TopoDS_Shape& theShape, const Standard_Boolean theForce = Standard_False);