Example #1
0
OCCFace *OCCFace::copy(bool deepCopy = false)
{
    OCCFace *ret = new OCCFace();
    try {
        if (deepCopy) {
            BRepBuilderAPI_Copy A;
            A.Perform(this->getShape());
            ret->setShape(A.Shape());
        } else {
            ret->setShape(this->getShape());
        }
    } catch(Standard_Failure &err) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        const Standard_CString msg = e->GetMessageString();
        if (msg != NULL && strlen(msg) > 1) {
            setErrorMessage(msg);
        } else {
            setErrorMessage("Failed to copy face");
        }
        return NULL;
    }
    return ret;
}
Example #2
0
int extractSubShape(const TopoDS_Shape& shape, std::vector<OCCBase *>& shapes)
{
    TopAbs_ShapeEnum type = shape.ShapeType();
    switch (type)
    {
    case TopAbs_COMPOUND:
        return 0;
    case TopAbs_COMPSOLID:
    case TopAbs_SOLID:
    {
        OCCSolid *ret = new OCCSolid();
        ret->setShape(shape);
        if (!ret->fixShape()) {
            delete ret;
            return 0;
        }
        shapes.push_back((OCCBase *)ret);
        break;
    }
    case TopAbs_FACE:
    case TopAbs_SHELL:
    {
        OCCFace *ret = new OCCFace();
        ret->setShape(shape);
        if (!ret->fixShape()) {
            delete ret;
            return 0;
        }
        shapes.push_back((OCCBase *)ret);
        break;
    }
    case TopAbs_WIRE:
    {
        OCCWire *ret = new OCCWire();
        ret->setShape(shape);
        if (!ret->fixShape()) {
            delete ret;
            return 0;
        }
        shapes.push_back((OCCBase *)ret);
        break;
    }
    case TopAbs_EDGE:
    {
        OCCEdge *ret = new OCCEdge();
        ret->setShape(shape);
        if (!ret->fixShape()) {
            delete ret;
            return 0;
        }
        shapes.push_back((OCCBase *)ret);
        break;
    }
    case TopAbs_VERTEX:
    {
        OCCVertex *ret = new OCCVertex();
        ret->setShape(shape);
        if (!ret->fixShape()) {
            delete ret;
            return 0;
        }
        shapes.push_back((OCCBase *)ret);
        break;
    }
    default:
        return 0;
    }
    return 1;
}