Exemplo n.º 1
0
/**
 * PrintVertexNeighbors -- Print the neighbors of a vertex.
 *
 * @param imEnv is the compare environment
 * @param vertex is the vertex we looking at
 */
void
PrintVertexNeighbors(IMEnv * imEnv, Vertex * vertex) {
    register int i;

    switch (vertex->vertexType) {
        case DEVICE:
            for (i = 0; i < NumberOfLinksD(imEnv, vertex); i++)
                PrintVertex(imEnv, vertex->connects.netList[i]);
            break;

        case NET:
            for (i = 0; i < vertex->n.netConnects; i++)
                PrintVertex(imEnv, vertex->connects.devList[i].vertex);
    }
}
Exemplo n.º 2
0
/**
 * PrintVertices -- Print a vector of vertices.
 *
 * @param imEnv is the compare environment
 * @param vertices is the array of vertices we a printing
 * @param numVertices is the number of vertices in the array
 */
void
PrintVertices(IMEnv * imEnv, Vertex * vertices, int numVertices) {
    register int i;

    for (i = 0; i < numVertices; i++)
        PrintVertex(imEnv, &vertices[i]);
}
Exemplo n.º 3
0
/**
 * This can be called from within gdb after a crash:
 * (gdb) call ReportState()
 */
static void
LastPrim(void)
{
   int i;
   for (i = 0; i < Vcount; i++) {
      switch (Vbuffer[i].type) {
      case BEGIN:
         printf("glBegin(%d);\n", (int) Vbuffer[i].v[0]);
         break;
      case END:
         printf("glEnd();\n");
         break;
      case VERTEX2:
         PrintVertex("glVertex2f", Vbuffer + i, 2);
         break;
      case VERTEX3:
         PrintVertex("glVertex3f", Vbuffer + i, 3);
         break;
      case VERTEX4:
         PrintVertex("glVertex4f", Vbuffer + i, 4);
         break;
      case COLOR3:
         PrintVertex("glColor3f", Vbuffer + i, 3);
         break;
      case COLOR4:
         PrintVertex("glColor4f", Vbuffer + i, 4);
         break;
      case TEX2:
         PrintVertex("glTexCoord2f", Vbuffer + i, 2);
         break;
      case TEX3:
         PrintVertex("glTexCoord3f", Vbuffer + i, 3);
         break;
      case TEX4:
         PrintVertex("glTexCoord4f", Vbuffer + i, 4);
         break;
      case SECCOLOR3:
         PrintVertex("glSecondaryColor3f", Vbuffer + i, 3);
         break;
      case NORMAL3:
         PrintVertex("glNormal3f", Vbuffer + i, 3);
         break;
      default:
         abort();
      }
   }
}
Exemplo n.º 4
0
/**
 * PrintQueue -- Print out an entire Queue.
 *
 * @param imEnv is the compare environment
 * @param queue is the queue we are printing
 */
