//=======================================================================
static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n < 3 || n > 6)
+ if (n < 3)
{
- di << "Use unifysamedom result shape [-f] [-e] [+b] [-i]\n";
+ di << "Use unifysamedom result shape [-f] [-e] [+b] [-i] [-t val] [-a val]\n";
di << "options:\n";
- di << "[-f] to switch off 'unify-faces' mode \n";
- di << "[-e] to switch off 'unify-edges' mode\n";
- di << "[+b] to switch on 'concat bspline' mode\n";
- di << "[+i] to switch on 'allow internal edges' mode\n";
+ di << "-f to switch off 'unify-faces' mode \n";
+ di << "-e to switch off 'unify-edges' mode\n";
+ di << "+b to switch on 'concat bspline' mode\n";
+ di << "+i to switch on 'allow internal edges' mode\n";
+ di << "-t val to set linear tolerance\n";
+ di << "-a val to set angular tolerance\n";
di << "'unify-faces' and 'unify-edges' modes are switched on by default";
return 1;
}
Standard_Boolean anUEdges = Standard_True;
Standard_Boolean anConBS = Standard_False;
Standard_Boolean isAllowInternal = Standard_False;
+ Standard_Real aLinTol = Precision::Confusion();
+ Standard_Real aAngTol = Precision::Angular();
if (n > 3)
for ( int i = 3; i < n; i++ )
anConBS = Standard_True;
else if (!strcmp(a[i], "+i"))
isAllowInternal = Standard_True;
+ else if (!strcmp(a[i], "-t") || !strcmp(a[i], "-a"))
+ {
+ if (++i < n)
+ {
+ (a[i-1][1] == 't' ? aLinTol : aAngTol) = Draw::Atof(a[i]);
+ }
+ else
+ {
+ di << "value expected after " << a[i-1];
+ return 1;
+ }
+ }
}
Unifier().Initialize(aShape, anUEdges, anUFaces, anConBS);
Unifier().AllowInternalEdges(isAllowInternal);
+ Unifier().SetLinearTolerance(aLinTol);
+ Unifier().SetAngularTolerance(aAngTol);
Unifier().Build();
TopoDS_Shape Result = Unifier().Shape();
theCommands.Add ("removeloc","result shape",__FILE__,removeloc,g);
theCommands.Add ("unifysamedom",
- "unifysamedom result shape [-f] [-e] [+b]", __FILE__,unifysamedom,g);
+ "unifysamedom result shape [-f] [-e] [+b] [-i] [-t val] [-a val]", __FILE__,unifysamedom,g);
theCommands.Add ("unifysamedomgen",
"unifysamedomgen newshape oldshape : get new shape generated "
//purpose :
//=======================================================================
static Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,
- const TopoDS_Face& aCheckedFace)
+ const TopoDS_Face& aCheckedFace,
+ const Standard_Real theLinTol,
+ const Standard_Real theAngTol)
{
//checking the same handles
TopLoc_Location L1, L2;
if (S1 == S2 && L1 == L2)
return Standard_True;
- // planar and cylindrical cases (IMP 20052)
- Standard_Real aPrec = Precision::Confusion();
-
S1 = BRep_Tool::Surface(aFace);
S2 = BRep_Tool::Surface(aCheckedFace);
//if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface();
//if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface();
+ // case of two planar surfaces:
+ // all kinds of surfaces checked, including b-spline and bezier
+ GeomLib_IsPlanarSurface aPlanarityChecker1(S1, theLinTol);
+ if (aPlanarityChecker1.IsPlanar()) {
+ GeomLib_IsPlanarSurface aPlanarityChecker2(S2, theLinTol);
+ if (aPlanarityChecker2.IsPlanar()) {
+ gp_Pln aPln1 = aPlanarityChecker1.Plan();
+ gp_Pln aPln2 = aPlanarityChecker2.Plan();
+
+ if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), theAngTol) &&
+ aPln1.Distance(aPln2) < theLinTol) {
+ return Standard_True;
+ }
+ }
+ }
+
// case of two elementary surfaces: use OCCT tool
// elementary surfaces: ConicalSurface, CylindricalSurface,
// Plane, SphericalSurface and ToroidalSurface
Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool();
try {
- IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
+ IntPatch_ImpImpIntersection anIIInt(aGA1, aTT1, aGA2, aTT2, theLinTol, theLinTol);
if (!anIIInt.IsDone() || anIIInt.IsEmpty())
return Standard_False;
}
}
- // case of two planar surfaces:
- // all kinds of surfaces checked, including b-spline and bezier
- GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec);
- if (aPlanarityChecker1.IsPlanar()) {
- GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec);
- if (aPlanarityChecker2.IsPlanar()) {
- gp_Pln aPln1 = aPlanarityChecker1.Plan();
- gp_Pln aPln2 = aPlanarityChecker2.Plan();
-
- if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(),Precision::Angular()) &&
- aPln1.Distance(aPln2) < aPrec) {
- return Standard_True;
- }
- }
- }
-
// case of two cylindrical surfaces, at least one of which is a swept surface
// swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution
if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
{
gp_Cylinder aCyl1, aCyl2;
if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) {
- if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) {
+ if (fabs(aCyl1.Radius() - aCyl2.Radius()) < theLinTol) {
gp_Dir aDir1 = aCyl1.Position().Direction();
gp_Dir aDir2 = aCyl2.Position().Direction();
if (aDir1.IsParallel(aDir2, Precision::Angular())) {
gp_Pnt aLoc1 = aCyl1.Location();
gp_Pnt aLoc2 = aCyl2.Location();
gp_Vec aVec12 (aLoc1, aLoc2);
- if (aVec12.SquareMagnitude() < aPrec*aPrec ||
+ if (aVec12.SquareMagnitude() < theLinTol*theLinTol ||
aVec12.IsParallel(aDir1, Precision::Angular())) {
return Standard_True;
}
k++;
for (Standard_Integer j = 2; j <= SeqOfSubsSeqOfEdges(i).SeqsEdges.Length(); j++)
{
- TopoDS_Shape OldEdge = NewEdges2OldEdges(SeqOfSubsSeqOfEdges(i).SeqsEdges(j));
- theOldShapes.Bind(OldEdge, SeqOfSubsSeqOfEdges(i).UnionEdges);
+ const TopoDS_Shape& anOldEdge = SeqOfSubsSeqOfEdges(i).SeqsEdges(j);
+ const TopoDS_Shape* pOrigEdge = NewEdges2OldEdges.Seek(anOldEdge);
+ if (!pOrigEdge)
+ pOrigEdge = &anOldEdge;
+ theOldShapes.Bind(*pOrigEdge, SeqOfSubsSeqOfEdges(i).UnionEdges);
theContext->Remove(SeqOfSubsSeqOfEdges(i).SeqsEdges(j));
}
}
//=======================================================================
ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain()
- : myUnifyFaces (Standard_True),
+ : myLinTol(Precision::Confusion()),
+ myAngTol(Precision::Angular()),
+ myUnifyFaces(Standard_True),
myUnifyEdges (Standard_True),
myConcatBSplines (Standard_False),
myAllowInternal (Standard_False)
const Standard_Boolean UnifyFaces,
const Standard_Boolean ConcatBSplines)
: myInitShape (aShape),
- myUnifyFaces (UnifyFaces),
+ myLinTol(Precision::Confusion()),
+ myAngTol(Precision::Angular()),
+ myUnifyFaces(UnifyFaces),
myUnifyEdges (UnifyEdges),
myConcatBSplines (ConcatBSplines),
myAllowInternal (Standard_False),
if (IsCheckSharedEdgeOri && !CheckSharedEdgeOri(aFace, anCheckedFace, edge) )
continue;
- if (IsSameDomain(aFace,anCheckedFace)) {
+ if (IsSameDomain(aFace,anCheckedFace, myLinTol, myAngTol)) {
// hotfix for 27271: prevent merging along periodic direction.
if (IsLikeSeam(edge, aFace, aBaseSurface))