0027670: Visualization - avoid duplication of structures defining primitive array...
[occt.git] / src / Graphic3d / Graphic3d_Group.cxx
index c4d99e1..26aa68c 100644 (file)
@@ -63,17 +63,7 @@ Graphic3d_Group::Graphic3d_Group (const Handle(Graphic3d_Structure)& theStruct)
 
   myStructure = theStruct.operator->();
 
-  MyContainsFacet = Standard_False,
-
-  ContextLine.IsDef     = 0;
-  ContextText.IsDef     = 0;
-  ContextMarker.IsDef   = 0;
-  ContextFillArea.IsDef = 0;
-
-  ContextLine.IsSet     = 0;
-  ContextText.IsSet     = 0;
-  ContextMarker.IsSet   = 0;
-  ContextFillArea.IsSet = 0;
+  MyContainsFacet = Standard_False;
 }
 
 // =======================================================================
@@ -87,16 +77,6 @@ void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
     return;
   }
 
-  ContextLine.IsSet     = 0,
-  ContextText.IsSet     = 0,
-  ContextMarker.IsSet   = 0,
-  ContextFillArea.IsSet = 0;
-
-  ContextLine.IsDef     = 0,
-  ContextText.IsDef     = 0,
-  ContextMarker.IsDef   = 0,
-  ContextFillArea.IsDef = 0;
-
   myBounds.Clear();
 
   if (MyContainsFacet)
