1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include <Standard_Stream.hxx>
23 #include <GEOMImpl_PolylineDriver.hxx>
24 #include <GEOMImpl_IPolyline.hxx>
25 #include <GEOMImpl_Types.hxx>
26 #include <GEOM_Function.hxx>
28 #include <BRepBuilderAPI_MakePolygon.hxx>
29 #include <BRep_Tool.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Vertex.hxx>
33 #include <TopoDS_Wire.hxx>
37 #include <Precision.hxx>
40 //=======================================================================
43 //=======================================================================
44 const Standard_GUID& GEOMImpl_PolylineDriver::GetID()
46 static Standard_GUID aPolylineDriver("FF1BBB31-5D14-4df2-980B-3A668264EA16");
47 return aPolylineDriver;
51 //=======================================================================
52 //function : GEOMImpl_PolylineDriver
54 //=======================================================================
55 GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver()
59 //=======================================================================
62 //=======================================================================
63 Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
65 if (Label().IsNull()) return 0;
66 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
68 GEOMImpl_IPolyline aCI (aFunction);
69 Standard_Integer aType = aFunction->GetType();
73 if (aType == POLYLINE_POINTS) {
74 int aLen = aCI.GetLength();
76 BRepBuilderAPI_MakePolygon aMakePoly;
77 for (; ind <= aLen; ind++)
79 Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
80 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
81 if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
82 aMakePoly.Add(TopoDS::Vertex(aShapePnt));
83 // if (!aMakePoly.Added()) return 0;
86 if (false) aMakePoly.Close();
87 if (aMakePoly.IsDone()) {
88 aShape = aMakePoly.Wire();
94 if (aShape.IsNull()) return 0;
96 aFunction->SetValue(aShape);
98 log.SetTouched(Label());
104 //=======================================================================
105 //function : GEOMImpl_PolylineDriver_Type_
107 //=======================================================================
108 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_()
111 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
112 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
113 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
114 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
115 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
116 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
119 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
120 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PolylineDriver",
121 sizeof(GEOMImpl_PolylineDriver),
123 (Standard_Address)_Ancestors,
124 (Standard_Address)NULL);
129 //=======================================================================
130 //function : DownCast
132 //=======================================================================
133 const Handle(GEOMImpl_PolylineDriver) Handle(GEOMImpl_PolylineDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
135 Handle(GEOMImpl_PolylineDriver) _anOtherObject;
137 if (!AnObject.IsNull()) {
138 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PolylineDriver))) {
139 _anOtherObject = Handle(GEOMImpl_PolylineDriver)((Handle(GEOMImpl_PolylineDriver)&)AnObject);
143 return _anOtherObject ;