Hi, all. I am really stuck and cannot find the reason what I am doing wrong :( I am trying to create a face, which technically is half cylinder with 3 mm distance. The code below is what I am trying to use, but the face is wrong. I don't understand what I am missing. The last lines supposed not to ASSERT at all. Can you help me? I really will appreciate this.
TopoDS_Face TheFace;
gp_Pnt pt(0.0, 0.0, 0.0);
gp_Dir dir(0.0, 0.0, 1.0);
gp_Ax3 ax(pt, dir, gp_Dir(1.0, 0.0, 0.0));
gp_Cylinder cyl(ax, 5.0);//radius
TopoDS_Wire Outwire;
BRepBuilderAPI_MakeWire mkWire;
{
TopoDS_Edge e1, e2, e3, e4;
{
gp_Pnt oP1(-5.0, 0.0, 0.0);
gp_Pnt oP2(0.0, -5.0, 0.0);
gp_Pnt oP3(5.0, 0.0, 0.0);
GC_MakeArcOfCircle mac(oP1, oP2, oP3);
e1 = BRepBuilderAPI_MakeEdge(mac.Value());
}
{
cD3DPoint P1(5.0, 0.0, 0.0);
cD3DPoint P2(5.0, 0.0, 3.0);
gp_Dir V(P2.x - P1.x, P2.y - P1.y, P2.z - P1.z);
Handle_Geom_Line theCurve = new Geom_Line(gp_Pnt(P1.x, P1.y, P1.z), V);
Handle_Geom_TrimmedCurve TrimCurve = new Geom_TrimmedCurve(theCurve, 0.0, (P2 - P1).GetLength());
e2 = BRepBuilderAPI_MakeEdge(TrimCurve);
}
{
gp_Pnt oP1(5.0, 0.0, 3.0);
gp_Pnt oP2(0.0, -5.0, 3.0);
gp_Pnt oP3(-5.0, 0.0, 3.0);
GC_MakeArcOfCircle mac(oP1, oP2, oP3);
e3 = BRepBuilderAPI_MakeEdge(mac.Value());
}
{
cD3DPoint P1(-5.0, 0.0, 3.0);
cD3DPoint P2(-5.0, 0.0, 0.0);
gp_Dir V(P2.x - P1.x, P2.y - P1.y, P2.z - P1.z);
Handle_Geom_Line theCurve = new Geom_Line(gp_Pnt(P1.x, P1.y, P1.z), V);
Handle_Geom_TrimmedCurve TrimCurve = new Geom_TrimmedCurve(theCurve, 0.0, (P2 - P1).GetLength());
e4 = BRepBuilderAPI_MakeEdge(TrimCurve);
}
mkWire.Add(e1);
mkWire.Add(e2);
mkWire.Add(e3);
mkWire.Add(e4);
Outwire = mkWire.Wire();
}
BRepBuilderAPI_MakeFace makeface(cyl, Outwire);
TheFace = makeface.Face();
gp_Pnt2d np(FLT_MAX, FLT_MAX);
BRepClass_FaceClassifier fc;
fc.Perform(TheFace, np, FLT_EPSILON);
if (fc.State() == TopAbs_IN)
{
ASSERT(FALSE);
}