cgma
OCCLump Class Reference

#include <OCCLump.hpp>

Inheritance diagram for OCCLump:
Lump GeometryEntity TopologyBridge

List of all members.

Public Member Functions

 OCCLump (TopoDS_Solid *theSolid, OCCSurface *surface=NULL, OCCShell *shell=NULL)
OCCSurfacemy_sheet_surface ()
OCCShellmy_shell ()
void set_surface (OCCSurface *surface)
void set_shell (OCCShell *shell)
virtual ~OCCLump ()
void add_body (BodySM *new_body)
TopoDS_Solid * get_TopoDS_Solid ()
void set_TopoDS_Solid (TopoDS_Solid solid)
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 > &)
virtual CubitBox bounding_box () const
virtual GeometryQueryEngineget_geometry_query_engine () const
virtual CubitStatus merge (GeometryEntity *)
virtual TopologyEntityunmerge (DLIList< RefVolume * >)
virtual double measure ()
virtual void get_parents_virt (DLIList< TopologyBridge * > &parents)
virtual void get_children_virt (DLIList< TopologyBridge * > &children)
BodySMget_body () const
void remove_body ()
CubitStatus mass_properties (CubitVector &centroid, double &volume)
CubitPointContainment point_containment (const CubitVector &point)
CubitStatus update_OCC_entity (BRepBuilderAPI_ModifyShape *aBRepTrsf, BRepAlgoAPI_BooleanOperation *op=NULL)

Static Public Member Functions

static CubitStatus update_OCC_entity (TopoDS_Solid &old_shape, TopoDS_Shape &new_shape, BRepBuilderAPI_MakeShape *op, LocOpe_SplitShape *sp=NULL)

Private Attributes

BodySMmyBodyPtr
TopoDS_Solid * myTopoDSSolid
OCCSurfacemySheetSurface
OCCShellmyShell

Detailed Description

Definition at line 44 of file OCCLump.hpp.


Constructor & Destructor Documentation

OCCLump::OCCLump ( TopoDS_Solid *  theSolid,
OCCSurface surface = NULL,
OCCShell shell = NULL 
)

Definition at line 72 of file OCCLump.cpp.

{
  myTopoDSSolid = theSolid;
  mySheetSurface = surface;
  myShell = shell;
  if(myTopoDSSolid && !myTopoDSSolid->IsNull())
    assert(myTopoDSSolid->ShapeType() == TopAbs_SOLID);
}
OCCLump::~OCCLump ( ) [virtual]

Definition at line 81 of file OCCLump.cpp.

{ 
  if (myTopoDSSolid)
  {
    myTopoDSSolid->Nullify();
    delete myTopoDSSolid;
  }
}

Member Function Documentation

void OCCLump::add_body ( BodySM new_body) [inline]

Definition at line 59 of file OCCLump.hpp.

    {myBodyPtr = new_body;}

Implements TopologyBridge.

Definition at line 136 of file OCCLump.cpp.

{ 
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;
  OCCAttribSet::append_attribute(csa, shape); 
}
CubitBox OCCLump::bounding_box ( void  ) const [virtual]

Implements GeometryEntity.

Definition at line 235 of file OCCLump.cpp.

{
  Bnd_Box box;
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;

  //calculate the bounding box
  BRepBndLib::Add(shape, box);
  double min[3], max[3];

  //get values
  box.Get(min[0], min[1], min[2], max[0], max[1], max[2]);

  //update boundingbox.
  CubitBox cBox(min, max);
  return cBox;
}

Definition at line 301 of file OCCLump.cpp.

{
  if(mySheetSurface)
    return mySheetSurface->my_body();
  if(myShell)
    return myShell->my_body();
  return myBodyPtr;
}
void OCCLump::get_children_virt ( DLIList< TopologyBridge * > &  children) [virtual]

Implements TopologyBridge.

Definition at line 310 of file OCCLump.cpp.

{
  if (mySheetSurface)
  {
    shellsms.append(mySheetSurface->my_shell());
    return;
  }
  else if(myShell)
  {
    shellsms.append(myShell);
    return;
  }
  TopTools_IndexedMapOfShape M;
  TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
  int ii;
  for (ii=1; ii<=M.Extent(); ii++) {
      TopologyBridge *shell = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
          if (shell)
        shellsms.append_unique(shell);
  }
}

Implements TopologyBridge.

Definition at line 265 of file OCCLump.cpp.

void OCCLump::get_parents_virt ( DLIList< TopologyBridge * > &  parents) [virtual]

Implements TopologyBridge.

Definition at line 291 of file OCCLump.cpp.

{
  if(mySheetSurface)
    bodies.append(mySheetSurface->my_body());
  else if (myShell)
    bodies.append(myShell->my_body());
  else
    bodies.append(myBodyPtr);
}

Implements TopologyBridge.

Definition at line 203 of file OCCLump.cpp.

{ 
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;
  return OCCAttribSet::get_attributes(shape, csa_list ); 
}
CubitStatus OCCLump::get_simple_attribute ( const CubitString name,
DLIList< CubitSimpleAttrib > &  csa_list 
) [virtual]

Implements TopologyBridge.

