cgma
FacetShell Class Reference

#include <FacetShell.hpp>

Inheritance diagram for FacetShell:
ShellSM TopologyBridge

List of all members.

Public Member Functions

 FacetShell (Lump *my_lump, DLIList< Surface * > &my_surfs)
 FacetShell (DLIList< Surface * > &my_surfs)
virtual ~FacetShell ()
void add_lump (Lump *lump_ptr)
virtual GeometryQueryEngineget_geometry_query_engine () const
virtual void append_simple_attribute_virt (const CubitSimpleAttrib &)
virtual void remove_simple_attribute_virt (const CubitSimpleAttrib &)
virtual void remove_all_simple_attribute_virt ()
virtual CubitStatus get_simple_attribute (DLIList< CubitSimpleAttrib > &)
virtual CubitStatus get_simple_attribute (const CubitString &name, DLIList< CubitSimpleAttrib > &)
void get_lumps (DLIList< FacetLump * > &lumps)
void get_surfaces (DLIList< FacetSurface * > &surfaces)
void get_coedges (DLIList< FacetCoEdge * > &coedges)
void get_curves (DLIList< FacetCurve * > &curves)
void get_parents_virt (DLIList< TopologyBridge * > &parents)
void get_children_virt (DLIList< TopologyBridge * > &children)
Lumpget_lump () const
void remove_lump ()
void disconnect_surfaces (DLIList< FacetSurface * > &surfs_to_disconnect)
void disconnect_all_surfaces ()
void reverse ()
void reverse_surfaces ()
CubitPointContainment point_containment (const CubitVector &point, double tolerance=-1.0)
CubitBoolean is_sheet ()

Private Attributes

LumpmyLump
DLIList< Surface * > mySurfs

Detailed Description

Definition at line 35 of file FacetShell.hpp.


Constructor & Destructor Documentation

FacetShell::FacetShell ( Lump my_lump,
DLIList< Surface * > &  my_surfs 
)

Definition at line 53 of file FacetShell.cpp.

{
  myLump = my_lump;
  mySurfs += my_surfs;
}
FacetShell::FacetShell ( DLIList< Surface * > &  my_surfs)

Definition at line 66 of file FacetShell.cpp.

{
  myLump = NULL; 
  mySurfs += my_surfs;
}
FacetShell::~FacetShell ( ) [virtual]

Definition at line 77 of file FacetShell.cpp.

{}

Member Function Documentation

void FacetShell::add_lump ( Lump lump_ptr)

Definition at line 173 of file FacetShell.cpp.

{
  assert(NULL == myLump);
  myLump = lump_ptr;
}

Implements TopologyBridge.

Definition at line 93 of file FacetShell.cpp.

{
}

Definition at line 267 of file FacetShell.cpp.

{
  mySurfs.reset();
  for (int i = mySurfs.size(); i--; )
  {
    Surface* sm_ptr = mySurfs.get_and_step();
    FacetSurface* surface = dynamic_cast<FacetSurface*>(sm_ptr);
    if (surface)
      surface->remove_shell(this);
  }
  mySurfs.clean_out();
}
void FacetShell::disconnect_surfaces ( DLIList< FacetSurface * > &  surfs_to_disconnect)

Definition at line 243 of file FacetShell.cpp.

{
  for (int i = surfs_to_disconnect.size(); i--; )
  {
    FacetSurface* surface = surfs_to_disconnect.get_and_step();
    if( mySurfs.move_to( dynamic_cast<Surface*>(surface) ) )
      mySurfs.change_to(NULL);

    if (surface)
      surface->remove_shell(this);
  }
  mySurfs.remove_all_with_value( NULL );
}
void FacetShell::get_children_virt ( DLIList< TopologyBridge * > &  children) [virtual]

Implements TopologyBridge.

Definition at line 191 of file FacetShell.cpp.

  { CAST_LIST_TO_PARENT( mySurfs, children ); }
void FacetShell::get_coedges ( DLIList< FacetCoEdge * > &  coedges)

Definition at line 211 of file FacetShell.cpp.

{
  DLIList<FacetSurface*> surface_list;
  get_surfaces( surface_list );
  surface_list.reset();
  for ( int i = 0; i < surface_list.size(); i++ )
    surface_list.next(i)->get_coedges( result_list );
}
void FacetShell::get_curves ( DLIList< FacetCurve * > &  curves)

