0027860: Visualization - clean up Transformation Persistence API
[occt.git] / src / Graphic3d / Graphic3d_ArrayOfPrimitives.lxx
index 783b98b..4661b9b 100644 (file)
@@ -68,13 +68,21 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Graphic3d_
   return AddVertex (theVertex.x(), theVertex.y(), theVertex.z());
 }
 
+inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt&           theVertex,
+                                                                const Graphic3d_Vec4ub& theColor)
+{
+  const Standard_Integer anIndex = AddVertex (theVertex);
+  SetVertexColor (anIndex, theColor);
+  return anIndex;
+}
+
 inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,
                                                                 const Standard_Real theY,
                                                                 const Standard_Real theZ)
 {
-  return AddVertex (Standard_ShortReal (theX),
-                    Standard_ShortReal (theY),
-                    Standard_ShortReal (theZ));
+  return AddVertex (RealToShortReal (theX),
+                    RealToShortReal (theY),
+                    RealToShortReal (theZ));
 }
 
 inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex,
@@ -87,7 +95,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& th
 inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,  const Standard_Real theY,  const Standard_Real theZ,
                                                                 const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ)
 {
-  return AddVertex (Standard_ShortReal (theX),  Standard_ShortReal (theY),  Standard_ShortReal (theZ),
+  return AddVertex (RealToShortReal (theX),  RealToShortReal (theY),  RealToShortReal (theZ),
                     Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ));
 }
 
@@ -101,7 +109,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt&
 inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,  const Standard_Real theY,  const Standard_Real theZ,
                                                                 const Standard_Real theTX, const Standard_Real theTY)
 {
-  return AddVertex (Standard_ShortReal (theX),  Standard_ShortReal (theY),  Standard_ShortReal (theZ),
+  return AddVertex (RealToShortReal (theX),  RealToShortReal (theY),  RealToShortReal (theZ),
                     Standard_ShortReal (theTX), Standard_ShortReal (theTY));
 }
 
@@ -118,7 +126,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_R
                                                                 const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ,
                                                                 const Standard_Real theTX, const Standard_Real theTY)
 {
-  return AddVertex (Standard_ShortReal (theX),  Standard_ShortReal (theY),  Standard_ShortReal (theZ),
+  return AddVertex (RealToShortReal (theX),  RealToShortReal (theY),  RealToShortReal (theZ),
                     Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ),
                     Standard_ShortReal (theTX), Standard_ShortReal (theTY));
 }
@@ -167,12 +175,18 @@ inline void Graphic3d_ArrayOfPrimitives::SetVertexColor (const Standard_Integer
   {
     Graphic3d_Vec4ub aColor (Standard_Byte(theR * 255.0),
                              Standard_Byte(theG * 255.0),
-                             Standard_Byte(theB * 255.0), 0);
+                             Standard_Byte(theB * 255.0), 255);
     SetVertexColor (theIndex, *reinterpret_cast<Standard_Integer*>(&aColor));
   }
   myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
 }
 
+inline void Graphic3d_ArrayOfPrimitives::SetVertexColor (const Standard_Integer  theIndex,
+                                                         const Graphic3d_Vec4ub& theColor)
+{
+  SetVertexColor (theIndex, *reinterpret_cast<const Standard_Integer*> (&theColor));
+}
+
 inline void Graphic3d_ArrayOfPrimitives::SetVertexNormal (const Standard_Integer theIndex,
                                                           const Standard_Real    theNX,
                                                           const Standard_Real    theNY,
@@ -288,7 +302,7 @@ inline void Graphic3d_ArrayOfPrimitives::VertexColor (const Standard_Integer the
   }
   Standard_Integer aColorInt = 0;
   VertexColor (theIndex, aColorInt);
-  const Graphic3d_Vec4ub& aColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(aColorInt);
+  const Graphic3d_Vec4ub& aColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(&aColorInt);
   theR = Standard_Real(aColor.r()) / 255.0;
   theG = Standard_Real(aColor.g()) / 255.0;
   theB = Standard_Real(aColor.b()) / 255.0;