0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / TopOpeBRep / TopOpeBRep_PointGeomTool.cxx
CommitLineData
b311480e 1// Created on: 1994-10-25
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <BRep_Tool.hxx>
7fd59977 19#include <TopoDS.hxx>
20#include <TopoDS_Edge.hxx>
42cf5bc1 21#include <TopoDS_Shape.hxx>
22#include <TopOpeBRep_FaceEdgeIntersector.hxx>
23#include <TopOpeBRep_Point2d.hxx>
24#include <TopOpeBRep_PointGeomTool.hxx>
25#include <TopOpeBRep_VPointInter.hxx>
26#include <TopOpeBRepDS_Point.hxx>
7fd59977 27
7fd59977 28//=======================================================================
29//function : MakePoint
30//purpose :
31//=======================================================================
32TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
33(const TopOpeBRep_VPointInter& IP)
34{
35 Standard_Real tolip = IP.Tolerance();
36 Standard_Real tolout = tolip;
37 Standard_Integer si = IP.ShapeIndex();
38 if ( si == 0 ) {
39 tolout = tolip;
40 } else if ( si == 1 ) {
41 const TopoDS_Edge& E = TopoDS::Edge(IP.Edge(si));
42 tolout = BRep_Tool::Tolerance(E);
43 } else if ( si == 2 ) {
44 const TopoDS_Edge& E = TopoDS::Edge(IP.Edge(si));
45 tolout = BRep_Tool::Tolerance(E);
46 } else if ( si == 3 ) {
47 const TopoDS_Edge& E1 = TopoDS::Edge(IP.Edge(1));
48 const TopoDS_Edge& E2 = TopoDS::Edge(IP.Edge(2));
49 Standard_Real t1 = BRep_Tool::Tolerance(E1);
50 Standard_Real t2 = BRep_Tool::Tolerance(E2);
51 // tolout = Max(t1,t2);
52 if (t1 > 0.9) t1 = 0.9;
53 if (t1 > 0.9) t1 = 0.9;
54 tolout = 2.5*(t1+t2);
55 }
56 tolout = Max(tolout,tolip);
57 return TopOpeBRepDS_Point(IP.Value(),tolout);
58}
59
60//=======================================================================
61//function : MakePoint
62//purpose :
63//=======================================================================
64TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
65(const TopOpeBRep_Point2d& P2D)
66{
67 Standard_Real tol = P2D.Tolerance();
68 return TopOpeBRepDS_Point(P2D.Value(),tol);
69}
70
71//=======================================================================
72//function : MakePoint
73//purpose :
74//=======================================================================
75TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
76(const TopOpeBRep_FaceEdgeIntersector& FEI)
77{
78 Standard_Real tol = FEI.Tolerance();
79 return TopOpeBRepDS_Point(FEI.Value(),tol);
80}
81
82//=======================================================================
83//function : MakePoint
84//purpose :
85//=======================================================================
86TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint
87(const TopoDS_Shape& S)
88{
89 return TopOpeBRepDS_Point(S);
90}
91
92//=======================================================================
93//function : IsEqual
94//purpose :
95//=======================================================================
96Standard_Boolean TopOpeBRep_PointGeomTool::IsEqual
97(const TopOpeBRepDS_Point& DSP1,
98 const TopOpeBRepDS_Point& DSP2)
99{
100 Standard_Boolean b = DSP1.IsEqual(DSP2);
101 return b;
102}