Message: Re: Failed in creating a polyhedron Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Failed in creating a polyhedron 

Forum: Geometry
Re: Question Failed in creating a polyhedron (Yuefeng Qiu)
Re: None Re: Failed in creating a polyhedron (John Allison)
Re: None Re: Failed in creating a polyhedron (Yuefeng Qiu)
Re: None Re: Failed in creating a polyhedron (John Allison)
Re: None Re: Failed in creating a polyhedron (Yuefeng Qiu)
Date: 12 Aug, 2014
From: John Allison <John Allison>

Dear Yuefeng Qiu

HepPolyhedron::createPolyhedron takes triangles or planar quadrilaterals. Your data are triangles. The fourth component of faces must be zero. I have discovered that if the fourth component is set equal to the third component, it crashes in the way you describe. Is that the problem?

I attach an image of your solid created with the following code.

Best wishes

John Allison

    const G4int nNodes = 18;
    G4double nodes[nNodes+1][3] = {
      {0.,0.,0.},
      {7.75,0.25,21.2},
      {7.75,-0.25,21.2},
      {7.50,0.0,21.2},
      {7.75,0.25,21.2},
      {7.75,-0.25,21.2},
      {7.75,-0.25,20.57},
      {7.75,0.25,20.57},
      {7.75,-0.25,20.57},
      {7.75,-0.25,21.2},
      {7.50,0.0,21.2},
      {7.50,0.0,20.57},
      {7.75,0.25,21.2},
      {7.75,0.25,20.57},
      {7.50,0.0,20.57},
      {7.50,0.0,21.2},
      {7.50,0.0,20.57},
      {7.75,0.25,20.57},
      {7.75,-0.25,20.57}
    };
    const G4int nFaces = 8;
    G4int faces[nFaces+1][4] = {
      {0,0,0,0},
      {1,3,2,2},
      {6,7,4,4},
      {6,4,5,5},
      {9,10,11,11},
      {9,11,8,8},
      {13,14,15,15},
      {13,15,12,12},
      {18,16,17,17}
    };
    for (G4int iNode = 1; iNode <= nNodes; iNode++) {
      for (G4int iCoord = 0; iCoord < 3; iCoord++) {
        nodes[iNode][iCoord] *= cm;
      }
    }

    //    G4Polyhedron* polyhedron = new G4Polyhedron;
    //    polyhedron->createPolyhedron(nNodes, nFaces, nodes, faces);
    // This crashes.  But if the fourth component of each element of faces
    // is set to zero, all is well.

    // Nevertheless, this works because the fourth component is not used
    // and, presumably, G4TessellatedSolid knows what to do.
    G4TessellatedSolid* testTess = new G4TessellatedSolid("YuefengQiu");
    for (G4int iFace = 1; iFace <= nFaces; iFace++) {
      G4TriangularFacet *facet = new G4TriangularFacet
      (G4ThreeVector(nodes[faces[iFace][0]][0],
                     nodes[faces[iFace][0]][1],
                     nodes[faces[iFace][0]][2]),
       G4ThreeVector(nodes[faces[iFace][1]][0],
                      nodes[faces[iFace][1]][1],
                      nodes[faces[iFace][1]][2]),
       G4ThreeVector(nodes[faces[iFace][2]][0],
                       nodes[faces[iFace][2]][1],
                       nodes[faces[iFace][2]][2]),
       ABSOLUTE);
      testTess->AddFacet(facet);
    }
    testTess->SetSolidClosed(true);
    G4LogicalVolume* testTess_log =
    new G4LogicalVolume( testTess, Ar, "TestTess-log" );
    new G4PVPlacement
    (G4Translate3D(G4ThreeVector(1000.*cm,-300.*cm,0.)),
     "TestTessCut-phys", testTess_log, experimentalHall_phys, false, 0 );

   Attachment:
      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2014/08/12/05.50-33820-YuefengQiu.pdf

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Failed in creating a polyhedron   (Yuefeng Qiu - 13 Aug, 2014)
1 None: Re: Failed in creating a polyhedron   (John Allison - 13 Aug, 2014)
2 None: Re: Failed in creating a polyhedron   (John Allison - 13 Aug, 2014)
1 Ok: Re: Failed in creating a polyhedron   (Yuefeng Qiu - 14 Aug, 2014)
 Add Message Add Message
to: "Re: Failed in creating a polyhedron"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]