Fix crashes of Sketcher and Import/Export

This commit is contained in:
jfa 2005-08-19 09:11:52 +00:00
parent 150ae46477
commit a8a220072b
8 changed files with 135 additions and 145 deletions

View File

@ -472,13 +472,13 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
* MakeSketcher * MakeSketcher
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand, Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher
list<double> theWorkingPlane) (const TCollection_AsciiString& theCommand,
list<double> theWorkingPlane)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (!theCommand) return NULL; if (theCommand.IsEmpty()) return NULL;
if (strcmp(theCommand, "") == 0) return NULL;
//Add a new Sketcher object //Add a new Sketcher object
Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
@ -493,8 +493,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
GEOMImpl_ISketcher aCI (aFunction); GEOMImpl_ISketcher aCI (aFunction);
TCollection_AsciiString aCommand ((char*) theCommand); aCI.SetCommand(theCommand);
aCI.SetCommand(aCommand);
int ind = 1; int ind = 1;
list<double>::iterator it = theWorkingPlane.begin(); list<double>::iterator it = theWorkingPlane.begin();
@ -516,7 +515,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
//Make a Python command //Make a Python command
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aFunction);
pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand << "\", ["; pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand.ToCString() << "\", [";
it = theWorkingPlane.begin(); it = theWorkingPlane.begin();
pd << (*it++); pd << (*it++);
@ -534,13 +533,13 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
* MakeSketcherOnPlane * MakeSketcherOnPlane
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* theCommand, Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
Handle(GEOM_Object) theWorkingPlane) (const TCollection_AsciiString& theCommand,
Handle(GEOM_Object) theWorkingPlane)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (!theCommand) return NULL; if (theCommand.IsEmpty()) return NULL;
if (strcmp(theCommand, "") == 0) return NULL;
//Add a new Sketcher object //Add a new Sketcher object
Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
@ -554,9 +553,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char*
if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
GEOMImpl_ISketcher aCI (aFunction); GEOMImpl_ISketcher aCI (aFunction);
aCI.SetCommand(theCommand);
TCollection_AsciiString aCommand ((char*) theCommand);
aCI.SetCommand(aCommand);
Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
if (aRefPlane.IsNull()) return NULL; if (aRefPlane.IsNull()) return NULL;
@ -577,7 +574,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char*
//Make a Python command //Make a Python command
GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\"" GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
<< theCommand << "\", " << theWorkingPlane << " )"; << theCommand.ToCString() << "\", " << theWorkingPlane << " )";
SetErrorCode(OK); SetErrorCode(OK);
return aSketcher; return aSketcher;

View File

@ -5,6 +5,8 @@ using namespace std;
#include "GEOM_IOperations.hxx" #include "GEOM_IOperations.hxx"
#include <TCollection_AsciiString.hxx>
#include <list> #include <list>
class GEOM_Engine; class GEOM_Engine;
@ -18,25 +20,26 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakePolyline (list<Handle(GEOM_Object)> thePoints); Standard_EXPORT Handle(GEOM_Object) MakePolyline (list<Handle(GEOM_Object)> thePoints);
Standard_EXPORT Handle(GEOM_Object) MakeCircleThreePnt (Handle(GEOM_Object) thePnt1, Standard_EXPORT Handle(GEOM_Object) MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt2,
Handle(GEOM_Object) thePnt3); Handle(GEOM_Object) thePnt3);
Standard_EXPORT Handle(GEOM_Object) MakeCirclePntVecR (Handle(GEOM_Object) thePnt, 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, Standard_EXPORT Handle(GEOM_Object) MakeEllipse (Handle(GEOM_Object) thePnt,
Handle(GEOM_Object) theVec, Handle(GEOM_Object) theVec,
double theRMajor, double theRMinor); double theRMajor, double theRMinor);
Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1, Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt2,
Handle(GEOM_Object) thePnt3); Handle(GEOM_Object) thePnt3);
Standard_EXPORT Handle(GEOM_Object) MakeSplineBezier (list<Handle(GEOM_Object)> thePoints); 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) MakeSplineInterpolation (list<Handle(GEOM_Object)> thePoints);
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, list<double> theWorkingPlane); Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const TCollection_AsciiString& theCommand,
Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand, list<double> theWorkingPlane);
Handle(GEOM_Object) theWorkingPlane); Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const TCollection_AsciiString& theCommand,
Handle(GEOM_Object) theWorkingPlane);
}; };
#endif #endif

View File

