* 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);
GEOMImpl_ISketcher aCI (aFunction);
- TCollection_AsciiString aCommand ((char*) theCommand);
- aCI.SetCommand(aCommand);
+ aCI.SetCommand(theCommand);
int ind = 1;
list<double>::iterator it = theWorkingPlane.begin();
//Make a Python command
GEOM::TPythonDump pd (aFunction);
- pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand << "\", [";
+ pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand.ToCString() << "\", [";
it = theWorkingPlane.begin();
pd << (*it++);
* MakeSketcherOnPlane
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* theCommand,
- Handle(GEOM_Object) theWorkingPlane)
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
+ (const TCollection_AsciiString& theCommand,
+ Handle(GEOM_Object) 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);
if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
GEOMImpl_ISketcher aCI (aFunction);
-
- TCollection_AsciiString aCommand ((char*) theCommand);
- aCI.SetCommand(aCommand);
+ aCI.SetCommand(theCommand);
Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
if (aRefPlane.IsNull()) return NULL;
//Make a Python command
GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
- << theCommand << "\", " << theWorkingPlane << " )";
+ << theCommand.ToCString() << "\", " << theWorkingPlane << " )";
SetErrorCode(OK);
return aSketcher;
-using namespace std;
+using namespace std;
#ifndef _GEOMImpl_ICurvesOperations_HXX_
#define _GEOMImpl_ICurvesOperations_HXX_
#include "GEOM_IOperations.hxx"
+#include <TCollection_AsciiString.hxx>
+
#include <list>
class GEOM_Engine;
Standard_EXPORT Handle(GEOM_Object) MakePolyline (list<Handle(GEOM_Object)> thePoints);
Standard_EXPORT Handle(GEOM_Object) MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
- Handle(GEOM_Object) thePnt2,
- Handle(GEOM_Object) thePnt3);
+ Handle(GEOM_Object) thePnt2,
+ Handle(GEOM_Object) thePnt3);
Standard_EXPORT Handle(GEOM_Object) MakeCirclePntVecR (Handle(GEOM_Object) thePnt,
- Handle(GEOM_Object) theVec, double theR);
+ Handle(GEOM_Object) theVec, double theR);
Standard_EXPORT Handle(GEOM_Object) MakeEllipse (Handle(GEOM_Object) thePnt,
- Handle(GEOM_Object) theVec,
- double theRMajor, double theRMinor);
+ Handle(GEOM_Object) theVec,
+ double theRMajor, double theRMinor);
Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1,
- Handle(GEOM_Object) thePnt2,
- Handle(GEOM_Object) thePnt3);
+ Handle(GEOM_Object) thePnt2,
+ Handle(GEOM_Object) thePnt3);
Standard_EXPORT Handle(GEOM_Object) MakeSplineBezier (list<Handle(GEOM_Object)> thePoints);
Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolation (list<Handle(GEOM_Object)> thePoints);
- Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, list<double> theWorkingPlane);
- Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
- Handle(GEOM_Object) theWorkingPlane);
+ Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const TCollection_AsciiString& theCommand,
+ list<double> theWorkingPlane);
+ Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const TCollection_AsciiString& theCommand,
+ Handle(GEOM_Object) theWorkingPlane);
};
#endif
*/
//=============================================================================
void GEOMImpl_IInsertOperations::Export
- (const Handle(GEOM_Object) theOriginal,
- const char* theFileName,
- const char* theFormatName)
+ (const Handle(GEOM_Object) theOriginal,
+ const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theFormatName)
{
SetErrorCode(KO);
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
aCI.SetOriginal(aRefFunction);
- char* aFileName = (char*)theFileName;
- aCI.SetFileName(aFileName);
+ aCI.SetFileName(theFileName);
- char* aFormatName = (char*)theFormatName;
Handle(TCollection_HAsciiString) aHLibName;
- if (!IsSupported(Standard_False, aFormatName, aHLibName)) {
+ if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
return;
}
TCollection_AsciiString aLibName = aHLibName->String();
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal
- << ", \"" << theFileName << "\", \"" << theFormatName << "\")";
+ GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \""
+ << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
SetErrorCode(OK);
}
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
- (const char* theFileName,
- const char* theFormatName)
+ (const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theFormatName)
{
SetErrorCode(KO);
- if (!theFileName || !theFormatName) return NULL;
+ if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL;
//Add a new result object
Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
- char* aFileName = (char*)theFileName;
- aCI.SetFileName(aFileName);
+ aCI.SetFileName(theFileName);
- char* aFormatName = (char*)theFormatName;
Handle(TCollection_HAsciiString) aHLibName;
- if (!IsSupported(Standard_True, aFormatName, aHLibName)) {
+ if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
return result;
}
TCollection_AsciiString aLibName = aHLibName->String();
//Make a Python command
GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
- << theFileName << "\", \"" << theFormatName << "\")";
+ << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
SetErrorCode(OK);
return result;
//=============================================================================
Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
(const Standard_Boolean isImport,
- const TCollection_AsciiString theFormat,
+ const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName)
{
if (!InitResMgr()) return Standard_False;
// Import/Export mode
- Standard_CString aMode;
+ TCollection_AsciiString aMode;
+ //Standard_CString aMode;
if (isImport) aMode = "Import";
else aMode = "Export";
// Read supported formats for the certain mode
- if (myResMgr->Find(aMode)) {
- TCollection_AsciiString aFormats (myResMgr->Value(aMode));
+ if (myResMgr->Find(aMode.ToCString())) {
+ TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
if (aFormats.Search(theFormat) > -1) {
// Read library name for the supported format
TCollection_AsciiString aKey (theFormat);
Standard_EXPORT Handle(GEOM_Object) MakeCopy (Handle(GEOM_Object) theOriginal);
-
- Standard_EXPORT Handle(GEOM_Object) Import (const char* theFileName, const char* theFormatType);
-
- Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
- const char* theFileName,
- const char* theFormatType);
+
+ Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theFormatType);
+
+ Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
+ const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theFormatType);
Standard_EXPORT Standard_Boolean ImportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
- Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
+ Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
Standard_EXPORT Standard_Boolean ExportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
- Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
+ Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
Standard_EXPORT Standard_Boolean IsSupported (const Standard_Boolean isImport,
- const TCollection_AsciiString theFormat,
- Handle(TCollection_HAsciiString)& theLibName);
+ const TCollection_AsciiString& theFormat,
+ Handle(TCollection_HAsciiString)& theLibName);
private:
Standard_Boolean InitResMgr ();
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
- (list<Handle(GEOM_Object)> theShapes,
- const Standard_Integer theObjectType,
- const Standard_Integer theFunctionType,
- const TCollection_AsciiString theMethodName)
+ (list<Handle(GEOM_Object)> theShapes,
+ const Standard_Integer theObjectType,
+ const Standard_Integer theFunctionType,
+ const TCollection_AsciiString& theMethodName)
{
SetErrorCode(KO);
Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
private:
- Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
- const Standard_Integer theObjectType,
- const Standard_Integer theFunctionType,
- const TCollection_AsciiString theMethodName);
+ Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
+ const Standard_Integer theObjectType,
+ const Standard_Integer theFunctionType,
+ const TCollection_AsciiString& theMethodName);
bool CheckTriangulation (const TopoDS_Shape& aShape);
};
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
(const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
{
- GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
-
//Set a not done flag
GetOperations()->SetNotDone();
// Make Sketcher
Handle(GEOM_Object) anObject =
- GetOperations()->MakeSketcher(strdup(theCommand), aWorkingPlane);
+ GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
- //return aGEOMObject._retn();
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
- GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
-
//Set a not done flag
GetOperations()->SetNotDone();
// Make Sketcher
Handle(GEOM_Object) anObject =
- GetOperations()->MakeSketcherOnPlane(strdup(theCommand), aWorkingPlane);
+ GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
- return aGEOMObject._retn();
+ return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}
// GEOM SKETCHER : basic sketcher
//
// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Sketcher_Profile.cxx
// Author : Damien COQUERET
// Module : GEOM
-// $Header:
+// $Header:
#include <Standard_Stream.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Ax2.hxx>
#include <BRepLib.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <GeomAPI.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom_Surface.hxx>
+
#include <Precision.hxx>
-#include <GeomAPI.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Ax2.hxx>
#include <TCollection_AsciiString.hxx>
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <TColStd_Array1OfAsciiString.hxx>
#include "utilities.h"
myOK = Standard_False;
- TCollection_AsciiString aCommand(CORBA::string_dup(aCmd));
+ //TCollection_AsciiString aCommand(CORBA::string_dup(aCmd));
+ TCollection_AsciiString aCommand ((char*)aCmd);
TCollection_AsciiString aToken = aCommand.Token(":", 1);
int n = 0;
// porting to WNT
- TCollection_AsciiString* aTab = 0;
+ TColStd_Array1OfAsciiString aTab (0, aCommand.Length() - 1);
if ( aCommand.Length() )
{
- aTab = new TCollection_AsciiString[ aCommand.Length() ];
while(aToken.Length() != 0) {
if(aCommand.Token(":", n + 1).Length() > 0)
- aTab[n] = aCommand.Token(":", n + 1);
+ aTab(n) = aCommand.Token(":", n + 1);
aToken = aCommand.Token(":", ++n);
}
n = n - 1;
}
- if ( aTab && aTab[0].Length() )
+ if ( aTab.Length() && aTab(0).Length() )
while(i < n) {
Standard_Real length = 0, radius = 0, angle = 0;
move = point;
-
+
int n1 = 0;
- TCollection_AsciiString* a = new TCollection_AsciiString[ aTab[0].Length() ];
- aToken = aTab[i].Token(" ", 1);
- while(aToken.Length() != 0) {
- if(aTab[i].Token(" ", n1 + 1).Length() > 0)
- a[n1] = aTab[i].Token(" ", n1 + 1);
- aToken = aTab[i].Token(" ", ++n1);
+ TColStd_Array1OfAsciiString a (0, aTab(0).Length());
+ aToken = aTab(i).Token(" ", 1);
+ while (aToken.Length() != 0) {
+ if (aTab(i).Token(" ", n1 + 1).Length() > 0)
+ a(n1) = aTab(i).Token(" ", n1 + 1);
+ aToken = aTab(i).Token(" ", ++n1);
}
n1 = n1 - 1;
-
- switch(a[0].Value(1))
+
+ switch(a(0).Value(1))
{
case 'F':
{
MESSAGE("profile : The F instruction must precede all moves");
return;
}
- x0 = x = a[1].RealValue();
- y0 = y = a[2].RealValue();
+ x0 = x = a(1).RealValue();
+ y0 = y = a(2).RealValue();
stayfirst = Standard_True;
break;
}
case 'O':
{
if (n1 != 4) goto badargs;
- P.SetLocation(gp_Pnt(a[1].RealValue(), a[2].RealValue(), a[3].RealValue()));
+ P.SetLocation(gp_Pnt(a(1).RealValue(), a(2).RealValue(), a(3).RealValue()));
stayfirst = Standard_True;
break;
}
case 'P':
{
if (n1 != 7) goto badargs;
- gp_Vec vn(a[1].RealValue(), a[2].RealValue(), a[3].RealValue());
- gp_Vec vx(a[4].RealValue(), a[5].RealValue(), a[6].RealValue());
+ gp_Vec vn(a(1).RealValue(), a(2).RealValue(), a(3).RealValue());
+ gp_Vec vx(a(4).RealValue(), a(5).RealValue(), a(6).RealValue());
if (vn.Magnitude() <= Precision::Confusion() || vx.Magnitude() <= Precision::Confusion()) {
MESSAGE("profile : null direction");
return;
case 'X':
{
if (n1 != 2) goto badargs;
- length = a[1].RealValue();
- if (a[0] == "XX")
+ length = a(1).RealValue();
+ if (a(0) == "XX")
length -= x;
dx = 1; dy = 0;
move = line;
case 'Y':
{
if (n1 != 2) goto badargs;
- length = a[1].RealValue();
- if (a[0] == "YY")
+ length = a(1).RealValue();
+ if (a(0) == "YY")
length -= y;
dx = 0; dy = 1;
move = line;
case 'L':
{
if (n1 != 2) goto badargs;
- length = a[1].RealValue();
+ length = a(1).RealValue();
if (Abs(length) > Precision::Confusion())
move = line;
else
case 'T':
{
if (n1 != 3) goto badargs;
- Standard_Real vx = a[1].RealValue();
- Standard_Real vy = a[2].RealValue();
- if (a[0] == "TT") {
+ Standard_Real vx = a(1).RealValue();
+ Standard_Real vy = a(2).RealValue();
+ if (a(0) == "TT") {
vx -= x;
vy -= y;
}
case 'R':
{
if (n1 != 2) goto badargs;
- angle = a[1].RealValue() * PI180;
- if (a[0] == "RR") {
+ angle = a(1).RealValue() * PI180;
+ if (a(0) == "RR") {
dx = Cos(angle);
dy = Sin(angle);
}
case 'D':
{
if (n1 != 3) goto badargs;
- Standard_Real vx = a[1].RealValue();
- Standard_Real vy = a[2].RealValue();
+ Standard_Real vx = a(1).RealValue();
+ Standard_Real vy = a(2).RealValue();
length = Sqrt(vx * vx + vy * vy);
if (length > Precision::Confusion()) {
dx = vx / length;
case 'C':
{
if (n1 != 3) goto badargs;
- radius = a[1].RealValue();
+ radius = a(1).RealValue();
if (Abs(radius) > Precision::Confusion()) {
- angle = a[2].RealValue() * PI180;
+ angle = a(2).RealValue() * PI180;
move = circle;
}
else
case 'I':
{
if (n1 != 2) goto badargs;
- length = a[1].RealValue();
- if (a[0] == "IX") {
+ length = a(1).RealValue();
+ if (a(0) == "IX") {
if (Abs(dx) < Precision::Confusion()) {
MESSAGE("profile : cannot intersect, arg "<<i-1);
return;
}
length = (length - x) / dx;
}
- else if (a[0] == "IY") {
+ else if (a(0) == "IY") {
if (Abs(dy) < Precision::Confusion()) {
MESSAGE("profile : cannot intersect, arg "<<i-1);
return;
}
case 'W':
{
- if (a[0] == "WW")
+ if (a(0) == "WW")
close = Standard_True;
- else if(a[0] == "WF") {
+ else if(a(0) == "WF") {
close = Standard_True;
face = Standard_True;
}
}
default:
{
- MESSAGE("profile : unknown code "<<a[i]);
+ MESSAGE("profile : unknown code " << a(i));
return;
}
}
again :
- switch (move)
+ switch (move)
{
case line :
{
break;
}
}
-
+
// update first
first = stayfirst;
stayfirst = Standard_False;
-
+
if(!(dx == 0 && dy == 0))
myLastDir.SetCoord(dx, dy, 0.0);
else
return;
myLastPoint.SetX(x);
myLastPoint.SetY(y);
-
+
// next segment....
i++;
if ((i == n) && close) {
goto again;
}
}
- delete a;
}
- delete aTab;
- aTab = 0;
-
+
// get the result, face or wire
if (move == none) {
return;
}
S = MW;
}
-
+
if(!TheLocation.IsIdentity())
S.Move(TheLocation);