3 #include "GEOMImpl_SphereDriver.hxx"
4 #include "GEOMImpl_ISphere.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepPrimAPI_MakeSphere.hxx>
9 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
16 //=======================================================================
19 //=======================================================================
20 const Standard_GUID& GEOMImpl_SphereDriver::GetID()
22 static Standard_GUID aSphereDriver("FF1BBB16-5D14-4df2-980B-3A668264EA16");
27 //=======================================================================
28 //function : GEOMImpl_SphereDriver
30 //=======================================================================
31 GEOMImpl_SphereDriver::GEOMImpl_SphereDriver()
35 //=======================================================================
38 //=======================================================================
39 Standard_Integer GEOMImpl_SphereDriver::Execute(TFunction_Logbook& log) const
41 if (Label().IsNull()) return 0;
42 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
44 GEOMImpl_ISphere aCI (aFunction);
45 Standard_Integer aType = aFunction->GetType();
49 if (aType == SPHERE_R) {
50 aShape = BRepPrimAPI_MakeSphere(aCI.GetR()).Shape();
52 else if (aType == SPHERE_PNT_R) {
53 Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
54 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
55 if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
56 gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
57 aShape = BRepPrimAPI_MakeSphere(aP, aCI.GetR()).Shape();
63 if (aShape.IsNull()) return 0;
65 aFunction->SetValue(aShape);
67 log.SetTouched(Label());
73 //=======================================================================
74 //function : GEOMImpl_SphereDriver_Type_
76 //=======================================================================
77 Standard_EXPORT Handle_Standard_Type& GEOMImpl_SphereDriver_Type_()
80 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
81 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
82 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
83 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
84 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
85 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
88 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
89 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_SphereDriver",
90 sizeof(GEOMImpl_SphereDriver),
92 (Standard_Address)_Ancestors,
93 (Standard_Address)NULL);
98 //=======================================================================
101 //=======================================================================
102 const Handle(GEOMImpl_SphereDriver) Handle(GEOMImpl_SphereDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
104 Handle(GEOMImpl_SphereDriver) _anOtherObject;
106 if (!AnObject.IsNull()) {
107 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_SphereDriver))) {
108 _anOtherObject = Handle(GEOMImpl_SphereDriver)((Handle(GEOMImpl_SphereDriver)&)AnObject);
112 return _anOtherObject ;