For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Arc Direction err!

lanhan's picture
Forums: 

i use a circle cut a square,then to get all edges and their directions,bat arc's directions are error!
source code and output:
void test()
{
TRACE(_T("\noutput:\n"));
//square
TopoDS_Compound aRes1;

{
BRepBuilderAPI_MakeWire mkWire;

Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(gp_Pnt(0,0,0) ,gp_Pnt(2000,0,0));
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);

Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(gp_Pnt(2000,0,0) ,gp_Pnt(2000,2000,0));
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aSegment2);

Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(gp_Pnt(2000,2000,0) ,gp_Pnt(0,2000,0));
TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aSegment3);

Handle(Geom_TrimmedCurve) aSegment4 = GC_MakeSegment(gp_Pnt(0,2000,0) ,gp_Pnt(0,0,0));
TopoDS_Edge aEdge4 = BRepBuilderAPI_MakeEdge(aSegment4);

mkWire.Add(aEdge1);
mkWire.Add(aEdge2);
mkWire.Add(aEdge3);
mkWire.Add(aEdge4);

TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(mkWire);
BRep_Builder aBuilder;
aBuilder.MakeCompound(aRes1);
aBuilder.Add(aRes1,myFaceProfile);
}

//circle
TopoDS_Compound aRes2;

{
BRepBuilderAPI_MakeWire mkWire;

Handle(Geom_Circle) aCircle = /*GC_MakeCircle*/
GC_MakeCircle(gp_Pnt(200,1000,0),gp_Pnt(0,1200,0),gp_Pnt(-200,1000,0));
TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aCircle);
mkWire.Add(aEdge);
// TopoDS_Wire myWireProfile = mkWire.Wire();
TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(mkWire);
BRep_Builder aBuilder;
aBuilder.MakeCompound(aRes2);
aBuilder.Add(aRes2,myFaceProfile);
}
TopoDS_Shape aShape=BRepAlgoAPI_Cut(aRes1,aRes2);

TopTools_IndexedDataMapOfShapeListOfShape M;
M.Clear();
TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,M);
Standard_Integer nbedge = M.Extent();

gp_Pnt ps,pe;
for(Standard_Integer eiterator = 1; eiterator {
TopoDS_Edge anEdge = TopoDS::Edge(M.FindKey(eiterator));
anEdge.Orientation(TopAbs_FORWARD);
BRepAdaptor_Curve aCurve( anEdge );
GeomAbs_CurveType mtype=aCurve.GetType();
switch (mtype)
{
case GeomAbs_Line:
{
Standard_Real FirstPar = aCurve.FirstParameter();
Standard_Real LastPar = aCurve.LastParameter();

aCurve.D0(FirstPar, ps );
aCurve.D0(LastPar, pe );

TRACE(_T("Line\n"));
TRACE(_T("%.0lf,%.0lf,%.0lf -> %.0lf,%.0lf,%.0lf\n"),ps.X(),ps.Y(),ps.Z(),pe.X(),pe.Y(),pe.Z());
}
break;
case GeomAbs_Circle:
{
Standard_Real StartAngle = aCurve.FirstParameter();
Standard_Real EndAngle = aCurve.LastParameter();
gp_Circ mgp_Circ=aCurve.Circle();
gp_Ax2 ax2=mgp_Circ.Position();
gp_Dir zdir=ax2.Direction();
gp_Dir xdir=ax2.XDirection();
gp_Dir ydir=ax2.YDirection();
TRACE(_T("ARC\n"));
TRACE(_T("xdir:%.0lf,%.0lf,%.0lf\n"),xdir.X(),xdir.Y(),xdir.Z());
TRACE(_T("ydir:%.0lf,%.0lf,%.0lf\n"),ydir.X(),ydir.Y(),ydir.Z());
TRACE(_T("zdir:%.0lf,%.0lf,%.0lf\n"),zdir.X(),zdir.Y(),zdir.Z());
TRACE(_T("StartAngle:%.0lf,EndAngle:%.0lf\n"),StartAngle*180/3.14,EndAngle*180/3.14);
}
break;
}
}
}

output:
Line
0,0,0 -> 2000,0,0
Line
0,800,0 -> 0,0,0
Line
2000,0,0 -> 2000,2000,0
ARC
xdir:1,0,-0
ydir:-0,1,0
zdir:0,0,1
StartAngle:270,EndAngle:360
Line
2000,2000,0 -> 0,2000,0
ARC
xdir:1,0,-0
ydir:-0,1,0
zdir:0,0,1
StartAngle:0,EndAngle:90
Line
0,2000,0 -> 0,1200,0

THANKS!