//Compute the Edge value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Vector driver failed");
return NULL;
//Compute the Edge value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Vector driver failed");
return NULL;
//Compute the Edge value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
//Compute the shape
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
//Compute the Face value
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to compute a face");
return NULL;
//Compute the shape
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
//Compute the shape
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed");
return NULL;
//Compute the sub-shape value
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to glue faces");
return NULL;
//Compute the sub-shape value
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to glue faces");
return NULL;
//Compute the sub-shape value
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to glue edges");
return NULL;
//Compute the sub-shape value
Standard_Boolean isWarning = Standard_False;
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to glue edges");
return NULL;
* GetExistingSubObjects
*/
//=============================================================================
-Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubObjects
- (Handle(GEOM_Object) theShape,
- const Standard_Boolean theGroupsOnly)
+Handle(TColStd_HSequenceOfTransient)
+GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape,
+ const Standard_Boolean theGroupsOnly)
+{
+ // note: this method does not return fields
+
+ Standard_Integer types = theGroupsOnly ? Groups : Groups|SubShapes;
+ Handle(TColStd_HSequenceOfTransient) results = GetExistingSubObjects(theShape, types);
+
+ if (results->Length() > 0) {
+ //Make a Python command
+ TCollection_AsciiString anAsciiList;
+ for (int i = 1; i <= results->Length(); i++)
+ {
+ Handle(GEOM_BaseObject) obj = Handle(GEOM_BaseObject)::DownCast( results->Value(i));
+ obj->GetEntryString();
+ if ( i < results->Length() )
+ anAsciiList += ",";
+ }
+
+ GEOM::TPythonDump pd (theShape->GetLastFunction(), /*append=*/true);
+ pd << "[" << anAsciiList.ToCString();
+ pd << "] = geompy.GetExistingSubObjects(";
+ pd << theShape << ", " << (bool)theGroupsOnly << ")";
+ }
+
+ return results;
+}
+
+Handle(TColStd_HSequenceOfTransient)
+GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape,
+ const Standard_Integer theTypes)
{
SetErrorCode(KO);
SetErrorCode(KO);
- TCollection_AsciiString anAsciiList;
-
TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
for (; anIt.More(); anIt.Next()) {
TCollection_ExtendedString anEntry = anIt.Value();
char* anEntryStr = new char[aStrLen+1];
anEntry.ToUTF8CString(anEntryStr);
Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false);
- if (!anObj.IsNull() && anObj->IsKind(STANDARD_TYPE(GEOM_Object))) {
- if (!theGroupsOnly || anObj->GetType() == GEOM_GROUP) {
+ if (!anObj.IsNull() ) {
+ bool isGroup = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() == GEOM_GROUP;
+ bool isSubShape = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() != GEOM_GROUP;
+ bool isField = anObj->IsKind(STANDARD_TYPE(GEOM_Field));
+ if (theTypes & Groups && isGroup ||
+ theTypes & SubShapes && isSubShape ||
+ theTypes & Fields && isField) {
aSeq->Append(anObj);
-
- // for python command
- anAsciiList += anEntryStr;
- anAsciiList += ",";
}
}
delete [] anEntryStr;
return aSeq;
}
- //Make a Python command
- anAsciiList.Trunc(anAsciiList.Length() - 1);
-
- GEOM::TPythonDump pd (aMainShape, /*append=*/true);
- pd << "[" << anAsciiList.ToCString();
- pd << "] = geompy.GetExistingSubObjects(";
- pd << theShape << ", " << (bool)theGroupsOnly << ")";
-
SetErrorCode(OK);
return aSeq;
*/
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
int iType, nbTypes [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)
nbTypes[iType] = 0;
//Compute the sub-shape value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Shape driver failed to reverse shape");
return NULL;
// Compute tolerance
Standard_Real T, VertMax = -RealLast();
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
for (TopExp_Explorer ExV (theShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
T = BRep_Tool::Tolerance(Vertex);
TopoDS_Shape aWhere = theShapeWhere->GetValue();
TopoDS_Shape aWhat = theShapeWhat->GetValue();
- TopoDS_Shape aPntShape;
- TopoDS_Vertex aVertex;
if (aWhere.IsNull() || aWhat.IsNull()) {
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
return NULL;
}
- Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction();
- if (aWhereFunction.IsNull()) {
- SetErrorCode("Error: aWhereFunction is Null.");
- return NULL;
- }
-
- TopTools_IndexedMapOfShape aWhereIndices;
- TopExp::MapShapes(aWhere, aWhereIndices);
-
- TopAbs_ShapeEnum iType = TopAbs_SOLID;
- Standard_Real dl_l = 1e-3;
- Standard_Real min_l, Tol_0D, Tol_1D, Tol_2D, Tol_3D, Tol_Mass;
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- Bnd_Box BoundingBox;
- gp_Pnt aPnt, aPnt_aWhat, tab_Pnt[2];
- GProp_GProps aProps;
-
- // Find the iType of the aWhat shape
- iType = GEOMUtils::GetTypeOfSimplePart(aWhat);
- if (iType == TopAbs_SHAPE) {
- SetErrorCode("Error: An attempt to extract a shape of not supported type.");
- return NULL;
- }
+ // Compute confusion tolerance.
+ Standard_Real aTolConf = Precision::Confusion();
+ Standard_Integer i;
- TopExp_Explorer Exp_aWhat ( aWhat, iType );
- TopExp_Explorer Exp_aWhere ( aWhere, iType );
- TopExp_Explorer Exp_Edge ( aWhere, TopAbs_EDGE );
+ for (i = 0; i < 2; ++i) {
+ TopExp_Explorer anExp(i == 0 ? aWhere : aWhat, TopAbs_VERTEX);
- // Find the shortest edge in theShapeWhere shape
- BRepBndLib::Add(aWhere, BoundingBox);
- BoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- min_l = fabs(aXmax - aXmin);
- if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin);
- if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin);
+ for (; anExp.More(); anExp.Next()) {
+ const TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current());
+ const Standard_Real aTolVtx = BRep_Tool::Tolerance(aVtx);
- // Mantis issue 0020908 BEGIN
- if (!Exp_Edge.More()) {
- min_l = Precision::Confusion();
- }
- // Mantis issue 0020908 END
- for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) {
- TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX);
- for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) {
- aPnt = BRep_Tool::Pnt( TopoDS::Vertex( Exp_Vertex.Current() ) );
- tab_Pnt[nbVertex] = aPnt;
- }
- if ( ! tab_Pnt[0].IsEqual(tab_Pnt[1], dl_l) ) {
- BRepGProp::LinearProperties(Exp_Edge.Current(), aProps);
- if ( aProps.Mass() < min_l ) min_l = aProps.Mass();
+ if (aTolVtx > aTolConf) {
+ aTolConf = aTolVtx;
+ }
}
}
- min_l *= dl_l;
-
- // Compute tolerances
- Tol_0D = dl_l;
- Tol_1D = dl_l * min_l;
- Tol_2D = dl_l * ( min_l * min_l) * ( 2. + dl_l);
- Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) );
- if (Tol_0D < Precision::Confusion()) Tol_0D = Precision::Confusion();
- if (Tol_1D < Precision::Confusion()) Tol_1D = Precision::Confusion();
- if (Tol_2D < Precision::Confusion()) Tol_2D = Precision::Confusion();
- if (Tol_3D < Precision::Confusion()) Tol_3D = Precision::Confusion();
+ // Compute mass tolerance.
+ Bnd_Box aBoundingBox;
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ Standard_Real aMassTol;
- Tol_Mass = Tol_3D;
- if ( iType == TopAbs_VERTEX ) Tol_Mass = Tol_0D;
- else if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D;
- else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D;
+ BRepBndLib::Add(aWhere, aBoundingBox);
+ BRepBndLib::Add(aWhat, aBoundingBox);
+ aBoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+ aMassTol = Max(aXmax - aXmin, aYmax - aYmin);
+ aMassTol = Max(aMassTol, aZmax - aZmin);
+ aMassTol *= aTolConf;
// Searching for the sub-shapes inside the ShapeWhere shape
GEOMAlgo_GetInPlace aGIP;
- aGIP.SetTolerance(Tol_1D);
- aGIP.SetTolMass(Tol_Mass);
- aGIP.SetTolCG(Tol_1D);
+ aGIP.SetTolerance(aTolConf);
+ aGIP.SetTolMass(aMassTol);
+ aGIP.SetTolCG(aTolConf);
aGIP.SetArgument(aWhat);
aGIP.SetShapeWhere(aWhere);
return NULL;
}
- // aGIP.IsFound() returns true only when the whole theShapeWhat
- // is found (as one shape or several parts). But we are also interested
- // in the partial result, that is why this check is commented.
- //if (!aGIP.IsFound()) {
- // SetErrorCode(NOT_FOUND_ANY);
- // return NULL;
- //}
-
// Add direct result.
- TopTools_ListOfShape aLSA;
- const TopoDS_Shape &aShapeResult = aGIP.Result();
- TopTools_MapOfShape aMFence;
+ TopTools_ListOfShape aLSA;
+ const TopoDS_Shape &aShapeResult = aGIP.Result();
+ TopTools_MapOfShape aMFence;
+ TopTools_IndexedMapOfShape aWhereIndices;
+
+ TopExp::MapShapes(aWhere, aWhereIndices);
if (aShapeResult.IsNull() == Standard_False) {
TopoDS_Iterator anIt(aShapeResult);