mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0026897: BRepBuilderAPI_Copy does not copy polygons
1. Implemented copying for 3D polygons and polygons on surfaces 2. Added test case bugs/modalg_6/bug26897
This commit is contained in:
@@ -25,9 +25,20 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
|
||||
Standard_Boolean BRepTools_Modification::NewTriangulation(const TopoDS_Face&, Handle(Poly_Triangulation)&)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Boolean BRepTools_Modification::NewPolygon(const TopoDS_Edge&, Handle(Poly_Polygon3D)&)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Boolean BRepTools_Modification::NewPolygonOnTriangulation(const TopoDS_Edge&, const TopoDS_Face&, Handle(Poly_PolygonOnTriangulation)&)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
@@ -34,6 +34,9 @@ class gp_Pnt;
|
||||
class Geom2d_Curve;
|
||||
class Poly_Triangulation;
|
||||
|
||||
class Poly_Polygon3D;
|
||||
class Poly_PolygonOnTriangulation;
|
||||
|
||||
|
||||
class BRepTools_Modification;
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_Modification, MMgt_TShared)
|
||||
@@ -74,6 +77,16 @@ public:
|
||||
//! If the edge has not been modified, this function
|
||||
//! returns false, and the values of C, L and Tol are not significant.
|
||||
Standard_EXPORT virtual Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C, TopLoc_Location& L, Standard_Real& Tol) = 0;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon
|
||||
Standard_EXPORT virtual Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P);
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon on triangulation
|
||||
Standard_EXPORT virtual Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F, Handle(Poly_PolygonOnTriangulation)& P);
|
||||
|
||||
//! Returns true if the vertex V has been modified.
|
||||
//! If V has been modified:
|
||||
|
@@ -330,6 +330,20 @@ Standard_Boolean BRepTools_Modifier::Rebuild
|
||||
B.SameRange(TopoDS::Edge(result),
|
||||
BRep_Tool::SameRange(TopoDS::Edge(S)));
|
||||
}
|
||||
|
||||
// update polygonal structure on the edge
|
||||
Handle(Poly_Polygon3D) aPolygon;
|
||||
if (M->NewPolygon(TopoDS::Edge(S), aPolygon))
|
||||
{
|
||||
if (rebuild) // the copied edge already exists => update it
|
||||
B.UpdateEdge(TopoDS::Edge(result), aPolygon, S.Location());
|
||||
else
|
||||
{ // create new edge with bare polygon
|
||||
B.MakeEdge(TopoDS::Edge(result), aPolygon);
|
||||
result.Location(S.Location());
|
||||
}
|
||||
rebuild = Standard_True;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -405,7 +419,7 @@ Standard_Boolean BRepTools_Modifier::Rebuild
|
||||
{
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
|
||||
|
||||
if (M->NewCurve2d(edge, face, TopoDS::Edge(myMap(ex.Current())), TopoDS::Face(result), curve2d, tol))
|
||||
if (M->NewCurve2d(edge, face, TopoDS::Edge(myMap(ex.Current())), TopoDS::Face(result), curve2d, tol))
|
||||
{
|
||||
// rem dub 16/09/97 : Make constant topology or not make at all.
|
||||
// Do not make if CopySurface = 1
|
||||
@@ -510,6 +524,39 @@ Standard_Boolean BRepTools_Modifier::Rebuild
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy polygon on triangulation
|
||||
Handle(Poly_PolygonOnTriangulation) aPolyOnTria_1, aPolyOnTria_2;
|
||||
Standard_Boolean aNewPonT = M->NewPolygonOnTriangulation(edge, face, aPolyOnTria_1);
|
||||
if (BRepTools::IsReallyClosed(edge, face))
|
||||
{
|
||||
// Obtain triangulation on reversed edge
|
||||
TopoDS_Edge anEdgeRev = edge;
|
||||
anEdgeRev.Reverse();
|
||||
aNewPonT = M->NewPolygonOnTriangulation(anEdgeRev, face, aPolyOnTria_2) || aNewPonT;
|
||||
// It there is only one polygon on triangulation, store it to aPolyOnTria_1
|
||||
if (aPolyOnTria_1.IsNull() && !aPolyOnTria_2.IsNull())
|
||||
{
|
||||
aPolyOnTria_1 = aPolyOnTria_2;
|
||||
aPolyOnTria_2 = Handle(Poly_PolygonOnTriangulation)();
|
||||
}
|
||||
}
|
||||
if (aNewPonT)
|
||||
{
|
||||
TopLoc_Location aLocation;
|
||||
Handle(Poly_Triangulation) aNewFaceTria =
|
||||
BRep_Tool::Triangulation(TopoDS::Face(myMap(face)), aLocation);
|
||||
TopoDS_Edge aNewEdge = TopoDS::Edge(myMap(edge));
|
||||
if (aPolyOnTria_2.IsNull())
|
||||
B.UpdateEdge(aNewEdge, aPolyOnTria_1, aNewFaceTria, aLocation);
|
||||
else
|
||||
{
|
||||
if (edge.Orientation() == TopAbs_FORWARD)
|
||||
B.UpdateEdge(aNewEdge, aPolyOnTria_1, aPolyOnTria_2, aNewFaceTria, aLocation);
|
||||
else
|
||||
B.UpdateEdge(aNewEdge, aPolyOnTria_2, aPolyOnTria_1, aNewFaceTria, aLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user