0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / TopOpeBRep / TopOpeBRep_PointGeomTool.cxx
1 // Created on: 1994-10-25
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-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 <BRep_Tool.hxx>
19 #include <TopoDS.hxx>
20 #include <TopoDS_Shape.hxx>
21 #include <TopOpeBRep_FaceEdgeIntersector.hxx>
22 #include <TopOpeBRep_Point2d.hxx>
23 #include <TopOpeBRep_PointGeomTool.hxx>
24 #include <TopOpeBRep_VPointInter.hxx>
25 #include <TopOpeBRepDS_Point.hxx>
26
27 //=======================================================================
28 //function : MakePoint
29 //purpose  : 
30 //=======================================================================
31 TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
32 (const TopOpeBRep_VPointInter& IP)
33 {
34   Standard_Real tolip = IP.Tolerance();
35   Standard_Real tolout = tolip;
36   Standard_Integer si = IP.ShapeIndex();
37   if ( si == 0 ) {
38     tolout = tolip;
39   } else if ( si == 1 ) {
40     const TopoDS_Edge& E = TopoDS::Edge(IP.Edge(si));
41     tolout = BRep_Tool::Tolerance(E);      
42   } else if ( si == 2 ) {
43     const TopoDS_Edge& E = TopoDS::Edge(IP.Edge(si));
44     tolout = BRep_Tool::Tolerance(E);      
45   } else if ( si == 3 ) {
46     const TopoDS_Edge& E1 = TopoDS::Edge(IP.Edge(1));
47     const TopoDS_Edge& E2 = TopoDS::Edge(IP.Edge(2));
48     Standard_Real t1 = BRep_Tool::Tolerance(E1);
49     Standard_Real t2 = BRep_Tool::Tolerance(E2);
50     //    tolout = Max(t1,t2);
51     if (t1 > 0.9) t1 = 0.9;
52     if (t1 > 0.9) t1 = 0.9;
53     tolout = 2.5*(t1+t2);
54   }
55   tolout = Max(tolout,tolip);
56   return TopOpeBRepDS_Point(IP.Value(),tolout);
57 }
58
59 //=======================================================================
60 //function : MakePoint
61 //purpose  : 
62 //=======================================================================
63 TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
64 (const TopOpeBRep_Point2d& P2D)
65 {
66   Standard_Real tol = P2D.Tolerance();
67   return TopOpeBRepDS_Point(P2D.Value(),tol);
68 }
69
70 //=======================================================================
71 //function : MakePoint
72 //purpose  : 
73 //=======================================================================
74 TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
75 (const TopOpeBRep_FaceEdgeIntersector& FEI)
76 {
77   Standard_Real tol = FEI.Tolerance();
78   return TopOpeBRepDS_Point(FEI.Value(),tol);
79 }
80
81 //=======================================================================
82 //function : MakePoint
83 //purpose  : 
84 //=======================================================================
85 TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
86 (const TopoDS_Shape& S)
87 {
88   return TopOpeBRepDS_Point(S);
89 }
90
91 //=======================================================================
92 //function : IsEqual
93 //purpose  : 
94 //=======================================================================
95 Standard_Boolean TopOpeBRep_PointGeomTool::IsEqual
96 (const TopOpeBRepDS_Point& DSP1, 
97  const TopOpeBRepDS_Point& DSP2)
98 {
99   Standard_Boolean b = DSP1.IsEqual(DSP2);
100   return b;
101 }