Ejemplo n.º 1
0
//-------------------------------------------------------------------------
// Purpose       : Get named attributes
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 03/03/03
//-------------------------------------------------------------------------
void CompositeGeom::get_attributes( const char* name,
                                    DLIList<CubitSimpleAttrib>& list )
{
  if (entityList.size() == 1)
  {
      // handle 8.1 attribs on single-entity 'composites'
    list.clean_out();
    entityList[0].entity->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
    while (list.size())
    {
      CubitSimpleAttrib attrib = list.pop();
      if (attrib.int_data_list()[0] == 1)
      {
        entityList[0].entity->remove_simple_attribute_virt(attrib);
        std::vector<CubitString> s(attrib.string_data_list().begin()+1, attrib.string_data_list().end());
        std::vector<int> i(attrib.int_data_list().begin()+1, attrib.int_data_list().end());
        CubitSimpleAttrib new_attrib(&s, &attrib.double_data_list(), &i);
        entityList[0].entity->append_simple_attribute_virt(new_attrib);
      }
    }
    
    entityList[0].entity->get_simple_attribute(name, list);
  }
    
  for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
    if (ptr->name() == name)
      list.append(ptr->csa());
}
Ejemplo n.º 2
0
void CAMergePartner::merge_prepare(DLIList<RefEntity*> &merge_list)
{
  DLIList<CubitAttrib*> my_ca_list;
  CAMergePartner *my_camp_ptr;
  RefEntity* re_ptr;

    // get all the merge partner attributes that are on my owner
  attribOwnerEntity->find_cubit_attrib_type(CA_MERGE_PARTNER, my_ca_list);
  merge_list.clean_out();
  DLIList<ToolDataUser*> td_list, temp_td_list;
  int i;
  for (i = my_ca_list.size(); i > 0; i--)
  {
    my_camp_ptr = CAST_TO(my_ca_list.get(),CAMergePartner);
    my_ca_list.step();
    td_list.clean_out();
      // get all the objects with this unique id (which is also the merge id)
    TDUniqueId::find_td_unique_id(my_camp_ptr->merge_id(), temp_td_list);
    td_list += temp_td_list;
  }
  
    // now put those entities into the merge_list
  for (i = td_list.size(); i > 0; i--) 
  {
    re_ptr = CAST_TO(td_list.get(), RefEntity);
    if (re_ptr) 
    {
      CubitAttrib *tmp_attrib = re_ptr->get_cubit_attrib( CA_MERGE_PARTNER, CUBIT_FALSE );
      if( tmp_attrib )
        merge_list.append(re_ptr);
    }
    td_list.step();
  }
  
    // Now get bridge sense for each entity in list.
    // Add this entity to list, too.
  merge_list.append( attribOwnerEntity );
  for( i = merge_list.size(); i--; )
  {
    RefEntity* ent = merge_list.get_and_step();
    TopologyEntity* te = dynamic_cast<TopologyEntity*>(ent);
    if( te->bridge_manager()->number_of_bridges() != 1 )
      continue;
    
    my_ca_list.clean_out();
    ent->find_cubit_attrib_type(CA_MERGE_PARTNER, my_ca_list);
    assert( my_ca_list.size() < 2);
    if( !my_ca_list.size() )
      continue;
    
    my_camp_ptr = dynamic_cast<CAMergePartner*>(my_ca_list.get());
    if( my_camp_ptr->bridge_sense() == CUBIT_UNKNOWN )
      continue;
  }  
  merge_list.pop(); // take attribOwnerEntity back off list
    
  return;
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------------
// Purpose       : Check if shell is a sheet.
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 01/15/04
//-------------------------------------------------------------------------
CubitBoolean Shell::is_sheet()
{
  DLIList<RefFace*> faces;
  ref_faces(faces);
  while (faces.size())
    if ( ! faces.pop()->is_nonmanifold(this) )
      return CUBIT_FALSE;
  return CUBIT_TRUE;
}  
Ejemplo n.º 4
0
//-------------------------------------------------------------------------
// Purpose       : Clean out composite attributes.
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 07/01/03
//-------------------------------------------------------------------------
void CompositeGeom::clean_up_attribs( GeometryEntity* ent )
{
  DLIList<CubitSimpleAttrib> list;
  ent->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
  while (list.size())
  {
    CubitSimpleAttrib csa = list.pop();
    ent->remove_simple_attribute_virt(csa);
  }
}
Ejemplo n.º 5
0
//-------------------------------------------------------------------------
// Purpose       : facet_surface: facets the surface.
//
// Special Notes : 
//
// Creator       : David White
//
// Creation Date : 03/01/02
//-------------------------------------------------------------------------
CubitStatus Faceter::facet_surface(DLIList <CubitFacet*> &results,
                                   DLIList <CubitPoint*> &point_list)
{
  if ( DEBUG_FLAG(129) )
  {
    GfxDebug::clear();
    GfxDebug::draw_ref_face_edges(thisRefFacePtr);
    GfxDebug::flush();
    int debug = 0;
    if ( debug )
    {
      GfxDebug::mouse_xforms();
      GfxDebug::flush();
    }
  }
  if ( thisRefFacePtr->number_of_Loops() > 1 )
    return CUBIT_FAILURE;
    //Get the ordered boundary loops.
  int ii, jj;
  DLIList <DLIList<CubitPoint*>*>  boundary_point_loops;
  DLIList <CubitPoint*> *tmp_list_ptr;
  CubitStatus stat = get_boundary_points( boundary_point_loops );
  if ( stat != CUBIT_SUCCESS )
  {
      //clean up the data...
    for ( ii = boundary_point_loops.size(); ii > 0; ii-- )
    {
      tmp_list_ptr = boundary_point_loops.pop();
      for ( jj = tmp_list_ptr->size(); jj > 0; jj-- )
        delete tmp_list_ptr->pop();
      delete tmp_list_ptr;
    }
    return stat;
  }
    //Set up the gridsearch.
  double ratio = gridCellScale, cell_size = 0.0;
  max_min_edge_ratio(boundary_point_loops, ratio, cell_size);
  if (ratio <= gridCellScale) {
    ratio = gridCellScale;
  }
    //Get all of the points into a single list.
  for ( ii = boundary_point_loops.size(); ii > 0; ii-- )
  {
    tmp_list_ptr = boundary_point_loops.get_and_step();
    for ( jj = tmp_list_ptr->size(); jj > 0; jj-- )
    {
      globalPointList->append(tmp_list_ptr->get_and_step());
    }
  }
  gridSearchPtr = new PointGridSearch(*globalPointList,
                                      cell_size,
                                      ratio);
      //fill in the grid...
  for ( ii = globalPointList->size(); ii > 0; ii-- )
    gridSearchPtr->add_point(globalPointList->get_and_step());

    //Now start faceting.
  stat = facet_loop( boundary_point_loops.get(), results );
    //clean up the data...
  for ( ii = boundary_point_loops.size(); ii > 0; ii-- )
    delete boundary_point_loops.pop();
  if ( stat != CUBIT_SUCCESS )
  {
      //clean the data and return..
    for ( ii = results.size(); ii > 0; ii-- )
      delete results.pop();
    for ( ii = globalPointList->size(); ii > 0; ii-- )
      delete globalPointList->pop();
    return stat;
  }
    //Didn't add any points...
  point_list += *globalPointList;
  return CUBIT_SUCCESS;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
//-------------------------------------------------------------------------
// Purpose       : Save attributes on first underlying entity
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 06/30/03
//-------------------------------------------------------------------------
void CompositeGeom::write_attributes( GeometryEntity* geom_ptr )
{
  DLIList<CubitSimpleAttrib> list;

  if (geom_ptr)
  {
      // Special case for point-curves (no real curves to write
      // attirbutes to.)  Write to passed entity instead.
    assert(entityList.size() == 0);
 
      // clean up any attributes from the previous write
    geom_ptr->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
    while (list.size())
    {
      CubitSimpleAttrib csa = list.pop();
      geom_ptr->remove_simple_attribute_virt(csa);
    }
  }
  else
  {
    geom_ptr = entityList[0].entity;
 
      // clean up any attributes from the previous write
    for (int i = 0; i < entityList.size(); i++)
    {
      entityList[i].entity->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
      while (list.size())
      {
        CubitSimpleAttrib csa = list.pop();
        entityList[i].entity->remove_simple_attribute_virt(csa);
      } 
    }
  }
  
  
  CubitString name = COMPOSITE_DATA_ATTRIB_NAME;
  int count = entityList.size();
  CubitSimpleAttrib attrib;
  
  for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
  {
    attrib.string_data_list().push_back(name);
    attrib.int_data_list().push_back(count);
  
    ptr->append_to_csa(attrib);
    
    //append the name attribute on all the rest of the entities too.  This 
    //is so that if a one gets split, the results each get the name as well:
    //jack --> jack and jack@A
    if( ptr->name() == "ENTITY_NAME" )
    {
      for( int k=1; k<entityList.size(); k++ )
        entityList[k].entity->append_simple_attribute_virt( attrib );
    }

    geom_ptr->append_simple_attribute_virt(attrib);    
    
    attrib.string_data_list().clear();
    attrib.int_data_list().clear();
    attrib.double_data_list().clear();
  }
}
Ejemplo n.º 8
0
//-------------------------------------------------------------------------
// Purpose       : Remove all child partition geometry (body deleted)
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 04/04/03
//-------------------------------------------------------------------------
void PartitionBody::destroy_all_children()
{
  DLIList<PartitionLump*> lumps;
  DLIList<PartitionSurface*> surfs;
  DLIList<PartitionCoEdge*> coedges;
  DLIList<PartitionCurve*> curves;
  DLIList<PartitionPoint*> points;
  
  DLIList<PartitionEntity*> sub_geom, split_geom;
  for ( SubEntitySet* ptr = childList; ptr; ptr = ptr->next_in_body() )
  {
    ptr->get_sub_entities( sub_geom );
    ptr->get_lower_order( split_geom );
    sub_geom += split_geom;
    split_geom.clean_out();
    while( sub_geom.size() )
    { 
      PartitionEntity* ent = sub_geom.pop();
      if ( PartitionPoint* point = dynamic_cast<PartitionPoint*>(ent) )
        points.append(point);
      else if( PartitionCoEdge* coedge = dynamic_cast<PartitionCoEdge*>(ent) )
        coedges.append(coedge);
      else if( PartitionCurve* curve = dynamic_cast<PartitionCurve*>(ent) )
        curves.append(curve);
      else if( PartitionSurface* surf = dynamic_cast<PartitionSurface*>(ent) )
        surfs.append(surf);
      else if ( PartitionLump* lump = dynamic_cast<PartitionLump*>(ent) )
        lumps.append(lump);
      else
        assert(0);
    }
  }
  
  while( lumps.size() )
  {
    PartitionLump* lump = lumps.pop();
    while( PartitionShell* shell = lump->first_shell() )
    {
      lump->remove(shell);
      shell->remove_all_surfaces();
      delete shell;
    }
    delete lump;
  }

  while( surfs.size() )
  {
    PartitionSurface* surf = surfs.pop();
    while( PartitionLoop* loop = surf->next_loop(NULL) )
    {
      surf->remove(loop);
      loop->remove_all_coedges();
      delete loop;
    }
    delete surf;
  }

  while( coedges.size() )
  {
    PartitionCoEdge* coedge = coedges.pop();
    if (coedge->get_curve() != NULL)
       coedge->get_curve()->remove( coedge );
    delete coedge;
  }

  while( curves.size() )
  {
    PartitionCurve* curve = curves.pop();
    assert( !curve->next_coedge(NULL) );
    delete curve;
  }

  while( points.size() )
  {
    PartitionPoint* point = points.pop();
    assert( !point->num_curves() );
    delete point;
  }

  // All child SubEntitySets should have been deleted when they
  // became empty, and should be removed from the list in this
  // body as they are destroyed.  However, when the last SubEntitySet
  // in this body is destroyed, this body will be destroyed as well.
  // So don't do this check!
  //assert(!childList);
}
Ejemplo n.º 9
0
CubitStatus SimplifyTool::simplify_curves_in_volume(
    DLIList<RefEdge*> ref_edge_list, 
    double angle_in,
    DLIList<RefEdge*> respect_edge_list,
    DLIList<RefVertex*> respect_vertex_list,
    CubitBoolean respect_imprints,
    CubitBoolean local_normals,
    CubitBoolean preview)
{
  if(local_normals){
    PRINT_WARNING("When simplifying curves, 'local_normals' is currently ignored.\n");
  }
  
    if(ref_edge_list.size()==0)
    {
        PRINT_ERROR("No curves specified for simplification\n");
        return CUBIT_FAILURE;
    }
    else if(ref_edge_list.size() == 1)
    {
        PRINT_ERROR("Only one curve specified for simplification\n");
        return CUBIT_FAILURE;
    }

    RefVolume* ref_volume = ref_edge_list.get()->ref_volume();
    if (NULL == ref_volume)
    {
      PRINT_WARNING("Simplifying free curves is not supported.\n"); 
      return CUBIT_FAILURE;
    }

    DLIList<RefEdge*> seed_edges;
    DLIList<RefVertex*> preview_vertices;
    DLIList<RefVertex*> preview_removed;

    if(preview)
        ref_volume->ref_vertices(preview_vertices);

    int j,k;

    int new_edge_count = 0;
    int combined_edge_count = 0;
    ProgressTool *prog_ptr = 0;
    if(ref_edge_list.size() > 100 )
    {
        char title[200];
        if(preview)
            sprintf(title, "Previewing Volume %d",ref_volume->id());
        else
            sprintf(title, "Simplifying Curves in Volume %d",ref_volume->id());

        prog_ptr = AppUtil::instance()->progress_tool();
        assert(prog_ptr != NULL);
        prog_ptr->start(0,100, title);
    }
    int start_edge_count = ref_edge_list.size();
    while(ref_edge_list.size())
    {
        DLIList<RefEdge*> composite_edges;
        seed_edges.append_unique(ref_edge_list.pop());

        for ( j = ref_edge_list.size(); j--; )
            ref_edge_list.get_and_step()->marked( CUBIT_FALSE );

        while(seed_edges.size())
        {
            RefEdge *seed_ref_edge = seed_edges.pop();
            seed_ref_edge->marked(CUBIT_TRUE);

            composite_edges.append(seed_ref_edge);

            // Get the vertices
            DLIList<RefVertex*> ref_vertex_list;
            seed_ref_edge->ref_vertices( ref_vertex_list );
            RefVertex *ref_vertex_ptr;
            RefEdge *ref_edge_ptr;
            for( k = ref_vertex_list.size(); k--; )
            {
                ref_vertex_ptr = ref_vertex_list.get_and_step();

                // Don't go propagate across surface splits if the user asks for it
                GeometryFeatureTool* gft = GeometryFeatureTool::instance();
                if( respect_imprints &&
                    gft->feature_type(ref_vertex_ptr) == GeometryFeatureEngine::FEATURE_IMPRINT)
                    continue;

                // Don't cross a curve if we want it respected
                if(respect_vertex_list.is_in_list(ref_vertex_ptr))
                    continue;

                DLIList<RefEdge*> attached_ref_edges;
                ref_vertex_ptr->ref_edges( attached_ref_edges );

                attached_ref_edges.remove(seed_ref_edge);
                ref_edge_ptr = attached_ref_edges.size()!=0?attached_ref_edges.get():0;

                // keep the face if we want it respected
                if(attached_ref_edges.size() == 1 &&
                    respect_edge_list.is_in_list(attached_ref_edges.get()))
                    continue;

                // Don't consider ref_faces that are already in the list
                if( attached_ref_edges.size() == 1 &&
                    !ref_edge_ptr->marked())
                {
                    DLIList<RefVolume*> ref_volumes;
                    ref_edge_ptr->ref_volumes( ref_volumes );
                    if( !ref_volumes.size() || ref_volumes.size()==1 )
                    {
                        // Only add the ref_face if it meets the feature angle criteria
                        if(composite_curves(seed_ref_edge,ref_edge_ptr,angle_in))
                        {
                          ref_edge_ptr->marked( CUBIT_TRUE );
                          seed_edges.append(ref_edge_ptr);
                          composite_edges.append(ref_edge_ptr);
                        }
                    }
                }
            }
        }
        composite_edges.uniquify_unordered();
        ref_edge_list -= composite_edges;

        if(!preview &&
            composite_edges.size()>1)
        {
            DLIList<RefVertex*> result_vertices;
            DLIList<RefEdge*> result_edges;
            CompositeTool::instance()->composite(
                composite_edges,
                result_edges,
                &result_vertices);

            combined_edge_count +=composite_edges.size();
            for(int m = result_edges.size();m--;)
                result_edges.get_and_step()->marked(CUBIT_TRUE);

            new_edge_count+=result_edges.size();
        }
        else if(preview)
        {
            int edge_count = composite_edges.size();
            for(int i =0;i<edge_count;i++)
            {
                RefEdge* cur_comp_edge = composite_edges[i];
                DLIList<RefVertex*> refvertices; 
                for(int j =0;j<edge_count;j++)
                {
                    if(i==j) continue;
                    composite_edges[j]->ref_vertices(refvertices);
                }

                refvertices.uniquify_unordered();

                DLIList<RefVertex*> temp_refvertices; 
                cur_comp_edge->ref_vertices(temp_refvertices);
                refvertices.intersect_unordered(temp_refvertices);
                preview_removed+=refvertices;
            }
        }

        if(prog_ptr)
        {
            double frac = 1.0-(double)ref_edge_list.size()/(double)start_edge_count;
            prog_ptr->percent(frac);
        }
    }

    if(prog_ptr)
    {
        prog_ptr->end();
        prog_ptr = 0;
    }

    if(preview)
    {
        preview_vertices -=preview_removed;
        for(int c = preview_vertices.size();c--;)
            GfxDebug::draw_ref_vertex(preview_vertices.get_and_step(),7);
    }
    else if(combined_edge_count>new_edge_count)
    {
        PRINT_INFO("Simplified %d curves into %d curves\n",
            combined_edge_count,
            new_edge_count);
	}

	// make sure to set all of the surface markers to false
	DLIList<RefEdge*> marked_edge_list;
	ref_volume->ref_edges(marked_edge_list);
	for(int i =0;i<marked_edge_list.size();i++)
		marked_edge_list[i]->marked(CUBIT_FALSE);

    return CUBIT_SUCCESS;
}