Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forums
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forums / Usage issues / Arc Direction err!

Arc Direction err!

Arc Direction err!
lanhan 2012/06/28 12:52
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 <= nbedge; 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!
 
 
Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map