Author: janehu Date: 2008-03-03 13:17:06 -0600 (Mon, 03 Mar 2008) New Revision: 1632 Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp cgm/trunk/geom/OCC/OCCQueryEngine.cpp Log: fixed 2 places where the made combo-body can't be deleted; added make primitive of sphere and box. Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp =================================================================== --- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-03 18:10:57 UTC (rev 1631) +++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-03 19:17:06 UTC (rev 1632) @@ -49,6 +49,8 @@ #include "TopoDS.hxx" #include "TopologyBridge.hpp" #include "BRepAlgoAPI_Fuse.hxx" +#include "BRepPrimAPI_MakeSphere.hxx" +#include "BRepPrimAPI_MakeBox.hxx" #include "Handle_Geom_TrimmedCurve.hxx" #include "Handle_Geom_RectangularTrimmedSurface.hxx" #include "TopExp_Explorer.hxx" @@ -1068,41 +1070,73 @@ // Function : sphere // Member Type: PUBLIC // Description: build an OCC sphere -// Author : John Fowler -// Date : 10/02 +// Author : Jane Hu +// Date : 03/08 //=============================================================================== BodySM* OCCModifyEngine::sphere(double radius) const { - return (BodySM*) NULL; + if (radius <= 0) + return (BodySM*) NULL; + + TopoDS_Solid S = BRepPrimAPI_MakeSphere(radius); + + Lump* lump = OCCQueryEngine::instance()->populate_topology_bridge(S, + CUBIT_TRUE); + if (lump == NULL) + return (BodySM*)NULL; + + return CAST_TO(lump, OCCLump)->body(); } //=============================================================================== // Function : brick // Member Type: PUBLIC -// Description: build a brick with facets -// Author : John Fowler -// Date : 10/02 +// Description: build an OCC brick +// Author : Jane Hu +// Date : 03/08 //=============================================================================== BodySM* OCCModifyEngine::brick( double wid, double dep, double hi ) const { - return (BodySM*)NULL; + if (wid <= 0 || dep <=0 || hi <= 0) + return (BodySM*)NULL; + + TopoDS_Solid S = BRepPrimAPI_MakeBox(wid, dep, hi); + + Lump* lump = OCCQueryEngine::instance()->populate_topology_bridge(S, + CUBIT_TRUE); + + if (lump == NULL) + return (BodySM*)NULL; + + return CAST_TO(lump, OCCLump)->body(); } //=============================================================================== // Function : brick // Member Type: PUBLIC -// Description: create a brick with facets given center axes and extension -// Author : John Fowler -// Date : 10/02 +// Description: create an OCC brick given center axes and extension +// Author : Jane Hu +// Date : 03/08 //=============================================================================== -BodySM* OCCModifyEngine::brick( const CubitVector &/*center*/, - const CubitVector* /*axes[3]*/, - const CubitVector &/*extension*/) const +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; + CubitVector left_corner = center - 0.5 * extension; + gp_Pnt left_point(left_corner.x(), left_corner.y(), left_corner.z()); + gp_Dir main_dir(axes[2].x(), axes[2].y(), axes[2].z()); + gp_Ax2 Axis(left_point, main_dir); + TopoDS_Solid S = BRepPrimAPI_MakeBox( Axis, extension.x(), extension.y(), + extension.z()); + + Lump* lump = OCCQueryEngine::instance()->populate_topology_bridge(S, + CUBIT_TRUE); + if (lump == NULL) + return (BodySM*)NULL; + + return CAST_TO(lump, OCCLump)->body(); } //=============================================================================== Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp =================================================================== --- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-03 18:10:57 UTC (rev 1631) +++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-03 19:17:06 UTC (rev 1632) @@ -1423,9 +1423,10 @@ return delete_solid_model_entities(occ_surface); } - for(int i =0; i < occ_body->lumps().size(); i++) + DLIList<Lump*> lumps = occ_body->lumps(); + for(int i =0; i < lumps.size(); i++) { - Lump* lump = occ_body->lumps().get_and_step(); + Lump* lump = lumps.get_and_step(); OCCLump* occ_lump = CAST_TO(lump, OCCLump); if (occ_lump) occ_lump->remove_body(); @@ -1462,7 +1463,8 @@ if(!OccToCGM->erase(k)) PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!"); } - occ_body->lumps().clean_out(); + DLIList<Lump*> lumps; + occ_body->lumps(lumps); if (occ_body_find) BodyList->remove(occ_body_find); else
participants (1)
-
janehu@mcs.anl.gov