0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GeomPlate / GeomPlate_PlateG0Criterion.cxx
CommitLineData
7fd59977 1// File: GeomPlate_PlateG0Criterion.cxx
2// Created: Wed Mar 5 10:04:41 1997
3// Author: Joelle CHAUVET
4// <jct@sgi38>
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)
10
11
12#include <GeomPlate_PlateG0Criterion.ixx>
13#include <AdvApp2Var_Criterion.hxx>
14#include <TColgp_SequenceOfXY.hxx>
15#include <TColgp_SequenceOfXYZ.hxx>
16#include <gp_Vec.hxx>
17#include <gp_XY.hxx>
18#include <gp_Pnt.hxx>
19#include <TColStd_HArray1OfReal.hxx>
20#include <PLib.hxx>
21
22
23
24//============================================================================
25//function : GeomPlate_PlateG0Criterion
26//purpose :
27//============================================================================
28
29
30 GeomPlate_PlateG0Criterion::
31GeomPlate_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)
36{
37 myData=Data;
38 myXYZ=G0Data;
39 myMaxValue = Maximum;
40 myType = Type;
41 myRepartition = Repart;
42}
43
44
45//============================================================================
46//function : Value
47//purpose :
48//============================================================================
49
50void GeomPlate_PlateG0Criterion::Value(AdvApp2Var_Patch& P,
51 const AdvApp2Var_Context& C) const
52{
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());
57
58 MaxNbCoeff[0] = C.ULimit();
59 MaxNbCoeff[1] = C.VLimit();
60 NbCoeff[0] = P.NbCoeffInU();
61 NbCoeff[1] = P.NbCoeffInV();
62 UInt[0] = P.U0();
63 UInt[1] = P.U1();
64 VInt[0] = P.V0();
65 VInt[1] = P.V1();
66
67 Standard_Real up,vp, dist = 0.;
68
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);
7fd59977 74 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
75
76 Standard_Integer k1, k2, pos, ll=1;
77 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
78// JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
79 pos = 3*(MaxNbCoeff[1])*(k1-1);
80 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
81 Patch(ll) = adrCoeff[pos];
82 Patch(ll+1) = adrCoeff[pos+1];
83 Patch(ll+2) = adrCoeff[pos+2];
84 ll += 3;
85 }
86 }
87
88 Standard_Integer i, NbCtr = myData.Length();
89 for(i=1; i<=NbCtr; i++) {
90 gp_XY P2d = myData.Value(i);
91// gp_Pnt PP = myXYZ.Value(i);
92 gp_Pnt P3d;
93 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
94 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
95// u,v recadres sur (-1,1)
96 up = (2*P2d.X()-UInt[0]-UInt[1])
97 / (UInt[1]-UInt[0]) ;
98 vp = (2*P2d.Y()-VInt[0]-VInt[1])
99 / (VInt[1]-VInt[0]) ;
100 PLib::EvalPoly2Var(up,vp,
101 0,0,
102 NbCoeff[0]-1,NbCoeff[1]-1,3,
103 Coeffs[0],
104 Digit[0]);
105
106 P3d.SetCoord(1,Digit[0]);
107 P3d.SetCoord(2,Digit[1]);
108 P3d.SetCoord(3,Digit[2]);
109 Standard_Real x=(P3d.Coord(1)-myXYZ.Value(i).Coord(1)),
110 y=(P3d.Coord(2)-myXYZ.Value(i).Coord(2)),
111 z=(P3d.Coord(3)-myXYZ.Value(i).Coord(3)),
112 DistTmp= x*x+y*y+z*z;
113 if( DistTmp>dist ) {
114 dist = DistTmp;
115 }
116 }
117 }
118 P.SetCritValue(Sqrt(dist));
119}
120
121
122//============================================================================
123//function : IsSatisfied
124//purpose :
125//============================================================================
126
127Standard_Boolean GeomPlate_PlateG0Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
128{
129 return (P.CritValue() < myMaxValue);
130}
131