[vtkusers] double definition of vtkstd_bool

Thomas Stark toemmy at gmail.com
Wed Oct 18 13:17:22 EDT 2006


Hi,

when compiling the attached classes i always get the following error:

two or more data types in declaration of vtkstd_bool.

the error message points to the vtkConfigure.h.

No idea where the problem is, I didnt even use a bool in the code.
I am pretty new to vtk, so any help would be great.

Thanks in advance,
Thomas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061018/3b73fa8a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ShortestPathOnPolyhedralSurface.h
Type: text/x-c-header
Size: 1273 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061018/3b73fa8a/attachment.bin>
-------------- next part --------------
// ShortestPathOnPolyhedralSurface.cpp

#include "ShortestPathOnPolyhedralSurface.h"
#include "Graph.h"
#include <vtkPolyData.h>
#include <vtkMath.h>
#include <vtkIdList.h>

//***************************************************************************************************************************************

void ShortestPathOnPolyhedralSurface::trianglestrip(double* startpoint, double* endpoint, vtkPolyData* mesh) {

     // find the IDs of startpoint and endpoint in the mesh

     startpointID = mesh->FindPoint(startpoint);
     endpointID   = mesh->FindPoint(endpoint);


     // saves all cells using the startingpoint in cellList

     mesh->GetPointCells(startpointID, cellList);


     // chooses the cell from cellList which is the closest to the endpoint

     int cellListSize = cellList->GetNumberOfIds();
     CellDist* distArray = NULL;
     distArray = new CellDist[cellListSize];

     for (int i=0; i<cellListSize; i++) {
         mesh->GetCellPoints(cellList->GetId(i), ptIDs);
         double avgdist = 0;
	 for (int j=0; j<3; j++) {
             if (ptIDs->GetId(j) != startpointID) {
                  mesh->GetPoint(ptIDs->GetId(j), coord);  // definiert in vtkPointSet
                  double dist = vtkMath::Distance2BetweenPoints(endpoint, coord);
                  avgdist = avgdist + dist;
             }
         }

	 // save actual ID and distance in an array of this struct
		
		
	 distArray[i].cellID  = cellList->GetId(i);
         distArray[i].avgdist = avgdist;


     }

     // search in the struct array for CellId with the min avgdist

     double    tempDist = distArray[0].avgdist;
     vtkIdType tempID   = distArray[0].cellID;
     for (int i=1; i<cellListSize; i++) {
         if (tempDist > distArray[i].avgdist) {
	   tempDist = distArray[i].avgdist;
	   tempID   = distArray[i].cellID;
         }
     }

     vtkIdType start_CellID = tempID;

     delete [] distArray;
     distArray = NULL;

     // initializes the triangleStripList with the chosen cell as startcell
     // and sets values for the triangle's edge opposite to the startpoint

     triangleStripList->InsertId(0, start_CellID);
     mesh->GetCellPoints(start_CellID, ptIDs);
     
     // IDs of triangle points (initialized with -1)
     vtkIdType aID = -1;
     vtkIdType bID = -1;
     vtkIdType cID = -1;
 
     for (int i=0; i<3; i++) {
         if (ptIDs->GetId(i) != startpointID) {
              if (aID != -1)
               bID = ptIDs->GetId(i);
              else aID = ptIDs->GetId(i);
         }
     }

     vtkIdType cellID = start_CellID;
     int i=0;

     // picks the next cell which shares the same edge and proofs the
     // distance of the other two edges of the triangle (relative to
     // the endpoint) and chooses the edge with the smaller distance
     // then the next neighbor (sharing this new edge) will be picked
     // and so on ...

     while (cID != endpointID) {
           i = i+1;
           mesh->GetCellEdgeNeighbors(cellID, aID, bID, neighbor);
           mesh->GetCellPoints(neighbor->GetId(0), ptIDs); // nur ein nachbar ???

           for (int j=0; j<3; j++) {
               if (ptIDs->GetId(j) != aID  &&  ptIDs->GetId(j) != bID)
                cID = ptIDs->GetId(j);
           }

           mesh->GetPoint(aID, a);
           mesh->GetPoint(bID, b);
           mesh->GetPoint(cID, c);

           double distA = vtkMath::Distance2BetweenPoints(a, endpoint);
           double distB = vtkMath::Distance2BetweenPoints(b, endpoint);
           double distC = vtkMath::Distance2BetweenPoints(c, endpoint);

           double distAC_endpt = distC + distA;
           double distBC_endpt = distC + distB;

           if (distAC_endpt <= distBC_endpt)
                 bID = cID;
           else  aID = cID;

           cellID = neighbor->GetId(0);    // gibt es nur einen neighbor???
           triangleStripList->InsertId(i, cellID);
     }
}