Definition at line 215 of file OCCLump.cpp.

{
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;
  return OCCAttribSet::get_attributes( name, shape, csa_list ); 
}
TopoDS_Solid* OCCLump::get_TopoDS_Solid ( ) [inline]

Definition at line 62 of file OCCLump.hpp.

  {if(myTopoDSSolid && !myTopoDSSolid->IsNull()) assert (myTopoDSSolid->ShapeType() == TopAbs_SOLID); return myTopoDSSolid; }
CubitStatus OCCLump::mass_properties ( CubitVector centroid,
double &  volume 
) [virtual]

Implements Lump.

Definition at line 109 of file OCCLump.cpp.

{
  if (mySheetSurface || myShell)
    return CUBIT_FAILURE;

  GProp_GProps myProps;
  BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
  volume = myProps.Mass();
  gp_Pnt pt = myProps.CentreOfMass();
  centroid.set(pt.X(), pt.Y(), pt.Z());

  return CUBIT_SUCCESS;
}
double OCCLump::measure ( ) [virtual]

Implements GeometryEntity.

Definition at line 279 of file OCCLump.cpp.

{
  if(mySheetSurface) 
    return mySheetSurface->measure();
  else if(myShell)
    return myShell->measure();

  GProp_GProps myProps;
  BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
  return myProps.Mass();
}
virtual CubitStatus OCCLump::merge ( GeometryEntity ) [inline, virtual]

Definition at line 116 of file OCCLump.hpp.

    {
      PRINT_ERROR("BUG: In OCCLump::merge\n"
                  "     This function should not be called at all\n"
                  "  This is a Bug -- please report it!\n");
      return CUBIT_FAILURE;
    }

Definition at line 51 of file OCCLump.hpp.

{return mySheetSurface;}
OCCShell* OCCLump::my_shell ( ) [inline]

Definition at line 52 of file OCCLump.hpp.

{return myShell;}

Definition at line 334 of file OCCLump.cpp.

{
  if (mySheetSurface || myShell)
    return CUBIT_PNT_UNKNOWN;

  TopoDS_Solid * solid = get_TopoDS_Solid();
  gp_Pnt pnt(point.x(), point.y(), point.z());
  BRepClass3d_SolidExplorer ex(*solid);
   
  //use face tolerance at the tolerence to see if the point is on.
  TopExp_Explorer Ex;
  Ex.Init(*solid, TopAbs_FACE);
  TopoDS_Face face = TopoDS::Face(Ex.Current());
  
  double dtol = BRep_Tool::Tolerance(face);
  BRepClass3d_SClassifier ps(ex, pnt, dtol);
  
  TopAbs_State state = ps.State();
  if (state == TopAbs_IN)
     return CUBIT_PNT_INSIDE;
  else if (state == TopAbs_OUT)
     return CUBIT_PNT_OUTSIDE;
  else if (state == TopAbs_ON)
     return CUBIT_PNT_BOUNDARY;

  return CUBIT_PNT_UNKNOWN;
  
}

Implements TopologyBridge.

Definition at line 183 of file OCCLump.cpp.

{ 
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;
  OCCAttribSet::remove_attribute(CubitSimpleAttrib(), shape);
}
void OCCLump::remove_body ( ) [inline]

Definition at line 145 of file OCCLump.hpp.

{myBodyPtr = 0;}

Implements TopologyBridge.

Definition at line 159 of file OCCLump.cpp.

{ 
  TopoDS_Shape shape;
  if(mySheetSurface)
    shape = *(mySheetSurface->get_TopoDS_Face());
  else if(myShell)
    shape = *(myShell->get_TopoDS_Shell());
  else
    shape =*myTopoDSSolid;
  OCCAttribSet::remove_attribute(csa, shape); 
}
void OCCLump::set_shell ( OCCShell shell) [inline]

Definition at line 54 of file OCCLump.hpp.

{myShell = shell;}
void OCCLump::set_surface ( OCCSurface surface) [inline]

Definition at line 53 of file OCCLump.hpp.

{mySheetSurface = surface;}
void OCCLump::set_TopoDS_Solid ( TopoDS_Solid  solid)

Definition at line 90 of file OCCLump.cpp.

{
  if(myTopoDSSolid && solid.IsEqual(*myTopoDSSolid) )
    return;

  if(myTopoDSSolid)
    myTopoDSSolid->Nullify() ;

  *myTopoDSSolid = solid;
}
virtual TopologyEntity* OCCLump::unmerge ( DLIList< RefVolume * >  ) [inline, virtual]

Definition at line 124 of file OCCLump.hpp.

    {
      PRINT_ERROR( "BUG: In OCCLump::unmerge\n"
                   "     This function should not be called\n"
                   "  This is a Bug -- please report it!\n" );
      return (TopologyEntity*)NULL;
    }
CubitStatus OCCLump::update_OCC_entity ( BRepBuilderAPI_ModifyShape *  aBRepTrsf,
BRepAlgoAPI_BooleanOperation *  op = NULL 
)

Definition at line 368 of file OCCLump.cpp.

