-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifdef WNT
+#ifdef WIN32
// E.A. : On windows with python 2.6, there is a conflict
// E.A. : between pymath.h and Standard_math.h which define
// E.A. : some same symbols : acosh, asinh, ...
#include "GEOMImpl_SplineDriver.hxx"
#include "GEOMImpl_EllipseDriver.hxx"
#include "GEOMImpl_ArcDriver.hxx"
+#include "GEOMImpl_ShapeDriver.hxx"
#include "GEOMImpl_SketcherDriver.hxx"
#include "GEOMImpl_3DSketcherDriver.hxx"
#include "GEOMImpl_IPolyline.hxx"
+#include "GEOMImpl_IPolyline2D.hxx"
#include "GEOMImpl_ICircle.hxx"
#include "GEOMImpl_ISpline.hxx"
#include "GEOMImpl_IEllipse.hxx"
#include "GEOMImpl_ISketcher.hxx"
#include "GEOMImpl_I3DSketcher.hxx"
#include "GEOMImpl_ICurveParametric.hxx"
+#include "GEOMImpl_IIsoline.hxx"
+#include "GEOMImpl_PolylineDumper.hxx"
#include <Basics_OCCTVersion.hxx>
#include "utilities.h"
#include <TDF_Tool.hxx>
+#include <TColStd_HArray1OfByte.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Standard_Failure.hxx>
//Compute the Circle value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Circle driver failed");
return NULL;
//Compute the Circle value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Circle driver failed");
return NULL;
//Compute the Circle value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Circle driver failed");
return NULL;
//Compute the Ellipse value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Ellipse driver failed");
return NULL;
//Compute the Arc value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Arc driver failed");
return NULL;
//Compute the Arc value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
- SetErrorCode("Arc driver failed");
- return NULL;
+ SetErrorCode("Arc driver failed");
+ return NULL;
}
}
catch (Standard_Failure) {
//Compute the Arc value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Arc driver failed");
return NULL;
//Compute the Polyline value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Polyline driver failed");
return NULL;
//Compute the Spline value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Spline driver failed");
return NULL;
//Compute the Spline value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Spline driver failed");
return NULL;
//Compute the Spline value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Spline driver failed");
return NULL;
//Compute the Curve value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Curve driver failed !!!");
return NULL;
//Compute the Sketcher value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Sketcher driver failed");
return NULL;
//Compute the Sketcher value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Sketcher driver failed");
return NULL;
//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;
//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;
SetErrorCode(OK);
return a3DSketcher;
}
+
+//=============================================================================
+/*!
+ * MakeIsoline
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline
+ (const Handle(GEOM_Object) &theFace,
+ const bool IsUIso,
+ const double theParameter)
+{
+ SetErrorCode(KO);
+
+ if (theFace.IsNull()) {
+ return NULL;
+ }
+
+ //Add a new Spline object
+ Handle(GEOM_Object) anIsoline =
+ GetEngine()->AddObject(GetDocID(), GEOM_ISOLINE);
+
+ //Add a new Spline function for interpolation type
+ Handle(GEOM_Function) aFunction =
+ anIsoline->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPE_ISOLINE);
+
+ if (aFunction.IsNull()) {
+ return NULL;
+ }
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
+ return NULL;
+ }
+
+ GEOMImpl_IIsoline aCI (aFunction);
+ Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
+
+ if (aRefFace.IsNull()) {
+ return NULL;
+ }
+
+ aCI.SetFace(aRefFace);
+ aCI.SetIsUIso(IsUIso);
+ aCI.SetParameter(theParameter);
+
+ //Compute the isoline curve
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Shape 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) << anIsoline << " = geompy.MakeIsoline( "
+ << theFace << ", " << IsUIso << ", " << theParameter << " )";
+
+ SetErrorCode(OK);
+ return anIsoline;
+}
+
+//=============================================================================
+/*!
+ * MakePolyline2D
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D
+ (const std::list <std::list <double> > &theCoords,
+ const Handle(TColStd_HArray1OfExtendedString) &theNames,
+ const Handle(TColStd_HArray1OfByte) &theTypes,
+ const Handle(TColStd_HArray1OfByte) &theCloseds,
+ const Handle(TColStd_HArray1OfReal) &theWorkingPlane)
+{
+ SetErrorCode(KO);
+
+ if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
+ theCloseds.IsNull() || theWorkingPlane.IsNull()) {
+ return NULL;
+ }
+
+ // Add a new Polyline object
+ Handle(GEOM_Object) aResult =
+ GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
+ Handle(GEOM_Function) aFunction = aResult->AddFunction
+ (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS);
+
+ if (aFunction.IsNull()) {
+ return NULL;
+ }
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
+ return NULL;
+ }
+
+ GEOMImpl_IPolyline2D aCI(aFunction);
+
+ aCI.SetCoords(theCoords);
+ aCI.SetNames(theNames);
+ aCI.SetTypes(theTypes);
+ aCI.SetClosedFlags(theCloseds);
+ aCI.SetWorkingPlaneDbls(theWorkingPlane);
+
+ // Compute the isoline curve
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Polyline driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
+ theCloseds, theWorkingPlane);
+
+ aDumper.Dump(aResult);
+
+ if (aDumper.IsDone() == Standard_False) {
+ SetErrorCode("Python dump failed");
+ return NULL;
+ }
+
+ SetErrorCode(OK);
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * MakePolyline2DOnPlane
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane
+ (const std::list <std::list <double> > &theCoords,
+ const Handle(TColStd_HArray1OfExtendedString) &theNames,
+ const Handle(TColStd_HArray1OfByte) &theTypes,
+ const Handle(TColStd_HArray1OfByte) &theCloseds,
+ const Handle(GEOM_Object) &theWorkingPlane)
+{
+ SetErrorCode(KO);
+
+ if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
+ theCloseds.IsNull() || theWorkingPlane.IsNull()) {
+ return NULL;
+ }
+
+ //Add a new Polyline object
+ Handle(GEOM_Object) aResult =
+ GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
+ Handle(GEOM_Function) aFunction = aResult->AddFunction
+ (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT);
+
+ if (aFunction.IsNull()) {
+ return NULL;
+ }
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
+ return NULL;
+ }
+
+ Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
+
+ if (aRefPlane.IsNull()) {
+ return NULL;
+ }
+
+ GEOMImpl_IPolyline2D aCI(aFunction);
+
+ aCI.SetCoords(theCoords);
+ aCI.SetNames(theNames);
+ aCI.SetTypes(theTypes);
+ aCI.SetClosedFlags(theCloseds);
+ aCI.SetWorkingPlane(aRefPlane);
+
+ //Compute the isoline curve
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Polyline driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
+ theCloseds, theWorkingPlane);
+
+ aDumper.Dump(aResult);
+
+ if (aDumper.IsDone() == Standard_False) {
+ SetErrorCode("Python dump failed");
+ return NULL;
+ }
+
+ SetErrorCode(OK);
+ return aResult;
+}