3 #include "GEOMImpl_PolylineDriver.hxx"
4 #include "GEOMImpl_IPolyline.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepBuilderAPI_MakePolygon.hxx>
9 #include <BRep_Tool.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <TopoDS_Vertex.hxx>
13 #include <TopoDS_Wire.hxx>
17 #include <Precision.hxx>
20 //=======================================================================
23 //=======================================================================
24 const Standard_GUID& GEOMImpl_PolylineDriver::GetID()
26 static Standard_GUID aPolylineDriver("FF1BBB31-5D14-4df2-980B-3A668264EA16");
27 return aPolylineDriver;
31 //=======================================================================
32 //function : GEOMImpl_PolylineDriver
34 //=======================================================================
35 GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver()
39 //=======================================================================
42 //=======================================================================
43 Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
45 if (Label().IsNull()) return 0;
46 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
48 GEOMImpl_IPolyline aCI (aFunction);
49 Standard_Integer aType = aFunction->GetType();
53 if (aType == POLYLINE_POINTS) {
54 int aLen = aCI.GetLength();
56 BRepBuilderAPI_MakePolygon aMakePoly;
57 for (; ind <= aLen; ind++)
59 Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
60 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
61 if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
62 aMakePoly.Add(TopoDS::Vertex(aShapePnt));
63 // if (!aMakePoly.Added()) return 0;
66 if (false) aMakePoly.Close();
67 if (aMakePoly.IsDone()) {
68 aShape = aMakePoly.Wire();
74 if (aShape.IsNull()) return 0;
76 aFunction->SetValue(aShape);
78 log.SetTouched(Label());
84 //=======================================================================
85 //function : GEOMImpl_PolylineDriver_Type_
87 //=======================================================================
88 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_()
91 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
92 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
93 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
94 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
95 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
96 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
99 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
100 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PolylineDriver",
101 sizeof(GEOMImpl_PolylineDriver),
103 (Standard_Address)_Ancestors,
104 (Standard_Address)NULL);
109 //=======================================================================
110 //function : DownCast
112 //=======================================================================
113 const Handle(GEOMImpl_PolylineDriver) Handle(GEOMImpl_PolylineDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
115 Handle(GEOMImpl_PolylineDriver) _anOtherObject;
117 if (!AnObject.IsNull()) {
118 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PolylineDriver))) {
119 _anOtherObject = Handle(GEOMImpl_PolylineDriver)((Handle(GEOMImpl_PolylineDriver)&)AnObject);
123 return _anOtherObject ;