Пример #1
0
HRESULT CMenuToolbarBase::OnPagerCalcSize(LPNMPGCALCSIZE csize)
{
    SIZE tbs;
    GetSizes(NULL, &tbs, NULL);
    if (csize->dwFlag == PGF_CALCHEIGHT)
    {
        csize->iHeight = tbs.cy;
    }
    else if (csize->dwFlag == PGF_CALCWIDTH)
    {
        csize->iWidth = tbs.cx;
    }
    return S_OK;
}
Пример #2
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       GetVirtualWidth()
//  DESC:
//  PARAMETERS: NOne
//  RETURN:     None
//----------------------------------------------------------------------E-+++
ChartValue wxChartWindow::GetVirtualWidth() const
{
    int iNodes = static_cast<int>(ceil( GetVirtualMaxX() ));
    wxChartSizes *sizes = GetSizes();

    ChartValue x = 0;

    for ( int iNode = 0; iNode <= iNodes; ++ iNode )
    {
        x +=  GetZoom() * ( sizes->GetWidthBar() * sizes->GetNumBar() +
                sizes->GetWidthBar3d() * sizes->GetNumBar3d() +
                sizes->GetGap() );
    }

    return ( x );
}
Пример #3
0
DWORD PCOBuffer::Allocate()
{
  DWORD err = 0;
  int ccdxsize = 0;
  int ccdysize = 0;
  int width = 0;
  int height = 0;

  err = GetSizes(cameraHandle,&ccdxsize,&ccdysize,&width,&height,&bit_pix);
  if (err != PCO_NOERROR)
  {
   errmsg.ShowPCOError("GetSizes",err);
   return err;
  }

//check if buffer was already allocated
  if (bufnr > -1)
  {
//if buffer has different size allocate new one else use old
   if ((bufwidth != width) || (bufheight != height))
   {
    err = Free();
    if (err != PCO_NOERROR)
     return err;
   }
   else
    return 0;
  }

  int size = width * height * 2;

  picev = NULL;
  err = AllocateBufferEx(cameraHandle,&bufnr,size,&picev,&buf);
  errmsg.ShowPCOError("AllocateBufferEx",err);
  if(err == PCO_NOERROR)
  {
   bufwidth=width;
   bufheight=height;
  }

  return err;
}
Пример #4
0
//+++-S-cf-------------------------------------------------------------------
//	NAME:		Draw()
//	DESC:		Draw xaxis
//	PARAMETERS:	CHART_HPAINT hp,
//				CHART_HRECT hr
//	RETURN:		None
//----------------------------------------------------------------------E-+++
void wxYAxis::Draw(
    CHART_HPAINT hp,
    CHART_HRECT hr
)
{
    if ( GetVirtualMax() > 0 )
    {
        double range = GetVirtualMax();
        double start = 0;
        double end = range;

        int int_log_range = (int)floor( log10( range ) );
        double step = 1.0;
        if (int_log_range > 0)
        {
            for (int i = 0; i < int_log_range; i++)
                step *= 10;
        }
        if (int_log_range < 0)
        {
            for (int i = 0; i < -int_log_range; i++)
                step /= 10;
        }
        double lower = ceil(start / step) * step;
        double upper = floor(end / step) * step;

        // if too few values, shrink size
        if ((range/step) < 4)
        {
            step /= 2;
            if (lower-step > start) lower -= step;
            if (upper+step < end) upper += step;
        }

        // if still too few, again
        if ((range/step) < 4)
        {
            step /= 2;
            if (lower-step > start) lower -= step;
            if (upper+step < end) upper += step;
        }

        wxChartSizes *sizes = GetSizes();


        wxFont font( 8, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
        hp->SetFont(font);
        hp->SetPen( *wxBLACK_PEN );

        double current = lower;
        while (current < upper+(step/2))
        {
            int y = (int)( (GetVirtualMax()-current) /
                           range * ((double)hr->h - sizes->GetSizeHeight())) - 1;
            if ((y > 10) && (y < hr->h - 7 - sizes->GetSizeHeight()))
            {
                hp->DrawLine( hr->x + hr->w - 15,
                              y + sizes->GetSizeHeight() + hr->y,
                              hr->x + hr->w - 7,
                              y + sizes->GetSizeHeight() + hr->y );
                wxString label;
                if (range < 50)
                {
                    label.Printf( wxT("%f"), current );
                    while (label.Last() == wxT('0'))
                        label.RemoveLast();
                    if ((label.Last() == wxT('.')) || (label.Last() == wxT(',')))
                        label.Append( wxT('0') );
                }
                else
                    label.Printf( wxT("%d"), (int)floor(current) );
                hp->DrawText( label, hr->x + 5,
                              hr->y + y - 7 + sizes->GetSizeHeight() );
            }

            current += step;
        }

        hp->DrawLine( hr->w - 1, 6 + sizes->GetSizeHeight(),
                      hr->w - 1, hr->h );

        //hp->DrawLine( hr->w - 7, 6 + sizes.s_height,
        //			  hr->w - 7, hr->h );
        //hp->DrawLine( hr->w - 7, 2 + sizes.s_height,
        //			  hr->w - 13, 8 + sizes.s_height );
        //hp->DrawLine( hr->w - 7, 2 + sizes.s_height,
        //			  hr->w - 2, 8 + sizes.s_height );
    }
}
//+++-S-cf-------------------------------------------------------------------
//  NAME:       Draw()
//  DESC:       Draw Bar chart
//  PARAMETERS: CHART_HPAINT hp, 
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxBar3DChartPoints::Draw(
    CHART_HPAINT hp, 
    CHART_HRECT hr
)
{
    //-----------------------------------------------------------------------
    // get number of bars
    //-----------------------------------------------------------------------
    double iNodes = ceil( static_cast<double>(GetCount()) );

    //-----------------------------------------------------------------------
    // Get sizes
    //-----------------------------------------------------------------------
    wxChartSizes *sizes = GetSizes();

    //-----------------------------------------------------------------------
    // get max height
    //-----------------------------------------------------------------------
    double ValMax = ceil( sizes->GetMaxY() );
    if ( ValMax == 0 ) 
        ValMax = 1;
    
    hp->SetBrush( wxBrush(GetColor(), wxSOLID) );
    //hp->SetPen( *wxTRANSPARENT_PEN );
    //hp->SetPen( *wxLIGHT_GREY_PEN );
    hp->SetPen( wxPen(wxChartColors::GetDarkColor(GetColor(), 15)) );

    double x, y, w, h;
        
    //-----------------------------------------------------------------------
    // Get the real width of the bar
    // Assume 80% of sizes->GetWidthBar3d()
    //-----------------------------------------------------------------------
    w = sizes->GetWidthBar3d() * 0.80;
    
    //-----------------------------------------------------------------------
    // Get how mutch high deep the bar should start.
    // Suppose we to use 30 degree
    // rad = 2 * pi / 360 * grd
    //-----------------------------------------------------------------------
    h = ( sizes->GetWidthBar3d() - w ) / cos( 0.5236 ) * sin( 0.5236 );
    h *= GetZoom();
    
    for ( int iNode = 0; iNode < iNodes; ++ iNode )
    {
        //-------------------------------------------------------------------
        // Get x-position for iNode bar
        //-------------------------------------------------------------------
        double xVal  = ceil( GetXVal(iNode) );
        x = hr->x + GetZoom() * xVal * ( 
                sizes->GetWidthBar() * sizes->GetNumBar() + 
                sizes->GetWidthBar3d() * sizes->GetNumBar3d() + 
                sizes->GetGap() );

        //-------------------------------------------------------------------
        // Get y-position for iNode bar
        //-------------------------------------------------------------------
        y = hr->y + ( (hr->h - sizes->GetSizeHeight() )* GetYVal(iNode) ) / ValMax ;

        hp->DrawRectangle( static_cast<int>(ceil(x)),
                           static_cast<int>(ceil(hr->h - y)),
                           static_cast<int>(ceil(w * GetZoom())), 
                           static_cast<int>(ceil(y)));
       
        //-------------------------------------------------------------------
        // Draw Poligon next to main Rectangle 
        //-------------------------------------------------------------------
    	        
        hp->SetBrush( wxBrush(wxChartColors::GetDarkColor(GetColor(), 
            10), wxSOLID) );
        
        //-------------------------------------------------------------------
        // Make sure that the difference y and y - h is at lease 1
        //-------------------------------------------------------------------
        int y1 = static_cast<int>(ceil(static_cast<double>(hr->h)));
        int y2 = static_cast<int>(ceil(static_cast<double>(hr->h - h)));
        int y3 = static_cast<int>(ceil(static_cast<double>(hr->h - y - h)));
        int y4 = static_cast<int>(ceil(static_cast<double>(hr->h - y)));
        int d = y1 - y2 > y4 - y3 ? y1 - y2 : y4 - y3;
        if ( d == 0 )
            d += 1;
        
        wxPoint next[] = { 
            wxPoint( 
                static_cast<int>(ceil(x + w * GetZoom())), 
                y1 ),
            wxPoint( 
                static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), 
                y1 - d ),
            wxPoint( 
                static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), 
                y4 - d ),
            wxPoint( 
                static_cast<int>(ceil(x + w * GetZoom())), 
                y4 ),
	   };
	
    	hp->DrawPolygon( 4, next );

        //-------------------------------------------------------------------
        // Draw Poligon on top of main Rectangle 
        //-------------------------------------------------------------------
        wxPoint top[] = { 
            wxPoint( 
                static_cast<int>(ceil(x)), 
                y4 ),
            wxPoint( 
                static_cast<int>(ceil(x + w * GetZoom())), 
                y4 ),
            wxPoint( 
                static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), 
                y4 - d ),
            wxPoint( 
                static_cast<int>(ceil(x + (sizes->GetWidthBar3d() - w) * GetZoom())), 
                y4 - d ),
       };
    
        hp->DrawPolygon( 4, top );

        hp->SetBrush( wxBrush(GetColor(), wxSOLID) );
	
        //-------------------------------------------------------------------
        // Only draw Label if user wants it
        //-------------------------------------------------------------------
        if (!m_ShowLabel)
            continue;

        wxString lbl;
        wxLabel wxLbl;
        switch ( GetDisplayTag() )
        {
        case XVALUE:
            lbl.Printf( wxT("%d"), static_cast<int>(xVal));
            wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                        static_cast<int>(ceil(hr->h - y)), 
                        GetColor(),
                        lbl,
                        UP);
            break;
        case YVALUE:
            lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iNode)));
			
            wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                        static_cast<int>(ceil(hr->h - y)), 
                        GetColor(),
                        lbl,
                        UP );
            break;
        case XVALUE_FLOAT:
            lbl.Printf( wxT("%4.1f"), xVal);
            wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                        static_cast<int>(ceil(hr->h - y)), 
                        GetColor(),
                        lbl,
                        UP);
            break;
        case YVALUE_FLOAT:
            lbl.Printf( wxT("%4.1f"), GetYVal(iNode));
        
            wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                        static_cast<int>(ceil(hr->h - y)), 
                        GetColor(),
                        lbl,
                        UP );
            break;
            case NAME:
            lbl = GetName(iNode).c_str();
            wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                        static_cast<int>(ceil(hr->h - y)), 
                        GetColor(),
                        lbl,
                        UP );
            break;
        default:
            break;      
        }
    }

    hp->SetPen( *wxBLACK_PEN );
}
Пример #6
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       DrawHLines()
//  DESC:       Draw horizontal lines
//  PARAMETERS: CHART_HPAINT hp,
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxChartWindow::DrawHLines(
    CHART_HPAINT hp,
    CHART_HRECT hr
)
{
    if ( GetVirtualMaxY() > 0 )
    {
        double range = GetVirtualMaxY();
        double start = 0;
        double end = range;

        int int_log_range = (int)floor( log10( range ) );
        double step = 1.0;
        if (int_log_range > 0)
        {
            for (int i = 0; i < int_log_range; i++)
                step *= 10;
        }
        if (int_log_range < 0)
        {
            for (int i = 0; i < -int_log_range; i++)
                step /= 10;
        }
        double lower = ceil(start / step) * step;
        double upper = floor(end / step) * step;

        // if too few values, shrink size
        if ((range/step) < 4)
        {
            step /= 2;
            if (lower-step > start) lower -= step;
            if (upper+step < end) upper += step;
        }

        // if still too few, again
        if ((range/step) < 4)
        {
            step /= 2;
            if (lower-step > start) lower -= step;
            if (upper+step < end) upper += step;
        }

        wxChartSizes *sizes = GetSizes();
/* C::B begin */
        // avoid crashes if style contains USE_GRID and no charts are added to chartctrl
        if(!sizes)
            return;
/* C::B end */

        hp->SetPen( *wxBLACK_DASHED_PEN );

        double current = lower;
        while (current < upper+(step/2))
        {
            int y = (int)( (GetVirtualMaxY()-current) /
                    range * ((double)hr->h - sizes->GetSizeHeight())) - 1;
            if ((y > 10) && (y < hr->h - 7 - sizes->GetSizeHeight()))
            {
                hp->DrawLine( hr->x,
                              y + sizes->GetSizeHeight() + hr->y,
                    hr->x + static_cast<int>(GetVirtualWidth()),
                    y + sizes->GetSizeHeight() + hr->y );
            }

            current += step;
        }
    }
}
Пример #7
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       Draw()
//  DESC:       Draw Bar chart
//  PARAMETERS: CHART_HPAINT hp, 
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxBarChartPoints::Draw(
    CHART_HPAINT hp, 
    CHART_HRECT hr
)
{
    //-----------------------------------------------------------------------
    // get number of bars
    //-----------------------------------------------------------------------
    double iNodes = ceil( static_cast<double>(GetCount()) );

    //-----------------------------------------------------------------------
    // Get sizes
    //-----------------------------------------------------------------------
    wxChartSizes *sizes = GetSizes();

    //-----------------------------------------------------------------------
    // get max height
    //-----------------------------------------------------------------------
    double ValMax = ceil( sizes->GetMaxY() );
    if ( ValMax == 0 ) 
        ValMax = 1;
    
    hp->SetBrush( wxBrush(GetColor(), wxSOLID) );
    hp->SetPen( *wxTRANSPARENT_PEN );

    double x, y;
    for ( int iNode = 0; iNode < iNodes; ++ iNode )
    {
        //-------------------------------------------------------------------
        // Get x-position for iNode bar
        //-------------------------------------------------------------------
        double xVal  = ceil( GetXVal(iNode) );
        x = hr->x + GetZoom() * xVal * ( sizes->GetWidthBar() * 
                sizes->GetNumBar() + 
                sizes->GetWidthBar3d() * sizes->GetNumBar3d() + 
                sizes->GetGap() );

        //-------------------------------------------------------------------
        // Get y-position for iNode bar
        //-------------------------------------------------------------------
        y = hr->y + ( (hr->h - sizes->GetSizeHeight())* 
                GetYVal(iNode) ) / ValMax ;

        hp->DrawRectangle( static_cast<int>(ceil(x)),
                           static_cast<int>(ceil(hr->h - y)),
                           static_cast<int>(sizes->GetWidthBar() * GetZoom()), 
                           static_cast<int>(ceil(y)) );
        
        //-------------------------------------------------------------------
        // Only draw Label if user wants it
        //-------------------------------------------------------------------
        if (!m_ShowLabel)
            continue;

        wxString lbl;
        wxLabel wxLbl;
        switch ( GetDisplayTag() )
        {
            case XVALUE:
                lbl.Printf( wxT("%d"), static_cast<int>(xVal));
                wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                            static_cast<int>(ceil(hr->h - y)), 
                            GetColor(),
                            lbl,
                            UP);
                break;
            case YVALUE:
                lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iNode)));
                wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                            static_cast<int>(ceil(hr->h - y)), 
                            GetColor(),
                            lbl,
                            UP );
                break;
            case XVALUE_FLOAT:
                lbl.Printf( wxT("%4.1f"), xVal);
                wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                            static_cast<int>(ceil(hr->h - y)), 
                            GetColor(),
                            lbl,
                            UP);
                break;
            case YVALUE_FLOAT:
                lbl.Printf( wxT("%4.1f"), GetYVal(iNode));
                wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                            static_cast<int>(ceil(hr->h - y)), 
                            GetColor(),
                            lbl,
                            UP );
                break;
            case NAME:
                lbl = GetName(iNode).c_str();
                wxLbl.Draw( hp, static_cast<int>(ceil(x)), 
                            static_cast<int>(ceil(hr->h - y)), 
                            GetColor(),
                            lbl,
                            UP );
                break;
        default:
            break;      
        }
    }

    hp->SetPen( *wxBLACK_PEN );
}
Пример #8
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       Draw()
//  DESC:       Draw Bar chart
//  PARAMETERS: CHART_HPAINT hp,
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxPieChartPoints::Draw(
    CHART_HPAINT hp,
    CHART_HRECT hr
)
{

    //-----------------------------------------------------------------------
    // Get sizes
    //-----------------------------------------------------------------------
    wxChartSizes *sizes = GetSizes();

    int r = (int)wxMin( (int)hr->w/2,
        (int)(hr->h - 2*sizes->GetSizeHeight())/2 );

    if ( r > 0 )
    {
        int iNodes = GetCount();

        if ( iNodes > 0 )
        {
            int iData;
            int ValTot;
            int iDatas = GetCount();
            for ( iData = 0, ValTot = 0; iData < iDatas; ++ iData )
                ValTot += static_cast<int>(GetYVal( iData ));

            double percent;
            double grad;
            double rad;
            int x1, y1, x2, y2, xc, yc;
            xc = hr->x + hr->w/2;
            yc = hr->y + hr->h/2;
            x1 = xc + r;
            y1 = yc;

            hp->SetPen( *wxBLACK_PEN );

            for ( iData = 0, rad = 0; iData < iDatas; ++ iData )
            {
                hp->SetBrush( wxBrush(GetColor(iData), wxSOLID) );

                // Calc radiants
                percent = (double)(GetYVal(iData) * 100) / (double)ValTot;
                grad    = (double)(percent * 360) / (double)100;
                rad     += (double)(grad * 3.1415) / (double)180;

                x2 = (int)(xc + r * cos( rad ));
                y2 = (int)(yc - r * sin( rad ));
                hp->DrawArc( x1, y1, x2, y2, xc, yc );
                x1 = x2;
                y1 = y2;

                //-----------------------------------------------------------
                // Only draw Label if user wants it
                //-----------------------------------------------------------
                if (!m_ShowLabel)
                    continue;

                wxString lbl;
                wxLabel wxLbl;

                LABEL_POSITION p;
                if ( x2 > xc )
                    p = RIGHT;
                else
                    p = LEFT;
                if ( y2 > yc )
                    p = (LABEL_POSITION)( p | DOWN );
                else
                    p = (LABEL_POSITION)( p | UP );

                switch ( GetDisplayTag() )
                {
                case XVALUE:
                    lbl.Printf( wxT("%d"), static_cast<int>(GetXVal(iData)) );
                    wxLbl.Draw( hp, x2, y2, GetColor(iData), lbl, p );
                    break;
                case YVALUE:
                    lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iData)) );
                    wxLbl.Draw( hp, x2, y2, GetColor(iData), lbl, p );
                    break;
                case XVALUE_FLOAT:
                    lbl.Printf( wxT("%4.1f"), GetXVal(iData) );
                    wxLbl.Draw( hp, x2, y2, GetColor(iData), lbl, p );
                    break;
                case YVALUE_FLOAT:
                    lbl.Printf( wxT("%4.1f"), GetYVal(iData) );
                    wxLbl.Draw( hp, x2, y2, GetColor(iData), lbl, p );
                    break;
                    case NAME:
                    lbl = GetName(iData).c_str();
                    wxLbl.Draw( hp, x2, y2, GetColor(iData), lbl, p );
                    break;
                default:
                    break;
                }
            }
        }
    }

}
int StVKReducedInternalForces::LoadFromStream(FILE * fin, int rTarget, int bigEndianMachine) 
{
  if (verbose)
    printf("Loading polynomials assuming little endian machine: %s.", (!bigEndianMachine) ? "TRUE" : "FALSE");

  int header[4];

  if ((int)(fread(header, sizeof(int), 4, fin)) < 4)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }
  
  r = header[0];

  int buffer;
  if (bigEndianMachine)
  {
    little2big(&r, &buffer, sizeof(int));
    r = buffer;
  }

  if (rTarget > r)
  {
    printf("Error: the input cubic polynomial file has r=%d, but you requested %d > %d.\n", r, rTarget, r);
    throw 2;
  }

  // first read in the coefficients as if all modes requested
  if (verbose)
    printf(" r=%d\n", r);
  
  r2 = r * r;

  linearSize = header[1];

  if (bigEndianMachine)
  {
    little2big(&linearSize, &buffer, sizeof(int));
    linearSize = buffer;
  }

  quadraticSize = header[2];

  if (bigEndianMachine)
  {
    little2big(&quadraticSize, &buffer, sizeof(int));
    quadraticSize = buffer;
  }

  cubicSize = header[3];

  if (bigEndianMachine)
  {
    little2big(&cubicSize, &buffer, sizeof(int));
    cubicSize = buffer;
  }

  linearCoef_ = (double*) malloc (sizeof(double) * r * linearSize);

  if ((int)(fread(linearCoef_,sizeof(double),r*linearSize,fin)) < r*linearSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  double bufferd;
  if (bigEndianMachine)
  {
    for(int i=0; i<r*linearSize; i++)
    {
      little2big(&linearCoef_[i], &bufferd, sizeof(double));
      linearCoef_[i] = bufferd;
    }
  }

  quadraticCoef_ = (double*) malloc (sizeof(double) * r * quadraticSize);

  if ((int)(fread(quadraticCoef_,sizeof(double),r*quadraticSize,fin)) < r*quadraticSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  if (bigEndianMachine)
  {
    for(int i=0; i<r*quadraticSize; i++)
    {
      little2big(&quadraticCoef_[i], &bufferd, sizeof(double));
      quadraticCoef_[i] = bufferd;
    }
  }

  cubicCoef_ = (double*) malloc (sizeof(double) * r * cubicSize);

  if ((int)(fread(cubicCoef_,sizeof(double),r*cubicSize,fin)) < r*cubicSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  if (bigEndianMachine)
  {
    for(int i=0; i<r*cubicSize; i++)
    {
      little2big(&cubicCoef_[i], &bufferd, sizeof(double));
      cubicCoef_[i] = bufferd;
    }
  }

  if (rTarget >= 0)
  {
    int linearSizeTarget, quadraticSizeTarget, cubicSizeTarget;
    GetSizes(rTarget, &linearSizeTarget, &quadraticSizeTarget, &cubicSizeTarget);

    double * linearCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * linearSizeTarget);

    double * quadraticCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * quadraticSizeTarget);

    double * cubicCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * cubicSizeTarget);

    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
      {
        SetSizes(rTarget);
        int positionTarget = linearCoefPos(output, i); 
        SetSizes(r);
        int position = linearCoefPos(output, i); 
        linearCoefTemp_[positionTarget] = linearCoef_[position];
      }
 
    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
        for(int j=i; j<rTarget; j++)
        {
          SetSizes(rTarget);
          int positionTarget = quadraticCoefPos(output, i, j); 
          SetSizes(r);
          int position = quadraticCoefPos(output, i, j); 
          quadraticCoefTemp_[positionTarget] = quadraticCoef_[position];
        }

    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
        for(int j=i; j<rTarget; j++)
          for(int k=j; k<rTarget; k++)
          {
            SetSizes(rTarget);
            int positionTarget = cubicCoefPos(output, i, j, k); 
            SetSizes(r);
            int position = cubicCoefPos(output, i, j, k); 
            cubicCoefTemp_[positionTarget] = cubicCoef_[position];
          }

    r = rTarget;
    SetSizes(r);

    free(linearCoef_);
    free(quadraticCoef_);
    free(cubicCoef_);

    linearCoef_ = linearCoefTemp_;
    quadraticCoef_ = quadraticCoefTemp_;
    cubicCoef_ = cubicCoefTemp_;
  }

  volumetricMesh = NULL;
  U = NULL;
  reducedGravityForce = NULL;
  precomputedIntegrals = NULL;
  numElementVertices = 0;
  muLame = NULL;

  InitBuffers();

  addGravity = false;

  useSingleThread = 0;
  shallowCopy = 0;
  g=9.81; 

  return 0;
}
void StVKReducedInternalForces::SetSizes(int rTarget)
{
  r = rTarget;
  r2 = r*r;
  GetSizes(r, &linearSize, &quadraticSize, &cubicSize);
}
//+++-S-cf-------------------------------------------------------------------
//  NAME:       Draw()
//  DESC:       Draw Bar chart
//  PARAMETERS: CHART_HPAINT hp, 
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxPie3DChartPoints::Draw(
    CHART_HPAINT hp, 
    CHART_HRECT hr
)
{
    
    //-----------------------------------------------------------------------
    // Get sizes
    //-----------------------------------------------------------------------
    wxChartSizes *sizes = GetSizes();

    //-----------------------------------------------------------------------
    // Fit Ellisse in window
    //-----------------------------------------------------------------------
    int r = (int)wxMin( (int)hr->w / 2, 
        (int)(hr->h - 2 * sizes->GetSizeHeight() * ELLISSE_H) / 2 );
         
    if ( r > 0 )
    {
        int iNodes = GetCount();

        if ( iNodes > 0 )
        {
            int iData;
            int ValTot;         
            int iDatas = GetCount();
            for ( iData = 0, ValTot = 0; iData < iDatas; ++ iData )
                ValTot += static_cast<int>(GetYVal( iData ));

            hp->SetPen( *wxBLACK_PEN );

            double percent;
            double grad, grad1;
            double rad;
            int deep;
            int x, y, w, h;

			// Calc Size of Rectangle which hold Ellisse
            w = (int)floor(r * ELLISSE_W);
			h = (int)floor(r * ELLISSE_H);

			// Top corner left hand side
            x = hr->x + hr->w/2 - w/2;
            y = hr->y + hr->h/2 - h;
                        
            // Shadow Deep
            deep = (int)floor( SHADOW_DEEP * GetZoom() );
                        
			//---------------------------------------------------------------
			// Draw shadow part of chart
			//---------------------------------------------------------------      

			hp->DrawEllipticArc( 
				x, 
				y + deep, // Shadow Deep
				w, 
				h, 
				175, // Draw half Ellisse
				360);
			hp->DrawEllipticArc( 
				x, 
				y + deep, // Shadow Deep
				w, 
				h, 
				0, // Draw half Ellisse
				5);

			// left hand side line
			rad = DegToRad( 180 );
			
			hp->DrawLine( 
                EllipsePoint( w, h, x, y, rad ).x,
                EllipsePoint( w, h, x, y, rad ).y,
                EllipsePoint( w, h, x, y, rad ).x,
                EllipsePoint( w, h, x, y + deep, rad ).y + 1
            );

			// right hand side line
			rad = DegToRad( 360 );

            hp->DrawLine( 
                EllipsePoint( w, h, x, y, rad ).x,
                EllipsePoint( w, h, x, y, rad ).y,
                EllipsePoint( w, h, x, y, rad ).x,
                EllipsePoint( w - 180, h, x, y + deep, rad ).y
            );

			grad = 0;
			//int count = 0;
            for ( iData = 0; iData < iDatas; ++ iData )
            {
                hp->SetPen( *wxBLACK_PEN );
                hp->SetBrush( wxBrush(GetColor(iData), wxSOLID) );

                // Calc radiants
                percent = (double)(GetYVal(iData) * 100) / (double)ValTot;
                grad1    = grad + (double)(percent * 360) / (double)100;
                rad     = DegToRad( grad );
                
                hp->DrawEllipticArc( x, y, w, h, grad, grad1);

                //-----------------------------------------------------------
                // Fill the shadow with right color
                //-----------------------------------------------------------
                if ( grad1 > 180 )
                {
					//if (++count > 3)
					//	return;

                    // set colors to draw
                    hp->SetPen( 
                        wxPen(wxChartColors::GetDarkColor(
                            GetColor(iData), 15)) 
                    );
                    hp->SetBrush( 
                        wxBrush(wxChartColors::GetDarkColor(
                            GetColor(iData), 15), 
                        wxSOLID) 
                    );
                    
                    // Avoid redraw line
                    if ( grad1 < 360 )
                    {
                        hp->DrawLine( 
                            EllipsePoint( w, h, x, y, DegToRad( grad1 ) ).x,
                            EllipsePoint( w, h, x, y, DegToRad( grad1 ) ).y - 1,
                            EllipsePoint( w, h, x, y, DegToRad( grad1 ) ).x,
                            EllipsePoint( w, h, x, y + deep, 
                                DegToRad( grad1 ) ).y + 1
                        );
                    }
                    hp->FloodFill(
                        EllipsePoint( w, h, x, y, 
                            DegToRad( grad1 ) ).x - 3, // just inside
                        (int)floor(EllipsePoint( w, h, x, y, 
                            DegToRad( grad1 ) ).y + (double)deep/2), // middle
                        *wxWHITE
                    );
				}
                                
                //-----------------------------------------------------------
                // Only draw Label if user wants it
                //-----------------------------------------------------------
                if (!m_ShowLabel)
                    continue;

                wxString lbl; 
                wxLabel wxLbl;
                
                LABEL_POSITION p;
                if ( grad < 90 ||
                    grad > 270 )
                    p = RIGHT;
                else
                    p = LEFT;
                if ( grad  > 180 )
                    p = (LABEL_POSITION)( p | DOWN );
                else
                    p = (LABEL_POSITION)( p | UP );

                switch ( GetDisplayTag() )
                {
                case XVALUE:
                    lbl.Printf( wxT("%d"), static_cast<int>(GetXVal(iData)) );
                    wxLbl.Draw( hp, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).x, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).y, 
                        GetColor(iData), lbl, p );
                    break;
                case YVALUE:
                    lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iData)) );
                    wxLbl.Draw( hp, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).x, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).y, 
                        GetColor(iData), lbl, p );
                    break;
                case XVALUE_FLOAT:
                    lbl.Printf( wxT("%4.1f"), GetXVal(iData) );
                    wxLbl.Draw( hp, 
                                EllipsePoint( w, h, x, y, DegToRad( grad ) ).x, 
                                EllipsePoint( w, h, x, y, DegToRad( grad ) ).y, 
                                GetColor(iData), lbl, p );
                    break;
                case YVALUE_FLOAT:
                    lbl.Printf( wxT("%4.1f"), GetYVal(iData) );
                    wxLbl.Draw( hp, 
                                EllipsePoint( w, h, x, y, DegToRad( grad ) ).x, 
                                EllipsePoint( w, h, x, y, DegToRad( grad ) ).y, 
                                GetColor(iData), lbl, p );
                    break;
                    case NAME:
                    lbl = GetName(iData).c_str();
                    wxLbl.Draw( hp, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).x, 
                        EllipsePoint( w, h, x, y, DegToRad( grad ) ).y, 
                        GetColor(iData), lbl, p );
                    break;
                default:
                    break;            
                }

                grad = grad1;

            }

        }
    }
}