3 #include "GEOMImpl_ScaleDriver.hxx"
4 #include "GEOMImpl_IScale.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepBuilderAPI_Transform.hxx>
9 #include <BRep_Tool.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <TopoDS_Vertex.hxx>
16 #include <Precision.hxx>
19 //=======================================================================
22 //=======================================================================
23 const Standard_GUID& GEOMImpl_ScaleDriver::GetID()
25 static Standard_GUID aScaleDriver("FF1BBB52-5D14-4df2-980B-3A668264EA16");
30 //=======================================================================
31 //function : GEOMImpl_ScaleDriver
33 //=======================================================================
34 GEOMImpl_ScaleDriver::GEOMImpl_ScaleDriver()
38 //=======================================================================
41 //=======================================================================
42 Standard_Integer GEOMImpl_ScaleDriver::Execute(TFunction_Logbook& log) const
44 if (Label().IsNull()) return 0;
45 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
47 GEOMImpl_IScale aCI (aFunction);
48 Standard_Integer aType = aFunction->GetType();
52 if (aType == SCALE_SHAPE || aType == SCALE_SHAPE_COPY) {
53 Handle(GEOM_Function) aRefShape = aCI.GetShape();
54 Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
55 TopoDS_Shape aShapeBase = aRefShape->GetValue();
56 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
57 if (aShapeBase.IsNull() || aShapePnt.IsNull()) return 0;
58 if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
60 gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
62 aTrsf.SetScale(aP, aCI.GetFactor());
63 BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
64 aShape = aBRepTrsf.Shape();
68 if (aShape.IsNull()) return 0;
70 aFunction->SetValue(aShape);
72 log.SetTouched(Label());
78 //=======================================================================
79 //function : GEOMImpl_ScaleDriver_Type_
81 //=======================================================================
82 Standard_EXPORT Handle_Standard_Type& GEOMImpl_ScaleDriver_Type_()
85 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
86 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
87 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
88 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
89 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
90 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
93 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
94 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_ScaleDriver",
95 sizeof(GEOMImpl_ScaleDriver),
97 (Standard_Address)_Ancestors,
98 (Standard_Address)NULL);
103 //=======================================================================
104 //function : DownCast
106 //=======================================================================
107 const Handle(GEOMImpl_ScaleDriver) Handle(GEOMImpl_ScaleDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
109 Handle(GEOMImpl_ScaleDriver) _anOtherObject;
111 if (!AnObject.IsNull()) {
112 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ScaleDriver))) {
113 _anOtherObject = Handle(GEOMImpl_ScaleDriver)((Handle(GEOMImpl_ScaleDriver)&)AnObject);
117 return _anOtherObject ;