Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]
### Fixed
- Filling a cavity in an ordinary manifold union preserves the material region in either operand order.

## [1.1.0-alpha.1]
### Fixed
- `smlib_fillet` no longer ends a round with a smooth-vertex End and a plane cap where its edge runs on into an edge whose faces meet tangentially (a flat side running onto a round end), which has no convexity and is no edge of a tangent chain. The round ends on the end face past the vertex, as before 1.1.0-alpha; such a round no longer gains two cap faces on the walls it ends on.
Expand Down
23 changes: 23 additions & 0 deletions capi/tests/booleans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ void expect(const char *what, const smlib_brep *a, const smlib_brep *b, int32_t
smlib_brep_free(r);
}

// Refill a box-shaped cavity exactly, or with a box overlapping its inner walls.
void cavity_fill()
{
smlib_brep *outer = box(0, 0, 0, 10, 10, 10);
smlib_brep *inner = box(2, 2, 2, 8, 8, 8);
smlib_brep *larger = box(1, 1, 1, 9, 9, 9);
smlib_brep *hollow = nullptr;
CHECK(smlib_boolean(outer, inner, SMLIB_BOOLEAN_SUBTRACT, &hollow) == SMLIB_OK);
if (hollow != nullptr)
{
for (const smlib_brep *fill : {inner, larger})
{
expect("hollow union fill", hollow, fill, SMLIB_BOOLEAN_UNION, 1000, 1e-7, 1);
expect("fill union hollow", fill, hollow, SMLIB_BOOLEAN_UNION, 1000, 1e-7, 1);
}
}
for (smlib_brep *b : {hollow, larger, inner, outer})
{
smlib_brep_free(b);
}
}

// A cylinder of SMLib's own along `axis` (0 x, 1 y, 2 z) from its base centre.
smlib_brep *cylinder(int axis, double x, double y, double z, double r, double h)
{
Expand Down Expand Up @@ -1175,6 +1197,7 @@ int main(int argc, char **argv)
{"cylinder_grazing_box_edge", cylinder_grazing_box_edge},
{"pleated_skins_join", pleated_skins_join},
{"grazing_edge_crossing", grazing_edge_crossing},
{"cavity_fill", cavity_fill},
{"sealed_void_join", sealed_void_join},
{"overlapped_k_joint", overlapped_k_joint},
{"equal_rods_join", equal_rods_join},
Expand Down
10 changes: 10 additions & 0 deletions source/SMLib/inc/SmTopologyIntersector.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ class SM_EXPORT SmTopologyIntersector
///< : NULL to ignore, default:[NULL]. <br>
) ;


// Internal ordinary manifold union variant; the existing two-argument
// symbol and all callers retain their original survivor semantics.
SmStatus DeleteFaces
(
const SmTArray<SmFace*> & crFaces,
const SmTArray<SmEdge*> * pOptKeepAsWires,
SmBoolean bUnionKeepUnattributedSolid
);

SmStatus FixGaps
(
const SmTArray<SmVertex*> & crSingleVertices, ///< [in ]: list of single vertices <br>
Expand Down
6 changes: 5 additions & 1 deletion source/SMLib/src/SmMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5119,7 +5119,11 @@ static ULONG lDebugCount = 0 ;
// STEP 6. delete Brep->faces on the DelFaces list
// note: when Infinite region happens to be merged, it's kept and the other merge region is deleted
{
SER(m_vTI.DeleteFaces(sDelFaces, &sKeepAsWires));
const SmBoolean bUnionKeepUnattributedSolid =
eOperation==SM_BO_UNION && m_bManifoldBoolean && !m_bImprinting
&& !m_bImprintAndClassifyFaces && !m_bCookieCutter
&& !m_bKeepOtherBrep && m_bBooleanPostProcess;
SER(m_vTI.DeleteFaces(sDelFaces, &sKeepAsWires, bUnionKeepUnattributedSolid));

} // end STEP 6 - delete Brep->faces on the DelFaces list

Expand Down
35 changes: 31 additions & 4 deletions source/SMLib/src/SmTopologyIntersector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "StdAfx.h"

#include <SmTopologyIntersector.h>
#include <SmAttribute.h>

#ifndef __SMBREP_H__
#include <SmBrep.h>
Expand Down Expand Up @@ -456,13 +457,21 @@ PURPOSE: Remove faces listed in crFaces from the merge Brep and
NOTES: when Infinite Region happens to be merged, it is kept and
the region to which it is being merged is deleted.
***********************************************************************/
SmStatus SmTopologyIntersector::DeleteFaces
(const SmTArray<SmFace*> & crFaces,
const SmTArray<SmEdge*> * pOptKeepAsWires)
{
return DeleteFaces(crFaces,pOptKeepAsWires,FALSE);
}

SmStatus SmTopologyIntersector::DeleteFaces
(const SmTArray<SmFace*> & crFaces, // in : Brep faces to delete
const SmTArray<SmEdge*> * pOptKeepAsWires) // in : list of edges to turn into wires if all the faces
const SmTArray<SmEdge*> * pOptKeepAsWires, // in : list of edges to turn into wires if all the faces
// to which they are attached happen to get deleted.
// Edges not on this list are deleted when all
// the faces to which they are attached are deleted.
// NULL to ignore, default:[NULL].
SmBoolean bUnionKeepUnattributedSolid) // in : narrowly scoped normal manifold union policy
{
// locals
SmTArray<SmVertex*> sFacesVertices(128), sFaceVertices(128);
Expand Down Expand Up @@ -512,9 +521,27 @@ SmBoolean bDebugMe = FALSE;
}
#endif // SM_DEBUG_CODE

// delete TargetFace from its Brep
// note: when Infinite region merges it's kept and other region is deleted
SER( pBrep->DeleteFace( pF, FALSE )); // FALSE = don't delete dangling edges and vertices,
// For ordinary manifold union only, a face may disappear
// between two *unattributed* A regions. A material point is necessarily
// material in A union B. Keep the existing A-solid region rather than
// DeleteFace's generic void preference, but only when both regions are
// non-infinite and neither has Boolean merge ancestry to propagate.
// Other operations, specialized modes and attributed merges retain the
// original survivor policy and STEP7 ancestry-based truth calculation.
SmRegion* pUnionRegionToKeep = NULL;
if (bUnionKeepUnattributedSolid) {
SmFaceuse *pUse1=NULL,*pUse2=NULL; pF->GetFaceuses(pUse1,pUse2);
SmRegion* r1=(pUse1 && pUse1->GetShell()) ? pUse1->GetShell()->GetRegion() : NULL;
SmRegion* r2=(pUse2 && pUse2->GetShell()) ? pUse2->GetShell()->GetRegion() : NULL;
if (r1 && r2 && r1!=r2 && !r1->IsInfiniteRegion() && !r2->IsInfiniteRegion()
&& r1->IsVoid()!=r2->IsVoid()
&& !r1->FindAttribute(SM_AI_OTHER_REGION_ID)
&& !r2->FindAttribute(SM_AI_OTHER_REGION_ID))
pUnionRegionToKeep = r1->IsVoid() ? r2 : r1;
}

// The selection above excludes infinite regions; otherwise use default policy.
SER( pBrep->DeleteFace( pF, FALSE, TRUE, NULL, pUnionRegionToKeep )); // FALSE = don't delete dangling edges and vertices,
// we do that below in accordance with pOptKeepAsWires.
#ifdef SM_DEBUG_CODE
if (bDebugMe)
Expand Down