Create(shape : Shape from TopoDS;
voxels : out BoolDS from Voxel;
- delfection : Real from Standard = 0.1;
+ deflection : Real from Standard = 0.1;
nbx : Integer from Standard = 10;
nby : Integer from Standard = 10;
nbz : Integer from Standard = 10;
- nbthreads : Integer from Standard = 1)
+ nbthreads : Integer from Standard = 1;
+ useExistingTriangulation : Boolean from Standard = Standard_False)
---Purpose: A constructor for conversion of a shape into a cube of boolean voxels.
-- It allocates the voxels in memory.
-- "nbthreads" defines the number of threads used to convert the shape.
Create(shape : Shape from TopoDS;
voxels : out ColorDS from Voxel;
- delfection : Real from Standard = 0.1;
+ deflection : Real from Standard = 0.1;
nbx : Integer from Standard = 10;
nby : Integer from Standard = 10;
nbz : Integer from Standard = 10;
- nbthreads : Integer from Standard = 1)
+ nbthreads : Integer from Standard = 1;
+ useExistingTriangulation : Boolean from Standard = Standard_False)
---Purpose: A constructor for conversion of a shape into a cube of colored voxels.
-- It allocates the voxels in memory.
-- "nbthreads" defines the number of threads used to convert the shape.
Create(shape : Shape from TopoDS;
voxels : out ROctBoolDS from Voxel;
- delfection : Real from Standard = 0.1;
+ deflection : Real from Standard = 0.1;
nbx : Integer from Standard = 10;
nby : Integer from Standard = 10;
nbz : Integer from Standard = 10;
- nbthreads : Integer from Standard = 1)
+ nbthreads : Integer from Standard = 1;
+ useExistingTriangulation : Boolean from Standard = Standard_False)
---Purpose: A constructor for conversion of a shape into a cube of boolean voxels
-- split into 8 sub-voxels recursively.
-- It allocates the voxels in memory.
myNbZ : Integer from Standard;
myNbThreads : Integer from Standard;
myNbTriangles : Integer from Standard;
+ myUseExistingTriangulation : Boolean from Standard;
end FastConverter;
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
- const Standard_Integer nbthreads)
+ const Standard_Integer nbthreads,
+ const Standard_Boolean useExistingTriangulation)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),myIsBool(2),
- myNbTriangles(0)
+ myNbTriangles(0),
+ myUseExistingTriangulation(useExistingTriangulation)
{
Init();
}
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
- const Standard_Integer nbthreads)
+ const Standard_Integer nbthreads,
+ const Standard_Boolean useExistingTriangulation)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),myIsBool(1),
- myNbTriangles(0)
+ myNbTriangles(0),
+ myUseExistingTriangulation(useExistingTriangulation)
{
Init();
}
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
- const Standard_Integer nbthreads)
+ const Standard_Integer nbthreads,
+ const Standard_Boolean useExistingTriangulation)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),myIsBool(0),
- myNbTriangles(0)
+ myNbTriangles(0),
+ myUseExistingTriangulation(useExistingTriangulation)
{
Init();
}
TopLoc_Location L;
Standard_Boolean triangulate = Standard_False;
TopExp_Explorer expl(myShape, TopAbs_FACE);
- for (; expl.More(); expl.Next())
+ if(myUseExistingTriangulation == Standard_False)
{
- const TopoDS_Face & F = TopoDS::Face(expl.Current());
- Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
- if (T.IsNull() || (T->Deflection() > myDeflection))
+ for (; expl.More(); expl.Next())
{
- triangulate = Standard_True;
- break;
+ const TopoDS_Face & F = TopoDS::Face(expl.Current());
+ Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
+ if (T.IsNull() || (T->Deflection() > myDeflection))
+ {
+ triangulate = Standard_True;
+ break;
+ }
}
}
if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0)
return Standard_False;
+ if(myNbTriangles == 0)
+ return Standard_False;
+
// Half of diagonal of a voxel
Voxel_DS* ds = (Voxel_DS*) myVoxels;
Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(),