1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 // rln 22.03.99: syntax correction in CombineVertex
20 #include <ShapeBuild_Vertex.ixx>
21 #include <BRep_Tool.hxx>
22 #include <Precision.hxx>
23 #include <BRep_Builder.hxx>
25 //=======================================================================
26 //function : CombineVertex
28 //=======================================================================
30 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const TopoDS_Vertex& V1,
31 const TopoDS_Vertex& V2,
32 const Standard_Real tolFactor) const
34 return CombineVertex ( BRep_Tool::Pnt ( V1 ), BRep_Tool::Pnt ( V2 ),
35 BRep_Tool::Tolerance ( V1 ), BRep_Tool::Tolerance ( V2 ),
39 //=======================================================================
40 //function : CombineVertex
42 //=======================================================================
44 TopoDS_Vertex ShapeBuild_Vertex::CombineVertex (const gp_Pnt& pnt1,
46 const Standard_Real tol1,
47 const Standard_Real tol2,
48 const Standard_Real tolFactor) const
53 gp_Vec v = pnt2.XYZ() - pnt1.XYZ();
54 Standard_Real dist = v.Magnitude();
56 //#47 rln 09.12.98 S4054 PRO14323 entity 2844
57 if ( dist + tol2 <= tol1 ) {
61 else if ( dist + tol1 <= tol2 ) {
66 tol = 0.5 * ( dist + tol1 + tol2 );
67 Standard_Real s = ( dist > 0. )? ( tol2 - tol1 ) / dist : 0.; //szv#4:S4163:12Mar99 anti-exception
68 pos = 0.5 * ( ( 1 - s ) * pnt1.XYZ() + ( 1 + s ) * pnt2.XYZ() );
73 B.MakeVertex ( V, pos, tolFactor * tol );