3 #include "GEOMImpl_BoxDriver.hxx"
4 #include "GEOMImpl_IBox.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepPrimAPI_MakeBox.hxx>
9 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
16 #include <StdFail_NotDone.hxx>
18 //=======================================================================
21 //=======================================================================
22 const Standard_GUID& GEOMImpl_BoxDriver::GetID()
24 static Standard_GUID aBoxDriver("FF1BBB13-5D14-4df2-980B-3A668264EA16");
29 //=======================================================================
30 //function : GEOMImpl_BoxDriver
32 //=======================================================================
33 GEOMImpl_BoxDriver::GEOMImpl_BoxDriver()
37 //=======================================================================
40 //=======================================================================
41 Standard_Integer GEOMImpl_BoxDriver::Execute(TFunction_Logbook& log) const
43 if (Label().IsNull()) return 0;
44 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
46 GEOMImpl_IBox aBI (aFunction);
47 Standard_Integer aType = aFunction->GetType();
51 if (aType == BOX_DX_DY_DZ) {
52 BRepPrimAPI_MakeBox MB (aBI.GetDX(), aBI.GetDY(), aBI.GetDZ());
56 StdFail_NotDone::Raise("Box with the given dimensions can not be computed");
60 else if (aType == BOX_TWO_PNT) {
61 Handle(GEOM_Function) aRefPoint1 = aBI.GetRef1();
62 Handle(GEOM_Function) aRefPoint2 = aBI.GetRef2();
63 TopoDS_Shape aShape1 = aRefPoint1->GetValue();
64 TopoDS_Shape aShape2 = aRefPoint2->GetValue();
65 if (aShape1.ShapeType() == TopAbs_VERTEX &&
66 aShape2.ShapeType() == TopAbs_VERTEX) {
67 gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1));
68 gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2));
69 BRepPrimAPI_MakeBox MB (P1,P2);
73 StdFail_NotDone::Raise("Box can not be computed from the given point");
81 if (aShape.IsNull()) return 0;
83 aFunction->SetValue(aShape);
85 log.SetTouched(Label());
91 //=======================================================================
92 //function : GEOMImpl_BoxDriver_Type_
94 //=======================================================================
95 Standard_EXPORT Handle_Standard_Type& GEOMImpl_BoxDriver_Type_()
98 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
99 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
100 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
101 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
102 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
103 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
106 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
107 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_BoxDriver",
108 sizeof(GEOMImpl_BoxDriver),
110 (Standard_Address)_Ancestors,
111 (Standard_Address)NULL);
116 //=======================================================================
117 //function : DownCast
119 //=======================================================================
120 const Handle(GEOMImpl_BoxDriver) Handle(GEOMImpl_BoxDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
122 Handle(GEOMImpl_BoxDriver) _anOtherObject;
124 if (!AnObject.IsNull()) {
125 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BoxDriver))) {
126 _anOtherObject = Handle(GEOMImpl_BoxDriver)((Handle(GEOMImpl_BoxDriver)&)AnObject);
130 return _anOtherObject ;