Example #1
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l, TopoDS_Shape& shape) {
	TopoDS_Shape halfspace;
	if ( ! IfcGeom::Kernel::convert((IfcSchema::IfcHalfSpaceSolid*)l,halfspace) ) return false;	
	
	TopoDS_Wire wire;
	if ( ! convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;
	
	gp_Trsf trsf;
	if ( ! convert(l->Position(),trsf) ) return false;

	TColgp_SequenceOfPnt points;
	if (wire_to_sequence_of_point(wire, points)) {
		remove_duplicate_points_from_loop(points, wire.Closed()); // Note: wire always closed, as per if statement above
		remove_collinear_points_from_loop(points, wire.Closed());
		sequence_of_point_to_wire(points, wire, wire.Closed());
	}

	TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire),gp_Vec(0,0,200));
	gp_Trsf down; down.SetTranslation(gp_Vec(0,0,-100.0));
	
	// `trsf` and `down` both have a unit scale factor
	prism.Move(trsf*down);	
	
	shape = BRepAlgoAPI_Common(halfspace,prism);
	return true;
}
Example #2
0
void occQt::testCommon()
{
    gp_Ax2 anAxis;
    anAxis.SetLocation(gp_Pnt(0.0, 110.0, 0.0));

    TopoDS_Shape aTopoBox = BRepPrimAPI_MakeBox(anAxis, 3.0, 4.0, 5.0);
    TopoDS_Shape aTopoSphere = BRepPrimAPI_MakeSphere(anAxis, 2.5);
    TopoDS_Shape aCommonShape = BRepAlgoAPI_Common(aTopoBox, aTopoSphere);

    gp_Trsf aTrsf;
    aTrsf.SetTranslation(gp_Vec(8.0, 0.0, 0.0));
    BRepBuilderAPI_Transform aTransform(aCommonShape, aTrsf);

    Handle_AIS_Shape anAisBox = new AIS_Shape(aTopoBox);
    Handle_AIS_Shape anAisSphere = new AIS_Shape(aTopoSphere);
    Handle_AIS_Shape anAisCommonShape = new AIS_Shape(aTransform.Shape());

    anAisBox->SetColor(Quantity_NOC_SPRINGGREEN);
    anAisSphere->SetColor(Quantity_NOC_STEELBLUE);
    anAisCommonShape->SetColor(Quantity_NOC_ROYALBLUE);

    mContext->Display(anAisBox);
    mContext->Display(anAisSphere);
    mContext->Display(anAisCommonShape);
}
Example #3
0
/**
 * @todo: it would be nice if this algorithm would support
 * some progress bar interface
 */
void CTiglFusePlane::Perform()
{
    if (_hasPerformed) {
        return;
    }

    CTiglUIDManager& uidManager = _myconfig.GetUIDManager();
    CTiglAbstractPhysicalComponent* rootComponent = uidManager.GetRootComponent();
    if (!rootComponent) {
        LOG(ERROR) << "Root component of plane not found. Cannot create fused plane.";
        return;
    }

    _result = FuseWithChilds(rootComponent);

    CCPACSFarField& farfield = _myconfig.GetFarField();
    if (farfield.GetFieldType() != NONE && (_mymode == FULL_PLANE_TRIMMED_FF || _mymode == HALF_PLANE_TRIMMED_FF)) {
        PNamedShape ff = farfield.GetLoft();

        BOPCol_ListOfShape aLS;
        aLS.Append(_result->Shape());
        aLS.Append(ff->Shape());

        BOPAlgo_PaveFiller dsfill;
        dsfill.SetArguments(aLS);
        dsfill.Perform();
        CTrimShape trim1(_result, ff, dsfill, INCLUDE);
        PNamedShape resulttrimmed = trim1.NamedShape();

        CTrimShape trim2(ff, _result, dsfill, EXCLUDE);
        _farfield = trim2.NamedShape();

        _result = resulttrimmed;

        // trim intersections with far field
        ListPNamedShape::iterator intIt = _intersections.begin();
        ListPNamedShape newInts;
        for (; intIt != _intersections.end(); ++intIt) {
            PNamedShape inters = *intIt;
            if (!inters) {
                continue;
            }

            TopoDS_Shape sh = inters->Shape();
            sh = BRepAlgoAPI_Common(sh, ff->Shape());
            if (! sh.IsNull()) {
                inters->SetShape(sh);
                newInts.push_back(inters);
            }
        }
        _intersections = newInts;
    }

    if (_result) {
        _result->SetName(_myconfig.GetUID().c_str());
        _result->SetShortName("AIRCRAFT");
    }
    _hasPerformed = true;

}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l, TopoDS_Shape& shape) {
	TopoDS_Shape halfspace;
	if ( ! IfcGeom::Kernel::convert((IfcSchema::IfcHalfSpaceSolid*)l,halfspace) ) return false;	
	TopoDS_Wire wire;
	if ( ! convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;	
	gp_Trsf trsf;
	convert(l->Position(),trsf);
	TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire),gp_Vec(0,0,200));
	gp_Trsf down; down.SetTranslation(gp_Vec(0,0,-100.0));
	prism.Move(trsf*down);
	shape = BRepAlgoAPI_Common(halfspace,prism);
	return true;
}
Example #5
0
TopoDS_Shape BRLFile::PerformBoolean(union tree *tp)
{
    TopoDS_Shape left, right, result;
    if(tp->tr_op==OP_UNION || tp->tr_op==OP_INTERSECT || tp->tr_op==OP_SUBTRACT
    ) {
        left=PerformBoolean(tp->tr_b.tb_left);
        right=PerformBoolean(tp->tr_b.tb_right);
    }

    if(verbose&BRL) {
        switch(tp->tr_op) {
        case OP_UNION:
        case OP_INTERSECT:
        case OP_SUBTRACT:
                cout<< "    Bool " << *tp;
                break;
        case OP_DB_LEAF:
            if(verbose&BRL)
                cout << "    Leaf " << tp->tr_l.tl_name;
            break;
        }
        cout << " remaining " << construction.size() << '\n';
    }

    switch(tp->tr_op) {
    case OP_UNION:    return BRepAlgoAPI_Fuse(left,right); 
    case OP_INTERSECT:return BRepAlgoAPI_Common(left,right);
    case OP_SUBTRACT: return BRepAlgoAPI_Cut(left,right);
    case OP_DB_LEAF:
        result=construction.back();
        construction.pop_back();
        return result;
    default:
        std::cerr << "Invalid boolean operation in " << __FUNCTION__ << '\n';
        return result;
    }
}
Example #6
0
static HeeksObj* Common(HeeksObj* s1, HeeksObj* s2){
	if(s1 == NULL)
	{
		wxGetApp().Remove(s2);
		return NULL;
	}

	try
	{
		TopoDS_Shape sh1, sh2;
		TopoDS_Shape new_shape = BRepAlgoAPI_Common(((CShape*)s1)->Shape(), ((CShape*)s2)->Shape());

		HeeksObj* new_object = CShape::MakeObject(new_shape, _("Result of Common Operation"), SOLID_TYPE_UNKNOWN, ((CShape*)s1)->m_color, ((CShape*)s1)->GetOpacity());
		wxGetApp().Add(new_object, NULL);
		wxGetApp().Remove(s1);
		wxGetApp().Remove(s2);
		return new_object;
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error with common operation")) + _T(": ") + Ctt(e->GetMessageString()));
		return NULL;
	}
}