Logo Search packages:      
Sourcecode: opencascade version File versions  Download package

Graphic3d_Structure.cxx

// File         Graphic3d_Structure.cxx
// Created      Mars 1992
// Author       NW,JPB,CAL
// Modified      1/08/97 ; PCT : ajout texture mapping
//              20/08/97 ; PCT : ajout transparence pour texture
//              11/97 ; CAL : gestion du GraphicClear
//              11/97 ; CAL : ajout pointer StructPtr
//              11/97 ; CAL : amelioration de l'effacement SetManager
//      CAL : 15 janvier 1998
//              Ajout de la methode IsTransformed dans une Structure.
//                      (Permet la transmission de cette Trsf vers
//                      la structure COMPUTED si necessaire)
//
//              Ajout de la methode IsRotated dans une Structure.
//                      (Permet de connaitre le type de transformation
//                      pour declencher le calcul des parties cachees
//                      de maniere plus sioux)
//
//              Ajout de 3 nouvelles methodes Compute virtual dans Structure.
//                      (Permet des Compute un peu plus specialises)
//
//              Ajout des 2 methodes sur Owner dans Structure.
//                      (evite de calculer 2 fois les parties cachees
//                      pour 2 representations differentes affichees
//                      d'un meme Presentable Object (Owner))
//
//              Ajout des 2 methodes sur HLRValidation dans Structure.
//                      (permet de valider ou d'invalider le calcul des
//                      parties cachees sur certaines representations)
//
//              Ajout de la transmission de la transformation d'une structure
//              vers sa COMPUTED.
//              24/2/98 ; CAL : Modification de la gestion des champs
//      CAL : 26 mars 1998
//              Patch, erreur dans la gestion du nombre de Group avec
//              facettes dans Graphic3d_Structure avec une operation
//              de Clear. (PRO12795)
//      FGU : 30 Avril 1998
//              Ajout emission
//      CAL : 20 mai 1998
//              Perfs. Connection entre structures COMPUTED.
//      30/11/98 ; FMN : S4069. Textes always visible.  
//      22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets  

#define G003    //EUG 26/01/00 Degeneration management

#define BUC60918        //GG 31/05/01 A transparente structure priority must have the 
//                      MAX_PRIORITY value so, the highlighted structure must have
//                      MAX_PRIORITY-1 value.   
//                      Add ResetDisplayPriority() method.

#define OCC1174 // SAV 08/01/03 Added back face interior color controling

#define OCC2934 // SAN 22/01/04 Texture mapped fonts on WNT 

//                      
//-Copyright    MatraDatavision 1991,1992,1993,1994,1995

//-Version      

//-Design       Declaration des variables specifiques aux structures
//              graphiques

//-Warning      Une structure est definie dans un manager
//              Il s'agit d'une sequence de groupes de primitives

//-References   

//-Language     C++ 2.0

//-Declarations

// for the class

#define XDOWNCAST
#define XDESTROY
#define XDEBUG
#define XTRACE
#define XTRACE_ISTRSF

#include <stdio.h>

#include <Graphic3d_Structure.ixx>
#include <Graphic3d_Structure.pxx>

#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_MaterialAspect.hxx>

#include <Graphic3d_MapOfStructure.hxx>
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>

#include <Quantity_Color.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <Graphic3d_TextureMap.hxx>

// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
#include <Aspect_PolygonOffsetMode.hxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 

//-Aliases

//-Global data definitions

//-Constructors

00107 Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& AManager):
MyGroupGenId (Group_IDMIN, Group_IDMAX),
MyAncestors (),
MyDescendants (),
MyGroups (),
MyHighlightColor (Quantity_NOC_WHITE)
{

Standard_Integer i, j;

        MyOwner = NULL;

        Handle(Graphic3d_AspectLine3d) aAspectLine3d =
                                        new Graphic3d_AspectLine3d ();
        Handle(Graphic3d_AspectText3d) aAspectText3d =
                                        new Graphic3d_AspectText3d ();
        Handle(Graphic3d_AspectMarker3d) aAspectMarker3d =
                                        new Graphic3d_AspectMarker3d ();
        Handle(Graphic3d_AspectFillArea3d) aAspectFillArea3d =
                                        new Graphic3d_AspectFillArea3d ();

        // Recuperation des valeurs par defaut
        AManager->PrimitivesAspect (aAspectLine3d, aAspectText3d,
                                        aAspectMarker3d, aAspectFillArea3d);

        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
        // It is necessary to set default polygon offsets for a new presentation
        aAspectFillArea3d->SetPolygonOffsets( Aspect_POM_Fill, 1., 0. );
        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 

        // Mise a jour de la CStructure associee
        UpdateStructure (aAspectLine3d, aAspectText3d,
                                        aAspectMarker3d, aAspectFillArea3d);

        MyFirstPtrStructureManager = MyPtrStructureManager =
                                        (void *) AManager.operator->();
        MyCStructure.Id         = int (AManager->NewIdentification ());

        MyCStructure.IsOpen     = 0;
        MyCStructure.IsDeleted  = 0;

        MyCStructure.Composition        = 0; /* Graphic3d_TOC_REPLACE */

        for (i=0; i<=3; i++)
            for (j=0; j<=3; j++)
                if (i == j)
                    MyCStructure.Transformation[i][j] = float (1.0);
                else
                    MyCStructure.Transformation[i][j] = float (0.0);

        MyCStructure.Priority   = int (Structure_MAX_PRIORITY / 2);
        MyCStructure.PreviousPriority   = MyCStructure.Priority;
        MyCStructure.stick      = 0,
        MyCStructure.highlight  = 0,
        MyCStructure.visible    = 1,
        MyCStructure.pick       = 1;
        MyCStructure.ContainsFacet      = 0,
        MyCStructure.IsInfinite         = 0,
        MyCStructure.HLRValidation      = 0;

        MyCStructure.GroupBegin = Structure_GROUPBEGIN;
        MyCStructure.GroupEnd   = Structure_GROUPEND;

        MyCStructure.ContextLine.IsDef          = 1,
        MyCStructure.ContextFillArea.IsDef      = 1,
        MyCStructure.ContextMarker.IsDef        = 1,
        MyCStructure.ContextText.IsDef          = 1;

        MyCStructure.ContextLine.IsSet          = 0,
        MyCStructure.ContextFillArea.IsSet      = 0,
        MyCStructure.ContextMarker.IsSet        = 0,
        MyCStructure.ContextText.IsSet          = 0;

        MyVisual        = Graphic3d_TOS_ALL;
        MyComputeVisual = Graphic3d_TOS_ALL;

      /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
        /*MyCStructure.TransformPersistence.IsDef = 1;*/
      MyCStructure.TransformPersistence.IsSet = 0;
      MyCStructure.TransformPersistence.Flag = Graphic3d_TMF_None;
        MyCStructure.TransformPersistence.Point.x = 0.0;
        MyCStructure.TransformPersistence.Point.y = 0.0;
        MyCStructure.TransformPersistence.Point.z = 0.0;
      /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
Handle(Aspect_GraphicDriver) agd =
        (AManager->GraphicDevice ())->GraphicDriver ();

        MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;

        MyGraphicDriver->Structure (MyCStructure);

#ifdef TRACE
        cout << "Graphic3d_Structure::Create (" << MyCStructure.Id << ")\n";
#endif

}

//-Destructors

00206 void Graphic3d_Structure::Destroy () {

#ifdef DESTROY
        cout << "Graphic3d_Structure::Destroy (" << MyCStructure.Id << ")\n";
#endif

        // as MyFirstPtrStructureManager can be already destroyed,
        // avoid attempts to access it 
        MyFirstPtrStructureManager = 0;
        Remove ();

}

//-Methods, in order

00221 void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction) {

        if (IsDeleted ()) return;

        if (WithDestruction) {
                MyGroupGenId.Free ();
                MyGroups.Clear ();
        }

        MyCStructure.ContainsFacet      = 0;

        GraphicClear (WithDestruction);
        MyStructureManager->Clear (this, WithDestruction);

        Update ();

}

00239 void Graphic3d_Structure::Remove () {

        if (IsDeleted ()) return;

#ifdef DESTROY
        if (MyDescendants.Length () != 0) {
                cout << "The structure " << MyCStructure.Id << " have "
                     << MyDescendants.Length () << " descendants.\n" << flush;
        }
        if (MyAncestors.Length () != 0) {
                cout << "The structure " << MyCStructure.Id << " have "
                     << MyAncestors.Length () << " ancestors.\n" << flush;
        }
#endif

        Standard_Integer i, Length;
//        Standard_Address APtr = (void *) This ().operator->();
        Standard_Address APtr = (void *) this;
        // Il faut enlever le pointeur possible sur cette structure
        // que l'on est en train de detruire, dans la liste des descendants
        // des ancetres de cette structure et dans la liste des ancetres
        // des descendants de cette meme structure.

        Length  = MyDescendants.Length ();
        for (i=1; i<=Length; i++)
            ((Graphic3d_Structure *)
            (MyDescendants.Value (i)))->Remove (APtr, Graphic3d_TOC_ANCESTOR);

        Length  = MyAncestors.Length ();
        for (i=1; i<=Length; i++)
            ((Graphic3d_Structure *)
            (MyAncestors.Value (i)))->Remove (APtr, Graphic3d_TOC_DESCENDANT);

        MyCStructure.ContainsFacet      = 0;
        MyCStructure.IsDeleted  = 1;

        // Destruction de me dans la bibliotheque graphique
        MyGraphicDriver->RemoveStructure (MyCStructure);

        // Liberation de l'identification de la structure detruite
        // dans le premier manager qui a gere la creation de la structure.
        if ( MyFirstPtrStructureManager )
          MyFirstStructureManager->Remove (Standard_Integer (MyCStructure.Id));

}

00285 void Graphic3d_Structure::Display () {

        if (IsDeleted ()) return;

        if (! MyCStructure.stick) {
                MyCStructure.stick      = 1;
                MyStructureManager->Display (this);
        }

}

00296 void Graphic3d_Structure::Display (const Standard_Integer Priority) {

        if (IsDeleted ()) return;

        SetDisplayPriority (Priority);

        if (! MyCStructure.stick) {
                MyCStructure.stick      = 1;
                MyStructureManager->Display (this);
        }

}

00309 void Graphic3d_Structure::SetDisplayPriority (const Standard_Integer Priority) {

        if (IsDeleted ()) return;

#ifdef BUC60918
        if( Priority == MyCStructure.Priority ) return;
#endif

        MyCStructure.PreviousPriority   = MyCStructure.Priority;
        MyCStructure.Priority   = int (Priority);

        if (MyCStructure.Priority != MyCStructure.PreviousPriority) {
                if ( (MyCStructure.Priority > Structure_MAX_PRIORITY) ||
                     (MyCStructure.Priority < Structure_MIN_PRIORITY) )
                        Graphic3d_PriorityDefinitionError::Raise
                                ("Bad value for StructurePriority");

                if (MyCStructure.stick)
                        MyStructureManager->ChangeDisplayPriority (this,
                            Standard_Integer (MyCStructure.PreviousPriority),
                            Standard_Integer (MyCStructure.Priority));
        }

}

