mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0024406: Visualization - crash on re-usage of the same primitive array
Redesign Graphic3d_ArrayOfPrimitives Store vertices data in buffer objects managed using smart-pointers - no more low-level memory corruption by memory releasing after VBO creation. Remove broken hasEdgeInfos. Interleave vertex attributes (position, color, normal, uv) in single buffer. Remove from Graphic3d_ArrayOfPrimitives methods ::Orientate(). Remove structures Graphic3d_PrimitiveArray, CALL_DEF_PARRAY. Add support for 2D vertex arrays. Graphic3d_Group - remove array or primitive arrays. Introduce more universal method Graphic3d_Group::AddPrimitiveArray(). Fix warning
This commit is contained in:
parent
c002793be1
commit
871fa1038d
@ -56,14 +56,8 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
|
||||
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
|
||||
Standard_Boolean hasVColors = (myFlagColor == 1);
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray =
|
||||
new Graphic3d_ArrayOfTriangles ( myNbNodes, //maxVertexs
|
||||
myNbTriangles * 3,//maxEdges
|
||||
hasVNormals, //hasVNormals
|
||||
hasVColors, //hasVColors
|
||||
Standard_False, //hasTexels
|
||||
Standard_True //hasEdgeInfos
|
||||
);
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (myNbNodes, myNbTriangles * 3,
|
||||
hasVNormals, hasVColors, Standard_False);
|
||||
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
|
||||
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
Graphic3d_Buffer.hxx
|
||||
Graphic3d_Buffer_Handle.hxx
|
||||
Graphic3d_BoundBuffer.hxx
|
||||
Graphic3d_BoundBuffer_Handle.hxx
|
||||
Graphic3d_IndexBuffer.hxx
|
||||
Graphic3d_IndexBuffer_Handle.hxx
|
||||
Graphic3d_CAspectFillArea.hxx
|
||||
Graphic3d_CAspectLine.hxx
|
||||
Graphic3d_CAspectMarker.hxx
|
||||
@ -34,7 +40,6 @@ Graphic3d_StructureManager.pxx
|
||||
Graphic3d.edl
|
||||
Graphic3d_CMPLRS.edl
|
||||
Graphic3d_WOKSteps.edl
|
||||
Graphic3d_PrimitiveArray.hxx
|
||||
Graphic3d_TransModeFlags.hxx
|
||||
Graphic3d_CTransPersStruct.hxx
|
||||
Graphic3d_NListOfHAsciiString.hxx
|
||||
|
@ -336,7 +336,13 @@ is
|
||||
-- Category: Imported types
|
||||
---------------------------
|
||||
|
||||
imported PrimitiveArray;
|
||||
imported Buffer;
|
||||
imported Buffer_Handle;
|
||||
imported BoundBuffer;
|
||||
imported BoundBuffer_Handle;
|
||||
imported IndexBuffer;
|
||||
imported IndexBuffer_Handle;
|
||||
|
||||
imported BufferType;
|
||||
|
||||
imported CBitFields20;
|
||||
@ -519,10 +525,6 @@ is
|
||||
-- Category: Instantiated classes
|
||||
---------------------------------
|
||||
|
||||
class ListOfPArray instantiates
|
||||
List from TCollection (ArrayOfPrimitives from Graphic3d);
|
||||
---Category: Instantiated classes
|
||||
|
||||
class SequenceOfAddress instantiates
|
||||
Sequence from TCollection
|
||||
(Address from Standard);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfPoints.ixx>
|
||||
|
||||
Graphic3d_ArrayOfPoints :: Graphic3d_ArrayOfPoints (const Standard_Integer maxVertexs,
|
||||
const Standard_Boolean hasVColors)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, maxVertexs, 0, 0, Standard_False, hasVColors, Standard_False, Standard_False, Standard_False)
|
||||
Graphic3d_ArrayOfPoints::Graphic3d_ArrayOfPoints (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Boolean theHasVColors)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, theMaxVertexs, 0, 0, Standard_False, theHasVColors, Standard_False, Standard_False)
|
||||
{}
|
||||
|
@ -24,8 +24,7 @@ is
|
||||
hasVNormals: Boolean from Standard = Standard_False;
|
||||
hasVColors: Boolean from Standard = Standard_False;
|
||||
hasBColors: Boolean from Standard = Standard_False;
|
||||
hasTexels: Boolean from Standard = Standard_False;
|
||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
||||
hasTexels: Boolean from Standard = Standard_False)
|
||||
returns mutable ArrayOfPolygons from Graphic3d;
|
||||
---Purpose: Creates an array of polygons,
|
||||
-- a polygon can be filled as:
|
||||
@ -105,9 +104,6 @@ is
|
||||
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddBound(number,Color) method.
|
||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddEdge(number,visibillity) method.
|
||||
-- Warning:
|
||||
-- the user is responsible about the orientation of the polygon
|
||||
-- depending of the order of the created vertex or edges and this
|
||||
|
@ -14,13 +14,12 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfPolygons.ixx>
|
||||
|
||||
Graphic3d_ArrayOfPolygons :: Graphic3d_ArrayOfPolygons (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxBounds,
|
||||
const Standard_Integer maxEdges,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasFColors,
|
||||
const Standard_Boolean hasVTexels,
|
||||
const Standard_Boolean hasEdgeInfos)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_POLYGONS,maxVertexs,maxBounds,maxEdges,hasVNormals,hasVColors,hasFColors,hasVTexels,hasEdgeInfos) {}
|
||||
Graphic3d_ArrayOfPolygons::Graphic3d_ArrayOfPolygons (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxBounds,
|
||||
const Standard_Integer theMaxEdges,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasFColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYGONS, theMaxVertexs, theMaxBounds, theMaxEdges, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
|
||||
{}
|
||||
|
@ -22,8 +22,7 @@ is
|
||||
maxBounds: Integer from Standard = 0;
|
||||
maxEdges: Integer from Standard = 0;
|
||||
hasVColors: Boolean from Standard = Standard_False;
|
||||
hasBColors: Boolean from Standard = Standard_False;
|
||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
||||
hasBColors: Boolean from Standard = Standard_False)
|
||||
returns mutable ArrayOfPolylines from Graphic3d;
|
||||
---Purpose: Creates an array of polylines,
|
||||
-- a polyline can be filled as:
|
||||
@ -97,8 +96,5 @@ is
|
||||
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddBound(number,Color) method.
|
||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddEdge(number,visibillity) method.
|
||||
|
||||
end;
|
||||
|
@ -14,11 +14,10 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfPolylines.ixx>
|
||||
|
||||
Graphic3d_ArrayOfPolylines :: Graphic3d_ArrayOfPolylines (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxBounds,
|
||||
const Standard_Integer maxEdges,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasFColors,
|
||||
const Standard_Boolean hasEdgeInfos)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_POLYLINES,maxVertexs,maxBounds,maxEdges,Standard_False,hasVColors,hasFColors,Standard_False,hasEdgeInfos) {}
|
||||
Graphic3d_ArrayOfPolylines::Graphic3d_ArrayOfPolylines (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxBounds,
|
||||
const Standard_Integer theMaxEdges,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasFColors)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYLINES, theMaxVertexs, theMaxBounds, theMaxEdges, Standard_False, theHasVColors, theHasFColors, Standard_False)
|
||||
{}
|
||||
|
@ -34,12 +34,14 @@ deferred class ArrayOfPrimitives from Graphic3d inherits TShared
|
||||
|
||||
uses
|
||||
|
||||
TypeOfPrimitiveArray from Graphic3d,
|
||||
PrimitiveArray from Graphic3d,
|
||||
Color from Quantity,
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Dir from gp
|
||||
TypeOfPrimitiveArray from Graphic3d,
|
||||
Buffer_Handle from Graphic3d,
|
||||
BoundBuffer_Handle from Graphic3d,
|
||||
IndexBuffer_Handle from Graphic3d,
|
||||
Color from Quantity,
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Dir from gp
|
||||
|
||||
raises
|
||||
OutOfRange from Standard,
|
||||
@ -56,8 +58,7 @@ is
|
||||
hasVNormals: Boolean from Standard;
|
||||
hasVColors: Boolean from Standard;
|
||||
hasBColors: Boolean from Standard;
|
||||
hasTexels: Boolean from Standard;
|
||||
hasEdgeInfos: Boolean from Standard)
|
||||
hasTexels: Boolean from Standard)
|
||||
returns mutable ArrayOfPrimitives from Graphic3d
|
||||
raises InitialisationError from Graphic3d;
|
||||
---Purpose: Warning
|
||||
@ -68,8 +69,6 @@ is
|
||||
-- constructor parameter is > 0.
|
||||
-- You must use AddEdge() method only if the <maxEdges>
|
||||
-- constructor parameter is > 0.
|
||||
-- You must use a coherent set of AddEdge() methods according to the
|
||||
-- <hasEdgeInfos> constructor parameter.
|
||||
|
||||
Destroy( me: mutable);
|
||||
-- destructor
|
||||
@ -327,17 +326,11 @@ is
|
||||
-- if the actual Bound number is >= <maxBounds>
|
||||
|
||||
AddEdge( me:mutable;
|
||||
vertexIndex: Integer from Standard;
|
||||
isVisible: Boolean from Standard = Standard_True)
|
||||
vertexIndex: Integer from Standard)
|
||||
returns Integer from Standard
|
||||
---Level: Public
|
||||
---Purpose: Adds an edge in the range [1,VertexNumber()] in the array,
|
||||
-- if <isVisible> is FALSE the edge between <vertexIndex> and
|
||||
-- the next edge will not be visible even if the SetEdgeOn() method
|
||||
-- is activated in Graphic3d_AspectFillArea3d class.
|
||||
-- returns the actual edges number.
|
||||
-- Warning: <isVisible> is ignored when the <hasEdgeInfos>
|
||||
-- constructor parameter is FALSE.
|
||||
---Purpose: Adds an edge in the range [1,VertexNumber()] in the array.
|
||||
-- Returns the actual edges number.
|
||||
raises OutOfRange from Standard;
|
||||
-- if the actual edge number is >= <maxEdges>
|
||||
|
||||
@ -345,47 +338,6 @@ is
|
||||
-- Methods to modify the array
|
||||
-- -------------------------------------------------------------------
|
||||
|
||||
Orientate( me:mutable;
|
||||
aNormal: Dir from gp)
|
||||
returns Boolean from Standard;
|
||||
---Level: Public
|
||||
---Purpose: Orientate correctly all vertexs & normals of this array
|
||||
-- according to the <aNormal> parameter and
|
||||
-- returns TRUE when something has change in the array.
|
||||
-- Warning: When the array has edges this method is apply
|
||||
-- on edge sub array instead on vertex sub array.
|
||||
|
||||
Orientate( me:mutable;
|
||||
aVertexIndex: Integer from Standard;
|
||||
aVertexNumber: Integer from Standard;
|
||||
aNormal: Dir from gp)
|
||||
returns Boolean from Standard
|
||||
---Level: Internal
|
||||
---Purpose: Orientate correctly a set of vertexs & normal
|
||||
-- from <aVertexIndex> to <aVertexIndex>+<aVertexNumber>-1
|
||||
-- according to the <aNormal> parameter and
|
||||
-- returns TRUE when something has change in the array.
|
||||
-- Warning: When the array has edges this method is apply
|
||||
-- on edge sub array instead on vertex sub array.
|
||||
raises OutOfRange from Standard is private;
|
||||
-- if the <aVertexIndex> parameter is < 1 or > VertexNumber() or
|
||||
-- EdgeNumber()
|
||||
|
||||
Orientate( me:mutable;
|
||||
aBoundIndex: Integer from Standard;
|
||||
aNormal: Dir from gp)
|
||||
returns Boolean from Standard
|
||||
---Level: Public
|
||||
---Purpose: Orientate correctly all vertexs & normal of the bound <aBound>
|
||||
-- according to the <aNormal> parameter and
|
||||
-- returns TRUE when something has change in the array.
|
||||
-- Warning: When the array has edges this method is apply
|
||||
-- on edge sub array instead on vertex sub array.
|
||||
-- When this array has no bound, <aBoundIndex> design the item number
|
||||
raises OutOfRange from Standard;
|
||||
-- if the <aBoundIndex> parameter is < 1 or > BoundNumber()
|
||||
-- or if the <aBoundIndex> parameter is < 1 or > ItemNumber()
|
||||
|
||||
SetVertice( me:mutable;
|
||||
anIndex: Integer from Standard;
|
||||
aVertice: Pnt from gp)
|
||||
@ -487,11 +439,23 @@ is
|
||||
-- Category Inquiries on array
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Array( me )
|
||||
returns PrimitiveArray from Graphic3d;
|
||||
---Level: Internal
|
||||
---Purpose: Returns the array address.
|
||||
Indices (me)
|
||||
returns IndexBuffer_Handle from Graphic3d;
|
||||
---Purpose: Returns optional index buffer.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
Attributes (me)
|
||||
returns Buffer_Handle from Graphic3d;
|
||||
---Purpose: Returns vertex attributes buffer (colors, normals, texture coordinates).
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
Bounds (me)
|
||||
returns BoundBuffer_Handle from Graphic3d;
|
||||
---Purpose: Returns optional bounds buffer.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
Type( me )
|
||||
returns TypeOfPrimitiveArray from Graphic3d;
|
||||
@ -606,12 +570,6 @@ is
|
||||
-- when the rank is < 1 or > VertexNumber().
|
||||
---C++: inline
|
||||
|
||||
HasEdgeInfos( me )
|
||||
returns Boolean from Standard;
|
||||
---Level: Public
|
||||
---Purpose: Returns TRUE when edge visibillity array is defined.
|
||||
---C++: inline
|
||||
|
||||
EdgeNumber( me )
|
||||
returns Integer from Standard;
|
||||
---Level: Public
|
||||
@ -627,15 +585,6 @@ is
|
||||
-- when the rank is < 1 or > EdgeNumber()
|
||||
---C++: inline
|
||||
|
||||
EdgeIsVisible( me ; aRank: Integer from Standard)
|
||||
returns Boolean from Standard
|
||||
---Level: Public
|
||||
---Purpose: Returns TRUE when the edge at rank <aRank>
|
||||
-- is visible.
|
||||
raises OutOfRange from Standard;
|
||||
-- when the rank is < 1 or > EdgeNumber()
|
||||
---C++: inline
|
||||
|
||||
HasBoundColors( me )
|
||||
returns Boolean from Standard;
|
||||
---Level: Public
|
||||
@ -692,10 +641,19 @@ is
|
||||
is private;
|
||||
|
||||
fields
|
||||
myPrimitiveArray: PrimitiveArray from Graphic3d;
|
||||
myMaxBounds: Integer from Standard;
|
||||
myMaxVertexs: Integer from Standard;
|
||||
myMaxEdges: Integer from Standard;
|
||||
|
||||
myIndices : IndexBuffer_Handle from Graphic3d; -- optional index buffer
|
||||
myAttribs : Buffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
|
||||
myBounds : BoundBuffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
|
||||
|
||||
myType : TypeOfPrimitiveArray from Graphic3d;
|
||||
|
||||
myMaxBounds : Integer from Standard;
|
||||
myMaxVertexs : Integer from Standard;
|
||||
myMaxEdges : Integer from Standard;
|
||||
myVNor : Byte from Standard; -- offset to normal attribute
|
||||
myVTex : Byte from Standard; -- offset to texel attribute
|
||||
myVCol : Byte from Standard; -- offset to color attribute
|
||||
|
||||
friends
|
||||
class Group from Graphic3d
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,373 +15,391 @@
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
inline Graphic3d_PrimitiveArray Graphic3d_ArrayOfPrimitives::Array() const
|
||||
inline const Handle(Graphic3d_IndexBuffer)& Graphic3d_ArrayOfPrimitives::Indices() const
|
||||
{
|
||||
return myPrimitiveArray;
|
||||
return myIndices;
|
||||
}
|
||||
|
||||
inline const Handle(Graphic3d_Buffer)& Graphic3d_ArrayOfPrimitives::Attributes() const
|
||||
{
|
||||
return myAttribs;
|
||||
}
|
||||
|
||||
inline const Handle(Graphic3d_BoundBuffer)& Graphic3d_ArrayOfPrimitives::Bounds() const
|
||||
{
|
||||
return myBounds;
|
||||
}
|
||||
|
||||
inline Graphic3d_TypeOfPrimitiveArray Graphic3d_ArrayOfPrimitives::Type() const
|
||||
{
|
||||
Graphic3d_TypeOfPrimitiveArray type = Graphic3d_TOPA_UNDEFINED;
|
||||
if( myPrimitiveArray ) type = (Graphic3d_TypeOfPrimitiveArray) myPrimitiveArray->type;
|
||||
return type;
|
||||
return myType;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexNormals() const
|
||||
{
|
||||
Standard_Boolean defined = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->vnormals ) defined = Standard_True;
|
||||
return defined;
|
||||
return myVNor != 0;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexColors() const
|
||||
{
|
||||
Standard_Boolean defined = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->vcolours ) defined = Standard_True;
|
||||
return defined;
|
||||
return myVCol != 0;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexTexels() const
|
||||
{
|
||||
Standard_Boolean defined = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->vtexels ) defined = Standard_True;
|
||||
return defined;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasEdgeInfos() const
|
||||
{
|
||||
Standard_Boolean defined = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->edge_vis ) defined = Standard_True;
|
||||
return defined;
|
||||
return myVTex != 0;
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::VertexNumber() const
|
||||
{
|
||||
Standard_Integer number = -1;
|
||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_vertexs;
|
||||
return number;
|
||||
return !myAttribs.IsNull() ? myAttribs->NbElements : -1;
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice)
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex)
|
||||
{
|
||||
return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z());
|
||||
return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(
|
||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z)
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,
|
||||
const Standard_Real theY,
|
||||
const Standard_Real theZ)
|
||||
{
|
||||
return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z));
|
||||
return AddVertex (Standard_ShortReal (theX),
|
||||
Standard_ShortReal (theY),
|
||||
Standard_ShortReal (theZ));
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal)
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex,
|
||||
const gp_Dir& theNormal)
|
||||
{
|
||||
return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aNormal.X(),aNormal.Y(),aNormal.Z());
|
||||
return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z(),
|
||||
theNormal.X(), theNormal.Y(), theNormal.Z());
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(
|
||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
||||
const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ)
|
||||
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(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
||||
Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ));
|
||||
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||
Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ));
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Pnt2d& aTexel)
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex,
|
||||
const gp_Pnt2d& theTexel)
|
||||
{
|
||||
return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aTexel.X(),aTexel.Y());
|
||||
return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z(),
|
||||
theTexel.X(), theTexel.Y());
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(
|
||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
||||
const Standard_Real TX, const Standard_Real TY)
|
||||
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(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
||||
Standard_ShortReal(TX),Standard_ShortReal(TY));
|
||||
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||
Standard_ShortReal (theTX), Standard_ShortReal (theTY));
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal, const gp_Pnt2d& aTexel)
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex,
|
||||
const gp_Dir& theNormal,
|
||||
const gp_Pnt2d& theTexel)
|
||||
{
|
||||
return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aNormal.X(),aNormal.Y(),aNormal.Z(),aTexel.X(),aTexel.Y());
|
||||
return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z(),
|
||||
theNormal.X(), theNormal.Y(), theNormal.Z(),
|
||||
theTexel.X(), theTexel.Y());
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(
|
||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
||||
const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ,
|
||||
const Standard_Real TX, const Standard_Real TY)
|
||||
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,
|
||||
const Standard_Real theTX, const Standard_Real theTY)
|
||||
{
|
||||
return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
||||
Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ),
|
||||
Standard_ShortReal(TX),Standard_ShortReal(TY));
|
||||
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||
Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ),
|
||||
Standard_ShortReal (theTX), Standard_ShortReal (theTY));
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertice(
|
||||
const Standard_Integer anIndex,
|
||||
const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertice (const Standard_Integer theIndex,
|
||||
const Standard_ShortReal theX,
|
||||
const Standard_ShortReal theY,
|
||||
const Standard_ShortReal theZ)
|
||||
{
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myMaxVertexs )
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
|
||||
if( myPrimitiveArray->vertices ) {
|
||||
Tfloat *p = myPrimitiveArray->vertices[anIndex-1].xyz;
|
||||
*p++ = X;
|
||||
*p++ = Y;
|
||||
*p = Z;
|
||||
}
|
||||
myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexColor(const Standard_Integer anIndex,
|
||||
const Standard_Real R,
|
||||
const Standard_Real G,
|
||||
const Standard_Real B)
|
||||
{
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myMaxVertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
}
|
||||
|
||||
if( myPrimitiveArray->vcolours ) {
|
||||
unsigned int red = (unsigned int)(R * 255.);
|
||||
unsigned int green = (unsigned int)(G * 255.);
|
||||
unsigned int blue = (unsigned int)(B * 255.);
|
||||
unsigned int alpha = 0;
|
||||
Standard_Integer outColor = alpha << 24 | blue << 16 | green << 8 | red;
|
||||
SetVertexColor( anIndex, outColor );
|
||||
}
|
||||
myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexNormal(
|
||||
const Standard_Integer anIndex,
|
||||
const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ)
|
||||
{
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myMaxVertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
if( myPrimitiveArray->vnormals ) {
|
||||
Tfloat *p = myPrimitiveArray->vnormals[index].xyz;
|
||||
*p++ = Standard_ShortReal(NX);
|
||||
*p++ = Standard_ShortReal(NY);
|
||||
*p = Standard_ShortReal(NZ);
|
||||
}
|
||||
return;
|
||||
}
|
||||
myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs);
|
||||
|
||||
if (theIndex < 1
|
||||
|| theIndex > myMaxVertexs)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
Graphic3d_Vec3& aVec = myAttribs->ChangeValue<Graphic3d_Vec3> (theIndex - 1);
|
||||
aVec.x() = theX;
|
||||
aVec.y() = theY;
|
||||
aVec.z() = theZ;
|
||||
|
||||
myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexTexel(
|
||||
const Standard_Integer anIndex,
|
||||
const Standard_Real TX, const Standard_Real TY)
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexColor (const Standard_Integer theIndex,
|
||||
const Standard_Real theR,
|
||||
const Standard_Real theG,
|
||||
const Standard_Real theB)
|
||||
{
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myMaxVertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
if( myPrimitiveArray->vtexels ) {
|
||||
Tfloat *p = myPrimitiveArray->vtexels[index].xy;
|
||||
*p++ = Standard_ShortReal(TX);
|
||||
*p = Standard_ShortReal(TY);
|
||||
if (theIndex < 1
|
||||
|| theIndex > myMaxVertexs)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs);
|
||||
|
||||
if (myVCol != 0)
|
||||
{
|
||||
Graphic3d_Vec4ub aColor (Standard_Byte(theR * 255.0),
|
||||
Standard_Byte(theG * 255.0),
|
||||
Standard_Byte(theB * 255.0), 0);
|
||||
SetVertexColor (theIndex, *reinterpret_cast<Standard_Integer*>(&aColor));
|
||||
}
|
||||
myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetBoundColor(
|
||||
const Standard_Integer anIndex,
|
||||
const Standard_Real R, const Standard_Real G, const Standard_Real B)
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexNormal (const Standard_Integer theIndex,
|
||||
const Standard_Real theNX,
|
||||
const Standard_Real theNY,
|
||||
const Standard_Real theNZ)
|
||||
{
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myMaxBounds ) {
|
||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
Tfloat *p = myPrimitiveArray->fcolours[index].rgb;
|
||||
*p++ = Standard_ShortReal(R);
|
||||
*p++ = Standard_ShortReal(G);
|
||||
*p = Standard_ShortReal(B);
|
||||
if (theIndex < 1
|
||||
|| theIndex > myMaxVertexs)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
myPrimitiveArray->num_bounds = Max(anIndex,myPrimitiveArray->num_bounds);
|
||||
if (myVNor != 0)
|
||||
{
|
||||
Graphic3d_Vec3& aVec = *reinterpret_cast<Graphic3d_Vec3* >(myAttribs->changeValue (theIndex - 1) + size_t(myVNor));
|
||||
aVec.x() = Standard_ShortReal (theNX);
|
||||
aVec.y() = Standard_ShortReal (theNY);
|
||||
aVec.z() = Standard_ShortReal (theNZ);
|
||||
}
|
||||
myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::Vertice(const Standard_Integer anIndex,
|
||||
Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetVertexTexel (const Standard_Integer theIndex,
|
||||
const Standard_Real theTX,
|
||||
const Standard_Real theTY)
|
||||
{
|
||||
X = Y = Z = 0.;
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
if( myPrimitiveArray->vertices ) {
|
||||
Tfloat *p = myPrimitiveArray->vertices[index].xyz;
|
||||
X = Standard_Real(*p++); Y = Standard_Real(*p++); Z = Standard_Real(*p);
|
||||
if (theIndex < 1
|
||||
|| theIndex > myMaxVertexs)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
if (myVTex != 0)
|
||||
{
|
||||
Graphic3d_Vec2& aVec = *reinterpret_cast<Graphic3d_Vec2* >(myAttribs->changeValue (theIndex - 1) + size_t(myVTex));
|
||||
aVec.x() = Standard_ShortReal (theTX);
|
||||
aVec.y() = Standard_ShortReal (theTY);
|
||||
}
|
||||
myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::SetBoundColor (const Standard_Integer theIndex,
|
||||
const Standard_Real theR,
|
||||
const Standard_Real theG,
|
||||
const Standard_Real theB)
|
||||
{
|
||||
if (myBounds.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theIndex < 1
|
||||
|| theIndex > myMaxBounds)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD BOUND index");
|
||||
}
|
||||
|
||||
Graphic3d_Vec4& aVec = myBounds->Colors[theIndex - 1];
|
||||
aVec.r() = Standard_ShortReal (theR);
|
||||
aVec.g() = Standard_ShortReal (theG);
|
||||
aVec.b() = Standard_ShortReal (theB);
|
||||
aVec.a() = 1.0f;
|
||||
myBounds->NbBounds = Max (theIndex, myBounds->NbBounds);
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::Vertice (const Standard_Integer theIndex,
|
||||
Standard_Real& theX,
|
||||
Standard_Real& theY,
|
||||
Standard_Real& theZ) const
|
||||
{
|
||||
theX = theY = theZ = 0.0;
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theIndex < 1
|
||||
|| theIndex > myAttribs->NbElements)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
const Graphic3d_Vec3& aVec = myAttribs->Value<Graphic3d_Vec3> (theIndex - 1);
|
||||
theX = Standard_Real(aVec.x());
|
||||
theY = Standard_Real(aVec.y());
|
||||
theZ = Standard_Real(aVec.z());
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexColor (const Standard_Integer theIndex,
|
||||
Standard_Real& theR,
|
||||
Standard_Real& theG,
|
||||
Standard_Real& theB) const
|
||||
{
|
||||
theR = theG = theB = 0.0;
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theIndex < 1
|
||||
|| theIndex > myAttribs->NbElements)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
Standard_Integer aColorInt = 0;
|
||||
VertexColor (theIndex, 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;
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexColor (const Standard_Integer theIndex,
|
||||
Standard_Integer& theColor) const
|
||||
{
|
||||
if (myVCol != 0)
|
||||
{
|
||||
theColor = *reinterpret_cast<const Standard_Integer* >(myAttribs->value (theIndex - 1) + size_t(myVCol));
|
||||
}
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer anIndex,
|
||||
Standard_Real& R, Standard_Real& G, Standard_Real& B) const
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexNormal (const Standard_Integer theIndex,
|
||||
Standard_Real& theNX,
|
||||
Standard_Real& theNY,
|
||||
Standard_Real& theNZ) const
|
||||
{
|
||||
R = G = B = 0;
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
theNX = theNY = theNZ = 0.0;
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Standard_Integer aColor;
|
||||
VertexColor(anIndex, aColor);
|
||||
if( myPrimitiveArray->vcolours ) {
|
||||
Standard_Integer r,g,b;
|
||||
Standard_Integer aColor;
|
||||
VertexColor(anIndex, aColor);
|
||||
/*Standard_Real A;
|
||||
Standard_Integer a = aColor & 0xff000000;
|
||||
a >>= 24;
|
||||
A = ((Standard_Real) a) / 255.;*/
|
||||
|
||||
b = aColor & 0x00ff0000;
|
||||
b >>= 16;
|
||||
B =((Standard_Real) b) / 255.;
|
||||
if (theIndex < 1
|
||||
|| theIndex > myAttribs->NbElements)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
g = aColor & 0x0000ff00;
|
||||
g >>= 8;
|
||||
G = ((Standard_Real) g) / 255.;
|
||||
|
||||
r = aColor & 0x000000ff;
|
||||
r >>= 0;
|
||||
R = ((Standard_Real) r) / 255.;
|
||||
if (myVNor != 0)
|
||||
{
|
||||
const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3* >(myAttribs->value (theIndex - 1) + size_t(myVNor));
|
||||
theNX = Standard_Real(aVec.x());
|
||||
theNY = Standard_Real(aVec.y());
|
||||
theNZ = Standard_Real(aVec.z());
|
||||
}
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer anIndex,
|
||||
Standard_Integer& aColor) const
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexTexel (const Standard_Integer theIndex,
|
||||
Standard_Real& theTX,
|
||||
Standard_Real& theTY) const
|
||||
{
|
||||
Standard_Integer index = anIndex-1;
|
||||
|
||||
if( myPrimitiveArray->vcolours ) {
|
||||
#if defined (sparc) || defined (__sparc__) || defined (__sparc)
|
||||
aColor = 0;
|
||||
const char* p_ch = (const char*)&(myPrimitiveArray->vcolours[index]);
|
||||
aColor += p_ch[0];
|
||||
aColor += p_ch[1] << 8 ;
|
||||
aColor += p_ch[2] << 16;
|
||||
aColor += p_ch[3] << 24;
|
||||
#else
|
||||
aColor = myPrimitiveArray->vcolours[index];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexNormal(const Standard_Integer anIndex,
|
||||
Standard_Real& NX, Standard_Real& NY, Standard_Real& NZ) const
|
||||
{
|
||||
NX = NY = NZ = 0.;
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
theTX = theTY = 0.0;
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
if( myPrimitiveArray->vnormals ) {
|
||||
Tfloat *p = myPrimitiveArray->vnormals[index].xyz;
|
||||
NX = Standard_Real(*p++); NY = Standard_Real(*p++); NZ = Standard_Real(*p);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::VertexTexel(const Standard_Integer anIndex,
|
||||
Standard_Real& TX, Standard_Real& TY) const
|
||||
{
|
||||
TX = TY = 0.;
|
||||
if( !myPrimitiveArray ) return;
|
||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
||||
if (theIndex < 1
|
||||
|| theIndex > myAttribs->NbElements)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||
}
|
||||
|
||||
Standard_Integer index = anIndex-1;
|
||||
if( myPrimitiveArray->vtexels ) {
|
||||
Tfloat *p = myPrimitiveArray->vtexels[index].xy;
|
||||
TX = Standard_Real(*p++); TY = Standard_Real(*p);
|
||||
if (myVTex != 0)
|
||||
{
|
||||
const Graphic3d_Vec2& aVec = *reinterpret_cast<const Graphic3d_Vec2* >(myAttribs->value (theIndex - 1) + size_t(myVTex));
|
||||
theTX = Standard_Real(aVec.x());
|
||||
theTY = Standard_Real(aVec.y());
|
||||
}
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::EdgeNumber() const
|
||||
{
|
||||
Standard_Integer number = -1;
|
||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_edges;
|
||||
return number;
|
||||
return !myIndices.IsNull() ? myIndices->NbElements : -1;
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::Edge(const Standard_Integer anIndex ) const
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::Edge (const Standard_Integer theIndex) const
|
||||
{
|
||||
Standard_Integer index=0;
|
||||
if( myPrimitiveArray && myPrimitiveArray->edge_vis &&
|
||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_edges) ) {
|
||||
index = myPrimitiveArray->edges[anIndex-1];
|
||||
} else {
|
||||
Standard_OutOfRange::Raise(" BAD EDGE index");
|
||||
if (myIndices.IsNull()
|
||||
|| theIndex <= 0
|
||||
|| theIndex > myIndices->NbElements)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD EDGE index");
|
||||
}
|
||||
return index+1;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::EdgeIsVisible(const Standard_Integer anIndex ) const
|
||||
{
|
||||
Standard_Boolean isVisible = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->edge_vis &&
|
||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_edges) ) {
|
||||
isVisible = (myPrimitiveArray->edge_vis[anIndex-1] == 0) ?
|
||||
Standard_False : Standard_True;
|
||||
} else {
|
||||
Standard_OutOfRange::Raise(" BAD EDGE index");
|
||||
}
|
||||
return isVisible;
|
||||
return Standard_Integer(myIndices->Index (theIndex - 1) + 1);
|
||||
}
|
||||
|
||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasBoundColors() const
|
||||
{
|
||||
Standard_Boolean defined = Standard_False;
|
||||
if( myPrimitiveArray && myPrimitiveArray->fcolours ) defined = Standard_True;
|
||||
return defined;
|
||||
return !myBounds.IsNull() && myBounds->Colors != NULL;
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::BoundNumber() const
|
||||
{
|
||||
Standard_Integer number = -1;
|
||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_bounds;
|
||||
return number;
|
||||
return !myBounds.IsNull() ? myBounds->NbBounds : -1;
|
||||
}
|
||||
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::Bound(const Standard_Integer anIndex) const
|
||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::Bound (const Standard_Integer theIndex) const
|
||||
{
|
||||
Standard_Integer number=-1;
|
||||
if( myPrimitiveArray && myPrimitiveArray->bounds &&
|
||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) {
|
||||
number = myPrimitiveArray->bounds[anIndex-1];
|
||||
} else {
|
||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
||||
if (myBounds.IsNull()
|
||||
|| theIndex <= 0
|
||||
|| theIndex > myBounds->NbBounds)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("BAD BOUND index");
|
||||
}
|
||||
return number;
|
||||
return myBounds->Bounds[theIndex - 1];
|
||||
}
|
||||
|
||||
inline void Graphic3d_ArrayOfPrimitives::BoundColor(const Standard_Integer anIndex,
|
||||
Standard_Real& R, Standard_Real& G, Standard_Real& B) const
|
||||
inline void Graphic3d_ArrayOfPrimitives::BoundColor (const Standard_Integer theIndex,
|
||||
Standard_Real& theR,
|
||||
Standard_Real& theG,
|
||||
Standard_Real& theB) const
|
||||
{
|
||||
if( myPrimitiveArray && myPrimitiveArray->fcolours &&
|
||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) {
|
||||
Tfloat *p = myPrimitiveArray->fcolours[anIndex-1].rgb;
|
||||
R = Standard_Real(*p++); G = Standard_Real(*p++); B = Standard_Real(*p);
|
||||
} else {
|
||||
if (myBounds.IsNull()
|
||||
|| myBounds->Colors == NULL
|
||||
|| theIndex <= 0
|
||||
|| theIndex > myBounds->NbBounds)
|
||||
{
|
||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
||||
}
|
||||
|
||||
const Graphic3d_Vec4& aVec = myBounds->Colors[theIndex - 1];
|
||||
theR = Standard_Real(aVec.r());
|
||||
theG = Standard_Real(aVec.g());
|
||||
theB = Standard_Real(aVec.b());
|
||||
}
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfQuadrangleStrips.ixx>
|
||||
|
||||
Graphic3d_ArrayOfQuadrangleStrips :: Graphic3d_ArrayOfQuadrangleStrips (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxStrips,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasSColors,
|
||||
const Standard_Boolean hasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_QUADRANGLESTRIPS,maxVertexs,maxStrips,0,hasVNormals,hasVColors,hasSColors,hasVTexels,Standard_False) {}
|
||||
Graphic3d_ArrayOfQuadrangleStrips::Graphic3d_ArrayOfQuadrangleStrips (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxStrips,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasSColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
|
||||
{}
|
||||
|
@ -31,8 +31,7 @@ is
|
||||
maxEdges: Integer from Standard = 0;
|
||||
hasVNormals: Boolean from Standard = Standard_False;
|
||||
hasVColors: Boolean from Standard = Standard_False;
|
||||
hasTexels: Boolean from Standard = Standard_False;
|
||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
||||
hasTexels: Boolean from Standard = Standard_False)
|
||||
returns mutable ArrayOfQuadrangles from Graphic3d;
|
||||
---Purpose: Creates an array of quadrangles,
|
||||
-- a quadrangle can be filled as:
|
||||
@ -71,9 +70,6 @@ is
|
||||
-- When <hasTexels> is TRUE , you must use one of
|
||||
-- AddVertex(Point,Texel)
|
||||
-- or AddVertex(Point,Normal,Texel) methods.
|
||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddEdge(number,visibillity) method.
|
||||
-- Warning:
|
||||
-- the user is responsible about the orientation of the quadrangle
|
||||
-- depending of the order of the created vertex or edges and this
|
||||
|
@ -14,11 +14,10 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfQuadrangles.ixx>
|
||||
|
||||
Graphic3d_ArrayOfQuadrangles :: Graphic3d_ArrayOfQuadrangles (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxEdges,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasVTexels,
|
||||
const Standard_Boolean hasEdgesInfos)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_QUADRANGLES,maxVertexs,0,maxEdges,hasVNormals,hasVColors,Standard_False,hasVTexels,hasEdgesInfos) {}
|
||||
Graphic3d_ArrayOfQuadrangles::Graphic3d_ArrayOfQuadrangles (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxEdges,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
|
||||
{}
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfSegments.ixx>
|
||||
|
||||
Graphic3d_ArrayOfSegments :: Graphic3d_ArrayOfSegments (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxEdges,
|
||||
const Standard_Boolean hasVColors)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_SEGMENTS,maxVertexs,0,maxEdges,Standard_False,hasVColors,Standard_False,Standard_False,Standard_False) {}
|
||||
Graphic3d_ArrayOfSegments::Graphic3d_ArrayOfSegments (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxEdges,
|
||||
const Standard_Boolean theHasVColors)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, Standard_False, theHasVColors, Standard_False, Standard_False)
|
||||
{}
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangleFans.ixx>
|
||||
|
||||
Graphic3d_ArrayOfTriangleFans :: Graphic3d_ArrayOfTriangleFans (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxFans,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasFColors,
|
||||
const Standard_Boolean hasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLEFANS,maxVertexs,maxFans,0,hasVNormals,hasVColors,hasFColors,hasVTexels,Standard_False) {}
|
||||
Graphic3d_ArrayOfTriangleFans::Graphic3d_ArrayOfTriangleFans (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxFans,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasFColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLEFANS, theMaxVertexs, theMaxFans, 0, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
|
||||
{}
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangleStrips.ixx>
|
||||
|
||||
Graphic3d_ArrayOfTriangleStrips :: Graphic3d_ArrayOfTriangleStrips (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxStrips,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasSColors,
|
||||
const Standard_Boolean hasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLESTRIPS,maxVertexs,maxStrips,0,hasVNormals,hasVColors,hasSColors,hasVTexels,Standard_False) {}
|
||||
Graphic3d_ArrayOfTriangleStrips::Graphic3d_ArrayOfTriangleStrips (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxStrips,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasSColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
|
||||
{}
|
||||
|
@ -22,8 +22,7 @@ is
|
||||
maxEdges: Integer from Standard = 0;
|
||||
hasVNormals: Boolean from Standard = Standard_False;
|
||||
hasVColors: Boolean from Standard = Standard_False;
|
||||
hasTexels: Boolean from Standard = Standard_False;
|
||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
||||
hasTexels: Boolean from Standard = Standard_False)
|
||||
returns mutable ArrayOfTriangles from Graphic3d;
|
||||
---Purpose: Creates an array of triangles,
|
||||
-- a triangle can be filled as:
|
||||
@ -60,9 +59,6 @@ is
|
||||
-- When <hasTexels> is TRUE , you must use one of
|
||||
-- AddVertex(Point,Texel)
|
||||
-- or AddVertex(Point,Normal,Texel) methods.
|
||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
||||
-- you must use the
|
||||
-- AddEdge(number,visibillity) method.
|
||||
-- Warning:
|
||||
-- the user is responsible about the orientation of the triangle
|
||||
-- depending of the order of the created vertex or edges and this
|
||||
|
@ -14,11 +14,10 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.ixx>
|
||||
|
||||
Graphic3d_ArrayOfTriangles :: Graphic3d_ArrayOfTriangles (
|
||||
const Standard_Integer maxVertexs,
|
||||
const Standard_Integer maxEdges,
|
||||
const Standard_Boolean hasVNormals,
|
||||
const Standard_Boolean hasVColors,
|
||||
const Standard_Boolean hasVTexels,
|
||||
const Standard_Boolean hasEdgeInfos)
|
||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLES,maxVertexs,0,maxEdges,hasVNormals,hasVColors,Standard_False,hasVTexels,hasEdgeInfos) {}
|
||||
Graphic3d_ArrayOfTriangles::Graphic3d_ArrayOfTriangles (const Standard_Integer theMaxVertexs,
|
||||
const Standard_Integer theMaxEdges,
|
||||
const Standard_Boolean theHasVNormals,
|
||||
const Standard_Boolean theHasVColors,
|
||||
const Standard_Boolean theHasVTexels)
|
||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
|
||||
{}
|
||||
|
70
src/Graphic3d/Graphic3d_BoundBuffer.hxx
Normal file
70
src/Graphic3d/Graphic3d_BoundBuffer.hxx
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_BoundBuffer_HeaderFile
|
||||
#define _Graphic3d_BoundBuffer_HeaderFile
|
||||
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
|
||||
//! Bounds buffer.
|
||||
class Graphic3d_BoundBuffer : public NCollection_Buffer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Graphic3d_BoundBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
|
||||
: NCollection_Buffer (theAlloc),
|
||||
Colors (NULL),
|
||||
Bounds (NULL),
|
||||
NbBounds (0) {}
|
||||
|
||||
//! Allocates new empty array
|
||||
bool Init (const Standard_Integer theNbBounds,
|
||||
const Standard_Boolean theHasColors)
|
||||
{
|
||||
Colors = NULL;
|
||||
Bounds = NULL;
|
||||
NbBounds = 0;
|
||||
Free();
|
||||
if (theNbBounds < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t aBoundsSize = sizeof(Standard_Integer) * theNbBounds;
|
||||
const size_t aColorsSize = theHasColors
|
||||
? sizeof(Graphic3d_Vec4) * theNbBounds
|
||||
: 0;
|
||||
if (!Allocate (aColorsSize + aBoundsSize))
|
||||
{
|
||||
Free();
|
||||
return false;
|
||||
}
|
||||
|
||||
NbBounds = theNbBounds;
|
||||
Colors = theHasColors ? reinterpret_cast<Graphic3d_Vec4* >(myData) : NULL;
|
||||
Bounds = reinterpret_cast<Standard_Integer* >(theHasColors ? (myData + aColorsSize) : myData);
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Graphic3d_Vec4* Colors; //!< pointer to facet color values
|
||||
Standard_Integer* Bounds; //!< pointer to bounds array
|
||||
Standard_Integer NbBounds; //!< number of bounds
|
||||
|
||||
};
|
||||
|
||||
typedef NCollection_Handle<Graphic3d_BoundBuffer> Handle(Graphic3d_BoundBuffer);
|
||||
|
||||
#endif // _Graphic3d_BoundBuffer_HeaderFile
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@ -11,14 +11,10 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
/*
|
||||
File Graphic3d_PrimitiveArray.hxx
|
||||
Created 16/06/2000 : ATS : G005 : This structure is an enumeration of all internal structures for PARRAY primitives
|
||||
*/
|
||||
#ifndef _Graphic3d_PrimitiveArray_HeaderFile
|
||||
#define _Graphic3d_PrimitiveArray_HeaderFile
|
||||
#ifndef _Graphic3d_BoundBuffer_Handle_HeaderFile
|
||||
#define _Graphic3d_BoundBuffer_Handle_HeaderFile
|
||||
|
||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
||||
typedef CALL_DEF_PARRAY *Graphic3d_PrimitiveArray;
|
||||
#include <Graphic3d_BoundBuffer.hxx>
|
||||
typedef Handle(Graphic3d_BoundBuffer) Graphic3d_BoundBuffer_Handle;
|
||||
|
||||
#endif /* _Graphic3d_PrimitiveArray_HeaderFile */
|
||||
#endif // _Graphic3d_BoundBuffer_Handle_HeaderFile
|
208
src/Graphic3d/Graphic3d_Buffer.hxx
Normal file
208
src/Graphic3d/Graphic3d_Buffer.hxx
Normal file
@ -0,0 +1,208 @@
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_Buffer_HeaderFile
|
||||
#define _Graphic3d_Buffer_HeaderFile
|
||||
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
//! Type of attribute in Vertex Buffer
|
||||
enum Graphic3d_TypeOfAttribute
|
||||
{
|
||||
Graphic3d_TOA_POS = 0, //!< vertex position
|
||||
Graphic3d_TOA_NORM, //!< normal
|
||||
Graphic3d_TOA_UV, //!< texture coordinates
|
||||
Graphic3d_TOA_COLOR, //!< per-vertex color
|
||||
Graphic3d_TOA_CUSTOM = 10, //!< custom attributes
|
||||
};
|
||||
|
||||
//! Type of the element in Vertex or Index Buffer
|
||||
enum Graphic3d_TypeOfData
|
||||
{
|
||||
Graphic3d_TOD_USHORT, //!< unsigned 16-bit integer
|
||||
Graphic3d_TOD_UINT, //!< unsigned 32-bit integer
|
||||
Graphic3d_TOD_VEC2, //!< 2-components float vector
|
||||
Graphic3d_TOD_VEC3, //!< 3-components float vector
|
||||
Graphic3d_TOD_VEC4, //!< 4-components float vector
|
||||
Graphic3d_TOD_VEC4UB, //!< 4-components unsigned byte vector
|
||||
};
|
||||
|
||||
//! Vertex attribute definition.
|
||||
struct Graphic3d_Attribute
|
||||
{
|
||||
Graphic3d_TypeOfAttribute Id; //!< attribute identifier in vertex shader, 0 is reserved for vertex position
|
||||
Graphic3d_TypeOfData DataType; //!< vec2,vec3,vec4,vec4ub
|
||||
|
||||
Standard_Integer Stride() const { return Stride (DataType); }
|
||||
|
||||
//! @return size of attribute of specified data type
|
||||
static Standard_Integer Stride (const Graphic3d_TypeOfData theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case Graphic3d_TOD_USHORT: return sizeof(unsigned short);
|
||||
case Graphic3d_TOD_UINT: return sizeof(unsigned int);
|
||||
case Graphic3d_TOD_VEC2: return sizeof(Graphic3d_Vec2);
|
||||
case Graphic3d_TOD_VEC3: return sizeof(Graphic3d_Vec3);
|
||||
case Graphic3d_TOD_VEC4: return sizeof(Graphic3d_Vec4);
|
||||
case Graphic3d_TOD_VEC4UB: return sizeof(Graphic3d_Vec4ub);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//! Buffer of vertex attributes.
|
||||
class Graphic3d_Buffer : public NCollection_Buffer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Graphic3d_Buffer (const Handle(NCollection_BaseAllocator)& theAlloc)
|
||||
: NCollection_Buffer (theAlloc),
|
||||
Stride (0),
|
||||
NbElements (0),
|
||||
NbAttributes (0)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//! @return array of attributes definitions
|
||||
const Graphic3d_Attribute* AttributesArray() const
|
||||
{
|
||||
return (Graphic3d_Attribute* )(myData + mySize);
|
||||
}
|
||||
|
||||
//! @return attribute definition
|
||||
const Graphic3d_Attribute& Attribute (const Standard_Integer theAttribIndex) const
|
||||
{
|
||||
return AttributesArray()[theAttribIndex];
|
||||
}
|
||||
|
||||
//! @return attribute definition
|
||||
Graphic3d_Attribute& ChangeAttribute (const Standard_Integer theAttribIndex)
|
||||
{
|
||||
return *((Graphic3d_Attribute* )(myData + mySize) + theAttribIndex);
|
||||
}
|
||||
|
||||
//! @return data offset to specified attribute
|
||||
Standard_Integer AttributeOffset (const Standard_Integer theAttribIndex) const
|
||||
{
|
||||
Standard_Integer anOffset = 0;
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theAttribIndex; ++anAttribIter)
|
||||
{
|
||||
anOffset += Graphic3d_Attribute::Stride (Attribute (anAttribIter).DataType);
|
||||
}
|
||||
return anOffset;
|
||||
}
|
||||
|
||||
using NCollection_Buffer::Data;
|
||||
using NCollection_Buffer::ChangeData;
|
||||
|
||||
//! @return data for specified attribute
|
||||
const Standard_Byte* Data (const Standard_Integer theAttribIndex) const
|
||||
{
|
||||
return myData + AttributeOffset (theAttribIndex);
|
||||
}
|
||||
|
||||
//! @return data for specified attribute
|
||||
Standard_Byte* ChangeData (const Standard_Integer theAttribIndex)
|
||||
{
|
||||
return myData + AttributeOffset (theAttribIndex);
|
||||
}
|
||||
|
||||
//! Access specified element.
|
||||
inline const Standard_Byte* value (const Standard_Integer theElem) const
|
||||
{
|
||||
return myData + Stride * size_t(theElem);
|
||||
}
|
||||
|
||||
//! Access specified element.
|
||||
inline Standard_Byte* changeValue (const Standard_Integer theElem)
|
||||
{
|
||||
return myData + Stride * size_t(theElem);
|
||||
}
|
||||
|
||||
//! Access element with specified position and type.
|
||||
template <typename Type_t>
|
||||
inline const Type_t& Value (const Standard_Integer theElem) const
|
||||
{
|
||||
return *reinterpret_cast<const Type_t*>(value (theElem));
|
||||
}
|
||||
|
||||
//! Access element with specified position and type.
|
||||
template <typename Type_t>
|
||||
inline Type_t& ChangeValue (const Standard_Integer theElem)
|
||||
{
|
||||
return *reinterpret_cast<Type_t* >(changeValue (theElem));
|
||||
}
|
||||
|
||||
//! Release buffer.
|
||||
void release()
|
||||
{
|
||||
Free();
|
||||
Stride = 0;
|
||||
NbElements = 0;
|
||||
NbAttributes = 0;
|
||||
}
|
||||
|
||||
//! Allocates new empty array
|
||||
bool Init (const Standard_Integer theNbElems,
|
||||
const Graphic3d_Attribute* theAttribs,
|
||||
const Standard_Integer theNbAttribs)
|
||||
{
|
||||
release();
|
||||
Standard_Integer aStride = 0;
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theNbAttribs; ++anAttribIter)
|
||||
{
|
||||
const Graphic3d_Attribute& anAttrib = theAttribs[anAttribIter];
|
||||
aStride += anAttrib.Stride();
|
||||
}
|
||||
if (aStride == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Stride = aStride;
|
||||
NbElements = theNbElems;
|
||||
NbAttributes = theNbAttribs;
|
||||
if (NbElements != 0)
|
||||
{
|
||||
const size_t aDataSize = size_t(Stride) * size_t(NbElements);
|
||||
if (!Allocate (aDataSize + sizeof(Graphic3d_Attribute) * NbAttributes))
|
||||
{
|
||||
release();
|
||||
return false;
|
||||
}
|
||||
|
||||
mySize = aDataSize;
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theNbAttribs; ++anAttribIter)
|
||||
{
|
||||
ChangeAttribute (anAttribIter) = theAttribs[anAttribIter];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Standard_Integer Stride; //!< the distance to the attributes of the next vertex
|
||||
Standard_Integer NbElements; //!< number of the elements
|
||||
Standard_Integer NbAttributes; //!< number of vertex attributes
|
||||
|
||||
};
|
||||
|
||||
typedef NCollection_Handle<Graphic3d_Buffer> Handle(Graphic3d_Buffer);
|
||||
|
||||
#endif // _Graphic3d_Buffer_HeaderFile
|
20
src/Graphic3d/Graphic3d_Buffer_Handle.hxx
Normal file
20
src/Graphic3d/Graphic3d_Buffer_Handle.hxx
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_Buffer_Handle_HeaderFile
|
||||
#define _Graphic3d_Buffer_Handle_HeaderFile
|
||||
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
typedef Handle(Graphic3d_Buffer) Graphic3d_Buffer_Handle;
|
||||
|
||||
#endif // _Graphic3d_Buffer_Handle_HeaderFile
|
@ -79,7 +79,6 @@ uses
|
||||
Array2OfVertex from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
VerticalTextAlignment from Graphic3d,
|
||||
PrimitiveArray from Graphic3d,
|
||||
PtrFrameBuffer from Graphic3d,
|
||||
HArray1OfByte from TColStd,
|
||||
FillMethod from Aspect,
|
||||
|
@ -83,9 +83,12 @@ deferred class Group from Graphic3d inherits TShared
|
||||
Array1OfVertex from Graphic3d,
|
||||
Array2OfVertex from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
VerticalTextAlignment from Graphic3d,
|
||||
VerticalTextAlignment from Graphic3d,
|
||||
ArrayOfPrimitives from Graphic3d,
|
||||
ListOfPArray from Graphic3d,
|
||||
TypeOfPrimitiveArray from Graphic3d,
|
||||
IndexBuffer_Handle from Graphic3d,
|
||||
Buffer_Handle from Graphic3d,
|
||||
BoundBuffer_Handle from Graphic3d,
|
||||
TransModeFlags from Graphic3d,
|
||||
CBounds from Graphic3d,
|
||||
Ax2 from gp
|
||||
@ -365,9 +368,18 @@ deferred class Group from Graphic3d inherits TShared
|
||||
---Category: Methods to create Triangle
|
||||
---------------------------------------
|
||||
|
||||
AddPrimitiveArray (me : mutable;
|
||||
theType : TypeOfPrimitiveArray from Graphic3d;
|
||||
theIndices : IndexBuffer_Handle from Graphic3d;
|
||||
theAttribs : Buffer_Handle from Graphic3d;
|
||||
theBounds : BoundBuffer_Handle from Graphic3d;
|
||||
theToEvalMinMax : Boolean from Standard = Standard_True) is virtual;
|
||||
---Level: Public
|
||||
---Purpose: Adds an array of primitives for display
|
||||
|
||||
AddPrimitiveArray( me : mutable;
|
||||
thePrim : ArrayOfPrimitives from Graphic3d;
|
||||
theToEvalMinMax : Boolean from Standard = Standard_True ) is virtual;
|
||||
theToEvalMinMax : Boolean from Standard = Standard_True );
|
||||
---Level: Public
|
||||
---Purpose: Adds an array of primitives for display
|
||||
|
||||
@ -523,9 +535,6 @@ deferred class Group from Graphic3d inherits TShared
|
||||
ContextMarker : CAspectMarker from Graphic3d is protected;
|
||||
ContextText : CAspectText from Graphic3d is protected;
|
||||
|
||||
-- temporary field - to be removed
|
||||
myListOfPArray : ListOfPArray from Graphic3d is protected;
|
||||
|
||||
friends
|
||||
|
||||
class Structure from Graphic3d
|
||||
|
@ -988,30 +988,79 @@ void Graphic3d_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitive
|
||||
return;
|
||||
}
|
||||
|
||||
AddPrimitiveArray (thePrim->Type(), thePrim->Indices(), thePrim->Attributes(), thePrim->Bounds(), theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddPrimitiveArray
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& ,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& ,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted()
|
||||
|| theAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MyContainsFacet
|
||||
&& thePrim->Type() != Graphic3d_TOPA_POLYLINES
|
||||
&& thePrim->Type() != Graphic3d_TOPA_SEGMENTS
|
||||
&& thePrim->Type() != Graphic3d_TOPA_POINTS)
|
||||
&& theType != Graphic3d_TOPA_POLYLINES
|
||||
&& theType != Graphic3d_TOPA_SEGMENTS
|
||||
&& theType != Graphic3d_TOPA_POINTS)
|
||||
{
|
||||
myStructure->GroupsWithFacet (1);
|
||||
MyContainsFacet = Standard_True;
|
||||
}
|
||||
|
||||
MyIsEmpty = Standard_False;
|
||||
myListOfPArray.Append (thePrim);
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
Standard_Real x, y, z;
|
||||
const Standard_Integer aNbVerts = thePrim->VertexNumber();
|
||||
for (Standard_Integer aVertIter = 1; aVertIter <= aNbVerts; ++aVertIter)
|
||||
const Standard_Integer aNbVerts = theAttribs->NbElements;
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theAttribs->NbAttributes; ++anAttribIter)
|
||||
{
|
||||
thePrim->Vertice (aVertIter, x, y, z);
|
||||
if (x < myBounds.XMin) myBounds.XMin = Standard_ShortReal (x);
|
||||
if (y < myBounds.YMin) myBounds.YMin = Standard_ShortReal (y);
|
||||
if (z < myBounds.ZMin) myBounds.ZMin = Standard_ShortReal (z);
|
||||
if (x > myBounds.XMax) myBounds.XMax = Standard_ShortReal (x);
|
||||
if (y > myBounds.YMax) myBounds.YMax = Standard_ShortReal (y);
|
||||
if (z > myBounds.ZMax) myBounds.ZMax = Standard_ShortReal (z);
|
||||
const Graphic3d_Attribute& anAttrib = theAttribs->Attribute (anAttribIter);
|
||||
if (anAttrib.Id != Graphic3d_TOA_POS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const size_t anOffset = theAttribs->AttributeOffset (anAttribIter);
|
||||
switch (anAttrib.DataType)
|
||||
{
|
||||
case Graphic3d_TOD_VEC2:
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < aNbVerts; ++aVertIter)
|
||||
{
|
||||
const Graphic3d_Vec2& aVert = *reinterpret_cast<const Graphic3d_Vec2* >(theAttribs->value (aVertIter) + anOffset);
|
||||
if (aVert.x() < myBounds.XMin) myBounds.XMin = aVert.x();
|
||||
if (aVert.y() < myBounds.YMin) myBounds.YMin = aVert.y();
|
||||
if (aVert.x() > myBounds.XMax) myBounds.XMax = aVert.x();
|
||||
if (aVert.y() > myBounds.YMax) myBounds.YMax = aVert.y();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOD_VEC3:
|
||||
case Graphic3d_TOD_VEC4:
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < aNbVerts; ++aVertIter)
|
||||
{
|
||||
const Graphic3d_Vec3& aVert = *reinterpret_cast<const Graphic3d_Vec3* >(theAttribs->value (aVertIter) + anOffset);
|
||||
if (aVert.x() < myBounds.XMin) myBounds.XMin = aVert.x();
|
||||
if (aVert.y() < myBounds.YMin) myBounds.YMin = aVert.y();
|
||||
if (aVert.z() < myBounds.ZMin) myBounds.ZMin = aVert.z();
|
||||
if (aVert.x() > myBounds.XMax) myBounds.XMax = aVert.x();
|
||||
if (aVert.y() > myBounds.YMax) myBounds.YMax = aVert.y();
|
||||
if (aVert.z() > myBounds.ZMax) myBounds.ZMax = aVert.z();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
77
src/Graphic3d/Graphic3d_IndexBuffer.hxx
Normal file
77
src/Graphic3d/Graphic3d_IndexBuffer.hxx
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_IndexBuffer_HeaderFile
|
||||
#define _Graphic3d_IndexBuffer_HeaderFile
|
||||
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
|
||||
//! Index buffer.
|
||||
class Graphic3d_IndexBuffer : public Graphic3d_Buffer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Graphic3d_IndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
|
||||
: Graphic3d_Buffer (theAlloc) {}
|
||||
|
||||
//! Allocates new empty index array
|
||||
template<typename IndexType_t>
|
||||
bool Init (const Standard_Integer theNbElems)
|
||||
{
|
||||
release();
|
||||
Stride = sizeof(IndexType_t);
|
||||
if (Stride != sizeof(unsigned short)
|
||||
&& Stride != sizeof(unsigned int))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NbElements = theNbElems;
|
||||
NbAttributes = 0;
|
||||
if (NbElements != 0
|
||||
&& !Allocate (size_t(Stride) * size_t(NbElements)))
|
||||
{
|
||||
release();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Access index at specified position
|
||||
Standard_Integer Index (const Standard_Integer theIndex) const
|
||||
{
|
||||
return Stride == sizeof(unsigned short)
|
||||
? Standard_Integer(Value<unsigned short> (theIndex))
|
||||
: Standard_Integer(Value<unsigned int> (theIndex));
|
||||
}
|
||||
|
||||
//! Change index at specified position
|
||||
void SetIndex (const Standard_Integer theIndex,
|
||||
const Standard_Integer theValue)
|
||||
{
|
||||
if (Stride == sizeof(unsigned short))
|
||||
{
|
||||
ChangeValue<unsigned short> (theIndex) = (unsigned short )theValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeValue<unsigned int> (theIndex) = (unsigned int )theValue;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef NCollection_Handle<Graphic3d_IndexBuffer> Handle(Graphic3d_IndexBuffer);
|
||||
|
||||
#endif // _Graphic3d_IndexBuffer_HeaderFile
|
20
src/Graphic3d/Graphic3d_IndexBuffer_Handle.hxx
Normal file
20
src/Graphic3d/Graphic3d_IndexBuffer_Handle.hxx
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_IndexBuffer_Handle_HeaderFile
|
||||
#define _Graphic3d_IndexBuffer_Handle_HeaderFile
|
||||
|
||||
#include <Graphic3d_IndexBuffer.hxx>
|
||||
typedef Handle(Graphic3d_IndexBuffer) Graphic3d_IndexBuffer_Handle;
|
||||
|
||||
#endif // _Graphic3d_IndexBuffer_Handle_HeaderFile
|
@ -9,6 +9,5 @@ InterfaceGraphic_XWD.hxx
|
||||
InterfaceGraphic_wntio.hxx
|
||||
InterfaceGraphic_cPrintf.cxx
|
||||
InterfaceGraphic_Palette.c
|
||||
InterfaceGraphic_PrimitiveArray.hxx
|
||||
InterfaceGraphic_telem.hxx
|
||||
InterfaceGraphic_tgl_all.hxx
|
||||
|
@ -15,7 +15,7 @@
|
||||
#ifndef InterfaceGraphic_Graphic3dHeader
|
||||
#define InterfaceGraphic_Graphic3dHeader
|
||||
|
||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
/* COULEUR */
|
||||
|
@ -1,65 +0,0 @@
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _InterfaceGraphic_PrimitiveArray_header_file_
|
||||
#define _InterfaceGraphic_PrimitiveArray_header_file_
|
||||
|
||||
/*
|
||||
FILE: InterfaceGraphic_PrimitiveArray.hxx
|
||||
|
||||
Created 16/06/2000 : ATS,SPK : G005
|
||||
|
||||
This file contains definitios of internal structures for
|
||||
PARRAY and DARRAY primitives, used in OpenGl package for presentation
|
||||
|
||||
*/
|
||||
|
||||
#include <InterfaceGraphic_telem.hxx>
|
||||
|
||||
#define MVERTICE 1
|
||||
#define MVNORMAL 2
|
||||
#define MVCOLOR 4
|
||||
#define MVTEXEL 8
|
||||
|
||||
typedef enum {
|
||||
TelUnknownArrayType,
|
||||
TelPointsArrayType,
|
||||
TelPolylinesArrayType,
|
||||
TelSegmentsArrayType,
|
||||
TelPolygonsArrayType,
|
||||
TelTrianglesArrayType,
|
||||
TelQuadranglesArrayType,
|
||||
TelTriangleStripsArrayType,
|
||||
TelQuadrangleStripsArrayType,
|
||||
TelTriangleFansArrayType
|
||||
} TelPrimitivesArrayType;
|
||||
|
||||
typedef struct {
|
||||
TelPrimitivesArrayType type; /* Array type */
|
||||
Tint format; /* Array datas format */
|
||||
Tint num_vertexs; /* Number of vertexs */
|
||||
Tint num_bounds; /* Number of bounds */
|
||||
Tint num_edges; /* Number of edges */
|
||||
Tint *bounds; /* Bounds array */
|
||||
Tint *edges; /* Edges array vertex index */
|
||||
tel_colour fcolours; /* Facet colour values */
|
||||
tel_point vertices; /* Vertices */
|
||||
Tint *vcolours; /* Vertex colour values */
|
||||
tel_point vnormals; /* Vertex normals */
|
||||
tel_texture_coord vtexels; /* Texture Coordinates */
|
||||
Tchar *edge_vis; /* Edge visibility flag*/
|
||||
Tchar *keys; /* Vertex keys*/
|
||||
} CALL_DEF_PARRAY;
|
||||
|
||||
#endif /* _InterfaceGraphic_PrimitiveArray_header_file_ */
|
@ -29,7 +29,7 @@ class NCollection_Vec4
|
||||
public:
|
||||
|
||||
//! Returns the number of components.
|
||||
static size_t Length()
|
||||
static int Length()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
@ -257,22 +257,8 @@ void OpenGl_CappingAlgo::Init()
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_CappingAlgoFilter::CanRender (const OpenGl_Element* theElement)
|
||||
{
|
||||
const OpenGl_PrimitiveArray* aPArray =
|
||||
dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
||||
if (!aPArray)
|
||||
return Standard_False;
|
||||
|
||||
switch (aPArray->PArray()->type)
|
||||
{
|
||||
case TelPolygonsArrayType :
|
||||
case TelTrianglesArrayType :
|
||||
case TelQuadranglesArrayType :
|
||||
case TelTriangleStripsArrayType :
|
||||
case TelQuadrangleStripsArrayType :
|
||||
case TelTriangleFansArrayType :
|
||||
return Standard_True;
|
||||
|
||||
default:
|
||||
return Standard_False;
|
||||
}
|
||||
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
||||
return aPArray != NULL
|
||||
&& aPArray->DrawMode() >= GL_TRIANGLES
|
||||
&& aPArray->DrawMode() <= GL_POLYGON;
|
||||
}
|
||||
|
@ -43,12 +43,10 @@
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Graphic3d_CView.hxx>
|
||||
#include <Graphic3d_CStructure.hxx>
|
||||
#include <Graphic3d_TypeOfPrimitive.hxx>
|
||||
#include <Graphic3d_CPick.hxx>
|
||||
#include <Graphic3d_TextPath.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <Graphic3d_PrimitiveArray.hxx>
|
||||
#include <Graphic3d_CUserDraw.hxx>
|
||||
#include <Graphic3d_CGraduatedTrihedron.hxx>
|
||||
#include <Graphic3d_TypeOfComposition.hxx>
|
||||
|
@ -183,19 +183,22 @@ void OpenGl_Group::UpdateAspectText (const Standard_Boolean theIsGlobal)
|
||||
// function : AddPrimitiveArray
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted()
|
||||
|| !thePrim->IsValid())
|
||||
|| theAttribs.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray ((CALL_DEF_PARRAY *)thePrim->Array());
|
||||
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray (theType, theIndices, theAttribs, theBounds);
|
||||
AddElement (anArray);
|
||||
|
||||
Graphic3d_Group::AddPrimitiveArray (thePrim, theToEvalMinMax);
|
||||
Graphic3d_Group::AddPrimitiveArray (theType, theIndices, theAttribs, theBounds, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@ -61,8 +61,11 @@ public:
|
||||
Standard_EXPORT virtual void UpdateAspectText (const Standard_Boolean theIsGlobal);
|
||||
|
||||
//! Add primitive array element
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
|
||||
const Standard_Boolean theToEvalMinMax);
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax);
|
||||
|
||||
//! Add text element
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,47 +16,55 @@
|
||||
#ifndef OpenGl_PrimitiveArray_Header
|
||||
#define OpenGl_PrimitiveArray_Header
|
||||
|
||||
#include <OpenGl_VertexBuffer.hxx>
|
||||
#include <OpenGl_IndexBuffer.hxx>
|
||||
|
||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
|
||||
#include <Graphic3d_IndexBuffer.hxx>
|
||||
#include <Graphic3d_BoundBuffer.hxx>
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
struct OPENGL_SURF_PROP;
|
||||
|
||||
class OpenGl_PrimitiveArray : public OpenGl_Element
|
||||
{
|
||||
public:
|
||||
// OpenGL does not provie a constant for "none" draw mode.
|
||||
// OpenGL does not provide a constant for "none" draw mode.
|
||||
// So we define our own one that does not conflict with GL constants
|
||||
// and untilizes common GL invalid value
|
||||
// and utilizes common GL invalid value
|
||||
enum
|
||||
{
|
||||
DRAW_MODE_NONE = -1
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
OpenGl_PrimitiveArray (CALL_DEF_PARRAY* thePArray);
|
||||
OpenGl_PrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds);
|
||||
|
||||
//! Render primitives to the window
|
||||
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
virtual void Release (const Handle(OpenGl_Context)& theContext);
|
||||
|
||||
CALL_DEF_PARRAY* PArray() const { return myPArray; }
|
||||
//! @return primitive type (GL_LINES, GL_TRIANGLES and others)
|
||||
GLint DrawMode() const { return myDrawMode; }
|
||||
|
||||
//! @return indices array
|
||||
const Handle(Graphic3d_IndexBuffer)& Indices() const { return myIndices; }
|
||||
|
||||
//! @return attributes array
|
||||
const Handle(Graphic3d_Buffer)& Attributes() const { return myAttribs; }
|
||||
|
||||
//! @return bounds array
|
||||
const Handle(Graphic3d_BoundBuffer)& Bounds() const { return myBounds; }
|
||||
|
||||
private:
|
||||
|
||||
Standard_Boolean toDrawVbo() const
|
||||
{
|
||||
return !myVbos[VBOVertices].IsNull();
|
||||
}
|
||||
|
||||
//! VBO initialization procedures
|
||||
Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
void clearMemoryOwn() const;
|
||||
void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
|
||||
|
||||
//! Main procedure to draw array
|
||||
@ -66,7 +74,6 @@ private:
|
||||
const TEL_COLOUR* theInteriorColour,
|
||||
const TEL_COLOUR* theLineColour,
|
||||
const TEL_COLOUR* theEdgeColour,
|
||||
const OPENGL_SURF_PROP* theFaceProp,
|
||||
const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Auxiliary procedures
|
||||
@ -82,20 +89,14 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VBOEdges,
|
||||
VBOVertices,
|
||||
VBOVcolours,
|
||||
VBOVnormals,
|
||||
VBOVtexels,
|
||||
VBOMaxType
|
||||
} VBODataType;
|
||||
mutable Handle(OpenGl_IndexBuffer) myVboIndices;
|
||||
mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
|
||||
|
||||
mutable CALL_DEF_PARRAY* myPArray;
|
||||
mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType];
|
||||
GLint myDrawMode;
|
||||
mutable Standard_Boolean myIsVboInit;
|
||||
mutable Handle(Graphic3d_IndexBuffer) myIndices;
|
||||
mutable Handle(Graphic3d_Buffer) myAttribs;
|
||||
mutable Handle(Graphic3d_BoundBuffer) myBounds;
|
||||
GLint myDrawMode;
|
||||
mutable Standard_Boolean myIsVboInit;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -346,7 +346,7 @@ namespace OpenGl_Raytrace
|
||||
{
|
||||
OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem);
|
||||
return anArray != NULL
|
||||
&& anArray->PArray()->type >= TelPolygonsArrayType;
|
||||
&& anArray->DrawMode() >= GL_TRIANGLES;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@ -106,13 +106,15 @@ void OpenGl_VertexBuffer::Unbind (const Handle(OpenGl_Context)& theGlCtx) const
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// function : init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
bool OpenGl_VertexBuffer::init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData)
|
||||
const void* theData,
|
||||
const GLenum theDataType,
|
||||
const GLsizei theStride)
|
||||
{
|
||||
if (!Create (theGlCtx))
|
||||
{
|
||||
@ -120,138 +122,42 @@ bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
myDataType = GL_FLOAT;
|
||||
myDataType = theDataType;
|
||||
myComponentsNb = theComponentsNb;
|
||||
myElemsNb = theElemsNb;
|
||||
theGlCtx->core15->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLfloat), theData, GL_STATIC_DRAW);
|
||||
theGlCtx->core15->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * theStride, theData, GL_STATIC_DRAW);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SubData
|
||||
// function : subData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
bool OpenGl_VertexBuffer::subData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData)
|
||||
const void* theData,
|
||||
const GLenum theDataType)
|
||||
{
|
||||
if (!IsValid() || myDataType != GL_FLOAT ||
|
||||
if (!IsValid() || myDataType != theDataType ||
|
||||
theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
const size_t aDataSize = sizeOfGlType (theDataType);
|
||||
theGlCtx->core15->glBufferSubData (GetTarget(),
|
||||
GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLfloat), // offset in bytes
|
||||
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLfloat), // size in bytes
|
||||
GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize, // offset in bytes
|
||||
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize, // size in bytes
|
||||
theData);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // some dummy error
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData)
|
||||
{
|
||||
if (!Create (theGlCtx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
myDataType = GL_UNSIGNED_INT;
|
||||
myComponentsNb = theComponentsNb;
|
||||
myElemsNb = theElemsNb;
|
||||
theGlCtx->core15->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLuint), theData, GL_STATIC_DRAW);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SubData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData)
|
||||
{
|
||||
if (!IsValid() || myDataType != GL_UNSIGNED_INT
|
||||
|| theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
theGlCtx->core15->glBufferSubData (GetTarget(),
|
||||
GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLuint), // offset in bytes
|
||||
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLuint), // size in bytes
|
||||
theData);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData)
|
||||
{
|
||||
if (!Create (theGlCtx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
myDataType = GL_UNSIGNED_BYTE;
|
||||
myComponentsNb = theComponentsNb;
|
||||
myElemsNb = theElemsNb;
|
||||
theGlCtx->core15->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLubyte), theData, GL_STATIC_DRAW);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SubData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData)
|
||||
{
|
||||
if (!IsValid() || myDataType != GL_UNSIGNED_BYTE
|
||||
|| theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bind (theGlCtx);
|
||||
theGlCtx->core15->glBufferSubData (GetTarget(),
|
||||
GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLubyte), // offset in bytes
|
||||
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLubyte), // size in bytes
|
||||
theData);
|
||||
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||
Unbind (theGlCtx);
|
||||
return isDone;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BindVertexAttrib
|
||||
// purpose :
|
||||
@ -317,6 +223,8 @@ void OpenGl_VertexBuffer::BindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||
case GL_COLOR_ARRAY:
|
||||
{
|
||||
glColorPointer (static_cast<GLint> (myComponentsNb), myDataType, 0, NULL);
|
||||
glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
glEnable (GL_COLOR_MATERIAL);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@ -336,4 +244,44 @@ void OpenGl_VertexBuffer::UnbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||
}
|
||||
Unbind (theGlCtx);
|
||||
glDisableClientState (theMode);
|
||||
if (theMode == GL_COLOR_ARRAY)
|
||||
{
|
||||
glDisable (GL_COLOR_MATERIAL);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BindFixed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_VertexBuffer::BindFixed (const Handle(OpenGl_Context)& ) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BindFixedPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_VertexBuffer::BindFixedPosition (const Handle(OpenGl_Context)& ) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UnbindFixed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_VertexBuffer::UnbindFixed (const Handle(OpenGl_Context)& ) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasColorAttribute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_VertexBuffer::HasColorAttribute() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
#include <OpenGl_GlCore20.hxx>
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
class Handle(OpenGl_Context);
|
||||
class OpenGl_Context;
|
||||
#include <Graphic3d_IndexBuffer.hxx>
|
||||
|
||||
//! Vertex Buffer Object - is a general storage object for vertex attributes (position, normal, color).
|
||||
//! Notice that you should use OpenGl_IndexBuffer specialization for array of indices.
|
||||
@ -82,28 +82,49 @@ public:
|
||||
//! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||
//! @param theElemsNb - elements count;
|
||||
//! @param theData - pointer to GLfloat data (vertices/normals etc.).
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData);
|
||||
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData)
|
||||
{
|
||||
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_FLOAT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||
//! @param theElemsNb - elements count;
|
||||
//! @param theData - pointer to GLuint data (indices etc.).
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData);
|
||||
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData)
|
||||
{
|
||||
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_INT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||
//! @param theElemsNb - elements count;
|
||||
//! @param theData - pointer to GLushort data (indices etc.).
|
||||
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLushort* theData)
|
||||
{
|
||||
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_SHORT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||
//! @param theElemsNb - elements count;
|
||||
//! @param theData - pointer to GLubyte data (indices/colors etc.).
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData);
|
||||
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData)
|
||||
{
|
||||
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_BYTE);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
||||
@ -111,10 +132,13 @@ public:
|
||||
//! @param theElemFrom - element id from which replace buffer data (>=0);
|
||||
//! @param theElemsNb - elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||
//! @param theData - pointer to GLfloat data.
|
||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData);
|
||||
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLfloat* theData)
|
||||
{
|
||||
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
||||
@ -122,10 +146,27 @@ public:
|
||||
//! @param theElemFrom element id from which replace buffer data (>=0);
|
||||
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||
//! @param theData pointer to GLuint data.
|
||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData);
|
||||
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLuint* theData)
|
||||
{
|
||||
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_INT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
||||
//! The VBO should be initialized before call.
|
||||
//! @param theElemFrom element id from which replace buffer data (>=0);
|
||||
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||
//! @param theData pointer to GLushort data.
|
||||
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLushort* theData)
|
||||
{
|
||||
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_SHORT);
|
||||
}
|
||||
|
||||
//! Notice that VBO will be unbound after this call.
|
||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
||||
@ -133,10 +174,13 @@ public:
|
||||
//! @param theElemFrom element id from which replace buffer data (>=0);
|
||||
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||
//! @param theData pointer to GLubyte data.
|
||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData);
|
||||
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const GLubyte* theData)
|
||||
{
|
||||
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
|
||||
}
|
||||
|
||||
//! Bind this VBO to active GLSL program.
|
||||
Standard_EXPORT void BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
|
||||
@ -158,6 +202,129 @@ public:
|
||||
Standard_EXPORT void UnbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLenum theMode) const;
|
||||
|
||||
public: //! @name advanced methods
|
||||
|
||||
//! @return size of specified GL type
|
||||
static size_t sizeOfGlType (const GLenum theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case GL_BYTE:
|
||||
case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
|
||||
case GL_SHORT:
|
||||
case GL_UNSIGNED_SHORT: return sizeof(GLushort);
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT: return sizeof(GLuint);
|
||||
case GL_FLOAT: return sizeof(GLfloat);
|
||||
case GL_DOUBLE: return sizeof(GLdouble);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Initialize buffer with new data.
|
||||
Standard_EXPORT bool init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const void* theData,
|
||||
const GLenum theDataType,
|
||||
const GLsizei theStride);
|
||||
|
||||
//! Initialize buffer with new data.
|
||||
bool init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint theComponentsNb,
|
||||
const GLsizei theElemsNb,
|
||||
const void* theData,
|
||||
const GLenum theDataType)
|
||||
{
|
||||
return init (theGlCtx, theComponentsNb, theElemsNb, theData, theDataType, GLsizei(theComponentsNb) * GLsizei(sizeOfGlType (theDataType)));
|
||||
}
|
||||
|
||||
//! Update part of the buffer with new data.
|
||||
Standard_EXPORT bool subData (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLsizei theElemFrom,
|
||||
const GLsizei theElemsNb,
|
||||
const void* theData,
|
||||
const GLenum theDataType);
|
||||
|
||||
//! Setup FFP array pointer.
|
||||
static void bindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const Graphic3d_TypeOfAttribute theMode,
|
||||
const GLint theNbComp,
|
||||
const GLenum theDataType,
|
||||
const GLsizei theStride,
|
||||
const GLvoid* theOffset)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_TOA_POS:
|
||||
{
|
||||
theGlCtx->core11->glEnableClientState (GL_VERTEX_ARRAY);
|
||||
theGlCtx->core11->glVertexPointer (theNbComp, theDataType, theStride, theOffset);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOA_NORM:
|
||||
{
|
||||
theGlCtx->core11->glEnableClientState (GL_NORMAL_ARRAY);
|
||||
theGlCtx->core11->glNormalPointer (theDataType, theStride, theOffset);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOA_UV:
|
||||
{
|
||||
theGlCtx->core11->glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
theGlCtx->core11->glTexCoordPointer (theNbComp, theDataType, theStride, theOffset);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOA_COLOR:
|
||||
{
|
||||
theGlCtx->core11->glEnableClientState (GL_COLOR_ARRAY);
|
||||
theGlCtx->core11->glColorPointer (theNbComp, theDataType, theStride, theOffset);
|
||||
theGlCtx->core11->glColorMaterial (GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
theGlCtx->core11fwd->glEnable (GL_COLOR_MATERIAL);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOA_CUSTOM:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Disable FFP array pointer.
|
||||
static void unbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const Graphic3d_TypeOfAttribute theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_TOA_POS: theGlCtx->core11->glDisableClientState (GL_VERTEX_ARRAY); break;
|
||||
case Graphic3d_TOA_NORM: theGlCtx->core11->glDisableClientState (GL_NORMAL_ARRAY); break;
|
||||
case Graphic3d_TOA_UV: theGlCtx->core11->glDisableClientState (GL_TEXTURE_COORD_ARRAY); break;
|
||||
case Graphic3d_TOA_COLOR:
|
||||
{
|
||||
theGlCtx->core11->glDisableClientState (GL_COLOR_ARRAY);
|
||||
theGlCtx->core11fwd->glDisable (GL_COLOR_MATERIAL);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOA_CUSTOM:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public: //! @name methods for interleaved attributes array
|
||||
|
||||
//! Bind all vertex attributes. Default implementation does nothing.
|
||||
Standard_EXPORT virtual void BindFixed (const Handle(OpenGl_Context)& theGlCtx) const;
|
||||
|
||||
//! Bind all vertex position attribute only. Default implementation does nothing.
|
||||
Standard_EXPORT virtual void BindFixedPosition (const Handle(OpenGl_Context)& theGlCtx) const;
|
||||
|
||||
//! Unbind all vertex attributes. Default implementation does nothing.
|
||||
Standard_EXPORT virtual void UnbindFixed (const Handle(OpenGl_Context)& theGlCtx) const;
|
||||
|
||||
//! @return true if buffer contains per-vertex color attribute
|
||||
Standard_EXPORT virtual bool HasColorAttribute() const;
|
||||
|
||||
protected:
|
||||
|
||||
GLuint myBufferId; //!< VBO name (index)
|
||||
|
@ -380,32 +380,53 @@ protected: //! @name methods related to ray-tracing
|
||||
const OpenGl_PrimitiveArray* theArray, int theMatID, const Standard_ShortReal* theTrans);
|
||||
|
||||
//! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
|
||||
const OpenGl_PrimitiveArray& theArray,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL triangle fan array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL triangle strip array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL quadrangle array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Adds OpenGL polygon array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
||||
Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID);
|
||||
|
||||
//! Loads and compiles shader object from specified source.
|
||||
Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);
|
||||
|
@ -452,100 +452,114 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
|
||||
// function : AddRaytracePrimitiveArray
|
||||
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
||||
const OpenGl_PrimitiveArray* theArray, Standard_Integer theMatID, const Standard_ShortReal* theTransform)
|
||||
OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||
Standard_Integer theMatID,
|
||||
const Standard_ShortReal* theTransform)
|
||||
{
|
||||
CALL_DEF_PARRAY* aPArray = theArray->PArray();
|
||||
|
||||
if (aPArray->type != TelPolygonsArrayType &&
|
||||
aPArray->type != TelTrianglesArrayType &&
|
||||
aPArray->type != TelQuadranglesArrayType &&
|
||||
aPArray->type != TelTriangleFansArrayType &&
|
||||
aPArray->type != TelTriangleStripsArrayType &&
|
||||
aPArray->type != TelQuadrangleStripsArrayType)
|
||||
const Handle(Graphic3d_IndexBuffer)& anIndices = theArray->Indices();
|
||||
const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes();
|
||||
const Handle(Graphic3d_BoundBuffer)& aBounds = theArray->Bounds();
|
||||
if (theArray->DrawMode() < GL_TRIANGLES
|
||||
|| theArray->DrawMode() > GL_POLYGON
|
||||
|| anAttribs.IsNull())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (aPArray->vertices == NULL)
|
||||
return NULL;
|
||||
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
switch (aPArray->type)
|
||||
switch (aPArray->DrawMode())
|
||||
{
|
||||
case TelPolygonsArrayType:
|
||||
std::cout << "\tAdding TelPolygonsArrayType" << std::endl; break;
|
||||
case TelTrianglesArrayType:
|
||||
std::cout << "\tAdding TelTrianglesArrayType" << std::endl; break;
|
||||
case TelQuadranglesArrayType:
|
||||
std::cout << "\tAdding TelQuadranglesArrayType" << std::endl; break;
|
||||
case TelTriangleFansArrayType:
|
||||
std::cout << "\tAdding TelTriangleFansArrayType" << std::endl; break;
|
||||
case TelTriangleStripsArrayType:
|
||||
std::cout << "\tAdding TelTriangleStripsArrayType" << std::endl; break;
|
||||
case TelQuadrangleStripsArrayType:
|
||||
std::cout << "\tAdding TelQuadrangleStripsArrayType" << std::endl; break;
|
||||
case GL_POLYGON: std::cout << "\tAdding GL_POLYGON\n"; break;
|
||||
case GL_TRIANGLES: std::cout << "\tAdding GL_TRIANGLES\n"; break;
|
||||
case GL_QUADS: std::cout << "\tAdding GL_QUADS\n"; break;
|
||||
case GL_TRIANGLE_FAN: std::cout << "\tAdding GL_TRIANGLE_FAN\n"; break;
|
||||
case GL_TRIANGLE_STRIP: std::cout << "\tAdding GL_TRIANGLE_STRIP\n"; break;
|
||||
case GL_QUAD_STRIP: std::cout << "\tAdding GL_QUAD_STRIP\n"; break;
|
||||
}
|
||||
#endif
|
||||
|
||||
OpenGl_TriangleSet* aSet = new OpenGl_TriangleSet (theArray);
|
||||
|
||||
{
|
||||
aSet->Vertices.reserve (aPArray->num_vertexs);
|
||||
|
||||
for (Standard_Integer aVert = 0; aVert < aPArray->num_vertexs; ++aVert)
|
||||
aSet->Vertices.reserve (anAttribs->NbElements);
|
||||
aSet->Normals .reserve (anAttribs->NbElements);
|
||||
const size_t aVertFrom = aSet->Vertices.size();
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < anAttribs->NbAttributes; ++anAttribIter)
|
||||
{
|
||||
BVH_Vec4f aVertex (aPArray->vertices[aVert].xyz[0],
|
||||
aPArray->vertices[aVert].xyz[1],
|
||||
aPArray->vertices[aVert].xyz[2],
|
||||
1.f);
|
||||
if (theTransform)
|
||||
aVertex = MatVecMult (theTransform, aVertex);
|
||||
|
||||
aSet->Vertices.push_back (aVertex);
|
||||
}
|
||||
|
||||
aSet->Normals.reserve (aPArray->num_vertexs);
|
||||
|
||||
for (Standard_Integer aNorm = 0; aNorm < aPArray->num_vertexs; ++aNorm)
|
||||
{
|
||||
BVH_Vec4f aNormal;
|
||||
|
||||
// Note: In case of absence of normals, the
|
||||
// renderer uses generated geometric normals
|
||||
|
||||
if (aPArray->vnormals != NULL)
|
||||
const Graphic3d_Attribute& anAttrib = anAttribs->Attribute (anAttribIter);
|
||||
const size_t anOffset = anAttribs->AttributeOffset (anAttribIter);
|
||||
if (anAttrib.Id == Graphic3d_TOA_POS)
|
||||
{
|
||||
aNormal = BVH_Vec4f (aPArray->vnormals[aNorm].xyz[0],
|
||||
aPArray->vnormals[aNorm].xyz[1],
|
||||
aPArray->vnormals[aNorm].xyz[2],
|
||||
0.f);
|
||||
|
||||
if (theTransform)
|
||||
aNormal = MatVecMult (theTransform, aNormal);
|
||||
if (anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4)
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < anAttribs->NbElements; ++aVertIter)
|
||||
{
|
||||
const Graphic3d_Vec3& aVert = *reinterpret_cast<const Graphic3d_Vec3* >(anAttribs->value (aVertIter) + anOffset);
|
||||
aSet->Vertices.push_back (BVH_Vec4f (aVert.x(), aVert.y(), aVert.z(), 1.0f));
|
||||
}
|
||||
}
|
||||
else if (anAttrib.DataType == Graphic3d_TOD_VEC2)
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < anAttribs->NbElements; ++aVertIter)
|
||||
{
|
||||
const Graphic3d_Vec2& aVert = *reinterpret_cast<const Graphic3d_Vec2* >(anAttribs->value (aVertIter) + anOffset);
|
||||
aSet->Vertices.push_back (BVH_Vec4f (aVert.x(), aVert.y(), 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (anAttrib.Id == Graphic3d_TOA_NORM)
|
||||
{
|
||||
if (anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4)
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < anAttribs->NbElements; ++aVertIter)
|
||||
{
|
||||
const Graphic3d_Vec3& aNorm = *reinterpret_cast<const Graphic3d_Vec3* >(anAttribs->value (aVertIter) + anOffset);
|
||||
aSet->Normals.push_back (BVH_Vec4f (aNorm.x(), aNorm.y(), aNorm.z(), 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aSet->Normals.push_back (aNormal);
|
||||
}
|
||||
|
||||
if (aPArray->num_bounds > 0)
|
||||
if (aSet->Normals.size() != aSet->Vertices.size())
|
||||
{
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < anAttribs->NbElements; ++aVertIter)
|
||||
{
|
||||
aSet->Normals.push_back (BVH_Vec4f());
|
||||
}
|
||||
}
|
||||
|
||||
if (theTransform)
|
||||
{
|
||||
for (size_t aVertIter = aVertFrom; aVertIter < aSet->Vertices.size(); ++aVertIter)
|
||||
{
|
||||
BVH_Vec4f& aVertex = aSet->Vertices[aVertIter];
|
||||
aVertex = MatVecMult (theTransform, aVertex);
|
||||
}
|
||||
for (size_t aVertIter = aVertFrom; aVertIter < aSet->Normals.size(); ++aVertIter)
|
||||
{
|
||||
BVH_Vec4f& aNorm = aSet->Normals[aVertIter];
|
||||
aNorm = MatVecMult (theTransform, aNorm);
|
||||
}
|
||||
}
|
||||
|
||||
if (!aBounds.IsNull())
|
||||
{
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "\tNumber of bounds = " << aPArray->num_bounds << std::endl;
|
||||
#endif
|
||||
|
||||
Standard_Integer aBoundStart = 0;
|
||||
|
||||
for (Standard_Integer aBound = 0; aBound < aPArray->num_bounds; ++aBound)
|
||||
for (Standard_Integer aBound = 0; aBound < aBounds->NbBounds; ++aBound)
|
||||
{
|
||||
const Standard_Integer aVertNum = aPArray->bounds[aBound];
|
||||
const Standard_Integer aVertNum = aBounds->Bounds[aBound];
|
||||
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "\tAdding indices from bound " << aBound << ": " <<
|
||||
aBoundStart << " .. " << aVertNum << std::endl;
|
||||
#endif
|
||||
|
||||
if (!AddRaytraceVertexIndices (aSet, aPArray, aBoundStart, aVertNum, theMatID))
|
||||
if (!AddRaytraceVertexIndices (*aSet, *theArray, aBoundStart, aVertNum, theMatID))
|
||||
{
|
||||
delete aSet;
|
||||
return NULL;
|
||||
@ -556,13 +570,13 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Integer aVertNum = aPArray->num_edges > 0 ? aPArray->num_edges : aPArray->num_vertexs;
|
||||
const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements;
|
||||
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "\tAdding indices from array: " << aVertNum << std::endl;
|
||||
#endif
|
||||
|
||||
if (!AddRaytraceVertexIndices (aSet, aPArray, 0, aVertNum, theMatID))
|
||||
if (!AddRaytraceVertexIndices (*aSet, *theArray, 0, aVertNum, theMatID))
|
||||
{
|
||||
delete aSet;
|
||||
return NULL;
|
||||
@ -580,61 +594,55 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
||||
// function : AddRaytraceVertexIndices
|
||||
// purpose : Adds vertex indices to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
|
||||
const OpenGl_PrimitiveArray& theArray,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
switch (theArray->type)
|
||||
switch (theArray.DrawMode())
|
||||
{
|
||||
case TelTrianglesArrayType:
|
||||
return AddRaytraceTriangleArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
|
||||
case TelQuadranglesArrayType:
|
||||
return AddRaytraceQuadrangleArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
|
||||
case TelTriangleFansArrayType:
|
||||
return AddRaytraceTriangleFanArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
|
||||
case TelTriangleStripsArrayType:
|
||||
return AddRaytraceTriangleStripArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
|
||||
case TelQuadrangleStripsArrayType:
|
||||
return AddRaytraceQuadrangleStripArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
|
||||
default:
|
||||
return AddRaytracePolygonArray (theSet, theArray, theOffset, theCount, theMatID);
|
||||
case GL_TRIANGLES: return AddRaytraceTriangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
case GL_QUADS: return AddRaytraceQuadrangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
case GL_TRIANGLE_FAN: return AddRaytraceTriangleFanArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
case GL_TRIANGLE_STRIP: return AddRaytraceTriangleStripArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
case GL_QUAD_STRIP: return AddRaytraceQuadrangleStripArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
case GL_POLYGON: return AddRaytracePolygonArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddRaytraceTriangleArray
|
||||
// purpose : Adds OpenGL triangle array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 3)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + theCount / 3);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + theCount / 3);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; aVert += 3)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
||||
theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||
theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; aVert += 3)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 1, aVert + 2,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,32 +653,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet*
|
||||
// function : AddRaytraceTriangleFanArray
|
||||
// purpose : Adds OpenGL triangle fan array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 3)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + theCount - 2);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + theCount - 2);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[theOffset],
|
||||
theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (theOffset),
|
||||
theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theOffset,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theOffset,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,32 +692,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleS
|
||||
// function : AddRaytraceTriangleStripArray
|
||||
// purpose : Adds OpenGL triangle strip array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 3)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + theCount - 2);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + theCount - 2);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset, aCW = 0; aVert < theOffset + theCount - 2; ++aVert, aCW = (aCW + 1) % 2)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + aCW ? 1 : 0],
|
||||
theArray->edges[aVert + aCW ? 0 : 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + aCW ? 1 : 0),
|
||||
theIndices->Index (aVert + aCW ? 0 : 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset, aCW = 0; aVert < theOffset + theCount - 2; ++aVert, aCW = (aCW + 1) % 2)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + aCW ? 1 : 0,
|
||||
aVert + aCW ? 0 : 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + aCW ? 1 : 0,
|
||||
aVert + aCW ? 0 : 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -717,42 +731,39 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_Triangl
|
||||
// function : AddRaytraceQuadrangleArray
|
||||
// purpose : Adds OpenGL quad array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 4)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + theCount / 2);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + theCount / 2);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 4)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
||||
theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
||||
theArray->edges[aVert + 2],
|
||||
theArray->edges[aVert + 3],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||
theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||
theIndices->Index (aVert + 2),
|
||||
theIndices->Index (aVert + 3),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 4)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||
aVert + 2,
|
||||
aVert + 3,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 1, aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 2, aVert + 3,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -763,42 +774,45 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleArray (OpenGl_TriangleSe
|
||||
// function : AddRaytraceQuadrangleStripArray
|
||||
// purpose : Adds OpenGL quad strip array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 4)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + 2 * theCount - 6);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + 2 * theCount - 6);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 2)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
||||
theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||
theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 3],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 3),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 2)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
|
||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 1,
|
||||
aVert + 3,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (aVert + 1,
|
||||
aVert + 3,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -809,32 +823,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_Trian
|
||||
// function : AddRaytracePolygonArray
|
||||
// purpose : Adds OpenGL polygon array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytracePolygonArray (OpenGl_TriangleSet* theSet,
|
||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
||||
Standard_Boolean OpenGl_Workspace::AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
Standard_Integer theOffset,
|
||||
Standard_Integer theCount,
|
||||
Standard_Integer theMatID)
|
||||
{
|
||||
if (theCount < 3)
|
||||
return Standard_True;
|
||||
|
||||
theSet->Elements.reserve (theSet->Elements.size() + theCount - 2);
|
||||
theSet.Elements.reserve (theSet.Elements.size() + theCount - 2);
|
||||
|
||||
if (theArray->num_edges > 0)
|
||||
if (!theIndices.IsNull())
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[theOffset],
|
||||
theArray->edges[aVert + 1],
|
||||
theArray->edges[aVert + 2],
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (theOffset),
|
||||
theIndices->Index (aVert + 1),
|
||||
theIndices->Index (aVert + 2),
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||
{
|
||||
theSet->Elements.push_back (BVH_Vec4i (theOffset,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
theSet.Elements.push_back (BVH_Vec4i (theOffset,
|
||||
aVert + 1,
|
||||
aVert + 2,
|
||||
theMatID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace
|
||||
TopLoc_Location aLoc;
|
||||
gp_Pnt p;
|
||||
Standard_Integer decal;
|
||||
Standard_Integer t[3], n[3];
|
||||
Standard_Integer n[3];
|
||||
Standard_Integer nbTriangles = 0, nbVertices = 0;
|
||||
Standard_Real aUmin (0.0), aUmax (0.0), aVmin (0.0), aVmax (0.0), dUmax (0.0), dVmax (0.0);
|
||||
|
||||
@ -132,9 +132,8 @@ namespace
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) aPArray
|
||||
= new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
|
||||
Standard_True, Standard_False, theHasTexels, Standard_True);
|
||||
Handle(Graphic3d_ArrayOfTriangles) aPArray = new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
|
||||
Standard_True, Standard_False, theHasTexels);
|
||||
for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
|
||||
{
|
||||
const TopoDS_Face& aFace = SST.CurrentFace();
|
||||
@ -184,7 +183,6 @@ namespace
|
||||
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
||||
for (Standard_Integer aTriIter = 1; aTriIter <= T->NbTriangles(); ++aTriIter)
|
||||
{
|
||||
pc.Triangles (aTriIter, t[0], t[1], t[2]);
|
||||
if (SST.Orientation (aFace) == TopAbs_REVERSED)
|
||||
aTriangles (aTriIter).Get (n[0], n[2], n[1]);
|
||||
else
|
||||
@ -214,9 +212,9 @@ namespace
|
||||
V1.Cross (V2);
|
||||
if (V1.SquareMagnitude() > aPreci)
|
||||
{
|
||||
aPArray->AddEdge (n[0] + decal, t[0] == 0);
|
||||
aPArray->AddEdge (n[1] + decal, t[1] == 0);
|
||||
aPArray->AddEdge (n[2] + decal, t[2] == 0);
|
||||
aPArray->AddEdge (n[0] + decal);
|
||||
aPArray->AddEdge (n[1] + decal);
|
||||
aPArray->AddEdge (n[2] + decal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3186,8 +3186,8 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
|
||||
// Parsing array description
|
||||
Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
|
||||
Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
|
||||
hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
|
||||
Standard_Boolean hasVColors, hasBColors, hasNormals, hasTexels;
|
||||
hasVColors = hasNormals = hasBColors = hasTexels = Standard_False;
|
||||
|
||||
Standard_Integer anArgIndex = 0;
|
||||
Standard_Integer anArgsCount = myArrayDescription->Length();
|
||||
@ -3228,10 +3228,6 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
// edge command
|
||||
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
||||
{
|
||||
// edge has a hide flag
|
||||
if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
|
||||
hasInfos = Standard_True;
|
||||
|
||||
aEdgeNum++;
|
||||
}
|
||||
// unknown command
|
||||
@ -3248,10 +3244,10 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
|
||||
else if (anArrayType == "polylines")
|
||||
anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
|
||||
hasVColors, hasBColors, hasInfos);
|
||||
hasVColors, hasBColors);
|
||||
else if (anArrayType == "triangles")
|
||||
anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
|
||||
hasVColors, hasTexels, hasInfos);
|
||||
hasVColors, hasTexels);
|
||||
else if (anArrayType == "trianglefans")
|
||||
anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
|
||||
hasNormals, hasVColors,
|
||||
@ -3263,7 +3259,7 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
else if (anArrayType == "quads")
|
||||
anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
|
||||
hasNormals, hasVColors,
|
||||
hasTexels, hasInfos);
|
||||
hasTexels);
|
||||
else if (anArrayType == "quadstrips")
|
||||
anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
|
||||
hasNormals, hasVColors,
|
||||
@ -3271,7 +3267,7 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
else if (anArrayType == "polygons")
|
||||
anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
|
||||
hasNormals, hasVColors, hasBColors,
|
||||
hasTexels, hasInfos);
|
||||
hasTexels);
|
||||
|
||||
anArgIndex = 1;
|
||||
while (anArgIndex < anArgsCount)
|
||||
@ -3287,22 +3283,23 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
anArray->AddVertex (myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||
const Standard_Integer aVertIndex = anArray->VertexNumber();
|
||||
|
||||
// vertex has a normal or normal with color or texel
|
||||
if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
|
||||
anArray->SetVertexNormal (anArray->VertexNumber (),
|
||||
anArray->SetVertexNormal (aVertIndex,
|
||||
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||
|
||||
if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
|
||||
anArray->SetVertexColor (anArray->VertexNumber (),
|
||||
anArray->SetVertexColor (aVertIndex,
|
||||
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||
|
||||
if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
|
||||
anArray->SetVertexTexel (anArray->VertexNumber (),
|
||||
anArray->SetVertexTexel (aVertIndex,
|
||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||
}
|
||||
@ -3323,13 +3320,8 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
||||
// edge command
|
||||
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
||||
{
|
||||
Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
|
||||
|
||||
// edge has/hasn't hide flag
|
||||
if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
|
||||
anArray->AddEdge (aVertIndex, Standard_False);
|
||||
else
|
||||
anArray->AddEdge (aVertIndex, Standard_True);
|
||||
const Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
|
||||
anArray->AddEdge (aVertIndex);
|
||||
}
|
||||
// unknown command
|
||||
else
|
||||
@ -3420,7 +3412,7 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
|
||||
<< " vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
|
||||
<< " [texel={ 't' tx ty }] } \n"
|
||||
<< " bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n"
|
||||
<< " edges={ 'e' vertex_id [hidden_edge={'h'}] }\n";
|
||||
<< " edges={ 'e' vertex_id }\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5120,7 +5112,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__, VComputeHLR, group);
|
||||
|
||||
theCommands.Add("vdrawparray",
|
||||
"vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id [edge_hidden = { 'h' }] ]",
|
||||
"vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id ]",
|
||||
__FILE__,VDrawPArray,group);
|
||||
|
||||
theCommands.Add("vconnect",
|
||||
|
Loading…
x
Reference in New Issue
Block a user