-using namespace std;
-
-#include "GEOMImpl_ICurvesOperations.hxx"
-
-#include "GEOM_Function.hxx"
-#include "GEOMImpl_Types.hxx"
-
-#include "GEOMImpl_PolylineDriver.hxx"
-#include "GEOMImpl_CircleDriver.hxx"
-#include "GEOMImpl_SplineDriver.hxx"
-#include "GEOMImpl_EllipseDriver.hxx"
-#include "GEOMImpl_ArcDriver.hxx"
-#include "GEOMImpl_SketcherDriver.hxx"
-
-#include "GEOMImpl_IPolyline.hxx"
-#include "GEOMImpl_ICircle.hxx"
-#include "GEOMImpl_ISpline.hxx"
-#include "GEOMImpl_IEllipse.hxx"
-#include "GEOMImpl_IArc.hxx"
-#include "GEOMImpl_ISketcher.hxx"
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// 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>
+
+#include <GEOMImpl_ICurvesOperations.hxx>
+
+#include <GEOM_Function.hxx>
+#include <GEOM_PythonDump.hxx>
+
+#include <GEOMImpl_Types.hxx>
+
+#include <GEOMImpl_PolylineDriver.hxx>
+#include <GEOMImpl_CircleDriver.hxx>
+#include <GEOMImpl_SplineDriver.hxx>
+#include <GEOMImpl_EllipseDriver.hxx>
+#include <GEOMImpl_ArcDriver.hxx>
+#include <GEOMImpl_SketcherDriver.hxx>
+
+#include <GEOMImpl_IPolyline.hxx>
+#include <GEOMImpl_ICircle.hxx>
+#include <GEOMImpl_ISpline.hxx>
+#include <GEOMImpl_IEllipse.hxx>
+#include <GEOMImpl_IArc.hxx>
+#include <GEOMImpl_ISketcher.hxx>
#include "utilities.h"
#include <TDF_Tool.hxx>
+#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=============================================================================
//Compute the Polyline value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Polyline driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(aPolyline->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakePolyline([";
+ GEOM::TPythonDump pd (aFunction);
+ pd << aPolyline << " = geompy.MakePolyline([";
+
it = thePoints.begin();
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- it++;
- aDescr += (anEntry+", ");
- for (; it != thePoints.end(); it++) {
- aDescr += ", ";
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- aDescr += anEntry;
+ pd << (*it++);
+ while (it != thePoints.end()) {
+ pd << ", " << (*it++);
}
- aDescr += "])";
-
- aFunction->SetDescription(aDescr);
+ pd << "])";
SetErrorCode(OK);
return aPolyline;
//Compute the Circle value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Circle driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(aCircle->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeCircleThreePnt(";
- TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(thePnt3->GetEntry(), anEntry);
- aDescr += (anEntry+")");
-
- aFunction->SetDescription(aDescr);
+ GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
+ << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
SetErrorCode(OK);
return aCircle;
//Compute the Circle value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Circle driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(aCircle->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeCirclePntVecR(";
- TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(theVec->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- aDescr += (TCollection_AsciiString(theR)+")");
-
- aFunction->SetDescription(aDescr);
+ GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
+ << thePnt << ", " << theVec << ", " << theR << ")";
SetErrorCode(OK);
return aCircle;
//Compute the Ellipse value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Ellipse driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(anEll->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeEllipse(";
- TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(theVec->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- aDescr += (TCollection_AsciiString(theRMajor)+", ");
- aDescr += (TCollection_AsciiString(theRMinor)+")");
-
- aFunction->SetDescription(aDescr);
+ GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+ << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
SetErrorCode(OK);
return anEll;
//Add a new Circle Arc function
Handle(GEOM_Function) aFunction =
- anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
- if (aFunction.IsNull()) return NULL;
+ anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
+ if (aFunction.IsNull()) return NULL;
+
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
-
GEOMImpl_IArc aCI (aFunction);
Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
+
if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
aCI.SetPoint1(aRefPnt1);
aCI.SetPoint2(aRefPnt2);
aCI.SetPoint3(aRefPnt3);
-
+
//Compute the Arc value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Arc driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(anArc->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeArc(";
- TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
- aDescr += (anEntry+", ");
- TDF_Tool::Entry(thePnt3->GetEntry(), anEntry);
- aDescr += (anEntry+")");
-
- aFunction->SetDescription(aDescr);
+ GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
+ << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
+
+ SetErrorCode(OK);
+ return anArc;
+}
+
+//=============================================================================
+/*!
+ * MakeArcCenter
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
+ Handle(GEOM_Object) thePnt2,
+ Handle(GEOM_Object) thePnt3,
+ bool theSense)
+{
+ SetErrorCode(KO);
+ if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
+
+ //Add a new Circle Arc object
+ Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
+
+ //Add a new Circle Arc function
+ Handle(GEOM_Function) aFunction =
+ anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
+
+ GEOMImpl_IArc aCI (aFunction);
+
+ Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
+ Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
+ Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
+
+ if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
+
+ aCI.SetPoint1(aRefPnt1);
+ aCI.SetPoint2(aRefPnt2);
+ aCI.SetPoint3(aRefPnt3);
+ aCI.SetSense(theSense);
+
+ //Compute the Arc value
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Arc 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) << anArc << " = geompy.MakeArcCenter("
+ << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
SetErrorCode(OK);
return anArc;
//Compute the Spline value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Spline driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(aSpline->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeSplineBezier([";
+ GEOM::TPythonDump pd (aFunction);
+ pd << aSpline << " = geompy.MakeBezier([";
+
it = thePoints.begin();
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- it++;
- aDescr += (anEntry+", ");
- for (; it != thePoints.end(); it++) {
- aDescr += ", ";
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- aDescr += anEntry;
+ pd << (*it++);
+ while (it != thePoints.end()) {
+ pd << ", " << (*it++);
}
- aDescr += "])";
-
- aFunction->SetDescription(aDescr);
+ pd << "])";
SetErrorCode(OK);
return aSpline;
//Compute the Spline value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Spline driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr("");
- TDF_Tool::Entry(aSpline->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeSplineInterpolation([";
+ GEOM::TPythonDump pd (aFunction);
+ pd << aSpline << " = geompy.MakeInterpol([";
+
it = thePoints.begin();
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- it++;
- aDescr += (anEntry+", ");
- for (; it != thePoints.end(); it++) {
- aDescr += ", ";
- TDF_Tool::Entry((*it)->GetEntry(), anEntry);
- aDescr += anEntry;
+ pd << (*it++);
+ while (it != thePoints.end()) {
+ pd << ", " << (*it++);
}
- aDescr += "])";
-
- aFunction->SetDescription(aDescr);
+ pd << "])";
SetErrorCode(OK);
return aSpline;
* MakeSketcher
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
- list<double> theWorkingPlane)
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher
+ (const TCollection_AsciiString& theCommand,
+ list<double> theWorkingPlane)
{
SetErrorCode(KO);
- if (!theCommand) return NULL;
- if (strcmp(theCommand, "") == 0) return NULL;
+ if (theCommand.IsEmpty()) 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_COMMAND);
+ aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
GEOMImpl_ISketcher aCI (aFunction);
- TCollection_AsciiString aCommand ((char*) theCommand);
- aCI.SetCommand(aCommand);
+ aCI.SetCommand(theCommand);
int ind = 1;
list<double>::iterator it = theWorkingPlane.begin();
//Compute the Sketcher value
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Sketcher driver failed");
return NULL;
}
//Make a Python command
- TCollection_AsciiString anEntry, aDescr;
- TDF_Tool::Entry(aSketcher->GetEntry(), anEntry);
- aDescr += anEntry;
- aDescr += " = ICurvesOperations.MakeSketcher(";
- aDescr += aCommand+", [";
+ GEOM::TPythonDump pd (aFunction);
+ pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand.ToCString() << "\", [";
it = theWorkingPlane.begin();
- aDescr += TCollection_AsciiString(*it);
- it++;
- for (; it != theWorkingPlane.end(); it++) {
- aDescr += ", ";
- aDescr += TCollection_AsciiString(*it);
+ pd << (*it++);
+ while (it != theWorkingPlane.end()) {
+ pd << ", " << (*it++);
}
+ pd << "])";
- aDescr += "])";
+ SetErrorCode(OK);
+ return aSketcher;
+}
+
+//=============================================================================
+/*!
+ * MakeSketcherOnPlane
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
+ (const TCollection_AsciiString& theCommand,
+ Handle(GEOM_Object) theWorkingPlane)
+{
+ SetErrorCode(KO);
+
+ if (theCommand.IsEmpty()) return NULL;
+
+ //Add a new Sketcher object
+ Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
- aFunction->SetDescription(aDescr);
+ //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);
+ aCI.SetCommand(theCommand);
+
+ Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
+ if (aRefPlane.IsNull()) return NULL;
+ aCI.SetWorkingPlane( aRefPlane );
+
+ //Compute the Sketcher value
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ 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.ToCString() << "\", " << theWorkingPlane << " )";
SetErrorCode(OK);
return aSketcher;