Exemple #1
0
void append_the_edge_mates(Tfragment frags[],
                           Tedge edges[]) {

  // Scan the current edges to find un-mated edges.  For each un-mated
  // edge, append the mate edge to the edge array.

  IntEdge_ID
    ie0,
    nedge = GetNumEdges(edges),
    nedge_delta = 0;
  fprintf(stderr,"append_the_edge_mates: nedge="F_IID "\n", nedge);

  verify_that_the_edges_are_in_order(edges);

  for( ie0=0; ie0 < nedge; ie0++) {
    const IntEdge_ID ie1 = find_overlap_edge_mate( frags, edges, ie0);
    if( AS_CGB_EDGE_NOT_FOUND == ie1 ) {
      IntEdge_ID ie2 = nedge+nedge_delta;
      // fprintf(stderr,"nedge_delta="F_IID "\n", nedge_delta);
      EnableRangeVA_Aedge(edges,ie2+1);
      fill_new_edge_with_reflected_old_edge( edges, ie2, ie0);
      nedge_delta ++;
    }
  }

  reorder_edges( frags, edges);
}
Exemple #2
0
void
verify_that_the_edges_are_in_order(Tedge edges[]) {
  IntEdge_ID ie0 = 0, nedge = GetNumEdges(edges);

  for (ie0=0; ie0 < nedge-1; ie0++) {
    int icompare = compare_edge_function(GetVA_Aedge(edges,ie0),GetVA_Aedge(edges,ie0+1));
    assert(icompare <= 0);
  }
}
Exemple #3
0
//  BPW -- this really doesn't have anything to do with "edgemate" but
//  it's commonly called with check_symmetry_of_the_edge_mates(), and
//  they're both disabled.
//
void count_fragment_and_edge_labels(Tfragment frags[],
                                    Tedge     edges[],
                                    char      comment[]) {
  FILE *fout = stderr;

  fprintf(stderr, "count_fragment_and_edge_labels()--  Disabled.\n");
  return;

  const int nsample=500;
  const int nbucket=500;

  IntFragment_ID nfrag = GetNumFragments(frags);
  IntFragment_ID vid;
  Histogram_t *frag_lab_histogram = create_histogram(nsample,nbucket,TRUE,FALSE);

  fprintf(fout,"*** Histogram Fragment Labels <%s> ***\n",comment);

  for(vid=0; vid<nfrag; vid++) {
    const Tlab ilab = get_lab_fragment(frags,vid);
    add_to_histogram(frag_lab_histogram, (int)ilab, NULL);
  }

  fprintf(fout,"Histogram of the fragment label \n");
  print_histogram(fout,frag_lab_histogram, 0, 1);
  free_histogram(frag_lab_histogram);

  IntEdge_ID ie;
  IntEdge_ID nedge = GetNumEdges(edges);
  Histogram_t *inter_chunk_edge_nes_histogram = create_histogram(nsample,nbucket,TRUE,FALSE);
  Histogram_t *intra_chunk_edge_nes_histogram = create_histogram(nsample,nbucket,TRUE,FALSE);

  fprintf(fout,
          "*** Histogram Edge Labels (2 edges/overlap) <%s> ***\n",
          comment);

  for(ie=0; ie<nedge; ie++) {
    const Tnes nes = get_nes_edge(edges,ie);
    const IntFragment_ID avx = get_avx_edge(edges,ie);
    const IntFragment_ID bvx = get_bvx_edge(edges,ie);
    const IntChunk_ID a_cid = get_cid_fragment(frags,avx);
    const IntChunk_ID b_cid = get_cid_fragment(frags,bvx);
    if( a_cid == b_cid ) {
      add_to_histogram(intra_chunk_edge_nes_histogram, (int)nes, NULL);
    } else {
      add_to_histogram(inter_chunk_edge_nes_histogram, (int)nes, NULL);
    }
  }

  fprintf(fout,"Histogram of the inter-chunk overlap labels \n");
  print_histogram(fout,inter_chunk_edge_nes_histogram, 0, 1);
  free_histogram(inter_chunk_edge_nes_histogram);

  fprintf(fout,"Histogram of the intra-chunk overlap labels \n");
  print_histogram(fout,intra_chunk_edge_nes_histogram, 0, 1);
  free_histogram(intra_chunk_edge_nes_histogram);
}
Exemple #4
0
void SkpModel::print_all_counts(){
	
	std::cout << "Definitions: " << GetNumDefinitions() << "\n";
	std::cout << "Instances: "   << GetNumInstances()   << "\n";
	std::cout << "Groups: "      << GetNumGroups()      << "\n";
	std::cout << "Faces: "       << GetNumFaces()       << "\n";
	std::cout << "Images: "      << GetNumImages()      << "\n";
	std::cout << "Edges: "       << GetNumEdges()       << "\n";
	std::cout << "Guides: "      << GetNumGuides()      << "\n";
	std::cout << "Curves: "      << GetNumCurves()      << "\n";

}
void as_graph_traversal
(
 FILE *    fout,
 Tfragment frags[],
 Tedge     edges[],
 size_t    fragment_rank[]
 )
{ /* A marked traversal of the graph. */
  size_t  nconnected=0,nfound=0,ncontained=0,ncircl=0;
  IntFragment_ID ivi;

  const IntFragment_ID nfrag = GetNumFragments(frags);
  const IntEdge_ID nedge = GetNumEdges(edges);

  for(ivi=0; ivi<nfrag; ivi++) {
    fragment_rank[ivi] = NOT_RANKED;
  }
  for(ivi=0;ivi<nfrag;ivi++) {
    if(fragment_rank[ivi] == NOT_RANKED){
	nconnected++;
	as_bfs
	  (ivi, &nfound,
	   nfrag, frags,
	   nedge, edges,
	   fragment_rank
	   );
    }
  }

  for(ivi=0;ivi<nfrag;ivi++) {
    assert(fragment_rank[ivi] != NOT_RANKED);
    //ncircl++;
    //nfound++;
  }
  fprintf(fout,"FRAGMENT OVERLAP GRAPH TRAVERSAL STATISTICS\n\n"
	  "%15"F_IIDP " : number of fragments in overlap graph\n"
	  "%15" F_SIZE_TP " : number of fragments found by breadth first search\n"
	  "%15" F_SIZE_TP " : number of weakly connected graph components\n"
	  "%15" F_SIZE_TP " : number of contained fragments\n"
	  "%15" F_SIZE_TP " : number of circular chunks\n\n\n",
	  nfrag,nfound,nconnected,ncontained,ncircl);
  assert( nfound == nfrag );

  /*
     Some of the search_method()s assume that circular chunks do not occur.
     If this assert ever fails than look for fragments with
     get_lab_fragment() == AS_CGB_INTRACHUNK_FRAG, but have not been visited.
  */
}
Exemple #6
0
/* Performs a topological sort of the fragment graph.  The output is an array
   of fragment IDs in topological order, pointed to by the out parameter (which
   is assumed to point to sufficient pre-allocated space).  Only those
   fragments and edges which are marked as VALID are used.

   The return value is the number of elements placed in topological order.
   If the graph is found to be cyclic, 0 is returned instead.
*/
IntFragment_ID
AS_CGB_Bubble_topo_sort(BubGraph_t bg, IntFragment_ID *out)
{
  IntFragment_ID q_start = 0, q_end = 0, f, opp_f, num_valid = 0;
  IntEdge_ID e;
  uint16 valid_and_unused = AS_CGB_BUBBLE_E_VALID | AS_CGB_BUBBLE_E_UNUSED;
  BG_E_Iter e_it;

  for (e = 0; e < GetNumEdges(BG_edges(bg)); ++e)
    if (BG_E_isSetFlag(bg, e, AS_CGB_BUBBLE_E_VALID)) {
      num_valid++;
      BG_E_setFlag(bg, e, AS_CGB_BUBBLE_E_UNUSED);
    }

  //fprintf(stderr, "  * Found "F_IID " valid edges.\n", num_valid);

  num_valid = 0;
  for (f = 0; f < GetNumFragments(BG_vertices(bg)); ++f)
    if (BG_V_isSetFlag(bg, f, AS_CGB_BUBBLE_V_VALID)) {
      num_valid++;
      if (BG_inDegree(bg, f, valid_and_unused) == 0)
	out[q_end++] = f;
    }

  //fprintf(stderr, "  * Found "F_IID " valid vertices.\n", num_valid);

  while (q_start < q_end) {
    for (e = BGEI_bgn(bg, &e_it, out[q_start], bgeiOut, valid_and_unused);
	 !BGEI_end(&e_it);
	 e = BGEI_next(bg, &e_it, valid_and_unused)) {
      opp_f = BG_getOppositeVertex(bg, e, out[q_start]);
      BG_E_clearFlagSymmetric(bg, e, AS_CGB_BUBBLE_E_UNUSED);
      if (BG_inDegree(bg, opp_f, valid_and_unused) == 0)
	out[q_end++] = opp_f;
    }
    q_start++;
  }

  if (q_end < num_valid) {
    //fprintf(stderr, "  * WARNING: Only processed "F_IID " of "F_IID " vertices!  Cyclic graph!\n", q_end, num_valid);
    return 0;
  }

  return num_valid;
}
Exemple #7
0
IntEdge_ID check_symmetry_of_the_edge_mates(Tfragment frags[],
                                            Tedge edges[]) {

  //  This was diagnostic code, used all over the place, but never did much.
  fprintf(stderr, "check_symmetry_of_the_edge_mates()--  Disabled.  (Was a NOP anyway)\n");
  return(0);

  IntEdge_ID
    ie0,
    nedge = GetNumEdges(edges),
    counter = 0;

  verify_that_the_edges_are_in_order(edges);

  for( ie0=0; ie0 < nedge; ie0++) {
    const IntEdge_ID ie1 = find_overlap_edge_mate( frags, edges, ie0);
    if( AS_CGB_EDGE_NOT_FOUND == ie1 )
      counter ++;
  }
  fprintf(stderr,"check_symmetry_of_the_edge_mates: nedge="F_IID " counter="F_IID "\n",
          nedge, counter);
  return counter;
}
/*! Proceeds to check if the mesh is valid. All indices are inspected and
 * checked to see that they are initialized. The method checks: mEdges, mFaces and mVerts.
 * Also checks to see if all verts have a neighborhood using the findNeighbourFaces method.
 */
