Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1992-10-02 |
2 | // Created by: Remi GILET | |
3 | // Copyright (c) 1992-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
42cf5bc1 | 17 | |
18 | #include <Extrema_ExtPElC.hxx> | |
7fd59977 | 19 | #include <GC_MakeConicalSurface.hxx> |
42cf5bc1 | 20 | #include <GC_MakeTrimmedCone.hxx> |
7fd59977 | 21 | #include <Geom_ConicalSurface.hxx> |
42cf5bc1 | 22 | #include <Geom_RectangularTrimmedSurface.hxx> |
7fd59977 | 23 | #include <gp_Dir.hxx> |
24 | #include <gp_Lin.hxx> | |
25 | #include <gp_Pnt.hxx> | |
42cf5bc1 | 26 | #include <StdFail_NotDone.hxx> |
7fd59977 | 27 | |
28 | //========================================================================= | |
0d969553 Y |
29 | // Creation of a cone by four points. + |
30 | // First two give the axis. + | |
31 | // The third gives the base radius. + | |
32 | // the third and the fourth demi-angle. + | |
7fd59977 | 33 | //========================================================================= |
7fd59977 | 34 | GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 , |
35 | const gp_Pnt& P2 , | |
36 | const gp_Pnt& P3 , | |
37 | const gp_Pnt& P4 ) | |
38 | { | |
39 | GC_MakeConicalSurface Cone(P1,P2,P3,P4); | |
40 | TheError = Cone.Status(); | |
41 | if (TheError == gce_Done) { | |
42 | gp_Dir D1(P2.XYZ()-P1.XYZ()); | |
43 | gp_Lin L1(P1,D1); | |
44 | Extrema_ExtPElC ext1(P3,L1,1.0e-7,-2.0e+100,+2.0e+100); | |
45 | Extrema_ExtPElC ext2(P4,L1,1.0e-7,-2.0e+100,+2.0e+100); | |
46 | gp_Pnt P5 = ext1.Point(1).Value(); | |
47 | gp_Pnt P6 = ext2.Point(1).Value(); | |
48 | Standard_Real D = P6.Distance(P5)/cos((Cone.Value())->SemiAngle()); | |
c6541a0c | 49 | TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True); |
7fd59977 | 50 | } |
51 | } | |
52 | ||
53 | //========================================================================= | |
54 | //========================================================================= | |
55 | ||
56 | GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 , | |
57 | const gp_Pnt& P2 , | |
58 | const Standard_Real R1 , | |
59 | const Standard_Real R2 ) | |
60 | { | |
61 | GC_MakeConicalSurface Cone(P1,P2,R1,R2); | |
62 | TheError = Cone.Status(); | |
63 | if (TheError == gce_Done) { | |
64 | Standard_Real D = (P2.Distance(P1))/cos((Cone.Value())->SemiAngle()); | |
c6541a0c | 65 | TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True); |
7fd59977 | 66 | } |
67 | } | |
68 | ||
69 | //======================================================================= | |
70 | //function : Value | |
71 | //purpose : | |
72 | //======================================================================= | |
73 | ||
74 | const Handle(Geom_RectangularTrimmedSurface)& GC_MakeTrimmedCone:: | |
75 | Value() const | |
76 | { | |
2d2b3d53 | 77 | StdFail_NotDone_Raise_if (TheError != gce_Done, |
78 | "GC_MakeTrimmedCone::Value() - no result"); | |
7fd59977 | 79 | return TheCone; |
80 | } |