// @(#)geom/geocad:$Id$ // Author: Cinzia Luzzi 5/5/2012 /************************************************************************* * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ //////////////////////////////////////////////////////////////////////////////// // TGeoToOCC Class // // -------------------- // // // // This class contains implementation of converting ROOT's // // geometry shapes to OpenCascade shapes. // // // Each ROOT shape is translated in the corrispondent OCC shape using the // // following methods: // // // // TGeoBBox -> OCC_Box(..) // // TGeoSphere -> OCC_Sphere(..) // // TGeoArb8 -> OCC_Arb8(..) // // TGeoConeSeg -> OCC_Cones(..) // // TGeoCone -> OCC_Cones(..) // // TGeoPara -> OCC_ParaTrap(..) // // TGeoTrap -> OCC_ParaTrap(..) // // TGeoGtra -> OCC_ParaTrap(..) // // TGeoTrd1 -> OCC_Trd(..) // // TGeoTrd2 -> OCC_Trd(..) // // TGeoTubeSeg -> OCC_Tube(..) // // TGeoCtub -> OCC_Cuttub(..) // // TGeoTube -> OCC_TubeSeg(..) // // TGeoPcon -> OCC_Pcon(..) // // TGeoTorus -> OCC_Torus(..) // // TGeoPgon -> OCC_Pgon(..) // // TGeoEltu -> OCC_Eltu(..) // // TGeoHype -> OCC_Hype(..) // // TGeoXtru -> OCC_Xtru(..) // // TGeoCompositeShape -> OCC_CompositeShape(..) // // // // A log file is created in /tmp/TGeoCad.log // // // //////////////////////////////////////////////////////////////////////////////// #include "TGeoToOCC.h" //Cascade #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //ROOT #include "TString.h" #include "TClass.h" #include "TGeoBoolNode.h" #include "TGeoShapeAssembly.h" #include "TGeoTrd1.h" #include "TGeoTrd2.h" #include "TGeoArb8.h" #include "TGeoPara.h" #include "TGeoTorus.h" #include "TGeoCone.h" #include "TGeoTube.h" #include "TGeoEltu.h" #include "TGeoSphere.h" #include "TGeoPcon.h" #include "TGeoPgon.h" #include "TGeoHype.h" #include "TGeoPolygon.h" #include "TGeoMatrix.h" #include TGeoToOCC::TGeoToOCC():fOccShape() { } TGeoToOCC::~TGeoToOCC() { } TopoDS_Shape TGeoToOCC::OCC_SimpleShape(TGeoShape *TG_Shape) { TString type = TG_Shape->IsA()->GetName(); out.open("/tmp/TGeoCad.log",ios::app); out<<"Translating: "<IsA()==TGeoTube::Class()) { TGeoTube* TG_Tube=(TGeoTube*)TG_Shape; return OCC_Tube(TG_Tube->GetRmin(), TG_Tube->GetRmax(),TG_Tube->GetDz(),0, 0); } else if(TG_Shape->IsA()==TGeoTubeSeg::Class()) { TGeoTubeSeg* TG_TubeSeg=(TGeoTubeSeg*)TG_Shape; Double_t r = (TG_TubeSeg->GetPhi2()-TG_TubeSeg->GetPhi1()); return OCC_Tube(TG_TubeSeg->GetRmin(), TG_TubeSeg->GetRmax(),TG_TubeSeg->GetDz(),(TG_TubeSeg->GetPhi1())*M_PI/180., r*M_PI/180.); } else if(TG_Shape->IsA()==TGeoEltu::Class()) { TGeoEltu* TG_Eltu=(TGeoEltu*)TG_Shape; return OCC_EllTube(TG_Eltu->GetA(),TG_Eltu->GetB() , TG_Eltu->GetDz()); } else if(TG_Shape->IsA()==TGeoCtub::Class()) { TGeoCtub* TG_Ctub=(TGeoCtub*)TG_Shape; Double_t r = (TG_Ctub->GetPhi2()-TG_Ctub->GetPhi1()); return OCC_Cuttub(TG_Ctub->GetRmin(), TG_Ctub->GetRmax(), TG_Ctub->GetDz(), TG_Ctub->GetPhi1()*M_PI/180.,r*M_PI/180.,TG_Ctub->GetNlow(),TG_Ctub->GetNhigh()); } else if(TG_Shape->IsA()==TGeoCone::Class()) { TGeoCone* TG_Cone=(TGeoCone*)TG_Shape; return OCC_Cones(TG_Cone->GetRmin1(),TG_Cone->GetRmax1(),TG_Cone->GetRmin2(), TG_Cone->GetRmax2(),TG_Cone->GetDz(), 0, 2*M_PI); } else if(TG_Shape->IsA()==TGeoConeSeg::Class()) { TGeoConeSeg* TG_ConeSeg=(TGeoConeSeg*)TG_Shape; Double_t r = (TG_ConeSeg->GetPhi2()-TG_ConeSeg->GetPhi1()); return OCC_Cones(TG_ConeSeg->GetRmin1(), TG_ConeSeg->GetRmax1(),TG_ConeSeg->GetRmin2(), TG_ConeSeg->GetRmax2(), TG_ConeSeg->GetDz(), (TG_ConeSeg->GetPhi1())*M_PI/180., r*M_PI/180.); } else if(TG_Shape->IsA()==TGeoTorus::Class()) { TGeoTorus* TG_Torus=(TGeoTorus*)TG_Shape; Double_t DPhi=(Double_t)TG_Torus->GetDphi()-TG_Torus->GetPhi1(); if (DPhi<0) DPhi=(Double_t)TG_Torus->GetPhi1()-TG_Torus->GetDphi(); Double_t Phi1= (Double_t)TG_Torus->GetPhi1(); return OCC_Torus((Double_t)TG_Torus->GetRmin(),(Double_t)TG_Torus->GetRmax(),(Double_t)TG_Torus->GetR(), Phi1*M_PI/180., DPhi*M_PI/180.); } else if(TG_Shape->IsA()==TGeoSphere::Class()) { TGeoSphere* TG_Sphere=(TGeoSphere*)TG_Shape; Double_t DPhi = (TG_Sphere->GetPhi2()-TG_Sphere->GetPhi1()); Double_t DTheta = (TG_Sphere->GetTheta2()-TG_Sphere->GetTheta1()); return OCC_Sphere(TG_Sphere->GetRmin(), TG_Sphere->GetRmax(),(TG_Sphere->GetPhi1())*M_PI/180., DPhi*M_PI/180., TG_Sphere->GetTheta1()*M_PI/180., DTheta*M_PI/180.); } else if(TG_Shape->IsA()==TGeoPcon::Class()) { TGeoPcon* TG_Pcon=(TGeoPcon*)TG_Shape; return OCC_Pcon((TG_Pcon->GetPhi1())*M_PI/180., (TG_Pcon->GetDphi())*M_PI/180.,TG_Pcon->GetNz(),TG_Pcon->GetRmin(),TG_Pcon->GetRmax(),TG_Pcon->GetZ()); } else if(TG_Shape->IsA()==TGeoPgon::Class()) { TGeoPgon* TG_Pgon=(TGeoPgon*)TG_Shape; Int_t numpoints=TG_Pgon->GetNmeshVertices(); Double_t *p = new Double_t[3*numpoints]; TG_Pgon->SetPoints(p); return OCC_Pgon(TG_Pgon->GetNsegments(),TG_Pgon->GetNz(),p,TG_Pgon->GetPhi1(),TG_Pgon->GetDphi(),numpoints*3); } else if(TG_Shape->IsA()==TGeoHype::Class()) { TGeoHype* TG_Hype=(TGeoHype*)TG_Shape; return OCC_Hype(TG_Hype->GetRmin(), TG_Hype->GetRmax(), TG_Hype->GetStIn(), TG_Hype->GetStOut(),TG_Hype->GetDz()); } else if(TG_Shape->IsA()==TGeoXtru::Class()) { return OCC_Xtru((TGeoXtru*)TG_Shape); } else if (TG_Shape->IsA()==TGeoBBox::Class()) { TGeoBBox * TG_Box=(TGeoBBox*)TG_Shape; const Double_t * Origin = TG_Box->GetOrigin(); return OCC_Box(TG_Box->GetDX(),TG_Box->GetDY(),TG_Box->GetDZ(),Origin[0],Origin[1],Origin[2]); } else if (TG_Shape->IsA()==TGeoTrd1::Class()) { TGeoTrd1 * TG_Trd1=(TGeoTrd1*)TG_Shape; return OCC_Trd(TG_Trd1->GetDx1(),TG_Trd1->GetDx2(),TG_Trd1->GetDy(),TG_Trd1->GetDy(),TG_Trd1->GetDz()); } else if (TG_Shape->IsA()==TGeoTrd2::Class()) { TGeoTrd2 * TG_Trd2=(TGeoTrd2*)TG_Shape; return OCC_Trd(TG_Trd2->GetDx1(),TG_Trd2->GetDx2(),TG_Trd2->GetDy1(),TG_Trd2->GetDy2(),TG_Trd2->GetDz()); } else if (TG_Shape->IsA()==TGeoArb8::Class()) { TGeoArb8 * TG_Arb8=(TGeoArb8*)TG_Shape; Double_t vertex[24]; TG_Shape->SetPoints(vertex); return OCC_Arb8(TG_Arb8->GetDz(),TG_Arb8->GetVertices(),vertex); } else if (TG_Shape->IsA()==TGeoShapeAssembly::Class()) { TGeoBBox * TG_Ass=(TGeoBBox*)TG_Shape; return OCC_Box(TG_Ass->GetDX(),TG_Ass->GetDY(),TG_Ass->GetDZ(),0,0,0); } else if (TG_Shape->IsA()==TGeoPara::Class()) { //TGeoPara * TG_Para=(TGeoPara*)TG_Shape; Double_t vertex[24]; TG_Shape->SetPoints(vertex); return OCC_ParaTrap(vertex); } else if (TG_Shape->IsA()==TGeoTrap::Class()) { //TGeoTrap * TG_Trap=(TGeoTrap*)TG_Shape; Double_t vertex[24]; TG_Shape->SetPoints(vertex); return OCC_ParaTrap(vertex); } else if (TG_Shape->IsA()==TGeoGtra::Class()) { //TGeoGtra * TG_Tra=(TGeoGtra*)TG_Shape; Double_t vertex[24]; TG_Shape->SetPoints(vertex); return OCC_ParaTrap(vertex); } else { throw std::domain_error("Unknown Shape"); } } TopoDS_Shape TGeoToOCC::OCC_CompositeShape(TGeoCompositeShape *comp, TGeoHMatrix m) { Double_t const *t; Double_t const *r; gp_Trsf Transl; gp_Trsf Transf; out.open("/tmp/TGeoCad.log",ios::app); TopoDS_Shape leftOCCShape; TopoDS_Shape rightOCCShape; TopoDS_Shape result; GProp_GProps System; GProp_GProps System2; TGeoBoolNode *boolNode=comp->GetBoolNode(); TGeoShape *rightShape=boolNode->GetRightShape(); TString rightSName = rightShape->IsA()->GetName(); TGeoShape *leftShape=boolNode->GetLeftShape(); TString leftSName = leftShape->IsA()->GetName(); TGeoMatrix *leftMtx=boolNode->GetLeftMatrix(); TGeoMatrix *rightMtx=boolNode->GetRightMatrix(); TGeoHMatrix leftGlobMatx=m*(*leftMtx); if(leftSName == "TGeoCompositeShape") { leftOCCShape=OCC_CompositeShape((TGeoCompositeShape*)leftShape, leftGlobMatx); } else { t=leftGlobMatx.GetTranslation(); r=leftGlobMatx.GetRotationMatrix(); Transl.SetTranslation(gp_Vec(t[0],t[1],t[2])); Transf.SetValues(r[0],r[1],r[2],0, r[3],r[4],r[5],0, r[6],r[7],r[8],0 #if OCC_VERSION_MAJOR == 6 && OCC_VERSION_MINOR < 8 ,0,1 #endif ); BRepBuilderAPI_Transform Transformation(Transf); BRepBuilderAPI_Transform Translation(Transl); Transformation.Perform(OCC_SimpleShape(leftShape),true); TopoDS_Shape shapeTransf = Transformation.Shape(); Translation.Perform(shapeTransf, Standard_True); leftOCCShape = Translation.Shape(); } TGeoHMatrix rightGlobMatx=m*(*rightMtx); if(rightSName == "TGeoCompositeShape" ) { rightOCCShape=OCC_CompositeShape((TGeoCompositeShape*)rightShape, leftGlobMatx); } else { t=rightGlobMatx.GetTranslation(); r=rightGlobMatx.GetRotationMatrix(); Transl.SetTranslation(gp_Vec(t[0],t[1],t[2])); Transf.SetValues( r[0],r[1],r[2],0, r[3],r[4],r[5],0, r[6],r[7],r[8],0 #if OCC_VERSION_MAJOR == 6 && OCC_VERSION_MINOR < 8 ,0,1 #endif ); BRepBuilderAPI_Transform Transformation(Transf); BRepBuilderAPI_Transform Translation(Transl); TopoDS_Shape sh=OCC_SimpleShape(rightShape); Transformation.Perform(sh,true); TopoDS_Shape shapeTransf = Transformation.Shape(); Translation.Perform(shapeTransf, Standard_True); rightOCCShape = Translation.Shape(); } TGeoBoolNode::EGeoBoolType boolOper=boolNode->GetBooleanOperator(); if(TGeoBoolNode::kGeoUnion == boolOper){ if (leftOCCShape.IsNull())out<<"leftshape is null"<b) e=BRepBuilderAPI_MakeEdge(GC_MakeEllipse (ax2, a, b)); else e=BRepBuilderAPI_MakeEdge(GC_MakeEllipse (ax2, b, a)); w=BRepBuilderAPI_MakeWire(e); f=BRepBuilderAPI_MakeFace(w); gp_Vec v(0 , 0 , dz*2); fOccShape = BRepPrimAPI_MakePrism(f , v); if(a0) { Handle(Geom_TrimmedCurve) arcI = GC_MakeArcOfCircle (gp_Circ (gp_Ax2 (gp_Pnt(0.,0., 0.), gp_Dir (0,1, 0)),rmin), theta1, theta1+Dtheta,true); BRepBuilderAPI_MakeEdge makeEI(arcI); eI = TopoDS::Edge(makeEI.Shape()); e1 = BRepBuilderAPI_MakeEdge(makeEO.Vertex1(), makeEI.Vertex1()); e2 = BRepBuilderAPI_MakeEdge(makeEO.Vertex2(), makeEI.Vertex2()); w = BRepBuilderAPI_MakeWire(eO , e2 , eI, e1); f = BRepBuilderAPI_MakeFace(w); } else { gp_Pnt pZero(0.,0.,0.); TopoDS_Vertex vZero = BRepBuilderAPI_MakeVertex(pZero); e1 = BRepBuilderAPI_MakeEdge(makeEO.Vertex1(),vZero ); e2 = BRepBuilderAPI_MakeEdge(makeEO.Vertex2(),vZero ); w = BRepBuilderAPI_MakeWire(eO , e2 , e1); f = BRepBuilderAPI_MakeFace(w); } gp_Trsf t; t.SetRotation(gp::OZ(), phi1); BRepBuilderAPI_Transform brepT(f , t); fOccShape= brepT.Shape(); fOccShape = BRepPrimAPI_MakeRevol(fOccShape,gp::OZ(),Dphi); return Reverse(fOccShape); } TopoDS_Shape TGeoToOCC::OCC_Tube(Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2) { TopoDS_Solid innerCyl; TopoDS_Solid outerCyl; TopoDS_Shape tubs; TopoDS_Shape tubsT; gp_Trsf TT; gp_Trsf TR; if (rmin==0) rmin=rmin+0.00001; if (rmax==0) rmax=rmax+0.00001; if (phi1==0&&phi2==0) { innerCyl = BRepPrimAPI_MakeCylinder(rmin,dz*2); outerCyl = BRepPrimAPI_MakeCylinder(rmax,dz*2); } else { innerCyl = BRepPrimAPI_MakeCylinder(rmin,dz*2,phi2); outerCyl = BRepPrimAPI_MakeCylinder(rmax,dz*2,phi2); } BRepAlgoAPI_Cut cutResult(outerCyl, innerCyl); cutResult.Build(); tubs=cutResult.Shape(); TopExp_Explorer anExp1 (tubs, TopAbs_SOLID); if (anExp1.More()) { TopoDS_Shape aTmpShape = anExp1.Current(); tubs = TopoDS::Solid (aTmpShape); } TT.SetRotation(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Vec(0., 0., 1.)), phi1); BRepBuilderAPI_Transform theTT(TT); theTT.Perform(tubs, Standard_True); tubsT=theTT.Shape(); TR.SetTranslation(gp_Vec(0,0,-dz )); BRepBuilderAPI_Transform theTR(TR); theTR.Perform(tubsT, Standard_True); fOccShape=theTR.Shape(); return Reverse(fOccShape); } TopoDS_Shape TGeoToOCC::OCC_Cones(Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t dz, Double_t phi1, Double_t phi2) { TopoDS_Solid innerCon; TopoDS_Solid outerCon; TopoDS_Shape cons; gp_Trsf TT; gp_Trsf TR; if (rmin1==0) rmin1=rmin1+0.000001; if (rmax1==0) rmax1=rmax1+0.000001; if(rmin1!=rmin2) innerCon = BRepPrimAPI_MakeCone(rmin1,rmin2,dz*2,phi2); else innerCon = BRepPrimAPI_MakeCylinder(rmin1,dz*2,phi2); if(rmax1!=rmax2) outerCon = BRepPrimAPI_MakeCone(rmax1,rmax2,dz*2,phi2); else outerCon = BRepPrimAPI_MakeCylinder(rmax1,dz*2,phi2); BRepAlgoAPI_Cut cutResult(outerCon, innerCon); cutResult.Build(); cons = cutResult.Shape(); TT.SetRotation(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Vec(0., 0., 1.)), phi1); BRepBuilderAPI_Transform theTT(TT); theTT.Perform(cons, Standard_True); cons=theTT.Shape(); TR.SetTranslation(gp_Vec(0,0,-dz )); BRepBuilderAPI_Transform theTR(TR); theTR.Perform(cons, Standard_True); fOccShape=theTR.Shape(); return Reverse(fOccShape); } TopoDS_Shape TGeoToOCC::OCC_Cuttub(Double_t rmin, Double_t rmax, Double_t dz, Double_t, Double_t Dphi,const Double_t * Nlow,const Double_t * Nhigh) { out.open("/tmp/TGeoCad.log",ios::app); out<<"siamo in ctube"<-1e-4)||(Nhigh[0]<1e-4)) nhigh0=0; if ((Nhigh[1]>-1e-4)||(Nhigh[1]<1e-4)) nhigh1=0; if ((Nlow[0]>-1e-4)||(Nlow[0]<1e-4)) nlow0=0; if ((Nlow[1]>-1e-4)||(Nlow[1]<1e-4)) nlow1=0; Handle(Geom_Plane) pH = new Geom_Plane (gp_Pnt(0,0,dz), gp_Dir(nhigh0,nhigh1,Nhigh[2])); Handle(Geom_Plane) pL = new Geom_Plane (gp_Pnt(0,0,-dz), gp_Dir(nlow0,nlow1,Nlow[2])); /* gp_Dir D(nhigh0,nhigh1,Nhigh[2]); gp_Pnt P(0,0,dz); gp_Pln Plan(P,D); TopoDS_Face maLame = BRepBuilderAPI_MakeFace(Plan); if (maLame.IsNull()) cout<<"null face"<GetNvert(); Int_t nz=TG_Xtru->GetNz(); Double_t x [vert]; Double_t y [vert]; Double_t z [nz]; gp_Trsf TR; TopoDS_Wire w; BRepOffsetAPI_ThruSections sect(true,true); for (Int_t i=0;iGetXOffset(i)+(TG_Xtru->GetScale(i)*TG_Xtru->GetX(pp)); y[pp]=TG_Xtru->GetYOffset(i)+(TG_Xtru->GetScale(i)*TG_Xtru->GetY(pp)); } z[i]=TG_Xtru->GetZ(i); w=TGeoToOCC::Polygon(x,y,z[i],vert); sect.AddWire(w); } sect.Build(); if (sect.IsDone()) fOccShape = sect.Shape(); return fOccShape; } TopoDS_Shape TGeoToOCC::OCC_Hype(Double_t rmin, Double_t rmax,Double_t stin, Double_t stout, Double_t dz ) { gp_Pnt p(0, 0, 0); gp_Dir d(0, 0, 1); TopoDS_Vertex vIn,vOut; TopoDS_Vertex vIn1,vOut1; TopoDS_Edge hyEO; TopoDS_Edge hyEI; TopoDS_Edge eT; TopoDS_Edge eB; TopoDS_Edge eT1; TopoDS_Wire hyW; TopoDS_Face hyF; gp_Trsf t; BRepBuilderAPI_MakeEdge makeHyEO; BRepBuilderAPI_MakeEdge makeHyEI; Double_t xO,xI; if(stout>0) { Double_t aO = rmax; Double_t bO = (rmax/(tan(stout))); xO = aO*sqrt(1+(dz*dz)/(bO*bO)); gp_Hypr hyO( gp_Ax2 (p, d ), aO, bO); vOut = BRepBuilderAPI_MakeVertex(gp_Pnt(xO,dz,0)); vOut1 = BRepBuilderAPI_MakeVertex(gp_Pnt(xO,-dz,0)); makeHyEO=BRepBuilderAPI_MakeEdge(hyO,vOut,vOut1); } else makeHyEO=BRepBuilderAPI_MakeEdge(gp_Pnt(rmax,-dz,0), gp_Pnt(rmax,dz,0)); if(stin>0) { Double_t aI = rmin; Double_t bI = (rmin/(tan(stin))); xI = aI*sqrt(1+(dz*dz)/(bI*bI)); gp_Hypr hyI( gp_Ax2 (p, d ), aI, bI); vIn = BRepBuilderAPI_MakeVertex(gp_Pnt(xI,dz,0)); vIn1 = BRepBuilderAPI_MakeVertex(gp_Pnt(xI,-dz,0)); makeHyEI=BRepBuilderAPI_MakeEdge(hyI,vIn,vIn1); } else makeHyEI=BRepBuilderAPI_MakeEdge(gp_Pnt(rmin,-dz,0), gp_Pnt(rmin,dz,0)); hyEO=TopoDS::Edge(makeHyEO.Shape()); hyEI=TopoDS::Edge(makeHyEI.Shape()); eT= BRepBuilderAPI_MakeEdge(makeHyEO.Vertex1(), makeHyEI.Vertex1()); eB= BRepBuilderAPI_MakeEdge(makeHyEO.Vertex2(), makeHyEI.Vertex2()); eT1 =BRepBuilderAPI_MakeEdge(makeHyEO.Vertex1(), makeHyEO.Vertex2()); BRepBuilderAPI_MakeWire WIRE(hyEO,eB,hyEI,eT); WIRE.Add(eT1); hyW=WIRE.Wire(); BRepBuilderAPI_MakeFace face(hyW); hyF=face.Face(); t.SetRotation(gp::OX(), M_PI/2.); BRepBuilderAPI_Transform TF(t); TF.Perform(hyF,Standard_True); hyF = TopoDS::Face(TF.Shape()); fOccShape = BRepPrimAPI_MakeRevol (hyF,gp::OZ(),2*M_PI); return Reverse(fOccShape); } TopoDS_Shape TGeoToOCC::OCC_ParaTrap (Double_t *vertex) { BRepOffsetAPI_ThruSections sect(true,true); TopoDS_Wire w; TopoDS_Face ff; //Int_t punti=0; Int_t f=0; TopoDS_Edge e1; TopoDS_Edge e2; TopoDS_Edge e3; TopoDS_Edge e4; gp_Pnt p1; gp_Pnt p2; gp_Pnt p3; gp_Pnt p4; while (f<24) { p1=gp_Pnt(vertex[f],vertex[f+1],vertex[f+2]); p2=gp_Pnt(vertex[f+3],vertex[f+4],vertex[f+5]); p3=gp_Pnt(vertex[f+6],vertex[f+7],vertex[f+8]); p4=gp_Pnt(vertex[f+9],vertex[f+10],vertex[f+11]); e1=BRepBuilderAPI_MakeEdge(p1,p2 ); e2=BRepBuilderAPI_MakeEdge(p2,p3 ); e3=BRepBuilderAPI_MakeEdge(p3,p4 ); e4=BRepBuilderAPI_MakeEdge(p4,p1 ); w = BRepBuilderAPI_MakeWire(e1,e2,e3,e4); sect.AddWire(w); f += 12; } sect.Build(); fOccShape=sect.Shape(); return fOccShape; } TopoDS_Shape TGeoToOCC::OCC_Arb8(Double_t, Double_t* , Double_t *points) { out.open("/tmp/TGeoCad.log",ios::app); TopoDS_Shell newShell; TopoDS_Shape sewedShape; TopoDS_Shape aTmpShape; Int_t count=0; ShapeFix_ShapeTolerance FTol; Double_t tolerance=1; Handle(TColgp_HArray1OfPnt) pathArray =new TColgp_HArray1OfPnt(0,8); BRepBuilderAPI_Sewing sew(1.0);//e-02); TopoDS_Wire wire1,wire2,wire3,wire4,wire5,wire6; TopoDS_Face ff,ff1,ff2,ff3,ff4,ff5; BRepBuilderAPI_MakePolygon poly1,poly2,poly3,poly4,poly5,poly6; Int_t x=0,y=0,z=0; gp_Pnt point; for (Int_t i=0;i<8;i++) { x=count++;y=count++;z=count++; point=gp_Pnt(points[x],points[y],points[z]); if (points[x]<=0.1) { tolerance=1;} if (points[y]<=0.1) { tolerance=1;} if (points[z]<=0.1) { tolerance=1;} pathArray->SetValue(i,point); } poly1.Add(pathArray->Value(0)); out<Value(0).X()<<" "<Value(0).Y()<<" "<Value(0).Z()<Value(3)); out<Value(3).X()<Value(3).Y()<Value(3).Z()<Value(2)); out<Value(2).X()<Value(2).Y()<Value(2).Z()<Value(1)); out<Value(1).X()<<" "<Value(1).Y()<<" "<Value(1).Z()<Value(0)); out<Value(0).X()<Value(0).Y()<Value(0).Z()<Value(1)); out<Value(1).X()<Value(1).Y()<Value(1).Z()<Value(5)); out<Value(5).X()<Value(5).Y()<Value(5).Z()<Value(4)); out<Value(4).X()<Value(4).Y()<Value(4).Z()<Value(0)); out<Value(0).X()<Value(0).Y()<Value(0).Z()<Value(4)); out<Value(4).X()<Value(4).Y()<Value(4).Z()<Value(7)); out<Value(7).X()<Value(7).Y()<Value(7).Z()<Value(3)); out<Value(3).X()<Value(3).Y()<Value(3).Z()<Value(3)); out<Value(3).X()<Value(3).Y()<Value(3).Z()<Value(2)); out<Value(2).X()<Value(2).Y()<Value(2).Z()<Value(6)); out<Value(6).X()<Value(6).Y()<Value(6).Z()<Value(7)); out<Value(7).X()<Value(7).Y()<Value(7).Z()<Value(4)); out<Value(4).X()<Value(4).Y()<Value(4).Z()<Value(5)); out<Value(5).X()<Value(5).Y()<Value(5).Z()<Value(6)); out<Value(6).X()<Value(6).Y()<Value(6).Z()<Value(7)); out<Value(7).X()<Value(7).Y()<Value(7).Z()<Value(1)); out<Value(1).X()<Value(1).Y()<Value(1).Z()<Value(2)); out<Value(2).X()<Value(2).Y()<Value(2).Z()<Value(6)); out<Value(6).X()<Value(6).Y()<Value(6).Z()<Value(5)); out<Value(5).X()<Value(5).Y()<Value(5).Z()<0) { BRepAlgoAPI_Fuse fuse(pCone, cone); pCone=fuse.Shape(); } else pCone=cone; } return Reverse(pCone); } TopoDS_Shape TGeoToOCC::OCC_Pgon(Int_t, Int_t nz, Double_t * p, Double_t phi1, Double_t DPhi, Int_t numpoint) { BRepOffsetAPI_ThruSections sectInner(true,true); BRepOffsetAPI_ThruSections sectOuter(true,true); BRepLib_MakePolygon aPoly2; TopoDS_Face f; TopoDS_Wire w1,w2; TopoDS_Solid myCut; Int_t i=2; Double_t z=p[2]; Int_t nzvert=0; Double_t xx=0.0,yy=0.0,zz=0.0; Double_t Xmax=0.0,Ymax=0.0, Zmax=0.0, max=0.0; Int_t aa=0,bb=1,cc=2; Int_t ind=0; Int_t check=0; //Int_t k=0; gp_Pnt point; gp_Trsf TR; gp_Trsf TT; while (i-1e-4)&&(p[check]<1e-4)) p[check]=0; check=check+1; } for (i=0;iXmax) { Xmax=fabs(p[aa]); } if (fabs(p[bb])>Ymax) { Ymax=fabs(p[bb]); } if (fabs(p[cc])>Zmax) { Zmax=fabs(p[cc]); } if(numpoint-1==cc) break; aa=aa+3; bb=bb+3; cc=cc+3; } if (Xmax>Ymax) max=Xmax; else max=Ymax; if ((IsEqual(DPhi,360.0))||(IsEqual(DPhi,0.))) { fOccShape=Result.Shape(); return Reverse(fOccShape); } else { myCut=BRepPrimAPI_MakeCylinder (max+1,2*Zmax,(360.-DPhi)*M_PI/180.); TT.SetRotation(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Vec(0., 0., 1.)), (-90.0+phi1)*M_PI/180.0); BRepBuilderAPI_Transform theTT(TT); theTT.Perform(myCut, Standard_True); fOccShape=theTT.Shape(); TR.SetTranslation(gp_Vec(0,0,-Zmax)); BRepBuilderAPI_Transform theTR(TR); theTR.Perform(fOccShape, Standard_True); fOccShape=theTR.Shape(); BRepAlgoAPI_Cut Result2(Result.Shape(),fOccShape ); Result2.Build(); fOccShape=Result2.Shape(); //if (fOccShape.IsNull()) cout<<"The Pgon shae is null. Cut Operation Error: "<PerformInfinitePoint(Precision::Confusion()); if (setPrecision->State() == TopAbs_IN) { //cout<<"reverse"<