3 #include "GEOMImpl_SketcherDriver.hxx"
4 #include "GEOMImpl_ISketcher.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOM_Function.hxx"
8 #include <TopoDS_Shape.hxx>
11 #include <BRepBuilderAPI_Transform.hxx>
13 #include <Sketcher_Profile.hxx>
15 #include <Standard_ConstructionError.hxx>
17 //=======================================================================
20 //=======================================================================
21 const Standard_GUID& GEOMImpl_SketcherDriver::GetID()
23 static Standard_GUID aSketcherDriver("FF1BBB64-5D14-4df2-980B-3A668264EA16");
24 return aSketcherDriver;
28 //=======================================================================
29 //function : GEOMImpl_SketcherDriver
31 //=======================================================================
32 GEOMImpl_SketcherDriver::GEOMImpl_SketcherDriver()
36 //=======================================================================
39 //=======================================================================
40 Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const
42 if (Label().IsNull()) return 0;
43 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
45 GEOMImpl_ISketcher aCI (aFunction);
46 //Standard_Integer aType = aFunction->GetType();
48 // retrieve the command
49 TCollection_AsciiString aCommand = aCI.GetCommand();
50 if (aCommand.IsEmpty())
56 Sketcher_Profile aProfile (aCommand.ToCString());
58 if (!aProfile.IsDone()) {
59 Standard_ConstructionError::Raise("Sketcher creation failed");
62 aShape = aProfile.GetShape();
67 gp_Pnt aOrigin = gp_Pnt(aCI.GetWorkingPlane(1), aCI.GetWorkingPlane(2), aCI.GetWorkingPlane(3));
68 gp_Dir aDirZ = gp_Dir(aCI.GetWorkingPlane(4), aCI.GetWorkingPlane(5), aCI.GetWorkingPlane(6));
69 gp_Dir aDirX = gp_Dir(aCI.GetWorkingPlane(7), aCI.GetWorkingPlane(8), aCI.GetWorkingPlane(9));
70 gp_Ax3 aWPlane = gp_Ax3(aOrigin, aDirZ, aDirX);
72 aTrans.SetTransformation(aWPlane);
74 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
75 aShape = aTransformation.Shape();
80 // set the function result
81 aFunction->SetValue(aShape);
83 log.SetTouched(Label());
89 //=======================================================================
90 //function : GEOMImpl_SketcherDriver_Type_
92 //=======================================================================
93 Standard_EXPORT Handle_Standard_Type& GEOMImpl_SketcherDriver_Type_()
96 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
97 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
98 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
99 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
100 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
101 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
104 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
105 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_SketcherDriver",
106 sizeof(GEOMImpl_SketcherDriver),
108 (Standard_Address)_Ancestors,
109 (Standard_Address)NULL);
114 //=======================================================================
115 //function : DownCast
117 //=======================================================================
118 const Handle(GEOMImpl_SketcherDriver) Handle(GEOMImpl_SketcherDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
120 Handle(GEOMImpl_SketcherDriver) _anOtherObject;
122 if (!AnObject.IsNull()) {
123 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_SketcherDriver))) {
124 _anOtherObject = Handle(GEOMImpl_SketcherDriver)((Handle(GEOMImpl_SketcherDriver)&)AnObject);
128 return _anOtherObject ;