Integration of OCCT 6.5.0 from SVN
[occt.git] / src / gce / gce_MakeHypr.cxx
CommitLineData
7fd59977 1// File: gce_MakeElips.cxx
2// Created: Wed Sep 2 12:35:36 1992
3// Author: Remi GILET
4// <reg@sdsun1>
5
6#include <gce_MakeHypr.ixx>
7#include <StdFail_NotDone.hxx>
8#include <gp_Lin.hxx>
9
10//=========================================================================
11// Creation d une Hyperbole 3d de gp de centre <Center> et de sommets +
12// <S1> et <S2>. +
13// <CenterS1> donne le grand axe . +
14// <S1> donne le grand rayon et <S2> le petit rayon. +
15//=========================================================================
16
17gce_MakeHypr::gce_MakeHypr(const gp_Pnt& S1 ,
18 const gp_Pnt& S2 ,
19 const gp_Pnt& Center )
20{
21 gp_Dir XAxis(gp_XYZ(S1.XYZ()-Center.XYZ()));
22 gp_Lin L(Center,XAxis);
23 Standard_Real D = S1.Distance(Center);
24 Standard_Real d = L.Distance(S2);
25 if (d > D) { TheError = gce_InvertAxis; }
26 else {
27 gp_Dir Norm(XAxis.Crossed(gp_Dir(gp_XYZ(S2.XYZ()-Center.XYZ()))));
28 TheHypr = gp_Hypr(gp_Ax2(Center,Norm,XAxis),D,d);
29 TheError = gce_Done;
30 }
31}
32
33gce_MakeHypr::gce_MakeHypr(const gp_Ax2& A2 ,
34 const Standard_Real MajorRadius ,
35 const Standard_Real MinorRadius )
36{
37 if (MajorRadius < MinorRadius) { TheError = gce_InvertRadius; }
38 else if (MajorRadius < 0.0) { TheError = gce_NegativeRadius; }
39 else {
40 TheHypr = gp_Hypr(A2,MajorRadius,MinorRadius);
41 TheError = gce_Done;
42 }
43}
44
45const gp_Hypr& gce_MakeHypr::Value() const
46{
47 StdFail_NotDone_Raise_if(!TheError == gce_Done,"");
48 return TheHypr;
49}
50
51const gp_Hypr& gce_MakeHypr::Operator() const
52{
53 return Value();
54}
55
56gce_MakeHypr::operator gp_Hypr() const
57{
58 return Value();
59}
60