Salome HOME
1f1f653da203e0b834f0714146305c347d3051b1
[modules/geom.git] / src / GEOMImpl / GEOMImpl_MarkerDriver.cxx
1
2 #include <Standard_Stream.hxx>
3
4 #include <GEOMImpl_MarkerDriver.hxx>
5 #include <GEOMImpl_IMarker.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
8
9 #include <BRepBuilderAPI_MakeFace.hxx>
10 #include <BRep_Tool.hxx>
11
12 #include <TopAbs.hxx>
13 #include <TopoDS.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <TopoDS_Edge.hxx>
16 #include <TopoDS_Vertex.hxx>
17 #include <TopExp.hxx>
18
19 #include <GC_MakePlane.hxx>
20 #include <Geom_Surface.hxx>
21
22 #include <Precision.hxx>
23 #include <gp_Ax3.hxx>
24 #include <gp_Pnt.hxx>
25 #include <gp_Pln.hxx>
26 #include <gp_Vec.hxx>
27
28 #include <Standard_ConstructionError.hxx>
29
30 //=======================================================================
31 //function : GetID
32 //purpose  :
33 //=======================================================================
34 const Standard_GUID& GEOMImpl_MarkerDriver::GetID()
35 {
36   static Standard_GUID aMarkerDriver("FF1BBB07-5D14-4df2-980B-3A668264EA16");
37   return aMarkerDriver;
38 }
39
40
41 //=======================================================================
42 //function : GEOMImpl_MarkerDriver
43 //purpose  :
44 //=======================================================================
45 GEOMImpl_MarkerDriver::GEOMImpl_MarkerDriver()
46 {
47 }
48
49 //=======================================================================
50 //function : Execute
51 //purpose  :
52 //=======================================================================
53 Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const
54 {
55   if (Label().IsNull())  return 0;
56   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
57
58   GEOMImpl_IMarker aPI (aFunction);
59   Standard_Integer aType = aFunction->GetType();
60
61   TopoDS_Shape aShape;
62
63   if (aType == MARKER_CS) {
64     double OX, OY, OZ;
65     double XDX, XDY, XDZ;
66     double YDX, YDY, YDZ;
67     aPI.GetOrigin(OX, OY, OZ);
68     aPI.GetXDir(XDX, XDY, XDZ);
69     aPI.GetYDir(YDX, YDY, YDZ);
70
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");
79     }
80
81     gp_Vec aN = aVX ^ aVY;
82     gp_Ax3 anA (aPO, aN, aVX);
83     gp_Pln aPln (anA);
84
85     double aTrimSize = 100.0;
86     aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
87   } else {
88   }
89
90   if (aShape.IsNull()) return 0;
91
92   aFunction->SetValue(aShape);
93
94   log.SetTouched(Label());
95
96   return 1;
97 }
98
99
100 //=======================================================================
101 //function :  GEOMImpl_MarkerDriver_Type_
102 //purpose  :
103 //=======================================================================
104 Standard_EXPORT Handle_Standard_Type& GEOMImpl_MarkerDriver_Type_()
105 {
106
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);
113
114
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),
118                                                          1,
119                                                          (Standard_Address)_Ancestors,
120                                                          (Standard_Address)NULL);
121
122   return _aType;
123 }
124
125 //=======================================================================
126 //function : DownCast
127 //purpose  :
128 //=======================================================================
129 const Handle(GEOMImpl_MarkerDriver) Handle(GEOMImpl_MarkerDriver)::DownCast
130        (const Handle(Standard_Transient)& AnObject)
131 {
132   Handle(GEOMImpl_MarkerDriver) _anOtherObject;
133
134   if (!AnObject.IsNull()) {
135      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MarkerDriver))) {
136        _anOtherObject = Handle(GEOMImpl_MarkerDriver)((Handle(GEOMImpl_MarkerDriver)&)AnObject);
137      }
138   }
139
140   return _anOtherObject ;
141 }