1 // File: GEOMAlgo_SurfaceTools.cxx
2 // Created: Thu Jan 27 11:05:16 2005
3 // Author: Peter KURNEV
7 #include <GEOMAlgo_SurfaceTools.ixx>
10 #include <gp_Cylinder.hxx>
11 #include <gp_Sphere.hxx>
17 #include <GeomAbs_SurfaceType.hxx>
18 #include <GeomAdaptor_Surface.hxx>
20 //=======================================================================
23 //=======================================================================
24 Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP,
25 const Handle(Geom_Surface)& aSurf,
26 const Standard_Real aTol,
29 Standard_Integer iErr;
30 Standard_Real aDp, aR;
31 GeomAbs_SurfaceType aType;
32 GeomAdaptor_Surface aGAS;
38 aState=TopAbs_UNKNOWN;
46 aDp=GEOMAlgo_SurfaceTools::Distance(aP, aPln);
49 case GeomAbs_Cylinder:
52 aDp=GEOMAlgo_SurfaceTools::Distance(aP, aCyl);
58 aDp=GEOMAlgo_SurfaceTools::Distance(aP, aSph);
62 iErr=1; // unprocessed surface type
71 else if (aDp<aR-aTol) {
78 //=======================================================================
79 //function : ReverseState
81 //=======================================================================
82 TopAbs_State GEOMAlgo_SurfaceTools::ReverseState(const TopAbs_State aState)
84 TopAbs_State aRSt=aState;
99 //=======================================================================
100 //function : Distance
102 //=======================================================================
103 Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
104 const gp_Sphere& aSph)
106 Standard_Real aD, aR;
109 const gp_Pnt& aLoc=aSph.Location();
110 aD=aLoc.Distance(aP);
114 //=======================================================================
115 //function : Distance
117 //=======================================================================
118 Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
119 const gp_Cylinder& aCyl)
121 Standard_Real aD, aR;
124 const gp_Ax1& aAxis=aCyl.Axis();
126 aD=aLin.Distance(aP);
130 //=======================================================================
131 //function : Distance
133 //=======================================================================
134 Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
139 const gp_Ax3& aPos=aPL.Position();
140 const gp_Pnt& aLoc=aPos.Location ();
141 const gp_Dir& aDir=aPos.Direction();
143 aD= (aDir.X() * (aP.X() - aLoc.X()) +
144 aDir.Y() * (aP.Y() - aLoc.Y()) +
145 aDir.Z() * (aP.Z() - aLoc.Z()));
148 //=======================================================================
149 //function : IsAnalytic
151 //=======================================================================
152 Standard_Boolean GEOMAlgo_SurfaceTools::IsAnalytic(const Handle(Geom_Surface)& aSurf)
154 Standard_Boolean bRet;
155 GeomAbs_SurfaceType aType;
156 GeomAdaptor_Surface aGAS;
159 aType=aGAS.GetType();
160 bRet=(aType==GeomAbs_Plane ||
161 aType==GeomAbs_Cylinder ||
162 aType==GeomAbs_Sphere);
165 //=======================================================================
166 //function : IsConformState
168 //=======================================================================
169 Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState(const TopAbs_State aST1,
170 const GEOMAlgo_State aST2)
172 Standard_Boolean bRet=Standard_False;
176 if (aST1==TopAbs_IN) {
180 case GEOMAlgo_ST_OUT:
181 if (aST1==TopAbs_OUT) {
186 if (aST1==TopAbs_ON) {
190 case GEOMAlgo_ST_ONIN:
191 if (aST1==TopAbs_ON || aST1==TopAbs_IN) {
195 case GEOMAlgo_ST_ONOUT:
196 if (aST1==TopAbs_ON || aST1==TopAbs_OUT) {