void ImpExpDxfRead::AddGraphics() const { if (optionGroupLayers) { for(std::map<std::string,std::vector<Part::TopoShape*> > ::const_iterator i = layers.begin(); i != layers.end(); ++i) { BRep_Builder builder; TopoDS_Compound comp; builder.MakeCompound(comp); std::string k = i->first; if (k == "0") // FreeCAD doesn't like an object name being '0'... k = "LAYER_0"; std::vector<Part::TopoShape*> v = i->second; if(k.substr(0, 6) != "BLOCKS") { for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) { const TopoDS_Shape& sh = (*j)->getShape(); if (!sh.IsNull()) builder.Add(comp, sh); } if (!comp.IsNull()) { Part::Feature *pcFeature = (Part::Feature *)document->addObject("Part::Feature", k.c_str()); pcFeature->Shape.setValue(comp); } } } } }
Standard_Boolean ShHealOper_FillHoles::Fill() { ShapeAnalysis_FreeBounds sab(myInitShape); TopoDS_Compound aCompClosed = sab.GetClosedWires(); TopoDS_Compound aCompOpen = sab.GetOpenWires(); TopTools_SequenceOfShape aFillWires; if(!aCompClosed.IsNull()) { TopoDS_Iterator aIt(aCompClosed); for( ; aIt.More(); aIt.Next()) aFillWires.Append(aIt.Value()); } if(!aCompOpen.IsNull()) { TopoDS_Iterator aIt(aCompOpen); for( ; aIt.More(); aIt.Next()) aFillWires.Append(aIt.Value()); } TopExp_Explorer aExp(myInitShape,TopAbs_EDGE,TopAbs_FACE); for( ; aExp.More(); aExp.Next()) aFillWires.Append(aExp.Current()); return Fill(aFillWires); }
void DraftDxfRead::OnReadInsert(const double* point, const double* scale, const char* name, double rotation) { std::cout << "Inserting block " << name << " rotation " << rotation << " pos " << point[0] << "," << point[1] << "," << point[2] << std::endl; for(std::map<std::string,std::vector<Part::TopoShape*> > ::const_iterator i = layers.begin(); i != layers.end(); ++i) { std::string k = i->first; std::string prefix = "BLOCKS "; prefix += name; prefix += " "; if(k.substr(0, prefix.size()) == prefix) { BRep_Builder builder; TopoDS_Compound comp; builder.MakeCompound(comp); std::vector<Part::TopoShape*> v = i->second; for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) { const TopoDS_Shape& sh = (*j)->_Shape; if (!sh.IsNull()) builder.Add(comp, sh); } if (!comp.IsNull()) { Part::TopoShape* pcomp = new Part::TopoShape(comp); Base::Matrix4D mat; mat.scale(scale[0],scale[1],scale[2]); mat.rotZ(rotation); mat.move(point[0],point[1],point[2]); pcomp->transformShape(mat,true); AddObject(pcomp); } } } }
void OCCBody::set_TopoDS_Shape( TopoDS_Compound& theshape) { if(!theshape.IsNull()) assert(theshape.ShapeType() == TopAbs_COMPOUND); else { if(myTopoDSShape && !myTopoDSShape->IsNull()) myTopoDSShape->Nullify(); return; } if(myTopoDSShape && !myTopoDSShape->IsNull() && theshape.IsEqual(*myTopoDSShape)) return; if (myTopoDSShape && !myTopoDSShape->IsNull() && theshape.IsPartner(*myTopoDSShape)) { myTopoDSShape->Location(theshape.Location()); myTopoDSShape->Orientation(theshape.Orientation()); } else { if(myTopoDSShape) myTopoDSShape->Nullify(); *myTopoDSShape = theshape; } }
//---------------------------------------------------------------- // Function: private function to update the core compound and // for any movement of the body. // Note: input shape must have the same number of Compound // as the body's lumps number. // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_ModifyShape *aBRepTrsf, BRepAlgoAPI_BooleanOperation *op) { assert(aBRepTrsf != NULL || op != NULL); TopoDS_Compound compsolid; TopoDS_Shape shape; shape = aBRepTrsf->Shape(); if(aBRepTrsf && myTopoDSShape) { compsolid = TopoDS::Compound(shape); if(OCCQueryEngine::instance()->OCCMap->IsBound(*myTopoDSShape) ) OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShape, shape); else if (!shape.IsEqual(*myTopoDSShape)) set_TopoDS_Shape(compsolid); } //Boolean operation works only on one lump body //set the lumps DLIList<Lump *> lumps; lumps = this->lumps(); for (int i = 1; i <= lumps.size(); i++) { OCCLump *lump = CAST_TO(lumps.get_and_step(), OCCLump); lump->update_OCC_entity(aBRepTrsf, op); } for(int i = 0; i < mySheetSurfaces.size(); i++) { OCCSurface* surface = mySheetSurfaces.get_and_step(); surface->update_OCC_entity(aBRepTrsf, op); } for(int i = 0; i <myShells.size() ; i++) { OCCShell* occ_shell = myShells.get_and_step(); occ_shell->update_OCC_entity(aBRepTrsf,op); } if (aBRepTrsf && !compsolid.IsNull()) set_TopoDS_Shape(compsolid); update_bounding_box(); //unset marks. DLIList<OCCCurve*> curves; DLIList<OCCPoint*> points; get_all_curves(curves); get_all_points(points); for(int i = 0; i < curves.size(); i++) curves.get_and_step()->set_myMarked(CUBIT_FALSE); for(int i = 0; i < points.size(); i++) points.get_and_step()->set_myMarked(CUBIT_FALSE); return CUBIT_SUCCESS; }