Fix for bug 10041: Loading the dumped study with imported 'ex19_sphereINcube.py' script failed.

This commit is contained in:
jfa 2006-03-07 13:58:43 +00:00
parent 370fc2949e
commit 0e9a386bbb
5 changed files with 159 additions and 159 deletions

View File

@ -21,6 +21,11 @@
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include <TopAbs.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
namespace GEOM namespace GEOM
{ {
size_t TPythonDump::myCounter = 0; size_t TPythonDump::myCounter = 0;
@ -89,6 +94,14 @@ namespace GEOM
return *this; return *this;
} }
TPythonDump& TPythonDump::operator<< (const TopAbs_ShapeEnum theArg)
{
myStream<<"geompy.ShapeType[\"";
TopAbs::Print(theArg, myStream);
myStream<<"\"]";
return *this;
}
TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject) TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject)
{ {
TCollection_AsciiString anEntry; TCollection_AsciiString anEntry;
@ -96,4 +109,40 @@ namespace GEOM
myStream << anEntry.ToCString(); myStream << anEntry.ToCString();
return *this; return *this;
} }
Handle(GEOM_Object) GetCreatedLast(const Handle(GEOM_Object)& theObj1,
const Handle(GEOM_Object)& theObj2)
{
if (theObj1.IsNull()) return theObj2;
if (theObj2.IsNull()) return theObj1;
TColStd_ListOfInteger aTags1, aTags2;
TDF_Tool::TagList(theObj1->GetEntry(), aTags1);
TDF_Tool::TagList(theObj2->GetEntry(), aTags2);
TColStd_ListIteratorOfListOfInteger aListIter1(aTags1), aListIter2(aTags2);
for (; aListIter1.More(); aListIter1.Next()) {
if (!aListIter2.More())
return theObj1; // anObj1 is stored under anObj2
if (aListIter1.Value() > aListIter2.Value())
return theObj1;
else if (aListIter1.Value() < aListIter2.Value())
return theObj2;
}
return theObj1;
}
Handle(GEOM_Object) GetCreatedLast(const Handle(TColStd_HSequenceOfTransient)& theObjects)
{
Handle(GEOM_Object) anObject, aLatest;
int i, aLen = theObjects->Length();
if (aLen < 1)
return aLatest;
for (i = 1; i <= aLen; i++) {
anObject = Handle(GEOM_Object)::DownCast(theObjects->Value(i));
aLatest = GetCreatedLast(aLatest, anObject);
}
return aLatest;
}
} }

View File

@ -49,8 +49,18 @@ namespace GEOM
Standard_EXPORT TPythonDump& operator<< (float theArg); Standard_EXPORT TPythonDump& operator<< (float theArg);
Standard_EXPORT TPythonDump& operator<< (const void* theArg); Standard_EXPORT TPythonDump& operator<< (const void* theArg);
Standard_EXPORT TPythonDump& operator<< (const char* theArg); Standard_EXPORT TPythonDump& operator<< (const char* theArg);
Standard_EXPORT TPythonDump& operator<< (const TopAbs_ShapeEnum theArg);
Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_Object)& theObject); Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_Object)& theObject);
}; };
/*! Returns an object from two given, which has the latest entry
*/
Handle(GEOM_Object) GetCreatedLast (const Handle(GEOM_Object)& theObj1,
const Handle(GEOM_Object)& theObj2);
/*! Returns an object from \a theObjects, which has the latest entry
*/
Handle(GEOM_Object) GetCreatedLast (const Handle(TColStd_HSequenceOfTransient)& theObjects);
} }
#endif #endif

View File

