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