1 // Created on: 1992-10-02
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <GC_MakeTrimmedCone.ixx>
18 #include <GC_MakeConicalSurface.hxx>
19 #include <StdFail_NotDone.hxx>
20 #include <Geom_ConicalSurface.hxx>
24 #include <Extrema_ExtPElC.hxx>
26 //=========================================================================
27 // Creation of a cone by four points. +
28 // First two give the axis. +
29 // The third gives the base radius. +
30 // the third and the fourth demi-angle. +
31 //=========================================================================
33 GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 ,
38 GC_MakeConicalSurface Cone(P1,P2,P3,P4);
39 TheError = Cone.Status();
40 if (TheError == gce_Done) {
41 gp_Dir D1(P2.XYZ()-P1.XYZ());
43 Extrema_ExtPElC ext1(P3,L1,1.0e-7,-2.0e+100,+2.0e+100);
44 Extrema_ExtPElC ext2(P4,L1,1.0e-7,-2.0e+100,+2.0e+100);
45 gp_Pnt P5 = ext1.Point(1).Value();
46 gp_Pnt P6 = ext2.Point(1).Value();
47 Standard_Real D = P6.Distance(P5)/cos((Cone.Value())->SemiAngle());
48 TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True);
52 //=========================================================================
53 //=========================================================================
55 GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 ,
57 const Standard_Real R1 ,
58 const Standard_Real R2 )
60 GC_MakeConicalSurface Cone(P1,P2,R1,R2);
61 TheError = Cone.Status();
62 if (TheError == gce_Done) {
63 Standard_Real D = (P2.Distance(P1))/cos((Cone.Value())->SemiAngle());
64 TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True);
68 //=======================================================================
71 //=======================================================================
73 const Handle(Geom_RectangularTrimmedSurface)& GC_MakeTrimmedCone::
76 StdFail_NotDone_Raise_if(TheError != gce_Done,"");
80 const Handle(Geom_RectangularTrimmedSurface)& GC_MakeTrimmedCone::
87 operator Handle(Geom_RectangularTrimmedSurface) () const