//***************************************************************************************************************************************

void ShortestPathOnPolyhedralSurface::steinerpoints(vtkPolyData* mesh)  {

     // seeks the triangleStripList for entries (cellIds -> triangles)
     // computes and inserts on each edge 4 steinerpoints if they are
     // not already inserted into adjacency array

     steinerPoint* adjacency = NULL;
     adjacency = new steinerPoint[15];  //zun???hst 4 Punkte pro Kante + Eckpunkte
     int steinerID = -1;

     for (int i=0; i<sizeof(triangleStripList); i++) {

         vtkIdType cellID = triangleStripList->GetId(i);
         mesh->GetCellPoints(cellID, ptIDs);
         mesh->GetPoint(ptIDs->GetId(0), a);
         mesh->GetPoint(ptIDs->GetId(1), b);
         mesh->GetPoint(ptIDs->GetId(2), c);

         double distAB = vtkMath::Distance2BetweenPoints(a, b);
         double distAC = vtkMath::Distance2BetweenPoints(a, c);
         double distBC = vtkMath::Distance2BetweenPoints(b, c);


         // save point a,b and c to adjacency matrix, important fot building the adjacencylist
         // [A0, A1, A2, A3, A4, B0, B1, B2, B3, B4, C0, C!, C2, C3, C4]
         // where A0, B0 and C0 are the points of the triangle and A1-A4, B1-B4 and C1-C4
         // are the Steinerpoints


	 // Computing and Inserting the four Steinerpoints on edge AB
         distAB = distAB / 5;
         for (int j=0; j<5; j++) {

             for (int k=0; k<3; k++) {
              steiner[k] = a[k] + j * distAB * (b[k]-a[k]);
             }
             if (g.containsVertexWithCoord(steiner[0], steiner[1], steiner[2]) == 1) {
	      adjacency[j].ID = g.getIDofVertexWithCoord(steiner[0], steiner[1], steiner[2]);
	     }
	     else {
              steinerID = steinerID + 1;
              adjacency[j].ID = steinerID;
	     }
	     adjacency[j].x  = steiner[0];
	     adjacency[j].y  = steiner[1];
	     adjacency[j].z  = steiner[2];

          }

         // Computing and Inserting the four Steinerpoints on edge AC
         distAC = distAC / 5;
         for (int j=0; j<5; j++) {

             for (int k=0; k<3; k++) {
              steiner[k] = a[k] + j * distAC * (b[k]-a[k]);
             }
             if (g.containsVertexWithCoord(steiner[0], steiner[1], steiner[2]) == 1) {
	      adjacency[j+5].ID = g.getIDofVertexWithCoord(steiner[0], steiner[1], steiner[2]);
	     }
	     else {
	      steinerID = steinerID + 1;
	      adjacency[j+5].ID = steinerID;
	     }
             adjacency[j+5].x  = steiner[0];
	     adjacency[j+5].y  = steiner[1];
	     adjacency[j+5].z  = steiner[2];

         }

         // Computing and Inserting the four Steinerpoints on edge BC
         distBC = distBC / 5;
         for (int j=0; j<5; j++) {

             for (int k=0; k<3; k++) {
              steiner[k] = a[k] + j * distBC * (b[k]-a[k]);
             }
             if (g.containsVertexWithCoord(steiner[0], steiner[1], steiner[2]) == 1) {
	      adjacency[j+10].ID = g.getIDofVertexWithCoord(steiner[0], steiner[1], steiner[2]);
	     }
	     else {
	      steinerID = steinerID + 1;
              adjacency[j+10].ID = steinerID;
	     }
	     adjacency[j+10].x  = steiner[0];
	     adjacency[j+10].y  = steiner[1];
	     adjacency[j+10].z  = steiner[2];

          }

          buildAdjacency(adjacency);
     }

     delete [] adjacency;
     adjacency = NULL;

}

