1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 // rln 22.03.99: syntax correction in CombineVertex
17 #include <BRep_Builder.hxx>
18 #include <BRep_Tool.hxx>
20 #include <ShapeBuild_Vertex.hxx>
21 #include <TopoDS_Vertex.hxx>
23 //=======================================================================
24 //function : CombineVertex
26 //=======================================================================
27 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const TopoDS_Vertex& V1,
28 const TopoDS_Vertex& V2,
29 const Standard_Real tolFactor) const
31 return CombineVertex ( BRep_Tool::Pnt ( V1 ), BRep_Tool::Pnt ( V2 ),
32 BRep_Tool::Tolerance ( V1 ), BRep_Tool::Tolerance ( V2 ),
36 //=======================================================================
37 //function : CombineVertex
39 //=======================================================================
41 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const gp_Pnt& pnt1,
43 const Standard_Real tol1,
44 const Standard_Real tol2,
45 const Standard_Real tolFactor) const
50 gp_Vec v = pnt2.XYZ() - pnt1.XYZ();
51 Standard_Real dist = v.Magnitude();
53 //#47 rln 09.12.98 S4054 PRO14323 entity 2844
54 if ( dist + tol2 <= tol1 ) {
58 else if ( dist + tol1 <= tol2 ) {
63 tol = 0.5 * ( dist + tol1 + tol2 );
64 Standard_Real s = ( dist > 0. )? ( tol2 - tol1 ) / dist : 0.; //szv#4:S4163:12Mar99 anti-exception
65 pos = 0.5 * ( ( 1 - s ) * pnt1.XYZ() + ( 1 + s ) * pnt2.XYZ() );
70 B.MakeVertex ( V, pos, tolFactor * tol );