@ -537,12 +537,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint
//The GetPoint() doesn't change object so no new function is required. //The GetPoint() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" GEOM::TPythonDump(aFunction, /*append=*/true)
<< aResult << " = geompy.GetPoint(" << theShape << ", " << aResult << " = geompy.GetPoint(" << theShape << ", "
<< theX << ", " << theY << ", " << theZ << ", " << theEpsilon << ")"; << theX << ", " << theY << ", " << theZ << ", " << theEpsilon << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -2447,12 +2446,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound
//The explode doesn't change object so no new function is required. //The explode doesn't change object so no new function is required.
aFunction = theCompound->GetLastFunction(); aFunction = theCompound->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t[" GEOM::TPythonDump(aFunction, /*append=*/true)
<< anAsciiList.ToCString() << "] = geompy.MakeBlockExplode(" << "[" << anAsciiList.ToCString() << "] = geompy.MakeBlockExplode("
<< theCompound << ", " << theMinNbFaces << ", " << theMaxNbFaces << ")"; << theCompound << ", " << theMinNbFaces << ", " << theMaxNbFaces << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aBlocks; return aBlocks;
@ -3118,11 +3116,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate
// The Propagation doesn't change object so no new function is required. // The Propagation doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
// Make a Python command // Make a Python command
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t[" GEOM::TPythonDump(aFunction, /*append=*/true)
<< aListRes.ToCString() << "] = geompy.Propagate(" << theShape << ")"; << "[" << aListRes.ToCString() << "] = geompy.Propagate(" << theShape << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;

View File

@ -75,7 +75,7 @@ GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
(Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType) (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -94,14 +94,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
//Make a Python command //Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
//TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" << aGroup
GEOM::TPythonDump(aFunction) << aGroup GEOM::TPythonDump(aFunction) << aGroup
<< " = geompy.CreateGroup(" << theMainShape << ", " << (int)theShapeType << ")"; << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aGroup; return aGroup;
} }
//============================================================================= //=============================================================================
@ -156,9 +154,7 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
<< "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")"; << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -222,9 +218,7 @@ void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
<< "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")"; << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -242,6 +236,12 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
SetErrorCode(KO); SetErrorCode(KO);
if (theGroup.IsNull()) return; if (theGroup.IsNull()) return;
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
SetErrorCode("The list is empty");
return;
}
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if (aFunction.IsNull()) return; if (aFunction.IsNull()) return;
@ -277,7 +277,7 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
TopExp::MapShapes(aMainShape, mapIndices); TopExp::MapShapes(aMainShape, mapIndices);
// Get IDs of sub-shapes to add // Get IDs of sub-shapes to add
Standard_Integer i, new_id, aLen = theSubShapes->Length(); Standard_Integer i, new_id;
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@ -363,11 +363,13 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
pd << anOldDescr.ToCString() << "\n\t" << "geompy.UnionList(" << theGroup << ", ["; pd << "geompy.UnionList(" << theGroup << ", [";
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@ -388,6 +390,12 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
SetErrorCode(KO); SetErrorCode(KO);
if (theGroup.IsNull()) return; if (theGroup.IsNull()) return;
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
SetErrorCode("The list is empty");
return;
}
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if (aFunction.IsNull()) return; if (aFunction.IsNull()) return;
@ -424,7 +432,7 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
TopExp::MapShapes(aMainShape, mapIndices); TopExp::MapShapes(aMainShape, mapIndices);
// Get IDs of sub-shapes to be removed // Get IDs of sub-shapes to be removed
Standard_Integer i, rem_id, aLen = theSubShapes->Length(); Standard_Integer i, rem_id;
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@ -514,10 +522,12 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
pd << anOldDescr.ToCString() << "\n\t" << "geompy.DifferenceList(" << theGroup << ", ["; pd << "geompy.DifferenceList(" << theGroup << ", [";
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@ -526,6 +536,7 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
SetErrorCode(OK); SetErrorCode(OK);
} }
//============================================================================= //=============================================================================
/*! /*!
* UnionIDs * UnionIDs
@ -537,6 +548,12 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
SetErrorCode(KO); SetErrorCode(KO);
if (theGroup.IsNull()) return; if (theGroup.IsNull()) return;
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
SetErrorCode("The list is empty");
return;
}
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if (aFunction.IsNull()) return; if (aFunction.IsNull()) return;
@ -572,7 +589,7 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
TopExp::MapShapes(aMainShape, mapIndices); TopExp::MapShapes(aMainShape, mapIndices);
// Get IDs of sub-shapes to add // Get IDs of sub-shapes to add
Standard_Integer i, new_id, aLen = theSubShapes->Length(); Standard_Integer i, new_id;
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
new_id = theSubShapes->Value(i); new_id = theSubShapes->Value(i);
@ -594,6 +611,13 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
} }
//Make a Python command
GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << "geompy.UnionIDs(" << theGroup << ", [";
for (i = 1; i < aLen; i++)
pd << theSubShapes->Value(i) << ", ";
pd << theSubShapes->Value(aLen) << "])";
SetErrorCode(OK); SetErrorCode(OK);
} }
@ -608,6 +632,12 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
SetErrorCode(KO); SetErrorCode(KO);
if (theGroup.IsNull()) return; if (theGroup.IsNull()) return;
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
SetErrorCode("The list is empty");
return;
}
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if (aFunction.IsNull()) return; if (aFunction.IsNull()) return;
@ -644,7 +674,7 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
TopExp::MapShapes(aMainShape, mapIndices); TopExp::MapShapes(aMainShape, mapIndices);
// Get IDs of sub-shapes to be removed // Get IDs of sub-shapes to be removed
Standard_Integer i, rem_id, aLen = theSubShapes->Length(); Standard_Integer i, rem_id;
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
rem_id = theSubShapes->Value(i); rem_id = theSubShapes->Value(i);
if (mapIDsCurrent.Contains(rem_id)) { if (mapIDsCurrent.Contains(rem_id)) {
@ -666,6 +696,13 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
} }
//Make a Python command
GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << "geompy.DifferenceIDs(" << theGroup << ", [";
for (i = 1; i < aLen; i++)
pd << theSubShapes->Value(i) << ", ";
pd << theSubShapes->Value(aLen) << "])";
SetErrorCode(OK); SetErrorCode(OK);
} }
@ -709,9 +746,7 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object)
if (aMainShape.IsNull()) return NULL; if (aMainShape.IsNull()) return NULL;
//Make a Python command //Make a Python command
TCollection_AsciiString anOldDescr = aGroupFunction->GetDescription(); GEOM::TPythonDump(aGroupFunction, /*append=*/true)
GEOM::TPythonDump(aGroupFunction) << anOldDescr.ToCString() << "\n\t"
<< aMainShape << " = geompy.GetMainShape(" << theGroup << ")"; << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -726,12 +761,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object)
Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup) Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if(theGroup.IsNull()) return NULL; if(theGroup.IsNull()) return NULL;
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if(aFunction.IsNull()) return NULL; if(aFunction.IsNull()) return NULL;
GEOM_ISubShape aSSI(aFunction); GEOM_ISubShape aSSI(aFunction);
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices(); Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if(aSeq.IsNull()) return NULL; if(aSeq.IsNull()) return NULL;