@ -103,9 +103,9 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the
*/ */
//============================================================================= //=============================================================================
void GEOMImpl_IInsertOperations::Export void GEOMImpl_IInsertOperations::Export
(const Handle(GEOM_Object) theOriginal, (const Handle(GEOM_Object) theOriginal,
const char* theFileName, const TCollection_AsciiString& theFileName,
const char* theFormatName) const TCollection_AsciiString& theFormatName)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -124,12 +124,10 @@ void GEOMImpl_IInsertOperations::Export
//Set parameters //Set parameters
GEOMImpl_IImportExport aCI (aFunction); GEOMImpl_IImportExport aCI (aFunction);
aCI.SetOriginal(aRefFunction); aCI.SetOriginal(aRefFunction);
char* aFileName = (char*)theFileName; aCI.SetFileName(theFileName);
aCI.SetFileName(aFileName);
char* aFormatName = (char*)theFormatName;
Handle(TCollection_HAsciiString) aHLibName; Handle(TCollection_HAsciiString) aHLibName;
if (!IsSupported(Standard_False, aFormatName, aHLibName)) { if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
return; return;
} }
TCollection_AsciiString aLibName = aHLibName->String(); TCollection_AsciiString aLibName = aHLibName->String();
@ -149,8 +147,8 @@ void GEOMImpl_IInsertOperations::Export
} }
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \""
<< ", \"" << theFileName << "\", \"" << theFormatName << "\")"; << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
SetErrorCode(OK); SetErrorCode(OK);
} }
@ -161,12 +159,12 @@ void GEOMImpl_IInsertOperations::Export
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
(const char* theFileName, (const TCollection_AsciiString& theFileName,
const char* theFormatName) const TCollection_AsciiString& theFormatName)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (!theFileName || !theFormatName) return NULL; if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL;
//Add a new result object //Add a new result object
Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
@ -180,12 +178,10 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
//Set parameters //Set parameters
GEOMImpl_IImportExport aCI (aFunction); GEOMImpl_IImportExport aCI (aFunction);
char* aFileName = (char*)theFileName; aCI.SetFileName(theFileName);
aCI.SetFileName(aFileName);
char* aFormatName = (char*)theFormatName;
Handle(TCollection_HAsciiString) aHLibName; Handle(TCollection_HAsciiString) aHLibName;
if (!IsSupported(Standard_True, aFormatName, aHLibName)) { if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
return result; return result;
} }
TCollection_AsciiString aLibName = aHLibName->String(); TCollection_AsciiString aLibName = aHLibName->String();
@ -206,7 +202,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\"" GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
<< theFileName << "\", \"" << theFormatName << "\")"; << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
SetErrorCode(OK); SetErrorCode(OK);
return result; return result;
@ -317,19 +313,20 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
//============================================================================= //=============================================================================
Standard_Boolean GEOMImpl_IInsertOperations::IsSupported Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
(const Standard_Boolean isImport, (const Standard_Boolean isImport,
const TCollection_AsciiString theFormat, const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName) Handle(TCollection_HAsciiString)& theLibName)
{ {
if (!InitResMgr()) return Standard_False; if (!InitResMgr()) return Standard_False;
// Import/Export mode // Import/Export mode
Standard_CString aMode; TCollection_AsciiString aMode;
//Standard_CString aMode;
if (isImport) aMode = "Import"; if (isImport) aMode = "Import";
else aMode = "Export"; else aMode = "Export";
// Read supported formats for the certain mode // Read supported formats for the certain mode
if (myResMgr->Find(aMode)) { if (myResMgr->Find(aMode.ToCString())) {
TCollection_AsciiString aFormats (myResMgr->Value(aMode)); TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
if (aFormats.Search(theFormat) > -1) { if (aFormats.Search(theFormat) > -1) {
// Read library name for the supported format // Read library name for the supported format
TCollection_AsciiString aKey (theFormat); TCollection_AsciiString aKey (theFormat);

View File

@ -19,21 +19,22 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakeCopy (Handle(GEOM_Object) theOriginal); Standard_EXPORT Handle(GEOM_Object) MakeCopy (Handle(GEOM_Object) theOriginal);
Standard_EXPORT Handle(GEOM_Object) Import (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, Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
const char* theFileName, const TCollection_AsciiString& theFileName,
const char* theFormatType); const TCollection_AsciiString& theFormatType);
Standard_EXPORT Standard_Boolean ImportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats, 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, 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, Standard_EXPORT Standard_Boolean IsSupported (const Standard_Boolean isImport,
const TCollection_AsciiString theFormat, const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName); Handle(TCollection_HAsciiString)& theLibName);
private: private:
Standard_Boolean InitResMgr (); Standard_Boolean InitResMgr ();

View File

@ -375,10 +375,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeCompound
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
(list<Handle(GEOM_Object)> theShapes, (list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType, const Standard_Integer theObjectType,
const Standard_Integer theFunctionType, const Standard_Integer theFunctionType,
const TCollection_AsciiString theMethodName) const TCollection_AsciiString& theMethodName)
{ {
SetErrorCode(KO); SetErrorCode(KO);

View File

@ -114,10 +114,10 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL); Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
private: private:
Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes, Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType, const Standard_Integer theObjectType,
const Standard_Integer theFunctionType, const Standard_Integer theFunctionType,
const TCollection_AsciiString theMethodName); const TCollection_AsciiString& theMethodName);
bool CheckTriangulation (const TopoDS_Shape& aShape); bool CheckTriangulation (const TopoDS_Shape& aShape);
}; };

View File

@ -285,8 +285,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
(const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane) (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
{ {
GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -298,9 +296,8 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
// Make Sketcher // Make Sketcher
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcher(strdup(theCommand), aWorkingPlane); GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || anObject.IsNull())
//return aGEOMObject._retn();
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
return GetObject(anObject); return GetObject(anObject);
@ -315,8 +312,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane) (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{ {
GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -325,9 +320,9 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
// Make Sketcher // Make Sketcher
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcherOnPlane(strdup(theCommand), aWorkingPlane); GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn(); return GEOM::GEOM_Object::_nil();
return GetObject(anObject); return GetObject(anObject);
} }

View File

@ -32,23 +32,23 @@
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <gp_Pln.hxx>
#include <gp_Ax2.hxx>
#include <BRepLib.hxx> #include <BRepLib.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx> #include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx> #include <BRepBuilderAPI_MakeFace.hxx>
#include <GeomAPI.hxx>
#include <Geom2d_Line.hxx> #include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx> #include <Geom2d_Circle.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <GeomAPI.hxx> #include <gp_Pln.hxx>
#include <gp_Ax2.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TColStd_Array1OfAsciiString.hxx>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
#include "utilities.h" #include "utilities.h"
@ -88,37 +88,37 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
myOK = Standard_False; 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); TCollection_AsciiString aToken = aCommand.Token(":", 1);
int n = 0; int n = 0;
// porting to WNT // porting to WNT
TCollection_AsciiString* aTab = 0; TColStd_Array1OfAsciiString aTab (0, aCommand.Length() - 1);
if ( aCommand.Length() ) if ( aCommand.Length() )
{ {
aTab = new TCollection_AsciiString[ aCommand.Length() ];
while(aToken.Length() != 0) { while(aToken.Length() != 0) {
if(aCommand.Token(":", n + 1).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); aToken = aCommand.Token(":", ++n);
} }
n = n - 1; n = n - 1;
} }
if ( aTab && aTab[0].Length() ) if ( aTab.Length() && aTab(0).Length() )
while(i < n) { while(i < n) {
Standard_Real length = 0, radius = 0, angle = 0; Standard_Real length = 0, radius = 0, angle = 0;
move = point; move = point;
int n1 = 0; int n1 = 0;
TCollection_AsciiString* a = new TCollection_AsciiString[ aTab[0].Length() ]; TColStd_Array1OfAsciiString a (0, aTab(0).Length());
aToken = aTab[i].Token(" ", 1); aToken = aTab(i).Token(" ", 1);
while(aToken.Length() != 0) { while (aToken.Length() != 0) {
if(aTab[i].Token(" ", n1 + 1).Length() > 0) if (aTab(i).Token(" ", n1 + 1).Length() > 0)
a[n1] = aTab[i].Token(" ", n1 + 1); a(n1) = aTab(i).Token(" ", n1 + 1);
aToken = aTab[i].Token(" ", ++n1); aToken = aTab(i).Token(" ", ++n1);
} }
n1 = n1 - 1; n1 = n1 - 1;
switch(a[0].Value(1)) switch(a(0).Value(1))
{ {
case 'F': case 'F':
{ {
@ -127,23 +127,23 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
MESSAGE("profile : The F instruction must precede all moves"); MESSAGE("profile : The F instruction must precede all moves");
return; return;
} }
x0 = x = a[1].RealValue(); x0 = x = a(1).RealValue();
y0 = y = a[2].RealValue(); y0 = y = a(2).RealValue();
stayfirst = Standard_True; stayfirst = Standard_True;
break; break;
} }
case 'O': case 'O':
{ {
if (n1 != 4) goto badargs; 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; stayfirst = Standard_True;
break; break;
} }
case 'P': case 'P':
{ {
if (n1 != 7) goto badargs; if (n1 != 7) goto badargs;
gp_Vec vn(a[1].RealValue(), a[2].RealValue(), a[3].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()); gp_Vec vx(a(4).RealValue(), a(5).RealValue(), a(6).RealValue());
if (vn.Magnitude() <= Precision::Confusion() || vx.Magnitude() <= Precision::Confusion()) { if (vn.Magnitude() <= Precision::Confusion() || vx.Magnitude() <= Precision::Confusion()) {
MESSAGE("profile : null direction"); MESSAGE("profile : null direction");
return; return;
@ -156,8 +156,8 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'X': case 'X':
{ {
if (n1 != 2) goto badargs; if (n1 != 2) goto badargs;
length = a[1].RealValue(); length = a(1).RealValue();
if (a[0] == "XX") if (a(0) == "XX")
length -= x; length -= x;
dx = 1; dy = 0; dx = 1; dy = 0;
move = line; move = line;
@ -166,8 +166,8 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'Y': case 'Y':
{ {
if (n1 != 2) goto badargs; if (n1 != 2) goto badargs;
length = a[1].RealValue(); length = a(1).RealValue();
if (a[0] == "YY") if (a(0) == "YY")
length -= y; length -= y;
dx = 0; dy = 1; dx = 0; dy = 1;
move = line; move = line;
@ -176,7 +176,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'L': case 'L':
{ {
if (n1 != 2) goto badargs; if (n1 != 2) goto badargs;
length = a[1].RealValue(); length = a(1).RealValue();
if (Abs(length) > Precision::Confusion()) if (Abs(length) > Precision::Confusion())
move = line; move = line;
else else
@ -186,9 +186,9 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'T': case 'T':
{ {
if (n1 != 3) goto badargs; if (n1 != 3) goto badargs;
Standard_Real vx = a[1].RealValue(); Standard_Real vx = a(1).RealValue();
Standard_Real vy = a[2].RealValue(); Standard_Real vy = a(2).RealValue();
if (a[0] == "TT") { if (a(0) == "TT") {
vx -= x; vx -= x;
vy -= y; vy -= y;
} }
@ -205,8 +205,8 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'R': case 'R':
{ {
if (n1 != 2) goto badargs; if (n1 != 2) goto badargs;
angle = a[1].RealValue() * PI180; angle = a(1).RealValue() * PI180;
if (a[0] == "RR") { if (a(0) == "RR") {
dx = Cos(angle); dx = Cos(angle);
dy = Sin(angle); dy = Sin(angle);
} }
@ -222,8 +222,8 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'D': case 'D':
{ {
if (n1 != 3) goto badargs; if (n1 != 3) goto badargs;
Standard_Real vx = a[1].RealValue(); Standard_Real vx = a(1).RealValue();
Standard_Real vy = a[2].RealValue(); Standard_Real vy = a(2).RealValue();
length = Sqrt(vx * vx + vy * vy); length = Sqrt(vx * vx + vy * vy);
if (length > Precision::Confusion()) { if (length > Precision::Confusion()) {
dx = vx / length; dx = vx / length;
@ -236,9 +236,9 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'C': case 'C':
{ {
if (n1 != 3) goto badargs; if (n1 != 3) goto badargs;
radius = a[1].RealValue(); radius = a(1).RealValue();
if (Abs(radius) > Precision::Confusion()) { if (Abs(radius) > Precision::Confusion()) {
angle = a[2].RealValue() * PI180; angle = a(2).RealValue() * PI180;
move = circle; move = circle;
} }
else else
@ -248,15 +248,15 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
case 'I': case 'I':
{ {
if (n1 != 2) goto badargs; if (n1 != 2) goto badargs;
length = a[1].RealValue(); length = a(1).RealValue();
if (a[0] == "IX") { if (a(0) == "IX") {
if (Abs(dx) < Precision::Confusion()) { if (Abs(dx) < Precision::Confusion()) {
MESSAGE("profile : cannot intersect, arg "<<i-1); MESSAGE("profile : cannot intersect, arg "<<i-1);
return; return;
} }
length = (length - x) / dx; length = (length - x) / dx;
} }
else if (a[0] == "IY") { else if (a(0) == "IY") {
if (Abs(dy) < Precision::Confusion()) { if (Abs(dy) < Precision::Confusion()) {
MESSAGE("profile : cannot intersect, arg "<<i-1); MESSAGE("profile : cannot intersect, arg "<<i-1);
return; return;
@ -271,9 +271,9 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
} }
case 'W': case 'W':
{ {
if (a[0] == "WW") if (a(0) == "WW")
close = Standard_True; close = Standard_True;
else if(a[0] == "WF") { else if(a(0) == "WF") {
close = Standard_True; close = Standard_True;
face = Standard_True; face = Standard_True;
} }
@ -282,7 +282,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
} }
default: default:
{ {
MESSAGE("profile : unknown code "<<a[i]); MESSAGE("profile : unknown code " << a(i));
return; return;
} }
} }
@ -371,10 +371,7 @@ again :
goto again; goto again;
} }
} }
delete a;
} }
delete aTab;
aTab = 0;
// get the result, face or wire // get the result, face or wire
if (move == none) { if (move == none) {