示例#1
0
CubitBoolean RefEdge::common_vertices( RefEdge *other_edge,
                                       DLIList<RefVertex*> &common_verts)
{
  CubitBoolean result = CUBIT_FALSE;
  RefVertex *this_start = start_vertex();
  RefVertex *this_end   = end_vertex();
  RefVertex *other_start = other_edge->start_vertex();
  RefVertex *other_end   = other_edge->end_vertex();
  
  if ( this_start == other_start || this_start == other_end )
  {
    common_verts.append(this_start);
    result = CUBIT_TRUE;
  }
  if ( this_end == other_start || this_end == other_end )
  {
    common_verts.append(this_end);
    result = CUBIT_TRUE;
  }

  return result;
}
示例#2
0
void PointGridSearch::get_neighborhood_points_sorted(
  DLIList<CubitPoint*> &point_list,
  const CubitVector& center, double cut_off)
{
  point_list.clean_out();
  DLIList<CubitPoint*> temp_point_list;
  int i;

  for (int k = boundingCellMinimumZ; k <= boundingCellMaximumZ; k++)
  {
    int kn = numberGridCellsY * k;
    for (int j = boundingCellMinimumY; j <= boundingCellMaximumY; j++)
    {
      int jn = numberGridCellsX * (kn + j);
      for ( i = boundingCellMinimumX; i <= boundingCellMaximumX; i++)
      {
	int in = jn + i;
        if (neighborhoodList[in])
        {
          temp_point_list += *(neighborhoodList[in]);
        }
      }
    }
  }

  // evaluate point distance to center ... remove those larger than cut_off
  SDLByDouble sorted_index_list;
  IndexedDouble *ID;  
  CubitVector vec;
  cut_off *= cut_off;
  temp_point_list.reset();
  for ( i = 0; i < temp_point_list.size(); i++)
  {
    vec = center - temp_point_list.get_and_step()->coordinates();
    double distance = vec.length_squared();
    if (distance < cut_off)
    {
      ID = new IndexedDouble( i, distance );
      sorted_index_list.append( ID );
    }
  }

  sorted_index_list.sort();
  temp_point_list.reset();
  for ( i = 0; i < sorted_index_list.size(); i++ )
  {
    ID = sorted_index_list.get_and_step();
    point_list.append( temp_point_list.next( ID->index() ) );
    delete ID;
  }
}
示例#3
0
void CompositePoint::get_parents_virt( DLIList<TopologyBridge*>& list )
{
  DLIList<TopologyBridge*> point_parents;
  realPoint->get_parents_virt( point_parents );
  for( int i = point_parents.size(); i--; )
  {
    TopologyBridge* tb = point_parents.get_and_step();
    if( CompositeCurve* curve = dynamic_cast<CompositeCurve*>(tb->owner()) )
    {
      if( ! dynamic_cast<HiddenEntitySet*>(curve->owner()) )
        list.append_unique( curve );
    }
    else if( ! dynamic_cast<HiddenEntitySet*>(tb->owner()) )
      list.append( tb );
  }

    // get point-curves also
  CompositeCurve* curve = 0;
  while ((curve = next_curve(curve)))
    if (curve->num_curves() == 0)
      list.append(curve);
  
  if (stitchNext)
  {
    point_parents.clean_out();
    stitchNext->get_parents_virt( point_parents );
    point_parents.reset();
    for (int j = point_parents.size(); j--; )
    {
      TopologyBridge* bridge = point_parents.get_and_step();
      CompositeCurve* curv = dynamic_cast<CompositeCurve*>(bridge);
      if (curv)
        list.append_unique( curv->primary_stitched_curve() );
      else
        list.append_unique( bridge );
    }
  }
}
示例#4
0
int RefEntityName::get_refentity_name(const RefEntity *entity,
                                      DLIList<CubitString> &names)
{
    // NOTE: There may be multiple names for one RefEntity. Make sure to 
    //       access all of them. 

  RefEntityNameMapList temp_list;
  int found_match = get_refentity_name(entity, temp_list);
  
  for (int i=temp_list.size(); i > 0; i--)
    names.append(temp_list.get_and_step()->key());

  return found_match;
}
示例#5
0
CubitStatus OCCBody::get_simple_attribute( const CubitString& name,
                                          DLIList<CubitSimpleAttrib>& csas )
{ 
  if (myTopoDSShape != NULL)
    return OCCAttribSet::get_attributes( name, *myTopoDSShape, csa_list );

  for(int i = 0 ; i < csa_list.size(); i ++)
  {
    const CubitSimpleAttrib& csa = csa_list.get_and_step();
    if(csa.string_data_list().size() > 0)
      if (csa.string_data_list()[0] == name)
       csas.append(csa);
  }
  return CUBIT_SUCCESS;
}
示例#6
0
//-------------------------------------------------------------------------
// Purpose       : Get parent CoEdges
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 07/29/03
//-------------------------------------------------------------------------
CubitStatus RefEdge::get_co_edges( DLIList<CoEdge*>& co_edges_found_list,
                                   RefFace *input_ref_face_ptr )
{
  for (SenseEntity* coedge_ptr = get_first_sense_entity_ptr();
       coedge_ptr;
       coedge_ptr = coedge_ptr->next_on_bte())
  {
    if (!input_ref_face_ptr ||
      coedge_ptr->get_parent_basic_topology_entity_ptr() == input_ref_face_ptr)
    {
      co_edges_found_list.append (dynamic_cast<CoEdge*>(coedge_ptr));
    }
  }
  
  return CUBIT_SUCCESS;
}
示例#7
0
template <class Z> MY_INLINE void RStarTree<Z>::to_list(DLIList <RStarTreeNode<Z>*> &member_list,
                                          RStarTreeNode<Z> *top)
{
    //Get the children of the top into the list.
  int ii;
  RStarTreeNode <Z> *curr_node;
  for ( ii = 0; ii < top->num_children(); ii++ )
  {
    curr_node = top->get_child(ii);
    member_list.append(curr_node);
      //don't go below the bottom level...
    if ( curr_node->get_leaf_level() == 0 )
      continue;
    to_list(member_list, curr_node);
  }
  return;
}
示例#8
0
//=============================================================================
//Function:  add_preexisting_feature_edges (PRIVATE)
//Description: edges that were marked previously in function ChollaEngine::mark_features
//             are added to the feature edge list
//Author: sjowen
//Date: 01/08
//=============================================================================
CubitStatus ChollaSurface::add_preexisting_feature_edges( 
	DLIList<CubitFacetEdge *> &feature_edge_list)
{
	DLIList<CubitFacetEdge *> edge_list;
	DLIList<CubitFacet *> facet_list;
	CAST_LIST( surfaceElemList, facet_list, CubitFacet );
	FacetDataUtil::get_edges( facet_list, edge_list );
	int iedge;
	CubitFacetEdge *edge;
	for (iedge=0; iedge < edge_list.size(); iedge++)
	{
		edge = edge_list.get_and_step();
		if (edge->is_feature())
			feature_edge_list.append(edge);
	}
	return CUBIT_SUCCESS;
}
示例#9
0
int RefEdge::common_ref_faces ( RefEdge* input_edge, DLIList<RefFace*> &common_face_list )
{
   int nedges = 0;
   DLIList<RefFace*> ref_faces, ref_faces_for_other_edge;
   this->ref_faces(ref_faces);
   input_edge->ref_faces(ref_faces_for_other_edge);                            

   int i, j;
   for (i = 0; i < ref_faces.size(); i++)
   {
      RefFace * ref_face = ref_faces.get_and_step();
      for (j = 0; j < ref_faces_for_other_edge.size(); j++)
         if (ref_face == ref_faces_for_other_edge.get_and_step())
         {
           common_face_list.append(ref_face);
           nedges++;
         }
   }

   return nedges;
}
示例#10
0
template <class Z> MY_INLINE CubitStatus RStarTree<Z>::recursive_find(RStarTreeNode<Z> *rect_tree,
                                                        const CubitBox &range_box,
                                                        DLIList <Z> &range_members )
{
  CubitBox rect_box = rect_tree->bounding_box();
  if ( !range_box.overlap(myTolerance, rect_box ) )
    return CUBIT_SUCCESS;

    //Now see if this is a data member.  If it is, append the data to the
    //list.
  if (rect_tree->is_data() )
  {
    range_members.append(rect_tree->get_data());
    return CUBIT_SUCCESS;
  }
    //Now if this is anything else we need to keep iterating...
  int loop_size = rect_tree->num_children();
    //We are doing a depth-first search of the tree.  Not
    //all branches will need to be followed since they won't
    //all overlap...
  int ii;
  RStarTreeNode<Z> *curr_node;
  CubitStatus stat;
  for ( ii = 0; ii < loop_size; ii++ )
  {
    curr_node = rect_tree->get_child(ii);
    if ( curr_node == NULL )
    {
      PRINT_ERROR("Problems finding boxes in range.\n");
      assert(curr_node != NULL);
      return CUBIT_FAILURE;
    }
    stat = recursive_find(curr_node, range_box, range_members);
    if ( stat != CUBIT_SUCCESS )
      return stat;
  }
  
  return CUBIT_SUCCESS;
}
示例#11
0
//=============================================================================
//Function:  non_manifold_edges (PRIVATE)
//Description: mark all edges that are non-manifold (have more than 2 adj
//             facets)
//Author: sjowen
//Date: 5/01
//=============================================================================
CubitStatus ChollaSurface::non_manifold_edges( 
  DLIList<CubitFacetEdge *> &feature_edge_list)
{
  //CubitStatus stat = CUBIT_SUCCESS;
  int ii, jj;
  DLIList<CubitFacetEdge*> edge_list;
  FacetEntity *face_ptr;
  TDGeomFacet *td_gm_face;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    edge_list.clean_out();
    face_ptr->edges( edge_list );
    for (jj=0; jj<edge_list.size(); jj++)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      if (!td_gm_edge)
      {
        DLIList<FacetEntity*> adj_face_list;
        edge_ptr->get_parents( adj_face_list );

        // non-manifold edges (edges with more than 2 adj facets)
        // must be features

        if (adj_face_list.size() > 2 || edge_ptr->is_feature())
        {
          TDGeomFacet::add_geom_facet(edge_ptr, -1); 
          td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
          edge_ptr->set_as_feature();
          feature_edge_list.append( edge_ptr );
        }
      }
    }
  }
  return CUBIT_SUCCESS;
}
示例#12
0
void PointGridSearch::get_neighborhood_facets( DLIList<CubitFacet*> &facet_list )
{
  // retrieve points over the current bounding box range

  facet_list.clean_out();
  DLIList<CubitPoint*> point_list;
  get_neighborhood_points( point_list );

  // retrieve all faces attached to the points in point_list

  for (int i = 0; i < point_list.size(); i++)
  {
    CubitPoint* point = point_list.get_and_step();

    DLIList<CubitFacet*> temp_facet_list;
    point->facets(temp_facet_list);

    for (int j = 0; j < temp_facet_list.size(); j++)
    {
      CubitFacet* facet = temp_facet_list.get_and_step();

      if (!facet->marked())
      {
        facet->marked(CUBIT_TRUE);
        facet_list.append(facet);
      }
    }
  }

  // unmark the found faces and return face_list

  for (int m = 0; m < facet_list.size(); m++)
  {
    facet_list.get_and_step()->marked(CUBIT_FALSE);
  }

}
示例#13
0
//-------------------------------------------------------------------------
// Purpose       : gets the ref edges in order with respect to this Loop.
//                 
// Special Notes : appends the edges to the list, with respect to coedges.
//
// Creator       : David White
//
// Creation Date : 03/25/97
//-------------------------------------------------------------------------
CubitStatus Loop::ordered_ref_edges(DLIList<RefEdge*>& ordered_edge_list )
{
  CubitStatus status = CUBIT_SUCCESS;

  DLIList<SenseEntity*> sense_entity_list;

  status = this->get_sense_entity_list(sense_entity_list);
  if ( status == CUBIT_FAILURE )
  {
    PRINT_ERROR("In Loop::ordered_ref_edges\n");
    PRINT_ERROR("       Problem getting the CoEdges of this Loop.\n");
    return CUBIT_FAILURE;
  }
  
    //Get the ref_edges associated with each co_edge.
  for ( int ii = sense_entity_list.size(); ii > 0; ii-- )
  {
    SenseEntity* se_ptr = sense_entity_list.get_and_step();
    BasicTopologyEntity* bte_ptr = se_ptr->get_basic_topology_entity_ptr();
    ordered_edge_list.append( dynamic_cast<RefEdge*>(bte_ptr) );
  }

  return CUBIT_SUCCESS;
}
示例#14
0
//=============================================================================
//Function:  get_adj_facets (PRIVATE)
//Description: non recursive function that creates a list of all facets connected
//             to the passed in facet  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::get_adj_facets( 
  FacetEntity *start_face_ptr,
  DLIList<FacetEntity*> &face_list,
  int mydebug,
  bool bound_check,
  bool feature_edge_check)
{
  //int found = 0;
  int ii;
  CubitStatus stat = CUBIT_SUCCESS;
  DLIList<FacetEntity*> temp_list;
  FacetEntity *face_ptr = NULL;
  FacetEntity *adj_face_ptr = NULL;
  DLIList<CubitFacetEdge *>edge_list;
  CubitFacetEdge *edge_ptr = NULL;
  DLIList<FacetEntity *>adj_face_list;

  if (mydebug)
  {
    for(ii=0; ii<surfaceElemList.size(); ii++)
    {
      face_ptr = surfaceElemList.get_and_step();
      TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
      PRINT_INFO("%d ", td_gm_face->get_hit_flag());
      if (ii%10 == 0)
      {
        PRINT_INFO("\n");
      }
    }
  }

  // add this face to the list

  temp_list.append( start_face_ptr );
  TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(start_face_ptr);
  td_gm_face->set_hit_flag( 0 );

  while (temp_list.size())
  {
    face_ptr = temp_list.pop();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
    if (td_gm_face->get_hit_flag() == 0)
    {
      face_list.append( face_ptr );
      if (mydebug)
      {
        face_ptr->debug_draw( CUBIT_RED );
        GfxDebug::flush();
      }
      edge_list.clean_out();
      face_ptr->edges( edge_list );
      for (ii=0; ii<edge_list.size(); ii++)
      {
        edge_ptr = edge_list.get_and_step();

        // edges that already have a tool data defined are the result
        // of a feature angle.  Don't traverse past a feature angle edge
    
        TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
        if (td_gm_edge == NULL || !feature_edge_check )
        {
          adj_face_list.clean_out();
          edge_ptr->get_parents( adj_face_list );

          // keep traversing only if there are two adjacent faces to this edge,
          // otherwise, this is a boundary

          if (adj_face_list.size() != 2)
          {
            continue;
          }

          if( bound_check )
          {
            TDFacetBoundaryEdge *td_facet_bnd_edge = TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
            if( td_facet_bnd_edge )
              continue;
          }
            
          adj_face_ptr = adj_face_list.get_and_step();
          if (adj_face_ptr == face_ptr)
            adj_face_ptr = adj_face_list.get();

          // go to its neighbor if it is part of the surface

          td_gm_face = TDGeomFacet::get_geom_facet(adj_face_ptr); 
          if (td_gm_face->get_hit_flag() == id)
          {
            temp_list.append( adj_face_ptr );
            td_gm_face->set_hit_flag( 0 );
          }
          
        }
      }
    }
  }
  return stat;
}
示例#15
0
//=============================================================================
//Function:  feature_angle (PRIVATE)
//Description: mark all edges that exceed the specified feature angle
//             min_dot is the minimum dot product between adjacent face normals
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::feature_angle( 
  double min_dot,
  DLIList<CubitFacetEdge *> &feature_edge_list)
{
  //CubitStatus stat = CUBIT_SUCCESS;
  int ii, jj;

  // compute face normals
  int mydebug = 0;
  double dot;
  CubitVector face_normal, adj_face_normal;
  FacetEntity *face_ptr, *adj_face_ptr;
  TDGeomFacet *td_gm_face;
  CubitFacet *tri_ptr;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    tri_ptr = CAST_TO( face_ptr, CubitFacet );
    face_normal = tri_ptr->normal( );
    face_normal.normalize();
    td_gm_face->set_normal( face_normal );
  }

  // check adjacencies and compute the dot product between them
  // where dot product is less than the min_dot, create a tool data
  // on the edge
  
  if(mydebug)
    GfxDebug::clear();
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    CubitFacet* curr_facet = CAST_TO(face_ptr, CubitFacet);
    CubitFacet* temp_facet = NULL;
    double curr_area=curr_facet->area();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    face_normal = td_gm_face->get_normal();
    DLIList<CubitFacetEdge*> edge_list;
    face_ptr->edges( edge_list );
    for (jj=0; jj<edge_list.size(); jj++)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      if (!td_gm_edge)
      {
        DLIList<FacetEntity*> adj_face_list;
        edge_ptr->get_parents( adj_face_list );

        // it has to be an internal edge - ignore boundaries
        if (adj_face_list.size() == 2)
        {
          adj_face_ptr = adj_face_list.get_and_step();
          
          if (adj_face_ptr == face_ptr)
            adj_face_ptr = adj_face_list.get();          
          td_gm_face = TDGeomFacet::get_geom_facet(adj_face_ptr);

          // make sure the adj face is on the same surface

          if (td_gm_face->get_hit_flag() == id)
          {

            // test the dot product between normals

            adj_face_normal = td_gm_face->get_normal();
            temp_facet = CAST_TO(adj_face_ptr, CubitFacet);
            double adj_area=temp_facet->area();
              //mbrewer:: ensure no NULL
            dot = adj_face_normal % face_normal;
            bool add_an_edge = true;
            if(mydebug){
              PRINT_INFO("This area %f, other %f\n",curr_area,adj_area);
            }
            if(curr_area<(1.e-10*adj_area)){
              DLIList<CubitFacetEdge*> edge_list_tmp;
              CubitFacetEdge* edge_ptr_tmp=NULL;
              curr_facet->edges(edge_list_tmp);
              double edge_length = edge_ptr->length();
              int k = 0;
              if(edge_list_tmp.size()>0)
                add_an_edge=false;
              for(k=edge_list_tmp.size();k>0;k--){
                edge_ptr_tmp=edge_list_tmp.get_and_step();
                if(edge_ptr_tmp != edge_ptr &&
                   edge_ptr_tmp->length() > edge_length){
                  add_an_edge=true;
                }
              }
            }
            if(adj_area<(1.e-10*curr_area))
            {
              DLIList<CubitFacetEdge*> edge_list_tmp;
              CubitFacetEdge* edge_ptr_tmp=NULL;
              temp_facet->edges(edge_list_tmp);
              double edge_length = edge_ptr->length();
              int k = 0;
              if(edge_list_tmp.size()>0)
                add_an_edge=false;
              for(k=edge_list_tmp.size();k>0;k--){
                edge_ptr_tmp=edge_list_tmp.get_and_step();
                if(edge_ptr_tmp != edge_ptr &&
                   edge_ptr_tmp->length() > edge_length){
                  add_an_edge=true;
                }
              }
            }
            if (dot <= min_dot && add_an_edge )
            {
              if(mydebug){
                edge_ptr->debug_draw(CUBIT_MAGENTA);
              }
              TDGeomFacet::add_geom_facet(edge_ptr, -1); 
              td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
              edge_ptr->set_as_feature();
              feature_edge_list.append( edge_ptr );
            }
          }
        }

        // non-manifold edges (edges with more than 2 adj facets)
        // must be features

        else if (adj_face_list.size() > 2)
        {
          TDGeomFacet::add_geom_facet(edge_ptr, -1); 
          td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
          edge_ptr->set_as_feature();
          feature_edge_list.append( edge_ptr );
        }
      }
    }
  }
  if(mydebug){
    GfxDebug::mouse_xforms();
  }
  return CUBIT_SUCCESS;
}
示例#16
0
void FacetCoEdge::get_curves( DLIList<FacetCurve*>& result_list )
{
  if (FacetCurve* curve = dynamic_cast<FacetCurve*>(myCurve))
    result_list.append(curve);
}
示例#17
0
//=============================================================================
//Function:  get_adj_facets (PRIVATE)
//Description: recursive funstion that creates a list of all faces connected
//             the passed in face  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::get_adj_facets( 
  FacetEntity *start_face_ptr,
  DLIList<FacetEntity*> &face_list,
  int mydebug)
{
  CubitStatus stat = CUBIT_SUCCESS;

  // add this face to the list

  if (mydebug)
  {
    //start_face_ptr->draw( CUBIT_RED );
    //CDrawingTool::instance()->flush();
  }
  face_list.append( start_face_ptr );
  TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(start_face_ptr);
  td_gm_face->set_hit_flag( 0 );

  // loop through its edges

  CubitFacetEdge *edge_ptr;
  FacetEntity *face_ptr;
  DLIList<CubitFacetEdge*> edge_list;
  start_face_ptr->edges( edge_list );
  int ii;
  for (ii=0; ii<edge_list.size(); ii++)
  {
    edge_ptr = edge_list.get_and_step();
    
    // edges that already have a tool data defined are the result
    // of a feature angle.  Don't traverse past a feature angle edge
    
    TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
    if (td_gm_edge == NULL)
    {
      DLIList<FacetEntity*> adj_face_list;
      edge_ptr->get_parents( adj_face_list );

      // keep traversing only if there are two adjacent faces to this edge,
      // otherwise, this is a boundary

      if (adj_face_list.size() == 2)
      {
        face_ptr = adj_face_list.get_and_step();
        if (face_ptr == start_face_ptr)
          face_ptr = adj_face_list.get();

        // go to its neighbor if it is part of the surface

        td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
        if (td_gm_face->get_hit_flag() == id)
        {
          stat = get_adj_facets( face_ptr, face_list, mydebug );
          if (stat != CUBIT_SUCCESS)
            return stat;
        }
      }
    }
  }
  return stat;
}
示例#18
0
CubitStatus Faceter::get_boundary_points( DLIList <DLIList<CubitPoint*>*> &boundary_point_loops ) const
{
  DLIList<DLIList<CoEdge*>*> co_edge_loops;
  thisRefFacePtr->co_edge_loops(co_edge_loops);
  int ii, jj;
  DLIList <CoEdge*> *co_edge_list_ptr;
  DLIList <CubitPoint*> *new_point_loop_ptr, tmp_point_list;
  RefEdge *ref_edge_ptr;
  CoEdge *co_edge_ptr;
  CubitStatus stat;
  CubitSense sense;
  
  for ( ii = co_edge_loops.size(); ii > 0; ii-- )
  {
    co_edge_list_ptr = co_edge_loops.get_and_step();
    new_point_loop_ptr = new DLIList <CubitPoint*>;
    for ( jj = co_edge_list_ptr->size(); jj > 0; jj-- )
    {
      co_edge_ptr = co_edge_list_ptr->get_and_step();
      ref_edge_ptr = co_edge_ptr->get_ref_edge_ptr();
      tmp_point_list.clean_out();
      stat = get_curve_facets( ref_edge_ptr, tmp_point_list );
      PRINT_DEBUG_129("curve %d has %d points\n",
                      ref_edge_ptr->id(),
                      tmp_point_list.size());
      if ( !stat )
        return CUBIT_FAILURE;
      tmp_point_list.reset();
        //the points are in order from start vertex to end vertex.
        //append them now according to the loop.
      sense = co_edge_ptr->get_sense();
      if ( CUBIT_FORWARD != sense )
        tmp_point_list.reverse();
        //Now take off the last point as it is a duplicate with the
        //other list...
      tmp_point_list.reset();
      delete tmp_point_list.pop();
      (*new_point_loop_ptr) += tmp_point_list;
    }
    CubitVector curr, prev;
    for ( jj = new_point_loop_ptr->size(); jj > 0; jj-- )
    {
      prev = new_point_loop_ptr->prev()->coordinates();
      curr = new_point_loop_ptr->get_and_step()->coordinates();
      if ( prev.about_equal(curr) )
      {
        PRINT_DEBUG_129("Points within tolerance in boundaryloop.\n");
        new_point_loop_ptr->back();
        delete new_point_loop_ptr->remove();
      }
    }
    boundary_point_loops.append(new_point_loop_ptr);
  }
  
    //clean up the list memory.
  for(ii = co_edge_loops.size(); ii>0; ii-- )
    delete co_edge_loops.pop();
  co_edge_loops.clean_out();
      
  return CUBIT_SUCCESS;
}
示例#19
0
void CubitUtil::sort_and_print_ids( const char *const heading,
                                      DLIList<int> &id_list,
                                      int should_sort, int report_once,
                                      int wrap )
{
    // sort, if desired
  if ( should_sort ) {
    id_list.sort();
  }

  if ( report_once ) {
    DLIList <int> id_list_2( id_list );
    id_list_2.reset();
    id_list.clean_out();
    id_list.append( id_list_2.get_and_step() );
    for ( int j = id_list_2.size()-1; j--; )
    {
      if ( id_list_2.get() != id_list_2.prev() )
        id_list.append( id_list_2.get() );
      id_list_2.step();
    }
  }

  if( wrap == -1 )
  {
    // print out ranges
    int begin = id_list.get_and_step();
    int end = begin;
    int current = -1;
    PRINT_INFO("  The %d %s ids are %d", id_list.size(), heading, begin);
    for (int i=id_list.size()-1; i > 0; i--) {
      current = id_list.get_and_step();
      if (current == end+1) {
        end++;
      }
      else {
        if (end == begin) {
          PRINT_INFO(", %d", current);
        }
        else if (end == begin+1) {
          PRINT_INFO(", %d, %d", end, current);
        }
        else {
          PRINT_INFO(" to %d, %d", end, current);
        }
        begin = current;
        end = begin;
      }
    }
    if (current == begin + 1)	{
      PRINT_INFO(", %d", current);
    }
    else if (current != begin) {
      PRINT_INFO(" to %d", current);
    }
    PRINT_INFO(".\n");
  }
  else
  {
    char pre_string[67];
    sprintf( pre_string, "  The %d %s ids are: ", id_list.size(),heading );
    CubitUtil::list_entity_ids( pre_string, id_list, wrap, ".\n", CUBIT_FALSE,
                                CUBIT_FALSE );
  }
}
示例#20
0
CubitStatus Faceter::get_curve_facets( RefEdge* curve, DLIList<CubitPoint*>& segments ) const
{
//const double COS_ANGLE_TOL =  0.965925826289068312213715; // cos(15)
  const double COS_ANGLE_TOL =  0.984807753012208020315654; // cos(10)
//const double COS_ANGLE_TOL =  0.996194698091745545198705; // cos(5)
  GMem curve_graphics;
  const double dist_tol = GEOMETRY_RESABS;
  const double dist_tol_sqr = dist_tol*dist_tol;
  Curve* curve_ptr = curve->get_curve_ptr();
  curve_ptr->get_geometry_query_engine()->get_graphics( curve_ptr, &curve_graphics );
  
  GPoint* gp = curve_graphics.point_list();
  CubitPoint* last = (CubitPoint*) new FaceterPointData( gp->x, gp->y, gp->z );
  ((FaceterPointData*)last)->owner(dynamic_cast<RefEntity*>(curve));
  CubitVector lastv = last->coordinates();
  segments.append( last );
  GPoint* end = gp + curve_graphics.pointListCount - 1;
  
  for( gp++; gp < end; gp++ )
  {
    CubitVector pos(  gp->x, gp->y, gp->z );
    CubitVector step1 = (pos - lastv);
    double len1 = step1.length();
    if( len1 < dist_tol ) continue;
    
    GPoint* np = gp + 1;
    CubitVector next( np->x, np->y, np->z );
    CubitVector step2 = next - pos;
    double len2 = step2.length();
    if( len2 < dist_tol ) continue;
    
    double cosine = (step1 % step2) / (len1 * len2);
    if( cosine > COS_ANGLE_TOL ) continue;
    
    last = new FaceterPointData( pos );
    ((FaceterPointData*)last)->owner(dynamic_cast<RefEntity*>(curve));
    segments.append( last );
    lastv = last->coordinates();
  }
  
  CubitVector last_pos( gp->x, gp->y, gp->z );
  segments.last();
  while( (last_pos - (segments.get()->coordinates())).length_squared() < dist_tol_sqr )
  {
    delete segments.pop();
    segments.last();
  }
  CubitPoint *tmp_point = (CubitPoint*) new FaceterPointData( last_pos );
  segments.append( tmp_point );
  ((FaceterPointData*)tmp_point)->owner( dynamic_cast<RefEntity*>(curve) );
    
  // Now check if the segment list is reversed wrt the curve direction.
  segments.reset();
  double u1, u2;
  if( segments.size() > 2 )
  {
    u1 = curve->u_from_position( (segments.next(1)->coordinates()) );
    u2 = curve->u_from_position( (segments.next(2)->coordinates()) );    
  }
  else
  {
    u1 = curve->u_from_position( (segments.get()->coordinates() ) );
    u2 = curve->u_from_position( (segments.next()->coordinates()) );
  }
  if( (u2 < u1) && (curve->start_param() <= curve->end_param()) )
    segments.reverse();

    //Make sure we don't have duplicate points.
  int jj;
  CubitVector curr, prev;
  for ( jj = segments.size(); jj > 0; jj-- )
  {
    prev = segments.prev()->coordinates();
    curr = segments.get_and_step()->coordinates();
    if ( prev.about_equal(curr) )
    {
      PRINT_DEBUG_129("Points on curve %d within tolerance...\n", curve->id());
      segments.back();
      delete segments.remove();
    }
  }
  return CUBIT_SUCCESS;
}
示例#21
0
//=============================================================================
//Function:  split_surface (PUBLIC)
//Description: split this surface into multiple ChollaSurface where there are
//             discontinuous faces.  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::split_surface( 
  DLIList<ChollaSurface*> &facet_surface_list 
  )
{
  DLIList<ChollaSurface*> new_surface_list;
  CubitStatus stat = CUBIT_SUCCESS;

  // Go through the surfaceElemList and pull faces off one by one as we
  // determine which surface it belongs to.  Continue until we have depleted
  // the list

  int jj;
  int mydebug = 0;
  int num_surfs_created = 0;
  while( surfaceElemList.size() > 0)
  {

    // start with the first face and create a list of all elements 
    // attached to the face

    DLIList<FacetEntity*> face_list;
    FacetEntity *start_face_ptr = surfaceElemList.get_and_step();
    stat = get_adj_facets( start_face_ptr, face_list, mydebug );
    if (stat != CUBIT_SUCCESS)
      return stat;

    // if we have the same number of faces on the face_list as we do
    // on the surfaceElemList, then we are done.  This surface is
    // not multiply connected.  Oherwise continue...

    if (face_list.size() == surfaceElemList.size())
    {

      // if this surface had a curve already defined (its a 2D topology
      // defined in skin2D) then its no longer valid if the surface was split
      // (for 3D the curves aren't defined until later)

      if (num_surfs_created > 0 && curveList.size() > 0)
      {
        ChollaCurve *fcm_ptr = curveList.get();  // there should only be 1
        curveList.remove();
        fcm_ptr->remove_td_associativity( this );
        delete fcm_ptr;
      }
      return CUBIT_SUCCESS;
    }

    // create a new surface to hold the face info

    num_surfs_created++;
    ChollaSurface *fsm_ptr = new ChollaSurface( blockId );
    facet_surface_list.append( fsm_ptr );

    // update the geometric curve pointer

    fsm_ptr->assign_geometric_surface( NULL );

    // add the faces to this surface and update the surface 
    // pointers in the face tool data

      // surfaceElemList: nullify the items then compress the list
      // afterwards, instead of removing the items one by one, for
      // speed.
    for (jj=face_list.size(); jj > 0; jj--)
    {
      FacetEntity *face_ptr = face_list.get_and_step();
      TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
      td_gm_face->remove_cholla_surf( this );
      td_gm_face->add_cholla_surf( fsm_ptr );
      surfaceElemList.move_to_nearby( face_ptr );
      surfaceElemList.extract();
      fsm_ptr->add_facet( face_ptr );
    }
  }

  return CUBIT_SUCCESS;
}
示例#22
0
void PartitionShell::get_parents_virt( DLIList<TopologyBridge*>& parents )
{
  if( myLump )
    parents.append( myLump );
}
示例#23
0
//=============================================================================
//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;
}
示例#24
0
CubitStatus FacetLump::mass_properties( CubitVector& centroid, double& volume )
{
  int i;
  
  DLIList<FacetShell*> shells( myShells.size() );
  CAST_LIST( myShells, shells, FacetShell );
  assert( myShells.size() == shells.size() );
  
  DLIList<FacetSurface*> surfaces;
  DLIList<FacetShell*> surf_shells;
  get_surfaces( surfaces );
  
  DLIList<CubitFacet*> facets, surf_facets;
  DLIList<CubitPoint*> junk;
  DLIList<CubitSense> senses;
  for (i = surfaces.size(); i--; )
  {
    FacetSurface* surf = surfaces.step_and_get();
    surf_shells.clean_out();
    surf->get_shells( surf_shells );
    surf_shells.intersect( shells );
    assert( surf_shells.size() );
    CubitSense sense = surf->get_shell_sense( surf_shells.get() );
    if (surf_shells.size() == 1 && CUBIT_UNKNOWN != sense)
    {
      surf_facets.clean_out();
      junk.clean_out();
      surf->get_my_facets( surf_facets, junk );
      facets += surf_facets;
      
      for (int j = surf_facets.size(); j--; )
        senses.append(sense);
    }
  }
  
  const CubitVector p0 = bounding_box().center();
  CubitVector p1, p2, p3, normal;
  centroid.set( 0.0, 0.0, 0.0 );
  volume = 0.0;
  
  facets.reset();
  senses.reset();
  for (i = facets.size(); i--; )
  {
    CubitFacet* facet = facets.get_and_step();
    CubitSense sense = senses.get_and_step();
    p1 = facet->point(0)->coordinates();
    p2 = facet->point(1)->coordinates();
    p3 = facet->point(2)->coordinates();
    normal = (p3 - p1) * (p2 - p1);

    double two_area = normal.length();
    if (two_area > CUBIT_RESABS )
    {
      if (CUBIT_REVERSED == sense)
        normal = -normal;

      normal /= two_area;

      double height = normal % (p0 - p1);
      double vol = two_area * height;

      volume += vol;
      centroid += vol * (p0 + p1 + p2 + p3);
    }
  }
  
  if (volume > CUBIT_RESABS)
    centroid /= 4.0 * volume;
  volume /= 6.0;
  return CUBIT_SUCCESS;
}
示例#25
0
void FacetLump::get_bodies( DLIList<FacetBody*>& result_list )
{
  FacetBody* body = dynamic_cast<FacetBody*>(myBodyPtr);
  if (body)
    result_list.append(body);
}
示例#26
0
//- "k_nearest_neighbor"
//- Find the K nearest neighbors to a point.
//-
//- Description:
//-   This algorithm is based on the best-first search.  The goal of this
//-   algorithm is to minimize the number of nodes visited by using the
//-   distance to each subtree's bounding box to avoid visiting subtrees
//-   which could not possibly contain one of the k nearest objects.
//-
template <class Z> CubitStatus KDDTree<Z>::k_nearest_neighbor
  (CubitVector &q, int k, double &closest_dist, DLIList<Z> &nearest_neighbors,
   typename KDDTree<Z>::DistSqFunc dist_sq_point_data
  )  
{
  //// Create the priority queues
  PriorityQueue<KDDTreeNode<Z>*> *queue = new PriorityQueue<KDDTreeNode<Z>*> (KDDTree<Z>::less_than_func);
  PriorityQueue<KDDTreeNode<Z>*> *queueTemp = new PriorityQueue<KDDTreeNode<Z>*> (KDDTree<Z>::less_than_func);


  KDDTreeNode<Z> *element = root;

  // push this node on the queue
  element->set_dist (min_dist_sq (q, element->safetyBox));
  element->set_dist_data (DD_SAFETY);
  queue->push (element);
  

  // if the k closest nodes on the tree are not leaf-nodes, expand the closest
  //   non-leaf node
  while ( !queue->empty() )
  {
    element = queue->top();
    queue->pop();

    if (element->get_dist_data() == DD_LEAF)
    {
      // this node is a leaf, so it can be pushed onto the temporary queue
      queueTemp->push (element);
    }
    else
    {
      // one of the top k nodes is a non-leaf node, so expand it
      if (element->left)
      {
        element->left->set_dist (min_dist_sq (q, element->left->safetyBox));
        element->left->set_dist_data (DD_SAFETY);
        queue->push (element->left);
      }
      if (element->right)
      {
        element->right->set_dist (min_dist_sq (q, element->right->safetyBox));
        element->right->set_dist_data (DD_SAFETY);
        queue->push (element->right);
      }
      element->set_dist (dist_sq_point_data (q, element->data));
      element->set_dist_data (DD_LEAF);
      queue->push (element);

      // take all the elements in the temporary queue and reinsert them into
      //   the actual queue
      while ( !queueTemp->empty() )
      {
        queue->push ( queueTemp->top() );
        queueTemp->pop ();
      }
    }

    if (queueTemp->size() == k)
    {
      // success-- place the k nodes into the nearest_neighbors list
      element = queueTemp->top();
      queueTemp->pop();
      closest_dist = element->get_dist();
      nearest_neighbors.append (element->data);

      while ( !queueTemp->empty() )
      {
        nearest_neighbors.append ( queueTemp->top()->data );
        queueTemp->pop();
      }
     
      return CUBIT_SUCCESS;
    }
  }
  return CUBIT_FAILURE;
}
示例#27
0
// order edges in list beginning at start_point
// report the endpoint
// return CUBIT_SUCCESS if all edges are connected and ordered successfully
// otherwise return CUBIT_FAILURE, in which case no changes are made
CubitStatus CubitFacetEdge::order_edge_list(DLIList<CubitFacetEdge*> &edge_list,
                                            CubitPoint *start_point,
                                            CubitPoint *&end_point)
{
  int i;
  assert(start_point);

  end_point = NULL;

  // invalid input
  if (0 == edge_list.size())
    return CUBIT_FAILURE;

  // simple case of a single edge - endpoitn
  if (1 == edge_list.size())
  {
    end_point = edge_list.get()->other_point(start_point);
    return end_point ? CUBIT_SUCCESS : CUBIT_FAILURE;
  }

  edge_list.reset();

  // note that a periodic/closed curve will fail
  // we could handle that case here if needed, but we may need more information
  // to know where to start and end the curve
  if (NULL == start_point)
    return CUBIT_FAILURE;

  // put edges in a set for faster searching
  std::set<CubitFacetEdge *> edge_set;
  for (i=0; i<edge_list.size(); i++)
    edge_set.insert(dynamic_cast<CubitFacetEdge*> (edge_list.step_and_get()));

  // a vector for the ordered list
  std::vector<CubitFacetEdge*> ordered_edges;

  // find connected edges from the start point
  CubitPoint *cur_pt = start_point;
  do
  {
    // get edges connected to the current point and find the next edge
    DLIList<CubitFacetEdge *> pt_edges;
    cur_pt->edges(pt_edges);

    std::set<CubitFacetEdge *>::iterator iter_found;
    CubitFacetEdge *cur_edge = NULL;
    for (i=0; i<pt_edges.size() && !cur_edge; i++)
    {
      CubitFacetEdge *tmp_edge = pt_edges.get_and_step();
      iter_found = edge_set.find(tmp_edge);
      if ( iter_found != edge_set.end() )
        cur_edge = tmp_edge;
    }

    // if we don't find a connection before we empty the set
    // then not all the edges are connected  -- return failure
    if (NULL == cur_edge)
      return CUBIT_FAILURE;

    // add the edge to the ordered list
    ordered_edges.push_back( cur_edge );
    edge_set.erase(iter_found);

    cur_pt = cur_edge->other_point(cur_pt);
  }
  while ( edge_set.size());

  if (ordered_edges.size() != edge_list.size())
    return CUBIT_FAILURE;

  // store the edges in the correct order
  edge_list.clean_out();

  std::vector<CubitFacetEdge*>::iterator iter;
  for (iter=ordered_edges.begin(); iter!=ordered_edges.end(); iter++)
    edge_list.append(*iter);

  // get the end point
  CubitFacetEdge *edge1 = edge_list[edge_list.size() - 1];
  CubitFacetEdge *edge2 = edge_list[edge_list.size() - 2];

  end_point = edge1->other_point( edge1->shared_point(edge2) );

  return CUBIT_SUCCESS;
}
示例#28
0
void FacetCoEdge::get_parents_virt( DLIList<TopologyBridge*>& parents )
  { parents.append( myLoop ); }
