1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <IntPatch_CSFunction.ixx>
17 #include <Adaptor3d_HSurface.hxx>
18 #include <Adaptor3d_HSurfaceTool.hxx>
19 #include <Adaptor2d_HCurve2d.hxx>
20 #include <IntPatch_HCurve2dTool.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <gp_Vec2d.hxx>
28 #define No_Standard_RangeError
29 #define No_Standard_OutOfRange
33 #define SURFACE1 (*((Handle(Adaptor3d_HSurface) *)(surface1)))
34 #define SURFACE2 (*((Handle(Adaptor3d_HSurface) *)(surface2)))
35 #define CURVE (*((Handle(Adaptor2d_HCurve2d) *)(curve)))
37 IntPatch_CSFunction::IntPatch_CSFunction(const Handle(Adaptor3d_HSurface)& S1,
38 const Handle(Adaptor2d_HCurve2d)& C,
39 const Handle(Adaptor3d_HSurface)& S2)
41 surface1 = (Standard_Address)(&S1);
42 surface2 = (Standard_Address)(&S2);
43 curve = (Standard_Address)(&C);
47 Standard_Integer IntPatch_CSFunction::NbVariables()const { return 3;}
49 Standard_Integer IntPatch_CSFunction::NbEquations()const { return 3;}
51 Standard_Boolean IntPatch_CSFunction::Value(const math_Vector& X,
54 gp_Pnt Psurf(Adaptor3d_HSurfaceTool::Value(SURFACE1,X(1),X(2)));
55 gp_Pnt2d p2d(IntPatch_HCurve2dTool::Value(CURVE,X(3)));
56 gp_Pnt Pcurv(Adaptor3d_HSurfaceTool::Value(SURFACE2,p2d.X(),p2d.Y()));
58 F(1) = Psurf.X()-Pcurv.X();
59 F(2) = Psurf.Y()-Pcurv.Y();
60 F(3) = Psurf.Z()-Pcurv.Z();
61 f = F(1)*F(1)+ F(2)*F(2)+ F(3)*F(3);
62 p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())/2.);
66 Standard_Boolean IntPatch_CSFunction::Derivatives ( const math_Vector& X,
74 Adaptor3d_HSurfaceTool::D1(SURFACE1,X(1),X(2),Psurf,D1u,D1v);
75 IntPatch_HCurve2dTool::D1(CURVE,X(3),p2d,d2d);
76 Adaptor3d_HSurfaceTool::D1(SURFACE2,p2d.X(),p2d.Y(),Pcurv,d1u,d1v);
77 D1w.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
91 Standard_Boolean IntPatch_CSFunction::Values( const math_Vector& X,
101 Adaptor3d_HSurfaceTool::D1(SURFACE1,X(1),X(2),Psurf,D1u,D1v);
102 IntPatch_HCurve2dTool::D1(CURVE,X(3),p2d,d2d);
103 Adaptor3d_HSurfaceTool::D1(SURFACE2,p2d.X(),p2d.Y(),Pcurv,d1u,d1v);
104 D1w.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
115 F(1) = Psurf.X()-Pcurv.X();
116 F(2) = Psurf.Y()-Pcurv.Y();
117 F(3) = Psurf.Z()-Pcurv.Z();
118 f = F(1)*F(1)+ F(2)*F(2)+ F(3)*F(3);
119 p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())/2.);
120 return Standard_True;
123 const gp_Pnt& IntPatch_CSFunction::Point() const { return p;}
125 Standard_Real IntPatch_CSFunction::Root() const { return f;}
127 const Handle(Adaptor3d_HSurface)& IntPatch_CSFunction::AuxillarSurface() const {
130 const Handle(Adaptor2d_HCurve2d)& IntPatch_CSFunction::AuxillarCurve() const {