Create a line from gp_Ax1 seem get nothing, is that normal?

jianbaoxia

CAD master
Hi Bros, I'm JianBaoxia.
As we know, the gp_Ax1 usually describes an axis in 3D space.
I found there are function to build line for it, like Geom_Line and gp_Lin, so I try it and get nothing.
I don't know is that normal, if it's normal, what's the meaning of the gp_Lin(gp_Ax1) or Geom_Line(gp_Ax1) o_O

In other word, it seems get something, however, when output as step file, it seems show nothing.
1657623780566.png
1657623822140.png
There is my simple Demo:
Code:
#include <BRepTools.hxx>
//
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
//
#include <GCE2d_MakeSegment.hxx>
//
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepFeat_Gluer.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
//
#include <gp_Pln.hxx>
//
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
//
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_Surface.hxx>
//
#include <STEPControl_Writer.hxx>
#include <STEPControl_Reader.hxx>
#include <Interface_Static.hxx>
//
#include <BRepBndLib.hxx>
//
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepBuilderAPI_Transform.hxx>
//
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
//
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_Line.hxx>
//
#include <GeomLProp_CLProps.hxx>
//
#include <Geom_BezierSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
//
#include <TColGeom_Array2OfBezierSurface.hxx>
//
#include <GeomConvert_CompBezierSurfacesToBSplineSurface.hxx>
#include <GeomAPI_PointsToBSplineSurface.hxx>
#include <BRepClass_FaceExplorer.hxx>
//
#include <BRepExtrema_DistShapeShape.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/";

    gp_Pnt p1(0.1, 0.1, 2);
    gp_Pnt p2(0.9, 0.9, 2);
    gp_Ax1 axis1(p1, gp_Dir(0, 0, -1));
    gp_Ax1 axis2(p2, gp_Dir(0, 0, -1));
    Handle(Geom_Line) aLine1 = new Geom_Line(axis1);
    Handle(Geom_Line) aLine2 = new Geom_Line(axis2);
    TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1);
    TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2);

    BRepBuilderAPI_Sewing aSewer;
    aSewer.Add(aEdge1);
    aSewer.Add(aEdge2);
    aSewer.Perform();
    TopoDS_Shape asewShape = aSewer.SewedShape();
    BRepTools::Dump(asewShape, std::cout);
    WriteStepFile(asewShape, filePath + "asewShape.step");
   
    return 0;
}
 

Andrey

Active CAD practitioner
Staff member
Dear jianbaoxia,

Try to limit the line.

TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1, P1, P2);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2, P1, P2);

1657638558677.png
 

jianbaoxia

CAD master
@Andrey , you are right, it real do something, however, I still get some error, cause I'm not adept at using it.
I change the code to:
Code:
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1,p1,gp_Pnt(0.1, 0.1, 0));
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2,p1,gp_Pnt(0.9, 0.9, 0));
 

Andrey

Active CAD practitioner
Staff member
@Andrey , you are right, it real do something, however, I still get some error, cause I'm not adept at using it.
I change the code to:
Code:
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1,p1,gp_Pnt(0.1, 0.1, 0));
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2,p1,gp_Pnt(0.9, 0.9, 0));
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1, -10.0 , 10.0);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2, -10.0 , 10.0);
 
Top