Пример #1
0
GeoCoord::GeoCoord(double lng, double lat, double ellipsoidH)
{
   _latitude = lat;
   _longitude = lng;
   _ellipsoid_height = ellipsoidH;
   ToCartesian(&_fCartesianX, &_fCartesianY, &_fCartesianZ);
   _bCartesian = true;
}
Пример #2
0
cmsBool cmsGBDdumpVRML(cmsHANDLE hGBD, const char* fname)
{
    FILE* fp;
    int   i, j;
    cmsGDB* gbd = (cmsGDB*) hGBD;
    cmsGDBPoint* pt;

    fp = fopen (fname, "wt");
    if (fp == NULL)
        return FALSE;

    fprintf (fp, "#VRML V2.0 utf8\n");

    // set the viewing orientation and distance
    fprintf (fp, "DEF CamTest Group {\n");
    fprintf (fp, "\tchildren [\n");
    fprintf (fp, "\t\tDEF Cameras Group {\n");
    fprintf (fp, "\t\t\tchildren [\n");
    fprintf (fp, "\t\t\t\tDEF DefaultView Viewpoint {\n");
    fprintf (fp, "\t\t\t\t\tposition 0 0 340\n");
    fprintf (fp, "\t\t\t\t\torientation 0 0 1 0\n");
    fprintf (fp, "\t\t\t\t\tdescription \"default view\"\n");
    fprintf (fp, "\t\t\t\t}\n");
    fprintf (fp, "\t\t\t]\n");
    fprintf (fp, "\t\t},\n");
    fprintf (fp, "\t]\n");
    fprintf (fp, "}\n");

    // Output the background stuff
    fprintf (fp, "Background {\n");
    fprintf (fp, "\tskyColor [\n");
    fprintf (fp, "\t\t.5 .5 .5\n");
    fprintf (fp, "\t]\n");
    fprintf (fp, "}\n");

    // Output the shape stuff
    fprintf (fp, "Transform {\n");
    fprintf (fp, "\tscale .3 .3 .3\n");
    fprintf (fp, "\tchildren [\n");

    // Draw the axes as a shape:
    fprintf (fp, "\t\tShape {\n");
    fprintf (fp, "\t\t\tappearance Appearance {\n");
    fprintf (fp, "\t\t\t\tmaterial Material {\n");
    fprintf (fp, "\t\t\t\t\tdiffuseColor 0 0.8 0\n");
    fprintf (fp, "\t\t\t\t\temissiveColor 1.0 1.0 1.0\n");
    fprintf (fp, "\t\t\t\t\tshininess 0.8\n");
    fprintf (fp, "\t\t\t\t}\n");
    fprintf (fp, "\t\t\t}\n");
    fprintf (fp, "\t\t\tgeometry IndexedLineSet {\n");
    fprintf (fp, "\t\t\t\tcoord Coordinate {\n");
    fprintf (fp, "\t\t\t\t\tpoint [\n");
    fprintf (fp, "\t\t\t\t\t0.0 0.0 0.0,\n");
    fprintf (fp, "\t\t\t\t\t%f 0.0 0.0,\n",  255.0);
    fprintf (fp, "\t\t\t\t\t0.0 %f 0.0,\n",  255.0);
    fprintf (fp, "\t\t\t\t\t0.0 0.0 %f]\n",  255.0);
    fprintf (fp, "\t\t\t\t}\n");
    fprintf (fp, "\t\t\t\tcoordIndex [\n");
    fprintf (fp, "\t\t\t\t\t0, 1, -1\n");
    fprintf (fp, "\t\t\t\t\t0, 2, -1\n");
    fprintf (fp, "\t\t\t\t\t0, 3, -1]\n");
    fprintf (fp, "\t\t\t}\n");
    fprintf (fp, "\t\t}\n");


    fprintf (fp, "\t\tShape {\n");
    fprintf (fp, "\t\t\tappearance Appearance {\n");
    fprintf (fp, "\t\t\t\tmaterial Material {\n");
    fprintf (fp, "\t\t\t\t\tdiffuseColor 0 0.8 0\n");
    fprintf (fp, "\t\t\t\t\temissiveColor 1 1 1\n");
    fprintf (fp, "\t\t\t\t\tshininess 0.8\n");
    fprintf (fp, "\t\t\t\t}\n");
    fprintf (fp, "\t\t\t}\n");
    fprintf (fp, "\t\t\tgeometry PointSet {\n");

    // fill in the points here
    fprintf (fp, "\t\t\t\tcoord Coordinate {\n");
    fprintf (fp, "\t\t\t\t\tpoint [\n");

    // We need to transverse all gamut hull.
    for (i=0; i < SECTORS; i++)
        for (j=0; j < SECTORS; j++) {

            cmsVEC3 v;

            pt = &gbd ->Gamut[i][j];
            ToCartesian(&v, &pt ->p);

            fprintf (fp, "\t\t\t\t\t%g %g %g", v.n[0]+50, v.n[1], v.n[2]);

            if ((j == SECTORS - 1) && (i == SECTORS - 1))
                fprintf (fp, "]\n");
            else
                fprintf (fp, ",\n");

        }

        fprintf (fp, "\t\t\t\t}\n");



    // fill in the face colors
    fprintf (fp, "\t\t\t\tcolor Color {\n");
    fprintf (fp, "\t\t\t\t\tcolor [\n");

    for (i=0; i < SECTORS; i++)
        for (j=0; j < SECTORS; j++) {

           cmsVEC3 v;

            pt = &gbd ->Gamut[i][j];


            ToCartesian(&v, &pt ->p);


        if (pt ->Type == GP_EMPTY)
            fprintf (fp, "\t\t\t\t\t%g %g %g", 0.0, 0.0, 0.0);
        else
            if (pt ->Type == GP_MODELED)
                fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, .5, .5);
            else {
                fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, 1.0, 1.0);

            }

        if ((j == SECTORS - 1) && (i == SECTORS - 1))
                fprintf (fp, "]\n");
            else
                fprintf (fp, ",\n");
    }
    fprintf (fp, "\t\t\t}\n");


    fprintf (fp, "\t\t\t}\n");
    fprintf (fp, "\t\t}\n");
    fprintf (fp, "\t]\n");
    fprintf (fp, "}\n");

    fclose (fp);

    return TRUE;
}
Пример #3
0
// Interpolate a missing sector. Method identifies whatever this is top, bottom or mid
static
cmsBool InterpolateMissingSector(cmsGDB* gbd, int alpha, int theta)
{
    cmsSpherical sp;
    cmsVEC3 Lab;
    cmsVEC3 Centre;
    cmsLine ray;
    int nCloseSectors;
    cmsGDBPoint* Close[NSTEPS + 1];
    cmsSpherical closel, templ;
    cmsLine edge;
    int k, m;

    // Is that point already specified?
    if (gbd ->Gamut[theta][alpha].Type != GP_EMPTY) return TRUE;

    // Fill close points
    nCloseSectors = FindNearSectors(gbd, alpha, theta, Close);


    // Find a central point on the sector
    sp.alpha = (cmsFloat64Number) ((alpha + 0.5) * 360.0) / (SECTORS);
    sp.theta = (cmsFloat64Number) ((theta + 0.5) * 180.0) / (SECTORS);
    sp.r     = 50.0;

    // Convert to Cartesian
    ToCartesian(&Lab, &sp);

    // Create a ray line from centre to this point
    _cmsVEC3init(&Centre, 50.0, 0, 0);
    LineOf2Points(&ray, &Lab, &Centre);

    // For all close sectors
    closel.r = 0.0;
    closel.alpha = 0;
    closel.theta = 0;

    for (k=0; k < nCloseSectors; k++) {

        for(m = k+1; m < nCloseSectors; m++) {

            cmsVEC3 temp, a1, a2;

            // A line from sector to sector
            ToCartesian(&a1, &Close[k]->p);
            ToCartesian(&a2, &Close[m]->p);

            LineOf2Points(&edge, &a1, &a2);

            // Find a line
            ClosestLineToLine(&temp, &ray, &edge);

            // Convert to spherical
            ToSpherical(&templ, &temp);


            if ( templ.r > closel.r &&
                 templ.theta >= (theta*180.0/SECTORS) &&
                 templ.theta <= ((theta+1)*180.0/SECTORS) &&
                 templ.alpha >= (alpha*360.0/SECTORS) &&
                 templ.alpha <= ((alpha+1)*360.0/SECTORS)) {

                closel = templ;
            }
        }
    }

    gbd ->Gamut[theta][alpha].p = closel;
    gbd ->Gamut[theta][alpha].Type = GP_MODELED;

    return TRUE;

}
Пример #4
0
template <class P1, class P2> static
void Convolve_2( const GenericImage<P1>& image, GenericImage<P2>& sharp,
                 pcl_enum interpolation, float dR, float angleD, DPoint center, int c )
{
   PixelInterpolation* P = 0;
   PixelInterpolation::Interpolator<P1>* interpolator = 0;

   try
   {
      switch ( interpolation )
      {
      case LSInterpolation::Bilinear:
         P = new BilinearPixelInterpolation();
         break;
      default:
      case LSInterpolation::Bicubic:
         P = new BicubicPixelInterpolation();
         break;
      case LSInterpolation::BicubicSpline:
         P = new BicubicSplinePixelInterpolation();
         break;
      case LSInterpolation::BicubicBSpline:
         P = new BicubicBSplinePixelInterpolation();
         break;
      }

      interpolator = P->NewInterpolator<P1>( image[c], image.Width(), image.Height() );

      int w = image.Width() - 1;
      int h = image.Height() - 1;

      double fimg, fsharp;
      StatusMonitor monitor;
      monitor.Initialize( "<end><cbr>High-pass Larson-Sekanina filter", image.NumberOfPixels() );

      sharp.Zero();

      float dAlpha = Rad( angleD );
      for ( int x = 0; x < image.Width(); ++x )
         for ( int y = 0; y < image.Height(); ++y, ++monitor )
         {
            // Get the central value
            P1::FromSample( fimg, image.Pixel( x, y, c ) );
            fsharp = fimg+fimg;

            double r, theta;
            ToPolar( x, y, center, r, theta);

            DPoint delta;

            // Positive differential
            ToCartesian( r-dR, theta+dAlpha, center, delta );
            if ( delta.x < 0 )
               delta.x = Abs( delta.x );
            else if ( delta.x > w )
               delta.x = 2*w - delta.x;
            if ( delta.y < 0 )
               delta.y = Abs( delta.y );
            else if ( delta.y > h )
               delta.y = 2*h - delta.y;
            P1::FromSample( fimg, (*interpolator)( delta ) );
            fsharp -= fimg;

            //Negative differential
            ToCartesian( r-dR, theta-dAlpha, center, delta );
            if ( delta.x < 0 )
               delta.x = Abs( delta.x );
            else if ( delta.x > w )
               delta.x = 2*w - delta.x;
            if ( delta.y < 0 )
               delta.y = Abs( delta.y );
            else if ( delta.y > h )
               delta.y = 2*h - delta.y;
            P1::FromSample( fimg, (*interpolator)( delta ) );
            fsharp -= fimg;

            sharp.Pixel( x, y ) = P2::ToSample( fsharp );
         }

      delete interpolator;
      delete P;
   }

   catch ( ... )
   {
      if ( interpolator != 0 )
         delete interpolator;
      if ( P != 0 )
         delete P;
      throw;
   }
}
Пример #5
0
void GeoCoord::Recalc()
{
   ToCartesian(&_fCartesianX, &_fCartesianY, &_fCartesianZ);
   _bCartesian = true;
}
Пример #6
0
void CFpoint::Rotate( const CFfloat angle )
{
    ToPolar();
    m_x += angle;
    ToCartesian();
}