Test for 0022778: Bug in BRepMesh
[occt.git] / src / GC / GC_MakeTrimmedCone.cxx
CommitLineData
b311480e 1// Created on: 1992-10-02
2// Created by: Remi GILET
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <GC_MakeTrimmedCone.ixx>
23#include <GC_MakeConicalSurface.hxx>
24#include <StdFail_NotDone.hxx>
25#include <Geom_ConicalSurface.hxx>
26#include <gp_Dir.hxx>
27#include <gp_Lin.hxx>
28#include <gp_Pnt.hxx>
29#include <Extrema_ExtPElC.hxx>
30
31//=========================================================================
0d969553
Y
32// Creation of a cone by four points. +
33// First two give the axis. +
34// The third gives the base radius. +
35// the third and the fourth demi-angle. +
7fd59977 36//=========================================================================
37
38GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 ,
39 const gp_Pnt& P2 ,
40 const gp_Pnt& P3 ,
41 const gp_Pnt& P4 )
42{
43 GC_MakeConicalSurface Cone(P1,P2,P3,P4);
44 TheError = Cone.Status();
45 if (TheError == gce_Done) {
46 gp_Dir D1(P2.XYZ()-P1.XYZ());
47 gp_Lin L1(P1,D1);
48 Extrema_ExtPElC ext1(P3,L1,1.0e-7,-2.0e+100,+2.0e+100);
49 Extrema_ExtPElC ext2(P4,L1,1.0e-7,-2.0e+100,+2.0e+100);
50 gp_Pnt P5 = ext1.Point(1).Value();
51 gp_Pnt P6 = ext2.Point(1).Value();
52 Standard_Real D = P6.Distance(P5)/cos((Cone.Value())->SemiAngle());
c6541a0c 53 TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True);
7fd59977 54 }
55}
56
57//=========================================================================
58//=========================================================================
59
60GC_MakeTrimmedCone::GC_MakeTrimmedCone(const gp_Pnt& P1 ,
61 const gp_Pnt& P2 ,
62 const Standard_Real R1 ,
63 const Standard_Real R2 )
64{
65 GC_MakeConicalSurface Cone(P1,P2,R1,R2);
66 TheError = Cone.Status();
67 if (TheError == gce_Done) {
68 Standard_Real D = (P2.Distance(P1))/cos((Cone.Value())->SemiAngle());
c6541a0c 69 TheCone=new Geom_RectangularTrimmedSurface(Cone.Value(),0.,2.*M_PI,0.,D,Standard_True,Standard_True);
7fd59977 70 }
71}
72
73//=======================================================================
74//function : Value
75//purpose :
76//=======================================================================
77
78const Handle(Geom_RectangularTrimmedSurface)& GC_MakeTrimmedCone::
79 Value() const
80{
81 StdFail_NotDone_Raise_if(!TheError == gce_Done,"");
82 return TheCone;
83}
84
85const Handle(Geom_RectangularTrimmedSurface)& GC_MakeTrimmedCone::
86 Operator() const
87{
88 return Value();
89}
90
91GC_MakeTrimmedCone::
92 operator Handle(Geom_RectangularTrimmedSurface) () const
93{
94 return Value();
95}
96