diff --git a/source/visualization/management/src/G4VSceneHandler.cc b/source/visualization/management/src/G4VSceneHandler.cc index d133673a6ef..d8ebdd10e50 100644 --- a/source/visualization/management/src/G4VSceneHandler.cc +++ b/source/visualization/management/src/G4VSceneHandler.cc @@ -947,33 +947,12 @@ G4DisplacedSolid* G4VSceneHandler::CreateCutawaySolid() G4VSolid* cutawayBox = new G4Box("_cutaway_box", safe, safe, safe); // world box... - for (int plane_no = 0; plane_no < int(vp.GetCutawayPlanes().size()); plane_no++){ - - const G4Normal3D originalNormal(0,0,1); // ...so this is original normal. - - const G4Plane3D& sp = vp.GetCutawayPlanes()[plane_no]; //]; - const G4double& a = sp.a(); - const G4double& b = sp.b(); - const G4double& c = sp.c(); - const G4double& d = sp.d(); - const G4Normal3D newNormal(-a,-b,-c); // Convention: keep a*x+b*y+c*z+d>=0 - // Not easy to see why the above gives the right convention, but it has been - // arrived at by trial and error to agree with the OpenGL implementation - // of clipping planes. - - G4Transform3D requiredTransform; // Null transform - // Calculate the rotation - // If newNormal is (0,0,1), no need to do anything - // Treat (0,0,-1) as a special case, since cannot define axis in this case - if (newNormal == G4Normal3D(0,0,-1)) { - requiredTransform = G4Rotate3D(pi,G4Vector3D(1,0,0)); - } else if (newNormal != originalNormal) { - const G4double& angle = std::acos(newNormal.dot(originalNormal)); - const G4Vector3D& axis = originalNormal.cross(newNormal); - requiredTransform = G4Rotate3D(angle, axis); - } - // Translation - requiredTransform = requiredTransform * G4TranslateZ3D(d + safe); + for (G4int plane_no = 0; plane_no < G4int(vp.GetCutawayPlanes().size()); plane_no++) + { + const G4Plane3D& sp = vp.GetCutawayPlanes()[plane_no]; + G4ThreeVector normal = sp.normal(); + G4Transform3D requiredTransform = G4Translate3D(normal*(safe - sp.d())) * + G4Rotate3D(G4ThreeVector(1,0,0), G4ThreeVector(0,1,0), normal, normal.orthogonal()); cutaway_solids.push_back (new G4DisplacedSolid("_displaced_cutaway_box", cutawayBox, requiredTransform)); } diff --git a/source/visualization/modeling/src/G4PhysicalVolumeModel.cc b/source/visualization/modeling/src/G4PhysicalVolumeModel.cc index e6def4c1158..7a2de71fea1 100644 --- a/source/visualization/modeling/src/G4PhysicalVolumeModel.cc +++ b/source/visualization/modeling/src/G4PhysicalVolumeModel.cc @@ -775,7 +775,7 @@ void G4PhysicalVolumeModel::DescribeSolid } if (pCutawaySolid) { - pResultantSolid = new G4SubtractionSolid + pResultantSolid = new G4IntersectionSolid ("cutaway_solid", pSol, pCutawaySolid, theAT.inverse()); }