3 #include "GEOMImpl_MarkerDriver.hxx"
4 #include "GEOMImpl_IMarker.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <BRepBuilderAPI_MakeFace.hxx>
9 #include <BRep_Tool.hxx>
13 #include <TopoDS_Shape.hxx>
14 #include <TopoDS_Edge.hxx>
15 #include <TopoDS_Vertex.hxx>
18 #include <GC_MakePlane.hxx>
19 #include <Geom_Surface.hxx>
21 #include <Precision.hxx>
27 #include <Standard_ConstructionError.hxx>
29 //=======================================================================
32 //=======================================================================
33 const Standard_GUID& GEOMImpl_MarkerDriver::GetID()
35 static Standard_GUID aMarkerDriver("FF1BBB07-5D14-4df2-980B-3A668264EA16");
40 //=======================================================================
41 //function : GEOMImpl_MarkerDriver
43 //=======================================================================
44 GEOMImpl_MarkerDriver::GEOMImpl_MarkerDriver()
48 //=======================================================================
51 //=======================================================================
52 Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const
54 if (Label().IsNull()) return 0;
55 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
57 GEOMImpl_IMarker aPI (aFunction);
58 Standard_Integer aType = aFunction->GetType();
62 if (aType == MARKER_CS) {
66 aPI.GetOrigin(OX, OY, OZ);
67 aPI.GetXDir(XDX, XDY, XDZ);
68 aPI.GetYDir(YDX, YDY, YDZ);
70 gp_Pnt aPO (OX, OY, OZ);
71 gp_Vec aVX (XDX, XDY, XDZ);
72 gp_Vec aVY (YDX, YDY, YDZ);
73 Standard_Real aTol = Precision::Confusion();
74 if (aVX.Magnitude() < aTol ||
75 aVY.Magnitude() < aTol ||
76 aVX.IsParallel(aVY, Precision::Angular())) {
77 Standard_ConstructionError::Raise("Degenerated or parallel directions given");
80 gp_Vec aN = aVX ^ aVY;
81 gp_Ax3 anA (aPO, aN, aVX);
84 double aTrimSize = 100.0;
85 aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
89 if (aShape.IsNull()) return 0;
91 aFunction->SetValue(aShape);
93 log.SetTouched(Label());
99 //=======================================================================
100 //function : GEOMImpl_MarkerDriver_Type_
102 //=======================================================================
103 Standard_EXPORT Handle_Standard_Type& GEOMImpl_MarkerDriver_Type_()
106 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
107 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
108 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
109 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
110 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
111 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
114 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
115 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_MarkerDriver",
116 sizeof(GEOMImpl_MarkerDriver),
118 (Standard_Address)_Ancestors,
119 (Standard_Address)NULL);
124 //=======================================================================
125 //function : DownCast
127 //=======================================================================
128 const Handle(GEOMImpl_MarkerDriver) Handle(GEOMImpl_MarkerDriver)::DownCast
129 (const Handle(Standard_Transient)& AnObject)
131 Handle(GEOMImpl_MarkerDriver) _anOtherObject;
133 if (!AnObject.IsNull()) {
134 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MarkerDriver))) {
135 _anOtherObject = Handle(GEOMImpl_MarkerDriver)((Handle(GEOMImpl_MarkerDriver)&)AnObject);
139 return _anOtherObject ;