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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 
18 #include <GC_MakePlane.hxx>
19 #include <gce_MakePln.hxx>
20 #include <Geom_Plane.hxx>
21 #include <gp.hxx>
22 #include <gp_Ax1.hxx>
23 #include <gp_Ax2.hxx>
24 #include <gp_Ax3.hxx>
25 #include <gp_Dir.hxx>
26 #include <gp_Pln.hxx>
27 #include <gp_Pnt.hxx>
28 #include <Standard_NotImplemented.hxx>
29 #include <StdFail_NotDone.hxx>
30 #include <TColgp_Array1OfPnt.hxx>
31 
GC_MakePlane(const gp_Pln & Pl)32 GC_MakePlane::GC_MakePlane(const gp_Pln& Pl)
33 {
34   TheError = gce_Done;
35   ThePlane = new Geom_Plane(Pl);
36 }
37 
GC_MakePlane(const gp_Pnt & P,const gp_Dir & V)38 GC_MakePlane::GC_MakePlane(const gp_Pnt& P,
39 			     const gp_Dir& V)
40 {
41   TheError = gce_Done;
42   ThePlane = new Geom_Plane(P,V);
43 }
44 
GC_MakePlane(const Standard_Real A,const Standard_Real B,const Standard_Real C,const Standard_Real D)45 GC_MakePlane::GC_MakePlane(const Standard_Real A,
46 			     const Standard_Real B,
47 			     const Standard_Real C,
48 			     const Standard_Real D)
49 {
50   if (Sqrt(A*A + B*B +C*C) <= gp::Resolution()) {
51     TheError = gce_BadEquation;
52   }
53   else {
54     TheError = gce_Done;
55     ThePlane = new Geom_Plane(gp_Pln(A,B,C,D));
56   }
57 }
58 
59 //=========================================================================
60 //   Creation d un Geom_Plane passant par trois points.                   +
61 //=========================================================================
62 
GC_MakePlane(const gp_Pnt & P1,const gp_Pnt & P2,const gp_Pnt & P3)63 GC_MakePlane::GC_MakePlane(const gp_Pnt& P1    ,
64 			     const gp_Pnt& P2    ,
65 			     const gp_Pnt& P3    ) {
66   gce_MakePln Pl(P1,P2,P3);
67   TheError = Pl.Status();
68   if (TheError == gce_Done) {
69     ThePlane = new Geom_Plane(Pl.Value());
70   }
71 }
72 
73 //=========================================================================
74 //   Creation d un Geom_Plane parallele a un pln a une distance donnee.   +
75 //=========================================================================
76 
GC_MakePlane(const gp_Pln & Pl,const Standard_Real Dist)77 GC_MakePlane::GC_MakePlane(const gp_Pln& Pl   ,
78 			     const Standard_Real    Dist ) {
79   gp_Pln Pln = gce_MakePln(Pl,Dist);
80   TheError = gce_Done;
81   ThePlane = new Geom_Plane(Pln);
82 }
83 
84 //=========================================================================
85 //   Creation d un Geom_Plane parallele a un pln passant par un point     +
86 //   <Point1>.                                                            +
87 //=========================================================================
88 
GC_MakePlane(const gp_Pln & Pl,const gp_Pnt & Point)89 GC_MakePlane::GC_MakePlane(const gp_Pln& Pl    ,
90 			     const gp_Pnt& Point ) {
91   gp_Pln Pln= gce_MakePln(Pl,Point);
92   TheError = gce_Done;
93   ThePlane = new Geom_Plane(Pln);
94 }
95 
96 //=========================================================================
97 //  Creation d un Geom_Plane a partir d un Ax1 (Point + Normale).         +
98 //=========================================================================
99 
GC_MakePlane(const gp_Ax1 & Axis)100 GC_MakePlane::GC_MakePlane(const gp_Ax1& Axis ) {
101   gp_Pln Pln = gce_MakePln(Axis);
102   TheError = gce_Done;
103   ThePlane = new Geom_Plane(Pln);
104 }
105 
106 //=========================================================================
107 //  Creation d un Geom_Plane par un tableau de points.                    +
108 //=========================================================================
109 
110 /*GC_MakePlane::GC_MakePlane(const TColgp_Array1OfPnt&    Pts     ,
111 	 		           Standard_Real            ErrMax  ,
112 			           Standard_Real            ErrMean ) {
113   GC_MakePln Pln(Pts,ErrMax,ErrMean);
114   TheError = Pln.Status();
115   if (TheError == GC_Done) {
116     ThePlane = new Geom_Plane(Pln.Value());
117   }
118 }
119 */
120 
Handle(Geom_Plane)121 const Handle(Geom_Plane)& GC_MakePlane::Value() const
122 {
123   StdFail_NotDone_Raise_if (TheError != gce_Done,
124                             "GC_MakePlane::Value() - no result");
125   return ThePlane;
126 }
127