//***************************************************************************************************************************************

void ShortestPathOnPolyhedralSurface::buildAdjacency(steinerPoint* array) {

     // copy array with SteinerPoints to array with vertecies and check if actual
     // steinerPoint is already vertex of the graph or not

     vertex* v;
     v = new vertex[sizeof(array)];

     for (int i=0; i<sizeof(array); i++) {

        v[i].setIndex(array[i].ID);
	v[i].setX(array[i].x);
	v[i].setY(array[i].y);
	v[i].setZ(array[i].z);

        if (g.containsVertex(v[i]) == 0)
	 g.addVertex(v[i]);
     }

     // the following excerpt builds the part of the graph containing the vertices on
     // the edge AB of the given cell (triangle)

     g.addEdge(v[0],v[6]);
     g.addEdge(v[0],v[7]);
     g.addEdge(v[0],v[8]);
     g.addEdge(v[0],v[9]);
     g.addEdge(v[0],v[1]);
     g.addEdge(v[0],v[14]);

     g.addEdge(v[1],v[9]);
     g.addEdge(v[1],v[14]);
     g.addEdge(v[1],v[0]);
     g.addEdge(v[1],v[2]);

     g.addEdge(v[2],v[8]);
     g.addEdge(v[2],v[13]);
     g.addEdge(v[2],v[1]);
     g.addEdge(v[2],v[3]);

     g.addEdge(v[3],v[7]);
     g.addEdge(v[3],v[12]);
     g.addEdge(v[3],v[2]);
     g.addEdge(v[3],v[4]);

     g.addEdge(v[4],v[6]);
     g.addEdge(v[4],v[11]);
     g.addEdge(v[4],v[3]);
     g.addEdge(v[4],v[5]);

     // the following excerpt builds the part of the graph containing the vertices on
     // the edge BC of the given cell (triangle)

     g.addEdge(v[5],v[11]);
     g.addEdge(v[5],v[12]);
     g.addEdge(v[5],v[13]);
     g.addEdge(v[5],v[14]);
     g.addEdge(v[5],v[6]);
     g.addEdge(v[5],v[4]);

     g.addEdge(v[6],v[14]);
     g.addEdge(v[6],v[4]);
     g.addEdge(v[6],v[5]);
     g.addEdge(v[6],v[7]);

     g.addEdge(v[7],v[13]);
     g.addEdge(v[7],v[3]);
     g.addEdge(v[7],v[6]);
     g.addEdge(v[7],v[8]);

     g.addEdge(v[8],v[12]);
     g.addEdge(v[8],v[2]);
     g.addEdge(v[8],v[7]);
     g.addEdge(v[8],v[9]);

     g.addEdge(v[9],v[11]);
     g.addEdge(v[9],v[1]);
     g.addEdge(v[9],v[8]);
     g.addEdge(v[9],v[10]);

     // the following excerpt builds the part of the graph containing the vertices on
     // the edge CA of the given cell (triangle)

     g.addEdge(v[10],v[1]);
     g.addEdge(v[10],v[2]);
     g.addEdge(v[10],v[3]);
     g.addEdge(v[10],v[4]);
     g.addEdge(v[10],v[9]);
     g.addEdge(v[10],v[11]);

     g.addEdge(v[11],v[4]);
     g.addEdge(v[11],v[9]);
     g.addEdge(v[11],v[10]);
     g.addEdge(v[11],v[12]);

     g.addEdge(v[12],v[3]);
     g.addEdge(v[12],v[8]);
     g.addEdge(v[12],v[11]);
     g.addEdge(v[12],v[13]);

     g.addEdge(v[13],v[2]);
     g.addEdge(v[13],v[7]);
     g.addEdge(v[13],v[12]);
     g.addEdge(v[13],v[14]);

     g.addEdge(v[14],v[1]);
     g.addEdge(v[14],v[6]);
     g.addEdge(v[14],v[13]);
     g.addEdge(v[14],v[0]);

}
//***************************************************************************************************************************************

  void ShortestPathOnPolyhedralSurface::djikstra(vertex startpt, vertex endpt) {
	
		
      vertex* vert = g.getVerties();
      startpt.setDist(0);
      queue.push_back(startpt);

      for (int i=1; i<sizeof(vert); i++) {
         vert[i].setDist(-1);
	 queue.push_back(vert[i]);
      }
      while (queue.empty() == 0) {
         list<vertex>::iterator it;
	 it = queue.begin();
	 vertex u = *it;
	 queue.pop_front();
	 if (u.getIndex() == endpt.getIndex()) {
	   path.push_back(endpt);
	 }
         else {
           vertex* ver = g.getSuccessors(u);
           vertex  temp_vertex; 
	   for (int i=0; i<sizeof(ver); i++) {
	   flag = 0;
              if (u.getDist() > ver[i].getDist() + g.edgeWeight(u,ver[i])) {
                double temp_value = ver[i].getDist() + g.edgeWeight(u,ver[i]);
		u.setDist(temp_value);
		temp_vertex = ver[i];
		flag = 1;
	      }
	   }
	   if (flag == 1) 
	     path.push_back(temp_vertex);
	    
	 }

        }
  }

//***************************************************************************************************************************************

  vtkIdList ShortestPathOnPolyhedralSurface::computePath(vtkPolyData* mesh, double* startpoint, double* endpoint) {

		double **points;
       new graph(g);
       trianglestrip(startpoint, endpoint, mesh);
       steinerpoints(mesh);
       vertex startpt = g.getVertexWithCoord(startpoint[0], startpoint[1], startpoint[2]);
       vertex endpt   = g.getVertexWithCoord(endpoint[0]  , endpoint[1]  , endpoint[2]  );
       djikstra(startpt, endpt);

       for (int i=0; i<path.size(); i++) {
	     list<vertex>::iterator it;
	     it = path.begin();
	     vertex v= *it;
         path.pop_front();
	     points[i][0] = v.getX();
   	     points[i][1] = v.getY();
	     points[i][2] = v.getZ();
       }

}




-------------- next part --------------
// Graph.cpp
# include "Graph.h"
# include <list>

//***************************************************************************************************************************************

void vertex::setIndex(int ID) {

     this.Index = ID;

  }

int vertex::getIndex() {

     return this.Index;

  }

void vertex::setDist(double dist) {

     this.dist = dist;

  }

double vertex::getDist() {

     return this.dist;

  }

void vertex::setX(double x) {

     this.x = x;

  }

void vertex::setY(double y) {

     this.y = y;

  }

void vertex::setZ(double z) {

     this.z = z;

  }

double vertex::getX() {

     return this.x;

}

double vertex::getY() {

     return this.y;

}

double vertex::getZ() {

     return this.z;

}

//***************************************************************************************************************************************

/* void graph::graph(list<vertex> v_list) {

     laenge = v_list.size();

     for (int i=0; i<laenge; i++) {
         temp = v_list.pop_front();
	 verties.push_back(temp);
     }
     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
	 list.push_back(*verties_iterator);
	 edges.push_back(list);
	 list.pop_back();
     }
}   */
 