#ifdef BUC60918
00335 void Graphic3d_Structure::ResetDisplayPriority () {

        if (IsDeleted ()) return;

        if (MyCStructure.Priority != MyCStructure.PreviousPriority) {
                Standard_Integer priority = MyCStructure.Priority;
                MyCStructure.Priority   = MyCStructure.PreviousPriority;

                if (MyCStructure.stick)
                        MyStructureManager->ChangeDisplayPriority (this,
                            priority,
                            Standard_Integer (MyCStructure.Priority));
        }

}
#endif

00352 Standard_Integer Graphic3d_Structure::DisplayPriority () const {

        return Standard_Integer (MyCStructure.Priority);

}

00358 void Graphic3d_Structure::Erase () {

        if (IsDeleted ()) return;

        if (MyCStructure.stick) {
                MyCStructure.stick      = 0;
                MyStructureManager->Erase (this);
        }

}

00369 void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod AMethod) {

        if (IsDeleted ()) return;

        // Highlight sur une structure deja Highlighted.
        if (MyCStructure.highlight) {

Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
                if (UpdateMode == Aspect_TOU_WAIT)
                        UnHighlight ();
                else {
                        // Pour eviter d'appeler la methode : Update ()
                        // Inutile et peut-etre couteux.
                        MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
                        UnHighlight ();
                        MyStructureManager->SetUpdateMode (UpdateMode);
                }
        }

#ifdef BUC60918
        SetDisplayPriority (Standard_Integer (Structure_MAX_PRIORITY)-1);
#else
        SetDisplayPriority (Standard_Integer (Structure_MAX_PRIORITY));
#endif

        GraphicHighlight (AMethod);
        MyStructureManager->Highlight (this, AMethod);

        Update ();

}

00401 void Graphic3d_Structure::SetHighlightColor (const Quantity_Color& AColor) {

        if (IsDeleted ()) return;

        if (! MyCStructure.highlight)
                MyHighlightColor        = AColor;
        else {
        // Changement de highlight color sur une structure deja Highlighted.

Aspect_TypeOfUpdate UpdateMode  = MyStructureManager->UpdateMode ();
                if (UpdateMode == Aspect_TOU_WAIT)
                        UnHighlight ();
                else {
                        // Pour eviter d'appeler la methode : Update ()
                        // Inutile et peut-etre couteux.
                        MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
                        UnHighlight ();
                        MyStructureManager->SetUpdateMode (UpdateMode);
                }
                MyHighlightColor        = AColor;
                Highlight (MyHighlightMethod);
        }

}

00426 void Graphic3d_Structure::SetVisible (const Standard_Boolean AValue) {

        if (IsDeleted ()) return;

        MyCStructure.visible    = AValue ? 1:0;

        MyGraphicDriver->NameSetStructure (MyCStructure);

        if (AValue)
                MyStructureManager->Visible (this);
        else
                MyStructureManager->Invisible (this);

        Update ();

}

00443 void Graphic3d_Structure::SetPick (const Standard_Boolean AValue) {

        if (IsDeleted ()) return;

        MyCStructure.pick       = AValue ? 1:0;

        MyGraphicDriver->NameSetStructure (MyCStructure);

        if (AValue)
                MyStructureManager->Detectable (this);
        else
                MyStructureManager->Undetectable (this);

        Update ();

}

00460 void Graphic3d_Structure::UnHighlight () {

        if (IsDeleted ()) return;

        if (MyCStructure.highlight) {
                MyCStructure.highlight  = 0;

                GraphicUnHighlight ();
                MyStructureManager->UnHighlight (this);
#ifdef BUC60918
                ResetDisplayPriority();
#else
                SetDisplayPriority
                        (Standard_Integer (MyCStructure.PreviousPriority));
#endif
                Update ();
        }

}

00480 Quantity_Color Graphic3d_Structure::HighlightColor () const {

        return (MyHighlightColor);

}

00486 Standard_Boolean Graphic3d_Structure::IsDisplayed () const {

        if (MyCStructure.stick)
                return (Standard_True);
        else
                return (Standard_False);

}

00495 Standard_Boolean Graphic3d_Structure::IsDeleted () const {

        if (MyCStructure.IsDeleted)
                return (Standard_True);
        else
                return (Standard_False);

}

00504 Standard_Boolean Graphic3d_Structure::IsHighlighted () const {

        if (MyCStructure.highlight)
                return (Standard_True);
        else
                return (Standard_False);

}

00513 Standard_Boolean Graphic3d_Structure::IsSelectable () const {

        if (MyCStructure.pick)
                return (Standard_True);
        else
                return (Standard_False);

}

00522 Standard_Boolean Graphic3d_Structure::IsVisible () const {

        if (MyCStructure.visible)
                return (Standard_True);
        else
                return (Standard_False);

}

00531 Standard_Boolean Graphic3d_Structure::IsRotated () const {

        // Test un peu leger !
        return   ( MyCStructure.Transformation[0][1] != 0.
                || MyCStructure.Transformation[0][2] != 0.
                || MyCStructure.Transformation[1][0] != 0.
                || MyCStructure.Transformation[1][2] != 0.
                || MyCStructure.Transformation[2][0] != 0.
                || MyCStructure.Transformation[2][1] != 0. );

}

00543 Standard_Boolean Graphic3d_Structure::IsTransformed () const {

Standard_Boolean Result = Standard_False;
Standard_Integer i, j;

        for (i=0; i<=3 && ! Result; i++)
            for (j=0; j<=3 && ! Result; j++)
                if (i == j)
                    Result = MyCStructure.Transformation[i][j] != 1.;
                else
                    Result = MyCStructure.Transformation[i][j] != 0.;

#ifdef TRACE_ISTRSF
        cout << "La structure " << Identification ();
        if (Result)
            cout << " est transformee\n" << flush;
        else
            cout << " n'est pas transformee\n" << flush;
#endif

        return Result;

}

00567 Standard_Boolean Graphic3d_Structure::ContainsFacet () const {

        if (IsDeleted ()) return (Standard_False);

        // Une structure contient au moins une facette :
        // si l'un de ses groupes est contient au moins une facette.

Standard_Boolean Result1        = Standard_False;
Standard_Boolean Result2        = Standard_False;
Standard_Integer i, Length;

        Result1 = (MyCStructure.ContainsFacet > 0);

        // Si un des groupes contient au moins une facette alors
        // la structure aussi.
        if (Result1) return (Result1);

        Length  = MyDescendants.Length ();

        // Je m'arrete au premier descendant qui contient au moins une facette.
        for (i=1; i<=Length && ! Result2; i++)
                Result2 = ((Graphic3d_Structure *)
                        (MyDescendants.Value (i)))->ContainsFacet ();

        return (Result2);

}

00595 Standard_Boolean Graphic3d_Structure::IsEmpty () const {

        if (IsDeleted ()) return (Standard_True);

        // Une structure est vide :
        // si l'ensemble de ses groupes est vide ou tous ses
        // groupes sont vides et si l'ensemble de ses descendants
        // est vide ou tous ses descendants sont vides.

Standard_Boolean Result1        = Standard_True;
Standard_Integer i, Length      = MyGroups.Length ();

        // Je m'arrete au premier groupe non vide
        for (i=1; i<=Length && Result1; i++)
                Result1 = (MyGroups.Value (i))->IsEmpty ();

        // Si un des groupes est non vide alors la structure l'est aussi.
        if (! Result1) return (Standard_False);

Standard_Boolean Result2        = Standard_True;

        Length  = MyDescendants.Length ();

        // Je m'arrete au premier descendant non vide
        for (i=1; i<=Length && Result2; i++)
                Result2 = ((Graphic3d_Structure *)
                        (MyDescendants.Value (i)))->IsEmpty ();

        return (Result2);

}

00627 void Graphic3d_Structure::PrimitivesAspect (Handle(Graphic3d_AspectLine3d)& CTXL, Handle(Graphic3d_AspectText3d)& CTXT, Handle(Graphic3d_AspectMarker3d)& CTXM, Handle(Graphic3d_AspectFillArea3d)& CTXF) const {

        CTXL     = Line3dAspect ();
        CTXT     = Text3dAspect ();
        CTXM     = Marker3dAspect ();
        CTXF     = FillArea3dAspect ();

}

00636 void Graphic3d_Structure::GroupsWithFacet (const Standard_Integer ADelta) {

        MyCStructure.ContainsFacet      = MyCStructure.ContainsFacet + ADelta;
        if (MyCStructure.ContainsFacet < 0) MyCStructure.ContainsFacet = 0;

#ifdef DEBUG
        cout << "MyCStructure.ContainsFacet " << MyCStructure.ContainsFacet;
        cout << endl << flush;
#endif

}

Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ) {

        // Implemented by Presentation
        return this;
}

Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , const TColStd_Array2OfReal& ) {

        // Implemented by Presentation
        return this;
}

00660 void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , Handle(Graphic3d_Structure)& ) {

        // Implemented by Presentation
}

00665 void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , const TColStd_Array2OfReal& , Handle(Graphic3d_Structure)& ) {

        // Implemented by Presentation
}

00670 void Graphic3d_Structure::ReCompute () {

        MyStructureManager->ReCompute (this);

}

00676 void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& aProjector) {

        MyStructureManager->ReCompute (this, aProjector);

}

00682 void Graphic3d_Structure::SetInfiniteState (const Standard_Boolean AValue) {

        MyCStructure.IsInfinite = AValue ? 1:0;

}

00688 Standard_Boolean Graphic3d_Structure::IsInfinite () const {

        if (IsDeleted ()) return (Standard_True);

        if (MyCStructure.IsInfinite)
                return (Standard_True);
        else
                return (Standard_False);

}

00699 void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction) {

        if (WithDestruction)
                /*
                 * Dans ce cas l'appelant dans faire :
                 * void Prs3d_Presentation::Clear () {
                 *   Graphic3d_Structure::Clear ();
                 *   myCurrentGroup = new Graphic3d_Group (this);
                 * }
                 */
                MyGraphicDriver->ClearStructure (MyCStructure);
        else {
                /*
                 * Dans ce cas l'appelant dans faire :
                 * void Prs3d_Presentation::Clear () {
                 *   Graphic3d_Structure::Clear ();
                 *   // myCurrentGroup = new Graphic3d_Group (this);
                 * }
                 */
                Standard_Integer Length = MyGroups.Length ();

                for (Standard_Integer i=1; i<=Length; i++)
                        (MyGroups.Value (i))->Clear ();
        }

}

void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter) {

        MyGraphicDriver->Connect
        (MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));

}

void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& ADaughter) {

        MyGraphicDriver->Disconnect
        (MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));

}

