3 #include "GEOMImpl_OffsetDriver.hxx"
4 #include "GEOMImpl_IOffset.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
9 #include <BRep_Tool.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <TopoDS_Vertex.hxx>
16 #include <Precision.hxx>
19 #include <StdFail_NotDone.hxx>
21 //=======================================================================
24 //=======================================================================
25 const Standard_GUID& GEOMImpl_OffsetDriver::GetID()
27 static Standard_GUID aOffsetDriver("FF1BBB51-5D14-4df2-980B-3A668264EA16");
32 //=======================================================================
33 //function : GEOMImpl_OffsetDriver
35 //=======================================================================
36 GEOMImpl_OffsetDriver::GEOMImpl_OffsetDriver()
40 //=======================================================================
43 //=======================================================================
44 Standard_Integer GEOMImpl_OffsetDriver::Execute(TFunction_Logbook& log) const
46 if (Label().IsNull()) return 0;
47 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
49 GEOMImpl_IOffset aCI (aFunction);
50 Standard_Integer aType = aFunction->GetType();
54 if (aType == OFFSET_SHAPE || aType == OFFSET_SHAPE_COPY) {
55 Handle(GEOM_Function) aRefShape = aCI.GetShape();
56 TopoDS_Shape aShapeBase = aRefShape->GetValue();
57 Standard_Real anOffset = aCI.GetValue();
58 Standard_Real aTol = Precision::Confusion();
60 if (Abs(anOffset) < aTol) {
61 TCollection_AsciiString aMsg ("Absolute value of offset can not be less than the tolerance value (");
62 aMsg += TCollection_AsciiString(aTol);
64 StdFail_NotDone::Raise(aMsg.ToCString());
67 BRepOffsetAPI_MakeOffsetShape MO (aShapeBase,
73 StdFail_NotDone::Raise("Offset construction failed");
78 if (aShape.IsNull()) return 0;
80 aFunction->SetValue(aShape);
82 log.SetTouched(Label());
88 //=======================================================================
89 //function : GEOMImpl_OffsetDriver_Type_
91 //=======================================================================
92 Standard_EXPORT Handle_Standard_Type& GEOMImpl_OffsetDriver_Type_()
95 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
96 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
97 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
98 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
99 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
100 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
103 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
104 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_OffsetDriver",
105 sizeof(GEOMImpl_OffsetDriver),
107 (Standard_Address)_Ancestors,
108 (Standard_Address)NULL);
113 //=======================================================================
114 //function : DownCast
116 //=======================================================================
117 const Handle(GEOMImpl_OffsetDriver) Handle(GEOMImpl_OffsetDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
119 Handle(GEOMImpl_OffsetDriver) _anOtherObject;
121 if (!AnObject.IsNull()) {
122 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_OffsetDriver))) {
123 _anOtherObject = Handle(GEOMImpl_OffsetDriver)((Handle(GEOMImpl_OffsetDriver)&)AnObject);
127 return _anOtherObject ;