コード例 #1
0
ファイル: PartitionBody.cpp プロジェクト: chrismullins/cgma
//-------------------------------------------------------------------------
// Purpose       : get bounding box
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 02/14/03
//-------------------------------------------------------------------------
CubitBox PartitionBody::bounding_box() const
{
  DLIList<TopologyBridge*> lumps;
  real_body()->get_children_virt(lumps);
  
  CubitBox result = dynamic_cast<Lump*>(lumps.step_and_get())->bounding_box();
  for( int i = 1; i < lumps.size(); i++ )
    result |= dynamic_cast<Lump*>(lumps.step_and_get())->bounding_box();
  
  return result;
}
コード例 #2
0
ファイル: CompositeGeom.cpp プロジェクト: chrismullins/cgma
//-------------------------------------------------------------------------
// Purpose       : Get all attributes
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 06/18/02
//-------------------------------------------------------------------------
void CompositeGeom::get_attributes( DLIList<CubitSimpleAttrib>& list )
{
    // special case: single-entity 'composite'
  if (entityList.size() == 1)
  {
    TopologyBridge* entity = entityList[0].entity;
    entity->get_simple_attribute(list);
    
      // handle 8.1 attribs on single-entity 'composites'
    for (int i = list.size(); i--; )
    {
      const CubitSimpleAttrib& attrib = list.step_and_get();
      if (attrib.character_type() == COMPOSITE_DATA_ATTRIB_NAME &&
          attrib.int_data_list()[0] == 1)
      {
        entity->remove_simple_attribute_virt(attrib);
        CubitSimpleAttrib newattrib = attrib;
        newattrib.string_data_list().erase(newattrib.string_data_list().begin());
        newattrib.int_data_list().erase(newattrib.int_data_list().begin());
        entity->append_simple_attribute_virt(newattrib);
      }
    }
  }
      
    
  for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
    list.append(ptr->csa());
}
コード例 #3
0
GeomDataObserver* GeomDataObserver::get( RefEntity* on_this )
{
   DLIList<CubitObserver*> list;
   GeomDataObserver* eo = NULL;

   on_this->get_observer_list(list);
   for (int i = list.size(); i--; )
   {
     if ( (eo = dynamic_cast<GeomDataObserver*>(list.step_and_get()) ))
        break;
   }
   return eo;
}
コード例 #4
0
ファイル: PartitionShell.cpp プロジェクト: chrismullins/cgma
CubitStatus PartitionShell::mass_properties( CubitVector& centroid, 
                                             double& volume )
{
  PartitionCoSurf* cosurf = 0;
  DLIList<CubitFacetData*> facets;
  CubitVector p1, p2, p3, normal;
  const CubitVector p0(0.0, 0.0, 0.0);
  centroid.set(0.0, 0.0, 0.0 );
  volume = 0.0;
  
  while ((cosurf = next_co_surface( cosurf )))
  {
    if (is_nonmanifold( cosurf->get_surface() ))
      continue;
    
    facets.clean_out();
    cosurf->get_surface()->get_facet_data( facets );
    
    for (int i = facets.size(); i--; )
    {
      CubitFacet* facet = facets.step_and_get();
      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 (cosurf->sense() == CUBIT_REVERSED)
          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;
}
コード例 #5
0
ファイル: CubitFacetEdge.cpp プロジェクト: chrismullins/cgma
// 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;
}
コード例 #6
0
ファイル: FacetLump.cpp プロジェクト: chrismullins/cgma
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;
}