1 // File: GeomPlate_PlateG0Criterion.cxx
2 // Created: Wed Mar 5 10:04:41 1997
3 // Author: Joelle CHAUVET
5 //Modified by Jerome LEMONIER
6 // Tue Jun 17 10:20:35 1997
7 // Modification de la comparaison dans la methode
8 // Value (Appel a des distances remplace par le calcul
9 // de la distance au carre)
12 #include <GeomPlate_PlateG0Criterion.ixx>
13 #include <AdvApp2Var_Criterion.hxx>
14 #include <TColgp_SequenceOfXY.hxx>
15 #include <TColgp_SequenceOfXYZ.hxx>
19 #include <TColStd_HArray1OfReal.hxx>
24 //============================================================================
25 //function : GeomPlate_PlateG0Criterion
27 //============================================================================
30 GeomPlate_PlateG0Criterion::
31 GeomPlate_PlateG0Criterion(const TColgp_SequenceOfXY& Data,
32 const TColgp_SequenceOfXYZ& G0Data,
33 const Standard_Real Maximum,
34 const AdvApp2Var_CriterionType Type,
35 const AdvApp2Var_CriterionRepartition Repart)
41 myRepartition = Repart;
45 //============================================================================
48 //============================================================================
50 void GeomPlate_PlateG0Criterion::Value(AdvApp2Var_Patch& P,
51 const AdvApp2Var_Context& C) const
53 Standard_Real UInt[2],VInt[2];
54 Standard_Integer MaxNbCoeff[2], NbCoeff[2];
55 Standard_Real * adrCoeff = NULL ;
56 adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower());
58 MaxNbCoeff[0] = C.ULimit();
59 MaxNbCoeff[1] = C.VLimit();
60 NbCoeff[0] = P.NbCoeffInU();
61 NbCoeff[1] = P.NbCoeffInV();
67 Standard_Real up,vp, dist = 0.;
69 Standard_Integer dimension = 3 * NbCoeff[1];
70 TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension);
71 TColStd_Array1OfReal Curve(1, dimension);
72 TColStd_Array1OfReal Point(1, 3);
73 Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1);
75 Standard_Real * Result =
77 (Standard_Real *) &Curve.ChangeValue(1);
78 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
80 Standard_Integer k1, k2, pos, ll=1;
81 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
82 // JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
83 pos = 3*(MaxNbCoeff[1])*(k1-1);
84 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
85 Patch(ll) = adrCoeff[pos];
86 Patch(ll+1) = adrCoeff[pos+1];
87 Patch(ll+2) = adrCoeff[pos+2];
92 Standard_Integer i, NbCtr = myData.Length();
93 for(i=1; i<=NbCtr; i++) {
94 gp_XY P2d = myData.Value(i);
95 // gp_Pnt PP = myXYZ.Value(i);
97 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
98 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
99 // u,v recadres sur (-1,1)
100 up = (2*P2d.X()-UInt[0]-UInt[1])
101 / (UInt[1]-UInt[0]) ;
102 vp = (2*P2d.Y()-VInt[0]-VInt[1])
103 / (VInt[1]-VInt[0]) ;
104 PLib::EvalPoly2Var(up,vp,
106 NbCoeff[0]-1,NbCoeff[1]-1,3,
110 P3d.SetCoord(1,Digit[0]);
111 P3d.SetCoord(2,Digit[1]);
112 P3d.SetCoord(3,Digit[2]);
113 Standard_Real x=(P3d.Coord(1)-myXYZ.Value(i).Coord(1)),
114 y=(P3d.Coord(2)-myXYZ.Value(i).Coord(2)),
115 z=(P3d.Coord(3)-myXYZ.Value(i).Coord(3)),
116 DistTmp= x*x+y*y+z*z;
122 P.SetCritValue(Sqrt(dist));
126 //============================================================================
127 //function : IsSatisfied
129 //============================================================================
131 Standard_Boolean GeomPlate_PlateG0Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
133 return (P.CritValue() < myMaxValue);