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
16 #include <ShapeBuild_Vertex.ixx>
17 #include <BRep_Tool.hxx>
18 #include <Precision.hxx>
19 #include <BRep_Builder.hxx>
21 //=======================================================================
22 //function : CombineVertex
24 //=======================================================================
26 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const TopoDS_Vertex& V1,
27 const TopoDS_Vertex& V2,
28 const Standard_Real tolFactor) const
30 return CombineVertex ( BRep_Tool::Pnt ( V1 ), BRep_Tool::Pnt ( V2 ),
31 BRep_Tool::Tolerance ( V1 ), BRep_Tool::Tolerance ( V2 ),
35 //=======================================================================
36 //function : CombineVertex
38 //=======================================================================
40 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const gp_Pnt& pnt1,
42 const Standard_Real tol1,
43 const Standard_Real tol2,
44 const Standard_Real tolFactor) const
49 gp_Vec v = pnt2.XYZ() - pnt1.XYZ();
50 Standard_Real dist = v.Magnitude();
52 //#47 rln 09.12.98 S4054 PRO14323 entity 2844
53 if ( dist + tol2 <= tol1 ) {
57 else if ( dist + tol1 <= tol2 ) {
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() );
69 B.MakeVertex ( V, pos, tolFactor * tol );