//---------------------------------------------------------------- // Function: to update the core Surface // for any movement or Boolean operation of the body. // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf, BRepAlgoAPI_BooleanOperation *op) { assert(aBRepTrsf != NULL || op != NULL); TopoDS_Shape shape; if (aBRepTrsf) shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face()); else { TopTools_ListOfShape shapes; shapes.Assign(op->Modified(*get_TopoDS_Face())); if(shapes.Extent() == 0) shapes.Assign(op->Generated(*get_TopoDS_Face())); if (shapes.Extent() == 1) shape = shapes.First(); else if(shapes.Extent() > 1) { //update all attributes first. TopTools_ListIteratorOfListOfShape it; it.Initialize(shapes); for(; it.More(); it.Next()) { shape = it.Value(); OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Face(), shape); } shape = shapes.First(); } else if(op->IsDeleted(*get_TopoDS_Face())) ; else return CUBIT_SUCCESS; } TopoDS_Face surface; if(!shape.IsNull()) surface = TopoDS::Face(shape); if (aBRepTrsf) { //set the loops DLIList<OCCLoop *> loops; this->get_loops(loops); for (int i = 1; i <= loops.size(); i++) { OCCLoop *loop = loops.get_and_step(); loop->update_OCC_entity(aBRepTrsf, op); } OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface); } else if(op) update_OCC_entity(*myTopoDSFace, surface, op); return CUBIT_SUCCESS; }
//---------------------------------------------------------------- // Function: transform // Description: transform the body and its child entities // use a transform matrix // // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCBody::transform(BRepBuilderAPI_Transform& aBRepTrsf) { TopoDS_Shape * shape; get_TopoDS_Shape(shape); aBRepTrsf.Perform(*shape); update_OCC_entity(&aBRepTrsf); // calculate for bounding box update_bounding_box(); return CUBIT_SUCCESS; }
//---------------------------------------------------------------- // Function: scale // Description: deforming transformation of the body and its child entities // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCBody::scale(double scale_factor_x, double scale_factor_y, double scale_factor_z ) { gp_GTrsf gTrsf; gTrsf.SetValue(1,1, scale_factor_x); gTrsf.SetValue(2,2, scale_factor_y); gTrsf.SetValue(3,3, scale_factor_z); BRepBuilderAPI_GTransform gBRepTrsf(gTrsf); TopoDS_Shape * shape; get_TopoDS_Shape(shape); gBRepTrsf.Perform(*shape); update_OCC_entity(&gBRepTrsf); // calculate for bounding box update_bounding_box(); return CUBIT_SUCCESS; }