#include <TopoDS_Shell.hxx>
#include <TopoDS_Wire.hxx>
-#include <stdio.h>
+#include <stdio.h>
//#include <SWDRAW_ShapeUpgrade.hxx>
//#include <ShapeUpgrade_SupportModification.hxx>
//#include <ShapeExtend_WireData.hxx>
{
if (n < 3 || n > 6)
{
- di << "Use unifysamedom result shape [-f] [-e] [+b]\n";
- di << "where [-f]. [-e], [+b] is available options\n";
+ di << "Use unifysamedom result shape [-f] [-e] [+b] [-i]\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 a 'concat bspline' mode\n";
+ di << "[+b] to switch on 'concat bspline' mode\n";
+ di << "[+i] to switch on 'allow internal edges' mode\n";
di << "'unify-faces' and 'unify-edges' modes are switched on by default";
return 1;
}
Standard_Boolean anUFaces = Standard_True;
Standard_Boolean anUEdges = Standard_True;
Standard_Boolean anConBS = Standard_False;
+ Standard_Boolean isAllowInternal = Standard_False;
if (n > 3)
for ( int i = 3; i < n; i++ )
anUEdges = Standard_False;
else if (!strcmp(a[i], "+b"))
anConBS = Standard_True;
+ else if (!strcmp(a[i], "+i"))
+ isAllowInternal = Standard_True;
}
Unifier().Initialize(aShape, anUEdges, anUFaces, anConBS);
+ Unifier().AllowInternalEdges(isAllowInternal);
Unifier().Build();
TopoDS_Shape Result = Unifier().Shape();
theCommands.Add ("unifysamedom",
"unifysamedom result shape [-f] [-e] [+b]", __FILE__,unifysamedom,g);
-
+
theCommands.Add ("unifysamedomgen",
"unifysamedomgen newshape oldshape : get new shape generated "
"by unifysamedom command from the old one",
}
if (Abs(FP) < Precision::PConfusion())
{
- B.MakeEdge (E,Cir, Precision::Confusion());
- B.Add(E,V1);
- B.Add(E,V2);
- E.Orientation(FE.Orientation());
- }
+ B.MakeEdge (E,Cir,Precision::Confusion());
+ B.Add(E,V1);
+ B.Add(E,V2);
+ E.Orientation(FE.Orientation());
+ }
else
{
GC_MakeCircle MC1 (adef.Value(FP), adef.Value((FP + LP) * 0.5), adef.Value(LP));
//=======================================================================
ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain()
+ : myUnifyFaces (Standard_True),
+ myUnifyEdges (Standard_True),
+ myConcatBSplines (Standard_False),
+ myAllowInternal (Standard_False)
{
- myUnifyEdges = Standard_True;
- myUnifyFaces = Standard_True;
- myConcatBSplines = Standard_False;
-
myContext = new ShapeBuild_ReShape;
}
const Standard_Boolean UnifyEdges,
const Standard_Boolean UnifyFaces,
const Standard_Boolean ConcatBSplines)
+ : myInitShape (aShape),
+ myUnifyFaces (UnifyFaces),
+ myUnifyEdges (UnifyEdges),
+ myConcatBSplines (ConcatBSplines),
+ myAllowInternal (Standard_False),
+ myShape (aShape)
{
- myInitShape = aShape;
- myShape = aShape;
- myUnifyEdges = UnifyEdges;
- myUnifyFaces = UnifyFaces;
- myConcatBSplines = ConcatBSplines;
-
myContext = new ShapeBuild_ReShape;
}
myContext->Clear();
myOldShapes.Clear();
- //myGenerated.Clear();
+}
+
+//=======================================================================
+//function : AllowInternalEdges
+//purpose :
+//=======================================================================
+
+void ShapeUpgrade_UnifySameDomain::AllowInternalEdges (const Standard_Boolean theValue)
+{
+ myAllowInternal = theValue;
}
//=======================================================================
void ShapeUpgrade_UnifySameDomain::UnifyFaces()
{
- // creating map of edge faces
- TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
- TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
+ // creating map of edge faces for the whole shape
+ TopTools_IndexedDataMapOfShapeListOfShape aGMapEdgeFaces;
+ TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aGMapEdgeFaces);
+
// processing each shell
TopExp_Explorer exps;
for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next()) {
TopoDS_Shell aShell = TopoDS::Shell(exps.Current());
+ // creating map of edge faces for the shell
+ TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
+ TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
+
// map of processed shapes
TopTools_MapOfShape aProcessed;
if (BRep_Tool::Degenerated(edge))
continue;
+ // get connectivity of the edge in the global shape
+ const TopTools_ListOfShape& aGList = aGMapEdgeFaces.FindFromKey(edge);
+ if (!myAllowInternal && aGList.Extent() != 2) {
+ // non mainfold case is not processed unless myAllowInternal
+ continue;
+ }
+ // process faces connected through the edge in the current shell
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter(aList);
for (; anIter.More(); anIter.Next()) {
if (IsSameDomain(aFace,anCheckedFace)) {
- if (aList.Extent() != 2) {
- // non mainfold case is not processed
- continue;
- }
-
// replacing pcurves
TopoDS_Face aMockUpFace;
BRep_Builder B;
}
}
+ if (faces.Length() > 1) {
+ // fill in the connectivity map for selected faces
+ TopTools_IndexedDataMapOfShapeListOfShape aMapEF;
+ for (i = 1; i <= faces.Length(); i++) {
+ TopExp::MapShapesAndAncestors(faces(i), TopAbs_EDGE, TopAbs_FACE, aMapEF);
+ }
+
+ // Collect multiconnected edges, i.e. edges that are internal to
+ // the set of selected faces and have connections to other faces.
+ TopTools_ListOfShape aMultEdges;
+ for (i = 1; i <= aMapEF.Extent(); i++) {
+ const TopTools_ListOfShape& aLF = aMapEF(i);
+ if (aLF.Extent() == 2) {
+ const TopoDS_Shape& aE = aMapEF.FindKey(i);
+ const TopTools_ListOfShape& aGLF = aGMapEdgeFaces.FindFromKey(aE);
+ if (aGLF.Extent() > 2) {
+ aMultEdges.Append(aE);
+ }
+ }
+ }
+ if (!aMultEdges.IsEmpty()) {
+ if (!myAllowInternal) {
+ // Remove from the selection the faces containing multiconnected edges
+ TopTools_MapOfShape anAvoidFaces;
+ TopTools_ListIteratorOfListOfShape it(aMultEdges);
+ for (; it.More(); it.Next()) {
+ const TopoDS_Shape& aE = it.Value();
+ const TopTools_ListOfShape& aLF = aMapEF.FindFromKey(aE);
+ anAvoidFaces.Add(aLF.First());
+ anAvoidFaces.Add(aLF.Last());
+ }
+ for (i = 1; i <= faces.Length(); ) {
+ if (anAvoidFaces.Contains(faces(i)))
+ faces.Remove(i);
+ else
+ i++;
+ }
+ }
+ else {
+ // add multiconnected edges as internal in new face
+ TopTools_ListIteratorOfListOfShape it(aMultEdges);
+ for (; it.More(); it.Next()) {
+ const TopoDS_Shape& aE = it.Value();
+ edges.Append(aE.Oriented(TopAbs_INTERNAL));
+ }
+ }
+ }
+ }
+
// all faces collected in the sequence. Perform union of faces
if (faces.Length() > 1) {
NbModif++;
}
else
{
- Handle(ShapeExtend_WireData) sbwd =
+ Handle(ShapeExtend_WireData) sbwd =
new ShapeExtend_WireData (aWire);
- ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
- wires.Append(seg);
- }
+ ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
+ wires.Append(seg);
+ }
}
CompShell.DispatchWires ( parts,wires );