myInitialShape = theShape;
}
+//=======================================================================
+//function : BRepOffsetAPI_PatchFaces
+//purpose : Empty constructor
+//=======================================================================
+BRepOffsetAPI_PatchFaces::BRepOffsetAPI_PatchFaces()
+{}
+
+//=======================================================================
+//function : Clear
+//purpose :
+//=======================================================================
+void BRepOffsetAPI_PatchFaces::Clear()
+{
+ myFacePatchFace.Clear();
+ myFaceNewFace.Clear();
+ myNewFaceBoundedFace.Clear();
+ myEdgeNewEdge.Clear();
+ myVertexNewVertex.Clear();
+ myTangentEdges.Clear();
+ mySmoothEdges.Clear();
+ myEFmap.Clear();
+ myVEmap.Clear();
+ myVFmap.Clear();
+}
+
//=======================================================================
//function : SetOffsetFace
//purpose :
myFacePatchFace.Add(aFace, anOrientedPatchFace);
}
+//=======================================================================
+//function : GetPatchFace
+//purpose :
+//=======================================================================
+TopoDS_Face BRepOffsetAPI_PatchFaces::GetPatchFace(const TopoDS_Face& theFace) const
+{
+ const TopoDS_Shape* anInitialPatchFace = myFacePatchFace.Seek(theFace);
+ if (!anInitialPatchFace)
+ {
+ TopoDS_Face aNullFace;
+ return aNullFace;
+ }
+
+ const TopoDS_Face& aPatch = TopoDS::Face(myNewFaceBoundedFace(*anInitialPatchFace));
+ return aPatch;
+}
+
+//=======================================================================
+//function : Get
+//purpose :
+//=======================================================================
+void BRepOffsetAPI_PatchFaces::GetAdjacentFaces(const TopoDS_Face& theFace,
+ TopTools_ListOfShape& theNeighbors) const
+{
+ const TopoDS_Shape* anInitialPatchFace = myFacePatchFace.Seek(theFace);
+ if (!anInitialPatchFace)
+ return;
+
+ // Fence map to avoid duplicates in the list
+ TopTools_MapOfShape aMFence;
+ // Find all adjacent faces in the initial solid
+ TopExp_Explorer anExpV(theFace, TopAbs_VERTEX);
+ for (; anExpV.More(); anExpV.Next())
+ {
+ const TopoDS_Shape& aVertex = anExpV.Current();
+ const TopTools_ListOfShape& aLFaces = myVFmap.Find(aVertex);
+
+ TopTools_ListIteratorOfListOfShape aItLF(aLFaces);
+ for (; aItLF.More(); aItLF.Next())
+ {
+ const TopoDS_Shape& aFace = aItLF.Value();
+ if (aFace.IsSame(theFace) || !aMFence.Add(aFace))
+ continue;
+
+ // Get face from the result solid
+ const TopoDS_Shape* pNewFace = myFaceNewFace.Seek(aFace);
+ if (pNewFace)
+ theNeighbors.Append(myNewFaceBoundedFace(*pNewFace));
+ else
+ theNeighbors.Append(aFace);
+ }
+ }
+}
+
//=======================================================================
//function : Build
//purpose :
//! General constructor.
Standard_EXPORT BRepOffsetAPI_PatchFaces(const TopoDS_Shape& aShape);
-
+
+ //! Empty constructor.
+ Standard_EXPORT BRepOffsetAPI_PatchFaces();
+
+ //! Sets the model
+ void SetShape(const TopoDS_Shape& theShape)
+ {
+ myInitialShape = theShape;
+ }
+
+ //! Clears the contents from the previous runs
+ Standard_EXPORT void Clear();
+
//! Adds the patch face for the face in the shape.
Standard_EXPORT void AddPatchFace (const TopoDS_Face& theFace, const TopoDS_Face& thePatchFace);
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
+ //! Returns the patched face, updated to fit the model, for the given face <theFace>.
+ //! If there is no patched faces for the given face, the returned face will be null.
+ Standard_EXPORT TopoDS_Face GetPatchFace(const TopoDS_Face& theFace) const;
+ //! Returns the list of the faces, updated to fit the model, adjacent to the given replaced face.
+ //! If the given face has not been replaced, the list will be empty.
+ Standard_EXPORT void GetAdjacentFaces(const TopoDS_Face& theFace, TopTools_ListOfShape& theNeighbors) const;
protected:
return 1;
}
+static BRepOffsetAPI_PatchFaces aPFBuilder;
//=======================================================================
//function : patchfaces
//purpose :
if (aLocalNewFace.IsNull()) return 1;
TopoDS_Face aNewFace = TopoDS::Face(aLocalNewFace);
- BRepOffsetAPI_PatchFaces Builder(aShape);
- Builder.AddPatchFace(aFace, aNewFace);
- Builder.Build();
+ aPFBuilder.Clear();
+ aPFBuilder.SetShape(aShape);
+ aPFBuilder.AddPatchFace(aFace, aNewFace);
+ aPFBuilder.Build();
- TopoDS_Shape Result = Builder.Shape();
+ const TopoDS_Shape& Result = aPFBuilder.Shape();
DBRep::Set(a[1], Result);
return 0;
}
+//=======================================================================
+//function : pfgetpatchface
+//purpose :
+//=======================================================================
+static Standard_Integer pfgetpatchface(Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
+{
+ if (n != 3)
+ {
+ di << di.PrintHelp(a[0]);
+ return 1;
+ }
+
+ if (!aPFBuilder.IsDone())
+ {
+ di << "perform PatchFace operation first\n";
+ return 1;
+ }
+
+ TopoDS_Shape anInitialFace = DBRep::Get(a[2]);
+ if (anInitialFace.IsNull())
+ {
+ di << "The shape " << a[2] << " is a null shape\n";
+ return 1;
+ }
+
+ TopoDS_Shape aPatch = aPFBuilder.GetPatchFace(TopoDS::Face(anInitialFace));
+
+ DBRep::Set(a[1], aPatch);
+
+ return 0;
+}
+
+//=======================================================================
+//function : pfgetadjacentfaces
+//purpose :
+//=======================================================================
+static Standard_Integer pfgetadjacentfaces(Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
+{
+ if (n != 3)
+ {
+ di << di.PrintHelp(a[0]);
+ return 1;
+ }
+
+ if (!aPFBuilder.IsDone())
+ {
+ di << "perform PatchFace operation first\n";
+ return 1;
+ }
+
+ TopoDS_Shape anInitialFace = DBRep::Get(a[2]);
+ if (anInitialFace.IsNull())
+ {
+ di << "The shape " << a[2] << " is a null shape\n";
+ return 1;
+ }
+
+ TopTools_ListOfShape aLF;
+ aPFBuilder.GetAdjacentFaces(TopoDS::Face(anInitialFace), aLF);
+
+ BRep_Builder aBB;
+ TopoDS_Compound aCFN;
+ aBB.MakeCompound(aCFN);
+
+ TopTools_ListIteratorOfListOfShape aIt(aLF);
+ for (; aIt.More(); aIt.Next())
+ aBB.Add(aCFN, aIt.Value());
+
+ DBRep::Set(a[1], aCFN);
+
+ return 0;
+}
+
//=======================================================================
//function : FeatureCommands
//purpose :
theCommands.Add("patchfaces", "patchfaces res shape face newface",
__FILE__,patchfaces,g);
+
+ theCommands.Add("pfgetpatchface", "Get the patched face, updated to fit the model, for the given face.\n"
+ "Usage: pfgetpatchface res face", __FILE__, pfgetpatchface, g);
+
+ theCommands.Add("pfgetadjacentfaces", "Returns the list of the faces, updated to fit the model, adjacent to the given replaced face.\n"
+ "Usage: pfgetadjacentfaces res face", __FILE__, pfgetadjacentfaces, g);
}