void HalfEdgeMesh::Validate()
{
  std::vector<HalfEdge>::iterator iterEdge = mEdges.begin();
  std::vector<HalfEdge>::iterator iterEdgeEnd = mEdges.end();
  while (iterEdge != iterEdgeEnd) {
    if ((*iterEdge).face == UNINITIALIZED ||
        (*iterEdge).next == UNINITIALIZED ||
        (*iterEdge).pair == UNINITIALIZED ||
        (*iterEdge).prev == UNINITIALIZED ||
        (*iterEdge).vert == UNINITIALIZED)
        std::cerr << "HalfEdge " << iterEdge - mEdges.begin() << " not properly initialized" << std::endl;

    iterEdge++;
  }
  std::cerr << "Done with edge check (checked " << GetNumEdges() << " edges)" << std::endl;

  std::vector<Face>::iterator iterTri = mFaces.begin();
  std::vector<Face>::iterator iterTriEnd = mFaces.end();
  while (iterTri != iterTriEnd) {
    if ((*iterTri).edge == UNINITIALIZED)
        std::cerr << "Tri " << iterTri - mFaces.begin() << " not properly initialized" << std::endl;

    iterTri++;
  }
  std::cerr << "Done with face check (checked " << GetNumFaces() << " faces)" << std::endl;

  std::vector<Vertex>::iterator iterVertex = mVerts.begin();
  std::vector<Vertex>::iterator iterVertexEnd = mVerts.end();
  while (iterVertex != iterVertexEnd) {
    if ((*iterVertex).edge == UNINITIALIZED)
        std::cerr << "Vertex " << iterVertex - mVerts.begin() << " not properly initialized" << std::endl;

    iterVertex++;
  }
  std::cerr << "Done with vertex check (checked " << GetNumVerts() << " vertices)" << std::endl;

  std::cerr << "Looping through triangle neighborhood of each vertex... ";
  iterVertex = mVerts.begin();
  iterVertexEnd = mVerts.end();
  int emptyCount = 0;
  std::vector<unsigned int> problemVerts;
  while (iterVertex != iterVertexEnd) {
    std::vector<unsigned int> foundFaces = FindNeighborFaces(iterVertex - mVerts.begin());
    std::vector<unsigned int> foundVerts = FindNeighborVertices(iterVertex - mVerts.begin());
    if (foundFaces.empty() || foundVerts.empty())
      emptyCount++;
    std::set<unsigned int> uniqueFaces(foundFaces.begin(), foundFaces.end());
    std::set<unsigned int> uniqueVerts(foundVerts.begin(), foundVerts.end());
        if ( foundFaces.size() != uniqueFaces.size() ||
         foundVerts.size() != uniqueVerts.size() )
      problemVerts.push_back(iterVertex - mVerts.begin());
    iterVertex++;
  }
  std::cerr << std::endl << "Done: " << emptyCount << " isolated vertices found" << std::endl;
  if(problemVerts.size()){
    std::cerr << std::endl << "Found " << problemVerts.size() << " duplicate faces in vertices: ";
    std::copy(problemVerts.begin(), problemVerts.end(), std::ostream_iterator<unsigned int>(std::cerr, ", "));
    std::cerr << "\n";
  }
  std::cerr << std::endl << "The mesh has genus " << Genus() << ", and consists of " << Shells() << " shells.\n";
}
Exemple #9
0
IntEdge_ID find_overlap_edge_mate
(/* Input Only */
 Tfragment frags[],
 Tedge edges[],
 IntEdge_ID ie0
 )
{
  // Find the other directed edge of the overlap and return the index.
  // Assert if the edge is not found.

  // This binary search version assumes that the edges are sorted with
  // respect to the compare_edge() function, and that all duplicate
  // edges with respect to the compare_edge() function have been
  // removed.

  const IntEdge_ID nedge = GetNumEdges(edges);

  IntEdge_ID mate_edge = nedge;
  Aedge test_edge = *(GetVA_Aedge(edges,ie0));
  // For the uninitialized variable finder "man third".
  // I have cheated the accessor function rule here.

  assert(0 <= ie0);
  assert(ie0 < nedge);

  reflect_Aedge( &test_edge, &test_edge);

  {
    IntEdge_ID ie1
      = get_segstart_vertex(frags,test_edge.avx,test_edge.asx);
    IntEdge_ID ie3 = ie1
      + get_seglen_vertex(frags,test_edge.avx,test_edge.asx);
    IntEdge_ID ie2 = ie1;

    if(ie3 == ie1 ) { return AS_CGB_EDGE_NOT_FOUND;}
    // Empty edge segment.

    assert( ie1 < ie3);

    for(; (ie1 < ie3); ) {
      int icompare;

      ie2 = (ie1 + ie3)/2;

      Aedge *curr_edge = GetVA_Aedge(edges,ie2);

      icompare = compare_edge_function(curr_edge, &test_edge);

      if( icompare == 0 ) {
	// Found the other half of the undirected edge?
	// const Tnes nes2 = get_nes_edge(edges,ie2);
        // found = (nes2 == nes0);
        mate_edge = ie2;
        goto escape;
      }

      assert((icompare!=0)&&(ie1 < ie3));
      if(icompare > 0) {
	ie3 = ie2;
      }
      if(icompare < 0) {
	ie1 = ie2+1;
      }

    }
  }
  mate_edge = AS_CGB_EDGE_NOT_FOUND;
 escape: ; // The edge is found...
  return mate_edge;
}