topods - Face Aface Topods::Face (Faceexp - Current ) : "Line"
topods - Face Aface Topods::Face (Faceexp - Current ) : "Line"
topods - Face Aface Topods::Face (Faceexp - Current ) : "Line"
IsNull()) return; TopoDS_Shape transShape1 = aShape1->Shape(); TopExp_Explorer faceExp(transShape1, TopAbs_FACE); TopoDS_Shape sewed ; //TopoDS_Face aFace = TopoDS::Face(faceExp.Current()); try{ for (faceExp.Init(transShape1, TopAbs_FACE); faceExp.More(); faceExp.Next()) { TopoDS_Face aFace = TopoDS::Face(faceExp.Current()); TopoDS_Face aFacePrev; TopExp_Explorer edgeExp(aFace,TopAbs_EDGE); TopoDS_Edge aEdge = TopoDS::Edge(edgeExp.Current()); curveCheck=false; for(;edgeExp.More();edgeExp.Next()) { if(!curveCheck) { BRepAdaptor_Curve bac(aEdge); GeomAbs_CurveType theCurveType = bac.GetType(); switch(theCurveType) { case GeomAbs_Line: cout<<"Line"; break; case 1: cout<<"Circle"; case 2: cout<<"Ellipse"; case 3: cout<<"Hyperbola"; case 4: cout<<"Circle"; case 5: cout<<"Circle"; case 6: cout<<"Circle"; case 7: cout<<"Circle"; default: cout<<"other";
} if ( theCurveType == GeomAbs_BSplineCurve) { curveCheck = true; break; } } } if(!curveCheck) SEW.Add(aFace); else break; aFacePrev = aFace; } SEW.Perform(); sewed = SEW.SewedShape(); //SEW.Dump(); TopoDS_Shape cutShape = BRepAlgoAPI_Cut(transShape1,sewed); Handle(AIS_Shape) AISShape; AISShape = new AIS_Shape(sewed); myAISContext->SetDisplayMode(AISShape,1,Standard_False); myAISContext->Display(AISShape, Standard_False); myAISContext->Erase(aShape1); //if(sewed.ShapeType() == TopAbs_SHELL) //{ // TopAbs_ShapeEnum shapeEnum = sewed.ShapeType(); // TopoDS_Compound occCompoundS; // BRep_Builder occBuilder; // occBuilder.MakeCompound(occCompoundS); // TopExp_Explorer exp; // exp.Init(sewed, TopAbs_SHELL); // for( ; exp.More(); exp.Next()) // { try { TopoDS_Shell shell = TopoDS::Shell(exp.Current()); // // // // ShapeFix_Solid solid; TopoDS_Shape tmpS = solid.SolidFromShell(shell); occBuilder.Add(occCompoundS, tmpS); //TopoDS_Shape cut = BRepAlgoAPI_Cut();
// // //
// Handle(AIS_Shape) AISShape; // AISShape = new AIS_Shape(occCompoundS); // myAISContext>SetDisplayMode(AISShape,1,Standard_False); // myAISContext->Display(AISShape, Standard_False); // myAISContext->Erase(aShape1); // // } // catch (...){}
// } //} } catch(...) { } } else return; myAISContext->UpdateCurrentViewer(); } TopoDS_Shape EXTRUDEDSHAPE; void OCCViewer::Extrusion(void) { if(!myAISContext.IsNull()) { try{ for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected()) { Handle( AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(myAISContext>Current()); Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(myAISContext>Current()); TopoDS_Shape transShape = aShape->Shape(); TopoDS_Face aFace; aFace=TopoDS::Face(transShape); TopExp_Explorer ex; TopoDS_Wire aWire ; for(ex.Init(aFace,TopAbs_WIRE);ex.More();ex.Next()) { aWire = TopoDS::Wire(ex.Current()); break; } TopoDS_Face profile = BRepBuilderAPI_MakeFace(aWire, Standard_True); BRepAdaptor_Surface aSurface(aFace); Standard_Real u1,u2,v1,v2; u1 = aSurface.FirstUParameter(); u2 = aSurface.LastUParameter(); v1 = aSurface.FirstVParameter(); v2 = aSurface.LastVParameter(); gp_Pnt aCenterOfFace; gp_Vec aVec1,aVec2,aNormalOfFace; aSurface.D1((u1+u2)/2,(v1+v2)/2,aCenterOfFace,aVec1,aVec2); aNormalOfFace = aVec1^aVec2; gp_Dir aDir= gp_Dir(aNormalOfFace); /*gp_Dir aDir1= FaceNormal(aFace);*/
GC_MakePlane omakePlane(aCenterOfFace,aDir); Handle(Geom_Plane) ogeomPlane = omakePlane.Value(); double BA = 90*(M_PI/180)*(10+(0.5*10));// Bend Allowance //double SB = 10+10;//Set Back //double BC = BA - (2*SB);// Bend Compensation double flangeLength = 100+BA; GC_MakePlane makePlane(ogeomPlane->Pln(),flangeLength); gp_Pnt fp= ogeomPlane->Location(); Handle(Geom_Plane) geomPlane = makePlane.Value(); gp_Pnt ep=geomPlane->Location(); TopoDS_Shape aPlaneShape = BRepBuilderAPI_MakeFace(geomPlane>Pln(),-200, 200, -200, 200 ); gp_Trsf theTransformation; theTransformation.SetTranslation(fp,ep); BRepBuilderAPI_Copy copy_shape; copy_shape.Perform(transShape,true); TopoDS_Face face = TopoDS::Face(copy_shape.Shape()); BRepBuilderAPI_Transform myBRepTransformation(face,theTransformation,true); TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); Handle(Geom_TrimmedCurve) segment = GC_MakeSegment(fp , ep); TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(segment); TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge); BRepOffsetAPI_MakePipe pipeShell(wire,profile); pipeShell.Build(); TopoDS_Shape resultShape = pipeShell.Shape(); EXTRUDEDSHAPE=resultShape; Handle(AIS_Shape) AISShape; AISShape = new AIS_Shape(resultShape); myAISContext->SetDisplayMode(AISShape,1,Standard_False); myAISContext->Display(AISShape, Standard_False); } } catch(...){} } } void OCCViewer::convertToFace(void) { if(!myAISContext.IsNull()) { try{ for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected()) {
Handle( AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(myAISContext>Current()); Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(myAISContext>Current()); TopoDS_Shape transShape = aShape->Shape(); TopoDS_Face aFace; TopExp_Explorer faceExp(transShape, TopAbs_FACE); TopExp_Explorer exWire; TopoDS_Wire aWire ; Handle(AIS_Shape) AISShape; for (faceExp.Init(transShape, TopAbs_FACE); faceExp.More(); faceExp.Next()) { aFace = TopoDS::Face(faceExp.Current()); for(exWire.Init(transShape,TopAbs_WIRE);exWire.More();exWire.Next()) { TopExp_Explorer edgeExp(aFace,TopAbs_WIRE); aWire = TopoDS::Wire(exWire.Current()); } AISShape = new AIS_Shape(aFace); myAISContext->SetDisplayMode(AISShape,1,Standard_False); myAISContext->Display(AISShape, Standard_False); myAISContext->Erase(aShape); } } } catch(...){} } } gp_Dir OCCViewer::FaceNormal(const TopoDS_Face &face) { // get bounds of face Standard_Real umin, umax, vmin, vmax; BRepTools::UVBounds(face, umin, umax, vmin, vmax); // create surface Handle(Geom_Surface) surf=BRep_Tool::Surface(face); // get surface properties GeomLProp_SLProps props(surf, umin, vmin, 1, 0.01); // get surface normal gp_Dir norm=props.Normal(); // check orientation if(face.Orientation()==TopAbs_REVERSED) norm.Reverse(); else if(face.Orientation()==TopAbs_FORWARD) norm.Reverse(); else if(face.Orientation()==TopAbs_INTERNAL) norm.Reverse(); else if(face.Orientation()==TopAbs_EXTERNAL) norm.Reverse(); return norm; }