[cgma-dev] r1280 - cgm/trunk/geom/OCC
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Fri Sep 21 12:56:58 CDT 2007
Author: kraftche
Date: 2007-09-21 12:56:58 -0500 (Fri, 21 Sep 2007)
New Revision: 1280
Added:
cgm/trunk/geom/OCC/FacetboolInterface.cpp
cgm/trunk/geom/OCC/FacetboolInterface.hpp
cgm/trunk/geom/OCC/GridSearchTree.cpp
cgm/trunk/geom/OCC/GridSearchTree.hpp
cgm/trunk/geom/OCC/GridSearchTreeNode.hpp
cgm/trunk/geom/OCC/OCCAttrib.hpp
cgm/trunk/geom/OCC/OCCAttribSet.cpp
cgm/trunk/geom/OCC/OCCAttribSet.hpp
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCCoEdge.cpp
cgm/trunk/geom/OCC/OCCCoEdge.hpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCCurve.hpp
cgm/trunk/geom/OCC/OCCGeometryCreator.hpp
cgm/trunk/geom/OCC/OCCLoop.cpp
cgm/trunk/geom/OCC/OCCLoop.hpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCLump.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/geom/OCC/OCCParamTool.cpp
cgm/trunk/geom/OCC/OCCParamTool.hpp
cgm/trunk/geom/OCC/OCCPoint.cpp
cgm/trunk/geom/OCC/OCCPoint.hpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCShell.hpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Initial checkin for previous work provided by 3rd party
Added: cgm/trunk/geom/OCC/FacetboolInterface.cpp
===================================================================
--- cgm/trunk/geom/OCC/FacetboolInterface.cpp (rev 0)
+++ cgm/trunk/geom/OCC/FacetboolInterface.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,1763 @@
+#include "FacetboolInterface.hpp"
+#include "FacetDataUtil.hpp"
+#include "FBDataUtil.hpp"
+#include "FBIntersect.hpp"
+#include "IntegerHash.hpp"
+#include "OCCBody.hpp"
+#include "BodySM.hpp"
+#include "Body.hpp"
+#include "OCCSurface.hpp"
+#include "FBDataUtil.hpp"
+#include "CubitPoint.hpp"
+#include "CubitPointData.hpp"
+#include "CubitFacetData.hpp"
+#include "OCCModifyEngine.hpp"
+#include "OCCQueryEngine.hpp"
+#include "OCCCurve.hpp"
+#include "CubitFacetEdge.hpp"
+#include "TDFacetboolData.hpp"
+#include "CurveFacetEvalTool.hpp"
+#include "OCCPoint.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "CubitBox.hpp"
+#include "FBImprint.hpp"
+#include "GfxDebug.hpp"
+#include "ChollaEngine.hpp"
+
+FacetboolInterface::FacetboolInterface()
+{
+
+}
+
+FacetboolInterface::~FacetboolInterface()
+{
+
+}
+
+//===============================================================================
+// Function : webcut_FB
+// Member Type: PUBLIC
+// Description: webcut a OCCBody with a FacetBool cutter
+// Author : John Fowler
+// Date : 02/04
+//===============================================================================
+CubitStatus FacetboolInterface::webcut_FB(BodySM *bodysm_ptr,
+ STD(vector)<double>& cutter_verts,
+ STD(vector)<int>& cutter_connections,
+ bool cutter_is_plane,
+ CubitBoolean delete_bodies,
+ CubitBoolean &intersects,
+ DLIList<BodySM*>& results_list)
+
+{
+ intersects = CUBIT_TRUE;
+ DLIList<OCCSurface*> facet_surf_list;
+ STD(vector)<double> body_verts;
+ STD(vector)<int> body_connections, newbodyfacets;
+ STD(vector)<int> newcutterfacets;
+ STD(vector)<int> f_c_indices1;
+ STD(vector)<OCCSurface *> fsurfarray;
+ STD(vector)<OCCCurve *> fcurvearray;
+ CubitStatus status;
+ int mydebug = 0;
+ OCCModifyEngine *fme = OCCModifyEngine::instance();
+ OCCBody *facet_body_ptr = CAST_TO(bodysm_ptr, OCCBody);
+
+ facet_body_ptr->get_surfaces(facet_surf_list);
+
+ status = facetbody_to_facetbool(facet_surf_list,body_verts,
+ body_connections,&f_c_indices1,
+ fsurfarray,fcurvearray);
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ FBIntersect *intersector = new FBIntersect();
+ intersector->set_classify_flag(true);
+ if ( cutter_is_plane == true ) intersector->set_body2_planar();
+
+ status = intersector->intersect(body_verts,body_connections,
+ cutter_verts,cutter_connections,
+ newbodyfacets,newcutterfacets,
+ &f_c_indices1,
+ 0);
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ bool *surfs_in_intersection, *surfs_in_subtraction;
+ bool *curves_in_intersection, *curves_in_subtraction;
+
+ surfs_in_intersection = new bool[1+fsurfarray.size()];
+ surfs_in_subtraction = new bool[1+fsurfarray.size()];
+ curves_in_intersection = new bool[1+fcurvearray.size()];
+ curves_in_subtraction = new bool[1+fcurvearray.size()];
+ unsigned int k;
+ for ( k = 1; k < 1 + fsurfarray.size(); k++ )
+ surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
+ for ( k = 1; k < 1 + fcurvearray.size(); k++ )
+ curves_in_subtraction[k] = curves_in_intersection[k] = false;
+
+ status = intersector->get_persistent_entity_info(surfs_in_intersection,
+ curves_in_intersection,surfs_in_subtraction,
+ curves_in_subtraction,CUBIT_FB_INTERSECTION,1);
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ facet_surf_list.reset();
+
+ STD(vector)<int> surfindex, surfindex2;
+ STD(vector)<int> curveindex, curveindex2;
+ STD(vector)<double> vertsout, vertsout2;
+ STD(vector)<int> coordsout, coordsout2;
+
+ status = intersector->gather_by_boolean(vertsout,coordsout,
+ &surfindex,&curveindex,0,
+ CUBIT_FB_INTERSECTION);
+ if( status == CUBIT_FAILURE )
+ return status;
+ status = intersector->gather_by_boolean(vertsout2,coordsout2,
+ &surfindex2,&curveindex2,0,
+ CUBIT_FB_SUBTRACTION);
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ // If there were no intersections
+ if ( (vertsout.size() == 0) || (coordsout.size() == 0) ||
+ (vertsout2.size() == 0) || (coordsout2.size() == 0) )
+ {
+ intersects = CUBIT_FALSE;
+ delete intersector;
+ delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
+ delete [] curves_in_intersection; delete [] curves_in_subtraction;
+ return CUBIT_SUCCESS;
+ }
+
+ CubitPoint *new_point;
+ STD(vector)<CubitPoint *> points;
+
+ for ( k = 0; k < vertsout.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout[k],
+ vertsout[k+1],
+ vertsout[k+2] );
+ points.push_back(new_point);
+ }
+
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitFacet *facet_ptr;
+ if(mydebug)
+ GfxDebug::clear();
+ for ( k = 0; k < coordsout.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout[k]],
+ points[coordsout[k+1]],
+ points[coordsout[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex[k];
+ cptr[1] = curveindex[k+1];
+ cptr[2] = curveindex[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
+ facet_ptr->is_backwards());
+ if(mydebug){
+ facet_ptr->debug_draw(CUBIT_YELLOW);
+ CubitVector tmp1 = points[coordsout[k]]->coordinates();
+ CubitVector tmp2 = points[coordsout[k+1]]->coordinates();
+ CubitVector tmp3 = points[coordsout[k+2]]->coordinates();
+
+ if(cptr[0]){
+ GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE);
+ }
+ if(cptr[1]){
+ GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN);
+ }
+ if(cptr[2]){
+ GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE);
+ }
+ }
+ facet_list.append( facet_ptr );
+ }
+ if(mydebug){
+ GfxDebug::mouse_xforms();
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr, *body_ptr2;
+ //determine if original body is a sheet body
+ Body *tmp_body = CAST_TO(bodysm_ptr->topology_entity(), Body);
+ bool is_sheet_body = false;
+ if( tmp_body->is_sheet_body() )
+ is_sheet_body = true;
+
+ //mbrewer: This is not the best solution. For now, we are using
+ // a no feature angle unless we are working with a sheet-body. For
+ // sheet-bodies, however, we are not marking the vertices that
+ // bound curves. Therefore, if we do not use a feature angle, curves
+ // are not split correctly. The correct fix would be to mark
+ // the vertices and maintain them through the webcut.
+ if( is_sheet_body )
+ feature_angle = 135.0;
+ else
+ feature_angle = 0.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_ptr);
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+ DLIList<BodySM*> new_bodies;
+
+ status = separate_shells_into_bodies( body_ptr, is_sheet_body, new_bodies );
+ if( status == CUBIT_FAILURE )
+ return status;
+ for(k=new_bodies.size(); k--;)
+ results_list.append( new_bodies.get_and_step() );
+
+ vertsout.clear();
+ coordsout.clear();
+
+ facet_list.clean_out();
+ for ( k = 0; k < vertsout2.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
+ vertsout2[k+1],
+ vertsout2[k+2] );
+ points.push_back(new_point);
+ }
+ for ( k = 0; k < coordsout2.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout2[k]],
+ points[coordsout2[k+1]],
+ points[coordsout2[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex2[k];
+ cptr[1] = curveindex2[k+1];
+ cptr[2] = curveindex2[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
+ facet_ptr->is_backwards());
+ if(mydebug){
+ CubitVector tmp1 = points[coordsout2[k]]->coordinates();
+ CubitVector tmp2 = points[coordsout2[k+1]]->coordinates();
+ CubitVector tmp3 = points[coordsout2[k+2]]->coordinates();
+ if(cptr[0]){
+ GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE);
+ }
+ if(cptr[1]){
+ GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN);
+ }
+ if(cptr[2]){
+ GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE);
+ }
+ }
+ facet_list.append( facet_ptr );
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_ptr2);
+ if( status == CUBIT_FAILURE )
+ return status;
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+ new_bodies.clean_out();
+ status = separate_shells_into_bodies( body_ptr2, is_sheet_body, new_bodies );
+ if( status == CUBIT_FAILURE )
+ return status;
+ for(k=new_bodies.size(); k--;)
+ results_list.append( new_bodies.get_and_step() );
+
+ if ( delete_bodies == CUBIT_TRUE )
+ make_persistents_webcut(bodysm_ptr,body_ptr,body_ptr2,fsurfarray,fcurvearray,
+ surfs_in_intersection,surfs_in_subtraction,
+ curves_in_intersection,curves_in_subtraction);
+
+ vertsout2.clear();
+ coordsout2.clear();
+
+ delete intersector;
+ delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
+ delete [] curves_in_intersection; delete [] curves_in_subtraction;
+
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus FacetboolInterface::separate_lumps( BodySM *body_ptr,
+ bool is_sheet_body)
+{
+ //get all the shells in 'body_ptr'
+ DLIList<OCCShell*> facet_shells;
+ OCCBody *facet_body = CAST_TO( body_ptr, OCCBody );
+ facet_body->get_shells( facet_shells );
+
+ // some shells here might contain more than one connected
+ // patch of surfaces...which is illegal. Separate them into their own shells.
+ bool created_shells = false;
+ int k,i;
+ for( k=facet_shells.size(); k--; )
+ {
+ OCCShell *facet_shell = facet_shells.get_and_step();
+ DLIList<OCCSurface*> facet_surfs;
+ facet_shell->get_surfaces( facet_surfs );
+ DLIList<OCCSurface*> connected_patch;
+ int max_num_passes = facet_surfs.size();
+ int num_passes=0; //prevents infinite loop
+ while( facet_surfs.size() && num_passes < max_num_passes )
+ {
+ connected_patch.clean_out();
+ OCCQueryEngine::instance()->get_connected_patch( facet_surfs, connected_patch );
+
+ if( num_passes == 0 )
+ {
+ int kk;
+ for( kk=connected_patch.size(); kk--; )
+ {
+ OCCSurface *f_surf = connected_patch.get_and_step();
+ if( is_sheet_body )
+ f_surf->set_shell_sense( facet_shell, CUBIT_UNKNOWN );
+ else
+ f_surf->set_shell_sense( facet_shell, CUBIT_FORWARD );
+ }
+ }
+ else //extract surfaces out of current shell and make them into their own shell
+ {
+
+ facet_shell->disconnect_surfaces( connected_patch );
+
+ DLIList<Surface*> tmp_surfs;
+ CAST_LIST( connected_patch, tmp_surfs, Surface );
+ ShellSM *shellsm_ptr;
+ OCCModifyEngine::instance()->make_facet_shell(tmp_surfs, shellsm_ptr);
+ if ( shellsm_ptr == NULL )
+ {
+ PRINT_ERROR("Problems building facet based shell entity.\n");
+ }
+ else
+ {
+ OCCShell *tmp_shell = static_cast<OCCShell*>(shellsm_ptr);
+
+ int kk;
+ //now for each surface, add sense wrt this new shell
+ for( kk=tmp_surfs.size(); kk--;)
+ {
+ OCCSurface *tmp_facet_surf = CAST_TO(tmp_surfs.get_and_step(), OCCSurface);
+
+ //if it's not a sheet body, tag the surfs wrt the shell, FORWARD
+ if( is_sheet_body )
+ tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_UNKNOWN );
+ else
+ tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_FORWARD );
+ }
+
+ created_shells = true;
+ OCCLump *facet_lump = static_cast<OCCLump*>( facet_shell->get_lump() );
+ facet_lump->add_shell( tmp_shell );
+ }
+ }
+ num_passes++;
+ }
+ }
+
+ bool created_lumps = false;
+ DLIList<OCCShell*> void_shells;
+ int number_regions = 0;
+ if( created_shells )
+ {
+ //determine which shells are regions and which are voids
+ //get a point we know is outside the body
+ CubitBox bbox;
+ CubitVector centroid;
+ double vol;
+ facet_body->mass_properties( centroid, vol );
+ OCCQueryEngine::instance()->create_facet_bounding_box( facet_body, bbox );
+ CubitVector point_outside = 2*(bbox.maximum() - centroid);
+ point_outside = centroid + point_outside;
+
+ facet_shells.clean_out();
+ facet_body->get_shells( facet_shells );
+ for( k=facet_shells.size(); k--; )
+ {
+ OCCShell *facet_shell = facet_shells.get_and_step();
+ CubitPointContainment point_cont;
+ point_cont = facet_shell->point_containment( point_outside );
+
+ if( point_cont == CUBIT_PNT_OUTSIDE )
+ number_regions++;
+ else if( point_cont == CUBIT_PNT_INSIDE )
+ void_shells.append( facet_shell );
+
+ //is a region...if it is the second found region, should be
+ //in its own lump
+ if( number_regions>1 && point_cont == CUBIT_PNT_OUTSIDE )
+ {
+ created_lumps = true;
+
+ //remove this shell from its current Lump
+ OCCLump *tmp_lump = static_cast<OCCLump*>(facet_shell->get_lump());
+ tmp_lump->remove_shell( facet_shell );
+
+ //make a new lump containing this shell
+ Lump *new_lump;
+ DLIList<ShellSM*> sm_shells;
+ sm_shells.append( static_cast<ShellSM*>(facet_shell) );
+ OCCModifyEngine::instance()->make_facet_lump( sm_shells, new_lump );
+
+ //add lump to body
+ facet_body->add_lump( static_cast<OCCLump*>(new_lump) );
+ }
+ }
+ }
+
+ if( void_shells.size() && created_lumps )
+ {
+ //the void shells are still in the original lump. We need to pair each
+ //up with the region that encloses it
+
+ //make a list of all the region (non-void) shells in the body
+ DLIList<OCCShell*> region_shells;
+ facet_body->get_shells( region_shells );
+ for(k=void_shells.size(); k--;)
+ {
+ if( region_shells.move_to( void_shells.get_and_step() ) )
+ region_shells.change_to( NULL );
+ }
+ region_shells.remove_all_with_value( NULL );
+
+ //for each void lump...find the region that contains it
+ for( k=void_shells.size(); k--; )
+ {
+ OCCShell *void_shell = void_shells.get_and_step();
+
+ //get a point on the void
+ DLIList<OCCSurface*> tmp_surfs;
+ void_shell->get_surfaces( tmp_surfs );
+ CubitVector point_on_shell;
+
+ DLIList<CubitFacet*> facet_list;
+ tmp_surfs.get()->tris( facet_list );
+
+ point_on_shell = facet_list.get()->center();
+
+ //get the region that contains that point
+ for( i=region_shells.size(); i--; )
+ {
+ OCCShell *region_shell = region_shells.get_and_step();
+
+ tmp_surfs.clean_out();
+ region_shell->get_surfaces( tmp_surfs );
+
+ if( region_shell->point_containment( point_on_shell )
+ == CUBIT_PNT_INSIDE )
+ {
+ //remove the void shell from it's lump
+ OCCLump *tmp_lump = static_cast<OCCLump*>(void_shell->get_lump());
+ tmp_lump->remove_shell( void_shell );
+
+ //add the void shell to the region's lump
+ tmp_lump = static_cast<OCCLump*>(region_shell->get_lump());
+ tmp_lump->add_shell( void_shell );
+ break;
+ }
+ }
+ }
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus FacetboolInterface::separate_shells_into_bodies(BodySM *body_ptr,
+ bool is_sheet_body,
+ DLIList<BodySM*> &new_bodies)
+{
+ //first separate the body into its lumps
+ if(!separate_lumps(body_ptr,is_sheet_body))
+ return CUBIT_FAILURE;
+
+ //split out each lump into it's own body
+ DLIList<BodySM*> split_bodies;
+ OCCModifyEngine::instance()->split_body( body_ptr, split_bodies);
+ new_bodies += split_bodies;
+
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus FacetboolInterface::facetbody_to_facetbool(
+ DLIList<OCCSurface*> &facet_surf_list,
+ STD(vector)<double> &body_verts,
+ STD(vector)<int> &body_connections,
+ STD(vector)<int> *f_c_indices,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray
+ )
+{
+ CubitStatus status;
+ int mydebug = 0;
+
+ if(mydebug){
+ GfxDebug::clear();
+ }
+ int i, j, k, m, n, vtx[3], hashvalue, *hasharrayptr, hasharraysize, ifoundit;
+ IntegerHash *hashobj;
+ double xx, yy, zz, xval, yval, zval;
+ OCCSurface *facet_surface;
+ DLIList<CubitFacet*> facetlist;
+ DLIList<CubitFacetEdge*> c_edgelist, f_edgelist;
+ DLIList<OCCCurve *> curve_list;
+ CubitPoint *point;
+ CubitFacet *facet;
+ OCCCurve *curve;
+ CubitFacetEdge *c_edge, *edge;
+ int numhashbins, c_index;
+
+ numhashbins = 101;
+ status = CUBIT_SUCCESS;
+ hashobj = new IntegerHash(numhashbins,20);
+
+ for ( i = 0; i < facet_surf_list.size(); i++ ) {
+ facet_surface = facet_surf_list.get_and_step();
+ fsurfarray.push_back(facet_surface);
+ facet_surface->get_my_facetedges(f_edgelist);
+ for ( m = f_edgelist.size(); m > 0; m-- ) {
+ edge = f_edgelist.get_and_step();
+ edge->set_flag(0); // Initialize edge flags.
+ if(mydebug)
+ edge->debug_draw(CUBIT_PINK);
+ }
+ // Assume that each facet surf occurs only once, so there won't be
+ // duplicates on fsarray.
+ facetlist.clean_out();
+ facet_surface->tris(facetlist);
+ curve_list.clean_out();
+ facet_surface->get_curves(curve_list);
+ for ( m = 0; m < curve_list.size(); m++ ) {
+ curve = curve_list.get_and_step();
+ c_index = findcurve(curve,fcurvearray);
+ c_edgelist.clean_out();
+ curve->get_facets(c_edgelist);
+ for ( n = c_edgelist.size(); n > 0; n-- ) {
+ c_edge = c_edgelist.get_and_step();
+ c_edge->set_flag(c_index+1);
+ if(mydebug)
+ c_edge->debug_draw(CUBIT_RED);
+
+ }
+ }
+ int efindex[3];
+ for ( j = facetlist.size(); j > 0; j-- ) {
+ facet = facetlist.get_and_step();
+ for ( k = 0; k < 3; k++ ) {
+ point = facet->point(k);
+ edge = facet->edge(k);
+ if(mydebug){
+ if(edge->get_flag()){
+ edge->debug_draw(CUBIT_WHITE);
+ }
+ }
+ efindex[k] = edge->get_flag();
+ xx = point->x();
+ yy = point->y();
+ zz = point->z();
+ // Get a vertex number.
+ hashvalue = FBDataUtil::makeahashvaluefrom_coord(xx,yy,zz,numhashbins);
+ hasharrayptr = hashobj->getHashBin(hashvalue,&hasharraysize);
+ ifoundit = -1;
+ for ( m = 0; m < hasharraysize; m++ ) {
+ n = hasharrayptr[m];
+ xval = body_verts[3*n];
+ yval = body_verts[3*n+1];
+ zval = body_verts[3*n+2];
+ if ( ( fabs(xval-xx) < 1.e-6 ) &&
+ ( fabs(yval-yy) < 1.e-6 ) &&
+ ( fabs(zval-zz) < 1.e-6 ) ) {
+ ifoundit = n;
+ break;
+ }
+ }
+ if ( ifoundit == -1 ) {
+ ifoundit = body_verts.size()/3;
+ body_verts.push_back(xx);
+ body_verts.push_back(yy);
+ body_verts.push_back(zz);
+ hashobj->addtoHashList(hashvalue,ifoundit);
+ }
+ vtx[k] = ifoundit;
+ }
+ body_connections.push_back(vtx[0]);
+ body_connections.push_back(vtx[1]);
+ body_connections.push_back(vtx[2]);
+ f_c_indices->push_back(i+1); // put the surface index for the facet
+ f_c_indices->push_back(efindex[2]); // edge indices for the facet
+ f_c_indices->push_back(efindex[0]);
+ f_c_indices->push_back(efindex[1]);
+ }
+ }
+ if(mydebug)
+ GfxDebug::mouse_xforms();
+ delete hashobj;
+ return status;
+
+}
+
+//===============================================================================
+// Function : dofacetboolean
+// Member Type: PUBLIC
+// Description: do facetboolean operations on a list of bodies.
+// Author : John Fowler
+// Date : 02/04
+//===============================================================================
+CubitStatus FacetboolInterface::dofacetboolean(DLIList<BodySM*>& body_list,
+ BodySM*& newBody,
+ bool keep_old,
+ const CubitFacetboolOp op)
+{
+ int k;
+ BodySM *body_sm1, *body_sm2, *body_out;
+ CubitStatus status = CUBIT_FAILURE;
+ bool intersection_found = false;
+
+ body_sm1 = body_list.get_and_step();
+
+ for ( k = body_list.size() - 1; k > 0; k-- ) {
+ body_out =0;
+ if(!body_sm1)
+ body_sm1=body_list.get_and_step();
+ else{
+ body_sm2 = body_list.get_and_step();
+ status = dofacetboolean_2bodies(body_sm1,body_sm2,body_out,keep_old,
+ intersection_found,op);
+ if ( keep_old == false){
+ //if there was an intersection, we want to delete the two
+ //original bodies if we are not keeping old.
+ //Also, if we we were performing an INTERSECTION we
+ //want to delete the two original bodies even if there was
+ //no intersection between the two bodies (again if we
+ //are not keeping originals).
+ if(intersection_found == true || op == CUBIT_FB_INTERSECTION) {
+ OCCQueryEngine::instance()->
+ delete_solid_model_entities(body_sm2);
+ OCCQueryEngine::instance()->
+ delete_solid_model_entities(body_sm1);
+ body_sm2=NULL;
+ body_sm1=NULL;
+ }
+ //if we are not keeping old, we want to delete the second
+ //body even if there was no intersection between the two
+ //bodies (for a subtration).
+ else if(op == CUBIT_FB_SUBTRACTION) {
+ OCCQueryEngine::instance()->
+ delete_solid_model_entities(body_sm2);
+ body_sm2=NULL;
+ }
+ }
+
+ if ( body_out ) body_sm1 = body_out;
+ }
+ }
+ newBody = body_sm1;
+
+ return status;
+}
+
+//===============================================================================
+// Function : dofacetboolean_subtract
+// Member Type: PUBLIC
+// Description: do facetboolean subtract operations on a list of bodies.
+// Author : John Fowler
+// Date : 02/04
+//===============================================================================
+CubitStatus FacetboolInterface::dofacetboolean_subtract(BodySM*& tool_body,
+ DLIList<BodySM*>& from_bodies,
+ DLIList<BodySM*>& new_bodies,
+ bool keep_old,
+ bool* to_be_deleted,
+ const CubitFacetboolOp op)
+{
+ int k;
+ BodySM *body_sm2, *body_out;
+ CubitStatus status = CUBIT_FAILURE;
+ bool intersection_found = false;
+
+ for ( k = 0; k < from_bodies.size(); k++ ) {
+ body_out = 0;
+ body_sm2 = from_bodies.get_and_step();
+ status = dofacetboolean_2bodies(body_sm2,tool_body,body_out,keep_old,
+ intersection_found,op);
+ if ( (keep_old == false) && (intersection_found == true) ) {
+ to_be_deleted[k] = true;
+ }
+
+ if ( (status == CUBIT_SUCCESS) && (body_out) ) new_bodies.append(body_out);
+ }
+
+ return status;
+}
+
+CubitStatus FacetboolInterface::dofacetboolean_2bodies(BodySM*& body_in1,
+ BodySM*& body_in2,
+ BodySM*& body_out,
+ bool keep_old,
+ bool& intersection_found,
+ const CubitFacetboolOp op)
+{
+
+CubitStatus status;
+STD(vector)<double> body_verts;
+STD(vector)<double> body2_verts;
+STD(vector)<int> body_connections, newbodyfacets;
+STD(vector)<int> body2_connections, newbody2facets;
+STD(vector)<double> vertsout;
+STD(vector)<int> coordsout;
+STD(vector)<int> f_c_indices1;
+STD(vector)<int> f_c_indices2;
+STD(vector)<OCCSurface *> fsurfarray1, fsurfarray2;
+STD(vector)<OCCCurve *> fcurvearray1, fcurvearray2;
+STD(vector)<int> surfindex;
+STD(vector)<int> curveindex;
+
+
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ STD(vector)<CubitPoint *> points;
+ bool *surfs_in_intersection, *surfs_in_subtraction;
+ bool *curves_in_intersection, *curves_in_subtraction;
+ bool *surfs_in_intersection2, *surfs_in_subtraction2;
+ bool *curves_in_intersection2, *curves_in_subtraction2;
+
+ status = CUBIT_SUCCESS;
+ intersection_found = true;
+ bool is_sheet_body = false;
+ Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
+ Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
+ //try to figure out if we are using sheet bodies
+ //if it is ambiguous, print a warning.
+ if(tmp_body_1 && tmp_body_1->is_sheet_body()){
+ is_sheet_body = true;
+ }
+ else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
+ is_sheet_body = true;
+ }
+ if(tmp_body_1 && tmp_body_2 &&
+ tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
+ {
+ PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
+ }
+ OCCBody *fbody_ptr;
+ fbody_ptr = dynamic_cast<OCCBody *>(body_in1);
+ DLIList<OCCSurface*> facet_surf_list;
+ fbody_ptr->get_surfaces(facet_surf_list);
+
+ status = facetbody_to_facetbool(facet_surf_list,body_verts,
+ body_connections,&f_c_indices1,
+ fsurfarray1,fcurvearray1);
+ facet_surf_list.clean_out();
+
+ fbody_ptr = dynamic_cast<OCCBody *>(body_in2);
+ fbody_ptr->get_surfaces(facet_surf_list);
+ status = facetbody_to_facetbool(facet_surf_list,body2_verts,
+ body2_connections,&f_c_indices2,
+ fsurfarray2,fcurvearray2);
+ facet_surf_list.clean_out();
+
+ FBIntersect *intersector = new FBIntersect();
+ intersector->set_classify_flag(true);
+
+ status = intersector->intersect(body_verts,body_connections,
+ body2_verts,body2_connections,
+ newbodyfacets,newbody2facets,
+ &f_c_indices1,
+ &f_c_indices2);
+
+ STD(vector)<bool> is_body_1;
+ status = intersector->gather_by_boolean(vertsout,coordsout,
+ &surfindex,&curveindex,&is_body_1,op);
+
+ // If there were no intersections
+ if ( (vertsout.size() == 0) || (coordsout.size() == 0)) {
+ delete intersector;
+ intersection_found = false;
+ return CUBIT_SUCCESS;
+ }
+ // If there was no body_out, we are just checking if there was any
+ // intersection. If we got this far, there was -- so return.
+ if ( &body_out == 0 ) return CUBIT_SUCCESS;
+
+ surfs_in_intersection = new bool[1+fsurfarray1.size()];
+ surfs_in_subtraction = new bool[1+fsurfarray1.size()];
+ curves_in_intersection = new bool[1+fcurvearray1.size()];
+ curves_in_subtraction = new bool[1+fcurvearray1.size()];
+ surfs_in_intersection2 = new bool[1+fsurfarray2.size()];
+ surfs_in_subtraction2 = new bool[1+fsurfarray2.size()];
+ curves_in_intersection2 = new bool[1+fcurvearray2.size()];
+ curves_in_subtraction2 = new bool[1+fcurvearray2.size()];
+
+ unsigned int k;
+ for ( k = 1; k < 1 + fsurfarray1.size(); k++ ) {
+ surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
+ }
+ for ( k = 1; k < 1 + fcurvearray1.size(); k++ ) {
+ curves_in_subtraction[k] = curves_in_intersection[k] = false;
+ }
+
+ for ( k = 1; k < 1 + fsurfarray2.size(); k++ ) {
+ surfs_in_subtraction2[k] = surfs_in_intersection2[k] = false;
+ }
+ for ( k = 1; k < 1 + fcurvearray2.size(); k++ ) {
+ curves_in_subtraction2[k] = curves_in_intersection2[k] = false;
+ }
+
+ status = intersector->get_persistent_entity_info(surfs_in_intersection,
+ curves_in_intersection,surfs_in_subtraction,
+ curves_in_subtraction,op,1);
+ // If op == unite, the curves ans surfs that are undamaged are those
+ // for which xxx_in_intereseciton = 0 false and xxx_in_subtraction == true
+
+ status = intersector->get_persistent_entity_info(surfs_in_intersection2,
+ curves_in_intersection2,surfs_in_subtraction2,
+ curves_in_subtraction2,op,2);
+
+ delete intersector;
+
+ for ( k = 0; k < vertsout.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout[k],
+ vertsout[k+1],
+ vertsout[k+2] );
+ points.push_back(new_point);
+ }
+ for ( k = 0; k < coordsout.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout[k]],
+ points[coordsout[k+1]],
+ points[coordsout[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex[k];
+ cptr[1] = curveindex[k+1];
+ cptr[2] = curveindex[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],is_body_1[k/3],
+ facet_ptr->is_backwards());
+
+ facet_list.append( facet_ptr );
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ OCCModifyEngine *fme = OCCModifyEngine::instance();
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr;
+ feature_angle = 135.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_ptr);
+ if( status == CUBIT_FAILURE )
+ return status;
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+
+ if ( keep_old == false ) {
+ make_persistents_boolean(body_in2,body_ptr,fsurfarray2,fcurvearray2,
+ surfs_in_intersection2,surfs_in_subtraction2,
+ curves_in_intersection2,curves_in_subtraction2,op,false);
+ make_persistents_boolean(body_in1,body_ptr,fsurfarray1,fcurvearray1,
+ surfs_in_intersection,surfs_in_subtraction,
+ curves_in_intersection,curves_in_subtraction,op,true);
+
+ }
+
+ body_out = body_ptr;
+ //separate the lumps in the "body_out", these will be converted to
+ //separate volumes later in the code.
+ status=separate_lumps(body_out,is_sheet_body);
+ vertsout.clear();
+ coordsout.clear();
+ delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
+ delete [] curves_in_intersection; delete [] curves_in_subtraction;
+ delete [] surfs_in_intersection2; delete [] surfs_in_subtraction2;
+ delete [] curves_in_intersection2; delete [] curves_in_subtraction2;
+
+ return status;
+
+}
+
+int FacetboolInterface::findcurve(OCCCurve *curve,
+ STD(vector)<OCCCurve *>& fcurvearray)
+{
+unsigned int i;
+
+ for ( i = 0; i < fcurvearray.size(); i++ ) {
+ if ( fcurvearray[i] == curve ) {
+ return i;
+ }
+ }
+ fcurvearray.push_back(curve);
+
+ return fcurvearray.size() - 1;
+}
+
+void FacetboolInterface::make_persistents_webcut(BodySM *body_in,
+ BodySM *body_out1,
+ BodySM *body_out2,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ bool *surfs_in_intersection,
+ bool *surfs_in_subtraction,
+ bool *curves_in_intersection,
+ bool *curves_in_subtraction
+ )
+{
+unsigned int k, n;
+DLIList<CubitSimpleAttrib*> csa_list;
+OCCBody *facet_body_in = CAST_TO(body_in, OCCBody);
+OCCBody *facet_body_out1;
+OCCBody *facet_body_out2;
+
+ facet_body_out1 = CAST_TO(body_out1, OCCBody);
+ facet_body_out2 = CAST_TO(body_out2, OCCBody);
+
+// Fix the curves.
+DLIList<OCCCurve*> fcurvelist, fcurvelist2;
+
+ facet_body_out1->get_curves(fcurvelist);
+ facet_body_out2->get_curves(fcurvelist2);
+
+ for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
+ if ( (curves_in_intersection[n] == true) && (curves_in_subtraction[n] == false) ) {
+ make_persistent_curves(fcurvelist,fcurvearray,n);
+ } else if ( (curves_in_intersection[n] == false) &&
+ (curves_in_subtraction[n] == true) ) {
+ make_persistent_curves(fcurvelist2,fcurvearray,n);
+ }
+ }
+
+
+// Fix the surfaces
+DLIList<OCCSurface*> fsurfaceslist, fsurfaceslist2;
+ facet_body_out1->get_surfaces(fsurfaceslist);
+ facet_body_out2->get_surfaces(fsurfaceslist2);
+
+ for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
+ if ( (surfs_in_intersection[n] == true) && (surfs_in_subtraction[n] == false) ) {
+ make_persistent_surfaces(fsurfaceslist,fsurfarray,n);
+ } else if ( (surfs_in_intersection[n] == false) &&
+ (surfs_in_subtraction[n] == true) ) {
+ make_persistent_surfaces(fsurfaceslist2,fsurfarray,n);
+ }
+ }
+
+// Fix the lumps.
+OCCLump *florig, *fl2;
+DLIList<OCCLump*> flumplist, flumplist2;
+ facet_body_in->get_lumps(flumplist);
+ facet_body_out1->get_lumps(flumplist2);
+ florig = flumplist.get();
+ fl2 = flumplist2.get();
+ if ( florig->owner() ) {
+ florig->owner()->swap_bridge(florig,fl2,false);
+ florig->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fl2->append_simple_attribute_virt(csa);
+ }
+ }
+// Fix the bodies.
+ if ( facet_body_in->owner() ) {
+ facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
+ facet_body_in->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ facet_body_out1->append_simple_attribute_virt(csa);
+ }
+ }
+
+}
+
+void FacetboolInterface::make_persistents_imprint(BodySM *body_in,
+ BodySM *body_out1,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray
+ )
+{
+DLIList<CubitSimpleAttrib*> csa_list;
+OCCBody *facet_body_in = CAST_TO(body_in, OCCBody);
+OCCBody *facet_body_out1 = CAST_TO(body_out1, OCCBody);
+unsigned int n;
+
+// Fix the curves.
+ DLIList<OCCCurve*> fcurvelist;
+ facet_body_out1->get_curves(fcurvelist);
+
+ for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
+ make_persistent_curves(fcurvelist,fcurvearray,n,0);
+ }
+
+
+// Fix the surfaces
+ DLIList<OCCSurface*> fsurfaceslist;
+ facet_body_out1->get_surfaces(fsurfaceslist);
+
+ for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
+ make_persistent_surfaces(fsurfaceslist,fsurfarray,n,0);
+ }
+
+// Fix the lumps.
+OCCLump *florig, *fl2;
+DLIList<OCCLump*> flumplist, flumplist2;
+int k;
+
+ facet_body_in->get_lumps(flumplist);
+ facet_body_out1->get_lumps(flumplist2);
+ florig = flumplist.get();
+ fl2 = flumplist2.get();
+ if ( florig->owner() ) {
+ florig->owner()->swap_bridge(florig,fl2,false);
+ florig->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fl2->append_simple_attribute_virt(csa);
+ }
+ }
+
+// Fix the bodies.
+ if ( facet_body_in->owner() ) {
+ facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
+ facet_body_in->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ facet_body_out1->append_simple_attribute_virt(csa);
+ }
+ }
+
+}
+
+void FacetboolInterface::make_persistents_boolean(BodySM *body_in,
+ BodySM *body_out1,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ bool *surfs_in_intersection,
+ bool *surfs_in_subtraction,
+ bool *curves_in_intersection,
+ bool *curves_in_subtraction,
+ const CubitFacetboolOp op,
+ bool body_1
+ )
+{
+ unsigned int n;
+ DLIList<CubitSimpleAttrib*> csa_list;
+ OCCBody *facet_body_in = CAST_TO(body_in, OCCBody);
+ OCCBody *facet_body_out1 = CAST_TO(body_out1, OCCBody);
+ int which_parent;
+ bool bvalue1 = false, bvalue2 = false;
+
+ if ( body_1 == true ) which_parent = 1;
+ else which_parent = 2;
+
+ switch (op) {
+
+ case CUBIT_FB_UNION:
+ bvalue1 = false;
+ bvalue2 = true;
+ break;
+ case CUBIT_FB_INTERSECTION:
+ bvalue2 = false;
+ bvalue1 = true;
+ break;
+ case CUBIT_FB_SUBTRACTION:
+ if ( body_1 == true ) {
+ bvalue2 = false;
+ bvalue1 = true;
+ } else {
+ bvalue1 = false;
+ bvalue2 = true;
+ }
+ break;
+ }
+// Fix the curves.
+ DLIList<OCCCurve*> fcurvelist;
+ facet_body_out1->get_curves(fcurvelist);
+
+ for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
+ if ( (curves_in_intersection[n] == bvalue1) &&
+ (curves_in_subtraction[n] == bvalue2) ) {
+ make_persistent_curves(fcurvelist,fcurvearray,n,which_parent);
+ }
+ }
+
+
+// Fix the surfaces
+ DLIList<OCCSurface*> fsurfaceslist;
+ facet_body_out1->get_surfaces(fsurfaceslist);
+
+ for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
+ if ( (surfs_in_intersection[n] == bvalue1) &&
+ (surfs_in_subtraction[n] == bvalue2) ) {
+ make_persistent_surfaces(fsurfaceslist,fsurfarray,n,which_parent);
+ }
+ }
+
+ if ( body_1 == true ) {
+// Fix the lumps.
+OCCLump *florig, *fl2;
+DLIList<OCCLump*> flumplist, flumplist2;
+int k;
+
+ facet_body_in->get_lumps(flumplist);
+ facet_body_out1->get_lumps(flumplist2);
+ florig = flumplist.get();
+ fl2 = flumplist2.get();
+ if ( florig->owner() ) {
+ florig->owner()->swap_bridge(florig,fl2,false);
+ florig->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fl2->append_simple_attribute_virt(csa);
+ }
+ }
+
+// Fix the bodies.
+ if ( facet_body_in->owner() ) {
+ facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
+ facet_body_in->get_simple_attribute(csa_list);
+ for ( k = csa_list.size(); k > 0; k-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ facet_body_out1->append_simple_attribute_virt(csa);
+ }
+ }
+ }
+
+}
+
+void FacetboolInterface::make_persistent_curves(DLIList<OCCCurve*> fcurvelist,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ int n,
+ int which_parent)
+{
+int k, m, jj;
+OCCCurve *fcurveorig, *fcurve2;
+int *marked3, index;
+bool ifoundit;
+OCCPoint *fpointorig, *fpoint2;
+DLIList<OCCPoint*> fpointlist, fpointlist2;
+CubitFacet *cfac;
+DLIList<CubitSimpleAttrib*> csa_list;
+bool is_from_1, error;
+TDFacetboolData* tdf;
+
+ fcurveorig = fcurvearray[n-1];
+ ifoundit = false;
+ for ( k = fcurvelist.size(); k > 0; k-- ) {
+ fcurve2 = fcurvelist.get_and_step();
+ if ( fcurve2->owner() ) continue; // If owner is already set, skip it.
+ CurveFacetEvalTool *evaltool = fcurve2->get_eval_tool();
+ DLIList<CubitFacetEdge*> edgelist;
+ CubitFacetEdge *cfedge;
+ evaltool->get_facets(edgelist);
+ cfedge = edgelist.get();
+ cfac = cfedge->adj_facet(0);
+ index = cfac->edge_index(cfedge);
+ tdf = TDFacetboolData::get(cfac);
+ if ( which_parent ) {
+ is_from_1 = tdf->parent_is_body_1();
+ if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
+ ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
+ }
+ marked3 = tdf->get_edge_indices(cfac->is_backwards());
+ if ( marked3[(index+1)%3] == n ) ifoundit = true;
+ else {
+ cfac = cfedge->adj_facet(1);
+ if (cfac) {
+ index = cfac->edge_index(cfedge);
+ tdf = TDFacetboolData::get(cfac);
+ if ( which_parent ) {
+ is_from_1 = tdf->parent_is_body_1();
+ if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
+ ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
+ }
+ marked3 = tdf->get_edge_indices(cfac->is_backwards());
+ if ( marked3[(index+1)%3] == n ) ifoundit = true;
+ }
+ }
+ if ( ifoundit == true ) {
+ fpointlist.clean_out();
+ fpointlist2.clean_out();
+ fcurveorig->get_points(fpointlist);
+ fcurve2->get_points(fpointlist2);
+ for ( jj = fpointlist.size(); jj > 0; jj-- ) {
+ error = false;
+ fpointorig = fpointlist.get_and_step();
+ fpoint2 = fpointlist2.get_and_step();
+ while ( fpoint2->coordinates() != fpointorig->coordinates() ) {
+ if ( fpointlist2.is_at_beginning() == CUBIT_TRUE ) {
+// PRINT_WARNING("Unable to make point on curve persistent.\n");
+ error = true;
+ break;
+ }
+ fpoint2 = fpointlist2.get_and_step();
+ }
+ if ( error == true ) continue;
+ if ( fpointorig->owner() && !(fpoint2->owner()) ) {
+ fpointorig->owner()->swap_bridge(fpointorig,fpoint2,false);
+ fpointorig->get_simple_attribute(csa_list);
+ for ( m = csa_list.size(); m > 0; m-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fpoint2->append_simple_attribute_virt(csa);
+ }
+ }
+ }
+ if ( fcurveorig->owner() != 0 )
+ fcurveorig->owner()->swap_bridge(fcurveorig,fcurve2,false);
+ fcurveorig->get_simple_attribute(csa_list);
+ for ( m = csa_list.size(); m > 0; m-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fcurve2->append_simple_attribute_virt(csa);
+ }
+ break;
+ }
+ }
+}
+
+void FacetboolInterface::make_persistent_surfaces(DLIList<OCCSurface*> fsurfaceslist,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ int n,
+ int which_parent)
+{
+DLIList<CubitSimpleAttrib*> csa_list;
+int k, m;
+OCCSurface *fsorig, *fsurf2;
+bool is_from_1;
+
+ fsorig = fsurfarray[n-1];
+ for ( k = fsurfaceslist.size(); k > 0; k-- ) {
+ fsurf2 = fsurfaceslist.get_and_step();
+ DLIList<CubitFacet*> facet_list2;
+ fsurf2->tris(facet_list2);
+ CubitFacet* facet2 = facet_list2.get();
+ TDFacetboolData* tdf = TDFacetboolData::get(facet2);
+ if ( which_parent ) {
+ is_from_1 = tdf->parent_is_body_1();
+ if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
+ ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
+ }
+ int marked2 = tdf->get_surf_index();
+ if ( marked2 == n ) {
+ if ( fsorig->owner() != 0 )
+ fsorig->owner()->swap_bridge(fsorig,fsurf2,false);
+ fsorig->get_simple_attribute(csa_list);
+ for ( m = csa_list.size(); m > 0; m-- ) {
+ CubitSimpleAttrib* csa = csa_list.get_and_step();
+ fsurf2->append_simple_attribute_virt(csa);
+ }
+ break;
+ }
+ }
+}
+
+CubitStatus FacetboolInterface::FB_imprint_with_curves(BodySM*& body_in,
+ BodySM*& body_out,
+ bool keep_old)
+{
+CubitStatus status;
+
+ OCCModifyEngine *fme = OCCModifyEngine::instance();
+
+ OCCBody *fbody_ptr;
+ fbody_ptr = dynamic_cast<OCCBody *>(body_in);
+ DLIList<OCCSurface*> facet_surf_list;
+ fbody_ptr->get_surfaces(facet_surf_list);
+STD(vector)<double> body_verts;
+STD(vector)<int> body_connections, newbodyfacets;
+STD(vector)<int> f_c_indices;
+STD(vector)<OCCSurface *> fsurfarray;
+STD(vector)<OCCCurve *> fcurvearray;
+STD(vector)<double> vertsout;
+STD(vector)<int> coordsout;
+STD(vector)<int> surfindex;
+STD(vector)<int> curveindex;
+
+ status = facetbody_to_facetbool(facet_surf_list,body_verts,
+ body_connections,&f_c_indices,
+ fsurfarray,fcurvearray);
+ facet_surf_list.clean_out();
+
+ FBImprint *imprinter = new FBImprint();
+
+ status = imprinter->imprint_body_curve(body_verts,body_connections,
+ FB_imprint_edge_coords,FB_imprint_edges,
+ FB_imprint_edge_bboxes,&f_c_indices);
+
+ status = imprinter->update_surfs_and_curves(vertsout,coordsout,
+ &surfindex,&curveindex);
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ STD(vector)<CubitPoint *> points;
+
+unsigned int k;
+ for ( k = 0; k < vertsout.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout[k],
+ vertsout[k+1],
+ vertsout[k+2] );
+ points.push_back(new_point);
+ }
+ for ( k = 0; k < coordsout.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout[k]],
+ points[coordsout[k+1]],
+ points[coordsout[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex[k];
+ cptr[1] = curveindex[k+1];
+ cptr[2] = curveindex[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
+ facet_ptr->is_backwards());
+
+ facet_list.append( facet_ptr );
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ feature_angle = 135.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_TRUE;
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_out);
+ if( status == CUBIT_FAILURE )
+ return status;
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+
+ vertsout.clear();
+ coordsout.clear();
+ if ( keep_old == false ) {
+ make_persistents_imprint(body_in,body_out,fsurfarray,fcurvearray);
+ }
+
+ delete imprinter;
+
+ return status;
+
+}
+
+CubitStatus FacetboolInterface::dofacetboolean_2bodies_imprint(BodySM*& body_in1,
+ BodySM*& body_in2,
+ BodySM*& body_out1,
+ BodySM*& body_out2,
+ bool keep_old)
+{
+CubitStatus status;
+STD(vector)<double> body_verts;
+STD(vector)<double> body2_verts;
+STD(vector)<int> body_connections, newbodyfacets;
+STD(vector)<int> body2_connections, newbody2facets;
+STD(vector)<double> vertsout1, vertsout2;
+STD(vector)<int> coordsout1, coordsout2;
+STD(vector)<int> f_c_indices1;
+STD(vector)<int> f_c_indices2;
+STD(vector)<OCCSurface *> fsurfarray1, fsurfarray2;
+STD(vector)<OCCCurve *> fcurvearray1, fcurvearray2;
+STD(vector)<int> surfindex1, surfindex2;
+STD(vector)<int> curveindex1, curveindex2;
+
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ STD(vector)<CubitPoint *> points;
+
+ OCCModifyEngine *fme = OCCModifyEngine::instance();
+ bool is_sheet_body = false;
+ Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
+ Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
+ if(tmp_body_1 && tmp_body_1->is_sheet_body()){
+ is_sheet_body = true;
+ }
+ else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
+ is_sheet_body = true;
+ }
+ if(tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
+ {
+ PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
+ }
+ OCCBody *fbody_ptr;
+ fbody_ptr = dynamic_cast<OCCBody *>(body_in1);
+ DLIList<OCCSurface*> facet_surf_list;
+ fbody_ptr->get_surfaces(facet_surf_list);
+
+ status = facetbody_to_facetbool(facet_surf_list,body_verts,
+ body_connections,&f_c_indices1,
+ fsurfarray1,fcurvearray1);
+ facet_surf_list.clean_out();
+
+ fbody_ptr = dynamic_cast<OCCBody *>(body_in2);
+ fbody_ptr->get_surfaces(facet_surf_list);
+ status = facetbody_to_facetbool(facet_surf_list,body2_verts,
+ body2_connections,&f_c_indices2,
+ fsurfarray2,fcurvearray2);
+ facet_surf_list.clean_out();
+
+ FBIntersect *intersector = new FBIntersect();
+ intersector->set_imprint();
+ status = intersector->intersect(body_verts,body_connections,
+ body2_verts,body2_connections,
+ newbodyfacets,newbody2facets,
+ &f_c_indices1,
+ &f_c_indices2);
+ status = intersector->update_surfs_and_curves(vertsout1,coordsout1,
+ &surfindex1,&curveindex1,1);
+ status = intersector->update_surfs_and_curves(vertsout2,coordsout2,
+ &surfindex2,&curveindex2,2);
+unsigned int k;
+ for ( k = 0; k < vertsout1.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout1[k],
+ vertsout1[k+1],
+ vertsout1[k+2] );
+ points.push_back(new_point);
+ }
+ for ( k = 0; k < coordsout1.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout1[k]],
+ points[coordsout1[k+1]],
+ points[coordsout1[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex1[k];
+ cptr[1] = curveindex1[k+1];
+ cptr[2] = curveindex1[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex1[k/3],cptr[0],cptr[1],cptr[2],false,
+ facet_ptr->is_backwards());
+
+ facet_list.append( facet_ptr );
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ feature_angle = 135.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_out1);
+ if( status == CUBIT_FAILURE )
+ return status;
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+ vertsout1.clear();
+ coordsout1.clear();
+
+ facet_list.clean_out();
+ for ( k = 0; k < vertsout2.size(); k += 3 ) {
+ new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
+ vertsout2[k+1],
+ vertsout2[k+2] );
+ points.push_back(new_point);
+ }
+ for ( k = 0; k < coordsout2.size(); k += 3 ) {
+ facet_ptr = new CubitFacetData( points[coordsout2[k]],
+ points[coordsout2[k+1]],
+ points[coordsout2[k+2]] );
+ int *cptr = new int[3];
+ cptr[0] = curveindex2[k];
+ cptr[1] = curveindex2[k+1];
+ cptr[2] = curveindex2[k+2];
+ TDFacetboolData::add_facetbool_facet( facet_ptr );
+ TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
+ td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
+ facet_ptr->is_backwards());
+ facet_list.append( facet_ptr );
+ }
+ points.clear(); // clear out the points vector since we are through with it.
+
+ {
+ ChollaEngine *cholla_ptr = NULL;
+
+ status = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if( status == CUBIT_FAILURE )
+ return status;
+
+ status = fme->finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle, interp_order,
+ body_out2);
+ if( status == CUBIT_FAILURE )
+ return status;
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+
+ if ( keep_old == false ) {
+ make_persistents_imprint(body_in1,body_out1,fsurfarray1,fcurvearray1);
+ make_persistents_imprint(body_in2,body_out2,fsurfarray2,fcurvearray2);
+ }
+
+ //separate the lumps in the "body_out1" and "body_out2", these will
+ //be converted to separate volumes later in the code.
+ status=separate_lumps(body_out1, is_sheet_body);
+ status=separate_lumps(body_out2, is_sheet_body);
+ vertsout2.clear();
+ coordsout2.clear();
+
+ delete intersector;
+
+ return status;
+}
+
+CubitStatus FacetboolInterface::make_FB_edge_list(DLIList<Curve*> &ref_edge_list)
+{
+CubitStatus success = CUBIT_SUCCESS;
+Curve *ref_edge_ptr;
+OCCCurve *cfcurve;
+CubitPoint *cfpoint;
+DLIList<CubitPoint *> cfpointlist;
+int i, j, lastvert, nextvert;
+CubitVector coords;
+
+ ref_edge_list.reset();
+ for( i = ref_edge_list.size(); i > 0; i-- )
+ {
+ ref_edge_ptr = ref_edge_list.get_and_step();
+ cfcurve = CAST_TO( ref_edge_ptr, OCCCurve);
+ cfpointlist.clean_out();
+ cfcurve->get_points(cfpointlist);
+ cfpoint = cfpointlist.get_and_step();
+ coords = cfpoint->coordinates();
+ lastvert = find_coord(coords.x(),coords.y(),coords.z());
+ for ( j = cfpointlist.size()-1; j > 0; j-- ) {
+ cfpoint = cfpointlist.get_and_step();
+ coords = cfpoint->coordinates();
+ nextvert = find_coord(coords.x(),coords.y(),coords.z());
+
+ FB_Edge *FBedge = new FB_Edge(lastvert,nextvert,0,0,false);
+ FSBoundingBox *bb = make_edge_bounding_box(lastvert,nextvert);
+ lastvert = nextvert;
+ FB_imprint_edges.push_back(FBedge);
+ FB_imprint_edge_bboxes.push_back(bb);
+ }
+ }
+
+ return success;
+}
+
+int FacetboolInterface::find_coord(double xx, double yy, double zz)
+{
+int value;
+unsigned int i;
+
+ value = -1;
+ for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
+ if ( (fabs(FB_imprint_edge_coords[i]->coord[0] - xx) < GEOMETRY_RESABS) &&
+ (fabs(FB_imprint_edge_coords[i]->coord[1] - yy) < GEOMETRY_RESABS) &&
+ (fabs(FB_imprint_edge_coords[i]->coord[2] - zz) < GEOMETRY_RESABS) ) {
+ value = (int)i;
+ break;
+ }
+ }
+ if ( value == -1 ) {
+ value = FB_imprint_edge_coords.size();
+ FB_Coord *FBcoord = new FB_Coord(xx,yy,zz);
+ FB_imprint_edge_coords.push_back(FBcoord);
+ }
+
+ return value;
+}
+
+FSBoundingBox* FacetboolInterface::make_edge_bounding_box(int v0, int v1)
+{
+FSBoundingBox *bb;
+double xmin, ymin, zmin, xmax, ymax, zmax;
+
+
+ xmin = ( FB_imprint_edge_coords[v0]->coord[0] < FB_imprint_edge_coords[v1]->coord[0] ) ?
+ FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
+ ymin = ( FB_imprint_edge_coords[v0]->coord[1] < FB_imprint_edge_coords[v1]->coord[1] ) ?
+ FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
+ zmin = ( FB_imprint_edge_coords[v0]->coord[2] < FB_imprint_edge_coords[v1]->coord[2] ) ?
+ FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
+ xmax = ( FB_imprint_edge_coords[v0]->coord[0] > FB_imprint_edge_coords[v1]->coord[0] ) ?
+ FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
+ ymax = ( FB_imprint_edge_coords[v0]->coord[1] > FB_imprint_edge_coords[v1]->coord[1] ) ?
+ FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
+ zmax = ( FB_imprint_edge_coords[v0]->coord[2] > FB_imprint_edge_coords[v1]->coord[2] ) ?
+ FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
+ if ( (xmax - xmin) < 2.0*GEOMETRY_RESABS ) {
+ xmin -= GEOMETRY_RESABS;
+ xmax += GEOMETRY_RESABS;
+ }
+ if ( (ymax - ymin) < 2.0*GEOMETRY_RESABS ) {
+ ymin -= GEOMETRY_RESABS;
+ ymax += GEOMETRY_RESABS;
+ }
+ if ( (zmax - zmin) < 2.0*GEOMETRY_RESABS ) {
+ zmin -= GEOMETRY_RESABS;
+ zmax += GEOMETRY_RESABS;
+ }
+
+ bb = new FSBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax);
+
+ return bb;
+
+}
+
+void FacetboolInterface::get_edge_list_bbox(CubitBox& edge_list_bbox)
+{
+unsigned int i;
+double min[3],max[3];
+
+ min[0] = min[1] = min[2] = CUBIT_DBL_MAX - 1.0;
+ max[0] = max[1] = max[2] = -CUBIT_DBL_MAX;
+
+ for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
+ min[0] = ( min[0] < FB_imprint_edge_coords[i]->coord[0] ) ? min[0] :
+ FB_imprint_edge_coords[i]->coord[0];
+ min[1] = ( min[1] < FB_imprint_edge_coords[i]->coord[1] ) ? min[1] :
+ FB_imprint_edge_coords[i]->coord[1];
+ min[2] = ( min[2] < FB_imprint_edge_coords[i]->coord[2] ) ? min[2] :
+ FB_imprint_edge_coords[i]->coord[2];
+ max[0] = ( max[0] > FB_imprint_edge_coords[i]->coord[0] ) ? max[0] :
+ FB_imprint_edge_coords[i]->coord[0];
+ max[1] = ( max[1] > FB_imprint_edge_coords[i]->coord[1] ) ? max[1] :
+ FB_imprint_edge_coords[i]->coord[1];
+ max[2] = ( max[2] > FB_imprint_edge_coords[i]->coord[2] ) ? max[2] :
+ FB_imprint_edge_coords[i]->coord[2];
+ }
+ if ( (max[0] - min[0]) < 2.0*GEOMETRY_RESABS ) {
+ min[0] -= GEOMETRY_RESABS;
+ max[0] += GEOMETRY_RESABS;
+ }
+ if ( (max[1] - min[1]) < 2.0*GEOMETRY_RESABS ) {
+ min[1] -= GEOMETRY_RESABS;
+ max[1] += GEOMETRY_RESABS;
+ }
+ if ( (max[2] - min[2]) < 2.0*GEOMETRY_RESABS ) {
+ min[2] -= GEOMETRY_RESABS;
+ max[2] += GEOMETRY_RESABS;
+ }
+ CubitBox box(min,max);
+ edge_list_bbox = box;
+
+}
+
+
+
Added: cgm/trunk/geom/OCC/FacetboolInterface.hpp
===================================================================
--- cgm/trunk/geom/OCC/FacetboolInterface.hpp (rev 0)
+++ cgm/trunk/geom/OCC/FacetboolInterface.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,136 @@
+#ifndef FACETBOOLINTERFACE_HPP
+#define FACETBOOLINTERFACE_HPP
+
+class OCCBody;
+class BodySM;
+class OCCSurface;
+class OCCCurve;
+class Curve;
+class CubitBox;
+
+#include <vector>
+#include "CubitDefines.h"
+#include "DLIList.hpp"
+#include "FBStructs.hpp"
+
+class FacetboolInterface {
+
+public:
+
+ FacetboolInterface();
+ ~FacetboolInterface();
+
+CubitStatus webcut_FB(BodySM *bodysm_ptr,
+ STD(vector)<double>& cutter_verts,
+ STD(vector)<int>& cutter_connections,
+ bool cutter_is_plane,
+ CubitBoolean delete_bodies,
+ CubitBoolean &intersects,
+ DLIList<BodySM*>& results_list);
+
+ CubitStatus dofacetboolean(DLIList<BodySM*>& body_list,
+ BodySM*& newBody,
+ bool keep_old,
+ const CubitFacetboolOp op);
+
+ CubitStatus dofacetboolean_subtract(BodySM*& tool_body,
+ DLIList<BodySM*>& from_bodies,
+ DLIList<BodySM*>& new_bodies,
+ bool keep_old,
+ bool* to_be_deleted,
+ const CubitFacetboolOp op);
+
+ CubitStatus dofacetboolean_2bodies(BodySM*& body_in1,
+ BodySM*& body_in2,
+ BodySM*& body_out,
+ bool keep_old,
+ bool& intersection_found,
+ const CubitFacetboolOp op);
+
+CubitStatus FB_imprint_with_curves(BodySM*& body_in,
+ BodySM*& body_out,
+ bool keep_old);
+
+ CubitStatus dofacetboolean_2bodies_imprint(BodySM*& body_in1,
+ BodySM*& body_in2,
+ BodySM*& body_out1,
+ BodySM*& body_out2,
+ bool keep_old);
+
+ CubitStatus make_FB_edge_list(DLIList<Curve*> &ref_edge_list);
+
+ void get_edge_list_bbox(CubitBox& edge_list_bbox);
+
+private:
+
+ STD(vector)<FB_Edge*> FB_imprint_edges;
+ STD(vector)<FB_Coord*> FB_imprint_edge_coords;
+ STD(vector)<FSBoundingBox*> FB_imprint_edge_bboxes;
+
+ CubitStatus facetbody_to_facetbool(
+ DLIList<OCCSurface*> &facet_surf_list,
+ STD(vector)<double> &body_verts,
+ STD(vector)<int> &body_connections,
+ STD(vector)<int> *f_c_indices,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray
+ );
+ int findcurve(OCCCurve *curve, STD(vector)<OCCCurve *>& fcurvearray);
+
+ void make_persistents_webcut(BodySM *body_in,
+ BodySM *body_out1,
+ BodySM *body_out2,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ bool *surfs_in_intersection,
+ bool *surfs_in_subtraction,
+ bool *curves_in_intersection,
+ bool *curves_in_subtraction
+ );
+
+ void make_persistents_imprint(BodySM *body_in,
+ BodySM *body_out1,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray
+ );
+
+ void make_persistents_boolean(BodySM *body_in,
+ BodySM *body_out1,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ bool *surfs_in_intersection,
+ bool *surfs_in_subtraction,
+ bool *curves_in_intersection,
+ bool *curves_in_subtraction,
+ const CubitFacetboolOp op,
+ bool body_1
+ );
+
+ void make_persistent_curves(DLIList<OCCCurve*> fcurvelist,
+ STD(vector)<OCCCurve *>& fcurvearray,
+ int n,
+ int which_parent = 0);
+
+ void make_persistent_surfaces(DLIList<OCCSurface*> fsurfaceslist,
+ STD(vector)<OCCSurface *>& fsurfarray,
+ int n,
+ int which_parent = 0);
+
+ int find_coord(double xx, double yy, double zz);
+
+ FSBoundingBox* make_edge_bounding_box(int v0, int v1);
+
+ //Separate out the different "lumps" in a given body. Generally,
+ // lumps are disjoint volumes. They will be converted to separate
+ // volumes later in the code.
+ CubitStatus separate_lumps( BodySM *body_ptr, bool is_sheet_body );
+
+ //First call separate_lumps to find the disjoing lumps in the body,
+ // and then separates the lumps into different bodies.
+ CubitStatus separate_shells_into_bodies( BodySM *body_ptr,
+ bool is_sheet_body,
+ DLIList<BodySM*> &new_bodies );
+
+};
+
+#endif
Added: cgm/trunk/geom/OCC/GridSearchTree.cpp
===================================================================
--- cgm/trunk/geom/OCC/GridSearchTree.cpp (rev 0)
+++ cgm/trunk/geom/OCC/GridSearchTree.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,220 @@
+#include <math.h>
+#include "GridSearchTree.hpp"
+
+double dist (CubitPoint * a, CubitPoint * b){
+ return sqrt((a->x() - b->x())*(a->x() - b->x()) + (a->y() - b->y())*(a->y() - b->y()) + (a->z() - b->z())*(a->z() - b->z()) );
+}
+
+CubitPoint * GridSearchTree::fix(CubitPoint * data) {
+
+ long i, j, k;
+ double x, y, z;
+
+ x=data->x();
+ y=data->y();
+ z=data->z();
+
+ // get the coordinates of the box containing the point
+ i=(long)(x/(2*epsilon));
+ j=(long)(y/(2*epsilon));
+ k=(long)(z/(2*epsilon));
+
+
+ if (x<0) i--;
+ if (y<0) j--;
+ if (z<0) k--;
+
+
+ int ofi;
+ int ofj;
+ int ofk;
+ int ii;
+
+ // calculate the i, j, k offset for the seven neighboring boxes to be searched
+ if (fabs(x-i*2*epsilon) < epsilon) ofi = -1; else ofi = 1;
+ if (fabs(y-j*2*epsilon) < epsilon) ofj = -1; else ofj = 1;
+ if (fabs(z-k*2*epsilon) < epsilon) ofk = -1; else ofk = 1;
+
+ // mindist holds the distance to the current closest point
+ double mindist=2*epsilon;
+ // curdist holds the distance to the current point
+ double curdist;
+ // closest is the current closest point
+ CubitPoint * closest = NULL;
+ // curpoint is the current point
+ CubitPoint * curpoint;
+
+ // construct grid cell ( box )
+ GridSearchTreeNode * curnode = new GridSearchTreeNode(i+ofi,j+ofj,k+ofk);
+ // attempt to find it in the tree
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ // if cell is in the tree search its list for close points
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ // construct grid cell ( box )
+ curnode = new GridSearchTreeNode(i+ofi,j+ofj,k);
+ // attempt to find it in the tree
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ // if cell is in the tree search its list for close points
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ curnode = new GridSearchTreeNode(i+ofi,j,k+ofk);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ curnode = new GridSearchTreeNode(i+ofi,j,k);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ curnode = new GridSearchTreeNode(i,j+ofj,k+ofk);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ curnode = new GridSearchTreeNode(i,j+ofj,k);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+ curnode = new GridSearchTreeNode(i,j,k+ofk);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+ delete curnode;
+
+
+ curnode = new GridSearchTreeNode(i,j,k);
+ pos = nodemap.find(curnode);
+ if (pos!=nodemap.end())
+ {
+ DLIList<CubitPoint*> curlist = (*pos).first->get_list();
+ for (ii= curlist.size(); ii>0; ii--)
+ {
+ curpoint = curlist.get_and_step();
+ curdist = dist(data, curpoint);
+ if (curdist<mindist)
+ {
+ closest = curpoint;
+ mindist=curdist;
+ }
+ }
+ }
+
+ // if closest point is within epsilon distance return the closest point
+ if (mindist<=epsilon)
+ {
+ delete curnode;
+ return closest;
+ }
+ else
+ {
+ // add current point and cell to tree
+ if (pos==nodemap.end())
+ {
+ curnode->add(data);
+ nodemap.insert(gmap::value_type(curnode, 1));
+ }
+ else
+ {
+ (*pos).first->add(data);
+ delete curnode;
+ }
+
+ return data;
+ }
+}
+
Added: cgm/trunk/geom/OCC/GridSearchTree.hpp
===================================================================
--- cgm/trunk/geom/OCC/GridSearchTree.hpp (rev 0)
+++ cgm/trunk/geom/OCC/GridSearchTree.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,37 @@
+
+#ifndef GSTREE_HPP
+#define GSTREE_HPP
+
+#include "GridSearchTreeNode.hpp"
+
+#include <typeinfo>
+#if !defined(NT) && !defined(CANT_USE_STD)
+using std::type_info;
+#endif
+
+#include <map>
+
+typedef STD(map)< GridSearchTreeNode* , int, GridSearchTreeNode::GSTNodeComparator > gmap;
+
+class GridSearchTree {
+
+private:
+ double epsilon;
+ gmap nodemap;
+ gmap::iterator pos;
+public:
+
+ GridSearchTree(double tolerance) {
+ epsilon = tolerance;
+ }
+
+ ~GridSearchTree() {}
+
+
+ CubitPoint * fix (CubitPoint * data);
+
+};
+
+#endif
+
+
Added: cgm/trunk/geom/OCC/GridSearchTreeNode.hpp
===================================================================
--- cgm/trunk/geom/OCC/GridSearchTreeNode.hpp (rev 0)
+++ cgm/trunk/geom/OCC/GridSearchTreeNode.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,45 @@
+#ifndef GSTREENODE_HPP
+#define GSTREENODE_HPP
+
+#include "DLIList.hpp"
+#include "CubitPoint.hpp"
+
+class GridSearchTreeNode {
+private:
+ DLIList <CubitPoint *> plist;
+
+public:
+ long icoord;
+ long jcoord;
+ long kcoord;
+
+ GridSearchTreeNode (long i, long j, long k) {
+ icoord=i;
+ jcoord=j;
+ kcoord=k;
+ }
+ ~GridSearchTreeNode() {}
+
+ DLIList <CubitPoint *> get_list(){
+ return plist;
+ }
+
+ void add(CubitPoint * data) {
+ plist.append(data);
+ }
+
+
+class GSTNodeComparator {
+public:
+ bool operator () (GridSearchTreeNode * a, GridSearchTreeNode * b) const
+ {
+ return ( a->icoord < b->icoord ) || (a->icoord==b->icoord && a->jcoord<b->jcoord) || (a->icoord == b->icoord && a->jcoord==b->jcoord && a->kcoord < b->kcoord );
+ }
+};
+
+};
+
+
+#endif
+
+
Added: cgm/trunk/geom/OCC/OCCAttrib.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCAttrib.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCAttrib.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,51 @@
+#ifndef FACET_ATTRIB_HPP
+#define FACET_ATTRIB_HPP
+
+#include "CubitDefines.h"
+#include "CubitString.hpp"
+class CubitSimpleAttrib;
+class CubitString;
+
+class OCCAttrib
+{
+public:
+
+ OCCAttrib( CubitSimpleAttrib* );
+
+ ~OCCAttrib();
+
+ CubitSimpleAttrib* get_CSA() const;
+
+ bool equals( CubitSimpleAttrib* ) const;
+
+ CubitStatus save( FILE* file ) const;
+
+ static OCCAttrib* restore( FILE* file, unsigned int endian );
+
+ CubitString name() const
+ { return stringArray[0]; }
+
+ // Use arrays rather than std::vector so IO routines
+ // can use the data without making copies.
+ CubitString* stringArray;
+ double* doubleArray;
+ int* integerArray;
+
+ int numStrings;
+ int numDoubles;
+ int numIntegers;
+
+ OCCAttrib* listNext;
+
+
+
+
+private:
+
+ OCCAttrib( int string_count, CubitString* strings,
+ int double_count, double* doubles,
+ int integer_count, int* integers );
+
+};
+
+#endif
Added: cgm/trunk/geom/OCC/OCCAttribSet.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCAttribSet.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCAttribSet.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,128 @@
+//-------------------------------------------------------------------------
+// Filename : OCCAttribSet.cpp
+//
+// Purpose : Common attribute functionality for MBG
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 03/01/03
+//-------------------------------------------------------------------------
+
+#include "OCCAttribSet.hpp"
+#include "OCCAttrib.hpp"
+#include "CubitSimpleAttrib.hpp"
+#include "CubitFileIOWrapper.hpp"
+
+void OCCAttribSet::append_attribute( CubitSimpleAttrib* csa )
+{
+ OCCAttrib* new_attrib = new OCCAttrib(csa);
+ new_attrib->listNext = listHead;
+ listHead = new_attrib;
+}
+
+void OCCAttribSet::remove_attribute( CubitSimpleAttrib* csa )
+{
+ if( !listHead )
+ return;
+
+ OCCAttrib* attrib = 0;
+ if ( listHead->equals(csa) )
+ {
+ attrib = listHead;
+ listHead = listHead->listNext;
+ delete attrib;
+ return;
+ }
+
+ for ( OCCAttrib* prev = listHead; prev->listNext; prev = prev->listNext )
+ {
+ if( prev->listNext->equals(csa) )
+ {
+ attrib = prev->listNext;
+ prev->listNext = attrib->listNext;
+ delete attrib;
+ return;
+ }
+ }
+}
+
+void OCCAttribSet::remove_all_attributes()
+{
+ while( listHead )
+ {
+ OCCAttrib* dead = listHead;
+ listHead = dead->listNext;
+ delete dead;
+ }
+}
+
+CubitStatus OCCAttribSet::get_attributes( DLIList<CubitSimpleAttrib*>& list ) const
+{
+ for( OCCAttrib* attrib = listHead; attrib; attrib = attrib->listNext )
+ list.append( attrib->get_CSA() );
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCAttribSet::get_attributes( const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& list ) const
+{
+ for( OCCAttrib* attrib = listHead; attrib; attrib = attrib->listNext )
+ if( attrib->name() == name )
+ list.append( attrib->get_CSA() );
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCAttribSet::save_attributes( FILE* file_ptr ) const
+{
+ OCCAttrib *curr_attrib;
+ CubitStatus status = CUBIT_SUCCESS;
+
+ //save # attribs
+ unsigned int size = attribute_count();
+ NCubitFile::CIOWrapper wrapper( file_ptr );
+ wrapper.Write( &size, 1 );
+
+ //save each attrib
+ for( curr_attrib = listHead; curr_attrib; curr_attrib = curr_attrib->listNext )
+ if( !curr_attrib->save(file_ptr) )
+ status = CUBIT_FAILURE;
+
+ return status;
+}
+
+CubitStatus OCCAttribSet::restore_attributes( FILE* file_ptr, unsigned endian )
+{
+ OCCAttrib *curr_attrib;
+
+ //Read # attribs
+ unsigned int size;
+ NCubitFile::CIOWrapper wrapper( endian, file_ptr );
+ wrapper.Read( &size, 1 );
+
+ for (unsigned i = 0; i < size; i++)
+ {
+ curr_attrib = OCCAttrib::restore( file_ptr, endian);
+ if (!curr_attrib)
+ {
+ // file corrupt? don't try to read any more
+ return CUBIT_FAILURE;
+ }
+
+ curr_attrib->listNext = listHead;
+ listHead = curr_attrib;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+
+int OCCAttribSet::attribute_count() const
+{
+ int count = 0;
+ for( OCCAttrib* attrib = listHead; attrib; attrib = attrib->listNext )
+ count++;
+ return count;
+}
+
Added: cgm/trunk/geom/OCC/OCCAttribSet.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCAttribSet.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCAttribSet.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,53 @@
+//-------------------------------------------------------------------------
+// Filename : OCCAttribSet.hpp
+//
+// Purpose : Common attrib functions for MBG
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 03/01/03
+//-------------------------------------------------------------------------
+
+#ifndef FACET_BRIDGE_HPP
+#define FACET_BRIDGE_HPP
+
+#include <DLIList.hpp>
+
+class CubitSimpleAttrib;
+class OCCAttrib;
+class CubitString;
+
+class OCCAttribSet
+{
+
+ public:
+
+ OCCAttribSet() : listHead(0) {}
+
+ ~OCCAttribSet() { remove_all_attributes(); }
+
+ void append_attribute( CubitSimpleAttrib* );
+
+ void remove_attribute( CubitSimpleAttrib* );
+
+ void remove_all_attributes();
+
+ CubitStatus get_attributes( DLIList<CubitSimpleAttrib*>& ) const;
+
+ CubitStatus get_attributes( const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& ) const;
+
+ CubitStatus save_attributes( FILE* file ) const;
+
+ CubitStatus restore_attributes( FILE* file, unsigned int endian );
+
+ int attribute_count() const;
+
+ private:
+
+ OCCAttrib* listHead;
+};
+
+#endif
Added: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,1066 @@
+//-------------------------------------------------------------------------
+// Filename : OCCBody.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : David White
+//
+// Creation Date : 7/18/00
+//
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+#include <assert.h>
+// ********** END STANDARD INCLUDES **********
+
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "CubitString.hpp"
+#include "CubitPoint.hpp"
+#include "CastTo.hpp"
+#include "BodySM.hpp"
+#include "Body.hpp"
+#include "OCCBody.hpp"
+#include "CubitSimpleAttrib.hpp"
+#include "OCCQueryEngine.hpp"
+#include "DLIList.hpp"
+#include "FacetEvalTool.hpp"
+#include "Surface.hpp"
+#include "OCCSurface.hpp"
+#include "CubitTransformMatrix.hpp"
+#include "OCCPoint.hpp"
+#include "OCCCurve.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCLoop.hpp"
+#include "OCCShell.hpp"
+#include "OCCLump.hpp"
+#include "CubitFacetEdge.hpp"
+#include "OCCModifyEngine.hpp"
+#include "OCCAttrib.hpp"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+//-------------------------------------------------------------------------
+// Purpose : A constructor with a list of lumps that are attached.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCBody::OCCBody(TopoDS_Shape *theShape)
+{
+ myTopoDSShape = theShape;
+}
+OCCBody::OCCBody(DLIList<Lump*>& my_lumps)
+{
+ myLumps += my_lumps;
+}
+OCCBody::~OCCBody()
+{
+ //Not sure what to do..
+}
+
+GeometryQueryEngine* OCCBody::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+void OCCBody::append_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.append_attribute(csa); }
+
+void OCCBody::remove_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.remove_attribute(csa); }
+
+void OCCBody::remove_all_simple_attribute_virt()
+ { attribSet.remove_all_attributes(); }
+
+CubitStatus OCCBody::get_simple_attribute(DLIList<CubitSimpleAttrib*>& csa_list)
+ { return attribSet.get_attributes(csa_list); }
+
+CubitStatus OCCBody::get_simple_attribute( const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& csa_list )
+ { return attribSet.get_attributes( name, csa_list ); }
+
+CubitStatus OCCBody::save_attribs( FILE *file_ptr )
+ { return attribSet.save_attributes( file_ptr); }
+
+CubitStatus OCCBody::restore_attribs( FILE *file_ptr, unsigned int endian )
+ { return attribSet.restore_attributes( file_ptr, endian ); }
+
+
+
+//----------------------------------------------------------------
+// Function: copy
+// Description: create a new copy of the body.
+// Author: sjowen
+//----------------------------------------------------------------
+BodySM* OCCBody::copy()
+{
+ CubitStatus rv;
+
+ // ----------Copy the points on the body------------------------
+
+ int ii;
+ DLIList<OCCPoint*> point_list;
+ get_points(point_list);
+ DLIList<Point*> copy_points;
+ point_list.reset();
+ Point *point_ptr;
+ Point *point_copy;
+ for(ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ CubitVector temp_vector = point_ptr->coordinates();
+
+ rv = OCCModifyEngine::instance()->make_facet_point(temp_vector,
+ point_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy points");
+ return (BodySM *)NULL;
+ }
+ copy_points.append( point_copy );
+ }
+
+ // ------------------Copy the curves-------------------------
+
+ int jj;
+ DLIList<OCCCurve*> curve_list;
+ get_curves( curve_list );
+ DLIList<Curve*> copy_curves;
+ curve_list.reset();
+ Curve *curve_ptr, *curve_copy;
+ Curve *curvsm_copy = NULL;
+ OCCCurve *fcurve;
+ Point *ptsm_ptr;
+ Point *start_ptr, *end_ptr, *copy_start = NULL, *copy_end = NULL;
+ for (ii=0; ii<curve_list.size(); ii++)
+ {
+ curve_ptr = curve_list.get_and_step();
+ fcurve = CAST_TO( curve_ptr, OCCCurve );
+ start_ptr = fcurve->start_point();
+ end_ptr = fcurve->end_point();
+ int found0 = 0;
+ int found1 = 0;
+
+ // find the end points
+
+ point_list.reset();
+ copy_points.reset();
+ for (jj=0; jj<point_list.size() && (!found0 || !found1); jj++)
+ {
+ point_ptr = point_list.get_and_step();
+ ptsm_ptr = CAST_TO(point_ptr, Point);
+ point_copy = copy_points.get_and_step();
+ if (ptsm_ptr == start_ptr)
+ {
+ copy_start = point_copy;
+ found0 = 1;
+ }
+ if (ptsm_ptr == end_ptr)
+ {
+ copy_end = point_copy;
+ found1 = 1;
+ }
+ }
+
+ // create the new curve and update the points
+
+ rv = OCCModifyEngine::instance()->make_facet_curve(copy_start,
+ copy_end,
+ curve_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy curves");
+ return (BodySM *)NULL;
+ }
+ curvsm_copy = CAST_TO(curve_copy, Curve);
+ copy_curves.append( curvsm_copy );
+ }
+
+ // ------------------copy coedges-----------------------
+
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ DLIList<CoEdgeSM*> copy_coedges;
+ coedge_list.reset();
+ Curve *curvsm_ptr;
+ CoEdgeSM *coedge_ptr, *coedge_copy;
+ OCCCoEdge *fcoedge;
+ for (ii=0; ii<coedge_list.size(); ii++)
+ {
+ coedge_ptr = coedge_list.get_and_step();
+ fcoedge = CAST_TO( coedge_ptr, OCCCoEdge );
+ Curve *curve_at_coedge = fcoedge->curve();
+ int found = 0;
+
+ // find the associated curve
+
+ curve_list.reset();
+ copy_curves.reset();
+ for (jj=0; jj<curve_list.size() && !found; jj++)
+ {
+ curve_ptr = curve_list.get_and_step();
+ curvsm_ptr = CAST_TO(curve_ptr, Curve);
+ curvsm_copy = copy_curves.get_and_step();
+ if (curve_at_coedge == curvsm_ptr)
+ {
+ found = 1;
+ }
+ }
+
+ // create the new coedge
+
+ CubitSense sense = fcoedge->sense();
+ rv = OCCModifyEngine::instance()->make_facet_coedge(curvsm_copy,
+ sense, coedge_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy coedge");
+ return (BodySM *)NULL;
+ }
+ copy_coedges.append( coedge_copy );
+ }
+
+ // ----------------------copy loops--------------------------
+
+ int kk;
+ DLIList<OCCLoop*> loop_list;
+ get_loops( loop_list );
+ DLIList<LoopSM*> copy_loops;
+ loop_list.reset();
+ LoopSM *loop_ptr, *loop_copy;
+ OCCLoop *floop;
+ for (ii=0; ii<loop_list.size(); ii++)
+ {
+ floop = loop_list.get_and_step();
+ DLIList<OCCCoEdge *>coedges_on_loop;
+ floop->get_coedges(coedges_on_loop);
+ DLIList<CoEdgeSM *>copy_coedges_on_loop;
+
+ // find all associated coedges on the loop
+
+ for(kk=0; kk<coedges_on_loop.size(); kk++)
+ {
+ int found = 0;
+ coedge_list.reset();
+ copy_coedges.reset();
+ CoEdgeSM *coedge_on_loop = coedges_on_loop.get_and_step();
+ for (jj=0; jj<coedge_list.size() && !found; jj++)
+ {
+ coedge_ptr = coedge_list.get_and_step();
+ coedge_copy = copy_coedges.get_and_step();
+ if (coedge_on_loop == coedge_ptr)
+ {
+ found = 1;
+ copy_coedges_on_loop.append(coedge_copy);
+ }
+ }
+ }
+
+ // create the new loop
+
+ rv = OCCModifyEngine::instance()->make_facet_loop(copy_coedges_on_loop,
+ loop_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy loops");
+ return (BodySM *)NULL;
+ }
+ copy_loops.append( loop_copy );
+ }
+
+ // ----------------------copy surfaces--------------------------
+
+ DLIList<OCCSurface*> surface_list;
+ get_surfaces(surface_list);
+ DLIList<Surface*> copy_surfaces;
+ surface_list.reset();
+ Surface *surface_ptr, *surface_copy;
+ OCCSurface *fsurface;
+ for (ii=0; ii<surface_list.size(); ii++)
+ {
+ fsurface = surface_list.get_and_step();
+ DLIList<OCCLoop *>loops_on_surface;
+ fsurface->get_loops(loops_on_surface);
+ DLIList<LoopSM *>copy_loops_on_surface;
+
+ // find all associated loops on the surface
+
+ for(kk=0; kk<loops_on_surface.size(); kk++)
+ {
+ int found = 0;
+ loop_list.reset();
+ copy_loops.reset();
+ LoopSM *loop_on_surface = loops_on_surface.get_and_step();
+ for (jj=0; jj<loop_list.size() && !found; jj++)
+ {
+ loop_ptr = loop_list.get_and_step();
+ loop_copy = copy_loops.get_and_step();
+ if (loop_on_surface == loop_ptr)
+ {
+ found = 1;
+ copy_loops_on_surface.append(loop_copy);
+ }
+ }
+ }
+
+ // create the new surface
+
+ DLIList<CubitFacet*>facet_list;
+ DLIList<CubitPoint*>cpoint_list;
+ rv = fsurface->copy_facets( facet_list, cpoint_list );
+ if (rv != CUBIT_SUCCESS)
+ {
+ return (BodySM *)NULL;
+ }
+ int interp_order = fsurface->interp_order();
+ double min_dot = fsurface->min_dot();
+ const CubitEvaluatorData *eval_data = fsurface->evaluator_data();
+ CubitBoolean use_point_addresses = CUBIT_FALSE;
+ rv = OCCModifyEngine::instance()->make_facet_surface(eval_data,
+ facet_list,
+ cpoint_list,
+ copy_loops_on_surface,
+ interp_order,
+ min_dot,
+ surface_copy,
+ use_point_addresses);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy surfaces");
+ return (BodySM *)NULL;
+ }
+ copy_surfaces.append( surface_copy );
+ }
+
+ // ----------------------copy shells--------------------------
+
+ DLIList<OCCShell*> shell_list;
+ get_shells(shell_list);
+ DLIList<ShellSM*> copy_shells;
+ shell_list.reset();
+ ShellSM *shell_ptr, *shell_copy;
+ OCCShell *fshell;
+ for (ii=0; ii<shell_list.size(); ii++)
+ {
+ fshell = shell_list.get_and_step();
+ DLIList<OCCSurface *>surfaces_on_shell;
+ fshell->get_surfaces(surfaces_on_shell);
+ DLIList<Surface *>copy_surfaces_on_shell;
+
+ // find all associated loops on the surface
+
+ for(kk=0; kk<surfaces_on_shell.size(); kk++)
+ {
+ int found = 0;
+ surface_list.reset();
+ copy_surfaces.reset();
+ Surface *surface_on_shell = surfaces_on_shell.get_and_step();
+ for (jj=0; jj<surface_list.size() && !found; jj++)
+ {
+ surface_ptr = surface_list.get_and_step();
+ surface_copy = copy_surfaces.get_and_step();
+ if (surface_on_shell == surface_ptr)
+ {
+ found = 1;
+ copy_surfaces_on_shell.append(surface_copy);
+ }
+ }
+ }
+
+ // create the new shell
+
+ rv = OCCModifyEngine::instance()->make_facet_shell(copy_surfaces_on_shell,
+ shell_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy shell");
+ return (BodySM *)NULL;
+ }
+
+ // set the sense of the surfaces on the shell - copy from the old shell
+
+ OCCShell *fshell_copy = CAST_TO(shell_copy, OCCShell);
+ surfaces_on_shell.reset();
+ copy_surfaces_on_shell.reset();
+ for (kk=0; kk<surfaces_on_shell.size(); kk++)
+ {
+ Surface *surface_on_shell = surfaces_on_shell.get_and_step();
+ Surface *copy_surface_on_shell = copy_surfaces_on_shell.get_and_step();
+ fsurface = CAST_TO( surface_on_shell, OCCSurface );
+ CubitSense sense = fsurface->get_shell_sense(fshell);
+ OCCSurface *copy_fsurface = CAST_TO( copy_surface_on_shell, OCCSurface );
+ copy_fsurface->set_shell_sense( fshell_copy, sense );
+ }
+ copy_shells.append( shell_copy );
+ }
+
+ // ----------------------copy lumps--------------------------
+
+ DLIList<OCCLump*> lump_list;
+ get_lumps(lump_list);
+ DLIList<Lump*> copy_lumps;
+ lump_list.reset();
+ Lump *lump_copy;
+ OCCLump *flump;
+ for (ii=0; ii<lump_list.size(); ii++)
+ {
+ flump = lump_list.get_and_step();
+ DLIList<OCCShell *>shells_on_lump;
+ flump->get_shells(shells_on_lump);
+ DLIList<ShellSM *>copy_shells_on_lump;
+
+ // find all associated loops on the surface
+
+ for(kk=0; kk<shells_on_lump.size(); kk++)
+ {
+ int found = 0;
+ shell_list.reset();
+ copy_shells.reset();
+ ShellSM *shell_on_lump = shells_on_lump.get_and_step();
+ for (jj=0; jj<shell_list.size() && !found; jj++)
+ {
+ shell_ptr = shell_list.get_and_step();
+ shell_copy = copy_shells.get_and_step();
+ if (shell_on_lump == shell_ptr)
+ {
+ found = 1;
+ copy_shells_on_lump.append(shell_copy);
+ }
+ }
+ }
+
+ // create the new lump
+
+ rv = OCCModifyEngine::instance()->make_facet_lump(copy_shells_on_lump,
+ lump_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy lump");
+ return (BodySM *)NULL;
+ }
+ copy_lumps.append( lump_copy );
+ }
+
+ // ----------------------copy body--------------------------
+
+ BodySM *body_copy;
+ rv = OCCModifyEngine::instance()->make_facet_body(copy_lumps,
+ body_copy);
+ if(rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Couldn't copy lump");
+ return (BodySM *)NULL;
+ }
+
+ return (BodySM*)body_copy;
+}
+//----------------------------------------------------------------
+// Function: can_be_deleted
+// Description: determine if the body can be deleted
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitBoolean OCCBody::can_be_deleted( DLIList <Body*> &body_list )
+{
+ CubitBoolean delete_ok = CUBIT_TRUE;
+ DLIList<OCCSurface *>surf_list;
+ get_surfaces(surf_list);
+ int ii;
+ for (ii=0; ii<surf_list.size() && delete_ok; ii++)
+ {
+ OCCSurface *surf_ptr = surf_list.get_and_step();
+ DLIList<OCCBody*>my_body_list;
+ surf_ptr->get_bodies(my_body_list);
+ int jj;
+ if (my_body_list.size() >= 2)
+ {
+ for (jj=0; jj<my_body_list.size() && delete_ok; jj++)
+ {
+ BodySM *my_body_ptr = my_body_list.get_and_step();
+ if (my_body_ptr != this)
+ {
+ int kk;
+ int found = 0;
+ for (kk=0; kk<body_list.size() && !found; kk++)
+ {
+ Body *body_ptr = body_list.get_and_step();
+ OCCBody* fbody_ptr = CAST_TO(body_ptr->get_body_sm_ptr(), OCCBody);
+ if (fbody_ptr)
+ {
+ if (my_body_ptr == fbody_ptr)
+ found = 1;
+ }
+ }
+ if (!found)
+ {
+ delete_ok = CUBIT_FALSE;
+ PRINT_ERROR("Body cannot be deleted because it is merged with adjacent Body\n");
+ PRINT_INFO(" Mesh Based Geometry entities cannot be unmerged.\n"
+ " Try using the no_merge option when importing the mesh\n");
+ }
+ }
+ }
+ }
+ }
+ return delete_ok;
+}
+
+//----------------------------------------------------------------
+// Function: move
+// Description: translate the body and its child entities
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::move(double dx, double dy, double dz)
+{
+ CubitTransformMatrix tfmat;
+ tfmat.translate( dx, dy, dz );
+
+ CubitStatus stat = transform( tfmat, CUBIT_FALSE );
+
+ if (stat == CUBIT_SUCCESS)
+ myTransforms.translate( dx, dy, dz );
+
+ return stat;
+}
+
+
+//----------------------------------------------------------------
+// Function: rotate
+// Description: rotate the body and its child entities
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::rotate( double x, double y, double z,
+ double angle_in_degrees )
+{
+
+ CubitTransformMatrix rotmat;
+ CubitVector axis( x, y, z );
+ rotmat.rotate( angle_in_degrees, axis );
+
+ CubitStatus stat = transform( rotmat, CUBIT_TRUE );
+
+ if (stat == CUBIT_SUCCESS)
+ myTransforms.rotate( angle_in_degrees, axis );
+
+ return stat;
+}
+
+//----------------------------------------------------------------
+// Function: scale
+// Description: scale the body and its child entities
+// use a constant scale factor
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::scale(double scale_factor )
+{
+ return scale(scale_factor,scale_factor,scale_factor);
+}
+
+//----------------------------------------------------------------
+// Function: scale
+// Description: scale the body and its child entities
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::scale(double scale_factor_x,
+ double scale_factor_y,
+ double scale_factor_z )
+{
+ CubitTransformMatrix scalemat;
+ scalemat.scale_about_origin( scale_factor_x,
+ scale_factor_y,
+ scale_factor_z );
+
+ CubitStatus stat = transform( scalemat, CUBIT_FALSE );
+
+ if (stat == CUBIT_SUCCESS)
+ myTransforms.scale_about_origin( scale_factor_x,
+ scale_factor_y,
+ scale_factor_z );
+
+ // scale the facetcurve
+
+ DLIList<OCCCurve *> curve_list;
+ get_curves(curve_list);
+ Curve *curv_ptr;
+ for (int ii=0; ii<curve_list.size(); ii++)
+ {
+ curv_ptr = curve_list.get_and_step();
+ OCCCurve *fcurve = CAST_TO( curv_ptr, OCCCurve );
+ if (fcurve)
+ {
+ fcurve->reset_length();
+ }
+ }
+
+ return stat;
+}
+
+//----------------------------------------------------------------
+// Function: restore
+// Description: restore the body and its child entities
+// to its original coordinates using the inverse
+// transformation matrix
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::restore()
+{
+ // invert the transformation matrix and apply to entities
+ // (assumes an orthogonal matrix (ie. no shear or non-uniform scaling)
+
+ CubitTransformMatrix inverse_mat;
+ inverse_mat = myTransforms.inverse();
+
+ CubitStatus stat = transform( inverse_mat, CUBIT_TRUE );
+
+ if (stat == CUBIT_SUCCESS)
+ myTransforms.set_to_identity();
+
+ return stat;
+}
+
+//----------------------------------------------------------------
+// Function: reflect
+// Description: reflect the body about a exis
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::reflect( double reflect_axis_x,
+ double reflect_axis_y,
+ double reflect_axis_z )
+{
+ CubitTransformMatrix reflectmat;
+ CubitVector reflect_vector( reflect_axis_x,
+ reflect_axis_y,
+ reflect_axis_z );
+ reflectmat.reflect( reflect_vector );
+
+ CubitStatus stat = transform( reflectmat, CUBIT_TRUE );
+
+ if (stat == CUBIT_SUCCESS)
+ myTransforms.reflect( reflect_vector );
+
+ return stat;
+}
+
+//----------------------------------------------------------------
+// Function: transform
+// Description: transform the body based on a transformation matrix
+// main function for applying transformations to
+// facet-based bodies
+//
+// Author: sjowen
+//----------------------------------------------------------------
+CubitStatus OCCBody::transform( CubitTransformMatrix &tfmat,
+ CubitBoolean is_rotation )
+{
+ int ii;
+
+ // get the list of surfaces on the body
+
+ DLIList<OCCSurface *>surf_list;
+ get_surfaces( surf_list );
+ Surface *surf;
+ OCCSurface *fsurf;
+ FacetEvalTool *ftool;
+#ifdef BOYD17
+ CubitBox box;
+#endif
+ //CubitVector min, max;
+
+ // go through all the surfaces and collect the list of all points.
+ // (some may be listed on multiple surfaces)
+
+ DLIList<CubitPoint *>point_list;
+ for (ii=0; ii<surf_list.size(); ii++)
+ {
+ surf = surf_list.get_and_step();
+ fsurf = CAST_TO( surf, OCCSurface );
+ fsurf->get_my_points( point_list );
+ }
+
+ // unmark all the points so we can keep track of the ones that have
+ // already been transformed
+
+ CubitPoint *cp;
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ cp = point_list.get_and_step();
+ cp->marked( 0 );
+ }
+
+ // transform the points
+
+ //CubitVector norm, du, dv;
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ cp = point_list.get_and_step();
+ if (!cp->marked())
+ {
+ cp->transform( tfmat );
+ if (is_rotation)
+ cp->rotate_normal( tfmat );
+ cp->marked( 1 );
+ }
+ }
+
+ // check the vertices - make sure they are transformed
+
+ OCCPoint *fpt;
+ Point *pt;
+ DLIList<OCCPoint*>gpoint_list;
+ get_points(gpoint_list);
+ for (ii=0; ii<gpoint_list.size(); ii++)
+ {
+ pt = gpoint_list.get_and_step();
+ fpt = CAST_TO( pt, OCCPoint );
+
+ // only transform the point if it isn't already part of the facets
+ // (they could be points by themselves)
+
+ cp = fpt->get_cubit_point();
+ if (cp->num_adj_facets() == 0)
+ {
+ cp->transform( tfmat );
+ if (is_rotation)
+ cp->rotate_normal( tfmat );
+ }
+ }
+
+ // reset the bounding box and update the facet normal and plane
+
+ // init flags on edges to 0
+ DLIList<Surface*> tmp_surf_list( surf_list.size() );
+ CAST_LIST_TO_PARENT( surf_list, tmp_surf_list );
+ init_edge_flags( tmp_surf_list, 0 );
+ for (ii=0; ii<surf_list.size(); ii++)
+ {
+ surf = surf_list.get_and_step();
+ fsurf = CAST_TO( surf, OCCSurface );
+
+ // if we are using a bspline representation, then we also need to
+ // transform the control points on the edges and facets
+
+ ftool = fsurf->get_eval_tool();
+ if (ftool->interp_order() == 4)
+ {
+ ftool->transform_control_points( tfmat );
+ }
+ ftool->reset_bounding_box();
+
+ DLIList<CubitFacet *>flist;
+ DLIList<CubitPoint *>plist;
+ fsurf->get_my_facets( flist, plist);
+ int jj;
+ CubitFacet *facet_ptr;
+ for (jj=0; jj<flist.size(); jj++)
+ {
+ facet_ptr = flist.get_and_step();
+ facet_ptr->update_plane();
+ facet_ptr->reset_bounding_box();
+ }
+
+ // if this facet surface has a primitive evaluator, then we need
+ // to tell it about the transformation also.
+ fsurf->add_transformation( tfmat );
+
+ //re-calculate the area of the surface in case it changed
+ fsurf->update_measurement();
+ }
+ init_edge_flags( tmp_surf_list, 0 );
+
+ // Some transforms (those incorporating reflections)
+ // invert the geometry. Correct for it.
+ // -- jason k.
+ if ( tfmat.sub_matrix(3,3).determinant() < 0.0 )
+ {
+ // Flip CoFace senses
+ DLIList<OCCShell*> shells;
+ get_shells( shells );
+ //modified. mbrewer. doing both a reverse and a
+ //reverse_surfaces. the latter actually changes the
+ // underlying surfaces so that the normals can all
+ // still be outward pointing. It automatically changes
+ // the sense, therefore we also still need excplicity
+ // call reverse so that sense is corrected.
+ while (shells.size()){
+ shells.get()->reverse_surfaces();
+ shells.pop()->reverse();
+ }
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//----------------------------------------------------------------
+// Function: init_edge_flags
+// Description: set the flags on the facet edges
+// Note: Only done for facet eval tool with order 4 interpolation
+// Author: sjowen
+//----------------------------------------------------------------
+void OCCBody::init_edge_flags( DLIList<Surface *>&surf_list,
+ int )
+{
+ int ii, jj;
+ Surface *surf;
+ OCCSurface *fsurf;
+ FacetEvalTool *ftool;
+ CubitFacetEdge *edge_ptr;
+
+ for (ii=0; ii<surf_list.size(); ii++)
+ {
+ DLIList<CubitFacetEdge*>edge_list;
+ surf = surf_list.get_and_step();
+ fsurf = CAST_TO( surf, OCCSurface );
+ ftool = fsurf->get_eval_tool();
+ if (ftool->interp_order() == 4)
+ {
+ ftool->get_edges( edge_list );
+ for (jj=0; jj<edge_list.size(); jj++)
+ {
+ edge_ptr = edge_list.get_and_step();
+ edge_ptr->set_flag( 0 );
+ }
+ }
+ }
+}
+
+CubitStatus OCCBody::get_transforms( CubitTransformMatrix &tfm )
+{
+ tfm = myTransforms;
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCBody::set_transforms( CubitTransformMatrix tfm )
+{
+ myTransforms = tfm;
+ return CUBIT_SUCCESS;
+}
+
+int OCCBody::validate(const CubitString &, DLIList <TopologyEntity*>&)
+{
+ PRINT_ERROR("This option is not available for mesh defined geometry.\n");
+ return 0;
+}
+
+void OCCBody::get_parents_virt( DLIList<TopologyBridge*>& )
+ {}
+
+void OCCBody::get_children_virt( DLIList<TopologyBridge*>& lumps )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSShape, TopAbs_SOLID, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *lump = OCCQueryEngine::occ_to_cgm(M(ii));
+ lumps.append_unique(lump);
+ }
+}
+
+void OCCBody::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSShape, TopAbs_SOLID, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *lump = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCLump*>(lump));
+ }
+}
+
+void OCCBody::get_shells( DLIList<OCCShell*>& result_list )
+{
+ DLIList<OCCLump*> lump_list;
+ get_lumps( lump_list );
+ lump_list.reset();
+ for ( int i = 0; i < lump_list.size(); i++ )
+ lump_list.next(i)->get_shells( result_list );
+}
+
+void OCCBody::get_surfaces( DLIList<OCCSurface*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ DLIList<OCCSurface*> tmp_list;
+ get_shells(shell_list);
+ shell_list.reset();
+ for ( int i = 0; i < shell_list.size(); i++ )
+ {
+ tmp_list.clean_out();
+ shell_list.next(i)->get_surfaces( tmp_list );
+ result_list.merge_unique( tmp_list );
+ }
+}
+
+void OCCBody::get_loops( DLIList<OCCLoop*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = 0; i < surface_list.size(); i++ )
+ surface_list.next(i)->get_loops( result_list );
+}
+
+void OCCBody::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = 0; i < surface_list.size(); i++ )
+ surface_list.next(i)->get_coedges( result_list );
+}
+
+void OCCBody::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ result_list.append_unique(curve);
+ }
+}
+
+void OCCBody::get_points( DLIList<OCCPoint*>& result_list )
+{
+ DLIList<OCCCurve*> curve_list;
+ get_curves( curve_list );
+ curve_list.reset();
+ for ( int i = curve_list.size(); i--; )
+ {
+ OCCCurve* curve = curve_list.get_and_step();
+ OCCPoint* point = dynamic_cast<OCCPoint*>(curve->start_point());
+ if (point)
+ result_list.append_unique(point);
+ point = dynamic_cast<OCCPoint*>(curve->end_point());
+ if (point)
+ result_list.append_unique(point);
+ }
+}
+
+void OCCBody::add_lump( OCCLump *lump_to_add )
+{
+ Lump* lump = dynamic_cast<Lump*>(lump_to_add);
+ if (lump)
+ {
+ lump_to_add->add_body(this);
+ myLumps.append( lump );
+ }
+}
+
+void OCCBody::remove_lump( OCCLump *lump_to_remove )
+{
+ OCCLump* lump = dynamic_cast<OCCLump*>(lump_to_remove);
+ if (lump)
+ {
+ assert(lump_to_remove->get_body() == this);
+ lump_to_remove->remove_body();
+ myLumps.remove( lump );
+ }
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+void OCCBody::disconnect_all_lumps()
+{
+ myLumps.reset();
+ for (int i = myLumps.size(); i--; )
+ {
+ Lump* sm_ptr = myLumps.get_and_step();
+ OCCLump* lump = dynamic_cast<OCCLump*>(sm_ptr);
+ if (lump)
+ {
+ assert(lump->get_body() == this);
+ lump->remove_body();
+ }
+ }
+ myLumps.clean_out();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Find centroid
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 05/10/04
+//-------------------------------------------------------------------------
+CubitStatus OCCBody::mass_properties( CubitVector& centroid,
+ double& volume )
+{
+ centroid.set( 0.0, 0.0, 0.0 );
+ volume = 0.0;
+
+ DLIList<OCCLump*> lumps (myLumps.size());
+ CAST_LIST( myLumps, lumps, OCCLump );
+ assert( myLumps.size() == lumps.size() );
+ for (int i = lumps.size(); i--; )
+ {
+ CubitVector cent;
+ double vol;
+ if (CUBIT_SUCCESS != lumps.get_and_step()->mass_properties(cent,vol))
+ return CUBIT_FAILURE;
+ centroid += vol*cent;
+ volume += vol;
+ }
+ if (volume > CUBIT_RESABS)
+ {
+ centroid /= volume;
+ }
+ else
+ {
+ centroid.set( 0.0, 0.0, 0.0 );
+ volume = 0.0;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Used to be OCCQueryEngine::is_point_in_body
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 05/10/04
+//-------------------------------------------------------------------------
+CubitPointContainment OCCBody::point_containment( const CubitVector &point )
+{
+ CubitPointContainment pc_value;
+ OCCLump *facet_lump;
+
+ int i;
+ for(i=myLumps.size(); i--;)
+ {
+ facet_lump = dynamic_cast<OCCLump*>(myLumps.get_and_step());
+ pc_value = facet_lump->point_containment( point );
+ if( pc_value == CUBIT_PNT_INSIDE )
+ return CUBIT_PNT_INSIDE;
+ else if( pc_value == CUBIT_PNT_BOUNDARY )
+ return CUBIT_PNT_BOUNDARY;
+ }
+
+ return CUBIT_PNT_OUTSIDE;
+}
+
+
Property changes on: cgm/trunk/geom/OCC/OCCBody.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,217 @@
+//-------------------------------------------------------------------------
+// Filename : OCCBody.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : David White
+//
+// Creation Date : 7/18/00
+//
+//-------------------------------------------------------------------------
+
+#ifndef FACET_BODY_HPP
+#define FACET_BODY_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "BodySM.hpp"
+#include "CubitTransformMatrix.hpp"
+#include "OCCAttribSet.hpp"
+
+#include <TopoDS_CompSolid.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class Body;
+class TopologyEntity;
+class CubitString;
+class OCCAttrib;
+
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+
+// ********** END FORWARD DECLARATIONS **********
+
+class OCCBody : public BodySM
+{
+public:
+
+ OCCBody(TopoDS_Shape *theShape);
+ OCCBody(DLIList<Lump*> &myLumps);
+ //- Constructor with a pointer to a ACIS BODY.
+ virtual ~OCCBody() ;
+ //- The destructor.
+
+ CubitBoolean can_be_deleted( DLIList <Body*> &body_list );
+
+ virtual GeometryQueryEngine* get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual BodySM* copy();
+ //R OCCBody*
+ //R- Pointer to a OCCBody object
+ //- Copies this OCCBody object (including the ACIS BODY that it
+ //- contains) and returns a pointer to a new OCCBody object.
+
+ virtual CubitStatus move(double , double , double );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I dx, dy, dz
+ //I- Offset values in each of the 3 Cartesian coordinate directions
+ //- Move the ACIS BODY by dx, dy and dz
+
+ virtual CubitStatus rotate( double , double , double ,
+ double );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I x, y, z
+ //I- Axis of rotation
+ //I angle_in_degrees
+ //I- Angle of rotation in degrees
+ //- Rotate the ACIS BODY angle degrees about a vector defined by
+ //- x, y and z
+
+ virtual CubitStatus scale(double, double, double);
+
+ virtual CubitStatus scale(double);
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I scaling_factor
+ //I- Scaling factor
+ //- Scale the ACIS BODY by the factor, scaling_factor
+
+ CubitStatus reflect(double,double,double);
+ //- reflect about an axis
+
+ virtual CubitStatus restore();
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //- Restore the ACIS BODY by replacing the transformation matrix
+ //- associated with it with a unit matrix
+
+#ifdef BOYD14
+ CubitStatus reverse() ;
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/CUBIT_FAILURE
+ //I BODYPtr
+ //- Reverse the face orientations on this body
+#endif
+
+ CubitStatus get_transforms( CubitTransformMatrix &tfm );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/CUBIT_FAILURE
+ //I BODYPtr
+ //- return the transformation matrix for this body
+
+ CubitStatus set_transforms( CubitTransformMatrix tfm );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/CUBIT_FAILURE that myTransforms was
+ // set correctly
+ //I BODYPtr
+
+ int validate(const CubitString &, DLIList <TopologyEntity*>&);
+ //- does an api_entity_check for the body.
+
+ CubitStatus save_attribs( FILE* file_ptr );
+ // Write FactAttribs out to file
+
+ CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
+ // Read FactAttribs from file
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+ void get_loops ( DLIList<OCCLoop *>& loops );
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+ void get_points ( DLIList<OCCPoint *>& points );
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ void disconnect_all_lumps();
+ void add_lump( OCCLump *lump_to_add );
+ void remove_lump( OCCLump *lump_to_remove );
+
+ virtual CubitStatus mass_properties( CubitVector& result, double& volume );
+
+ virtual CubitPointContainment point_containment( const CubitVector& pos );
+
+protected:
+
+private:
+ CubitStatus transform( CubitTransformMatrix &tfmat, CubitBoolean is_rotation );
+ // main function for applying transforms to facet-based bodies
+
+ void init_edge_flags( DLIList<Surface *>&surf_list, int flag );
+ // set the flags on the facet edges
+
+ CubitTransformMatrix myTransforms;
+ DLIList<Lump*> myLumps;
+ //List of the attached lumps for the traversal functions.
+ OCCAttribSet attribSet;
+ //List of OCCAttrib*'s instead of CubitSimpleAttribs
+ TopoDS_Shape *myTopoDSShape;
+};
+
+
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCBody.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCCoEdge.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoEdge.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCCoEdge.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,293 @@
+//-------------------------------------------------------------------------
+// Filename : OCCCoEdge.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 07/18/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "CastTo.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCLoop.hpp"
+#include "OCCQueryEngine.hpp"
+#include "CubitUtil.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCCurve.hpp"
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+// ********** END FORWARD DECLARATIONS **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : A constructor with a pointer to a Facet CoEdge.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+OCCCoEdge::OCCCoEdge( TopoDS_Edge *theEdge, Curve *curv_ptr )
+{
+ myTopoDSEdge = theEdge;
+ myCurve = curv_ptr;
+}
+
+OCCCoEdge::OCCCoEdge( Curve *curv_ptr, LoopSM *loop_ptr, CubitSense sense )
+{
+ assert(0);
+ myCurve = curv_ptr;
+ myLoop = loop_ptr;
+ edgeSense = sense;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : A constructor with a pointer to a Facet CoEdge.
+//
+// Special Notes : Constructor used for save/restore
+//
+// Creator : Corey Ernst
+//
+// Creation Date : 02/03/03
+//-------------------------------------------------------------------------
+OCCCoEdge::OCCCoEdge( Curve *curv_ptr, CubitSense sense )
+{
+ assert(0);
+ myCurve = curv_ptr;
+ myLoop = NULL;
+ edgeSense = sense;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The destructor
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+OCCCoEdge::~OCCCoEdge()
+{
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: OCCQueryEngine
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+GeometryQueryEngine* OCCCoEdge::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the OSME. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+void OCCCoEdge::append_simple_attribute_virt(CubitSimpleAttrib* /*csattrib_ptr*/)
+{
+ //PRINT_ERROR("OCCCoEdge::append_simple_attribute_virt not implemented\n");
+ return;
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+void OCCCoEdge::remove_simple_attribute_virt(CubitSimpleAttrib* /*csattrib_ptr*/)
+{
+ //PRINT_ERROR("OCCCoEdge::remove_simple_attribute_virt not implemented\n");
+ return;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+void OCCCoEdge::remove_all_simple_attribute_virt()
+{
+ //PRINT_ERROR("OCCCoEdge::remove_all_simple_attribute_virt not implemented\n");
+ return;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/18/00
+//-------------------------------------------------------------------------
+CubitStatus OCCCoEdge::get_simple_attribute(DLIList<CubitSimpleAttrib*>&
+ /*cubit_simple_attrib_list*/)
+{
+ //PRINT_ERROR("OCCCoEdge::get_simple_attribute not implemented\n");
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCCoEdge::get_simple_attribute(const CubitString&,
+ DLIList<CubitSimpleAttrib*>&)
+ { return CUBIT_FAILURE; }
+
+
+CubitSense OCCCoEdge::sense()
+{
+ TopAbs_Orientation d = myTopoDSEdge->Orientation();
+ if (d == TopAbs_FORWARD) return CUBIT_FORWARD;
+ else if (d == TopAbs_REVERSED) return CUBIT_REVERSED;
+ else {
+ printf("Check Orientation");
+ return CUBIT_UNKNOWN;
+ }
+}
+/*
+void OCCCoEdge::bodysms(DLIList<BodySM*> &bodies)
+{
+ myLoop->bodysms(bodies);
+}
+
+void OCCCoEdge::lumps(DLIList<Lump*> &lumps)
+{
+ myLoop->lumps(lumps);
+}
+
+void OCCCoEdge::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ myLoop->shellsms(shellsms);
+}
+
+void OCCCoEdge::surfaces(DLIList<Surface*> &surfaces)
+{
+ myLoop->surfaces( surfaces );
+}
+
+void OCCCoEdge::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ loopsms.append_unique( myLoop );
+}
+
+void OCCCoEdge::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ coedgesms.append_unique( this );
+}
+
+void OCCCoEdge::curves(DLIList<Curve*> &curves)
+{
+ curves.append_unique( myCurve );
+}
+
+void OCCCoEdge::points(DLIList<Point*> &points)
+{
+ myCurve->points( points );
+}
+*/
+
+void OCCCoEdge::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { parents.append( myLoop ); }
+
+void OCCCoEdge::get_children_virt( DLIList<TopologyBridge*>& children )
+ { children.append( myCurve ); }
+
+void OCCCoEdge::reverse_sense()
+{
+ edgeSense = CubitUtil::opposite_sense( edgeSense );
+}
+
+
+void OCCCoEdge::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ get_shells( shell_list );
+ shell_list.reset();
+ for ( int i = shell_list.size(); i--; )
+ {
+ OCCShell* shell = shell_list.get_and_step();
+ shell->get_lumps( result_list );
+ OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
+ if (lump)
+ result_list.append_unique(lump);
+ }
+}
+
+void OCCCoEdge::get_shells( DLIList<OCCShell*>& result_list )
+{
+ if ( OCCLoop* loop = dynamic_cast<OCCLoop*>(myLoop) )
+ if ( OCCSurface* surf = dynamic_cast<OCCSurface*>(loop->get_surface()) )
+ surf->get_shells( result_list );
+}
+
+void OCCCoEdge::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ if (OCCCurve* curve = dynamic_cast<OCCCurve*>(myCurve))
+ result_list.append(curve);
+}
+
+
+// ********** END PUBLIC FUNCTIONS **********
+
+// ********** BEGIN PROTECTED FUNCTIONS **********
+// ********** END PROTECTED FUNCTIONS **********
+
+// ********** BEGIN PRIVATE FUNCTIONS **********
+// ********** END PRIVATE FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASSES **********
+// ********** END HELPER CLASSES **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN STATIC FUNCTIONS **********
+// ********** END STATIC FUNCTIONS **********
+
Property changes on: cgm/trunk/geom/OCC/OCCCoEdge.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCCoEdge.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoEdge.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCCoEdge.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,165 @@
+//-------------------------------------------------------------------------
+// Filename : OCCCoEdge.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 07/23/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#ifndef FACETCOEDGE_HPP
+#define FACETCOEDGE_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "CubitEntity.hpp"
+#include "CoEdgeSM.hpp"
+#include <TopoDS_Edge.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class TopologyEntity;
+class LoopSM;
+
+class OCCBody;
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCurve;
+class OCCPoint;
+
+// ********** END FORWARD DECLARATIONS **********
+
+class OCCCoEdge : public CoEdgeSM
+{
+public:
+
+ OCCCoEdge(TopoDS_Edge *theEdge, Curve *curv_ptr);
+ OCCCoEdge(Curve *curv_ptr, LoopSM *loop_ptr, CubitSense sense);
+ //- A constructor
+ //
+ OCCCoEdge(Curve *curv_ptr, CubitSense sense);
+ //- A constructor (for save/restore)
+
+ virtual ~OCCCoEdge() ;
+ //- The destructor
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ CubitSense sense();
+ //- returns the sense of the underlying coedge wrt the underlying edge
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+#ifdef BOYD14
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+ void get_loops ( DLIList<OCCLoop *>& loops );
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+ void get_curves ( DLIList<OCCCurve *>& curves );
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ void add_loop( LoopSM *loop_ptr )
+ { myLoop = loop_ptr; }
+ //- set the loop pointer that this coedge is asociated
+
+#ifdef BOYD14
+ void set_sense( CubitSense sense );
+ //- set the sense of the coedge wrt the surface loop
+#endif
+ CubitSense get_sense()
+ {return edgeSense;}
+ //- get the sense of the coedge wrt the surface loop
+ void reverse_sense();
+
+ Curve *curve()
+ {return myCurve;}
+ //- get the curve associated with this coedge
+
+ inline LoopSM* get_loop() const { return myLoop; }
+
+ inline void remove_loop() { myLoop = 0; }
+ inline void remove_curve() { myCurve = 0; }
+
+protected:
+
+private:
+ LoopSM *myLoop;
+ Curve *myCurve;
+ CubitSense edgeSense;
+ TopoDS_Edge *myTopoDSEdge;
+};
+
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCCoEdge.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,1004 @@
+//-------------------------------------------------------------------------
+// Filename : OCCCurve.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 07/14/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+
+#include "CastTo.hpp"
+#include "CubitVector.hpp"
+#include "CubitBox.hpp"
+#include "GeometryDefines.h"
+#include "OCCCurve.hpp"
+#include "OCCAttrib.hpp"
+#include "FacetEvalTool.hpp"
+#include "CurveFacetEvalTool.hpp"
+#include "GeometryQueryEngine.hpp"
+#include "OCCQueryEngine.hpp"
+#include "CoEdgeSM.hpp"
+#include "CubitPoint.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCLoop.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCPoint.hpp"
+
+#include <BRepAdaptor_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <Bnd_Box.hxx>
+#include <BndLib_Add3dCurve.hxx>
+#include <Precision.hxx>
+#include <Extrema_ExtPC.hxx>
+#include <BRepLProp_CLProps.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+// ********** END FORWARD DECLARATIONS **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : The default constructor
+//
+// Special Notes :
+//
+// Creator: : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+OCCCurve::OCCCurve( TopoDS_Edge *theEdge )
+{
+ myTopoDSEdge = theEdge;
+}
+OCCCurve::OCCCurve(CurveFacetEvalTool *curve_facet_tool,
+ Point *start_ptr, Point *end_ptr,
+ DLIList<CoEdgeSM*> &coedge_list )
+ : sense_(CUBIT_FORWARD)
+{
+ assert(0);
+ static int counter = 0;
+ myId = counter++;
+ // Calculate a bounding box if there isn't one already
+ curveFacetEvalTool = curve_facet_tool;
+ myStartPoint = start_ptr;
+ myEndPoint = end_ptr;
+ myCoEdges += coedge_list;
+ periodic = start_ptr == end_ptr;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Another constructor
+//
+// Special Notes : Implemented for save/restore
+//
+// Creator: : Corey Ernst
+//
+// Creation Date : 02/03/03
+//-------------------------------------------------------------------------
+OCCCurve::OCCCurve(CurveFacetEvalTool *curve_facet_tool,
+ Point *start_ptr, Point *end_ptr,
+ CubitSense sense )
+{
+ assert(0);
+ static int counter = 0;
+ myId = counter++;
+ // Calculate a bounding box if there isn't one already
+ curveFacetEvalTool = curve_facet_tool;
+ myStartPoint = start_ptr;
+ myEndPoint = end_ptr;
+ periodic = start_ptr == end_ptr;
+ sense_ = sense;
+}
+//-------------------------------------------------------------------------
+// Purpose : The destructor.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+OCCCurve::~OCCCurve()
+{
+
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the GE. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+void OCCCurve::append_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.append_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+void OCCCurve::remove_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.remove_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+void OCCCurve::remove_all_simple_attribute_virt()
+ { attribSet.remove_all_attributes(); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::get_simple_attribute(DLIList<CubitSimpleAttrib*>&
+ csa_list)
+ { return attribSet.get_attributes(csa_list); }
+
+CubitStatus OCCCurve::get_simple_attribute( const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& csa_list)
+ { return attribSet.get_attributes( name, csa_list ); }
+
+
+CubitStatus OCCCurve::save_attribs( FILE *file_ptr )
+ { return attribSet.save_attributes(file_ptr); }
+
+CubitStatus OCCCurve::restore_attribs( FILE *file_ptr, unsigned int endian )
+ { return attribSet.restore_attributes(file_ptr, endian); }
+
+
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: OCCQueryEngine
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+GeometryQueryEngine* OCCCurve::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get the bounding box of the object.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 10/23/96
+//-------------------------------------------------------------------------
+CubitBox OCCCurve::bounding_box() const
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ Bnd_Box aBox;
+ BndLib_Add3dCurve::Add(acurve, Precision::Approximation(), aBox);
+ double min[3], max[3];
+ aBox.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+ return CubitBox(min, max);
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Return the length of the curve.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+double OCCCurve::measure()
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ return GCPnts_AbscissaPoint::Length(acurve);
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Return the arc length along the Curve starting from
+// the point represented by the parameter1 going to the
+// point represented by parameter2.
+//
+// Special Notes : The sign of the returned length value is always positive.
+// Parameter1 and parameter2 are with respect to the EDGE.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+double OCCCurve::length_from_u( double parameter1, double parameter2 )
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ return GCPnts_AbscissaPoint::Length(acurve, parameter1, parameter2);
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns CUBIT_TRUE and the associated period value. Not
+// implemented yet
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitBoolean OCCCurve::is_periodic(double& period)
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ if (acurve.IsPeriodic())
+ {
+ period = acurve.Period();
+ return CUBIT_TRUE;
+ }
+ return CUBIT_FALSE;
+}
+
+//------------------------------------------------------------------
+// Purpose: Returns CUBIT_TRUE and the associated parametric values,
+// if the facet curve associated with the first EDGE is
+// parametric.
+// Otherwise returns CUBIT_FALSE and the values of
+// the lower and upper parametric bounds are undetermined.
+// NOT IMPLEMENTED YET
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------
+CubitBoolean OCCCurve::get_param_range( double& lower_bound,
+ double& upper_bound )
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ lower_bound = acurve.FirstParameter();
+ upper_bound = acurve.LastParameter();
+ return CUBIT_TRUE;
+}
+
+//------------------------------------------------------------------
+// Purpose: Finds the extrema along this Curve.
+//
+// Special Notes : It is the responsibility of the
+// calling code to delete the CubitVectors added to
+// interior_points!
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 05/29/01
+//-------------------------------------------------------------------
+CubitStatus OCCCurve::get_interior_extrema(
+ DLIList<CubitVector*>& interior_points,
+ CubitSense& return_sense )
+{
+ // Danilov: try to use GeomAPI_ExtremaCurveCurve
+ assert(0);
+ // Need curveFacetEvalTool to get point list
+ if( ! curveFacetEvalTool )
+ return CUBIT_FAILURE;
+
+ // Get list of points defining this curve
+ DLIList<CubitPoint*> point_list;
+ get_points( point_list );
+
+ // If there are only 2 points, then the curve is a line and there
+ // are no interior extrema
+ if( point_list.size() < 3 )
+ return CUBIT_SUCCESS;
+
+ // Return sense is whatever the sense of this curve is.
+ return_sense = sense_;
+
+ // Get a vector between the first two points
+ point_list.reset();
+ CubitVector prev_pt = point_list.get_and_step()->coordinates();
+ CubitVector curr_pt = point_list.get_and_step()->coordinates();
+ CubitVector prev_vct = curr_pt - prev_pt;
+ CubitVector next_vct;
+
+ for( int i = point_list.size(); i > 2; i-- )
+ {
+ // Get a vector between the next two points
+ next_vct = point_list.get()->coordinates() - curr_pt;
+
+ // In CurveACIS::get_interior_extrema, the extrema seem to
+ // be evaluated with respect to the principle axes, so do
+ // the same here. The extrema are points at which the
+ // derivitive in the specified direction (principle axis)
+ // is zero. So look for a sign change in the slope across
+ // a point wrt each principle direction.
+ if( (prev_vct.x() * next_vct.x() < 0.) || // x extrema
+ (prev_vct.y() * next_vct.y() < 0.) || // y extrema
+ (prev_vct.z() * next_vct.z() < 0.) ) // z extrema
+ interior_points.append( new CubitVector( curr_pt ) );
+
+ // Advance to next point.
+ prev_vct = next_vct;
+ curr_pt = point_list.get_and_step()->coordinates();
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function computes the point on the curve closest
+// to the input location. Optionally, it can also compute
+// the tangent and curvature on the Curve at the point on
+// on the Curve closest to the input location.
+//
+// Special Notes : The tangent direction is always in the positive direction of the
+// owning RefEdge, regardless of the positive direction of the
+// underlying solid model entities.
+//
+// If the calling code needs the tangent and/or the curvature,
+// it is responsible for allocating the memory for these
+// CubitVector(s) and sending in the relevant non-NULL
+// pointers to this routine.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::closest_point(
+ CubitVector const& location,
+ CubitVector& closest_location,
+ CubitVector* tangent_ptr,
+ CubitVector* curvature_ptr,
+ double* param)
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
+ double newVal=0.0;
+ int i;
+ BRepLProp_CLProps CLP(acurve, 2, Precision::PConfusion());
+ Extrema_ExtPC ext(p, acurve, Precision::Approximation());
+ if (ext.IsDone() && (ext.NbExt() > 0)) {
+ for ( i = 1 ; i <= ext.NbExt() ; i++ ) {
+ if ( ext.IsMin(i) ) {
+ newVal = ext.Point(i).Parameter();
+ newP = ext.Point(i).Value();
+ CLP.SetParameter(newVal);
+ }
+ }
+ }
+ closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+ if (tangent_ptr != NULL) {
+ gp_Dir tangent;
+ if (CLP.IsTangentDefined()) {
+ CLP.Tangent(tangent);
+ *tangent_ptr = CubitVector(tangent.X(), tangent.Y(), tangent.Z());
+ }
+ }
+ if (curvature_ptr != NULL) {
+ double curvature = CLP.Curvature();
+ // Danilov: confused here
+ }
+ if (param != NULL) {
+ *param = newVal;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+
+//------------------------------------------------------------------
+// Purpose: This function returns the coordinate of a point in the local
+// parametric (u) space that corresponds to the input position
+// in global (world) space. The input point is first moved to
+// the closest point on the Curve and the parameter value of
+// that point is determined.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------
+CubitStatus OCCCurve::position_from_u (double u_value,
+ CubitVector& output_position)
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ gp_Pnt p = acurve.Value(u_value);
+ output_position.x(p.X());
+ output_position.y(p.Y());
+ output_position.z(p.Z());
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function returns the coordinate of a point in the local
+// parametric (u) space that corresponds to the input position
+// in global (world) space. The input point is first moved to
+// the closest point on the Curve and the parameter value of
+// that point is determined.
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 2/25/97
+//-------------------------------------------------------------------------
+double OCCCurve::u_from_position (const CubitVector& input_position)
+{
+ // Get the closest point on the Curve to the input position
+ CubitVector closest_point;
+ double u_val;
+ this->closest_point(input_position, closest_point,
+ NULL, NULL, &u_val);
+ // closest_point already makes adjustments for sense and periodicity
+
+ return u_val;
+}
+
+//------------------------------------------------------------------
+// Purpose: This function returns the parameter value of the point
+// that is "arc_length" away from the root point, in the
+// positive sense direction of the owning RefEdge.
+//
+// Special Notes :
+// If arc_length is negative, the new point (whose parameter value
+// is being computed) is in the negative sense direction (along
+// the RefEdge) from the root point (whose parameter value is
+// root_param).
+//
+// If the curve is not periodic and the new point, "arc_length"
+// away from the root point in the appropriate direction, goes
+// beyond the end point of the first EDGE, that end point is used
+// to generate the returned parameter value.
+//
+// If the curve is periodic and the new point, "arc_length" away
+// from the root point in the appropriate direction, goes beyond
+// the end point of the first EDGE, wrap around is done. After
+// wrap around, the point is treated as with other curves
+//
+// NOTE:
+// The important assumption that is made in this routine is that
+// the end points of the RefEdge that owns this CurveACIS are the
+// same as the end points of the first ACIS EDGE in the list of EDGEs
+// associated with this CurveACIS.
+//
+// Assume that the parameter root_param is with respect to the
+// RefEdge as well as arc_length. Before calling the ACIS "curve",
+// we need to get them with respect to the curve.
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 2/28/97
+//------------------------------------------------------------------
+double OCCCurve::u_from_arc_length ( double root_param,
+ double arc_length )
+{
+ BRepAdaptor_Curve acurve(*myTopoDSEdge);
+ GCPnts_AbscissaPoint abs(acurve, arc_length, root_param);
+ if (abs.IsDone()) return abs.Parameter();
+ else return 0.0;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function tests the passed in position to see if
+// is on the underlying curve.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitBoolean OCCCurve::is_position_on( const CubitVector &test_position )
+{
+ CubitVector new_point;
+ CubitStatus stat = closest_point(test_position, new_point, NULL,NULL,NULL);
+
+ if ( !stat )
+ return CUBIT_FALSE;
+ CubitVector result_vec = test_position - new_point;
+ if ( result_vec.length_squared() < GEOMETRY_RESABS )
+ return CUBIT_TRUE;
+ return CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function returns the type of underlying curve.
+//
+// Special Notes : It checks to see if *any* of the ACIS curves associated
+// with the EDGEs in the list of EDGEs of this Curve is of
+// a particular type and returns the appropriate value
+// of the enum, CurveType.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+GeometryType OCCCurve::geometry_type()
+{
+ return UNDEFINED_CURVE_TYPE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Return direction of point on curve
+//
+// Special Notes : not currently implemented
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::get_point_direction( CubitVector& point,
+ CubitVector& direction )
+{
+ point = point;
+ direction = direction;
+ PRINT_DEBUG_122("OCCCurve::get_point_direction currently not implemented.\n");
+ return CUBIT_FAILURE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Return the center and radius of an arc
+//
+// Special Notes : not currently implemented
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::get_center_radius( CubitVector& center,
+ double& radius )
+{
+ center = center;
+ radius = radius;
+ PRINT_DEBUG_122("OCCCurve::get_center_radius currently not implemented.\n");
+ return CUBIT_FAILURE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function returns the start parameter.
+//
+// Special Notes : The start param is with respect to the ref_edge.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+double OCCCurve::start_param()
+{
+ double start = 0.0, end = 0.0;
+
+ get_param_range( start, end );
+ return start;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function returns the end parameter.
+//
+// Special Notes : The end param is with respect to the ref_edge.
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+double OCCCurve::end_param()
+{
+ double start = 0.0, end = 0.0;
+
+ get_param_range( start, end );
+ return end;
+}
+
+/*
+void OCCCurve::bodysms(DLIList<BodySM*> &bodies)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->bodysms(bodies);
+ }
+}
+
+void OCCCurve::lumps(DLIList<Lump*> &lumps)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->lumps(lumps);
+ }
+}
+
+void OCCCurve::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->shellsms(shellsms);
+ }
+}
+
+void OCCCurve::surfaces(DLIList<Surface*> &surfaces)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->surfaces(surfaces);
+ }
+}
+
+void OCCCurve::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->loopsms(loopsms);
+ }
+}
+
+
+void OCCCurve::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ coedgesms.append_unique( myCoEdges.get_and_step() );
+ }
+}
+
+void OCCCurve::curves(DLIList<Curve*> &curves)
+{
+ curves.append_unique( this );
+}
+
+void OCCCurve::points(DLIList<Point*> &points)
+{
+ points.append_unique( myStartPoint );
+ points.append_unique( myEndPoint );
+}
+*/
+
+
+void OCCCurve::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { CAST_LIST_TO_PARENT( myCoEdges, parents ); }
+void OCCCurve::get_children_virt( DLIList<TopologyBridge*>& children )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSEdge, TopAbs_VERTEX, M);
+ TopologyBridge *point1, *point2;
+ if (M.Extent()==1) {
+ point1 = OCCQueryEngine::occ_to_cgm(M(1));
+ children.append_unique(point1);
+ } else if (M.Extent()==2) {
+ if ( fabs(BRep_Tool::Parameter(TopoDS::Vertex(M(1)), *myTopoDSEdge)-start_param()) >
+ fabs(BRep_Tool::Parameter(TopoDS::Vertex(M(2)), *myTopoDSEdge)-start_param()) ) {
+ point1 = OCCQueryEngine::occ_to_cgm(M(2));
+ point2 = OCCQueryEngine::occ_to_cgm(M(1));
+ } else {
+ point1 = OCCQueryEngine::occ_to_cgm(M(1));
+ point2 = OCCQueryEngine::occ_to_cgm(M(2));
+ }
+ if (point1 == point2) {
+ children.append_unique(point1);
+ } else {
+ children.append_unique(point1);
+ children.append_unique(point2);
+ }
+ }
+}
+
+
+
+
+//-------------------------------------------------------------------------
+// Purpose : Check for G1 discontinuity
+//
+// Special Notes : not implemented
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/14/00
+//-------------------------------------------------------------------------
+CubitBoolean OCCCurve::G1_discontinuous(
+ double param, CubitVector* mtan, CubitVector* ptan )
+{
+ assert(0);
+ DLIList<CubitPoint*> point_list;
+ curveFacetEvalTool->get_points( point_list );
+ CubitVector position;
+ position_from_u( param, position );
+ point_list.reset();
+ CubitPoint* prev = point_list.get_and_step();
+ for( int i = point_list.size(); i > 2; i--)
+ {
+ CubitPoint* point = point_list.get_and_step();
+ if( (point->coordinates() - position).length_squared() <
+ (GEOMETRY_RESABS*GEOMETRY_RESABS) )
+ {
+ if( mtan )
+ {
+ *mtan = point->coordinates() - prev->coordinates();
+ }
+ if( ptan )
+ {
+ *ptan = point_list.get()->coordinates() - point->coordinates();
+ }
+ return CUBIT_TRUE;
+ }
+ }
+ return CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : retreive the facet edge list for this curve
+//
+// Special Notes :
+//
+// Creator : Steve J. Owen
+//
+// Creation Date : 12/10/00
+//-------------------------------------------------------------------------
+void OCCCurve::get_facets(DLIList<CubitFacetEdge*>& facet_list)
+{
+ if (curveFacetEvalTool)
+ {
+ curveFacetEvalTool->get_facets(facet_list);
+ }
+ else
+ {
+ PRINT_ERROR("curve facet evaluation tool not defined for OCCCurve\n");
+ }
+}
+
+//-------------------------------------------------------------------------
+// Purpose : retreive the facet point list for this curve
+//
+// Special Notes :
+//
+// Creator : Steve J. Owen
+//
+// Creation Date : 12/10/00
+//-------------------------------------------------------------------------
+void OCCCurve::get_points(DLIList<CubitPoint*>& point_list)
+{
+ if (curveFacetEvalTool)
+ {
+ curveFacetEvalTool->get_points(point_list);
+ }
+ else
+ {
+ PRINT_ERROR("curve facet evaluation tool not defined for OCCCurve\n");
+ }
+}
+
+//-------------------------------------------------------------------------
+// Purpose : set the facetLength in the CurveFacetEvalTool
+//
+// Special Notes :
+//
+// Creator : Steve J. Owen
+//
+// Creation Date : 03/19/02
+//-------------------------------------------------------------------------
+void OCCCurve::reset_length()
+{
+ if (curveFacetEvalTool)
+ {
+ curveFacetEvalTool->set_length();
+ }
+ else
+ {
+ PRINT_ERROR("curve facet evaluation tool not defined for OCCCurve\n");
+ }
+}
+
+
+void OCCCurve::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ get_shells( shell_list );
+ shell_list.reset();
+ for ( int i = shell_list.size(); i--; )
+ {
+ OCCShell* shell = shell_list.get_and_step();
+ shell->get_lumps( result_list );
+ OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
+ if (lump)
+ result_list.append_unique(lump);
+ }
+}
+
+void OCCCurve::get_shells( DLIList<OCCShell*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ DLIList<OCCShell*> temp_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = surface_list.size(); i--; )
+ {
+ OCCSurface* surface = surface_list.get_and_step();
+ temp_list.clean_out();
+ surface->get_shells( temp_list );
+ result_list.merge_unique( temp_list );
+ }
+}
+
+void OCCCurve::get_surfaces( DLIList<OCCSurface*>& result_list )
+{
+ DLIList<OCCLoop*> loop_list;
+ get_loops( loop_list );
+ loop_list.reset();
+ for ( int i = loop_list.size(); i--; )
+ {
+ OCCLoop* loop = loop_list.get_and_step();
+ OCCSurface* surface = dynamic_cast<OCCSurface*>(loop->get_surface());
+ if (surface)
+ result_list.append_unique(surface);
+ }
+}
+
+void OCCCurve::get_loops( DLIList<OCCLoop*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCLoop* loop = dynamic_cast<OCCLoop*>(coedge->get_loop());
+ if (loop)
+ result_list.append_unique(loop);
+ }
+}
+
+void OCCCurve::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ myCoEdges.reset();
+ for ( int i = 0; i < myCoEdges.size(); i++ )
+ if ( OCCCoEdge* coedge = dynamic_cast<OCCCoEdge*>(myCoEdges.next(i)) )
+ result_list.append(coedge);
+}
+
+void OCCCurve::get_points( DLIList<OCCPoint*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSEdge, TopAbs_VERTEX, M);
+ int ii;
+ for (ii=M.Extent(); ii>0; ii--) {
+ TopologyBridge *point = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCPoint*>(point));
+ }
+}
+
+
+// ********** END PUBLIC FUNCTIONS **********
+
+// ********** BEGIN PROTECTED FUNCTIONS **********
+// ********** END PROTECTED FUNCTIONS **********
+
+// ********** BEGIN PRIVATE FUNCTIONS **********
+
+
+//----------------------------------------------------------------
+// Adjusts the input parameter so that it falls within the
+// parameter range of this Curve, if possible. Necessary for
+// periodic curves.
+//----------------------------------------------------------------
+void OCCCurve::adjust_periodic_parameter(double& param)
+{
+ assert(0);
+ // Adjustment only legal if this is a periodic curve.
+ double period;
+ if ( this->is_periodic(period) && (fabs(period) > CUBIT_RESABS))
+ {
+ double upper_bound, lower_bound;
+ this->get_param_range( lower_bound, upper_bound );
+ double edge_range = upper_bound - lower_bound;
+ assert( edge_range > CUBIT_RESABS * 100 );
+
+ lower_bound -= CUBIT_RESABS;
+ upper_bound += CUBIT_RESABS;
+
+ // Make sure period is positive
+ if (period < 0.)
+ period = -period;
+
+ // Move the parameter above the low param
+ while (param < lower_bound)
+ param += period;
+ // Move the parameter below the high param
+ while (param > upper_bound)
+ param -= period;
+ }
+}
+CubitPointContainment OCCCurve::point_containment( const CubitVector &/*point*/ )
+{
+ return CUBIT_PNT_UNKNOWN;
+}
+CubitPointContainment OCCCurve::point_containment( double /*u_param*/,
+ double /*v_param*/ )
+{
+ return CUBIT_PNT_UNKNOWN;
+}
+CubitPointContainment OCCCurve::point_containment( CubitVector &/*point*/,
+ double /*u_param*/,
+ double /*v_param*/ )
+{
+ return CUBIT_PNT_UNKNOWN;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::disconnect_coedge( OCCCoEdge* coedge )
+{
+ assert(0);
+ if (!myCoEdges.move_to(coedge))
+ return CUBIT_FAILURE;
+ myCoEdges.remove();
+
+ assert(coedge->curve() == this);
+ coedge->remove_curve();
+
+ return CUBIT_SUCCESS;
+}
+
+// ********** END PRIVATE FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASSES **********
+// ********** END HELPER CLASSES **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN STATIC FUNCTIONS **********
+// ********** END STATIC FUNCTIONS **********
Property changes on: cgm/trunk/geom/OCC/OCCCurve.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,429 @@
+//-------------------------------------------------------------------------
+// Filename : OCCCurve.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 07/14/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#ifndef CURVE_FACET_HPP
+#define CURVE_FACET_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "Curve.hpp"
+#include "OCCAttribSet.hpp"
+#include <TopoDS_Edge.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class TopologyEntity;
+class CurveFacetEvalTool;
+class FacetEvalTool;
+class OCCAttrib;
+class CurveFacetEvalTool;
+class Point;
+class CubitPoint;
+class CubitFacetEdge;
+class CubitFacetEdge;
+
+class OCCBody;
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCoEdge;
+class OCCPoint;
+
+// ********** END FORWARD DECLARATIONS **********
+
+class OCCCurve : public Curve
+{
+public :
+
+ OCCCurve( TopoDS_Edge *theEdge );
+ OCCCurve( CurveFacetEvalTool *curve_facet_tool,
+ Point *fp0, Point *fp1,
+ DLIList<CoEdgeSM*> &coedgelist );
+ //I- curve_facet_eval_tool_ptr pointer
+ //I- A pointer to the set of facet edges that define this curve.
+
+ OCCCurve( CurveFacetEvalTool *curve_facet_tool,
+ Point *fp0, Point *fp1,
+ CubitSense sense );
+ //I- curve_facet_eval_tool_ptr pointer
+ //I- start and end points
+ //I- Sense of curve
+
+ virtual ~OCCCurve() ;
+ //- The destructor
+
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual CubitBox bounding_box() const ;
+ //- see comments in GeometryEntity.hpp
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ virtual double measure();
+ //R double
+ //R- The numeric value of the measure (its units depend on the dimension
+ //R- of the RefEntity being "measured")
+ //- A generic geometric extent function.
+ //- Returns volume for Lump, area for Surface, length for Curve and
+ //- 1.0 for Point
+ //-
+ //- If there is an error computing the length a value of -1.0 is
+ //- returned.
+
+ virtual double length_from_u( double parameter1,
+ double parameter2 );
+ //R double
+ //R- Returned length value
+ //I parameter1
+ //I- The first parameter value
+ //I parameter2
+ //I- The second parameter value
+ //- This function returns the arc length along the Curve starting from
+ //- the point represented by the parameter1 going to the point represented
+ //- by parameter2.
+ //-
+ //- The sign of the returned length value is always positive.
+
+ virtual CubitBoolean is_periodic( double& period);
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O period
+ //O- Returned period value
+ //- This function determines whether the underlying geometry of the
+ //- Curve is periodic or not. Returns CUBIT_TRUE if it is and
+ //- CUBIT_FALSE if it is not.
+ //-
+ //- If it is periodic, then it returns the period in the input
+ //- reference variable, "period". This value is set to 0.0 if
+ //- the Curve is not periodic.
+ //-
+
+ virtual CubitBoolean get_param_range( double& lower_bound,
+ double& upper_bound );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O lower_bound
+ //O- The lower bound of the parametric range.
+ //O upper_bound
+ //O- The upper bound of the parametric range.
+ //- Returns the lower and upper parametric bounds of the
+ //- Curve.
+ //-
+ //- IMPORTANT NOTE:
+ //- Note that the lower bound is the parameter value of the start
+ //- location of the RefEdge that uses this Curve and the upper
+ //- bound is the parameter value of the end location of the RefEdge
+ //- that uses this Curve. This takes into account the sense of the
+ //- RefEdge with respect to the Curve (which could be REVERSED).
+ //- Hence, the numerical value of the lower parameter bound could be
+ //- greater than that of the upper parameter bound.
+
+ virtual CubitStatus get_interior_extrema(DLIList<CubitVector*>& interior_points,
+ CubitSense& return_sense);
+ //- Finds the extrema along this RefEdge. An extremum is defined as
+ //- a local min or max in the direction of one of the primary axial directions.
+ //- O-interior_points: list of coordinates where the extrema occur.
+ //- O-return_sense: Whether the interior extrema are ordered in the
+ //- FORWARD or REVERSED direction of this RefEdge.
+ //-
+ //- ***IMPORTANT!!!***
+ //- This function dynamically allocates the CubitVectors appended to
+ //- interior_points. It is the responsibility of the calling code to
+ //- delete these CubitVectors (or in the case of RefEdge, to make sure
+ //- that *it's* calling code knows that it should delete the CubitVectors)!
+
+ virtual CubitStatus closest_point( CubitVector const& location,
+ CubitVector& closest_location,
+ CubitVector* tangent_ptr = NULL,
+ CubitVector* curvature_ptr = NULL,
+ double *param = NULL);
+ //R void
+ //I location
+ //I- The point to which the closest point on the Curve is desired.
+ //O closest_location
+ //O- The point on the Curve, closest to the input location which
+ //O- might not be on the Curve. This is input as a reference
+ //O- so that the function can modify its contents.
+ //O tangent_ptr
+ //O- The tangent to the Curve (output as a unit vector) at the
+ //O- closest_location.
+ //O curvature_ptr
+ //O- The curvature of the Curve at the closest_location.
+ //- This function computes the point on the Curve closest to the input
+ //- location.
+ //-
+ //- If the tangent and/or curvature is required, then the calling code
+ //- is responsible for allocating space for the CubitVector(s) and
+ //- sending in the relevant non-NULL pointers. If either of these
+ //- pointers is NULL, the related quantity is not computed.
+ //-
+ //- Notes:
+ //- The tangent direction is always in the positive direction of the
+ //- *owning RefEdge*, regardless of the positive direction of the
+ //- underlying solid model entities.
+
+#ifdef BOYD14
+ void get_tangent( CubitVector const& location,
+ CubitVector& tangent);
+ //- this function returns the tangent vector at the given location
+
+ void get_curvature( CubitVector const& location,
+ CubitVector& curvature);
+ //- this function returns the curvature vector at the given location
+#endif
+
+ virtual CubitStatus position_from_u (double u_value,
+ CubitVector& output_position);
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I u_value
+ //I- The input u parameter value
+ //O output_position
+ //O- The output position
+ //- This function returns the coordinates of a point in the global
+ //- (world) space that corresponds to the input parametric position
+ //- in the local space.
+ //-
+ //- If the input parameter value is not defined for the Curve, then
+ //- the input CubitVector is not modified and CUBIT_FAILURE is
+ //- returned. Otherwise, position is appropriately modified and
+ //- CUBIT_SUCCESS is returned.
+ //-
+ //- If the curve is periodic, the input u_value is first "normalized"
+ //- to the fundamental period of the Curve before its position
+ //- in global space is determined.
+
+ double u_from_position (const CubitVector& input_position);
+
+ virtual double u_from_arc_length ( double root_param,
+ double arc_length );
+ //R double
+ //R- Returned parameter value
+ //I root_param
+ //I- The parameter value of the "root point"
+ //I arc_length
+ //I- A distance along the Curve
+ //- This function returns the parameter value of the point that is
+ //- "arc_length" away from the root point in the
+ //- positive sense direction of the owning RefEdge.
+ //-
+ //- If arc_length is negative, the new point (whose parameter value is
+ //- being computed) is in the negative sense direction (along the
+ //- RefEdge) from the root point (whose parameter value is root_param).
+
+ virtual CubitBoolean is_position_on( const CubitVector &test_position );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //I CubitVector
+ //I- position, point where we want to test, whether or not it
+ //- is on the curve.
+
+ GeometryType geometry_type();
+ //R GeometryType (enum)
+ //R- The enumerated type of the geometric representation
+
+ CubitStatus get_point_direction( CubitVector& origin, CubitVector& direction );
+ //- Only valid for straight lines
+ //- Finds the underlying line's origin and direction unit vector
+ //- Returns CUBIT_FAILURE if curve is not a line
+
+ CubitStatus get_center_radius( CubitVector& center, double& radius );
+ //- Only valid for arcs
+ //- Finds the underlying arc's center point and radius
+ //- Returns CUBIT_FAILURE if curve is not an arc
+
+ virtual double start_param();
+ //R double parameter
+ //R- start parameter of curve with respect to refEdge.
+
+ virtual double end_param();
+ //R double parameter
+ //R- start parameter of curve with respect to refEdge.
+
+ virtual CubitBoolean G1_discontinuous( double param,
+ CubitVector* minus_tangent = NULL,
+ CubitVector* plus_tangent = NULL );
+
+ virtual CubitPointContainment point_containment( const CubitVector &point );
+ virtual CubitPointContainment point_containment( double u, double v );
+ virtual CubitPointContainment point_containment( CubitVector &point,
+ double u, double v );
+ //R CubitPointContainment - is the point outside, inside or on the boundary?
+ //R- CUBIT_PNT_OUTSIDE, CUBIT_PNT_INSIDE, CUBIT_PNT_BOUNDARY,
+ // CUBIT_PNT_UNKNOWN
+ //I CubitVector
+ //I- position to check, known to be on the Surface
+ //I double
+ //I- u coordinate, if known (significantly faster, if this is known - however
+ // if not known let the function figure it out)
+ //I double
+ //I- v coordinate, if known (significantly faster, if this is known - however
+ // if not known let the function figure it out)
+ // NOTE: POINT MUST LIE ON THE SURFACE FOR THIS FUNCTION TO WORK PROPERLY.
+
+ CubitStatus save_attribs( FILE* file_ptr );
+ // Write FactAttribs out to file
+
+ CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
+ // Read FactAttribs from file
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+ void get_loops ( DLIList<OCCLoop *>& loops );
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+#ifdef BOYD14
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#endif
+ void get_points ( DLIList<OCCPoint *>& points );
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ void add_loop( LoopSM *loop_ptr )
+ { myLoops.append_unique( loop_ptr ); }
+ //- associate this curve with a coedge
+
+ void add_coedge( CoEdgeSM *coedge_ptr )
+ { myCoEdges.append_unique( coedge_ptr ); }
+ //- associate this curve with a coedge
+
+ void get_facets(DLIList<CubitFacetEdge*>& facet_list);
+ //- Gets the list of facets describing this curve.
+ void get_points(DLIList<CubitPoint*>& point_list);
+ //- Gets the list of points describing this curve.
+
+ void reset_length();
+ //- update the length of the facet curve
+
+ CurveFacetEvalTool *get_eval_tool()
+ { return curveFacetEvalTool; }
+ //- return the curve evaluation tool
+
+ void set_eval_tool( CurveFacetEvalTool *eval_tool)
+ { curveFacetEvalTool = eval_tool; }
+ //- set the curve evaluation tool
+
+ Point *start_point()
+ { assert(0);return myStartPoint; }
+ Point *end_point()
+ { assert(0);return myEndPoint; }
+ CubitSense get_sense() { return sense_; }
+
+ CubitStatus disconnect_coedge( OCCCoEdge* coedge );
+
+ void remove_start_point() { myStartPoint = 0; }
+ void remove_end_point() { myEndPoint = 0; }
+
+ bool has_parent_coedge() { return myCoEdges.size() > 0; }
+
+protected:
+
+private:
+
+ CubitSense get_relative_curve_sense();
+ //R CubitSense
+ //R- Returned sense value
+ //- Returns the sense of the RefEdge with respect to the underlying
+ //- facet curve.
+
+ void adjust_periodic_parameter(double& param);
+
+ CubitSense sense_;
+ //- The sense of the RefEdge that owns this Curve with respect
+ //- to the positive sense of the first EDGE in EDGEPtrList_.
+ //- When a Curve is first constructed, this value is arbitrarily
+ //- set to CUBIT_FORWARD.
+ //- MJP NOTE:
+ //- Not only does the RefEdge have a sense wrt its Curve, but each
+ //- ACIS EDGE has a sense wrt its underlying "curve" object.
+
+ OCCAttribSet attribSet;
+ //List of OCCAttrib*'s instead of CubitSimpleAttribs
+
+ friend void run_test_function();
+
+ CurveFacetEvalTool *curveFacetEvalTool;
+ TopoDS_Edge *myTopoDSEdge;
+ DLIList<LoopSM*> myLoops;
+ Point *myStartPoint;
+ Point *myEndPoint;
+ DLIList<CoEdgeSM*> myCoEdges;
+ int myId;
+ bool periodic;
+};
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCCurve.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCGeometryCreator.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCGeometryCreator.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCGeometryCreator.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,156 @@
+//-------------------------------------------------------------------------
+// Filename : OCCGeometryCreator.hpp
+//
+// Purpose : For a list of facets, builds a topology of
+// surfaces, curves and vertices
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Date : 4/29/2001
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#ifndef MESHGEOMETRYCREATOR_HPP
+#define MESHGEOMETRYCREATOR_HPP
+
+#include "DLIList.hpp"
+
+class FacetEntity;
+class FacetCurveMesh;
+class FacetSurfaceMesh;
+class FacetVolumeMesh;
+class LoopSM;
+class Body;
+class Surface;
+class FacetPointMesh;
+class CubitPoint;
+class CubitFacetEdge;
+class CubitFacet;
+
+class FacetGeometryCreator
+{
+public:
+ FacetGeometryCreator( );
+ FacetGeometryCreator(DLIList<FacetEntity*> &face_list,
+ DLIList<FacetEntity*> &edge_list,
+ DLIList<FacetEntity*> &point_list );
+ //- Constructor
+
+ ~FacetGeometryCreator();
+ //- Destructor
+
+#ifdef BOYD14
+ CubitStatus create_geometry(CubitBoolean use_feature_angle,
+ double angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list);
+ //- Creates the geometry infrastructure based on
+ //- the given mesh data.
+#endif
+ void print_me();
+
+private:
+
+ DLIList<FacetEntity*> faceList;
+ DLIList<FacetEntity*> edgeList;
+ DLIList<FacetEntity*> pointList;
+ DLIList<FacetSurfaceMesh*> facetSurfaceList;
+ DLIList<FacetCurveMesh*> facetCurveList;
+ DLIList<FacetPointMesh*> facetPointList;
+
+ DLIList<FacetCurveMesh*> *hashCurveArray;
+ int hashCurveSize;
+ DLIList<FacetPointMesh*> *hashPointArray;
+ int hashPointSize;
+
+ void set_up_tool_datas( );
+ void delete_tool_datas( );
+
+#ifdef BOYD14
+ int facet_dimension(FacetEntity *facet_ptr);
+ //- returns the dimension of the facet entity.
+#endif
+
+ CubitStatus create_volume_boundaries( DLIList<FacetSurfaceMesh*> &facet_surface_sheets,
+ CubitBoolean use_feature_angle,
+ double min_dot,
+ CubitBoolean split_surfaces );
+ //- creates the correct facetsurfaces for all the element blocks.
+
+ CubitStatus create_surface_boundaries( DLIList<FacetSurfaceMesh*> &facet_surface_list,
+ DLIList<FacetCurveMesh*> &facet_curve_list,
+ CubitBoolean use_feature_angle,
+ double min_dot );
+ //- creates the correct blockcurves for all the surfaces
+
+ CubitStatus create_curve_boundaries( DLIList<FacetCurveMesh*> &facet_curve_list,
+ DLIList<FacetPointMesh*> &facet_point_list );
+ //- creates the correct blockpoints for all the curves
+
+ CubitStatus classify_edge( FacetEntity *edge_ptr,
+ DLIList<FacetCurveMesh*> &facet_curve_list,
+ FacetSurfaceMesh *fsm_ptr );
+ //- sorts a edge into its correct curve based on its associated
+ //- blocks and sidesets. Creates a new facet curve if necessary.
+
+ CubitStatus classify_point(CubitPoint *point_ptr,
+ DLIList<FacetPointMesh*> &facet_point_list,
+ FacetCurveMesh *fcm_ptr );
+ //- sorts a node into correct point based on its associated
+ //- curve. Creates a new facet point if necessary
+
+ CubitStatus build_geometry( DLIList<FacetSurfaceMesh*> &facet_surface_list,
+ DLIList<FacetCurveMesh*> &facet_curve_list,
+ DLIList<FacetPointMesh*> &facet_point_list,
+ int interp_order,
+ CubitBoolean use_feature_angle,
+ double min_dot,
+ CubitBoolean smooth_non_manifold ,
+ CubitBoolean split_surfaces );
+ //- build the CUBIT geometry based on the Facet entity class lists
+
+ CubitStatus build_point_geometry( DLIList<FacetPointMesh*> &facet_point_list );
+ //- From the facet point list, create geometric points for each
+
+ CubitStatus build_curve_geometry( DLIList<FacetCurveMesh*> &facet_curve_list );
+ //- From the facet curve list, create geometric curves for each
+
+ CubitStatus build_loop_geometry( DLIList<FacetCurveMesh*> &facet_curve_list,
+ FacetSurfaceMesh *fsm_ptr,
+ DLIList<LoopSM*> &loop_list,
+ int &ncurves );
+ //- From the facet curve list of a surface, create geometric loops
+
+ CubitStatus build_surface_geometry( DLIList<FacetSurfaceMesh*> &facet_surface_list,
+ int interp_order, double min_dot );
+ //- From the facet surface list, create geometric surface,
+ //- loops and coedges for each surface in the list
+
+ CubitStatus init_hash_curves( );
+ void delete_hash_curves( );
+ int get_curve_hash_key( DLIList<FacetSurfaceMesh*> *bsm_list_ptr );
+ // functions for hashing curves - to speed up edge classification
+
+ CubitStatus init_hash_points( );
+ void delete_hash_points( );
+ int get_point_hash_key( DLIList<FacetCurveMesh*> *bsm_list_ptr );
+ // functions for hashing points - to speed up node classification
+
+ CubitStatus clean_geometry( CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ CubitBoolean use_feature_angle,
+ double min_dot,
+ DLIList <FacetCurveMesh *> &facet_curve_list );
+
+ //- fix the edge control points and the normals so they are conforming
+ //- (or non-conforming) accross curves
+
+
+};
+
+#endif
Added: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,301 @@
+//-------------------------------------------------------------------------
+// Filename : OCCLoop.cpp
+//
+// Purpose : Loops for Facet-based geometry module
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 12/06/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#include "CastTo.hpp"
+#include "OCCLoop.hpp"
+#include "OCCQueryEngine.hpp"
+#include "CoEdgeSM.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCCurve.hpp"
+#include "OCCPoint.hpp"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the FacetEvalTool.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCLoop::OCCLoop( TopoDS_Wire *theWire )
+{
+ myTopoDSWire = theWire;
+}
+OCCLoop::OCCLoop( Surface *surf_ptr,
+ DLIList<CoEdgeSM*> &coedge_list )
+{
+ mySurface = surf_ptr;
+ myCoEdges += coedge_list;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with coedges.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCLoop::OCCLoop( DLIList<CoEdgeSM*> &coedge_list )
+{
+ myCoEdges += coedge_list;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The default destructor.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCLoop::~OCCLoop()
+{
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the GE. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCLoop::append_simple_attribute_virt(CubitSimpleAttrib* /*csattrib_ptr*/)
+{
+ //PRINT_ERROR("OCCLoop::append_simple_attribute_virt not defined\n");
+ return;
+
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCLoop::remove_simple_attribute_virt(CubitSimpleAttrib* /*csattrib_ptr*/)
+{
+ //PRINT_ERROR("OCCLoop::remove_simple_attribute_virt not defined\n");
+ return;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCLoop::remove_all_simple_attribute_virt()
+{
+ //PRINT_ERROR(" OCCLoop::remove_all_simple_attribute_virt not defined\n");
+ return;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCLoop::get_simple_attribute(DLIList<CubitSimpleAttrib*>&
+ /*cubit_simple_attrib_list*/)
+{
+ //PRINT_ERROR("OCCLoop::get_simple_attribute not defined\n");
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCLoop::get_simple_attribute(const CubitString&,
+ DLIList<CubitSimpleAttrib*>&)
+ { return CUBIT_FAILURE; }
+
+//-------------------------------------------------------------------------
+// Purpose : compute bounding box of loop
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitBox OCCLoop::bounding_box() const
+{
+ CubitBox box;
+ PRINT_ERROR("OCCLoop::bounding_box not implemented\n");
+ return box;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: OCCQueryEngine
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+GeometryQueryEngine* OCCLoop::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+/*
+void OCCLoop::bodysms(DLIList<BodySM*> &bodies)
+{
+ mySurface->bodysms(bodies);
+}
+
+void OCCLoop::lumps(DLIList<Lump*> &lumps)
+{
+ mySurface->lumps(lumps);
+}
+
+void OCCLoop::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ mySurface->shellsms(shellsms);
+}
+
+void OCCLoop::surfaces(DLIList<Surface*> &surfaces)
+{
+ surfaces.append_unique( mySurface );
+}
+
+void OCCLoop::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ loopsms.append_unique( this );
+}
+void OCCLoop::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ coedgesms.append_unique(myCoEdges.get_and_step());
+ }
+}
+
+void OCCLoop::curves(DLIList<Curve*> &curves)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->curves(curves);
+ }
+}
+void OCCLoop::points(DLIList<Point*> &points)
+{
+ int ii;
+ for ( ii = myCoEdges.size(); ii > 0; ii-- )
+ {
+ myCoEdges.get_and_step()->points(points);
+ }
+}
+*/
+
+
+void OCCLoop::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { parents.append( mySurface ); }
+void OCCLoop::get_children_virt( DLIList<TopologyBridge*>& children )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSWire, TopAbs_EDGE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *curve = OCCQueryEngine::occ_to_cgm(M(ii));
+ children.append_unique(curve);
+ }
+}
+
+
+void OCCLoop::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ get_shells( shell_list );
+ shell_list.reset();
+ for ( int i = shell_list.size(); i--; )
+ {
+ OCCShell* shell = shell_list.get_and_step();
+ shell->get_lumps( result_list );
+ OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
+ if (lump)
+ result_list.append_unique(lump);
+ }
+}
+
+void OCCLoop::get_shells( DLIList<OCCShell*>& result_list )
+{
+ if ( OCCSurface* surf = dynamic_cast<OCCSurface*>(mySurface) )
+ surf->get_shells( result_list );
+}
+
+void OCCLoop::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSWire, TopAbs_EDGE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *curve = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCCoEdge*>(curve));
+ }
+}
+
+void OCCLoop::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ result_list.append_unique(curve);
+ }
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+void OCCLoop::disconnect_all_coedges()
+{
+ myCoEdges.reset();
+ for (int i = myCoEdges.size(); i--; )
+ {
+ CoEdgeSM* sm_ptr = myCoEdges.get_and_step();
+ OCCCoEdge* coedge = dynamic_cast<OCCCoEdge*>(sm_ptr);
+ if (coedge)
+ {
+ assert(coedge->get_loop() == this);
+ coedge->remove_loop();
+ }
+ }
+ myCoEdges.clean_out();
+}
+
+
Property changes on: cgm/trunk/geom/OCC/OCCLoop.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCLoop.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCLoop.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,152 @@
+//-------------------------------------------------------------------------
+// Filename : OCCLoop.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 12/06/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#ifndef LOOP_Facet_HPP
+#define LOOP_Facet_HPP
+
+#include "CubitDefines.h"
+#include "CubitEntity.hpp"
+#include "LoopSM.hpp"
+#include "DLIList.hpp"
+
+#include <TopoDS_Wire.hxx>
+
+class GeometryEntity;
+
+class OCCBody;
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+
+class OCCLoop : public LoopSM
+{
+public :
+
+ OCCLoop( TopoDS_Wire *theWire );
+ OCCLoop( Surface *surf_ptr,
+ DLIList<CoEdgeSM*> &coedge_list );
+ //I- surf_ptr
+ //I- A pointer to the set of CoEdges that bound this loop
+
+ OCCLoop( DLIList<CoEdgeSM*> &coedge_list );
+ //I- A pointer to the set of CoEdges that bound this loop
+
+ virtual ~OCCLoop() ;
+ //- The destructor
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual CubitBox bounding_box() const ;
+ // see comments in GeometryEntity.hpp
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+#ifdef BOYD14
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+ void get_loops ( DLIList<OCCLoop *>& loops );
+#endif
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#ifdef BOYD14
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ void add_surface( Surface *new_surface_ptr )
+ { mySurface = new_surface_ptr; }
+
+ void reverse()
+ { myCoEdges.reverse(); }
+
+ inline Surface* get_surface() const { return mySurface; }
+
+ inline void remove_surface() { mySurface = 0; }
+
+ void disconnect_all_coedges();
+
+protected:
+
+private:
+ Surface *mySurface;
+ DLIList<CoEdgeSM*> myCoEdges;
+ TopoDS_Wire *myTopoDSWire;
+
+};
+
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCLoop.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,483 @@
+//-------------------------------------------------------------------------
+// Filename : OCCLump.cpp
+//
+// Purpose :
+//
+// Creator : David White
+//
+// Creation Date : 7/18/2000
+//
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+#include <assert.h>
+// ********** END STANDARD INCLUDES **********
+
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "OCCQueryEngine.hpp"
+#include "OCCLump.hpp"
+#include "CastTo.hpp"
+#include "Surface.hpp"
+#include "DLIList.hpp"
+#include "CubitFacet.hpp"
+#include "CubitPoint.hpp"
+#include "CubitVector.hpp"
+#include "CubitString.hpp"
+#include "ShellSM.hpp"
+#include "BodySM.hpp"
+#include "Body.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCLoop.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCCurve.hpp"
+#include "OCCPoint.hpp"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class RefVolume;
+// ********** END FORWARD DECLARATIONS **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the owning shells and body.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCLump::OCCLump(TopoDS_Solid *theSolid)
+{
+ myTopoDSSolid = theSolid;
+}
+
+OCCLump::OCCLump(DLIList<ShellSM*> &shells,
+ BodySM *body_ptr )
+{
+ myBodyPtr = body_ptr;
+ myShells += shells;
+}
+
+
+OCCLump::~OCCLump()
+{}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the GE. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+// Creator : Malcolm J. Panthaki
+//
+// Creation Date : 11/21/96
+//-------------------------------------------------------------------------
+void OCCLump::append_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.append_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : David R. White
+//
+// Creation Date : 03/18/97
+//-------------------------------------------------------------------------
+void OCCLump::remove_simple_attribute_virt(CubitSimpleAttrib *csa )
+ { attribSet.remove_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+// Creator : Greg Nielson
+//
+// Creation Date : 07/10/98
+//-------------------------------------------------------------------------
+void OCCLump::remove_all_simple_attribute_virt()
+{ attribSet.remove_all_attributes(); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCLump::get_simple_attribute(DLIList<CubitSimpleAttrib*>& csa_list)
+ { return attribSet.get_attributes( csa_list ); }
+
+CubitStatus OCCLump::get_simple_attribute( const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& csa_list )
+ { return attribSet.get_attributes( name, csa_list ); }
+
+CubitStatus OCCLump::save_attribs( FILE *file_ptr )
+ { return attribSet.save_attributes( file_ptr ); }
+
+CubitStatus OCCLump::restore_attribs( FILE *file_ptr, unsigned int endian )
+ { return attribSet.restore_attributes( file_ptr, endian ); }
+
+
+
+
+//-------------------------------------------------------------------------
+// Purpose : Get the bounding box of the object.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitBox OCCLump::bounding_box() const
+{
+ CubitBox my_box, temp_box;
+ DLIList<OCCSurface*> surfaces;
+ int ii;
+ const_cast<OCCLump*>(this)->get_surfaces(surfaces);
+ if (surfaces.size() > 0)
+ {
+ Surface* surface = surfaces.get_and_step();
+ my_box = surface->bounding_box();
+ for ( ii = surfaces.size(); ii > 1; ii-- )
+ {
+ surface = surfaces.get_and_step();
+ temp_box = surface->bounding_box();
+ //unite the boxes..
+ my_box |= temp_box;
+ }
+ }
+ return my_box;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: AcisGeometryEngine
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+GeometryQueryEngine*
+ OCCLump::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns the volume of the Lump
+//
+// Special Notes :
+//
+// Creator :
+//
+// Creation Date :
+//-------------------------------------------------------------------------
+double OCCLump::measure()
+{
+ DLIList<CubitFacet*> bounding_facets;
+ DLIList<CubitPoint*> bounding_points;
+ DLIList<OCCSurface*> surfaces;
+ Surface *curr_surface;
+ OCCSurface *facet_surface;
+ //if this is a sheet body... return 0.0
+
+ //Body *tmp_body = CAST_TO(myBodyPtr->topology_entity(), Body);
+ if( is_sheet() )
+ return 0.0;
+
+ int ii;
+ get_surfaces(surfaces);
+ if (surfaces.size() > 0)
+ {
+ for ( ii = surfaces.size(); ii > 0; ii-- )
+ {
+ curr_surface = surfaces.get_and_step();
+ facet_surface = CAST_TO(curr_surface, OCCSurface);
+ if ( facet_surface == NULL )
+ {
+ PRINT_ERROR("Facet lump has surfaces that aren't facets?");
+ return 1;
+ }
+ facet_surface->get_my_facets(bounding_facets, bounding_points);
+ }
+ }
+ double volume, curr_facet_area, summation = 0.0;
+ CubitFacet *curr_facet;
+ CubitVector normal_of_curr_facet, vector_of_point;
+ CubitPoint *point_1, *point_2, *point_3;
+
+ for( int jj = bounding_facets.size(); jj > 0; jj-- )
+ {
+ curr_facet = bounding_facets.get_and_step();
+ curr_facet_area = curr_facet->area(); // Current facet's area
+
+ normal_of_curr_facet = curr_facet->normal(); // Current facet's normal
+
+ curr_facet->points(point_1, point_2, point_3); // Current facet's points
+
+ vector_of_point = point_1->coordinates(); // One point's vector
+
+ summation += ( double(vector_of_point % normal_of_curr_facet) * curr_facet_area);
+ }
+
+ volume = summation / 3;
+
+ return volume;
+}
+void OCCLump::get_parents_virt(DLIList<TopologyBridge*> &bodies)
+{
+ if (myBodyPtr != NULL )
+ bodies.append_unique(myBodyPtr);
+}
+
+void OCCLump::get_children_virt(DLIList<TopologyBridge*> &shellsms)
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *shell = OCCQueryEngine::occ_to_cgm(M(ii));
+ shellsms.append_unique(shell);
+ }
+}
+
+void OCCLump::get_bodies( DLIList<OCCBody*>& result_list )
+{
+ OCCBody* body = dynamic_cast<OCCBody*>(myBodyPtr);
+ if (body)
+ result_list.append(body);
+}
+
+void OCCLump::get_shells( DLIList<OCCShell*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *shell = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCShell*>(shell));
+ }
+}
+
+void OCCLump::get_surfaces( DLIList<OCCSurface*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ DLIList<OCCSurface*> tmp_list;
+ get_shells(shell_list);
+ shell_list.reset();
+ for ( int i = 0; i < shell_list.size(); i++ )
+ {
+ tmp_list.clean_out();
+ shell_list.next(i)->get_surfaces( tmp_list );
+ result_list.merge_unique( tmp_list );
+ }
+}
+
+
+void OCCLump::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = 0; i < surface_list.size(); i++ )
+ surface_list.next(i)->get_coedges( result_list );
+}
+
+void OCCLump::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ result_list.append_unique(curve);
+ }
+}
+
+
+void OCCLump::add_shell( OCCShell *shell )
+{
+ ShellSM* sm_ptr;
+ sm_ptr = dynamic_cast<ShellSM*>(shell);
+
+ if( sm_ptr )
+ myShells.append( sm_ptr );
+
+ shell->add_lump( this );
+}
+
+void OCCLump::remove_shell( OCCShell *shell )
+{
+ ShellSM* sm_ptr;
+ sm_ptr = dynamic_cast<ShellSM*>(shell);
+
+ if( sm_ptr )
+ myShells.remove( sm_ptr );
+
+ shell->remove_lump();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+void OCCLump::disconnect_all_shells()
+{
+ myShells.reset();
+ for (int i = myShells.size(); i--; )
+ {
+ ShellSM* sm_ptr = myShells.get_and_step();
+ OCCShell* shell = dynamic_cast<OCCShell*>(sm_ptr);
+ if (shell)
+ {
+ assert(shell->get_lump() == this);
+ shell->remove_lump();
+ }
+ }
+ myShells.clean_out();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Calculate centroid
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 05/12/04
+//-------------------------------------------------------------------------
+#include "GfxDebug.hpp"
+CubitStatus OCCLump::mass_properties( CubitVector& centroid, double& volume )
+{
+ int i;
+
+ DLIList<OCCShell*> shells( myShells.size() );
+ CAST_LIST( myShells, shells, OCCShell );
+ assert( myShells.size() == shells.size() );
+
+ DLIList<OCCSurface*> surfaces;
+ DLIList<OCCShell*> surf_shells;
+ get_surfaces( surfaces );
+
+ DLIList<CubitFacet*> facets, surf_facets;
+ DLIList<CubitPoint*> junk;
+ DLIList<CubitSense> senses;
+ for (i = surfaces.size(); i--; )
+ {
+ OCCSurface* surf = surfaces.step_and_get();
+ surf_shells.clean_out();
+ surf->get_shells( surf_shells );
+ surf_shells.intersect( shells );
+ assert( surf_shells.size() );
+ CubitSense sense = surf->get_shell_sense( surf_shells.get() );
+ if (surf_shells.size() == 1 && CUBIT_UNKNOWN != sense)
+ {
+ surf_facets.clean_out();
+ junk.clean_out();
+ surf->get_my_facets( surf_facets, junk );
+ facets += surf_facets;
+
+ for (int j = surf_facets.size(); j--; )
+ senses.append(sense);
+ }
+ }
+
+ const CubitVector p0 = bounding_box().center();
+ CubitVector p1, p2, p3, normal;
+ centroid.set( 0.0, 0.0, 0.0 );
+ volume = 0.0;
+
+ facets.reset();
+ senses.reset();
+ for (i = facets.size(); i--; )
+ {
+ CubitFacet* facet = facets.get_and_step();
+ CubitSense sense = senses.get_and_step();
+ p1 = facet->point(0)->coordinates();
+ p2 = facet->point(1)->coordinates();
+ p3 = facet->point(2)->coordinates();
+ normal = (p3 - p1) * (p2 - p1);
+
+ double two_area = normal.length();
+ if (two_area > CUBIT_RESABS )
+ {
+ if (CUBIT_REVERSED == sense)
+ normal = -normal;
+
+ normal /= two_area;
+
+ double height = normal % (p0 - p1);
+ double vol = two_area * height;
+
+ volume += vol;
+ centroid += vol * (p0 + p1 + p2 + p3);
+ }
+ }
+
+ if (volume > CUBIT_RESABS)
+ centroid /= 4.0 * volume;
+ volume /= 6.0;
+ return CUBIT_SUCCESS;
+}
+
+CubitPointContainment OCCLump::point_containment( const CubitVector &point )
+{
+ CubitPointContainment pc_value;
+ OCCShell *facet_shell;
+
+ int i;
+ for(i=myShells.size(); i--;)
+ {
+ facet_shell = dynamic_cast<OCCShell*>(myShells.get_and_step());
+ pc_value = facet_shell->point_containment( point );
+ if( pc_value == CUBIT_PNT_OUTSIDE )
+ return CUBIT_PNT_OUTSIDE;
+ else if( pc_value == CUBIT_PNT_BOUNDARY )
+ return CUBIT_PNT_BOUNDARY;
+ }
+
+ return CUBIT_PNT_INSIDE;
+
+}
+
+//Determine whether this lump is really a sheet (that is, sheet-body).
+CubitBoolean OCCLump::is_sheet( )
+{
+ OCCShell *facet_shell;
+ int i;
+ //if any of the shells are sheets, the body is assume to be a sheet
+ // for our purposes...
+ for(i=myShells.size(); i--;)
+ {
+ facet_shell = dynamic_cast<OCCShell*>(myShells.get_and_step());
+ if(facet_shell->is_sheet()){
+ return CUBIT_TRUE;
+ }
+ }
+ return CUBIT_FALSE;
+}
+
Property changes on: cgm/trunk/geom/OCC/OCCLump.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCLump.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,195 @@
+//-------------------------------------------------------------------------
+// Filename : OCCLump.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : David White
+//
+// Creation Date : 7/18/2000
+//-------------------------------------------------------------------------
+
+#ifndef FACET_LUMP_HPP
+#define FACET_LUMP_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "Lump.hpp"
+#include "OCCAttribSet.hpp"
+
+#include <TopoDS_Solid.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class TopologyEntity;
+class BodySM;
+class OCCAttrib;
+
+class OCCBody;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+
+// ********** END FORWARD DECLARATIONS **********
+
+class OCCLump : public Lump
+{
+public:
+
+ OCCLump(TopoDS_Solid *theSolid);
+
+ OCCLump(DLIList<ShellSM*> &my_shells,
+ BodySM *body_sm_ptr = NULL);
+ //Pass in a list of shells attached to this lump if you have them.
+ //Also pass in the body that this lump belongs to.
+ virtual ~OCCLump();
+ //- The destructor
+
+ void add_body(BodySM* new_body)
+ {myBodyPtr = new_body;}
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual CubitBox bounding_box() const ;
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ virtual CubitStatus merge( GeometryEntity* /*GEPtr*/)
+ {
+ PRINT_ERROR("BUG: In OCCLump::merge\n"
+ " This function should not be called at all\n"
+ " This is a Bug -- please report it!\n");
+ return CUBIT_FAILURE;
+ }
+
+ virtual TopologyEntity* unmerge(DLIList<RefVolume*>)
+ {
+ PRINT_ERROR( "BUG: In OCCLump::unmerge\n"
+ " This function should not be called\n"
+ " This is a Bug -- please report it!\n" );
+ return (TopologyEntity*)NULL;
+ }
+
+ virtual double measure();
+ //R double
+ //R- The numeric value of the measure (its units depend on the dimension
+ //R- of the RefEntity being "measured")
+ //- A generic geometric extent function.
+ //- Returns volume for Lump, area for Surface, length for Curve and
+ //- 1.0 for Point
+
+ CubitStatus save_attribs( FILE* file_ptr );
+ // Write FactAttribs out to file
+
+ CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
+ // Read FactAttribs from file
+
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#ifdef BOYD14
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+#endif
+ void get_shells ( DLIList<OCCShell *>& shells );
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+#ifdef BOYD14
+ void get_loops ( DLIList<OCCLoop *>& loops );
+#endif
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#ifdef BOYD14
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ inline BodySM* get_body() const { return myBodyPtr; }
+
+ inline void remove_body() {myBodyPtr = 0;}
+
+ void add_shell( OCCShell *shell );
+ void remove_shell( OCCShell *shell );
+
+ void disconnect_all_shells();
+
+ CubitStatus mass_properties( CubitVector& centroid, double& volume );
+
+ CubitPointContainment point_containment( const CubitVector &point );
+
+ //is this lump a sheet
+ CubitBoolean is_sheet( );
+
+protected:
+
+private:
+ DLIList<ShellSM*> myShells;
+ BodySM *myBodyPtr;
+
+ TopoDS_Solid *myTopoDSSolid;
+
+ OCCAttribSet attribSet;
+ //List of OCCAttrib*'s instead of CubitSimpleAttribs
+} ;
+
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCLump.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,4647 @@
+//-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+
+// Filename : OCCModifyEngine.cpp
+//
+// Purpose : ModifyEngine for faceted geometry
+//
+// Special Notes : Modeled after GeometryModifyEngine and AcisModifyEngine.
+//
+// Creator : John Fowler
+//
+// Creation Date : 6/02
+//
+// Owner : John Fowler
+//-------------------------------------------------------------------------
+
+#include "OCCModifyEngine.hpp"
+#include "OCCQueryEngine.hpp"
+
+#include "CubitMessage.hpp"
+#include "CubitDefines.h"
+
+#include "CubitUtil.hpp"
+#include "CubitPoint.hpp"
+#include "CubitPointData.hpp"
+#include "CubitFacet.hpp"
+#include "CubitQuadFacet.hpp"
+#include "CubitFacetData.hpp"
+#include "CubitFacetEdge.hpp"
+#include "CubitFacetEdgeData.hpp"
+#include "GeometryQueryTool.hpp"
+#include "GeometryModifyTool.hpp"
+#include "ChollaSurface.hpp"
+#include "ChollaCurve.hpp"
+#include "ChollaPoint.hpp"
+#include "OCCPoint.hpp"
+#include "OCCCurve.hpp"
+#include "CurveFacetEvalTool.hpp"
+#include "FacetEvalTool.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCLoop.hpp"
+#include "OCCSurface.hpp"
+#include "OCCShell.hpp"
+#include "OCCLump.hpp"
+#include "OCCBody.hpp"
+#include "ChollaEngine.hpp"
+#include "TDGeomFacet.hpp"
+#include "CubitFileIOWrapper.hpp"
+#include "TDFacetBoundaryPoint.hpp"
+#include "Cholla.h"
+#include "Body.hpp"
+#include "GfxDebug.hpp"
+#include "RefFace.hpp"
+#include "FacetDataUtil.hpp"
+#include "FBDataUtil.hpp"
+#include "FBIntersect.hpp"
+#include "IntegerHash.hpp"
+#include "FacetboolInterface.hpp"
+#include "CpuTimer.hpp"
+#include "ProgressTool.hpp"
+#include "AppUtil.hpp"
+#include "SphereEvaluator.hpp"
+#include "CylinderEvaluator.hpp"
+
+OCCModifyEngine* OCCModifyEngine::instance_ = 0;
+
+//===============================================================================
+// Function : OCCModifyEngine
+// Member Type: PUBLIC
+// Description: constructor
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+OCCModifyEngine::OCCModifyEngine()
+{
+// assert( !instance_ );
+
+ // add this modify engine to geometrymodifytool
+ GeometryModifyTool::instance()->add_gme(this);
+}
+
+
+//===============================================================================
+// Function : ~OCCModifyEngine
+// Member Type: PUBLIC
+// Description: destructor
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+OCCModifyEngine::~OCCModifyEngine()
+{
+ instance_ = 0;
+}
+
+//===============================================================================
+// Function : make_Point
+// Member Type: PUBLIC
+// Description: make a geometric entity point
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Point* OCCModifyEngine::make_Point( CubitVector const& /*point*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Point*) NULL;
+}
+
+//===============================================================================
+// Function : make_Curve
+// Member Type: PUBLIC
+// Description: make a curve
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::make_Curve(Curve * /*curve_ptr*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//===============================================================================
+// Function : make_Curve
+// Member Type: PUBLIC
+// Description: make a curve
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::make_Curve( Point const* /*point1_ptr*/,
+ Point const* /*point2_ptr*/,
+ Surface* /*ref_face_ptr*/,
+ const CubitVector * /*third_point*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//===============================================================================
+// Function : make_Curve
+// Member Type: PUBLIC
+// Description: make a curve
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::make_Curve( GeometryType /*curve_type*/,
+ Point const* /*point1_ptr*/,
+ Point const* /*point2_ptr*/,
+ DLIList<CubitVector*>& /*vector_list*/,
+ Surface* /*ref_face_ptr*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//===============================================================================
+// Function : make_Curve
+// Member Type: PUBLIC
+// Description: make a curve
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::make_Curve( GeometryType /*curve_type*/,
+ Point const* /*point1_ptr*/,
+ Point const* /*point2_ptr*/,
+ CubitVector const* /*intermediate_point_ptr*/,
+ CubitSense /*sense*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//===============================================================================
+// Function : make_Surface
+// Member Type: PUBLIC
+// Description: make a surface
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Surface* OCCModifyEngine::make_Surface( Surface * /*old_surface_ptr*/,
+ CubitBoolean /*extended_from*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Surface*) NULL;
+}
+
+//===============================================================================
+// Function : make_Surface
+// Member Type: PUBLIC
+// Description: make a surface
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Surface* OCCModifyEngine::make_Surface( GeometryType /*surface_type*/,
+ DLIList<Curve*>& /*curve_list*/,
+ Surface * /*old_surface_ptr*/,
+ bool /*check_edges*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Surface*) NULL;
+}
+
+//===============================================================================
+// Function : make_Lump
+// Member Type: PUBLIC
+// Description: make a lump
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Lump* OCCModifyEngine::make_Lump( DLIList<Surface*>& /*surface_list*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Lump*) NULL;
+}
+
+//===============================================================================
+// Function : make_BodySM
+// Member Type: PUBLIC
+// Description: make a BodySM
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::make_BodySM( Surface * ) const
+ {return NULL ;}
+
+//===============================================================================
+// Function : make_BodySM
+// Member Type: PUBLIC
+// Description: make a BodySM
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::make_BodySM( DLIList<Lump*>& /*lump_list*/ ) const
+ {return NULL ;}
+
+//===============================================================================
+// Function : fillinedge
+// Member Type: PRIVATE
+// Description: put points on this edge of triangle to be refined
+// Author : John Fowler
+// Date : 11/02
+//===============================================================================
+void OCCModifyEngine::fillinedge(
+ int *edge,
+ int numpointsonanedge,
+ double radius,
+ STD(vector)<CubitPoint *>& points) const
+{
+ int numintervals, i;
+ double xbegin, ybegin, zbegin, xend, yend, zend, xincr, yincr, zincr;
+ double dist;
+ CubitPoint *new_point;
+
+ numintervals = numpointsonanedge - 1;
+ if ( numintervals < 1 ) return;
+ xbegin = points[edge[0]]->x();
+ ybegin = points[edge[0]]->y();
+ zbegin = points[edge[0]]->z();
+ xend = points[edge[numintervals]]->x();
+ yend = points[edge[numintervals]]->y();
+ zend = points[edge[numintervals]]->z();
+ xincr = (xend-xbegin)/(double)(numintervals);
+ yincr = (yend-ybegin)/(double)(numintervals);
+ zincr = (zend-zbegin)/(double)(numintervals);
+ for ( i = 0; i < numintervals - 1; i++ ) {
+ xbegin += xincr;
+ ybegin += yincr;
+ zbegin += zincr;
+
+ dist = sqrt(xbegin*xbegin + ybegin*ybegin + zbegin*zbegin);
+ new_point = (CubitPoint *) new CubitPointData( xbegin*radius/dist, ybegin*radius/dist,
+ zbegin*radius/dist );
+ edge[i+1] = points.size(); // get the point number
+ points.push_back(new_point);
+ }
+
+}
+
+//===============================================================================
+// Function : refinetriangle
+// Member Type: PRIVATE
+// Description: add internal points and make connections for this triangle
+// Author : John Fowler
+// Date : 11/02
+//===============================================================================
+void OCCModifyEngine::refinetriangle(
+ int level,
+ int numpointsonanedge,
+ int *iedge1,
+ int *iedge2,
+ int *iedge3,
+ int isign1,
+ int isign2,
+ int isign3,
+ double radius,
+ STD(vector)<CubitPoint *>& points,
+ DLIList<CubitFacet *>& facet_list) const
+{
+int i, numintervals, icount, j, jcount;
+int ntris;
+int iedge1cnt, iedge2cnt, iedge3cnt;
+
+int increment, trissofar, i1s, i2s, i1e;
+int nverts1, nverts;
+double dlev;
+int *vertnumarray, index, iskip;
+CubitFacet *facet_ptr;
+CubitPoint *new_point;
+ double x1inc, y1inc, z1inc, x2inc, y2inc, z2inc;
+ double xstart, ystart, zstart, xend, yend, zend, dist;
+ double xinternalinc, yinternalinc, zinternalinc;
+
+ numintervals = numpointsonanedge - 1;
+ iedge1cnt = ( isign1 == 1 ) ? 0 : numintervals;
+ iedge2cnt = ( isign2 == 1 ) ? 0 : numintervals;
+ iedge3cnt = ( isign3 == 1 ) ? 0 : numintervals;
+
+ index = points.size();
+ dlev = 1. + (double)level;
+ nverts1 = (int)(0.5*(dlev+1.)*dlev);
+
+ ntris = (level+1)*(level+1);
+ dlev += 1.;
+ nverts = (int)(0.5*(dlev+1.)*dlev);
+ vertnumarray = new int[nverts];
+
+// Put the point numbers for the interior points into vertnumarray.
+ if ( numintervals > 2 ) { // numintervals must be at least 3 to make interior points
+ jcount = 1;
+ icount = 2;
+ for ( i = 2; i < numintervals; i++ ) {
+ icount += 2;
+ for ( j = 0; j < jcount; j++ ) {
+ vertnumarray[icount] = index++;
+ icount += 1;
+ }
+ jcount += 1;
+ }
+ }
+ i = 3;
+
+ iskip = 2;
+ vertnumarray[0] = iedge1[iedge1cnt]; iedge1cnt += isign1;
+ vertnumarray[1] = iedge1[iedge1cnt]; iedge1cnt += isign1;
+ iedge2cnt += isign2;
+ vertnumarray[2] = iedge2[iedge2cnt]; iedge2cnt += isign2;
+
+ while ( i < nverts1 ) {
+ vertnumarray[i] = iedge1[iedge1cnt]; iedge1cnt += isign1;
+ vertnumarray[i+iskip] = iedge2[iedge2cnt]; iedge2cnt += isign2;
+ i += iskip+1;
+ iskip += 1;
+ }
+ for ( i = nverts1; i < nverts; i++ ) {
+ vertnumarray[i] = iedge3[iedge3cnt]; iedge3cnt += isign3;
+ }
+
+
+//! Make the internal points, and put them on the sphere.
+
+ if ( numintervals > 2 ) {
+ int i1first, i1last, i2first, i2last;
+ if ( isign1 == 1 ) {
+ i1first = 0; i1last = numintervals;
+ } else {
+ i1last = 0; i1first = numintervals;
+ }
+ if ( isign2 == 1 ) {
+ i2first = 0; i2last = numintervals;
+ } else {
+ i2last = 0; i2first = numintervals;
+ }
+ x1inc = (points[iedge1[i1last]]->x() - points[iedge1[i1first]]->x())/numintervals;
+ y1inc = (points[iedge1[i1last]]->y() - points[iedge1[i1first]]->y())/numintervals;
+ z1inc = (points[iedge1[i1last]]->z() - points[iedge1[i1first]]->z())/numintervals;
+ x2inc = (points[iedge2[i2last]]->x() - points[iedge2[i2first]]->x())/numintervals;
+ y2inc = (points[iedge2[i2last]]->y() - points[iedge2[i2first]]->y())/numintervals;
+ z2inc = (points[iedge2[i2last]]->z() - points[iedge2[i2first]]->z())/numintervals;
+
+ icount = 2;
+ jcount = 1;
+ for ( i = 2; i < numintervals; i++ ) {
+ xstart = points[iedge1[i1first]]->x() + (double)i*x1inc;
+ ystart = points[iedge1[i1first]]->y() + (double)i*y1inc;
+ zstart = points[iedge1[i1first]]->z() + (double)i*z1inc;
+ xend = points[iedge2[i2first]]->x() + (double)i*x2inc;
+ yend = points[iedge2[i2first]]->y() + (double)i*y2inc;
+ zend = points[iedge2[i2first]]->z() + (double)i*z2inc;
+ xinternalinc = (xend-xstart)/(icount);
+ yinternalinc = (yend-ystart)/(icount);
+ zinternalinc = (zend-zstart)/(icount);
+ for ( j = 0; j < jcount; j++ ) {
+ xstart += xinternalinc;
+ ystart += yinternalinc;
+ zstart += zinternalinc;
+
+ dist = sqrt(xstart*xstart + ystart*ystart + zstart*zstart);
+ new_point = (CubitPoint *) new CubitPointData( xstart*radius/dist,
+ ystart*radius/dist,
+ zstart*radius/dist );
+ points.push_back(new_point);
+ }
+ icount += 1;
+ jcount += 1;
+ }
+
+ }
+
+//! Make the connections.
+ increment = trissofar = 0;
+ i1s = 0;
+ i2s = 1;
+ while ( trissofar < ntris ) {
+ i1e = i1s + increment;
+ while ( i1s < i1e) {
+ facet_ptr = new CubitFacetData( points[vertnumarray[i1s]],
+ points[vertnumarray[i2s]],
+ points[vertnumarray[i2s+1]] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[vertnumarray[i1s]],
+ points[vertnumarray[i2s+1]],
+ points[vertnumarray[i1s+1]] );
+ facet_list.append( facet_ptr );
+ i1s++;
+ i2s++;
+ trissofar += 2;
+ }
+ facet_ptr = new CubitFacetData( points[vertnumarray[i1s]],
+ points[vertnumarray[i2s]],
+ points[vertnumarray[i2s+1]] );
+ facet_list.append( facet_ptr );
+ increment++;
+ trissofar++;
+ i1s++;
+ i2s += 2;
+ }
+ delete [] vertnumarray;
+}
+
+//===============================================================================
+// Function : sphere
+// Member Type: PUBLIC
+// Description: build a sphere with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::sphere(double radius) const
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ double feature_angle;
+ int i, interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr = NULL;
+ STD(vector)<CubitPoint *> points;
+//! We use a vector for the points because when refining the triangles, we will
+//! need fast random access to them. After all of the points have been made,
+//! they will go onto the DLIList point_list. Then the points vector will be
+//! deleted.
+//! xp and yp are the fundamental units for an icosahedron.
+ const double xp = 0.525731112119133606*radius, zp = 0.850650808352039932*radius;
+//! Makes an icosahedron and then refines the triangles as they are made. Number
+//! of levels is given by the variable "level".
+ int level, numpointsonanedge;
+ int *edge[30];
+//! 20 faces in an icosahedron. const int basefacets[][] holds the connections.
+//! 30 edges in an icosahedron. const int edgeendverts[][] holds the edge endpoints.
+/*
+ const int basefacets[20][3] = { {0,1,2},{0,2,3},{3,2,4},{2,5,4},
+ {2,1,5},{5,1,6},{5,6,7},{4,5,7},
+ {4,7,8},{8,7,9},{9,7,6},{9,6,10},
+ {9,10,11},{11,10,0},{0,10,1},{10,6,1},
+ {3,11,0},{3,8,11},{3,4,8},{9,11,8} };
+*/
+ const int edgeendverts[30][2] = { {0,1},{0,2},{0,3},{0,11},{0,10},{1,2},
+ {1,5},{1,6},{1,10},{2,3},{2,4},{2,5},
+ {3,4},{3,8},{3,11},{4,5},{4,7},{4,8},
+ {5,6},{5,7},{6,7},{6,9},{6,10},{7,8},
+ {7,9},{8,9},{8,11},{9,10},{9,11},{10,11} };
+//! triedges[][] holds the three edges for each of the 20 triangles. A minus sign means
+//! that the edge will be traversed backward. To accommodate a zero, one has been added
+//! to the magnitude of the edge. So, for example, the first triangle has edges 0, 5, and 1,
+//! with the last being traversed from end to beginning.
+ const int triedges[20][3] = { {1,2,6},{2,3,10},{-10,13,11},{12,11,-16,},
+ {-6,12,7,},{-7,19,8,},{19,20,21},{16,17,20},
+ {17,18,24,},{-24,26,25},{-25,-22,-21},{-22,28,23},
+ {28,29,30},{-30,-4,-5},{5,1,-9},{-23,-9,-8},
+ {15,-3,-4},{14,15,27},{13,14,18},{29,-26,-27} };
+//! 12 points in an icosahedron. svert[][] holds these.
+ const double svert[12][3] = { {-xp,0.,zp}, {xp,0.,zp}, {0.,zp,xp}, {-zp, xp, 0.},
+ {0.,zp,-xp}, {zp,xp,0.}, {zp,-xp,0.}, {xp,0.,-zp},
+ {-xp,0.,-zp}, {0.,-zp,-xp}, {0.,-zp,xp}, {-zp,-xp,0.} };
+
+ level = 7; // gives a sphere with 642 vertices and 1280 triangles.
+ // Eventually this should be user-selectable.
+ numpointsonanedge = 2 + level;
+
+ for ( i = 0; i < 30; i++ ) { // make the edges
+ edge[i] = new int[numpointsonanedge];
+ edge[i][0] = edgeendverts[i][0];
+ edge[i][numpointsonanedge-1] = edgeendverts[i][1];
+ }
+
+ for ( i = 0; i < 12; i++ ) { // make the icosahedron vertices
+ new_point = (CubitPoint *) new CubitPointData( svert[i][0],svert[i][1],svert[i][2] );
+ points.push_back(new_point);
+ }
+
+ for ( i = 0; i < 30; i++ ) { // put points on the edges
+ fillinedge(edge[i], numpointsonanedge, radius, points);
+ }
+
+ int sign1, sign2, sign3, edg1, edg2, edg3;
+ for ( i = 0; i < 20; i++ ) { // refine the 20 triangles
+ edg1 = ( triedges[i][0] > 0 ) ? triedges[i][0] - 1 : -triedges[i][0] - 1;
+ edg2 = ( triedges[i][1] > 0 ) ? triedges[i][1] - 1 : -triedges[i][1] - 1;
+ edg3 = ( triedges[i][2] > 0 ) ? triedges[i][2] - 1 : -triedges[i][2] - 1;
+//! sign1, etc., says in which direction to traverse an edge
+ sign1 = ( triedges[i][0] > 0 ) ? 1 : -1;
+ sign2 = ( triedges[i][1] > 0 ) ? 1 : -1;
+ sign3 = ( triedges[i][2] > 0 ) ? 1 : -1;
+
+ refinetriangle(level,numpointsonanedge,edge[edg1],edge[edg2],edge[edg3],
+ sign1,sign2,sign3,radius,points,facet_list);
+ }
+
+//! Put the points in point_list and then delete the points vector.
+ for ( unsigned int z = 0; z < points.size(); z++ ) {
+ point_list.append(points[z]);
+ }
+
+ points.clear();
+
+ for ( i = 0; i < 30; i++ ) delete[] edge[i];
+ feature_angle = -1.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ ChollaEngine *cholla_ptr = NULL;
+ OCCModifyEngine *fme = const_cast<OCCModifyEngine *> (this);
+ rv = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if ( rv == CUBIT_SUCCESS )
+ {
+ CubitEvaluatorData **sphere_data;
+
+ set_sphere_eval_data( cholla_ptr, radius, sphere_data );
+
+ finish_facet_Body( cholla_ptr,
+ (const CubitEvaluatorData **)sphere_data,
+ feature_angle,
+ interp_order,
+ body_ptr);
+
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ if ( sphere_data[0] ) delete sphere_data[0];
+ delete sphere_data;
+ }
+ return body_ptr;
+}
+
+void OCCModifyEngine::set_sphere_eval_data
+(
+ ChollaEngine *cholla_ptr,
+ double radius,
+ CubitEvaluatorData **&eval_data ) const
+{
+ eval_data = new CubitEvaluatorData*;
+
+ SphereEvaluatorData *data = new SphereEvaluatorData;
+ data->radius = radius;
+ data->center.set( 0.0, 0.0, 0.0 );
+ eval_data[0] = data;
+}
+
+//===============================================================================
+// Function : brick
+// Member Type: PUBLIC
+// Description: build a brick with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::brick( double wid, double dep, double hi ) const
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ double xmin, xmax, ymin, ymax, zmin, zmax;
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ int i, numpoints, numtris;
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr = NULL;
+ STD(vector)<CubitPoint *> points;
+
+ numpoints = 14;
+ numtris = 24;
+
+ xmin = -0.5*wid;
+ xmax = 0.5*wid;
+ ymin = -0.5*dep;
+ ymax = 0.5*dep;
+ zmin = -0.5*hi;
+ zmax = 0.5*hi;
+
+ new_point = (CubitPoint *) new CubitPointData( xmin,ymin,zmin );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmax,ymin,zmin );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmax,ymin,zmax );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmin,ymin,zmax );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmin,ymax,zmin );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmax,ymax,zmin );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmax,ymax,zmax );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmin,ymax,zmax );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( 0.5*(xmin+xmax),0.5*(ymin+ymax),zmin );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmax,0.5*(ymin+ymax),0.5*(zmin+zmax) );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( 0.5*(xmin+xmax),0.5*(ymin+ymax),zmax );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( xmin,0.5*(ymin+ymax),0.5*(zmin+zmax) );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( 0.5*(xmin+xmax),ymin,0.5*(zmin+zmax) );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( 0.5*(xmin+xmax),ymax,0.5*(zmin+zmax) );
+ points.push_back(new_point);
+
+ for ( i = 0; i < numpoints; i++ ) {
+ point_list.append(points[i]);
+ }
+
+ // bottom face
+ facet_ptr = new CubitFacetData( points[0],points[1], points[12] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[1],points[2], points[12] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[2],points[3], points[12] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[3],points[0], points[12] );
+ // back face
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[1],points[0], points[8] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[5],points[1], points[8] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[4],points[5], points[8] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[0],points[4], points[8] );
+ facet_list.append( facet_ptr );
+ // left face
+ facet_ptr = new CubitFacetData( points[0],points[3], points[11] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[3],points[7], points[11] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[7],points[4], points[11] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[4],points[0], points[11] );
+ facet_list.append( facet_ptr );
+ // top face
+ facet_ptr = new CubitFacetData( points[7],points[6], points[13] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[6],points[5], points[13] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[5],points[4], points[13] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[4],points[7], points[13] );
+ facet_list.append( facet_ptr );
+ // right face
+ facet_ptr = new CubitFacetData( points[1],points[5], points[9] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[5],points[6], points[9] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[6],points[2], points[9] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[2],points[1], points[9] );
+ facet_list.append( facet_ptr );
+ // front face
+ facet_ptr = new CubitFacetData( points[3],points[2], points[10] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[2],points[6], points[10] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[6],points[7], points[10] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[7],points[3], points[10] );
+ facet_list.append( facet_ptr );
+
+ points.clear(); // clear out the points vector since we are through with it.
+
+ feature_angle = 100.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ ChollaEngine *cholla_ptr = NULL;
+ OCCModifyEngine *fme = const_cast<OCCModifyEngine *> (this);
+ rv = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+ if ( rv == CUBIT_SUCCESS )
+ {
+ finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle,
+ interp_order,
+ body_ptr);
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+
+ }
+ return body_ptr;
+}
+
+//===============================================================================
+// Function : finish_facet_Body
+// Member Type: PRIVATE
+// Description: general function for creating a facet-based Body given a closed
+// set of facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::finish_facet_Body( ChollaEngine *&cholla_ptr,
+ const CubitEvaluatorData **eval_data,
+ double feature_angle,
+ int interp_order,
+ BodySM *&bodysm_ptr) const
+{
+ DLIList<Surface *> surface_list;
+ ShellSM *shell_ptr;
+ DLIList<ShellSM*> shell_list;
+ Lump *lump_ptr;
+ DLIList<Lump*> lump_list;
+ CubitStatus rv;
+ DLIList<ChollaSurface *> cholla_surface_list;
+ DLIList<ChollaCurve *> cholla_curve_list;
+ DLIList<ChollaPoint *> cholla_point_list;
+
+ cholla_ptr->get_curves( cholla_curve_list );
+ cholla_ptr->get_surfaces( cholla_surface_list );
+ cholla_ptr->get_points( cholla_point_list );
+
+ CubitBoolean use_feature_angle;
+ if (feature_angle < 0.0)
+ use_feature_angle = CUBIT_FALSE;
+ else
+ use_feature_angle = CUBIT_TRUE;
+
+ GeometryQueryTool *gti = GeometryQueryTool::instance();
+
+ OCCModifyEngine *fme = const_cast<OCCModifyEngine *> (this);
+
+ rv = fme->build_cholla_geometry( eval_data,
+ cholla_surface_list,
+ cholla_curve_list,
+ cholla_point_list,
+ use_feature_angle,
+ feature_angle,
+ interp_order, surface_list );
+
+ if ( surface_list.size() == 0 || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based surfaces.\n");
+ rv = CUBIT_FAILURE;
+ goto end_brick;
+ }
+
+ // make a body out of it
+ rv = fme->make_facet_shell(surface_list,shell_ptr);
+ if ( shell_ptr == NULL || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based shell entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_brick;
+ }
+ //Set the sense for the surfaces (will be cofaces) on this shell.
+ //Assumption: The sense is always forward when creating geom from facets.
+ // (This may not be correct -especially with multiple shells in a body)
+ int ii;
+ OCCShell* facet_shell;
+ facet_shell = CAST_TO( shell_ptr, OCCShell );
+ for( ii = surface_list.size(); ii > 0; ii-- )
+ {
+ Surface* surf = surface_list.get_and_step();
+ OCCSurface* facet_surf = CAST_TO( surf, OCCSurface );
+ facet_surf->set_shell_sense( facet_shell, CUBIT_FORWARD );
+ }
+
+ shell_list.append(shell_ptr);
+ rv = fme->make_facet_lump(shell_list,lump_ptr);
+ if ( lump_ptr == NULL || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based lump entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_brick;
+ }
+ lump_list.append(lump_ptr);
+ rv = fme->make_facet_body(lump_list,bodysm_ptr);
+
+ if ( rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based body entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_brick;
+ }
+
+ PRINT_INFO("Body successfully created.\n");
+ PRINT_INFO(" Number of vertices = %d\n", gti->num_ref_vertices());
+ PRINT_INFO(" Number of edges = %d\n", gti->num_ref_edges());
+ PRINT_INFO(" Number of faces = %d\n", gti->num_ref_faces());
+ PRINT_INFO(" Number of volumes = %d\n", gti->num_ref_volumes());
+ PRINT_INFO(" Number of bodies = %d\n", gti->num_bodies());
+
+ return rv;
+
+end_brick:
+ bodysm_ptr = (BodySM *)NULL;
+ return rv;
+
+}
+
+//===============================================================================
+// Function : brick
+// Member Type: PUBLIC
+// Description: create a brick with facets given center axes and extension
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::brick( const CubitVector &/*center*/,
+ const CubitVector* /*axes[3]*/,
+ const CubitVector &/*extension*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//===============================================================================
+// Function : prism
+// Member Type: PUBLIC
+// Description: create a prism with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::prism( double /*height*/, int /*sides*/, double /*major*/,
+ double /*minor*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//===============================================================================
+// Function : pyramid
+// Member Type: PUBLIC
+// Description: create a pyramid with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::pyramid( double /*height*/, int /*sides*/, double /*major*/,
+ double /*minor*/, double /*top*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//===============================================================================
+// Function : cylinder
+// Member Type: PUBLIC
+// Description: create a cylinder with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::cylinder( double hi, double r1, double r2, double r3 ) const
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ int i, j, numpoints;
+ double feature_angle;
+ int interp_order;
+ CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr = NULL;
+ STD(vector)<CubitPoint *> points;
+ int reslevel; // relative level of resolution
+ int nl; // number of axial divisions
+ int nr; // number of radil divisions
+ double cfac, rinc, linc;
+ double x, y, z;
+ int istart, iend, V3, pend;
+ double zoffset, lpos, rpos, xrad, yrad;
+ double rad_ratio = 1.0;
+
+ reslevel = 4;
+ nl = reslevel;
+ nr = 8*reslevel;
+
+ rinc = 360.0/(double)nr;
+ linc = hi/(double)nl;
+ cfac = CUBIT_PI/180.;
+
+ if ( r3 > 0.0 ) {
+ // Cylinder:
+ numpoints = (nl + 1)*nr + 2;
+ istart = 0; iend = nl+1;
+ V3 = (nl+1)*nr;
+ pend = nl;
+ rad_ratio = r2/r1;
+ } else {
+ // Cone:
+ numpoints = nl*nr + 2;
+ istart = 0; iend = nl;
+ V3 = nl*nr;
+ pend = nl-1;
+ }
+
+ // Make the points.
+
+ zoffset = 0.0;
+ lpos = -0.5*hi;
+ xrad = r1;
+ yrad = r2;
+ for ( i = istart; i < iend; i++ ) {
+ rpos = 10.0;
+ xrad = zoffset*r3/hi + (hi - zoffset)*r1/hi;
+ yrad = zoffset*r3*rad_ratio/hi + (hi - zoffset)*r2/hi;
+ for ( j = 0; j < nr; j++ ) {
+ x = xrad*cos(cfac*rpos);
+ y = yrad*sin(cfac*rpos);
+ z = lpos;
+ new_point = (CubitPoint *) new CubitPointData( x,y,z );
+ points.push_back(new_point);
+ rpos += rinc;
+ }
+ lpos += linc;
+ zoffset += linc;
+ }
+ // Add the two apoint on the axis at the ends.
+ new_point = (CubitPoint *) new CubitPointData( 0.,0.,-0.5*hi );
+ points.push_back(new_point);
+ new_point = (CubitPoint *) new CubitPointData( 0.,0.,0.5*hi );
+ points.push_back(new_point);
+
+ for ( i = 0; i < numpoints; i++ ) {
+ point_list.append(points[i]);
+ }
+
+ // Make the triangles.
+ int vertnum;
+ vertnum = 0;
+ for ( i = 0; i < pend; i++ ) {
+ for ( j = 0; j < nr-1; j++ ) {
+ facet_ptr = new CubitFacetData( points[vertnum+j],points[vertnum+j+1], points[vertnum+j+nr] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[vertnum+j+1],points[vertnum+j+1+nr], points[vertnum+j+nr] );
+ facet_list.append( facet_ptr );
+ }
+ facet_ptr = new CubitFacetData( points[vertnum],points[vertnum+nr], points[vertnum+2*nr-1] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[vertnum+nr-1],points[vertnum], points[vertnum+2*nr-1] );
+ facet_list.append( facet_ptr );
+ vertnum += nr;
+ }
+
+ // Endcap(s)
+ for ( i = 0; i < nr-1; i++ ) { // top cap
+ facet_ptr = new CubitFacetData( points[vertnum+i],points[vertnum+i+1], points[V3+1] );
+ facet_list.append( facet_ptr );
+ }
+ facet_ptr = new CubitFacetData( points[nr-1+vertnum],points[vertnum], points[V3+1] );
+ facet_list.append( facet_ptr );
+
+ for ( i = 0; i < nr-1; i++ ) { // bottom cap
+ facet_ptr = new CubitFacetData( points[i+1],points[i], points[V3] );
+ facet_list.append( facet_ptr );
+ }
+ facet_ptr = new CubitFacetData( points[0],points[nr-1], points[V3] );
+ facet_list.append( facet_ptr );
+
+ points.clear(); // clear out the points vector since we are through with it.
+
+ feature_angle = 135.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ ChollaEngine *cholla_ptr = NULL;
+ OCCModifyEngine *fme = const_cast<OCCModifyEngine *> (this);
+ rv = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+
+ if ( rv == CUBIT_SUCCESS )
+ {
+ CubitEvaluatorData **cyl_data = NULL;
+
+ set_cylinder_eval_data( cholla_ptr, hi, r1, r2, r3, cyl_data );
+ finish_facet_Body( cholla_ptr,
+ (const CubitEvaluatorData**)cyl_data,
+ feature_angle,
+ interp_order,
+ body_ptr);
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ if ( cyl_data )
+ {
+ if ( cyl_data[0] ) delete cyl_data[0];
+ if ( cyl_data[1] ) delete cyl_data[1];
+ if ( cyl_data[2] ) delete cyl_data[2];
+ delete []cyl_data;
+ }
+ }
+ return body_ptr;
+}
+
+void OCCModifyEngine::set_cylinder_eval_data
+(
+ ChollaEngine *cholla_ptr,
+ double height,
+ double base_radius_xdir,
+ double base_radius_ydir,
+ double top_radius,
+ CubitEvaluatorData **&eval_data ) const
+{
+ DLIList<ChollaSurface *> cholla_surface_list;
+ cholla_ptr->get_surfaces( cholla_surface_list );
+ cholla_surface_list.reset();
+
+ eval_data = NULL;
+
+ if ( cholla_surface_list.size() != 3 )
+ {
+ // This cylinder/cone is shaped quite unusually such that the cholla engine
+ // found more than 3 faces on it. This is likely because it is quite smashed
+ // in the minor radius direction. As such, there is not a cylindrical
+ // surface so exit.
+
+ return;
+ }
+
+ eval_data = new CubitEvaluatorData* [3];
+ eval_data[0] =
+ eval_data[1] =
+ eval_data[2] = NULL;
+
+ int isurf;
+ for ( isurf = 0; isurf < cholla_surface_list.size(); isurf++ )
+ {
+ eval_data[isurf] = NULL;
+ DLIList<ChollaCurve*> cholla_curve_list;
+ ChollaSurface *csurf = cholla_surface_list.get_and_step();
+ csurf->get_curves( cholla_curve_list );
+ if ( cholla_curve_list.size() == 2 )
+ {
+ // this is the cylindrical face around the cylinder.
+ CylinderEvaluatorData *data = new CylinderEvaluatorData;
+ data->height = height;
+ data->height = height;
+ data->base_radius_x = base_radius_xdir;
+ data->base_radius_y = base_radius_ydir;
+ data->top_radius = top_radius;
+
+ eval_data[isurf] = data;
+ }
+ }
+}
+
+//===============================================================================
+// Function : torus
+// Member Type: PUBLIC
+// Description: create a torus with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::torus( double r1, double r2 ) const
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ DLIList <CubitFacet *>facet_list;
+ DLIList <CubitPoint *>point_list;
+ CubitPoint *new_point;
+ CubitFacet *facet_ptr;
+ int numpoints;
+ double feature_angle;
+int interp_order;
+CubitBoolean smooth_non_manifold, split_surfaces;
+ BodySM *body_ptr = NULL;
+ STD(vector)<CubitPoint *> points;
+ int reslevel; // relative level of resolution
+ double theta, thetainc, phi, phiinc, x, z, xp, yp, zp, rmajor, rminor;
+ int numtheta, numphi, i, j;
+
+ reslevel = 4;
+ numtheta = 8*reslevel;
+ numphi = 8*reslevel;
+ numpoints = numtheta*numphi;
+ rmajor = r1;
+ rminor = r2;
+ thetainc = 2.*CUBIT_PI/(double)numtheta;
+ phiinc = 2.*CUBIT_PI/(double)numphi;
+ phi = 0.;
+
+// Make the points in the y=0 plane
+ for ( j = 0; j < numphi; j++ ) {
+ theta = 0.;
+ for ( i = 0; i < numtheta; i++ ) {
+ x = rmajor + rminor*cos(theta);
+ z = rminor*sin(theta);
+// Rotate around the z axis
+ xp = x*cos(phi);
+ zp = z;
+ yp = x*sin(phi);
+ new_point = (CubitPoint *) new CubitPointData( xp,yp,zp );
+ points.push_back(new_point);
+ theta += thetainc;
+ }
+ phi += phiinc;
+ }
+
+ for ( i = 0; i < numpoints; i++ ) {
+ point_list.append(points[i]);
+ }
+// Make the triangles
+ int m, k, m2, numtris;
+ m = numtheta;
+ numtris = 0;
+ for ( j = 0; j < numphi; j++ ) {
+ if ( j == numphi-1 ) m2 = 0;
+ else m2 = m;
+ for ( i = 0; i < numtheta; i++ ) {
+ k = (i+1)%numtheta;
+ facet_ptr = new CubitFacetData( points[i+m-numtheta], points[m2+i], points[m2+k] );
+ facet_list.append( facet_ptr );
+ facet_ptr = new CubitFacetData( points[i+m-numtheta], points[m2+k], points[m-numtheta+k] );
+ facet_list.append( facet_ptr );
+ numtris += 2;
+ }
+ m += numtheta;
+ }
+
+ points.clear(); // clear out the points vector since we are through with it.
+
+ feature_angle = 135.0;
+ interp_order = 0;
+ smooth_non_manifold = CUBIT_TRUE;
+ split_surfaces = CUBIT_FALSE;
+
+ ChollaEngine *cholla_ptr = NULL;
+ OCCModifyEngine *fme = const_cast<OCCModifyEngine *> (this);
+ rv = fme->build_cholla_surfaces( facet_list,
+ point_list,
+ feature_angle,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ cholla_ptr );
+
+
+ if ( rv == CUBIT_SUCCESS )
+ {
+ finish_facet_Body( cholla_ptr,
+ NULL,
+ feature_angle,
+ interp_order,
+ body_ptr);
+ if ( cholla_ptr )
+ {
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ }
+ return body_ptr;
+}
+
+//===============================================================================
+// Function : planar_sheet
+// Member Type: PUBLIC
+// Description: create a planar_sheet with facets
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::planar_sheet ( const CubitVector& /*p1*/,
+ const CubitVector& /*p2*/,
+ const CubitVector& /*p3*/,
+ const CubitVector& /*p4*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//===============================================================================
+// Function : copy_body
+// Member Type: PUBLIC
+// Description: copy a facet-based body
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+BodySM* OCCModifyEngine::copy_body ( BodySM* /*bodyPtr*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//===============================================================================
+// Function : subtract
+// Member Type: PUBLIC
+// Description: subtract boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::subtract(DLIList<BodySM*> &tool_body_list,
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_bodies,
+ bool keep_old) const
+{
+
+ CubitStatus status = CUBIT_FAILURE;
+ int i;
+ BodySM *tool_body, *from_body;
+ FacetboolInterface *fbint;
+ CubitFacetboolOp op;
+
+ bool *to_be_deleted = new bool[from_bodies.size()];
+
+ op = CUBIT_FB_SUBTRACTION;
+
+ from_bodies.reset();
+ tool_body_list.reset();
+
+ for ( i = 0; i < from_bodies.size(); i++ ) to_be_deleted[i] = false;
+
+ for ( i = tool_body_list.size(); i > 0; i-- ) {
+ tool_body = tool_body_list.get_and_step();
+ fbint = new FacetboolInterface;
+ status = fbint->dofacetboolean_subtract(tool_body,from_bodies,new_bodies,
+ keep_old,to_be_deleted,op);
+ delete fbint;
+ OCCQueryEngine::instance()->delete_solid_model_entities(tool_body);
+ }
+
+ for ( i = 0; i < from_bodies.size(); i++ ) {
+ from_body = from_bodies.get_and_step();
+ if ( to_be_deleted[i] == true )
+ OCCQueryEngine::instance()->delete_solid_model_entities(from_body);
+ }
+
+ delete [] to_be_deleted;
+
+ return status;
+
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint(BodySM* /*BodyPtr1*/, BodySM* /*BodyPtr2*/,
+ BodySM*& /*newBody1*/, BodySM*& /*newBody2*/,
+ bool /*keep_old*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint(DLIList<BodySM*> &from_body_list ,
+ DLIList<BodySM*> &new_from_body_list,
+ bool keep_old) const
+{
+ CubitStatus success = CUBIT_SUCCESS;
+
+ // total number of imprints to be done
+ const int num_bodies = from_body_list.size();
+// int total_imprints = (num_bodies *(num_bodies-1))/2;
+ int i, j;
+ CubitBox bbox1, bbox2;
+ STD(vector)<BodySM*> bodies_vector;
+ for ( i = 0; i < from_body_list.size(); i++ )
+ bodies_vector.push_back(from_body_list.get_and_step());
+
+ // 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);
+
+ from_body_list.reset();
+ for (i = 0; success && i < num_bodies - 1; i++) {
+ for (j = i + 1; j < num_bodies; j++) {
+ BodySM *Body_Ptr1 = bodies_vector[i];
+ success = OCCQueryEngine::instance()->create_facet_bounding_box(
+ Body_Ptr1,
+ bbox1);
+
+ if (CubitMessage::instance()->Interrupt())
+ {
+ success = CUBIT_FAILURE;
+ break;
+ }
+ BodySM *Body_Ptr2 = bodies_vector[j];
+ success = OCCQueryEngine::instance()->create_facet_bounding_box(
+ Body_Ptr2,
+ bbox2);
+ if (bbox1.overlap(GEOMETRY_RESABS, bbox2)) {
+ FacetboolInterface *FBInt = new FacetboolInterface;
+ BodySM *out_Body_Ptr1, *out_Body_Ptr2;
+ FBInt->dofacetboolean_2bodies_imprint(Body_Ptr1,Body_Ptr2,
+ out_Body_Ptr1,out_Body_Ptr2,
+ keep_old);
+ delete FBInt;
+ instance()->get_gqe()->delete_solid_model_entities(bodies_vector[i]);
+ instance()->get_gqe()->delete_solid_model_entities(bodies_vector[j]);
+ bodies_vector[i] = out_Body_Ptr1;
+ bodies_vector[j] = out_Body_Ptr2;
+ }
+
+ }
+ }
+
+ from_body_list.reset();
+ for ( i = 0; i < from_body_list.size(); i++ ) {
+ new_from_body_list.append(bodies_vector[i]);
+ }
+
+ return success;
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint( DLIList<BodySM*> &body_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old,
+ bool show_messages) const
+{
+ CubitStatus success = CUBIT_SUCCESS;
+// bool delete_attribs =
+ (GeometryModifyTool::instance()->get_new_ids() || keep_old);
+ int i;
+ CubitBox edge_list_bbox, bbox2;
+ const int num_bodies = body_list.size();
+
+ FacetboolInterface *FBInt = new FacetboolInterface;
+
+ FBInt->make_FB_edge_list(ref_edge_list);
+ FBInt->get_edge_list_bbox(edge_list_bbox);
+
+ for (i = 0; success && i < num_bodies; i++) {
+ BodySM *Body_Ptr = body_list.next(i);
+ success = OCCQueryEngine::instance()->create_facet_bounding_box(
+ Body_Ptr,
+ bbox2);
+ if (edge_list_bbox.overlap(GEOMETRY_RESABS, bbox2)) {
+ BodySM *new_body;
+ FBInt->FB_imprint_with_curves(Body_Ptr,new_body,keep_old);
+ new_body_list.append(new_body);
+ }
+ }
+
+ delete FBInt;
+
+ body_list.reset();
+ for ( i = 0; i < body_list.size(); i++ ) {
+ instance()->get_gqe()->delete_solid_model_entities(body_list.get_and_step());
+ }
+
+ return success;
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint( DLIList<Surface*> &/*ref_face_list*/,
+ DLIList<Curve*> &/*ref_edge_list*/,
+ DLIList<BodySM*>& /*new_body_list*/,
+ bool /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint( DLIList<Surface*> &/*surface_list*/,
+ DLIList<DLIList<Curve*>*> &/*curve_lists_list*/,
+ BodySM*& /*new_body*/,
+ bool /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : imprint
+// Member Type: PUBLIC
+// Description: imprint boolean operation on facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint( DLIList<BodySM*> &/*body_list*/,
+ DLIList<CubitVector*> &/*vector_list*/,
+ DLIList<BodySM*>& /*new_body_list*/,
+ bool keep_old /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : imprint_projected_edges
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint_projected_edges( DLIList<Surface*> &/*ref_face_list*/,
+ DLIList<Curve*> &/*ref_edge_list*/,
+ DLIList<BodySM*>& /*new_body_list*/,
+ bool /*keep_old_body*/,
+ bool /*keep_free_edges*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : imprint_projected_edges
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint_projected_edges(DLIList<Surface*> &/*ref_face_list*/,
+ DLIList<BodySM*> &/*body_list*/,
+ DLIList<Curve*> &/*ref_edge_list*/,
+ DLIList<BodySM*>& /*new_body_list*/,
+ bool /*keep_old_body*/,
+ bool /*keep_free_edges*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : project_edges
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::project_edges( DLIList<Surface*> &/*ref_face_list*/,
+ DLIList<Curve*> &/*ref_edge_list_in*/,
+ DLIList<Curve*> &/*ref_edge_list_new*/,
+ bool /*print_error*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+
+//===============================================================================
+// Function : intersect
+// Member Type: PUBLIC
+// Description: intersect boolean operation between facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::intersect(BodySM* tool_body_ptr,
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_bodies,
+ bool keep_old) const
+{
+
+ CubitStatus status = CUBIT_FAILURE;
+ int i;
+ BodySM *from_body, *newBody;
+ FacetboolInterface *fbint;
+ CubitFacetboolOp op;
+ DLIList<BodySM*> bodies;
+
+ op = CUBIT_FB_INTERSECTION;
+ fbint = new FacetboolInterface;
+
+ from_bodies.reset();
+ for ( i = from_bodies.size(); i > 0; i-- ) {
+ bodies.clean_out();
+ bodies.append(tool_body_ptr);
+ from_body = from_bodies.get_and_step();
+ bodies.append(from_body);
+ fbint = new FacetboolInterface;
+ status = fbint->dofacetboolean(bodies,newBody,keep_old,op);
+ delete fbint;
+ if ( status == CUBIT_SUCCESS && newBody) new_bodies.append(newBody);
+ }
+
+ return status;
+
+/*
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+*/
+}
+
+//===============================================================================
+// Function : chop
+// Member Type: PUBLIC
+// Description: chop boolean operation between facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::chop(DLIList<BodySM*>& bodies,
+ DLIList<BodySM*> &intersectBodies,
+ DLIList<BodySM*> &outsideBodies,
+ BodySM*& leftoversBody,
+ bool keep_old ,
+ bool nonreg) const
+{
+//Note: there is never any leftover body.
+FacetboolInterface *fbint;
+CubitFacetboolOp op;
+bool keep_old_this = keep_old;
+CubitStatus status;
+BodySM *body_1, *body_2;
+bool intersection_found;
+BodySM* intersectBody = NULL;
+BodySM* outsideBody = NULL;
+
+ if ( bodies.size() > 2 ) {
+ PRINT_ERROR("Chop not yet supported for more than two bodies.\n");
+ return CUBIT_FAILURE;
+ }
+ body_1 = bodies.get_and_step();
+ body_2 = bodies.get();
+ op = CUBIT_FB_INTERSECTION;
+ fbint = new FacetboolInterface;
+ status = fbint->dofacetboolean_2bodies(body_2,body_1,intersectBody,
+ keep_old_this,intersection_found,op);
+ intersectBodies.append( intersectBody );
+
+ delete fbint;
+ op = CUBIT_FB_SUBTRACTION;
+ fbint = new FacetboolInterface;
+ status = fbint->dofacetboolean_2bodies(body_1,body_2,outsideBody,
+ keep_old_this,intersection_found,op);
+ outsideBodies.append( outsideBody );
+
+ delete fbint;
+
+ if ( keep_old == false ) {
+ OCCQueryEngine::instance()->delete_solid_model_entities(body_1);
+ OCCQueryEngine::instance()->delete_solid_model_entities(body_2);
+ }
+
+ return status;
+
+}
+
+//===============================================================================
+// Function : unite
+// Member Type: PUBLIC
+// Description: unite boolean operation between facet-based bodies
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::unite(DLIList<BodySM*> &bodies,
+ DLIList<BodySM*> &newBodies,
+ bool keep_old) const
+{
+
+CubitStatus status;
+FacetboolInterface *fbint;
+CubitFacetboolOp op;
+
+ op = CUBIT_FB_UNION;
+ fbint = new FacetboolInterface;
+
+ BodySM *newBody = NULL;
+ status = fbint->dofacetboolean(bodies,newBody,keep_old,op);
+
+ newBodies.append( newBody );
+ delete fbint;
+ return status;
+/*
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+*/
+
+}
+
+
+//===============================================================================
+// Function : thicken
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::thicken(DLIList<BodySM*>& /*bodies*/,
+ DLIList<BodySM*>& /*new_bodies*/,
+ double /*depth*/,
+ bool /*both*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+
+//===============================================================================
+// Function : flip_normals
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine :: flip_normals( DLIList<Surface*>& face_list ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+
+//===============================================================================
+// Function : sweep_translational
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine:: sweep_translational(
+ DLIList<GeometryEntity*>& /*ref_ent_list*/,
+ DLIList<BodySM*>& /*result_body_list*/,
+ const CubitVector& /*sweep_vector*/,
+ double /*draft_angle*/,
+ int /*draft_type*/,
+ bool /*switchside*/,
+ bool /*rigid*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : sweep_perpendicular
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine:: sweep_perpendicular(
+ DLIList<GeometryEntity*>& /*ref_ent_list*/,
+ DLIList<BodySM*>& /*result_body_list*/,
+ double /*distance*/,
+ double /*draft_angle*/,
+ int /*draft_type*/,
+ bool /*switchside*/,
+ bool /*rigid*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : sweep_rotational
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine:: sweep_rotational(
+ DLIList<GeometryEntity*>& /*ref_ent_list*/,
+ DLIList<BodySM*>& /*result_body_list*/,
+ const CubitVector& /*point*/,
+ const CubitVector& /*direction*/,
+ double /*angle*/,
+ int /*steps*/,
+ double /*draft_angle*/,
+ int /*draft_type*/,
+ bool /*switchside*/,
+ bool /*make_solid*/,
+ bool /*rigid*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : sweep_along_curve
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::sweep_along_curve(
+ DLIList<GeometryEntity*>& /*ref_ent_list*/,
+ DLIList<BodySM*>& /*result_body_list*/,
+ DLIList<Curve*>& /*ref_edge_list*/,
+ double /*draft_angle*/,
+ int /*draft_type*/,
+ bool /*rigid*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//HEADER- Webcut-related functions
+
+//===============================================================================
+// Function : webcut
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut(DLIList<BodySM*>& webcut_body_list,
+ const CubitVector &v1,
+ const CubitVector &v2,
+ const CubitVector &v3,
+ DLIList<BodySM*>& results_list,
+ bool imprint ) const
+{
+
+CubitBox super_bbox;
+CubitStatus status;
+int i;
+
+ CubitBoolean delete_bodies = (GeometryModifyTool::instance()->get_new_ids() ?
+ CUBIT_FALSE : CUBIT_TRUE);
+
+// Find the bounding box of all of the bodies. This will be used to make
+// the cutting plane.
+
+
+ status = OCCQueryEngine::instance()->create_super_facet_bounding_box(webcut_body_list,
+ super_bbox);
+
+// Find the size of the cutting plane (x,y) in terms of super_bbox.
+ DLIList<CubitVector> intersection_points;
+ FBDataUtil::intersect_plane_with_boundingbox(super_bbox,
+ v1,v2,v3,intersection_points);
+ int numpts = intersection_points.size();;
+ if ( numpts < 3 ) {
+ PRINT_INFO("INFO: Cutting Tool overlaps the original volume,\n"
+ " Or cutting plane does not pass through volume.\n"
+ " The original volume is unaffected.\n" );
+
+ return CUBIT_FAILURE;
+ }
+double xsize, ysize, xcen, ycen, zcen;
+double xmin, ymin, zmin, xmax, ymax, zmax, xx, yy, zz;
+ xmin = ymin = zmin = CUBIT_DBL_MAX;
+ xmax = ymax = zmax = -xmin + 1;
+ xcen = ycen = zcen = 0.0;
+ for ( i = 0; i < numpts; i++ ) {
+ xx = intersection_points[i].x();
+ yy = intersection_points[i].y();
+ zz = intersection_points[i].z();
+
+ xcen += xx;
+ ycen += yy;
+ zcen += zz;
+
+ xmin = (xmin < xx ) ? xmin : xx;
+ ymin = (ymin < yy ) ? ymin : yy;
+ zmin = (zmin < zz ) ? zmin : zz;
+ xmax = (xmax > xx ) ? xmax : xx;
+ ymax = (ymax > yy ) ? ymax : yy;
+ zmax = (zmax > zz ) ? zmax : zz;
+ }
+ xcen /= numpts; ycen /= numpts; zcen /= numpts;
+
+ // Could do this better by rotating the intersection points into the
+ // x-y plane and then getting xsize and ysize. Factor of 1.3 is just
+ // to make sure that the plane extends beyond the bodies.
+ xsize = ysize = 1.3*sqrt( (xmax-xmin)*(xmax-xmin) +
+ (ymax-ymin)*(ymax-ymin) +
+ (zmax-zmin)*(zmax-zmin) );
+ STD(vector)<double> cutter_verts;
+ STD(vector)<int> cutter_connections;
+ int numx, numy;
+ numx = 20;
+ numy = 20;
+ // Make the cutter surface.
+ status = FBDataUtil::FBmake_xy_plane(cutter_verts, cutter_connections,
+ xsize, ysize, numx, numy);
+ CubitVector va, vb;
+ va = v1 - v2;
+ vb = v3 - v2;
+ CubitVector rotate_to;
+
+ rotate_to = vb*va;
+ rotate_to.normalize();
+ CubitVector center_pt(xcen,ycen,zcen);
+ status = FBDataUtil::rotate_FB_object(cutter_verts,rotate_to,center_pt);
+ FacetboolInterface *fbint;
+ bool cutter_is_plane = true;
+ // Now make the facetbool objects for the bodies.
+ webcut_body_list.reset();
+BodySM *body_sm;
+
+ for ( i = webcut_body_list.size(); i > 0; i-- ) {
+ CubitBoolean intersects;
+ body_sm = webcut_body_list.get_and_step();
+ fbint = new FacetboolInterface;
+ status = fbint->webcut_FB(body_sm,cutter_verts,cutter_connections,
+ cutter_is_plane,delete_bodies,
+ intersects,results_list);
+ delete fbint;
+ if ( status == CUBIT_FAILURE )
+ {
+ PRINT_ERROR(" Unable to perform webcut.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ if ( status == CUBIT_SUCCESS && intersects )
+ {
+ instance()->get_gqe()->delete_solid_model_entities(body_sm);
+ }
+ else
+ {
+ PRINT_INFO("INFO: Cutting Tool overlaps the original volume,\n"
+ " Or cutting plane does not pass through volume.\n"
+ " The original volume is unaffected.\n" );
+ }
+ }
+
+ return status;
+
+}
+
+//===============================================================================
+// Function : webcut
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut(DLIList<BodySM*>& /*webcut_body_list*/,
+ BodySM const* /*tool_body*/,
+ DLIList<BodySM*>& /*results_list*/,
+ bool /*imprint*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_across_translate
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_across_translate( DLIList<BodySM*>& /*body_list*/,
+ Surface* /*plane_surf1*/,
+ Surface* /*plane_surf2*/,
+ DLIList<BodySM*>& /*results_list*/,
+ bool /*imprint*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_with_sheet
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_sheet(DLIList<BodySM*> & /*webcut_body_list*/,
+ BodySM * /*sheet_body*/,
+ DLIList<BodySM*> & /*new_bodies*/,
+ bool /*imprint*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_with_extended_surf
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_extended_surf(DLIList<BodySM*> & /*webcut_body_list*/,
+ Surface * /*extend_from*/,
+ DLIList<BodySM*> & /*new_bodies*/,
+ int & /*num_cut*/,
+ bool /*imprint*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_with_cylinder
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_cylinder(DLIList<BodySM*> &webcut_body_list,
+ double radius,
+ const CubitVector &axis,
+ const CubitVector ¢er,
+ DLIList<BodySM*>& results_list,
+ bool imprint )
+{
+
+CubitBox super_bbox;
+CubitStatus status;
+int i;
+CubitVector bodies_center, my_center, diagonal, my_axis;
+
+ CubitBoolean delete_bodies = (GeometryModifyTool::instance()->get_new_ids() ?
+ CUBIT_FALSE : CUBIT_TRUE);
+
+ status = OCCQueryEngine::instance()->create_super_facet_bounding_box(
+ webcut_body_list,super_bbox);
+ STD(vector)<double> cutter_verts;
+ STD(vector)<int> cutter_connections;
+ int nr, nz;
+ double length;
+
+ diagonal = super_bbox.diagonal();
+// length = 2.3*diagonal.length() + 2.0*center.length();
+ bodies_center = super_bbox.center();
+ length = 3.*sqrt((bodies_center.x() - center.x())*(bodies_center.x() - center.x()) +
+ (bodies_center.y() - center.y())*(bodies_center.y() - center.y()) +
+ (bodies_center.z() - center.z())*(bodies_center.z() - center.z()) );
+ length += 3.*diagonal.length();
+ //length = sqrt(length*length + radius*radius);
+ // bodies_center += center;
+
+ nr = 30;
+ nz = 5;
+
+ // Make the cutter surface.
+ status = FBDataUtil::FBmake_cylinder(cutter_verts, cutter_connections,
+ radius, length, nr, nz);
+ my_center = center;
+ my_axis = axis;
+ status = FBDataUtil::rotate_FB_object(cutter_verts,my_axis,my_center);
+
+ FacetboolInterface *fbint;
+ bool cutter_is_plane = false;
+ // Now make the facetbool objects for the bodies.
+ webcut_body_list.reset();
+ BodySM* body_sm;
+ for ( i = webcut_body_list.size(); i > 0; i-- ) {
+ CubitBoolean intersects;
+ body_sm = webcut_body_list.get_and_step();
+ fbint = new FacetboolInterface;
+ status = fbint->webcut_FB(body_sm,cutter_verts,cutter_connections,
+ cutter_is_plane,delete_bodies,
+ intersects,results_list);
+ delete fbint;
+ if ( status == CUBIT_FAILURE )
+ {
+ PRINT_ERROR(" Unable to perform webcut.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ if ( status == CUBIT_SUCCESS && intersects )
+ {
+ instance()->get_gqe()->delete_solid_model_entities(body_sm);
+ }
+ else
+ {
+ PRINT_INFO("INFO: Cutting Tool overlaps the original volume,\n"
+ " Or cutting plane does not pass through volume.\n"
+ " The original volume is unaffected.\n" );
+ }
+ }
+
+ return status;
+
+}
+
+//===============================================================================
+// Function : webcut_with_brick
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_brick(
+ DLIList<BodySM*>& /*webcut_body_list*/,
+ const CubitVector &/*center*/,
+ const CubitVector* /*axes[3]*/,
+ const CubitVector &/*extension*/,
+ DLIList<BodySM*> &/*results_list*/,
+ bool /*imprint*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_with_planar_sheet
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_planar_sheet(
+ DLIList<BodySM*>& /*webcut_body_list*/,
+ const CubitVector &/*center*/,
+ const CubitVector* /*axes[2]*/,
+ double /*width*/,
+ double /*height*/,
+ DLIList<BodySM*> &/*results_list*/,
+ bool /*imprint*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : webcut_with_curve_loop
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::webcut_with_curve_loop(
+ DLIList<BodySM*> &/*webcut_body_list*/,
+ DLIList<Curve*> &/*ref_edge_list*/,
+ DLIList<BodySM*>& /*results_list*/,
+ bool /*imprint*/)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : section
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::section( DLIList<BodySM*> &/*section_body_list*/,
+ const CubitVector &/*point_1*/,
+ const CubitVector &/*point_2*/,
+ const CubitVector &/*point_3*/,
+ DLIList<BodySM*>& /*new_body_list*/,
+ bool /*keep_normal_side*/,
+ bool /*keep_old*/,
+ bool /*keep_both_sides*/)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : split_body
+// Member Type: PUBLIC
+// Description: Splits multiple lumps in one body into separate bodies
+// Author : Corey Ernst
+// Date : 08/04
+//===============================================================================
+CubitStatus OCCModifyEngine::split_body( BodySM *body_ptr,
+ DLIList<BodySM*> &new_bodies )
+{
+ //get the all lumps of input body
+ DLIList<Lump*> lumps;
+ body_ptr->lumps( lumps );
+
+ if( lumps.size() == 1 )
+ {
+ new_bodies.append( body_ptr );
+ return CUBIT_SUCCESS;
+ }
+
+ //for each lump except one first one, create a new body
+ DLIList<Lump*> single_lump;
+ lumps.reset();
+ lumps.step();
+ int i;
+ OCCBody *tmp_facet_body = static_cast<OCCBody*>( body_ptr );
+ for( i=lumps.size()-1; i--; )
+ {
+ BodySM *bodysm_ptr;
+ single_lump.clean_out();
+ tmp_facet_body->remove_lump( static_cast<OCCLump*>(lumps.get()));
+ single_lump.append( lumps.get_and_step() );
+ make_facet_body(single_lump, bodysm_ptr);
+ if( bodysm_ptr )
+ new_bodies.append(bodysm_ptr);
+ }
+
+ new_bodies.append( body_ptr );
+
+ return CUBIT_SUCCESS;
+}
+
+
+//===============================================================================
+// Function : reverse_body
+// Member Type: PUBLIC
+// Description: Turn body inside-out
+// Author : Jason Kraftcheck
+// Date : 05/25/04
+//===============================================================================
+CubitStatus OCCModifyEngine::reverse_body( BodySM* body_ptr )
+{
+ OCCBody* body = dynamic_cast<OCCBody*>(body_ptr);
+ if (0 == body)
+ {
+ PRINT_ERROR("Non-facet body in FME::reverse.\n");
+ return CUBIT_FAILURE;
+ }
+
+ // Flip CoFace senses
+ DLIList<OCCShell*> shells;
+ body->get_shells( shells );
+ while (shells.size())
+ shells.pop()->reverse();
+
+ return CUBIT_SUCCESS;
+}
+
+
+
+//===============================================================================
+// Function : split_periodic
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::split_periodic( BodySM * /*body_ptr*/,
+ BodySM *& /*new_body*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : regularize_body
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::regularize_body( BodySM * /*body_ptr*/,
+ BodySM *& /*new_body_ptr*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : regularize_refentity
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::regularize_entity( GeometryEntity * /*old_entity_ptr*/,
+ BodySM *& /*new_body_ptr*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : offset_curves
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::offset_curves( DLIList<Curve*>& /*ref_edge_list*/,
+ DLIList<Curve*>&,
+ double /*offset_distance*/,
+ const CubitVector& /*offset_direction*/,
+ int /*gap_type*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : trim_curve
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::trim_curve( Curve* /*trim_curve*/,
+ const CubitVector& /*trim_vector*/,
+ const CubitVector& /*keep_vector*/,
+ bool )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return 0;
+}
+
+//===============================================================================
+// Function : create_body_from_surfs
+// Member Type: PUBLIC
+// Description:
+// Author : Steve Owen
+// Date : 9/11/03
+//===============================================================================
+CubitStatus OCCModifyEngine::create_body_from_surfs(DLIList<Surface*> & ref_face_list,
+ BodySM *& new_body,
+ bool keep_old,
+ bool heal) const
+{
+ // get the facets from the faces
+
+ int ii;
+ Surface *surf_ptr;
+ OCCSurface *fsurf_ptr;
+ DLIList<CubitFacet *> facet_list;
+ DLIList<CubitPoint *> point_list;
+#ifdef BOYD17
+ DLIList<CubitFacetEdge *>edge_list;
+#endif
+
+ if (heal)
+ {
+ PRINT_WARNING("\"heal\" option for facet-based geometry is not supported.\n");
+ }
+
+ ref_face_list.reset();
+ for(ii=0; ii<ref_face_list.size(); ii++)
+ {
+ surf_ptr = ref_face_list.get_and_step();
+ fsurf_ptr = dynamic_cast<OCCSurface *>(surf_ptr);
+ assert(fsurf_ptr != NULL);
+ if (fsurf_ptr == NULL)
+ return CUBIT_FAILURE;
+ point_list.clean_out();
+ fsurf_ptr->get_my_facets( facet_list, point_list );
+ }
+
+ // copy the facets
+
+ DLIList<CubitFacet *> new_facet_list;
+ DLIList<CubitPoint *> new_point_list;
+ DLIList<CubitFacetEdge *> new_edge_list;
+ FacetDataUtil::copy_facets( facet_list, new_facet_list, new_point_list, new_edge_list );
+
+ // generate new geometry
+
+ const char *file_name = NULL;
+ CubitBoolean use_feature_angle = CUBIT_FALSE;
+ double feature_angle = 0.0;
+ int interp_order = 0;
+ double tol=0.0;
+ CubitBoolean smooth_non_manifold = CUBIT_FALSE;
+ CubitBoolean split_surfaces = CUBIT_FALSE;
+ CubitBoolean stitch = CUBIT_TRUE;
+ CubitBoolean improve = CUBIT_TRUE;
+ DLIList <CubitQuadFacet *> quad_facet_list;
+ DLIList<Surface *> surface_list;
+ FacetFileFormat file_format = FROM_FACET_LIST;
+ CubitStatus rv =
+ OCCQueryEngine::instance()->import_facets( file_name,
+ use_feature_angle,
+ feature_angle,
+ tol,
+ interp_order,
+ smooth_non_manifold,
+ split_surfaces,
+ stitch,
+ improve,
+ quad_facet_list,
+ new_facet_list,
+ surface_list,
+ file_format );
+
+ if (rv == CUBIT_SUCCESS)
+ {
+ surf_ptr = surface_list.get();
+ new_body = surf_ptr->bodysm();
+
+ // delete the old model
+
+ if (!keep_old)
+ {
+ DLIList<BodySM*> mybody_list;
+ DLIList<BodySM*> body_list;
+ for(ii=0; ii<ref_face_list.size(); ii++)
+ {
+ mybody_list.clean_out();
+ surf_ptr = ref_face_list.get_and_step();
+ surf_ptr->bodysms(mybody_list);
+ if (mybody_list.size() == 1)
+ {
+ body_list.append_unique( mybody_list.get() );
+ }
+ }
+ if (body_list.size() > 0)
+ {
+ OCCQueryEngine::instance()->delete_solid_model_entities(body_list);
+ //GeometryQueryTool::instance()->delete_Body( body_list );
+ }
+ }
+ }
+ else
+ {
+ new_body = NULL;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//===============================================================================
+// Function : create_arc_three
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::create_arc_three( Point* /*ref_vertex1*/,
+ Point* /*ref_vertex2*/,
+ Point* /*ref_vertex3*/,
+ bool /*full*/ )
+{ return NULL;
+
+}
+
+//===============================================================================
+// Function : create_arc_three
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::create_arc_three( Curve* /*ref_edge1*/,
+ Curve* /*ref_edge2*/,
+ Curve* /*ref_edge3*/,
+ bool /*full*/ )
+{ return NULL;
+}
+
+//===============================================================================
+// Function : create_arc_center_edge
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+Curve* OCCModifyEngine::create_arc_center_edge( Point* /*ref_vertex1*/,
+ Point* /*ref_vertex2*/,
+ Point* /*ref_vertex3*/,
+ const CubitVector& /*normal*/,
+ double /*radius*/,
+ bool /*full*/ )
+{
+ return NULL;
+}
+
+CubitStatus
+OCCModifyEngine::create_curve_combine( DLIList<Curve*>& curve_list,
+ Curve *&new_curve_ptr )
+{
+ PRINT_ERROR("Curve combine is not implemented for facet based models\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : get_gqe
+// Member Type: PUBLIC
+// Description: get the facet geometry query engince instance pointer
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+GeometryQueryEngine *OCCModifyEngine::get_gqe()
+{
+ return OCCQueryEngine::instance();
+}
+
+//===============================================================================
+// Function : is_modify_engine
+// Member Type: PUBLIC
+// Description: return CUBIT_TRUE if the tb_ptr belongs to this modify engine
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitBoolean OCCModifyEngine::is_modify_engine(const TopologyBridge *tb_ptr) const
+{
+ return tb_ptr->get_geometry_query_engine() == OCCQueryEngine::instance();
+}
+
+//===============================================================================
+// Function : get_offset_intersections
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::get_offset_intersections( Curve* /*ref_edge1*/,
+ Curve* /*ref_edge2*/,
+ DLIList<CubitVector*>& /*intersection_list*/,
+ double /*offset*/,
+ CubitBoolean /*ext_first*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : get_offset_intersections
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::get_offset_intersections( Curve* /*ref_edge_ptr*/,
+ Surface* /*ref_face_ptr*/,
+ DLIList<CubitVector*> & /*intersection_list*/,
+ double /*offset*/,
+ CubitBoolean /*ext_surf*/ )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : surface_intersection
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::surface_intersection( Surface * /*surface1_ptr*/,
+ Surface * /*surface2_ptr*/,
+ DLIList<Curve*> &/*inter_graph*/,
+ const double /*tol*/) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : get_mid_plane
+// Member Type: PUBLIC
+// Description:
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::get_mid_plane( const CubitVector & /*point_1*/,
+ const CubitVector & /*point_2*/,
+ const CubitVector & /*point_3*/,
+ BodySM * /*body_to_trim_to*/,
+ BodySM *& /*midplane_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_chamfer
+// Member Type: PUBLIC
+// Description: Chamfer curves on solid bodies. The left and right offsets are
+// with respect to the curve direction. If the given right offset
+// is negative, the left offset is used. Users can preview to
+// clarify the meaning of left and right.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_chamfer( DLIList<Curve*> & /*curve_list*/,
+ double /*left_offset*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ double /*right_offset*/,
+ CubitBoolean /*keep_old_body*/,
+ CubitBoolean /*preview*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_chamfer
+// Member Type: PUBLIC
+// Description: Chamfer vertices on solid or sheet bodies. On a solid body
+// there can be up to 3 offsets; on a sheet body up to 2 offsets.
+// The offsets are in the direction of the supplied edges. If
+// multiple vertices are supplied, only one offset value is
+// allowed and the edges are not used.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus
+OCCModifyEngine::tweak_chamfer( DLIList<Point*> & /*point_list*/,
+ double /*offset1*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ Curve * /*edge1*/,
+ double /*offset2*/,
+ Curve * /*edge2*/,
+ double /*offset3*/,
+ Curve * /*edge3*/,
+ CubitBoolean /*keep_old_body*/,
+ CubitBoolean /*preview*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_fillet
+// Member Type: PUBLIC
+// Description: Create a round fillet (or blend) at the given curves on solid
+// bodies.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_fillet( DLIList<Curve*> & /*curve_list*/,
+ double /*radius*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/,
+ CubitBoolean /*preview*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_fillet
+// Member Type: PUBLIC
+// Description: Create a round fillet (or blend) at the given curves on a solid
+// body. The fillet has a variable radius from the start to the
+// end of the curve.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_fillet( Curve * /*curve_ptr*/,
+ double /*start_radius*/,
+ double /*end_radius*/,
+ BodySM *& /*new_bodysm_ptr*/,
+ CubitBoolean /*keep_old_body*/,
+ CubitBoolean /*preview*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_fillet
+// Member Type: PUBLIC
+// Description: Create a round fillet (or blend) at the given vertices on sheet
+// bodies.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus
+OCCModifyEngine::tweak_fillet( DLIList<Point*> & /*ref_vertex_list*/,
+ double /*radius*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/,
+ CubitBoolean /*preview*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_move
+// Member Type: PUBLIC
+// Description: Tweak specified faces of a volume or volumes along a vector.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_move( DLIList<Surface*> & /*surface_list*/,
+ const CubitVector & /*delta*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_move
+// Member Type: PUBLIC
+// Description: Tweak specified curves of a sheet body along a vector.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_move( DLIList<Curve*> & /*curve_list*/,
+ const CubitVector & /*delta*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_offset
+// Member Type: PUBLIC
+// Description: Tweak specified faces of a volume or volumes by offsetting
+// those faces by the offset distance.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_offset( DLIList<Surface*> & /*surface_list*/,
+ double /*offset_distance*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_offset
+// Member Type: PUBLIC
+// Description: Tweak specified curves of a sheet body or bodies by offsetting
+// those curves by the offset distance.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_offset( DLIList<Curve*> & /*curve_list*/,
+ double /*offset_distance*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_remove
+// Member Type: PUBLIC
+// Description: Function to remove surfaces from a body and then extend the
+// remaining surfaces to fill the gap or hole.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_remove( DLIList<Surface*> & /*surface_list*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*extend_adjoining*/,
+ CubitBoolean /*keep_surface*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_remove
+// Member Type: PUBLIC
+// Description: Function to remove curves from a sheet body and then extend the
+// remaining curves or fill the gap or hole.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_remove( DLIList<Curve*> & /*curve_list*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_target
+// Member Type: PUBLIC
+// Description: Tweak specified faces of a volume or volumes up to a target
+// surface.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_target( DLIList<Surface*> & /*surface_list*/,
+ Surface * /*target_surf_ptr*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*reverse_flg*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_target
+// Member Type: PUBLIC
+// Description: Tweak specified edges of a surface or set of surfaces (in sheet
+// bodies) up to a target surface.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_target( DLIList<Curve*> & /*curve_list*/,
+ Surface * /*target_surf_ptr*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//=============================================================================
+// Function : tweak_target
+// Member Type: PUBLIC
+// Description: Tweak specified edges of a sheet body or bodies up to a target
+// curve that is part of a sheet body. The target is a surface
+// created by thickening the owning surface of the target curve.
+// Author :
+// Date :
+//=============================================================================
+CubitStatus OCCModifyEngine::tweak_target( DLIList<Curve*> & /*curve_list*/,
+ Curve * /*target_curve_ptr*/,
+ DLIList<BodySM*> & /*new_bodysm_list*/,
+ CubitBoolean /*keep_old_body*/ ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a net surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_net_surface( DLIList<Surface*>& /*ref_face_list*/,
+ BodySM *& /*new_body*/,
+ DLIList<DLIList<CubitVector*>*> & /*vec_lists_u*/,
+ DLIList<DLIList<CubitVector*>*> & /*vec_lists_v*/,
+ double /*net_tol*/,
+ CubitBoolean /*heal*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a net surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_net_surface( DLIList<Curve*>& /*u_curves*/,
+ DLIList<Curve*>& /*v_curves*/,
+ BodySM *& /*new_body*/,
+ double /*net_tol*/,
+ CubitBoolean /*heal*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates an offset surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_offset_surface( Surface* /*ref_face_ptr*/,
+ BodySM*& /*new_body*/,
+ double /*offset_distance*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates an offset body.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_offset_body( BodySM* body_ptr,
+ BodySM*& new_bodysm,
+ double offset_distance ) const
+{
+ return OCCModifyEngine::instance()->
+ create_shell_offset( body_ptr, new_bodysm, offset_distance );
+}
+
+//================================================================================
+// Description: Creates a skin surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_skin_surface( DLIList<Curve*>& /*curves*/,
+ BodySM*& /*new_body*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a body from lofting surfaces.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::loft_surfaces( Surface * /*face1*/,
+ const double & /*takeoff1*/,
+ Surface * /*face2*/,
+ const double & /*takeoff2*/,
+ BodySM*& /*new_body*/,
+ CubitBoolean /*arc_length_option*/,
+ CubitBoolean /*twist_option*/,
+ CubitBoolean /*align_direction*/,
+ CubitBoolean /*perpendicular*/,
+ CubitBoolean /*simplify_option*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a body by lofting surfaces between bodies.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::loft_surfaces_to_body( Surface * /*face1*/,
+ const double & /*takeoff1*/,
+ Surface * /*face2*/,
+ const double & /*takeoff2*/,
+ BodySM*& /*new_body*/,
+ CubitBoolean /*arc_length_option*/,
+ CubitBoolean /*twist_option*/,
+ CubitBoolean /*align_direction*/,
+ CubitBoolean /*perpendicular*/,
+ CubitBoolean /*simplify_option*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_surface( DLIList<CubitVector*>& /*vec_list*/,
+ BodySM *& /*new_body*/,
+ Surface * /*ref_face_ptr*/,
+ CubitBoolean /*project_points*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Creates a weld surface.
+// Author : Tyronne Lim
+// Date : 08/18/03
+//================================================================================
+CubitStatus OCCModifyEngine::create_weld_surface( CubitVector & /*root*/,
+ Surface * /*ref_face1*/,
+ double /*leg1*/,
+ Surface * /*ref_face2*/,
+ double /*leg2*/,
+ BodySM *& /*new_body*/ ) const
+{
+ PRINT_ERROR("Function not implemented in this engine.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Facet-based geometry entities
+// Methods for building specific facet-based geometry entities
+//================================================================================
+
+//================================================================================
+// Function : make_facet_point
+// Member Type: PUBLIC
+// Description: create a new facet point given a pointer to the
+// associated CubitPoint
+// Author : sjowen
+// Date : 12/28/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_point( CubitPoint *thePoint,
+ Point *&new_point_ptr )
+{
+ //We don't know in this function what to attach it to, so do that later.
+ DLIList<Curve*> curves;
+
+ OCCPoint *new_facet_point = new OCCPoint( thePoint, curves );
+
+ new_point_ptr = (Point*) new_facet_point;
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_point
+// Member Type: PUBLIC
+// Description: create a new facet point given its location
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_point( CubitVector &location,
+ Point *&new_point_ptr )
+{
+ //We don't know in this function what to attach it to, so do that later.
+ DLIList<Curve*> curves;
+
+ OCCPoint *new_facet_point = new OCCPoint( location, curves );
+
+ new_point_ptr = (Point*) new_facet_point;
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_curve
+// Member Type: PUBLIC
+// Description: create a new facet curve
+// (Assumes the curve will have an associated parent surface.
+// Evaluations will be done on the surface -- uses the same
+// order evaluations as the surface)
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_curve( Point *start_ptr,
+ Point *end_ptr,
+ Curve *&new_curve_ptr,
+ CurveFacetEvalTool *eval_tool_ptr)
+{
+
+ //We don't know in this function what to attach it to, so do that later.
+ DLIList<CoEdgeSM*> coedgesms;
+
+ OCCCurve *new_facet_curv = new OCCCurve( eval_tool_ptr, start_ptr,
+ end_ptr, coedgesms );
+ new_curve_ptr = (Curve*) new_facet_curv;
+
+ OCCPoint *facet_start_point = CAST_TO( start_ptr, OCCPoint );
+ OCCPoint *facet_end_point = CAST_TO( end_ptr, OCCPoint );
+ facet_start_point->add_curve( new_curve_ptr );
+ facet_end_point->add_curve( new_curve_ptr );
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_curve
+// Member Type: PUBLIC
+// Description: create a new facet curve given its edge facets
+// (this can be used for generating a facet curve representation
+// that does not have a parent surface associated -- currently
+// only linear evaluations are possible)
+// Author : sjowen
+// Date : 2/17/01
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_curve(
+ Point *start_ptr, // endpoints on the curve
+ Point *end_ptr,
+ DLIList<CubitFacetEdge*> &edge_list, // the ordered facet edges on this curve
+ DLIList<CubitPoint*> &point_list, // the ordered points on this curve
+ Curve *&new_curve_ptr, // return the new curve pointer
+ CurveFacetEvalTool *curve_facet_tool )
+{
+ if ( curve_facet_tool == NULL )
+ {
+ curve_facet_tool = new CurveFacetEvalTool;
+ CubitStatus status = curve_facet_tool->initialize( edge_list, point_list );
+ if ( status != CUBIT_SUCCESS )
+ {
+ return status;
+ }
+ }
+ if (!curve_facet_tool)
+ return CUBIT_FAILURE;
+
+ //We don't know in this function what to attach it to, so do that later.
+ DLIList<CoEdgeSM*> coedgesms;
+
+ OCCCurve *new_facet_curv = new OCCCurve( curve_facet_tool, start_ptr,
+ end_ptr, coedgesms );
+ new_curve_ptr = (Curve*) new_facet_curv;
+
+ OCCPoint *facet_start_point = CAST_TO( start_ptr, OCCPoint );
+ OCCPoint *facet_end_point = CAST_TO( end_ptr, OCCPoint );
+ facet_start_point->add_curve( new_curve_ptr );
+ facet_end_point->add_curve( new_curve_ptr );
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_coedge
+// Member Type: PUBLIC
+// Description: create a new facet coedge
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_coedge( Curve *curv_ptr,
+ CubitSense sense,
+ CoEdgeSM *&new_coedge_ptr )
+{
+ //We don't know in this function what to attach it to, so do that later.
+ LoopSM *loop_ptr = NULL;
+
+ //Now create a new loop.
+
+ OCCCoEdge *new_facet_coedge = new OCCCoEdge(curv_ptr, loop_ptr, sense);
+
+ new_coedge_ptr = (CoEdgeSM*) new_facet_coedge;
+
+ OCCCurve *facet_curve = CAST_TO( curv_ptr, OCCCurve );
+ facet_curve->add_coedge( new_coedge_ptr );
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_loop
+// Member Type: PUBLIC
+// Description: create a new facet loop
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_loop( DLIList<CoEdgeSM*> &coedge_list,
+ LoopSM *&new_loop_ptr )
+{
+ //We don't know in this function what to attach it to, so do that later.
+ Surface *surf_ptr = NULL;
+
+ //Now create a new loop.
+
+ OCCLoop *new_facet_loop = new OCCLoop(surf_ptr, coedge_list );
+
+ new_loop_ptr = (LoopSM*) new_facet_loop;
+ int ii;
+ for ( ii = coedge_list.size(); ii > 0; ii-- )
+ {
+ CoEdgeSM* coedge_ptr = coedge_list.get_and_step();
+ OCCCoEdge *facet_coedge = CAST_TO(coedge_ptr, OCCCoEdge);
+ facet_coedge->add_loop(new_loop_ptr);
+ }
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_surface
+// Member Type: PUBLIC
+// Description: create a new facet surface from Quad facets
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_surface(
+ DLIList<CubitQuadFacet*> &quad_facet_list,
+ DLIList<CubitPoint*> &point_list,
+ DLIList<LoopSM*> &my_loops,
+ int interp_order,
+ double min_dot,
+ Surface *&new_surface_ptr)
+{
+ CubitQuadFacet *qfacet;
+ DLIList<CubitFacet*> facet_list;
+ int ii;
+
+ quad_facet_list.reset();
+ for (ii=0; ii<quad_facet_list.size(); ii++)
+ {
+ qfacet = quad_facet_list.get_and_step();
+ facet_list.append( qfacet->get_tri_facet( 0 ) );
+ facet_list.append( qfacet->get_tri_facet( 1 ) );
+ }
+ return make_facet_surface( NULL, facet_list, point_list, my_loops,
+ interp_order, min_dot, new_surface_ptr );
+}
+
+//================================================================================
+// Function : make_facet_surface
+// Member Type: PUBLIC
+// Description: create a new facet surface
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_surface( const CubitEvaluatorData *eval_data,
+ DLIList<CubitFacet*> &facet_list,
+ DLIList<CubitPoint*> &point_list,
+ DLIList<LoopSM*> &my_loops,
+ int interp_order,
+ double min_dot,
+ Surface *&new_surface_ptr,
+ CubitBoolean use_point_addresses,
+ FacetEvalTool *facet_eval_tool)
+{
+ //Create a new surface given the facets and point list.
+ if (facet_eval_tool == NULL)
+ {
+ facet_eval_tool = new FacetEvalTool(facet_list, point_list,
+ interp_order, min_dot );
+ }
+
+ //We don't know in this function what to attach it to, so do that later.
+ DLIList<ShellSM*> shellsms;
+ OCCSurface *new_facet_surf;
+
+ //Now create a new surface.
+ if ( eval_data && eval_data->ask_type() == SPHERE_SURFACE_TYPE )
+ {
+ new_facet_surf = new OCCSurface( (const SphereEvaluatorData*)eval_data,
+ facet_eval_tool,
+ shellsms,
+ my_loops );
+ }
+ else if ( eval_data && eval_data->ask_type() == CONE_SURFACE_TYPE )
+ {
+ new_facet_surf = new OCCSurface( (const CylinderEvaluatorData*)eval_data,
+ facet_eval_tool,
+ shellsms,
+ my_loops );
+ }
+ else
+ {
+ new_facet_surf = new OCCSurface( facet_eval_tool,
+ shellsms, my_loops );
+ }
+
+ new_surface_ptr = (Surface*) new_facet_surf;
+ int ii;
+ for ( ii = my_loops.size(); ii > 0; ii-- )
+ {
+ LoopSM* loop_ptr = my_loops.get_and_step();
+ OCCLoop *facet_loop = CAST_TO(loop_ptr, OCCLoop);
+ facet_loop->add_surface(new_surface_ptr);
+#ifdef BOYD17
+ DLIList<CoEdgeSM*> coedges;
+#endif
+ }
+
+ // generate the curve facet evaluaion tools for each of the curves on this
+ // surface - they are based on the surface evaluation tool
+
+ DLIList<OCCCoEdge*> coedges;
+ new_facet_surf->get_coedges( coedges );
+ for (ii=0; ii<coedges.size(); ii++)
+ {
+ OCCCoEdge *coedgesm_ptr = coedges.get_and_step();
+ DLIList<OCCCurve*> curve_list;
+ coedgesm_ptr->get_curves( curve_list );
+ OCCCurve *facet_curve =curve_list.get();
+ CurveFacetEvalTool *eval_tool = facet_curve->get_eval_tool();
+ if (eval_tool == NULL)
+ {
+ Point *start_point = facet_curve->start_point();
+ Point *end_point = facet_curve->end_point();
+ OCCCoEdge *facet_coedge_ptr = CAST_TO( coedgesm_ptr, OCCCoEdge );
+ CubitSense sense = facet_coedge_ptr->get_sense();
+
+ CubitStatus status = CUBIT_SUCCESS;
+ eval_tool = new CurveFacetEvalTool;
+ if (!use_point_addresses)
+ {
+ CubitVector temp_vec1 = start_point->coordinates();
+ CubitVector temp_vec2 = end_point->coordinates();
+ status = eval_tool->initialize( facet_eval_tool,
+ temp_vec1,
+ temp_vec2,
+ sense );
+ if ( status != CUBIT_SUCCESS )
+ {
+ return status;
+ }
+ }
+ else
+ {
+ OCCPoint *start_facet_pt_ptr = CAST_TO( start_point, OCCPoint );
+ OCCPoint *end_facet_pt_ptr = CAST_TO( end_point, OCCPoint );
+ CubitPoint *start_pt = start_facet_pt_ptr->get_cubit_point();
+ CubitPoint *end_pt = end_facet_pt_ptr->get_cubit_point();
+ status = eval_tool->initialize( facet_eval_tool,
+ start_pt,
+ end_pt,
+ sense );
+ if ( status != CUBIT_SUCCESS )
+ {
+ return status;
+ }
+ }
+ if( !eval_tool->has_good_curve_data() )
+ return CUBIT_FAILURE;
+ facet_curve->set_eval_tool( eval_tool );
+ }
+ }
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_shell
+// Member Type: PUBLIC
+// Description: create a new facet shell
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_shell(DLIList<Surface*> &surface_list,
+ ShellSM *&new_shell_ptr)
+{
+
+ Lump* my_lump = NULL;
+ OCCShell *new_facet_shell = new OCCShell(my_lump, surface_list);
+ new_shell_ptr = (ShellSM*) new_facet_shell;
+ int ii;
+ for ( ii = surface_list.size(); ii > 0; ii-- )
+ {
+ Surface* surface_ptr = surface_list.get_and_step();
+ OCCSurface *facet_surface = CAST_TO(surface_ptr, OCCSurface);
+ facet_surface->add_shell(new_shell_ptr);
+ }
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_lump
+// Member Type: PUBLIC
+// Description: create a new facet lump
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_lump(DLIList<ShellSM*> &shell_list,
+ Lump *&new_lump_ptr)
+{
+
+ OCCLump *new_facet_lump = new OCCLump(shell_list);
+ new_lump_ptr = (Lump*) new_facet_lump;
+ int ii;
+ for ( ii = shell_list.size(); ii > 0; ii-- )
+ {
+ ShellSM* shell_ptr = shell_list.get_and_step();
+ OCCShell *facet_shell = CAST_TO(shell_ptr, OCCShell);
+ facet_shell->add_lump(new_lump_ptr);
+ }
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : make_facet_body
+// Member Type: PUBLIC
+// Description: create a new facet body
+// Author : sjowen
+// Date : 12/6/00
+//================================================================================
+CubitStatus OCCModifyEngine::make_facet_body(DLIList<Lump*> &lump_list,
+ BodySM *&new_body_ptr)
+{
+
+ OCCBody *new_facet_body = new OCCBody(lump_list);
+ new_body_ptr = (BodySM*) new_facet_body;
+ //Now attach the lower entites.
+
+ int ii;
+ for ( ii = lump_list.size(); ii > 0; ii-- )
+ {
+ Lump* lump_ptr = lump_list.get_and_step();
+ OCCLump *facet_lump = CAST_TO(lump_ptr, OCCLump);
+ facet_lump->add_body(new_body_ptr);
+ }
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Function : build_facet_surface
+// Member Type: PUBLIC
+// Description: same as build_facet_surface below, but takes a list of quad facets
+// Author : sjowen
+// Date : 4/30/01
+//================================================================================
+CubitStatus OCCModifyEngine::build_facet_surface(
+ DLIList<CubitQuadFacet *> &quad_facet_list,
+ DLIList<CubitPoint *>&point_list, // fills this in if not provided
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list)
+{
+ CubitQuadFacet *qfacet;
+ DLIList<CubitFacet*> facet_list;
+ int ii;
+
+ quad_facet_list.reset();
+ for (ii=0; ii<quad_facet_list.size(); ii++)
+ {
+ qfacet = quad_facet_list.get_and_step();
+ facet_list.append( qfacet->get_tri_facet( 0 ) );
+ facet_list.append( qfacet->get_tri_facet( 1 ) );
+ }
+ return build_facet_surface( NULL, facet_list, point_list, feature_angle,
+ interp_order, smooth_non_manifold,
+ split_surfaces, surface_list );
+}
+
+//================================================================================
+// Function : build_facet_surface
+// Member Type: PUBLIC
+// Description: same as build_facet_surface below, both quad and triangle facets
+// Author : sjowen
+// Date : 4/30/01
+//================================================================================
+CubitStatus OCCModifyEngine::build_facet_surface(
+ DLIList<CubitQuadFacet *> &quad_facet_list,
+ DLIList<CubitFacet *> &tri_facet_list,
+ DLIList<CubitPoint *>&point_list, // fills this in if not provided
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ CubitQuadFacet *qfacet;
+ DLIList<CubitFacet*> facet_list;
+ int ii;
+ quad_facet_list.reset();
+ for (ii=0; ii<quad_facet_list.size(); ii++)
+ {
+ qfacet = quad_facet_list.get_and_step();
+ facet_list.append( qfacet->get_tri_facet( 0 ) );
+ facet_list.append( qfacet->get_tri_facet( 1 ) );
+ }
+ facet_list += tri_facet_list;
+
+ rv = build_facet_surface( NULL, facet_list, point_list, feature_angle,
+ interp_order, smooth_non_manifold,
+ split_surfaces, surface_list );
+ return rv;
+}
+
+//================================================================================
+// Function : build_cholla_surfaces
+// Member Type: PUBLIC
+// Description: create one or more surfaces from the list of facets. Also creates
+// the lower order entities. Generate curves (split surfaces), based
+// on feature angle. If feature_angle < 0 then ignore feature_angle
+// Note : This function is the main interface for Cubit to the Cholla library
+// Author : sjowen
+// Date : 4/26/01
+//================================================================================
+CubitStatus OCCModifyEngine::build_cholla_surfaces
+(
+ DLIList<CubitFacet *> facet_list,
+ DLIList<CubitPoint *> point_list, // fills this in if not provided
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ ChollaEngine *&cholla_ptr
+)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ // generate the edge and point lists from the facets
+
+ DLIList<CubitFacetEdge *> edge_list;
+ DLIList<FacetEntity*> pe_list;
+ DLIList<FacetEntity *> pf_list;
+ FacetDataUtil::get_edges( facet_list, edge_list );
+ if (facet_list.size() > 0 && point_list.size() == 0)
+ FacetDataUtil::get_points( facet_list, point_list );
+
+ CAST_LIST( point_list, pf_list, FacetEntity );
+ CAST_LIST( edge_list, pe_list, FacetEntity );
+
+ // create the surfaces
+
+ if (rv == CUBIT_SUCCESS)
+ {
+ DLIList<FacetEntity*> facet_entity_list;
+ CAST_LIST( facet_list, facet_entity_list, FacetEntity );
+ cholla_ptr = new ChollaEngine( facet_entity_list,
+ pe_list, pf_list );
+ CubitBoolean use_feature_angle;
+ if (feature_angle < 0.0)
+ use_feature_angle = CUBIT_FALSE;
+ else
+ use_feature_angle = CUBIT_TRUE;
+ rv = cholla_ptr->create_geometry( use_feature_angle, feature_angle,
+ interp_order, smooth_non_manifold,
+ split_surfaces );
+ }
+ return rv;
+}
+//================================================================================
+// Function : build_facet_surface
+// Member Type: PUBLIC
+// Description: create one or more surfaces from the list of facets. Also creates
+// the lower order entities. Generate curves (split surfaces), based
+// on feature angle. If feature_angle < 0 then ignore feature_angle
+// Note : This function is the main interface for Cubit to the Cholla library
+// Author : sjowen
+// Date : 4/26/01
+//================================================================================
+CubitStatus OCCModifyEngine::build_facet_surface(
+ const CubitEvaluatorData **eval_data,
+ DLIList<CubitFacet *> &facet_list,
+ DLIList<CubitPoint *> &point_list, // fills this in if not provided
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ // generate the edge and point lists from the facets
+
+ DLIList<CubitFacetEdge *> edge_list;
+ DLIList<FacetEntity*> pe_list;
+ DLIList<FacetEntity *> pf_list;
+ FacetDataUtil::get_edges( facet_list, edge_list );
+ if (point_list.size() == 0)
+ FacetDataUtil::get_points( facet_list, point_list );
+
+ CAST_LIST( point_list, pf_list, FacetEntity );
+ CAST_LIST( edge_list, pe_list, FacetEntity );
+
+ // create the surfaces
+
+ if (rv == CUBIT_SUCCESS)
+ {
+ DLIList<FacetEntity*> facet_entity_list;
+ CAST_LIST( facet_list, facet_entity_list, FacetEntity );
+ ChollaEngine *cholla_ptr = new ChollaEngine( facet_entity_list,
+ pe_list, pf_list );
+ cholla_ptr->set_flip_flag(CUBIT_TRUE);
+ CubitBoolean use_feature_angle;
+ if (feature_angle < 0.0)
+ use_feature_angle = CUBIT_FALSE;
+ else
+ use_feature_angle = CUBIT_TRUE;
+ rv = cholla_ptr->create_geometry( use_feature_angle, feature_angle,
+ interp_order, smooth_non_manifold,
+ split_surfaces );
+
+ // make CUBIT geometry out of the Cholla entities
+
+ if (rv == CUBIT_SUCCESS)
+ {
+ DLIList<ChollaSurface *> cholla_surface_list;
+ cholla_ptr->get_surfaces( cholla_surface_list );
+ DLIList<ChollaCurve *> cholla_curve_list;
+ cholla_ptr->get_curves( cholla_curve_list );
+ DLIList<ChollaPoint *> cholla_point_list;
+ cholla_ptr->get_points( cholla_point_list );
+ rv = build_cholla_geometry(eval_data, cholla_surface_list, cholla_curve_list,
+ cholla_point_list, use_feature_angle,
+ feature_angle, interp_order, surface_list);
+ }
+ cholla_ptr->delete_me();
+ delete cholla_ptr;
+ }
+ return rv;
+}
+
+//===============================================================================
+// Function : build_cholla_geometry
+// Member Type: PRIVATE
+// Description: build the CUBIT geometry based on the Facet entity class lists
+// Author : sjowen
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::build_cholla_geometry(
+ const CubitEvaluatorData **eval_data,
+ DLIList<ChollaSurface*> &cholla_surface_list,
+ DLIList<ChollaCurve*> &cholla_curve_list,
+ DLIList<ChollaPoint*> &cholla_point_list,
+ CubitBoolean use_feature_angle,
+ double feature_angle,
+ int interp_order,
+ DLIList<Surface *> &surface_list)
+{
+ CubitStatus stat = CUBIT_SUCCESS;
+
+ //- convert feature angle to a dot product
+
+ double min_dot = 0.0;
+ if (use_feature_angle)
+ {
+ if (feature_angle > 180.0) feature_angle = 180.0;
+ if (feature_angle < 0.0) feature_angle = 0.0;
+ double rad_angle = (180.0 - feature_angle) * CUBIT_PI / 180.0;
+ min_dot = cos( rad_angle );
+ }
+
+ // build the CUBIT geometry based on Cholla entities
+
+ stat = build_cholla_point_geometry( cholla_point_list );
+
+ if (stat == CUBIT_SUCCESS)
+ stat = build_cholla_curve_geometry( cholla_curve_list );
+
+ if (stat == CUBIT_SUCCESS)
+ stat = build_cholla_surface_geometry( eval_data,
+ cholla_surface_list,
+ interp_order, min_dot,
+ surface_list);
+
+ return stat;
+}
+
+//===============================================================================
+// Function : build_cholla_point_geometry
+// Member Type: PRIVATE
+// Description: From the cholla point list, create geometric points for each
+// Author : sjowen
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::build_cholla_point_geometry(
+ DLIList<ChollaPoint*> &cholla_point_list )
+{
+ CubitStatus stat = CUBIT_SUCCESS;
+ int kk;
+ //int mydebug = 0;
+ for ( kk = cholla_point_list.size(); kk > 0; kk-- )
+ {
+ ChollaPoint *chpnt_ptr = cholla_point_list.get_and_step();
+ Point *point_ptr = (Point *)chpnt_ptr->get_geometric_point();
+ if (point_ptr == NULL)
+ {
+ FacetEntity *facet_ptr = chpnt_ptr->get_facets();
+ CubitPoint *cp_ptr = CAST_TO( facet_ptr, CubitPoint );
+ Point *point = NULL;
+ stat = make_facet_point( cp_ptr, point );
+ if ( point == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based points.\n");
+ return stat;
+ }
+ point_ptr = (Point *)point;
+ chpnt_ptr->assign_geometric_point((void *)point_ptr);
+ }
+ }
+ return stat;
+}
+
+//===============================================================================
+// Function : build_cholla_curve_geometry
+// Member Type: PRIVATE
+// Description: From the cholla curve list, create geometric curves for each
+// Author : sjowen
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::build_cholla_curve_geometry(
+ DLIList<ChollaCurve*> &cholla_curve_list )
+{
+ CubitStatus stat = CUBIT_SUCCESS;
+ int kk;
+ for ( kk = cholla_curve_list.size(); kk > 0; kk-- )
+ {
+ ChollaCurve *chcurv_ptr = cholla_curve_list.get_and_step();
+ Curve *curv_ptr = (Curve *)chcurv_ptr->get_geometric_curve();
+ if (curv_ptr == NULL)
+ {
+ DLIList<ChollaPoint*> fpoint_list = chcurv_ptr->get_points( );
+ ChollaPoint *fpm0_ptr = fpoint_list.get_and_step();
+ ChollaPoint *fpm1_ptr = fpoint_list.get_and_step();
+ CubitPoint *start_point, *end_point;
+ chcurv_ptr->get_ends( start_point, end_point );
+ if (fpm0_ptr->get_facets() != start_point)
+ {
+ ChollaPoint *temp_ptr;
+ temp_ptr = fpm0_ptr;
+ fpm0_ptr = fpm1_ptr;
+ fpm1_ptr = temp_ptr;
+ }
+ Point *start_ptr = (Point *) fpm0_ptr->get_geometric_point();
+ Point *end_ptr = (Point *) fpm1_ptr->get_geometric_point();
+
+ // if this is a curve without a parent surface then handle it
+ // differently. (Curves with parents use the surface to evaluate to
+ // With only a curve, it must evaluate to the curve)
+
+ DLIList<ChollaSurface*> fsm_list = chcurv_ptr->get_surfaces();
+ if (fsm_list.size() == 0)
+ {
+ DLIList<FacetEntity*> facet_list;
+ DLIList<CubitPoint*> point_list; // needs to be filled in
+ facet_list = chcurv_ptr->get_facet_list();
+ DLIList<CubitFacetEdge*> edge_list;
+ CAST_LIST( facet_list, edge_list, CubitFacetEdge );
+ if (stat != CUBIT_SUCCESS)
+ return stat;
+
+ // the CurveFacetEvalTool was computed in Cholla. Retreive it
+ // and pass it to make_facet_curve so it can store it with the
+ // new curve
+ CurveFacetEvalTool *eval_tool_ptr = chcurv_ptr->get_eval_tool();
+ if (eval_tool_ptr == NULL)
+ return CUBIT_FAILURE;
+ stat = make_facet_curve( start_ptr, end_ptr,
+ edge_list, point_list,
+ curv_ptr, eval_tool_ptr );
+ if (stat == CUBIT_SUCCESS)
+ {
+ Curve *curvsm_ptr = CAST_TO( curv_ptr, Curve );
+ GeometryQueryTool::instance()->make_free_RefEdge( curvsm_ptr );
+ }
+ }
+ else
+ {
+ CurveFacetEvalTool *eval_tool_ptr = chcurv_ptr->get_eval_tool();
+ if (eval_tool_ptr == NULL)
+ return CUBIT_FAILURE;
+ stat = make_facet_curve( start_ptr, end_ptr,
+ curv_ptr, eval_tool_ptr );
+ if ( curv_ptr == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based curves.\n");
+ return stat;
+ }
+ }
+ chcurv_ptr->assign_geometric_curve((void *)curv_ptr);
+ }
+ }
+ return stat;
+}
+
+//===============================================================================
+// Function : build_cholla_loop_geometry
+// Member Type: PRIVATE
+// Description: From the cholla curve list of a surface, create geometric loops
+// Author : sjowen
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::build_cholla_loop_geometry(
+ DLIList<ChollaCurve*> &cholla_curve_list, // curves on a surface
+ ChollaSurface *chsurf_ptr, // the surface
+ DLIList<LoopSM*> &loop_list, // append to this loop list
+ int &ncurves, // number of curves used
+ int debug_draw )
+{
+
+ // find the first unused curve on the list. Use that as the starting curve
+ // in the loop
+
+ ncurves = 0;
+ CubitStatus stat = CUBIT_SUCCESS;
+ int ii, jj;
+ int found = 0;
+ ChollaCurve *chcurv_ptr = NULL;
+ for(ii=0; ii<cholla_curve_list.size() && !found; ii++)
+ {
+ chcurv_ptr = cholla_curve_list.get_and_step();
+ if (chcurv_ptr->get_flag() == 0)
+ found = 1;
+ }
+ if (!found)
+ return CUBIT_FAILURE; // all the curves have already been used in this surface
+
+ // get the orientation of this curve w.r.t. this surface
+
+ CubitSense orientation;
+ stat = ChollaEngine::determine_curve_orientation( chsurf_ptr,
+ chcurv_ptr, orientation );
+ if (orientation == CUBIT_UNKNOWN || stat == CUBIT_FAILURE)
+ return CUBIT_FAILURE;
+
+ CubitPoint *start_ptr, *end_ptr;
+ chcurv_ptr->get_ends( start_ptr, end_ptr );
+
+ // create a new coedge
+
+ CoEdgeSM *coedge_ptr = NULL;
+ Curve *curv_ptr = (Curve *)chcurv_ptr->get_geometric_curve();
+ stat = make_facet_coedge( curv_ptr, orientation, coedge_ptr );
+ if ( coedge_ptr == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based coedges.\n");
+ return stat;
+ }
+
+ if (debug_draw)
+ {
+ CubitVector s = start_ptr->coordinates();
+ CubitVector e = end_ptr->coordinates();
+ CubitSense sense = coedge_ptr->sense();
+ if (sense == CUBIT_FORWARD)
+ GfxDebug::draw_line(s, e, CUBIT_GREEN);
+ else
+ GfxDebug::draw_line(s, e, CUBIT_RED);
+
+ GfxDebug::draw_point(s, CUBIT_GREEN);
+ GfxDebug::draw_label(0, s.x(), s.y(), s.z(), CUBIT_GREEN);
+
+ GfxDebug::draw_point(e, CUBIT_RED);
+ GfxDebug::draw_label(1, e.x(), e.y(), e.z(), CUBIT_RED);
+
+ GfxDebug::flush();
+ debug_draw=debug_draw;
+ }
+
+ // start a list of coedges for this loop
+
+ DLIList<CoEdgeSM*> coedge_list;
+ coedge_list.append( coedge_ptr );
+ chcurv_ptr->set_flag(1);
+ ChollaCurve *last_chcurv_ptr = chcurv_ptr;
+
+ // loop through and determine the rest of the coedges based on the
+ // orientation of the first curve in the loop
+
+ chcurv_ptr->get_ends( start_ptr, end_ptr );
+ FacetEntity *n0_ptr, *n1_ptr;
+ if (orientation == CUBIT_FORWARD)
+ {
+ n0_ptr = start_ptr;
+ n1_ptr = end_ptr;
+ }
+ else
+ {
+ n1_ptr = start_ptr;
+ n0_ptr = end_ptr;
+ }
+
+ while (n0_ptr != n1_ptr)
+ {
+
+ // find the next curve in the loop
+
+ int ntimes = 0;
+ found = 0;
+ while(!found)
+ {
+ for ( jj = 0; jj < cholla_curve_list.size() && !found; jj++)
+ {
+ chcurv_ptr = cholla_curve_list.get_and_step();
+ if (last_chcurv_ptr != chcurv_ptr && (chcurv_ptr->get_flag() == 0 || ntimes > 0))
+ {
+ chcurv_ptr->get_ends( start_ptr, end_ptr );
+ if (start_ptr == n1_ptr)
+ {
+ found = 1;
+ orientation = CUBIT_FORWARD;
+ n1_ptr = end_ptr;
+ }
+ else if (end_ptr == n1_ptr)
+ {
+ found = 1;
+ orientation = CUBIT_REVERSED;
+ n1_ptr = start_ptr;
+ }
+ }
+ }
+ if (!found)
+ {
+
+ // in this special case - we have gone through the whole list without
+ // finding the next curve on the loop. In the first pass we have assumed
+ // that each curve is only used once. This may not be the case. Go
+ // back and see of we can find a curve that has already been used that
+ // will work. If we fail the second time through, then we fail!
+
+ ntimes++;
+ if (ntimes > 1)
+ // return CUBIT_FAILURE; // didn't find the next curve in the loop
+ // DEBUG ONLY -- THIS NEEDS TO BE FIXED
+ goto create_loop;
+ }
+ }
+
+ // create a new coedge
+
+ coedge_ptr = NULL;
+ curv_ptr = (Curve *)chcurv_ptr->get_geometric_curve();
+ stat = make_facet_coedge( curv_ptr, orientation,coedge_ptr );
+ if ( coedge_ptr == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based coedges.\n");
+ return stat;
+ }
+
+ if (debug_draw)
+ {
+ CubitVector s = start_ptr->coordinates();
+ CubitVector e = end_ptr->coordinates();
+ CubitSense sense = coedge_ptr->sense();
+ if (sense == CUBIT_FORWARD)
+ GfxDebug::draw_line(s, e, CUBIT_GREEN);
+ else
+ GfxDebug::draw_line(s, e, CUBIT_RED);
+
+ GfxDebug::draw_point(s, CUBIT_GREEN);
+ GfxDebug::draw_label(0, s.x(), s.y(), s.z(), CUBIT_GREEN);
+
+ GfxDebug::draw_point(e, CUBIT_RED);
+ GfxDebug::draw_label(1, e.x(), e.y(), e.z(), CUBIT_RED);
+
+ GfxDebug::flush();
+ debug_draw=debug_draw;
+ }
+ coedge_list.append( coedge_ptr );
+ if (coedge_list.size() > 2*cholla_curve_list.size())
+ return CUBIT_FAILURE; // more curves in the loop than their are curves ????
+ chcurv_ptr->set_flag(1);
+ last_chcurv_ptr = chcurv_ptr;
+ }
+
+ // create the loop
+
+create_loop:
+ LoopSM *loop_ptr = NULL;
+ stat = make_facet_loop( coedge_list, loop_ptr );
+ if ( coedge_ptr == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based loops.\n");
+ return stat;
+ }
+ loop_list.append( loop_ptr );
+ ncurves = coedge_list.size();
+
+ return stat;
+}
+
+//===============================================================================
+// Function : build_cholla_surface_geometry (PRIVATE)
+// Member Type: PRIVATE
+// Description: From the facet surface list, create geometric surface,
+// loops and coedges for each surface in the list
+// Author : sjowen
+// Date : 10/02
+//===============================================================================
+CubitStatus OCCModifyEngine::build_cholla_surface_geometry(
+ const CubitEvaluatorData **eval_data,
+ DLIList<ChollaSurface*> &cholla_surface_list,
+ int interp_order,
+ double min_dot,
+ DLIList<Surface *> &surface_list)
+{
+ CubitStatus stat = CUBIT_SUCCESS;
+ int ii, isurface;
+
+ // make sure the facet flags have been reset
+
+ ChollaCurve *chcurv_ptr;
+ cholla_surface_list.reset();
+ for ( isurface = 0; isurface < cholla_surface_list.size(); isurface++ )
+ {
+ ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
+ chsurf_ptr->reset_facet_flags();
+ }
+
+ // now loop through surfaces and create them
+
+ int mydebug = 0;
+ cholla_surface_list.reset();
+ for ( isurface = 0; isurface < cholla_surface_list.size(); isurface++ )
+ {
+ const CubitEvaluatorData *surf_eval_data = eval_data == NULL ? NULL : eval_data[isurface];
+ int num_curves = 0;
+ ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
+
+ DLIList<ChollaCurve*> chcurve_list;
+ chsurf_ptr->get_curves( chcurve_list );
+
+ // init flags for curves on this surface
+
+ for (ii=0; ii< chcurve_list.size(); ii++)
+ {
+ chcurv_ptr = chcurve_list.get_and_step();
+ chcurv_ptr->set_flag(0);
+ if (mydebug)
+ {
+ chcurv_ptr->debug_draw();
+ }
+ }
+
+ // generate loops - keep going until we have used all the curves in the list
+
+ DLIList<LoopSM*> loop_list;
+ int debug_draw = 0;
+ while (num_curves < chcurve_list.size())
+ {
+ int ncurves = 0;
+ stat = build_cholla_loop_geometry( chcurve_list, chsurf_ptr,
+ loop_list, ncurves, debug_draw );
+ if (stat != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Can't build geometric loop from facets\n");
+ return stat;
+ }
+ num_curves += ncurves;
+ }
+
+ // create the surface
+
+ Surface *surf_ptr = (Surface *)chsurf_ptr->get_geometric_surface();
+ if (surf_ptr == NULL)
+ {
+ DLIList<FacetEntity*> facet_entity_list;
+ DLIList<CubitPoint*> point_list;
+ chsurf_ptr->get_points(point_list);
+ chsurf_ptr->get_facets(facet_entity_list);
+ DLIList<CubitFacet*> facet_list;
+ CAST_LIST( facet_entity_list, facet_list, CubitFacet );
+ FacetEvalTool *eval_tool_ptr = chsurf_ptr->get_eval_tool();
+ if (eval_tool_ptr == NULL)
+ return CUBIT_FAILURE;
+ stat = make_facet_surface(surf_eval_data, facet_list,point_list,loop_list,
+ interp_order,min_dot,surf_ptr, CUBIT_TRUE, eval_tool_ptr);
+ if ( surf_ptr == NULL || stat != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building mesh based surfaces.\n");
+ return stat;
+ }
+ chsurf_ptr->assign_geometric_surface((void *)surf_ptr);
+ surface_list.append(surf_ptr);
+ }
+ }
+ return stat;
+}
+
+//================================================================================
+// Description: improve the facets on a surface
+// Author : Steve Owen
+// Date : 8/28/2003
+//================================================================================
+CubitStatus OCCModifyEngine::improve_facets( RefFace *ref_face_ptr )
+{
+ //CubitStatus rv = CUBIT_SUCCESS;
+
+ // This must be a facet-based surface - return now if it isn't
+
+ Surface *surf_ptr = ref_face_ptr->get_surface_ptr();
+ OCCSurface *fsurf_ptr = dynamic_cast<OCCSurface *>(surf_ptr);
+ if (fsurf_ptr == NULL)
+ {
+ PRINT_ERROR("Couldn't improve facets on surface %d. It is not a facet-based geometry.\n",
+ ref_face_ptr->id());
+ return CUBIT_FAILURE;
+ }
+
+ CubitPoint *point_ptr;
+ DLIList<CubitPoint *> point_list;
+ DLIList<CubitFacet *> facet_list;
+ DLIList<CubitFacetEdge *> edge_list;
+
+ // get the facets from the facet-based surface
+
+ fsurf_ptr->get_my_facets(facet_list, point_list);
+ FacetDataUtil::get_edges(facet_list, edge_list);
+
+ // compute normals if necessary
+
+ int ii;
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ point_ptr->normal();
+ }
+
+ // main clean loop
+
+ CubitFacet *facet0, *facet1;
+ CubitFacetData *cfacet0, *cfacet1;
+ CubitPoint *pt0, *pt1, *pt2, *pt3;
+ CubitFacetEdge *edge;
+ CubitFacetEdgeData *cedge;
+ int nflip = 0;
+ CubitVector n0, n1, n2, n3;
+ CubitVector c0, c1, c2, c3;
+ double q0, q1, q2, q3;
+ CubitVector nt0, nt1, nt2, nt3;
+ DLIList<CubitFacet *>adj_facets;
+ int nedges = edge_list.size();
+ for(ii=0; ii<nedges; ii++)
+ {
+ edge = edge_list.get();
+
+ // can't be a feature (edge is on a curve)
+ if(edge->is_feature())
+ {
+ edge_list.step();
+ continue;
+ }
+
+ pt0 = edge->point(0);
+ pt1 = edge->point(1);
+ adj_facets.clean_out();
+ edge->facets( adj_facets );
+
+ // must be 2 adjacent facets.
+ if (adj_facets.size() != 2)
+ {
+ edge_list.step();
+ continue;
+ }
+ facet0 = adj_facets.get_and_step();
+ facet1 = adj_facets.get();
+
+ // get the adjacent vertices, make sure we are oriented correctly
+ // - swap pt0 and pt1 if necessary
+ pt2 = facet0->next_node(pt1);
+ if(pt2 == pt0)
+ {
+ pt2 = pt0;
+ pt0 = pt1;
+ pt1 = pt2;
+ pt2 = facet0->next_node(pt1);
+ }
+ pt3 = facet1->next_node(pt0);
+
+ // get the normals from the vertices
+ n0 = pt0->normal( facet0 );
+ n1 = pt1->normal( facet0 );
+ n2 = pt2->normal( facet0 );
+ n3 = pt3->normal( facet1 );
+ c0 = pt0->coordinates();
+ c1 = pt1->coordinates();
+ c2 = pt2->coordinates();
+ c3 = pt3->coordinates();
+
+ // compute triangle normals by averaging vertices
+ nt0 = n0 + n1 + n2;
+ nt0.normalize();
+ nt1 = n0 + n1 + n3;
+ nt1.normalize();
+ nt2 = n0 + n2 + n3;
+ nt2.normalize();
+ nt3 = n1 + n2 + n3;
+ nt3.normalize();
+
+ // compute quality for each of the four tris... 2 existing tris
+ // and the two potential tris if we flip
+ q0 = FacetDataUtil::quality(c0, c1, c2, nt0);
+ q1 = FacetDataUtil::quality(c1, c0, c3, nt1);
+ q2 = FacetDataUtil::quality(c0, c3, c2, nt2);
+ q3 = FacetDataUtil::quality(c1, c2, c3, nt3);
+ q0 = CUBIT_MIN( q0, q1 );
+ q2 = CUBIT_MIN( q2, q3 );
+ if (q2 > q0)
+ {
+ // flip
+
+ facet_list.remove( facet0 ); // these take too long - find another way to remove them
+ facet_list.remove( facet1 );
+ edge_list.change_to(NULL);
+
+ cfacet0 = dynamic_cast<CubitFacetData *>( facet0 );
+ cfacet1 = dynamic_cast<CubitFacetData *>( facet1 );
+ cedge = dynamic_cast<CubitFacetEdgeData *>( edge );
+
+ delete cfacet0;
+ delete cfacet1;
+ delete cedge;
+
+ // get edges
+
+ CubitFacetEdge *e[4];
+ e[0] = pt2->get_edge( pt0 );
+ e[1] = pt0->get_edge( pt3 );
+ e[2] = pt3->get_edge( pt1 );
+ e[3] = pt1->get_edge( pt2 );
+ cedge = new CubitFacetEdgeData( pt2, pt3 );
+ edge = dynamic_cast<CubitFacetEdge *>( cedge );
+
+ cfacet0 = new CubitFacetData( edge, e[0], e[1] );
+ cfacet1 = new CubitFacetData( edge, e[2], e[3] );
+ facet0 = dynamic_cast<CubitFacet *>( cfacet0 );
+ facet1 = dynamic_cast<CubitFacet *>( cfacet1 );
+
+ edge_list.append( edge );
+ facet_list.append( facet0 );
+ facet_list.append( facet1 );
+
+ nflip++;
+ }
+ edge_list.step();
+ }
+ edge_list.remove_all_with_value(NULL);
+ assert(edge_list.size() == nedges);
+ if (nflip > 0)
+ {
+ fsurf_ptr->get_eval_tool()->replace_facets(facet_list);
+ }
+ return CUBIT_SUCCESS;
+}
+
+
+//================================================================================
+// Description: smooth the facets on a surface
+// Author : Steve Owen
+// Date : 8/28/2003
+// Note: free_laplacian = TRUE will not project the node back to a tangent plane
+// free_laplacian = FALSE will project to local tangent plane
+//================================================================================
+CubitStatus OCCModifyEngine::smooth_facets( RefFace *ref_face_ptr, int niter,
+ CubitBoolean free_laplacian )
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ // This must be a facet-based surface - return now if it isn't
+
+ Surface *surf_ptr = ref_face_ptr->get_surface_ptr();
+ OCCSurface *fsurf_ptr = dynamic_cast<OCCSurface *>(surf_ptr);
+ if (fsurf_ptr == NULL)
+ {
+ PRINT_ERROR("Couldn't smooth facets on surface %d. It is not a facet-based geometry.\n",
+ ref_face_ptr->id());
+ return CUBIT_FAILURE;
+ }
+
+ CubitPoint *point_ptr;
+ DLIList<CubitPoint *>point_list;
+
+ // get the points from the facet-basec surface
+
+ fsurf_ptr->get_my_points(point_list);
+
+ // compute normals if necessary
+
+ int ii, jj;
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ point_ptr->normal();
+ point_ptr->marked(0);
+ }
+
+ // get the points on the facet curves associated with this surface
+
+ DLIList<CubitPoint *>cpoint_list;
+ OCCCurve *fcurv_ptr;
+ Curve *curv_ptr;
+
+ int idx;
+ DLIList<Curve *> curves;
+ fsurf_ptr->curves(curves);
+ OCCCurve **fcurve_array = new OCCCurve * [curves.size()];
+ for (ii=0; ii<curves.size(); ii++)
+ {
+ idx = ii+1;
+ curv_ptr = curves.get_and_step();
+ fcurv_ptr = dynamic_cast<OCCCurve *>(curv_ptr);
+ if (!fcurv_ptr)
+ {
+ PRINT_ERROR("Couldn't smooth facets on surface %d. At least one of it curves is not a facet-based geometry.\n",
+ ref_face_ptr->id());
+ return CUBIT_FAILURE;
+ }
+
+ // mark the points on the curve with the index of the curve in the array
+ // this will allow us to project the point back to the owning curve
+
+ cpoint_list.clean_out();
+ fcurv_ptr->get_points(cpoint_list);
+ for (jj=0; jj<cpoint_list.size(); jj++)
+ {
+ point_ptr = cpoint_list.get_and_step();
+ point_ptr->marked( idx );
+ }
+ fcurve_array[idx-1] = fcurv_ptr;
+
+ // mark the vertices with a negative value so we don't touch them
+
+ DLIList<Point *> verts;
+ fcurv_ptr->points(verts);
+ for(jj=0; jj<verts.size(); jj++)
+ {
+ Point *vert = verts.get_and_step();
+ OCCPoint *fvert = dynamic_cast<OCCPoint *> (vert);
+ fvert->get_cubit_point()->marked(-1);
+ }
+ }
+
+ // laplacian smoothing
+
+ DLIList<CubitPoint *> adj_points;
+ int iter, nadj;
+ CubitPoint *adj_point_ptr;
+ CubitVector new_location;
+
+ for (iter = 0; iter < niter; iter++)
+ {
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+
+ // don't smooth points at vertices
+
+ if (point_ptr->marked() >= 0)
+ {
+ adj_points.clean_out();
+ point_ptr->adjacent_points( adj_points );
+ new_location.set(0.0, 0.0, 0.0);
+ nadj=0;
+ for (jj = 0; jj<adj_points.size(); jj++)
+ {
+ adj_point_ptr = adj_points.get_and_step();
+ if (point_ptr->marked()) // is on a curve
+ {
+ // only use points on the same curve to influence the new location
+ if (point_ptr->marked() == adj_point_ptr->marked())
+ {
+ new_location += adj_point_ptr->coordinates();
+ nadj++;
+ }
+ }
+
+ // interior nodes use all adjacent points
+ else
+ {
+ new_location += adj_point_ptr->coordinates();
+ nadj++;
+ }
+ }
+ new_location /= nadj;
+
+ // project it to a tangent plane defined at the point.
+ // except if we are on a curve or we're using free-laplacian option
+ if (!free_laplacian && point_ptr->marked() == 0)
+ new_location = point_ptr->project_to_tangent_plane( new_location );
+
+ // for points on a curve project to the curve definition
+ if(point_ptr->marked() != 0)
+ {
+ const CubitVector temp = new_location;
+ fcurve_array[point_ptr->marked()-1]->closest_point( temp,
+ new_location );
+ }
+
+ if (point_ptr->check_inverted_facets(new_location) == CUBIT_SUCCESS)
+ {
+ point_ptr->set(new_location);
+ }
+ }
+ }
+
+ // update the normals
+
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ point_ptr->compute_avg_normal();
+ }
+ }
+
+ return rv;
+}
+
+//================================================================================
+// Description: create a shell that is the normal offset of the given shell
+// Author : Steve Owen
+// Date : 8/28/2003
+//================================================================================
+CubitStatus OCCModifyEngine::create_shell_offset( BodySM *bodysm_ptr,
+ BodySM *&new_bodysm, double offset )
+{
+ // check that this is a facet body
+
+ OCCBody *fbody_ptr = dynamic_cast<OCCBody *>(bodysm_ptr);
+ if (fbody_ptr == NULL)
+ {
+ PRINT_ERROR("Body is not a facet-based geometry. This command is intended for use with facetted models\n");
+ return CUBIT_FAILURE;
+ }
+
+ // The facet and point lists
+
+ DLIList<CubitPoint *> point_list;
+ DLIList<CubitFacet *> facet_list;
+
+ // get the surfaces. Check that they are also all facet bodies
+
+ int ii;
+ Surface *surf_ptr;
+ OCCSurface *fsurf_ptr;
+ DLIList<Surface *> surface_list;
+ fbody_ptr->surfaces( surface_list );
+ for (ii=0; ii<surface_list.size(); ii++)
+ {
+ surf_ptr = surface_list.get_and_step();
+ fsurf_ptr = dynamic_cast<OCCSurface *>(surf_ptr);
+ if (fsurf_ptr == NULL)
+ {
+ PRINT_ERROR("At least one of the surfaces in Body is not facet-based geometry.\n"
+ "This command is intended for use with facetted models\n");
+ return CUBIT_FAILURE;
+ }
+ fsurf_ptr->get_my_facets(facet_list, point_list);
+ }
+
+ // create an array of points so we can reference them quickly when generating new facets
+
+ CubitPoint **points = new CubitPoint * [point_list.size()];
+
+ // make a unique set of points
+
+ int id = 0;
+ CubitPoint *point_ptr;
+ for (ii=0; ii < point_list.size(); ii++)
+ {
+ point_list.get_and_step()->marked(1);
+ }
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ if (point_ptr->marked() == 1)
+ {
+ point_ptr->marked(0);
+ points[id] = point_ptr;
+ point_ptr->set_id( id );
+ id ++;
+ }
+ }
+ int npoints = id;
+
+ // get the curves and mark any point on a curve as non-smoothable.
+
+ int jj;
+ Curve *curv_ptr;
+ OCCCurve *fcurv_ptr;
+ DLIList<Curve *> curve_list;
+ fbody_ptr->curves( curve_list );
+ for(ii=0; ii<curve_list.size(); ii++)
+ {
+ curv_ptr = curve_list.get_and_step();
+ fcurv_ptr = dynamic_cast<OCCCurve *>(curv_ptr);
+ if (fcurv_ptr == NULL)
+ {
+ PRINT_ERROR("At least one of the curves in Body is not a facet-based geometry.\n"
+ "This command is intended for use with facetted models\n");
+ return CUBIT_FAILURE;
+ }
+ point_list.clean_out();
+ fcurv_ptr->get_points( point_list );
+ for(jj=0; jj<point_list.size(); jj++)
+ {
+ point_ptr = point_list.get_and_step();
+ point_ptr->marked(1);
+ }
+ }
+
+ // smooth the normals to reduce chance of overlap on concave regions
+
+ CubitVector new_normal, normal;
+ const int niter = 3;
+ int iter, nadj;
+ CubitPoint *adj_point_ptr;
+ DLIList<CubitPoint *> adj_points;
+
+ for (iter = 0; iter < niter; iter++)
+ {
+ for (ii=0; ii<npoints; ii++)
+ {
+ point_ptr = points[ii];
+
+ // don't smooth points on curves
+
+ if (point_ptr->marked() != 1)
+ {
+ adj_points.clean_out();
+ point_ptr->adjacent_points( adj_points );
+ new_normal.set(0.0, 0.0, 0.0);
+ nadj = adj_points.size();
+ for (jj = 0; jj<nadj; jj++)
+ {
+ adj_point_ptr = adj_points.get_and_step();
+ new_normal += adj_point_ptr->normal();
+ }
+ new_normal.normalize();
+ point_ptr->normal(new_normal);
+ }
+ }
+ }
+
+ // generate a new set of points offset from the original
+
+ CubitPointData *new_point;
+ CubitVector new_location;
+ CubitPoint **new_points = new CubitPoint * [npoints];
+ for (ii=0; ii<npoints; ii++)
+ {
+ point_ptr = points[ii];
+ new_location = point_ptr->coordinates() + point_ptr->normal() * offset;
+ new_point = new CubitPointData( new_location );
+ new_point->set_id( ii );
+ new_points[ii] = (CubitPoint *) new_point;
+ }
+
+ // generate triangles for the new shell
+
+ DLIList<CubitFacet *> fix_list;
+ DLIList<CubitFacet *> orig_list;
+ double dot;
+ double mindot = 1.0;
+ CubitFacet *facet_ptr, *new_facet_ptr;
+ DLIList<CubitFacet *> new_facet_list;
+ CubitPoint *p0, *p1, *p2;
+ CubitPoint *np0, *np1, *np2;
+ for(ii=0; ii<facet_list.size(); ii++)
+ {
+ facet_ptr = facet_list.get_and_step();
+ facet_ptr->points( p0, p1, p2 );
+ np0 = new_points[p0->id()];
+ np1 = new_points[p1->id()];
+ np2 = new_points[p2->id()];
+ new_facet_ptr = (CubitFacet *) new CubitFacetData( np0, np1, np2 );
+ new_facet_list.append( new_facet_ptr );
+
+ // compare normals to see if we inverted anything
+
+ normal = facet_ptr->normal();
+ new_normal = new_facet_ptr->normal();
+ dot = normal % new_normal;
+ if (dot < mindot) mindot = dot;
+ if (dot < 0.707)
+ {
+ new_facet_ptr->marked(1);
+ fix_list.append( new_facet_ptr );
+ orig_list.append( facet_ptr );
+ }
+ }
+
+ // go back and try to uninvert tris if needed
+
+ int kk;
+ DLIList<CubitFacet *> problem_list;
+ if (fix_list.size() > 0)
+ {
+ CubitVector new_location;
+ for (iter = 0; iter < niter; iter++)
+ {
+ for (ii=0; ii<fix_list.size(); ii++)
+ {
+ facet_ptr = fix_list.get_and_step();
+ point_list.clean_out();
+ facet_ptr->points( point_list );
+ for (jj=0; jj<point_list.size(); jj++)
+ {
+ point_ptr = point_list.get_and_step();
+
+ // don't smooth marked points
+
+ if (point_ptr->marked() != 1)
+ {
+ adj_points.clean_out();
+ point_ptr->adjacent_points( adj_points );
+ new_location.set(0.0, 0.0, 0.0);
+ nadj = adj_points.size();
+ for (kk = 0; kk<nadj; kk++)
+ {
+ adj_point_ptr = adj_points.get_and_step();
+ new_location += adj_point_ptr->coordinates();
+ }
+ new_location /= nadj;
+ point_ptr->set(new_location);
+ }
+ }
+ }
+ }
+
+ // see if it worked
+
+ fix_list.reset();
+ orig_list.reset();
+ for(ii=0; ii<fix_list.size(); ii++)
+ {
+ new_facet_ptr = fix_list.get_and_step();
+ facet_ptr = orig_list.get_and_step();
+ new_facet_ptr->update_plane();
+ new_normal = new_facet_ptr->normal();
+ normal = facet_ptr->normal();
+ dot = normal % new_normal;
+ if (dot < 0.707)
+ {
+ problem_list.append( new_facet_ptr );
+ }
+ }
+ }
+
+ // set the normals back the way they were and clean up
+
+ for (ii=0; ii<npoints; ii++)
+ {
+ point_ptr = points[ii];
+ point_ptr->compute_avg_normal();
+ }
+ delete [] points;
+ delete [] new_points;
+
+ // build the geometry
+
+ const char *file_name = NULL;
+ CubitBoolean use_feature_angle = CUBIT_TRUE;
+ double feature_angle = 0.0;
+ int interp_order = 0;
+ CubitBoolean smooth_non_manifold = CUBIT_TRUE;
+ CubitBoolean split_surfaces = CUBIT_FALSE;
+ CubitBoolean stitch = CUBIT_FALSE;
+ CubitBoolean improve = CUBIT_FALSE;
+ DLIList<CubitQuadFacet *> quad_facet_list;
+ DLIList<Surface *> new_surface_list;
+ FacetFileFormat file_format = FROM_FACET_LIST;
+
+ CubitStatus rv =
+ OCCQueryEngine::instance()->import_facets( file_name, use_feature_angle, feature_angle, 0.0,
+ interp_order, smooth_non_manifold,
+ split_surfaces, stitch, improve, quad_facet_list,
+ new_facet_list, new_surface_list, file_format );
+
+ if(problem_list.size() > 0)
+ {
+ PRINT_WARNING("Offset process on facet body, may have resulted in %d overalapping facets.\n"
+ "Check results carefully. Problem facet(s) are displayed in red.)\n",
+ problem_list.size());
+ for (ii=0; ii<problem_list.size(); ii++)
+ {
+ facet_ptr = problem_list.get_and_step();
+ GfxDebug::draw_facet(facet_ptr, CUBIT_RED);
+ }
+ GfxDebug::flush();
+ }
+
+ if( new_surface_list.size() )
+ {
+ new_bodysm = new_surface_list.get()->bodysm();
+ if( !new_bodysm )
+ {
+ PRINT_ERROR("Problem offsetting Body\n");
+ return CUBIT_FAILURE;
+ }
+ }
+ else
+ {
+ PRINT_ERROR("Problem offsetting Body\n");
+ return CUBIT_FAILURE;
+ }
+ return rv;
+}
+
+CubitStatus OCCModifyEngine::webcut_with_sweep_surfaces(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Surface*> &surfaces,
+ const CubitVector& sweep_vector,
+ bool sweep_perp,
+ bool through_all,
+ bool outward,
+ bool up_to_next,
+ Surface *stop_surf,
+ Curve *curve_to_sweep_along,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCModifyEngine::webcut_with_sweep_curves(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Curve*> &curves,
+ const CubitVector& sweep_vector,
+ bool through_all,
+ Surface *stop_surf,
+ Curve *curve_to_sweep_along,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCModifyEngine::webcut_with_sweep_surfaces_rotated(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Surface*> &surfaces,
+ const CubitVector &point,
+ const CubitVector &sweep_axis,
+ double angle,
+ Surface *stop_surf,
+ bool up_to_next,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCModifyEngine::webcut_with_sweep_curves_rotated(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Curve*> &curves,
+ const CubitVector &point,
+ const CubitVector &sweep_axis,
+ double angle,
+ Surface *stop_surf,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint)
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCModifyEngine::scale( BodySM *&body, const CubitVector& factors )
+{
+ return OCCQueryEngine::instance()->scale( body, factors );
+}
+
+CubitStatus OCCModifyEngine::tolerant_imprint( DLIList<BodySM*> &bodies_in,
+ DLIList<BodySM*> &new_bodies ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+// EOF
Added: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,828 @@
+//-------------------------------------------------------------------------
+// Filename : OCCModifyEngine.hpp
+//
+// Purpose : ModifyEngine for faceted geometry
+//
+// Special Notes : Modeled after GeometryModifyEngine and AcisModifyEngine.
+//
+// Creator : John Fowler
+//
+// Creation Date : 6/02
+//
+// Owner : John Fowler
+//-------------------------------------------------------------------------
+
+#ifndef FACET_MODIFY_ENGINE_HPP
+#define FACET_MODIFY_ENGINE_HPP
+
+#include "GeometryModifyEngine.hpp"
+#include <vector>
+
+class Point;
+class TopologyBridge;
+class TopologyEntity;
+class ChollaSurface;
+class ChollaCurve;
+class ChollaPoint;
+class ChollaEngine;
+class CurveFacetEvalTool;
+class FacetEvalTool;
+class CubitPoint;
+class CubitFacet;
+class CubitFacetEdge;
+class CubitQuadFacet;
+class Point;
+class CoEdgeSM;
+class ShellSM;
+class OCCBody;
+class Body;
+class RefFace;
+class OCCSurface;
+class CubitEvaluatorData;
+class SphereEvaluatorData;
+class CylinderEvaluatorData;
+
+class OCCModifyEngine : public GeometryModifyEngine
+{
+
+public:
+
+ //HEADER- Constructor and Destructor
+private:
+
+ OCCModifyEngine();
+
+ static OCCModifyEngine* instance_;
+
+public:
+
+ static inline OCCModifyEngine* instance()
+ {
+ if( !instance_ )
+ instance_ = new OCCModifyEngine;
+ return instance_;
+ }
+
+ virtual ~OCCModifyEngine();
+ //- virtual destructor
+
+ virtual Point* make_Point( CubitVector const& point) const ;
+
+ virtual Curve* make_Curve(Curve *curve_ptr) const;
+ //- creates a curve from an existing curve. This creates totally
+ //- new topology. This function is useful for constructing geometry
+ //- from existing geometry.
+
+ virtual Curve* make_Curve( Point const* point1_ptr,
+ Point const* point2_ptr,
+ Surface* ref_face_ptr,
+ const CubitVector *third_point = NULL) const;
+ //- Create a curve exactly on the give ref_face.
+ //- Make sure the points are on the underlying surface.
+
+ virtual Curve* make_Curve( GeometryType curve_type,
+ Point const* point1_ptr,
+ Point const* point2_ptr,
+ DLIList<CubitVector*>& vector_list,
+ Surface* ref_face_ptr = NULL) const;
+
+ virtual Curve* make_Curve( GeometryType curve_type,
+ Point const* point1_ptr,
+ Point const* point2_ptr,
+ CubitVector const* intermediate_point_ptr,
+ CubitSense sense) const;
+
+
+ virtual Surface* make_Surface( Surface *old_surface_ptr,
+ CubitBoolean extended_from = CUBIT_FALSE) const;
+
+ virtual Surface* make_Surface( GeometryType surface_type,
+ DLIList<Curve*>& curve_list,
+ Surface *old_surface_ptr = NULL,
+ bool check_edges = true ) const;
+
+ virtual Lump* make_Lump( DLIList<Surface*>& surface_list ) const;
+
+ //virtual Body *make_Body(Surface *) const;
+
+ virtual BodySM* make_BodySM( Surface * ) const;
+
+ virtual BodySM* make_BodySM( DLIList<Lump*>& /*lump_list*/ ) const;
+
+ //virtual Chain *make_Chain(Curve *) const;
+
+ virtual BodySM* sphere(double radius) const ;
+
+ virtual BodySM* brick( double wid, double dep, double hi ) const ;
+
+ virtual BodySM* brick( const CubitVector ¢er,
+ const CubitVector axes[3],
+ const CubitVector &extension) const ;
+
+ virtual BodySM* prism( double height, int sides, double major,
+ double minor) const ;
+
+ virtual BodySM* pyramid( double height, int sides, double major,
+ double minor, double top=0.0) const ;
+
+ virtual BodySM* cylinder( double hi, double r1, double r2,
+ double r3 ) const ;
+
+ virtual BodySM* torus( double r1, double r2 ) const ;
+
+ virtual BodySM* planar_sheet ( const CubitVector& p1,
+ const CubitVector& p2,
+ const CubitVector& p3,
+ const CubitVector& p4 ) const;
+
+ virtual BodySM* copy_body ( BodySM* bodyPtr) const ;
+
+ virtual CubitStatus subtract(DLIList<BodySM*> &tool_body_list,
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_bodies,
+ bool keep_old = false) const;
+
+ virtual CubitStatus imprint(BodySM* BodyPtr1, BodySM* BodyPtr2,
+ BodySM*& newBody1, BodySM*& newBody2,
+ bool keep_old) const;
+
+ virtual CubitStatus imprint(DLIList<BodySM*> &from_body_list,
+ DLIList<BodySM*> &new_from_body_list,
+ bool keep_old) const;
+
+ virtual CubitStatus imprint( DLIList<BodySM*> &body_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool show_messages=CUBIT_TRUE) const;
+
+ virtual CubitStatus imprint( DLIList<Surface*> &ref_face_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body ) const;
+
+ virtual CubitStatus imprint( DLIList<Surface*> &surface_list,
+ DLIList<DLIList<Curve*>*> &curve_lists_list,
+ BodySM*& new_body,
+ bool keep_old_body ) const;
+
+ virtual CubitStatus imprint( DLIList<BodySM*> &body_list,
+ DLIList<CubitVector*> &vector_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body ) const;
+
+ virtual CubitStatus imprint_projected_edges( DLIList<Surface*> &ref_face_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool keep_free_edges) const;
+
+ virtual CubitStatus imprint_projected_edges(DLIList<Surface*> &ref_face_list,
+ DLIList<BodySM*> &body_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old_body,
+ bool keep_free_edges) const;
+
+ virtual CubitStatus project_edges( DLIList<Surface*> &ref_face_list,
+ DLIList<Curve*> &ref_edge_list_in,
+ DLIList<Curve*> &ref_edge_list_new,
+ bool print_error = true ) const;
+
+ virtual CubitStatus intersect(BodySM* tool_body_ptr,
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_bodies,
+ bool keep_old = CUBIT_FALSE) const;
+
+ virtual CubitStatus chop(DLIList<BodySM*> &bodies,
+ DLIList<BodySM*> &intersectBodies,
+ DLIList<BodySM*> &outsideBody,
+ BodySM*& leftoversBody,
+ bool keep_old = CUBIT_FALSE,
+ bool nonreg = CUBIT_FALSE) const;
+
+ virtual CubitStatus unite(DLIList<BodySM*> &bodies,
+ DLIList<BodySM*> &newBodies,
+ bool keep_old = CUBIT_FALSE) const;
+
+ virtual CubitStatus thicken(DLIList<BodySM*>& bodies,
+ DLIList<BodySM*>& new_bodies,
+ double depth,
+ bool both = CUBIT_FALSE) const ;
+
+ virtual CubitStatus flip_normals( DLIList<Surface*>& face_list ) const;
+
+ virtual CubitStatus sweep_translational(
+ DLIList<GeometryEntity*>& ref_ent_list,
+ DLIList<BodySM*>& result_body_list,
+ const CubitVector& sweep_vector,
+ double draft_angle,
+ int draft_type,
+ bool switchside,
+ bool rigid) const;
+
+ virtual CubitStatus sweep_perpendicular(
+ DLIList<GeometryEntity*>& ref_ent_list,
+ DLIList<BodySM*>& result_body_list,
+ double distance,
+ double draft_angle,
+ int draft_type,
+ bool switchside,
+ bool rigid) const;
+
+ virtual CubitStatus sweep_rotational(
+ DLIList<GeometryEntity*>& ref_ent_list,
+ DLIList<BodySM*>& result_body_list,
+ const CubitVector& point,
+ const CubitVector& direction,
+ double angle,
+ int steps = 0,
+ double draft_angle = 0.0,
+ int draft_type = 0,
+ bool switchside = CUBIT_FALSE,
+ bool make_solid = CUBIT_FALSE,
+ bool rigid = CUBIT_FALSE ) const;
+
+ virtual CubitStatus sweep_along_curve(
+ DLIList<GeometryEntity*>& ref_ent_list,
+ DLIList<BodySM*>& result_body_list,
+ DLIList<Curve*>& ref_edge_list,
+ double draft_angle = 0.0,
+ int draft_type = 0,
+ bool rigid = CUBIT_FALSE ) const;
+
+
+ virtual CubitStatus webcut_with_sweep_surfaces(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Surface*> &surfaces,
+ const CubitVector& sweep_vector,
+ bool sweep_perp,
+ bool through_all,
+ bool outward,
+ bool up_to_next,
+ Surface *stop_surf,
+ Curve *curve_to_sweep_along,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint = false);
+
+ virtual CubitStatus webcut_with_sweep_curves(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Curve*> &curves,
+ const CubitVector& sweep_vector,
+ bool through_all,
+ Surface *stop_surf,
+ Curve *curve_to_sweep_along,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint = false);
+
+ virtual CubitStatus webcut_with_sweep_curves_rotated(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Curve*> &curves,
+ const CubitVector &point,
+ const CubitVector &sweep_axis,
+ double angle,
+ Surface *stop_surf,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint = false);
+
+ virtual CubitStatus webcut_with_sweep_surfaces_rotated(
+ DLIList<BodySM*> &blank_bodies,
+ DLIList<Surface*> &surfaces,
+ const CubitVector &point,
+ const CubitVector &sweep_axis,
+ double angle,
+ Surface *stop_surf,
+ bool up_to_next,
+ DLIList<BodySM*> &results_list,
+ CubitBoolean imprint = false);
+
+ //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 ) const;
+
+ virtual CubitStatus webcut(DLIList<BodySM*>& webcut_body_list,
+ BodySM const* tool_body,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false ) const;
+
+ virtual CubitStatus webcut_across_translate( DLIList<BodySM*>& body_list,
+ Surface* plane_surf1,
+ Surface* plane_surf2,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false ) const;
+
+ virtual CubitStatus webcut_with_sheet(DLIList<BodySM*> &webcut_body_list,
+
+ BodySM *sheet_body,
+ DLIList<BodySM*> &new_bodies,
+ bool imprint = false );
+
+ virtual CubitStatus webcut_with_extended_surf(DLIList<BodySM*> &webcut_body_list,
+ Surface *extend_from,
+ DLIList<BodySM*> &new_bodies,
+ int &num_cut,
+ bool imprint = false );
+
+ virtual CubitStatus webcut_with_cylinder(DLIList<BodySM*> &webcut_body_list,
+ double radius,
+ const CubitVector &axis,
+ const CubitVector ¢er,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false );
+
+ virtual CubitStatus webcut_with_brick( DLIList<BodySM*>& webcut_body_list,
+ const CubitVector ¢er,
+ const CubitVector axes[3],
+ const CubitVector &extension,
+ DLIList<BodySM*> &results_list,
+ bool imprint = false );
+
+ virtual CubitStatus webcut_with_planar_sheet( DLIList<BodySM*>& webcut_body_list,
+ const CubitVector ¢er,
+ const CubitVector axes[2],
+ double width, double height,
+ DLIList<BodySM*> &results_list,
+ bool imprint = false );
+
+ virtual CubitStatus webcut_with_curve_loop(DLIList<BodySM*> &webcut_body_list,
+ DLIList<Curve*> &ref_edge_list,
+ DLIList<BodySM*>& results_list,
+ bool imprint = false );
+
+ virtual CubitStatus section( DLIList<BodySM*> §ion_body_list,
+ const CubitVector &point_1,
+ const CubitVector &point_2,
+ const CubitVector &point_3,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_normal_side,
+ bool keep_old = false,
+ bool keep_both_sides = false);
+
+ virtual CubitStatus split_body( BodySM *body_ptr,
+ DLIList<BodySM*> &new_bodies );
+
+ virtual CubitStatus reverse_body( BodySM *body_to_reverse );
+
+ virtual CubitStatus split_periodic( BodySM *body_ptr,
+ BodySM *&new_body );
+
+ virtual CubitStatus regularize_body( BodySM *body_ptr,
+ BodySM *&new_body_ptr );
+
+ virtual CubitStatus regularize_entity(GeometryEntity *old_entity_ptr,
+ BodySM *&new_body_ptr);
+
+ virtual CubitStatus offset_curves( DLIList<Curve*>& ref_edge_list,
+ DLIList<Curve*>& result_curve_list,
+ double offset_distance,
+ const CubitVector& offset_direction,
+ int gap_type = 1 );
+
+ virtual CubitStatus scale ( BodySM *&body, const CubitVector& factors );
+
+ virtual Curve* trim_curve( Curve* trim_curve,
+ const CubitVector& trim_vector,
+ const CubitVector& keep_vector,
+ bool keep_old = false );
+
+ virtual CubitStatus create_body_from_surfs(DLIList<Surface*> &ref_face_list,
+ BodySM *&new_body,
+ bool keep_old = false,
+ bool heal = false) const;
+
+ virtual Curve* create_arc_three( Point* ref_vertex1,
+ Point* ref_vertex2,
+ Point* ref_vertex3,
+ bool full = false );
+
+ virtual Curve* create_arc_three( Curve* ref_edge1,
+ Curve* ref_edge2,
+ Curve* ref_edge3,
+ bool full = false );
+
+ virtual Curve* create_arc_center_edge(
+ Point* ref_vertex1,
+ Point* ref_vertex2,
+ Point* ref_vertex3,
+ const CubitVector &normal,
+ double radius = CUBIT_DBL_MAX,
+ bool full = false );
+
+ virtual CubitStatus create_curve_combine( DLIList<Curve*>& curve_list,
+ Curve *&new_curve_ptr );
+ //- Uses the solid modeller to create a new RefEdge that is a combination
+ //- of the input chain of edges.
+ //-
+
+ virtual GeometryQueryEngine *get_gqe();
+
+ virtual CubitBoolean is_modify_engine(const TopologyBridge *tb_ptr) const;
+
+ virtual CubitStatus get_offset_intersections(
+ Curve* ref_edge1,
+ Curve* ref_edge2,
+ DLIList<CubitVector*>& intersection_list,
+ double offset,
+ bool ext_first = true );
+
+ virtual CubitStatus get_offset_intersections(
+ Curve* ref_edge_ptr,
+ Surface* ref_face_ptr,
+ DLIList<CubitVector*> &intersection_list,
+ double offset = 0.0,
+ bool ext_surf = true );
+
+ virtual CubitStatus surface_intersection( Surface *surface1_ptr,
+ Surface *surface2_ptr,
+ DLIList<Curve*> &inter_graph,
+ const double tol) const;
+
+ virtual CubitStatus get_mid_plane( const CubitVector &point_1,
+ const CubitVector &point_2,
+ const CubitVector &point_3,
+ BodySM *body_to_trim_to,
+ BodySM *&midplane_body ) const;
+
+ virtual CubitStatus tweak_chamfer( DLIList<Curve*> &curve_list,
+ double left_offset,
+ DLIList<BodySM*> &new_bodysm_list,
+ double right_offset = -1.0,
+ CubitBoolean keep_old_body = CUBIT_FALSE,
+ CubitBoolean preview = CUBIT_FALSE ) const;
+ /**< Chamfer curves on solid bodies. The left and right offsets are with
+ * respect to the curve direction. If the given right offset is negative,
+ * the left offset is used. Users can preview to clarify the meaning of
+ * left and right.
+ */
+
+ virtual CubitStatus tweak_chamfer( DLIList<Point*> &point_list,
+ double offset1,
+ DLIList<BodySM*> &new_bodysm_list,
+ Curve *edge1 = NULL,
+ double offset2 = -1.0,
+ Curve *edge2 = NULL,
+ double offset3 = -1.0,
+ Curve *edge3 = NULL,
+ CubitBoolean keep_old_body = CUBIT_FALSE,
+ CubitBoolean preview = CUBIT_FALSE ) const;
+ /**< Chamfer vertices on solid or sheet bodies. On a solid body there can
+ * be up to 3 offsets; on a sheet body up to 2 offsets. The offsets are
+ * in the direction of the supplied edges. If multiple vertices are
+ * supplied, only one offset value is allowed and the edges are not used.
+ */
+
+ virtual CubitStatus tweak_fillet( DLIList<Curve*> &curve_list,
+ double radius,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE,
+ CubitBoolean preview = CUBIT_FALSE ) const;
+ /**< Create a round fillet (or blend) at the given curves on solid bodies.
+ */
+
+ virtual CubitStatus tweak_fillet( Curve *curve_ptr,
+ double start_radius,
+ double end_radius,
+ BodySM *&new_body_ptr,
+ CubitBoolean keep_old_body = CUBIT_FALSE,
+ CubitBoolean preview = CUBIT_FALSE ) const;
+ /**< Create a round fillet (or blend) at the given curve on a solid body.
+ * The fillet has a variable radius from the start to the end of the curve.
+ */
+
+ virtual CubitStatus tweak_fillet( DLIList<Point*> &point_list,
+ double radius,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE,
+ CubitBoolean preview = CUBIT_FALSE ) const;
+ /**< Create a round fillet (or blend) at the given vertices on sheet bodies.
+ */
+
+ virtual CubitStatus tweak_move( DLIList<Surface*> &surface_list,
+ const CubitVector &delta,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified faces of a volume or volumes along a vector.
+ */
+
+ virtual CubitStatus tweak_move( DLIList<Curve*> &curve_list,
+ const CubitVector &delta,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified curves of a sheet body along a vector.
+ */
+
+ virtual CubitStatus tweak_offset( DLIList<Surface*> &surface_list,
+ double offset_distance,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified faces of a volume or volumes by offsetting those faces
+ * by the offset distance.
+ */
+
+ virtual CubitStatus tweak_offset( DLIList<Curve*> &curve_list,
+ double offset_distance,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified curves of a sheet body or bodies by offsetting those
+ * curves by the offset distance.
+ */
+
+ virtual CubitStatus tweak_remove( DLIList<Surface*> &surface_list,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean extend_adjoining = CUBIT_TRUE,
+ CubitBoolean keep_surface = CUBIT_FALSE,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Remove surfaces from a body or bodies and then extend the adjoining
+ * surfaces to fill the gap or remove the hole.
+ */
+
+ virtual CubitStatus tweak_remove( DLIList<Curve*> &curve_list,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Remove curves from a sheet body or bodies and then extend the remaining
+ * curves to fill the gap. If an internal loop of curves is removed the
+ * hole is removed.
+ */
+
+ virtual CubitStatus tweak_target( DLIList<Surface*> &surface_list,
+ Surface *target_surf_ptr,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean reverse_flg = CUBIT_FALSE,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified faces of a volume or volumes up to a target surface.
+ */
+
+ virtual CubitStatus tweak_target( DLIList<Curve*> &curve_list,
+ Surface *target_surf_ptr,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified edges of a surface or set of surfaces (in sheet
+ * bodies) up to a target surface. This essentially extends or
+ * trims the attached surfaces of the sheet body.
+ */
+
+ virtual CubitStatus tweak_target( DLIList<Curve*> &curve_list,
+ Curve *target_curve_ptr,
+ DLIList<BodySM*> &new_bodysm_list,
+ CubitBoolean keep_old_body = CUBIT_FALSE ) const;
+ /**< Tweak specified edges of a sheet body or bodies up to a target curve
+ * that is part of a sheet body. The target is a surface created by
+ * thickening the owning surface of the target curve.
+ */
+
+ virtual CubitStatus create_net_surface( DLIList<Surface*>& ref_face_list, BodySM *& new_body,
+ DLIList<DLIList<CubitVector*>*> &vec_lists_u,
+ DLIList<DLIList<CubitVector*>*> &vec_lists_v,
+ double net_tol = 1e-3,
+ CubitBoolean heal = CUBIT_TRUE ) const;
+
+ virtual CubitStatus create_net_surface( DLIList<Curve*>& u_curves, DLIList<Curve*>& v_curves,
+ BodySM *& new_body,
+ double net_tol = 1e-3,
+ CubitBoolean heal = CUBIT_TRUE ) const;
+
+ virtual CubitStatus create_offset_surface( Surface* ref_face_ptr, BodySM*& new_body, double offset_distance ) const;
+
+ virtual CubitStatus create_offset_body( BodySM* body_ptr, BodySM*& new_body, double offset_distance ) const;
+
+ virtual CubitStatus create_skin_surface( DLIList<Curve*>& curves, BodySM*& new_body ) const;
+
+ virtual CubitStatus loft_surfaces( Surface *face1, const double &takeoff1,
+ Surface *face2, const double &takeoff2,
+ BodySM*& new_body,
+ CubitBoolean arc_length_option = CUBIT_FALSE,
+ CubitBoolean twist_option = CUBIT_FALSE,
+ CubitBoolean align_direction = CUBIT_TRUE,
+ CubitBoolean perpendicular = CUBIT_TRUE,
+ CubitBoolean simplify_option = CUBIT_FALSE) const;
+
+ virtual CubitStatus loft_surfaces_to_body( Surface *face1, const double &takeoff1,
+ Surface *face2, const double &takeoff2,
+ BodySM*& new_body,
+ CubitBoolean arc_length_option,
+ CubitBoolean twist_option,
+ CubitBoolean align_direction,
+ CubitBoolean perpendicular,
+ CubitBoolean simplify_option) const;
+
+ virtual CubitStatus create_surface( DLIList<CubitVector*>& vec_list,
+ BodySM *&new_body,
+ Surface *ref_face_ptr,
+ CubitBoolean project_points ) const;
+
+ virtual CubitStatus create_weld_surface( CubitVector &root,
+ Surface *ref_face1, double leg1, Surface *ref_face2, double leg2,
+ BodySM *&new_body ) const;
+
+ //--------------------------------------------------------------
+ //- Methods for building specific facet-based geometry entities
+ //--------------------------------------------------------------
+ CubitStatus make_facet_point( CubitPoint *thePoint,
+ Point *&new_point_ptr );
+ CubitStatus make_facet_point( CubitVector &location,
+ Point *&new_point_ptr );
+ //- create a new facet point
+
+ CubitStatus make_facet_curve( Point *start_ptr,
+ Point *end_ptr,
+ Curve *&new_curve_ptr,
+ CurveFacetEvalTool *eval_tool_ptr = NULL);
+ CubitStatus make_facet_curve( Point *start_ptr,
+ Point *end_ptr,
+ DLIList<CubitFacetEdge*> &edge_list,
+ DLIList<CubitPoint*> &point_list,
+ Curve *&new_curve_ptr,
+ CurveFacetEvalTool *eval_tool_ptr = NULL);
+ //- create a new facet curve
+
+ CubitStatus make_facet_coedge( Curve *curv_ptr,
+ CubitSense sense,
+ CoEdgeSM *&new_coedge_ptr );
+ //- create a new facet coedge
+
+ CubitStatus make_facet_loop( DLIList<CoEdgeSM*> &coedge_list,
+ LoopSM *&new_loop_ptr );
+ //- create a new facet loop
+
+ CubitStatus make_facet_surface(const CubitEvaluatorData *eval_data,
+ DLIList<CubitFacet*> &facet_list,
+ DLIList<CubitPoint*> &point_list,
+ DLIList<LoopSM*> &my_loops,
+ int interp_order,
+ double min_dot,
+ Surface *&new_surface_ptr,
+ CubitBoolean use_point_addresses = CUBIT_TRUE,
+ FacetEvalTool *eval_tool_ptr = NULL);
+ //-creates a new OCCSurface given the points and facet list.
+
+ CubitStatus make_facet_surface(DLIList<CubitQuadFacet*> &facet_list,
+ DLIList<CubitPoint*> &point_list,
+ DLIList<LoopSM*> &my_loops,
+ int interp_order,
+ double min_dot,
+ Surface *&new_surface_ptr);
+ //-creates a new OCCSurface given the points and quad facet list.
+
+ CubitStatus make_facet_shell(DLIList<Surface*> &surface_list,
+ ShellSM *&new_shell_ptr);
+ //-creates a new shell, given the list of surfaces.
+
+ CubitStatus make_facet_lump(DLIList<ShellSM*> &shell_list,
+ Lump*& new_lump_ptr);
+ //-creates a new lump, given the list of shells.
+
+ CubitStatus make_facet_body(DLIList<Lump*> &lump_list,
+ BodySM *&new_body_ptr);
+ //-creates a new body, given the list of lump.
+
+ CubitStatus build_facet_surface( const CubitEvaluatorData **eval_data,
+ DLIList<CubitFacet *> &facet_list,
+ DLIList<CubitPoint *> &point_list,
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list);
+ CubitStatus build_facet_surface( DLIList<CubitQuadFacet *> &qfacet_list,
+ DLIList<CubitFacet *> &tfacet_list,
+ DLIList<CubitPoint *> &point_list,
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list);
+ CubitStatus build_facet_surface( DLIList<CubitQuadFacet *> &facet_list,
+ DLIList<CubitPoint *> &point_list,
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ DLIList<Surface *> &surface_list);
+ //- creates one or more new OCCSurfaces with all of its lower
+ //- order entities. Use an optional feature_angle to break
+ //- surface
+
+ CubitStatus smooth_facets( RefFace *ref_face_ptr, int niter, CubitBoolean free_laplacian );
+ //- attempt to clean up facets by smoothing the points on the surface
+ CubitStatus create_shell_offset( BodySM *bodysm_ptr, BodySM *&new_bodysm, double offset );
+ // create a shell offset from body
+ CubitStatus improve_facets( RefFace *ref_face_ptr );
+ // improve the facets by local swaps
+
+ CubitStatus build_cholla_surfaces( DLIList<CubitFacet *> facet_list,
+ DLIList<CubitPoint *> point_list,
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ ChollaEngine *&cholla_ptr );
+
+/* virtual CubitStatus finish_facet_Body(
+ GeometryType surface_type,
+ const CubitEvaluatorData *eval_data,
+ DLIList <CubitFacet *>facet_list,
+ DLIList <CubitPoint *>point_list,
+ double feature_angle,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ BodySM *&body_ptr) const;
+*/
+ virtual CubitStatus finish_facet_Body( ChollaEngine *&cholla_ptr,
+ const CubitEvaluatorData **eval_data,
+ double feature_angle,
+ int interp_order,
+ BodySM *&bodysm_ptr) const;
+
+ void set_sphere_eval_data( ChollaEngine *cholla_ptr,
+ double radius,
+ CubitEvaluatorData **&eval_data ) const;
+
+ void set_cylinder_eval_data( ChollaEngine *cholla_ptr,
+ double height,
+ double base_radius_xdir,
+ double base_radius_ydir,
+ double top_radius,
+ CubitEvaluatorData **&eval_data ) const;
+
+ // non-virtual specific functions for building facet-based geometry
+ // from Cholla geometry
+
+ CubitStatus build_cholla_geometry(
+ const CubitEvaluatorData **eval_data,
+ DLIList<ChollaSurface*> &cholla_surface_list,
+ DLIList<ChollaCurve*> &cholla_curve_list,
+ DLIList<ChollaPoint*> &cholla_point_list,
+ CubitBoolean use_feature_angle,
+ double feature_angle,
+ int interp_order,
+ DLIList<Surface *> &surface_list);
+ // build the CUBIT geometry based on the Cholla entity class lists
+
+ CubitStatus build_cholla_point_geometry(
+ DLIList<ChollaPoint*> &cholla_point_list );
+ // From the cholla point list, create geometric points for each
+
+ CubitStatus build_cholla_curve_geometry(
+ DLIList<ChollaCurve*> &cholla_curve_list );
+ // From the cholla curve list, create geometric curves for each
+
+ CubitStatus build_cholla_surface_geometry(
+ const CubitEvaluatorData **eval_data,
+ DLIList<ChollaSurface*> &cholla_surface_list,
+ int interp_order,
+ double min_dot,
+ DLIList<Surface *> &surface_list);
+ // From the facet surface list, create geometric surface,
+ // loops and coedges for each surface in the list
+
+ CubitStatus tolerant_imprint( DLIList<BodySM*> &bodies_in,
+ DLIList<BodySM*> &new_bodies ) const;
+
+protected:
+
+private:
+
+ CubitStatus build_cholla_loop_geometry(
+ DLIList<ChollaCurve*> &cholla_curve_list,
+ ChollaSurface *chsurf_ptr,
+ DLIList<LoopSM*> &loop_list,
+ int &ncurves,
+ int debug_draw = 0 );
+ // From the cholla curve list of a surface, create geometric loops
+
+ void fillinedge(
+ int *edge,
+ int numpointsonanedge,
+ double radius,
+#ifdef CANT_USE_STD
+ vector<CubitPoint *>& points) const;
+#else
+ std::vector<CubitPoint *>& points) const;
+#endif
+ //! Put points on this edge of a triangle being refined.
+
+ void refinetriangle(
+ int level,
+ int numpointsonanedge,
+ int *iedge1,
+ int *iedge2,
+ int *iedge3,
+ int isign1,
+ int isign2,
+ int isign3,
+ double radius,
+#ifdef CANT_USE_STD
+ vector<CubitPoint *>& points,
+#else
+ std::vector<CubitPoint *>& points,
+#endif
+ DLIList<CubitFacet *>& facet_list) const;
+ //! add internal points and make connections for this triangle
+} ;
+
+#endif
Added: cgm/trunk/geom/OCC/OCCParamTool.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCParamTool.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCParamTool.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,442 @@
+//===================================================================================
+//
+// File: OCCParamTool.cpp
+//
+// Descripiton: interface for 3D-2D parameterization algorithms
+//
+//===================================================================================
+
+
+#include "OCCParamTool.hpp"
+#include "CastTo.hpp"
+#include "Surface.hpp"
+#include "OCCSurface.hpp"
+#include "FacetEvalTool.hpp"
+#include "FacetorTool.hpp"
+#include "CubitPoint.hpp"
+#include "CubitPointData.hpp"
+#include "CubitFacet.hpp"
+#include "CubitFacetData.hpp"
+#include "CubitBox.hpp"
+#include "TDFacetBoundaryPoint.hpp"
+
+#ifdef ROADKILL
+#include "ParamManager.hpp"
+#endif
+
+#define DETERM(p1,q1,p2,q2,p3,q3)\
+ ((q3)*((p2)-(p1)) + (q2)*((p1)-(p3)) + (q1)*((p3)-(p2)))
+#define INSIDE_TOL 1.0e-6
+
+//===================================================================================
+// Function: OCCParamTool (Public)
+// Description: Constructor
+// Author: chynes
+// Date: 1/02
+//===================================================================================
+OCCParamTool::OCCParamTool(int numn, int nume, double* nodes, int* tri)
+{}
+
+
+//-------------------------------------------------------------------------
+// Function: OCCParamTool
+// Description: constructor
+// Author: chynes
+// Date: 7/10/2002
+//-------------------------------------------------------------------------
+OCCParamTool::OCCParamTool(Surface *surf)
+{
+ refSurf = surf;
+}
+
+//===================================================================================
+// Function: ~OCCParamTool
+// Description: Deconstructor
+// Author: chynes
+// Date: 1/02
+//===================================================================================
+OCCParamTool::~OCCParamTool() {}
+
+//===================================================================================
+// Function: set_up_space (Public)
+// Description: sets up space of flattening, flattens, and then updates surface
+// Author: chynes
+// Date: 7/10/02
+//===================================================================================
+CubitStatus OCCParamTool::set_up_space()
+{
+#ifdef ROADKILL
+ FacetEvalTool *fetool = CAST_TO(refSurf, OCCSurface)->get_eval_tool();
+
+ if ((fetool->loops())->size() != 1)
+ {
+ PRINT_WARNING("Cannot parameterize surface. Multiple loops detected\n");
+ return CUBIT_FAILURE;
+ }
+
+ DLIList<CubitPoint *> my_point_list;
+ fetool->get_points(my_point_list);
+ DLIList<CubitFacet *> my_facet_list;
+ fetool->get_facets(my_facet_list);
+
+ // make arrays out of the points and facets
+ double *points = new double [3 * my_point_list.size()];
+ int *facets = new int [3 * my_facet_list.size()];
+ if (!points || !facets)
+ {
+ PRINT_ERROR("Could not define parameterization for surface (out of memory)\n");
+ return CUBIT_FAILURE;
+ }
+ int ii;
+ CubitPoint *pt;
+ my_point_list.reset();
+ for (ii=0; ii<my_point_list.size(); ii++)
+ {
+ pt = my_point_list.get_and_step();
+ points[ii*3] = pt->x();
+ points[ii*3+1] = pt->y();
+ points[ii*3+2] = pt->z();
+ pt->marked(ii);
+ }
+ CubitFacet *facet;
+ CubitPoint *pts[3];
+ for (ii=0; ii<my_facet_list.size(); ii++)
+ {
+ facet = my_facet_list.get_and_step();
+ facet->points( pts[0], pts[1], pts[2] );
+ facets[ii*3] = pts[0]->marked();
+ facets[ii*3+1] = pts[1]->marked();
+ facets[ii*3+2] = pts[2]->marked();
+ }
+
+ //debug, export facets
+// export_facets(my_point_list.size(), my_facet_list.size(), points, facets);
+// PRINT_ERROR("Debugging Failure. Please remove export_facets from OCCParamTool\n");
+// return CUBIT_FAILURE;
+
+ // do the parameterization
+ ParamManager parammanager( my_point_list.size(), my_facet_list.size(),
+ points, facets );
+ if(!parammanager.flatten())
+ {
+ PRINT_ERROR("Surface Parameterizer Failed\n");
+ return CUBIT_FAILURE;
+ }
+ else
+ {
+ double ratio;
+ double *sizes;
+ parammanager.build_sizing();
+ double *uv = parammanager.get_uvs_sizing( ratio, sizes );
+
+ // update the points with uvs values
+
+ TDFacetBoundaryPoint *td_fbp;
+ CubitBoolean on_internal_boundary;
+ my_point_list.reset();
+ for (ii=0; ii<my_point_list.size(); ii++)
+ {
+ pt = my_point_list.get_and_step();
+ DLIList <CubitFacet *> facet_list;
+ pt->facets_on_surf( fetool->tool_id(), facet_list, on_internal_boundary );
+ if (on_internal_boundary)
+ {
+ td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( pt );
+ if (!td_fbp)
+ {
+ TDFacetBoundaryPoint::add_facet_boundary_point( pt );
+ td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( pt );
+ td_fbp->add_surf_facets( facet_list );
+ td_fbp->set_uvs( facet_list.get(), uv[ii*2], uv[ii*2+1], sizes[ii]);
+ }
+ else
+ {
+ if (td_fbp->set_uvs( facet_list.get(),
+ uv[ii*2], uv[ii*2+1], sizes[ii] ) != CUBIT_SUCCESS)
+ {
+ td_fbp->add_surf_facets( facet_list );
+ td_fbp->set_uvs( facet_list.get(), uv[ii*2], uv[ii*2+1], sizes[ii]);
+ }
+ }
+ }
+ else
+ {
+ pt->set_uvs( uv[ii*2], uv[ii*2+1], sizes[ii]);
+ }
+ }
+
+ PRINT_INFO("Surface Parameterization succeeded\n");
+ delete [] sizes;
+ delete [] uv;
+
+ }
+
+ // clean up
+
+ delete [] points;
+ delete [] facets;
+ return CUBIT_SUCCESS;
+
+#else
+ return CUBIT_FAILURE;
+#endif
+
+}
+
+//===================================================================================
+// Function: transform_to_uv (Public)
+// Description: same as title, set_up_space must have been already called
+// the local sizing will be returned in the z coord
+// of the uv location vector
+// Author: chynes
+// Date: 7/10/02
+//===================================================================================
+CubitStatus OCCParamTool::transform_to_uv(CubitVector &xyz_location, CubitVector &uv_location)
+{
+ DLIList<CubitFacet *> facet_list;
+ FacetEvalTool *fetool;
+ CubitFacet *tri_ptr;
+ CubitBoolean outside = CUBIT_FALSE;
+ CubitVector closest_point;
+ CubitVector area_coord;
+ double u, v, s;
+ double compare_tol;
+
+ // find best compare_tol
+ fetool = CAST_TO(refSurf, OCCSurface)->get_eval_tool();
+ compare_tol = 1e-3*(fetool->bounding_box().diagonal().length());
+
+ // locate point
+ CubitStatus rv = CUBIT_SUCCESS;
+ fetool->get_facets(facet_list);
+ rv = FacetEvalTool::project_to_facets(facet_list,
+ tri_ptr,
+ 0,
+ compare_tol,
+ xyz_location,
+ CUBIT_FALSE,
+ &outside,
+ &closest_point,
+ NULL);
+ // determine barycentric coordinates for in facet
+ if(rv == CUBIT_SUCCESS)
+ {
+ FacetEvalTool::facet_area_coordinate(tri_ptr, closest_point, area_coord);
+
+ // extract data
+ double u0, u1, u2, v0, v1, v2, s0, s1, s2;
+ CubitPoint *p0, *p1, *p2;
+ tri_ptr->points(p0, p1, p2);
+ p0->get_uvs(tri_ptr, u0, v0, s0);
+ p1->get_uvs(tri_ptr, u1, v1, s1);
+ p2->get_uvs(tri_ptr, u2, v2, s2);
+
+ // determine u coordinate
+ u = (area_coord.x()*u0) + (area_coord.y()*u1) + (area_coord.z()*u2);
+
+ // determine v coordinate
+ v = (area_coord.x()*v0) + (area_coord.y()*v1) + (area_coord.z()*v2);
+
+ // determine sizing
+ s = (area_coord.x()*s0) + (area_coord.y()*s1) + (area_coord.z()*s2);
+
+ uv_location.set(u,v,s);
+ }
+
+ return rv;
+}
+
+//===================================================================================
+// Function: transform_to_xyz (Public)
+// Description: same as title
+// Author: chynes
+// Date: 7/10/02
+//===================================================================================
+CubitStatus OCCParamTool::transform_to_xyz(CubitVector &xyz_location, CubitVector &uv_location)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+ CubitFacet *tri_ptr;
+ OCCSurface *facet_surf = CAST_TO(refSurf, OCCSurface);
+ CubitVector area_coord;
+ double x, y, z;
+
+ //locate point
+ rv = locate_point_in_uv(facet_surf, uv_location, tri_ptr);
+
+ if(rv == CUBIT_SUCCESS)
+ {
+ // create uv facet
+ CubitPoint* uvpoint_array[3];
+ DLIList<CubitPoint *> point_list;
+ CubitPoint *pt_ptr;
+ double u,v;
+ int ii;
+ tri_ptr->points(point_list);
+ for(ii = 0; ii<3; ii++)
+ {
+ pt_ptr = point_list.get_and_step();
+ pt_ptr->get_uv(tri_ptr, u, v);
+ uvpoint_array[ii] = (CubitPoint *) new CubitPointData(u, v, 0.0);
+ }
+ CubitFacet *uvfacet_ptr = (CubitFacet *) new CubitFacetData( uvpoint_array[0],
+ uvpoint_array[1],
+ uvpoint_array[2] );
+
+ // determine barycentric coordinates of uv point in uv facet
+ FacetEvalTool::facet_area_coordinate(uvfacet_ptr, uv_location, area_coord);
+
+ //delete created objects
+ delete uvfacet_ptr;
+ for(ii = 0; ii<3; ii++)
+ {
+ pt_ptr = uvpoint_array[ii];
+ delete pt_ptr;
+ }
+
+ CubitPoint *p0, *p1, *p2;
+ CubitVector coord0, coord1, coord2;
+ tri_ptr->points(p0,p1,p2);
+ coord0 = p0->coordinates();
+ coord1 = p1->coordinates();
+ coord2 = p2->coordinates();
+
+ //determine x coordinate
+ x = (area_coord.x()*coord0.x())
+ + (area_coord.y()*coord1.x())
+ + (area_coord.z()*coord2.x());
+ //determine y coordinate
+ y = (area_coord.x()*coord0.y())
+ + (area_coord.y()*coord1.y())
+ + (area_coord.z()*coord2.y());
+ //determine z coordinate
+ z = (area_coord.x()*coord0.z())
+ + (area_coord.y()*coord1.z())
+ + (area_coord.z()*coord2.z());
+
+ xyz_location.set(x,y,z);
+
+ }
+
+ return rv;
+}
+
+
+//===================================================================================
+// Function: locate_point_in_uv (Public)
+// Description: same as title (the_point must have coords (u,v,0.0))
+// Author: chynes
+// Date: 7/10/02
+//===================================================================================
+CubitStatus OCCParamTool::
+locate_point_in_uv(OCCSurface *surf, CubitVector &the_point, CubitFacet *&tri_ptr)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ DLIList<CubitFacet *> facet_list;
+ int tool_id = surf->get_eval_tool()->tool_id();
+ surf->get_eval_tool()->get_facets(facet_list);
+ tri_ptr = facet_list.get();
+
+ // loop until we find something
+
+ CubitPoint *p0, *p1, *p2;
+ double aa, bb, cc;
+ double u0, u1, u2, v0, v1, v2;
+ CubitBoolean found = CUBIT_FALSE;
+ while(!found && rv == CUBIT_SUCCESS)
+ {
+ tri_ptr->points(p0, p1, p2);
+ p0->get_uv(tri_ptr, u0, v0);
+ p1->get_uv(tri_ptr, u1, v1);
+ p2->get_uv(tri_ptr, u2, v2);
+ aa = DETERM(the_point.x(), the_point.y(), u1, v1, u2, v2);
+ bb = DETERM(u0, v0, the_point.x(), the_point.y(), u2, v2);
+ cc = DETERM(u0, v0, u1, v1, the_point.x(), the_point.y());
+ if (aa > -INSIDE_TOL &&
+ bb > -INSIDE_TOL &&
+ cc > -INSIDE_TOL)
+ {
+ found = CUBIT_TRUE; // this is the one
+ }
+ else
+ {
+ // set up to check the next logical neighbor
+ if (aa <= bb && aa <= cc) {
+ int edge_index = 1;
+ tri_ptr = tri_ptr->adjacent( edge_index, &tool_id );
+ }
+ else if (bb <= aa && bb <= cc) {
+ int edge_index = 2;
+ tri_ptr = tri_ptr->adjacent( edge_index, &tool_id );
+ }
+ else {
+ int edge_index = 0;
+ tri_ptr = tri_ptr->adjacent( edge_index, &tool_id);
+ }
+ // check to see if we've left the triangulation
+
+ if (tri_ptr == NULL)
+ {
+ rv = exhaustive_locate_point_in_uv(surf, the_point, tri_ptr );
+ found = CUBIT_TRUE;
+ }
+ }
+ }
+
+ return rv;
+}
+//===================================================================================
+// Function: exhaustive_locate_point_in_uv (Public)
+// Description: same as title
+// Author: chynes
+// Date: 7/10/02
+//===================================================================================
+CubitStatus OCCParamTool::
+exhaustive_locate_point_in_uv(OCCSurface *surf, CubitVector &the_point, CubitFacet *&tri_ptr)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ DLIList<CubitFacet *> facet_list;
+ surf->get_eval_tool()->get_facets(facet_list);
+
+ // loop until we find something
+
+ CubitPoint *p0, *p1, *p2;
+ int ii;
+ double aa, bb, cc;
+ double u0, u1, u2, v0, v1, v2;
+ CubitBoolean found = CUBIT_FALSE;
+ for(ii = 0; ii < facet_list.size() && !found; ii++)
+ {
+ tri_ptr = facet_list.get_and_step();
+ tri_ptr->points(p0, p1, p2);
+ p0->get_uv(tri_ptr, u0, v0);
+ p1->get_uv(tri_ptr, u1, v1);
+ p2->get_uv(tri_ptr, u2, v2);
+ aa = DETERM(the_point.x(), the_point.y(), u1, v1, u2, v2);
+ bb = DETERM(u0, v0, the_point.x(), the_point.y(), u2, v2);
+ cc = DETERM(u0, v0, u1, v1, the_point.x(), the_point.y());
+ if (aa > -INSIDE_TOL &&
+ bb > -INSIDE_TOL &&
+ cc > -INSIDE_TOL)
+ {
+ found = CUBIT_TRUE; // this is the one
+ }
+ }
+ if (!found)
+ {
+ rv = CUBIT_FAILURE;
+ tri_ptr = NULL;
+ }
+ return rv;
+}
+
+//===================================================================================
+// Function: flatten
+// Description: accessor function to the parameterization algorithms
+// Author: chynes
+// Date: 1/02
+//====================================================================================
+
+
+//EOF
Added: cgm/trunk/geom/OCC/OCCParamTool.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCParamTool.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCParamTool.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,62 @@
+//-----------------------------------------------------------------------------
+//
+// File:OCCParamTool.hpp
+//
+// Purpose: interface for 3D-2D parameterization algorithms for facets
+//
+//
+//-----------------------------------------------------------------------------
+
+
+
+#ifndef FACET_PARAM_TOOL_HPP
+#define FACET_PARAM_TOOL_HPP
+
+#include "ParamTool.hpp"
+class Surface;
+class OCCSurface;
+class CubitFacet;
+class CubitVector;
+
+class OCCParamTool : public ParamTool
+{
+
+public:
+ OCCParamTool(int numn, int nume, double* nodes, int* tri);
+ //~constructor
+ OCCParamTool(Surface *surf);
+ //- constructor
+
+ ~OCCParamTool();
+ //~deconstructor
+
+ CubitStatus set_up_space(void);
+
+ CubitStatus transform_to_uv(CubitVector &xyz_location, CubitVector &uv_location);
+
+ CubitStatus transform_to_xyz(CubitVector &xyz_location, CubitVector &uv_location);
+
+ CubitStatus locate_point_in_uv(OCCSurface *surf, CubitVector &the_point, CubitFacet *&tri_ptr);
+
+ CubitStatus exhaustive_locate_point_in_uv(OCCSurface *surf, CubitVector &the_point, CubitFacet *&tri_ptr);
+
+#ifdef BOYD14
+ CubitStatus export_facets(int numn, int numf, double *points, int *facets);
+ // - debug function for testing inputs to roadkill
+
+ int flatten();
+ //accessor function to the parameterization algorithms
+
+ double* get_uvs_sizing(double& ratio, double*& sizings);
+ //after calling flatten, returns an array of the u,v parameters, accessing
+ //d_flat_mesh
+#endif
+private:
+
+ Surface *refSurf;
+ //- reference surface
+
+};
+
+#endif
+
Added: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,458 @@
+//-------------------------------------------------------------------------
+// Filename : OCCPoint.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 07/15/00
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+#include <assert.h>
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitMessage.hpp"
+#include "OCCPoint.hpp"
+#include "OCCAttrib.hpp"
+#include "CubitPoint.hpp"
+#include "CubitPointData.hpp"
+#include "RefVertex.hpp"
+#include "OCCQueryEngine.hpp"
+#include "CastTo.hpp"
+#include "Curve.hpp"
+
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCLoop.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCCurve.hpp"
+
+#include <BRep_Tool.hxx>
+
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the associated VERTEX .
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+OCCPoint::OCCPoint( CubitVector &location, DLIList<Curve*> &curves )
+{
+ assert(0);
+ myPoint = (CubitPoint *) new CubitPointData( location );
+ myCurves += curves;
+ iCreated = CUBIT_TRUE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the associated CubitPoint .
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 12/28/00
+//-------------------------------------------------------------------------
+OCCPoint::OCCPoint( CubitPoint *thePoint, DLIList<Curve*> &curves )
+{
+ assert(0);
+ myPoint = thePoint;
+ myCurves += curves;
+ iCreated = CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the associated CubitPoint .
+//
+// Special Notes : Was make especially for save/restore
+//
+// Creator : Corey Ernst
+//
+// Creation Date : 02/03/03
+//-------------------------------------------------------------------------
+OCCPoint::OCCPoint( CubitPoint *thePoint )
+{
+ assert(0);
+ myPoint = thePoint;
+ iCreated = CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the associated TopoDS_Vertex .
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 12/28/00
+//-------------------------------------------------------------------------
+OCCPoint::OCCPoint( TopoDS_Vertex *thePoint, DLIList<Curve*> &curves )
+{
+ assert(0);
+ myTopoDSVertex = thePoint;
+ myCurves += curves;
+ iCreated = CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the associated TopoDS_Vertex .
+//
+// Special Notes : Was make especially for save/restore
+//
+// Creator : Corey Ernst
+//
+// Creation Date : 02/03/03
+//-------------------------------------------------------------------------
+OCCPoint::OCCPoint( TopoDS_Vertex *thePoint )
+{
+ myTopoDSVertex = thePoint;
+ iCreated = CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The destructor.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+OCCPoint::~OCCPoint()
+{
+ if (iCreated && myPoint != NULL)
+ {
+ delete myPoint;
+ }
+ myPoint = NULL;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the GE. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+void OCCPoint::append_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.append_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+void OCCPoint::remove_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.remove_attribute(csa); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+void OCCPoint::remove_all_simple_attribute_virt()
+ { attribSet.remove_all_attributes(); }
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+CubitStatus OCCPoint::get_simple_attribute(DLIList<CubitSimpleAttrib*>&
+ csa_list)
+ { return attribSet.get_attributes(csa_list); }
+CubitStatus OCCPoint::get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& csa_list )
+ { return attribSet.get_attributes( name, csa_list ); }
+
+CubitStatus OCCPoint::save_attribs( FILE *file_ptr )
+ { return attribSet.save_attributes(file_ptr); }
+
+CubitStatus OCCPoint::restore_attribs( FILE *file_ptr, unsigned int endian )
+ { return attribSet.restore_attributes(file_ptr, endian); }
+
+
+//-------------------------------------------------------------------------
+// Purpose : Returns the coordinates of this Point.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+CubitVector OCCPoint::coordinates() const
+{
+ gp_Pnt Point = BRep_Tool::Pnt(*myTopoDSVertex);
+ CubitVector p(Point.X(), Point.Y(), Point.Z());
+ return p;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: AcisGeometryEngine
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+GeometryQueryEngine* OCCPoint::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get the bounding box of the object.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 07/16/00
+//-------------------------------------------------------------------------
+CubitBox OCCPoint::bounding_box() const
+{
+ CubitVector temp_vector = this->coordinates();
+ CubitBox temp_box(temp_vector);
+ return temp_box;
+}
+
+
+/*
+void OCCPoint::bodysms(DLIList<BodySM*> &bodies)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->bodysms(bodies);
+ }
+}
+
+void OCCPoint::lumps(DLIList<Lump*> &lumps)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->lumps(lumps);
+ }
+}
+
+void OCCPoint::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->shellsms(shellsms);
+ }
+}
+
+void OCCPoint::surfaces(DLIList<Surface*> &surfaces)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->surfaces(surfaces);
+ }
+}
+
+void OCCPoint::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->loopsms(loopsms);
+ }
+}
+
+void OCCPoint::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ myCurves.get_and_step()->coedgesms(coedgesms);
+ }
+}
+
+
+void OCCPoint::curves(DLIList<Curve*> &curves)
+{
+ int ii;
+ for ( ii = myCurves.size(); ii > 0; ii-- )
+ {
+ curves.append_unique( myCurves.get_and_step() );
+ }
+}
+
+void OCCPoint::points(DLIList<Point*> &points)
+{
+ points.append_unique( this );
+}
+*/
+
+
+void OCCPoint::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { CAST_LIST_TO_PARENT( myCurves, parents ); }
+void OCCPoint::get_children_virt( DLIList<TopologyBridge*>& )
+ { }
+
+
+void OCCPoint::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ get_shells( shell_list );
+ shell_list.reset();
+ for ( int i = shell_list.size(); i--; )
+ {
+ OCCShell* shell = shell_list.get_and_step();
+ shell->get_lumps( result_list );
+ OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
+ if (lump)
+ result_list.append_unique(lump);
+ }
+}
+
+void OCCPoint::get_shells( DLIList<OCCShell*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ DLIList<OCCShell*> temp_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = surface_list.size(); i--; )
+ {
+ OCCSurface* surface = surface_list.get_and_step();
+ temp_list.clean_out();
+ surface->get_shells( temp_list );
+ result_list.merge_unique( temp_list );
+ }
+}
+
+void OCCPoint::get_surfaces( DLIList<OCCSurface*>& result_list )
+{
+ DLIList<OCCLoop*> loop_list;
+ get_loops( loop_list );
+ loop_list.reset();
+ for ( int i = loop_list.size(); i--; )
+ {
+ OCCLoop* loop = loop_list.get_and_step();
+ OCCSurface* surface = dynamic_cast<OCCSurface*>(loop->get_surface());
+ if (surface)
+ result_list.append_unique(surface);
+ }
+}
+
+void OCCPoint::get_loops( DLIList<OCCLoop*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCLoop* loop = dynamic_cast<OCCLoop*>(coedge->get_loop());
+ if (loop)
+ result_list.append_unique(loop);
+ }
+}
+
+void OCCPoint::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ DLIList<OCCCurve*> curve_list;
+ get_curves( curve_list );
+ curve_list.reset();
+ for ( int i = curve_list.size(); i--; )
+ curve_list.get_and_step()->get_coedges( result_list );
+}
+
+void OCCPoint::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ myCurves.reset();
+ for ( int i = 0; i < myCurves.size(); i++ )
+ if ( OCCCurve* curve = dynamic_cast<OCCCurve*>(myCurves.next(i)) )
+ result_list.append(curve);
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus OCCPoint::disconnect_curve (OCCCurve* curve)
+{
+ assert(0);
+ if (!myCurves.move_to(curve))
+ return CUBIT_FAILURE;
+ myCurves.remove();
+
+ if (curve->start_point() == this)
+ curve->remove_start_point();
+
+ if (curve->end_point() == this)
+ curve->remove_end_point();
+
+ return CUBIT_SUCCESS;
+}
+
+
+// ********** END PUBLIC FUNCTIONS **********
+
+// ********** BEGIN PROTECTED FUNCTIONS **********
+// ********** END PROTECTED FUNCTIONS **********
+
+// ********** BEGIN PRIVATE FUNCTIONS **********
+// ********** END PRIVATE FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASSES **********
+// ********** END HELPER CLASSES **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN STATIC FUNCTIONS **********
+// ********** END STATIC FUNCTIONS **********
Added: cgm/trunk/geom/OCC/OCCPoint.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCPoint.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,203 @@
+//-------------------------------------------------------------------------
+// Filename : OCCPoint.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Steven J. Owen
+//
+// Creation Date : 08/02/96
+//
+// Owner : Steven J. Owen
+//-------------------------------------------------------------------------
+
+#ifndef POINT_FACET_HPP
+#define POINT_FACET_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "Point.hpp"
+#include "OCCAttribSet.hpp"
+#include <TopoDS_Vertex.hxx>
+#include <gp_Pnt.hxx>
+
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS **********
+class TopologyEntity;
+class CubitSimpleAttrib;
+class RefVertex;
+class RefVolume;
+class RefVolume;
+class CubitPoint;
+class OCCAttrib;
+
+class OCCBody;
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCoEdge;
+class OCCCurve;
+
+// ********** END FORWARD DECLARATIONS **********
+
+class OCCPoint : public Point
+{
+private:
+
+ DLIList<Curve*> myCurves;
+ CubitPoint *myPoint;
+ CubitBoolean iCreated;
+ TopoDS_Vertex *myTopoDSVertex;
+
+ OCCAttribSet attribSet;
+ //List of OCCAttrib*'s instead of CubitSimpleAttribs
+
+public :
+
+ OCCPoint(CubitVector &location, DLIList<Curve*> &curves );
+ //I- CubitVector &location
+ //I- location of point (creates a CubiPoint).
+ //I- DLIList<Curve*> curves
+ //I- curves attaced to point
+
+ OCCPoint(CubitPoint *thePoint, DLIList<Curve*> &curves );
+ //I- CubitPoint *thePoint
+ //I- pointer to the CubitPoint associated with OCCPoint
+ //I- DLIList<Curve*> curves
+ //I- curves attaced to point
+
+ OCCPoint(CubitPoint *thePoint );
+ //I- CubitPoint *thePoint
+ //I- pointer to the CubitPoint associated with OCCPoint
+
+ OCCPoint(TopoDS_Vertex *thePoint, DLIList<Curve*> &curves );
+ //I- TopoDS_Vertex *thePoint
+ //I- pointer to the TopoDS_Vertex associated with OCCPoint
+ //I- DLIList<Curve*> curves
+ //I- curves attaced to point
+
+ OCCPoint(TopoDS_Vertex *thePoint );
+ //I- TopoDS_Vertex *thePoint
+ //I- pointer to the TopoDS_Vertex associated with OCCPoint
+
+ virtual ~OCCPoint();
+ //- The destructor
+
+#ifdef BOYD14
+ OCCPoint *copy();
+ // make a new copy of this point and return it
+#endif
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual CubitVector coordinates() const;
+ //R CubitVector
+ //R- Contains the coordinate values {x y z} of this Point
+ //- Returns the spatial coordinates of this Point.
+
+ virtual CubitBox bounding_box() const ;
+ // see comments in GeometryEntity.hpp
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+#ifdef BOYD14
+ CubitStatus move( CubitVector &delta );
+ //- Move the first vertex's point by the delta.
+#endif
+
+ void add_curve( Curve* curv_ptr )
+ { myCurves.append_unique( curv_ptr ); }
+ // associate this point with a curve
+
+ CubitPoint *get_cubit_point()
+ { return myPoint; }
+ // return the CubitPoint associated with this facet point
+
+ CubitStatus save_attribs( FILE* file_ptr );
+ // Write FactAttribs out to file
+
+ CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
+ // Read FactAttribs from file
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+ void get_loops ( DLIList<OCCLoop *>& loops );
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#ifdef BOYD14
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+
+ CubitStatus disconnect_curve( OCCCurve* curve );
+
+ inline bool has_parent_curve() const { return myCurves.size() > 0; }
+};
+
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
Added: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,4963 @@
+//-------------------------------------------------------------------------
+// Filename : OCCQueryEngine.cpp
+//
+// Purpose : Implementation of the OCCQueryEngine class.
+// This class provides facet-based implementations
+// of various virtual functions in the GeometryQueryEngine
+// hierarchy.
+//
+// Special Notes :
+//
+// Creator : David R. White
+//
+// Creation Date : 7/17/00
+//
+//-------------------------------------------------------------------------
+#include "OCCQueryEngine.hpp"
+#include "OCCModifyEngine.hpp"
+#include "FacetboolInterface.hpp"
+#include "TopologyEntity.hpp"
+#include "TopologyBridge.hpp"
+#include "RefEntity.hpp"
+#include "Body.hpp"
+#include "Shell.hpp"
+#include "Loop.hpp"
+#include "Chain.hpp"
+#include "CoEdge.hpp"
+#include "CoFace.hpp"
+#include "RefVolume.hpp"
+#include "RefFace.hpp"
+#include "RefEdge.hpp"
+#include "RefVertex.hpp"
+#include "GeometryEntity.hpp"
+#include "DLIList.hpp"
+#include "CubitBox.hpp"
+#include "CubitString.hpp"
+#include "OCCPoint.hpp"
+#include "OCCCurve.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCLoop.hpp"
+#include "OCCSurface.hpp"
+#include "OCCShell.hpp"
+#include "OCCLump.hpp"
+#include "OCCBody.hpp"
+#include "CubitFacetEdge.hpp"
+#include "CubitFacetEdgeData.hpp"
+#include "CubitFacet.hpp"
+#include "CubitFacetData.hpp"
+#include "CubitQuadFacet.hpp"
+#include "CubitQuadFacetData.hpp"
+#include "CubitPoint.hpp"
+#include "GMem.hpp"
+#include "FacetEvalTool.hpp"
+#include "CurveFacetEvalTool.hpp"
+#include "CubitPointData.hpp"
+#include "GeometryQueryTool.hpp"
+#include "debug.hpp"
+#include "CubitObserver.hpp"
+#include "ChollaEngine.hpp"
+#include "ChollaSurface.hpp"
+#include "ChollaCurve.hpp"
+#include "ChollaPoint.hpp"
+#include "Cholla.h"
+#include "CubitFileIOWrapper.hpp"
+#include "CubitFile.hpp"
+#include "TDFacetBoundaryPoint.hpp"
+#include "GfxDebug.hpp"
+#include "KDDTree.hpp"
+#include "RTree.hpp"
+#include "FacetDataUtil.hpp"
+#include "GridSearchTree.hpp"
+#include <stdio.h>
+#include <errno.h>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <Bnd_Box.hxx>
+#include <BndLib_AddSurface.hxx>
+#include <Precision.hxx>
+#include <BRepAdaptor_Surface.hxx>
+using namespace NCubitFile;
+
+OCCQueryEngine* OCCQueryEngine::instance_ = NULL;
+int OCCQueryEngine::hashPointSize = 0;
+DLIList<CubitPoint*> *OCCQueryEngine::hashPointArray = NULL;
+
+const int OCCQueryEngine::OCCQE_MAJOR_VERSION = 6;
+const int OCCQueryEngine::OCCQE_MINOR_VERSION = 1;
+const int OCCQueryEngine::OCCQE_SUBMINOR_VERSION = 0;
+
+TopTools_DataMapOfShapeInteger *OCCQueryEngine::OCCMap = new TopTools_DataMapOfShapeInteger;
+TopTools_DataMapOfShapeInteger *OCCQueryEngine::OCCMapr = new TopTools_DataMapOfShapeInteger;
+DLIList<TopologyBridge*> *OCCQueryEngine::CGMList = new DLIList<TopologyBridge*>;
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+OCCQueryEngine* OCCQueryEngine::instance()
+{
+ if (instance_ == NULL ) {
+ instance_ = new OCCQueryEngine;
+ }
+ return instance_;
+}
+
+//================================================================================
+// Description: default constructor
+// Author :
+// Date :
+//================================================================================
+OCCQueryEngine::OCCQueryEngine()
+{
+ GeometryQueryTool::instance()->add_gqe( this );
+}
+
+//================================================================================
+// Description: destructor
+// Author :
+// Date :
+//================================================================================
+OCCQueryEngine::~OCCQueryEngine()
+{
+ instance_ = NULL;
+}
+
+//================================================================================
+// Description: can_delete_bodies
+// Author : sjowen
+// Date : 4/25/02
+//================================================================================
+CubitBoolean OCCQueryEngine::can_delete_bodies(DLIList<Body*>body_list)
+{
+ CubitBoolean delete_ok = CUBIT_TRUE;
+ int ii;
+ for (ii=0; ii<body_list.size() && delete_ok; ii++)
+ {
+ Body *body_ptr = body_list.get_and_step();
+ // Extract the BODY from Body
+ OCCBody* fbody_ptr = CAST_TO(body_ptr->get_body_sm_ptr(), OCCBody);
+ if (fbody_ptr)
+ {
+ delete_ok = fbody_ptr->can_be_deleted(body_list);
+ }
+ }
+ return delete_ok;
+}
+
+int OCCQueryEngine::get_major_version()
+{
+ return OCCQE_MAJOR_VERSION;
+}
+
+int OCCQueryEngine::get_minor_version()
+{
+ return OCCQE_MINOR_VERSION;
+}
+
+int OCCQueryEngine::get_subminor_version()
+{
+ return OCCQE_SUBMINOR_VERSION;
+}
+
+CubitString OCCQueryEngine::get_engine_version_string()
+{
+ CubitString version_string = "OCC Geometry Engine version ";
+ version_string += CubitString(get_major_version());
+ version_string += CubitString(".");
+ version_string += CubitString(get_minor_version());
+ version_string += CubitString(".");
+ version_string += CubitString(get_subminor_version());
+
+ return version_string;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+const type_info& OCCQueryEngine::entity_type_info() const
+{
+ return typeid(*this);
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Point* OCCQueryEngine::make_Point( GeometryType ,
+ CubitVector const& ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Point*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Curve* OCCQueryEngine::make_Curve(Curve *) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Curve* OCCQueryEngine::make_Curve( Point const* ,
+ Point const* ,
+ RefFace* ,
+ CubitVector * ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Curve* OCCQueryEngine::make_Curve( GeometryType ,
+ Point const* ,
+ Point const* ,
+ DLIList<CubitVector*>& ,
+ RefFace* ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Curve* OCCQueryEngine::make_Curve( GeometryType ,
+ Point const* ,
+ Point const* ,
+ CubitVector const* ,
+ CubitSense ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Curve*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Surface* OCCQueryEngine::make_Surface( Surface *,
+ DLIList<Loop*> &,
+ CubitBoolean ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Surface*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Surface* OCCQueryEngine::make_Surface( GeometryType ,
+ DLIList<Curve*>& ,
+ DLIList<Loop*> &,
+ Surface *) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Surface*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+Lump* OCCQueryEngine::make_Lump( GeometryType ,
+ DLIList<Surface*>& ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (Lump*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+BodySM* OCCQueryEngine::make_BodySM( Surface * ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+BodySM* OCCQueryEngine::make_BodySM( DLIList<Lump*>& ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return (BodySM*) NULL;
+}
+
+//================================================================================
+// Description: create a new body by copying
+// Author : sjowen
+// Date : 9/7/01
+//================================================================================
+Body* OCCQueryEngine::copy_body( Body *body_ptr )
+{
+ BodySM* bodysm_ptr = body_ptr->get_body_sm_ptr();
+ OCCBody *facet_body_ptr = CAST_TO(bodysm_ptr, OCCBody);
+ if (!facet_body_ptr)
+ {
+ PRINT_ERROR("Attempt to copy mesh-based geometry Body. This body is not MBG.");
+ return (Body*)NULL;
+ }
+ BodySM* osme_body_ptr = (BodySM*)facet_body_ptr->copy();
+ if (!osme_body_ptr)
+ {
+ PRINT_ERROR("Failed to copy mesh-based geometry Body");
+ return (Body*)NULL;
+ }
+ Body *new_body_ptr = GeometryQueryTool::instance()->make_Body( osme_body_ptr );
+ return new_body_ptr;
+}
+
+//================================================================================
+// Description: reflect body about an axis
+// Author : sjowen
+// Date : 9/7/01
+//================================================================================
+CubitStatus OCCQueryEngine::reflect( BodySM *bodysm,
+ const CubitVector& axis)
+{
+ OCCBody *fbody = CAST_TO(bodysm, OCCBody);
+ if (!fbody)
+ {
+ PRINT_ERROR("Attempt to reflect mesh-based geometry Body. This body is not MBG.");
+ return CUBIT_FAILURE;
+ }
+
+ fbody->reflect( axis.x(), axis.y(), axis.z() );
+
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::get_connected_patch(
+ DLIList<OCCSurface*>& remaining_surfs,
+ DLIList<OCCSurface*>& output_patch )
+{
+ DLIList<OCCSurface*> stack, curve_surfs;
+ STD(set)<OCCSurface*> marked;
+ DLIList<OCCCurve*> curves;
+ int debug_this = 0;
+ if(debug_this){
+ GfxDebug::clear();
+ }
+ int i;
+ for (i = remaining_surfs.size(); i--; )
+ marked.insert( remaining_surfs.get_and_step() );
+
+ // Choose one surface to start with
+ OCCSurface* surf = remaining_surfs.pop();
+ marked.erase( surf );
+ stack.append( surf );
+
+ // Get all connected surfaces
+ while( stack.size() )
+ {
+ surf = stack.pop();
+ if(debug_this){
+ surf->get_eval_tool()->debug_draw_facets(CUBIT_BLUE);
+ GfxDebug::mouse_xforms();
+ }
+ output_patch.append( surf );
+
+ surf->get_curves( curves );
+ while (curves.size())
+ {
+ OCCCurve* curve = curves.pop();
+ curve->get_surfaces( curve_surfs );
+ if(debug_this && curve_surfs.size() < 2){
+ PRINT_INFO("Curve is not connected to 2 surfaces.\n");
+ curve->get_eval_tool()->debug_draw_facet_edges(CUBIT_MAGENTA);
+ }
+
+
+ while (curve_surfs.size())
+ {
+ OCCSurface* curve_surf = curve_surfs.pop();
+ if (marked.erase(curve_surf))
+ stack.append( curve_surf );
+ }
+ }
+ }
+
+ // Remove output surfaces from input list
+ // At this point, "marked" contains all the surfaces not in "ouput_patch"
+ remaining_surfs.last();
+ for (i = remaining_surfs.size(); i--; )
+ if (marked.find(remaining_surfs.step_and_get()) == marked.end())
+ remaining_surfs.change_to( 0 );
+ remaining_surfs.remove_all_with_value( 0 );
+
+ return CUBIT_SUCCESS;
+
+}
+
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+CubitStatus OCCQueryEngine::get_graphics( Surface* surface_ptr,
+ int& number_triangles,
+ int& number_points,
+ int& number_facets,
+ GMem* gMem,
+ unsigned short ,
+ double ) const
+{
+ // get the OCCSurface.
+ int i;
+ OCCSurface *facet_surf_ptr = CAST_TO(surface_ptr,OCCSurface);
+ if( ! facet_surf_ptr )
+ return CUBIT_FAILURE;
+
+ // get the facets for the surface
+ DLIList<CubitFacet*> surface_facets;
+ DLIList<CubitPoint*> surface_points;
+ facet_surf_ptr->get_my_facets(surface_facets, surface_points);
+
+ // set return values, and if GMem is NULL return
+ // (caller just wanted to know the counts.)
+ number_facets = surface_facets.size() * 4;
+ number_points = surface_points.size();
+ number_triangles = surface_facets.size();
+ if( !gMem )
+ return CUBIT_SUCCESS;
+
+
+ // Allocate space in GMem
+ gMem->allocate_tri(surface_facets.size());
+ gMem->fListCount = number_facets;
+ gMem->pointListCount = number_points;
+
+ // Copy points to GMem
+ surface_points.reset();
+ GPoint* pt_itor = gMem->point_list();
+ for ( i = 0; i < number_points; i++ )
+ {
+ CubitPoint* point = surface_points.get_and_step();
+ pt_itor->x = (float)point->x();
+ pt_itor->y = (float)point->y();
+ pt_itor->z = (float)point->z();
+ point->marked(i);
+ pt_itor++;
+ }
+
+ // Copy facets to Gmem
+ surface_facets.reset();
+ int* f_itor = gMem->facet_list();
+ for ( i = 0; i < number_triangles; i++ )
+ {
+ *(f_itor++) = 3;
+ CubitFacet* facet = surface_facets.get_and_step();
+ for ( int j = 0; j < 3; j++ )
+ *(f_itor++) = facet->point(j)->marked();
+ }
+
+ // cleanup
+ while( surface_points.size() )
+ surface_points.pop()->marked(0);
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+CubitStatus OCCQueryEngine::get_graphics( Curve* curve_ptr,
+ int& num_points,
+ GMem* gMem,
+ double /*tolerance*/ ) const
+{
+ // get the OCCCurve.
+ OCCCurve *facet_curv_ptr = CAST_TO(curve_ptr,OCCCurve);
+
+ DLIList<CubitFacetEdge*> curve_facets;
+ facet_curv_ptr->get_facets(curve_facets);
+ int number_facets = curve_facets.size();
+ DLIList<CubitPoint*> curve_points;
+ facet_curv_ptr->get_points(curve_points);
+ curve_points.reset();
+ curve_facets.reset();
+ num_points = curve_points.size();
+ GPoint *new_point_list = new GPoint[num_points];
+ int *new_facet_list = new int [number_facets*3];
+ int ii;
+ for ( ii = 0; ii < num_points; ii++ )
+ {
+ new_point_list[ii].x = curve_points.get()->x();
+ new_point_list[ii].y = curve_points.get()->y();
+ new_point_list[ii].z = curve_points.get()->z();
+ //mark the point with the index into the point list.
+ //This is very important to make sure we can index these
+ //points when we do the facet array.
+ curve_points.get_and_step()->marked(ii);
+ }
+ for ( ii = 0; ii < number_facets; ii++ )
+ {
+ //All our facets are segments. So the first value is 2.
+ int index_count = 3*ii;
+ new_facet_list[index_count] = 2;
+ int jj = index_count + 1;
+ int ll, kk;
+ CubitFacetEdge *facet_ptr = curve_facets.get_and_step();
+ CubitPoint *temp_point;
+ for ( kk = jj, ll = 0; kk < jj+2; kk++, ll++)
+ {
+ temp_point = facet_ptr->point(ll);
+ int index_to_point = temp_point->marked();
+ if ( index_to_point < 0 || index_to_point > num_points )
+ {
+ PRINT_ERROR("Bad logic in converting edge facets to drawing facets.\n");
+ return CUBIT_FAILURE;
+ }
+ new_facet_list[kk] = index_to_point;
+ }
+ }
+ gMem->replace_point_list(new_point_list, num_points, num_points);
+ gMem->replace_facet_list(new_facet_list, number_facets*3, number_facets*3);
+ gMem->points_consolidated(CUBIT_TRUE);
+
+ return CUBIT_SUCCESS;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+CubitStatus OCCQueryEngine::get_isoparametric_points(Surface* ,
+ int &nu, int &nv,
+ GMem*&) const
+{
+ nu = nv = 0;
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::get_u_isoparametric_points(Surface* ,
+ double, int&,
+ GMem*&) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::get_v_isoparametric_points(Surface* ,
+ double, int&,
+ GMem*&) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+CubitStatus OCCQueryEngine::transform_vec_position( CubitVector const& ,
+ BodySM *,
+ CubitVector & ) const
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description:
+// Author :
+// Date :
+//================================================================================
+CubitStatus OCCQueryEngine::get_intersections( Curve* , CubitVector& ,
+ CubitVector&,
+ DLIList<CubitVector*>& ,
+ CubitBoolean,
+ CubitBoolean )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::get_intersections( Curve* , Curve* ,
+ DLIList<CubitVector*>& ,
+ CubitBoolean,
+ CubitBoolean )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::get_intersections( Curve*,
+ Curve*,
+ DLIList<CubitVector*>&,
+ double, CubitBoolean )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus
+OCCQueryEngine::get_intersections( Curve* /*ref_edge*/, Surface* /*ref_face*/,
+ DLIList<CubitVector*>& ,
+ CubitBoolean )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Find extrema position on an entity list
+// Author :
+// Date :
+//================================================================================
+CubitStatus
+OCCQueryEngine::entity_extrema( DLIList<GeometryEntity*> &,
+ const CubitVector *,
+ const CubitVector *,
+ const CubitVector *,
+ CubitVector &,
+ GeometryEntity *& )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//================================================================================
+// Description: Find distance between two entities and closest positions.
+// Author :
+// Date :
+//================================================================================
+CubitStatus
+OCCQueryEngine::entity_entity_distance( GeometryEntity *,
+ GeometryEntity *,
+ CubitVector &, CubitVector &,
+ double & )
+{
+ PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ return CUBIT_FAILURE;
+}
+
+//===========================================================================
+//Function Name: save_temp_geom_file
+//Member Type: PUBLIC
+//Description: function called for save/restore to save temporary FACET file
+// If file is created, CubitString 'created_file' and
+// 'create_file_type' are set
+//Author: Corey Ernst
+//Date: 1/18/2003
+//===========================================================================
+
+CubitStatus OCCQueryEngine::save_temp_geom_file( DLIList<TopologyBridge*>& ref_entity_list,
+ const char *file_name,
+ const CubitString &cubit_version,
+ CubitString &created_file,
+ CubitString &created_file_type)
+{
+ int size_before = ref_entity_list.size();
+ CubitString temp_filename(file_name);
+ temp_filename += ".mbg";
+
+ if( export_solid_model( ref_entity_list, temp_filename.c_str(), "FACET",
+ cubit_version ) == CUBIT_FAILURE )
+ {
+ PRINT_ERROR( "Error occured while trying to save temporary MESH_BASED_GEOMETRY file\n");
+ return CUBIT_FAILURE;
+ }
+
+ int size_after = ref_entity_list.size();
+
+ if( size_before > size_after )
+ {
+ created_file += temp_filename;
+ created_file_type += "FACET";
+ }
+ return CUBIT_SUCCESS;
+}
+
+//===========================================================================
+//Function Name:export_solid_model
+//Member Type: PUBLIC
+//Description: function called for save/restore to save temporary FACET file
+//Author: Corey Ernst
+//Date: 1/18/2003
+//===========================================================================
+
+CubitStatus OCCQueryEngine::export_solid_model( DLIList<TopologyBridge*>& ref_entity_list,
+ const char* file_name,
+ const char* file_type,
+ const CubitString &,
+ const char*)
+{
+ if( strcmp( file_type, "FACET" ) )
+ return CUBIT_SUCCESS;
+
+ DLIList<OCCBody*> facet_bodies;
+ DLIList<OCCLump*> facet_lumps;
+ DLIList<OCCShell*> facet_shells;
+ DLIList<OCCSurface*> facet_surfaces;
+ DLIList<OCCLoop*> facet_loops;
+ DLIList<OCCCoEdge*> facet_coedges;
+ DLIList<OCCCurve*> facet_curves;
+ DLIList<OCCPoint*> facet_points;
+
+ DLIList<TopologyBridge*> ref_entities_handled;
+
+ int i;
+ //Collect all free entities (bodies, curves, vertices )
+ ref_entity_list.reset();
+ for(i=ref_entity_list.size(); i>0; i--)
+ {
+ TopologyBridge* ref_entity_ptr = ref_entity_list.get();
+ CubitBoolean handled = CUBIT_TRUE;
+
+ //if it is a Vertex
+ if( OCCPoint* pt = CAST_TO( ref_entity_ptr, OCCPoint) )
+ facet_points.append( pt );
+ //if it is a Curve
+ else if( OCCCurve* curve = CAST_TO( ref_entity_ptr, OCCCurve) )
+ facet_curves.append( curve );
+ /*
+ //if it is a Surface -- I don't think you can ever have a free surface
+ //without it being a Body
+ else if( OCCSurface* surf = CAST_TO( ref_entity_ptr, OCCSurface) )
+ facet_surfaces.append( surf );
+ */
+ //if it is a Body
+ else if( OCCBody* body = CAST_TO( ref_entity_ptr, OCCBody ) )
+ facet_bodies.append( body );
+ else
+ handled = CUBIT_FALSE;
+
+ if( handled == CUBIT_TRUE )
+ {
+ ref_entities_handled.append( ref_entity_ptr );
+ ref_entity_list.change_to(NULL);
+ }
+
+ ref_entity_list.step();
+ }
+
+ ref_entity_list.remove_all_with_value(NULL);
+
+ int free_body_count = facet_bodies.size();
+ int free_curve_count = facet_curves.size();
+ int free_point_count = facet_points.size();
+
+ //if nothing to write out...return
+ if( free_body_count == 0 && free_curve_count == 0 && free_point_count == 0)
+ return CUBIT_SUCCESS;
+
+ //get file pointer
+ FILE *file_ptr = fopen( file_name, "wb" );
+
+ //get all child entities from the bodies, curves, & vertices
+ gather_all_facet_entities( facet_bodies, facet_lumps,
+ facet_shells, facet_surfaces,
+ facet_loops, facet_coedges,
+ facet_curves, facet_points );
+
+ //create a wrapper object for writing
+ CIOWrapper file_writer( file_ptr );
+
+ // write out file type "MESHED_BASED_GEOMETRY"
+ file_writer.BeginWriteBlock(0);
+ file_writer.Write( "MESH_BASED_GEOMETRY", 19 );
+
+ // write out Endian value
+ UnsignedInt32 endian_value = CCubitFile::mintNativeEndian;
+ file_writer.Write( &endian_value, 1 );
+
+ // write out version #
+ UnsignedInt32 version = 1;
+ file_writer.Write( &version, 1 );
+
+
+ //save the facets (geometry info )
+ CubitStatus status;
+ status = save_facets( file_ptr, facet_surfaces, facet_curves, facet_points );
+ if( status == CUBIT_FAILURE ) return CUBIT_FAILURE;
+
+ //write out topology and attributes
+ status = write_topology( file_ptr,
+ facet_bodies, facet_lumps,
+ facet_shells, facet_surfaces,
+ facet_loops, facet_coedges,
+ facet_curves, facet_points );
+ if( status == CUBIT_FAILURE ) return CUBIT_FAILURE;
+
+ if( free_body_count || free_curve_count || free_point_count )
+ PRINT_INFO( "\nExported:" );
+
+ int flg = 0;
+
+ if( free_body_count )
+ {
+ if( flg )PRINT_INFO( " " );else flg=1;
+ if( DEBUG_FLAG( 153 ) )
+ {
+ if( free_body_count == 1 )
+ PRINT_INFO( "%4d Facet Body\n", free_body_count );
+ else
+ PRINT_INFO( "%4d Facet Bodies\n", free_body_count );
+ }
+
+ if( facet_lumps.size() == 1 )
+ PRINT_INFO( "%4d Facet Volume\n", facet_lumps.size() );
+ else
+ PRINT_INFO( "%4d Facet Volumes\n", facet_lumps.size() );
+ }
+ if( free_curve_count )
+ {
+ if( flg )PRINT_INFO( " " );else flg=1;
+ if( free_curve_count == 1 )
+ PRINT_INFO( "%4d Facet Curve\n", free_curve_count );
+ else
+ PRINT_INFO( "%4d Facet Curves\n", free_curve_count );
+ }
+ if( free_point_count )
+ {
+ if( flg )PRINT_INFO( " " );else flg=1;
+ if( free_point_count == 1 )
+ PRINT_INFO( "%4d Facet Point\n", free_point_count );
+ else
+ PRINT_INFO( "%4d Facet Points\n", free_point_count );
+ }
+ PRINT_INFO( "\n" );
+
+
+
+ fclose( file_ptr );
+
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus
+OCCQueryEngine::gather_all_facet_entities( DLIList<OCCBody*> &facet_bodies,
+ DLIList<OCCLump*> &facet_lumps,
+ DLIList<OCCShell*> &facet_shells,
+ DLIList<OCCSurface*> &facet_surfaces,
+ DLIList<OCCLoop*> &facet_loops,
+ DLIList<OCCCoEdge*> &facet_coedges,
+ DLIList<OCCCurve*> &facet_curves,
+ DLIList<OCCPoint*> &facet_points )
+{
+ int i;
+
+
+ //Collect OCCLumps from OCCBody
+ for(i=0; i<facet_bodies.size(); i++)
+ {
+ OCCBody *facet_body = facet_bodies.get_and_step();
+ facet_body->get_lumps( facet_lumps );
+ }
+
+
+ //Collect OCCShells from OCCLumps
+ for(i=0; i<facet_lumps.size(); i++)
+ {
+ OCCLump *facet_lump = facet_lumps.get_and_step();
+ facet_lump->get_shells( facet_shells );
+ }
+
+
+ //Collect OCCSurfaces from OCCShells
+ for(i=0; i<facet_shells.size(); i++)
+ {
+ OCCShell *facet_shell = facet_shells.get_and_step();
+ facet_shell->get_surfaces( facet_surfaces );
+ }
+ facet_surfaces.uniquify_unordered();
+
+
+ //Collect OCCLoops from OCCSurfaces
+ for(i=0; i<facet_surfaces.size(); i++)
+ {
+ OCCSurface *facet_surface = facet_surfaces.get_and_step();
+ facet_surface->get_loops( facet_loops );
+ }
+
+ //Collect OCCCoEdges from OCCLoops
+ for(i=0; i<facet_loops.size(); i++)
+ {
+ OCCLoop *facet_loop = facet_loops.get_and_step();
+ facet_loop->get_coedges( facet_coedges );
+ }
+
+
+ //Collect FacetCurves from OCCCoEdges
+ for( i=0; i<facet_coedges.size(); i++)
+ {
+ OCCCoEdge *facet_coedge = facet_coedges.get_and_step();
+ facet_coedge->get_curves( facet_curves );
+ }
+ facet_curves.uniquify_unordered();
+
+
+ //Collect OCCPoints from FacetCurves
+ for( i=0; i<facet_curves.size(); i++)
+ {
+ OCCCurve *facet_curve = facet_curves.get_and_step();
+ facet_curve->get_points( facet_points );
+ }
+
+ //uniquify lists
+ facet_points.uniquify_unordered();
+
+
+ return CUBIT_SUCCESS;
+
+}
+
+
+CubitStatus
+OCCQueryEngine::write_topology( FILE *file_ptr,
+ DLIList<OCCBody*> &facet_bodies,
+ DLIList<OCCLump*> &facet_lumps,
+ DLIList<OCCShell*> &facet_shells,
+ DLIList<OCCSurface*> &facet_surfaces,
+ DLIList<OCCLoop*> &facet_loops,
+ DLIList<OCCCoEdge*> &facet_coedges,
+ DLIList<OCCCurve*> &facet_curves,
+ DLIList<OCCPoint*> &facet_points )
+{
+
+ int i;
+
+ //create a wrapper object for writing
+ CIOWrapper file_writer( file_ptr );
+
+ //-----------------write OCCPoints--------------
+ UnsignedInt32 size = facet_points.size();
+ //write out number of OCCPoints
+ file_writer.Write( &size, 1 );
+ facet_points.reset();
+ for( i=0; i<facet_points.size(); i++)
+ {
+ OCCPoint *curr_point = facet_points.get_and_step();
+ int id = curr_point->get_cubit_point()->id();
+
+ file_writer.Write( reinterpret_cast<UnsignedInt32*>(&id), 1 );
+ if( curr_point->save_attribs(file_ptr) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
+ }
+
+ //-----------------write FacetCurves--------------
+ size = facet_curves.size();
+ //write out number of FacetCurves
+ file_writer.Write( &size, 1 );
+ facet_curves.reset();
+ for( i=0; i<facet_curves.size(); i++)
+ {
+ OCCCurve *curr_curve = facet_curves.get_and_step();
+ Point *s_point, *e_point;
+ s_point = curr_curve->start_point();
+ e_point = curr_curve->end_point();
+
+ int data_to_write[4];
+
+ // get start&end points implicit ids
+ OCCPoint *temp_point = NULL;
+ temp_point = CAST_TO( s_point, OCCPoint );
+ if( !temp_point ) assert(0);
+ int found;
+ found = facet_points.where_is_item( temp_point );
+ if( found == -1)
+ assert(0);
+ data_to_write[0] = found;
+
+ temp_point = CAST_TO( e_point, OCCPoint );
+ if( !temp_point ) assert(0);
+ found = facet_points.where_is_item( temp_point );
+ if( found == -1)
+ PRINT_ERROR("Problem saving Facet Curves\n");
+ data_to_write[1] = found;
+
+ //convert Sense info to integer
+ if( curr_curve->get_sense() == CUBIT_UNKNOWN )
+ data_to_write[2] = -1;
+ else
+ data_to_write[2] = (curr_curve->get_sense() == CUBIT_REVERSED) ? 1 : 0;
+
+ data_to_write[3] = curr_curve->get_eval_tool()->get_output_id();
+
+ //write the data
+ file_writer.Write( reinterpret_cast<UnsignedInt32*>(data_to_write), 4 );
+
+ if( curr_curve->save_attribs(file_ptr) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
+ }
+
+ //-----------------write FacetCoedges--------------
+ size = facet_coedges.size();
+ // write out number of FacetCurves
+ file_writer.Write( &size, 1 );
+ facet_coedges.reset();
+ for( i=0; i<facet_coedges.size(); i++)
+ {
+ OCCCoEdge *curr_coedge = facet_coedges.get_and_step();
+ Curve *curve_sm;
+ curve_sm = curr_coedge->curve();
+
+ OCCCurve *temp_curve = NULL;
+ temp_curve = CAST_TO( curve_sm, OCCCurve );
+
+ int data_to_write[2];
+
+ // get implicit id of this curve
+ int found;
+ found = facet_curves.where_is_item( temp_curve );
+ if( found == -1)
+ PRINT_ERROR("Problem saving Facet CoEdges\n");
+ data_to_write[0] = found;
+
+ // convert sense info to integer
+ if( curr_coedge->get_sense() == CUBIT_UNKNOWN )
+ data_to_write[1] = -1;
+ else
+ data_to_write[1] = (curr_coedge->get_sense() == CUBIT_REVERSED) ? 1 : 0;
+
+ // write out the data
+ file_writer.Write( reinterpret_cast<UnsignedInt32*>(data_to_write), 2 );
+
+ }
+
+ //-----------------write OCCLoops--------------
+ size = facet_loops.size();
+ // write out number of OCCLoops
+ file_writer.Write( &size, 1 );
+ facet_loops.reset();
+ for( i=0; i<facet_loops.size(); i++)
+ {
+ OCCLoop *curr_loop = facet_loops.get_and_step();
+ DLIList<OCCCoEdge*> coedge_list;
+ curr_loop->get_coedges( coedge_list );
+
+ // get number of coedges in this loop
+ UnsignedInt32 *data_to_write;
+ size = coedge_list.size();
+ data_to_write = new UnsignedInt32[ size + 1 ];
+ data_to_write[0] = size;
+
+ UnsignedInt32 j;
+ // get implicit ids of coedges
+ coedge_list.reset();
+ for( j=1; j<size+1; j++)
+ {
+ OCCCoEdge *temp_coedge = coedge_list.get_and_step();
+ int found;
+ found = facet_coedges.where_is_item( temp_coedge );
+ if( found == -1)
+ PRINT_ERROR("Problem saving Facet Loops\n");
+ data_to_write[j] = found;
+ }
+
+ // write out the data
+ file_writer.Write( data_to_write, size + 1);
+ delete [] data_to_write;
+ }
+
+ //-----------------write OCCSurfaces--------------
+ size = facet_surfaces.size();
+ // write out number of OCCSurfaces
+ file_writer.Write( &size, 1 );
+ facet_surfaces.reset();
+ for( i=0; i<facet_surfaces.size(); i++)
+ {
+ OCCSurface *curr_surface = facet_surfaces.get_and_step();
+
+ DLIList<OCCLoop*> loop_list;
+ curr_surface->get_loops( loop_list );
+
+ int num_loops = loop_list.size();
+ int data_to_write[6];
+
+ // convert sense info to integer
+ // if( curr_surface->get_relative_surface_sense() == CUBIT_UNKNOWN )
+// data_to_write[0] = -1;
+// else
+// data_to_write[0] = (curr_surface->get_relative_surface_sense() == CUBIT_REVERSED) ? 1 : 0;
+ data_to_write[0]=0;
+ // get "useFacets"
+ data_to_write[1] = 1;
+
+ // get output id of FacetEvalTool
+ data_to_write[2] = curr_surface->get_eval_tool()->get_output_id();
+
+ // get Shell Sense stuff
+ CubitSense sense0;
+
+ curr_surface->get_shell_sense( sense0 );
+ if( sense0 == CUBIT_UNKNOWN )
+ data_to_write[3] = -1;
+ else
+ data_to_write[3] = (sense0 == CUBIT_REVERSED) ? 1 : 0;
+
+// if( sense1 == CUBIT_UNKNOWN )
+ data_to_write[4] = -1;
+// else
+// data_to_write[4] = (sense1 == CUBIT_REVERSED) ? 1 : 0;
+
+ // get number of loops
+ data_to_write[5] = num_loops;
+
+ file_writer.Write( reinterpret_cast<UnsignedInt32*>(data_to_write), 6 );
+
+ // get implicit ids of loops
+ if( num_loops > 0 )
+ {
+ int *loop_ids = new int[num_loops];
+ int j;
+ loop_list.reset();
+ for( j=0; j<num_loops; j++)
+ {
+ OCCLoop *temp_loop = loop_list.get_and_step();
+ int found;
+ found = facet_loops.where_is_item( temp_loop );
+ if( found == -1 )
+ PRINT_ERROR("Problem saving Facet Surfaces\n");
+ loop_ids[j] = found;
+ }
+
+ // write out data
+ file_writer.Write( reinterpret_cast<UnsignedInt32*>(loop_ids), num_loops );
+ delete [] loop_ids;
+ }
+
+ if( curr_surface->save_attribs(file_ptr) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
+ }
+
+ //-----------------write OCCShells--------------
+ size = facet_shells.size();
+ // write out number of OCCShells
+ file_writer.Write( &size, 1 );
+ facet_shells.reset();
+ for( i=0; i<facet_shells.size(); i++)
+ {
+ OCCShell *curr_shell= facet_shells.get_and_step(); //number of surfaces
+ DLIList<OCCSurface*> temp_facet_surf_list;
+ curr_shell->get_surfaces( temp_facet_surf_list );
+
+ // get number of surfaces in this shell
+ UnsignedInt32 *data_to_write;
+ int num_surfs = temp_facet_surf_list.size();
+ data_to_write = new UnsignedInt32[ num_surfs + 1];
+ data_to_write[0] = num_surfs;
+
+ // get implicit ids of surfaces
+ int j;
+ temp_facet_surf_list.reset();
+ for( j=1; j<num_surfs+1; j++)
+ {
+ OCCSurface *temp_facet_surface = temp_facet_surf_list.get_and_step();
+ int found;
+ found = facet_surfaces.where_is_item( temp_facet_surface );
+ if( found == -1 )
+ PRINT_ERROR("Problem saving Facet Shells\n");
+ data_to_write[j] = found;
+ }
+
+ // write the data
+ file_writer.Write( data_to_write, num_surfs + 1 );
+ delete [] data_to_write;
+ }
+
+ //-----------------write OCCLumps--------------
+ size = facet_lumps.size();
+ // write out number of OCCLumps
+ file_writer.Write( &size, 1 );
+ facet_lumps.reset();
+ for( i=0; i<facet_lumps.size(); i++)
+ {
+ OCCLump *curr_lump = facet_lumps.get_and_step();
+
+ DLIList<OCCShell*> temp_facet_shell_list;
+ curr_lump->get_shells( temp_facet_shell_list );
+
+ // get number of shells in this lump
+ UnsignedInt32 *data_to_write;
+ int num_shells= temp_facet_shell_list.size();
+ data_to_write = new UnsignedInt32[ num_shells+ 1];
+ data_to_write[0] = num_shells;
+
+ //get implicit ides of the lumps in this shell
+ int j;
+ temp_facet_shell_list.reset();
+ for( j=1; j<num_shells+1; j++)
+ {
+ OCCShell *temp_facet_shell = temp_facet_shell_list.get_and_step();
+ int found;
+ found = facet_shells.where_is_item( temp_facet_shell );
+ if( found == -1 )
+ PRINT_ERROR("Problem saving Facet Lumps\n");
+ data_to_write[j] = found;
+ }
+
+ //write the data
+ file_writer.Write( data_to_write, num_shells + 1 );
+ delete [] data_to_write;
+ if( curr_lump->save_attribs(file_ptr) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
+ }
+
+ //-----------------write FacetBodies--------------
+ size = facet_bodies.size();
+ // write out number of FacetBodies
+ file_writer.Write( &size, 1 );
+ facet_bodies.reset();
+ for( i=0; i<facet_bodies.size(); i++)
+ {
+ OCCBody *curr_body = facet_bodies.get_and_step();
+
+ DLIList<OCCLump*> temp_facet_lump_list;
+ curr_body->get_lumps( temp_facet_lump_list );
+
+ // get the number of lumps in this body
+ UnsignedInt32 *data_to_write;
+ int num_lumps = temp_facet_lump_list.size();
+ data_to_write = new UnsignedInt32[ num_lumps + 1];
+ data_to_write[0] = num_lumps;
+
+ // get the implicit ids of the lumps in this body
+ int j;
+ temp_facet_lump_list.reset();
+ for( j=1; j<num_lumps+1; j++)
+ {
+ OCCLump *temp_facet_lump = temp_facet_lump_list.get_and_step();
+ int found;
+ found = facet_lumps.where_is_item( temp_facet_lump );
+ if( found == -1 )
+ PRINT_ERROR("Problem saving Facet Bodies\n");
+ data_to_write[j] = found;
+ }
+
+ // write the data
+ file_writer.Write( data_to_write, num_lumps + 1 );
+ delete [] data_to_write;
+
+ // write the transformation matrix of this body
+ CubitTransformMatrix trans_matrix;
+ curr_body->get_transforms( trans_matrix );
+
+ UnsignedInt32 num_rows = trans_matrix.num_rows();
+ UnsignedInt32 num_cols = trans_matrix.num_cols();
+ UnsignedInt32 rows_and_cols[2];
+ rows_and_cols[0] = num_rows;
+ rows_and_cols[1] = num_cols;
+
+ file_writer.Write( rows_and_cols, 2 );
+
+ double *trans_matrix_array;
+ trans_matrix_array = new double[ num_rows*num_cols ];
+
+ //fill up the array row-by-row
+ unsigned u, k = 0;
+ for(u=0; u<num_rows; u++)
+ {
+ for(k=0; k<num_cols; k++)
+ trans_matrix_array[(u*num_cols)+k] = trans_matrix.get(u,k);
+ }
+
+ file_writer.Write( trans_matrix_array, u*k );
+ delete [] trans_matrix_array;
+ if( curr_body->save_attribs(file_ptr) == CUBIT_FAILURE )
+ return CUBIT_FAILURE;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+
+CubitStatus
+OCCQueryEngine::restore_topology( FILE *file_ptr,
+ unsigned int endian,
+ int num_points,
+ CubitPoint **points_array,
+ int num_cfet,
+ CurveFacetEvalTool** cfev_array,
+ int num_fet,
+ FacetEvalTool** fev_array,
+ DLIList<TopologyBridge*> &imported_entities )
+{
+
+ //get file pointer
+ unsigned int size;
+ unsigned int i, j;
+ int id, k;
+
+ OCCPoint **facet_points;
+ OCCCurve **facet_curves;
+ OCCCoEdge **facet_coedges;
+ OCCLoop **facet_loops;
+ OCCSurface **facet_surfaces;
+ OCCShell **facet_shells;
+ OCCLump **facet_lumps;
+ OCCBody **facet_bodies;
+
+ OCCPoint *tmp_point;
+ OCCCurve *tmp_curve;
+ OCCCoEdge *tmp_coedge;
+ OCCLoop *tmp_loop;
+ OCCSurface *tmp_surf;
+ OCCShell *tmp_shell;
+ OCCLump *tmp_lump;
+ OCCBody*tmp_body;
+
+ int num_facet_points = 0;
+ int num_facet_curves = 0;
+ int num_facet_coedges = 0;
+ int num_facet_loops = 0;
+ int num_facet_surfaces = 0;
+ int num_facet_shells = 0;
+ int num_facet_lumps = 0;
+ int num_facet_bodies = 0;
+
+ //create a wrapper object for writing
+ CIOWrapper file_reader( endian, file_ptr );
+
+ //-----------------Read OCCPoints------------------
+ // Read number of OCCPoints
+ file_reader.Read( &size, 1 );
+ // Allocate memory for OCCPoints
+ facet_points = new OCCPoint*[size];
+ for(i=0; i<size; i++)
+ {
+ file_reader.Read( reinterpret_cast<UnsignedInt32*>(&id), 1 );
+ if( id >= num_points || id < 0 )
+ {
+ delete [] facet_points;
+ return CUBIT_FAILURE;
+ }
+
+ tmp_point = new OCCPoint( points_array[ id ] );
+ if( tmp_point == NULL )
+ return CUBIT_FAILURE;
+
+ num_facet_points++;
+ facet_points[i] = tmp_point;
+ tmp_point->restore_attribs( file_ptr, endian );
+ }
+
+ //-----------------Read FacetCurves------------------
+ //Read number of FacetCurves
+ file_reader.Read( &size, 1 );
+ // Allocate memory for FacetCurves
+ facet_curves = new OCCCurve*[size];
+ for(i=0; i<size; i++)
+ {
+ int data[4];
+ file_reader.Read( reinterpret_cast<UnsignedInt32*>(data), 4 );
+ if( data[0] >= num_facet_points || data[0] < 0 ||
+ data[1] >= num_facet_points || data[1] < 0 ||
+ data[3] >= num_cfet || data[3] < 0 )
+ {
+ delete [] facet_curves;
+ return CUBIT_FAILURE;
+ }
+
+ CubitSense sense;
+ if (data[2] == -1 )
+ sense = CUBIT_UNKNOWN;
+ else
+ sense = data[2] ? CUBIT_REVERSED : CUBIT_FORWARD;
+
+ tmp_curve = new OCCCurve( cfev_array[ data[3] ], facet_points[ data[0] ],
+ facet_points[ data[1] ], sense );
+ if( tmp_curve == NULL )
+ return CUBIT_FAILURE;
+
+ // Add curve to OCCPoints
+ facet_points[data[0]]->add_curve( tmp_curve );
+ facet_points[data[1]]->add_curve( tmp_curve );
+
+ num_facet_curves++;
+ facet_curves[i] = tmp_curve;
+ tmp_curve->restore_attribs( file_ptr, endian );
+ }
+
+ //-----------------Read OCCCoEdges------------------
+ //Read number of OCCCoEdges
+ file_reader.Read( &size, 1 );
+ facet_coedges = new OCCCoEdge*[ size ];
+ for(i=0; i<size; i++)
+ {
+ int data[2];
+ file_reader.Read( reinterpret_cast<unsigned int*>(data), 2 );
+
+ if( data[0] >= num_facet_curves || data[0] < 0 )
+ {
+ delete [] facet_coedges;
+ return CUBIT_FAILURE;
+ }
+
+ CubitSense sense;
+ if (data[1] == -1 )
+ sense = CUBIT_UNKNOWN;
+ else
+ sense = data[1] ? CUBIT_REVERSED : CUBIT_FORWARD;
+
+ tmp_coedge = new OCCCoEdge( facet_curves[ data[0] ], sense );
+ if( tmp_coedge == NULL )
+ return CUBIT_FAILURE;
+
+ facet_coedges[i] = tmp_coedge;
+ num_facet_coedges++;
+
+ // Add OCCCoEdge to OCCCurve
+ facet_curves[ data[0] ]->add_coedge( tmp_coedge );
+ }
+
+ //-----------------Read OCCLoops------------------
+ //Read number of OCCLoops
+ file_reader.Read( &size, 1 );
+ DLIList<CoEdgeSM*> temp_coedge_list;
+ facet_loops = new OCCLoop*[ size ];
+ for(i=0; i<size; i++)
+ {
+ temp_coedge_list.clean_out();
+
+ unsigned int num_coedges = 0;
+ file_reader.Read( &num_coedges, 1);
+
+ int* coedge_ids = new int[ num_coedges];
+ file_reader.Read( (unsigned*)coedge_ids, num_coedges );
+
+ for( j=0; j<num_coedges; j++)
+ {
+ if( coedge_ids[j] >= num_facet_coedges || coedge_ids[j] < 0 )
+ {
+ delete [] facet_loops;
+ return CUBIT_FAILURE;
+ }
+ temp_coedge_list.append( facet_coedges[ coedge_ids[j] ] );
+ }
+
+ tmp_loop = new OCCLoop( temp_coedge_list );
+ if( tmp_loop == NULL)
+ return CUBIT_FAILURE;
+
+ num_facet_loops++;
+ facet_loops[i] = tmp_loop;
+
+ for( j=0; j<num_coedges; j++)
+ facet_coedges[ coedge_ids[j] ]->add_loop( tmp_loop );
+
+ delete [] coedge_ids;
+ }
+
+ //-----------------Read OCCSurfaces------------------
+ //Read number of OCCSurfaces
+ file_reader.Read( &size, 1 );
+ facet_surfaces = new OCCSurface*[size];
+ DLIList<LoopSM*> temp_loops;
+ for(i=0; i<size; i++)
+ {
+ temp_loops.clean_out();
+ int data[6];
+ file_reader.Read( (unsigned int*)data, 6);
+
+ CubitSense sense, sense0, sense1;
+ if (data[0] == -1 )
+ sense = CUBIT_UNKNOWN;
+ else
+ sense = data[0] ? CUBIT_REVERSED : CUBIT_FORWARD;
+
+ CubitBoolean useFacets;
+ useFacets = data[1] ? CUBIT_TRUE : CUBIT_FALSE;
+
+ // make sure FacetEvalTool ID is in range
+ if( data[2] >= num_fet || data[2] < 0 )
+ {
+ delete [] facet_surfaces;
+ return CUBIT_FAILURE;
+ }
+
+ if (data[3] == -1 )
+ sense0 = CUBIT_UNKNOWN;
+ else
+ sense0 = data[3] ? CUBIT_REVERSED : CUBIT_FORWARD;
+
+ if (data[4] == -1 )
+ sense1 = CUBIT_UNKNOWN;
+ else
+ sense1 = data[4] ? CUBIT_REVERSED : CUBIT_FORWARD;
+
+ int num_loops = data[5];
+ int* loop_ids = new int[ num_loops ];
+ file_reader.Read( (unsigned*)loop_ids, num_loops );
+
+ for( k=0; k<num_loops; k++)
+ {
+ if( loop_ids[k] >= num_facet_loops ||
+ loop_ids[k] < 0 )
+ {
+ delete [] loop_ids;
+ return CUBIT_FAILURE;
+ }
+ temp_loops.append( facet_loops[ loop_ids[k] ] );
+ }
+ tmp_surf = new OCCSurface( fev_array[ data[2] ],
+ sense, sense0,
+ useFacets, temp_loops );
+ if( tmp_surf == NULL)
+ return CUBIT_FAILURE;
+
+ facet_surfaces[i] = tmp_surf;
+ num_facet_surfaces++;
+
+ // Add OCCSurface to OCCLoops
+ for( k=0; k<num_loops; k++)
+ facet_loops[ loop_ids[k] ]->add_surface( tmp_surf );
+
+ delete [] loop_ids;
+ tmp_surf->restore_attribs( file_ptr, endian );
+ }
+
+ //-----------------Read OCCShells------------------
+ //Read number of OCCShells
+ file_reader.Read( &size, 1 );
+ facet_shells = new OCCShell*[size];
+ DLIList<Surface*> temp_surfs;
+ for(i=0; i<size; i++)
+ {
+ temp_surfs.clean_out();
+ unsigned int num_surfs = 0;
+ file_reader.Read( &num_surfs, 1 );
+
+ int* surface_ids = new int[ num_surfs ];
+ file_reader.Read( (unsigned*)surface_ids, num_surfs );
+
+ for( j=0; j<num_surfs; j++)
+ {
+ if( surface_ids[j] >= num_facet_surfaces ||
+ surface_ids[j] < 0 )
+ {
+ delete [] facet_shells;
+ return CUBIT_FAILURE;
+ }
+
+ temp_surfs.append( facet_surfaces[ surface_ids[j] ] );
+ }
+
+ tmp_shell = new OCCShell( temp_surfs );
+ facet_shells[i] = tmp_shell;
+ num_facet_shells++;
+
+ // Add this shell to surfaces
+ for( j=0; j<num_surfs; j++)
+ facet_surfaces[ surface_ids[j] ]->add_shell( tmp_shell );
+
+ delete [] surface_ids;
+ }
+
+ //-----------------Read OCCLumps------------------
+ //Read number of OCCLumps
+ file_reader.Read( &size, 1 );
+ facet_lumps = new OCCLump*[size];
+ DLIList<ShellSM*> temp_shells;
+ for(i=0; i<size; i++)
+ {
+ temp_shells.clean_out();
+
+ unsigned int num_shells = 0;
+ file_reader.Read( &num_shells, 1 );
+
+ int* shell_ids = new int[ num_shells ];
+ file_reader.Read( (unsigned*)shell_ids, num_shells );
+
+ for( j=0; j<num_shells; j++)
+ {
+ if( shell_ids[j] >= num_facet_shells )
+ {
+ delete [] facet_lumps;
+ return CUBIT_FAILURE;
+ }
+ temp_shells.append( facet_shells[ shell_ids[j] ] );
+ }
+
+ tmp_lump = new OCCLump( temp_shells );
+ if( tmp_lump == NULL )
+ return CUBIT_FAILURE;
+
+ facet_lumps[i] = tmp_lump;
+ num_facet_lumps++;
+
+ for( j=0; j<num_shells; j++)
+ facet_shells[ shell_ids[j] ]->add_lump( tmp_lump );
+
+ delete [] shell_ids;
+ tmp_lump->restore_attribs( file_ptr, endian );
+ }
+
+ //-----------------Read FacetBodies ------------------
+ //Read number of FacetBodies
+ file_reader.Read( &size, 1 );
+ facet_bodies = new OCCBody*[size];
+ DLIList<Lump*> temp_lumps;
+ for(i=0; i<size; i++)
+ {
+ temp_lumps.clean_out();
+
+ unsigned int num_lumps= 0;
+ file_reader.Read( &num_lumps, 1 );
+
+ int* lump_ids = new int[ num_lumps ];
+ file_reader.Read( (unsigned*)lump_ids, num_lumps );
+
+ for( j=0; j<num_lumps; j++)
+ {
+ if( lump_ids[j] >= num_facet_lumps )
+ {
+ delete [] facet_bodies;
+ return CUBIT_FAILURE;
+ }
+ temp_lumps.append( facet_lumps[ lump_ids[j] ] );
+ }
+
+ tmp_body = new OCCBody( temp_lumps );
+ if( tmp_body == NULL )
+ return CUBIT_FAILURE;
+
+ facet_bodies[i] = tmp_body;
+ num_facet_bodies++;
+
+ // Add this OCCBody to OCCLumps
+ for( j=0; j<num_lumps; j++)
+ facet_lumps[ lump_ids[j] ]->add_body( tmp_body );
+
+ delete [] lump_ids;
+
+ //read in trans matrix
+ unsigned int rows_and_cols[2];
+ file_reader.Read( rows_and_cols, 2 );
+
+ unsigned int num_rows = rows_and_cols[0];
+ unsigned int num_cols = rows_and_cols[1];
+
+ if( num_rows || num_cols)
+ {
+ CubitTransformMatrix trans_matrix;
+
+ double *trans_matrix_array;
+ trans_matrix_array = new double[ num_rows*num_cols ];
+ file_reader.Read( trans_matrix_array, num_rows*num_cols );
+
+ unsigned c;
+ for(j=0; j<num_rows; j++ )
+ {
+ for(c=0; c<num_cols; c++)
+ trans_matrix.add(j,c, trans_matrix_array[(j*num_cols)+c] );
+ }
+ tmp_body->set_transforms( trans_matrix );
+ delete [] trans_matrix_array;
+ }
+ tmp_body->restore_attribs( file_ptr, endian );
+ }
+
+ // Here is where we determine if the entites are free or not
+ // bodies, all bodies are free
+ for(k=0; k<num_facet_bodies; k++)
+ imported_entities.append( facet_bodies[k] );
+
+ // surfaces are free if they are not in a shell
+ DLIList<OCCShell*> shell_list;
+ for(k=0; k<num_facet_surfaces; k++)
+ {
+ shell_list.clean_out();
+ facet_surfaces[k]->get_shells( shell_list );
+ if( shell_list.size() == 0 )
+ imported_entities.append( facet_surfaces[k] );
+ }
+
+ // curves are free if they are not associate with a coedge
+ DLIList<OCCCoEdge*> coedge_list;
+ for(k=0; k<num_facet_curves; k++)
+ {
+ coedge_list.clean_out();
+ facet_curves[k]->get_coedges( coedge_list );
+ if( coedge_list.size() == 0 )
+ imported_entities.append( facet_curves[k] );
+ }
+
+ // points are free if they are not associate with a curve
+ DLIList<OCCCurve*> curve_list;
+ for(k=0; k<num_facet_points; k++)
+ {
+ curve_list.clean_out();
+ facet_points[k]->get_curves( curve_list );
+ if( curve_list.size() == 0 )
+ imported_entities.append( facet_points[k] );
+ }
+
+ // clean up
+ delete [] facet_points;
+ delete [] facet_curves;
+ delete [] facet_coedges;
+ delete [] facet_loops;
+ delete [] facet_surfaces;
+ delete [] facet_shells;
+ delete [] facet_lumps;
+ delete [] facet_bodies;
+
+ return CUBIT_SUCCESS;
+}
+
+
+CubitStatus
+OCCQueryEngine::import_temp_geom_file(FILE* file_ptr,
+ const char* /*file_name*/,
+ const char* file_type,
+ DLIList<TopologyBridge*> &bridge_list )
+{
+ //make sure that file_type == "FACET"
+ if( !strcmp( file_type,"FACET") )
+ return import_solid_model( file_ptr, file_type, bridge_list );
+ else
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::import_solid_model(
+ const char* file_name ,
+ const char* file_type,
+ DLIList<TopologyBridge*> &imported_entities,
+ CubitBoolean print_results,
+ const char* logfile_name,
+ CubitBoolean heal_step,
+ CubitBoolean import_bodies,
+ CubitBoolean import_surfaces,
+ CubitBoolean import_curves,
+ CubitBoolean import_vertices,
+ CubitBoolean free_surfaces)
+{
+ TopoDS_Shape *aShape = new TopoDS_Shape;
+ BRep_Builder aBuilder;
+ Standard_Boolean result = BRepTools::Read(*aShape, (char*) file_name, aBuilder);
+ if (result==0) return CUBIT_FAILURE;
+ OCCBody *body = new OCCBody(aShape);
+// CGMList->append(body);
+ imported_entities.append(body);
+// OCCMap->Bind(*aShape, CGMList->where_is_item(body));
+ populate_topology_bridge_solid(*aShape, imported_entities);
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_solid(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities)
+{
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next()) {
+ TopoDS_Solid *posolid = new TopoDS_Solid;
+ *posolid = TopoDS::Solid(Ex.Current());
+ OCCLump *lump;
+ if (!OCCMap->IsBound(*posolid)) {
+ printf("Adding solid\n");
+ lump = new OCCLump(posolid);
+ CGMList->append(lump);
+// imported_entities.append(lump);
+ OCCMap->Bind(*posolid, CGMList->where_is_item(lump));
+ populate_topology_bridge_shell(*posolid, imported_entities);
+ } else {
+ lump = (OCCLump*)((*CGMList)[OCCMap->Find(*posolid)]);
+ }
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_shell(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities)
+{
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next()) {
+ TopoDS_Shell *poshell = new TopoDS_Shell;
+ *poshell = TopoDS::Shell(Ex.Current());
+ OCCShell *shell;
+ if (!OCCMap->IsBound(*poshell)) {
+ printf("Adding shell\n");
+ shell = new OCCShell(poshell);
+ CGMList->append(shell);
+// imported_entities.append(shell);
+ OCCMap->Bind(*poshell, CGMList->where_is_item(shell));
+ populate_topology_bridge_face(*poshell, imported_entities);
+ } else {
+ shell = (OCCShell*)(*CGMList)[OCCMap->Find(*poshell)];
+ }
+ shell->add_lump((OCCLump*)(*CGMList)[OCCMap->Find(aShape)]);
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_face(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities)
+{
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next()) {
+ TopoDS_Face *poface = new TopoDS_Face;
+ *poface = TopoDS::Face(Ex.Current());
+ OCCSurface *surface;
+ if (!OCCMap->IsBound(*poface)) {
+ printf("Adding face\n");
+/* BRepAdaptor_Surface asurface(*poface);
+ Bnd_Box aBox;
+ double min[3], max[3];
+ BndLib_AddSurface::Add(asurface, Precision::Approximation(), aBox);
+ aBox.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+ printf(". . . box: %lf %lf %lf, %lf %lf %lf\n", min[0], min[1], min[2], max[0], max[1], max[2]);*/
+
+ surface = new OCCSurface(poface);
+ CGMList->append(surface);
+// imported_entities.append(surface);
+ OCCMap->Bind(*poface, CGMList->where_is_item(surface));
+ populate_topology_bridge_wire(*poface, imported_entities);
+ } else {
+ surface = (OCCSurface*)(*CGMList)[OCCMap->Find(*poface)];
+ }
+ surface->add_shell((OCCShell*)(*CGMList)[OCCMap->Find(aShape)]);
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_wire(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities)
+{
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next()) {
+ TopoDS_Wire *powire = new TopoDS_Wire;
+ *powire = TopoDS::Wire(Ex.Current());
+ OCCLoop *loop;
+ if (!OCCMap->IsBound(*powire)) {
+ printf("Adding wire\n");
+ loop = new OCCLoop(powire);
+ CGMList->append(loop);
+// imported_entities.append(loop);
+ OCCMap->Bind(*powire, CGMList->where_is_item(loop));
+ populate_topology_bridge_edge(*powire, imported_entities);
+ } else {
+ loop = (OCCLoop*)(*CGMList)[OCCMap->Find(*powire)];
+ }
+ loop->add_surface((OCCSurface*)(*CGMList)[OCCMap->Find(aShape)]);
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_edge(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities)
+{
+ TopExp_Explorer Ex;
+ TopTools_DataMapOfShapeInteger *Map, *Mapr;
+ for (Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) {
+ TopoDS_Edge *poedge = new TopoDS_Edge;
+ *poedge = TopoDS::Edge(Ex.Current());
+ Curve *curve;
+ OCCCoEdge *coedge;
+ TopoDS_Shape test = *poedge;
+ if (poedge->Orientation() == TopAbs_FORWARD) {
+ Map = OCCMap;
+ Mapr = OCCMapr;
+ } else if (poedge->Orientation() == TopAbs_REVERSED) {
+ Map = OCCMapr;
+ Mapr = OCCMap;
+ } else {
+ printf("Oooooop!\n");
+ }
+ if (!Mapr->IsBound(*poedge)) {
+ printf("Adding edge\n");
+ curve = new OCCCurve(poedge);
+ } else {
+ curve = ((OCCCoEdge*)(*CGMList)[Mapr->Find(*poedge)])->curve();
+ }
+ if (!Map->IsBound(*poedge)) {
+ printf("Adding coedge\n");
+ coedge = new OCCCoEdge(poedge, curve);
+ CGMList->append(coedge);
+// CGMList->append(curve);
+ Map->Bind(*poedge, CGMList->where_is_item(coedge));
+ populate_topology_bridge_vertex(*poedge, imported_entities, curve);
+ } else {
+ coedge = (OCCCoEdge*)(*CGMList)[Map->Find(*poedge)];
+ }
+ coedge->add_loop((OCCLoop*)occ_to_cgm(aShape));
+ }
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::populate_topology_bridge_vertex(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities, Curve *curve)
+{
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next()) {
+ TopoDS_Vertex *povertex = new TopoDS_Vertex;
+ *povertex = TopoDS::Vertex(Ex.Current());
+ OCCPoint *point;
+ if (!OCCMap->IsBound(*povertex)) {
+ printf("Adding vertex\n");
+ point = new OCCPoint(povertex);
+ CGMList->append(point);
+// imported_entities.append(point);
+ OCCMap->Bind(*povertex, CGMList->where_is_item(point));
+ } else {
+ point = (OCCPoint*)(*CGMList)[OCCMap->Find(*povertex)];
+ }
+ point->add_curve(curve);
+ }
+ return CUBIT_SUCCESS;
+}
+
+TopologyBridge* OCCQueryEngine::occ_to_cgm(TopoDS_Shape shape)
+{
+
+ if ((shape.ShapeType() != TopAbs_EDGE) || (shape.Orientation() == TopAbs_FORWARD)) return (*CGMList)[OCCMap->Find(shape)];
+ else return (*CGMList)[OCCMapr->Find(shape)];
+/* if (OCCMap->IsBound(shape))*/ return (*CGMList)[OCCMap->Find(shape)];
+// else return (*CGMList)[(*OCCMapt)[shape]];
+}
+
+CubitStatus OCCQueryEngine::import_solid_model(FILE *file_ptr,
+ const char* /*file_type*/,
+ DLIList<TopologyBridge*> &imported_entities,
+ CubitBoolean ,
+ const char* ,
+ CubitBoolean,
+ CubitBoolean,
+ CubitBoolean,
+ CubitBoolean,
+ CubitBoolean,
+ CubitBoolean )
+
+{
+ CubitPoint **points_array = NULL;
+ CurveFacetEvalTool **cfet_array = NULL;
+ FacetEvalTool **fet_array = NULL;
+
+ int num_points, num_edges, num_facets;
+ int num_cfet, num_fet;
+
+ // read in the file type "MESHED_BASED_GEOMETRY"
+ char fileType[19] = {0};
+
+ if( fread( fileType, 1, 19, file_ptr) != 19 )
+ {
+ PRINT_ERROR("Trouble reading in file type for MBG\n");
+ return CUBIT_FAILURE;
+ }
+
+ if( strncmp( fileType, "MESH_BASED_GEOMETRY", 19 ) )
+ {
+ PRINT_ERROR("Not MESH_BASED_GEOMETRY file type\n");
+ return CUBIT_FAILURE;
+ }
+
+ // read in the endian value
+ NCubitFile::CIOWrapper file_reader(file_ptr, 19, 0);
+
+ // read in version #
+ UnsignedInt32 version;
+ file_reader.Read( &version, 1 );
+
+ //Read in points/edges/facets
+ CubitStatus status;
+ status = restore_facets( file_ptr, file_reader.get_endian(),
+ num_points, num_edges,
+ num_facets, points_array, num_cfet,
+ num_fet, cfet_array, fet_array );
+ if( status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("Problems restore facets\n");
+ return CUBIT_FAILURE;
+ }
+
+ //Restore Topology
+ status = restore_topology( file_ptr, file_reader.get_endian(),
+ num_points, points_array,
+ num_cfet, cfet_array, num_fet,
+ fet_array, imported_entities);
+ if( status == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("Problems restore MDB topology\n");
+ return CUBIT_FAILURE;
+ }
+
+
+ if(cfet_array != NULL)
+ delete [] cfet_array;
+ if(fet_array != NULL)
+ delete [] fet_array;
+ if(points_array != NULL)
+ delete [] points_array;
+
+ return CUBIT_SUCCESS;
+}
+
+
+//===============================================================================
+// Function : restore_facets
+// Member Type: PUBLIC
+// Description: restore facets and eval tools onto the list of entities
+// Author : sjowen
+// Date : 1/26/03
+//===============================================================================
+CubitStatus OCCQueryEngine::restore_facets(
+ FILE *fp, // CUB file we are currently reading
+ unsigned int endian,
+ int &num_points,
+ int &num_edges,
+ int &num_facets,
+ CubitPoint **&points,
+ int &num_cfet,
+ int &num_fet,
+ CurveFacetEvalTool **&cfet_array,
+ FacetEvalTool **&fet_array)
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ CubitFacet **facets = NULL;
+ CubitFacetEdge **edges = NULL;
+
+ // read facets from the file and build arrays of facet entities
+
+ rv = read_facets( fp, endian,
+ num_facets, num_edges, num_points,
+ facets, edges, points );
+
+ // create the CurveFacetEvalTools and FacetEval Tools
+
+ if (rv != CUBIT_FAILURE )
+ {
+ rv = restore_eval_tools( fp, endian,
+ num_facets, num_edges, num_points,
+ facets, edges, points,
+ num_cfet, num_fet,
+ cfet_array, fet_array );
+ }
+
+ if (facets != NULL)
+ delete [] facets;
+ if(edges != NULL)
+ delete [] edges;
+ return rv;
+
+}
+
+
+//===============================================================================
+// Function : read_facets
+// Member Type: PUBLIC
+// Description: read facets from the file and create facet entities
+// Author : sjowen
+// Date : 1/26/03
+//===============================================================================
+CubitStatus OCCQueryEngine::read_facets(
+ FILE *fp,
+ unsigned int endian,
+ int &num_facets,
+ int &num_edges,
+ int &num_points,
+ CubitFacet **&facets,
+ CubitFacetEdge **&edges,
+ CubitPoint **&points )
+{
+
+ NCubitFile::CIOWrapper cio(endian, fp );
+ int ii;
+
+ // read points
+ UnsignedInt32 npoints;
+ double uu,vv,ss;
+ cio.Read(&npoints, 1);
+ num_points = (int)npoints;
+ if (num_points > 0)
+ {
+ double* coord_array = new double [num_points * 3];
+ double* uvs_array = new double [num_points * 3];
+ cio.Read(coord_array, npoints*3);
+ cio.Read(uvs_array, npoints*3);
+
+ // create CubitPoints
+ CubitPoint *point_ptr;
+ //CubitVector normal;
+ points = new CubitPoint * [num_points];
+ for(ii=0; ii<num_points; ii++)
+ {
+ point_ptr = (CubitPoint *) new CubitPointData( coord_array[ii*3],
+ coord_array[ii*3+1],
+ coord_array[ii*3+2] );
+ points[ii] = point_ptr;
+ uu = uvs_array[ii*3];
+ vv = uvs_array[ii*3+1];
+ ss = uvs_array[ii*3+2];
+ point_ptr->set_uvs(uu, vv, ss);
+ }
+
+ //Clean up
+ delete [] coord_array;
+ delete [] uvs_array;
+ }
+
+
+ //Read in Normals
+ int nnormals;
+ cio.Read(reinterpret_cast<UnsignedInt32*>(&nnormals), 1);
+ if( nnormals > 0 )
+ {
+ double* normal_array = new double [nnormals * 3];
+ int* normal_ids = new int[nnormals * 3];
+ cio.Read(normal_array, nnormals * 3);
+ cio.Read(reinterpret_cast<UnsignedInt32*>(normal_ids), nnormals);
+ CubitVector normal;
+ for(ii=0; ii<nnormals; ii++)
+ {
+ normal.x( normal_array[ii*3] );
+ normal.y( normal_array[ii*3+1] );
+ normal.z( normal_array[ii*3+2] );
+ points[ normal_ids[ii] ]->normal( normal );
+ }
+
+ //Clean up
+ delete [] normal_array;
+ delete [] normal_ids;
+ }
+
+
+ // read edges and edge control points
+
+ UnsignedInt32 nedges;
+ cio.Read(&nedges, 1);
+ num_edges = (int)nedges;
+ if (num_edges > 0)
+ {
+ UnsignedInt32 *edge_vert_array = new UnsignedInt32 [nedges*2];
+ cio.Read(edge_vert_array, nedges*2);
+ UnsignedInt32 nctrl_pts;
+ cio.Read(&nctrl_pts, 1);
+ double *control_points = NULL;
+ if (nctrl_pts > 0)
+ {
+ control_points = new double [nctrl_pts*3];
+ cio.Read(control_points, nctrl_pts*3);
+ }
+
+ unsigned id0, id1, ii;
+ edges = new CubitFacetEdge * [num_edges];
+ CubitFacetEdge *edge_ptr;
+ for(ii=0; ii<nedges; ii++)
+ {
+ id0 = edge_vert_array[ii*2];
+ id1 = edge_vert_array[ii*2+1];
+
+ edge_ptr = (CubitFacetEdge *) new CubitFacetEdgeData( points[id0], points[id1] );
+ edges[ii] = edge_ptr;
+ if (nctrl_pts > 0)
+ {
+ edge_ptr->set_control_points(&control_points[ii*NUM_EDGE_CPTS*3]);
+ }
+ }
+
+ //Clean up
+ delete [] edge_vert_array;
+ delete [] control_points;
+ edge_vert_array = NULL;
+ control_points = NULL;
+ }
+
+ // read the facets and the facet control points
+
+ UnsignedInt32 nfacets;
+ cio.Read(&nfacets, 1);
+ num_facets = (int)nfacets;
+ if(num_facets > 0)
+ {
+ UnsignedInt32 *facet_edge_array = new UnsignedInt32 [nfacets*3];
+ cio.Read(facet_edge_array, nfacets*3);
+ int *int_data = new int [nfacets*2];
+ cio.Read(reinterpret_cast<UnsignedInt32*>(int_data), nfacets*2);
+
+ UnsignedInt32 nctrl_pts;
+ cio.Read(&nctrl_pts, 1);
+ double *control_points = NULL;
+ if (nctrl_pts > 0)
+ {
+ control_points = new double [nctrl_pts*3];
+ cio.Read(control_points, nctrl_pts*3);
+ }
+
+ unsigned id0, id1, id2, ii;
+ CubitFacet *facet_ptr;
+ facets = new CubitFacet * [num_facets];
+ for (ii=0; ii<nfacets; ii++)
+ {
+ id0 = facet_edge_array[ii*3];
+ id1 = facet_edge_array[ii*3+1];
+ id2 = facet_edge_array[ii*3+2];
+ facet_ptr = (CubitFacet *) new CubitFacetData(edges[id0], edges[id1], edges[id2]);
+ facets[ii] = facet_ptr;
+ facet_ptr->is_flat( int_data[ii*2] );
+ facet_ptr->is_backwards( int_data[ii*2+1] );
+
+ if(nctrl_pts > 0)
+ {
+ facet_ptr->set_control_points(&control_points[ii*NUM_TRI_CPTS*3]);
+ }
+ }
+
+ //Clean up
+ delete [] facet_edge_array;
+ delete [] control_points;
+ delete [] int_data;
+ facet_edge_array = NULL;
+ control_points = NULL;
+ int_data = NULL;
+ }
+
+ // read the extra info at the surface boundaries
+
+ UnsignedInt32 num_c_zero_points = 0;
+ cio.Read(&num_c_zero_points, 1);
+ if (num_c_zero_points > 0)
+ {
+ UnsignedInt32 c_zero_int_data_size;
+
+ cio.Read(&c_zero_int_data_size, 1);
+ if (c_zero_int_data_size <= 0)
+ return CUBIT_FAILURE;
+ UnsignedInt32 *c_zero_int32_data = new UnsignedInt32 [c_zero_int_data_size];
+ cio.Read(c_zero_int32_data, c_zero_int_data_size);
+ int *c_zero_int_data = new int [c_zero_int_data_size];
+ unsigned int jj;
+ for (jj=0; jj<c_zero_int_data_size; jj++)
+ c_zero_int_data[jj] = (int) c_zero_int32_data[jj];
+
+ UnsignedInt32 c_zero_double_data_size;
+
+ cio.Read(&c_zero_double_data_size, 1);
+ if (c_zero_double_data_size <= 0)
+ return CUBIT_FAILURE;
+ double *c_zero_double_data = new double [c_zero_double_data_size];
+ cio.Read(c_zero_double_data, c_zero_double_data_size);
+
+ // create the facet boundary tool datas and assign to points
+
+ int didx = 0;
+ int iidx = 0;
+ UnsignedInt32 zz;
+ for (zz=0; zz<num_c_zero_points; zz++)
+ {
+ if (didx >= (int)c_zero_double_data_size ||
+ iidx >= (int)c_zero_int_data_size)
+ return CUBIT_FAILURE;
+ TDFacetBoundaryPoint::new_facet_boundary_point( points, facets,
+ iidx, didx, c_zero_int_data, c_zero_double_data );
+ }
+
+ //Clean up
+ delete [] c_zero_int_data;
+ delete [] c_zero_int32_data;
+ delete [] c_zero_double_data;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+
+
+
+//-------------------------------------------------------------------------
+// Purpose : Deletes all solid model entities associated with the
+// Bodies in the input list.
+//
+// Special Notes :
+//
+// Creator : Steve Owen
+//
+// Creation Date : 4/23/01
+//-------------------------------------------------------------------------
+void OCCQueryEngine::delete_solid_model_entities(DLIList<BodySM*>&BodyList) const
+{
+ BodySM* BodyPtr = NULL;
+ for (int i = 0; i < BodyList.size(); i++ )
+ {
+ BodyPtr = BodyList.get_and_step();
+ this->delete_solid_model_entities(BodyPtr);
+ }
+
+ return;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Delete a OCCBody and child entities.
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::delete_solid_model_entities( BodySM* bodysm ) const
+{
+ OCCBody* fbody = dynamic_cast<OCCBody*>(bodysm);
+ if (!fbody)
+ return CUBIT_FAILURE;
+
+ DLIList<OCCLump*> lumps;
+ DLIList<OCCShell*> shells;
+ DLIList<OCCSurface*> surfaces;
+
+ fbody->get_lumps(lumps);
+ fbody->disconnect_all_lumps();
+ delete fbody;
+
+ for (int i = lumps.size(); i--; )
+ {
+ OCCLump* lump = lumps.get_and_step();
+
+ shells.clean_out();
+ lump->get_shells(shells);
+ lump->disconnect_all_shells();
+ delete lump;
+
+ for (int j = shells.size(); j--; )
+ {
+ OCCShell* shell = shells.get_and_step();
+
+ surfaces.clean_out();
+ shell->get_surfaces(surfaces);
+ shell->disconnect_all_surfaces();
+ delete shell;
+
+ for (int k = surfaces.size(); k--; )
+ {
+ OCCSurface* surface = surfaces.get_and_step();
+ if (!surface->has_parent_shell())
+ delete_solid_model_entities(surface);
+ }
+ }
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Delete a OCCSurface and child entities.
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::delete_solid_model_entities( Surface* surface ) const
+{
+ OCCSurface* fsurf = dynamic_cast<OCCSurface*>(surface);
+ if (!fsurf || fsurf->has_parent_shell())
+ return CUBIT_FAILURE;
+
+ DLIList<OCCLoop*> loops;
+ DLIList<OCCCoEdge*> coedges;
+
+ fsurf->get_loops(loops);
+ fsurf->disconnect_all_loops();
+ delete fsurf;
+
+ for (int i = loops.size(); i--; )
+ {
+ OCCLoop* loop = loops.get_and_step();
+
+ coedges.clean_out();
+ loop->get_coedges(coedges);
+ loop->disconnect_all_coedges();
+ delete loop;
+
+ for (int j = coedges.size(); j--; )
+ {
+ OCCCoEdge* coedge = coedges.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ {
+ curve->disconnect_coedge(coedge);
+ if (!curve->has_parent_coedge())
+ delete_solid_model_entities(curve);
+ }
+
+ delete coedge;
+ }
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Delete a OCCCurve and child entities.
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::delete_solid_model_entities( Curve* curve ) const
+{
+ OCCCurve* fcurve = dynamic_cast<OCCCurve*>(curve);
+ if (!fcurve || fcurve->has_parent_coedge())
+ return CUBIT_FAILURE;
+
+ OCCPoint* start = dynamic_cast<OCCPoint*>(fcurve->start_point());
+ OCCPoint* end = dynamic_cast<OCCPoint*>(fcurve->end_point() );
+
+ if (start == end )
+ end = NULL;
+
+ if (start)
+ {
+ start->disconnect_curve(fcurve);
+ if (!start->has_parent_curve())
+ delete_solid_model_entities(start);
+ }
+
+ if (end)
+ {
+ end->disconnect_curve(fcurve);
+ if (!end->has_parent_curve())
+ delete_solid_model_entities(end);
+ }
+
+ delete curve;
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Delete a OCCPoint and child entities.
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::delete_solid_model_entities( Point* point ) const
+{
+ OCCPoint* fpoint = dynamic_cast<OCCPoint*>(point);
+ if (!fpoint || fpoint->has_parent_curve())
+ return CUBIT_FAILURE;
+
+ delete point;
+ return CUBIT_SUCCESS;
+}
+
+CubitStatus OCCQueryEngine::fire_ray(BodySM *,
+ const CubitVector &,
+ const CubitVector &,
+ DLIList<double>&,
+ DLIList<GeometryEntity*> *) const
+{
+ PRINT_ERROR("OCCQueryEngine::fire_ray not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+ //- fire a ray at the specified body, returning the entities hit and
+ //- the parameters along the ray; return CUBIT_FAILURE if error
+
+double OCCQueryEngine::get_sme_resabs_tolerance() const
+{
+ PRINT_ERROR("OCCQueryEngine::get_sme_resabs_tolerance not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+// Gets solid modeler's resolution absolute tolerance
+
+double OCCQueryEngine::set_sme_resabs_tolerance( double )
+{
+ PRINT_ERROR("OCCQueryEngine::set_sme_resabs_tolerance not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::set_int_option( const char* , int )
+{
+ PRINT_ERROR("OCCQueryEngine::set_int_option not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::set_dbl_option( const char* , double )
+{
+ PRINT_ERROR("OCCQueryEngine::set_dbl_option not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::set_str_option( const char* , const char* )
+{
+ PRINT_ERROR("OCCQueryEngine::set_str_option not yet implemented.\n");
+ return CUBIT_FAILURE;
+}
+ //- Set solid modeler options
+
+//===========================================================================
+//Function Name: make_facets
+//Member Type: PUBLIC
+//Description: creates Cubit quad facet entities from the hash points and
+// connectivity
+//===========================================================================
+CubitStatus OCCQueryEngine::make_facets(
+ int *conn, // conectivity array (size = 4 * nfacets)
+ int nfacets, // total number of facets (tri+quad)
+ DLIList<CubitQuadFacet *> &facet_list ) // return the facet list
+{
+ CubitQuadFacet *facet_ptr = NULL;
+ CubitStatus rv = CUBIT_SUCCESS;
+ CubitPoint *point0, *point1, *point2, *point3;
+
+ // create the facet array
+
+ for(int ii=0; ii<nfacets; ii++)
+ {
+ if (conn[ii*4+2] != conn[ii*4+3])
+ {
+ point0 = get_hash_point(conn[ii*4]);
+ point1 = get_hash_point(conn[ii*4+1]);
+ point2 = get_hash_point(conn[ii*4+2]);
+ point3 = get_hash_point(conn[ii*4+3]);
+
+ facet_ptr = new CubitQuadFacetData( point0, point1, point2, point3 );
+
+ if (!facet_ptr)
+ {
+ rv = CUBIT_FAILURE;
+ return rv;
+ }
+ facet_list.append( facet_ptr );
+ }
+ }
+ return rv;
+}
+
+//===========================================================================
+//Function Name: make_facets
+//Member Type: PUBLIC
+//Description: creates Cubit tri facet entities from the hash points and
+// connectivity
+//===========================================================================
+CubitStatus OCCQueryEngine::make_facets(
+ int *conn, // conectivity array (size = 4 * nfacets)
+ int nfacets, // total number of facets (tri+quad)
+ DLIList<CubitFacet *> &facet_list ) // return the facet list
+{
+ CubitFacet *facet_ptr = NULL;
+ CubitStatus rv = CUBIT_SUCCESS;
+ CubitPoint *point0, *point1, *point2;
+
+ // create the facet array
+
+ for(int ii=0; ii<nfacets; ii++)
+ {
+ if (conn[ii*4+2] == conn[ii*4+3])
+ {
+ point0 = get_hash_point(conn[ii*4]);
+ point1 = get_hash_point(conn[ii*4+1]);
+ point2 = get_hash_point(conn[ii*4+2]);
+ if( (point0 == point1) || (point0 == point2) || (point1 == point2) ){
+ PRINT_ERROR("Point used more than once in a single facet. This is not allowed.\n");
+ return CUBIT_FAILURE;
+ }
+ if( !point0 || !point1 || !point2 ){
+ PRINT_ERROR("Point in facet is undefined. This is not allowed.\n");
+ return CUBIT_FAILURE;
+ }
+
+ facet_ptr = new CubitFacetData( point0, point1, point2 );
+
+ if (!facet_ptr)
+ {
+ rv = CUBIT_FAILURE;
+ return rv;
+ }
+ facet_list.append( facet_ptr );
+ }
+ }
+
+ return rv;
+}
+
+//===========================================================================
+//Function Name: ensure_is_ascii_stl_file
+//Member Type:
+//Description: returns CUBIT_TRUE in is_ascii if fp is an ascii stl file
+//Author: Plamen Stoyanov (USF)
+//===========================================================================
+CubitStatus OCCQueryEngine::ensure_is_ascii_stl_file(FILE * fp, CubitBoolean &is_ascii)
+{
+
+ char line[128]="";
+
+ if (fgets(line, 128, fp)==NULL)
+ {
+ return CUBIT_FAILURE;
+ }
+ if (fgets(line, 128, fp)==NULL)
+ {
+ return CUBIT_FAILURE;
+ }
+ if (strlen(line)==127)
+ {
+ if (fgets(line, 128, fp)==NULL)
+ {
+ return CUBIT_FAILURE;
+ }
+ }
+
+
+ unsigned int dummy_int=0;
+
+ while (isspace(line[dummy_int])&& dummy_int<strlen(line)) dummy_int++;
+
+ if (strlen(line)-dummy_int>5)
+ {
+ if (tolower(line[dummy_int++])=='f' &&
+ tolower(line[dummy_int++])=='a' &&
+ tolower(line[dummy_int++])=='c' &&
+ tolower(line[dummy_int++])=='e' &&
+ tolower(line[dummy_int])=='t')
+ {
+ if (fgets(line, 128, fp)==NULL)
+ {
+ return CUBIT_FAILURE;
+ }
+ dummy_int=0;
+ while (isspace(line[dummy_int])&& dummy_int<strlen(line))
+ {
+ dummy_int++;
+ }
+ if (strlen(line)-dummy_int>5)
+ {
+ if (tolower(line[dummy_int++])=='o' &&
+ tolower(line[dummy_int++])=='u' &&
+ tolower(line[dummy_int++])=='t' &&
+ tolower(line[dummy_int++])=='e' &&
+ tolower(line[dummy_int])=='r')
+ {
+ if (fgets(line, 128, fp)==NULL)
+ {
+ return CUBIT_FAILURE;
+ }
+ dummy_int=0;
+ while (isspace(line[dummy_int])&& dummy_int<strlen(line)) {
+ dummy_int++;
+ }
+ if (strlen(line)-dummy_int>6)
+ {
+ if (tolower(line[dummy_int++])=='v' &&
+ tolower(line[dummy_int++])=='e' &&
+ tolower(line[dummy_int++])=='r' &&
+ tolower(line[dummy_int++])=='t' &&
+ tolower(line[dummy_int++])=='e' &&
+ tolower(line[dummy_int])=='x')
+ {
+ is_ascii=CUBIT_TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ return CUBIT_SUCCESS;
+}
+
+//===========================================================================
+//Function Name: read_facets_stl
+//Member Type:
+//Description: read facets from stl file combining vertices within tolerance
+//distance
+//Author: Plamen Stoyanov (USF)
+//===========================================================================
+CubitStatus OCCQueryEngine::read_facets_stl_tolerance(
+ DLIList<CubitFacet *> &tfacet_list,
+ DLIList<CubitPoint *> & /*point_list*/,
+ const char * file_name,
+ int &npoints,
+ int &ntri,
+ long& seek_address,
+ double tolerance
+ )
+{
+
+ FILE *fp = fopen(file_name, "r");
+ if (fp == NULL)
+ {
+ PRINT_ERROR("Could not open file %s for reading\n", file_name);
+ seek_address = 0;
+ return CUBIT_FAILURE;
+ }
+
+ DLIList <CubitPoint *> file_points;
+ CubitPoint *current_point;
+ int points_in_file=0;
+ int ii;
+
+ CubitBoolean is_ascii=CUBIT_FALSE;
+ if (!ensure_is_ascii_stl_file(fp, is_ascii))
+ {
+ seek_address = 0;
+ fclose(fp);
+ return CUBIT_FAILURE;
+ }
+
+ if (is_ascii==CUBIT_TRUE)
+ {
+
+ PRINT_INFO("Reading facets...\n");
+ fclose(fp);
+ fp = fopen(file_name, "r");
+ fseek(fp,seek_address,SEEK_SET);
+
+ char line[128], junk[30];
+ int numverts;
+ double xx[3], yy[3], zz[3];
+ int linenumber, num;
+ bool done, error_found, eof_found;
+
+ linenumber = 0;
+
+ strcpy(line,"");
+ done = false;
+ error_found = false;
+ eof_found = false;
+ while ( (strstr(line,"endsolid") == 0) && (error_found == false) ) {
+ numverts = 0;
+ while ( numverts < 3 ) {
+ if ( fgets(line,127,fp) == 0 ) {
+ linenumber++;
+ eof_found = true;
+ break; // EOF
+ }
+ linenumber++;
+// makelowercase(line);
+ int len, ij;
+ len = strlen(line);
+ for ( ij = 0; ij < len; ij++ )
+ line[ij] = tolower(line[ij]);
+
+ if ( strstr(line,"endsolid") != 0 ) {
+ done = true;
+ break; // End of part definition
+ }
+ if ( strstr(line,"vertex") != 0 ) {
+ num = sscanf(line,"%s %le %le %le",junk,&xx[numverts],&yy[numverts],&zz[numverts]);
+ if ( num != 4 ) {
+ error_found = true;
+ break; // error in reading vertices
+ }
+ numverts += 1;
+ }
+ } // end of while ( numverts < 3 )
+
+ if ( (eof_found == true) || (done == true) ||
+ (error_found == true) || (numverts != 3) ) break;
+
+ current_point = (CubitPoint *) new CubitPointData(xx[0],yy[0],zz[0]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+ current_point = (CubitPoint *) new CubitPointData(xx[1],yy[1],zz[1]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+ current_point = (CubitPoint *) new CubitPointData(xx[2],yy[2],zz[2]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+
+ }
+ seek_address = 0;
+ if ( eof_found == true ) {
+ PRINT_WARNING("Premature end-of-file on STL file. Body may be incomplete.\n");
+ fclose(fp);
+ goto end_read_file_points;
+ }
+ if ( error_found == true ) {
+ PRINT_WARNING("Error found while reading line number %d of file %s. Body may be incomplete.\n",
+ linenumber,file_name);
+ fclose(fp);
+ goto end_read_file_points;
+ }
+ if ( done == false ) {
+ PRINT_WARNING("Error found while reading line number %d of file %s. Body may be incomplete.\n",
+ linenumber,file_name);
+ fclose(fp);
+ goto end_read_file_points;
+ }
+
+ if ( (eof_found == false) && (error_found == false) && (done == true) ) {
+ while ( fgets(line,127,fp) != 0 ) {
+ if ( (strstr(line,"solid") != 0) && (strstr(line,"endsolid") == 0) ) {
+ seek_address = ftell(fp);
+ break;
+ }
+ }
+ }
+ fclose(fp);
+ goto end_read_file_points;
+ }
+ else
+ {
+ fclose(fp);
+ // file is closed so that it can be opened as binary
+ fp = fopen(file_name, "rb");
+ if (fp == NULL)
+ {
+ PRINT_ERROR("Could not open file %s for reading\n", file_name);
+ return CUBIT_FAILURE;
+ }
+
+ char dummy;
+ // iterates through the facets of the file
+ float cur[12]; // an array to hold 48 bytes representing 1AVS facet
+
+ fseek(fp, 80, SEEK_SET);
+ fread(&ntri, 4, 1, fp);
+
+ PRINT_INFO ("Reading facets...\n");
+ for (ii=0; ii<ntri; ii++) {
+ // read in 1 facet
+ if (!fread(cur, 4, 12, fp))
+ {
+ PRINT_INFO ("Abnormal file termination %s \n", file_name); break;
+ }
+ fread(&dummy, 1, 1, fp);
+ fread(&dummy, 1, 1, fp);
+
+ //make point
+ current_point = (CubitPoint *) new CubitPointData(cur[3],cur[4],cur[5]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+ current_point = (CubitPoint *) new CubitPointData(cur[6],cur[7],cur[8]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+ current_point = (CubitPoint *) new CubitPointData(cur[9],cur[10],cur[11]);
+ current_point->set_id(points_in_file++);
+ file_points.append(current_point);
+ }
+ }
+ fclose(fp);
+
+// at this point all points from the file are in file_points
+end_read_file_points:
+
+ // grid search tree to hold points
+ GridSearchTree * node_grid = new GridSearchTree (tolerance);
+
+ CubitPoint
+ *point0,
+ *point1,
+ *point2;
+ CubitFacet
+ *facet_ptr;
+ ntri=0;
+ npoints=0;
+
+ if (file_points.size() % 3 != 0)
+ {
+ PRINT_INFO("File Error.");
+ return CUBIT_FAILURE;
+ }
+
+ for (ii = file_points.size(); ii>0; ii-=3)
+ {
+
+ // get three points from the file_points list
+ // and compare them against the data already in the
+ // grid search tree; if it contains a point within
+ // epsilon tolerance this point would replace the
+ // current point
+ point0 = node_grid->fix(file_points.get_and_step());
+ point1 = node_grid->fix(file_points.get_and_step());
+ point2 = node_grid->fix(file_points.get_and_step());
+
+
+ if (point0 && point1 && point2 && point0 != point1 && point1!=point2 && point2!=point0 )
+ {
+
+ facet_ptr = new CubitFacetData(point0, point1, point2);
+
+ if (facet_ptr)
+ {
+ tfacet_list.append(facet_ptr);
+ ntri++;
+ }
+
+ }
+ }
+
+ //delete node_grid;
+ return CUBIT_SUCCESS;
+}
+
+
+//===========================================================================
+//Function Name: read_facets_stl
+//Member Type:
+//Description: read facets from stl file
+//Author: Plamen Stoyanov (USF)
+//===========================================================================
+
+CubitStatus OCCQueryEngine::read_facets_stl(
+ DLIList<CubitFacet *> &tfacet_list,
+ DLIList<CubitPoint *> &point_list,
+ const char * file_name,
+ int &npoints,
+ int &ntri,
+ long& seek_address
+ )
+{
+
+ ntri = 0;
+ npoints = 0;
+ FILE *fp = fopen(file_name, "r");
+ if (fp == NULL)
+ {
+ PRINT_ERROR("Could not open file %s for reading\n", file_name);
+ seek_address = 0;
+ return CUBIT_FAILURE;
+ }
+
+ typedef STD(map)< CubitPoint * , int, CubitPointComparator > vMap;
+
+ vMap mm; // binary search tree to hold the vertices for efficiency
+ vMap::iterator pos;
+ bool append_to_facet_list=CUBIT_TRUE;
+
+ CubitBoolean is_ascii=CUBIT_FALSE;
+
+ if (!ensure_is_ascii_stl_file(fp, is_ascii))
+ {
+ seek_address = 0;
+ fclose(fp);
+ return CUBIT_FAILURE;
+ }
+
+ if (is_ascii==CUBIT_TRUE)
+ {
+ CubitPoint *point0,*point1,*point2;
+ CubitFacet *facet_ptr = NULL;
+
+ PRINT_INFO("Reading facets...\n");
+ fclose(fp);
+ fp = fopen(file_name, "r");
+ fseek(fp,seek_address,SEEK_SET);
+ char line[128], junk[30];
+ int numverts;
+ double xx[3], yy[3], zz[3];
+ int linenumber, num;
+ bool done, error_found, eof_found;
+
+ linenumber = 0;
+
+ strcpy(line,"");
+ done = false;
+ error_found = false;
+ eof_found = false;
+ while ( (strstr(line,"endsolid") == 0) && (error_found == false) ) {
+ numverts = 0;
+ while ( numverts < 3 ) {
+ if ( fgets(line,127,fp) == 0 ) {
+ linenumber++;
+ eof_found = true;
+ break; // EOF
+ }
+ linenumber++;
+// makelowercase(line);
+ int len, ij;
+ len = strlen(line);
+ for ( ij = 0; ij < len; ij++ )
+ line[ij] = tolower(line[ij]);
+
+ if ( strstr(line,"endsolid") != 0 ) {
+ done = true;
+ break; // End of part definition
+ }
+ if ( strstr(line,"vertex") != 0 ) {
+ num = sscanf(line,"%s %le %le %le",junk,&xx[numverts],&yy[numverts],&zz[numverts]);
+ if ( num != 4 ) {
+ error_found = true;
+ break; // error in reading vertices
+ }
+ numverts += 1;
+ }
+ } // end of while ( numverts < 3 )
+
+ if ( (eof_found == true) || (done == true) ||
+ (error_found == true) || (numverts != 3) ) break;
+ point0 = (CubitPoint *) new CubitPointData(xx[0],yy[0],zz[0]);
+ pos=mm.find(point0);
+
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point0, npoints));
+ point0->set_id( npoints ++ );
+ //point_list is output of functionAVS
+ point_list.append(point0);
+ }
+ else
+ {
+ delete point0;
+ point0=((*pos).first);
+ }
+ point1 = (CubitPoint *) new CubitPointData(xx[1],yy[1],zz[1]);
+ pos=mm.find(point1);
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point1, npoints));
+ point1->set_id( npoints ++ );
+ //point_list is output of function
+ point_list.append(point1);
+ }
+ else
+ {
+ delete point1;
+ point1=((*pos).first);
+ }
+ point2 = (CubitPoint *) new CubitPointData(xx[2],yy[2],zz[2]);
+ pos=mm.find(point2);
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point2, npoints));
+ point2->set_id( npoints ++ );
+ //point_list is output of function
+ point_list.append(point2);
+ }
+ else
+ {
+ delete point2;
+ point2=((*pos).first);
+ }
+
+ if (point0 && point1 && point2 && point0!=point1 && point1!=point2 && point2 !=point0)
+ {
+ facet_ptr = new CubitFacetData( point0, point1, point2 );
+ append_to_facet_list=CUBIT_TRUE;
+ }
+ else
+ {
+ append_to_facet_list=CUBIT_FALSE;
+ }
+
+ if (!facet_ptr)
+ {
+ seek_address = 0;
+ fclose(fp);
+ return CUBIT_FAILURE;
+ }
+
+ /// APPEND facet to output facet_ptr list
+ if (append_to_facet_list)
+ {
+ tfacet_list.append( facet_ptr );
+ ntri++;
+ }
+
+ }
+ seek_address = 0;
+ if ( eof_found == true ) {
+ PRINT_WARNING("Premature end-of-file on STL file. Body may be incomplete.\n");
+ fclose(fp);
+ return CUBIT_SUCCESS;
+ }
+ if ( error_found == true ) {
+ PRINT_WARNING("Error found while reading line number %d of file %s. Body may be incomplete.\n",
+ linenumber,file_name);
+ fclose(fp);
+ return CUBIT_SUCCESS;
+ }
+ if ( done == false ) {
+ PRINT_WARNING("Error found while reading line number %d of file %s. Body may be incomplete.\n",
+ linenumber,file_name);
+ fclose(fp);
+ return CUBIT_SUCCESS;
+ }
+
+ if ( (eof_found == false) && (error_found == false) && (done == true) ) {
+ while ( fgets(line,127,fp) != 0 ) {
+ if ( (strstr(line,"solid") != 0) && (strstr(line,"endsolid") == 0) ) {
+ seek_address = ftell(fp);
+// PRINT_INFO("This STL file is a multipart file. Only the first part was read.\n");
+ break;
+ }
+ }
+ }
+ fclose(fp);
+
+ return CUBIT_SUCCESS;
+ }
+ else
+ {
+ fclose(fp);
+ // file is closed so that it can be opened as binary
+ fp = fopen(file_name, "rb");
+ if (fp == NULL)
+ {
+ PRINT_ERROR("Could not open file %s for reading\n", file_name);
+ return CUBIT_FAILURE;
+ }
+
+
+ CubitFacet *facet_ptr = NULL;
+ CubitPoint *point0,
+ *point1,
+ *point2;
+
+ char dummy;
+ int ii=0; // iterates through the facets of the file
+ float cur[12]; // an array to hold 48 bytes representing 1 facet
+ npoints=0; // only tri facets in stl files
+
+ fseek(fp, 80, SEEK_SET);
+ fread(&ntri, 4, 1, fp);
+ int distinct_ntri=ntri;
+
+ PRINT_INFO ("Reading facets...\n");
+ for (ii=0; ii<ntri; ii++) {
+ // read in 1 facet
+ if (!fread(cur, 4, 12, fp))
+ {
+ PRINT_INFO ("Abnormal file termination %s \n", file_name); break;
+ }
+ fread(&dummy, 1, 1, fp);
+ fread(&dummy, 1, 1, fp);
+
+ //make point
+ point0 = (CubitPoint *) new CubitPointData( cur[3], cur[4], cur[5] );
+
+ pos=mm.find(point0);
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point0, npoints));
+ point0->set_id( npoints ++ );
+ //point_list is output of function
+ point_list.append(point0);
+ }
+ else
+ {
+ delete point0;
+ point0=((*pos).first);
+ }
+
+ //make point
+ point1 = (CubitPoint *) new CubitPointData( cur[6], cur[7], cur[8] );
+
+ pos=mm.find(point1);
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point1, npoints));
+ point1->set_id( npoints ++ );
+ //point_list is output of function
+ point_list.append(point1);
+ }
+ else
+ {
+ delete point1;
+ point1=((*pos).first);
+ }
+
+ //make point
+ point2 = (CubitPoint *) new CubitPointData( cur[9], cur[10], cur[11] );
+
+ pos=mm.find(point2);
+ if (pos==mm.end())
+ {
+ mm.insert ( vMap::value_type(point2, npoints));
+ point2->set_id( npoints ++ );
+ //point_list is output of function
+ point_list.append(point2);
+ }
+ else
+ {
+ delete point2;
+ point2=((*pos).first);
+ }
+
+ // this is to avoid a facet with all points on same line, which crashes CUBIT
+ // because of assertion
+ if (point0 && point1 && point2 && point0!=point1 && point1!=point2 && point2 !=point0)
+ {
+ facet_ptr = new CubitFacetData( point0, point1, point2 );
+ append_to_facet_list=CUBIT_TRUE;
+ }
+ else
+ {
+ append_to_facet_list=CUBIT_FALSE;
+ }
+
+ if (!facet_ptr)
+ {
+ fclose(fp);
+ return CUBIT_FAILURE;
+ }
+
+ if (append_to_facet_list)
+ {
+ tfacet_list.append( facet_ptr );
+ }
+ else
+ {
+ distinct_ntri--;
+ }
+ }
+ ntri=distinct_ntri;
+ fclose(fp);
+ return CUBIT_SUCCESS;
+ }
+}
+
+
+//===========================================================================
+//Function Name: import_facets
+//Member Type: PUBLIC
+//Description: import facets and create geometry
+//===========================================================================
+CubitStatus OCCQueryEngine::import_facets(
+ const char *file_name, // to be read
+ CubitBoolean use_feature_angle, // to define where surfaces are broken
+ double feature_angle, // angle where surfaces are broken (degrees)
+ double tolerance, // for stl files loading
+ int interp_order, // Facet representation 1= linear, 4= Bezier
+ CubitBoolean smooth_non_manifold, // continutiy accross non-manifold edges
+ CubitBoolean split_surfaces, // break facet rep at surface boundaries
+ CubitBoolean stitch, // attempt to stitch together facets at the boundary
+ CubitBoolean improve, // smooth, swap and collapse to improve quality
+ DLIList<CubitQuadFacet *> &quad_facet_list, // return quad facets
+ DLIList<CubitFacet *> &tri_facet_list, // return tri facets
+ DLIList<Surface *> &surface_list, // return list of surfaces
+ FacetFileFormat file_format )
+{
+ DLIList <CubitFacet *>tfacet_list;
+ DLIList <CubitQuadFacet *>qfacet_list;
+ DLIList <CubitPoint *>point_list;
+
+ ShellSM *shell_ptr;
+ DLIList<ShellSM*> shell_list;
+ Lump *lump_ptr;
+ DLIList<Lump*> lump_list;
+ BodySM *bodysm_ptr;
+ Body *body_ptr;
+ GeometryQueryTool *gti = GeometryQueryTool::instance();
+ OCCShell* facet_shell;
+ DLIList<DLIList<CubitFacet *> *> shell_facet_list;
+ int ishell, ii;
+ CubitBoolean is_water_tight = CUBIT_TRUE;
+
+ // read the facets from a file
+
+ int *conn = NULL;
+ int npoints = 0;
+ int nfacets = 0;
+ int nquad = 0;
+ int ntri = 0;
+
+ int prev_vert;
+ int prev_edge;
+ int prev_face;
+ int prev_vol;
+ int prev_bod;
+
+ long stl_seek_address=0;
+ bool stl_multiple_parts = true;
+
+ CubitStatus rv;
+ // Here we add the capability to read stl files with more than one part.
+ while ( stl_multiple_parts == true ) {
+ stl_multiple_parts = false;
+ prev_vert = gti->num_ref_vertices();
+ prev_edge = gti->num_ref_edges();
+ prev_face = gti->num_ref_faces();
+ prev_vol = gti->num_ref_volumes();
+ prev_bod = gti->num_bodies();
+ switch (file_format)
+ {
+ case STL_FILE:
+ tfacet_list.clean_out(); // In case there are multiple parts in the stl file
+ point_list.clean_out();
+ shell_list.clean_out();
+ lump_list.clean_out();
+ shell_facet_list.clean_out();
+ if (tolerance>0)
+ {
+ rv = read_facets_stl_tolerance(tfacet_list, point_list, file_name, npoints, ntri, stl_seek_address, tolerance);
+ }
+ else
+ {
+ rv = read_facets_stl(tfacet_list, point_list, file_name, npoints, ntri, stl_seek_address);
+ }
+ PRINT_INFO(" %d facets read.\n", ntri);
+ if ( (rv == CUBIT_SUCCESS) && (stl_seek_address) > 0 ) stl_multiple_parts = true;
+ nfacets = ntri;
+
+ if (rv != CUBIT_SUCCESS)
+ {
+ goto end_import_facets;
+ }
+ break;
+
+ case CUBIT_FACET_FILE:
+ case AVS_FILE:
+ rv = read_facets( file_name, conn, npoints, nquad, ntri, file_format );
+
+ nfacets = ntri + nquad;
+
+ if (rv != CUBIT_SUCCESS)
+ goto end_import_facets;
+
+ // make cubit facet entities from the points and connectivity
+
+ if (nquad > 0)
+ rv = make_facets(conn, nfacets, qfacet_list);
+ if (ntri > 0)
+ rv = make_facets(conn, nfacets, tfacet_list);
+ if (rv != CUBIT_SUCCESS)
+ goto end_import_facets;
+ get_all_hash_points(point_list);
+ delete_hash_points();
+ break;
+ case CHOLLA_FILE:
+ rv = read_cholla_file( file_name, feature_angle, point_list, tfacet_list );
+ nquad = 0;
+ ntri = tfacet_list.size();
+ npoints = point_list.size();
+ break;
+ case FROM_FACET_LIST:
+ tfacet_list = tri_facet_list;
+ qfacet_list = quad_facet_list;
+ if (tfacet_list.size() + qfacet_list.size() == 0)
+ {
+ PRINT_ERROR("No facets found to build geometry\n");
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+ break;
+ default:
+ assert(0); // unrecognized file format
+ break;
+ }
+
+ if (tfacet_list.size() + qfacet_list.size() == 0)
+ {
+ PRINT_ERROR("No facets read from file %s.\n", file_name);
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+ else
+ {
+ PRINT_INFO("Building facet-based geometry from %d facets...\n",
+ tfacet_list.size() + qfacet_list.size() );
+ }
+
+// if (fix)
+// {
+// rv = check_facets( point_list, tfacet_list );
+// }
+
+ if (0)
+ {
+ // Call function to generate an x-y-z file for a CTH/SPH simulation
+ // the following is an exampl call...
+ //make_sph( point_list, tfacet_list, 100.0, "fem1-sph100.xyz" );
+ }
+
+ if (0)
+ {
+ // This is an example of using the export_facets function. Writes
+ // a facet file of all facets in the list
+
+ //commented out because otherwise it's a compiler warning.
+
+// char filename[128];
+// strcpy(filename, "my_test.facets");
+// export_facets(tfacet_list,filename);
+ }
+
+
+ // split the facets into shells if needed
+
+ rv = FacetDataUtil::split_into_shells(tfacet_list, qfacet_list,
+ shell_facet_list, is_water_tight);
+ if (rv != CUBIT_SUCCESS)
+ {
+ PRINT_ERROR("Error processing facets from %s.\n", file_name);
+ goto end_import_facets;
+ }
+
+ // if the facets aren't watertight, see if they can be merged
+
+ if (!is_water_tight && stitch)
+ {
+ rv = FacetDataUtil::stitch_facets(shell_facet_list,
+ GEOMETRY_RESABS,
+ is_water_tight);
+ if (rv != CUBIT_SUCCESS)
+ {
+ PRINT_WARNING("Couldn't stitch facets.\n");
+ }
+ }
+
+ DLIList <CubitFacet *> *facet_list_ptr;
+ if (improve)
+ {
+ for (ishell = 0; ishell < shell_facet_list.size(); ishell++)
+ {
+ facet_list_ptr = shell_facet_list.get_and_step();
+ rv = FacetDataUtil::collapse_short_edges( *facet_list_ptr, CUBIT_TRUE );
+ if (rv != CUBIT_SUCCESS)
+ {
+ PRINT_WARNING("Couldn't improve facets.\n");
+ }
+ }
+ }
+
+ // create the surface geometry
+
+ if (!use_feature_angle)
+ feature_angle = -1.0;
+
+ for (ishell = 0; ishell < shell_facet_list.size(); ishell++)
+ {
+ DLIList <Surface *> shell_surfaces;
+ DLIList <CubitPoint *> mypoint_list;
+ facet_list_ptr = shell_facet_list.get_and_step();
+ rv = OCCModifyEngine::instance()->build_facet_surface( NULL,
+ *facet_list_ptr, mypoint_list,
+ feature_angle, interp_order,
+ smooth_non_manifold,
+ split_surfaces, shell_surfaces);
+ if (rv != CUBIT_SUCCESS || shell_surfaces.size() == 0)
+ {
+ PRINT_ERROR("Couldn't build facet based geometry from facets in %s\n", file_name);
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+
+ // make a shell out of these surfaces
+
+ rv = OCCModifyEngine::instance()->make_facet_shell(shell_surfaces, shell_ptr);
+ if ( shell_ptr == NULL || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based shell entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+
+ //Set the sense for the surfaces (will be cofaces) on this shell.
+ //Assumption: The sense is always forward when creating geom from facets.
+ // (This may not be correct -especially with multiple shells in a body)
+
+ facet_shell = CAST_TO( shell_ptr, OCCShell );
+ for( ii = shell_surfaces.size(); ii > 0; ii-- )
+ {
+ Surface* surf = shell_surfaces.get_and_step();
+ OCCSurface* facet_surf = CAST_TO( surf, OCCSurface );
+ facet_surf->set_shell_sense( facet_shell, CUBIT_FORWARD );
+ }
+
+ surface_list += shell_surfaces;
+ shell_list.append(shell_ptr);
+ }
+
+ // make a body out of it
+
+ rv = OCCModifyEngine::instance()->make_facet_lump(shell_list,lump_ptr);
+ if ( lump_ptr == NULL || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based lump entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+ lump_list.append(lump_ptr);
+ rv = OCCModifyEngine::instance()->make_facet_body(lump_list,bodysm_ptr);
+ body_ptr = GeometryQueryTool::instance()->make_Body(bodysm_ptr);
+
+ if ( body_ptr == NULL || rv != CUBIT_SUCCESS )
+ {
+ PRINT_ERROR("Problems building facet based body entity.\n");
+ rv = CUBIT_FAILURE;
+ goto end_import_facets;
+ }
+
+ if(gti->num_bodies() - prev_bod > 1)
+ PRINT_INFO("Bodies successfully created.\n");
+ else
+ PRINT_INFO("Body successfully created.\n");
+ PRINT_INFO(" Number of new vertices = %d\n", gti->num_ref_vertices() - prev_vert);
+ PRINT_INFO(" Number of new curves = %d\n", gti->num_ref_edges() - prev_edge);
+ PRINT_INFO(" Number of new surfaces = %d\n", gti->num_ref_faces() - prev_face);
+ PRINT_INFO(" Number of new shells = %d\n", shell_facet_list.size());
+ PRINT_INFO(" Number of new volumes = %d\n", gti->num_ref_volumes() - prev_vol);
+ PRINT_INFO(" Number of new bodies = %d\n", gti->num_bodies() - prev_bod);
+
+ if (!is_water_tight)
+ {
+ PRINT_WARNING("Volume generated does not completely close. 3D meshing (ie. hex/tet) will not be permitted.\n");
+ PRINT_INFO("Hint: In some cases the \"stitch\" option on the import command may correct the problem.\n");
+ }
+ } // end while ( stl_multiple_parts == true )
+
+end_import_facets:
+ if (conn != NULL)
+ delete [] conn;
+ for (ii=0; ii<shell_list.size(); ii++)
+ delete shell_facet_list.get_and_step();
+
+ quad_facet_list = qfacet_list;
+ tri_facet_list = tfacet_list;
+ return rv;
+}
+
+
+
+//===========================================================================
+//Function Name: read_facets
+//Member Type: PUBLIC
+//Description: read facets from facet file
+//===========================================================================
+CubitStatus OCCQueryEngine::read_facets( const char * file_name,
+ int *&conn,
+ int &npoints,
+ int &nquad, int &ntri,
+ FacetFileFormat file_format )
+{
+ // open the file
+ FILE *fp = fopen(file_name, "r");
+ if (fp == NULL)
+ {
+ PRINT_ERROR("Could not open file %s for reading\n", file_name);
+ return CUBIT_FAILURE;
+ }
+
+ PRINT_INFO("Reading facets...\n");
+
+ // read the number of nodes
+
+ int id;
+ int nfacets = 0;
+ int iline = 1;
+ char line[128];
+ if (fgets(line, 128, fp) == NULL)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ int n = sscanf(line, "%d %d", &npoints, &nfacets);
+ if (n < 1 || n > 2 && file_format == CUBIT_FACET_FILE )
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ if (npoints <= 0)
+ {
+ PRINT_ERROR("Expecting number of nodes in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ if (n==1)
+ {
+ nfacets = 0;
+ }
+ else if (nfacets <= 0)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d reading number of facets\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ if (init_hash_points( npoints ) == CUBIT_FAILURE)
+ {
+ PRINT_ERROR("Can't allocate memory for points in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ // read the nodes
+
+ int ii;
+ double xx, yy, zz;
+ CubitPoint *new_point;
+ for (ii=0; ii<npoints; ii++)
+ {
+ iline++;
+ if (fgets(line, 128, fp)== NULL)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ n = sscanf(line, "%d %lf %lf %lf", &id, &xx, &yy, &zz );
+ if (n != 4)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d\n", file_name, iline);
+ PRINT_INFO(" Expecting 1 integer and 3 doubles, but instead read %d values\n", n);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ new_point = (CubitPoint *) new CubitPointData( xx, yy, zz );
+ new_point->set_id( id );
+ add_hash_point( new_point );
+ }
+
+ // read the number of facets
+
+ if (nfacets == 0)
+ {
+ iline++;
+ if (fgets(line, 128, fp) == NULL)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d reading number of facets\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ n = sscanf(line, "%d", &nfacets);
+ if (n != 1)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d reading number of facets\n", file_name, iline);
+ PRINT_INFO(" Expecting <num facets>\n");
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ if (nfacets <= 0)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d reading number of facets\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ }
+
+ conn = new int [4*nfacets];
+ if (!conn)
+ {
+ PRINT_ERROR("Can't allocate memory for facets in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+ ntri = nquad = 0;
+
+ // read the facets
+
+ for (ii=0; ii<nfacets; ii++)
+ {
+ iline++;
+ if (fgets(line, 128, fp) == NULL)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d\n", file_name, iline);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ if( AVS_FILE == file_format )
+ {
+ n = sscanf( line, "%d %*d %*s %d %d %d %d", &id, &conn[4*ii],
+ &conn[4*ii+1], &conn[4*ii+2], &conn[4*ii+3] );
+
+ if( n < 4 || n > 5 )
+ {
+ PRINT_ERROR("Format error in avs file %s on line %d reading facets\n", file_name, iline);
+ PRINT_INFO("Expecting 6 or 7 values, but instead read %d values\n", n);
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ //duplicate the point
+ if( n == 4 )
+ {
+ conn[4*ii+3] = conn[4*ii+2];
+ ntri++;
+ }
+ else
+ {
+ nquad++;
+ }
+ }
+ else
+ {
+ n = sscanf(line, "%d %d %d %d %d", &id, &conn[4*ii], &conn[4*ii+1],
+ &conn[4*ii+2], &conn[4*ii+3] );
+
+ if (n < 4 || n > 5)
+ {
+ PRINT_ERROR("Format error in facet file %s on line %d reading facets\n", file_name, iline);
+ PRINT_INFO(" Expecting 4 or 5 integers, but instead read %d values\n", n);
+ PRINT_INFO(" For example: <id> <i0> <i1> <i2> [<i3>]\n");
+ fclose( fp );
+ return CUBIT_FAILURE;
+ }
+
+ // for triangles -- duplicate the point
+ if (n==4)
+ {
+ conn[4*ii+3] = conn[4*ii+2];
+ ntri++;
+ }
+ else
+ {
+ nquad++;
+ }
+ }
+ }
+
+ fclose( fp );
+ return CUBIT_SUCCESS;
+}
+
+//===========================================================================
+// Function: read_cholla_file
+// Purpose: import the face mesh from the cholla file
+// Date: 11/28/2002
+// Author: sjowen
+//===========================================================================
+CubitStatus OCCQueryEngine::read_cholla_file( const char *file_name,
+ double &feature_angle,
+ DLIList<CubitPoint *> &point_list,
+ DLIList<CubitFacet *> &facet_list )
+
+{
+
+ double angle = 135.0;
+ int num_tri = 0;
+ int num_quad = 0;
+ int num_edge = 0;
+ int num_vert = 0;
+ int* tri_edge = NULL;
+ int* quad_edge = NULL;
+ int* edge_vert = NULL;
+ double* vert = NULL;
+ double* edge_ctrl_pts = NULL;
+ double* tri_ctrl_pts = NULL;
+ double* quad_ctrl_pts = NULL;
+ int results_included = 0;
+
+ // importMesh and resolveFaceVectors are in Cholla.h
+
+ importMesh(file_name, &results_included, &angle, &num_tri, &num_quad, &num_edge,
+ &num_vert, &tri_edge, &quad_edge, &edge_vert, &vert,
+ &edge_ctrl_pts, &tri_ctrl_pts, &quad_ctrl_pts);
+
+ feature_angle = angle;
+
+ // create the points
+
+ CubitPoint **point_array = new CubitPoint * [num_vert];
+ double x, y, z;
+ int ii;
+
+ for (ii=0; ii<num_vert; ii++)
+ {
+ x = vert[ii*3];
+ y = vert[ii*3 + 1];
+ z = vert[ii*3 + 2];
+ point_array[ii] = (CubitPoint *) new CubitPointData( x, y, z );
+ point_list.append( point_array[ii] );
+ }
+
+ // create the edges
+
+ CubitFacetEdge **edge_array = new CubitFacetEdge * [num_edge];
+ int ip, jp;
+ for (ii=0; ii<num_edge; ii++)
+ {
+ ip = edge_vert[ii*2];
+ jp = edge_vert[ii*2 + 1];
+ assert(ip < num_vert && jp < num_vert && ip >= 0 && jp >= 0);
+ edge_array[ii] = (CubitFacetEdge *) new CubitFacetEdgeData( point_array[ip],
+ point_array[jp] );
+ }
+
+ // create the tri facets
+
+ int begin_face;
+ int jj, iedge;
+ CubitFacetEdge *edges[4];
+ CubitFacet *facet_ptr = NULL;
+ CubitQuadFacet *qfacet_ptr = NULL;
+ for (ii=0; ii<num_tri; ii++)
+ {
+ begin_face = 3 * ii;
+ for(jj=0; jj<3; jj++)
+ {
+ iedge = tri_edge[begin_face+jj];
+ edges[jj] = edge_array[iedge];
+ }
+ facet_ptr = (CubitFacet *)
+ new CubitFacetData(edges[0], edges[1], edges[2]);
+ facet_list.append(facet_ptr);
+ }
+
+ // create the quad facets
+
+ for (ii=0; ii<num_quad; ii++)
+ {
+ begin_face = 4 * ii;
+ for(jj=0; jj<4; jj++)
+ {
+ iedge = quad_edge[begin_face+jj];
+ edges[jj] = edge_array[iedge];
+ }
+ qfacet_ptr = (CubitQuadFacet *)
+ new CubitQuadFacetData(edges[0], edges[1], edges[2], edges[3]);
+ facet_list.append(qfacet_ptr->get_tri_facet(0));
+ facet_list.append(qfacet_ptr->get_tri_facet(1));
+ }
+
+ // delete the temp arrays
+
+ delete [] point_array;
+ delete [] edge_array;
+ delete [] tri_edge;
+ delete [] quad_edge;
+ delete [] edge_vert;
+ delete [] vert;
+ delete [] edge_ctrl_pts;
+ delete [] tri_ctrl_pts;
+ delete [] quad_ctrl_pts;
+
+ return CUBIT_SUCCESS;
+}
+
+
+//===========================================================================
+//Function Name: is_close
+//
+//Member Type: PRIVATE
+//Description: determine if one of the facets in the list is within a
+// certain distance of the point.
+//===========================================================================
+CubitBoolean
+OCCQueryEngine::is_close(CubitVector &this_point,
+ DLIList<CubitFacet *>&facet_list,
+ CubitFacet *&lastFacet,
+ double tol)
+{
+ CubitBoolean isclose = CUBIT_FALSE;
+ CubitBox bbox;
+ CubitVector close_point;
+ CubitFacet *facet;
+ int ii;
+
+ // set the first facet to be checked as the last one located
+
+ if (lastFacet) {
+ if (!facet_list.move_to(lastFacet)) {
+ facet_list.reset();
+ }
+ }
+ else {
+ facet_list.reset();
+ }
+
+ CubitBoolean done = CUBIT_FALSE;
+
+ // define a bounding box around the point
+
+ CubitVector ptmin( this_point.x() - tol,
+ this_point.y() - tol,
+ this_point.z() - tol );
+ CubitVector ptmax( this_point.x() + tol,
+ this_point.y() + tol,
+ this_point.z() + tol );
+
+ for ( ii = facet_list.size(); ii > 0 && !done; ii-- ) {
+ facet = facet_list.get_and_step();
+
+ // Try to trivially reject this facet with a bounding box test
+
+ bbox = facet->bounding_box();
+ if (ptmax.x() < bbox.minimum().x() ||
+ ptmin.x() > bbox.maximum().x()) {
+ continue;
+ }
+ if (ptmax.y() < bbox.minimum().y() ||
+ ptmin.y() > bbox.maximum().y()) {
+ continue;
+ }
+ if (ptmax.z() < bbox.minimum().z() ||
+ ptmin.z() > bbox.maximum().z()) {
+ continue;
+ }
+
+ // Only facets that pass the bounding box test will get past here!
+
+ // Project point to plane of the facet and determine its area coordinates
+
+ CubitVector pt_on_plane;
+ double dist_to_plane;
+ FacetEvalTool::project_to_facet_plane( facet, this_point, pt_on_plane, dist_to_plane );
+
+ CubitVector areacoord;
+ FacetEvalTool::facet_area_coordinate( facet, pt_on_plane, areacoord );
+
+ // If sign of areacoords are all positive then its inside the triangle
+ // and we are done - go interpolate the point. (use an absolute
+ // tolerance since the coordinates arenormalized)
+
+ if (areacoord.x() > -GEOMETRY_RESABS &&
+ areacoord.y() > -GEOMETRY_RESABS &&
+ areacoord.z() > -GEOMETRY_RESABS) {
+ FacetEvalTool::eval_facet( facet, areacoord, &close_point, NULL );
+ }
+
+ // otherwise find the closest vertex or edge to the projected point
+
+ else if (areacoord.x() < GEOMETRY_RESABS) {
+ if (areacoord.y() < GEOMETRY_RESABS) {
+ FacetEvalTool::eval_point( facet, 2, close_point );
+ }
+ else if(areacoord.z() < GEOMETRY_RESABS) {
+ FacetEvalTool::eval_point( facet, 1, close_point );
+ }
+ else {
+ FacetEvalTool::eval_edge( facet, 1, 2, pt_on_plane, close_point );
+ }
+ }
+ else if (areacoord.y() < GEOMETRY_RESABS) {
+ if (areacoord.z() < GEOMETRY_RESABS) {
+ FacetEvalTool::eval_point( facet, 0, close_point );
+ }
+ else {
+ FacetEvalTool::eval_edge( facet, 2, 0, pt_on_plane, close_point);
+ }
+ }
+ else {
+ FacetEvalTool::eval_edge( facet, 0, 1, pt_on_plane, close_point );
+ }
+
+ // keep track of the minimum distance
+
+ double dist = sqrt(sqr(close_point.x() - this_point.x()) +
+ sqr(close_point.y() - this_point.y()) +
+ sqr(close_point.z() - this_point.z()));
+ if (dist <= tol) {
+ done = CUBIT_TRUE;
+ isclose = CUBIT_TRUE;
+ lastFacet = facet;
+ }
+ }
+ return isclose;
+}
+
+
+
+
+//=============================================================================
+// Function Name: export_facets
+// Member Type: PUBLIC
+// Description: export a list of facets to a facet file for debugging purposes
+// Author: sjowen
+// Date: 10/29/01
+//=============================================================================
+CubitStatus OCCQueryEngine::export_facets(DLIList<CubitFacet*> &facet_list,
+ char *filename)
+{
+
+ // open the file for writing
+
+ FILE *fp = fopen(filename, "w");
+ if (!fp)
+ {
+ PRINT_ERROR("Couldn't open file %s for writing.\n", filename);
+ return CUBIT_FAILURE;
+ }
+
+ // make list of all points
+
+ CubitPoint *point_ptr;
+ CubitFacet *facet_ptr;
+ DLIList<CubitPoint*>temp_point_list;
+ int ii, jj;
+ for (ii=0; ii<facet_list.size(); ii++)
+ {
+ facet_ptr = facet_list.get_and_step();
+ for(jj=0; jj<3; jj++)
+ {
+ point_ptr = facet_ptr->point(jj);
+ point_ptr->marked(-1);
+ temp_point_list.append(point_ptr);
+ }
+ }
+
+ // assign ids to points and make list unique
+
+ int id = 0;
+ DLIList<CubitPoint*>point_list;
+ for (ii=0; ii<temp_point_list.size(); ii++)
+ {
+ point_ptr = temp_point_list.get_and_step();
+ if (point_ptr->marked() == -1)
+ {
+ point_ptr->marked(id++);
+ point_list.append( point_ptr );
+ }
+ }
+
+ // write the points
+
+ CubitVector coords;
+ fprintf(fp, "%d\n", point_list.size());
+ point_list.reset();
+ for(ii=0; ii<point_list.size(); ii++)
+ {
+ point_ptr = point_list.get_and_step();
+ coords = point_ptr->coordinates();
+ fprintf(fp,"%d %f %f %f\n", ii, coords.x(), coords.y(), coords.z());
+ }
+
+ // write the facets
+
+ int indx[3];
+ fprintf(fp, "%d\n", facet_list.size());
+ for (ii=0; ii<facet_list.size(); ii++)
+ {
+ facet_ptr = facet_list.get_and_step();
+ for (jj=0; jj<3; jj++)
+ {
+ indx[jj] = facet_ptr->point(jj)->marked();
+ }
+ fprintf(fp,"%d %d %d %d\n", ii, indx[0], indx[1], indx[2]);
+ }
+
+ //- unmark the points
+
+ for (ii=0; ii<point_list.size(); ii++)
+ point_list.get_and_step()->marked(0);
+
+ fclose(fp);
+ return CUBIT_SUCCESS;
+}
+
+//=============================================================================
+//Function: init_hash_point (PRIVATE)
+//Description: create a hash array of all points. They are hashed based on the
+// id of the point
+//Author: sjowen
+//Date: 4/3/01
+//=============================================================================
+CubitStatus OCCQueryEngine::init_hash_points( int num_points )
+{
+ /* === find the next highest prime number */
+
+ hashPointSize = num_points / 10;
+ int i;
+ if (hashPointSize < 13) hashPointSize = 13;
+ else
+ {
+ i=2;
+ while (i<hashPointSize*0.5 + 1) {
+ if (hashPointSize % i == 0) {
+ i=2;
+ hashPointSize++;
+ }
+ else {
+ i++;
+ }
+ }
+ }
+ hashPointArray = new DLIList<CubitPoint*>[hashPointSize];
+
+ return CUBIT_SUCCESS;
+}
+
+//=============================================================================
+//Function: add_hash_point (PRIVATE)
+//Description: hash the point into the hash table
+//Author: sjowen
+//Date: 4/3/02
+//=============================================================================
+CubitStatus OCCQueryEngine::add_hash_point( CubitPoint *point_ptr )
+{
+ int id = point_ptr->id();
+ int key = get_hash_key( id );
+ hashPointArray[key].append( point_ptr );
+ return CUBIT_SUCCESS;
+}
+
+//=============================================================================
+//Function: get_hash_point (PRIVATE)
+//Description: retreive the CubitPoint pointer from the id
+//Author: sjowen
+//Date: 4/3/02
+//=============================================================================
+CubitPoint *OCCQueryEngine::get_hash_point( int id )
+{
+ int key = get_hash_key( id );
+ int ii;
+ int found = 0;
+ CubitPoint *point_ptr;
+ for (ii=0; ii<hashPointArray[key].size() && !found; ii++)
+ {
+ point_ptr = hashPointArray[key].get_and_step();
+ if (point_ptr->id() == id)
+ {
+ return point_ptr;
+ }
+ }
+ return (CubitPoint*)NULL;
+}
+
+//=============================================================================
+//Function: delete_hash_points (PRIVATE)
+//Description: delete the hash points stuff
+//Author: sjowen
+//Date: 4/3/02
+//=============================================================================
+void OCCQueryEngine::delete_hash_points( )
+{
+ if (hashPointArray)
+ delete [] hashPointArray;
+ hashPointArray = NULL;
+ hashPointSize = 0;
+}
+
+//=============================================================================
+//Function: get_hash_key (PRIVATE)
+//Description:
+//Author: sjowen
+//Date: 4/3/02
+//=============================================================================
+int OCCQueryEngine::get_hash_key( int id )
+{
+ int key = id % hashPointSize;
+ return key;
+}
+
+//===========================================================================
+//Function Name: get_all_hash_points
+//Member Type: PUBLIC
+//Description: makes a single list from all points in the hash table
+//===========================================================================
+CubitStatus OCCQueryEngine::get_all_hash_points(
+ DLIList<CubitPoint *> &point_list ) // return point list
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ int ii, jj;
+ CubitPoint *point_ptr;
+ for(jj=0; jj<hashPointSize; jj++)
+ {
+ for (ii=0; ii<hashPointArray[jj].size(); ii++)
+ {
+ point_ptr = hashPointArray[jj].get_and_step();
+ point_list.append(point_ptr);
+ }
+ }
+
+ return rv;
+}
+
+//===========================================================================
+//Function Name: save_facets
+//Member Type: PUBLIC
+//Description: save the facets from the entities to a Cubit file
+//Author: sjowen
+//Date: 1/16/2003
+//===========================================================================
+CubitStatus OCCQueryEngine::save_facets(
+ FILE *fp, // file we are dumping to
+ DLIList<OCCSurface*> facet_surfaces,
+ DLIList<OCCCurve*> facet_curves,
+ DLIList<OCCPoint*> facet_points ) // save facets from these entities
+{
+ CubitStatus rv = CUBIT_SUCCESS;
+
+ DLIList<CubitFacet *> facet_list;
+ DLIList<CubitFacetEdge *> edge_list;
+ DLIList<CubitPoint *> point_list;
+
+ // get a unique list of all facets, edges and points
+ rv = gather_facets(facet_surfaces, facet_curves, facet_points,
+ facet_list, edge_list, point_list );
+
+ if (rv != CUBIT_SUCCESS)
+ return rv;
+
+ // dump the facet entities the file
+
+ rv = dump_facets( fp, facet_list, edge_list, point_list );
+ if (rv != CUBIT_SUCCESS)
+ return rv;
+
+ // dump the CurveFacetEvalTools and FacetEval Tools
+ rv = save_eval_tools( fp, facet_surfaces, facet_curves );
+
+ return rv;
+}
+
+//===========================================================================
+//Function Name: save_eval_tools
+//Member Type: PUBLIC
+//Description: go through the RefEntities and save the CurveFacetEvalTools
+// and FacetEvalTools. These are essentially lists of facets
+// that are owned by the curve or surface
+//Authors: sjowen & cdernst
+//Date: 1/21/2003
+//===========================================================================
+CubitStatus OCCQueryEngine::save_eval_tools(
+ FILE *fp, // cubit file we are dumping to
+ DLIList<OCCSurface*> facet_surfaces,
+ DLIList<OCCCurve*> facet_curves )
+{
+
+ int ii;
+ OCCSurface *fsurf_ptr;
+ OCCCurve *fcurv_ptr;
+
+ //separate out eval tools and set ids
+ DLIList<CurveFacetEvalTool*> cfe_tools;
+ DLIList<FacetEvalTool*> fe_tools;
+ int ft_id = 0;
+ int cft_id = 0;
+
+ facet_surfaces.reset();
+ for (ii=facet_surfaces.size(); ii--; )
+ {
+ fsurf_ptr = facet_surfaces.get_and_step();
+ FacetEvalTool *feval_tool = fsurf_ptr->get_eval_tool();
+ if( feval_tool )
+ {
+ feval_tool->set_output_id( ft_id++ );
+ fe_tools.append( feval_tool );
+ }
+ }
+
+ facet_curves.reset();
+ for (ii=facet_curves.size(); ii--; )
+ {
+ fcurv_ptr = facet_curves.get_and_step();
+ CurveFacetEvalTool *ceval_tool = fcurv_ptr->get_eval_tool();
+ if( ceval_tool )
+ {
+ ceval_tool->set_output_id( cft_id++ );
+ cfe_tools.append( ceval_tool );
+ }
+ }
+
+ //Write out number of FacetEvalTools
+ int count = fe_tools.size();
+ NCubitFile::CIOWrapper cio(fp);
+ cio.Write( reinterpret_cast<UnsignedInt32*>(&count), 1 );
+
+ //Write out each FacetEvalTool
+ fe_tools.reset();
+ for( ii=0; ii<fe_tools.size(); ii++)
+ {
+ FacetEvalTool *feval_tool = fe_tools.get_and_step();
+ feval_tool->save( fp );
+ }
+
+ //Write out number of CurveFacetEvalTools
+ count = cfe_tools.size();
+ cio.Write( reinterpret_cast<UnsignedInt32*>(&count), 1 );
+
+ //Write out each CurveFacetEvalTool
+ cfe_tools.reset();
+ for( ii=0; ii<cfe_tools.size(); ii++)
+ {
+ CurveFacetEvalTool *ceval_tool = cfe_tools.get_and_step();
+ ceval_tool->save( fp );
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//===============================================================================
+// Function : restore_eval_tools
+// Member Type: PUBLIC
+// Description: restore the curve and surface eval tools
+// Author : sjowen
+// Date : 1/26/03
+//===============================================================================
+CubitStatus OCCQueryEngine::restore_eval_tools(
+ FILE *fp, // CUB file we are currently reading
+ unsigned int endian,
+ int num_facets, // list of facet entities already read from the CUB file
+ int num_edges, // that we will assign to the eval tools. Index into
+ int num_points, // the array is the same as ID
+ CubitFacet **facets,
+ CubitFacetEdge **edges,
+ CubitPoint **points,
+ int &num_cfet,
+ int &num_fet,
+ CurveFacetEvalTool **&cfeval_tools,
+ FacetEvalTool **&feval_tools) // return list of curve and surface tools
+{
+ NCubitFile::CIOWrapper cio(endian, fp);
+
+ int ii;
+ FacetEvalTool *fsurf_ptr;
+ CurveFacetEvalTool *fcurv_ptr;
+
+ // read the number of facet eval tools
+ // we are about to read from the CUB file
+ cio.Read(reinterpret_cast<UnsignedInt32*>(&num_fet), 1);
+
+ feval_tools = new FacetEvalTool *[num_fet];
+
+ // read all the facet surface eval tools
+
+ for (ii=0; ii<num_fet; ii++)
+ {
+ /*
+ // read the topo ID from the CUB file. This will be stored as the
+ // FacetEvalTool toolID and serve as the means to associate this
+ // eval tool with it's topology entity
+ UnsignedInt32 surf_id = 0;
+ cio.Read(&surf_id, 1);
+ int topo_id = (int)surf_id; */
+
+ // read the facet eval tool data and create the tool
+ fsurf_ptr = new FacetEvalTool();
+ fsurf_ptr->restore(fp, endian, num_facets,
+ num_edges, num_points,
+ facets, edges, points);
+ if (fsurf_ptr == NULL)
+ {
+ PRINT_ERROR("Error restoring mesh-based geometry\n");
+ return CUBIT_FAILURE;
+ }
+ feval_tools[ii] = fsurf_ptr;
+ }
+
+ // read the number of curves
+ cio.Read(reinterpret_cast<UnsignedInt32*>(&num_cfet), 1);
+ cfeval_tools = new CurveFacetEvalTool *[num_cfet];
+
+ // read all the curve facet eval tools. Same thing as surfaces
+
+ for (ii=0; ii<num_cfet; ii++)
+ {
+ // read the facet eval tool data and create the tool
+ fcurv_ptr = new CurveFacetEvalTool();
+ fcurv_ptr->restore(fp, endian, num_edges, num_points,
+ edges, points, num_fet, feval_tools );
+ if (fcurv_ptr == NULL)
+ {
+ PRINT_ERROR("Error restoring mesh-based geometry\n");
+ return CUBIT_FAILURE;
+ }
+
+ cfeval_tools[ii] = fcurv_ptr;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+
+//===========================================================================
+//Function Name: dump_facets
+//Member Type: PUBLIC
+//Description: dump the facets and associated data to the cubit file
+//Authors: sjowen & cdernst
+//Date: 1/16/2003
+//===========================================================================
+CubitStatus OCCQueryEngine::dump_facets(
+ FILE *fp, // file we are dumping to
+ DLIList<CubitFacet *> &facet_list, // return unique list of facets
+ DLIList<CubitFacetEdge *> &edge_list, // return unique list of edges
+ DLIList<CubitPoint *> &point_list ) // return unique list of points
+{
+
+ NCubitFile::CIOWrapper cio(fp);
+ typedef NCubitFile::UnsignedInt32 UnsignedInt32;
+
+ // Gather CubitPoint Data
+ int npoints = point_list.size();
+ int nnormals = 0;
+ double* uvs_array = new double [npoints * 3];
+ double* coord_array = new double [npoints * 3];
+ //double* du_array = new double [npoints * 3];
+ //double* dv_array = new double [npoints * 3];
+ int c_zero_points = 0;
+ int c_zero_int_data_size = 0;
+ int c_zero_double_data_size = 0;
+ int ii;
+ DLIList<CubitPoint*> has_td_boundary_point;
+ DLIList<CubitPoint*> points_with_normal;
+
+ TDFacetBoundaryPoint *td_fbp;
+ CubitPoint *cp_ptr;
+ CubitVector coord, *normal;
+ point_list.reset();
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ cp_ptr = point_list.get_and_step();
+
+ // write out uVal, vVal, sizeVal
+ uvs_array[ii*3] = cp_ptr->u();
+ uvs_array[ii*3+1] = cp_ptr->v();
+ uvs_array[ii*3+2] = cp_ptr->size();
+ // coordinates
+ coord = cp_ptr->coordinates();
+ coord_array[ii*3] = coord.x();
+ coord_array[ii*3+1] = coord.y();
+ coord_array[ii*3+2] = coord.z();
+ // surfNormal
+ if( cp_ptr->normal_ptr() )
+ points_with_normal.append( cp_ptr );
+
+ /*
+ // surfU
+ du = cp_ptr->du();
+ du_array[ii*3] = du.x();
+ du_array[ii*3+1] = du.y();
+ du_array[ii*3+2] = du.z();
+ // surfV
+ dv = cp_ptr->dv();
+ dv_array[ii*3] = dv.x();
+ dv_array[ii*3+1] = dv.y();
+ dv_array[ii*3+2] = dv.z(); */
+
+ if ((td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( cp_ptr ))!= NULL)
+ {
+ has_td_boundary_point.append( cp_ptr );
+ c_zero_points++;
+ td_fbp->get_boundary_point_data_size( c_zero_int_data_size,
+ c_zero_double_data_size );
+ }
+ }
+
+ // Normals
+ nnormals = points_with_normal.size();
+ double* normal_array = NULL;
+ int* normal_ids = NULL;
+ points_with_normal.reset();
+ if( nnormals > 0 )
+ {
+ normal_array = new double [nnormals* 3];
+ normal_ids = new int[nnormals];
+ points_with_normal.reset();
+ for( ii=0; ii<nnormals; ii++)
+ {
+ cp_ptr = points_with_normal.get_and_step();
+ normal_ids[ii] = cp_ptr->id();
+ normal = cp_ptr->normal_ptr();
+ normal_array[ii*3] = normal->x();
+ normal_array[ii*3+1] = normal->y();
+ normal_array[ii*3+2] = normal->z();
+ }
+ }
+
+ // write arrays --CubitPoint
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&npoints), 1);
+ if( npoints > 0 )
+ {
+ cio.Write(coord_array, npoints*3);
+ cio.Write(uvs_array, npoints*3);
+ }
+
+ // clean up
+ delete [] uvs_array;
+ delete [] coord_array;
+ uvs_array = NULL;
+ coord_array = NULL;
+
+ // write normals & ids of points to which normals belong
+ cio.Write( reinterpret_cast<UnsignedInt32*>(&nnormals), 1 );
+ if( nnormals > 0 )
+ {
+ cio.Write(normal_array, nnormals*3);
+ cio.Write(reinterpret_cast<UnsignedInt32*>(normal_ids), nnormals);
+ delete [] normal_array;
+ delete [] normal_ids;
+ normal_array = NULL;
+ normal_ids = NULL;
+ }
+
+ // Gather CubitFacetEdge Data
+ int jj, idx;
+ int nedges = edge_list.size();
+ int nctrl_pts = nedges * NUM_EDGE_CPTS;
+ CubitFacetEdge *edge_ptr;
+ CubitVector *edge_ctrl_pts;
+ double* control_points = new double [nctrl_pts * 3];
+ UnsignedInt32* edge_vert_array = new UnsignedInt32 [nedges * 2];
+ for(ii=0; ii<nedges; ii++)
+ {
+ // pointArray[2]
+ edge_ptr = edge_list.get_and_step();
+ edge_vert_array[ii*2] = edge_ptr->point(0)->id();
+ edge_vert_array[ii*2+1] = edge_ptr->point(1)->id();
+ edge_ctrl_pts = edge_ptr->control_points();
+
+ // controlPoints[3]
+ if (nctrl_pts > 0)
+ {
+ if (!edge_ctrl_pts)
+ {
+ nctrl_pts = 0;
+ continue;
+ }
+ for(jj=0; jj<NUM_EDGE_CPTS; jj++)
+ {
+ idx = (ii*NUM_EDGE_CPTS+jj)*3;
+ control_points[idx] = edge_ctrl_pts[jj].x();
+ control_points[idx+1] = edge_ctrl_pts[jj].y();
+ control_points[idx+2] = edge_ctrl_pts[jj].z();
+ }
+ }
+ }
+
+ // write arrays --CubitFacetEdge
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&nedges), 1);
+ if( nedges > 0 )
+ {
+ cio.Write(edge_vert_array, nedges*2 );
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&nctrl_pts), 1);
+ if (nctrl_pts > 0)
+ cio.Write(control_points, nctrl_pts*3);
+ }
+
+ // clean up
+ delete [] edge_vert_array;
+ delete [] control_points;
+ edge_vert_array = NULL;
+ control_points = NULL;
+
+ // Gather CubitFacet Data
+ int nfacets = facet_list.size();
+ nctrl_pts = nfacets * NUM_TRI_CPTS;
+ CubitFacet *facet_ptr;
+ CubitVector *facet_ctrl_pts;
+ control_points = new double [nctrl_pts * 3];
+ UnsignedInt32* facet_edge_array = new UnsignedInt32 [nfacets * 3];
+ int *int_data = new int[ nfacets * 2 ];
+ facet_list.reset();
+ for (ii=0; ii<nfacets; ii++)
+ {
+ facet_ptr = facet_list.get_and_step();
+
+ // is Flat and isBackwards
+ int_data[ii*2] = facet_ptr->is_flat();
+ int_data[ii*2+1] = facet_ptr->is_backwards();
+
+ // edgeArray[3]
+ facet_edge_array[ii*3] = facet_ptr->edge(0)->id();
+ facet_edge_array[ii*3+1] = facet_ptr->edge(1)->id();
+ facet_edge_array[ii*3+2] = facet_ptr->edge(2)->id();
+ facet_ctrl_pts = facet_ptr->control_points();
+ if(nctrl_pts > 0)
+ {
+ if (!facet_ctrl_pts)
+ {
+ nctrl_pts = 0;
+ continue;
+ }
+ for(jj=0; jj<NUM_TRI_CPTS; jj++)
+ {
+ idx = (ii*NUM_TRI_CPTS+jj)*3;
+ control_points[idx] = facet_ctrl_pts[jj].x();
+ control_points[idx+1] = facet_ctrl_pts[jj].y();
+ control_points[idx+2] = facet_ctrl_pts[jj].z();
+ }
+ }
+ }
+
+ // write arrays --CubitFacet
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&nfacets), 1);
+ if( nfacets > 0 )
+ {
+ cio.Write(facet_edge_array, nfacets*3);
+ cio.Write( reinterpret_cast<UnsignedInt32*>(int_data), nfacets*2 );
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&nctrl_pts), 1);
+ if (nctrl_pts > 0)
+ cio.Write(control_points, nctrl_pts*3);
+ }
+
+ // clean up
+ delete [] facet_edge_array;
+ delete [] control_points;
+ delete [] int_data;
+ facet_edge_array = NULL;
+ control_points = NULL;
+ int_data = NULL;
+
+
+ // At points along the boundary (C0 continuity) there may be
+ // multiple normals. Write this data too. First gether it
+ // into two arrays and then dump.
+
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&c_zero_points), 1);
+ if (c_zero_points > 0)
+ {
+ int *c_zero_int_data = new int [c_zero_int_data_size];
+ double *c_zero_double_data = new double [c_zero_double_data_size];
+ point_list.reset();
+ int iidx = 0;
+ int didx = 0;
+ point_list.reset();
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ cp_ptr = point_list.get_and_step();
+ td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( cp_ptr );
+ if (td_fbp != NULL)
+ {
+ td_fbp->get_boundary_point_data( c_zero_int_data,
+ c_zero_double_data,
+ iidx, didx );
+ }
+ }
+
+ // dump the int data array
+
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&c_zero_int_data_size), 1);
+ //convert to UnsignedInt32
+ UnsignedInt32 *c_zero_int32_data = new UnsignedInt32 [c_zero_int_data_size];
+ for (ii=0; ii<c_zero_int_data_size; ii++)
+ c_zero_int32_data[ii] = (UnsignedInt32)c_zero_int_data[ii];
+ cio.Write(c_zero_int32_data, c_zero_int_data_size);
+
+ // dump the double array
+
+ cio.Write(reinterpret_cast<UnsignedInt32*>(&c_zero_double_data_size), 1);
+ cio.Write(c_zero_double_data, c_zero_double_data_size);
+
+ // clean up
+ delete [] c_zero_int_data;
+ delete [] c_zero_int32_data;
+ delete [] c_zero_double_data;
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//===========================================================================
+//Function Name: gather_facets
+//Member Type: PUBLIC
+//Description: get a unique list of facets from the entities
+//Author: sjowen
+//Date: 1/16/2003
+//===========================================================================
+CubitStatus OCCQueryEngine::gather_facets(
+ DLIList<OCCSurface *> facet_surfaces,
+ DLIList<OCCCurve *> facet_curves,
+ DLIList<OCCPoint *> facet_points,
+ DLIList<CubitFacet *> &facet_list, // return unique list of facets
+ DLIList<CubitFacetEdge *> &edge_list, // return unique list of edges
+ DLIList<CubitPoint *> &point_list) // return unique list of points
+{
+ int ii, jj, kk;
+ OCCSurface *fsurf_ptr;
+ OCCCurve *fcurv_ptr;
+ OCCPoint *fpoint_ptr;
+ DLIList<CubitFacet *>temp_facets;
+ DLIList<CubitPoint *>temp_points;
+ DLIList<CubitFacetEdge *>temp_edges;
+
+ CubitFacet *facet_ptr;
+ CubitFacetEdge *edge_ptr;
+ CubitPoint *cp_ptr;
+
+ //unmark facets/edges/points on surface
+ for(ii=facet_surfaces.size(); ii--;)
+ {
+ fsurf_ptr = facet_surfaces.get_and_step();
+ temp_facets.clean_out();
+ temp_points.clean_out();
+ fsurf_ptr->get_my_facets(temp_facets, temp_points);
+ for(jj=0; jj<temp_facets.size(); jj++)
+ {
+ facet_ptr = temp_facets.get_and_step();
+ facet_ptr->marked( 0 );
+ for (kk=0; kk<3; kk++)
+ {
+ edge_ptr = facet_ptr->edge( kk );
+ edge_ptr->marked( 0 );
+ }
+ }
+ for (jj=0; jj<temp_points.size(); jj++)
+ {
+ cp_ptr = temp_points.get_and_step();
+ cp_ptr->marked( 0 );
+ }
+ }
+
+ //unmark facet-edges/points on curves
+ for(ii=facet_curves.size(); ii--; )
+ {
+ fcurv_ptr = facet_curves.get_and_step();
+ temp_edges.clean_out();
+ fcurv_ptr->get_facets( temp_edges );
+ for (jj=0; jj<temp_edges.size(); jj++)
+ {
+ edge_ptr = temp_edges.get_and_step();
+ edge_ptr->marked( 0 );
+ edge_ptr->point( 0 )->marked( 0 );
+ edge_ptr->point( 1 )->marked( 0 );
+ }
+ }
+
+ //unmark facet-points on points
+ for(ii=facet_points.size(); ii--; )
+ {
+ fpoint_ptr = facet_points.get_and_step();
+ if (fpoint_ptr != NULL)
+ {
+ cp_ptr = fpoint_ptr->get_cubit_point();
+ cp_ptr->marked( 0 );
+ }
+ }
+
+
+ // make unique lists
+ for(ii=facet_surfaces.size(); ii--;)
+ {
+ fsurf_ptr = facet_surfaces.get_and_step();
+ temp_facets.clean_out();
+ temp_points.clean_out();
+ fsurf_ptr->get_my_facets(temp_facets, temp_points);
+ for(jj=0; jj<temp_facets.size(); jj++)
+ {
+ facet_ptr = temp_facets.get_and_step();
+ if (0 == facet_ptr->marked())
+ {
+ facet_ptr->marked( 1 );
+ facet_list.append( facet_ptr );
+ }
+ for (kk=0; kk<3; kk++)
+ {
+ edge_ptr = facet_ptr->edge( kk );
+ if (0 == edge_ptr->marked())
+ {
+ edge_ptr->marked( 1 );
+ edge_list.append( edge_ptr );
+ }
+ }
+ }
+ for (jj=0; jj<temp_points.size(); jj++)
+ {
+ cp_ptr = temp_points.get_and_step();
+ if (0 == cp_ptr->marked())
+ {
+ cp_ptr->marked(1);
+ point_list.append( cp_ptr );
+ }
+ }
+ }
+
+ for(ii=facet_curves.size(); ii--;)
+ {
+ fcurv_ptr = facet_curves.get_and_step();
+ temp_edges.clean_out();
+ fcurv_ptr->get_facets( temp_edges );
+ for (jj=0; jj<temp_edges.size(); jj++)
+ {
+ edge_ptr = temp_edges.get_and_step();
+ if (0 == edge_ptr->marked())
+ {
+ edge_ptr->marked(1);
+ edge_list.append( edge_ptr );
+ for (kk=0; kk<2; kk++)
+ {
+ cp_ptr = edge_ptr->point( kk );
+ if (0 == cp_ptr->marked())
+ {
+ cp_ptr->marked(1);
+ point_list.append(cp_ptr);
+ }
+ }
+ }
+ }
+ }
+
+ for(ii=facet_points.size(); ii--;)
+ {
+ fpoint_ptr = facet_points.get_and_step();
+ cp_ptr = fpoint_ptr->get_cubit_point();
+ if (0 == cp_ptr->marked())
+ {
+ cp_ptr->marked( 1 );
+ point_list.append( cp_ptr );
+ }
+ }
+
+ // set the IDs of the facet entities and clear the marks
+ facet_list.reset();
+ for (ii=0; ii<facet_list.size(); ii++)
+ {
+ facet_ptr = facet_list.get_and_step();
+ facet_ptr->set_id(ii);
+ facet_ptr->marked(0);
+ }
+ edge_list.reset();
+ for (ii=0; ii<edge_list.size(); ii++)
+ {
+ edge_ptr = edge_list.get_and_step();
+ edge_ptr->set_id(ii);
+ edge_ptr->marked(0);
+ }
+ for (ii=0; ii<point_list.size(); ii++)
+ {
+ cp_ptr = point_list.get_and_step();
+ cp_ptr->set_id(ii);
+ cp_ptr->marked(0);
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//=============================================================================
+//Function: create_super_facet_bounding_box(PUBLIC)
+//Description: Find the bounding box of a list of BodySMs
+//Author: jdfowle
+//Date: 12/15/03
+//=============================================================================
+CubitStatus OCCQueryEngine::create_super_facet_bounding_box(
+ DLIList<BodySM*>& body_list,
+ CubitBox& super_box )
+{
+BodySM *bodySM;
+int i;
+CubitStatus status = CUBIT_SUCCESS;
+
+ body_list.reset();
+ for ( i = 0; i < body_list.size(); i++ ) {
+ bodySM = body_list.get_and_step();
+ create_facet_bounding_box(bodySM,super_box);
+ }
+
+ return status;
+}
+
+//=============================================================================
+//Function: create_facet_bounding_box(PUBLIC)
+//Description: Find the bounding box of a BodySM
+//Author: jdfowle
+//Date: 12/15/03
+//=============================================================================
+CubitStatus OCCQueryEngine::create_facet_bounding_box(
+ BodySM* bodySM,
+ CubitBox& bbox )
+{
+ OCCBody *fbody_ptr;
+ int j;
+ DLIList<OCCSurface*> facet_surf_list;
+ DLIList<CubitFacet*> facet_list;
+ DLIList<CubitPoint*> point_list;
+ OCCSurface *facet_surface;
+ CubitBox surf_bbox, total_box;
+ CubitStatus status = CUBIT_FAILURE;
+
+ fbody_ptr = dynamic_cast<OCCBody *>(bodySM);
+ fbody_ptr->get_surfaces(facet_surf_list);
+ for ( j = 0; j < facet_surf_list.size(); j++ ) {
+ facet_surface = facet_surf_list.get_and_step();
+ facet_list.clean_out();
+ point_list.clean_out();
+ facet_surface->get_my_facets(facet_list,point_list);
+ status = FacetDataUtil::get_bbox_of_points(point_list,surf_bbox);
+ if ( j == 0 ) total_box = surf_bbox;
+ else
+ total_box |= surf_bbox;
+ }
+ bbox |= total_box;
+ return status;
+}
+
+const char* fqe_xform_err = "Transform not implemented for facet geometry.\n";
+CubitStatus OCCQueryEngine::restore_transform( BodySM* body )
+{
+ OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
+ return facetbod ? facetbod->restore( ) : CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::translate( BodySM* body, const CubitVector& d )
+{
+ OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
+ return facetbod ? facetbod->move( d.x(), d.y(), d.z() ) : CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::rotate( BodySM* body, const CubitVector& v, double a )
+{
+ OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
+ return facetbod ? facetbod->rotate( v.x(), v.y(), v.z(), a ) : CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::scale( BodySM* body, double factor )
+{
+ OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
+ return facetbod ? facetbod->scale( factor ) : CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::scale( BodySM* body, const CubitVector& f )
+{
+ OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
+ return facetbod ? facetbod->scale( f.x(), f.y(), f.z() ) : CUBIT_FAILURE;
+}
+
+CubitStatus OCCQueryEngine::translate( GeometryEntity* , const CubitVector& )
+{
+ PRINT_ERROR(fqe_xform_err);
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::rotate( GeometryEntity* , const CubitVector& , double )
+{
+ PRINT_ERROR(fqe_xform_err);
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::scale( GeometryEntity* , double )
+{
+ PRINT_ERROR(fqe_xform_err);
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::scale( GeometryEntity* , const CubitVector& )
+{
+ PRINT_ERROR(fqe_xform_err);
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCQueryEngine::reflect( GeometryEntity* , const CubitVector& )
+{
+ PRINT_ERROR(fqe_xform_err);
+ return CUBIT_FAILURE;
+}
+
+//===============================================================================
+// Function : bodies_overlap
+// Member Type: PUBLIC
+// Description: determine if facet-based bodies overlap
+// Author : John Fowler
+// Date : 10/02
+//===============================================================================
+CubitBoolean OCCQueryEngine::bodies_overlap (BodySM * body_ptr_1,
+ BodySM * body_ptr_2 ) const
+{
+FacetboolInterface *fbint;
+CubitFacetboolOp op = CUBIT_FB_INTERSECTION;
+bool keep_old = true;
+CubitStatus status;
+BodySM* body_out = 0;
+bool intersection_found;
+
+ fbint = new FacetboolInterface;
+ status = fbint->dofacetboolean_2bodies(body_ptr_1,body_ptr_2,body_out,
+ keep_old,intersection_found,op);
+ if ( status == CUBIT_FAILURE ) return CUBIT_FALSE;
+ else return CUBIT_TRUE;
+}
+
+//EOF
Added: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,584 @@
+//-------------------------------------------------------------------------
+// Filename : OCCQueryEngine.hpp
+//
+// Purpose : Facet geometry engine.
+//
+// This class is implemented as a Singleton pattern. Only
+// one instance is created and it is accessed through the
+// {instance()} static member function.
+//
+// Special Notes :
+//
+// Creator : David R. White
+//
+// Creation Date : 6/29/00
+//
+//-------------------------------------------------------------------------
+
+#ifndef FACET_GEOMETRY_ENGINE_HPP
+#define FACET_GEOMETRY_ENGINE_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+
+#include <typeinfo>
+#if !defined(NT) && !defined(CANT_USE_STD)
+using std::type_info;
+#endif
+
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+
+#include "CubitFileIOWrapper.hpp"
+#include "GeometryQueryEngine.hpp"
+
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <map>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN FORWARD DECLARATIONS
+class TopologyEntity;
+class TopologyBridge;
+class RefEntity;
+class Body;
+class Shell;
+class ShellSM;
+class Loop;
+class Chain;
+class CoEdgeSM;
+class LoopSM;
+class RefVolume;
+class RefFace;
+class RefEdge;
+class RefVertex;
+class Point;
+class Curve;
+class Surface;
+class Lump;
+class BodySM;
+
+class GeometryEntity;
+class BodySM;
+class Lump;
+class ShellSM;
+class Surface;
+class LoopSM;
+class Curve;
+class CoEdgeSM;
+class Point;
+class TopologyEntity;
+class CubitBox;
+class CubitString;
+
+class OtherSolidModelingEntity;
+class OCCLump;
+class OCCShell;
+class OCCLoop;
+class OCCSurface;
+class OCCBody;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+
+class RefEntity;
+class RefVertex;
+class RefEdge;
+class RefFace;
+class Loop;
+class CubitFacet;
+class CubitQuadFacet;
+class CubitFacetEdge;
+class CubitPoint;
+class FacetEntity;
+class CurveFacetEvalTool;
+class FacetEvalTool;
+
+// ********** END FORWARD DECLARATIONS **********
+
+// ********** BEGIN MACRO DEFINITIONS **********
+// ********** END MACRO DEFINITIONS **********
+
+// ********** BEGIN ENUM DEFINITIONS **********
+typedef enum {
+ CUBIT_FACET_FILE,
+ AVS_FILE,
+ CHOLLA_FILE,
+ FROM_FACET_LIST,
+ STL_FILE
+} FacetFileFormat;
+
+// ********** END ENUM DEFINITIONS **********
+
+class OCCQueryEngine : public GeometryQueryEngine
+{
+public:
+// ********** BEGIN FRIEND DECLARATIONS **********
+ friend class OCCSurface;
+
+// ********** END FRIEND DECLARATIONS **********
+
+//HEADER- Constructor and Destructor
+
+ static OCCQueryEngine* instance();
+ //- Singleton pattern
+ //- Controlled access and creation of the sole instance of this class.
+
+ virtual ~OCCQueryEngine();
+
+ const char* modeler_type()
+ { return "OCC"; }
+
+ int get_major_version();
+
+ int get_minor_version();
+
+ int get_subminor_version();
+
+ CubitString get_engine_version_string();
+
+//HEADER- RTTI and safe casting functions.
+
+ virtual const type_info& entity_type_info() const ;
+ //R- The geometric modeler type
+ //- This function returns the type of the geometric modeler.
+
+ virtual CubitBoolean is_solid_modeler_type() const
+ {return CUBIT_FALSE;}
+ //R CubitBoolean
+ //R- This is not a solid modeling engine.
+//HEADER- Functions for importing and exporting solid models.
+
+ CubitBoolean can_delete_bodies(DLIList<Body*>body_list);
+
+ virtual Point* make_Point( GeometryType point_type,
+ CubitVector const& point) const ;
+ virtual Curve* make_Curve(Curve *) const;
+ virtual Curve* make_Curve( Point const* ,
+ Point const* ,
+ RefFace* ,
+ CubitVector * ) const;
+ virtual Curve* make_Curve( GeometryType ,
+ Point const* ,
+ Point const* ,
+ DLIList<CubitVector*>& ,
+ RefFace* ) const;
+ virtual Curve* make_Curve( GeometryType ,
+ Point const* ,
+ Point const* ,
+ CubitVector const* ,
+ CubitSense ) const;
+ virtual Surface* make_Surface( Surface *,
+ DLIList<Loop*> &,
+ CubitBoolean ) const;
+
+
+ virtual Surface* make_Surface( GeometryType ,
+ DLIList<Curve*>& ,
+ DLIList<Loop*> &,
+ Surface *) const ;
+ virtual Lump* make_Lump( GeometryType ,
+ DLIList<Surface*>& ) const ;
+ virtual BodySM* make_BodySM( Surface * ) const;
+ virtual BodySM* make_BodySM( DLIList<Lump*>& ) const ;
+
+ Body* copy_body( Body *body_ptr );
+
+ virtual CubitStatus get_graphics( Surface* surface_ptr,
+ int& number_triangles,
+ int& number_points,
+ int& number_facets,
+ GMem* gMem,
+ unsigned short normal_tolerance,
+ double distance_tolerance) const;
+ virtual CubitStatus get_graphics( Curve* curve_ptr,
+ int& num_points,
+ GMem* gMem = NULL,
+ double tolerance = 0.0 ) const;
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/CUBIT_FAILURE
+ //I ref_edge_ptr
+ //I- The RefEdge for which hoops facetting information will be
+ //I- gathered.
+ //O numSteps
+ //O- The number of points in resulting polyline.
+ //O gMem
+ //O- The storage place for edges, involved in facetting.
+ //I tolerance
+ //I- The tolerance deviation used when facetting the curve (optional
+ //I- and currently IGNORED by this engine).
+ //- This function gathers and outputs ACIS edge information for
+ //- hoops involved in facetting a RefEdge. If all goes well,
+ //- CUBIT_SUCCESS is returned. Otherwise, CUBIT_FAILURE is
+ //- returned.
+
+ virtual CubitStatus get_isoparametric_points(Surface* ,
+ int&, int&,
+ GMem*&) const;
+
+ virtual CubitStatus get_u_isoparametric_points(Surface* ref_face_ptr,
+ double v, int& n,
+ GMem *&gMem) const;
+
+ virtual CubitStatus get_v_isoparametric_points(Surface* ref_face_ptr,
+ double u, int&n,
+ GMem *&gMem) const;
+
+ virtual CubitStatus transform_vec_position(
+ CubitVector const& ,
+ BodySM *,
+ CubitVector & ) const;
+
+ virtual CubitStatus get_intersections( Curve*, CubitVector& point1,
+ CubitVector&,
+ DLIList<CubitVector*>& ,
+ CubitBoolean,
+ CubitBoolean );
+
+ virtual CubitStatus get_intersections( Curve* , Curve* ,
+ DLIList<CubitVector*>& ,
+ CubitBoolean,
+ CubitBoolean );
+ virtual CubitStatus get_intersections( Curve* ref_edge1, Curve* ref_edge2,
+ DLIList<CubitVector*>& intersection_list,
+ double offset,
+ CubitBoolean ext_first = CUBIT_TRUE );
+ virtual CubitStatus get_intersections( Curve* ref_edge, Surface* ref_face,
+ DLIList<CubitVector*>& intersection_list,
+ CubitBoolean bounded = CUBIT_FALSE );
+
+ virtual CubitStatus entity_extrema( DLIList<GeometryEntity*> &ref_entity_list,
+ const CubitVector *dir1,
+ const CubitVector *dir2,
+ const CubitVector *dir3,
+ CubitVector &extrema,
+ GeometryEntity *&extrema_entity_ptr );
+ //- Gets the extrema position along the first given direction. If there
+ //- is more than one extrema position, the other directions will be used
+ //- to determine a unique position. Directions 2 and 3 can be NULL.
+ //- Entities supported include bodies, volumes, surfaces, curves and
+ //- vertices. The entity the extrema is found on is also returned.
+
+ virtual CubitStatus entity_entity_distance( GeometryEntity *ref_entity_ptr1,
+ GeometryEntity *ref_entity_ptr2,
+ CubitVector &pos1, CubitVector &pos2,
+ double &distance );
+ //- Gets the minimum distance between two entities and the closest positions
+ //- on those entities. Supports vertices, curves, surfaces, volumes and bodies.
+
+ virtual CubitStatus export_solid_model( DLIList<TopologyBridge*>& bridge_list,
+ const char* file_name,
+ const char* file_type,
+ const CubitString &cubit_version,
+ const char* logfile_name = NULL );
+
+ virtual CubitStatus save_temp_geom_file( DLIList<TopologyBridge*>& ref_entity_list,
+ const char *file_name,
+ const CubitString &cubit_version,
+ CubitString &created_file,
+ CubitString &created_file_type );
+
+ virtual CubitStatus import_temp_geom_file(FILE* file_ptr,
+ const char* file_name,
+ const char* file_type,
+ DLIList<TopologyBridge*> &bridge_list );
+
+ virtual CubitStatus import_solid_model(const char* file_name,
+ const char* file_type,
+ DLIList<TopologyBridge*>& imported_entities,
+ CubitBoolean print_results = CUBIT_TRUE,
+ const char* logfile_name = NULL,
+ CubitBoolean heal_step = CUBIT_TRUE,
+ CubitBoolean import_bodies = CUBIT_TRUE,
+ CubitBoolean import_surfaces = CUBIT_TRUE,
+ CubitBoolean import_curves = CUBIT_TRUE,
+ CubitBoolean import_vertices = CUBIT_TRUE,
+ CubitBoolean free_surfaces = CUBIT_TRUE );
+private:
+ CubitStatus import_solid_model(FILE *file_ptr,
+ const char* /*file_type*/,
+ DLIList<TopologyBridge*> &imported_entities,
+ CubitBoolean print_results = CUBIT_TRUE,
+ const char* logfile_name = NULL,
+ CubitBoolean heal_step = CUBIT_TRUE,
+ CubitBoolean import_bodies = CUBIT_TRUE,
+ CubitBoolean import_surfaces = CUBIT_TRUE,
+ CubitBoolean import_curves = CUBIT_TRUE,
+ CubitBoolean import_vertices = CUBIT_TRUE,
+ CubitBoolean free_surfaces = CUBIT_TRUE);
+public:
+ virtual void delete_solid_model_entities(DLIList<BodySM*>& body_list) const;
+ //- Deletes all solid model entities associated with the Bodies in
+ //- the input list.
+
+ virtual CubitStatus delete_solid_model_entities( BodySM* body_ptr ) const;
+ virtual CubitStatus delete_solid_model_entities(Surface* surf_ptr ) const;
+ virtual CubitStatus delete_solid_model_entities( Curve* curve_ptr ) const;
+ virtual CubitStatus delete_solid_model_entities( Point* point_ptr ) const;
+
+ virtual CubitStatus fire_ray(BodySM *body,
+ const CubitVector &ray_point,
+ const CubitVector &unit,
+ DLIList<double>& ray_params,
+ DLIList<GeometryEntity*> *entity_list = NULL) const;
+ //- fire a ray at the specified body, returning the entities hit and
+ //- the parameters along the ray; return CUBIT_FAILURE if error
+
+ virtual double get_sme_resabs_tolerance() const; // Gets solid modeler's resolution absolute tolerance
+ virtual double set_sme_resabs_tolerance( double new_resabs );
+
+ virtual CubitStatus set_int_option( const char* opt_name, int val );
+ virtual CubitStatus set_dbl_option( const char* opt_name, double val );
+ virtual CubitStatus set_str_option( const char* opt_name, const char* val );
+ //- Set solid modeler options
+
+ static CubitStatus make_facets( int *conn, int nfacets,
+ DLIList<CubitQuadFacet *> &facet_list );
+ static CubitStatus make_facets( int *conn, int nfacets,
+ DLIList<CubitFacet *> &facet_list );
+ //- create facets from a list of points and connectivity
+
+#ifdef BOYD14
+ static CubitStatus check_facets( DLIList<CubitPoint*>&point_list, DLIList<CubitFacet*> &facet_list );
+ //- check integrity of facets
+#endif
+
+ CubitStatus ensure_is_ascii_stl_file(FILE * fp, CubitBoolean &is_ascii);
+ //- returns true in is_ascii if fp points to an ascii stl file
+
+ CubitStatus read_facets_stl_tolerance(
+ DLIList<CubitFacet *> &tfacet_list,
+ DLIList<CubitPoint *> &point_list,
+ const char * file_name,
+ int &npoints,
+ int &ntri,
+ long& seek_address,
+ double tolerance);
+ //- read facets from an stl file and combine vertices within tolerance distance
+
+ CubitStatus read_facets_stl(
+ DLIList<CubitFacet *> &tfacet_list,
+ DLIList<CubitPoint *> &point_list,
+ const char * file_name,
+ int &npoints,
+ int &ntri,
+ long& seek_address);
+ //- read facets from an stl file
+
+ CubitStatus import_facets( const char *file_name,
+ CubitBoolean use_feature_angle,
+ double feature_angle,
+ double tolerance,
+ int interp_order,
+ CubitBoolean smooth_non_manifold,
+ CubitBoolean split_surfaces,
+ CubitBoolean stitch,
+ CubitBoolean improve,
+ DLIList <CubitQuadFacet *>&quad_facet_list,
+ DLIList <CubitFacet *> &tri_facet_list,
+ DLIList<Surface *> &surface_list,
+ FacetFileFormat file_format = CUBIT_FACET_FILE );
+ //- import facets from a file and create a geometry model
+
+ static CubitStatus read_facets( const char * file_name,
+ int *&conn,
+ int &npoints,
+ int &nquad, int &ntri,
+ FacetFileFormat file_format = CUBIT_FACET_FILE );
+#ifdef BOYD14
+ static CubitStatus read_vtk_facets( const char * file_name,
+ double *&points,
+ int *&conn,
+ int &npoints,
+ int &tri );
+ static CubitStatus read_obj_facets( const char * file_name,
+ double *&points,
+ int *&conn,
+ int &npoints,
+ int &tri );
+#endif
+ static CubitStatus read_cholla_file( const char *file_name,
+ double &feature_angle,
+ DLIList<CubitPoint *> &point_list,
+ DLIList<CubitFacet *> &facet_list);
+ //- read points and facets from a file
+
+ CubitBoolean is_close(CubitVector &this_point,
+ DLIList<CubitFacet *>&facet_list,
+ CubitFacet *&lastFacet,
+ double tol);
+ //- determine if one of the facets in the list is within a
+ //- certain distance of the point.
+
+#ifdef BOYD14
+ CubitStatus make_sph( DLIList <CubitPoint *>&point_list,
+ DLIList <CubitFacet *>&facet_list,
+ double size, char *filename);
+#endif
+ static CubitStatus export_facets(DLIList<CubitFacet*> &facet_list,
+ char *filename);
+ //- export a list of facets to a facet file for debugging purposes
+
+ CubitStatus gather_all_facet_entities( DLIList<OCCBody*> &facet_bodies,
+ DLIList<OCCLump*> &facet_lumps,
+ DLIList<OCCShell*> &facet_shells,
+ DLIList<OCCSurface*> &facet_surfaces,
+ DLIList<OCCLoop*> &facet_loops,
+ DLIList<OCCCoEdge*> &facet_coedges,
+ DLIList<OCCCurve*> &facet_curves,
+ DLIList<OCCPoint*> &facet_points );
+
+ CubitStatus save_facets( FILE *fp, DLIList<OCCSurface*> facet_surfaces,
+ DLIList<OCCCurve*> facet_curves,
+ DLIList<OCCPoint*> facet_points );
+
+ CubitStatus save_eval_tools( FILE *fp, DLIList<OCCSurface*> facet_surfaces,
+ DLIList<OCCCurve*> facet_curves );
+
+ CubitStatus dump_facets( FILE *fp,
+ DLIList<CubitFacet *> &facet_list,
+ DLIList<CubitFacetEdge *> &edge_list,
+ DLIList<CubitPoint *> &point_list );
+ CubitStatus gather_facets( DLIList<OCCSurface *> facet_surfaces,
+ DLIList<OCCCurve *> facet_curves,
+ DLIList<OCCPoint *> facet_points,
+ DLIList<CubitFacet *> &facet_list,
+ DLIList<CubitFacetEdge *> &edge_list,
+ DLIList<CubitPoint *> &point_list );
+ //- functions for saving the facet geometry representation to a cubit file
+
+ CubitStatus restore_eval_tools( FILE *fp,
+ unsigned int endian,
+ int num_facets,
+ int num_edges,
+ int num_points,
+ CubitFacet **facets,
+ CubitFacetEdge **edges,
+ CubitPoint **points,
+ int &num_cfet,
+ int &num_fet,
+ CurveFacetEvalTool **&cfeval_tools,
+ FacetEvalTool **&feval_tools );
+ //- restore facets from CUB file
+
+CubitStatus create_super_facet_bounding_box(
+ DLIList<BodySM*>& body_list,
+ CubitBox& super_box );
+CubitStatus create_facet_bounding_box(
+ BodySM* bodySM,
+ CubitBox& bbox );
+
+ CubitStatus restore_transform( BodySM* body );
+
+ CubitStatus translate( BodySM* body, const CubitVector& offset );
+ CubitStatus rotate ( BodySM* body, const CubitVector& axis, double angle );
+ CubitStatus scale ( BodySM* body, double factor );
+ CubitStatus scale ( BodySM* body, const CubitVector& factors );
+ CubitStatus reflect ( BodySM* body, const CubitVector& axis );
+
+ CubitStatus translate( GeometryEntity* ent, const CubitVector& offset );
+ CubitStatus rotate ( GeometryEntity* ent, const CubitVector& axis, double degrees );
+ CubitStatus scale ( GeometryEntity* ent, double factor );
+ CubitStatus scale ( GeometryEntity* ent, const CubitVector& factors );
+ CubitStatus reflect ( GeometryEntity* ent, const CubitVector& axis );
+
+ CubitStatus get_connected_patch( DLIList<OCCSurface*>& remaining_surfs,
+ DLIList<OCCSurface*>& output_patch );
+ virtual CubitBoolean bodies_overlap (BodySM *body_ptr_1,
+ BodySM *body_ptr_2 ) const;
+ //R CubitBoolean
+ //R- CUBIT_TRUE if the two bodies overlap, CUBIT_FALSE if they don't
+ //R- overlap. If the bodies are touching the function
+ //R- should return CUBIT_FALSE.
+ //I body_ptr_1, body_ptr_2
+ //I- The two body pointers that are being tested for overlap.
+ //- The function uses the intersect call to test if the bodies
+ //- are overlaping. The full intersect Boolean is needed to see if
+ //- the bodies actually overlap and don't just touch.
+
+ static TopologyBridge* occ_to_cgm(TopoDS_Shape shape);
+
+protected:
+
+ OCCQueryEngine();
+
+private:
+
+ CubitStatus write_topology( FILE *file_ptr,
+ DLIList<OCCBody*> &facet_bodies,
+ DLIList<OCCLump*> &facet_lumps,
+ DLIList<OCCShell*> &facet_shells,
+ DLIList<OCCSurface*> &facet_surfaces,
+ DLIList<OCCLoop*> &facet_loops,
+ DLIList<OCCCoEdge*> &facet_coedges,
+ DLIList<OCCCurve*> &facet_curves,
+ DLIList<OCCPoint*> &facet_points );
+
+ CubitStatus restore_topology( FILE *file_ptr,
+ unsigned int endian,
+ int num_points,
+ CubitPoint **points_array,
+ int num_cfet,
+ CurveFacetEvalTool **cfev_array,
+ int num_fet,
+ FacetEvalTool **fev_array,
+ DLIList<TopologyBridge*> &imported_entities );
+
+ CubitStatus restore_facets( FILE *file_ptr,
+ unsigned int endian,
+ int &num_facets,
+ int &num_edges,
+ int &num_points,
+ CubitPoint**&points_array,
+ int &num_cfet,
+ int &num_fet,
+ CurveFacetEvalTool **&cfet_array,
+ FacetEvalTool **&fet_array);
+
+ CubitStatus read_facets( FILE *fp,
+ unsigned int endian,
+ int &num_facets, int &num_edges, int &num_points,
+ CubitFacet **&facets, CubitFacetEdge **&edges,
+ CubitPoint **&points );
+
+ CubitStatus populate_topology_bridge_solid(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities);
+ CubitStatus populate_topology_bridge_shell(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities);
+ CubitStatus populate_topology_bridge_face(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities);
+ CubitStatus populate_topology_bridge_wire(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities);
+ CubitStatus populate_topology_bridge_edge(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities);
+ CubitStatus populate_topology_bridge_vertex(TopoDS_Shape aShape, DLIList<TopologyBridge*> &imported_entities, Curve *curve);
+
+ static TopTools_DataMapOfShapeInteger* OCCMap;
+ static TopTools_DataMapOfShapeInteger* OCCMapr;
+ static DLIList<TopologyBridge*>* CGMList;
+ static OCCQueryEngine* instance_;
+ //- static pointer to unique instance of this class
+
+ static CubitStatus init_hash_points( int num_points );
+ static CubitStatus add_hash_point( CubitPoint *point_ptr );
+ static CubitPoint *get_hash_point( int id );
+ static void delete_hash_points( );
+ static int get_hash_key( int id );
+ static CubitStatus get_all_hash_points(DLIList<CubitPoint *> &point_list);
+ static int hashPointSize;
+ static DLIList<CubitPoint *> *hashPointArray;
+ //- hash table functions used for reading the facet file
+
+ static const int OCCQE_MAJOR_VERSION;
+ static const int OCCQE_MINOR_VERSION;
+ static const int OCCQE_SUBMINOR_VERSION;
+
+};
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASS DECLARATIONS **********
+// ********** END HELPER CLASS DECLARATIONS **********
+
+#endif
Added: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,512 @@
+//-------------------------------------------------------------------------
+// Filename : OCCShell.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : David White
+//
+// Creation Date : 7/18/2000
+//
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES **********
+#include <stddef.h>
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CastTo.hpp"
+#include "CubitUtil.hpp"
+
+#include "OCCQueryEngine.hpp"
+#include "OCCShell.hpp"
+#include "ShellSM.hpp"
+#include "Lump.hpp"
+#include "Surface.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCSurface.hpp"
+#include "OCCLoop.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCCurve.hpp"
+#include "OCCPoint.hpp"
+#include "FacetEvalTool.hpp"
+#include "CubitPoint.hpp"
+#include "CubitFacetEdge.hpp"
+#include "GfxDebug.hpp"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+// ********** END CUBIT INCLUDES **********
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+
+//-------------------------------------------------------------------------
+// Purpose : A constructor with a pointer to a ACIS SHELL.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCShell::OCCShell(TopoDS_Shell *theShell)
+{
+ myLump = NULL;
+ myTopoDSShell = theShell;
+}
+OCCShell::OCCShell(Lump* my_lump,
+ DLIList<Surface*> &my_surfs )
+{
+ myLump = my_lump;
+ mySurfs += my_surfs;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : A constructor with list of surfaces.
+//
+// Special Notes : For use with save/restore
+//
+//-------------------------------------------------------------------------
+OCCShell::OCCShell( DLIList<Surface*> &my_surfs )
+{
+ myLump = NULL;
+ mySurfs += my_surfs;
+}
+//-------------------------------------------------------------------------
+// Purpose : The destructor.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCShell::~OCCShell()
+{}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: OCCQueryEngine
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+GeometryQueryEngine*
+ OCCShell::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+void OCCShell::append_simple_attribute_virt(CubitSimpleAttrib*)
+{
+}
+void OCCShell::remove_simple_attribute_virt(CubitSimpleAttrib* )
+{
+}
+void OCCShell::remove_all_simple_attribute_virt()
+{
+}
+CubitStatus OCCShell::get_simple_attribute(DLIList<CubitSimpleAttrib*>&)
+{
+ return CUBIT_FAILURE;
+}
+CubitStatus OCCShell::get_simple_attribute(const CubitString&,
+ DLIList<CubitSimpleAttrib*>&)
+ { return CUBIT_FAILURE; }
+
+/*
+void OCCShell::bodysms(DLIList<BodySM*> &bodies)
+{
+ if (myLump)
+ myLump->bodysms(bodies);
+}
+
+void OCCShell::lumps(DLIList<Lump*> &lumps)
+{
+ lumps.append_unique(myLump);
+}
+
+void OCCShell::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ shellsms.append_unique(this);
+}
+
+void OCCShell::surfaces(DLIList<Surface*> &surfaces)
+{
+ int ii;
+ for ( ii = mySurfs.size(); ii > 0; ii-- )
+ {
+ surfaces.append_unique(mySurfs.get_and_step());
+ }
+}
+
+void OCCShell::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ int ii;
+ for ( ii = mySurfs.size(); ii > 0; ii-- )
+ {
+ mySurfs.get_and_step()->loopsms(loopsms);
+ }
+}
+
+void OCCShell::curves(DLIList<Curve*> &curves)
+{
+ int ii;
+ for ( ii = mySurfs.size(); ii > 0; ii-- )
+ {
+ mySurfs.get_and_step()->curves(curves);
+ }
+}
+
+void OCCShell::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ int ii;
+ for ( ii = mySurfs.size(); ii > 0; ii-- )
+ {
+ mySurfs.get_and_step()->coedgesms(coedgesms);
+ }
+}
+
+void OCCShell::points(DLIList<Point*> &points)
+{
+ int ii;
+ for ( ii = mySurfs.size(); ii > 0; ii-- )
+ {
+ mySurfs.get_and_step()->points(points);
+ }
+}
+*/
+
+void OCCShell::add_lump(Lump* lump_ptr)
+{
+ assert(NULL == myLump);
+ myLump = lump_ptr;
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Query solid modeler topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date :
+//-------------------------------------------------------------------------
+void OCCShell::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { parents.append(myLump); }
+void OCCShell::get_children_virt( DLIList<TopologyBridge*>& children )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSShell, TopAbs_FACE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *surface = OCCQueryEngine::occ_to_cgm(M(ii));
+ children.append_unique(surface);
+ }
+}
+
+
+void OCCShell::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ OCCLump* lump = dynamic_cast<OCCLump*>(myLump);
+ if (lump)
+ result_list.append(lump);
+}
+
+void OCCShell::get_surfaces( DLIList<OCCSurface*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSShell, TopAbs_FACE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *surface = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCSurface*>(surface));
+ }
+}
+
+
+void OCCShell::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ DLIList<OCCSurface*> surface_list;
+ get_surfaces( surface_list );
+ surface_list.reset();
+ for ( int i = 0; i < surface_list.size(); i++ )
+ surface_list.next(i)->get_coedges( result_list );
+}
+
+void OCCShell::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ result_list.append_unique(curve);
+ }
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Disconnect input surfaces from "this" shell
+//
+// Special Notes :
+//
+// Creator : Corey Ernst
+//
+// Creation Date : 08/31/04
+//-------------------------------------------------------------------------
+void OCCShell::disconnect_surfaces( DLIList<OCCSurface*> &surfs_to_disconnect )
+{
+ for (int i = surfs_to_disconnect.size(); i--; )
+ {
+ OCCSurface* surface = surfs_to_disconnect.get_and_step();
+ if( mySurfs.move_to( dynamic_cast<Surface*>(surface) ) )
+ mySurfs.change_to(NULL);
+
+ if (surface)
+ surface->remove_shell(this);
+ }
+ mySurfs.remove_all_with_value( NULL );
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+void OCCShell::disconnect_all_surfaces()
+{
+ mySurfs.reset();
+ for (int i = mySurfs.size(); i--; )
+ {
+ Surface* sm_ptr = mySurfs.get_and_step();
+ OCCSurface* surface = dynamic_cast<OCCSurface*>(sm_ptr);
+ if (surface)
+ surface->remove_shell(this);
+ }
+ mySurfs.clean_out();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Flip surface-use sense
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 05/26/04
+//-------------------------------------------------------------------------
+void OCCShell::reverse()
+{
+ for (int i = mySurfs.size(); i--; )
+ {
+ OCCSurface* surf = dynamic_cast<OCCSurface*>(mySurfs.next(i));
+ CubitSense sense = surf->get_shell_sense( this );
+ assert( CUBIT_UNKNOWN != sense );
+ surf->set_shell_sense( this, CubitUtil::opposite_sense( sense ) );
+ }
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Actually flip the underlying surfaces
+//
+// Special Notes :
+//
+// Creator : Michael Brewer
+//
+// Creation Date : 03/22/05
+//-------------------------------------------------------------------------
+void OCCShell::reverse_surfaces()
+{
+ for (int i = mySurfs.size(); i--; )
+ {
+ OCCSurface* surf = dynamic_cast<OCCSurface*>(mySurfs.next(i));
+ surf->reverse_sense();
+ }
+}
+//-------------------------------------------------------------------------
+// Purpose : Determines if point is contained within shell
+//
+// Special Notes : If the shell is a void, it contains all points it doesn't enclose
+//
+// Creator : Corey Ernst
+//
+// Creation Date : 09/01/04
+//-------------------------------------------------------------------------
+CubitPointContainment OCCShell::point_containment( const CubitVector &input_point )
+{
+ //just to avoid crashes, make sure we have surfaces in this list.
+ if(mySurfs.size() < 1){
+ return CUBIT_PNT_OUTSIDE;
+ }
+ CubitVector closest_location, point = input_point;
+ OCCSurface *closest_surf = dynamic_cast<OCCSurface*>(mySurfs.get_and_step());
+ OCCSurface *tmp_surf;
+ closest_surf->closest_point_trimmed( point, closest_location );
+ double shortest_dist = point.distance_between( closest_location );
+
+ int i;
+ //Look through all this shell's surfaces to find the closest
+ //surface to input_point
+
+ for(i=mySurfs.size()-1; i--;)
+ {
+ CubitVector tmp_closest_location;
+ tmp_surf = dynamic_cast<OCCSurface*>(mySurfs.get_and_step());
+ tmp_surf->closest_point_trimmed( point, tmp_closest_location );
+
+ double tmp_shortest_dist = point.distance_between( tmp_closest_location );
+ if( tmp_shortest_dist < shortest_dist )
+ {
+ closest_location = tmp_closest_location;
+ closest_surf = tmp_surf;
+ shortest_dist = tmp_shortest_dist;
+ }
+ }
+
+ //determine if it's on the surface, inside or outside
+ if( shortest_dist <= GEOMETRY_RESABS )
+ return CUBIT_PNT_BOUNDARY;
+
+ //find the closest facet on that surface to input_point
+ CubitFacet *closest_facet = closest_surf->get_eval_tool()->closest_facet( closest_location );
+
+ //get the coordinates of the closest point
+ CubitPoint *pt1, *pt2;
+ closest_facet->closest_point_trimmed( point, closest_location, pt1, pt2 );
+
+ CubitVector normal;
+ CubitPoint *on_point = NULL;
+ //case 1: point is closest to an edge of the facet
+ if( pt1 || pt2 )
+ {
+ //only returned one, so the it is closest to a node
+ if(!pt2){
+ on_point = pt1;
+ }
+ else if(!pt1){
+ on_point = pt2;
+ }
+ else{//double-check that we are not closest to a single node
+
+ if((pt1->coordinates().distance_between(closest_location)) <= GEOMETRY_RESABS )
+ on_point = pt1;
+ else if((pt2->coordinates().distance_between(closest_location)) <= GEOMETRY_RESABS )
+ on_point = pt2;
+ }
+
+ if( on_point )
+ {
+ //get all facets that share this point
+ DLIList<CubitFacet*> facets_sharing_point;
+ on_point->facets( facets_sharing_point );
+
+ for(i=facets_sharing_point.size(); i--; )
+ normal += facets_sharing_point.get_and_step()->normal();
+
+ //average the normals of all these facets
+ normal /= facets_sharing_point.size();
+ }
+ else
+ {
+ //case 2: get the 2 normals of the 2 neighboring facets and average them
+ int index;
+ CubitFacetEdge *shared_facet_edge;
+ shared_facet_edge = closest_facet->edge_from_pts( pt1, pt2, index);
+ CubitFacet *other_facet = shared_facet_edge->other_facet( closest_facet );
+ if(!other_facet){
+ PRINT_ERROR("Edge is not connected to two facets.\n");
+ normal = closest_facet->normal();
+ }
+ else{
+ normal = ( closest_facet->normal() + other_facet->normal() ) / 2;
+ }
+ }
+ }
+ else
+ {
+ //case 3: just get the normal of this facet
+ normal = closest_facet->normal();
+ }
+
+// if ( closest_surf->get_relative_surface_sense() == CUBIT_REVERSED )
+// {
+// PRINT_WARNING("mbrewer: This shouldn't happen anymore.\n");
+// normal = -1.0*( normal );
+// }
+
+ ShellSM *shell_sm = static_cast<ShellSM*>(this);
+ if( closest_surf->get_shell_sense( shell_sm ) == CUBIT_REVERSED )
+ {
+ normal = -1.0*( normal );
+ }
+ if( (point-closest_location)%(normal) > 0 )
+ return CUBIT_PNT_OUTSIDE;
+ else
+ return CUBIT_PNT_INSIDE;
+}
+
+//Determine whether this shell is a sheet (ie, closed or not)
+CubitBoolean OCCShell::is_sheet()
+{
+ //get a list of all the facets in the sheet
+ DLIList<CubitFacet*> facet_list;
+ int i;
+ for (i = mySurfs.size(); i--; )
+ {
+ OCCSurface* surf = dynamic_cast<OCCSurface*>(mySurfs.next(i));
+ surf->tris(facet_list);
+ }
+ //should be unique... doesn't hurt anything if it isn't
+ //facet_list.uniquify_ordered();
+ CubitFacet* this_facet;
+ CubitPoint* node_1;
+ CubitPoint* node_2;
+ CubitPoint* node_3;
+ //if any of the facets don't have another facet across a given
+ // edge... this is a sheet shell because it isn't closed.
+ for (i = facet_list.size(); i--; ){
+ this_facet=facet_list.get_and_step();
+ if(!this_facet){
+ PRINT_ERROR("Unexpected NULL pointer.");
+ return CUBIT_TRUE;
+ }
+ this_facet->tri_nodes(node_1,node_2,node_3);
+ if(!this_facet->shared_facet( node_1, node_2 ) ||
+ !this_facet->shared_facet( node_1, node_3 ) ||
+ !this_facet->shared_facet( node_2, node_3 ) ){
+ return CUBIT_TRUE;
+ }
+ }
+ //otherwise we made it through without finding a gap so it is close...
+ // thus not a sheet.
+ return CUBIT_FALSE;
+}
+
+
+
+// ********** END PUBLIC FUNCTIONS **********
+
+// ********** BEGIN PROTECTED FUNCTIONS **********
+// ********** END PROTECTED FUNCTIONS **********
+
+// ********** BEGIN PRIVATE FUNCTIONS **********
+// ********** END PRIVATE FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASSES **********
+// ********** END HELPER CLASSES **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN STATIC FUNCTIONS **********
+// ********** END STATIC FUNCTIONS **********
+
Property changes on: cgm/trunk/geom/OCC/OCCShell.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCShell.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,156 @@
+//-------------------------------------------------------------------------
+// Filename : OCCShell.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Xuechen Liu
+//
+// Creation Date : 08/06/96
+//
+// Owner : Malcolm J. Panthaki
+//-------------------------------------------------------------------------
+
+#ifndef FACET_SHELL_HPP
+#define FACET_SHELL_HPP
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN ACIS INCLUDES **********
+// ********** END ACIS INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+#include "CubitDefines.h"
+#include "ShellSM.hpp"
+
+#include <TopoDS_Shell.hxx>
+
+class OCCBody;
+class OCCLump;
+class OCCSurface;
+class OCCLoop;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+
+// ********** END CUBIT INCLUDES **********
+
+class OCCShell : public ShellSM
+{
+public:
+
+ OCCShell(TopoDS_Shell *theShell);
+ OCCShell(Lump* my_lump,
+ DLIList<Surface*> &my_surfs );
+ //- Constructor with lists of attached lumps and surfaces.
+
+ OCCShell( DLIList<Surface*> &my_surfs );
+ //- Constructor with lists of attached surfaces.
+
+ virtual ~OCCShell() ;
+ //- Destructor.
+ void add_lump(Lump* lump_ptr);
+
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+#ifdef BOYD14
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+#endif
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+#ifdef BOYD14
+ void get_shells ( DLIList<OCCShell *>& shells );
+#endif
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+#ifdef BOYD14
+ void get_loops ( DLIList<OCCLoop *>& loops );
+#endif
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#ifdef BOYD14
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ inline Lump* get_lump() const { return myLump; }
+
+ inline void remove_lump() { myLump = 0; }
+
+ void disconnect_surfaces( DLIList<OCCSurface*> &surfs_to_disconnect );
+ void disconnect_all_surfaces();
+
+ void reverse(); // invert sense of each surface as used in this shell.
+ void reverse_surfaces(); //Actually flip the surface... do not change sense.
+
+ CubitPointContainment point_containment( const CubitVector &point );
+
+ //determine whether this is a sheet shell or not.
+ // This function may have problems with certain non-manifold geometries
+ // It is looking for facets that aren't attached to another facet for
+ // one or more of its edges.
+ // NOTE (mbrewer): this can probably be improved by going to the
+ // curves and checking for the number of co-edges on each curve.
+ CubitBoolean is_sheet();
+
+protected:
+
+private:
+ TopoDS_Shell *myTopoDSShell;
+ Lump* myLump;
+ DLIList<Surface*> mySurfs;
+};
+
+
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCShell.hpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,1172 @@
+//-------------------------------------------------------------------------
+// Filename : OCCSurface.cpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Alexander Danilov
+//
+// Creation Date :
+//
+// Owner :
+//-------------------------------------------------------------------------
+
+// ********** BEGIN OCC INCLUDES **********
+
+#include "OCCSurface.hpp"
+#include "RefFace.hpp"
+#include "OCCQueryEngine.hpp"
+#include "OCCAttrib.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCLoop.hpp"
+#include "OCCCoEdge.hpp"
+#include "OCCCurve.hpp"
+#include "OCCPoint.hpp"
+
+// ********** END OCC INCLUDES **********
+
+// ********** BEGIN CUBIT INCLUDES **********
+
+#include "CubitSimpleAttrib.hpp"
+#include "CubitVector.hpp"
+#include "GeometryDefines.h"
+
+#include "CubitUtil.hpp"
+#include "CastTo.hpp"
+#include "RefVolume.hpp"
+#include "GeometryQueryEngine.hpp"
+#include "DLIList.hpp"
+#include "ShellSM.hpp"
+#include "Lump.hpp"
+#include "LoopSM.hpp"
+#include "CubitPointData.hpp"
+
+////// #include "FacetEvalTool.hpp"
+////// #include "CubitFacetData.hpp"
+////// #include "CubitFacetEdge.hpp"
+
+// ********** END CUBIT INCLUDES **********
+
+//// #include "CubitEvaluator.hpp"
+//// #include "SphereEvaluator.hpp"
+//// #include "CylinderEvaluator.hpp"
+
+// ********** BEGIN OpenCascade INCLUDES **********
+
+#include <BRepAdaptor_Surface.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <Bnd_Box.hxx>
+#include <BndLib_AddSurface.hxx>
+#include <Precision.hxx>
+#include <TopoDS.hxx>
+#include <Extrema_ExtPS.hxx>
+#include <BRepLProp_SLProps.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+
+// ********** END OpenCascade INCLUDES **********
+
+
+// ********** BEGIN STATIC DECLARATIONS **********
+// ********** END STATIC DECLARATIONS **********
+
+
+// ********** BEGIN PUBLIC FUNCTIONS **********
+//-------------------------------------------------------------------------
+// Purpose : The constructor with a pointer to the FacetEvalTool.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+OCCSurface::OCCSurface(TopoDS_Face *theFace)
+{
+ myTopoDSFace = theFace;
+
+/* printf("Yeah!\n");
+ TopoDS_Face face = *myTopoDSFace;
+ BRepAdaptor_Surface asurface(face);
+ Bnd_Box aBox;
+ BndLib_AddSurface::Add(asurface, Precision::Approximation(), aBox);
+ double min[3], max[3];
+ aBox.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+ printf(". . . box: %lf %lf %lf, %lf %lf %lf\n", min[0], min[1], min[2], max[0], max[1], max[2]);*/
+
+}
+
+//// OCCSurface::OCCSurface(FacetEvalTool *facet_tool,
+//// DLIList<ShellSM*> &shellsms,
+//// DLIList<LoopSM*> &loopsms)
+//// {
+//// assert(0);
+//// // Calculate a bounding box if there isn't one already
+//// facetEvalTool = facet_tool;
+//// //sense_ = CUBIT_FORWARD;
+//// myShells += shellsms;
+//// myLoops += loopsms;
+//// myShellSense = CUBIT_UNKNOWN;
+//// myEvaluator = NULL;
+//// }
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : The constructor with a pointer to the FacetEvalTool.
+//// //
+//// // Special Notes : Used for save/restore
+//// //
+//// //-------------------------------------------------------------------------
+//// OCCSurface::OCCSurface( const SphereEvaluatorData *sphere_data,
+//// FacetEvalTool *facet_tool,
+//// DLIList<ShellSM*> &shellsms,
+//// DLIList<LoopSM*> &loopsms )
+//// {
+//// assert(0);
+//// facetEvalTool = facet_tool;
+//// //sense_ = CUBIT_FORWARD;
+//// myShells += shellsms;
+//// myLoops += loopsms;
+//// myShellSense = CUBIT_UNKNOWN;
+////
+//// myEvaluator = new SphereEvaluator( sphere_data );
+//// }
+//// //-------------------------------------------------------------------------
+//// // Purpose : The constructor with a pointer to the FacetEvalTool.
+//// //
+//// // Special Notes : Used for save/restore
+//// //
+//// //-------------------------------------------------------------------------
+//// OCCSurface::OCCSurface( const CylinderEvaluatorData *cylinder_data,
+//// FacetEvalTool *facet_tool,
+//// DLIList<ShellSM*> &shellsms,
+//// DLIList<LoopSM*> &loopsms )
+//// {
+//// assert(0);
+//// facetEvalTool = facet_tool;
+//// //sense_ = CUBIT_FORWARD;
+//// myShells += shellsms;
+//// myLoops += loopsms;
+//// myShellSense = CUBIT_UNKNOWN;
+////
+//// myEvaluator = new CylinderEvaluator( cylinder_data );
+//// }
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : The constructor with a pointer to the FacetEvalTool.
+//// //
+//// // Special Notes : Used for save/restore
+//// //
+//// //-------------------------------------------------------------------------
+//// OCCSurface::OCCSurface(FacetEvalTool *facet_tool,
+//// CubitSense sense,
+//// CubitSense shell_sense0,
+//// CubitBoolean use_facets,
+//// DLIList<LoopSM*> &loopsms)
+//// {
+//// assert(0);
+//// // Calculate a bounding box if there isn't one already
+//// facetEvalTool = facet_tool;
+//// //sense_ = CUBIT_FORWARD;
+//// myLoops += loopsms;
+//// myShellSense = shell_sense0;
+//// myEvaluator = NULL;
+//// }
+//// //-------------------------------------------------------------------------
+//// // Purpose : The default destructor.
+//// //
+//// // Special Notes :
+//// //
+//// //-------------------------------------------------------------------------
+
+OCCSurface::~OCCSurface()
+{
+ //// if ( facetEvalTool )
+ //// {
+ //// delete facetEvalTool;
+ //// }
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : get the interpolation order of the FacetEvalTool
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+//// int OCCSurface::interp_order()
+//// {
+//// assert(0);
+//// assert(facetEvalTool != NULL);
+////
+//// return facetEvalTool->interp_order();
+//// }
+
+//-------------------------------------------------------------------------
+// Purpose : get the min dot of the FacetEvalTool
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+//// double OCCSurface::min_dot()
+//// {
+//// assert(0);
+//// assert(facetEvalTool != NULL);
+////
+//// return facetEvalTool->get_min_dot();
+////}
+
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to append a
+// attribute to the GE. The name is attached to the
+// underlying solid model entity this one points to.
+//
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCSurface::append_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.append_attribute(csa); }
+
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove a simple
+// attribute attached to this geometry entity. The name is
+// removed from the underlying BODY this points to.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCSurface::remove_simple_attribute_virt(CubitSimpleAttrib *csa)
+ { attribSet.remove_attribute( csa ); }
+
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to remove all simple
+// attributes attached to this geometry entity. Also
+// removes lingering GTC attributes.
+//
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+void OCCSurface::remove_all_simple_attribute_virt()
+ { attribSet.remove_all_attributes(); }
+
+
+//-------------------------------------------------------------------------
+// Purpose : The purpose of this function is to get the
+// attributes attached to this geometry entity. The name is
+// attached to the underlying BODY this points to.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCSurface::get_simple_attribute(DLIList<CubitSimpleAttrib*>&
+ csa_list)
+ { return attribSet.get_attributes(csa_list); }
+CubitStatus OCCSurface::get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>& csa_list )
+ { return attribSet.get_attributes( name, csa_list ); }
+
+
+CubitStatus OCCSurface::save_attribs( FILE *file_ptr )
+ { return attribSet.save_attributes(file_ptr); }
+
+CubitStatus OCCSurface::restore_attribs( FILE *file_ptr, unsigned int endian )
+ { return attribSet.restore_attributes( file_ptr, endian ); }
+
+
+
+//-------------------------------------------------------------------------
+// Purpose : Get geometry modeling engine: OCCQueryEngine
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+GeometryQueryEngine*
+ OCCSurface::get_geometry_query_engine() const
+{
+ return OCCQueryEngine::instance();
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Get the bounding box of the object.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitBox OCCSurface::bounding_box() const
+{
+ TopoDS_Face face = *myTopoDSFace;
+ BRepAdaptor_Surface asurface(face);
+ Bnd_Box aBox;
+ BndLib_AddSurface::Add(asurface, Precision::Approximation(), aBox);
+ double min[3], max[3];
+ aBox.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+ return CubitBox(min, max);
+}
+
+
+CubitStatus OCCSurface::get_point_normal( CubitVector& location,
+ CubitVector& normal )
+{
+ assert(0);
+ return closest_point( location, NULL, &normal );
+}
+
+CubitStatus OCCSurface::closest_point_uv_guess(
+ CubitVector const& location,
+ double& , double& ,
+ CubitVector* closest_location,
+ CubitVector* unit_normal )
+{
+ // don't use u and v guesses
+ return closest_point(location, closest_location, unit_normal);
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Computes the closest_point on the surface to the input
+// location. Optionally, it also computes and returns
+// the normal to the surface and the principal curvatures
+// at closest_location.
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCSurface::closest_point( CubitVector const& location,
+ CubitVector* closest_location,
+ CubitVector* unit_normal_ptr,
+ CubitVector* curvature1_ptr,
+ CubitVector* curvature2_ptr)
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
+ double minDist=0.0, u, v;
+ int i;
+ BRepLProp_SLProps SLP(asurface, 2, Precision::PConfusion());
+ Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
+ if (ext.IsDone() && (ext.NbExt() > 0)) {
+ for ( i = 1 ; i < ext.NbExt() ; i++ ) {
+ if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
+ minDist = p.Distance(ext.Point(i).Value());
+ newP = ext.Point(i).Value();
+ ext.Point(i).Parameter(u, v);
+ SLP.SetParameters(u, v);
+ }
+ }
+ }
+ *closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+ if (unit_normal_ptr != NULL) {
+ gp_Dir normal;
+ if (SLP.IsNormalDefined()) {
+ normal = SLP.Normal();
+ *unit_normal_ptr = CubitVector(normal.X(), normal.Y(), normal.Z());
+ }
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Computes the closest_point on the trimmed surface to the
+// input location.
+//
+// Special Notes :
+//-------------------------------------------------------------------------
+void OCCSurface::closest_point_trimmed( CubitVector from_point,
+ CubitVector& point_on_surface)
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p(from_point.x(), from_point.y(), from_point.z()), newP(0.0, 0.0, 0.0);
+ double minDist=0.0;
+ int i;
+ Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
+ if (ext.IsDone() && (ext.NbExt() > 0)) {
+ for ( i = 1 ; i < ext.NbExt() ; i++ ) {
+ if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
+ minDist = p.Distance(ext.Point(i).Value());
+ newP = ext.Point(i).Value();
+ }
+ }
+ }
+ point_on_surface = CubitVector(newP.X(), newP.Y(), newP.Z());
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This functions computes the point on the surface that is
+// closest to the input location and then calculates the
+// magnitudes of the principal curvatures at this (possibly,
+// new) point on the surface. Specifying the RefVolume for
+// reference is optional.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+
+CubitStatus OCCSurface::principal_curvatures(
+ CubitVector const& location,
+ double& curvature_1,
+ double& curvature_2,
+ CubitVector* closest_location )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
+ double minDist=0.0, u, v;
+ int i;
+ BRepLProp_SLProps SLP(asurface, 2, Precision::PConfusion());
+ Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
+ if (ext.IsDone() && (ext.NbExt() > 0)) {
+ for ( i = 1 ; i < ext.NbExt() ; i++ ) {
+ if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
+ minDist = p.Distance(ext.Point(i).Value());
+ newP = ext.Point(i).Value();
+ ext.Point(i).Parameter(u, v);
+ SLP.SetParameters(u, v);
+ }
+ }
+ }
+ *closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+ curvature_1 = SLP.MinCurvature();
+ curvature_2 = SLP.MaxCurvature();
+ return CUBIT_SUCCESS;
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Given values of the two parameters, get the position.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitVector OCCSurface::position_from_u_v (double u, double v)
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p = asurface.Value(u, v);
+ return CubitVector (p.X(), p.Y(), p.Z());
+}
+
+//-------------------------------------------------------------------------
+// Purpose : This function returns the {u, v} coordinates of the point
+// on the Surface closest to the input point (specified in
+// global space). The closest_location is also returned.
+//
+// Special Notes :
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCSurface::u_v_from_position( CubitVector const& location,
+ double& u,
+ double& v,
+ CubitVector* closest_location )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
+ double minDist=0.0;
+ int i;
+ Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
+ if (ext.IsDone() && (ext.NbExt() > 0)) {
+ for ( i = 1 ; i <= ext.NbExt() ; i++ ) {
+ if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
+ minDist = p.Distance(ext.Point(i).Value());
+ newP = ext.Point(i).Value();
+ ext.Point(i).Parameter(u, v);
+ }
+ }
+ }
+ if (closest_location != NULL) *closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines whether the Facet surface is periodic. Not
+// available yet.
+//
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_periodic()
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ return (asurface.IsUPeriodic() || asurface.IsVPeriodic())?CUBIT_TRUE:CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is periodic in the given parameter
+// direction. Not available yet.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_periodic_in_U( double& period )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ return (asurface.IsUPeriodic())?CUBIT_TRUE:CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is periodic in the given parameter
+// direction. Not available yet.
+//
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_periodic_in_V( double& period )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ return (asurface.IsVPeriodic())?CUBIT_TRUE:CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is singular in the given parameter
+// direction. Not available yet.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_singular_in_U( double )
+{
+ assert(0);
+ if ( myEvaluator )
+ return myEvaluator->is_singular_in_U();
+
+ //PRINT_ERROR("OCCSurface::is_singular_in_U not implemented yet\n");
+ return CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is singular in the given parameter
+// direction. Not available yet.
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_singular_in_V( double )
+{
+ assert(0);
+ if ( myEvaluator )
+ return myEvaluator->is_singular_in_V();
+
+ //PRINT_ERROR("OCCSurface::is_singular_in_V not implemented yet\n");
+ return CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is closed in the U parameter.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_closed_in_U()
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ return (asurface.IsUClosed())?CUBIT_TRUE:CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines if the face is closed in the V parameter.
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_closed_in_V()
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ return (asurface.IsUClosed())?CUBIT_TRUE:CUBIT_FALSE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Calculates the derivitives at a given parameter location.
+//
+//-------------------------------------------------------------------------
+CubitStatus OCCSurface::uv_derivitives( double u,
+ double v,
+ CubitVector &du,
+ CubitVector &dv )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ gp_Pnt p;
+ gp_Vec d1u, d1v;
+ asurface.D1(u, v, p, d1u, d1v);
+ du = CubitVector(d1u.X(), d1u.Y(), d1u.Z());
+ dv = CubitVector(d1v.X(), d1v.Y(), d1v.Z());
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Determines whether the surface is parametrically defined.
+// Hopefully later this will be available.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_parametric()
+{
+ return CUBIT_TRUE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns the lower and upper parametric bounds of the
+// surface in U, if it is parametric. Otherwise, it returns
+// CUBIT_FALSE and zeroes for the upper and lower parametric
+// bounds.
+//
+// Creator :
+//
+// Creation Date :
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::get_param_range_U( double& lower_bound,
+ double& upper_bound )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ lower_bound = asurface.FirstUParameter();
+ upper_bound = asurface.LastUParameter();
+ return CUBIT_TRUE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns the lower and upper parametric bounds of the
+// surface in V, if it is parametric. Otherwise, it returns
+// CUBIT_FALSE and zeroes for the upper and lower parametric
+// bounds.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::get_param_range_V( double& lower_bound,
+ double& upper_bound )
+{
+ BRepAdaptor_Surface asurface(*myTopoDSFace);
+ lower_bound = asurface.FirstVParameter();
+ upper_bound = asurface.LastVParameter();
+ return CUBIT_TRUE;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns a surface type ID
+//
+//-------------------------------------------------------------------------
+GeometryType OCCSurface::geometry_type()
+{
+ return UNDEFINED_SURFACE_TYPE;
+/* if ( is_flat() )
+ {
+ return PLANE_SURFACE_TYPE;
+ }
+ else if ( is_spherical() )
+ {
+ return SPHERE_SURFACE_TYPE;
+ }
+ else if ( is_conical() )
+ {
+ return CONE_SURFACE_TYPE;
+ }
+ else
+ {
+ return UNDEFINED_SURFACE_TYPE;
+ }*/
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Returns the area of the Surface
+//
+//-------------------------------------------------------------------------
+double OCCSurface::measure()
+{
+ GProp_GProps myProps;
+ BRepGProp::SurfaceProperties(*myTopoDSFace, myProps);
+ return myProps.Mass();
+}
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : Updates the (cached) area of the Surface so that if
+//// // measure() is called, the correct value is returned.
+//// //-------------------------------------------------------------------------
+//// void OCCSurface::update_measurement()
+//// {
+//// assert(0);
+//// facetEvalTool->calculate_area();
+//// }
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : Returns whether the facet surface is completely flat
+//// //
+//// //-------------------------------------------------------------------------
+//// CubitBoolean OCCSurface::is_flat()
+//// {
+//// assert(0);
+//// // Danilov: try to use BRepAdaptor_Surface::GetType
+//// return (facetEvalTool->is_flat() == 1) ? CUBIT_TRUE : CUBIT_FALSE;
+//// }
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : Returns whether the facet surface is spherical
+//// //
+//// //-------------------------------------------------------------------------
+//// CubitBoolean OCCSurface::is_spherical()
+//// {
+//// assert(0);
+//// // Danilov: try to use BRepAdaptor_Surface::GetType
+//// if ( myEvaluator && myEvaluator->ask_type() == SPHERE_SURFACE_TYPE )
+//// {
+//// return CUBIT_TRUE;
+//// }
+//// return CUBIT_FALSE;
+//// }
+////
+
+//// //-------------------------------------------------------------------------
+//// // Purpose : Returns whether the facet surface is spherical
+//// //
+//// //-------------------------------------------------------------------------
+//// CubitBoolean OCCSurface::is_conical()
+//// {
+//// assert(0);
+//// // Danilov: try to use BRepAdaptor_Surface::GetType
+//// if ( myEvaluator && myEvaluator->ask_type() == CONE_SURFACE_TYPE )
+//// {
+//// return CUBIT_TRUE;
+//// }
+//// return CUBIT_FALSE;
+//// }
+
+//// const CubitEvaluatorData *OCCSurface::evaluator_data( void )
+//// {
+//// assert(0);
+//// if ( myEvaluator )
+//// {
+//// return myEvaluator->evaluator_data();
+//// }
+//// return NULL;
+//// }
+
+//-------------------------------------------------------------------------
+// Purpose : This function tests the passed in position to see if
+// is on the underlying surface.
+//
+//-------------------------------------------------------------------------
+CubitBoolean OCCSurface::is_position_on( CubitVector &test_position )
+{
+ CubitVector new_point;
+ CubitStatus stat = closest_point(test_position, &new_point, NULL,NULL,NULL);
+ if ( !stat )
+ return CUBIT_FALSE;
+ CubitVector result_vec = test_position - new_point;
+ if ( result_vec.length_squared() < GEOMETRY_RESABS )
+ return CUBIT_TRUE;
+ return CUBIT_FALSE;
+}
+
+CubitPointContainment OCCSurface::point_containment( const CubitVector &/*point*/ )
+{
+ assert(0);
+ return CUBIT_PNT_UNKNOWN;
+}
+
+CubitPointContainment OCCSurface::point_containment( double /*u_param*/,
+ double /*v_param*/ )
+{
+ assert(0);
+ return CUBIT_PNT_UNKNOWN;
+}
+
+//CubitPointContainment OCCSurface::point_containment( const CubitVector &/*point*/,
+// double /*u_param*/,
+// double /*v_param*/ )
+//{
+// return CUBIT_PNT_UNKNOWN;
+//}
+
+CubitSense OCCSurface::get_geometry_sense()
+{
+ assert(0);
+ CubitSense sense = CUBIT_FORWARD; //get_relative_surface_sense();
+ return sense;
+}
+
+// CubitSense OCCSurface::get_relative_surface_sense()
+// {
+// //not sure if this is right for the facet surface...
+// return sense_;
+// }
+
+/*
+
+void OCCSurface::bodysms(DLIList<BodySM*> &bodies)
+{
+ int ii;
+ for ( ii = myShells.size(); ii > 0; ii-- )
+ {
+ myShells.get_and_step()->bodysms(bodies);
+ }
+}
+
+void OCCSurface::lumps(DLIList<Lump*> &lumps)
+{
+ int ii;
+ for ( ii = myShells.size(); ii > 0; ii-- )
+ {
+ myShells.get_and_step()->lumps(lumps);
+ }
+}
+
+void OCCSurface::shellsms(DLIList<ShellSM*> &shellsms)
+{
+ int ii;
+ for ( ii = myShells.size(); ii > 0; ii-- )
+ {
+ shellsms.append_unique(myShells.get_and_step());
+ }
+}
+
+void OCCSurface::surfaces(DLIList<Surface*> &surfaces)
+{
+ surfaces.append_unique(this);
+}
+
+void OCCSurface::loopsms(DLIList<LoopSM*> &loopsms)
+{
+ int ii;
+ for ( ii = myLoops.size(); ii > 0; ii-- )
+ {
+ loopsms.append_unique(myLoops.get_and_step());
+ }
+}
+void OCCSurface::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
+{
+ int ii;
+ for ( ii = myLoops.size(); ii > 0; ii-- )
+ {
+ myLoops.get_and_step()->coedgesms(coedgesms);
+ }
+}
+
+void OCCSurface::curves(DLIList<Curve*> &curves)
+{
+ int ii;
+ for ( ii = myLoops.size(); ii > 0; ii-- )
+ {
+ myLoops.get_and_step()->curves(curves);
+ }
+}
+void OCCSurface::points(DLIList<Point*> &points)
+{
+ int ii;
+ for ( ii = myLoops.size(); ii > 0; ii-- )
+ {
+ myLoops.get_and_step()->points(points);
+ }
+}
+*/
+
+
+void OCCSurface::get_parents_virt( DLIList<TopologyBridge*>& parents )
+ { CAST_LIST_TO_PARENT( myShells, parents ); }
+
+void OCCSurface::get_children_virt( DLIList<TopologyBridge*>& children )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSFace, TopAbs_WIRE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *loop = OCCQueryEngine::occ_to_cgm(M(ii));
+ children.append_unique(loop);
+ }
+}
+
+
+//// CubitStatus OCCSurface::get_my_facets(DLIList<CubitFacet*> &facet_list,
+//// DLIList<CubitPoint*>& point_list)
+//// {
+//// facetEvalTool->get_facets(facet_list);
+//// facetEvalTool->get_points(point_list);
+//// return CUBIT_SUCCESS;
+//// }
+
+//// void OCCSurface::tris(DLIList<CubitFacet *> &facet_list)
+//// {
+//// facetEvalTool->get_facets(facet_list);
+//// }
+
+//// void OCCSurface::get_my_points(DLIList<CubitPoint*> &point_list)
+//// {
+//// facetEvalTool->get_points(point_list);
+//// }
+
+//// void OCCSurface::get_my_facetedges(DLIList<CubitFacetEdge*> &edge_list)
+//// {
+//// facetEvalTool->get_edges(edge_list);
+//// }
+
+void OCCSurface::get_shell_sense( CubitSense &sense0)
+{
+ TopAbs_Orientation d = myTopoDSFace->Orientation();
+ if (d == TopAbs_FORWARD) sense0 = CUBIT_FORWARD;
+ else if (d == TopAbs_REVERSED) sense0 = CUBIT_REVERSED;
+ else {
+ printf("Check Orientation (surface)");
+ sense0 = CUBIT_UNKNOWN;
+ }
+}
+
+
+// return the sense with respect to the given shell
+CubitSense OCCSurface::get_shell_sense( ShellSM* shell_ptr ) const
+{
+ TopAbs_Orientation d = myTopoDSFace->Orientation();
+ if (d == TopAbs_FORWARD) return CUBIT_FORWARD;
+ else if (d == TopAbs_REVERSED) return CUBIT_REVERSED;
+ else {
+ printf("Check Orientation (surface)");
+ return CUBIT_UNKNOWN;
+ }
+}
+
+// set the sense of the surface with respect to the shell
+void OCCSurface::set_shell_sense( OCCShell *facet_shell,
+ CubitSense thesense )
+{
+ assert(0);
+// if(thesense == CUBIT_REVERSED){
+// PRINT_INFO("should not do this.");
+// }
+ int idx = myShells.get_index();
+ if(idx > 0){
+ PRINT_ERROR("Multiple shells attached to a single surface.\n");
+ return;
+ }
+ ShellSM *shell_ptr = (ShellSM *)facet_shell;
+ ShellSM *ashell = myShells.get();
+ if (ashell == shell_ptr)
+ {
+ myShellSense = thesense;
+ }
+// else
+// {
+// myShells.step();
+// idx = myShells.get_index();
+// ashell = myShells.get();
+// if (ashell == shell_ptr)
+// {
+// myShellSense[idx] = thesense;
+// }
+// }
+}
+
+//// //----------------------------------------------------------------
+//// // Function: copy_facets
+//// // Description: copy the points and facets
+//// //
+//// // Author: sjowen
+//// //----------------------------------------------------------------
+//// CubitStatus OCCSurface::copy_facets(DLIList<CubitFacet*>©_facet_list,
+//// DLIList<CubitPoint*>©_point_list)
+//// {
+//// assert(0);
+//// if (!facetEvalTool)
+//// {
+//// PRINT_ERROR("Couldn't copy facets.");
+//// return CUBIT_FAILURE;
+//// }
+//// int ii;
+//// DLIList<CubitFacet*>facet_list;
+//// DLIList<CubitPoint*>point_list;
+//// facetEvalTool->get_facets( facet_list );
+//// facetEvalTool->get_points( point_list );
+//// CubitPoint **point_array = new CubitPoint* [point_list.size()];
+////
+//// //- copy the points
+////
+//// point_list.reset();
+//// CubitPoint *new_point, *the_point;
+//// for(ii=0; ii<point_list.size(); ii++)
+//// {
+//// the_point = point_list.get_and_step();
+//// new_point = new CubitPointData( the_point->coordinates() );
+//// the_point->marked( ii );
+//// copy_point_list.append( new_point );
+//// point_array[ii] = new_point;
+//// }
+////
+//// //- copy the facets
+////
+//// int jj, idx;
+//// CubitFacet *new_facet, *the_facet;
+//// CubitPoint *points[3];
+//// for (ii=0; ii<facet_list.size(); ii++)
+//// {
+//// the_facet = facet_list.get_and_step();
+//// for (jj=0; jj<3; jj++)
+//// {
+//// idx = the_facet->point(jj)->marked();
+//// points[jj] = point_array[idx];
+//// }
+//// new_facet = new CubitFacetData( points[0], points[1], points[2] );
+//// copy_facet_list.append( new_facet );
+//// }
+////
+//// delete [] point_array;
+////
+//// return CUBIT_SUCCESS;
+//// }
+
+void OCCSurface::get_bodies( DLIList<OCCBody*>& result_list )
+{
+ DLIList<OCCLump*> lump_list;
+ get_lumps( lump_list );
+ lump_list.reset();
+ for ( int i = lump_list.size(); i--; )
+ {
+ OCCLump* lump = lump_list.get_and_step();
+ OCCBody* body = dynamic_cast<OCCBody*>(lump->get_body());
+ if (body)
+ result_list.append_unique(body);
+ }
+}
+
+void OCCSurface::get_lumps( DLIList<OCCLump*>& result_list )
+{
+ DLIList<OCCShell*> shell_list;
+ get_shells( shell_list );
+ shell_list.reset();
+ for ( int i = shell_list.size(); i--; )
+ {
+ OCCShell* shell = shell_list.get_and_step();
+ shell->get_lumps( result_list );
+ OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
+ if (lump)
+ result_list.append_unique(lump);
+ }
+}
+
+void OCCSurface::get_shells( DLIList<OCCShell*>& result_list )
+{
+ myShells.reset();
+ for ( int i = 0; i < myShells.size(); i++ )
+ if ( OCCShell* shell = dynamic_cast<OCCShell*>(myShells.next(i)) )
+ result_list.append(shell);
+}
+
+
+void OCCSurface::get_loops( DLIList<OCCLoop*>& result_list )
+{
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*myTopoDSFace, TopAbs_WIRE, M);
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopologyBridge *loop = OCCQueryEngine::occ_to_cgm(M(ii));
+ result_list.append_unique(dynamic_cast<OCCLoop*>(loop));
+ }
+}
+
+void OCCSurface::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ DLIList<OCCLoop*> loop_list;
+ get_loops( loop_list );
+ loop_list.reset();
+ for ( int i = 0; i < loop_list.size(); i++ )
+ loop_list.next(i)->get_coedges( result_list );
+}
+
+void OCCSurface::get_curves( DLIList<OCCCurve*>& result_list )
+{
+ DLIList<OCCCoEdge*> coedge_list;
+ get_coedges( coedge_list );
+ coedge_list.reset();
+ for ( int i = coedge_list.size(); i--; )
+ {
+ OCCCoEdge* coedge = coedge_list.get_and_step();
+ OCCCurve* curve = dynamic_cast<OCCCurve*>(coedge->curve());
+ if (curve)
+ result_list.append_unique(curve);
+ }
+}
+
+
+//-------------------------------------------------------------------------
+// Purpose : Remove Shell from shell list
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus OCCSurface::remove_shell(OCCShell* shell)
+{
+ assert(0);
+ // Something strange here -- A DLIList of Shells and a
+ // two-element array for senses? Try to keep the senses
+ // intact anyway...
+ myShells.reset();
+ if (myShells.get() == shell)
+ myShellSense = CUBIT_UNKNOWN;
+
+ if (!myShells.move_to(shell))
+ return CUBIT_FAILURE;
+
+ myShells.remove();
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+void OCCSurface::disconnect_all_loops()
+{
+ assert(0);
+ myLoops.reset();
+ for (int i = myLoops.size(); i--; )
+ {
+ LoopSM* sm_ptr = myLoops.get_and_step();
+ OCCLoop* loop = dynamic_cast<OCCLoop*>(sm_ptr);
+ if (loop)
+ {
+ assert(loop->get_surface() == this);
+ loop->remove_surface();
+ }
+ }
+ myLoops.clean_out();
+}
+
+void OCCSurface::add_transformation( CubitTransformMatrix &tfmat )
+{
+ assert(0);
+ if ( myEvaluator )
+ myEvaluator->add_transformation( tfmat );
+}
+
+// ********** END PUBLIC FUNCTIONS **********
+
+// ********** BEGIN PROTECTED FUNCTIONS **********
+// ********** END PROTECTED FUNCTIONS **********
+
+// ********** BEGIN PRIVATE FUNCTIONS **********
+
+//// void OCCSurface::reverse_sense()
+//// {
+//// assert(0);
+//// facetEvalTool->reverse_facets();
+//// myLoops.reset();
+//// int i,j;
+//// OCCLoop* this_loop;
+//// LoopSM* this_loop_sm;
+//// DLIList<OCCCoEdge *> this_coedge_list;
+//// for(i=0;i<myLoops.size();i++){
+//// this_loop_sm= myLoops.get_and_step();
+//// this_loop = dynamic_cast<OCCLoop*>(this_loop_sm);
+//// if(!this_loop){
+//// PRINT_ERROR("Unexpected null pointer for loop.\n");
+//// return;
+//// }
+//// this_loop->reverse();
+//// this_coedge_list.clean_out();
+//// this_loop->get_coedges(this_coedge_list);
+//// for(j=0; j<this_coedge_list.size(); j++){
+//// this_coedge_list.get_and_step()->reverse_sense();
+//// }
+//// }
+////
+//// //sense_ = CubitUtil::opposite_sense( sense_ );
+//// myShellSense = CubitUtil::opposite_sense( myShellSense );
+//// //myShellSense[1] = CubitUtil::opposite_sense( myShellSense[1] );
+//// }
+
+// ********** END PRIVATE FUNCTIONS **********
+
+// ********** BEGIN HELPER CLASSES **********
+// ********** END HELPER CLASSES **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+// ********** BEGIN STATIC FUNCTIONS **********
+// ********** END STATIC FUNCTIONS **********
Property changes on: cgm/trunk/geom/OCC/OCCSurface.cpp
___________________________________________________________________
Name: svn:executable
+ *
Added: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp (rev 0)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp 2007-09-21 17:56:58 UTC (rev 1280)
@@ -0,0 +1,540 @@
+//-------------------------------------------------------------------------
+// Filename : OCCSurface.hpp
+//
+// Purpose :
+//
+// Special Notes :
+//
+// Creator : Alexander Danilov
+//
+// Creation Date :
+//
+// Owner :
+//-------------------------------------------------------------------------
+
+#ifndef SURFACE_OCC_HPP
+#define SURFACE_OCC_HPP
+
+
+// ********** BEGIN STANDARD INCLUDES **********
+// ********** END STANDARD INCLUDES **********
+
+// ********** BEGIN OCC INCLUDES **********
+
+#include "OCCAttribSet.hpp"
+#include <TopoDS_Face.hxx>
+
+// ********** END OCC INCLUDES **********
+
+
+// ********** BEGIN CUBIT INCLUDES **********
+
+#include "CubitDefines.h"
+#include "Surface.hpp"
+
+// ********** END CUBIT INCLUDES **********
+
+class TopologyEntity;
+class RefVolume;
+class RefFace;
+class RefVolume;
+//// class FacetEvalTool;
+class OCCShell;
+class OCCAttrib;
+
+class OCCBody;
+class OCCLump;
+class OCCLoop;
+class OCCCoEdge;
+class OCCCurve;
+class OCCPoint;
+//// class CubitFacetEdge;
+//// class CubitFacet;
+//// class CubitPoint;
+//// class CubitTransformMatrix;
+//// class CubitEvaluator;
+//// class CubitEvaluatorData;
+//// class SphereEvaluatorData;
+//// class CylinderEvaluatorData;
+
+class OCCSurface : public Surface
+{
+
+public :
+
+ OCCSurface(TopoDS_Face *theFace);
+
+ //// OCCSurface(FacetEvalTool *facet_eval_tool_ptr,
+ //// DLIList<ShellSM*> &shellsms,DLIList<LoopSM*> &loopsms );
+ //// //I- facet_eval_tool pointer
+ //// //I- A pointer to the set of facets that define this surface.
+
+ //// OCCSurface(FacetEvalTool *facet_eval_tool_ptr,
+ //// CubitSense sense,
+ //// CubitSense shell_sense0,
+ //// CubitBoolean use_facets,
+ //// DLIList<LoopSM*> &loopsms );
+
+
+ //// OCCSurface( const CylinderEvaluatorData *cylinder_data,
+ //// FacetEvalTool *facet_tool,
+ //// DLIList<ShellSM*> &shellsms,
+ //// DLIList<LoopSM*> &loopsms );
+ //// //- Constructor used to create a faceted surface representing a cylinder.
+ //// //I- eval_data - radius, base, etc. of cylinder.
+ //// //I- facet_eval_tool_ptr - evaluator to evaluate directly on facets.
+ //// //I- shellsms - the shells in this facet model
+ //// //I- loopsms - the loops in this facet model.
+
+ //// OCCSurface( const SphereEvaluatorData *eval_data,
+ //// FacetEvalTool *facet_eval_tool_ptr,
+ //// DLIList<ShellSM*> &shellsms,
+ //// DLIList<LoopSM*> &loopsms );
+ //// //- Constructor used to create a faceted surface representing a sphere.
+ //// //I- eval_data - radius, center, etc. of sphere.
+ //// //I- facet_eval_tool_ptr - evaluator to evaluate directly on facets.
+ //// //I- shellsms - the shells in this facet model
+ //// //I- loopsms - the loops in this facet model.
+
+ virtual ~OCCSurface() ;
+ //- The destructor
+
+ void add_shell(ShellSM *shell_ptr) //// Not in SurfaceACIS
+ {myShells.append(shell_ptr);}
+
+ CubitStatus remove_shell(OCCShell* shell_ptr); //// Not in SurfaceACIS
+
+ void disconnect_all_loops(); //// Not in SurfaceACIS
+
+ inline bool has_parent_shell() { return myShells.size() > 0; } //// Not in SurfaceACIS
+
+ //CubitSense get_relative_surface_sense();
+ //- Return the relative surface sense. (see below)
+
+ virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I
+ //I-
+ //I- that is to be appended to this OSME object.
+ //- The purpose of this function is to append a
+ //- attribute to the OSME. The is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_simple_attribute_virt(CubitSimpleAttrib*);
+ //R void
+ //I CubitSimpleAttrib*
+ //I- A reference to a CubitSimpleAttrib object which is the object
+ //I- that is to be removed to this OSME object.
+ //- The purpose of this function is to remove a simple
+ //- attribute from the OSME. The attribute is attached to each of the
+ //- underlying solid model entities this one points to.
+
+ virtual void remove_all_simple_attribute_virt();
+ //R void
+ //I-
+ //- The purpose of this function is to remove all simple
+ //- attributes from the OSME.
+
+ virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>&);
+ virtual CubitStatus get_simple_attribute(const CubitString& name,
+ DLIList<CubitSimpleAttrib*>&);
+ //R CubitSimpleAttrib*
+ //R- the returned cubit simple attribute.
+ //- The purpose of this function is to get the attributes
+ //- of the geometry entity. The name is attached to the underlying solid
+ //- model entity(ies) this one points to.
+ //- MJP Note:
+ //- This is the code that implements the requirement that names
+ //- of VGI Entities propagate across solid model boolean
+ //- operations. The success of this relies, of course, on the underlying
+ //- solid modeler being able to propagate attributes across
+ //- such operations on its entities. If it cannot, then "names"
+ //- of VGI entities will not propagate.
+
+ virtual CubitBox bounding_box() const ;
+ // see comments in GeometryEntity.hpp
+
+ virtual GeometryQueryEngine*
+ get_geometry_query_engine() const;
+ //R GeometryQueryEngine*
+ //R- A pointer to the geometric modeling engine associated with
+ //R- the object.
+ //- This function returns a pointer to the geometric modeling engine
+ //- associated with the object.
+
+ // Added by CAT
+ virtual CubitStatus get_point_normal( CubitVector& ,
+ CubitVector& );
+ //- Only valid for planar surfaces
+ //- Finds the underlying plane's origin and normal vector
+ //- Returns CubitFailure if not a plane. The origin and normal
+ //- are returned directly from the underlying format for a plane.
+
+ virtual void closest_point_trimmed(CubitVector from_point,
+ CubitVector& point_on_surface);
+ //R void
+ //I CubitVector
+ //I- point from which to find closest point on trimmed surface
+ //O CubitVector
+ //O- point on trimmed surface closest to passed-in point
+ //- This function finds the closest point on a TRIMMED surface to the
+ //- passed-in point.
+
+ virtual CubitStatus closest_point_uv_guess(
+ CubitVector const& location,
+ double &u, double &v,
+ CubitVector* closest_location = NULL,
+ CubitVector* unit_normal = NULL );
+
+
+ virtual CubitStatus closest_point(
+ CubitVector const& location,
+ CubitVector* closest_location = NULL,
+ CubitVector* unit_normal_ptr = NULL,
+ CubitVector* curvature1_ptr = NULL,
+ CubitVector* curvature2_ptr = NULL);
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I location
+ //I- The point to which the closest point on the surface is desired.
+ //O closest_location
+ //O- The point on the Surface, closest to the
+ //O- input location (which might not be on the Surface). This is
+ //O- input as a reference so that the function can modify its
+ //O- contents.
+ //O unit_normal_ptr
+ //O- The normal (represented as a unit vector) at the closest_location.
+ //O- If this pointer is NULL, the normal is not returned.
+ //O curvature1_ptr
+ //O- The first principal curvature of the surface at closest_location.
+ //O- If this pointer is NULL, this curvature is not returned.
+ //O curvature2_ptr
+ //O- The second principal curvature of the surface at closest_location.
+ //O- If this pointer is NULL, this curvature is not returned.
+ //- This function computes the point on the surface closest to the input
+ //- location -- i.e., closest_location.
+ //- The first Facet FACE in the list
+ //- is queried.
+ //-
+ //- If the input pointer values of unit_normal, curvature1 and
+ //- curvature2
+ //- are non-NULL, the normal and principal curvatures, too, are
+ //- returned. These are computed at closest_location, not at the
+ //- input location.
+ //-
+ //- NOTE:
+ //- It is assumed that if the calling code needs the normal or the
+ //- principal curvatures, it will *allocate* space for the CubitVectors
+ //- before sending in the pointers.
+
+ virtual CubitStatus principal_curvatures(
+ CubitVector const& location,
+ double& curvature_1,
+ double& curvature_2,
+ CubitVector* closest_location = NULL );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I location
+ //I- The point at which the curvatures are being requested -- it is also
+ //I- the point to which the closest point on the surface is returned.
+ //I- curvatures.
+ //O closest_location
+ //O- The point on the surface, closest to the input location (this
+ //O- might not be on the surface). This is input as a reference
+ //O- so that the function can modify its contents.
+ //O curvature_1/2
+ //O- Returned principal curvature magnitudes.
+ //- This functions computes the point on the surface that is closest
+ //- to the input location and then calculates the magnitudes of the
+ //- principal curvatures at this (possibly, new) point on the surface.
+
+ virtual CubitVector position_from_u_v (double u, double v);
+ //R CubitVector
+ //R- Returned position vector.
+ //I u, v
+ //I- Input point in {u.v} space
+ //- This function returns the coordinates in world space of a point
+ //- in the parameter space of this Surface object.
+
+ virtual CubitStatus u_v_from_position (CubitVector const& location,
+ double& u,
+ double& v,
+ CubitVector*
+ closest_location = NULL );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/FAILURE
+ //I location
+ //I- The input point in global space
+ //O closest_point
+ //O- The point on the Surface closest to the input location
+ //O u, v
+ //O- The returned u, v coordinate values (in local parametric space)
+ //O- of the closest_point
+ //I refvolume_ptr
+ //- This function returns the {u, v} coordinates of the point
+ //- on the Surface closest to the input point (specified in global
+ //- space). The closest_location is also returned.
+
+ virtual CubitBoolean is_periodic();
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //- This function determines whether the underlying geometry of the
+ //- OCCSurface is periodic or not. Returns CUBIT_TRUE if it is and
+ //- CUBIT_FALSE if it is not.
+ //- MJP NOTE:
+ //- The first Facet FACE in the list is queried. It is assumed
+ //- that all the FACEs have the same underlying surface.
+
+ virtual CubitBoolean is_periodic_in_U( double& period );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O period
+ //O- The value of the period in the U direction.
+ //- Determines whether the Facet surface object associated
+ //- with one of the FACEs of this OCCSurface object is
+ //- periodic in the U direction or not. If it is, it
+ //- returns CUBIT_TRUE and the value of the period. Otherwise,
+ //- it returns CUBIT_FALSE and a value of 0.0 or the period.
+ //- MJP NOTE:
+ //- The first Facet FACE in the list is queried. It is assumed
+ //- that all the FACEs have the same underlying surface.
+
+ virtual CubitBoolean is_periodic_in_V( double& period );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O period
+ //O- The value of the period in the V direction.
+ //- Determines whether the Facet surface object associated
+ //- with one of the FACEs of this OCCSurface object is
+ //- periodic in the V direction or not. If it is, it
+ //- returns CUBIT_TRUE and the value of the period. Otherwise,
+ //- it returns CUBIT_FALSE and a value of 0.0 or the period.
+ //- MJP NOTE:
+ //- The first Facet FACE in the list is queried. It is assumed
+ //- that all the FACEs have the same underlying surface.
+
+ virtual CubitBoolean is_singular_in_U( double u_param );
+ virtual CubitBoolean is_singular_in_V( double v_param );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //I double u/v parameter value.
+ //- Determines if the surface is singular in a given direction
+ //- at a given parameter value.
+
+ virtual CubitBoolean is_closed_in_U();
+ virtual CubitBoolean is_closed_in_V();
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //- Determines if the surface is closed, smoothly or not in the
+ //- given parameter direction.
+ //- A periodic surface is always closed but a closed surface is
+ //- is not always periodic.
+
+ virtual CubitStatus uv_derivitives( double u_param,
+ double v_param,
+ CubitVector &du,
+ CubitVector &dv );
+ //R CubitStatus
+ //R- CUBIT_SUCCESS/CUBIT_FAILURE
+ //O- du, dv
+ //- Determines the u and v derivitives from the given parameter
+ //- values.
+
+ virtual CubitBoolean is_parametric();
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //- This method returns CUBIT_TRUE if a parametric representation
+ //- is available for the surface
+
+ virtual CubitBoolean get_param_range_U( double& lower_bound,
+ double& upper_bound );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O lower_bound
+ //O- The lower bound of the parametric range in the U direction.
+ //O- This is set to 0.0 if the surface is not parametric.
+ //O upper_bound
+ //O- The upper bound of the parametric range in the U direction.
+ //O- This is set to 0.0 if the surface is not parametric.
+ //- Returns the lower and upper parametric bounds of the
+ //- surface in U, if it is parametric. Otherwise, it returns
+ //- CUBIT_FALSE and zeroes for the upper and lower parametric
+ //- bounds.
+ //- MJP NOTE:
+ //- The first Facet FACE in the list is queried. It is assumed
+ //- that all the FACEs have the same underlying surface.
+
+ virtual CubitBoolean get_param_range_V( double& lower_bound,
+ double& upper_bound );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //O lower_bound
+ //O- The lower bound of the parametric range in the V direction.
+ //O- This is set to 0.0 if the surface is not parametric.
+ //O upper_bound
+ //O- The upper bound of the parametric range in the V direction.
+ //O- This is set to 0.0 if the surface is not parametric.
+ //- Returns the lower and upper parametric bounds of the
+ //- surface in V, if it is parametric. Otherwise, it returns
+ //- CUBIT_FALSE and zeroes for the upper and lower parametric
+ //- bounds.
+ //- MJP NOTE:
+ //- The first Facet FACE in the list is queried. It is assumed
+ //- that all the FACEs have the same underlying surface.
+
+ virtual CubitBoolean is_position_on( CubitVector &test_position );
+ //R CubitBoolean
+ //R- CUBIT_TRUE/CUBIT_FALSE
+ //I CubitVector
+ //I- position, point where we want to test, whether or not it
+ //- is on the surface.
+
+ virtual CubitPointContainment point_containment( const CubitVector &point );
+ virtual CubitPointContainment point_containment( double u, double v );
+
+ //// In SurfaceACIS, commented out here!!
+// virtual CubitPointContainment point_containment( const CubitVector &point,
+// double u, double v );
+ //R CubitPointContainment - is the point outside, inside or on the boundary?
+ //R- CUBIT_PNT_OUTSIDE, CUBIT_PNT_INSIDE, CUBIT_PNT_BOUNDARY,
+ // CUBIT_PNT_UNKNOWN
+ //I CubitVector
+ //I- position to check, known to be on the Surface
+ //I double
+ //I- u coordinate, if known (significantly faster, if this is known - however
+ // if not known let the function figure it out)
+ //I double
+ //I- v coordinate, if known (significantly faster, if this is known - however
+ // if not known let the function figure it out)
+ // NOTE: POINT MUST LIE ON THE SURFACE FOR THIS FUNCTION TO WORK PROPERLY.
+
+ GeometryType geometry_type();
+ //R GeometryType (enum)
+ //R- The enumerated type of the geometric representation
+
+ virtual double measure();
+ //R double
+ //R- The numeric value of the measure (its units depend on the dimension
+ //R- of the RefEntity being "measured")
+ //- A generic geometric extent function.
+ //- Returns volume for Lump, area for Surface, length for Curve and
+ //- 1.0 for Point
+
+ //// void update_measurement();
+ //// //Make sure we don't retain an out-dated measurement.
+
+ virtual CubitSense get_geometry_sense();
+ //- Return the relative surface sense. (see below)
+
+ virtual void reverse_sense();
+ //- Switch the sense of this Surface wrt the RefFace that owns it:
+ //- For Facet, this means switch the sense of the RefFace that
+ //- owns this Surface with respect to the positive sense of the
+ //- first FACE in FACEPtrList_.
+
+ CubitStatus save_attribs( FILE* file_ptr );
+ // Write FactAttribs out to file
+
+ CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
+ // Read FactAttribs from file
+
+ void get_bodies ( DLIList<OCCBody *>& bodies );
+ void get_lumps ( DLIList<OCCLump *>& lumps );
+ void get_shells ( DLIList<OCCShell *>& shells );
+#ifdef BOYD14
+ void get_surfaces( DLIList<OCCSurface*>& surfaces );
+#endif
+ void get_loops ( DLIList<OCCLoop *>& loops );
+ void get_coedges ( DLIList<OCCCoEdge *>& coedges );
+ void get_curves ( DLIList<OCCCurve *>& curves );
+#ifdef BOYD14
+ void get_points ( DLIList<OCCPoint *>& points );
+#endif
+
+ void get_parents_virt( DLIList<TopologyBridge*>& parents );
+ void get_children_virt( DLIList<TopologyBridge*>& children );
+
+ //// CubitStatus get_my_facets(DLIList<CubitFacet*>& facet_list,
+ //// DLIList<CubitPoint*>& point_list);
+ //// //- Gets the list of facets describing this surface.
+ //// void tris(DLIList<CubitFacet*> &facet_list);
+ //// void get_my_points(DLIList<CubitPoint*>& point_list);
+ //// //- Gets the list of points describing this surface.
+ //// void get_my_facetedges(DLIList<CubitFacetEdge*>& edge_list);
+ //// //- Gets the list of points describing this surface.
+ //// FacetEvalTool *get_eval_tool()
+ //// { return facetEvalTool; }
+ //// const FacetEvalTool *get_eval_tool() const
+ //// { return facetEvalTool; }
+ //// //- return the facet evaluation tool for this surface
+
+ CubitSense get_shell_sense( ShellSM *facet_shell ) const;
+ // return the sense with respect to the given shell
+
+ void get_shell_sense( CubitSense &sense0 );
+ // return senses
+
+ void set_shell_sense( OCCShell *facet_shell,
+ CubitSense thesense );
+ // set the sense of the surface with respect to the shell
+
+ //// CubitStatus copy_facets(DLIList<CubitFacet*>©_facet_list,
+ //// DLIList<CubitPoint*>©_point_list);
+ //// // create a copy of the points and facets
+
+ //// int interp_order();
+ //// double min_dot();
+
+ CubitBoolean is_flat(); //// Not in SurfaceACIS
+ CubitBoolean is_spherical(); //// Not in SurfaceACIS
+ CubitBoolean is_conical(); //// Not in SurfaceACIS
+
+ //// const CubitEvaluatorData *evaluator_data();
+ //// void add_transformation( CubitTransformMatrix &tfmat );
+
+protected:
+
+private:
+ //CubitSense sense_;
+ //- The sense of the RefFace that owns this Surface with respect
+ //- to the positive sense of the first FACE in FACEPtrList_.
+ //- When a Surface is first constructed, this value is arbitrarily
+ //- set to CUBIT_FORWARD.
+ //- In the case of Surfaces, the normal is used in determining
+ //- the relative sense value.
+ //- MJP NOTE:
+ //- Not only does the RefFace have a sense wrt its Surface, but each
+ //- Facet FACE has a sense wrt its underlying "surface" object.
+
+ //sjowen FacetEvalTool *facetEvalTool;
+ //// FacetEvalTool *facetEvalTool;
+ //For topology traversals we need to have connections to the
+ //entitities connected to this surface. From these we can get the rest.
+
+ DLIList<LoopSM*> myLoops;
+ DLIList<ShellSM*> myShells;
+
+ OCCAttribSet attribSet;
+ //List of OCCAttrib*'s instead of CubitSimpleAttribs
+
+ // the sense of the surface with respect to the shells in the myShells list
+ CubitSense myShellSense;
+
+ CubitEvaluator *myEvaluator;
+
+ TopoDS_Face *myTopoDSFace;
+
+};
+
+
+// ********** BEGIN INLINE FUNCTIONS **********
+// ********** END INLINE FUNCTIONS **********
+
+// ********** BEGIN FRIEND FUNCTIONS **********
+// ********** END FRIEND FUNCTIONS **********
+
+// ********** BEGIN EXTERN FUNCTIONS **********
+// ********** END EXTERN FUNCTIONS **********
+
+#endif
+
Property changes on: cgm/trunk/geom/OCC/OCCSurface.hpp
___________________________________________________________________
Name: svn:executable
+ *
More information about the cgma-dev
mailing list