// File: gce_MakeCirc2d.cxx // Created: Wed Sep 2 10:34:28 1992 // Author: Remi GILET // #include #include #include #include #include #include #include //========================================================================= // Creation d un cercle 2d de gp passant par trois points. + // Trois cas de figures : + // 1/ Les trois points sont confondus. + // ----------------------------------- + // Le resultat est le cercle centre en Point1 de rayon zero. + // 2/ Deux des trois points sont confondus. + // ---------------------------------------- + // On cree la mediatrice a deux points non confondus ainsi que la + // droite passant par ces deux points. + // La solution a pour centre l intersection de ces deux droite et + // pour rayon la distance entre ce centre et l un des trois points. + // 3/ Les trois points sont distinct. + // ---------------------------------- + // On cree la mediatrice a P1P2 ainsi que la mediatrice a P1P3. + // La solution a pour centre l intersection de ces deux droite et + // pour rayon la distance entre ce centre et l un des trois points. + //========================================================================= gce_MakeCirc2d::gce_MakeCirc2d(const gp_Pnt2d& P1 , const gp_Pnt2d& P2 , const gp_Pnt2d& P3 ) { gp_Dir2d dirx(1.0,0.0); //========================================================================= // Traitement. + //========================================================================= Standard_Real dist1 = P1.Distance(P2); Standard_Real dist2 = P1.Distance(P3); Standard_Real dist3 = P2.Distance(P3); if ((dist1= RealEpsilon()) { L1 = gp_Lin2d(gp_Pnt2d((P1.XY()+P2.XY())/2.0), gp_Dir2d(P1.Y()-P2.Y(),P2.X()-P1.X())); } if (dist2 >= RealEpsilon()) { L2 = gp_Lin2d(gp_Pnt2d((P1.XY()+P3.XY())/2.0), gp_Dir2d(P1.Y()-P3.Y(),P3.X()-P1.X())); } if (dist2 <= RealEpsilon()) { L2 = gp_Lin2d(P1,gp_Dir2d(P1.Y()-P2.Y(),P2.X()-P1.X())); } else if (dist1 <= RealEpsilon()) { L1 = gp_Lin2d(P1,gp_Dir2d(P1.Y()-P3.Y(),P3.X()-P1.X())); } else if (dist3 <= RealEpsilon()) { L2 = gp_Lin2d(P1,gp_Dir2d(P1.Y()-P2.Y(),P2.X()-P1.X())); } IntAna2d_AnaIntersection Intp(L1,L2); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { gp_Pnt2d pInt(Intp.Point(1).Value()); dist1 = P1.Distance(pInt); dist2 = P2.Distance(pInt); dist3 = P3.Distance(pInt); Standard_Real xc,yc; pInt.Coord(xc,yc); gp_Dir2d d1(x1-xc,y1-yc); gp_Dir2d d2(xc-x3,yc-y3); TheCirc2d = gp_Circ2d(gp_Ax22d(pInt,d1,d2),(dist1+dist2+dist3)/3.); Standard_Real Alpha1 = ElCLib::Parameter(TheCirc2d,P1); Standard_Real Alpha2 = ElCLib::Parameter(TheCirc2d,P2); Standard_Real Alpha3 = ElCLib::Parameter(TheCirc2d,P3); if (!((Alpha1 <= Alpha2) && (Alpha2 <= Alpha3))) { TheCirc2d.Reverse(); } TheError = gce_Done; } } else { TheError = gce_IntersectionError; } } } //========================================================================== // Creation d un gp_Circ2d par son Axe et son rayon . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Ax2d& XAxis , const Standard_Real Radius , const Standard_Boolean Sense ) { if (Radius >= 0.) { TheCirc2d = gp_Circ2d(XAxis,Radius,Sense); TheError = gce_Done; } else { TheError = gce_NegativeRadius; } } //========================================================================== // Creation d un gp_Circ2d par son Repere et son rayon . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Ax22d& Axis , const Standard_Real Radius ) { if (Radius >= 0.) { TheCirc2d = gp_Circ2d(Axis,Radius); TheError = gce_Done; } else { TheError = gce_NegativeRadius; } } //========================================================================== // Creation d un gp_Circ2d par son centre
et son rayon + // . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Pnt2d& Center , const Standard_Real Radius , const Standard_Boolean Sense ) { if (Radius >= 0.) { TheCirc2d = gp_Circ2d(gp_Ax2d(Center,gp_Dir2d(1.0,0.0)),Radius,Sense); TheError = gce_Done; } else { TheError = gce_NegativeRadius; } } //========================================================================== // Creation d un gp_Circ2d par son centre
et un point de sa + // circonference . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Pnt2d& Center , const gp_Pnt2d& Point , const Standard_Boolean Sense ) { TheCirc2d = gp_Circ2d(gp_Ax2d(Center,gp_Dir2d(1.0,0.0)), Point.Distance(Center),Sense); TheError = gce_Done; } //========================================================================== // Creation d un cercle concentrique a passant par le + // point . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Circ2d& Circ , const gp_Pnt2d& Point ) { TheCirc2d = gp_Circ2d(Circ.Axis(),Point.Distance(Circ.Location())); TheError = gce_Done; } //========================================================================== // Creation d un cercle concentrique a a une distance + // . + //========================================================================== gce_MakeCirc2d::gce_MakeCirc2d(const gp_Circ2d& Circ , const Standard_Real Dist1 ) { TheCirc2d = gp_Circ2d(Circ.Axis(),Abs(Circ.Radius()+Dist1)); TheError = gce_Done; } const gp_Circ2d& gce_MakeCirc2d::Value() const { StdFail_NotDone_Raise_if(!TheError == gce_Done,""); return TheCirc2d; } const gp_Circ2d& gce_MakeCirc2d::Operator() const { return Value(); } gce_MakeCirc2d::operator gp_Circ2d() const { return Value(); }