示例#29
0
void CubitUtil::process_entity_ids( int method,
                                    CubitString &ret_str,
                                    const char *pre_string, 
                                    DLIList<int> &id_list,
                                    int max_len, 
                                    const char *post_string,
                                    int sort, int unique,
                                    int tab_len, const char *sep_string,
                                    const char* post_string_none ) 
{
  // Method: 0 - to a string
  //         1 - to PRINT_INFO
  char temp[200];

  if ( id_list.size() == 0 ) {
    if( method )
      PRINT_INFO("%s%s", pre_string, post_string_none );
    else
    {
      sprintf( temp, "%s%s", pre_string, post_string_none );
      ret_str = temp;
    }
    if( fp )
      fprintf( fp, "%s%s", pre_string, post_string_none );
    return;
  }

  // sort
  if( sort )
  {
    id_list.sort();
    
    // make unique
    if( unique ) 
    {
      int i;
      DLIList <int> id_list_2( id_list );
      id_list_2.reset();
      id_list.clean_out();
      id_list.append( id_list_2.get_and_step() );
      for ( i=id_list_2.size()-1; i--; ) 
      {
        if ( id_list_2.get() != id_list_2.prev() )
          id_list.append( id_list_2.get() );
        id_list_2.step();
      }
    }
  }

  if( max_len < 0 )
    max_len = CUBIT_INT_MAX/2;
    
  // TODO: wrap prestring, if necessary
  if( method )
    PRINT_INFO( "%s", pre_string );
  else
    ret_str = pre_string;
  if( fp )
    fprintf( fp, "%s", pre_string );

  // Keep track of length printed
  int curr_len = strlen(pre_string);
  
  int num = 0;
  int begin = id_list.get();
  int previous = begin;
  int current;
  int comma = 0; // Is comma needed
  int beg_len, prev_len;
  int sep_len = strlen( sep_string );

  // Setup the tab
  char* tab = new char[tab_len+1];
  for( int i=0; i<tab_len; i++ )
     tab[i] = ' ';
  tab[tab_len] = '\0';

  // Loop until all the ids are printed.  Use ranges if possible.
  while( num < id_list.size()+1 )
  {
    current = id_list.get_and_step();
    num++;

    // Handle last entity
    if( num <= id_list.size() )
    {
      if( num==1 ) // Handle 1st time in loop
        continue;
      
      if( current==previous+1 )
      {
        previous = current;
        continue;
      }
    }

    // If we are here, we are no longer tracking a range and
    // need to print the range or a number.
    if( comma )
    {
      if( method )
        PRINT_INFO("%s", sep_string );
      else
        ret_str += sep_string;
      if( fp )
        fprintf( fp, "%s", sep_string );
      curr_len += sep_len;
    }

    if( begin==previous )
    {
      // a single number
      prev_len = int_len(previous);

      if( curr_len+1+prev_len+sep_len > max_len )
      {
        if( method )
        {
          PRINT_INFO( "\n" );
          PRINT_INFO( "%s%d", tab, previous );
        }
        else
        {
          sprintf( temp, "\n%s%d", tab, previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "\n%s%d", tab, previous );
        curr_len = tab_len + prev_len;
      }
      else
      {
        if( comma ) // Don't print space before first item
        {
          if( method )
            PRINT_INFO( " " );
          else
            ret_str += " ";
          if( fp )
            fprintf( fp, " " );
          curr_len++;
        }

        if( method )
          PRINT_INFO( "%d", previous );
        else
        {
          sprintf( temp, "%d", previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "%d", previous );
        curr_len = curr_len + prev_len;
      }
    }
    else if( previous==begin+1 )
    {
      // a range, but only 2 consecutive numbers
      prev_len = int_len(previous);
      beg_len = int_len(begin);

      // Print 1st
      if( curr_len+1+beg_len+sep_len > max_len )
      {
        if( method )
        {
          PRINT_INFO( "\n" );
          PRINT_INFO( "%s%d%s", tab, begin, sep_string );
        }
        else
        {
          sprintf( temp, "\n%s%d%s", tab, begin, sep_string );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "\n%s%d%s", tab, begin, sep_string );
        curr_len = tab_len + beg_len + sep_len;
      }
      else
      {
        if( comma ) // Don't print space before first item
        {
          if( method )
            PRINT_INFO( " " );
          else
            ret_str += " ";
          if( fp )
            fprintf( fp, " " );
          curr_len++;
        }

        if( method )
          PRINT_INFO( "%d%s", begin, sep_string );
        else
        {
          sprintf( temp, "%d%s", begin, sep_string );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "%d%s", begin, sep_string );
        curr_len = curr_len + beg_len + sep_len;
      }

      // Print 2nd
      if( curr_len+1+prev_len+sep_len > max_len )
      {
        if( method )
        {
          PRINT_INFO( "\n" );
          PRINT_INFO( "%s%d", tab, previous );
        }
        else
        {
          sprintf( temp, "\n%s%d", tab, previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "\n%s%d", tab, previous );
        curr_len = tab_len + prev_len;
      }
      else
      {
        if( method )
          PRINT_INFO( " %d", previous );
        else
        {
          sprintf( temp, " %d", previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, " %d", previous );
        curr_len = curr_len + 1+prev_len;
      }
    }
    else
    {
      // a range of 3 or more consecutive numbers
      prev_len = int_len(previous);
      beg_len = int_len(begin);

      if( curr_len+beg_len+prev_len+5+sep_len > max_len )
      {
        if( method )
        {
          PRINT_INFO( "\n" );
          PRINT_INFO( "%s%d to %d", tab, begin, previous );
        }
        else
        {
          sprintf( temp, "\n%s%d to %d", tab, begin, previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "\n%s%d to %d", tab, begin, previous );
        curr_len = tab_len + beg_len+prev_len+4;
      }
      else
      {
        if( comma ) // Don't print space before first item
        {
          if( method )
            PRINT_INFO( " " );
          else
            ret_str += " ";
          if( fp )
            fprintf( fp, " " );
          curr_len++;
        }

        if( method )
          PRINT_INFO( "%d to %d", begin, previous );
        else
        {
          sprintf( temp, "%d to %d", begin, previous );
          ret_str += temp;
        }
        if( fp )
          fprintf( fp, "%d to %d", begin, previous );
        curr_len = curr_len + beg_len+4+prev_len;
      }
    }

    begin = current;
    previous = current;
    comma = 1;

  }

  //TODO: wrap poststring, if required
  if (post_string) {
    
    if( method )
      PRINT_INFO( "%s", post_string );
    else
      ret_str += post_string;
    if( fp )
      fprintf( fp, "%s", post_string );
  }
  
  delete [] tab;
}
示例#30
0
void FacetCoEdge::get_children_virt( DLIList<TopologyBridge*>& children )
  { children.append( myCurve ); }