r1640 - in cgm/trunk: geom/OCC test
Author: janehu Date: 2008-03-10 13:08:33 -0500 (Mon, 10 Mar 2008) New Revision: 1640 Added: cgm/trunk/test/modify.cpp Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp cgm/trunk/test/Makefile.am Log: Fine tuned stitch_surfs; Added test case for it. Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp =================================================================== --- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-07 19:56:28 UTC (rev 1639) +++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-10 18:08:33 UTC (rev 1640) @@ -1453,20 +1453,13 @@ TopoDS_Face* second_face = NULL; TopoDS_Face* new_face = NULL ; CubitBoolean disconnected = CUBIT_FALSE; - DLIList<TopoDS_Face*>disconnected_faces; TopoDS_Shape fusion; int count = 0; for(int i = 0; i < faces_to_stitch.size(); i++) { - if (count > 0 && disconnected) - { - first_face = faces_to_stitch[i]; - disconnected = CUBIT_FALSE; - } - else if (count > 0 && disconnected == CUBIT_FALSE) - { + if (count > 0) first_face = new_face; - } + for(int j = i + 1; j < faces_to_stitch.size(); j++) { second_face = faces_to_stitch[j]; @@ -1489,35 +1482,28 @@ delete new_face; new_face = new TopoDS_Face(TopoDS::Face(fusion)); faces_to_stitch.remove(second_face); + disconnected = CUBIT_FALSE; i--; count++; break; } if (disconnected) { - //save the first_face for building the body - disconnected_faces.append(first_face); + //Can't make a body out of disconnected faces + PRINT_ERROR("Can't create one BodySM out of disconnected surfaces. \n"); + if(new_face != NULL) + delete new_face; + return CUBIT_FAILURE; } } - if (disconnected) //last one - disconnected_faces.append(second_face); - if(disconnected_faces.size() == 0) - { - Surface* surface = OCCQueryEngine::instance()-> - populate_topology_bridge(*new_face, CUBIT_TRUE); + Surface* surface = OCCQueryEngine::instance()-> + populate_topology_bridge(*new_face, CUBIT_TRUE); - stitched_body = CAST_TO(surface, OCCSurface)->my_body(); - //delete all original surfaces - OCCQueryEngine::instance()->delete_solid_model_entities(surf_bodies); - return CUBIT_SUCCESS; - } - - //Can't make a body out of disconnected faces - PRINT_ERROR("Can't create one BodySM out of disconnected surfaces. \n"); - if(new_face != NULL) - delete new_face; - return CUBIT_FAILURE; + stitched_body = CAST_TO(surface, OCCSurface)->my_body(); + //delete all original surfaces + OCCQueryEngine::instance()->delete_solid_model_entities(surf_bodies); + return CUBIT_SUCCESS; } //=============================================================================== Modified: cgm/trunk/test/Makefile.am =================================================================== --- cgm/trunk/test/Makefile.am 2008-03-07 19:56:28 UTC (rev 1639) +++ cgm/trunk/test/Makefile.am 2008-03-10 18:08:33 UTC (rev 1640) @@ -16,7 +16,7 @@ TESTS += webcut endif if WITH_OCC - TESTS += makept + TESTS += modify makept endif CPPFLAGS += -DSRCDIR=@srcdir@ @@ -24,6 +24,7 @@ webcut_SOURCES = webcut.cpp makept_SOURCES = makept.cpp +modify_SOURCES = modify.cpp LDADD = ../geom/virtual/libcubit_virtual.la \ ../geom/facetbool/libcubit_facetbool.la \ ../geom/Cholla/libcholla.la \ Added: cgm/trunk/test/modify.cpp =================================================================== --- cgm/trunk/test/modify.cpp (rev 0) +++ cgm/trunk/test/modify.cpp 2008-03-10 18:08:33 UTC (rev 1640) @@ -0,0 +1,159 @@ +/** + * \file makept.cpp + * + * \brief makept, another simple C++ driver for CGM + * + * This program acts as a simple driver for CGM. It reads in a geometry, + * and performs varies checks for bodies, surfaces, curves and vertices. + */ +#include "config.h" +#include "CpuTimer.hpp" +#include "GeometryModifyTool.hpp" +#include "GeometryQueryTool.hpp" +#include "OCCQueryEngine.hpp" +#include "CubitUtil.hpp" +#include "CubitMessage.hpp" +#include "CubitDefines.h" +#include "RefEntity.hpp" +#include "Body.hpp" +#include "RefVolume.hpp" +#include "RefFace.hpp" +#include "RefEdge.hpp" +#include "RefVertex.hpp" +#include "CubitObserver.hpp" +#include "CastTo.hpp" +#include "OCCModifyEngine.hpp" +#include "AppUtil.hpp" +#include "RefEntityFactory.hpp" +#include "RefEdge.hpp" +#include "BodySM.hpp" +#include "OCCBody.hpp" +#include "OCCSurface.hpp" +#include "OCCCurve.hpp" + +// forward declare some functions used and defined later +CubitStatus read_geometry(int, char **); +CubitStatus make_Point(); +// macro for printing a separator line +#define PRINT_SEPARATOR PRINT_INFO("=======================================\n"); + + +// main program - initialize, then send to proper function +int main (int argc, char **argv) +{ + + CubitObserver::init_static_observers(); + // Initialize the GeometryTool + + CGMApp::instance()->startup( argc, argv ); + OCCQueryEngine::instance(); + OCCModifyEngine::instance(); + + // If there aren't any file arguments, print usage and exit + //if (argc == 1) { + // PRINT_INFO("Usage: mergechk <geom_file> [<geom_file> ...]\n"); + // exit(0); + //} + + CubitStatus status = CUBIT_SUCCESS; + + + + //Do make point. + status = make_Point(); + if (status == CUBIT_FAILURE) + PRINT_INFO("Operation Failed"); + + int ret_val = ( CubitMessage::instance()->error_count() ); + if ( ret_val > 0 ) + { + PRINT_ERROR("Errors found during Mergechk session.\n"); + } + return ret_val; + +} + +/// attribs module: list, modify attributes in a give model or models +/// +/// Arguments: file name(s) of geometry files in which to look +/// +CubitStatus read_geometry(int num_files, char **argv) +{ + CubitStatus status = CUBIT_SUCCESS; + GeometryQueryTool *gti = GeometryQueryTool::instance(); + assert(gti); + int i; + + PRINT_SEPARATOR; + + for (i = 0; i < num_files; i++) { + status = gti->import_solid_model(argv[i], "OCC"); + if (status != CUBIT_SUCCESS) { + PRINT_ERROR("Problems reading geometry file %s.\n", argv[i]); + } + } + PRINT_SEPARATOR; + + return CUBIT_SUCCESS; +} + +CubitStatus make_Point() +{ + GeometryQueryTool *gti = GeometryQueryTool::instance(); + GeometryModifyTool *gmti = GeometryModifyTool::instance(); + + OCCQueryEngine::instance(); + OCCModifyEngine::instance(); + + Body* body = gmti->brick(10, 10, 10); + BodySM* bodysm = body->get_body_sm_ptr(); + DLIList<OCCSurface*> surfaces; + CAST_TO(bodysm, OCCBody)->get_all_surfaces(surfaces); + DLIList<RefFace*> ref_faces; + body->ref_faces(ref_faces); + + + DLIList<RefFace*> faces_to_stitch; + for(int i = 0 ; i < ref_faces.size(); i++) + { + RefFace* refface = gmti->make_RefFace(ref_faces.get_and_step()); + if(refface) + faces_to_stitch.append(refface); + } + + DLIList<BodySM*> bodysm_list; + for(int i = 0; i < faces_to_stitch.size(); i++) + { + //move each refface by (15,0,0) + RefFace* refface = faces_to_stitch.get_and_step(); + Body* body = refface->ref_volume()->get_body_ptr(); + BodySM* bodysm = body->get_body_sm_ptr(); + bodysm_list.append(bodysm); + CubitVector v(15,0,0); + gti->translate(body, v); + } + + //stitch surfaces together + GeometryModifyEngine *gme = gmti->get_engine(surfaces.get()); + BodySM* stitched_body = NULL; + CubitStatus stat = gme->stitch_surfs(bodysm_list, stitched_body); + Body* body2; + if (stat) + body2 = gti->make_Body(stitched_body); + + CubitVector v = body2->center_point(); + + DLIList<Body*> bodies; + DLIList<RefEntity*> free_entities; + gti->bodies(bodies); + gti->get_free_ref_entities(free_entities); + //delete all entities + gti->delete_Body(bodies); + + for (int j = free_entities.size(); j--;) + { + gti->delete_RefEntity( free_entities.get_and_step()); + } + + return stat; +}
participants (1)
-
janehu@mcs.anl.gov