1 // File: GeomPlate_PlateG1Criterion.cxx
2 // Created: Wed Mar 5 10:04:41 1997
3 // Author: Joelle CHAUVET
7 #include <GeomPlate_PlateG1Criterion.ixx>
8 #include <AdvApp2Var_Criterion.hxx>
9 #include <TColgp_SequenceOfXY.hxx>
10 #include <TColgp_SequenceOfXYZ.hxx>
14 #include <TColStd_HArray1OfReal.hxx>
18 // static Standard_Boolean first = Standard_True;
21 //============================================================================
22 //function : GeomPlate_PlateG1Criterion
24 //============================================================================
27 GeomPlate_PlateG1Criterion::
28 GeomPlate_PlateG1Criterion(const TColgp_SequenceOfXY& Data,
29 const TColgp_SequenceOfXYZ& G1Data,
30 const Standard_Real Maximum,
31 const AdvApp2Var_CriterionType Type,
32 const AdvApp2Var_CriterionRepartition Repart)
38 myRepartition = Repart;
42 //============================================================================
45 //============================================================================
47 void GeomPlate_PlateG1Criterion::Value(AdvApp2Var_Patch& P,
48 const AdvApp2Var_Context& C) const
50 Standard_Real UInt[2],VInt[2];
51 Standard_Integer MaxNbCoeff[2], NbCoeff[2];
52 Standard_Real * adrCoeff = NULL ;
53 adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower());
55 MaxNbCoeff[0] = C.ULimit();
56 MaxNbCoeff[1] = C.VLimit();
57 NbCoeff[0] = P.NbCoeffInU();
58 NbCoeff[1] = P.NbCoeffInV();
64 Standard_Real up,vp, ang = 0.;
66 Standard_Integer dimension = 3 * NbCoeff[1];
67 TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension);
68 TColStd_Array1OfReal Curve(1, 2*dimension);
69 TColStd_Array1OfReal Point(1, 3);
70 Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1);
72 Standard_Real * Result = (Standard_Real *) &Curve.ChangeValue(1);
76 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
78 Standard_Integer k1, k2, pos, ll=1;
79 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
80 // JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
81 pos = 3*(MaxNbCoeff[1])*(k1-1);
82 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
83 Patch(ll) = adrCoeff[pos];
84 Patch(ll+1) = adrCoeff[pos+1];
85 Patch(ll+2) = adrCoeff[pos+2];
90 Standard_Integer i, NbCtr = myData.Length();
91 for(i=1; i<=NbCtr; i++) {
93 gp_Vec v3h(myXYZ.Value(i).X(),myXYZ.Value(i).Y(),myXYZ.Value(i).Z());
94 gp_XY P2d = myData.Value(i);
95 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
96 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
97 // u,v recadres sur (-1,1)
98 up = (2*P2d.X()-UInt[0]-UInt[1])
100 vp = (2*P2d.Y()-VInt[0]-VInt[1])
101 / (VInt[1]-VInt[0]) ;
102 PLib::EvalPoly2Var(up,vp,
104 NbCoeff[0]-1,NbCoeff[1]-1,3,
108 v1s.SetCoord(1,Digit[0]);
109 v1s.SetCoord(2,Digit[1]);
110 v1s.SetCoord(3,Digit[2]);
112 PLib::EvalPoly2Var(up,vp,
114 NbCoeff[0]-1,NbCoeff[1]-1,3,
118 v2s.SetCoord(1,Digit[0]);
119 v2s.SetCoord(2,Digit[1]);
120 v2s.SetCoord(3,Digit[2]);
123 if( v3s.Angle(v3h)>(M_PI/2)) {
124 if ((M_PI-v3s.Angle(v3h))>ang) {
125 ang=(M_PI-v3s.Angle(v3h));
129 if(v3s.Angle(v3h)>ang) {
139 //============================================================================
140 //function : IsSatisfied
142 //============================================================================
144 Standard_Boolean GeomPlate_PlateG1Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
146 return (P.CritValue() < myMaxValue);