The iso lines create through ShapeAnalysis_Surface::UIso() can show in Analysis Situs, but can't show in FreeCAD and SolidWorks

jianbaoxia

CAD master
Hi Bros, I'm JianBaoXia.
Today, I try to create iso lines of a face through use ShapeAnalysis_Surface::UIso(). However, the step file of iso lines I get can show in Analysis Situs, but can't show in FreeCAD and SolidWorks. This make me confuse.
There is my demo code, and step file I get:
Code:
//
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
//
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
//
#include <gp_Pln.hxx>
//
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
//
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_Surface.hxx>
//
#include <STEPControl_Writer.hxx>
#include <Interface_Static.hxx>

bool WriteStepFile(const TopoDS_Shape& shape, const std::string filepath)
{
    bool output_flag = true;
    STEPControl_Writer writer;
    Interface_Static::SetCVal("write.step.schema", "AP203");
    IFSelect_ReturnStatus status = writer.Transfer(shape, STEPControl_AsIs);
    if (status != IFSelect_RetDone) output_flag = false;
    status = writer.Write(filepath.c_str());
    if (status != IFSelect_RetDone) output_flag = false;

    return output_flag;
}

int main()
{
    std::string filePath = "C:/Users/14656/Desktop/Program/Open Cascade/Demo/";
   
    // get a face
    TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 5, 10);
    gp_Pln pln(gp_Pnt(0, 0, 5), gp_Dir(0, 0, 1));
    TopoDS_Face aPlane = BRepBuilderAPI_MakeFace(pln);
    TopoDS_Shape com = BRepAlgoAPI_Common(cylinder, aPlane);
    TopoDS_Iterator it(com);
    TopoDS_Face comFace = TopoDS::Face(it.Value());
   
    // get UV bounds
    Handle(Geom_Surface) comSur = BRep_Tool::Surface(comFace);
    Standard_Real umin, umax, vmin, vmax;
    ShapeAnalysis::GetFaceUVBounds(comFace, umin, umax, vmin, vmax);
   
    // create uiso lines
    ShapeAnalysis_Surface sas(comSur);
    std::vector<TopoDS_Edge> uisoList;
    for (int i = 0; i <= 12; i++)
    {
        Handle(Geom_Curve) curveU = sas.UIso( (umax - umin) * ((double)i / 12) );
        TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(curveU);
        uisoList.push_back(aEdge);
    }
   
    // fues uiso lines
    TopoDS_Shape uiso = uisoList[0];
    for (int i = 1; i < uisoList.size(); i++)
    {
        uiso = BRepAlgoAPI_Fuse(uiso, uisoList[i]);
    }
   
    WriteStepFile(uiso, filePath + "uiso.step");

    return 0;
}
1656942204301.png
 

Attachments

  • uiso.step
    40.5 KB · Views: 2

tx781854760

Looking around for some CAD
Probably by default, these softwares may delete these very short edges in the shapefix process? Try to enlarge your uiso lines.
 

Jonathan

CAD community veteran
Top