2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_PipeDriver.hxx>
5 #include <GEOMImpl_IPipe.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRep_Tool.hxx>
10 #include <BRepCheck_Analyzer.hxx>
11 #include <BRepOffsetAPI_MakePipe.hxx>
12 #include <BRepBuilderAPI_MakeWire.hxx>
16 #include <TopoDS_Wire.hxx>
17 #include <TopoDS_Edge.hxx>
18 #include <TopoDS_Shape.hxx>
20 #include <Standard_NullObject.hxx>
21 #include <Standard_TypeMismatch.hxx>
22 #include <Standard_ConstructionError.hxx>
24 //=======================================================================
27 //=======================================================================
28 const Standard_GUID& GEOMImpl_PipeDriver::GetID()
30 static Standard_GUID aPipeDriver("FF1BBB19-5D14-4df2-980B-3A668264EA16");
35 //=======================================================================
36 //function : GEOMImpl_PipeDriver
38 //=======================================================================
39 GEOMImpl_PipeDriver::GEOMImpl_PipeDriver()
43 //=======================================================================
46 //=======================================================================
47 Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const
49 if (Label().IsNull()) return 0;
50 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
52 GEOMImpl_IPipe aCI (aFunction);
53 Standard_Integer aType = aFunction->GetType();
57 if (aType == PIPE_BASE_PATH) {
58 Handle(GEOM_Function) aRefBase = aCI.GetBase();
59 Handle(GEOM_Function) aRefPath = aCI.GetPath();
60 TopoDS_Shape aShapeBase = aRefBase->GetValue();
61 TopoDS_Shape aShapePath = aRefPath->GetValue();
62 if (aShapeBase.IsNull() || aShapePath.IsNull()) {
63 Standard_NullObject::Raise("MakePipe aborted : null shape argument");
68 if (aShapePath.ShapeType() == TopAbs_WIRE) {
69 aWire = TopoDS::Wire(aShapePath);
71 if (aShapePath.ShapeType() == TopAbs_EDGE) {
72 TopoDS_Edge anEdge = TopoDS::Edge(aShapePath);
73 aWire = BRepBuilderAPI_MakeWire(anEdge);
75 Standard_TypeMismatch::Raise("MakePipe aborted : path shape is neither a wire nor an edge");
80 aShape = BRepOffsetAPI_MakePipe(aWire, aShapeBase);
85 if (aShape.IsNull()) return 0;
87 BRepCheck_Analyzer ana (aShape, Standard_False);
89 Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
92 aFunction->SetValue(aShape);
94 log.SetTouched(Label());
100 //=======================================================================
101 //function : GEOMImpl_PipeDriver_Type_
103 //=======================================================================
104 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipeDriver_Type_()
107 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
108 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
109 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
110 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
111 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
112 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
115 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
116 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PipeDriver",
117 sizeof(GEOMImpl_PipeDriver),
119 (Standard_Address)_Ancestors,
120 (Standard_Address)NULL);
125 //=======================================================================
126 //function : DownCast
128 //=======================================================================
129 const Handle(GEOMImpl_PipeDriver) Handle(GEOMImpl_PipeDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
131 Handle(GEOMImpl_PipeDriver) _anOtherObject;
133 if (!AnObject.IsNull()) {
134 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipeDriver))) {
135 _anOtherObject = Handle(GEOMImpl_PipeDriver)((Handle(GEOMImpl_PipeDriver)&)AnObject);
139 return _anOtherObject ;