@@ -264,536 +244,6 @@ void Graphic3d_Group::Update() const
   myStructure->StructureManager()->Update (myStructure->StructureManager()->UpdateMode());
 }
 
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real aWidth;
-  Quantity_Color aColor;
-  Aspect_TypeOfLine aLType;
-  theAspLine->Values (aColor, aLType, aWidth);
-
-  ContextLine.IsDef         = 1;
-  ContextLine.Color.r       = float (aColor.Red());
-  ContextLine.Color.g       = float (aColor.Green());
-  ContextLine.Color.b       = float (aColor.Blue());
-  ContextLine.LineType      = aLType;
-  ContextLine.Width         = float (aWidth);
-  ContextLine.ShaderProgram = theAspLine->ShaderProgram();
-
-  UpdateAspectLine (Standard_True);
-
-  ContextLine.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real        anRGB[3];
-  Standard_Real        aWidth;
-  Quantity_Color       anIntColor;
-  Quantity_Color       aBackIntColor;
-  Quantity_Color       anEdgeColor;
-  Aspect_TypeOfLine    aLType;
-  Aspect_InteriorStyle aStyle;
-  theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
-
-  anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
-  ContextFillArea.Style      = aStyle;
-  ContextFillArea.IntColor.r = float (anRGB[0]);
-  ContextFillArea.IntColor.g = float (anRGB[1]);
-  ContextFillArea.IntColor.b = float (anRGB[2]);
-
-  if (theAspFill->Distinguish())
-  {
-    aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
-  }
-  ContextFillArea.BackIntColor.r = float (anRGB[0]);
-  ContextFillArea.BackIntColor.g = float (anRGB[1]);
-  ContextFillArea.BackIntColor.b = float (anRGB[2]);
-
-  // Edges
-  ContextFillArea.Edge        = theAspFill->Edge() ? 1 : 0;
-  ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
-  ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
-  ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
-  ContextFillArea.LineType    = aLType;
-  ContextFillArea.Width       = float (aWidth);
-  ContextFillArea.Hatch       = theAspFill->HatchStyle();
-
-  // Front and Back face
-  ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
-  ContextFillArea.BackFace    = theAspFill->BackFace()    ? 1 : 0;
-
-  // Back Material
-  const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
-
-  // Material properties
-  ContextFillArea.Back.Shininess       = float (aBack.Shininess());
-  ContextFillArea.Back.Ambient         = float (aBack.Ambient());
-  ContextFillArea.Back.Diffuse         = float (aBack.Diffuse());
-  ContextFillArea.Back.Specular        = float (aBack.Specular());
-  ContextFillArea.Back.Transparency    = float (aBack.Transparency());
-  ContextFillArea.Back.Emission        = float (aBack.Emissive());
-  ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex());
-  ContextFillArea.Back.BSDF            = aBack.BSDF();
-
-  // Reflection mode
-  ContextFillArea.Back.IsAmbient    = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT)  ? 1 : 0;
-  ContextFillArea.Back.IsDiffuse    = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE)  ? 1 : 0;
-  ContextFillArea.Back.IsSpecular   = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
-  ContextFillArea.Back.IsEmission   = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
-
-  // Material type
-  ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
-
-  // Specular color
-  ContextFillArea.Back.ColorSpec.r  = float (aBack.SpecularColor().Red());
-  ContextFillArea.Back.ColorSpec.g  = float (aBack.SpecularColor().Green());
-  ContextFillArea.Back.ColorSpec.b  = float (aBack.SpecularColor().Blue());
-
-  // Ambient color
-  ContextFillArea.Back.ColorAmb.r   = float (aBack.AmbientColor().Red());
-  ContextFillArea.Back.ColorAmb.g   = float (aBack.AmbientColor().Green());
-  ContextFillArea.Back.ColorAmb.b   = float (aBack.AmbientColor().Blue());
-
-  // Diffuse color
-  ContextFillArea.Back.ColorDif.r   = float (aBack.DiffuseColor().Red());
-  ContextFillArea.Back.ColorDif.g   = float (aBack.DiffuseColor().Green());
-  ContextFillArea.Back.ColorDif.b   = float (aBack.DiffuseColor().Blue());
-
-  // Emissive color
-  ContextFillArea.Back.ColorEms.r   = float (aBack.EmissiveColor().Red());
-  ContextFillArea.Back.ColorEms.g   = float (aBack.EmissiveColor().Green());
-  ContextFillArea.Back.ColorEms.b   = float (aBack.EmissiveColor().Blue());
-
-  ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
-
-  // Front Material
-  const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
-
-  // Material properties
-  ContextFillArea.Front.Shininess       = float (aFront.Shininess());
-  ContextFillArea.Front.Ambient         = float (aFront.Ambient());
-  ContextFillArea.Front.Diffuse         = float (aFront.Diffuse());
-  ContextFillArea.Front.Specular        = float (aFront.Specular());
-  ContextFillArea.Front.Transparency    = float (aFront.Transparency());
-  ContextFillArea.Front.Emission        = float (aFront.Emissive());
-  ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex());
-  ContextFillArea.Front.BSDF            = aFront.BSDF();
-
-  // Reflection mode
-  ContextFillArea.Front.IsAmbient     = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT)  ? 1 : 0;
-  ContextFillArea.Front.IsDiffuse     = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE)  ? 1 : 0;
-  ContextFillArea.Front.IsSpecular    = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
-  ContextFillArea.Front.IsEmission    = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
-
-  // Material type
-  ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
-
-  // Specular color
-  ContextFillArea.Front.ColorSpec.r   = float (aFront.SpecularColor().Red());
-  ContextFillArea.Front.ColorSpec.g   = float (aFront.SpecularColor().Green());
-  ContextFillArea.Front.ColorSpec.b   = float (aFront.SpecularColor().Blue());
-
-  // Ambient color
-  ContextFillArea.Front.ColorAmb.r    = float (aFront.AmbientColor().Red());
-  ContextFillArea.Front.ColorAmb.g    = float (aFront.AmbientColor().Green());
-  ContextFillArea.Front.ColorAmb.b    = float (aFront.AmbientColor().Blue());
-
-  // Diffuse color
-  ContextFillArea.Front.ColorDif.r    = float (aFront.DiffuseColor().Red());
-  ContextFillArea.Front.ColorDif.g    = float (aFront.DiffuseColor().Green());
-  ContextFillArea.Front.ColorDif.b    = float (aFront.DiffuseColor().Blue());
-
-  // Emissive color
-  ContextFillArea.Front.ColorEms.r    = float (aFront.EmissiveColor().Red());
-  ContextFillArea.Front.ColorEms.g    = float (aFront.EmissiveColor().Green());
-  ContextFillArea.Front.ColorEms.b    = float (aFront.EmissiveColor().Blue());
-
-  ContextFillArea.Front.EnvReflexion  = float (aFront.EnvReflexion());
-
-  ContextFillArea.IsDef  = 1; // Definition material ok
-
-  // Texture map
-  ContextFillArea.Texture.TextureMap   = theAspFill->TextureMap();
-  ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
-
-  Standard_Integer   aPolyMode;
-  Standard_ShortReal aPolyFactor, aPolyUnits;
-  theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
-  ContextFillArea.PolygonOffsetMode   = aPolyMode;
-  ContextFillArea.PolygonOffsetFactor = aPolyFactor;
-  ContextFillArea.PolygonOffsetUnits  = aPolyUnits;
-
-  ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
-
-  UpdateAspectFace (Standard_True);
-
-  ContextFillArea.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real       aScale;
-  Quantity_Color      aColor;
-  Aspect_TypeOfMarker aMarkerType;
-  theAspMarker->Values (aColor, aMarkerType, aScale);
-
-  ContextMarker.IsDef         = 1;
-  ContextMarker.Color.r       = Standard_ShortReal (aColor.Red());
-  ContextMarker.Color.g       = Standard_ShortReal (aColor.Green());
-  ContextMarker.Color.b       = Standard_ShortReal (aColor.Blue());
-  ContextMarker.MarkerType    = aMarkerType;
-  ContextMarker.Scale         = Standard_ShortReal (aScale);
-  ContextMarker.MarkerImage   = theAspMarker->GetMarkerImage();
-  ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
-
-  UpdateAspectMarker (Standard_True);
-
-  ContextMarker.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real  anExpansion, aSpace, aTextAngle;
-  Quantity_Color aColor, aColorSubTitle;
-  Standard_CString         aFont;
-  Aspect_TypeOfStyleText   aStyle;
-  Aspect_TypeOfDisplayText aDisplayType;
-  Standard_Boolean         isTextZoomable;
-  Font_FontAspect          aTextFontAspect;
-  theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
-                      aColorSubTitle, isTextZoomable, aTextAngle, aTextFontAspect);
-
-  ContextText.IsDef           = 1;
-  ContextText.Color.r         = float (aColor.Red());
-  ContextText.Color.g         = float (aColor.Green());
-  ContextText.Color.b         = float (aColor.Blue());
-  ContextText.Font            = (char* )aFont;
-  ContextText.Expan           = float (anExpansion);
-  ContextText.Space           = float (aSpace);
-  ContextText.Style           = aStyle;
-  ContextText.DisplayType     = aDisplayType;
-  ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
-  ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
-  ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
-  ContextText.TextZoomable    = isTextZoomable;
-  ContextText.TextAngle       = float (aTextAngle);
-  ContextText.TextFontAspect  = aTextFontAspect;
-  ContextText.ShaderProgram   = theAspText->ShaderProgram();
-
-  UpdateAspectText (Standard_True);
-
-  ContextText.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real     aWidth;
-  Quantity_Color    aColor;
-  Aspect_TypeOfLine aLType;
-  theAspLine->Values (aColor, aLType, aWidth);
-
-  ContextLine.IsDef         = 1;
-  ContextLine.Color.r       = float (aColor.Red());
-  ContextLine.Color.g       = float (aColor.Green());
-  ContextLine.Color.b       = float (aColor.Blue());
-  ContextLine.LineType      = aLType;
-  ContextLine.Width         = float (aWidth);
-  ContextLine.ShaderProgram = theAspLine->ShaderProgram();
-
-  UpdateAspectLine (Standard_False);
-
-  ContextLine.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real        anRGB[3];
-  Standard_Real        aWidth;
-  Quantity_Color       anIntColor;
-  Quantity_Color       aBackIntColor;
-  Quantity_Color       anEdgeColor;
-  Aspect_TypeOfLine    aLType;
-  Aspect_InteriorStyle aStyle;
-  theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
-
-  anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
-  ContextFillArea.Style      = aStyle;
-  ContextFillArea.IntColor.r = float (anRGB[0]);
-  ContextFillArea.IntColor.g = float (anRGB[1]);
-  ContextFillArea.IntColor.b = float (anRGB[2]);
-
-  if (theAspFill->Distinguish())
-  {
-    aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
-  }
-  ContextFillArea.BackIntColor.r = float(anRGB[0]);
-  ContextFillArea.BackIntColor.g = float(anRGB[1]);
-  ContextFillArea.BackIntColor.b = float(anRGB[2]);
-
-  // Edges
-  ContextFillArea.Edge        = theAspFill->Edge() ? 1 : 0;
-  ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
-  ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
-  ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
-  ContextFillArea.LineType    = aLType;
-  ContextFillArea.Width       = float (aWidth);
-  ContextFillArea.Hatch       = theAspFill->HatchStyle();
-
-  // Front and Back face
-  ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
-  ContextFillArea.BackFace    = theAspFill->BackFace()    ? 1 : 0;
-
-  // Back Material
-  const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
-  // Material state
-  ContextFillArea.Back.Shininess    = float (aBack.Shininess());
-  ContextFillArea.Back.Ambient      = float (aBack.Ambient());
-  ContextFillArea.Back.Diffuse      = float (aBack.Diffuse());
-  ContextFillArea.Back.Specular     = float (aBack.Specular());
-  ContextFillArea.Back.Transparency = float (aBack.Transparency());
-  ContextFillArea.Back.Emission     = float (aBack.Emissive());
-
-  // Reflection mode
-  ContextFillArea.Back.IsAmbient    = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT)  ? 1 : 0;
-  ContextFillArea.Back.IsDiffuse    = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE)  ? 1 : 0;
-  ContextFillArea.Back.IsSpecular   = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
-  ContextFillArea.Back.IsEmission   = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
-
-  // Material type
-  ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
-
-  // Specular color
-  ContextFillArea.Back.ColorSpec.r  = float (aBack.SpecularColor().Red());
-  ContextFillArea.Back.ColorSpec.g  = float (aBack.SpecularColor().Green());
-  ContextFillArea.Back.ColorSpec.b  = float (aBack.SpecularColor().Blue());
-
-  // Ambient color
-  ContextFillArea.Back.ColorAmb.r   = float (aBack.AmbientColor().Red());
-  ContextFillArea.Back.ColorAmb.g   = float (aBack.AmbientColor().Green());
-  ContextFillArea.Back.ColorAmb.b   = float (aBack.AmbientColor().Blue());
-
-  // Diffuse color
-  ContextFillArea.Back.ColorDif.r   = float (aBack.DiffuseColor().Red());
-  ContextFillArea.Back.ColorDif.g   = float (aBack.DiffuseColor().Green());
-  ContextFillArea.Back.ColorDif.b   = float (aBack.DiffuseColor().Blue());
-
-  // Emissive color
-  ContextFillArea.Back.ColorEms.r   = float (aBack.EmissiveColor().Red());
-  ContextFillArea.Back.ColorEms.g   = float (aBack.EmissiveColor().Green());
-  ContextFillArea.Back.ColorEms.b   = float (aBack.EmissiveColor().Blue());
-
-  ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
-
-  ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex());
-  ContextFillArea.Back.BSDF = aBack.BSDF();
-
-  // Front Material
-  const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
-  // Light specificity
-  ContextFillArea.Front.Shininess     = float (aFront.Shininess());
-  ContextFillArea.Front.Ambient       = float (aFront.Ambient());
-  ContextFillArea.Front.Diffuse       = float (aFront.Diffuse());
-  ContextFillArea.Front.Specular      = float (aFront.Specular());
-  ContextFillArea.Front.Transparency  = float (aFront.Transparency());
-  ContextFillArea.Front.Emission      = float (aFront.Emissive());
-
-  // Reflection mode
-  ContextFillArea.Front.IsAmbient     = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT)  ? 1 : 0;
-  ContextFillArea.Front.IsDiffuse     = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE)  ? 1 : 0;
-  ContextFillArea.Front.IsSpecular    = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
-  ContextFillArea.Front.IsEmission    = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
-
-  // Material type
-  ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
-
-  // Specular color
-  ContextFillArea.Front.ColorSpec.r   = float (aFront.SpecularColor().Red());
-  ContextFillArea.Front.ColorSpec.g   = float (aFront.SpecularColor().Green());
-  ContextFillArea.Front.ColorSpec.b   = float (aFront.SpecularColor().Blue());
-
-  // Ambient color
-  ContextFillArea.Front.ColorAmb.r    = float (aFront.AmbientColor().Red());
-  ContextFillArea.Front.ColorAmb.g    = float (aFront.AmbientColor().Green());
-  ContextFillArea.Front.ColorAmb.b    = float (aFront.AmbientColor().Blue());
-
-  // Diffuse color
-  ContextFillArea.Front.ColorDif.r    = float (aFront.DiffuseColor().Red());
-  ContextFillArea.Front.ColorDif.g    = float (aFront.DiffuseColor().Green());
-  ContextFillArea.Front.ColorDif.b    = float (aFront.DiffuseColor().Blue());
-
-  // Emissive color
-  ContextFillArea.Front.ColorEms.r    = float (aFront.EmissiveColor().Red());
-  ContextFillArea.Front.ColorEms.g    = float (aFront.EmissiveColor().Green());
-  ContextFillArea.Front.ColorEms.b    = float (aFront.EmissiveColor().Blue());
-
-  ContextFillArea.Front.EnvReflexion  = float (aFront.EnvReflexion());
-
-  ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex());
-  ContextFillArea.Front.BSDF = aFront.BSDF();
-
-  ContextFillArea.IsDef = 1; // Material definition ok
-
-  ContextFillArea.Texture.TextureMap   = theAspFill->TextureMap();
-  ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
-
-  Standard_Integer   aPolyMode;
-  Standard_ShortReal aPolyFactor, aPolyUnits;
-  theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
-  ContextFillArea.PolygonOffsetMode   = aPolyMode;
-  ContextFillArea.PolygonOffsetFactor = aPolyFactor;
-  ContextFillArea.PolygonOffsetUnits  = aPolyUnits;
-
-  ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
-
-  UpdateAspectFace (Standard_False);
-
-  ContextFillArea.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_Real       aScale;
-  Quantity_Color      aColor;
-  Aspect_TypeOfMarker aMarkerType;
-  theAspMarker->Values (aColor, aMarkerType, aScale);
-
-  ContextMarker.IsDef         = 1;
-  ContextMarker.Color.r       = Standard_ShortReal (aColor.Red());
-  ContextMarker.Color.g       = Standard_ShortReal (aColor.Green());
-  ContextMarker.Color.b       = Standard_ShortReal (aColor.Blue());
-  ContextMarker.MarkerType    = aMarkerType;
-  ContextMarker.Scale         = Standard_ShortReal (aScale);
-  ContextMarker.MarkerImage   = theAspMarker->GetMarkerImage();
-
-  ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
-
-  UpdateAspectMarker (Standard_False);
-
-  ContextMarker.IsSet = 1;
-
-  Update();
-}
-
-// =======================================================================
-// function : SetPrimitivesAspect
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
-{
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  Standard_CString aFont;
-  Standard_Real aSpace, anExpansion, aTextAngle;
-  Quantity_Color aColor, aColorSubTitle;
-  Aspect_TypeOfStyleText   aStyle;
-  Aspect_TypeOfDisplayText aDisplayType;
-  Standard_Boolean aTextZoomable;
-  Font_FontAspect  aTextFontAspect;
-  theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
-                      aColorSubTitle, aTextZoomable, aTextAngle, aTextFontAspect);
-
-  ContextText.IsDef           = 1;
-  ContextText.Color.r         = float (aColor.Red());
-  ContextText.Color.g         = float (aColor.Green());
-  ContextText.Color.b         = float (aColor.Blue());
-  ContextText.Font            = (char* )aFont;
-  ContextText.Expan           = float (anExpansion);
-  ContextText.Space           = float (aSpace);
-  ContextText.Style           = aStyle;
-  ContextText.DisplayType     = aDisplayType;
-  ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
-  ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
-  ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
-  ContextText.TextZoomable    = aTextZoomable;
-  ContextText.TextAngle       = float (aTextAngle);
-  ContextText.TextFontAspect  = aTextFontAspect;
-  ContextText.ShaderProgram   = theAspText->ShaderProgram();
-
-  UpdateAspectText (Standard_False);
-
-  ContextText.IsSet = 1;
-
-  Update();
-}
-
 // =======================================================================
 // function : IsGroupPrimitivesAspectSet
 // purpose  :