{
  if(mySheetSurface || myShell)
    return CUBIT_FAILURE;

  assert(aBRepTrsf != NULL || op != NULL);
 
  TopoDS_Shape shape;
  if(aBRepTrsf)
    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Solid());

  else
  {
    TopTools_ListOfShape shapes;
    shapes.Assign(op->Modified(*get_TopoDS_Solid()));
    if(shapes.Extent() == 0)
      shapes.Assign(op->Generated(*get_TopoDS_Solid()));
    if(shapes.Extent() > 1)
    { 
      //update all attributes first.
      TopTools_ListIteratorOfListOfShape it;
      it.Initialize(shapes);
      for(; it.More(); it.Next())
      {
        shape = it.Value();
        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Solid(), 
                                                    shape);
      }
      shape = shapes.First();
    }
    else if (shapes.Extent() == 1)
      shape = shapes.First();
    else if(op->IsDeleted(*get_TopoDS_Solid()))
      ;
    else
      return CUBIT_SUCCESS;
  }
  
  TopoDS_Solid solid;
  if(aBRepTrsf || !op->IsDeleted(*get_TopoDS_Solid()))
    solid = TopoDS::Solid(shape);

  //set the lumps
  DLIList<TopologyBridge *> shells;
  this->get_children_virt(shells);
  for (int i = 1; i <= shells.size(); i++)
  {
     OCCShell *shell = CAST_TO(shells.get_and_step(), OCCShell);
     shell->update_OCC_entity(aBRepTrsf, op);
  }
  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);

  return CUBIT_SUCCESS;
}
CubitStatus OCCLump::update_OCC_entity ( TopoDS_Solid &  old_shape,
TopoDS_Shape &  new_shape,
BRepBuilderAPI_MakeShape *  op,
LocOpe_SplitShape *  sp = NULL 
) [static]

Definition at line 429 of file OCCLump.cpp.

{
  //set the Shells
  TopTools_IndexedMapOfShape M;
  TopoDS_Shape shape, shape2;
  TopExp::MapShapes(new_shape, TopAbs_SOLID,M);
  TopoDS_Solid new_solid;
  CubitBoolean isCompound = CUBIT_FALSE;
  if(M.Extent() > 1 )
    isCompound = CUBIT_TRUE;

  if(M.Extent() == 1 )
    new_solid = TopoDS::Solid(M(1));  

  M.Clear();
  TopExp::MapShapes(old_solid, TopAbs_SHELL, M);
  TopTools_ListOfShape shapes;
 
  for(int ii=1; ii<=M.Extent(); ii++)
  {
    TopoDS_Shell shell = TopoDS::Shell(M(ii));

    TopTools_ListOfShape shapes;
    TopTools_IndexedMapOfShape M2;
    if (op)
    {
      shapes.Assign(op->Modified(shell));
      if(shapes.Extent() == 0)
         shapes.Assign(op->Generated(shell));
      // bug fix for hollow operation, in which a new shell is genearted
      // but the shapes we get from old_shell->Generated() is still old_shell
      // not the new one.
      if(!new_solid.IsNull())  
         TopExp::MapShapes(new_solid, TopAbs_SHELL, M2);
    }
    else if(sp)
      shapes.Assign(sp->DescendantShapes(shell));

    if (shapes.Extent() == 1)
    {
      shape = shapes.First(); 
      if(M2.Extent() > 0)
        shape2 = TopoDS::Shell(M2(1)); 
      if(M2.Extent() == 1 && !shape.IsSame(shape2))
         shape = shape2;
      else if(M2.Extent() > 1)
      {
         shapes.Clear(); 
         for(int jj = 1; jj <= M2.Extent(); jj++) 
           shapes.Append(M2(jj));
      }
    }

    else if(shapes.Extent() > 1)
    {
      //update all attributes first.
      TopTools_ListIteratorOfListOfShape it;
      it.Initialize(shapes);
      for(; it.More(); it.Next())
      {
        shape = it.Value();
        OCCQueryEngine::instance()->copy_attributes(shell, shape);
      }
      shape = shapes.First();
    }
    else if(op->IsDeleted(shell))
    {
       TopTools_IndexedMapOfShape M_new;
       TopExp::MapShapes(new_shape, TopAbs_SHELL, M_new);
       if (M_new.Extent()== 1)
         shape = M_new(1);
       else
         shape.Nullify();
    }
    else
    {
       shape = shell;
       continue;
    }
 
    if(shapes.Extent() > 0 || (op && op->IsDeleted(shell)))
      OCCShell::update_OCC_entity(shell, shape, op, sp);
  }
  if(!new_solid.IsNull() && !old_solid.IsSame(new_solid))
    OCCQueryEngine::instance()->update_OCC_map(old_solid, new_solid);
  else if(isCompound)
    OCCQueryEngine::instance()->update_OCC_map(old_solid, new_shape);  
  return CUBIT_SUCCESS;
}

Member Data Documentation

Definition at line 160 of file OCCLump.hpp.

Definition at line 164 of file OCCLump.hpp.

Definition at line 165 of file OCCLump.hpp.

TopoDS_Solid* OCCLump::myTopoDSSolid [private]

Definition at line 162 of file OCCLump.hpp.


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