[cgma-dev] r1778 - cgm/trunk/geom/OCC

Jason Kraftcheck kraftche at cae.wisc.edu
Thu May 15 15:01:50 CDT 2008


janehu at mcs.anl.gov wrote:
> Author: janehu
> Date: 2008-04-25 14:24:47 -0500 (Fri, 25 Apr 2008)
> New Revision: 1778
> 
> Modified:
>    cgm/trunk/geom/OCC/Makefile.am
>    cgm/trunk/geom/OCC/OCCBody.cpp
>    cgm/trunk/geom/OCC/OCCCurve.cpp
>    cgm/trunk/geom/OCC/OCCCurve.hpp
>    cgm/trunk/geom/OCC/OCCLoop.cpp
>    cgm/trunk/geom/OCC/OCCLump.cpp
>    cgm/trunk/geom/OCC/OCCModifyEngine.cpp
>    cgm/trunk/geom/OCC/OCCPoint.cpp
>    cgm/trunk/geom/OCC/OCCQueryEngine.cpp
>    cgm/trunk/geom/OCC/OCCQueryEngine.hpp
>    cgm/trunk/geom/OCC/OCCShell.cpp
>    cgm/trunk/geom/OCC/OCCShell.hpp
>    cgm/trunk/geom/OCC/OCCSurface.cpp
> Log:
> Modified to delete free curves after a unite operation.
> 



Jane,

Several files in the checkin below reference a "OCCCoFace" class and related
files.  These files have not been checked in, thus the CGM build is broken
if configured with OCC support.

- jason



