コード例 #1
0
ファイル: edge.c プロジェクト: MicBosi/GTS
/**
 * gts_edge_is_contact:
 * @e: a #GtsEdge.
 *
 * Returns: the number of sets of connected triangles sharing @e as a
 * contact edge.
 */
guint gts_edge_is_contact (GtsEdge * e)
{
    GSList * i, * triangles;
    guint ncomponent = 0;

    g_return_val_if_fail (e != NULL, 0);

    triangles = gts_vertex_triangles (GTS_SEGMENT (e)->v1, NULL);
    i = triangles = gts_vertex_triangles (GTS_SEGMENT (e)->v2, triangles);
    while (i) {
        GTS_OBJECT (i->data)->reserved = i;
        i = i->next;
    }

    i = e->triangles;
    while (i) {
        GtsTriangle * t = i->data;
        if (GTS_OBJECT (t)->reserved) {
            GtsEdge * e1;
            GTS_OBJECT (t)->reserved = NULL;
            e1 = next_edge (t, NULL, e);
            triangle_next (e1, e);
            triangle_next (next_edge (t, e1, e), e);
            ncomponent++;
        }
        i = i->next;
    }

    g_slist_foreach (triangles, (GFunc) gts_object_reset_reserved, NULL);
    g_slist_free (triangles);

    return ncomponent;
}
コード例 #2
0
ファイル: edge_strip.C プロジェクト: ArnaudGastinel/jot-lib
void
EdgeStrip::build(Bvert* v, Bedge* e, CSimplexFilter& filter)
{
   // continue building the edge strip, starting with the
   // given edge e. if v is not null, e must contain v.
   // in that case v will be the leading vertex of the strip.

   // must have an edge to proceed,
   // and the edge must be accepted by the filter.
   if (!(e && filter.accept(e))) // someone has to punch its ticket
      return;

   assert(!v || e->contains(v));

   static Bvert_list stack(64);
   stack.clear();

   // first loop:
   build_line_strip(v ? v : e->v1(), e, filter, stack);

   // get the rest of them
   while (!stack.empty()) {
      if ((v = stack.pop()) && (e = next_edge(v, stack, filter))) 
         build_line_strip(v, e, filter, stack);
   }
}
コード例 #3
0
ファイル: cutgraph.c プロジェクト: PauloMigAlmeida/cuneiform
void find_path()
//
//  This procedure find lowermost path from left border to right one.
//  If it fails, it means so-called "S"-case that will be treated specially.
//
{
	int16_t n, l, l0, v;
	uchar svpath[MAX_LINES];
	int16_t svpathl, svpatot;

	Z = &string;
	svpatot = -1;
	S_flag = 0;
	memset(path, 0, sizeof(path)); // first line is the beginning

	path_lth = 1;
	l0 = verts[0].bot;
	svpath[0] = 0;
	svpathl = 1;

	while (1) {
		if ((n = next_edge()) > 0) {
			l = verts[n].bot;
			path[path_lth++] = (uchar) n;
			if ((l - l0) > svpatot) // save longest path
			{
				svpatot = l - l0;
				for (v = 0; v < path_lth; v++)
					svpath[v] = path[v];
				svpathl = path_lth;
			}
			if (l == t_height)
				break;
			continue;
		}

		/*
		 if (verts[path[path_lth-1]].in > 1)            // "S"-case
		 flag=1;
		 */
		path[path_lth--] = 0;
		if (path_lth >= 1) // ****** >= 0 ??
			continue; // backtracking
		S_flag = 1;
		break;
	}
	//  if (S_flag)
	{
		for (l = 0; l < svpathl; l++)
			path[l] = svpath[l];
		path_lth = svpathl;
	}
}
コード例 #4
0
ファイル: edge.c プロジェクト: MicBosi/GTS
static void triangle_next (GtsEdge * e1, GtsEdge * e)
{
    GSList * i;

    i = e1->triangles;
    while (i) {
        GtsTriangle * t = i->data;
        if (GTS_OBJECT (t)->reserved) {
            GTS_OBJECT (t)->reserved = NULL;
            triangle_next (next_edge (t, e1, e), e);
        }
        i = i->next;
    }
}
コード例 #5
0
ファイル: edge_strip.C プロジェクト: ArnaudGastinel/jot-lib
void
EdgeStrip::build_line_strip(
   Bvert*          v,           // leading vertex
   Bedge*          e,           // contains v, satisfied filter
   CSimplexFilter& filter,      // selects desired edges
   Bvert_list&     stack        // vertices to check later
   )
{
   // Run a strip from v thru e and continuing on to other edges
   // accepted by the filter. Incompletely explored vertices are
   // pushed on the stack so they can be revisited another time.
   //
   // Note: e has already satisfied the filter, and e contains v.

   assert(e && e->contains(v));

   while (e) {
      add(v,e);
      e = next_edge(v = e->other_vertex(v), stack, filter);
   }
}
コード例 #6
0
ファイル: planar_face_traversal.hpp プロジェクト: 8573/anura
  void planar_face_traversal(const Graph& g, 
                             PlanarEmbedding embedding, 
                             Visitor& visitor, EdgeIndexMap em
                             )
  {
    typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
    typedef typename graph_traits<Graph>::edge_descriptor edge_t;
    typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator_t;
    typedef typename graph_traits<Graph>::edge_iterator edge_iterator_t;
    typedef typename 
      property_traits<PlanarEmbedding>::value_type embedding_value_t;
    typedef typename embedding_value_t::const_iterator embedding_iterator_t;

    typedef typename 
      std::vector< std::set<vertex_t> > distinguished_edge_storage_t;
    typedef typename 
      std::vector< std::map<vertex_t, edge_t> > 
      distinguished_edge_to_edge_storage_t;

    typedef typename 
      boost::iterator_property_map
        <typename distinguished_edge_storage_t::iterator, EdgeIndexMap>
      distinguished_edge_map_t;

    typedef typename 
      boost::iterator_property_map
        <typename distinguished_edge_to_edge_storage_t::iterator, EdgeIndexMap>
      distinguished_edge_to_edge_map_t;

    distinguished_edge_storage_t visited_vector(num_edges(g));
    distinguished_edge_to_edge_storage_t next_edge_vector(num_edges(g));

    distinguished_edge_map_t visited(visited_vector.begin(), em);
    distinguished_edge_to_edge_map_t next_edge(next_edge_vector.begin(), em);

    vertex_iterator_t vi, vi_end;
    typename std::vector<edge_t>::iterator ei, ei_end;
    edge_iterator_t fi, fi_end;
    embedding_iterator_t pi, pi_begin, pi_end;

    visitor.begin_traversal();

    // Initialize the next_edge property map. This map is initialized from the
    // PlanarEmbedding so that get(next_edge, e)[v] is the edge that comes
    // after e in the clockwise embedding around vertex v.

    for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
      {
        vertex_t v(*vi);
        pi_begin = embedding[v].begin();
        pi_end = embedding[v].end();
        for(pi = pi_begin; pi != pi_end; ++pi)
          {
            edge_t e(*pi);
            std::map<vertex_t, edge_t> m = get(next_edge, e);
            m[v] = boost::next(pi) == pi_end ? *pi_begin : *boost::next(pi);
            put(next_edge, e, m);
          } 
      }

    // Take a copy of the edges in the graph here, since we want to accomodate
    // face traversals that add edges to the graph (for triangulation, in 
    // particular) and don't want to use invalidated edge iterators.
    // Also, while iterating over all edges in the graph, we single out
    // any self-loops, which need some special treatment in the face traversal.

    std::vector<edge_t> self_loops;
    std::vector<edge_t> edges_cache;
    std::vector<vertex_t> vertices_in_edge;

    for(boost::tie(fi,fi_end) = edges(g); fi != fi_end; ++fi)
      {
        edge_t e(*fi);
        edges_cache.push_back(e);
        if (source(e,g) == target(e,g))
          self_loops.push_back(e);
      }


    // Iterate over all edges in the graph
    ei_end = edges_cache.end();
    for(ei = edges_cache.begin(); ei != ei_end; ++ei)
      {

        edge_t e(*ei);
        vertices_in_edge.clear();
        vertices_in_edge.push_back(source(e,g));
        vertices_in_edge.push_back(target(e,g));

        typename std::vector<vertex_t>::iterator vi, vi_end;
        vi_end = vertices_in_edge.end();
        
        //Iterate over both vertices in the current edge
        for(vi = vertices_in_edge.begin(); vi != vi_end; ++vi)
          {

            vertex_t v(*vi);
            std::set<vertex_t> e_visited = get(visited, e);
            typename std::set<vertex_t>::iterator e_visited_found 
              = e_visited.find(v);
            
            if (e_visited_found == e_visited.end())
              visitor.begin_face();
            
            while (e_visited.find(v) == e_visited.end())
              {
                visitor.next_vertex(v);
                visitor.next_edge(e);
                e_visited.insert(v);
                put(visited, e, e_visited);
                v = source(e,g) == v ? target(e,g) : source(e,g);
                e = get(next_edge, e)[v];
                e_visited = get(visited, e);
              }
            
            if (e_visited_found == e_visited.end())
              visitor.end_face();
            
          }

      }

    // Iterate over all self-loops, visiting them once separately
    // (they've already been visited once, this visitation is for
    // the "inside" of the self-loop)
    
    ei_end = self_loops.end();
    for(ei = self_loops.begin(); ei != ei_end; ++ei)
      {
        visitor.begin_face();
        visitor.next_edge(*ei);
        visitor.next_vertex(source(*ei,g));
        visitor.end_face();
      }

    visitor.end_traversal();

  }
