-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
// 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>
}
-//=============================================================================
-/*!
- * MakePolyline
- */
-//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list<Handle(GEOM_Object)> thePoints)
-{
- SetErrorCode(KO);
-
- //Add a new Polyline object
- Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
-
- //Add a new Polyline function for creation a polyline relatively to points set
- Handle(GEOM_Function) aFunction =
- aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
- if (aFunction.IsNull()) return NULL;
-
- //Check if the function is set correctly
- if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
-
- GEOMImpl_IPolyline aCI (aFunction);
-
- int aLen = thePoints.size();
- aCI.SetLength(aLen);
-
- int ind = 1;
- list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
- for (; it != thePoints.end(); it++, ind++) {
- Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
- if (aRefPnt.IsNull()) {
- SetErrorCode("NULL point for Polyline");
- return NULL;
- }
- aCI.SetPoint(ind, aRefPnt);
- }
-
- //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;
- }
- }
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
- return NULL;
- }
-
- //Make a Python command
- GEOM::TPythonDump pd (aFunction);
- pd << aPolyline << " = geompy.MakePolyline([";
-
- it = thePoints.begin();
- pd << (*it++);
- while (it != thePoints.end()) {
- pd << ", " << (*it++);
- }
- pd << "])";
-
- SetErrorCode(OK);
- return aPolyline;
-}
-
//=============================================================================
/*!
* MakeCircleThreePnt
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
(Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
- double theRMajor, double theRMinor)
+ double theRMajor, double theRMinor,
+ Handle(GEOM_Object) theVecMaj)
{
SetErrorCode(KO);
// Not set thePnt means origin of global CS,
// Not set theVec means Z axis of global CS
+ // Not set theVecMaj means X axis of global CS
//if (thePnt.IsNull() || theVec.IsNull()) return NULL;
//Add a new Ellipse object
aCI.SetRMajor(theRMajor);
aCI.SetRMinor(theRMinor);
+ if (!theVecMaj.IsNull()) {
+ Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
+ if (aRefVecMaj.IsNull()) return NULL;
+ aCI.SetVectorMajor(aRefVecMaj);
+ }
+
//Compute the Ellipse value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
- << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+ if (!theVecMaj.IsNull()) {
+ GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+ << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
+ << ", " << theVecMaj << ")";
+ }
+ else {
+ GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+ << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+ }
SetErrorCode(OK);
return anEll;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
- Handle(GEOM_Object) thePnt2,
- Handle(GEOM_Object) thePnt3)
+ Handle(GEOM_Object) thePnt2,
+ Handle(GEOM_Object) thePnt3)
{
SetErrorCode(KO);
return anArc;
}
+//=============================================================================
+/*!
+ * MakePolyline
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
+ bool theIsClosed)
+{
+ SetErrorCode(KO);
+
+ //Add a new Polyline object
+ Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
+
+ //Add a new Polyline function for creation a polyline relatively to points set
+ Handle(GEOM_Function) aFunction =
+ aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
+
+ GEOMImpl_IPolyline aCI (aFunction);
+
+ int aLen = thePoints.size();
+ aCI.SetLength(aLen);
+
+ int ind = 1;
+ std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+ for (; it != thePoints.end(); it++, ind++) {
+ Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
+ if (aRefPnt.IsNull()) {
+ SetErrorCode("NULL point for Polyline");
+ return NULL;
+ }
+ aCI.SetPoint(ind, aRefPnt);
+ }
+
+ aCI.SetIsClosed(theIsClosed);
+
+ //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;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aPolyline << " = geompy.MakePolyline([";
+
+ it = thePoints.begin();
+ pd << (*it++);
+ while (it != thePoints.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "], " << theIsClosed << ")";
+
+ SetErrorCode(OK);
+ return aPolyline;
+}
+
//=============================================================================
/*!
* MakeSplineBezier
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
- (list<Handle(GEOM_Object)> thePoints)
+ (std::list<Handle(GEOM_Object)> thePoints,
+ bool theIsClosed)
{
SetErrorCode(KO);
aCI.SetLength(aLen);
int ind = 1;
- list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+ std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
for (; it != thePoints.end(); it++, ind++) {
Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
aCI.SetPoint(ind, aRefPnt);
}
+ aCI.SetIsClosed(theIsClosed);
+
//Compute the Spline value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
while (it != thePoints.end()) {
pd << ", " << (*it++);
}
- pd << "])";
+ pd << "], " << theIsClosed << ")";
SetErrorCode(OK);
return aSpline;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
- (list<Handle(GEOM_Object)> thePoints)
+ (std::list<Handle(GEOM_Object)> thePoints,
+ bool theIsClosed,
+ bool theDoReordering)
{
SetErrorCode(KO);
aCI.SetLength(aLen);
int ind = 1;
- list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+ std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
for (; it != thePoints.end(); it++, ind++) {
Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
aCI.SetPoint(ind, aRefPnt);
}
+ aCI.SetIsClosed(theIsClosed);
+ aCI.SetDoReordering(theDoReordering);
+
//Compute the Spline value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
while (it != thePoints.end()) {
pd << ", " << (*it++);
}
- pd << "])";
+ pd << "], " << theIsClosed << ", " << theDoReordering << ")";
SetErrorCode(OK);
return aSpline;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
- list<double> theWorkingPlane)
+ std::list<double> theWorkingPlane)
{
SetErrorCode(KO);
aCI.SetCommand(aCommand);
int ind = 1;
- list<double>::iterator it = theWorkingPlane.begin();
+ std::list<double>::iterator it = theWorkingPlane.begin();
for (; it != theWorkingPlane.end(); it++, ind++)
aCI.SetWorkingPlane(ind, *it);
* Make3DSketcher
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> theCoordinates)
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
{
SetErrorCode(KO);
GEOMImpl_I3DSketcher aCI (aFunction);
int nbOfCoords = 0;
- list<double>::iterator it = theCoordinates.begin();
+ std::list<double>::iterator it = theCoordinates.begin();
for (; it != theCoordinates.end(); it++)
nbOfCoords++;