0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / ShapeBuild / ShapeBuild_Vertex.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14// rln 22.03.99: syntax correction in CombineVertex
15//szv#4 S4163
16#include <ShapeBuild_Vertex.ixx>
17#include <BRep_Tool.hxx>
18#include <Precision.hxx>
19#include <BRep_Builder.hxx>
20
21//=======================================================================
22//function : CombineVertex
23//purpose :
24//=======================================================================
25
26TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const TopoDS_Vertex& V1,
27 const TopoDS_Vertex& V2,
28 const Standard_Real tolFactor) const
29{
30 return CombineVertex ( BRep_Tool::Pnt ( V1 ), BRep_Tool::Pnt ( V2 ),
31 BRep_Tool::Tolerance ( V1 ), BRep_Tool::Tolerance ( V2 ),
32 tolFactor );
33}
34
35//=======================================================================
36//function : CombineVertex
37//purpose :
38//=======================================================================
39
40TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const gp_Pnt& pnt1,
41 const gp_Pnt& pnt2,
42 const Standard_Real tol1,
43 const Standard_Real tol2,
44 const Standard_Real tolFactor) const
45{
46 gp_Pnt pos;
47 Standard_Real tol;
48
49 gp_Vec v = pnt2.XYZ() - pnt1.XYZ();
50 Standard_Real dist = v.Magnitude();
51
52 //#47 rln 09.12.98 S4054 PRO14323 entity 2844
53 if ( dist + tol2 <= tol1 ) {
54 pos = pnt1;
55 tol = tol1;
56 }
57 else if ( dist + tol1 <= tol2 ) {
58 pos = pnt2;
59 tol = tol2;
60 }
61 else {
62 tol = 0.5 * ( dist + tol1 + tol2 );
63 Standard_Real s = ( dist > 0. )? ( tol2 - tol1 ) / dist : 0.; //szv#4:S4163:12Mar99 anti-exception
64 pos = 0.5 * ( ( 1 - s ) * pnt1.XYZ() + ( 1 + s ) * pnt2.XYZ() );
65 }
66
67 TopoDS_Vertex V;
68 BRep_Builder B;
69 B.MakeVertex ( V, pos, tolFactor * tol );
70 return V;
71}
72