*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
- (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
+ (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
{
SetErrorCode(KO);
//Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
- //TCollection_AsciiString anOldDescr = aFunction->GetDescription();
- //GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" << aGroup
GEOM::TPythonDump(aFunction) << aGroup
- << " = geompy.CreateGroup(" << theMainShape << ", " << (int)theShapeType << ")";
+ << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
SetErrorCode(OK);
- return aGroup;
+ return aGroup;
}
//=============================================================================
}
//Make a Python command
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
-
- GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK);
}
//Make a Python command
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
-
- GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK);
SetErrorCode(KO);
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);
if (aFunction.IsNull()) return;
TopExp::MapShapes(aMainShape, mapIndices);
// 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++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
aSSI.SetIndices(aNewSeq);
}
- //Make a Python command
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
+ //Make a Python command
+ Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
+ aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
+ Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
- GEOM::TPythonDump pd (aFunction);
- pd << anOldDescr.ToCString() << "\n\t" << "geompy.UnionList(" << theGroup << ", [";
+ GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
+ pd << "geompy.UnionList(" << theGroup << ", [";
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
SetErrorCode(KO);
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);
if (aFunction.IsNull()) return;
TopExp::MapShapes(aMainShape, mapIndices);
// 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++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
}
//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);
- pd << anOldDescr.ToCString() << "\n\t" << "geompy.DifferenceList(" << theGroup << ", [";
+ GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
+ pd << "geompy.DifferenceList(" << theGroup << ", [";
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
SetErrorCode(OK);
}
+
//=============================================================================
/*!
* UnionIDs
SetErrorCode(KO);
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);
if (aFunction.IsNull()) return;
TopExp::MapShapes(aMainShape, mapIndices);
// 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++) {
new_id = theSubShapes->Value(i);
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(KO);
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);
if (aFunction.IsNull()) return;
TopExp::MapShapes(aMainShape, mapIndices);
// 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++) {
rem_id = theSubShapes->Value(i);
if (mapIDsCurrent.Contains(rem_id)) {
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);
}
if (aMainShape.IsNull()) return NULL;
//Make a Python command
- TCollection_AsciiString anOldDescr = aGroupFunction->GetDescription();
-
- GEOM::TPythonDump(aGroupFunction) << anOldDescr.ToCString() << "\n\t"
+ GEOM::TPythonDump(aGroupFunction, /*append=*/true)
<< aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
SetErrorCode(OK);
Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
{
SetErrorCode(KO);
-
- if(theGroup.IsNull()) return NULL;
+
+ if(theGroup.IsNull()) return NULL;
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
if(aFunction.IsNull()) return NULL;
-
+
GEOM_ISubShape aSSI(aFunction);
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if(aSeq.IsNull()) return NULL;
#include <TColStd_HArray1OfInteger.hxx>
#include <vector>
-//#include <iostream>
-
-//#include <OSD_Timer.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
const Standard_Integer theShapeType,
const Standard_Boolean isSorted)
{
-// OSD_Timer timer1, timer2, timer3, timer4;
-// timer1.Start();
-
SetErrorCode(KO);
if (theShape.IsNull()) return NULL;
return aSeq;
}
-// timer1.Stop();
-// timer2.Start();
-
if (isSorted)
SortShapes(listShape);
-// timer2.Stop();
-// timer3.Start();
-
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices);
Handle(TColStd_HArray1OfInteger) anArray;
anAsciiList.Trunc(anAsciiList.Length() - 1);
aFunction = theShape->GetLastFunction();
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
- GEOM::TPythonDump pd (aFunction);
- pd << anOldDescr.ToCString() << "\n\t[" << anAsciiList.ToCString();
+ GEOM::TPythonDump pd (aFunction, /*append=*/true);
+ pd << "[" << anAsciiList.ToCString();
pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "(");
- pd << theShape << ", " << theShapeType << ")";
+ pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
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;
}
}
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command
- GEOM::TPythonDump pd (aFunction);
- pd << anOldDescr.ToCString() << "\n\tlistSubShapeIDs = geompy.SubShapeAll";
+ GEOM::TPythonDump pd (aFunction, /*append=*/true);
+ pd << "listSubShapeIDs = geompy.SubShapeAll";
pd << (isSorted ? "SortedIDs(" : "IDs(");
- pd << theShape << ", " << theShapeType << ")";
+ pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
SetErrorCode(OK);
return aSeq;
//The explode doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
- TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command
- GEOM::TPythonDump(aFunction) << anOldDescr.ToCString()
- << "\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")";
+ GEOM::TPythonDump(aFunction, /*append=*/true)
+ << "listFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")";
SetErrorCode(OK);
return aSeq;
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetSharedShapes(" << theShape1 << ", "
- << theShape2 << ", " << theShapeType << ")";
+ << theShape2 << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
SetErrorCode(OK);
return aSeq;
GEOMAlgo_State theState)
{
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
-// MESSAGE("--------------------------- GetShapesOnPlane phase 1 takes:");
-// OSD_Timer timer1;
-// timer1.Start();
// Check presence of triangulation, build if need
if (!CheckTriangulation(theShape))
// Default value=0
aFinder.SetNbPntsMax(100);
-// timer1.Stop();
-// timer1.Show();
-
-// MESSAGE("--------------------------- Perform on Plane takes:");
-// timer1.Reset();
-// timer1.Start();
aFinder.Perform();
-// timer1.Stop();
-// timer1.Show();
-
-// MESSAGE("--------------------------- GetShapesOnPlane phase 3 takes:");
-// timer1.Reset();
-// timer1.Start();
// Interprete results
Standard_Integer iErr = aFinder.ErrorStatus();
return aSeqOfIDs;
}
-// timer1.Stop();
-// timer1.Show();
-
-// MESSAGE("--------------------------- GetShapesOnPlane phase 4 takes:");
-// timer1.Reset();
-// timer1.Start();
-
// Fill sequence of object IDs
aSeqOfIDs = new TColStd_HSequenceOfInteger;
int id = anIndices.FindIndex(itSub.Value());
aSeqOfIDs->Append(id);
}
-// timer1.Stop();
-// timer1.Show();
+
return aSeqOfIDs;
}
{
SetErrorCode(KO);
-// MESSAGE("--------------------------- GetShapesOnPlane phase 1 takes:");
-// OSD_Timer timer1;
-// timer1.Start();
-
if (theShape.IsNull() || theAx1.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue();
if ( aSeq.IsNull() || aSeq->Length() == 0 )
return NULL;
-// timer1.Stop();
-// timer1.Show();
-
-// MESSAGE("--------------------------- GetShapesOnPlane phase 5 takes:");
-// timer1.Reset();
-// timer1.Start();
-
// Make a Python command
Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast( aSeq->Value( 1 ));
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnPlane(" << theShape << ", "
- << theShapeType << ", " << theAx1 << ", " << theState << ")";
+ << aShapeType << ", " << theAx1 << ", " << theState << ")";
SetErrorCode(OK);
return aSeq;
Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
- << "] = geompy.GetShapesOnCylinder(" << theShape << ", " << theShapeType
+ << "] = geompy.GetShapesOnCylinder(" << theShape << ", " << aShapeType
<< ", " << theAxis << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK);
Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
- << "] = geompy.GetShapesOnSphere(" << theShape << ", " << theShapeType
+ << "] = geompy.GetShapesOnSphere(" << theShape << ", " << aShapeType
<< ", " << theCenter << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK);
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
aSeq = getShapesOnSurfaceIDs( aPlane, aShape, aShapeType, theState );
// 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
- const bool append = true;
- GEOM::TPythonDump(aFunction,append)
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "listShapesOnPlane = geompy.GetShapesOnPlaneIDs"
- << "(" << theShape << "," << theShapeType << "," << theAx1 << "," << theState << ")";
+ << "(" << theShape << "," << aShapeType << "," << theAx1 << "," << theState << ")";
SetErrorCode(OK);
return aSeq;
aSeq = getShapesOnSurfaceIDs( aCylinder, aShape, aShapeType, theState );
// 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
- const bool append = true;
- GEOM::TPythonDump(aFunction,append)
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs"
- << "(" << theShape << ", " << theShapeType << ", " << theAxis << ", "
+ << "(" << theShape << ", " << aShapeType << ", " << theAxis << ", "
<< theRadius << ", " << theState << ")";
SetErrorCode(OK);
aSeq = getShapesOnSurfaceIDs( aSphere, aShape, aShapeType, theState );
// 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
- const bool append = true;
- GEOM::TPythonDump(aFunction,append)
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs"
- << "(" << theShape << ", " << theShapeType << ", " << theCenter << ", "
+ << "(" << theShape << ", " << aShapeType << ", " << theCenter << ", "
<< theRadius << ", " << theState << ")";
SetErrorCode(OK);
GEOM::TPythonDump(aFunction)
<< "[" << anAsciiList.ToCString() << "] = geompy.GetShapesOnQuadrangle("
<< theShape << ", "
- << theShapeType << ", "
+ << TopAbs_ShapeEnum(theShapeType) << ", "
<< theTopLeftPoint << ", "
<< theTopRigthPoint << ", "
<< theBottomLeftPoint << ", "
// Make a Python command
// The GetShapesOnCylinder() doesn't change object so no new function is required.
- Handle(GEOM_Object) lastObj = getCreatedLast(theShape,theTopLeftPoint);
- lastObj = getCreatedLast(lastObj,theTopRigthPoint);
- lastObj = getCreatedLast(lastObj,theBottomRigthPoint);
- lastObj = getCreatedLast(lastObj,theBottomLeftPoint);
+ Handle(GEOM_Object) lastObj = GEOM::GetCreatedLast(theShape,theTopLeftPoint);
+ lastObj = GEOM::GetCreatedLast(lastObj,theTopRigthPoint);
+ lastObj = GEOM::GetCreatedLast(lastObj,theBottomRigthPoint);
+ lastObj = GEOM::GetCreatedLast(lastObj,theBottomLeftPoint);
Handle(GEOM_Function) aFunction = lastObj->GetLastFunction();
- const bool append = true;
- GEOM::TPythonDump(aFunction,append)
+ GEOM::TPythonDump(aFunction, /*append=*/true)
<< "listShapesOnQuadrangle = geompy.GetShapesOnQuadrangleIDs("
<< theShape << ", "
- << theShapeType << ", "
+ << TopAbs_ShapeEnum(theShapeType) << ", "
<< theTopLeftPoint << ", "
<< theTopRigthPoint << ", "
<< theBottomLeftPoint << ", "
MidXYZ.SetValue(Index,
GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9);
}
+
// Sorting
Standard_Integer aTemp;
Standard_Boolean exchange, Sort = Standard_True;
//=======================================================================
bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
{
-// MESSAGE("CheckTriangulation");
-//
-// OSD_Timer timer1;
-// timer1.Start();
-
TopExp_Explorer exp (aShape, TopAbs_FACE);
if (!exp.More()) {
SetErrorCode("Shape without faces given");
Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
-
-// MESSAGE("Deflection = " << aDeflection);
-
Standard_Real aHLRAngle = 0.349066;
BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle);
}
-// timer1.Stop();
-// timer1.Show();
return true;
}