mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-06 18:26: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 hasVNormals = myTriangulation->HasNormals();
|
||||||
Standard_Boolean hasVColors = (myFlagColor == 1);
|
Standard_Boolean hasVColors = (myFlagColor == 1);
|
||||||
|
|
||||||
Handle(Graphic3d_ArrayOfTriangles) anArray =
|
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (myNbNodes, myNbTriangles * 3,
|
||||||
new Graphic3d_ArrayOfTriangles ( myNbNodes, //maxVertexs
|
hasVNormals, hasVColors, Standard_False);
|
||||||
myNbTriangles * 3,//maxEdges
|
|
||||||
hasVNormals, //hasVNormals
|
|
||||||
hasVColors, //hasVColors
|
|
||||||
Standard_False, //hasTexels
|
|
||||||
Standard_True //hasEdgeInfos
|
|
||||||
);
|
|
||||||
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
|
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
|
||||||
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
|
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_CAspectFillArea.hxx
|
||||||
Graphic3d_CAspectLine.hxx
|
Graphic3d_CAspectLine.hxx
|
||||||
Graphic3d_CAspectMarker.hxx
|
Graphic3d_CAspectMarker.hxx
|
||||||
@ -34,7 +40,6 @@ Graphic3d_StructureManager.pxx
|
|||||||
Graphic3d.edl
|
Graphic3d.edl
|
||||||
Graphic3d_CMPLRS.edl
|
Graphic3d_CMPLRS.edl
|
||||||
Graphic3d_WOKSteps.edl
|
Graphic3d_WOKSteps.edl
|
||||||
Graphic3d_PrimitiveArray.hxx
|
|
||||||
Graphic3d_TransModeFlags.hxx
|
Graphic3d_TransModeFlags.hxx
|
||||||
Graphic3d_CTransPersStruct.hxx
|
Graphic3d_CTransPersStruct.hxx
|
||||||
Graphic3d_NListOfHAsciiString.hxx
|
Graphic3d_NListOfHAsciiString.hxx
|
||||||
|
@ -336,7 +336,13 @@ is
|
|||||||
-- Category: Imported types
|
-- Category: Imported types
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
imported PrimitiveArray;
|
imported Buffer;
|
||||||
|
imported Buffer_Handle;
|
||||||
|
imported BoundBuffer;
|
||||||
|
imported BoundBuffer_Handle;
|
||||||
|
imported IndexBuffer;
|
||||||
|
imported IndexBuffer_Handle;
|
||||||
|
|
||||||
imported BufferType;
|
imported BufferType;
|
||||||
|
|
||||||
imported CBitFields20;
|
imported CBitFields20;
|
||||||
@ -519,10 +525,6 @@ is
|
|||||||
-- Category: Instantiated classes
|
-- Category: Instantiated classes
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
class ListOfPArray instantiates
|
|
||||||
List from TCollection (ArrayOfPrimitives from Graphic3d);
|
|
||||||
---Category: Instantiated classes
|
|
||||||
|
|
||||||
class SequenceOfAddress instantiates
|
class SequenceOfAddress instantiates
|
||||||
Sequence from TCollection
|
Sequence from TCollection
|
||||||
(Address from Standard);
|
(Address from Standard);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfPoints.ixx>
|
#include <Graphic3d_ArrayOfPoints.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfPoints :: Graphic3d_ArrayOfPoints (const Standard_Integer maxVertexs,
|
Graphic3d_ArrayOfPoints::Graphic3d_ArrayOfPoints (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Boolean hasVColors)
|
const Standard_Boolean theHasVColors)
|
||||||
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POINTS, maxVertexs, 0, 0, Standard_False, hasVColors, Standard_False, Standard_False, Standard_False)
|
: 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;
|
hasVNormals: Boolean from Standard = Standard_False;
|
||||||
hasVColors: Boolean from Standard = Standard_False;
|
hasVColors: Boolean from Standard = Standard_False;
|
||||||
hasBColors: Boolean from Standard = Standard_False;
|
hasBColors: Boolean from Standard = Standard_False;
|
||||||
hasTexels: Boolean from Standard = Standard_False;
|
hasTexels: Boolean from Standard = Standard_False)
|
||||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
|
||||||
returns mutable ArrayOfPolygons from Graphic3d;
|
returns mutable ArrayOfPolygons from Graphic3d;
|
||||||
---Purpose: Creates an array of polygons,
|
---Purpose: Creates an array of polygons,
|
||||||
-- a polygon can be filled as:
|
-- a polygon can be filled as:
|
||||||
@ -105,9 +104,6 @@ is
|
|||||||
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
||||||
-- you must use the
|
-- you must use the
|
||||||
-- AddBound(number,Color) method.
|
-- AddBound(number,Color) method.
|
||||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
|
||||||
-- you must use the
|
|
||||||
-- AddEdge(number,visibillity) method.
|
|
||||||
-- Warning:
|
-- Warning:
|
||||||
-- the user is responsible about the orientation of the polygon
|
-- the user is responsible about the orientation of the polygon
|
||||||
-- depending of the order of the created vertex or edges and this
|
-- depending of the order of the created vertex or edges and this
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfPolygons.ixx>
|
#include <Graphic3d_ArrayOfPolygons.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfPolygons :: Graphic3d_ArrayOfPolygons (
|
Graphic3d_ArrayOfPolygons::Graphic3d_ArrayOfPolygons (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxBounds,
|
||||||
const Standard_Integer maxBounds,
|
const Standard_Integer theMaxEdges,
|
||||||
const Standard_Integer maxEdges,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasFColors,
|
||||||
const Standard_Boolean hasFColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels,
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYGONS, theMaxVertexs, theMaxBounds, theMaxEdges, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
|
||||||
const Standard_Boolean hasEdgeInfos)
|
{}
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_POLYGONS,maxVertexs,maxBounds,maxEdges,hasVNormals,hasVColors,hasFColors,hasVTexels,hasEdgeInfos) {}
|
|
||||||
|
@ -22,8 +22,7 @@ is
|
|||||||
maxBounds: Integer from Standard = 0;
|
maxBounds: Integer from Standard = 0;
|
||||||
maxEdges: Integer from Standard = 0;
|
maxEdges: Integer from Standard = 0;
|
||||||
hasVColors: Boolean from Standard = Standard_False;
|
hasVColors: Boolean from Standard = Standard_False;
|
||||||
hasBColors: Boolean from Standard = Standard_False;
|
hasBColors: Boolean from Standard = Standard_False)
|
||||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
|
||||||
returns mutable ArrayOfPolylines from Graphic3d;
|
returns mutable ArrayOfPolylines from Graphic3d;
|
||||||
---Purpose: Creates an array of polylines,
|
---Purpose: Creates an array of polylines,
|
||||||
-- a polyline can be filled as:
|
-- a polyline can be filled as:
|
||||||
@ -97,8 +96,5 @@ is
|
|||||||
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
-- When <hasBColors> is TRUE , <maxBounds> must be > 0 and
|
||||||
-- you must use the
|
-- you must use the
|
||||||
-- AddBound(number,Color) method.
|
-- AddBound(number,Color) method.
|
||||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
|
||||||
-- you must use the
|
|
||||||
-- AddEdge(number,visibillity) method.
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfPolylines.ixx>
|
#include <Graphic3d_ArrayOfPolylines.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfPolylines :: Graphic3d_ArrayOfPolylines (
|
Graphic3d_ArrayOfPolylines::Graphic3d_ArrayOfPolylines (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxBounds,
|
||||||
const Standard_Integer maxBounds,
|
const Standard_Integer theMaxEdges,
|
||||||
const Standard_Integer maxEdges,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasFColors)
|
||||||
const Standard_Boolean hasFColors,
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_POLYLINES, theMaxVertexs, theMaxBounds, theMaxEdges, Standard_False, theHasVColors, theHasFColors, Standard_False)
|
||||||
const Standard_Boolean hasEdgeInfos)
|
{}
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_POLYLINES,maxVertexs,maxBounds,maxEdges,Standard_False,hasVColors,hasFColors,Standard_False,hasEdgeInfos) {}
|
|
||||||
|
@ -34,12 +34,14 @@ deferred class ArrayOfPrimitives from Graphic3d inherits TShared
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
|
|
||||||
TypeOfPrimitiveArray from Graphic3d,
|
TypeOfPrimitiveArray from Graphic3d,
|
||||||
PrimitiveArray from Graphic3d,
|
Buffer_Handle from Graphic3d,
|
||||||
Color from Quantity,
|
BoundBuffer_Handle from Graphic3d,
|
||||||
Pnt from gp,
|
IndexBuffer_Handle from Graphic3d,
|
||||||
Pnt2d from gp,
|
Color from Quantity,
|
||||||
Dir from gp
|
Pnt from gp,
|
||||||
|
Pnt2d from gp,
|
||||||
|
Dir from gp
|
||||||
|
|
||||||
raises
|
raises
|
||||||
OutOfRange from Standard,
|
OutOfRange from Standard,
|
||||||
@ -56,8 +58,7 @@ is
|
|||||||
hasVNormals: Boolean from Standard;
|
hasVNormals: Boolean from Standard;
|
||||||
hasVColors: Boolean from Standard;
|
hasVColors: Boolean from Standard;
|
||||||
hasBColors: Boolean from Standard;
|
hasBColors: Boolean from Standard;
|
||||||
hasTexels: Boolean from Standard;
|
hasTexels: Boolean from Standard)
|
||||||
hasEdgeInfos: Boolean from Standard)
|
|
||||||
returns mutable ArrayOfPrimitives from Graphic3d
|
returns mutable ArrayOfPrimitives from Graphic3d
|
||||||
raises InitialisationError from Graphic3d;
|
raises InitialisationError from Graphic3d;
|
||||||
---Purpose: Warning
|
---Purpose: Warning
|
||||||
@ -68,8 +69,6 @@ is
|
|||||||
-- constructor parameter is > 0.
|
-- constructor parameter is > 0.
|
||||||
-- You must use AddEdge() method only if the <maxEdges>
|
-- You must use AddEdge() method only if the <maxEdges>
|
||||||
-- constructor parameter is > 0.
|
-- constructor parameter is > 0.
|
||||||
-- You must use a coherent set of AddEdge() methods according to the
|
|
||||||
-- <hasEdgeInfos> constructor parameter.
|
|
||||||
|
|
||||||
Destroy( me: mutable);
|
Destroy( me: mutable);
|
||||||
-- destructor
|
-- destructor
|
||||||
@ -327,17 +326,11 @@ is
|
|||||||
-- if the actual Bound number is >= <maxBounds>
|
-- if the actual Bound number is >= <maxBounds>
|
||||||
|
|
||||||
AddEdge( me:mutable;
|
AddEdge( me:mutable;
|
||||||
vertexIndex: Integer from Standard;
|
vertexIndex: Integer from Standard)
|
||||||
isVisible: Boolean from Standard = Standard_True)
|
|
||||||
returns Integer from Standard
|
returns Integer from Standard
|
||||||
---Level: Public
|
---Level: Public
|
||||||
---Purpose: Adds an edge in the range [1,VertexNumber()] in the array,
|
---Purpose: Adds an edge in the range [1,VertexNumber()] in the array.
|
||||||
-- if <isVisible> is FALSE the edge between <vertexIndex> and
|
-- Returns the actual edges number.
|
||||||
-- 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.
|
|
||||||
raises OutOfRange from Standard;
|
raises OutOfRange from Standard;
|
||||||
-- if the actual edge number is >= <maxEdges>
|
-- if the actual edge number is >= <maxEdges>
|
||||||
|
|
||||||
@ -345,47 +338,6 @@ is
|
|||||||
-- Methods to modify the array
|
-- 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;
|
SetVertice( me:mutable;
|
||||||
anIndex: Integer from Standard;
|
anIndex: Integer from Standard;
|
||||||
aVertice: Pnt from gp)
|
aVertice: Pnt from gp)
|
||||||
@ -487,11 +439,23 @@ is
|
|||||||
-- Category Inquiries on array
|
-- Category Inquiries on array
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
Array( me )
|
Indices (me)
|
||||||
returns PrimitiveArray from Graphic3d;
|
returns IndexBuffer_Handle from Graphic3d;
|
||||||
---Level: Internal
|
---Purpose: Returns optional index buffer.
|
||||||
---Purpose: Returns the array address.
|
|
||||||
---C++: inline
|
---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 )
|
Type( me )
|
||||||
returns TypeOfPrimitiveArray from Graphic3d;
|
returns TypeOfPrimitiveArray from Graphic3d;
|
||||||
@ -606,12 +570,6 @@ is
|
|||||||
-- when the rank is < 1 or > VertexNumber().
|
-- when the rank is < 1 or > VertexNumber().
|
||||||
---C++: inline
|
---C++: inline
|
||||||
|
|
||||||
HasEdgeInfos( me )
|
|
||||||
returns Boolean from Standard;
|
|
||||||
---Level: Public
|
|
||||||
---Purpose: Returns TRUE when edge visibillity array is defined.
|
|
||||||
---C++: inline
|
|
||||||
|
|
||||||
EdgeNumber( me )
|
EdgeNumber( me )
|
||||||
returns Integer from Standard;
|
returns Integer from Standard;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
@ -627,15 +585,6 @@ is
|
|||||||
-- when the rank is < 1 or > EdgeNumber()
|
-- when the rank is < 1 or > EdgeNumber()
|
||||||
---C++: inline
|
---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 )
|
HasBoundColors( me )
|
||||||
returns Boolean from Standard;
|
returns Boolean from Standard;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
@ -692,10 +641,19 @@ is
|
|||||||
is private;
|
is private;
|
||||||
|
|
||||||
fields
|
fields
|
||||||
myPrimitiveArray: PrimitiveArray from Graphic3d;
|
|
||||||
myMaxBounds: Integer from Standard;
|
myIndices : IndexBuffer_Handle from Graphic3d; -- optional index buffer
|
||||||
myMaxVertexs: Integer from Standard;
|
myAttribs : Buffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
|
||||||
myMaxEdges: Integer from Standard;
|
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
|
friends
|
||||||
class Group from Graphic3d
|
class Group from Graphic3d
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,373 +15,391 @@
|
|||||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
#include <gp_Pnt.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
|
inline Graphic3d_TypeOfPrimitiveArray Graphic3d_ArrayOfPrimitives::Type() const
|
||||||
{
|
{
|
||||||
Graphic3d_TypeOfPrimitiveArray type = Graphic3d_TOPA_UNDEFINED;
|
return myType;
|
||||||
if( myPrimitiveArray ) type = (Graphic3d_TypeOfPrimitiveArray) myPrimitiveArray->type;
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexNormals() const
|
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexNormals() const
|
||||||
{
|
{
|
||||||
Standard_Boolean defined = Standard_False;
|
return myVNor != 0;
|
||||||
if( myPrimitiveArray && myPrimitiveArray->vnormals ) defined = Standard_True;
|
|
||||||
return defined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexColors() const
|
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexColors() const
|
||||||
{
|
{
|
||||||
Standard_Boolean defined = Standard_False;
|
return myVCol != 0;
|
||||||
if( myPrimitiveArray && myPrimitiveArray->vcolours ) defined = Standard_True;
|
|
||||||
return defined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexTexels() const
|
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexTexels() const
|
||||||
{
|
{
|
||||||
Standard_Boolean defined = Standard_False;
|
return myVTex != 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::VertexNumber() const
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::VertexNumber() const
|
||||||
{
|
{
|
||||||
Standard_Integer number = -1;
|
return !myAttribs.IsNull() ? myAttribs->NbElements : -1;
|
||||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_vertexs;
|
|
||||||
return number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,
|
||||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z)
|
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(
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
|
||||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ)
|
||||||
const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ)
|
|
||||||
{
|
{
|
||||||
return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||||
Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ));
|
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(
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
|
||||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
const Standard_Real theTX, const Standard_Real theTY)
|
||||||
const Standard_Real TX, const Standard_Real TY)
|
|
||||||
{
|
{
|
||||||
return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||||
Standard_ShortReal(TX),Standard_ShortReal(TY));
|
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(
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
|
||||||
const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
|
const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ,
|
||||||
const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ,
|
const Standard_Real theTX, const Standard_Real theTY)
|
||||||
const Standard_Real TX, const Standard_Real TY)
|
|
||||||
{
|
{
|
||||||
return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z),
|
return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ),
|
||||||
Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ),
|
Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ),
|
||||||
Standard_ShortReal(TX),Standard_ShortReal(TY));
|
Standard_ShortReal (theTX), Standard_ShortReal (theTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Graphic3d_ArrayOfPrimitives::SetVertice(
|
inline void Graphic3d_ArrayOfPrimitives::SetVertice (const Standard_Integer theIndex,
|
||||||
const Standard_Integer anIndex,
|
const Standard_ShortReal theX,
|
||||||
const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
|
const Standard_ShortReal theY,
|
||||||
|
const Standard_ShortReal theZ)
|
||||||
{
|
{
|
||||||
if( !myPrimitiveArray ) return;
|
if (myAttribs.IsNull())
|
||||||
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( myPrimitiveArray->vnormals ) {
|
return;
|
||||||
Tfloat *p = myPrimitiveArray->vnormals[index].xyz;
|
|
||||||
*p++ = Standard_ShortReal(NX);
|
|
||||||
*p++ = Standard_ShortReal(NY);
|
|
||||||
*p = Standard_ShortReal(NZ);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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(
|
inline void Graphic3d_ArrayOfPrimitives::SetVertexColor (const Standard_Integer theIndex,
|
||||||
const Standard_Integer anIndex,
|
const Standard_Real theR,
|
||||||
const Standard_Real TX, const Standard_Real TY)
|
const Standard_Real theG,
|
||||||
|
const Standard_Real theB)
|
||||||
{
|
{
|
||||||
if( !myPrimitiveArray ) return;
|
if (myAttribs.IsNull())
|
||||||
if( anIndex < 1 || anIndex > myMaxVertexs ) {
|
{
|
||||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer index = anIndex-1;
|
if (theIndex < 1
|
||||||
if( myPrimitiveArray->vtexels ) {
|
|| theIndex > myMaxVertexs)
|
||||||
Tfloat *p = myPrimitiveArray->vtexels[index].xy;
|
{
|
||||||
*p++ = Standard_ShortReal(TX);
|
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||||
*p = Standard_ShortReal(TY);
|
|
||||||
}
|
}
|
||||||
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(
|
inline void Graphic3d_ArrayOfPrimitives::SetVertexNormal (const Standard_Integer theIndex,
|
||||||
const Standard_Integer anIndex,
|
const Standard_Real theNX,
|
||||||
const Standard_Real R, const Standard_Real G, const Standard_Real B)
|
const Standard_Real theNY,
|
||||||
|
const Standard_Real theNZ)
|
||||||
{
|
{
|
||||||
if( !myPrimitiveArray ) return;
|
if (myAttribs.IsNull())
|
||||||
if( anIndex < 1 || anIndex > myMaxBounds ) {
|
{
|
||||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer index = anIndex-1;
|
if (theIndex < 1
|
||||||
Tfloat *p = myPrimitiveArray->fcolours[index].rgb;
|
|| theIndex > myMaxVertexs)
|
||||||
*p++ = Standard_ShortReal(R);
|
{
|
||||||
*p++ = Standard_ShortReal(G);
|
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||||
*p = Standard_ShortReal(B);
|
}
|
||||||
|
|
||||||
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,
|
inline void Graphic3d_ArrayOfPrimitives::SetVertexTexel (const Standard_Integer theIndex,
|
||||||
Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
|
const Standard_Real theTX,
|
||||||
|
const Standard_Real theTY)
|
||||||
{
|
{
|
||||||
X = Y = Z = 0.;
|
if (myAttribs.IsNull())
|
||||||
if( !myPrimitiveArray ) return;
|
{
|
||||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
return;
|
||||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer index = anIndex-1;
|
if (theIndex < 1
|
||||||
if( myPrimitiveArray->vertices ) {
|
|| theIndex > myMaxVertexs)
|
||||||
Tfloat *p = myPrimitiveArray->vertices[index].xyz;
|
{
|
||||||
X = Standard_Real(*p++); Y = Standard_Real(*p++); Z = Standard_Real(*p);
|
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,
|
inline void Graphic3d_ArrayOfPrimitives::VertexNormal (const Standard_Integer theIndex,
|
||||||
Standard_Real& R, Standard_Real& G, Standard_Real& B) const
|
Standard_Real& theNX,
|
||||||
|
Standard_Real& theNY,
|
||||||
|
Standard_Real& theNZ) const
|
||||||
{
|
{
|
||||||
R = G = B = 0;
|
theNX = theNY = theNZ = 0.0;
|
||||||
if( !myPrimitiveArray ) return;
|
if (myAttribs.IsNull())
|
||||||
if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) {
|
{
|
||||||
Standard_OutOfRange::Raise(" BAD VERTEX index");
|
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;
|
if (theIndex < 1
|
||||||
b >>= 16;
|
|| theIndex > myAttribs->NbElements)
|
||||||
B =((Standard_Real) b) / 255.;
|
{
|
||||||
|
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||||
|
}
|
||||||
|
|
||||||
g = aColor & 0x0000ff00;
|
if (myVNor != 0)
|
||||||
g >>= 8;
|
{
|
||||||
G = ((Standard_Real) g) / 255.;
|
const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3* >(myAttribs->value (theIndex - 1) + size_t(myVNor));
|
||||||
|
theNX = Standard_Real(aVec.x());
|
||||||
r = aColor & 0x000000ff;
|
theNY = Standard_Real(aVec.y());
|
||||||
r >>= 0;
|
theNZ = Standard_Real(aVec.z());
|
||||||
R = ((Standard_Real) r) / 255.;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer anIndex,
|
inline void Graphic3d_ArrayOfPrimitives::VertexTexel (const Standard_Integer theIndex,
|
||||||
Standard_Integer& aColor) const
|
Standard_Real& theTX,
|
||||||
|
Standard_Real& theTY) const
|
||||||
{
|
{
|
||||||
Standard_Integer index = anIndex-1;
|
theTX = theTY = 0.0;
|
||||||
|
if (myAttribs.IsNull())
|
||||||
if( myPrimitiveArray->vcolours ) {
|
{
|
||||||
#if defined (sparc) || defined (__sparc__) || defined (__sparc)
|
return;
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer index = anIndex-1;
|
if (theIndex < 1
|
||||||
if( myPrimitiveArray->vnormals ) {
|
|| theIndex > myAttribs->NbElements)
|
||||||
Tfloat *p = myPrimitiveArray->vnormals[index].xyz;
|
{
|
||||||
NX = Standard_Real(*p++); NY = Standard_Real(*p++); NZ = Standard_Real(*p);
|
Standard_OutOfRange::Raise ("BAD VERTEX index");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer index = anIndex-1;
|
if (myVTex != 0)
|
||||||
if( myPrimitiveArray->vtexels ) {
|
{
|
||||||
Tfloat *p = myPrimitiveArray->vtexels[index].xy;
|
const Graphic3d_Vec2& aVec = *reinterpret_cast<const Graphic3d_Vec2* >(myAttribs->value (theIndex - 1) + size_t(myVTex));
|
||||||
TX = Standard_Real(*p++); TY = Standard_Real(*p);
|
theTX = Standard_Real(aVec.x());
|
||||||
|
theTY = Standard_Real(aVec.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::EdgeNumber() const
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::EdgeNumber() const
|
||||||
{
|
{
|
||||||
Standard_Integer number = -1;
|
return !myIndices.IsNull() ? myIndices->NbElements : -1;
|
||||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_edges;
|
|
||||||
return number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (myIndices.IsNull()
|
||||||
if( myPrimitiveArray && myPrimitiveArray->edge_vis &&
|
|| theIndex <= 0
|
||||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_edges) ) {
|
|| theIndex > myIndices->NbElements)
|
||||||
index = myPrimitiveArray->edges[anIndex-1];
|
{
|
||||||
} else {
|
Standard_OutOfRange::Raise ("BAD EDGE index");
|
||||||
Standard_OutOfRange::Raise(" BAD EDGE index");
|
|
||||||
}
|
}
|
||||||
return index+1;
|
return Standard_Integer(myIndices->Index (theIndex - 1) + 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasBoundColors() const
|
inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasBoundColors() const
|
||||||
{
|
{
|
||||||
Standard_Boolean defined = Standard_False;
|
return !myBounds.IsNull() && myBounds->Colors != NULL;
|
||||||
if( myPrimitiveArray && myPrimitiveArray->fcolours ) defined = Standard_True;
|
|
||||||
return defined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Standard_Integer Graphic3d_ArrayOfPrimitives::BoundNumber() const
|
inline Standard_Integer Graphic3d_ArrayOfPrimitives::BoundNumber() const
|
||||||
{
|
{
|
||||||
Standard_Integer number = -1;
|
return !myBounds.IsNull() ? myBounds->NbBounds : -1;
|
||||||
if( myPrimitiveArray ) number = myPrimitiveArray->num_bounds;
|
|
||||||
return number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (myBounds.IsNull()
|
||||||
if( myPrimitiveArray && myPrimitiveArray->bounds &&
|
|| theIndex <= 0
|
||||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) {
|
|| theIndex > myBounds->NbBounds)
|
||||||
number = myPrimitiveArray->bounds[anIndex-1];
|
{
|
||||||
} else {
|
Standard_OutOfRange::Raise ("BAD BOUND index");
|
||||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
|
||||||
}
|
}
|
||||||
return number;
|
return myBounds->Bounds[theIndex - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Graphic3d_ArrayOfPrimitives::BoundColor(const Standard_Integer anIndex,
|
inline void Graphic3d_ArrayOfPrimitives::BoundColor (const Standard_Integer theIndex,
|
||||||
Standard_Real& R, Standard_Real& G, Standard_Real& B) const
|
Standard_Real& theR,
|
||||||
|
Standard_Real& theG,
|
||||||
|
Standard_Real& theB) const
|
||||||
{
|
{
|
||||||
if( myPrimitiveArray && myPrimitiveArray->fcolours &&
|
if (myBounds.IsNull()
|
||||||
(anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) {
|
|| myBounds->Colors == NULL
|
||||||
Tfloat *p = myPrimitiveArray->fcolours[anIndex-1].rgb;
|
|| theIndex <= 0
|
||||||
R = Standard_Real(*p++); G = Standard_Real(*p++); B = Standard_Real(*p);
|
|| theIndex > myBounds->NbBounds)
|
||||||
} else {
|
{
|
||||||
Standard_OutOfRange::Raise(" BAD BOUND index");
|
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>
|
#include <Graphic3d_ArrayOfQuadrangleStrips.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfQuadrangleStrips :: Graphic3d_ArrayOfQuadrangleStrips (
|
Graphic3d_ArrayOfQuadrangleStrips::Graphic3d_ArrayOfQuadrangleStrips (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxStrips,
|
||||||
const Standard_Integer maxStrips,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasSColors,
|
||||||
const Standard_Boolean hasSColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels)
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_QUADRANGLESTRIPS,maxVertexs,maxStrips,0,hasVNormals,hasVColors,hasSColors,hasVTexels,Standard_False) {}
|
{}
|
||||||
|
@ -31,8 +31,7 @@ is
|
|||||||
maxEdges: Integer from Standard = 0;
|
maxEdges: Integer from Standard = 0;
|
||||||
hasVNormals: Boolean from Standard = Standard_False;
|
hasVNormals: Boolean from Standard = Standard_False;
|
||||||
hasVColors: Boolean from Standard = Standard_False;
|
hasVColors: Boolean from Standard = Standard_False;
|
||||||
hasTexels: Boolean from Standard = Standard_False;
|
hasTexels: Boolean from Standard = Standard_False)
|
||||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
|
||||||
returns mutable ArrayOfQuadrangles from Graphic3d;
|
returns mutable ArrayOfQuadrangles from Graphic3d;
|
||||||
---Purpose: Creates an array of quadrangles,
|
---Purpose: Creates an array of quadrangles,
|
||||||
-- a quadrangle can be filled as:
|
-- a quadrangle can be filled as:
|
||||||
@ -71,9 +70,6 @@ is
|
|||||||
-- When <hasTexels> is TRUE , you must use one of
|
-- When <hasTexels> is TRUE , you must use one of
|
||||||
-- AddVertex(Point,Texel)
|
-- AddVertex(Point,Texel)
|
||||||
-- or AddVertex(Point,Normal,Texel) methods.
|
-- or AddVertex(Point,Normal,Texel) methods.
|
||||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
|
||||||
-- you must use the
|
|
||||||
-- AddEdge(number,visibillity) method.
|
|
||||||
-- Warning:
|
-- Warning:
|
||||||
-- the user is responsible about the orientation of the quadrangle
|
-- the user is responsible about the orientation of the quadrangle
|
||||||
-- depending of the order of the created vertex or edges and this
|
-- depending of the order of the created vertex or edges and this
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfQuadrangles.ixx>
|
#include <Graphic3d_ArrayOfQuadrangles.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfQuadrangles :: Graphic3d_ArrayOfQuadrangles (
|
Graphic3d_ArrayOfQuadrangles::Graphic3d_ArrayOfQuadrangles (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxEdges,
|
||||||
const Standard_Integer maxEdges,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels,
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_QUADRANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
|
||||||
const Standard_Boolean hasEdgesInfos)
|
{}
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_QUADRANGLES,maxVertexs,0,maxEdges,hasVNormals,hasVColors,Standard_False,hasVTexels,hasEdgesInfos) {}
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfSegments.ixx>
|
#include <Graphic3d_ArrayOfSegments.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfSegments :: Graphic3d_ArrayOfSegments (
|
Graphic3d_ArrayOfSegments::Graphic3d_ArrayOfSegments (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxEdges,
|
||||||
const Standard_Integer maxEdges,
|
const Standard_Boolean theHasVColors)
|
||||||
const Standard_Boolean hasVColors)
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_SEGMENTS, theMaxVertexs, 0, theMaxEdges, Standard_False, theHasVColors, Standard_False, Standard_False)
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_SEGMENTS,maxVertexs,0,maxEdges,Standard_False,hasVColors,Standard_False,Standard_False,Standard_False) {}
|
{}
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfTriangleFans.ixx>
|
#include <Graphic3d_ArrayOfTriangleFans.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfTriangleFans :: Graphic3d_ArrayOfTriangleFans (
|
Graphic3d_ArrayOfTriangleFans::Graphic3d_ArrayOfTriangleFans (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxFans,
|
||||||
const Standard_Integer maxFans,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasFColors,
|
||||||
const Standard_Boolean hasFColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels)
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLEFANS, theMaxVertexs, theMaxFans, 0, theHasVNormals, theHasVColors, theHasFColors, theHasVTexels)
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLEFANS,maxVertexs,maxFans,0,hasVNormals,hasVColors,hasFColors,hasVTexels,Standard_False) {}
|
{}
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfTriangleStrips.ixx>
|
#include <Graphic3d_ArrayOfTriangleStrips.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfTriangleStrips :: Graphic3d_ArrayOfTriangleStrips (
|
Graphic3d_ArrayOfTriangleStrips::Graphic3d_ArrayOfTriangleStrips (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxStrips,
|
||||||
const Standard_Integer maxStrips,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasSColors,
|
||||||
const Standard_Boolean hasSColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels)
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLESTRIPS, theMaxVertexs, theMaxStrips, 0, theHasVNormals, theHasVColors, theHasSColors, theHasVTexels)
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLESTRIPS,maxVertexs,maxStrips,0,hasVNormals,hasVColors,hasSColors,hasVTexels,Standard_False) {}
|
{}
|
||||||
|
@ -22,8 +22,7 @@ is
|
|||||||
maxEdges: Integer from Standard = 0;
|
maxEdges: Integer from Standard = 0;
|
||||||
hasVNormals: Boolean from Standard = Standard_False;
|
hasVNormals: Boolean from Standard = Standard_False;
|
||||||
hasVColors: Boolean from Standard = Standard_False;
|
hasVColors: Boolean from Standard = Standard_False;
|
||||||
hasTexels: Boolean from Standard = Standard_False;
|
hasTexels: Boolean from Standard = Standard_False)
|
||||||
hasEdgeInfos: Boolean from Standard = Standard_False)
|
|
||||||
returns mutable ArrayOfTriangles from Graphic3d;
|
returns mutable ArrayOfTriangles from Graphic3d;
|
||||||
---Purpose: Creates an array of triangles,
|
---Purpose: Creates an array of triangles,
|
||||||
-- a triangle can be filled as:
|
-- a triangle can be filled as:
|
||||||
@ -60,9 +59,6 @@ is
|
|||||||
-- When <hasTexels> is TRUE , you must use one of
|
-- When <hasTexels> is TRUE , you must use one of
|
||||||
-- AddVertex(Point,Texel)
|
-- AddVertex(Point,Texel)
|
||||||
-- or AddVertex(Point,Normal,Texel) methods.
|
-- or AddVertex(Point,Normal,Texel) methods.
|
||||||
-- When <hasEdgeInfos> is TRUE , <maxEdges> must be > 0 and
|
|
||||||
-- you must use the
|
|
||||||
-- AddEdge(number,visibillity) method.
|
|
||||||
-- Warning:
|
-- Warning:
|
||||||
-- the user is responsible about the orientation of the triangle
|
-- the user is responsible about the orientation of the triangle
|
||||||
-- depending of the order of the created vertex or edges and this
|
-- depending of the order of the created vertex or edges and this
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfTriangles.ixx>
|
#include <Graphic3d_ArrayOfTriangles.ixx>
|
||||||
|
|
||||||
Graphic3d_ArrayOfTriangles :: Graphic3d_ArrayOfTriangles (
|
Graphic3d_ArrayOfTriangles::Graphic3d_ArrayOfTriangles (const Standard_Integer theMaxVertexs,
|
||||||
const Standard_Integer maxVertexs,
|
const Standard_Integer theMaxEdges,
|
||||||
const Standard_Integer maxEdges,
|
const Standard_Boolean theHasVNormals,
|
||||||
const Standard_Boolean hasVNormals,
|
const Standard_Boolean theHasVColors,
|
||||||
const Standard_Boolean hasVColors,
|
const Standard_Boolean theHasVTexels)
|
||||||
const Standard_Boolean hasVTexels,
|
: Graphic3d_ArrayOfPrimitives (Graphic3d_TOPA_TRIANGLES, theMaxVertexs, 0, theMaxEdges, theHasVNormals, theHasVColors, Standard_False, theHasVTexels)
|
||||||
const Standard_Boolean hasEdgeInfos)
|
{}
|
||||||
: Graphic3d_ArrayOfPrimitives(Graphic3d_TOPA_TRIANGLES,maxVertexs,0,maxEdges,hasVNormals,hasVColors,Standard_False,hasVTexels,hasEdgeInfos) {}
|
|
||||||
|
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.
|
// 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
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
/*
|
#ifndef _Graphic3d_BoundBuffer_Handle_HeaderFile
|
||||||
File Graphic3d_PrimitiveArray.hxx
|
#define _Graphic3d_BoundBuffer_Handle_HeaderFile
|
||||||
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
|
|
||||||
|
|
||||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
#include <Graphic3d_BoundBuffer.hxx>
|
||||||
typedef CALL_DEF_PARRAY *Graphic3d_PrimitiveArray;
|
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,
|
Array2OfVertex from Graphic3d,
|
||||||
Vertex from Graphic3d,
|
Vertex from Graphic3d,
|
||||||
VerticalTextAlignment from Graphic3d,
|
VerticalTextAlignment from Graphic3d,
|
||||||
PrimitiveArray from Graphic3d,
|
|
||||||
PtrFrameBuffer from Graphic3d,
|
PtrFrameBuffer from Graphic3d,
|
||||||
HArray1OfByte from TColStd,
|
HArray1OfByte from TColStd,
|
||||||
FillMethod from Aspect,
|
FillMethod from Aspect,
|
||||||
|
@ -85,7 +85,10 @@ deferred class Group from Graphic3d inherits TShared
|
|||||||
Vertex from Graphic3d,
|
Vertex from Graphic3d,
|
||||||
VerticalTextAlignment from Graphic3d,
|
VerticalTextAlignment from Graphic3d,
|
||||||
ArrayOfPrimitives 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,
|
TransModeFlags from Graphic3d,
|
||||||
CBounds from Graphic3d,
|
CBounds from Graphic3d,
|
||||||
Ax2 from gp
|
Ax2 from gp
|
||||||
@ -365,9 +368,18 @@ deferred class Group from Graphic3d inherits TShared
|
|||||||
---Category: Methods to create Triangle
|
---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;
|
AddPrimitiveArray( me : mutable;
|
||||||
thePrim : ArrayOfPrimitives from Graphic3d;
|
thePrim : ArrayOfPrimitives from Graphic3d;
|
||||||
theToEvalMinMax : Boolean from Standard = Standard_True ) is virtual;
|
theToEvalMinMax : Boolean from Standard = Standard_True );
|
||||||
---Level: Public
|
---Level: Public
|
||||||
---Purpose: Adds an array of primitives for display
|
---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;
|
ContextMarker : CAspectMarker from Graphic3d is protected;
|
||||||
ContextText : CAspectText from Graphic3d is protected;
|
ContextText : CAspectText from Graphic3d is protected;
|
||||||
|
|
||||||
-- temporary field - to be removed
|
|
||||||
myListOfPArray : ListOfPArray from Graphic3d is protected;
|
|
||||||
|
|
||||||
friends
|
friends
|
||||||
|
|
||||||
class Structure from Graphic3d
|
class Structure from Graphic3d
|
||||||
|
@ -988,30 +988,79 @@ void Graphic3d_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitive
|
|||||||
return;
|
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
|
if (!MyContainsFacet
|
||||||
&& thePrim->Type() != Graphic3d_TOPA_POLYLINES
|
&& theType != Graphic3d_TOPA_POLYLINES
|
||||||
&& thePrim->Type() != Graphic3d_TOPA_SEGMENTS
|
&& theType != Graphic3d_TOPA_SEGMENTS
|
||||||
&& thePrim->Type() != Graphic3d_TOPA_POINTS)
|
&& theType != Graphic3d_TOPA_POINTS)
|
||||||
{
|
{
|
||||||
myStructure->GroupsWithFacet (1);
|
myStructure->GroupsWithFacet (1);
|
||||||
MyContainsFacet = Standard_True;
|
MyContainsFacet = Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyIsEmpty = Standard_False;
|
MyIsEmpty = Standard_False;
|
||||||
myListOfPArray.Append (thePrim);
|
|
||||||
if (theToEvalMinMax)
|
if (theToEvalMinMax)
|
||||||
{
|
{
|
||||||
Standard_Real x, y, z;
|
const Standard_Integer aNbVerts = theAttribs->NbElements;
|
||||||
const Standard_Integer aNbVerts = thePrim->VertexNumber();
|
for (Standard_Integer anAttribIter = 0; anAttribIter < theAttribs->NbAttributes; ++anAttribIter)
|
||||||
for (Standard_Integer aVertIter = 1; aVertIter <= aNbVerts; ++aVertIter)
|
|
||||||
{
|
{
|
||||||
thePrim->Vertice (aVertIter, x, y, z);
|
const Graphic3d_Attribute& anAttrib = theAttribs->Attribute (anAttribIter);
|
||||||
if (x < myBounds.XMin) myBounds.XMin = Standard_ShortReal (x);
|
if (anAttrib.Id != Graphic3d_TOA_POS)
|
||||||
if (y < myBounds.YMin) myBounds.YMin = Standard_ShortReal (y);
|
{
|
||||||
if (z < myBounds.ZMin) myBounds.ZMin = Standard_ShortReal (z);
|
continue;
|
||||||
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 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_wntio.hxx
|
||||||
InterfaceGraphic_cPrintf.cxx
|
InterfaceGraphic_cPrintf.cxx
|
||||||
InterfaceGraphic_Palette.c
|
InterfaceGraphic_Palette.c
|
||||||
InterfaceGraphic_PrimitiveArray.hxx
|
|
||||||
InterfaceGraphic_telem.hxx
|
InterfaceGraphic_telem.hxx
|
||||||
InterfaceGraphic_tgl_all.hxx
|
InterfaceGraphic_tgl_all.hxx
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#ifndef InterfaceGraphic_Graphic3dHeader
|
#ifndef InterfaceGraphic_Graphic3dHeader
|
||||||
#define InterfaceGraphic_Graphic3dHeader
|
#define InterfaceGraphic_Graphic3dHeader
|
||||||
|
|
||||||
#include <InterfaceGraphic_PrimitiveArray.hxx>
|
#include <InterfaceGraphic_telem.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
|
|
||||||
/* COULEUR */
|
/* 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:
|
public:
|
||||||
|
|
||||||
//! Returns the number of components.
|
//! Returns the number of components.
|
||||||
static size_t Length()
|
static int Length()
|
||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
@ -257,22 +257,8 @@ void OpenGl_CappingAlgo::Init()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_CappingAlgoFilter::CanRender (const OpenGl_Element* theElement)
|
Standard_Boolean OpenGl_CappingAlgoFilter::CanRender (const OpenGl_Element* theElement)
|
||||||
{
|
{
|
||||||
const OpenGl_PrimitiveArray* aPArray =
|
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
||||||
dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
return aPArray != NULL
|
||||||
if (!aPArray)
|
&& aPArray->DrawMode() >= GL_TRIANGLES
|
||||||
return Standard_False;
|
&& aPArray->DrawMode() <= GL_POLYGON;
|
||||||
|
|
||||||
switch (aPArray->PArray()->type)
|
|
||||||
{
|
|
||||||
case TelPolygonsArrayType :
|
|
||||||
case TelTrianglesArrayType :
|
|
||||||
case TelQuadranglesArrayType :
|
|
||||||
case TelTriangleStripsArrayType :
|
|
||||||
case TelQuadrangleStripsArrayType :
|
|
||||||
case TelTriangleFansArrayType :
|
|
||||||
return Standard_True;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,10 @@
|
|||||||
#include <gp_Ax2.hxx>
|
#include <gp_Ax2.hxx>
|
||||||
#include <Graphic3d_CView.hxx>
|
#include <Graphic3d_CView.hxx>
|
||||||
#include <Graphic3d_CStructure.hxx>
|
#include <Graphic3d_CStructure.hxx>
|
||||||
#include <Graphic3d_TypeOfPrimitive.hxx>
|
|
||||||
#include <Graphic3d_CPick.hxx>
|
#include <Graphic3d_CPick.hxx>
|
||||||
#include <Graphic3d_TextPath.hxx>
|
#include <Graphic3d_TextPath.hxx>
|
||||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||||
#include <Graphic3d_PrimitiveArray.hxx>
|
|
||||||
#include <Graphic3d_CUserDraw.hxx>
|
#include <Graphic3d_CUserDraw.hxx>
|
||||||
#include <Graphic3d_CGraduatedTrihedron.hxx>
|
#include <Graphic3d_CGraduatedTrihedron.hxx>
|
||||||
#include <Graphic3d_TypeOfComposition.hxx>
|
#include <Graphic3d_TypeOfComposition.hxx>
|
||||||
|
@ -183,19 +183,22 @@ void OpenGl_Group::UpdateAspectText (const Standard_Boolean theIsGlobal)
|
|||||||
// function : AddPrimitiveArray
|
// function : AddPrimitiveArray
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
|
void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||||
const Standard_Boolean theToEvalMinMax)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||||
|
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||||
|
const Standard_Boolean theToEvalMinMax)
|
||||||
{
|
{
|
||||||
if (IsDeleted()
|
if (IsDeleted()
|
||||||
|| !thePrim->IsValid())
|
|| theAttribs.IsNull())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray ((CALL_DEF_PARRAY *)thePrim->Array());
|
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray (theType, theIndices, theAttribs, theBounds);
|
||||||
AddElement (anArray);
|
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);
|
Standard_EXPORT virtual void UpdateAspectText (const Standard_Boolean theIsGlobal);
|
||||||
|
|
||||||
//! Add primitive array element
|
//! Add primitive array element
|
||||||
Standard_EXPORT virtual void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
|
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||||
const Standard_Boolean theToEvalMinMax);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||||
|
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||||
|
const Standard_Boolean theToEvalMinMax);
|
||||||
|
|
||||||
//! Add text element
|
//! Add text element
|
||||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
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
|
#ifndef OpenGl_PrimitiveArray_Header
|
||||||
#define OpenGl_PrimitiveArray_Header
|
#define OpenGl_PrimitiveArray_Header
|
||||||
|
|
||||||
#include <OpenGl_VertexBuffer.hxx>
|
#include <OpenGl_IndexBuffer.hxx>
|
||||||
|
|
||||||
#include <InterfaceGraphic_Graphic3d.hxx>
|
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||||
#include <Aspect_InteriorStyle.hxx>
|
#include <Aspect_InteriorStyle.hxx>
|
||||||
#include <Aspect_TypeOfMarker.hxx>
|
#include <Aspect_TypeOfMarker.hxx>
|
||||||
|
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
|
||||||
|
#include <Graphic3d_IndexBuffer.hxx>
|
||||||
|
#include <Graphic3d_BoundBuffer.hxx>
|
||||||
|
|
||||||
#include <OpenGl_Element.hxx>
|
#include <OpenGl_Element.hxx>
|
||||||
|
|
||||||
struct OPENGL_SURF_PROP;
|
|
||||||
|
|
||||||
class OpenGl_PrimitiveArray : public OpenGl_Element
|
class OpenGl_PrimitiveArray : public OpenGl_Element
|
||||||
{
|
{
|
||||||
public:
|
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
|
// 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
|
enum
|
||||||
{
|
{
|
||||||
DRAW_MODE_NONE = -1
|
DRAW_MODE_NONE = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor
|
//! 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
|
//! Render primitives to the window
|
||||||
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||||
|
|
||||||
virtual void Release (const Handle(OpenGl_Context)& theContext);
|
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:
|
private:
|
||||||
|
|
||||||
Standard_Boolean toDrawVbo() const
|
|
||||||
{
|
|
||||||
return !myVbos[VBOVertices].IsNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! VBO initialization procedures
|
//! VBO initialization procedures
|
||||||
Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||||
void clearMemoryOwn() const;
|
|
||||||
void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
|
void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
|
||||||
|
|
||||||
//! Main procedure to draw array
|
//! Main procedure to draw array
|
||||||
@ -66,7 +74,6 @@ private:
|
|||||||
const TEL_COLOUR* theInteriorColour,
|
const TEL_COLOUR* theInteriorColour,
|
||||||
const TEL_COLOUR* theLineColour,
|
const TEL_COLOUR* theLineColour,
|
||||||
const TEL_COLOUR* theEdgeColour,
|
const TEL_COLOUR* theEdgeColour,
|
||||||
const OPENGL_SURF_PROP* theFaceProp,
|
|
||||||
const Handle(OpenGl_Workspace)& theWorkspace) const;
|
const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||||
|
|
||||||
//! Auxiliary procedures
|
//! Auxiliary procedures
|
||||||
@ -82,20 +89,14 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef enum
|
mutable Handle(OpenGl_IndexBuffer) myVboIndices;
|
||||||
{
|
mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
|
||||||
VBOEdges,
|
|
||||||
VBOVertices,
|
|
||||||
VBOVcolours,
|
|
||||||
VBOVnormals,
|
|
||||||
VBOVtexels,
|
|
||||||
VBOMaxType
|
|
||||||
} VBODataType;
|
|
||||||
|
|
||||||
mutable CALL_DEF_PARRAY* myPArray;
|
mutable Handle(Graphic3d_IndexBuffer) myIndices;
|
||||||
mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType];
|
mutable Handle(Graphic3d_Buffer) myAttribs;
|
||||||
GLint myDrawMode;
|
mutable Handle(Graphic3d_BoundBuffer) myBounds;
|
||||||
mutable Standard_Boolean myIsVboInit;
|
GLint myDrawMode;
|
||||||
|
mutable Standard_Boolean myIsVboInit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ namespace OpenGl_Raytrace
|
|||||||
{
|
{
|
||||||
OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem);
|
OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem);
|
||||||
return anArray != NULL
|
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 :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
bool OpenGl_VertexBuffer::init (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLuint theComponentsNb,
|
const GLuint theComponentsNb,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLfloat* theData)
|
const void* theData,
|
||||||
|
const GLenum theDataType,
|
||||||
|
const GLsizei theStride)
|
||||||
{
|
{
|
||||||
if (!Create (theGlCtx))
|
if (!Create (theGlCtx))
|
||||||
{
|
{
|
||||||
@ -120,138 +122,42 @@ bool OpenGl_VertexBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bind (theGlCtx);
|
Bind (theGlCtx);
|
||||||
myDataType = GL_FLOAT;
|
myDataType = theDataType;
|
||||||
myComponentsNb = theComponentsNb;
|
myComponentsNb = theComponentsNb;
|
||||||
myElemsNb = theElemsNb;
|
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
|
bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
|
||||||
Unbind (theGlCtx);
|
Unbind (theGlCtx);
|
||||||
return isDone;
|
return isDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : SubData
|
// function : subData
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
|
bool OpenGl_VertexBuffer::subData (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLsizei theElemFrom,
|
const GLsizei theElemFrom,
|
||||||
const GLsizei theElemsNb,
|
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))
|
theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bind (theGlCtx);
|
Bind (theGlCtx);
|
||||||
|
const size_t aDataSize = sizeOfGlType (theDataType);
|
||||||
theGlCtx->core15->glBufferSubData (GetTarget(),
|
theGlCtx->core15->glBufferSubData (GetTarget(),
|
||||||
GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLfloat), // offset in bytes
|
GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize, // offset in bytes
|
||||||
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLfloat), // size in bytes
|
GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize, // size in bytes
|
||||||
theData);
|
theData);
|
||||||
bool isDone = (glGetError() == GL_NO_ERROR); // some dummy error
|
bool isDone = (glGetError() == GL_NO_ERROR); // some dummy error
|
||||||
Unbind (theGlCtx);
|
Unbind (theGlCtx);
|
||||||
return isDone;
|
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
|
// function : BindVertexAttrib
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -317,6 +223,8 @@ void OpenGl_VertexBuffer::BindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
|||||||
case GL_COLOR_ARRAY:
|
case GL_COLOR_ARRAY:
|
||||||
{
|
{
|
||||||
glColorPointer (static_cast<GLint> (myComponentsNb), myDataType, 0, NULL);
|
glColorPointer (static_cast<GLint> (myComponentsNb), myDataType, 0, NULL);
|
||||||
|
glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||||
|
glEnable (GL_COLOR_MATERIAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@ -336,4 +244,44 @@ void OpenGl_VertexBuffer::UnbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
|||||||
}
|
}
|
||||||
Unbind (theGlCtx);
|
Unbind (theGlCtx);
|
||||||
glDisableClientState (theMode);
|
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_GlCore20.hxx>
|
||||||
#include <OpenGl_Resource.hxx>
|
#include <OpenGl_Resource.hxx>
|
||||||
|
#include <OpenGl_Context.hxx>
|
||||||
|
|
||||||
class Handle(OpenGl_Context);
|
#include <Graphic3d_IndexBuffer.hxx>
|
||||||
class OpenGl_Context;
|
|
||||||
|
|
||||||
//! Vertex Buffer Object - is a general storage object for vertex attributes (position, normal, color).
|
//! 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.
|
//! 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 theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||||
//! @param theElemsNb - elements count;
|
//! @param theElemsNb - elements count;
|
||||||
//! @param theData - pointer to GLfloat data (vertices/normals etc.).
|
//! @param theData - pointer to GLfloat data (vertices/normals etc.).
|
||||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLuint theComponentsNb,
|
const GLuint theComponentsNb,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLfloat* theData);
|
const GLfloat* theData)
|
||||||
|
{
|
||||||
|
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
//! Notice that VBO will be unbound after this call.
|
//! 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 theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||||
//! @param theElemsNb - elements count;
|
//! @param theElemsNb - elements count;
|
||||||
//! @param theData - pointer to GLuint data (indices etc.).
|
//! @param theData - pointer to GLuint data (indices etc.).
|
||||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLuint theComponentsNb,
|
const GLuint theComponentsNb,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLuint* theData);
|
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.
|
//! 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 theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
|
||||||
//! @param theElemsNb - elements count;
|
//! @param theElemsNb - elements count;
|
||||||
//! @param theData - pointer to GLubyte data (indices/colors etc.).
|
//! @param theData - pointer to GLubyte data (indices/colors etc.).
|
||||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
bool Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLuint theComponentsNb,
|
const GLuint theComponentsNb,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLubyte* theData);
|
const GLubyte* theData)
|
||||||
|
{
|
||||||
|
return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_BYTE);
|
||||||
|
}
|
||||||
|
|
||||||
//! Notice that VBO will be unbound after this call.
|
//! Notice that VBO will be unbound after this call.
|
||||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
//! 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 theElemFrom - element id from which replace buffer data (>=0);
|
||||||
//! @param theElemsNb - elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
//! @param theElemsNb - elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||||
//! @param theData - pointer to GLfloat data.
|
//! @param theData - pointer to GLfloat data.
|
||||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLsizei theElemFrom,
|
const GLsizei theElemFrom,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLfloat* theData);
|
const GLfloat* theData)
|
||||||
|
{
|
||||||
|
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
//! Notice that VBO will be unbound after this call.
|
//! Notice that VBO will be unbound after this call.
|
||||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
//! 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 theElemFrom element id from which replace buffer data (>=0);
|
||||||
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||||
//! @param theData pointer to GLuint data.
|
//! @param theData pointer to GLuint data.
|
||||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLsizei theElemFrom,
|
const GLsizei theElemFrom,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLuint* theData);
|
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.
|
//! Notice that VBO will be unbound after this call.
|
||||||
//! Function replaces portion of data within this VBO using glBufferSubData().
|
//! 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 theElemFrom element id from which replace buffer data (>=0);
|
||||||
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
//! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
|
||||||
//! @param theData pointer to GLubyte data.
|
//! @param theData pointer to GLubyte data.
|
||||||
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
bool SubData (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLsizei theElemFrom,
|
const GLsizei theElemFrom,
|
||||||
const GLsizei theElemsNb,
|
const GLsizei theElemsNb,
|
||||||
const GLubyte* theData);
|
const GLubyte* theData)
|
||||||
|
{
|
||||||
|
return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
|
||||||
|
}
|
||||||
|
|
||||||
//! Bind this VBO to active GLSL program.
|
//! Bind this VBO to active GLSL program.
|
||||||
Standard_EXPORT void BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
|
Standard_EXPORT void BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
@ -158,6 +202,129 @@ public:
|
|||||||
Standard_EXPORT void UnbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
Standard_EXPORT void UnbindFixed (const Handle(OpenGl_Context)& theGlCtx,
|
||||||
const GLenum theMode) const;
|
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:
|
protected:
|
||||||
|
|
||||||
GLuint myBufferId; //!< VBO name (index)
|
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);
|
const OpenGl_PrimitiveArray* theArray, int theMatID, const Standard_ShortReal* theTrans);
|
||||||
|
|
||||||
//! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
|
//! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const OpenGl_PrimitiveArray& theArray,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL triangle fan array to ray-traced scene geometry.
|
//! Adds OpenGL triangle fan array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL triangle strip array to ray-traced scene geometry.
|
//! Adds OpenGL triangle strip array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL quadrangle array to ray-traced scene geometry.
|
//! Adds OpenGL quadrangle array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
|
//! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Adds OpenGL polygon array to ray-traced scene geometry.
|
//! Adds OpenGL polygon array to ray-traced scene geometry.
|
||||||
Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID);
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID);
|
||||||
|
|
||||||
//! Loads and compiles shader object from specified source.
|
//! Loads and compiles shader object from specified source.
|
||||||
Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);
|
Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);
|
||||||
|
@ -452,100 +452,114 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
|
|||||||
// function : AddRaytracePrimitiveArray
|
// function : AddRaytracePrimitiveArray
|
||||||
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||||
const OpenGl_PrimitiveArray* theArray, Standard_Integer theMatID, const Standard_ShortReal* theTransform)
|
Standard_Integer theMatID,
|
||||||
|
const Standard_ShortReal* theTransform)
|
||||||
{
|
{
|
||||||
CALL_DEF_PARRAY* aPArray = theArray->PArray();
|
const Handle(Graphic3d_IndexBuffer)& anIndices = theArray->Indices();
|
||||||
|
const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes();
|
||||||
if (aPArray->type != TelPolygonsArrayType &&
|
const Handle(Graphic3d_BoundBuffer)& aBounds = theArray->Bounds();
|
||||||
aPArray->type != TelTrianglesArrayType &&
|
if (theArray->DrawMode() < GL_TRIANGLES
|
||||||
aPArray->type != TelQuadranglesArrayType &&
|
|| theArray->DrawMode() > GL_POLYGON
|
||||||
aPArray->type != TelTriangleFansArrayType &&
|
|| anAttribs.IsNull())
|
||||||
aPArray->type != TelTriangleStripsArrayType &&
|
|
||||||
aPArray->type != TelQuadrangleStripsArrayType)
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aPArray->vertices == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
#ifdef RAY_TRACE_PRINT_INFO
|
#ifdef RAY_TRACE_PRINT_INFO
|
||||||
switch (aPArray->type)
|
switch (aPArray->DrawMode())
|
||||||
{
|
{
|
||||||
case TelPolygonsArrayType:
|
case GL_POLYGON: std::cout << "\tAdding GL_POLYGON\n"; break;
|
||||||
std::cout << "\tAdding TelPolygonsArrayType" << std::endl; break;
|
case GL_TRIANGLES: std::cout << "\tAdding GL_TRIANGLES\n"; break;
|
||||||
case TelTrianglesArrayType:
|
case GL_QUADS: std::cout << "\tAdding GL_QUADS\n"; break;
|
||||||
std::cout << "\tAdding TelTrianglesArrayType" << std::endl; break;
|
case GL_TRIANGLE_FAN: std::cout << "\tAdding GL_TRIANGLE_FAN\n"; break;
|
||||||
case TelQuadranglesArrayType:
|
case GL_TRIANGLE_STRIP: std::cout << "\tAdding GL_TRIANGLE_STRIP\n"; break;
|
||||||
std::cout << "\tAdding TelQuadranglesArrayType" << std::endl; break;
|
case GL_QUAD_STRIP: std::cout << "\tAdding GL_QUAD_STRIP\n"; 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;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OpenGl_TriangleSet* aSet = new OpenGl_TriangleSet (theArray);
|
OpenGl_TriangleSet* aSet = new OpenGl_TriangleSet (theArray);
|
||||||
|
|
||||||
{
|
{
|
||||||
aSet->Vertices.reserve (aPArray->num_vertexs);
|
aSet->Vertices.reserve (anAttribs->NbElements);
|
||||||
|
aSet->Normals .reserve (anAttribs->NbElements);
|
||||||
for (Standard_Integer aVert = 0; aVert < aPArray->num_vertexs; ++aVert)
|
const size_t aVertFrom = aSet->Vertices.size();
|
||||||
|
for (Standard_Integer anAttribIter = 0; anAttribIter < anAttribs->NbAttributes; ++anAttribIter)
|
||||||
{
|
{
|
||||||
BVH_Vec4f aVertex (aPArray->vertices[aVert].xyz[0],
|
const Graphic3d_Attribute& anAttrib = anAttribs->Attribute (anAttribIter);
|
||||||
aPArray->vertices[aVert].xyz[1],
|
const size_t anOffset = anAttribs->AttributeOffset (anAttribIter);
|
||||||
aPArray->vertices[aVert].xyz[2],
|
if (anAttrib.Id == Graphic3d_TOA_POS)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
aNormal = BVH_Vec4f (aPArray->vnormals[aNorm].xyz[0],
|
if (anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||||
aPArray->vnormals[aNorm].xyz[1],
|
|| anAttrib.DataType == Graphic3d_TOD_VEC4)
|
||||||
aPArray->vnormals[aNorm].xyz[2],
|
{
|
||||||
0.f);
|
for (Standard_Integer aVertIter = 0; aVertIter < anAttribs->NbElements; ++aVertIter)
|
||||||
|
{
|
||||||
if (theTransform)
|
const Graphic3d_Vec3& aVert = *reinterpret_cast<const Graphic3d_Vec3* >(anAttribs->value (aVertIter) + anOffset);
|
||||||
aNormal = MatVecMult (theTransform, aNormal);
|
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
|
#ifdef RAY_TRACE_PRINT_INFO
|
||||||
std::cout << "\tNumber of bounds = " << aPArray->num_bounds << std::endl;
|
std::cout << "\tNumber of bounds = " << aPArray->num_bounds << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Standard_Integer aBoundStart = 0;
|
Standard_Integer aBoundStart = 0;
|
||||||
|
for (Standard_Integer aBound = 0; aBound < aBounds->NbBounds; ++aBound)
|
||||||
for (Standard_Integer aBound = 0; aBound < aPArray->num_bounds; ++aBound)
|
|
||||||
{
|
{
|
||||||
const Standard_Integer aVertNum = aPArray->bounds[aBound];
|
const Standard_Integer aVertNum = aBounds->Bounds[aBound];
|
||||||
|
|
||||||
#ifdef RAY_TRACE_PRINT_INFO
|
#ifdef RAY_TRACE_PRINT_INFO
|
||||||
std::cout << "\tAdding indices from bound " << aBound << ": " <<
|
std::cout << "\tAdding indices from bound " << aBound << ": " <<
|
||||||
aBoundStart << " .. " << aVertNum << std::endl;
|
aBoundStart << " .. " << aVertNum << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!AddRaytraceVertexIndices (aSet, aPArray, aBoundStart, aVertNum, theMatID))
|
if (!AddRaytraceVertexIndices (*aSet, *theArray, aBoundStart, aVertNum, theMatID))
|
||||||
{
|
{
|
||||||
delete aSet;
|
delete aSet;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -556,13 +570,13 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
|||||||
}
|
}
|
||||||
else
|
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
|
#ifdef RAY_TRACE_PRINT_INFO
|
||||||
std::cout << "\tAdding indices from array: " << aVertNum << std::endl;
|
std::cout << "\tAdding indices from array: " << aVertNum << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!AddRaytraceVertexIndices (aSet, aPArray, 0, aVertNum, theMatID))
|
if (!AddRaytraceVertexIndices (*aSet, *theArray, 0, aVertNum, theMatID))
|
||||||
{
|
{
|
||||||
delete aSet;
|
delete aSet;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -580,61 +594,55 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (
|
|||||||
// function : AddRaytraceVertexIndices
|
// function : AddRaytraceVertexIndices
|
||||||
// purpose : Adds vertex indices to ray-traced scene geometry
|
// purpose : Adds vertex indices to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const OpenGl_PrimitiveArray& theArray,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
switch (theArray->type)
|
switch (theArray.DrawMode())
|
||||||
{
|
{
|
||||||
case TelTrianglesArrayType:
|
case GL_TRIANGLES: return AddRaytraceTriangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||||
return AddRaytraceTriangleArray (theSet, theArray, 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 TelQuadranglesArrayType:
|
case GL_TRIANGLE_STRIP: return AddRaytraceTriangleStripArray (theSet, theArray.Indices(), theOffset, theCount, theMatID);
|
||||||
return AddRaytraceQuadrangleArray (theSet, theArray, 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);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : AddRaytraceTriangleArray
|
// function : AddRaytraceTriangleArray
|
||||||
// purpose : Adds OpenGL triangle array to ray-traced scene geometry
|
// purpose : Adds OpenGL triangle array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 3)
|
if (theCount < 3)
|
||||||
return Standard_True;
|
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)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; aVert += 3)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||||
theArray->edges[aVert + 1],
|
theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; aVert += 3)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; aVert += 3)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 1, aVert + 2,
|
||||||
aVert + 1,
|
theMatID));
|
||||||
aVert + 2,
|
|
||||||
theMatID));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,32 +653,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleArray (OpenGl_TriangleSet*
|
|||||||
// function : AddRaytraceTriangleFanArray
|
// function : AddRaytraceTriangleFanArray
|
||||||
// purpose : Adds OpenGL triangle fan array to ray-traced scene geometry
|
// purpose : Adds OpenGL triangle fan array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 3)
|
if (theCount < 3)
|
||||||
return Standard_True;
|
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)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[theOffset],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (theOffset),
|
||||||
theArray->edges[aVert + 1],
|
theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theOffset,
|
theSet.Elements.push_back (BVH_Vec4i (theOffset,
|
||||||
aVert + 1,
|
aVert + 1,
|
||||||
aVert + 2,
|
aVert + 2,
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,32 +692,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleFanArray (OpenGl_TriangleS
|
|||||||
// function : AddRaytraceTriangleStripArray
|
// function : AddRaytraceTriangleStripArray
|
||||||
// purpose : Adds OpenGL triangle strip array to ray-traced scene geometry
|
// purpose : Adds OpenGL triangle strip array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 3)
|
if (theCount < 3)
|
||||||
return Standard_True;
|
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)
|
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],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + aCW ? 1 : 0),
|
||||||
theArray->edges[aVert + aCW ? 0 : 1],
|
theIndices->Index (aVert + aCW ? 0 : 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset, aCW = 0; aVert < theOffset + theCount - 2; ++aVert, aCW = (aCW + 1) % 2)
|
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,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + aCW ? 1 : 0,
|
||||||
aVert + aCW ? 0 : 1,
|
aVert + aCW ? 0 : 1,
|
||||||
aVert + 2,
|
aVert + 2,
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,42 +731,39 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceTriangleStripArray (OpenGl_Triangl
|
|||||||
// function : AddRaytraceQuadrangleArray
|
// function : AddRaytraceQuadrangleArray
|
||||||
// purpose : Adds OpenGL quad array to ray-traced scene geometry
|
// purpose : Adds OpenGL quad array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 4)
|
if (theCount < 4)
|
||||||
return Standard_True;
|
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)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 4)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||||
theArray->edges[aVert + 1],
|
theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
theIndices->Index (aVert + 2),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 3),
|
||||||
theArray->edges[aVert + 3],
|
theMatID));
|
||||||
theMatID));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 4)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 4)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 1, aVert + 2,
|
||||||
aVert + 1,
|
theMatID));
|
||||||
aVert + 2,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + 0, aVert + 2, aVert + 3,
|
||||||
theMatID));
|
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
|
// function : AddRaytraceQuadrangleStripArray
|
||||||
// purpose : Adds OpenGL quad strip array to ray-traced scene geometry
|
// purpose : Adds OpenGL quad strip array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 4)
|
if (theCount < 4)
|
||||||
return Standard_True;
|
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)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 2)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 0],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 0),
|
||||||
theArray->edges[aVert + 1],
|
theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
|
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[aVert + 1],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 3],
|
theIndices->Index (aVert + 3),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 2)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 3; aVert += 2)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 0,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + 0,
|
||||||
aVert + 1,
|
aVert + 1,
|
||||||
aVert + 2,
|
aVert + 2,
|
||||||
theMatID));
|
theMatID));
|
||||||
|
|
||||||
theSet->Elements.push_back (BVH_Vec4i (aVert + 1,
|
theSet.Elements.push_back (BVH_Vec4i (aVert + 1,
|
||||||
aVert + 3,
|
aVert + 3,
|
||||||
aVert + 2,
|
aVert + 2,
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,32 +823,35 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceQuadrangleStripArray (OpenGl_Trian
|
|||||||
// function : AddRaytracePolygonArray
|
// function : AddRaytracePolygonArray
|
||||||
// purpose : Adds OpenGL polygon array to ray-traced scene geometry
|
// purpose : Adds OpenGL polygon array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Workspace::AddRaytracePolygonArray (OpenGl_TriangleSet* theSet,
|
Standard_Boolean OpenGl_Workspace::AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
|
||||||
const CALL_DEF_PARRAY* theArray, Standard_Integer theOffset, Standard_Integer theCount, Standard_Integer theMatID)
|
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||||
|
Standard_Integer theOffset,
|
||||||
|
Standard_Integer theCount,
|
||||||
|
Standard_Integer theMatID)
|
||||||
{
|
{
|
||||||
if (theCount < 3)
|
if (theCount < 3)
|
||||||
return Standard_True;
|
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)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theArray->edges[theOffset],
|
theSet.Elements.push_back (BVH_Vec4i (theIndices->Index (theOffset),
|
||||||
theArray->edges[aVert + 1],
|
theIndices->Index (aVert + 1),
|
||||||
theArray->edges[aVert + 2],
|
theIndices->Index (aVert + 2),
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
for (Standard_Integer aVert = theOffset; aVert < theOffset + theCount - 2; ++aVert)
|
||||||
{
|
{
|
||||||
theSet->Elements.push_back (BVH_Vec4i (theOffset,
|
theSet.Elements.push_back (BVH_Vec4i (theOffset,
|
||||||
aVert + 1,
|
aVert + 1,
|
||||||
aVert + 2,
|
aVert + 2,
|
||||||
theMatID));
|
theMatID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace
|
|||||||
TopLoc_Location aLoc;
|
TopLoc_Location aLoc;
|
||||||
gp_Pnt p;
|
gp_Pnt p;
|
||||||
Standard_Integer decal;
|
Standard_Integer decal;
|
||||||
Standard_Integer t[3], n[3];
|
Standard_Integer n[3];
|
||||||
Standard_Integer nbTriangles = 0, nbVertices = 0;
|
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);
|
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;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(Graphic3d_ArrayOfTriangles) aPArray
|
Handle(Graphic3d_ArrayOfTriangles) aPArray = new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
|
||||||
= new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
|
Standard_True, Standard_False, theHasTexels);
|
||||||
Standard_True, Standard_False, theHasTexels, Standard_True);
|
|
||||||
for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
|
for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
|
||||||
{
|
{
|
||||||
const TopoDS_Face& aFace = SST.CurrentFace();
|
const TopoDS_Face& aFace = SST.CurrentFace();
|
||||||
@ -184,7 +183,6 @@ namespace
|
|||||||
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
||||||
for (Standard_Integer aTriIter = 1; aTriIter <= T->NbTriangles(); ++aTriIter)
|
for (Standard_Integer aTriIter = 1; aTriIter <= T->NbTriangles(); ++aTriIter)
|
||||||
{
|
{
|
||||||
pc.Triangles (aTriIter, t[0], t[1], t[2]);
|
|
||||||
if (SST.Orientation (aFace) == TopAbs_REVERSED)
|
if (SST.Orientation (aFace) == TopAbs_REVERSED)
|
||||||
aTriangles (aTriIter).Get (n[0], n[2], n[1]);
|
aTriangles (aTriIter).Get (n[0], n[2], n[1]);
|
||||||
else
|
else
|
||||||
@ -214,9 +212,9 @@ namespace
|
|||||||
V1.Cross (V2);
|
V1.Cross (V2);
|
||||||
if (V1.SquareMagnitude() > aPreci)
|
if (V1.SquareMagnitude() > aPreci)
|
||||||
{
|
{
|
||||||
aPArray->AddEdge (n[0] + decal, t[0] == 0);
|
aPArray->AddEdge (n[0] + decal);
|
||||||
aPArray->AddEdge (n[1] + decal, t[1] == 0);
|
aPArray->AddEdge (n[1] + decal);
|
||||||
aPArray->AddEdge (n[2] + decal, t[2] == 0);
|
aPArray->AddEdge (n[2] + decal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3186,8 +3186,8 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
|
|
||||||
// Parsing array description
|
// Parsing array description
|
||||||
Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
|
Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
|
||||||
Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
|
Standard_Boolean hasVColors, hasBColors, hasNormals, hasTexels;
|
||||||
hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
|
hasVColors = hasNormals = hasBColors = hasTexels = Standard_False;
|
||||||
|
|
||||||
Standard_Integer anArgIndex = 0;
|
Standard_Integer anArgIndex = 0;
|
||||||
Standard_Integer anArgsCount = myArrayDescription->Length();
|
Standard_Integer anArgsCount = myArrayDescription->Length();
|
||||||
@ -3228,10 +3228,6 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
// edge command
|
// edge command
|
||||||
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
||||||
{
|
{
|
||||||
// edge has a hide flag
|
|
||||||
if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
|
|
||||||
hasInfos = Standard_True;
|
|
||||||
|
|
||||||
aEdgeNum++;
|
aEdgeNum++;
|
||||||
}
|
}
|
||||||
// unknown command
|
// unknown command
|
||||||
@ -3248,10 +3244,10 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
|
anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
|
||||||
else if (anArrayType == "polylines")
|
else if (anArrayType == "polylines")
|
||||||
anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
|
anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
|
||||||
hasVColors, hasBColors, hasInfos);
|
hasVColors, hasBColors);
|
||||||
else if (anArrayType == "triangles")
|
else if (anArrayType == "triangles")
|
||||||
anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
|
anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
|
||||||
hasVColors, hasTexels, hasInfos);
|
hasVColors, hasTexels);
|
||||||
else if (anArrayType == "trianglefans")
|
else if (anArrayType == "trianglefans")
|
||||||
anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
|
anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
|
||||||
hasNormals, hasVColors,
|
hasNormals, hasVColors,
|
||||||
@ -3263,7 +3259,7 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
else if (anArrayType == "quads")
|
else if (anArrayType == "quads")
|
||||||
anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
|
anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
|
||||||
hasNormals, hasVColors,
|
hasNormals, hasVColors,
|
||||||
hasTexels, hasInfos);
|
hasTexels);
|
||||||
else if (anArrayType == "quadstrips")
|
else if (anArrayType == "quadstrips")
|
||||||
anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
|
anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
|
||||||
hasNormals, hasVColors,
|
hasNormals, hasVColors,
|
||||||
@ -3271,7 +3267,7 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
else if (anArrayType == "polygons")
|
else if (anArrayType == "polygons")
|
||||||
anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
|
anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
|
||||||
hasNormals, hasVColors, hasBColors,
|
hasNormals, hasVColors, hasBColors,
|
||||||
hasTexels, hasInfos);
|
hasTexels);
|
||||||
|
|
||||||
anArgIndex = 1;
|
anArgIndex = 1;
|
||||||
while (anArgIndex < anArgsCount)
|
while (anArgIndex < anArgsCount)
|
||||||
@ -3287,22 +3283,23 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
anArray->AddVertex (myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
anArray->AddVertex (myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||||
|
const Standard_Integer aVertIndex = anArray->VertexNumber();
|
||||||
|
|
||||||
// vertex has a normal or normal with color or texel
|
// vertex has a normal or normal with color or texel
|
||||||
if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
|
if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
|
||||||
anArray->SetVertexNormal (anArray->VertexNumber (),
|
anArray->SetVertexNormal (aVertIndex,
|
||||||
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||||
|
|
||||||
if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
|
if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
|
||||||
anArray->SetVertexColor (anArray->VertexNumber (),
|
anArray->SetVertexColor (aVertIndex,
|
||||||
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
myArrayDescription->Value (anArgIndex - 3).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||||
|
|
||||||
if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
|
if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
|
||||||
anArray->SetVertexTexel (anArray->VertexNumber (),
|
anArray->SetVertexTexel (aVertIndex,
|
||||||
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
myArrayDescription->Value (anArgIndex - 2).RealValue(),
|
||||||
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
myArrayDescription->Value (anArgIndex - 1).RealValue());
|
||||||
}
|
}
|
||||||
@ -3323,13 +3320,8 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
|
|||||||
// edge command
|
// edge command
|
||||||
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
|
||||||
{
|
{
|
||||||
Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
|
const Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
|
||||||
|
anArray->AddEdge (aVertIndex);
|
||||||
// edge has/hasn't hide flag
|
|
||||||
if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
|
|
||||||
anArray->AddEdge (aVertIndex, Standard_False);
|
|
||||||
else
|
|
||||||
anArray->AddEdge (aVertIndex, Standard_True);
|
|
||||||
}
|
}
|
||||||
// unknown command
|
// unknown command
|
||||||
else
|
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 }]"
|
<< " vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
|
||||||
<< " [texel={ 't' tx ty }] } \n"
|
<< " [texel={ 't' tx ty }] } \n"
|
||||||
<< " bounds={ 'b' verticies_count [color={ 'c' r g b }] }\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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5120,7 +5112,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
|||||||
__FILE__, VComputeHLR, group);
|
__FILE__, VComputeHLR, group);
|
||||||
|
|
||||||
theCommands.Add("vdrawparray",
|
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);
|
__FILE__,VDrawPArray,group);
|
||||||
|
|
||||||
theCommands.Add("vconnect",
|
theCommands.Add("vconnect",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user