Create;
- Create ( S : Shape from TopoDS;
- Offset : Real from Standard;
- Tol : Real from Standard;
- Mode : Mode from BRepOffset = BRepOffset_Skin;
- Intersection : Boolean from Standard = Standard_False;
- SelfInter : Boolean from Standard = Standard_False;
- Join : JoinType from GeomAbs = GeomAbs_Arc;
- Thickening : Boolean from Standard = Standard_False)
+ Create ( S : Shape from TopoDS;
+ Offset : Real from Standard;
+ Tol : Real from Standard;
+ Mode : Mode from BRepOffset = BRepOffset_Skin;
+ Intersection : Boolean from Standard = Standard_False;
+ SelfInter : Boolean from Standard = Standard_False;
+ Join : JoinType from GeomAbs = GeomAbs_Arc;
+ RemoveIntEdges : Boolean from Standard = Standard_False;
+ Thickening : Boolean from Standard = Standard_False;
+ RemoveInvalidFaces: Boolean from Standard = Standard_False)
returns MakeOffset from BRepOffset;
---Category: Initialization.
Initialize (me : in out;
- S : Shape from TopoDS;
- Offset : Real from Standard;
- Tol : Real from Standard;
- Mode : Mode from BRepOffset = BRepOffset_Skin;
- Intersection : Boolean from Standard = Standard_False;
- SelfInter : Boolean from Standard = Standard_False;
- Join : JoinType from GeomAbs = GeomAbs_Arc;
- Thickening : Boolean from Standard = Standard_False)
+ S : Shape from TopoDS;
+ Offset : Real from Standard;
+ Tol : Real from Standard;
+ Mode : Mode from BRepOffset = BRepOffset_Skin;
+ Intersection : Boolean from Standard = Standard_False;
+ SelfInter : Boolean from Standard = Standard_False;
+ Join : JoinType from GeomAbs = GeomAbs_Arc;
+ RemoveIntEdges : Boolean from Standard = Standard_False;
+ Thickening : Boolean from Standard = Standard_False;
+ RemoveInvalidFaces: Boolean from Standard = Standard_False)
is static;
Clear (me : in out)
MakeMissingWalls (me: in out)
---Purpose: Private method used to build walls for thickening the shell
- is static private;
+ is static private;
+
+ RemoveInternalEdges (me: in out)
+ ---Purpose: Removes INTERNAL edges from the faces
+ is static private;
fields
myMode : Mode from BRepOffset;
myInter : Boolean from Standard;
mySelfInter : Boolean from Standard;
- myJoin : JoinType from GeomAbs;
+ myJoin : JoinType from GeomAbs;
+ myRemoveIntEdges : Boolean from Standard;
myThickening : Boolean from Standard;
-
+ myRemoveInvalidFaces : Boolean from Standard;
+
myFaceOffset : DataMapOfShapeReal from TopTools;
myFaces : IndexedMapOfShape from TopTools;
const TopTools_IndexedDataMapOfShapeListOfShape& theOrigins,
const TopTools_MapOfShape& theMFence,
Standard_Boolean& bKeep,
- Standard_Boolean& bRem);
+ Standard_Boolean& bRem,
+ const Standard_Boolean RemoveInvalidFaces);
static
void CheckBiNormals(TopTools_ListOfShape& theLFImages,
const TopoDS_Face& theF,
const TopTools_IndexedDataMapOfShapeListOfShape& theOrigins,
- TopTools_ListOfShape& theLFKeep);
+ TopTools_ListOfShape& theLFKeep,
+ const Standard_Boolean RemoveInvalidFaces);
static
Standard_Boolean CheckNormals(const TopoDS_Face& theFIm,
const TopoDS_Shape& myOffsetShape,
const TopAbs_ShapeEnum &theShapeType);
+static
+ void RemoveShapes(TopoDS_Shape& theS,
+ const TopTools_ListOfShape& theLS);
+
//=======================================================================
const Standard_Boolean Inter,
const Standard_Boolean SelfInter,
const GeomAbs_JoinType Join,
- const Standard_Boolean Thickening)
+ const Standard_Boolean RemoveIntEdges,
+ const Standard_Boolean Thickening,
+ const Standard_Boolean RemInvFaces)
:
-myOffset (Offset),
-myTol (Tol),
-myShape (S),
-myMode (Mode),
-myInter (Inter),
-mySelfInter (SelfInter),
-myJoin (Join),
-myThickening (Thickening),
-myDone (Standard_False)
+myOffset (Offset),
+myTol (Tol),
+myShape (S),
+myMode (Mode),
+myInter (Inter),
+mySelfInter (SelfInter),
+myJoin (Join),
+myRemoveIntEdges(RemoveIntEdges),
+myThickening (Thickening),
+myRemoveInvalidFaces(RemInvFaces),
+myDone (Standard_False)
{
myAsDes = new BRepAlgo_AsDes();
const Standard_Boolean Inter,
const Standard_Boolean SelfInter,
const GeomAbs_JoinType Join,
- const Standard_Boolean Thickening)
+ const Standard_Boolean RemoveIntEdges,
+ const Standard_Boolean Thickening,
+ const Standard_Boolean RemInvFaces)
{
- myOffset = Offset;
- myShape = S;
- myTol = Tol;
- myMode = Mode;
- myInter = Inter;
- mySelfInter = SelfInter;
- myJoin = Join;
- myThickening = Thickening;
- myDone = Standard_False;
+ myOffset = Offset;
+ myShape = S;
+ myTol = Tol;
+ myMode = Mode;
+ myInter = Inter;
+ mySelfInter = SelfInter;
+ myJoin = Join;
+ myRemoveIntEdges = RemoveIntEdges;
+ myThickening = Thickening;
+ myRemoveInvalidFaces = RemInvFaces;
+ myDone = Standard_False;
Clear();
}
//--------------
SelectShells ();
//----------------------------------
+ // Remove INTERNAL edges if necessasry
+ //----------------------------------
+ if (myRemoveIntEdges) {
+ RemoveInternalEdges();
+ }
+ //----------------------------------
// Coding of regularities.
//----------------------------------
EncodeRegularity();
//
// check offset faces on the coincidence of the
// bi-normal directions with the original faces
- CheckBiNormals(aLFImages, aF, theOrigins, aLFKeep);
+ CheckBiNormals(aLFImages, aF, theOrigins, aLFKeep, myRemoveInvalidFaces);
//
// limit the face
if (aLFImages.Extent() > 1) {
//
// check the result
Standard_Boolean bGood = Standard_True;
- BOPCol_ListIteratorOfListOfShape aItLSF(aLSF);
- for (; aItLSF.More(); aItLSF.Next()) {
- const TopoDS_Shape& aFx = aItLSF.Value();
- if (!aMFResult.Contains(aFx)) {
- const TopTools_ListOfShape& aLFMx = aMV1.Modified(aFx);
- if (aLFMx.IsEmpty()) {
- bGood = Standard_False;
- break;
+ if (myRemoveInvalidFaces) {
+ BOPCol_ListIteratorOfListOfShape aItLSF(aLSF);
+ for (; aItLSF.More(); aItLSF.Next()) {
+ const TopoDS_Shape& aFx = aItLSF.Value();
+ if (!aMFResult.Contains(aFx)) {
+ const TopTools_ListOfShape& aLFMx = aMV1.Modified(aFx);
+ if (aLFMx.IsEmpty()) {
+ bGood = Standard_False;
+ break;
+ }
}
}
}
#endif
}
+//=======================================================================
+//function : RemoveInternalEdges
+//purpose :
+//=======================================================================
+void BRepOffset_MakeOffset::RemoveInternalEdges()
+{
+ Standard_Boolean bRemoveWire, bRemoveEdge;
+ TopExp_Explorer aExpF, aExpW, aExpE;
+ TopTools_IndexedDataMapOfShapeListOfShape aDMELF;
+ //
+ TopExp::MapShapesAndAncestors(myOffsetShape, TopAbs_EDGE, TopAbs_FACE, aDMELF);
+ //
+ aExpF.Init(myOffsetShape, TopAbs_FACE);
+ for (; aExpF.More(); aExpF.Next()) {
+ TopoDS_Face& aF = *(TopoDS_Face*)&aExpF.Current();
+ //
+ TopTools_ListOfShape aLIW;
+ //
+ aExpW.Init(aF, TopAbs_WIRE);
+ for (; aExpW.More(); aExpW.Next()) {
+ TopoDS_Wire& aW = *(TopoDS_Wire*)&aExpW.Current();
+ //
+ bRemoveWire = Standard_True;
+ TopTools_ListOfShape aLIE;
+ //
+ aExpE.Init(aW, TopAbs_EDGE);
+ for (; aExpE.More(); aExpE.Next()) {
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExpE.Current();
+ if (aE.Orientation() != TopAbs_INTERNAL) {
+ bRemoveWire = Standard_False;
+ continue;
+ }
+ //
+ const TopTools_ListOfShape& aLF = aDMELF.FindFromKey(aE);
+ bRemoveEdge = (aLF.Extent() == 1);
+ if (bRemoveEdge) {
+ aLIE.Append(aE);
+ }
+ else {
+ bRemoveWire = Standard_False;
+ }
+ }
+ //
+ if (bRemoveWire) {
+ aLIW.Append(aW);
+ }
+ else if (aLIE.Extent()) {
+ RemoveShapes(aW, aLIE);
+ }
+ }
+ //
+ if (aLIW.Extent()) {
+ RemoveShapes(aF, aLIW);
+ }
+ }
+}
//=======================================================================
// static methods implementation
//=======================================================================
+//=======================================================================
+//function : RemoveShapes
+//purpose : Removes the shapes <theLS> from the shape <theS>
+//=======================================================================
+void RemoveShapes(TopoDS_Shape& theS,
+ const TopTools_ListOfShape& theLS)
+{
+ BRep_Builder aBB;
+ //
+ Standard_Boolean bFree = theS.Free();
+ theS.Free(Standard_True);
+ //
+ TopTools_ListIteratorOfListOfShape aIt(theLS);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aSI = aIt.Value();
+ aBB.Remove(theS, aSI);
+ }
+ //
+ theS.Free(bFree);
+}
+
//=======================================================================
//function : UpDateTolerance
//purpose :
const TopTools_IndexedDataMapOfShapeListOfShape& theOrigins,
const TopTools_MapOfShape& theMFence,
Standard_Boolean& bKeep,
- Standard_Boolean& bRemove)
+ Standard_Boolean& bRemove,
+ const Standard_Boolean RemoveInvalidFaces)
{
Standard_Boolean bChecked;
Standard_Integer aNbEdgesChecked;
Standard_Real anAngle;
- TopTools_ListOfShape aLEInv;
+ TopTools_IndexedMapOfShape aMEInv;
//
aNbEdgesChecked = 0;
//
}
}
//
+ if (!RemoveInvalidFaces) {
+ if (theMFence.Contains(aEIm)) {
+ bChecked = Standard_True;
+ bKeep = Standard_True;
+ bRemove = Standard_False;
+ return bChecked;
+ }
+ }
+ //
const TopoDS_Edge& aEOr = *(TopoDS_Edge*)&aLEOr.First();
//
TopoDS_Edge aEOrF;
++aNbEdgesChecked;
//
anAngle = aDB1.Angle(aDB2);
- if (Abs(anAngle - M_PI) < Precision::Confusion()) {
- aLEInv.Append(aEIm);
+ if (Abs(anAngle - M_PI) < 1.e-4) {
+ aMEInv.Add(aEIm);
}
}
//
bKeep = Standard_True;
bRemove = Standard_False;
//
- if (aLEInv.IsEmpty()) {
+ Standard_Integer aNb = aMEInv.Extent();
+ if (aNb == 0) {
return bChecked;
}
//
- TopTools_ListIteratorOfListOfShape aItLS(aLEInv);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aE = aItLS.Value();
- if (theMFence.Contains(aE)) {
- bKeep = Standard_False;
- bRemove = Standard_True;
- break;
- }
+ if (aNb == aNbEdgesChecked) {
+ bKeep = Standard_False;
+ bRemove = Standard_True;
}
//
if (!bRemove) {
- if (aNbEdgesChecked == aLEInv.Extent()) {
- bKeep = Standard_False;
- bRemove = Standard_True;
+ for (Standard_Integer i = 1; i <= aNb; ++i) {
+ const TopoDS_Shape& aE = aMEInv(i);
+ if (theMFence.Contains(aE)) {
+ bKeep = Standard_False;
+ bRemove = Standard_True;
+ break;
+ }
}
}
//
(TopTools_ListOfShape& theLFImages,
const TopoDS_Face& theF,
const TopTools_IndexedDataMapOfShapeListOfShape& theOrigins,
- TopTools_ListOfShape& theLFKeep)
+ TopTools_ListOfShape& theLFKeep,
+ const Standard_Boolean RemoveInvalidFaces)
{
Standard_Boolean bChecked, bKeep, bRem;
Standard_Integer i, aNb;
for (; aItLF.More(); ) {
const TopoDS_Face& aFIm = *(TopoDS_Face*)&aItLF.Value();
//
- bChecked = CheckBiNormals(aFIm, aFOr, theOrigins, aMEToKeep, bKeep, bRem);
+ bChecked = CheckBiNormals(aFIm, aFOr, theOrigins, aMEToKeep, bKeep, bRem, RemoveInvalidFaces);
//
if (bChecked) {
if (bRem) {
//=======================================================================
Standard_Integer thickshell(Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+ Standard_Integer n, const char** a)
{
//OSD_Chronometer Clock;
if (n > 4)
{
if (!strcmp(a[4],"i"))
- JT = GeomAbs_Intersection;
+ JT = GeomAbs_Intersection;
if (!strcmp(a[4],"t"))
- JT = GeomAbs_Tangent;
+ JT = GeomAbs_Tangent;
}
Standard_Boolean Inter = Standard_False; //Standard_True;
Tol = Draw::Atof(a[5]);
BRepOffset_MakeOffset B;
- B.Initialize(S,Of,Tol,BRepOffset_Skin,Inter,0,JT, Standard_True);
+ B.Initialize(S,Of,Tol,BRepOffset_Skin,Inter,0,JT, Standard_False, Standard_True);
// Clock.Start();
static Standard_Real TheTolerance = Precision::Confusion();
static Standard_Boolean TheInter = Standard_False;
static GeomAbs_JoinType TheJoin = GeomAbs_Arc;
+static Standard_Boolean RemoveIntEdges = Standard_False;
+static Standard_Boolean RemoveInvalidFaces = Standard_False;
Standard_Integer offsetparameter(Draw_Interpretor& di,
- Standard_Integer n, const char** a)
+ Standard_Integer n, const char** a)
{
if ( n == 1 ) {
- //cout << " OffsetParameter Tol Inter(c/p) JoinType(a/i)" << endl;
- //cout << " Current Values" << endl;
- //cout << " --> Tolerance :" << TheTolerance << endl;
- //cout << " --> TheInter :";
- di << " OffsetParameter Tol Inter(c/p) JoinType(a/i)" << "\n";
+ di << " OffsetParameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k) RemoveInvalidFaces(r/k)] " << "\n";
di << " Current Values" << "\n";
- di << " --> Tolerance :" << TheTolerance << "\n";
- di << " --> TheInter :";
+ di << " --> Tolerance : " << TheTolerance << "\n";
+ di << " --> TheInter : ";
if ( TheInter) {
- //cout << "Complet" ;
di << "Complet" ;
} else {
- //cout << "Partial";
di << "Partial";
}
- //cout << endl << " --> TheJoin :";
- di << "\n" << " --> TheJoin :";
+ di << "\n" << " --> TheJoin : ";
switch (TheJoin) {
- //case GeomAbs_Arc: cout << " Arc"; break;
- //case GeomAbs_Intersection: cout << " Intersection"; break;
- case GeomAbs_Arc: di << " Arc"; break;
- case GeomAbs_Intersection: di << " Intersection"; break;
+ case GeomAbs_Arc: di << "Arc"; break;
+ case GeomAbs_Intersection: di << "Intersection"; break;
default:
break ;
}
- //cout << endl;
+ //
+ di << "\n" << " --> Internal Edges : ";
+ if (RemoveIntEdges) {
+ di << "Remove";
+ }
+ else {
+ di << "Keep";
+ }
+ //
+ di << "\n" << " --> Invalid Faces : ";
+ if (RemoveInvalidFaces) {
+ di << "Remove";
+ }
+ else {
+ di << "Keep";
+ }
di << "\n";
-
+ //
return 0;
}
if ( n < 4 ) return 1;
-
+ //
TheTolerance = Draw::Atof(a[1]);
TheInter = strcmp(a[2],"p");
-
+ //
if ( !strcmp(a[3],"a")) TheJoin = GeomAbs_Arc;
else if ( !strcmp(a[3],"i")) TheJoin = GeomAbs_Intersection;
else if ( !strcmp(a[3],"t")) TheJoin = GeomAbs_Tangent;
-
- return 0;
+ //
+ RemoveIntEdges = (n >= 5) ? !strcmp(a[4], "r") : Standard_False;
+ RemoveInvalidFaces = (n == 6) ? !strcmp(a[5], "r") : Standard_False;
+ //
+ return 0;
}
//=======================================================================
Standard_Integer offsetload(Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+ Standard_Integer n, const char** a)
{
if ( n < 2) return 1;
TopoDS_Shape S = DBRep::Get(a[1]);
TheRadius = Of;
// Standard_Boolean Inter = Standard_True;
- TheOffset.Initialize(S,Of,TheTolerance,BRepOffset_Skin,TheInter,0,TheJoin);
+ TheOffset.Initialize(S,Of,TheTolerance,BRepOffset_Skin,TheInter,0,TheJoin,
+ RemoveIntEdges,Standard_False,RemoveInvalidFaces);
//------------------------------------------
// recuperation et chargement des bouchons.
//----------------------------------------