TopoNaming/Part: transfer makeElementThickSolid

This commit is contained in:
Zheng, Lei
2024-02-16 16:42:45 -05:00
committed by bgbsww
parent fc1d0cc71c
commit dc258745e0
2 changed files with 131 additions and 1 deletions

View File

@@ -194,6 +194,14 @@ enum class MapElement
map
};
/// Defines how to fill the holes that may appear after offset two adjacent faces
enum class JoinType
{
Arc,
Tangent,
Intersection,
};
/** The representation for a CAD Shape
*/
// NOLINTNEXTLINE cppcoreguidelines-special-member-functions
@@ -780,6 +788,53 @@ public:
}
//@}
/** Make a hollowed solid by removing some faces from a given solid
*
* @param source: input shape
* @param faces: list of faces to remove, must be sub shape of the input shape
* @param offset: thickness of the walls
* @param tol: tolerance criterion for coincidence in generated shapes
* @param intersection: whether to check intersection in all generated parallel.
* @param selfInter: whether to eliminate self intersection.
* @param offsetMode: defines the construction type of parallels applied to free edges
* @param join: join type. Only support JoinType::Arc and JoinType::Intersection.
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return The original content of this TopoShape is discarded and replaced
* with the new shape. The function returns the TopoShape itself as
* a self reference so that multiple operations can be carried out
* for the same shape in the same line of code.
*/
TopoShape &makeElementThickSolid(const TopoShape &source, const std::vector<TopoShape> &faces,
double offset, double tol, bool intersection = false, bool selfInter = false,
short offsetMode = 0, JoinType join = JoinType::Arc, const char *op=nullptr);
/** Make a hollowed solid by removing some faces from a given solid
*
* @param source: input shape
* @param faces: list of faces to remove, must be sub shape of the input shape
* @param offset: thickness of the walls
* @param tol: tolerance criterion for coincidence in generated shapes
* @param intersection: whether to check intersection in all generated parallel
* (OCCT document states the option is not fully implemented)
* @param selfInter: whether to eliminate self intersection
* (OCCT document states the option is not implemented)
* @param offsetMode: defines the construction type of parallels applied to free edges
* (OCCT document states the option is not implemented)
* @param join: join type. Only support JoinType::Arc and JoinType::Intersection.
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return Return the generated new shape. The TopoShape itself is not modified.
*/
TopoShape makeElementThickSolid(const std::vector<TopoShape> &faces,
double offset, double tol, bool intersection = false, bool selfInter = false,
short offsetMode = 0, JoinType join = JoinType::Arc, const char *op=nullptr) const {
return TopoShape(0,Hasher).makeElementThickSolid(*this,faces,offset,tol,intersection,selfInter,
offsetMode,join,op);
}
/* Make a shell or solid by sweeping profile wire along a spine
*
* @params sources: source shapes. The first shape is used as spine. The

View File

@@ -52,6 +52,7 @@
#include <BRepLib.hxx>
#include <BRepOffsetAPI_DraftAngle.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <BRepOffsetAPI_MakeThickSolid.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <ShapeUpgrade_ShellSewing.hxx>
#include <TopTools_HSequenceOfShape.hxx>
@@ -2053,6 +2054,76 @@ TopoShape& TopoShape::makeElementPipeShell(const std::vector<TopoShape>& shapes,
return makeElementShape(mkPipeShell, shapes, op);
}
TopoShape& TopoShape::makeElementThickSolid(const TopoShape& shape,
const std::vector<TopoShape>& faces,
double offset,
double tol,
bool intersection,
bool selfInter,
short offsetMode,
JoinType join,
const char* op)
{
if (!op) {
op = Part::OpCodes::Thicken;
}
// we do not offer tangent join type
switch (join) {
case JoinType::Arc:
case JoinType::Intersection:
break;
default:
join = JoinType::Intersection;
}
if (shape.isNull()) {
FC_THROWM(NullShapeException, "Null shape");
}
if (faces.empty()) {
FC_THROWM(NullShapeException, "Null input shape");
}
if (fabs(offset) <= 2 * tol) {
*this = shape;
return *this;
}
TopTools_ListOfShape remFace;
for (auto& face : faces) {
if (face.isNull()) {
FC_THROWM(NullShapeException, "Null input shape");
}
if (!shape.findShape(face.getShape())) {
FC_THROWM(Base::CADKernelError, "face does not belong to the shape");
}
remFace.Append(face.getShape());
}
#if OCC_VERSION_HEX < 0x070200
BRepOffsetAPI_MakeThickSolid mkThick(shape.getShape(),
remFace,
offset,
tol,
BRepOffset_Mode(offsetMode),
intersection ? Standard_True : Standard_False,
selfInter ? Standard_True : Standard_False,
GeomAbs_JoinType(join));
#else
BRepOffsetAPI_MakeThickSolid mkThick;
mkThick.MakeThickSolidByJoin(shape.getShape(),
remFace,
offset,
tol,
BRepOffset_Mode(offsetMode),
intersection ? Standard_True : Standard_False,
selfInter ? Standard_True : Standard_False,
GeomAbs_JoinType(join));
#endif
return makeElementShape(mkThick, shape, op);
}
TopoShape& TopoShape::makeElementWires(const std::vector<TopoShape>& shapes,
const char* op,
double tol,
@@ -2065,7 +2136,11 @@ TopoShape& TopoShape::makeElementWires(const std::vector<TopoShape>& shapes,
if (shapes.size() == 1) {
return makeElementWires(shapes[0], op, tol, policy, output);
}
return makeElementWires(TopoShape(Tag).makeElementCompound(shapes), op, tol, policy, output);
return makeElementWires(TopoShape(Tag).makeElementCompound(shapes),
op,
tol,
policy,
output);
}