mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
7
src/ViewerTest/FILES
Executable file
7
src/ViewerTest/FILES
Executable file
@@ -0,0 +1,7 @@
|
||||
ViewerTest_CMPLRS.edl
|
||||
ViewerTest_AviCommands.cxx
|
||||
ViewerTest_ViewerCommands.cxx
|
||||
ViewerTest_RelationCommands.cxx
|
||||
ViewerTest_ObjectCommands.cxx
|
||||
ViewerTest_FilletCommands.cxx
|
||||
ViewerTest_VoxelCommands.cxx
|
160
src/ViewerTest/ViewerTest.cdl
Executable file
160
src/ViewerTest/ViewerTest.cdl
Executable file
@@ -0,0 +1,160 @@
|
||||
-- File: ViewerTest.cdl
|
||||
-- Created: Wed Jul 23 14:11:55 1997
|
||||
-- Author: Henri JEANNIN
|
||||
-- <hjn@entrax.paris3.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
|
||||
package ViewerTest
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Draw,
|
||||
TCollection,
|
||||
TColStd,
|
||||
TopAbs,
|
||||
TopTools,
|
||||
TopoDS,
|
||||
V3d,
|
||||
AIS,
|
||||
NIS,
|
||||
MMgt
|
||||
|
||||
is
|
||||
|
||||
class Tool;
|
||||
---Purpose: to build a context and set a given context as current
|
||||
-- for ViewerTest.
|
||||
|
||||
|
||||
|
||||
class EventManager;
|
||||
---Purpose: used to manage mouse event (move,select,shiftselect)
|
||||
-- By default the events are transmitted to interactive context.
|
||||
|
||||
|
||||
class DoubleMapOfInteractiveAndName instantiates DoubleMap
|
||||
from TCollection ( Transient from Standard,
|
||||
AsciiString from TCollection,
|
||||
MapTransientHasher from TColStd,
|
||||
AsciiString from TCollection);
|
||||
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Package methods
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
Factory (theDI : out Interpretor from Draw);
|
||||
---Purpose: Loads all Draw commands of V2d & V3d. Used for plugin.
|
||||
|
||||
---Category: Create the viewer....
|
||||
|
||||
ViewerInit ( thePxLeft, thePxTop : Integer from Standard = 0;
|
||||
thePxWidth, thePxHeight : Integer from Standard = 0);
|
||||
---Purpose:
|
||||
-- implemented in ViewerTest_ViewerCommands.cxx
|
||||
|
||||
---Category: Selection in the viewer....
|
||||
|
||||
|
||||
WClass returns TShared from MMgt is private;
|
||||
---C++: return const &
|
||||
---Purpose: Returns a window class that implements standard behavior of
|
||||
-- all windows of the ViewerTest. This includes usual Open CASCADE
|
||||
-- view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
|
||||
-- Ctrl+MB2 for pan, etc) and keyboard shortcuts.
|
||||
-- This method is relevant for MS Windows only and respectively
|
||||
-- returns WNT_WClass handle.
|
||||
|
||||
PickShape (aType : ShapeEnum from TopAbs;
|
||||
MaxPick : Integer from Standard = 5) returns Shape from TopoDS;
|
||||
---Purpose: waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
|
||||
-- if <aType> == TopAbs_Shape, any shape can be picked...
|
||||
-- MaxPick is the Max number before exiting, if no pick is successfull
|
||||
|
||||
|
||||
PickShapes (aType : ShapeEnum from TopAbs;
|
||||
thepicked : in out HArray1OfShape from TopTools;
|
||||
MaxPick : Integer from Standard = 5)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: wait until the array is filled with picked shapes.
|
||||
-- returns True if the array is filled.
|
||||
-- exit if number of unsuccesfull picks = <MaxPick>
|
||||
|
||||
PickObject(Type : KindOfInteractive from AIS = AIS_KOI_None;
|
||||
Signature : Integer from Standard = -1;
|
||||
MaxPick : Integer from Standard = 5)
|
||||
returns InteractiveObject from AIS;
|
||||
---Purpose: waits until an interactive object of a given Type
|
||||
-- and signature is picked (defaut values authorize
|
||||
-- selection of any Interactive Object)
|
||||
-- exit if number of unsuccesfull picks = <MaxPick>
|
||||
|
||||
PickObjects(thepicked : in out HArray1OfTransient from TColStd;
|
||||
Type : KindOfInteractive from AIS = AIS_KOI_None;
|
||||
Signature : Integer from Standard = -1;
|
||||
MaxPick : Integer from Standard = 5)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: selection of several interactive objects. Number is given
|
||||
-- by the size of <thepicked>
|
||||
-- exit if number of unsuccesfull picks = <MaxPick>
|
||||
|
||||
|
||||
Commands (theCommands : in out Interpretor from Draw);
|
||||
AviCommands(theCommands :in out Interpretor from Draw);
|
||||
ViewerCommands(theCommands :in out Interpretor from Draw);
|
||||
MyCommands (theCommands : in out Interpretor from Draw); -- My Own Com-s
|
||||
RelationCommands(theCommands :in out Interpretor from Draw);
|
||||
ObjectCommands(theCommands :in out Interpretor from Draw);
|
||||
FilletCommands(theCommands :in out Interpretor from Draw);
|
||||
VoxelCommands(theCommands :in out Interpretor from Draw);
|
||||
|
||||
GetMousePosition(xpix,ypix: out Integer from Standard);
|
||||
|
||||
GetViewerFromContext returns Viewer from V3d;
|
||||
|
||||
GetCollectorFromContext returns Viewer from V3d;
|
||||
|
||||
GetAISContext returns InteractiveContext from AIS;
|
||||
|
||||
GetNISContext returns InteractiveContext from NIS;
|
||||
---C++: return &
|
||||
|
||||
SetAISContext (aContext: InteractiveContext from AIS);
|
||||
|
||||
SetNISContext (aContext: InteractiveContext from NIS);
|
||||
|
||||
CurrentView returns View from V3d;
|
||||
|
||||
CurrentView (aViou:View from V3d);
|
||||
|
||||
Clear ;
|
||||
|
||||
---Category: Change behaviour on move,select,... events.
|
||||
|
||||
SetEventManager (aMgr:EventManager from ViewerTest);
|
||||
---Purpose: puts <aMgr> as current eventmanager (the
|
||||
-- move,select,...will be applied to <aMgr>
|
||||
|
||||
UnsetEventManager;
|
||||
---Purpose: removes the last EventManager from the list.
|
||||
|
||||
ResetEventManager;
|
||||
---Purpose: clear the list of EventManagers and
|
||||
-- sets the default EventManager as current
|
||||
|
||||
CurrentEventManager returns EventManager from ViewerTest;
|
||||
|
||||
|
||||
---Category: privateMethods...
|
||||
|
||||
|
||||
RemoveSelected;
|
||||
|
||||
StandardModeActivation(Mode : Integer from Standard);
|
||||
|
||||
|
||||
|
||||
end;
|
3733
src/ViewerTest/ViewerTest.cxx
Executable file
3733
src/ViewerTest/ViewerTest.cxx
Executable file
File diff suppressed because it is too large
Load Diff
86
src/ViewerTest/ViewerTest_AviCommands.cxx
Executable file
86
src/ViewerTest/ViewerTest_AviCommands.cxx
Executable file
@@ -0,0 +1,86 @@
|
||||
// File: ViewerTest_AviCommands.cxx
|
||||
// Created: 30.06.08 18:02
|
||||
// Author: Alexander GRIGORIEV
|
||||
// Copyright: Open Cascade 2008
|
||||
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <ViewerTest.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <OpenGl_AVIWriter.hxx>
|
||||
|
||||
static Standard_Integer avi_record(Draw_Interpretor& di,
|
||||
Standard_Integer argc, const char** argv)
|
||||
{
|
||||
Standard_Integer aResult(1);
|
||||
if (argc < 2) {
|
||||
cout << "Syntax: " << argv[0] << " file | start | stop | save" << endl;
|
||||
} else {
|
||||
|
||||
#ifndef WNT
|
||||
cout << "AVI writer is implemented only in Windows version" << endl;
|
||||
#else
|
||||
static OpenGl_AVIWriter * pAviWriter = 0L;
|
||||
|
||||
if (strncmp(argv[1], "file", 5) == 0) {
|
||||
if (argc < 3) {
|
||||
cout << "Please define the name of AVI file to create ..." << endl;
|
||||
} else {
|
||||
const char * aFilename = argv[2];
|
||||
DWORD aFormat = mmioFOURCC('X','V','I','D');
|
||||
if (argc > 3) {
|
||||
const char * aFourcc = argv[3];
|
||||
aFormat = mmioFOURCC(aFourcc[0], aFourcc[1], aFourcc[2], aFourcc[3]);
|
||||
}
|
||||
pAviWriter = new OpenGl_AVIWriter (aFilename, aFormat, 25);
|
||||
aResult = 0;
|
||||
}
|
||||
} else if (pAviWriter == 0L) {
|
||||
cout << "AVI Writer instance has not been initialized. Use command "
|
||||
<< argv[0] << " file ..." << endl;
|
||||
} else if (strncmp(argv[1], "start", 6) == 0) {
|
||||
pAviWriter->StartRecording();
|
||||
aResult = 0;
|
||||
} else if (strncmp(argv[1], "stop", 5) == 0) {
|
||||
pAviWriter->StopRecording();
|
||||
aResult = 0;
|
||||
} else if (strncmp(argv[1], "save", 5) == 0) {
|
||||
pAviWriter->StopRecording();
|
||||
delete pAviWriter;
|
||||
pAviWriter = 0L;
|
||||
aResult = 0;
|
||||
} else if (strncmp(argv[1], "status", 7) == 0) {
|
||||
cout << pAviWriter->GetLastErrorMessage() << endl;
|
||||
aResult = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AviCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest::AviCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
const char* group = "ViewerTest AVI commands";
|
||||
|
||||
theCommands.Add("vrecord", "vrecord [option]\n"
|
||||
"where [option] can be:\n"
|
||||
"\tfile <filename.avi> <FOURCC=VIDX': Create AVI file "
|
||||
"for recording,\n"
|
||||
"\tstart : begin/restart recording,\n"
|
||||
"\tstop : stop recording,\n"
|
||||
"\tstatus : log error message,\n"
|
||||
"\tsave : close the AVI file\n",
|
||||
__FILE__,
|
||||
&avi_record, group); //Draft_Modification
|
||||
}
|
||||
|
||||
|
||||
|
8
src/ViewerTest/ViewerTest_CMPLRS.edl
Executable file
8
src/ViewerTest/ViewerTest_CMPLRS.edl
Executable file
@@ -0,0 +1,8 @@
|
||||
@ifnotdefined ( %ViewerTest_CMPLRS ) then
|
||||
@set %ViewerTest_CMPLRS = "";
|
||||
|
||||
@uses "CSF.edl" ;
|
||||
|
||||
@string %CMPLRS_CXX_Options = " -I"%CSF_TCL_INCLUDE %CMPLRS_CXX_Options ;
|
||||
|
||||
@endif;
|
44
src/ViewerTest/ViewerTest_EventManager.cdl
Executable file
44
src/ViewerTest/ViewerTest_EventManager.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: ViewerTest_EventManager.cdl
|
||||
-- Created: Thu Aug 27 13:53:26 1998
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@robox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class EventManager from ViewerTest inherits TShared from MMgt
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
View from V3d,
|
||||
InteractiveContext from AIS
|
||||
|
||||
is
|
||||
|
||||
Create (aView: View from V3d;
|
||||
aCtx :InteractiveContext from AIS)
|
||||
returns mutable EventManager from ViewerTest;
|
||||
|
||||
MoveTo (me:mutable;
|
||||
xpix, ypix : Integer from Standard) is virtual;
|
||||
|
||||
Select(me:mutable) is virtual;
|
||||
|
||||
ShiftSelect(me:mutable) is virtual;
|
||||
|
||||
Select(me:mutable;xmin,ymin,xmax,ymax:Integer) is virtual;
|
||||
|
||||
ShiftSelect(me:mutable;xmin,ymin,xmax,ymax:Integer) is virtual;
|
||||
|
||||
Context(me) returns InteractiveContext from AIS;
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
fields
|
||||
|
||||
myCtx : InteractiveContext from AIS;
|
||||
myView: View from V3d;
|
||||
myX : Integer from Standard;
|
||||
myY : Integer from Standard;
|
||||
|
||||
end EventManager;
|
104
src/ViewerTest/ViewerTest_EventManager.cxx
Executable file
104
src/ViewerTest/ViewerTest_EventManager.cxx
Executable file
@@ -0,0 +1,104 @@
|
||||
// File: ViewerTest_EventManager.cxx
|
||||
// Created: Thu Aug 27 14:20:19 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <ViewerTest_EventManager.ixx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <NIS_View.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewerTest_EventManager
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ViewerTest_EventManager::ViewerTest_EventManager
|
||||
(const Handle(V3d_View)& aView,
|
||||
const Handle(AIS_InteractiveContext)& Ctx)
|
||||
: myView (aView),
|
||||
myCtx (Ctx),
|
||||
myX (-1),
|
||||
myY (-1)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoveTo
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::MoveTo(const Standard_Integer XPix,
|
||||
const Standard_Integer YPix)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->MoveTo(XPix,YPix,myView);
|
||||
myX = XPix;
|
||||
myY = YPix;
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->DynamicHilight (XPix, YPix);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::Select(const Standard_Integer XPMin,
|
||||
const Standard_Integer YPMin,
|
||||
const Standard_Integer XPMax,
|
||||
const Standard_Integer YPMax)
|
||||
{
|
||||
#define IS_FULL_INCLUSION Standard_True
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->Select(XPMin,YPMin,XPMax,YPMax,myView);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_False, IS_FULL_INCLUSION);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShiftSelect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::ShiftSelect(const Standard_Integer XPMin,
|
||||
const Standard_Integer YPMin,
|
||||
const Standard_Integer XPMax,
|
||||
const Standard_Integer YPMax)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->AIS_InteractiveContext::ShiftSelect(XPMin,YPMin,XPMax,YPMax,myView,
|
||||
Standard_True);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_True, IS_FULL_INCLUSION);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::Select()
|
||||
{
|
||||
if (!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->Select();
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(myX, myY);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShiftSelect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::ShiftSelect()
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->ShiftSelect(Standard_True);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(myX, myY, Standard_True);
|
||||
}
|
6
src/ViewerTest/ViewerTest_EventManager.lxx
Executable file
6
src/ViewerTest/ViewerTest_EventManager.lxx
Executable file
@@ -0,0 +1,6 @@
|
||||
// File: ViewerTest_EventManager.lxx
|
||||
// Created: Thu Aug 27 15:13:00 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
inline const Handle(AIS_InteractiveContext)& ViewerTest_EventManager::Context() const
|
||||
{return myCtx;}
|
176
src/ViewerTest/ViewerTest_FilletCommands.cxx
Executable file
176
src/ViewerTest/ViewerTest_FilletCommands.cxx
Executable file
@@ -0,0 +1,176 @@
|
||||
// File: ViewerTest_FilletCommands.cxx
|
||||
// Created: Fri Nov 20 16:58:22 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ViewerTest.hxx>
|
||||
#include <string.h>
|
||||
#include <BRepTest.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <BRepFilletAPI_MakeFillet.hxx>
|
||||
//#include <BRepAlgo_BooleanOperation.hxx>
|
||||
//#include <BRepAlgo_Fuse.hxx>
|
||||
//#include <BRepAlgo_Cut.hxx>
|
||||
#include <BiTgte_Blend.hxx>
|
||||
#include <TopOpeBRepBuild_HBuilder.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <FilletSurf_Builder.hxx>
|
||||
#include <ChFi3d_FilletShape.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <FilletSurf_StatusType.hxx>
|
||||
#include <FilletSurf_ErrorTypeStatus.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <TopTools_HArray1OfShape.hxx>
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef WNT
|
||||
//#define strcasecmp strcmp Already defined in Standard
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
extern Handle(AIS_Shape) GetAISShapeFromName(const char* name);
|
||||
|
||||
|
||||
static Standard_Real t3d = 1.e-4;
|
||||
static Standard_Real t2d = 1.e-5;
|
||||
static Standard_Real ta = 1.e-2;
|
||||
static Standard_Real fl = 1.e-3;
|
||||
static Standard_Real tapp_angle = 1.e-2;
|
||||
static GeomAbs_Shape blend_cont = GeomAbs_C1;
|
||||
|
||||
static BRepFilletAPI_MakeFillet* Rakk = 0;
|
||||
#ifdef DEB
|
||||
static BRepFilletAPI_MakeFillet* Rake = 0;
|
||||
static char name[100];
|
||||
#endif
|
||||
|
||||
|
||||
static void printtolblend(Draw_Interpretor& di)
|
||||
{
|
||||
di<<"tolerance ang : "<<ta<<"\n";
|
||||
di<<"tolerance 3d : "<<t3d<<"\n";
|
||||
di<<"tolerance 2d : "<<t2d<<"\n";
|
||||
di<<"fleche : "<<fl<<"\n";
|
||||
|
||||
di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
|
||||
}
|
||||
|
||||
// Unused :
|
||||
#ifdef DEB
|
||||
static Standard_Integer tolblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
|
||||
{
|
||||
if(narg == 1){
|
||||
printtolblend(di);
|
||||
return 0;
|
||||
}
|
||||
else if(narg == 5){
|
||||
ta = atof(a[1]);
|
||||
t3d = atof(a[2]);
|
||||
t2d = atof(a[3]);
|
||||
fl = atof(a[4]);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static Standard_Integer VBLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
|
||||
{
|
||||
if(Rakk != 0) {delete Rakk; Rakk = 0;}
|
||||
printtolblend(di);
|
||||
if (narg<5) return 1;
|
||||
|
||||
Standard_Integer NbToPick = (narg -4)/2;
|
||||
#ifdef DEB
|
||||
Standard_Boolean autonaming = !strcasecmp(a[3],".");
|
||||
#endif
|
||||
Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
|
||||
if(ViewerTest::PickShapes(TopAbs_EDGE,arr)){
|
||||
for(Standard_Integer i=1;i<=NbToPick;i++){
|
||||
TopoDS_Shape PickSh = arr->Value(i);
|
||||
if(!PickSh.IsNull()){
|
||||
DBRep::Set(a[(2*i+2)],PickSh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Shape V = DBRep::Get(a[2]);
|
||||
if(V.IsNull()) return 1;
|
||||
ChFi3d_FilletShape FSh = ChFi3d_Rational;
|
||||
if (narg%2 == 0) {
|
||||
if (!strcasecmp(a[narg-1], "Q")) {
|
||||
FSh = ChFi3d_QuasiAngular;
|
||||
}
|
||||
else if (!strcasecmp(a[narg-1], "P")) {
|
||||
FSh = ChFi3d_Polynomial;
|
||||
}
|
||||
}
|
||||
Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
|
||||
Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
|
||||
Rakk->SetContinuity(blend_cont, tapp_angle);
|
||||
Standard_Real Rad;
|
||||
TopoDS_Edge E;
|
||||
Standard_Integer nbedge = 0;
|
||||
for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
|
||||
Rad = atof(a[2*ii + 1]);
|
||||
TopoDS_Shape aLocalShape = DBRep::Get(a[(2*ii+2)],TopAbs_EDGE);
|
||||
E = TopoDS::Edge(aLocalShape);
|
||||
// E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
|
||||
if(!E.IsNull()){
|
||||
Rakk->Add(Rad,E);
|
||||
nbedge++;
|
||||
}
|
||||
}
|
||||
if(!nbedge) return 1;
|
||||
Rakk->Build();
|
||||
if(!Rakk->IsDone()) return 1;
|
||||
TopoDS_Shape res = Rakk->Shape();
|
||||
DBRep::Set(a[1],res);
|
||||
|
||||
|
||||
// visu resultat...
|
||||
Handle(AIS_Shape) AS = GetAISShapeFromName(a[1]);
|
||||
Handle(AIS_Shape) Start = GetAISShapeFromName(a[2]);
|
||||
Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
|
||||
Ctx->Erase(Start,Standard_False);
|
||||
if(Ctx->IsDisplayed(AS))
|
||||
Ctx->Redisplay(AS);
|
||||
else
|
||||
Ctx->Display(AS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ViewerTest::FilletCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
const char* g = "Viewer Fillet construction commands";
|
||||
theCommands.Add("vblend",
|
||||
"vblend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,
|
||||
VBLEND,g);
|
||||
}
|
2590
src/ViewerTest/ViewerTest_ObjectCommands.cxx
Executable file
2590
src/ViewerTest/ViewerTest_ObjectCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
2213
src/ViewerTest/ViewerTest_RelationCommands.cxx
Executable file
2213
src/ViewerTest/ViewerTest_RelationCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
30
src/ViewerTest/ViewerTest_Tool.cdl
Executable file
30
src/ViewerTest/ViewerTest_Tool.cdl
Executable file
@@ -0,0 +1,30 @@
|
||||
-- File: ViewerTest_Tool.cdl
|
||||
-- Created: Thu Oct 15 10:20:43 1998
|
||||
-- Author: Denis PASCAL
|
||||
-- <dp@dingox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Tool from ViewerTest
|
||||
|
||||
---Purpose: to build and initialize ViewerTest static variables.
|
||||
-- ====================================================
|
||||
|
||||
uses Viewer from V3d,
|
||||
InteractiveContext from AIS
|
||||
|
||||
|
||||
is
|
||||
|
||||
MakeViewer (myclass; title : CString from Standard)
|
||||
---Purpose: create a new <context>. ViewerTest variables are not initialized;
|
||||
returns Viewer from V3d;
|
||||
|
||||
MakeContext (myclass; title : CString from Standard)
|
||||
---Purpose: create a new <context>. ViewerTest variables are not initialized;
|
||||
returns InteractiveContext from AIS;
|
||||
|
||||
InitViewerTest (myclass; current : InteractiveContext from AIS);
|
||||
---Purpose: init variables of ViewerTest with <current>
|
||||
|
||||
end Tool;
|
161
src/ViewerTest/ViewerTest_Tool.cxx
Executable file
161
src/ViewerTest/ViewerTest_Tool.cxx
Executable file
@@ -0,0 +1,161 @@
|
||||
// File: ViewerTest_Tool.cxx
|
||||
// Created: Thu Oct 15 10:24:56 1998
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <ViewerTest_Tool.ixx>
|
||||
|
||||
#include <V3d_View.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <string.h>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <Graphic3d_GraphicDevice.hxx>
|
||||
#include <Xw_GraphicDevice.hxx>
|
||||
#include <Xw_WindowQuality.hxx>
|
||||
#include <Xw_Window.hxx>
|
||||
#include <Graphic3d_GraphicDevice.hxx>
|
||||
#include <Xw_GraphicDevice.hxx>
|
||||
#include <Xw_WindowQuality.hxx>
|
||||
#include <Xw_Window.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d.hxx>
|
||||
#include <AIS_DisplayMode.hxx>
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
#include <AIS_MapOfInteractive.hxx>
|
||||
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
|
||||
#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
|
||||
#include <ViewerTest_EventManager.hxx>
|
||||
#include <Draw_Window.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <Aspect_Window.hxx>
|
||||
|
||||
|
||||
#ifndef WNT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#else
|
||||
#include <WNT_WClass.hxx>
|
||||
#include <WNT_Window.hxx>
|
||||
#include <Graphic3d_WNTGraphicDevice.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// GLOBAL VARIABLES
|
||||
//==============================================================================
|
||||
#define ZCLIPWIDTH 1.
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
static Handle(Graphic3d_WNTGraphicDevice) GetDevice() {
|
||||
static Handle(Graphic3d_WNTGraphicDevice) myDevice;
|
||||
static int first = 1;
|
||||
if ( first ) myDevice = new Graphic3d_WNTGraphicDevice();
|
||||
first = 0;
|
||||
return myDevice;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static Handle(Graphic3d_GraphicDevice)& GetDevice() {
|
||||
static Handle(Graphic3d_GraphicDevice) myDevice;
|
||||
static int first = 1;
|
||||
if ( first ) myDevice = new Graphic3d_GraphicDevice (getenv("DISPLAY"),Xw_TOM_READONLY);
|
||||
first = 0;
|
||||
return myDevice;
|
||||
}
|
||||
|
||||
//static Display *display;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeViewer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(V3d_Viewer) ViewerTest_Tool::MakeViewer (const Standard_CString title)
|
||||
{
|
||||
|
||||
Handle(Aspect_Window) window;
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
window = new WNT_Window (GetDevice(),
|
||||
title,
|
||||
Handle(WNT_WClass)::DownCast (ViewerTest::WClass()),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0.,0.,0.25,0.25,
|
||||
Quantity_NOC_BLACK);
|
||||
window->Map();
|
||||
|
||||
#else
|
||||
window = new Xw_Window(GetDevice(),
|
||||
title,
|
||||
0.,0.60,0.40,0.40,
|
||||
Xw_WQ_3DQUALITY,
|
||||
Quantity_NOC_BLACK);
|
||||
#endif
|
||||
|
||||
// Viewer
|
||||
|
||||
Handle(Aspect_GraphicDevice) theDevice = GetDevice();
|
||||
TCollection_ExtendedString NameOfWindow("Visu3D");
|
||||
Handle(V3d_Viewer) a3DViewer = new V3d_Viewer(theDevice,NameOfWindow.ToExtString());
|
||||
|
||||
|
||||
a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
|
||||
a3DViewer->SetDefaultLights();
|
||||
a3DViewer->SetLightOn();
|
||||
|
||||
// View
|
||||
Handle (V3d_View) V = a3DViewer->CreateView();
|
||||
V->SetDegenerateModeOn();
|
||||
V->SetWindow(window);
|
||||
V->SetZClippingDepth(0.5);
|
||||
V->SetZClippingWidth(ZCLIPWIDTH/2.);
|
||||
|
||||
return a3DViewer;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeContext
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(AIS_InteractiveContext) ViewerTest_Tool::MakeContext (const Standard_CString title)
|
||||
{
|
||||
return new AIS_InteractiveContext (MakeViewer(title));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : InitViewerTest
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
// ********* next method is defined in ViewerTest_ViewerCommands.hxx ****
|
||||
extern void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)&);
|
||||
// **********************************************************************
|
||||
|
||||
void ViewerTest_Tool::InitViewerTest (const Handle(AIS_InteractiveContext)& context)
|
||||
{
|
||||
ViewerTest_InitViewerTest (context);
|
||||
}
|
||||
|
1778
src/ViewerTest/ViewerTest_ViewerCommands.cxx
Executable file
1778
src/ViewerTest/ViewerTest_ViewerCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
854
src/ViewerTest/ViewerTest_VoxelCommands.cxx
Executable file
854
src/ViewerTest/ViewerTest_VoxelCommands.cxx
Executable file
@@ -0,0 +1,854 @@
|
||||
// File: ViewerTest_VoxelCommands.cxx
|
||||
// Created: Wed Sep 17 17:26 2008
|
||||
// Author: Vlad Romashko
|
||||
// <vladislav.romashko@opencascade.com>
|
||||
|
||||
#include <ViewerTest.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
#include <Voxel_BoolDS.hxx>
|
||||
#include <Voxel_ColorDS.hxx>
|
||||
#include <Voxel_FloatDS.hxx>
|
||||
#include <Voxel_OctBoolDS.hxx>
|
||||
#include <Voxel_ROctBoolDS.hxx>
|
||||
#include <Voxel_BooleanOperation.hxx>
|
||||
#include <Voxel_FastConverter.hxx>
|
||||
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
|
||||
static Standard_Integer VOXELBOOLDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. BoolDS:
|
||||
|
||||
Voxel_BoolDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds.Set(ix, iy, iz, Standard_False);
|
||||
else
|
||||
ds.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz) == Standard_True;
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != Standard_False)
|
||||
{
|
||||
di<<"error : voxelboolds";
|
||||
return 1; // error
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelboolds";
|
||||
return 1; // error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // Sehr gut
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELCOLORDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. ColorDS:
|
||||
|
||||
Voxel_ColorDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds.Set(ix, iy, iz, 8);
|
||||
else
|
||||
ds.Set(ix, iy, iz, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Byte value = ds.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != 8)
|
||||
{
|
||||
di<<"error : voxelcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != 7)
|
||||
{
|
||||
di<<"error : voxelcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELFLOATDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. FloatDS:
|
||||
|
||||
Voxel_FloatDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds.Set(ix, iy, iz, 8.8f);
|
||||
else
|
||||
ds.Set(ix, iy, iz, 7.7f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Write the voxels
|
||||
Voxel_Writer writer;
|
||||
writer.SetFormat(Voxel_VFF_BINARY);
|
||||
writer.SetVoxels(ds);
|
||||
if (!writer.Write("W:\\OCC621\\samples\\standard\\voxeldemo\\f.vx"))
|
||||
{
|
||||
statusBar()->message( "Storage failed... sorry", 2000 );
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the voxels
|
||||
Voxel_Reader reader;
|
||||
if (!reader.Read("W:\\OCC621\\samples\\standard\\voxeldemo\\f.vx"))
|
||||
{
|
||||
statusBar()->message( "Open failed... sorry", 2000 );
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
float value = ds.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != 8.8f)
|
||||
{
|
||||
di<<"error : voxelfloatds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != 7.7f)
|
||||
{
|
||||
di<<"error : voxelfloatds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELOCTBOOLDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 30, nby = 30, nbz = 30;
|
||||
|
||||
// 1. OctBoolDS:
|
||||
|
||||
Voxel_OctBoolDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
{
|
||||
ds.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 8; i++)
|
||||
{
|
||||
if (i & 0x01)
|
||||
ds.Set(ix, iy, iz, i, Standard_True);
|
||||
else
|
||||
ds.Set(ix, iy, iz, i, Standard_False);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz) == Standard_True;
|
||||
if (value != Standard_True)
|
||||
cout<<"Wrong value!"<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 8; i++)
|
||||
{
|
||||
if (i & 0x01)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz, i) == Standard_True;
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxeloctboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz, i) == Standard_True;
|
||||
if (value != Standard_False)
|
||||
{
|
||||
di<<"error : voxeloctboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 8; i++)
|
||||
{
|
||||
ds.Set(ix, iy, iz, i, Standard_True);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 8; i++)
|
||||
{
|
||||
ds.Set(ix, iy, iz, i, Standard_False);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ds.OptimizeMemory();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELROCTBOOLDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz, i, j;
|
||||
Standard_Integer nbx = 30, nby = 30, nbz = 30;
|
||||
|
||||
// 1. ROctBoolDS:
|
||||
|
||||
Voxel_ROctBoolDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
ds.Set(ix, iy, iz, i, j, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ds.OptimizeMemory();
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ds.Deepness(ix, iy, iz) == 0)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz);
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelroctboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (ds.Deepness(ix, iy, iz) == 1)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz, i);
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelroctboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ds.Deepness(ix, iy, iz) == 2)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
Standard_Boolean value = ds.Get(ix, iy, iz, i, j);
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelroctboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test converter
|
||||
Standard_Integer progress = 0;
|
||||
TopoDS_Shape S = BRepPrimAPI_MakeSphere(100.0).Shape();
|
||||
Voxel_ROctBoolDS* ds2 = new Voxel_ROctBoolDS;
|
||||
Voxel_FastConverter converter(S, *ds2, 0.1, nbx, nby, nbz, 1);
|
||||
converter.Convert(progress);
|
||||
ds2->OptimizeMemory();
|
||||
delete ds2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELFUSEBOOLDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two BoolDS:
|
||||
|
||||
Voxel_BoolDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_BoolDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, Standard_False);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fuse them
|
||||
|
||||
Voxel_BooleanOperation fuser;
|
||||
if (!fuser.Fuse(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelfuseboolds";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Boolean value = ds1.Get(ix, iy, iz) == Standard_True;
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != Standard_False)
|
||||
{
|
||||
di<<"error : voxelfuseboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelfuseboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELFUSECOLORDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two ColorDS:
|
||||
|
||||
Voxel_ColorDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_ColorDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds1.Set(ix, iy, iz, 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, 3);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fuse them
|
||||
|
||||
Voxel_BooleanOperation fuser;
|
||||
if (!fuser.Fuse(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelfusecolords";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Byte value = ds1.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != 14)
|
||||
{
|
||||
di<<"error : voxelfusecolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != 15)
|
||||
{
|
||||
di<<"error : voxelfusecolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELFUSEFLOATDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two FloatDS:
|
||||
|
||||
Voxel_FloatDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_FloatDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds1.Set(ix, iy, iz, 11.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, 3.3f);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, 5.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fuse them
|
||||
|
||||
Voxel_BooleanOperation fuser;
|
||||
if (!fuser.Fuse(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelfusefloatds";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
float value = ds1.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (fabs(value - 14.4f) > 0.001)
|
||||
{
|
||||
di<<"error : voxelfusefloatds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fabs(value - 16.6f) > 0.001)
|
||||
{
|
||||
di<<"error : voxelfusefloatds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELCUTBOOLDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two BoolDS:
|
||||
|
||||
Voxel_BoolDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_BoolDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds1.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, Standard_False);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Cut them
|
||||
|
||||
Voxel_BooleanOperation cutter;
|
||||
if (!cutter.Cut(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelcutboolds";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Boolean value = ds1.Get(ix, iy, iz) == Standard_True;
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != Standard_True)
|
||||
{
|
||||
di<<"error : voxelcutboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != Standard_False)
|
||||
{
|
||||
di<<"error : voxelcutboolds";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELCUTCOLORDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two ColorDS:
|
||||
|
||||
Voxel_ColorDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_ColorDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds1.Set(ix, iy, iz, 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, 3);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Cut them
|
||||
|
||||
Voxel_BooleanOperation cutter;
|
||||
if (!cutter.Cut(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
Standard_Byte value = ds1.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (value != 8)
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != 6)
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer VOXELCUTFLOATDS(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer ix, iy, iz;
|
||||
Standard_Integer nbx = 100, nby = 100, nbz = 100;
|
||||
|
||||
// 1. Set two FloatDS:
|
||||
|
||||
Voxel_FloatDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
Voxel_FloatDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz);
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
ds1.Set(ix, iy, iz, 11.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
if (ix & 0x01)
|
||||
ds2.Set(ix, iy, iz, 3.3f);
|
||||
else
|
||||
ds2.Set(ix, iy, iz, 5.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Cut them
|
||||
|
||||
Voxel_BooleanOperation cutter;
|
||||
if (!cutter.Cut(ds1, ds2))
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 3. Check result
|
||||
|
||||
for (ix = 0; ix < nbx; ix++)
|
||||
{
|
||||
for (iy = 0; iy < nby; iy++)
|
||||
{
|
||||
for (iz = 0; iz < nbz; iz++)
|
||||
{
|
||||
float value = ds1.Get(ix, iy, iz);
|
||||
if (ix & 0x01)
|
||||
{
|
||||
if (fabs(value - 7.8f) > 0.001)
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fabs(value - 5.6f) > 0.001)
|
||||
{
|
||||
di<<"error : voxelcutcolords";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViewerTest::VoxelCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
const char* g = "Viewer Voxel non-regression test-commands";
|
||||
theCommands.Add("voxelboolds","voxelboolds; returns 0 if success",__FILE__,VOXELBOOLDS,g);
|
||||
theCommands.Add("voxelcolords","voxelcolords; returns 0 if success",__FILE__,VOXELCOLORDS,g);
|
||||
theCommands.Add("voxelfloatds","voxelfloatds; returns 0 if success",__FILE__,VOXELFLOATDS,g);
|
||||
theCommands.Add("voxeloctboolds","voxeloctboolds; returns 0 if success",__FILE__,VOXELOCTBOOLDS,g);
|
||||
theCommands.Add("voxelroctboolds","voxelroctboolds; returns 0 if success",__FILE__,VOXELROCTBOOLDS,g);
|
||||
theCommands.Add("voxelfuseboolds","voxelfuseboolds; returns 0 if success",__FILE__,VOXELFUSEBOOLDS,g);
|
||||
theCommands.Add("voxelfusecolords","voxelfusecolords; returns 0 if success",__FILE__,VOXELFUSECOLORDS,g);
|
||||
theCommands.Add("voxelfusefloatds","voxelfusefloatds; returns 0 if success",__FILE__,VOXELFUSEFLOATDS,g);
|
||||
theCommands.Add("voxelcutboolds","voxelcutboolds; returns 0 if success",__FILE__,VOXELCUTBOOLDS,g);
|
||||
theCommands.Add("voxelcutcolords","voxelcutcolords; returns 0 if success",__FILE__,VOXELCUTCOLORDS,g);
|
||||
theCommands.Add("voxelcutfloatds","voxelcutfloatds; returns 0 if success",__FILE__,VOXELCUTFLOATDS,g);
|
||||
}
|
Reference in New Issue
Block a user