2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_PolylineDriver.hxx>
5 #include <GEOMImpl_IPolyline.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepBuilderAPI_MakePolygon.hxx>
10 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <TopoDS_Wire.hxx>
18 #include <Precision.hxx>
21 //=======================================================================
24 //=======================================================================
25 const Standard_GUID& GEOMImpl_PolylineDriver::GetID()
27 static Standard_GUID aPolylineDriver("FF1BBB31-5D14-4df2-980B-3A668264EA16");
28 return aPolylineDriver;
32 //=======================================================================
33 //function : GEOMImpl_PolylineDriver
35 //=======================================================================
36 GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver()
40 //=======================================================================
43 //=======================================================================
44 Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
46 if (Label().IsNull()) return 0;
47 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
49 GEOMImpl_IPolyline aCI (aFunction);
50 Standard_Integer aType = aFunction->GetType();
54 if (aType == POLYLINE_POINTS) {
55 int aLen = aCI.GetLength();
57 BRepBuilderAPI_MakePolygon aMakePoly;
58 for (; ind <= aLen; ind++)
60 Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
61 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
62 if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
63 aMakePoly.Add(TopoDS::Vertex(aShapePnt));
64 // if (!aMakePoly.Added()) return 0;
67 if (false) aMakePoly.Close();
68 if (aMakePoly.IsDone()) {
69 aShape = aMakePoly.Wire();
75 if (aShape.IsNull()) return 0;
77 aFunction->SetValue(aShape);
79 log.SetTouched(Label());
85 //=======================================================================
86 //function : GEOMImpl_PolylineDriver_Type_
88 //=======================================================================
89 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_()
92 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
93 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
94 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
95 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
96 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
97 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
100 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
101 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PolylineDriver",
102 sizeof(GEOMImpl_PolylineDriver),
104 (Standard_Address)_Ancestors,
105 (Standard_Address)NULL);
110 //=======================================================================
111 //function : DownCast
113 //=======================================================================
114 const Handle(GEOMImpl_PolylineDriver) Handle(GEOMImpl_PolylineDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
116 Handle(GEOMImpl_PolylineDriver) _anOtherObject;
118 if (!AnObject.IsNull()) {
119 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PolylineDriver))) {
120 _anOtherObject = Handle(GEOMImpl_PolylineDriver)((Handle(GEOMImpl_PolylineDriver)&)AnObject);
124 return _anOtherObject ;