#include <Draw_Viewer.hxx>
#include <Draw.hxx>
-#ifndef WNT
+#ifndef _WIN32
extern Draw_Viewer dout;
#else
Standard_IMPORT Draw_Viewer dout;
#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopoDS.hxx>
-#if ! defined(WNT)
+#if ! defined(_WIN32)
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
#else
Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
#endif
-static TColStd_MapOfInteger theactivatedmodes(8);
-
#include <AIS_PlaneTrihedron.hxx>
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GC_MakePlane.hxx>
-static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull()) {
- di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
- return 1;
- }
-
- if ( argc != 3) {
- di << "ERROR : Usage : " << argv[0] << " shape mode" << "\n";
- return 1;
- }
-
- Standard_Integer ChoosingMode = -1;
- if ( strcmp (argv [2], "VERTEX") == 0 ) {
- ChoosingMode = 1;
- }
- if ( strcmp (argv [2], "EDGE") == 0 ) {
- ChoosingMode = 2;
- }
- if ( strcmp (argv [2], "WIRE") == 0 ) {
- ChoosingMode = 3;
- }
- if ( strcmp (argv [2], "FACE") == 0 ) {
- ChoosingMode = 4;
- }
- if ( strcmp (argv [2], "SHELL") == 0 ) {
- ChoosingMode = 5;
- }
- if ( strcmp (argv [2], "SOLID") == 0 ) {
- ChoosingMode = 6;
- }
- if ( strcmp (argv [2], "COMPOUND") == 0 ) {
- ChoosingMode = 7;
- }
- if ( ChoosingMode == -1 ) {
- di << "ERROR : " << argv[1] << " : vrong value of a mode" << "\n";
- return 1;
- }
-
- Standard_Boolean updateviewer = Standard_True;
-
- ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-
- TCollection_AsciiString aName(argv[1]);
- Handle(AIS_InteractiveObject) AISObj;
-
- if(!aMap.IsBound2(aName)) {
- di << "Use 'vdisplay' before" << "\n";
- return 1;
- } else {
- AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
- if(AISObj.IsNull()){
- di << argv[1] << " : No interactive object" << "\n";
- return 1;
- }
-
- if (!aContext->HasOpenedContext()) {
- aContext->OpenLocalContext();
- }
-
- if(!theactivatedmodes.Contains(ChoosingMode)) {
- aContext->ActivateStandardMode(AIS_Shape::SelectionType(ChoosingMode));
- theactivatedmodes.Add(ChoosingMode);
- }
- aContext->Erase(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
-
- aContext->Display(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
-
- const TColStd_ListOfInteger& aList = aContext->ActivatedStandardModes();
- Standard_Integer SelectMode;
- TCollection_AsciiString SelectModeString;
- TColStd_ListIteratorOfListOfInteger itr(aList);
- for (; itr.More(); itr.Next()) {
- SelectMode = itr.Value();
- //cout << "SelectMode = " << SelectMode << endl;
-
- switch (SelectMode)
- {
- case 1:
- SelectModeString.Copy("VERTEX");
- break;
- case 2:
- SelectModeString.Copy("EDGE");
- break;
- case 3:
- SelectModeString.Copy("WIRE");
- break;
- case 4:
- SelectModeString.Copy("FACE");
- break;
- case 5:
- SelectModeString.Copy("SHELL");
- break;
- case 6:
- SelectModeString.Copy("SOLID");
- break;
- case 7:
- SelectModeString.Copy("COMPOUND");
- break;
- default:
- SelectModeString.Copy("UNKNOWN");
- }
- di << "SelectMode = " << SelectModeString.ToCString() << "\n";
-
- }
- }
-
- return 0;
-}
-
static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if ( argc != 2) {
- di << "ERROR : Usage : " << argv[0] << " Doc" << "\n";
+ di << "ERROR : Usage : " << argv[0] << " Doc\n";
return 1;
}
Handle(TDocStd_Document) OwnerD1 = Owner->GetDocument();
if (OwnerD1.IsNull()) {
- di << "DocOwner1 = NULL" << "\n";
+ di << "DocOwner1 = NULL\n";
} else {
- di << "DocOwner1 = NOTNULL" << "\n";
+ di << "DocOwner1 = NOTNULL\n";
}
+ OwnerD1.Nullify();
- Handle(TDocStd_Application) A;
- if (!DDocStd::Find(A)) return 1;
+ Handle(TDocStd_Application) A = DDocStd::GetApplication();
A->Close(D);
- Handle(Draw_Drawable3D) DD = Draw::Get(argv[1],Standard_False);
- dout.RemoveDrawable (DD);
+ if (Handle(Draw_Drawable3D) DD = Draw::GetExisting (argv[1]))
+ {
+ dout.RemoveDrawable (DD);
+ }
Handle(TDocStd_Document) OwnerD2 = Owner->GetDocument();
if (OwnerD2.IsNull()) {
- di << "DocOwner2 = NULL" << "\n";
+ di << "DocOwner2 = NULL\n";
} else {
- di << "DocOwner2 = NOTNULL" << "\n";
+ di << "DocOwner2 = NOTNULL\n";
}
Standard_Integer DocRefCount2 = D->GetRefCount();
static Standard_Integer OCC145bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if ( argc != 3) {
- di << "ERROR : Usage : " << argv[0] << " Shape MaxNbr" << "\n";
+ di << "ERROR : Usage : " << argv[0] << " Shape MaxNbr\n";
return 1;
}
TopoDS_Shape aShape;
if (!BRepTools::Read(aShape, aFileName.ToCString(), aBld)) {
- di << "ERROR :Could not read a shape!!!" << "\n";
+ di << "ERROR :Could not read a shape!!!\n";
return 1;
}
for (i = 1; i <= aMaxNbr; i++) {
BRepBuilderAPI_MakeFace aMF(aWire);
if (!aMF.IsDone()) {
- di << "ERROR : Could not make a face" << "\n";
+ di << "ERROR : Could not make a face\n";
return 1;
}
}
static Standard_Integer OCC73_SelectionMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if ( argc < 3) {
- di << "ERROR : Usage : " << argv[0] << " DOC entry [SelectionMode]" << "\n";
+ di << "ERROR : Usage : " << argv[0] << " DOC entry [SelectionMode]\n";
return 1;
}
Handle(TDocStd_Document) D;
- //cout << "OCC73_SelectionMode 1" << endl;
+ //std::cout << "OCC73_SelectionMode 1" << std::endl;
if (!DDocStd::GetDocument(argv[1],D)) return 1;
TDF_Label L;
- //cout << "OCC73_SelectionMode 2" << endl;
+ //std::cout << "OCC73_SelectionMode 2" << std::endl;
if (!DDF::FindLabel(D->GetData(),argv[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
- //cout << "OCC73_SelectionMode 3" << endl;
+ //std::cout << "OCC73_SelectionMode 3" << std::endl;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
- //cout << "OCC73_SelectionMode 4" << endl;
+ //std::cout << "OCC73_SelectionMode 4" << std::endl;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( argc == 4 ) {
prs->SetSelectionMode((Standard_Integer)Draw::Atoi(argv[3]));
}
else {
Standard_Integer SelectionMode = prs->SelectionMode();
- //cout << "SelectionMode = " << SelectionMode << endl;
+ //std::cout << "SelectionMode = " << SelectionMode << std::endl;
di<<SelectionMode;
}
}
- //cout << "OCC73_SelectionMode 5" << endl;
+ //std::cout << "OCC73_SelectionMode 5" << std::endl;
return 0;
}
}
if(argc != 4) {
- di << "Usage : " << argv[0] << " name plane Length" << "\n";
+ di << "Usage : " << argv[0] << " name plane Length\n";
return 1;
}
TopoDS_Shape S = DBRep::Get( argv[2] );
if ( S.IsNull() ) {
- di << "Shape is empty" << "\n";
+ di << "Shape is empty\n";
return 1;
}
Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
if (IsBound) {
// on recupere la shape dans la map des objets displayes
- Handle(AIS_InteractiveObject) aShape =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+ Handle(AIS_InteractiveObject) aShape = GetMapOfAIS().Find2(name);
// On verifie que l'AIS InteraciveObject est bien
// un AIS_PlaneTrihedron
if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
// On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
- theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape;
+ theAISPlaneTri = Handle(AIS_PlaneTrihedron)::DownCast (aShape);
theAISPlaneTri->SetLength(Length);
theAISPlaneTri->SetLength(Length);
GetMapOfAIS().Bind ( theAISPlaneTri, name);
- aContext->Display(theAISPlaneTri );
+ aContext->Display (theAISPlaneTri, Standard_True);
}
Standard_Real getLength = theAISPlaneTri->GetLength();
di << "getLength = " << getLength << "\n";
if (getLength == Length) {
- di << "OCC10: OK" << "\n";
+ di << "OCC10: OK\n";
} else {
- di << "OCC10: ERROR" << "\n";
+ di << "OCC10: ERROR\n";
}
return 0;
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if(aContext.IsNull()) {
- di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+ di << argv[0] << "ERROR : use 'vinit' command before \n";
return 1;
}
if ( argc != 3) {
- di << "ERROR : Usage : " << argv[0] << " shape mode; set selection mode" << "\n";
+ di << "ERROR : Usage : " << argv[0] << " shape mode; set selection mode\n";
return 1;
}
Handle(AIS_InteractiveObject) AISObj;
Standard_Integer SelectMode = Draw::Atoi(argv[2]);
-
- if(!aMap.IsBound2(aName)) {
- di << "Use 'vdisplay' before" << "\n";
+ if (!aMap.Find2 (aName, AISObj)
+ || AISObj.IsNull())
+ {
+ di << "Use 'vdisplay' before\n";
return 1;
- } else {
- AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
- if(AISObj.IsNull()){
- di << argv[1] << " : No interactive object" << "\n";
- return 1;
- }
- AISObj->SetSelectionMode(SelectMode);
- if (!aContext->HasOpenedContext()) {
- aContext->OpenLocalContext();
- }
- aContext->Erase(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
- aContext->Display(AISObj, updateviewer);
- aContext->UpdateCurrentViewer();
}
+
+ aContext->Erase(AISObj, updateviewer);
+ aContext->UpdateCurrentViewer();
+ aContext->SetAutoActivateSelection (Standard_False);
+ aContext->Display(AISObj, updateviewer);
+ aContext->Activate (AISObj, SelectMode);
+ aContext->UpdateCurrentViewer();
return 0;
}
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if(aContext.IsNull()) {
- di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+ di << argv[0] << "ERROR : use 'vinit' command before \n";
return 1;
}
if ( argc != 2) {
- di << "ERROR : Usage : " << argv[0] << " shape; get selection mode" << "\n";
+ di << "ERROR : Usage : " << argv[0] << " shape; get selection mode\n";
return 1;
}
TCollection_AsciiString aName(argv[1]);
Handle(AIS_InteractiveObject) AISObj;
-
- if(!aMap.IsBound2(aName)) {
- di << "Use 'vdisplay' before" << "\n";
+ if (!aMap.Find2(aName, AISObj)
+ || AISObj.IsNull())
+ {
+ di << "Use 'vdisplay' before\n";
return 1;
- } else {
- AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
- if(AISObj.IsNull()){
- di << argv[1] << " : No interactive object" << "\n";
- return 1;
- }
- Standard_Integer SelectMode = AISObj->SelectionMode();
- di << SelectMode << "\n";
}
+ TColStd_ListOfInteger anActivatedModes;
+ aContext->ActivatedModes (AISObj, anActivatedModes);
+ Standard_Integer aMode = anActivatedModes.IsEmpty() ? -1 : anActivatedModes.Last();
+ di << aMode << "\n";
return 0;
}
static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
{
if ( nb != 2) {
- di << "ERROR : Usage : " << a[0] << " Doc" << "\n";
- di << "-1" << "\n";
+ di << "ERROR : Usage : " << a[0] << " Doc\n";
+ di << "-1\n";
return -1;
}
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(a[1],D)) {
- di << "-2" << "\n";
+ di << "-2\n";
return 1;
}
aTBox = aBuilder2.NamedShape()->Get();
if(aTBox.Orientation() != TopAbs_REVERSED) {
- di << "1" << "\n";
+ di << "1\n";
} else {
- di << "0" << "\n";
+ di << "0\n";
+ }
+ return 0;
+}
+
+#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Image_AlienPixMap.hxx>
+#include <OSD_OpenFile.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Standard_ArrayStreamBuffer.hxx>
+//=======================================================================
+//function : OCC30182
+//purpose : Testing different interfaces of Image_AlienPixMap::Load()
+//=======================================================================
+static Standard_Integer OCC30182 (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec)
+{
+ if (ViewerTest::CurrentView().IsNull())
+ {
+ std::cout << "Error: no active view\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aPrsName, anImgPath;
+ Standard_Integer anOffset = 0;
+ Standard_Integer aSrc = 0; // 0 - file name, 1 - file stream, 2 - memory buffer
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-offset"
+ && anArgIter + 1 < theNbArgs)
+ {
+ anOffset = Draw::Atoi (theArgVec[++anArgIter]);
+ }
+ else if (anArg == "-filename")
+ {
+ aSrc = 0;
+ }
+ else if (anArg == "-stream")
+ {
+ aSrc = 1;
+ }
+ else if (anArg == "-mem"
+ || anArg == "-memory")
+ {
+ aSrc = 2;
+ }
+ else if (aPrsName.IsEmpty())
+ {
+ aPrsName = theArgVec[anArgIter];
+ }
+ else if (anImgPath.IsEmpty())
+ {
+ anImgPath = theArgVec[anArgIter];
+ }
+ else
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ }
+ if (anImgPath.IsEmpty())
+ {
+ std::cout << "Syntax error: wrong number of arguments\n";
+ return 1;
}
+
+ Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+ if (aSrc == 0)
+ {
+ if (!anImage->Load (anImgPath))
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ std::ifstream aFile;
+ OSD_OpenStream (aFile, anImgPath.ToCString(), std::ios::in | std::ios::binary);
+ if (!aFile.is_open())
+ {
+ std::cout << "Syntax error: image file '" << anImgPath << "' cannot be found\n";
+ return 1;
+ }
+ if (anOffset != 0)
+ {
+ aFile.seekg (anOffset);
+ }
+
+ if (aSrc == 2)
+ {
+ aFile.seekg (0, std::ios::end);
+ Standard_Integer aLen = (Standard_Integer )aFile.tellg() - anOffset;
+ aFile.seekg (anOffset);
+ if (aLen <= 0)
+ {
+ std::cout << "Syntax error: wrong offset\n";
+ return 1;
+ }
+ NCollection_Array1<Standard_Byte> aBuff (1, aLen);
+ if (!aFile.read ((char* )&aBuff.ChangeFirst(), aBuff.Size()))
+ {
+ std::cout << "Error: unable to read file\n";
+ return 1;
+ }
+ aFile.close();
+ if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath))
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ if (!anImage->Load (aFile, anImgPath))
+ {
+ return 0;
+ }
+ }
+ }
+
+ TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100.0 * anImage->Ratio(), 100.0, 1.0).Shape();
+ Handle(AIS_Shape) aPrs = new AIS_Shape (aShape);
+ aPrs->SetDisplayMode (AIS_Shaded);
+ aPrs->Attributes()->SetupOwnShadingAspect();
+ const Handle(Graphic3d_AspectFillArea3d)& anAspect = aPrs->Attributes()->ShadingAspect()->Aspect();
+ anAspect->SetShadingModel (Graphic3d_TOSM_UNLIT);
+ anAspect->SetTextureMapOn (true);
+ anAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (anImage));
+ if (anImage->IsTopDown())
+ {
+ anAspect->TextureMap()->GetParams()->SetTranslation(Graphic3d_Vec2 (0.0f, -1.0f));
+ anAspect->TextureMap()->GetParams()->SetScale (Graphic3d_Vec2 (1.0f, -1.0f));
+ }
+
+ ViewerTest::Display (aPrsName, aPrs, true, true);
return 0;
}
void QABugs::Commands_1(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
- theCommands.Add ("OCC328", "OCC328 shape mode", __FILE__, OCC328bug, group);
-
theCommands.Add ("OCC159", "OCC159 Doc", __FILE__, OCC159bug, group);
theCommands.Add ("OCC145", "OCC145 Shape MaxNbr", __FILE__, OCC145bug, group);
theCommands.Add ("OCC74_set", "OCC74_set shape mode; set selection mode", __FILE__, OCC74bug_set, group);
theCommands.Add ("OCC74_get", "OCC74_get shape; get selection mode", __FILE__, OCC74bug_get, group);
- theCommands.Add("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group);
-
+ theCommands.Add ("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group);
+ theCommands.Add ("OCC30182",
+ "OCC30182 name image [-offset Start] [-fileName] [-stream] [-memory]\n"
+ "Decodes image either by passing file name, file stream or memory stream", __FILE__, OCC30182, group);
return;
}