Salome HOME
d39e06c38da5356a97a3c411725912bc7f1d49cb
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_BndSphere.lxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:        GEOMAlgo_BndSphere.lxx
21 // Created:     
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24 //=======================================================================
25 //function : SetCenter
26 //purpose  : 
27 //=======================================================================
28   inline void GEOMAlgo_BndSphere::SetCenter(const gp_Pnt& theP)
29 //
30 {
31   myCenter=theP;
32 }
33 //=======================================================================
34 //function : Center
35 //purpose  : 
36 //=======================================================================
37   inline const gp_Pnt& GEOMAlgo_BndSphere::Center()const
38 {
39   return myCenter;
40 }
41 //=======================================================================
42 //function : SetRadius
43 //purpose  : 
44 //=======================================================================
45   inline void GEOMAlgo_BndSphere::SetRadius(const Standard_Real theR)
46 {
47   myRadius=theR;
48 }
49 //=======================================================================
50 //function : Radius
51 //purpose  : 
52 //=======================================================================
53   inline Standard_Real GEOMAlgo_BndSphere::Radius()const
54 {
55   return myRadius;
56 }
57 //=======================================================================
58 //function : SetGap
59 //purpose  : 
60 //=======================================================================
61   inline void GEOMAlgo_BndSphere::SetGap(const Standard_Real theGap)
62 {
63   myGap=theGap;
64 }
65 //=======================================================================
66 //function : Gap
67 //purpose  : 
68 //=======================================================================
69   inline Standard_Real GEOMAlgo_BndSphere::Gap()const
70 {
71   return myGap;
72 }
73 //=======================================================================
74 //function : Add
75 //purpose  : 
76 //=======================================================================
77   inline void GEOMAlgo_BndSphere::Add(const GEOMAlgo_BndSphere& theOther)
78 {
79   Standard_Real aTmax, aR, aT, aTOther;
80   gp_Pnt aPc;
81   //
82   aPc.SetXYZ(0.5*(myCenter.XYZ()+theOther.myCenter.XYZ()));
83   //
84   aR=aPc.Distance(myCenter);
85   //
86   aT=myRadius+myGap;
87   aTOther=theOther.myRadius+theOther.myGap;
88   aTmax=(aT>aTOther) ? aT: aTOther;
89   //
90   aR=aR+aTmax;
91   //
92   myCenter=aPc;
93   myRadius=aR;
94 }
95 //=======================================================================
96 //function : SquareExtent
97 //purpose  : 
98 //=======================================================================
99   inline Standard_Real GEOMAlgo_BndSphere::SquareExtent()const
100 {
101   Standard_Real aD;
102   //
103   aD=myRadius+myGap;
104   aD=aD+aD;
105   aD=aD*aD;
106   //
107   return aD;
108 }