2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_PointDriver.hxx>
5 #include <GEOMImpl_IPoint.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRep_Tool.hxx>
10 #include <BRepBuilderAPI_MakeVertex.hxx>
14 #include <TopoDS_Edge.hxx>
15 #include <TopoDS_Shape.hxx>
16 #include <TopoDS_Vertex.hxx>
18 #include <Geom_Curve.hxx>
21 //=======================================================================
24 //=======================================================================
25 const Standard_GUID& GEOMImpl_PointDriver::GetID()
27 static Standard_GUID aPointDriver("FF1BBB02-5D14-4df2-980B-3A668264EA16");
32 //=======================================================================
33 //function : GEOMImpl_PointDriver
35 //=======================================================================
36 GEOMImpl_PointDriver::GEOMImpl_PointDriver()
40 //=======================================================================
43 //=======================================================================
44 Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
46 if (Label().IsNull()) return 0;
47 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
49 GEOMImpl_IPoint aPI (aFunction);
50 Standard_Integer aType = aFunction->GetType();
54 if (aType == POINT_XYZ) {
55 aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ());
57 } else if (aType == POINT_XYZ_REF) {
59 Handle(GEOM_Function) aRefPoint = aPI.GetRef();
60 TopoDS_Shape aRefShape = aRefPoint->GetValue();
61 if (aRefShape.ShapeType() != TopAbs_VERTEX) {
62 Standard_TypeMismatch::Raise
63 ("Point creation aborted : referenced shape is not a vertex");
65 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aRefShape));
66 aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ());
68 } else if (aType == POINT_CURVE_PAR) {
70 Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
71 TopoDS_Shape aRefShape = aRefCurve->GetValue();
72 if (aRefShape.ShapeType() != TopAbs_EDGE) {
73 Standard_TypeMismatch::Raise
74 ("Point On Curve creation aborted : curve shape is not an edge");
76 Standard_Real aFP, aLP, aP;
77 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFP, aLP);
78 aP = aFP + (aLP - aFP) * aPI.GetParameter();
79 aPnt = aCurve->Value(aP);
85 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
86 TopoDS_Shape aShape = mkVertex.Shape();
87 aShape.Infinite(Standard_True);
88 aFunction->SetValue(aShape);
90 log.SetTouched(Label());
96 //=======================================================================
97 //function : GEOMImpl_PointDriver_Type_
99 //=======================================================================
100 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PointDriver_Type_()
103 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
104 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
105 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
106 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
107 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
108 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
111 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
112 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PointDriver",
113 sizeof(GEOMImpl_PointDriver),
115 (Standard_Address)_Ancestors,
116 (Standard_Address)NULL);
121 //=======================================================================
122 //function : DownCast
124 //=======================================================================
126 const Handle(GEOMImpl_PointDriver) Handle(GEOMImpl_PointDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
128 Handle(GEOMImpl_PointDriver) _anOtherObject;
130 if (!AnObject.IsNull()) {
131 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PointDriver))) {
132 _anOtherObject = Handle(GEOMImpl_PointDriver)((Handle(GEOMImpl_PointDriver)&)AnObject);
136 return _anOtherObject ;