1 #include <nurbsS.h>
2 
main()3 int main(){
4   using namespace PLib ;
5 #ifdef WITH_IMAGE_MAGICK
6   IM_Image img ;
7 
8   if(!img.read("tleastS.png")){
9     cout << "Problem reading the tleastS.png image.\n" ;
10     return 1 ;
11   }
12 
13   Matrix_Point3Df Pts(img.rows(),img.cols()) ;
14   for(int i=0;i<Pts.rows();++i)
15     for(int j=0;j<Pts.cols();++j){
16       Pts(i,j).x() = i ;
17       Pts(i,j).y() = j ;
18       Pts(i,j).z() = img(i,j) ;
19     }
20 
21   PlNurbsSurfacef S ;
22 
23   S.leastSquares(Pts,3,3,Pts.rows()/3,Pts.cols()/3) ;
24 
25   S.writeVRML("tleastS.wrl",Color(255,100,255),50,80) ;
26 
27   #else
28   cout << "The least squares surface approximation test requires Image Magick\n" ;
29   #endif
30   return 0 ;
31 }
32