------------------------------------------------------------
-
-
- ------------------------------------------------------------
- TriangleIsValid(me;
- P1: Pnt from gp;
- P2: Pnt from gp;
- P3: Pnt from gp)
- returns Boolean from Standard is private;
-
- ------------------------------------------------------------
-
-
-
------------------------------------------------------------
--
-- QUERY METHODS
#include <AIS_TexturedShape.ixx>
#include <Standard_ErrorHandler.hxx>
+#include <AIS_Drawer.hxx>
+#include <AIS_InteractiveContext.hxx>
#include <BRepTools.hxx>
-#include <gp_Vec.hxx>
+#include <gp_Pnt2d.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_Group.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Texture2Dmanual.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <TopExp_Explorer.hxx>
+#include <StdPrs_ShadedShape.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
-#include <Graphic3d_Group.hxx>
-#include <AIS_Drawer.hxx>
#include <StdPrs_WFShape.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_ToolShadedShape.hxx>
-#include <Precision.hxx>
-#include <BRepMesh.hxx>
-#include <Poly_Triangulation.hxx>
-#include <Poly_Connect.hxx>
-#include <Graphic3d_Array1OfVertexNT.hxx>
-#include <Aspect_Array1OfEdge.hxx>
-#include <TColgp_Array1OfDir.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-
-#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
-#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
-
-//////////////////////////////////////////////////////////////////////
-// CONSTRUCTOR / DESTRUCTOR
-//////////////////////////////////////////////////////////////////////
+#include <TopExp_Explorer.hxx>
//=======================================================================
//function : AIS_TexturedShape
-//purpose :
+//purpose :
//=======================================================================
-
-AIS_TexturedShape::AIS_TexturedShape(const TopoDS_Shape& ashape):AIS_Shape(ashape),
- myPredefTexture(Graphic3d_NameOfTexture2D(0)),
- myTextureFile(""),
- DoRepeat(Standard_True),
- myURepeat(1.0),
- myVRepeat(1.0),
- DoMapTexture(Standard_True),
- DoSetTextureOrigin(Standard_True),
- myUOrigin(0.0),
- myVOrigin(0.0),
- DoSetTextureScale(Standard_True),
- myScaleU(1.0),
- myScaleV(1.0),
- DoShowTriangles(Standard_False),
- myModulate(Standard_True)
+AIS_TexturedShape::AIS_TexturedShape (const TopoDS_Shape& theShape)
+: AIS_Shape (theShape),
+ myPredefTexture (Graphic3d_NameOfTexture2D(0)),
+ myTextureFile (""),
+ DoRepeat (Standard_True),
+ myURepeat (1.0),
+ myVRepeat (1.0),
+ DoMapTexture (Standard_True),
+ DoSetTextureOrigin (Standard_True),
+ myUOrigin (0.0),
+ myVOrigin (0.0),
+ DoSetTextureScale (Standard_True),
+ myScaleU (1.0),
+ myScaleV (1.0),
+ DoShowTriangles (Standard_False),
+ myModulate (Standard_True)
{
}
-//////////////////////////////////////////////////////////////////////
-// TEXTURE MAPPING MANAGEMENT METHODS
-//////////////////////////////////////////////////////////////////////
-
//=======================================================================
//function : SetTextureFileName
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_TexturedShape::SetTextureFileName(const TCollection_AsciiString& TextureFileName)
+void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTextureFileName)
{
- if (TextureFileName.IsIntegerValue())
+ if (theTextureFileName.IsIntegerValue())
+ {
+ if (theTextureFileName.IntegerValue() < Graphic3d_Texture2D::NumberOfTextures()
+ && theTextureFileName.IntegerValue() >= 0)
{
- if(TextureFileName.IntegerValue()<Graphic3d_Texture2D::NumberOfTextures() && TextureFileName.IntegerValue()>=0)
- myPredefTexture = (Graphic3d_NameOfTexture2D)(TextureFileName.IntegerValue());
- else
- {
- cout << "Texture "<<TextureFileName<<" doesn't exist \n"<< endl;
- cout << "Using Texture 0 instead ...\n"<< endl;
- myPredefTexture = (Graphic3d_NameOfTexture2D)(0);
- }
- myTextureFile = "";
+ myPredefTexture = Graphic3d_NameOfTexture2D (theTextureFileName.IntegerValue());
}
- else
+ else
{
- myTextureFile = TextureFileName;
- myPredefTexture = (Graphic3d_NameOfTexture2D)(-1);
+ std::cout << "Texture " << theTextureFileName << " doesn't exist \n";
+ std::cout << "Using Texture 0 instead ...\n";
+ myPredefTexture = Graphic3d_NameOfTexture2D (0);
}
+ myTextureFile = "";
+ }
+ else
+ {
+ myTextureFile = theTextureFileName;
+ myPredefTexture = Graphic3d_NameOfTexture2D (-1);
+ }
}
//=======================================================================
//function : SetTextureRepeat
-//purpose :
+//purpose :
//=======================================================================
-void AIS_TexturedShape::SetTextureRepeat(const Standard_Boolean RepeatYN,
- const Standard_Real URepeat,
- const Standard_Real VRepeat)
+void AIS_TexturedShape::SetTextureRepeat (const Standard_Boolean theRepeatYN,
+ const Standard_Real theURepeat,
+ const Standard_Real theVRepeat)
{
- DoRepeat = RepeatYN;
- myURepeat = URepeat;
- myVRepeat = VRepeat;
+ DoRepeat = theRepeatYN;
+ myURepeat = theURepeat;
+ myVRepeat = theVRepeat;
}
//=======================================================================
//function : SetTextureMapOn
-//purpose :
+//purpose :
//=======================================================================
void AIS_TexturedShape::SetTextureMapOn()
//=======================================================================
//function : SetTextureMapOff
-//purpose :
+//purpose :
//=======================================================================
void AIS_TexturedShape::SetTextureMapOff()
//=======================================================================
//function : SetTextureOrigin
-//purpose :
+//purpose :
//=======================================================================
-void AIS_TexturedShape::SetTextureOrigin(const Standard_Boolean SetTextureOriginYN, const Standard_Real UOrigin, const Standard_Real VOrigin)
+void AIS_TexturedShape::SetTextureOrigin (const Standard_Boolean toSetTextureOriginYN,
+ const Standard_Real theUOrigin,
+ const Standard_Real theVOrigin)
{
- DoSetTextureOrigin = SetTextureOriginYN;
- myUOrigin = UOrigin;
- myVOrigin = VOrigin;
+ DoSetTextureOrigin = toSetTextureOriginYN;
+ myUOrigin = theUOrigin;
+ myVOrigin = theVOrigin;
}
//=======================================================================
//function : SetTextureScale
-//purpose :
+//purpose :
//=======================================================================
-void AIS_TexturedShape::SetTextureScale(const Standard_Boolean SetTextureScaleYN, const Standard_Real ScaleU, const Standard_Real ScaleV)
+void AIS_TexturedShape::SetTextureScale (const Standard_Boolean toSetTextureScaleYN,
+ const Standard_Real theScaleU,
+ const Standard_Real theScaleV)
{
- DoSetTextureScale = SetTextureScaleYN;
- myScaleU = ScaleU;
- myScaleV = ScaleV;
-}
-
-//=======================================================================
-//function : TriangleIsValid
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_TexturedShape::TriangleIsValid(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3) const
-{
- gp_Vec V1(P1,P2); // V1=(P1,P2)
- gp_Vec V2(P2,P3); // V2=(P2,P3)
- gp_Vec V3(P3,P1); // V3=(P3,P1)
-
- if ((V1.SquareMagnitude() > 1.e-10) && (V2.SquareMagnitude() > 1.e-10) && (V3.SquareMagnitude() > 1.e-10))
- {
- V1.Cross(V2); // V1 = Normal
- if (V1.SquareMagnitude() > 1.e-10)
- return Standard_True;
- else
- return Standard_False;
- }
- else
- return Standard_False;
-
+ DoSetTextureScale = toSetTextureScaleYN;
+ myScaleU = theScaleU;
+ myScaleV = theScaleV;
}
//=======================================================================
//function : ShowTriangles
-//purpose :
+//purpose :
//=======================================================================
-void AIS_TexturedShape::ShowTriangles(const Standard_Boolean ShowTrianglesYN)
+void AIS_TexturedShape::ShowTriangles (const Standard_Boolean toShowTrianglesYN)
{
- DoShowTriangles = ShowTrianglesYN;
+ DoShowTriangles = toShowTrianglesYN;
}
//=======================================================================
//function : EnableTextureModulate
-//purpose :
+//purpose :
//=======================================================================
void AIS_TexturedShape::EnableTextureModulate()
//=======================================================================
//function : UpdateAttributes
-//purpose :
+//purpose :
//=======================================================================
void AIS_TexturedShape::UpdateAttributes()
{
Handle(Graphic3d_StructureManager) aStrucMana = GetContext()->MainPrsMgr()->StructureManager();
- myAspect = (new Prs3d_ShadingAspect())->Aspect();
+ Prs3d_ShadingAspect aDummy;
+ myAspect = aDummy.Aspect();
Handle(Prs3d_Presentation) aPrs = Presentation();
if (!DoMapTexture)
- {
- myAspect->SetTextureMapOff();
- return;
- }
-
- if(myPredefTexture!=-1)
- mytexture = new Graphic3d_Texture2Dmanual(aStrucMana, myPredefTexture);
+ {
+ myAspect->SetTextureMapOff();
+ return;
+ }
+
+ if (myPredefTexture != -1)
+ mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myPredefTexture);
else
- mytexture = new Graphic3d_Texture2Dmanual(aStrucMana, myTextureFile.ToCString());
-
+ mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myTextureFile.ToCString());
+
myAspect->SetTextureMapOn();
-
- myAspect->SetTextureMap(mytexture);
+
+ myAspect->SetTextureMap (mytexture);
if (!mytexture->IsDone())
- {
- cout << "An error occured while building texture \n" <<endl;
- return;
- }
-
+ {
+ std::cout << "An error occured while building texture \n";
+ return;
+ }
+
if (DoShowTriangles)
myAspect->SetEdgeOn();
else
myAspect->SetEdgeOff();
-
- Prs3d_Root::CurrentGroup(aPrs)->SetGroupPrimitivesAspect(myAspect);
+
+ Prs3d_Root::CurrentGroup (aPrs)->SetGroupPrimitivesAspect (myAspect);
}
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-void AIS_TexturedShape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPrs,
- const Standard_Integer aMode)
+void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresManager*/,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
{
- aPrs->Clear();
-
- if(myshape.IsNull()) return;
-
- Standard_Integer TheType;
- TheType = (Standard_Integer) myshape.ShapeType();
- if(TheType>4 && TheType<8)
- {
- aPrs->SetVisual(Graphic3d_TOS_ALL);
- aPrs->SetDisplayPriority(TheType+2);
- }
+ thePrs->Clear();
+
+ if (myshape.IsNull())
+ {
+ return;
+ }
+
+ if (myshape.ShapeType() > TopAbs_FACE && myshape.ShapeType() < TopAbs_SHAPE)
+ {
+ thePrs->SetVisual (Graphic3d_TOS_ALL);
+ thePrs->SetDisplayPriority (myshape.ShapeType() + 2);
+ }
if (myshape.ShapeType() == TopAbs_COMPOUND)
+ {
+ TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
+ if (!anExplor.More())
{
- TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
- if (!anExplor.More()) {return;}
+ return;
}
+ }
if (IsInfinite())
- aPrs->SetInfiniteState(Standard_True);
-
- switch (aMode)
- {
+ {
+ thePrs->SetInfiniteState (Standard_True);
+ }
+ switch (theMode)
+ {
case 0: // Wireframe
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+ {
+ StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
break;
+ }
+ case 1: // Shading
+ {
+ Standard_Real prevangle;
+ Standard_Real newangle;
+ Standard_Real prevcoeff;
+ Standard_Real newcoeff;
- case 1: // Shading)
+ if (!OwnDeviationAngle (newangle, prevangle) && !OwnDeviationCoefficient (newcoeff, prevcoeff))
+ {
+ break;
+ }
+ if (Abs (newangle - prevangle) > Precision::Angular() || Abs (newcoeff - prevcoeff) > Precision::Confusion())
+ {
+ BRepTools::Clean (myshape);
+ }
+ if (myshape.ShapeType() > TopAbs_FACE)
{
- Standard_Real prevangle ;
- Standard_Real newangle ;
- Standard_Real prevcoeff ;
- Standard_Real newcoeff ;
-
- if (OwnDeviationAngle(newangle,prevangle) || OwnDeviationCoefficient(newcoeff,prevcoeff))
- if (Abs (newangle - prevangle) > Precision::Angular() || Abs (newcoeff - prevcoeff) > Precision::Confusion() )
- {
- BRepTools::Clean(myshape);
- }
- if ((Standard_Integer) myshape.ShapeType()>4)
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else
- {
- myDrawer->SetShadingAspectGlobal(Standard_False);
- if (IsInfinite())
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else
- {
- try
- {
- OCC_CATCH_SIGNALS
- StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
- }
- catch (Standard_Failure)
- {
- cout <<"AIS_TexturedShape::Compute() in ShadingMode failed \n" <<endl;
- StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
- }
- }
- }
- break;
+ StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ break;
}
+ myDrawer->SetShadingAspectGlobal (Standard_False);
+ if (IsInfinite())
+ {
+ StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ break;
+ }
+ try
+ {
+ OCC_CATCH_SIGNALS
+ StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer);
+ }
+ catch (Standard_Failure)
+ {
+ std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n";
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
+ }
+ break;
+ }
case 2: // Bounding box
+ {
+ if (IsInfinite())
{
- if (IsInfinite())
- {
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- }
- else
- {
- AIS_Shape::DisplayBox(aPrs,BoundingBox(),myDrawer);
- }
- break;
+ StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
}
-
- case 3: // texture mapping on triangulation
+ else
{
- BRepTools::Clean(myshape);
- BRepTools::Update(myshape);
-
- Handle(Graphic3d_StructureManager) aStrucMana = GetContext()->MainPrsMgr()->StructureManager();
- {
- Handle(Prs3d_ShadingAspect) aPrs3d_ShadingAspect = new Prs3d_ShadingAspect;
- myAspect = aPrs3d_ShadingAspect->Aspect();
- }
- if (!DoMapTexture)
- {
- myAspect->SetTextureMapOff();
- return;
- }
- myAspect->SetTextureMapOn();
-
- if(myPredefTexture!=-1)
- mytexture = new Graphic3d_Texture2Dmanual(aStrucMana, myPredefTexture);
- else
- mytexture = new Graphic3d_Texture2Dmanual(aStrucMana, myTextureFile.ToCString());
-
- if (!mytexture->IsDone())
- {
- cout <<"An error occured while building texture \n" <<endl;
- return;
- }
- if (myModulate)
- mytexture->EnableModulate();
- else
- mytexture->DisableModulate();
-
- myAspect->SetTextureMap(mytexture);
- if (DoShowTriangles)
- myAspect->SetEdgeOn();
- else
- myAspect->SetEdgeOff();
-
- if (DoRepeat)
- mytexture->EnableRepeat();
- else
- mytexture->DisableRepeat();
-
- myDeflection = AIS_Shape::GetDeflection(myshape,myDrawer);
- BRepMesh::Mesh(myshape,myDeflection);
- // Adds a triangulation of the shape myshape to its topological data structure.
- // This triangulation is computed with the deflection myDeflection.
-
-#ifdef DEBUG
- cout <<"Deflection = " << myDeflection << "\n" << endl;
-#endif
-
- StdPrs_ToolShadedShape SST;
-
- Standard_Integer NumFace;
- TopExp_Explorer ExpFace;
-
- for( NumFace=0,ExpFace.Init(myshape,TopAbs_FACE); ExpFace.More(); ExpFace.Next(),NumFace++ )
- {
- TopoDS_Face myFace = TopoDS::Face(ExpFace.Current());
- TopLoc_Location aLocation = myFace.Location();
-
-#ifdef DEBUG
- cout << "The face is being processed" << NumFace << "\n" << endl;
-#endif
- Handle(Poly_Triangulation) myT = BRep_Tool::Triangulation(myFace, aLocation);
- // Returns the Triangulation of the face. It is a null handle if there is no triangulation.
-
- if (myT.IsNull())
- {
-#ifdef DEBUG
- cout << "Triangulation of the face "<< i <<" is null \n"<< endl;
-#endif
- return;
- }
- Poly_Connect pc(myT);
- const TColgp_Array1OfPnt& Nodes = myT->Nodes();
- const TColgp_Array1OfPnt2d& UVNodes = myT->UVNodes();
- const Poly_Array1OfTriangle& triangles = myT->Triangles();
- TColgp_Array1OfDir myNormal(Nodes.Lower(), Nodes.Upper());
-
- SST.Normal(myFace, pc, myNormal);
- BRepTools::UVBounds(myFace,Umin, Umax, Vmin, Vmax);
- dUmax = (Umax - Umin);
- dVmax = (Vmax - Vmin);
- Handle(Graphic3d_Group) mygroup = Prs3d_Root::CurrentGroup(aPrs);
-
- Standard_Integer nnn = myT->NbTriangles(); // nnn : number of triangles
- Standard_Integer nt, n1, n2, n3 = 0; // nt : current triangle
- // ni : top i of the current triangle
- for (nt = 1; nt <= nnn; nt++)
- {
-#ifdef DEBUG
- cout << "The triangle is being processed: "<< nt <<"\n";
-#endif
- if (SST.Orientation(myFace) == TopAbs_REVERSED) // if the face is "reversed"
- triangles(nt).Get(n1,n3,n2); // the triangle is n1,n3,n2
- else
- triangles(nt).Get(n1,n2,n3); // the triangle is n1,n2,n3
-
- if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
- { // vertexNT associated to each node
- Graphic3d_Array1OfVertexNT Points(1,3);
- Aspect_Array1OfEdge aretes(1,3);
-
- mygroup->BeginPrimitives();
- {
- gp_Pnt p = Nodes(n1).Transformed(aLocation.Transformation());
- gp_Pnt q = Nodes(n2).Transformed(aLocation.Transformation());
- gp_Pnt r = Nodes(n3).Transformed(aLocation.Transformation());
-
- Points(1).SetCoord(p.X(), p.Y(), p.Z());
- Points(2).SetCoord(q.X(), q.Y(), q.Z());
- Points(3).SetCoord(r.X(), r.Y(), r.Z());
-
- Points(1).SetNormal(myNormal(n1).X(), myNormal(n1).Y(), myNormal(n1).Z());
- Points(2).SetNormal(myNormal(n2).X(), myNormal(n2).Y(), myNormal(n2).Z());
- Points(3).SetNormal(myNormal(n3).X(), myNormal(n3).Y(), myNormal(n3).Z());
-
- Points(1).SetTextureCoordinate((-myUOrigin+(myURepeat*(UVNodes(n1).X()-Umin))/dUmax)/myScaleU,
- (-myVOrigin+(myVRepeat*(UVNodes(n1).Y()-Vmin))/dVmax)/myScaleV);
- Points(2).SetTextureCoordinate((-myUOrigin+(myURepeat*(UVNodes(n2).X()-Umin))/dUmax)/myScaleU,
- (-myVOrigin+(myVRepeat*(UVNodes(n2).Y()-Vmin))/dVmax)/myScaleV);
- Points(3).SetTextureCoordinate((-myUOrigin+(myURepeat*(UVNodes(n3).X()-Umin))/dUmax)/myScaleU,
- (-myVOrigin+(myVRepeat*(UVNodes(n3).Y()-Vmin))/dVmax)/myScaleV);
-
- aretes(1).SetValues(1, 2, Aspect_TOE_INVISIBLE);
- aretes(2).SetValues(2, 3, Aspect_TOE_INVISIBLE);
- aretes(3).SetValues(3, 1, Aspect_TOE_INVISIBLE);
- }
- mygroup->EndPrimitives();
- mygroup->TriangleSet(Points, aretes, Standard_True);
-
- } // end of "if the triangle is valid
- } // end of the "parcours" of the triangles
- mygroup->SetGroupPrimitivesAspect(myAspect);
- }// end of the exploration of the shape in faces
- break;
- }// end case 3
-
- } // end switch
- // aPrs->ReCompute(); // for hidden line recomputation if necessary...
-}
+ AIS_Shape::DisplayBox (thePrs, BoundingBox(), myDrawer);
+ }
+ break;
+ }
+
+ case 3: // texture mapping on triangulation
+ {
+ BRepTools::Clean (myshape);
+ BRepTools::Update (myshape);
+ Handle(Graphic3d_StructureManager) aStrucMana = GetContext()->MainPrsMgr()->StructureManager();
+ {
+ Handle(Prs3d_ShadingAspect) aPrs3d_ShadingAspect = new Prs3d_ShadingAspect();
+ myAspect = aPrs3d_ShadingAspect->Aspect();
+ }
+ if (!DoMapTexture)
+ {
+ myAspect->SetTextureMapOff();
+ return;
+ }
+ myAspect->SetTextureMapOn();
+ if (myPredefTexture != -1)
+ mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myPredefTexture);
+ else
+ mytexture = new Graphic3d_Texture2Dmanual (aStrucMana, myTextureFile.ToCString());
+ if (!mytexture->IsDone())
+ {
+ std::cout << "An error occured while building texture \n";
+ return;
+ }
+ if (myModulate)
+ mytexture->EnableModulate();
+ else
+ mytexture->DisableModulate();
-/////////////////////////////////////////////////////////
-// QUERY METHODS
-/////////////////////////////////////////////////////////
+ myAspect->SetTextureMap (mytexture);
+ if (DoShowTriangles)
+ myAspect->SetEdgeOn();
+ else
+ myAspect->SetEdgeOff();
+ if (DoRepeat)
+ mytexture->EnableRepeat();
+ else
+ mytexture->DisableRepeat();
+ const gp_Pnt2d aUVOrigin (myUOrigin, myVOrigin);
+ const gp_Pnt2d aUVRepeat (myURepeat, myVRepeat);
+ const gp_Pnt2d aUVScale (myScaleU, myScaleV);
+ try
+ {
+ OCC_CATCH_SIGNALS
+ StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
+ Standard_True, aUVOrigin, aUVRepeat, aUVScale);
+ // within primitive arrays - object should be in one group of primitives
+ Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (myAspect);
+ }
+ catch (Standard_Failure)
+ {
+ std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n";
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
+ }
+ break;
+ }
+ }
+}
Standard_Boolean AIS_TexturedShape::TextureMapState() const
{
{
return myVRepeat;
}
+
Standard_Boolean AIS_TexturedShape::ShowTriangles() const
{
return DoShowTriangles;
}
+
Standard_Real AIS_TexturedShape::TextureUOrigin() const
{
return myUOrigin;
}
+
Standard_Real AIS_TexturedShape::TextureVOrigin() const
{
return myVOrigin;
}
+
Standard_Real AIS_TexturedShape::TextureScaleU() const
{
return myScaleU;
}
+
Standard_Real AIS_TexturedShape::TextureScaleV() const
{
return myScaleV;
}
-Standard_Boolean AIS_TexturedShape::TextureScale() const
+
+Standard_Boolean AIS_TexturedShape::TextureScale() const
{
return DoSetTextureScale;
}
-Standard_Boolean AIS_TexturedShape::TextureOrigin() const
+
+Standard_Boolean AIS_TexturedShape::TextureOrigin() const
{
return DoSetTextureOrigin;
}
-Standard_Boolean AIS_TexturedShape::TextureModulate() const
+
+Standard_Boolean AIS_TexturedShape::TextureModulate() const
{
return myModulate;
}
Graphic3d_Group_5.cxx
Graphic3d_Group_7.cxx
Graphic3d_Group_8.cxx
-Graphic3d_Group_9.cxx
Graphic3d_Group_10.cxx
-Graphic3d_Group_11.cxx
Graphic3d_Structure.pxx
Graphic3d_DataStructure.pxx
Graphic3d_StructureManager.pxx
is deferred;
---Purpose: call_togl_polygon
- Polygon ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertex from Graphic3d;
- Normal : Vector from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon
-
- Polygon ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexN from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon
-
- Polygon ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexN from Graphic3d;
- Normal : Vector from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon
-
- Polygon ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexNT from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon
-
- PolygonHoles ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_holes
-
- PolygonHoles ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertex from Graphic3d;
- Normal : Vector from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_holes
-
- PolygonHoles ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_holes
-
- PolygonHoles ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertexN from Graphic3d;
- Normal : Vector from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_holes
-
- ----------------------------------------
- -- Category: Methods to create Polyline
- -- for Purpose : see Graphic3d_Group.cdl
- ----------------------------------------
-
- Polyline ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- X1, Y1, Z1, X2, Y2, Z2 : Real from Standard;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polyline
-
- Polyline ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polyline
-
- Polyline ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexC from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polyline
-
- -----------------------------------------
- -- Category: Methods to create Quadrangle
- -- for Purpose : see Graphic3d_Group.cdl
- -----------------------------------------
-
- QuadrangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array2OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_quadrangle
-
- QuadrangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array2OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_quadrangle
-
- QuadrangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array2OfVertexNT from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_quadrangle
-
----------------------------------------
-- Category: Methods to create Text
-- for Purpose : see Graphic3d_Group.cdl
-- for Purpose : see Graphic3d_Group.cdl
----------------------------------------
- TriangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_triangle
-
- TriangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_triangle
-
- TriangleMesh ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexNT from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_triangle
-
- TriangleSet ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertex from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_indices
-
- TriangleSet ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexN from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_indices
-
- TriangleSet ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexNT from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_indices
-
- TriangleSet ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexC from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_indices
-
- TriangleSet ( me : mutable;
- ACGroup : CGroup from Graphic3d;
- ListVertex : Array1OfVertexNC from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- is deferred;
- ---Purpose: call_togl_polygon_indices
-
PrimitiveArray( me : mutable;
ACGroup : CGroup from Graphic3d;
parray : PrimitiveArray from Graphic3d;
-- using the current fill attributes (AspectFillArea3d))
-- The first and last points are not duplicates.
---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- ListVertex : Array1OfVertex from Graphic3d;
- Normal : Vector from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Links up points to create a face drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- The normal to the polygon is defined normalised.
- ---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- ListVertex : Array1OfVertexN from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Links up points to create a face drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- The normal is defined and normalised for each vertex.
- ---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- ListVertex : Array1OfVertexN from Graphic3d;
- Normal : Vector from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Links up points to create a face drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- The normal is defined for each vertex.
- -- The normal to the polygon is defined normalised.
- ---Category: Methods to create Polygon
-
-
- Polygon ( me : mutable;
- ListVertex : Array1OfVertexNT from Graphic3d;
- AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Links up points to create a face drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicated.
- -- The normal is defined and normalised for each vertex.
- -- The texture coordinate is defined for each vertex.
- ---Category: Methods to create Polygon
-
-
-
- --------------------------------------------------
- -- Summary of Polygons with holes --
- -- --
- -- They may have multiple boundaries. --
- -- --
- -- Each boundary should be closed. --
- -- --
- -- Each boundary should have at least three --
- -- vertices. --
- -- --
- -- They should be planar. --
- -- --
- -- They should have a normal. --
- -- --
- -- The boundary is drawn only when the interior --
- -- style is hollow. --
- -- --
- -- The boundary have the following attributes : --
- -- --
- -- Line Type. --
- -- Line Width Scale Factor. --
- -- Line Color. --
- -- --
- -- They have only interior attributes : --
- -- --
- -- Interior Style. --
- -- Interior Color. --
- -- Front Material. --
- -- Back Material. --
- --------------------------------------------------
-
- Polygon ( me : mutable;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Creates a face with holes.
- -- The face is described by the total number
- -- of vertices on the external contour and around the holes,
- -- and by the list of vertices.
- -- The face will be drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- Bounds : total number of interior and exterior vertices
- -- ListVertex : a list of the interior and exterior vertices
- ---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertex from Graphic3d;
- Normal : Vector from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Creates a face with holes.
- -- The face is described by the total number
- -- of vertices on the external contour and around the holes,
- -- and by the list of vertices.
- -- The face will be drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- The normal to the polygon is normalised.
- -- Bounds : total number of interior and exterior vertices
- -- ListVertex : a list of the interior and exterior vertices
- ---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Creates a face with holes.
- -- The face is described by the total number
- -- of vertices on the external contour and around the holes,
- -- and by the list of vertices.
- -- The face will be drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- Bounds : total number of interior and exterior vertices
- -- ListVertex : a list of the interior and exterior vertices
- ---Category: Methods to create Polygon
-
- Polygon ( me : mutable;
- Bounds : Array1OfInteger from TColStd;
- ListVertex : Array1OfVertexN from Graphic3d;
- Normal : Vector from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- is static;
- ---Level: Public
- ---Purpose: Creates a face with holes.
- -- The face is described by the total number
- -- of vertices on the external contour and around the holes,
- -- and by the list of vertices.
- -- The face will be drawn
- -- using the current fill attributes (AspectFillArea3d))
- -- The first and last points are not duplicates.
- -- The normal to the polygon is normalised.
- -- Bounds : total number of interior and exterior vertices
- -- ListVertex : a list of the interior and exterior vertices
- ---Category: Methods to create Polygon
-
+
PolygonSet ( me : mutable;
Bounds : Array1OfInteger from TColStd;
ListVertex : Array1OfVertex from Graphic3d;
-- for each vertex.
---Category: Methods to create Polyline
- -----------------------------------------
- -- Category: Methods to create Quadrangle
- -----------------------------------------
-
- QuadrangleMesh ( me : mutable;
- ListVertex : Array2OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of quadrilaterals from a list of
- -- points, such that their vertices are:
- -- Ki,j; Ki,j+1; Ki+1,j+1; Ki+1,j.
- -- The quadrilaterals will be drawn according to the
- -- current attributes (AspectFillArea3d).
- -- Category: Methods to create Quadrangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than four points.
- raises GroupDefinitionError from Graphic3d is static;
-
- QuadrangleMesh ( me : mutable;
- ListVertex : Array2OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of quadrilaterals from a list of
- -- points, such that their vertices are:
- -- Ki,j; Ki,j+1; Ki+1,j+1; Ki+1,j.
- -- The quadrilaterals will be drawn according to the
- -- current attributes (AspectFillArea3d).
- -- For each vertex the normal is given.
- -- Category: Methods to create Quadrangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than four points.
- raises GroupDefinitionError from Graphic3d is static;
-
- QuadrangleMesh ( me : mutable;
- ListVertex : Array2OfVertexNT from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of quadrilaterals from a list of
- -- points, such that their vertices are:
- -- Ki,j; Ki,j+1; Ki+1,j+1; Ki+1,j.
- -- The quadrilaterals will be drawn according to the
- -- current attributes (AspectFillArea3d).
- -- For each vertex the normal is given.
- -- For each vertex a texture coordinate is given.
- -- Category: Methods to create Quadrangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than four points.
- raises GroupDefinitionError from Graphic3d is static;
-
-----------------------------------
-- Category: Methods to create Text
-----------------------------------
---------------------------------------
---Category: Methods to create Triangle
---------------------------------------
-
- TriangleMesh ( me : mutable;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates triangles from an array of points such that
- -- the Kth triangle contains the vertices K, K+1, K+2.
- -- The triangle will be drawn using the current fill
- -- attributes (AspectFillArea3d)
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleMesh ( me : mutable;
- ListVertex : Array1OfVertexN from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates triangles from an array of points such that
- -- the Kth triangle contains the vertices K, K+1, K+2.
- -- The triangle will be drawn using the current fill
- -- attributes (AspectFillArea3d)
- -- The normal is given for each vertex.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleMesh ( me : mutable;
- ListVertex : Array1OfVertexNT from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates triangles from an array of points such that
- -- the Kth triangle contains the vertices K, K+1, K+2.
- -- The triangle will be drawn using the current fill
- -- attributes (AspectFillArea3d)
- -- The normal is given for each vertex.
- -- A texture coordinate is given for each vertex.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleSet ( me : mutable;
- ListVertex : Array1OfVertex from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of triangles defined by a table of
- -- vertices and a table of edges, visible or not.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points or if <ListEdge> contains
- -- less than three edges.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleSet ( me : mutable;
- ListVertex : Array1OfVertexN from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of triangles defined by a table of
- -- vertices and a table of edges, visible or not.
- -- For each vertex the normal is given.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points or if <ListEdge> contains
- -- less than three edges.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleSet ( me : mutable;
- ListVertex : Array1OfVertexNT from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of triangles defined by a table of
- -- vertices and a table of edges, visible or not.
- -- For each vertex the normal is given.
- -- For each vertex a texture coordinate is given.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points or if <ListEdge> contains
- -- less than three edges.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleSet ( me : mutable;
- ListVertex : Array1OfVertexC from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of triangles defined by a table of
- -- vertices and a table of edges, visible or not.
- -- For each vertex the color is given.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points or if <ListEdge> contains
- -- less than three edges.
- raises GroupDefinitionError from Graphic3d is static;
-
- TriangleSet ( me : mutable;
- ListVertex : Array1OfVertexNC from Graphic3d;
- ListEdge : Array1OfEdge from Aspect;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Public
- ---Purpose: Creates a group of triangles defined by a table of
- -- vertices and a table of edges, visible or not.
- -- For each vertex the normal and the color are given.
- -- Category: Methods to create Triangle
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than three points or if <ListEdge> contains
- -- less than three edges.
- raises GroupDefinitionError from Graphic3d is static;
-
+
AddPrimitiveArray( me : mutable;
elem : ArrayOfPrimitives from Graphic3d;
EvalMinMax: Boolean from Standard = Standard_True );
is static;
---Level: Internal
---Category: Internal methods
-
- Bezier ( me : mutable;
- ListVertex : Array1OfVertex from Graphic3d;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Internal
- ---Purpose: Creates a non rational Bezier curve with a set of poles :
- -- ListVertex. The weights are defaulted to all being 1.
- -- Category: Methods to create Curve
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than two points.
- raises GroupDefinitionError from Graphic3d is static;
-
- Bezier ( me : mutable;
- ListVertex : Array1OfVertex from Graphic3d;
- ListWeight : Array1OfReal from TColStd;
- EvalMinMax : Boolean from Standard = Standard_True )
- ---Level: Internal
- ---Purpose: Creates a non rational Bezier curve with a set of poles :
- -- ListVertex and the set of weights ListWeight.
- -- If all the weights are identical the curve is considered
- -- as non rational.
- -- Category: Methods to create Curve
- -- Warning: Raises GroupDefinitionError if <ListVertex> contains
- -- less than two points or <ListVertex> and <ListWeight>
- -- have not the same length or one weight value is lower
- -- or equal to Resolution from package gp.
- raises GroupDefinitionError from Graphic3d is static;
-
+
--
fields
+++ /dev/null
-// Created by: NW,JPB,CAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-// Modified
-// 27/08/97 ; PCT : ajout coordonnee texture
-
-
-//-Version
-
-//-Design Declaration des variables specifiques aux groupes
-// de primitives
-
-//-Warning Un groupe est defini dans une structure
-// Il s'agit de la plus petite entite editable
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <Graphic3d_Group.jxx>
-#include <Graphic3d_Group.pxx>
-
-#include <Graphic3d_VertexN.hxx>
-#include <Graphic3d_VertexC.hxx>
-#include <Graphic3d_VertexNT.hxx>
-
-//-Methods, in order
-
-void Graphic3d_Group::TriangleMesh (const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
-
- if (i <= 2)
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::TriangleMesh (const Graphic3d_Array1OfVertexN& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
-
- if (i <= 2)
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-
-void Graphic3d_Group::TriangleMesh(const Graphic3d_Array1OfVertexNT& ListVertex,const Standard_Boolean EvalMinMax)
-{
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
-
- if (i <= 2)
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-
-void Graphic3d_Group::TriangleSet (const Graphic3d_Array1OfVertex& ListVertex, const Aspect_Array1OfEdge& ListEdge, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
- j = ListEdge.Length ();
-
- if ((i <= 2) || (j <= 2))
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleSet
- (MyCGroup, ListVertex, ListEdge, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::TriangleSet (const Graphic3d_Array1OfVertexN& ListVertex, const Aspect_Array1OfEdge& ListEdge, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
- j = ListEdge.Length ();
-
- if ((i <= 2) || (j <= 2))
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleSet
- (MyCGroup, ListVertex, ListEdge, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::TriangleSet (const Graphic3d_Array1OfVertexC& ListVertex, const Aspect_Array1OfEdge& ListEdge, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
- j = ListEdge.Length ();
-
- if ((i <= 2) || (j <= 2))
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleSet
- (MyCGroup, ListVertex, ListEdge, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::TriangleSet (const Graphic3d_Array1OfVertexNC& ListVertex, const Aspect_Array1OfEdge& ListEdge, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
- j = ListEdge.Length ();
-
- if ((i <= 2) || (j <= 2))
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleSet
- (MyCGroup, ListVertex, ListEdge, EvalMinMax);
-
- Update ();
-
-}
-
-
-
-void Graphic3d_Group::TriangleSet(const Graphic3d_Array1OfVertexNT& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax)
-{
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Integer i, j;
-
- i = ListVertex.Length ();
- j = ListEdge.Length ();
-
- if ((i <= 2) || (j <= 2))
- Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Real X, Y, Z;
-Standard_Integer Lower = ListVertex.Lower ();
-Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->TriangleSet
- (MyCGroup, ListVertex, ListEdge, EvalMinMax);
-
- Update ();
-
-}
}
-void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, j;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polygon
- (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (i=Lower; i<=Upper; i++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (i=Lower; i<=Upper; i++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polygon
- (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
-
- Update ();
-
-}
-
void Graphic3d_Group::PolygonSet (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
if (IsDeleted ()) return;
}
}
-
-void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, ii;
- Standard_Integer k, kk;
- Standard_Integer begin_points;
- Standard_Integer end_points;
- Standard_Integer Lower, Upper;
-
- begin_points = ListVertex.Lower ();
- end_points = ListVertex.Upper ();
-
- Lower = Bounds.Lower ();
- Upper = Bounds.Upper ();
- // Parcours des facettes
- for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
- // Parcours des sommets
- for (i=0, ii=begin_points;
- ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
- i++, ii++) {
- ListVertex (ii).Coord (X, Y, Z);
-
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- begin_points += int (Bounds.Value (kk));
- }
- }
-
- MyGraphicDriver->PolygonHoles
- (MyCGroup, Bounds, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, ii;
- Standard_Integer k, kk;
- Standard_Integer begin_points;
- Standard_Integer end_points;
- Standard_Integer Lower, Upper;
-
- begin_points = ListVertex.Lower ();
- end_points = ListVertex.Upper ();
-
- Lower = Bounds.Lower ();
- Upper = Bounds.Upper ();
- // Parcours des facettes
- for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
- // Parcours des sommets
- for (i=0, ii=begin_points;
- ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
- i++, ii++) {
- ListVertex (ii).Coord (X, Y, Z);
-
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- begin_points += int (Bounds.Value (kk));
- }
- }
-
- MyGraphicDriver->PolygonHoles
- (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, ii;
- Standard_Integer k, kk;
- Standard_Integer begin_points;
- Standard_Integer end_points;
- Standard_Integer Lower, Upper;
-
- begin_points = ListVertex.Lower ();
- end_points = ListVertex.Upper ();
-
- Lower = Bounds.Lower ();
- Upper = Bounds.Upper ();
- // Parcours des facettes
- for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
- // Parcours des sommets
- for (i=0, ii=begin_points;
- ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
- i++, ii++) {
- ListVertex (ii).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- begin_points += int (Bounds.Value (kk));
- }
- }
-
- MyGraphicDriver->PolygonHoles
- (MyCGroup, Bounds, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, ii;
- Standard_Integer k, kk;
- Standard_Integer begin_points;
- Standard_Integer end_points;
- Standard_Integer Lower, Upper;
-
- begin_points = ListVertex.Lower ();
- end_points = ListVertex.Upper ();
-
- Lower = Bounds.Lower ();
- Upper = Bounds.Upper ();
- // Parcours des facettes
- for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
- // Parcours des sommets
- for (i=0, ii=begin_points;
- ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
- i++, ii++) {
- ListVertex (ii).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- begin_points += int (Bounds.Value (kk));
- }
- }
-
- MyGraphicDriver->PolygonHoles
- (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
-
- Update ();
-
-}
-
-
-
-void Graphic3d_Group::Polygon(const Graphic3d_Array1OfVertexNT& ListVertex,const Graphic3d_TypeOfPolygon AType,const Standard_Boolean EvalMinMax)
-{
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (i=Lower; i<=Upper; i++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
-
- Update ();
-
-}
#include <Graphic3d_Group.jxx>
#include <Graphic3d_Group.pxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_VertexC.hxx>
-
-//-Methods, in order
-
-void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, j;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polyline (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
+#include <gp_Pnt.hxx>
+
+void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertex& theListVertex,
+ const Standard_Boolean theToEvalMinMax)
+{
+ if (IsDeleted())
+ {
+ return;
+ }
+
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines (theListVertex.Length());
+
+ Standard_Real aX, aY, aZ;
+ Standard_Integer aVertLower = theListVertex.Lower();
+ Standard_Integer aVertUpper = theListVertex.Upper();
+ for (Standard_Integer aVertIter = aVertLower; aVertIter <= aVertUpper; ++aVertIter)
+ {
+ const Graphic3d_Vertex& aVert = theListVertex (aVertIter);
+ aVert.Coord (aX, aY, aZ);
+ aPrims->AddVertex (aX, aY, aZ);
+ }
+
+ AddPrimitiveArray (aPrims, theToEvalMinMax);
}
-void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertexC& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- MyIsEmpty = Standard_False;
-
- // Min-Max Update
- if (EvalMinMax) {
- Standard_Real X, Y, Z;
- Standard_Integer i, j;
- Standard_Integer Lower = ListVertex.Lower ();
- Standard_Integer Upper = ListVertex.Upper ();
- // Parcours des sommets
- for (j=0, i=Lower; i<=Upper; i++, j++) {
- ListVertex (i).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->Polyline (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
+void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertexC& theListVertex,
+ const Standard_Boolean theToEvalMinMax)
+{
+ if (IsDeleted())
+ {
+ return;
+ }
+
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims
+ = new Graphic3d_ArrayOfPolylines (theListVertex.Length(), 0, 0, Standard_True); // color per vertex
+
+ Standard_Real aX, aY, aZ;
+ Standard_Integer aVertLower = theListVertex.Lower();
+ Standard_Integer aVertUpper = theListVertex.Upper();
+ for (Standard_Integer aVertIter = aVertLower; aVertIter <= aVertUpper; ++aVertIter)
+ {
+ const Graphic3d_VertexC& aVert = theListVertex (aVertIter);
+ aVert.Coord (aX, aY, aZ);
+ aPrims->AddVertex (gp_Pnt (aX, aY, aZ), aVert.Color());
+ }
+
+ AddPrimitiveArray (aPrims, theToEvalMinMax);
}
-void Graphic3d_Group::Polyline (const Graphic3d_Vertex& APT1, const Graphic3d_Vertex& APT2, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- MyIsEmpty = Standard_False;
-
-Standard_Real X1, Y1, Z1;
-Standard_Real X2, Y2, Z2;
-
- APT1.Coord (X1, Y1, Z1);
- APT2.Coord (X2, Y2, Z2);
+void Graphic3d_Group::Polyline (const Graphic3d_Vertex& thePnt1,
+ const Graphic3d_Vertex& thePnt2,
+ const Standard_Boolean theToEvalMinMax)
+{
+ if (IsDeleted())
+ {
+ return;
+ }
- // Min-Max Update
- if (EvalMinMax) {
- if (X1 < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X1);
- if (Y1 < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y1);
- if (Z1 < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z1);
- if (X1 > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X1);
- if (Y1 > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y1);
- if (Z1 > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z1);
- if (X2 < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X2);
- if (Y2 < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y2);
- if (Z2 < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z2);
- if (X2 > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X2);
- if (Y2 > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y2);
- if (Z2 > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z2);
- }
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines (2);
- MyGraphicDriver->Polyline (MyCGroup, X1, Y1, Z1, X2, Y2, Z2, EvalMinMax);
+ Standard_Real aX, aY, aZ;
+ thePnt1.Coord (aX, aY, aZ);
+ aPrims->AddVertex (aX, aY, aZ);
- Update ();
+ thePnt2.Coord (aX, aY, aZ);
+ aPrims->AddVertex (aX, aY, aZ);
+ AddPrimitiveArray (aPrims, theToEvalMinMax);
}
+++ /dev/null
-// Created by: NW,JPB,CAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-// Modified
-// 27/08/97 ; PCT : ajout coordonnee texture
-
-
-//-Version
-
-//-Design Declaration des variables specifiques aux groupes
-// de primitives
-
-//-Warning Un groupe est defini dans une structure
-// Il s'agit de la plus petite entite editable
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-#include <Graphic3d_Group.jxx>
-#include <Graphic3d_Group.pxx>
-
-void Graphic3d_Group::QuadrangleMesh (const Graphic3d_Array2OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Real X, Y, Z;
-
- // Min-Max Update
- if (EvalMinMax) {
-Standard_Integer i, j;
-Standard_Integer LowerRow = ListVertex.LowerRow ();
-Standard_Integer UpperRow = ListVertex.UpperRow ();
-Standard_Integer LowerCol = ListVertex.LowerCol ();
-Standard_Integer UpperCol = ListVertex.UpperCol ();
- // Parcours des sommets
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++) {
- ListVertex (i, j).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->QuadrangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-void Graphic3d_Group::QuadrangleMesh (const Graphic3d_Array2OfVertexN& ListVertex, const Standard_Boolean EvalMinMax) {
-
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Real X, Y, Z;
-
-Standard_Integer i, j;
-Standard_Integer LowerRow = ListVertex.LowerRow ();
-Standard_Integer UpperRow = ListVertex.UpperRow ();
-Standard_Integer LowerCol = ListVertex.LowerCol ();
-Standard_Integer UpperCol = ListVertex.UpperCol ();
-
- // Min-Max Update
- if (EvalMinMax) {
- // Parcours des sommets
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++) {
- ListVertex (i, j).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->QuadrangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
-
-
-void Graphic3d_Group::QuadrangleMesh(const Graphic3d_Array2OfVertexNT& ListVertex,const Standard_Boolean EvalMinMax)
-{
- if (IsDeleted ()) return;
-
- if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
- MyContainsFacet = Standard_True;
- MyIsEmpty = Standard_False;
-
-Standard_Real X, Y, Z;
-
-Standard_Integer i, j;
-Standard_Integer LowerRow = ListVertex.LowerRow ();
-Standard_Integer UpperRow = ListVertex.UpperRow ();
-Standard_Integer LowerCol = ListVertex.LowerCol ();
-Standard_Integer UpperCol = ListVertex.UpperCol ();
-
- // Min-Max Update
- if (EvalMinMax) {
- // Parcours des sommets
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++) {
- ListVertex (i, j).Coord (X, Y, Z);
- if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X);
- if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y);
- if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z);
- if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X);
- if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y);
- if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z);
- }
- }
-
- MyGraphicDriver->QuadrangleMesh (MyCGroup, ListVertex, EvalMinMax);
-
- Update ();
-
-}
OpenGl_GraphicDriver_9.cxx
OpenGl_GraphicDriver_703.cxx
OpenGl_GraphicDriver_705.cxx
-OpenGl_GraphicDriver_707.cxx
-OpenGl_GraphicDriver_709.cxx
OpenGl_GraphicDriver_710.cxx
-OpenGl_GraphicDriver_711.cxx
OpenGl_GraphicDriver_713.cxx
OpenGl_GraphicDriver_Layer.cxx
OpenGl_GraphicDriver_print.cxx
OpenGl_MarkerSet.cxx
OpenGl_Polygon.hxx
OpenGl_Polygon.cxx
-OpenGl_QuadrangleStrip.hxx
-OpenGl_QuadrangleStrip.cxx
-OpenGl_TriangleStrip.hxx
-OpenGl_TriangleStrip.cxx
-OpenGl_Mesh.hxx
-OpenGl_Mesh.cxx
OpenGl_PrimitiveArray.hxx
OpenGl_PrimitiveArray.cxx
Handle_OpenGl_Workspace.hxx
#include <OpenGl_ExtFBO.hxx>
#include <OpenGl_GlCore20.hxx>
+#include <Standard_ProgramError.hxx>
+
#if (defined(_WIN32) || defined(__WIN32__))
//
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
delete extFBO;
}
+// =======================================================================
+// function : MakeCurrent
+// purpose :
+// =======================================================================
+Standard_Boolean OpenGl_Context::MakeCurrent()
+{
+#if (defined(_WIN32) || defined(__WIN32__))
+ if (myWindowDC == NULL || myGContext == NULL ||
+ !wglMakeCurrent ((HDC )myWindowDC, (HGLRC )myGContext))
+ {
+ //GLenum anErrCode = glGetError();
+ //const GLubyte* anErrorString = gluErrorString (anErrCode);
+ //std::cerr << "wglMakeCurrent() failed: " << anErrCode << " " << anErrorString << "\n";
+ return Standard_False;
+ }
+#else
+ if (myDisplay == NULL || myWindow == 0 || myGContext == 0 ||
+ !glXMakeCurrent ((Display* )myDisplay, (GLXDrawable )myWindow, (GLXContext )myGContext))
+ {
+ // if there is no current context it might be impossible to use glGetError() correctly
+ //std::cerr << "glXMakeCurrent() failed!\n";
+ return Standard_False;
+ }
+#endif
+ return Standard_True;
+}
+
// =======================================================================
// function : findProc
// purpose :
// function : CheckExtension
// purpose :
// =======================================================================
-Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName)
+Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const
{
if (theExtName == NULL)
{
// available since OpenGL 3.0
// and the ONLY way to check extensions with OpenGL 3.1+ core profile
- /**if (IsGlUpperEqual (3, 0))
+ /**if (IsGlGreaterEqual (3, 0))
{
GLint anExtNb = 0;
glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb);
// =======================================================================
void OpenGl_Context::Init()
{
- if (!myIsInitialized)
+ if (myIsInitialized)
{
- init();
- myIsInitialized = Standard_True;
+ return;
}
+
+#if (defined(_WIN32) || defined(__WIN32__))
+ myWindowDC = (Aspect_Handle )wglGetCurrentDC();
+ myGContext = (Aspect_RenderingContext )wglGetCurrentContext();
+#else
+ myDisplay = (Aspect_Display )glXGetCurrentDisplay();
+ myGContext = (Aspect_RenderingContext )glXGetCurrentContext();
+ myWindow = (Aspect_Drawable )glXGetCurrentDrawable();
+#endif
+
+ init();
+ myIsInitialized = Standard_True;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+#if (defined(_WIN32) || defined(__WIN32__))
+void OpenGl_Context::Init (const Aspect_Handle theWindow,
+ const Aspect_Handle theWindowDC,
+ const Aspect_RenderingContext theGContext)
+#else
+void OpenGl_Context::Init (const Aspect_Drawable theWindow,
+ const Aspect_Display theDisplay,
+ const Aspect_RenderingContext theGContext)
+#endif
+{
+ Standard_ProgramError_Raise_if (myIsInitialized, "OpenGl_Context::Init() should be called only once!");
+
+ myWindow = theWindow;
+ myGContext = theGContext;
+#if (defined(_WIN32) || defined(__WIN32__))
+ myWindowDC = theWindowDC;
+#else
+ myDisplay = theDisplay;
+#endif
+
+ init();
+ myIsInitialized = Standard_True;
}
// =======================================================================
memset (myGlCore20, 0, sizeof(OpenGl_GlCore20)); // nullify whole structure
// initialize OpenGL 1.2 core functionality
- if (IsGlUpperEqual (1, 2))
+ if (IsGlGreaterEqual (1, 2))
{
if (!FindProcShort (myGlCore20, glBlendColor)
|| !FindProcShort (myGlCore20, glBlendEquation)
}
// initialize OpenGL 1.3 core functionality
- if (IsGlUpperEqual (1, 3))
+ if (IsGlGreaterEqual (1, 3))
{
if (!FindProcShort (myGlCore20, glActiveTexture)
|| !FindProcShort (myGlCore20, glSampleCoverage)
}
// initialize OpenGL 1.4 core functionality
- if (IsGlUpperEqual (1, 4))
+ if (IsGlGreaterEqual (1, 4))
{
if (!FindProcShort (myGlCore20, glBlendFuncSeparate)
|| !FindProcShort (myGlCore20, glMultiDrawArrays)
}
// initialize OpenGL 1.5 core functionality
- if (IsGlUpperEqual (1, 5))
+ if (IsGlGreaterEqual (1, 5))
{
if (!FindProcShort (myGlCore20, glGenQueries)
|| !FindProcShort (myGlCore20, glDeleteQueries)
}
// initialize OpenGL 2.0 core functionality
- if (IsGlUpperEqual (2, 0))
+ if (IsGlGreaterEqual (2, 0))
{
if (!FindProcShort (myGlCore20, glBlendEquationSeparate)
|| !FindProcShort (myGlCore20, glDrawBuffers)
}
}
- if (IsGlUpperEqual (2, 0))
+ if (IsGlGreaterEqual (2, 0))
{
core12 = myGlCore20;
core13 = myGlCore20;
#ifndef _OpenGl_Context_H__
#define _OpenGl_Context_H__
+#include <Aspect_Handle.hxx>
+#include <Aspect_Drawable.hxx>
+#include <Aspect_Display.hxx>
+#include <Aspect_RenderingContext.hxx>
#include <Standard_Transient.hxx>
#include <Handle_OpenGl_Context.hxx>
//! GL context should be active!
Standard_EXPORT void Init();
+#if (defined(_WIN32) || defined(__WIN32__))
+ Standard_EXPORT void Init (const Aspect_Handle theWindow,
+ const Aspect_Handle theWindowDC,
+ const Aspect_RenderingContext theGContext);
+#else
+ Standard_EXPORT void Init (const Aspect_Drawable theWindow,
+ const Aspect_Display theDisplay,
+ const Aspect_RenderingContext theGContext);
+#endif
+
//! Check if theExtName extension is supported by active GL context.
- Standard_EXPORT static Standard_Boolean CheckExtension (const char* theExtName);
+ Standard_EXPORT Standard_Boolean CheckExtension (const char* theExtName) const;
//! Auxiliary template to retrieve GL function pointer.
//! Pointer to function retrieved from library is statically casted
return (theFuncPtr != NULL);
}
- //! @return true if detected GL version is higher or equal to requested one.
- inline Standard_Boolean IsGlUpperEqual (const Standard_Integer theVerMajor,
- const Standard_Integer theVerMinor)
+ //! @return true if detected GL version is greater or equal to requested one.
+ inline Standard_Boolean IsGlGreaterEqual (const Standard_Integer theVerMajor,
+ const Standard_Integer theVerMinor)
{
return (myGlVerMajor > theVerMajor)
|| (myGlVerMajor == theVerMajor && myGlVerMinor >= theVerMinor);
//! Clean up errors stack for this GL context (glGetError() in loop).
Standard_EXPORT void ResetErrors();
+ //! Activates current context.
+ //! Class should be initialized with appropriate info.
+ Standard_EXPORT Standard_Boolean MakeCurrent();
+
private:
//! Wrapper to system function to retrieve GL function pointer by name.
private:
+#if (defined(_WIN32) || defined(__WIN32__))
+ Aspect_Handle myWindow; //!< window handle (owner of GL context) : HWND
+ Aspect_Handle myWindowDC; //!< Device Descriptor handle : HDC
+ Aspect_RenderingContext myGContext; //!< Rendering Context handle : HGLRC
+#else
+ Aspect_Drawable myWindow; //!< window handle (owner of GL context) : GLXDrawable
+ Aspect_Display myDisplay; //!< connection to the X-server : Display*
+ Aspect_RenderingContext myGContext; //!< X-GLX rendering context : GLXContext
+#endif
+
void* myGlLibHandle; //!< optional handle to GL library
OpenGl_GlCore20* myGlCore20; //!< common structure for GL core functions upto 2.0
Standard_Integer myGlVerMajor; //!< cached GL version major number
Standard_EXPORT void Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void MarkerSet (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertexNT& ListVertex, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void PolygonHoles (const Graphic3d_CGroup& ACGroup, const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void PolygonHoles (const Graphic3d_CGroup& ACGroup, const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void PolygonHoles (const Graphic3d_CGroup& ACGroup, const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void PolygonHoles (const Graphic3d_CGroup& ACGroup, const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polyline (const Graphic3d_CGroup& ACGroup, const Standard_Real X1, const Standard_Real Y1, const Standard_Real Z1, const Standard_Real X2, const Standard_Real Y2, const Standard_Real Z2, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polyline (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void Polyline (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertexC& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void QuadrangleMesh (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array2OfVertex& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void QuadrangleMesh (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array2OfVertexN& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void QuadrangleMesh (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array2OfVertexNT& ListVertex, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleMesh (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertex& ListVertex,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleMesh (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexN& ListVertex,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleMesh (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexNT& ListVertex,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleSet (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertex& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleSet (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexN& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleSet (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexNT& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleSet (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexC& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax = Standard_True);
- Standard_EXPORT void TriangleSet (const Graphic3d_CGroup& ACGroup,const Graphic3d_Array1OfVertexNC& ListVertex,const Aspect_Array1OfEdge& ListEdge,const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void PrimitiveArray (const Graphic3d_CGroup& ACGroup,const Graphic3d_PrimitiveArray& parray,const Standard_Boolean EvalMinMax = Standard_True);
Standard_EXPORT void UserDraw (const Graphic3d_CGroup& ACGroup,const Graphic3d_CUserDraw& AUserDraw);
Standard_EXPORT void ZBufferTriedronSetup (const Quantity_NameOfColor XColor = Quantity_NOC_RED, const Quantity_NameOfColor YColor = Quantity_NOC_GREEN, const Quantity_NameOfColor ZColor = Quantity_NOC_BLUE1, const Standard_Real SizeRatio = 0.8, const Standard_Real AxisDiametr = 0.05, const Standard_Integer NbFacettes = 12);
((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygon, apolygon );
}
}
-
-void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ,
- const Graphic3d_Array1OfVertex& ,
- const Graphic3d_Vector& ,
- const Graphic3d_TypeOfPolygon ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ,
- const Graphic3d_Array1OfVertexN& ,
- const Graphic3d_TypeOfPolygon ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ,
- const Graphic3d_Array1OfVertexN& ,
- const Graphic3d_Vector& ,
- const Graphic3d_TypeOfPolygon ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ,
- const Graphic3d_Array1OfVertexNT& ,
- const Graphic3d_TypeOfPolygon ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ,
- const TColStd_Array1OfInteger& ,
- const Graphic3d_Array1OfVertex& ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ,
- const TColStd_Array1OfInteger& ,
- const Graphic3d_Array1OfVertex& ,
- const Graphic3d_Vector& ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ,
- const TColStd_Array1OfInteger& ,
- const Graphic3d_Array1OfVertexN& ,
- const Standard_Boolean )
-{
- // Do nothing
-}
-
-void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ,
- const TColStd_Array1OfInteger& ,
- const Graphic3d_Array1OfVertexN& ,
- const Graphic3d_Vector& ,
- const Standard_Boolean )
-{
- // Do nothing
-}
+++ /dev/null
-// Created on: 2011-10-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GraphicDriver.hxx>
-
-#include <OpenGl_Group.hxx>
-#include <OpenGl_Polyline.hxx>
-
-void OpenGl_GraphicDriver::Polyline (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertex& AListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Polyline *apolyline = new OpenGl_Polyline( AListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolyline, apolyline );
- }
-}
-
-void OpenGl_GraphicDriver::Polyline (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexC& AListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Polyline *apolyline = new OpenGl_Polyline( AListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolyline, apolyline );
- }
-}
-
-void OpenGl_GraphicDriver::Polyline (const Graphic3d_CGroup& ACGroup,
- const Standard_Real X1,
- const Standard_Real Y1,
- const Standard_Real Z1,
- const Standard_Real X2,
- const Standard_Real Y2,
- const Standard_Real Z2,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Polyline *apolyline = new OpenGl_Polyline( X1, Y1, Z1, X2, Y2, Z2 );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolyline, apolyline );
- }
-}
+++ /dev/null
-// Created on: 2011-10-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GraphicDriver.hxx>
-
-#include <OpenGl_Group.hxx>
-#include <OpenGl_QuadrangleStrip.hxx>
-
-void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array2OfVertex& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_QuadrangleStrip *aqstrip = new OpenGl_QuadrangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelQuadrangle, aqstrip );
- }
-}
-
-void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array2OfVertexN& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_QuadrangleStrip *aqstrip = new OpenGl_QuadrangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelQuadrangle, aqstrip );
- }
-}
-
-void OpenGl_GraphicDriver::QuadrangleMesh(const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array2OfVertexNT& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_QuadrangleStrip *aqstrip = new OpenGl_QuadrangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelQuadrangle, aqstrip );
- }
-}
+++ /dev/null
-// Created on: 2011-10-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GraphicDriver.hxx>
-
-#include <OpenGl_Group.hxx>
-#include <OpenGl_TriangleStrip.hxx>
-#include <OpenGl_Mesh.hxx>
-
-void OpenGl_GraphicDriver::TriangleMesh (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertex& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_TriangleStrip *atstrip = new OpenGl_TriangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelTriangleMesh, atstrip );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleMesh (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexN& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_TriangleStrip *atstrip = new OpenGl_TriangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelTriangleMesh, atstrip );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleMesh(const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexNT& ListVertex,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_TriangleStrip *atstrip = new OpenGl_TriangleStrip( ListVertex );
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelTriangleMesh, atstrip );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertex& ListVertex,
- const Aspect_Array1OfEdge& ListEdge,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Mesh *amesh = new OpenGl_Mesh (ListVertex, ListEdge);
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygonIndices, amesh );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexN& ListVertex,
- const Aspect_Array1OfEdge& ListEdge,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Mesh *amesh = new OpenGl_Mesh (ListVertex, ListEdge);
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygonIndices, amesh );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexC& ListVertex,
- const Aspect_Array1OfEdge& ListEdge,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Mesh *amesh = new OpenGl_Mesh (ListVertex, ListEdge);
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygonIndices, amesh );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexNC& ListVertex,
- const Aspect_Array1OfEdge& ListEdge,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Mesh *amesh = new OpenGl_Mesh (ListVertex, ListEdge);
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygonIndices, amesh );
- }
-}
-
-void OpenGl_GraphicDriver::TriangleSet(const Graphic3d_CGroup& ACGroup,
- const Graphic3d_Array1OfVertexNT& ListVertex,
- const Aspect_Array1OfEdge& ListEdge,
- const Standard_Boolean )
-{
- if (ACGroup.ptrGroup)
- {
- OpenGl_Mesh *amesh = new OpenGl_Mesh (ListVertex, ListEdge);
- ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygonIndices, amesh );
- }
-}
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#define OCC749 /* SAV 19/09/02 added processing of colored vertices */
-#define OCC7824 /* ASL 26/01/05 transparency of polygon with colors assigned to vertices */
-
-/*----------------------------------------------------------------------*/
-/*
-* Includes
-*/
-
-#include <OpenGl_GlCore11.hxx>
-
-#include <OpenGl_Mesh.hxx>
-
-#include <OpenGl_telem_util.hxx>
-#include <OpenGl_TextureBox.hxx>
-
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_Structure.hxx>
-
-#include <float.h>
-
-static long s_Rand = 1L;
-# define OPENGL_RAND() ( ( unsigned )( s_Rand = s_Rand * 214013L + 2531011L ) )
-
-/*----------------------------------------------------------------------*/
-/*
-* Prototypes
-*/
-
-typedef TEL_INDEXPOLY_DATA* tel_indexpoly_data;
-
-void set_drawable_items ( GLboolean*, int, const float );
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Mesh::draw_indexpoly (const Tint front_lighting_model,
- const Aspect_InteriorStyle interior_style,
- const TEL_COLOUR *edge_colour,
- const OPENGL_SURF_PROP *prop,
- const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- Tint i, j, k, a, newList = 0;
- Tint lighting_model;
-
- /* Following pointers have been provided for performance improvement */
- Tint *ind;
- tel_point pfn, pvn, pv;
- tel_colour pvc, pfc;
- tel_texture_coord pvt;
-
- ind = myData.indices;
- pfn = myData.fnormals;
- pvn = myData.vnormals;
- pvc = myData.vcolours;
- pfc = myData.fcolours;
- pv = myData.vertices;
- pvt = myData.vtexturecoord;
- if ( AWorkspace->DegenerateModel < 2 && interior_style != Aspect_IS_EMPTY )
- {
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
- {
- pvc = 0;
- pfc = 0;
- }
-
- if ( interior_style == Aspect_IS_HIDDENLINE)
- {
- pvc = 0;
- pfc = 0;
- }
-
- if ( front_lighting_model )
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
-
- lighting_model = front_lighting_model;
-
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- /* window's context and bitmap's one */
-
- if ( myDS->model != lighting_model || !myDS->list ||
- myDS->model == -1 || ( AWorkspace->DegenerateModel && myDS->skipRatio != AWorkspace->SkipRatio ))
- {
- myDS->skipRatio = AWorkspace->SkipRatio;
- myDS->model = lighting_model;
- myDS->degMode = AWorkspace->DegenerateModel;
- if ( AWorkspace->SkipRatio <= 0.f ) {
- if ( !myDS->list ) myDS->list = glGenLists ( 1 );
-
- glNewList ( myDS->list, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- if ( !lighting_model )
- {
- if ( myData.num_bounds == 3 )
- glBegin ( GL_TRIANGLES );
- else if ( myData.num_bounds == 4 )
- glBegin ( GL_QUADS );
- else glBegin ( GL_POLYGON );
-
- if ( pvc )
- {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i )
- {
- a = j + myData.num_bounds;
- for ( ; j < a; ++j )
- {
- glColor3fv ( pvc[ ind[ j ] ].rgb );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- }
- }
- }
- else if ( pfc )
- {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i )
- {
- a = j + myData.num_bounds;
- glColor3fv ( pfc[ i ].rgb );
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- }
- }
- else
- {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i )
- {
- a = j + myData.num_bounds;
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- }
- }
- glEnd ();
- }
- else
- {
- /* lighting_model != TelLModelNone */
- if ( myData.num_bounds == 3 )
- glBegin ( GL_TRIANGLES );
- else if ( myData.num_bounds == 4 )
- glBegin ( GL_QUADS );
- else glBegin ( GL_POLYGON );
-
-#ifdef OCC749
- for ( i = a = 0; i < myData.num_facets; ++i ) {
- j = a; a += myData.num_bounds;
- if( pfn ) glNormal3fv ( pfn[ i ].xyz );
- if( pfc && !prop->isphysic ) {
- GLfloat diff[4], ambi[4], emsv[4], r, g, b;
-
- ambi[3] = diff[3] = emsv[3] = prop->trans;
-
- r = pfc[ i ].rgb[0]; g = pfc[ i ].rgb[1]; b = pfc[ i ].rgb[2];
-
- if( prop->color_mask & OPENGL_AMBIENT_MASK ) {
- ambi[0] = prop->amb * r;
- ambi[1] = prop->amb * g;
- ambi[2] = prop->amb * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambi);
- }
- if( prop->color_mask & OPENGL_DIFFUSE_MASK ) {
- diff[0] = prop->diff * r;
- diff[1] = prop->diff * g;
- diff[2] = prop->diff * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
- }
- if( prop->color_mask & OPENGL_EMISSIVE_MASK ) {
- emsv[0] = prop->emsv * r;
- emsv[1] = prop->emsv * g;
- emsv[2] = prop->emsv * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emsv);
- }
- }
- for ( ; j < a; ++j ) {
- k = ind[ j ];
- if( pvn ) glNormal3fv ( pvn[ k ].xyz );
- if( pvc && !prop->isphysic ) {
- GLfloat diff[4], ambi[4], emsv[4], r, g, b;
-
- ambi[3] = diff[3] = emsv[3] = prop->trans;
-
- r = pvc[ k ].rgb[0]; g = pvc[ k ].rgb[1]; b = pvc[ k ].rgb[2];
-
- if( prop->color_mask & OPENGL_AMBIENT_MASK ) {
- ambi[0] = prop->amb * r;
- ambi[1] = prop->amb * g;
- ambi[2] = prop->amb * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambi);
- }
- if( prop->color_mask & OPENGL_DIFFUSE_MASK ) {
- diff[0] = prop->diff * r;
- diff[1] = prop->diff * g;
- diff[2] = prop->diff * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
- }
- if( prop->color_mask & OPENGL_EMISSIVE_MASK ) {
- emsv[0] = prop->emsv * r;
- emsv[1] = prop->emsv * g;
- emsv[2] = prop->emsv * b;
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emsv);
- }
- }
- if( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 ) glTexCoord2fv ( pvt[ k ].xy );
- glVertex3fv ( pv[ k ].xyz );
- } /* end for ( j . . . ) */
- } /* end for ( i . . . ) */
- glEnd ();
-#else
- if ( pvn ) {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- for ( ; j < a; ++j ) {
- glNormal3fv ( pvn[ ind[ j ] ].xyz );
- glTexCoord2fv ( pvt[ ind[ j ] ].xy );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for ( j . . . ) */
- } /* end for ( i . . . ) */
- else
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- for ( ; j < a; ++j ) {
- glNormal3fv ( pvn[ ind[ j ] ].xyz );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for ( j . . . ) */
- } /* end for ( i . . . ) */
- } else { /* !pvn */
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- glNormal3fv ( pfn[ i ].xyz );
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for */
- } /* end else */
- glEnd ();
-#endif /* OCC749 */
-
- } /* end else */
- } else if ( AWorkspace->SkipRatio < 1.f ) {
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
- set_drawable_items ( myDS->bDraw, myData.num_facets, AWorkspace->SkipRatio );
- if ( !lighting_model ) {
- if ( myData.num_bounds == 3 )
- glBegin ( GL_TRIANGLES );
- else if ( myData.num_bounds == 4 )
- glBegin ( GL_QUADS );
- else glBegin ( GL_POLYGON );
-
- if ( pvc ) {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] )
- for ( ; j < a; ++j ) {
- glColor3fv ( pvc[ ind[ j ] ].rgb );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for ( j . . . ) */
- else j = a;
- } /* end for ( i . . . ) */
- } else if ( pfc ) {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] ) {
- glColor3fv ( pfc[ i ].rgb );
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- } else j = a;
- } /* end for */
- } else {
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] )
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- else j = a;
- } /* end for */
- } /* end else */
- glEnd ();
- } else { /* lighting_model != TelLModelNone */
- if ( myData.num_bounds == 3 )
- glBegin ( GL_TRIANGLES );
- else if ( myData.num_bounds == 4 )
- glBegin ( GL_QUADS );
- else glBegin ( GL_POLYGON );
-
- if ( pvn ) {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] )
- for ( ; j < a; ++j ) {
- glNormal3fv ( pvn[ ind[ j ] ].xyz );
- glTexCoord2fv ( pvt[ ind[ j ] ].xy );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for ( j . . . ) */
- else j = a;
- } /* end for ( i . . . ) */
- else
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] )
- for ( ; j < a; ++j ) {
- glNormal3fv ( pvn[ ind[ j ] ].xyz );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
- } /* end for ( j . . . ) */
- else j = a;
- } /* end for ( i . . . ) */
- } else { /* !pvn */
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
- a = j + myData.num_bounds;
- if ( myDS->bDraw[ i ] ) {
- glNormal3fv ( pfn[ i ].xyz );
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
- } else j = a;
- } /* end for */
- } /* end else */
- glEnd ();
- } /* end else */
- } else {
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
- } /* end else */
- if ( newList ) glEndList ();
- if ( AWorkspace->DegenerateModel ) return;
- } else {
- glCallList ( AWorkspace->SkipRatio <= 0.f ? myDS->list : myDS->dlist );
- if ( AWorkspace->DegenerateModel ) return;
- } /* end else */
- }
-
- i = 0;
-
- switch ( AWorkspace->DegenerateModel )
- {
- default:
- break;
-
- case 2: /* XXX_TDM_WIREFRAME */
- i = 1;
- break;
-
- case 3: /* XXX_TDM_MARKER */
- draw_degenerates_as_points ( AWorkspace->SkipRatio );
- return;
-
- case 4: /* XXX_TDM_BBOX */
- draw_degenerates_as_bboxs ();
- return;
- }
-
- draw_edges ( edge_colour, interior_style, i, AWorkspace );
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Mesh::draw_edges (const TEL_COLOUR *edge_colour, const Aspect_InteriorStyle interior_style,
- Tint forceDraw, const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- if ( interior_style != Aspect_IS_HIDDENLINE && !forceDraw && aspect_face->Context().Edge == TOff )
- return;
-
- glDisable(GL_LIGHTING);
- const GLboolean texture_on = IsTextureEnabled();
- if (texture_on) DisableTexture();
-
- // Setup line aspect
- const OpenGl_AspectLine *aspect_line_old = AWorkspace->SetAspectLine( aspect_face->AspectEdge() );
- AWorkspace->AspectLine( Standard_True );
-
- tel_point pv = myData.vertices;
- Tint *ind = myData.indices;
- Tint *vis = myData.edge_vis;
-
- Tint i, j, a, newList = 0;
-
- if ( !forceDraw ) {
-
- glColor3fv ( edge_colour -> rgb );
- glPushAttrib ( GL_POLYGON_BIT );
- glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE );
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- a = j + myData.num_bounds;
-
- glBegin ( GL_POLYGON );
-
- for ( ; j < a; ++j ) {
-
- glEdgeFlag ( ( GLboolean )( vis[ j ] == 1 ? GL_TRUE : GL_FALSE ) );
- glVertex3fv ( pv[ ind[ j ] ].xyz );
-
- } /* end for */
-
- glEnd();
-
- glEdgeFlag ( GL_TRUE );
-
- } /* end for */
-
- glPopAttrib ();
-
- } else {
-
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
-
- if ( myDS->degMode != 2 || myDS->skipRatio != AWorkspace->SkipRatio || !myDS->dlist ) {
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- myDS->degMode = 2;
- myDS->skipRatio = AWorkspace->SkipRatio;
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
-doDraw:
- glPushAttrib ( GL_POLYGON_BIT | GL_DEPTH_BUFFER_BIT );
-
- glEdgeFlag ( GL_TRUE );
- glDisable ( GL_DEPTH_TEST );
- glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE );
-
- if ( AWorkspace->SkipRatio <= 0.f )
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- a = j + myData.num_bounds;
-
- glBegin ( GL_POLYGON );
-
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
-
- glEnd();
-
- } /* end for */
-
- else if ( AWorkspace->SkipRatio < 1.f ) {
-
- set_drawable_items ( myDS->bDraw, myData.num_facets, AWorkspace->SkipRatio );
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- a = j + myData.num_bounds;
-
- if ( myDS->bDraw[ i ] ) {
-
- glBegin ( GL_POLYGON );
-
- for ( ; j < a; ++j ) glVertex3fv ( pv[ ind[ j ] ].xyz );
-
- glEnd();
-
- } else j = a;
-
- } /* end for */
-
- } /* end if */
-
- glPopAttrib ();
- if ( newList ) glEndList ();
-
- } else glCallList ( myDS->dlist );
-
- } /* end else */
-
- // Restore line context
- AWorkspace->SetAspectLine( aspect_line_old );
-
- if (texture_on) EnableTexture();
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Mesh::draw_degenerates_as_points (const float aSkipRatio) const
-{
- Tint* ind, *vis;
- Tint i, j, n, a, newList = 0;
- GLfloat pt[ 3 ];
- tel_point pv;
-
- pv = myData.vertices;
- ind = myData.indices;
- vis = myData.edge_vis;
-
- glDisable(GL_LIGHTING);
-
- if ( myDS->degMode != 3 || myDS->skipRatio != aSkipRatio || !myDS->dlist ) {
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- myDS->degMode = 3;
- myDS->skipRatio = aSkipRatio;
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- if ( aSkipRatio <= 0.f ) {
-
- glBegin ( GL_POINTS );
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- n = myData.num_bounds;
- a = j + n;
-
- for ( pt [ 0 ] = pt[ 1 ] = pt[ 2 ] = 0.; j < a; ++j ) {
-
- pt[ 0 ] += pv[ ind[ j ] ].xyz[ 0 ];
- pt[ 1 ] += pv[ ind[ j ] ].xyz[ 1 ];
- pt[ 2 ] += pv[ ind[ j ] ].xyz[ 2 ];
-
- } /* end for ( j ) */
-
- pt[ 0 ] /= n;
- pt[ 1 ] /= n;
- pt[ 2 ] /= n;
-
- glVertex3fv ( pt );
-
- } /* end for ( i ) */
-
- glEnd ();
-
- } else if ( aSkipRatio < 1.f ) {
-
- set_drawable_items ( myDS->bDraw, myData.num_facets, aSkipRatio );
-
- glBegin ( GL_POINTS );
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- n = myData.num_bounds;
- a = j + n;
-
- if ( myDS->bDraw[ i ] ) {
-
- for ( pt [ 0 ] = pt[ 1 ] = pt[ 2 ] = 0.; j < a; ++j ) {
-
- pt[ 0 ] += pv[ ind[ j ] ].xyz[ 0 ];
- pt[ 1 ] += pv[ ind[ j ] ].xyz[ 1 ];
- pt[ 2 ] += pv[ ind[ j ] ].xyz[ 2 ];
-
- } /* end for ( j ) */
-
- pt[ 0 ] /= n;
- pt[ 1 ] /= n;
- pt[ 2 ] /= n;
-
- glVertex3fv ( pt );
-
- } else j = a;
-
- } /* end for ( i ) */
-
- glEnd ();
-
- } /* end if */
-
- glEndList ();
-
- } else glCallList ( myDS->dlist );
-
-}
-
-void OpenGl_Mesh::draw_degenerates_as_bboxs () const
-{
- Tint* ind, *vis;
- Tint i, j, n, a, newList = 0;
- GLfloat minp[ 3 ] = { FLT_MAX, FLT_MAX, FLT_MAX };
- GLfloat maxp[ 3 ] = { FLT_MIN, FLT_MIN, FLT_MIN };
- tel_point pv;
-
- pv = myData.vertices;
- ind = myData.indices;
- vis = myData.edge_vis;
-
- glDisable(GL_LIGHTING);
-
- if ( myDS->degMode != 4 || !myDS->dlist ) {
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- myDS->degMode = 4;
-
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- for ( i = 0, j = 0, a = 0; i < myData.num_facets; ++i ) {
-
- n = myData.num_bounds;
- a = j + n;
-
- for ( ; j < a; ++j ) {
-
- if ( pv[ ind[ j ] ].xyz[ 0 ] < minp[ 0 ] )
- minp[ 0 ] = pv[ ind[ j ] ].xyz[ 0 ] ;
- if ( pv[ ind[ j ] ].xyz[ 1 ] < minp[ 1 ] )
- minp[ 1 ] = pv[ ind[ j ] ].xyz[ 1 ] ;
- if ( pv[ ind[ j ] ].xyz[ 2 ] < minp[ 2 ] )
- minp[ 2 ] = pv[ ind[ j ] ].xyz[ 2 ] ;
-
- if ( pv[ ind[ j ] ].xyz[ 0 ] > maxp[ 0 ] )
- maxp[ 0 ] = pv[ ind[ j ] ].xyz[ 0 ] ;
- if ( pv[ ind[ j ] ].xyz[ 1 ] > maxp[ 1 ] )
- maxp[ 1 ] = pv[ ind[ j ] ].xyz[ 1 ] ;
- if ( pv[ ind[ j ] ].xyz[ 2 ] > maxp[ 2 ] )
- maxp[ 2 ] = pv[ ind[ j ] ].xyz[ 2 ] ;
-
- } /* end for ( j ) */
-
- } /* end for ( i ) */
-
- /* OCC11904 -- Temporarily disable environment mapping */
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_TEXTURE_1D);
- glDisable(GL_TEXTURE_2D);
-
- glBegin ( GL_LINE_STRIP );
-
- glVertex3fv ( minp );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], minp[ 2 ] );
-
- glVertex3f ( maxp[ 0 ], minp[ 1 ], minp[ 2 ] );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3f ( maxp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( maxp[ 0 ], minp[ 1 ], minp[ 2 ] );
-
- glVertex3f ( maxp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3fv ( maxp );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], minp[ 2 ] );
-
- glEnd();
- glPopAttrib();
- glEndList ();
-
- } else glCallList ( myDS->dlist );
-}
-
-/*----------------------------------------------------------------------*/
-
-void set_drawable_items ( GLboolean* pbDraw, int n, const float aSkipRatio )
-{
- memset ( pbDraw, 0, sizeof ( GLboolean ) * n );
-
- int i = ( int )( ( 1.0F - aSkipRatio ) * n );
-
- while ( i-- ) pbDraw[ OPENGL_RAND() % n ] = 1;
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::OpenGl_Mesh (const Graphic3d_Array1OfVertex& AListVertex, const Aspect_Array1OfEdge& AListEdge)
-{
- const Standard_Integer nv = AListVertex.Length();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- memcpy( points, &AListVertex(AListVertex.Lower()), nv*sizeof(TEL_POINT) );
-
- Init (nv,points,NULL,NULL,NULL,AListEdge,3);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::OpenGl_Mesh (const Graphic3d_Array1OfVertexN& AListVertex, const Aspect_Array1OfEdge& AListEdge)
-{
- const Standard_Integer nv = AListVertex.Length ();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_POINT *normals = new TEL_POINT[nv];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord(X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Normal(X, Y, Z);
- normals[i].xyz[0] = float (X);
- normals[i].xyz[1] = float (Y);
- normals[i].xyz[2] = float (Z);
- }
-
- Init (nv,points,normals,NULL,NULL,AListEdge,3);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::OpenGl_Mesh (const Graphic3d_Array1OfVertexC& AListVertex, const Aspect_Array1OfEdge& AListEdge)
-{
- const Standard_Integer nv = AListVertex.Length ();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_COLOUR *colors = new TEL_COLOUR[nv];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord(X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Color().Values (X, Y, Z, Quantity_TOC_RGB);
- colors[i].rgb[0] = float (X);
- colors[i].rgb[1] = float (Y);
- colors[i].rgb[2] = float (Z);
- colors[i].rgb[3] = 1.0F;
- }
-
- Init (nv,points,NULL,colors,NULL,AListEdge,3);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::OpenGl_Mesh (const Graphic3d_Array1OfVertexNC& AListVertex, const Aspect_Array1OfEdge& AListEdge)
-{
- const Standard_Integer nv = AListVertex.Length ();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_POINT *normals = new TEL_POINT[nv];
- TEL_COLOUR *colors = new TEL_COLOUR[nv];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord(X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Normal(X, Y, Z);
- normals[i].xyz[0] = float (X);
- normals[i].xyz[1] = float (Y);
- normals[i].xyz[2] = float (Z);
- AListVertex(j).Color().Values (X, Y, Z, Quantity_TOC_RGB);
- colors[i].rgb[0] = float (X);
- colors[i].rgb[1] = float (Y);
- colors[i].rgb[2] = float (Z);
- colors[i].rgb[3] = 1.0F;
- }
-
- Init (nv,points,normals,colors,NULL,AListEdge,3);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::OpenGl_Mesh (const Graphic3d_Array1OfVertexNT& AListVertex, const Aspect_Array1OfEdge& AListEdge)
-{
- const Standard_Integer nv = AListVertex.Length ();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_POINT *normals = new TEL_POINT[nv];
- TEL_TEXTURE_COORD *tcoords = new TEL_TEXTURE_COORD[nv];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord(X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Normal(X, Y, Z);
- normals[i].xyz[0] = float (X);
- normals[i].xyz[1] = float (Y);
- normals[i].xyz[2] = float (Z);
- AListVertex(j).TextureCoordinate(X, Y);
- tcoords[i].xy[0] = float(X);
- tcoords[i].xy[1] = float(Y);
- }
-
- Init (nv,points,normals,NULL,tcoords,AListEdge,3);
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Mesh::Init (const Tint ANbVertices, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- const Aspect_Array1OfEdge& AListEdge, const Tint ANbBounds)
-{
- // Get number of bounds in a facet
- myData.num_bounds = ANbBounds;
-
- // Get number of vertices
- myData.num_vertices = ANbVertices;
-
- // Get vertices
- myData.vertices = AVertices;
-
- // Get number of edges
- const Standard_Integer nb_edges = AListEdge.Length ();
-
- myData.indices = new Tint[nb_edges];
- myData.edge_vis = new Tint[nb_edges];
-
- const Standard_Integer LowerE = AListEdge.Lower ();
- const Standard_Integer UpperE = AListEdge.Upper ();
-
- // Loop on edges
- Standard_Integer i, j;
- for (j=0, i=LowerE; i<=UpperE; i++, j++)
- {
- myData.indices[j] = AListEdge(i).FirstIndex() - LowerE; //LastIndex unused
- myData.edge_vis[j] = AListEdge(i).Type() ? TOff : TOn;
- }
-
- // Get number of facets
- myData.num_facets = nb_edges / ANbBounds;
-
- myData.vnormals = AVNormals;
- if (AVNormals)
- {
- myData.vertex_flag = TEL_VT_NORMAL;
- for( i = 0; i < ANbVertices; i++ )
- vecnrm( myData.vnormals[i].xyz );
- }
- else
- {
- myData.vertex_flag = TEL_VT_NONE;
- }
-
- myData.vcolours = AVColors;
- myData.vtexturecoord = ATCoords;
-
- myData.facet_flag = TEL_FA_NONE;
- myData.fnormals = new TEL_POINT[myData.num_facets];
- for( i = 0, j = 0; i < myData.num_facets; i++ )
- {
- TelGetPolygonNormal( myData.vertices, &myData.indices[j], myData.num_bounds, myData.fnormals[i].xyz );
- j += myData.num_bounds;
- }
-
- myData.fcolours = NULL;
-
- myDS = new DS_INTERNAL();
- myDS->list = 0;
- myDS->dlist = 0;
- myDS->degMode = 0;
- myDS->model = -1;
- myDS->skipRatio = 0.0F;
- myDS->bDraw = new unsigned char[myData.num_facets];
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Mesh::~OpenGl_Mesh ()
-{
- if( myData.edge_vis )
- delete[] myData.edge_vis;
- if( myData.indices )
- delete[] myData.indices;
- if( myData.fcolours )
- delete[] myData.fcolours;
- if( myData.fnormals )
- delete[] myData.fnormals;
- if( myData.vertices )
- delete[] myData.vertices;
- if( myData.vcolours )
- delete[] myData.vcolours;
- if( myData.vnormals )
- delete[] myData.vnormals;
- if( myData.vtexturecoord )
- delete[] myData.vtexturecoord;
-
- if ( myDS )
- {
- if ( GET_GL_CONTEXT() != NULL )
- {
- if ( myDS->list ) glDeleteLists ( myDS->list, 1 );
- if ( myDS->dlist ) glDeleteLists ( myDS->dlist, 1 );
- }
-
- if ( myDS->bDraw )
- delete[] myDS->bDraw;
-
- delete myDS;
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Mesh::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- Tint front_lighting_model = aspect_face->Context().IntFront.color_mask;
- const TEL_COLOUR *interior_colour = &aspect_face->Context().IntFront.matcol;
- const TEL_COLOUR *edge_colour = &aspect_face->AspectEdge()->Color();
-
- // Use highlight colors
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
- {
- edge_colour = interior_colour = AWorkspace->HighlightColor;
- front_lighting_model = 0;
- }
-
- glColor3fv( interior_colour->rgb );
-
- draw_indexpoly( front_lighting_model,
- aspect_face->Context().InteriorStyle,
- edge_colour,
- &aspect_face->Context().IntFront,
- AWorkspace );
-}
-
-/*----------------------------------------------------------------------*/
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#ifndef OpenGl_Mesh_Header
-#define OpenGl_Mesh_Header
-
-#include <InterfaceGraphic_telem.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_Array1OfVertexN.hxx>
-#include <Graphic3d_Array1OfVertexC.hxx>
-#include <Graphic3d_Array1OfVertexNC.hxx>
-#include <Graphic3d_Array1OfVertexNT.hxx>
-#include <Aspect_Array1OfEdge.hxx>
-#include <Aspect_InteriorStyle.hxx>
-
-#include <OpenGl_Element.hxx>
-#include <OpenGl_AspectFace.hxx>
-
-struct TEL_INDEXPOLY_DATA
-{
- Tint num_vertices; /* Number of vertices */
- Tint num_facets; /* Number of facets (triangles, quadrangles or polygons) */
- Tint num_bounds; /* Number of bounds in a facet (3, 4 or more) */
- Tint facet_flag; /* TEL_FA_NONE or TEL_FA_NORMAL */
- Tint vertex_flag; /* TEL_VT_NONE or TEL_VT_NORMAL */
- Tint *edge_vis; /* Edge visibility indicators for each edge */
- Tint *indices; /* Connectivity array */
- tel_point fnormals; /* Facet normals */
- tel_colour fcolours; /* Facet colour values */
- tel_point vertices; /* Vertices */
- tel_colour vcolours; /* Vertex colour values */
- tel_point vnormals; /* Vertex normals */
- tel_texture_coord vtexturecoord; /* Texture Coordinates */
- DEFINE_STANDARD_ALLOC
-};
-
-class OpenGl_Mesh : public OpenGl_Element
-{
- public:
-
- OpenGl_Mesh (const Graphic3d_Array1OfVertex& AListVertex, const Aspect_Array1OfEdge& AListEdge);
- OpenGl_Mesh (const Graphic3d_Array1OfVertexN& AListVertex, const Aspect_Array1OfEdge& AListEdge);
- OpenGl_Mesh (const Graphic3d_Array1OfVertexC& AListVertex, const Aspect_Array1OfEdge& AListEdge);
- OpenGl_Mesh (const Graphic3d_Array1OfVertexNC& AListVertex, const Aspect_Array1OfEdge& AListEdge);
- OpenGl_Mesh (const Graphic3d_Array1OfVertexNT& AListVertex, const Aspect_Array1OfEdge& AListEdge);
-
- virtual ~OpenGl_Mesh ();
-
- virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
-
- protected:
-
- void Init (const Tint ANbVertices, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- const Aspect_Array1OfEdge& AListEdge, const Tint ANbBounds);
-
- void draw_indexpoly (const Tint, /* front_lighting_model, */
- const Aspect_InteriorStyle, /* interior_style, */
- const TEL_COLOUR *, /* edge_colour, */
- const OPENGL_SURF_PROP *,
- const Handle(OpenGl_Workspace) &) const;
-
- void draw_degenerates_as_points (const float) const;
-
- void draw_degenerates_as_bboxs () const;
-
- void draw_edges (const TEL_COLOUR *, const Aspect_InteriorStyle, Tint, const Handle(OpenGl_Workspace) &) const;
-
- TEL_INDEXPOLY_DATA myData;
- DS_INTERNAL *myDS;
-
- public:
- DEFINE_STANDARD_ALLOC
-};
-
-#endif //OpenGl_Mesh_Header
OpenGl_Polyline::OpenGl_Polyline (const Graphic3d_Array1OfVertex& AListVertex)
: myNbVertices(AListVertex.Length()),
- myVertices(NULL),
- myColors(NULL)
+ myVertices(NULL)
{
myVertices = new TEL_POINT[myNbVertices];
memcpy( myVertices, &AListVertex(AListVertex.Lower()), myNbVertices*sizeof(TEL_POINT) );
/*----------------------------------------------------------------------*/
-OpenGl_Polyline::OpenGl_Polyline (const Graphic3d_Array1OfVertexC& AListVertex)
-: myNbVertices(AListVertex.Length()),
- myVertices(NULL),
- myColors(NULL)
+OpenGl_Polyline::~OpenGl_Polyline()
{
- myVertices = new TEL_POINT[myNbVertices];
- myColors = new TEL_COLOUR[myNbVertices];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < myNbVertices; i++, j++)
- {
- AListVertex(j).Coord(X, Y, Z);
- myVertices[i].xyz[0] = float (X);
- myVertices[i].xyz[1] = float (Y);
- myVertices[i].xyz[2] = float (Z);
- AListVertex(j).Color().Values(X, Y, Z, Quantity_TOC_RGB);
- myColors[i].rgb[0] = float (X);
- myColors[i].rgb[1] = float (Y);
- myColors[i].rgb[2] = float (Z);
- myColors[i].rgb[3] = 1.0F;
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Polyline::OpenGl_Polyline (const Standard_Real X1,const Standard_Real Y1,const Standard_Real Z1,
- const Standard_Real X2,const Standard_Real Y2,const Standard_Real Z2)
-: myNbVertices(2),
- myVertices(new TEL_POINT[2]),
- myColors(NULL)
-{
- myVertices[0].xyz[0] = float (X1);
- myVertices[0].xyz[1] = float (Y1);
- myVertices[0].xyz[2] = float (Z1);
- myVertices[1].xyz[0] = float (X2);
- myVertices[1].xyz[1] = float (Y2);
- myVertices[1].xyz[2] = float (Z2);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Polyline::~OpenGl_Polyline ()
-{
- if ( myVertices )
- delete[] myVertices;
- if( myColors )
- delete[] myColors;
+ delete[] myVertices;
}
/*----------------------------------------------------------------------*/
glDisable (GL_TEXTURE_2D);
glBegin (theWorkspace->DegenerateModel != 3 ? GL_LINE_STRIP : GL_POINTS);
- if (!myColors || (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT))
- {
- // Use highlight colors
- glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
-
- for (Tint i = 0; i < myNbVertices; ++i)
- glVertex3fv (myVertices[i].xyz);
- }
- else
- {
- for (Tint i = 0; i < myNbVertices; ++i)
- {
- glColor3fv (myColors[i].rgb);
- glVertex3fv (myVertices[i].xyz);
- }
- }
+
+ // Use highlight colors
+ glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
+
+ for (Tint i = 0; i < myNbVertices; ++i)
+ glVertex3fv (myVertices[i].xyz);
+
glEnd();
glPopAttrib();
}
-
-/*----------------------------------------------------------------------*/
public:
OpenGl_Polyline (const Graphic3d_Array1OfVertex& AListVertex);
- OpenGl_Polyline (const Graphic3d_Array1OfVertexC& AListVertex);
- OpenGl_Polyline (const Standard_Real X1,const Standard_Real Y1,const Standard_Real Z1,
- const Standard_Real X2,const Standard_Real Y2,const Standard_Real Z2);
virtual ~OpenGl_Polyline ();
virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
Tint myNbVertices; // Number of vertices in vertices array
tel_point myVertices; // Vertices array of length myNbVertices
- tel_colour myColors; // Vertex color values for each vertex
public:
DEFINE_STANDARD_ALLOC
// either disable VBO or turn off edge visibilty in the current
// primitive array and create a separate primitive array (segments)
// and put edges to be drawn into it.
- DrawEdges (theEdgeFlag ? theEdgeColour : theInteriorColour, theWorkspace);
+ if (myDrawMode > GL_LINE_STRIP)
+ {
+ DrawEdges (theEdgeFlag ? theEdgeColour : theInteriorColour, theWorkspace);
+ }
break;
// DegenerateModel(as Lines, Points, BBoxs) are used only without VBO
case 2: // XXX_TDM_WIREFRAME
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GlCore11.hxx>
-
-#include <OpenGl_QuadrangleStrip.hxx>
-
-#include <OpenGl_telem_util.hxx>
-#include <OpenGl_TextureBox.hxx>
-
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_Structure.hxx>
-
-/*----------------------------------------------------------------------*/
-
-#define OPENGL_RAND() ( ( unsigned )( s_Rand = s_Rand * 214013L + 2531011L ) )
-
-/*----------------------------------------------------------------------*/
-
-extern void draw_degenerates_as_points ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
-extern void draw_degenerates_as_bboxs ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
-extern void set_drawable_items ( GLboolean*, int, const float );
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_QuadrangleStrip::draw_qstrip (const Tint front_lighting_model,
- const Aspect_InteriorStyle interior_style,
- const TEL_COLOUR *edge_colour,
- const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- Tint i, m, newList = 0;
- Tint nf, nv, nr, nc;
- Tint lighting_model;
-
- tel_colour pfc = myData.fcolours;
- tel_point pv = myData.vertices;
- tel_colour pvc = myData.vcolours;
- tel_point pvn = myData.vnormals;
- tel_texture_coord pvt = myData.vtexturecoord;
-
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
- {
- pvc = 0;
- pfc = 0;
- }
-
- if ( AWorkspace->DegenerateModel < 2 && interior_style != Aspect_IS_EMPTY )
- {
- if ( front_lighting_model )
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
-
- lighting_model = front_lighting_model;
- nr = myData.num_rows;
- nc = myData.num_columns;
- nf = nr * nc;
- nv = ( nr + 1 ) * ( nc + 1 );
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- /* window's context and bitmap's one */
- if ( myDS->model != front_lighting_model || !myDS->list || myDS->model == -1 ||
- ( AWorkspace->DegenerateModel && myDS->skipRatio != AWorkspace->SkipRatio ) )
- {
- myDS->skipRatio = AWorkspace->SkipRatio;
- myDS->model = front_lighting_model;
- myDS->degMode = AWorkspace->DegenerateModel;
-
- if ( AWorkspace->SkipRatio == 0.f ) {
-
- if ( !myDS->list ) myDS->list = glGenLists ( 1 );
-
- glNewList ( myDS->list, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- if ( lighting_model )
- {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- {
- for ( m = 0; m < nr; ++m )
- {
- glBegin ( GL_QUAD_STRIP );
- glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- else
- {
- for ( m = 0; m < nr; ++m )
- {
- glBegin ( GL_QUAD_STRIP );
- glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- else
- {
- if ( pvc )
- {
- for ( m = 0; m < nr; ++m )
- {
- glBegin ( GL_QUAD_STRIP );
- glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- else if ( pfc )
- {
- glColor3fv ( pfc[ 0 ].rgb );
- for ( m = 0; m < nr; ++m )
- {
- glBegin ( GL_QUAD_STRIP );
- glColor3fv ( pfc[ m * nc ].rgb );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- else
- {
- for ( m = 0; m < nr; ++m )
- {
- glBegin ( GL_QUAD_STRIP );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
- glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- }
- else if ( AWorkspace->SkipRatio < 1.f )
- {
- set_drawable_items ( myDS->bDraw, nr, AWorkspace->SkipRatio );
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- if ( lighting_model )
- {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- {
- for ( m = 0; m < nr; ++m )
- {
- if ( myDS->bDraw[ m ] )
- {
- glBegin ( GL_QUADS );
- glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
- glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- else
- {
- for ( m = 0; m < nr; ++m )
- {
- if ( myDS->bDraw[ m ] )
- {
- glBegin ( GL_QUADS );
- glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- }
- else
- {
- if ( pvc )
- {
- for ( m = 0; m < nr; ++m )
- {
- if ( myDS->bDraw[ m ] )
- {
- glBegin ( GL_QUAD_STRIP );
- glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- else if ( pfc )
- {
- glColor3fv ( pfc[ 0 ].rgb );
- for ( m = 0; m < nr; ++m )
- {
- if ( myDS->bDraw[ m ] )
- {
- glBegin ( GL_QUADS );
- glColor3fv ( pfc[ m * nc ].rgb );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
- glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- else
- {
- for ( m = 0; m < nr; ++m )
- {
- if ( myDS->bDraw[ m ] )
- {
- glBegin ( GL_QUADS );
- glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
- glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
- for ( i = 1; i < nc + 1; ++i )
- {
- glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
- glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
- }
- glEnd ();
- }
- }
- }
- }
- }
- else
- {
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- } /* end else */
- if ( newList ) glEndList ();
-
- if ( AWorkspace->DegenerateModel ) return;
-
- } else {
-
- glCallList ( AWorkspace->SkipRatio <= 0.f ? myDS->list : myDS->dlist );
-
- if ( AWorkspace->DegenerateModel ) return;
-
- } /* end else */
- }
-
- i = 0;
-
- /* OCC11904 -- Temporarily disable environment mapping */
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_TEXTURE_1D);
- glDisable(GL_TEXTURE_2D);
-
- switch ( AWorkspace->DegenerateModel )
- {
- default:
- break;
-
- case 2: /* XXX_TDM_WIREFRAME */
- i = 1;
- break;
-
- case 3: /* XXX_TDM_MARKER */
- draw_degenerates_as_points ( myDS, myData.vertices, ( myData.num_rows + 1 ) * ( myData.num_columns + 1 ), AWorkspace );
- glPopAttrib();
- return;
-
- case 4: /* XXX_TDM_BBOX */
- draw_degenerates_as_bboxs ( myDS, myData.vertices, ( myData.num_rows + 1 ) * ( myData.num_columns + 1 ), AWorkspace );
- glPopAttrib();
- return;
- } /* end switch */
-
- draw_edges ( edge_colour, interior_style, i, AWorkspace );
-
- glPopAttrib();
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_QuadrangleStrip::draw_edges (const TEL_COLOUR *edge_colour, const Aspect_InteriorStyle interior_style,
- Tint forceDraw, const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- if ( interior_style != Aspect_IS_HIDDENLINE && !forceDraw && aspect_face->Context().Edge == TOff )
- return;
-
- glDisable(GL_LIGHTING);
- const GLboolean texture_on = IsTextureEnabled();
- if ( texture_on ) DisableTexture();
-
- // Setup line aspect
- const OpenGl_AspectLine *aspect_line_old = AWorkspace->SetAspectLine( aspect_face->AspectEdge() );
- AWorkspace->AspectLine( Standard_True );
-
- Tint nc = myData.num_columns;
- Tint nf = myData.num_rows * myData.num_columns;
-
- Tint newList = 0;
-
- if ( !forceDraw )
- draw_line_strip ( edge_colour, nf, nc );
- else
- {
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- if ( myDS->degMode != 2 || myDS->skipRatio != AWorkspace->SkipRatio || !myDS->dlist ) {
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- myDS->degMode = 2;
- myDS->skipRatio = AWorkspace->SkipRatio;
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- glPushAttrib ( GL_DEPTH_BUFFER_BIT );
- glDisable ( GL_DEPTH_TEST );
-
- if ( AWorkspace->SkipRatio <= 0.f )
-
- draw_line_strip ( edge_colour, nf, nc );
-
- else if ( AWorkspace->SkipRatio < 1.f ) {
-
- int i, m1, m2, n1, n2, n3, n4;
-
- set_drawable_items ( myDS->bDraw, nf, AWorkspace->SkipRatio );
-
- glColor3fv ( edge_colour -> rgb );
-
- for ( i = 0; i < nf; ++i )
-
- if ( myDS->bDraw[ i ] ) {
-
- glBegin ( GL_LINE_STRIP );
- m1 = i / nc;
- m2 = i % nc;
- n1 = m1 * ( nc + 1 ) + m2;
- n2 = n1 + nc + 1;
- n3 = n2 + 1;
- n4 = n1 + 1;
-
- glVertex3fv ( myData.vertices[ n1 ].xyz );
- glVertex3fv ( myData.vertices[ n2 ].xyz );
- glVertex3fv ( myData.vertices[ n3 ].xyz );
- glVertex3fv ( myData.vertices[ n4 ].xyz );
- glVertex3fv ( myData.vertices[ n1 ].xyz );
- glEnd();
-
- } /* end if */
-
- } /* end if */
-
- glPopAttrib ();
- if ( newList ) glEndList ();
-
- } else glCallList ( myDS->dlist );
-
- } /* end else */
-
- // Restore line context
- AWorkspace->SetAspectLine( aspect_line_old );
-
- if ( texture_on ) EnableTexture ();
-}
-
-void OpenGl_QuadrangleStrip::draw_line_strip (const TEL_COLOUR *c, Tint nf, Tint nc) const
-{
- int i, m1, m2, n1, n2, n3, n4;
-
- glColor3fv ( c->rgb );
-
- for ( i = 0; i < nf; ++i )
- {
- glBegin ( GL_LINE_STRIP );
- m1 = i / nc;
- m2 = i % nc;
- n1 = m1 * ( nc + 1 ) + m2;
- n2 = n1 + nc + 1;
- n3 = n2 + 1;
- n4 = n1 + 1;
-
- glVertex3fv ( myData.vertices[ n1 ].xyz );
- glVertex3fv ( myData.vertices[ n2 ].xyz );
- glVertex3fv ( myData.vertices[ n3 ].xyz );
- glVertex3fv ( myData.vertices[ n4 ].xyz );
- glVertex3fv ( myData.vertices[ n1 ].xyz );
- glEnd();
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertex& AListVertex)
-{
- const Standard_Integer nbr = AListVertex.RowLength ();
- const Standard_Integer nbc = AListVertex.ColLength ();
- const Standard_Integer nbf = nbr*nbc;
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nbf];
-
- const Standard_Integer LowerRow = AListVertex.LowerRow ();
- const Standard_Integer UpperRow = AListVertex.UpperRow ();
- const Standard_Integer LowerCol = AListVertex.LowerCol ();
- const Standard_Integer UpperCol = AListVertex.UpperCol ();
-
- Standard_Integer i, j, k = 0;
- Standard_Real X, Y, Z;
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++)
- {
- AListVertex (i, j).Coord (X, Y, Z);
- points[k].xyz[0] = float (X);
- points[k].xyz[1] = float (Y);
- points[k].xyz[2] = float (Z);
- k++;
- }
-
- Init(nbr,nbc,points,NULL,NULL,NULL,NULL,NULL,TEL_SHAPE_UNKNOWN);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexN& AListVertex)
-{
- const Standard_Integer nbr = AListVertex.RowLength ();
- const Standard_Integer nbc = AListVertex.ColLength ();
- const Standard_Integer nbf = nbr*nbc;
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nbf];
- TEL_POINT *normals = new TEL_POINT[nbf];
-
- const Standard_Integer LowerRow = AListVertex.LowerRow ();
- const Standard_Integer UpperRow = AListVertex.UpperRow ();
- const Standard_Integer LowerCol = AListVertex.LowerCol ();
- const Standard_Integer UpperCol = AListVertex.UpperCol ();
-
- Standard_Integer i, j, k = 0;
- Standard_Real X, Y, Z;
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++)
- {
- AListVertex (i, j).Coord (X, Y, Z);
- points[k].xyz[0] = float (X);
- points[k].xyz[1] = float (Y);
- points[k].xyz[2] = float (Z);
- AListVertex (i, j).Normal (X, Y, Z);
- normals[k].xyz[0] = float (X);
- normals[k].xyz[1] = float (Y);
- normals[k].xyz[2] = float (Z);
- k++;
- }
-
- Init(nbr,nbc,points,normals,NULL,NULL,NULL,NULL,TEL_SHAPE_UNKNOWN);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexNT& AListVertex)
-{
- const Standard_Integer nbr = AListVertex.RowLength ();
- const Standard_Integer nbc = AListVertex.ColLength ();
- const Standard_Integer nbf = nbr*nbc;
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nbf];
- TEL_POINT *normals = new TEL_POINT[nbf];
- TEL_TEXTURE_COORD *tcoords = new TEL_TEXTURE_COORD[nbf];
-
- const Standard_Integer LowerRow = AListVertex.LowerRow ();
- const Standard_Integer UpperRow = AListVertex.UpperRow ();
- const Standard_Integer LowerCol = AListVertex.LowerCol ();
- const Standard_Integer UpperCol = AListVertex.UpperCol ();
-
- Standard_Integer i, j, k = 0;
- Standard_Real X, Y, Z;
- for (i=LowerRow; i<=UpperRow; i++)
- for (j=LowerCol; j<=UpperCol; j++)
- {
- AListVertex (i, j).Coord (X, Y, Z);
- points[k].xyz[0] = float (X);
- points[k].xyz[1] = float (Y);
- points[k].xyz[2] = float (Z);
- AListVertex (i, j).Normal (X, Y, Z);
- normals[k].xyz[0] = float (X);
- normals[k].xyz[1] = float (Y);
- normals[k].xyz[2] = float (Z);
- AListVertex (i, j).TextureCoordinate(X, Y);
- tcoords[k].xy[0] = float(X);
- tcoords[k].xy[1] = float(Y);
- k++;
- }
-
- Init(nbr,nbc,points,normals,NULL,tcoords,NULL,NULL,TEL_SHAPE_UNKNOWN);
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_QuadrangleStrip::Init (const Tint ANbRows, const Tint ANbCols, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- tel_point AFNormals, tel_colour AFColors, const Tint AShapeFlag)
-{
- myData.num_rows = ANbRows;
- myData.num_columns = ANbCols;
-
- const Tint nf = ANbRows * ANbCols;
- const Tint nv = ( ANbRows+1 ) * ( ANbCols+1 );
-
- Tint i;
-
- // Store vertices
- myData.vertices = AVertices;
-
- // Store or compute (based on vertices) facet normals
- if (AFNormals)
- {
- myData.facet_flag = TEL_FA_NORMAL;
- myData.fnormals = new TEL_POINT[nf];
- memcpy( myData.fnormals, AFNormals, nf*sizeof(TEL_POINT) );
- for( i = 0; i < nf; i++ )
- vecnrm( myData.fnormals[i].xyz );
- }
- else
- {
- myData.facet_flag = TEL_FA_NONE;
- myData.fnormals = new TEL_POINT[nf];
- for( i = 0; i < nf; i++ )
- {
- const Tint r = i/ANbCols;
- const Tint c = i%ANbCols;
- const Tint id = r*(ANbCols+1) + c;
-
- TEL_POINT p1, p2, p3, p4;
-
- p1 = myData.vertices[id];
- p2 = myData.vertices[id+ANbCols+1];
- p3 = myData.vertices[id+ANbCols+2];
- p4 = myData.vertices[id+1];
-
- p4.xyz[0] -= p2.xyz[0];
- p4.xyz[1] -= p2.xyz[1];
- p4.xyz[2] -= p2.xyz[2];
-
- p4.xyz[0] += p1.xyz[0];
- p4.xyz[1] += p1.xyz[1];
- p4.xyz[2] += p1.xyz[2];
-
- TelGetNormal( p4.xyz, p1.xyz, p3.xyz, myData.fnormals[i].xyz );
- }
- }
-
- // Store or compute (based on facet normals) vertex normals
- if (AVNormals)
- {
- myData.vertex_flag = TEL_VT_NORMAL;
- myData.vnormals = AVNormals;
- for( i = 0; i < nv; i++ )
- vecnrm( myData.vnormals[i].xyz );
- }
- else
- {
- myData.vertex_flag = TEL_VT_NONE;
- myData.vnormals = new TEL_POINT[nv];
- Tint r, c, id;
- for( i = 0; i < nv; i++ )
- {
- if( i == 0 )
- myData.vnormals[i] = myData.fnormals[i];
- else if( i == (nv-1) )
- myData.vnormals[i] = myData.fnormals[nf-1];
- else if( i == (nv-ANbCols-1) )
- myData.vnormals[i] = myData.fnormals[nf-ANbCols];
- else if( i == ANbCols )
- myData.vnormals[i] = myData.fnormals[i-1];
- else if( i%(ANbCols+1) == 0 )
- {
- r = i/(myData.num_columns+1);
- myData.vnormals[i].xyz[0] = ( myData.fnormals[(r-1)*ANbCols].xyz[0] + myData.fnormals[r*ANbCols].xyz[0] ) / 2.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[(r-1)*ANbCols].xyz[1] + myData.fnormals[r*ANbCols].xyz[1] ) / 2.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[(r-1)*ANbCols].xyz[2] + myData.fnormals[r*ANbCols].xyz[2] ) / 2.0F;
- }
- else if( i <= ANbCols )
- {
- myData.vnormals[i].xyz[0] = ( myData.fnormals[i-1].xyz[0] + myData.fnormals[i].xyz[0] ) / 2.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[i-1].xyz[1] + myData.fnormals[i].xyz[1] ) / 2.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[i-1].xyz[2] + myData.fnormals[i].xyz[2] ) / 2.0F;
- }
- else if( i >= (nv-ANbCols-1 ) )
- {
- c = i%(ANbCols+1);
- id = nf-ANbCols+c;
-
- myData.vnormals[i].xyz[0] = ( myData.fnormals[id-1].xyz[0] + myData.fnormals[id].xyz[0] ) / 2.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[id-1].xyz[1] + myData.fnormals[id].xyz[1] ) / 2.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[id-1].xyz[2] + myData.fnormals[id].xyz[2] ) / 2.0F;
- }
- else if( (i+1)%(ANbCols+1) == 0 )
- {
- r = (i+1)/(ANbCols+1);
- myData.vnormals[i].xyz[0] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[0] + myData.fnormals[r*ANbCols-1].xyz[0] ) / 2.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[1] + myData.fnormals[r*ANbCols-1].xyz[1] ) / 2.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[2] + myData.fnormals[r*ANbCols-1].xyz[2] ) / 2.0F;
- }
- else
- {
- r = i/(ANbCols+1);
- c = i%(ANbCols+1);
-
- id = r*ANbCols+c;
-
- myData.vnormals[i].xyz[0] = ( myData.fnormals[id].xyz[0] + myData.fnormals[id-ANbCols].xyz[0] + myData.fnormals[id-1].xyz[0] + myData.fnormals[id-ANbCols-1].xyz[0] ) / 4.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[id].xyz[1] + myData.fnormals[id-ANbCols].xyz[1] + myData.fnormals[id-1].xyz[1] + myData.fnormals[id-ANbCols-1].xyz[1] ) / 4.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[id].xyz[2] + myData.fnormals[id-ANbCols].xyz[2] + myData.fnormals[id-1].xyz[2] + myData.fnormals[id-ANbCols-1].xyz[2] ) / 4.0F;
- }
- }
- }
-
- myData.vcolours = AVColors;
- myData.vtexturecoord = ATCoords;
- myData.fcolours = AFColors;
-
- myData.shape_flag = AShapeFlag;
-
- myDS = new DS_INTERNAL;
- myDS->list = 0;
- myDS->dlist = 0;
- myDS->degMode = 0;
- myDS->model = -1;
- myDS->skipRatio = 0.0F;
- myDS->bDraw = new unsigned char[nv];
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_QuadrangleStrip::~OpenGl_QuadrangleStrip ()
-{
- if( myData.fnormals )
- delete[] myData.fnormals;
- if( myData.fcolours )
- delete[] myData.fcolours;
- if( myData.vertices )
- delete[] myData.vertices;
- if( myData.vcolours )
- delete[] myData.vcolours;
- if( myData.vnormals )
- delete[] myData.vnormals;
- if ( myData.vtexturecoord )
- delete[] myData.vtexturecoord;
-
- if ( myDS )
- {
- if ( GET_GL_CONTEXT() != NULL )
- {
- if ( myDS->list ) glDeleteLists ( myDS->list, 1 );
- if ( myDS->dlist ) glDeleteLists ( myDS->dlist, 1 );
- }
- if ( myDS->bDraw )
- delete[] myDS->bDraw;
-
- delete myDS;
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_QuadrangleStrip::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- Tint front_lighting_model = aspect_face->Context().IntFront.color_mask;
- const TEL_COLOUR *interior_colour = &aspect_face->Context().IntFront.matcol;
- const TEL_COLOUR *edge_colour = &aspect_face->AspectEdge()->Color();
-
- // Use highlight colors
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
- {
- edge_colour = interior_colour = AWorkspace->HighlightColor;
- front_lighting_model = 0;
- }
-
- glColor3fv( interior_colour->rgb );
-
- draw_qstrip( front_lighting_model,
- aspect_face->Context().InteriorStyle,
- edge_colour,
- AWorkspace );
-}
-
-/*----------------------------------------------------------------------*/
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#ifndef OpenGl_QuadrangleStrip_Header
-#define OpenGl_QuadrangleStrip_Header
-
-#include <InterfaceGraphic_telem.hxx>
-#include <Graphic3d_Array2OfVertex.hxx>
-#include <Graphic3d_Array2OfVertexN.hxx>
-#include <Graphic3d_Array2OfVertexNT.hxx>
-#include <Aspect_InteriorStyle.hxx>
-
-#include <OpenGl_Element.hxx>
-
-struct OPENGL_QSTRIP_DATA
-{
- Tint shape_flag; /* TEL_SHAPE_UNKNOWN or TEL_SHAPE_COMPLEX or
- TEL_SHAPE_CONVEX or TEL_SHAPE_CONCAVE */
- Tint facet_flag; /* TEL_FA_NONE or TEL_FA_NORMAL */
- Tint vertex_flag; /* TEL_VT_NONE or TEL_VT_NORMAL */
- Tint num_rows, num_columns; /* Number of rows and columns */
- tel_point fnormals; /* Facet normals */
- tel_colour fcolours; /* Facet colours */
- tel_point vertices; /* Vertices */
- tel_colour vcolours; /* Vertex colour values */
- tel_point vnormals; /* Vertex normals */
- tel_texture_coord vtexturecoord; /* Texture coordinates */
- DEFINE_STANDARD_ALLOC
-};
-
-class OpenGl_QuadrangleStrip : public OpenGl_Element
-{
- public:
-
- OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertex& AListVertex);
- OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexN& AListVertex);
- OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexNT& AListVertex);
- virtual ~OpenGl_QuadrangleStrip ();
-
- virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
-
- protected:
-
- void Init (const Tint ANbRows, const Tint ANbCols, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- tel_point AFNormals, tel_colour AFColors, const Tint AShapeFlag);
-
- void draw_qstrip (const Tint, /* front_lighting_model, */
- const Aspect_InteriorStyle, /* interior_style, */
- const TEL_COLOUR *, /* edge_colour, */
- const Handle(OpenGl_Workspace) &) const;
-
- void draw_edges (const TEL_COLOUR *, const Aspect_InteriorStyle, Tint, const Handle(OpenGl_Workspace) &) const;
-
- void draw_line_strip (const TEL_COLOUR *, Tint, Tint) const;
-
- OPENGL_QSTRIP_DATA myData;
- DS_INTERNAL *myDS;
-
- public:
- DEFINE_STANDARD_ALLOC
-};
-
-#endif //OpenGl_QuadrangleStrip_Header
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GlCore11.hxx>
-
-#include <OpenGl_TriangleStrip.hxx>
-
-#include <OpenGl_telem_util.hxx>
-#include <OpenGl_TextureBox.hxx>
-
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_Structure.hxx>
-
-/*----------------------------------------------------------------------*/
-
-void draw_degenerates_as_points ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
-void draw_degenerates_as_bboxs ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
-extern void set_drawable_items ( GLboolean*, int, const float );
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_TriangleStrip::draw_tmesh (const Tint front_lighting_model,
- const Aspect_InteriorStyle interior_style,
- const TEL_COLOUR *edge_colour,
- const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- Tint i, newList = 0;
-
- tel_colour pfc = myData.fcolours;
- tel_point pv = myData.vertices;
- tel_colour pvc = myData.vcolours;
- tel_point pvn = myData.vnormals;
- tel_texture_coord pvt = myData.vtexturecoord;
-
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT ) pvc = pfc = 0;
-
- if ( AWorkspace->DegenerateModel < 2 && interior_style != Aspect_IS_EMPTY )
- {
- if ( front_lighting_model )
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
-
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- if ( myDS->model != front_lighting_model || !myDS->list || myDS->model == -1 ||
- ( AWorkspace->DegenerateModel && myDS->skipRatio != AWorkspace->SkipRatio ) )
- {
- myDS->skipRatio = AWorkspace->SkipRatio;
- myDS->model = front_lighting_model;
- myDS->degMode = AWorkspace->DegenerateModel;
-
- if ( AWorkspace->SkipRatio <= 0.f ) {
-
- if ( !myDS->list ) myDS->list = glGenLists ( 1 );
-
- glNewList ( myDS->list, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- glBegin ( GL_TRIANGLE_STRIP );
-
- if ( front_lighting_model )
- {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- {
- for ( i = 0; i < myData.num_facets + 2; ++i )
- {
- glNormal3fv ( pvn[ i ].xyz );
- glTexCoord2fv ( pvt[ i ].xy );
- glVertex3fv ( pv [ i ].xyz );
- }
- }
- else
- for ( i = 0; i < myData.num_facets + 2; ++i )
- {
- glNormal3fv( pvn[ i ].xyz );
- glVertex3fv( pv[ i ].xyz );
- }
- }
- else
- {
- if ( pvc )
- {
- for ( i = 0; i < myData.num_facets + 2; ++i )
- {
- glColor3fv ( pvc[ i ].rgb );
- glVertex3fv ( pv [ i ].xyz );
- }
- }
- else if ( pfc )
- {
- glColor3fv ( pfc[ 0 ].rgb );
- glVertex3fv ( pv [ 0 ].xyz );
- glVertex3fv ( pv [ 1 ].xyz );
- for ( i = 2; i < myData.num_facets + 2; ++i )
- {
- glColor3fv ( pfc[ i - 2 ].rgb );
- glVertex3fv( pv [ i ].xyz );
- }
- }
- else
- for ( i = 0; i < myData.num_facets + 2; ++i ) glVertex3fv ( pv[ i ].xyz );
- }
- glEnd ();
- }
- else if ( AWorkspace->SkipRatio < 1.f )
- {
- set_drawable_items ( myDS->bDraw, myData.num_facets + 2, AWorkspace->SkipRatio );
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- glBegin ( GL_TRIANGLES );
-
- if ( front_lighting_model )
- {
- if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
- {
- for ( i = 0; i < myData.num_facets; ++i )
- {
- if ( myDS->bDraw[ i ] )
- {
- if ( i % 2 )
- {
- glNormal3fv ( pvn[ i ].xyz );
- glTexCoord2fv ( pvt[ i ].xy );
- glVertex3fv ( pv [ i ].xyz );
- glNormal3fv ( pvn[ i + 2 ].xyz );
- glTexCoord2fv ( pvt[ i + 2 ].xy );
- glVertex3fv ( pv [ i + 2 ].xyz );
- glNormal3fv ( pvn[ i + 1 ].xyz );
- glTexCoord2fv ( pvt[ i + 1 ].xy );
- glVertex3fv ( pv [ i + 1 ].xyz );
- }
- else
- {
- glNormal3fv ( pvn[ i + 2 ].xyz );
- glTexCoord2fv ( pvt[ i + 2 ].xy );
- glVertex3fv ( pv [ i + 2 ].xyz );
- glNormal3fv ( pvn[ i ].xyz );
- glTexCoord2fv ( pvt[ i ].xy );
- glVertex3fv ( pv [ i ].xyz );
- glNormal3fv ( pvn[ i + 1 ].xyz );
- glTexCoord2fv ( pvt[ i + 1 ].xy );
- glVertex3fv ( pv [ i + 1 ].xyz );
- }
- }
- }
- }
- else
- {
- for ( i = 0; i < myData.num_facets; ++i )
- {
- if ( myDS->bDraw[ i ] )
- {
- if ( i % 2 )
- {
- glNormal3fv( pvn[ i ].xyz );
- glVertex3fv( pv[ i ].xyz );
- glNormal3fv( pvn[ i + 2 ].xyz );
- glVertex3fv( pv[ i + 2 ].xyz );
- glNormal3fv( pvn[ i + 1 ].xyz );
- glVertex3fv( pv[ i + 1 ].xyz );
- }
- else
- {
- glNormal3fv( pvn[ i + 2 ].xyz );
- glVertex3fv( pv[ i + 2 ].xyz );
- glNormal3fv( pvn[ i ].xyz );
- glVertex3fv( pv[ i ].xyz );
- glNormal3fv( pvn[ i + 1 ].xyz );
- glVertex3fv( pv[ i + 1 ].xyz );
- }
- }
- }
- }
- }
- else
- {
- if ( pvc )
- {
- for ( i = 0; i < myData.num_facets; ++i )
- {
- if ( myDS->bDraw[ i ] )
- {
- if ( i % 2 )
- {
- glColor3fv ( pvc[ i ].rgb );
- glVertex3fv ( pv [ i ].xyz );
- glColor3fv ( pvc[ i + 2 ].rgb );
- glVertex3fv ( pv [ i + 2 ].xyz );
- glColor3fv ( pvc[ i + 1 ].rgb );
- glVertex3fv ( pv [ i + 1 ].xyz );
- }
- else
- {
- glColor3fv ( pvc[ i + 2 ].rgb );
- glVertex3fv ( pv [ i + 2 ].xyz );
- glColor3fv ( pvc[ i ].rgb );
- glVertex3fv ( pv [ i ].xyz );
- glColor3fv ( pvc[ i + 1 ].rgb );
- glVertex3fv ( pv [ i + 1 ].xyz );
- }
- }
- }
- }
- else if ( pfc )
- {
- for ( i = 0; i < myData.num_facets; ++i )
- {
- if ( myDS->bDraw[ i ] )
- {
- if ( i % 2 )
- {
- glColor3fv ( pfc[ i ].rgb );
- glVertex3fv( pv [ i ].xyz );
- glColor3fv ( pfc[ i + 2 ].rgb );
- glVertex3fv( pv [ i + 2 ].xyz );
- glColor3fv ( pfc[ i + 1 ].rgb );
- glVertex3fv( pv [ i + 1 ].xyz );
- }
- else
- {
- glColor3fv ( pfc[ i + 2 ].rgb );
- glVertex3fv( pv [ i + 2 ].xyz );
- glColor3fv ( pfc[ i ].rgb );
- glVertex3fv( pv [ i ].xyz );
- glColor3fv ( pfc[ i + 1 ].rgb );
- glVertex3fv( pv [ i + 1 ].xyz );
- }
- }
- }
- }
- else
- {
- for ( i = 0; i < myData.num_facets; ++i )
- {
- if ( myDS->bDraw[ i ] )
- {
- if ( i % 2 )
- {
- glVertex3fv ( pv[ i ].xyz );
- glVertex3fv ( pv[ i + 2 ].xyz );
- glVertex3fv ( pv[ i + 1 ].xyz );
- }
- else
- {
- glVertex3fv ( pv[ i + 2 ].xyz );
- glVertex3fv ( pv[ i ].xyz );
- glVertex3fv ( pv[ i + 1 ].xyz );
- }
- }
- }
- }
- }
- glEnd ();
- }
- else
- {
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
- }
- if ( newList ) glEndList ();
-
- if ( AWorkspace->DegenerateModel ) return;
- }
- else
- {
- glCallList ( AWorkspace->SkipRatio <= 0.f ? myDS->list : myDS->dlist );
- if ( AWorkspace->DegenerateModel ) return;
- }
- }
-
- i = 0;
-
- /* OCC11904 -- Temporarily disable environment mapping */
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_TEXTURE_1D);
- glDisable(GL_TEXTURE_2D);
-
- switch ( AWorkspace->DegenerateModel )
- {
- default:
- break;
-
- case 2: /* XXX_TDM_WIREFRAME */
- i = 1;
- break;
-
- case 3: /* XXX_TDM_MARKER */
- draw_degenerates_as_points ( myDS, myData.vertices, myData.num_facets + 2, AWorkspace );
- glPopAttrib();
- return;
-
- case 4: /* XXX_TDM_BBOX */
- draw_degenerates_as_bboxs ( myDS, myData.vertices, myData.num_facets + 2, AWorkspace );
- glPopAttrib();
- return;
- }
-
- draw_edges ( edge_colour, interior_style, i, AWorkspace );
-
- glPopAttrib();
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_TriangleStrip::draw_edges (const TEL_COLOUR *edge_colour, const Aspect_InteriorStyle interior_style,
- Tint forceDraw, const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- if ( interior_style != Aspect_IS_HIDDENLINE && !forceDraw && aspect_face->Context().Edge == TOff )
- return;
-
- glDisable(GL_LIGHTING);
- const GLboolean texture_on = IsTextureEnabled();
- if ( texture_on ) DisableTexture();
-
- // Setup line aspect
- const OpenGl_AspectLine *aspect_line_old = AWorkspace->SetAspectLine( aspect_face->AspectEdge() );
- AWorkspace->AspectLine( Standard_True );
-
- tel_point pv = myData.vertices;
- Tint i, newList = 0;
-
- glColor3fv ( edge_colour->rgb );
- if ( !forceDraw )
- draw_line_loop ();
- else
- {
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- if ( myDS->degMode != 2 || myDS->skipRatio != AWorkspace->SkipRatio || !myDS->dlist ) {
-
- if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
-
- myDS->degMode = 2;
- myDS->skipRatio = AWorkspace->SkipRatio;
- glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- glPushAttrib ( GL_DEPTH_BUFFER_BIT );
- glDisable ( GL_DEPTH_TEST );
-
- if ( AWorkspace->SkipRatio <= 0.f )
-
- draw_line_loop ();
-
- else if ( AWorkspace->SkipRatio < 1.f ) {
-
- set_drawable_items ( myDS->bDraw, myData.num_facets + 2, AWorkspace->SkipRatio );
-
- for ( i = 0; i < myData.num_facets; ++i )
-
- if ( myDS->bDraw[ i ] ) {
-
- glBegin ( GL_LINE_LOOP );
- glVertex3fv ( pv[ i ].xyz );
- glVertex3fv ( pv[ i + 1 ].xyz );
- glVertex3fv ( pv[ i + 2 ].xyz );
- glEnd();
-
- } /* end if */
-
- } /* end if */
-
- glPopAttrib ();
- if ( newList ) glEndList ();
-
- } else glCallList ( myDS->dlist );
-
- } /* end else */
-
- // Restore line context
- AWorkspace->SetAspectLine( aspect_line_old );
-
- if ( texture_on ) EnableTexture ();
-}
-
-void draw_degenerates_as_points ( PDS_INTERNAL pd, tel_point p, Tint n, const Handle(OpenGl_Workspace) &AWorkspace )
-{
- int i, newList = 0;
-
- glDisable(GL_LIGHTING);
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- if ( pd -> degMode != 3 || pd -> skipRatio != AWorkspace->SkipRatio || !pd -> dlist ) {
-
- if ( !pd -> dlist ) pd -> dlist = glGenLists ( 1 );
-
- pd -> degMode = 3;
- pd -> skipRatio = AWorkspace->SkipRatio;
- glNewList ( pd -> dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-
- if ( AWorkspace->SkipRatio <= 0.f ) {
-doDraw:
- glBegin ( GL_POINTS );
-
- for ( i = 0; i < n; ++i ) glVertex3fv ( p[ i ].xyz );
-
- glEnd ();
-
- } else if ( AWorkspace->SkipRatio < 1.f ) {
-
- set_drawable_items ( pd -> bDraw, n, AWorkspace->SkipRatio );
-
- glBegin ( GL_POINTS );
-
- for ( i = 0; i < n; ++i )
-
- if ( pd -> bDraw[ i ] ) glVertex3fv ( p[ i ].xyz );
-
- glEnd ();
-
- } /* end if */
- if ( newList ) glEndList ();
-
- } else glCallList ( pd -> dlist );
-
-} /* end draw_degenerates_as_points */
-
-void draw_degenerates_as_bboxs ( PDS_INTERNAL pd, tel_point p, Tint n, const Handle(OpenGl_Workspace) &AWorkspace )
-{
- int i, newList = 0;
- GLfloat minp[ 3 ] = { FLT_MAX, FLT_MAX, FLT_MAX };
- GLfloat maxp[ 3 ] = { FLT_MIN, FLT_MIN, FLT_MIN };
-
- glDisable(GL_LIGHTING);
- if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
- goto doDraw; /* Disable object display list out of animation */
- if ( pd -> degMode != 4 || !pd -> dlist ) {
-
- if ( !pd -> dlist ) pd -> dlist = glGenLists ( 1 );
-
- pd -> degMode = 4;
-
- glNewList ( pd -> dlist, GL_COMPILE_AND_EXECUTE );
- newList = 1;
-doDraw:
- for ( i = 0; i < n; ++i ) {
-
- TEL_POINT pt = p[ i ];
-
- if ( pt.xyz[ 0 ] < minp[ 0 ] )
- minp[ 0 ] = pt.xyz[ 0 ] ;
- if ( pt.xyz[ 1 ] < minp[ 1 ] )
- minp[ 1 ] = pt.xyz[ 1 ] ;
- if ( pt.xyz[ 2 ] < minp[ 2 ] )
- minp[ 2 ] = pt.xyz[ 2 ] ;
-
- if ( pt.xyz[ 0 ] > maxp[ 0 ] )
- maxp[ 0 ] = pt.xyz[ 0 ] ;
- if ( pt.xyz[ 1 ] > maxp[ 1 ] )
- maxp[ 1 ] = pt.xyz[ 1 ] ;
- if ( pt.xyz[ 2 ] > maxp[ 2 ] )
- maxp[ 2 ] = pt.xyz[ 2 ] ;
-
- } /* end for */
-
- glBegin ( GL_LINE_STRIP );
-
- glVertex3fv ( minp );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], minp[ 2 ] );
-
- glVertex3f ( maxp[ 0 ], minp[ 1 ], minp[ 2 ] );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3f ( maxp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( maxp[ 0 ], minp[ 1 ], minp[ 2 ] );
-
- glVertex3f ( maxp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], minp[ 1 ], maxp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], maxp[ 2 ] );
- glVertex3fv ( maxp );
- glVertex3f ( maxp[ 0 ], maxp[ 1 ], minp[ 2 ] );
- glVertex3f ( minp[ 0 ], maxp[ 1 ], minp[ 2 ] );
-
- glEnd();
- if ( newList ) glEndList ();
-
- } else glCallList ( pd -> dlist );
-
-} /* end draw_degenerates_as_bboxs */
-
-void OpenGl_TriangleStrip::draw_line_loop () const
-{
- int i;
-
- for ( i = 0; i < myData.num_facets; ++i )
- {
- glBegin ( GL_LINE_LOOP );
- glVertex3fv ( myData.vertices[ i ].xyz );
- glVertex3fv ( myData.vertices[ i + 1 ].xyz );
- glVertex3fv ( myData.vertices[ i + 2 ].xyz );
- glEnd();
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_TriangleStrip::OpenGl_TriangleStrip (const Graphic3d_Array1OfVertex& AListVertex)
-{
- const Standard_Integer nv = AListVertex.Length();
- TEL_POINT *points = new TEL_POINT[nv];
- memcpy( points, &AListVertex(AListVertex.Lower()), nv*sizeof(TEL_POINT) );
-
- Init(nv - 2,points,NULL,NULL,NULL,NULL,NULL);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_TriangleStrip::OpenGl_TriangleStrip (const Graphic3d_Array1OfVertexN& AListVertex)
-{
- const Standard_Integer nv = AListVertex.Length ();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_POINT *normals = new TEL_POINT[nv];
-
- Standard_Integer i = 0, j = AListVertex.Lower();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord (X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Normal (X, Y, Z);
- normals[i].xyz[0] = float (X);
- normals[i].xyz[1] = float (Y);
- normals[i].xyz[2] = float (Z);
- }
-
- Init(nv - 2,points,normals,NULL,NULL,NULL,NULL);
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_TriangleStrip::OpenGl_TriangleStrip (const Graphic3d_Array1OfVertexNT& AListVertex)
-{
- const Standard_Integer nv = AListVertex.Length();
-
- // Dynamic allocation
- TEL_POINT *points = new TEL_POINT[nv];
- TEL_POINT *normals = new TEL_POINT[nv];
- TEL_TEXTURE_COORD *tcoords = new TEL_TEXTURE_COORD[nv];
-
- Standard_Integer i = 0, j = AListVertex.Upper();
- Standard_Real X, Y, Z;
- for ( ; i < nv; i++, j++)
- {
- AListVertex(j).Coord (X, Y, Z);
- points[i].xyz[0] = float (X);
- points[i].xyz[1] = float (Y);
- points[i].xyz[2] = float (Z);
- AListVertex(j).Normal (X, Y, Z);
- normals[i].xyz[0] = float (X);
- normals[i].xyz[1] = float (Y);
- normals[i].xyz[2] = float (Z);
- AListVertex(j).TextureCoordinate(X, Y);
- tcoords[i].xy[0] = float(X);
- tcoords[i].xy[1] = float(Y);
- }
-
- Init(nv - 2,points,normals,NULL,tcoords,NULL,NULL);
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_TriangleStrip::Init (const Tint ANbFacets, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- tel_point AFNormals, tel_colour AFColors)
-{
- myData.num_facets = ANbFacets;
-
- const Tint nv = ANbFacets + 2;
-
- Tint i;
-
- // Store vertices
- myData.vertices = AVertices;
-
- // Store or compute (based on vertices) facet normals
- if (AFNormals)
- {
- myData.facet_flag = TEL_FA_NORMAL;
- myData.fnormals = AFNormals;
- for( i = 0; i < ANbFacets; i++ )
- vecnrm( myData.fnormals[i].xyz );
- }
- else
- {
- myData.facet_flag = TEL_FA_NONE;
- myData.fnormals = new TEL_POINT[ANbFacets];
- for( i = 0; i < ANbFacets; i++ )
- {
- if( i & 1 ) {
- TelGetNormal( myData.vertices[i].xyz, myData.vertices[i+2].xyz, myData.vertices[i+1].xyz, myData.fnormals[i].xyz );
- } else {
- TelGetNormal( myData.vertices[i].xyz, myData.vertices[i+1].xyz, myData.vertices[i+2].xyz, myData.fnormals[i].xyz );
- }
- }
- }
-
- // Store or compute (based on facet normals) vertex normals
- if (AVNormals)
- {
- myData.vertex_flag = TEL_VT_NORMAL;
- myData.vnormals = AVNormals;
- for( i = 0; i < nv; i++ )
- vecnrm( myData.vnormals[i].xyz );
- }
- else
- {
- myData.vertex_flag = TEL_VT_NONE;
- myData.vnormals = new TEL_POINT[nv];
- for( i = 2; i < ANbFacets; i++ )
- {
- myData.vnormals[i].xyz[0] = ( myData.fnormals[i-2].xyz[0] + myData.fnormals[i-1].xyz[0] + myData.fnormals[i].xyz[0] ) / 3.0F;
- myData.vnormals[i].xyz[1] = ( myData.fnormals[i-2].xyz[1] + myData.fnormals[i-1].xyz[1] + myData.fnormals[i].xyz[1] ) / 3.0F;
- myData.vnormals[i].xyz[2] = ( myData.fnormals[i-2].xyz[2] + myData.fnormals[i-1].xyz[2] + myData.fnormals[i].xyz[2] ) / 3.0F;
- }
- myData.vnormals[0] = myData.fnormals[0];
- if( ANbFacets > 1 )
- {
- myData.vnormals[1].xyz[0] = ( myData.fnormals[0].xyz[0] + myData.fnormals[1].xyz[0] ) / 2.0F;
- myData.vnormals[1].xyz[1] = ( myData.fnormals[0].xyz[1] + myData.fnormals[1].xyz[1] ) / 2.0F;
- myData.vnormals[1].xyz[2] = ( myData.fnormals[0].xyz[2] + myData.fnormals[1].xyz[2] ) / 2.0F;
- }
- else
- myData.vnormals[1] = myData.fnormals[0];
- // last vertex
- myData.vnormals[ANbFacets+1] = myData.fnormals[ANbFacets-1];
- // second last vertex
- if( ANbFacets > 1 )
- {
- myData.vnormals[ANbFacets].xyz[0] = ( myData.fnormals[ANbFacets-1].xyz[0] + myData.fnormals[ANbFacets-2].xyz[0] ) / 2.0F;
- myData.vnormals[ANbFacets].xyz[1] = ( myData.fnormals[ANbFacets-1].xyz[1] + myData.fnormals[ANbFacets-2].xyz[1] ) / 2.0F;
- myData.vnormals[ANbFacets].xyz[2] = ( myData.fnormals[ANbFacets-1].xyz[2] + myData.fnormals[ANbFacets-2].xyz[2] ) / 2.0F;
- }
- }
-
- myData.vcolours = AVColors;
- myData.vtexturecoord = ATCoords;
- myData.fcolours = AFColors;
-
- myDS = new DS_INTERNAL();
- myDS->list = 0;
- myDS->dlist = 0;
- myDS->degMode = 0;
- myDS->model = -1;
- myDS->skipRatio = 0.0F;
- myDS->bDraw = new unsigned char[nv];
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_TriangleStrip::~OpenGl_TriangleStrip ()
-{
- if( myData.fnormals )
- delete[] myData.fnormals;
- if( myData.fcolours )
- delete[] myData.fcolours;
- if( myData.vertices )
- delete[] myData.vertices;
- if( myData.vcolours )
- delete[] myData.vcolours;
- if( myData.vnormals )
- delete[] myData.vnormals;
- if ( myData.vtexturecoord )
- delete[] myData.vtexturecoord;
-
- if ( myDS )
- {
- if ( GET_GL_CONTEXT() != NULL )
- {
- if ( myDS->list ) glDeleteLists ( myDS->list, 1 );
- if ( myDS->dlist ) glDeleteLists ( myDS->dlist, 1 );
- }
- if ( myDS->bDraw )
- delete[] myDS->bDraw;
-
- delete myDS;
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_TriangleStrip::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
-{
- const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
-
- Tint front_lighting_model = aspect_face->Context().IntFront.color_mask;
- const TEL_COLOUR *interior_colour = &aspect_face->Context().IntFront.matcol;
- const TEL_COLOUR *edge_colour = &aspect_face->AspectEdge()->Color();
-
- // Use highlight colors
- if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
- {
- edge_colour = interior_colour = AWorkspace->HighlightColor;
- front_lighting_model = 0;
- }
-
- glColor3fv( interior_colour->rgb );
-
- draw_tmesh( front_lighting_model,
- aspect_face->Context().InteriorStyle,
- edge_colour,
- AWorkspace );
-}
-
-/*----------------------------------------------------------------------*/
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#ifndef OpenGl_TriangleStrip_Header
-#define OpenGl_TriangleStrip_Header
-
-#include <InterfaceGraphic_telem.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_Array1OfVertexN.hxx>
-#include <Graphic3d_Array1OfVertexNT.hxx>
-#include <Aspect_InteriorStyle.hxx>
-
-#include <OpenGl_Element.hxx>
-
-struct TEL_TMESH_DATA
-{
- Tint num_facets; /* Number of facets */
- Tint facet_flag; /* TEL_FA_NONE or TEL_FA_NORMAL */
- Tint vertex_flag;/* TEL_VT_NONE or TEL_VT_NORMAL */
- tel_point fnormals; /* length = num_facets */
- tel_colour fcolours; /* length = num_facets */
- tel_point vertices; /* length = num_facets + 2 */
- tel_colour vcolours; /* length = num_facets + 2 */
- tel_point vnormals; /* length = num_facets + 2 */
- tel_texture_coord vtexturecoord; /* Texture coordinates */
- DEFINE_STANDARD_ALLOC
-};
-
-class OpenGl_TriangleStrip : public OpenGl_Element
-{
- public:
-
- OpenGl_TriangleStrip (const Graphic3d_Array1OfVertex& AListVertex);
- OpenGl_TriangleStrip (const Graphic3d_Array1OfVertexN& AListVertex);
- OpenGl_TriangleStrip (const Graphic3d_Array1OfVertexNT& AListVertex);
- virtual ~OpenGl_TriangleStrip ();
-
- virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
-
- protected:
-
- void Init (const Tint ANbFacets, tel_point AVertices,
- tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
- tel_point AFNormals, tel_colour AFColors);
-
- void draw_tmesh (const Tint, /* front_lighting_model, */
- const Aspect_InteriorStyle, /* interior_style */
- const TEL_COLOUR *, /* edge_colour */
- const Handle(OpenGl_Workspace) &) const;
-
- void draw_edges (const TEL_COLOUR *, const Aspect_InteriorStyle, Tint, const Handle(OpenGl_Workspace) &) const;
-
- void draw_line_loop () const;
-
- TEL_TMESH_DATA myData;
- DS_INTERNAL *myDS;
-
- public:
- DEFINE_STANDARD_ALLOC
-};
-
-#endif //OpenGl_TriangleStrip_Header
generic class SectionShapeTool;
- generic class ShadedShape;
-
-
---Category: Basis construction elements.
generic class Vector;
generic class Datum;
+++ /dev/null
--- Created on: 1993-09-23
--- Created by: Jean Louis FRENKEL
--- Copyright (c) 1993-1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
---
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
---
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
---
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
-
-
-generic class ShadedShape from Prs3d(anyShape as any;
- anyTopFace as any;
- anyMeshTriangle as any;
- anyMeshEdge as any;
- anyShadedShapeTool as any
- )
-inherits Root from Prs3d
-
-uses
-
- Presentation from Prs3d,
- Drawer from Prs3d
-
-is
- Add(myclass; aPresentation: Presentation from Prs3d;
- aShape : anyShape;
- aDrawer : Drawer from Prs3d);
-
- ---Purpose: Shades <aShape>.
-
-end ShadedShape from Prs3d;
+++ /dev/null
-// Created on: 1993-09-23
-// Created by: Jean-Louis FRENKEL
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-//#define BUC60488//GG_081199 Enable the SuppressBackface() ShadingAspect attribute
-
-#define G005 //ATS,GG 04/01/01 Use ArrayOfPrimitives instead Sets of primitives
-// for performance improvment
-
-#include <Graphic3d_Vertex.hxx>
-#include <Graphic3d_VertexN.hxx>
-#include <Graphic3d_Array1OfVertexN.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Aspect_Edge.hxx>
-#include <Aspect_Array1OfEdge.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Aspect_TypeOfEdge.hxx>
-#include <Bnd_Box.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <BRepTools.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-#include <Poly_Triangulation.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TColgp_Array1OfDir.hxx>
-#include <Poly_Connect.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-#include <BRepMesh_FactoryError.hxx>
-#include <BRepMesh_DiscretRoot.hxx>
-#include <BRepMesh_DiscretFactory.hxx>
-#include <BRepMesh_PDiscretRoot.hxx>
-#include <gp_Vec.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <BRepBndLib.hxx>
-#include <Precision.hxx>
-#ifdef G005
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#endif
-
-
-#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
-#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
-
-
-static Standard_Real GetDeflection(const anyShape& aShape,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
- if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
- Bnd_Box B;
- BRepBndLib::Add(aShape, B, Standard_False);
- if ( ! B.IsVoid() )
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
- * aDrawer->DeviationCoefficient()*4;
- }
- }
- return aDeflection;
-}
-
-
-static Standard_Boolean ShadeFromShape(const anyShape& aShape,
- const Standard_Real /*defle*/,
- const Standard_Boolean /*share*/,
- const Handle (Prs3d_Presentation)& aPresentation,
- const Handle (Prs3d_Drawer)& aDrawer)
-{
- anyShadedShapeTool SST;
- Handle(Poly_Triangulation) T;
- TopLoc_Location loc;
- gp_Pnt p;
- Standard_Integer i,j,k,decal ;
- Standard_Integer t[3], n[3];
- Standard_Integer nbTriangles = 0, nbVertices = 0;
-
- // precision for compare square distances
- double dPreci = Precision::Confusion()*Precision::Confusion();
-
- if ( !aDrawer->ShadingAspectGlobal() ) {
-
- Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
- if(anyShadedShapeTool::IsClosed(aShape)) {
- Asp->SuppressBackFace();
- } else {
- Asp->AllowBackFace();
- }
- Prs3d_Root::CurrentGroup(aPresentation)->SetGroupPrimitivesAspect(Asp);
- }
-
-#ifdef G005
- if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
-
- for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
- const anyTopFace& F = SST.CurrentFace();
- T = SST.Triangulation(F, loc);
- if (!T.IsNull()) {
- nbTriangles += T->NbTriangles();
- nbVertices += T->NbNodes();
- }
- }
-
- if (nbVertices > 2 && nbTriangles > 0) {
- Handle(Graphic3d_ArrayOfTriangles) parray =
- new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
- Standard_True,Standard_False,Standard_False,Standard_True);
- for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
- const anyTopFace& F = SST.CurrentFace();
- T = SST.Triangulation(F, loc);
- if (!T.IsNull()) {
- const gp_Trsf& trsf = loc.Transformation();
- Poly_Connect pc(T);
- // Extracts vertices & normals from nodes
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
- SST.Normal(F, pc, NORMAL);
-
- decal = parray->VertexNumber();
- for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
- p = Nodes(i);
- if( !loc.IsIdentity() ) {
- p.Transform(trsf);
- NORMAL(i).Transform(trsf);
- }
- parray->AddVertex(p,NORMAL(i));
- }
-
- // Fill parray with vertex and edge visibillity info
- const Poly_Array1OfTriangle& triangles = T->Triangles();
- for (i = 1; i <= T->NbTriangles(); i++) {
- pc.Triangles(i,t[0],t[1],t[2]);
- if (SST.Orientation(F) == TopAbs_REVERSED)
- triangles(i).Get(n[0],n[2],n[1]);
- else
- triangles(i).Get(n[0],n[1],n[2]);
- gp_Pnt P1 = Nodes(n[0]);
- gp_Pnt P2 = Nodes(n[1]);
- gp_Pnt P3 = Nodes(n[2]);
- gp_Vec V1(P1,P2);
- if ( V1.SquareMagnitude() > dPreci ) {
- gp_Vec V2(P2,P3);
- if ( V2.SquareMagnitude() > dPreci ) {
- gp_Vec V3(P3,P1);
- if ( V3.SquareMagnitude() > dPreci ) {
- V1.Normalize();
- V2.Normalize();
- V1.Cross(V2);
- if ( V1.SquareMagnitude() > dPreci ) {
- parray->AddEdge(n[0]+decal,t[0] == 0);
- parray->AddEdge(n[1]+decal,t[1] == 0);
- parray->AddEdge(n[2]+decal,t[2] == 0);
- }
- }
- }
- }
- }
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
- Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
- }
- return Standard_True;
- }
-#endif
-
- // phase de comptage:
- Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
- static Standard_Integer plus1mod3[3] = {1, 2, 0};
- for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
- const anyTopFace& F = SST.CurrentFace();
- T = SST.Triangulation(F, loc);
- if (!T.IsNull()) {
- nnn = T->NbTriangles();
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- const Poly_Array1OfTriangle& triangles = T->Triangles();
- for (nt = 1; nt <= nnn; nt++) {
- if (SST.Orientation(F) == TopAbs_REVERSED)
- triangles(nt).Get(n1,n3,n2);
- else
- triangles(nt).Get(n1,n2,n3);
- const gp_Pnt& P1 = Nodes(n1);
- const gp_Pnt& P2 = Nodes(n2);
- const gp_Pnt& P3 = Nodes(n3);
- gp_Vec V1(P1,P2);
- if ( V1.SquareMagnitude() > dPreci ) {
- gp_Vec V2(P2,P3);
- if (V2.SquareMagnitude() > dPreci ) {
- gp_Vec V3(P3,P1);
- if (V3.SquareMagnitude() > dPreci ) {
- V1.Normalize();
- V2.Normalize();
- V1.Cross(V2);
- if (V1.SquareMagnitude() > dPreci ) {
- nbTriangles++;
- }
- }
- }
- }
- }
- nbVertices += T->NbNodes();
- }
- }
-
- if (nbVertices > 2 && nbTriangles > 0) {
- Graphic3d_Array1OfVertexN AVN(1, nbVertices);
- Aspect_Array1OfEdge AE(1, 3*nbTriangles);
-
- EI = 1;
- nnv = 1;
-
- for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
- const anyTopFace& F = SST.CurrentFace();
- T = SST.Triangulation(F, loc);
- if (!T.IsNull()) {
- Poly_Connect pc(T);
- // 1- les noeuds.
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
- SST.Normal(F, pc, NORMAL);
- decal = nnv-1;
-
- for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
- p = Nodes(j).Transformed(loc.Transformation());
- AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
- AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
- nnv++;
- }
- // 2- les edges.
- nbTriangles = T->NbTriangles();
- const Poly_Array1OfTriangle& triangles = T->Triangles();
-
- for (i = 1; i <= nbTriangles; i++) {
- pc.Triangles(i,t[0],t[1],t[2]);
- if (SST.Orientation(F) == TopAbs_REVERSED)
- triangles(i).Get(n[0],n[2],n[1]);
- else
- triangles(i).Get(n[0],n[1],n[2]);
- const gp_Pnt& P1 = Nodes(n[0]);
- const gp_Pnt& P2 = Nodes(n[1]);
- const gp_Pnt& P3 = Nodes(n[2]);
- gp_Vec V1(P1,P2);
- if (V1.SquareMagnitude() > 1.e-10) {
- gp_Vec V2(P2,P3);
- if (V2.SquareMagnitude() > 1.e-10) {
- gp_Vec V3(P3,P1);
- if (V3.SquareMagnitude() > 1.e-10) {
- V1.Normalize();
- V2.Normalize();
- V1.Cross(V2);
- if (V1.SquareMagnitude() > 1.e-10) {
- for (j = 0; j < 3; j++) {
- k = plus1mod3[j];
- if (t[j] == 0)
- AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
- else
- AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
- EI++;
- }
- }
- }
- }
- }
- }
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
- }
- return Standard_True;
-}
-
-
-
-void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
- const anyShape& aShape,
- const Handle (Prs3d_Drawer)& aDrawer)
-{
-
- if (aShape.IsNull()) return;
-
- TopAbs_ShapeEnum E = aShape.ShapeType();
- if (E == TopAbs_COMPOUND) {
- TopExp_Explorer ex;
-
- ex.Init(aShape, TopAbs_FACE);
- if (ex.More()) {
- TopoDS_Compound CO;
- BRep_Builder B;
- B.MakeCompound(CO);
- Standard_Boolean haselement = Standard_False;
-
- // il faut presenter les edges isoles.
- for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
- haselement = Standard_True;
- B.Add(CO, ex.Current());
- }
- // il faut presenter les vertex isoles.
- for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
- haselement = Standard_True;
- B.Add(CO, ex.Current());
- }
- if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
- }
- else {
- StdPrs_WFShape::Add(aPresentation, aShape, aDrawer);
- }
- }
- Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
-
- // Check if it is possible to avoid unnecessary recomputation
- // of shape triangulation
- if (!BRepTools::Triangulation (aShape, aDeflection))
- {
- BRepTools::Clean (aShape);
-
- // retrieve meshing tool from Factory
- Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aShape,
- aDeflection,
- aDrawer->HLRAngle());
- if (!aMeshAlgo.IsNull())
- aMeshAlgo->Perform();
- }
-
- ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
-}
#include <Graphic3d_MaterialAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Aspect_Array1OfEdge.hxx>
-#include <Graphic3d_VertexC.hxx>
-#include <Graphic3d_VertexNC.hxx>
-#include <Graphic3d_Array1OfVertexC.hxx>
-#include <Graphic3d_Array1OfVertexNC.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
#include <AIS_Drawer.hxx>
-QABugs_PresentableObject::QABugs_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
- :AIS_InteractiveObject(aTypeOfPresentation3d)
+QABugs_PresentableObject::QABugs_PresentableObject(const PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d)
+ :AIS_InteractiveObject(theTypeOfPresentation3d)
{
}
-void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer aMode )
+void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
{
- Handle(Graphic3d_Structure) theStructure = Handle(Graphic3d_Structure)::DownCast(aPresentation);
- Handle(Graphic3d_Group) theGroup= new Graphic3d_Group(theStructure);
- Handle_Prs3d_ShadingAspect theAspect = myDrawer->ShadingAspect();
- Graphic3d_MaterialAspect mat = theAspect->Aspect()->FrontMaterial();
- mat.SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
- mat.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
- mat.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
- mat.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
- theAspect->SetMaterial(mat);
- theGroup->SetPrimitivesAspect(theAspect->Aspect());
-
- Aspect_Array1OfEdge aListEdge(1, 3);
- aListEdge.SetValue(1, Aspect_Edge(1, 2, Aspect_TOE_VISIBLE));
- aListEdge.SetValue(2, Aspect_Edge(2, 3, Aspect_TOE_VISIBLE));
- aListEdge.SetValue(3, Aspect_Edge(3, 1, Aspect_TOE_VISIBLE));
- theGroup->BeginPrimitives();
+ Handle(Graphic3d_Structure) aStructure = Handle(Graphic3d_Structure)::DownCast (thePrs);
+ Handle(Graphic3d_Group) aGroup = new Graphic3d_Group (aStructure);
+ Handle_Prs3d_ShadingAspect anAspect = myDrawer->ShadingAspect();
+ Graphic3d_MaterialAspect aMat = anAspect->Aspect()->FrontMaterial();
+ aMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
+ aMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
+ aMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
+ aMat.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
+ anAspect->SetMaterial (aMat);
+ aGroup->SetPrimitivesAspect (anAspect->Aspect());
- switch (aMode)
+ Handle(Graphic3d_ArrayOfTriangles) aPrims
+ = new Graphic3d_ArrayOfTriangles (6, 0,
+ theMode == 1, // normals
+ Standard_True); // color per vertex
+ switch (theMode)
+ {
+ case 0:
{
- case 0://using VertexC
- {
- Graphic3d_Array1OfVertexC theArray1(1, 3);
+ aPrims->AddVertex (gp_Pnt (0.0, 0.0, 0.0), Quantity_Color (Quantity_NOC_RED));
+ aPrims->AddVertex (gp_Pnt (0.0, 5.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
+ aPrims->AddVertex (gp_Pnt (5.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
- theArray1.SetValue(1, Graphic3d_VertexC(0,0,0,Quantity_NOC_RED));
- theArray1.SetValue(2, Graphic3d_VertexC(0,5,1,Quantity_NOC_BLUE1));
- theArray1.SetValue(3, Graphic3d_VertexC(5,0,1,Quantity_NOC_YELLOW));
- theGroup->TriangleSet(theArray1, aListEdge);
-
- theArray1.SetValue(1, Graphic3d_VertexC(0,5,1,Quantity_NOC_BLUE1));
- theArray1.SetValue(2, Graphic3d_VertexC(5,5,-1,Quantity_NOC_GREEN));
- theArray1.SetValue(3, Graphic3d_VertexC(5,0,1,Quantity_NOC_YELLOW));
- theGroup->TriangleSet(theArray1, aListEdge);
- }
- break;
- case 1://using VertexNC
- {
- Graphic3d_Array1OfVertexNC theArray1(1, 3);
-
- theArray1.SetValue(1, Graphic3d_VertexNC(5,0,0, //coord
- 0,0,1, //normal
- Quantity_NOC_RED));
- theArray1.SetValue(2, Graphic3d_VertexNC(5,5,1, //coord
- 1,1,1, //normal
- Quantity_NOC_BLUE1));
- theArray1.SetValue(3, Graphic3d_VertexNC(10,0,1, //coord
- 0,1,1, //normal
- Quantity_NOC_YELLOW));
- theGroup->TriangleSet(theArray1, aListEdge);
-
- theArray1.SetValue(1, Graphic3d_VertexNC(5,5,1, //coord
- 1,1,1, //normal
- Quantity_NOC_BLUE1));
- theArray1.SetValue(2, Graphic3d_VertexNC(10,5,-1, //coord
- 0,0,-1, //normal
- Quantity_NOC_GREEN));
- theArray1.SetValue(3, Graphic3d_VertexNC(10,0,1, //coord
- 0,1,1, //normal
- Quantity_NOC_YELLOW));
- theGroup->TriangleSet(theArray1, aListEdge);
- }
+ aPrims->AddVertex (gp_Pnt (0.0, 5.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
+ aPrims->AddVertex (gp_Pnt (5.0, 5.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
+ aPrims->AddVertex (gp_Pnt (5.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
break;
}
- theGroup->EndPrimitives();
-
+ case 1:
+ {
+ aPrims->AddVertex (gp_Pnt ( 5.0, 0.0, 0.0), gp_Dir (0.0, 0.0, 1.0), Quantity_Color (Quantity_NOC_RED));
+ aPrims->AddVertex (gp_Pnt ( 5.0, 5.0, 1.0), gp_Dir (1.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
+ aPrims->AddVertex (gp_Pnt (10.0, 0.0, 1.0), gp_Dir (0.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
+
+ aPrims->AddVertex (gp_Pnt ( 5.0, 5.0, 1.0), gp_Dir (1.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_BLUE1));
+ aPrims->AddVertex (gp_Pnt (10.0, 5.0, -1.0), gp_Dir (0.0, 0.0, -1.0), Quantity_Color (Quantity_NOC_GREEN));
+ aPrims->AddVertex (gp_Pnt (10.0, 0.0, 1.0), gp_Dir (0.0, 1.0, 1.0), Quantity_Color (Quantity_NOC_YELLOW));
+ }
+ break;
+ }
+
+ aGroup->BeginPrimitives();
+ aGroup->AddPrimitiveArray (aPrims);
+ aGroup->EndPrimitives();
}
-void QABugs_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer aMode) {
+void QABugs_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& ,
+ const Standard_Integer ) {
}
class HLRToolShape;
--class ToolSectionShape;
class ToolShadedShape;
+ class ShadedShape;
class Point
class ShadedSurface;
---Purpose: computes the shading presentation of surfaces.
- class ShadedPoleSurface;
-
-
-----------------------------------------------
--- deflection drawing classes :
-----------------------------------------------
Curve from StdPrs,
Vertex from StdPrs);
-
- class ShadedShape instantiates ShadedShape from Prs3d
- (Shape from TopoDS,
- Face from TopoDS,
- Triangle from BRepMesh,
- Edge from BRepMesh,
- ToolShadedShape from StdPrs);
-
-
class HLRShape instantiates HLRShape from Prs3d
(Shape from TopoDS,
HLRToolShape from StdPrs,
+++ /dev/null
--- Created on: 1993-07-05
--- Created by: Jean Louis FRENKEL
--- Copyright (c) 1993-1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
---
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
---
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
---
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
-
-
-class ShadedPoleSurface from StdPrs
-
-inherits Root from Prs3d
- --- Purpose: Draws a surface by drawing the isoparametric curves with respect to
- -- a maximal chordial deviation.
- -- The number of isoparametric curves to be drawn and their color are
- -- controlled by the furnished Drawer.
-
-uses
- Presentation from Prs3d,
- Surface from Adaptor3d,
- Drawer from Prs3d
-
-is
-
-
- Add(myclass; aPresentation: Presentation from Prs3d;
- aSurface : Surface from Adaptor3d;
- aDrawer : Drawer from Prs3d);
- ---Purpose: Adds the surface aSurface to the presentation object aPresentation.
- -- The surface's display attributes are set in the attribute manager, aDrawer.
-
-end ShadedPoleSurface;
-
-
-
+++ /dev/null
-// Created on: 1995-08-01
-// Created by: Modelistation
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#define G005 //ATS,GG 04/01/01 Use PrimitiveArray instead Sets of primitives
-// for performance improvment
-
-#include <StdPrs_ShadedPoleSurface.ixx>
-
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Graphic3d_Array2OfVertex.hxx>
-#include <TColgp_Array2OfPnt.hxx>
-#include <gp_Pnt.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-
-#include <Geom_BezierSurface.hxx>
-#include <Geom_BSplineSurface.hxx>
-#ifdef G005
-#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
-#endif
-
-//=======================================================================
-//function : Add
-//purpose :
-//=======================================================================
-
-void StdPrs_ShadedPoleSurface::Add(
- const Handle(Prs3d_Presentation)& aPresentation,
- const Adaptor3d_Surface& aSurface,
- const Handle (Prs3d_Drawer)& aDrawer)
-{
- if ( ! aDrawer->ShadingAspectGlobal() ) {
-
-// If the surface is closed, the faces from back-side are not traced:
-
-
- Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
- if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
- Asp->SuppressBackFace();
- } else {
- Asp->AllowBackFace();
- }
- Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
- }
-
- Standard_Integer i,j,n = aSurface.NbUPoles(), m = aSurface.NbVPoles();
-
- if (aSurface.GetType() == GeomAbs_BezierSurface) {
- Handle(Geom_BezierSurface) surface = aSurface.Bezier();
-#ifdef G005
- if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
- Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
- new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
- Standard_False,Standard_False,Standard_False,Standard_False);
- for ( i=1; i<=n; i++) {
- parray->AddBound(m);
- for ( j=1; j<=m; j++) {
- parray->AddVertex(surface->Pole(i,j));
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
- return;
- }
-#endif
- TColgp_Array2OfPnt A(1,n,1,m);
- surface->Poles(A);
- Graphic3d_Array2OfVertex V(1,n,1,m);
- Standard_Real x,y,z;
- for ( i=1; i<=n; i++) {
- for ( j=1; j<=m; j++) {
- A(i,j).Coord(x,y,z);
- V(i,j).SetCoord(x,y,z);
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
- }
- else if (aSurface.GetType() == GeomAbs_BSplineSurface) {
- Handle(Geom_BSplineSurface) surface = aSurface.BSpline();
-#ifdef G005
- if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
- Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
- new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
- Standard_False,Standard_False,Standard_False,Standard_False);
- for ( i=1; i<=n; i++) {
- parray->AddBound(m);
- for ( j=1; j<=m; j++) {
- parray->AddVertex(surface->Pole(i,j));
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
- return;
- }
-#endif
- TColgp_Array2OfPnt A(1,n,1,m);
- surface->Poles(A);
- Graphic3d_Array2OfVertex V(1,n,1,m);
- Standard_Real x,y,z;
- for ( i=1; i<=n; i++) {
- for ( j=1; j<=m; j++) {
- A(i,j).Coord(x,y,z);
- V(i,j).SetCoord(x,y,z);
- }
- }
- Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
- }
-}
--- /dev/null
+-- File: StdPrs_ShadedShape.cdl
+-- Created: 23 Sep 1993
+-- Author: Jean Louis FRENKEL
+---Copyright: Matra Datavision 1993
+
+class ShadedShape from StdPrs
+
+inherits Root from Prs3d
+ --- Purpose: unknown.
+
+uses
+
+ Presentation from Prs3d,
+ Drawer from Prs3d,
+ Shape from TopoDS,
+ Pnt2d from gp
+
+is
+
+ Add (myclass;
+ thePresentation : Presentation from Prs3d;
+ theShape : Shape from TopoDS;
+ theDrawer : Drawer from Prs3d);
+ ---Purpose: Shades <theShape>.
+
+ Add (myclass;
+ thePresentation : Presentation from Prs3d;
+ theShape : Shape from TopoDS;
+ theDrawer : Drawer from Prs3d;
+ theHasTexels : Boolean from Standard;
+ theUVOrigin : Pnt2d from gp;
+ theUVRepeat : Pnt2d from gp;
+ theUVScale : Pnt2d from gp);
+ ---Purpose: Shades <theShape> with texture coordinates.
+
+end ShadedShape;
--- /dev/null
+// File: StdPrs_ShadedShape.cxx
+// Created: 23 Sep 1993
+// Author: Jean-Louis FRENKEL
+// Copyright: OPEN CASCADE 2012
+
+#include <StdPrs_ShadedShape.hxx>
+
+#include <Bnd_Box.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepMesh_DiscretFactory.hxx>
+#include <BRepMesh_DiscretRoot.hxx>
+#include <BRepTools.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Poly_Connect.hxx>
+#include <Poly_Triangulation.hxx>
+#include <StdPrs_ToolShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TColgp_Array1OfDir.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+
+#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
+#define MAX3(X, Y, Z) (MAX2 (MAX2 (X, Y), Z))
+
+namespace
+{
+ // =======================================================================
+ // function : GetDeflection
+ // purpose :
+ // =======================================================================
+ static Standard_Real GetDeflection (const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer)
+ {
+ Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
+ if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
+ {
+ Bnd_Box aBndBox;
+ BRepBndLib::Add (theShape, aBndBox, Standard_False);
+ if (!aBndBox.IsVoid())
+ {
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+ aDeflection = MAX3 (aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theDrawer->DeviationCoefficient() * 4.0;
+ }
+ }
+ return aDeflection;
+ }
+
+ // =======================================================================
+ // function : ShadeFromShape
+ // purpose :
+ // =======================================================================
+ static Standard_Boolean ShadeFromShape (const TopoDS_Shape& theShape,
+ const Handle (Prs3d_Presentation)& thePresentation,
+ const Handle (Prs3d_Drawer)& theDrawer,
+ const Standard_Boolean theHasTexels,
+ const gp_Pnt2d& theUVOrigin,
+ const gp_Pnt2d& theUVRepeat,
+ const gp_Pnt2d& theUVScale)
+ {
+ StdPrs_ToolShadedShape SST;
+ Handle(Poly_Triangulation) T;
+ TopLoc_Location aLoc;
+ gp_Pnt p;
+ Standard_Integer decal;
+ Standard_Integer t[3], n[3];
+ Standard_Integer nbTriangles = 0, nbVertices = 0;
+ Standard_Real aUmin (0.0), aUmax (0.0), aVmin (0.0), aVmax (0.0), dUmax (0.0), dVmax (0.0);
+
+ // precision for compare square distances
+ const double aPreci = Precision::Confusion() * Precision::Confusion();
+
+ if (!theDrawer->ShadingAspectGlobal())
+ {
+ Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+ if (StdPrs_ToolShadedShape::IsClosed (theShape))
+ {
+ anAsp->SuppressBackFace();
+ }
+ else
+ {
+ anAsp->AllowBackFace();
+ }
+ Prs3d_Root::CurrentGroup (thePresentation)->SetGroupPrimitivesAspect (anAsp);
+ }
+
+ for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
+ {
+ const TopoDS_Face& aFace = SST.CurrentFace();
+ T = SST.Triangulation (aFace, aLoc);
+ if (!T.IsNull())
+ {
+ nbTriangles += T->NbTriangles();
+ nbVertices += T->NbNodes();
+ }
+ }
+
+ if (nbVertices > 2 && nbTriangles > 0)
+ {
+ Handle(Graphic3d_ArrayOfTriangles) aPArray
+ = new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
+ Standard_True, Standard_False, theHasTexels, Standard_True);
+ for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
+ {
+ const TopoDS_Face& aFace = SST.CurrentFace();
+ T = SST.Triangulation (aFace, aLoc);
+ if (T.IsNull())
+ {
+ continue;
+ }
+ const gp_Trsf& aTrsf = aLoc.Transformation();
+ Poly_Connect pc (T);
+ // Extracts vertices & normals from nodes
+ const TColgp_Array1OfPnt& aNodes = T->Nodes();
+ const TColgp_Array1OfPnt2d& aUVNodes = T->UVNodes();
+ TColgp_Array1OfDir aNormals (aNodes.Lower(), aNodes.Upper());
+ SST.Normal (aFace, pc, aNormals);
+
+ if (theHasTexels)
+ {
+ BRepTools::UVBounds (aFace, aUmin, aUmax, aVmin, aVmax);
+ dUmax = (aUmax - aUmin);
+ dVmax = (aVmax - aVmin);
+ }
+
+ decal = aPArray->VertexNumber();
+ for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ {
+ p = aNodes (aNodeIter);
+ if (!aLoc.IsIdentity())
+ {
+ p.Transform (aTrsf);
+ aNormals (aNodeIter).Transform (aTrsf);
+ }
+
+ if (theHasTexels && aUVNodes.Upper() == aNodes.Upper())
+ {
+ const gp_Pnt2d aTexel = gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
+ (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
+ aPArray->AddVertex (p, aNormals (aNodeIter), aTexel);
+ }
+ else
+ {
+ aPArray->AddVertex (p, aNormals (aNodeIter));
+ }
+ }
+
+ // Fill parray with vertex and edge visibillity info
+ const Poly_Array1OfTriangle& aTriangles = T->Triangles();
+ for (Standard_Integer aTriIter = 1; aTriIter <= T->NbTriangles(); ++aTriIter)
+ {
+ pc.Triangles (aTriIter, t[0], t[1], t[2]);
+ if (SST.Orientation (aFace) == TopAbs_REVERSED)
+ aTriangles (aTriIter).Get (n[0], n[2], n[1]);
+ else
+ aTriangles (aTriIter).Get (n[0], n[1], n[2]);
+
+ gp_Pnt P1 = aNodes (n[0]);
+ gp_Pnt P2 = aNodes (n[1]);
+ gp_Pnt P3 = aNodes (n[2]);
+
+ gp_Vec V1 (P1, P2);
+ if (V1.SquareMagnitude() <= aPreci)
+ {
+ continue;
+ }
+ gp_Vec V2 (P2, P3);
+ if (V2.SquareMagnitude() <= aPreci)
+ {
+ continue;
+ }
+ gp_Vec V3 (P3, P1);
+ if (V3.SquareMagnitude() <= aPreci)
+ {
+ continue;
+ }
+ V1.Normalize();
+ V2.Normalize();
+ V1.Cross (V2);
+ if (V1.SquareMagnitude() > aPreci)
+ {
+ aPArray->AddEdge (n[0] + decal, t[0] == 0);
+ aPArray->AddEdge (n[1] + decal, t[1] == 0);
+ aPArray->AddEdge (n[2] + decal, t[2] == 0);
+ }
+ }
+ }
+ Prs3d_Root::CurrentGroup (thePresentation)->BeginPrimitives();
+ Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPArray);
+ Prs3d_Root::CurrentGroup (thePresentation)->EndPrimitives();
+ }
+ return Standard_True;
+ }
+};
+
+// =======================================================================
+// function : Add
+// purpose :
+// =======================================================================
+void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
+ const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer)
+{
+ gp_Pnt2d aDummy;
+ StdPrs_ShadedShape::Add (thePresentation, theShape, theDrawer,
+ Standard_False, aDummy, aDummy, aDummy);
+}
+
+// =======================================================================
+// function : Add
+// purpose :
+// =======================================================================
+void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
+ const TopoDS_Shape& theShape,
+ const Handle (Prs3d_Drawer)& theDrawer,
+ const Standard_Boolean theHasTexels,
+ const gp_Pnt2d& theUVOrigin,
+ const gp_Pnt2d& theUVRepeat,
+ const gp_Pnt2d& theUVScale)
+{
+ if (theShape.IsNull())
+ {
+ return;
+ }
+
+ if (theShape.ShapeType() == TopAbs_COMPOUND)
+ {
+ TopExp_Explorer ex;
+ ex.Init (theShape, TopAbs_FACE);
+ if (ex.More())
+ {
+ TopoDS_Compound CO;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound (CO);
+ Standard_Boolean hasElement = Standard_False;
+
+ // il faut presenter les edges isoles.
+ for (ex.Init (theShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next())
+ {
+ hasElement = Standard_True;
+ aBuilder.Add (CO, ex.Current());
+ }
+ // il faut presenter les vertex isoles.
+ for (ex.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next())
+ {
+ hasElement = Standard_True;
+ aBuilder.Add (CO, ex.Current());
+ }
+ if (hasElement)
+ {
+ StdPrs_WFShape::Add (thePresentation, CO, theDrawer);
+ }
+ }
+ else
+ {
+ StdPrs_WFShape::Add (thePresentation, theShape, theDrawer);
+ }
+ }
+ Standard_Real aDeflection = GetDeflection (theShape, theDrawer);
+
+ // Check if it is possible to avoid unnecessary recomputation
+ // of shape triangulation
+ if (!BRepTools::Triangulation (theShape, aDeflection))
+ {
+ BRepTools::Clean (theShape);
+
+ // retrieve meshing tool from Factory
+ Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
+ aDeflection,
+ theDrawer->HLRAngle());
+ if (!aMeshAlgo.IsNull())
+ aMeshAlgo->Perform();
+ }
+
+ ShadeFromShape (theShape, thePresentation, theDrawer,
+ theHasTexels, theUVOrigin, theUVRepeat, theUVScale);
+}
+
#include <StdPrs_ShadedSurface.ixx>
+#include <Graphic3d_ArrayOfTriangleStrips.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Graphic3d_VertexN.hxx>
-#include <Graphic3d_Array1OfVertexN.hxx>
+#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
-#include <gp_Pnt.hxx>
-#ifdef G005
-#include <Graphic3d_ArrayOfTriangleStrips.hxx>
-#endif
//=======================================================================
//function : Add
-//purpose :
+//purpose :
//=======================================================================
-void StdPrs_ShadedSurface::Add(const Handle(Prs3d_Presentation)& aPresentation,
- const Adaptor3d_Surface& aSurface,
- const Handle(Prs3d_Drawer)& aDrawer)
+void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs,
+ const Adaptor3d_Surface& theSurface,
+ const Handle(Prs3d_Drawer)& theDrawer)
{
- Standard_Integer N1 = aDrawer->UIsoAspect()->Number();
- Standard_Integer N2 = aDrawer->VIsoAspect()->Number();
-
+ Standard_Integer N1 = theDrawer->UIsoAspect()->Number();
+ Standard_Integer N2 = theDrawer->VIsoAspect()->Number();
N1 = N1 < 3 ? 3 : N1;
N2 = N2 < 3 ? 3 : N2;
-
- if ( ! aDrawer->ShadingAspectGlobal() ) {
-// If the surface is closed, the faces from back-side are not traced:
-
- Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
-
- if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
- Asp->SuppressBackFace();
- } else {
- Asp->AllowBackFace();
+ if (!theDrawer->ShadingAspectGlobal())
+ {
+ // If the surface is closed, the faces from back-side are not traced:
+ Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+ if (theSurface.IsUClosed() && theSurface.IsVClosed())
+ {
+ anAsp->SuppressBackFace();
+ }
+ else
+ {
+ anAsp->AllowBackFace();
}
- Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
+ Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (anAsp);
}
- Standard_Integer NBUintv = aSurface.NbUIntervals(GeomAbs_C1);
- Standard_Integer NBVintv = aSurface.NbVIntervals(GeomAbs_C1);
- TColStd_Array1OfReal InterU(1, NBUintv+1);
- TColStd_Array1OfReal InterV(1, NBVintv+1);
-
- aSurface.UIntervals(InterU, GeomAbs_C1);
- aSurface.VIntervals(InterV, GeomAbs_C1);
-
- Standard_Real U1, U2, V1, V2, DU, DV;
-
- Standard_Integer i,j;
-
- gp_Pnt P1,P2;
- gp_Vec D1U,D1V,D1,D2;
-
-#ifdef G005
- if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
- Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
- for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
- for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
- U1 = InterU(NU); U2 = InterU(NU+1);
- V1 = InterV(NV); V2 = InterV(NV+1);
-
- U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
- U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
-
- V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
- V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
-
- DU = (U2-U1)/ N1;
- DV = (V2-V1)/ N2;
-
- Handle(Graphic3d_ArrayOfTriangleStrips) parray = new
- Graphic3d_ArrayOfTriangleStrips(2*(N1+1)*(N2+1),N1+1,
- Standard_True,Standard_False,Standard_False,Standard_False);
- for ( i = 1; i<= N1+1; i++) {
- parray->AddBound(N2+1);
- for (j = 1; j <= N2+1; j++) {
- aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),P2,D1U,D1V);
- D1 = D1U^D1V;
- D1.Normalize();
- aSurface.D1(U1 + DU * i, V1 + DV * (j-1),P2,D1U,D1V);
- D2 = D1U^D1V;
- D2.Normalize();
- parray->AddVertex(P1,D1);
- parray->AddVertex(P2,D2);
- }
+ Standard_Integer aNBUintv = theSurface.NbUIntervals (GeomAbs_C1);
+ Standard_Integer aNBVintv = theSurface.NbVIntervals (GeomAbs_C1);
+ TColStd_Array1OfReal anInterU (1, aNBUintv + 1);
+ TColStd_Array1OfReal anInterV (1, aNBVintv + 1);
+
+ theSurface.UIntervals (anInterU, GeomAbs_C1);
+ theSurface.VIntervals (anInterV, GeomAbs_C1);
+
+ Standard_Real U1, U2, V1, V2, DU, DV;
+
+ gp_Pnt P1, P2;
+ gp_Vec D1U, D1V, D1, D2;
+
+ Prs3d_Root::CurrentGroup (thePrs)->BeginPrimitives();
+ for (Standard_Integer NU = 1; NU <= aNBUintv; ++NU)
+ {
+ for (Standard_Integer NV = 1; NV <= aNBVintv; ++NV)
+ {
+ U1 = anInterU (NU); U2 = anInterU (NU + 1);
+ V1 = anInterV (NV); V2 = anInterV (NV + 1);
+
+ U1 = (Precision::IsNegativeInfinite (U1)) ? - theDrawer->MaximalParameterValue() : U1;
+ U2 = (Precision::IsPositiveInfinite (U2)) ? theDrawer->MaximalParameterValue() : U2;
+
+ V1 = (Precision::IsNegativeInfinite (V1)) ? - theDrawer->MaximalParameterValue() : V1;
+ V2 = (Precision::IsPositiveInfinite (V2)) ? theDrawer->MaximalParameterValue() : V2;
+
+ DU = (U2 - U1) / N1;
+ DV = (V2 - V1) / N2;
+
+ Handle(Graphic3d_ArrayOfTriangleStrips) aPArray
+ = new Graphic3d_ArrayOfTriangleStrips (2 * (N1 + 1) * (N2 + 1), N1 + 1,
+ Standard_True, Standard_False, Standard_False, Standard_False);
+ for (Standard_Integer i = 1; i <= N1 + 1; ++i)
+ {
+ aPArray->AddBound (N2 + 1);
+ for (Standard_Integer j = 1; j <= N2 + 1; ++j)
+ {
+ theSurface.D1 (U1 + DU * (i - 1), V1 + DV * (j - 1), P2, D1U, D1V);
+ D1 = D1U ^ D1V;
+ D1.Normalize();
+ theSurface.D1 (U1 + DU * i, V1 + DV * (j - 1), P2, D1U, D1V);
+ D2 = D1U ^ D1V;
+ D2.Normalize();
+ aPArray->AddVertex (P1, D1);
+ aPArray->AddVertex (P2, D2);
}
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
- }
- Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
- }
- return;
- }
-#endif
- gp_Pnt P;
- gp_Vec Normale;
- Quantity_Length x,y,z;
- Graphic3d_Array1OfVertexN A1 ( 1 , N2+1);
- Graphic3d_Array1OfVertexN A2 ( 1 , N2+1);
- Graphic3d_Array1OfVertexN TriangleStrip ( 1, 2*(N2+1));
-
- Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
- for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
- for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
- U1 = InterU(NU); U2 = InterU(NU+1);
- V1 = InterV(NV); V2 = InterV(NV+1);
-
- U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
- U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
-
- V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
- V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
-
- DU = (U2-U1)/ N1;
- DV = (V2-V1)/ N2;
-
- // Calculation of the first line;
-
- for ( i = 1; i<= N2+1; i++) {
- aSurface.D1(U1 , V1 + DV * (i-1),P,D1U,D1V);
- P.Coord(x,y,z);
- A1(i).SetCoord (x,y,z);
- Normale = D1U^D1V;
- Normale.Normalize();
- Normale.Coord(x,y,z);
- A1(i).SetNormal(x,y,z);
- }
-
- for ( i = 2; i<= N1+1; i++) {
- for (j = 1; j <= N2+1; j++) {
- aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),
- P,D1U,D1V);
-
- P.Coord(x,y,z);
- A2(j).SetCoord (x,y,z);
- Normale = D1U^D1V;
- Normale.Normalize();
- Normale.Coord(x,y,z);
- A2(j).SetNormal(x,y,z);
- TriangleStrip (2*(j-1) + 1) = A1(j);
- TriangleStrip (2*(j-1) + 2) = A2(j);
- }
- Prs3d_Root::CurrentGroup(aPresentation)->TriangleMesh(TriangleStrip);
- for ( j = 1; j <= N2 + 1; j++) { A1(j) = A2(j);}
-
}
+ Prs3d_Root::CurrentGroup (thePrs)->AddPrimitiveArray (aPArray);
}
+ Prs3d_Root::CurrentGroup (thePrs)->EndPrimitives();
}
- Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
}
#include <windows.h>
#endif
+#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_ExportFormat.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_EventManager.hxx>
return 0;
}
+//==============================================================================
+//function : VGrid
+//purpose :
+//==============================================================================
+
+static int VGrid (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ // get the active view
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
+ if (aView.IsNull() || aViewer.IsNull())
+ {
+ std::cerr << "No active view. Please call vinit.\n";
+ return 1;
+ }
+
+ Aspect_GridType aType = aViewer->GridType();
+ Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
+
+ Standard_Integer anIter = 1;
+ for (; anIter < theArgNb; ++anIter)
+ {
+ const char* aValue = theArgVec[anIter];
+ if (*aValue == 'r')
+ {
+ aType = Aspect_GT_Rectangular;
+ }
+ else if (*aValue == 'c')
+ {
+ aType = Aspect_GT_Circular;
+ }
+ else if (*aValue == 'l')
+ {
+ aMode = Aspect_GDM_Lines;
+ }
+ else if (*aValue == 'p')
+ {
+ aMode = Aspect_GDM_Points;
+ }
+ else if (strcmp (aValue, "off" ) == 0)
+ {
+ aViewer->DeactivateGrid();
+ return 0;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ Standard_Integer aTail = (theArgNb - anIter);
+ if (aTail == 0)
+ {
+ aViewer->ActivateGrid (aType, aMode);
+ return 0;
+ }
+ else if (aTail != 2 && aTail != 5)
+ {
+ std::cerr << "Incorrect arguments number! Usage:\n"
+ << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
+ return 1;
+ }
+
+ Quantity_Length anOriginX, anOriginY;
+ Quantity_PlaneAngle aRotAngle;
+ if (aType == Aspect_GT_Rectangular)
+ {
+ Quantity_Length aRStepX, aRStepY;
+ aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
+
+ anOriginX = atof (theArgVec[anIter++]);
+ anOriginY = atof (theArgVec[anIter++]);
+ if (aTail == 5)
+ {
+ aRStepX = atof (theArgVec[anIter++]);
+ aRStepY = atof (theArgVec[anIter++]);
+ aRotAngle = atof (theArgVec[anIter++]);
+ }
+ aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
+ aViewer->ActivateGrid (aType, aMode);
+ }
+ else if (aType == Aspect_GT_Circular)
+ {
+ Quantity_Length aRadiusStep;
+ Standard_Integer aDivisionNumber;
+ aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
+
+ anOriginX = atof (theArgVec[anIter++]);
+ anOriginY = atof (theArgVec[anIter++]);
+ if (aTail == 5)
+ {
+ aRadiusStep = atof (theArgVec[anIter++]);
+ aDivisionNumber = atof (theArgVec[anIter++]);
+ aRotAngle = atof (theArgVec[anIter++]);
+ }
+
+ aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
+ aViewer->ActivateGrid (aType, aMode);
+ }
+
+ return 0;
+}
+
//=======================================================================
//function : ViewerCommands
//purpose :
theCommands.Add("vlayerline",
"vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
__FILE__,VLayerLine,group);
+ theCommands.Add ("vgrid",
+ "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
+ " : Mode - rectangular or circular"
+ " : Type - lines or points",
+ __FILE__, VGrid, group);
}