Import STL with good quality

Hello everyone,

I use the code below to import a STL file and to show that on view. But actually there is a difference between reel stl file and imported stl file. Generally same but looks different and imported like bad quality. So is there an opinion to get better my visualization?

        TCollection_AsciiString theFileName = toAsciiString(inp);
        auto polyTriangulation = RWStl::ReadFile(theFileName.ToCString());
        auto aShape = TopoDS_Face();
        auto aBuilder = BRep_Builder();
        aBuilder.MakeFace(aShape, polyTriangulation);
        Handle(AIS_Shape) shape = new AIS_Shape(aShape);
        importedStl() = shape;
        myAISContext()->Display(importedStl(), AIS_Shaded, 0, true);

gkv311 n's picture

You may try changing theMergeAngle parameter to a reasonable value to avoid merging triangulation nodes at sharp edges. Or use some better mesh file format, not that simple and limited as STL.

  57   //! Read specified STL file and returns its content as triangulation.
  58   //! @param[in] theFile file path to read
  59   //! @param[in] theMergeAngle maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angle
  60   //! @param[in] theProgress progress indicator
  61   //! @return result triangulation or NULL in case of error
  62   Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
  63                                                               const Standard_Real theMergeAngle,
  64                                                               const Message_ProgressRange& theProgress = Message_ProgressRange());
Batuhan Cengiz's picture

You're the best! Thank you.