For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Intersecting pipes, 3d Curve to edge

George Stavrou's picture
Forums: 

Hi to all, I have managed to create shell and add thickness in shapes using fuse, TopExp_Explorer to remove some faces(check the image and code below).

//below is an example how to make shell and add thickness
	double extrude = 200;
	double addThickiness = 10;
	TopoDS_Shape A = BRepPrimAPI_MakeBox(gp_Pnt(-100, -100, 0), 200., 200., extrude);

	gp_Pnt cylLocation(0, 0, extrude);
	gp_Dir cylAxis = gp::DZ();
	gp_Ax2 neckAxis(cylLocation, cylAxis);

	TopoDS_Shape B = BRepPrimAPI_MakeCylinder(neckAxis, 50, 200);

	TopoDS_Shape ans2 = BRepAlgoAPI_Fuse(A, B);

	TopoDS_Face   removeFaceY;
	Standard_Real yyMax = 0;
	for (TopExp_Explorer afaceExplorer(ans2, TopAbs_FACE); afaceExplorer.More(); afaceExplorer.Next())
	{
		TopoDS_Face aFace = TopoDS::Face(afaceExplorer.Current());
		Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
		if (aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
		{
			Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);
			gp_Pnt aPnt = aPlane->Location();
			Standard_Real aY = aPnt.Y();
			if (aY > yyMax)
			{
				yyMax = aY;
				removeFaceY = aFace;
			}
		}
	}
	TopoDS_Face   removeFaceZ;
	Standard_Real zzMax = 0;
	for (TopExp_Explorer afaceExplorer(ans2, TopAbs_FACE); afaceExplorer.More(); afaceExplorer.Next())
	{
		TopoDS_Face aFace = TopoDS::Face(afaceExplorer.Current());
		Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
		if (aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
		{
			Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);
			gp_Pnt aPnt = aPlane->Location();
			Standard_Real aZ = aPnt.Z();
			if (aZ > zzMax)
			{
				zzMax = aZ;
				removeFaceZ = aFace;
			}
		}
	}
	TopTools_ListOfShape removeFaces;
	removeFaces.Append(removeFaceY);
	removeFaces.Append(removeFaceZ);

	BRepOffsetAPI_MakeThickSolid BodyMaker;
	BodyMaker.MakeThickSolidByJoin(ans2, removeFaces, -addThickiness, 1e-3);
	ans2 = BodyMaker.Shape();

	return ans2;

I want to do the same with shapes that intersect one the other, for example i want two intersected cylinders to create a tea join for pipes and add different thickness in the main branch and in the perpendicular branch of the tea join. The below code supposed to achive that but i get a null result. I do get the faces i want to remove(3 planar faces, one at y axis the other two at (+,-)x axis) and the 3dcurve the intersect creates, but the creation of shell in the remaining faces never happens because the shapes intersect one the other. Please see the photos.

//variables
	double angleRotation = 2 * uPi;
	double addThickiness = 10;

	double outDiaMain = 100;
	double extrusionMain = 300;
	gp_Ax2 axisMain(gp_Pnt(-extrusionMain / 2, 0., 0.), gp_Dir(1., 0., 0.));
	double outDiaTea = 100;
	double extrusionTea = 200;
	gp_Ax2 axisTea(gp_Pnt(0., 0., 0.), gp_Dir(0., 1., 0.));
	//main shape
	TopoDS_Shape mainBranch = BRepPrimAPI_MakeCylinder(axisMain, outDiaMain, extrusionMain, angleRotation);
	TopoDS_Shape teaBranch = BRepPrimAPI_MakeCylinder(axisTea, outDiaTea, extrusionTea, angleRotation);
	TopoDS_Shape regTea = BRepAlgoAPI_Fuse(mainBranch, teaBranch);
	
	//display the 3d curve of the intersect faces
	BRepAlgoAPI_Section myCurve(mainBranch, teaBranch); //this is a compound curve and not and edge, i have to convert it to edge if i want to use it as cutting tool
	//apply fillets
	BRepFilletAPI_MakeFillet mkFillet(regTea);
	TopExp_Explorer anEdgeExplorer(regTea, TopAbs_EDGE);
	while (anEdgeExplorer.More())
	{
		TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current());
		//Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge);
		mkFillet.Add(5, anEdge);
		anEdgeExplorer.Next();
	}
	regTea = mkFillet.Shape();
	
	//find the faces to remove in order to take from solid the surface
	TopoDS_Face   afaceToRemove;
	Standard_Real yMax = 0;
	for (TopExp_Explorer afaceExplorer(regTea, TopAbs_FACE); afaceExplorer.More(); afaceExplorer.Next())
	{
		TopoDS_Face aFace = TopoDS::Face(afaceExplorer.Current());
		Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
		if (aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
		{
			Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);
			gp_Pnt aPnt = aPlane->Location();
			Standard_Real aY = aPnt.Y();
			if (aY > yMax)
			{
				yMax = aY;
				afaceToRemove = aFace;
			}
		}
	}
	TopoDS_Face   bfaceToRemove;
	Standard_Real xMax = 0;
	for (TopExp_Explorer bfaceExplorer(regTea, TopAbs_FACE); bfaceExplorer.More(); bfaceExplorer.Next())
	{
		TopoDS_Face bFace = TopoDS::Face(bfaceExplorer.Current());
		Handle(Geom_Surface) bSurface = BRep_Tool::Surface(bFace);
		if (bSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
		{
			Handle(Geom_Plane) bPlane = Handle(Geom_Plane)::DownCast(bSurface);
			gp_Pnt bPnt = bPlane->Location();
			Standard_Real bX = bPnt.X();
			if (bX > xMax)
			{
				xMax = bX;
				bfaceToRemove = bFace;
			}
		}

	}
	TopoDS_Face   cfaceToRemove;
	Standard_Real xMin = 0;
	for (TopExp_Explorer cfaceExplorer(regTea, TopAbs_FACE); cfaceExplorer.More(); cfaceExplorer.Next())
	{
		TopoDS_Face cFace = TopoDS::Face(cfaceExplorer.Current());
		Handle(Geom_Surface) cSurface = BRep_Tool::Surface(cFace);
		if (cSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
		{
			Handle(Geom_Plane) cPlane = Handle(Geom_Plane)::DownCast(cSurface);
			gp_Pnt cPnt = cPlane->Location();
			Standard_Real cX = cPnt.X();
			if (cX < xMin)
			{
				xMin = cX;
				cfaceToRemove = cFace;
			}
		}

	}

	TopTools_ListOfShape removeFaces;
	removeFaces.Append(afaceToRemove);
	removeFaces.Append(bfaceToRemove);
	removeFaces.Append(cfaceToRemove);
	
	BRepOffsetAPI_MakeThickSolid BodyMaker;
	BodyMaker.MakeThickSolidByJoin(regTea, removeFaces, -addThickiness, 1e-4);
	regTea = BodyMaker.Shape();

	return regTea;

Last how can i convert my 3d curve i mention above (which is a compound) to a regular edge in order to use it as a cutting tool for the pipes.

Thank you in advance.