return 0;
}
+#include <Voxel_BoolDS.hxx>
+#include <Voxel_FastConverter.hxx>
+#include <Voxel_BooleanOperation.hxx>
+static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if ( argc != 2 ) {
+ di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aFileName = argv[1];
+ TopoDS_Shape aShape;
+ BRep_Builder aBuilder;
+
+ if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
+ di << "Error: Could not read a shape!" << "\n";
+ return 1;
+ }
+
+ TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
+
+ Standard_Real deflection = 0.005;
+ Standard_Integer nbThreads = 1;
+ Standard_Integer nbx = 200, nby = 200, nbz = 200;
+ Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz);
+ Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz);
+
+ Standard_Integer progress = 0;
+ Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
+ fcp.ConvertUsingSAT(progress, 1);
+ fcp.FillInVolume(1);
+
+ Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
+ fcp1.ConvertUsingSAT(progress, 1);
+ fcp1.FillInVolume(1);
+
+ Voxel_BooleanOperation op;
+ Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
+ if ( result != 1 ) {
+ di << "Error: invalid boolean operation" << "\n";
+ } else {
+ di << "OK: boolean operation is ok" << "\n";
+ }
+
+ return 0;
+}
+
void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
theCommands.Add("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group);
+ theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
+
return;
}
#include <ElSLib.hxx>
#include <Poly_Triangulation.hxx>
#include <IntAna2d_AnaIntersection.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
// Printing the progress in stdout.
//#define CONV_DUMP
return Standard_True;
}
+Standard_Boolean Voxel_FastConverter::FillInVolume(const Standard_Byte inner, const TopoDS_Shape & shape, const Standard_Integer ithread)
+{
+ Voxel_DS* ds = (Voxel_DS*) myVoxels;
+ Standard_Integer ix, iy, iz, nbx = ds->GetNbX(), nby = ds->GetNbY(), nbz = ds->GetNbZ();
+ Standard_Boolean prev_surface, surface, volume, isOnVerticalSurface;
+
+ BRepClass3d_SolidClassifier solidClassifier(shape);
+ Standard_Real xc, yc, zc;
+
+ if (inner)
+ {
+ // Fill-in internal voxels by the value "inner"
+ for (ix = 0; ix < nbx; ix++)
+ {
+ for (iy = 0; iy < nby; iy++)
+ {
+ // Check existence of volume.
+ volume = Standard_False;
+ surface = Standard_False;
+ prev_surface = Standard_False;
+ isOnVerticalSurface = Standard_False;
+ for (iz = 0; iz < nbz; iz++)
+ {
+ surface = (myIsBool == 1) ?
+ ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True :
+ ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0;
+ if (prev_surface && !surface)
+ {
+ if(isOnVerticalSurface)
+ {
+ isOnVerticalSurface = Standard_False;
+ ((Voxel_BoolDS*)myVoxels)->GetCenter(ix, iy, iz, xc, yc, zc);
+ gp_Pnt P(xc, yc, zc);
+ solidClassifier.Perform(P, Precision::Confusion());
+
+ if(solidClassifier.State() == TopAbs_IN)
+ volume = Standard_True;
+ else
+ volume = Standard_False;
+ }
+ else
+ volume = !volume;
+ }
+ if(prev_surface && surface)
+ isOnVerticalSurface = Standard_True;
+ else
+ isOnVerticalSurface = Standard_False;
+ prev_surface = surface;
+ }
+ if (volume)
+ continue;
+
+ // Fill-in the volume.
+ volume = Standard_False;
+ surface = Standard_False;
+ prev_surface = Standard_False;
+ isOnVerticalSurface = Standard_False;
+ for (iz = 0; iz < nbz; iz++)
+ {
+ surface = (myIsBool == 1) ?
+ ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True :
+ ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0;
+ if (prev_surface && !surface)
+ {
+ if(isOnVerticalSurface)
+ {
+ isOnVerticalSurface = Standard_False;
+ ((Voxel_BoolDS*)myVoxels)->GetCenter(ix, iy, iz, xc, yc, zc);
+ gp_Pnt P(xc, yc, zc);
+ solidClassifier.Perform(P, Precision::Confusion());
+
+ if(solidClassifier.State() == TopAbs_IN)
+ volume = Standard_True;
+ else
+ volume = Standard_False;
+ }
+ else
+ volume = !volume;
+ }
+ if (volume && !surface)
+ {
+ (myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) :
+ ((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner);
+ }
+ if(prev_surface && surface)
+ isOnVerticalSurface = Standard_True;
+ else
+ isOnVerticalSurface = Standard_False;
+ prev_surface = surface;
+ }
+ }
+ }
+ }
+
+ return Standard_True;
+}
+
void Voxel_FastConverter::GetBndBox(const gp_Pnt& p1,
const gp_Pnt& p2,
const gp_Pnt& p3,