Mantis issue 0021392: EDF 1631 GEOM: Dump study of sketcher 3D with relatives coordinates.

This commit is contained in:
jfa 2012-09-06 13:29:35 +00:00
parent b0cc47d13b
commit 89c42a4f37
12 changed files with 1191 additions and 685 deletions

View File

@ -2788,7 +2788,7 @@ module GEOM
* passed through \a theCommand argument.
*
* Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
* Format of the description string have to be the following:
* Format of the description string has to be the following:
*
* "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
*
@ -2816,32 +2816,60 @@ module GEOM
* coordinates of the working plane.
* \param theWorkingPlane Nine double values, defining origin,
* OZ and OX directions of the working plane.
* \return New GEOM_Object, containing the created wire.
* \return New GEOM_Object, containing the created wire or face.
*/
GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane);
/*!
* \brief Create a 3D sketcher, following the numerical description,
* passed through points created by \a theCoordinates argument.
*
* Format of the description string have to be the following:
*
* "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]"
*/
GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
/*!
* \brief Create a sketcher (wire or face), following the textual description,
* passed through \a theCommand argument.
*
* 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 or LCS(Marker) of the working plane.
* \return New GEOM_Object, containing the created wire.
* \return New GEOM_Object, containing the created wire or face.
*/
GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane);
/*!
* \brief Create a 3D sketcher, following the textual description,
* passed through \a theCommand argument.
*
* Format of the description string has to be the following:
*
* "3DSketcher:CMD[:CMD[:CMD...]]"
*
* Where CMD is one of
* - "TT x y z" : Create segment by point at X & Y or set the first point
* - "T dx dy dz" : Create segment by point with DX & DY
* .
* \n
* - "OXY angleX angle2 length" : Create segment by two angles and length
* - "OYZ angleY angle2 length" : Create segment by two angles and length
* - "OXZ angleX angle2 length" : Create segment by two angles and length
* .
* \n
* - "WW" : Close Wire (to finish)
*
* \param theCommand String, defining the sketcher in local
* coordinates of the working plane.
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object Make3DSketcherCommand (in string theCommand);
/*!
* \brief Create a 3D sketcher, made of a straight segments, joining points
* with coordinates passed through \a theCoordinates argument.
*
* Order of coordinates has to be the following:
* x1, y1, z1, x2, y2, z2, ..., xN, yN, zN
*
* \param theCoordinates List of double values.
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
};
// # GEOM_ILocalOperations:

View File

@ -15,12 +15,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_3DSketcherDlg.cxx
// Author : DMV, OCN
//
#include <cmath>
#include <string>
#include <boost/lexical_cast.hpp>
@ -173,8 +172,6 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q
Init();
}
//=================================================================================
// function : ~EntityGUI_3DSketcherDlg()
// purpose : Destroys the object and frees any allocated resources
@ -291,13 +288,15 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
Group3Spin->SpinBox_DX->blockSignals(true);
Group3Spin->SpinBox_DY->blockSignals(true);
Group3Spin->SpinBox_DZ->blockSignals(true);
// Get setting of step value from file configuration
XYZ xyz = getLastPoint();
bool okx, oky, okz;
Group3Spin->SpinBox_DX->text().toDouble(&okx);
Group3Spin->SpinBox_DY->text().toDouble(&oky);
Group3Spin->SpinBox_DZ->text().toDouble(&okz);
if ( mode == 0 ) { // XY
if (mode == 0) { // XYZ
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2"));
@ -309,7 +308,7 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
}
Group3Spin->buttonApply->setFocus();
}
else if ( mode == 1) { // DXDY
else if (mode == 1) { // DXDYDZ
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_DZ2"));
@ -321,7 +320,7 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
}
Group3Spin->buttonApply->setFocus();
}
else if (mode == 2){ // Angles
else if (mode == 2) { // Angles and Length
Group3Spin->hide();
GroupAngles->show();
GroupAngles->buttonApply->setFocus();
@ -394,7 +393,6 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
}
UpdateButtonsState();
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
@ -559,11 +557,11 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
if (!CORBA::is_nil(aSelectedObject)) {
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { // Explore the shape if its a local selection
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) {
// Explore the shape if its a local selection
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1)
{
if (aMap.Extent() == 1) {
int anIndex = aMap(1);
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
@ -588,7 +586,8 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
Group3Spin->SpinBox_DX->setValue(aX);
Group3Spin->SpinBox_DY->setValue(aY);
Group3Spin->SpinBox_DZ->setValue(aZ);
} else if ( GroupType->RadioButton2->isChecked() ) {
}
else if (GroupType->RadioButton2->isChecked()) {
XYZ xyz = getLastPoint();
Group3Spin->SpinBox_DX->setValue(aX - xyz.x);
Group3Spin->SpinBox_DY->setValue(aY - xyz.y);
@ -616,7 +615,6 @@ void EntityGUI_3DSketcherDlg::DeactivateActiveDialog()
myGeomGUI->SetActiveDialogBox(0);
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -634,7 +632,6 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
@ -644,7 +641,6 @@ void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : BoxChecked()
// purpose : ChecBoxes management
@ -736,37 +732,38 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
//=================================================================================
bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects)
{
GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
if (!myOK || myPointsList.size() == 0)
aCoordsArray->length((myPointsList.size()+1)*3);
else
aCoordsArray->length(myPointsList.size()*3);
//GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
//if (!myOK || myPointsList.size() == 0)
// aCoordsArray->length((myPointsList.size()+1)*3);
//else
// aCoordsArray->length(myPointsList.size()*3);
QStringList aCommands;
aCommands << "3DSketcher";
QStringList aParameters;
int i = 0;
//int i = 0;
QList<XYZ>::const_iterator it;
for (it = myPointsList.begin(); it != myPointsList.end(); ++it) {
aCoordsArray[i++] = (*it).x;
aCoordsArray[i++] = (*it).y;
aCoordsArray[i++] = (*it).z;
aParameters << (*it).xt;
aParameters << (*it).yt;
aParameters << (*it).zt;
//aCoordsArray[i++] = (*it).x;
//aCoordsArray[i++] = (*it).y;
//aCoordsArray[i++] = (*it).z;
aCommands << (*it).command;
aParameters << (*it).params;
}
if (!myOK || myPointsList.size() == 0) {
XYZ xyz = getCurrentPoint();
aCoordsArray[i++] = xyz.x;
aCoordsArray[i++] = xyz.y;
aCoordsArray[i++] = xyz.z;
aParameters << xyz.xt;
aParameters << xyz.yt;
aParameters << xyz.zt;
//aCoordsArray[i++] = xyz.x;
//aCoordsArray[i++] = xyz.y;
//aCoordsArray[i++] = xyz.z;
aCommands << xyz.command;
aParameters << xyz.params;
}
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher( aCoordsArray );
//GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher(aCoordsArray);
GEOM::GEOM_Object_var anObj = anOper->Make3DSketcherCommand(aCommands.join(":").toLatin1().constData());
if (!anObj->_is_nil()) {
if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
@ -849,59 +846,94 @@ EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getPenultimatePoint() cons
//=================================================================================
// function : getCurrentPoint()
// purpose : returns current points
// purpose : returns current point
//=================================================================================
EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const
{
XYZ xyz;
// Temporary way of doing this. To be changed with ordered improvement of the sketcher
if ( myMode == 2 )
{
double anAngle = GroupAngles->SpinBox_DA->value() * M_PI/180.0;
double anAngle2 = 0.0;
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue("Geometry", "length_precision", 7);
if (myMode == 2) {
if (GroupAngles->radioButton_1->isChecked())
xyz.command = "OXY ";
else if (GroupAngles->radioButton_2->isChecked())
xyz.command = "OYZ ";
else
xyz.command = "OXZ ";
double anAngle = GroupAngles->SpinBox_DA->value();
double aLength = GroupAngles->SpinBox_DL->value();
if (GroupAngles->checkBox->isChecked())
anAngle2 = GroupAngles->SpinBox_DA2->value() * M_PI/180.0;
double anAngle2 = 0.0;
QString da2 = "0";
if (GroupAngles->checkBox->isChecked()) {
anAngle2 = GroupAngles->SpinBox_DA2->value();
da2 = GroupAngles->SpinBox_DA2->text();
}
xyz.command +=
QString::number(anAngle, 'g', aPrecision) + " " +
QString::number(anAngle2, 'g', aPrecision) + " " +
QString::number(aLength, 'g', aPrecision);
xyz.params =
GroupAngles->SpinBox_DA->text() + ":" +
da2 + ":" +
GroupAngles->SpinBox_DL->text();
// Calculate point coordinates for preview
anAngle = anAngle * M_PI/180.0;
anAngle2 = anAngle2 * M_PI/180.0;
double aProjectedLength = aLength * cos(anAngle2);
xyz = getLastPoint();
if (GroupAngles->radioButton_1->isChecked())
XYZ xyzP = getLastPoint();
if (GroupAngles->radioButton_1->isChecked()) // OXY
{
xyz.x += aProjectedLength * cos(anAngle);
xyz.y += aProjectedLength * sin(anAngle);
xyz.z += aLength * sin(anAngle2);
xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
xyz.y = xyzP.y + aProjectedLength * sin(anAngle);
xyz.z = xyzP.z + aLength * sin(anAngle2);
}
else if (GroupAngles->radioButton_2->isChecked())
else if (GroupAngles->radioButton_2->isChecked()) // OYZ
{
xyz.y += aProjectedLength * cos(anAngle);
xyz.z += aProjectedLength * sin(anAngle);
xyz.x += aLength * sin(anAngle2);
xyz.y = xyzP.y + aProjectedLength * cos(anAngle);
xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
xyz.x = xyzP.x + aLength * sin(anAngle2);
}
else
else // OXZ
{
xyz.z += aProjectedLength * sin(anAngle);
xyz.x += aProjectedLength * cos(anAngle);
xyz.y += aLength * sin(anAngle2);
xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
xyz.y = xyzP.y + aLength * sin(anAngle2);
}
}
else
{
if ( myMode == 0 ) {
else {
if (myMode == 0) { // XYZ
xyz.x = Group3Spin->SpinBox_DX->value();
xyz.y = Group3Spin->SpinBox_DY->value();
xyz.z = Group3Spin->SpinBox_DZ->value();
xyz.command = "TT ";
}
else{
else { // DXDYDZ
xyz = getLastPoint();
xyz.x += Group3Spin->SpinBox_DX->value();
xyz.y += Group3Spin->SpinBox_DY->value();
xyz.z += Group3Spin->SpinBox_DZ->value();
xyz.command = "T ";
}
xyz.xt = Group3Spin->SpinBox_DX->text();
xyz.yt = Group3Spin->SpinBox_DY->text();
xyz.zt = Group3Spin->SpinBox_DZ->text();
double aX = Group3Spin->SpinBox_DX->value();
double aY = Group3Spin->SpinBox_DY->value();
double aZ = Group3Spin->SpinBox_DZ->value();
xyz.command +=
QString::number(aX, 'g', aPrecision) + " " +
QString::number(aY, 'g', aPrecision) + " " +
QString::number(aZ, 'g', aPrecision);
xyz.params =
Group3Spin->SpinBox_DX->text() + ":" +
Group3Spin->SpinBox_DY->text() + ":" +
Group3Spin->SpinBox_DZ->text();
}
return xyz;
}
@ -996,10 +1028,10 @@ void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode)
Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis);
anIO->SetSelectionMode(selMode);
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (aSPrs)
{
if (aSPrs) {
aSPrs->PrependObject(anIO);
GEOMBase_Helper::displayPreview(aSPrs, true, true);
}
@ -1009,7 +1041,8 @@ void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode)
// Function : displayAngle()
// Purpose : Method for displaying angle dimensions
//================================================================
void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, double theLength, int theOrientation, bool store)
void EntityGUI_3DSketcherDlg::displayAngle (double theAngle1, double theAngle2,
double theLength, int theOrientation, bool store)
{
if (Abs(theAngle2 - 90.0) < Precision::Angular() ||
theLength < Precision::Confusion())
@ -1070,7 +1103,8 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
std::string Angle2_str = doubleToString(theAngle2);
// Create interactive object
Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180.,
Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension
(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180.,
TCollection_ExtendedString(Angle1_str.c_str()));
anAngleIO->SetArrowSize((theAngle1 * M_PI / 180) * (theLength/20));
@ -1081,7 +1115,8 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
asp->LineAspect()->SetWidth(w);
anAngleIO->Attributes()->SetAngleAspect(asp);
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (store)
{
@ -1105,7 +1140,8 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
gce_MakePln gce_MP2(Last_Pnt, P2, Current_Pnt);
Handle(Geom_Plane) aPlane2 = new Geom_Plane(gce_MP2.Value());
Handle(AIS_AngleDimension) anAngle2IO = new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180.,
Handle(AIS_AngleDimension) anAngle2IO =
new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180.,
TCollection_ExtendedString(Angle2_str.c_str()));
anAngle2IO->SetArrowSize((theAngle2 * M_PI / 180) * (theLength/20));
@ -1217,7 +1253,8 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
gce_MakePln gce_MP(P1, Normal);
Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension(aVert1,
Handle(AIS_LengthDimension) anIO =
new AIS_LengthDimension(aVert1,
aVert2,
aPlane,
aLength,
@ -1244,7 +1281,8 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
}
else if (isLengthVisible)
{
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (aSPrs)
{
aSPrs->PrependObject(anIO);

View File

@ -15,12 +15,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_3DSketcherDlg.h
// Author : DMV, OCN
//
#ifndef ENTITYGUI_3DSKETCHERDLG_H
#define ENTITYGUI_3DSKETCHERDLG_H
@ -53,9 +52,10 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
struct XYZ
{
XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; }
double x, y, z;
QString xt, yt, zt;
XYZ() { x = y = z = 0.0; command = params = ""; }
double x, y, z; // for preview only
QString command;
QString params;
};
typedef QList<XYZ> XYZList;

View File

@ -961,7 +961,7 @@ std::list<int> GEOM_Engine::getAllTextures(int theDocID)
//=============================================================================
/*!
* ProcessFunction: Dump fucntion description into script
* ProcessFunction: Dump function description into script
*/
//=============================================================================
bool ProcessFunction(Handle(GEOM_Function)& theFunction,
@ -1036,6 +1036,95 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction,
//Replace parameter by notebook variables
ReplaceVariables(aDescr,theVariables);
//Process sketcher functions, replacing string command by calls to Sketcher interface
if (aDescr.Search( "Make3DSketcher" ) != -1) {
TCollection_AsciiString aNewDescr;
int i = 1;
TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i);
for (; !aSubStr.IsEmpty(); aSubStr = aDescr.Token("\n\t", i)) {
if (aSubStr.Search( "Make3DSketcherCommand" ) != -1) {
TCollection_AsciiString aResult = aSubStr.Token(" ", 1);
// "3DSketcher:CMD[:CMD[:CMD...]]"
TCollection_AsciiString aCommand = aSubStr.Token("\"", 2);
// Split the command string to separate CMDs
int icmd = 2;
TColStd_SequenceOfAsciiString aSequence;
if (aCommand.Length()) {
TCollection_AsciiString aToken = aCommand.Token(":", icmd);
while (aToken.Length() > 0) {
aSequence.Append(aToken);
aToken = aCommand.Token(":", ++icmd);
}
}
if (aSequence.Length() > 0) {
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += "sk = geompy.Sketcher3D()";
int nbCMDs = aSequence.Length();
for (icmd = 1; icmd <= nbCMDs; icmd++) {
aNewDescr += "\n\t";
TCollection_AsciiString aCMD = aSequence.Value(icmd);
// Split the CMD into string values
TColStd_SequenceOfAsciiString aStrVals;
int ival = 1;
TCollection_AsciiString aToken = aCMD.Token(" ", ival);
while (aToken.Length() > 0) {
aStrVals.Append(aToken);
aToken = aCMD.Token(" ", ++ival);
}
TCollection_AsciiString aCMDpref = aStrVals.Value(1);
if (aCMDpref == "TT") {
aNewDescr += "sk.addPointsAbsolute(";
aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
else if (aCMDpref == "T") {
aNewDescr += "sk.addPointsRelative(";
aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
else if (aCMDpref == "WW") {
aNewDescr += "sk.close()";
}
else {
aNewDescr += "sk.addPointAnglesLength(\"";
aNewDescr += aCMDpref + "\", " +
aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
}
aNewDescr += "\n\t";
aNewDescr += aResult + " = sk.wire()";
}
} // Make3DSketcherCommand
else if (aSubStr.Search( "Make3DSketcher" ) != -1) {
TCollection_AsciiString aResult = aSubStr.Token(" ", 1);
TCollection_AsciiString aCommand = aSubStr.Token("[", 2);
aCommand = aCommand.Token("]", 1);
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += "sk = geompy.Sketcher3D()";
aNewDescr += "\n\t";
aNewDescr += "sk.addPointsAbsolute(";
aNewDescr += aCommand + ")";
aNewDescr += "\n\t";
aNewDescr += aResult + " = sk.wire()";
}
else {
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += aSubStr;
}
i++;
}
aDescr = aNewDescr;
}
if ( theIsDumpCollected ) {
int i = 1;
bool isBefore = true;

View File

@ -15,7 +15,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
@ -26,9 +25,13 @@
#include <GEOMImpl_IMeasureOperations.hxx>
#include <Basics_Utils.hxx>
// OCCT Includes
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
@ -68,6 +71,7 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
TopoDS_Shape aShape;
if (aFunction->GetType() == SKETCHER3D_COORDS) {
Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
int anArrayLength = aCoordsArray->Length();
@ -99,6 +103,196 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
if (aMakePoly.IsDone())
aShape = aMakePoly.Wire();
}
}
else if (aFunction->GetType() == SKETCHER3D_COMMAND) {
Kernel_Utils::Localizer loc;
TCollection_AsciiString aCommand = aCI.GetCommand();
// "3DSketcher:CMD[:CMD[:CMD...]]"
// Split the command string to separate CMDs
int icmd = 2;
TColStd_SequenceOfAsciiString aSequence;
if (aCommand.Length()) {
TCollection_AsciiString aToken = aCommand.Token(":", icmd);
while (aToken.Length() > 0) {
aSequence.Append(aToken);
aToken = aCommand.Token(":", ++icmd);
}
}
int nbEdges = 0;
bool isFirstPointSet = false;
gp_XYZ p = gp::Origin().XYZ();
BRepBuilderAPI_MakeVertex MV0 (p);
TopoDS_Vertex V = TopoDS::Vertex(MV0.Shape());
gp_XYZ p0 = p;
TopoDS_Vertex V0 = V;
bool doClose = false;
BRepBuilderAPI_MakeWire MW;
int nbCMDs = aSequence.Length();
for (icmd = 1; icmd <= nbCMDs; icmd++) {
TCollection_AsciiString aCMD = aSequence.Value(icmd);
// Split the CMD into string values
TColStd_SequenceOfAsciiString aStrVals;
int ival = 1;
TCollection_AsciiString aToken = aCMD.Token(" ", ival);
while (aToken.Length() > 0) {
aStrVals.Append(aToken);
aToken = aCMD.Token(" ", ++ival);
}
// "TT x y z" : Create segment by point at X & Y or set the first point
// "T dx dy dz" : Create segment by point with DX & DY
//
// "OXY angleX angle2 length" : Create segment by two angles and length
// "OYZ angleY angle2 length" : Create segment by two angles and length
// "OXZ angleX angle2 length" : Create segment by two angles and length
//
// "WW" : Close Wire (to finish)
switch (aStrVals.Value(1).Value(1))
{
case 'T':
{
if (aStrVals.Length() != 4)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
gp_XYZ vp;
vp.SetX(aStrVals.Value(2).RealValue());
vp.SetY(aStrVals.Value(3).RealValue());
vp.SetZ(aStrVals.Value(4).RealValue());
if (aStrVals.Value(1) == "TT") { // absolute coordinates
if (!isFirstPointSet) {
p = vp;
BRepBuilderAPI_MakeVertex MV (p);
V = TopoDS::Vertex(MV.Shape());
p0 = p;
V0 = V;
isFirstPointSet = true;
}
else {
if ((vp - p).SquareModulus() > Precision::Confusion()) {
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
}
}
else if (aStrVals.Value(1) == "T") { // relative coordinates
if (vp.SquareModulus() > Precision::Confusion()) {
vp = p + vp;
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
}
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
break;
case 'O':
{
if (aStrVals.Length() != 4)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
double anAngle = aStrVals.Value(2).RealValue() * M_PI/180.0;
double anAngle2 = aStrVals.Value(3).RealValue() * M_PI/180.0;
double aLength = aStrVals.Value(4).RealValue();
double aProjectedLength = aLength * cos(anAngle2);
gp_XYZ vp;
vp.SetX(aStrVals.Value(2).RealValue());
vp.SetY(aStrVals.Value(3).RealValue());
vp.SetZ(aStrVals.Value(4).RealValue());
if (aStrVals.Value(1) == "OXY") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aProjectedLength * sin(anAngle));
vp.SetZ(p.Z() + aLength * sin(anAngle2));
}
else if (aStrVals.Value(1) == "OYZ") {
vp.SetX(p.X() + aLength * sin(anAngle2));
vp.SetY(p.Y() + aProjectedLength * cos(anAngle));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
}
else if (aStrVals.Value(1) == "OXZ") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aLength * sin(anAngle2));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
}
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
break;
case 'W':
{
if (aStrVals.Length() != 1)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
if (aStrVals.Value(1) == "WW")
doClose = true;
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
break;
default:
{
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
}
}
if (doClose &&
nbEdges > 1 && // as 3D sketcher has only straight edges
(p - p0).SquareModulus() > Precision::Confusion()) {
BRepBuilderAPI_MakeEdge ME (V, V0);
MW.Add(ME);
nbEdges++;
}
if (nbEdges > 0) {
if (!MW.IsDone())
Standard_ConstructionError::Raise("3D Sketcher error: Wire construction failed.");
aShape = MW;
}
else {
if (isFirstPointSet) {
aShape = V0;
}
}
}
else {
}
if (aShape.IsNull()) return 0;

View File

@ -15,16 +15,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//NOTE: This is an interface to a function for the Sketcher creation.
//
#include "GEOM_Function.hxx"
#include <TColStd_HArray1OfReal.hxx>
#define SKETCH_ARG_COORDS 1
class GEOMImpl_I3DSketcher
{
public:
@ -36,7 +33,17 @@ class GEOMImpl_I3DSketcher
Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); }
void SetCommand (const TCollection_AsciiString& theCommand)
{ _func->SetString(SKETCH_ARG_COMMAND, theCommand); }
TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_COMMAND); }
private:
enum {
SKETCH_ARG_COORDS = 1,
SKETCH_ARG_COMMAND = 2
};
Handle(GEOM_Function) _func;
};

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT
// E.A. : On windows with python 2.6, there is a conflict
@ -1166,73 +1165,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
return aSketcher;
}
//=============================================================================
/*!
* Make3DSketcher
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
{
SetErrorCode(KO);
//Add a new Sketcher object
Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
int nbOfCoords = 0;
std::list<double>::iterator it = theCoordinates.begin();
for (; it != theCoordinates.end(); it++)
nbOfCoords++;
Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
it = theCoordinates.begin();
int ind = 1;
for (; it != theCoordinates.end(); it++, ind++)
aCoordsArray->SetValue(ind, *it);
aCI.SetCoordinates(aCoordsArray);
//Compute the Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D 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 pd (aFunction);
pd << a3DSketcher << " = geompy.Make3DSketcher([";
it = theCoordinates.begin();
pd << (*it++);
while (it != theCoordinates.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK);
return a3DSketcher;
}
//=============================================================================
/*!
* MakeSketcherOnPlane
@ -1289,3 +1221,121 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
SetErrorCode(OK);
return aSketcher;
}
//=============================================================================
/*!
* Make3DSketcherCommand
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const char* theCommand)
{
SetErrorCode(KO);
if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
//Add a new Sketcher object
Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
TCollection_AsciiString aCommand ((char*) theCommand);
aCI.SetCommand(aCommand);
//Compute the 3D Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D 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 pd (aFunction);
pd << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")";
SetErrorCode(OK);
return aSketcher;
}
//=============================================================================
/*!
* Make3DSketcher
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
{
SetErrorCode(KO);
//Add a new Sketcher object
Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
int nbOfCoords = 0;
std::list<double>::iterator it = theCoordinates.begin();
for (; it != theCoordinates.end(); it++)
nbOfCoords++;
Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
it = theCoordinates.begin();
int ind = 1;
for (; it != theCoordinates.end(); it++, ind++)
aCoordsArray->SetValue(ind, *it);
aCI.SetCoordinates(aCoordsArray);
//Compute the Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D 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 pd (aFunction);
pd << a3DSketcher << " = geompy.Make3DSketcher([";
it = theCoordinates.begin();
pd << (*it++);
while (it != theCoordinates.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK);
return a3DSketcher;
}

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_ICurvesOperations_HXX_
#define _GEOMImpl_ICurvesOperations_HXX_
@ -78,16 +77,17 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
bool theIsClosed = false,
bool theDoReordering = false);
Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
CurveType theCurveType,
int theParamNbStep=0, bool theNewMethod=false);
CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false);
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
std::list<double> theWorkingPlane);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
Handle(GEOM_Object) theWorkingPlane);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcherCommand (const char* theCommand);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
};
#endif

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM_Object types
@ -297,6 +296,9 @@
#define SKETCHER_NINE_DOUBLS 1
#define SKETCHER_PLANE 2
#define SKETCHER3D_COORDS 1
#define SKETCHER3D_COMMAND 2
// Measures
#define CDG_MEASURE 1
#define VECTOR_FACE_NORMALE 4

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
@ -433,9 +432,11 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
* MakeCurveParametric
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
GEOM::curve_type theCurveType) {
GEOM::curve_type theCurveType)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
@ -455,7 +456,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char*
break;
}
// Make Polyline
Handle(GEOM_Object) anObject =
GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
@ -473,9 +473,11 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char*
* MakeCurveParametricNew
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
GEOM::curve_type theCurveType) {
GEOM::curve_type theCurveType)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
@ -495,7 +497,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const cha
break;
}
// Make Polyline
Handle(GEOM_Object) anObject =
GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
@ -534,6 +535,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeSketcherOnPlane
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
//Set a not done flag
GetOperations()->SetNotDone();
Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
// Make Sketcher
Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}
//=============================================================================
/*!
* Make3DSketcherCommand
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
{
//Set a not done flag
GetOperations()->SetNotDone();
// Make 3D Sketcher
Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}
//=============================================================================
/*!
* Make3DSketcher
@ -559,25 +600,3 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeSketcherOnPlane
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
//Set a not done flag
GetOperations()->SetNotDone();
Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
// Make Sketcher
Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_ICurvesOperations_i_HeaderFile
#define _GEOM_ICurvesOperations_i_HeaderFile
@ -86,20 +85,24 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
CORBA::Boolean theIsClosed,
CORBA::Boolean theDoReordering);
GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
GEOM::GEOM_Object_ptr MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
GEOM::curve_type theCurveType);
GEOM::GEOM_Object_ptr MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
GEOM::GEOM_Object_ptr MakeCurveParametricNew
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
GEOM::curve_type theCurveType);
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane);
GEOM::GEOM_Object_ptr Make3DSketcherCommand (const char* theCommand);
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
::GEOMImpl_ICurvesOperations* GetOperations()
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
};

View File

@ -1622,7 +1622,6 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# - "C radius length" : Create arc by direction, radius and length(in degree)
# - "AA x y": Create arc by point at X & Y
# - "A dx dy" : Create arc by point with DX & DY
# - "A dx dy" : Create arc by point with DX & DY
# - "UU x y radius flag1": Create arc by point at X & Y with given radiUs
# - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs
# - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
@ -1672,7 +1671,6 @@ class geompyDC(GEOM._objref_GEOM_Gen):
- "C radius length" : Create arc by direction, radius and length(in degree)
- "AA x y": Create arc by point at X & Y
- "A dx dy" : Create arc by point with DX & DY
- "A dx dy" : Create arc by point with DX & DY
- "UU x y radius flag1": Create arc by point at X & Y with given radiUs
- "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs
- "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
@ -1729,8 +1727,10 @@ class geompyDC(GEOM._objref_GEOM_Gen):
Returns:
New GEOM.GEOM_Object, containing the created wire.
"""
theCommand,Parameters = ParseSketcherCommand(theCommand)
anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp)
anObj.SetParameters(Parameters)
return anObj
## Create a sketcher wire, following the numerical description,
@ -1758,6 +1758,21 @@ class geompyDC(GEOM._objref_GEOM_Gen):
anObj.SetParameters(Parameters)
return anObj
## Obtain a 3D sketcher interface
def Sketcher3D (self):
"""
Example of usage:
sk = geompy.Sketcher3D()
sk.addPointsAbsolute(0, 0, 0)
sk.addPointsAbsolute(70, 0, 0)
sk.addPointsRelative(0, 0, 130)
sk.addPointAnglesLength("OXY", 50, 0, 100)
sk.addPointAnglesLength("OXZ", 30, 80, 130)
a3D_Sketcher_1 = sk.makeWire()
"""
sk = Sketcher3D (self)
return sk
# end of l3_sketcher
## @}
@ -8836,6 +8851,67 @@ class geompyDC(GEOM._objref_GEOM_Gen):
RaiseIfFailed("AddTexture", self.InsertOp)
return ID
## 3D Sketcher functionality
## Use geompy.Sketcher3D() to obtain an instance of this class
def printVar (var):
if isinstance(var, str):
return "\'%s\'"%var
else:
return "%.7f"%var
class Sketcher3D:
def __init__(self, geompyD):
self.geompyD = geompyD
self.myCommand = "3DSketcher"
pass
def addPointsAbsolute (self, *listCoords):
ii = 1
for cc in listCoords:
if ii == 1:
self.myCommand = self.myCommand + ":TT"
#self.myCommand = self.myCommand + " %.7f"%cc
self.myCommand = self.myCommand + " %s"%printVar(cc)
if ii == 3:
ii = 1
else:
ii = ii + 1
pass
def addPointsRelative (self, *listCoords):
ii = 1
for cc in listCoords:
if ii == 1:
self.myCommand = self.myCommand + ":T"
#self.myCommand = self.myCommand + " %.7f"%cc
self.myCommand = self.myCommand + " %s"%printVar(cc)
if ii == 3:
ii = 1
else:
ii = ii + 1
pass
## axes can be: "OXY", "OYZ" or "OXZ"
def addPointAnglesLength (self, axes, angle1, angle2, length):
#self.myCommand = self.myCommand + ":%s %.7f %.7f %.7f" % (axes, angle1, angle2, length)
self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length))
pass
def close (self):
self.myCommand = self.myCommand + ":WW"
pass
## Obtain the sketcher result
def wire (self):
print "myCommand =", self.myCommand
Command,Parameters = ParseSketcherCommand(self.myCommand)
print "Command =", Command
wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command)
self.myCommand = "3DSketcher"
RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp)
wire.SetParameters(Parameters)
return wire
import omniORB
#Register the new proxy for GEOM_Gen
omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC)