[cgma-dev] r3493 - in cgm/trunk: geom geom/ACIS_SRC geom/OCC geom/facet test
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Tue Jan 26 18:35:41 CST 2010
Author: kraftche
Date: 2010-01-26 18:35:39 -0600 (Tue, 26 Jan 2010)
New Revision: 3493
Modified:
cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp
cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp
cgm/trunk/geom/GeometryModifyEngine.hpp
cgm/trunk/geom/GeometryModifyTool.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/geom/facet/FacetModifyEngine.cpp
cgm/trunk/geom/facet/FacetModifyEngine.hpp
cgm/trunk/test/operation.cpp
Log:
Revert some of Jane's changes that are interferring with merging
code from Cubit12:
o Revert API change to GeometryModifyTool from r2506
o Revert massive gratuitous whitespace changes to AcisModifyEngine.cpp
from r1253
Modified: cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.cpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -1,4 +1,5 @@
-
+//-------------------------------------------------------------------------
+// Filename : AcisModifyEngine.cpp
//
// Purpose : Performs all acis-based geometry modification or creation
//
@@ -233,13 +234,13 @@
#ifdef ACIS_IGES_TRANSLATOR
#if CUBIT_ACIS_VERSION < 1100
-#include "igeshusk/igs_api/routines.hxx"
+ #include "igeshusk/igs_api/routines.hxx"
#else
#include "acisiges_api.hxx"
#endif
#endif
#ifdef ACIS_PROE_TRANSLATOR
-#include "proe/proehusk/api/proeapi.hxx"
+ #include "proe/proehusk/api/proeapi.hxx"
#endif
#ifdef ACIS_LOCAL_OPS
@@ -252,13 +253,13 @@
#ifdef ACIS_STEP_TRANSLATOR
#if CUBIT_ACIS_VERSION < 1100
-#include "stephusk/include/acis_inc.hxx"
-#include "stephusk/include/stpapi.hxx"
-#include "stephusk/util/apiinit.hxx"
-#include "stephusk/stepwrit/api/apiwrite.hxx"
-#include "stephusk/stepread/api/apiread.hxx"
-#include "stephusk/util/stphead.hxx"
-#include "stephusk/util/stp_res.hxx"
+ #include "stephusk/include/acis_inc.hxx"
+ #include "stephusk/include/stpapi.hxx"
+ #include "stephusk/util/apiinit.hxx"
+ #include "stephusk/stepwrit/api/apiwrite.hxx"
+ #include "stephusk/stepread/api/apiread.hxx"
+ #include "stephusk/util/stphead.hxx"
+ #include "stephusk/util/stp_res.hxx"
#else
#include "acisstep_api.hxx"
#endif
@@ -334,51 +335,51 @@
AcisModifyEngine::~AcisModifyEngine()
{
- api_terminate_booleans();
- api_terminate_covering();
- api_terminate_sweeping();
- api_terminate_skinning();
- api_terminate_offsetting();
- api_terminate_shelling ();
+ api_terminate_booleans();
+ api_terminate_covering();
+ api_terminate_sweeping();
+ api_terminate_skinning();
+ api_terminate_offsetting();
+ api_terminate_shelling ();
#ifdef ACIS_LOCAL_OPS
- api_terminate_face_removal();
+ api_terminate_face_removal();
#endif
- instance_ = 0;
+ instance_ = 0;
}
AcisModifyEngine::AcisModifyEngine()
{
assert( !instance_ );
- // add this modify engine to geometrymodifytool
+ // add this modify engine to geometrymodifytool
GeometryModifyTool::instance()->add_gme(this);
- API_BEGIN;
- //initialize the correct modules
- api_initialize_booleans();
- api_initialize_covering();
- api_initialize_sweeping();
- api_initialize_skinning();
- api_initialize_offsetting();
- api_initialize_shelling ();
+ API_BEGIN;
+ //initialize the correct modules
+ api_initialize_booleans();
+ api_initialize_covering();
+ api_initialize_sweeping();
+ api_initialize_skinning();
+ api_initialize_offsetting();
+ api_initialize_shelling ();
#ifdef ACIS_LOCAL_OPS
- api_initialize_face_removal();
+ api_initialize_face_removal();
#endif
- API_END;
+ API_END;
}
CubitString AcisModifyEngine::identify()
{
- CubitString number_string = get_major_version();
- number_string += ".";
- number_string += CubitString(get_minor_version());
- number_string += ".";
- number_string += CubitString(get_point_version());
- CubitString version_string = "ACIS Version ";
- version_string += number_string;
- return version_string;
+ CubitString number_string = get_major_version();
+ number_string += ".";
+ number_string += CubitString(get_minor_version());
+ number_string += ".";
+ number_string += CubitString(get_point_version());
+ CubitString version_string = "ACIS Version ";
+ version_string += number_string;
+ return version_string;
}
//-------------------------------------------------------------------------
@@ -393,7 +394,7 @@
const type_info& AcisModifyEngine::entity_type_info() const
{
- return typeid(AcisModifyEngine);
+ return typeid(AcisModifyEngine);
}
//-------------------------------------------------------------------------
@@ -408,20 +409,20 @@
BodySM* AcisModifyEngine::sphere(double radius) const
{
- BODY* BODYPtr = NULL;
+ BODY* BODYPtr = NULL;
- // Create a BODY that represents the cuboid
- outcome result = api_make_sphere ( radius, BODYPtr );
- if (!result.ok())
- {
+ // Create a BODY that represents the cuboid
+ outcome result = api_make_sphere ( radius, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::sphere, Line# %d\n"
" Problems creating a sphere\n", __LINE__ );
return NULL ;
- }
+ }
- // Build a Body from the BODY and return it.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ // Build a Body from the BODY and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -436,31 +437,31 @@
BodySM* AcisModifyEngine::brick(double width, double depth,
double height) const
{
- BODY* BODYPtr = NULL;
+ BODY* BODYPtr = NULL;
- // Create a BODY that represents the cuboid
- outcome result = api_make_cuboid ( width, depth, height, BODYPtr );
- if (!result.ok())
- {
+ // Create a BODY that represents the cuboid
+ outcome result = api_make_cuboid ( width, depth, height, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::brick, Line# %d\n"
" Problems creating a brick\n", __LINE__);
return NULL ;
- }
+ }
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
BodySM* AcisModifyEngine::brick( const CubitVector ¢er,
const CubitVector axes[3],
const CubitVector &extension ) const
{
- BODY* BODY_ptr;
+ BODY* BODY_ptr;
- BODY_ptr = make_brick_BODY( center, axes, extension );
+ BODY_ptr = make_brick_BODY( center, axes, extension );
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges( BODY_ptr );
- return this_bodysm;
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges( BODY_ptr );
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -476,20 +477,20 @@
BodySM* AcisModifyEngine::prism( double height, int sides,
double major, double minor) const
{
- BODY* BODYPtr = NULL;
+ BODY* BODYPtr = NULL;
- // Create a BODY that represents the prism
- outcome result = api_make_prism ( height, major, minor, sides, BODYPtr );
- if (!result.ok())
- {
+ // Create a BODY that represents the prism
+ outcome result = api_make_prism ( height, major, minor, sides, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::prism, Line# %d\n"
" Problems creating a prism\n", __LINE__);
return NULL ;
- }
+ }
- // Build a Body from the BODY and return it.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ // Build a Body from the BODY and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -505,19 +506,19 @@
BodySM* AcisModifyEngine::pyramid( double height, int sides, double major,
double minor, double top ) const
{
- BODY* BODYPtr = NULL;
- // Create a BODY that represents the pyramid
- outcome result = api_make_pyramid ( height, major, minor, top,
- sides, BODYPtr );
- if (!result.ok())
- {
+ BODY* BODYPtr = NULL;
+ // Create a BODY that represents the pyramid
+ outcome result = api_make_pyramid ( height, major, minor, top,
+ sides, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::pyramid, Line# %d\n"
" Problems creating a pyramid\n", __LINE__);
return NULL ;
- }
- // Build a Body from the BODY and return it.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ }
+ // Build a Body from the BODY and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -533,23 +534,21 @@
BodySM* AcisModifyEngine::cylinder( double hi, double r1, double r2,
double r3 ) const
{
- BODY* BODYPtr = NULL;
- // Create a BODY that represents the cylinder
- outcome result = api_make_frustum ( hi, r1, r2, r3, BODYPtr );
- if (!result.ok())
- {
+ BODY* BODYPtr = NULL;
+ // Create a BODY that represents the cylinder
+ outcome result = api_make_frustum ( hi, r1, r2, r3, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::cylinder, Line# %d\n"
" Problems creating a cylinder\n", __LINE__);
return NULL ;
- }
+ }
- // Build a Body from the BODY and return it.
-
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ // Build a Body from the BODY and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
-
//-------------------------------------------------------------------------
// Purpose : Create a torus and return a pointer to the Body.
//
@@ -562,18 +561,18 @@
BodySM* AcisModifyEngine::torus( double r1, double r2 ) const
{
- BODY* BODYPtr = NULL;
- // Create a BODY that represents the torus
- outcome result = api_make_torus ( r1, r2, BODYPtr );
- if (!result.ok())
- {
+ BODY* BODYPtr = NULL;
+ // Create a BODY that represents the torus
+ outcome result = api_make_torus ( r1, r2, BODYPtr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::torus, Line# %d\n"
" Problems creating a torus\n", __LINE__);
return NULL ;
- }
- // Build a Body from the BODY and return it.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
- return this_bodysm;
+ }
+ // Build a Body from the BODY and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr);
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -590,13 +589,13 @@
const CubitVector& p3,
const CubitVector& p4 ) const
{
- BODY* new_BODY = make_planar_quad_BODY( p1, p2, p3, p4 );
+ BODY* new_BODY = make_planar_quad_BODY( p1, p2, p3, p4 );
- // Build a VGI Body (i.e, the entire VGI structure) from this
- // ACIS BODY.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY);
+ // Build a VGI Body (i.e, the entire VGI structure) from this
+ // ACIS BODY.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY);
- return this_bodysm;
+ return this_bodysm;
}
//-------------------------------------------------------------------------
@@ -612,138 +611,138 @@
BodySM* AcisModifyEngine::copy_body ( BodySM* OSMEPtr) const
{
- // Make sure that we have a valid pointer
- assert(OSMEPtr != NULL) ;
+ // Make sure that we have a valid pointer
+ assert(OSMEPtr != NULL) ;
- BodyACIS* bodyACISPtr = CAST_TO(OSMEPtr, BodyACIS) ;
+ BodyACIS* bodyACISPtr = CAST_TO(OSMEPtr, BodyACIS) ;
- // Make sure that we have a valid BodyACIS
- assert(bodyACISPtr != NULL) ;
+ // Make sure that we have a valid BodyACIS
+ assert(bodyACISPtr != NULL) ;
- // Get the ACIS BODY
- BODY* BODY_ptr = bodyACISPtr->get_BODY_ptr() ;
+ // Get the ACIS BODY
+ BODY* BODY_ptr = bodyACISPtr->get_BODY_ptr() ;
- // Construct a new BODY from what we have
- BODY* new_BODY_ptr = this->copy_BODY(BODY_ptr) ;
+ // Construct a new BODY from what we have
+ BODY* new_BODY_ptr = this->copy_BODY(BODY_ptr) ;
- // Build a VGI Body and return it.
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_ptr);
- return this_bodysm;
+ // Build a VGI Body and return it.
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_ptr);
+ return this_bodysm;
}
CubitStatus AcisModifyEngine::imprint_BODYs (BODY* body1_ptr,
BODY* body2_ptr) const
{
- CpuTimer imprint_BODYs_timer;
+ CpuTimer imprint_BODYs_timer;
- // Imprints the 2 input ACIS BODYs. If something goes wrong, state is
- // restored and CUBIT_FALSE is returned.
+ // Imprints the 2 input ACIS BODYs. If something goes wrong, state is
+ // restored and CUBIT_FALSE is returned.
- CubitStatus status = CUBIT_FAILURE;
+ CubitStatus status = CUBIT_FAILURE;
- // Use the BEGIN/END pair so that a roll-back is done by ACIS if something
- // goes wrong in the api_imprint or api_check_entity operations
- if ( GeometryModifyTool::get_all_edges_imprint() )
- {
+ // Use the BEGIN/END pair so that a roll-back is done by ACIS if something
+ // goes wrong in the api_imprint or api_check_entity operations
+ if ( GeometryModifyTool::get_all_edges_imprint() )
+ {
api_set_int_option("all_free_edges", TRUE );
- }
+ }
- outcome result = api_imprint(body1_ptr, body2_ptr);
+ outcome result = api_imprint(body1_ptr, body2_ptr);
- //Gets rid of sliver curves/surfaces that could get produced by the imprint.
- AcisModifyEngine::instance()->cleanup_slivers( body1_ptr );
- AcisModifyEngine::instance()->cleanup_slivers( body2_ptr );
+ //Gets rid of sliver curves/surfaces that could get produced by the imprint.
+ AcisModifyEngine::instance()->cleanup_slivers( body1_ptr );
+ AcisModifyEngine::instance()->cleanup_slivers( body2_ptr );
- if ( GeometryModifyTool::get_all_edges_imprint() )
- {
+ if ( GeometryModifyTool::get_all_edges_imprint() )
+ {
api_set_int_option("all_free_edges", FALSE );
- }
+ }
- if (DEBUG_FLAG(18))
- {
+ if (DEBUG_FLAG(18))
+ {
if (result.ok())
- {
- status = CUBIT_SUCCESS;
+ {
+ status = CUBIT_SUCCESS;
- // Now that the imprint operation has apparently succeeded (:-)
- // test the resulting BODYs for correctness. The output of the
- // api_check_entity procedure is sent to the file whose pointer
- // is debug_file_ptr (an ACIS global file pointer).
+ // Now that the imprint operation has apparently succeeded (:-)
+ // test the resulting BODYs for correctness. The output of the
+ // api_check_entity procedure is sent to the file whose pointer
+ // is debug_file_ptr (an ACIS global file pointer).
- // MJP Note:
- // I do this test here because there are bugs in the imprint
- // operation that result in invalid BODYs even though the api_imprint
- // call may return a successful status. I've been told that the imprint
- // operation will be a lot more stable in Version 2 -- and where have
- // we heard this kind of stuff before?? :-)
+ // MJP Note:
+ // I do this test here because there are bugs in the imprint
+ // operation that result in invalid BODYs even though the api_imprint
+ // call may return a successful status. I've been told that the imprint
+ // operation will be a lot more stable in Version 2 -- and where have
+ // we heard this kind of stuff before?? :-)
- FILE* save_dfp = NULL;
+ FILE* save_dfp = NULL;
- // Save the original value of the ACIS Debug File Pointer
- save_dfp = debug_file_ptr;
+ // Save the original value of the ACIS Debug File Pointer
+ save_dfp = debug_file_ptr;
- // Check the first entity and save the results of the check in the file,
- // api_check_entity_output.txt
- debug_file_ptr = fopen ("api_check_entity_output.txt", "w");
- result = api_check_entity (body1_ptr, (ENTITY_LIST *)NULL);
- if (debug_file_ptr) fclose (debug_file_ptr);
+ // Check the first entity and save the results of the check in the file,
+ // api_check_entity_output.txt
+ debug_file_ptr = fopen ("api_check_entity_output.txt", "w");
+ result = api_check_entity (body1_ptr, (ENTITY_LIST *)NULL);
+ if (debug_file_ptr) fclose (debug_file_ptr);
- if (result.ok())
- {
+ if (result.ok())
+ {
// Check the second entity and save the results of the check in the
// file, api_check_entity_output.txt
- debug_file_ptr = fopen("api_check_entity_output.txt", "w");
- result = api_check_entity (body2_ptr, (ENTITY_LIST *)NULL);
- if (debug_file_ptr) fclose (debug_file_ptr);
+ debug_file_ptr = fopen("api_check_entity_output.txt", "w");
+ result = api_check_entity (body2_ptr, (ENTITY_LIST *)NULL);
+ if (debug_file_ptr) fclose (debug_file_ptr);
- if (result.ok())
- {
- status = CUBIT_SUCCESS;
- }
+ if (result.ok())
+ {
+ status = CUBIT_SUCCESS;
+ }
- else
- {
- status = CUBIT_FAILURE;
- AcisQueryEngine::instance()->ACIS_API_error (result);
- }
- }
- else
- {
- status = CUBIT_FAILURE;
- AcisQueryEngine::instance()->ACIS_API_error (result);
- }
- // Restore the original value of the ACIS Debug File Pointer
- debug_file_ptr = save_dfp;
- }
+ else
+ {
+ status = CUBIT_FAILURE;
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ }
+ }
+ else
+ {
+ status = CUBIT_FAILURE;
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ }
+ // Restore the original value of the ACIS Debug File Pointer
+ debug_file_ptr = save_dfp;
+ }
else
- {
- status = CUBIT_FAILURE;
- AcisQueryEngine::instance()->ACIS_API_error (result);
- }
- }
- if (result.ok())
- status = CUBIT_SUCCESS;
- else
- {
- // mieht just be no overlap, check smaller boxes
- SPAbox box1 = get_body_box(body1_ptr);
- SPAbox box2 = get_body_box(body2_ptr);
+ {
+ status = CUBIT_FAILURE;
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ }
+ }
+ if (result.ok())
+ status = CUBIT_SUCCESS;
+ else
+ {
+ // mieht just be no overlap, check smaller boxes
+ SPAbox box1 = get_body_box(body1_ptr);
+ SPAbox box2 = get_body_box(body2_ptr);
- if (!body1_ptr || !body2_ptr || (box1 && box2))
- {
- if (DEBUG_FLAG(95))
- {
- PRINT_DEBUG_95( "Bodies were not "
- "imprinted.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
- }
- status = CUBIT_FAILURE;
- }
- }
- PRINT_DEBUG_3( "CPU time taken to imprint two BODYs: "
- "%f secs\n", imprint_BODYs_timer.cpu_secs() ) ;
+ if (!body1_ptr || !body2_ptr || (box1 && box2))
+ {
+ if (DEBUG_FLAG(95))
+ {
+ PRINT_DEBUG_95( "Bodies were not "
+ "imprinted.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
+ }
+ status = CUBIT_FAILURE;
+ }
+ }
+ PRINT_DEBUG_3( "CPU time taken to imprint two BODYs: "
+ "%f secs\n", imprint_BODYs_timer.cpu_secs() ) ;
- return status;
+ return status;
}
//-------------------------------------------------------------------------
@@ -760,40 +759,40 @@
BODY* AcisModifyEngine::copy_BODY (BODY* body_ptr,
bool remove_attribs ) const
{
- // If the input pointer is NULL, return a NULL pointer
- if (body_ptr == NULL)
- {
+ // If the input pointer is NULL, return a NULL pointer
+ if (body_ptr == NULL)
+ {
PRINT_ERROR("Cannot copy ACIS BODY - input pointer is NULL.\n");
return (BODY *) NULL;
- }
+ }
- BODY* new_body_ptr = NULL;
+ BODY* new_body_ptr = NULL;
- if( remove_attribs )
- ATTRIB_CUBIT_OWNER::set_copyable( false );
+ if( remove_attribs )
+ ATTRIB_CUBIT_OWNER::set_copyable( false );
- outcome result = api_copy_body(body_ptr, new_body_ptr);
+ outcome result = api_copy_body(body_ptr, new_body_ptr);
- if (!result.ok())
- {
+ if (!result.ok())
+ {
AcisQueryEngine::instance()->ACIS_API_error (result);
new_body_ptr = NULL;
- }
- // Before returning this new BODY, first make sure that all the CUBIT
- // OWNER attributes are cleaned out of it
- if( remove_attribs )
- ATTRIB_CUBIT_OWNER::set_copyable( true );
- /*
- if ( remove_attribs )
- {
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(new_body_ptr);
- }
- */
- // Also make sure that any healing attributes are removed from it
+ }
+ // Before returning this new BODY, first make sure that all the CUBIT
+ // OWNER attributes are cleaned out of it
+ if( remove_attribs )
+ ATTRIB_CUBIT_OWNER::set_copyable( true );
+/*
+ if ( remove_attribs )
+ {
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(new_body_ptr);
+ }
+*/
+ // Also make sure that any healing attributes are removed from it
#ifdef ACIS_HEALER
- AcisHealerTool::instance()->end_BODY_for_healing( new_body_ptr );
+ AcisHealerTool::instance()->end_BODY_for_healing( new_body_ptr );
#endif
- return new_body_ptr;
+ return new_body_ptr;
}
CubitStatus AcisModifyEngine::surface_intersection( Surface *surface1_ptr,
@@ -801,42 +800,42 @@
DLIList<Curve*> &intersect_graph,
const double ) const
{
- //First make sure the entities are ACIS.
+ //First make sure the entities are ACIS.
SurfaceACIS *surf_ACIS_1= CAST_TO(surface1_ptr,SurfaceACIS);
SurfaceACIS *surf_ACIS_2= CAST_TO(surface2_ptr,SurfaceACIS);
if ( !surf_ACIS_1 || !surf_ACIS_2 )
- {
- PRINT_ERROR("In AcisModifyEngine::surface_intersection\n"
- "Not all entities are from the same engine.\n");
- return CUBIT_FAILURE;
- }
- //Get the original bodies.
+ {
+ PRINT_ERROR("In AcisModifyEngine::surface_intersection\n"
+ "Not all entities are from the same engine.\n");
+ return CUBIT_FAILURE;
+ }
+ //Get the original bodies.
FACE* FACE1_ptr = surf_ACIS_1->get_FACE_ptr();
FACE* FACE2_ptr = surf_ACIS_2->get_FACE_ptr();
BODY* intersect_BODY = NULL;
- //Now get the intersection.
+ //Now get the intersection.
CubitBoolean intersecting = CUBIT_FALSE;
CubitStatus ret = FACE_intersection(FACE1_ptr, FACE2_ptr,
intersect_BODY, intersecting);
if ( ret != CUBIT_SUCCESS )
return ret;
if ( !intersecting )
- {
+ {
//No intersection, we should have caught this before, but
//just return with an empty edge list.
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+ }
ret = convert_WIRE( intersect_BODY, intersect_graph );
if ( ret != CUBIT_SUCCESS )
return ret;
- //Okay we should have our fill of curves.
- //Delete the intersection graph wire, which should
- //be fine since we copied the curves.
+ //Okay we should have our fill of curves.
+ //Delete the intersection graph wire, which should
+ //be fine since we copied the curves.
api_del_entity(intersect_BODY);
- //return sucess!
+ //return sucess!
return CUBIT_SUCCESS;
}
@@ -844,7 +843,7 @@
const CubitVector &point_2,
const CubitVector &point_3,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midplane_bodies ) const
+ BodySM *&midplane_body ) const
{
DLIList<BodySM*> body_list;
@@ -855,33 +854,32 @@
return CUBIT_FAILURE;
BODY *sheet_BODY = this->create_infinite_plane_cutting_tool(
- point_1, point_2, point_3, super_box, CUBIT_TRUE);
+ point_1, point_2, point_3, super_box, CUBIT_TRUE);
BODY* BODY_to_trim_to = AcisQueryEngine::get_BODY(body_to_trim_to);
bool delete_attribs = CUBIT_TRUE;
BODY* BODY_copy = this->copy_BODY(BODY_to_trim_to, delete_attribs);
if (BODY_copy == NULL)
- {
- PRINT_ERROR("Cannot make a copy of the parent ACIS BODY of volume.\n"
- " mid plane creation failed.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR("Cannot make a copy of the parent ACIS BODY of volume.\n"
+ " mid plane creation failed.\n" );
+ return CUBIT_FAILURE;
+ }
outcome result = api_intersect( BODY_copy, sheet_BODY );
if ( !result.ok() )
- {
- api_del_entity(BODY_copy);
- api_del_entity(sheet_BODY);
- PRINT_ERROR("Problems creating midplane.\n");
- return CUBIT_FAILURE;
- }
+ {
+ api_del_entity(BODY_copy);
+ api_del_entity(sheet_BODY);
+ PRINT_ERROR("Problems creating midplane.\n");
+ return CUBIT_FAILURE;
+ }
//Create a new cubit body for the imprinted body.
- BodySM* midplane_body = AcisQueryEngine::instance()->
+ midplane_body = AcisQueryEngine::instance()->
populate_topology_bridges(sheet_BODY);
- midplane_bodies.append(midplane_body);
return CUBIT_SUCCESS;
}
@@ -893,48 +891,48 @@
// Date : 03/07/06
//=============================================================================
CubitStatus AcisModifyEngine::get_spheric_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies) const
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const
{
SurfaceACIS *surf_ACIS1 = CAST_TO(surface_ptr1, SurfaceACIS );
FACE* FACE1_ptr = make_FACE( surf_ACIS1->get_FACE_ptr() );
int surface_type = (&(FACE1_ptr->geometry()->equation()))->type();
if( surface_type != sphere_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " The CGM sphere is not an ASIS sphere (%d %d).\n", surface_type, SPHERE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " The CGM sphere is not an ASIS sphere (%d %d).\n", surface_type, SPHERE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
SurfaceACIS *surf_ACIS2 = CAST_TO(surface_ptr2, SurfaceACIS );
FACE* FACE2_ptr = make_FACE( surf_ACIS2->get_FACE_ptr() );
surface_type = (&(FACE2_ptr->geometry()->equation()))->type();
if( surface_type != sphere_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " The CGM sphere is not an ASIS sphere (%d %d).\n", surface_type, SPHERE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " The CGM sphere is not an ASIS sphere (%d %d).\n", surface_type, SPHERE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
- // surface const* acis_surface1 = &(FACE1_ptr->geometry()->equation());
- // sphere const* sphere_surface1 = (sphere *)acis_surface1;
+// surface const* acis_surface1 = &(FACE1_ptr->geometry()->equation());
+// sphere const* sphere_surface1 = (sphere *)acis_surface1;
SURFACE const* acis_SURFACE1 = FACE1_ptr->geometry();
SPHERE const* SPHERE_SURFACE1 = (SPHERE *)acis_SURFACE1;
SPAposition center1 = SPHERE_SURFACE1->centre();
- // surface const* acis_surface2 = &(FACE2_ptr->geometry()->equation());
- // sphere const* sphere_surface2 = (sphere *)acis_surface2;
+// surface const* acis_surface2 = &(FACE2_ptr->geometry()->equation());
+// sphere const* sphere_surface2 = (sphere *)acis_surface2;
SURFACE const* acis_SURFACE2 = FACE2_ptr->geometry();
SPHERE const* SPHERE_SURFACE2 = (SPHERE *)acis_SURFACE2;
SPAposition center2 = SPHERE_SURFACE2->centre();
if ( center1 != center2 )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " Not supported yet: spheres do not have the same center.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " Not supported yet: spheres do not have the same center.\n" );
+ return CUBIT_FAILURE;
+ }
CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
@@ -958,56 +956,55 @@
new_FACE_ptr );
if (!result.ok() || new_FACE_ptr == NULL ||
new_FACE_ptr->geometry() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " ACIS api_make_spface function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " ACIS api_make_spface function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
FACE *face_list[1];
face_list[0] = new_FACE_ptr;
result = api_sheet_from_ff( 1, face_list, sheet_BODY );
if ( !result.ok() || sheet_BODY == NULL || sheet_BODY->lump() == NULL
- || sheet_BODY->lump()->shell() == NULL ||
- sheet_BODY->lump()->shell()->first_face() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " ACIS api_sheet_from_ff function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ || sheet_BODY->lump()->shell() == NULL ||
+ sheet_BODY->lump()->shell()->first_face() == NULL )
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " ACIS api_sheet_from_ff function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
result = api_body_to_2d( sheet_BODY );
if ( !result.ok() )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " ACIS api_body_to_2d function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " ACIS api_body_to_2d function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
BODY* BODY_to_trim_to = AcisQueryEngine::get_BODY(body_to_trim_to);
bool delete_attribs = CUBIT_TRUE;
BODY* BODY_copy = this->copy_BODY(BODY_to_trim_to, delete_attribs);
if ( BODY_copy == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " Cannot make a copy of the parent ACIS BODY of volume.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " Cannot make a copy of the parent ACIS BODY of volume.\n" );
+ return CUBIT_FAILURE;
+ }
result = api_intersect( BODY_copy, sheet_BODY );
if ( !result.ok() )
- {
- api_del_entity( BODY_copy );
- api_del_entity( sheet_BODY );
- PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
- " ACIS api_intersect function failed.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ api_del_entity( BODY_copy );
+ api_del_entity( sheet_BODY );
+ PRINT_ERROR( "In AcisModifyEngine::get_spheric_mid_surface\n"
+ " ACIS api_intersect function failed.\n" );
+ return CUBIT_FAILURE;
+ }
- BodySM* midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
+ midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
- midsurface_bodies.append(midsurface_body);
return CUBIT_SUCCESS;
}
@@ -1019,28 +1016,28 @@
// Date : 03/07/06
//=============================================================================
CubitStatus AcisModifyEngine::get_conic_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies ) const
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const
{
SurfaceACIS *surf_ACIS1 = CAST_TO(surface_ptr1, SurfaceACIS );
FACE* FACE1_ptr = make_FACE( surf_ACIS1->get_FACE_ptr() );
int surface_type = (&(FACE1_ptr->geometry()->equation()))->type();
if( surface_type != cone_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " The CGM cone is not an ASIS cone (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " The CGM cone is not an ASIS cone (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
SurfaceACIS *surf_ACIS2 = CAST_TO(surface_ptr2, SurfaceACIS );
FACE* FACE2_ptr = make_FACE( surf_ACIS2->get_FACE_ptr() );
surface_type = (&(FACE2_ptr->geometry()->equation()))->type();
if( surface_type != cone_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " The CGM cone is not an ASIS cone (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " The CGM cone is not an ASIS cone (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
surface const* acis_surface1 = &(FACE1_ptr->geometry()->equation());
cone const* cone_surface1 = (cone *)acis_surface1;
@@ -1055,34 +1052,34 @@
if ( ( sine_angle1 != 0.0 ) || ( fabs( cosine_angle1 ) != 1.0 )
||
( sine_angle2 != 0.0 ) || ( fabs( cosine_angle2 ) != 1.0 ) )
+ {
+ if( ( sine_angle1 != sine_angle2 ) || ( cosine_angle1 != cosine_angle2 ) )
{
- if( ( sine_angle1 != sine_angle2 ) || ( cosine_angle1 != cosine_angle2 ) )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " Not supported yet: cones do not have the same major angle.\n" );
- return CUBIT_FAILURE;
- }
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " Not supported yet: cones do not have the same major angle.\n" );
+ return CUBIT_FAILURE;
}
+ }
ellipse const* base1 = &cone_surface1->base;
double ratio1 = base1->radius_ratio;
ellipse const* base2 = &cone_surface2->base;
double ratio2 = base2->radius_ratio;
if( ratio1 != ratio2 )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " Not supported yet: cones do not have the same radius ratios.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " Not supported yet: cones do not have the same radius ratios.\n" );
+ return CUBIT_FAILURE;
+ }
SPAunit_vector normal1 = base1->normal;
SPAunit_vector normal2 = base2->normal;
if ( ( normal1 != normal2 ) && ( - normal1 != normal2 ) )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " Not supported yet: cones do not have the same axis of symmetry.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " Not supported yet: cones do not have the same axis of symmetry.\n" );
+ return CUBIT_FAILURE;
+ }
SPAposition const centre1 = base1->centre;
SPAposition const centre2 = base2->centre;
@@ -1092,72 +1089,72 @@
centre2.y() - centre1.y(),
centre2.z() - centre1.z() );
if ( ! c1_to_c2.about_equal( null_vec ) )
+ {
+ CubitVector comm_dir( normal1.x(), normal1.y(), normal1.z() );
+ c1_to_c2.normalize();
+ if ( ( ! c1_to_c2.about_equal( comm_dir ) ) && ( ! (-c1_to_c2).about_equal( comm_dir ) ) )
{
- CubitVector comm_dir( normal1.x(), normal1.y(), normal1.z() );
- c1_to_c2.normalize();
- if ( ( ! c1_to_c2.about_equal( comm_dir ) ) && ( ! (-c1_to_c2).about_equal( comm_dir ) ) )
- {
- CubitVector const point_1( ( centre1.x() + centre2.x() ) * .5,
- ( centre1.y() + centre2.y() ) * .5,
- ( centre1.z() + centre2.z() ) * .5 );
- CubitVector const point_2 = point_1 + comm_dir;
- CubitVector const point_3 = point_1 + ( comm_dir * c1_to_c2 );
- CubitStatus ret = this->get_mid_plane( point_1, point_2, point_3,
- body_to_trim_to, midsurface_bodies );
+ CubitVector const point_1( ( centre1.x() + centre2.x() ) * .5,
+ ( centre1.y() + centre2.y() ) * .5,
+ ( centre1.z() + centre2.z() ) * .5 );
+ CubitVector const point_2 = point_1 + comm_dir;
+ CubitVector const point_3 = point_1 + ( comm_dir * c1_to_c2 );
+ CubitStatus ret = this->get_mid_plane( point_1, point_2, point_3,
+ body_to_trim_to, midsurface_body );
- return ret;
- }
+ return ret;
}
+ }
CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
BODY *sheet_BODY;
CubitBoolean cylinder = CUBIT_FALSE;
if ( ( sine_angle1 == 0.0 ) && ( fabs( cosine_angle1 ) == 1.0 ) )
- {
- cylinder = CUBIT_TRUE;
- }
+ {
+ cylinder = CUBIT_TRUE;
+ }
double const st_ang = 0.;
double const end_ang = 2. * CUBIT_PI;
double const height = 2. * (bounding_box.diagonal()).length();
CubitVector center_vec;
CubitVector temp_norm( normal1.x(), normal1.y(), normal1.z());
if ( ! cylinder )
+ {
+ if ( sine_angle1 > 0.0 && cosine_angle1 > 0.0 )
{
- if ( sine_angle1 > 0.0 && cosine_angle1 > 0.0 )
- {
- sine_angle1 = - sine_angle1;
- temp_norm *= - 1.0;
- }
- else if ( sine_angle1 < 0.0 && cosine_angle1 < 0.0 )
- {
- cosine_angle1 = - cosine_angle1;
- temp_norm *= - 1.0;
- }
- //make center of surface along axis, 1/2 height of
- //bounding box of entire model.
- CubitVector root_vec( centre1.x(), centre1.y(), centre1.z() );
- center_vec = root_vec + ( -.5 * height) * temp_norm;
+ sine_angle1 = - sine_angle1;
+ temp_norm *= - 1.0;
}
- else
+ else if ( sine_angle1 < 0.0 && cosine_angle1 < 0.0 )
{
- CubitVector root_vec( centre1.x(), centre1.y(), centre1.z() );
- center_vec = .5 * height * temp_norm;
- center_vec = root_vec - center_vec;
+ cosine_angle1 = - cosine_angle1;
+ temp_norm *= - 1.0;
}
+ //make center of surface along axis, 1/2 height of
+ //bounding box of entire model.
+ CubitVector root_vec( centre1.x(), centre1.y(), centre1.z() );
+ center_vec = root_vec + ( -.5 * height) * temp_norm;
+ }
+ else
+ {
+ CubitVector root_vec( centre1.x(), centre1.y(), centre1.z() );
+ center_vec = .5 * height * temp_norm;
+ center_vec = root_vec - center_vec;
+ }
SPAposition const center ( center_vec.x(), center_vec.y(), center_vec.z() );
SPAvector const major_axis1 = base1->major_axis;
SPAvector const major_axis2 = base2->major_axis;
SPAvector newmajor_axis;
if ( cosine_angle1 * cosine_angle2 < 0. )
- {
- newmajor_axis = ( major_axis1 - major_axis2 ) * .5;
- }
+ {
+ newmajor_axis = ( major_axis1 - major_axis2 ) * .5;
+ }
else
- {
- newmajor_axis = ( major_axis1 + major_axis2 ) * .5;
- }
+ {
+ newmajor_axis = ( major_axis1 + major_axis2 ) * .5;
+ }
FACE *new_FACE_ptr = NULL;
outcome result = api_make_cnface( center,
@@ -1172,55 +1169,54 @@
new_FACE_ptr );
if (!result.ok() || new_FACE_ptr == NULL ||
new_FACE_ptr->geometry() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " ACIS api_make_cnface function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " ACIS api_make_cnface function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
FACE *face_list[1];
face_list[0] = new_FACE_ptr;
result = api_sheet_from_ff( 1, face_list, sheet_BODY );
if ( !result.ok() || sheet_BODY == NULL || sheet_BODY->lump() == NULL
- || sheet_BODY->lump()->shell() == NULL ||
- sheet_BODY->lump()->shell()->first_face() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " ACIS api_sheet_from_ff function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ || sheet_BODY->lump()->shell() == NULL ||
+ sheet_BODY->lump()->shell()->first_face() == NULL )
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " ACIS api_sheet_from_ff function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
result = api_body_to_2d( sheet_BODY );
if ( !result.ok() )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " ACIS api_body_to_2d function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " ACIS api_body_to_2d function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
BODY* BODY_to_trim_to = AcisQueryEngine::get_BODY(body_to_trim_to);
bool delete_attribs = CUBIT_TRUE;
BODY* BODY_copy = this->copy_BODY(BODY_to_trim_to, delete_attribs);
if ( BODY_copy == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " Cannot make a copy of the parent ACIS BODY of volume.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " Cannot make a copy of the parent ACIS BODY of volume.\n" );
+ return CUBIT_FAILURE;
+ }
result = api_intersect( BODY_copy, sheet_BODY );
if ( !result.ok() )
- {
- api_del_entity( BODY_copy );
- api_del_entity( sheet_BODY );
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " ACIS api_intersect function failed.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ api_del_entity( BODY_copy );
+ api_del_entity( sheet_BODY );
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " ACIS api_intersect function failed.\n" );
+ return CUBIT_FAILURE;
+ }
- BodySM* midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
- midsurface_bodies.append(midsurface_body);
+ midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
return CUBIT_SUCCESS;
}
@@ -1233,64 +1229,64 @@
// Date : 03/07/06
//=============================================================================
CubitStatus AcisModifyEngine::get_toric_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies ) const
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const
{
SurfaceACIS *surf_ACIS1 = CAST_TO(surface_ptr1, SurfaceACIS );
FACE* FACE1_ptr = make_FACE( surf_ACIS1->get_FACE_ptr() );
int surface_type = (&(FACE1_ptr->geometry()->equation()))->type();
if( surface_type != torus_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " The CGM cone is not an ASIS torus (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " The CGM cone is not an ASIS torus (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
SurfaceACIS *surf_ACIS2 = CAST_TO(surface_ptr2, SurfaceACIS );
FACE* FACE2_ptr = make_FACE( surf_ACIS2->get_FACE_ptr() );
surface_type = (&(FACE2_ptr->geometry()->equation()))->type();
if( surface_type != torus_type )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " The CGM cone is not an ASIS torus (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " The CGM cone is not an ASIS torus (%d %d).\n", surface_type, CONE_SURFACE_TYPE );
+ return CUBIT_FAILURE;
+ }
- // surface const* acis_surface1 = &(FACE1_ptr->geometry()->equation());
- // torus const* torus_surface1 = (torus *)acis_surface1;
+// surface const* acis_surface1 = &(FACE1_ptr->geometry()->equation());
+// torus const* torus_surface1 = (torus *)acis_surface1;
SURFACE const* acis_SURFACE1 = FACE1_ptr->geometry();
TORUS const* TORUS_SURFACE1 = (TORUS *)acis_SURFACE1;
double major_radius1 = TORUS_SURFACE1->major_radius();
- // surface const* acis_surface2 = &(FACE2_ptr->geometry()->equation());
- // torus const* torus_surface2 = (torus *)acis_surface2;
+// surface const* acis_surface2 = &(FACE2_ptr->geometry()->equation());
+// torus const* torus_surface2 = (torus *)acis_surface2;
SURFACE const* acis_SURFACE2 = FACE2_ptr->geometry();
TORUS const* TORUS_SURFACE2 = (TORUS *)acis_SURFACE2;
double major_radius2 = TORUS_SURFACE2->major_radius();
if ( major_radius1 != major_radius2 )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " Not supported yet: torii do not have the same radii.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " Not supported yet: torii do not have the same radii.\n" );
+ return CUBIT_FAILURE;
+ }
SPAposition center1 = TORUS_SURFACE1->centre();
SPAposition center2 = TORUS_SURFACE2->centre();
if ( center1 != center2 )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " Not supported yet: torii do not have the same center.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " Not supported yet: torii do not have the same center.\n" );
+ return CUBIT_FAILURE;
+ }
SPAunit_vector normal1 = TORUS_SURFACE1->normal();
SPAunit_vector normal2 = TORUS_SURFACE2->normal();
if ( ( normal1 != normal2 ) && ( - normal1 != normal2 ) )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
- " Not supported yet: torii do not have the same axis of symmetry.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_conic_mid_surface\n"
+ " Not supported yet: torii do not have the same axis of symmetry.\n" );
+ return CUBIT_FAILURE;
+ }
CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
@@ -1314,55 +1310,54 @@
new_FACE_ptr );
if (!result.ok() || new_FACE_ptr == NULL ||
new_FACE_ptr->geometry() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " ACIS api_make_trface function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " ACIS api_make_trface function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
FACE *face_list[1];
face_list[0] = new_FACE_ptr;
result = api_sheet_from_ff( 1, face_list, sheet_BODY );
if ( !result.ok() || sheet_BODY == NULL || sheet_BODY->lump() == NULL
- || sheet_BODY->lump()->shell() == NULL ||
- sheet_BODY->lump()->shell()->first_face() == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " ACIS api_sheet_from_ff function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ || sheet_BODY->lump()->shell() == NULL ||
+ sheet_BODY->lump()->shell()->first_face() == NULL )
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " ACIS api_sheet_from_ff function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
result = api_body_to_2d( sheet_BODY );
if ( !result.ok() )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " ACIS api_body_to_2d function failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " ACIS api_body_to_2d function failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
BODY* BODY_to_trim_to = AcisQueryEngine::get_BODY(body_to_trim_to);
bool delete_attribs = CUBIT_TRUE;
BODY* BODY_copy = this->copy_BODY(BODY_to_trim_to, delete_attribs);
if ( BODY_copy == NULL )
- {
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " Cannot make a copy of the parent ACIS BODY of volume.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " Cannot make a copy of the parent ACIS BODY of volume.\n" );
+ return CUBIT_FAILURE;
+ }
result = api_intersect( BODY_copy, sheet_BODY );
if ( !result.ok() )
- {
- api_del_entity( BODY_copy );
- api_del_entity( sheet_BODY );
- PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
- " ACIS api_intersect function failed.\n" );
- return CUBIT_FAILURE;
- }
+ {
+ api_del_entity( BODY_copy );
+ api_del_entity( sheet_BODY );
+ PRINT_ERROR( "In AcisModifyEngine::get_toric_mid_surface\n"
+ " ACIS api_intersect function failed.\n" );
+ return CUBIT_FAILURE;
+ }
- BodySM* midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
- midsurface_bodies.append(midsurface_body);
+ midsurface_body = AcisQueryEngine::instance()->populate_topology_bridges(sheet_BODY);
return CUBIT_SUCCESS;
}
@@ -1384,8 +1379,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview )
{
- return AcisTweakTool::instance()->tweak_chamfer( curve_list, left_offset,
- new_bodysm_list, right_offset, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_chamfer( curve_list, left_offset,
+ new_bodysm_list, right_offset, keep_old_body, preview );
}
//=============================================================================
@@ -1412,8 +1407,8 @@
CubitBoolean preview )
{
return AcisTweakTool::instance()->tweak_chamfer( ref_vertex_list, offset1,
- new_bodysm_list, edge1, offset2, edge2, offset3, edge3, keep_old_body,
- preview );
+ new_bodysm_list, edge1, offset2, edge2, offset3, edge3, keep_old_body,
+ preview );
}
//=============================================================================
@@ -1430,8 +1425,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview )
{
- return AcisTweakTool::instance()->tweak_fillet( curve_list, radius,
- new_bodysm_list, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_fillet( curve_list, radius,
+ new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1451,7 +1446,7 @@
CubitBoolean preview )
{
return AcisTweakTool::instance()->tweak_fillet( curve_ptr, start_radius,
- end_radius, new_bodysm_ptr, keep_old_body, preview );
+ end_radius, new_bodysm_ptr, keep_old_body, preview );
}
//=============================================================================
@@ -1470,7 +1465,7 @@
CubitBoolean preview )
{
return AcisTweakTool::instance()->tweak_fillet( ref_vertex_list, radius,
- new_bodysm_list, keep_old_body, preview );
+ new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1486,8 +1481,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview ) const
{
- return AcisTweakTool::instance()->tweak_move( surface_list, delta,
- new_bodysm_list, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_move( surface_list, delta,
+ new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1504,7 +1499,7 @@
CubitBoolean preview ) const
{
return AcisTweakTool::instance()->tweak_move( curve_list, delta,
- new_bodysm_list, keep_old_body, preview );
+ new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1521,8 +1516,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview ) const
{
- return AcisTweakTool::instance()->tweak_offset( surface_list,
- offset_distance, new_bodysm_list, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_offset( surface_list,
+ offset_distance, new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1540,7 +1535,7 @@
CubitBoolean preview ) const
{
return AcisTweakTool::instance()->tweak_offset( curve_list, offset_distance,
- new_bodysm_list, keep_old_body, preview );
+ new_bodysm_list, keep_old_body, preview );
}
//=============================================================================
@@ -1558,8 +1553,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview ) const
{
- return AcisTweakTool::instance()->tweak_remove( ref_face_list,
- new_bodysm_list, extend_adjoining, keep_surface, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_remove( ref_face_list,
+ new_bodysm_list, extend_adjoining, keep_surface, keep_old_body, preview );
}
//================================================================================
@@ -1574,7 +1569,7 @@
CubitBoolean preview ) const
{
return AcisTweakTool::instance()->tweak_remove( curve_list, new_bodysm_list,
- keep_old_body, preview );
+ keep_old_body, preview );
}
//=============================================================================
@@ -1592,8 +1587,8 @@
CubitBoolean keep_old_body,
CubitBoolean preview ) const
{
- return AcisTweakTool::instance()->tweak_target( surface_list, target_face_list,
- new_bodysm_list, reverse_flg, keep_old_body, preview );
+ return AcisTweakTool::instance()->tweak_target( surface_list, target_face_list,
+ new_bodysm_list, reverse_flg, keep_old_body, preview );
}
//=============================================================================
@@ -1613,7 +1608,7 @@
CubitBoolean preview ) const
{
return AcisTweakTool::instance()->tweak_target( curve_list, target_surf_list,
- new_body_list, reverse_flg, keep_old_bodies, preview );
+ new_body_list, reverse_flg, keep_old_bodies, preview );
}
//=============================================================================
@@ -1635,7 +1630,7 @@
CubitBoolean preview ) const
{
return AcisTweakTool::instance()->tweak_target( curve_list, target_curve_list,
- new_body_list, reverse_flg, keep_old_bodies, preview );
+ new_body_list, reverse_flg, keep_old_bodies, preview );
}
//================================================================================
@@ -1648,8 +1643,8 @@
DLIList<DLIList<CubitVector*>*> &vec_lists_v,
double net_tol, CubitBoolean heal ) const
{
- return AcisSurfaceTool::instance()->create_net_surface( new_body, vec_lists_u, vec_lists_v,
- net_tol, heal );
+ return AcisSurfaceTool::instance()->create_net_surface( new_body, vec_lists_u, vec_lists_v,
+ net_tol, heal );
}
//================================================================================
@@ -1660,7 +1655,7 @@
CubitStatus AcisModifyEngine::create_net_surface( DLIList<Curve*>& u_curves, DLIList<Curve*>& v_curves,
BodySM *& new_body, double net_tol, CubitBoolean heal ) const
{
- return AcisSurfaceTool::instance()->create_net_surface( u_curves, v_curves, new_body, net_tol, heal );
+ return AcisSurfaceTool::instance()->create_net_surface( u_curves, v_curves, new_body, net_tol, heal );
}
//================================================================================
@@ -1670,7 +1665,7 @@
//================================================================================
CubitStatus AcisModifyEngine::create_offset_surface( Surface* ref_face_ptr, BodySM*& new_body, double offset_distance ) const
{
- return AcisSurfaceTool::instance()->create_offset_surface( ref_face_ptr, new_body, offset_distance );
+ return AcisSurfaceTool::instance()->create_offset_surface( ref_face_ptr, new_body, offset_distance );
}
//================================================================================
@@ -1680,7 +1675,7 @@
//================================================================================
CubitStatus AcisModifyEngine::create_offset_body( BodySM* body_ptr, BodySM*& new_body, double offset_distance ) const
{
- return AcisSurfaceTool::instance()->create_offset_body( body_ptr, new_body, offset_distance );
+ return AcisSurfaceTool::instance()->create_offset_body( body_ptr, new_body, offset_distance );
}
//================================================================================
@@ -1690,7 +1685,7 @@
//================================================================================
CubitStatus AcisModifyEngine::create_skin_surface( DLIList<Curve*>& curves, BodySM*& new_body ) const
{
- return AcisSurfaceTool::instance()->create_skin_surface( curves, new_body );
+ return AcisSurfaceTool::instance()->create_skin_surface( curves, new_body );
}
//================================================================================
@@ -1705,9 +1700,9 @@
CubitBoolean align_direction, CubitBoolean perpendicular,
CubitBoolean simplify_option ) const
{
- return AcisSurfaceTool::instance()->loft_surfaces( face1, takeoff1, face2, takeoff2, new_body,
- arc_length_option, twist_option, align_direction,
- perpendicular, simplify_option );
+ return AcisSurfaceTool::instance()->loft_surfaces( face1, takeoff1, face2, takeoff2, new_body,
+ arc_length_option, twist_option, align_direction,
+ perpendicular, simplify_option );
}
//================================================================================
@@ -1722,9 +1717,9 @@
CubitBoolean align_direction, CubitBoolean perpendicular,
CubitBoolean simplify_option ) const
{
- return AcisSurfaceTool::instance()->loft_surfaces_to_body( face1, takeoff1, face2, takeoff2, new_body,
- arc_length_option, twist_option, align_direction,
- perpendicular, simplify_option );
+ return AcisSurfaceTool::instance()->loft_surfaces_to_body( face1, takeoff1, face2, takeoff2, new_body,
+ arc_length_option, twist_option, align_direction,
+ perpendicular, simplify_option );
}
//================================================================================
@@ -1735,7 +1730,7 @@
CubitStatus AcisModifyEngine::create_surface( DLIList<CubitVector*>& vec_list, BodySM *&new_body, Surface *ref_face_ptr,
CubitBoolean project_points ) const
{
- return AcisSurfaceTool::instance()->create_surface( vec_list, new_body, ref_face_ptr, project_points );
+ return AcisSurfaceTool::instance()->create_surface( vec_list, new_body, ref_face_ptr, project_points );
}
//================================================================================
@@ -1747,7 +1742,7 @@
Surface *ref_face1, double leg1, Surface *ref_face2, double leg2,
BodySM *&new_body ) const
{
- return AcisSurfaceTool::instance()->create_weld_surface( root, ref_face1, leg1, ref_face2, leg2, new_body );
+ return AcisSurfaceTool::instance()->create_weld_surface( root, ref_face1, leg1, ref_face2, leg2, new_body );
}
//-------------------------------------------------------------------------
@@ -1771,38 +1766,38 @@
BODY *&intersect_graph,
CubitBoolean &interfering ) const
{
- // Make sure we have 2 non-NULL, valid BODYs first.
+ // Make sure we have 2 non-NULL, valid BODYs first.
if ( FACE1_ptr == NULL || !IS_ENTITY_TYPE( FACE1_ptr, FACE ) ||
FACE2_ptr == NULL || !IS_ENTITY_TYPE( FACE2_ptr, FACE ) )
- {
- PRINT_ERROR("BUG: In AcisModifyEngine::BODY_intersection\n"
- " One or both input FACE's are NULL or invalid.\n");
- assert(0);
- return CUBIT_FAILURE;
- }
- //make copies to make sure nothing bad happens to the FACES.
+ {
+ PRINT_ERROR("BUG: In AcisModifyEngine::BODY_intersection\n"
+ " One or both input FACE's are NULL or invalid.\n");
+ assert(0);
+ return CUBIT_FAILURE;
+ }
+ //make copies to make sure nothing bad happens to the FACES.
FACE* copy_1 = make_FACE(FACE1_ptr);
FACE* copy_2 = make_FACE(FACE2_ptr);
intersect_graph = NULL;
- // Create the intersection graph between the given bodies
+ // Create the intersection graph between the given bodies
outcome result = api_fafa_int(copy_1, copy_2,
intersect_graph);
if (!result.ok() || intersect_graph == NULL )
- {
+ {
// Find out if the returned "slice" is empty
- interfering = CUBIT_FALSE;
- }
+ interfering = CUBIT_FALSE;
+ }
else
- {
- interfering = CUBIT_TRUE;
- }
- //now delete the copies.
+ {
+ interfering = CUBIT_TRUE;
+ }
+ //now delete the copies.
api_delent(copy_1);
api_delent(copy_2);
- //return success.
+ //return success.
return CUBIT_SUCCESS;
}
@@ -1812,101 +1807,101 @@
CubitStatus AcisModifyEngine::convert_WIRE( BODY *wire_BODY,
DLIList <Curve*> &curve_list ) const
{
- //Now get the edges from the wire body (int_graph), and create
- //ref edges.
- DLIList <EDGE*> EDGE_list;
- WIRE *cur_WIRE = NULL;
- LUMP *cur_LUMP = NULL;
- // Make sure the wire is OK, and get the appropriate entity
- // Get a WIRE if it's there
- if ( wire_BODY->wire() == NULL ||
- wire_BODY->wire()->coedge() == NULL ||
- wire_BODY->wire()->coedge()->edge() == NULL )
+ //Now get the edges from the wire body (int_graph), and create
+ //ref edges.
+ DLIList <EDGE*> EDGE_list;
+ WIRE *cur_WIRE = NULL;
+ LUMP *cur_LUMP = NULL;
+ // Make sure the wire is OK, and get the appropriate entity
+ // Get a WIRE if it's there
+ if ( wire_BODY->wire() == NULL ||
+ wire_BODY->wire()->coedge() == NULL ||
+ wire_BODY->wire()->coedge()->edge() == NULL )
{
- // If there was no WIRE, see if there's a lump
- if(wire_BODY->lump() != NULL &&
- wire_BODY->lump()->shell() != NULL &&
- wire_BODY->lump()->shell()->wire() != NULL &&
- wire_BODY->lump()->shell()->wire()->coedge() != NULL &&
- wire_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
+ // If there was no WIRE, see if there's a lump
+ if(wire_BODY->lump() != NULL &&
+ wire_BODY->lump()->shell() != NULL &&
+ wire_BODY->lump()->shell()->wire() != NULL &&
+ wire_BODY->lump()->shell()->wire()->coedge() != NULL &&
+ wire_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
{
- cur_LUMP = wire_BODY->lump();
+ cur_LUMP = wire_BODY->lump();
}
- else
+ else
{
- PRINT_ERROR("Non-existent wire body in convert_WIRE function.\n");
- return CUBIT_FAILURE;
+ PRINT_ERROR("Non-existent wire body in convert_WIRE function.\n");
+ return CUBIT_FAILURE;
}
}
- else
+ else
{
- cur_WIRE = wire_BODY->wire();
+ cur_WIRE = wire_BODY->wire();
}
- LUMP *start_LUMP = cur_LUMP;
- do{
- if((wire_BODY->wire() == NULL ||
- wire_BODY->wire()->coedge() == NULL ||
- wire_BODY->wire()->coedge()->edge() == NULL ) &&
- wire_BODY->lump() != NULL &&
- wire_BODY->lump()->shell() != NULL &&
- wire_BODY->lump()->shell()->wire() != NULL &&
- wire_BODY->lump()->shell()->wire()->coedge() != NULL &&
- wire_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
- {
- cur_WIRE = cur_LUMP->shell()->wire();
- }
+ LUMP *start_LUMP = cur_LUMP;
+ do{
+ if((wire_BODY->wire() == NULL ||
+ wire_BODY->wire()->coedge() == NULL ||
+ wire_BODY->wire()->coedge()->edge() == NULL ) &&
+ wire_BODY->lump() != NULL &&
+ wire_BODY->lump()->shell() != NULL &&
+ wire_BODY->lump()->shell()->wire() != NULL &&
+ wire_BODY->lump()->shell()->wire()->coedge() != NULL &&
+ wire_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
+ {
+ cur_WIRE = cur_LUMP->shell()->wire();
+ }
- WIRE *start_WIRE = cur_WIRE;
+ WIRE *start_WIRE = cur_WIRE;
- if (cur_WIRE != NULL){
- do {
- COEDGE *start_COEDGE = cur_WIRE->coedge();
- COEDGE *cur_COEDGE = start_COEDGE;
- do{
- EDGE *cur_EDGE = cur_COEDGE->edge();
- //Just get one of the edges. Often you have two coedges
- //for the same edge.
- if ( EDGE_list.move_to(cur_EDGE) )
- {
- // additional check to avoid an infinite loop
- if(cur_COEDGE == cur_COEDGE->next())
- break;
+ if (cur_WIRE != NULL){
+ do {
+ COEDGE *start_COEDGE = cur_WIRE->coedge();
+ COEDGE *cur_COEDGE = start_COEDGE;
+ do{
+ EDGE *cur_EDGE = cur_COEDGE->edge();
+ //Just get one of the edges. Often you have two coedges
+ //for the same edge.
+ if ( EDGE_list.move_to(cur_EDGE) )
+ {
+ // additional check to avoid an infinite loop
+ if(cur_COEDGE == cur_COEDGE->next())
+ break;
- cur_COEDGE = cur_COEDGE->next();
- continue;
- }
- else
- {
- EDGE_list.append(cur_EDGE);
- }
- EDGE *new_EDGE_ptr = NULL;
- outcome result = api_edge(cur_EDGE, new_EDGE_ptr);
- if ( !result.ok() || new_EDGE_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::body_intersection\n"
- " Cannot copy curve in intersection graph.\n");
- return CUBIT_FAILURE;
- }
- // Create a new CurveACIS object
- // Use the new EDGE to create a new CurveACIS
- Curve *new_curve =
- AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
- curve_list.append(new_curve);
- cur_COEDGE = cur_COEDGE->next();
- } while (cur_COEDGE && (cur_COEDGE != start_COEDGE));
- cur_WIRE = cur_WIRE->next();
- } while (cur_WIRE && (cur_WIRE != start_WIRE));
- }
+ cur_COEDGE = cur_COEDGE->next();
+ continue;
+ }
+ else
+ {
+ EDGE_list.append(cur_EDGE);
+ }
+ EDGE *new_EDGE_ptr = NULL;
+ outcome result = api_edge(cur_EDGE, new_EDGE_ptr);
+ if ( !result.ok() || new_EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::body_intersection\n"
+ " Cannot copy curve in intersection graph.\n");
+ return CUBIT_FAILURE;
+ }
+ // Create a new CurveACIS object
+ // Use the new EDGE to create a new CurveACIS
+ Curve *new_curve =
+ AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
+ curve_list.append(new_curve);
+ cur_COEDGE = cur_COEDGE->next();
+ } while (cur_COEDGE && (cur_COEDGE != start_COEDGE));
+ cur_WIRE = cur_WIRE->next();
+ } while (cur_WIRE && (cur_WIRE != start_WIRE));
+ }
- //we may not have a lump, ACIS sometimes will return a wire
- //as the intersection and other times a LUMP...
- if (cur_LUMP)
- {
- cur_LUMP = cur_LUMP->next();
- }
- }while (cur_LUMP && (start_LUMP != cur_LUMP));
- //At this point we are done!
- return CUBIT_SUCCESS;
+ //we may not have a lump, ACIS sometimes will return a wire
+ //as the intersection and other times a LUMP...
+ if (cur_LUMP)
+ {
+ cur_LUMP = cur_LUMP->next();
+ }
+ }while (cur_LUMP && (start_LUMP != cur_LUMP));
+ //At this point we are done!
+ return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1920,62 +1915,62 @@
//
//-------------------------------------------------------------------------
CubitBoolean AcisModifyEngine::BODYs_interfering (
- BODY* body1_ptr,
- BODY* body2_ptr) const
+ BODY* body1_ptr,
+ BODY* body2_ptr) const
{
- CpuTimer timer;
+ CpuTimer timer;
- // Efficient algorithm to test interference between 2 ACIS BODYs. The
- // entire intersection boolean operation is *not* performed if api_slice
- // is used.
+ // Efficient algorithm to test interference between 2 ACIS BODYs. The
+ // entire intersection boolean operation is *not* performed if api_slice
+ // is used.
- CubitBoolean interfering = CUBIT_TRUE;
+ CubitBoolean interfering = CUBIT_TRUE;
- // Use the NOP pair to ensure that the roll-back is done by ACIS after
- // the test, so that the input BODYs are unaffected by this operation.
- API_NOP_BEGIN;
+ // Use the NOP pair to ensure that the roll-back is done by ACIS after
+ // the test, so that the input BODYs are unaffected by this operation.
+ API_NOP_BEGIN;
- BODY* slice = NULL;
+ BODY* slice = NULL;
- // Make sure we have 2 non-NULL, valid BODYs first.
- if ( body1_ptr == NULL || !IS_ENTITY_TYPE( body1_ptr, BODY ) ||
- body2_ptr == NULL || !IS_ENTITY_TYPE( body2_ptr, BODY ) )
- {
+ // Make sure we have 2 non-NULL, valid BODYs first.
+ if ( body1_ptr == NULL || !IS_ENTITY_TYPE( body1_ptr, BODY ) ||
+ body2_ptr == NULL || !IS_ENTITY_TYPE( body2_ptr, BODY ) )
+ {
PRINT_ERROR("BUG: In AcisModifyEngine::BODYs_interfering\n"
" One or both input BODYs are NULL or invalid.\n");
assert(0);
return CUBIT_FALSE;
- }
+ }
- // Create the intersection graph between the given bodies
- outcome status = api_slice(body1_ptr, body2_ptr,
- *(SPAunit_vector *)NULL_REF, slice);
+ // Create the intersection graph between the given bodies
+ outcome status = api_slice(body1_ptr, body2_ptr,
+ *(SPAunit_vector *)NULL_REF, slice);
- if (!status.ok() || slice == NULL )
- interfering = CUBIT_FALSE;
- else
- interfering = CUBIT_TRUE;
+ if (!status.ok() || slice == NULL )
+ interfering = CUBIT_FALSE;
+ else
+ interfering = CUBIT_TRUE;
- // Set the result variable to true so that the API_NOP_END
- // can roll back the bulletin board to ensure that the
- // ENTITYs that were modified within this NOP block will be
- // returned to their original state.
- result = outcome(0);
+ // Set the result variable to true so that the API_NOP_END
+ // can roll back the bulletin board to ensure that the
+ // ENTITYs that were modified within this NOP block will be
+ // returned to their original state.
+ result = outcome(0);
- API_NOP_END;
+ API_NOP_END;
- PRINT_DEBUG_3( "CPU time taken to check if two BODYs are "
- "interfering: %f secs\n", timer.cpu_secs());
+ PRINT_DEBUG_3( "CPU time taken to check if two BODYs are "
+ "interfering: %f secs\n", timer.cpu_secs());
- // Return the interference status
- return interfering;
+ // Return the interference status
+ return interfering;
}
CubitStatus AcisModifyEngine::stitch_FACEs( DLIList<FACE*> &faces,
- FACE *&result_FACE,
- BODY *&stitched_BODY )const
+ FACE *&result_FACE,
+ BODY *&stitched_BODY ) const
{
//Make copies of each FACE
ENTITY_LIST copied_FACES;
@@ -1985,62 +1980,62 @@
BODY *master = NULL;
for( i=faces.size(); i--;)
- {
- FACE *tmp_FACE = faces.get_and_step();
- ENTITY *new_FACE = NULL;
- result = api_copy_entity( (ENTITY*)tmp_FACE, new_FACE );
+ {
+ FACE *tmp_FACE = faces.get_and_step();
+ ENTITY *new_FACE = NULL;
+ result = api_copy_entity( (ENTITY*)tmp_FACE, new_FACE );
- FACE *face_list[1];
- face_list[0] = (FACE*)new_FACE;
- result = api_sheet_from_ff( 1, face_list, sheet_BODY_ptr );
- result = api_body_to_2d( sheet_BODY_ptr );
+ FACE *face_list[1];
+ face_list[0] = (FACE*)new_FACE;
+ result = api_sheet_from_ff( 1, face_list, sheet_BODY_ptr );
+ result = api_body_to_2d( sheet_BODY_ptr );
- if( !result.ok() )
- {
- PRINT_ERROR("Problems copying surface(s)\n");
- //delete all other surface
- for(i=0; i<copied_FACES.count(); i++)
- api_delent( copied_FACES[i]);
- return CUBIT_FAILURE;
- }
+ if( !result.ok() )
+ {
+ PRINT_ERROR("Problems copying surface(s)\n");
+ //delete all other surface
+ for(i=0; i<copied_FACES.count(); i++)
+ api_delent( copied_FACES[i]);
+ return CUBIT_FAILURE;
+ }
+ else
+ {
+ if( master == NULL )
+ master = sheet_BODY_ptr;
else
- {
- if( master == NULL )
- master = sheet_BODY_ptr;
- else
- copied_FACES.add( sheet_BODY_ptr );
- }
+ copied_FACES.add( sheet_BODY_ptr );
}
+ }
//stitch together to form a sheet body.
#if CUBIT_ACIS_VERSION < 1100
for( i=0; i<copied_FACES.count(); i++ )
+ {
+ result = api_unite((BODY*)copied_FACES[i], master );
+ if( !result.ok() )
{
- result = api_unite((BODY*)copied_FACES[i], master );
- if( !result.ok() )
- {
- PRINT_ERROR("Problems stitching surfaces\n");
- //delete all other surface
- for(; i<copied_FACES.count(); i++)
- api_delent( copied_FACES[i]);
- return CUBIT_FAILURE;
- }
+ PRINT_ERROR("Problems stitching surfaces\n");
+ //delete all other surface
+ for(; i<copied_FACES.count(); i++)
+ api_delent( copied_FACES[i]);
+ return CUBIT_FAILURE;
}
+ }
#else
exact_stitch_options stitch_opts;
result = api_stitch( master, copied_FACES, &stitch_opts );
#endif
if( !result.ok() )
- {
- api_delent( master );
- stitched_BODY = NULL;
- for(i=0; i<copied_FACES.count(); i++)
- api_delent( copied_FACES[i]);
- result_FACE = NULL;
- return CUBIT_FAILURE;
- }
+ {
+ api_delent( master );
+ stitched_BODY = NULL;
+ for(i=0; i<copied_FACES.count(); i++)
+ api_delent( copied_FACES[i]);
+ result_FACE = NULL;
+ return CUBIT_FAILURE;
+ }
copied_FACES.clear();
stitched_BODY = master;
@@ -2050,16 +2045,17 @@
api_get_faces( master, copied_FACES );
if( copied_FACES.count() != 1 )
- {
- result_FACE = NULL;
- return CUBIT_SUCCESS;
- }
+ {
+ result_FACE = NULL;
+ return CUBIT_SUCCESS;
+ }
else
result_FACE = (FACE*)copied_FACES[0];
return CUBIT_SUCCESS;
}
+
CubitStatus AcisModifyEngine::trim_up_to_next_surface( BODY *&tool_BODY,
DLIList<BodySM*> &blank_bodies,
VERTEX *surf_VERT )
@@ -2072,17 +2068,17 @@
int i;
for( i=blank_bodies.size()-1; i--; )
- {
- blank_BODY = AcisQueryEngine::get_BODY( blank_bodies.get_and_step() );
- BODY *copy_blank_BODY = this->copy_BODY(blank_BODY, true );
- result = api_unite( copy_blank_BODY, master_blank_BODY);
+ {
+ blank_BODY = AcisQueryEngine::get_BODY( blank_bodies.get_and_step() );
+ BODY *copy_blank_BODY = this->copy_BODY(blank_BODY, true );
+ result = api_unite( copy_blank_BODY, master_blank_BODY);
- if( !result.ok() )
- {
- PRINT_ERROR("Problems uniting blank volumes with 'up_to_next' option.\n");
- return CUBIT_FAILURE;
- }
+ if( !result.ok() )
+ {
+ PRINT_ERROR("Problems uniting blank volumes with 'up_to_next' option.\n");
+ return CUBIT_FAILURE;
}
+ }
//get all the cells
generic_graph *boolean_graph;
@@ -2093,10 +2089,10 @@
gvertex **vertex_array = boolean_graph->get_vertices( num_verts );
ENTITY_LIST common_vertices;
for(i=num_verts; i--; )
- {
- if( vertex_array[i]->is_kind(0) && vertex_array[i]->is_kind(1) )
- common_vertices.add( vertex_array[i]->get_entity() );
- }
+ {
+ if( vertex_array[i]->is_kind(0) && vertex_array[i]->is_kind(1) )
+ common_vertices.add( vertex_array[i]->get_entity() );
+ }
ENTITY *vertex_to_keep = NULL;
@@ -2104,35 +2100,35 @@
if( common_vertices.count() == 1 )
vertex_to_keep = common_vertices[0];
else
+ {
+ SPAposition point_on_surf = surf_VERT->geometry()->coords();
+ SPAposition dummy_pos;
+ double min_distance = -1, tmp_distance = 0;
+ for( i=common_vertices.count(); i--; )
{
- SPAposition point_on_surf = surf_VERT->geometry()->coords();
- SPAposition dummy_pos;
- double min_distance = -1, tmp_distance = 0;
- for( i=common_vertices.count(); i--; )
- {
- if( is_CELL( common_vertices[i] ) )
- {
- CELL *tmp_cell = NULL;
- tmp_cell = static_cast<CELL*>( common_vertices[i] );
- BODY *tmp_body = NULL;
- api_ct_copy_cell( tmp_cell, tmp_body );
+ if( is_CELL( common_vertices[i] ) )
+ {
+ CELL *tmp_cell = NULL;
+ tmp_cell = static_cast<CELL*>( common_vertices[i] );
+ BODY *tmp_body = NULL;
+ api_ct_copy_cell( tmp_cell, tmp_body );
- api_entity_point_distance( tmp_body, point_on_surf, dummy_pos, tmp_distance );
- api_delent( tmp_body );
+ api_entity_point_distance( tmp_body, point_on_surf, dummy_pos, tmp_distance );
+ api_delent( tmp_body );
- if( min_distance < 0 )
- {
- min_distance = tmp_distance;
- vertex_to_keep = common_vertices[i];
- }
- else if( tmp_distance < min_distance )
- {
- min_distance = tmp_distance;
- vertex_to_keep = common_vertices[i];
- }
- }
- }
+ if( min_distance < 0 )
+ {
+ min_distance = tmp_distance;
+ vertex_to_keep = common_vertices[i];
+ }
+ else if( tmp_distance < min_distance )
+ {
+ min_distance = tmp_distance;
+ vertex_to_keep = common_vertices[i];
+ }
+ }
}
+ }
ENTITY_LIST ent_list;
if( vertex_to_keep )
@@ -2161,95 +2157,95 @@
// Creation Date :
//-------------------------------------------------------------------------
CubitStatus AcisModifyEngine::sweep_FACE_along_vector(
- FACE *& FACE_ptr,
- const CubitVector& sweep_vector,
- bool& volume_is_negative,
- bool primary_side,
- double draft_angle,
- int draft_type,
- bool rigid,
- FACE *to_FACE,
- BODY *to_BODY) const
+ FACE *& FACE_ptr,
+ const CubitVector& sweep_vector,
+ bool& volume_is_negative,
+ bool primary_side,
+ double draft_angle,
+ int draft_type,
+ bool rigid,
+ FACE *to_FACE,
+ BODY *to_BODY) const
{
- // Make sure the distance of the sweep is not zero
- if ( sweep_vector.length() < (1.0E5 * CUBIT_DBL_MIN) )
- {
+ // Make sure the distance of the sweep is not zero
+ if ( sweep_vector.length() < (1.0E5 * CUBIT_DBL_MIN) )
+ {
PRINT_WARNING("Distance of sweep is almost zero. No sweep was performed.\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
- if ( !(draft_type == 0 || draft_type == 1) )
- {
+ // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
+ if ( !(draft_type == 0 || draft_type == 1) )
+ {
PRINT_ERROR("Draft type must be either 0 or 1\n");
return CUBIT_FAILURE;
- }
+ }
- // Sweep ho!!
- CubitStatus sweep_status = CUBIT_SUCCESS;
- SPAvector ACIS_sweep_vector;
- ACIS_sweep_vector.set_x(sweep_vector.x());
- ACIS_sweep_vector.set_y(sweep_vector.y());
- ACIS_sweep_vector.set_z(sweep_vector.z());
+ // Sweep ho!!
+ CubitStatus sweep_status = CUBIT_SUCCESS;
+ SPAvector ACIS_sweep_vector;
+ ACIS_sweep_vector.set_x(sweep_vector.x());
+ ACIS_sweep_vector.set_y(sweep_vector.y());
+ ACIS_sweep_vector.set_z(sweep_vector.z());
- logical ACIS_primary_side = CUBIT_TRUE;
- if (!primary_side)
- ACIS_primary_side = CUBIT_FALSE;
+ logical ACIS_primary_side = CUBIT_TRUE;
+ if (!primary_side)
+ ACIS_primary_side = CUBIT_FALSE;
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans.
- outcome result = api_set_int_option ( "merge",
- CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans.
+ outcome result = api_set_int_option ( "merge",
+ CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_along_vector.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- sweep_options ACIS_sweep_options;
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_which_side(ACIS_primary_side);
- ACIS_sweep_options.set_rigid(rigid);
-
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ sweep_options ACIS_sweep_options;
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_which_side(ACIS_primary_side);
+ ACIS_sweep_options.set_rigid(rigid);
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
+
else if(to_BODY)
{
ACIS_sweep_options.set_sweep_to_body(to_BODY);
@@ -2258,187 +2254,186 @@
//body.
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- BODY* BODYptr = NULL;
- result = api_sweep_with_options (FACE_ptr, ACIS_sweep_vector,
- &ACIS_sweep_options, BODYptr);
+ BODY* BODYptr = NULL;
+ result = api_sweep_with_options (FACE_ptr, ACIS_sweep_vector,
+ &ACIS_sweep_options, BODYptr);
- if (BODYptr)
- {
- //when setting the sweep to end at a face, result is BODYptr.
- if( to_FACE || to_BODY)
- {
- //swept body & to_FACE must intersect some
- BODY *tmp_body = NULL;
- if(to_FACE)
- tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
- else
- tmp_body = to_BODY;
- if ( !BODYs_interfering( tmp_body, BODYptr ) )
- {
- PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
- if (to_FACE)
- api_delent( tmp_body );
- return CUBIT_FAILURE;
- }
- FACE_ptr = BODYptr->lump()->shell()->first_face();
- }
-
- else
- {
- PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
- PRINT_ERROR("API wants to create a new volume.\n");
- api_delent( BODYptr );
- sweep_status = CUBIT_FAILURE;
- }
- }
+ if (BODYptr)
+ {
+ //when setting the sweep to end at a face, result is BODYptr.
+ if( to_FACE || to_BODY )
+ {
+ //swept body & to_FACE must intersect some
+ BODY *tmp_body = NULL;
+ if(to_FACE)
+ tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
+ else
+ tmp_body = to_BODY;
+ if ( !BODYs_interfering( tmp_body, BODYptr ) )
+ {
+ PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
+ if (to_FACE)
+ api_delent( tmp_body );
+ return CUBIT_FAILURE;
+ }
+ FACE_ptr = BODYptr->lump()->shell()->first_face();
+ }
+ else
+ {
+ PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
+ PRINT_ERROR("API wants to create a new volume.\n");
+ api_delent( BODYptr );
+ sweep_status = CUBIT_FAILURE;
+ }
+ }
- if (!result.ok())
- {
- if(rigid)
+ if (!result.ok())
+ {
+ if(rigid)
PRINT_WARNING("Because surface is not planar, the 'rigid' keyword will be ignored.\n");
- PRINT_DEBUG_99("api_sweep_with_options failed, reverting to api_sw_face_vec.\n");
+ PRINT_DEBUG_99("api_sweep_with_options failed, reverting to api_sw_face_vec.\n");
- result = api_sw_face_vec (FACE_ptr, ACIS_primary_side, ACIS_sweep_vector,
- draft_angle, draft_type);
+ result = api_sw_face_vec (FACE_ptr, ACIS_primary_side, ACIS_sweep_vector,
+ draft_angle, draft_type);
- if (!result.ok())
- {
+ if (!result.ok())
+ {
- PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
- PRINT_INFO("in sweep_FACE_along_vector\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- sweep_status = CUBIT_FAILURE;
- }
- }
+ PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
+ PRINT_INFO("in sweep_FACE_along_vector\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ sweep_status = CUBIT_FAILURE;
+ }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- if (!result.ok())
- {
- PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
- PRINT_INFO("in sweep_FACE_along_vector\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- sweep_status = CUBIT_FAILURE;
- }
+ if (!result.ok())
+ {
+ PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
+ PRINT_INFO("in sweep_FACE_along_vector\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ sweep_status = CUBIT_FAILURE;
+ }
- // Now set the option back to its default
- result = api_set_int_option ( "merge",
- CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge",
+ CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_along_vector.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- // Finally, check to make sure that the volume of the swept BODY is positive.
- // 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)
- if ( AcisQueryEngine::instance()->volume(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr)) < 0.0)
- {
+ // Finally, check to make sure that the volume of the swept BODY is positive.
+ // 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)
+ if ( AcisQueryEngine::instance()->volume(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr)) < 0.0)
+ {
sweep_status = CUBIT_FAILURE;
volume_is_negative = true;
- // Set the value of result such that the API_END macro performs
- // a bulletin board rollback operation to the corresponding API_BEGIN
- //result = outcome(API_FAILED);
- }
+ // Set the value of result such that the API_END macro performs
+ // a bulletin board rollback operation to the corresponding API_BEGIN
+ //result = outcome(API_FAILED);
+ }
- return sweep_status;
+ return sweep_status;
}
CubitStatus AcisModifyEngine::sweep_FACE_perpendicular(
- FACE *& FACE_ptr,
- double distance,
- bool& volume_is_negative,
- bool primary_side,
- double draft_angle,
- int draft_type,
- bool rigid,
- FACE *to_FACE,
- BODY *to_BODY) const
+ FACE *& FACE_ptr,
+ double distance,
+ bool& volume_is_negative,
+ bool primary_side,
+ double draft_angle,
+ int draft_type,
+ bool rigid,
+ FACE *to_FACE,
+ BODY *to_BODY) const
{
- // Make sure the distance of the sweep is not zero
- if ( distance < (1.0E5 * CUBIT_DBL_MIN) )
- {
+ // Make sure the distance of the sweep is not zero
+ if ( distance < (1.0E5 * CUBIT_DBL_MIN) )
+ {
PRINT_WARNING("Distance of sweep is almost zero. No sweep was performed.\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
- if ( !(draft_type == 0 || draft_type == 1) )
- {
+ // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
+ if ( !(draft_type == 0 || draft_type == 1) )
+ {
PRINT_ERROR("Draft type must be either 0 or 1\n");
return CUBIT_FAILURE;
- }
+ }
- // Sweep ho!!
- CubitStatus sweep_status = CUBIT_SUCCESS;
+ // Sweep ho!!
+ CubitStatus sweep_status = CUBIT_SUCCESS;
- logical ACIS_primary_side = CUBIT_FALSE;
- if (!primary_side)
- ACIS_primary_side = CUBIT_TRUE;
+ logical ACIS_primary_side = CUBIT_FALSE;
+ if (!primary_side)
+ ACIS_primary_side = CUBIT_TRUE;
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans.
- outcome result = api_set_int_option ( "merge",
- CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans.
+ outcome result = api_set_int_option ( "merge",
+ CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_perpendicular.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- sweep_options ACIS_sweep_options;
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_which_side(ACIS_primary_side);
- ACIS_sweep_options.set_rigid(rigid);
+ sweep_options ACIS_sweep_options;
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_which_side(ACIS_primary_side);
+ ACIS_sweep_options.set_rigid(rigid);
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )//mutually exclusive with sweep_to_body
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )//mutually exclusive with sweep_to_body
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
else if(to_BODY)//mutually exclusive with to_face
{
@@ -2449,168 +2444,168 @@
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- BODY* BODYptr = NULL;
- result = api_sweep_with_options (FACE_ptr, distance,
- &ACIS_sweep_options, BODYptr);
+ BODY* BODYptr = NULL;
+ result = api_sweep_with_options (FACE_ptr, distance,
+ &ACIS_sweep_options, BODYptr);
- if (BODYptr)
- {
- //when setting the sweep to end at a face, result is BODYptr.
- if( to_FACE || to_BODY)
- {
- BODY *tmp_body = NULL;
- //swept body & to_FACE must intersect some
- if(to_FACE)
- tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
- else
- tmp_body = to_BODY;
- if ( !BODYs_interfering( tmp_body, BODYptr ) )
- {
- PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
- if(to_FACE)
- api_delent( tmp_body );
- return CUBIT_FAILURE;
- }
- FACE_ptr = BODYptr->lump()->shell()->first_face();
- }
- else
- {
- PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
- PRINT_ERROR("API wants to create a new volume \n");
- api_delent( BODYptr );
- sweep_status = CUBIT_FAILURE;
- }
- }
+ if (BODYptr)
+ {
+ //when setting the sweep to end at a face, result is BODYptr.
+ if( to_FACE || to_BODY)
+ {
+ BODY *tmp_body = NULL;
+ //swept body & to_FACE must intersect some
+ if(to_FACE)
+ tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
+ else
+ tmp_body = to_BODY;
+ if ( !BODYs_interfering( tmp_body, BODYptr ) )
+ {
+ PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
+ if(to_FACE)
+ api_delent( tmp_body );
+ return CUBIT_FAILURE;
+ }
+ FACE_ptr = BODYptr->lump()->shell()->first_face();
+ }
+ else
+ {
+ PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
+ PRINT_ERROR("API wants to create a new volume \n");
+ api_delent( BODYptr );
+ sweep_status = CUBIT_FAILURE;
+ }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- if (!result.ok())
- {
+ if (!result.ok())
+ {
PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options \n");
PRINT_INFO("in sweep_FACE_perpendicular\n");
PRINT_INFO("If face is not planar, perpendicular doesn't make sense.\n"
"Try sweeping along a vector instead.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
sweep_status = CUBIT_FAILURE;
- }
+ }
- // Now set the option back to its default
- result = api_set_int_option ( "merge",
- CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge",
+ CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_perpendicular.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- // Finally, check to make sure that the volume of the swept BODY is positive.
- // 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)
- if ( AcisQueryEngine::instance()->volume(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr)) < 0.0)
- {
+ // Finally, check to make sure that the volume of the swept BODY is positive.
+ // 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)
+ if ( AcisQueryEngine::instance()->volume(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr)) < 0.0)
+ {
sweep_status = CUBIT_FAILURE;
volume_is_negative = CUBIT_TRUE;
- // Set the value of result such that the API_END macro performs
- // a bulletin board rollback operation to the corresponding API_BEGIN
- //result = outcome(API_FAILED);
- }
+ // Set the value of result such that the API_END macro performs
+ // a bulletin board rollback operation to the corresponding API_BEGIN
+ //result = outcome(API_FAILED);
+ }
- return sweep_status;
+ return sweep_status;
}
CubitStatus AcisModifyEngine::sweep_EDGE_along_vector(
- EDGE* EDGE_ptr,
- BODY *&BODYptr,
- const CubitVector& sweep_vector,
- double draft_angle,
- int draft_type,
- bool rigid,
- FACE *to_FACE,
- BODY *to_BODY) const
+ EDGE* EDGE_ptr,
+ BODY *&BODYptr,
+ const CubitVector& sweep_vector,
+ double draft_angle,
+ int draft_type,
+ bool rigid,
+ FACE *to_FACE,
+ BODY* to_BODY) const
{
- // Make sure the distance of the sweep is not zero
- if ( sweep_vector.length() < (1.0E5 * CUBIT_DBL_MIN) )
- {
+ // Make sure the distance of the sweep is not zero
+ if ( sweep_vector.length() < (1.0E5 * CUBIT_DBL_MIN) )
+ {
PRINT_WARNING("Distance of sweep is almost zero. No sweep was performed.\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
- if ( !(draft_type == 0 || draft_type == 1) )
- {
+ // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
+ if ( !(draft_type == 0 || draft_type == 1) )
+ {
PRINT_ERROR("Draft type must be either 0 or 1\n");
return CUBIT_FAILURE;
- }
+ }
- // Sweep ho!!
- CubitStatus sweep_status = CUBIT_SUCCESS;
- SPAvector ACIS_sweep_vector;
- ACIS_sweep_vector.set_x(sweep_vector.x());
- ACIS_sweep_vector.set_y(sweep_vector.y());
- ACIS_sweep_vector.set_z(sweep_vector.z());
+ // Sweep ho!!
+ CubitStatus sweep_status = CUBIT_SUCCESS;
+ SPAvector ACIS_sweep_vector;
+ ACIS_sweep_vector.set_x(sweep_vector.x());
+ ACIS_sweep_vector.set_y(sweep_vector.y());
+ ACIS_sweep_vector.set_z(sweep_vector.z());
- // Turn off the merge option in ACIS so EDGEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans.
- outcome result = api_set_int_option ( "merge",
- CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so EDGEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans.
+ outcome result = api_set_int_option ( "merge",
+ CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_along_vector.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- sweep_options ACIS_sweep_options;
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_rigid(rigid);
- EDGE *copied_EDGE_ptr = NULL;
- result = api_edge( EDGE_ptr, copied_EDGE_ptr);
+ sweep_options ACIS_sweep_options;
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_rigid(rigid);
+ EDGE *copied_EDGE_ptr = NULL;
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr);
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )//mutually exclusive with sweep_to_body
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )//mutually exclusive with sweep_to_body
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
else if(to_BODY)//mutually exclusive with to_face
{
@@ -2621,52 +2616,52 @@
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to copy edge\n");
- return CUBIT_FAILURE;
- }
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
- CUBIT_TRUE );
- result = api_sweep_with_options (copied_EDGE_ptr, ACIS_sweep_vector,
- &ACIS_sweep_options, BODYptr);
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to copy edge\n");
+ return CUBIT_FAILURE;
+ }
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
+ CUBIT_TRUE );
+ result = api_sweep_with_options (copied_EDGE_ptr, ACIS_sweep_vector,
+ &ACIS_sweep_options, BODYptr);
- if (BODYptr)
- {
- sweep_status = CUBIT_SUCCESS;
- }
- if (!result.ok())
- {
+ if (BODYptr)
+ {
+ sweep_status = CUBIT_SUCCESS;
+ }
+ if (!result.ok())
+ {
PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
if ( copied_EDGE_ptr != NULL )
api_delent(copied_EDGE_ptr);
sweep_status = CUBIT_FAILURE;
- }
+ }
- // Now set the option back to its default
- result = api_set_int_option ( "merge",
- CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge",
+ CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_along_vector.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- // Finally, check to make sure that the volume of the swept BODY is positive.
- // 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)
+ // Finally, check to make sure that the volume of the swept BODY is positive.
+ // 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)
- return sweep_status;
+ return sweep_status;
}
@@ -2681,69 +2676,69 @@
// Creation Date : 8/7/98
//-------------------------------------------------------------------------
CubitStatus AcisModifyEngine::sweep_FACE_along_WIRE(
- FACE *& FACE_ptr,
- BODY* wire_BODY_ptr,
- double draft_angle,
- int draft_type,
- bool rigid,
- FACE *to_FACE,
- BODY *to_BODY ) const
+ FACE *& FACE_ptr,
+ BODY* wire_BODY_ptr,
+ double draft_angle,
+ int draft_type,
+ bool rigid,
+ FACE *to_FACE,
+ BODY *to_BODY ) const
{
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- CubitStatus sweep_status = CUBIT_SUCCESS;
+ CubitStatus sweep_status = CUBIT_SUCCESS;
- sweep_options ACIS_sweep_options;
+ sweep_options ACIS_sweep_options;
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans.
- outcome result = api_set_int_option ( "merge", CUBIT_FALSE );
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans.
+ outcome result = api_set_int_option ( "merge", CUBIT_FALSE );
- if (!result.ok())
- {
- PRINT_WARNING("In AcisModifyEngine::sweep_FACE_along_WIRE.\n"
- " Error in api_set_int_option.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
+ if (!result.ok())
+ {
+ PRINT_WARNING("In AcisModifyEngine::sweep_FACE_along_WIRE.\n"
+ " Error in api_set_int_option.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
- result = outcome(0);
- }
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
+ result = outcome(0);
+ }
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_rigid(rigid);
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_rigid(rigid);
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )//mutually exclusive with sweep_to_body.
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )//mutually exclusive with sweep_to_body.
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
else if(to_BODY)//mutually exclusive with to_face
{
@@ -2754,179 +2749,179 @@
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- // Do the real work!!
- BODY* BODYptr = NULL;
- result = api_sweep_with_options (FACE_ptr, (EDGE*)wire_BODY_ptr, &ACIS_sweep_options, BODYptr);
+ // Do the real work!!
+ BODY* BODYptr = NULL;
+ result = api_sweep_with_options (FACE_ptr, (EDGE*)wire_BODY_ptr, &ACIS_sweep_options, BODYptr);
- if (BODYptr)
- {
- //when setting the sweep to end at a face, result is BODYptr.
- if( to_FACE || to_BODY)
- {
- BODY *tmp_body = NULL;
- //swept body & to_FACE must intersect some
- if(to_FACE)
- tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
- else
- tmp_body = to_BODY;
+ if (BODYptr)
+ {
+ //when setting the sweep to end at a face, result is BODYptr.
+ if( to_FACE || to_BODY )
+ {
+ BODY *tmp_body = NULL;
+ //swept body & to_FACE must intersect some
+ if(to_FACE)
+ tmp_body = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_to_sweep_to );
+ else
+ tmp_body = to_BODY;
- if ( !BODYs_interfering( tmp_body, BODYptr ) )
- {
- PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
- if(to_FACE)
- api_delent( tmp_body );
- return CUBIT_FAILURE;
- }
- FACE_ptr = BODYptr->lump()->shell()->first_face();
- }
- else
- {
- PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
- PRINT_ERROR("API wants to create a new volume \n");
- api_delent( BODYptr );
- sweep_status = CUBIT_FAILURE;
- }
- }
+ if ( !BODYs_interfering( tmp_body, BODYptr ) )
+ {
+ PRINT_ERROR("Terminating surface must intersect swept tool volume.\n");
+ if(to_FACE)
+ api_delent( tmp_body );
+ return CUBIT_FAILURE;
+ }
+ FACE_ptr = BODYptr->lump()->shell()->first_face();
+ }
+ else
+ {
+ PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
+ PRINT_ERROR("API wants to create a new volume \n");
+ api_delent( BODYptr );
+ sweep_status = CUBIT_FAILURE;
+ }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- if (!result.ok())
- {
+ if (!result.ok())
+ {
PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
sweep_status = CUBIT_FAILURE;
- }
+ }
- // Now set the option back to its default
- result = api_set_int_option ( "merge", CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge", CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_along_WIRE.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- return sweep_status;
+ return sweep_status;
}
CubitStatus AcisModifyEngine::sweep_EDGE_along_WIRE(
- EDGE* EDGE_ptr,
- BODY* wire_BODY_ptr,
- BODY *&BODYptr,
- double draft_angle,
- int draft_type,
- bool rigid,
- FACE *to_FACE,
- BODY *to_BODY) const
+ EDGE* EDGE_ptr,
+ BODY* wire_BODY_ptr,
+ BODY *&BODYptr,
+ double draft_angle,
+ int draft_type,
+ bool rigid,
+ FACE *to_FACE,
+ BODY *to_BODY) const
{
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- CubitStatus sweep_status = CUBIT_SUCCESS;
+ CubitStatus sweep_status = CUBIT_SUCCESS;
- sweep_options ACIS_sweep_options;
+ sweep_options ACIS_sweep_options;
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans.
- outcome result = api_set_int_option ( "merge", CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans.
+ outcome result = api_set_int_option ( "merge", CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_along_WIRE.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_rigid(rigid);
- EDGE *copied_EDGE_ptr = NULL;
- result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to copy edge\n");
- return CUBIT_FAILURE;
- }
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_rigid(rigid);
+ EDGE *copied_EDGE_ptr = NULL;
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to copy edge\n");
+ return CUBIT_FAILURE;
+ }
- //if edge-to-sweep has start or end vertex coincident w/
- //end vertex on path wire, flip all edges in path wire
- SPAposition end_coords;
- get_wire_end_position(wire_BODY_ptr, end_coords);
+ //if edge-to-sweep has start or end vertex coincident w/
+ //end vertex on path wire, flip all edges in path wire
+ SPAposition end_coords;
+ get_wire_end_position(wire_BODY_ptr, end_coords);
- SPAposition tmp_coords = EDGE_ptr->start()->geometry()->coords();
- CubitVector start_coord( tmp_coords.x(), tmp_coords.y(), tmp_coords.z() );
+ SPAposition tmp_coords = EDGE_ptr->start()->geometry()->coords();
+ CubitVector start_coord( tmp_coords.x(), tmp_coords.y(), tmp_coords.z() );
- tmp_coords = EDGE_ptr->end()->geometry()->coords();
- CubitVector end_coord( tmp_coords.x(), tmp_coords.y(), tmp_coords.z() );
+ tmp_coords = EDGE_ptr->end()->geometry()->coords();
+ CubitVector end_coord( tmp_coords.x(), tmp_coords.y(), tmp_coords.z() );
- CubitVector wire_end_coord( end_coords.x(), end_coords.y(), end_coords.z() );
+ CubitVector wire_end_coord( end_coords.x(), end_coords.y(), end_coords.z() );
- if ( (GeometryQueryTool::instance()->about_spatially_equal(start_coord, wire_end_coord,
- GeometryQueryTool::get_geometry_factor())) ||
- (GeometryQueryTool::instance()->about_spatially_equal(end_coord, wire_end_coord,
- GeometryQueryTool::get_geometry_factor())) )
- {
- //reverse all edges in wire body
- ENTITY_LIST EDGE_list;
- api_get_edges( wire_BODY_ptr, EDGE_list );
+ if ( (GeometryQueryTool::instance()->about_spatially_equal(start_coord, wire_end_coord,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GeometryQueryTool::instance()->about_spatially_equal(end_coord, wire_end_coord,
+ GeometryQueryTool::get_geometry_factor())) )
+ {
+ //reverse all edges in wire body
+ ENTITY_LIST EDGE_list;
+ api_get_edges( wire_BODY_ptr, EDGE_list );
- EDGE_list.init();
- ENTITY *tmp_ent = NULL;
- while( (tmp_ent = EDGE_list.next()) != NULL )
- {
- EDGE *tmp_edge = (EDGE*)tmp_ent;
- VERTEX *old_start = tmp_edge->start();
- VERTEX *old_end = tmp_edge->end();
- tmp_edge->set_sense( tmp_edge->sense() == FORWARD ? REVERSED : FORWARD );
- tmp_edge->set_start( old_end );
- tmp_edge->set_end( old_start );
- }
- }
+ EDGE_list.init();
+ ENTITY *tmp_ent = NULL;
+ while( (tmp_ent = EDGE_list.next()) != NULL )
+ {
+ EDGE *tmp_edge = (EDGE*)tmp_ent;
+ VERTEX *old_start = tmp_edge->start();
+ VERTEX *old_end = tmp_edge->end();
+ tmp_edge->set_sense( tmp_edge->sense() == FORWARD ? REVERSED : FORWARD );
+ tmp_edge->set_start( old_end );
+ tmp_edge->set_end( old_start );
+ }
+ }
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
- CUBIT_TRUE );
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
+ CUBIT_TRUE );
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )//mutually exclusive with sweep_to_body
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )//mutually exclusive with sweep_to_body
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
- else if(to_BODY)//mutually exclusive with to_face
+ else if(to_BODY)//mutually exclusive with to_face
{
ACIS_sweep_options.set_sweep_to_body(to_BODY);
//Creates one body out of the fixed body and the result of the sweep up
@@ -2935,41 +2930,41 @@
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- // Do the real work!!
- result = api_sweep_with_options (copied_EDGE_ptr, wire_BODY_ptr, &ACIS_sweep_options, BODYptr);
+ // Do the real work!!
+ result = api_sweep_with_options (copied_EDGE_ptr, wire_BODY_ptr, &ACIS_sweep_options, BODYptr);
- if (BODYptr)
- {
+ if (BODYptr)
+ {
sweep_status = CUBIT_SUCCESS;
- }
+ }
- if (!result.ok())
- {
+ if (!result.ok())
+ {
PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
if ( copied_EDGE_ptr != NULL )
api_delent(copied_EDGE_ptr);
sweep_status = CUBIT_FAILURE;
- }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- // Now set the option back to its default
- result = api_set_int_option ( "merge", CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge", CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_along_WIRE.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- return sweep_status;
+ return sweep_status;
}
//-------------------------------------------------------------------------
@@ -3013,60 +3008,60 @@
logical ACIS_primary_side = CUBIT_TRUE;
if (!primary_side) ACIS_primary_side = CUBIT_FALSE;
- // Make sure the distance of the sweep is not zero
- if (angle == 0.0)
- {
+ // Make sure the distance of the sweep is not zero
+ if (angle == 0.0)
+ {
PRINT_ERROR("The angle of the sweep must be > 0.0. Nothing done.\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
- if ( !(draft_type == 0 || draft_type == 1) )
- {
+ // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
+ if ( !(draft_type == 0 || draft_type == 1) )
+ {
PRINT_ERROR("Draft type must be either 0 or 1\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure we have a reasonable number of steps
- if (steps < 0)
- {
+ // Make sure we have a reasonable number of steps
+ if (steps < 0)
+ {
PRINT_WARNING("Number of steps must be a positive number.\n"
" It is set to 0 and the sweep operation will proceed.\n");
steps = 0;
- }
+ }
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans
- outcome result = api_set_int_option ( "merge",
- CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans
+ outcome result = api_set_int_option ( "merge",
+ CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_about_axis.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- sweep_options ACIS_sweep_options;
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_which_side(ACIS_primary_side);
- ACIS_sweep_options.set_steps(steps);
- ACIS_sweep_options.set_sweep_angle(angle);
- ACIS_sweep_options.set_rigid(rigid);
+ sweep_options ACIS_sweep_options;
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_which_side(ACIS_primary_side);
+ ACIS_sweep_options.set_steps(steps);
+ ACIS_sweep_options.set_sweep_angle(angle);
+ ACIS_sweep_options.set_rigid(rigid);
FACE *FACE_to_sweep_to = NULL;
if( to_FACE )//mutually exclusive with sweep_to_body
@@ -3149,11 +3144,11 @@
sweep_status = CUBIT_FAILURE;
}
- // Now set the option back to its default
- result = api_set_int_option ( "merge",
- CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge",
+ CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_FACE_about_axis.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
@@ -3161,12 +3156,12 @@
// As the problem is not really serious, continue and make sure that
// the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- // Finally, check to make sure that the volume of the swept BODY is positive.
- // 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)
+ // Finally, check to make sure that the volume of the swept BODY is positive.
+ // 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)
if(BODYptr)
{
new_BODY_ptr = BODYptr;
@@ -3189,7 +3184,7 @@
}
}
- return sweep_status;
+ return sweep_status;
}
CubitStatus AcisModifyEngine::sweep_EDGE_about_axis(
@@ -3206,101 +3201,101 @@
FACE *to_FACE,
BODY *to_BODY) const
{
- // Sweep ho!!
- CubitStatus sweep_status = CUBIT_SUCCESS;
+ // Sweep ho!!
+ CubitStatus sweep_status = CUBIT_SUCCESS;
- // Convert the Cubit point and SPAvector into an ACIS point and SPAvector
- // before calling the member function that calls the ACIS API
- // function.
- SPAunit_vector ACIS_axis_unit_vector(
- axis_unit_vector.x(),
- axis_unit_vector.y(),
- axis_unit_vector.z() );
- SPAposition ACIS_point( point.x(), point.y(), point.z() );
- if (angle == 0.0)
- {
+ // Convert the Cubit point and SPAvector into an ACIS point and SPAvector
+ // before calling the member function that calls the ACIS API
+ // function.
+ SPAunit_vector ACIS_axis_unit_vector(
+ axis_unit_vector.x(),
+ axis_unit_vector.y(),
+ axis_unit_vector.z() );
+ SPAposition ACIS_point( point.x(), point.y(), point.z() );
+ if (angle == 0.0)
+ {
PRINT_ERROR("The angle of the sweep must be > 0.0. Nothing done.\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft angle is reasonable
- if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
- {
+ // Make sure the draft angle is reasonable
+ if (draft_angle >= CUBIT_PI/2.0 || draft_angle <= -(CUBIT_PI/2.0))
+ {
PRINT_ERROR("Draft angle cannot be greater than %e radians\n",
CUBIT_PI/2.0);
return CUBIT_FAILURE;
- }
+ }
- // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
- if ( !(draft_type == 0 || draft_type == 1) )
- {
+ // Make sure the draft type is either 0 or 1 (this is an ACISism, of course!)
+ if ( !(draft_type == 0 || draft_type == 1) )
+ {
PRINT_ERROR("Draft type must be either 0 or 1\n");
return CUBIT_FAILURE;
- }
+ }
- // Make sure we have a reasonable number of steps
- if (steps < 0)
- {
+ // Make sure we have a reasonable number of steps
+ if (steps < 0)
+ {
PRINT_WARNING("Number of steps must be a positive number.\n"
" It is set to 0 and the sweep operation will proceed.\n");
steps = 0;
- }
+ }
- // Turn off the merge option in ACIS so FACEs used to sweep won't be
- // "simplified" in their topology (i.e., 5-sided squared faces won't
- // be reduced to 4-sided square faces) -- in other words, turn on
- // non-regularized booleans
- outcome result = api_set_int_option ( "merge",
- CUBIT_FALSE );
- if (!result.ok())
- {
+ // Turn off the merge option in ACIS so FACEs used to sweep won't be
+ // "simplified" in their topology (i.e., 5-sided squared faces won't
+ // be reduced to 4-sided square faces) -- in other words, turn on
+ // non-regularized booleans
+ outcome result = api_set_int_option ( "merge",
+ CUBIT_FALSE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_about_axis.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- sweep_options ACIS_sweep_options;
- ACIS_sweep_options.set_draft_angle(draft_angle);
- ACIS_sweep_options.set_gap_type(draft_type);
- ACIS_sweep_options.set_steps(steps);
- ACIS_sweep_options.set_sweep_angle(angle);
- ACIS_sweep_options.set_rigid(rigid);
- EDGE *copied_EDGE_ptr = NULL;
- result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to copy edge\n");
- return CUBIT_FAILURE;
- }
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
- CUBIT_TRUE );
+ sweep_options ACIS_sweep_options;
+ ACIS_sweep_options.set_draft_angle(draft_angle);
+ ACIS_sweep_options.set_gap_type(draft_type);
+ ACIS_sweep_options.set_steps(steps);
+ ACIS_sweep_options.set_sweep_angle(angle);
+ ACIS_sweep_options.set_rigid(rigid);
+ EDGE *copied_EDGE_ptr = NULL;
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to copy edge\n");
+ return CUBIT_FAILURE;
+ }
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
+ CUBIT_TRUE );
- FACE *FACE_to_sweep_to = NULL;
- if( to_FACE )//mutually exclusive with sweep_to_body
- {
- //get face type
- SURFACE *SURFACE_ptr = to_FACE->geometry();
- int type = SURFACE_ptr->identity();
+ FACE *FACE_to_sweep_to = NULL;
+ if( to_FACE )
+ {
+ //get face type
+ SURFACE *SURFACE_ptr = to_FACE->geometry();
+ int type = SURFACE_ptr->identity();
- //if face is planar...vector must not be parallel to surf normal
- if (type == PLANE_TYPE)
- {
- FACE_to_sweep_to = make_FACE( to_FACE, true );
- }
- //vector must intersect surf
- else
- {
- FACE_to_sweep_to = make_FACE( to_FACE );
- }
+ //if face is planar...vector must not be parallel to surf normal
+ if (type == PLANE_TYPE)
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE, true );
+ }
+ //vector must intersect surf
+ else
+ {
+ FACE_to_sweep_to = make_FACE( to_FACE );
+ }
- SPAtransf trans = get_face_trans(FACE_to_sweep_to);
- surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
- ACIS_sweep_options.set_to_face( eq_surf );
- }
+ SPAtransf trans = get_face_trans(FACE_to_sweep_to);
+ surface *eq_surf = FACE_to_sweep_to->geometry()->trans_surface(trans );
+ ACIS_sweep_options.set_to_face( eq_surf );
+ }
else if(to_BODY)//utually exclusive with to_face
{
ACIS_sweep_options.set_sweep_to_body(to_BODY);
@@ -3310,66 +3305,66 @@
ACIS_sweep_options.set_bool_type(INTERSECT);
}
- if(make_solid)
- {
- ACIS_sweep_options.set_close_to_axis(TRUE);
- EDGE* EDGES[1];
- EDGES[0] = copied_EDGE_ptr;
- BODY* EDGE_BODY_ptr = NULL;
+ if(make_solid)
+ {
+ ACIS_sweep_options.set_close_to_axis(TRUE);
+ EDGE* EDGES[1];
+ EDGES[0] = copied_EDGE_ptr;
+ BODY* EDGE_BODY_ptr = NULL;
- result = api_make_ewire(1, EDGES, EDGE_BODY_ptr);
+ result = api_make_ewire(1, EDGES, EDGE_BODY_ptr);
- // WIRE* WIRE_ptr = EDGE_BODY_ptr->lump()->shell()->wire();
- result = api_sweep_with_options(EDGE_BODY_ptr,
- ACIS_point, ACIS_axis_unit_vector,
- &ACIS_sweep_options, BODYptr);
- BODYptr = EDGE_BODY_ptr;
+// WIRE* WIRE_ptr = EDGE_BODY_ptr->lump()->shell()->wire();
+ result = api_sweep_with_options(EDGE_BODY_ptr,
+ ACIS_point, ACIS_axis_unit_vector,
+ &ACIS_sweep_options, BODYptr);
+ BODYptr = EDGE_BODY_ptr;
- }
- else {
- result = api_sweep_with_options(copied_EDGE_ptr,
- ACIS_point, ACIS_axis_unit_vector,
- &ACIS_sweep_options, BODYptr);
- }
+ }
+ else {
+ result = api_sweep_with_options(copied_EDGE_ptr,
+ ACIS_point, ACIS_axis_unit_vector,
+ &ACIS_sweep_options, BODYptr);
+ }
- if (BODYptr)
- {
- sweep_status = CUBIT_SUCCESS;
- }
- if (!result.ok())
- {
+ if (BODYptr)
+ {
+ sweep_status = CUBIT_SUCCESS;
+ }
+ if (!result.ok())
+ {
PRINT_ERROR("Error during ACIS sweep operation, api_sweep_with_options\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
if ( copied_EDGE_ptr != NULL )
api_delent(copied_EDGE_ptr);
sweep_status = CUBIT_FAILURE;
- }
+ }
- if( FACE_to_sweep_to )
- api_delent( FACE_to_sweep_to );
+ if( FACE_to_sweep_to )
+ api_delent( FACE_to_sweep_to );
- // Now set the option back to its default
- result = api_set_int_option ( "merge",
- CUBIT_TRUE );
- if (!result.ok())
- {
+ // Now set the option back to its default
+ result = api_set_int_option ( "merge",
+ CUBIT_TRUE );
+ if (!result.ok())
+ {
PRINT_WARNING("In AcisModifyEngine::sweep_EDGE_about_axis.\n"
" Error in api_set_int_option.\n");
AcisQueryEngine::instance()->ACIS_API_error(result);
- // As the problem is not really serious, continue and make sure that
- // the value of result is set to "OK" so no rollback occurs
+ // As the problem is not really serious, continue and make sure that
+ // the value of result is set to "OK" so no rollback occurs
result = outcome(0);
- }
+ }
- // Finally, check to make sure that the volume of the swept BODY is positive.
- // 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)
+ // Finally, check to make sure that the volume of the swept BODY is positive.
+ // 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)
- return sweep_status;
+ return sweep_status;
}
//-------------------------------------------------------------------------
@@ -3386,168 +3381,168 @@
const CubitVector& V3,
const CubitVector& V4 ) const
{
- GeometryQueryTool* GT_ptr = GeometryQueryTool::instance();
- BODY* Body1 = NULL;
+ GeometryQueryTool* GT_ptr = GeometryQueryTool::instance();
+ BODY* Body1 = NULL;
- // Debug info
- PRINT_DEBUG_18(
- "Debug output from AcisModifyEngine::make_planar_quad_BODY\n");
+ // Debug info
+ PRINT_DEBUG_18(
+ "Debug output from AcisModifyEngine::make_planar_quad_BODY\n");
- // First make sure that none of the points have the same coordinates.
- if ( (GT_ptr->about_spatially_equal(V1, V2,
- GeometryQueryTool::get_geometry_factor())) ||
- (GT_ptr->about_spatially_equal(V1, V3,
- GeometryQueryTool::get_geometry_factor())) ||
- (GT_ptr->about_spatially_equal(V1, V4,
- GeometryQueryTool::get_geometry_factor())) ||
- (GT_ptr->about_spatially_equal(V2, V3,
- GeometryQueryTool::get_geometry_factor())) ||
- (GT_ptr->about_spatially_equal(V2, V4,
- GeometryQueryTool::get_geometry_factor())) ||
- (GT_ptr->about_spatially_equal(V3, V4,
- GeometryQueryTool::get_geometry_factor())) )
- {
+ // First make sure that none of the points have the same coordinates.
+ if ( (GT_ptr->about_spatially_equal(V1, V2,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GT_ptr->about_spatially_equal(V1, V3,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GT_ptr->about_spatially_equal(V1, V4,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GT_ptr->about_spatially_equal(V2, V3,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GT_ptr->about_spatially_equal(V2, V4,
+ GeometryQueryTool::get_geometry_factor())) ||
+ (GT_ptr->about_spatially_equal(V3, V4,
+ GeometryQueryTool::get_geometry_factor())) )
+ {
PRINT_ERROR("In AcisModifyEngine::make_planar_quad_BODY.\n"
" Some of the input points are spatially equivalent.\n"
" Cannot create a planar quadrilateral ACIS BODY.\n");
return NULL;
- }
+ }
- // Make sure that the 4 input points are coplanar.
- // If the 4 points are coplanar, then the scalar triple product
- // of the 3 vectors joining points 1 and 2, 2 and 3, and 3 and 4, will
- // equal zero.
- // For 4 coplanar points, Vector12 . (Vector23 * Vector34) = 0
+ // Make sure that the 4 input points are coplanar.
+ // If the 4 points are coplanar, then the scalar triple product
+ // of the 3 vectors joining points 1 and 2, 2 and 3, and 3 and 4, will
+ // equal zero.
+ // For 4 coplanar points, Vector12 . (Vector23 * Vector34) = 0
- CubitVector vector12 = V2 - V1;
- CubitVector vector23 = V3 - V2;
- CubitVector vector34 = V4 - V3;
+ CubitVector vector12 = V2 - V1;
+ CubitVector vector23 = V3 - V2;
+ CubitVector vector34 = V4 - V3;
- // normalize the vectors
- vector12.normalize();
- vector23.normalize();
- vector34.normalize();
+ // normalize the vectors
+ vector12.normalize();
+ vector23.normalize();
+ vector34.normalize();
- double tripleProd = vector12 % (vector23 * vector34);
+ double tripleProd = vector12 % (vector23 * vector34);
- // MJP Note:
- // The following tests to make sure that tripleProd is "0.0". But this
- // cannot be tested exactly, so we have to approximate the notion of zero.
- // I have run into a case where a not-so-large (size about 2000 units)
- // set of 4 points results in a tripleProd value of approximately
- // -3.5E-6 whose fabs is 3.5E-6 which is larger than SPAresabs (1E-6).
- // I have put in an arbitrary factor of 100 here!!!!!!! This raises
- // our notion of "zero" from 1E-6 to 1E-4......:-)
- if (fabs(tripleProd) > 100.0 * GEOMETRY_RESABS)
- {
+ // MJP Note:
+ // The following tests to make sure that tripleProd is "0.0". But this
+ // cannot be tested exactly, so we have to approximate the notion of zero.
+ // I have run into a case where a not-so-large (size about 2000 units)
+ // set of 4 points results in a tripleProd value of approximately
+ // -3.5E-6 whose fabs is 3.5E-6 which is larger than SPAresabs (1E-6).
+ // I have put in an arbitrary factor of 100 here!!!!!!! This raises
+ // our notion of "zero" from 1E-6 to 1E-4......:-)
+ if (fabs(tripleProd) > 100.0 * GEOMETRY_RESABS)
+ {
PRINT_ERROR("In AcisModifyEngine::make_planar_quad_BODY.\n"
" The 4 input points are not coplanar.\n"
" Cannot create a planar quadrilateral ACIS BODY.\n");
return NULL;
- }
+ }
- // Initialize the bulletin board (this is done so that if there is an
- // error while building this body, ACIS will automatically roll its
- // state back to what it was before this next statement was executed.
- int success = CUBIT_TRUE;
- API_BEGIN;
+ // Initialize the bulletin board (this is done so that if there is an
+ // error while building this body, ACIS will automatically roll its
+ // state back to what it was before this next statement was executed.
+ int success = CUBIT_TRUE;
+ API_BEGIN;
- // Create an ACIS Body using the direct interface (it's tons of fun :-)
+ // Create an ACIS Body using the direct interface (it's tons of fun :-)
- // Create ACIS points
- APOINT* P1 = new APOINT (V1.x(), V1.y(), V1.z());
- APOINT* P2 = new APOINT (V2.x(), V2.y(), V2.z());
- APOINT* P3 = new APOINT (V3.x(), V3.y(), V3.z());
- APOINT* P4 = new APOINT (V4.x(), V4.y(), V4.z());
+ // Create ACIS points
+ APOINT* P1 = new APOINT (V1.x(), V1.y(), V1.z());
+ APOINT* P2 = new APOINT (V2.x(), V2.y(), V2.z());
+ APOINT* P3 = new APOINT (V3.x(), V3.y(), V3.z());
+ APOINT* P4 = new APOINT (V4.x(), V4.y(), V4.z());
- // Create ACIS straight lines between the 4 input points
- STRAIGHT* S1 = new STRAIGHT( P1->coords(),
- normalise(P2->coords() - P1->coords()) );
- STRAIGHT* S2 = new STRAIGHT( P2->coords(),
- normalise(P3->coords() - P2->coords()) );
- STRAIGHT* S3 = new STRAIGHT( P3->coords(),
- normalise(P4->coords() - P3->coords()) );
- STRAIGHT* S4 = new STRAIGHT( P4->coords(),
- normalise(P1->coords() - P4->coords()) );
+ // Create ACIS straight lines between the 4 input points
+ STRAIGHT* S1 = new STRAIGHT( P1->coords(),
+ normalise(P2->coords() - P1->coords()) );
+ STRAIGHT* S2 = new STRAIGHT( P2->coords(),
+ normalise(P3->coords() - P2->coords()) );
+ STRAIGHT* S3 = new STRAIGHT( P3->coords(),
+ normalise(P4->coords() - P3->coords()) );
+ STRAIGHT* S4 = new STRAIGHT( P4->coords(),
+ normalise(P1->coords() - P4->coords()) );
- // Compute the unit SPAvector of the plane containing the 4 points
- CubitVector planeNormal;
- planeNormal = (vector12 * vector23);
- planeNormal.normalize();
+ // Compute the unit SPAvector of the plane containing the 4 points
+ CubitVector planeNormal;
+ planeNormal = (vector12 * vector23);
+ planeNormal.normalize();
- // Create an ACIS surface
- PLANE* Plane1 = new PLANE( P1->coords(),
- SPAunit_vector(planeNormal.x(),
- planeNormal.y(),
- planeNormal.z() ) );
+ // Create an ACIS surface
+ PLANE* Plane1 = new PLANE( P1->coords(),
+ SPAunit_vector(planeNormal.x(),
+ planeNormal.y(),
+ planeNormal.z() ) );
- // Create ACIS vertices
- VERTEX* Vertex1 = new VERTEX (P1);
- VERTEX* Vertex2 = new VERTEX (P2);
- VERTEX* Vertex3 = new VERTEX (P3);
- VERTEX* Vertex4 = new VERTEX (P4);
+ // Create ACIS vertices
+ VERTEX* Vertex1 = new VERTEX (P1);
+ VERTEX* Vertex2 = new VERTEX (P2);
+ VERTEX* Vertex3 = new VERTEX (P3);
+ VERTEX* Vertex4 = new VERTEX (P4);
- // Create ACIS edges
- EDGE* Edge1 = new EDGE (Vertex1, Vertex2, S1, FORWARD);
- EDGE* Edge2 = new EDGE (Vertex2, Vertex3, S2, FORWARD);
- EDGE* Edge3 = new EDGE (Vertex3, Vertex4, S3, FORWARD);
- EDGE* Edge4 = new EDGE (Vertex4, Vertex1, S4, FORWARD);
+ // Create ACIS edges
+ EDGE* Edge1 = new EDGE (Vertex1, Vertex2, S1, FORWARD);
+ EDGE* Edge2 = new EDGE (Vertex2, Vertex3, S2, FORWARD);
+ EDGE* Edge3 = new EDGE (Vertex3, Vertex4, S3, FORWARD);
+ EDGE* Edge4 = new EDGE (Vertex4, Vertex1, S4, FORWARD);
- // Create an ACIS loop of coedges
- COEDGE* Coedge1 = new COEDGE (Edge1, FORWARD, NULL, NULL);
- COEDGE* Coedge2 = new COEDGE (Edge2, FORWARD, Coedge1, NULL);
- COEDGE* Coedge3 = new COEDGE (Edge3, FORWARD, Coedge2, NULL);
- /*COEDGE* Coedge4 =*/ new COEDGE (Edge4, FORWARD, Coedge3, Coedge1);
- LOOP* Loop1 = new LOOP (Coedge1, NULL);
+ // Create an ACIS loop of coedges
+ COEDGE* Coedge1 = new COEDGE (Edge1, FORWARD, NULL, NULL);
+ COEDGE* Coedge2 = new COEDGE (Edge2, FORWARD, Coedge1, NULL);
+ COEDGE* Coedge3 = new COEDGE (Edge3, FORWARD, Coedge2, NULL);
+ /*COEDGE* Coedge4 =*/ new COEDGE (Edge4, FORWARD, Coedge3, Coedge1);
+ LOOP* Loop1 = new LOOP (Coedge1, NULL);
- // Create an ACIS face
- FACE* Face1 = new FACE (Loop1, NULL, Plane1, FORWARD);
+ // Create an ACIS face
+ FACE* Face1 = new FACE (Loop1, NULL, Plane1, FORWARD);
- // Create an ACIS shell
- SHELL* Shell1 = new SHELL (Face1, NULL, NULL);
+ // Create an ACIS shell
+ SHELL* Shell1 = new SHELL (Face1, NULL, NULL);
- // Create an ACIS lump
- LUMP* Lump1 = new LUMP (Shell1, NULL);
+ // Create an ACIS lump
+ LUMP* Lump1 = new LUMP (Shell1, NULL);
- // Create the ACIS body
- Body1 = new BODY (Lump1);
+ // Create the ACIS body
+ Body1 = new BODY (Lump1);
- // Make sure all's well with this BODY and then 2D-it!
- if (Body1 != NULL)
- {
- // Finally, make sure this BODY consists of a DOUBLE-SIDED,
- // BOTH_OUTSIDE FACE
+ // Make sure all's well with this BODY and then 2D-it!
+ if (Body1 != NULL)
+ {
+ // Finally, make sure this BODY consists of a DOUBLE-SIDED,
+ // BOTH_OUTSIDE FACE
result = api_body_to_2d(Body1);
if (!result.ok())
- {
- PRINT_ERROR("In AcisModifyEngine::make_planar_quad_BODY.\n"
- " Unable to convert FACE to a 2D BODY using api_body_to2d.\n");
- success = CUBIT_FALSE;
- }
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_planar_quad_BODY.\n"
+ " Unable to convert FACE to a 2D BODY using api_body_to2d.\n");
+ success = CUBIT_FALSE;
+ }
+ }
- // Scream bloody murder....only if necessary, of course :-)
- if (Body1 == NULL)
- {
+ // Scream bloody murder....only if necessary, of course :-)
+ if (Body1 == NULL)
+ {
PRINT_ERROR("In AcisModifyEngine::make_planar_quad_BODY.\n"
" Problem creating a Planar Quadrilateral ACIS BODY.\n");
success = CUBIT_FALSE;
- }
+ }
- // Terminate the bulletin board
- API_END;
+ // Terminate the bulletin board
+ API_END;
- if (success)
- {
- // Debug info
- PRINT_DEBUG_18(" Successfully created a planar quadrilateral ACIS BODY.\n");
- return Body1;
- }
+ if (success)
+ {
+ // Debug info
+ PRINT_DEBUG_18(" Successfully created a planar quadrilateral ACIS BODY.\n");
+ return Body1;
+ }
- else
- {
- return NULL;
- }
+ else
+ {
+ return NULL;
+ }
}
//-------------------------------------------------------------------------
@@ -3565,55 +3560,55 @@
const CubitVector axes[3],
const CubitVector &extension ) const
{
- BODY* BODY_ptr = NULL;
+ BODY* BODY_ptr = NULL;
- double width = 2.0*extension.x();
- double depth = 2.0*extension.y();
- double height = 2.0*extension.z();
+ double width = 2.0*extension.x();
+ double depth = 2.0*extension.y();
+ double height = 2.0*extension.z();
- // Create a BODY that represents the cuboid
- outcome result = api_make_cuboid ( width, depth, height, BODY_ptr );
- if (!result.ok())
- {
+ // Create a BODY that represents the cuboid
+ outcome result = api_make_cuboid ( width, depth, height, BODY_ptr );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisGeometryEngine::make_brick_BODY, Line# %d\n"
" Problems creating a brick\n", __LINE__);
return NULL ;
- }
+ }
- // Transform the brick into SPAposition
+ // Transform the brick into SPAposition
- SPAposition brick_center( center.x(), center.y(), center.z() );
- SPAunit_vector x_axis_this( axes[0].x(), axes[0].y(), axes[0].z() );
- SPAunit_vector y_axis_this( axes[1].x(), axes[1].y(), axes[1].z() );
+ SPAposition brick_center( center.x(), center.y(), center.z() );
+ SPAunit_vector x_axis_this( axes[0].x(), axes[0].y(), axes[0].z() );
+ SPAunit_vector y_axis_this( axes[1].x(), axes[1].y(), axes[1].z() );
- SPAtransf transformation = coordinate_transf( brick_center, x_axis_this, y_axis_this );
+ SPAtransf transformation = coordinate_transf( brick_center, x_axis_this, y_axis_this );
- // Concatenate the input transformation to the existing one
- result = api_apply_transf ( BODY_ptr, transformation );
- if (!result.ok())
- {
+ // Concatenate the input transformation to the existing one
+ result = api_apply_transf ( BODY_ptr, transformation );
+ if (!result.ok())
+ {
AcisQueryEngine::instance()->ACIS_API_error ( result );
PRINT_ERROR("In AcisGeometryEngine::make_brick_BODY, Line# %d\n"
" Problems creating a brick\n", __LINE__);
return NULL;
- }
- TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
- result = api_change_body_trans ( BODY_ptr, identity, FALSE );
- identity->lose();
- if (!result.ok())
- {
+ }
+ TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
+ result = api_change_body_trans ( BODY_ptr, identity, FALSE );
+ identity->lose();
+ if (!result.ok())
+ {
AcisQueryEngine::instance()->ACIS_API_error ( result );
PRINT_ERROR("In AcisGeometryEngine::make_brick_BODY, Line# %d\n"
" Problems creating a brick\n", __LINE__);
return NULL;
- }
- //The bounding SPAbox does not get re-computed, so we need
- //to do it.
- AcisQueryEngine::instance()->clear_bounding_box( BODY_ptr );
- AcisQueryEngine::instance()->bounding_box( BODY_ptr );
+ }
+ //The bounding SPAbox does not get re-computed, so we need
+ //to do it.
+ AcisQueryEngine::instance()->clear_bounding_box( BODY_ptr );
+ AcisQueryEngine::instance()->bounding_box( BODY_ptr );
- return BODY_ptr;
+ return BODY_ptr;
}
//-------------------------------------------------------------------------
@@ -3913,15 +3908,15 @@
VERTEX* VERTEX_ptr = NULL;
API_BEGIN;
- // Create a new ACIS VERTEX -- it is not attached to a BODY
- APOINT* APOINT_ptr = new APOINT ( point.x(), point.y(), point.z() );
+ // Create a new ACIS VERTEX -- it is not attached to a BODY
+ APOINT* APOINT_ptr = new APOINT ( point.x(), point.y(), point.z() );
- if ( APOINT_ptr != NULL )
+ if ( APOINT_ptr != NULL )
{
VERTEX_ptr = new VERTEX ( APOINT_ptr );
}
- else
+ else
{
PRINT_ERROR("In AcisModifyEngine::make_VERTEX\n"
" ACIS could not make an APOINT object.\n"
@@ -3929,8 +3924,8 @@
status = CUBIT_FAILURE;
}
- // Complain if ACIS wasn't able to create the VERTEX
- if ( VERTEX_ptr == NULL && status == CUBIT_SUCCESS)
+ // Complain if ACIS wasn't able to create the VERTEX
+ if ( VERTEX_ptr == NULL && status == CUBIT_SUCCESS)
{
PRINT_ERROR("In AcisModifyEngine::make_VERTEX\n"
" ACIS could not make a VERTEX object.\n");
@@ -3966,59 +3961,59 @@
// Creation Date : 03-27-97
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_EDGE( GeometryType EDGE_type,
- VERTEX* start_VERTEX,
- VERTEX* end_VERTEX,
- SPAposition* intermediate_point_ptr,
+ VERTEX* start_VERTEX,
+ VERTEX* end_VERTEX,
+ SPAposition* intermediate_point_ptr,
bool sense ) const
{
- // Make sure the input VERTEX'es are non-NULL -- these are needed by
- // all the EDGE generation routines.
- if ( start_VERTEX == NULL || end_VERTEX == NULL )
- {
+ // Make sure the input VERTEX'es are non-NULL -- these are needed by
+ // all the EDGE generation routines.
+ if ( start_VERTEX == NULL || end_VERTEX == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_EDGE\n"
" An input end VERTEX is invalid (NULL).\n");
assert (start_VERTEX != NULL && end_VERTEX != NULL);
return (EDGE *)NULL;
- }
+ }
- // Make a straight EDGE
- if ( EDGE_type == STRAIGHT_CURVE_TYPE )
- {
+ // Make a straight EDGE
+ if ( EDGE_type == STRAIGHT_CURVE_TYPE )
+ {
return make_straight_EDGE(start_VERTEX, end_VERTEX);
- }
+ }
- // Make a parabolic EDGE
- else if ( EDGE_type == PARABOLA_CURVE_TYPE )
- {
+ // Make a parabolic EDGE
+ else if ( EDGE_type == PARABOLA_CURVE_TYPE )
+ {
return make_parabolic_EDGE( start_VERTEX,
end_VERTEX,
intermediate_point_ptr);
- }
+ }
- // Make an elliptical EDGE
- else if ( EDGE_type == ELLIPSE_CURVE_TYPE )
- {
+ // Make an elliptical EDGE
+ else if ( EDGE_type == ELLIPSE_CURVE_TYPE )
+ {
return make_elliptical_EDGE( start_VERTEX,
end_VERTEX,
intermediate_point_ptr,
sense);
- }
+ }
- else if (EDGE_type == ARC_CURVE_TYPE)
- {
- return make_circular_EDGE(start_VERTEX,
- end_VERTEX,
- intermediate_point_ptr);
- }
+ else if (EDGE_type == ARC_CURVE_TYPE)
+ {
+ return make_circular_EDGE(start_VERTEX,
+ end_VERTEX,
+ intermediate_point_ptr);
+ }
- // OOps!!!!
- else
- {
+ // OOps!!!!
+ else
+ {
PRINT_ERROR("In AcisModifyEngine::make_EDGE\n"
" Invalid curve type.\n");
assert (0 == 1);
return (EDGE *)NULL;
- }
+ }
}
// This function will create a supper cone using the info
@@ -4028,110 +4023,110 @@
// in cubit.
FACE* AcisModifyEngine::make_type_FACE( CONE *CONE_ptr ) const
{
- //Given this lets create another face that is extended from it.
- CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
+ //Given this lets create another face that is extended from it.
+ CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
- BODY *sheet_body;
- CubitBoolean cylinder = CUBIT_FALSE;
+ BODY *sheet_body;
+ CubitBoolean cylinder = CUBIT_FALSE;
- double const st_ang = 0.0;
- double const end_ang = 2*CUBIT_PI;
- double cost = CONE_ptr->cosine_angle();
- double sint = CONE_ptr->sine_angle();
- if ( sint == 0.0 && fabs(cost) == 1.0 )
- {
- //This is a cylinder.
- cylinder = CUBIT_TRUE;
- }
- SPAvector major_a = CONE_ptr->major_axis();
- SPAunit_vector normal_a = CONE_ptr->direction();
- double const radius_ratio = CONE_ptr->radius_ratio();
- double const height = 2*(bounding_box.diagonal()).length();
- SPAposition root = CONE_ptr->root_point();
- CubitVector elipse_radius, center_vec;
- CubitVector temp_norm( normal_a.x(), normal_a.y(), normal_a.z());
- if ( !cylinder )
- {
- if ( sint > 0.0 && cost > 0.0 )
- {
- sint = -sint;
- temp_norm *= -1.0;
- }
- else if ( sint < 0.0 && cost < 0.0 )
- {
- cost = -cost;
- temp_norm *= -1.0;
- }
- //First we need to calculate the new radius.
- //Also calc the old height to find the new center SPAposition.
- double theta_rad = acos(cost);
- elipse_radius.set(major_a.x(), major_a.y(), major_a.z() );
- double old_radius = elipse_radius.length();
- double old_height = old_radius/tan(theta_rad);
+ double const st_ang = 0.0;
+ double const end_ang = 2*CUBIT_PI;
+ double cost = CONE_ptr->cosine_angle();
+ double sint = CONE_ptr->sine_angle();
+ if ( sint == 0.0 && fabs(cost) == 1.0 )
+ {
+ //This is a cylinder.
+ cylinder = CUBIT_TRUE;
+ }
+ SPAvector major_a = CONE_ptr->major_axis();
+ SPAunit_vector normal_a = CONE_ptr->direction();
+ double const radius_ratio = CONE_ptr->radius_ratio();
+ double const height = 2*(bounding_box.diagonal()).length();
+ SPAposition root = CONE_ptr->root_point();
+ CubitVector elipse_radius, center_vec;
+ CubitVector temp_norm( normal_a.x(), normal_a.y(), normal_a.z());
+ if ( !cylinder )
+ {
+ if ( sint > 0.0 && cost > 0.0 )
+ {
+ sint = -sint;
+ temp_norm *= -1.0;
+ }
+ else if ( sint < 0.0 && cost < 0.0 )
+ {
+ cost = -cost;
+ temp_norm *= -1.0;
+ }
+ //First we need to calculate the new radius.
+ //Also calc the old height to find the new center SPAposition.
+ double theta_rad = acos(cost);
+ elipse_radius.set(major_a.x(), major_a.y(), major_a.z() );
+ double old_radius = elipse_radius.length();
+ double old_height = old_radius/tan(theta_rad);
- //make center of surface along axis, 1/2 height of
- //bounding box of entire model.
- CubitVector root_vec( root.x(), root.y(), root.z() );
- center_vec = root_vec + (-0.5*height)*temp_norm;
+ //make center of surface along axis, 1/2 height of
+ //bounding box of entire model.
+ CubitVector root_vec( root.x(), root.y(), root.z() );
+ center_vec = root_vec + (-0.5*height)*temp_norm;
- //calculate new radius
- double new_radius = (old_height+ 0.5*height) * tan (theta_rad );
- elipse_radius.normalize();
- elipse_radius *= new_radius;
- }
- else
- {
- CubitVector root_vec( root.x(), root.y(), root.z() );
- center_vec = .5*height*temp_norm;
- center_vec = root_vec - center_vec;
- elipse_radius.set(major_a.x(), major_a.y(), major_a.z() );
- }
- SPAvector const major_axis(elipse_radius.x(), elipse_radius.y(), elipse_radius.z() );
+ //calculate new radius
+ double new_radius = (old_height+ 0.5*height) * tan (theta_rad );
+ elipse_radius.normalize();
+ elipse_radius *= new_radius;
+ }
+ else
+ {
+ CubitVector root_vec( root.x(), root.y(), root.z() );
+ center_vec = .5*height*temp_norm;
+ center_vec = root_vec - center_vec;
+ elipse_radius.set(major_a.x(), major_a.y(), major_a.z() );
+ }
+ SPAvector const major_axis(elipse_radius.x(), elipse_radius.y(), elipse_radius.z() );
- SPAunit_vector const normal_axis(temp_norm.x(), temp_norm.y(), temp_norm.z());
- SPAposition const center ( center_vec.x(), center_vec.y(), center_vec.z() );
+ SPAunit_vector const normal_axis(temp_norm.x(), temp_norm.y(), temp_norm.z());
+ SPAposition const center ( center_vec.x(), center_vec.y(), center_vec.z() );
- FACE *new_FACE_ptr = NULL;
- outcome result = api_make_cnface( center, normal_axis, major_axis,
- radius_ratio, sint, cost, st_ang,
- end_ang, height, new_FACE_ptr );
- if (!result.ok() || new_FACE_ptr == NULL ||
- new_FACE_ptr->geometry() == NULL )
- {
+ FACE *new_FACE_ptr = NULL;
+ outcome result = api_make_cnface( center, normal_axis, major_axis,
+ radius_ratio, sint, cost, st_ang,
+ end_ang, height, new_FACE_ptr );
+ if (!result.ok() || new_FACE_ptr == NULL ||
+ new_FACE_ptr->geometry() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(cone)\n"
" ACIS api_make_cnface function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- FACE *face_list[1];
- face_list[0] = new_FACE_ptr;
- result = api_sheet_from_ff( 1, face_list, sheet_body );
- if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
- || sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL )
- {
+ }
+ FACE *face_list[1];
+ face_list[0] = new_FACE_ptr;
+ result = api_sheet_from_ff( 1, face_list, sheet_body );
+ if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
+ || sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(cone)\n"
" ACIS api_sheet_from_ff function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- result = api_body_to_2d( sheet_body );
- if (!result.ok())
- {
+ }
+ result = api_body_to_2d( sheet_body );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(cone)\n"
" ACIS api_body_to_2d function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- int debug_flg = 0;
- // Save the BODY being cut, if debug is on
- if (debug_flg)
- {
+ }
+ int debug_flg = 0;
+ // Save the BODY being cut, if debug is on
+ if (debug_flg)
+ {
AcisQueryEngine::instance()->save_ENTITY_as_sat_file(sheet_body, "cone_sheet.sat", "w");
- }
+ }
- return sheet_body->lump()->shell()->first_face();
+ return sheet_body->lump()->shell()->first_face();
}
// This function will create a sphere face using the info
// from the existing sphere. It is actually a face or sheet
@@ -4139,73 +4134,73 @@
// will be the grand sphere itself, not a section of it.
FACE* AcisModifyEngine::make_type_FACE( SPHERE *SPHERE_ptr ) const
{
- BODY *sheet_body;
+ BODY *sheet_body;
- BODY *sphere_body;
- SPAposition const center = SPHERE_ptr->centre();
- double const radius = SPHERE_ptr->radius();
+ BODY *sphere_body;
+ SPAposition const center = SPHERE_ptr->centre();
+ double const radius = SPHERE_ptr->radius();
- //make a sphere body then move it to the give place.
- outcome result = api_make_sphere( radius, sphere_body );
- if (!result.ok() || sphere_body == NULL ||
- sphere_body->lump() == NULL ||
- sphere_body->lump()->shell() == NULL ||
- sphere_body->lump()->shell()->first_face() == NULL )
- {
+ //make a sphere body then move it to the give place.
+ outcome result = api_make_sphere( radius, sphere_body );
+ if (!result.ok() || sphere_body == NULL ||
+ sphere_body->lump() == NULL ||
+ sphere_body->lump()->shell() == NULL ||
+ sphere_body->lump()->shell()->first_face() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(sphere)\n"
" ACIS api_make_sphere function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- //now move the body.
- SPAvector translation_vector( center.x(), center.y(), center.z() );
- result = api_apply_transf ( sphere_body,
- translate_transf (translation_vector) );
- if ( !result.ok() )
- {
+ }
+ //now move the body.
+ SPAvector translation_vector( center.x(), center.y(), center.z() );
+ result = api_apply_transf ( sphere_body,
+ translate_transf (translation_vector) );
+ if ( !result.ok() )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(sphere)\n"
" ACIS api_aply_transf function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
return (FACE*)NULL;
- }
- TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
- result = api_change_body_trans ( sphere_body, identity, FALSE );
- identity->lose();
- if (!result.ok())
- {
+ }
+ TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
+ result = api_change_body_trans ( sphere_body, identity, FALSE );
+ identity->lose();
+ if (!result.ok())
+ {
AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
return (FACE*)NULL;
- }
- //The bounding SPAbox does not get re-computed, so we need
- //to do it.
- AcisQueryEngine::instance()->clear_bounding_box( sphere_body );
- AcisQueryEngine::instance()->bounding_box(sphere_body);
+ }
+ //The bounding SPAbox does not get re-computed, so we need
+ //to do it.
+ AcisQueryEngine::instance()->clear_bounding_box( sphere_body );
+ AcisQueryEngine::instance()->bounding_box(sphere_body);
- FACE *face_list[1];
- face_list[0] = sphere_body->lump()->shell()->first_face();
- result = api_sheet_from_ff( 1, face_list, sheet_body );
- if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
- || sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL )
- {
+ FACE *face_list[1];
+ face_list[0] = sphere_body->lump()->shell()->first_face();
+ result = api_sheet_from_ff( 1, face_list, sheet_body );
+ if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
+ || sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(sphere)\n"
" ACIS api_sheet_from_ff function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- result = api_body_to_2d( sheet_body );
- if (!result.ok())
- {
+ }
+ result = api_body_to_2d( sheet_body );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(sphere)\n"
" ACIS api_body_to_2d function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- AcisQueryEngine::instance()->delete_ACIS_BODY(sphere_body, CUBIT_TRUE);
+ }
+ AcisQueryEngine::instance()->delete_ACIS_BODY(sphere_body, CUBIT_TRUE);
- return sheet_body->lump()->shell()->first_face();
+ return sheet_body->lump()->shell()->first_face();
}
// This function will create a torus face using the info
// from the existing torus. It is actually a face or sheet
@@ -4214,66 +4209,66 @@
FACE* AcisModifyEngine::make_type_FACE( TORUS *TORUS_ptr ) const
{
if ( TORUS_ptr == NULL )
- {
- PRINT_ERROR("NULL pointer passed to make face from. (torus).\n");
- return (FACE*)NULL;
- }
+ {
+ PRINT_ERROR("NULL pointer passed to make face from. (torus).\n");
+ return (FACE*)NULL;
+ }
- BODY *sheet_body;
- SPAposition const center = TORUS_ptr->centre();
- SPAunit_vector const normal = TORUS_ptr->normal();
- double const uf = 0.0;
- double const ut = 2*CUBIT_PI;
- double const vf = 0.0;
- double const vt = 2*CUBIT_PI;
- double const major_radius = TORUS_ptr->major_radius();
- double const minor_radius = TORUS_ptr->minor_radius();
- CubitVector temp_center(center.x(), center.y(), center.z());
- CubitVector temp_normal(normal.x(), normal.y(), normal.z());
- temp_normal.normalize();
- CubitVector temp_point = temp_center + major_radius*temp_normal;
- SPAposition const point(temp_point.x(), temp_point.y(), temp_point.z());
+ BODY *sheet_body;
+ SPAposition const center = TORUS_ptr->centre();
+ SPAunit_vector const normal = TORUS_ptr->normal();
+ double const uf = 0.0;
+ double const ut = 2*CUBIT_PI;
+ double const vf = 0.0;
+ double const vt = 2*CUBIT_PI;
+ double const major_radius = TORUS_ptr->major_radius();
+ double const minor_radius = TORUS_ptr->minor_radius();
+ CubitVector temp_center(center.x(), center.y(), center.z());
+ CubitVector temp_normal(normal.x(), normal.y(), normal.z());
+ temp_normal.normalize();
+ CubitVector temp_point = temp_center + major_radius*temp_normal;
+ SPAposition const point(temp_point.x(), temp_point.y(), temp_point.z());
- //make a torus body then move it to the give place.
- FACE *new_FACE_ptr = NULL;
- outcome result = api_make_trface( center, normal, major_radius,
- minor_radius, point,
- uf, ut, vf, vt, new_FACE_ptr );
- if (!result.ok() || new_FACE_ptr == NULL )
- {
+ //make a torus body then move it to the give place.
+ FACE *new_FACE_ptr = NULL;
+ outcome result = api_make_trface( center, normal, major_radius,
+ minor_radius, point,
+ uf, ut, vf, vt, new_FACE_ptr );
+ if (!result.ok() || new_FACE_ptr == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(torus)\n"
" ACIS api_make_trface function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- FACE *face_list[1];
- face_list[0] = new_FACE_ptr;
- result = api_sheet_from_ff( 1, face_list, sheet_body );
- if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
- || sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL )
- {
+ }
+ FACE *face_list[1];
+ face_list[0] = new_FACE_ptr;
+ result = api_sheet_from_ff( 1, face_list, sheet_body );
+ if (!result.ok() || sheet_body == NULL || sheet_body->lump() == NULL
+ || sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(torus)\n"
" ACIS api_sheet_from_ff function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- result = api_body_to_2d( sheet_body );
- if (!result.ok())
- {
+ }
+ result = api_body_to_2d( sheet_body );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(torus)\n"
" ACIS api_body_to_2d function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- int debug_flg = 0;
- // Save the BODY being cut, if debug is on
- if (debug_flg)
- {
+ }
+ int debug_flg = 0;
+ // Save the BODY being cut, if debug is on
+ if (debug_flg)
+ {
AcisQueryEngine::instance()->save_ENTITY_as_sat_file(sheet_body, "torus_sheet.sat", "w");
- }
+ }
- return sheet_body->lump()->shell()->first_face();
+ return sheet_body->lump()->shell()->first_face();
}
// This function will create a spline face using the info
// from the existing spline. It is actually a face or sheet
@@ -4281,36 +4276,36 @@
// will be the grand spline itself, not a section of it.
FACE* AcisModifyEngine::make_type_FACE( SPLINE *SPLINE_ptr ) const
{
- BODY *sheet_body;
- PRINT_WARNING("Extents of spline will be only as far as\n"
- "the spline definition, this really isn't an infinite surface.\n");
+ BODY *sheet_body;
+ PRINT_WARNING("Extents of spline will be only as far as\n"
+ "the spline definition, this really isn't an infinite surface.\n");
- //use the geometry to make the spline body.
- surface const *this_spline = &(SPLINE_ptr->equation());
+ //use the geometry to make the spline body.
+ surface const *this_spline = &(SPLINE_ptr->equation());
- //make a spline body then move it to the give place.
- outcome result = api_make_spline( *((spline*)this_spline), sheet_body );
- if (!result.ok() || sheet_body == NULL ||
- sheet_body->lump() == NULL ||
- sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL ||
- sheet_body->lump()->shell()->first_face()->geometry() == NULL )
- {
+ //make a spline body then move it to the give place.
+ outcome result = api_make_spline( *((spline*)this_spline), sheet_body );
+ if (!result.ok() || sheet_body == NULL ||
+ sheet_body->lump() == NULL ||
+ sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL ||
+ sheet_body->lump()->shell()->first_face()->geometry() == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(spline)\n"
" ACIS api_make_spline function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
- result = api_body_to_2d( sheet_body );
- if (!result.ok())
- {
+ }
+ result = api_body_to_2d( sheet_body );
+ if (!result.ok())
+ {
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(spline)\n"
" ACIS api_body_to_2d function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (FACE *)NULL;
- }
+ }
- return sheet_body->lump()->shell()->first_face();
+ return sheet_body->lump()->shell()->first_face();
}
// This function will create a plane face using the info
// from the existing plane. It is actually a face or sheet
@@ -4318,37 +4313,37 @@
// will be the grand plane itself, not a section of it.
FACE* AcisModifyEngine::make_type_FACE( PLANE *PLANE_ptr ) const
{
- //first lets find 3 points.
- SPAposition point_1, point_2, point_3;
- SPApar_pos const pos_1( 0, 1 );
- SPApar_pos const pos_2( 1, 0 );
- SPApar_pos const pos_3( 0, 0 );
- PLANE_ptr->equation().eval( pos_1, point_1 );
- PLANE_ptr->equation().eval( pos_2, point_2 );
- PLANE_ptr->equation().eval( pos_3, point_3 );
+ //first lets find 3 points.
+ SPAposition point_1, point_2, point_3;
+ SPApar_pos const pos_1( 0, 1 );
+ SPApar_pos const pos_2( 1, 0 );
+ SPApar_pos const pos_3( 0, 0 );
+ PLANE_ptr->equation().eval( pos_1, point_1 );
+ PLANE_ptr->equation().eval( pos_2, point_2 );
+ PLANE_ptr->equation().eval( pos_3, point_3 );
- CubitBox cubit_super_box = GeometryQueryTool::instance()->model_bounding_box();
- SPAbox super_box = AcisQueryEngine::bounding_box(cubit_super_box);
+ CubitBox cubit_super_box = GeometryQueryTool::instance()->model_bounding_box();
+ SPAbox super_box = AcisQueryEngine::bounding_box(cubit_super_box);
- CubitVector vec_1( point_1.x(), point_1.y(), point_1.z() );
- CubitVector vec_2( point_2.x(), point_2.y(), point_2.z() );
- CubitVector vec_3( point_3.x(), point_3.y(), point_3.z() );
+ CubitVector vec_1( point_1.x(), point_1.y(), point_1.z() );
+ CubitVector vec_2( point_2.x(), point_2.y(), point_2.z() );
+ CubitVector vec_3( point_3.x(), point_3.y(), point_3.z() );
- BODY *sheet_body = this->create_infinite_plane_cutting_tool(
- vec_1, vec_2, vec_3, super_box, CUBIT_TRUE );
- if (sheet_body == NULL ||
- sheet_body->lump() == NULL ||
- sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL ||
- sheet_body->lump()->shell()->first_face()->geometry() == NULL )
- {
- //webcut_failed(refbody_cleanup_list, BODY_cleanup_list);
+ BODY *sheet_body = this->create_infinite_plane_cutting_tool(
+ vec_1, vec_2, vec_3, super_box, CUBIT_TRUE );
+ if (sheet_body == NULL ||
+ sheet_body->lump() == NULL ||
+ sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL ||
+ sheet_body->lump()->shell()->first_face()->geometry() == NULL )
+ {
+ //webcut_failed(refbody_cleanup_list, BODY_cleanup_list);
PRINT_ERROR("In AcisModifyEngine::make_type_FACE(plane)"
" Cannot create infinite plane cutting tool using \n"
" the give surface. \n");
return (FACE*)NULL;
- }
- return sheet_body->lump()->shell()->first_face();
+ }
+ return sheet_body->lump()->shell()->first_face();
}
//-------------------------------------------------------------------------
// Purpose : Create a face from the face pointer. This will create
@@ -4360,66 +4355,66 @@
// Creation Date : 10/6/97
//-------------------------------------------------------------------------
FACE* AcisModifyEngine::make_FACE(FACE* FACE_ptr,
- CubitBoolean extended_from) const
+ CubitBoolean extended_from) const
{
if (FACE_ptr == NULL)
return NULL;
if (extended_from == CUBIT_TRUE)
- {
+ {
// We need to get the type of surface.
// For some reason I can't get it to cast on the fly.
- SURFACE *SURFACE_ptr = FACE_ptr->geometry();
- int type = SURFACE_ptr->identity();
- if (type == CONE_TYPE)
- return make_type_FACE((CONE*)SURFACE_ptr);
- else if (type == SPHERE_TYPE)
- return make_type_FACE((SPHERE*)SURFACE_ptr);
- else if (type == TORUS_TYPE)
- return make_type_FACE((TORUS*)SURFACE_ptr);
- else if (type == SPLINE_TYPE)
- return make_type_FACE((SPLINE*)SURFACE_ptr);
- else if (type == PLANE_TYPE)
- return make_type_FACE((PLANE*)SURFACE_ptr);
- else
- return NULL;
- }
+ SURFACE *SURFACE_ptr = FACE_ptr->geometry();
+ int type = SURFACE_ptr->identity();
+ if (type == CONE_TYPE)
+ return make_type_FACE((CONE*)SURFACE_ptr);
+ else if (type == SPHERE_TYPE)
+ return make_type_FACE((SPHERE*)SURFACE_ptr);
+ else if (type == TORUS_TYPE)
+ return make_type_FACE((TORUS*)SURFACE_ptr);
+ else if (type == SPLINE_TYPE)
+ return make_type_FACE((SPLINE*)SURFACE_ptr);
+ else if (type == PLANE_TYPE)
+ return make_type_FACE((PLANE*)SURFACE_ptr);
+ else
+ return NULL;
+ }
FACE *face_list[1];
BODY *sheet_body;
face_list[0] = FACE_ptr;
- // Make a FACE from copy_FACE.
+ // Make a FACE from copy_FACE.
outcome rc = api_sheet_from_ff(1, face_list, sheet_body);
- // Now check to see if we created the sheet successfully.
+ // Now check to see if we created the sheet successfully.
if (!rc.ok())
- {
- PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
- " ACIS api_sheet_from_ff function failed.\n\n");
- AcisQueryEngine::instance()->ACIS_API_error (rc);
- return (FACE *)NULL;
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
+ " ACIS api_sheet_from_ff function failed.\n\n");
+ AcisQueryEngine::instance()->ACIS_API_error (rc);
+ return (FACE *)NULL;
+ }
- // Convert the FACE to a true sheet BODY.
+ // Convert the FACE to a true sheet BODY.
outcome rc_2 = api_body_to_2d(sheet_body);
if (!rc_2.ok())
- {
- PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
- " ACIS api_body_to_2d function failed.\n\n");
- AcisQueryEngine::instance()->ACIS_API_error (rc_2);
- return (FACE *)NULL;
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
+ " ACIS api_body_to_2d function failed.\n\n");
+ AcisQueryEngine::instance()->ACIS_API_error (rc_2);
+ return (FACE *)NULL;
+ }
- // Make sure we were successful
+ // Make sure we were successful
if ( sheet_body->lump() == NULL ||
sheet_body->lump()->shell() == NULL ||
sheet_body->lump()->shell()->first_face() == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
- " ACIS api_sheet_from_ff function failed.\n\n");
- return (FACE*)NULL;
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_FACE\n"
+ " ACIS api_sheet_from_ff function failed.\n\n");
+ return (FACE*)NULL;
+ }
return sheet_body->lump()->shell()->first_face();
}
@@ -4440,26 +4435,26 @@
DLIList<EDGE*>& input_EDGE_list,
Surface *old_surface_ptr) const
{
- // Make sure a supported type of surface is being requested.
+ // Make sure a supported type of surface is being requested.
if ( FACE_type != PLANE_SURFACE_TYPE &&
FACE_type != BEST_FIT_SURFACE_TYPE)
- {
- PRINT_WARNING("In AcisGeometryEngine::make_FACE\n"
- " At this time, cannot make a FACE that isn't"
- " planar or best fit.\n");
- return (FACE *)NULL;
- }
+ {
+ PRINT_WARNING("In AcisGeometryEngine::make_FACE\n"
+ " At this time, cannot make a FACE that isn't"
+ " planar or best fit.\n");
+ return (FACE *)NULL;
+ }
- // Set the FACE pointer, if requested.
+ // Set the FACE pointer, if requested.
FACE *fit_FACE = NULL;
if ( old_surface_ptr != NULL )
- {
- SurfaceACIS *surf_ACIS = CAST_TO(old_surface_ptr, SurfaceACIS );
- fit_FACE = surf_ACIS->get_FACE_ptr();
- }
+ {
+ SurfaceACIS *surf_ACIS = CAST_TO(old_surface_ptr, SurfaceACIS );
+ fit_FACE = surf_ACIS->get_FACE_ptr();
+ }
- // Copy the original EDGEs and put them into an array.
- // Also initialize variables that will be used/returned by ACIS.
+ // Copy the original EDGEs and put them into an array.
+ // Also initialize variables that will be used/returned by ACIS.
int edge_count = input_EDGE_list.size();
FACE* FACE_ptr = NULL;
BODY* wire_BODY = NULL;
@@ -4469,12 +4464,12 @@
int i;
for (i = 0 ; i < edge_count ; i++)
- {
- copy_single_entity( (ENTITY *)input_EDGE_list.get_and_step(), temp_ENTITY_ptr);
- EDGEs[i] = (EDGE*)temp_ENTITY_ptr;
+ {
+ copy_single_entity( (ENTITY *)input_EDGE_list.get_and_step(), temp_ENTITY_ptr);
+ EDGEs[i] = (EDGE*)temp_ENTITY_ptr;
// Deactivate the RefEntities attached to the EDGE and its VERTEXes.
- mark_owners_deactivated_flag(EDGEs[i], CUBIT_TRUE, CUBIT_TRUE);
- }
+ mark_owners_deactivated_flag(EDGEs[i], CUBIT_TRUE, CUBIT_TRUE);
+ }
// Make a wire BODY from the copied EDGEs.
// Coincident VERTEXes will be deleted by ACIS.
@@ -4487,116 +4482,116 @@
wire_BODYs.add( wireBODYs[i] );
if ( !result.ok() || wire_BODYs.count() == 0 )
+ {
+ PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
+ " ACIS api_make_ewire function failed.\n\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ if (wire_BODYs.count())
+ for(i=0; i<wire_BODYs.count(); i++ )
+ api_delent(wire_BODYs[i]);
+ else
{
- PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
- " ACIS api_make_ewire function failed.\n\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- if (wire_BODYs.count())
- for(i=0; i<wire_BODYs.count(); i++ )
- api_delent(wire_BODYs[i]);
- else
- {
- while (edge_count--)
- api_delent(EDGEs[edge_count]);
- }
-
- delete [] EDGEs;
- return (FACE *)NULL;
+ while (edge_count--)
+ api_delent(EDGEs[edge_count]);
}
- // Check to make sure the wire is closed
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
+
+ // Check to make sure the wire is closed
for(i=0; i<wire_BODYs.count(); i++ )
+ {
+ result = api_closed_wire( (BODY*)wire_BODYs[i] );
+ if( !result.ok() )
{
- result = api_closed_wire( (BODY*)wire_BODYs[i] );
- if( !result.ok() )
- {
- PRINT_ERROR( "ACIS reports that a closed loop was not found\n" );
- // Delete the wire BODY. This will also delete
- // each copied EDGE
- for(i=0; i<wire_BODYs.count(); i++ )
- api_delent(wire_BODYs[i]);
- // Delete the array
- delete [] EDGEs;
- return (FACE *)NULL;
- }
+ PRINT_ERROR( "ACIS reports that a closed loop was not found\n" );
+ // Delete the wire BODY. This will also delete
+ // each copied EDGE
+ for(i=0; i<wire_BODYs.count(); i++ )
+ api_delent(wire_BODYs[i]);
+ // Delete the array
+ delete [] EDGEs;
+ return (FACE *)NULL;
}
+ }
//check planarity & co-planarity
if( wire_BODYs.count() > 1 )
+ {
+ CubitVector master_centroid;
+ CubitVector master_normal;
+ for(i=0; i<wire_BODYs.count(); i++ )
{
- CubitVector master_centroid;
- CubitVector master_normal;
- for(i=0; i<wire_BODYs.count(); i++ )
- {
- SPAposition centroid;
- SPAunit_vector normal;
+ SPAposition centroid;
+ SPAunit_vector normal;
- if( !is_planar_wire( (WIRE*)wire_BODYs[i], centroid, normal ) )
- {
- PRINT_ERROR( "Multiple loops must be planar.\n" );
- for(i=0; i<wire_BODYs.count(); i++ )
- api_delent(wire_BODYs[i]);
- delete [] EDGEs;
- return (FACE *)NULL;
- }
- //make the plane
- if( i==0 )
- {
- master_centroid.set( centroid.x(), centroid.y(), centroid.z() );
- master_normal.set( normal.x(), normal.y(), normal.z() );
- }
- else
- {
- CubitVector tmp_centroid( centroid.x(), centroid.y(), centroid.z() );
- CubitVector tmp_normal( normal.x(), normal.y(), normal.z() );
- CubitVector tmp_vec( tmp_centroid - master_centroid );
- tmp_vec.normalize();
- double dot = master_normal % tmp_vec;
- tmp_normal = tmp_normal * master_normal;
+ if( !is_planar_wire( (WIRE*)wire_BODYs[i], centroid, normal ) )
+ {
+ PRINT_ERROR( "Multiple loops must be planar.\n" );
+ for(i=0; i<wire_BODYs.count(); i++ )
+ api_delent(wire_BODYs[i]);
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
+ //make the plane
+ if( i==0 )
+ {
+ master_centroid.set( centroid.x(), centroid.y(), centroid.z() );
+ master_normal.set( normal.x(), normal.y(), normal.z() );
+ }
+ else
+ {
+ CubitVector tmp_centroid( centroid.x(), centroid.y(), centroid.z() );
+ CubitVector tmp_normal( normal.x(), normal.y(), normal.z() );
+ CubitVector tmp_vec( tmp_centroid - master_centroid );
+ tmp_vec.normalize();
+ double dot = master_normal % tmp_vec;
+ tmp_normal = tmp_normal * master_normal;
- if( tmp_normal.length() > GEOMETRY_RESABS ||
- fabs(dot) > GEOMETRY_RESABS )
- {
- PRINT_ERROR( "Multiple loops must be co-planar.\n" );
- for(i=0; i<wire_BODYs.count(); i++ )
- api_delent(wire_BODYs[i]);
- delete [] EDGEs;
- return (FACE *)NULL;
- }
- }
- }
+ if( tmp_normal.length() > GEOMETRY_RESABS ||
+ fabs(dot) > GEOMETRY_RESABS )
+ {
+ PRINT_ERROR( "Multiple loops must be co-planar.\n" );
+ for(i=0; i<wire_BODYs.count(); i++ )
+ api_delent(wire_BODYs[i]);
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
+ }
}
+ }
//check intersecting
if( wire_BODYs.count() > 1 )
+ {
+ for(i=0; i<wire_BODYs.count(); i++ )
{
- for(i=0; i<wire_BODYs.count(); i++ )
- {
- ENTITY *ent1 = wire_BODYs[i];
+ ENTITY *ent1 = wire_BODYs[i];
- int j;
- for(j=0; j<wire_BODYs.count(); j++ )
- {
- if( i==j )
- continue;
+ int j;
+ for(j=0; j<wire_BODYs.count(); j++ )
+ {
+ if( i==j )
+ continue;
- ENTITY *ent2 = wire_BODYs[j];
- logical touching = FALSE;
+ ENTITY *ent2 = wire_BODYs[j];
+ logical touching = FALSE;
- api_entity_entity_touch( ent1, ent2, touching );
+ api_entity_entity_touch( ent1, ent2, touching );
- if( touching )
- {
- PRINT_ERROR( "Multiple loops cannot intersect.\n" );
- for(i=0; i<wire_BODYs.count(); i++ )
- api_delent(wire_BODYs[i]);
- delete [] EDGEs;
- return (FACE *)NULL;
- }
- }
- }
+ if( touching )
+ {
+ PRINT_ERROR( "Multiple loops cannot intersect.\n" );
+ for(i=0; i<wire_BODYs.count(); i++ )
+ api_delent(wire_BODYs[i]);
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
+ }
}
+ }
//sort wires so that the outermost is first
wire_BODYs.init();
@@ -4604,256 +4599,256 @@
ENTITY *outermost_wire= NULL;
double longest_diagonal = 0.0;
if( wire_BODYs.count() > 1 )
+ {
+ for(i=0; i<wire_BODYs.count(); i++ )
{
- for(i=0; i<wire_BODYs.count(); i++ )
- {
- SPAbox tmp_box;
- CubitBox tmp_cbox;
- ENTITY *tmp_wire = wire_BODYs.next();
- if(i==0)
- {
- tmp_box = AcisQueryEngine::instance()->bounding_box( (BODY*)tmp_wire);
- outermost_wire = tmp_wire;
- tmp_cbox = AcisQueryEngine::bounding_box( tmp_box );
- longest_diagonal = tmp_cbox.diagonal().length();
- }
- else
- {
- tmp_box = AcisQueryEngine::instance()->bounding_box( (BODY*)tmp_wire);
- tmp_cbox = AcisQueryEngine::bounding_box( tmp_box );
+ SPAbox tmp_box;
+ CubitBox tmp_cbox;
+ ENTITY *tmp_wire = wire_BODYs.next();
+ if(i==0)
+ {
+ tmp_box = AcisQueryEngine::instance()->bounding_box( (BODY*)tmp_wire);
+ outermost_wire = tmp_wire;
+ tmp_cbox = AcisQueryEngine::bounding_box( tmp_box );
+ longest_diagonal = tmp_cbox.diagonal().length();
+ }
+ else
+ {
+ tmp_box = AcisQueryEngine::instance()->bounding_box( (BODY*)tmp_wire);
+ tmp_cbox = AcisQueryEngine::bounding_box( tmp_box );
- if( tmp_cbox.diagonal().length() > longest_diagonal )
- {
- longest_diagonal = tmp_cbox.diagonal().length();
- outermost_wire = tmp_wire;
- }
- }
- }
+ if( tmp_cbox.diagonal().length() > longest_diagonal )
+ {
+ longest_diagonal = tmp_cbox.diagonal().length();
+ outermost_wire = tmp_wire;
+ }
+ }
+ }
- //now that we found the outermost, put it first in the list
- wire_BODYs.clear();
- tmp_wire_BODYs.remove( outermost_wire );
- wire_BODYs.add( outermost_wire );
+ //now that we found the outermost, put it first in the list
+ wire_BODYs.clear();
+ tmp_wire_BODYs.remove( outermost_wire );
+ wire_BODYs.add( outermost_wire );
- tmp_wire_BODYs.init();
- for(i=0; i<tmp_wire_BODYs.count(); i++ )
- wire_BODYs.add( tmp_wire_BODYs.next() );
- }
+ tmp_wire_BODYs.init();
+ for(i=0; i<tmp_wire_BODYs.count(); i++ )
+ wire_BODYs.add( tmp_wire_BODYs.next() );
+ }
- // Use the WIRE to make a FACE.
- // Note that the call to api_cover_wires creates not
- // only the FACE but the entire topological data
- // structure above FACE (till BODY).
+ // Use the WIRE to make a FACE.
+ // Note that the call to api_cover_wires creates not
+ // only the FACE but the entire topological data
+ // structure above FACE (till BODY).
ENTITY_LIST acis_FACE_list;
if ( fit_FACE != NULL )
- {
- wire_BODY = static_cast<BODY*>(wire_BODYs[0]);
- outcome result_2 = api_cover_wires ( wire_BODY,
- fit_FACE->geometry()->equation(),
- acis_FACE_list );
+ {
+ wire_BODY = static_cast<BODY*>(wire_BODYs[0]);
+ outcome result_2 = api_cover_wires ( wire_BODY,
+ fit_FACE->geometry()->equation(),
+ acis_FACE_list );
// Now check to see if we covered the wire successfully
- if ( !result_2.ok() || acis_FACE_list.count() == 0 ||
- wire_BODY == NULL )
- {
- PRINT_ERROR("Error in constructing surface on top of another"
- "surface, the edges must fit the surface...\n");
- AcisQueryEngine::instance()->ACIS_API_error (result_2);
- acis_FACE_list.clear();
- if (wire_BODY)
- api_delent(wire_BODY);
- else
- // TO DO: Delete each EDGE in EDGEs
- void (0);
- delete [] EDGEs;
- return (FACE*)NULL;
- }
+ if ( !result_2.ok() || acis_FACE_list.count() == 0 ||
+ wire_BODY == NULL )
+ {
+ PRINT_ERROR("Error in constructing surface on top of another"
+ "surface, the edges must fit the surface...\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result_2);
+ acis_FACE_list.clear();
+ if (wire_BODY)
+ api_delent(wire_BODY);
+ else
+ // TO DO: Delete each EDGE in EDGEs
+ void (0);
+ delete [] EDGEs;
+ return (FACE*)NULL;
}
+ }
else
+ {
+ outcome surface_creation;
+ bool valid_loops = true;
+ outcome loop_check;
+
+ //can create non-planar surfs with one wire
+ if( wire_BODYs.count() == 1 )
{
- outcome surface_creation;
- bool valid_loops = true;
- outcome loop_check;
+ wire_BODY = static_cast<BODY*>(wire_BODYs[0]);
+ surface_creation = api_cover_wires ( wire_BODY,
+ *(surface*)NULL_REF,
+ acis_FACE_list );
+ }
+ else
+ {
+ wire_BODY = NULL;
+ surface_creation = api_cover_wire_loops( wire_BODYs,
+ wire_BODY);
+ //check all nested in largest
+ //check doubly nested
+ api_get_faces( wire_BODY, acis_FACE_list);
+ loop_check = api_check_face_loops( static_cast<FACE*>(acis_FACE_list[0]) );
+ if( !loop_check.ok() )
+ valid_loops = false;
+ }
- //can create non-planar surfs with one wire
- if( wire_BODYs.count() == 1 )
- {
- wire_BODY = static_cast<BODY*>(wire_BODYs[0]);
- surface_creation = api_cover_wires ( wire_BODY,
- *(surface*)NULL_REF,
- acis_FACE_list );
- }
- else
- {
- wire_BODY = NULL;
- surface_creation = api_cover_wire_loops( wire_BODYs,
- wire_BODY);
- //check all nested in largest
- //check doubly nested
- api_get_faces( wire_BODY, acis_FACE_list);
- loop_check = api_check_face_loops( static_cast<FACE*>(acis_FACE_list[0]) );
- if( !loop_check.ok() )
- valid_loops = false;
- }
-
- if ( !surface_creation.ok() || wire_BODY == NULL ||
- !valid_loops || acis_FACE_list.count() != 1 )
- {
- PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
- " problem covering wires.\n\n");
- if( !surface_creation.ok() )
- AcisQueryEngine::instance()->ACIS_API_error (surface_creation);
- if( !valid_loops )
- AcisQueryEngine::instance()->ACIS_API_error( loop_check );
-
- acis_FACE_list.clear();
- if (wire_BODY)
- api_delent(wire_BODY);
- else
- {
- // TO DO: delete each EDGE in EDGEs
- void(0);
-
- wire_BODYs.init();
- ENTITY *ent_to_del;
- while( (ent_to_del = wire_BODYs.next())!=NULL )
- api_delent( ent_to_del );
- }
- delete [] EDGEs;
- return (FACE *)NULL;
- }
- }
- if (acis_FACE_list.count() != 1)
+ if ( !surface_creation.ok() || wire_BODY == NULL ||
+ !valid_loops || acis_FACE_list.count() != 1 )
{
- PRINT_ERROR("ACIS api_cover_wires function created "
- "more than one FACE.\n"
- " At this time, we cannot deal with this.\n");
+ PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
+ " problem covering wires.\n\n");
+ if( !surface_creation.ok() )
+ AcisQueryEngine::instance()->ACIS_API_error (surface_creation);
+ if( !valid_loops )
+ AcisQueryEngine::instance()->ACIS_API_error( loop_check );
+
acis_FACE_list.clear();
if (wire_BODY)
- api_delent(wire_BODY);
+ api_delent(wire_BODY);
else
- // TO DO: delete each EDGE in EDGEs
- void(0);
+ {
+ // TO DO: delete each EDGE in EDGEs
+ void(0);
+
+ wire_BODYs.init();
+ ENTITY *ent_to_del;
+ while( (ent_to_del = wire_BODYs.next())!=NULL )
+ api_delent( ent_to_del );
+ }
delete [] EDGEs;
return (FACE *)NULL;
}
+ }
+ if (acis_FACE_list.count() != 1)
+ {
+ PRINT_ERROR("ACIS api_cover_wires function created "
+ "more than one FACE.\n"
+ " At this time, we cannot deal with this.\n");
+ acis_FACE_list.clear();
+ if (wire_BODY)
+ api_delent(wire_BODY);
+ else
+ // TO DO: delete each EDGE in EDGEs
+ void(0);
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
- //make this a 2d body.
+ //make this a 2d body.
outcome result_2 = api_body_to_2d( wire_BODY );
if ( !result_2.ok() )
- {
- PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
- " ACIS api_body_to_2d function failed.\n\n");
- AcisQueryEngine::instance()->ACIS_API_error (result_2);
- acis_FACE_list.clear();
- if (wire_BODY)
- api_delent(wire_BODY);
- else
+ {
+ PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
+ " ACIS api_body_to_2d function failed.\n\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result_2);
+ acis_FACE_list.clear();
+ if (wire_BODY)
+ api_delent(wire_BODY);
+ else
// TO DO: delete each EDGE in EDGEs
- void(0);
- delete [] EDGEs;
- return (FACE *)NULL;
- }
+ void(0);
+ delete [] EDGEs;
+ return (FACE *)NULL;
+ }
FACE_ptr = (FACE*) acis_FACE_list[0];
if ( FACE_ptr == NULL || FACE_ptr->geometry() == NULL )
- {
- PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
- "FACE or FACE's geometry was NULL.\n");
- acis_FACE_list.clear();
- if (wire_BODY)
- api_delent(wire_BODY);
- else
+ {
+ PRINT_ERROR("In AcisGeometryEngine::make_FACE\n"
+ "FACE or FACE's geometry was NULL.\n");
+ acis_FACE_list.clear();
+ if (wire_BODY)
+ api_delent(wire_BODY);
+ else
// TO DO: delete each EDGE in EDGEs
- void(0);
- delete [] EDGEs;
- return (FACE*)NULL;
- }
+ void(0);
+ delete [] EDGEs;
+ return (FACE*)NULL;
+ }
acis_FACE_list.clear();
if ( !result.ok() )
- {
- if (wire_BODY)
- api_delent(wire_BODY);
- else
+ {
+ if (wire_BODY)
+ api_delent(wire_BODY);
+ else
// TO DO: delete each EDGE in EDGEs
- void(0);
- delete [] EDGEs;
- return (FACE*)NULL;
- }
+ void(0);
+ delete [] EDGEs;
+ return (FACE*)NULL;
+ }
- // This will reactivate all the RefEntities that need to be kept.
+ // This will reactivate all the RefEntities that need to be kept.
mark_owners_deactivated_flag(FACE_ptr, CUBIT_FALSE, CUBIT_TRUE);
- // Where coincident vertices were merged by ACIS,
- // make sure the lower ID is used.
+ // Where coincident vertices were merged by ACIS,
+ // make sure the lower ID is used.
input_EDGE_list.reset();
for (i = 0; i < input_EDGE_list.size(); i++)
- {
+ {
// get the copy and original EDGE
- EDGE* cur_EDGE_new = EDGEs[i];
- EDGE* cur_EDGE_old = input_EDGE_list.get_and_step();
+ EDGE* cur_EDGE_new = EDGEs[i];
+ EDGE* cur_EDGE_old = input_EDGE_list.get_and_step();
// If the original start RefVertex is deactivated,
// see if we need to swap it with the replacement RefVertex
- VERTEX* cur_VERT_new = cur_EDGE_new->start();
- VERTEX* cur_VERT_old = cur_EDGE_old->start();
+ VERTEX* cur_VERT_new = cur_EDGE_new->start();
+ VERTEX* cur_VERT_old = cur_EDGE_old->start();
- for (int j = 2; j--; )
- {
- RefVertex* ref_vert_old =
- CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_old),
- RefVertex);
+ for (int j = 2; j--; )
+ {
+ RefVertex* ref_vert_old =
+ CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_old),
+ RefVertex);
- AcisBridge* bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_old);
+ AcisBridge* bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_old);
- if (ref_vert_old && bridge_deactivated(bridge))
- {
- RefVertex* ref_vert_new =
- CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_new),
- RefVertex);
- if (ref_vert_new && ref_vert_old->id() < ref_vert_new->id())
- {
- int id_old = ref_vert_old->id();
- int id_new = ref_vert_new->id();
- ref_vert_old->set_id(0);
- ref_vert_new->set_id(id_old);
- ref_vert_old->set_id(id_new);
- }
- }
+ if (ref_vert_old && bridge_deactivated(bridge))
+ {
+ RefVertex* ref_vert_new =
+ CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_new),
+ RefVertex);
+ if (ref_vert_new && ref_vert_old->id() < ref_vert_new->id())
+ {
+ int id_old = ref_vert_old->id();
+ int id_new = ref_vert_new->id();
+ ref_vert_old->set_id(0);
+ ref_vert_new->set_id(id_old);
+ ref_vert_old->set_id(id_new);
+ }
+ }
- /*
- PointACIS* ref_vert_old =
- CAST_TO(ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_old),PointACIS);
+/*
+ PointACIS* ref_vert_old =
+ CAST_TO(ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_old),PointACIS);
- if (ref_vert_old && bridge_deactivated(ref_vert_old) && ref_vert_old->owner())
- {
- //RefVertex* ref_vert_new =
- // CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_new),
- // RefVertex);
- PointACIS* ref_vert_new =
- CAST_TO(ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_new),PointACIS);
- if (ref_vert_new)
- {
- ref_vert_old->owner()->swap_bridge(ref_vert_old,ref_vert_new,true);
- }
- }
- */
- cur_VERT_new = cur_EDGE_new->end();
- cur_VERT_old = cur_EDGE_old->end();
- }
+ if (ref_vert_old && bridge_deactivated(ref_vert_old) && ref_vert_old->owner())
+ {
+ //RefVertex* ref_vert_new =
+ // CAST_TO(ATTRIB_CUBIT_OWNER::get_topology_entity(cur_VERT_new),
+ // RefVertex);
+ PointACIS* ref_vert_new =
+ CAST_TO(ATTRIB_CUBIT_OWNER::cubit_owner(cur_VERT_new),PointACIS);
+ if (ref_vert_new)
+ {
+ ref_vert_old->owner()->swap_bridge(ref_vert_old,ref_vert_new,true);
+ }
+ }
+*/
+ cur_VERT_new = cur_EDGE_new->end();
+ cur_VERT_old = cur_EDGE_old->end();
}
+ }
- // Get rid of the stuff we aren't using. This will delete the RefVertices
- // that correspond to the VERTEXes deleted by ACIS in api_make_ewire.
- // We also delete the original ACIS EDGEs since they are no longer
- // being used.
+ // Get rid of the stuff we aren't using. This will delete the RefVertices
+ // that correspond to the VERTEXes deleted by ACIS in api_make_ewire.
+ // We also delete the original ACIS EDGEs since they are no longer
+ // being used.
for (i = input_EDGE_list.size(); i--; )
- {
- AcisQueryEngine::instance()->unhook_ENTITY_from_VGI(input_EDGE_list.get());
- api_delent(input_EDGE_list.get_and_step());
- }
+ {
+ AcisQueryEngine::instance()->unhook_ENTITY_from_VGI(input_EDGE_list.get());
+ api_delent(input_EDGE_list.get_and_step());
+ }
//GeometryQueryTool::instance()->cleanout_deactivated_geometry();
cleanout_deactivated_geometry();
delete [] EDGEs;
@@ -4871,35 +4866,35 @@
// Creation Date : 03-27-97
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_straight_EDGE( VERTEX* start_VERTEX,
- VERTEX* end_VERTEX ) const
+ VERTEX* end_VERTEX ) const
{
- // Make a straight EDGE
- EDGE* EDGE_ptr = NULL;
- outcome result = api_mk_ed_line ( start_VERTEX->geometry()->coords(),
- end_VERTEX->geometry()->coords(),
- EDGE_ptr );
- if (!result.ok() || EDGE_ptr == NULL)
- {
+ // Make a straight EDGE
+ EDGE* EDGE_ptr = NULL;
+ outcome result = api_mk_ed_line ( start_VERTEX->geometry()->coords(),
+ end_VERTEX->geometry()->coords(),
+ EDGE_ptr );
+ if (!result.ok() || EDGE_ptr == NULL)
+ {
PRINT_ERROR("In AcisModifyEngine::make_straight_EDGE\n"
" ACIS api_mk_ed_line function failed.\n\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (EDGE *)NULL;
- }
+ }
- else
- {
- // Switch the end VERTEXes of the new EDGE to the input VERTEXes. Keep
- // in mind that the back links (from the VERTEX back to the EDGE)
- // need to be modified as well.
+ else
+ {
+ // Switch the end VERTEXes of the new EDGE to the input VERTEXes. Keep
+ // in mind that the back links (from the VERTEX back to the EDGE)
+ // need to be modified as well.
EDGE_ptr->set_start(start_VERTEX);
start_VERTEX->add_edge(EDGE_ptr);
EDGE_ptr->set_end(end_VERTEX);
end_VERTEX->add_edge(EDGE_ptr);
- // Return the newly created EDGE
+ // Return the newly created EDGE
return EDGE_ptr;
- }
+ }
}
//-------------------------------------------------------------------------
@@ -4913,87 +4908,87 @@
// Creation Date : 03-27-97
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_parabolic_EDGE(
- VERTEX* from,
- VERTEX* to,
- SPAposition* peak_ptr ) const
+ VERTEX* from,
+ VERTEX* to,
+ SPAposition* peak_ptr ) const
{
- if ( peak_ptr == NULL )
- {
+ if ( peak_ptr == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_parabolic_EDGE\n"
" Input parabola tip is invalid (NULL pointer).\n");
assert ( peak_ptr != NULL );
return (EDGE *)NULL;
- }
+ }
- // Convert positions to CubitVectors (legacy code!!!)
- SPAposition from_position = from->geometry()->coords();
- SPAposition to_position = to->geometry()->coords();
+ // Convert positions to CubitVectors (legacy code!!!)
+ SPAposition from_position = from->geometry()->coords();
+ SPAposition to_position = to->geometry()->coords();
- CubitVector from_vec( from_position.x(),
- from_position.y(),
- from_position.z() );
- CubitVector to_vec( to_position.x(),
- to_position.y(),
- to_position.z() );
- CubitVector peak_vec( peak_ptr->x(),
- peak_ptr->y(),
- peak_ptr->z() );
+ CubitVector from_vec( from_position.x(),
+ from_position.y(),
+ from_position.z() );
+ CubitVector to_vec( to_position.x(),
+ to_position.y(),
+ to_position.z() );
+ CubitVector peak_vec( peak_ptr->x(),
+ peak_ptr->y(),
+ peak_ptr->z() );
- CubitVector width_vec, midpoint_vec, height_vec;
- width_vec = to_vec - from_vec;
- midpoint_vec = (from_vec + to_vec)/2.0;
- height_vec = peak_vec - midpoint_vec;
+ CubitVector width_vec, midpoint_vec, height_vec;
+ width_vec = to_vec - from_vec;
+ midpoint_vec = (from_vec + to_vec)/2.0;
+ height_vec = peak_vec - midpoint_vec;
- // rho = 0.5 is a (spline) parabola -
- // see ACIS Geometric Modeler API Reference 3-138 ver. 1.7
- double rho = 0.5;
- EDGE* EDGE_ptr = NULL;
- // Find the focus of this parabola.
- // Since for a parabola with its peak at the origin, y = (1/(4*a))*x^2,
- // and since we have restricted this parabola to be symmetric (per the FastQ
- // method, see the FastQ file getwt.f), we can use the following relationship
- // to determine "a", the distance the focus lies from the peak on the line
- // formed by the peak and the midpoint of the start and end points
- //double a = width_vec.length_squared()/(16. * height_vec.length());
- CubitVector height_vec_unit = height_vec;
- height_vec_unit.normalize();
+ // rho = 0.5 is a (spline) parabola -
+ // see ACIS Geometric Modeler API Reference 3-138 ver. 1.7
+ double rho = 0.5;
+ EDGE* EDGE_ptr = NULL;
+ // Find the focus of this parabola.
+ // Since for a parabola with its peak at the origin, y = (1/(4*a))*x^2,
+ // and since we have restricted this parabola to be symmetric (per the FastQ
+ // method, see the FastQ file getwt.f), we can use the following relationship
+ // to determine "a", the distance the focus lies from the peak on the line
+ // formed by the peak and the midpoint of the start and end points
+ //double a = width_vec.length_squared()/(16. * height_vec.length());
+ CubitVector height_vec_unit = height_vec;
+ height_vec_unit.normalize();
- // See Geometric Modeling by M. E. Mortenson, pg. 82, Fig 2.28 c, we need p2
- // as the center_vec from which to get the tangents
- // Our approach assumes that midpoint_vec, peak, and center_vec will all lie
- // on the same line, a valid assumption with the restrictions from FastQ
- CubitVector vec_E_C = peak_vec - midpoint_vec;
- CubitVector center_vec = ((2./rho)*vec_E_C + to_vec + from_vec)/2.;
+ // See Geometric Modeling by M. E. Mortenson, pg. 82, Fig 2.28 c, we need p2
+ // as the center_vec from which to get the tangents
+ // Our approach assumes that midpoint_vec, peak, and center_vec will all lie
+ // on the same line, a valid assumption with the restrictions from FastQ
+ CubitVector vec_E_C = peak_vec - midpoint_vec;
+ CubitVector center_vec = ((2./rho)*vec_E_C + to_vec + from_vec)/2.;
- SPAvector start_tan = SPAvector ( center_vec.x() - from_vec.x(),
- center_vec.y() - from_vec.y(),
- center_vec.z() - from_vec.z() );
+ SPAvector start_tan = SPAvector ( center_vec.x() - from_vec.x(),
+ center_vec.y() - from_vec.y(),
+ center_vec.z() - from_vec.z() );
- SPAvector end_tan = SPAvector ( center_vec.x() - to_vec.x(),
- center_vec.y() - to_vec.y(),
- center_vec.z() - to_vec.z() );
+ SPAvector end_tan = SPAvector ( center_vec.x() - to_vec.x(),
+ center_vec.y() - to_vec.y(),
+ center_vec.z() - to_vec.z() );
- SPAunit_vector start_tan_unit = normalise( start_tan );
- SPAunit_vector end_tan_unit = normalise( end_tan );
+ SPAunit_vector start_tan_unit = normalise( start_tan );
+ SPAunit_vector end_tan_unit = normalise( end_tan );
- outcome result = api_mk_ed_conic ( from_position,
- start_tan_unit,
- to_position,
- end_tan_unit,
- rho,
- EDGE_ptr );
- if (!result.ok() || EDGE_ptr == NULL)
- {
+ outcome result = api_mk_ed_conic ( from_position,
+ start_tan_unit,
+ to_position,
+ end_tan_unit,
+ rho,
+ EDGE_ptr );
+ if (!result.ok() || EDGE_ptr == NULL)
+ {
PRINT_ERROR("ACIS api_mk_ed_conic function failed\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
return (EDGE *)NULL;
- }
+ }
- else
- {
- // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
- // in mind that the back links (from the VERTEX back to the EDGE)
- // need to be modified as well.
+ else
+ {
+ // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
+ // in mind that the back links (from the VERTEX back to the EDGE)
+ // need to be modified as well.
EDGE_ptr->set_start ( from );
from->add_edge( EDGE_ptr );
@@ -5001,7 +4996,7 @@
to->add_edge( EDGE_ptr );
return EDGE_ptr;
- }
+ }
}
//-------------------------------------------------------------------------
@@ -5021,94 +5016,94 @@
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_elliptical_EDGE( VERTEX* from,
- VERTEX* to,
- SPAposition* ctr_ptr,
- bool sense ) const
+ VERTEX* to,
+ SPAposition* ctr_ptr,
+ bool sense ) const
{
- if ( ctr_ptr == NULL )
- {
+ if ( ctr_ptr == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_elliptical_EDGE\n"
" Input ellipse center is invalid (NULL pointer).\n");
return (EDGE *)NULL;
- }
+ }
- // Convert positions to CubitVectors (legacy code!!!)
- SPAposition from_position = from->geometry()->coords();
- SPAposition to_position = to->geometry()->coords();
+ // Convert positions to CubitVectors (legacy code!!!)
+ SPAposition from_position = from->geometry()->coords();
+ SPAposition to_position = to->geometry()->coords();
- CubitVector from_vec( from_position.x(),
- from_position.y(),
- from_position.z() );
- CubitVector to_vec( to_position.x(),
- to_position.y(),
- to_position.z() );
- CubitVector ctr_vec( ctr_ptr->x(),
- ctr_ptr->y(),
- ctr_ptr->z() );
+ CubitVector from_vec( from_position.x(),
+ from_position.y(),
+ from_position.z() );
+ CubitVector to_vec( to_position.x(),
+ to_position.y(),
+ to_position.z() );
+ CubitVector ctr_vec( ctr_ptr->x(),
+ ctr_ptr->y(),
+ ctr_ptr->z() );
- // delta_vee_1 gives major axis of ellipse (circle)
- SPAvector delta_vee_1 = from_position - *ctr_ptr;
- SPAvector delta_vee_2 = to_position - *ctr_ptr;
- if ( delta_vee_1.len() < CUBIT_RESABS*.000001 )
- {
- PRINT_ERROR("Zero length distance to center point.\n");
- return (EDGE*) NULL;
- }
- if ( delta_vee_2.len() < CUBIT_RESABS*.000001 )
- {
- PRINT_ERROR("Zero length distance to center point.\n");
- return (EDGE*) NULL;
- }
- SPAunit_vector normal = normalise( delta_vee_1 * delta_vee_2 );
- // Since this is a normalised SPAvector, its length should be 1.0.
- // If it is not, then the delta_vee_1 and delta_vee_2
- // vectors are collinear and we have to manually set the normal
- // SPAvector. Assume that this is being done in FASTQ and set the normal
- // to be the Z axis.
- if (normal.len() == 0.0)
- {
- // The start and end vertex are in the same SPAposition, or they are
- // 180 degrees opposed.
+ // delta_vee_1 gives major axis of ellipse (circle)
+ SPAvector delta_vee_1 = from_position - *ctr_ptr;
+ SPAvector delta_vee_2 = to_position - *ctr_ptr;
+ if ( delta_vee_1.len() < CUBIT_RESABS*.000001 )
+ {
+ PRINT_ERROR("Zero length distance to center point.\n");
+ return (EDGE*) NULL;
+ }
+ if ( delta_vee_2.len() < CUBIT_RESABS*.000001 )
+ {
+ PRINT_ERROR("Zero length distance to center point.\n");
+ return (EDGE*) NULL;
+ }
+ SPAunit_vector normal = normalise( delta_vee_1 * delta_vee_2 );
+ // Since this is a normalised SPAvector, its length should be 1.0.
+ // If it is not, then the delta_vee_1 and delta_vee_2
+ // vectors are collinear and we have to manually set the normal
+ // SPAvector. Assume that this is being done in FASTQ and set the normal
+ // to be the Z axis.
+ if (normal.len() == 0.0)
+ {
+ // The start and end vertex are in the same SPAposition, or they are
+ // 180 degrees opposed.
normal.set_x(0.0);
normal.set_y(0.0);
normal.set_z(1.0);
- }
- double radius_ratio = delta_vee_2.len() / delta_vee_1.len();
+ }
+ double radius_ratio = delta_vee_2.len() / delta_vee_1.len();
- EDGE* EDGE_ptr = NULL;
+ EDGE* EDGE_ptr = NULL;
- // if radius_ratio is not 1.0, then this code probably won't produce
- // the intended geometry since delta_vee_1 does not necessarily
- // represent the major axis of an ellipse unless it is circular
- outcome result;
- if ( radius_ratio <= 0.999 || radius_ratio > 1.001 )
- {
+ // if radius_ratio is not 1.0, then this code probably won't produce
+ // the intended geometry since delta_vee_1 does not necessarily
+ // represent the major axis of an ellipse unless it is circular
+ outcome result;
+ if ( radius_ratio <= 0.999 || radius_ratio > 1.001 )
+ {
EDGE_ptr = make_spiral_EDGE(from, to, ctr_ptr, sense);
- }
- else
- {
+ }
+ else
+ {
PRINT_DEBUG_5( "radius ratio = %f\n", radius_ratio);
- // Calculate the included angle between from and to on the
- // circular ellipse
+ // Calculate the included angle between from and to on the
+ // circular ellipse
CubitVector cubit_normal (normal.x(), normal.y(), normal.z());
CubitVector cubit_from = from_vec - ctr_vec;
CubitVector cubit_to = to_vec - ctr_vec;
double incl_angle = cubit_normal.vector_angle ( cubit_from,
cubit_to );
if (incl_angle == 0.0)
- incl_angle = 2.0 * CUBIT_PI;
+ incl_angle = 2.0 * CUBIT_PI;
double start_angle = 0.0;
double end_angle = incl_angle;
if (radius_ratio > 1.0)
- {
- delta_vee_1 = delta_vee_2;
- radius_ratio = 1.0 / radius_ratio;
- start_angle = -incl_angle;
- end_angle = 0.0;
- }
+ {
+ delta_vee_1 = delta_vee_2;
+ radius_ratio = 1.0 / radius_ratio;
+ start_angle = -incl_angle;
+ end_angle = 0.0;
+ }
result = api_mk_ed_ellipse ( *ctr_ptr,
@@ -5118,26 +5113,26 @@
start_angle,
end_angle,
EDGE_ptr );
- }
- if (!result.ok() || EDGE_ptr == NULL)
- {
+ }
+ if (!result.ok() || EDGE_ptr == NULL)
+ {
PRINT_ERROR("In AGE:make_elliptical_EDGE.\n"
"ACIS api_mk_ed_ellipse function failed\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
if ( from == NULL || to == NULL )
- {
- PRINT_ERROR("In AGE:make_elliptical_EDGE.\n"
- " Input VERTEX is NULL\n");
- }
+ {
+ PRINT_ERROR("In AGE:make_elliptical_EDGE.\n"
+ " Input VERTEX is NULL\n");
+ }
return (EDGE *)NULL;
- }
+ }
- else
- {
- // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
- // in mind that the back links (from the VERTEX back to the EDGE)
- // need to be modified as well.
+ else
+ {
+ // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
+ // in mind that the back links (from the VERTEX back to the EDGE)
+ // need to be modified as well.
EDGE_ptr->set_start ( from );
from->add_edge( EDGE_ptr );
@@ -5145,7 +5140,7 @@
to->add_edge( EDGE_ptr );
return EDGE_ptr ;
- }
+ }
}
//-------------------------------------------------------------------------
@@ -5158,30 +5153,30 @@
// Creation Date : 12/10/99
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_circular_EDGE( VERTEX* from,
- VERTEX* to,
- SPAposition* third_pt ) const
+ VERTEX* to,
+ SPAposition* third_pt ) const
{
assert (from != NULL);
assert (to != NULL);
assert (third_pt != NULL);
- // get the 3 points
+ // get the 3 points
SPAposition start_pt = from->geometry()->coords();
SPAposition end_pt = to->geometry()->coords();
- // create the arc
+ // create the arc
EDGE *e_arc;
outcome result = api_curve_arc_3pt(start_pt, *third_pt, end_pt,
FALSE, e_arc);
if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- return NULL;
- }
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ return NULL;
+ }
- // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
- // in mind that the back links (from the VERTEX back to the EDGE)
- // need to be modified as well.
+ // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
+ // in mind that the back links (from the VERTEX back to the EDGE)
+ // need to be modified as well.
e_arc->set_start(from);
from->add_edge(e_arc);
e_arc->set_end (to);
@@ -5204,91 +5199,91 @@
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_spiral_EDGE( VERTEX* from,
- VERTEX* to,
- SPAposition* ctr_ptr,
- bool sense) const
+ VERTEX* to,
+ SPAposition* ctr_ptr,
+ bool sense) const
{
- if ( ctr_ptr == NULL )
- {
+ if ( ctr_ptr == NULL )
+ {
PRINT_ERROR("In AcisModifyEngine::make_spiral_EDGE\n"
" Input spiral center is invalid (NULL pointer).\n");
return (EDGE *)NULL;
- }
+ }
- // Convert positions to CubitVectors (legacy code!!!)
- SPAposition from_position = from->geometry()->coords();
- SPAposition to_position = to->geometry()->coords();
+ // Convert positions to CubitVectors (legacy code!!!)
+ SPAposition from_position = from->geometry()->coords();
+ SPAposition to_position = to->geometry()->coords();
- // NOTE: This function assumes that vertices from, to, and ctr lie in the
- // X-Y plane.
- if (from_position.z() != to_position.z() ||
- from_position.z() != ctr_ptr->z()) {
- PRINT_ERROR("In AcisModifyEngine::make_spiral_EDGE\n"
- " Points must be in the constant-z plane.\n");
- return (EDGE *)NULL;
- }
+ // NOTE: This function assumes that vertices from, to, and ctr lie in the
+ // X-Y plane.
+ if (from_position.z() != to_position.z() ||
+ from_position.z() != ctr_ptr->z()) {
+ PRINT_ERROR("In AcisModifyEngine::make_spiral_EDGE\n"
+ " Points must be in the constant-z plane.\n");
+ return (EDGE *)NULL;
+ }
- CubitVector from_vec( from_position.x(),
- from_position.y(),
- from_position.z() );
- CubitVector to_vec( to_position.x(),
- to_position.y(),
- to_position.z() );
- //CubitVector ctr_vec( ctr_ptr->x(),
- // ctr_ptr->y(),
- // ctr_ptr->z() );
+ CubitVector from_vec( from_position.x(),
+ from_position.y(),
+ from_position.z() );
+ CubitVector to_vec( to_position.x(),
+ to_position.y(),
+ to_position.z() );
+ //CubitVector ctr_vec( ctr_ptr->x(),
+ // ctr_ptr->y(),
+ // ctr_ptr->z() );
- SPAvector delta_vee_1 = from_position - *ctr_ptr;
- SPAvector delta_vee_2 = to_position - *ctr_ptr;
+ SPAvector delta_vee_1 = from_position - *ctr_ptr;
+ SPAvector delta_vee_2 = to_position - *ctr_ptr;
- CubitVector side1( delta_vee_1.x(),
- delta_vee_1.y(),
- delta_vee_1.z()) ;
+ CubitVector side1( delta_vee_1.x(),
+ delta_vee_1.y(),
+ delta_vee_1.z()) ;
- CubitVector side2( delta_vee_2.x(),
- delta_vee_2.y(),
- delta_vee_2.z()) ;
+ CubitVector side2( delta_vee_2.x(),
+ delta_vee_2.y(),
+ delta_vee_2.z()) ;
- CubitVector center( ctr_ptr->x(),
- ctr_ptr->y(),
- ctr_ptr->z()) ;
+ CubitVector center( ctr_ptr->x(),
+ ctr_ptr->y(),
+ ctr_ptr->z()) ;
- // Calcualate parameters for the spiral. See FASTQ source, arcpar.f
- double radius1 = side1.length();
- double radius2 = side2.length();
+ // Calcualate parameters for the spiral. See FASTQ source, arcpar.f
+ double radius1 = side1.length();
+ double radius2 = side2.length();
- double theta1 = atan2(side1.y(), side1.x());
- double theta2 = atan2(side2.y(), side2.x());
- if (sense && theta2 <= theta1)
- {
+ double theta1 = atan2(side1.y(), side1.x());
+ double theta2 = atan2(side2.y(), side2.x());
+ if (sense && theta2 <= theta1)
+ {
theta2 += 2.0 * CUBIT_PI;
- }
- if (!sense && theta1 <= theta2)
- {
+ }
+ if (!sense && theta1 <= theta2)
+ {
theta1 += 2.0 * CUBIT_PI;
- }
+ }
- double total_angle = theta2 - theta1;
+ double total_angle = theta2 - theta1;
- double xk = log(radius2 / radius1) / (theta2 - theta1);
- double xa = radius2 / exp(xk * theta2);
+ double xk = log(radius2 / radius1) / (theta2 - theta1);
+ double xa = radius2 / exp(xk * theta2);
- // Calculate points at 2.0 degree intervals
- int number_points = int(total_angle * 180.0 / CUBIT_PI / 2.0 + 0.5);
- number_points = number_points < 20 ? 20 : number_points;
+ // Calculate points at 2.0 degree intervals
+ int number_points = int(total_angle * 180.0 / CUBIT_PI / 2.0 + 0.5);
+ number_points = number_points < 20 ? 20 : number_points;
- SPAposition *pos_array = new SPAposition [number_points];
+ SPAposition *pos_array = new SPAposition [number_points];
- pos_array[0].set_x(from_vec.x());
- pos_array[0].set_y(from_vec.y());
- pos_array[0].set_z(from_vec.z());
+ pos_array[0].set_x(from_vec.x());
+ pos_array[0].set_y(from_vec.y());
+ pos_array[0].set_z(from_vec.z());
- pos_array[number_points - 1].set_x(to_vec.x());
- pos_array[number_points - 1].set_y(to_vec.y());
- pos_array[number_points - 1].set_z(to_vec.z());
+ pos_array[number_points - 1].set_x(to_vec.x());
+ pos_array[number_points - 1].set_y(to_vec.y());
+ pos_array[number_points - 1].set_z(to_vec.z());
- for (int i=1; i < number_points-1; i++)
- {
+ for (int i=1; i < number_points-1; i++)
+ {
double theta = theta1 + total_angle * ((double)i/(double)number_points);
double radius = xa * exp(xk * theta);
double x = center.x() + radius * cos(theta);
@@ -5297,49 +5292,49 @@
pos_array[i].set_x(x);
pos_array[i].set_y(y);
pos_array[i].set_z(to_vec.z());
- }
+ }
- // calculate default tangent directions using up to three points
- // at the ends of the point array.
- SPAunit_vector uv1(0, 0, 0);
- SPAunit_vector uv2(0, 0, 0);
+ // calculate default tangent directions using up to three points
+ // at the ends of the point array.
+ SPAunit_vector uv1(0, 0, 0);
+ SPAunit_vector uv2(0, 0, 0);
- EDGE* EDGE_ptr = NULL;
- outcome result;
+ EDGE* EDGE_ptr = NULL;
+ outcome result;
- // fifth SPAparameter 0.0 -> interpolate the sequence of points.
- result = api_mk_ed_cubic(number_points, pos_array,
- uv1, uv2, 0.0, EDGE_ptr);
+ // fifth SPAparameter 0.0 -> interpolate the sequence of points.
+ result = api_mk_ed_cubic(number_points, pos_array,
+ uv1, uv2, 0.0, EDGE_ptr);
- // Free memory
- delete [] pos_array;
+ // Free memory
+ delete [] pos_array;
- if ( !result.ok() || EDGE_ptr == NULL )
- {
+ if ( !result.ok() || EDGE_ptr == NULL )
+ {
PRINT_ERROR("ACIS api_mk_ed_cubic function failed\n");
AcisQueryEngine::instance()->ACIS_API_error (result);
if ( from == NULL || to == NULL )
- {
- PRINT_ERROR("In AGE:make_spiral_EDGE.\n"
- " Input VERTEX is NULL\n");
- return (EDGE *)NULL;
- }
- }
+ {
+ PRINT_ERROR("In AGE:make_spiral_EDGE.\n"
+ " Input VERTEX is NULL\n");
+ return (EDGE *)NULL;
+ }
+ }
- else
- {
- // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
- // in mind that the back links (from the VERTEX back to the EDGE)
- // need to be modified as well.
+ else
+ {
+ // Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
+ // in mind that the back links (from the VERTEX back to the EDGE)
+ // need to be modified as well.
EDGE_ptr->set_start ( from );
from->add_edge( EDGE_ptr );
EDGE_ptr->set_end ( to );
to->add_edge( EDGE_ptr );
- }
+ }
- return EDGE_ptr;
+ return EDGE_ptr;
}
//-------------------------------------------------------------------------
// Purpose : Create a curve on a surface.
@@ -5353,17 +5348,17 @@
// Creation Date : 05/15/97
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_surface_EDGE( VERTEX* from_VERTEX,
- VERTEX* to_VERTEX,
- FACE *FACE_ptr,
- const CubitVector &plane_normal,
- const CubitVector *third_point) const
+ VERTEX* to_VERTEX,
+ FACE *FACE_ptr,
+ const CubitVector &plane_normal,
+ const CubitVector *third_point) const
{
- //Now create a cutting plane using the normal passed in. This
- //normal should point sort of tangential to the surface. We
- //want the plane to intersect the surface.
+ //Now create a cutting plane using the normal passed in. This
+ //normal should point sort of tangential to the surface. We
+ //want the plane to intersect the surface.
SPAposition const plane_point = from_VERTEX->geometry()->coords();
SPAunit_vector const normal_vector( plane_normal.x(), plane_normal.y(),
- plane_normal.z() );
+ plane_normal.z() );
plane const new_plane( plane_point, normal_vector );
SPAposition point_1, point_2, point_3;
SPApar_pos const pos_1( 0, 1 );
@@ -5373,35 +5368,35 @@
new_plane.eval( pos_2, point_2 );
new_plane.eval( pos_3, point_3 );
- // Get the size of the model so we can create an "infinite"
- // cutting plane
+ // Get the size of the model so we can create an "infinite"
+ // cutting plane
CubitBox cubit_super_box = GeometryQueryTool::instance()->model_bounding_box();
SPAbox super_box = AcisQueryEngine::bounding_box(cubit_super_box);
CubitVector vec_1( point_1.x(), point_1.y(), point_1.z() );
CubitVector vec_2( point_2.x(), point_2.y(), point_2.z() );
CubitVector vec_3( point_3.x(), point_3.y(), point_3.z() );
- // Create the infinite plane, get a FACE
+ // Create the infinite plane, get a FACE
BODY *sheet_body = this->create_infinite_plane_cutting_tool(
- vec_1, vec_2, vec_3, super_box, CUBIT_TRUE );
+ vec_1, vec_2, vec_3, super_box, CUBIT_TRUE );
if (sheet_body == NULL ||
sheet_body->lump() == NULL ||
sheet_body->lump()->shell() == NULL ||
sheet_body->lump()->shell()->first_face() == NULL ||
sheet_body->lump()->shell()->first_face()->geometry() == NULL )
- {
+ {
//webcut_failed(refbody_cleanup_list, BODY_cleanup_list);
- PRINT_ERROR("In AcisModifyEngine::make_surface_EDGE"
- " Cannot create infinite plane cutting tool using \n"
- " the give surface. \n");
- return (EDGE*)NULL;
- }
+ PRINT_ERROR("In AcisModifyEngine::make_surface_EDGE"
+ " Cannot create infinite plane cutting tool using \n"
+ " the give surface. \n");
+ return (EDGE*)NULL;
+ }
FACE *FACE_1 = sheet_body->lump()->shell()->first_face();
- // Copy the FACE
+ // Copy the FACE
FACE *FACE_2 = make_FACE( FACE_ptr );
- // Now we can create a body representing the intersection
- // of the infinite plane and the passed in surface
+ // Now we can create a body representing the intersection
+ // of the infinite plane and the passed in surface
EDGE* new_EDGE = NULL;
BODY *intersect_BODY = NULL;
LUMP *cur_LUMP = NULL;
@@ -5409,199 +5404,199 @@
COEDGE *cur_COEDGE;
WIRE *cur_WIRE;
- // Get the intersection
+ // Get the intersection
outcome result_1 = api_fafa_int ( FACE_1, FACE_2, intersect_BODY );
- // for some reason a NULL body still returns an ok result. - KGM
+ // for some reason a NULL body still returns an ok result. - KGM
if (intersect_BODY == NULL)
- {
- return (EDGE*)NULL;
- }
+ {
+ return (EDGE*)NULL;
+ }
- // Make sure it was OK, and get the appropriate entity
- // Get a WIRE if it's there
+ // Make sure it was OK, and get the appropriate entity
+ // Get a WIRE if it's there
if ( !result_1.ok() || intersect_BODY->wire() == NULL ||
intersect_BODY->wire()->coedge() == NULL ||
intersect_BODY->wire()->coedge()->edge() == NULL )
- {
+ {
// If there was no WIRE, see if there is a lump
- if ( result_1.ok() && intersect_BODY->lump() != NULL &&
- intersect_BODY->lump()->shell() != NULL &&
- intersect_BODY->lump()->shell()->wire() != NULL &&
- intersect_BODY->lump()->shell()->wire()->coedge() != NULL &&
- intersect_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
- {
- PRINT_DEBUG_18( "Using wire from lumps.\n");
- cur_LUMP = intersect_BODY->lump();
- cur_WIRE = cur_LUMP->shell()->wire();
- }
- else
- {
- PRINT_ERROR("ACIS api_fafa_int function failed\n");
- AcisQueryEngine::instance()->ACIS_API_error (result_1);
- return (EDGE*)NULL;
- }
+ if ( result_1.ok() && intersect_BODY->lump() != NULL &&
+ intersect_BODY->lump()->shell() != NULL &&
+ intersect_BODY->lump()->shell()->wire() != NULL &&
+ intersect_BODY->lump()->shell()->wire()->coedge() != NULL &&
+ intersect_BODY->lump()->shell()->wire()->coedge()->edge() != NULL )
+ {
+ PRINT_DEBUG_18( "Using wire from lumps.\n");
+ cur_LUMP = intersect_BODY->lump();
+ cur_WIRE = cur_LUMP->shell()->wire();
}
- else
+ else
{
- PRINT_DEBUG_18( "Using wire straight from BODY\n");
- cur_WIRE = intersect_BODY->wire();
+ PRINT_ERROR("ACIS api_fafa_int function failed\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result_1);
+ return (EDGE*)NULL;
}
+ }
+ else
+ {
+ PRINT_DEBUG_18( "Using wire straight from BODY\n");
+ cur_WIRE = intersect_BODY->wire();
+ }
- // Now find an EDGE that the points lie on.
- // Start by going through each LUMP, if LUMPs are being used.
+ // Now find an EDGE that the points lie on.
+ // Start by going through each LUMP, if LUMPs are being used.
LUMP* start_LUMP = cur_LUMP;
CURVE *geometry = NULL;
do
- {
- PRINT_DEBUG_18( "**New Lump check**\n");
+ {
+ PRINT_DEBUG_18( "**New Lump check**\n");
// Now go through the wires, coedges, and edges
// to find an edge that the points lie on
- WIRE* start_WIRE = cur_WIRE;
+ WIRE* start_WIRE = cur_WIRE;
+ do
+ {
+ // Get the first coedge in this wire
+ COEDGE* start_COEDGE = cur_WIRE->coedge();
+ cur_COEDGE = start_COEDGE;
+ // Check it and loop through the rest
do
- {
- // Get the first coedge in this wire
- COEDGE* start_COEDGE = cur_WIRE->coedge();
- cur_COEDGE = start_COEDGE;
- // Check it and loop through the rest
- do
- {
- PRINT_DEBUG_18( " **New CoEdge check**\n");
- cur_EDGE = cur_COEDGE->edge();
- geometry = cur_EDGE->geometry();
- // See if this is close enough to
- // the start and end points
- if (geometry != NULL)
- {
- SPAposition new_point;
- // Make sure start vertex is on curve
- geometry->equation().point_perp(from_VERTEX->geometry()->coords(),
- new_point);
- PRINT_DEBUG_18( "\n\tNew Point 1: (%g, %g, %g)\n"
- "\t From Vert: (%g, %g, %g)\n",
- new_point.x(),
- new_point.y(),
- new_point.z(),
- from_VERTEX->geometry()->coords().x(),
- from_VERTEX->geometry()->coords().y(),
- from_VERTEX->geometry()->coords().z());
- if (AcisQueryEngine::instance()->about_spatially_equal(from_VERTEX->geometry()->coords(),
- new_point, 1.0))
- {
- // Make sure end vertex is on curve
- geometry->equation().point_perp(to_VERTEX->geometry()->coords(),
- new_point);
- PRINT_DEBUG_18( "\tNew Point 2: (%g, %g, %g)\n"
- "\t To Vert: (%g, %g, %g) \n",
- new_point.x(),
- new_point.y(),
- new_point.z(),
- to_VERTEX->geometry()->coords().x(),
- to_VERTEX->geometry()->coords().y(),
- to_VERTEX->geometry()->coords().z());
- if (AcisQueryEngine::instance()->about_spatially_equal(to_VERTEX->geometry()->coords(),
- new_point, 1.0))
- {
- // You found it!!!
- cur_WIRE = NULL;
- start_LUMP = NULL;
- break;
- }
- }
- }
- cur_COEDGE = cur_COEDGE->next();
- geometry = NULL; // Make sure you indicate we haven't found geom
- }while (cur_COEDGE != NULL && cur_COEDGE != start_COEDGE);
- // You break out of this do-while loop when
- // a) You find the correct EDGE
- // b) There are no more COEDGEs in this WIRE
- // c) You loop through all of the COEDGES in this WIRE
+ {
+ PRINT_DEBUG_18( " **New CoEdge check**\n");
+ cur_EDGE = cur_COEDGE->edge();
+ geometry = cur_EDGE->geometry();
+ // See if this is close enough to
+ // the start and end points
+ if (geometry != NULL)
+ {
+ SPAposition new_point;
+ // Make sure start vertex is on curve
+ geometry->equation().point_perp(from_VERTEX->geometry()->coords(),
+ new_point);
+ PRINT_DEBUG_18( "\n\tNew Point 1: (%g, %g, %g)\n"
+ "\t From Vert: (%g, %g, %g)\n",
+ new_point.x(),
+ new_point.y(),
+ new_point.z(),
+ from_VERTEX->geometry()->coords().x(),
+ from_VERTEX->geometry()->coords().y(),
+ from_VERTEX->geometry()->coords().z());
+ if (AcisQueryEngine::instance()->about_spatially_equal(from_VERTEX->geometry()->coords(),
+ new_point, 1.0))
+ {
+ // Make sure end vertex is on curve
+ geometry->equation().point_perp(to_VERTEX->geometry()->coords(),
+ new_point);
+ PRINT_DEBUG_18( "\tNew Point 2: (%g, %g, %g)\n"
+ "\t To Vert: (%g, %g, %g) \n",
+ new_point.x(),
+ new_point.y(),
+ new_point.z(),
+ to_VERTEX->geometry()->coords().x(),
+ to_VERTEX->geometry()->coords().y(),
+ to_VERTEX->geometry()->coords().z());
+ if (AcisQueryEngine::instance()->about_spatially_equal(to_VERTEX->geometry()->coords(),
+ new_point, 1.0))
+ {
+ // You found it!!!
+ cur_WIRE = NULL;
+ start_LUMP = NULL;
+ break;
+ }
+ }
+ }
+ cur_COEDGE = cur_COEDGE->next();
+ geometry = NULL; // Make sure you indicate we haven't found geom
+ }while (cur_COEDGE != NULL && cur_COEDGE != start_COEDGE);
+ // You break out of this do-while loop when
+ // a) You find the correct EDGE
+ // b) There are no more COEDGEs in this WIRE
+ // c) You loop through all of the COEDGES in this WIRE
- // Print out some debug diagnostics
- if (DEBUG_FLAG(18))
- {
- if (cur_COEDGE == NULL)
- PRINT_INFO("Exit loop because CoEdge was NULL\n");
- else if (cur_COEDGE == start_COEDGE)
- PRINT_INFO("Exit loop because cur_COEDGE == start_COEDGE\n");
- else
- PRINT_INFO("Exit loop for Other Reason!!!\n");
- }
+ // Print out some debug diagnostics
+ if (DEBUG_FLAG(18))
+ {
+ if (cur_COEDGE == NULL)
+ PRINT_INFO("Exit loop because CoEdge was NULL\n");
+ else if (cur_COEDGE == start_COEDGE)
+ PRINT_INFO("Exit loop because cur_COEDGE == start_COEDGE\n");
+ else
+ PRINT_INFO("Exit loop for Other Reason!!!\n");
+ }
- // cur_WIRE is NULL if the correct EDGE has been found
- if (cur_WIRE)
- cur_WIRE = cur_WIRE->next();
- }while (cur_WIRE && cur_WIRE != start_WIRE);
+ // cur_WIRE is NULL if the correct EDGE has been found
+ if (cur_WIRE)
+ cur_WIRE = cur_WIRE->next();
+ }while (cur_WIRE && cur_WIRE != start_WIRE);
// You break out of this do-while loop when
// a) You find the correct EDGE
// b) There are no more WIREs in this WIRE list
// c) You loop through all the WIREs
// Print out some debug diagnostics
- if (DEBUG_FLAG(18))
- {
- if (cur_WIRE == NULL)
- PRINT_DEBUG_18( "Exit loop because Wire was NULL\n");
- else if (cur_WIRE == start_WIRE)
- PRINT_DEBUG_18( "Exit loop because cur_WIRE == start_WIRE\n");
- else
- PRINT_DEBUG_18( "Exit loop for Other Reason!!!\n");
- }
+ if (DEBUG_FLAG(18))
+ {
+ if (cur_WIRE == NULL)
+ PRINT_DEBUG_18( "Exit loop because Wire was NULL\n");
+ else if (cur_WIRE == start_WIRE)
+ PRINT_DEBUG_18( "Exit loop because cur_WIRE == start_WIRE\n");
+ else
+ PRINT_DEBUG_18( "Exit loop for Other Reason!!!\n");
+ }
// If we are using lumps, go to the next lump
// and get its first wire.
- if (start_LUMP)
- {
- cur_LUMP = cur_LUMP->next();
- if (cur_LUMP)
- cur_WIRE = cur_LUMP->shell()->wire();
- }
+ if (start_LUMP)
+ {
+ cur_LUMP = cur_LUMP->next();
+ if (cur_LUMP)
+ cur_WIRE = cur_LUMP->shell()->wire();
+ }
- }while (start_LUMP && cur_LUMP && start_LUMP != cur_LUMP);
- // You break out of this do-while loop when
- // a) You find the correct EDGE
- // b) There are no more LUMPs in the BODY
- // c) You looped through all the LUMPs in the BODY
- // d) We weren't using LUMPs to start with
+ }while (start_LUMP && cur_LUMP && start_LUMP != cur_LUMP);
+ // You break out of this do-while loop when
+ // a) You find the correct EDGE
+ // b) There are no more LUMPs in the BODY
+ // c) You looped through all the LUMPs in the BODY
+ // d) We weren't using LUMPs to start with
- // Print out some debug diagnostics
+ // Print out some debug diagnostics
if (DEBUG_FLAG(18))
- {
- if (start_LUMP == NULL)
- PRINT_INFO("Exit loop because start_LUMP was NULL\n");
- else if (cur_LUMP == NULL)
- PRINT_INFO("Exit loop because cur_LUMP == NULL\n");
- else if (cur_LUMP == start_LUMP)
- PRINT_INFO("Exit loop because cur_WIRE == start_WIRE\n");
- else
- PRINT_INFO("Exit loop for Other Reason!!!\n");
- }
+ {
+ if (start_LUMP == NULL)
+ PRINT_INFO("Exit loop because start_LUMP was NULL\n");
+ else if (cur_LUMP == NULL)
+ PRINT_INFO("Exit loop because cur_LUMP == NULL\n");
+ else if (cur_LUMP == start_LUMP)
+ PRINT_INFO("Exit loop because cur_WIRE == start_WIRE\n");
+ else
+ PRINT_INFO("Exit loop for Other Reason!!!\n");
+ }
- // Make sure you found something valid
+ // Make sure you found something valid
if ( geometry == NULL )
- {
- PRINT_ERROR("ACIS failed to find geometry for new curve.\n");
- return (EDGE*)NULL;
- }
+ {
+ PRINT_ERROR("ACIS failed to find geometry for new curve.\n");
+ return (EDGE*)NULL;
+ }
PRINT_DEBUG_18( " The EDGE coords:\n"
- " start: (%g, %g, %g)\n"
- " end: (%g, %g, %g)\n",
- cur_EDGE->end_pos().x(),
- cur_EDGE->end_pos().y(),
- cur_EDGE->end_pos().z(),
- cur_EDGE->start_pos().x(),
- cur_EDGE->start_pos().y(),
- cur_EDGE->start_pos().z());
+ " start: (%g, %g, %g)\n"
+ " end: (%g, %g, %g)\n",
+ cur_EDGE->end_pos().x(),
+ cur_EDGE->end_pos().y(),
+ cur_EDGE->end_pos().z(),
+ cur_EDGE->start_pos().x(),
+ cur_EDGE->start_pos().y(),
+ cur_EDGE->start_pos().z());
- // Handle special stuff for periodic curves
+ // Handle special stuff for periodic curves
int periodic = geometry->equation().periodic();
double period = 0.0;
if ( periodic )
- {
- period = geometry->equation().param_period();
- }
+ {
+ period = geometry->equation().param_period();
+ }
double start_param, end_param;
start_param = cur_EDGE->start_param();
@@ -5616,32 +5611,32 @@
// If periodic get the params in the range of the curve's param range.
if(periodic)
+ {
+ // forward param range
+ if(curve_range > 0.0)
{
- // forward param range
- if(curve_range > 0.0)
- {
- while(v1_param < start_param - GEOMETRY_RESABS)
- v1_param += period;
- while(v1_param > end_param + GEOMETRY_RESABS)
- v1_param -= period;
- while(v2_param < start_param - GEOMETRY_RESABS)
- v2_param += period;
- while(v2_param > end_param + GEOMETRY_RESABS)
- v2_param -= period;
- }
- // reversed param range (will this ever happen?)
- else
- {
- while(v1_param < end_param - GEOMETRY_RESABS)
- v1_param += period;
- while(v1_param > start_param + GEOMETRY_RESABS)
- v1_param -= period;
- while(v2_param < end_param - GEOMETRY_RESABS)
- v2_param += period;
- while(v2_param > start_param + GEOMETRY_RESABS)
- v2_param -= period;
- }
+ while(v1_param < start_param - GEOMETRY_RESABS)
+ v1_param += period;
+ while(v1_param > end_param + GEOMETRY_RESABS)
+ v1_param -= period;
+ while(v2_param < start_param - GEOMETRY_RESABS)
+ v2_param += period;
+ while(v2_param > end_param + GEOMETRY_RESABS)
+ v2_param -= period;
}
+ // reversed param range (will this ever happen?)
+ else
+ {
+ while(v1_param < end_param - GEOMETRY_RESABS)
+ v1_param += period;
+ while(v1_param > start_param + GEOMETRY_RESABS)
+ v1_param -= period;
+ while(v2_param < end_param - GEOMETRY_RESABS)
+ v2_param += period;
+ while(v2_param > start_param + GEOMETRY_RESABS)
+ v2_param -= period;
+ }
+ }
double new_param_range = v2_param-v1_param;
@@ -5652,34 +5647,34 @@
if(curve_range*new_param_range < 0.0)
sense_int = 0; /* REVERSED */
- //if we have a third point and we are periodic... use
- //it to nail down the direction.
+ //if we have a third point and we are periodic... use
+ //it to nail down the direction.
if ( third_point != NULL && periodic )
- {
- SPAposition const some_point( third_point->x(),
- third_point->y(),
- third_point->z() );
- SPAposition closest_point;
- geometry->equation().point_perp( some_point, closest_point );
- double some_param = geometry->equation().param( closest_point );
- int val1 = (curve_range > 0.0);
- int val2 = (sense_int == 1);
+ {
+ SPAposition const some_point( third_point->x(),
+ third_point->y(),
+ third_point->z() );
+ SPAposition closest_point;
+ geometry->equation().point_perp( some_point, closest_point );
+ double some_param = geometry->equation().param( closest_point );
+ int val1 = (curve_range > 0.0);
+ int val2 = (sense_int == 1);
- // val1 will equal val2 for two cases. In either case v1_param will
- // be less than v2_param.
- if (val1 == val2)
- {
- if ( some_param < v1_param || some_param > v2_param )
- sense_int = !sense_int;
- }
- // val1 will NOT equal val2 for two cases. In either case v1_param will
- // be greater than v2_param.
- else
- {
- if ( some_param < v2_param || some_param > v1_param )
- sense_int = !sense_int;
- }
+ // val1 will equal val2 for two cases. In either case v1_param will
+ // be less than v2_param.
+ if (val1 == val2)
+ {
+ if ( some_param < v1_param || some_param > v2_param )
+ sense_int = !sense_int;
}
+ // val1 will NOT equal val2 for two cases. In either case v1_param will
+ // be greater than v2_param.
+ else
+ {
+ if ( some_param < v2_param || some_param > v1_param )
+ sense_int = !sense_int;
+ }
+ }
REVBIT sense;
if(sense_int == 0)
@@ -5687,13 +5682,13 @@
else
sense = FORWARD;
- // Actually create the new EDGE
+ // Actually create the new EDGE
API_BEGIN;
new_EDGE = new EDGE ( from_VERTEX, to_VERTEX, geometry, sense );
API_END;
- //Delete the body and the sheet_body and the other body associated with
- //this other face...
+ //Delete the body and the sheet_body and the other body associated with
+ //this other face...
AcisQueryEngine::instance()->delete_ACIS_BODY(intersect_BODY, CUBIT_TRUE);
AcisQueryEngine::instance()->delete_ACIS_BODY(sheet_body, CUBIT_TRUE);
AcisQueryEngine::instance()->delete_ACIS_BODY(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_2), CUBIT_TRUE);
@@ -5713,34 +5708,34 @@
// Creation Date : 05/15/97
//-------------------------------------------------------------------------
EDGE* AcisModifyEngine::make_spline_EDGE( VERTEX* from_VERTEX,
- VERTEX* to_VERTEX,
- SPAposition* pos_array,
- int number_points ) const
+ VERTEX* to_VERTEX,
+ SPAposition* pos_array,
+ int number_points ) const
{
- // Create the spline curve and attach it to the EDGE
+ // Create the spline curve and attach it to the EDGE
EDGE* EDGE_ptr = NULL;
outcome result = api_curve_spline(number_points, pos_array, 0, 0, EDGE_ptr,
FALSE, from_VERTEX == to_VERTEX);
if (result.ok() == FALSE || EDGE_ptr == NULL)
- {
- PRINT_ERROR("In AcisModifyEngine::make_spline_EDGE\n"
- " ACIS function, api_mk_ed_cubic, failed\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return (EDGE *)NULL;
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_spline_EDGE\n"
+ " ACIS function, api_mk_ed_cubic, failed\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return (EDGE *)NULL;
+ }
else
- {
+ {
// Switch the end VERTEXes of the EDGE to the input VERTEXes. Keep
// in mind that the back links (from the VERTEX back to the EDGE)
// need to be modified as well.
- EDGE_ptr->set_start ( from_VERTEX );
- from_VERTEX->add_edge( EDGE_ptr );
+ EDGE_ptr->set_start ( from_VERTEX );
+ from_VERTEX->add_edge( EDGE_ptr );
- EDGE_ptr->set_end ( to_VERTEX );
- to_VERTEX->add_edge( EDGE_ptr );
+ EDGE_ptr->set_end ( to_VERTEX );
+ to_VERTEX->add_edge( EDGE_ptr );
- return EDGE_ptr;
- }
+ return EDGE_ptr;
+ }
}
//-------------------------------------------------------------------------
@@ -5761,26 +5756,26 @@
{
leftoverBody = 0;
- // chops the blank with the tool, returing the body formed by subtracting the tool from the blank,
- // and the body formed by intersecting the tool with the blank,
- // simultaneously.
+ // chops the blank with the tool, returing the body formed by subtracting the tool from the blank,
+ // and the body formed by intersecting the tool with the blank,
+ // simultaneously.
if (bodysms.size() <= 1)
- {
- PRINT_WARNING("There is only one volume in the list. Nothing modified\n");
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_WARNING("There is only one volume in the list. Nothing modified\n");
+ return CUBIT_FAILURE;
+ }
- // Create new acis bodies that are copies of the original acis bodies.
- // If something goes wrong in the choping, we can then delete our copies
- // and the originals are intact. If everything goes fine, we will delete
- // the originals at that time.
+ // Create new acis bodies that are copies of the original acis bodies.
+ // If something goes wrong in the choping, we can then delete our copies
+ // and the originals are intact. If everything goes fine, we will delete
+ // the originals at that time.
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
DLIList<BODY*> old_BODY_list;
DLIList<BodySM*> old_BodySM_list;
@@ -5792,56 +5787,56 @@
BODY *blank_BODY = this->copy_BODY(BODYPtr, delete_attribs);
if (blank_BODY == NULL)
- {
- return CUBIT_FAILURE; // Nothing to clean up at this point.
- }
+ {
+ return CUBIT_FAILURE; // Nothing to clean up at this point.
+ }
BODY* outside_BODY=NULL;
BODY* leftovers_BODY=NULL;
- // get the tool Body
+ // get the tool Body
BodySMPtr = bodysms.get_and_step();
BODYPtr = AcisQueryEngine::get_BODY(BodySMPtr);
BODY *tool_BODY = this->copy_BODY(BODYPtr, delete_attribs);
if (tool_BODY == NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
- return CUBIT_FAILURE;
- }
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
+ return CUBIT_FAILURE;
+ }
// Chop the blank_BODY using the tool_BODY.
// If this is successful, the result is blank_BODY and outside_BODY, leftovers_BODY
outcome result = api_boolean_chop_body(tool_BODY, blank_BODY, nonreg,outside_BODY, leftovers_BODY);
if (!result.ok() || blank_BODY == NULL ||
- tool_BODY == NULL || blank_BODY->lump() == NULL )
- {
+ tool_BODY == NULL || blank_BODY->lump() == NULL )
+ {
- if( !result.ok() )
- {
- PRINT_ERROR("In AcisModifyEngine::chop\n");
- AcisQueryEngine::instance()->ACIS_API_error(result, "chop Bodies");
- if (blank_BODY != NULL)
- AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
- if (tool_BODY != NULL)
- AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY, CUBIT_TRUE);
- }
+ if( !result.ok() )
+ {
+ PRINT_ERROR("In AcisModifyEngine::chop\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "chop Bodies");
+ if (blank_BODY != NULL)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
+ if (tool_BODY != NULL)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY, CUBIT_TRUE);
+ }
- if( blank_BODY->lump() == NULL )
- {
- PRINT_ERROR("Bodies do not intersect\n");
- if (blank_BODY != NULL)
- AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
- if (leftovers_BODY != NULL)
- AcisQueryEngine::instance()->delete_ACIS_BODY(leftovers_BODY, CUBIT_TRUE);
- if (outside_BODY != NULL)
- AcisQueryEngine::instance()->delete_ACIS_BODY(outside_BODY, CUBIT_TRUE);
- }
-
- return CUBIT_FAILURE;
+ if( blank_BODY->lump() == NULL )
+ {
+ PRINT_ERROR("Bodies do not intersect\n");
+ if (blank_BODY != NULL)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(blank_BODY, CUBIT_TRUE);
+ if (leftovers_BODY != NULL)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(leftovers_BODY, CUBIT_TRUE);
+ if (outside_BODY != NULL)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(outside_BODY, CUBIT_TRUE);
}
+ return CUBIT_FAILURE;
+ }
+
BodySM* intersectBody = get_new_Body(BodySMPtr, BODYPtr, blank_BODY, keep_old);
intersectBodies.append( intersectBody );
BodySM* outsideBody = get_new_Body(old_BodySM_list, old_BODY_list, outside_BODY, keep_old);
@@ -5873,60 +5868,60 @@
DLIList<SurfaceACIS*> copied_ref_face_list(ref_face_list.size());
CAST_LIST(ref_face_list, copied_ref_face_list, SurfaceACIS);
if (ref_face_list.size() != copied_ref_face_list.size())
- {
- PRINT_ERROR("Non-ACIS surface at %s:%d\n", __FILE__, __LINE__ );
- return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR("Non-ACIS surface at %s:%d\n", __FILE__, __LINE__ );
+ return CUBIT_FAILURE;
+ }
// Loop on FACEs. We will work on reversing surfaces from one body at a time.
copied_ref_face_list.reset();
while( copied_ref_face_list.size() )
- {
- BODY *copied_BODY_ptr;
+ {
+ BODY *copied_BODY_ptr;
#ifdef BOYD07
- DLIList<SurfaceACIS*> reverse_face_list;
+ DLIList<SurfaceACIS*> reverse_face_list;
#endif
- DLIList<FACE*> reverse_FACE_list;
- if( get_copied_FACES_of_body( copied_ref_face_list, reverse_FACE_list,
- copied_BODY_ptr ) == CUBIT_FAILURE )
- break;
+ DLIList<FACE*> reverse_FACE_list;
+ if( get_copied_FACES_of_body( copied_ref_face_list, reverse_FACE_list,
+ copied_BODY_ptr ) == CUBIT_FAILURE )
+ break;
- // Get original Body and BODY
- BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
- BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // Get original Body and BODY
+ BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
+ BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- // Now cleanout the owner attributes from the copied BODY, if required
- if( delete_attribs )
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
+ // Now cleanout the owner attributes from the copied BODY, if required
+ if( delete_attribs )
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
- reverse_FACE_list.reset();
- for( i=reverse_FACE_list.size(); i--; )
- {
- FACE *FACE_ptr = reverse_FACE_list.get_and_step();
- result = api_reverse_face( FACE_ptr );
+ reverse_FACE_list.reset();
+ for( i=reverse_FACE_list.size(); i--; )
+ {
+ FACE *FACE_ptr = reverse_FACE_list.get_and_step();
+ result = api_reverse_face( FACE_ptr );
- if (!result.ok())
- {
- //TODO: get ref_face from FACE
- //PRINT_INFO("Surface %d did not reverse\n", ref_face->id());
- PRINT_INFO("Surface did not reverse\n");
- return CUBIT_FAILURE;
- }
- }
+ if (!result.ok())
+ {
+ //TODO: get ref_face from FACE
+ //PRINT_INFO("Surface %d did not reverse\n", ref_face->id());
+ PRINT_INFO("Surface did not reverse\n");
+ return CUBIT_FAILURE;
+ }
+ }
- BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr, CUBIT_FALSE );
+ BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr, CUBIT_FALSE );
- if( new_body_ptr!=NULL && new_body_ptr!=body_ptr )
- {
- PRINT_INFO( "Created new volume\n" );
- }
- else if( new_body_ptr!=NULL && new_body_ptr==body_ptr )
- {
- PRINT_INFO( "Modified volume\n" );
- }
- else
- PRINT_WARNING( "Volume was not modified\n" );
+ if( new_body_ptr!=NULL && new_body_ptr!=body_ptr )
+ {
+ PRINT_INFO( "Created new volume\n" );
}
+ else if( new_body_ptr!=NULL && new_body_ptr==body_ptr )
+ {
+ PRINT_INFO( "Modified volume\n" );
+ }
+ else
+ PRINT_WARNING( "Volume was not modified\n" );
+ }
return CUBIT_SUCCESS;
}
@@ -6066,2006 +6061,2006 @@
PRINT_ERROR( "This function is not available in ACIS versions below 800\n" );
return CUBIT_FAILURE;
#else
- CubitStatus AcisModifyEngine::thicken( DLIList<BodySM*>& bodies,
- DLIList<BodySM*>& new_body_list,
- double depth,
- bool both) const
- {
- if (bodies.size() < 1)
- {
- PRINT_WARNING("There are no volumes in the list. Nothing modified\n");
- return CUBIT_FAILURE;
- }
+CubitStatus AcisModifyEngine::thicken( DLIList<BodySM*>& bodies,
+ DLIList<BodySM*>& new_body_list,
+ double depth,
+ bool both) const
+{
+ if (bodies.size() < 1)
+ {
+ PRINT_WARNING("There are no volumes in the list. Nothing modified\n");
+ return CUBIT_FAILURE;
+ }
- SPAposition box_l(0,0,0);
- SPAposition box_h(0,0,0);
+ SPAposition box_l(0,0,0);
+ SPAposition box_h(0,0,0);
- BODY* in_out_BODY;
- DLIList<BODY*> old_BODY_list;
- DLIList<BodySM*> old_Body_list;
+ BODY* in_out_BODY;
+ DLIList<BODY*> old_BODY_list;
+ DLIList<BodySM*> old_Body_list;
- for(int i = bodies.size(); i >= 1 ; i-- ){
+ for(int i = bodies.size(); i >= 1 ; i-- ){
- BodySM* BodyPtr = bodies.get_and_step();
- BodySM* new_bodysm;
- BodyACIS* acis_body = dynamic_cast<BodyACIS*>(BodyPtr);
- if (!acis_body)
- {
- PRINT_ERROR("Non-ACIS BodySM passed to AcisModifyEngine::thicken.\n");
- continue;
- }
+ BodySM* BodyPtr = bodies.get_and_step();
+ BodySM* new_bodysm;
+ BodyACIS* acis_body = dynamic_cast<BodyACIS*>(BodyPtr);
+ if (!acis_body)
+ {
+ PRINT_ERROR("Non-ACIS BodySM passed to AcisModifyEngine::thicken.\n");
+ continue;
+ }
- BODY* BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
+ BODY* BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
- in_out_BODY = this->copy_BODY(BODYPtr, CUBIT_FALSE);
+ in_out_BODY = this->copy_BODY(BODYPtr, CUBIT_FALSE);
- if (in_out_BODY == NULL)
- {
- return CUBIT_FAILURE; // Nothing to clean up at this point.
- }
+ if (in_out_BODY == NULL)
+ {
+ return CUBIT_FAILURE; // Nothing to clean up at this point.
+ }
- if( !acis_body->is_sheet_body() )
- {
- PRINT_WARNING("Only surface volumes should be thickened\n"
- " results may be different than expected\n");
- }
+ if( !acis_body->is_sheet_body() )
+ {
+ PRINT_WARNING("Only surface volumes should be thickened\n"
+ " results may be different than expected\n");
+ }
- outcome result = api_sheet_thicken(in_out_BODY, depth, both, box_l, box_h);
+ outcome result = api_sheet_thicken(in_out_BODY, depth, both, box_l, box_h);
- if (!result.ok())//
- {
- if(result.error_number() == 41000) // checking surface normals
- {
- PRINT_ERROR("In AcisModifyEngine::thicken\n"
- " Surface normals may not be consistent\n"
- " use: validate normal reverse\n");
- return CUBIT_FAILURE;
- }
+ if (!result.ok())//
+ {
+ if(result.error_number() == 41000) // checking surface normals
+ {
+ PRINT_ERROR("In AcisModifyEngine::thicken\n"
+ " Surface normals may not be consistent\n"
+ " use: validate normal reverse\n");
+ return CUBIT_FAILURE;
+ }
- PRINT_ERROR("In AcisModifyEngine::thicken \n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
-
- new_bodysm = get_new_Body(BodyPtr, BODYPtr, in_out_BODY, CUBIT_FALSE);
- if (new_bodysm)
- new_body_list.append(new_bodysm);
+ PRINT_ERROR("In AcisModifyEngine::thicken \n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
}
- return CUBIT_SUCCESS;
+
+ new_bodysm = get_new_Body(BodyPtr, BODYPtr, in_out_BODY, CUBIT_FALSE);
+ if (new_bodysm)
+ new_body_list.append(new_bodysm);
+ }
+ return CUBIT_SUCCESS;
#endif
- }
+}
- //-------------------------------------------------------------------------
- // Purpose : Boolean Operation of a list of Bodies: unite
- //
- // Special Notes :
- //
- // Creator : Malcolm J. Panthaki
- //
- // Creation Date : 10/31/96
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::unite(DLIList<BodySM*> &bodies,
- DLIList<BodySM*> &newBodies,
+//-------------------------------------------------------------------------
+// Purpose : Boolean Operation of a list of Bodies: unite
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 10/31/96
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::unite(DLIList<BodySM*> &bodies,
+ DLIList<BodySM*> &newBodies,
bool keep_old) const
- {
- // Union all bodies in the bodies list into a single body.
- if (bodies.size() <= 1)
- {
- PRINT_WARNING("There is only one volume in the list. Nothing modified\n");
- return CUBIT_FAILURE;
- }
+{
+ // Union all bodies in the bodies list into a single body.
+ if (bodies.size() <= 1)
+ {
+ PRINT_WARNING("There is only one volume in the list. Nothing modified\n");
+ return CUBIT_FAILURE;
+ }
- // Create new acis bodies that are copies of the original acis bodies.
- // If something goes wrong in the unioning, we can then delete our copies
- // and the originals are intact. If everything goes fine, we will delete
- // the originals at that time.
+ // Create new acis bodies that are copies of the original acis bodies.
+ // If something goes wrong in the unioning, we can then delete our copies
+ // and the originals are intact. If everything goes fine, we will delete
+ // the originals at that time.
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
- // check if the boolean operation is regularized or nonregularized
- BOOL_TYPE bool_type = UNION;
- CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
+ // check if the boolean operation is regularized or nonregularized
+ BOOL_TYPE bool_type = UNION;
+ CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
- if (boolean_regularize == FALSE)
+ if (boolean_regularize == FALSE)
{
- bool_type = NONREG_UNION;
+ bool_type = NONREG_UNION;
}
- DLIList<BODY*> old_BODY_list;
- DLIList<BodySM*> old_Body_list;
+ DLIList<BODY*> old_BODY_list;
+ DLIList<BodySM*> old_Body_list;
- BodySM* BodyPtr = bodies.get_and_step();
- BODY* BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
- old_Body_list.append(BodyPtr);
- old_BODY_list.append(BODYPtr);
+ BodySM* BodyPtr = bodies.get_and_step();
+ BODY* BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
+ old_Body_list.append(BodyPtr);
+ old_BODY_list.append(BODYPtr);
- BODY *master = this->copy_BODY(BODYPtr, delete_attribs);
- if (master == NULL)
- {
- return CUBIT_FAILURE; // Nothing to clean up at this point.
- }
+ BODY *master = this->copy_BODY(BODYPtr, delete_attribs);
+ if (master == NULL)
+ {
+ return CUBIT_FAILURE; // Nothing to clean up at this point.
+ }
- // Note: one iteration less because we already pulled out one body above
- for (int i = 1; i < bodies.size(); i++)
- {
- BodyPtr = bodies.get_and_step();
- BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
+ // Note: one iteration less because we already pulled out one body above
+ for (int i = 1; i < bodies.size(); i++)
+ {
+ BodyPtr = bodies.get_and_step();
+ BODYPtr = AcisQueryEngine::get_BODY(BodyPtr);
- BODY *copy = this->copy_BODY(BODYPtr, delete_attribs);
- if (copy == NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(master, CUBIT_TRUE);
- return CUBIT_FAILURE;
- }
+ BODY *copy = this->copy_BODY(BODYPtr, delete_attribs);
+ if (copy == NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(master, CUBIT_TRUE);
+ return CUBIT_FAILURE;
+ }
- // Do the union of the master and the copy.
- // If this is successful, the result is master and copy will be deleted
- // outcome result = api_unite(copy, master);
- // replaced with the api_boolean call in order to do nonregularize boolean operation
+ // Do the union of the master and the copy.
+ // If this is successful, the result is master and copy will be deleted
+ // outcome result = api_unite(copy, master);
+ // replaced with the api_boolean call in order to do nonregularize boolean operation
- outcome result = api_boolean (copy,master,bool_type);
+ outcome result = api_boolean (copy,master,bool_type);
- if (!result.ok() || (master && master->lump() == NULL))
- {
- // If there are no LUMPs in the resulting BODY, return with a failure
- if (master && master->lump() == NULL)
- PRINT_ERROR("Unite produced volume with no volume - "
- "check for (and remove) co-incident surfaces\n");
- else
- PRINT_ERROR("In AcisModifyEngine::unite\n");
+ if (!result.ok() || (master && master->lump() == NULL))
+ {
+ // If there are no LUMPs in the resulting BODY, return with a failure
+ if (master && master->lump() == NULL)
+ PRINT_ERROR("Unite produced volume with no volume - "
+ "check for (and remove) co-incident surfaces\n");
+ else
+ PRINT_ERROR("In AcisModifyEngine::unite\n");
- AcisQueryEngine::instance()->ACIS_API_error(result, "unite Bodies");
- if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master, CUBIT_TRUE);
- if (copy != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(copy, CUBIT_TRUE);
+ AcisQueryEngine::instance()->ACIS_API_error(result, "unite Bodies");
+ if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master, CUBIT_TRUE);
+ if (copy != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(copy, CUBIT_TRUE);
- return CUBIT_FAILURE;
- }
- else {
- old_Body_list.append(BodyPtr);
- old_BODY_list.append(BODYPtr);
- }
+ return CUBIT_FAILURE;
+ }
+ else {
+ old_Body_list.append(BodyPtr);
+ old_BODY_list.append(BODYPtr);
+ }
- //For nonregularized boolean, find all internal surfaces and delete
+ //For nonregularized boolean, find all internal surfaces and delete
- if ( bool_type == NONREG_UNION)
- {
- outcome result1;
- // ENTITY_LIST FACES;
- DLIList<FACE*> FACE_list ;
- FACE *this_FACE;
- AcisQueryEngine::instance()->get_FACEs(master,FACE_list);
- // loop through all faces
- for( int i = 0; i< FACE_list.size(); i++)
- {
- this_FACE = FACE_list.get_and_step();
- assert( this_FACE != NULL );
- // Make sure this is a DOUBLE_SIDED FACE
- if (this_FACE->sides() == DOUBLE_SIDED)
- {
- if (this_FACE->cont()==BOTH_INSIDE)
- {
- // found internal faces
- // Now we have the FACE - unhook it from the BODY. Keep track of new
- // BODIES that are created as this is done.
- PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
- BODY *new_BODY_ptr;
- result1 = api_unhook_face( this_FACE, new_BODY_ptr );
- if( !result1.ok() )
- {
- AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
- PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
- return CUBIT_FAILURE;
- }
- AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
- }
- }
- }
+ if ( bool_type == NONREG_UNION)
+ {
+ outcome result1;
+ // ENTITY_LIST FACES;
+ DLIList<FACE*> FACE_list ;
+ FACE *this_FACE;
+ AcisQueryEngine::instance()->get_FACEs(master,FACE_list);
+ // loop through all faces
+ for( int i = 0; i< FACE_list.size(); i++)
+ {
+ this_FACE = FACE_list.get_and_step();
+ assert( this_FACE != NULL );
+ // Make sure this is a DOUBLE_SIDED FACE
+ if (this_FACE->sides() == DOUBLE_SIDED)
+ {
+ if (this_FACE->cont()==BOTH_INSIDE)
+ {
+ // found internal faces
+ // Now we have the FACE - unhook it from the BODY. Keep track of new
+ // BODIES that are created as this is done.
+ PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
+ BODY *new_BODY_ptr;
+ result1 = api_unhook_face( this_FACE, new_BODY_ptr );
+ if( !result1.ok() )
+ {
+ AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
+ PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
+ return CUBIT_FAILURE;
+ }
+ AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
+ }
+ }
+ }
- // heal the leftover body
- //
- // PRINT_INFO(" Healing the leftover volume...\n");
- // if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
- // {
- // int percent_before, percent_after, number_splines_simplified;
- // if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
- // percent_after, number_splines_simplified ) == CUBIT_FAILURE )
- // PRINT_ERROR( "Error healing the combined volume\n" );
- // else
- // PRINT_INFO( "Successfully healed the combined volume!\n" );
- // AcisHealerTool::instance()->end_BODY_for_healing( master );
- // }
- }
-
+ // heal the leftover body
+//
+// PRINT_INFO(" Healing the leftover volume...\n");
+// if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
+// {
+// int percent_before, percent_after, number_splines_simplified;
+// if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
+// percent_after, number_splines_simplified ) == CUBIT_FAILURE )
+// PRINT_ERROR( "Error healing the combined volume\n" );
+// else
+// PRINT_INFO( "Successfully healed the combined volume!\n" );
+// AcisHealerTool::instance()->end_BODY_for_healing( master );
+// }
}
- AcisQueryEngine::instance()->clear_bounding_box( master );
- AcisQueryEngine::instance()->bounding_box( master );
+ }
- BodySM *newBodyPtr = get_new_Body(old_Body_list, old_BODY_list, master, keep_old);
- newBodies.append( newBodyPtr );
+ AcisQueryEngine::instance()->clear_bounding_box( master );
+ AcisQueryEngine::instance()->bounding_box( master );
- return CUBIT_SUCCESS;
- }
+ BodySM *newBodyPtr = get_new_Body(old_Body_list, old_BODY_list, master, keep_old);
+ newBodies.append( newBodyPtr );
- CubitStatus AcisModifyEngine::subtract( DLIList<BodySM*> &tool_body_list,
- DLIList<BodySM*> &from_bodies,
- DLIList<BodySM*> &new_from_bodies,
- bool imprint,
- bool keep_old) const
- {
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ return CUBIT_SUCCESS;
+}
- // check if the boolean operation is regularized or nonregularized
- BOOL_TYPE bool_type = SUBTRACTION;
- CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
+CubitStatus AcisModifyEngine::subtract( DLIList<BodySM*> &tool_body_list,
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_from_bodies,
+ bool imprint,
+ bool keep_old) const
+{
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
- if (boolean_regularize == FALSE)
+ // check if the boolean operation is regularized or nonregularized
+ BOOL_TYPE bool_type = SUBTRACTION;
+ CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
+
+ if (boolean_regularize == FALSE)
{
- bool_type = NONREG_SUBTRACTION;
+ bool_type = NONREG_SUBTRACTION;
}
- int ii;
- DLIList<CubitBox*> tool_boxes;
+ int ii;
+ DLIList<CubitBox*> tool_boxes;
- CubitBox tool_box;
+ CubitBox tool_box;
- DLIList<BODY*> tool_BODY_list;
- DLIList<BODY*> tool_BODY_list_copy;
+ DLIList<BODY*> tool_BODY_list;
+ DLIList<BODY*> tool_BODY_list_copy;
- // get acis bodies, and copy them
- tool_body_list.reset();
+ // get acis bodies, and copy them
+ tool_body_list.reset();
- for (ii = tool_body_list.size(); ii > 0; ii--) {
- CubitBox *temp_box = new CubitBox(
- AcisQueryEngine::instance()->bounding_box(tool_body_list.get()));
- tool_boxes.append(temp_box);
+ for (ii = tool_body_list.size(); ii > 0; ii--) {
+ CubitBox *temp_box = new CubitBox(
+ AcisQueryEngine::instance()->bounding_box(tool_body_list.get()));
+ tool_boxes.append(temp_box);
- BODY *BODYPtr1 = AcisQueryEngine::get_BODY(tool_body_list.get_and_step());
- tool_BODY_list.append(BODYPtr1);
+ BODY *BODYPtr1 = AcisQueryEngine::get_BODY(tool_body_list.get_and_step());
+ tool_BODY_list.append(BODYPtr1);
- BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
- tool_BODY_list_copy.append(BODYPtr1);
- }
+ BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
+ tool_BODY_list_copy.append(BODYPtr1);
+ }
- if (tool_BODY_list.size() != tool_body_list.size())
- {
- for(ii = tool_boxes.size(); ii>0; ii--)
- delete tool_boxes.get_and_step();
- return CUBIT_FAILURE;
- }
+ if (tool_BODY_list.size() != tool_body_list.size())
+ {
+ for(ii = tool_boxes.size(); ii>0; ii--)
+ delete tool_boxes.get_and_step();
+ return CUBIT_FAILURE;
+ }
- DLIList<BODY*> from_BODY_list;
- DLIList<BODY*> from_BODY_list_copy;
+ DLIList<BODY*> from_BODY_list;
+ DLIList<BODY*> from_BODY_list_copy;
- // get acis bodies, and copy them
- from_bodies.reset();
+ // get acis bodies, and copy them
+ from_bodies.reset();
- for (ii = from_bodies.size(); ii > 0; ii--) {
- BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_bodies.get_and_step());
- from_BODY_list.append(BODYPtr1);
+ for (ii = from_bodies.size(); ii > 0; ii--) {
+ BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_bodies.get_and_step());
+ from_BODY_list.append(BODYPtr1);
- BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
- from_BODY_list_copy.append(BODYPtr1);
- }
+ BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
+ from_BODY_list_copy.append(BODYPtr1);
+ }
- if (from_BODY_list.size() != from_bodies.size())
- {
- for(ii = tool_boxes.size(); ii>0; ii--)
- delete tool_boxes.get_and_step();
- return CUBIT_FAILURE;
- }
+ if (from_BODY_list.size() != from_bodies.size())
+ {
+ for(ii = tool_boxes.size(); ii>0; ii--)
+ delete tool_boxes.get_and_step();
+ return CUBIT_FAILURE;
+ }
- // now, subtract the tool from the list of bodies
- tool_BODY_list.reset();
- tool_BODY_list_copy.reset();
- tool_body_list.reset();
- tool_boxes.reset();
+ // now, subtract the tool from the list of bodies
+ tool_BODY_list.reset();
+ tool_BODY_list_copy.reset();
+ tool_body_list.reset();
+ tool_boxes.reset();
- from_BODY_list.reset();
- from_BODY_list_copy.reset();
- from_bodies.reset();
+ from_BODY_list.reset();
+ from_BODY_list_copy.reset();
+ from_bodies.reset();
- int fraction_remaining = 10;
- CubitStatus sub_stat = CUBIT_SUCCESS;
+ int fraction_remaining = 10;
+ CubitStatus sub_stat = CUBIT_SUCCESS;
- // subtract the tool body from each body in the list
- CubitMessage* cmi = CubitMessage::instance();
- for (ii = 1; ii <= from_BODY_list.size(); ii++)
- {
- BODY *from_BODY = from_BODY_list.get();
- BODY *from_BODY_copy = from_BODY_list_copy.get();
- BodySM *from_Body = from_bodies.get();
- CubitBox box1 = AcisQueryEngine::instance()->bounding_box(from_Body);
+ // subtract the tool body from each body in the list
+ CubitMessage* cmi = CubitMessage::instance();
+ for (ii = 1; ii <= from_BODY_list.size(); ii++)
+ {
+ BODY *from_BODY = from_BODY_list.get();
+ BODY *from_BODY_copy = from_BODY_list_copy.get();
+ BodySM *from_Body = from_bodies.get();
+ CubitBox box1 = AcisQueryEngine::instance()->bounding_box(from_Body);
- for(int jj = tool_BODY_list.size(); jj>0; jj--)
- {
- if (cmi->Interrupt())
- {
- PRINT_ERROR("Subtraction interrupted. Aborting...\n");
- while (tool_boxes.size())
- delete tool_boxes.pop();
- while (tool_BODY_list_copy.size())
- AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_list_copy.pop(),CUBIT_TRUE);
- while (from_BODY_list_copy.size())
- AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_list_copy.pop(),CUBIT_TRUE);
- return CUBIT_FAILURE;
- }
+ for(int jj = tool_BODY_list.size(); jj>0; jj--)
+ {
+ if (cmi->Interrupt())
+ {
+ PRINT_ERROR("Subtraction interrupted. Aborting...\n");
+ while (tool_boxes.size())
+ delete tool_boxes.pop();
+ while (tool_BODY_list_copy.size())
+ AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_list_copy.pop(),CUBIT_TRUE);
+ while (from_BODY_list_copy.size())
+ AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_list_copy.pop(),CUBIT_TRUE);
+ return CUBIT_FAILURE;
+ }
- tool_box = *tool_boxes.get();
- BODY* tool_BODY = tool_BODY_list.get();
- BODY *tool_BODY_copy = tool_BODY_list_copy.get();
+ tool_box = *tool_boxes.get();
+ BODY* tool_BODY = tool_BODY_list.get();
+ BODY *tool_BODY_copy = tool_BODY_list_copy.get();
- // first, check bounding SPAbox; if they don't intersect, don't do the subtract
- if ( tool_box.overlap( SPAresabs, box1 ) )
- {
- // the bodies overlap; proceed with the subtract
+ // first, check bounding SPAbox; if they don't intersect, don't do the subtract
+ if ( tool_box.overlap( SPAresabs, box1 ) )
+ {
+ // the bodies overlap; proceed with the subtract
- // Subtract body1 from body2.
- // outcome result = api_subtract( tool_BODY_copy, from_BODY_copy );
- outcome result = api_boolean( tool_BODY_copy, from_BODY_copy, bool_type );
- // We may or may not get an error if the resulting BODY is
- // empty (body1 totally encloses body2).
- // Also check the result.
- if (from_BODY_copy == NULL ||
- (from_BODY_copy->lump() == NULL && from_BODY_copy->wire() == NULL) ||
- !result.ok())
- {
- if (!result.ok())
- {
- PRINT_ERROR("Subtraction operation failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result, "subtract Bodies");
- if (tool_BODY_copy != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_copy, CUBIT_TRUE);
- }
- }
- else
- PRINT_ERROR("Subtraction operation failed.\n"
- " Empty volume created. Original volume is probably\n"
- " completely enclosed by the subtracting volume.\n");
- if (from_BODY_copy != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
- }
+ // Subtract body1 from body2.
+ // outcome result = api_subtract( tool_BODY_copy, from_BODY_copy );
+ outcome result = api_boolean( tool_BODY_copy, from_BODY_copy, bool_type );
+ // We may or may not get an error if the resulting BODY is
+ // empty (body1 totally encloses body2).
+ // Also check the result.
+ if (from_BODY_copy == NULL ||
+ (from_BODY_copy->lump() == NULL && from_BODY_copy->wire() == NULL) ||
+ !result.ok())
+ {
+ if (!result.ok())
+ {
+ PRINT_ERROR("Subtraction operation failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "subtract Bodies");
+ if (tool_BODY_copy != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_copy, CUBIT_TRUE);
+ }
+ }
+ else
+ PRINT_ERROR("Subtraction operation failed.\n"
+ " Empty volume created. Original volume is probably\n"
+ " completely enclosed by the subtracting volume.\n");
+ if (from_BODY_copy != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
+ }
- // we had an error, so copy the original body into the copy list
- from_BODY_copy = this->copy_BODY(from_BODY);
- from_BODY_list_copy.change_to(from_BODY_copy);
- tool_BODY_copy = this->copy_BODY(tool_BODY);
- tool_BODY_list_copy.change_to(tool_BODY_copy);
- sub_stat = CUBIT_FAILURE;
- }
- else
- {
- // else subtract was successful; make another tool body
- tool_BODY_copy = this->copy_BODY(tool_BODY);
- if( imprint )
- imprint_BODYs( tool_BODY_copy, from_BODY_copy );
- tool_BODY_list_copy.change_to(tool_BODY_copy);
- }
+ // we had an error, so copy the original body into the copy list
+ from_BODY_copy = this->copy_BODY(from_BODY);
+ from_BODY_list_copy.change_to(from_BODY_copy);
+ tool_BODY_copy = this->copy_BODY(tool_BODY);
+ tool_BODY_list_copy.change_to(tool_BODY_copy);
+ sub_stat = CUBIT_FAILURE;
+ }
+ else
+ {
+ // else subtract was successful; make another tool body
+ tool_BODY_copy = this->copy_BODY(tool_BODY);
+ if( imprint )
+ imprint_BODYs( tool_BODY_copy, from_BODY_copy );
+ tool_BODY_list_copy.change_to(tool_BODY_copy);
+ }
- //For nonregularized boolean, find all internal surfaces and delete
+ //For nonregularized boolean, find all internal surfaces and delete
- if ( bool_type == NONREG_SUBTRACTION)
- {
- outcome result1;
- // ENTITY_LIST FACES;
- DLIList<FACE*> FACE_list ;
- FACE *this_FACE;
- AcisQueryEngine::instance()->get_FACEs(from_BODY_copy,FACE_list);
- // loop through all faces
- for( int i = 0; i< FACE_list.size(); i++)
- {
+ if ( bool_type == NONREG_SUBTRACTION)
+ {
+ outcome result1;
+ // ENTITY_LIST FACES;
+ DLIList<FACE*> FACE_list ;
+ FACE *this_FACE;
+ AcisQueryEngine::instance()->get_FACEs(from_BODY_copy,FACE_list);
+ // loop through all faces
+ for( int i = 0; i< FACE_list.size(); i++)
+ {
this_FACE = FACE_list.get_and_step();
assert( this_FACE != NULL );
// Make sure this is a DOUBLE_SIDED FACE
if (this_FACE->sides() == DOUBLE_SIDED)
- {
- if (this_FACE->cont()==BOTH_INSIDE)
- {
- // found internal faces
- // Now we have the FACE - unhook it from the BODY. Keep track of new
- // BODIES that are created as this is done.
- PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
- BODY *new_BODY_ptr;
- result1 = api_unhook_face( this_FACE, new_BODY_ptr );
- if( !result1.ok() )
- {
- AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
- PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
- return CUBIT_FAILURE;
- }
- AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
- }
- }
- }
+ {
+ if (this_FACE->cont()==BOTH_INSIDE)
+ {
+ // found internal faces
+ // Now we have the FACE - unhook it from the BODY. Keep track of new
+ // BODIES that are created as this is done.
+ PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
+ BODY *new_BODY_ptr;
+ result1 = api_unhook_face( this_FACE, new_BODY_ptr );
+ if( !result1.ok() )
+ {
+ AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
+ PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
+ return CUBIT_FAILURE;
+ }
+ AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
+ }
+ }
+ }
- // heal the leftover body
- //
- // PRINT_INFO(" Healing the leftover volume...\n");
- // if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
- // {
- // int percent_before, percent_after, number_splines_simplified;
- // if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
- // percent_after, number_splines_simplified ) == CUBIT_FAILURE )
- // PRINT_ERROR( "Error healing the combined volume\n" );
- // else
- // PRINT_INFO( "Successfully healed the combined volume.\n" );
- // AcisHealerTool::instance()->end_BODY_for_healing( master );
- // }
- }
-
- // done with this j iteration; write out count, if necessary
- if (from_bodies.size() * tool_body_list.size() > 1)
- {
- int frac_done = (10 * ii) / (from_bodies.size()* tool_body_list.size());
- if ((10 - frac_done) < fraction_remaining)
- {
- PRINT_INFO("%d ", fraction_remaining);
- fraction_remaining--;
- }
- }
- }
- tool_boxes.step();
- tool_BODY_list.step();
- tool_BODY_list_copy.step();
-
- }
-
- // done with iteration over ii; step the lists
- from_BODY_list_copy.step();
- from_BODY_list.step();
- from_bodies.step();
+ // heal the leftover body
+//
+// PRINT_INFO(" Healing the leftover volume...\n");
+// if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
+// {
+// int percent_before, percent_after, number_splines_simplified;
+// if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
+// percent_after, number_splines_simplified ) == CUBIT_FAILURE )
+// PRINT_ERROR( "Error healing the combined volume\n" );
+// else
+// PRINT_INFO( "Successfully healed the combined volume.\n" );
+// AcisHealerTool::instance()->end_BODY_for_healing( master );
+// }
}
- // ok, we're done with all the imprints; construct new Body's for the new BODY's
- from_BODY_list_copy.reset();
- from_BODY_list.reset();
- from_bodies.reset();
+ // done with this j iteration; write out count, if necessary
+ if (from_bodies.size() * tool_body_list.size() > 1)
+ {
+ int frac_done = (10 * ii) / (from_bodies.size()* tool_body_list.size());
+ if ((10 - frac_done) < fraction_remaining)
+ {
+ PRINT_INFO("%d ", fraction_remaining);
+ fraction_remaining--;
+ }
+ }
+ }
+ tool_boxes.step();
+ tool_BODY_list.step();
+ tool_BODY_list_copy.step();
- for (ii = 0; ii< from_BODY_list_copy.size(); ii++)
- {
- BODY *old_BODY = from_BODY_list.get();
- BODY *new_BODY = from_BODY_list_copy.get();
+ }
- BodySM *new_body = NULL;
- if (old_BODY != new_BODY)
- new_body = get_new_Body(from_bodies.get(), old_BODY, new_BODY, keep_old);
+ // done with iteration over ii; step the lists
+ from_BODY_list_copy.step();
+ from_BODY_list.step();
+ from_bodies.step();
+ }
- if (new_body)
- {
- new_from_bodies.append(new_body);
- from_bodies.change_to(NULL);
- }
+ // ok, we're done with all the imprints; construct new Body's for the new BODY's
+ from_BODY_list_copy.reset();
+ from_BODY_list.reset();
+ from_bodies.reset();
- // now step all the lists
- from_BODY_list.step();
- from_BODY_list_copy.step();
- from_bodies.step();
- }
+ for (ii = 0; ii< from_BODY_list_copy.size(); ii++)
+ {
+ BODY *old_BODY = from_BODY_list.get();
+ BODY *new_BODY = from_BODY_list_copy.get();
- from_bodies.remove_all_with_value(NULL);
- from_bodies.reset();
- new_from_bodies.reset();
+ BodySM *new_body = NULL;
+ if (old_BODY != new_BODY)
+ new_body = get_new_Body(from_bodies.get(), old_BODY, new_BODY, keep_old);
- for(ii = tool_BODY_list_copy.size(); ii>0; ii--)
- AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_list_copy.get_and_step(), CUBIT_TRUE);
+ if (new_body)
+ {
+ new_from_bodies.append(new_body);
+ from_bodies.change_to(NULL);
+ }
- if (sub_stat == CUBIT_SUCCESS && !keep_old)
- AcisQueryEngine::instance()->delete_solid_model_entities(tool_body_list);
+ // now step all the lists
+ from_BODY_list.step();
+ from_BODY_list_copy.step();
+ from_bodies.step();
+ }
- for(ii = tool_boxes.size(); ii>0; ii--)
- delete tool_boxes.get_and_step();
+ from_bodies.remove_all_with_value(NULL);
+ from_bodies.reset();
+ new_from_bodies.reset();
- return CUBIT_SUCCESS;
- }
+ for(ii = tool_BODY_list_copy.size(); ii>0; ii--)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_list_copy.get_and_step(), CUBIT_TRUE);
- //-------------------------------------------------------------------------
- // Purpose : Boolean Operation of two Bodys: imprint
- //
- // Special Notes :
- //
- // Creator : Malcolm J. Panthaki
- //
- // Creation Date : 10/30/96
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::imprint(BodySM* BodyPtr1,
- BodySM* BodyPtr2,
- BodySM*& newBodyPtr1,
- BodySM*& newBodyPtr2,
- bool keep_old) const
- {
- // There are two many places things can go wrong. When they do, in
- // addition to returning a CUBIT_FAILURE, we should return some sensible
- // values through the output arguments. Before any of the output Body's can
- // be created, the most sensible for these is NULL.
- newBodyPtr1 = NULL ;
- newBodyPtr2 = NULL ;
+ if (sub_stat == CUBIT_SUCCESS && !keep_old)
+ AcisQueryEngine::instance()->delete_solid_model_entities(tool_body_list);
- // first, check bounding SPAbox; if they don't intersect, imprint will fail
- AcisQueryEngine* aqe = AcisQueryEngine::instance();
- BODY* BODYPtr1 = aqe->get_BODY(BodyPtr1);
- BODY* BODYPtr2 = aqe->get_BODY(BodyPtr2);
+ for(ii = tool_boxes.size(); ii>0; ii--)
+ delete tool_boxes.get_and_step();
- if( (BODYPtr1 == NULL) || (BODYPtr2 == NULL) )
- {
- return CUBIT_FAILURE;
- }
+ return CUBIT_SUCCESS;
+}
- CubitBox box1 = aqe->bounding_box(aqe->bounding_box(BODYPtr1));
- CubitBox box2 = aqe->bounding_box(aqe->bounding_box(BODYPtr2));
- if (! box1.overlap(SPAresabs, box2))
- return CUBIT_FAILURE;
+//-------------------------------------------------------------------------
+// Purpose : Boolean Operation of two Bodys: imprint
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 10/30/96
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::imprint(BodySM* BodyPtr1,
+ BodySM* BodyPtr2,
+ BodySM*& newBodyPtr1,
+ BodySM*& newBodyPtr2,
+ bool keep_old) const
+{
+ // There are two many places things can go wrong. When they do, in
+ // addition to returning a CUBIT_FAILURE, we should return some sensible
+ // values through the output arguments. Before any of the output Body's can
+ // be created, the most sensible for these is NULL.
+ newBodyPtr1 = NULL ;
+ newBodyPtr2 = NULL ;
- // Make copies of the ACIS bodies. This is required because if the ultimate
- // result is a body with no LUMPs, then we need to be able to restore
- // the original BODY's and their Bodies.
- BODY* BODYPtr1Save;
- BODY* BODYPtr2Save;
+ // first, check bounding SPAbox; if they don't intersect, imprint will fail
+ AcisQueryEngine* aqe = AcisQueryEngine::instance();
+ BODY* BODYPtr1 = aqe->get_BODY(BodyPtr1);
+ BODY* BODYPtr2 = aqe->get_BODY(BodyPtr2);
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
- BODYPtr1Save = this->copy_BODY(BODYPtr1, delete_attribs);
- if (BODYPtr1Save == NULL)
- {
- PRINT_ERROR("Copy of volume failed.\n Imprint failed.\n");
- return CUBIT_FAILURE;
- }
- BODYPtr2Save = this->copy_BODY(BODYPtr2, delete_attribs);
- if (BODYPtr2Save == NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- PRINT_ERROR("Copy of volume failed.\n Imprint failed.\n");
- return CUBIT_FAILURE;
- }
+ if( (BODYPtr1 == NULL) || (BODYPtr2 == NULL) )
+ {
+ return CUBIT_FAILURE;
+ }
- // Keep track of the number of curves/surfaces/vertices in each body. That
- // way we can tell if they really changed.
- int num_vol1_bef, num_face1_bef, num_edge1_bef, num_vertex1_bef;
- if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr1Save, num_vol1_bef, num_face1_bef, num_edge1_bef,
- num_vertex1_bef ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to count number of entities in volume\n" );
- return CUBIT_FAILURE;
- }
- int num_vol2_bef, num_face2_bef, num_edge2_bef, num_vertex2_bef;
- if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr2Save, num_vol2_bef, num_face2_bef, num_edge2_bef,
- num_vertex2_bef ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to count number of entities in volume\n" );
- return CUBIT_FAILURE;
- }
+ CubitBox box1 = aqe->bounding_box(aqe->bounding_box(BODYPtr1));
+ CubitBox box2 = aqe->bounding_box(aqe->bounding_box(BODYPtr2));
+ if (! box1.overlap(SPAresabs, box2))
+ return CUBIT_FAILURE;
- // Now, imprint the 2 BODYs
- if ( GeometryModifyTool::get_all_edges_imprint() )
- {
- api_set_int_option("all_free_edges", TRUE );
- }
+ // Make copies of the ACIS bodies. This is required because if the ultimate
+ // result is a body with no LUMPs, then we need to be able to restore
+ // the original BODY's and their Bodies.
+ BODY* BODYPtr1Save;
+ BODY* BODYPtr2Save;
- outcome result = api_imprint( BODYPtr1Save, BODYPtr2Save );
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ BODYPtr1Save = this->copy_BODY(BODYPtr1, delete_attribs);
+ if (BODYPtr1Save == NULL)
+ {
+ PRINT_ERROR("Copy of volume failed.\n Imprint failed.\n");
+ return CUBIT_FAILURE;
+ }
+ BODYPtr2Save = this->copy_BODY(BODYPtr2, delete_attribs);
+ if (BODYPtr2Save == NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ PRINT_ERROR("Copy of volume failed.\n Imprint failed.\n");
+ return CUBIT_FAILURE;
+ }
- //Gets rid of sliver curves/surfaces that could get produced by the imprint.
- AcisModifyEngine::instance()->cleanup_slivers( BODYPtr1Save );
- AcisModifyEngine::instance()->cleanup_slivers( BODYPtr2Save );
+ // Keep track of the number of curves/surfaces/vertices in each body. That
+ // way we can tell if they really changed.
+ int num_vol1_bef, num_face1_bef, num_edge1_bef, num_vertex1_bef;
+ if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr1Save, num_vol1_bef, num_face1_bef, num_edge1_bef,
+ num_vertex1_bef ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to count number of entities in volume\n" );
+ return CUBIT_FAILURE;
+ }
+ int num_vol2_bef, num_face2_bef, num_edge2_bef, num_vertex2_bef;
+ if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr2Save, num_vol2_bef, num_face2_bef, num_edge2_bef,
+ num_vertex2_bef ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to count number of entities in volume\n" );
+ return CUBIT_FAILURE;
+ }
- if ( GeometryModifyTool::get_all_edges_imprint() )
- {
- api_set_int_option("all_free_edges", FALSE );
- }
+ // Now, imprint the 2 BODYs
+ if ( GeometryModifyTool::get_all_edges_imprint() )
+ {
+ api_set_int_option("all_free_edges", TRUE );
+ }
- if (!result.ok())
- {
- // might just be no overlap, check smaller boxes
- if (!BODYPtr1Save || !BODYPtr2Save ||
- box1.overlap(SPAresabs,box2) == CUBIT_TRUE)
- {
- if (DEBUG_FLAG(95))
- {
- AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
- }
+ outcome result = api_imprint( BODYPtr1Save, BODYPtr2Save );
- if (BODYPtr1Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- }
- if (BODYPtr2Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
- return CUBIT_FAILURE;
- }
- }
+ //Gets rid of sliver curves/surfaces that could get produced by the imprint.
+ AcisModifyEngine::instance()->cleanup_slivers( BODYPtr1Save );
+ AcisModifyEngine::instance()->cleanup_slivers( BODYPtr2Save );
+ if ( GeometryModifyTool::get_all_edges_imprint() )
+ {
+ api_set_int_option("all_free_edges", FALSE );
+ }
- // Compare body 1 before & after imprint
- int num_vol1_aft, num_face1_aft, num_edge1_aft, num_vertex1_aft;
- if( AcisQueryEngine::instance()->
- number_ENTITIES( BODYPtr1Save, num_vol1_aft, num_face1_aft, num_edge1_aft,
- num_vertex1_aft ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to count number of entities in volume\n" );
- if (BODYPtr1Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- }
- if (BODYPtr2Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
- return CUBIT_FAILURE;
- }
+ if (!result.ok())
+ {
+ // might just be no overlap, check smaller boxes
+ if (!BODYPtr1Save || !BODYPtr2Save ||
+ box1.overlap(SPAresabs,box2) == CUBIT_TRUE)
+ {
+ if (DEBUG_FLAG(95))
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
+ }
- // Only create a new Body1 if it changed
- if( num_vol1_bef != num_vol1_aft ||
- num_face1_bef != num_face1_aft ||
- num_edge1_bef != num_edge1_aft ||
- num_vertex1_bef != num_vertex1_aft ||
- GeometryModifyTool::instance()->get_group_imprint() == CUBIT_FALSE)
- {
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(BODYPtr2Save);
+ if (BODYPtr1Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ }
+ if (BODYPtr2Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
+ return CUBIT_FAILURE;
+ }
+ }
- newBodyPtr1 = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr1Save);
- if (newBodyPtr1 == NULL )
- {
- PRINT_ERROR("Problems creating topology for imprinted volume.\n") ;
- if (BODYPtr1Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- }
- if (BODYPtr2Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
- return CUBIT_FAILURE;
- }
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count--; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
+ // Compare body 1 before & after imprint
+ int num_vol1_aft, num_face1_aft, num_edge1_aft, num_vertex1_aft;
+ if( AcisQueryEngine::instance()->
+ number_ENTITIES( BODYPtr1Save, num_vol1_aft, num_face1_aft, num_edge1_aft,
+ num_vertex1_aft ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to count number of entities in volume\n" );
+ if (BODYPtr1Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ }
+ if (BODYPtr2Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
+ return CUBIT_FAILURE;
+ }
- //BodyPtr1->switch_entity_names(newBodyPtr1);
- if (GeometryModifyTool::get_old_names())
- {
- Body* model_ent = dynamic_cast<Body*>(BodyPtr1->topology_entity());
- if (model_ent)
- {
- Body* new_model_ent = dynamic_cast<Body*>(newBodyPtr1->topology_entity());
- if (!new_model_ent)
- new_model_ent = GeometryQueryTool::instance()->make_Body(newBodyPtr1);
- model_ent->switch_entity_names(new_model_ent);
- }
- }
+ // Only create a new Body1 if it changed
+ if( num_vol1_bef != num_vol1_aft ||
+ num_face1_bef != num_face1_aft ||
+ num_edge1_bef != num_edge1_aft ||
+ num_vertex1_bef != num_vertex1_aft ||
+ GeometryModifyTool::instance()->get_group_imprint() == CUBIT_FALSE)
+ {
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(BODYPtr2Save);
- if (keep_old == CUBIT_FALSE)
- AcisQueryEngine::instance()->delete_solid_model_entities(BodyPtr1);
- }
- else
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- }
+ newBodyPtr1 = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr1Save);
+ if (newBodyPtr1 == NULL )
+ {
+ PRINT_ERROR("Problems creating topology for imprinted volume.\n") ;
+ if (BODYPtr1Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ }
+ if (BODYPtr2Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
+ return CUBIT_FAILURE;
+ }
- // Compare body 2 before & after imprint
- int num_vol2_aft, num_face2_aft, num_edge2_aft, num_vertex2_aft;
- if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr2Save, num_vol2_aft, num_face2_aft, num_edge2_aft,
- num_vertex2_aft ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to count number of entities in volume.\n");
- if (BODYPtr1Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
- }
- if (BODYPtr2Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
- return CUBIT_FAILURE;
- }
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count--; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
- // Only create a new Body2 if it changed
- if( num_vol2_bef != num_vol2_aft ||
- num_face2_bef != num_face2_aft ||
- num_edge2_bef != num_edge2_aft ||
- num_vertex2_bef != num_vertex2_aft ||
- GeometryModifyTool::instance()->get_group_imprint() == CUBIT_FALSE)
- {
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(BODYPtr2Save);
+ //BodyPtr1->switch_entity_names(newBodyPtr1);
+ if (GeometryModifyTool::get_old_names())
+ {
+ Body* model_ent = dynamic_cast<Body*>(BodyPtr1->topology_entity());
+ if (model_ent)
+ {
+ Body* new_model_ent = dynamic_cast<Body*>(newBodyPtr1->topology_entity());
+ if (!new_model_ent)
+ new_model_ent = GeometryQueryTool::instance()->make_Body(newBodyPtr1);
+ model_ent->switch_entity_names(new_model_ent);
+ }
+ }
- newBodyPtr2 = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr2Save);
- if (newBodyPtr2 == NULL )
- {
- PRINT_ERROR("Problems creating topology for imprinted volume.\n" ) ;
- if (BODYPtr2Save != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
- return CUBIT_FAILURE;
- }
+ if (keep_old == CUBIT_FALSE)
+ AcisQueryEngine::instance()->delete_solid_model_entities(BodyPtr1);
+ }
+ else
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ }
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count--; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
+ // Compare body 2 before & after imprint
+ int num_vol2_aft, num_face2_aft, num_edge2_aft, num_vertex2_aft;
+ if( AcisQueryEngine::instance()->number_ENTITIES( BODYPtr2Save, num_vol2_aft, num_face2_aft, num_edge2_aft,
+ num_vertex2_aft ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to count number of entities in volume.\n");
+ if (BODYPtr1Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr1Save, CUBIT_TRUE);
+ }
+ if (BODYPtr2Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
+ return CUBIT_FAILURE;
+ }
- if (GeometryModifyTool::get_old_names())
- {
- Body* model_ent = dynamic_cast<Body*>(BodyPtr2->topology_entity());
- if (model_ent)
- {
- Body* new_model_ent = dynamic_cast<Body*>(newBodyPtr2->topology_entity());
- if (!new_model_ent)
- new_model_ent = GeometryQueryTool::instance()->make_Body(newBodyPtr2);
- model_ent->switch_entity_names(new_model_ent);
- }
- }
+ // Only create a new Body2 if it changed
+ if( num_vol2_bef != num_vol2_aft ||
+ num_face2_bef != num_face2_aft ||
+ num_edge2_bef != num_edge2_aft ||
+ num_vertex2_bef != num_vertex2_aft ||
+ GeometryModifyTool::instance()->get_group_imprint() == CUBIT_FALSE)
+ {
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(BODYPtr2Save);
- if (keep_old == CUBIT_FALSE)
- AcisQueryEngine::instance()->delete_solid_model_entities(BodyPtr2);
- //actuate_mesh_intervals( newBodyPtr2 );
- }
- else
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
- }
+ newBodyPtr2 = AcisQueryEngine::instance()->populate_topology_bridges(BODYPtr2Save);
+ if (newBodyPtr2 == NULL )
+ {
+ PRINT_ERROR("Problems creating topology for imprinted volume.\n" ) ;
+ if (BODYPtr2Save != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
+ return CUBIT_FAILURE;
+ }
- // All's well with the world :-)
- return CUBIT_SUCCESS;
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count--; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
- }
+ if (GeometryModifyTool::get_old_names())
+ {
+ Body* model_ent = dynamic_cast<Body*>(BodyPtr2->topology_entity());
+ if (model_ent)
+ {
+ Body* new_model_ent = dynamic_cast<Body*>(newBodyPtr2->topology_entity());
+ if (!new_model_ent)
+ new_model_ent = GeometryQueryTool::instance()->make_Body(newBodyPtr2);
+ model_ent->switch_entity_names(new_model_ent);
+ }
+ }
- BodySM *AcisModifyEngine::get_new_Body( BodySM *old_Body,
- BODY *old_BODY,
- BODY *new_BODY,
- const bool keep_old,
- const bool topology_check,
- const bool delete_old) const
- {
- if (topology_check)
- {
- // must do topology check between old & new bodies. In the case
- // of a topology check, we know there's only one old and new body
- int num_vol_bef, num_face_bef, num_edge_bef, num_vertex_bef;
- CubitStatus status1 = AcisQueryEngine::instance()->number_ENTITIES( old_BODY, num_vol_bef,
- num_face_bef, num_edge_bef,
- num_vertex_bef );
+ if (keep_old == CUBIT_FALSE)
+ AcisQueryEngine::instance()->delete_solid_model_entities(BodyPtr2);
+ //actuate_mesh_intervals( newBodyPtr2 );
+ }
+ else
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODYPtr2Save, CUBIT_TRUE);
+ }
- int num_vol_aft, num_face_aft, num_edge_aft, num_vertex_aft;
- CubitStatus status2 = AcisQueryEngine::instance()->number_ENTITIES( new_BODY, num_vol_aft,
- num_face_aft, num_edge_aft,
- num_vertex_aft );
+ // All's well with the world :-)
+ return CUBIT_SUCCESS;
- if( status1 == CUBIT_FAILURE ||
- status2 == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to count number of entities in volume\n" );
+}
- return 0;
- }
+BodySM *AcisModifyEngine::get_new_Body( BodySM *old_Body,
+ BODY *old_BODY,
+ BODY *new_BODY,
+ const bool keep_old,
+ const bool topology_check,
+ const bool delete_old) const
+{
+ if (topology_check)
+ {
+ // must do topology check between old & new bodies. In the case
+ // of a topology check, we know there's only one old and new body
+ int num_vol_bef, num_face_bef, num_edge_bef, num_vertex_bef;
+ CubitStatus status1 = AcisQueryEngine::instance()->number_ENTITIES( old_BODY, num_vol_bef,
+ num_face_bef, num_edge_bef,
+ num_vertex_bef );
- if( num_vol_bef == num_vol_aft &&
- num_face_bef == num_face_aft &&
- num_edge_bef == num_edge_aft &&
- num_vertex_bef == num_vertex_aft)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(new_BODY, CUBIT_TRUE);
- return 0;
- }
- }
+ int num_vol_aft, num_face_aft, num_edge_aft, num_vertex_aft;
+ CubitStatus status2 = AcisQueryEngine::instance()->number_ENTITIES( new_BODY, num_vol_aft,
+ num_face_aft, num_edge_aft,
+ num_vertex_aft );
- // convert input to list-based version and pass to overloaded version of
- // get_new_body
- DLIList<BodySM*> Body_list(1);
- if(old_Body != NULL)
- Body_list.append(old_Body);
- DLIList<BODY*> BODY_list(1);
- if(old_BODY != NULL)
- BODY_list.append(old_BODY);
+ if( status1 == CUBIT_FAILURE ||
+ status2 == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to count number of entities in volume\n" );
- return get_new_Body(Body_list, BODY_list, new_BODY, keep_old, delete_old);
+ return 0;
}
- BodySM *AcisModifyEngine::get_new_Body(DLIList<BodySM*> &old_Body_list,
- DLIList<BODY*> &old_BODY_list,
- BODY *new_BODY,
- const bool keep_old,
- const bool delete_old) const
+ if( num_vol_bef == num_vol_aft &&
+ num_face_bef == num_face_aft &&
+ num_edge_bef == num_edge_aft &&
+ num_vertex_bef == num_vertex_aft)
{
- DLIList<BODY*> new_BODY_list;
- new_BODY_list.append(new_BODY);
- DLIList<BodySM*> new_Body_list;
- CubitStatus status = get_new_Body(old_Body_list, old_BODY_list,
- new_BODY_list, new_Body_list,
- keep_old, delete_old);
+ AcisQueryEngine::instance()->delete_ACIS_BODY(new_BODY, CUBIT_TRUE);
+ return 0;
+ }
+ }
- if (status == CUBIT_FAILURE ||
- new_Body_list.size() == 0) return NULL;
+ // convert input to list-based version and pass to overloaded version of
+ // get_new_body
+ DLIList<BodySM*> Body_list(1);
+ if(old_Body != NULL)
+ Body_list.append(old_Body);
+ DLIList<BODY*> BODY_list(1);
+ if(old_BODY != NULL)
+ BODY_list.append(old_BODY);
- assert(new_Body_list.size() == 1);
+ return get_new_Body(Body_list, BODY_list, new_BODY, keep_old, delete_old);
+}
- return new_Body_list.get();
- }
+BodySM *AcisModifyEngine::get_new_Body(DLIList<BodySM*> &old_Body_list,
+ DLIList<BODY*> &old_BODY_list,
+ BODY *new_BODY,
+ const bool keep_old,
+ const bool delete_old) const
+{
+ DLIList<BODY*> new_BODY_list;
+ new_BODY_list.append(new_BODY);
+ DLIList<BodySM*> new_Body_list;
+ CubitStatus status = get_new_Body(old_Body_list, old_BODY_list,
+ new_BODY_list, new_Body_list,
+ keep_old, delete_old);
- CubitStatus AcisModifyEngine::get_new_Body( BodySM *old_Body,
- BODY *old_BODY,
- DLIList<BODY*> &new_BODY_list,
- DLIList<BodySM*> &new_Body_list,
- const bool keep_old,
- const bool delete_old) const
- {
- DLIList<BODY*> old_BODY_list;
- old_BODY_list.append(old_BODY);
- DLIList<BodySM*> old_Body_list;
- old_Body_list.append(old_Body);
- return get_new_Body(old_Body_list, old_BODY_list,
- new_BODY_list, new_Body_list,
- keep_old, delete_old);
- }
+ if (status == CUBIT_FAILURE ||
+ new_Body_list.size() == 0) return NULL;
- CubitStatus AcisModifyEngine::get_new_Body(DLIList<BodySM*> &old_Body_list,
+ assert(new_Body_list.size() == 1);
+
+ return new_Body_list.get();
+}
+
+CubitStatus AcisModifyEngine::get_new_Body( BodySM *old_Body,
+ BODY *old_BODY,
+ DLIList<BODY*> &new_BODY_list,
+ DLIList<BodySM*> &new_Body_list,
+ const bool keep_old,
+ const bool delete_old) const
+{
+ DLIList<BODY*> old_BODY_list;
+ old_BODY_list.append(old_BODY);
+ DLIList<BodySM*> old_Body_list;
+ old_Body_list.append(old_Body);
+ return get_new_Body(old_Body_list, old_BODY_list,
+ new_BODY_list, new_Body_list,
+ keep_old, delete_old);
+}
+
+CubitStatus AcisModifyEngine::get_new_Body(DLIList<BodySM*> &old_Body_list,
DLIList<BODY*> &old_BODY_list,
DLIList<BODY*> &new_BODY_list,
DLIList<BodySM*> &new_Body_list,
const bool keep_old,
const bool delete_old) const
- {
- assert(old_Body_list.size() == old_BODY_list.size());
+{
+ assert(old_Body_list.size() == old_BODY_list.size());
- //&& old_Body_list.size() > 0); It's possible now to have no
- //old bodies, so don't stress over this
+ //&& old_Body_list.size() > 0); It's possible now to have no
+ //old bodies, so don't stress over this
- // Only create a new Body if it changed
- BodySM *new_Body = NULL;
+ // Only create a new Body if it changed
+ BodySM *new_Body = NULL;
- // body changed; need to build a new vgi body around
- // old_BODY, either by reusing old_Body or creating new one
+ // body changed; need to build a new vgi body around
+ // old_BODY, either by reusing old_Body or creating new one
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_FALSE &&
- keep_old == CUBIT_FALSE)
- {
- // if we're reusing old refentities, prepare by marking
- // deactivated the ones that don't get reused, then delete
- // those
- int num_deactivd = 0;
- int i;
- for (i = old_BODY_list.size(); i > 0; i--)
- num_deactivd += mark_owners_deactivated_flag(old_BODY_list.get_and_step(),
- CUBIT_TRUE);
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_FALSE &&
+ keep_old == CUBIT_FALSE)
+ {
+ // if we're reusing old refentities, prepare by marking
+ // deactivated the ones that don't get reused, then delete
+ // those
+ int num_deactivd = 0;
+ int i;
+ for (i = old_BODY_list.size(); i > 0; i--)
+ num_deactivd += mark_owners_deactivated_flag(old_BODY_list.get_and_step(),
+ CUBIT_TRUE);
- int num_reactivd = 0;
- for (i = new_BODY_list.size(); i > 0; i--)
- num_reactivd = mark_owners_deactivated_flag(new_BODY_list.get_and_step(),
- CUBIT_FALSE);
- if (DEBUG_FLAG(99))
- {
- PRINT_DEBUG_99( "Number of entities deactivated = %d,"
- " reactivated = %d\n", num_deactivd, num_reactivd);
- print_deleted_reused(old_BODY_list, new_BODY_list);
- }
+ int num_reactivd = 0;
+ for (i = new_BODY_list.size(); i > 0; i--)
+ num_reactivd = mark_owners_deactivated_flag(new_BODY_list.get_and_step(),
+ CUBIT_FALSE);
+ if (DEBUG_FLAG(99))
+ {
+ PRINT_DEBUG_99( "Number of entities deactivated = %d,"
+ " reactivated = %d\n", num_deactivd, num_reactivd);
+ print_deleted_reused(old_BODY_list, new_BODY_list);
+ }
- // ok, now unhook the old body from the vgi data (only done if
- // we aren't keeping old geometry)
- if (keep_old == CUBIT_FALSE)
- {
- for (i = old_BODY_list.size(); i > 0; i--)
- AcisQueryEngine::instance()->delete_ACIS_BODY(old_BODY_list.get_and_step(), CUBIT_FALSE);
- }
+ // ok, now unhook the old body from the vgi data (only done if
+ // we aren't keeping old geometry)
+ if (keep_old == CUBIT_FALSE)
+ {
+ for (i = old_BODY_list.size(); i > 0; i--)
+ AcisQueryEngine::instance()->delete_ACIS_BODY(old_BODY_list.get_and_step(), CUBIT_FALSE);
+ }
- // now cleanout the deactivated geometry; automatically unhooks
- // from the dag
- cleanout_deactivated_geometry();
- }
- // now delete the old body, either obeying or not obeying the
- // deactivated flags (which is opposite of the
- // create_new_refents flag)
- if (GeometryModifyTool::instance()->get_new_ids() && !keep_old && delete_old)
- {
- for (int i = old_Body_list.size(); i > 0; i--)
- {
- BodySM *old_Body = old_Body_list.get_and_step();
- AcisQueryEngine::instance()->delete_solid_model_entities(old_Body);
- }
- }
+ // now cleanout the deactivated geometry; automatically unhooks
+ // from the dag
+ cleanout_deactivated_geometry();
+ }
+ // now delete the old body, either obeying or not obeying the
+ // deactivated flags (which is opposite of the
+ // create_new_refents flag)
+ if (GeometryModifyTool::instance()->get_new_ids() && !keep_old && delete_old)
+ {
+ for (int i = old_Body_list.size(); i > 0; i--)
+ {
+ BodySM *old_Body = old_Body_list.get_and_step();
+ AcisQueryEngine::instance()->delete_solid_model_entities(old_Body);
+ }
+ }
- int i;
- for (i = new_BODY_list.size(); i > 0; i--)
- {
- new_Body = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_list.get_and_step());
- if (new_Body != NULL)
- new_Body_list.append(new_Body);
- else
- {
- PRINT_ERROR("Problems creating new Body from new BODY.\n"
- " get_new_Body failed.\n") ;
- return CUBIT_FAILURE;
- }
- }
-
- if( keep_old && GeometryModifyTool::get_old_names() )
- {
- // switch names with the first body only
- old_Body_list.reset();
- BodySM* old_bodysm = old_Body_list.get();
- Body* body = dynamic_cast<Body*>(old_bodysm->topology_entity());
- if (body)
- {
- Body* new_body = dynamic_cast<Body*>(new_Body->topology_entity());
- if (!new_body)
- new_body = GeometryQueryTool::instance()->make_Body(new_Body);
- body->switch_entity_names(new_body);
- }
- }
-
- return CUBIT_SUCCESS;
+ int i;
+ for (i = new_BODY_list.size(); i > 0; i--)
+ {
+ new_Body = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_list.get_and_step());
+ if (new_Body != NULL)
+ new_Body_list.append(new_Body);
+ else
+ {
+ PRINT_ERROR("Problems creating new Body from new BODY.\n"
+ " get_new_Body failed.\n") ;
+ return CUBIT_FAILURE;
}
+ }
- CubitStatus AcisModifyEngine::get_new_Body( DLIList<TopologyBridge*> &old_entity_list,
- DLIList<BODY*> &new_BODY_list,
- DLIList<BodySM*> &new_Body_list,
- const bool keep_old,
- const bool delete_old) const
+ if( keep_old && GeometryModifyTool::get_old_names() )
+ {
+ // switch names with the first body only
+ old_Body_list.reset();
+ BodySM* old_bodysm = old_Body_list.get();
+ Body* body = dynamic_cast<Body*>(old_bodysm->topology_entity());
+ if (body)
{
- assert(old_entity_list.size() > 0 || keep_old );
+ Body* new_body = dynamic_cast<Body*>(new_Body->topology_entity());
+ if (!new_body)
+ new_body = GeometryQueryTool::instance()->make_Body(new_Body);
+ body->switch_entity_names(new_body);
+ }
+ }
- // don't do a topology check in this version of get_new_Body
+ return CUBIT_SUCCESS;
+}
- // need to build a new body or bodies
+CubitStatus AcisModifyEngine::get_new_Body( DLIList<TopologyBridge*> &old_entity_list,
+ DLIList<BODY*> &new_BODY_list,
+ DLIList<BodySM*> &new_Body_list,
+ const bool keep_old,
+ const bool delete_old) const
+{
+ assert(old_entity_list.size() > 0 || keep_old );
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_FALSE &&
- keep_old == CUBIT_FALSE)
- {
- // if we're reusing old refentities, prepare by marking
- // deactivated the ones that don't get reused, then delete
- // those
- int i, j, num_deactivd = 0, num_reactivd = 0;
+ // don't do a topology check in this version of get_new_Body
- ENTITY_LIST old_ENTITY_list, tmp_ENTITY_list;
- old_entity_list.reset();
- for (i = old_entity_list.size(); i--; )
- {
- tmp_ENTITY_list.clear();
- TopologyBridge* geom_ptr = old_entity_list.get_and_step();
- AcisBridge* bridge_ptr = dynamic_cast<AcisBridge*>(geom_ptr);
- if (!bridge_ptr)
- {
- PRINT_ERROR("Non-ACIS geometry at %s:%d\n",__FILE__,__LINE__);
- continue;
- }
- ENTITY* ENTITY_ptr = bridge_ptr->ENTITY_ptr();
- if (!ENTITY_ptr)
- continue;
+ // need to build a new body or bodies
- old_ENTITY_list.add(ENTITY_ptr);
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_FALSE &&
+ keep_old == CUBIT_FALSE)
+ {
+ // if we're reusing old refentities, prepare by marking
+ // deactivated the ones that don't get reused, then delete
+ // those
+ int i, j, num_deactivd = 0, num_reactivd = 0;
+ ENTITY_LIST old_ENTITY_list, tmp_ENTITY_list;
+ old_entity_list.reset();
+ for (i = old_entity_list.size(); i--; )
+ {
+ tmp_ENTITY_list.clear();
+ TopologyBridge* geom_ptr = old_entity_list.get_and_step();
+ AcisBridge* bridge_ptr = dynamic_cast<AcisBridge*>(geom_ptr);
+ if (!bridge_ptr)
+ {
+ PRINT_ERROR("Non-ACIS geometry at %s:%d\n",__FILE__,__LINE__);
+ continue;
+ }
+ ENTITY* ENTITY_ptr = bridge_ptr->ENTITY_ptr();
+ if (!ENTITY_ptr)
+ continue;
- CubitStatus stat = AcisQueryEngine::instance()->
- get_child_ENTITYs( ENTITY_ptr, tmp_ENTITY_list, true);
- if (!stat)
- {
- PRINT_ERROR("AcisQueryEngine::get_child_ENTITYs failed at %s:%d\n",__FILE__,__LINE__);
- continue;
- }
+ old_ENTITY_list.add(ENTITY_ptr);
- for (j = 0; j < tmp_ENTITY_list.count(); j++)
- {
- old_ENTITY_list.add( tmp_ENTITY_list[j] );
- }
- }
- for (i = 0; i < old_ENTITY_list.count(); i++)
- {
- // mark the owners deactivated, but don't recurse, since we've got all
- // the lower order topology already
- num_deactivd += mark_owners_deactivated_flag(old_ENTITY_list[i],
- CUBIT_TRUE,
- CUBIT_FALSE);
- }
+ CubitStatus stat = AcisQueryEngine::instance()->
+ get_child_ENTITYs( ENTITY_ptr, tmp_ENTITY_list, true);
+ if (!stat)
+ {
+ PRINT_ERROR("AcisQueryEngine::get_child_ENTITYs failed at %s:%d\n",__FILE__,__LINE__);
+ continue;
+ }
+ for (j = 0; j < tmp_ENTITY_list.count(); j++)
+ {
+ old_ENTITY_list.add( tmp_ENTITY_list[j] );
+ }
+ }
- for (i = new_BODY_list.size(); i > 0; i--)
- num_reactivd += mark_owners_deactivated_flag(new_BODY_list.get_and_step(),
- CUBIT_FALSE);
- if (DEBUG_FLAG(99))
- {
- PRINT_DEBUG_99( "Number of entities deactivated = %d,"
- " reactivated = %d\n", num_deactivd, num_reactivd);
- }
+ for (i = 0; i < old_ENTITY_list.count(); i++)
+ {
+ // mark the owners deactivated, but don't recurse, since we've got all
+ // the lower order topology already
+ num_deactivd += mark_owners_deactivated_flag(old_ENTITY_list[i],
+ CUBIT_TRUE,
+ CUBIT_FALSE);
+ }
- // ok, now unhook the old body from the vgi data (only done if
- // we aren't keeping old geometry)
- if (keep_old == CUBIT_FALSE)
- {
- ENTITY_LIST to_be_deleted;
- for (i = 0; i < old_ENTITY_list.count(); i++)
- {
- // need to check to make sure the old entity isn't in the new body
- ENTITY *this_ENTITY = old_ENTITY_list[i];
- BODY *this_BODY = AcisQueryEngine::instance()->get_BODY_of_ENTITY(this_ENTITY);
- //if the entity is not in the new body, add it to a list of
- //entities to be deleted
- if (!new_BODY_list.move_to(this_BODY))
- to_be_deleted.add(this_ENTITY);
- }
- //delete the ENTITYs in the list
- AcisQueryEngine::instance()->delete_ACIS_ENTITY(to_be_deleted);
- }
- // now cleanout the deactivated geometry; automatically unhooks
- // from the dag
- cleanout_deactivated_geometry();
- }
+ for (i = new_BODY_list.size(); i > 0; i--)
+ num_reactivd += mark_owners_deactivated_flag(new_BODY_list.get_and_step(),
+ CUBIT_FALSE);
+ if (DEBUG_FLAG(99))
+ {
+ PRINT_DEBUG_99( "Number of entities deactivated = %d,"
+ " reactivated = %d\n", num_deactivd, num_reactivd);
+ }
+ // ok, now unhook the old body from the vgi data (only done if
+ // we aren't keeping old geometry)
+ if (keep_old == CUBIT_FALSE)
+ {
+ ENTITY_LIST to_be_deleted;
+ for (i = 0; i < old_ENTITY_list.count(); i++)
+ {
+ // need to check to make sure the old entity isn't in the new body
+ ENTITY *this_ENTITY = old_ENTITY_list[i];
+ BODY *this_BODY = AcisQueryEngine::instance()->get_BODY_of_ENTITY(this_ENTITY);
+ //if the entity is not in the new body, add it to a list of
+ //entities to be deleted
+ if (!new_BODY_list.move_to(this_BODY))
+ to_be_deleted.add(this_ENTITY);
+ }
+ //delete the ENTITYs in the list
+ AcisQueryEngine::instance()->delete_ACIS_ENTITY(to_be_deleted);
+ }
- // now delete the old body, either obeying or not obeying the
- // deactivated flags (which is opposite of the
- // create_new_refents flag)
- int i;
- if (GeometryModifyTool::instance()->get_new_ids() && !keep_old && delete_old)
- {
- for (i = old_entity_list.size(); i > 0; i--)
- {
- TopologyBridge *old_entity = old_entity_list.get_and_step();
- if (BodySM* bod_ptr = dynamic_cast<BodySM*>(old_entity))
- AcisQueryEngine::instance()->delete_solid_model_entities(bod_ptr);
- else
- AcisQueryEngine::instance()->delete_solid_model_entities(
- dynamic_cast<GeometryEntity*>(old_entity),true);
- }
- cleanout_deactivated_geometry();
- }
+ // now cleanout the deactivated geometry; automatically unhooks
+ // from the dag
+ cleanout_deactivated_geometry();
+ }
- for (i = new_BODY_list.size(); i > 0; i--)
- {
- BodySM *new_Body = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_list.get_and_step());
- if (new_Body != NULL)
- new_Body_list.append(new_Body);
- else
- {
- PRINT_ERROR("Problems creating new Body from new BODY.\n"
- " get_new_Body failed.\n") ;
- return CUBIT_FAILURE;
- }
- }
- return CUBIT_SUCCESS;
+ // now delete the old body, either obeying or not obeying the
+ // deactivated flags (which is opposite of the
+ // create_new_refents flag)
+ int i;
+ if (GeometryModifyTool::instance()->get_new_ids() && !keep_old && delete_old)
+ {
+ for (i = old_entity_list.size(); i > 0; i--)
+ {
+ TopologyBridge *old_entity = old_entity_list.get_and_step();
+ if (BodySM* bod_ptr = dynamic_cast<BodySM*>(old_entity))
+ AcisQueryEngine::instance()->delete_solid_model_entities(bod_ptr);
+ else
+ AcisQueryEngine::instance()->delete_solid_model_entities(
+ dynamic_cast<GeometryEntity*>(old_entity),true);
}
+ cleanout_deactivated_geometry();
+ }
- int AcisModifyEngine::mark_owners_deactivated_flag(ENTITY *this_ENTITY,
+ for (i = new_BODY_list.size(); i > 0; i--)
+ {
+ BodySM *new_Body = AcisQueryEngine::instance()->populate_topology_bridges(new_BODY_list.get_and_step());
+ if (new_Body != NULL)
+ new_Body_list.append(new_Body);
+ else
+ {
+ PRINT_ERROR("Problems creating new Body from new BODY.\n"
+ " get_new_Body failed.\n") ;
+ return CUBIT_FAILURE;
+ }
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+int AcisModifyEngine::mark_owners_deactivated_flag(ENTITY *this_ENTITY,
bool flag,
bool recurse) const
- {
- // marks as deactivated all the owners of the input BODY,
- // along with all its children
- //
- // order is important here; entities must be put in the
- // deactivated list from lower order to higher order, that saves
- // work when removing the DAG nodes from the DAG
- // (not sure it's absolutely necessary though, since the
- // remove_from_DAG() function calls that function recursively for
- // lower order entities)
+{
+ // marks as deactivated all the owners of the input BODY,
+ // along with all its children
+ //
+ // order is important here; entities must be put in the
+ // deactivated list from lower order to higher order, that saves
+ // work when removing the DAG nodes from the DAG
+ // (not sure it's absolutely necessary though, since the
+ // remove_from_DAG() function calls that function recursively for
+ // lower order entities)
- int num_deactivated = 0;
+ int num_deactivated = 0;
- // if we're not recursing, set the skip flag to true
- CubitBoolean skip = (recurse ? CUBIT_FALSE : CUBIT_TRUE);
- ENTITY_LIST ENTITIES;
- outcome result;
+ // if we're not recursing, set the skip flag to true
+ CubitBoolean skip = (recurse ? CUBIT_FALSE : CUBIT_TRUE);
+ ENTITY_LIST ENTITIES;
+ outcome result;
- // vertices
- if (IS_ENTITY_TYPE( this_ENTITY, VERTEX )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_vertices( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // vertices
+ if (IS_ENTITY_TYPE( this_ENTITY, VERTEX )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_vertices( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // edges
- if (IS_ENTITY_TYPE( this_ENTITY, EDGE )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_edges( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // edges
+ if (IS_ENTITY_TYPE( this_ENTITY, EDGE )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_edges( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // coedges
- if (IS_ENTITY_TYPE( this_ENTITY, COEDGE )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_coedges( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // coedges
+ if (IS_ENTITY_TYPE( this_ENTITY, COEDGE )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_coedges( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // loops
- if (IS_ENTITY_TYPE( this_ENTITY, LOOP )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_loops( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // loops
+ if (IS_ENTITY_TYPE( this_ENTITY, LOOP )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_loops( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // faces
- if (IS_ENTITY_TYPE( this_ENTITY, FACE )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_faces( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // faces
+ if (IS_ENTITY_TYPE( this_ENTITY, FACE )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_faces( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // shells
- if (IS_ENTITY_TYPE( this_ENTITY, SHELL )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_shells( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // shells
+ if (IS_ENTITY_TYPE( this_ENTITY, SHELL )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_shells( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // volumes
- if (IS_ENTITY_TYPE( this_ENTITY, LUMP )) skip = CUBIT_TRUE;
- if (!skip) {
- result = api_get_lumps( this_ENTITY, ENTITIES);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- ENTITIES.clear();
- }
+ // volumes
+ if (IS_ENTITY_TYPE( this_ENTITY, LUMP )) skip = CUBIT_TRUE;
+ if (!skip) {
+ result = api_get_lumps( this_ENTITY, ENTITIES);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ ENTITIES.clear();
+ }
- // now, finally, do the entity itself
- ENTITIES.add(this_ENTITY);
- num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
+ // now, finally, do the entity itself
+ ENTITIES.add(this_ENTITY);
+ num_deactivated += mark_owners_deactivated_flag( ENTITIES, flag );
- return num_deactivated;
- }
+ return num_deactivated;
+}
- int AcisModifyEngine::mark_owners_deactivated_flag( ENTITY_LIST& ENTITIES,
- bool flag ) const
+int AcisModifyEngine::mark_owners_deactivated_flag( ENTITY_LIST& ENTITIES,
+ bool flag ) const
+{
+ int num_deactivated = 0;
+
+ for (int i = 0; i < ENTITIES.count(); i++)
+ {
+ AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]);
+ if (acis_bridge != NULL)
{
- int num_deactivated = 0;
+ if (flag == false)
+ {
+ // if bridge was deactivated, re-activate it and...
+ if (reactivate_bridge(acis_bridge))
+ {
+ // ...and get the pointers between
+ // ACIS and the TB right.
+ acis_bridge->ENTITY_ptr(ENTITIES[i]);
+ num_deactivated++;
+ }
+ else // bridge was already reactivated
+ {
+ // if we're reactivating an entity and it has already been reactivated,
+ // that means another acis entity is using it - make this acis entity
+ // get a new one
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner(ENTITIES[i]);
+ }
+ }
- for (int i = 0; i < ENTITIES.count(); i++)
- {
- AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]);
- if (acis_bridge != NULL)
- {
- if (flag == false)
- {
- // if bridge was deactivated, re-activate it and...
- if (reactivate_bridge(acis_bridge))
- {
- // ...and get the pointers between
- // ACIS and the TB right.
- acis_bridge->ENTITY_ptr(ENTITIES[i]);
- num_deactivated++;
- }
- else // bridge was already reactivated
- {
- // if we're reactivating an entity and it has already been reactivated,
- // that means another acis entity is using it - make this acis entity
- // get a new one
- ATTRIB_CUBIT_OWNER::remove_cubit_owner(ENTITIES[i]);
- }
- }
-
- // if flag is true and acis_bridge is NOT deactivated,
- // deactivate it.
- else if (deactivate_bridge(acis_bridge))
- {
- num_deactivated++;
- }
- }
- }
-
- return num_deactivated;
+ // if flag is true and acis_bridge is NOT deactivated,
+ // deactivate it.
+ else if (deactivate_bridge(acis_bridge))
+ {
+ num_deactivated++;
+ }
}
+ }
- void AcisModifyEngine::print_deleted_reused(DLIList<BODY*> &old_BODY_list,
+ return num_deactivated;
+}
+
+void AcisModifyEngine::print_deleted_reused(DLIList<BODY*> &old_BODY_list,
DLIList<BODY*> &new_BODY_list) const
- {
+{
- // print out what's saved and what's not
- DLIList<TopologyBridge*> deact_list, react_list;
- int i;
- for (i = old_BODY_list.size(); i > 0; i--)
- AcisQueryEngine::instance()->get_all_cubit_owners(old_BODY_list.get_and_step(), deact_list);
- for (i = new_BODY_list.size(); i > 0; i--)
- AcisQueryEngine::instance()->get_all_cubit_owners(new_BODY_list.get_and_step(), react_list);
- for (i = react_list.size(); i > 0; i--)
- deact_list.remove(react_list.get_and_step());
- PRINT_DEBUG_99( "Deleted entities:\n");
- for (i = deact_list.size(); i > 0; i--) {
- TopologyBridge* bridge = deact_list.get_and_step();
- TopologyEntity *entity = bridge->topology_entity();
- BasicTopologyEntity *bte = CAST_TO(entity, BasicTopologyEntity);
- GroupingEntity *grpe = CAST_TO(entity, GroupingEntity);
- SenseEntity *se = CAST_TO(entity, SenseEntity);
- if (bte != NULL) {
- PRINT_DEBUG_99( "%s %d\n",
- bte->class_name(),
- bte->id());
- }
- else if (se != NULL) {
- PRINT_DEBUG_99( "%s (lower BTE: %d)\n",
- entity->class_name(),
- (se->get_basic_topology_entity_ptr() ?
- se->get_basic_topology_entity_ptr()->id() : 0));
- }
- else if (grpe != NULL) {
- PRINT_DEBUG_99( "%s (upper BTE: %d)\n",
- entity->class_name(),
- (grpe->get_basic_topology_entity_ptr() ?
- grpe->get_basic_topology_entity_ptr()->id() : 0));
- }
- }
- PRINT_DEBUG_99( "ReUsed entities:\n");
- for (i = react_list.size(); i > 0; i--) {
- TopologyBridge* bridge = react_list.get_and_step();
- TopologyEntity *entity = bridge->topology_entity();
- BasicTopologyEntity *bte = CAST_TO(entity, BasicTopologyEntity);
- GroupingEntity *grpe = CAST_TO(entity, GroupingEntity);
- SenseEntity *se = CAST_TO(entity, SenseEntity);
- if (bte != NULL) {
- PRINT_DEBUG_99( "%s %d\n",
- bte->class_name(),
- bte->id());
- }
- else if (se != NULL) {
- PRINT_DEBUG_99( "%s (lower BTE: %d)\n",
- entity->class_name(),
- (se->get_basic_topology_entity_ptr() ?
- se->get_basic_topology_entity_ptr()->id() : 0));
- }
- else if (grpe != NULL) {
- PRINT_DEBUG_99( "%s (upper BTE: %d)\n",
- entity->class_name(),
- (grpe->get_basic_topology_entity_ptr() ?
- grpe->get_basic_topology_entity_ptr()->id() : 0));
- }
- }
+ // print out what's saved and what's not
+ DLIList<TopologyBridge*> deact_list, react_list;
+ int i;
+ for (i = old_BODY_list.size(); i > 0; i--)
+ AcisQueryEngine::instance()->get_all_cubit_owners(old_BODY_list.get_and_step(), deact_list);
+ for (i = new_BODY_list.size(); i > 0; i--)
+ AcisQueryEngine::instance()->get_all_cubit_owners(new_BODY_list.get_and_step(), react_list);
+ for (i = react_list.size(); i > 0; i--)
+ deact_list.remove(react_list.get_and_step());
+ PRINT_DEBUG_99( "Deleted entities:\n");
+ for (i = deact_list.size(); i > 0; i--) {
+ TopologyBridge* bridge = deact_list.get_and_step();
+ TopologyEntity *entity = bridge->topology_entity();
+ BasicTopologyEntity *bte = CAST_TO(entity, BasicTopologyEntity);
+ GroupingEntity *grpe = CAST_TO(entity, GroupingEntity);
+ SenseEntity *se = CAST_TO(entity, SenseEntity);
+ if (bte != NULL) {
+ PRINT_DEBUG_99( "%s %d\n",
+ bte->class_name(),
+ bte->id());
}
+ else if (se != NULL) {
+ PRINT_DEBUG_99( "%s (lower BTE: %d)\n",
+ entity->class_name(),
+ (se->get_basic_topology_entity_ptr() ?
+ se->get_basic_topology_entity_ptr()->id() : 0));
+ }
+ else if (grpe != NULL) {
+ PRINT_DEBUG_99( "%s (upper BTE: %d)\n",
+ entity->class_name(),
+ (grpe->get_basic_topology_entity_ptr() ?
+ grpe->get_basic_topology_entity_ptr()->id() : 0));
+ }
+ }
+ PRINT_DEBUG_99( "ReUsed entities:\n");
+ for (i = react_list.size(); i > 0; i--) {
+ TopologyBridge* bridge = react_list.get_and_step();
+ TopologyEntity *entity = bridge->topology_entity();
+ BasicTopologyEntity *bte = CAST_TO(entity, BasicTopologyEntity);
+ GroupingEntity *grpe = CAST_TO(entity, GroupingEntity);
+ SenseEntity *se = CAST_TO(entity, SenseEntity);
+ if (bte != NULL) {
+ PRINT_DEBUG_99( "%s %d\n",
+ bte->class_name(),
+ bte->id());
+ }
+ else if (se != NULL) {
+ PRINT_DEBUG_99( "%s (lower BTE: %d)\n",
+ entity->class_name(),
+ (se->get_basic_topology_entity_ptr() ?
+ se->get_basic_topology_entity_ptr()->id() : 0));
+ }
+ else if (grpe != NULL) {
+ PRINT_DEBUG_99( "%s (upper BTE: %d)\n",
+ entity->class_name(),
+ (grpe->get_basic_topology_entity_ptr() ?
+ grpe->get_basic_topology_entity_ptr()->id() : 0));
+ }
+ }
+}
- //-------------------------------------------------------------------------
- // Purpose : Imprint multiple bodies at once
- //
- // Special Notes :
- //
- // Creator : Tim Tautges
- //
- // Creation Date : 12/8/98
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::imprint(DLIList<BodySM*> &from_body_list,
- DLIList<BodySM*> &new_from_body_list,
- bool keep_old,
- DLIList<TopologyBridge*> *new_tbs,
- DLIList<TopologyBridge*> *att_tbs) const
- {
+//-------------------------------------------------------------------------
+// Purpose : Imprint multiple bodies at once
+//
+// Special Notes :
+//
+// Creator : Tim Tautges
+//
+// Creation Date : 12/8/98
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::imprint(DLIList<BodySM*> &from_body_list,
+ DLIList<BodySM*> &new_from_body_list,
+ bool keep_old,
+ DLIList<TopologyBridge*> *new_tbs,
+ DLIList<TopologyBridge*> *att_tbs) const
+{
- DLIList<BODY*> from_BODY_list;
- DLIList<BODY*> from_BODY_list_copy;
- CubitStatus success = CUBIT_SUCCESS;
+ DLIList<BODY*> from_BODY_list;
+ DLIList<BODY*> from_BODY_list_copy;
+ CubitStatus success = CUBIT_SUCCESS;
- // get acis bodies, and copy them
- from_body_list.reset();
- int i, j;
+ // get acis bodies, and copy them
+ from_body_list.reset();
+ int i, j;
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
- const int num_bodies = from_body_list.size();
- from_body_list.reset();
- for (i = 0; i < num_bodies; i++) {
- BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_body_list.next(i));
- from_BODY_list.append(BODYPtr1);
- //BODY *BODYPtr1Save = this->copy_BODY(BODYPtr1, delete_attribs);
- //from_BODY_list_copy.append(BODYPtr1Save);
- from_BODY_list_copy.append(NULL);
- }
+ const int num_bodies = from_body_list.size();
+ from_body_list.reset();
+ for (i = 0; i < num_bodies; i++) {
+ BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_body_list.next(i));
+ from_BODY_list.append(BODYPtr1);
+ //BODY *BODYPtr1Save = this->copy_BODY(BODYPtr1, delete_attribs);
+ //from_BODY_list_copy.append(BODYPtr1Save);
+ from_BODY_list_copy.append(NULL);
+ }
- if (from_BODY_list.is_in_list(NULL))
- return CUBIT_FAILURE;
+ if (from_BODY_list.is_in_list(NULL))
+ return CUBIT_FAILURE;
- // set the free_edges acis option
- if ( GeometryModifyTool::get_all_edges_imprint() )
- {
- api_set_int_option("all_free_edges", TRUE );
- }
+ // set the free_edges acis option
+ if ( GeometryModifyTool::get_all_edges_imprint() )
+ {
+ api_set_int_option("all_free_edges", TRUE );
+ }
// total number of imprints to be done
- int total_imprints = (from_body_list.size() *
- (from_body_list.size()-1))/2;
+ int total_imprints = (from_body_list.size() *
+ (from_body_list.size()-1))/2;
- if( num_bodies > 2 )
- {
- char message[128];
- sprintf(message, "Imprinting %d ACIS Bodies", from_BODY_list.size() );
- AppUtil::instance()->progress_tool()->start(0, total_imprints, message);
- }
+ if( num_bodies > 2 )
+ {
+ char message[128];
+ sprintf(message, "Imprinting %d ACIS Bodies", from_BODY_list.size() );
+ AppUtil::instance()->progress_tool()->start(0, total_imprints, message);
+ }
- // imprint each body with each one later in the list
- from_BODY_list.reset();
- from_BODY_list_copy.reset();
- for (i = 0; success && i < num_bodies - 1; i++) {
- //BODY *BODY_Ptr1 = from_BODY_list_copy.next(i);
- BodySM *Body_Ptr1 = from_body_list.next(i);
- CubitBox box1 = AcisQueryEngine::instance()->bounding_box(Body_Ptr1);
+ // imprint each body with each one later in the list
+ from_BODY_list.reset();
+ from_BODY_list_copy.reset();
+ for (i = 0; success && i < num_bodies - 1; i++) {
+ //BODY *BODY_Ptr1 = from_BODY_list_copy.next(i);
+ BodySM *Body_Ptr1 = from_body_list.next(i);
+ CubitBox box1 = AcisQueryEngine::instance()->bounding_box(Body_Ptr1);
- for (j = i + 1; j < num_bodies; j++) {
+ for (j = i + 1; j < num_bodies; j++) {
- if (CubitMessage::instance()->Interrupt())
- {
- success = CUBIT_FAILURE;
- break;
- }
+ if (CubitMessage::instance()->Interrupt())
+ {
+ success = CUBIT_FAILURE;
+ break;
+ }
- //BODY *BODY_Ptr2 = from_BODY_list_copy.next(j);
- BodySM *Body_Ptr2 = from_body_list.next(j);
- CubitBox box2 = AcisQueryEngine::instance()->bounding_box(Body_Ptr2);
+ //BODY *BODY_Ptr2 = from_BODY_list_copy.next(j);
+ BodySM *Body_Ptr2 = from_body_list.next(j);
+ CubitBox box2 = AcisQueryEngine::instance()->bounding_box(Body_Ptr2);
- // first, check bounding SPAbox; if they don't intersect, imprint will fail
+ // first, check bounding SPAbox; if they don't intersect, imprint will fail
- if (box1.overlap(SPAresabs, box2))
- {
- if (DEBUG_FLAG(95))
- {
- TopologyEntity *te1 = Body_Ptr1->topology_entity();
- TopologyEntity *te2 = Body_Ptr2->topology_entity();
- RefEntity *ref1 = CAST_TO(te1, RefEntity );
- RefEntity *ref2 = CAST_TO(te2, RefEntity );
- PRINT_INFO("Imprinting bodies %d and %d\n", ref1->id(), ref2->id() );
- }
+ if (box1.overlap(SPAresabs, box2))
+ {
+ if (DEBUG_FLAG(95))
+ {
+ TopologyEntity *te1 = Body_Ptr1->topology_entity();
+ TopologyEntity *te2 = Body_Ptr2->topology_entity();
+ RefEntity *ref1 = CAST_TO(te1, RefEntity );
+ RefEntity *ref2 = CAST_TO(te2, RefEntity );
+ PRINT_INFO("Imprinting bodies %d and %d\n", ref1->id(), ref2->id() );
+ }
- BODY* BODY_Ptr1 = from_BODY_list_copy.next(i);
- BODY* BODY_Ptr2 = from_BODY_list_copy.next(j);
- if (!BODY_Ptr1)
- BODY_Ptr1 = from_BODY_list.next(i);
- if (!BODY_Ptr2)
- BODY_Ptr2 = from_BODY_list.next(j);
+ BODY* BODY_Ptr1 = from_BODY_list_copy.next(i);
+ BODY* BODY_Ptr2 = from_BODY_list_copy.next(j);
+ if (!BODY_Ptr1)
+ BODY_Ptr1 = from_BODY_list.next(i);
+ if (!BODY_Ptr2)
+ BODY_Ptr2 = from_BODY_list.next(j);
- BODY_Ptr1 = copy_BODY(BODY_Ptr1, delete_attribs);
- BODY_Ptr2 = copy_BODY(BODY_Ptr2, delete_attribs);
- // the bodies overlap; proceed with the imprint
- outcome result = api_imprint(BODY_Ptr1, BODY_Ptr2);
+ BODY_Ptr1 = copy_BODY(BODY_Ptr1, delete_attribs);
+ BODY_Ptr2 = copy_BODY(BODY_Ptr2, delete_attribs);
+ // the bodies overlap; proceed with the imprint
+ outcome result = api_imprint(BODY_Ptr1, BODY_Ptr2);
- AcisModifyEngine::instance()->cleanup_slivers( BODY_Ptr1 );
- AcisModifyEngine::instance()->cleanup_slivers( BODY_Ptr2 );
+ AcisModifyEngine::instance()->cleanup_slivers( BODY_Ptr1 );
+ AcisModifyEngine::instance()->cleanup_slivers( BODY_Ptr2 );
- if (result.ok())
- {
- from_BODY_list_copy.step(i);
- if (from_BODY_list_copy.get())
- api_delent(from_BODY_list_copy.get());
- from_BODY_list_copy.change_to(BODY_Ptr1);
- from_BODY_list_copy.reset();
+ if (result.ok())
+ {
+ from_BODY_list_copy.step(i);
+ if (from_BODY_list_copy.get())
+ api_delent(from_BODY_list_copy.get());
+ from_BODY_list_copy.change_to(BODY_Ptr1);
+ from_BODY_list_copy.reset();
- from_BODY_list_copy.step(j);
- if (from_BODY_list_copy.get())
- api_delent(from_BODY_list_copy.get());
- from_BODY_list_copy.change_to(BODY_Ptr2);
- from_BODY_list_copy.reset();
- }
- else
- {
- if (DEBUG_FLAG(95)) {
- AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
- }
+ from_BODY_list_copy.step(j);
+ if (from_BODY_list_copy.get())
+ api_delent(from_BODY_list_copy.get());
+ from_BODY_list_copy.change_to(BODY_Ptr2);
+ from_BODY_list_copy.reset();
+ }
+ else
+ {
+ if (DEBUG_FLAG(95)) {
+ AcisQueryEngine::instance()->ACIS_API_error(result, "imprint Bodies");
+ }
- if (BODY_Ptr1)
- api_delent(BODY_Ptr1);
- if (BODY_Ptr2)
- api_delent(BODY_Ptr2);
- }
- } // if overlap
+ if (BODY_Ptr1)
+ api_delent(BODY_Ptr1);
+ if (BODY_Ptr2)
+ api_delent(BODY_Ptr2);
+ }
+ } // if overlap
- if( num_bodies > 2 )
- AppUtil::instance()->progress_tool()->step();
- }
- }
-
if( num_bodies > 2 )
- AppUtil::instance()->progress_tool()->end();
+ AppUtil::instance()->progress_tool()->step();
+ }
+ }
- if( CubitMessage::instance()->Interrupt() )
- PRINT_INFO("Imprint aborted.\n");
+ if( num_bodies > 2 )
+ AppUtil::instance()->progress_tool()->end();
- // new_ENTITIES will hold new entities that were created by
- // the imprint operation. att_ENTITIES will hold entities
- // from the original bodies that had composite attributes
- // on them. At the end we will compare the new entities
- // with the ones that had attributes and if we find matches
- // we will put a composite attribute on the new entity.
- // This is how we are handling the imprinting of bodies
- // with composites.
- DLIList<ENTITY*> new_ENTITIES;
- DLIList<ENTITY*> att_ENTITIES;
+ if( CubitMessage::instance()->Interrupt() )
+ PRINT_INFO("Imprint aborted.\n");
- // Create/update ACIS Bridges.
- for ( i = 0; i < num_bodies; i++ )
- {
- BodySM* from_body = from_body_list.next(i);
- BODY* from_BODY = from_BODY_list.next(i);
- BODY* new_BODY = from_BODY_list_copy.next(i);
- if (new_BODY)
- {
- // Get the new entities (just edges for now)
- // created by the imprint operation.
- DLIList<ENTITY*> cur_new_ENTITIES;
- if(new_tbs)
- get_new_ENTITIES(new_BODY, cur_new_ENTITIES);
+ // new_ENTITIES will hold new entities that were created by
+ // the imprint operation. att_ENTITIES will hold entities
+ // from the original bodies that had composite attributes
+ // on them. At the end we will compare the new entities
+ // with the ones that had attributes and if we find matches
+ // we will put a composite attribute on the new entity.
+ // This is how we are handling the imprinting of bodies
+ // with composites.
+ DLIList<ENTITY*> new_ENTITIES;
+ DLIList<ENTITY*> att_ENTITIES;
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(new_BODY);
+ // Create/update ACIS Bridges.
+ for ( i = 0; i < num_bodies; i++ )
+ {
+ BodySM* from_body = from_body_list.next(i);
+ BODY* from_BODY = from_BODY_list.next(i);
+ BODY* new_BODY = from_BODY_list_copy.next(i);
+ if (new_BODY)
+ {
+ // Get the new entities (just edges for now)
+ // created by the imprint operation.
+ DLIList<ENTITY*> cur_new_ENTITIES;
+ if(new_tbs)
+ get_new_ENTITIES(new_BODY, cur_new_ENTITIES);
- BodySM* new_body = get_new_Body( from_body, from_BODY, new_BODY, keep_old, true );
- if (new_body)
- {
- // Add the new entities to the list we are
- // accumulating.
- if(new_tbs)
- new_ENTITIES += cur_new_ENTITIES;
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(new_BODY);
- // Get entities with composite attributes.
- if(att_tbs)
- get_att_ENTITIES(new_BODY, att_ENTITIES, "COMPOSITE_GEOM");
+ BodySM* new_body = get_new_Body( from_body, from_BODY, new_BODY, keep_old, true );
+ if (new_body)
+ {
+ // Add the new entities to the list we are
+ // accumulating.
+ if(new_tbs)
+ new_ENTITIES += cur_new_ENTITIES;
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count--; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
- new_from_body_list.append(new_body);
- }
- else
- {
- // Get entities with composite attributes.
- if(att_tbs)
- get_att_ENTITIES(from_BODY, att_ENTITIES, "COMPOSITE_GEOM");
- }
- }
- }
+ // Get entities with composite attributes.
+ if(att_tbs)
+ get_att_ENTITIES(new_BODY, att_ENTITIES, "COMPOSITE_GEOM");
- // Convert the new_ENTITIES/att_ENTITIES lists into
- // topology bridge lists.
- if(new_tbs)
- {
- for(i=new_ENTITIES.size(); i--;)
- {
- ENTITY *cur_ENT = new_ENTITIES.get_and_step();
- AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
- if(dynamic_cast<TopologyBridge*>(acis_bridge))
- new_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
- }
- }
- if(att_tbs)
- {
- for(i=att_ENTITIES.size(); i--;)
- {
- ENTITY *cur_ENT = att_ENTITIES.get_and_step();
- AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
- if(dynamic_cast<TopologyBridge*>(acis_bridge))
- att_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
- }
- }
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count--; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
+ new_from_body_list.append(new_body);
+ }
+ else
+ {
+ // Get entities with composite attributes.
+ if(att_tbs)
+ get_att_ENTITIES(from_BODY, att_ENTITIES, "COMPOSITE_GEOM");
+ }
+ }
+ }
+ // Convert the new_ENTITIES/att_ENTITIES lists into
+ // topology bridge lists.
+ if(new_tbs)
+ {
+ for(i=new_ENTITIES.size(); i--;)
+ {
+ ENTITY *cur_ENT = new_ENTITIES.get_and_step();
+ AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
+ if(dynamic_cast<TopologyBridge*>(acis_bridge))
+ new_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
+ }
+ }
+ if(att_tbs)
+ {
+ for(i=att_ENTITIES.size(); i--;)
+ {
+ ENTITY *cur_ENT = att_ENTITIES.get_and_step();
+ AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
+ if(dynamic_cast<TopologyBridge*>(acis_bridge))
+ att_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
+ }
+ }
- PRINT_INFO("Group imprint finished.\n");
- // reset the free_edges acis option
- api_set_int_option("all_free_edges", FALSE );
+ PRINT_INFO("Group imprint finished.\n");
- return success;
- }
+ // reset the free_edges acis option
+ api_set_int_option("all_free_edges", FALSE );
- //-------------------------------------------------------------------------
- // Purpose : Projects an EDGE to a FACE
- //
- // Special Notes :
- //
- //
- // Creator : Eric Nielsen
- //
- // Creation Date : 06/14/00
- //-------------------------------------------------------------------------
- EDGE* AcisModifyEngine::project_EDGE(EDGE* EDGE_in_ptr, FACE* FACE_ptr, bool print_error ) const
- {
- curve* in_crv=NULL;
- surface *in_srf=NULL;
- curve * out_crv = NULL;
- EDGE * new_EDGE = NULL;
+ return success;
+}
- if(FACE_ptr && FACE_ptr->geometry())
- {
- SPAtransf t= get_owner_transf(FACE_ptr);
- in_srf = FACE_ptr->geometry()->trans_surface(t);
- }
+//-------------------------------------------------------------------------
+// Purpose : Projects an EDGE to a FACE
+//
+// Special Notes :
+//
+//
+// Creator : Eric Nielsen
+//
+// Creation Date : 06/14/00
+//-------------------------------------------------------------------------
+EDGE* AcisModifyEngine::project_EDGE(EDGE* EDGE_in_ptr, FACE* FACE_ptr, bool print_error ) const
+{
+ curve* in_crv=NULL;
+ surface *in_srf=NULL;
+ curve * out_crv = NULL;
+ EDGE * new_EDGE = NULL;
- if(EDGE_in_ptr && EDGE_in_ptr->geometry())
- {
- SPAtransf t= get_owner_transf(EDGE_in_ptr);
- in_crv = EDGE_in_ptr->geometry()->trans_curve(t);
- }
+ if(FACE_ptr && FACE_ptr->geometry())
+ {
+ SPAtransf t= get_owner_transf(FACE_ptr);
+ in_srf = FACE_ptr->geometry()->trans_surface(t);
+ }
- if(in_crv && in_srf)
- {
- // create the curve
- SPAinterval in_range = EDGE_in_ptr->param_range();
+ if(EDGE_in_ptr && EDGE_in_ptr->geometry())
+ {
+ SPAtransf t= get_owner_transf(EDGE_in_ptr);
+ in_crv = EDGE_in_ptr->geometry()->trans_curve(t);
+ }
- if( EDGE_in_ptr->sense() )
- in_range.negate();
+ if(in_crv && in_srf)
+ {
+ // create the curve
+ SPAinterval in_range = EDGE_in_ptr->param_range();
- outcome result = api_project_curve_to_surface(*in_crv, in_range, *in_srf, out_crv);
+ if( EDGE_in_ptr->sense() )
+ in_range.negate();
- if (!result.ok() || out_crv == NULL) //out_crv check added 6/18/04 by aga at cat
- //api CAN return a null curve in some failures- if so we'll end the fcn here and return
- {
- if( print_error )
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "api_project_curve_to_surface failed ");
- }
- return (EDGE *)NULL;
- }
+ outcome result = api_project_curve_to_surface(*in_crv, in_range, *in_srf, out_crv);
- // create the CURVE
- CURVE *the_curve=make_curve(*out_crv);
+ if (!result.ok() || out_crv == NULL) //out_crv check added 6/18/04 by aga at cat
+ //api CAN return a null curve in some failures- if so we'll end the fcn here and return
+ {
+ if( print_error )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "api_project_curve_to_surface failed ");
+ }
+ return (EDGE *)NULL;
+ }
- // get ends of the edge
- SPAposition pt0=out_crv->eval_position(in_range.start_pt());
- SPAposition pt1=out_crv->eval_position(in_range.end_pt());
+ // create the CURVE
+ CURVE *the_curve=make_curve(*out_crv);
- ACIS_DELETE out_crv;
+ // get ends of the edge
+ SPAposition pt0=out_crv->eval_position(in_range.start_pt());
+ SPAposition pt1=out_crv->eval_position(in_range.end_pt());
- // create the vertices
- VERTEX *svert= ACIS_NEW VERTEX( ACIS_NEW APOINT(pt0));
+ ACIS_DELETE out_crv;
- // -- check for a closed edge
- VERTEX *evert= NULL;
- if ( pt0 != pt1 )
- evert = ACIS_NEW VERTEX( ACIS_NEW APOINT(pt1));
- else
- evert = svert;
+ // create the vertices
+ VERTEX *svert= ACIS_NEW VERTEX( ACIS_NEW APOINT(pt0));
- // make the edge
- new_EDGE= ACIS_NEW EDGE(svert,evert,the_curve,FORWARD,EDGE_cvty_unknown,in_range);
- }
+ // -- check for a closed edge
+ VERTEX *evert= NULL;
+ if ( pt0 != pt1 )
+ evert = ACIS_NEW VERTEX( ACIS_NEW APOINT(pt1));
+ else
+ evert = svert;
- if(in_crv)
- ACIS_DELETE in_crv;
- if(in_srf)
- ACIS_DELETE in_srf;
+ // make the edge
+ new_EDGE= ACIS_NEW EDGE(svert,evert,the_curve,FORWARD,EDGE_cvty_unknown,in_range);
+ }
- if(new_EDGE)
- {
- ENTITY *edge_entity = (ENTITY*)new_EDGE;
- api_simplify_entity( edge_entity );
- return new_EDGE;
- }
- else
- return (EDGE *)NULL;
- }
+ if(in_crv)
+ ACIS_DELETE in_crv;
+ if(in_srf)
+ ACIS_DELETE in_srf;
- //-------------------------------------------------------------------------
- // Purpose : Projects a list of RefEdges on to a list of RefFaces
- // returning a list of new RefEdges
- //
- // Special Notes :
- //
- //
- // Creator : Eric Nielsen
- //
- // Creation Date : 06/14/00
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::project_edges( DLIList<Surface*> &ref_face_list,
- DLIList<Curve*> &ref_edge_list_in,
- DLIList<Curve*> &ref_edge_list_new,
- bool print_error ) const
- {
- Curve* ref_edge = NULL;
- Surface* ref_face = NULL;
- EDGE *new_EDGE_ptr = NULL;
+ if(new_EDGE)
+ {
+ ENTITY *edge_entity = (ENTITY*)new_EDGE;
+ api_simplify_entity( edge_entity );
+ return new_EDGE;
+ }
+ else
+ return (EDGE *)NULL;
+}
- for(int j=0; j< ref_face_list.size(); j++)
- {
- ref_face = ref_face_list.get_and_step();
+//-------------------------------------------------------------------------
+// Purpose : Projects a list of RefEdges on to a list of RefFaces
+// returning a list of new RefEdges
+//
+// Special Notes :
+//
+//
+// Creator : Eric Nielsen
+//
+// Creation Date : 06/14/00
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::project_edges( DLIList<Surface*> &ref_face_list,
+ DLIList<Curve*> &ref_edge_list_in,
+ DLIList<Curve*> &ref_edge_list_new,
+ bool print_error ) const
+{
+ Curve* ref_edge = NULL;
+ Surface* ref_face = NULL;
+ EDGE *new_EDGE_ptr = NULL;
- FACE *FACE_ptr = AcisQueryEngine::get_FACE( ref_face );
+ for(int j=0; j< ref_face_list.size(); j++)
+ {
+ ref_face = ref_face_list.get_and_step();
- for(int i=0; i< ref_edge_list_in.size(); i++)
- {
- ref_edge = ref_edge_list_in.get_and_step();
+ FACE *FACE_ptr = AcisQueryEngine::get_FACE( ref_face );
- EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge);
+ for(int i=0; i< ref_edge_list_in.size(); i++)
+ {
+ ref_edge = ref_edge_list_in.get_and_step();
- new_EDGE_ptr = project_EDGE(EDGE_ptr,FACE_ptr, print_error );
+ EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge);
- if (!new_EDGE_ptr)
- {
- if( print_error )
- PRINT_ERROR( "Unable to project curve on surface\n" );
- continue;
- }
- else{
- Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
- ref_edge_list_new.append(curve_ptr);
- }
+ new_EDGE_ptr = project_EDGE(EDGE_ptr,FACE_ptr, print_error );
- }
- }
+ if (!new_EDGE_ptr)
+ {
+ if( print_error )
+ PRINT_ERROR( "Unable to project curve on surface\n" );
+ continue;
+ }
+ else{
+ Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
+ ref_edge_list_new.append(curve_ptr);
+ }
- if (ref_edge_list_new.size() == ref_edge_list_in.size())
- return CUBIT_SUCCESS;
- else
- return CUBIT_FAILURE;
}
+ }
- //-------------------------------------------------------------------------
- // Purpose : Projects a list of RefEdges on to a list of RefFaces
- // and imprint the faces with the new RefEdges
- //
- // Special Notes :
- //
- //
- // Creator : Eric Nielsen
- //
- // Creation Date : 06/14/00
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::imprint_projected_edges(DLIList<Surface*> &ref_face_list,
- DLIList<Curve*> &ref_edge_list_in,
- DLIList<BodySM*>& new_body_list,
- bool keep_old_body,
- bool keep_free_edges) const
- {
- CubitStatus status;
+ if (ref_edge_list_new.size() == ref_edge_list_in.size())
+ return CUBIT_SUCCESS;
+ else
+ return CUBIT_FAILURE;
+}
- DLIList<Curve*> ref_edge_list_new;
+//-------------------------------------------------------------------------
+// Purpose : Projects a list of RefEdges on to a list of RefFaces
+// and imprint the faces with the new RefEdges
+//
+// Special Notes :
+//
+//
+// Creator : Eric Nielsen
+//
+// Creation Date : 06/14/00
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::imprint_projected_edges(DLIList<Surface*> &ref_face_list,
+ DLIList<Curve*> &ref_edge_list_in,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool keep_free_edges) const
+{
+ CubitStatus status;
- project_edges(ref_face_list, ref_edge_list_in, ref_edge_list_new);
+ DLIList<Curve*> ref_edge_list_new;
- // imprint Surface with curves
- status = imprint(ref_face_list, ref_edge_list_new, new_body_list, keep_old_body );
+ project_edges(ref_face_list, ref_edge_list_in, ref_edge_list_new);
- if (keep_free_edges)
- return status;
+ // imprint Surface with curves
+ status = imprint(ref_face_list, ref_edge_list_new, new_body_list, keep_old_body );
- PRINT_INFO( "Removing projected curves \n");
- for(int i=0; i< ref_edge_list_new.size();i++){
- // Now delete this RefEdge and its underlying solid model entities
+ if (keep_free_edges)
+ return status;
- Curve* ref_edge = ref_edge_list_new.get_and_step();
- status = AcisQueryEngine::instance()->
- delete_solid_model_entities( ref_edge );
- if (status == CUBIT_FAILURE)
- {
- PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
- " Could not delete RefEdge.\n"
- " The Model database is likely corrupted "
- "due to\n this unsuccessful deletion.\n" );
- }
- }
- return status;
- }
+ PRINT_INFO( "Removing projected curves \n");
+ for(int i=0; i< ref_edge_list_new.size();i++){
+ // Now delete this RefEdge and its underlying solid model entities
- //-------------------------------------------------------------------------
- // Purpose : Projects a list of RefEdges on to a list of RefFaces
- // and imprint the bodies with the new RefEdges
- //
- // Special Notes :
- //
- //
- // Creator : Eric Nielsen
- //
- // Creation Date : 06/14/00
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::imprint_projected_edges(DLIList<Surface*> &ref_face_list,
- DLIList<BodySM*> &body_list,
- DLIList<Curve*> &ref_edge_list_in,
- DLIList<BodySM*>& new_body_list,
- bool keep_old_body,
- bool keep_free_edges) const
+ Curve* ref_edge = ref_edge_list_new.get_and_step();
+ status = AcisQueryEngine::instance()->
+ delete_solid_model_entities( ref_edge );
+ if (status == CUBIT_FAILURE)
{
- CubitStatus status;
+ PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
+ " Could not delete RefEdge.\n"
+ " The Model database is likely corrupted "
+ "due to\n this unsuccessful deletion.\n" );
+ }
+ }
+ return status;
+}
- DLIList<Curve*> ref_edge_list_new;
+//-------------------------------------------------------------------------
+// Purpose : Projects a list of RefEdges on to a list of RefFaces
+// and imprint the bodies with the new RefEdges
+//
+// Special Notes :
+//
+//
+// Creator : Eric Nielsen
+//
+// Creation Date : 06/14/00
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::imprint_projected_edges(DLIList<Surface*> &ref_face_list,
+ DLIList<BodySM*> &body_list,
+ DLIList<Curve*> &ref_edge_list_in,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool keep_free_edges) const
+{
+ CubitStatus status;
- project_edges(ref_face_list, ref_edge_list_in, ref_edge_list_new);
+ DLIList<Curve*> ref_edge_list_new;
- // imprint bodies with curves
- status = imprint(body_list,ref_edge_list_new,new_body_list, keep_old_body );
+ project_edges(ref_face_list, ref_edge_list_in, ref_edge_list_new);
- if (keep_free_edges)
- return status;
+ // imprint bodies with curves
+ status = imprint(body_list,ref_edge_list_new,new_body_list, keep_old_body );
- PRINT_INFO( "Removing projected curves \n");
- for(int i=0; i< ref_edge_list_new.size();i++){
- // Now delete this RefEdge and its underlying solid model entities
+ if (keep_free_edges)
+ return status;
- Curve* ref_edge = ref_edge_list_new.get_and_step();
- status = AcisQueryEngine::instance()->
- delete_solid_model_entities( ref_edge );
- if (status == CUBIT_FAILURE)
- {
- PRINT_ERROR("In GeometryModifyTool::delete_geometry\n"
- " Could not delete RefEdge.\n"
- " The Model database is likely corrupted "
- "due to\n this unsuccessful deletion.\n" );
- }
- }
- return status;
+ PRINT_INFO( "Removing projected curves \n");
+ for(int i=0; i< ref_edge_list_new.size();i++){
+ // Now delete this RefEdge and its underlying solid model entities
+
+ Curve* ref_edge = ref_edge_list_new.get_and_step();
+ status = AcisQueryEngine::instance()->
+ delete_solid_model_entities( ref_edge );
+ if (status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("In GeometryModifyTool::delete_geometry\n"
+ " Could not delete RefEdge.\n"
+ " The Model database is likely corrupted "
+ "due to\n this unsuccessful deletion.\n" );
}
+ }
+ return status;
+}
- //-------------------------------------------------------------------------
- // Purpose : Boolean Operation of body with list of bodies.
- //
- // Special Notes : INTERSECTION
- //
- // Creator : David White
- //
- // Creation Date : 11/24/97
- //------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::intersect( BodySM* tool_body,
+//-------------------------------------------------------------------------
+// Purpose : Boolean Operation of body with list of bodies.
+//
+// Special Notes : INTERSECTION
+//
+// Creator : David White
+//
+// Creation Date : 11/24/97
+//------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::intersect( BodySM* tool_body,
DLIList<BodySM*> &from_bodies,
DLIList<BodySM*> &new_from_bodies,
bool keep_old) const
- {
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+{
+ // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
+ // old bodies, we want to keep the owner attrib, so we can pick up entities
+ // that didn't change
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
- int ii;
- CubitBox tool_box = AcisQueryEngine::instance()->bounding_box(tool_body);
+ int ii;
+ CubitBox tool_box = AcisQueryEngine::instance()->bounding_box(tool_body);
- DLIList<BODY*> from_BODY_list;
- DLIList<BODY*> from_BODY_list_copy;
+ DLIList<BODY*> from_BODY_list;
+ DLIList<BODY*> from_BODY_list_copy;
- // get acis bodies, and copy them
- from_bodies.reset();
+ // get acis bodies, and copy them
+ from_bodies.reset();
- for (ii = from_bodies.size(); ii > 0; ii--) {
- BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_bodies.get_and_step());
- from_BODY_list.append(BODYPtr1);
- BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
- from_BODY_list_copy.append(BODYPtr1);
- }
+ for (ii = from_bodies.size(); ii > 0; ii--) {
+ BODY *BODYPtr1 = AcisQueryEngine::get_BODY(from_bodies.get_and_step());
+ from_BODY_list.append(BODYPtr1);
+ BODYPtr1 = this->copy_BODY(BODYPtr1, delete_attribs);
+ from_BODY_list_copy.append(BODYPtr1);
+ }
- if (from_BODY_list.size() != from_bodies.size())
- return CUBIT_FAILURE;
+ if (from_BODY_list.size() != from_bodies.size())
+ return CUBIT_FAILURE;
- // check if the boolean operation is regularized or nonregularized
- BOOL_TYPE bool_type = INTERSECTION;
- CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
+ // check if the boolean operation is regularized or nonregularized
+ BOOL_TYPE bool_type = INTERSECTION;
+ CubitBoolean boolean_regularize = GeometryModifyTool::instance()->boolean_regularize();
- if (boolean_regularize == FALSE)
- {
- bool_type = NONREG_INTERSECTION;
- }
+ if (boolean_regularize == FALSE)
+ {
+ bool_type = NONREG_INTERSECTION;
+ }
- // now, intersect the tool with the list of bodies
- from_BODY_list.reset();
- from_BODY_list_copy.reset();
- from_bodies.reset();
+ // now, intersect the tool with the list of bodies
+ from_BODY_list.reset();
+ from_BODY_list_copy.reset();
+ from_bodies.reset();
- CubitStatus int_stat = CUBIT_SUCCESS;
+ CubitStatus int_stat = CUBIT_SUCCESS;
- // intersect the tool body with each body in the list
- for (ii = 1; ii <= from_BODY_list.size(); ii++) {
- BODY *from_BODY = from_BODY_list.get();
- BODY *from_BODY_copy = from_BODY_list_copy.get();
- BodySM *from_Body = from_bodies.get();
- CubitBox box1 = AcisQueryEngine::instance()->bounding_box(from_Body);
+ // intersect the tool body with each body in the list
+ for (ii = 1; ii <= from_BODY_list.size(); ii++) {
+ BODY *from_BODY = from_BODY_list.get();
+ BODY *from_BODY_copy = from_BODY_list_copy.get();
+ BodySM *from_Body = from_bodies.get();
+ CubitBox box1 = AcisQueryEngine::instance()->bounding_box(from_Body);
- // first, check bounding SPAbox; if they don't intersect, don't do the intersection
+ // first, check bounding SPAbox; if they don't intersect, don't do the intersection
- if (from_Body == tool_body) {
- PRINT_ERROR("Can't intersect volume with itself.\n");
- }
+ if (from_Body == tool_body) {
+ PRINT_ERROR("Can't intersect volume with itself.\n");
+ }
- else if (tool_box.overlap(SPAresabs, box1)) {
+ else if (tool_box.overlap(SPAresabs, box1)) {
- // the bodies overlap; proceed with the intersect
- BODY* tool_BODY = AcisQueryEngine::get_BODY(tool_body);
- BODY *tool_BODY_copy = this->copy_BODY(tool_BODY);
+ // the bodies overlap; proceed with the intersect
+ BODY* tool_BODY = AcisQueryEngine::get_BODY(tool_body);
+ BODY *tool_BODY_copy = this->copy_BODY(tool_BODY);
- // Intersect body1 with body2.
- //outcome result = api_intersect( tool_BODY_copy, from_BODY_copy );
- outcome result = api_boolean(tool_BODY_copy, from_BODY_copy, bool_type );
+ // Intersect body1 with body2.
+ //outcome result = api_intersect( tool_BODY_copy, from_BODY_copy );
+ outcome result = api_boolean(tool_BODY_copy, from_BODY_copy, bool_type );
- // We may or may not get an error if the resulting BODY is
- // empty
- // Also check the result.
- if (from_BODY_copy == NULL ||
- (from_BODY_copy->lump() == NULL && from_BODY_copy->wire() == NULL) ||
- !result.ok())
- {
- if (!result.ok())
- {
- PRINT_ERROR("Intersection operation failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result, "intersect Bodies");
- int_stat = CUBIT_FAILURE;
+ // We may or may not get an error if the resulting BODY is
+ // empty
+ // Also check the result.
+ if (from_BODY_copy == NULL ||
+ (from_BODY_copy->lump() == NULL && from_BODY_copy->wire() == NULL) ||
+ !result.ok())
+ {
+ if (!result.ok())
+ {
+ PRINT_ERROR("Intersection operation failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "intersect Bodies");
+ int_stat = CUBIT_FAILURE;
- //I might need to take this out. Not sure. CDE 10/17/2003
- if (tool_BODY_copy != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_copy, CUBIT_TRUE);
- }
- }
- else
- PRINT_ERROR("Intersection operation failed.\n"
- " Empty volume created and will be deleted.\n");
- if (from_BODY_copy != NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
- }
+ //I might need to take this out. Not sure. CDE 10/17/2003
+ if (tool_BODY_copy != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(tool_BODY_copy, CUBIT_TRUE);
+ }
+ }
+ else
+ PRINT_ERROR("Intersection operation failed.\n"
+ " Empty volume created and will be deleted.\n");
+ if (from_BODY_copy != NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
+ }
- // we had an error, so put the original body into the copy list
- from_BODY_list_copy.change_to(from_BODY);
- }
+ // we had an error, so put the original body into the copy list
+ from_BODY_list_copy.change_to(from_BODY);
+ }
- if ( bool_type == NONREG_INTERSECTION)
- {
- outcome result1;
- // ENTITY_LIST FACES;
- DLIList<FACE*> FACE_list ;
- FACE *this_FACE;
- AcisQueryEngine::instance()->get_FACEs(from_BODY_copy,FACE_list);
- // loop through all faces
- for( int i = 0; i< FACE_list.size(); i++)
- {
- this_FACE = FACE_list.get_and_step();
- assert( this_FACE != NULL );
- // Make sure this is a DOUBLE_SIDED FACE
- if (this_FACE->sides() == DOUBLE_SIDED)
+ if ( bool_type == NONREG_INTERSECTION)
+ {
+ outcome result1;
+ // ENTITY_LIST FACES;
+ DLIList<FACE*> FACE_list ;
+ FACE *this_FACE;
+ AcisQueryEngine::instance()->get_FACEs(from_BODY_copy,FACE_list);
+ // loop through all faces
+ for( int i = 0; i< FACE_list.size(); i++)
{
- if (this_FACE->cont()==BOTH_INSIDE)
- {
- // found internal faces
- // Now we have the FACE - unhook it from the BODY. Keep track of new
- // BODIES that are created as this is done.
- PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
- BODY *new_BODY_ptr;
- result1 = api_unhook_face( this_FACE, new_BODY_ptr );
- if( !result1.ok() )
+ this_FACE = FACE_list.get_and_step();
+ assert( this_FACE != NULL );
+ // Make sure this is a DOUBLE_SIDED FACE
+ if (this_FACE->sides() == DOUBLE_SIDED)
{
- AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
- PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
- return CUBIT_FAILURE;
+ if (this_FACE->cont()==BOTH_INSIDE)
+ {
+ // found internal faces
+ // Now we have the FACE - unhook it from the BODY. Keep track of new
+ // BODIES that are created as this is done.
+ PRINT_INFO( " Unhooking and deleting each internal surface...\n" );
+ BODY *new_BODY_ptr;
+ result1 = api_unhook_face( this_FACE, new_BODY_ptr );
+ if( !result1.ok() )
+ {
+ AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result1 );
+ PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
+ return CUBIT_FAILURE;
+ }
+ AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
+ }
}
- AcisQueryEngine::instance()->delete_ACIS_BODY (new_BODY_ptr);
- }
}
- }
- // heal the leftover body
- //
- // PRINT_INFO(" Healing the leftover volume...\n");
- // if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
- // {
- // int percent_before, percent_after, number_splines_simplified;
- // if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
- // percent_after, number_splines_simplified ) == CUBIT_FAILURE )
- // PRINT_ERROR( "Error healing the combined volume\n" );
- // else
- // PRINT_INFO( "Successfully healed the combined volume.\n" );
- // AcisHealerTool::instance()->end_BODY_for_healing( master );
- // }
+ // heal the leftover body
+//
+// PRINT_INFO(" Healing the leftover volume...\n");
+// if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
+// {
+// int percent_before, percent_after, number_splines_simplified;
+// if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
+// percent_after, number_splines_simplified ) == CUBIT_FAILURE )
+// PRINT_ERROR( "Error healing the combined volume\n" );
+// else
+// PRINT_INFO( "Successfully healed the combined volume.\n" );
+// AcisHealerTool::instance()->end_BODY_for_healing( master );
+// }
}
- // done with this j iteration; write out count, if necessary
- // if (from_bodies.size() > 1) {
- // int frac_done = (10 * ii) / from_bodies.size();
- // if ((10 - frac_done) < fraction_remaining) {
- // PRINT_INFO("%d ", fraction_remaining);
- // fraction_remaining--;
- // }
- // }
- }
+ // done with this j iteration; write out count, if necessary
+// if (from_bodies.size() > 1) {
+// int frac_done = (10 * ii) / from_bodies.size();
+// if ((10 - frac_done) < fraction_remaining) {
+// PRINT_INFO("%d ", fraction_remaining);
+// fraction_remaining--;
+// }
+// }
+ }
- else {
- AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
- from_BODY_list_copy.change_to(from_BODY);
- }
+ else {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(from_BODY_copy, CUBIT_TRUE);
+ from_BODY_list_copy.change_to(from_BODY);
+ }
- // done with iteration over ii; step the lists
- from_BODY_list_copy.step();
- from_BODY_list.step();
- from_bodies.step();
- }
+ // done with iteration over ii; step the lists
+ from_BODY_list_copy.step();
+ from_BODY_list.step();
+ from_bodies.step();
+ }
- // PRINT_INFO("\n");
+// PRINT_INFO("\n");
- // ok, we're done; construct new Body's for the new BODY's
- from_BODY_list_copy.reset();
- from_BODY_list.reset();
- from_bodies.reset();
+ // ok, we're done; construct new Body's for the new BODY's
+ from_BODY_list_copy.reset();
+ from_BODY_list.reset();
+ from_bodies.reset();
- for (ii = from_BODY_list_copy.size(); ii > 0; ii--) {
+ for (ii = from_BODY_list_copy.size(); ii > 0; ii--) {
- BODY *old_BODY = from_BODY_list.get();
- BODY *new_BODY = from_BODY_list_copy.get();
+ BODY *old_BODY = from_BODY_list.get();
+ BODY *new_BODY = from_BODY_list_copy.get();
- BodySM *new_body = NULL;
- if (old_BODY != new_BODY)
- new_body = get_new_Body(from_bodies.get(), old_BODY, new_BODY, keep_old);
- else if (!keep_old && int_stat == CUBIT_SUCCESS) {
- //GeometryQueryTool::instance()->delete_Body(from_bodies.get());
- AcisQueryEngine::instance()->delete_solid_model_entities(from_bodies.get());
- from_bodies.change_to(NULL);
- }
+ BodySM *new_body = NULL;
+ if (old_BODY != new_BODY)
+ new_body = get_new_Body(from_bodies.get(), old_BODY, new_BODY, keep_old);
+ else if (!keep_old && int_stat == CUBIT_SUCCESS) {
+ //GeometryQueryTool::instance()->delete_Body(from_bodies.get());
+ AcisQueryEngine::instance()->delete_solid_model_entities(from_bodies.get());
+ from_bodies.change_to(NULL);
+ }
- if (new_body) {
- new_from_bodies.append(new_body);
- from_bodies.change_to(NULL);
- }
+ if (new_body) {
+ new_from_bodies.append(new_body);
+ from_bodies.change_to(NULL);
+ }
- // now step all the lists
- from_BODY_list.step();
- from_BODY_list_copy.step();
- from_bodies.step();
- }
+ // now step all the lists
+ from_BODY_list.step();
+ from_BODY_list_copy.step();
+ from_bodies.step();
+ }
- from_bodies.remove_all_with_value(NULL);
- from_bodies.reset();
- new_from_bodies.reset();
+ from_bodies.remove_all_with_value(NULL);
+ from_bodies.reset();
+ new_from_bodies.reset();
- if (int_stat == CUBIT_SUCCESS && !keep_old )
- //GeometryQueryTool::instance()->delete_Body(tool_body);
- AcisQueryEngine::instance()->delete_solid_model_entities(tool_body);
- /*
- // write the message about bodies kept and not kept
- //NOTE TO JS:
- PRINT_INFO("Intersect finished; \n"
- "Old bodies retained: ");
- if (from_bodies.size() > 0) {
- for (ii = from_bodies.size(); ii > 0; ii--)
+ if (int_stat == CUBIT_SUCCESS && !keep_old )
+ //GeometryQueryTool::instance()->delete_Body(tool_body);
+ AcisQueryEngine::instance()->delete_solid_model_entities(tool_body);
+/*
+ // write the message about bodies kept and not kept
+//NOTE TO JS:
+ PRINT_INFO("Intersect finished; \n"
+ "Old bodies retained: ");
+ if (from_bodies.size() > 0) {
+ for (ii = from_bodies.size(); ii > 0; ii--)
PRINT_INFO("%d ", from_bodies.get_and_step()->id());
- }
- else {
- PRINT_INFO(" (none)");
- }
+ }
+ else {
+ PRINT_INFO(" (none)");
+ }
- PRINT_INFO("\n");
+ PRINT_INFO("\n");
- //NOTE TO JS:
- PRINT_INFO("New bodies created: ");
- if (new_from_bodies.size() > 0) {
- for (ii = new_from_bodies.size(); ii > 0; ii--)
+//NOTE TO JS:
+ PRINT_INFO("New bodies created: ");
+ if (new_from_bodies.size() > 0) {
+ for (ii = new_from_bodies.size(); ii > 0; ii--)
PRINT_INFO("%d ", new_from_bodies.get_and_step()->id());
- }
- else {
- PRINT_INFO(" (none)");
- }
- PRINT_INFO("\n");
- */
- return CUBIT_SUCCESS;
- }
+ }
+ else {
+ PRINT_INFO(" (none)");
+ }
+ PRINT_INFO("\n");
+*/
+ return CUBIT_SUCCESS;
+}
//-------------------------------------------------------------------------
// Purpose : Perform a rotational sweep
@@ -8092,19 +8087,19 @@
BodySM* stop_body) const
{
- DLIList<FACE*> FACEs_to_be_swept_list;
- DLIList<EDGE*> EDGEs_to_be_swept_list;
- DLIList<Surface*> ref_faces_list;
- DLIList<Curve*> ref_edges_list;
+ DLIList<FACE*> FACEs_to_be_swept_list;
+ DLIList<EDGE*> EDGEs_to_be_swept_list;
+ DLIList<Surface*> ref_faces_list;
+ DLIList<Curve*> ref_edges_list;
- // First get the ACIS FACEs associated with the input RefFaces
- //DLIList<FACE*> temp_faces;
- int i;
- for (i = ref_ent_list.size(); i > 0; i--)
- {
- GeometryEntity *ref_ent = ref_ent_list.get_and_step();
- Surface *ref_face = CAST_TO(ref_ent, Surface);
- Curve* ref_edge = CAST_TO(ref_ent, Curve);
+ // First get the ACIS FACEs associated with the input RefFaces
+ //DLIList<FACE*> temp_faces;
+ int i;
+ for (i = ref_ent_list.size(); i > 0; i--)
+ {
+ GeometryEntity *ref_ent = ref_ent_list.get_and_step();
+ Surface *ref_face = CAST_TO(ref_ent, Surface);
+ Curve* ref_edge = CAST_TO(ref_ent, Curve);
if(ref_face != NULL)
{
@@ -8157,102 +8152,102 @@
ref_faces_list.reset();
// Next, call ACIS to do the real work for each of the FACEs in the list!!
- FACEs_to_be_swept_list.reset();
- EDGEs_to_be_swept_list.reset();
- FACE* FACE_ptr = NULL;
- FACE* copied_FACE_ptr = NULL;
- EDGE* copied_EDGE_ptr = NULL;
- Surface* refface_ptr = NULL;
- BodySM* body_ptr = NULL;
- BODY* BODY_ptr = NULL;
- BODY* copy_of_original_BODY_ptr = NULL;
- bool primary_side = true;
- bool skip_loop = false;
- CubitStatus sweep_status = CUBIT_FAILURE;
- for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
- {
- skip_loop = CUBIT_FALSE;
- copied_FACE_ptr = NULL;
+ FACEs_to_be_swept_list.reset();
+ EDGEs_to_be_swept_list.reset();
+ FACE* FACE_ptr = NULL;
+ FACE* copied_FACE_ptr = NULL;
+ EDGE* copied_EDGE_ptr = NULL;
+ Surface* refface_ptr = NULL;
+ BodySM* body_ptr = NULL;
+ BODY* BODY_ptr = NULL;
+ BODY* copy_of_original_BODY_ptr = NULL;
+ bool primary_side = true;
+ bool skip_loop = false;
+ CubitStatus sweep_status = CUBIT_FAILURE;
+ for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
+ {
+ skip_loop = CUBIT_FALSE;
+ copied_FACE_ptr = NULL;
- // Get the RefFace we're going to sweep
- GeometryEntity* ref_ent = ref_ent_list.get_and_step();
- refface_ptr = CAST_TO(ref_ent, Surface);
- if(make_solid)
- {
- PRINT_WARNING("The make_solid option is ignored for surface\n");
- }
+ // Get the RefFace we're going to sweep
+ GeometryEntity* ref_ent = ref_ent_list.get_and_step();
+ refface_ptr = CAST_TO(ref_ent, Surface);
+ if(make_solid)
+ {
+ PRINT_WARNING("The make_solid option is ignored for surface\n");
+ }
- // Get the FACE we're going to sweep
- FACE_ptr = FACEs_to_be_swept_list.get_and_step();
+ // Get the FACE we're going to sweep
+ FACE_ptr = FACEs_to_be_swept_list.get_and_step();
- // If the FACE is DOUBLE-SIDED; deal with the switchside option
- if (FACE_ptr->sides() && switchside)
- {
- primary_side = CUBIT_FALSE;
- }
+ // If the FACE is DOUBLE-SIDED; deal with the switchside option
+ if (FACE_ptr->sides() && switchside)
+ {
+ primary_side = CUBIT_FALSE;
+ }
- // Make sure the FACE has a plane surface as it's underlying geometry
- if (FACE_ptr->geometry()->equation().type() != plane_type)
- {
- PRINT_ERROR("One of the surfaces being swept is not planar.\n"
- " Skipping to the next surface.\n");
- skip_loop = CUBIT_TRUE;
- }
+ // Make sure the FACE has a plane surface as it's underlying geometry
+ if (FACE_ptr->geometry()->equation().type() != plane_type)
+ {
+ PRINT_ERROR("One of the surfaces being swept is not planar.\n"
+ " Skipping to the next surface.\n");
+ skip_loop = CUBIT_TRUE;
+ }
- // If this FACE is planar, continue
- if( !skip_loop )
- {
- // Get the associated Body and it's ACIS BODY
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
- if (body_ptr != NULL)
- {
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // If this FACE is planar, continue
+ if( !skip_loop )
+ {
+ // Get the associated Body and it's ACIS BODY
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
+ if (body_ptr != NULL)
+ {
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- // Make sure we have a valid ACIS BODY associated with this Body
- // and FACE
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ // Make sure we have a valid ACIS BODY associated with this Body
+ // and FACE
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- else
- {
- PRINT_WARNING("No volume associated with this surface.\n"
- " Sweeping will continue with the ACIS BODY.\n");
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ else
+ {
+ PRINT_WARNING("No volume associated with this surface.\n"
+ " Sweeping will continue with the ACIS BODY.\n");
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- // If there were no problems finding an associated ACIS BODY, proceed
- if( !skip_loop )
- {
- // Make a copy of the original BODY before doing the sweep.
- // We will perform the sweep on the copy, not on the original body.
- copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr,
- CUBIT_FALSE);
+ // If there were no problems finding an associated ACIS BODY, proceed
+ if( !skip_loop )
+ {
+ // Make a copy of the original BODY before doing the sweep.
+ // We will perform the sweep on the copy, not on the original body.
+ copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr,
+ CUBIT_FALSE);
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- if (copy_of_original_BODY_ptr)
- {
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
- get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr) );
- }
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ if (copy_of_original_BODY_ptr)
+ {
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
+ get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr) );
+ }
- if (copied_FACE_ptr)
- {
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ if (copied_FACE_ptr)
+ {
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
// Rotate the FACE about the axis, sweep_vector.
int reverse_failed = CUBIT_FALSE;
@@ -8436,43 +8431,43 @@
}
- for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
- {
- // Get the EDGE we're going to sweep
- copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
+ for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
+ {
+ // Get the EDGE we're going to sweep
+ copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
- BODY* new_BODY_ptr = NULL;
- sweep_status = sweep_EDGE_about_axis( copied_EDGE_ptr,
- new_BODY_ptr,
- sweep_axis,
- point,
- angle,
- steps,
- draft_angle,
- draft_type,
- make_solid,
- rigid,
- stop_FACE);
+ BODY* new_BODY_ptr = NULL;
+ sweep_status = sweep_EDGE_about_axis( copied_EDGE_ptr,
+ new_BODY_ptr,
+ sweep_axis,
+ point,
+ angle,
+ steps,
+ draft_angle,
+ draft_type,
+ make_solid,
+ rigid,
+ stop_FACE);
- if(sweep_status == CUBIT_FAILURE)
- {
- PRINT_ERROR("Problem sweeping curve.\n");
- continue;
- }
+ if(sweep_status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("Problem sweeping curve.\n");
+ continue;
+ }
- BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
- new_BODY_ptr,
- CUBIT_FALSE, CUBIT_FALSE);
- if (new_body_ptr)
- {
- result_body_list.append(new_body_ptr);
- sweep_status = CUBIT_SUCCESS;
- }
- } // End of i loop, iterating over EDGEs_to_be_swept_list
-
- return sweep_status;
+ BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
+ new_BODY_ptr,
+ CUBIT_FALSE, CUBIT_FALSE);
+ if (new_body_ptr)
+ {
+ result_body_list.append(new_body_ptr);
+ sweep_status = CUBIT_SUCCESS;
}
+ } // End of i loop, iterating over EDGEs_to_be_swept_list
+ return sweep_status;
+}
+
//-------------------------------------------------------------------------
// Purpose : Perform a translational sweep operation
//
@@ -8547,95 +8542,95 @@
}
- ref_edges_list.reset();
- ref_faces_list.reset();
+ ref_edges_list.reset();
+ ref_faces_list.reset();
- // Now sweep them along the sweep_vector, a distance equal to the length of
- // the sweep SPAvector, with the input draft angle and draft type.
+ // Now sweep them along the sweep_vector, a distance equal to the length of
+ // the sweep SPAvector, with the input draft angle and draft type.
- FACEs_to_be_swept_list.reset();
- EDGEs_to_be_swept_list.reset();
- FACE* FACE_ptr = NULL;
- FACE* copied_FACE_ptr = NULL;
- EDGE* copied_EDGE_ptr = NULL;
- Surface* refface_ptr = NULL;
- BodySM* body_ptr = NULL;
- BODY* BODY_ptr = NULL;
- BODY* copy_of_original_BODY_ptr = NULL;
- bool primary_side = true;
- bool skip_loop = false;
- CubitStatus sweep_status = CUBIT_FAILURE;
- for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
- {
- skip_loop = CUBIT_FALSE;
- copied_FACE_ptr = NULL;
+ FACEs_to_be_swept_list.reset();
+ EDGEs_to_be_swept_list.reset();
+ FACE* FACE_ptr = NULL;
+ FACE* copied_FACE_ptr = NULL;
+ EDGE* copied_EDGE_ptr = NULL;
+ Surface* refface_ptr = NULL;
+ BodySM* body_ptr = NULL;
+ BODY* BODY_ptr = NULL;
+ BODY* copy_of_original_BODY_ptr = NULL;
+ bool primary_side = true;
+ bool skip_loop = false;
+ CubitStatus sweep_status = CUBIT_FAILURE;
+ for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
+ {
+ skip_loop = CUBIT_FALSE;
+ copied_FACE_ptr = NULL;
- // Get the RefFace we're going to sweep
- refface_ptr = ref_faces_list.get_and_step();
+ // Get the RefFace we're going to sweep
+ refface_ptr = ref_faces_list.get_and_step();
- // Get the FACE we're going to sweep
- FACE_ptr = FACEs_to_be_swept_list.get_and_step();
+ // Get the FACE we're going to sweep
+ FACE_ptr = FACEs_to_be_swept_list.get_and_step();
- // If the FACE is DOUBLE-SIDED and the switchside option is TRUE
- if (FACE_ptr->sides() && switchside)
- {
- primary_side = CUBIT_FALSE;
- }
+ // If the FACE is DOUBLE-SIDED and the switchside option is TRUE
+ if (FACE_ptr->sides() && switchside)
+ {
+ primary_side = CUBIT_FALSE;
+ }
- // Get the associated Body and its ACIS BODY
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
- if (body_ptr != NULL)
- {
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // Get the associated Body and its ACIS BODY
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
+ if (body_ptr != NULL)
+ {
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- // Make sure we have a valid ACIS BODY associated with this Body
- // and FACE
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ // Make sure we have a valid ACIS BODY associated with this Body
+ // and FACE
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- else
- {
- PRINT_WARNING("No volume associated with this surface.\n"
- " Sweeping will continue with the ACIS BODY.\n");
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ else
+ {
+ PRINT_WARNING("No volume associated with this surface.\n"
+ " Sweeping will continue with the ACIS BODY.\n");
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- // If there were no problems finding an associated ACIS BODY, proceed
- if( !skip_loop )
- {
- // Make a copy of the original BODY before doing the sweep.
- // We will perform the sweep on the copy, not on the original body.
- copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
+ // If there were no problems finding an associated ACIS BODY, proceed
+ if( !skip_loop )
+ {
+ // Make a copy of the original BODY before doing the sweep.
+ // We will perform the sweep on the copy, not on the original body.
+ copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- if (copy_of_original_BODY_ptr)
- {
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
- get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
- }
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ if (copy_of_original_BODY_ptr)
+ {
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
+ get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
+ }
- if (copied_FACE_ptr)
- {
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ if (copied_FACE_ptr)
+ {
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- // Sweep the FACE along the SPAvector, sweep_vector
- bool reverse_failed = false;
- bool volume_is_negative = false;
+ // Sweep the FACE along the SPAvector, sweep_vector
+ bool reverse_failed = false;
+ bool volume_is_negative = false;
//copy stop_BODY
BODY* temp_BODY = NULL;
@@ -8665,80 +8660,80 @@
// not on the original body.
copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- if (copy_of_original_BODY_ptr)
- {
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
- get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
- }
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ if (copy_of_original_BODY_ptr)
+ {
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
+ get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
+ }
- if (copied_FACE_ptr)
- {
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ if (copied_FACE_ptr)
+ {
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- // Find out how many FACEs exist in the BODY that owns
- // copied_FACE_ptr
- DLIList<FACE*> FACE_list;
- if (AcisQueryEngine::instance()->get_FACEs( (ENTITY *)copy_of_original_BODY_ptr, FACE_list ))
- {
- // If copied_FACE_ptr is the only FACE in this BODY, then we can
- // try reversing the BODY before attempting the sweep again
- if (FACE_list.size() == 1)
- {
- // Make sure this is a DOUBLE_SIDED FACE
- if (copied_FACE_ptr->sides() == DOUBLE_SIDED)
- {
- // Reverse the BODY that this FACE belongs to
- if (!api_reverse_body(copy_of_original_BODY_ptr).ok())
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Find out how many FACEs exist in the BODY that owns
+ // copied_FACE_ptr
+ DLIList<FACE*> FACE_list;
+ if (AcisQueryEngine::instance()->get_FACEs( (ENTITY *)copy_of_original_BODY_ptr, FACE_list ))
+ {
+ // If copied_FACE_ptr is the only FACE in this BODY, then we can
+ // try reversing the BODY before attempting the sweep again
+ if (FACE_list.size() == 1)
+ {
+ // Make sure this is a DOUBLE_SIDED FACE
+ if (copied_FACE_ptr->sides() == DOUBLE_SIDED)
+ {
+ // Reverse the BODY that this FACE belongs to
+ if (!api_reverse_body(copy_of_original_BODY_ptr).ok())
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // The single FACE in this BODY is *not* DOUBLE_SIDED.
- // Cannot do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // The single FACE in this BODY is *not* DOUBLE_SIDED.
+ // Cannot do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // More than 1 FACE in this BODY. Cannot do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // More than 1 FACE in this BODY. Cannot do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // Couldn't get the FACES of the BODY being swept. Cannot do
- // the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Couldn't get the FACES of the BODY being swept. Cannot do
+ // the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // Couldn't find the FACE in the copied BODY that corresponds to
- // the FACE being swept in the original BODY. Cannot do the
- // reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Couldn't find the FACE in the copied BODY that corresponds to
+ // the FACE being swept in the original BODY. Cannot do the
+ // reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // The sweep failed for reasons other than the creation of a negative
- // volume. Doesn't make sense to do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
+ // The sweep failed for reasons other than the creation of a negative
+ // volume. Doesn't make sense to do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
// If reverse was successful, then try the sweep again
if ( reverse_failed == CUBIT_FALSE )
@@ -8764,87 +8759,87 @@
// Delete the BODY created by this sweep
AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr, CUBIT_TRUE );
- skip_loop = CUBIT_TRUE;
- }
- }
- else
- {
- skip_loop = CUBIT_TRUE;
- }
- } // End of if branch for initial sweep attemp
- }
+ skip_loop = CUBIT_TRUE;
+ }
+ }
+ else
+ {
+ skip_loop = CUBIT_TRUE;
+ }
+ } // End of if branch for initial sweep attemp
+ }
- // There were problems getting the FACE in the copied BODY, corresponding
- // to the FACE being swept in the original BODY. We can't proceed with the
- // sweep of this RefFace.
- else
- {
- skip_loop = CUBIT_TRUE;
- } // End of if branch if copied_FACE_ptr exists
+ // There were problems getting the FACE in the copied BODY, corresponding
+ // to the FACE being swept in the original BODY. We can't proceed with the
+ // sweep of this RefFace.
+ else
+ {
+ skip_loop = CUBIT_TRUE;
+ } // End of if branch if copied_FACE_ptr exists
- // 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.
- if( !skip_loop )
- {
- BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
- copy_of_original_BODY_ptr,
- CUBIT_FALSE, CUBIT_FALSE);
- if (new_body_ptr)
- {
- result_body_list.append(new_body_ptr);
- sweep_status = CUBIT_SUCCESS;
- }
+ // 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.
+ if( !skip_loop )
+ {
+ BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
+ copy_of_original_BODY_ptr,
+ CUBIT_FALSE, CUBIT_FALSE);
+ if (new_body_ptr)
+ {
+ result_body_list.append(new_body_ptr);
+ sweep_status = CUBIT_SUCCESS;
+ }
- } // End of if branch if skip_loop != TRUE of final new_body_ptr construction
- else
- {
- // Get rid of the copied body, if it exists
- if( copy_of_original_BODY_ptr )
- {
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr);
+ } // End of if branch if skip_loop != TRUE of final new_body_ptr construction
+ else
+ {
+ // Get rid of the copied body, if it exists
+ if( copy_of_original_BODY_ptr )
+ {
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr);
- copy_of_original_BODY_ptr = NULL;
- }
- }
- } // End of if branch if skip_loop != TRUE for problems finding assoc. ACIS BODY
- } // End of i loop, iterating over FACEs_to_be_swept_list
+ copy_of_original_BODY_ptr = NULL;
+ }
+ }
+ } // End of if branch if skip_loop != TRUE for problems finding assoc. ACIS BODY
+ } // End of i loop, iterating over FACEs_to_be_swept_list
- //Now we iterate over the EDGEs
- for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
- {
- // Get the EDGE we're going to sweep
- copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
+ //Now we iterate over the EDGEs
+ for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
+ {
+ // Get the EDGE we're going to sweep
+ copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
- BODY* new_BODY_ptr = NULL;
- sweep_status = sweep_EDGE_along_vector( copied_EDGE_ptr,
- new_BODY_ptr,
- sweep_vector,
- draft_angle,
- draft_type,
- rigid,
- stop_FACE);
- if(sweep_status == CUBIT_FAILURE)
- {
- PRINT_ERROR("Problem sweeping curve.\n");
- continue;
- }
+ BODY* new_BODY_ptr = NULL;
+ sweep_status = sweep_EDGE_along_vector( copied_EDGE_ptr,
+ new_BODY_ptr,
+ sweep_vector,
+ draft_angle,
+ draft_type,
+ rigid,
+ stop_FACE);
+ if(sweep_status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("Problem sweeping curve.\n");
+ continue;
+ }
- BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
- new_BODY_ptr,
- CUBIT_FALSE, CUBIT_FALSE);
- if (new_body_ptr)
- {
- sweep_status = CUBIT_SUCCESS;
- result_body_list.append(new_body_ptr);
- }
+ BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
+ new_BODY_ptr,
+ CUBIT_FALSE, CUBIT_FALSE);
+ if (new_body_ptr)
+ {
+ sweep_status = CUBIT_SUCCESS;
+ result_body_list.append(new_body_ptr);
+ }
- } // End of i loop, iterating over EDGEs_to_be_swept_list
+ } // End of i loop, iterating over EDGEs_to_be_swept_list
- return sweep_status;
- }
+ return sweep_status;
+}
CubitStatus AcisModifyEngine::sweep_perpendicular(
DLIList<GeometryEntity*>& ref_ent_list,
@@ -8874,130 +8869,130 @@
stop_BODY = bodyACISPtr->get_BODY_ptr() ;
}
- // First get the ACIS FACEs associated with the input RefFaces
- // DLIList<FACE*> temp_faces;
- int i;
- for (i = ref_ent_list.size(); i > 0; i--)
- {
- GeometryEntity *ref_ent = ref_ent_list.get_and_step();
- Surface *ref_face = CAST_TO(ref_ent, Surface);
- Curve* ref_edge = CAST_TO(ref_ent, Curve);
+ // First get the ACIS FACEs associated with the input RefFaces
+ //DLIList<FACE*> temp_faces;
+ int i;
+ for (i = ref_ent_list.size(); i > 0; i--)
+ {
+ GeometryEntity *ref_ent = ref_ent_list.get_and_step();
+ Surface *ref_face = CAST_TO(ref_ent, Surface);
+ Curve* ref_edge = CAST_TO(ref_ent, Curve);
- if(ref_face != NULL)
- {
- //SurfaceACIS::get_FACEs_of_RefFace( ref_face, temp_faces);
- //if (temp_faces.size() > 1) {
- // PRINT_ERROR("Surface %d cannot be swept as the number of ACIS FACEs associated \n"
- // " with it is not 1.\n",
- // ref_face->id());
- // return CUBIT_FAILURE;
- //}
- //if (temp_faces.size() > 0)
- // FACEs_to_be_swept_list += temp_faces;
- //temp_faces.clean_out();
- FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face);
- if (!FACE_ptr)
- return CUBIT_FAILURE;
- FACEs_to_be_swept_list.append(FACE_ptr);
- ref_faces_list.append(ref_face);
- }
- else if (ref_edge != NULL)
- {
- ref_edges_list.append(ref_edge);
- }
- }
+ if(ref_face != NULL)
+ {
+ //SurfaceACIS::get_FACEs_of_RefFace( ref_face, temp_faces);
+ //if (temp_faces.size() > 1) {
+ // PRINT_ERROR("Surface %d cannot be swept as the number of ACIS FACEs associated \n"
+ // " with it is not 1.\n",
+ // ref_face->id());
+ // return CUBIT_FAILURE;
+ //}
+ //if (temp_faces.size() > 0)
+ // FACEs_to_be_swept_list += temp_faces;
+ //temp_faces.clean_out();
+ FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face);
+ if (!FACE_ptr)
+ return CUBIT_FAILURE;
+ FACEs_to_be_swept_list.append(FACE_ptr);
+ ref_faces_list.append(ref_face);
+ }
+ else if (ref_edge != NULL)
+ {
+ ref_edges_list.append(ref_edge);
+ }
+ }
- if(ref_edges_list.size())
- PRINT_ERROR("Curves cannot be swept perpendicularly, please use the vector sweep.\n");
+ if(ref_edges_list.size())
+ PRINT_ERROR("Curves cannot be swept perpendicularly, please use the vector sweep.\n");
- ref_faces_list.reset();
+ ref_faces_list.reset();
- // Now sweep them perpendicularly, a distance equal to the
- // distance given with the input draft angle and
- // draft type.
+ // Now sweep them perpendicularly, a distance equal to the
+ // distance given with the input draft angle and
+ // draft type.
- FACEs_to_be_swept_list.reset();
- FACE* FACE_ptr = NULL;
- FACE* copied_FACE_ptr = NULL;
+ FACEs_to_be_swept_list.reset();
+ FACE* FACE_ptr = NULL;
+ FACE* copied_FACE_ptr = NULL;
- Surface* refface_ptr = NULL;
- BodySM* body_ptr = NULL;
- BODY* BODY_ptr = NULL;
- BODY* copy_of_original_BODY_ptr = NULL;
- bool primary_side = CUBIT_TRUE;
- int skip_loop = CUBIT_FALSE;
- CubitStatus sweep_status = CUBIT_FAILURE;
- for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
- {
- skip_loop = CUBIT_FALSE;
- copied_FACE_ptr = NULL;
+ Surface* refface_ptr = NULL;
+ BodySM* body_ptr = NULL;
+ BODY* BODY_ptr = NULL;
+ BODY* copy_of_original_BODY_ptr = NULL;
+ bool primary_side = CUBIT_TRUE;
+ int skip_loop = CUBIT_FALSE;
+ CubitStatus sweep_status = CUBIT_FAILURE;
+ for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
+ {
+ skip_loop = CUBIT_FALSE;
+ copied_FACE_ptr = NULL;
- // Get the RefFace we're going to sweep
- refface_ptr = ref_faces_list.get_and_step();
+ // Get the RefFace we're going to sweep
+ refface_ptr = ref_faces_list.get_and_step();
- // Get the FACE we're going to sweep
- FACE_ptr = FACEs_to_be_swept_list.get_and_step();
+ // Get the FACE we're going to sweep
+ FACE_ptr = FACEs_to_be_swept_list.get_and_step();
- // If the FACE is DOUBLE-SIDED and the switchside option is TRUE
- if (FACE_ptr->sides() && switchside)
- {
- primary_side = CUBIT_FALSE;
- }
+ // If the FACE is DOUBLE-SIDED and the switchside option is TRUE
+ if (FACE_ptr->sides() && switchside)
+ {
+ primary_side = CUBIT_FALSE;
+ }
- // Get the associated Body and its ACIS BODY
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
- if (body_ptr != NULL)
- {
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // Get the associated Body and its ACIS BODY
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
+ if (body_ptr != NULL)
+ {
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- // Make sure we have a valid ACIS BODY associated with this Body
- // and FACE
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ // Make sure we have a valid ACIS BODY associated with this Body
+ // and FACE
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- else
- {
- PRINT_WARNING("No volume associated with this surface.\n"
- " Sweeping will continue with the ACIS BODY.\n");
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with the RefFace.\n");
- skip_loop = CUBIT_TRUE;
- }
- }
+ else
+ {
+ PRINT_WARNING("No volume associated with this surface.\n"
+ " Sweeping will continue with the ACIS BODY.\n");
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with the RefFace.\n");
+ skip_loop = CUBIT_TRUE;
+ }
+ }
- // If there were no problems finding an associated ACIS BODY, proceed
- if( !skip_loop )
- {
- // Make a copy of the original BODY before doing the sweep.
- // We will perform the sweep on the copy, not on the original body.
- copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
+ // If there were no problems finding an associated ACIS BODY, proceed
+ if( !skip_loop )
+ {
+ // Make a copy of the original BODY before doing the sweep.
+ // We will perform the sweep on the copy, not on the original body.
+ copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- if (copy_of_original_BODY_ptr)
- {
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
- get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
- }
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ if (copy_of_original_BODY_ptr)
+ {
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
+ get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
+ }
- if (copied_FACE_ptr)
- {
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ if (copied_FACE_ptr)
+ {
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- // Sweep the FACE along the SPAvector, sweep_vector
- bool reverse_failed = CUBIT_FALSE;
- bool volume_is_negative = CUBIT_FALSE;
+ // Sweep the FACE along the SPAvector, sweep_vector
+ bool reverse_failed = CUBIT_FALSE;
+ bool volume_is_negative = CUBIT_FALSE;
//copy stop_BODY
BODY* temp_BODY = NULL;
@@ -9022,85 +9017,85 @@
// negative volume).
AcisQueryEngine::instance()->delete_ACIS_BODY(copy_of_original_BODY_ptr, CUBIT_TRUE);
- // Make another copy of the original BODY before attempting
- // the sweep again. We will perform the sweep on this copy,
- // not on the original body.
- copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
+ // Make another copy of the original BODY before attempting
+ // the sweep again. We will perform the sweep on this copy,
+ // not on the original body.
+ copy_of_original_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- if (copy_of_original_BODY_ptr)
- {
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
- get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
- }
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ if (copy_of_original_BODY_ptr)
+ {
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->
+ get_ENTITY_of_entity( copy_of_original_BODY_ptr, refface_ptr ));
+ }
- if (copied_FACE_ptr)
- {
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ if (copied_FACE_ptr)
+ {
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- // Find out how many FACEs exist in the BODY that owns
- // copied_FACE_ptr
- DLIList<FACE*> FACE_list;
- if (AcisQueryEngine::instance()->get_FACEs( (ENTITY *)copy_of_original_BODY_ptr, FACE_list ))
- {
- // If copied_FACE_ptr is the only FACE in this BODY, then we can
- // try reversing the BODY before attempting the sweep again
- if (FACE_list.size() == 1)
- {
- // Make sure this is a DOUBLE_SIDED FACE
- if (copied_FACE_ptr->sides() == DOUBLE_SIDED)
- {
- // Reverse the BODY that this FACE belongs to
- if (!api_reverse_body(copy_of_original_BODY_ptr).ok())
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Find out how many FACEs exist in the BODY that owns
+ // copied_FACE_ptr
+ DLIList<FACE*> FACE_list;
+ if (AcisQueryEngine::instance()->get_FACEs( (ENTITY *)copy_of_original_BODY_ptr, FACE_list ))
+ {
+ // If copied_FACE_ptr is the only FACE in this BODY, then we can
+ // try reversing the BODY before attempting the sweep again
+ if (FACE_list.size() == 1)
+ {
+ // Make sure this is a DOUBLE_SIDED FACE
+ if (copied_FACE_ptr->sides() == DOUBLE_SIDED)
+ {
+ // Reverse the BODY that this FACE belongs to
+ if (!api_reverse_body(copy_of_original_BODY_ptr).ok())
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // The single FACE in this BODY is *not* DOUBLE_SIDED.
- // Cannot do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // The single FACE in this BODY is *not* DOUBLE_SIDED.
+ // Cannot do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // More than 1 FACE in this BODY. Cannot do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // More than 1 FACE in this BODY. Cannot do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // Couldn't get the FACES of the BODY being swept. Cannot do
- // the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Couldn't get the FACES of the BODY being swept. Cannot do
+ // the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // Couldn't find the FACE in the copied BODY that corresponds to
- // the FACE being swept in the original BODY. Cannot do the
- // reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
- }
+ // Couldn't find the FACE in the copied BODY that corresponds to
+ // the FACE being swept in the original BODY. Cannot do the
+ // reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
+ }
- // The sweep failed for reasons other than the creation of a negative
- // volume. Doesn't make sense to do the reversal and sweep.
- else
- {
- reverse_failed = CUBIT_TRUE;
- }
+ // The sweep failed for reasons other than the creation of a negative
+ // volume. Doesn't make sense to do the reversal and sweep.
+ else
+ {
+ reverse_failed = CUBIT_TRUE;
+ }
// If reverse was successful, then try the sweep again
if ( reverse_failed == CUBIT_FALSE )
@@ -9123,57 +9118,57 @@
// The attempt to reverse the BODY and sweep it again failed.
PRINT_ERROR("Problem sweeping one of the surfaces.\n");
- // Delete the BODY created by this sweep
- AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr, CUBIT_TRUE );
+ // Delete the BODY created by this sweep
+ AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr, CUBIT_TRUE );
- skip_loop = CUBIT_TRUE;
- }
- }
- else
- {
- skip_loop = CUBIT_TRUE;
- }
- } // End of if branch for initial sweep attemp
- }
+ skip_loop = CUBIT_TRUE;
+ }
+ }
+ else
+ {
+ skip_loop = CUBIT_TRUE;
+ }
+ } // End of if branch for initial sweep attemp
+ }
- // There were problems getting the FACE in the copied BODY, corresponding
- // to the FACE being swept in the original BODY. We can't proceed with the
- // sweep of this RefFace.
- else
- {
- skip_loop = CUBIT_TRUE;
- } // End of if branch if copied_FACE_ptr exists
+ // There were problems getting the FACE in the copied BODY, corresponding
+ // to the FACE being swept in the original BODY. We can't proceed with the
+ // sweep of this RefFace.
+ else
+ {
+ skip_loop = CUBIT_TRUE;
+ } // End of if branch if copied_FACE_ptr exists
- // 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.
- if( !skip_loop )
- {
- BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
- copy_of_original_BODY_ptr,
- CUBIT_FALSE, CUBIT_FALSE);
- if (new_body_ptr)
- {
- result_body_list.append(new_body_ptr);
- sweep_status = CUBIT_SUCCESS;
- }
+ // 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.
+ if( !skip_loop )
+ {
+ BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr,
+ copy_of_original_BODY_ptr,
+ CUBIT_FALSE, CUBIT_FALSE);
+ if (new_body_ptr)
+ {
+ result_body_list.append(new_body_ptr);
+ sweep_status = CUBIT_SUCCESS;
+ }
- } // End of if branch if skip_loop != TRUE of final new_body_ptr construction
- else
- {
- // Get rid of the copied body, if it exists
- if( copy_of_original_BODY_ptr )
- {
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
- AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr);
+ } // End of if branch if skip_loop != TRUE of final new_body_ptr construction
+ else
+ {
+ // Get rid of the copied body, if it exists
+ if( copy_of_original_BODY_ptr )
+ {
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copy_of_original_BODY_ptr);
+ AcisQueryEngine::instance()->delete_ACIS_BODY( copy_of_original_BODY_ptr);
- copy_of_original_BODY_ptr = NULL;
- }
- }
- } // End of if branch if skip_loop != TRUE for problems finding assoc. ACIS BODY
- } // End of i loop, iterating over FACEs_to_be_swept_list
- return sweep_status;
- }
+ copy_of_original_BODY_ptr = NULL;
+ }
+ }
+ } // End of if branch if skip_loop != TRUE for problems finding assoc. ACIS BODY
+ } // End of i loop, iterating over FACEs_to_be_swept_list
+ return sweep_status;
+}
//-------------------------------------------------------------------------
// Purpose : Perform a face sweep operation along a curve
@@ -9218,333 +9213,333 @@
stop_BODY = bodyACISPtr->get_BODY_ptr() ;
}
- // First get the ACIS FACEs associated with the input RefFaces
- // DLIList<FACE*> temp_faces;
- int i;
- for (i = ref_ent_list.size(); i > 0; i--)
- {
- GeometryEntity* ref_ent = ref_ent_list.get_and_step();
- Surface *ref_face = CAST_TO(ref_ent, Surface);
- Curve* ref_edge = CAST_TO(ref_ent, Curve);
- if(ref_face != NULL)
- {
- // SurfaceACIS::get_FACEs_of_RefFace( ref_face, temp_faces);
- // if (temp_faces.size() > 1) {
- // PRINT_ERROR("Surface %d cannot be swept as the number of ACIS FACEs associated \n"
- // " with it is not 1.\n",
- // ref_face->id());
- // return CUBIT_FAILURE;
- // }
- // if (temp_faces.size() > 0)
- // FACEs_to_be_swept_list += temp_faces;
- // temp_faces.clean_out();
- FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face);
- if (!FACE_ptr)
- return CUBIT_FAILURE;
- FACEs_to_be_swept_list.append(FACE_ptr);
- ref_faces_list.append(ref_face);
- }
- 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));
- ref_edges_list.append(ref_edge);
- }
+ // First get the ACIS FACEs associated with the input RefFaces
+// DLIList<FACE*> temp_faces;
+ int i;
+ for (i = ref_ent_list.size(); i > 0; i--)
+ {
+ GeometryEntity* ref_ent = ref_ent_list.get_and_step();
+ Surface *ref_face = CAST_TO(ref_ent, Surface);
+ Curve* ref_edge = CAST_TO(ref_ent, Curve);
+ if(ref_face != NULL)
+ {
+// SurfaceACIS::get_FACEs_of_RefFace( ref_face, temp_faces);
+// if (temp_faces.size() > 1) {
+// PRINT_ERROR("Surface %d cannot be swept as the number of ACIS FACEs associated \n"
+// " with it is not 1.\n",
+// ref_face->id());
+ // return CUBIT_FAILURE;
+// }
+// if (temp_faces.size() > 0)
+// FACEs_to_be_swept_list += temp_faces;
+// temp_faces.clean_out();
+ FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face);
+ if (!FACE_ptr)
+ return CUBIT_FAILURE;
+ FACEs_to_be_swept_list.append(FACE_ptr);
+ ref_faces_list.append(ref_face);
+ }
+ 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));
+ ref_edges_list.append(ref_edge);
+ }
- }
+ }
- // Now sweep them along the EDGE.
+ // Now sweep them along the EDGE.
- BODY* EDGE_BODY_ptr = NULL;
+ BODY* EDGE_BODY_ptr = NULL;
- FACEs_to_be_swept_list.reset();
- EDGEs_to_be_swept_list.reset();
- ref_edges_list.reset();
+ FACEs_to_be_swept_list.reset();
+ EDGEs_to_be_swept_list.reset();
+ ref_edges_list.reset();
- FACE* FACE_ptr = NULL;
- FACE* copied_FACE_ptr = NULL;
- Surface* ref_face_ptr = NULL;
- BodySM* body_ptr = NULL;
- BODY* BODY_ptr = NULL;
- BODY* copied_BODY_ptr = NULL;
+ FACE* FACE_ptr = NULL;
+ FACE* copied_FACE_ptr = NULL;
+ Surface* ref_face_ptr = NULL;
+ BodySM* body_ptr = NULL;
+ BODY* BODY_ptr = NULL;
+ BODY* copied_BODY_ptr = NULL;
- // Get the EDGE to sweep along. No need to copy it as it is going into
- // a WIRE body (it's copied into the WIRE body).
- //
- Curve* ref_edge_ptr = NULL;
+ // Get the EDGE to sweep along. No need to copy it as it is going into
+ // a WIRE body (it's copied into the WIRE body).
+ //
+ Curve* ref_edge_ptr = NULL;
- // Sweep the FACE along the chain of EDGES.
- int num_edges = ref_edge_list.size();
- EDGE** EDGES = new EDGE*[num_edges];
- ref_edge_list.reset();
- for( int j=0; j<num_edges; j++ )
- {
- ref_edge_ptr = ref_edge_list.get_and_step();
- //Curve* curve_ptr = ref_edge_ptr->get_curve_ptr();
- //CurveACIS *curve_ACIS = CAST_TO(curve_ptr, CurveACIS);
- CurveACIS *curve_ACIS = CAST_TO(ref_edge_ptr, CurveACIS);
- EDGE *EDGE_ptr = curve_ACIS->get_EDGE_ptr();
+ // Sweep the FACE along the chain of EDGES.
+ int num_edges = ref_edge_list.size();
+ EDGE** EDGES = new EDGE*[num_edges];
+ ref_edge_list.reset();
+ for( int j=0; j<num_edges; j++ )
+ {
+ ref_edge_ptr = ref_edge_list.get_and_step();
+ //Curve* curve_ptr = ref_edge_ptr->get_curve_ptr();
+ //CurveACIS *curve_ACIS = CAST_TO(curve_ptr, CurveACIS);
+ CurveACIS *curve_ACIS = CAST_TO(ref_edge_ptr, CurveACIS);
+ EDGE *EDGE_ptr = curve_ACIS->get_EDGE_ptr();
- if (!EDGE_ptr)
- {
- PRINT_ERROR("Unable to get ACIS EDGE from Curve\n" );
- delete [] EDGES;
- return CUBIT_FAILURE;
- }
+ if (!EDGE_ptr)
+ {
+ PRINT_ERROR("Unable to get ACIS EDGE from Curve\n" );
+ delete [] EDGES;
+ return CUBIT_FAILURE;
+ }
- EDGE *copied_EDGE_ptr = NULL;
- result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- if (!result.ok() || copied_EDGE_ptr == NULL )
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "Unable to copy ACIS curve\n" );
- delete [] EDGES;
- return CUBIT_FAILURE;
- }
- EDGES[j] = copied_EDGE_ptr;
- }
+ EDGE *copied_EDGE_ptr = NULL;
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ if (!result.ok() || copied_EDGE_ptr == NULL )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "Unable to copy ACIS curve\n" );
+ delete [] EDGES;
+ return CUBIT_FAILURE;
+ }
+ EDGES[j] = copied_EDGE_ptr;
+ }
- // Make a WIRE body to sweep along. If we have to reverse the EDGE
- // (since ACIS only allows you to sweep from start to end), the wire
- // will be needed.
- result = api_make_ewire( num_edges, EDGES, EDGE_BODY_ptr );
- WIRE* WIRE_ptr = NULL;
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "Unable to make ACIS wire body from curve to sweep along\n" );
- }
- else
- WIRE_ptr = EDGE_BODY_ptr->lump()->shell()->wire();
+ // Make a WIRE body to sweep along. If we have to reverse the EDGE
+ // (since ACIS only allows you to sweep from start to end), the wire
+ // will be needed.
+ result = api_make_ewire( num_edges, EDGES, EDGE_BODY_ptr );
+ WIRE* WIRE_ptr = NULL;
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "Unable to make ACIS wire body from curve to sweep along\n" );
+ }
+ else
+ WIRE_ptr = EDGE_BODY_ptr->lump()->shell()->wire();
- CubitStatus sweep_status = CUBIT_FAILURE;
- for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
- {
- copied_FACE_ptr = NULL;
+ CubitStatus sweep_status = CUBIT_FAILURE;
+ for (i = 0; i < FACEs_to_be_swept_list.size(); i++)
+ {
+ copied_FACE_ptr = NULL;
- // Get the RefFace we're going to sweep
- ref_face_ptr = ref_faces_list.get_and_step();
+ // Get the RefFace we're going to sweep
+ ref_face_ptr = ref_faces_list.get_and_step();
- // Get the FACE we're going to sweep
- FACE_ptr = FACEs_to_be_swept_list.get_and_step();
+ // Get the FACE we're going to sweep
+ FACE_ptr = FACEs_to_be_swept_list.get_and_step();
- // Get the associated Body and its ACIS BODY
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
- if (body_ptr != NULL)
- {
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // Get the associated Body and its ACIS BODY
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(FACE_ptr);
+ if (body_ptr != NULL)
+ {
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- // Make sure we have a valid ACIS BODY associated with this Body
- // and FACE
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with Surface.\n" );
- continue;
- }
- }
+ // Make sure we have a valid ACIS BODY associated with this Body
+ // and FACE
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with Surface.\n" );
+ continue;
+ }
+ }
- else
- {
- // This can happen when a Surface entity is created at the SM level for temp use
- // This function should only care about the ACIS BODY anyway
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
- if (BODY_ptr == NULL)
- {
- PRINT_ERROR("No valid volume associated with Surface\n" );
- continue;
- }
- }
+ else
+ {
+ // This can happen when a Surface entity is created at the SM level for temp use
+ // This function should only care about the ACIS BODY anyway
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr);
+ if (BODY_ptr == NULL)
+ {
+ PRINT_ERROR("No valid volume associated with Surface\n" );
+ continue;
+ }
+ }
- // Make a copy of the original BODY before doing the sweep.
- // We will perform the sweep on the copy, not on the original body.
- copied_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
+ // Make a copy of the original BODY before doing the sweep.
+ // We will perform the sweep on the copy, not on the original body.
+ copied_BODY_ptr = this->copy_BODY(BODY_ptr, CUBIT_FALSE);
- if( copied_BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to copy volume before sweeping\n" );
- continue;
- }
+ if( copied_BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to copy volume before sweeping\n" );
+ continue;
+ }
- // Find the FACE in the copied BODY that corresponds to the FACE
- // being swept in the original BODY. Note that when we made a copy
- // of the original BODY, all the "parent" attributes were copied
- // over to the new BODY.
- copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->get_ENTITY_of_entity(
- copied_BODY_ptr, ref_face_ptr ) );
+ // Find the FACE in the copied BODY that corresponds to the FACE
+ // being swept in the original BODY. Note that when we made a copy
+ // of the original BODY, all the "parent" attributes were copied
+ // over to the new BODY.
+ copied_FACE_ptr = (FACE *) (AcisQueryEngine::instance()->get_ENTITY_of_entity(
+ copied_BODY_ptr, ref_face_ptr ) );
- if( copied_FACE_ptr == NULL )
- {
- PRINT_ERROR( "Unable to find FACE to sweep in copied volume\n" );
- continue;
- }
+ if( copied_FACE_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to find FACE to sweep in copied volume\n" );
+ continue;
+ }
- // Remove all the CUBIT_OWNER attributes from the copied BODY
- // as we're going to sweep it.
- if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
+ // Remove all the CUBIT_OWNER attributes from the copied BODY
+ // as we're going to sweep it.
+ if (GeometryModifyTool::instance()->get_new_ids() == CUBIT_TRUE)
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
- // Check to see if the start of the edge is in the profile of
- // the face. If not, check the end - if this is, we'll need to
- // reverse the WIRE body.
- //
- // When we support a chain of EDGES, here we will need to get the start
- // and end vertices of the WIRE. This should be the only change needed.
- //VERTEX* start_VERTEX_ptr;// copied_EDGE_ptr->start();
- //VERTEX* end_VERTEX_ptr;// copied_EDGE_ptr->end();
- //if( start_VERTEX_ptr == end_VERTEX_ptr )
- //{
- // PRINT_ERROR( "Edge start and end are the same - sweeping not possible\n" );
- // return CUBIT_FAILURE;
- //}
- ENTITY *ent = WIRE_ptr;
+ // Check to see if the start of the edge is in the profile of
+ // the face. If not, check the end - if this is, we'll need to
+ // reverse the WIRE body.
+ //
+ // When we support a chain of EDGES, here we will need to get the start
+ // and end vertices of the WIRE. This should be the only change needed.
+ //VERTEX* start_VERTEX_ptr;// copied_EDGE_ptr->start();
+ //VERTEX* end_VERTEX_ptr;// copied_EDGE_ptr->end();
+ //if( start_VERTEX_ptr == end_VERTEX_ptr )
+ //{
+ // PRINT_ERROR( "Edge start and end are the same - sweeping not possible\n" );
+ // return CUBIT_FAILURE;
+ //}
+ ENTITY *ent = WIRE_ptr;
- SPAposition acis_start_coords;
- get_wire_start_position(ent, acis_start_coords);
- CubitVector start_vec( acis_start_coords.x(), acis_start_coords.y(),
- acis_start_coords.z() );
+ SPAposition acis_start_coords;
+ get_wire_start_position(ent, acis_start_coords);
+ CubitVector start_vec( acis_start_coords.x(), acis_start_coords.y(),
+ acis_start_coords.z() );
- bool start_flg;
- Curve* start_curve = find_curve_by_end_coord( start_vec,
- ref_edge_list, start_flg );
- if( !start_curve )
- {
- PRINT_ERROR( "unable to find start vertex of sweep chain; aborting\n" );
- delete []EDGES;
- return CUBIT_FAILURE;
- }
- CubitVector start_position;
- start_curve->position_from_fraction( start_flg ? 0.0 : 1.0, start_position);
+ bool start_flg;
+ Curve* start_curve = find_curve_by_end_coord( start_vec,
+ ref_edge_list, start_flg );
+ if( !start_curve )
+ {
+ PRINT_ERROR( "unable to find start vertex of sweep chain; aborting\n" );
+ delete []EDGES;
+ return CUBIT_FAILURE;
+ }
+ CubitVector start_position;
+ start_curve->position_from_fraction( start_flg ? 0.0 : 1.0, start_position);
- SPAposition acis_end_coords;
- get_wire_end_position(ent, acis_end_coords);
- CubitVector end_vec( acis_end_coords.x(), acis_end_coords.y(),
- acis_end_coords.z() );
+ SPAposition acis_end_coords;
+ get_wire_end_position(ent, acis_end_coords);
+ CubitVector end_vec( acis_end_coords.x(), acis_end_coords.y(),
+ acis_end_coords.z() );
- Curve* end_curve = find_curve_by_end_coord( end_vec,
- ref_edge_list, start_flg );
- if( !end_curve )
- {
- PRINT_ERROR( "unable to find end vertex of sweep chain; aborting\n" );
- delete []EDGES;
- return CUBIT_FAILURE;
- }
- CubitVector end_position;
- end_curve->position_from_fraction( start_flg ? 0.0 : 1.0, end_position );
+ Curve* end_curve = find_curve_by_end_coord( end_vec,
+ ref_edge_list, start_flg );
+ if( !end_curve )
+ {
+ PRINT_ERROR( "unable to find end vertex of sweep chain; aborting\n" );
+ delete []EDGES;
+ return CUBIT_FAILURE;
+ }
+ CubitVector end_position;
+ end_curve->position_from_fraction( start_flg ? 0.0 : 1.0, end_position );
- //SPAposition pos1, pos2;
- double distance1, distance2;
- SPAposition acis_closest_point;
- (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_start_coords,
- acis_closest_point );
- CubitVector closest_point_start( acis_closest_point.x(),
- acis_closest_point.y(),
- acis_closest_point.z() );
- distance1 = closest_point_start.distance_between( start_vec );
+ //SPAposition pos1, pos2;
+ double distance1, distance2;
+ SPAposition acis_closest_point;
+ (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_start_coords,
+ acis_closest_point );
+ CubitVector closest_point_start( acis_closest_point.x(),
+ acis_closest_point.y(),
+ acis_closest_point.z() );
+ distance1 = closest_point_start.distance_between( start_vec );
- //VERTEX* close_VERTEX_ptr = NULL;
- CubitVector closest_position;
- EDGE* start_EDGE_ptr = NULL;
+ //VERTEX* close_VERTEX_ptr = NULL;
+ CubitVector closest_position;
+ EDGE* start_EDGE_ptr = NULL;
- if( distance1 > SPAresabs )
- {
- // Try the other end
- (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_end_coords,
- acis_closest_point );
- CubitVector closest_point_end( acis_closest_point.x(), acis_closest_point.y(),
- acis_closest_point.z() );
- distance2 = closest_point_end.distance_between( end_vec );
+ if( distance1 > SPAresabs )
+ {
+ // Try the other end
+ (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_end_coords,
+ acis_closest_point );
+ CubitVector closest_point_end( acis_closest_point.x(), acis_closest_point.y(),
+ acis_closest_point.z() );
+ distance2 = closest_point_end.distance_between( end_vec );
- if( distance2 > SPAresabs )
- {
- PRINT_ERROR( "Neither chain end lies in the plane of surface\n" );
- continue;
- }
- else
- {
- //close_VERTEX_ptr = end_VERTEX_ptr;
- closest_position = end_position;
- start_curve = end_curve;
- start_EDGE_ptr = EDGES[ref_edge_list.size()-1];
- }
+ if( distance2 > SPAresabs )
+ {
+ PRINT_ERROR( "Neither chain end lies in the plane of surface\n" );
+ continue;
+ }
+ else
+ {
+ //close_VERTEX_ptr = end_VERTEX_ptr;
+ closest_position = end_position;
+ start_curve = end_curve;
+ start_EDGE_ptr = EDGES[ref_edge_list.size()-1];
+ }
- // Reverse the WIRE in the BODY
- //api_reverse_body( EDGE_BODY_ptr );
- api_reverse_wire( WIRE_ptr );
+ // Reverse the WIRE in the BODY
+ //api_reverse_body( EDGE_BODY_ptr );
+ api_reverse_wire( WIRE_ptr );
- }
- else
- {
- //close_VERTEX_ptr = start_VERTEX_ptr;
- closest_position = start_position;
- start_EDGE_ptr = EDGES[0];
- }
+ }
+ else
+ {
+ //close_VERTEX_ptr = start_VERTEX_ptr;
+ closest_position = start_position;
+ start_EDGE_ptr = EDGES[0];
+ }
- SPAposition acis_closest_position;
- SPAunit_vector acis_surface_normal;
+ SPAposition acis_closest_position;
+ SPAunit_vector acis_surface_normal;
- //APOINT* acis_point = close_VERTEX_ptr->geometry() ;
- //SPAposition acis_curve_position = acis_point->coords() ;
- SPAposition acis_curve_position( closest_position.x(),
- closest_position.y(), closest_position.z() );
+ //APOINT* acis_point = close_VERTEX_ptr->geometry() ;
+ //SPAposition acis_curve_position = acis_point->coords() ;
+ SPAposition acis_curve_position( closest_position.x(),
+ closest_position.y(), closest_position.z() );
- // Need to compute the FACE normal at the start of the sweep
- (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_curve_position,
- acis_closest_position, acis_surface_normal );
+ // Need to compute the FACE normal at the start of the sweep
+ (copied_FACE_ptr->geometry()->equation()).point_perp ( acis_curve_position,
+ acis_closest_position, acis_surface_normal );
- CubitVector surface_normal( acis_surface_normal.x(), acis_surface_normal.y(),
- acis_surface_normal.z() );
+ CubitVector surface_normal( acis_surface_normal.x(), acis_surface_normal.y(),
+ acis_surface_normal.z() );
- // Check to see if SENSE of FACE is REVERSED. The direction of the
- // ACIS face is the direction of sweep.
- if( copied_FACE_ptr->sense() == REVERSED )
- {
- if( copied_FACE_ptr->geometry()->equation().left_handed_uv() == CUBIT_FALSE )
- surface_normal *= -1.0;
- }
- else
- {
- if( copied_FACE_ptr->geometry()->equation().left_handed_uv() )
- surface_normal *= -1.0;
- }
+ // Check to see if SENSE of FACE is REVERSED. The direction of the
+ // ACIS face is the direction of sweep.
+ if( copied_FACE_ptr->sense() == REVERSED )
+ {
+ if( copied_FACE_ptr->geometry()->equation().left_handed_uv() == CUBIT_FALSE )
+ surface_normal *= -1.0;
+ }
+ else
+ {
+ if( copied_FACE_ptr->geometry()->equation().left_handed_uv() )
+ surface_normal *= -1.0;
+ }
- // Get curve tangent at start of the sweep
- SPAunit_vector acis_curve_tangent;
+ // Get curve tangent at start of the sweep
+ SPAunit_vector acis_curve_tangent;
- (start_EDGE_ptr->geometry()->equation()).point_perp( acis_curve_position,
- acis_closest_position,
- acis_curve_tangent );
+ (start_EDGE_ptr->geometry()->equation()).point_perp( acis_curve_position,
+ acis_closest_position,
+ acis_curve_tangent );
- CubitVector curve_tangent( acis_curve_tangent.x(), acis_curve_tangent.y(),
- acis_curve_tangent.z() );
+ CubitVector curve_tangent( acis_curve_tangent.x(), acis_curve_tangent.y(),
+ acis_curve_tangent.z() );
- // Determine if the WIRE has been reversed - ??? there's a better way to
- // do this but I don't know it. I would think you could just go by the
- // underlying EDGE but apparently when the WIRE get's reversed, the EDGE
- // doesn't change - the sweep uses the WIRE, not the EDGE.
- if( closest_position == end_position )
- curve_tangent *= -1.0;
+ // Determine if the WIRE has been reversed - ??? there's a better way to
+ // do this but I don't know it. I would think you could just go by the
+ // underlying EDGE but apparently when the WIRE get's reversed, the EDGE
+ // doesn't change - the sweep uses the WIRE, not the EDGE.
+ if( closest_position == end_position )
+ curve_tangent *= -1.0;
- // Make sure the sense is correct based on the underlying EDGE sense
- if( start_EDGE_ptr->sense() == REVERSED )
- curve_tangent *= -1.0;
+ // Make sure the sense is correct based on the underlying EDGE sense
+ if( start_EDGE_ptr->sense() == REVERSED )
+ curve_tangent *= -1.0;
- // Properties of dot product
- // angle acute if dot product > 0
- // angle obtuse if dot product < 0
- // angle 90 deg if dot product = 0
+ // Properties of dot product
+ // angle acute if dot product > 0
+ // angle obtuse if dot product < 0
+ // angle 90 deg if dot product = 0
- if( surface_normal%curve_tangent < 0 )
- {
- if( FACE_ptr->sides() != DOUBLE_SIDED )
- {
- PRINT_ERROR( "Attempting to sweep Surface back into the solid\n"
- " Sweeping of Surface aborted\n" );
- api_delent(copied_FACE_ptr);
- continue;
- }
- api_reverse_face( copied_FACE_ptr );
- }
+ if( surface_normal%curve_tangent < 0 )
+ {
+ if( FACE_ptr->sides() != DOUBLE_SIDED )
+ {
+ PRINT_ERROR( "Attempting to sweep Surface back into the solid\n"
+ " Sweeping of Surface aborted\n" );
+ api_delent(copied_FACE_ptr);
+ continue;
+ }
+ api_reverse_face( copied_FACE_ptr );
+ }
//copy stop_BODY
BODY* temp_BODY = NULL;
@@ -9570,61 +9565,61 @@
}
}
- // Create a new Body using the new swept solid and delete the
- // original Body and its associated ACIS BODY.
- BodySM* new_body_ptr = 0;
- if(body_ptr)
- new_body_ptr = get_new_Body(body_ptr, BODY_ptr, copied_BODY_ptr,
+ // Create a new Body using the new swept solid and delete the
+ // original Body and its associated ACIS BODY.
+ BodySM* new_body_ptr = 0;
+ if(body_ptr)
+ new_body_ptr = get_new_Body(body_ptr, BODY_ptr, copied_BODY_ptr,
CUBIT_FALSE, CUBIT_FALSE);
- else // this handles the case of a NULL body sweep surface (typically the result of a SM only entity)
- // in this case the caller must properly handle the sweep surface deletion
- new_body_ptr = AcisQueryEngine::instance()->populate_topology_bridges(copied_BODY_ptr);
+ else // this handles the case of a NULL body sweep surface (typically the result of a SM only entity)
+ // in this case the caller must properly handle the sweep surface deletion
+ new_body_ptr = AcisQueryEngine::instance()->populate_topology_bridges(copied_BODY_ptr);
- if (new_body_ptr)
- {
- sweep_status = CUBIT_SUCCESS;
- result_body_list.append(new_body_ptr);
- }
- } // End of i loop, iterating over FACEs_to_be_swept_list
- //Now let's iterate over the EDGEs_to_be_swept_list
- for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
- {
- EDGE *copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
- BODY* new_BODY_ptr = NULL;
+ if (new_body_ptr)
+ {
+ sweep_status = CUBIT_SUCCESS;
+ result_body_list.append(new_body_ptr);
+ }
+ } // End of i loop, iterating over FACEs_to_be_swept_list
+ //Now let's iterate over the EDGEs_to_be_swept_list
+ for (i = 0; i < EDGEs_to_be_swept_list.size(); i++)
+ {
+ EDGE *copied_EDGE_ptr = EDGEs_to_be_swept_list.get_and_step();
+ BODY* new_BODY_ptr = NULL;
- sweep_status = sweep_EDGE_along_WIRE( copied_EDGE_ptr,
- EDGE_BODY_ptr,
- new_BODY_ptr,
- draft_angle,
- draft_type,
- rigid,
- stop_FACE);
- if( sweep_status == CUBIT_FAILURE )
- {
- PRINT_ERROR("Problem sweeping curve.\n");
- continue;
+ sweep_status = sweep_EDGE_along_WIRE( copied_EDGE_ptr,
+ EDGE_BODY_ptr,
+ new_BODY_ptr,
+ draft_angle,
+ draft_type,
+ rigid,
+ stop_FACE);
+ if( sweep_status == CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Problem sweeping curve.\n");
+ continue;
- }
+ }
- // Create a new Body using the new swept solid
+ // Create a new Body using the new swept solid
- BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr, new_BODY_ptr,
- CUBIT_FALSE, CUBIT_FALSE);
- if (new_body_ptr)
- {
- sweep_status = CUBIT_SUCCESS;
- result_body_list.append(new_body_ptr);
- }
+ BodySM* new_body_ptr = get_new_Body(body_ptr, BODY_ptr, new_BODY_ptr,
+ CUBIT_FALSE, CUBIT_FALSE);
+ if (new_body_ptr)
+ {
+ sweep_status = CUBIT_SUCCESS;
+ result_body_list.append(new_body_ptr);
+ }
- } // End of i loop, iterating over FACEs_to_be_swept_list
- delete []EDGES;
+ } // End of i loop, iterating over FACEs_to_be_swept_list
+ delete []EDGES;
- // Remove the created WIRE body
- api_delent( EDGE_BODY_ptr );
+ // Remove the created WIRE body
+ api_delent( EDGE_BODY_ptr );
- return sweep_status;
- }
+ return sweep_status;
+}
//-------------------------------------------------------------------------
// Purpose : Sections the list of bodies (cuts in half). This is
@@ -9649,316 +9644,315 @@
bool delete_attribs =
(GeometryModifyTool::instance()->get_new_ids() || keep_old);
- if (keep_both_sides == CUBIT_TRUE )
- {
- PRINT_ERROR("keeping both sides of section is not implemented.");
- return CUBIT_FAILURE;
- }
+ if (keep_both_sides == CUBIT_TRUE )
+ {
+ PRINT_ERROR("keeping both sides of section is not implemented.");
+ return CUBIT_FAILURE;
+ }
- // Compute the super bounding SPAbox
- SPAbox super_bounding_box;
- CubitStatus rv =
- AcisQueryEngine::instance()->create_super_acis_bounding_box (section_body_list,
- super_bounding_box);
- if (rv != CUBIT_SUCCESS)
- return rv;
+ // Compute the super bounding SPAbox
+ SPAbox super_bounding_box;
+ CubitStatus rv =
+ AcisQueryEngine::instance()->create_super_acis_bounding_box (section_body_list,
+ super_bounding_box);
+ if (rv != CUBIT_SUCCESS)
+ return rv;
- // Construct a BODY from the given CubitVectors and the size of
- // the super bounding SPAbox.
- BODY *cutting_tool_ptr;
- cutting_tool_ptr = this->create_infinite_plane_cutting_tool(
- point_1,
- point_2,
- point_3,
- super_bounding_box );
- if (cutting_tool_ptr == NULL || cutting_tool_ptr->lump() == NULL )
- {
- PRINT_ERROR("failed in sectioning volumes.\n");
- return CUBIT_FAILURE;
- }
+ // Construct a BODY from the given CubitVectors and the size of
+ // the super bounding SPAbox.
+ BODY *cutting_tool_ptr;
+ cutting_tool_ptr = this->create_infinite_plane_cutting_tool(
+ point_1,
+ point_2,
+ point_3,
+ super_bounding_box );
+ if (cutting_tool_ptr == NULL || cutting_tool_ptr->lump() == NULL )
+ {
+ PRINT_ERROR("failed in sectioning volumes.\n");
+ return CUBIT_FAILURE;
+ }
- // Copy BODYs
- i = section_body_list.size();
- DLIList<BODY*> tool_BODY_list(i);
- DLIList<BODY*> blank_BODY_list(i);
- DLIList<BODY*> input_BODY_list(i);
- section_body_list.reset();
- tool_BODY_list.append( cutting_tool_ptr );
- for (i = section_body_list.size(); i > 0; i-- )
- {
- BodySM* body_sm = section_body_list.get_and_step();
+ // Copy BODYs
+ i = section_body_list.size();
+ DLIList<BODY*> tool_BODY_list(i);
+ DLIList<BODY*> blank_BODY_list(i);
+ DLIList<BODY*> input_BODY_list(i);
+ section_body_list.reset();
+ tool_BODY_list.append( cutting_tool_ptr );
+ for (i = section_body_list.size(); i > 0; i-- )
+ {
+ BodySM* body_sm = section_body_list.get_and_step();
- BODY* input_BODY = AcisQueryEngine::get_BODY( body_sm );
- if (!input_BODY) continue;
+ BODY* input_BODY = AcisQueryEngine::get_BODY( body_sm );
+ if (!input_BODY) continue;
- //also make sure that the cutting plane and blank body intersect
- if ( !BODYs_interfering( input_BODY, cutting_tool_ptr) )
- {
- TopologyEntity *topo_entity = body_sm->topology_entity();
- RefEntity *ref_entity = CAST_TO(topo_entity, RefEntity);
- assert(ref_entity != 0);
- PRINT_WARNING("Volume %d does not interect sectioning plane\n", ref_entity->id() );
- section_body_list.remove( body_sm );
- continue;
- }
+ //also make sure that the cutting plane and blank body intersect
+ if ( !BODYs_interfering( input_BODY, cutting_tool_ptr) )
+ {
+ TopologyEntity *topo_entity = body_sm->topology_entity();
+ RefEntity *ref_entity = CAST_TO(topo_entity, RefEntity);
+ assert(ref_entity != 0);
+ PRINT_WARNING("Volume %d does not interect sectioning plane\n", ref_entity->id() );
+ section_body_list.remove( body_sm );
+ continue;
+ }
- input_BODY_list.append( input_BODY );
+ input_BODY_list.append( input_BODY );
- BODY* blank_BODY = copy_BODY( input_BODY, delete_attribs );
- if (!blank_BODY) continue;
- blank_BODY_list.append( blank_BODY );
+ BODY* blank_BODY = copy_BODY( input_BODY, delete_attribs );
+ if (!blank_BODY) continue;
+ blank_BODY_list.append( blank_BODY );
- if (i < section_body_list.size()) // not first iteration
- {
- BODY* tool_BODY = copy_BODY( cutting_tool_ptr );
- if (tool_BODY)
- tool_BODY_list.append( tool_BODY );
- }
- }
+ if (i < section_body_list.size()) // not first iteration
+ {
+ BODY* tool_BODY = copy_BODY( cutting_tool_ptr );
+ if (tool_BODY)
+ tool_BODY_list.append( tool_BODY );
+ }
+ }
- if( input_BODY_list.size() == 0 )
- {
- PRINT_WARNING("No geometry interects sectioning plane\n");
- return CUBIT_FAILURE;
- }
+ if( input_BODY_list.size() == 0 )
+ {
+ PRINT_WARNING("No geometry interects sectioning plane\n");
+ return CUBIT_FAILURE;
+ }
- // If there were any errors in the above loop, clean up and exit
- if ( input_BODY_list.size() < section_body_list.size() ||
- blank_BODY_list.size() < section_body_list.size() ||
- tool_BODY_list.size() < section_body_list.size() )
- {
- if (input_BODY_list.size() < section_body_list.size())
- PRINT_ERROR("Internal error: Invalid BodySM at %s:%d\n", __FILE__, __LINE__ );
- else
- PRINT_ERROR("Internal error: BODY copy failed at %s:%d\n", __FILE__, __LINE__ );
- while (tool_BODY_list.size())
- api_delent( input_BODY_list.pop() );
- while (blank_BODY_list.size())
- api_delent( input_BODY_list.pop() );
- return CUBIT_FAILURE;
- }
+ // If there were any errors in the above loop, clean up and exit
+ if ( input_BODY_list.size() < section_body_list.size() ||
+ blank_BODY_list.size() < section_body_list.size() ||
+ tool_BODY_list.size() < section_body_list.size() )
+ {
+ if (input_BODY_list.size() < section_body_list.size())
+ PRINT_ERROR("Internal error: Invalid BodySM at %s:%d\n", __FILE__, __LINE__ );
+ else
+ PRINT_ERROR("Internal error: BODY copy failed at %s:%d\n", __FILE__, __LINE__ );
+ while (tool_BODY_list.size())
+ api_delent( input_BODY_list.pop() );
+ while (blank_BODY_list.size())
+ api_delent( input_BODY_list.pop() );
+ return CUBIT_FAILURE;
+ }
- // Deterine which type of Boolean to use.
- BOOL_TYPE bool_type;
- CubitBoolean nonreg = !GeometryModifyTool::instance()->boolean_regularize();
- if (keep_normal_side && !nonreg)
- bool_type = SUBTRACTION;
- else if (keep_normal_side && nonreg)
- bool_type = NONREG_SUBTRACTION;
- else if (!keep_normal_side && !nonreg)
- bool_type = INTERSECTION;
- else
- bool_type = NONREG_INTERSECTION;
+ // Deterine which type of Boolean to use.
+ BOOL_TYPE bool_type;
+ CubitBoolean nonreg = !GeometryModifyTool::instance()->boolean_regularize();
+ if (keep_normal_side && !nonreg)
+ bool_type = SUBTRACTION;
+ else if (keep_normal_side && nonreg)
+ bool_type = NONREG_SUBTRACTION;
+ else if (!keep_normal_side && !nonreg)
+ bool_type = INTERSECTION;
+ else
+ bool_type = NONREG_INTERSECTION;
- // Do Boolean for each blank body
- input_BODY_list.reset();
- blank_BODY_list.reset();
- tool_BODY_list.reset();
- for ( i = input_BODY_list.size(); i--; )
- {
- input_BODY_list.step();
- BODY* blank_BODY = blank_BODY_list.get_and_step();
- BODY* tool_BODY = tool_BODY_list.get_and_step();
- outcome result = api_boolean( tool_BODY, blank_BODY, bool_type );
- if (!result.ok())
- {
- PRINT_ERROR("Volume section failed.\n");
- blank_BODY_list.back();
- BODY *blank = blank_BODY_list.remove();
- AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(blank);
- if( tb_ptr && keep_old == false )
- {
- BodyACIS *body_acis = CAST_TO(tb_ptr, BodyACIS );
- if( body_acis )
- {
- BodySM *body_sm = CAST_TO(body_acis, BodySM );
- TopologyEntity *topo_entity = body_sm->topology_entity();
- RefEntity *ref_entity = CAST_TO(topo_entity, RefEntity);
- section_body_list.remove( body_sm );
- }
- }
+ // Do Boolean for each blank body
+ input_BODY_list.reset();
+ blank_BODY_list.reset();
+ tool_BODY_list.reset();
+ for ( i = input_BODY_list.size(); i--; )
+ {
+ input_BODY_list.step();
+ BODY* blank_BODY = blank_BODY_list.get_and_step();
+ BODY* tool_BODY = tool_BODY_list.get_and_step();
+ outcome result = api_boolean( tool_BODY, blank_BODY, bool_type );
+ if (!result.ok())
+ {
+ PRINT_ERROR("Volume section failed.\n");
+ blank_BODY_list.back();
+ BODY *blank = blank_BODY_list.remove();
+ AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(blank);
+ if( tb_ptr && keep_old == false )
+ {
+ BodyACIS *body_acis = CAST_TO(tb_ptr, BodyACIS );
+ if( body_acis )
+ {
+ BodySM *body_sm = CAST_TO(body_acis, BodySM );
+ TopologyEntity *topo_entity = body_sm->topology_entity();
+ RefEntity *ref_entity = CAST_TO(topo_entity, RefEntity);
+ section_body_list.remove( body_sm );
+ }
+ }
- api_delent( blank );
- tool_BODY_list.back();
- api_delent( tool_BODY_list.remove() );
- input_BODY_list.back();
- input_BODY_list.remove();
- }
- }
+ api_delent( blank );
+ tool_BODY_list.back();
+ api_delent( tool_BODY_list.remove() );
+ input_BODY_list.back();
+ input_BODY_list.remove();
+ }
+ }
- if( input_BODY_list.size() == 0 )
- return CUBIT_FAILURE;
+ if( input_BODY_list.size() == 0 )
+ return CUBIT_FAILURE;
- // If a non-regularized operation, clean up internal surfaces
- if (nonreg)
- {
- DLIList<FACE*> FACE_list;
- input_BODY_list.reset();
- blank_BODY_list.reset();
+ // If a non-regularized operation, clean up internal surfaces
+ if (nonreg)
+ {
+ DLIList<FACE*> FACE_list;
+ input_BODY_list.reset();
+ blank_BODY_list.reset();
- for (i = input_BODY_list.size(); i--; )
- {
- input_BODY_list.step();
- BODY* blank_BODY = blank_BODY_list.get_and_step();
+ for (i = input_BODY_list.size(); i--; )
+ {
+ input_BODY_list.step();
+ BODY* blank_BODY = blank_BODY_list.get_and_step();
- FACE_list.clean_out();
- AcisQueryEngine::instance()->get_FACEs( blank_BODY, FACE_list );
+ FACE_list.clean_out();
+ AcisQueryEngine::instance()->get_FACEs( blank_BODY, FACE_list );
- FACE_list.reset();
- for (int j = FACE_list.size(); j--; )
- {
- FACE* FACE_ptr = FACE_list.get_and_step();
- assert( FACE_ptr != NULL );
+ FACE_list.reset();
+ for (int j = FACE_list.size(); j--; )
+ {
+ FACE* FACE_ptr = FACE_list.get_and_step();
+ assert( FACE_ptr != NULL );
- if (FACE_ptr->sides() == DOUBLE_SIDED &&
- FACE_ptr->cont() == BOTH_INSIDE)
- {
- PRINT_INFO("Unhooking and deleting internal surface.\n");
- BODY* FACE_BODY_ptr;
- outcome result = api_unhook_face( FACE_ptr, FACE_BODY_ptr );
- if (!result.ok())
- {
- AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result );
- PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
- }
- else
- {
- api_delent( FACE_BODY_ptr );
- }
- }
- }
- }
- }
+ if (FACE_ptr->sides() == DOUBLE_SIDED &&
+ FACE_ptr->cont() == BOTH_INSIDE)
+ {
+ PRINT_INFO("Unhooking and deleting internal surface.\n");
+ BODY* FACE_BODY_ptr;
+ outcome result = api_unhook_face( FACE_ptr, FACE_BODY_ptr );
+ if (!result.ok())
+ {
+ AcisModifyEngine::instance()->get_acis_query_engine()->ACIS_API_error( result );
+ PRINT_ERROR( " Face unhooking during rebuild of volume didn't work\n" );
+ }
+ else
+ {
+ api_delent( FACE_BODY_ptr );
+ }
+ }
+ }
+ }
+ }
- // Create/update AcisBridges
- if( keep_old == true )
- {
- int k;
- for( k=blank_BODY_list.size(); k--; )
- {
- BodySM *this_bodysm = AcisQueryEngine::instance()->
- populate_topology_bridges( blank_BODY_list.get_and_step() );
- new_body_list.append( this_bodysm );
- }
- }
- else
- get_new_Body( section_body_list,
- input_BODY_list,
- blank_BODY_list,
- new_body_list,
- keep_old );
-
- return CUBIT_SUCCESS;
+ // Create/update AcisBridges
+ if( keep_old == true )
+ {
+ int k;
+ for( k=blank_BODY_list.size(); k--; )
+ {
+ BodySM *this_bodysm = AcisQueryEngine::instance()->
+ populate_topology_bridges( blank_BODY_list.get_and_step() );
+ new_body_list.append( this_bodysm );
}
+ }
+ else
+ get_new_Body( section_body_list,
+ input_BODY_list,
+ blank_BODY_list,
+ new_body_list,
+ keep_old );
+ return CUBIT_SUCCESS;
+}
- //-------------------------------------------------------------------------
- // Purpose : webcuts a list of bodies using a plane.
- // The newly created bodies are merged and imprinted
- // depending on the respective flags.
- //
- // Special Notes :
- //
- // Creator : Malcolm J. Panthaki
- //
- // Creation Date : 12/17/96
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::webcut( DLIList<BodySM*>& webcut_body_list,
- const CubitVector &vecVertex1,
- const CubitVector &vecVertex2,
- const CubitVector &vecVertex3,
- DLIList<BodySM*>& results_list,
- bool imprint )
- {
- //int webcut_debug_flag = 18;
- //int webcut_debug_flag_on = DEBUG_FLAG(webcut_debug_flag);
- BODY* cutting_tool_ptr = NULL;
+//-------------------------------------------------------------------------
+// Purpose : webcuts a list of bodies using a plane.
+// The newly created bodies are merged and imprinted
+// depending on the respective flags.
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 12/17/96
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::webcut( DLIList<BodySM*>& webcut_body_list,
+ const CubitVector &vecVertex1,
+ const CubitVector &vecVertex2,
+ const CubitVector &vecVertex3,
+ DLIList<BodySM*>& results_list,
+ bool imprint ) const
+{
+ //int webcut_debug_flag = 18;
+ //int webcut_debug_flag_on = DEBUG_FLAG(webcut_debug_flag);
- // To be able to create a Cutting Tool of the appropriate ("infinite")
- // size, first generate the bounding SPAbox that surrounds all the BODYs
- // being webcut. The procedure, GeometryModifyTool::create_infinite_plane_cutting
- // _tool, will use the size of this "super" bounding SPAbox to determine an
- // appropriate "infinite-enough" size for the Cutting Tool.
+ BODY* cutting_tool_ptr = NULL;
- // Compute the super bounding SPAbox
- SPAbox super_bounding_box;
- CubitStatus rv =
- AcisQueryEngine::instance()->create_super_acis_bounding_box ( webcut_body_list, super_bounding_box );
- if (rv != CUBIT_SUCCESS)
- return CUBIT_FAILURE;
+ // To be able to create a Cutting Tool of the appropriate ("infinite")
+ // size, first generate the bounding SPAbox that surrounds all the BODYs
+ // being webcut. The procedure, GeometryModifyTool::create_infinite_plane_cutting
+ // _tool, will use the size of this "super" bounding SPAbox to determine an
+ // appropriate "infinite-enough" size for the Cutting Tool.
- // Construct a BODY from the given CubitVectors and the size of
- // the super bounding SPAbox.
- cutting_tool_ptr = this-> create_infinite_plane_cutting_tool(
- vecVertex1,
- vecVertex2,
- vecVertex3,
- super_bounding_box );
+ // Compute the super bounding SPAbox
+ SPAbox super_bounding_box;
+ CubitStatus rv =
+ AcisQueryEngine::instance()->create_super_acis_bounding_box ( webcut_body_list, super_bounding_box );
+ if (rv != CUBIT_SUCCESS)
+ return CUBIT_FAILURE;
- if (cutting_tool_ptr == NULL)
- {
- //webcut_failed(refbody_cleanup_list, BODY_cleanup_list);
- PRINT_ERROR("In AcisModifyEngine::webcut(,Vector,,,),%d"
- " Cannot create infinite plane cutting tool using \n"
- " the vectors. \n", __LINE__ );
- return CUBIT_FAILURE;
- }
+ // Construct a BODY from the given CubitVectors and the size of
+ // the super bounding SPAbox.
+ cutting_tool_ptr = this-> create_infinite_plane_cutting_tool(
+ vecVertex1,
+ vecVertex2,
+ vecVertex3,
+ super_bounding_box );
- else
- {
- // Use the BODY to perform webcut
- CubitStatus stat =
- this->webcut(webcut_body_list, cutting_tool_ptr, results_list, imprint) ;
+ if (cutting_tool_ptr == NULL)
+ {
+ //webcut_failed(refbody_cleanup_list, BODY_cleanup_list);
+ PRINT_ERROR("In AcisModifyEngine::webcut(,Vector,,,),%d"
+ " Cannot create infinite plane cutting tool using \n"
+ " the vectors. \n", __LINE__ );
+ return CUBIT_FAILURE;
+ }
- // Delete the BODY that was created to be used as a tool
- AcisQueryEngine::instance()->delete_ACIS_BODY(cutting_tool_ptr, CUBIT_TRUE) ;
- cutting_tool_ptr = NULL;
+ else
+ {
+ // Use the BODY to perform webcut
+ CubitStatus stat =
+ this->webcut(webcut_body_list, cutting_tool_ptr, results_list, imprint) ;
- return stat ;
- }
- }
+ // Delete the BODY that was created to be used as a tool
+ AcisQueryEngine::instance()->delete_ACIS_BODY(cutting_tool_ptr, CUBIT_TRUE) ;
+ cutting_tool_ptr = NULL;
- //-------------------------------------------------------------------------
- // Purpose : webcuts a list of bodies using another Body as the tool.
- // The newly created bodies are merged and imprinted
- // depending on the respective flags.
- //
- // Special Notes :
- //
- // Creator : Jihong Ma
- //
- // Creation Date : 12/23/96
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::webcut(
- DLIList<BodySM*>& webcut_body_list,
- BodySM const* tool_body,
- DLIList<BodySM*>& results_list,
- bool imprint)
- {
- // check the tool body if it is made of AcisModifyEngine
- if( !is_modify_engine(tool_body))
- {
- PRINT_ERROR("In AcisModifyEngine::webcut() %d, \n"
- " The tool volume is not made of AGE itself.\n", __LINE__);
- return CUBIT_FAILURE;
- }
+ return stat ;
+ }
+}
+//-------------------------------------------------------------------------
+// Purpose : webcuts a list of bodies using another Body as the tool.
+// The newly created bodies are merged and imprinted
+// depending on the respective flags.
+//
+// Special Notes :
+//
+// Creator : Jihong Ma
+//
+// Creation Date : 12/23/96
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::webcut( DLIList<BodySM*>& webcut_body_list,
+ BodySM const* tool_body,
+ DLIList<BodySM*>& results_list,
+ bool imprint ) const
+{
+ // check the tool body if it is made of AcisModifyEngine
+ if( !is_modify_engine(tool_body))
+ {
+ PRINT_ERROR("In AcisModifyEngine::webcut() %d, \n"
+ " The tool volume is not made of AGE itself.\n", __LINE__);
+ return CUBIT_FAILURE;
+ }
- BODY* tool_BODY = NULL;
- //get the ACIS BODY of tool_body
- tool_BODY = AcisQueryEngine::get_BODY( const_cast<BodySM*>(tool_body) );
- if( tool_BODY == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::webcut() %d, \n"
- " There is no underlying tool volume.\n",__LINE__);
- return CUBIT_FAILURE;
- }
+ BODY* tool_BODY = NULL;
- return this->webcut( webcut_body_list, tool_BODY, results_list, imprint);
- }
+ //get the ACIS BODY of tool_body
+ tool_BODY = AcisQueryEngine::get_BODY( const_cast<BodySM*>(tool_body) );
+ if( tool_BODY == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::webcut() %d, \n"
+ " There is no underlying tool volume.\n",__LINE__);
+ return CUBIT_FAILURE;
+ }
+ return this->webcut( webcut_body_list, tool_BODY, results_list, imprint );
+}
+
//-------------------------------------------------------------------------
// Purpose : webcuts a list of bodies using another Body as the tool.
// The newly created bodies are merged and imprinted
@@ -10177,5768 +10171,5769 @@
}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a Point, given coordinates. The
- // particular type of Point object that is created depends on
- // the specific GeometryQueryEngine. For example, this
- // engine, AcisModifyEngine, creates a PointACIS and
- // returns it.
- //
- // Special Notes :
- // In this routine, a floating ACIS VERTEX is created. This VERTEX
- // is not a part of any BODY and, hence, does not take part in
- // any boolean operations.
- //
- // Creator : Malcolm J. Panthaki
- //
- // Creation Date : 03/05/97
- //-------------------------------------------------------------------------
- Point* AcisModifyEngine::make_Point(CubitVector const& point) const
- {
- // Create a new ACIS VERTEX -- it is not attached to a BODY
- VERTEX* VERTEX_ptr = this->make_VERTEX( point );
- if ( VERTEX_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Point\n"
- " Cannot make Point object.\n");
- return (Point *)NULL;
- }
+//-------------------------------------------------------------------------
+// Purpose : This function creates a Point, given coordinates. The
+// particular type of Point object that is created depends on
+// the specific GeometryQueryEngine. For example, this
+// engine, AcisModifyEngine, creates a PointACIS and
+// returns it.
+//
+// Special Notes :
+// In this routine, a floating ACIS VERTEX is created. This VERTEX
+// is not a part of any BODY and, hence, does not take part in
+// any boolean operations.
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 03/05/97
+//-------------------------------------------------------------------------
+Point* AcisModifyEngine::make_Point(CubitVector const& point) const
+{
+ // Create a new ACIS VERTEX -- it is not attached to a BODY
+ VERTEX* VERTEX_ptr = this->make_VERTEX( point );
+ if ( VERTEX_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Point\n"
+ " Cannot make Point object.\n");
+ return (Point *)NULL;
+ }
- // Create a new PointACIS object
- return AcisQueryEngine::instance()->populate_topology_bridges( VERTEX_ptr );
+ // Create a new PointACIS object
+ return AcisQueryEngine::instance()->populate_topology_bridges( VERTEX_ptr );
- }
+}
- // This function creates a curve given an existing curve.
- Curve* AcisModifyEngine::make_Curve(Curve *curve_ptr) const
- {
- EDGE *EDGE_ptr, *new_EDGE_ptr = NULL;
- CurveACIS *curve_ACIS = CAST_TO(curve_ptr, CurveACIS);
- if (!curve_ACIS)
- {
- PRINT_ERROR("Cannot create an ACIS curve from the given curve.\n"
- "Possible incompatible geometry engines.\n");
- return (Curve *)NULL;
- }
- EDGE_ptr = curve_ACIS->get_EDGE_ptr();
+// This function creates a curve given an existing curve.
+Curve* AcisModifyEngine::make_Curve(Curve *curve_ptr) const
+{
+ EDGE *EDGE_ptr, *new_EDGE_ptr = NULL;
+ CurveACIS *curve_ACIS = CAST_TO(curve_ptr, CurveACIS);
+ if (!curve_ACIS)
+ {
+ PRINT_ERROR("Cannot create an ACIS curve from the given curve.\n"
+ "Possible incompatible geometry engines.\n");
+ return (Curve *)NULL;
+ }
+ EDGE_ptr = curve_ACIS->get_EDGE_ptr();
- outcome result = api_edge( EDGE_ptr, new_EDGE_ptr );
+ outcome result = api_edge( EDGE_ptr, new_EDGE_ptr );
- if ( !result.ok() || new_EDGE_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
- " Cannot make Curve object.\n");
- return (Curve *)NULL;
- }
+ if ( !result.ok() || new_EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
+ " Cannot make Curve object.\n");
+ return (Curve *)NULL;
+ }
- // Create a new CurveACIS object
- // Use the new EDGE to create a new CurveACIS
- return AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
- }
+ // Create a new CurveACIS object
+ // Use the new EDGE to create a new CurveACIS
+ return AcisQueryEngine::instance()->populate_topology_bridges(new_EDGE_ptr);
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a Curve of type, curve_type,
- // given the end points of the curve and an intermediate
- // point. The particular type of Curve object that is
- // created depends on the specific modeling engine. For
- // example, if the engine is AcisModifyEngine, then a
- // CurveACIS is created and returned.
- //
- // Special Notes :
- //
- // Creator : Raikanta Sahu
- //
- // Creation Date : 03/29/97
- //-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+// Purpose : This function creates a Curve of type, curve_type,
+// given the end points of the curve and an intermediate
+// point. The particular type of Curve object that is
+// created depends on the specific modeling engine. For
+// example, if the engine is AcisModifyEngine, then a
+// CurveACIS is created and returned.
+//
+// Special Notes :
+//
+// Creator : Raikanta Sahu
+//
+// Creation Date : 03/29/97
+//-------------------------------------------------------------------------
- Curve* AcisModifyEngine::make_Curve( GeometryType curve_type,
+Curve* AcisModifyEngine::make_Curve( GeometryType curve_type,
Point const* point1_ptr,
Point const* point2_ptr,
CubitVector const* intermediate_point_ptr,
CubitSense sense) const
- {
- // Extract the VERTEXes from the Points and construct a SPAposition
- // from the cubit SPAvector.
+{
+ // Extract the VERTEXes from the Points and construct a SPAposition
+ // from the cubit SPAvector.
- // Cast the Points to PointACIS
- PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
- PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
+ // Cast the Points to PointACIS
+ PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
+ PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
- // Make sure that we don't get NULL pointers after the cast down.
- assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
+ // Make sure that we don't get NULL pointers after the cast down.
+ assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
- // Get a reference to the VERTEX list of the PointACIS
- VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
- VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
+ // Get a reference to the VERTEX list of the PointACIS
+ VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
+ VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
- SPAposition* pos_ptr = NULL ;
- SPAposition pos ;
+ SPAposition* pos_ptr = NULL ;
+ SPAposition pos ;
- if ( curve_type != STRAIGHT_CURVE_TYPE )
- {
- assert ( intermediate_point_ptr != NULL) ;
+ if ( curve_type != STRAIGHT_CURVE_TYPE )
+ {
+ assert ( intermediate_point_ptr != NULL) ;
- // Construct a SPAposition from the given intermediate point.
- pos = SPAposition (intermediate_point_ptr->x(),
- intermediate_point_ptr->y(),
- intermediate_point_ptr->z()) ;
- pos_ptr = &pos ;
- }
+ // Construct a SPAposition from the given intermediate point.
+ pos = SPAposition (intermediate_point_ptr->x(),
+ intermediate_point_ptr->y(),
+ intermediate_point_ptr->z()) ;
+ pos_ptr = &pos ;
+ }
- logical acis_sense = TRUE;
- if ( sense == CUBIT_REVERSED )
- {
- acis_sense = FALSE;
- }
+ logical acis_sense = TRUE;
+ if ( sense == CUBIT_REVERSED )
+ {
+ acis_sense = FALSE;
+ }
- // Use the VERTEXes and the SPAposition to make a new EDGE
- EDGE* EDGE_ptr = this->make_EDGE(curve_type,
- VERTEX_ptr1,
- VERTEX_ptr2,
- pos_ptr,
- acis_sense == TRUE) ;
+ // Use the VERTEXes and the SPAposition to make a new EDGE
+ EDGE* EDGE_ptr = this->make_EDGE(curve_type,
+ VERTEX_ptr1,
+ VERTEX_ptr2,
+ pos_ptr,
+ acis_sense == TRUE) ;
- if ( EDGE_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
- " Cannot make Curve object.\n");
- return (Curve *)NULL;
- }
+ if ( EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
+ " Cannot make Curve object.\n");
+ return (Curve *)NULL;
+ }
- // Use the new EDGE to create a new CurveACIS
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- }
+ // Use the new EDGE to create a new CurveACIS
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a Curve of type, curve_type,
- // given the end points of the curve and an intermediate
- // point. The particular type of Curve object that is
- // created depends on the specific modeling engine. For
- // example, if the engine is AcisModifyEngine, then a
- // CurveACIS is created and returned.
- //
- // Special Notes :
- //
- // Creator : Malcolm J. Panthaki
- //
- // Creation Date : 05/16/97
- //-------------------------------------------------------------------------
- Curve* AcisModifyEngine::make_Curve( GeometryType curve_type,
+//-------------------------------------------------------------------------
+// Purpose : This function creates a Curve of type, curve_type,
+// given the end points of the curve and an intermediate
+// point. The particular type of Curve object that is
+// created depends on the specific modeling engine. For
+// example, if the engine is AcisModifyEngine, then a
+// CurveACIS is created and returned.
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 05/16/97
+//-------------------------------------------------------------------------
+Curve* AcisModifyEngine::make_Curve( GeometryType curve_type,
Point const* point1_ptr,
Point const* point2_ptr,
DLIList<CubitVector*>& vector_list,
Surface* ref_face_ptr ) const
- {
- // We make splines here :-)
- if ( curve_type != SPLINE_CURVE_TYPE )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
- " Can only make spline surves in this routine.\n");
- return (Curve *)NULL;
- }
+{
+ // We make splines here :-)
+ if ( curve_type != SPLINE_CURVE_TYPE )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
+ " Can only make spline surves in this routine.\n");
+ return (Curve *)NULL;
+ }
- // Extract the VERTEXes from the Points.
+ // Extract the VERTEXes from the Points.
- // Cast the Points to PointACIS
- PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
- PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
+ // Cast the Points to PointACIS
+ PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
+ PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
- // Make sure that we don't get NULL pointers after the cast down.
- assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
+ // Make sure that we don't get NULL pointers after the cast down.
+ assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
- // Get a reference to the VERTEX list of the PointACIS
- VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
- VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
+ // Get a reference to the VERTEX list of the PointACIS
+ VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
+ VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
- // Convert the list of CubitVectors into an array of ACIS position's.
- // MJP NOTE:
- // Add the positions of the 2 end VERTEX'es into this list.
- int number_points = vector_list.size();
- vector_list.reset();
- CubitVector* vector_ptr = NULL, on_surf;
- SPAposition* pos_array = new SPAposition [number_points];
+ // Convert the list of CubitVectors into an array of ACIS position's.
+ // MJP NOTE:
+ // Add the positions of the 2 end VERTEX'es into this list.
+ int number_points = vector_list.size();
+ vector_list.reset();
+ CubitVector* vector_ptr = NULL, on_surf;
+ SPAposition* pos_array = new SPAposition [number_points];
- // Do the vector_list of points
- for (int i = 0; i < number_points; i++)
- {
- vector_ptr = vector_list.get_and_step();
+ // Do the vector_list of points
+ for (int i = 0; i < number_points; i++)
+ {
+ vector_ptr = vector_list.get_and_step();
- // If the input RefFace pointer is not NULL, then move this point
- // to the surface of the RefFace
- if (ref_face_ptr != NULL)
- {
- ref_face_ptr->closest_point(*vector_ptr, &on_surf);
- *vector_ptr = on_surf;
- //ref_face_ptr->move_to_surface(*vector_ptr);
- }
+ // If the input RefFace pointer is not NULL, then move this point
+ // to the surface of the RefFace
+ if (ref_face_ptr != NULL)
+ {
+ ref_face_ptr->closest_point(*vector_ptr, &on_surf);
+ *vector_ptr = on_surf;
+ //ref_face_ptr->move_to_surface(*vector_ptr);
+ }
- // Set the coordinates of the SPAposition object
- pos_array[i].set_x(vector_ptr->x());
- pos_array[i].set_y(vector_ptr->y());
- pos_array[i].set_z(vector_ptr->z());
- }
+ // Set the coordinates of the SPAposition object
+ pos_array[i].set_x(vector_ptr->x());
+ pos_array[i].set_y(vector_ptr->y());
+ pos_array[i].set_z(vector_ptr->z());
+ }
- // Use the VERTEXes and the SPAposition array to make a new EDGE
- EDGE* EDGE_ptr = this->make_spline_EDGE( VERTEX_ptr1,
- VERTEX_ptr2,
- pos_array,
- number_points );
- // Free memory
- delete [] pos_array;
+ // Use the VERTEXes and the SPAposition array to make a new EDGE
+ EDGE* EDGE_ptr = this->make_spline_EDGE( VERTEX_ptr1,
+ VERTEX_ptr2,
+ pos_array,
+ number_points );
+ // Free memory
+ delete [] pos_array;
- if ( EDGE_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
- " Cannot make Curve object.\n");
- return (Curve *)NULL;
- }
+ if ( EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
+ " Cannot make Curve object.\n");
+ return (Curve *)NULL;
+ }
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- }
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creats a curve that is on a
- // given surface. The third point is used
- // for curves that could be periodic to dertermine
- // the correct direction.
- //
- //
- // Creator : David White
- //
- // Creation Date : 10/21/97
- //-------------------------------------------------------------------------
- Curve* AcisModifyEngine::make_Curve( Point const* point1_ptr,
- Point const* point2_ptr,
- Surface* ref_face_ptr,
- const CubitVector *third_point) const
+//-------------------------------------------------------------------------
+// Purpose : This function creats a curve that is on a
+// given surface. The third point is used
+// for curves that could be periodic to dertermine
+// the correct direction.
+//
+//
+// Creator : David White
+//
+// Creation Date : 10/21/97
+//-------------------------------------------------------------------------
+Curve* AcisModifyEngine::make_Curve( Point const* point1_ptr,
+ Point const* point2_ptr,
+ Surface* ref_face_ptr,
+ const CubitVector *third_point) const
- {
- CubitVector point_1 = point1_ptr->coordinates();
- CubitVector point_2 = point2_ptr->coordinates();
- CubitVector surf_norm;
- ref_face_ptr->closest_point( point_1, NULL, &surf_norm );
+{
+ CubitVector point_1 = point1_ptr->coordinates();
+ CubitVector point_2 = point2_ptr->coordinates();
+ CubitVector surf_norm;
+ ref_face_ptr->closest_point( point_1, NULL, &surf_norm );
- CubitVector plane_norm;
+ CubitVector plane_norm;
- CubitVector edge0 = point_2 - point_1;
- CubitVector edge1 = surf_norm;
+ CubitVector edge0 = point_2 - point_1;
+ CubitVector edge1 = surf_norm;
+ plane_norm = edge0*edge1;
+ if ( plane_norm.length() < CUBIT_RESABS )
+ {
+ //try using the normal at point 2.
+ ref_face_ptr->closest_point(point_2, NULL, &surf_norm);
+ edge1 = surf_norm;
+ edge0 = point_1 - point_2;
plane_norm = edge0*edge1;
if ( plane_norm.length() < CUBIT_RESABS )
- {
- //try using the normal at point 2.
- ref_face_ptr->closest_point(point_2, NULL, &surf_norm);
- edge1 = surf_norm;
- edge0 = point_1 - point_2;
- plane_norm = edge0*edge1;
- if ( plane_norm.length() < CUBIT_RESABS )
- {
- if ( third_point == NULL )
- {
- PRINT_ERROR("Can't create curve on surface.\n"
- "\tVertices are on opposite sides of surface.\n"
- "\tUnable to infer a plane that will cut the surface.\n"
- "\tTry specifying a 3rd vertex in the new curve.\n");
- return (Curve*)NULL;
- }
- else
- {
- // Try getting a normal from the third point
- edge0 = point_1 - *third_point;
- plane_norm = edge0*edge1;
- if ( plane_norm.length() < CUBIT_RESABS )
- {
- PRINT_ERROR("Can't create curve on surface.\n"
- "\tVertices are on opposite sides of surface\n"
- "\tand all three points are colinear.\n"
- "\tTry specifying a non-colinear 3rd vertex.\n");
- return (Curve*)NULL;
- }
- }
- }
- }
- plane_norm.normalize();
- // Extract the VERTEXes from the Points.
+ {
+ if ( third_point == NULL )
+ {
+ PRINT_ERROR("Can't create curve on surface.\n"
+ "\tVertices are on opposite sides of surface.\n"
+ "\tUnable to infer a plane that will cut the surface.\n"
+ "\tTry specifying a 3rd vertex in the new curve.\n");
+ return (Curve*)NULL;
+ }
+ else
+ {
+ // Try getting a normal from the third point
+ edge0 = point_1 - *third_point;
+ plane_norm = edge0*edge1;
+ if ( plane_norm.length() < CUBIT_RESABS )
+ {
+ PRINT_ERROR("Can't create curve on surface.\n"
+ "\tVertices are on opposite sides of surface\n"
+ "\tand all three points are colinear.\n"
+ "\tTry specifying a non-colinear 3rd vertex.\n");
+ return (Curve*)NULL;
+ }
+ }
+ }
+ }
+ plane_norm.normalize();
+ // Extract the VERTEXes from the Points.
- // Cast the Points to PointACIS
- PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
- PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
+ // Cast the Points to PointACIS
+ PointACIS* pointACIS_ptr1 = CAST_TO(const_cast<Point*>(point1_ptr), PointACIS) ;
+ PointACIS* pointACIS_ptr2 = CAST_TO(const_cast<Point*>(point2_ptr), PointACIS) ;
- // Make sure that we don't get NULL pointers after the cast down.
- assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
+ // Make sure that we don't get NULL pointers after the cast down.
+ assert ( pointACIS_ptr1 != NULL && pointACIS_ptr2 != NULL ) ;
- // Get a reference to the VERTEX list of the PointACIS
- VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
- VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
+ // Get a reference to the VERTEX list of the PointACIS
+ VERTEX* VERTEX_ptr1 = pointACIS_ptr1->get_VERTEX_ptr();
+ VERTEX* VERTEX_ptr2 = pointACIS_ptr2->get_VERTEX_ptr();
- FACE *FACE_ptr = CAST_TO(ref_face_ptr, SurfaceACIS )->get_FACE_ptr();
- //now using the points, vertices, FACE and plane normal,
- //creat an edge.
- EDGE* EDGE_ptr = this->make_surface_EDGE( VERTEX_ptr1,
- VERTEX_ptr2,
- FACE_ptr,
- plane_norm,
- third_point);
- // Free memory
- if ( EDGE_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
- " Cannot make Curve object.\n");
- return (Curve *)NULL;
- }
+ FACE *FACE_ptr = CAST_TO(ref_face_ptr, SurfaceACIS )->get_FACE_ptr();
+ //now using the points, vertices, FACE and plane normal,
+ //creat an edge.
+ EDGE* EDGE_ptr = this->make_surface_EDGE( VERTEX_ptr1,
+ VERTEX_ptr2,
+ FACE_ptr,
+ plane_norm,
+ third_point);
+ // Free memory
+ if ( EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Curve\n"
+ " Cannot make Curve object.\n");
+ return (Curve *)NULL;
+ }
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- }
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- //-------------------------------------------------------------------------
- // Purpose : Create a surface given a surface. From another surface
- //
- // Special Notes :
- //
- // Creator : David White
- //
- // Creation Date : 10/6/97
- //-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+// Purpose : Create a surface given a surface. From another surface
+//
+// Special Notes :
+//
+// Creator : David White
+//
+// Creation Date : 10/6/97
+//-------------------------------------------------------------------------
- Surface* AcisModifyEngine::make_Surface( Surface *old_surface_ptr,
+Surface* AcisModifyEngine::make_Surface( Surface *old_surface_ptr,
bool extended_from) const
- {
- //Get the surface ACIS.
- SurfaceACIS *surf_ACIS = CAST_TO(old_surface_ptr, SurfaceACIS );
- if (surf_ACIS == NULL)
- {
- PRINT_ERROR("surface is not created from acis.\n");
- return (Surface*) NULL;
- }
+{
+ //Get the surface ACIS.
+ SurfaceACIS *surf_ACIS = CAST_TO(old_surface_ptr, SurfaceACIS );
+ if (surf_ACIS == NULL)
+ {
+ PRINT_ERROR("surface is not created from acis.\n");
+ return (Surface*) NULL;
+ }
- //Get the acis face.
- FACE *FACE_ptr = surf_ACIS->get_FACE_ptr();
+ //Get the acis face.
+ FACE *FACE_ptr = surf_ACIS->get_FACE_ptr();
- //use this to make a FACE.
- if (FACE_ptr == NULL )
- {
- PRINT_ERROR("surface is not created from acis.\n");
- return (Surface*) NULL;
- }
- FACE *new_FACE_ptr = NULL;
+ //use this to make a FACE.
+ if (FACE_ptr == NULL )
+ {
+ PRINT_ERROR("surface is not created from acis.\n");
+ return (Surface*) NULL;
+ }
+ FACE *new_FACE_ptr = NULL;
- new_FACE_ptr = make_FACE( FACE_ptr, extended_from );
- if (new_FACE_ptr == NULL)
- {
- PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
- " Cannot make Surface object.\n");
- return (Surface *)NULL;
- }
+ new_FACE_ptr = make_FACE( FACE_ptr, extended_from );
+ if (new_FACE_ptr == NULL)
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
+ " Cannot make Surface object.\n");
+ return (Surface *)NULL;
+ }
- //populate the bridges from the body
- BODY *body_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(new_FACE_ptr);
- BodySM *body_sm = AcisQueryEngine::instance()->populate_topology_bridges( body_ptr );
- DLIList<Surface*> surfs;
- body_sm->surfaces( surfs );
- Surface *surface = surfs.get();
+ //populate the bridges from the body
+ BODY *body_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(new_FACE_ptr);
+ BodySM *body_sm = AcisQueryEngine::instance()->populate_topology_bridges( body_ptr );
+ DLIList<Surface*> surfs;
+ body_sm->surfaces( surfs );
+ Surface *surface = surfs.get();
- return surface;
+ return surface;
- }
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a Surface of type,
- // surface_type, given the list of curves.
- //
- // Special Notes :
- //
- // Creator : Raikanta Sahu
- //
- // Creation Date : 03/29/97
- //-------------------------------------------------------------------------
- Surface* AcisModifyEngine::make_Surface( GeometryType surface_type,
+//-------------------------------------------------------------------------
+// Purpose : This function creates a Surface of type,
+// surface_type, given the list of curves.
+//
+// Special Notes :
+//
+// Creator : Raikanta Sahu
+//
+// Creation Date : 03/29/97
+//-------------------------------------------------------------------------
+Surface* AcisModifyEngine::make_Surface( GeometryType surface_type,
DLIList<Curve*>& curve_list,
Surface *old_surface_ptr,
bool check_edges ) const
+{
+ DLIList<RefEdge*> copied_ref_edges;
+ int i;
+ if( check_edges )
+ {
+ DLIList<RefEdge*> edge_list;
+ for( i=curve_list.size(); i--; )
{
- DLIList<RefEdge*> copied_ref_edges;
- int i;
- if( check_edges )
- {
- DLIList<RefEdge*> edge_list;
- for( i=curve_list.size(); i--; )
- {
- RefEdge *tmp_ref_edge = NULL;
- tmp_ref_edge = CAST_TO( curve_list.get_and_step()->topology_entity(), RefEdge );
- if( tmp_ref_edge )
- edge_list.append( tmp_ref_edge );
- }
+ RefEdge *tmp_ref_edge = NULL;
+ tmp_ref_edge = CAST_TO( curve_list.get_and_step()->topology_entity(), RefEdge );
+ if( tmp_ref_edge )
+ edge_list.append( tmp_ref_edge );
+ }
- //duplicate curves possibly
+ //duplicate curves possibly
- //Modified by J.K. to avoid core dump if vertices are merged.
- //If vertices belong to edges other than those we are creating
- //the surface from, copy the corresponding edges. This will
- //also pick up the case where edges already belong to a face.
- DLIList<RefEdge*> vtx_edges;
- DLIList<RefVertex*> vtx_list;
- for ( i = edge_list.size(); i > 0; i-- )
- {
- RefEdge *ref_edge = edge_list.get();
+ //Modified by J.K. to avoid core dump if vertices are merged.
+ //If vertices belong to edges other than those we are creating
+ //the surface from, copy the corresponding edges. This will
+ //also pick up the case where edges already belong to a face.
+ DLIList<RefEdge*> vtx_edges;
+ DLIList<RefVertex*> vtx_list;
+ for ( i = edge_list.size(); i > 0; i-- )
+ {
+ RefEdge *ref_edge = edge_list.get();
- CubitBoolean other_edge = CUBIT_FALSE;
- ref_edge->ref_vertices(vtx_list);
- while( vtx_list.size() )
- {
- vtx_edges.clean_out();
- vtx_list.pop()->ref_edges( vtx_edges );
- while( vtx_edges.size() )
- {
- if( ! edge_list.is_in_list( vtx_edges.pop() ) )
- {
- other_edge = CUBIT_TRUE;
- vtx_list.clean_out();
- break;
- }
- }
- }
+ CubitBoolean other_edge = CUBIT_FALSE;
+ ref_edge->ref_vertices(vtx_list);
+ while( vtx_list.size() )
+ {
+ vtx_edges.clean_out();
+ vtx_list.pop()->ref_edges( vtx_edges );
+ while( vtx_edges.size() )
+ {
+ if( ! edge_list.is_in_list( vtx_edges.pop() ) )
+ {
+ other_edge = CUBIT_TRUE;
+ vtx_list.clean_out();
+ break;
+ }
+ }
+ }
- if ( other_edge || (ref_edge->get_parents() > 0) )
- {
- RefEdge *replacement_edge = GeometryModifyTool::instance()->make_RefEdge( ref_edge );
- if (!replacement_edge)
- {
- PRINT_WARNING("Creation of Surface Unsuccessful\n");
- return (Surface *)NULL;
- }
- edge_list.change_to( replacement_edge );
- copied_ref_edges.append( replacement_edge );
- }
- edge_list.step();
- }
+ if ( other_edge || (ref_edge->get_parents() > 0) )
+ {
+ RefEdge *replacement_edge = GeometryModifyTool::instance()->make_RefEdge( ref_edge );
+ if (!replacement_edge)
+ {
+ PRINT_WARNING("Creation of Surface Unsuccessful\n");
+ return (Surface *)NULL;
+ }
+ edge_list.change_to( replacement_edge );
+ copied_ref_edges.append( replacement_edge );
+ }
+ edge_list.step();
+ }
- curve_list.clean_out();
- for( i=edge_list.size(); i--; )
- {
- Curve *tmp_curve = NULL;
- tmp_curve =
- CAST_TO( edge_list.get_and_step()->bridge_manager()->topology_bridge(), Curve);
- if( tmp_curve )
- curve_list.append( tmp_curve );
- }
- }
+ curve_list.clean_out();
+ for( i=edge_list.size(); i--; )
+ {
+ Curve *tmp_curve = NULL;
+ tmp_curve =
+ CAST_TO( edge_list.get_and_step()->bridge_manager()->topology_bridge(), Curve);
+ if( tmp_curve )
+ curve_list.append( tmp_curve );
+ }
+ }
- DLIList<EDGE*> EDGE_list ;
- // List of EDGEs to use to create the FACE from which we can make
- // a SurfaceACIS.
+ DLIList<EDGE*> EDGE_list ;
+ // List of EDGEs to use to create the FACE from which we can make
+ // a SurfaceACIS.
- // Extract the EDGEs from the given Curves
- Curve const* curve_ptr = NULL ;
- CurveACIS* curveACIS_ptr = NULL ;
- EDGE* EDGE_ptr = NULL ;
+ // Extract the EDGEs from the given Curves
+ Curve const* curve_ptr = NULL ;
+ CurveACIS* curveACIS_ptr = NULL ;
+ EDGE* EDGE_ptr = NULL ;
- curve_list.reset() ;
+ curve_list.reset() ;
- for ( i = 0 ; i < curve_list.size() ; i++ )
- {
- curve_ptr = curve_list.get_and_step() ;
- curveACIS_ptr = CAST_TO(const_cast<Curve*>(curve_ptr), CurveACIS) ;
+ for ( i = 0 ; i < curve_list.size() ; i++ )
+ {
+ curve_ptr = curve_list.get_and_step() ;
+ curveACIS_ptr = CAST_TO(const_cast<Curve*>(curve_ptr), CurveACIS) ;
- // Make sure that we don't get NULL pointers after the cast down.
- if ( curveACIS_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
- " Got a NULL pointer to CurveACIS\n") ;
- assert ( curveACIS_ptr != NULL ) ;
- }
+ // Make sure that we don't get NULL pointers after the cast down.
+ if ( curveACIS_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
+ " Got a NULL pointer to CurveACIS\n") ;
+ assert ( curveACIS_ptr != NULL ) ;
+ }
- // Get the EDGE
- EDGE_ptr = curveACIS_ptr->get_EDGE_ptr() ;
+ // Get the EDGE
+ EDGE_ptr = curveACIS_ptr->get_EDGE_ptr() ;
- // Add the EDGE to the list of EDGEs to be used to make a FACE
- EDGE_list.append(EDGE_ptr) ;
- }
+ // Add the EDGE to the list of EDGEs to be used to make a FACE
+ EDGE_list.append(EDGE_ptr) ;
+ }
- // Use the EDGEs to make a FACE
- FACE* FACE_ptr = this->make_FACE(surface_type, EDGE_list,
- old_surface_ptr) ;
+ // Use the EDGEs to make a FACE
+ FACE* FACE_ptr = this->make_FACE(surface_type, EDGE_list,
+ old_surface_ptr) ;
- if (FACE_ptr == NULL)
- {
- //delete all the copied ref edges...copied just for creating this surface
- for(i=copied_ref_edges.size(); i--; )
- GeometryQueryTool::instance()->delete_RefEdge( copied_ref_edges.get_and_step() );
+ if (FACE_ptr == NULL)
+ {
+ //delete all the copied ref edges...copied just for creating this surface
+ for(i=copied_ref_edges.size(); i--; )
+ GeometryQueryTool::instance()->delete_RefEdge( copied_ref_edges.get_and_step() );
- PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
- " Cannot make Surface object.\n");
- return (Surface *)NULL;
- }
+ PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
+ " Cannot make Surface object.\n");
+ return (Surface *)NULL;
+ }
- // make the topology bridges for the face
- Surface *surface = AcisQueryEngine::instance()->populate_topology_bridges(FACE_ptr);
- return surface;
+ // make the topology bridges for the face
+ Surface *surface = AcisQueryEngine::instance()->populate_topology_bridges(FACE_ptr);
+ return surface;
- /*
+/*
- // now generate the body
- DLIList<BODY*> new_BODIES;
- DLIList<Body*> new_bodies;
- new_BODIES.append(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr));
- CubitStatus success = get_new_Body(old_entities,
- new_BODIES, new_bodies, CUBIT_FALSE);
+ // now generate the body
+ DLIList<BODY*> new_BODIES;
+ DLIList<Body*> new_bodies;
+ new_BODIES.append(AcisQueryEngine::instance()->get_BODY_of_ENTITY(FACE_ptr));
+ CubitStatus success = get_new_Body(old_entities,
+ new_BODIES, new_bodies, CUBIT_FALSE);
- AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(FACE_ptr);
- return CAST_TO(tb_ptr, Surface);
- */
- }
+ AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(FACE_ptr);
+ return CAST_TO(tb_ptr, Surface);
+*/
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a Lump of type, lump_type,
- // given the list of surfaces.
- //
- // Special Notes :
- //
- // Creator : Raikanta Sahu
- //
- // Creation Date : 03/29/97
- //-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+// Purpose : This function creates a Lump of type, lump_type,
+// given the list of surfaces.
+//
+// Special Notes :
+//
+// Creator : Raikanta Sahu
+//
+// Creation Date : 03/29/97
+//-------------------------------------------------------------------------
- Lump* AcisModifyEngine::make_Lump( DLIList<Surface*>& surface_list ) const
- {
- // Extract the FACEs of the surface list. Use the FACEs to
- // create a SHELL.
- Surface const* surface_ptr = NULL ;
- SurfaceACIS* surfaceACIS_ptr = NULL ;
- FACE* first_FACE_ptr = NULL ;
- FACE* current_FACE_ptr = NULL ;
- FACE* previous_FACE_ptr = NULL ;
+Lump* AcisModifyEngine::make_Lump( DLIList<Surface*>& surface_list ) const
+{
+ // Extract the FACEs of the surface list. Use the FACEs to
+ // create a SHELL.
+ Surface const* surface_ptr = NULL ;
+ SurfaceACIS* surfaceACIS_ptr = NULL ;
+ FACE* first_FACE_ptr = NULL ;
+ FACE* current_FACE_ptr = NULL ;
+ FACE* previous_FACE_ptr = NULL ;
- surface_list.reset() ;
- for ( int i = 0 ; i < surface_list.size() ; i++ )
- {
- surface_ptr = surface_list.get_and_step() ;
- surfaceACIS_ptr = CAST_TO(const_cast<Surface*>(surface_ptr), SurfaceACIS) ;
+ surface_list.reset() ;
+ for ( int i = 0 ; i < surface_list.size() ; i++ )
+ {
+ surface_ptr = surface_list.get_and_step() ;
+ surfaceACIS_ptr = CAST_TO(const_cast<Surface*>(surface_ptr), SurfaceACIS) ;
- // Make sure that we have a valid SurfaceACIS pointer
- if ( surfaceACIS_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
- " Got a NULL pointer to SurfaceACIS\n") ;
- assert ( surfaceACIS_ptr != NULL ) ;
- }
+ // Make sure that we have a valid SurfaceACIS pointer
+ if ( surfaceACIS_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
+ " Got a NULL pointer to SurfaceACIS\n") ;
+ assert ( surfaceACIS_ptr != NULL ) ;
+ }
- current_FACE_ptr = surfaceACIS_ptr->get_FACE_ptr();
+ current_FACE_ptr = surfaceACIS_ptr->get_FACE_ptr();
- // Connect up the previous FACE and the current FACE if
- // the current FACE is not the first FACE.
- if ( previous_FACE_ptr != NULL )
- {
- previous_FACE_ptr->set_next(current_FACE_ptr) ;
- }
- else
- {
- first_FACE_ptr = current_FACE_ptr ;
- }
+ // Connect up the previous FACE and the current FACE if
+ // the current FACE is not the first FACE.
+ if ( previous_FACE_ptr != NULL )
+ {
+ previous_FACE_ptr->set_next(current_FACE_ptr) ;
+ }
+ else
+ {
+ first_FACE_ptr = current_FACE_ptr ;
+ }
- previous_FACE_ptr = current_FACE_ptr ;
- }
+ previous_FACE_ptr = current_FACE_ptr ;
+ }
- // Create a new SHELL if the first FACE is not attached to
- // a SHELL.
- SHELL* SHELL_ptr = first_FACE_ptr->shell() ;
+ // Create a new SHELL if the first FACE is not attached to
+ // a SHELL.
+ SHELL* SHELL_ptr = first_FACE_ptr->shell() ;
+ if ( SHELL_ptr == NULL )
+ {
+ SHELL_ptr = new SHELL(first_FACE_ptr, NULL, NULL) ;
if ( SHELL_ptr == NULL )
- {
- SHELL_ptr = new SHELL(first_FACE_ptr, NULL, NULL) ;
- if ( SHELL_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
- " ACIS cannot make SHELL object.\n"
- " Cannot make Lump object.\n");
- return (Lump *)NULL;
- }
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
+ " ACIS cannot make SHELL object.\n"
+ " Cannot make Lump object.\n");
+ return (Lump *)NULL;
+ }
+ }
- // Create a new LUMP and attach the SHELL to it.
- LUMP* LUMP_ptr = SHELL_ptr->lump();
- if (LUMP_ptr == NULL)
- {
- LUMP_ptr = new LUMP(SHELL_ptr, NULL) ;
- if ( LUMP_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
- " ACIS cannot make LUMP object.\n"
- " Cannot make Lump object.\n");
- return (Lump *)NULL;
- }
- }
+ // Create a new LUMP and attach the SHELL to it.
+ LUMP* LUMP_ptr = SHELL_ptr->lump();
+ if (LUMP_ptr == NULL)
+ {
+ LUMP_ptr = new LUMP(SHELL_ptr, NULL) ;
+ if ( LUMP_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
+ " ACIS cannot make LUMP object.\n"
+ " Cannot make Lump object.\n");
+ return (Lump *)NULL;
+ }
+ }
- // Create a LumpACIS using the LUMP_ptr
- LumpACIS* lumpACIS_ptr = new LumpACIS(LUMP_ptr) ;
- assert( lumpACIS_ptr != NULL );
+ // Create a LumpACIS using the LUMP_ptr
+ LumpACIS* lumpACIS_ptr = new LumpACIS(LUMP_ptr) ;
+ assert( lumpACIS_ptr != NULL );
- AcisQueryEngine::instance()->populate_topology_bridges(LUMP_ptr);
- /*
- AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(LUMP_ptr);
+ AcisQueryEngine::instance()->populate_topology_bridges(LUMP_ptr);
+/*
+ AcisBridge *tb_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(LUMP_ptr);
- Lump *this_lump = CAST_TO(tb_ptr, Lump);
- ShellSM *shellsm = this_lump->shellsm();
+ Lump *this_lump = CAST_TO(tb_ptr, Lump);
+ ShellSM *shellsm = this_lump->shellsm();
- // Use the SHELL to build VGI Shell and CoFace, using 0 for color
- Shell* Shell_ptr = GeometryQueryTool::instance()->make_Shell(shellsm) ;
+ // Use the SHELL to build VGI Shell and CoFace, using 0 for color
+ Shell* Shell_ptr = GeometryQueryTool::instance()->make_Shell(shellsm) ;
- if (Shell_ptr == NULL)
- {
- PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
- " Could not build a Shell for unknown reasons.\n");
- return (Lump *)NULL;
- }
- */
- // Return the new LumpACIS
- return lumpACIS_ptr ;
- }
+ if (Shell_ptr == NULL)
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
+ " Could not build a Shell for unknown reasons.\n");
+ return (Lump *)NULL;
+ }
+*/
+ // Return the new LumpACIS
+ return lumpACIS_ptr ;
+}
- BodySM* AcisModifyEngine::make_BodySM( Surface *surface_ptr) const
- {
- //- given a Surface, make a BodySM
- // make sure this Surface is the right type
- SurfaceACIS *sa_ptr = CAST_TO(surface_ptr, SurfaceACIS);
- assert(sa_ptr != 0);
+BodySM* AcisModifyEngine::make_BodySM( Surface *surface_ptr) const
+{
+ //- given a Surface, make a BodySM
+ // make sure this Surface is the right type
+ SurfaceACIS *sa_ptr = CAST_TO(surface_ptr, SurfaceACIS);
+ assert(sa_ptr != 0);
- // now, get the acis BODY and populate the topology bridges
- FACE *face = sa_ptr->get_FACE_ptr();
- BODY *body_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(face);
+ // now, get the acis BODY and populate the topology bridges
+ FACE *face = sa_ptr->get_FACE_ptr();
+ BODY *body_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(face);
- return AcisQueryEngine::instance()->populate_topology_bridges(body_ptr);
- }
+ return AcisQueryEngine::instance()->populate_topology_bridges(body_ptr);
+}
- //-------------------------------------------------------------------------
- // Purpose : This function creates a BodySM given a list of Lumps.
- //
- // Special Notes :
- //
- // Creator : Raikanta Sahu
- //
- // Creation Date : 03/29/97
- //-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+// Purpose : This function creates a BodySM given a list of Lumps.
+//
+// Special Notes :
+//
+// Creator : Raikanta Sahu
+//
+// Creation Date : 03/29/97
+//-------------------------------------------------------------------------
- BodySM* AcisModifyEngine::make_BodySM( DLIList<Lump*>& lump_list ) const
- {
- // Extract the LUMPs of the lump list. Use the LUMPs to
- // create a BODY.
- Lump const* lump_ptr = NULL ;
- LumpACIS* lumpACIS_ptr = NULL ;
- LUMP* first_LUMP_ptr = NULL ;
- LUMP* current_LUMP_ptr = NULL ;
- LUMP* previous_LUMP_ptr = NULL ;
+BodySM* AcisModifyEngine::make_BodySM( DLIList<Lump*>& lump_list ) const
+{
+ // Extract the LUMPs of the lump list. Use the LUMPs to
+ // create a BODY.
+ Lump const* lump_ptr = NULL ;
+ LumpACIS* lumpACIS_ptr = NULL ;
+ LUMP* first_LUMP_ptr = NULL ;
+ LUMP* current_LUMP_ptr = NULL ;
+ LUMP* previous_LUMP_ptr = NULL ;
- lump_list.reset() ;
- for ( int i = 0 ; i < lump_list.size() ; i++ )
- {
- lump_ptr = lump_list.get_and_step() ;
- lumpACIS_ptr = CAST_TO(const_cast<Lump*>(lump_ptr), LumpACIS) ;
+ lump_list.reset() ;
+ for ( int i = 0 ; i < lump_list.size() ; i++ )
+ {
+ lump_ptr = lump_list.get_and_step() ;
+ lumpACIS_ptr = CAST_TO(const_cast<Lump*>(lump_ptr), LumpACIS) ;
- // Make sure that we have a valid LumpACIS pointer
- if ( lumpACIS_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
- " Input Lump is not a LumpACIS\n") ;
- assert ( lumpACIS_ptr != NULL ) ;
- }
+ // Make sure that we have a valid LumpACIS pointer
+ if ( lumpACIS_ptr == NULL )
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Lump\n"
+ " Input Lump is not a LumpACIS\n") ;
+ assert ( lumpACIS_ptr != NULL ) ;
+ }
- current_LUMP_ptr = lumpACIS_ptr->get_LUMP_ptr();
+ current_LUMP_ptr = lumpACIS_ptr->get_LUMP_ptr();
- // Connect up the previous LUMP and the current LUMP if
- // the current LUMP is not the first LUMP.
- if ( previous_LUMP_ptr != NULL )
- {
- previous_LUMP_ptr->set_next(current_LUMP_ptr) ;
- }
- else
- {
- first_LUMP_ptr = current_LUMP_ptr ;
- }
+ // Connect up the previous LUMP and the current LUMP if
+ // the current LUMP is not the first LUMP.
+ if ( previous_LUMP_ptr != NULL )
+ {
+ previous_LUMP_ptr->set_next(current_LUMP_ptr) ;
+ }
+ else
+ {
+ first_LUMP_ptr = current_LUMP_ptr ;
+ }
- previous_LUMP_ptr = current_LUMP_ptr ;
- }
+ previous_LUMP_ptr = current_LUMP_ptr ;
+ }
- // Create a new BODY if the first LUMP is not attached to
- // a BODY.
- BODY* BODY_ptr = first_LUMP_ptr->body() ;
+ // Create a new BODY if the first LUMP is not attached to
+ // a BODY.
+ BODY* BODY_ptr = first_LUMP_ptr->body() ;
+ if ( BODY_ptr == NULL )
+ {
+ BODY_ptr = new BODY(first_LUMP_ptr) ;
if ( BODY_ptr == NULL )
- {
- BODY_ptr = new BODY(first_LUMP_ptr) ;
- if ( BODY_ptr == NULL )
- {
- PRINT_ERROR("In AcisModifyEngine::make_BodySM\n"
- " ACIS cannot make BODY object.\n"
- " Cannot make BodySM object.\n");
- return (BodySM *)NULL;
- }
- }
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_BodySM\n"
+ " ACIS cannot make BODY object.\n"
+ " Cannot make BodySM object.\n");
+ return (BodySM *)NULL;
+ }
+ }
- // Use the BODY to build VGI Body and CoVolume(s)
- BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODY_ptr);
+ // Use the BODY to build VGI Body and CoVolume(s)
+ BodySM *this_bodysm = AcisQueryEngine::instance()->populate_topology_bridges(BODY_ptr);
- /* Commenting out following section - we shouldn't be making
- Body's yet!!!
+ /* Commenting out following section - we shouldn't be making
+ Body's yet!!!
- Body* body_ptr = GeometryModifyTool::instance()->make_Body(this_bodysm);
- assert( body_ptr != NULL );
+ Body* body_ptr = GeometryModifyTool::instance()->make_Body(this_bodysm);
+ assert( body_ptr != NULL );
- // First get the OSME associated with this Body
- BodySM* OSME_ptr =
- body_ptr->get_body_sm_ptr() ;
+ // First get the OSME associated with this Body
+ BodySM* OSME_ptr =
+ body_ptr->get_body_sm_ptr() ;
- // Cast the OSME to BodyACIS
- BodyACIS* bodyACIS_ptr = CAST_TO(OSME_ptr, BodyACIS) ;
+ // Cast the OSME to BodyACIS
+ BodyACIS* bodyACIS_ptr = CAST_TO(OSME_ptr, BodyACIS) ;
- // Make sure that we have a valid BodyACIS
- assert ( bodyACIS_ptr != NULL ) ;
- */
- // Return the BodyACIS
- return this_bodysm;
- }
+ // Make sure that we have a valid BodyACIS
+ assert ( bodyACIS_ptr != NULL ) ;
+ */
+ // Return the BodyACIS
+ return this_bodysm;
+}
- CubitStatus AcisModifyEngine::regularize_body( BodySM *body_ptr,
- BodySM *&new_body_ptr)
- {
- CubitBoolean new_ids = GeometryModifyTool::instance()->get_new_ids();
- CubitBoolean not_new_ids = (new_ids ? CUBIT_FALSE : CUBIT_TRUE);
- BODY *old_BODY = AcisQueryEngine::get_BODY(body_ptr );
- if (!old_BODY)
- return CUBIT_FAILURE;
- BODY *acis_BODY = this->copy_BODY(old_BODY, new_ids);
+CubitStatus AcisModifyEngine::regularize_body( BodySM *body_ptr,
+ BodySM *&new_body_ptr)
+{
+ CubitBoolean new_ids = GeometryModifyTool::instance()->get_new_ids();
+ CubitBoolean not_new_ids = (new_ids ? CUBIT_FALSE : CUBIT_TRUE);
- outcome result = api_clean_entity( (ENTITY*) acis_BODY);
- //outcome result = api_regularise_entity( (ENTITY*) acis_BODY);
- if (!result.ok() || acis_BODY == NULL ||
- acis_BODY->lump() == NULL )
- {
- PRINT_ERROR("found in AcisModifyEngine::regularize_body.\n"
- "api_regularise_entity failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- AcisQueryEngine::instance()->delete_ACIS_BODY(acis_BODY, not_new_ids);
- return CUBIT_FAILURE;
- }
+ BODY *old_BODY = AcisQueryEngine::get_BODY(body_ptr );
+ if (!old_BODY)
+ return CUBIT_FAILURE;
+ BODY *acis_BODY = this->copy_BODY(old_BODY, new_ids);
- new_body_ptr = get_new_Body(body_ptr, old_BODY, acis_BODY, false);
+ outcome result = api_clean_entity( (ENTITY*) acis_BODY);
+ //outcome result = api_regularise_entity( (ENTITY*) acis_BODY);
+ if (!result.ok() || acis_BODY == NULL ||
+ acis_BODY->lump() == NULL )
+ {
+ PRINT_ERROR("found in AcisModifyEngine::regularize_body.\n"
+ "api_regularise_entity failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ AcisQueryEngine::instance()->delete_ACIS_BODY(acis_BODY, not_new_ids);
+ return CUBIT_FAILURE;
+ }
- if (new_body_ptr) return CUBIT_SUCCESS;
- else return CUBIT_FAILURE;
+ new_body_ptr = get_new_Body(body_ptr, old_BODY, acis_BODY, false);
- }
- //-------------------------------------------------------------------------
- // Purpose : clean RefEntity
- //
- // Special Notes :
- //
- // Creator : Lingyun Pan (CAT)
- //
- // Creation Date : 07/15/01
- //-------------------------------------------------------------------------
+ if (new_body_ptr) return CUBIT_SUCCESS;
+ else return CUBIT_FAILURE;
- CubitStatus AcisModifyEngine::regularize_entity( GeometryEntity *old_refentity_ptr,
- BodySM *&new_body_ptr)
- {
- CubitBoolean new_ids = GeometryModifyTool::instance()->get_new_ids();
- CubitBoolean not_new_ids = (new_ids ? CUBIT_FALSE : CUBIT_TRUE);
+}
+//-------------------------------------------------------------------------
+// Purpose : clean RefEntity
+//
+// Special Notes :
+//
+// Creator : Lingyun Pan (CAT)
+//
+// Creation Date : 07/15/01
+//-------------------------------------------------------------------------
- BODY *copied_BODY_ptr;
- SurfaceACIS *ref_face = CAST_TO(old_refentity_ptr, SurfaceACIS);
- CurveACIS *ref_edge= CAST_TO(old_refentity_ptr, CurveACIS);
- PointACIS *ref_vertex= CAST_TO(old_refentity_ptr, PointACIS);
+CubitStatus AcisModifyEngine::regularize_entity( GeometryEntity *old_refentity_ptr,
+ BodySM *&new_body_ptr)
+{
+ CubitBoolean new_ids = GeometryModifyTool::instance()->get_new_ids();
+ CubitBoolean not_new_ids = (new_ids ? CUBIT_FALSE : CUBIT_TRUE);
- DLIList<SurfaceACIS*> reg_face_list;
- DLIList<FACE*> FACE_list;
+ BODY *copied_BODY_ptr;
+ SurfaceACIS *ref_face = CAST_TO(old_refentity_ptr, SurfaceACIS);
+ CurveACIS *ref_edge= CAST_TO(old_refentity_ptr, CurveACIS);
+ PointACIS *ref_vertex= CAST_TO(old_refentity_ptr, PointACIS);
- DLIList<CurveACIS*> reg_edge_list;
- DLIList<EDGE*> EDGE_list;
+ DLIList<SurfaceACIS*> reg_face_list;
+ DLIList<FACE*> FACE_list;
- DLIList<PointACIS*> reg_vertex_list;
- DLIList<VERTEX*> VERTEX_list;
+ DLIList<CurveACIS*> reg_edge_list;
+ DLIList<EDGE*> EDGE_list;
- // get the copied_BODY_ptr and FACE_list to clean
- if (ref_face)
- {
+ DLIList<PointACIS*> reg_vertex_list;
+ DLIList<VERTEX*> VERTEX_list;
+
+ // get the copied_BODY_ptr and FACE_list to clean
+ if (ref_face)
+ {
reg_face_list.append(ref_face);
- if (get_copied_FACES_of_body( reg_face_list, FACE_list, copied_BODY_ptr )== CUBIT_FAILURE )
- {
- PRINT_ERROR("Surface has no volume associated with it.\n");
- return CUBIT_FAILURE;
- }
- }
+ if (get_copied_FACES_of_body( reg_face_list, FACE_list, copied_BODY_ptr )== CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Surface has no volume associated with it.\n");
+ return CUBIT_FAILURE;
+ }
+ }
- // get the copied_BODY_ptr and EDGE_list to clean
- if (ref_edge)
- {
+// get the copied_BODY_ptr and EDGE_list to clean
+ if (ref_edge)
+ {
reg_edge_list.append(ref_edge);
- if(get_copied_EDGES_of_body( reg_edge_list, EDGE_list, copied_BODY_ptr )== CUBIT_FAILURE )
- {
- PRINT_ERROR("Edge has no volume associated with it.\n");
- return CUBIT_FAILURE;
- }
- }
+ if(get_copied_EDGES_of_body( reg_edge_list, EDGE_list, copied_BODY_ptr )== CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Edge has no volume associated with it.\n");
+ return CUBIT_FAILURE;
+ }
+ }
- if (ref_vertex)
- {
+ if (ref_vertex)
+ {
reg_vertex_list.append(ref_vertex);
- if (get_copied_VERTICES_of_body( reg_vertex_list, VERTEX_list, copied_BODY_ptr )== CUBIT_FAILURE )
- {
- PRINT_ERROR("Vertex has no volume associated with it.\n");
- return CUBIT_FAILURE;
- }
- }
+ if (get_copied_VERTICES_of_body( reg_vertex_list, VERTEX_list, copied_BODY_ptr )== CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Vertex has no volume associated with it.\n");
+ return CUBIT_FAILURE;
+ }
+ }
- if (!ref_face && !ref_edge && !ref_vertex)
- {
+ if (!ref_face && !ref_edge && !ref_vertex)
+ {
//complain
- PRINT_ERROR("RefEntity is neither a RefEdge, RefFace, nor RefVertex.\n");
+ PRINT_ERROR("RefEntity is neither a RefEdge, RefFace, nor RefVertex.\n");
PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
- "api_regularise_refentity aborted.\n");
+ "api_regularise_refentity aborted.\n");
AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
- return CUBIT_FAILURE;
- }
+ return CUBIT_FAILURE;
+ }
- // Get original Body and BODY
- BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
+ // Get original Body and BODY
+ BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
- BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- int i;
- FACE *acis_FACE;
- EDGE *acis_EDGE;
- VERTEX *acis_VERTEX;
+ int i;
+ FACE *acis_FACE;
+ EDGE *acis_EDGE;
+ VERTEX *acis_VERTEX;
- //clean FACE
- for (i=0;i<FACE_list.size();i++)
- {
+ //clean FACE
+ for (i=0;i<FACE_list.size();i++)
+ {
acis_FACE = FACE_list.get_and_step();
outcome result = api_clean_entity( (ENTITY*) acis_FACE);
if (!result.ok() || acis_FACE == NULL )
- {
- PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
- "api_regularise_refentity failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
- return CUBIT_FAILURE;
- }
- }
+ {
+ PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
+ "api_regularise_refentity failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
+ return CUBIT_FAILURE;
+ }
+ }
- // clean EDGE
- for (i=0;i<EDGE_list.size();i++)
- {
+ // clean EDGE
+ for (i=0;i<EDGE_list.size();i++)
+ {
acis_EDGE = EDGE_list.get_and_step();
outcome result = api_clean_entity( (ENTITY*) acis_EDGE);
if (!result.ok() || acis_EDGE == NULL )
- {
- PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
- "api_regularise_refentity failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
- return CUBIT_FAILURE;
- }
- }
+ {
+ PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
+ "api_regularise_refentity failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
+ return CUBIT_FAILURE;
+ }
+ }
- // clean VERTEX
- for (i=0;i<VERTEX_list.size();i++)
- {
+ // clean VERTEX
+ for (i=0;i<VERTEX_list.size();i++)
+ {
acis_VERTEX = VERTEX_list.get_and_step();
outcome result = api_clean_entity( (ENTITY*) acis_VERTEX);
if (!result.ok() || acis_VERTEX == NULL )
- {
- PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
- "api_regularise_refentity failed.\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
- return CUBIT_FAILURE;
- }
- }
- //rebuild the cubit geometry
- new_body_ptr = get_new_Body( body_ptr, BODY_ptr , copied_BODY_ptr , false);
- if (new_body_ptr) return CUBIT_SUCCESS;
- else return CUBIT_FAILURE;
- }
+ {
+ PRINT_ERROR("found in AcisModifyEngine::regularize_refentity.\n"
+ "api_regularise_refentity failed.\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY_ptr, not_new_ids);
+ return CUBIT_FAILURE;
+ }
+ }
+ //rebuild the cubit geometry
+ new_body_ptr = get_new_Body( body_ptr, BODY_ptr , copied_BODY_ptr , false);
+ if (new_body_ptr) return CUBIT_SUCCESS;
+ else return CUBIT_FAILURE;
+}
- CubitStatus AcisModifyEngine::split_body( BodySM *body_ptr,
- DLIList<BodySM*> &new_bodies )
- {
- bool delete_attribs = GeometryModifyTool::instance()->get_new_ids() != 0;
- //get the acis body.
- BODY* acis_BODY = NULL;
- BODY **new_BODY_list;
- int n_body;
+CubitStatus AcisModifyEngine::split_body( BodySM *body_ptr,
+ DLIList<BodySM*> &new_bodies )
+{
+ bool delete_attribs = GeometryModifyTool::instance()->get_new_ids() != 0;
+ //get the acis body.
+ BODY* acis_BODY = NULL;
+ BODY **new_BODY_list;
+ int n_body;
- BODY *old_BODY = AcisQueryEngine::get_BODY(body_ptr );
- acis_BODY = this->copy_BODY(old_BODY, delete_attribs);
+ BODY *old_BODY = AcisQueryEngine::get_BODY(body_ptr );
+ acis_BODY = this->copy_BODY(old_BODY, delete_attribs);
- outcome result = api_separate_body( acis_BODY, n_body, new_BODY_list );
+ outcome result = api_separate_body( acis_BODY, n_body, new_BODY_list );
- if (!result.ok())
- {
- PRINT_ERROR("Error in seperating volumes.\n");
- AcisQueryEngine::instance()->delete_ACIS_BODY(acis_BODY, CUBIT_TRUE);
- return CUBIT_FAILURE;
- }
+ if (!result.ok())
+ {
+ PRINT_ERROR("Error in seperating volumes.\n");
+ AcisQueryEngine::instance()->delete_ACIS_BODY(acis_BODY, CUBIT_TRUE);
+ return CUBIT_FAILURE;
+ }
- DLIList<BODY*> new_BODYs;
- for (int i = 0; i < n_body; i++)
- new_BODYs.append(new_BODY_list[i]);
+ DLIList<BODY*> new_BODYs;
+ for (int i = 0; i < n_body; i++)
+ new_BODYs.append(new_BODY_list[i]);
- CubitStatus status = get_new_Body(body_ptr, old_BODY,
- new_BODYs, new_bodies,
- CUBIT_FALSE);
- return status;
- }
+ CubitStatus status = get_new_Body(body_ptr, old_BODY,
+ new_BODYs, new_bodies,
+ CUBIT_FALSE);
+ return status;
+}
- CubitStatus AcisModifyEngine::split_periodic( BodySM *body_ptr,
- BodySM *&new_body)
- {
+CubitStatus AcisModifyEngine::split_periodic( BodySM *body_ptr,
+ BodySM *&new_body)
+{
- BODY* acis_BODY = NULL;
+ BODY* acis_BODY = NULL;
- //get the ACIS BODY of tool_body
- BODY *old_BODY = AcisQueryEngine::get_BODY( body_ptr );
- acis_BODY = this->copy_BODY(old_BODY,
- GeometryModifyTool::instance()->get_new_ids());
+ //get the ACIS BODY of tool_body
+ BODY *old_BODY = AcisQueryEngine::get_BODY( body_ptr );
+ acis_BODY = this->copy_BODY(old_BODY,
+ GeometryModifyTool::instance()->get_new_ids());
- outcome some_result = api_split_periodic_faces( acis_BODY );
+ outcome some_result = api_split_periodic_faces( acis_BODY );
- if ( acis_BODY == NULL || !some_result.ok() )
- {
- if (acis_BODY != NULL )
- AcisQueryEngine::instance()->delete_ACIS_BODY( acis_BODY );
+ if ( acis_BODY == NULL || !some_result.ok() )
+ {
+ if (acis_BODY != NULL )
+ AcisQueryEngine::instance()->delete_ACIS_BODY( acis_BODY );
- PRINT_ERROR("Unable to split periodic surface.\n");
- return CUBIT_FAILURE;
- }
+ PRINT_ERROR("Unable to split periodic surface.\n");
+ return CUBIT_FAILURE;
+ }
- new_body = get_new_Body(body_ptr, old_BODY, acis_BODY, false);
+ new_body = get_new_Body(body_ptr, old_BODY, acis_BODY, false);
- if ( new_body == NULL )
- {
- PRINT_ERROR("Can not make a volume out of the split volumes.\n");
- return CUBIT_FAILURE;
- }
+ if ( new_body == NULL )
+ {
+ PRINT_ERROR("Can not make a volume out of the split volumes.\n");
+ return CUBIT_FAILURE;
+ }
- else return CUBIT_SUCCESS;
- }
+ else return CUBIT_SUCCESS;
+}
- EDGE *
- AcisModifyEngine::make_spline_EDGE( DLIList<CubitVector*> &vec_list )
- {
- int i;
- EDGE *new_EDGE_ptr = NULL;
+EDGE *
+AcisModifyEngine::make_spline_EDGE( DLIList<CubitVector*> &vec_list )
+{
+ int i;
+ EDGE *new_EDGE_ptr = NULL;
- // Create a spline
- int num_pnts = vec_list.size();
- SPAposition* pos_array = new SPAposition[num_pnts];
+ // Create a spline
+ int num_pnts = vec_list.size();
+ SPAposition* pos_array = new SPAposition[num_pnts];
- // Fill the vector_list of points
- vec_list.reset();
- for( i=0; i<num_pnts; i++)
- {
- // Set the coordinates of the SPAposition object
- pos_array[i].set_x(vec_list.get()->x());
- pos_array[i].set_y(vec_list.get()->y());
- pos_array[i].set_z(vec_list.get()->z());
- vec_list.step();
- }
+ // Fill the vector_list of points
+ vec_list.reset();
+ for( i=0; i<num_pnts; i++)
+ {
+ // Set the coordinates of the SPAposition object
+ pos_array[i].set_x(vec_list.get()->x());
+ pos_array[i].set_y(vec_list.get()->y());
+ pos_array[i].set_z(vec_list.get()->z());
+ vec_list.step();
+ }
- outcome result = api_curve_spline(num_pnts, pos_array, NULL, NULL, new_EDGE_ptr);
- delete [] pos_array;
- if( !result.ok() || new_EDGE_ptr == NULL )
- {
- get_acis_query_engine()->ACIS_API_error(result);
- PRINT_ERROR( "unable to make spline from list of positions\n" );
- return NULL;
- }
+ outcome result = api_curve_spline(num_pnts, pos_array, NULL, NULL, new_EDGE_ptr);
+ delete [] pos_array;
+ if( !result.ok() || new_EDGE_ptr == NULL )
+ {
+ get_acis_query_engine()->ACIS_API_error(result);
+ PRINT_ERROR( "unable to make spline from list of positions\n" );
+ return NULL;
+ }
- return new_EDGE_ptr;
- }
+ return new_EDGE_ptr;
+}
- //-------------------------------------------------------------------------
- // Purpose : Reverse the ACIS BODY
- //
- // Special Notes : Moved from BodyACIS - j.k, 2004-5-25
- //
- // Creator : Tim Tautges
- //
- // Creation Date : 3/18/97
- //-------------------------------------------------------------------------
- CubitStatus AcisModifyEngine::reverse_body( BodySM* body_to_reverse )
- {
- BODY* body_ptr = AcisQueryEngine::get_BODY( body_to_reverse );
- if (!body_ptr)
- return CUBIT_FAILURE;
+//-------------------------------------------------------------------------
+// Purpose : Reverse the ACIS BODY
+//
+// Special Notes : Moved from BodyACIS - j.k, 2004-5-25
+//
+// Creator : Tim Tautges
+//
+// Creation Date : 3/18/97
+//-------------------------------------------------------------------------
+CubitStatus AcisModifyEngine::reverse_body( BodySM* body_to_reverse )
+{
+ BODY* body_ptr = AcisQueryEngine::get_BODY( body_to_reverse );
+ if (!body_ptr)
+ return CUBIT_FAILURE;
- outcome result = api_reverse_body( body_ptr );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error( result, "reversing BODY." );
- return CUBIT_FAILURE;
- }
+ outcome result = api_reverse_body( body_ptr );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error( result, "reversing BODY." );
+ return CUBIT_FAILURE;
+ }
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
- void AcisModifyEngine::webcut_cleanup( DLIList<BodySM*>& body_list,
+void AcisModifyEngine::webcut_cleanup( DLIList<BodySM*>& body_list,
ENTITY_LIST& BODY_list) const
- {
- // This procedure is called by webcut_handler and gets rid of
- // all the Body's and Acis BODY's created during the execution
- // of the webcut command. The command was unsuccessful and hence,
- // these entities need to be removed so the system can be returned
- // to its state before the command was invoked.
+{
+ // This procedure is called by webcut_handler and gets rid of
+ // all the Body's and Acis BODY's created during the execution
+ // of the webcut command. The command was unsuccessful and hence,
+ // these entities need to be removed so the system can be returned
+ // to its state before the command was invoked.
- // Delete the Bodies
- AcisQueryEngine::instance()->delete_solid_model_entities(body_list);
- //GeometryQueryTool::instance()->delete_Body(body_list, CUBIT_TRUE);
+ // Delete the Bodies
+ AcisQueryEngine::instance()->delete_solid_model_entities(body_list);
+ //GeometryQueryTool::instance()->delete_Body(body_list, CUBIT_TRUE);
- // Delete the Acis BODYs
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list);
+ // Delete the Acis BODYs
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list);
- return;
+ return;
- }
+}
- void AcisModifyEngine::webcut_imprint(
- BODY* cutting_tool_BODY_ptr,
- DLIList<BodySM*> &old_body_list,
- DLIList<BODY*>& new_webcut_BODY_list,
- DLIList<BODY*>& just_webcut_BODY_list,
- DLIList<BodySM*>& results_list,
- DLIList<BodySM*> &imprinted_Body_from_Model_list,
- DLIList<BODY*> &imprinted_BODY_from_Model_list) const
- {
- // This procedure takes care of the imprint operations that are required
- // by the webcut operation. Each of the BODYs in the new_webcut_BODY_list
- // is tested against every other BODY in the model as well as every other
- // BODY in the same list for interference. If interference exists, then
- // the BODYs are imprinted with each other and new (corresponding) Bodies
- // are created. Pointers to these new Bodies are inserted into the list,
- // new_webcut_body_list.
+void AcisModifyEngine::webcut_imprint(
+ BODY* cutting_tool_BODY_ptr,
+ DLIList<BodySM*> &old_body_list,
+ DLIList<BODY*>& new_webcut_BODY_list,
+ DLIList<BODY*>& just_webcut_BODY_list,
+ DLIList<BodySM*>& results_list,
+ DLIList<BodySM*> &imprinted_Body_from_Model_list,
+ DLIList<BODY*> &imprinted_BODY_from_Model_list) const
+{
+ // This procedure takes care of the imprint operations that are required
+ // by the webcut operation. Each of the BODYs in the new_webcut_BODY_list
+ // is tested against every other BODY in the model as well as every other
+ // BODY in the same list for interference. If interference exists, then
+ // the BODYs are imprinted with each other and new (corresponding) Bodies
+ // are created. Pointers to these new Bodies are inserted into the list,
+ // new_webcut_body_list.
- // MJP Note:
- // Note that this procedure takes care of imprinting the existing Bodies
- // (i.e., the ones in the model) and creating new Bodies when necessary
- // to replace these. However, new Body's are *not* created from the list
- // of ACIS BODYs in the input list, new_webcut_BODY_list. These are simply
- // returned to the calling routine, where it is expected that new Bodies
- // will be created, as required.
+ // MJP Note:
+ // Note that this procedure takes care of imprinting the existing Bodies
+ // (i.e., the ones in the model) and creating new Bodies when necessary
+ // to replace these. However, new Body's are *not* created from the list
+ // of ACIS BODYs in the input list, new_webcut_BODY_list. These are simply
+ // returned to the calling routine, where it is expected that new Bodies
+ // will be created, as required.
- int webcut_debug_flag = 18;
- int webcut_debug_flag_on = DEBUG_FLAG(webcut_debug_flag);
+ int webcut_debug_flag = 18;
+ int webcut_debug_flag_on = DEBUG_FLAG(webcut_debug_flag);
- int i = 0;
- int j = 0;
+ int i = 0;
+ int j = 0;
- // Make copies of the input BODYs
- DLIList<BODY*> copy_new_webcut_BODY_list ;
- DLIList<BODY*> new_results_BODYS;
- new_webcut_BODY_list.reset() ;
- for (i = 0; i < new_webcut_BODY_list.size() ; i++)
- {
- BODY* old_BODY = new_webcut_BODY_list.get_and_step() ;
- BODY* new_BODY = this->copy_BODY(old_BODY,
- GeometryModifyTool::instance()->get_new_ids()) ;
+ // Make copies of the input BODYs
+ DLIList<BODY*> copy_new_webcut_BODY_list ;
+ DLIList<BODY*> new_results_BODYS;
+ new_webcut_BODY_list.reset() ;
+ for (i = 0; i < new_webcut_BODY_list.size() ; i++)
+ {
+ BODY* old_BODY = new_webcut_BODY_list.get_and_step() ;
+ BODY* new_BODY = this->copy_BODY(old_BODY,
+ GeometryModifyTool::instance()->get_new_ids()) ;
- // Make sure the the new BODY is a valid BODY
- assert( new_BODY != NULL) ;
+ // Make sure the the new BODY is a valid BODY
+ assert( new_BODY != NULL) ;
- // Add the new BODY to the backup list
- copy_new_webcut_BODY_list.append(new_BODY) ;
- }
+ // Add the new BODY to the backup list
+ copy_new_webcut_BODY_list.append(new_BODY) ;
+ }
- // Loop over each of the new BODYs and imprint it with any other new BODY
- // that touches it.
- BODY* first_BODY_ptr = NULL;
- BODY* second_BODY_ptr = NULL;
- copy_new_webcut_BODY_list.reset() ;
- for (i = 0; i < (copy_new_webcut_BODY_list.size() - 1); i++)
- {
- // Get the first BODY
- first_BODY_ptr = copy_new_webcut_BODY_list.get_and_step();
+ // Loop over each of the new BODYs and imprint it with any other new BODY
+ // that touches it.
+ BODY* first_BODY_ptr = NULL;
+ BODY* second_BODY_ptr = NULL;
+ copy_new_webcut_BODY_list.reset() ;
+ for (i = 0; i < (copy_new_webcut_BODY_list.size() - 1); i++)
+ {
+ // Get the first BODY
+ first_BODY_ptr = copy_new_webcut_BODY_list.get_and_step();
- for (j = (i + 1); j < copy_new_webcut_BODY_list.size(); j++)
- {
- // Get the second BODY
- second_BODY_ptr = copy_new_webcut_BODY_list.get_and_step();
+ for (j = (i + 1); j < copy_new_webcut_BODY_list.size(); j++)
+ {
+ // Get the second BODY
+ second_BODY_ptr = copy_new_webcut_BODY_list.get_and_step();
- // If these BODYs touch, then imprint them
- CubitBoolean result_interfer =
- BODYs_interfering( first_BODY_ptr,second_BODY_ptr );
+ // If these BODYs touch, then imprint them
+ CubitBoolean result_interfer =
+ BODYs_interfering( first_BODY_ptr,second_BODY_ptr );
- if ( result_interfer == CUBIT_TRUE )
- {
- CubitStatus resultImprint =
- imprint_BODYs( first_BODY_ptr, second_BODY_ptr );
+ if ( result_interfer == CUBIT_TRUE )
+ {
+ CubitStatus resultImprint =
+ imprint_BODYs( first_BODY_ptr, second_BODY_ptr );
- if( resultImprint == CUBIT_FAILURE )
- {
- PRINT_WARNING ("Imprint operation failed.\n"
- " Going back to the previous state");
+ if( resultImprint == CUBIT_FAILURE )
+ {
+ PRINT_WARNING ("Imprint operation failed.\n"
+ " Going back to the previous state");
- // Delete the new BODYs and return.
- copy_new_webcut_BODY_list.reset() ;
- for (int k = 0 ; k < copy_new_webcut_BODY_list.size() ; k++)
- {
- first_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
- AcisQueryEngine::instance()->delete_ACIS_BODY(first_BODY_ptr) ;
- }
- return ;
- }
- }
- }
+ // Delete the new BODYs and return.
+ copy_new_webcut_BODY_list.reset() ;
+ for (int k = 0 ; k < copy_new_webcut_BODY_list.size() ; k++)
+ {
+ first_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
+ AcisQueryEngine::instance()->delete_ACIS_BODY(first_BODY_ptr) ;
+ }
+ return ;
+ }
+ }
+ }
- // Go to the (i+1)th element of the list
- copy_new_webcut_BODY_list.reset() ;
- copy_new_webcut_BODY_list.step(i+1) ;
+ // Go to the (i+1)th element of the list
+ copy_new_webcut_BODY_list.reset() ;
+ copy_new_webcut_BODY_list.step(i+1) ;
- }
+ }
- /*
- CDE-- commented out this code. For now, we've decided that when webcutting
- with the 'imprint' option, the imprint should occur between bodies involved
- in the webcut. This code was imprinting all resulting pieces of the webcut
- with all the other Bodies in the model.
+/*
+ CDE-- commented out this code. For now, we've decided that when webcutting
+ with the 'imprint' option, the imprint should occur between bodies involved
+ in the webcut. This code was imprinting all resulting pieces of the webcut
+ with all the other Bodies in the model.
- // Get the Bodys in the Model
- DLIList<Body*> Body_in_Model_list_tmp;
- GeometryQueryTool::instance()->bodies(Body_in_Model_list_tmp);
- DLIList<BodySM*> Body_in_Model_list;
- Body_in_Model_list_tmp.reset();
- for (i = Body_in_Model_list_tmp.size(); i--; )
- Body_in_Model_list.append( Body_in_Model_list_tmp.get_and_step()->get_body_sm_ptr());
+ // Get the Bodys in the Model
+ DLIList<Body*> Body_in_Model_list_tmp;
+ GeometryQueryTool::instance()->bodies(Body_in_Model_list_tmp);
+ DLIList<BodySM*> Body_in_Model_list;
+ Body_in_Model_list_tmp.reset();
+ for (i = Body_in_Model_list_tmp.size(); i--; )
+ Body_in_Model_list.append( Body_in_Model_list_tmp.get_and_step()->get_body_sm_ptr());
- // Loop over each of the new BODYs and imprint it with any of the
- // BODYs already existing in the model, if they touch.
+ // Loop over each of the new BODYs and imprint it with any of the
+ // BODYs already existing in the model, if they touch.
- // List of new imprinted BODYs -- Bodies need to be created from these
- DLIList<BODY*> copy_imprinted_BODY_from_Model_list;
+ // List of new imprinted BODYs -- Bodies need to be created from these
+ DLIList<BODY*> copy_imprinted_BODY_from_Model_list;
- BodySM* model_Body_ptr = NULL;
- BODY* model_BODY_ptr = NULL;
- BODY* new_model_BODY_ptr = NULL;
- BODY* new_BODY_ptr = NULL ;
- int copy_made = CUBIT_FALSE;
+ BodySM* model_Body_ptr = NULL;
+ BODY* model_BODY_ptr = NULL;
+ BODY* new_model_BODY_ptr = NULL;
+ BODY* new_BODY_ptr = NULL ;
+ int copy_made = CUBIT_FALSE;
- Body_in_Model_list.reset();
- // Loop over all the existing Bodies
- for (i = 0; i < Body_in_Model_list.size(); i++)
- {
+ Body_in_Model_list.reset();
+ // Loop over all the existing Bodies
+ for (i = 0; i < Body_in_Model_list.size(); i++)
+ {
// Get this existing Body's parent ACIS BODY
- model_Body_ptr = Body_in_Model_list.get_and_step() ;
- model_BODY_ptr = AcisQueryEngine::get_BODY(model_Body_ptr) ;
+ model_Body_ptr = Body_in_Model_list.get_and_step() ;
+ model_BODY_ptr = AcisQueryEngine::get_BODY(model_Body_ptr) ;
// Make sure that model_BODY_ptr is not the Cutting Tool as the
// user is allowed to use an existing Body as a Cutting Tool.
// If this is the case, then don't involve it in the imprint
// operations.
- if (model_BODY_ptr == cutting_tool_BODY_ptr || old_body_list.move_to(model_Body_ptr))
- {
- // Don't do anything
- continue;
- }
+ if (model_BODY_ptr == cutting_tool_BODY_ptr || old_body_list.move_to(model_Body_ptr))
+ {
+ // Don't do anything
+ continue;
+ }
// Loop over all the newly created (by webcutting) ACIS BODYs and test
// the existing Body against them (for imprinting purposes, if there
// is interference)
- copy_made = CUBIT_FALSE;
- new_model_BODY_ptr = NULL;
- copy_new_webcut_BODY_list.reset();
+ copy_made = CUBIT_FALSE;
+ new_model_BODY_ptr = NULL;
+ copy_new_webcut_BODY_list.reset();
- for (j = 0; j < copy_new_webcut_BODY_list.size(); j++)
- {
- // Get the BODY that we're going to test the existing Body against
- new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
+ for (j = 0; j < copy_new_webcut_BODY_list.size(); j++)
+ {
+ // Get the BODY that we're going to test the existing Body against
+ new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
- // DEBUG stuff
- if (webcut_debug_flag_on)
- {
- //Save the two BODYs
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr, "BODY1.sat", "w");
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(model_BODY_ptr, "BODY2.sat", "w");
- }
+ // DEBUG stuff
+ if (webcut_debug_flag_on)
+ {
+ //Save the two BODYs
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr, "BODY1.sat", "w");
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(model_BODY_ptr, "BODY2.sat", "w");
+ }
- // If these BODYs touch, then ...
- if ( BODYs_interfering(new_BODY_ptr, model_BODY_ptr) == CUBIT_TRUE )
- {
- // DEBUG stuff
- if (webcut_debug_flag_on)
- {
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr,
- "BODY1_after_test.sat",
- "w");
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_model_BODY_ptr,
- "BODY2_after_test.sat",
- "w");
- }
+ // If these BODYs touch, then ...
+ if ( BODYs_interfering(new_BODY_ptr, model_BODY_ptr) == CUBIT_TRUE )
+ {
+ // DEBUG stuff
+ if (webcut_debug_flag_on)
+ {
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr,
+ "BODY1_after_test.sat",
+ "w");
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_model_BODY_ptr,
+ "BODY2_after_test.sat",
+ "w");
+ }
- // Because of the fact that the RefEntity datastructure is
- // nonmanifold and hence shares underlying ACIS ENTITYs, I have to:
- // a) make a copy of the parent ACIS BODY of the Body being
- // deactivated (this is done only once for the inner loop)
- // b) then all imprinting is done with this copy instead of
- // with the original parent ACIS BODY.
- // deactivateRefStructure takes care of detaching the RefEntities
- // and their associated ACIS ENTITYs (removing the double links
- // between them).
- if (!copy_made) // Make this copy at most once per outer loop iteration
- {
- // Make a copy of the parent ACIS BODY.
- new_model_BODY_ptr = this->copy_BODY(model_BODY_ptr,
- GeometryModifyTool::instance()->get_new_ids());
+ // Because of the fact that the RefEntity datastructure is
+ // nonmanifold and hence shares underlying ACIS ENTITYs, I have to:
+ // a) make a copy of the parent ACIS BODY of the Body being
+ // deactivated (this is done only once for the inner loop)
+ // b) then all imprinting is done with this copy instead of
+ // with the original parent ACIS BODY.
+ // deactivateRefStructure takes care of detaching the RefEntities
+ // and their associated ACIS ENTITYs (removing the double links
+ // between them).
+ if (!copy_made) // Make this copy at most once per outer loop iteration
+ {
+ // Make a copy of the parent ACIS BODY.
+ new_model_BODY_ptr = this->copy_BODY(model_BODY_ptr,
+ GeometryModifyTool::instance()->get_new_ids());
- // Make sure a valid copy was made. If not, then we need to exit
- // this loop (i.e., stop testing this Body for imprinting
- // and go on to the next one).
- if (new_model_BODY_ptr == NULL)
- {
- PRINT_ERROR("Cannot test imprinting for volume.\n" );
- break;
- }
- else
- {
- copy_made = CUBIT_TRUE;
- if ( results_list.move_to(model_Body_ptr) )
- new_results_BODYS.append( new_model_BODY_ptr );
- imprinted_Body_from_Model_list.append(model_Body_ptr) ;
- imprinted_BODY_from_Model_list.append(model_BODY_ptr) ;
- copy_imprinted_BODY_from_Model_list.append(new_model_BODY_ptr) ;
- }
- }
+ // Make sure a valid copy was made. If not, then we need to exit
+ // this loop (i.e., stop testing this Body for imprinting
+ // and go on to the next one).
+ if (new_model_BODY_ptr == NULL)
+ {
+ PRINT_ERROR("Cannot test imprinting for volume.\n" );
+ break;
+ }
+ else
+ {
+ copy_made = CUBIT_TRUE;
+ if ( results_list.move_to(model_Body_ptr) )
+ new_results_BODYS.append( new_model_BODY_ptr );
+ imprinted_Body_from_Model_list.append(model_Body_ptr) ;
+ imprinted_BODY_from_Model_list.append(model_BODY_ptr) ;
+ copy_imprinted_BODY_from_Model_list.append(new_model_BODY_ptr) ;
+ }
+ }
- // Imprint the BODYs (use the new copied BODY). If the imprint
- // operation fails, the state of these BODYs is left unchanged.
- if (imprint_BODYs(new_BODY_ptr, new_model_BODY_ptr) == CUBIT_SUCCESS )
- {
- // DEBUG stuff, if the imprint operation succeeded.
- if (webcut_debug_flag_on)
- {
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr,
- "BODY1_after_imprint.sat",
- "w");
- AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_model_BODY_ptr,
- "BODY2_after_imprint.sat",
- "w");
- }
- }
+ // Imprint the BODYs (use the new copied BODY). If the imprint
+ // operation fails, the state of these BODYs is left unchanged.
+ if (imprint_BODYs(new_BODY_ptr, new_model_BODY_ptr) == CUBIT_SUCCESS )
+ {
+ // DEBUG stuff, if the imprint operation succeeded.
+ if (webcut_debug_flag_on)
+ {
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_BODY_ptr,
+ "BODY1_after_imprint.sat",
+ "w");
+ AcisQueryEngine::instance()->save_ENTITY_as_sat_file(new_model_BODY_ptr,
+ "BODY2_after_imprint.sat",
+ "w");
+ }
+ }
- else
- {
- PRINT_WARNING ("Imprint operation failed.\n"
- " Going back to the previous state");
+ else
+ {
+ PRINT_WARNING ("Imprint operation failed.\n"
+ " Going back to the previous state");
- // Delete the new BODYs and return.
- copy_new_webcut_BODY_list.reset() ;
- int k;
- for (k = 0 ; k < copy_new_webcut_BODY_list.size() ; k++)
- {
- new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
- AcisQueryEngine::instance()->delete_ACIS_BODY(first_BODY_ptr) ;
- }
+ // Delete the new BODYs and return.
+ copy_new_webcut_BODY_list.reset() ;
+ int k;
+ for (k = 0 ; k < copy_new_webcut_BODY_list.size() ; k++)
+ {
+ new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
+ AcisQueryEngine::instance()->delete_ACIS_BODY(first_BODY_ptr) ;
+ }
- copy_imprinted_BODY_from_Model_list.reset() ;
- for (k = 0 ; k < copy_imprinted_BODY_from_Model_list.size() ; k++)
- {
- new_model_BODY_ptr = copy_imprinted_BODY_from_Model_list.get_and_step() ;
- AcisQueryEngine::instance()->delete_ACIS_BODY(new_model_BODY_ptr) ;
- }
+ copy_imprinted_BODY_from_Model_list.reset() ;
+ for (k = 0 ; k < copy_imprinted_BODY_from_Model_list.size() ; k++)
+ {
+ new_model_BODY_ptr = copy_imprinted_BODY_from_Model_list.get_and_step() ;
+ AcisQueryEngine::instance()->delete_ACIS_BODY(new_model_BODY_ptr) ;
+ }
- return ;
- }
- }
- } // Loop over the new (webcut) BODYs
+ return ;
+ }
+ }
+ } // Loop over the new (webcut) BODYs
- } // Loop over the existing Bodies in Model
- */
- // Now that we have come so far successfully, create the final list
- // of new BODYs that will be used to create VGI Bodys.
- new_webcut_BODY_list.clean_out() ;
+ } // Loop over the existing Bodies in Model
+*/
+ // Now that we have come so far successfully, create the final list
+ // of new BODYs that will be used to create VGI Bodys.
+ new_webcut_BODY_list.clean_out() ;
- // First the BODYs that were copies of the webcut BODYs
- BODY* new_BODY_ptr = NULL ;
- copy_new_webcut_BODY_list.reset() ;
- for (i = 0 ; i < copy_new_webcut_BODY_list.size() ; i++)
- {
- new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
- new_webcut_BODY_list.append(new_BODY_ptr) ;
- }
- just_webcut_BODY_list = new_webcut_BODY_list;
+ // First the BODYs that were copies of the webcut BODYs
+ BODY* new_BODY_ptr = NULL ;
+ copy_new_webcut_BODY_list.reset() ;
+ for (i = 0 ; i < copy_new_webcut_BODY_list.size() ; i++)
+ {
+ new_BODY_ptr = copy_new_webcut_BODY_list.get_and_step() ;
+ new_webcut_BODY_list.append(new_BODY_ptr) ;
+ }
+ just_webcut_BODY_list = new_webcut_BODY_list;
- /*
- // Then the BODYs that were copies of Model BODYs
- copy_imprinted_BODY_from_Model_list.reset() ;
- for (i = 0 ; i < copy_imprinted_BODY_from_Model_list.size() ; i++)
- {
+/*
+ // Then the BODYs that were copies of Model BODYs
+ copy_imprinted_BODY_from_Model_list.reset() ;
+ for (i = 0 ; i < copy_imprinted_BODY_from_Model_list.size() ; i++)
+ {
new_BODY_ptr = copy_imprinted_BODY_from_Model_list.get_and_step() ;
new_webcut_BODY_list.append(new_BODY_ptr) ;
- }
- */
- // now, two important lists:
- // a) just_webcut_BODY_list: bodies in original bodies-to-be-webcut list
- // that were modified, either by webcut or by imprint
- // b) new_webcut_BODY_list: all bodies modified by webcut or imprint,
- // including model bodies affected by imprint
+ }
+*/
+ // now, two important lists:
+ // a) just_webcut_BODY_list: bodies in original bodies-to-be-webcut list
+ // that were modified, either by webcut or by imprint
+ // b) new_webcut_BODY_list: all bodies modified by webcut or imprint,
+ // including model bodies affected by imprint
- return;
- }
+ return;
+}
- BODY* AcisModifyEngine::create_infinite_plane_cutting_tool(
- const CubitVector &input_p1,
- const CubitVector &input_p2,
- const CubitVector &input_p3,
- const SPAbox& box_to_cut,
- bool just_face ) const
- {
- // Create a plane from the vertices
- // Note: The old infinite plane code always swept in the opposite direction
- // from the normal of the passed in points, so we create the plane with
- // the points in opposite order.
- CubitPlane p;
- p.mk_plane_with_points(input_p3, input_p2, input_p1);
+BODY* AcisModifyEngine::create_infinite_plane_cutting_tool(
+ const CubitVector &input_p1,
+ const CubitVector &input_p2,
+ const CubitVector &input_p3,
+ const SPAbox& box_to_cut,
+ bool just_face ) const
+{
+ // Create a plane from the vertices
+ // Note: The old infinite plane code always swept in the opposite direction
+ // from the normal of the passed in points, so we create the plane with
+ // the points in opposite order.
+ CubitPlane p;
+ p.mk_plane_with_points(input_p3, input_p2, input_p1);
- // Convert it to an ACIS plane
- SPAunit_vector plane_normal(p.normal().x(),
- p.normal().y(),
- p.normal().z());
+ // Convert it to an ACIS plane
+ SPAunit_vector plane_normal(p.normal().x(),
+ p.normal().y(),
+ p.normal().z());
- plane the_plane(SPAposition(input_p1.x(),
- input_p1.y(),
- input_p1.z()),
- plane_normal);
+ plane the_plane(SPAposition(input_p1.x(),
+ input_p1.y(),
+ input_p1.z()),
+ plane_normal);
- if (DEBUG_FLAG(18))
- PRINT_DEBUG_18(
- "plane created with root point (%g %g %g) and\n"
- " normal (%g %g %g).\n",
- input_p1.x(),
- input_p1.y(),
- input_p1.z(),
- plane_normal.x(),
- plane_normal.y(),
- plane_normal.z());
+ if (DEBUG_FLAG(18))
+ PRINT_DEBUG_18(
+ "plane created with root point (%g %g %g) and\n"
+ " normal (%g %g %g).\n",
+ input_p1.x(),
+ input_p1.y(),
+ input_p1.z(),
+ plane_normal.x(),
+ plane_normal.y(),
+ plane_normal.z());
- // Need to declare this up here so that it is outside of the API block
- BODY* infinite_plane_BODY = NULL;
- API_BEGIN;
+ // Need to declare this up here so that it is outside of the API block
+ BODY* infinite_plane_BODY = NULL;
+ API_BEGIN;
- // Make a PLANE from it
- PLANE* the_PLANE = new PLANE(the_plane);
+ // Make a PLANE from it
+ PLANE* the_PLANE = new PLANE(the_plane);
- // Make a FACE out of it
- FACE* planar_FACE = new FACE(NULL, NULL, the_PLANE, FORWARD);
+ // Make a FACE out of it
+ FACE* planar_FACE = new FACE(NULL, NULL, the_PLANE, FORWARD);
- // Get the midpoint and diagonal length of the
- // SPAbox this needs to fit around. Make diag length a little
- // bigger than necessary as a buffer.
- SPAposition midpoint = box_to_cut.mid();
- double diag_length = 1.01 * (box_to_cut.high() - midpoint).len();
+ // Get the midpoint and diagonal length of the
+ // SPAbox this needs to fit around. Make diag length a little
+ // bigger than necessary as a buffer.
+ SPAposition midpoint = box_to_cut.mid();
+ double diag_length = 1.01 * (box_to_cut.high() - midpoint).len();
- // Get the point on the plane that the SPAbox midpoint projects to.
- ENTITY_LIST temp_list;
- double distance;
- double *dist_ptr = &distance;
- ENTITY* entity_ptr = planar_FACE;
- // Test points behind plane
- result = api_ray_test_ents(midpoint, plane_normal, 1, 1, 1, &entity_ptr,
- temp_list, dist_ptr);
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- }
- if (temp_list.count() < 1)
- {
- // Test points in front of plane, if needed
- result = api_ray_test_ents(midpoint, -plane_normal, 1, 1, 1, &entity_ptr,
- temp_list, dist_ptr);
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- }
- // Indicate that the distance is in front of the plane
- distance = -distance;
- }
+ // Get the point on the plane that the SPAbox midpoint projects to.
+ ENTITY_LIST temp_list;
+ double distance;
+ double *dist_ptr = &distance;
+ ENTITY* entity_ptr = planar_FACE;
+ // Test points behind plane
+ result = api_ray_test_ents(midpoint, plane_normal, 1, 1, 1, &entity_ptr,
+ temp_list, dist_ptr);
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ }
+ if (temp_list.count() < 1)
+ {
+ // Test points in front of plane, if needed
+ result = api_ray_test_ents(midpoint, -plane_normal, 1, 1, 1, &entity_ptr,
+ temp_list, dist_ptr);
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ }
+ // Indicate that the distance is in front of the plane
+ distance = -distance;
+ }
- if (DEBUG_FLAG(18))
- {
- PRINT_DEBUG_18(
- "Midpoint before moving it: %g, %g, %g.\n",
- midpoint.x(), midpoint.y(), midpoint.z());
- }
+ if (DEBUG_FLAG(18))
+ {
+ PRINT_DEBUG_18(
+ "Midpoint before moving it: %g, %g, %g.\n",
+ midpoint.x(), midpoint.y(), midpoint.z());
+ }
- // Move midpoint from SPAbox to plane
- midpoint += distance * plane_normal;
+ // Move midpoint from SPAbox to plane
+ midpoint += distance * plane_normal;
- if (DEBUG_FLAG(18))
- {
- PRINT_DEBUG_18(
- "just_face = %d.\n"
- "The center of the box was %s the plane.\n",
- just_face,
- distance >= 0 ? "behind" : "in front of");
- PRINT_DEBUG_18(
- "Distance to center of box was determined to be %g.\n",
- distance);
- PRINT_DEBUG_18( "Mapped point is %g, %g, %g.\n",
- midpoint.x(), midpoint.y(), midpoint.z());
- }
+ if (DEBUG_FLAG(18))
+ {
+ PRINT_DEBUG_18(
+ "just_face = %d.\n"
+ "The center of the box was %s the plane.\n",
+ just_face,
+ distance >= 0 ? "behind" : "in front of");
+ PRINT_DEBUG_18(
+ "Distance to center of box was determined to be %g.\n",
+ distance);
+ PRINT_DEBUG_18( "Mapped point is %g, %g, %g.\n",
+ midpoint.x(), midpoint.y(), midpoint.z());
+ }
- // Get 4 points on the plane that form a square with sides of
- // length 2*diag_length.
- SPAvector in_plane_1 = diag_length * normalise(the_plane.u_deriv);
- SPAvector in_plane_2 = plane_normal * in_plane_1;
- SPAposition corners[4];
- corners[0] = midpoint - in_plane_1 - in_plane_2;
- corners[1] = midpoint + in_plane_1 - in_plane_2;
- corners[2] = midpoint + in_plane_1 + in_plane_2;
- corners[3] = midpoint - in_plane_1 + in_plane_2;
+ // Get 4 points on the plane that form a square with sides of
+ // length 2*diag_length.
+ SPAvector in_plane_1 = diag_length * normalise(the_plane.u_deriv);
+ SPAvector in_plane_2 = plane_normal * in_plane_1;
+ SPAposition corners[4];
+ corners[0] = midpoint - in_plane_1 - in_plane_2;
+ corners[1] = midpoint + in_plane_1 - in_plane_2;
+ corners[2] = midpoint + in_plane_1 + in_plane_2;
+ corners[3] = midpoint - in_plane_1 + in_plane_2;
+ if (DEBUG_FLAG(18))
+ {
+ // Uncomment this if you want to see the plane before it's swept
+// GfxDebug::draw_line(
+// corners[0].x(), corners[0].y(), corners[0].z(),
+// corners[1].x(), corners[1].y(), corners[1].z(), CUBIT_RED);
+// GfxDebug::draw_line(
+// corners[1].x(), corners[1].y(), corners[1].z(),
+// corners[2].x(), corners[2].y(), corners[2].z(), CUBIT_GREEN);
+// GfxDebug::draw_line(
+// corners[2].x(), corners[2].y(), corners[2].z(),
+// corners[3].x(), corners[3].y(), corners[3].z(), CUBIT_BLUE);
+// GfxDebug::draw_line(
+// corners[3].x(), corners[3].y(), corners[3].z(),
+// corners[0].x(), corners[0].y(), corners[0].z(), CUBIT_CYAN);
+// GfxDebug::draw_line(
+// midpoint.x(), midpoint.y(), midpoint.z(),
+// midpoint.x()+plane_normal.x(),
+// midpoint.y()+plane_normal.y(),
+// midpoint.z()+plane_normal.z(), CUBIT_BLUE);
+// GfxDebug::flush();
+
+ PRINT_DEBUG_18( "Diag length is %g.\n"
+ "Got four corners: (%g %g %g)\n"
+ " (%g %g %g).\n"
+ " (%g %g %g).\n"
+ " (%g %g %g).\n",
+ diag_length,
+ corners[0].x(), corners[0].y(), corners[0].z(),
+ corners[1].x(), corners[1].y(), corners[1].z(),
+ corners[2].x(), corners[2].y(), corners[2].z(),
+ corners[3].x(), corners[3].y(), corners[3].z());
+ }
+ // Make some geometry and topology from the corners
+ STRAIGHT* S[4];
+ S[0] = new STRAIGHT(corners[0], normalise(in_plane_1));
+ S[1] = new STRAIGHT(corners[1], normalise(in_plane_2));
+ S[2] = new STRAIGHT(corners[2], normalise(-in_plane_1));
+ S[3] = new STRAIGHT(corners[3], normalise(-in_plane_2));
+ APOINT* P[4];
+ VERTEX* V[4];
+ EDGE* E[4];
+ COEDGE* CE[4];
+ int i;
+ for ( i = 0; i < 4; i++)
+ {
+ P[i] = new APOINT (corners[i]);
+ V[i] = new VERTEX (P[i]);
+ }
+ CE[0] = NULL;
+ for (i = 0; i < 4; i++)
+ {
+ E[i] = new EDGE(V[i], V[(i+ 1)%4], S[i], FORWARD);
+ CE[i] = new COEDGE(E[i], FORWARD,
+ i == 0 ? NULL : CE[i-1],
+ i == 3 ? CE[0] : NULL);
+ }
+ LOOP* LOOP1 = new LOOP (CE[0], NULL);
+ FACE* FACE1 = new FACE (LOOP1, NULL, the_PLANE, FORWARD);
+ SHELL* SHELL1 = new SHELL(FACE1, NULL, NULL);
+ LUMP* LUMP1 = new LUMP(SHELL1, NULL);
+ infinite_plane_BODY = new BODY(LUMP1);
+ // At this point we are done with planar_FACE. It has been replaced by
+ // a FACE that is bounded by a LOOPm FACE1.
+ planar_FACE->lose();
+ // Let's make sure everything went as planned.
+ if (infinite_plane_BODY != NULL)
+ {
+ result = api_body_to_2d(infinite_plane_BODY);
+ if (!result.ok() || infinite_plane_BODY == NULL)
+ {
+ PRINT_ERROR("Unable to create infinite plane.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ infinite_plane_BODY = NULL;
+ }
+ // Just leave it as a 2D body if we are creating a sheet, or
+ // if the plane never intersects the input box_to_cut.
+ else if (!just_face && distance < diag_length && distance > -diag_length)
+ {
+ // Now sweep the FACE to make a 3D body
if (DEBUG_FLAG(18))
- {
- // Uncomment this if you want to see the plane before it's swept
- // GfxDebug::draw_line(
- // corners[0].x(), corners[0].y(), corners[0].z(),
- // corners[1].x(), corners[1].y(), corners[1].z(), CUBIT_RED);
- // GfxDebug::draw_line(
- // corners[1].x(), corners[1].y(), corners[1].z(),
- // corners[2].x(), corners[2].y(), corners[2].z(), CUBIT_GREEN);
- // GfxDebug::draw_line(
- // corners[2].x(), corners[2].y(), corners[2].z(),
- // corners[3].x(), corners[3].y(), corners[3].z(), CUBIT_BLUE);
- // GfxDebug::draw_line(
- // corners[3].x(), corners[3].y(), corners[3].z(),
- // corners[0].x(), corners[0].y(), corners[0].z(), CUBIT_CYAN);
- // GfxDebug::draw_line(
- // midpoint.x(), midpoint.y(), midpoint.z(),
- // midpoint.x()+plane_normal.x(),
- // midpoint.y()+plane_normal.y(),
- // midpoint.z()+plane_normal.z(), CUBIT_BLUE);
- // GfxDebug::flush();
+ PRINT_DEBUG_18(
+ "Sweeping (%g %g %g).\n",
+ ((diag_length-distance)*plane_normal).x(),
+ ((diag_length-distance)*plane_normal).y(),
+ ((diag_length-distance)*plane_normal).z());
- PRINT_DEBUG_18( "Diag length is %g.\n"
- "Got four corners: (%g %g %g)\n"
- " (%g %g %g).\n"
- " (%g %g %g).\n"
- " (%g %g %g).\n",
- diag_length,
- corners[0].x(), corners[0].y(), corners[0].z(),
- corners[1].x(), corners[1].y(), corners[1].z(),
- corners[2].x(), corners[2].y(), corners[2].z(),
- corners[3].x(), corners[3].y(), corners[3].z());
- }
- // Make some geometry and topology from the corners
- STRAIGHT* S[4];
- S[0] = new STRAIGHT(corners[0], normalise(in_plane_1));
- S[1] = new STRAIGHT(corners[1], normalise(in_plane_2));
- S[2] = new STRAIGHT(corners[2], normalise(-in_plane_1));
- S[3] = new STRAIGHT(corners[3], normalise(-in_plane_2));
- APOINT* P[4];
- VERTEX* V[4];
- EDGE* E[4];
- COEDGE* CE[4];
- int i;
- for ( i = 0; i < 4; i++)
- {
- P[i] = new APOINT (corners[i]);
- V[i] = new VERTEX (P[i]);
- }
- CE[0] = NULL;
- for (i = 0; i < 4; i++)
- {
- E[i] = new EDGE(V[i], V[(i+ 1)%4], S[i], FORWARD);
- CE[i] = new COEDGE(E[i], FORWARD,
- i == 0 ? NULL : CE[i-1],
- i == 3 ? CE[0] : NULL);
- }
- LOOP* LOOP1 = new LOOP (CE[0], NULL);
- FACE* FACE1 = new FACE (LOOP1, NULL, the_PLANE, FORWARD);
- SHELL* SHELL1 = new SHELL(FACE1, NULL, NULL);
- LUMP* LUMP1 = new LUMP(SHELL1, NULL);
- infinite_plane_BODY = new BODY(LUMP1);
- // At this point we are done with planar_FACE. It has been replaced by
- // a FACE that is bounded by a LOOPm FACE1.
- planar_FACE->lose();
- // Let's make sure everything went as planned.
- if (infinite_plane_BODY != NULL)
- {
- result = api_body_to_2d(infinite_plane_BODY);
- if (!result.ok() || infinite_plane_BODY == NULL)
- {
- PRINT_ERROR("Unable to create infinite plane.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- infinite_plane_BODY = NULL;
- }
- // Just leave it as a 2D body if we are creating a sheet, or
- // if the plane never intersects the input box_to_cut.
- else if (!just_face && distance < diag_length && distance > -diag_length)
- {
- // Now sweep the FACE to make a 3D body
- if (DEBUG_FLAG(18))
- PRINT_DEBUG_18(
- "Sweeping (%g %g %g).\n",
- ((diag_length-distance)*plane_normal).x(),
- ((diag_length-distance)*plane_normal).y(),
- ((diag_length-distance)*plane_normal).z());
+ // A negative distance means that it was in front of the plane, so
+ // we need to sweep extra distance. A positive distance means behind the
+ // plane, so we don't need to sweep as far.
+ sweep_options sweep_ops;
+ logical ACIS_primary_side = true;
+ sweep_ops.set_which_side(ACIS_primary_side);
+ result = api_sweep_with_options(FACE1,
+ (diag_length-distance)*plane_normal,
+ &sweep_ops,
+ infinite_plane_BODY);
+ if (!result.ok())
+ {
+ PRINT_ERROR("In GeometryModifyTool::create_infinite_plane_cutting_tool.\n"
+ " Problem sweeping the infinite plane.\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ infinite_plane_BODY = NULL;
+ }
+ }
+ else if (DEBUG_FLAG(18))
+ PRINT_DEBUG_18( "Not sweeping the infinite plane.\n");
+ }
- // A negative distance means that it was in front of the plane, so
- // we need to sweep extra distance. A positive distance means behind the
- // plane, so we don't need to sweep as far.
- sweep_options sweep_ops;
- logical ACIS_primary_side = true;
- sweep_ops.set_which_side(ACIS_primary_side);
- result = api_sweep_with_options(FACE1,
- (diag_length-distance)*plane_normal,
- &sweep_ops,
- infinite_plane_BODY);
- if (!result.ok())
- {
- PRINT_ERROR("In GeometryModifyTool::create_infinite_plane_cutting_tool.\n"
- " Problem sweeping the infinite plane.\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- infinite_plane_BODY = NULL;
- }
- }
- else if (DEBUG_FLAG(18))
- PRINT_DEBUG_18( "Not sweeping the infinite plane.\n");
- }
+ API_END;
- API_END;
+ return infinite_plane_BODY;
+}
- return infinite_plane_BODY;
- }
+//***********************************************************
+// Function: create_solid_bodies_from_surfs
+// Description: This function assumes that the reffaces sent into
+// this function are either sheet bodies, or free surfaces. This
+// Will have been taken care of in the calling function. GT?
+// All the surfaces, in ACIS, will be turned into sheet bodies. They
+// will be united, then the void enclosed. The result will be healed
+// if the option is specified (default is to heal, from experience).
+// This function will not create new reffaces.
+//***********************************************************
+CubitStatus AcisModifyEngine::create_solid_bodies_from_surfs( DLIList<Surface*> &ref_face_list,
+ DLIList<BodySM*> &new_bodies,
+ bool keep_old,
+ bool heal ) const
+{
+ int ii;
+ Surface* ref_face;
+ outcome rc;
+ //First sort the ref_face_list to sheet_bodies and free faces.
+ DLIList<BodySM*> body_list;
+ DLIList<Surface*> free_faces;
- //***********************************************************
- // Function: create_solid_bodies_from_surfs
- // Description: This function assumes that the reffaces sent into
- // this function are either sheet bodies, or free surfaces. This
- // Will have been taken care of in the calling function. GT?
- // All the surfaces, in ACIS, will be turned into sheet bodies. They
- // will be united, then the void enclosed. The result will be healed
- // if the option is specified (default is to heal, from experience).
- // This function will not create new reffaces.
- //***********************************************************
- CubitStatus AcisModifyEngine::create_solid_bodies_from_surfs( DLIList<Surface*> &ref_face_list,
- DLIList<BodySM*> &new_bodies,
- bool keep_old,
- bool heal ) const
- {
- int ii;
- Surface* ref_face;
- outcome rc;
- //First sort the ref_face_list to sheet_bodies and free faces.
- DLIList<BodySM*> body_list;
- DLIList<Surface*> free_faces;
+ AcisQueryEngine* aqe = AcisQueryEngine::instance();
- AcisQueryEngine* aqe = AcisQueryEngine::instance();
+ ref_face_list.reset();
+ for( ii = ref_face_list.size(); ii > 0; ii-- )
+ {
+ ref_face = ref_face_list.get_and_step();
+ FACE* FACE_ptr = aqe->get_FACE(ref_face);
+ BodySM* body_ptr = aqe->get_body_sm_of_ENTITY(FACE_ptr);
- ref_face_list.reset();
- for( ii = ref_face_list.size(); ii > 0; ii-- )
- {
- ref_face = ref_face_list.get_and_step();
- FACE* FACE_ptr = aqe->get_FACE(ref_face);
- BodySM* body_ptr = aqe->get_body_sm_of_ENTITY(FACE_ptr);
+ if (body_ptr)
+ body_list.append_unique(body_ptr);
+ else
+ free_faces.append_unique(ref_face);
+ }
- if (body_ptr)
- body_list.append_unique(body_ptr);
- else
- free_faces.append_unique(ref_face);
- }
+ //Now for all of the free_faces, create BODYS for them.
+ DLIList<BODY*> BODY_list, old_BODY_list;
+ for ( ii = free_faces.size(); ii > 0; ii-- )
+ {
+ ref_face = free_faces.get_and_step();
+ FACE *acis_FACE = AcisQueryEngine::get_FACE(ref_face);
+ if (!acis_FACE)
+ return CUBIT_FAILURE;
- //Now for all of the free_faces, create BODYS for them.
- DLIList<BODY*> BODY_list, old_BODY_list;
- for ( ii = free_faces.size(); ii > 0; ii-- )
- {
- ref_face = free_faces.get_and_step();
- FACE *acis_FACE = AcisQueryEngine::get_FACE(ref_face);
- if (!acis_FACE)
- return CUBIT_FAILURE;
+ FACE *face_list[1];
+ BODY *sheet_body;
+ face_list[0] = acis_FACE;
+ rc = api_sheet_from_ff(1, face_list, sheet_body);
+ if (!rc.ok())
+ {
+ PRINT_ERROR("Couldn't build a volume with Surface.\n") ;
+ for (int jj = BODY_list.size(); jj > 0; jj-- )
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
+ AcisQueryEngine::instance()->ACIS_API_error (rc);
+ return CUBIT_FAILURE;
+ }
+ rc = api_body_to_2d(sheet_body);
+ if (!rc.ok())
+ {
+ PRINT_ERROR("Couldn't build a volume with Surface.\n" );
+ for (int jj = BODY_list.size(); jj > 0; jj-- )
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
+ AcisQueryEngine::instance()->ACIS_API_error (rc);
+ return CUBIT_FAILURE;
+ }
+ // Make sure we were successful
+ if ( sheet_body->lump() == NULL ||
+ sheet_body->lump()->shell() == NULL ||
+ sheet_body->lump()->shell()->first_face() == NULL )
+ {
+ PRINT_ERROR("Couldn't build a volume with Surface.\n" );
+ for (int jj = BODY_list.size(); jj > 0; jj-- )
+ AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
+ return CUBIT_FAILURE;
+ }
+ BODY_list.append(sheet_body);
+ }
+ BODY *first_BODY = NULL;
- FACE *face_list[1];
- BODY *sheet_body;
- face_list[0] = acis_FACE;
- rc = api_sheet_from_ff(1, face_list, sheet_body);
- if (!rc.ok())
- {
- PRINT_ERROR("Couldn't build a volume with Surface.\n") ;
- for (int jj = BODY_list.size(); jj > 0; jj-- )
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
- AcisQueryEngine::instance()->ACIS_API_error (rc);
- return CUBIT_FAILURE;
- }
- rc = api_body_to_2d(sheet_body);
- if (!rc.ok())
- {
- PRINT_ERROR("Couldn't build a volume with Surface.\n" );
- for (int jj = BODY_list.size(); jj > 0; jj-- )
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
- AcisQueryEngine::instance()->ACIS_API_error (rc);
- return CUBIT_FAILURE;
- }
- // Make sure we were successful
- if ( sheet_body->lump() == NULL ||
- sheet_body->lump()->shell() == NULL ||
- sheet_body->lump()->shell()->first_face() == NULL )
- {
- PRINT_ERROR("Couldn't build a volume with Surface.\n" );
- for (int jj = BODY_list.size(); jj > 0; jj-- )
- AcisQueryEngine::instance()->delete_ACIS_BODY(BODY_list.remove());
- return CUBIT_FAILURE;
- }
- BODY_list.append(sheet_body);
- }
- BODY *first_BODY = NULL;
+ for ( ii = body_list.size(); ii > 0; ii-- )
+ {
+ BodySM *body_ptr = body_list.get_and_step();
+ BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ if (!BODY_ptr)
+ return CUBIT_FAILURE;
- for ( ii = body_list.size(); ii > 0; ii-- )
- {
- BodySM *body_ptr = body_list.get_and_step();
- BODY *BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- if (!BODY_ptr)
- return CUBIT_FAILURE;
+ if (first_BODY == NULL )
+ first_BODY = BODY_ptr;
+ BODY_list.append(BODY_ptr);
+ old_BODY_list.append(BODY_ptr);
+ }
+ //Okay unite all of these bodies into one body.
+ BODY_list.reset();
+ int new_ids = GeometryModifyTool::instance()->get_new_ids();
+ bool delete_attribs = (new_ids || keep_old);
+ BODY *master;
- if (first_BODY == NULL )
- first_BODY = BODY_ptr;
- BODY_list.append(BODY_ptr);
- old_BODY_list.append(BODY_ptr);
- }
- //Okay unite all of these bodies into one body.
- BODY_list.reset();
- int new_ids = GeometryModifyTool::instance()->get_new_ids();
- bool delete_attribs = (new_ids || keep_old);
- BODY *master;
+ //if we're not healing, we're assuming the surfaces have gaps between each other
+ //less than 1e-6, so we'll use stitching, otherwise we assume the gaps are bigger than
+ //1e-6 and we'll us api_combine_body, and subsequently we'll heal
+ ENTITY_LIST bodies_to_be_stitched;
- //if we're not healing, we're assuming the surfaces have gaps between each other
- //less than 1e-6, so we'll use stitching, otherwise we assume the gaps are bigger than
- //1e-6 and we'll us api_combine_body, and subsequently we'll heal
- ENTITY_LIST bodies_to_be_stitched;
+ if ( first_BODY )
+ {
+ master = this->copy_BODY(first_BODY, delete_attribs);
+ BODY_list.remove(first_BODY);
+ }
+ else
+ master = this->copy_BODY(BODY_list.remove(), delete_attribs);
- if ( first_BODY )
- {
- master = this->copy_BODY(first_BODY, delete_attribs);
- BODY_list.remove(first_BODY);
- }
- else
- master = this->copy_BODY(BODY_list.remove(), delete_attribs);
+ if( !heal )
+ bodies_to_be_stitched.add( master );
- if( !heal )
- bodies_to_be_stitched.add( master );
+ for ( ii = BODY_list.size(); ii > 0; ii-- )
+ {
+ BODY *BODY_ptr = BODY_list.get_and_step();
+ BODY *copy = this->copy_BODY(BODY_ptr, delete_attribs);
+ if (copy == NULL)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(master);
+ return CUBIT_FAILURE;
+ }
+ if( !heal )
+ bodies_to_be_stitched.add( copy );
+ else
+ {
+ outcome result = api_combine_body(copy, master );
- for ( ii = BODY_list.size(); ii > 0; ii-- )
- {
- BODY *BODY_ptr = BODY_list.get_and_step();
- BODY *copy = this->copy_BODY(BODY_ptr, delete_attribs);
- if (copy == NULL)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(master);
- return CUBIT_FAILURE;
- }
- if( !heal )
- bodies_to_be_stitched.add( copy );
- else
- {
- outcome result = api_combine_body(copy, master );
+ if (!result.ok() || (!master ))
+ {
+ // If there are no LUMPs in the resulting BODY, return with a failure
+ if (master == NULL)
+ PRINT_ERROR("In AcisModifyEngine::create_solid_bodies_from_surfs\n");
- if (!result.ok() || (!master ))
- {
- // If there are no LUMPs in the resulting BODY, return with a failure
- if (master == NULL)
- PRINT_ERROR("In AcisModifyEngine::create_solid_bodies_from_surfs\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "create body from surfs");
+ if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master);
+ if (copy != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(copy);
- AcisQueryEngine::instance()->ACIS_API_error(result, "create body from surfs");
- if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master);
- if (copy != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(copy);
+ return CUBIT_FAILURE;
+ }
+ }
+ }
- return CUBIT_FAILURE;
- }
- }
- }
+ if( !heal )
+ {
+ ENTITY_LIST dummy_list, resultant_bodies;
+ tolerant_stitch_options stitch_opts;
+ //surfaces better be between GEOMETRY_RESABS or else fail
+ stitch_opts.set_max_stitch_tol( GEOMETRY_RESABS );
+ outcome result = api_stitch( bodies_to_be_stitched, dummy_list, resultant_bodies, &stitch_opts );
- if( !heal )
- {
- ENTITY_LIST dummy_list, resultant_bodies;
- tolerant_stitch_options stitch_opts;
- //surfaces better be between GEOMETRY_RESABS or else fail
- stitch_opts.set_max_stitch_tol( GEOMETRY_RESABS );
- outcome result = api_stitch( bodies_to_be_stitched, dummy_list, resultant_bodies, &stitch_opts );
+ master = (BODY*)dummy_list.first();
- master = (BODY*)dummy_list.first();
+ if (!result.ok() || (!master ))
+ {
+ // If there are no LUMPs in the resulting BODY, return with a failure
+ if (master == NULL)
+ PRINT_ERROR("In AcisModifyEngine::create_solid_bodies_from_surfs\n");
- if (!result.ok() || (!master ))
- {
- // If there are no LUMPs in the resulting BODY, return with a failure
- if (master == NULL)
- PRINT_ERROR("In AcisModifyEngine::create_solid_bodies_from_surfs\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result, "create body from surfs");
+ if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master);
- AcisQueryEngine::instance()->ACIS_API_error(result, "create body from surfs");
- if (master != NULL) AcisQueryEngine::instance()->delete_ACIS_BODY(master);
+ return CUBIT_FAILURE;
+ }
+ }
- return CUBIT_FAILURE;
- }
- }
+ // If all went well, delete the old Bodies
+ DLIList<TopologyBridge*> old_entities;
+ body_list.reset() ;
- // If all went well, delete the old Bodies
- DLIList<TopologyBridge*> old_entities;
- body_list.reset() ;
+ CAST_LIST_TO_PARENT(body_list, old_entities);
- CAST_LIST_TO_PARENT(body_list, old_entities);
+ for ( ii = free_faces.size(); ii > 0; ii-- )
+ old_entities.append(free_faces.get_and_step());
- for ( ii = free_faces.size(); ii > 0; ii-- )
- old_entities.append(free_faces.get_and_step());
+/*
+ if (!keep_old )
+ {
+ for( ii = body_list.size(); ii > 0; ii--)
+ {
+ Body* body_ptr = body_list.get_and_step() ;
+ GeometryModifyTool::instance()->delete_Body(body_ptr) ;
+ }
+ for ( ii = free_faces.size(); ii > 0; ii-- )
+ {
+ RefFace *ref_ptr = free_faces.get_and_step();
+ RefEntity *ref_entity_ptr = CAST_TO(ref_ptr, RefEntity);
+ GeometryModifyTool::instance()->delete_RefEntity(ref_entity_ptr);
+ }
+ }
+*/
- /*
- if (!keep_old )
- {
- for( ii = body_list.size(); ii > 0; ii--)
- {
- Body* body_ptr = body_list.get_and_step() ;
- GeometryModifyTool::instance()->delete_Body(body_ptr) ;
- }
- for ( ii = free_faces.size(); ii > 0; ii-- )
- {
- RefFace *ref_ptr = free_faces.get_and_step();
- RefEntity *ref_entity_ptr = CAST_TO(ref_ptr, RefEntity);
- GeometryModifyTool::instance()->delete_RefEntity(ref_entity_ptr);
- }
- }
- */
-
- BODY *new_master = master;
+ BODY *new_master = master;
#ifdef ACIS_HEALER
- // BODY *new_master = master;
- if ( heal )
- {
+// BODY *new_master = master;
+ if ( heal )
+ {
- // Now heal the combined body
- PRINT_INFO(" Healing the combined volume...\n");
- if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
- {
- int percent_before, percent_after, number_splines_simplified;
- if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
- percent_after, number_splines_simplified ) == CUBIT_FAILURE )
- PRINT_ERROR( "Error healing the combined volume\n" );
- else
- PRINT_INFO( "Healed the combined volume to %d%% good geometry.\n", percent_after );
- AcisHealerTool::instance()->end_BODY_for_healing( master );
- }
- }
+ // Now heal the combined body
+ PRINT_INFO(" Healing the combined volume...\n");
+ if( AcisHealerTool::instance()->init_BODY_for_healing( master ) == CUBIT_SUCCESS )
+ {
+ int percent_before, percent_after, number_splines_simplified;
+ if( AcisHealerTool::instance()->heal_BODY( master, percent_before,
+ percent_after, number_splines_simplified ) == CUBIT_FAILURE )
+ PRINT_ERROR( "Error healing the combined volume\n" );
+ else
+ PRINT_INFO( "Healed the combined volume to %d%% good geometry.\n", percent_after );
+ AcisHealerTool::instance()->end_BODY_for_healing( master );
+ }
+ }
#else
- PRINT_WARNING("Healer was not included with this version.\n"
- " Volume healing is usually required for creating\n"
- " volumes out of surfaces.\n");
+ PRINT_WARNING("Healer was not included with this version.\n"
+ " Volume healing is usually required for creating\n"
+ " volumes out of surfaces.\n");
#endif
- //Gather all the FACEs from resultant BODY
- ENTITY_LIST tmp_FACEs;
- api_get_faces( new_master, tmp_FACEs );
- FACE **tmp_FACE_array = new FACE*[tmp_FACEs.count()];
- tmp_FACEs.init();
- ENTITY *tmp_ent = NULL;
- while( (tmp_ent = tmp_FACEs.next()) != NULL)
- tmp_FACE_array[ii++] = static_cast<FACE*>(tmp_ent);
+ //Gather all the FACEs from resultant BODY
+ ENTITY_LIST tmp_FACEs;
+ api_get_faces( new_master, tmp_FACEs );
+ FACE **tmp_FACE_array = new FACE*[tmp_FACEs.count()];
+ tmp_FACEs.init();
+ ENTITY *tmp_ent = NULL;
+ while( (tmp_ent = tmp_FACEs.next()) != NULL)
+ tmp_FACE_array[ii++] = static_cast<FACE*>(tmp_ent);
- //lets make sure that there are not inappropriate intersections between FACEs
- ENTITY_LIST insane_ents;
- logical bad_ints = true;
- api_check_list_ff_ints( tmp_FACEs.count(), tmp_FACE_array, &insane_ents, bad_ints );
+ //lets make sure that there are not inappropriate intersections between FACEs
+ ENTITY_LIST insane_ents;
+ logical bad_ints = true;
+ api_check_list_ff_ints( tmp_FACEs.count(), tmp_FACE_array, &insane_ents, bad_ints );
- delete [] tmp_FACE_array;
+ delete [] tmp_FACE_array;
- if( insane_ents.count() || bad_ints )
- {
- PRINT_INFO("Bad surface-surface intersections\n");
- insane_ents.init();
- while( (tmp_ent=insane_ents.next()) != NULL)
- {
- ERROR_ENTITY *error_ent = static_cast<ERROR_ENTITY*>(tmp_ent);
- PRINT_ERROR("ACIS error number %d %s\n", error_ent->get_error_id(),
- find_err_mess (error_ent->get_error_id()));
- }
- api_delent( new_master );
- return CUBIT_FAILURE;
- }
-
- //separate the bodies so that you have no multi-volume bodies
- ENTITY_LIST separated_bodies;
- BODY **new_BODY_list;
- int n_bodies;
- api_separate_body( new_master, n_bodies, new_BODY_list );
-
- DLIList<BODY*> new_BODIES;
- int i;
- for( i=0; i<n_bodies; i++ )
- new_BODIES.append( new_BODY_list[i] );
-
- CubitStatus success =
- get_new_Body(old_entities, new_BODIES, new_bodies, keep_old);
-
- if ( new_bodies.size() == 0 )
- {
- PRINT_ERROR("Problems creating new volume.\n" );
- return CUBIT_FAILURE;
- }
- return CUBIT_SUCCESS;
+ if( insane_ents.count() || bad_ints )
+ {
+ PRINT_INFO("Bad surface-surface intersections\n");
+ insane_ents.init();
+ while( (tmp_ent=insane_ents.next()) != NULL)
+ {
+ ERROR_ENTITY *error_ent = static_cast<ERROR_ENTITY*>(tmp_ent);
+ PRINT_ERROR("ACIS error number %d %s\n", error_ent->get_error_id(),
+ find_err_mess (error_ent->get_error_id()));
}
+ api_delent( new_master );
+ return CUBIT_FAILURE;
+ }
- // Currently no command line to this
- CubitStatus AcisModifyEngine::webcut_across_translate(
- DLIList<BodySM*>& body_list,
- Surface* top_surf_ptr,
- Surface* bottom_surf_ptr,
- DLIList<BodySM*>& ,
- bool ) const
- {
- CubitVector top_orig, top_norm, bottom_orig, bottom_norm;
- double top_orig_pnt[3], top_norm_vec[3], bottom_orig_pnt[3], bottom_norm_vec[3];
- //CubitVector top_sweep_vector, bottom_sweep_vector;
- double distance;
- int i, ii;
- BodySM* body_ptr;
- Surface* ref_face_ptr;
- FACE* FACE_ptr;
- FACE* copied_FACE_ptr;
- ENTITY *entity_ptr;
- DLIList<BODY*> tool_BODY_list;
- //int volume_is_negative;
- AgtSide side;
- AgtOrientation orien;
- outcome result;
+ //separate the bodies so that you have no multi-volume bodies
+ ENTITY_LIST separated_bodies;
+ BODY **new_BODY_list;
+ int n_bodies;
+ api_separate_body( new_master, n_bodies, new_BODY_list );
- AnalyticGeometryTool* agt = AnalyticGeometryTool::instance();
+ DLIList<BODY*> new_BODIES;
+ int i;
+ for( i=0; i<n_bodies; i++ )
+ new_BODIES.append( new_BODY_list[i] );
- // Find top plane
- if( top_surf_ptr->get_point_normal( top_orig, top_norm ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Surface is not planar\n" );
- return CUBIT_FAILURE;
- }
+ CubitStatus success =
+ get_new_Body(old_entities, new_BODIES, new_bodies, keep_old);
- if( bottom_surf_ptr->get_point_normal( bottom_orig, bottom_norm ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Surface is not planar\n" );
- return CUBIT_FAILURE;
- }
+ if ( new_bodies.size() == 0 )
+ {
+ PRINT_ERROR("Problems creating new volume.\n" );
+ return CUBIT_FAILURE;
+ }
+ return CUBIT_SUCCESS;
+}
- top_orig.get_xyz( top_orig_pnt ); top_norm.get_xyz( top_norm_vec );
- bottom_orig.get_xyz( bottom_orig_pnt ); bottom_norm.get_xyz( bottom_norm_vec );
+// Currently no command line to this
+CubitStatus AcisModifyEngine::webcut_across_translate(
+ DLIList<BodySM*>& body_list,
+ Surface* top_surf_ptr,
+ Surface* bottom_surf_ptr,
+ DLIList<BodySM*>& ,
+ bool ) const
+{
+ CubitVector top_orig, top_norm, bottom_orig, bottom_norm;
+ double top_orig_pnt[3], top_norm_vec[3], bottom_orig_pnt[3], bottom_norm_vec[3];
+ //CubitVector top_sweep_vector, bottom_sweep_vector;
+ double distance;
+ int i, ii;
+ BodySM* body_ptr;
+ Surface* ref_face_ptr;
+ FACE* FACE_ptr;
+ FACE* copied_FACE_ptr;
+ ENTITY *entity_ptr;
+ DLIList<BODY*> tool_BODY_list;
+ //int volume_is_negative;
+ AgtSide side;
+ AgtOrientation orien;
+ outcome result;
- // Check distance between planes
- distance = agt->dist_pln_pln( top_orig_pnt, top_norm_vec, bottom_orig_pnt, bottom_norm_vec,
- &side, &orien );
+ AnalyticGeometryTool* agt = AnalyticGeometryTool::instance();
- if( agt->dbl_eq( distance, 0.0 ) )
- {
- PRINT_ERROR( "Distance between planes is 0.0\n" );
- return CUBIT_FAILURE;
- }
+ // Find top plane
+ if( top_surf_ptr->get_point_normal( top_orig, top_norm ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Surface is not planar\n" );
+ return CUBIT_FAILURE;
+ }
- double top_bott[3];
- top_bott[0] = top_norm.x();
- top_bott[1] = top_norm.y();
- top_bott[2] = top_norm.z();
- if( side == AGT_NEG_SIDE ) {
- agt->reverse_vec( top_bott, top_bott );
- }
+ if( bottom_surf_ptr->get_point_normal( bottom_orig, bottom_norm ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Surface is not planar\n" );
+ return CUBIT_FAILURE;
+ }
- // Top plane
- for( i=0; i<body_list.size(); i++ )
- {
- body_ptr = body_list.get_and_step();
+ top_orig.get_xyz( top_orig_pnt ); top_norm.get_xyz( top_norm_vec );
+ bottom_orig.get_xyz( bottom_orig_pnt ); bottom_norm.get_xyz( bottom_norm_vec );
- DLIList<Surface*> ref_face_list;
- AcisQueryEngine::instance()->get_surfs_on_plane( body_ptr, top_orig_pnt, top_norm_vec, ref_face_list );
+ // Check distance between planes
+ distance = agt->dist_pln_pln( top_orig_pnt, top_norm_vec, bottom_orig_pnt, bottom_norm_vec,
+ &side, &orien );
- if( ref_face_list.size() == 0 )
- continue;
+ if( agt->dbl_eq( distance, 0.0 ) )
+ {
+ PRINT_ERROR( "Distance between planes is 0.0\n" );
+ return CUBIT_FAILURE;
+ }
- for( ii=0; ii<ref_face_list.size(); ii++ )
- {
- ref_face_ptr = ref_face_list.get_and_step();
+ double top_bott[3];
+ top_bott[0] = top_norm.x();
+ top_bott[1] = top_norm.y();
+ top_bott[2] = top_norm.z();
+ if( side == AGT_NEG_SIDE ) {
+ agt->reverse_vec( top_bott, top_bott );
+ }
- // Copy each surface, reverse and extrude
- FACE_ptr = AcisQueryEngine::get_FACE( ref_face_ptr );
+ // Top plane
+ for( i=0; i<body_list.size(); i++ )
+ {
+ body_ptr = body_list.get_and_step();
- if( FACE_ptr == NULL )
- {
- return CUBIT_FAILURE;
- }
+ DLIList<Surface*> ref_face_list;
+ AcisQueryEngine::instance()->get_surfs_on_plane( body_ptr, top_orig_pnt, top_norm_vec, ref_face_list );
- result = api_copy_entity_contents( (ENTITY *)FACE_ptr, entity_ptr);
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to copy face off volume\n" );
- continue;
- }
+ if( ref_face_list.size() == 0 )
+ continue;
- copied_FACE_ptr = (FACE *)entity_ptr;
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_FACE_ptr,
- CUBIT_TRUE );
+ for( ii=0; ii<ref_face_list.size(); ii++ )
+ {
+ ref_face_ptr = ref_face_list.get_and_step();
- // Create a sheet body from this free-face
- BODY* sheet_BODY_ptr;
- result = api_sheet_from_ff( 1, &copied_FACE_ptr, sheet_BODY_ptr );
- if (!result.ok())
- {
- PRINT_ERROR("Error in api_sheet_from_ff\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to create sheet volume from face\n" );
- continue;
- }
- if( sheet_BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to create sheet volume from face\n" );
- continue;
- }
+ // Copy each surface, reverse and extrude
+ FACE_ptr = AcisQueryEngine::get_FACE( ref_face_ptr );
- DLIList<FACE*> sheet_FACE_list;
- AcisQueryEngine::instance()->get_FACEs( (ENTITY *)sheet_BODY_ptr, sheet_FACE_list );
- if( sheet_FACE_list.size() != 1 )
- {
- PRINT_ERROR( "Sheet doesn't have one face\n" );
- continue;
- }
- FACE* sheet_FACE_ptr = sheet_FACE_list.get();
+ if( FACE_ptr == NULL )
+ {
+ return CUBIT_FAILURE;
+ }
- // Get underlying plane normal. The FACE normal might be reversed
- // of this.
- surface const* acis_surface = &(sheet_FACE_ptr->geometry()->equation());
- SPAposition sheet_surf_orig;
- SPAunit_vector sheet_surf_norm;
- acis_surface->planar( sheet_surf_orig, sheet_surf_norm );
- double sheet_norm[3];
- sheet_norm[0] = sheet_surf_norm.x();
- sheet_norm[1] = sheet_surf_norm.y();
- sheet_norm[2] = sheet_surf_norm.z();
+ result = api_copy_entity_contents( (ENTITY *)FACE_ptr, entity_ptr);
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to copy face off volume\n" );
+ continue;
+ }
- // Get sheet normal in same direction as ACIS FACE. The direction of the
- // ACIS face is the direction of sweep.
- if( sheet_FACE_ptr->sense() == REVERSED )
- agt->reverse_vec( sheet_norm, sheet_norm );
+ copied_FACE_ptr = (FACE *)entity_ptr;
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_FACE_ptr,
+ CUBIT_TRUE );
- // Properties of dot product
- // angle acute if dot product > 0
- // angle obtuse if dot product < 0
- // angle 90 deg if dot product = 0
+ // Create a sheet body from this free-face
+ BODY* sheet_BODY_ptr;
+ result = api_sheet_from_ff( 1, &copied_FACE_ptr, sheet_BODY_ptr );
+ if (!result.ok())
+ {
+ PRINT_ERROR("Error in api_sheet_from_ff\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to create sheet volume from face\n" );
+ continue;
+ }
+ if( sheet_BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to create sheet volume from face\n" );
+ continue;
+ }
- if( agt->dot_vec( sheet_norm, top_bott ) < 0.0 )
- {
- //PRINT_INFO( "Reversing volume...\n" );
- api_reverse_body( sheet_BODY_ptr );
- }
+ DLIList<FACE*> sheet_FACE_list;
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY *)sheet_BODY_ptr, sheet_FACE_list );
+ if( sheet_FACE_list.size() != 1 )
+ {
+ PRINT_ERROR( "Sheet doesn't have one face\n" );
+ continue;
+ }
+ FACE* sheet_FACE_ptr = sheet_FACE_list.get();
- result = api_sw_face_norm( sheet_FACE_ptr, FORWARD, distance+distance*(.50), 0, 0 );
+ // Get underlying plane normal. The FACE normal might be reversed
+ // of this.
+ surface const* acis_surface = &(sheet_FACE_ptr->geometry()->equation());
+ SPAposition sheet_surf_orig;
+ SPAunit_vector sheet_surf_norm;
+ acis_surface->planar( sheet_surf_orig, sheet_surf_norm );
+ double sheet_norm[3];
+ sheet_norm[0] = sheet_surf_norm.x();
+ sheet_norm[1] = sheet_surf_norm.y();
+ sheet_norm[2] = sheet_surf_norm.z();
- if (!result.ok())
- {
- PRINT_ERROR("Error during ACIS sweep operation, api_sw_face_norm\n");
- AcisQueryEngine::instance()->ACIS_API_error(result);
- continue;
- }
+ // Get sheet normal in same direction as ACIS FACE. The direction of the
+ // ACIS face is the direction of sweep.
+ if( sheet_FACE_ptr->sense() == REVERSED )
+ agt->reverse_vec( sheet_norm, sheet_norm );
- BODY* tool_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(sheet_FACE_ptr);
+ // Properties of dot product
+ // angle acute if dot product > 0
+ // angle obtuse if dot product < 0
+ // angle 90 deg if dot product = 0
- if (is_BODY(tool_BODY_ptr))
- {
- result = api_body_to_2d(tool_BODY_ptr);
- if (!result.ok())
- PRINT_WARNING("Couldn't turn a tool into a 3D sheet\n" );
+ if( agt->dot_vec( sheet_norm, top_bott ) < 0.0 )
+ {
+ //PRINT_INFO( "Reversing volume...\n" );
+ api_reverse_body( sheet_BODY_ptr );
+ }
- tool_BODY_list.append( tool_BODY_ptr );
+ result = api_sw_face_norm( sheet_FACE_ptr, FORWARD, distance+distance*(.50), 0, 0 );
- // Move the body slightly so it overlaps
- // Create a SPAvector representing the offsets
- double fact = 0.35;
- SPAvector translation_vector( -top_bott[0]*distance*fact, -top_bott[1]*distance*fact, -top_bott[2]*distance*fact );
- SPAtransf tran_vec = translate_transf (translation_vector);
+ if (!result.ok())
+ {
+ PRINT_ERROR("Error during ACIS sweep operation, api_sw_face_norm\n");
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ continue;
+ }
- // Concatenate the input transformation to the existing one
- result = api_apply_transf ( tool_BODY_ptr, tran_vec );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
- continue;
- }
- TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
- result = api_change_body_trans ( tool_BODY_ptr, identity, FALSE );
- identity->lose();
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
- continue;
+ BODY* tool_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY(sheet_FACE_ptr);
- }
+ if (is_BODY(tool_BODY_ptr))
+ {
+ result = api_body_to_2d(tool_BODY_ptr);
+ if (!result.ok())
+ PRINT_WARNING("Couldn't turn a tool into a 3D sheet\n" );
- }
+ tool_BODY_list.append( tool_BODY_ptr );
- else
- {
- PRINT_ERROR( "Unable to create tool from surface\n" );
- }
- }
+ // Move the body slightly so it overlaps
+ // Create a SPAvector representing the offsets
+ double fact = 0.35;
+ SPAvector translation_vector( -top_bott[0]*distance*fact, -top_bott[1]*distance*fact, -top_bott[2]*distance*fact );
+ SPAtransf tran_vec = translate_transf (translation_vector);
- PRINT_INFO( "Got %d tools\n from the top\n", tool_BODY_list.size() );
+ // Concatenate the input transformation to the existing one
+ result = api_apply_transf ( tool_BODY_ptr, tran_vec );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
+ continue;
+ }
+ TRANSFORM* identity = new TRANSFORM(scale_transf(1.0));
+ result = api_change_body_trans ( tool_BODY_ptr, identity, FALSE );
+ identity->lose();
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error ( result, "transforming body" );
+ continue;
- // For now just create tools
- for( ii=0; ii<tool_BODY_list.size(); ii++ )
- {
- BODY *temp_tool_BODY_ptr = tool_BODY_list.get_and_step();
+ }
- /*BodySM *new_body = */
- AcisQueryEngine::instance()->populate_topology_bridges(temp_tool_BODY_ptr);
- }
+ }
- }
+ else
+ {
+ PRINT_ERROR( "Unable to create tool from surface\n" );
+ }
+ }
- return CUBIT_SUCCESS;
- }
+ PRINT_INFO( "Got %d tools\n from the top\n", tool_BODY_list.size() );
- // Imprints curves to bodies.
- CubitStatus AcisModifyEngine::imprint( DLIList<BodySM*> &body_list,
- DLIList<Curve*> &ref_edge_list,
- DLIList<BodySM*>& new_body_list,
- bool keep_old_body,
- bool show_messages) const
- {
- int i, j;
- outcome result;
- CubitStatus status = CUBIT_SUCCESS;
- CubitBoolean imprint_worked = CUBIT_FALSE;
+ // For now just create tools
+ for( ii=0; ii<tool_BODY_list.size(); ii++ )
+ {
+ BODY *temp_tool_BODY_ptr = tool_BODY_list.get_and_step();
- Curve* ref_edge_ptr;
- BodySM *body_ptr;
+ /*BodySM *new_body = */
+ AcisQueryEngine::instance()->populate_topology_bridges(temp_tool_BODY_ptr);
+ }
- BODY *BODY_ptr;
- BODY *copied_BODY_ptr;
- BODY *wire_BODY_ptr;
+ }
- EDGE *EDGE_ptr;
- EDGE *copied_EDGE_ptr;
+ return CUBIT_SUCCESS;
+}
- DLIList<BODY*> ewire_list;
+// Imprints curves to bodies.
+CubitStatus AcisModifyEngine::imprint( DLIList<BodySM*> &body_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool show_messages) const
+{
+ int i, j;
+ outcome result;
+ CubitStatus status = CUBIT_SUCCESS;
+ CubitBoolean imprint_worked = CUBIT_FALSE;
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
+ Curve* ref_edge_ptr;
+ BodySM *body_ptr;
- // Make wires which can be used to imprint onto the bodies
- ref_edge_list.reset();
- for( i=0; i<ref_edge_list.size(); i++ )
- {
- ref_edge_ptr = ref_edge_list.get_and_step();
+ BODY *BODY_ptr;
+ BODY *copied_BODY_ptr;
+ BODY *wire_BODY_ptr;
- // Get the EDGE pointer
- EDGE_ptr = AcisQueryEngine::get_EDGE( ref_edge_ptr );
+ EDGE *EDGE_ptr;
+ EDGE *copied_EDGE_ptr;
- if( EDGE_ptr == NULL )
- {
- return CUBIT_FAILURE;
- }
+ DLIList<BODY*> ewire_list;
- // Copy the EDGE. I've found that the ewire will reference
- // the original EDGE and that EDGE can get split later when
- // doing imprints. Also note that the copied EDGE will get
- // deleted when deleting the ewire.
- result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- if (!result.ok())
- {
- PRINT_ERROR( "Unable to copy curve; aborting\n" );
- AcisQueryEngine::instance()->ACIS_API_error (result);
- return CUBIT_FAILURE;
- }
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
- // Remove the CUBIT owner attribute from the EDGE
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
- CUBIT_TRUE );
+ // Make wires which can be used to imprint onto the bodies
+ ref_edge_list.reset();
+ for( i=0; i<ref_edge_list.size(); i++ )
+ {
+ ref_edge_ptr = ref_edge_list.get_and_step();
- // Make an ewire from this EDGE
- result = api_make_ewire( 1, &copied_EDGE_ptr, wire_BODY_ptr );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "Unable to make ACIS WIRE from curve; aborting\n" );
- for( j=0; j<ewire_list.size(); j++ )
- api_delent( ewire_list.get_and_step() );
- return CUBIT_FAILURE;
- }
+ // Get the EDGE pointer
+ EDGE_ptr = AcisQueryEngine::get_EDGE( ref_edge_ptr );
- ewire_list.append( wire_BODY_ptr );
- }
+ if( EDGE_ptr == NULL )
+ {
+ return CUBIT_FAILURE;
+ }
- // Loop on bodies, imprinting each with all the ewires
- for( i=0; i<body_list.size(); i++ )
- {
- body_ptr = body_list.get_and_step();
+ // Copy the EDGE. I've found that the ewire will reference
+ // the original EDGE and that EDGE can get split later when
+ // doing imprints. Also note that the copied EDGE will get
+ // deleted when deleting the ewire.
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ if (!result.ok())
+ {
+ PRINT_ERROR( "Unable to copy curve; aborting\n" );
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ return CUBIT_FAILURE;
+ }
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- if( BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to find ACIS BODY from volume; aborting\n" );
- for( j=0; j<ewire_list.size(); j++ )
- api_delent( ewire_list.get_and_step() );
- return CUBIT_FAILURE;
- }
+ // Remove the CUBIT owner attribute from the EDGE
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
+ CUBIT_TRUE );
- // Copy the body before working with it
- copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
+ // Make an ewire from this EDGE
+ result = api_make_ewire( 1, &copied_EDGE_ptr, wire_BODY_ptr );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "Unable to make ACIS WIRE from curve; aborting\n" );
+ for( j=0; j<ewire_list.size(); j++ )
+ api_delent( ewire_list.get_and_step() );
+ return CUBIT_FAILURE;
+ }
- // Imprint the wire-bodies onto the BODY
- api_set_int_option("all_free_edges", TRUE );
- ewire_list.reset();
- ref_edge_list.reset();
- for( j=0; j<ewire_list.size(); j++ )
- {
- wire_BODY_ptr = ewire_list.get_and_step();
- ref_edge_ptr = ref_edge_list.get_and_step();
- BODY* temp_BODY_ptr = copy_BODY( copied_BODY_ptr, delete_attribs );
+ ewire_list.append( wire_BODY_ptr );
+ }
- result = api_imprint( wire_BODY_ptr, copied_BODY_ptr );
+ // Loop on bodies, imprinting each with all the ewires
+ for( i=0; i<body_list.size(); i++ )
+ {
+ body_ptr = body_list.get_and_step();
- //Gets rid of sliver curves/surfaces that could get produced by the imprint.
- AcisModifyEngine::instance()->cleanup_slivers( copied_BODY_ptr );
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ if( BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to find ACIS BODY from volume; aborting\n" );
+ for( j=0; j<ewire_list.size(); j++ )
+ api_delent( ewire_list.get_and_step() );
+ return CUBIT_FAILURE;
+ }
- if( !result.ok() && result.error_number()!=200 )
- {
- if ( show_messages )
- {
- PRINT_ERROR( "problem imprinting curve onto volume\n" );
- AcisQueryEngine::instance()->ACIS_API_error(result);
- }
- //revert back to the old body.
- api_delent(copied_BODY_ptr);
- copied_BODY_ptr = temp_BODY_ptr;
- status = CUBIT_FAILURE;
- }
- else
- imprint_worked = CUBIT_TRUE;
- }
- if( imprint_worked )
- {
- api_set_int_option("all_free_edges", FALSE );
+ // Copy the body before working with it
+ copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
+ // Imprint the wire-bodies onto the BODY
+ api_set_int_option("all_free_edges", TRUE );
+ ewire_list.reset();
+ ref_edge_list.reset();
+ for( j=0; j<ewire_list.size(); j++ )
+ {
+ wire_BODY_ptr = ewire_list.get_and_step();
+ ref_edge_ptr = ref_edge_list.get_and_step();
+ BODY* temp_BODY_ptr = copy_BODY( copied_BODY_ptr, delete_attribs );
- BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
- keep_old_body, CUBIT_TRUE );
+ result = api_imprint( wire_BODY_ptr, copied_BODY_ptr );
- if( new_body_ptr )
- {
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count--; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
- new_body_list.append(new_body_ptr);
- }
- }
- }
+ //Gets rid of sliver curves/surfaces that could get produced by the imprint.
+ AcisModifyEngine::instance()->cleanup_slivers( copied_BODY_ptr );
- // Free memory
- for( i=0; i<ewire_list.size(); i++ )
- api_delent( ewire_list.get_and_step() );
- if ( imprint_worked && status != CUBIT_SUCCESS )
- status = CUBIT_SUCCESS;
- return status;
- }
+ if( !result.ok() && result.error_number()!=200 )
+ {
+ if ( show_messages )
+ {
+ PRINT_ERROR( "problem imprinting curve onto volume\n" );
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ }
+ //revert back to the old body.
+ api_delent(copied_BODY_ptr);
+ copied_BODY_ptr = temp_BODY_ptr;
+ status = CUBIT_FAILURE;
+ }
+ else
+ imprint_worked = CUBIT_TRUE;
+ }
+ if( imprint_worked )
+ {
+ api_set_int_option("all_free_edges", FALSE );
- // This is a special case - needed because if a curve hangs over
- // several surfaces on a body and the user wants to split only one
- // of the surfaces. This method sometimes works when function to
- // imprint a curve to a body fails. The surfaces must be part of
- // a body, but the curves just have to be valid ACIS EDGEs.
- CubitStatus AcisModifyEngine::imprint( DLIList<Surface*> &surface_list,
- DLIList<Curve*> &curve_list,
- DLIList<BodySM*>& new_body_list,
- bool keep_old_body ) const
- {
- int i;
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
- outcome result;
+ BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
+ keep_old_body, CUBIT_TRUE );
- // Copy the incoming surface_list since we will be pulling
- // surfaces out of it.
- DLIList<SurfaceACIS*> copied_surface_list(surface_list.size());
- Curve* curve_ptr;
+ if( new_body_ptr )
+ {
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count--; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
+ new_body_list.append(new_body_ptr);
+ }
+ }
+ }
- BodySM *body_ptr;
- BODY *BODY_ptr;
+ // Free memory
+ for( i=0; i<ewire_list.size(); i++ )
+ api_delent( ewire_list.get_and_step() );
+ if ( imprint_worked && status != CUBIT_SUCCESS )
+ status = CUBIT_SUCCESS;
+ return status;
+}
- EDGE *EDGE_ptr;
- EDGE *copied_EDGE_ptr;
+// This is a special case - needed because if a curve hangs over
+// several surfaces on a body and the user wants to split only one
+// of the surfaces. This method sometimes works when function to
+// imprint a curve to a body fails. The surfaces must be part of
+// a body, but the curves just have to be valid ACIS EDGEs.
+CubitStatus AcisModifyEngine::imprint( DLIList<Surface*> &surface_list,
+ DLIList<Curve*> &curve_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body ) const
+{
+ int i;
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
+ outcome result;
- CAST_LIST( surface_list, copied_surface_list, SurfaceACIS );
- if (surface_list.size() != copied_surface_list.size())
- {
- PRINT_ERROR("Non-ACIS Surface at %s:%d\n", __FILE__, __LINE__ );
- return CUBIT_FAILURE;
- }
+ // Copy the incoming surface_list since we will be pulling
+ // surfaces out of it.
+ DLIList<SurfaceACIS*> copied_surface_list(surface_list.size());
+ Curve* curve_ptr;
- // Need to copy all of the EDGE's before doing anything, if they are
- // part of a body being imprinted on they could be invalidated before
- // subsequent imprints.
- DLIList<EDGE*> EDGE_list;
- curve_list.reset();
- for( i=curve_list.size(); i--; )
- {
- curve_ptr = curve_list.get_and_step();
+ BodySM *body_ptr;
+ BODY *BODY_ptr;
- // Get the EDGE pointer
- EDGE_ptr = AcisQueryEngine::get_EDGE( curve_ptr );
+ EDGE *EDGE_ptr;
+ EDGE *copied_EDGE_ptr;
- if( EDGE_ptr == NULL )
- {
- PRINT_ERROR("Non-ACIS Curve at %s:%d\n", __FILE__, __LINE__ );
- return CUBIT_FAILURE;
- }
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
- // Copy the EDGE.
- result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "Unable to copy curve; aborting.\n" );
- return CUBIT_FAILURE;
- }
+ CAST_LIST( surface_list, copied_surface_list, SurfaceACIS );
+ if (surface_list.size() != copied_surface_list.size())
+ {
+ PRINT_ERROR("Non-ACIS Surface at %s:%d\n", __FILE__, __LINE__ );
+ return CUBIT_FAILURE;
+ }
- // Remove the CUBIT owner attribute from the EDGE
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr, CUBIT_TRUE );
+ // Need to copy all of the EDGE's before doing anything, if they are
+ // part of a body being imprinted on they could be invalidated before
+ // subsequent imprints.
+ DLIList<EDGE*> EDGE_list;
+ curve_list.reset();
+ for( i=curve_list.size(); i--; )
+ {
+ curve_ptr = curve_list.get_and_step();
- // Add the EDGE to the list
- EDGE_list.append( copied_EDGE_ptr );
- }
+ // Get the EDGE pointer
+ EDGE_ptr = AcisQueryEngine::get_EDGE( curve_ptr );
- // Loop on FACEs. We will work on imprinting surfaces from one body at a time.
- copied_surface_list.reset();
- while( copied_surface_list.size() )
- {
- DLIList<FACE*> imprint_FACE_list;
- BODY *copied_BODY_ptr;
- if( get_copied_FACES_of_body( copied_surface_list, imprint_FACE_list,
- copied_BODY_ptr ) == CUBIT_FAILURE )
- continue;
+ if( EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("Non-ACIS Curve at %s:%d\n", __FILE__, __LINE__ );
+ return CUBIT_FAILURE;
+ }
- // Get original Body and BODY
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
- BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
+ // Copy the EDGE.
+ result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "Unable to copy curve; aborting.\n" );
+ return CUBIT_FAILURE;
+ }
- // Now cleanout the owner attributes from the copied BODY, if required
- if( delete_attribs )
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
+ // Remove the CUBIT owner attribute from the EDGE
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr, CUBIT_TRUE );
- if( imprint( copied_BODY_ptr, imprint_FACE_list, EDGE_list ) == CUBIT_FAILURE )
- {
- // This only fails if there is a serious error - delete the copied Body
- api_delent( copied_BODY_ptr );
- continue;
- }
+ // Add the EDGE to the list
+ EDGE_list.append( copied_EDGE_ptr );
+ }
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
+ // Loop on FACEs. We will work on imprinting surfaces from one body at a time.
+ copied_surface_list.reset();
+ while( copied_surface_list.size() )
+ {
+ DLIList<FACE*> imprint_FACE_list;
+ BODY *copied_BODY_ptr;
+ if( get_copied_FACES_of_body( copied_surface_list, imprint_FACE_list,
+ copied_BODY_ptr ) == CUBIT_FAILURE )
+ continue;
- BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
- keep_old_body, CUBIT_TRUE );
+ // Get original Body and BODY
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( copied_BODY_ptr );
+ BODY_ptr = AcisQueryEngine::get_BODY(body_ptr);
- if( new_body_ptr )
- {
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count--; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
+ // Now cleanout the owner attributes from the copied BODY, if required
+ if( delete_attribs )
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
- new_body_list.append( new_body_ptr );
- }
- }
+ if( imprint( copied_BODY_ptr, imprint_FACE_list, EDGE_list ) == CUBIT_FAILURE )
+ {
+ // This only fails if there is a serious error - delete the copied Body
+ api_delent( copied_BODY_ptr );
+ continue;
+ }
- // Free the memory allocated when copying edges
- for( i=0; i<EDGE_list.size(); i++ )
- {
- copied_EDGE_ptr = EDGE_list.get_and_step();
- api_delent( copied_EDGE_ptr );
- }
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
- return CUBIT_SUCCESS;
- }
+ BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
+ keep_old_body, CUBIT_TRUE );
- // Imprint EDGEs to select FACEs. FACEs must be from same BODY. Input FACEs
- // are modified but EDGEs are not.
- CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
- DLIList<FACE*> &FACE_list,
- DLIList<EDGE*> &EDGE_list ) const
+ if( new_body_ptr )
{
- // Imprint the edges to the surfaces on this body
- outcome result;
- EDGE *EDGE_ptr;
- FACE *FACE_ptr;
- EDGE_list.reset();
- FACE_list.reset();
- int i, j;
- for( i=EDGE_list.size(); i--; )
- {
- // Imprint this edge selectively to the given faces on this body
- EDGE_ptr = EDGE_list.get_and_step();
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count--; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
- // Track the existing FACEs before imprinting this BODY with the edge.
- // Needed so we know which new surfaces result from the imprint. These
- // new surfaces will need to be imprinted with subsequent edges.
- DLIList<FACE*> FACES_BEFORE;
- DLIList<FACE*> FACES_AFTER;
- AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_BEFORE );
+ new_body_list.append( new_body_ptr );
+ }
+ }
- FACE_list.reset();
- for( j=FACE_list.size(); j--; )
- {
- // Get the FACE to imprint to
- FACE_ptr = FACE_list.get_and_step();
+ // Free the memory allocated when copying edges
+ for( i=0; i<EDGE_list.size(); i++ )
+ {
+ copied_EDGE_ptr = EDGE_list.get_and_step();
+ api_delent( copied_EDGE_ptr );
+ }
- if( imprint( BODY_ptr, FACE_ptr, EDGE_ptr ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to imprint EDGE to FACE\n" );
- continue;
- }
+ return CUBIT_SUCCESS;
+}
- // Check against an assumption that if invalid, will
- // cause a crash. The assumption is that the imprinted
- // FACE_ptr will remain valid after each imprint.
- FACES_AFTER.clean_out();
- AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_AFTER );
- if( !FACES_AFTER.is_in_list( FACE_ptr ) )
- {
- PRINT_ERROR( "serious problem in imprint - an imprinted surface disappeared!\n"
- " Model restored - operation aborted\n" );
- return CUBIT_FAILURE;
- }
+// Imprint EDGEs to select FACEs. FACEs must be from same BODY. Input FACEs
+// are modified but EDGEs are not.
+CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
+ DLIList<FACE*> &FACE_list,
+ DLIList<EDGE*> &EDGE_list ) const
+{
+ // Imprint the edges to the surfaces on this body
+ outcome result;
+ EDGE *EDGE_ptr;
+ FACE *FACE_ptr;
+ EDGE_list.reset();
+ FACE_list.reset();
+ int i, j;
+ for( i=EDGE_list.size(); i--; )
+ {
+ // Imprint this edge selectively to the given faces on this body
+ EDGE_ptr = EDGE_list.get_and_step();
- }
- // End of looping over FACES
+ // Track the existing FACEs before imprinting this BODY with the edge.
+ // Needed so we know which new surfaces result from the imprint. These
+ // new surfaces will need to be imprinted with subsequent edges.
+ DLIList<FACE*> FACES_BEFORE;
+ DLIList<FACE*> FACES_AFTER;
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_BEFORE );
- // Find which new surfaces were created - add these to the
- // FACE_list so that additional edges will imprint
- // on these as well.
- DLIList<FACE*> new_FACES;
- FACE* after_FACE_ptr;
- for( j=FACES_AFTER.size(); j--; )
- {
- after_FACE_ptr = FACES_AFTER.get_and_step();
+ FACE_list.reset();
+ for( j=FACE_list.size(); j--; )
+ {
+ // Get the FACE to imprint to
+ FACE_ptr = FACE_list.get_and_step();
- if( !FACES_BEFORE.is_in_list( after_FACE_ptr ) )
- new_FACES.append(after_FACE_ptr);
- }
- FACE_list += new_FACES;
- }
+ if( imprint( BODY_ptr, FACE_ptr, EDGE_ptr ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to imprint EDGE to FACE\n" );
+ continue;
+ }
- return CUBIT_SUCCESS;
- }
+ // Check against an assumption that if invalid, will
+ // cause a crash. The assumption is that the imprinted
+ // FACE_ptr will remain valid after each imprint.
+ FACES_AFTER.clean_out();
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_AFTER );
+ if( !FACES_AFTER.is_in_list( FACE_ptr ) )
+ {
+ PRINT_ERROR( "serious problem in imprint - an imprinted surface disappeared!\n"
+ " Model restored - operation aborted\n" );
+ return CUBIT_FAILURE;
+ }
- CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
- FACE *FACE_ptr,
- EDGE *EDGE_ptr ) const
- {
- outcome result;
+ }
+ // End of looping over FACES
- BODY* tbody = NULL;
- BODY* bbody = NULL; // Blank body
- FACE* bface = NULL; // Blank face
- surface* tsurf = NULL; // Tool surface
- EDGE* edge = NULL;
+ // Find which new surfaces were created - add these to the
+ // FACE_list so that additional edges will imprint
+ // on these as well.
+ DLIList<FACE*> new_FACES;
+ FACE* after_FACE_ptr;
+ for( j=FACES_AFTER.size(); j--; )
+ {
+ after_FACE_ptr = FACES_AFTER.get_and_step();
- //EXCEPTION_TRY
+ if( !FACES_BEFORE.is_in_list( after_FACE_ptr ) )
+ new_FACES.append(after_FACE_ptr);
+ }
+ FACE_list += new_FACES;
+ }
- bbody = BODY_ptr;
- bface = FACE_ptr;
- edge = EDGE_ptr;
+ return CUBIT_SUCCESS;
+}
- // Get the geometry of the blank face.
- surface const& bsurf = bface->geometry()->equation();
+CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
+ FACE *FACE_ptr,
+ EDGE *EDGE_ptr ) const
+{
+ outcome result;
- // Create an empty tool body
- tbody = ACIS_NEW BODY( (LUMP*) NULL );
+ BODY* tbody = NULL;
+ BODY* bbody = NULL; // Blank body
+ FACE* bface = NULL; // Blank face
+ surface* tsurf = NULL; // Tool surface
+ EDGE* edge = NULL;
- // Create the tool body which consists of a single face
- // with a "cross surface" geometric support and no loops.
- const curve &temp_cur = edge->geometry()->equation();
- SPAinterval cur_range = temp_cur.param_range();
- SPAinterval edge_range = edge->param_range();
- if (edge->sense() == REVERSED)
- edge_range = -edge_range;
- if (edge_range == cur_range)
- tsurf = cross_surface( edge->geometry()->equation(),
- bsurf, *(pcurve*) NULL_REF);
- else
- {
- // Create using a subsetted copy of the curve
- curve* subset_cur = temp_cur.subset(edge_range&cur_range);
- tsurf = cross_surface( *subset_cur, bsurf, *(pcurve*) NULL_REF);
- ACIS_DELETE subset_cur;
- }
- if( !tsurf )
- {
- PRINT_ERROR( "Unable to make imprint surface on body\n" );
- return CUBIT_FAILURE;
- }
- FACE* tface = ACIS_NEW FACE( NULL, NULL, make_surface( *tsurf ), FORWARD );
- ACIS_DELETE tsurf; // SRS Added 10-29-99
- tbody->set_lump( ACIS_NEW LUMP( ACIS_NEW SHELL( tface, NULL, NULL ), NULL ) );
+ //EXCEPTION_TRY
- // Now, imprint the two bodies and throw away the tool body. The
- // resultant blank body will have the edge imprinted on the
- // selected face.
- EDGE* ssi_edges[1];
- FACE* tfaces[1];
- FACE* bfaces[1];
+ bbody = BODY_ptr;
+ bface = FACE_ptr;
+ edge = EDGE_ptr;
- ssi_edges[0] = edge;
- tfaces[0] = tface;
- bfaces[0] = bface;
+ // Get the geometry of the blank face.
+ surface const& bsurf = bface->geometry()->equation();
- result = api_boolean_start( tbody, bbody );
+ // Create an empty tool body
+ tbody = ACIS_NEW BODY( (LUMP*) NULL );
- if( result.ok() )
- {
- // If the edge is known to lie on the face, some expensive
- // checking can be ommited by changing the last argument from
- // TRUE to FALSE.
- result = api_update_intersection( tface, *(SPAtransf *)NULL_REF, bface,
- *(SPAtransf *)NULL_REF, 1, ssi_edges, TRUE);
+ // Create the tool body which consists of a single face
+ // with a "cross surface" geometric support and no loops.
+ const curve &temp_cur = edge->geometry()->equation();
+ SPAinterval cur_range = temp_cur.param_range();
+ SPAinterval edge_range = edge->param_range();
+ if (edge->sense() == REVERSED)
+ edge_range = -edge_range;
+ if (edge_range == cur_range)
+ tsurf = cross_surface( edge->geometry()->equation(),
+ bsurf, *(pcurve*) NULL_REF);
+ else
+ {
+ // Create using a subsetted copy of the curve
+ curve* subset_cur = temp_cur.subset(edge_range&cur_range);
+ tsurf = cross_surface( *subset_cur, bsurf, *(pcurve*) NULL_REF);
+ ACIS_DELETE subset_cur;
+ }
+ if( !tsurf )
+ {
+ PRINT_ERROR( "Unable to make imprint surface on body\n" );
+ return CUBIT_FAILURE;
+ }
+ FACE* tface = ACIS_NEW FACE( NULL, NULL, make_surface( *tsurf ), FORWARD );
+ ACIS_DELETE tsurf; // SRS Added 10-29-99
+ tbody->set_lump( ACIS_NEW LUMP( ACIS_NEW SHELL( tface, NULL, NULL ), NULL ) );
- if( result.ok() )
- {
- result = api_selectively_intersect( 1, tfaces, bfaces );
- if( result.ok() )
- {
- result = api_imprint_complete( tbody, bbody );
- if( !result.ok() )
- {
- PRINT_ERROR( "problem in completing imprint for curve on surface\n" );
- AcisQueryEngine::instance()->ACIS_API_error(result);
- api_delent( tbody );
- return CUBIT_FAILURE;
- }
- }
- else
- {
- PRINT_ERROR( "problem in selective intersect for curve on surface\n" );
- AcisQueryEngine::instance()->ACIS_API_error(result);
- api_delent( tbody );
- return CUBIT_FAILURE;
- }
- }
- else if( result.error_number()!=200 && result.error_number()!=615
- && result.error_number()!=715 )
- {
- // Error 200 can occur when the imprint does nothing (curve that's
- // a surface boundary, curve away from surface). Errors 615/715 can occur
- // when imprinting a remnant of the same FACE again with the same curve.
- // The orignal FACE_ptr remains after an imprint - it lives as one
- // of the remnants. Then, when we attempt to imprint the other pieces
- // with the same curves, we are getting error 715. The same error
- // can occur when trying to use one of the surfaces own edges to
- // imprint with. This has been reported to Spatial and logged as r6294.
- // It's not fatal so for now we ignore it.
+ // Now, imprint the two bodies and throw away the tool body. The
+ // resultant blank body will have the edge imprinted on the
+ // selected face.
+ EDGE* ssi_edges[1];
+ FACE* tfaces[1];
+ FACE* bfaces[1];
- // We get these all the time, and they don't seem to hurt us.
- api_delent( tbody );
- return CUBIT_SUCCESS;
- }
- }
- else
- {
- PRINT_ERROR( "problem starting boolean for curve on surface\n" );
- AcisQueryEngine::instance()->ACIS_API_error(result);
- api_delent( tbody );
- return CUBIT_FAILURE;
- }
+ ssi_edges[0] = edge;
+ tfaces[0] = tface;
+ bfaces[0] = bface;
- //EXCEPTION_CATCH(TRUE)
+ result = api_boolean_start( tbody, bbody );
- // Remove temporary objects
- api_delent( tbody );
+ if( result.ok() )
+ {
+ // If the edge is known to lie on the face, some expensive
+ // checking can be ommited by changing the last argument from
+ // TRUE to FALSE.
+ result = api_update_intersection( tface, *(SPAtransf *)NULL_REF, bface,
+ *(SPAtransf *)NULL_REF, 1, ssi_edges, TRUE);
- //EXCEPTION_END
+ if( result.ok() )
+ {
+ result = api_selectively_intersect( 1, tfaces, bfaces );
+ if( result.ok() )
+ {
+ result = api_imprint_complete( tbody, bbody );
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "problem in completing imprint for curve on surface\n" );
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ api_delent( tbody );
+ return CUBIT_FAILURE;
+ }
+ }
+ else
+ {
+ PRINT_ERROR( "problem in selective intersect for curve on surface\n" );
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ api_delent( tbody );
+ return CUBIT_FAILURE;
+ }
+ }
+ else if( result.error_number()!=200 && result.error_number()!=615
+ && result.error_number()!=715 )
+ {
+ // Error 200 can occur when the imprint does nothing (curve that's
+ // a surface boundary, curve away from surface). Errors 615/715 can occur
+ // when imprinting a remnant of the same FACE again with the same curve.
+ // The orignal FACE_ptr remains after an imprint - it lives as one
+ // of the remnants. Then, when we attempt to imprint the other pieces
+ // with the same curves, we are getting error 715. The same error
+ // can occur when trying to use one of the surfaces own edges to
+ // imprint with. This has been reported to Spatial and logged as r6294.
+ // It's not fatal so for now we ignore it.
+ // We get these all the time, and they don't seem to hurt us.
+ api_delent( tbody );
return CUBIT_SUCCESS;
}
+ }
+ else
+ {
+ PRINT_ERROR( "problem starting boolean for curve on surface\n" );
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ api_delent( tbody );
+ return CUBIT_FAILURE;
+ }
- //- Imprints a list of Surfaces with list of Curves, sorted per
- //- Surface (ie., curve_lists_list is same length as surface_list).
- //- This version is more efficient than the general-purpose one
- //- above, as we know which curves to imprint with which surfaces.
- //- All input surfaces must be from the same body.
- CubitStatus AcisModifyEngine::imprint( DLIList<Surface*> &surface_list,
- DLIList<DLIList<Curve*>*> &curve_lists_list,
- BodySM*& new_body,
- bool keep_old_body ) const
- {
- // Calling code has already ensured that all the Surfaces are from the
- // same body
+ //EXCEPTION_CATCH(TRUE)
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
+ // Remove temporary objects
+ api_delent( tbody );
- SurfaceACIS* surf_ptr = dynamic_cast<SurfaceACIS*>(surface_list.get());
- if( surf_ptr == NULL )
- return CUBIT_FAILURE;
- FACE *FACE_ptr = surf_ptr->get_FACE_ptr();
- if (!FACE_ptr)
- {
- PRINT_ERROR("Invalid SurfaceACIS (no FACE ptr) at %s:%d\n",__FILE__,__LINE__);
- return CUBIT_FAILURE;
- }
- BODY *BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
- if( BODY_ptr == NULL )
- return CUBIT_FAILURE;
- BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
- if( body_ptr == NULL )
- return CUBIT_FAILURE;
+ //EXCEPTION_END
- int i, j;
- EDGE *EDGE_ptr;
- DLIList<DLIList<EDGE*>*> EDGE_lists_list;
- DLIList<EDGE*> *EDGE_list_ptr;
- DLIList<SurfaceACIS*> surf_ACIS_list;
+ return CUBIT_SUCCESS;
+}
- surface_list.reset();
- curve_lists_list.reset();
- for( i=surface_list.size(); i--; )
- {
- surf_ptr = dynamic_cast<SurfaceACIS*>(surface_list.get_and_step());
- if (!surf_ptr)
- {
- PRINT_ERROR("Non-ACIS surface at %s: %d\n",__FILE__,__LINE__);
- return CUBIT_FAILURE;
- }
- surf_ACIS_list.append( surf_ptr );
+//- Imprints a list of Surfaces with list of Curves, sorted per
+//- Surface (ie., curve_lists_list is same length as surface_list).
+//- This version is more efficient than the general-purpose one
+//- above, as we know which curves to imprint with which surfaces.
+//- All input surfaces must be from the same body.
+CubitStatus AcisModifyEngine::imprint( DLIList<Surface*> &surface_list,
+ DLIList<DLIList<Curve*>*> &curve_lists_list,
+ BodySM*& new_body,
+ bool keep_old_body ) const
+{
+ // Calling code has already ensured that all the Surfaces are from the
+ // same body
- // Make sure there is a FACE associated with this SurfaceACIS
- FACE_ptr = surf_ptr->get_FACE_ptr();
- if (!FACE_ptr)
- {
- PRINT_ERROR("Invalid SurfaceACIS (no FACE ptr) at %s:%d\n",__FILE__,__LINE__);
- return CUBIT_FAILURE;
- }
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
- EDGE_list_ptr = new DLIList<EDGE*>;
- EDGE_lists_list.append( EDGE_list_ptr );
+ SurfaceACIS* surf_ptr = dynamic_cast<SurfaceACIS*>(surface_list.get());
+ if( surf_ptr == NULL )
+ return CUBIT_FAILURE;
+ FACE *FACE_ptr = surf_ptr->get_FACE_ptr();
+ if (!FACE_ptr)
+ {
+ PRINT_ERROR("Invalid SurfaceACIS (no FACE ptr) at %s:%d\n",__FILE__,__LINE__);
+ return CUBIT_FAILURE;
+ }
+ BODY *BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
+ if( BODY_ptr == NULL )
+ return CUBIT_FAILURE;
+ BodySM *body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
+ if( body_ptr == NULL )
+ return CUBIT_FAILURE;
- DLIList<Curve*> *curve_list_ptr = curve_lists_list.get_and_step();
- curve_list_ptr->reset();
- for( j=curve_list_ptr->size(); j--; )
- {
- Curve *curve_ptr = curve_list_ptr->get_and_step();
- CurveACIS* curve_acis_ptr = dynamic_cast<CurveACIS*>(curve_ptr);
- if (!curve_acis_ptr)
- {
- PRINT_ERROR("Non-ACIS curve at %s: %d\n",__FILE__,__LINE__);
- return CUBIT_FAILURE;
- }
- EDGE_ptr = curve_acis_ptr->get_EDGE_ptr();
- if( EDGE_ptr == NULL )
- {
- PRINT_ERROR("Invalid CurveACIS (no EDGE ptr) at %s:%d\n",__FILE__,__LINE__);
- return CUBIT_FAILURE;
- }
- EDGE_list_ptr->append( EDGE_ptr );
- }
- }
+ int i, j;
+ EDGE *EDGE_ptr;
+ DLIList<DLIList<EDGE*>*> EDGE_lists_list;
+ DLIList<EDGE*> *EDGE_list_ptr;
+ DLIList<SurfaceACIS*> surf_ACIS_list;
- // Copy the BODY and get the corresponding FACEs on the copied BODY that need
- // to be imprinted
- DLIList<FACE*> copied_FACE_list;
- BODY *copied_BODY_ptr;
- if( get_copied_FACES_of_body( surf_ACIS_list, copied_FACE_list, copied_BODY_ptr )
- == CUBIT_FAILURE )
- {
- return CUBIT_FAILURE;
- }
+ surface_list.reset();
+ curve_lists_list.reset();
+ for( i=surface_list.size(); i--; )
+ {
+ surf_ptr = dynamic_cast<SurfaceACIS*>(surface_list.get_and_step());
+ if (!surf_ptr)
+ {
+ PRINT_ERROR("Non-ACIS surface at %s: %d\n",__FILE__,__LINE__);
+ return CUBIT_FAILURE;
+ }
+ surf_ACIS_list.append( surf_ptr );
- // Now cleanout the owner attributes from the copied BODY, if required
- if( delete_attribs )
- AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
+ // Make sure there is a FACE associated with this SurfaceACIS
+ FACE_ptr = surf_ptr->get_FACE_ptr();
+ if (!FACE_ptr)
+ {
+ PRINT_ERROR("Invalid SurfaceACIS (no FACE ptr) at %s:%d\n",__FILE__,__LINE__);
+ return CUBIT_FAILURE;
+ }
- // Imprint the temporary EDGEs to the FACEs
- if( imprint( copied_BODY_ptr, copied_FACE_list, EDGE_lists_list ) == CUBIT_FAILURE )
- {
- api_delent( copied_BODY_ptr );
- while( EDGE_lists_list.size() ) delete EDGE_lists_list.pop();
- return CUBIT_FAILURE;
- }
- DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
- new_body = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr, false);
+ EDGE_list_ptr = new DLIList<EDGE*>;
+ EDGE_lists_list.append( EDGE_list_ptr );
- // Add a imprint feature to the topo edges
- for (int edge_count = new_edges.size(); edge_count-- && new_body; )
- {
- CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
- new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
- delete tmp_attrib;
- }
+ DLIList<Curve*> *curve_list_ptr = curve_lists_list.get_and_step();
+ curve_list_ptr->reset();
+ for( j=curve_list_ptr->size(); j--; )
+ {
+ Curve *curve_ptr = curve_list_ptr->get_and_step();
+ CurveACIS* curve_acis_ptr = dynamic_cast<CurveACIS*>(curve_ptr);
+ if (!curve_acis_ptr)
+ {
+ PRINT_ERROR("Non-ACIS curve at %s: %d\n",__FILE__,__LINE__);
+ return CUBIT_FAILURE;
+ }
+ EDGE_ptr = curve_acis_ptr->get_EDGE_ptr();
+ if( EDGE_ptr == NULL )
+ {
+ PRINT_ERROR("Invalid CurveACIS (no EDGE ptr) at %s:%d\n",__FILE__,__LINE__);
+ return CUBIT_FAILURE;
+ }
+ EDGE_list_ptr->append( EDGE_ptr );
+ }
+ }
- // Free memory allocated in EDGE_lists_list
- while( EDGE_lists_list.size() ) delete EDGE_lists_list.pop();
+ // Copy the BODY and get the corresponding FACEs on the copied BODY that need
+ // to be imprinted
+ DLIList<FACE*> copied_FACE_list;
+ BODY *copied_BODY_ptr;
+ if( get_copied_FACES_of_body( surf_ACIS_list, copied_FACE_list, copied_BODY_ptr )
+ == CUBIT_FAILURE )
+ {
+ return CUBIT_FAILURE;
+ }
- return new_body ? CUBIT_SUCCESS : CUBIT_FAILURE;
- }
+ // Now cleanout the owner attributes from the copied BODY, if required
+ if( delete_attribs )
+ AcisQueryEngine::instance()->remove_cubit_owner_attrib_in_BODY(copied_BODY_ptr);
- DLIList<EDGE*> AcisModifyEngine::find_new_EDGES(BODY *copied_BODY_ptr)
+ // Imprint the temporary EDGEs to the FACEs
+ if( imprint( copied_BODY_ptr, copied_FACE_list, EDGE_lists_list ) == CUBIT_FAILURE )
+ {
+ api_delent( copied_BODY_ptr );
+ while( EDGE_lists_list.size() ) delete EDGE_lists_list.pop();
+ return CUBIT_FAILURE;
+ }
+ DLIList<EDGE*> new_edges = AcisModifyEngine::instance()->find_new_EDGES(copied_BODY_ptr);
+ new_body = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr, false);
+
+ // Add a imprint feature to the topo edges
+ for (int edge_count = new_edges.size(); edge_count-- && new_body; )
+ {
+ CubitSimpleAttrib *tmp_attrib = new CubitSimpleAttrib( "SOURCE_FEATURE", "IMPRINT" );
+ new ATTRIB_SNL_SIMPLE( new_edges[edge_count], tmp_attrib );
+ delete tmp_attrib;
+ }
+
+ // Free memory allocated in EDGE_lists_list
+ while( EDGE_lists_list.size() ) delete EDGE_lists_list.pop();
+
+ return new_body ? CUBIT_SUCCESS : CUBIT_FAILURE;
+}
+
+DLIList<EDGE*> AcisModifyEngine::find_new_EDGES(BODY *copied_BODY_ptr)
+{
+ DLIList<EDGE*> return_list;
+ ENTITY_LIST edge_list;
+ api_get_edges(copied_BODY_ptr, edge_list);
+ AcisBridge *ab_edge_ptr = NULL;
+ for(int i=0; i<edge_list.count(); i++)
{
- DLIList<EDGE*> return_list;
- ENTITY_LIST edge_list;
- api_get_edges(copied_BODY_ptr, edge_list);
- AcisBridge *ab_edge_ptr = NULL;
- for(int i=0; i<edge_list.count(); i++)
- {
- ab_edge_ptr = ATTRIB_CUBIT_OWNER::cubit_owner( edge_list[i] );
- if( !ab_edge_ptr )
- {
- return_list.append((EDGE*)edge_list[i]);
- //AcisDrawTool::instance()->draw_EDGE( (EDGE*)edge_list[i], CUBIT_BLUE );
- }
- }
- // GfxDebug::flush();
- return return_list;
+ ab_edge_ptr = ATTRIB_CUBIT_OWNER::cubit_owner( edge_list[i] );
+ if( !ab_edge_ptr )
+ {
+ return_list.append((EDGE*)edge_list[i]);
+ //AcisDrawTool::instance()->draw_EDGE( (EDGE*)edge_list[i], CUBIT_BLUE );
+ }
}
+ // GfxDebug::flush();
+ return return_list;
+}
- // This version is more efficient if it is known exactly which EDGEs
- // need to be imprinted with which FACEs (ie., it does not attempt to
- // imprint all input EDGEs to all input FACEs - only those in corresponding
- // list positions)
- CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
- DLIList<FACE*> &FACE_list,
- DLIList<DLIList<EDGE*>*> &EDGE_lists_list ) const
- {
- // Imprint the edges to the surfaces on this body
- outcome result;
- FACE *FACE_ptr = 0;
- EDGE *EDGE_ptr = 0;
+// This version is more efficient if it is known exactly which EDGEs
+// need to be imprinted with which FACEs (ie., it does not attempt to
+// imprint all input EDGEs to all input FACEs - only those in corresponding
+// list positions)
+CubitStatus AcisModifyEngine::imprint( BODY *BODY_ptr,
+ DLIList<FACE*> &FACE_list,
+ DLIList<DLIList<EDGE*>*> &EDGE_lists_list ) const
+{
+ // Imprint the edges to the surfaces on this body
+ outcome result;
+ FACE *FACE_ptr = 0;
+ EDGE *EDGE_ptr = 0;
- int i, j, k, m;
+ int i, j, k, m;
- DLIList<EDGE*> *EDGE_list_ptr;
- EDGE_lists_list.reset();
- FACE_list.reset();
- for( i=EDGE_lists_list.size(); i--; )
- {
- EDGE_list_ptr = EDGE_lists_list.get_and_step();
- FACE_ptr = FACE_list.get_and_step();
+ DLIList<EDGE*> *EDGE_list_ptr;
+ EDGE_lists_list.reset();
+ FACE_list.reset();
+ for( i=EDGE_lists_list.size(); i--; )
+ {
+ EDGE_list_ptr = EDGE_lists_list.get_and_step();
+ FACE_ptr = FACE_list.get_and_step();
- DLIList<FACE*> temp_FACE_list;
- temp_FACE_list.append( FACE_ptr );
+ DLIList<FACE*> temp_FACE_list;
+ temp_FACE_list.append( FACE_ptr );
- EDGE_list_ptr->reset();
- for( j=EDGE_list_ptr->size(); j--; )
- {
- // Imprint this edge list selectively to the current FACE
- EDGE_ptr = EDGE_list_ptr->get_and_step();
+ EDGE_list_ptr->reset();
+ for( j=EDGE_list_ptr->size(); j--; )
+ {
+ // Imprint this edge list selectively to the current FACE
+ EDGE_ptr = EDGE_list_ptr->get_and_step();
- // Track the existing FACEs before imprinting this BODY with the edge.
- // Needed so we know which new surfaces result from the imprint. These
- // new surfaces will need to be imprinted with subsequent edges.
- DLIList<FACE*> FACES_BEFORE;
- DLIList<FACE*> FACES_AFTER;
+ // Track the existing FACEs before imprinting this BODY with the edge.
+ // Needed so we know which new surfaces result from the imprint. These
+ // new surfaces will need to be imprinted with subsequent edges.
+ DLIList<FACE*> FACES_BEFORE;
+ DLIList<FACE*> FACES_AFTER;
- temp_FACE_list.reset();
- for( k=0; k<temp_FACE_list.size(); k++ )
- {
- FACE_ptr = temp_FACE_list.get_and_step();
+ temp_FACE_list.reset();
+ for( k=0; k<temp_FACE_list.size(); k++ )
+ {
+ FACE_ptr = temp_FACE_list.get_and_step();
- FACES_BEFORE.clean_out();
- AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_BEFORE );
+ FACES_BEFORE.clean_out();
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_BEFORE );
- if( imprint( BODY_ptr, FACE_ptr, EDGE_ptr ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to imprint EDGE to FACE\n" );
- continue;
- }
+ if( imprint( BODY_ptr, FACE_ptr, EDGE_ptr ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to imprint EDGE to FACE\n" );
+ continue;
+ }
- // Check against an assumption that if invalid, will
- // cause a crash. The assumption is that the imprinted
- // FACE_ptr will remain valid after each imprint.
- FACES_AFTER.clean_out();
- AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_AFTER );
- if( !FACES_AFTER.is_in_list( FACE_ptr ) )
- {
- PRINT_ERROR( "serious problem in imprint - an imprinted surface disappeared!\n"
- " Model restored - operation aborted\n" );
- return CUBIT_FAILURE;
- }
+ // Check against an assumption that if invalid, will
+ // cause a crash. The assumption is that the imprinted
+ // FACE_ptr will remain valid after each imprint.
+ FACES_AFTER.clean_out();
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY *)BODY_ptr, FACES_AFTER );
+ if( !FACES_AFTER.is_in_list( FACE_ptr ) )
+ {
+ PRINT_ERROR( "serious problem in imprint - an imprinted surface disappeared!\n"
+ " Model restored - operation aborted\n" );
+ return CUBIT_FAILURE;
+ }
- // Find which new surfaces were created - add these to the
- // temp_FACE_list so that additional edges will imprint
- // on these as well.
- DLIList<FACE*> new_FACES;
- FACE* after_FACE_ptr;
- for( m=FACES_AFTER.size(); m--; )
- {
- after_FACE_ptr = FACES_AFTER.get_and_step();
+ // Find which new surfaces were created - add these to the
+ // temp_FACE_list so that additional edges will imprint
+ // on these as well.
+ DLIList<FACE*> new_FACES;
+ FACE* after_FACE_ptr;
+ for( m=FACES_AFTER.size(); m--; )
+ {
+ after_FACE_ptr = FACES_AFTER.get_and_step();
- if( !FACES_BEFORE.is_in_list( after_FACE_ptr ) )
- new_FACES.append(after_FACE_ptr);
- }
- temp_FACE_list += new_FACES;
+ if( !FACES_BEFORE.is_in_list( after_FACE_ptr ) )
+ new_FACES.append(after_FACE_ptr);
+ }
+ temp_FACE_list += new_FACES;
- // Set list back to correct location
- temp_FACE_list.move_to( FACE_ptr );
- temp_FACE_list.step();
- } // End of looping over temp_FACE_list
- }
- }
- return CUBIT_SUCCESS;
+ // Set list back to correct location
+ temp_FACE_list.move_to( FACE_ptr );
+ temp_FACE_list.step();
+ } // End of looping over temp_FACE_list
}
+ }
+ return CUBIT_SUCCESS;
+}
- // Imprints locations to bodies (for splitting curves or putting hardpoints
- // on surfaces).
- CubitStatus AcisModifyEngine::imprint( DLIList<BodySM*> &body_list,
- DLIList<CubitVector*> &vector_list,
- DLIList<BodySM*>& new_body_list,
- bool keep_old_body,
- DLIList<TopologyBridge*> *new_tbs,
- DLIList<TopologyBridge*> *att_tbs ) const
- {
- // Until Spatial fixes imprinting with vertices, implement a hack
- // (Steve Storm, Caterpillar Inc.)
- int i, j, k;
- outcome result;
- double tol = 1e-3;
- //CubitStatus status = CUBIT_SUCCESS;
+// Imprints locations to bodies (for splitting curves or putting hardpoints
+// on surfaces).
+CubitStatus AcisModifyEngine::imprint( DLIList<BodySM*> &body_list,
+ DLIList<CubitVector*> &vector_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ DLIList<TopologyBridge*> *new_tbs,
+ DLIList<TopologyBridge*> *att_tbs ) const
+{
+ // Until Spatial fixes imprinting with vertices, implement a hack
+ // (Steve Storm, Caterpillar Inc.)
+ int i, j, k;
+ outcome result;
+ double tol = 1e-3;
+ //CubitStatus status = CUBIT_SUCCESS;
- CubitVector* vector_ptr;
- BodySM *body_ptr;
+ CubitVector* vector_ptr;
+ BodySM *body_ptr;
- VERTEX *VERTEX_ptr;
- EDGE *EDGE_ptr;
- FACE *FACE_ptr;
+ VERTEX *VERTEX_ptr;
+ EDGE *EDGE_ptr;
+ FACE *FACE_ptr;
- BODY *BODY_ptr;
- BODY *copied_BODY_ptr;
+ BODY *BODY_ptr;
+ BODY *copied_BODY_ptr;
- //CubitVector vertex_coords;
+ //CubitVector vertex_coords;
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old_body);
- // Set an option for imprinting
- api_set_int_option("all_free_edges", TRUE );
+ // Set an option for imprinting
+ api_set_int_option("all_free_edges", TRUE );
- // new_ENTITIES will hold new entities that were created by
- // the imprint operation. att_ENTITIES will hold entities
- // from the original bodies that had composite attributes
- // on them. At the end we will compare the new entities
- // with the ones that had attributes and if we find matches
- // we will put a composite attribute on the new entity.
- // This is how we are handling the imprinting of bodies
- // with composites.
- DLIList<ENTITY*> new_ENTITIES;
- DLIList<ENTITY*> att_ENTITIES;
+ // new_ENTITIES will hold new entities that were created by
+ // the imprint operation. att_ENTITIES will hold entities
+ // from the original bodies that had composite attributes
+ // on them. At the end we will compare the new entities
+ // with the ones that had attributes and if we find matches
+ // we will put a composite attribute on the new entity.
+ // This is how we are handling the imprinting of bodies
+ // with composites.
+ DLIList<ENTITY*> new_ENTITIES;
+ DLIList<ENTITY*> att_ENTITIES;
- body_list.reset();
- for( i=0; i<body_list.size(); i++ )
- {
- body_ptr = body_list.get_and_step();
+ body_list.reset();
+ for( i=0; i<body_list.size(); i++ )
+ {
+ body_ptr = body_list.get_and_step();
- BODY_ptr = AcisQueryEngine::get_BODY( body_ptr );
- if( BODY_ptr == NULL )
- return CUBIT_FAILURE;
+ BODY_ptr = AcisQueryEngine::get_BODY( body_ptr );
+ if( BODY_ptr == NULL )
+ return CUBIT_FAILURE;
- // Copy the body before working with it
- copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
+ // Copy the body before working with it
+ copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
- // Get all the vertices of the BODY
- DLIList<VERTEX*> VERTEX_list;
- AcisQueryEngine::instance()->get_VERTICEs( (ENTITY*)BODY_ptr, VERTEX_list );
+ // Get all the vertices of the BODY
+ DLIList<VERTEX*> VERTEX_list;
+ AcisQueryEngine::instance()->get_VERTICEs( (ENTITY*)BODY_ptr, VERTEX_list );
- // Get all the FACES of the *original* BODY
- DLIList<FACE*> FACE_list;
- AcisQueryEngine::instance()->get_FACEs( (ENTITY*)BODY_ptr, FACE_list );
+ // Get all the FACES of the *original* BODY
+ DLIList<FACE*> FACE_list;
+ AcisQueryEngine::instance()->get_FACEs( (ENTITY*)BODY_ptr, FACE_list );
- // Loop through the passed-in locations, first checking for coincidence
- // w/vertices, then if on curves, then on faces.
- vector_list.reset();
- for( j=0; j<vector_list.size(); j++ )
- {
- vector_ptr = vector_list.get_and_step();
- SPAposition test_point( vector_ptr->x(), vector_ptr->y(), vector_ptr->z() );
+ // Loop through the passed-in locations, first checking for coincidence
+ // w/vertices, then if on curves, then on faces.
+ vector_list.reset();
+ for( j=0; j<vector_list.size(); j++ )
+ {
+ vector_ptr = vector_list.get_and_step();
+ SPAposition test_point( vector_ptr->x(), vector_ptr->y(), vector_ptr->z() );
- CubitBoolean on_vertex = CUBIT_FALSE;
- VERTEX_list.reset();
- for( k=0; k<VERTEX_list.size(); k++ )
- {
- VERTEX_ptr = VERTEX_list.get_and_step();
+ CubitBoolean on_vertex = CUBIT_FALSE;
+ VERTEX_list.reset();
+ for( k=0; k<VERTEX_list.size(); k++ )
+ {
+ VERTEX_ptr = VERTEX_list.get_and_step();
- SPAposition VERTEX_coords = VERTEX_ptr->geometry()->coords();
+ SPAposition VERTEX_coords = VERTEX_ptr->geometry()->coords();
- if (( fabs(VERTEX_coords.x() - vector_ptr->x()) < tol) &&
- ( fabs(VERTEX_coords.y() - vector_ptr->y()) < tol) &&
- ( fabs(VERTEX_coords.z() - vector_ptr->z()) < tol))
- {
- on_vertex = CUBIT_TRUE;
- break; // Skip - coincident with a vertex
- }
- }
+ if (( fabs(VERTEX_coords.x() - vector_ptr->x()) < tol) &&
+ ( fabs(VERTEX_coords.y() - vector_ptr->y()) < tol) &&
+ ( fabs(VERTEX_coords.z() - vector_ptr->z()) < tol))
+ {
+ on_vertex = CUBIT_TRUE;
+ break; // Skip - coincident with a vertex
+ }
+ }
- if( on_vertex )
- continue; // No imprinting necessary
+ if( on_vertex )
+ continue; // No imprinting necessary
- // Get all the EDGES of the copied BODY
- DLIList<EDGE*> EDGE_list;
- AcisQueryEngine::instance()->get_EDGEs( (ENTITY*)copied_BODY_ptr, EDGE_list );
+ // Get all the EDGES of the copied BODY
+ DLIList<EDGE*> EDGE_list;
+ AcisQueryEngine::instance()->get_EDGEs( (ENTITY*)copied_BODY_ptr, EDGE_list );
- // Check the EDGES
- CubitBoolean on_edge = CUBIT_FALSE;
- EDGE_list.reset();
- for( k=0; k<EDGE_list.size(); k++ )
- {
- EDGE_ptr = EDGE_list.get_and_step();
+ // Check the EDGES
+ CubitBoolean on_edge = CUBIT_FALSE;
+ EDGE_list.reset();
+ for( k=0; k<EDGE_list.size(); k++ )
+ {
+ EDGE_ptr = EDGE_list.get_and_step();
- if (EDGE_ptr->geometry() == NULL)
- continue; // Check next edge
+ if (EDGE_ptr->geometry() == NULL)
+ continue; // Check next edge
- //const curve* acis_curve = &EDGE_ptr->geometry()->equation();
+ //const curve* acis_curve = &EDGE_ptr->geometry()->equation();
- SPAtransf ftrans;
+ SPAtransf ftrans;
- point_edge_containment pe_rel;
+ point_edge_containment pe_rel;
- ENTITY *ENTITY_ptr = NULL;
- SPAparameter param;
+ ENTITY *ENTITY_ptr = NULL;
+ SPAparameter param;
- pe_rel = sg_point_in_edge( test_point, EDGE_ptr, ftrans, ENTITY_ptr, param );
+ pe_rel = sg_point_in_edge( test_point, EDGE_ptr, ftrans, ENTITY_ptr, param );
- if( pe_rel == point_off_edge )
- continue; // Check next edge
- else if( pe_rel == point_on_edge )
- {
- on_edge = CUBIT_TRUE;
- VERTEX *new_vertex = ACIS_NEW VERTEX( ACIS_NEW APOINT( test_point) );
+ if( pe_rel == point_off_edge )
+ continue; // Check next edge
+ else if( pe_rel == point_on_edge )
+ {
+ on_edge = CUBIT_TRUE;
+ VERTEX *new_vertex = ACIS_NEW VERTEX( ACIS_NEW APOINT( test_point) );
- API_BEGIN;
- sg_split_edge_at_vertex( EDGE_ptr, new_vertex );
- API_END;
+ API_BEGIN;
+ sg_split_edge_at_vertex( EDGE_ptr, new_vertex );
+ API_END;
- if( !result.ok() && result.error_number()!=200 )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "problem imprinting curve onto volume\n");
- }
+ if( !result.ok() && result.error_number()!=200 )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "problem imprinting curve onto volume\n");
+ }
- break;
- }
- }
+ break;
+ }
+ }
- if( on_edge )
- continue; // Already imprinted onto the body - check next vertex
+ if( on_edge )
+ continue; // Already imprinted onto the body - check next vertex
- // Check the FACES
- FACE_list.reset();
- for( k=0; k<FACE_list.size(); k++ )
- {
- FACE_ptr = FACE_list.get_and_step();
+ // Check the FACES
+ FACE_list.reset();
+ for( k=0; k<FACE_list.size(); k++ )
+ {
+ FACE_ptr = FACE_list.get_and_step();
- if (FACE_ptr->geometry() == NULL)
- continue; // Check next face
+ if (FACE_ptr->geometry() == NULL)
+ continue; // Check next face
- SPAtransf ftrans;
+ SPAtransf ftrans;
- point_face_containment pf_rel = point_in_face( test_point, FACE_ptr, ftrans );
- if( pf_rel == point_outside_face )
- continue; // Check next face
- else if( pf_rel == point_inside_face )
- {
- // Create a short curve normal to the surface at the vertex and imprint it
- SPAunit_vector norm;
- norm = FACE_ptr->geometry()->equation().point_normal( test_point );
+ point_face_containment pf_rel = point_in_face( test_point, FACE_ptr, ftrans );
+ if( pf_rel == point_outside_face )
+ continue; // Check next face
+ else if( pf_rel == point_inside_face )
+ {
+ // Create a short curve normal to the surface at the vertex and imprint it
+ SPAunit_vector norm;
+ norm = FACE_ptr->geometry()->equation().point_normal( test_point );
- if ( FACE_ptr->sense() == REVERSED )
- norm = -norm;
+ if ( FACE_ptr->sense() == REVERSED )
+ norm = -norm;
- // Find the end point
- SPAposition end_point;
- end_point.set_x( test_point.x() + (tol * norm.x()) );
- end_point.set_y( test_point.y() + (tol * norm.y()) );
- end_point.set_z( test_point.z() + (tol * norm.z()) );
+ // Find the end point
+ SPAposition end_point;
+ end_point.set_x( test_point.x() + (tol * norm.x()) );
+ end_point.set_y( test_point.y() + (tol * norm.y()) );
+ end_point.set_z( test_point.z() + (tol * norm.z()) );
- // Create the curve
- EDGE* new_EDGE_ptr = NULL;
- result = api_mk_ed_line ( test_point, end_point, new_EDGE_ptr );
- if (!result.ok() || new_EDGE_ptr == NULL)
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_WARNING("Unable to make short normal curve for imprint operation\n" );
- continue;
- }
+ // Create the curve
+ EDGE* new_EDGE_ptr = NULL;
+ result = api_mk_ed_line ( test_point, end_point, new_EDGE_ptr );
+ if (!result.ok() || new_EDGE_ptr == NULL)
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_WARNING("Unable to make short normal curve for imprint operation\n" );
+ continue;
+ }
- // Create a wire from the short curve
- BODY *wire_BODY_ptr = NULL;
- result = api_make_ewire( 1, &new_EDGE_ptr, wire_BODY_ptr );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_WARNING( "Unable to make ACIS WIRE from short imprint curve\n" );
+ // Create a wire from the short curve
+ BODY *wire_BODY_ptr = NULL;
+ result = api_make_ewire( 1, &new_EDGE_ptr, wire_BODY_ptr );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_WARNING( "Unable to make ACIS WIRE from short imprint curve\n" );
- if( wire_BODY_ptr )
- api_delent( wire_BODY_ptr );
- else
- api_delent( new_EDGE_ptr );
- continue;
- }
+ if( wire_BODY_ptr )
+ api_delent( wire_BODY_ptr );
+ else
+ api_delent( new_EDGE_ptr );
+ continue;
+ }
- // Imprint the wire-body onto the BODY
- result = api_imprint( wire_BODY_ptr, copied_BODY_ptr );
+ // Imprint the wire-body onto the BODY
+ result = api_imprint( wire_BODY_ptr, copied_BODY_ptr );
- if( !result.ok() && result.error_number()!=200 )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "problem imprinting short curve onto volume\n");
- }
+ if( !result.ok() && result.error_number()!=200 )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "problem imprinting short curve onto volume\n");
+ }
- api_delent( wire_BODY_ptr );
+ api_delent( wire_BODY_ptr );
- break; // Done imprinting with this vertex
+ break; // Done imprinting with this vertex
- }
- else if( pf_rel == point_boundary_face )
- {
- PRINT_WARNING( "Algorithm error - point found on boundary of surface - please report this\n" );
- continue;
- }
- else if( pf_rel == point_unknown_face )
- continue; // Check next face
- }
- }
+ }
+ else if( pf_rel == point_boundary_face )
+ {
+ PRINT_WARNING( "Algorithm error - point found on boundary of surface - please report this\n" );
+ continue;
+ }
+ else if( pf_rel == point_unknown_face )
+ continue; // Check next face
+ }
+ }
- AcisModifyEngine::instance()->cleanup_slivers( copied_BODY_ptr );
+ AcisModifyEngine::instance()->cleanup_slivers( copied_BODY_ptr );
- // Get the new entities (just edges for now)
- // created by the imprint operation.
- DLIList<ENTITY*> cur_new_ENTITIES;
- if(copied_BODY_ptr && new_tbs)
- get_new_ENTITIES(copied_BODY_ptr, cur_new_ENTITIES);
+ // Get the new entities (just edges for now)
+ // created by the imprint operation.
+ DLIList<ENTITY*> cur_new_ENTITIES;
+ if(copied_BODY_ptr && new_tbs)
+ get_new_ENTITIES(copied_BODY_ptr, cur_new_ENTITIES);
- BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr,
- copied_BODY_ptr, keep_old_body, CUBIT_TRUE );
- if (new_body_ptr)
- {
- new_body_list.append(new_body_ptr);
+ BodySM* new_body_ptr = get_new_Body( body_ptr, BODY_ptr,
+ copied_BODY_ptr, keep_old_body, CUBIT_TRUE );
+ if (new_body_ptr)
+ {
+ new_body_list.append(new_body_ptr);
- // Add the new entities to the list we are
- // accumulating.
- if(new_tbs)
- new_ENTITIES += cur_new_ENTITIES;
+ // Add the new entities to the list we are
+ // accumulating.
+ if(new_tbs)
+ new_ENTITIES += cur_new_ENTITIES;
- // Get entities with composite attributes.
- if(copied_BODY_ptr && att_tbs)
- get_att_ENTITIES(copied_BODY_ptr, att_ENTITIES, "COMPOSITE_GEOM");
+ // Get entities with composite attributes.
+ if(copied_BODY_ptr && att_tbs)
+ get_att_ENTITIES(copied_BODY_ptr, att_ENTITIES, "COMPOSITE_GEOM");
- }
- else
- {
- // Get entities with composite attributes.
- if(att_tbs)
- get_att_ENTITIES(BODY_ptr, att_ENTITIES, "COMPOSITE_GEOM");
- }
+ }
+ else
+ {
+ // Get entities with composite attributes.
+ if(att_tbs)
+ get_att_ENTITIES(BODY_ptr, att_ENTITIES, "COMPOSITE_GEOM");
+ }
- }
+ }
- // Convert the new_ENTITIES/att_ENTITIES lists into
- // topology bridge lists.
- if(new_tbs)
- {
- for(i=new_ENTITIES.size(); i--;)
- {
- ENTITY *cur_ENT = new_ENTITIES.get_and_step();
- AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
- if(dynamic_cast<TopologyBridge*>(acis_bridge))
- new_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
- }
- }
- if(att_tbs)
- {
- for(i=att_ENTITIES.size(); i--;)
- {
- ENTITY *cur_ENT = att_ENTITIES.get_and_step();
- AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
- if(dynamic_cast<TopologyBridge*>(acis_bridge))
- att_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
- }
- }
+ // Convert the new_ENTITIES/att_ENTITIES lists into
+ // topology bridge lists.
+ if(new_tbs)
+ {
+ for(i=new_ENTITIES.size(); i--;)
+ {
+ ENTITY *cur_ENT = new_ENTITIES.get_and_step();
+ AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
+ if(dynamic_cast<TopologyBridge*>(acis_bridge))
+ new_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
+ }
+ }
+ if(att_tbs)
+ {
+ for(i=att_ENTITIES.size(); i--;)
+ {
+ ENTITY *cur_ENT = att_ENTITIES.get_and_step();
+ AcisBridge *acis_bridge = ATTRIB_CUBIT_OWNER::cubit_owner(cur_ENT);
+ if(dynamic_cast<TopologyBridge*>(acis_bridge))
+ att_tbs->append_unique(dynamic_cast<TopologyBridge*>(acis_bridge));
+ }
+ }
- api_set_int_option("all_free_edges", FALSE );
+ api_set_int_option("all_free_edges", FALSE );
- return CUBIT_SUCCESS;
+ return CUBIT_SUCCESS;
- // When Spatial gets vertex body to body imprinting working, you should be
- // able to replace all of the above code with this code.
+// When Spatial gets vertex body to body imprinting working, you should be
+// able to replace all of the above code with this code.
#if 0
- int i, j;
- outcome result;
- CubitStatus status = CUBIT_SUCCESS;
+ int i, j;
+ outcome result;
+ CubitStatus status = CUBIT_SUCCESS;
- RefVertex* ref_vertex_ptr;
- Body *body_ptr;
+ RefVertex* ref_vertex_ptr;
+ Body *body_ptr;
- BODY *BODY_ptr;
- BODY *copied_BODY_ptr;
+ BODY *BODY_ptr;
+ BODY *copied_BODY_ptr;
- CubitVector vertex_coords;
- BODY* vertex_BODY_ptr;
- DLIList<BODY*> vertex_BODY_list;
+ CubitVector vertex_coords;
+ BODY* vertex_BODY_ptr;
+ DLIList<BODY*> vertex_BODY_list;
- bool delete_attribs =
- (GeometryModifyTool::instance()->new_ids() || keep_old_body);
+ bool delete_attribs =
+ (GeometryModifyTool::instance()->new_ids() || keep_old_body);
- // Create a list of BODYs that consist of single points. These
- // will be used for imprinting onto the BODYs.
- vector_list.reset();
- SPAposition acis_position[1];
- for( i=0; i<vector_list.size(); i++ )
- {
- vector_ptr = vector_list.get_and_step();
+ // Create a list of BODYs that consist of single points. These
+ // will be used for imprinting onto the BODYs.
+ vector_list.reset();
+ SPAposition acis_position[1];
+ for( i=0; i<vector_list.size(); i++ )
+ {
+ vector_ptr = vector_list.get_and_step();
- acis_position[0].set_x( vector_ptr->x() );
- acis_position[0].set_y( vector_ptr->y() );
- acis_position[0].set_z( vector_ptr->z() );
+ acis_position[0].set_x( vector_ptr->x() );
+ acis_position[0].set_y( vector_ptr->y() );
+ acis_position[0].set_z( vector_ptr->z() );
- result = api_make_wire( NULL, 1, acis_position, vertex_BODY_ptr );
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "unable to make degenerate wire body from location %f, %f, %f; aborting\n",
- vector_ptr->x(), vector_ptr->y(), vector_ptr->z() );
- for( j=0; j<vertex_BODY_list.size(); j++ )
- api_delent( vertex_BODY_list.get_and_step() );
- return CUBIT_FAILURE;
- }
+ result = api_make_wire( NULL, 1, acis_position, vertex_BODY_ptr );
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "unable to make degenerate wire body from location %f, %f, %f; aborting\n",
+ vector_ptr->x(), vector_ptr->y(), vector_ptr->z() );
+ for( j=0; j<vertex_BODY_list.size(); j++ )
+ api_delent( vertex_BODY_list.get_and_step() );
+ return CUBIT_FAILURE;
+ }
- vertex_BODY_list.append( vertex_BODY_ptr );
- }
+ vertex_BODY_list.append( vertex_BODY_ptr );
+ }
- // Loop on bodies, imprinting each with all the vertex BODYs.
- for( i=0; i<body_list.size(); i++ )
- {
- body_ptr = body_list.get_and_step();
+ // Loop on bodies, imprinting each with all the vertex BODYs.
+ for( i=0; i<body_list.size(); i++ )
+ {
+ body_ptr = body_list.get_and_step();
- BODY_ptr = AcisQueryEngine::get_BODY( body_ptr );
- if( BODY_ptr == NULL )
- {
- //NOTE TO JS
- PRINT_ERROR( "Unable to get ACIS BODY from Body %d; aborting\n",
- body_ptr->id() );
- for( j=0; j<vertex_BODY_list.size(); j++ )
- api_delent( vertex_BODY_list.get_and_step() );
- return CUBIT_FAILURE;
- }
+ BODY_ptr = AcisQueryEngine::get_BODY( body_ptr );
+ if( BODY_ptr == NULL )
+ {
+//NOTE TO JS
+ PRINT_ERROR( "Unable to get ACIS BODY from Body %d; aborting\n",
+ body_ptr->id() );
+ for( j=0; j<vertex_BODY_list.size(); j++ )
+ api_delent( vertex_BODY_list.get_and_step() );
+ return CUBIT_FAILURE;
+ }
- // Copy the body before working with it
- copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
+ // Copy the body before working with it
+ copied_BODY_ptr = copy_BODY( BODY_ptr, delete_attribs );
- // Imprint the wire-bodies onto the BODY
- api_set_int_option("all_free_edges", TRUE );
- vertex_BODY_list.reset();
- vector_list.reset();
- for( i=0; i<vertex_BODY_list.size(); i++ )
- {
- vertex_BODY_ptr = vertex_BODY_list.get_and_step();
- vector_ptr = vector_list.get_and_step();
+ // Imprint the wire-bodies onto the BODY
+ api_set_int_option("all_free_edges", TRUE );
+ vertex_BODY_list.reset();
+ vector_list.reset();
+ for( i=0; i<vertex_BODY_list.size(); i++ )
+ {
+ vertex_BODY_ptr = vertex_BODY_list.get_and_step();
+ vector_ptr = vector_list.get_and_step();
- result = api_imprint( vertex_BODY_ptr, copied_BODY_ptr );
+ result = api_imprint( vertex_BODY_ptr, copied_BODY_ptr );
- if( !result.ok() && result.error_number()!=200 )
- {
- //NOTE to JS
- PRINT_ERROR( "problem imprinting location %f, %f, %f to body %d\n",
- vector_ptr->x(), vector_ptr->y(), vector_ptr->z(),
- body_ptr->id() );
- AcisQueryEngine::instance()->ACIS_API_error(result);
- status = CUBIT_FAILURE;
- }
- }
- api_set_int_option("all_free_edges", FALSE );
+ if( !result.ok() && result.error_number()!=200 )
+ {
+//NOTE to JS
+ PRINT_ERROR( "problem imprinting location %f, %f, %f to body %d\n",
+ vector_ptr->x(), vector_ptr->y(), vector_ptr->z(),
+ body_ptr->id() );
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ status = CUBIT_FAILURE;
+ }
+ }
+ api_set_int_option("all_free_edges", FALSE );
- Body* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
- keep_old_body, CUBIT_TRUE );
+ Body* new_body_ptr = get_new_Body( body_ptr, BODY_ptr, copied_BODY_ptr,
+ keep_old_body, CUBIT_TRUE );
- if( new_body_ptr!=NULL && new_body_ptr!=body_ptr )
- {
- //NOTE TO JS
- PRINT_INFO( "Created new body %d\n", new_body_ptr->id() );
- new_body_list.append( new_body_ptr );
- }
- else if( new_body_ptr!=NULL && new_body_ptr==body_ptr )
- {
- //NOTE TO JS
- PRINT_INFO( "Modified body %d\n", body_ptr->id() );
- }
- //NOTE TO JS
- else
- PRINT_WARNING( "Body %d was not modified\n", body_ptr->id() );
- }
+ if( new_body_ptr!=NULL && new_body_ptr!=body_ptr )
+ {
+//NOTE TO JS
+ PRINT_INFO( "Created new body %d\n", new_body_ptr->id() );
+ new_body_list.append( new_body_ptr );
+ }
+ else if( new_body_ptr!=NULL && new_body_ptr==body_ptr )
+ {
+//NOTE TO JS
+ PRINT_INFO( "Modified body %d\n", body_ptr->id() );
+ }
+//NOTE TO JS
+ else
+ PRINT_WARNING( "Body %d was not modified\n", body_ptr->id() );
+ }
- // Free memory
- for( i=0; i<vertex_BODY_list.size(); i++ )
- api_delent( vertex_BODY_list.get_and_step() );
+ // Free memory
+ for( i=0; i<vertex_BODY_list.size(); i++ )
+ api_delent( vertex_BODY_list.get_and_step() );
- return status;
+ return status;
#endif
- }
+}
- CubitStatus
- AcisModifyEngine::offset_curves( DLIList<Curve*>& ref_edge_list,
- DLIList<Curve*>& new_curves,
- double offset_distance,
- const CubitVector& offset_direction,
- int gap_type )
- {
- int i;
+CubitStatus
+AcisModifyEngine::offset_curves( DLIList<Curve*>& ref_edge_list,
+ DLIList<Curve*>& new_curves,
+ double offset_distance,
+ const CubitVector& offset_direction,
+ int gap_type )
+{
+ int i;
- Curve* ref_edge_ptr;
- EDGE* EDGE_ptr;
- outcome result;
+ Curve* ref_edge_ptr;
+ EDGE* EDGE_ptr;
+ outcome result;
- // If there's just one curve, and it's linear, all we can do is copy it and move it.
- // SRS Note (1-12-01) - this code should be moved up into GeometryTool...but, we
- // would need to be able to move a curve. When that capability exists move the
- // code.
+ // If there's just one curve, and it's linear, all we can do is copy it and move it.
+ // SRS Note (1-12-01) - this code should be moved up into GeometryTool...but, we
+ // would need to be able to move a curve. When that capability exists move the
+ // code.
- //CubitBoolean move_curve = CUBIT_FALSE;
+ //CubitBoolean move_curve = CUBIT_FALSE;
- if( ref_edge_list.size() == 1 && (offset_direction.x() || offset_direction.y() ||
- offset_direction.z()) )
- {
- ref_edge_ptr = ref_edge_list.get();
- if( AcisQueryEngine::instance()->is_curve_app_straight( ref_edge_ptr ) == CUBIT_TRUE )
- {
+ if( ref_edge_list.size() == 1 && (offset_direction.x() || offset_direction.y() ||
+ offset_direction.z()) )
+ {
+ ref_edge_ptr = ref_edge_list.get();
+ if( AcisQueryEngine::instance()->is_curve_app_straight( ref_edge_ptr ) == CUBIT_TRUE )
+ {
- EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge_ptr);
+ EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge_ptr);
- if( EDGE_ptr == NULL )
- return CUBIT_FAILURE;
+ if( EDGE_ptr == NULL )
+ return CUBIT_FAILURE;
- // Copy and move the EDGE
- EDGE* new_EDGE_ptr2 = copy_and_move_EDGE( EDGE_ptr, offset_direction,
- offset_distance );
+ // Copy and move the EDGE
+ EDGE* new_EDGE_ptr2 = copy_and_move_EDGE( EDGE_ptr, offset_direction,
+ offset_distance );
- Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( new_EDGE_ptr2 );
- new_curves.append(curve_ptr);
- return CUBIT_SUCCESS;
- }
- else
- {
- PRINT_WARNING( "Direction qualifier ignored - only valid for one straight curve\n" );
- }
- }
- else if( offset_direction.x() || offset_direction.y() || offset_direction.z() )
- {
- PRINT_WARNING( "Direction qualifier ignored - only valid for one straight curve\n" );
- }
+ Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( new_EDGE_ptr2 );
+ new_curves.append(curve_ptr);
+ return CUBIT_SUCCESS;
+ }
+ else
+ {
+ PRINT_WARNING( "Direction qualifier ignored - only valid for one straight curve\n" );
+ }
+ }
+ else if( offset_direction.x() || offset_direction.y() || offset_direction.z() )
+ {
+ PRINT_WARNING( "Direction qualifier ignored - only valid for one straight curve\n" );
+ }
- // Create a wire from the given EDGEs
+ // Create a wire from the given EDGEs
- // Offset the RefEdges
- DLIList<EDGE*> old_EDGE_list;
- if( AcisQueryEngine::instance()->get_EDGEs_of_Curves( ref_edge_list, old_EDGE_list )
- == CUBIT_FAILURE )
- return CUBIT_FAILURE;
+ // Offset the RefEdges
+ DLIList<EDGE*> old_EDGE_list;
+ if( AcisQueryEngine::instance()->get_EDGEs_of_Curves( ref_edge_list, old_EDGE_list )
+ == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
- DLIList<EDGE*> new_EDGE_list;
- if( offset_EDGES( old_EDGE_list, offset_distance, gap_type, new_EDGE_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to offset the curves\n" );
- return CUBIT_FAILURE;
- }
+ DLIList<EDGE*> new_EDGE_list;
+ if( offset_EDGES( old_EDGE_list, offset_distance, gap_type, new_EDGE_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to offset the curves\n" );
+ return CUBIT_FAILURE;
+ }
- // Make free curves from the offset EDGEs
- new_EDGE_list.reset();
- for( i=0; i<new_EDGE_list.size(); i++ )
- {
- EDGE_ptr = new_EDGE_list.get_and_step();
+ // Make free curves from the offset EDGEs
+ new_EDGE_list.reset();
+ for( i=0; i<new_EDGE_list.size(); i++ )
+ {
+ EDGE_ptr = new_EDGE_list.get_and_step();
- Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( EDGE_ptr );
- new_curves.append(curve_ptr);
- }
+ Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( EDGE_ptr );
+ new_curves.append(curve_ptr);
+ }
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
- Curve*
- AcisModifyEngine::trim_curve( Curve* trim_curve,
- const CubitVector& trim_vector,
- const CubitVector& keep_vector,
- bool keep_old )
- {
- //api_trim_curve(entity_with_ray &eray1, SPAposition* trim_pt, entity_with_ray *peray2);
- //The curve is trimmed to either a SPAposition or at its intersection with another curve. To trim
- //to a SPAposition, specify a SPAposition in trim_pt and NULL for eray2. The curve is trimmed to
- //the normal projection of the SPAposition onto the curve. To trim to the intersection with
- //another curve, specify NULL for trim_pt and an entity_with_ray for eray2. The curve
- //is trimmed to the intersection with the curve given in eray2 that is closest to the ray given
- //in eray2.
+Curve*
+AcisModifyEngine::trim_curve( Curve* trim_curve,
+ const CubitVector& trim_vector,
+ const CubitVector& keep_vector,
+ bool keep_old )
+{
+ //api_trim_curve(entity_with_ray &eray1, SPAposition* trim_pt, entity_with_ray *peray2);
+ //The curve is trimmed to either a SPAposition or at its intersection with another curve. To trim
+ //to a SPAposition, specify a SPAposition in trim_pt and NULL for eray2. The curve is trimmed to
+ //the normal projection of the SPAposition onto the curve. To trim to the intersection with
+ //another curve, specify NULL for trim_pt and an entity_with_ray for eray2. The curve
+ //is trimmed to the intersection with the curve given in eray2 that is closest to the ray given
+ //in eray2.
- EDGE* EDGE_ptr = AcisQueryEngine::get_EDGE( trim_curve );
- if( EDGE_ptr == NULL )
- return 0;
+ EDGE* EDGE_ptr = AcisQueryEngine::get_EDGE( trim_curve );
+ if( EDGE_ptr == NULL )
+ return 0;
- ENTITY_LIST edge_VERTS;
- api_get_vertices( EDGE_ptr, edge_VERTS );
- VERTEX *start_vertex = static_cast<VERTEX*>(edge_VERTS[0]);
- VERTEX *end_vertex = static_cast<VERTEX*>(edge_VERTS[1]);
- SPAposition s_vec = start_vertex->geometry()->coords();
- SPAposition e_vec = end_vertex->geometry()->coords();
- CubitVector s_vector( s_vec.x(), s_vec.y(), s_vec.z() );
- CubitVector e_vector( e_vec.x(), e_vec.y(), e_vec.z() );
+ ENTITY_LIST edge_VERTS;
+ api_get_vertices( EDGE_ptr, edge_VERTS );
+ VERTEX *start_vertex = static_cast<VERTEX*>(edge_VERTS[0]);
+ VERTEX *end_vertex = static_cast<VERTEX*>(edge_VERTS[1]);
+ SPAposition s_vec = start_vertex->geometry()->coords();
+ SPAposition e_vec = end_vertex->geometry()->coords();
+ CubitVector s_vector( s_vec.x(), s_vec.y(), s_vec.z() );
+ CubitVector e_vector( e_vec.x(), e_vec.y(), e_vec.z() );
- int start = 0, end = 0;
- if( keep_vector.distance_between( s_vector ) < 0.001 )
- start = 1;
- else if( keep_vector.distance_between( e_vector ) < 0.001 )
- end = 1;
+ int start = 0, end = 0;
+ if( keep_vector.distance_between( s_vector ) < 0.001 )
+ start = 1;
+ else if( keep_vector.distance_between( e_vector ) < 0.001 )
+ end = 1;
- if( start || end )
- {
- double trim_param = trim_curve->u_from_position( trim_vector );
- double start_param = trim_curve->start_param();
- double end_param = trim_curve->end_param();
+ if( start || end )
+ {
+ double trim_param = trim_curve->u_from_position( trim_vector );
+ double start_param = trim_curve->start_param();
+ double end_param = trim_curve->end_param();
- //if trim_param is not within start and end params, we are extending
- //and we don't need keep_vector
- bool within_u_param_range = true;
- if( start_param < end_param )
- {
- if( trim_param > end_param || trim_param < start_param )
- within_u_param_range = false;
- }
- else
- {
- if( trim_param > start_param || trim_param < end_param )
- within_u_param_range = false;
- }
+ //if trim_param is not within start and end params, we are extending
+ //and we don't need keep_vector
+ bool within_u_param_range = true;
+ if( start_param < end_param )
+ {
+ if( trim_param > end_param || trim_param < start_param )
+ within_u_param_range = false;
+ }
+ else
+ {
+ if( trim_param > start_param || trim_param < end_param )
+ within_u_param_range = false;
+ }
- if( within_u_param_range )
- {
- double keep_param;
- if( start )
- keep_param = start_param + .95*(trim_param-start_param);
- else
- keep_param = trim_param + .05*(end_param-trim_param);
+ if( within_u_param_range )
+ {
+ double keep_param;
+ if( start )
+ keep_param = start_param + .95*(trim_param-start_param);
+ else
+ keep_param = trim_param + .05*(end_param-trim_param);
- CubitVector tmp_keep_vec = keep_vector;
- trim_curve->position_from_u( keep_param, tmp_keep_vec );
- }
- }
+ CubitVector tmp_keep_vec = keep_vector;
+ trim_curve->position_from_u( keep_param, tmp_keep_vec );
+ }
+ }
- // Copy the edge to trim first
- EDGE* copied_EDGE_ptr;
- outcome result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ // Copy the edge to trim first
+ EDGE* copied_EDGE_ptr;
+ outcome result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- SPAposition trim_pos( trim_vector.x(),trim_vector.y(),trim_vector.z() );
- SPAposition* ptrim_pos = &trim_pos;
- entity_with_ray *peray2 = NULL;
+ SPAposition trim_pos( trim_vector.x(),trim_vector.y(),trim_vector.z() );
+ SPAposition* ptrim_pos = &trim_pos;
+ entity_with_ray *peray2 = NULL;
- SPAposition keep_pos( keep_vector.x(),keep_vector.y(),keep_vector.z() );
- SPAunit_vector keep_vec( 0.0, 0.0, 0.0 );
- entity_with_ray eray1( copied_EDGE_ptr, keep_pos, keep_vec );
+ SPAposition keep_pos( keep_vector.x(),keep_vector.y(),keep_vector.z() );
+ SPAunit_vector keep_vec( 0.0, 0.0, 0.0 );
+ entity_with_ray eray1( copied_EDGE_ptr, keep_pos, keep_vec );
- // Finally, do the real work
- result = api_trim_curve(eray1, ptrim_pos, peray2);
+ // Finally, do the real work
+ result = api_trim_curve(eray1, ptrim_pos, peray2);
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error (result);
- PRINT_ERROR( "Unable to trim curve\n" );
- api_delent( copied_EDGE_ptr );
- return 0;
- }
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ PRINT_ERROR( "Unable to trim curve\n" );
+ api_delent( copied_EDGE_ptr );
+ return 0;
+ }
- // Make a free curve from the trimmed EDGE
- Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( copied_EDGE_ptr );
- if (keep_old)
- return curve_ptr;
+ // Make a free curve from the trimmed EDGE
+ Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges( copied_EDGE_ptr );
+ if (keep_old)
+ return curve_ptr;
- // Delete the old curve (trim_curve), if it is a free curve
- DLIList<Surface*> surfaces;
- trim_curve->surfaces( surfaces );
- if ( surfaces.size() == 0 )
- {
- CubitStatus status =
- AcisQueryEngine::instance()->delete_solid_model_entities(trim_curve);
+ // Delete the old curve (trim_curve), if it is a free curve
+ DLIList<Surface*> surfaces;
+ trim_curve->surfaces( surfaces );
+ if ( surfaces.size() == 0 )
+ {
+ CubitStatus status =
+ AcisQueryEngine::instance()->delete_solid_model_entities(trim_curve);
- if (status == CUBIT_FAILURE)
- {
- PRINT_ERROR("In AcisModifyEngine::trim_curve\n"
- " Could not delete Curve.\n"
- " The Model database is likely corrupted "
- "due to\nthis unsuccessful deletion.\n" );
- }
- }
+ if (status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("In AcisModifyEngine::trim_curve\n"
+ " Could not delete Curve.\n"
+ " The Model database is likely corrupted "
+ "due to\nthis unsuccessful deletion.\n" );
+ }
+ }
- return curve_ptr;
- }
+ return curve_ptr;
+}
- Curve*
- AcisModifyEngine::create_arc_three( Point* vertex1, Point* vertex2,
- Point *vertex3, bool full )
- {
- CubitVector vec1 = vertex1->coordinates();
- CubitVector vec2 = vertex2->coordinates();
- CubitVector vec3 = vertex3->coordinates();
+Curve*
+AcisModifyEngine::create_arc_three( Point* vertex1, Point* vertex2,
+ Point *vertex3, bool full )
+{
+ CubitVector vec1 = vertex1->coordinates();
+ CubitVector vec2 = vertex2->coordinates();
+ CubitVector vec3 = vertex3->coordinates();
- SPAposition pos1( vec1.x(), vec1.y(), vec1.z() );
- SPAposition pos2( vec2.x(), vec2.y(), vec2.z() );
- SPAposition pos3( vec3.x(), vec3.y(), vec3.z() );
+ SPAposition pos1( vec1.x(), vec1.y(), vec1.z() );
+ SPAposition pos2( vec2.x(), vec2.y(), vec2.z() );
+ SPAposition pos3( vec3.x(), vec3.y(), vec3.z() );
- EDGE *EDGE_ptr;
+ EDGE *EDGE_ptr;
- outcome result = api_curve_arc_3pt( pos1, pos2, pos3, full, EDGE_ptr );
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to create arc from given vertices\n" );
- return NULL;
- }
+ outcome result = api_curve_arc_3pt( pos1, pos2, pos3, full, EDGE_ptr );
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to create arc from given vertices\n" );
+ return NULL;
+ }
- //reuse vertices
- if( full )
- {
- PointACIS *acis_point1 = CAST_TO( vertex1, PointACIS );
- EDGE_ptr->set_start(acis_point1->get_VERTEX_ptr() );
- EDGE_ptr->set_end(acis_point1->get_VERTEX_ptr() );
- acis_point1->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- }
- else
- {
+ //reuse vertices
+ if( full )
+ {
+ PointACIS *acis_point1 = CAST_TO( vertex1, PointACIS );
+ EDGE_ptr->set_start(acis_point1->get_VERTEX_ptr() );
+ EDGE_ptr->set_end(acis_point1->get_VERTEX_ptr() );
+ acis_point1->get_VERTEX_ptr()->add_edge(EDGE_ptr);
+ }
+ else
+ {
- PointACIS *acis_point1 = CAST_TO( vertex1, PointACIS );
- PointACIS *acis_point3 = CAST_TO( vertex3, PointACIS );
+ PointACIS *acis_point1 = CAST_TO( vertex1, PointACIS );
+ PointACIS *acis_point3 = CAST_TO( vertex3, PointACIS );
- EDGE_ptr->set_start(acis_point1->get_VERTEX_ptr() );
- acis_point1->get_VERTEX_ptr()->add_edge(EDGE_ptr);
+ EDGE_ptr->set_start(acis_point1->get_VERTEX_ptr() );
+ acis_point1->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- EDGE_ptr->set_end(acis_point3->get_VERTEX_ptr() );
- acis_point3->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- }
+ EDGE_ptr->set_end(acis_point3->get_VERTEX_ptr() );
+ acis_point3->get_VERTEX_ptr()->add_edge(EDGE_ptr);
+ }
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- }
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- Curve*
- AcisModifyEngine::create_arc_three( Curve* ref_edge1, Curve* ref_edge2,
- Curve *ref_edge3, bool full )
- {
- EDGE* EDGE_ptr1 = AcisQueryEngine::get_EDGE( ref_edge1 );
- EDGE* EDGE_ptr2 = AcisQueryEngine::get_EDGE( ref_edge2 );
- EDGE* EDGE_ptr3 = AcisQueryEngine::get_EDGE( ref_edge3 );
- if( !EDGE_ptr1 || !EDGE_ptr2 || !EDGE_ptr3)
- return NULL;
+Curve*
+AcisModifyEngine::create_arc_three( Curve* ref_edge1, Curve* ref_edge2,
+ Curve *ref_edge3, bool full )
+{
+ EDGE* EDGE_ptr1 = AcisQueryEngine::get_EDGE( ref_edge1 );
+ EDGE* EDGE_ptr2 = AcisQueryEngine::get_EDGE( ref_edge2 );
+ EDGE* EDGE_ptr3 = AcisQueryEngine::get_EDGE( ref_edge3 );
+ if( !EDGE_ptr1 || !EDGE_ptr2 || !EDGE_ptr3)
+ return NULL;
- SPAposition tang_pos( 0.0, 0.0, 0.0 );
- SPAunit_vector tang_vec( 0.0, 0.0, 0.0 );
- entity_with_ray eray1( EDGE_ptr1, tang_pos, tang_vec );
- entity_with_ray eray2( EDGE_ptr2, tang_pos, tang_vec );
- entity_with_ray eray3( EDGE_ptr3, tang_pos, tang_vec );
+ SPAposition tang_pos( 0.0, 0.0, 0.0 );
+ SPAunit_vector tang_vec( 0.0, 0.0, 0.0 );
+ entity_with_ray eray1( EDGE_ptr1, tang_pos, tang_vec );
+ entity_with_ray eray2( EDGE_ptr2, tang_pos, tang_vec );
+ entity_with_ray eray3( EDGE_ptr3, tang_pos, tang_vec );
- EDGE *EDGE_ptr;
+ EDGE *EDGE_ptr;
- outcome result = api_curve_arc_3curve( eray1, eray2, eray3, full, EDGE_ptr );
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to create arc from given curves\n" );
- return NULL;
- }
+ outcome result = api_curve_arc_3curve( eray1, eray2, eray3, full, EDGE_ptr );
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to create arc from given curves\n" );
+ return NULL;
+ }
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- }
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- Curve*
- AcisModifyEngine::create_arc_center_edge( Point* vertex1, Point* vertex2,
- Point *vertex3, const CubitVector &normal,
- double radius, bool full )
- {
- CubitVector vec1 = vertex1->coordinates(); // Center of arc
- CubitVector vec2 = vertex2->coordinates(); // Position on arc
- CubitVector vec3 = vertex3->coordinates(); // Position on arc
+Curve*
+AcisModifyEngine::create_arc_center_edge( Point* vertex1, Point* vertex2,
+ Point *vertex3, const CubitVector &normal,
+ double radius, bool full )
+{
+ CubitVector vec1 = vertex1->coordinates(); // Center of arc
+ CubitVector vec2 = vertex2->coordinates(); // Position on arc
+ CubitVector vec3 = vertex3->coordinates(); // Position on arc
- // Re-adjust vec2 if radius was given
- if( radius != CUBIT_DBL_MAX )
- {
- CubitVector dir1( vec1, vec2 );
- vec1.next_point( dir1, radius, vec2 );
- }
+ // Re-adjust vec2 if radius was given
+ if( radius != CUBIT_DBL_MAX )
+ {
+ CubitVector dir1( vec1, vec2 );
+ vec1.next_point( dir1, radius, vec2 );
+ }
- SPAposition pos1( vec1.x(), vec1.y(), vec1.z() );
- SPAposition pos2( vec2.x(), vec2.y(), vec2.z() );
- SPAposition pos3( vec3.x(), vec3.y(), vec3.z() );
+ SPAposition pos1( vec1.x(), vec1.y(), vec1.z() );
+ SPAposition pos2( vec2.x(), vec2.y(), vec2.z() );
+ SPAposition pos3( vec3.x(), vec3.y(), vec3.z() );
- EDGE *EDGE_ptr;
- SPAunit_vector arc_normal;
- if( normal.length() != 0 )
- {
- arc_normal.set_x( normal.x() );
- arc_normal.set_y( normal.y() );
- arc_normal.set_z( normal.z() );
- }
+ EDGE *EDGE_ptr;
+ SPAunit_vector arc_normal;
+ if( normal.length() != 0 )
+ {
+ arc_normal.set_x( normal.x() );
+ arc_normal.set_y( normal.y() );
+ arc_normal.set_z( normal.z() );
+ }
- outcome result;
- if( full == CUBIT_FALSE )
- {
- if( normal.length() != 0.0 )
- result = api_curve_arc_center_edge( pos1, pos2, pos3, &arc_normal, EDGE_ptr );
- else
- result = api_curve_arc_center_edge( pos1, pos2, pos3, NULL, EDGE_ptr );
- }
- else
- {
- if( normal.length() == 0.0 )
- {
- CubitVector dir1( vec1, vec2 );
- CubitVector dir2( vec1, vec3 );
- CubitVector tmp_normal = dir1 * dir2; // Cross-product
- tmp_normal.normalize();
- arc_normal.set_x( tmp_normal.x() );
- arc_normal.set_y( tmp_normal.y() );
- arc_normal.set_z( tmp_normal.z() );
- }
- result = api_curve_arc_center_edge( pos1, pos2, pos2, &arc_normal, EDGE_ptr );
- }
+ outcome result;
+ if( full == CUBIT_FALSE )
+ {
+ if( normal.length() != 0.0 )
+ result = api_curve_arc_center_edge( pos1, pos2, pos3, &arc_normal, EDGE_ptr );
+ else
+ result = api_curve_arc_center_edge( pos1, pos2, pos3, NULL, EDGE_ptr );
+ }
+ else
+ {
+ if( normal.length() == 0.0 )
+ {
+ CubitVector dir1( vec1, vec2 );
+ CubitVector dir2( vec1, vec3 );
+ CubitVector tmp_normal = dir1 * dir2; // Cross-product
+ tmp_normal.normalize();
+ arc_normal.set_x( tmp_normal.x() );
+ arc_normal.set_y( tmp_normal.y() );
+ arc_normal.set_z( tmp_normal.z() );
+ }
+ result = api_curve_arc_center_edge( pos1, pos2, pos2, &arc_normal, EDGE_ptr );
+ }
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to create arc from given vertices\n" );
- return NULL;
- }
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to create arc from given vertices\n" );
+ return NULL;
+ }
- //reuse vertices...if possible
- if( full )
- {
- PointACIS *acis_point2 = CAST_TO( vertex2, PointACIS );
- EDGE_ptr->set_start(acis_point2->get_VERTEX_ptr() );
- EDGE_ptr->set_end(acis_point2->get_VERTEX_ptr() );
- acis_point2->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- }
- else
- {
- //reuse vertices only if it is coincident with
- //new vertex on new curve
+ //reuse vertices...if possible
+ if( full )
+ {
+ PointACIS *acis_point2 = CAST_TO( vertex2, PointACIS );
+ EDGE_ptr->set_start(acis_point2->get_VERTEX_ptr() );
+ EDGE_ptr->set_end(acis_point2->get_VERTEX_ptr() );
+ acis_point2->get_VERTEX_ptr()->add_edge(EDGE_ptr);
+ }
+ else
+ {
+ //reuse vertices only if it is coincident with
+ //new vertex on new curve
- //compare original start vs. new start vertex on EDGE
- VERTEX *start_vert = EDGE_ptr->start();
- SPAposition temp_pos = start_vert->geometry()->coords();
- CubitVector tmp_pos1( temp_pos.x(), temp_pos.y(), temp_pos.z() );
- vec2 = vertex2->coordinates();
+ //compare original start vs. new start vertex on EDGE
+ VERTEX *start_vert = EDGE_ptr->start();
+ SPAposition temp_pos = start_vert->geometry()->coords();
+ CubitVector tmp_pos1( temp_pos.x(), temp_pos.y(), temp_pos.z() );
+ vec2 = vertex2->coordinates();
- if(tmp_pos1.distance_between( vec2 ) < GEOMETRY_RESABS )
- {
- PointACIS *acis_point2 = CAST_TO( vertex2, PointACIS );
- EDGE_ptr->set_start(acis_point2->get_VERTEX_ptr() );
- acis_point2->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- }
+ if(tmp_pos1.distance_between( vec2 ) < GEOMETRY_RESABS )
+ {
+ PointACIS *acis_point2 = CAST_TO( vertex2, PointACIS );
+ EDGE_ptr->set_start(acis_point2->get_VERTEX_ptr() );
+ acis_point2->get_VERTEX_ptr()->add_edge(EDGE_ptr);
+ }
- //compare original end vs. new end vertex on EDGE
- VERTEX *end_vert = EDGE_ptr->end();
- temp_pos = end_vert->geometry()->coords();
- tmp_pos1.set( temp_pos.x(), temp_pos.y(), temp_pos.z() );
- vec3 = vertex3->coordinates();
+ //compare original end vs. new end vertex on EDGE
+ VERTEX *end_vert = EDGE_ptr->end();
+ temp_pos = end_vert->geometry()->coords();
+ tmp_pos1.set( temp_pos.x(), temp_pos.y(), temp_pos.z() );
+ vec3 = vertex3->coordinates();
- if(tmp_pos1.distance_between( vec3 ) < GEOMETRY_RESABS )
- {
- PointACIS *acis_point3 = CAST_TO( vertex3, PointACIS );
- EDGE_ptr->set_end(acis_point3->get_VERTEX_ptr() );
- acis_point3->get_VERTEX_ptr()->add_edge(EDGE_ptr);
- }
- else
- {
- //make sure this point isn't a free vertex
- if( !vertex3->topology_entity() )
- AcisQueryEngine::instance()->delete_solid_model_entities( vertex3 );
- }
- }
-
-
- return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+ if(tmp_pos1.distance_between( vec3 ) < GEOMETRY_RESABS )
+ {
+ PointACIS *acis_point3 = CAST_TO( vertex3, PointACIS );
+ EDGE_ptr->set_end(acis_point3->get_VERTEX_ptr() );
+ acis_point3->get_VERTEX_ptr()->add_edge(EDGE_ptr);
}
-
- CubitStatus
- AcisModifyEngine::create_curve_combine( DLIList<Curve*>& curve_list,
- Curve *&new_curve_ptr )
+ else
{
- CubitStatus result;
+ //make sure this point isn't a free vertex
+ if( !vertex3->topology_entity() )
+ AcisQueryEngine::instance()->delete_solid_model_entities( vertex3 );
+ }
+ }
- result = AcisEdgeTool::instance()->create_curve_combine(curve_list,
- new_curve_ptr);
- if (result)
- {
- RefEdge* new_ref_edge_ptr = GeometryQueryTool::instance()->make_free_RefEdge( new_curve_ptr );
+ return AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+}
- if (new_ref_edge_ptr)
- PRINT_INFO( "Created new \"combined\" curve %d\n", new_ref_edge_ptr->id() );
- else
- result = CUBIT_FAILURE;
- }
+CubitStatus
+AcisModifyEngine::create_curve_combine( DLIList<Curve*>& curve_list,
+ Curve *&new_curve_ptr )
+{
+ CubitStatus result;
- return result;
+ result = AcisEdgeTool::instance()->create_curve_combine(curve_list,
+ new_curve_ptr);
- }
+ if (result)
+ {
+ RefEdge* new_ref_edge_ptr = GeometryQueryTool::instance()->make_free_RefEdge( new_curve_ptr );
- CubitStatus
- AcisModifyEngine::get_copied_FACES_of_body( DLIList<SurfaceACIS*>& ref_face_list,
- DLIList<FACE*>& FACE_list,
- DLIList<SurfaceACIS*>& removed_ref_faces,
- BODY*& copied_BODY_ptr ) const
- {
- int i, num_faces;
+ if (new_ref_edge_ptr)
+ PRINT_INFO( "Created new \"combined\" curve %d\n", new_ref_edge_ptr->id() );
+ else
+ result = CUBIT_FAILURE;
+ }
- // Note: we will be pulling surfaces out of incoming ref_face_list.
- SurfaceACIS* ref_face_ptr;
- BodySM *body_ptr;
+ return result;
- BODY *BODY_ptr;
- BODY *BODY_ptr2;
+}
- FACE *FACE_ptr;
+CubitStatus
+AcisModifyEngine::get_copied_FACES_of_body( DLIList<SurfaceACIS*>& ref_face_list,
+ DLIList<FACE*>& FACE_list,
+ DLIList<SurfaceACIS*>& removed_ref_faces,
+ BODY*& copied_BODY_ptr ) const
+{
+ int i, num_faces;
- copied_BODY_ptr = NULL;
+ // Note: we will be pulling surfaces out of incoming ref_face_list.
+ SurfaceACIS* ref_face_ptr;
+ BodySM *body_ptr;
- outcome result;
+ BODY *BODY_ptr;
+ BODY *BODY_ptr2;
- DLIList<SurfaceACIS*> body_face_list;
+ FACE *FACE_ptr;
- ref_face_list.reset();
- ref_face_ptr = ref_face_list.remove();
- removed_ref_faces.append( ref_face_ptr );
+ copied_BODY_ptr = NULL;
- FACE_ptr = ref_face_ptr->get_FACE_ptr();
- if (!FACE_ptr)
- {
- PRINT_ERROR( "Unable to get Acis FACE from Surface\n" );
- return CUBIT_FAILURE;
- }
+ outcome result;
- body_face_list.append_unique( ref_face_ptr );
+ DLIList<SurfaceACIS*> body_face_list;
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
- if( body_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from FACE\n" );
- return CUBIT_FAILURE;
- }
+ ref_face_list.reset();
+ ref_face_ptr = ref_face_list.remove();
+ removed_ref_faces.append( ref_face_ptr );
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
- if( BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from FACE\n" );
- return CUBIT_FAILURE;
- }
+ FACE_ptr = ref_face_ptr->get_FACE_ptr();
+ if (!FACE_ptr)
+ {
+ PRINT_ERROR( "Unable to get Acis FACE from Surface\n" );
+ return CUBIT_FAILURE;
+ }
- // Add all remaining faces from this same body to face list
- num_faces = ref_face_list.size();
- for( i=0; i<num_faces; i++ )
- {
- ref_face_ptr = ref_face_list.get();
+ body_face_list.append_unique( ref_face_ptr );
- BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_face_ptr );
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
+ if( body_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from FACE\n" );
+ return CUBIT_FAILURE;
+ }
- if( BODY_ptr == BODY_ptr2 )
- {
- body_face_list.append_unique( ref_face_ptr );
- ref_face_list.remove();
- removed_ref_faces.append( ref_face_ptr );
- }
- else
- ref_face_list.step();
- }
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
+ if( BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from FACE\n" );
+ return CUBIT_FAILURE;
+ }
- // Now we have all the faces from this particular BODY.
+ // Add all remaining faces from this same body to face list
+ num_faces = ref_face_list.size();
+ for( i=0; i<num_faces; i++ )
+ {
+ ref_face_ptr = ref_face_list.get();
- // Copy the body before working with it. Here we keep the
- // attributes on the BODY so we can get back to the TE's
- // in CUBIT from the copy (to find which FACE's to correlate
- // to the RefFace's).
- copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
+ BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_face_ptr );
- // Loop through the copied BODY's FACES to find which one's
- // match to the original BODY's RefFaces.
- ENTITY_LIST ENTITIES;
- result = api_get_faces( copied_BODY_ptr, ENTITIES );
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to get ACIS FACES from volume\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ if( BODY_ptr == BODY_ptr2 )
+ {
+ body_face_list.append_unique( ref_face_ptr );
+ ref_face_list.remove();
+ removed_ref_faces.append( ref_face_ptr );
+ }
+ else
+ ref_face_list.step();
+ }
- ENTITIES.init();
- ENTITY* ENTITY_ptr;
- int index = -1;
- DLIList<int> index_list;
- DLIList<FACE*> temp_FACE_list;
- while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
- {
- AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
- ref_face_ptr = CAST_TO( ab_ptr, SurfaceACIS );
- if( ref_face_ptr == NULL )
- {
- PRINT_ERROR( "Unable to find RefFace from ACIS FACE!\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ // Now we have all the faces from this particular BODY.
- index = body_face_list.where_is_item( ref_face_ptr );
- if( index != -1 )
- {
- index_list.append( index );
- temp_FACE_list.append( (FACE *)ENTITY_ptr );
- }
- if( temp_FACE_list.size() == body_face_list.size() )
- break;
- }
- ENTITIES.clear();
+ // Copy the body before working with it. Here we keep the
+ // attributes on the BODY so we can get back to the TE's
+ // in CUBIT from the copy (to find which FACE's to correlate
+ // to the RefFace's).
+ copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
- if( temp_FACE_list.size() != body_face_list.size() )
- {
- PRINT_ERROR( "Internal error correlating FACE lists\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ // Loop through the copied BODY's FACES to find which one's
+ // match to the original BODY's RefFaces.
+ ENTITY_LIST ENTITIES;
+ result = api_get_faces( copied_BODY_ptr, ENTITIES );
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to get ACIS FACES from volume\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- // Re-sort the list into the proper order
- temp_FACE_list.reset();
- index_list.reset();
- for( i=0; i<index_list.size(); i++ )
- {
- // Find the FACE with the corresponding index
- index = index_list.where_is_item( i );
- temp_FACE_list.reset();
- temp_FACE_list.step( index );
-
- FACE_list.append( temp_FACE_list.get() );
- }
-
- return CUBIT_SUCCESS;
+ ENTITIES.init();
+ ENTITY* ENTITY_ptr;
+ int index = -1;
+ DLIList<int> index_list;
+ DLIList<FACE*> temp_FACE_list;
+ while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
+ {
+ AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
+ ref_face_ptr = CAST_TO( ab_ptr, SurfaceACIS );
+ if( ref_face_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to find RefFace from ACIS FACE!\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
}
- CubitStatus
- AcisModifyEngine::get_copied_FACES_of_body( DLIList<SurfaceACIS*>& ref_face_list,
- DLIList<FACE*>& FACE_list,
- BODY*& copied_BODY_ptr ) const
+ index = body_face_list.where_is_item( ref_face_ptr );
+ if( index != -1 )
{
- DLIList<SurfaceACIS*> removed_faces;
-
- return get_copied_FACES_of_body( ref_face_list, FACE_list, removed_faces,
- copied_BODY_ptr );
+ index_list.append( index );
+ temp_FACE_list.append( (FACE *)ENTITY_ptr );
}
+ if( temp_FACE_list.size() == body_face_list.size() )
+ break;
+ }
+ ENTITIES.clear();
- CubitStatus
- AcisModifyEngine::get_copied_EDGES_of_body( DLIList<CurveACIS*>& ref_edge_list,
- DLIList<EDGE*>& EDGE_list,
- DLIList<CurveACIS*>& removed_ref_edges,
- BODY*& copied_BODY_ptr ) const
- {
- int i, num_edges;
+ if( temp_FACE_list.size() != body_face_list.size() )
+ {
+ PRINT_ERROR( "Internal error correlating FACE lists\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- // Note: we will be pulling surfaces out of incoming ref_edge_list.
- CurveACIS* ref_edge_ptr;
- BodySM *body_ptr;
+ // Re-sort the list into the proper order
+ temp_FACE_list.reset();
+ index_list.reset();
+ for( i=0; i<index_list.size(); i++ )
+ {
+ // Find the FACE with the corresponding index
+ index = index_list.where_is_item( i );
+ temp_FACE_list.reset();
+ temp_FACE_list.step( index );
- BODY *BODY_ptr;
- BODY *BODY_ptr2;
+ FACE_list.append( temp_FACE_list.get() );
+ }
- EDGE *EDGE_ptr;
+ return CUBIT_SUCCESS;
+}
- copied_BODY_ptr = NULL;
+CubitStatus
+AcisModifyEngine::get_copied_FACES_of_body( DLIList<SurfaceACIS*>& ref_face_list,
+ DLIList<FACE*>& FACE_list,
+ BODY*& copied_BODY_ptr ) const
+{
+ DLIList<SurfaceACIS*> removed_faces;
- outcome result;
+ return get_copied_FACES_of_body( ref_face_list, FACE_list, removed_faces,
+ copied_BODY_ptr );
+}
- DLIList<CurveACIS*> body_edge_list;
+CubitStatus
+AcisModifyEngine::get_copied_EDGES_of_body( DLIList<CurveACIS*>& ref_edge_list,
+ DLIList<EDGE*>& EDGE_list,
+ DLIList<CurveACIS*>& removed_ref_edges,
+ BODY*& copied_BODY_ptr ) const
+{
+ int i, num_edges;
- ref_edge_ptr = ref_edge_list.remove();
- removed_ref_edges.append( ref_edge_ptr );
+ // Note: we will be pulling surfaces out of incoming ref_edge_list.
+ CurveACIS* ref_edge_ptr;
+ BodySM *body_ptr;
- EDGE_ptr = ref_edge_ptr->get_EDGE_ptr();
+ BODY *BODY_ptr;
+ BODY *BODY_ptr2;
- body_edge_list.append_unique( ref_edge_ptr );
+ EDGE *EDGE_ptr;
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( EDGE_ptr );
- if( body_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from EDGE\n" );
- return CUBIT_FAILURE;
- }
+ copied_BODY_ptr = NULL;
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( EDGE_ptr );
- if( BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from EDGE\n" );
- return CUBIT_FAILURE;
- }
+ outcome result;
- // Add all remaining edges from this same body to edge list
- num_edges = ref_edge_list.size();
- for( i=0; i<num_edges; i++ )
- {
- ref_edge_ptr = ref_edge_list.get();
+ DLIList<CurveACIS*> body_edge_list;
- BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_edge_ptr );
+ ref_edge_ptr = ref_edge_list.remove();
+ removed_ref_edges.append( ref_edge_ptr );
- if( BODY_ptr == BODY_ptr2 )
- {
- body_edge_list.append_unique( ref_edge_ptr );
- ref_edge_list.remove();
- removed_ref_edges.append( ref_edge_ptr );
- }
- else
- ref_edge_list.step();
- }
+ EDGE_ptr = ref_edge_ptr->get_EDGE_ptr();
- // Now we have all the edges from this particular BODY.
+ body_edge_list.append_unique( ref_edge_ptr );
- // Copy the body before working with it. Here we keep the
- // attributes on the BODY so we can get back to the TE's
- // in CUBIT from the copy (to find which EDGE's to correlate
- // to the RefEdge's).
- copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( EDGE_ptr );
+ if( body_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from EDGE\n" );
+ return CUBIT_FAILURE;
+ }
- // Loop through the copied BODY's EDGES to find which one's
- // match to the original BODY's RefEdges.
- ENTITY_LIST ENTITIES;
- result = api_get_edges(copied_BODY_ptr, ENTITIES);
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to get ACIS EDGES from volume\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( EDGE_ptr );
+ if( BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from EDGE\n" );
+ return CUBIT_FAILURE;
+ }
- ENTITIES.init();
- ENTITY* ENTITY_ptr;
- int index = -1;
- DLIList<int> index_list;
- DLIList<EDGE*> temp_EDGE_list;
- while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
- {
- AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
- ref_edge_ptr = CAST_TO( ab_ptr, CurveACIS );
- if( ref_edge_ptr == NULL )
- {
- PRINT_ERROR( "Unable to find Cubit curve from ACIS EDGE!\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
- index = body_edge_list.where_is_item( ref_edge_ptr );
- if( index != -1 )
- {
- index_list.append( index );
- temp_EDGE_list.append( (EDGE *)ENTITY_ptr );
- }
- if( temp_EDGE_list.size() == body_edge_list.size() )
- break;
- }
- ENTITIES.clear();
+ // Add all remaining edges from this same body to edge list
+ num_edges = ref_edge_list.size();
+ for( i=0; i<num_edges; i++ )
+ {
+ ref_edge_ptr = ref_edge_list.get();
- if( temp_EDGE_list.size() != body_edge_list.size() )
- {
- PRINT_ERROR( "Internal error correlating EDGE lists\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_edge_ptr );
- // Re-sort the list into the proper order
- temp_EDGE_list.reset();
- index_list.reset();
- for( i=0; i<index_list.size(); i++ )
- {
- // Find the EDGE with the corresponding index
- index = index_list.where_is_item( i );
- temp_EDGE_list.reset();
- temp_EDGE_list.step( index );
-
- EDGE_list.append( temp_EDGE_list.get() );
- }
-
- return CUBIT_SUCCESS;
+ if( BODY_ptr == BODY_ptr2 )
+ {
+ body_edge_list.append_unique( ref_edge_ptr );
+ ref_edge_list.remove();
+ removed_ref_edges.append( ref_edge_ptr );
}
+ else
+ ref_edge_list.step();
+ }
- CubitStatus
- AcisModifyEngine::get_copied_EDGES_of_body( DLIList<CurveACIS*>& ref_edge_list,
- DLIList<EDGE*>& EDGE_list,
- BODY*& copied_BODY_ptr ) const
- {
- DLIList<CurveACIS*> removed_edges;
+ // Now we have all the edges from this particular BODY.
- return get_copied_EDGES_of_body( ref_edge_list, EDGE_list, removed_edges,
- copied_BODY_ptr );
- }
+ // Copy the body before working with it. Here we keep the
+ // attributes on the BODY so we can get back to the TE's
+ // in CUBIT from the copy (to find which EDGE's to correlate
+ // to the RefEdge's).
+ copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
- //-------------------------------------------------------------------------
- // Purpose : To get a pointer to a copy of the body along with a list of VERTEXs
- //
- // Special Notes :
- //
- // Creator : Lingyun Pan (CAT)
- //
- // Creation Date : 07/19/01
- //-------------------------------------------------------------------------
+ // Loop through the copied BODY's EDGES to find which one's
+ // match to the original BODY's RefEdges.
+ ENTITY_LIST ENTITIES;
+ result = api_get_edges(copied_BODY_ptr, ENTITIES);
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to get ACIS EDGES from volume\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- CubitStatus
- AcisModifyEngine::get_copied_VERTICES_of_body(
- DLIList<PointACIS*>& ref_vertex_list,
- DLIList<VERTEX*>& VERTEX_list,
- DLIList<PointACIS*>& removed_ref_vertices,
- BODY*& copied_BODY_ptr ) const
+ ENTITIES.init();
+ ENTITY* ENTITY_ptr;
+ int index = -1;
+ DLIList<int> index_list;
+ DLIList<EDGE*> temp_EDGE_list;
+ while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
+ {
+ AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
+ ref_edge_ptr = CAST_TO( ab_ptr, CurveACIS );
+ if( ref_edge_ptr == NULL )
{
- int i, num_vertices;
+ PRINT_ERROR( "Unable to find Cubit curve from ACIS EDGE!\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
+ index = body_edge_list.where_is_item( ref_edge_ptr );
+ if( index != -1 )
+ {
+ index_list.append( index );
+ temp_EDGE_list.append( (EDGE *)ENTITY_ptr );
+ }
+ if( temp_EDGE_list.size() == body_edge_list.size() )
+ break;
+ }
+ ENTITIES.clear();
- // Note: we will be pulling vertices out of incoming ref_vertex_list.
- PointACIS* ref_vertex_ptr;
- BodySM *body_ptr;
+ if( temp_EDGE_list.size() != body_edge_list.size() )
+ {
+ PRINT_ERROR( "Internal error correlating EDGE lists\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- BODY *BODY_ptr;
- BODY *BODY_ptr2;
+ // Re-sort the list into the proper order
+ temp_EDGE_list.reset();
+ index_list.reset();
+ for( i=0; i<index_list.size(); i++ )
+ {
+ // Find the EDGE with the corresponding index
+ index = index_list.where_is_item( i );
+ temp_EDGE_list.reset();
+ temp_EDGE_list.step( index );
- VERTEX *VERTEX_ptr;
+ EDGE_list.append( temp_EDGE_list.get() );
+ }
- copied_BODY_ptr = NULL;
+ return CUBIT_SUCCESS;
+}
- outcome result;
+CubitStatus
+AcisModifyEngine::get_copied_EDGES_of_body( DLIList<CurveACIS*>& ref_edge_list,
+ DLIList<EDGE*>& EDGE_list,
+ BODY*& copied_BODY_ptr ) const
+{
+ DLIList<CurveACIS*> removed_edges;
- DLIList<PointACIS*> body_vertex_list;
+ return get_copied_EDGES_of_body( ref_edge_list, EDGE_list, removed_edges,
+ copied_BODY_ptr );
+}
- ref_vertex_ptr =ref_vertex_list .remove();
- removed_ref_vertices.append( ref_vertex_ptr);
+//-------------------------------------------------------------------------
+// Purpose : To get a pointer to a copy of the body along with a list of VERTEXs
+//
+// Special Notes :
+//
+// Creator : Lingyun Pan (CAT)
+//
+// Creation Date : 07/19/01
+//-------------------------------------------------------------------------
- VERTEX_ptr = ref_vertex_ptr->get_VERTEX_ptr();
+CubitStatus
+AcisModifyEngine::get_copied_VERTICES_of_body(
+ DLIList<PointACIS*>& ref_vertex_list,
+ DLIList<VERTEX*>& VERTEX_list,
+ DLIList<PointACIS*>& removed_ref_vertices,
+ BODY*& copied_BODY_ptr ) const
+{
+ int i, num_vertices;
- body_vertex_list.append_unique( ref_vertex_ptr );
+ // Note: we will be pulling vertices out of incoming ref_vertex_list.
+ PointACIS* ref_vertex_ptr;
+ BodySM *body_ptr;
- body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(VERTEX_ptr );
- if( body_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from VERTEX\n" );
- return CUBIT_FAILURE;
- }
+ BODY *BODY_ptr;
+ BODY *BODY_ptr2;
- BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( VERTEX_ptr );
- if( BODY_ptr == NULL )
- {
- PRINT_ERROR( "Unable to get volume from VERTEX\n" );
- return CUBIT_FAILURE;
- }
+ VERTEX *VERTEX_ptr;
- // Add all remaining vertex from this same body to vertex list
- num_vertices = ref_vertex_list.size();
- for( i=0; i<num_vertices; i++ )
- {
- ref_vertex_ptr = ref_vertex_list.get();
+ copied_BODY_ptr = NULL;
- BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_vertex_ptr );
+ outcome result;
- if( BODY_ptr == BODY_ptr2 )
- {
- body_vertex_list.append_unique( ref_vertex_ptr );
- ref_vertex_list.remove();
- removed_ref_vertices.append( ref_vertex_ptr );
- }
- else
- ref_vertex_list.step();
- }
+ DLIList<PointACIS*> body_vertex_list;
- // Now we have all the vertices from this particular BODY.
+ ref_vertex_ptr =ref_vertex_list .remove();
+ removed_ref_vertices.append( ref_vertex_ptr);
- // Copy the body before working with it. Here we keep the
- // attributes on the BODY so we can get back to the TE's
- // in CUBIT from the copy (to find which VERTICE's to correlate
- // to the RefVertice's).
- copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
+ VERTEX_ptr = ref_vertex_ptr->get_VERTEX_ptr();
- // Loop through the copied BODY's VERTICEs to find which one's
- // match to the original BODY's RefVertices.
- ENTITY_LIST ENTITIES;
- result = api_get_vertices( copied_BODY_ptr, ENTITIES);
- if( !result.ok() )
- {
- PRINT_ERROR( "Unable to get ACIS VERTICES from a volume\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ body_vertex_list.append_unique( ref_vertex_ptr );
- ENTITIES.init();
- ENTITY* ENTITY_ptr;
- int index = -1;
- DLIList<int> index_list;
- DLIList<VERTEX*> temp_VERTEX_list;
- while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
- {
- AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
- ref_vertex_ptr = CAST_TO(ab_ptr, PointACIS);
- if( ref_vertex_ptr == NULL )
- {
- PRINT_ERROR( "Unable to find RefVertex from ACIS VERTEX!\n" );
- VERTEX_list.clean_out();
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- VERTEX_list.clean_out();
- return CUBIT_FAILURE;
- }
+ body_ptr = AcisQueryEngine::instance()->get_body_sm_of_ENTITY(VERTEX_ptr );
+ if( body_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from VERTEX\n" );
+ return CUBIT_FAILURE;
+ }
- index = body_vertex_list.where_is_item( ref_vertex_ptr );
- if( index != -1 )
- {
- index_list.append( index );
- temp_VERTEX_list.append( (VERTEX *)ENTITY_ptr );
- }
- if( temp_VERTEX_list.size() == body_vertex_list.size() )
- break;
- }
- ENTITIES.clear();
+ BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( VERTEX_ptr );
+ if( BODY_ptr == NULL )
+ {
+ PRINT_ERROR( "Unable to get volume from VERTEX\n" );
+ return CUBIT_FAILURE;
+ }
- if( temp_VERTEX_list.size() != body_vertex_list.size() )
- {
- PRINT_ERROR( "Internal error correlating VERTEX lists\n" );
- api_delent( copied_BODY_ptr );
- copied_BODY_ptr = NULL;
- return CUBIT_FAILURE;
- }
+ // Add all remaining vertex from this same body to vertex list
+ num_vertices = ref_vertex_list.size();
+ for( i=0; i<num_vertices; i++ )
+ {
+ ref_vertex_ptr = ref_vertex_list.get();
- // Re-sort the list into the proper order
- temp_VERTEX_list.reset();
- index_list.reset();
- for( i=0; i<index_list.size(); i++ )
- {
- // Find the VERTEX with the corresponding index
- index = index_list.where_is_item( i );
- temp_VERTEX_list.reset();
- temp_VERTEX_list.step( index );
+ BODY_ptr2 = AcisQueryEngine::instance()->get_BODY_of_entity( ref_vertex_ptr );
- VERTEX_list.append( temp_VERTEX_list.get() );
- }
-
- return CUBIT_SUCCESS;
+ if( BODY_ptr == BODY_ptr2 )
+ {
+ body_vertex_list.append_unique( ref_vertex_ptr );
+ ref_vertex_list.remove();
+ removed_ref_vertices.append( ref_vertex_ptr );
}
+ else
+ ref_vertex_list.step();
+ }
- CubitStatus
- AcisModifyEngine::get_copied_VERTICES_of_body(
- DLIList<PointACIS*>& ref_vertex_list,
- DLIList<VERTEX*>& VERTEX_list,
- BODY*& copied_BODY_ptr ) const
- {
- DLIList<PointACIS*> removed_vertices;
+ // Now we have all the vertices from this particular BODY.
- return get_copied_VERTICES_of_body( ref_vertex_list, VERTEX_list,
- removed_vertices, copied_BODY_ptr );
- }
+ // Copy the body before working with it. Here we keep the
+ // attributes on the BODY so we can get back to the TE's
+ // in CUBIT from the copy (to find which VERTICE's to correlate
+ // to the RefVertice's).
+ copied_BODY_ptr = copy_BODY(BODY_ptr, CUBIT_FALSE);
+ // Loop through the copied BODY's VERTICEs to find which one's
+ // match to the original BODY's RefVertices.
+ ENTITY_LIST ENTITIES;
+ result = api_get_vertices( copied_BODY_ptr, ENTITIES);
+ if( !result.ok() )
+ {
+ PRINT_ERROR( "Unable to get ACIS VERTICES from a volume\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- GeometryQueryEngine *AcisModifyEngine::get_gqe()
+ ENTITIES.init();
+ ENTITY* ENTITY_ptr;
+ int index = -1;
+ DLIList<int> index_list;
+ DLIList<VERTEX*> temp_VERTEX_list;
+ while( (ENTITY_ptr = ENTITIES.next() ) != NULL )
+ {
+ AcisBridge* ab_ptr = ATTRIB_CUBIT_OWNER::cubit_owner(ENTITY_ptr);
+ ref_vertex_ptr = CAST_TO(ab_ptr, PointACIS);
+ if( ref_vertex_ptr == NULL )
{
- return AcisQueryEngine::instance();
+ PRINT_ERROR( "Unable to find RefVertex from ACIS VERTEX!\n" );
+ VERTEX_list.clean_out();
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ VERTEX_list.clean_out();
+ return CUBIT_FAILURE;
}
- CubitBoolean AcisModifyEngine::is_modify_engine(const TopologyBridge *tb_ptr) const
+ index = body_vertex_list.where_is_item( ref_vertex_ptr );
+ if( index != -1 )
{
-
- if (CAST_TO(const_cast<TopologyBridge*>(tb_ptr), AcisBridge)) return CUBIT_TRUE;
- else return CUBIT_FALSE;
+ index_list.append( index );
+ temp_VERTEX_list.append( (VERTEX *)ENTITY_ptr );
}
+ if( temp_VERTEX_list.size() == body_vertex_list.size() )
+ break;
+ }
+ ENTITIES.clear();
- CubitStatus
- AcisModifyEngine::get_offset_intersections( Curve* ref_edge1,
- Curve* ref_edge2,
- DLIList<CubitVector*>& intersection_list,
- double offset_distance,
- bool ext_first )
- {
- int i;
- //int done = 0;
- bool bounded = !ext_first;
+ if( temp_VERTEX_list.size() != body_vertex_list.size() )
+ {
+ PRINT_ERROR( "Internal error correlating VERTEX lists\n" );
+ api_delent( copied_BODY_ptr );
+ copied_BODY_ptr = NULL;
+ return CUBIT_FAILURE;
+ }
- // Get the ACIS EDGES
- EDGE* EDGE_ptr1 = AcisQueryEngine::get_EDGE(ref_edge1);
- EDGE* EDGE_ptr2 = AcisQueryEngine::get_EDGE(ref_edge2);
- if (!EDGE_ptr1 || !EDGE_ptr2)
- return CUBIT_FAILURE;
+ // Re-sort the list into the proper order
+ temp_VERTEX_list.reset();
+ index_list.reset();
+ for( i=0; i<index_list.size(); i++ )
+ {
+ // Find the VERTEX with the corresponding index
+ index = index_list.where_is_item( i );
+ temp_VERTEX_list.reset();
+ temp_VERTEX_list.step( index );
- // Determine which curves are straight. Use this because some curves,
- // esp. from IGES, can be "straight" splines.
- bool straight1, straight2;
- straight1 = AcisQueryEngine::instance()->is_curve_app_straight( ref_edge1 );
- straight2 = AcisQueryEngine::instance()->is_curve_app_straight( ref_edge2 );
+ VERTEX_list.append( temp_VERTEX_list.get() );
+ }
- // If first is straight we need to find the plane to offset it in.
- CubitVector pln_norm;
- EDGE* offset_EDGE_ptr = NULL;
- if( straight1 )
- {
- // Need to find the plane normal to do offsets in
+ return CUBIT_SUCCESS;
+}
- // Get point normal form
- CubitVector orig1, dir1;
- if( ref_edge1->get_point_direction( orig1, dir1 ) == CUBIT_FAILURE )
- {
- // This must be a straight spline. Get it from endpoints.
- ref_edge1->position_from_fraction( 0.0, orig1 );
- CubitVector end_coords;
- ref_edge1->position_from_fraction( 1.0, end_coords );
- dir1 = end_coords - orig1;
- dir1.normalize();
- }
- if( straight2 )
- {
- // Get point normal form
- CubitVector orig2, dir2;
- if( ref_edge2->get_point_direction( orig2, dir2 ) == CUBIT_FAILURE )
- {
- // This must be a straight spline. Get it from endpoints.
- ref_edge2->position_from_fraction( 0.0, orig2 );
- CubitVector end_coords;
- ref_edge2->position_from_fraction( 1.0, end_coords );
- dir2 = end_coords - orig2;
- dir2.normalize();
- }
+CubitStatus
+AcisModifyEngine::get_copied_VERTICES_of_body(
+ DLIList<PointACIS*>& ref_vertex_list,
+ DLIList<VERTEX*>& VERTEX_list,
+ BODY*& copied_BODY_ptr ) const
+{
+ DLIList<PointACIS*> removed_vertices;
- // Find SPAvector from orig1 to orig2
- CubitVector vec1 = orig2 - orig1;
- vec1.normalize();
+ return get_copied_VERTICES_of_body( ref_vertex_list, VERTEX_list,
+ removed_vertices, copied_BODY_ptr );
+}
- // Cross dir1 with vec1 to get plane normal.
- pln_norm = dir1 * vec1;
- // Make sure this isn't a zero SPAvector.
- if( pln_norm.length() == 0.0 )
- {
- // Cross dir1 with dir2 to get plane normal
- pln_norm = dir1 * dir2;
- }
+GeometryQueryEngine *AcisModifyEngine::get_gqe()
+{
+ return AcisQueryEngine::instance();
+}
- if( pln_norm.length() == 0.0 )
- {
- PRINT_ERROR( "Unable to calculate plane that the curves lie in\n" );
- return CUBIT_FAILURE;
- }
- }
- else // EDGE2 is not straight
- {
- // Proper normal should be normal to curve, but check to see if EDGE 1 is on
- // this plane.
- CubitVector orig2;
- AcisQueryEngine::instance()->get_EDGE_normal( EDGE_ptr2, pln_norm );
+CubitBoolean AcisModifyEngine::is_modify_engine(const TopologyBridge *tb_ptr) const
+{
- double aln_orig[3], aln_vec[3], apln_orig[3], apln_norm[3];
+ if (CAST_TO(const_cast<TopologyBridge*>(tb_ptr), AcisBridge)) return CUBIT_TRUE;
+ else return CUBIT_FALSE;
+}
- AnalyticGeometryTool *agt = AnalyticGeometryTool::instance();
+CubitStatus
+AcisModifyEngine::get_offset_intersections( Curve* ref_edge1,
+ Curve* ref_edge2,
+ DLIList<CubitVector*>& intersection_list,
+ double offset_distance,
+ bool ext_first )
+{
+ int i;
+ //int done = 0;
+ bool bounded = !ext_first;
- agt->copy_pnt( orig1, aln_orig ); agt->copy_pnt( dir1, aln_vec );
- ref_edge2->position_from_fraction( 0.0, orig2 ); //
- ref_edge2->position_from_u(ref_edge2->start_param(),orig2);
- agt->copy_pnt( orig2, apln_orig );
- agt->copy_pnt( pln_norm, apln_norm );
+ // Get the ACIS EDGES
+ EDGE* EDGE_ptr1 = AcisQueryEngine::get_EDGE(ref_edge1);
+ EDGE* EDGE_ptr2 = AcisQueryEngine::get_EDGE(ref_edge2);
+ if (!EDGE_ptr1 || !EDGE_ptr2)
+ return CUBIT_FAILURE;
- if( !agt->is_ln_on_pln( aln_orig,aln_vec, apln_orig, apln_norm ) )
- {
- PRINT_ERROR( "Curve does not lie in the plane defined by Curve\n" );
- return CUBIT_FAILURE;
- }
- }
+ // Determine which curves are straight. Use this because some curves,
+ // esp. from IGES, can be "straight" splines.
+ bool straight1, straight2;
+ straight1 = AcisQueryEngine::instance()->is_curve_app_straight( ref_edge1 );
+ straight2 = AcisQueryEngine::instance()->is_curve_app_straight( ref_edge2 );
- // Get offset direction cross of plane normal and edge 1 direction
- CubitVector offset_dir = pln_norm*dir1;
+ // If first is straight we need to find the plane to offset it in.
+ CubitVector pln_norm;
+ EDGE* offset_EDGE_ptr = NULL;
+ if( straight1 )
+ {
+ // Need to find the plane normal to do offsets in
- // Do first side
- offset_EDGE_ptr = copy_and_move_EDGE( EDGE_ptr1, offset_dir, offset_distance );
- if( offset_EDGE_ptr == NULL )
- {
- PRINT_ERROR( "unable to offset Curve for intersection calculation\n" );
- return CUBIT_FAILURE;
- }
+ // Get point normal form
+ CubitVector orig1, dir1;
+ if( ref_edge1->get_point_direction( orig1, dir1 ) == CUBIT_FAILURE )
+ {
+ // This must be a straight spline. Get it from endpoints.
+ ref_edge1->position_from_fraction( 0.0, orig1 );
+ CubitVector end_coords;
+ ref_edge1->position_from_fraction( 1.0, end_coords );
+ dir1 = end_coords - orig1;
+ dir1.normalize();
+ }
+ if( straight2 )
+ {
+ // Get point normal form
+ CubitVector orig2, dir2;
+ if( ref_edge2->get_point_direction( orig2, dir2 ) == CUBIT_FAILURE )
+ {
+ // This must be a straight spline. Get it from endpoints.
+ ref_edge2->position_from_fraction( 0.0, orig2 );
+ CubitVector end_coords;
+ ref_edge2->position_from_fraction( 1.0, end_coords );
+ dir2 = end_coords - orig2;
+ dir2.normalize();
+ }
- if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2,
- intersection_list, bounded ) ==
- CUBIT_FAILURE )
- {
- PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
- api_delent( offset_EDGE_ptr );
- return CUBIT_FAILURE;
- }
+ // Find SPAvector from orig1 to orig2
+ CubitVector vec1 = orig2 - orig1;
+ vec1.normalize();
- api_delent( offset_EDGE_ptr );
+ // Cross dir1 with vec1 to get plane normal.
+ pln_norm = dir1 * vec1;
- // Do second side
- if( offset_distance != 0.0 )
- {
- offset_dir = -offset_dir;
- offset_EDGE_ptr = copy_and_move_EDGE( EDGE_ptr1, offset_dir, offset_distance );
- if( offset_EDGE_ptr == NULL )
- {
- PRINT_ERROR( "unable to offset Curve for intersection calculation\n" );
- return CUBIT_FAILURE;
- }
+ // Make sure this isn't a zero SPAvector.
+ if( pln_norm.length() == 0.0 )
+ {
+ // Cross dir1 with dir2 to get plane normal
+ pln_norm = dir1 * dir2;
+ }
- if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
- {
- api_delent( offset_EDGE_ptr );
- PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
- return CUBIT_FAILURE;
- }
+ if( pln_norm.length() == 0.0 )
+ {
+ PRINT_ERROR( "Unable to calculate plane that the curves lie in\n" );
+ return CUBIT_FAILURE;
+ }
+ }
+ else // EDGE2 is not straight
+ {
+ // Proper normal should be normal to curve, but check to see if EDGE 1 is on
+ // this plane.
+ CubitVector orig2;
+ AcisQueryEngine::instance()->get_EDGE_normal( EDGE_ptr2, pln_norm );
- api_delent( offset_EDGE_ptr );
- }
+ double aln_orig[3], aln_vec[3], apln_orig[3], apln_norm[3];
- }
- else if( offset_distance != 0.0 )
- {
- // If there is an offset, offset the first curve to each "side" of the original
- // and do the intersections - i.e., try each side. Note we already handled the
- // special case if the first curve is straight.
+ AnalyticGeometryTool *agt = AnalyticGeometryTool::instance();
- // Do first side
- DLIList<EDGE*> EDGE_list;
- DLIList<EDGE*> new_EDGE_list;
+ agt->copy_pnt( orig1, aln_orig ); agt->copy_pnt( dir1, aln_vec );
+ ref_edge2->position_from_fraction( 0.0, orig2 ); //
+ ref_edge2->position_from_u(ref_edge2->start_param(),orig2);
+ agt->copy_pnt( orig2, apln_orig );
+ agt->copy_pnt( pln_norm, apln_norm );
- EDGE_list.append( EDGE_ptr1 );
- if( offset_EDGES( EDGE_list, offset_distance, 1, new_EDGE_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to offset the curves\n" );
- return CUBIT_FAILURE;
- }
+ if( !agt->is_ln_on_pln( aln_orig,aln_vec, apln_orig, apln_norm ) )
+ {
+ PRINT_ERROR( "Curve does not lie in the plane defined by Curve\n" );
+ return CUBIT_FAILURE;
+ }
+ }
- // Note: the new_EDGE_list can have more curves in it than EDGE_list
- for( i=0; i<new_EDGE_list.size(); i++ )
- {
- offset_EDGE_ptr = new_EDGE_list.get_and_step();
- if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr,
- EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
- {
- api_delent( offset_EDGE_ptr );
- PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
- return CUBIT_FAILURE;
- }
- api_delent( offset_EDGE_ptr );
- }
+ // Get offset direction cross of plane normal and edge 1 direction
+ CubitVector offset_dir = pln_norm*dir1;
- new_EDGE_list.clean_out();
+ // Do first side
+ offset_EDGE_ptr = copy_and_move_EDGE( EDGE_ptr1, offset_dir, offset_distance );
+ if( offset_EDGE_ptr == NULL )
+ {
+ PRINT_ERROR( "unable to offset Curve for intersection calculation\n" );
+ return CUBIT_FAILURE;
+ }
- // Do other side
- if( offset_EDGES( EDGE_list, -offset_distance, 1, new_EDGE_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "Unable to offset the curves\n" );
- return CUBIT_FAILURE;
- }
+ if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2,
+ intersection_list, bounded ) ==
+ CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
+ api_delent( offset_EDGE_ptr );
+ return CUBIT_FAILURE;
+ }
- for( i=0; i<new_EDGE_list.size(); i++ )
- {
- offset_EDGE_ptr = new_EDGE_list.get_and_step();
- if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
- {
- api_delent( offset_EDGE_ptr );
- PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
- return CUBIT_FAILURE;
- }
- api_delent( offset_EDGE_ptr );
- }
+ api_delent( offset_EDGE_ptr );
- new_EDGE_list.clean_out();
+ // Do second side
+ if( offset_distance != 0.0 )
+ {
+ offset_dir = -offset_dir;
+ offset_EDGE_ptr = copy_and_move_EDGE( EDGE_ptr1, offset_dir, offset_distance );
+ if( offset_EDGE_ptr == NULL )
+ {
+ PRINT_ERROR( "unable to offset Curve for intersection calculation\n" );
+ return CUBIT_FAILURE;
+ }
- }
- else
- {
- // Just get the intersections
- if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr1, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
- {
- PRINT_ERROR( "unable to calculate intersections of Curves\n" );
- return CUBIT_FAILURE;
- }
- }
+ if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
+ {
+ api_delent( offset_EDGE_ptr );
+ PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
+ return CUBIT_FAILURE;
+ }
- // Cull out any points that are not on bounds of RefEdge 2
- if( bounded == CUBIT_FALSE )
- {
- CubitVector *vec_ptr;
- for( i=0; i<intersection_list.size(); i++ )
- {
- vec_ptr = intersection_list.get();
+ api_delent( offset_EDGE_ptr );
+ }
- if( ref_edge2->point_containment( *vec_ptr ) == CUBIT_PNT_OFF )
- {
- delete vec_ptr;
- intersection_list.remove();
- }
- else
- intersection_list.step();
- }
- }
+ }
+ else if( offset_distance != 0.0 )
+ {
+ // If there is an offset, offset the first curve to each "side" of the original
+ // and do the intersections - i.e., try each side. Note we already handled the
+ // special case if the first curve is straight.
- return CUBIT_SUCCESS;
- }
+ // Do first side
+ DLIList<EDGE*> EDGE_list;
+ DLIList<EDGE*> new_EDGE_list;
- CubitStatus
- AcisModifyEngine::get_offset_intersections( Curve* ref_edge_ptr,
- Surface* ref_face_ptr,
- DLIList<CubitVector*> &intersection_list,
- double offset_distance,
- bool ext_surf )
- {
- outcome result;
+ EDGE_list.append( EDGE_ptr1 );
+ if( offset_EDGES( EDGE_list, offset_distance, 1, new_EDGE_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to offset the curves\n" );
+ return CUBIT_FAILURE;
+ }
- EDGE* EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge_ptr);
- FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face_ptr);
- if (!EDGE_ptr || !FACE_ptr)
- return CUBIT_FAILURE;
+ // Note: the new_EDGE_list can have more curves in it than EDGE_list
+ for( i=0; i<new_EDGE_list.size(); i++ )
+ {
+ offset_EDGE_ptr = new_EDGE_list.get_and_step();
+ if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr,
+ EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
+ {
+ api_delent( offset_EDGE_ptr );
+ PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
+ return CUBIT_FAILURE;
+ }
+ api_delent( offset_EDGE_ptr );
+ }
- // If there is an offset, offset the surface to each "side" of the original
- // and do the intersections - i.e., try each side.
- if( offset_distance != 0.0 )
- {
- FACE* offset_FACE_ptr = NULL;
+ new_EDGE_list.clean_out();
- result = api_offset_face ( FACE_ptr, offset_distance, offset_FACE_ptr );
+ // Do other side
+ if( offset_EDGES( EDGE_list, -offset_distance, 1, new_EDGE_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Unable to offset the curves\n" );
+ return CUBIT_FAILURE;
+ }
- if( offset_FACE_ptr == NULL )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to offset surface\n" );
- return CUBIT_FAILURE;
- }
+ for( i=0; i<new_EDGE_list.size(); i++ )
+ {
+ offset_EDGE_ptr = new_EDGE_list.get_and_step();
+ if( AcisQueryEngine::instance()->get_intersections( offset_EDGE_ptr, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
+ {
+ api_delent( offset_EDGE_ptr );
+ PRINT_ERROR( "unable to calculate intersections of offset Curves\n" );
+ return CUBIT_FAILURE;
+ }
+ api_delent( offset_EDGE_ptr );
+ }
- // This creates a FACE from the given FACE, only it can be extended out.
- FACE* ext_offset_FACE_ptr = make_FACE( offset_FACE_ptr, ext_surf );
- BODY *ext_offset_BODY_ptr =
- AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_offset_FACE_ptr );
+ new_EDGE_list.clean_out();
- if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_offset_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR("Problems finding intersections of curve and surface.\n");
- api_delent( offset_FACE_ptr );
- api_delent( ext_offset_BODY_ptr );
- return CUBIT_FAILURE;
- }
+ }
+ else
+ {
+ // Just get the intersections
+ if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr1, EDGE_ptr2, intersection_list, bounded ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "unable to calculate intersections of Curves\n" );
+ return CUBIT_FAILURE;
+ }
+ }
- api_delent( offset_FACE_ptr ); offset_FACE_ptr = NULL;
- api_delent( ext_offset_BODY_ptr ); ext_offset_BODY_ptr = NULL;
- ext_offset_FACE_ptr = NULL;
+ // Cull out any points that are not on bounds of RefEdge 2
+ if( bounded == CUBIT_FALSE )
+ {
+ CubitVector *vec_ptr;
+ for( i=0; i<intersection_list.size(); i++ )
+ {
+ vec_ptr = intersection_list.get();
- // Try other side
- result = api_offset_face ( FACE_ptr, -offset_distance, offset_FACE_ptr );
+ if( ref_edge2->point_containment( *vec_ptr ) == CUBIT_PNT_OFF )
+ {
+ delete vec_ptr;
+ intersection_list.remove();
+ }
+ else
+ intersection_list.step();
+ }
+ }
- if( offset_FACE_ptr == NULL )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "Unable to offset surface\n" );
- return CUBIT_FAILURE;
- }
+ return CUBIT_SUCCESS;
+}
- // This creates a FACE from the given FACE, only it is extended out.
- ext_offset_FACE_ptr = make_FACE( offset_FACE_ptr, CUBIT_TRUE );
- ext_offset_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_offset_FACE_ptr );
+CubitStatus
+AcisModifyEngine::get_offset_intersections( Curve* ref_edge_ptr,
+ Surface* ref_face_ptr,
+ DLIList<CubitVector*> &intersection_list,
+ double offset_distance,
+ bool ext_surf )
+{
+ outcome result;
- if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_offset_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR("Problems finding intersections of curve and surface.\n" );
- api_delent( offset_FACE_ptr );
- api_delent( ext_offset_BODY_ptr );
- return CUBIT_FAILURE;
- }
+ EDGE* EDGE_ptr = AcisQueryEngine::get_EDGE(ref_edge_ptr);
+ FACE* FACE_ptr = AcisQueryEngine::get_FACE(ref_face_ptr);
+ if (!EDGE_ptr || !FACE_ptr)
+ return CUBIT_FAILURE;
- api_delent( offset_FACE_ptr );
- api_delent( ext_offset_BODY_ptr );
- }
- else
- {
- FACE* ext_FACE_ptr = make_FACE( FACE_ptr, ext_surf );
- BODY *ext_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_FACE_ptr );
- if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
- {
- PRINT_ERROR("Problems finding intersections of curve and surface.\n" );
- api_delent( ext_BODY_ptr );
- return CUBIT_FAILURE;
- }
- api_delent( ext_BODY_ptr );
- }
+ // If there is an offset, offset the surface to each "side" of the original
+ // and do the intersections - i.e., try each side.
+ if( offset_distance != 0.0 )
+ {
+ FACE* offset_FACE_ptr = NULL;
- return CUBIT_SUCCESS;
- }
+ result = api_offset_face ( FACE_ptr, offset_distance, offset_FACE_ptr );
- EDGE *
- AcisModifyEngine::copy_and_move_EDGE( EDGE *EDGE_ptr,
- const CubitVector &input_dir,
- double dist )
- {
- // Setup translation transform
- SPAtransf tr;
- CubitVector dir(input_dir);
- dir.normalize(); // For now, allow this SPAvector to be modified
- CubitVector delta = dist*dir;
- SPAvector vec(delta.x(), delta.y(), delta.z() );
- tr = translate_transf( vec );
+ if( offset_FACE_ptr == NULL )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to offset surface\n" );
+ return CUBIT_FAILURE;
+ }
- EDGE* new_EDGE_ptr;
- outcome result = api_trans_edge( EDGE_ptr, tr, new_EDGE_ptr );
- if (!result.ok())
- {
- AcisQueryEngine::instance()->ACIS_API_error( result );
- return NULL;
- }
+ // This creates a FACE from the given FACE, only it can be extended out.
+ FACE* ext_offset_FACE_ptr = make_FACE( offset_FACE_ptr, ext_surf );
+ BODY *ext_offset_BODY_ptr =
+ AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_offset_FACE_ptr );
- // Remove the CUBIT owner attributes from the new edge
- ATTRIB_CUBIT_OWNER::remove_cubit_owner((ENTITY*)new_EDGE_ptr, CUBIT_TRUE);
+ if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_offset_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Problems finding intersections of curve and surface.\n");
+ api_delent( offset_FACE_ptr );
+ api_delent( ext_offset_BODY_ptr );
+ return CUBIT_FAILURE;
+ }
- return new_EDGE_ptr;
- }
+ api_delent( offset_FACE_ptr ); offset_FACE_ptr = NULL;
+ api_delent( ext_offset_BODY_ptr ); ext_offset_BODY_ptr = NULL;
+ ext_offset_FACE_ptr = NULL;
- CubitStatus
- AcisModifyEngine::offset_EDGES( DLIList<EDGE*> &EDGE_list,
- double offset_distance,
- int gap_type,
- DLIList<EDGE*> &new_EDGE_list )
- {
- int i;
- EDGE *EDGE_ptr = NULL;
- //ENTITY *ENTITY_ptr = NULL;
- EDGE *tmp_EDGE_ptr = NULL;
+ // Try other side
+ result = api_offset_face ( FACE_ptr, -offset_distance, offset_FACE_ptr );
- // Need to create a wire from the EDGEs
+ if( offset_FACE_ptr == NULL )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "Unable to offset surface\n" );
+ return CUBIT_FAILURE;
+ }
- // Copy them first
- int edge_count = EDGE_list.size();
- EDGE** EDGEs = new EDGE*[edge_count];
+ // This creates a FACE from the given FACE, only it is extended out.
+ ext_offset_FACE_ptr = make_FACE( offset_FACE_ptr, CUBIT_TRUE );
+ ext_offset_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_offset_FACE_ptr );
- EDGE_list.reset();
- for( i=0; i<EDGE_list.size(); i++ )
- {
- EDGE_ptr = EDGE_list.get_and_step();
+ if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_offset_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Problems finding intersections of curve and surface.\n" );
+ api_delent( offset_FACE_ptr );
+ api_delent( ext_offset_BODY_ptr );
+ return CUBIT_FAILURE;
+ }
- api_edge( EDGE_ptr, tmp_EDGE_ptr );
+ api_delent( offset_FACE_ptr );
+ api_delent( ext_offset_BODY_ptr );
+ }
+ else
+ {
+ FACE* ext_FACE_ptr = make_FACE( FACE_ptr, ext_surf );
+ BODY *ext_BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( ext_FACE_ptr );
+ if( AcisQueryEngine::instance()->get_intersections( EDGE_ptr, ext_FACE_ptr, intersection_list ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR("Problems finding intersections of curve and surface.\n" );
+ api_delent( ext_BODY_ptr );
+ return CUBIT_FAILURE;
+ }
+ api_delent( ext_BODY_ptr );
+ }
- EDGEs[i] = tmp_EDGE_ptr;
+ return CUBIT_SUCCESS;
+}
- // Remove the owner attribute from the copied edge & children
- ATTRIB_CUBIT_OWNER::remove_cubit_owner(EDGEs[i], CUBIT_TRUE);
- }
+EDGE *
+AcisModifyEngine::copy_and_move_EDGE( EDGE *EDGE_ptr,
+ const CubitVector &input_dir,
+ double dist )
+{
+ // Setup translation transform
+ SPAtransf tr;
+ CubitVector dir(input_dir);
+ dir.normalize(); // For now, allow this SPAvector to be modified
+ CubitVector delta = dist*dir;
+ SPAvector vec(delta.x(), delta.y(), delta.z() );
+ tr = translate_transf( vec );
- // The EDGEs are put into the wire so don't delete them.
- BODY* wire_BODY = NULL;
- outcome result = api_make_ewire( edge_count, EDGEs, wire_BODY );
+ EDGE* new_EDGE_ptr;
+ outcome result = api_trans_edge( EDGE_ptr, tr, new_EDGE_ptr );
+ if (!result.ok())
+ {
+ AcisQueryEngine::instance()->ACIS_API_error( result );
+ return NULL;
+ }
- if( !result.ok() || wire_BODY==NULL )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "unable to make ACIS wire body from curves\n" );
- if( wire_BODY )
- api_delent( (ENTITY*)wire_BODY );
- else
- {
- for( i=0; i<edge_count; i++)
- api_delent( (ENTITY*)EDGEs[i] );
- }
- return CUBIT_FAILURE;
- }
+ // Remove the CUBIT owner attributes from the new edge
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner((ENTITY*)new_EDGE_ptr, CUBIT_TRUE);
- //The gap type is as follows; 0 = rounded like arcs, 1 = extended like lines, and 2 =
- //natural like curve extensions. Lines are extend with lines and circles are extended with
- //circles.
+ return new_EDGE_ptr;
+}
- law* offset_law = new constant_law( offset_distance );
- law *twist_law=NULL;
- BODY* offset_WIRE;
- logical trim_flg = TRUE;
+CubitStatus
+AcisModifyEngine::offset_EDGES( DLIList<EDGE*> &EDGE_list,
+ double offset_distance,
+ int gap_type,
+ DLIList<EDGE*> &new_EDGE_list )
+{
+ int i;
+ EDGE *EDGE_ptr = NULL;
+ //ENTITY *ENTITY_ptr = NULL;
+ EDGE *tmp_EDGE_ptr = NULL;
- // need to check if wire is planar and calculate the
- // normal to the plane
- WIRE* this_wire = wire_BODY->wire() ?
- wire_BODY->wire() : wire_BODY->lump()->shell()->wire();
+ // Need to create a wire from the EDGEs
- SPAposition centroid;
- SPAunit_vector normal;
- if(!is_planar_wire(this_wire, centroid, normal))
- {
- PRINT_ERROR("selected curves do not form a planar chain\n");
- api_delent( (ENTITY*)wire_BODY );
- return CUBIT_FAILURE;
- }
+ // Copy them first
+ int edge_count = EDGE_list.size();
+ EDGE** EDGEs = new EDGE*[edge_count];
- // Offset the wire to get the new curves
- result = api_offset_planar_wire( wire_BODY, offset_law, twist_law,
- normal, offset_WIRE, gap_type, trim_flg );
+ EDGE_list.reset();
+ for( i=0; i<EDGE_list.size(); i++ )
+ {
+ EDGE_ptr = EDGE_list.get_and_step();
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_ERROR( "unable to offset wire volume\n" );
- api_delent( (ENTITY*)wire_BODY );
- return CUBIT_FAILURE;
- }
+ api_edge( EDGE_ptr, tmp_EDGE_ptr );
- // Copy out the EDGES from the WIRE, then delete the WIRE
- DLIList<EDGE*> wire_edge_list;
- AcisQueryEngine::instance()->get_EDGEs( (ENTITY *)offset_WIRE, wire_edge_list );
+ EDGEs[i] = tmp_EDGE_ptr;
- // Sometimes the function works but we don't get any edges
- if( !wire_edge_list.size() )
- {
- api_delent( (ENTITY*)wire_BODY );
- return CUBIT_FAILURE;
- }
+ // Remove the owner attribute from the copied edge & children
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner(EDGEs[i], CUBIT_TRUE);
+ }
- wire_edge_list.reset();
- EDGE *new_EDGE_ptr;
- for( i=0; i<wire_edge_list.size(); i++ )
- {
- EDGE_ptr = wire_edge_list.get_and_step();
+ // The EDGEs are put into the wire so don't delete them.
+ BODY* wire_BODY = NULL;
+ outcome result = api_make_ewire( edge_count, EDGEs, wire_BODY );
- result = api_edge( EDGE_ptr, new_EDGE_ptr );
- if( !result.ok() )
- {
- AcisQueryEngine::instance()->ACIS_API_error(result);
- PRINT_INFO( "Unable to copy curve from new WIRE\n" );
- api_delent( (ENTITY*)wire_BODY );
- return CUBIT_FAILURE;
- }
+ if( !result.ok() || wire_BODY==NULL )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "unable to make ACIS wire body from curves\n" );
+ if( wire_BODY )
+ api_delent( (ENTITY*)wire_BODY );
+ else
+ {
+ for( i=0; i<edge_count; i++)
+ api_delent( (ENTITY*)EDGEs[i] );
+ }
+ return CUBIT_FAILURE;
+ }
- new_EDGE_list.append( new_EDGE_ptr );
- }
+ //The gap type is as follows; 0 = rounded like arcs, 1 = extended like lines, and 2 =
+ //natural like curve extensions. Lines are extend with lines and circles are extended with
+ //circles.
- // Delete the WIRE
+ law* offset_law = new constant_law( offset_distance );
+ law *twist_law=NULL;
+ BODY* offset_WIRE;
+ logical trim_flg = TRUE;
+
+ // need to check if wire is planar and calculate the
+ // normal to the plane
+ WIRE* this_wire = wire_BODY->wire() ?
+ wire_BODY->wire() : wire_BODY->lump()->shell()->wire();
+
+ SPAposition centroid;
+ SPAunit_vector normal;
+ if(!is_planar_wire(this_wire, centroid, normal))
+ {
+ PRINT_ERROR("selected curves do not form a planar chain\n");
api_delent( (ENTITY*)wire_BODY );
+ return CUBIT_FAILURE;
+ }
- return CUBIT_SUCCESS;
- }
+ // Offset the wire to get the new curves
+ result = api_offset_planar_wire( wire_BODY, offset_law, twist_law,
+ normal, offset_WIRE, gap_type, trim_flg );
- Curve* AcisModifyEngine::find_curve_by_end_coord( const CubitVector& coords,
- DLIList<Curve*>& curves,
- bool& start_flag ) const
- {
- Curve* curve = 0;
- CubitVector curve_pt;
- const double tol = AcisQueryEngine::instance()->get_sme_resabs_tolerance();
- const double tolsqr = tol*tol;
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_ERROR( "unable to offset wire volume\n" );
+ api_delent( (ENTITY*)wire_BODY );
+ return CUBIT_FAILURE;
+ }
- DLIList<Curve*> tmp_list(curves);
- tmp_list.reset();
- for ( int i = curves.size(); i--; )
- {
- curve = tmp_list.get_and_step();
+ // Copy out the EDGES from the WIRE, then delete the WIRE
+ DLIList<EDGE*> wire_edge_list;
+ AcisQueryEngine::instance()->get_EDGEs( (ENTITY *)offset_WIRE, wire_edge_list );
- curve->position_from_fraction( 0.0, curve_pt );
- if ( (curve_pt - coords).length_squared() < tolsqr )
- {
- start_flag = true;
- return curve;
- }
+ // Sometimes the function works but we don't get any edges
+ if( !wire_edge_list.size() )
+ {
+ api_delent( (ENTITY*)wire_BODY );
+ return CUBIT_FAILURE;
+ }
- curve->position_from_fraction( 1.0, curve_pt );
- if ( (curve_pt - coords).length_squared() < tolsqr )
- {
- start_flag = false;
- return curve;
- }
- }
+ wire_edge_list.reset();
+ EDGE *new_EDGE_ptr;
+ for( i=0; i<wire_edge_list.size(); i++ )
+ {
+ EDGE_ptr = wire_edge_list.get_and_step();
- return 0;
- }
+ result = api_edge( EDGE_ptr, new_EDGE_ptr );
+ if( !result.ok() )
+ {
+ AcisQueryEngine::instance()->ACIS_API_error(result);
+ PRINT_INFO( "Unable to copy curve from new WIRE\n" );
+ api_delent( (ENTITY*)wire_BODY );
+ return CUBIT_FAILURE;
+ }
- bool AcisModifyEngine::bridge_deactivated(AcisBridge* bridge) const
- {
- return deactivatedSet.count(bridge) > 0;
- }
+ new_EDGE_list.append( new_EDGE_ptr );
+ }
- CubitStatus AcisModifyEngine::deactivate_bridge( AcisBridge* bridge ) const
+ // Delete the WIRE
+ api_delent( (ENTITY*)wire_BODY );
+
+ return CUBIT_SUCCESS;
+}
+
+Curve* AcisModifyEngine::find_curve_by_end_coord( const CubitVector& coords,
+ DLIList<Curve*>& curves,
+ bool& start_flag ) const
+{
+ Curve* curve = 0;
+ CubitVector curve_pt;
+ const double tol = AcisQueryEngine::instance()->get_sme_resabs_tolerance();
+ const double tolsqr = tol*tol;
+
+ DLIList<Curve*> tmp_list(curves);
+ tmp_list.reset();
+ for ( int i = curves.size(); i--; )
+ {
+ curve = tmp_list.get_and_step();
+
+ curve->position_from_fraction( 0.0, curve_pt );
+ if ( (curve_pt - coords).length_squared() < tolsqr )
{
- AcisModifyEngine* nonconst = AcisModifyEngine::instance();
- bool unique = nonconst->deactivatedSet.insert(bridge).second;
- return (CubitStatus)unique;
+ start_flag = true;
+ return curve;
}
- CubitStatus AcisModifyEngine::reactivate_bridge( AcisBridge* bridge ) const
+ curve->position_from_fraction( 1.0, curve_pt );
+ if ( (curve_pt - coords).length_squared() < tolsqr )
{
- AcisModifyEngine* nonconst = AcisModifyEngine::instance();
- int count = nonconst->deactivatedSet.erase(bridge);
- return count > 0 ? CUBIT_SUCCESS : CUBIT_FAILURE;
+ start_flag = false;
+ return curve;
}
+ }
- void AcisModifyEngine::cleanout_deactivated_geometry() const
- {
- AcisModifyEngine* nonconst = AcisModifyEngine::instance();
- // std::set<AcisBridge*>::iterator itor = nonconst->deactivatedSet.begin(),
- // end = nonconst->deactivatedSet.end();
- // for ( ; itor != end; ++itor )
- // delete *itor;
+ return 0;
+}
- nonconst->deactivatedSet.clear();
- }
+bool AcisModifyEngine::bridge_deactivated(AcisBridge* bridge) const
+{
+ return deactivatedSet.count(bridge) > 0;
+}
- CubitStatus AcisModifyEngine::scale( BodySM *&body, const CubitVector& f )
- {
+CubitStatus AcisModifyEngine::deactivate_bridge( AcisBridge* bridge ) const
+{
+ AcisModifyEngine* nonconst = AcisModifyEngine::instance();
+ bool unique = nonconst->deactivatedSet.insert(bridge).second;
+ return (CubitStatus)unique;
+}
+
+CubitStatus AcisModifyEngine::reactivate_bridge( AcisBridge* bridge ) const
+{
+ AcisModifyEngine* nonconst = AcisModifyEngine::instance();
+ int count = nonconst->deactivatedSet.erase(bridge);
+ return count > 0 ? CUBIT_SUCCESS : CUBIT_FAILURE;
+}
+
+void AcisModifyEngine::cleanout_deactivated_geometry() const
+{
+ AcisModifyEngine* nonconst = AcisModifyEngine::instance();
+// std::set<AcisBridge*>::iterator itor = nonconst->deactivatedSet.begin(),
+// end = nonconst->deactivatedSet.end();
+// for ( ; itor != end; ++itor )
+// delete *itor;
+
+ nonconst->deactivatedSet.clear();
+}
+
+CubitStatus AcisModifyEngine::scale( BodySM *&body, const CubitVector& f )
+{
#if CUBIT_ACIS_VERSION < 1100
- api_initialize_operators();
+ api_initialize_operators();
#elif defined(WIN32) || defined(MACOSX)
- api_initialize_warp();
+ api_initialize_warp();
#endif
- BODY *new_BODY = NULL;
+ BODY *new_BODY = NULL;
- if( f.x() != f.y() ||
- f.x() != f.z() ||
- f.y() != f.z() )
- {
- BODY *tmp_BODY = AcisQueryEngine::get_BODY( body );
- new_BODY = AcisModifyEngine::instance()->copy_BODY(tmp_BODY,
- GeometryModifyTool::instance()->get_new_ids());
- }
+ if( f.x() != f.y() ||
+ f.x() != f.z() ||
+ f.y() != f.z() )
+ {
+ BODY *tmp_BODY = AcisQueryEngine::get_BODY( body );
+ new_BODY = AcisModifyEngine::instance()->copy_BODY(tmp_BODY,
+ GeometryModifyTool::instance()->get_new_ids());
+ }
- CubitStatus result = AcisQueryEngine::instance()->transform( new_BODY, scale_transf( f.x(), f.y(), f.z() ) );
+ CubitStatus result = AcisQueryEngine::instance()->transform( new_BODY, scale_transf( f.x(), f.y(), f.z() ) );
#if CUBIT_ACIS_VERSION < 1100
- api_terminate_operators();
+ api_terminate_operators();
#elif defined(WIN32) || defined(MACOSX)
- api_terminate_warp();
+ api_terminate_warp();
#endif
- if( new_BODY )
- {
- BODY *old_BODY = AcisQueryEngine::get_BODY( body );
- BodySM *new_body = get_new_Body( body, old_BODY, new_BODY, false);
- body = new_body;
- }
+ if( new_BODY )
+ {
+ BODY *old_BODY = AcisQueryEngine::get_BODY( body );
+ BodySM *new_body = get_new_Body( body, old_BODY, new_BODY, false);
+ body = new_body;
+ }
- return result;
- }
+ return result;
+}
- CubitStatus AcisModifyEngine::tolerant_imprint( DLIList<BodySM*> &bodies_in,
- DLIList<BodySM*> &new_bodies,
+CubitStatus AcisModifyEngine::tolerant_imprint( DLIList<BodySM*> &bodies_in,
+ DLIList<BodySM*> &new_bodies,
DLIList<TopologyBridge*> *new_tbs,
DLIList<TopologyBridge*> *att_tbs ) const
- {
- //make sure all bodies are from the same modify engine
- DLIList<BodySM*> new_body_list;
+{
+ //make sure all bodies are from the same modify engine
+ DLIList<BodySM*> new_body_list;
- ProgressTool *progress_tool = NULL;
- if( bodies_in.size() > 2 )
- {
- progress_tool = AppUtil::instance()->progress_tool();
- progress_tool->start(0, 100, "Tolerant Imprinting" );
- }
+ ProgressTool *progress_tool = NULL;
+ if( bodies_in.size() > 2 )
+ {
+ progress_tool = AppUtil::instance()->progress_tool();
+ progress_tool->start(0, 100, "Tolerant Imprinting" );
+ }
- CubitStatus status = imprint_overlapping_curves( bodies_in, new_body_list, progress_tool );
+ CubitStatus status = imprint_overlapping_curves( bodies_in, new_body_list, progress_tool );
- status = imprint_overlapping_surfaces( bodies_in, new_body_list, progress_tool );
+ status = imprint_overlapping_surfaces( bodies_in, new_body_list, progress_tool );
- status = imprint_overlapping_curves( bodies_in, new_body_list, progress_tool, new_tbs, att_tbs );
+ status = imprint_overlapping_curves( bodies_in, new_body_list, progress_tool, new_tbs, att_tbs );
- if( progress_tool )
- progress_tool->end();
+ if( progress_tool )
+ progress_tool->end();
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
- CubitStatus AcisModifyEngine::imprint_overlapping_curves( DLIList<BodySM*> &body_sms,
- DLIList<BodySM*> &new_body_sms,
- ProgressTool *progress_tool,
- DLIList<TopologyBridge*> *new_tbs,
- DLIList<TopologyBridge*> *att_tbs ) const
- {
- //find all mergeable curves between the bodies
- CubitStatus status;
+CubitStatus AcisModifyEngine::imprint_overlapping_curves( DLIList<BodySM*> &body_sms,
+ DLIList<BodySM*> &new_body_sms,
+ ProgressTool *progress_tool,
+ DLIList<TopologyBridge*> *new_tbs,
+ DLIList<TopologyBridge*> *att_tbs ) const
+{
+ //find all mergeable curves between the bodies
+ CubitStatus status;
#ifdef BOYD16
- DLIList<RefEntity*> entities;
+ DLIList<RefEntity*> entities;
#endif
- DLIList< DLIList<Curve*>* > lists_of_mergeable_curves;
+ DLIList< DLIList<Curve*>* > lists_of_mergeable_curves;
- status = MergeTool::instance()->find_only_mergeable_curves( body_sms, lists_of_mergeable_curves );
+ status = MergeTool::instance()->find_only_mergeable_curves( body_sms, lists_of_mergeable_curves );
- int i,j;
- //increment 4%
- if( progress_tool )
- {
- for( i=4; i--; )
- progress_tool->step();
- }
+ int i,j;
+ //increment 4%
+ if( progress_tool )
+ {
+ for( i=4; i--; )
+ progress_tool->step();
+ }
- //find all overlapping curves between the bodies
- std::map<Curve*, DLIList<Curve*>* > curve_to_list_map;
- DLIList< DLIList<Curve*>* > lists_of_overlapping_curves;
- //for each list, curves 2-n overlap the first curve
+ //find all overlapping curves between the bodies
+ std::map<Curve*, DLIList<Curve*>* > curve_to_list_map;
+ DLIList< DLIList<Curve*>* > lists_of_overlapping_curves;
+ //for each list, curves 2-n overlap the first curve
- SurfaceOverlapTool::instance()->find_overlapping_curves( body_sms, lists_of_overlapping_curves,
- curve_to_list_map );
+ SurfaceOverlapTool::instance()->find_overlapping_curves( body_sms, lists_of_overlapping_curves,
+ curve_to_list_map );
- //increment 8%
- if( progress_tool )
- {
- for( i=9; i--; )
- progress_tool->step();
- }
+ //increment 8%
+ if( progress_tool )
+ {
+ for( i=9; i--; )
+ progress_tool->step();
+ }
- //remove idential groups and sub-groups of mergeable curves from
- //overlapping groups. For example: If curves A,B,C,D are in a mergeable group
- //the following groups will have no need for imprinting, becasue the curves are
- //mergeable all
- //A,B,C,D
- //B,C,D is a sub-group
- //C,D is a sub-group
- //These groups need not be considered for imprinting
+ //remove idential groups and sub-groups of mergeable curves from
+ //overlapping groups. For example: If curves A,B,C,D are in a mergeable group
+ //the following groups will have no need for imprinting, becasue the curves are
+ //mergeable all
+ //A,B,C,D
+ //B,C,D is a sub-group
+ //C,D is a sub-group
+ //These groups need not be considered for imprinting
- std::map<Curve*, DLIList<Curve*>*>::iterator curve_iter;
- lists_of_mergeable_curves.reset();
+ std::map<Curve*, DLIList<Curve*>*>::iterator curve_iter;
+ lists_of_mergeable_curves.reset();
- DLIList< DLIList<Curve*>* > lists_to_delete;
+ DLIList< DLIList<Curve*>* > lists_to_delete;
- for( i=lists_of_mergeable_curves.size(); i--; )
- {
- DLIList<Curve*> *mergeable_curve_list = lists_of_mergeable_curves.get_and_step();
+ for( i=lists_of_mergeable_curves.size(); i--; )
+ {
+ DLIList<Curve*> *mergeable_curve_list = lists_of_mergeable_curves.get_and_step();
- for( j=mergeable_curve_list->size(); j--; )
- {
- Curve *tmp_curve = mergeable_curve_list->get_and_step();
- curve_iter = curve_to_list_map.find( tmp_curve );
+ for( j=mergeable_curve_list->size(); j--; )
+ {
+ Curve *tmp_curve = mergeable_curve_list->get_and_step();
+ curve_iter = curve_to_list_map.find( tmp_curve );
- if( curve_iter == curve_to_list_map.end() )
- continue;
+ if( curve_iter == curve_to_list_map.end() )
+ continue;
- DLIList<Curve*>* overlapping_curves = curve_iter->second;
+ DLIList<Curve*>* overlapping_curves = curve_iter->second;
- //make sure that list hasn't already been removed
- if( lists_to_delete.move_to( overlapping_curves ) )
- continue;
+ //make sure that list hasn't already been removed
+ if( lists_to_delete.move_to( overlapping_curves ) )
+ continue;
- //don't want to perturb the list...make a copy
- DLIList<Curve*> copy_list = *mergeable_curve_list;
+ //don't want to perturb the list...make a copy
+ DLIList<Curve*> copy_list = *mergeable_curve_list;
- //if the list of overlapping curve is the same as the mergeable curve list,
- //remove the list list of overlapping curves
+ //if the list of overlapping curve is the same as the mergeable curve list,
+ //remove the list list of overlapping curves
- if( copy_list == *overlapping_curves )
- {
- //remove overlapping_curve_list from the list
- lists_of_overlapping_curves.move_to( overlapping_curves );
- lists_of_overlapping_curves.change_to( NULL );
+ if( copy_list == *overlapping_curves )
+ {
+ //remove overlapping_curve_list from the list
+ lists_of_overlapping_curves.move_to( overlapping_curves );
+ lists_of_overlapping_curves.change_to( NULL );
- //put in list for deletion
- lists_to_delete.append( overlapping_curves );
+ //put in list for deletion
+ lists_to_delete.append( overlapping_curves );
- //remove overlapping_curve_list from the map
- curve_to_list_map.erase( curve_iter );
- continue;
- }
- else if (overlapping_curves->size() < copy_list.size() )
- {
- //If every curve in overlapping list is in the merge list,
- //remove that overlapping list.
- int list_size_before = copy_list.size();
- copy_list.merge_unique( *overlapping_curves );
- if( list_size_before == copy_list.size() )
- {
- //remove overlapping_curve_list from the list
- lists_of_overlapping_curves.move_to( overlapping_curves );
- lists_of_overlapping_curves.change_to( NULL );
+ //remove overlapping_curve_list from the map
+ curve_to_list_map.erase( curve_iter );
+ continue;
+ }
+ else if (overlapping_curves->size() < copy_list.size() )
+ {
+ //If every curve in overlapping list is in the merge list,
+ //remove that overlapping list.
+ int list_size_before = copy_list.size();
+ copy_list.merge_unique( *overlapping_curves );
+ if( list_size_before == copy_list.size() )
+ {
+ //remove overlapping_curve_list from the list
+ lists_of_overlapping_curves.move_to( overlapping_curves );
+ lists_of_overlapping_curves.change_to( NULL );
- //put in list for deletion
- lists_to_delete.append( overlapping_curves );
- }
- }
- }
- }
+ //put in list for deletion
+ lists_to_delete.append( overlapping_curves );
+ }
+ }
+ }
+ }
- //clean up lists
- for( i=lists_of_mergeable_curves.size(); i--; )
- delete lists_of_mergeable_curves.get_and_step();
- lists_of_overlapping_curves.remove_all_with_value( NULL );
+ //clean up lists
+ for( i=lists_of_mergeable_curves.size(); i--; )
+ delete lists_of_mergeable_curves.get_and_step();
+ lists_of_overlapping_curves.remove_all_with_value( NULL );
- for( i=lists_to_delete.size(); i--; )
- delete lists_to_delete.get_and_step();
+ for( i=lists_to_delete.size(); i--; )
+ delete lists_to_delete.get_and_step();
- double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
+ double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
- DLIList<BodySM*> imprint_body_order;
- lists_of_overlapping_curves.reset();
- //Now setup multi-map for imprinting vertices onto bodies
- //This is how the curve - vertex imprinting should be done:
- // -imprint vertices of curve 1 in list onto curves 2 - n
- // -imprint vertcies of curve 2 - n onto curve 1
- std::multimap<BodySM*, CubitVector* > body_point_imprint_map;
- std::multimap<BodySM*, CubitVector* >::iterator tmp_iter, upper_iter;
+ DLIList<BodySM*> imprint_body_order;
+ lists_of_overlapping_curves.reset();
+ //Now setup multi-map for imprinting vertices onto bodies
+ //This is how the curve - vertex imprinting should be done:
+ // -imprint vertices of curve 1 in list onto curves 2 - n
+ // -imprint vertcies of curve 2 - n onto curve 1
+ std::multimap<BodySM*, CubitVector* > body_point_imprint_map;
+ std::multimap<BodySM*, CubitVector* >::iterator tmp_iter, upper_iter;
- for( i=lists_of_overlapping_curves.size(); i--; )
- {
- DLIList<Curve*> *curve_list = lists_of_overlapping_curves.get_and_step();
- curve_list->reset();
- Curve *first_curve = curve_list->get_and_step();
+ for( i=lists_of_overlapping_curves.size(); i--; )
+ {
+ DLIList<Curve*> *curve_list = lists_of_overlapping_curves.get_and_step();
+ curve_list->reset();
+ Curve *first_curve = curve_list->get_and_step();
- DLIList<Point*> curve_1_points;
- first_curve->points( curve_1_points );
- Point *s_point1 = curve_1_points.get_and_step();
- Point *e_point1 = curve_1_points.get_and_step();
+ DLIList<Point*> curve_1_points;
+ first_curve->points( curve_1_points );
+ Point *s_point1 = curve_1_points.get_and_step();
+ Point *e_point1 = curve_1_points.get_and_step();
- BodySM *first_curve_body = first_curve->bodysm();
+ BodySM *first_curve_body = first_curve->bodysm();
- while( curve_list->size() > 1 )
- {
- Curve *other_curve = curve_list->pop();
- DLIList<Point*> curve_2_points;
- other_curve->points( curve_2_points );
- Point *s_point2 = curve_2_points.get_and_step();
- Point *e_point2 = curve_2_points.get_and_step();
+ while( curve_list->size() > 1 )
+ {
+ Curve *other_curve = curve_list->pop();
+ DLIList<Point*> curve_2_points;
+ other_curve->points( curve_2_points );
+ Point *s_point2 = curve_2_points.get_and_step();
+ Point *e_point2 = curve_2_points.get_and_step();
- BodySM *other_curve_body = other_curve->bodysm();
+ BodySM *other_curve_body = other_curve->bodysm();
- CubitVector close_pt;
- first_curve->closest_point_trimmed( s_point2->coordinates(), close_pt );
+ CubitVector close_pt;
+ first_curve->closest_point_trimmed( s_point2->coordinates(), close_pt );
- if( close_pt.distance_between( s_point1->coordinates() ) > tolerance &&
- close_pt.distance_between( e_point1->coordinates() ) > tolerance )
- {
- //are there any other points within tolerance to this point
- //to be imprinted onto this body?
- tmp_iter = body_point_imprint_map.find( first_curve_body );
- bool consider_point = true;
- if( tmp_iter != body_point_imprint_map.end() )
- {
- CubitVector *tmp_vec = tmp_iter->second;
- upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
+ if( close_pt.distance_between( s_point1->coordinates() ) > tolerance &&
+ close_pt.distance_between( e_point1->coordinates() ) > tolerance )
+ {
+ //are there any other points within tolerance to this point
+ //to be imprinted onto this body?
+ tmp_iter = body_point_imprint_map.find( first_curve_body );
+ bool consider_point = true;
+ if( tmp_iter != body_point_imprint_map.end() )
+ {
+ CubitVector *tmp_vec = tmp_iter->second;
+ upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
- for(; tmp_iter!=upper_iter; ++tmp_iter)
- {
- tmp_vec = tmp_iter->second;
- if( close_pt.distance_between( *tmp_vec ) < tolerance )
- {
- consider_point = false;
- break;
- }
- }
- }
+ for(; tmp_iter!=upper_iter; ++tmp_iter)
+ {
+ tmp_vec = tmp_iter->second;
+ if( close_pt.distance_between( *tmp_vec ) < tolerance )
+ {
+ consider_point = false;
+ break;
+ }
+ }
+ }
- if( consider_point )
- {
- //imprint body of curve1 with vertex at this location
- CubitVector *tmp_vec = new CubitVector( close_pt );
- body_point_imprint_map.insert( std::multimap<BodySM*,
- CubitVector*>::value_type( first_curve_body, tmp_vec ));
- imprint_body_order.append_unique( first_curve_body );
- }
- }
+ if( consider_point )
+ {
+ //imprint body of curve1 with vertex at this location
+ CubitVector *tmp_vec = new CubitVector( close_pt );
+ body_point_imprint_map.insert( std::multimap<BodySM*,
+ CubitVector*>::value_type( first_curve_body, tmp_vec ));
+ imprint_body_order.append_unique( first_curve_body );
+ }
+ }
- first_curve->closest_point_trimmed( e_point2->coordinates(), close_pt );
+ first_curve->closest_point_trimmed( e_point2->coordinates(), close_pt );
- if( close_pt.distance_between( s_point1->coordinates() ) > tolerance &&
- close_pt.distance_between( e_point1->coordinates() ) > tolerance )
- {
- //are there any other points within tolerance to this point
- //to be imprinted onto this body?
- tmp_iter = body_point_imprint_map.find( first_curve_body );
- bool consider_point = true;
- if( tmp_iter != body_point_imprint_map.end() )
- {
- CubitVector *tmp_vec = tmp_iter->second;
- upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
+ if( close_pt.distance_between( s_point1->coordinates() ) > tolerance &&
+ close_pt.distance_between( e_point1->coordinates() ) > tolerance )
+ {
+ //are there any other points within tolerance to this point
+ //to be imprinted onto this body?
+ tmp_iter = body_point_imprint_map.find( first_curve_body );
+ bool consider_point = true;
+ if( tmp_iter != body_point_imprint_map.end() )
+ {
+ CubitVector *tmp_vec = tmp_iter->second;
+ upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
- for(; tmp_iter!=upper_iter; ++tmp_iter)
- {
- tmp_vec = tmp_iter->second;
- if( close_pt.distance_between( *tmp_vec ) < tolerance )
- {
- consider_point = false;
- break;
- }
- }
- }
+ for(; tmp_iter!=upper_iter; ++tmp_iter)
+ {
+ tmp_vec = tmp_iter->second;
+ if( close_pt.distance_between( *tmp_vec ) < tolerance )
+ {
+ consider_point = false;
+ break;
+ }
+ }
+ }
- if( consider_point )
- {
- //imprint body of curve1 with vertex at this location
- CubitVector *tmp_vec = new CubitVector( close_pt );
- body_point_imprint_map.insert( std::multimap<BodySM*,
- CubitVector*>::value_type( first_curve_body, tmp_vec ));
- imprint_body_order.append_unique( first_curve_body );
- }
- }
+ if( consider_point )
+ {
+ //imprint body of curve1 with vertex at this location
+ CubitVector *tmp_vec = new CubitVector( close_pt );
+ body_point_imprint_map.insert( std::multimap<BodySM*,
+ CubitVector*>::value_type( first_curve_body, tmp_vec ));
+ imprint_body_order.append_unique( first_curve_body );
+ }
+ }
- other_curve->closest_point_trimmed( s_point1->coordinates(), close_pt );
+ other_curve->closest_point_trimmed( s_point1->coordinates(), close_pt );
- if( close_pt.distance_between( s_point2->coordinates() ) > tolerance &&
- close_pt.distance_between( e_point2->coordinates() ) > tolerance )
- {
- //are there any other points within tolerance to this point
- //to be imprinted onto this body?
- tmp_iter = body_point_imprint_map.find( other_curve_body );
- bool consider_point = true;
- if( tmp_iter != body_point_imprint_map.end() )
- {
- CubitVector *tmp_vec = tmp_iter->second;
- upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
+ if( close_pt.distance_between( s_point2->coordinates() ) > tolerance &&
+ close_pt.distance_between( e_point2->coordinates() ) > tolerance )
+ {
+ //are there any other points within tolerance to this point
+ //to be imprinted onto this body?
+ tmp_iter = body_point_imprint_map.find( other_curve_body );
+ bool consider_point = true;
+ if( tmp_iter != body_point_imprint_map.end() )
+ {
+ CubitVector *tmp_vec = tmp_iter->second;
+ upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
- for(; tmp_iter!=upper_iter; ++tmp_iter)
- {
- tmp_vec = tmp_iter->second;
- if( close_pt.distance_between( *tmp_vec ) < tolerance )
- {
- consider_point = false;
- break;
- }
- }
- }
+ for(; tmp_iter!=upper_iter; ++tmp_iter)
+ {
+ tmp_vec = tmp_iter->second;
+ if( close_pt.distance_between( *tmp_vec ) < tolerance )
+ {
+ consider_point = false;
+ break;
+ }
+ }
+ }
- if( consider_point )
- {
- //imprint body of curve1 with vertex at this location
- CubitVector *tmp_vec = new CubitVector( close_pt );
- body_point_imprint_map.insert( std::multimap<BodySM*,
- CubitVector*>::value_type( other_curve_body, tmp_vec ));
- imprint_body_order.append_unique( other_curve_body );
- }
- }
+ if( consider_point )
+ {
+ //imprint body of curve1 with vertex at this location
+ CubitVector *tmp_vec = new CubitVector( close_pt );
+ body_point_imprint_map.insert( std::multimap<BodySM*,
+ CubitVector*>::value_type( other_curve_body, tmp_vec ));
+ imprint_body_order.append_unique( other_curve_body );
+ }
+ }
- other_curve->closest_point_trimmed( e_point1->coordinates(), close_pt );
+ other_curve->closest_point_trimmed( e_point1->coordinates(), close_pt );
- if( close_pt.distance_between( s_point2->coordinates() ) > tolerance &&
- close_pt.distance_between( e_point2->coordinates() ) > tolerance )
- {
- //Are there already any other points within tolerance to this point
- //to be imprinted onto this body?
- //If so, don't imprint this point.
- tmp_iter = body_point_imprint_map.find( other_curve_body );
- bool consider_point = true;
- if( tmp_iter != body_point_imprint_map.end() )
- {
- CubitVector *tmp_vec = tmp_iter->second;
- upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
+ if( close_pt.distance_between( s_point2->coordinates() ) > tolerance &&
+ close_pt.distance_between( e_point2->coordinates() ) > tolerance )
+ {
+ //Are there already any other points within tolerance to this point
+ //to be imprinted onto this body?
+ //If so, don't imprint this point.
+ tmp_iter = body_point_imprint_map.find( other_curve_body );
+ bool consider_point = true;
+ if( tmp_iter != body_point_imprint_map.end() )
+ {
+ CubitVector *tmp_vec = tmp_iter->second;
+ upper_iter = body_point_imprint_map.upper_bound( tmp_iter->first );
- for(; tmp_iter!=upper_iter; ++tmp_iter )
- {
- tmp_vec = tmp_iter->second;
- if( close_pt.distance_between( *tmp_vec ) < tolerance )
- {
- consider_point = false;
- break;
- }
- }
- }
+ for(; tmp_iter!=upper_iter; ++tmp_iter )
+ {
+ tmp_vec = tmp_iter->second;
+ if( close_pt.distance_between( *tmp_vec ) < tolerance )
+ {
+ consider_point = false;
+ break;
+ }
+ }
+ }
- if( consider_point )
- {
- //imprint body of curve1 with vertex at this location
- CubitVector *tmp_vec = new CubitVector( close_pt );
- body_point_imprint_map.insert( std::multimap<BodySM*,
- CubitVector*>::value_type( other_curve_body, tmp_vec ));
- imprint_body_order.append_unique( other_curve_body );
- }
- }
- }
- }
+ if( consider_point )
+ {
+ //imprint body of curve1 with vertex at this location
+ CubitVector *tmp_vec = new CubitVector( close_pt );
+ body_point_imprint_map.insert( std::multimap<BodySM*,
+ CubitVector*>::value_type( other_curve_body, tmp_vec ));
+ imprint_body_order.append_unique( other_curve_body );
+ }
+ }
+ }
+ }
- //Imprint Vertices-onto-Body
- imprint_body_order.reset();
- std::multimap<BodySM*, CubitVector*>::iterator point_iter, last_point_iter;
- for( i=imprint_body_order.size(); i--; )
- {
- BodySM *tmp_body_sm = imprint_body_order.get_and_step();
- DLIList<BodySM*> body_to_imprint;
- body_to_imprint.append( tmp_body_sm );
+ //Imprint Vertices-onto-Body
+ imprint_body_order.reset();
+ std::multimap<BodySM*, CubitVector*>::iterator point_iter, last_point_iter;
+ for( i=imprint_body_order.size(); i--; )
+ {
+ BodySM *tmp_body_sm = imprint_body_order.get_and_step();
+ DLIList<BodySM*> body_to_imprint;
+ body_to_imprint.append( tmp_body_sm );
- DLIList<CubitVector*> points_to_imprint;
+ DLIList<CubitVector*> points_to_imprint;
- point_iter = body_point_imprint_map.find( tmp_body_sm );
- last_point_iter = body_point_imprint_map.upper_bound( point_iter->first );
+ point_iter = body_point_imprint_map.find( tmp_body_sm );
+ last_point_iter = body_point_imprint_map.upper_bound( point_iter->first );
- for(; point_iter!=last_point_iter; ++point_iter )
- points_to_imprint.append( point_iter->second );
+ for(; point_iter!=last_point_iter; ++point_iter )
+ points_to_imprint.append( point_iter->second );
- DLIList<BodySM*> new_bodies;
- CubitStatus status = imprint( body_to_imprint, points_to_imprint, new_bodies, false, new_tbs, att_tbs );
- if( new_bodies.size() )
- new_body_sms.append( new_bodies.get() );
+ DLIList<BodySM*> new_bodies;
+ CubitStatus status = imprint( body_to_imprint, points_to_imprint, new_bodies, false, new_tbs, att_tbs );
+ if( new_bodies.size() )
+ new_body_sms.append( new_bodies.get() );
- for( j=points_to_imprint.size(); j--; )
- delete points_to_imprint.get_and_step();
- }
+ for( j=points_to_imprint.size(); j--; )
+ delete points_to_imprint.get_and_step();
+ }
- //increment 4%
- if( progress_tool )
- {
- for( i=4; i--; )
- progress_tool->step();
- }
+ //increment 4%
+ if( progress_tool )
+ {
+ for( i=4; i--; )
+ progress_tool->step();
+ }
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
- CubitStatus AcisModifyEngine::imprint_overlapping_surfaces( DLIList<BodySM*> &body_sms,
- DLIList<BodySM*> &new_body_sms,
- ProgressTool *progress_tool) const
- {
- //Find all mergeable surfaces between the bodies
- DLIList< DLIList<Surface*>* > lists_of_mergeable_surfaces;
- CubitStatus status = MergeTool::instance()->
- find_only_mergeable_surfaces( body_sms, lists_of_mergeable_surfaces );
+CubitStatus AcisModifyEngine::imprint_overlapping_surfaces( DLIList<BodySM*> &body_sms,
+ DLIList<BodySM*> &new_body_sms,
+ ProgressTool *progress_tool) const
+{
+ //Find all mergeable surfaces between the bodies
+ DLIList< DLIList<Surface*>* > lists_of_mergeable_surfaces;
+ CubitStatus status = MergeTool::instance()->
+ find_only_mergeable_surfaces( body_sms, lists_of_mergeable_surfaces );
- if( progress_tool )
- progress_tool->percent( 0.24 );
+ if( progress_tool )
+ progress_tool->percent( 0.24 );
- //Find all overlapping surfaces between the bodies
- DLIList<Surface*> overlapping_surfaces1;
- DLIList<Surface*> overlapping_surfaces2;
- SurfaceOverlapTool::instance()->
- find_overlapping_surfaces( body_sms, overlapping_surfaces1, overlapping_surfaces2 );
+ //Find all overlapping surfaces between the bodies
+ DLIList<Surface*> overlapping_surfaces1;
+ DLIList<Surface*> overlapping_surfaces2;
+ SurfaceOverlapTool::instance()->
+ find_overlapping_surfaces( body_sms, overlapping_surfaces1, overlapping_surfaces2 );
- if( progress_tool )
- progress_tool->percent( 0.57 );
+ if( progress_tool )
+ progress_tool->percent( 0.57 );
- //We only want the non-mergeable overlapping surfaces.
- //Remove mergable surfaces from overlapping pairs.
- int i, j, k;
- for( i=lists_of_mergeable_surfaces.size(); i--; )
- {
- DLIList<Surface*> *tmp_surface_list = lists_of_mergeable_surfaces.get_and_step();
- for( j=tmp_surface_list->size(); j--; )
- {
- Surface *tmp_surface = tmp_surface_list->get_and_step();
- while( overlapping_surfaces1.move_to( tmp_surface ) )
- overlapping_surfaces1.change_to(NULL);
- while( overlapping_surfaces2.move_to( tmp_surface ) )
- overlapping_surfaces2.change_to(NULL);
- }
- delete tmp_surface_list;
- }
+ //We only want the non-mergeable overlapping surfaces.
+ //Remove mergable surfaces from overlapping pairs.
+ int i, j, k;
+ for( i=lists_of_mergeable_surfaces.size(); i--; )
+ {
+ DLIList<Surface*> *tmp_surface_list = lists_of_mergeable_surfaces.get_and_step();
+ for( j=tmp_surface_list->size(); j--; )
+ {
+ Surface *tmp_surface = tmp_surface_list->get_and_step();
+ while( overlapping_surfaces1.move_to( tmp_surface ) )
+ overlapping_surfaces1.change_to(NULL);
+ while( overlapping_surfaces2.move_to( tmp_surface ) )
+ overlapping_surfaces2.change_to(NULL);
+ }
+ delete tmp_surface_list;
+ }
- if( progress_tool )
- progress_tool->percent( 0.59 );
+ if( progress_tool )
+ progress_tool->percent( 0.59 );
- //Surface A might be mergeable/overlapping with B and just ever-so-slightly
- //overlapping with C. Get rid of C or other overlapping surfaces
- //that might be in the list.
- overlapping_surfaces1.reset();
- overlapping_surfaces2.reset();
- for( i=overlapping_surfaces1.size(); i--; )
- {
- Surface *tmp_surface1 = overlapping_surfaces1.get();
- Surface *tmp_surface2 = overlapping_surfaces2.get();
+ //Surface A might be mergeable/overlapping with B and just ever-so-slightly
+ //overlapping with C. Get rid of C or other overlapping surfaces
+ //that might be in the list.
+ overlapping_surfaces1.reset();
+ overlapping_surfaces2.reset();
+ for( i=overlapping_surfaces1.size(); i--; )
+ {
+ Surface *tmp_surface1 = overlapping_surfaces1.get();
+ Surface *tmp_surface2 = overlapping_surfaces2.get();
- if( tmp_surface1 != NULL )
- {
- if( tmp_surface2 == NULL )
- overlapping_surfaces1.change_to(NULL);
- }
- else
- {
- if( tmp_surface2 != NULL )
- overlapping_surfaces2.change_to(NULL);
- }
+ if( tmp_surface1 != NULL )
+ {
+ if( tmp_surface2 == NULL )
+ overlapping_surfaces1.change_to(NULL);
+ }
+ else
+ {
+ if( tmp_surface2 != NULL )
+ overlapping_surfaces2.change_to(NULL);
+ }
- overlapping_surfaces1.step();
- overlapping_surfaces2.step();
- }
+ overlapping_surfaces1.step();
+ overlapping_surfaces2.step();
+ }
- overlapping_surfaces1.remove_all_with_value(NULL);
- overlapping_surfaces2.remove_all_with_value(NULL);
+ overlapping_surfaces1.remove_all_with_value(NULL);
+ overlapping_surfaces2.remove_all_with_value(NULL);
- if ( overlapping_surfaces1.size() != overlapping_surfaces2.size() )
- {
- PRINT_ERROR("Number of overlapping pairs of surfaces is wrong.\n");
- return CUBIT_FAILURE;
- }
+ if ( overlapping_surfaces1.size() != overlapping_surfaces2.size() )
+ {
+ PRINT_ERROR("Number of overlapping pairs of surfaces is wrong.\n");
+ return CUBIT_FAILURE;
+ }
- if( progress_tool )
- progress_tool->percent( 0.62 );
+ if( progress_tool )
+ progress_tool->percent( 0.62 );
- // Make sure we are working with ACIS surfaces and not
- // something at some higher level.
- DLIList<Surface*> surfs_to_append1;
- DLIList<Surface*> surfs_to_append2;
- for(j=overlapping_surfaces1.size(); j--;)
- {
- Surface *s1 = overlapping_surfaces1.get();
- Surface *s2 = overlapping_surfaces2.get();
+ // Make sure we are working with ACIS surfaces and not
+ // something at some higher level.
+ DLIList<Surface*> surfs_to_append1;
+ DLIList<Surface*> surfs_to_append2;
+ for(j=overlapping_surfaces1.size(); j--;)
+ {
+ Surface *s1 = overlapping_surfaces1.get();
+ Surface *s2 = overlapping_surfaces2.get();
- GeometryQueryEngine *gqe1 = s1->get_geometry_query_engine();
- GeometryQueryEngine *gqe2 = s2->get_geometry_query_engine();
+ GeometryQueryEngine *gqe1 = s1->get_geometry_query_engine();
+ GeometryQueryEngine *gqe2 = s2->get_geometry_query_engine();
- DLIList<TopologyBridge*> tbs1, tbs2;
- gqe1->get_underlying_surfaces(s1, tbs1);
- gqe2->get_underlying_surfaces(s2, tbs2);
- int num_surfs1 = tbs1.size();
- int num_surfs2 = tbs2.size();
- if(num_surfs1 > 0 || num_surfs2 > 0)
- {
- if(num_surfs1 == 0)
- {
- for(k=tbs2.size(); k--;)
- {
- surfs_to_append1.append(s1);
- surfs_to_append2.append(dynamic_cast<Surface*>(tbs2.get_and_step()));
- }
- }
- else if(num_surfs2 == 0)
- {
- for(k=tbs1.size(); k--;)
- {
- surfs_to_append2.append(s2);
- surfs_to_append1.append(dynamic_cast<Surface*>(tbs1.get_and_step()));
- }
- }
- else
- {
- for(k=tbs1.size(); k--;)
- {
- int u;
- Surface *tmp1 = dynamic_cast<Surface*>(tbs1.get_and_step());
- for(u=num_surfs2; u--;)
- {
- surfs_to_append1.append(tmp1);
- surfs_to_append2.append(dynamic_cast<Surface*>(tbs2.get_and_step()));
- }
- }
- }
- overlapping_surfaces1.change_to(NULL);
- overlapping_surfaces2.change_to(NULL);
- }
+ DLIList<TopologyBridge*> tbs1, tbs2;
+ gqe1->get_underlying_surfaces(s1, tbs1);
+ gqe2->get_underlying_surfaces(s2, tbs2);
+ int num_surfs1 = tbs1.size();
+ int num_surfs2 = tbs2.size();
+ if(num_surfs1 > 0 || num_surfs2 > 0)
+ {
+ if(num_surfs1 == 0)
+ {
+ for(k=tbs2.size(); k--;)
+ {
+ surfs_to_append1.append(s1);
+ surfs_to_append2.append(dynamic_cast<Surface*>(tbs2.get_and_step()));
+ }
+ }
+ else if(num_surfs2 == 0)
+ {
+ for(k=tbs1.size(); k--;)
+ {
+ surfs_to_append2.append(s2);
+ surfs_to_append1.append(dynamic_cast<Surface*>(tbs1.get_and_step()));
+ }
+ }
+ else
+ {
+ for(k=tbs1.size(); k--;)
+ {
+ int u;
+ Surface *tmp1 = dynamic_cast<Surface*>(tbs1.get_and_step());
+ for(u=num_surfs2; u--;)
+ {
+ surfs_to_append1.append(tmp1);
+ surfs_to_append2.append(dynamic_cast<Surface*>(tbs2.get_and_step()));
+ }
+ }
+ }
+ overlapping_surfaces1.change_to(NULL);
+ overlapping_surfaces2.change_to(NULL);
+ }
- overlapping_surfaces1.step();
- overlapping_surfaces2.step();
- }
- overlapping_surfaces1.remove_all_with_value(NULL);
- overlapping_surfaces2.remove_all_with_value(NULL);
- for(k=surfs_to_append1.size(); k--;)
- {
- overlapping_surfaces1.append(surfs_to_append1.get_and_step());
- overlapping_surfaces2.append(surfs_to_append2.get_and_step());
- }
+ overlapping_surfaces1.step();
+ overlapping_surfaces2.step();
+ }
+ overlapping_surfaces1.remove_all_with_value(NULL);
+ overlapping_surfaces2.remove_all_with_value(NULL);
+ for(k=surfs_to_append1.size(); k--;)
+ {
+ overlapping_surfaces1.append(surfs_to_append1.get_and_step());
+ overlapping_surfaces2.append(surfs_to_append2.get_and_step());
+ }
- //Now that we have non-mergeable overlapping surface pairs, determine which
- //curves of surface1 to imprint onto surface2 and vice versa.
- //We eliminate curves between the 2 surfaces that overlap.
- DLIList<Surface*> surface_ordering_list;
- std::multimap<Surface*, Curve*> surface_curve_imprint_map;
- overlapping_surfaces1.reset();
- overlapping_surfaces2.reset();
+ //Now that we have non-mergeable overlapping surface pairs, determine which
+ //curves of surface1 to imprint onto surface2 and vice versa.
+ //We eliminate curves between the 2 surfaces that overlap.
+ DLIList<Surface*> surface_ordering_list;
+ std::multimap<Surface*, Curve*> surface_curve_imprint_map;
+ overlapping_surfaces1.reset();
+ overlapping_surfaces2.reset();
- double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
+ double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
- for( i=overlapping_surfaces1.size(); i--; )
- {
- Surface *overlapping_surface1 = overlapping_surfaces1.get_and_step();
- Surface *overlapping_surface2 = overlapping_surfaces2.get_and_step();
+ for( i=overlapping_surfaces1.size(); i--; )
+ {
+ Surface *overlapping_surface1 = overlapping_surfaces1.get_and_step();
+ Surface *overlapping_surface2 = overlapping_surfaces2.get_and_step();
- //get all the curves of the surfaces
- DLIList<Curve*> curves2, curves1;
- overlapping_surface2->curves( curves2 );
- overlapping_surface1->curves( curves1 );
+ //get all the curves of the surfaces
+ DLIList<Curve*> curves2, curves1;
+ overlapping_surface2->curves( curves2 );
+ overlapping_surface1->curves( curves1 );
- // Make sure we are working with ACIS curves
- // and not something at some higher level.
- DLIList<Curve*> curves_to_remove;
- DLIList<Curve*> curves_to_append;
- curves2.reset();
- for(j=curves2.size(); j--;)
- {
- Curve *c = curves2.get_and_step();
- GeometryQueryEngine *gqe = c->get_geometry_query_engine();
- DLIList<TopologyBridge*> tbs;
- gqe->get_underlying_curves(c, tbs);
- if(tbs.size() > 0)
- {
- curves_to_remove.append(c);
- for(k=tbs.size(); k--;)
- curves_to_append.append(dynamic_cast<Curve*>(tbs.get_and_step()));
- }
- }
- curves2 -= curves_to_remove;
- curves2 += curves_to_append;
- curves_to_remove.clean_out();
- curves_to_append.clean_out();
- curves1.reset();
- for(j=curves1.size(); j--;)
- {
- Curve *c = curves1.get_and_step();
- GeometryQueryEngine *gqe = c->get_geometry_query_engine();
- DLIList<TopologyBridge*> tbs;
- gqe->get_underlying_curves(c, tbs);
- if(tbs.size() > 0)
- {
- curves_to_remove.append(c);
- for(k=tbs.size(); k--;)
- curves_to_append.append(dynamic_cast<Curve*>(tbs.get_and_step()));
- }
- }
- curves1 -= curves_to_remove;
- curves1 += curves_to_append;
+ // Make sure we are working with ACIS curves
+ // and not something at some higher level.
+ DLIList<Curve*> curves_to_remove;
+ DLIList<Curve*> curves_to_append;
+ curves2.reset();
+ for(j=curves2.size(); j--;)
+ {
+ Curve *c = curves2.get_and_step();
+ GeometryQueryEngine *gqe = c->get_geometry_query_engine();
+ DLIList<TopologyBridge*> tbs;
+ gqe->get_underlying_curves(c, tbs);
+ if(tbs.size() > 0)
+ {
+ curves_to_remove.append(c);
+ for(k=tbs.size(); k--;)
+ curves_to_append.append(dynamic_cast<Curve*>(tbs.get_and_step()));
+ }
+ }
+ curves2 -= curves_to_remove;
+ curves2 += curves_to_append;
+ curves_to_remove.clean_out();
+ curves_to_append.clean_out();
+ curves1.reset();
+ for(j=curves1.size(); j--;)
+ {
+ Curve *c = curves1.get_and_step();
+ GeometryQueryEngine *gqe = c->get_geometry_query_engine();
+ DLIList<TopologyBridge*> tbs;
+ gqe->get_underlying_curves(c, tbs);
+ if(tbs.size() > 0)
+ {
+ curves_to_remove.append(c);
+ for(k=tbs.size(); k--;)
+ curves_to_append.append(dynamic_cast<Curve*>(tbs.get_and_step()));
+ }
+ }
+ curves1 -= curves_to_remove;
+ curves1 += curves_to_append;
- //Get bounding box for later
- CubitBox bb_surf = overlapping_surface1->bounding_box();
+ //Get bounding box for later
+ CubitBox bb_surf = overlapping_surface1->bounding_box();
- //remove overlapping curves between the 2 surfaces
- for( j=curves2.size(); j--; )
- {
- Curve *tmp_curve = curves2.get();
+ //remove overlapping curves between the 2 surfaces
+ for( j=curves2.size(); j--; )
+ {
+ Curve *tmp_curve = curves2.get();
- int k;
- bool overlap = false;
- for( k=curves1.size(); k--; )
- {
- if( curves1.get() )
- {
- Curve *tmp_curve_2 = curves1.get();
+ int k;
+ bool overlap = false;
+ for( k=curves1.size(); k--; )
+ {
+ if( curves1.get() )
+ {
+ Curve *tmp_curve_2 = curves1.get();
- if( SurfaceOverlapTool::instance()->
- check_overlap( tmp_curve, tmp_curve_2, NULL))
- {
- //They should be about spatially equal too!
- // CubitSense dummy_sense;
- // if( MergeTool::instance()->about_spatially_equal( curves1.get(), curves2.get(),
- // dummy_sense, GeometryQueryTool::get_geometry_factor() ) )
- // {
- curves1.change_to(NULL);
- curves2.change_to(NULL);
- overlap = true;
- break;
- // }
- }
- }
- curves1.step();
- }
- if( overlap )
- {
- curves2.step();
- continue;
- }
+ if( SurfaceOverlapTool::instance()->
+ check_overlap( tmp_curve, tmp_curve_2, NULL))
+ {
+ //They should be about spatially equal too!
+// CubitSense dummy_sense;
+// if( MergeTool::instance()->about_spatially_equal( curves1.get(), curves2.get(),
+// dummy_sense, GeometryQueryTool::get_geometry_factor() ) )
+// {
+ curves1.change_to(NULL);
+ curves2.change_to(NULL);
+ overlap = true;
+ break;
+// }
+ }
+ }
+ curves1.step();
+ }
+ if( overlap )
+ {
+ curves2.step();
+ continue;
+ }
- double distance;
- CubitVector v1, v2;
+ double distance;
+ CubitVector v1, v2;
- //bounding box check between curve and surface
- CubitBox bb_curve = tmp_curve->bounding_box();
- if( bb_surf.overlap( tolerance, bb_curve ) )
- {
- //measure distance between curve and surface
- overlapping_surface1->get_geometry_query_engine()->entity_entity_distance(
- overlapping_surface1, tmp_curve, v1, v2, distance );
+ //bounding box check between curve and surface
+ CubitBox bb_curve = tmp_curve->bounding_box();
+ if( bb_surf.overlap( tolerance, bb_curve ) )
+ {
+ //measure distance between curve and surface
+ overlapping_surface1->get_geometry_query_engine()->entity_entity_distance(
+ overlapping_surface1, tmp_curve, v1, v2, distance );
- if( distance < tolerance )
- {
- //check multimap to make sure that this curve has not already
- //been added (from another surface that shares it)
- //or that is overlaps another curve in the multimap
- std::pair< std::multimap<Surface*, Curve* >::iterator,
- std::multimap<Surface*, Curve* >::iterator > surface_curve_pair;
- surface_curve_pair = surface_curve_imprint_map.equal_range( overlapping_surface1 );
+ if( distance < tolerance )
+ {
+ //check multimap to make sure that this curve has not already
+ //been added (from another surface that shares it)
+ //or that is overlaps another curve in the multimap
+ std::pair< std::multimap<Surface*, Curve* >::iterator,
+ std::multimap<Surface*, Curve* >::iterator > surface_curve_pair;
+ surface_curve_pair = surface_curve_imprint_map.equal_range( overlapping_surface1 );
- std::multimap<Surface*, Curve*>::iterator iter = surface_curve_pair.first;
- std::multimap<Surface*, Curve*>::iterator end = surface_curve_pair.second;
- bool match_found = false;
- while( iter != end )
- {
- if( iter->second == tmp_curve )
- {
- match_found = true;
- break;
- }
+ std::multimap<Surface*, Curve*>::iterator iter = surface_curve_pair.first;
+ std::multimap<Surface*, Curve*>::iterator end = surface_curve_pair.second;
+ bool match_found = false;
+ while( iter != end )
+ {
+ if( iter->second == tmp_curve )
+ {
+ match_found = true;
+ break;
+ }
- if( SurfaceOverlapTool::instance()->check_overlap( iter->second, tmp_curve, NULL ) )
- {
- match_found = true;
- break;
- }
+ if( SurfaceOverlapTool::instance()->check_overlap( iter->second, tmp_curve, NULL ) )
+ {
+ match_found = true;
+ break;
+ }
- iter++;
- }
+ iter++;
+ }
- if( match_found == false )
- {
- surface_curve_imprint_map.insert( std::multimap<Surface*, Curve*>::value_type(
- overlapping_surface1, tmp_curve ));
- surface_ordering_list.append_unique( overlapping_surface1 );
- }
- }
- }
- curves2.step();
- }
+ if( match_found == false )
+ {
+ surface_curve_imprint_map.insert( std::multimap<Surface*, Curve*>::value_type(
+ overlapping_surface1, tmp_curve ));
+ surface_ordering_list.append_unique( overlapping_surface1 );
+ }
+ }
+ }
+ curves2.step();
+ }
- bb_surf = overlapping_surface2->bounding_box();
- curves1.remove_all_with_value( NULL );
- curves2.remove_all_with_value( NULL );
- //insert body and copied curves into list
- for( j=curves1.size(); j--; )
- {
- Curve *tmp_curve = curves1.get();
+ bb_surf = overlapping_surface2->bounding_box();
+ curves1.remove_all_with_value( NULL );
+ curves2.remove_all_with_value( NULL );
+ //insert body and copied curves into list
+ for( j=curves1.size(); j--; )
+ {
+ Curve *tmp_curve = curves1.get();
- double distance;
- CubitVector v1, v2;
- CubitBox bb_curve = tmp_curve->bounding_box();
- //bounding box check between curve and surface
- if( bb_surf.overlap( tolerance, bb_curve ) )
- {
- //measure distance between curve and surface
- overlapping_surface2->get_geometry_query_engine()->entity_entity_distance(
- overlapping_surface2, tmp_curve, v1, v2, distance );
+ double distance;
+ CubitVector v1, v2;
+ CubitBox bb_curve = tmp_curve->bounding_box();
+ //bounding box check between curve and surface
+ if( bb_surf.overlap( tolerance, bb_curve ) )
+ {
+ //measure distance between curve and surface
+ overlapping_surface2->get_geometry_query_engine()->entity_entity_distance(
+ overlapping_surface2, tmp_curve, v1, v2, distance );
- if( distance < tolerance )
- {
- //check multimap to make sure that this curve has not already
- //been added (from another surface that shares it)
- //or that is overlaps another curve in the multimap
- std::pair< std::multimap<Surface*, Curve* >::iterator,
- std::multimap<Surface*, Curve* >::iterator > surface_curve_pair;
- surface_curve_pair = surface_curve_imprint_map.equal_range( overlapping_surface2 );
+ if( distance < tolerance )
+ {
+ //check multimap to make sure that this curve has not already
+ //been added (from another surface that shares it)
+ //or that is overlaps another curve in the multimap
+ std::pair< std::multimap<Surface*, Curve* >::iterator,
+ std::multimap<Surface*, Curve* >::iterator > surface_curve_pair;
+ surface_curve_pair = surface_curve_imprint_map.equal_range( overlapping_surface2 );
- std::multimap<Surface*, Curve*>::iterator end = surface_curve_pair.second;
- std::multimap<Surface*, Curve*>::iterator iter = surface_curve_pair.first;
- bool match_found = false;
- while( iter != end )
- {
- if( iter->second == tmp_curve )
- {
- match_found = true;
- break;
- }
+ std::multimap<Surface*, Curve*>::iterator end = surface_curve_pair.second;
+ std::multimap<Surface*, Curve*>::iterator iter = surface_curve_pair.first;
+ bool match_found = false;
+ while( iter != end )
+ {
+ if( iter->second == tmp_curve )
+ {
+ match_found = true;
+ break;
+ }
- if( SurfaceOverlapTool::instance()->check_overlap( iter->second, tmp_curve, NULL ) )
- {
- match_found = true;
- break;
- }
+ if( SurfaceOverlapTool::instance()->check_overlap( iter->second, tmp_curve, NULL ) )
+ {
+ match_found = true;
+ break;
+ }
- iter++;
- }
+ iter++;
+ }
- if( match_found == false )
- {
- surface_curve_imprint_map.insert( std::multimap<Surface*, Curve*>::value_type(
- overlapping_surface2, tmp_curve ));
- surface_ordering_list.append_unique( overlapping_surface2 );
- }
+ if( match_found == false )
+ {
+ surface_curve_imprint_map.insert( std::multimap<Surface*, Curve*>::value_type(
+ overlapping_surface2, tmp_curve ));
+ surface_ordering_list.append_unique( overlapping_surface2 );
+ }
- }
- }
- curves1.step();
- }
- }
+ }
+ }
+ curves1.step();
+ }
+ }
- if( progress_tool )
- progress_tool->percent( 0.64 );
+ if( progress_tool )
+ progress_tool->percent( 0.64 );
- //We cannot use the original curves for imprinting....they'll be
- //getting modified. Make copies of them here and build a new multimap
- std::multimap<Surface*, Curve*>::iterator surf_curve_iter, surf_curve_last;
- std::multimap<Surface*, Curve*> final_surface_curve_imprint_map;
- for( surf_curve_iter = surface_curve_imprint_map.begin();
- surf_curve_iter != surface_curve_imprint_map.end(); )
- {
- Surface *tmp_surf = surf_curve_iter->first;
- surf_curve_last = surface_curve_imprint_map.upper_bound( tmp_surf );
+ //We cannot use the original curves for imprinting....they'll be
+ //getting modified. Make copies of them here and build a new multimap
+ std::multimap<Surface*, Curve*>::iterator surf_curve_iter, surf_curve_last;
+ std::multimap<Surface*, Curve*> final_surface_curve_imprint_map;
+ for( surf_curve_iter = surface_curve_imprint_map.begin();
+ surf_curve_iter != surface_curve_imprint_map.end(); )
+ {
+ Surface *tmp_surf = surf_curve_iter->first;
+ surf_curve_last = surface_curve_imprint_map.upper_bound( tmp_surf );
- for(; surf_curve_iter!=surf_curve_last; ++surf_curve_iter )
- {
- Curve *copied_curve = make_Curve( surf_curve_iter->second );
- final_surface_curve_imprint_map.insert( std::multimap<Surface*,
- Curve*>::value_type( tmp_surf, copied_curve ));
- }
- }
+ for(; surf_curve_iter!=surf_curve_last; ++surf_curve_iter )
+ {
+ Curve *copied_curve = make_Curve( surf_curve_iter->second );
+ final_surface_curve_imprint_map.insert( std::multimap<Surface*,
+ Curve*>::value_type( tmp_surf, copied_curve ));
+ }
+ }
- if( progress_tool )
- progress_tool->percent( 0.67 );
+ if( progress_tool )
+ progress_tool->percent( 0.67 );
- double percentage_per_surface = 0;
- double delta = 0;
+ double percentage_per_surface = 0;
+ double delta = 0;
- if( progress_tool )
- {
- if( surface_ordering_list.size() )
- percentage_per_surface = 0.16 / surface_ordering_list.size();
- else
- progress_tool->percent( 0.83 );
+ if( progress_tool )
+ {
+ if( surface_ordering_list.size() )
+ percentage_per_surface = 0.16 / surface_ordering_list.size();
+ else
+ progress_tool->percent( 0.83 );
- }
+ }
- //Now iterate of each surface that will be imprinted with curves.
- surface_ordering_list.reset();
- bool print_errors = false;
- for( i=surface_ordering_list.size(); i--; )
- {
- if( progress_tool )
- {
- delta += percentage_per_surface;
- progress_tool->percent( 0.67 + delta );
- }
+ //Now iterate of each surface that will be imprinted with curves.
+ surface_ordering_list.reset();
+ bool print_errors = false;
+ for( i=surface_ordering_list.size(); i--; )
+ {
+ if( progress_tool )
+ {
+ delta += percentage_per_surface;
+ progress_tool->percent( 0.67 + delta );
+ }
- Surface *tmp_surface = surface_ordering_list.get_and_step();
+ Surface *tmp_surface = surface_ordering_list.get_and_step();
- surf_curve_iter = final_surface_curve_imprint_map.find( tmp_surface );
- tmp_surface = surf_curve_iter->first;
+ surf_curve_iter = final_surface_curve_imprint_map.find( tmp_surface );
+ tmp_surface = surf_curve_iter->first;
- DLIList<Surface*> surface_list;
- surface_list.append( tmp_surface );
+ DLIList<Surface*> surface_list;
+ surface_list.append( tmp_surface );
- DLIList<Curve*> curves_to_imprint;
- surf_curve_last = final_surface_curve_imprint_map.upper_bound( surf_curve_iter->first );
- //For each curve that might be imprinted on the surface...
+ DLIList<Curve*> curves_to_imprint;
+ surf_curve_last = final_surface_curve_imprint_map.upper_bound( surf_curve_iter->first );
+ //For each curve that might be imprinted on the surface...
- for(; surf_curve_iter!=surf_curve_last; ++surf_curve_iter )
- {
- DLIList<Curve*> tmp_curve_list1, tmp_curve_list2;
- Curve *original_curve = surf_curve_iter->second;
- tmp_curve_list1.append( original_curve );
+ for(; surf_curve_iter!=surf_curve_last; ++surf_curve_iter )
+ {
+ DLIList<Curve*> tmp_curve_list1, tmp_curve_list2;
+ Curve *original_curve = surf_curve_iter->second;
+ tmp_curve_list1.append( original_curve );
- //project
- CubitStatus projected = project_edges( surface_list, tmp_curve_list1, tmp_curve_list2, print_errors );
+ //project
+ CubitStatus projected = project_edges( surface_list, tmp_curve_list1, tmp_curve_list2, print_errors );
- if( projected == CUBIT_FAILURE )
- {
- AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
- continue;
- }
+ if( projected == CUBIT_FAILURE )
+ {
+ AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
+ continue;
+ }
- Curve *projected_curve = tmp_curve_list2.get();
+ Curve *projected_curve = tmp_curve_list2.get();
- //if midpoint of projected is far from original curve, continue
- CubitVector original_curve_mid_point = original_curve->center_point();
- if( original_curve_mid_point.distance_between( projected_curve->center_point() ) > tolerance )
- {
- AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
- AcisQueryEngine::instance()->delete_solid_model_entities( projected_curve );
- continue;
- }
+ //if midpoint of projected is far from original curve, continue
+ CubitVector original_curve_mid_point = original_curve->center_point();
+ if( original_curve_mid_point.distance_between( projected_curve->center_point() ) > tolerance )
+ {
+ AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
+ AcisQueryEngine::instance()->delete_solid_model_entities( projected_curve );
+ continue;
+ }
- //now intersect
- tmp_curve_list1.clean_out();
- CubitStatus intersected = curve_surface_intersection( tmp_surface, projected_curve, tmp_curve_list1 );
+ //now intersect
+ tmp_curve_list1.clean_out();
+ CubitStatus intersected = curve_surface_intersection( tmp_surface, projected_curve, tmp_curve_list1 );
- //delete the curves
- AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
- AcisQueryEngine::instance()->delete_solid_model_entities( projected_curve );
+ //delete the curves
+ AcisQueryEngine::instance()->delete_solid_model_entities( original_curve );
+ AcisQueryEngine::instance()->delete_solid_model_entities( projected_curve );
- if( intersected == CUBIT_FAILURE)
- continue;
+ if( intersected == CUBIT_FAILURE)
+ continue;
- curves_to_imprint += tmp_curve_list1;
- }
+ curves_to_imprint += tmp_curve_list1;
+ }
- //filter out small curves
- int j;
- for( j=curves_to_imprint.size(); j--; )
- {
- Curve *tmp_curve = curves_to_imprint.get();
- double curve_length = tmp_curve->measure();
- if( curve_length < tolerance )
- {
- curves_to_imprint.change_to( NULL );
- AcisQueryEngine::instance()->delete_solid_model_entities( tmp_curve );
- }
- curves_to_imprint.step();
- }
- curves_to_imprint.remove_all_with_value( NULL );
+ //filter out small curves
+ int j;
+ for( j=curves_to_imprint.size(); j--; )
+ {
+ Curve *tmp_curve = curves_to_imprint.get();
+ double curve_length = tmp_curve->measure();
+ if( curve_length < tolerance )
+ {
+ curves_to_imprint.change_to( NULL );
+ AcisQueryEngine::instance()->delete_solid_model_entities( tmp_curve );
+ }
+ curves_to_imprint.step();
+ }
+ curves_to_imprint.remove_all_with_value( NULL );
- BodySM *new_body_sm = NULL;
+ BodySM *new_body_sm = NULL;
- //Now imprint the curves onto the surface
- CubitStatus status;
- if( curves_to_imprint.size() )
- {
- /*
- GfxDebug::clear();
- AcisDrawTool::instance()->draw_surface( tmp_surface, 4, true);
- GfxDebug::mouse_xforms();
- int kkk;
- PRINT_INFO("number of curve = %d\n", curves_to_imprint.size() );
- for( kkk=curves_to_imprint.size(); kkk--; )
- {
- AcisDrawTool::instance()->draw_curve( curves_to_imprint.get_and_step(), kkk+5 );
- GfxDebug::mouse_xforms();
- }
- */
- status = embed_curves_into_surface( tmp_surface, curves_to_imprint, new_body_sm );
- }
+ //Now imprint the curves onto the surface
+ CubitStatus status;
+ if( curves_to_imprint.size() )
+ {
+/*
+ GfxDebug::clear();
+ AcisDrawTool::instance()->draw_surface( tmp_surface, 4, true);
+ GfxDebug::mouse_xforms();
+ int kkk;
+ PRINT_INFO("number of curve = %d\n", curves_to_imprint.size() );
+ for( kkk=curves_to_imprint.size(); kkk--; )
+ {
+ AcisDrawTool::instance()->draw_curve( curves_to_imprint.get_and_step(), kkk+5 );
+ GfxDebug::mouse_xforms();
+ }
+*/
+ status = embed_curves_into_surface( tmp_surface, curves_to_imprint, new_body_sm );
+ }
- if( new_body_sm == NULL )
- continue;
- new_body_sms.append_unique( new_body_sm );
+ if( new_body_sm == NULL )
+ continue;
+ new_body_sms.append_unique( new_body_sm );
- //Delete all the curves that were imprinted. We're responsible for deleting them.
- for( j=curves_to_imprint.size(); j--; )
- AcisQueryEngine::instance()->delete_solid_model_entities( curves_to_imprint.get_and_step() );
+ //Delete all the curves that were imprinted. We're responsible for deleting them.
+ for( j=curves_to_imprint.size(); j--; )
+ AcisQueryEngine::instance()->delete_solid_model_entities( curves_to_imprint.get_and_step() );
- }
- return CUBIT_SUCCESS;
- }
+ }
+ return CUBIT_SUCCESS;
+}
- //WARNING!!! Only use this function if you KNOW that the curves you want
- //to imprint line on the surface.....otherwise you'll get problems.
- //api_embed_wire_in_faces returns unexpected results if the curve
- //does not lie on the surface.
- CubitStatus AcisModifyEngine::embed_curves_into_surface( Surface *surface,
+//WARNING!!! Only use this function if you KNOW that the curves you want
+//to imprint line on the surface.....otherwise you'll get problems.
+//api_embed_wire_in_faces returns unexpected results if the curve
+//does not lie on the surface.
+CubitStatus AcisModifyEngine::embed_curves_into_surface( Surface *surface,
DLIList<Curve*> &curves_to_imprint,
BodySM *&new_body ) const
- {
- if( curves_to_imprint.size() == 0 )
- return CUBIT_FAILURE;
+{
+ if( curves_to_imprint.size() == 0 )
+ return CUBIT_FAILURE;
- BODY *copied_BODY = NULL;
- DLIList<FACE*> imprint_FACE_list;
- DLIList<SurfaceACIS*> acis_surfs;
- SurfaceACIS *tmp_acis_surf = CAST_TO( surface, SurfaceACIS );
+ BODY *copied_BODY = NULL;
+ DLIList<FACE*> imprint_FACE_list;
+ DLIList<SurfaceACIS*> acis_surfs;
+ SurfaceACIS *tmp_acis_surf = CAST_TO( surface, SurfaceACIS );
- if( tmp_acis_surf == NULL )
- return CUBIT_FAILURE;
+ if( tmp_acis_surf == NULL )
+ return CUBIT_FAILURE;
- FACE *FACE_ptr = tmp_acis_surf->get_FACE_ptr();
- BODY *BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
- BodySM *old_body_sm = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
+ FACE *FACE_ptr = tmp_acis_surf->get_FACE_ptr();
+ BODY *BODY_ptr = AcisQueryEngine::instance()->get_BODY_of_ENTITY( FACE_ptr );
+ BodySM *old_body_sm = AcisQueryEngine::instance()->get_body_sm_of_ENTITY( FACE_ptr );
- acis_surfs.append( tmp_acis_surf );
- if( get_copied_FACES_of_body( acis_surfs, imprint_FACE_list, copied_BODY ) == CUBIT_FAILURE )
- return CUBIT_FAILURE;
+ acis_surfs.append( tmp_acis_surf );
+ if( get_copied_FACES_of_body( acis_surfs, imprint_FACE_list, copied_BODY ) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
- if( imprint_FACE_list.size() == 0 )
- return CUBIT_FAILURE;
+ if( imprint_FACE_list.size() == 0 )
+ return CUBIT_FAILURE;
- double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
- if( tolerance < 0.001 )
- tolerance = 0.001;
+ double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
+ if( tolerance < 0.001 )
+ tolerance = 0.001;
- int i;
- EDGE *EDGEs[ 1 ];
- ENTITY_LIST wire_BODYs;
+ int i;
+ EDGE *EDGEs[ 1 ];
+ ENTITY_LIST wire_BODYs;
#ifdef BOYD16
- outcome tmp_result;
+ outcome tmp_result;
#endif
- for( i=0; i<curves_to_imprint.size(); i++ )
- {
- //copy
- EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE( curves_to_imprint.get_and_step() );
+ for( i=0; i<curves_to_imprint.size(); i++ )
+ {
+ //copy
+ EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE( curves_to_imprint.get_and_step() );
- EDGE *copied_EDGE_ptr = NULL;
- outcome tmp_result = api_edge( EDGE_ptr, copied_EDGE_ptr );
- ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
- CUBIT_TRUE );
- EDGEs[0] = copied_EDGE_ptr;
- BODY *tmp_BODY = NULL;
- tmp_result = api_make_ewire( 1, EDGEs, tmp_BODY );
- wire_BODYs.add( (ENTITY*)tmp_BODY );
- }
+ EDGE *copied_EDGE_ptr = NULL;
+ outcome tmp_result = api_edge( EDGE_ptr, copied_EDGE_ptr );
+ ATTRIB_CUBIT_OWNER::remove_cubit_owner( (ENTITY *)copied_EDGE_ptr,
+ CUBIT_TRUE );
+ EDGEs[0] = copied_EDGE_ptr;
+ BODY *tmp_BODY = NULL;
+ tmp_result = api_make_ewire( 1, EDGEs, tmp_BODY );
+ wire_BODYs.add( (ENTITY*)tmp_BODY );
+ }
- int number_wire_bodies = wire_BODYs.count();
+ int number_wire_bodies = wire_BODYs.count();
- if( number_wire_bodies == 0 )
- return CUBIT_FAILURE;
+ if( number_wire_bodies == 0 )
+ return CUBIT_FAILURE;
- BODY *wire_BODY_ptr = (BODY*)wire_BODYs[0];
+ BODY *wire_BODY_ptr = (BODY*)wire_BODYs[0];
- ENTITY_LIST *face_list = new ENTITY_LIST;
- FACE* imprint_FACE = imprint_FACE_list.get();
- face_list->add( (ENTITY*)imprint_FACE );
+ ENTITY_LIST *face_list = new ENTITY_LIST;
+ FACE* imprint_FACE = imprint_FACE_list.get();
+ face_list->add( (ENTITY*)imprint_FACE );
- ENTITY_LIST temp_face_list;
- api_get_faces( copied_BODY, temp_face_list );
- int number_faces_before = temp_face_list.count();
+ ENTITY_LIST temp_face_list;
+ api_get_faces( copied_BODY, temp_face_list );
+ int number_faces_before = temp_face_list.count();
- API_BEGIN
- result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
- API_END
+ API_BEGIN
+ result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
+ API_END
- for(i=1; i<number_wire_bodies; i++ )
- {
+ for(i=1; i<number_wire_bodies; i++ )
+ {
#ifdef BOYD16
- bool embedded = false;
+ bool embedded = false;
#endif
- wire_BODY_ptr = (BODY*)wire_BODYs[i];
+ wire_BODY_ptr = (BODY*)wire_BODYs[i];
- //get all the faces on the body
- ENTITY_LIST FACEs;
- api_get_faces( copied_BODY, FACEs );
+ //get all the faces on the body
+ ENTITY_LIST FACEs;
+ api_get_faces( copied_BODY, FACEs );
- //if number of faces on body did not change, no face got split, and we can
- //split the same FACE again.
- if( number_faces_before == FACEs.count() )
- {
- result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
- continue;
- }
+ //if number of faces on body did not change, no face got split, and we can
+ //split the same FACE again.
+ if( number_faces_before == FACEs.count() )
+ {
+ result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
+ continue;
+ }
- //need to determine which face to embed curve onto
- //may be able to remove this later on and just embed into body
- //just embed the remining wires into the body
- //result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, NULL, tolerance );
- //if( !result.ok() )
- // AcisQueryEngine::instance()->ACIS_API_error (result);
+ //need to determine which face to embed curve onto
+ //may be able to remove this later on and just embed into body
+ //just embed the remining wires into the body
+ //result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, NULL, tolerance );
+ //if( !result.ok() )
+ // AcisQueryEngine::instance()->ACIS_API_error (result);
- //get midpoint of curve to embed
- ENTITY_LIST wire_edge_list;
- api_get_edges( wire_BODY_ptr, wire_edge_list );
- EDGE *wire_edge = (EDGE*)wire_edge_list[0];
- SPAposition mid_point = wire_edge->mid_pos();
+ //get midpoint of curve to embed
+ ENTITY_LIST wire_edge_list;
+ api_get_edges( wire_BODY_ptr, wire_edge_list );
+ EDGE *wire_edge = (EDGE*)wire_edge_list[0];
+ SPAposition mid_point = wire_edge->mid_pos();
- //get position at fraction 0.79 along curve
+ //get position at fraction 0.79 along curve
#ifdef BOYD16
- SPAposition start_point = wire_edge->start()->geometry()->coords();
+ SPAposition start_point = wire_edge->start()->geometry()->coords();
#endif
- SPAparameter s_param = wire_edge->start_param();
- SPAparameter e_param = wire_edge->end_param();
+ SPAparameter s_param = wire_edge->start_param();
+ SPAparameter e_param = wire_edge->end_param();
- //SPAinterval param_interval = wire_edge->param_range();
- SPAparameter new_parameter = s_param + ((e_param - s_param ) * 0.79);
+ //SPAinterval param_interval = wire_edge->param_range();
+ SPAparameter new_parameter = s_param + ((e_param - s_param ) * 0.79);
- if (wire_edge->sense() == REVERSED )
- new_parameter = -(new_parameter);
+ if (wire_edge->sense() == REVERSED )
+ new_parameter = -(new_parameter);
- SPAposition point_on_curve;
- wire_edge->geometry()->equation().eval(new_parameter, point_on_curve );
+ SPAposition point_on_curve;
+ wire_edge->geometry()->equation().eval(new_parameter, point_on_curve );
- //find surface which contains point at parameter 0.79 and midpoint
- //loop to find appropriate face
- ENTITY *temp_ENT;
- FACEs.init();
- FACE *embed_FACE = NULL;
- while( (temp_ENT = FACEs.next()) != NULL )
- {
- FACE *tmp_FACE = (FACE*)temp_ENT;
- SPAposition point1;
- api_find_cls_ptto_face(mid_point, tmp_FACE, point1 );
- if ( distance_to_point( point1, mid_point ) < 0.0005 )
- {
- api_find_cls_ptto_face(point_on_curve, tmp_FACE, point1 );
+ //find surface which contains point at parameter 0.79 and midpoint
+ //loop to find appropriate face
+ ENTITY *temp_ENT;
+ FACEs.init();
+ FACE *embed_FACE = NULL;
+ while( (temp_ENT = FACEs.next()) != NULL )
+ {
+ FACE *tmp_FACE = (FACE*)temp_ENT;
+ SPAposition point1;
+ api_find_cls_ptto_face(mid_point, tmp_FACE, point1 );
+ if ( distance_to_point( point1, mid_point ) < 0.0005 )
+ {
+ api_find_cls_ptto_face(point_on_curve, tmp_FACE, point1 );
- if ( distance_to_point( point1, point_on_curve ) < 0.0005 )
- {
- embed_FACE = tmp_FACE;
- break;
- }
- }
- }
- if( embed_FACE )
- {
- face_list->clear();
- face_list->add( (ENTITY*)embed_FACE );
- result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
- }
- }
+ if ( distance_to_point( point1, point_on_curve ) < 0.0005 )
+ {
+ embed_FACE = tmp_FACE;
+ break;
+ }
+ }
+ }
+ if( embed_FACE )
+ {
+ face_list->clear();
+ face_list->add( (ENTITY*)embed_FACE );
+ result = api_embed_wire_in_faces( wire_BODY_ptr, copied_BODY, face_list, tolerance );
+ }
+ }
- AcisModifyEngine::instance()->cleanup_slivers( copied_BODY );
+ AcisModifyEngine::instance()->cleanup_slivers( copied_BODY );
- //check to see if anything actually happened
- int num_vol_bef, num_face_bef, num_edge_bef, num_vertex_bef;
- CubitStatus status1 = AcisQueryEngine::instance()->number_ENTITIES( BODY_ptr, num_vol_bef,
- num_face_bef, num_edge_bef,
- num_vertex_bef );
+ //check to see if anything actually happened
+ int num_vol_bef, num_face_bef, num_edge_bef, num_vertex_bef;
+ CubitStatus status1 = AcisQueryEngine::instance()->number_ENTITIES( BODY_ptr, num_vol_bef,
+ num_face_bef, num_edge_bef,
+ num_vertex_bef );
- int num_vol_aft, num_face_aft, num_edge_aft, num_vertex_aft;
- CubitStatus status2 = AcisQueryEngine::instance()->number_ENTITIES( copied_BODY, num_vol_aft,
- num_face_aft, num_edge_aft,
- num_vertex_aft );
+ int num_vol_aft, num_face_aft, num_edge_aft, num_vertex_aft;
+ CubitStatus status2 = AcisQueryEngine::instance()->number_ENTITIES( copied_BODY, num_vol_aft,
+ num_face_aft, num_edge_aft,
+ num_vertex_aft );
- if( status1 == CUBIT_FAILURE ||
- status2 == CUBIT_FAILURE )
- {
- return CUBIT_FAILURE;
- }
+ if( status1 == CUBIT_FAILURE ||
+ status2 == CUBIT_FAILURE )
+ {
+ return CUBIT_FAILURE;
+ }
- if( num_vol_bef == num_vol_aft &&
- num_face_bef == num_face_aft &&
- num_edge_bef == num_edge_aft &&
- num_vertex_bef == num_vertex_aft)
- {
- AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY, CUBIT_TRUE);
- return CUBIT_SUCCESS;
- }
+ if( num_vol_bef == num_vol_aft &&
+ num_face_bef == num_face_aft &&
+ num_edge_bef == num_edge_aft &&
+ num_vertex_bef == num_vertex_aft)
+ {
+ AcisQueryEngine::instance()->delete_ACIS_BODY(copied_BODY, CUBIT_TRUE);
+ return CUBIT_SUCCESS;
+ }
- BodySM* new_body_ptr = get_new_Body( old_body_sm, BODY_ptr, copied_BODY,
- false, CUBIT_TRUE );
+ BodySM* new_body_ptr = get_new_Body( old_body_sm, BODY_ptr, copied_BODY,
+ false, CUBIT_TRUE );
- new_body = new_body_ptr;
- return CUBIT_SUCCESS;
- }
+ new_body = new_body_ptr;
+ return CUBIT_SUCCESS;
+}
- CubitStatus AcisModifyEngine::curve_surface_intersection( Surface *surface,
- Curve* curve,
- DLIList<Curve*> &new_curves ) const
- {
- FACE *FACE_ptr = AcisQueryEngine::get_FACE( surface );
- EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE( curve );
+CubitStatus AcisModifyEngine::curve_surface_intersection( Surface *surface,
+ Curve* curve,
+ DLIList<Curve*> &new_curves ) const
+{
+ FACE *FACE_ptr = AcisQueryEngine::get_FACE( surface );
+ EDGE *EDGE_ptr = AcisQueryEngine::get_EDGE( curve );
- ENTITY_LIST *ent_list = new ENTITY_LIST;
+ ENTITY_LIST *ent_list = new ENTITY_LIST;
- outcome result = api_edfa_int( EDGE_ptr, FACE_ptr, ent_list );
+ outcome result = api_edfa_int( EDGE_ptr, FACE_ptr, ent_list );
- if( !result.ok() || ent_list->count() == 0 )
- {
- delete ent_list;
- return CUBIT_FAILURE;
- }
+ if( !result.ok() || ent_list->count() == 0 )
+ {
+ delete ent_list;
+ return CUBIT_FAILURE;
+ }
- ENTITY *tmp_ent;
- ent_list->init();
- while( (tmp_ent=ent_list->next()) != NULL )
- {
- if( is_EDGE( tmp_ent ) )
- {
- EDGE_ptr = static_cast<EDGE*>(tmp_ent);
- Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
- new_curves.append( curve_ptr );
- }
- }
- delete ent_list;
+ ENTITY *tmp_ent;
+ ent_list->init();
+ while( (tmp_ent=ent_list->next()) != NULL )
+ {
+ if( is_EDGE( tmp_ent ) )
+ {
+ EDGE_ptr = static_cast<EDGE*>(tmp_ent);
+ Curve *curve_ptr = AcisQueryEngine::instance()->populate_topology_bridges(EDGE_ptr);
+ new_curves.append( curve_ptr );
+ }
+ }
+ delete ent_list;
- if( new_curves.size() == 0 )
- return CUBIT_FAILURE;
+ if( new_curves.size() == 0 )
+ return CUBIT_FAILURE;
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
- void AcisModifyEngine::get_new_ENTITIES(ENTITY *top_ENTITY, DLIList<ENTITY*> &new_ENTITIES) const
- {
- ENTITY_LIST ENTITIES;
- int i;
+void AcisModifyEngine::get_new_ENTITIES(ENTITY *top_ENTITY, DLIList<ENTITY*> &new_ENTITIES) const
+{
+ ENTITY_LIST ENTITIES;
+ int i;
- // vertices
- api_get_vertices( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
- {
- new_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
-
- // edges
- api_get_edges( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
- {
- new_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
- /*
- // faces
- api_get_faces( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
- {
+ // vertices
+ api_get_vertices( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
+ {
new_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
- */
}
+ }
+ ENTITIES.clear();
- void AcisModifyEngine::get_att_ENTITIES(ENTITY *top_ENTITY, DLIList<ENTITY*> &att_ENTITIES, char *att_name) const
+ // edges
+ api_get_edges( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
{
- ENTITY_LIST ENTITIES;
- int i;
- // vertices
- api_get_vertices( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- ATTRIB_SNL_SIMPLE *attribute =
- (ATTRIB_SNL_SIMPLE *) find_attrib(ENTITIES[i],
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE);
- for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
- find_next_attrib(attribute,
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE))
- {
- if( attribute->attribute_name() == att_name )
- att_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
+ new_ENTITIES.append_unique(ENTITIES[i]);
+ }
+ }
+ ENTITIES.clear();
+/*
+ // faces
+ api_get_faces( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ if (!ATTRIB_CUBIT_OWNER::cubit_owner(ENTITIES[i]))
+ {
+ new_ENTITIES.append_unique(ENTITIES[i]);
+ }
+ }
+ ENTITIES.clear();
+ */
+}
- // edges
- api_get_edges( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- ATTRIB_SNL_SIMPLE *attribute =
- (ATTRIB_SNL_SIMPLE *) find_attrib(ENTITIES[i],
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE);
- for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
- find_next_attrib(attribute,
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE))
- {
- if( attribute->attribute_name() == att_name )
- att_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
- /*
- // faces
- api_get_faces( top_ENTITY, ENTITIES);
- for (i = 0; i < ENTITIES.count(); i++)
- {
- ATTRIB_SNL_SIMPLE *attribute =
+void AcisModifyEngine::get_att_ENTITIES(ENTITY *top_ENTITY, DLIList<ENTITY*> &att_ENTITIES, char *att_name) const
+{
+ ENTITY_LIST ENTITIES;
+ int i;
+ // vertices
+ api_get_vertices( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ ATTRIB_SNL_SIMPLE *attribute =
(ATTRIB_SNL_SIMPLE *) find_attrib(ENTITIES[i],
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE);
- for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
- find_next_attrib(attribute,
- ATTRIB_SNL_TYPE,
- ATTRIB_SNL_SIMPLE_TYPE))
- {
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE);
+ for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
+ find_next_attrib(attribute,
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE))
+ {
if( attribute->attribute_name() == att_name )
- att_ENTITIES.append_unique(ENTITIES[i]);
- }
- }
- ENTITIES.clear();
- */
+ att_ENTITIES.append_unique(ENTITIES[i]);
}
+ }
+ ENTITIES.clear();
- CubitStatus AcisModifyEngine::cleanup_slivers( BODY *body_to_cleanup )
+ // edges
+ api_get_edges( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ ATTRIB_SNL_SIMPLE *attribute =
+ (ATTRIB_SNL_SIMPLE *) find_attrib(ENTITIES[i],
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE);
+ for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
+ find_next_attrib(attribute,
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE))
{
- double sliver_curve_tol = GeometryQueryTool::get_sliver_curve_cleanup_tolerance();
- double sliver_surface_tol = GeometryQueryTool::get_sliver_surface_cleanup_tolerance();
+ if( attribute->attribute_name() == att_name )
+ att_ENTITIES.append_unique(ENTITIES[i]);
+ }
+ }
+ ENTITIES.clear();
+/*
+ // faces
+ api_get_faces( top_ENTITY, ENTITIES);
+ for (i = 0; i < ENTITIES.count(); i++)
+ {
+ ATTRIB_SNL_SIMPLE *attribute =
+ (ATTRIB_SNL_SIMPLE *) find_attrib(ENTITIES[i],
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE);
+ for(;attribute != NULL;attribute = (ATTRIB_SNL_SIMPLE *)
+ find_next_attrib(attribute,
+ ATTRIB_SNL_TYPE,
+ ATTRIB_SNL_SIMPLE_TYPE))
+ {
+ if( attribute->attribute_name() == att_name )
+ att_ENTITIES.append_unique(ENTITIES[i]);
+ }
+ }
+ ENTITIES.clear();
+ */
+}
- ENTITY_LIST dummy_list;
- api_detect_short_edges( body_to_cleanup, dummy_list, sliver_curve_tol, true );
- api_detect_sliver_faces( body_to_cleanup, dummy_list, sliver_surface_tol, true );
+CubitStatus AcisModifyEngine::cleanup_slivers( BODY *body_to_cleanup )
+{
+ double sliver_curve_tol = GeometryQueryTool::get_sliver_curve_cleanup_tolerance();
+ double sliver_surface_tol = GeometryQueryTool::get_sliver_surface_cleanup_tolerance();
- return CUBIT_SUCCESS;
- }
+ ENTITY_LIST dummy_list;
+ api_detect_short_edges( body_to_cleanup, dummy_list, sliver_curve_tol, true );
+ api_detect_sliver_faces( body_to_cleanup, dummy_list, sliver_surface_tol, true );
- CubitStatus AcisModifyEngine::remove_curve_slivers( BodySM *body_sm,
- double lengthlimit ) const
- {
- //get the BODY
- BodyACIS *tmp_body_acis = CAST_TO(body_sm, BodyACIS );
- BODY *tmp_BODY = tmp_body_acis->get_BODY_ptr();
+ return CUBIT_SUCCESS;
+}
- //copy the BODY
- BODY *copy_BODY = AcisModifyEngine::instance()->copy_BODY( tmp_BODY, false );
+CubitStatus AcisModifyEngine::remove_curve_slivers( BodySM *body_sm,
+ double lengthlimit ) const
+{
+ //get the BODY
+ BodyACIS *tmp_body_acis = CAST_TO(body_sm, BodyACIS );
+ BODY *tmp_BODY = tmp_body_acis->get_BODY_ptr();
- //remove the slivers
- ENTITY_LIST removed_curves;
- outcome result = api_detect_short_edges( copy_BODY, removed_curves, lengthlimit, true );
+ //copy the BODY
+ BODY *copy_BODY = AcisModifyEngine::instance()->copy_BODY( tmp_BODY, false );
- if( !result.ok() )
- {
- PRINT_ERROR("Problem remove sliver curves\n");
- AcisQueryEngine::instance()->ACIS_API_error (result);
- api_delent( (ENTITY*)copy_BODY );
- return CUBIT_FAILURE;
- }
+ //remove the slivers
+ ENTITY_LIST removed_curves;
+ outcome result = api_detect_short_edges( copy_BODY, removed_curves, lengthlimit, true );
- TopologyEntity *te = body_sm->topology_entity();
- RefEntity *ref_ent = CAST_TO( te, RefEntity );
- PRINT_INFO("Removed %d sliver curves on body %d\n",
- removed_curves.count(), ref_ent->id() );
+ if( !result.ok() )
+ {
+ PRINT_ERROR("Problem remove sliver curves\n");
+ AcisQueryEngine::instance()->ACIS_API_error (result);
+ api_delent( (ENTITY*)copy_BODY );
+ return CUBIT_FAILURE;
+ }
- if( removed_curves.count() == 0 )
- {
- api_delent( (ENTITY*)copy_BODY );
- return CUBIT_SUCCESS;
- }
+ TopologyEntity *te = body_sm->topology_entity();
+ RefEntity *ref_ent = CAST_TO( te, RefEntity );
+ PRINT_INFO("Removed %d sliver curves on body %d\n",
+ removed_curves.count(), ref_ent->id() );
+
+ if( removed_curves.count() == 0 )
+ {
+ api_delent( (ENTITY*)copy_BODY );
+ return CUBIT_SUCCESS;
+ }
- get_new_Body(body_sm, tmp_BODY, copy_BODY, CUBIT_FALSE);
+ get_new_Body(body_sm, tmp_BODY, copy_BODY, CUBIT_FALSE);
- return CUBIT_SUCCESS;
- }
+ return CUBIT_SUCCESS;
+}
CubitStatus AcisModifyEngine::stitch_surfs(
DLIList<BodySM*>& surf_bodies,
Modified: cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/ACIS_SRC/AcisModifyEngine.hpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -461,7 +461,7 @@
const CubitVector &v2,
const CubitVector &v3,
DLIList<BodySM*>& results_list,
- bool imprint = false ) ;
+ bool imprint = false ) const;
//R int
//R- Number of bodies that were webcut ( >= 0 )
//I webcut_body_list
@@ -482,7 +482,7 @@
DLIList<BodySM*>& webcut_body_list,
BodySM const* tool_body,
DLIList<BodySM*>& results_list,
- bool imprint = false) ;
+ bool imprint = false) const;
//R int
//R- Number of bodies that were webcut ( >= 0 )
//I webcut_body_list
@@ -972,7 +972,7 @@
const CubitVector &point_2,
const CubitVector &point_3,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midplane_bodies ) const;
+ BodySM *&midsurface_body ) const;
//- Given 3 points that describe the mid_plane, return a body that
//- contains the trimmed surfaces defining the mid plane.
//- These surfaces will be part of the midplane_body and will
@@ -981,17 +981,17 @@
virtual CubitStatus get_spheric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus get_conic_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus get_toric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*> &midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus tweak_chamfer( DLIList<Curve*> &curve_list,
double left_offset,
Modified: cgm/trunk/geom/GeometryModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/GeometryModifyEngine.hpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/GeometryModifyEngine.hpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -253,7 +253,7 @@
//- Returns the ID of the new Body or CUBIT_FAILURE
virtual BodySM* cylinder( double hi, double r1, double r2,
- double r3) const = 0;
+ double r3 ) const = 0 ;
//- Creates an ACIS frustum and assigns it to a Body $
//- {hi} input height $
//- {r1} input radius in x-direction at base $
@@ -527,14 +527,12 @@
virtual CubitStatus scale( BodySM *&body, const CubitVector& factors ) = 0;
//HEADER- Webcut-related functions
- virtual CubitStatus webcut(
- DLIList<BodySM*>& webcut_body_list,
- const CubitVector &v1,
- const CubitVector &v2,
- const CubitVector &v3,
- DLIList<BodySM*>& results_list,
- bool imprint = false
- ) = 0;
+ virtual CubitStatus webcut( DLIList<BodySM*>& webcut_body_list,
+ const CubitVector &v1,
+ const CubitVector &v2,
+ const CubitVector &v3,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false ) const = 0;
//R int
//R- Number of bodies that were webcut ( >= 0 )
//I webcut_body_list
@@ -551,12 +549,10 @@
//- The newly created bodies are merged and imprinted depeding on
//- the respective flags.
- virtual CubitStatus webcut(
- DLIList<BodySM*>& webcut_body_list,
- BodySM const* tool_body,
- DLIList<BodySM*>& results_list,
- bool imprint = false
- ) = 0 ;
+ virtual CubitStatus webcut(DLIList<BodySM*>& webcut_body_list,
+ BodySM const* tool_body,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false ) const = 0 ;
//R int
//R- Number of bodies that were webcut ( >= 0 )
//I webcut_body_list
@@ -718,10 +714,10 @@
//- intersection graph.
virtual CubitStatus get_mid_plane( const CubitVector &point_1,
- const CubitVector &point_2,
+ const CubitVector &point_2,
const CubitVector &point_3,
- BodySM *body_to_trim_to,
- DLIList<BodySM*>& midplane_bodies ) const = 0;
+ BodySM *body_to_trim_to,
+ BodySM *&midplane_body ) const = 0;
//- Finds the mid plane described by the 3 points and trims
//- it to the body. It returns the mid planes as part of the
//- midplane_body
@@ -729,17 +725,17 @@
virtual CubitStatus get_spheric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midsurface_bodies ) const = 0;
+ BodySM *&midsurface_body ) const = 0;
virtual CubitStatus get_conic_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midsurface_bodies ) const = 0;
+ BodySM *&midsurface_body ) const = 0;
virtual CubitStatus get_toric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midsurface_bodies ) const = 0;
+ BodySM *&midsurface_body ) const = 0;
virtual CubitStatus tweak_chamfer( DLIList<Curve*> &curve_list,
double left_offset,
Modified: cgm/trunk/geom/GeometryModifyTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.cpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/GeometryModifyTool.cpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -7348,11 +7348,11 @@
CubitVector direction2 = direction1*n_mid;
point_3 = point_1 + direction2;
- DLIList<BodySM*> midplane_bodysm_list ;
+ BodySM* midplane_body_sm = NULL;
CubitStatus ret = gme1_ptr->get_mid_plane(point_1, point_2, point_3,
- body_sm_to_trim_to, midplane_bodysm_list );
+ body_sm_to_trim_to, midplane_body_sm );
- if (midplane_bodysm_list.size() > 0)
+ if (midplane_body_sm)
{
#ifdef BOYD17
DLIList<Body*> bodies;
@@ -7361,25 +7361,21 @@
Body *midplane_body;
- for (int j = 0; j < midplane_bodysm_list.size(); j++)
- {
- BodySM* midplane_body_sm = midplane_bodysm_list.get_and_step();
- midplane_body = GeometryQueryTool::instance()->make_Body(midplane_body_sm);
+ midplane_body = GeometryQueryTool::instance()->make_Body(midplane_body_sm);
- DLIList<RefFace*> ref_faces;
- midplane_body->ref_faces( ref_faces );
+ DLIList<RefFace*> ref_faces;
+ midplane_body->ref_faces( ref_faces );
- //make each surface of the body into its own body
- int i;
- for( i=0; i<ref_faces.size(); i++ )
- {
- RefEntity *new_entity_ptr;
- new_entity_ptr = GeometryModifyTool::instance()->copy_refentity(ref_faces.get_and_step());
- RefFace *ref_face_ptr = CAST_TO(new_entity_ptr, RefFace);
- mid_plane_surfs.append( ref_face_ptr );
- }
- GeometryQueryTool::instance()->delete_Body( midplane_body );
+ //make each surface of the body into its own body
+ int i;
+ for( i=0; i<ref_faces.size(); i++ )
+ {
+ RefEntity *new_entity_ptr;
+ new_entity_ptr = GeometryModifyTool::instance()->copy_refentity(ref_faces.get_and_step());
+ RefFace *ref_face_ptr = CAST_TO(new_entity_ptr, RefFace);
+ mid_plane_surfs.append( ref_face_ptr );
}
+ GeometryQueryTool::instance()->delete_Body( midplane_body );
}
else
return CUBIT_FAILURE;
@@ -7397,7 +7393,7 @@
CubitStatus get_planar_mid_surface( RefFace* ref_face1,
RefFace* ref_face2,
BodySM* body_sm_to_trim_to,
- DLIList<BodySM*>& midsurface_bodysm_list,
+ BodySM*& midsurface_body_sm,
GeometryModifyEngine *gme_ptr )
{
CubitVector normal_1, normal_2, point_1, point_2, point_3;
@@ -7496,7 +7492,7 @@
point_3 = point_1 + direction2;
CubitStatus ret = gme_ptr->get_mid_plane(point_1, point_2, point_3,
- body_sm_to_trim_to, midsurface_bodysm_list );
+ body_sm_to_trim_to, midsurface_body_sm );
return ret;
}
@@ -7515,8 +7511,8 @@
{
if( ref_face1 == ref_face2 )
{
- PRINT_ERROR("Cannot create midplane between the same surface.\n"
- " Surface %d was entered twice\n", ref_face1->id() );
+ PRINT_ERROR("Cannot create midplane between the same surface.\n",
+ " Surface %d was entered twice\n", ref_face1->id() );
return CUBIT_FAILURE;
}
@@ -7531,12 +7527,13 @@
bool found_case = false;
CubitStatus ret;
- DLIList<BodySM*> midsurfaces;
+ BodySM* midsurface_body_sm = NULL;
+
// Plane to plane case
if ( ( ref_face1->geometry_type() == PLANE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == PLANE_SURFACE_TYPE ) )
{
found_case = true;
- ret = get_planar_mid_surface( ref_face1, ref_face2, body_sm_to_trim_to, midsurfaces, gme1_ptr );
+ ret = get_planar_mid_surface( ref_face1, ref_face2, body_sm_to_trim_to, midsurface_body_sm, gme1_ptr );
}
// Quadric to quadric cases
@@ -7559,7 +7556,7 @@
PRINT_ERROR( "In GeometryModifyTool::get_mid_surface\n"
" Surfaces %d and %d do not have the same underlying geometry modeling engine.\n"
" For midsurface calculations, they must be the same\n",
- ref_face1->id(), ref_face2->id() );
+ ref_face1->id(), ref_face2 );
return CUBIT_FAILURE;
}
@@ -7578,19 +7575,19 @@
// Sphere to sphere case
if ( ( ref_face1->geometry_type() == SPHERE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == SPHERE_SURFACE_TYPE ) )
{
- ret = gme2_ptr->get_spheric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurfaces );
+ ret = gme2_ptr->get_spheric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
}
// Cone to cone case
if ( ( ref_face1->geometry_type() == CONE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == CONE_SURFACE_TYPE ) )
{
- ret = gme2_ptr->get_conic_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurfaces );
+ ret = gme2_ptr->get_conic_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
}
// Torus to torus case
if ( ( ref_face1->geometry_type() == TORUS_SURFACE_TYPE ) && ( ref_face2->geometry_type() == TORUS_SURFACE_TYPE ) )
{
- ret = gme2_ptr->get_toric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurfaces );
+ ret = gme2_ptr->get_toric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
}
}
@@ -7602,28 +7599,28 @@
return CUBIT_FAILURE;
}
- if ( midsurfaces.size() > 0)
+ if ( midsurface_body_sm )
{
- Body *midsurface_body;
- for(int j = 0; j < midsurfaces.size() ;j++)
+ DLIList<Surface*> mid_surfaces;
+ DLIList<Body*> new_bodies;
+ midsurface_body_sm->surfaces( mid_surfaces);
+ //make each surface of the body into its own body
+ int i;
+ for( i=0; i<mid_surfaces.size(); i++ )
{
- BodySM* midsurface_body_sm = midsurfaces.get_and_step();
- midsurface_body = GeometryQueryTool::instance()->make_Body(midsurface_body_sm);
+ Surface *tmp_surface = mid_surfaces.get_and_step();
+ bool extended_from = false;
+ Surface* new_surface_ptr = gme1_ptr->make_Surface( tmp_surface, extended_from );
+ Body *new_Body = make_Body(new_surface_ptr);
+ new_bodies.append( new_Body );
DLIList<RefFace*> ref_faces;
- midsurface_body->ref_faces( ref_faces );
-
- //make each surface of the body into its own body
- int i;
- for( i=0; i<ref_faces.size(); i++ )
- {
- RefEntity *new_entity_ptr;
- new_entity_ptr = GeometryModifyTool::instance()->copy_refentity(ref_faces.get_and_step());
- RefFace *ref_face_ptr = CAST_TO(new_entity_ptr, RefFace);
- mid_surface_surfs.append( ref_face_ptr );
- }
- GeometryQueryTool::instance()->delete_Body( midsurface_body );
+ new_Body->ref_faces(ref_faces);
+ RefFace *ref_face_ptr = ref_faces.get();
+ mid_surface_surfs.append( ref_face_ptr );
}
+ gme1_ptr->get_gqe()->delete_solid_model_entities( midsurface_body_sm );
+
return ret;
}
else
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -4572,18 +4572,18 @@
const CubitVector &v2,
const CubitVector &v3,
DLIList<BodySM*>& results_list,
- bool imprint )
+ bool imprint ) const
{
CubitStatus stat;
DLIList<BodySM*> new_BodySMs;
- stat = section(webcut_body_list, v1, v2, v3, new_BodySMs, true, true,false);
+ stat = OCCModifyEngine::instance()->section(webcut_body_list, v1, v2, v3, new_BodySMs, true, true,false);
if(stat == CUBIT_FAILURE)
{
PRINT_ERROR("Can't webcut the bodies using a plane determined by 3 points.\n");
return stat;
}
- stat = section(webcut_body_list, v1, v2, v3, new_BodySMs, false, false, false);
+ stat = OCCModifyEngine::instance()->section(webcut_body_list, v1, v2, v3, new_BodySMs, false, false, false);
if(stat == CUBIT_FAILURE)
{
PRINT_ERROR("Can't webcut the bodies using a plane determined by 3 points.\n");
@@ -4622,7 +4622,7 @@
CubitStatus OCCModifyEngine::webcut(DLIList<BodySM*>& webcut_body_list,
BodySM const* tool_body,
DLIList<BodySM*>& results_list,
- bool imprint )
+ bool imprint ) const
{
//do intersect and subtract separately and with imprint option and keep_old
// is true.
@@ -5700,7 +5700,7 @@
const CubitVector & point_2,
const CubitVector & point_3,
BodySM * body_to_trim_to,
- DLIList<BodySM*>& midplane_bodies ) const
+ BodySM *& result_body ) const
{
//Calculate normal of the mid plane
CubitVector v1, v2, normal;
@@ -5729,11 +5729,17 @@
BodySM* tool = CAST_TO(surf, OCCSurface)->my_body();
DLIList<BodySM*> from_bodies;
from_bodies.append(body_to_trim_to);
-
+ DLIList<BodySM*> midplane_bodies;
CubitStatus stat = intersect(tool, from_bodies, midplane_bodies,
CUBIT_TRUE);
OCCQueryEngine::instance()->delete_solid_model_entities(tool);
-
+ if (midplane_bodies.size() == 1)
+ result_body = midplane_bodies.get();
+ else {
+ for (int i = 0; i < midplane_bodies.size(); ++i)
+ OCCQueryEngine::instance()->delete_solid_model_entities(midplane_bodies.get_and_step());
+ stat = CUBIT_FAILURE;
+ }
return stat;
}
@@ -5747,7 +5753,7 @@
CubitStatus OCCModifyEngine::get_spheric_mid_surface( Surface* surface_ptr1,
Surface* surface_ptr2,
BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ BodySM*& result_body ) const
{
OCCSurface* occ_surf1 = CAST_TO(surface_ptr1, OCCSurface);
OCCSurface* occ_surf2 = CAST_TO(surface_ptr2, OCCSurface);
@@ -5778,12 +5784,19 @@
CubitVector center(center1.X(), center1.Y(), center1.Z());
OCCQueryEngine::instance()->translate(tool, center);
- DLIList<BodySM*> from_bodies;
+ DLIList<BodySM*> from_bodies, midsurface_bodies;
from_bodies.append(body_to_trim_to);
-
+
CubitStatus stat = intersect(tool, from_bodies, midsurface_bodies,
CUBIT_TRUE);
OCCQueryEngine::instance()->delete_solid_model_entities(tool);
+ if (midsurface_bodies.size() == 1)
+ result_body = midsurface_bodies.get();
+ else {
+ for (int i = 0; i < midsurface_bodies.size(); ++i)
+ OCCQueryEngine::instance()->delete_solid_model_entities(midsurface_bodies.get_and_step());
+ stat = CUBIT_FAILURE;
+ }
return stat;
}
@@ -5798,7 +5811,7 @@
CubitStatus OCCModifyEngine::get_conic_mid_surface( Surface* surface_ptr1,
Surface* surface_ptr2,
BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ BodySM*& result_body ) const
{
OCCSurface* occ_surf1 = CAST_TO(surface_ptr1, OCCSurface);
OCCSurface* occ_surf2 = CAST_TO(surface_ptr2, OCCSurface);
@@ -5892,12 +5905,19 @@
OCCQueryEngine::instance()->populate_topology_bridge(face, CUBIT_TRUE);
tool = CAST_TO(surface,OCCSurface)->my_body();
}
- DLIList<BodySM*> from_bodies;
+ DLIList<BodySM*> from_bodies, midsurface_bodies;
from_bodies.append(body_to_trim_to);
CubitStatus stat = intersect(tool, from_bodies, midsurface_bodies,
CUBIT_TRUE);
OCCQueryEngine::instance()->delete_solid_model_entities(tool);
+ if (midsurface_bodies.size() == 1)
+ result_body = midsurface_bodies.get();
+ else {
+ for (int i = 0; i < midsurface_bodies.size(); ++i)
+ OCCQueryEngine::instance()->delete_solid_model_entities(midsurface_bodies.get_and_step());
+ stat = CUBIT_FAILURE;
+ }
return stat;
}
@@ -5912,7 +5932,7 @@
CubitStatus OCCModifyEngine::get_toric_mid_surface( Surface* surface_ptr1,
Surface* surface_ptr2,
BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ BodySM*& result_body ) const
{
OCCSurface* occ_surf1 = CAST_TO(surface_ptr1, OCCSurface);
OCCSurface* occ_surf2 = CAST_TO(surface_ptr2, OCCSurface);
@@ -5971,12 +5991,19 @@
BodySM* tool = CAST_TO(lump, OCCLump)->get_body();
- DLIList<BodySM*> from_bodies;
+ DLIList<BodySM*> from_bodies, midsurface_bodies;
from_bodies.append(body_to_trim_to);
CubitStatus stat = intersect(tool, from_bodies, midsurface_bodies,
CUBIT_TRUE);
OCCQueryEngine::instance()->delete_solid_model_entities(tool);
+ if (midsurface_bodies.size() == 1)
+ result_body = midsurface_bodies.get();
+ else {
+ for (int i = 0; i < midsurface_bodies.size(); ++i)
+ OCCQueryEngine::instance()->delete_solid_model_entities(midsurface_bodies.get_and_step());
+ stat = CUBIT_FAILURE;
+ }
return stat;
}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -269,12 +269,12 @@
const CubitVector &v2,
const CubitVector &v3,
DLIList<BodySM*>& results_list,
- bool imprint = false ) ;
+ bool imprint = false ) const;
virtual CubitStatus webcut(DLIList<BodySM*>& webcut_body_list,
BodySM const* tool_body,
DLIList<BodySM*>& results_list,
- bool imprint = false ) ;
+ bool imprint = false ) const;
virtual CubitStatus webcut_across_translate( DLIList<BodySM*>& body_list,
Surface* plane_surf1,
@@ -374,23 +374,23 @@
const CubitVector &point_2,
const CubitVector &point_3,
BodySM *body_to_trim_to,
- DLIList<BodySM*>& midplane_bodies ) const;
+ BodySM *&midplane_body ) const;
virtual CubitStatus get_spheric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus get_conic_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus get_toric_mid_surface( Surface *surface_ptr1,
Surface *surface_ptr2,
BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ BodySM *&midsurface_body ) const;
virtual CubitStatus tweak_chamfer( DLIList<Curve*> &curve_list,
double left_offset,
Modified: cgm/trunk/geom/facet/FacetModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/facet/FacetModifyEngine.cpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/facet/FacetModifyEngine.cpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -1876,7 +1876,7 @@
const CubitVector &v3,
DLIList<BodySM*>& results_list,
bool imprint
- )
+ ) const
{
MODIFY_CHECK_RETURN_FAILURE;
@@ -2000,7 +2000,7 @@
DLIList<BodySM*>& /*webcut_body_list*/,
BodySM const* /*tool_body*/,
DLIList<BodySM*>& /*results_list*/,
- bool /*imprint*/ )
+ bool /*imprint*/ ) const
{
PRINT_ERROR("Option not supported for mesh based geometry.\n");
return CUBIT_FAILURE;
@@ -2634,7 +2634,7 @@
const CubitVector & /*point_2*/,
const CubitVector & /*point_3*/,
BodySM * /*body_to_trim_to*/,
- DLIList<BodySM*>& /*midplane_body*/ ) const
+ BodySM *& /*midplane_body*/ ) const
{
PRINT_ERROR("Option not supported for mesh based geometry.\n");
return CUBIT_FAILURE;
@@ -2648,9 +2648,9 @@
// Date : 03/06
//===============================================================================
CubitStatus FacetModifyEngine::get_spheric_mid_surface( Surface* surface_ptr1,
- Surface* surface_ptr2,
- BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ Surface* surface_ptr2,
+ BodySM* body_to_trim_to,
+ BodySM*& midsurface_body ) const
{
PRINT_ERROR("Option not supported for mesh based geometry.\n");
return CUBIT_FAILURE;
@@ -2664,9 +2664,9 @@
// Date : 03/06
//===============================================================================
CubitStatus FacetModifyEngine::get_conic_mid_surface( Surface* surface_ptr1,
- Surface* surface_ptr2,
- BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ Surface* surface_ptr2,
+ BodySM* body_to_trim_to,
+ BodySM*& midsurface_body ) const
{
PRINT_ERROR("Option not supported for mesh based geometry.\n");
return CUBIT_FAILURE;
@@ -2680,9 +2680,9 @@
// Date : 03/06
//===============================================================================
CubitStatus FacetModifyEngine::get_toric_mid_surface( Surface* surface_ptr1,
- Surface* surface_ptr2,
- BodySM* body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const
+ Surface* surface_ptr2,
+ BodySM* body_to_trim_to,
+ BodySM*& midsurface_body ) const
{
PRINT_ERROR("Option not supported for mesh based geometry.\n");
return CUBIT_FAILURE;
Modified: cgm/trunk/geom/facet/FacetModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/facet/FacetModifyEngine.hpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/geom/facet/FacetModifyEngine.hpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -325,12 +325,12 @@
const CubitVector &v3,
DLIList<BodySM*>& results_list,
bool imprint = false
- ) ;
+ ) const;
virtual CubitStatus webcut(DLIList<BodySM*>& webcut_body_list,
BodySM const* tool_body,
DLIList<BodySM*>& results_list,
- bool imprint = false);
+ bool imprint = false) const;
virtual CubitStatus webcut_across_translate( DLIList<BodySM*>& body_list,
Surface* plane_surf1,
@@ -469,20 +469,23 @@
const CubitVector &point_2,
const CubitVector &point_3,
BodySM *body_to_trim_to,
- DLIList<BodySM *>& midplane_bodies ) const;
+ BodySM *&midplane_body ) const;
virtual CubitStatus get_spheric_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const;
+
virtual CubitStatus get_conic_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const;
+
virtual CubitStatus get_toric_mid_surface( Surface *surface_ptr1,
- Surface *surface_ptr2,
- BodySM *body_to_trim_to,
- DLIList<BodySM *>&midsurface_bodies ) const;
+ Surface *surface_ptr2,
+ BodySM *body_to_trim_to,
+ BodySM *&midsurface_body ) const;
+
virtual CubitStatus tweak_chamfer( DLIList<Curve*> &curve_list,
double left_offset,
DLIList<BodySM*> &new_bodysm_list,
Modified: cgm/trunk/test/operation.cpp
===================================================================
--- cgm/trunk/test/operation.cpp 2010-01-26 21:18:33 UTC (rev 3492)
+++ cgm/trunk/test/operation.cpp 2010-01-27 00:35:39 UTC (rev 3493)
@@ -128,12 +128,12 @@
CubitVector v1(1,1,3);
CubitVector v2(1,2,2);
CubitVector v3(1,1,1);
- DLIList<BodySM*> mid_planes;
- status = OCCModifyEngine::instance()->get_mid_plane(v1, v2, v3, from_body, mid_planes);
- if(mid_planes.size() > 0)
+ BodySM* midplane_bodysm = 0;
+ status = OCCModifyEngine::instance()->get_mid_plane(v1, v2, v3, from_body, midplane_bodysm);
+ if(midplane_bodysm)
{
Body *midplane_body;
- midplane_body = gti->make_Body(mid_planes.pop());
+ midplane_body = gti->make_Body(midplane_bodysm);
double d = midplane_body->measure();
//d = 100
}
@@ -142,30 +142,16 @@
v2.x(2);
v3.x(2);
- status = OCCModifyEngine::instance()->get_mid_plane(v1, v2, v3, from_body, mid_planes);
- if(mid_planes.size() > 0)
+ midplane_bodysm = 0;
+ status = OCCModifyEngine::instance()->get_mid_plane(v1, v2, v3, from_body, midplane_bodysm);
+ if(midplane_bodysm)
{
Body *midplane_body;
- midplane_body = gti->make_Body(mid_planes.pop());
+ midplane_body = gti->make_Body(midplane_bodysm);
double d = midplane_body->measure();
//d = 70
}
- CubitVector v4(0,0,0);
- CubitVector v5(1,0,2);
- CubitVector v6(0,1,0);
- status = OCCModifyEngine::instance()->get_mid_plane(v4, v5, v6, from_body, mid_planes);
- if(mid_planes.size() > 0)
- {
- Body *midplane_body;
- for(int i = 0; i < mid_planes.size(); i++)
- {
- midplane_body = gti->make_Body(mid_planes.get_and_step());
- double d = midplane_body->measure();
- //d = 22.36 & 78.26
- }
- }
-
status = gmti->webcut_with_plane(from_bodies, v1, v2, v3, new_bodies, CUBIT_TRUE);
double d = new_bodies.step_and_get()->measure();
CubitVector v = new_bodies.get()->center_point();
More information about the cgma-dev
mailing list