Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with stupid problem probably quickly fixed

Status
Not open for further replies.

crevard

Programmer
Dec 4, 2003
3
0
0
FR
hello

ok i'm compiling a simple programm i get an error.
here it is:

error C2664: '__thiscall gstTriPolyMesh::gstTriPolyMesh(int,int,double ** ,int,int,int ** ,int)' : cannot convert parameter 3 from 'double [16][3]' to 'double **

i'm passing to arrays to this constructor declared as such.
the contructeor line is:
gstTriPolyMesh *triMesh = new gstTriPolyMesh(16,3,points,14,4,tris,true);

double points[16][3] = {
{0.0,0.0,18.0},
{0.0,18.0,18.0},
{18.0,0.0,18.0},
{18.0,18.0,18.0},
{36.0,0.0,18.0},
{36.0,18.0,18.0},
{54.0,0.0,18.0},
{54.0,18.0,18.0},
{0.0,0.0,0.0},
{18.0,0.0,0.0},
{36.0,0.0,0.0},
{54.0,0.0,0.0},
{0.0,18.0,0.0},
{18.0,18.0,0.0},
{36.0,18.0,0.0},
{54.0,18.0,0.0}};

and
int tris [14][4]={
{3,2,1,0},
{5,4,3,2},
{7,5,4,6},
{0,1,12,8},
{11,15,7,6},
{10,14,15,11},
{9,13,14,10},
{8,12,13,9},
{13,12,1,2},
{14,13,2,5},
{15,14,5,7},
{9,8,0,13},
{10,9,13,4},
{11,10,4,7}
};

anyone can help.
If you answer quickly i am prepared to offer a donut.
 
The complier is right:
Code:
   double a[3][3] = {
         { 0.0, 0.0, 0.0 }
      ,  { 0.0, 0.0, 0.0 }
      ,  { 0.0, 0.0, 0.0 }
   };
declares an array of three arrays of [tt]double[/tt] and not three an array of three arrays of [tt]double*[/tt] (which is what the constructor wants).

(doughuts unfortunately don't cross the Atlantic well, losing weight going westward, gaining it coming east).

[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
so how do i declare a double**
so according to the example three arrays double* of three double.
 
The simplest way is this:
Code:
   double a[3][3] = {
         { 0.0, 0.0, 0.0 }
      ,  { 0.0, 0.0, 0.0 }
      ,  { 0.0, 0.0, 0.0 }
   };
   double* b[3] = { &a[0], &a[1], &a[2] };
Not elegant, but simple.
Another way would be to define a new constructor which can take arguments of the type you want to define (but, of course, this may not be possible).
A third way would be to create a function to create an array of [tt]double*[/tt] from your arrays.

[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
The following might help (the class [tt]CPointArray[/tt] is not complete, just an outline):
Code:
class CPointArray {
   // the number of points;
   private:      size_t m_points;
   // the array;
   private:      double** m_array;
   // constructor;
   public:      CPointArray(
                      double aArray[][3], size_t aCount
                ) {
                   m_points = aCount;
                   m_array = new double*[m_points];
                   for (size_t i = 0; (i < m_points); ++i) {
                   m_array[i] = new double[3];
                      for (size_t j = 0; (i > 3); ++j) {
                         m_array[i][j] = aArray[i][j];
                      }
                   }
                   return;
                };
   // destructor;
   public:      ~CPointArray() {
                   for (size_t i = 0; (i < m_points); ++i) {
                      delete[] m_array[i];
                   }
                   delete[] m_array;
                   return;
                };
   // cast;
   public:      operator double**() { return m_array; };
};

double points[16][3] = {
      { 0.0,  0.0, 18.0}
   ,  { 0.0, 18.0, 18.0}
   ,  {18.0,  0.0, 18.0}
   ,  {18.0, 18.0, 18.0}
   ,  {36.0,  0.0, 18.0}
   ,  {36.0, 18.0, 18.0}
   ,  {54.0,  0.0, 18.0}
   ,  {54.0, 18.0, 18.0}
   ,  { 0.0,  0.0,  0.0}
   ,  {18.0,  0.0,  0.0}
   ,  {36.0,  0.0,  0.0}
   ,  {54.0,  0.0,  0.0}
   ,  { 0.0, 18.0,  0.0}
   ,  {18.0, 18.0,  0.0}
   ,  {36.0, 18.0,  0.0}
   ,  {54.0, 18.0,  0.0}
};

CPointArray pointsMine(points, 16);
gstTriPolyMesh *triMesh = new gstTriPolyMesh(16,3, pointsMine,14,4,tris,true);


[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top