@@ -802,10 +252,10 @@ Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_Gr
 {
   switch (theAspect)
   {
-    case Graphic3d_ASPECT_LINE:      return ContextLine.IsSet;
-    case Graphic3d_ASPECT_TEXT:      return ContextText.IsSet;
-    case Graphic3d_ASPECT_MARKER:    return ContextMarker.IsSet;
-    case Graphic3d_ASPECT_FILL_AREA: return ContextFillArea.IsSet;
+    case Graphic3d_ASPECT_LINE:      return !LineAspect().IsNull();
+    case Graphic3d_ASPECT_TEXT:      return !TextAspect().IsNull();
+    case Graphic3d_ASPECT_MARKER:    return !MarkerAspect().IsNull();
+    case Graphic3d_ASPECT_FILL_AREA: return !FillAreaAspect().IsNull();
     default:                         return Standard_False;
   }
 }
@@ -819,154 +269,41 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
                                              const Handle(Graphic3d_AspectMarker3d)&   theAspMarker,
                                              const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
 {
-  Quantity_Color aColor;
-  Graphic3d_MaterialAspect aFront, aBack;
-
-  const CALL_DEF_CONTEXTLINE& anAspLine = ContextLine;
-  aColor.SetValues (Standard_Real (anAspLine.Color.r),
-                    Standard_Real (anAspLine.Color.g),
-                    Standard_Real (anAspLine.Color.b), Quantity_TOC_RGB);
-  theAspLine->SetColor         (aColor);
-  theAspLine->SetType          (Aspect_TypeOfLine (anAspLine.LineType));
-  theAspLine->SetWidth         (Standard_Real     (anAspLine.Width));
-  theAspLine->SetShaderProgram (anAspLine.ShaderProgram);
-
-  const CALL_DEF_CONTEXTTEXT& anAspText = ContextText;
-  aColor.SetValues (Standard_Real (anAspText.Color.r),
-                    Standard_Real (anAspText.Color.g),
-                    Standard_Real (anAspText.Color.b), Quantity_TOC_RGB);
-  theAspText->SetColor (aColor);
-  aColor.SetValues (Standard_Real (anAspText.ColorSubTitle.r),
-                    Standard_Real (anAspText.ColorSubTitle.g),
-                    Standard_Real (anAspText.ColorSubTitle.b), Quantity_TOC_RGB);
-  theAspText->SetColorSubTitle   (aColor);
-  theAspText->SetFont            (anAspText.Font);
-  theAspText->SetSpace           (Standard_Real            (anAspText.Space));
-  theAspText->SetExpansionFactor (Standard_Real            (anAspText.Expan));
-  theAspText->SetStyle           (Aspect_TypeOfStyleText   (anAspText.Style));
-  theAspText->SetDisplayType     (Aspect_TypeOfDisplayText (anAspText.DisplayType));
-  theAspText->SetShaderProgram   (anAspText.ShaderProgram);
-
-  const CALL_DEF_CONTEXTMARKER& anAspMarker = ContextMarker;
-  aColor.SetValues (Standard_Real (anAspMarker.Color.r),
-                    Standard_Real (anAspMarker.Color.g),
-                    Standard_Real (anAspMarker.Color.b), Quantity_TOC_RGB);
-  theAspMarker->SetColor (aColor);
-  theAspMarker->SetType  (anAspMarker.MarkerType);
-  theAspMarker->SetScale (Standard_Real (anAspMarker.Scale));
-  theAspMarker->SetShaderProgram (anAspMarker.ShaderProgram);
-  if (anAspMarker.MarkerType == Aspect_TOM_USERDEFINED)
+  if (!theAspLine.IsNull())
   {
-    theAspMarker->SetMarkerImage (ContextMarker.MarkerImage);
+    Handle(Graphic3d_AspectLine3d) aLineAspect = LineAspect();
+    if (!aLineAspect.IsNull())
+    {
+      *theAspLine.operator->() = *aLineAspect;
+    }
   }
 
-  const CALL_DEF_CONTEXTFILLAREA& anAspFill = ContextFillArea;
-  // Interior
-  theAspFill->SetInteriorStyle (Aspect_InteriorStyle (anAspFill.Style));
-  aColor.SetValues (Standard_Real (anAspFill.IntColor.r),
-                    Standard_Real (anAspFill.IntColor.g),
-                    Standard_Real (anAspFill.IntColor.b), Quantity_TOC_RGB);
-  theAspFill->SetInteriorColor (aColor);
-
-  // Edges
-  aColor.SetValues (Standard_Real (anAspFill.EdgeColor.r),
-                    Standard_Real (anAspFill.EdgeColor.g),
-                    Standard_Real (anAspFill.EdgeColor.b), Quantity_TOC_RGB);
-  theAspFill->SetEdgeColor    (aColor);
-  theAspFill->SetEdgeLineType (Aspect_TypeOfLine (anAspFill.LineType));
-  theAspFill->SetEdgeWidth    (Standard_Real     (anAspFill.Width));
-
-  // Back Material
-  aBack.SetShininess    (Standard_Real (anAspFill.Back.Shininess));
-  aBack.SetAmbient      (Standard_Real (anAspFill.Back.Ambient));
-  aBack.SetDiffuse      (Standard_Real (anAspFill.Back.Diffuse));
-  aBack.SetSpecular     (Standard_Real (anAspFill.Back.Specular));
-  aBack.SetTransparency (Standard_Real (anAspFill.Back.Transparency));
-  aBack.SetEmissive     (Standard_Real (anAspFill.Back.Emission));
-  anAspFill.Back.IsAmbient  == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_AMBIENT)  : aBack.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
-  anAspFill.Back.IsDiffuse  == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE)  : aBack.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
-  anAspFill.Back.IsSpecular == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aBack.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
-  anAspFill.Back.IsEmission == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aBack.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
-
-  aColor.SetValues (Standard_Real (anAspFill.Back.ColorSpec.r),
-                    Standard_Real (anAspFill.Back.ColorSpec.g),
-                    Standard_Real (anAspFill.Back.ColorSpec.b), Quantity_TOC_RGB);
-  aBack.SetSpecularColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Back.ColorAmb.r),
-                    Standard_Real (anAspFill.Back.ColorAmb.g),
-                    Standard_Real (anAspFill.Back.ColorAmb.b), Quantity_TOC_RGB);
-  aBack.SetAmbientColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Back.ColorDif.r),
-                    Standard_Real (anAspFill.Back.ColorDif.g),
-                    Standard_Real (anAspFill.Back.ColorDif.b), Quantity_TOC_RGB);
-  aBack.SetDiffuseColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Back.ColorEms.r),
-                    Standard_Real (anAspFill.Back.ColorEms.g),
-                    Standard_Real (anAspFill.Back.ColorEms.b), Quantity_TOC_RGB);
-  aBack.SetEmissiveColor (aColor);
-
-  aBack.SetEnvReflexion (anAspFill.Back.EnvReflexion);
-
-  aBack.SetRefractionIndex (Standard_Real (anAspFill.Back.RefractionIndex));
-  aBack.SetBSDF (anAspFill.Back.BSDF);
-
-  // Front Material
-  aFront.SetShininess    (Standard_Real (anAspFill.Front.Shininess));
-  aFront.SetAmbient      (Standard_Real (anAspFill.Front.Ambient));
-  aFront.SetDiffuse      (Standard_Real (anAspFill.Front.Diffuse));
-  aFront.SetSpecular     (Standard_Real (anAspFill.Front.Specular));
-  aFront.SetTransparency (Standard_Real (anAspFill.Front.Transparency));
-  aFront.SetEmissive     (Standard_Real (anAspFill.Back.Emission));
-  anAspFill.Front.IsAmbient  == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_AMBIENT)  : aFront.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
-  anAspFill.Front.IsDiffuse  == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE)  : aFront.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
-  anAspFill.Front.IsSpecular == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aFront.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
-  anAspFill.Front.IsEmission == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aFront.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
-
-  aColor.SetValues (Standard_Real (anAspFill.Front.ColorSpec.r),
-                    Standard_Real (anAspFill.Front.ColorSpec.g),
-                    Standard_Real (anAspFill.Front.ColorSpec.b), Quantity_TOC_RGB);
-  aFront.SetSpecularColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Front.ColorAmb.r),
-                    Standard_Real (anAspFill.Front.ColorAmb.g),
-                    Standard_Real (anAspFill.Front.ColorAmb.b), Quantity_TOC_RGB);
-  aFront.SetAmbientColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Front.ColorDif.r),
-                    Standard_Real (anAspFill.Front.ColorDif.g),
-                    Standard_Real (anAspFill.Front.ColorDif.b), Quantity_TOC_RGB);
-  aFront.SetDiffuseColor (aColor);
-
-  aColor.SetValues (Standard_Real (anAspFill.Front.ColorEms.r),
-                    Standard_Real (anAspFill.Front.ColorEms.g),
-                    Standard_Real (anAspFill.Front.ColorEms.b), Quantity_TOC_RGB);
-  aFront.SetEmissiveColor (aColor);
-
-  aFront.SetEnvReflexion (anAspFill.Front.EnvReflexion);
+  if (!theAspText.IsNull())
+  {
+    Handle(Graphic3d_AspectText3d) aTextAspect = TextAspect();
+    if (!aTextAspect.IsNull())
+    {
+      *theAspText.operator->() = *aTextAspect;
+    }
+  }
 
