mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 08:50:36 +05:00
PAL9166. Add possibility to make sketcher on an existing plane
This commit is contained in:
parent
61dbea0587
commit
bc805bc164
@ -1511,6 +1511,17 @@ module GEOM
|
|||||||
* \return New GEOM_Object, containing the created wire.
|
* \return New GEOM_Object, containing the created wire.
|
||||||
*/
|
*/
|
||||||
GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane);
|
GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create a sketcher (wire or face), following the textual description,
|
||||||
|
* passed through \a theCommand argument. \n
|
||||||
|
* For format of the description string see the previous method.\n
|
||||||
|
* \param theCommand String, defining the sketcher in local
|
||||||
|
* coordinates of the working plane.
|
||||||
|
* \param theWorkingPlane Planar Face of the working plane.
|
||||||
|
* \return New GEOM_Object, containing the created wire.
|
||||||
|
*/
|
||||||
|
GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -485,7 +485,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
|
|||||||
|
|
||||||
//Add a new Sketcher function
|
//Add a new Sketcher function
|
||||||
Handle(GEOM_Function) aFunction =
|
Handle(GEOM_Function) aFunction =
|
||||||
aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_COMMAND);
|
aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
|
||||||
if (aFunction.IsNull()) return NULL;
|
if (aFunction.IsNull()) return NULL;
|
||||||
|
|
||||||
//Check if the function is set correctly
|
//Check if the function is set correctly
|
||||||
@ -528,3 +528,57 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
|
|||||||
SetErrorCode(OK);
|
SetErrorCode(OK);
|
||||||
return aSketcher;
|
return aSketcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* MakeSketcherOnPlane
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* theCommand,
|
||||||
|
Handle(GEOM_Object) theWorkingPlane)
|
||||||
|
{
|
||||||
|
SetErrorCode(KO);
|
||||||
|
|
||||||
|
if (!theCommand) return NULL;
|
||||||
|
if (strcmp(theCommand, "") == 0) return NULL;
|
||||||
|
|
||||||
|
//Add a new Sketcher object
|
||||||
|
Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
|
||||||
|
|
||||||
|
//Add a new Sketcher function
|
||||||
|
Handle(GEOM_Function) aFunction =
|
||||||
|
aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
|
||||||
|
if (aFunction.IsNull()) return NULL;
|
||||||
|
|
||||||
|
//Check if the function is set correctly
|
||||||
|
if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
|
||||||
|
|
||||||
|
GEOMImpl_ISketcher aCI (aFunction);
|
||||||
|
|
||||||
|
TCollection_AsciiString aCommand ((char*) theCommand);
|
||||||
|
aCI.SetCommand(aCommand);
|
||||||
|
|
||||||
|
Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
|
||||||
|
if (aRefPlane.IsNull()) return NULL;
|
||||||
|
aCI.SetWorkingPlane( aRefPlane );
|
||||||
|
|
||||||
|
//Compute the Sketcher value
|
||||||
|
try {
|
||||||
|
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||||
|
SetErrorCode("Sketcher driver failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||||
|
SetErrorCode(aFail->GetMessageString());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make a Python command
|
||||||
|
GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
|
||||||
|
<< theCommand << "\", " << theWorkingPlane << " )";
|
||||||
|
|
||||||
|
SetErrorCode(OK);
|
||||||
|
return aSketcher;
|
||||||
|
}
|
||||||
|
@ -35,6 +35,8 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
|
|||||||
Handle(GEOM_Object) MakeSplineInterpolation (list<Handle(GEOM_Object)> thePoints);
|
Handle(GEOM_Object) MakeSplineInterpolation (list<Handle(GEOM_Object)> thePoints);
|
||||||
|
|
||||||
Handle(GEOM_Object) MakeSketcher (const char* theCommand, list<double> theWorkingPlane);
|
Handle(GEOM_Object) MakeSketcher (const char* theCommand, list<double> theWorkingPlane);
|
||||||
|
Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
|
||||||
|
Handle(GEOM_Object) theWorkingPlane);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "GEOM_Function.hxx"
|
#include "GEOM_Function.hxx"
|
||||||
|
|
||||||
#define SKETCH_ARG_CMD 1
|
#define SKETCH_ARG_CMD 1
|
||||||
#define SKETCH_ARG_WPLANE 2
|
#define SKETCH_ARG_DOUBLE 2
|
||||||
|
#define SKETCH_ARG_WPLANE 12
|
||||||
|
|
||||||
class GEOMImpl_ISketcher
|
class GEOMImpl_ISketcher
|
||||||
{
|
{
|
||||||
@ -18,9 +19,14 @@ class GEOMImpl_ISketcher
|
|||||||
TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_CMD); }
|
TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_CMD); }
|
||||||
|
|
||||||
void SetWorkingPlane(int theInd, double theValue)
|
void SetWorkingPlane(int theInd, double theValue)
|
||||||
{ _func->SetReal(SKETCH_ARG_WPLANE + theInd, theValue); }
|
{ _func->SetReal(SKETCH_ARG_DOUBLE + theInd, theValue); }
|
||||||
|
|
||||||
double GetWorkingPlane(int theInd) { return _func->GetReal(SKETCH_ARG_WPLANE + theInd); }
|
double GetWorkingPlane(int theInd) { return _func->GetReal(SKETCH_ARG_DOUBLE + theInd); }
|
||||||
|
|
||||||
|
void SetWorkingPlane(Handle(GEOM_Function) thePlane)
|
||||||
|
{ _func->SetReference(SKETCH_ARG_WPLANE, thePlane); }
|
||||||
|
|
||||||
|
Handle(GEOM_Function) GetWorkingPlane() { return _func->GetReference(SKETCH_ARG_WPLANE); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -5,10 +5,12 @@ using namespace std;
|
|||||||
#include "GEOMImpl_Types.hxx"
|
#include "GEOMImpl_Types.hxx"
|
||||||
#include "GEOM_Function.hxx"
|
#include "GEOM_Function.hxx"
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <gp_Dir.hxx>
|
|
||||||
#include <gp_Ax3.hxx>
|
|
||||||
#include <BRepBuilderAPI_Transform.hxx>
|
#include <BRepBuilderAPI_Transform.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
|
||||||
#include <Sketcher_Profile.hxx>
|
#include <Sketcher_Profile.hxx>
|
||||||
|
|
||||||
@ -63,12 +65,30 @@ Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const
|
|||||||
if (aShape.IsNull())
|
if (aShape.IsNull())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
gp_Ax3 aWPlane;
|
||||||
|
if ( aFunction->GetType() == SKETCHER_NINE_DOUBLS )
|
||||||
|
{
|
||||||
|
gp_Pnt aOrigin =
|
||||||
|
gp_Pnt(aCI.GetWorkingPlane(1), aCI.GetWorkingPlane(2), aCI.GetWorkingPlane(3));
|
||||||
|
gp_Dir aDirZ =
|
||||||
|
gp_Dir(aCI.GetWorkingPlane(4), aCI.GetWorkingPlane(5), aCI.GetWorkingPlane(6));
|
||||||
|
gp_Dir aDirX =
|
||||||
|
gp_Dir(aCI.GetWorkingPlane(7), aCI.GetWorkingPlane(8), aCI.GetWorkingPlane(9));
|
||||||
|
aWPlane = gp_Ax3(aOrigin, aDirZ, aDirX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle(GEOM_Function) aRefFace = aCI.GetWorkingPlane();
|
||||||
|
TopoDS_Shape aShape = aRefFace->GetValue();
|
||||||
|
if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_FACE )
|
||||||
|
return 0;
|
||||||
|
Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ));
|
||||||
|
if ( aGS.IsNull() || !aGS->IsKind( STANDARD_TYPE( Geom_Plane )))
|
||||||
|
return 0;
|
||||||
|
Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS );
|
||||||
|
aWPlane = aGPlane->Pln().Position();
|
||||||
|
}
|
||||||
gp_Trsf aTrans;
|
gp_Trsf aTrans;
|
||||||
gp_Pnt aOrigin = gp_Pnt(aCI.GetWorkingPlane(1), aCI.GetWorkingPlane(2), aCI.GetWorkingPlane(3));
|
|
||||||
gp_Dir aDirZ = gp_Dir(aCI.GetWorkingPlane(4), aCI.GetWorkingPlane(5), aCI.GetWorkingPlane(6));
|
|
||||||
gp_Dir aDirX = gp_Dir(aCI.GetWorkingPlane(7), aCI.GetWorkingPlane(8), aCI.GetWorkingPlane(9));
|
|
||||||
gp_Ax3 aWPlane = gp_Ax3(aOrigin, aDirZ, aDirX);
|
|
||||||
|
|
||||||
aTrans.SetTransformation(aWPlane);
|
aTrans.SetTransformation(aWPlane);
|
||||||
aTrans.Invert();
|
aTrans.Invert();
|
||||||
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
|
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
|
||||||
|
@ -188,7 +188,8 @@
|
|||||||
|
|
||||||
#define GLUE_FACES 1
|
#define GLUE_FACES 1
|
||||||
|
|
||||||
#define SKETCHER_COMMAND 1
|
#define SKETCHER_NINE_DOUBLS 1
|
||||||
|
#define SKETCHER_PLANE 2
|
||||||
|
|
||||||
#define CDG_MEASURE 1
|
#define CDG_MEASURE 1
|
||||||
|
|
||||||
|
@ -303,3 +303,28 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher (const char* theCom
|
|||||||
|
|
||||||
return GetObject(anObject);
|
return GetObject(anObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* MakeSketcherOnPlane
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
|
||||||
|
{
|
||||||
|
GEOM::GEOM_Object_var aGEOMObject;
|
||||||
|
|
||||||
|
//Set a not done flag
|
||||||
|
GetOperations()->SetNotDone();
|
||||||
|
|
||||||
|
Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
|
||||||
|
(theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
|
||||||
|
|
||||||
|
// Make Sketcher
|
||||||
|
Handle(GEOM_Object) anObject =
|
||||||
|
GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
|
||||||
|
if (!GetOperations()->IsDone() || anObject.IsNull())
|
||||||
|
return aGEOMObject._retn();
|
||||||
|
|
||||||
|
return GetObject(anObject);
|
||||||
|
}
|
||||||
|
@ -44,6 +44,8 @@ class GEOM_ICurvesOperations_i :
|
|||||||
|
|
||||||
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
|
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
|
||||||
|
|
||||||
|
GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane);
|
||||||
|
|
||||||
::GEOMImpl_ICurvesOperations* GetOperations()
|
::GEOMImpl_ICurvesOperations* GetOperations()
|
||||||
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
|
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user