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)
In other word, it seems get something, however, when output as step file, it seems show nothing.


There is my simple Demo:
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)
In other word, it seems get something, however, when output as step file, it seems show nothing.


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;
}