3 #include "GEOMImpl_EllipseDriver.hxx"
4 #include "GEOMImpl_IEllipse.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepBuilderAPI_MakeEdge.hxx>
9 #include <BRep_Tool.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <TopoDS_Edge.hxx>
13 #include <TopoDS_Vertex.hxx>
18 #include <gp_Elips.hxx>
20 //=======================================================================
23 //=======================================================================
24 const Standard_GUID& GEOMImpl_EllipseDriver::GetID()
26 static Standard_GUID aEllipseDriver("FF1BBB34-5D14-4df2-980B-3A668264EA16");
27 return aEllipseDriver;
31 //=======================================================================
32 //function : GEOMImpl_EllipseDriver
34 //=======================================================================
35 GEOMImpl_EllipseDriver::GEOMImpl_EllipseDriver()
39 //=======================================================================
42 //=======================================================================
43 Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
45 if (Label().IsNull()) return 0;
46 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
48 GEOMImpl_IEllipse aCI (aFunction);
49 Standard_Integer aType = aFunction->GetType();
53 if (aType == ELLIPSE_PNT_VEC_RR) {
54 Handle(GEOM_Function) aRefPoint = aCI.GetCenter();
55 Handle(GEOM_Function) aRefVector = aCI.GetVector();
56 TopoDS_Shape aShapePnt = aRefPoint->GetValue();
57 TopoDS_Shape aShapeVec = aRefVector->GetValue();
58 if (aShapePnt.ShapeType() == TopAbs_VERTEX &&
59 aShapeVec.ShapeType() == TopAbs_EDGE) {
60 gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
61 TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
63 TopExp::Vertices(anE, V1, V2, Standard_True);
64 if (!V1.IsNull() && !V2.IsNull()) {
65 gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
66 gp_Ax2 anAxes (aP, aV);
67 gp_Elips anEll (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
68 aShape = BRepBuilderAPI_MakeEdge(anEll).Edge();
74 if (aShape.IsNull()) return 0;
76 aFunction->SetValue(aShape);
78 log.SetTouched(Label());
84 //=======================================================================
85 //function : GEOMImpl_EllipseDriver_Type_
87 //=======================================================================
88 Standard_EXPORT Handle_Standard_Type& GEOMImpl_EllipseDriver_Type_()
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);
99 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
100 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_EllipseDriver",
101 sizeof(GEOMImpl_EllipseDriver),
103 (Standard_Address)_Ancestors,
104 (Standard_Address)NULL);
109 //=======================================================================
110 //function : DownCast
112 //=======================================================================
113 const Handle(GEOMImpl_EllipseDriver) Handle(GEOMImpl_EllipseDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
115 Handle(GEOMImpl_EllipseDriver) _anOtherObject;
117 if (!AnObject.IsNull()) {
118 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_EllipseDriver))) {
119 _anOtherObject = Handle(GEOMImpl_EllipseDriver)((Handle(GEOMImpl_EllipseDriver)&)AnObject);
123 return _anOtherObject ;