mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 17:30:35 +05:00
0052538: TC7.5.0: Some edges are lost during group creation
This commit is contained in:
parent
a86e38643d
commit
e653d307b7
@ -3840,88 +3840,46 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
|
|
||||||
TopoDS_Shape aWhere = theShapeWhere->GetValue();
|
TopoDS_Shape aWhere = theShapeWhere->GetValue();
|
||||||
TopoDS_Shape aWhat = theShapeWhat->GetValue();
|
TopoDS_Shape aWhat = theShapeWhat->GetValue();
|
||||||
TopoDS_Shape aPntShape;
|
|
||||||
TopoDS_Vertex aVertex;
|
|
||||||
|
|
||||||
if (aWhere.IsNull() || aWhat.IsNull()) {
|
if (aWhere.IsNull() || aWhat.IsNull()) {
|
||||||
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
|
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction();
|
// Compute confusion tolerance.
|
||||||
if (aWhereFunction.IsNull()) {
|
Standard_Real aTolConf = Precision::Confusion();
|
||||||
SetErrorCode("Error: aWhereFunction is Null.");
|
Standard_Integer i;
|
||||||
return NULL;
|
|
||||||
|
for (i = 0; i < 2; ++i) {
|
||||||
|
TopExp_Explorer anExp(i == 0 ? aWhere : aWhat, TopAbs_VERTEX);
|
||||||
|
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
const TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current());
|
||||||
|
const Standard_Real aTolVtx = BRep_Tool::Tolerance(aVtx);
|
||||||
|
|
||||||
|
if (aTolVtx > aTolConf) {
|
||||||
|
aTolConf = aTolVtx;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape aWhereIndices;
|
// Compute mass tolerance.
|
||||||
TopExp::MapShapes(aWhere, aWhereIndices);
|
Bnd_Box aBoundingBox;
|
||||||
|
|
||||||
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;
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
Bnd_Box BoundingBox;
|
Standard_Real aMassTol;
|
||||||
gp_Pnt aPnt, aPnt_aWhat, tab_Pnt[2];
|
|
||||||
GProp_GProps aProps;
|
|
||||||
|
|
||||||
// Find the iType of the aWhat shape
|
BRepBndLib::Add(aWhere, aBoundingBox);
|
||||||
iType = GEOMUtils::GetTypeOfSimplePart(aWhat);
|
BRepBndLib::Add(aWhat, aBoundingBox);
|
||||||
if (iType == TopAbs_SHAPE) {
|
aBoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
SetErrorCode("Error: An attempt to extract a shape of not supported type.");
|
aMassTol = Max(aXmax - aXmin, aYmax - aYmin);
|
||||||
return NULL;
|
aMassTol = Max(aMassTol, aZmax - aZmin);
|
||||||
}
|
aMassTol *= aTolConf;
|
||||||
|
|
||||||
TopExp_Explorer Exp_aWhat ( aWhat, iType );
|
|
||||||
TopExp_Explorer Exp_aWhere ( aWhere, iType );
|
|
||||||
TopExp_Explorer Exp_Edge ( aWhere, TopAbs_EDGE );
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// Searching for the sub-shapes inside the ShapeWhere shape
|
// Searching for the sub-shapes inside the ShapeWhere shape
|
||||||
GEOMAlgo_GetInPlace aGIP;
|
GEOMAlgo_GetInPlace aGIP;
|
||||||
aGIP.SetTolerance(Tol_1D);
|
aGIP.SetTolerance(aTolConf);
|
||||||
aGIP.SetTolMass(Tol_Mass);
|
aGIP.SetTolMass(aMassTol);
|
||||||
aGIP.SetTolCG(Tol_1D);
|
aGIP.SetTolCG(aTolConf);
|
||||||
|
|
||||||
aGIP.SetArgument(aWhat);
|
aGIP.SetArgument(aWhat);
|
||||||
aGIP.SetShapeWhere(aWhere);
|
aGIP.SetShapeWhere(aWhere);
|
||||||
@ -3933,18 +3891,13 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
return NULL;
|
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.
|
// Add direct result.
|
||||||
TopTools_ListOfShape aLSA;
|
TopTools_ListOfShape aLSA;
|
||||||
const TopoDS_Shape &aShapeResult = aGIP.Result();
|
const TopoDS_Shape &aShapeResult = aGIP.Result();
|
||||||
TopTools_MapOfShape aMFence;
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_IndexedMapOfShape aWhereIndices;
|
||||||
|
|
||||||
|
TopExp::MapShapes(aWhere, aWhereIndices);
|
||||||
|
|
||||||
if (aShapeResult.IsNull() == Standard_False) {
|
if (aShapeResult.IsNull() == Standard_False) {
|
||||||
TopoDS_Iterator anIt(aShapeResult);
|
TopoDS_Iterator anIt(aShapeResult);
|
||||||
|
Loading…
Reference in New Issue
Block a user