> Modified: cgm/trunk/geom/OCC/Makefile.am
> ===================================================================
> --- cgm/trunk/geom/OCC/Makefile.am	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/Makefile.am	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -33,6 +33,7 @@
>      OCCAttribSet.cpp \
>      OCCBody.cpp \
>      OCCCoEdge.cpp \
> +    OCCCoFace.cpp \
>      OCCCurve.cpp \
>      OCCLoop.cpp \
>      OCCLump.cpp \
> 
> Modified: cgm/trunk/geom/OCC/OCCBody.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -102,6 +102,7 @@
>  
>  OCCBody::~OCCBody() 
>  {
> +  delete myTopoDSShape;
>  }
>  
>  GeometryQueryEngine* OCCBody::get_geometry_query_engine() const
> 
> Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -111,7 +111,7 @@
>  //-------------------------------------------------------------------------
>  OCCCurve::~OCCCurve() 
>  {
> -  assert(myLoopList.size() == 0);  
> +  delete myTopoDSEdge;
>  }
>  
>  //-------------------------------------------------------------------------
> 
> Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCCurve.hpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCCurve.hpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -45,7 +45,7 @@
>  {
>  public :
>    
> -  OCCCurve( TopoDS_Edge *theEdge );
> +  OCCCurve( TopoDS_Edge* theEdge );
>    
>    virtual ~OCCCurve() ;
>      //- The destructor
> 
> Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -62,6 +62,7 @@
>  OCCLoop::~OCCLoop()
>  {
>    disconnect_all_curves();
> +  delete myTopoDSWire;
>  }
>  
>  //-------------------------------------------------------------------------
> 
> Modified: cgm/trunk/geom/OCC/OCCLump.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -73,7 +73,7 @@
>  }
>  
>  OCCLump::~OCCLump()
> -{}
> +{ delete myTopoDSSolid;}
>  
>  //-------------------------------------------------------------------------
>  // Purpose       : Find centroid
> 
> Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -119,7 +119,6 @@
>  #include "AppUtil.hpp"
>  #include "SphereEvaluator.hpp"
>  #include "CylinderEvaluator.hpp"
> -
>  OCCModifyEngine* OCCModifyEngine::instance_ = 0;
>  
>  //===============================================================================
> @@ -1595,6 +1594,7 @@
>         delete shell->my_lump();
>         shell->set_body(NULL);
>         shell->set_lump(NULL);
> +
>         TopoDS_Shell* topods_shell = shell->get_TopoDS_Shell();
>         if(topods_shell)
>            faces_to_stitch.append(topods_shell);
> @@ -1629,8 +1629,20 @@
>              new_shape = shapes.First();
>              OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
>            }
> -          //else
> -          //  OCCSurface::update_OCC_entity(face, face, &fuser);
> +          else if(fuser.IsDeleted(face))
> +          {
> +            TopoDS_Face null_face;
> +            int k = OCCSurface::update_OCC_entity(face, null_face, &fuser);
> +            std::map<int, TopologyBridge*>::iterator it =  
> +                OCCQueryEngine::instance()->OccToCGM->find(k);
> +            TopologyBridge* tb = NULL;
> +            if (it != OCCQueryEngine::instance()->OccToCGM->end())
> +     	    {
> +              OCCQueryEngine::instance()->OccToCGM->erase(k);
> +              tb = (*it).second;
> +              delete tb;
> +   	    }
> +          }
>          }
>        } 
>  
> 
> Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -82,6 +82,7 @@
>  //-------------------------------------------------------------------------
>  OCCPoint::~OCCPoint() 
>  {
> +  delete myTopoDSVertex;
>  }
>  
>  //-------------------------------------------------------------------------
> 
> Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -53,6 +53,7 @@
>  #include "OCCPoint.hpp"
>  #include "OCCCurve.hpp"
>  #include "OCCCoEdge.hpp"
> +#include "OCCCoFace.hpp"
>  #include "OCCLoop.hpp"
>  #include "OCCSurface.hpp"
>  #include "OCCShell.hpp"
> @@ -1212,14 +1213,22 @@
>    }
>  
>    TopExp_Explorer Ex;
> +  DLIList<OCCCoFace*> cofaces;
>    for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
>    {
> +    TopoDS_Face topo_face = TopoDS::Face(Ex.Current());
>      Surface* face =
> -      populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
> +      populate_topology_bridge(topo_face, build_body);
> +    
> +    OCCSurface *occ_surface = CAST_TO(face, OCCSurface);
> +    OCCCoFace * coface = new OCCCoFace( occ_surface, shell,
> +        ( topo_face.Orientation()== TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
> +    cofaces.append(coface);
> + 
>      if(standalone)
> -      CAST_TO(face,OCCSurface)->set_shell(shell);
> +      occ_surface->set_shell(shell);
>    }
> -
> +  shell->cofaces(cofaces);
>    return shell;
>  }
>  
> @@ -2429,14 +2438,33 @@
>    return CUBIT_FALSE;
>  }
>  
> -void OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape, 
> +int OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape, 
>                                      TopoDS_Shape new_shape)
>  {
>    if (!OCCMap->IsBound(old_shape))
> -    return;
> +    return -1;
> +
>    int k = OCCMap->Find(old_shape);
>    assert (k > 0 && k <= iTotalTBCreated);
> +
> +  if (!new_shape.IsNull() && !old_shape.IsSame(new_shape)&& 
> +      OCCMap->IsBound(new_shape)) 
> +  //already has a TB built on new_shape
> +  {
> +    //delete the second TB corresponding to old_shape
> +    std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
> +    TopologyBridge* tb = NULL;
> +    if (it != OccToCGM->end())
> +    {
> +       OccToCGM->erase(k);
> +       tb = (*it).second;
> +       delete tb;
> +    }
> +  }
> +
>    OCCMap->UnBind(old_shape);
> -  OCCMap->Bind(new_shape, k);
> +  if(!new_shape.IsNull())
> +    OCCMap->Bind(new_shape, k);
> +  return k;
>  }
>  //EOF
> 
> Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -110,7 +110,7 @@
>      //- Singleton pattern
>      //- Controlled access and creation of the sole instance of this class.
>  
> -  void update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
> +  int update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
>  
>    virtual ~OCCQueryEngine();
>    
> 
> Modified: cgm/trunk/geom/OCC/OCCShell.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -70,8 +70,14 @@
>  //-------------------------------------------------------------------------
>  OCCShell::~OCCShell()
>  {
> +  delete myTopoDSShell;
>  }
>  
> +OCCCoFace* OCCShell::remove_coface(OCCCoFace *coface)
> +{
> +  return myCoFaceList.remove(coface);
> +}
> +
>  void OCCShell::set_TopoDS_Shell(TopoDS_Shell shell)
>  {
>    if (!myTopoDSShell)
> 
> Modified: cgm/trunk/geom/OCC/OCCShell.hpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -31,7 +31,7 @@
>  class OCCLump;
>  class OCCSurface;
>  class OCCLoop;
> -class OCCCoEdge;
> +class OCCCoFace;
>  class OCCCurve;
>  class OCCPoint;
>  class BRepBuilderAPI_Transform;
> @@ -48,6 +48,11 @@
>    virtual ~OCCShell() ;
>      //- Destructor.
>  
> +  void cofaces(DLIList<OCCCoFace *> cofaces) {myCoFaceList = cofaces;}
> +
> +  DLIList<OCCCoFace*> cofaces() {return myCoFaceList;}
> +
> +  OCCCoFace* remove_coface(OCCCoFace *coface);
>    TopoDS_Shell* get_TopoDS_Shell() {return myTopoDSShell;}
>    void set_TopoDS_Shell(TopoDS_Shell shell);
>  
> @@ -120,6 +125,7 @@
>    OCCSurface* mySheetSurface;
>    OCCLump*    myLump;
>    OCCBody*    myBody;
> +  DLIList<OCCCoFace *> myCoFaceList;
>  };
>  
>  
> 
> Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-24 19:55:06 UTC (rev 1777)
> +++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-25 19:24:47 UTC (rev 1778)
> @@ -94,6 +94,7 @@
>  
>  OCCSurface::~OCCSurface() 
>  {
> +  delete myTopoDSFace;
>  }
>  
>  
> @@ -774,7 +775,6 @@
>    assert(aBRepTrsf != NULL || op != NULL);
>  
>    TopoDS_Shape shape;
> -  CubitBoolean need_update = CUBIT_TRUE;
>    if (aBRepTrsf)
>      shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face());
>    else
> @@ -828,47 +828,82 @@
>    TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
>    double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
>    int ii;
> +  TopTools_ListOfShape shapes;  
> +
>    for (ii=1; ii<=M.Extent(); ii++) {
> -     TopoDS_Wire wire = TopoDS::Wire(M(ii)); 
> -     TopTools_ListOfShape shapes;
> -     shapes.Assign(op->Modified(wire));
> -     if (shapes.Extent() > 0)
> -       shape = shapes.First();
> -     else
> +     TopoDS_Wire wire = TopoDS::Wire(M(ii));
> +
> +     if(!new_surface.IsNull())
>       {
> -       TopTools_IndexedMapOfShape M_new;
> -       TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
> -       shape = M_new(ii);
> -     }
> +       TopTools_ListOfShape shapes;
> +       shapes.Assign(op->Modified(wire));
> +       if (shapes.Extent() > 0)
> +         shape = shapes.First();
> +       else
> +       {
> +         TopTools_IndexedMapOfShape M_new;
> +         TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
> +         shape = M_new(ii);
> +       }
>    
> -     OCCQueryEngine::instance()->update_OCC_map(wire, shape);
> -      
> +       OCCQueryEngine::instance()->update_OCC_map(wire, shape);
> +     } 
>       //set curves
> -     CubitBoolean need_update = CUBIT_TRUE;
>       BRepTools_WireExplorer Ex;
>       for(Ex.Init(wire); Ex.More();Ex.Next())
>       {
>         TopoDS_Edge edge = Ex.Current();
> +       shape.Nullify();
>         shapes.Assign(op->Modified(edge));
> +       shape.Nullify();
>         if (shapes.Extent() > 0)
>           shape = shapes.First();
> -       else
> +       else if (op->IsDeleted(edge))
> +       {
> +         int k = OCCQueryEngine::instance()->update_OCC_map(edge, shape);
> +         std::map<int, TopologyBridge*>::iterator it =
> +                OCCQueryEngine::instance()->OccToCGM->find(k);
> +         TopologyBridge* tb = NULL;
> +         if (it != OCCQueryEngine::instance()->OccToCGM->end())
> +         {
> +           OCCQueryEngine::instance()->OccToCGM->erase(k);
> +           tb = (*it).second;
> +           delete tb;
> +         }
> +       }    
> +
> +       else 
>           continue;
>  
> -       if(wire.Orientation() == TopAbs_REVERSED)
> +       if(wire.Orientation() == TopAbs_REVERSED && !shape.IsNull())
> +       {
>           shape.Orientation(
>            shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
> -       OCCQueryEngine::instance()->update_OCC_map(edge, shape); 
> +         OCCQueryEngine::instance()->update_OCC_map(edge, shape); 
> +       }
>    
>         //update vertex
>         TopoDS_Vertex vertex = Ex.CurrentVertex();
>         shapes.Assign(op->Modified(vertex));
> -       need_update = CUBIT_TRUE;
> +       shape.Nullify();
>         if (shapes.Extent() > 0)
>         {
>           shape = shapes.First();
>           OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
>         }
> +       else if(op->IsDeleted(vertex))
> +       {
> +         int k = OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
> +         std::map<int, TopologyBridge*>::iterator it =
> +                OCCQueryEngine::instance()->OccToCGM->find(k);
> +         TopologyBridge* tb = NULL;
> +         if (it != OCCQueryEngine::instance()->OccToCGM->end())
> +         {
> +           OCCQueryEngine::instance()->OccToCGM->erase(k);
> +           tb = (*it).second;
> +           delete tb;
> +         }
> +       }
>       }
>    }
>    return CUBIT_SUCCESS;
> 


-- 
"A foolish consistency is the hobgoblin of little minds" - Ralph Waldo Emerson




More information about the cgma-dev mailing list