3 #include "GEOMImpl_PipeDriver.hxx"
4 #include "GEOMImpl_IPipe.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRep_Tool.hxx>
9 #include <BRepCheck_Analyzer.hxx>
10 #include <BRepOffsetAPI_MakePipe.hxx>
11 #include <BRepBuilderAPI_MakeWire.hxx>
15 #include <TopoDS_Wire.hxx>
16 #include <TopoDS_Edge.hxx>
17 #include <TopoDS_Shape.hxx>
19 #include <Standard_NullObject.hxx>
20 #include <Standard_TypeMismatch.hxx>
21 #include <Standard_ConstructionError.hxx>
23 //=======================================================================
26 //=======================================================================
27 const Standard_GUID& GEOMImpl_PipeDriver::GetID()
29 static Standard_GUID aPipeDriver("FF1BBB19-5D14-4df2-980B-3A668264EA16");
34 //=======================================================================
35 //function : GEOMImpl_PipeDriver
37 //=======================================================================
38 GEOMImpl_PipeDriver::GEOMImpl_PipeDriver()
42 //=======================================================================
45 //=======================================================================
46 Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const
48 if (Label().IsNull()) return 0;
49 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
51 GEOMImpl_IPipe aCI (aFunction);
52 Standard_Integer aType = aFunction->GetType();
56 if (aType == PIPE_BASE_PATH) {
57 Handle(GEOM_Function) aRefBase = aCI.GetBase();
58 Handle(GEOM_Function) aRefPath = aCI.GetPath();
59 TopoDS_Shape aShapeBase = aRefBase->GetValue();
60 TopoDS_Shape aShapePath = aRefPath->GetValue();
61 if (aShapeBase.IsNull() || aShapePath.IsNull()) {
62 Standard_NullObject::Raise("MakePipe aborted : null shape argument");
67 if (aShapePath.ShapeType() == TopAbs_WIRE) {
68 aWire = TopoDS::Wire(aShapePath);
70 if (aShapePath.ShapeType() == TopAbs_EDGE) {
71 TopoDS_Edge anEdge = TopoDS::Edge(aShapePath);
72 aWire = BRepBuilderAPI_MakeWire(anEdge);
74 Standard_TypeMismatch::Raise("MakePipe aborted : path shape is neither a wire nor an edge");
79 aShape = BRepOffsetAPI_MakePipe(aWire, aShapeBase);
84 if (aShape.IsNull()) return 0;
86 BRepCheck_Analyzer ana (aShape, Standard_False);
88 Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
91 aFunction->SetValue(aShape);
93 log.SetTouched(Label());
99 //=======================================================================
100 //function : GEOMImpl_PipeDriver_Type_
102 //=======================================================================
103 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipeDriver_Type_()
106 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
107 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
108 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
109 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
110 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
111 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
114 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
115 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PipeDriver",
116 sizeof(GEOMImpl_PipeDriver),
118 (Standard_Address)_Ancestors,
119 (Standard_Address)NULL);
124 //=======================================================================
125 //function : DownCast
127 //=======================================================================
128 const Handle(GEOMImpl_PipeDriver) Handle(GEOMImpl_PipeDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
130 Handle(GEOMImpl_PipeDriver) _anOtherObject;
132 if (!AnObject.IsNull()) {
133 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipeDriver))) {
134 _anOtherObject = Handle(GEOMImpl_PipeDriver)((Handle(GEOMImpl_PipeDriver)&)AnObject);
138 return _anOtherObject ;