コード例 #7
0
ファイル: ChollaCurve.cpp プロジェクト: chrismullins/cgma
//=============================================================================
//Function:  feature_angle (PRIVATE)
//Description: compute angles at nodes on the curve to see if we need to split
//             the curve.  Mark the node tooldata hitflag if the node will
//             break the curve (this is refernced in next_edge)
//Author: sjowen
//Date: 12/4/00
//=============================================================================
CubitStatus ChollaCurve::feature_angle(
  double min_dot )
{
  // first compute all of the edge vector and store with the edge tooldata

  int ii, jj;
  FacetEntity *facet_ptr;
  CubitFacetEdge *edge_ptr;
  CubitPoint *start_node;
  CubitPoint *end_node;
  CubitVector tangent;
  TDGeomFacet *td_gm;
  for (ii=0; ii<curveEdgeList.size(); ii++)
  {

    // compute the tangent vector of the edge and store it with its tooldata

    facet_ptr = curveEdgeList.get_and_step();
    edge_ptr = CAST_TO( facet_ptr, CubitFacetEdge );
    start_node = edge_ptr->point(0);
    end_node = edge_ptr->point(1);
    tangent = end_node->coordinates() - start_node->coordinates();
    tangent.normalize();
    td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
    td_gm->set_normal( tangent );

    // initialize the nodes tooldata hit flags - set them all to -1

    td_gm = TDGeomFacet::get_geom_facet(start_node);
    td_gm->set_hit_flag(-1);
    td_gm = TDGeomFacet::get_geom_facet(end_node);
    td_gm->set_hit_flag(-1);
  }

  // now go through them again and compute the dot product between edges

  CubitVector tang0;
  CubitVector tang1;
  double dot;
  CubitPoint *node_ptr;
  CubitFacetEdge *next_edge_ptr;
  TDGeomFacet *td_gm_node;

  for (ii=0; ii<curveEdgeList.size(); ii++)
  {
    facet_ptr = curveEdgeList.get_and_step();
    edge_ptr = CAST_TO( facet_ptr, CubitFacetEdge );
    start_node = edge_ptr->point(0);
    end_node = edge_ptr->point(1);
    for (jj=0; jj<2; jj++)
    {
      node_ptr = (jj==0) ? start_node : end_node;
      td_gm_node = TDGeomFacet::get_geom_facet( node_ptr );
      if (td_gm_node->get_hit_flag() == -1)
      {
        next_edge_ptr = next_edge( node_ptr, edge_ptr );
        if (next_edge_ptr == NULL)
        {
          td_gm_node->set_hit_flag( 1 );
          node_ptr->set_as_feature();
        }
        else
        {
          td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
          tang0 = td_gm->get_normal();
          td_gm = TDGeomFacet::get_geom_facet( next_edge_ptr );
          tang1 = td_gm->get_normal();

          // change the sign of the tangent vectors if the
          // sense of the edges are not the same

          if (node_ptr == start_node)
          {
            if (node_ptr != next_edge_ptr->point(1))
              tang0 = -tang0;
          }
          else
          {
            if (node_ptr != next_edge_ptr->point(0))
              tang0 = -tang0;
          }

          // compute the dot product between tangemt vectors

          dot = tang0 % tang1;

          // set the hit flag if there needs to be a feature break here

          if (dot <= min_dot)
          {
            td_gm_node->set_hit_flag( 1 );
            node_ptr->set_as_feature();
          }
          else
          {
            td_gm_node->set_hit_flag( 0 );
          }
        }
      }
    }
  }
  return CUBIT_SUCCESS;
}
コード例 #8
0
ファイル: ChollaCurve.cpp プロジェクト: chrismullins/cgma
//=============================================================================
//Function:  split_curve (PRIVATE)
//Description: split this curve into multiple ChollaCurve where there are
//             discontinuous strings of edges.  Define start and end nodes
//             for each curve while we are at it
//Author: sjowen
//Date: 12/4/00
//=============================================================================
CubitStatus ChollaCurve::split_curve(
  DLIList<ChollaCurve*> &facet_curve_list)
{
  DLIList<ChollaCurve*> new_curve_list;

  // Go through the curveEdgeList and pull edges off one by one as we
  // determine which curve it belongs to.  Continue until we have depleted
  // the list

  int periodic = 0;
  int start_size = curveEdgeList.size();
  int icount = 0;

  curveEdgeList.reset();
  while( curveEdgeList.size() > 0)
  {

    // First, find an edge that has a start point on it

    CubitFacetEdge *start_edge_ptr = (CubitFacetEdge *)curveEdgeList.get_and_step();
    CubitPoint *point0_ptr = start_edge_ptr->point(0);
    CubitPoint *point1_ptr = start_edge_ptr->point(1);
    CubitPoint *start_point = NULL;
    if (periodic)
    {
      start_point = startPoint;
    }
    else
    {
      if (next_edge( point0_ptr, start_edge_ptr ) == NULL)
        start_point = point0_ptr;
      else if(next_edge( point1_ptr, start_edge_ptr ) == NULL)
        start_point = point1_ptr;
    }
    if (start_point != NULL || periodic)
    {

      // create a new curve to hold the edge info

      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(start_edge_ptr);
      int block_id = (td_gm_edge == NULL) ? -1 : td_gm_edge->get_block_id();
      ChollaCurve *fcm_ptr = new ChollaCurve( block_id );
      new_curve_list.append( fcm_ptr );
      
      // assign the edges to the new curve in the correct order and orientation
      
      CubitStatus rv = fcm_ptr->build_curve_from_edges( start_point,  periodic, start_size, start_edge_ptr, this );
      if (rv != CUBIT_SUCCESS)
        return rv;
      
      // remove the edges in the new curve from this curve
      
      int ii;
      DLIList<FacetEntity *> flist = fcm_ptr->get_facet_list();
      DLIList<CubitFacetEdge *> elist;
      CubitFacetEdge *edge_ptr;
      CAST_LIST( flist, elist, CubitFacetEdge );
      for ( ii = elist.size(); ii > 0; ii-- ) 
      {
        edge_ptr = elist.get_and_step();
        curveEdgeList.remove( edge_ptr );
      }
      start_size = curveEdgeList.size();
      icount = 0;
      periodic = 0;
    }

    // if we have gone through all of the edges without finding an end,
    // then we have a periodic curve.  Choose an arbirary node to act as
    // the beginning and end

    if (curveEdgeList.size() > 0)
    {
      icount++;
      if (icount > start_size)
      {
        curveEdgeList.reset();
        CubitFacetEdge *edge = (CubitFacetEdge *)curveEdgeList.get();
        CubitPoint *point_ptr = edge->point(0);
        startPoint = point_ptr;
        endPoint = point_ptr;
        periodic = 1;
      }
    }
  }

  // add the new curves to the global curve list

  int ii, jj;
  for (ii=new_curve_list.size(); ii>0; ii--)
  {
    ChollaCurve *fcm_ptr = new_curve_list.get_and_step();

    facet_curve_list.append( fcm_ptr );

    // update the surface info

    for (jj=surfaceList.size(); jj>0; jj--)
    {
      ChollaSurface *fsm_ptr = surfaceList.get_and_step();
      fcm_ptr->add_surface( fsm_ptr );
      fsm_ptr->remove_curve( this );
      fsm_ptr->add_curve( fcm_ptr );
    }

    // update the geometric curve pointer

    fcm_ptr->assign_geometric_curve( NULL );

    // update the curve pointers in the edge tool data

    DLIList<FacetEntity*> facet_list = fcm_ptr->get_facet_list();
    for (jj=facet_list.size(); jj > 0; jj--)
    {
      FacetEntity *edge_ptr = facet_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      td_gm_edge->remove_cholla_curve( this );
      td_gm_edge->add_cholla_curve( fcm_ptr );
    }
  }

  return CUBIT_SUCCESS;
}