#include <Draw_Appli.hxx>
#include <DBRep.hxx>
-
+#include <OSD_Chronometer.hxx>
#include <TCollection_AsciiString.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
//==============================================================================
//function : Vtrihedron 2d
//purpose : Create a plane with a 2D trihedron from a faceselection
-//Draw arg : vtri2d name
+//Draw arg : vtri2d name
//==============================================================================
#include <AIS_PlaneTrihedron.hxx>
// Declarations
Standard_Integer myCurrentIndex;
- // Fermeture des contextes
+ // Fermeture des contextes
TheAISContext()->CloseAllContexts();
// Ouverture d'un contexte local et recuperation de son index.
TheAISContext()->OpenLocalContext();
TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
- // declarations
+ // declarations
gp_Pnt A,B,C;
// si il y a plusieurs edges
TheAISContext()->Display(theAISPlaneTri );
GetMapOfAIS().Bind ( theAISPlaneTri ,argv[1]);
- return 0;
+ return 0;
}
GetMapOfAIS().Bind(aShape,name);
TheAISContext()->Display(aShape);
- return 0;
+ return 0;
}
Standard_Boolean ThereIsName;
Standard_Boolean ThereIsCurrent;
Standard_Real value;
- Standard_Boolean hascol;
+ Standard_Boolean hascol;
#ifdef DEB
Quantity_NameOfColor col;
#else
else {ThereIsName=Standard_True;value=atof(argv[2]);}
// On ferme le contexte local pour travailler dans le contexte global
- if(TheAISContext()->HasOpenedContext())
+ if(TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext();
// On set le booleen ThereIsCurrent
//===============================================================
// Il n'y a pas de nom mais des objets selectionnes
//===============================================================
- if (!ThereIsName && ThereIsCurrent)
+ if (!ThereIsName && ThereIsCurrent)
{
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
if (!aShape.IsNull() && TheAISContext()->IsCurrent(aShape) )
{
- // On verifie que l'AIS InteraciveObject selectionne est bien
+ // On verifie que l'AIS InteraciveObject selectionne est bien
// un AIS_Trihedron
if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3) {
Handle(AIS_InteractiveObject) aShape =
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
- // On verifie que l'AIS InteraciveObject est bien
+ // On verifie que l'AIS InteraciveObject est bien
// un AIS_Trihedron
if (!aShape.IsNull() &&
aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3)
}
}
}
- return 0;
+ return 0;
}
//==============================================================================
//function : VPlaneTrihedron
//purpose : Create a plane from a trihedron selection. If no arguments are set, the default
-//Draw arg : vplanetri name
+//Draw arg : vplanetri name
//==============================================================================
#include <AIS_Plane.hxx>
// Fermeture des contextes locaux
TheAISContext()->CloseAllContexts();
- // On recupere tous les trihedrons de la GetMapOfAIS()
+ // On recupere tous les trihedrons de la GetMapOfAIS()
// et on active le mode de selection par face.
// =================================================
TheAISContext()->Display(PlaneB );
GetMapOfAIS().Bind ( PlaneB ,argv[1]);
- return 0;
+ return 0;
}
//==============================================================================
// Fonction First click 2de click
-//
+//
// vaxis vertex vertex
// edge None
// vaxispara edge vertex
//==============================================================================
//function : VAxisBuilder
-//purpose :
+//purpose :
//Draw arg : vaxis AxisName Xa Ya Za Xb Yb Zb
//==============================================================================
#include <TopoDS_Edge.hxx>
#include <TopExp.hxx>
#include <Geom_Line.hxx>
-static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
Standard_Boolean HasArg;
const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvv = (const char **) buff;
while (ViewerMainLoop( argcc, argvv) ) { }
- // fin de la boucle
+ // fin de la boucle
// recuperation de la shape.
TopoDS_Shape ShapeA;
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
ShapeB = TheAISContext()->SelectedShape();
}
// Fermeture du context local
TheAISContext()->CloseLocalContext(MyCurrentIndex);
- // Construction de l'axe
+ // Construction de l'axe
gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
gp_Vec V (A,B);
Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
GetMapOfAIS().Bind (TheAxis,name);
TheAISContext()->Display(TheAxis);
- }
+ }
else {
// Un unique edge (ShapeA) a ete picke
// Fermeture du context local
TheAISContext()->CloseLocalContext(MyCurrentIndex);
- // Constuction de l'axe
+ // Constuction de l'axe
TopoDS_Edge ed =TopoDS::Edge(ShapeA);
TopoDS_Vertex Va,Vb;
TopExp::Vertices(ed,Va,Vb );
TheAISContext()->OpenLocalContext();
MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
- // Active le mode edge
+ // Active le mode edge
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
di<<" Select an edge."<<"\n";
const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvv = (const char **) buff;
while (ViewerMainLoop( argcc, argvv) ) { }
- // fin de la boucle
+ // fin de la boucle
TopoDS_Shape ShapeA;
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
// On peut choisir un pnt sur l'edge
TopoDS_Shape ShapeB;
TheAISContext()->OpenLocalContext();
MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
- // Active le mode edge
+ // Active le mode edge
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
di<<" Select an edge."<<"\n";
const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvv = (const char **) buff;
while (ViewerMainLoop( argcc, argvv) ) { }
- // fin de la boucle
+ // fin de la boucle
TopoDS_Shape ShapeA;
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
// On peut choisir un pnt sur l'edge
TopoDS_Shape ShapeB;
//==============================================================================
// Fonction First click Result
-//
+//
// vpoint vertex AIS_Point=Vertex
// edge AIS_Point=Middle of the edge
//==============================================================================
#include <AIS_Point.hxx>
#include <Geom_CartesianPoint.hxx>
-static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
Standard_Boolean HasArg;
}
//==============================================================================
-// Fonction 1st click 2de click 3de click
+// Fonction 1st click 2de click 3de click
// vplane Vertex Vertex Vertex
// Vertex Edge
// Edge Vertex
#include <gp_Pln.hxx>
#include <GC_MakePlane.hxx>
-static int VPlaneBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VPlaneBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
Standard_Boolean HasArg;
return 1;
}
- // Traitement des objets A,B,C
+ // Traitement des objets A,B,C
// Downcaste de AIS_IO en AIS_Point
Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
TheAISContext()->Display(myAISPlane);
}
- // si le premier argument est un AIS_Axis 2
+ // si le premier argument est un AIS_Axis 2
// creation d'un plan orthogonal a l'axe passant par un point
else if (theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==2 ) {
// le deuxieme argument doit etre un AIS_Point
return 1;
}
- // Traitement des objets A et B
+ // Traitement des objets A et B
Handle(AIS_Axis) theAISAxisA= *(Handle(AIS_Axis)*)& theShapeA;
Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
return 1;
}
- // Traitement des objets A et B
+ // Traitement des objets A et B
Handle(AIS_Plane) theAISPlaneA= *(Handle(AIS_Plane)*)& theShapeA;
Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
// ShapeC est aussi un vertex...
if (ShapeC.IsSame(ShapeA)||ShapeC.IsSame(ShapeB) ) {di<<" vplane: error, same points selected"<<"\n";return 1; }
- // Fermeture du contexte local
+ // Fermeture du contexte local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) );
gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) );
gp_Pnt C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeC ) );
}
else {
// le vertex n'appartient pes a l'edge on peut construire le plane
- // Fermeture du contexte local
+ // Fermeture du contexte local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
gp_Pnt A=BRep_Tool::Pnt(VertA );
TopoDS_Vertex VBa,VBb;
TopExp::Vertices(EdgeB ,VBa ,VBb );
}
else {
// le vertex n'appartient pas a l'edge on peut construire le plane
- // Fermeture du contexte local
+ // Fermeture du contexte local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
gp_Pnt B=BRep_Tool::Pnt(VertB );
TopoDS_Vertex VAa,VAb;
TopExp::Vertices(EdgeA ,VAa ,VAb );
else {
// Fermeture du contexte local: Plus rien a selectionner
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
TopoDS_Face myFace=TopoDS::Face(ShapeA);
BRepAdaptor_Surface mySurface (myFace, Standard_False );
if (mySurface.GetType()==GeomAbs_Plane ) {
TheAISContext()->OpenLocalContext();
myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
- // Active les modes Vertex et Face
+ // Active les modes Vertex et Face
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
di<<" Select a vertex or a face."<<"\n";
// Fermeture du context local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) );
TopoDS_Face myFace=TopoDS::Face(ShapeB);
// Fermeture du context local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) );
TopoDS_Face myFace=TopoDS::Face(ShapeA);
TheAISContext()->OpenLocalContext();
myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
- // Active les modes Edge et Face
+ // Active les modes Edge et Face
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
di<<" Select a face and an edge coplanar."<<"\n";
// Fermeture du context local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
TopoDS_Vertex VAa,VAb;
// vi
gp_Vec ab (Aa,Ab);
gp_Dir Dab (ab);
- // Creation de mon axe de rotation
- gp_Ax1 myRotAxis (Aa,Dab);
+ // Creation de mon axe de rotation
+ gp_Ax1 myRotAxis (Aa,Dab);
TopoDS_Face myFace=TopoDS::Face(ShapeB);
// Il faut imperativement que l'edge soit parallele a la face
BRepExtrema_ExtPF myHauteurB (VAb , myFace );
// on compare les deux hauteurs a la tolerance pres
if ( fabs(sqrt(myHauteurA.SquareDistance(1)) - sqrt (myHauteurB.SquareDistance(1)) )>0.1 ) {
- // l'edge n'est pas parallele a la face
+ // l'edge n'est pas parallele a la face
di<<" vplaneOrtho error: l'edge n'est pas parallele a la face."<<"\n";return 1;
}
// l'edge est OK
// Fermeture du context local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du plane
+ // Construction du plane
TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
TopoDS_Vertex VBa,VBb;
TopExp::Vertices(EdgeB ,VBa ,VBb );
gp_Pnt Bb=BRep_Tool::Pnt(VBb);
gp_Vec ab (Ba,Bb);
gp_Dir Dab (ab);
- // Creation de mon axe de rotation
- gp_Ax1 myRotAxis (Ba,Dab);
+ // Creation de mon axe de rotation
+ gp_Ax1 myRotAxis (Ba,Dab);
TopoDS_Face myFace=TopoDS::Face(ShapeA);
// Il faut imperativement que l'edge soit parallele a la face
BRepExtrema_ExtPF myHauteurB (VBb , myFace );
// on compare les deux hauteurs a la tolerance pres
if ( fabs(sqrt(myHauteurA.SquareDistance(1)) - sqrt(myHauteurB.SquareDistance(1)) )>0.1 ) {
- // l'edge n'est pas parallele a la face
+ // l'edge n'est pas parallele a la face
di<<" vplaneOrtho error: l'edge n'est pas parallele a la face."<<"\n";return 1;
}
// l'edge est OK
//==============================================================================
//function : VLineBuilder
-//purpose : Build an AIS_Line
+//purpose : Build an AIS_Line
//Draw arg : vline LineName [AIS_PointName] [AIS_PointName]
// [Xa] [Ya] [Za] [Xb] [Yb] [Zb]
//==============================================================================
#include <AIS_Line.hxx>
-static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
Standard_Integer myCurrentIndex;
// Verifications
return 1;
}
}
- else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
+ else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
// Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
// ==================
else if (argc==8) {
- // On verifie que les deux points ne sont pas confondus
+ // On verifie que les deux points ne sont pas confondus
Standard_Real coord[6];
for(Standard_Integer i=0;i<=2;i++){
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
ShapeB = TheAISContext()->SelectedShape();
//==============================================================================
//function : VCircleBuilder
-//purpose : Build an AIS_Circle
+//purpose : Build an AIS_Circle
//Draw arg : vcircle CircleName PlaneName PointName Radius
// PointName PointName PointName
//==============================================================================
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
-static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
Standard_Integer myCurrentIndex;
// verification of the arguments
{
if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) {
di<<"vcircle error: 2de argument is unexpected to be a point."<<"\n";
- return 1;
+ return 1;
}
// Le troisieme objet doit etre un point
Handle(AIS_InteractiveObject) theShapeC =
if (theShapeC.IsNull() ||
theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 ) {
di<<"vcircle error: 3de argument is unexpected to be a point."<<"\n";
- return 1;
+ return 1;
}
// tag
// On verifie que les 3 points sont differents.
// Test A=B
if (myCartPointA->X()==myCartPointB->X() && myCartPointA->Y()==myCartPointB->Y() && myCartPointA->Z()==myCartPointB->Z() ) {
- di<<"vcircle error: Same points."<<"\n";return 1;
+ di<<"vcircle error: Same points."<<"\n";return 1;
}
// Test A=C
if (myCartPointA->X()==myCartPointC->X() && myCartPointA->Y()==myCartPointC->Y() && myCartPointA->Z()==myCartPointC->Z() ) {
- di<<"vcircle error: Same points."<<"\n";return 1;
+ di<<"vcircle error: Same points."<<"\n";return 1;
}
// Test B=C
if (myCartPointB->X()==myCartPointC->X() && myCartPointB->Y()==myCartPointC->Y() && myCartPointB->Z()==myCartPointC->Z() ) {
- di<<"vcircle error: Same points."<<"\n";return 1;
+ di<<"vcircle error: Same points."<<"\n";return 1;
}
// Construction du cercle
GC_MakeCircle Cir=GC_MakeCircle (myCartPointA->Pnt(),myCartPointB->Pnt(),myCartPointC->Pnt() );
// ===================================
else if (theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==7 ) {
if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) {
- di<<"vcircle error: 2de element is a unexpected to be a point."<<"\n";return 1;
+ di<<"vcircle error: 2de element is a unexpected to be a point."<<"\n";return 1;
}
// On verifie que le rayon est bien >=0
if (atof(argv[4])<=0 ) {di<<"vcircle error: the radius must be >=0."<<"\n";return 1; }
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
ShapeB = TheAISContext()->SelectedShape();
const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvvv = (const char **) buffff;
while (ViewerMainLoop( argcccc, argvvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
ShapeC = TheAISContext()->SelectedShape();
// Fermeture du context local
TheAISContext()->CloseLocalContext(myCurrentIndex);
- // Construction du cercle
+ // Construction du cercle
gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
gp_Pnt C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeC) );
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
const char **argvvv = (const char **) bufff;
while (ViewerMainLoop( argccc, argvvv) ) { }
- // fin de la boucle
+ // fin de la boucle
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
ShapeB = TheAISContext()->SelectedShape();
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic2d_GraphicObject.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <gp_Pnt.hxx>
#include <Quantity_NameOfColor.hxx>
-#include <Quantity_Color.hxx>
+#include <Quantity_Color.hxx>
DEFINE_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
MyTextClass(){};
- MyTextClass
+ MyTextClass
(
const TCollection_ExtendedString& , const gp_Pnt& ,
- Quantity_Color color,
- Standard_Integer aHJust,
+ Quantity_Color color,
+ Standard_Integer aHJust,
Standard_Integer aVJust ,
- Standard_Real Angle ,
- Standard_Boolean Zoom ,
- Standard_Real Height,
+ Standard_Real Angle ,
+ Standard_Boolean Zoom ,
+ Standard_Real Height,
OSD_FontAspect FontAspect,
Standard_CString Font
);
const Standard_Integer aMode);
void ComputeSelection ( const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer aMode){} ;
+ const Standard_Integer aMode){} ;
protected:
TCollection_ExtendedString aText;
Standard_Real Green;
Standard_Real Blue;
Standard_Real aAngle;
- Standard_Real aHeight;
+ Standard_Real aHeight;
Standard_Boolean aZoomable;
Quantity_Color aColor;
- Standard_CString aFont;
+ Standard_CString aFont;
OSD_FontAspect aFontAspect;
Graphic3d_HorizontalTextAlignment aHJustification;
Graphic3d_VerticalTextAlignment aVJustification;
IMPLEMENT_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
-MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
- Quantity_Color color = Quantity_NOC_YELLOW,
- Standard_Integer aHJust = Graphic3d_HTA_LEFT,
+MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
+ Quantity_Color color = Quantity_NOC_YELLOW,
+ Standard_Integer aHJust = Graphic3d_HTA_LEFT,
Standard_Integer aVJust = Graphic3d_VTA_BOTTOM,
Standard_Real angle = 0.0 ,
Standard_Boolean zoomable = Standard_True,
Standard_CString font = "Courier")
{
aText = text;
- aPosition = position;
+ aPosition = position;
aHJustification = Graphic3d_HorizontalTextAlignment(aHJust);
aVJustification = Graphic3d_VerticalTextAlignment(aVJust);
aAngle = angle;
- aZoomable = zoomable;
- aHeight = height;
+ aZoomable = zoomable;
+ aHeight = height;
aColor = color;
aFontAspect = fontAspect;
aFont = font;
asp->SetHeight(aHeight); // I am changing the myHeight value
asp->SetHorizontalJustification(aHJustification);
- asp->SetVerticalJustification(aVJustification);
+ asp->SetVerticalJustification(aVJustification);
asp->Aspect()->SetTextZoomable(aZoomable);
asp->Aspect()->SetTextAngle(aAngle);
asp->Aspect()->SetTextFontAspect(aFontAspect);
Prs3d_Text::Draw(aPresentation, asp, aText, aPosition);
-
+
/* This comment code is worked
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
G = atof(argv[6])/255.;
B = atof(argv[7])/255.;
- hor_align = atoi(argv[8]);
+ hor_align = atoi(argv[8]);
ver_align = atoi(argv[9]);
angle = atof(argv[10]);
if(argc == 16)
{
font.AssignCat(argv[14]);
- font.AssignCat(" ");
- font.AssignCat(argv[15]);
+ font.AssignCat(" ");
+ font.AssignCat(argv[15]);
}
- if(argc == 17)
- {
+ if(argc == 17)
+ {
font.AssignCat(argv[14]);
- font.AssignCat(" ");
+ font.AssignCat(" ");
font.AssignCat(argv[15]);
- font.AssignCat(" ");
- font.AssignCat(argv[16]);
+ font.AssignCat(" ");
+ font.AssignCat(argv[16]);
}
aColor.SetValues( R, G, B, Quantity_TOC_RGB );
aContext->Display(my,Standard_True);
- if(aContext.IsNull())
- {
+ if(aContext.IsNull())
+ {
di << "use 'vinit' command before " << argv[0] << "\n";
return -1;
}
- return 0;
+ return 0;
}
#include <math.h>
//purpose : Create a Sphere
//===============================================================================================
-Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z ,
+Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z ,
int res ,
double Radius ){
double mRadius = Radius;
number_pointArray++;
numPoles++;
}
-
+
// Check data, determine increments, and convert to radians
startTheta = (localStartTheta < localEndTheta ? localStartTheta : localEndTheta);
startTheta *= Standard_PI / 180.0;
if ( mStartPhi <= 0.0 ) { // around north pole
number_triangle += localThetaResolution;
}
-
+
if ( mEndPhi >= 180.0 ) { // around south pole
number_triangle += localThetaResolution;
}
number_triangle++;
}
}
-
+
if ( mEndPhi >= 180.0 ){ // around south pole
numOffset = phiResolution - 1 + numPoles;
for (i=0; i < localThetaResolution; i++){
}
// bands in-between poles
-
+
for (i=0; i < localThetaResolution; i++){
for (j=0; j < (phiResolution-1); j++){
pts[0] = phiResolution*i + j + numPoles;
Standard_Real modmax = eqPlan.Modulus();
- if(modmax > Tol)
+ if(modmax > Tol)
Nor = gp_Dir(eqPlan);
- else
+ else
Nor = gp_Dir(0., 0., 1.);
Standard_Integer j = (i - PointsOfArray.Lower()) * 3;
//function : VDrawSphere
//author : psn
//purpose : Create an AIS shape.
-//Draw arg : vdrawsphere [X] [Y] [Z] [Rezolution] [Radius] [VBOEnabled]
//===============================================================================================
+static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ // check for errors
+ Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+ if (aContextAIS.IsNull())
+ {
+ std::cout << "Call vinit before!\n";
+ return 1;
+ }
+ else if (argc < 3)
+ {
+ std::cout << "Use: " << argv[0]
+ << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n";
+ return 1;
+ }
-#include <OSD_Chronometer.hxx>
-
-static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char** argv){
- // Verification des arguments
- if ( argc > 9 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
+ // read the arguments
+ TCollection_AsciiString aShapeName (argv[1]);
+ Standard_Integer aResolution = atoi (argv[2]);
+ Standard_Real aCenterX = (argc > 5) ? atof (argv[3]) : 0.0;
+ Standard_Real aCenterY = (argc > 5) ? atof (argv[4]) : 0.0;
+ Standard_Real aCenterZ = (argc > 5) ? atof (argv[5]) : 0.0;
+ Standard_Real aRadius = (argc > 6) ? atof (argv[6]) : 100.0;
+ Standard_Boolean isVBOEnabled = (argc > 7) ? atoi (argv[7]) : Standard_True;
+ Standard_Integer aRedrawsNb = (argc > 8) ? atoi (argv[8]) : 1;
+ Standard_Boolean toShowEdges = (argc > 9) ? atoi (argv[9]) : Standard_False;
+
+ if (aRedrawsNb <= 0)
+ {
+ aRedrawsNb = 1;
+ }
- Standard_Real X,Y,Z;
- X = atof(argv[1]);
- Y = atof(argv[2]);
- Z = atof(argv[3]);
-
- Standard_Integer Rezolution = atoi(argv[4]);
- Standard_Real Radius = atof(argv[5]);
- Standard_Integer VBOenabled = atoi(argv[6]);;
- Standard_Integer NumberOfViewerUpdate = 1;
- Standard_Integer ShowEdges = 0;
-
- if( argc == 9)
- ShowEdges = atoi(argv[8]);
- if( argc == 8)
- NumberOfViewerUpdate = atoi(argv[7]);
- if( argc == 7)
- NumberOfViewerUpdate = 1;
-
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- //ViewerTest::CurrentView()->SetTransparency(Standard_True);
-
- //enable VBO
- Handle(Graphic3d_GraphicDriver) aDriver =
- Handle(Graphic3d_GraphicDriver)::DownCast(aContext->CurrentViewer()->Device()->GraphicDriver() );
-
- aDriver->EnableVBO( VBOenabled );
-
- Standard_Integer numberTriangles = 0, numberPoints = 0;
- printf("Compute Triangulation...\n");
- Handle(AIS_Triangulation) myShape = new AIS_Triangulation(CalculationOfSphere( X, Y, Z,
- Rezolution,
- Radius));
- numberPoints = myShape->GetTriangulation()->Nodes().Length();
- numberTriangles = myShape->GetTriangulation()->Triangles().Length();
-
- Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger(1,numberPoints);
- int color = 0;
- int red = 0 ;
- int green = 255 ;
- int blue = 0 ;
- int alpha = 0 ; // not used
- color = red;
- color += green << 8;
- color += blue << 16;
- color += alpha << 24;
- for( int i = 1; i <= numberPoints ; i++ ){
- aColorArray->SetValue( i,color );
+ // remove AIS object with given name from map
+ if (GetMapOfAIS().IsBound2 (aShapeName))
+ {
+ Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aShapeName);
+ Handle(AIS_InteractiveObject) anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
+ if (anInterObj.IsNull())
+ {
+ std::cout << "Shape name was used for non AIS viewer\n!";
+ return 1;
+ }
+ aContextAIS->Remove (anInterObj, Standard_False);
+ GetMapOfAIS().UnBind2 (aShapeName);
+ }
+
+ // enable/disable VBO
+ Handle(Graphic3d_GraphicDriver) aDriver =
+ Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+ if (!aDriver.IsNull())
+ {
+ aDriver->EnableVBO (isVBOEnabled);
+ }
+
+ std::cout << "Compute Triangulation...\n";
+ Handle(AIS_Triangulation) aShape
+ = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
+ aResolution,
+ aRadius));
+ Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
+ Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
+
+ // register the object in map
+ GetMapOfAIS().Bind (aShape, aShapeName);
+
+ // stupid initialization of Green color in RGBA space as integer
+ // probably wrong for big-endian CPUs
+ Standard_Integer aRed = 0;
+ Standard_Integer aGreen = 255;
+ Standard_Integer aBlue = 0;
+ Standard_Integer anAlpha = 0; // not used
+ Standard_Integer aColorInt = aRed;
+ aColorInt += aGreen << 8;
+ aColorInt += aBlue << 16;
+ aColorInt += anAlpha << 24;
+
+ // setup colors array per vertex
+ Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger (1, aNumberPoints);
+ for (Standard_Integer aNodeId = 1; aNodeId <= aNumberPoints; ++aNodeId)
+ {
+ aColorArray->SetValue (aNodeId, aColorInt);
}
- //enable or disable color
- myShape->SetColors(aColorArray);
-
- printf("NumberOfPoints = %.i \n",numberPoints);
- printf("NumberOfTriangles = %.i \n",numberTriangles);
- int PointsSize = numberPoints * 12;
- int NormalsSize = numberPoints * 12;
- int ColorsSize = numberPoints * 12;
- int TrianglesSize = numberTriangles * 3 * 4;
- int PolyConnectSize = numberPoints * 4 + numberTriangles * 6 * 4;
- int size = PointsSize + NormalsSize + ColorsSize + TrianglesSize ;
- size>>=20;//MB
- NormalsSize >>= 20;
- ColorsSize >>= 20;
- TrianglesSize >>= 20;
- PolyConnectSize >>= 20;
- printf("Amount of memory required for PolyTriangulation without Normals: %i Mb \n", size - NormalsSize );
- printf("Amount of memory for colors: %i Mb \n",ColorsSize);
- printf("Amount of memory for PolyConnect: %i Mb \n", PolyConnectSize );
- printf("Amount of graphic card memory required: %i Mb \n",size);
+ aShape->SetColors (aColorArray);
+
+ // show statistics
+ Standard_Integer aPointsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
+ Standard_Integer aNormalsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
+ Standard_Integer aColorsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat without alpha
+ Standard_Integer aTrianglesSize = aNumberTriangles * 3 * sizeof(int); // 3x GLint
+ Standard_Integer aPolyConnectSize = aNumberPoints * 4 + aNumberTriangles * 6 * 4;
+ Standard_Integer aTotalSize = aPointsSize + aNormalsSize + aColorsSize + aTrianglesSize;
+ aTotalSize >>= 20; //MB
+ aNormalsSize >>= 20;
+ aColorsSize >>= 20;
+ aTrianglesSize >>= 20;
+ aPolyConnectSize >>= 20;
+ std::cout << "NumberOfPoints: " << aNumberPoints << "\n"
+ << "NumberOfTriangles: " << aNumberTriangles << "\n"
+ << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
+ << "Amount of memory for colors: " << aColorsSize << " Mb\n"
+ << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
+ << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
// Setting material properties, very important for desirable visual result!
- Graphic3d_MaterialAspect aMat( Graphic3d_NOM_PLASTIC );
- aMat.SetAmbient( 0.2 );
- aMat.SetSpecular( 0.5 );
- Handle(Graphic3d_AspectFillArea3d) aspect = new Graphic3d_AspectFillArea3d( Aspect_IS_SOLID,
- Quantity_NOC_RED,
- Quantity_NOC_YELLOW,
- Aspect_TOL_SOLID,
- 1.,
- aMat,
- aMat);
+ Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
+ aMat.SetAmbient (0.2);
+ aMat.SetSpecular (0.5);
+ Handle(Graphic3d_AspectFillArea3d) anAspect
+ = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
+ Quantity_NOC_RED,
+ Quantity_NOC_YELLOW,
+ Aspect_TOL_SOLID,
+ 1.0,
+ aMat,
+ aMat);
Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
-
- if( ShowEdges > 0 )
- aspect->SetEdgeOn();
+ if (toShowEdges)
+ {
+ anAspect->SetEdgeOn();
+ }
else
- aspect->SetEdgeOff();
-
- aShAsp -> SetAspect( aspect );
- //aShAsp -> SetTransparency( 0.5 );
- myShape -> Attributes() -> SetShadingAspect( aShAsp );
-
- aContext->Display(myShape,Standard_False);
+ {
+ anAspect->SetEdgeOff();
+ }
+ aShAsp->SetAspect (anAspect);
+ aShape->Attributes()->SetShadingAspect (aShAsp);
- const Handle(V3d_Viewer)& viewer = aContext->CurrentViewer();
+ aContextAIS->Display (aShape, Standard_False);
// Two viewer updates are needed in order to measure time spent on
- // loading triangulation to graphic card memory + redrawing (1st update) and
+ // loading triangulation to graphic card memory + redrawing (1st update) and
// time spent on redrawing itself (2nd and all further updates)
- OSD_Chronometer timer;
- Standard_Real UserSeconds, SystemSeconds;
- timer.Start();
- for ( int repeat = 0; repeat < NumberOfViewerUpdate; repeat++ ){
- for (viewer->InitActiveViews();viewer->MoreActiveViews();viewer->NextActiveViews())
+ OSD_Chronometer aTimer;
+ Standard_Real aUserSeconds, aSystemSeconds;
+ aTimer.Start();
+ const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
+ for (Standard_Integer anInteration = 0; anInteration < aRedrawsNb; ++anInteration)
+ {
+ for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
{
- if( repeat == 0 )
- viewer->ActiveView()->Update();
+ if (anInteration == 0)
+ {
+ aViewer->ActiveView()->Update();
+ }
else
- viewer->ActiveView()->Redraw();
+ {
+ aViewer->ActiveView()->Redraw();
+ }
}
}
- timer.Show(UserSeconds,SystemSeconds);
- timer.Stop();
- printf("Number of scene redrawings: %.i \n", NumberOfViewerUpdate);
- printf("User Seconds: %.20f sec \n", UserSeconds);
- printf("System Seconds: %.20f sec \n", SystemSeconds);
- printf("Average time of scene redrawing : %.20f sec \n", (UserSeconds)/(Standard_Real)NumberOfViewerUpdate);
+ aTimer.Show (aUserSeconds, aSystemSeconds);
+ aTimer.Stop();
+ std::cout << "Number of scene redrawings: " << aRedrawsNb << "\n"
+ << "CPU user time: "
+ << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aUserSeconds
+ << " msec\n"
+ << "CPU system time: "
+ << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aSystemSeconds
+ << " msec\n"
+ << "CPU average time of scene redrawing: "
+ << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * (aUserSeconds / (Standard_Real )aRedrawsNb)
+ << " msec\n";
return 0;
}
//=======================================================================
//function : ObjectsCommands
-//purpose :
+//purpose :
//=======================================================================
void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"vtrihedron : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw] ",
__FILE__,VTrihedron,group);
- theCommands.Add("vtri2d",
+ theCommands.Add("vtri2d",
"vtri2d Name Selection in the viewer only ",
__FILE__,VTrihedron2D ,group);
- theCommands.Add("vplanetri",
+ theCommands.Add("vplanetri",
"vplanetri Name Selection in the viewer only ",
__FILE__,VPlaneTrihedron ,group);
"vaxis nom [Xa] [Ya] [Za] [Xb] [Yb] [Zb]",
__FILE__,VAxisBuilder,group);
- theCommands.Add("vaxispara",
+ theCommands.Add("vaxispara",
"vaxispara nom ",
__FILE__,VAxisBuilder,group);
"vplaneortho PlaneName ",
__FILE__,VPlaneBuilder,group);
- theCommands.Add("vline",
+ theCommands.Add("vline",
"vline: vline LineName [Xa/PointName] [Ya/PointName] [Za] [Xb] [Yb] [Zb] ",
__FILE__,VLineBuilder,group);
__FILE__,VDrawText,group);
theCommands.Add("vdrawsphere",
- "vdrawsphere: VDrawSphere X Y Z Fineness Radius EnableVBO [NumberOfViewerUpdate(Default=1)] [ShowEdges(Default=0)]",
+ "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
__FILE__,VDrawSphere,group);
}