本文整理汇总了C++中BRep_Builder::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ BRep_Builder::Add方法的具体用法?C++ BRep_Builder::Add怎么用?C++ BRep_Builder::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRep_Builder
的用法示例。
在下文中一共展示了BRep_Builder::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_Compound
TopoDS_Compound* OCCBody::make_Compound(DLIList<Lump*>& my_lumps,
DLIList<OCCShell*>& shells,
DLIList<OCCSurface*>& surfaces)
{
BRep_Builder B;
TopoDS_Compound Co;
B.MakeCompound(Co);
for(int i = 0; i < my_lumps.size(); i ++)
{
OCCLump* lump = CAST_TO(my_lumps.get_and_step(), OCCLump);
if(!lump)
{
PRINT_ERROR("Cannot create an OCC BodySM from the given lumps.\n"
"Possible incompatible geometry engines.\n");
return (TopoDS_Compound *)NULL;
}
TopoDS_Solid * solid = CAST_TO(lump, OCCLump)->get_TopoDS_Solid();
B.Add(Co, *solid);
}
for(int i = 0; i < shells.size(); i ++)
{
TopoDS_Shell * shell = shells.get_and_step()->get_TopoDS_Shell();
B.Add(Co, *shell);
}
for(int i = 0; i < surfaces.size(); i ++)
{
TopoDS_Face * face = surfaces.get_and_step()->get_TopoDS_Face();
B.Add(Co, *face);
}
TopoDS_Compound* new_top = new TopoDS_Compound(Co);
return new_top;
}
示例2:
//=======================================================================
//function : FillContainers
//purpose :
//=======================================================================
void GEOMAlgo_Gluer2::FillContainers(const TopAbs_ShapeEnum aType)
{
Standard_Boolean bHasImage, bToReverse;
Standard_Integer i, aNbW;
TopoDS_Shape aWnew, aEnew;
TopoDS_Iterator aItS;
BRep_Builder aBB;
TopTools_IndexedMapOfShape aMW;
TopTools_MapOfShape aMFence;
//
myErrorStatus=0;
myWarningStatus=0;
//
TopExp::MapShapes(myArgument, aType, aMW);
//
aNbW=aMW.Extent();
for (i=1; i<=aNbW; ++i) {
const TopoDS_Shape& aW=aMW(i);
//
if (!aMFence.Add(aW)) {
continue;
}
//
bHasImage=HasImage(aW);
if (!bHasImage) {
continue;
}
//
GEOMAlgo_Tools3D::MakeContainer(aType, aWnew);
aWnew.Orientation(aW.Orientation());
//
aItS.Initialize(aW);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aE=aItS.Value();
if (myOrigins.IsBound(aE)) {
aEnew=myOrigins.Find(aE);
//
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aEnew, aE, myContext);
if (bToReverse) {
aEnew.Reverse();
}
//
aBB.Add(aWnew, aEnew);
}
else {
aBB.Add(aWnew, aE);
}
}
//
//myImages / myOrigins
TopTools_ListOfShape aLSD;
//
aLSD.Append(aW);
myImages.Bind(aWnew, aLSD);
myOrigins.Bind(aW, aWnew);
//
}//for (i=1; i<=aNbE; ++i) {
}
示例3: replaceFacesInternal
void OCCRegion::replaceFacesInternal(std::list<GFace*> &new_faces)
{
// we simply replace old faces by new faces in the structure
TopExp_Explorer aExpS, aExpF;
BRep_Builder aBB;
TopoDS_Compound aCmp;
aBB.MakeCompound(aCmp);
TopoDS_Solid _s_replacement;
aBB.MakeSolid(_s_replacement);
_s_replacement.Orientation(s.Orientation());
aExpS.Init(s, TopAbs_SHELL);
for (; aExpS.More(); aExpS.Next()) {
const TopoDS_Shell& _shell=TopoDS::Shell(aExpS.Current());
TopoDS_Shell _shell_replacement;
aBB.MakeShell(_shell_replacement);
_shell_replacement.Orientation(_shell.Orientation());
aExpF.Init(_shell, TopAbs_FACE);
for (; aExpF.More(); aExpF.Next()) {
const TopoDS_Face& _face=TopoDS::Face(aExpF.Current());
TopoDS_Face _face_replacement;
std::list<GFace*>::iterator it = l_faces.begin();
std::list<GFace*>::iterator it2 = new_faces.begin();
for ( ; it != l_faces.end() ; ++it,++it2){
OCCFace *occF = dynamic_cast<OCCFace*>(*it);
if (occF){
TopoDS_Face oldf = occF->getTopoDS_Face();
if (oldf.IsSame(_face)){
_face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
}
else {
oldf = occF->getTopoDS_FaceOld();
if (oldf.IsSame(_face)){
_face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
}
}
}
}
if (_face_replacement.IsNull()){
Msg::Error("cannot find an face for gluing a region");
}
if (_face_replacement.IsSame(_face)) {
aBB.Add(_shell_replacement, _face);
}
else {
if(FaceHaveDifferentOrientations(_face, _face_replacement))
_face_replacement.Reverse();
aBB.Add(_shell_replacement, _face_replacement);
}
}
aBB.Add(_s_replacement, _shell_replacement);
}
s = _s_replacement;
setup();
}
示例4: FillImagesCompound
//=======================================================================
//function : FillImagesCompound
//purpose :
//=======================================================================
void FillImagesCompound(const TopoDS_Shape& theS,
BRepAlgo_Image& theImages,
TopTools_MapOfShape& theMFP)
{
Standard_Boolean bInterferred;
TopAbs_ShapeEnum aTypeX;
TopAbs_Orientation aOrX;
TopoDS_Iterator aIt;
BRep_Builder aBB;
TopTools_ListIteratorOfListOfShape aItIm;
//
if (!theMFP.Add(theS)) {
return;
}
//
bInterferred=Standard_False;
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSX=aIt.Value();
aTypeX=aSX.ShapeType();
if (aTypeX==TopAbs_COMPOUND) {
FillImagesCompound(aSX, theImages, theMFP);
}
if (theImages.HasImage(aSX)) {
bInterferred=Standard_True;
}
}
if (!bInterferred) {
return;
}
//
TopoDS_Shape aCIm;
GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCIm);
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSX=aIt.Value();
aOrX=aSX.Orientation();
if (theImages.HasImage(aSX)) {
const TopTools_ListOfShape& aLFIm=theImages.Image(aSX);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aSXIm=aItIm.Value();
aSXIm.Orientation(aOrX);
aBB.Add(aCIm, aSXIm);
}
}
else {
aBB.Add(aCIm, aSX);
}
}
theImages.Bind(theS, aCIm);
}
示例5: removeFaces
Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Solid& theShape,
TopoDS_Shape& theNewShape)
{
Standard_Boolean isDone = Standard_False;
TopoDS_Solid aSol;
BRep_Builder aB;
aB.MakeSolid(aSol);
TopoDS_Compound aComp;
aB.MakeCompound(aComp);
Standard_Boolean isAddSol = Standard_False, isAddComp = Standard_False;
//firslty faces will be deleted from each shell.
TopoDS_Iterator aItSol(theShape,Standard_False);
for( ; aItSol.More(); aItSol.Next()) {
TopoDS_Shape aSh = aItSol.Value();
TopoDS_Shape aNewShape;
if(removeFaces(aSh,aNewShape))
isDone = Standard_True;
if(aNewShape.IsNull())
continue;
else if(aNewShape.ShapeType() == TopAbs_SHELL ) {
aB.Add(aSol,aNewShape);
isAddSol = Standard_True;
}
else {
aB.Add(aComp,aNewShape);
isAddComp = Standard_True;
}
}
if(isDone) {
//for getting correct solids class ShapeFix_Solid will be used.
if(isAddSol) {
Handle(ShapeFix_Solid) aSfSol = new ShapeFix_Solid(aSol);
aSfSol->FixShellMode()= Standard_False;
aSfSol->Perform();
TopoDS_Shape aresSol = aSfSol->Shape();
if(!isAddComp)
theNewShape = aresSol;
else
aB.Add(aComp,aresSol);
}
else if(isAddComp)
theNewShape = aComp;
else
theNewShape.Nullify();
}
else
theNewShape = theShape;
return isDone;
}
示例6: SuppressFacesRec
//=======================================================================
//function : SupressFaces
//purpose :
//=======================================================================
void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape)
{
if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND &&
theOriginalShape.ShapeType() != TopAbs_COMPSOLID))
{
ShHealOper_RemoveFace aHealer (theOriginalShape);
Standard_Boolean aResult = aHealer.Perform(theShapesFaces);
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption(aHealer.GetErrorStatus());
}
else
{
BRep_Builder BB;
TopoDS_Compound CC;
BB.MakeCompound(CC);
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape aShape_i = It.Value();
if (mapShape.Add(aShape_i)) {
// check, if current shape contains at least one of faces to be removed
bool isFound = false;
TopTools_IndexedMapOfShape aShapes_i;
TopExp::MapShapes(aShape_i, aShapes_i);
for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) {
const TopoDS_Shape& aFace_i = theShapesFaces.Value(i);
if (aShapes_i.Contains(aFace_i)) isFound = true;
}
if (isFound) {
TopoDS_Shape anOutSh_i;
SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i);
if ( !anOutSh_i.IsNull() )
BB.Add(CC, anOutSh_i);
}
else {
// nothing to do
BB.Add(CC, aShape_i);
}
}
}
theOutShape = CC;
}
}
示例7: MakeInternalWires
//=======================================================================
//function : MakeInternalWires
//purpose :
//=======================================================================
void MakeInternalWires(const TopTools_MapOfShape& theME,
TopTools_ListOfShape& theWires)
{
TopTools_MapIteratorOfMapOfShape aItM;
TopTools_MapOfShape aAddedMap;
TopTools_ListIteratorOfListOfShape aItE;
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
BRep_Builder aBB;
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aE=aItM.Key();
TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
TopoDS_Shape aEE=aItM.Key();
if (!aAddedMap.Add(aEE)) {
continue;
}
//
// make a new shell
TopoDS_Wire aW;
aBB.MakeWire(aW);
aEE.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEE);
//
TopoDS_Iterator aItAdded (aW);
for (; aItAdded.More(); aItAdded.Next()) {
const TopoDS_Shape& aE =aItAdded.Value();
//
TopExp_Explorer aExp(aE, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aV =aExp.Current();
const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
aItE.Initialize(aLE);
for (; aItE.More(); aItE.Next()) {
TopoDS_Shape aEL=aItE.Value();
if (aAddedMap.Add(aEL)){
aEL.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEL);
}
}
}
}
theWires.Append(aW);
}
}
示例8: GetDesiredCutShape
//#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
}
示例9: 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;
}
示例10: 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;
}
示例11:
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();
}
示例12: Write
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;
}
}
示例13: 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);
}
}
}
}
}
示例14: compound
void Subassembly::compound ( TopoDS_Shape& assembly )
{
BRep_Builder builder;
if ( dynamic_cast<Part*>( subassembly_ ) != 0 ) {
TopoDS_Shape placed_solid =
dynamic_cast<Part*>( subassembly_ )->shape().Located( location_ );
builder.Add( assembly, placed_solid );
}
else if ( dynamic_cast<Assembly*>( subassembly_ ) != 0 ) {
TopoDS_Shape placed_solid =
dynamic_cast<Assembly*>( subassembly_ )->compound().Located( location_ );
builder.Add( assembly, placed_solid );
}
}
示例15: 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);
}
}