本文整理汇总了C++中BRep_Builder类的典型用法代码示例。如果您正苦于以下问题:C++ BRep_Builder类的具体用法?C++ BRep_Builder怎么用?C++ BRep_Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BRep_Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeWire
const TopoDS_Shape& BRepOffsetAPI_MakeOffsetFix::Shape()
{
if (myResult.IsNull()) {
TopoDS_Shape result = mkOffset.Shape();
if (result.ShapeType() == TopAbs_WIRE) {
MakeWire(result);
}
else if (result.ShapeType() == TopAbs_COMPOUND) {
BRep_Builder builder;
TopoDS_Compound comp;
builder.MakeCompound(comp);
TopExp_Explorer xp(result, TopAbs_WIRE);
while (xp.More()) {
TopoDS_Wire wire = TopoDS::Wire(xp.Current());
MakeWire(wire);
builder.Add(comp, wire);
xp.Next();
}
result = comp;
}
myResult = result;
}
return myResult;
}
示例2: TopoDS_Shape
Part::TopoShape ShapeBinder::buildShapeFromReferences( Part::Feature* obj, std::vector< std::string > subs) {
if (!obj)
return TopoDS_Shape();
if (subs.empty())
return obj->Shape.getShape();
std::vector<TopoDS_Shape> shapes;
for (std::string sub : subs) {
shapes.push_back(obj->Shape.getShape().getSubShape(sub.c_str()));
}
if (shapes.size() == 1){
//single subshape. Return directly.
return shapes[0];
} else {
//multiple subshapes. Make a compound.
BRep_Builder builder;
TopoDS_Compound cmp;
builder.MakeCompound(cmp);
for(const TopoDS_Shape& sh : shapes){
builder.Add(cmp, sh);
}
return cmp;
}
}
示例3: getSectionPlane
//! tries to find the intersection of the section plane with the shape giving a collection of planar faces
TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shape& shape)
{
TopoDS_Compound result;
if(shape.IsNull()){
Base::Console().Log("DrawViewSection::getSectionSurface - Sectional View shape is Empty\n");
return result;
}
gp_Pln plnSection = getSectionPlane();
BRep_Builder builder;
builder.MakeCompound(result);
TopExp_Explorer expFaces(shape, TopAbs_FACE);
int i;
int dbAdded = 0;
for (i = 1 ; expFaces.More(); expFaces.Next(), i++) {
const TopoDS_Face& face = TopoDS::Face(expFaces.Current());
BRepAdaptor_Surface adapt(face);
if (adapt.GetType() == GeomAbs_Plane){
gp_Pln plnFace = adapt.Plane();
if(plnSection.Contains(plnFace.Location(), Precision::Confusion()) &&
plnFace.Axis().IsParallel(plnSection.Axis(), Precision::Angular())) {
dbAdded++;
builder.Add(result, face);
}
}
}
return result;
}
示例4: add
PyObject* TopoShapeCompSolidPy::add(PyObject *args)
{
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeSolidPy::Type), &obj))
return NULL;
BRep_Builder builder;
TopoDS_Shape& comp = getTopoShapePtr()->_Shape;
try {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>(obj)->
getTopoShapePtr()->_Shape;
if (!sh.IsNull())
builder.Add(comp, sh);
else
Standard_Failure::Raise("Cannot empty shape to compound solid");
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
Py_Return;
}
示例5: PNamedShape
CGroupShapes::CGroupShapes(const ListPNamedShape& list)
{
if (list.size() == 1) {
_result = list[0];
return;
}
BRep_Builder b;
TopoDS_Compound c;
b.MakeCompound(c);
for (ListPNamedShape::const_iterator it=list.begin(); it != list.end(); ++it) {
PNamedShape shape = *it;
if (!shape) {
continue;
}
b.Add(c, shape->Shape());
}
_result = PNamedShape(new CNamedShape(c, "ShapeGroup"));
// apply face names from the shapes
for (ListPNamedShape::const_iterator it=list.begin(); it != list.end(); ++it) {
PNamedShape shape = *it;
if (!shape) {
continue;
}
CBooleanOperTools::AppendNamesToShape(shape, _result);
}
}
示例6:
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeProfileDef* l, TopoDS_Shape& face) {
// BRepBuilderAPI_MakeFace mf;
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
IfcSchema::IfcProfileDef::list::ptr profiles = l->Profiles();
//bool first = true;
for (IfcSchema::IfcProfileDef::list::it it = profiles->begin(); it != profiles->end(); ++it) {
TopoDS_Face f;
if (convert_face(*it, f)) {
builder.Add(compound, f);
/* TopExp_Explorer exp(f, TopAbs_WIRE);
for (; exp.More(); exp.Next()) {
const TopoDS_Wire& wire = TopoDS::Wire(exp.Current());
if (first) {
mf.Init(BRepBuilderAPI_MakeFace(wire));
} else {
mf.Add(wire);
}
first = false;
} */
}
}
face = compound;
return !face.IsNull();
}
示例7: writeVRML
int OCCTools::writeVRML(const char *filename, std::vector<OCCBase *> shapes)
{
try {
BRep_Builder B;
TopoDS_Compound shape;
B.MakeCompound(shape);
for (unsigned i = 0; i < shapes.size(); i++) {
B.Add(shape, shapes[i]->getShape());
}
VrmlAPI_Writer writer;
writer.Write(shape, filename);
} catch(Standard_Failure &err) {
Handle_Standard_Failure e = Standard_Failure::Caught();
const Standard_CString msg = e->GetMessageString();
//printf("ERROR: %s\n", e->GetMessageString());
if (msg != NULL && strlen(msg) > 1) {
setErrorMessage(msg);
} else {
setErrorMessage("Failed to write VRML file");
}
return 0;
}
return 1;
}
示例8: OnReadInsert
void DraftDxfRead::OnReadInsert(const double* point, const double* scale, const char* name, double rotation)
{
std::cout << "Inserting block " << name << " rotation " << rotation << " pos " << point[0] << "," << point[1] << "," << point[2] << std::endl;
for(std::map<std::string,std::vector<Part::TopoShape*> > ::const_iterator i = layers.begin(); i != layers.end(); ++i) {
std::string k = i->first;
std::string prefix = "BLOCKS ";
prefix += name;
prefix += " ";
if(k.substr(0, prefix.size()) == prefix) {
BRep_Builder builder;
TopoDS_Compound comp;
builder.MakeCompound(comp);
std::vector<Part::TopoShape*> v = i->second;
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
const TopoDS_Shape& sh = (*j)->_Shape;
if (!sh.IsNull())
builder.Add(comp, sh);
}
if (!comp.IsNull()) {
Part::TopoShape* pcomp = new Part::TopoShape(comp);
Base::Matrix4D mat;
mat.scale(scale[0],scale[1],scale[2]);
mat.rotZ(rotation);
mat.move(point[0],point[1],point[2]);
pcomp->transformShape(mat,true);
AddObject(pcomp);
}
}
}
}
示例9: LOG
bool CTiglExportBrep::Write(const std::string& filename) const
{
if (filename.empty()) {
LOG(ERROR) << "Error: Empty filename in CTiglExportBrep::Write.";
return false;
}
if (_shapes.size() > 1) {
TopoDS_Compound c;
BRep_Builder b;
b.MakeCompound(c);
for (ListPNamedShape::const_iterator it = _shapes.begin(); it != _shapes.end(); ++it) {
PNamedShape shape = *it;
if (shape) {
b.Add(c, shape->Shape());
}
}
// write the file
return BRepTools::Write(c, filename.c_str());
}
else if ( _shapes.size() == 1) {
PNamedShape shape = _shapes[0];
return BRepTools::Write(shape->Shape(), filename.c_str());
}
else {
LOG(WARNING) << "No shapes defined in BRep export. Abort!";
return false;
}
}
示例10: AddGraphics
void ImpExpDxfRead::AddGraphics() const
{
if (optionGroupLayers) {
for(std::map<std::string,std::vector<Part::TopoShape*> > ::const_iterator i = layers.begin(); i != layers.end(); ++i) {
BRep_Builder builder;
TopoDS_Compound comp;
builder.MakeCompound(comp);
std::string k = i->first;
if (k == "0") // FreeCAD doesn't like an object name being '0'...
k = "LAYER_0";
std::vector<Part::TopoShape*> v = i->second;
if(k.substr(0, 6) != "BLOCKS") {
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
const TopoDS_Shape& sh = (*j)->getShape();
if (!sh.IsNull())
builder.Add(comp, sh);
}
if (!comp.IsNull()) {
Part::Feature *pcFeature = (Part::Feature *)document->addObject("Part::Feature", k.c_str());
pcFeature->Shape.setValue(comp);
}
}
}
}
}
示例11: PyInit
// constructor method
int TopoShapeCompoundPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O!", &(PyList_Type), &pcObj))
return -1;
BRep_Builder builder;
TopoDS_Compound Comp;
builder.MakeCompound(Comp);
try {
Py::List list(pcObj);
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>((*it).ptr())->
getTopoShapePtr()->_Shape;
if (!sh.IsNull())
builder.Add(Comp, sh);
}
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return -1;
}
getTopoShapePtr()->_Shape = Comp;
return 0;
}
示例12: Perform
//#include <BRepBuilder.hxx>
TopoDS_Shape Edgesort::GetDesiredCutShape(int desiredIndex)
{
m_edges.clear();
m_EdgeBBoxMap.clear();
m_vertices.clear();
Perform();
if (m_EdgeBBoxMap.size()>1)
{
if (desiredIndex == 1) //Return the smallest to return it
{
m_edges = m_EdgeBBoxMap.begin()->second;
}
else
{
m_edges = m_EdgeBBoxMap.rbegin()->second;
}
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound(aCompound);
for (m_edgeIter = m_edges.begin();m_edgeIter!=m_edges.end();++m_edgeIter)
{
aBuilder.Add(aCompound,*m_edgeIter);
}
return aCompound;
}
else
{
return m_shape;
}
//Go through the edges of the result you do not like and remove this result from the original shape
}
示例13: getTopoShapePtr
PyObject* TopoShapeCompoundPy::connectEdgesToWires(PyObject *args)
{
PyObject *shared=Py_True;
double tol = Precision::Confusion();
if (!PyArg_ParseTuple(args, "|O!d",&PyBool_Type,&shared,&tol))
return 0;
try {
const TopoDS_Shape& s = getTopoShapePtr()->_Shape;
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(s, TopAbs_EDGE); xp.More(); xp.Next())
hEdges->Append(xp.Current());
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, tol, PyObject_IsTrue(shared), hWires);
TopoDS_Compound comp;
BRep_Builder builder;
builder.MakeCompound(comp);
int len = hWires->Length();
for(int i=1;i<=len;i++) {
builder.Add(comp, hWires->Value(i));
}
getTopoShapePtr()->_Shape = comp;
return new TopoShapeCompoundPy(new TopoShape(comp));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
}
示例14: add
PyObject* TopoShapeShellPy::add(PyObject *args)
{
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &obj))
return NULL;
BRep_Builder builder;
TopoDS_Shape& shell = getTopoShapePtr()->_Shape;
try {
const TopoDS_Shape& sh = static_cast<TopoShapeFacePy*>(obj)->
getTopoShapePtr()->_Shape;
if (!sh.IsNull()) {
builder.Add(shell, sh);
BRepCheck_Analyzer check(shell);
if (!check.IsValid()) {
ShapeUpgrade_ShellSewing sewShell;
getTopoShapePtr()->_Shape = sewShell.ApplySewing(shell);
}
}
else {
Standard_Failure::Raise("cannot add empty shape");
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
Py_Return;
}
示例15: add
PyObject* TopoShapeCompoundPy::add(PyObject *args)
{
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &obj))
return NULL;
BRep_Builder builder;
TopoDS_Shape comp = getTopoShapePtr()->getShape();
try {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>(obj)->
getTopoShapePtr()->getShape();
if (!sh.IsNull())
builder.Add(comp, sh);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
getTopoShapePtr()->setShape(comp);
Py_Return;
}