2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_ScaleDriver.hxx>
5 #include <GEOMImpl_IScale.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepBuilderAPI_Transform.hxx>
10 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
17 #include <Precision.hxx>
20 //=======================================================================
23 //=======================================================================
24 const Standard_GUID& GEOMImpl_ScaleDriver::GetID()
26 static Standard_GUID aScaleDriver("FF1BBB52-5D14-4df2-980B-3A668264EA16");
31 //=======================================================================
32 //function : GEOMImpl_ScaleDriver
34 //=======================================================================
35 GEOMImpl_ScaleDriver::GEOMImpl_ScaleDriver()
39 //=======================================================================
42 //=======================================================================
43 Standard_Integer GEOMImpl_ScaleDriver::Execute(TFunction_Logbook& log) const
45 if (Label().IsNull()) return 0;
46 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
48 GEOMImpl_IScale aCI (aFunction);
49 Standard_Integer aType = aFunction->GetType();
53 if (aType == SCALE_SHAPE || aType == SCALE_SHAPE_COPY) {
54 Handle(GEOM_Function) aRefShape = aCI.GetShape();
55 Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
56 TopoDS_Shape aShapeBase = aRefShape->GetValue();
57 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
58 if (aShapeBase.IsNull() || aShapePnt.IsNull()) return 0;
59 if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
61 gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
63 aTrsf.SetScale(aP, aCI.GetFactor());
64 BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
65 aShape = aBRepTrsf.Shape();
69 if (aShape.IsNull()) return 0;
71 aFunction->SetValue(aShape);
73 log.SetTouched(Label());
79 //=======================================================================
80 //function : GEOMImpl_ScaleDriver_Type_
82 //=======================================================================
83 Standard_EXPORT Handle_Standard_Type& GEOMImpl_ScaleDriver_Type_()
86 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
87 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
88 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
89 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
90 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
91 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
94 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
95 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_ScaleDriver",
96 sizeof(GEOMImpl_ScaleDriver),
98 (Standard_Address)_Ancestors,
99 (Standard_Address)NULL);
104 //=======================================================================
105 //function : DownCast
107 //=======================================================================
108 const Handle(GEOMImpl_ScaleDriver) Handle(GEOMImpl_ScaleDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
110 Handle(GEOMImpl_ScaleDriver) _anOtherObject;
112 if (!AnObject.IsNull()) {
113 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ScaleDriver))) {
114 _anOtherObject = Handle(GEOMImpl_ScaleDriver)((Handle(GEOMImpl_ScaleDriver)&)AnObject);
118 return _anOtherObject ;