Import Geant4 8.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:36:02 +02:00
parent d93e1e39a9
commit 8a51e0bc40
5471 changed files with 99628 additions and 55248 deletions
+40 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.65 2005/06/02 16:51:56 allison Exp $
$Id: History,v 1.73 2005/11/30 16:16:34 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,45 @@ committal in the CVS repository !
History file for visualization/OpenInventor
-------------------------------------------
30th November 2005 Gabriele Cosmo (openinventor-V07-01-04)
- Trivial fix to SoPolyhedron for support of CLHEP-2.0.X series.
15th November 2005 Guy Barrand (openinventor-V07-01-03)
- G4OpenInventorXtViewer : handle fVP.GetXGeometryString().
- G4OpenInventorSceneHandler : handle global scale view parameter.
Done in BeginPrimitives and PreAddSolid by doing a
SbMatrix::multRight(sbScale) to the incoming global G4Transform3D matrix.
- G4OpenInventor[Xt,Win]Viewer : handle set background. Done
in the overloaded SetView method.
17th October 2005 Guy Barrand
- G4OpenInventorViewer::G4OpenInventorViewer : read a g4view.iv
file at creating of a view. If found, the scene graph in g4view.iv
if added at head of the overall scene graph. This permits easy
out of band customization of the scene without having to touch
the code.
- Modification in order to save geometry in an Inventor file.
Addition of an "alternateRep" for the SoPolyhedron (see Inventor doc).
Addition of an "alternateRep" for the SoDetectorTreeKit.
Addition of the SoAlternaterRepAction to traverse a scene graph
and construct / delete the alternate reps.
Modification of G4OpenInventorViewer::WriteInventor to write the
alternateRep of the SoPolyhedron and then save geometry in a
.iv file by using Inventor standard lib. In particular the produced
.iv files are readable by the ivview standard tool.
2nd September 2005 John Allison (openinventor-V07-01-02)
- Corrected treatment of edgeflags.
1st August 2005 Gabriele Cosmo (openinventor-V07-01-01)
- Fixed compilation errors and warnings on gcc-4.0.0. Modified files:
SoDetectorTreeKit.cc, gl2ps[.h.cc].
20th July 2005 John Allison (openinventor-V07-01-00)
- Changed Geant4_SoPolyhedron to construct from G4Polyhedron rather
than its base class, HepPolyhedron, for possible future
developments. Functionality unchanged.
2nd June 2005 John Allison (openinventor-V07-00-02)
- Changed char* to const char* in gl2psMsg.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventor.hh,v 1.7 2004/04/08 09:39:37 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// Guy Barrand 26 Mar 1998.
// OpenInventor graphics system factory.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorSceneHandler.hh,v 1.26 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// J Kallenbach 27th Aug 1996
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorTransform3D.hh,v 1.6 2004/11/22 14:20:19 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// jck 17 Dec 1996
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorWin.hh,v 1.1 2004/04/08 09:37:30 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// OpenInventor graphics system factory.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorWin32.hh,v 1.6 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// OpenInventor graphics system factory.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWinViewer.hh,v 1.7 2004/11/25 13:39:54 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventorWinViewer.hh,v 1.8 2005/11/15 08:39:03 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -43,6 +43,7 @@ class Geant4_SoWinExaminerViewer;
class G4OpenInventorWinViewer: public G4OpenInventorViewer {
public: //G4VViewer
virtual void FinishView();
virtual void SetView();
protected:
virtual void ViewerRender();
virtual SoCamera* GetCamera();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorX.hh,v 1.6 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorXt.hh,v 1.1 2004/04/08 09:37:30 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorXtViewer.hh,v 1.12 2004/11/25 13:39:54 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventorXtViewer.hh,v 1.13 2005/11/15 08:39:03 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -42,6 +42,7 @@ class SoXtExaminerViewer;
class G4OpenInventorXtViewer: public G4OpenInventorViewer {
public: //G4VViewer
virtual void FinishView();
virtual void SetView();
protected:
virtual void ViewerRender();
virtual SoCamera* GetCamera();
@@ -27,20 +27,25 @@
#include <Inventor/nodes/SoShape.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFNode.h>
class HepPolyhedron;
class G4Polyhedron;
/**
* Geant4_SoPolyhedron is an Inventor encapsulation of the HepPolyedron
* class written by E.Chernyaev. In particular Geant4_SoPolyhedron permits
* SoPolyhedron is an Inventor encapsulation of the G4Polyedron
* class written by E.Chernyaev. In particular SoPolyhedron permits
* to represent boolean operations over solids.
* The solids are modeled with HepPolyedron objects. The HepPolyhedron
* permits to produce a new HepPolyhedron according to the boolean
* operation done on them. The resulting HepPolyhedron is then given
* to an Geant4_SoPolyhedron for rendering.
* To avoid clashes with other libraries (Geant4) where the G4Polyhedron
* classes may be found, the G4Polyhedron (through usage of CPP macros)
* had been renamed G4Polyhedron in the HEPVis lib.
* The solids are modeled with G4Polyedron objects. The G4Polyhedron
* permits to produce a new G4Polyhedron according to the boolean
* operation done on them. The resulting G4Polyhedron is then given
* to an SoPolyhedron for rendering.
* Note that a boolean operation could be rendered in wire frame
* by drawing the contour of the resulting solid (not by drawing
* the wire frame of a triangulation).
* See the applications/Polyhedron example.
*/
class Geant4_SoPolyhedron : public SoShape {
@@ -48,19 +53,23 @@ class Geant4_SoPolyhedron : public SoShape {
public:
SoSFBool solid;
SoSFBool reducedWireFrame;
SoSFNode alternateRep;
public:
Geant4_SoPolyhedron();
Geant4_SoPolyhedron(const HepPolyhedron&);
Geant4_SoPolyhedron(HepPolyhedron*);
Geant4_SoPolyhedron(const G4Polyhedron&);
Geant4_SoPolyhedron(G4Polyhedron*);
virtual void generateAlternateRep();
virtual void clearAlternateRep();
public:
static void initClass();
protected:
virtual void computeBBox(SoAction*,SbBox3f&,SbVec3f&);
virtual void generatePrimitives(SoAction*);
virtual void doAction(SoAction*);
protected:
virtual ~Geant4_SoPolyhedron();
private:
HepPolyhedron* fPolyhedron;
G4Polyhedron* fPolyhedron;
};
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: SbMath.h,v 1.3 2004/12/07 23:40:59 perl Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
#ifndef HEPVis_SbMath_h
#define HEPVis_SbMath_h
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
#ifndef HEPVis_SoAlternateRepAction_h
#define HEPVis_SoAlternateRepAction_h
// Inheritance :
#include <Inventor/actions/SoAction.h>
#include <Inventor/actions/SoSubAction.h>
#define SoAlternateRepAction Geant4_SoAlternateRepAction
class SoAlternateRepAction : public SoAction {
SO_ACTION_HEADER(SoAlternateRepAction);
public:
SoAlternateRepAction();
virtual ~SoAlternateRepAction();
static void initClass(void);
void setGenerate(SbBool);
SbBool getGenerate() const;
private:
static void nodeAction(SoAction*,SoNode*);
private:
SbBool fGenerate;
};
#define SO_ALTERNATEREP_DO_ACTION(aAction) \
if(aAction->isOfType(SoAlternateRepAction::getClassTypeId())) {\
if(((SoAlternateRepAction*)aAction)->getGenerate()==TRUE) {\
if(alternateRep.getValue()==NULL) {\
generateAlternateRep();\
SoNode* altRep = alternateRep.getValue();\
if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
altRep->doAction(aAction);\
}\
} else {\
SoNode* altRep = alternateRep.getValue();\
if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
altRep->doAction(aAction);\
clearAlternateRep();\
}\
return;\
}
#endif
@@ -21,10 +21,10 @@
// ********************************************************************
//
//
// $Id: SoDetectorTreeKit.h,v 1.3 2004/11/22 22:57:01 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: SoDetectorTreeKit.h,v 1.4 2005/10/17 07:21:44 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/*-----------------------------HEPVis----------------------------------------*/
/* */
/* Node: SoDetectorTreeKit */
/* Description: Easy way of browsing through a tree of detectors */
@@ -34,11 +34,10 @@
#ifndef HEPVis_SoDetectorTreeKit_h
#define HEPVis_SoDetectorTreeKit_h
// Inheritance :
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoEventCallback.h>
class SoSFNode;
class SoHandleEventAction;
class SoEventCallback;
class SoSeparator;
#define SoDetectorTreeKit Geant4_SoDetectorTreeKit
@@ -49,7 +48,9 @@ class SoDetectorTreeKit:public SoBaseKit {
// The following is required:
SO_KIT_HEADER(SoDetectorTreeKit);
////////////////////////////////////////////
SoSFNode alternateRep;
public:
SoSFNode alternateRep; //public in order to query if alternateRep done.
private:
////////////////////////////////////////////
SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
@@ -80,7 +81,7 @@ public:
// Return the preview state
virtual SbBool getPreview() const;
// The SoSwitch::whichChild = SO_SWITCH_ALL
// Set SoSwitch::whichChild = SO_SWITCH_ALL
void setPreviewAndFull();
// Return the preview Separator
@@ -104,6 +105,7 @@ protected:
// Destructor.
virtual ~SoDetectorTreeKit();
virtual void doAction(SoAction*);
private:
// This is needed as well
@@ -22,7 +22,7 @@
//
//
// $Id: SoBox.h,v 1.2 2004/06/14 09:27:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
@@ -22,7 +22,7 @@
//
//
// $Id: SoCons.h,v 1.2 2004/06/14 09:27:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
@@ -22,7 +22,7 @@
//
//
// $Id: SoTrap.h,v 1.3 2004/11/23 21:51:05 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
@@ -22,7 +22,7 @@
//
//
// $Id: SoTrd.h,v 1.2 2004/06/14 09:27:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
@@ -22,7 +22,7 @@
//
//
// $Id: SoTubs.h,v 1.2 2004/06/14 09:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventor.cc,v 1.17 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventor.cc,v 1.18 2005/10/17 07:39:26 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
#ifdef G4VIS_BUILD_OI_DRIVER
@@ -39,6 +39,7 @@
#include "HEPVis/nodekits/SoDetectorTreeKit.h"
#include "HEPVis/actions/SoGL2PSAction.h"
#include "HEPVis/actions/SoCounterAction.h"
#include "HEPVis/actions/SoAlternateRepAction.h"
#include "Geant4_SoPolyhedron.h"
@@ -81,6 +82,7 @@ void G4OpenInventor::InitNodes()
SoGL2PSAction::initClass();
SoCounterAction::initClass();
SoAlternateRepAction::initClass();
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorSceneHandler.cc,v 1.38 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventorSceneHandler.cc,v 1.39 2005/11/15 08:39:03 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -51,9 +51,9 @@
#include <Inventor/nodes/SoComplexity.h>
#include <Inventor/nodes/SoNurbsSurface.h>
#include <Inventor/nodes/SoTranslation.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/nodes/SoMatrixTransform.h>
#include <Inventor/nodes/SoTransform.h>
#define USE_SOPOLYHEDRON
@@ -210,11 +210,11 @@ void G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker& polymarker) {
const G4VMarker& marker = polymarker;
G4bool userSpecified = (marker.GetWorldSize() || marker.GetScreenSize());
const G4VMarker& def = fpViewer -> GetViewParameters().GetDefaultMarker();
const G4VMarker& def = fpViewer->GetViewParameters().GetDefaultMarker();
//const G4Vector3D& viewpointDirection =
// fpViewer -> GetViewParameters().GetViewpointDirection();
// fpViewer->GetViewParameters().GetViewpointDirection();
//const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector();
G4double scale = fpViewer -> GetViewParameters().GetGlobalMarkerScale();
G4double scale = fpViewer->GetViewParameters().GetGlobalMarkerScale();
G4double size = scale *
userSpecified ? marker.GetWorldSize() : def.GetWorldSize();
G4double screenSize = 0; // Calculate marker in screen size...
@@ -357,11 +357,11 @@ void G4OpenInventorSceneHandler::AddCircleSquare
// A few useful quantities...
G4Point3D centre = marker.GetPosition();
G4bool userSpecified = (marker.GetWorldSize() || marker.GetScreenSize());
const G4VMarker& def = fpViewer -> GetViewParameters().GetDefaultMarker();
const G4VMarker& def = fpViewer->GetViewParameters().GetDefaultMarker();
//const G4Vector3D& viewpointDirection =
// fpViewer -> GetViewParameters().GetViewpointDirection();
// fpViewer->GetViewParameters().GetViewpointDirection();
//const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector();
G4double scale = fpViewer -> GetViewParameters().GetGlobalMarkerScale();
G4double scale = fpViewer->GetViewParameters().GetGlobalMarkerScale();
G4double size = scale *
userSpecified ? marker.GetWorldSize() : def.GetWorldSize();
G4double screenSize = 0; // Calculate marker in screen size...
@@ -433,56 +433,6 @@ void G4OpenInventorSceneHandler::AddCircleSquare
delete [] points;
}
/* Old method
//
// Method for handling G4Square objects - defaults to wireframe
//
void G4OpenInventorSceneHandler::AddPrimitive (const G4Square& square) {
//
// Color
//
const G4Colour& c = GetColour (square);
SoMaterial* material =
fStyleCache->getMaterial((float)c.GetRed(),
(float)c.GetGreen(),
(float)c.GetBlue(),
(float)(1-c.GetAlpha()));
fCurrentSeparator->addChild(material);
// A few useful quantities...
const G4VMarker& marker = square;
G4Point3D centre = marker.GetPosition();
G4bool userSpecified = (marker.GetWorldSize() || marker.GetScreenSize());
const G4VMarker& def = fpViewer -> GetViewParameters().GetDefaultMarker();
//const G4Vector3D& viewpointDirection =
// fpViewer -> GetViewParameters().GetViewpointDirection();
//const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector();
G4double scale = fpViewer -> GetViewParameters().GetGlobalMarkerScale();
G4double size = scale *
userSpecified ? marker.GetWorldSize() : def.GetWorldSize();
G4double screenSize = 0, worldSize = 0; // Calculate marker in world size...
if (size) { // Size specified in world coordinates.
worldSize = size;
} else { // Size specified in screen coordinates (pixels).
screenSize = scale *
userSpecified ? marker.GetScreenSize() : def.GetScreenSize();
worldSize = 1. * cm; // Needs to be more sophisticated!!
}
SoTranslation *sTrans = new SoTranslation;
sTrans->translation.setValue((float)centre.x(),
(float)centre.y(),
(float)centre.z());
fCurrentSeparator->addChild(sTrans);
SoCube *g4Square = new SoCube();
g4Square->width = (float)worldize;
g4Square->height = (float)worldSize;
g4Square->depth = (float)worldSize;
fCurrentSeparator->addChild(g4Square);
}
*/
//
// Method for handling G4Polyhedron objects for drawing solids.
//
@@ -603,6 +553,13 @@ void G4OpenInventorSceneHandler::BeginPrimitives
SoMatrixTransform* matrixTransform = new SoMatrixTransform;
G4OpenInventorTransform3D oiTran(objectTransformation);
SbMatrix* sbMatrix = oiTran.GetSbMatrix();
const G4Vector3D scale = fpViewer->GetViewParameters().GetScaleFactor();
SbMatrix sbScale;
sbScale.setScale
(SbVec3f((float)scale.x(),(float)scale.y(),(float)scale.z()));
sbMatrix->multRight(sbScale);
matrixTransform->matrix.setValue(*sbMatrix);
delete sbMatrix;
fCurrentSeparator->addChild(matrixTransform);
@@ -631,15 +588,6 @@ void G4OpenInventorSceneHandler::ClearTransientStore () {
fTransientRoot->removeAllChildren();
}
/*
void G4OpenInventorSceneHandler::RequestPrimitives (const G4VSolid& solid) {
// Stop-gap solution for display List re-use.
// A proper implementation would use geometry hierarchy.
//
G4VSceneHandler::RequestPrimitives (solid);
}
*/
void G4OpenInventorSceneHandler::PreAddSolid
(const G4Transform3D& objectTransformation,
const G4VisAttributes& visAttribs) {
@@ -677,8 +625,8 @@ void G4OpenInventorSceneHandler::PreAddSolid
// First find the color attributes.
//
const G4VisAttributes* pVisAttribs =
fpViewer -> GetApplicableVisAttributes (&visAttribs);
const G4Colour& g4Col = pVisAttribs -> GetColour ();
fpViewer->GetApplicableVisAttributes (&visAttribs);
const G4Colour& g4Col = pVisAttribs->GetColour ();
const double red = g4Col.GetRed ();
const double green = g4Col.GetGreen ();
const double blue = g4Col.GetBlue ();
@@ -757,18 +705,6 @@ void G4OpenInventorSceneHandler::PreAddSolid
} else {
//printf("debug : PreAddSolid : mother not found in map !!!\n");
fDetectorRoot->addChild(detectorTreeKit);
/*
do {
SoSeparator* dummySeparator =
(SoSeparator*) g4DetectorTreeKit->getPart("dummySeparator",TRUE);
dummySeparator->renderCaching = SoSeparator::OFF; //????
dummySeparator->addChild(transform);
fSeparatorMap[MotherVolume] = dummySeparator;
MotherVolume = MotherVolume->GetPhysicalVolume()->GetMotherLogical();
} while
(MotherVolume &&
fSeparatorMap.find(MotherVolume) == fSeparatorMap.end());
*/
}
} else {
//printf("debug : PreAddSolid : has no mother\n");
@@ -785,20 +721,10 @@ void G4OpenInventorSceneHandler::PreAddSolid
if (fSeparatorMap.find(MotherVolume) != fSeparatorMap.end()) {
fCurrentSeparator = fSeparatorMap[MotherVolume];
} else {
/*
G4cerr << "G4OpenInventorSceneHandler::PreAddSolid() : WARNING :"
<< " volume " << fpCurrentPV->GetName()
<< " has invisible mother (" << MotherVolume->GetName() << ")."
<< G4endl;
G4cerr << " Its scene graph will be put under the viewer"
<< " detector root scene graph."
<< G4endl;
*/
fCurrentSeparator = fDetectorRoot;
}
} else {
fCurrentSeparator = fDetectorRoot;
/* Fix here as above!!! */
}
SoMaterial* material =
@@ -820,62 +746,19 @@ void G4OpenInventorSceneHandler::PreAddSolid
SoMatrixTransform* matrixTransform = new SoMatrixTransform;
G4OpenInventorTransform3D oiTran(objectTransformation);
SbMatrix* sbMatrix = oiTran.GetSbMatrix();
const G4Vector3D scale = fpViewer->GetViewParameters().GetScaleFactor();
SbMatrix sbScale;
sbScale.setScale
(SbVec3f((float)scale.x(),(float)scale.y(),(float)scale.z()));
sbMatrix->multRight(sbScale);
matrixTransform->matrix.setValue(*sbMatrix);
delete sbMatrix;
fCurrentSeparator->addChild(matrixTransform);
}
/*
G4double G4OpenInventorSceneHandler::GetMarkerSize ( const G4VMarker& mark )
{
//----- return value ( marker radius in 3d units)
G4double size = 1.0 ; // initialization
//----- parameters to calculate 3d size from 2d size
const double HALF_SCREEN_SIZE_2D = 300.0 ; // pixels
double zoom_factor = fpViewer->GetViewParameters().GetZoomFactor() ;
if ( zoom_factor <= 0.0 ) { zoom_factor = 1.0 ; }
double extent_radius_3d = GetScene()->GetExtent().GetExtentRadius() ;
if ( extent_radius_3d <= 0.0 ) { extent_radius_3d = 1.0 ; }
//----- get marker radius in 3D units
size = mark.GetWorldSize();
if ( size ) {
// get mark radius in 3D units
size = 0.5 * mark.GetWorldSize() ;
} else if ( (size = mark.GetScreenSize()) ) {
// local
double mark_radius_2d = 0.5 * mark.GetScreenSize() ;
// get mark radius in 3D units
size \
= extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
size *= zoom_factor ;
} else {
// local
double mark_radius_2d \
= fpViewer->GetViewParameters().GetDefaultMarker().GetScreenSize();
// get mark radius in 3D units
size \
= extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
size *= zoom_factor ;
}
//----- global rescaling
size *= fpViewer->GetViewParameters().GetGlobalMarkerScale();
//----- return size
return size ;
} // G4OpenInventorSceneHandler::GetMarkerSize ()
*/
//void G4OpenInventorSceneHandler::AddSolid(const G4VTrajectory& traj) {
// G4VSceneHandler::AddSolid(traj); // For now.
//}
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorTransform3D.cc,v 1.7 2005/05/25 08:16:06 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// jck 17 Dec 1996
@@ -36,6 +36,7 @@
#include "HEPVis/nodes/SoImageWriter.h"
#include "HEPVis/actions/SoGL2PSAction.h"
#include "HEPVis/actions/SoCounterAction.h"
#include "HEPVis/actions/SoAlternateRepAction.h"
#include "G4OpenInventor.hh"
#include "G4OpenInventorSceneHandler.hh"
@@ -96,6 +97,12 @@ G4OpenInventorViewer::G4OpenInventorViewer(
camera->focalDistance.setValue(10);
group->addChild(camera);
{SoInput soInput;
if(soInput.openFile("g4view.iv",TRUE)) {
SoSeparator* separator = SoDB::readAll(&soInput);
if(separator) fSoSelection->addChild(separator);
}}
fSoSelection->addChild(fG4OpenInventorSceneHandler.fRoot);
// SoImageWriter should be the last.
@@ -242,8 +249,6 @@ void G4OpenInventorViewer::SetView () {
//FIXME : (2.*fVP.GetFieldHalfAngle());
}
}
}
//COIN_FUNCTION_EXTENSION
@@ -452,11 +457,29 @@ void G4OpenInventorViewer::WritePixmapPostScript(const G4String& aFile) {
void G4OpenInventorViewer::WriteInventor(const G4String& aFile) {
G4cout << "Produce " << aFile << "..." << G4endl;
SbBool genAlternateRep = TRUE;
//SbBool binary = FALSE;
SbBool binary = TRUE;
SoAlternateRepAction alternateRepAction;
if(genAlternateRep==TRUE) {
alternateRepAction.setGenerate(TRUE); //Clear alternate reps.
alternateRepAction.apply(fSoSelection);
}
SoWriteAction writeAction;
writeAction.getOutput()->openFile(aFile.c_str());
writeAction.getOutput()->setBinary(FALSE);
writeAction.getOutput()->setBinary(binary);
writeAction.apply(fSoSelection);
writeAction.getOutput()->closeFile();
if(genAlternateRep==TRUE) {
alternateRepAction.setGenerate(FALSE); //Clear alternate reps.
alternateRepAction.apply(fSoSelection);
}
}
struct Counter {
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorWin.cc,v 1.4 2004/04/08 10:49:57 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// OpenInventor graphics system factory.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWinViewer.cc,v 1.22 2004/11/25 14:45:06 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventorWinViewer.cc,v 1.24 2005/11/15 09:32:58 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
/*
* jck : 05 Feb 1997 : Initial Implementation
@@ -61,7 +61,7 @@ public:
}
};
#define SIZE 400
#define SIZE 600
// File :
#define ID_FILE_POSTSCRIPT 1
#define ID_FILE_PIXMAP_POSTSCRIPT 2
@@ -211,6 +211,14 @@ void G4OpenInventorWinViewer::FinishView () {
fViewer->saveHomePosition();
}
void G4OpenInventorWinViewer::SetView () {
G4OpenInventorViewer::SetView ();
if(!fViewer) return;
// Background.
G4Colour b = fVP.GetBackgroundColour ();
fViewer->setBackgroundColor
(SbColor((float)b.GetRed(),(float)b.GetGreen(),(float)b.GetBlue()));
}
void G4OpenInventorWinViewer::ViewerRender () {
if(!fViewer) return;
fViewer->render();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenInventorXt.cc,v 1.2 2004/11/22 15:00:48 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorXtViewer.cc,v 1.21 2004/11/26 08:38:51 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenInventorXtViewer.cc,v 1.23 2005/11/15 09:32:03 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
/*
* jck 05 Feb 1997 - Initial Implementation
@@ -75,16 +75,20 @@ G4OpenInventorXtViewer::G4OpenInventorXtViewer(
G4String wName = fName;
#define SIZE 400
#define SIZE 600
Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
if(!parent) {
// Check if user has specified an X-Windows-type geometry string...
char s[32];
sprintf(s,"%dx%d",SIZE,SIZE);
G4String sgeometry = fVP.GetXGeometryString();
if(sgeometry.empty()) sgeometry = s;
//Create a shell window :
G4String shellName = wName;
shellName += "_shell";
Arg args[10];
char s[32];
sprintf(s,"%dx%d",SIZE,SIZE);
XtSetArg(args[0],XtNgeometry,XtNewString(s));
XtSetArg(args[0],XtNgeometry,XtNewString(sgeometry.c_str()));
XtSetArg(args[1],XtNborderWidth,0);
XtSetArg(args[2],XtNtitle,XtNewString(wName.c_str()));
fShell = XtAppCreateShell(shellName.c_str(),"Inventor",
@@ -196,6 +200,16 @@ void G4OpenInventorXtViewer::FinishView () {
fViewer->saveHomePosition();
}
void G4OpenInventorXtViewer::SetView () {
G4OpenInventorViewer::SetView ();
if(!fViewer) return;
// Background.
G4Colour b = fVP.GetBackgroundColour ();
fViewer->setBackgroundColor
(SbColor((float)b.GetRed(),(float)b.GetGreen(),(float)b.GetBlue()));
}
void G4OpenInventorXtViewer::ViewerRender () {
if(!fViewer) return;
fViewer->render();
@@ -0,0 +1,141 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// this :
#include <HEPVis/actions/SoAlternateRepAction.h>
// Inventor :
#include <Inventor/nodes/SoNode.h>
#include <Inventor/elements/SoSwitchElement.h>
#include <Inventor/elements/SoCoordinateElement.h>
SO_ACTION_SOURCE(SoAlternateRepAction)
//////////////////////////////////////////////////////////////////////////////
void SoAlternateRepAction::initClass(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
SO_ACTION_INIT_CLASS(SoAlternateRepAction,SoAction);
SO_ENABLE(SoAlternateRepAction,SoSwitchElement); //SGI wants that.
SO_ENABLE(SoAlternateRepAction,SoCoordinateElement); //For SoMarkerSet.
SO_ACTION_ADD_METHOD(SoNode,nodeAction);
}
//////////////////////////////////////////////////////////////////////////////
SoAlternateRepAction::SoAlternateRepAction(
)
:fGenerate(FALSE)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
SO_ACTION_CONSTRUCTOR(SoAlternateRepAction);
}
//////////////////////////////////////////////////////////////////////////////
SoAlternateRepAction::~SoAlternateRepAction(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
}
//////////////////////////////////////////////////////////////////////////////
void SoAlternateRepAction::setGenerate(
SbBool aGenerate
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
fGenerate = aGenerate;
}
//////////////////////////////////////////////////////////////////////////////
SbBool SoAlternateRepAction::getGenerate(
) const
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
return fGenerate;
}
// Inventor :
#include <Inventor/nodes/SoNode.h>
#include <Inventor/nodes/SoGroup.h>
#include <Inventor/nodes/SoCoordinate3.h>
// HEPVisUtils :
//#include <HEPVis/nodes/SoHighlightMaterial.h>
//#include <HEPVis/nodes/SoSplineCurve.h>
#define IF_CLASS(aClass) \
if(aNode->isOfType(aClass::getClassTypeId())) {\
/*printf("debug : SoAlternateRepAction::nodeAction : %s generate %d\n",#aClass,This->fGenerate);*/\
aClass* node = (aClass*)aNode;\
if(This->fGenerate==TRUE) {\
if(node->alternateRep.getValue()==NULL) {\
node->generateAlternateRep();\
/* Then go down if needed : */\
SoNode* altRep = node->alternateRep.getValue();\
if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
altRep->doAction(This);\
}\
} else {\
/* First go down if needed : */\
SoNode* altRep = node->alternateRep.getValue();\
if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
altRep->doAction(This);\
/* Then clear : */\
node->clearAlternateRep();\
}\
}
//////////////////////////////////////////////////////////////////////////////
void SoAlternateRepAction::nodeAction(
SoAction* aThis
,SoNode* aNode
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
/*printf("debug : SoAlternateRepAction::nodeAction : %s %s\n",
aNode->getName().getString(),
aNode->getTypeId().getName().getString());*/
//SoAlternateRepAction* This = (SoAlternateRepAction*)aThis;
if(false) {}
// HEPVisUtils :
//else IF_CLASS(SoHighlightMaterial)
//else IF_CLASS(SoSplineCurve)
// Inventor :
else if(aNode->isOfType(SoGroup::getClassTypeId())) {
aNode->doAction(aThis);
}
else if(aNode->isOfType(SoCoordinate3::getClassTypeId())) { //For SoMakerSet.
aNode->doAction(aThis);
}
// Else :
else if(aNode->getField("alternateRep")!=NULL) {
aNode->doAction(aThis);
}
}
@@ -23,7 +23,7 @@
//
//
// $Id: SoBox.cc,v 1.7 2004/12/16 12:33:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*----------------------------HEPVis----------------------------------------*/
/* */
@@ -23,7 +23,7 @@
//
//
// $Id: SoCons.cc,v 1.7 2004/12/16 12:33:10 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------HEPVis---------------------------------------*/
/* */
@@ -22,8 +22,8 @@
//
//
//
// $Id: SoDetectorTreeKit.cc,v 1.9 2004/12/16 12:33:10 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: SoDetectorTreeKit.cc,v 1.11 2005/10/17 07:21:03 gbarrand Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------HEPVis----------------------------------------*/
/* */
@@ -36,26 +36,29 @@
#ifdef G4VIS_BUILD_OI_DRIVER
// this :
#include "HEPVis/nodekits/SoDetectorTreeKit.h"
#include <cmath>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoPickStyle.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoUnits.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoEventCallback.h>
#include <Inventor/nodekits/SoSeparatorKit.h>
#include <Inventor/nodekits/SoShapeKit.h>
#include <Inventor/nodekits/SoAppearanceKit.h>
#include <Inventor/nodekits/SoNodeKitListPart.h>
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodekits/SoSeparatorKit.h>
#include <Inventor/nodekits/SoShapeKit.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/actions/SoHandleEventAction.h>
#include <Inventor/nodes/SoUnits.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoTexture2Transform.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/actions/SoHandleEventAction.h>
#include <HEPVis/actions/SoAlternateRepAction.h>
#include <math.h>
// This statement is required
SO_KIT_SOURCE(SoDetectorTreeKit)
@@ -223,5 +226,15 @@ void SoDetectorTreeKit::generateAlternateRep() {
void SoDetectorTreeKit::clearAlternateRep() {
alternateRep.setValue(NULL);
}
//////////////////////////////////////////////////////////////////////////////
void SoDetectorTreeKit::doAction(
SoAction* aAction
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
SO_ALTERNATEREP_DO_ACTION(aAction)
SoBaseKit::doAction(aAction);
}
#endif
@@ -37,18 +37,21 @@
#include <Inventor/actions/SoAction.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include <Inventor/nodes/SoSeparator.h>
//#include <HEPVis/SbMath.h>
#define SbMinimum(a,b) ((a)<(b)?a:b)
#define SbMaximum(a,b) ((a)>(b)?a:b)
#include "HepPolyhedron.h"
#include <HEPVis/actions/SoAlternateRepAction.h>
#include "G4Polyhedron.hh"
//typedef SbVec3f HVPoint3D;
//typedef SbVec3f HVNormal3D;
typedef HepPoint3D HVPoint3D;
typedef HepNormal3D HVNormal3D;
typedef HepGeom::Point3D<double> HVPoint3D;
typedef HepGeom::Normal3D<double> HVNormal3D;
SO_NODE_SOURCE(Geant4_SoPolyhedron)
//////////////////////////////////////////////////////////////////////////////
@@ -69,10 +72,11 @@ Geant4_SoPolyhedron::Geant4_SoPolyhedron(
SO_NODE_CONSTRUCTOR(Geant4_SoPolyhedron);
SO_NODE_ADD_FIELD(solid,(TRUE));
SO_NODE_ADD_FIELD(reducedWireFrame,(TRUE));
SO_NODE_ADD_FIELD(alternateRep,(NULL));
}
//////////////////////////////////////////////////////////////////////////////
Geant4_SoPolyhedron::Geant4_SoPolyhedron(
const HepPolyhedron& aPolyhedron
const G4Polyhedron& aPolyhedron
)
:fPolyhedron(0)
//////////////////////////////////////////////////////////////////////////////
@@ -80,11 +84,14 @@ Geant4_SoPolyhedron::Geant4_SoPolyhedron(
{
SO_NODE_CONSTRUCTOR(Geant4_SoPolyhedron);
SO_NODE_ADD_FIELD(solid,(TRUE));
fPolyhedron = new HepPolyhedron(aPolyhedron);
SO_NODE_ADD_FIELD(reducedWireFrame,(TRUE));
SO_NODE_ADD_FIELD(alternateRep,(NULL));
fPolyhedron = new G4Polyhedron(aPolyhedron);
}
//////////////////////////////////////////////////////////////////////////////
Geant4_SoPolyhedron::Geant4_SoPolyhedron(
HepPolyhedron* aPolyhedron
G4Polyhedron* aPolyhedron
)
:fPolyhedron(aPolyhedron)
//////////////////////////////////////////////////////////////////////////////
@@ -92,6 +99,8 @@ Geant4_SoPolyhedron::Geant4_SoPolyhedron(
{
SO_NODE_CONSTRUCTOR(Geant4_SoPolyhedron);
SO_NODE_ADD_FIELD(solid,(TRUE));
SO_NODE_ADD_FIELD(reducedWireFrame,(TRUE));
SO_NODE_ADD_FIELD(alternateRep,(NULL));
}
//////////////////////////////////////////////////////////////////////////////
Geant4_SoPolyhedron::~Geant4_SoPolyhedron(
@@ -197,7 +206,7 @@ void Geant4_SoPolyhedron::generatePrimitives(
notLastEdge = fPolyhedron->GetNextVertex(vertex,edgeFlag);
if(reducedWireFrame.getValue()==FALSE) edgeFlag = 1;
if(firstEdge) {
if(edgeFlag) {
if(edgeFlag > 0) {
pvb.setNormal(normal);
point.setValue(vertex[0],vertex[1],vertex[2]);
pvb.setPoint(point);
@@ -207,7 +216,7 @@ void Geant4_SoPolyhedron::generatePrimitives(
prevEdgeFlag = edgeFlag;
} else {
if(edgeFlag!=prevEdgeFlag) {
if(edgeFlag) { // Pass to a visible edge :
if(edgeFlag > 0) { // Pass to a visible edge :
pvb.setNormal(normal);
point.setValue(vertex[0],vertex[1],vertex[2]);
pvb.setPoint(point);
@@ -219,7 +228,7 @@ void Geant4_SoPolyhedron::generatePrimitives(
}
prevEdgeFlag = edgeFlag;
} else {
if(edgeFlag) {
if(edgeFlag > 0) {
pve.setNormal(normal);
point.setValue(vertex[0],vertex[1],vertex[2]);
pve.setPoint(point);
@@ -300,5 +309,252 @@ void Geant4_SoPolyhedron::computeBBox(
}
}
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
//////////////////////////////////////////////////////////////////////////////
void Geant4_SoPolyhedron::generateAlternateRep(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(!fPolyhedron) return;
if(fPolyhedron->GetNoFacets()<=0) return; // Abnormal polyhedron.
if(fPolyhedron->GetNoVertices()<=0) return; // Abnormal polyhedron.
if(solid.getValue()==TRUE) {
SoSeparator* separator = new SoSeparator;
SoNormalBinding* normalBinding = new SoNormalBinding;
normalBinding->value = SoNormalBinding::PER_FACE;
separator->addChild(normalBinding);
SoCoordinate3* coordinate3 = new SoCoordinate3;
separator->addChild(coordinate3);
SoNormal* normal = new SoNormal;
separator->addChild(normal);
SoIndexedFaceSet* indexedFaceSet = new SoIndexedFaceSet;
separator->addChild(indexedFaceSet);
SbBool empty = TRUE;
int nvert = fPolyhedron->GetNoVertices();
int nface = fPolyhedron->GetNoFacets();
SbVec3f* normals = new SbVec3f[nface];
//FIXME : have the exact booking.
SbVec3f* points = new SbVec3f[nvert];
int32_t* coords = new int32_t[nvert+1];
int inormal = 0;
int icoord = 0;
int iindex = 0;
// Assume all facets are convex quadrilaterals :
bool notLastFace;
do {
HVNormal3D unitNormal;
notLastFace = fPolyhedron->GetNextUnitNormal(unitNormal);
// begin face POLYGON
int ipoint = 0;
bool notLastEdge;
int edgeFlag = 1;
do {
HVPoint3D vertex;
notLastEdge = fPolyhedron->GetNextVertex(vertex,edgeFlag);
points[ipoint].setValue(vertex[0],vertex[1],vertex[2]);
coords[ipoint] = icoord + ipoint;
ipoint++;
empty = FALSE;
} while (notLastEdge);
// end face.
coords[ipoint] = SO_END_FACE_INDEX;
coordinate3->point.setValues(icoord,ipoint,points);
icoord += ipoint;
normals[inormal].setValue(unitNormal[0],unitNormal[1],unitNormal[2]);
inormal++;
indexedFaceSet->coordIndex.setValues(iindex,(ipoint+1),coords);
iindex += ipoint+1;
} while (notLastFace);
normal->vector.setValues(0,inormal,normals);
delete [] normals;
delete [] coords;
delete [] points;
if(empty==TRUE) {
separator->unref();
} else {
alternateRep.setValue(separator);
}
} else {
SoSeparator* separator = new SoSeparator;
int nvert = fPolyhedron->GetNoVertices();
//FIXME : have the exact booking.
int nedge = nvert * 3;
int npoint = nedge*2;
SbVec3f* points = new SbVec3f[npoint];
int ncoord = nedge*3;
int32_t* coords = new int32_t[ncoord];
SbVec3f pvb,pve;
SbBool empty = TRUE;
int ipoint = 0;
int icoord = 0;
bool notLastFace;
do {
HVNormal3D unitNormal;
notLastFace = fPolyhedron->GetNextUnitNormal(unitNormal);
//SbVec3f normal;
//if( (fProjection==SbProjectionRZ) || (fProjection==SbProjectionZR) ) {
//normal.setValue(0,0,1);
//} else {
//normal.setValue(unitNormal[0],unitNormal[1],unitNormal[2]);
//}
// Treat edges :
int edgeFlag = 1;
int prevEdgeFlag = edgeFlag;
bool notLastEdge;
SbBool firstEdge = TRUE;
do {
HVPoint3D vertex;
notLastEdge = fPolyhedron->GetNextVertex(vertex,edgeFlag);
if(reducedWireFrame.getValue()==FALSE) edgeFlag = 1;
if(firstEdge) {
if(edgeFlag > 0) {
pvb.setValue(vertex[0],vertex[1],vertex[2]);
} else {
}
firstEdge = FALSE;
prevEdgeFlag = edgeFlag;
} else {
if(edgeFlag!=prevEdgeFlag) {
if(edgeFlag > 0) { // Pass to a visible edge :
pvb.setValue(vertex[0],vertex[1],vertex[2]);
} else { // Pass to an invisible edge :
pve.setValue(vertex[0],vertex[1],vertex[2]);
if((ipoint+1)>=npoint) {
int new_npoint = 2 * npoint;
SbVec3f* new_points = new SbVec3f[new_npoint];
for(int i=0;i<npoint;i++) new_points[i] = points[i];
delete [] points;
npoint = new_npoint;
points = new_points;
}
if((icoord+2)>=ncoord) {
int new_ncoord = 2 * ncoord;
int32_t* new_coords = new int32_t[new_ncoord];
for(int i=0;i<ncoord;i++) new_coords[i] = coords[i];
delete [] coords;
ncoord = new_ncoord;
coords = new_coords;
}
points[ipoint+0] = pvb;
points[ipoint+1] = pve;
coords[icoord+0] = ipoint + 0;
coords[icoord+1] = ipoint + 1;
coords[icoord+2] = SO_END_LINE_INDEX;
ipoint += 2;
icoord += 3;
empty = FALSE;
}
prevEdgeFlag = edgeFlag;
} else {
if(edgeFlag > 0) {
pve.setValue(vertex[0],vertex[1],vertex[2]);
if((ipoint+1)>=npoint) {
int new_npoint = 2 * npoint;
SbVec3f* new_points = new SbVec3f[new_npoint];
for(int i=0;i<npoint;i++) new_points[i] = points[i];
delete [] points;
npoint = new_npoint;
points = new_points;
}
if((icoord+2)>=ncoord) {
int new_ncoord = 2 * ncoord;
int32_t* new_coords = new int32_t[new_ncoord];
for(int i=0;i<ncoord;i++) new_coords[i] = coords[i];
delete [] coords;
ncoord = new_ncoord;
coords = new_coords;
}
points[ipoint+0] = pvb;
points[ipoint+1] = pve;
coords[icoord+0] = ipoint + 0;
coords[icoord+1] = ipoint + 1;
coords[icoord+2] = SO_END_LINE_INDEX;
ipoint += 2;
icoord += 3;
empty = FALSE;
pvb = pve;
} else {
}
}
}
} while (notLastEdge);
} while (notLastFace);
SoCoordinate3* coordinate3 = new SoCoordinate3;
coordinate3->point.setValues(0,ipoint,points);
separator->addChild(coordinate3);
SoIndexedLineSet* indexedLineSet = new SoIndexedLineSet;
indexedLineSet->coordIndex.setValues(0,icoord,coords);
separator->addChild(indexedLineSet);
delete [] coords;
delete [] points;
if(empty==TRUE) {
separator->unref();
} else {
alternateRep.setValue(separator);
}
}
}
//////////////////////////////////////////////////////////////////////////////
void Geant4_SoPolyhedron::clearAlternateRep(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
alternateRep.setValue(NULL);
}
//////////////////////////////////////////////////////////////////////////////
void Geant4_SoPolyhedron::doAction(
SoAction* aAction
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
SO_ALTERNATEREP_DO_ACTION(aAction)
SoShape::doAction(aAction);
}
#endif
@@ -23,7 +23,7 @@
//
//
// $Id: SoTrap.cc,v 1.7 2004/12/16 12:33:10 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------HEPVis----------------------------------------*/
/* */
@@ -23,7 +23,7 @@
//
//
// $Id: SoTrd.cc,v 1.7 2004/12/16 12:33:10 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------HEPVis---------------------------------------*/
/* */
@@ -23,7 +23,7 @@
//
//
// $Id: SoTubs.cc,v 1.7 2004/12/16 12:33:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
/*-----------------------------HEPVis---------------------------------------*/
/* */
@@ -26,7 +26,7 @@
* GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2003 Christophe Geuzaine
*
* $Id: gl2ps.cc,v 1.9 2005/06/02 16:51:56 allison Exp $
* $Id: gl2ps.cc,v 1.10 2005/08/01 16:15:49 gcosmo Exp $
*
* E-mail: geuz@geuz.org
* URL: http://www.geuz.org/gl2ps/
@@ -538,7 +538,7 @@ GLint gl2psFindRoot(GL2PSlist *primitives, GL2PSprimitive **root){
}
}
void gl2psFreePrimitive(void *a, void *b){
void gl2psFreePrimitive(void *a, void *){
GL2PSprimitive *q;
q = *(GL2PSprimitive**)a;
@@ -978,7 +978,7 @@ GLint gl2psAddInBspImageTree(GL2PSprimitive *prim, GL2PSbsptree2d **tree){
return 0;
}
void gl2psAddInImageTree(void *a, void *b){
void gl2psAddInImageTree(void *a, void *){
GL2PSprimitive *prim = *(GL2PSprimitive **)a;
if(!gl2psAddInBspImageTree(prim, &gl2ps->imagetree)){
@@ -1336,7 +1336,7 @@ int gl2psGetRGB(GLfloat *pixels, GLsizei width, GLsizei height, GLuint x, GLuint
}
void gl2psPrintPostScriptPixmap(GLfloat x, GLfloat y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLfloat *pixels,
GLenum, GLenum, GLfloat *pixels,
FILE *stream){
typedef unsigned char Uchar;
int status = 1, nbhex, nbyte;
@@ -1774,7 +1774,7 @@ void gl2psResetPostScriptColor(void){
gl2ps->lastrgba[0] = gl2ps->lastrgba[1] = gl2ps->lastrgba[2] = -1.;
}
void gl2psPrintPostScriptPrimitive(void *a, void *b){
void gl2psPrintPostScriptPrimitive(void *a, void *){
GL2PSprimitive *prim;
prim = *(GL2PSprimitive**)a;
@@ -1941,7 +1941,7 @@ void gl2psPrintTeXHeader(void){
gl2ps->viewport[2], gl2ps->viewport[3]);
}
void gl2psPrintTeXPrimitive(void *a, void *b){
void gl2psPrintTeXPrimitive(void *a, void *){
GL2PSprimitive *prim;
prim = *(GL2PSprimitive**)a;
@@ -1961,7 +1961,7 @@ void gl2psPrintTeXFooter(void){
(gl2ps->options & GL2PS_LANDSCAPE) ? "}" : "");
}
void gl2psPrintTeXBeginViewport(GLint viewport[4]){
void gl2psPrintTeXBeginViewport(GLint){
}
GLint gl2psPrintTeXEndViewport(void){
@@ -24,7 +24,7 @@
* GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2003 Christophe Geuzaine
*
* $Id: gl2ps.h,v 1.3 2004/12/15 15:43:11 gunter Exp $
* $Id: gl2ps.h,v 1.4 2005/08/01 16:15:49 gcosmo Exp $
*
* E-mail: geuz@geuz.org
* URL: http://www.geuz.org/gl2ps/
@@ -249,7 +249,7 @@ GL2PSDLL_API GLint gl2psPointSize(GLfloat value);
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value);
#ifdef __cplusplus
};
}
#endif
#endif /* __GL2PS_H__ */