std::unique_ptr<BSPNode> BSPUnion(std::unique_ptr<BSPNode> a, std::unique_ptr<BSPNode> b) { if(!a || b->isleaf == UNDER || a->isleaf==OVER) { if(a && b->isleaf==UNDER) { FaceCutting(a.get(), b->brep); } return b; } if(a->isleaf == UNDER || b->isleaf==OVER) { return a; } std::unique_ptr<BSPNode> aover; std::unique_ptr<BSPNode> aunder; // its like "b" is the master, so a should be the little object and b is the area's shell assert(!a->isleaf); BSPPartition(move(a), float4(b->xyz(), b->w), aunder, aover); assert(aunder || aover); b->under = BSPUnion(move(aunder), move(b->under)); b->over = BSPUnion(move(aover), move(b->over)); /* if(fusenodes) { if(b->over->isleaf == UNDER) { DeriveCells(b->under,b->cell); return b->under; } if(b->under->isleaf == OVER) { DeriveCells(b->over,b->cell); return b->over; } } */ return b; }
BSPNode *BSPUnion(BSPNode *a,BSPNode *b) { if(!a || b->isleaf == UNDER || a->isleaf==OVER) { if(a && b->isleaf==UNDER) { FaceCutting(a,b->brep); } return b; } if(a->isleaf == UNDER || b->isleaf==OVER) { return a; } BSPNode *aover; BSPNode *aunder; // its like "b" is the master, so a should be the little object and b is the area's shell assert(!a->isleaf); BSPPartition(a, float4(b->xyz(), b->w), aunder, aover); assert(aunder || aover); b->under = BSPUnion(aunder,b->under); b->over = BSPUnion(aover ,b->over ); /* if(fusenodes) { if(b->over->isleaf == UNDER) { DeriveCells(b->under,b->cell); return b->under; } if(b->under->isleaf == OVER) { DeriveCells(b->over,b->cell); return b->over; } } */ return b; }