mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028010: Visualization, Prs3d_Arrow - add Shading presentation builder
StdPrs_ToolCylinder, StdPrs_ToolDisk, StdPrs_ToolQuadric and StdPrs_ToolSphere have been moved from StdPrs package to Prs3d.
This commit is contained in:
@@ -21,16 +21,8 @@ StdPrs_ShadedShape.cxx
|
||||
StdPrs_ShadedShape.hxx
|
||||
StdPrs_ShadedSurface.cxx
|
||||
StdPrs_ShadedSurface.hxx
|
||||
StdPrs_ToolDisk.hxx
|
||||
StdPrs_ToolDisk.cxx
|
||||
StdPrs_ToolCylinder.hxx
|
||||
StdPrs_ToolCylinder.cxx
|
||||
StdPrs_ToolPoint.cxx
|
||||
StdPrs_ToolPoint.hxx
|
||||
StdPrs_ToolQuadric.hxx
|
||||
StdPrs_ToolQuadric.cxx
|
||||
StdPrs_ToolSphere.hxx
|
||||
StdPrs_ToolSphere.cxx
|
||||
StdPrs_ToolRFace.cxx
|
||||
StdPrs_ToolRFace.hxx
|
||||
StdPrs_ToolTriangulatedShape.cxx
|
||||
|
@@ -1,80 +0,0 @@
|
||||
// Created on: 1995-07-27
|
||||
// Created by: Modelistation
|
||||
// Copyright (c) 1995-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.
|
||||
|
||||
#include <StdPrs_ToolCylinder.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdPrs_ToolCylinder::StdPrs_ToolCylinder (const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks)
|
||||
: myBottomRadius (theBottomRad),
|
||||
myTopRadius (theTopRad),
|
||||
myHeight (theHeight)
|
||||
{
|
||||
myStacksNb = theNbStacks;
|
||||
mySlicesNb = theNbSlices;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Pnt StdPrs_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
|
||||
return gp_Pnt (Cos (aU) * aRadius,
|
||||
Sin (aU) * aRadius,
|
||||
theV * myHeight);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Dir StdPrs_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
return gp_Dir (Cos (aU) * myHeight,
|
||||
Sin (aU) * myHeight,
|
||||
myBottomRadius - myTopRadius);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolCylinder::Create (const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray;
|
||||
StdPrs_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
|
||||
aTool.FillArray (anArray, theTrsf);
|
||||
return anArray;
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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 _StdPrs_ToolCylinder_HeaderFile
|
||||
#define _StdPrs_ToolCylinder_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for cylindrical surface.
|
||||
class StdPrs_ToolCylinder : public StdPrs_ToolQuadric
|
||||
{
|
||||
public:
|
||||
|
||||
//! Generate primitives for 3D quadric surface and return a filled array.
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf);
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Initializes the algorithm.
|
||||
Standard_EXPORT StdPrs_ToolCylinder (const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks);
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes vertex at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
//! Computes normal at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myBottomRadius;
|
||||
Standard_Real myTopRadius;
|
||||
Standard_Real myHeight;
|
||||
|
||||
};
|
||||
|
||||
#endif // _StdPrs_ToolCylinder_HeaderFile
|
@@ -1,73 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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.
|
||||
|
||||
#include <StdPrs_ToolDisk.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_Real theInnerRadius,
|
||||
const Standard_Real theOuterRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks)
|
||||
: myInnerRadius (theInnerRadius),
|
||||
myOuterRadius (theOuterRadius)
|
||||
{
|
||||
mySlicesNb = theNbSlices;
|
||||
myStacksNb = theNbStacks;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Pnt StdPrs_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
|
||||
return gp_Pnt (Cos (aU) * aRadius,
|
||||
Sin (aU) * aRadius,
|
||||
0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Dir StdPrs_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
|
||||
{
|
||||
return gp_Dir (0.0, 0.0, -1.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolDisk::Create (const Standard_Real theInnerRadius,
|
||||
const Standard_Real theOuterRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray;
|
||||
StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theNbSlices, theNbStacks);
|
||||
aTool.FillArray (anArray, theTrsf);
|
||||
return anArray;
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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 _StdPrs_ToolDisk_HeaderFile
|
||||
#define _StdPrs_ToolDisk_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for disk surface.
|
||||
class StdPrs_ToolDisk : public StdPrs_ToolQuadric
|
||||
{
|
||||
public:
|
||||
|
||||
//! Generate primitives for 3D quadric surface and return a filled array.
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theInnerRadius,
|
||||
const Standard_Real theOuterRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf);
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Initializes the algorithm.
|
||||
Standard_EXPORT StdPrs_ToolDisk (const Standard_Real theInnerRadius,
|
||||
const Standard_Real theOuterRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks);
|
||||
protected:
|
||||
|
||||
//! Computes vertex at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
//! Computes normal at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myInnerRadius;
|
||||
Standard_Real myOuterRadius;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,118 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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.
|
||||
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
#include <gp_Quaternion.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : fillArrays
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_ToolQuadric::fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals)
|
||||
{
|
||||
Standard_ShortReal aStepU = 1.0f / mySlicesNb;
|
||||
Standard_ShortReal aStepV = 1.0f / myStacksNb;
|
||||
|
||||
for (Standard_Integer aU = 0; aU <= mySlicesNb; aU++)
|
||||
{
|
||||
const Standard_Real aParamU = aU * aStepU;
|
||||
for (Standard_Integer aV = 0; aV <= myStacksNb; aV++)
|
||||
{
|
||||
const Standard_ShortReal aParamV = aV * aStepV;
|
||||
const Standard_Integer aVertId = aU * (myStacksNb + 1) + aV + 1;
|
||||
gp_Pnt aVertex = Vertex(aParamU, aParamV);
|
||||
gp_Dir aNormal = Normal(aParamU, aParamV);
|
||||
|
||||
aVertex.Transform (theTrsf);
|
||||
aNormal.Transform (theTrsf);
|
||||
|
||||
theArray.SetValue (aVertId, aVertex);
|
||||
theNormals.SetValue (aVertId, aNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FIllArray
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf)
|
||||
{
|
||||
const Standard_Integer aTrianglesNb = TrianglesNb();
|
||||
theArray = new Graphic3d_ArrayOfTriangles (aTrianglesNb * 3, 0, Standard_True);
|
||||
|
||||
Poly_Array1OfTriangle aPolyTriangles (1, aTrianglesNb);
|
||||
TColgp_Array1OfPnt anArray (1, aTrianglesNb * 3);
|
||||
NCollection_Array1<gp_Dir> aNormals (1, aTrianglesNb * 3);
|
||||
fillArrays (theTrsf, anArray, aNormals);
|
||||
|
||||
// Fill primitives
|
||||
for (Standard_Integer aU = 0; aU < mySlicesNb; ++aU)
|
||||
{
|
||||
for (Standard_Integer aV = 1; aV <= myStacksNb; ++aV)
|
||||
{
|
||||
theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + aV), aNormals.Value (aU * (myStacksNb + 1) + aV));
|
||||
theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + aV), aNormals.Value ((aU + 1) * (myStacksNb + 1) + aV));
|
||||
theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + (aV + 1)), aNormals.Value (aU * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + aV), aNormals.Value (aU * (myStacksNb + 1) + aV));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FillTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
|
||||
Handle(Poly_Triangulation)& theTriangulation,
|
||||
const gp_Trsf& theTrsf)
|
||||
{
|
||||
const Standard_Integer aTrianglesNb = TrianglesNb();
|
||||
theArray = new Graphic3d_ArrayOfTriangles(aTrianglesNb * 3, 0, Standard_True);
|
||||
|
||||
Poly_Array1OfTriangle aPolyTriangles(1, aTrianglesNb);
|
||||
TColgp_Array1OfPnt anArray(1, aTrianglesNb * 3);
|
||||
NCollection_Array1<gp_Dir> aNormals(1, aTrianglesNb * 3);
|
||||
fillArrays(theTrsf, anArray, aNormals);
|
||||
|
||||
// Fill triangles
|
||||
for (Standard_Integer aU = 0, anIndex = 0; aU < mySlicesNb; ++aU)
|
||||
{
|
||||
for (Standard_Integer aV = 1; aV <= myStacksNb; ++aV)
|
||||
{
|
||||
theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + aV), aNormals.Value(aU * (myStacksNb + 1) + aV));
|
||||
theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + aV), aNormals.Value((aU + 1) * (myStacksNb + 1) + aV));
|
||||
theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + (aV + 1)), aNormals.Value(aU * (myStacksNb + 1) + (aV + 1)));
|
||||
theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + aV), aNormals.Value(aU * (myStacksNb + 1) + aV));
|
||||
|
||||
aPolyTriangles.SetValue (++anIndex, Poly_Triangle(aU * (myStacksNb + 1) + aV,
|
||||
(aU + 1) * (myStacksNb + 1) + aV,
|
||||
(aU + 1) * (myStacksNb + 1) + (aV + 1)));
|
||||
aPolyTriangles.SetValue (++anIndex, Poly_Triangle((aU + 1) * (myStacksNb + 1) + (aV + 1),
|
||||
aU * (myStacksNb + 1) + (aV + 1),
|
||||
aU * (myStacksNb + 1) + aV));
|
||||
}
|
||||
}
|
||||
|
||||
theTriangulation = new Poly_Triangulation (anArray, aPolyTriangles);
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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 _StdPrs_ToolQuadric_HeaderFile
|
||||
#define _StdPrs_ToolQuadric_HeaderFile
|
||||
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard.hxx>
|
||||
|
||||
//! Base class to build 3D surfaces presentation of quadric surfaces.
|
||||
class StdPrs_ToolQuadric
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Generate primitives for 3D quadric surface and fill the given array. Optional transformation is applied.
|
||||
Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf);
|
||||
|
||||
//! Generate primitives for 3D quadric surface presentation and fill the given array and poly triangulation structure. Optional transformation is applied.
|
||||
Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, Handle(Poly_Triangulation)& theTriangulation, const gp_Trsf& theTrsf);
|
||||
|
||||
protected:
|
||||
|
||||
//! Method implements an algorithm to generate arrays of vertices and normals for 3D surface.
|
||||
Standard_EXPORT void fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals);
|
||||
|
||||
//! Number of triangles in generated presentation.
|
||||
Standard_Integer TrianglesNb() const
|
||||
{
|
||||
return mySlicesNb * myStacksNb * 2;
|
||||
}
|
||||
|
||||
//! Redefine this method to generate vertex at given parameters.
|
||||
virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) = 0;
|
||||
|
||||
//! Redefine this method to generate normal at given parameters.
|
||||
virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Integer mySlicesNb;
|
||||
Standard_Integer myStacksNb;
|
||||
};
|
||||
|
||||
#endif // _StdPrs_ShadedSurface_HeaderFile
|
@@ -1,74 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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.
|
||||
|
||||
#include <StdPrs_ToolSphere.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdPrs_ToolSphere::StdPrs_ToolSphere (const Standard_Real theRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks)
|
||||
: myRadius (theRadius)
|
||||
{
|
||||
mySlicesNb = theNbSlices;
|
||||
myStacksNb = theNbStacks;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Pnt StdPrs_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
const Standard_Real aV = theV * M_PI;
|
||||
return gp_Pnt (myRadius * Cos (aU) * Sin (aV),
|
||||
-myRadius * Sin (aU) * Sin (aV),
|
||||
myRadius * Cos (aV));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Dir StdPrs_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
const Standard_Real aV = theV * M_PI;
|
||||
return gp_Dir (Cos (aU) * Sin (aV),
|
||||
-Sin (aU) * Sin (aV),
|
||||
Cos (aV));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolSphere::Create (const Standard_Real theRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray;
|
||||
StdPrs_ToolSphere aTool (theRadius, theNbSlices, theNbStacks);
|
||||
aTool.FillArray (anArray, theTrsf);
|
||||
return anArray;
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
// Created on: 2016-02-04
|
||||
// Created by: Anastasia BORISOVA
|
||||
// Copyright (c) 2016 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 _StdPrs_ToolSphere_HeaderFile
|
||||
#define _StdPrs_ToolSphere_HeaderFile
|
||||
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <StdPrs_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for spherical surface.
|
||||
class StdPrs_ToolSphere : public StdPrs_ToolQuadric
|
||||
{
|
||||
public:
|
||||
|
||||
//! Generate primitives for 3D quadric surface and return a filled array.
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks,
|
||||
const gp_Trsf& theTrsf);
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Initializes the algorithm.
|
||||
Standard_EXPORT StdPrs_ToolSphere (const Standard_Real theRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks);
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes vertex at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
//! Computes normal at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myRadius;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user