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 <Precision.hxx>
21 #include <ShapeBuild_Vertex.hxx>
22 #include <TopoDS_Vertex.hxx>
24 //=======================================================================
25 //function : CombineVertex
27 //=======================================================================
28 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const TopoDS_Vertex& V1,
29 const TopoDS_Vertex& V2,
30 const Standard_Real tolFactor) const
32 return CombineVertex ( BRep_Tool::Pnt ( V1 ), BRep_Tool::Pnt ( V2 ),
33 BRep_Tool::Tolerance ( V1 ), BRep_Tool::Tolerance ( V2 ),
37 //=======================================================================
38 //function : CombineVertex
40 //=======================================================================
42 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const gp_Pnt& pnt1,
44 const Standard_Real tol1,
45 const Standard_Real tol2,
46 const Standard_Real tolFactor) const
51 gp_Vec v = pnt2.XYZ() - pnt1.XYZ();
52 Standard_Real dist = v.Magnitude();
54 //#47 rln 09.12.98 S4054 PRO14323 entity 2844
55 if ( dist + tol2 <= tol1 ) {
59 else if ( dist + tol1 <= tol2 ) {
64 tol = 0.5 * ( dist + tol1 + tol2 );
65 Standard_Real s = ( dist > 0. )? ( tol2 - tol1 ) / dist : 0.; //szv#4:S4163:12Mar99 anti-exception
66 pos = 0.5 * ( ( 1 - s ) * pnt1.XYZ() + ( 1 + s ) * pnt2.XYZ() );
71 B.MakeVertex ( V, pos, tolFactor * tol );