Definition at line 220 of file FacetShell.cpp.

{
  DLIList<FacetCoEdge*> coedge_list;
  get_coedges( coedge_list );
  coedge_list.reset();
  for ( int i = coedge_list.size(); i--; )
  {
    FacetCoEdge* coedge = coedge_list.get_and_step();
    FacetCurve* curve = dynamic_cast<FacetCurve*>(coedge->curve());
    if (curve)
      result_list.append_unique(curve);
  }
}

Implements TopologyBridge.

Definition at line 88 of file FacetShell.cpp.

Lump* FacetShell::get_lump ( ) const [inline]

Definition at line 107 of file FacetShell.hpp.

{ return myLump; }
void FacetShell::get_lumps ( DLIList< FacetLump * > &  lumps)

Definition at line 195 of file FacetShell.cpp.

{
  FacetLump* lump = dynamic_cast<FacetLump*>(myLump);
  if (lump)
    result_list.append(lump);
}
void FacetShell::get_parents_virt ( DLIList< TopologyBridge * > &  parents) [virtual]

Implements TopologyBridge.

Definition at line 189 of file FacetShell.cpp.

  { parents.append(myLump); }

Implements TopologyBridge.

Definition at line 102 of file FacetShell.cpp.

{
  return CUBIT_FAILURE;
}

Implements TopologyBridge.

Definition at line 106 of file FacetShell.cpp.

  { return CUBIT_FAILURE; }
void FacetShell::get_surfaces ( DLIList< FacetSurface * > &  surfaces)

Definition at line 202 of file FacetShell.cpp.

{
  mySurfs.reset();
  for ( int i = 0; i < mySurfs.size(); i++ )
    if ( FacetSurface* surf = dynamic_cast<FacetSurface*>(mySurfs.next(i)) )
      result_list.append_unique(surf);
}

Definition at line 446 of file FacetShell.cpp.

{
    //get a list of all the facets in the sheet
  DLIList<CubitFacet*> facet_list;
  int i;
  for (i = mySurfs.size(); i--; )
  {
    FacetSurface* surf = dynamic_cast<FacetSurface*>(mySurfs.next(i));
    surf->tris(facet_list);
  }
    //should be unique... doesn't hurt anything if it isn't
  //facet_list.uniquify_ordered();
  CubitFacet* this_facet;
  CubitPoint* node_1;
  CubitPoint* node_2;
  CubitPoint* node_3;
    //if any of the facets don't have another facet across a given
    // edge... this is a sheet shell because it isn't closed.
  for (i = facet_list.size(); i--; ){
    this_facet=facet_list.get_and_step();
    if(!this_facet){
      PRINT_ERROR("Unexpected NULL pointer.");
      return CUBIT_TRUE;
    }
    this_facet->tri_nodes(node_1,node_2,node_3);
    if(!this_facet->shared_facet( node_1, node_2 ) ||
       !this_facet->shared_facet( node_1, node_3 ) ||
       !this_facet->shared_facet( node_2, node_3 ) ){
      return CUBIT_TRUE;
    }
  }
    //otherwise we made it through without finding a gap so it is close...
    // thus not a sheet.
  return CUBIT_FALSE;
}
CubitPointContainment FacetShell::point_containment ( const CubitVector point,
double  tolerance = -1.0 
)

Definition at line 326 of file FacetShell.cpp.