void
PrintQueue(IMEnv * imEnv, Queue * queue) {
    Vertex *vertexPt;

    for (vertexPt = queue->top; vertexPt != NULL; vertexPt = vertexPt->next) {
        PrintVertex(imEnv, vertexPt);
    }
}
Exemplo n.º 5
0
int main()
{
	//init vertex
	Vector3f v1 = Vector3f(0.3, 0.3, 0.3);
	Vector3f v2 = Vector3f(0.3, 0.3, 0.6);
	//print Vertex
	puts("Init Vertex");
	PrintVertex(v1); PrintVertex(v2);
	//set Camera
	myLookAt(Vector3f(0.0, 0.0, 2.0), Vector3f(0.0, 0.0, 0.0), Vector3f(0.0, 1.0, 0.0));
	
	//set Ortho
	myOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
	//print Vertex
	puts("Ortho");
	PrintVertex(DrawVertex(v1)); PrintVertex(DrawVertex(v2));
	
	//set Frustum
	myFrustum(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
	//print Vertex
	puts("Frustum");
	PrintVertex(DrawVertex(v1)); PrintVertex(DrawVertex(v2));

	getchar();
	return 0;
}
Exemplo n.º 6
0
void PrintInstance(Instance *instance, Graph *graph, LabelList *labelList)
{
   ULONG i;

   if (instance != NULL) 
   {
      for (i = 0; i < instance->numVertices; i++) 
      {
         printf("    ");
         PrintVertex(graph, instance->vertices[i], labelList);
      }
      for (i = 0; i < instance->numEdges; i++) 
      {
         printf("    ");
         PrintEdge(graph, instance->edges[i], labelList);
      }
   }
}
Exemplo n.º 7
0
void PrintGraph(Graph *graph, LabelList *labelList)
{
   ULONG v;
   ULONG e;

   if (graph != NULL) 
   {
      printf("  Graph(%luv,%lue):\n", graph->numVertices, graph->numEdges);
      // print vertices
      for (v = 0; v < graph->numVertices; v++) 
      {
         printf("    ");
         PrintVertex(graph, v, labelList);
      }
      // print edges
      for (e = 0; e < graph->numEdges; e++) 
      {
         printf("    ");
         PrintEdge(graph, e, labelList);
      }
   }
}
Exemplo n.º 8
0
void main()
{
   int Radius, Bands, i, j, LastIndex, BandsX2, LastBandStartIndex;
   int TopBandStartIndex, BottomBandStartIndex, FaceNum;
   struct Point3 BaseVec, BandVec, WorkingVec, TempVec;
   char OutputFilename[130];
   char Description[130];

   printf("Radius: ");
   scanf("%d",&Radius);
   printf("Bands: ");
   scanf("%d",&Bands);
   printf("Output file: ");
   OutputFilename[0] = 127;
   cgets(OutputFilename);
   printf("\nBrief description: ");
   Description[0] = 127;
   cgets(Description);
   printf("\n");

   BandsX2 = Bands*2;

   if ((OutputFile = fopen(&OutputFilename[2], "w")) == NULL) {
      printf("Error\n");
      exit(1);
   }

   /* Descriptive comments */
   fprintf(OutputFile, "/* %s */\n", &Description[2]);
   fprintf(OutputFile, "/* Created with radius = %d, bands = %d */\n",
         Radius, Bands);

   /* Defines for # of faces and vertices */
   fprintf(OutputFile, "#define NUM_FACES %d\n", BandsX2*Bands);
   fprintf(OutputFile, "#define NUM_VERTS %d\n\n",
         2+1+BandsX2*(Bands-1)+1+ (BandsX2*Bands));
   /* # of vertices excluding unit normal endpoints */
   fprintf(OutputFile, "#define NUM_REAL_VERTS %d\n\n",
         2+1+BandsX2*(Bands-1)+1);

   /* Do the polygon vertices */
   fprintf(OutputFile, "Point3 Verts[] = {\n");

	/* Generate the rotation matrices */
   AppendRotationY(YXform, PI / Bands);
   AppendRotationZ(ZXform, PI / Bands);

   /* Do the point at the top */
   BaseVec.X = 0.0;
   BaseVec.Y = Radius;
   BaseVec.Z = 0.0;
   BaseVec.W = 1.0;
   PrintVertex(&BaseVec);

   BandVec = BaseVec;

   /* Do the vertices in each band in turn */
   for (i=1; i<Bands; i++) {
      /* Rotate around Z to the next band's latitude */
      XformVec(ZXform, (double *)&BandVec, (double *)&TempVec);
      WorkingVec = BandVec = TempVec;
		/* Do the vertices in this band */
      for (j=0; j<BandsX2; j++) {
         WorkingVec = TempVec;
         PrintVertex(&WorkingVec);
         /* Now rotate around Y to the next vertex's longitude */
         XformVec(YXform, (double *)&WorkingVec, (double *)&TempVec);
      }
   }

   /* Do the point at the bottom */
   BaseVec.Y = -Radius;
   PrintVertex(&BaseVec);

   /* Now generate the unit normal endpoint for each face, as the last
      entries in the vertex list */
   /* Index in overall vertex list of first unit normal endpoint we'll
      create; remember where we can find it */
   FirstUnitNormalIndex = NumPoints;

   FaceNum = 0;

   /* Unit normal endpoints in top band */
   for (i=0; i<BandsX2; i++) {
      UnitNormal(&BaseVec, 0, ((i+1)%BandsX2)+1, i+1);
      PrintVertex(&BaseVec);
      FaceNum++;
   }

   /* Unit normal endpoints in middle bands */
   for (j=0; j<(Bands-2); j++) {
      TopBandStartIndex = j*BandsX2 + 1;
      BottomBandStartIndex = (j+1)*BandsX2 + 1;
		/* Indexes in this band */
      for (i=0; i<BandsX2; i++) {
         UnitNormal(&BaseVec, i+TopBandStartIndex,
               ((i+1)%BandsX2)+TopBandStartIndex,
               i+BottomBandStartIndex);
         PrintVertex(&BaseVec);
         FaceNum++;
      }
   }

   /* Unit normal endpoints in bottom band */
   LastIndex = BandsX2*(Bands-1)+1;
   LastBandStartIndex = BandsX2*(Bands-2)+1;
   for (i=0; i<BandsX2; i++) {
      UnitNormal(&BaseVec, LastBandStartIndex+i,
            LastBandStartIndex+((i+1)%BandsX2), LastIndex);
      PrintVertex(&BaseVec);
      FaceNum++;
   }

   /* Done generating points, including both polygon vertices and unit
      normals */
   fprintf(OutputFile, "};\n\n");


   /* Do the vertex indexes for each face in each band */
   FaceNum = 0;

   /* Vertex indexes in top band, with unit normal endpoint first */
   for (i=0; i<BandsX2; i++) {
      Print4Indexes(FaceNum++, FirstUnitNormalIndex++, 0,
            ((i+1)%BandsX2)+1, i+1);
   }

   /* Vertex indexes in middle bands, with unit normal endpoints first */
   for (j=0; j<(Bands-2); j++) {
      TopBandStartIndex = j*BandsX2 + 1;
      BottomBandStartIndex = (j+1)*BandsX2 + 1;
		/* Indexes in this band */
      for (i=0; i<BandsX2; i++) {
         Print5Indexes(FaceNum++, FirstUnitNormalIndex++,
               i+TopBandStartIndex,
               ((i+1)%BandsX2)+TopBandStartIndex,
               ((i+1)%BandsX2)+BottomBandStartIndex,
               i+BottomBandStartIndex);
      }
   }

   /* Vertex indexes in bottom band, with unit normal endpoint first */
   LastIndex = BandsX2*(Bands-1)+1;
   LastBandStartIndex = BandsX2*(Bands-2)+1;
   for (i=0; i<BandsX2; i++) {
      Print4Indexes(FaceNum++, FirstUnitNormalIndex++,
            LastBandStartIndex+i,
            LastBandStartIndex+((i+1)%BandsX2), LastIndex);
   }

   /* Do the list of pointers to index arrays for each face */
   fprintf(OutputFile, "\nstatic int *VertNumList[] = {\n");
   for (i=0; i<(BandsX2*Bands); i++) {
      fprintf(OutputFile, "Face%d,\n", i);
   }
   fprintf(OutputFile, "};\n");

   /* Do the # of vertices in each face (3 for the top and bottom
      bands, 4 for the rest) */
   fprintf(OutputFile, "\nstatic int VertsInFace[] = {\n");
   for (i=0; i<BandsX2; i++) fprintf(OutputFile, "3,\n");
   for (i=0; i<(BandsX2*(Bands-2)); i++) fprintf(OutputFile, "4,\n");
   for (i=0; i<BandsX2; i++) fprintf(OutputFile, "3,\n");
   fprintf(OutputFile, "};\n");

   exit(0);
}