View File

@ -93,9 +93,6 @@
#include <TColStd_HArray1OfInteger.hxx> #include <TColStd_HArray1OfInteger.hxx>
#include <vector> #include <vector>
//#include <iostream>
//#include <OSD_Timer.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
@ -533,9 +530,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
const Standard_Boolean isSorted) const Standard_Boolean isSorted)
{ {
// OSD_Timer timer1, timer2, timer3, timer4;
// timer1.Start();
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; if (theShape.IsNull()) return NULL;
@ -573,15 +567,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
return aSeq; return aSeq;
} }
// timer1.Stop();
// timer2.Start();
if (isSorted) if (isSorted)
SortShapes(listShape); SortShapes(listShape);
// timer2.Stop();
// timer3.Start();
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices); TopExp::MapShapes(aShape, anIndices);
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
@ -605,26 +593,14 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
anAsciiList.Trunc(anAsciiList.Length() - 1); anAsciiList.Trunc(anAsciiList.Length() - 1);
aFunction = theShape->GetLastFunction(); aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << anOldDescr.ToCString() << "\n\t[" << anAsciiList.ToCString(); pd << "[" << anAsciiList.ToCString();
pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "("); pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "(");
pd << theShape << ", " << theShapeType << ")"; pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
SetErrorCode(OK); SetErrorCode(OK);
// timer4.Stop();
// cout << "Explosure takes:" << endl;
// timer1.Show();
// cout << "Sorting takes:" << endl;
// timer2.Show();
// cout << "Sub-shapes addition takes:" << endl;
// timer3.Show();
// cout << "Update Description takes:" << endl;
// timer4.Show();
return aSeq; return aSeq;
} }
@ -687,13 +663,12 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
} }
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << anOldDescr.ToCString() << "\n\tlistSubShapeIDs = geompy.SubShapeAll"; pd << "listSubShapeIDs = geompy.SubShapeAll";
pd << (isSorted ? "SortedIDs(" : "IDs("); pd << (isSorted ? "SortedIDs(" : "IDs(");
pd << theShape << ", " << theShapeType << ")"; pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -873,11 +848,10 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetFreeFacesIDs
//The explode doesn't change object so no new function is required. //The explode doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() GEOM::TPythonDump(aFunction, /*append=*/true)
<< "\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")"; << "listFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -942,7 +916,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetSharedShapes(" << theShape1 << ", " << "] = geompy.GetSharedShapes(" << theShape1 << ", "
<< theShape2 << ", " << theShapeType << ")"; << theShape2 << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1084,9 +1058,6 @@ Handle(TColStd_HSequenceOfInteger)
GEOMAlgo_State theState) GEOMAlgo_State theState)
{ {
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
// MESSAGE("--------------------------- GetShapesOnPlane phase 1 takes:");
// OSD_Timer timer1;
// timer1.Start();
// Check presence of triangulation, build if need // Check presence of triangulation, build if need
if (!CheckTriangulation(theShape)) if (!CheckTriangulation(theShape))
@ -1112,19 +1083,7 @@ Handle(TColStd_HSequenceOfInteger)
// Default value=0 // Default value=0
aFinder.SetNbPntsMax(100); aFinder.SetNbPntsMax(100);
// timer1.Stop();
// timer1.Show();
// MESSAGE("--------------------------- Perform on Plane takes:");
// timer1.Reset();
// timer1.Start();
aFinder.Perform(); aFinder.Perform();
// timer1.Stop();
// timer1.Show();
// MESSAGE("--------------------------- GetShapesOnPlane phase 3 takes:");
// timer1.Reset();
// timer1.Start();
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
@ -1149,13 +1108,6 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
// timer1.Stop();
// timer1.Show();
// MESSAGE("--------------------------- GetShapesOnPlane phase 4 takes:");
// timer1.Reset();
// timer1.Start();
// Fill sequence of object IDs // Fill sequence of object IDs
aSeqOfIDs = new TColStd_HSequenceOfInteger; aSeqOfIDs = new TColStd_HSequenceOfInteger;
@ -1167,8 +1119,7 @@ Handle(TColStd_HSequenceOfInteger)
int id = anIndices.FindIndex(itSub.Value()); int id = anIndices.FindIndex(itSub.Value());
aSeqOfIDs->Append(id); aSeqOfIDs->Append(id);
} }
// timer1.Stop();
// timer1.Show();
return aSeqOfIDs; return aSeqOfIDs;
} }
@ -1250,10 +1201,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
{ {
SetErrorCode(KO); SetErrorCode(KO);
// MESSAGE("--------------------------- GetShapesOnPlane phase 1 takes:");
// OSD_Timer timer1;
// timer1.Start();
if (theShape.IsNull() || theAx1.IsNull()) return NULL; if (theShape.IsNull() || theAx1.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue(); TopoDS_Shape aShape = theShape->GetValue();
@ -1277,13 +1224,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
if ( aSeq.IsNull() || aSeq->Length() == 0 ) if ( aSeq.IsNull() || aSeq->Length() == 0 )
return NULL; return NULL;
// timer1.Stop();
// timer1.Show();
// MESSAGE("--------------------------- GetShapesOnPlane phase 5 takes:");
// timer1.Reset();
// timer1.Start();
// Make a Python command // Make a Python command
Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast( aSeq->Value( 1 )); Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast( aSeq->Value( 1 ));
@ -1291,7 +1231,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnPlane(" << theShape << ", " << "] = geompy.GetShapesOnPlane(" << theShape << ", "
<< theShapeType << ", " << theAx1 << ", " << theState << ")"; << aShapeType << ", " << theAx1 << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1340,7 +1280,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli
Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnCylinder(" << theShape << ", " << theShapeType << "] = geompy.GetShapesOnCylinder(" << theShape << ", " << aShapeType
<< ", " << theAxis << ", " << theRadius << ", " << theState << ")"; << ", " << theAxis << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -1393,31 +1333,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphe
Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnSphere(" << theShape << ", " << theShapeType << "] = geompy.GetShapesOnSphere(" << theShape << ", " << aShapeType
<< ", " << theCenter << ", " << theRadius << ", " << theState << ")"; << ", " << theCenter << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
} }
//=======================================================================
//function : getCreatedLast
/*!
* \brief Select the object created last
* \param theObj1 - Object 1
* \param theObj2 - Object 2
* \retval Handle(GEOM_Object) - selected object
*/
//=======================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::getCreatedLast(const Handle(GEOM_Object)& theObj1,
const Handle(GEOM_Object)& theObj2)
{
if ( theObj1.IsNull() ) return theObj2;
if ( theObj2.IsNull() ) return theObj1;
return ( theObj1->GetEntry().Tag() > theObj2->GetEntry().Tag() ) ? theObj1 : theObj2;
}
//============================================================================= //=============================================================================
/*! /*!
* GetShapesOnPlaneIDs * GetShapesOnPlaneIDs
@ -1452,13 +1374,12 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnPlaneI
aSeq = getShapesOnSurfaceIDs( aPlane, aShape, aShapeType, theState ); aSeq = getShapesOnSurfaceIDs( aPlane, aShape, aShapeType, theState );
// The GetShapesOnPlaneIDs() doesn't change object so no new function is required. // The GetShapesOnPlaneIDs() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = getCreatedLast(theShape,theAx1)->GetLastFunction(); Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShape,theAx1)->GetLastFunction();
// Make a Python command // Make a Python command
const bool append = true; GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction,append)
<< "listShapesOnPlane = geompy.GetShapesOnPlaneIDs" << "listShapesOnPlane = geompy.GetShapesOnPlaneIDs"
<< "(" << theShape << "," << theShapeType << "," << theAx1 << "," << theState << ")"; << "(" << theShape << "," << aShapeType << "," << theAx1 << "," << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1499,13 +1420,12 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnCylind
aSeq = getShapesOnSurfaceIDs( aCylinder, aShape, aShapeType, theState ); aSeq = getShapesOnSurfaceIDs( aCylinder, aShape, aShapeType, theState );
// The GetShapesOnCylinder() doesn't change object so no new function is required. // The GetShapesOnCylinder() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = getCreatedLast(theShape,theAxis)->GetLastFunction(); Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShape,theAxis)->GetLastFunction();
// Make a Python command // Make a Python command
const bool append = true; GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction,append)
<< "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs" << "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs"
<< "(" << theShape << ", " << theShapeType << ", " << theAxis << ", " << "(" << theShape << ", " << aShapeType << ", " << theAxis << ", "
<< theRadius << ", " << theState << ")"; << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -1550,13 +1470,12 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnSphere
aSeq = getShapesOnSurfaceIDs( aSphere, aShape, aShapeType, theState ); aSeq = getShapesOnSurfaceIDs( aSphere, aShape, aShapeType, theState );
// The GetShapesOnSphere() doesn't change object so no new function is required. // The GetShapesOnSphere() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = getCreatedLast(theShape,theCenter)->GetLastFunction(); Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShape,theCenter)->GetLastFunction();
// Make a Python command // Make a Python command
const bool append = true; GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction,append)
<< "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs" << "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs"
<< "(" << theShape << ", " << theShapeType << ", " << theCenter << ", " << "(" << theShape << ", " << aShapeType << ", " << theCenter << ", "
<< theRadius << ", " << theState << ")"; << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
@ -1738,7 +1657,7 @@ Handle(TColStd_HSequenceOfTransient)
GEOM::TPythonDump(aFunction) GEOM::TPythonDump(aFunction)
<< "[" << anAsciiList.ToCString() << "] = geompy.GetShapesOnQuadrangle(" << "[" << anAsciiList.ToCString() << "] = geompy.GetShapesOnQuadrangle("
<< theShape << ", " << theShape << ", "
<< theShapeType << ", " << TopAbs_ShapeEnum(theShapeType) << ", "
<< theTopLeftPoint << ", " << theTopLeftPoint << ", "
<< theTopRigthPoint << ", " << theTopRigthPoint << ", "
<< theBottomLeftPoint << ", " << theBottomLeftPoint << ", "
@ -1788,17 +1707,16 @@ Handle(TColStd_HSequenceOfInteger)
// Make a Python command // Make a Python command
// The GetShapesOnCylinder() doesn't change object so no new function is required. // The GetShapesOnCylinder() doesn't change object so no new function is required.
Handle(GEOM_Object) lastObj = getCreatedLast(theShape,theTopLeftPoint); Handle(GEOM_Object) lastObj = GEOM::GetCreatedLast(theShape,theTopLeftPoint);
lastObj = getCreatedLast(lastObj,theTopRigthPoint); lastObj = GEOM::GetCreatedLast(lastObj,theTopRigthPoint);
lastObj = getCreatedLast(lastObj,theBottomRigthPoint); lastObj = GEOM::GetCreatedLast(lastObj,theBottomRigthPoint);
lastObj = getCreatedLast(lastObj,theBottomLeftPoint); lastObj = GEOM::GetCreatedLast(lastObj,theBottomLeftPoint);
Handle(GEOM_Function) aFunction = lastObj->GetLastFunction(); Handle(GEOM_Function) aFunction = lastObj->GetLastFunction();
const bool append = true; GEOM::TPythonDump(aFunction, /*append=*/true)
GEOM::TPythonDump(aFunction,append)
<< "listShapesOnQuadrangle = geompy.GetShapesOnQuadrangleIDs(" << "listShapesOnQuadrangle = geompy.GetShapesOnQuadrangleIDs("
<< theShape << ", " << theShape << ", "
<< theShapeType << ", " << TopAbs_ShapeEnum(theShapeType) << ", "
<< theTopLeftPoint << ", " << theTopLeftPoint << ", "
<< theTopRigthPoint << ", " << theTopRigthPoint << ", "
<< theBottomLeftPoint << ", " << theBottomLeftPoint << ", "
@ -2099,6 +2017,7 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL)
MidXYZ.SetValue(Index, MidXYZ.SetValue(Index,
GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9); GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9);
} }
// Sorting // Sorting
Standard_Integer aTemp; Standard_Integer aTemp;
Standard_Boolean exchange, Sort = Standard_True; Standard_Boolean exchange, Sort = Standard_True;
@ -2133,11 +2052,6 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL)
//======================================================================= //=======================================================================
bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape) bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
{ {
// MESSAGE("CheckTriangulation");
//
// OSD_Timer timer1;
// timer1.Start();
TopExp_Explorer exp (aShape, TopAbs_FACE); TopExp_Explorer exp (aShape, TopAbs_FACE);
if (!exp.More()) { if (!exp.More()) {
SetErrorCode("Shape without faces given"); SetErrorCode("Shape without faces given");
@ -2158,15 +2072,10 @@ bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin; Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4; Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
// MESSAGE("Deflection = " << aDeflection);
Standard_Real aHLRAngle = 0.349066; Standard_Real aHLRAngle = 0.349066;
BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle); BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle);
} }
// timer1.Stop();
// timer1.Show();
return true; return true;
} }