1 // Created on: 1997-03-05
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <AdvApp2Var_Context.hxx>
19 #include <AdvApp2Var_Criterion.hxx>
20 #include <AdvApp2Var_Patch.hxx>
21 #include <GeomPlate_PlateG1Criterion.hxx>
26 #include <TColgp_SequenceOfXY.hxx>
27 #include <TColgp_SequenceOfXYZ.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
30 // static Standard_Boolean first = Standard_True;
31 //============================================================================
32 //function : GeomPlate_PlateG1Criterion
34 //============================================================================
35 GeomPlate_PlateG1Criterion::
36 GeomPlate_PlateG1Criterion(const TColgp_SequenceOfXY& Data,
37 const TColgp_SequenceOfXYZ& G1Data,
38 const Standard_Real Maximum,
39 const AdvApp2Var_CriterionType Type,
40 const AdvApp2Var_CriterionRepartition Repart)
46 myRepartition = Repart;
50 //============================================================================
53 //============================================================================
55 void GeomPlate_PlateG1Criterion::Value(AdvApp2Var_Patch& P,
56 const AdvApp2Var_Context& C) const
58 Standard_Real UInt[2],VInt[2];
59 Standard_Integer MaxNbCoeff[2], NbCoeff[2];
60 Standard_Real * adrCoeff = NULL ;
61 adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower());
63 MaxNbCoeff[0] = C.ULimit();
64 MaxNbCoeff[1] = C.VLimit();
65 NbCoeff[0] = P.NbCoeffInU();
66 NbCoeff[1] = P.NbCoeffInV();
72 Standard_Real up,vp, ang = 0.;
74 Standard_Integer dimension = 3 * NbCoeff[1];
75 TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension);
76 TColStd_Array1OfReal Curve(1, 2*dimension);
77 TColStd_Array1OfReal Point(1, 3);
78 Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1);
79 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
81 Standard_Integer k1, k2, pos, ll=1;
82 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
83 // JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
84 pos = 3*(MaxNbCoeff[1])*(k1-1);
85 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
86 Patch(ll) = adrCoeff[pos];
87 Patch(ll+1) = adrCoeff[pos+1];
88 Patch(ll+2) = adrCoeff[pos+2];
93 Standard_Integer i, NbCtr = myData.Length();
94 for(i=1; i<=NbCtr; i++) {
96 gp_Vec v3h(myXYZ.Value(i).X(),myXYZ.Value(i).Y(),myXYZ.Value(i).Z());
97 gp_XY P2d = myData.Value(i);
98 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
99 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
100 // u,v recadres sur (-1,1)
101 up = (2*P2d.X()-UInt[0]-UInt[1])
102 / (UInt[1]-UInt[0]) ;
103 vp = (2*P2d.Y()-VInt[0]-VInt[1])
104 / (VInt[1]-VInt[0]) ;
105 PLib::EvalPoly2Var(up,vp,
107 NbCoeff[0]-1,NbCoeff[1]-1,3,
111 v1s.SetCoord(1,Digit[0]);
112 v1s.SetCoord(2,Digit[1]);
113 v1s.SetCoord(3,Digit[2]);
115 PLib::EvalPoly2Var(up,vp,
117 NbCoeff[0]-1,NbCoeff[1]-1,3,
121 v2s.SetCoord(1,Digit[0]);
122 v2s.SetCoord(2,Digit[1]);
123 v2s.SetCoord(3,Digit[2]);
126 if( v3s.Angle(v3h)>(M_PI/2)) {
127 if ((M_PI-v3s.Angle(v3h))>ang) {
128 ang=(M_PI-v3s.Angle(v3h));
132 if(v3s.Angle(v3h)>ang) {
142 //============================================================================
143 //function : IsSatisfied
145 //============================================================================
147 Standard_Boolean GeomPlate_PlateG1Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
149 return (P.CritValue() < myMaxValue);