]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_PolylineDriver.cxx
Salome HOME
Modified a method createAndDisplayGO
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PolylineDriver.cxx
1
2 #include <Standard_Stream.hxx>
3
4 #include <GEOMImpl_PolylineDriver.hxx>
5 #include <GEOMImpl_IPolyline.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
8
9 #include <BRepBuilderAPI_MakePolygon.hxx>
10 #include <BRep_Tool.hxx>
11 #include <TopoDS.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <TopoDS_Wire.hxx>
15 #include <TopAbs.hxx>
16 #include <TopExp.hxx>
17
18 #include <Precision.hxx>
19 #include <gp_Pnt.hxx>
20
21 //=======================================================================
22 //function : GetID
23 //purpose  :
24 //======================================================================= 
25 const Standard_GUID& GEOMImpl_PolylineDriver::GetID()
26 {
27   static Standard_GUID aPolylineDriver("FF1BBB31-5D14-4df2-980B-3A668264EA16");
28   return aPolylineDriver; 
29 }
30
31
32 //=======================================================================
33 //function : GEOMImpl_PolylineDriver
34 //purpose  : 
35 //=======================================================================
36 GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver() 
37 {
38 }
39
40 //=======================================================================
41 //function : Execute
42 //purpose  :
43 //======================================================================= 
44 Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
45 {
46   if (Label().IsNull()) return 0;    
47   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
48
49   GEOMImpl_IPolyline aCI (aFunction);
50   Standard_Integer aType = aFunction->GetType();
51
52   TopoDS_Shape aShape;
53
54   if (aType == POLYLINE_POINTS) {
55     int aLen = aCI.GetLength();
56     int ind = 1;
57     BRepBuilderAPI_MakePolygon aMakePoly;
58     for (; ind <= aLen; ind++)
59     {
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;
65       }
66     }
67     if (false) aMakePoly.Close();
68     if (aMakePoly.IsDone()) {
69       aShape = aMakePoly.Wire();
70     }
71   }
72   else {
73   }
74
75   if (aShape.IsNull()) return 0;
76
77   aFunction->SetValue(aShape);
78
79   log.SetTouched(Label()); 
80
81   return 1;    
82 }
83
84
85 //=======================================================================
86 //function :  GEOMImpl_PolylineDriver_Type_
87 //purpose  :
88 //======================================================================= 
89 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_()
90 {
91
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);
98  
99
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),
103                                                          1,
104                                                          (Standard_Address)_Ancestors,
105                                                          (Standard_Address)NULL);
106
107   return _aType;
108 }
109
110 //=======================================================================
111 //function : DownCast
112 //purpose  :
113 //======================================================================= 
114 const Handle(GEOMImpl_PolylineDriver) Handle(GEOMImpl_PolylineDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
115 {
116   Handle(GEOMImpl_PolylineDriver) _anOtherObject;
117
118   if (!AnObject.IsNull()) {
119      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PolylineDriver))) {
120        _anOtherObject = Handle(GEOMImpl_PolylineDriver)((Handle(GEOMImpl_PolylineDriver)&)AnObject);
121      }
122   }
123
124   return _anOtherObject ;
125 }