void graph::addVertex(vertex v) {

     verties.push_back(v);
     list.push_back(v);
     edges.push_back(list);
     list.pop_back();
}

void graph::deleteVertex(vertex v) {

     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
         if (*verties_iterator == v) {
	   verties.erase(verties_iterator);
	   edges_iterator = edges.begin();
           for (int i=0; i<verties.getIndex(v); i++) {
               edges_iterator++;
           }
           edges.erase(edges_iterator);
	 }
     }

}

vertex   graph::getVertexWithCoord(double x, double y, double z) {
         
     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
         if (*verties_iterator.getX() == x &&
             *verties_iterator.getY() == y &&
             *verties_iterator.getZ() == z) {
	     return *verties_iterator;
         }
     }
}         
          
vertex* graph::getVerties() {

     int i=0;
     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
         v[i] = *verties_iterator;
         i = i+1;
     }
     return v;
}

vertex* graph::getSuccessors(vertex v) {

     int j=0;    
     edges_iterator = edges.begin();
     for (int i=0; i<verties.getIndex(v); i++) {
        edges_iterator++;
     }
     for (list_iterator  = *edges_iterator.begin();
          list_iterator != *edges_iterator.end();
	  list_iterator++) {
            v[j] = *list_iterator;
	    j = j+1;
     }
     return v;
}

int  graph::getIDofVertexWithCoord(double x, double y, double z) {

     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
         if (*verties_iterator.getX() == x &&
             *verties_iterator.getY() == y &&
	     *verties_iterator.getZ() == z) {
	     return *verties_iterator.getIndex();
         }
         else {
             return -1;
         }
     }
}

void graph::addEdge(vertex u, vertex v) {

     if (this.containsEdge(vertex u, vertex v) == false) {
       edges_iterator = edges.begin();
       for (int i=0; i<verties.getIndex(u); i++) {
          edges_iterator++;
       }
       *edges_iterator.push_back(v);
     }
}

void graph::deleteEdge(vertex u, vertex v) {

     if (this.containsEdge(vertex u, vertex v) == true) {
       edges_iterator = edges.begin();
       for (int i=0; i<verties.getIndex(u); i++) {
          edges_iterator++;
       }
       for (list_iterator  = *edges_iterator.begin();
            list_iterator != *edges_iterator.end();
	    list_iterator++) {
	        if (*list_iterator == v) {
                 *edges_iterator.erase(list_iterator);
		 break;
		}
	  }
     }
}

bool graph::containsVertex(vertex v) {

     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verties_iterator++) {
        if (*verties_iterator == v)
	  return true;
     }
     return false;
}

bool  graph::containsVertexWithCoord(double x, double y, double z) {

     for (verties_iterator = verties.begin(); verties_iterator != verties.end(); verities_iterator++) {
         if (*verties_iterator.getX() == x &&
             *verties_iterator.getY() == y &&
	     *verties_iterator.getZ() == z) {
	     return true;
         }
     }
     return false;
}


bool graph::containsEdge(vertex u, vertex v) {

     edges_iterator = edges.begin();
     for (int i=0; i<verties.getIndex(u); i++) {
        edges_iterator++;
     }
     for (list_iterator  = *edges_iterator.begin();
          list_iterator != *edges_iterator.end();
	  list_iterator++) {
              if (*list_iterator == v)
              return true;
          }
     return false;
}

double graph::edgeWeight(vertex u, vertex v) {

     dist = sqrt(sqr(v.getX-u.getX) + sqr(v.getY-u.getY) + sqr(v.getZ-u.getZ));
     return dist;

}

//***************************************************************************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Graph.h
Type: text/x-c-header
Size: 1671 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061018/3b73fa8a/attachment-0001.bin>


More information about the vtkusers mailing list