[cgma-dev] r3164 - cgm/trunk/geom/ACIS_SRC

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Sep 24 17:13:40 CDT 2009


Author: kraftche
Date: 2009-09-24 17:13:40 -0500 (Thu, 24 Sep 2009)
New Revision: 3164

Modified:
   cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp
   cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp
Log:
Fix query of deleted entity:  ACIS api_sweep_with_options(..) states that
if the input FACE has an owning BODY, then the owning BODY will be re-used
as the result of the sweep.  If it does not, then a new BODY will be created.
However, it does not guarantee that the input FACE will be kept in either
case.  Do not try to get BODY from FACE after calling api_sweep_with_options,
if it did not pass back a new BODY.



Modified: cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp	2009-09-23 19:54:02 UTC (rev 3163)
+++ cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp	2009-09-24 22:13:40 UTC (rev 3164)
@@ -2985,7 +2985,8 @@
 // Creation Date :
 //-------------------------------------------------------------------------
 CubitStatus AcisModifyEngine::sweep_FACE_about_axis(
-						    FACE *&FACE_ptr,
+						    FACE *FACE_ptr,
+                                                    BODY *&new_BODY_ptr,
 						    const CubitVector& axis_unit_vector,
 						    const CubitVector& point,
 						    double angle,
@@ -3098,6 +3099,10 @@
       //body.
       ACIS_sweep_options.set_bool_type(INTERSECT);
     }
+    
+    // NOTE: api_sweep_with_options will reuse existing body for sweep output,
+    //       but may consume (i.e. destroy FACE_ptr), so get it before calling
+    //       api_sweep.
   BODY* face_body_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
   BODY* BODYptr = NULL;
   result = api_sweep_with_options(FACE_ptr,
@@ -3162,19 +3167,18 @@
   // Note that ACIS allows the creation of swept solids that have
   // negative volume (all the surface normals point inward -- i.e.,
   // the swept solid is topologically identical to a void)
-  BODY *new_body = NULL;
   if(BODYptr)
     {
-      new_body = BODYptr;
+      new_BODY_ptr = BODYptr;
     }
   else if(face_body_ptr)
     {
-      new_body = face_body_ptr;
+      new_BODY_ptr = face_body_ptr;
     }
 
-  if(new_body)
+  if(new_BODY_ptr)
     {
-      if ( AcisQueryEngine::instance()->volume(new_body) < 0.0)
+      if ( AcisQueryEngine::instance()->volume(new_BODY_ptr) < 0.0)
 	{
 	  sweep_status = CUBIT_FAILURE;
 	  volume_is_negative = CUBIT_SUCCESS;
@@ -8124,7 +8128,10 @@
 	  else if (ref_edge != NULL)
 	    {
 	      //EDGEs_to_be_swept_list.append(CurveACIS::get_first_EDGE(ref_edge));
-	      EDGEs_to_be_swept_list.append(AcisQueryEngine::get_EDGE(ref_edge));
+              EDGE* EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge);
+              if (!EDGE_ptr)
+                return CUBIT_FAILURE;
+	      EDGEs_to_be_swept_list.append(EDGE_ptr);
 	      ref_edges_list.append(ref_edge);
 	    }
 	}
@@ -8134,15 +8141,16 @@
       BODY *stop_BODY = NULL;
       if( stop_surf )
 	{
-	  SurfaceACIS *surf_ACIS = CAST_TO(stop_surf, SurfaceACIS );
-	  stop_FACE = surf_ACIS->get_FACE_ptr();
+          stop_FACE = AcisQueryEngine::get_FACE(stop_surf);
+          if (!stop_FACE)
+            return CUBIT_FAILURE;
 	}
 
       if( stop_body )
 	{
-	  BodyACIS* bodyACISPtr = CAST_TO(stop_body, BodyACIS) ;
-	  assert(bodyACISPtr);
-	  stop_BODY = bodyACISPtr->get_BODY_ptr() ;
+          stop_BODY = AcisQueryEngine::get_BODY(stop_body);
+	  if (!stop_BODY)
+            return CUBIT_FAILURE;
 	}
 
       ref_edges_list.reset();
@@ -8255,6 +8263,7 @@
 			copy_BODY(stop_BODY);
 
 		      if ( !this->sweep_FACE_about_axis( copied_FACE_ptr,
+                                                         copy_of_original_BODY_ptr,
 							 sweep_axis,
 							 point,
 							 angle,
@@ -8273,7 +8282,7 @@
 			    {
 			      // Delete the BODY that was just created (the one with the
 			      // negative volume).
-			      //AcisQueryEngine::instance()->delete_ACIS_BODY(copy_of_original_BODY_ptr);
+			      AcisQueryEngine::instance()->delete_ACIS_BODY(copy_of_original_BODY_ptr);
 
 			      // Make another copy of the original BODY before attempting
 			      // the sweep again. We will perform the sweep on this copy,
@@ -8359,6 +8368,7 @@
 			  if (reverse_failed == CUBIT_FALSE)
 			    {
 			      if ( !this->sweep_FACE_about_axis( copied_FACE_ptr,
+                                                                 copy_of_original_BODY_ptr,
 								 sweep_axis,
 								 point,
 								 angle,
@@ -8400,7 +8410,6 @@
 		  // As all went well (apparently :-), create a new Body using the new
 		  // swept solid and get rid of the original Body and its associated
 		  // ACIS BODY.
-		  copy_of_original_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(copied_FACE_ptr);
 		  if( !skip_loop )
 		    {		      
 		      BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,

Modified: cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp	2009-09-23 19:54:02 UTC (rev 3163)
+++ cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp	2009-09-24 22:13:40 UTC (rev 3164)
@@ -1667,7 +1667,8 @@
     //- The draft angle is in radians.
     //- Returns CUBIT_SUCCESS if sweep successful, CUBIT_FAILURE otherwise.
 
-  CubitStatus sweep_FACE_about_axis( FACE *& FACE_ptr,
+  CubitStatus sweep_FACE_about_axis( FACE * FACE_ptr,
+                                     BODY *& new_BODY_ptr,
                                      const CubitVector& axis_unit_vector,
                                      const CubitVector& point,
                                      double angle,



More information about the cgma-dev mailing list