{
    //just to avoid crashes, make sure we have surfaces in this list.
  if(mySurfs.size() < 1){
    return CUBIT_PNT_OUTSIDE;
  }
  CubitVector closest_location, point = input_point;
  FacetSurface *closest_surf = dynamic_cast<FacetSurface*>(mySurfs.get_and_step());
  FacetSurface *tmp_surf;
  closest_surf->closest_point_trimmed( point, closest_location ); 
  double shortest_dist = point.distance_between( closest_location );

  int i;
  //Look through all this shell's surfaces to find the closest
  //surface to input_point

  for(i=mySurfs.size()-1; i--;)
  {
    CubitVector tmp_closest_location; 
    tmp_surf = dynamic_cast<FacetSurface*>(mySurfs.get_and_step());
    tmp_surf->closest_point_trimmed( point, tmp_closest_location ); 

    double tmp_shortest_dist = point.distance_between( tmp_closest_location );
    if( tmp_shortest_dist < shortest_dist ) 
    {
      closest_location = tmp_closest_location;
      closest_surf = tmp_surf;
      shortest_dist = tmp_shortest_dist;
    }
  }

  if( tolerance < 0 )
    tolerance = GEOMETRY_RESABS;  

  //determine if it's on the surface, inside or outside
  if( shortest_dist <= tolerance )
    return CUBIT_PNT_BOUNDARY;

  //find the closest facet on that surface to input_point
  CubitFacet *closest_facet = closest_surf->get_eval_tool()->closest_facet( closest_location );
  
  //get the coordinates of the closest point 
  CubitPoint *pt1 = NULL;
  CubitPoint *pt2 = NULL;
  closest_facet->closest_point_trimmed( point, closest_location, pt1, pt2 );

  CubitVector normal;
  CubitPoint *on_point = NULL;
  //case 1: point is closest to an edge of the facet
  if( pt1 || pt2 )
  {
      //only returned one, so the it is closest to a node
    if(!pt2){
      on_point = pt1;
    }
    else if(!pt1){
      on_point = pt2;
    }
    else{//double-check that we are not closest to a single node
      
      if((pt1->coordinates().distance_between(closest_location)) <= tolerance ) 
        on_point = pt1;
      else if((pt2->coordinates().distance_between(closest_location)) <= tolerance )
        on_point = pt2;
    }
    
    if( on_point )
    {
      //get all facets that share this point
      DLIList<CubitFacet*> facets_sharing_point;
      on_point->facets( facets_sharing_point );

      for(i=facets_sharing_point.size(); i--; )
        normal += facets_sharing_point.get_and_step()->normal();

      //average the normals of all these facets 
      normal /= facets_sharing_point.size();
    }
    else
    {
      //case 2: get the 2 normals of the 2 neighboring facets and average them
      int index;
      CubitFacetEdge *shared_facet_edge; 
      shared_facet_edge = closest_facet->edge_from_pts( pt1, pt2, index);
      CubitFacet *other_facet = shared_facet_edge->other_facet( closest_facet );
      if(!other_facet){
        PRINT_ERROR("Edge is not connected to two facets.\n");
        normal = closest_facet->normal();
      }
      else{
        normal = ( closest_facet->normal() + other_facet->normal() ) / 2;
      }
    }
  }
  else
  {
    //case 3: just get the normal of this facet
    normal = closest_facet->normal();
  }

//   if ( closest_surf->get_relative_surface_sense() == CUBIT_REVERSED )
//   {
//     PRINT_WARNING("mbrewer:  This shouldn't happen anymore.\n");
//     normal = -1.0*( normal );
//   }
  
  ShellSM *shell_sm = static_cast<ShellSM*>(this);
  if( closest_surf->get_shell_sense( shell_sm ) == CUBIT_REVERSED )
  {
    normal = -1.0*( normal );
  }
  if( (point-closest_location)%(normal) > 0 )
    return CUBIT_PNT_OUTSIDE;
  else
    return CUBIT_PNT_INSIDE;
}

Implements TopologyBridge.

Definition at line 99 of file FacetShell.cpp.

{
}
void FacetShell::remove_lump ( ) [inline]

Definition at line 109 of file FacetShell.hpp.

{ myLump = 0; }

Implements TopologyBridge.

Definition at line 96 of file FacetShell.cpp.

{
}

Definition at line 289 of file FacetShell.cpp.

{
  for (int i = mySurfs.size(); i--; )
  {
    FacetSurface* surf = dynamic_cast<FacetSurface*>(mySurfs.next(i));
    CubitSense sense = surf->get_shell_sense( this );
    assert( CUBIT_UNKNOWN != sense );
    surf->set_shell_sense( this, CubitUtil::opposite_sense( sense ) );
  }
}

Definition at line 309 of file FacetShell.cpp.

{
  for (int i = mySurfs.size(); i--; )
  {
    FacetSurface* surf = dynamic_cast<FacetSurface*>(mySurfs.next(i));
    surf->reverse_sense();
  }
}

Member Data Documentation

Definition at line 130 of file FacetShell.hpp.

Definition at line 131 of file FacetShell.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines