/*!
* \brief Kind of the curves.
*
- * Used in the functions GEOM_ICurvesOperations.MakeCurveParametric(), GEOM_ICurvesOperations.MakeCurveParametricNew()
+ * Used in the functions GEOM_ICurvesOperations.MakeCurveParametric(), GEOM_ICurvesOperations.MakeCurveParametricNew(),
+ * GEOM_ICurvesOperations.MakePolyline2D, GEOM_ICurvesOperations.MakePolyline2DOnPlane.
*/
enum curve_type {
/*! Polyline curve */
};
- typedef sequence<string> string_array;
- typedef sequence<short> short_array;
- typedef sequence<boolean> ListOfBool;
- typedef sequence<long> ListOfLong;
- typedef sequence<double> ListOfDouble;
+ typedef sequence<string> string_array;
+ typedef sequence<short> short_array;
+ typedef sequence<boolean> ListOfBool;
+ typedef sequence<long> ListOfLong;
+ typedef sequence<double> ListOfDouble;
+ typedef sequence<ListOfDouble> ListOfListOfDouble;
interface GEOM_Object;
interface GEOM_BaseObject;
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
+
+ /*!
+ * \brief Create a 2D polyline (wire or a compound of wires).
+ *
+ * The polyline can have several sections. Each section represents a set
+ * of points in the form of list of coordinates of the following order:
+ * x1, y1, x2, y2, ..., xN, yN
+ * Each section has its own name, type of curve (can be either
+ * GEOM::Polyline or GEOM::Interpolation) and Closed flag.
+ * For each section a wire is created. It represents either a polyline or
+ * interpolation BSpline either closed or not depending on the Closed flag.
+ * The result represents a wire if there is only one section is defined.
+ * Otherwise a compound of wires is returned.
+ *
+ * \param theCoordsList the list of coordinates list. theCoordsList[0]
+ * is the coordinates list of the first section. theCoordsList[1]
+ * is for the second section etc.
+ * \param theNamesList the list of names. The order corresponds to
+ * theCoordsList.
+ * \param theTypesList the list of curve types. The order corresponds to
+ * theCoordsList.
+ * \param theClosedList the list of Closed flags. The order corresponds to
+ * theCoordsList.
+ * \param theWorkingPlane 9 double values, defining origin,
+ * OZ and OX directions of the working plane.
+ * \return New GEOM_Object, containing the created wire or a compound
+ * of wires.
+ */
+ GEOM_Object MakePolyline2D (in ListOfListOfDouble theCoordsList,
+ in string_array theNamesList,
+ in short_array theTypesList,
+ in ListOfBool theClosedList,
+ in ListOfDouble theWorkingPlane);
+
+ /*!
+ * \brief Create a 2D polyline (wire or a compound of wires).
+ *
+ * The polyline can have several sections. Each section represents a set
+ * of points in the form of list of coordinates of the following order:
+ * x1, y1, x2, y2, ..., xN, yN
+ * Each section has its own name, type of curve (can be either
+ * GEOM::Polyline or GEOM::Interpolation) and Closed flag.
+ * For each section a wire is created. It represents either a polyline or
+ * interpolation BSpline either closed or not depending on the Closed flag.
+ * The result represents a wire if there is only one section is defined.
+ * Otherwise a compound of wires is returned.
+ *
+ * \param theCoordsList the list of coordinates list. theCoordsList[0]
+ * is the coordinates list of the first section. theCoordsList[1]
+ * is for the second section etc.
+ * \param theNamesList the list of names. The order corresponds to
+ * theCoordsList.
+ * \param theTypesList the list of curve types. The order corresponds to
+ * theCoordsList.
+ * \param theClosedList the list of Closed flags. The order corresponds to
+ * theCoordsList.
+ * \param theWorkingPlane planar Face or LCS(Marker) of the working plane.
+ * \return New GEOM_Object, containing the created wire or a compound
+ * of wires.
+ */
+ GEOM_Object MakePolyline2DOnPlane (in ListOfListOfDouble theCoordsList,
+ in string_array theNamesList,
+ in short_array theTypesList,
+ in ListOfBool theClosedList,
+ in GEOM_Object theWorkingPlane);
+
};
// # GEOM_ILocalOperations:
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)
+{
+ Handle(GEOM_Object) aResult;
+
+ 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)
+{
+ Handle(GEOM_Object) aResult;
+
+ return aResult;
+}
const bool IsUIso,
const double theParameter);
+ Standard_EXPORT Handle(GEOM_Object) 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);
+
+ Standard_EXPORT Handle(GEOM_Object) 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);
};
#endif
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
+#include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
//=============================================================================
/*!
* constructor:
return GetObject(anObject);
}
+
+//=============================================================================
+/*!
+ * MakePolyline2D
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2D
+ (const GEOM::ListOfListOfDouble &theCoordsList,
+ const GEOM::string_array &theNamesList,
+ const GEOM::short_array &theTypesList,
+ const GEOM::ListOfBool &theClosedList,
+ const GEOM::ListOfDouble &theWorkingPlane)
+{
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ // Convert input data
+ Handle(TColStd_HArray1OfExtendedString) aNames =
+ ConvertStringArray(theNamesList);
+ Handle(TColStd_HArray1OfByte) aTypes =
+ ConvertEnumArray(theTypesList);
+ Handle(TColStd_HArray1OfByte) aCloseds =
+ ConvertBoolArray(theClosedList);
+ std::list <std::list <double> > aCoords;
+
+ ConvertListListDouble(theCoordsList, aCoords);
+
+ Handle(TColStd_HArray1OfReal) aWorkingPlane;
+ const int n = theWorkingPlane.length();
+ int i;
+
+ if (n > 0) {
+ aWorkingPlane = new TColStd_HArray1OfReal(1, n);
+
+ for (i = 0; i < n; i++) {
+ aWorkingPlane->SetValue(i + 1, theWorkingPlane[i]);
+ }
+ }
+
+ // Make Polyline
+ Handle(GEOM_Object) anObject = GetOperations()->MakePolyline2D
+ (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
+
+ if (!GetOperations()->IsDone() || anObject.IsNull()) {
+ return GEOM::GEOM_Object::_nil();
+ }
+
+ return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ * MakePolylineOnPlane
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2DOnPlane
+ (const GEOM::ListOfListOfDouble &theCoordsList,
+ const GEOM::string_array &theNamesList,
+ const GEOM::short_array &theTypesList,
+ const GEOM::ListOfBool &theClosedList,
+ GEOM::GEOM_Object_ptr theWorkingPlane)
+{
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ // Convert input data
+ Handle(TColStd_HArray1OfExtendedString) aNames =
+ ConvertStringArray(theNamesList);
+ Handle(TColStd_HArray1OfByte) aTypes =
+ ConvertEnumArray(theTypesList);
+ Handle(TColStd_HArray1OfByte) aCloseds =
+ ConvertBoolArray(theClosedList);
+ std::list <std::list <double> > aCoords;
+ Handle(GEOM_Object) aWorkingPlane =
+ GetObjectImpl(theWorkingPlane);
+
+ ConvertListListDouble(theCoordsList, aCoords);
+
+ // Make Polyline
+ Handle(GEOM_Object) anObject = GetOperations()->MakePolyline2DOnPlane
+ (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
+
+ if (!GetOperations()->IsDone() || anObject.IsNull()) {
+ return GEOM::GEOM_Object::_nil();
+ }
+
+ return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ * ConvertEnumArray
+ */
+//=============================================================================
+Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertEnumArray
+ (const GEOM::short_array &theInArray)
+{
+ Handle(TColStd_HArray1OfByte) anOutArray;
+ const int n = theInArray.length();
+ int i;
+
+ if (n <= 0) {
+ return anOutArray;
+ }
+
+ anOutArray = new TColStd_HArray1OfByte(1, n);
+
+ for (i = 0; i < n; i++) {
+ bool isOK = true;
+ GEOMImpl_ICurvesOperations::CurveType aType;
+
+ switch(theInArray[i]) {
+ case GEOM::Polyline:
+ aType = GEOMImpl_ICurvesOperations::Polyline;
+ break;
+ case GEOM::Bezier:
+ aType = GEOMImpl_ICurvesOperations::Bezier;
+ break;
+ case GEOM::Interpolation:
+ aType = GEOMImpl_ICurvesOperations::Interpolation;
+ break;
+ default:
+ isOK = false;
+ break;
+ }
+
+ if (isOK) {
+ anOutArray->SetValue(i + 1, aType);
+ } else {
+ anOutArray.Nullify();
+ break;
+ }
+ }
+
+ return anOutArray;
+}
+
+//=============================================================================
+/*!
+ * ConvertBoolArray
+ */
+//=============================================================================
+Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertBoolArray
+ (const GEOM::ListOfBool &theInArray)
+{
+ Handle(TColStd_HArray1OfByte) anOutArray;
+ const int n = theInArray.length();
+ int i;
+
+ if (n <= 0) {
+ return anOutArray;
+ }
+
+ anOutArray = new TColStd_HArray1OfByte(1, n);
+
+ for (i = 0; i < n; i++) {
+ anOutArray->SetValue(i + 1, theInArray[i]);
+ }
+
+ return anOutArray;
+}
+
+//=============================================================================
+/*!
+ * ConvertListListDouble
+ */
+//=============================================================================
+void GEOM_ICurvesOperations_i::ConvertListListDouble
+ (const GEOM::ListOfListOfDouble &theInList,
+ std::list <std::list <double> > &theOutList)
+{
+ const int n = theInList.length();
+ int i;
+ std::list <double> anEmptyList;
+
+ for (i = 0; i < n; i++) {
+ theOutList.push_back(anEmptyList);
+
+ const int m = theInList[i].length();
+ int j;
+
+ for (j = 0; j < m; j++) {
+ theOutList.back().push_back(theInList[i][j]);
+ }
+ }
+}
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
+ GEOM::GEOM_Object_ptr MakePolyline2D
+ (const GEOM::ListOfListOfDouble &theCoordsList,
+ const GEOM::string_array &theNamesList,
+ const GEOM::short_array &theTypesList,
+ const GEOM::ListOfBool &theClosedList,
+ const GEOM::ListOfDouble &theWorkingPlane);
+
+ GEOM::GEOM_Object_ptr MakePolyline2DOnPlane
+ (const GEOM::ListOfListOfDouble &theCoordsList,
+ const GEOM::string_array &theNamesList,
+ const GEOM::short_array &theTypesList,
+ const GEOM::ListOfBool &theClosedList,
+ GEOM::GEOM_Object_ptr theWorkingPlane);
+
::GEOMImpl_ICurvesOperations* GetOperations()
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
+
+private:
+
+ Handle(TColStd_HArray1OfByte)
+ ConvertEnumArray(const GEOM::short_array &theInArray);
+
+ Handle(TColStd_HArray1OfByte)
+ ConvertBoolArray(const GEOM::ListOfBool &theInArray);
+
+ void ConvertListListDouble
+ (const GEOM::ListOfListOfDouble &theCoordsList,
+ std::list <std::list <double> > &theCoords);
+
};
#endif