// Created on: 1998-03-27 // Created by: # Andre LIEUTIER // Copyright (c) 1998-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #include static const Standard_Real NORMIN = 1.e-10; static const Standard_Real COSMIN = 1.e-2; // G1 Constraints Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d,const Plate_D1& D1S,const Plate_D1& D1T, const Standard_Real IncrementalLoad, const Standard_Integer orientation) { pnt2d = point2d; nb_PPConstraints = 0; nb_LSConstraints = 0; gp_XYZ normale = D1T.Du^D1T.Dv; if(normale.Modulus() < NORMIN) return; normale.Normalize(); if(IncrementalLoad!=1.) { gp_XYZ N0 = D1S.Du^D1S.Dv; if(N0.Modulus()< NORMIN) return; N0.Normalize(); gp_XYZ N1 = normale; if(orientation!=0) N1 *= orientation; Standard_Real c = N0*N1; if(orientation==0) { if (c <0.) { c *= -1.; N1 *= -1.; } } Standard_Real s = N0.CrossMagnitude(N1); if((s < 1.e-2)&&(c<0.)) return; Standard_Real angle = atan2(c,s); //if (angle < 0.) angle += M_PI; gp_XYZ d = N0^N1; d.Normalize(); gp_Dir dir = gp_Dir(d); gp_Trsf rota; gp_Ax1 Axe(gp_Pnt(0,0,0), dir); rota.SetRotation(Axe,angle*(IncrementalLoad-1.)); // gp_Trsf rota = gce_MakeRotation(gp_Pnt(0,0,0), dir, angle*(IncrementalLoad-1.)); rota.Transforms(normale); } gp_XYZ du = D1S.Du*(-1.); gp_XYZ dv = D1S.Dv*(-1.); myLSC[0] = Plate_LinearScalarConstraint(Plate_PinpointConstraint(pnt2d, du,1,0), normale); myLSC[1] = Plate_LinearScalarConstraint(Plate_PinpointConstraint(pnt2d, dv,0,1), normale); nb_LSConstraints = 2; } // G1 + G2 Constraints Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d,const Plate_D1& D1S,const Plate_D1& D1T0, const Plate_D2& D2S,const Plate_D2& D2T0, const Standard_Real IncrementalLoad, const Standard_Integer orientation) { pnt2d = point2d; nb_PPConstraints = 0; nb_LSConstraints = 0; Plate_D1 D1T = D1T0; Plate_D2 D2T = D2T0; gp_XYZ normale = D1T.Du^D1T.Dv; if(normale.Modulus() < NORMIN) return; normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du^D1S.Dv; if(normaleS.Modulus() < NORMIN) { if(IncrementalLoad!=1.) return; gp_XYZ du = D1S.Du*(-1.); gp_XYZ dv = D1S.Dv*(-1.); myLSC[0] = Plate_LinearScalarConstraint(Plate_PinpointConstraint(pnt2d, du,1,0), normale); myLSC[1] = Plate_LinearScalarConstraint(Plate_PinpointConstraint(pnt2d, dv,0,1), normale); nb_LSConstraints = 2; return; } normaleS.Normalize(); if(IncrementalLoad!=1.) { gp_XYZ N0 = normaleS; gp_XYZ N1 = normale; if(orientation!=0) N1 *= orientation; Standard_Real c = N0*N1; if(orientation==0) { if (c <0.) { c *= -1.; N1 *= -1.; } } Standard_Real s = N0.CrossMagnitude(N1); if((s < 1.e-2)&&(c<0.)) return; Standard_Real angle = atan2(c,s); gp_XYZ d = N0^N1; d.Normalize(); gp_Dir dir = gp_Dir(d); gp_Trsf rota; gp_Ax1 Axe(gp_Pnt(0,0,0), dir); rota.SetRotation(Axe,angle*(IncrementalLoad-1.)); // gp_Trsf rota = gce_MakeRotation(gp_Pnt(0,0,0), dir, angle*(IncrementalLoad-1.)); rota.Transforms(normale); rota.Transforms(D1T.Du); rota.Transforms(D1T.Dv); rota.Transforms(D2T.Duu); rota.Transforms(D2T.Duv); rota.Transforms(D2T.Dvv); } Standard_Real cos_normales = normale*normaleS; if( fabs(cos_normales)