int main(){
	
	
	printTriangle(4);
	printTriangle(8);
	return 0;
}
Exemplo n.º 2
0
void LodInputProvider::addTriangleToEdges(LodData* data, LodData::Triangle* triangle)
{
    if(MESHLOD_QUALITY >= 3) {
        LodData::Triangle* duplicate = isDuplicateTriangle(triangle);
        if (duplicate != NULL) {
#if OGRE_DEBUG_MODE
            stringstream str;
            str << "In " << data->mMeshName << " duplicate triangle found." << std::endl;
            str << "Triangle " << LodData::getVectorIDFromPointer(data->mTriangleList, triangle) << " positions:" << std::endl;
            printTriangle(triangle, str);
            str << "Triangle " << LodData::getVectorIDFromPointer(data->mTriangleList, duplicate) << " positions:" << std::endl;
            printTriangle(duplicate, str);
            str << "Triangle " << LodData::getVectorIDFromPointer(data->mTriangleList, triangle) << " will be excluded from Lod level calculations.";
            LogManager::getSingleton().stream() << str.str();
#endif
            triangle->isRemoved = true;
            data->mIndexBufferInfoList[triangle->submeshID].indexCount -= 3;
            return;
        }
    }
    for (int i = 0; i < 3; i++) {
        triangle->vertex[i]->triangles.addNotExists(triangle);
    }
    for (int i = 0; i < 3; i++) {
        for (int n = 0; n < 3; n++) {
            if (i != n) {
                triangle->vertex[i]->addEdge(LodData::Edge(triangle->vertex[n]));
            }
        }
    }
}
Exemplo n.º 3
0
int main() {
    
    // generate example data to work with. just 2 layers with a differently sloped line
    int n1 = 3;
    int n2 = 12;

    int l1[n1][2];
    int l2[n2][2];

    int i = 0;

    for(i=0; i<n1; i++) {
        l1[i][0] = i;
        l1[i][1] = i*2;
    }

    for(i=0; i<n2; i++) {
        l2[i][0] = i;
        l2[i][1] = i/2;
    }
    
    // do triangle generation
    int triangles[n1+n2][3][3];
    
    generateTriangles(triangles, l1, n1, 100, l2, n2, 101);

    // print results
    for(i=0; i<n1+n2; i++) {
        printTriangle(triangles[i]);
    }

    return 0;
}
Exemplo n.º 4
0
int main()
{
    char opt;
    int i,j;
    printMenu();
    scanf(" %c", &opt);
    while(opt != 'q') {
        switch (opt)
        {
        case 's' : printSquare();
                   break;
        case 't' : printTriangle();
                   break;
        default:   printf("Unknown option\n");
        }
        printMenu();
        scanf(" %c", &opt);
    }
    return 0;
}
Exemplo n.º 5
0
//
// Swap the common edge between two triangles t1 and t2. The common
// edge should always be edge ac, abc are part of t1 and acd are part
// of t2.
//
void edgeSwap(TRIANGLE *t1, TRIANGLE *t2, 
	      R_POINT *a, R_POINT *b, R_POINT *c, R_POINT *d,
	      double e, TIN_TILE *tt){

  // Common edge must be ac
  assert(isEndPoint(t1,a) && isEndPoint(t1,b) && isEndPoint(t1,c) && 
	 isEndPoint(t2,a) && isEndPoint(t2,c) && isEndPoint(t2,d));

  assert(a != b && a != c && a != d && b != c && b != d && c != d);

  assert(t1 != t2);
  
  // Add the two new triangles with the swapped edge 
  TRIANGLE *tn1, *tn2;
  tn1 = addTri(tt,a, b, d,whichTri(t1,a,b,tt),whichTri(t2,a,d,tt),NULL);
  tn2 = addTri(tt,c, b, d,whichTri(t1,c,b,tt),whichTri(t2,c,d,tt),tn1);
  
  assert(isEndPoint(tn1,a) && isEndPoint(tn1,b) && isEndPoint(tn1,d) && 
	 isEndPoint(tn2,b) && isEndPoint(tn2,c) && isEndPoint(tn2,d));

  assert(tn1->p2p3 == tn2 && tn2->p2p3 == tn1);

 
  if(tn1->p1p2 != NULL)
    assert(whichTri(tn1->p1p2,a,b,tt) == tn1);
  if(tn1->p1p3 != NULL)
    assert(whichTri(tn1->p1p3,a,d,tt) == tn1);
  if(tn2->p1p2 != NULL)
    assert(whichTri(tn2->p1p2,c,b,tt) == tn2);
  if(tn2->p1p3 != NULL)
    assert(whichTri(tn2->p1p3,c,d,tt) == tn2);

  // Debug
  DEBUG{
  printf("EdgeSwap: \n");
  printTriangle(t1);
  printTriangle(t2);
  printTriangle(tn1);
  printTriangle(tn2);
  } 

  // Distribute point list from t1 and t2 to tn1 and tn2. Distribute
  // points requires that the fourth argument (s) be a valid triangle
  // with a point list so we must check that t1 and t2 are not already
  // done and thus do not have a point list. If at least one does then
  // call distribute points with s = the trinagle with the valid point
  // list. If both are done then the newly created triangles are done
  // tooand need to be marked accordingly
  if(t1->maxE != DONE && t2->maxE != DONE)
    distrPoints(tn1,tn2,NULL,t1,t2,e,tt);
  else if(t1->maxE != DONE){
    distrPoints(tn1,tn2,NULL,t1,NULL,e,tt);
  }
  else if(t2->maxE != DONE){
    distrPoints(tn1,tn2,NULL,t2,NULL,e,tt);
  }
  else{
    tn1->maxE = tn2->maxE = DONE;
    tn1->points = tn2->points= NULL;
  }

  // Update the corner if the corner is being swapped. Distrpoints
  // will not always catch this so it must be done here
  if(t1 == tt->t || t2 == tt->t){
    updateTinTileCorner(tt,tn1,tn2,NULL);    
  }

  // mark triangles for deletion from the PQ
  t1->p1p2 = t1->p1p3 = t1->p2p3 = NULL;
  t2->p1p2 = t2->p1p3 = t2->p2p3 = NULL;
  PQ_delete(tt->pq,t1->pqIndex);
  PQ_delete(tt->pq,t2->pqIndex);
  removeTri(t1);
  removeTri(t2);

  DEBUG{checkPointList(tn1); checkPointList(tn2);}

  // We have created two different triangles, we need to check
  // delaunay on their 2 edges
  enforceDelaunay(tn1,a,d,b,e,tt);
  enforceDelaunay(tn2,c,d,b,e,tt);

}