2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_BoxDriver.hxx>
5 #include <GEOMImpl_IBox.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepPrimAPI_MakeBox.hxx>
10 #include <BRep_Tool.hxx>
13 #include <TopoDS_Shape.hxx>
14 #include <TopoDS_Vertex.hxx>
17 #include <StdFail_NotDone.hxx>
19 //=======================================================================
22 //=======================================================================
23 const Standard_GUID& GEOMImpl_BoxDriver::GetID()
25 static Standard_GUID aBoxDriver("FF1BBB13-5D14-4df2-980B-3A668264EA16");
30 //=======================================================================
31 //function : GEOMImpl_BoxDriver
33 //=======================================================================
34 GEOMImpl_BoxDriver::GEOMImpl_BoxDriver()
38 //=======================================================================
41 //=======================================================================
42 Standard_Integer GEOMImpl_BoxDriver::Execute(TFunction_Logbook& log) const
44 if (Label().IsNull()) return 0;
45 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
47 GEOMImpl_IBox aBI (aFunction);
48 Standard_Integer aType = aFunction->GetType();
52 if (aType == BOX_DX_DY_DZ) {
53 BRepPrimAPI_MakeBox MB (aBI.GetDX(), aBI.GetDY(), aBI.GetDZ());
57 StdFail_NotDone::Raise("Box with the given dimensions can not be computed");
61 else if (aType == BOX_TWO_PNT) {
62 Handle(GEOM_Function) aRefPoint1 = aBI.GetRef1();
63 Handle(GEOM_Function) aRefPoint2 = aBI.GetRef2();
64 TopoDS_Shape aShape1 = aRefPoint1->GetValue();
65 TopoDS_Shape aShape2 = aRefPoint2->GetValue();
66 if (aShape1.ShapeType() == TopAbs_VERTEX &&
67 aShape2.ShapeType() == TopAbs_VERTEX) {
68 gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1));
69 gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2));
70 BRepPrimAPI_MakeBox MB (P1,P2);
74 StdFail_NotDone::Raise("Box can not be computed from the given point");
82 if (aShape.IsNull()) return 0;
84 aFunction->SetValue(aShape);
86 log.SetTouched(Label());
92 //=======================================================================
93 //function : GEOMImpl_BoxDriver_Type_
95 //=======================================================================
96 Standard_EXPORT Handle_Standard_Type& GEOMImpl_BoxDriver_Type_()
99 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
100 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
101 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
102 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
103 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
104 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
107 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
108 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_BoxDriver",
109 sizeof(GEOMImpl_BoxDriver),
111 (Standard_Address)_Ancestors,
112 (Standard_Address)NULL);
117 //=======================================================================
118 //function : DownCast
120 //=======================================================================
121 const Handle(GEOMImpl_BoxDriver) Handle(GEOMImpl_BoxDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
123 Handle(GEOMImpl_BoxDriver) _anOtherObject;
125 if (!AnObject.IsNull()) {
126 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BoxDriver))) {
127 _anOtherObject = Handle(GEOMImpl_BoxDriver)((Handle(GEOMImpl_BoxDriver)&)AnObject);
131 return _anOtherObject ;