-  aFront.SetRefractionIndex (Standard_Real (anAspFill.Front.RefractionIndex));
-  aFront.SetBSDF (anAspFill.Front.BSDF);
+  if (!theAspMarker.IsNull())
+  {
+    Handle(Graphic3d_AspectMarker3d) aMarkerAspect = MarkerAspect();
+    if (!aMarkerAspect.IsNull())
+    {
+      *theAspMarker.operator->() = *aMarkerAspect;
+    }
+  }
 
-  // Edges
-  anAspFill.Edge == 1 ? theAspFill->SetEdgeOn() : theAspFill->SetEdgeOff();
-  // Hatch
-  theAspFill->SetHatchStyle (Aspect_HatchStyle (anAspFill.Hatch));
-  // Materials
-  // Front and Back face
-  anAspFill.Distinguish == 1 ? theAspFill->SetDistinguishOn() : theAspFill->SetDistinguishOff();
-  anAspFill.BackFace    == 1 ? theAspFill->SuppressBackFace() : theAspFill->AllowBackFace();
-  // Texture
-  theAspFill->SetTextureMap (anAspFill.Texture.TextureMap);
-  anAspFill.Texture.doTextureMap == 1 ? theAspFill->SetTextureMapOn() : theAspFill->SetTextureMapOff();
-  theAspFill->SetShaderProgram  (anAspFill.ShaderProgram);
-  theAspFill->SetPolygonOffsets (anAspFill.PolygonOffsetMode,
-                                 anAspFill.PolygonOffsetFactor,
-                                 anAspFill.PolygonOffsetUnits);
-  theAspFill->SetBackMaterial  (aBack);
-  theAspFill->SetFrontMaterial (aFront);
+  if (!theAspFill.IsNull())
+  {
+    Handle(Graphic3d_AspectFillArea3d) aFillAspect = FillAreaAspect();
+    if (!aFillAspect.IsNull())
+    {
+      *theAspFill.operator->() = *aFillAspect;
+    }
+  }
 }
 
 // =======================================================================
@@ -1207,39 +544,3 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
   Text (aText.ToCString(), thePoint, theHeight, 0.0,
         Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
 }
-
-// =======================================================================
-// function : SetClosed
-// purpose  :
-// =======================================================================
-void Graphic3d_Group::SetClosed (const Standard_Boolean theIsClosed)
-{
-  myIsClosed = theIsClosed;
-}
-
-// =======================================================================
-// function : IsClosed
-// purpose  :
-// =======================================================================
-Standard_Boolean Graphic3d_Group::IsClosed() const
-{
-  return myIsClosed;
-}
-
-//=======================================================================
-//function : BoundingBox
-//purpose  :
-//=======================================================================
-const Graphic3d_BndBox4f& Graphic3d_Group::BoundingBox() const
-{
-  return myBounds;
-}
-
-//=======================================================================
-//function : ChangeBoundingBox
-//purpose  :
-//=======================================================================
-Graphic3d_BndBox4f& Graphic3d_Group::ChangeBoundingBox()
-{
-  return myBounds;
-}