Handle(Graphic3d_AspectLine3d) Graphic3d_Structure::Line3dAspect () const {

Standard_Real           R, G, B;
Standard_Real           AWidth;
Quantity_Color          AColor;
Aspect_TypeOfLine       ALType;

        // ContextLine
        R       = Standard_Real (MyCStructure.ContextLine.Color.r);
        G       = Standard_Real (MyCStructure.ContextLine.Color.g);
        B       = Standard_Real (MyCStructure.ContextLine.Color.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        ALType  = Aspect_TypeOfLine (MyCStructure.ContextLine.LineType);
        AWidth  = Standard_Real (MyCStructure.ContextLine.Width);

        Handle(Graphic3d_AspectLine3d) CTXL =
                new Graphic3d_AspectLine3d (AColor, ALType, AWidth);
        // CTXL->SetColor (AColor);
        // CTXL->SetType (ALType);
        // CTXL->SetWidth (AWidth);

        return CTXL;

}

Handle(Graphic3d_AspectText3d) Graphic3d_Structure::Text3dAspect () const {

Standard_Real           R, G, B;
//Standard_Real         Rs, Gs, Bs;
Graphic3d_NameOfFont    AFont;
Standard_Real           ASpace;
Standard_Real           AnExpansion;
Quantity_Color          AColor;
Aspect_TypeOfStyleText  AStyle;
Aspect_TypeOfDisplayText ADisplayType;

        // ContextText
        R       = Standard_Real (MyCStructure.ContextText.Color.r);
        G       = Standard_Real (MyCStructure.ContextText.Color.g);
        B       = Standard_Real (MyCStructure.ContextText.Color.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        AFont   = Graphic3d_NameOfFont (MyCStructure.ContextText.Font);
        AnExpansion     = Standard_Real (MyCStructure.ContextText.Expan);
        ASpace  = Standard_Real (MyCStructure.ContextText.Space);
        AStyle  = Aspect_TypeOfStyleText (MyCStructure.ContextText.Style);
        ADisplayType = Aspect_TypeOfDisplayText (MyCStructure.ContextText.DisplayType);

        Handle(Graphic3d_AspectText3d) CTXT =
                new Graphic3d_AspectText3d (AColor, AFont, AnExpansion, ASpace,AStyle,ADisplayType);

        return CTXT;

}

Handle(Graphic3d_AspectMarker3d) Graphic3d_Structure::Marker3dAspect () const {

Standard_Real           R, G, B;
Standard_Real           AScale;
Quantity_Color          AColor;
Aspect_TypeOfMarker     AMType;

        // ContextMarker
        R       = Standard_Real (MyCStructure.ContextMarker.Color.r);
        G       = Standard_Real (MyCStructure.ContextMarker.Color.g);
        B       = Standard_Real (MyCStructure.ContextMarker.Color.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        AMType  = Aspect_TypeOfMarker (MyCStructure.ContextMarker.MarkerType);
        AScale  = Standard_Real (MyCStructure.ContextMarker.Scale);

        Handle(Graphic3d_AspectMarker3d) CTXM =
                new Graphic3d_AspectMarker3d (AMType, AColor, AScale);
        // CTXM->SetColor (AColor);
        // CTXM->SetType (AMType);
        // CTXM->SetScale (AScale);

        return CTXM;

}

Handle(Graphic3d_AspectFillArea3d) Graphic3d_Structure::FillArea3dAspect () const {

Standard_Real           R, G, B;
Standard_Real           AWidth;
Quantity_Color          AColor;
Quantity_Color          AnIntColor;
Quantity_Color          AnEdgeColor;
Aspect_TypeOfLine       ALType;
Aspect_InteriorStyle    AStyle;
Standard_Boolean        EdgeOn = Standard_False;
Graphic3d_MaterialAspect Front;
Graphic3d_MaterialAspect Back;

        // ContextFillArea
        AStyle  = Aspect_InteriorStyle (MyCStructure.ContextFillArea.Style);
        R       = Standard_Real (MyCStructure.ContextFillArea.IntColor.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.IntColor.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.IntColor.b);
        AnIntColor.SetValues (R, G, B, Quantity_TOC_RGB);
        // Edges
        if (MyCStructure.ContextFillArea.Edge == 1) EdgeOn = Standard_True;
        R       = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.b);
        AnEdgeColor.SetValues (R, G, B, Quantity_TOC_RGB);
        ALType  = Aspect_TypeOfLine (MyCStructure.ContextFillArea.LineType);
        AWidth  = Standard_Real (MyCStructure.ContextFillArea.Width);
        // Back Material
        Back.SetShininess (
                Standard_Real (MyCStructure.ContextFillArea.Back.Shininess));
        Back.SetAmbient (
                Standard_Real (MyCStructure.ContextFillArea.Back.Ambient));
        Back.SetDiffuse (
                Standard_Real (MyCStructure.ContextFillArea.Back.Diffuse));
        Back.SetSpecular (
                Standard_Real (MyCStructure.ContextFillArea.Back.Specular));
        Back.SetTransparency (
                Standard_Real (MyCStructure.ContextFillArea.Back.Transparency));
        Back.SetEmissive (
                Standard_Real (MyCStructure.ContextFillArea.Back.Emission));
        if (MyCStructure.ContextFillArea.Back.IsAmbient == 1)
                Back.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
        else
                Back.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
        if (MyCStructure.ContextFillArea.Back.IsDiffuse == 1)
                Back.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
        else
                Back.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
        if (MyCStructure.ContextFillArea.Back.IsSpecular == 1)
                Back.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
        else
                Back.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
        if (MyCStructure.ContextFillArea.Back.IsEmission == 1)
                Back.SetReflectionModeOn (Graphic3d_TOR_EMISSION);
        else
                Back.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Back.SetSpecularColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Back.SetAmbientColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Back.SetDiffuseColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Back.SetEmissiveColor (AColor);
        
        Back.SetEnvReflexion (MyCStructure.ContextFillArea.Back.EnvReflexion);

        Graphic3d_TypeOfMaterial mType = 
                MyCStructure.ContextFillArea.Back.IsPhysic ? 
                        Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
        Back.SetMaterialType(mType);

        // Front Material
        Front.SetShininess (
                Standard_Real (MyCStructure.ContextFillArea.Front.Shininess));
        Front.SetAmbient (
                Standard_Real (MyCStructure.ContextFillArea.Front.Ambient));
        Front.SetDiffuse (
                Standard_Real (MyCStructure.ContextFillArea.Front.Diffuse));
        Front.SetSpecular (
                Standard_Real (MyCStructure.ContextFillArea.Front.Specular));
        Front.SetTransparency (
                Standard_Real (MyCStructure.ContextFillArea.Front.Transparency));
        Front.SetEmissive (
                Standard_Real (MyCStructure.ContextFillArea.Front.Emission));
        if (MyCStructure.ContextFillArea.Front.IsAmbient == 1)
                Front.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
        else
                Front.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
        if (MyCStructure.ContextFillArea.Front.IsDiffuse == 1)
                Front.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
        else
                Front.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
        if (MyCStructure.ContextFillArea.Front.IsSpecular == 1)
                Front.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
        else
                Front.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
        if (MyCStructure.ContextFillArea.Front.Emission == 1)
                Front.SetReflectionModeOn (Graphic3d_TOR_EMISSION);
        else
                Front.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Front.SetSpecularColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Front.SetAmbientColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Front.SetDiffuseColor (AColor);
                
        R       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.r);
        G       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.g);
        B       = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.b);
        AColor.SetValues (R, G, B, Quantity_TOC_RGB);
        Front.SetEmissiveColor (AColor);
        
        Front.SetEnvReflexion (MyCStructure.ContextFillArea.Front.EnvReflexion);

        mType = MyCStructure.ContextFillArea.Front.IsPhysic ? 
                        Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
        Front.SetMaterialType(mType);

        Handle(Graphic3d_AspectFillArea3d) CTXF =
                new Graphic3d_AspectFillArea3d
                    (AStyle, AnIntColor, AnEdgeColor, ALType, AWidth, Front, Back);
        // CTXF->SetInteriorStyle (AStyle);
        // CTXF->SetInteriorColor (AnIntColor);
        // CTXF->SetEdgeColor (AnEdgeColor);
        // CTXF->SetEdgeLineType (ALType);
        // CTXF->SetEdgeWidth (AWidth);
        // CTXF->SetBackMaterial (Back);
        // CTXF->SetFrontMaterial (Front);

        // Edges
        if (EdgeOn)
                CTXF->SetEdgeOn ();
        else
                CTXF->SetEdgeOff ();
        // Hatch
        CTXF->SetHatchStyle(Aspect_HatchStyle (MyCStructure.ContextFillArea.Hatch));
        // Materials
        // Front and Back face
        if (MyCStructure.ContextFillArea.Distinguish == 1)
                CTXF->SetDistinguishOn ();
        else
                CTXF->SetDistinguishOff ();
        if (MyCStructure.ContextFillArea.BackFace == 1)
                CTXF->SuppressBackFace ();
        else
                CTXF->AllowBackFace ();
        // Texture
// Pb sur les textures
        //if (MyCStructure.ContextFillArea.Texture.TexId == -1)
        //else
        if (MyCStructure.ContextFillArea.Texture.doTextureMap == 1)
                CTXF->SetTextureMapOn ();
        else
                CTXF->SetTextureMapOff ();
#ifdef G003
        Aspect_TypeOfDegenerateModel dMode = Aspect_TypeOfDegenerateModel(
                MyCStructure.ContextFillArea.DegenerationMode); 
        Quantity_Ratio dRatio =
                MyCStructure.ContextFillArea.SkipRatio;
        CTXF->SetDegenerateModel(dMode,dRatio);
#endif  // G003

        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
        CTXF->SetPolygonOffsets(MyCStructure.ContextFillArea.PolygonOffsetMode, 
                                MyCStructure.ContextFillArea.PolygonOffsetFactor,
                                MyCStructure.ContextFillArea.PolygonOffsetUnits);
        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 

        return CTXF;

}

Handle(Graphic3d_HSetOfGroup) Graphic3d_Structure::Groups () const {

Handle (Graphic3d_HSetOfGroup) SG = new Graphic3d_HSetOfGroup ();

        if (IsDeleted ()) return (SG);

Standard_Integer i, Length      = MyGroups.Length ();

        for (i=1; i<=Length; i++)
                SG->Add (MyGroups.Value (i));

        return (SG);

}

01036 Standard_Integer Graphic3d_Structure::NumberOfGroups () const {

        return (MyGroups.Length ());

}

