mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-06 18:26:22 +03:00
0024013: Voxel_FastConverter is able to use existing triangulation
Added the possibility to use existing triangulation within Voxel_FastConverter. A grammar mistake is corrected.
This commit is contained in:
parent
85c44a05a0
commit
c5e9fb8bad
@ -37,11 +37,12 @@ is
|
|||||||
|
|
||||||
Create(shape : Shape from TopoDS;
|
Create(shape : Shape from TopoDS;
|
||||||
voxels : out BoolDS from Voxel;
|
voxels : out BoolDS from Voxel;
|
||||||
delfection : Real from Standard = 0.1;
|
deflection : Real from Standard = 0.1;
|
||||||
nbx : Integer from Standard = 10;
|
nbx : Integer from Standard = 10;
|
||||||
nby : Integer from Standard = 10;
|
nby : Integer from Standard = 10;
|
||||||
nbz : 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.
|
---Purpose: A constructor for conversion of a shape into a cube of boolean voxels.
|
||||||
-- It allocates the voxels in memory.
|
-- It allocates the voxels in memory.
|
||||||
-- "nbthreads" defines the number of threads used to convert the shape.
|
-- "nbthreads" defines the number of threads used to convert the shape.
|
||||||
@ -49,11 +50,12 @@ is
|
|||||||
|
|
||||||
Create(shape : Shape from TopoDS;
|
Create(shape : Shape from TopoDS;
|
||||||
voxels : out ColorDS from Voxel;
|
voxels : out ColorDS from Voxel;
|
||||||
delfection : Real from Standard = 0.1;
|
deflection : Real from Standard = 0.1;
|
||||||
nbx : Integer from Standard = 10;
|
nbx : Integer from Standard = 10;
|
||||||
nby : Integer from Standard = 10;
|
nby : Integer from Standard = 10;
|
||||||
nbz : 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.
|
---Purpose: A constructor for conversion of a shape into a cube of colored voxels.
|
||||||
-- It allocates the voxels in memory.
|
-- It allocates the voxels in memory.
|
||||||
-- "nbthreads" defines the number of threads used to convert the shape.
|
-- "nbthreads" defines the number of threads used to convert the shape.
|
||||||
@ -61,11 +63,12 @@ is
|
|||||||
|
|
||||||
Create(shape : Shape from TopoDS;
|
Create(shape : Shape from TopoDS;
|
||||||
voxels : out ROctBoolDS from Voxel;
|
voxels : out ROctBoolDS from Voxel;
|
||||||
delfection : Real from Standard = 0.1;
|
deflection : Real from Standard = 0.1;
|
||||||
nbx : Integer from Standard = 10;
|
nbx : Integer from Standard = 10;
|
||||||
nby : Integer from Standard = 10;
|
nby : Integer from Standard = 10;
|
||||||
nbz : 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
|
---Purpose: A constructor for conversion of a shape into a cube of boolean voxels
|
||||||
-- split into 8 sub-voxels recursively.
|
-- split into 8 sub-voxels recursively.
|
||||||
-- It allocates the voxels in memory.
|
-- It allocates the voxels in memory.
|
||||||
@ -136,5 +139,6 @@ fields
|
|||||||
myNbZ : Integer from Standard;
|
myNbZ : Integer from Standard;
|
||||||
myNbThreads : Integer from Standard;
|
myNbThreads : Integer from Standard;
|
||||||
myNbTriangles : Integer from Standard;
|
myNbTriangles : Integer from Standard;
|
||||||
|
myUseExistingTriangulation : Boolean from Standard;
|
||||||
|
|
||||||
end FastConverter;
|
end FastConverter;
|
||||||
|
@ -45,12 +45,14 @@ Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
|
|||||||
const Standard_Integer nbx,
|
const Standard_Integer nbx,
|
||||||
const Standard_Integer nby,
|
const Standard_Integer nby,
|
||||||
const Standard_Integer nbz,
|
const Standard_Integer nbz,
|
||||||
const Standard_Integer nbthreads)
|
const Standard_Integer nbthreads,
|
||||||
|
const Standard_Boolean useExistingTriangulation)
|
||||||
:myShape(shape),myVoxels(&voxels),
|
:myShape(shape),myVoxels(&voxels),
|
||||||
myDeflection(deflection),
|
myDeflection(deflection),
|
||||||
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
||||||
myNbThreads(nbthreads),myIsBool(2),
|
myNbThreads(nbthreads),myIsBool(2),
|
||||||
myNbTriangles(0)
|
myNbTriangles(0),
|
||||||
|
myUseExistingTriangulation(useExistingTriangulation)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -61,12 +63,14 @@ Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
|
|||||||
const Standard_Integer nbx,
|
const Standard_Integer nbx,
|
||||||
const Standard_Integer nby,
|
const Standard_Integer nby,
|
||||||
const Standard_Integer nbz,
|
const Standard_Integer nbz,
|
||||||
const Standard_Integer nbthreads)
|
const Standard_Integer nbthreads,
|
||||||
|
const Standard_Boolean useExistingTriangulation)
|
||||||
:myShape(shape),myVoxels(&voxels),
|
:myShape(shape),myVoxels(&voxels),
|
||||||
myDeflection(deflection),
|
myDeflection(deflection),
|
||||||
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
||||||
myNbThreads(nbthreads),myIsBool(1),
|
myNbThreads(nbthreads),myIsBool(1),
|
||||||
myNbTriangles(0)
|
myNbTriangles(0),
|
||||||
|
myUseExistingTriangulation(useExistingTriangulation)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -77,12 +81,14 @@ Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
|
|||||||
const Standard_Integer nbx,
|
const Standard_Integer nbx,
|
||||||
const Standard_Integer nby,
|
const Standard_Integer nby,
|
||||||
const Standard_Integer nbz,
|
const Standard_Integer nbz,
|
||||||
const Standard_Integer nbthreads)
|
const Standard_Integer nbthreads,
|
||||||
|
const Standard_Boolean useExistingTriangulation)
|
||||||
:myShape(shape),myVoxels(&voxels),
|
:myShape(shape),myVoxels(&voxels),
|
||||||
myDeflection(deflection),
|
myDeflection(deflection),
|
||||||
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
myNbX(nbx),myNbY(nby),myNbZ(nbz),
|
||||||
myNbThreads(nbthreads),myIsBool(0),
|
myNbThreads(nbthreads),myIsBool(0),
|
||||||
myNbTriangles(0)
|
myNbTriangles(0),
|
||||||
|
myUseExistingTriangulation(useExistingTriangulation)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -119,6 +125,8 @@ void Voxel_FastConverter::Init()
|
|||||||
TopLoc_Location L;
|
TopLoc_Location L;
|
||||||
Standard_Boolean triangulate = Standard_False;
|
Standard_Boolean triangulate = Standard_False;
|
||||||
TopExp_Explorer expl(myShape, TopAbs_FACE);
|
TopExp_Explorer expl(myShape, TopAbs_FACE);
|
||||||
|
if(myUseExistingTriangulation == Standard_False)
|
||||||
|
{
|
||||||
for (; expl.More(); expl.Next())
|
for (; expl.More(); expl.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Face & F = TopoDS::Face(expl.Current());
|
const TopoDS_Face & F = TopoDS::Face(expl.Current());
|
||||||
@ -129,6 +137,7 @@ void Voxel_FastConverter::Init()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Re-create the triangulation.
|
// Re-create the triangulation.
|
||||||
if (triangulate)
|
if (triangulate)
|
||||||
@ -167,6 +176,9 @@ Standard_Boolean Voxel_FastConverter::Convert(Standard_Integer& progress,
|
|||||||
if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0)
|
if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0)
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
|
if(myNbTriangles == 0)
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
// Half of diagonal of a voxel
|
// Half of diagonal of a voxel
|
||||||
Voxel_DS* ds = (Voxel_DS*) myVoxels;
|
Voxel_DS* ds = (Voxel_DS*) myVoxels;
|
||||||
Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(),
|
Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user