2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_OffsetDriver.hxx>
5 #include <GEOMImpl_IOffset.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
10 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
17 #include <Precision.hxx>
20 #include <StdFail_NotDone.hxx>
22 //=======================================================================
25 //=======================================================================
26 const Standard_GUID& GEOMImpl_OffsetDriver::GetID()
28 static Standard_GUID aOffsetDriver("FF1BBB51-5D14-4df2-980B-3A668264EA16");
33 //=======================================================================
34 //function : GEOMImpl_OffsetDriver
36 //=======================================================================
37 GEOMImpl_OffsetDriver::GEOMImpl_OffsetDriver()
41 //=======================================================================
44 //=======================================================================
45 Standard_Integer GEOMImpl_OffsetDriver::Execute(TFunction_Logbook& log) const
47 if (Label().IsNull()) return 0;
48 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
50 GEOMImpl_IOffset aCI (aFunction);
51 Standard_Integer aType = aFunction->GetType();
55 if (aType == OFFSET_SHAPE || aType == OFFSET_SHAPE_COPY) {
56 Handle(GEOM_Function) aRefShape = aCI.GetShape();
57 TopoDS_Shape aShapeBase = aRefShape->GetValue();
58 Standard_Real anOffset = aCI.GetValue();
59 Standard_Real aTol = Precision::Confusion();
61 if (Abs(anOffset) < aTol) {
62 TCollection_AsciiString aMsg ("Absolute value of offset can not be less than the tolerance value (");
63 aMsg += TCollection_AsciiString(aTol);
65 StdFail_NotDone::Raise(aMsg.ToCString());
68 BRepOffsetAPI_MakeOffsetShape MO (aShapeBase,
74 StdFail_NotDone::Raise("Offset construction failed");
79 if (aShape.IsNull()) return 0;
81 aFunction->SetValue(aShape);
83 log.SetTouched(Label());
89 //=======================================================================
90 //function : GEOMImpl_OffsetDriver_Type_
92 //=======================================================================
93 Standard_EXPORT Handle_Standard_Type& GEOMImpl_OffsetDriver_Type_()
96 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
97 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
98 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
99 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
100 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
101 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
104 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
105 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_OffsetDriver",
106 sizeof(GEOMImpl_OffsetDriver),
108 (Standard_Address)_Ancestors,
109 (Standard_Address)NULL);
114 //=======================================================================
115 //function : DownCast
117 //=======================================================================
118 const Handle(GEOMImpl_OffsetDriver) Handle(GEOMImpl_OffsetDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
120 Handle(GEOMImpl_OffsetDriver) _anOtherObject;
122 if (!AnObject.IsNull()) {
123 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_OffsetDriver))) {
124 _anOtherObject = Handle(GEOMImpl_OffsetDriver)((Handle(GEOMImpl_OffsetDriver)&)AnObject);
128 return _anOtherObject ;