2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_EllipseDriver.hxx>
5 #include <GEOMImpl_IEllipse.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepBuilderAPI_MakeEdge.hxx>
10 #include <BRep_Tool.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Edge.hxx>
14 #include <TopoDS_Vertex.hxx>
19 #include <gp_Elips.hxx>
21 //=======================================================================
24 //=======================================================================
25 const Standard_GUID& GEOMImpl_EllipseDriver::GetID()
27 static Standard_GUID aEllipseDriver("FF1BBB34-5D14-4df2-980B-3A668264EA16");
28 return aEllipseDriver;
32 //=======================================================================
33 //function : GEOMImpl_EllipseDriver
35 //=======================================================================
36 GEOMImpl_EllipseDriver::GEOMImpl_EllipseDriver()
40 //=======================================================================
43 //=======================================================================
44 Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
46 if (Label().IsNull()) return 0;
47 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
49 GEOMImpl_IEllipse aCI (aFunction);
50 Standard_Integer aType = aFunction->GetType();
54 if (aType == ELLIPSE_PNT_VEC_RR) {
55 Handle(GEOM_Function) aRefPoint = aCI.GetCenter();
56 Handle(GEOM_Function) aRefVector = aCI.GetVector();
57 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
58 TopoDS_Shape aShapeVec = aRefVector->GetValue();
59 if (aShapePnt.ShapeType() == TopAbs_VERTEX &&
60 aShapeVec.ShapeType() == TopAbs_EDGE) {
61 gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
62 TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
64 TopExp::Vertices(anE, V1, V2, Standard_True);
65 if (!V1.IsNull() && !V2.IsNull()) {
66 gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
67 gp_Ax2 anAxes (aP, aV);
68 gp_Elips anEll (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
69 aShape = BRepBuilderAPI_MakeEdge(anEll).Edge();
75 if (aShape.IsNull()) return 0;
77 aFunction->SetValue(aShape);
79 log.SetTouched(Label());
85 //=======================================================================
86 //function : GEOMImpl_EllipseDriver_Type_
88 //=======================================================================
89 Standard_EXPORT Handle_Standard_Type& GEOMImpl_EllipseDriver_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_EllipseDriver",
102 sizeof(GEOMImpl_EllipseDriver),
104 (Standard_Address)_Ancestors,
105 (Standard_Address)NULL);
110 //=======================================================================
111 //function : DownCast
113 //=======================================================================
114 const Handle(GEOMImpl_EllipseDriver) Handle(GEOMImpl_EllipseDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
116 Handle(GEOMImpl_EllipseDriver) _anOtherObject;
118 if (!AnObject.IsNull()) {
119 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_EllipseDriver))) {
120 _anOtherObject = Handle(GEOMImpl_EllipseDriver)((Handle(GEOMImpl_EllipseDriver)&)AnObject);
124 return _anOtherObject ;