01042 void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX) {

        if (IsDeleted ()) return;

Standard_Real           R, G, B;
Standard_Real           AWidth;
Quantity_Color          AColor;
Aspect_TypeOfLine       ALType;

        CTX->Values (AColor, ALType, AWidth);
        AColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextLine.Color.r        = float (R);
        MyCStructure.ContextLine.Color.g        = float (G);
        MyCStructure.ContextLine.Color.b        = float (B);
        MyCStructure.ContextLine.LineType       = int (ALType);
        MyCStructure.ContextLine.Width          = float (AWidth);
        MyCStructure.ContextLine.IsDef          = 1;

        MyGraphicDriver->ContextStructure (MyCStructure);

        // CAL 14/04/95
        // Les attributs sont "IsSet" lors de la premiere mise a jour
        // d'un contexte (line, marker...)
        MyCStructure.ContextLine.IsSet          = 1;
        MyCStructure.ContextFillArea.IsSet      = 1;
        MyCStructure.ContextMarker.IsSet        = 1;
        MyCStructure.ContextText.IsSet          = 1;

        Update ();

}

01075 void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX) {

        if (IsDeleted ()) return;

        Standard_Real           R, G, B;
        Standard_Real           AWidth;
        //Quantity_Color                AColor;
        Quantity_Color          AnIntColor;
        Quantity_Color      BackIntColor;
        Quantity_Color          AnEdgeColor;
        Aspect_TypeOfLine       ALType;
        Aspect_InteriorStyle    AStyle;

        CTX->Values (AStyle, AnIntColor, BackIntColor, AnEdgeColor, ALType, AWidth);
        AnIntColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextFillArea.Style      = int (AStyle);
        MyCStructure.ContextFillArea.IntColor.r = float (R);
        MyCStructure.ContextFillArea.IntColor.g = float (G);
        MyCStructure.ContextFillArea.IntColor.b = float (B);

#ifdef OCC1174
        if ( CTX->Distinguish() )
          BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
#endif
        MyCStructure.ContextFillArea.BackIntColor.r     = float( R );
        MyCStructure.ContextFillArea.BackIntColor.g     = float( G );
        MyCStructure.ContextFillArea.BackIntColor.b     = float( B );


        // Edges
        MyCStructure.ContextFillArea.Edge       = CTX->Edge () ? 1:0;
        AnEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
        MyCStructure.ContextFillArea.EdgeColor.r        = float (R);
        MyCStructure.ContextFillArea.EdgeColor.g        = float (G);
        MyCStructure.ContextFillArea.EdgeColor.b        = float (B);
        MyCStructure.ContextFillArea.LineType           = int (ALType);
        MyCStructure.ContextFillArea.Width              = float (AWidth);
        MyCStructure.ContextFillArea.Hatch              = int (CTX->HatchStyle ());
#ifdef G003
        Quantity_Ratio ratio;
        MyCStructure.ContextFillArea.DegenerationMode = 
                                        int (CTX->DegenerateModel(ratio));
        MyCStructure.ContextFillArea.SkipRatio = float (ratio);
#endif  // G003
                
        /*** Front and Back face ***/
        MyCStructure.ContextFillArea.Distinguish        = CTX->Distinguish () ? 1:0;
        MyCStructure.ContextFillArea.BackFace           = CTX->BackFace () ? 1:0;
                
        /*** Back Material ***/
        // Light specificity
        MyCStructure.ContextFillArea.Back.Shininess     =
                float ((CTX->BackMaterial ()).Shininess ());
        MyCStructure.ContextFillArea.Back.Ambient       =
                float ((CTX->BackMaterial ()).Ambient ());
        MyCStructure.ContextFillArea.Back.Diffuse       =
                float ((CTX->BackMaterial ()).Diffuse ());
        MyCStructure.ContextFillArea.Back.Specular      =
                float ((CTX->BackMaterial ()).Specular ());
        MyCStructure.ContextFillArea.Back.Transparency  =
                float ((CTX->BackMaterial ()).Transparency ());
        MyCStructure.ContextFillArea.Back.Emission      =
                float ((CTX->BackMaterial ()).Emissive ());
        
        // Reflection mode
        MyCStructure.ContextFillArea.Back.IsAmbient     =
                ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsDiffuse     =
                ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsSpecular    =
                ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsEmission    =
                ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
        
        // Material type
//JR/Hp
        const Graphic3d_MaterialAspect ama = CTX->BackMaterial () ;
        Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
        MyCStructure.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
//      MyCStructure.ContextFillArea.Back.IsPhysic      =
//              ( (CTX->BackMaterial ()).MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0 );
        
        // Material color
        //MyCStructure.ContextFillArea.Back.Color.r     =
        //float (((CTX->BackMaterial ()).Color ()).Red ());
        //MyCStructure.ContextFillArea.Back.Color.g     =
        //float (((CTX->BackMaterial ()).Color ()).Green ());
        //MyCStructure.ContextFillArea.Back.Color.b     =
        //float (((CTX->BackMaterial ()).Color ()).Blue ());
        
        // Specular Color 
        MyCStructure.ContextFillArea.Back.ColorSpec.r   =
                float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorSpec.g   =
                float (((CTX->BackMaterial ()).SpecularColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorSpec.b   =
                float (((CTX->BackMaterial ()).SpecularColor ()).Blue ());
        
        // Ambient color
        MyCStructure.ContextFillArea.Back.ColorAmb.r    =
                float (((CTX->BackMaterial ()).AmbientColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorAmb.g    =
                float (((CTX->BackMaterial ()).AmbientColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorAmb.b    =
                float (((CTX->BackMaterial ()).AmbientColor ()).Blue ());
        
        // Diffuse color
        MyCStructure.ContextFillArea.Back.ColorDif.r    =
                float (((CTX->BackMaterial ()).DiffuseColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorDif.g    =
                float (((CTX->BackMaterial ()).DiffuseColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorDif.b    =
                float (((CTX->BackMaterial ()).DiffuseColor ()).Blue ());
        
        // Emissive color
        MyCStructure.ContextFillArea.Back.ColorEms.r    =
                float (((CTX->BackMaterial ()).EmissiveColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorEms.g    =
                float (((CTX->BackMaterial ()).EmissiveColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorEms.b    =
                float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
        
        MyCStructure.ContextFillArea.Back.EnvReflexion = 
                float ((CTX->BackMaterial ()).EnvReflexion());
        
        /*** Front Material ***/
        // Light specificity
        MyCStructure.ContextFillArea.Front.Shininess    =
                float ((CTX->FrontMaterial ()).Shininess ());
        MyCStructure.ContextFillArea.Front.Ambient      =
                float ((CTX->FrontMaterial ()).Ambient ());
        MyCStructure.ContextFillArea.Front.Diffuse      =
                float ((CTX->FrontMaterial ()).Diffuse ());
        MyCStructure.ContextFillArea.Front.Specular     =
                float ((CTX->FrontMaterial ()).Specular ());
        MyCStructure.ContextFillArea.Front.Transparency =
                float ((CTX->FrontMaterial ()).Transparency ());
        MyCStructure.ContextFillArea.Front.Emission     =
                float ((CTX->FrontMaterial ()).Emissive ());
        
        // Reflection mode
        MyCStructure.ContextFillArea.Front.IsAmbient    =
                ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsDiffuse    =
                ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsSpecular   =
                ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsEmission   =
                ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
        
        // Materail type
//JR/Hp
        const Graphic3d_MaterialAspect amas = CTX->FrontMaterial () ;
        Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
        MyCStructure.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
//      MyCStructure.ContextFillArea.Front.IsPhysic     =
//              ( (CTX->FrontMaterial ()).MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0 );
        
        // Material Color
        //MyCStructure.ContextFillArea.Front.Color.r    =
        //float (((CTX->FrontMaterial ()).Color ()).Red ());
        //MyCStructure.ContextFillArea.Front.Color.g    =
        //float (((CTX->FrontMaterial ()).Color ()).Green ());
        //MyCStructure.ContextFillArea.Front.Color.b    =
        //float (((CTX->FrontMaterial ()).Color ()).Blue ());
        
        // Specular Color
        MyCStructure.ContextFillArea.Front.ColorSpec.r  =
                float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorSpec.g  =
                float (((CTX->FrontMaterial ()).SpecularColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorSpec.b  =
                float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
        
        // Ambient color
        MyCStructure.ContextFillArea.Front.ColorAmb.r   =
                float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorAmb.g   =
                float (((CTX->FrontMaterial ()).AmbientColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorAmb.b   =
                float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
        
        // Diffuse color
        MyCStructure.ContextFillArea.Front.ColorDif.r   =
                float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorDif.g   =
                float (((CTX->FrontMaterial ()).DiffuseColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorDif.b   =
                float (((CTX->FrontMaterial ()).DiffuseColor ()).Blue ());
        
        // Emissive color
        MyCStructure.ContextFillArea.Front.ColorEms.r   =
                float (((CTX->FrontMaterial ()).EmissiveColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorEms.g   =
                float (((CTX->FrontMaterial ()).EmissiveColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorEms.b   =
                float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
        
        MyCStructure.ContextFillArea.Front.EnvReflexion = 
                float ((CTX->FrontMaterial ()).EnvReflexion());
        
        MyCStructure.ContextFillArea.IsDef      = 1; // Definition material ok

        Handle(Graphic3d_TextureMap) TempTextureMap = CTX->TextureMap();
        if (! TempTextureMap.IsNull() )
          MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
        else
          MyCStructure.ContextFillArea.Texture.TexId = -1;

        MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1:0;

        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
        Standard_Integer aPolyMode;
        Standard_Real    aPolyFactor, aPolyUnits;
        CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
        MyCStructure.ContextFillArea.PolygonOffsetMode   = aPolyMode;
        MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
        MyCStructure.ContextFillArea.PolygonOffsetUnits  = aPolyUnits;
        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 

        MyGraphicDriver->ContextStructure (MyCStructure);
#ifdef G003
        MyGraphicDriver -> DegenerateStructure (MyCStructure);
#endif

        // CAL 14/04/95
        // Les attributs sont "IsSet" lors de la premiere mise a jour
        // d'un contexte (line, marker...)
        MyCStructure.ContextLine.IsSet          = 1;
        MyCStructure.ContextFillArea.IsSet      = 1;
        MyCStructure.ContextMarker.IsSet        = 1;
        MyCStructure.ContextText.IsSet          = 1;

        Update ();

}

01313 void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX) {

        if (IsDeleted ()) return;

Standard_Real           R, G, B;
Standard_Real           Rs, Gs, Bs;
Graphic3d_NameOfFont    AFont;
Standard_Real           ASpace;
Standard_Real           AnExpansion;
Quantity_Color          AColor;
Aspect_TypeOfStyleText  AStyle;
Aspect_TypeOfDisplayText ADisplayType;
Quantity_Color          AColorSubTitle;
Standard_Boolean        ATexMappedFont;

        CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATexMappedFont);
        AColor.Values (R, G, B, Quantity_TOC_RGB);
        AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);

        MyCStructure.ContextText.Color.r        = float (R);
        MyCStructure.ContextText.Color.g        = float (G);
        MyCStructure.ContextText.Color.b        = float (B);
        MyCStructure.ContextText.Font           = int (AFont);
        MyCStructure.ContextText.Expan          = float (AnExpansion);
        MyCStructure.ContextText.Space          = float (ASpace);
        MyCStructure.ContextText.Style          = int (AStyle);
        MyCStructure.ContextText.DisplayType    = int (ADisplayType);
        MyCStructure.ContextText.ColorSubTitle.r= float (Rs);
        MyCStructure.ContextText.ColorSubTitle.g= float (Gs);
        MyCStructure.ContextText.ColorSubTitle.b= float (Bs);
#if defined(OCC2934) && defined(WNT)
        MyCStructure.ContextText.TextureMappedFont = ATexMappedFont;
#endif
        MyCStructure.ContextText.IsDef          = 1;

        MyGraphicDriver->ContextStructure (MyCStructure);

        // CAL 14/04/95
        // Les attributs sont "IsSet" lors de la premiere mise a jour
        // d'un contexte (line, marker...)
        MyCStructure.ContextLine.IsSet          = 1;
        MyCStructure.ContextFillArea.IsSet      = 1;
        MyCStructure.ContextMarker.IsSet        = 1;
        MyCStructure.ContextText.IsSet          = 1;

        Update ();

}

01362 void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX) {

        if (IsDeleted ()) return;

Standard_Real           R, G, B;
Standard_Real           AScale;
Quantity_Color          AColor;
Aspect_TypeOfMarker     AMType;

        CTX->Values (AColor, AMType, AScale);
        AColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextMarker.Color.r      = float (R);
        MyCStructure.ContextMarker.Color.g      = float (G);
        MyCStructure.ContextMarker.Color.b      = float (B);
        MyCStructure.ContextMarker.MarkerType   = int (AMType);
        MyCStructure.ContextMarker.Scale        = float (AScale);
        MyCStructure.ContextMarker.IsDef        = 1;

        MyGraphicDriver->ContextStructure (MyCStructure);

        // CAL 14/04/95
        // Les attributs sont "IsSet" lors de la premiere mise a jour
        // d'un contexte (line, marker...)
        MyCStructure.ContextLine.IsSet          = 1;
        MyCStructure.ContextFillArea.IsSet      = 1;
        MyCStructure.ContextMarker.IsSet        = 1;
        MyCStructure.ContextText.IsSet          = 1;

        Update ();

}

01395 void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure AVisual) {

        if (IsDeleted ()) return;
        if (MyVisual == AVisual) return;

        if (! MyCStructure.stick) {
                MyVisual        = AVisual;
                SetComputeVisual (AVisual);
        }
        else {

Aspect_TypeOfUpdate UpdateMode  = MyStructureManager->UpdateMode ();
                if (UpdateMode == Aspect_TOU_WAIT) {
                        Erase ();
                        MyVisual        = AVisual;
                        SetComputeVisual (AVisual);
                        Display ();
                }
                else {
                        // Pour eviter d'appeler la methode : Update ()
                        // Inutile et peut-etre couteux.
                        MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
                        Erase ();
                        MyVisual        = AVisual;
                        SetComputeVisual (AVisual);
                        MyStructureManager->SetUpdateMode (UpdateMode);
                        Display ();
                }
        }

}

01427 void Graphic3d_Structure::SetZoomLimit (const Standard_Real LimitInf, const Standard_Real LimitSup) {

        if (LimitInf <= 0.0)
                Graphic3d_StructureDefinitionError::Raise
                        ("Bad value for ZoomLimit inf");

        if (LimitSup <= 0.0)
                Graphic3d_StructureDefinitionError::Raise
                        ("Bad value for ZoomLimit sup");

        if (LimitSup < LimitInf)
                Graphic3d_StructureDefinitionError::Raise
                        ("ZoomLimit sup < ZoomLimit inf");

}

01443 Graphic3d_TypeOfStructure Graphic3d_Structure::Visual () const {

        return (MyVisual);

}

01449 Standard_Boolean Graphic3d_Structure::AcceptConnection (const Handle(Graphic3d_Structure)& AStructure1, const Handle(Graphic3d_Structure)& AStructure2, const Graphic3d_TypeOfConnection AType) {

Graphic3d_MapOfStructure ASet;

        // cycle detection
        Graphic3d_Structure::Network (AStructure2, AType, ASet);

        return (! ASet.Contains (AStructure1));

}

01460 void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure &SG) const {

Standard_Integer i, Length      = MyAncestors.Length ();

        for (i=1; i<=Length; i++)
                SG.Add ((Graphic3d_Structure *) (MyAncestors.Value (i)));


}

void Graphic3d_Structure::SetOwner (const Standard_Address Owner) {

        MyOwner = Owner;

}

Standard_Address Graphic3d_Structure::Owner () const {

        return MyOwner;

}

01482 void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& SG) const {

Standard_Integer i, Length      = MyDescendants.Length ();

        for (i=1; i<=Length; i++)
                SG.Add ((Graphic3d_Structure *) (MyDescendants.Value (i)));

}

01491 void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType, const Standard_Boolean WithCheck) {

        if (IsDeleted ()) return;

        if (WithCheck)
                // cycle detection
                if (! Graphic3d_Structure::AcceptConnection
                        (this, AStructure, AType))
                        return;

        // connection
Standard_Integer i;
        switch (AType) {

            case Graphic3d_TOC_DESCENDANT : {
Standard_Integer indexD = 0;
Standard_Integer LengthD        = MyDescendants.Length ();
                for (i=1; i<=LengthD && indexD==0; i++)
                        if ((void *) (MyDescendants.Value (i)) ==
                            (void *) (AStructure.operator->())) indexD  = i;

                if (indexD == 0) {
                        MyDescendants.Append ((void *) AStructure.operator->());
                        AStructure->Connect (this, Graphic3d_TOC_ANCESTOR);

                        GraphicConnect (AStructure);
                        MyStructureManager->Connect (this, AStructure);

                        Update ();
                }
            }
            break;

            case Graphic3d_TOC_ANCESTOR : {
Standard_Integer indexA = 0;
Standard_Integer LengthA        = MyAncestors.Length ();
                for (i=1; i<=LengthA && indexA==0; i++)
                        if ((void *) (MyAncestors.Value (i)) ==
                            (void *) (AStructure.operator->())) indexA  = i;

                if (indexA == 0) {
                        MyAncestors.Append ((void *) AStructure.operator->());
                        AStructure->Connect (this, Graphic3d_TOC_DESCENDANT);

                        // MyGraphicDriver->Connect est appele dans le cas
                        // d'un connect entre mere et fille
                }
            }
            break;
        }

}

01544 void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& AStructure) {

        if (IsDeleted ()) return;

Standard_Integer i;

Standard_Integer indexD = 0;
Standard_Integer LengthD        = MyDescendants.Length ();
        for (i=1; i<=LengthD && indexD==0; i++)
                if ((void *) (MyDescendants.Value (i)) ==
                    (void *) (AStructure.operator->())) indexD  = i;

        // On cherche dans les Descendants
        if (indexD != 0) {
                MyDescendants.Remove (indexD);
                AStructure->Disconnect (this);

                GraphicDisconnect (AStructure);
                MyStructureManager->Disconnect (this, AStructure);

                Update ();
        }
        else {
Standard_Integer indexA = 0;
Standard_Integer LengthA        = MyAncestors.Length ();
                for (i=1; i<=LengthA && indexA==0; i++)
                        if ((void *) (MyAncestors.Value (i)) ==
                            (void *) (AStructure.operator->())) indexA  = i;

                // On cherche dans les Ancestors
                if (indexA != 0) {
                        MyAncestors.Remove (indexA);
                        AStructure->Disconnect (this);

                        // Pas de call a MyGraphicDriver->Disconnect
                        // dans le cas d'un ancetre
                }
        }

}

01585 void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection AType) {

        if (IsDeleted ()) return;

Standard_Integer i, Length;

        // disconnection
        switch (AType) {
                case Graphic3d_TOC_DESCENDANT :
                    Length      = MyDescendants.Length ();
                    for (i=1; i<=Length; i++)
                        // Value (1) et non Value (i) car MyDescendants
                        // est modifiee par :
                        // Graphic3d_Structure::Disconnect (AStructure)
                        // qui enleve AStructure de MyDescendants
                        ((Graphic3d_Structure *)
                                (MyDescendants.Value (1)))->Disconnect (this);
                break;
                case Graphic3d_TOC_ANCESTOR :
                    Length      = MyAncestors.Length ();
                    for (i=1; i<=Length; i++)
                        // Value (1) et non Value (i) car MyAncestors
                        // est modifiee par :
                        // Graphic3d_Structure::Disconnect (AStructure)
                        // qui enleve AStructure de MyAncestors
                        ((Graphic3d_Structure *)
                                (MyAncestors.Value (1)))->Disconnect (this);
                break;
        }

}

01617 Graphic3d_TypeOfComposition Graphic3d_Structure::Composition () const {

        if (MyCStructure.Composition)
                return (Graphic3d_TOC_POSTCONCATENATE);
        else
                return (Graphic3d_TOC_REPLACE);

}

01626 void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType) {

        if (IsDeleted ()) return;

Standard_Integer lr, ur, lc, uc;
Standard_Real valuetrsf;
Standard_Real valueoldtrsf;
Standard_Real valuenewtrsf;
Standard_Integer i, j, k;
TColStd_Array2OfReal TheTrsf (0, 3, 0, 3);
TColStd_Array2OfReal NewTrsf (0, 3, 0, 3);
TColStd_Array2OfReal AMatrix44 (0, 3, 0, 3);

        // Assign the new transformation in an array [0..3][0..3]
        // Evite des problemes si le user a defini sa matrice [1..4][1..4]
        //                                                 ou [3..6][-1..2] !!
        lr      = AMatrix.LowerRow ();
        ur      = AMatrix.UpperRow ();
        lc      = AMatrix.LowerCol ();
        uc      = AMatrix.UpperCol ();

        if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
                Graphic3d_TransformError::Raise
                        ("Transform : not a 4x4 matrix");

        if (AType == Graphic3d_TOC_REPLACE) {
                MyCStructure.Composition = 0;
                // La mise a jour de la CStructure
                for (i=0; i<=3; i++)
                    for (j=0; j<=3; j++) {
                        MyCStructure.Transformation[i][j] =
                                float (AMatrix (lr + i, lc + j));
                        NewTrsf (i, j) = AMatrix (lr + i, lc + j);
                    }
        }

        if (AType == Graphic3d_TOC_POSTCONCATENATE) {
                MyCStructure.Composition = 1;
                // Pour simplifier la gestion des indices
                for (i=0; i<=3; i++)
                    for (j=0; j<=3; j++)
                        AMatrix44 (i, j) = AMatrix (lr + i, lc + j);
                // Le calcul de produit de matrices
                for (i=0; i<=3; i++)
                    for (j=0; j<=3; j++) {
                        NewTrsf (i, j) = 0.0;
                        for (k=0; k<=3; k++) {
                            valueoldtrsf = MyCStructure.Transformation[i][k];
                            valuetrsf    = AMatrix44 (k, j);
                            valuenewtrsf = NewTrsf (i, j) +
                                          valueoldtrsf * valuetrsf;
                            NewTrsf (i, j) = valuenewtrsf;
                        }
                   }
                // La mise a jour de la CStructure
                for (i=0; i<=3; i++)
                    for (j=0; j<=3; j++)
                        MyCStructure.Transformation[i][j] = float (NewTrsf (i, j));
        }

        // Si transformation, non validation des parties cachees deja calculees.
        if (IsRotated ())
                ReCompute ();

        GraphicTransform (NewTrsf);
        MyStructureManager->SetTransform (this, NewTrsf);

        Update ();

}

01697 void Graphic3d_Structure::Transform (TColStd_Array2OfReal& AMatrix) const {

        Standard_Integer lr     = AMatrix.LowerRow ();
        Standard_Integer ur     = AMatrix.UpperRow ();
        Standard_Integer lc     = AMatrix.LowerCol ();
        Standard_Integer uc     = AMatrix.UpperCol ();

        if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
                Graphic3d_TransformError::Raise
                        ("Transform : not a 4x4 matrix");

        for (Standard_Integer i=0; i<=3; i++)
            for (Standard_Integer j=0; j<=3; j++)
                AMatrix (lr + i, lc + j) = MyCStructure.Transformation[i][j];

}

01714 void Graphic3d_Structure::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {

Standard_Real RL        = RealLast ();
Standard_Real RF        = RealFirst ();

Standard_Real XTMin, YTMin, ZTMin, XTMax, YTMax, ZTMax, U, V, W;

        if (IsEmpty () || IsInfinite ()) {
                XMin    = RF;
                YMin    = RF;
                ZMin    = RF;

                XMax    = RL;
                YMax    = RL;
                ZMax    = RL;
        }
        else {
                MinMaxCoord (XTMin, YTMin, ZTMin, XTMax, YTMax, ZTMax);
                if ((XTMin == RF) && (YTMin == RF) &&
                    (ZTMin == RF) && (XTMax == RL) &&
                    (YTMax == RL) && (ZTMax == RL)) {
                        // Cas impossible car cela voudrait dire
                        // que la structure est vide
                        XMin    = RF;
                        YMin    = RF;
                        ZMin    = RF;

                        XMax    = RL;
                        YMax    = RL;
                        ZMax    = RL;
                }
                else {
Standard_Integer i, j;
TColStd_Array2OfReal TheTrsf (0, 3, 0, 3);

                    for (i=0; i<=3; i++)
                        for (j=0; j<=3; j++)
                            TheTrsf (i, j) = MyCStructure.Transformation[i][j];

                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMin, YTMin, ZTMin, XMin, YMin, ZMin);
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMax, YTMax, ZTMax, XMax, YMax, ZMax);
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMin, YTMin, ZTMax, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMax, YTMin, ZTMax, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMax, YTMin, ZTMin, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMax, YTMax, ZTMin, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMin, YTMax, ZTMax, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                    Graphic3d_Structure::Transforms
                        (TheTrsf, XTMin, YTMax, ZTMin, U, V, W);
                    XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
                    YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
                    ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
                }

        }

}

01793 void Graphic3d_Structure::GroupLabels (Standard_Integer& LB, Standard_Integer& LE) {

        LB      = MyGroupGenId.Next ();
        LE      = MyGroupGenId.Next ();

}

01800 Standard_Integer Graphic3d_Structure::Identification () const {

Standard_Integer Result = MyCStructure.Id;

        return Result;

}

void Graphic3d_Structure::SetTransformPersistence( const Graphic3d_TransModeFlags& AFlag )
{
  SetTransformPersistence( AFlag, gp_Pnt( 0, 0, 0 ) );
}

01813 void Graphic3d_Structure::SetTransformPersistence( const Graphic3d_TransModeFlags& AFlag,
                                       const gp_Pnt& APoint )
{
      if (IsDeleted ()) return;     
      
      MyCStructure.TransformPersistence.Flag = AFlag;
        MyCStructure.TransformPersistence.Point.x = APoint.X();
      MyCStructure.TransformPersistence.Point.y = APoint.Y();
      MyCStructure.TransformPersistence.Point.z = APoint.Z();
        //MyStructureManager->Update ();
      //Update();
        MyGraphicDriver->ContextStructure( MyCStructure );

        MyCStructure.TransformPersistence.IsSet = 1;
}

01829 Graphic3d_TransModeFlags Graphic3d_Structure::TransformPersistenceMode() const
{
      return MyCStructure.TransformPersistence.Flag;
}

01834 gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
{
        gp_Pnt aPnt( 0., 0., 0. );
      aPnt.SetX( MyCStructure.TransformPersistence.Point.x );
      aPnt.SetY( MyCStructure.TransformPersistence.Point.y );
      aPnt.SetZ( MyCStructure.TransformPersistence.Point.z );

      return aPnt;
}

01844 void Graphic3d_Structure::Add (const Handle(Graphic3d_Group)& AGroup) {

        // Methode appelee que par le constructeur de Graphic3d_Group
        // Ce n'est pas la peine de tester l'existence de <AGroup>
        // dans la sequence MyGroups.
        MyGroups.Append (AGroup);

}

01853 void Graphic3d_Structure::Remove (const Standard_Address APtr, const Graphic3d_TypeOfConnection AType) {

Standard_Integer i, index, length;

        switch (AType) {
                case Graphic3d_TOC_DESCENDANT :
                        index   = 0;
                        length  = MyDescendants.Length ();
                        for (i=1; i<=length && index==0; i++)
                                if ((void *) (MyDescendants.Value (i)) == APtr)
                                        index   = i;
                        if (index != 0)
                                MyDescendants.Remove (index);
#ifdef TRACE
                        else
                                cout << "Error, Graphic3d_Structure::Remove\n";
#endif
                break;

                case Graphic3d_TOC_ANCESTOR :
                        index   = 0;
                        length  = MyAncestors.Length ();
                        for (i=1; i<=length && index==0; i++)
                                if ((void *) (MyAncestors.Value (i)) == APtr)
                                        index   = i;
                        if (index != 0)
                                MyAncestors.Remove (index);
#ifdef TRACE
                        else
                                cout << "Error, Graphic3d_Structure::Remove\n";
#endif
                break;
        }

}

01889 void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& AGroup) {

Standard_Integer index = 0;
Standard_Integer Length = MyGroups.Length ();
        for (Standard_Integer i=1; i<=Length && index==0; i++)
                if (MyGroups.Value (i) == AGroup) index = i;

        // On cherche dans les Groups
        if (index != 0) {
Standard_Integer GroupLabelBegin, GroupLabelEnd;
                AGroup->Labels (GroupLabelBegin, GroupLabelEnd);
                MyGroupGenId.Free (GroupLabelBegin);
                MyGroupGenId.Free (GroupLabelEnd);
                MyGroups.Remove (index);
        }

}

Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager () const {

#ifdef DOWNCAST
        return
        (Handle(Graphic3d_StructureManager)::DownCast(Handle(Standard_Transient)
                ((Standard_Transient*) MyPtrStructureManager)));
#else
        return MyStructureManager;
#endif

}

01919 Graphic3d_TypeOfPrimitive Graphic3d_Structure::Type (const Standard_Integer ElementNumber) const {

        if (IsDeleted ()) return (Graphic3d_TOP_UNDEFINED);

Graphic3d_TypeOfPrimitive Result;

        Result  = MyGraphicDriver->ElementType
                        (MyCStructure, ElementNumber);

        return (Result);

}

01932 Standard_Boolean Graphic3d_Structure::Exploration (const Standard_Integer ElementNumber, Graphic3d_VertexNC& AVertex, Graphic3d_Vector& AVector) const {

Standard_Boolean Result = Standard_False;

        if (IsDeleted ()) return (Result);

        Result  = MyGraphicDriver->ElementExploration
                        (MyCStructure, ElementNumber, AVertex, AVector);

        return (Result);

}

01945 void Graphic3d_Structure::Exploration () const {

        if (IsDeleted ()) return;

        MyGraphicDriver->DumpStructure (MyCStructure);

}

01953 void Graphic3d_Structure::MinMaxCoord (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {

Standard_Real RL        = RealLast ();
Standard_Real RF        = RealFirst ();

Standard_Real Xm, Ym, Zm, XM, YM, ZM;

        if (IsEmpty () || IsInfinite ()) {
                XMin    = RF;
                YMin    = RF;
                ZMin    = RF;

                XMax    = RL;
                YMax    = RL;
                ZMax    = RL;
        }
        else {
                XMin    = RL;
                YMin    = RL;
                ZMin    = RL;

                XMax    = RF;
                YMax    = RF;
                ZMax    = RF;

Standard_Integer i, Length;

                Length  = MyGroups.Length ();
                for (i=1; i<=Length; i++)
                        if (! (MyGroups.Value (i))->IsEmpty () ) {
                                (MyGroups.Value (i))->MinMaxValues
                                                (Xm, Ym, Zm, XM, YM, ZM);

                                if (Xm < XMin) XMin     = Xm;
                                if (Ym < YMin) YMin     = Ym;
                                if (Zm < ZMin) ZMin     = Zm;
                                if (XM > XMax) XMax     = XM;
                                if (YM > YMax) YMax     = YM;
                                if (ZM > ZMax) ZMax     = ZM;
                        }

                Length  = MyDescendants.Length ();
                for (i=1; i<=Length; i++)
                    if (! ((Graphic3d_Structure *)
                        (MyDescendants.Value (i)))->IsEmpty () ) {
                        ((Graphic3d_Structure *)
                                (MyDescendants.Value (i)))->MinMaxValues
                                        (Xm, Ym, Zm, XM, YM, ZM);

                                if (Xm < XMin) XMin     = Xm;
                                if (Ym < YMin) YMin     = Ym;
                                if (Zm < ZMin) ZMin     = Zm;
                                if (XM > XMax) XMax     = XM;
                                if (YM > YMax) YMax     = YM;
                                if (ZM > ZMax) ZMax     = ZM;
                        }

                if ((XMin == RL) && (YMin == RL) &&
                    (ZMin == RL) && (XMax == RF) &&
                    (YMax == RF) && (ZMax == RF)) {
                        // Cas impossible car cela voudrait dire
                        // que la structure est vide
                        XMin    = RF;
                        YMin    = RF;
                        ZMin    = RF;

                        XMax    = RL;
                        YMax    = RL;
                        ZMax    = RL;
                }

        }

}

02028 void Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& NewX, Standard_Real& NewY, Standard_Real& NewZ) {

Standard_Real A, B, C, D;

Standard_Real RL        = RealLast ();
Standard_Real RF        = RealFirst ();

        if ((X == RF) || (Y == RF) || (Z == RF) ||
            (X == RL) || (Y == RL) || (Z == RL)) {
                NewX    = X;
                NewY    = Y;
                NewZ    = Z;
        }
        else {
                A       = ATrsf (0, 0);
                B       = ATrsf (0, 1);
                C       = ATrsf (0, 2);
                D       = ATrsf (0, 3);
                NewX    = A * X + B * Y + C * Z + D;
                A       = ATrsf (1, 0);
                B       = ATrsf (1, 1);
                C       = ATrsf (1, 2);
                D       = ATrsf (1, 3);
                NewY    = A * X + B * Y + C * Z + D;
                A       = ATrsf (2, 0);
                B       = ATrsf (2, 1);
                C       = ATrsf (2, 2);
                D       = ATrsf (2, 3);
                NewZ    = A * X + B * Y + C * Z + D;
        }

}

02061 Graphic3d_Vector Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vector& Coord) {

Standard_Real NewX, NewY, NewZ;
Graphic3d_Vector Result;

        Graphic3d_Structure::Transforms
        (ATrsf, Coord.X (), Coord.Y (), Coord.Z (), NewX, NewY, NewZ);
        Result.SetCoord (NewX, NewY, NewZ);

        return (Result);

}

02074 Graphic3d_Vertex Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord) {

Standard_Real NewX, NewY, NewZ;
Graphic3d_Vertex Result;

        Graphic3d_Structure::Transforms
        (ATrsf, Coord.X (), Coord.Y (), Coord.Z (), NewX, NewY, NewZ);
        Result.SetCoord (NewX, NewY, NewZ);

        return (Result);

}

02087 void Graphic3d_Structure::Network (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType, Graphic3d_MapOfStructure& ASet) {


  Graphic3d_MapOfStructure h1;
  Graphic3d_MapOfStructure h2;
  AStructure->Descendants (h1);
  AStructure->Ancestors (h2);

  Graphic3d_MapIteratorOfMapOfStructure IteratorD (h1);
  Graphic3d_MapIteratorOfMapOfStructure IteratorA (h2);

        ASet.Add (AStructure);

        // exploration
        switch (AType) {

                case Graphic3d_TOC_DESCENDANT :
                        while (IteratorD.More ()) {
                                Graphic3d_Structure::Network
        (IteratorD.Key (), AType, ASet);
                                // IteratorD.Next () se positionne
                                // sur la prochaine structure
                                IteratorD.Next ();
                        }
                break;

                case Graphic3d_TOC_ANCESTOR :
                        while (IteratorA.More ()) {
                                Graphic3d_Structure::Network
        (IteratorA.Key (), AType, ASet);
                                // IteratorA.Next () se positionne
                                // sur la prochaine structure
                                IteratorA.Next ();
                        }
                break;

        }

}

02127 void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType) {

Graphic3d_MapOfStructure ASet;

Graphic3d_MapIteratorOfMapOfStructure IteratorASet (ASet);

        Graphic3d_Structure::Network (AStructure, AType, ASet);

        while (IteratorASet.More ()) {
                cout << "\tIdent "
                        << (IteratorASet.Key ())->Identification () << "\n";
                IteratorASet.Next ();
        }
        cout << flush;

}

02144 void Graphic3d_Structure::Update () const {

        if (IsDeleted ()) return;

        if (MyStructureManager->UpdateMode () == Aspect_TOU_ASAP)
                MyStructureManager->Update ();

}

02153 void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) {

Standard_Real           R, G, B;
Standard_Real           Rs, Gs, Bs;
Graphic3d_NameOfFont    AFont;
Standard_Real           ASpace;
Standard_Real           AnExpansion;
Standard_Real           AWidth;
Standard_Real           AScale;
Quantity_Color          AColor;
Quantity_Color          AnIntColor;
Quantity_Color          BackIntColor;
Quantity_Color          AnEdgeColor;
Aspect_TypeOfLine       ALType;
Aspect_TypeOfMarker     AMType;
Aspect_InteriorStyle    AStyle;
Aspect_TypeOfStyleText  AStyleT;
Aspect_TypeOfDisplayText ADisplayType;
Quantity_Color          AColorSubTitle;
Standard_Boolean        ATexMappedFont;

        CTXL->Values (AColor, ALType, AWidth);
        AColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextLine.Color.r        = float (R);
        MyCStructure.ContextLine.Color.g        = float (G);
        MyCStructure.ContextLine.Color.b        = float (B);
        MyCStructure.ContextLine.LineType       = int (ALType);
        MyCStructure.ContextLine.Width          = float (AWidth);

        CTXM->Values (AColor, AMType, AScale);
        AColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextMarker.Color.r      = float (R);
        MyCStructure.ContextMarker.Color.g      = float (G);
        MyCStructure.ContextMarker.Color.b      = float (B);
        MyCStructure.ContextMarker.MarkerType   = int (AMType);
        MyCStructure.ContextMarker.Scale        = float (AScale);

        CTXT->Values (AColor, AFont, AnExpansion, ASpace,AStyleT,ADisplayType,AColorSubTitle,ATexMappedFont);
        AColor.Values (R, G, B, Quantity_TOC_RGB);
        AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);

        MyCStructure.ContextText.Color.r        = float (R);
        MyCStructure.ContextText.Color.g        = float (G);
        MyCStructure.ContextText.Color.b        = float (B);
        MyCStructure.ContextText.Font           = int (AFont);
        MyCStructure.ContextText.Expan          = float (AnExpansion);
        MyCStructure.ContextText.Style          = int (AStyleT);
        MyCStructure.ContextText.DisplayType    = int (ADisplayType);
        MyCStructure.ContextText.Space          = float (ASpace);
        MyCStructure.ContextText.ColorSubTitle.r= float (Rs);
        MyCStructure.ContextText.ColorSubTitle.g= float (Gs);
        MyCStructure.ContextText.ColorSubTitle.b= float (Bs);
#if defined(OCC2934) && defined(WNT)
        MyCStructure.ContextText.TextureMappedFont = ATexMappedFont;
#endif

        CTXF->Values (AStyle, AnIntColor, BackIntColor, AnEdgeColor, ALType, AWidth);
        AnIntColor.Values (R, G, B, Quantity_TOC_RGB);

        MyCStructure.ContextFillArea.Style      = int (AStyle);
        MyCStructure.ContextFillArea.IntColor.r = float (R);
        MyCStructure.ContextFillArea.IntColor.g = float (G);
        MyCStructure.ContextFillArea.IntColor.b = float (B);
#ifdef OCC1174
        if ( CTXF->Distinguish() )
          BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
#endif
        MyCStructure.ContextFillArea.BackIntColor.r     = float( R );
        MyCStructure.ContextFillArea.BackIntColor.g     = float( G );
        MyCStructure.ContextFillArea.BackIntColor.b     = float( B );

        // Edges
        MyCStructure.ContextFillArea.Edge       = CTXF->Edge () ? 1:0;
        AnEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
        MyCStructure.ContextFillArea.EdgeColor.r        = float (R);
        MyCStructure.ContextFillArea.EdgeColor.g        = float (G);
        MyCStructure.ContextFillArea.EdgeColor.b        = float (B);
        MyCStructure.ContextFillArea.LineType           = int (ALType);
        MyCStructure.ContextFillArea.Width              = float (AWidth);
        MyCStructure.ContextFillArea.Hatch              = int (CTXF->HatchStyle ());
#ifdef G003
        Quantity_Ratio ratio;
        MyCStructure.ContextFillArea.DegenerationMode = 
                                        int (CTXF->DegenerateModel(ratio));
        MyCStructure.ContextFillArea.SkipRatio = float (ratio);
#endif  // G003


        /*** Front and Back face ***/
        MyCStructure.ContextFillArea.Distinguish = CTXF->Distinguish () ? 1:0;
        MyCStructure.ContextFillArea.BackFace    = CTXF->BackFace () ? 1:0;
        /*** Back Material ***/
        // Light specificity
        MyCStructure.ContextFillArea.Back.Shininess     =
                float ((CTXF->BackMaterial ()).Shininess ());
        MyCStructure.ContextFillArea.Back.Ambient       =
                float ((CTXF->BackMaterial ()).Ambient ());
        MyCStructure.ContextFillArea.Back.Diffuse       =
                float ((CTXF->BackMaterial ()).Diffuse ());
        MyCStructure.ContextFillArea.Back.Specular      =
                float ((CTXF->BackMaterial ()).Specular ());
        MyCStructure.ContextFillArea.Back.Transparency  =
                float ((CTXF->BackMaterial ()).Transparency ());
        MyCStructure.ContextFillArea.Back.Emission      =
                float ((CTXF->BackMaterial ()).Emissive ());
        
        // Reflection mode
        MyCStructure.ContextFillArea.Back.IsAmbient     =
                ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsDiffuse     =
                ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsSpecular    =
                ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
        MyCStructure.ContextFillArea.Back.IsEmission    =
                ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
        
        // Material type
//JR/Hp
        const Graphic3d_MaterialAspect ama = CTXF->BackMaterial () ;
        Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
        MyCStructure.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
//      MyCStructure.ContextFillArea.Back.IsPhysic      =
//        ( (CTXF->BackMaterial ()).MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0 );
        
        // Material color
        //MyCStructure.ContextFillArea.Back.Color.r     =
        //float (((CTXF->BackMaterial ()).Color ()).Red ());
        //MyCStructure.ContextFillArea.Back.Color.g     =
        //float (((CTXF->BackMaterial ()).Color ()).Green ());
        //MyCStructure.ContextFillArea.Back.Color.b     =
        //float (((CTXF->BackMaterial ()).Color ()).Blue ());
        
        // Specular color
        MyCStructure.ContextFillArea.Back.ColorSpec.r   =
                float (((CTXF->BackMaterial ()).SpecularColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorSpec.g   =
                float (((CTXF->BackMaterial ()).SpecularColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorSpec.b   =
                float (((CTXF->BackMaterial ()).SpecularColor ()).Blue ());
        
        // Ambient color
        MyCStructure.ContextFillArea.Back.ColorAmb.r    =
                float (((CTXF->BackMaterial ()).AmbientColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorAmb.g    =
                float (((CTXF->BackMaterial ()).AmbientColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorAmb.b    =
                float (((CTXF->BackMaterial ()).AmbientColor ()).Blue ());
        
        // Diffuse color
        MyCStructure.ContextFillArea.Back.ColorDif.r    =
                float (((CTXF->BackMaterial ()).DiffuseColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorDif.g    =
                float (((CTXF->BackMaterial ()).DiffuseColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorDif.b    =
                float (((CTXF->BackMaterial ()).DiffuseColor ()).Blue ());
        
        // Emissive color
        MyCStructure.ContextFillArea.Back.ColorEms.r    =
                float (((CTXF->BackMaterial ()).EmissiveColor ()).Red ());
        MyCStructure.ContextFillArea.Back.ColorEms.g    =
                float (((CTXF->BackMaterial ()).EmissiveColor ()).Green ());
        MyCStructure.ContextFillArea.Back.ColorEms.b    =
                float (((CTXF->BackMaterial ()).EmissiveColor ()).Blue ());
        
        MyCStructure.ContextFillArea.Back.EnvReflexion = 
                float ((CTXF->BackMaterial ()).EnvReflexion());
        
        /*** Front Material ***/
        // Light specificity
        MyCStructure.ContextFillArea.Front.Shininess    =
                float ((CTXF->FrontMaterial ()).Shininess ());
        MyCStructure.ContextFillArea.Front.Ambient      =
                float ((CTXF->FrontMaterial ()).Ambient ());
        MyCStructure.ContextFillArea.Front.Diffuse      =
                float ((CTXF->FrontMaterial ()).Diffuse ());
        MyCStructure.ContextFillArea.Front.Specular     =
                float ((CTXF->FrontMaterial ()).Specular ());
        MyCStructure.ContextFillArea.Front.Transparency =
                float ((CTXF->FrontMaterial ()).Transparency ());
        MyCStructure.ContextFillArea.Front.Emission     =
                float ((CTXF->FrontMaterial ()).Emissive ());
        
        // Reflection mode
        MyCStructure.ContextFillArea.Front.IsAmbient    =
                ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsDiffuse    =
                ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsSpecular   =
                ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
        MyCStructure.ContextFillArea.Front.IsEmission   =
                ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
        
        // Material type
//JR/Hp
        const Graphic3d_MaterialAspect amas = CTXF->FrontMaterial () ;
        Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
        MyCStructure.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
//      MyCStructure.ContextFillArea.Front.IsPhysic     =
//              ( (CTXF->FrontMaterial ()).MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0 );
        
        // Material color
        //MyCStructure.ContextFillArea.Front.Color.r    =
        //float (((CTXF->FrontMaterial ()).Color ()).Red ());
        //MyCStructure.ContextFillArea.Front.Color.g    =
        //float (((CTXF->FrontMaterial ()).Color ()).Green ());
        //MyCStructure.ContextFillArea.Front.Color.b    =
        //float (((CTXF->FrontMaterial ()).Color ()).Blue ());
        
        // Specular color
        MyCStructure.ContextFillArea.Front.ColorSpec.r  =
                float (((CTXF->FrontMaterial ()).SpecularColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorSpec.g  =
                float (((CTXF->FrontMaterial ()).SpecularColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorSpec.b  =
                float (((CTXF->FrontMaterial ()).SpecularColor ()).Blue ());
        
        // Ambient color
        MyCStructure.ContextFillArea.Front.ColorAmb.r   =
                float (((CTXF->FrontMaterial ()).AmbientColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorAmb.g   =
                float (((CTXF->FrontMaterial ()).AmbientColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorAmb.b   =
                float (((CTXF->FrontMaterial ()).AmbientColor ()).Blue ());
        
        // Diffuse color
        MyCStructure.ContextFillArea.Front.ColorDif.r   =
                float (((CTXF->FrontMaterial ()).DiffuseColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorDif.g   =
                float (((CTXF->FrontMaterial ()).DiffuseColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorDif.b   =
                float (((CTXF->FrontMaterial ()).DiffuseColor ()).Blue ());
        
        // Emissive color
        MyCStructure.ContextFillArea.Front.ColorEms.r   =
                float (((CTXF->FrontMaterial ()).EmissiveColor ()).Red ());
        MyCStructure.ContextFillArea.Front.ColorEms.g   =
                float (((CTXF->FrontMaterial ()).EmissiveColor ()).Green ());
        MyCStructure.ContextFillArea.Front.ColorEms.b   =
                float (((CTXF->FrontMaterial ()).EmissiveColor ()).Blue ());
        
        MyCStructure.ContextFillArea.Front.EnvReflexion = 
                float ((CTXF->FrontMaterial ()).EnvReflexion());

        Handle(Graphic3d_TextureMap) TempTextureMap = CTXF->TextureMap();
        if (! TempTextureMap.IsNull() )
          MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
        else
          MyCStructure.ContextFillArea.Texture.TexId = -1;

        MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1:0;

        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
        Standard_Integer aPolyMode;
        Standard_Real    aPolyFactor, aPolyUnits;
        CTXF->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
        MyCStructure.ContextFillArea.PolygonOffsetMode   = aPolyMode;
        MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
        MyCStructure.ContextFillArea.PolygonOffsetUnits  = aPolyUnits;
        // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
}

02416 void Graphic3d_Structure::GraphicHighlight (const Aspect_TypeOfHighlightMethod AMethod) {

Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
Standard_Real R, G, B;

        MyCStructure.highlight  = 1;
        MyHighlightMethod       = AMethod;

        switch (AMethod) {
                case Aspect_TOHM_COLOR :
                        MyHighlightColor.Values (R, G, B, Quantity_TOC_RGB);
                        MyGraphicDriver->HighlightColor
                                (MyCStructure, float (R), float (G),
                                 float (B) , Standard_True);
                        MyGraphicDriver->NameSetStructure (MyCStructure);
                break;
                case Aspect_TOHM_BLINK :
                        MyGraphicDriver->Blink (MyCStructure, Standard_True);
                        MyGraphicDriver->NameSetStructure (MyCStructure);
                break;
                case Aspect_TOHM_BOUNDBOX :
                        if (IsEmpty () || IsInfinite ()) {
                                // Structure vide ou infinie
                                XMin = YMin = ZMin = 0.;
                                XMax = YMax = ZMax = 0.;
                        }
                        else {
                                MinMaxCoord
                                        (XMin, YMin, ZMin, XMax, YMax, ZMax);
                        }
                        MyCStructure.BoundBox.Pmin.x    = float (XMin);
                        MyCStructure.BoundBox.Pmin.y    = float (YMin);
                        MyCStructure.BoundBox.Pmin.z    = float (ZMin);
                        MyCStructure.BoundBox.Pmax.x    = float (XMax);
                        MyCStructure.BoundBox.Pmax.y    = float (YMax);
                        MyCStructure.BoundBox.Pmax.z    = float (ZMax);
                        MyHighlightColor.Values (R, G, B, Quantity_TOC_RGB);
                        MyCStructure.BoundBox.Color.r   = float (R);
                        MyCStructure.BoundBox.Color.g   = float (G);
                        MyCStructure.BoundBox.Color.b   = float (B);
                        MyGraphicDriver->BoundaryBox
                                (MyCStructure, Standard_True);
                break;
        }

}

void Graphic3d_Structure::GraphicTransform (const TColStd_Array2OfReal& AMatrix) {

Standard_Integer i, j;

        for (i=0; i<=3; i++)
            for (j=0; j<=3; j++)
                MyCStructure.Transformation[i][j] = float (AMatrix (i, j));

        MyGraphicDriver->TransformStructure (MyCStructure);

}

02475 void Graphic3d_Structure::GraphicUnHighlight () {

        MyCStructure.highlight  = 0;

        switch (MyHighlightMethod) {
                case Aspect_TOHM_COLOR :
                        MyGraphicDriver->HighlightColor
                                (MyCStructure, 0.0, 0.0, 0.0 , Standard_False);
                        MyGraphicDriver->NameSetStructure (MyCStructure);
                break;
                case Aspect_TOHM_BLINK :
                        MyGraphicDriver->Blink (MyCStructure, Standard_False);
                        MyGraphicDriver->NameSetStructure (MyCStructure);
                break;
                case Aspect_TOHM_BOUNDBOX :
                        MyGraphicDriver->BoundaryBox
                                (MyCStructure, Standard_False);
                        MyGraphicDriver->NameSetStructure (MyCStructure);
                break;
        }

}

Graphic3d_TypeOfStructure Graphic3d_Structure::ComputeVisual () const {

        return (MyComputeVisual);

}

void Graphic3d_Structure::SetComputeVisual (const Graphic3d_TypeOfStructure AVisual) {

        // On ne memorise le ComputeVisual que lorsque la structure est
        // declaree TOS_ALL, TOS_WIREFRAME ou TOS_SHADING.
        // C'est cette declaration qui va nous permettre de calculer
        // la bonne representation de la structure calculee par Compute
        // et non pas le passage en TOS_COMPUTED.
        if (AVisual != Graphic3d_TOS_COMPUTED)
                MyComputeVisual = AVisual;

}

void Graphic3d_Structure::Plot (const Handle(Graphic3d_Plotter)& ) {

}

02520 void Graphic3d_Structure::SetManager (const Handle(Graphic3d_StructureManager)& AManager, const Standard_Boolean WithPropagation) {

        // Toutes les structures connectees doivent suivre ?
#ifdef IMPLEMENTED
        if (WithPropagation) {
Standard_Integer i, Length;
                Length  = MyDescendants.Length ();
                for (i=1; i<=Length; i++)
                    ((Graphic3d_Structure *)
                    (MyDescendants.Value (i)))->SetStructureManager (AManager);

                Length  = MyAncestors.Length ();
                for (i=1; i<=Length; i++)
                    ((Graphic3d_Structure *)
                    (MyAncestors.Value (i)))->SetStructureManager (AManager);
        }
#endif

        // changement d'identification ?
        // MyStructureManager->Remove (Standard_Integer (MyCStructure.Id));
        // AManager->NewIdentification ();
        // MyCStructure.Id      = int (AManager->NewIdentification ());

Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
Aspect_TypeOfUpdate NewUpdateMode = AManager->UpdateMode ();
        MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
        AManager->SetUpdateMode (Aspect_TOU_WAIT);

        if (MyCStructure.stick) {
                MyStructureManager->Erase (this);
                AManager->Display (this);
        }

        if (MyCStructure.highlight) {
        }

        if (MyCStructure.visible) {
                MyStructureManager->Invisible (this);
                AManager->Visible (this);
        }

        if (MyCStructure.pick) {
                MyStructureManager->Undetectable (this);
                AManager->Detectable (this);
        }

        MyStructureManager->SetUpdateMode (UpdateMode);
        AManager->SetUpdateMode (NewUpdateMode);

        // Nouveau manager
        MyPtrStructureManager   = (void *) AManager.operator->();

}

void Graphic3d_Structure::SetHLRValidation (const Standard_Boolean AFlag) {

        MyCStructure.HLRValidation      = AFlag ? 1:0;

}

Standard_Boolean Graphic3d_Structure::HLRValidation () const {

        // Les parties cachees stockees dans <me> sont valides si :
        // 1/ le proprietaire est defini.
        // 2/ elles n'ont pas ete invalidees.

Standard_Boolean Result = MyOwner != NULL && MyCStructure.HLRValidation != 0;

        return Result;

}

02592 Standard_Address Graphic3d_Structure::CStructure () const {

        return Standard_Address (&MyCStructure);

}

Generated by  Doxygen 1.6.0   Back to index