2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_MarkerDriver.hxx>
5 #include <GEOMImpl_IMarker.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
9 #include <BRepBuilderAPI_MakeFace.hxx>
10 #include <BRep_Tool.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <TopoDS_Edge.hxx>
16 #include <TopoDS_Vertex.hxx>
19 #include <GC_MakePlane.hxx>
20 #include <Geom_Surface.hxx>
22 #include <Precision.hxx>
28 #include <Standard_ConstructionError.hxx>
30 //=======================================================================
33 //=======================================================================
34 const Standard_GUID& GEOMImpl_MarkerDriver::GetID()
36 static Standard_GUID aMarkerDriver("FF1BBB07-5D14-4df2-980B-3A668264EA16");
41 //=======================================================================
42 //function : GEOMImpl_MarkerDriver
44 //=======================================================================
45 GEOMImpl_MarkerDriver::GEOMImpl_MarkerDriver()
49 //=======================================================================
52 //=======================================================================
53 Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const
55 if (Label().IsNull()) return 0;
56 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
58 GEOMImpl_IMarker aPI (aFunction);
59 Standard_Integer aType = aFunction->GetType();
63 if (aType == MARKER_CS) {
67 aPI.GetOrigin(OX, OY, OZ);
68 aPI.GetXDir(XDX, XDY, XDZ);
69 aPI.GetYDir(YDX, YDY, YDZ);
71 gp_Pnt aPO (OX, OY, OZ);
72 gp_Vec aVX (XDX, XDY, XDZ);
73 gp_Vec aVY (YDX, YDY, YDZ);
74 Standard_Real aTol = Precision::Confusion();
75 if (aVX.Magnitude() < aTol ||
76 aVY.Magnitude() < aTol ||
77 aVX.IsParallel(aVY, Precision::Angular())) {
78 Standard_ConstructionError::Raise("Degenerated or parallel directions given");
81 gp_Vec aN = aVX ^ aVY;
82 gp_Ax3 anA (aPO, aN, aVX);
85 double aTrimSize = 100.0;
86 aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
90 if (aShape.IsNull()) return 0;
92 aFunction->SetValue(aShape);
94 log.SetTouched(Label());
100 //=======================================================================
101 //function : GEOMImpl_MarkerDriver_Type_
103 //=======================================================================
104 Standard_EXPORT Handle_Standard_Type& GEOMImpl_MarkerDriver_Type_()
107 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
108 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
109 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
110 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
111 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
112 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
115 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
116 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_MarkerDriver",
117 sizeof(GEOMImpl_MarkerDriver),
119 (Standard_Address)_Ancestors,
120 (Standard_Address)NULL);
125 //=======================================================================
126 //function : DownCast
128 //=======================================================================
129 const Handle(GEOMImpl_MarkerDriver) Handle(GEOMImpl_MarkerDriver)::DownCast
130 (const Handle(Standard_Transient)& AnObject)
132 Handle(GEOMImpl_MarkerDriver) _anOtherObject;
134 if (!AnObject.IsNull()) {
135 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MarkerDriver))) {
136 _anOtherObject = Handle(GEOMImpl_MarkerDriver)((Handle(GEOMImpl_MarkerDriver)&)AnObject);
140 return _anOtherObject ;